feat(numbers): add number sequences store; restrict companysetting keys
- Add `numbers` store module with `list` and `update` methods backed by the `numbers` table (prefix, padding, next) per company. - Add sql queries LIST_BY_COMPANY, GET_BY_COMPANY_AND_ID, UPDATE_... - Regenerate and wire API docs for `numbers`. companysetting: - Remove the `delete` endpoint (settings are now upsert/read only). - Restrict `set` to a fixed allow-list of keys: ui.theme, keys.tavily, keys.openrouter, labelprinter.addr, labelprinter.type. - Drop DELETE_BY_COMPANY_AND_KEY sql and the delete store file. Docs: update README, API.md, API.companysetting.md, API.numbers.md.
This commit is contained in:
@@ -39,9 +39,3 @@ WHEN NOT MATCHED THEN
|
||||
INSERT (company_id, [key], value, frontend)
|
||||
VALUES (@companyId, @key, @value, @frontend);
|
||||
`;
|
||||
|
||||
export const DELETE_BY_COMPANY_AND_KEY = `
|
||||
DELETE FROM companysetting
|
||||
WHERE company_id = @companyId
|
||||
AND [key] = @key
|
||||
`;
|
||||
|
||||
@@ -9,3 +9,38 @@ BEGIN
|
||||
VALUES (@companyId, @type);
|
||||
END
|
||||
`;
|
||||
|
||||
export const LIST_BY_COMPANY = `
|
||||
SELECT
|
||||
id,
|
||||
[type],
|
||||
prefix,
|
||||
padding,
|
||||
[next] AS [next]
|
||||
FROM numbers
|
||||
WHERE company_id = @companyId
|
||||
ORDER BY [type]
|
||||
`;
|
||||
|
||||
export const GET_BY_COMPANY_AND_ID = `
|
||||
SELECT
|
||||
id,
|
||||
[type],
|
||||
prefix,
|
||||
padding,
|
||||
[next] AS [next]
|
||||
FROM numbers
|
||||
WHERE id = @id
|
||||
AND company_id = @companyId
|
||||
`;
|
||||
|
||||
export const UPDATE_BY_COMPANY_AND_ID = `
|
||||
UPDATE numbers
|
||||
SET
|
||||
prefix = @prefix,
|
||||
padding = @padding,
|
||||
[next] = @next
|
||||
OUTPUT INSERTED.id, INSERTED.[type], INSERTED.prefix, INSERTED.padding, INSERTED.[next]
|
||||
WHERE id = @id
|
||||
AND company_id = @companyId
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user