- 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.
42 lines
927 B
JavaScript
42 lines
927 B
JavaScript
export const LIST_BY_COMPANY = `
|
|
SELECT
|
|
[key],
|
|
value,
|
|
CAST(frontend AS INT) AS frontend
|
|
FROM companysetting
|
|
WHERE company_id = @companyId
|
|
ORDER BY [key]
|
|
`;
|
|
|
|
export const LIST_BY_COMPANY_FRONTEND = `
|
|
SELECT
|
|
[key],
|
|
value,
|
|
CAST(frontend AS INT) AS frontend
|
|
FROM companysetting
|
|
WHERE company_id = @companyId
|
|
AND frontend = 1
|
|
ORDER BY [key]
|
|
`;
|
|
|
|
export const GET_BY_COMPANY_AND_KEY = `
|
|
SELECT
|
|
[key],
|
|
value,
|
|
CAST(frontend AS INT) AS frontend
|
|
FROM companysetting
|
|
WHERE company_id = @companyId
|
|
AND [key] = @key
|
|
`;
|
|
|
|
export const UPSERT = `
|
|
MERGE companysetting AS target
|
|
USING (SELECT @companyId AS company_id, @key AS [key]) AS src
|
|
ON target.company_id = src.company_id AND target.[key] = src.[key]
|
|
WHEN MATCHED THEN
|
|
UPDATE SET value = @value, frontend = @frontend
|
|
WHEN NOT MATCHED THEN
|
|
INSERT (company_id, [key], value, frontend)
|
|
VALUES (@companyId, @key, @value, @frontend);
|
|
`;
|