@shipfox/api-secrets 4.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +45 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +29 -15
  6. package/dist/index.js.map +1 -1
  7. package/dist/presentation/inter-module.d.ts +4 -0
  8. package/dist/presentation/inter-module.d.ts.map +1 -0
  9. package/dist/presentation/inter-module.js +73 -0
  10. package/dist/presentation/inter-module.js.map +1 -0
  11. package/dist/presentation/routes/auth.d.ts +14 -10
  12. package/dist/presentation/routes/auth.d.ts.map +1 -1
  13. package/dist/presentation/routes/auth.js +27 -11
  14. package/dist/presentation/routes/auth.js.map +1 -1
  15. package/dist/presentation/routes/batch-secrets.d.ts +2 -1
  16. package/dist/presentation/routes/batch-secrets.d.ts.map +1 -1
  17. package/dist/presentation/routes/batch-secrets.js +35 -34
  18. package/dist/presentation/routes/batch-secrets.js.map +1 -1
  19. package/dist/presentation/routes/batch-variables.d.ts +2 -1
  20. package/dist/presentation/routes/batch-variables.d.ts.map +1 -1
  21. package/dist/presentation/routes/batch-variables.js +35 -34
  22. package/dist/presentation/routes/batch-variables.js.map +1 -1
  23. package/dist/presentation/routes/delete-secret.d.ts +2 -1
  24. package/dist/presentation/routes/delete-secret.d.ts.map +1 -1
  25. package/dist/presentation/routes/delete-secret.js +33 -32
  26. package/dist/presentation/routes/delete-secret.js.map +1 -1
  27. package/dist/presentation/routes/delete-variable.d.ts +2 -1
  28. package/dist/presentation/routes/delete-variable.d.ts.map +1 -1
  29. package/dist/presentation/routes/delete-variable.js +33 -32
  30. package/dist/presentation/routes/delete-variable.js.map +1 -1
  31. package/dist/presentation/routes/errors.d.ts.map +1 -1
  32. package/dist/presentation/routes/errors.js +0 -6
  33. package/dist/presentation/routes/errors.js.map +1 -1
  34. package/dist/presentation/routes/get-variable.d.ts +2 -1
  35. package/dist/presentation/routes/get-variable.d.ts.map +1 -1
  36. package/dist/presentation/routes/get-variable.js +34 -33
  37. package/dist/presentation/routes/get-variable.js.map +1 -1
  38. package/dist/presentation/routes/index.d.ts +2 -1
  39. package/dist/presentation/routes/index.d.ts.map +1 -1
  40. package/dist/presentation/routes/index.js +21 -17
  41. package/dist/presentation/routes/index.js.map +1 -1
  42. package/dist/presentation/routes/list-secrets.d.ts +2 -1
  43. package/dist/presentation/routes/list-secrets.d.ts.map +1 -1
  44. package/dist/presentation/routes/list-secrets.js +40 -39
  45. package/dist/presentation/routes/list-secrets.js.map +1 -1
  46. package/dist/presentation/routes/list-variables.d.ts +2 -1
  47. package/dist/presentation/routes/list-variables.d.ts.map +1 -1
  48. package/dist/presentation/routes/list-variables.js +40 -39
  49. package/dist/presentation/routes/list-variables.js.map +1 -1
  50. package/dist/presentation/routes/put-secret.d.ts +2 -1
  51. package/dist/presentation/routes/put-secret.d.ts.map +1 -1
  52. package/dist/presentation/routes/put-secret.js +43 -42
  53. package/dist/presentation/routes/put-secret.js.map +1 -1
  54. package/dist/presentation/routes/put-variable.d.ts +2 -1
  55. package/dist/presentation/routes/put-variable.d.ts.map +1 -1
  56. package/dist/presentation/routes/put-variable.js +43 -42
  57. package/dist/presentation/routes/put-variable.js.map +1 -1
  58. package/dist/tsconfig.test.tsbuildinfo +1 -1
  59. package/package.json +23 -36
  60. package/src/index.ts +16 -5
  61. package/src/presentation/inter-module.test.ts +32 -0
  62. package/src/presentation/inter-module.ts +78 -0
  63. package/src/presentation/routes/auth.ts +65 -19
  64. package/src/presentation/routes/batch-secrets.ts +26 -24
  65. package/src/presentation/routes/batch-variables.ts +26 -24
  66. package/src/presentation/routes/delete-secret.ts +21 -19
  67. package/src/presentation/routes/delete-variable.ts +21 -19
  68. package/src/presentation/routes/errors.ts +0 -5
  69. package/src/presentation/routes/get-variable.ts +21 -19
  70. package/src/presentation/routes/index.ts +22 -17
  71. package/src/presentation/routes/list-secrets.ts +33 -31
  72. package/src/presentation/routes/list-variables.ts +33 -31
  73. package/src/presentation/routes/management.test.ts +32 -18
  74. package/src/presentation/routes/put-secret.ts +28 -26
  75. package/src/presentation/routes/put-variable.ts +28 -26
  76. package/tsconfig.build.tsbuildinfo +1 -1
@@ -2,39 +2,40 @@ import { secretKeySchema, secretScopeQuerySchema } from '@shipfox/api-secrets-dt
2
2
  import { defineRoute } from '@shipfox/node-fastify';
3
3
  import { z } from 'zod';
4
4
  import { deleteManagedSecret } from '#core/index.js';
5
- import { requireManagementWrite } from './auth.js';
6
5
  import { translateManagementError } from './errors.js';
7
- export const deleteSecretRoute = defineRoute({
8
- method: 'DELETE',
9
- path: '/secrets/:key',
10
- description: 'Delete a user-managed secret.',
11
- schema: {
12
- params: z.object({
13
- workspaceId: z.string().uuid(),
14
- key: secretKeySchema
15
- }),
16
- querystring: secretScopeQuerySchema,
17
- response: {
18
- 204: z.void()
6
+ export function deleteSecretRoute(accessControl) {
7
+ return defineRoute({
8
+ method: 'DELETE',
9
+ path: '/secrets/:key',
10
+ description: 'Delete a user-managed secret.',
11
+ schema: {
12
+ params: z.object({
13
+ workspaceId: z.string().uuid(),
14
+ key: secretKeySchema
15
+ }),
16
+ querystring: secretScopeQuerySchema,
17
+ response: {
18
+ 204: z.void()
19
+ }
20
+ },
21
+ errorHandler: translateManagementError,
22
+ handler: async (request, reply)=>{
23
+ const { workspaceId, key } = request.params;
24
+ const { project_id: projectId } = request.query;
25
+ const access = await accessControl.requireManagementWrite({
26
+ request,
27
+ workspaceId,
28
+ projectId
29
+ });
30
+ await deleteManagedSecret({
31
+ workspaceId,
32
+ projectId,
33
+ key,
34
+ actorId: access.userId
35
+ });
36
+ return reply.status(204).send();
19
37
  }
20
- },
21
- errorHandler: translateManagementError,
22
- handler: async (request, reply)=>{
23
- const { workspaceId, key } = request.params;
24
- const { project_id: projectId } = request.query;
25
- const access = await requireManagementWrite({
26
- request,
27
- workspaceId,
28
- projectId
29
- });
30
- await deleteManagedSecret({
31
- workspaceId,
32
- projectId,
33
- key,
34
- actorId: access.userId
35
- });
36
- return reply.status(204).send();
37
- }
38
- });
38
+ });
39
+ }
39
40
 
40
41
  //# sourceMappingURL=delete-secret.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/presentation/routes/delete-secret.ts"],"sourcesContent":["import {secretKeySchema, secretScopeQuerySchema} from '@shipfox/api-secrets-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {deleteManagedSecret} from '#core/index.js';\nimport {requireManagementWrite} from './auth.js';\nimport {translateManagementError} from './errors.js';\n\nexport const deleteSecretRoute = defineRoute({\n method: 'DELETE',\n path: '/secrets/:key',\n description: 'Delete a user-managed secret.',\n schema: {\n params: z.object({workspaceId: z.string().uuid(), key: secretKeySchema}),\n querystring: secretScopeQuerySchema,\n response: {204: z.void()},\n },\n errorHandler: translateManagementError,\n handler: async (request, reply) => {\n const {workspaceId, key} = request.params;\n const {project_id: projectId} = request.query;\n const access = await requireManagementWrite({request, workspaceId, projectId});\n\n await deleteManagedSecret({workspaceId, projectId, key, actorId: access.userId});\n return reply.status(204).send();\n },\n});\n"],"names":["secretKeySchema","secretScopeQuerySchema","defineRoute","z","deleteManagedSecret","requireManagementWrite","translateManagementError","deleteSecretRoute","method","path","description","schema","params","object","workspaceId","string","uuid","key","querystring","response","void","errorHandler","handler","request","reply","project_id","projectId","query","access","actorId","userId","status","send"],"mappings":"AAAA,SAAQA,eAAe,EAAEC,sBAAsB,QAAO,2BAA2B;AACjF,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,mBAAmB,QAAO,iBAAiB;AACnD,SAAQC,sBAAsB,QAAO,YAAY;AACjD,SAAQC,wBAAwB,QAAO,cAAc;AAErD,OAAO,MAAMC,oBAAoBL,YAAY;IAC3CM,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,QAAQT,EAAEU,MAAM,CAAC;YAACC,aAAaX,EAAEY,MAAM,GAAGC,IAAI;YAAIC,KAAKjB;QAAe;QACtEkB,aAAajB;QACbkB,UAAU;YAAC,KAAKhB,EAAEiB,IAAI;QAAE;IAC1B;IACAC,cAAcf;IACdgB,SAAS,OAAOC,SAASC;QACvB,MAAM,EAACV,WAAW,EAAEG,GAAG,EAAC,GAAGM,QAAQX,MAAM;QACzC,MAAM,EAACa,YAAYC,SAAS,EAAC,GAAGH,QAAQI,KAAK;QAC7C,MAAMC,SAAS,MAAMvB,uBAAuB;YAACkB;YAAST;YAAaY;QAAS;QAE5E,MAAMtB,oBAAoB;YAACU;YAAaY;YAAWT;YAAKY,SAASD,OAAOE,MAAM;QAAA;QAC9E,OAAON,MAAMO,MAAM,CAAC,KAAKC,IAAI;IAC/B;AACF,GAAG"}
1
+ {"version":3,"sources":["../../../src/presentation/routes/delete-secret.ts"],"sourcesContent":["import {secretKeySchema, secretScopeQuerySchema} from '@shipfox/api-secrets-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {deleteManagedSecret} from '#core/index.js';\nimport type {ManagementAccessHelpers} from './auth.js';\nimport {translateManagementError} from './errors.js';\n\nexport function deleteSecretRoute(accessControl: ManagementAccessHelpers) {\n return defineRoute({\n method: 'DELETE',\n path: '/secrets/:key',\n description: 'Delete a user-managed secret.',\n schema: {\n params: z.object({workspaceId: z.string().uuid(), key: secretKeySchema}),\n querystring: secretScopeQuerySchema,\n response: {204: z.void()},\n },\n errorHandler: translateManagementError,\n handler: async (request, reply) => {\n const {workspaceId, key} = request.params;\n const {project_id: projectId} = request.query;\n const access = await accessControl.requireManagementWrite({request, workspaceId, projectId});\n\n await deleteManagedSecret({workspaceId, projectId, key, actorId: access.userId});\n return reply.status(204).send();\n },\n });\n}\n"],"names":["secretKeySchema","secretScopeQuerySchema","defineRoute","z","deleteManagedSecret","translateManagementError","deleteSecretRoute","accessControl","method","path","description","schema","params","object","workspaceId","string","uuid","key","querystring","response","void","errorHandler","handler","request","reply","project_id","projectId","query","access","requireManagementWrite","actorId","userId","status","send"],"mappings":"AAAA,SAAQA,eAAe,EAAEC,sBAAsB,QAAO,2BAA2B;AACjF,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,mBAAmB,QAAO,iBAAiB;AAEnD,SAAQC,wBAAwB,QAAO,cAAc;AAErD,OAAO,SAASC,kBAAkBC,aAAsC;IACtE,OAAOL,YAAY;QACjBM,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,QAAQT,EAAEU,MAAM,CAAC;gBAACC,aAAaX,EAAEY,MAAM,GAAGC,IAAI;gBAAIC,KAAKjB;YAAe;YACtEkB,aAAajB;YACbkB,UAAU;gBAAC,KAAKhB,EAAEiB,IAAI;YAAE;QAC1B;QACAC,cAAchB;QACdiB,SAAS,OAAOC,SAASC;YACvB,MAAM,EAACV,WAAW,EAAEG,GAAG,EAAC,GAAGM,QAAQX,MAAM;YACzC,MAAM,EAACa,YAAYC,SAAS,EAAC,GAAGH,QAAQI,KAAK;YAC7C,MAAMC,SAAS,MAAMrB,cAAcsB,sBAAsB,CAAC;gBAACN;gBAAST;gBAAaY;YAAS;YAE1F,MAAMtB,oBAAoB;gBAACU;gBAAaY;gBAAWT;gBAAKa,SAASF,OAAOG,MAAM;YAAA;YAC9E,OAAOP,MAAMQ,MAAM,CAAC,KAAKC,IAAI;QAC/B;IACF;AACF"}
@@ -1,2 +1,3 @@
1
- export declare const deleteVariableRoute: import("@shipfox/node-fastify").RouteDefinition;
1
+ import type { ManagementAccessHelpers } from './auth.js';
2
+ export declare function deleteVariableRoute(accessControl: ManagementAccessHelpers): import("@shipfox/node-fastify").RouteDefinition;
2
3
  //# sourceMappingURL=delete-variable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"delete-variable.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/delete-variable.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,mBAAmB,iDAkB9B,CAAC"}
1
+ {"version":3,"file":"delete-variable.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/delete-variable.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,WAAW,CAAC;AAGvD,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,uBAAuB,mDAoBzE"}
@@ -2,39 +2,40 @@ import { secretKeySchema, secretScopeQuerySchema } from '@shipfox/api-secrets-dt
2
2
  import { defineRoute } from '@shipfox/node-fastify';
3
3
  import { z } from 'zod';
4
4
  import { deleteManagedVariable } from '#core/index.js';
5
- import { requireManagementWrite } from './auth.js';
6
5
  import { translateManagementError } from './errors.js';
7
- export const deleteVariableRoute = defineRoute({
8
- method: 'DELETE',
9
- path: '/variables/:key',
10
- description: 'Delete a user-managed variable.',
11
- schema: {
12
- params: z.object({
13
- workspaceId: z.string().uuid(),
14
- key: secretKeySchema
15
- }),
16
- querystring: secretScopeQuerySchema,
17
- response: {
18
- 204: z.void()
6
+ export function deleteVariableRoute(accessControl) {
7
+ return defineRoute({
8
+ method: 'DELETE',
9
+ path: '/variables/:key',
10
+ description: 'Delete a user-managed variable.',
11
+ schema: {
12
+ params: z.object({
13
+ workspaceId: z.string().uuid(),
14
+ key: secretKeySchema
15
+ }),
16
+ querystring: secretScopeQuerySchema,
17
+ response: {
18
+ 204: z.void()
19
+ }
20
+ },
21
+ errorHandler: translateManagementError,
22
+ handler: async (request, reply)=>{
23
+ const { workspaceId, key } = request.params;
24
+ const { project_id: projectId } = request.query;
25
+ const access = await accessControl.requireManagementWrite({
26
+ request,
27
+ workspaceId,
28
+ projectId
29
+ });
30
+ await deleteManagedVariable({
31
+ workspaceId,
32
+ projectId,
33
+ key,
34
+ actorId: access.userId
35
+ });
36
+ return reply.status(204).send();
19
37
  }
20
- },
21
- errorHandler: translateManagementError,
22
- handler: async (request, reply)=>{
23
- const { workspaceId, key } = request.params;
24
- const { project_id: projectId } = request.query;
25
- const access = await requireManagementWrite({
26
- request,
27
- workspaceId,
28
- projectId
29
- });
30
- await deleteManagedVariable({
31
- workspaceId,
32
- projectId,
33
- key,
34
- actorId: access.userId
35
- });
36
- return reply.status(204).send();
37
- }
38
- });
38
+ });
39
+ }
39
40
 
40
41
  //# sourceMappingURL=delete-variable.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/presentation/routes/delete-variable.ts"],"sourcesContent":["import {secretKeySchema, secretScopeQuerySchema} from '@shipfox/api-secrets-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {deleteManagedVariable} from '#core/index.js';\nimport {requireManagementWrite} from './auth.js';\nimport {translateManagementError} from './errors.js';\n\nexport const deleteVariableRoute = defineRoute({\n method: 'DELETE',\n path: '/variables/:key',\n description: 'Delete a user-managed variable.',\n schema: {\n params: z.object({workspaceId: z.string().uuid(), key: secretKeySchema}),\n querystring: secretScopeQuerySchema,\n response: {204: z.void()},\n },\n errorHandler: translateManagementError,\n handler: async (request, reply) => {\n const {workspaceId, key} = request.params;\n const {project_id: projectId} = request.query;\n const access = await requireManagementWrite({request, workspaceId, projectId});\n\n await deleteManagedVariable({workspaceId, projectId, key, actorId: access.userId});\n return reply.status(204).send();\n },\n});\n"],"names":["secretKeySchema","secretScopeQuerySchema","defineRoute","z","deleteManagedVariable","requireManagementWrite","translateManagementError","deleteVariableRoute","method","path","description","schema","params","object","workspaceId","string","uuid","key","querystring","response","void","errorHandler","handler","request","reply","project_id","projectId","query","access","actorId","userId","status","send"],"mappings":"AAAA,SAAQA,eAAe,EAAEC,sBAAsB,QAAO,2BAA2B;AACjF,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,qBAAqB,QAAO,iBAAiB;AACrD,SAAQC,sBAAsB,QAAO,YAAY;AACjD,SAAQC,wBAAwB,QAAO,cAAc;AAErD,OAAO,MAAMC,sBAAsBL,YAAY;IAC7CM,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,QAAQT,EAAEU,MAAM,CAAC;YAACC,aAAaX,EAAEY,MAAM,GAAGC,IAAI;YAAIC,KAAKjB;QAAe;QACtEkB,aAAajB;QACbkB,UAAU;YAAC,KAAKhB,EAAEiB,IAAI;QAAE;IAC1B;IACAC,cAAcf;IACdgB,SAAS,OAAOC,SAASC;QACvB,MAAM,EAACV,WAAW,EAAEG,GAAG,EAAC,GAAGM,QAAQX,MAAM;QACzC,MAAM,EAACa,YAAYC,SAAS,EAAC,GAAGH,QAAQI,KAAK;QAC7C,MAAMC,SAAS,MAAMvB,uBAAuB;YAACkB;YAAST;YAAaY;QAAS;QAE5E,MAAMtB,sBAAsB;YAACU;YAAaY;YAAWT;YAAKY,SAASD,OAAOE,MAAM;QAAA;QAChF,OAAON,MAAMO,MAAM,CAAC,KAAKC,IAAI;IAC/B;AACF,GAAG"}
1
+ {"version":3,"sources":["../../../src/presentation/routes/delete-variable.ts"],"sourcesContent":["import {secretKeySchema, secretScopeQuerySchema} from '@shipfox/api-secrets-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {deleteManagedVariable} from '#core/index.js';\nimport type {ManagementAccessHelpers} from './auth.js';\nimport {translateManagementError} from './errors.js';\n\nexport function deleteVariableRoute(accessControl: ManagementAccessHelpers) {\n return defineRoute({\n method: 'DELETE',\n path: '/variables/:key',\n description: 'Delete a user-managed variable.',\n schema: {\n params: z.object({workspaceId: z.string().uuid(), key: secretKeySchema}),\n querystring: secretScopeQuerySchema,\n response: {204: z.void()},\n },\n errorHandler: translateManagementError,\n handler: async (request, reply) => {\n const {workspaceId, key} = request.params;\n const {project_id: projectId} = request.query;\n const access = await accessControl.requireManagementWrite({request, workspaceId, projectId});\n\n await deleteManagedVariable({workspaceId, projectId, key, actorId: access.userId});\n return reply.status(204).send();\n },\n });\n}\n"],"names":["secretKeySchema","secretScopeQuerySchema","defineRoute","z","deleteManagedVariable","translateManagementError","deleteVariableRoute","accessControl","method","path","description","schema","params","object","workspaceId","string","uuid","key","querystring","response","void","errorHandler","handler","request","reply","project_id","projectId","query","access","requireManagementWrite","actorId","userId","status","send"],"mappings":"AAAA,SAAQA,eAAe,EAAEC,sBAAsB,QAAO,2BAA2B;AACjF,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,qBAAqB,QAAO,iBAAiB;AAErD,SAAQC,wBAAwB,QAAO,cAAc;AAErD,OAAO,SAASC,oBAAoBC,aAAsC;IACxE,OAAOL,YAAY;QACjBM,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,QAAQT,EAAEU,MAAM,CAAC;gBAACC,aAAaX,EAAEY,MAAM,GAAGC,IAAI;gBAAIC,KAAKjB;YAAe;YACtEkB,aAAajB;YACbkB,UAAU;gBAAC,KAAKhB,EAAEiB,IAAI;YAAE;QAC1B;QACAC,cAAchB;QACdiB,SAAS,OAAOC,SAASC;YACvB,MAAM,EAACV,WAAW,EAAEG,GAAG,EAAC,GAAGM,QAAQX,MAAM;YACzC,MAAM,EAACa,YAAYC,SAAS,EAAC,GAAGH,QAAQI,KAAK;YAC7C,MAAMC,SAAS,MAAMrB,cAAcsB,sBAAsB,CAAC;gBAACN;gBAAST;gBAAaY;YAAS;YAE1F,MAAMtB,sBAAsB;gBAACU;gBAAaY;gBAAWT;gBAAKa,SAASF,OAAOG,MAAM;YAAA;YAChF,OAAOP,MAAMQ,MAAM,CAAC,KAAKC,IAAI;QAC/B;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/errors.ts"],"names":[],"mappings":"AAcA,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAgD9D"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/errors.ts"],"names":[],"mappings":"AAaA,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CA4C9D"}
@@ -1,4 +1,3 @@
1
- import { ProjectNotFoundError } from '@shipfox/api-projects';
2
1
  import { ClientError } from '@shipfox/node-fastify';
3
2
  import { NamespaceValidationError, SecretBatchDuplicateKeyError, SecretBatchScopeMismatchError, SecretKeyValidationError, SecretNotFoundError, SecretValueTooLargeError, UnknownSecretStoreError, VariableNotFoundError, WorkspaceSecretCapExceededError } from '#core/errors.js';
4
3
  export function translateManagementError(error) {
@@ -62,11 +61,6 @@ export function translateManagementError(error) {
62
61
  status: 400
63
62
  });
64
63
  }
65
- if (error instanceof ProjectNotFoundError) {
66
- throw new ClientError('Project not found', 'project-not-found', {
67
- status: 404
68
- });
69
- }
70
64
  throw error;
71
65
  }
72
66
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/presentation/routes/errors.ts"],"sourcesContent":["import {ProjectNotFoundError} from '@shipfox/api-projects';\nimport {ClientError} from '@shipfox/node-fastify';\nimport {\n NamespaceValidationError,\n SecretBatchDuplicateKeyError,\n SecretBatchScopeMismatchError,\n SecretKeyValidationError,\n SecretNotFoundError,\n SecretValueTooLargeError,\n UnknownSecretStoreError,\n VariableNotFoundError,\n WorkspaceSecretCapExceededError,\n} from '#core/errors.js';\n\nexport function translateManagementError(error: unknown): never {\n if (error instanceof SecretKeyValidationError) {\n throw new ClientError('Invalid secret key', 'invalid-key', {\n status: 400,\n details: {key: error.key},\n });\n }\n if (error instanceof NamespaceValidationError) {\n throw new ClientError('Invalid namespace', 'invalid-namespace', {\n status: 400,\n details: {namespace: error.namespace},\n });\n }\n if (error instanceof SecretValueTooLargeError) {\n throw new ClientError(error.message, 'value-too-large', {\n status: 413,\n details: {max_bytes: error.maxBytes},\n });\n }\n if (error instanceof WorkspaceSecretCapExceededError) {\n throw new ClientError('Workspace secret cap exceeded', 'workspace-secret-cap-exceeded', {\n status: 409,\n details: {cap: error.cap},\n });\n }\n if (error instanceof SecretBatchScopeMismatchError) {\n throw new ClientError(error.message, 'batch-scope-mismatch', {status: 400});\n }\n if (error instanceof SecretBatchDuplicateKeyError) {\n throw new ClientError('Duplicate batch key', 'duplicate-key', {\n status: 400,\n details: {key: error.key},\n });\n }\n if (error instanceof SecretNotFoundError) {\n throw new ClientError('Secret not found', 'secret-not-found', {status: 404});\n }\n if (error instanceof VariableNotFoundError) {\n throw new ClientError('Variable not found', 'variable-not-found', {status: 404});\n }\n if (error instanceof UnknownSecretStoreError) {\n throw new ClientError('Unknown secret store', 'unknown-secret-store', {status: 400});\n }\n if (error instanceof ProjectNotFoundError) {\n throw new ClientError('Project not found', 'project-not-found', {status: 404});\n }\n\n throw error;\n}\n"],"names":["ProjectNotFoundError","ClientError","NamespaceValidationError","SecretBatchDuplicateKeyError","SecretBatchScopeMismatchError","SecretKeyValidationError","SecretNotFoundError","SecretValueTooLargeError","UnknownSecretStoreError","VariableNotFoundError","WorkspaceSecretCapExceededError","translateManagementError","error","status","details","key","namespace","message","max_bytes","maxBytes","cap"],"mappings":"AAAA,SAAQA,oBAAoB,QAAO,wBAAwB;AAC3D,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SACEC,wBAAwB,EACxBC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,wBAAwB,EACxBC,mBAAmB,EACnBC,wBAAwB,EACxBC,uBAAuB,EACvBC,qBAAqB,EACrBC,+BAA+B,QAC1B,kBAAkB;AAEzB,OAAO,SAASC,yBAAyBC,KAAc;IACrD,IAAIA,iBAAiBP,0BAA0B;QAC7C,MAAM,IAAIJ,YAAY,sBAAsB,eAAe;YACzDY,QAAQ;YACRC,SAAS;gBAACC,KAAKH,MAAMG,GAAG;YAAA;QAC1B;IACF;IACA,IAAIH,iBAAiBV,0BAA0B;QAC7C,MAAM,IAAID,YAAY,qBAAqB,qBAAqB;YAC9DY,QAAQ;YACRC,SAAS;gBAACE,WAAWJ,MAAMI,SAAS;YAAA;QACtC;IACF;IACA,IAAIJ,iBAAiBL,0BAA0B;QAC7C,MAAM,IAAIN,YAAYW,MAAMK,OAAO,EAAE,mBAAmB;YACtDJ,QAAQ;YACRC,SAAS;gBAACI,WAAWN,MAAMO,QAAQ;YAAA;QACrC;IACF;IACA,IAAIP,iBAAiBF,iCAAiC;QACpD,MAAM,IAAIT,YAAY,iCAAiC,iCAAiC;YACtFY,QAAQ;YACRC,SAAS;gBAACM,KAAKR,MAAMQ,GAAG;YAAA;QAC1B;IACF;IACA,IAAIR,iBAAiBR,+BAA+B;QAClD,MAAM,IAAIH,YAAYW,MAAMK,OAAO,EAAE,wBAAwB;YAACJ,QAAQ;QAAG;IAC3E;IACA,IAAID,iBAAiBT,8BAA8B;QACjD,MAAM,IAAIF,YAAY,uBAAuB,iBAAiB;YAC5DY,QAAQ;YACRC,SAAS;gBAACC,KAAKH,MAAMG,GAAG;YAAA;QAC1B;IACF;IACA,IAAIH,iBAAiBN,qBAAqB;QACxC,MAAM,IAAIL,YAAY,oBAAoB,oBAAoB;YAACY,QAAQ;QAAG;IAC5E;IACA,IAAID,iBAAiBH,uBAAuB;QAC1C,MAAM,IAAIR,YAAY,sBAAsB,sBAAsB;YAACY,QAAQ;QAAG;IAChF;IACA,IAAID,iBAAiBJ,yBAAyB;QAC5C,MAAM,IAAIP,YAAY,wBAAwB,wBAAwB;YAACY,QAAQ;QAAG;IACpF;IACA,IAAID,iBAAiBZ,sBAAsB;QACzC,MAAM,IAAIC,YAAY,qBAAqB,qBAAqB;YAACY,QAAQ;QAAG;IAC9E;IAEA,MAAMD;AACR"}
1
+ {"version":3,"sources":["../../../src/presentation/routes/errors.ts"],"sourcesContent":["import {ClientError} from '@shipfox/node-fastify';\nimport {\n NamespaceValidationError,\n SecretBatchDuplicateKeyError,\n SecretBatchScopeMismatchError,\n SecretKeyValidationError,\n SecretNotFoundError,\n SecretValueTooLargeError,\n UnknownSecretStoreError,\n VariableNotFoundError,\n WorkspaceSecretCapExceededError,\n} from '#core/errors.js';\n\nexport function translateManagementError(error: unknown): never {\n if (error instanceof SecretKeyValidationError) {\n throw new ClientError('Invalid secret key', 'invalid-key', {\n status: 400,\n details: {key: error.key},\n });\n }\n if (error instanceof NamespaceValidationError) {\n throw new ClientError('Invalid namespace', 'invalid-namespace', {\n status: 400,\n details: {namespace: error.namespace},\n });\n }\n if (error instanceof SecretValueTooLargeError) {\n throw new ClientError(error.message, 'value-too-large', {\n status: 413,\n details: {max_bytes: error.maxBytes},\n });\n }\n if (error instanceof WorkspaceSecretCapExceededError) {\n throw new ClientError('Workspace secret cap exceeded', 'workspace-secret-cap-exceeded', {\n status: 409,\n details: {cap: error.cap},\n });\n }\n if (error instanceof SecretBatchScopeMismatchError) {\n throw new ClientError(error.message, 'batch-scope-mismatch', {status: 400});\n }\n if (error instanceof SecretBatchDuplicateKeyError) {\n throw new ClientError('Duplicate batch key', 'duplicate-key', {\n status: 400,\n details: {key: error.key},\n });\n }\n if (error instanceof SecretNotFoundError) {\n throw new ClientError('Secret not found', 'secret-not-found', {status: 404});\n }\n if (error instanceof VariableNotFoundError) {\n throw new ClientError('Variable not found', 'variable-not-found', {status: 404});\n }\n if (error instanceof UnknownSecretStoreError) {\n throw new ClientError('Unknown secret store', 'unknown-secret-store', {status: 400});\n }\n throw error;\n}\n"],"names":["ClientError","NamespaceValidationError","SecretBatchDuplicateKeyError","SecretBatchScopeMismatchError","SecretKeyValidationError","SecretNotFoundError","SecretValueTooLargeError","UnknownSecretStoreError","VariableNotFoundError","WorkspaceSecretCapExceededError","translateManagementError","error","status","details","key","namespace","message","max_bytes","maxBytes","cap"],"mappings":"AAAA,SAAQA,WAAW,QAAO,wBAAwB;AAClD,SACEC,wBAAwB,EACxBC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,wBAAwB,EACxBC,mBAAmB,EACnBC,wBAAwB,EACxBC,uBAAuB,EACvBC,qBAAqB,EACrBC,+BAA+B,QAC1B,kBAAkB;AAEzB,OAAO,SAASC,yBAAyBC,KAAc;IACrD,IAAIA,iBAAiBP,0BAA0B;QAC7C,MAAM,IAAIJ,YAAY,sBAAsB,eAAe;YACzDY,QAAQ;YACRC,SAAS;gBAACC,KAAKH,MAAMG,GAAG;YAAA;QAC1B;IACF;IACA,IAAIH,iBAAiBV,0BAA0B;QAC7C,MAAM,IAAID,YAAY,qBAAqB,qBAAqB;YAC9DY,QAAQ;YACRC,SAAS;gBAACE,WAAWJ,MAAMI,SAAS;YAAA;QACtC;IACF;IACA,IAAIJ,iBAAiBL,0BAA0B;QAC7C,MAAM,IAAIN,YAAYW,MAAMK,OAAO,EAAE,mBAAmB;YACtDJ,QAAQ;YACRC,SAAS;gBAACI,WAAWN,MAAMO,QAAQ;YAAA;QACrC;IACF;IACA,IAAIP,iBAAiBF,iCAAiC;QACpD,MAAM,IAAIT,YAAY,iCAAiC,iCAAiC;YACtFY,QAAQ;YACRC,SAAS;gBAACM,KAAKR,MAAMQ,GAAG;YAAA;QAC1B;IACF;IACA,IAAIR,iBAAiBR,+BAA+B;QAClD,MAAM,IAAIH,YAAYW,MAAMK,OAAO,EAAE,wBAAwB;YAACJ,QAAQ;QAAG;IAC3E;IACA,IAAID,iBAAiBT,8BAA8B;QACjD,MAAM,IAAIF,YAAY,uBAAuB,iBAAiB;YAC5DY,QAAQ;YACRC,SAAS;gBAACC,KAAKH,MAAMG,GAAG;YAAA;QAC1B;IACF;IACA,IAAIH,iBAAiBN,qBAAqB;QACxC,MAAM,IAAIL,YAAY,oBAAoB,oBAAoB;YAACY,QAAQ;QAAG;IAC5E;IACA,IAAID,iBAAiBH,uBAAuB;QAC1C,MAAM,IAAIR,YAAY,sBAAsB,sBAAsB;YAACY,QAAQ;QAAG;IAChF;IACA,IAAID,iBAAiBJ,yBAAyB;QAC5C,MAAM,IAAIP,YAAY,wBAAwB,wBAAwB;YAACY,QAAQ;QAAG;IACpF;IACA,MAAMD;AACR"}
@@ -1,2 +1,3 @@
1
- export declare const getVariableRoute: import("@shipfox/node-fastify").RouteDefinition;
1
+ import type { ManagementAccessHelpers } from './auth.js';
2
+ export declare function getVariableRoute(accessControl: ManagementAccessHelpers): import("@shipfox/node-fastify").RouteDefinition;
2
3
  //# sourceMappingURL=get-variable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-variable.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-variable.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,gBAAgB,iDAmB3B,CAAC"}
1
+ {"version":3,"file":"get-variable.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-variable.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,WAAW,CAAC;AAGvD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,uBAAuB,mDAqBtE"}
@@ -3,40 +3,41 @@ import { defineRoute } from '@shipfox/node-fastify';
3
3
  import { z } from 'zod';
4
4
  import { getManagedVariable } from '#core/index.js';
5
5
  import { toVariableDto } from '#presentation/dto/index.js';
6
- import { requireManagementRead } from './auth.js';
7
6
  import { translateManagementError } from './errors.js';
8
- export const getVariableRoute = defineRoute({
9
- method: 'GET',
10
- path: '/variables/:key',
11
- description: 'Read a user-managed variable.',
12
- schema: {
13
- params: z.object({
14
- workspaceId: z.string().uuid(),
15
- key: secretKeySchema
16
- }),
17
- querystring: secretScopeQuerySchema,
18
- response: {
19
- 200: getVariableResponseSchema
7
+ export function getVariableRoute(accessControl) {
8
+ return defineRoute({
9
+ method: 'GET',
10
+ path: '/variables/:key',
11
+ description: 'Read a user-managed variable.',
12
+ schema: {
13
+ params: z.object({
14
+ workspaceId: z.string().uuid(),
15
+ key: secretKeySchema
16
+ }),
17
+ querystring: secretScopeQuerySchema,
18
+ response: {
19
+ 200: getVariableResponseSchema
20
+ }
21
+ },
22
+ errorHandler: translateManagementError,
23
+ handler: async (request)=>{
24
+ const { workspaceId, key } = request.params;
25
+ const { project_id: projectId } = request.query;
26
+ await accessControl.requireManagementRead({
27
+ request,
28
+ workspaceId,
29
+ projectId
30
+ });
31
+ const variable = await getManagedVariable({
32
+ workspaceId,
33
+ projectId,
34
+ key
35
+ });
36
+ return {
37
+ variable: toVariableDto(variable)
38
+ };
20
39
  }
21
- },
22
- errorHandler: translateManagementError,
23
- handler: async (request)=>{
24
- const { workspaceId, key } = request.params;
25
- const { project_id: projectId } = request.query;
26
- await requireManagementRead({
27
- request,
28
- workspaceId,
29
- projectId
30
- });
31
- const variable = await getManagedVariable({
32
- workspaceId,
33
- projectId,
34
- key
35
- });
36
- return {
37
- variable: toVariableDto(variable)
38
- };
39
- }
40
- });
40
+ });
41
+ }
41
42
 
42
43
  //# sourceMappingURL=get-variable.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/presentation/routes/get-variable.ts"],"sourcesContent":["import {\n getVariableResponseSchema,\n secretKeySchema,\n secretScopeQuerySchema,\n} from '@shipfox/api-secrets-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {getManagedVariable} from '#core/index.js';\nimport {toVariableDto} from '#presentation/dto/index.js';\nimport {requireManagementRead} from './auth.js';\nimport {translateManagementError} from './errors.js';\n\nexport const getVariableRoute = defineRoute({\n method: 'GET',\n path: '/variables/:key',\n description: 'Read a user-managed variable.',\n schema: {\n params: z.object({workspaceId: z.string().uuid(), key: secretKeySchema}),\n querystring: secretScopeQuerySchema,\n response: {200: getVariableResponseSchema},\n },\n errorHandler: translateManagementError,\n handler: async (request) => {\n const {workspaceId, key} = request.params;\n const {project_id: projectId} = request.query;\n\n await requireManagementRead({request, workspaceId, projectId});\n const variable = await getManagedVariable({workspaceId, projectId, key});\n\n return {variable: toVariableDto(variable)};\n },\n});\n"],"names":["getVariableResponseSchema","secretKeySchema","secretScopeQuerySchema","defineRoute","z","getManagedVariable","toVariableDto","requireManagementRead","translateManagementError","getVariableRoute","method","path","description","schema","params","object","workspaceId","string","uuid","key","querystring","response","errorHandler","handler","request","project_id","projectId","query","variable"],"mappings":"AAAA,SACEA,yBAAyB,EACzBC,eAAe,EACfC,sBAAsB,QACjB,2BAA2B;AAClC,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,kBAAkB,QAAO,iBAAiB;AAClD,SAAQC,aAAa,QAAO,6BAA6B;AACzD,SAAQC,qBAAqB,QAAO,YAAY;AAChD,SAAQC,wBAAwB,QAAO,cAAc;AAErD,OAAO,MAAMC,mBAAmBN,YAAY;IAC1CO,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,QAAQV,EAAEW,MAAM,CAAC;YAACC,aAAaZ,EAAEa,MAAM,GAAGC,IAAI;YAAIC,KAAKlB;QAAe;QACtEmB,aAAalB;QACbmB,UAAU;YAAC,KAAKrB;QAAyB;IAC3C;IACAsB,cAAcd;IACde,SAAS,OAAOC;QACd,MAAM,EAACR,WAAW,EAAEG,GAAG,EAAC,GAAGK,QAAQV,MAAM;QACzC,MAAM,EAACW,YAAYC,SAAS,EAAC,GAAGF,QAAQG,KAAK;QAE7C,MAAMpB,sBAAsB;YAACiB;YAASR;YAAaU;QAAS;QAC5D,MAAME,WAAW,MAAMvB,mBAAmB;YAACW;YAAaU;YAAWP;QAAG;QAEtE,OAAO;YAACS,UAAUtB,cAAcsB;QAAS;IAC3C;AACF,GAAG"}
1
+ {"version":3,"sources":["../../../src/presentation/routes/get-variable.ts"],"sourcesContent":["import {\n getVariableResponseSchema,\n secretKeySchema,\n secretScopeQuerySchema,\n} from '@shipfox/api-secrets-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {getManagedVariable} from '#core/index.js';\nimport {toVariableDto} from '#presentation/dto/index.js';\nimport type {ManagementAccessHelpers} from './auth.js';\nimport {translateManagementError} from './errors.js';\n\nexport function getVariableRoute(accessControl: ManagementAccessHelpers) {\n return defineRoute({\n method: 'GET',\n path: '/variables/:key',\n description: 'Read a user-managed variable.',\n schema: {\n params: z.object({workspaceId: z.string().uuid(), key: secretKeySchema}),\n querystring: secretScopeQuerySchema,\n response: {200: getVariableResponseSchema},\n },\n errorHandler: translateManagementError,\n handler: async (request) => {\n const {workspaceId, key} = request.params;\n const {project_id: projectId} = request.query;\n\n await accessControl.requireManagementRead({request, workspaceId, projectId});\n const variable = await getManagedVariable({workspaceId, projectId, key});\n\n return {variable: toVariableDto(variable)};\n },\n });\n}\n"],"names":["getVariableResponseSchema","secretKeySchema","secretScopeQuerySchema","defineRoute","z","getManagedVariable","toVariableDto","translateManagementError","getVariableRoute","accessControl","method","path","description","schema","params","object","workspaceId","string","uuid","key","querystring","response","errorHandler","handler","request","project_id","projectId","query","requireManagementRead","variable"],"mappings":"AAAA,SACEA,yBAAyB,EACzBC,eAAe,EACfC,sBAAsB,QACjB,2BAA2B;AAClC,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,kBAAkB,QAAO,iBAAiB;AAClD,SAAQC,aAAa,QAAO,6BAA6B;AAEzD,SAAQC,wBAAwB,QAAO,cAAc;AAErD,OAAO,SAASC,iBAAiBC,aAAsC;IACrE,OAAON,YAAY;QACjBO,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,QAAQV,EAAEW,MAAM,CAAC;gBAACC,aAAaZ,EAAEa,MAAM,GAAGC,IAAI;gBAAIC,KAAKlB;YAAe;YACtEmB,aAAalB;YACbmB,UAAU;gBAAC,KAAKrB;YAAyB;QAC3C;QACAsB,cAAcf;QACdgB,SAAS,OAAOC;YACd,MAAM,EAACR,WAAW,EAAEG,GAAG,EAAC,GAAGK,QAAQV,MAAM;YACzC,MAAM,EAACW,YAAYC,SAAS,EAAC,GAAGF,QAAQG,KAAK;YAE7C,MAAMlB,cAAcmB,qBAAqB,CAAC;gBAACJ;gBAASR;gBAAaU;YAAS;YAC1E,MAAMG,WAAW,MAAMxB,mBAAmB;gBAACW;gBAAaU;gBAAWP;YAAG;YAEtE,OAAO;gBAACU,UAAUvB,cAAcuB;YAAS;QAC3C;IACF;AACF"}
@@ -1,3 +1,4 @@
1
+ import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
1
2
  import type { RouteGroup } from '@shipfox/node-fastify';
2
- export declare const secretsRoutes: RouteGroup[];
3
+ export declare function createSecretsRoutes(projects: ProjectsModuleClient): RouteGroup[];
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAWtD,eAAO,MAAM,aAAa,EAAE,UAAU,EAgBrC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAYtD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,UAAU,EAAE,CAmBhF"}
@@ -1,4 +1,5 @@
1
1
  import { AUTH_USER } from '@shipfox/api-auth-context';
2
+ import { createManagementAccess } from './auth.js';
2
3
  import { batchSecretsRoute } from './batch-secrets.js';
3
4
  import { batchVariablesRoute } from './batch-variables.js';
4
5
  import { deleteSecretRoute } from './delete-secret.js';
@@ -8,22 +9,25 @@ import { listSecretsRoute } from './list-secrets.js';
8
9
  import { listVariablesRoute } from './list-variables.js';
9
10
  import { putSecretRoute } from './put-secret.js';
10
11
  import { putVariableRoute } from './put-variable.js';
11
- export const secretsRoutes = [
12
- {
13
- prefix: '/workspaces/:workspaceId',
14
- auth: AUTH_USER,
15
- routes: [
16
- listSecretsRoute,
17
- putSecretRoute,
18
- batchSecretsRoute,
19
- deleteSecretRoute,
20
- listVariablesRoute,
21
- getVariableRoute,
22
- putVariableRoute,
23
- batchVariablesRoute,
24
- deleteVariableRoute
25
- ]
26
- }
27
- ];
12
+ export function createSecretsRoutes(projects) {
13
+ const access = createManagementAccess(projects);
14
+ return [
15
+ {
16
+ prefix: '/workspaces/:workspaceId',
17
+ auth: AUTH_USER,
18
+ routes: [
19
+ listSecretsRoute(access),
20
+ putSecretRoute(access),
21
+ batchSecretsRoute(access),
22
+ deleteSecretRoute(access),
23
+ listVariablesRoute(access),
24
+ getVariableRoute(access),
25
+ putVariableRoute(access),
26
+ batchVariablesRoute(access),
27
+ deleteVariableRoute(access)
28
+ ]
29
+ }
30
+ ];
31
+ }
28
32
 
29
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/presentation/routes/index.ts"],"sourcesContent":["import {AUTH_USER} from '@shipfox/api-auth-context';\nimport type {RouteGroup} from '@shipfox/node-fastify';\nimport {batchSecretsRoute} from './batch-secrets.js';\nimport {batchVariablesRoute} from './batch-variables.js';\nimport {deleteSecretRoute} from './delete-secret.js';\nimport {deleteVariableRoute} from './delete-variable.js';\nimport {getVariableRoute} from './get-variable.js';\nimport {listSecretsRoute} from './list-secrets.js';\nimport {listVariablesRoute} from './list-variables.js';\nimport {putSecretRoute} from './put-secret.js';\nimport {putVariableRoute} from './put-variable.js';\n\nexport const secretsRoutes: RouteGroup[] = [\n {\n prefix: '/workspaces/:workspaceId',\n auth: AUTH_USER,\n routes: [\n listSecretsRoute,\n putSecretRoute,\n batchSecretsRoute,\n deleteSecretRoute,\n listVariablesRoute,\n getVariableRoute,\n putVariableRoute,\n batchVariablesRoute,\n deleteVariableRoute,\n ],\n },\n];\n"],"names":["AUTH_USER","batchSecretsRoute","batchVariablesRoute","deleteSecretRoute","deleteVariableRoute","getVariableRoute","listSecretsRoute","listVariablesRoute","putSecretRoute","putVariableRoute","secretsRoutes","prefix","auth","routes"],"mappings":"AAAA,SAAQA,SAAS,QAAO,4BAA4B;AAEpD,SAAQC,iBAAiB,QAAO,qBAAqB;AACrD,SAAQC,mBAAmB,QAAO,uBAAuB;AACzD,SAAQC,iBAAiB,QAAO,qBAAqB;AACrD,SAAQC,mBAAmB,QAAO,uBAAuB;AACzD,SAAQC,gBAAgB,QAAO,oBAAoB;AACnD,SAAQC,gBAAgB,QAAO,oBAAoB;AACnD,SAAQC,kBAAkB,QAAO,sBAAsB;AACvD,SAAQC,cAAc,QAAO,kBAAkB;AAC/C,SAAQC,gBAAgB,QAAO,oBAAoB;AAEnD,OAAO,MAAMC,gBAA8B;IACzC;QACEC,QAAQ;QACRC,MAAMZ;QACNa,QAAQ;YACNP;YACAE;YACAP;YACAE;YACAI;YACAF;YACAI;YACAP;YACAE;SACD;IACH;CACD,CAAC"}
1
+ {"version":3,"sources":["../../../src/presentation/routes/index.ts"],"sourcesContent":["import {AUTH_USER} from '@shipfox/api-auth-context';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport type {RouteGroup} from '@shipfox/node-fastify';\nimport {createManagementAccess} from './auth.js';\nimport {batchSecretsRoute} from './batch-secrets.js';\nimport {batchVariablesRoute} from './batch-variables.js';\nimport {deleteSecretRoute} from './delete-secret.js';\nimport {deleteVariableRoute} from './delete-variable.js';\nimport {getVariableRoute} from './get-variable.js';\nimport {listSecretsRoute} from './list-secrets.js';\nimport {listVariablesRoute} from './list-variables.js';\nimport {putSecretRoute} from './put-secret.js';\nimport {putVariableRoute} from './put-variable.js';\n\nexport function createSecretsRoutes(projects: ProjectsModuleClient): RouteGroup[] {\n const access = createManagementAccess(projects);\n return [\n {\n prefix: '/workspaces/:workspaceId',\n auth: AUTH_USER,\n routes: [\n listSecretsRoute(access),\n putSecretRoute(access),\n batchSecretsRoute(access),\n deleteSecretRoute(access),\n listVariablesRoute(access),\n getVariableRoute(access),\n putVariableRoute(access),\n batchVariablesRoute(access),\n deleteVariableRoute(access),\n ],\n },\n ];\n}\n"],"names":["AUTH_USER","createManagementAccess","batchSecretsRoute","batchVariablesRoute","deleteSecretRoute","deleteVariableRoute","getVariableRoute","listSecretsRoute","listVariablesRoute","putSecretRoute","putVariableRoute","createSecretsRoutes","projects","access","prefix","auth","routes"],"mappings":"AAAA,SAAQA,SAAS,QAAO,4BAA4B;AAGpD,SAAQC,sBAAsB,QAAO,YAAY;AACjD,SAAQC,iBAAiB,QAAO,qBAAqB;AACrD,SAAQC,mBAAmB,QAAO,uBAAuB;AACzD,SAAQC,iBAAiB,QAAO,qBAAqB;AACrD,SAAQC,mBAAmB,QAAO,uBAAuB;AACzD,SAAQC,gBAAgB,QAAO,oBAAoB;AACnD,SAAQC,gBAAgB,QAAO,oBAAoB;AACnD,SAAQC,kBAAkB,QAAO,sBAAsB;AACvD,SAAQC,cAAc,QAAO,kBAAkB;AAC/C,SAAQC,gBAAgB,QAAO,oBAAoB;AAEnD,OAAO,SAASC,oBAAoBC,QAA8B;IAChE,MAAMC,SAASZ,uBAAuBW;IACtC,OAAO;QACL;YACEE,QAAQ;YACRC,MAAMf;YACNgB,QAAQ;gBACNT,iBAAiBM;gBACjBJ,eAAeI;gBACfX,kBAAkBW;gBAClBT,kBAAkBS;gBAClBL,mBAAmBK;gBACnBP,iBAAiBO;gBACjBH,iBAAiBG;gBACjBV,oBAAoBU;gBACpBR,oBAAoBQ;aACrB;QACH;KACD;AACH"}
@@ -1,2 +1,3 @@
1
- export declare const listSecretsRoute: import("@shipfox/node-fastify").RouteDefinition;
1
+ import type { ManagementAccessHelpers } from './auth.js';
2
+ export declare function listSecretsRoute(accessControl: ManagementAccessHelpers): import("@shipfox/node-fastify").RouteDefinition;
2
3
  //# sourceMappingURL=list-secrets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list-secrets.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-secrets.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,gBAAgB,iDA+B3B,CAAC"}
1
+ {"version":3,"file":"list-secrets.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-secrets.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,WAAW,CAAC;AAIvD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,uBAAuB,mDAiCtE"}
@@ -3,48 +3,49 @@ import { ClientError, defineRoute } from '@shipfox/node-fastify';
3
3
  import { z } from 'zod';
4
4
  import { listManagedSecrets } from '#core/index.js';
5
5
  import { toSecretDto } from '#presentation/dto/index.js';
6
- import { requireManagementRead } from './auth.js';
7
6
  import { decodeManagementCursor, encodeManagementCursor } from './cursor.js';
8
7
  import { translateManagementError } from './errors.js';
9
- export const listSecretsRoute = defineRoute({
10
- method: 'GET',
11
- path: '/secrets',
12
- description: 'List user-managed secrets for a workspace or project scope.',
13
- schema: {
14
- params: z.object({
15
- workspaceId: z.string().uuid()
16
- }),
17
- querystring: listSecretsQuerySchema,
18
- response: {
19
- 200: listSecretsResponseSchema
20
- }
21
- },
22
- errorHandler: translateManagementError,
23
- handler: async (request)=>{
24
- const { workspaceId } = request.params;
25
- const { project_id: projectId, limit, cursor } = request.query;
26
- const decodedCursor = decodeManagementCursor(cursor);
27
- if (cursor && !decodedCursor) {
28
- throw new ClientError('Invalid cursor', 'invalid-cursor', {
29
- status: 400
8
+ export function listSecretsRoute(accessControl) {
9
+ return defineRoute({
10
+ method: 'GET',
11
+ path: '/secrets',
12
+ description: 'List user-managed secrets for a workspace or project scope.',
13
+ schema: {
14
+ params: z.object({
15
+ workspaceId: z.string().uuid()
16
+ }),
17
+ querystring: listSecretsQuerySchema,
18
+ response: {
19
+ 200: listSecretsResponseSchema
20
+ }
21
+ },
22
+ errorHandler: translateManagementError,
23
+ handler: async (request)=>{
24
+ const { workspaceId } = request.params;
25
+ const { project_id: projectId, limit, cursor } = request.query;
26
+ const decodedCursor = decodeManagementCursor(cursor);
27
+ if (cursor && !decodedCursor) {
28
+ throw new ClientError('Invalid cursor', 'invalid-cursor', {
29
+ status: 400
30
+ });
31
+ }
32
+ await accessControl.requireManagementRead({
33
+ request,
34
+ workspaceId,
35
+ projectId
36
+ });
37
+ const result = await listManagedSecrets({
38
+ workspaceId,
39
+ projectId,
40
+ limit,
41
+ cursor: decodedCursor ?? undefined
30
42
  });
43
+ return {
44
+ secrets: result.secrets.map(toSecretDto),
45
+ next_cursor: result.nextCursor ? encodeManagementCursor(result.nextCursor) : null
46
+ };
31
47
  }
32
- await requireManagementRead({
33
- request,
34
- workspaceId,
35
- projectId
36
- });
37
- const result = await listManagedSecrets({
38
- workspaceId,
39
- projectId,
40
- limit,
41
- cursor: decodedCursor ?? undefined
42
- });
43
- return {
44
- secrets: result.secrets.map(toSecretDto),
45
- next_cursor: result.nextCursor ? encodeManagementCursor(result.nextCursor) : null
46
- };
47
- }
48
- });
48
+ });
49
+ }
49
50
 
50
51
  //# sourceMappingURL=list-secrets.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/presentation/routes/list-secrets.ts"],"sourcesContent":["import {listSecretsQuerySchema, listSecretsResponseSchema} from '@shipfox/api-secrets-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {listManagedSecrets} from '#core/index.js';\nimport {toSecretDto} from '#presentation/dto/index.js';\nimport {requireManagementRead} from './auth.js';\nimport {decodeManagementCursor, encodeManagementCursor} from './cursor.js';\nimport {translateManagementError} from './errors.js';\n\nexport const listSecretsRoute = defineRoute({\n method: 'GET',\n path: '/secrets',\n description: 'List user-managed secrets for a workspace or project scope.',\n schema: {\n params: z.object({workspaceId: z.string().uuid()}),\n querystring: listSecretsQuerySchema,\n response: {200: listSecretsResponseSchema},\n },\n errorHandler: translateManagementError,\n handler: async (request) => {\n const {workspaceId} = request.params;\n const {project_id: projectId, limit, cursor} = request.query;\n const decodedCursor = decodeManagementCursor(cursor);\n if (cursor && !decodedCursor) {\n throw new ClientError('Invalid cursor', 'invalid-cursor', {status: 400});\n }\n\n await requireManagementRead({request, workspaceId, projectId});\n const result = await listManagedSecrets({\n workspaceId,\n projectId,\n limit,\n cursor: decodedCursor ?? undefined,\n });\n\n return {\n secrets: result.secrets.map(toSecretDto),\n next_cursor: result.nextCursor ? encodeManagementCursor(result.nextCursor) : null,\n };\n },\n});\n"],"names":["listSecretsQuerySchema","listSecretsResponseSchema","ClientError","defineRoute","z","listManagedSecrets","toSecretDto","requireManagementRead","decodeManagementCursor","encodeManagementCursor","translateManagementError","listSecretsRoute","method","path","description","schema","params","object","workspaceId","string","uuid","querystring","response","errorHandler","handler","request","project_id","projectId","limit","cursor","query","decodedCursor","status","result","undefined","secrets","map","next_cursor","nextCursor"],"mappings":"AAAA,SAAQA,sBAAsB,EAAEC,yBAAyB,QAAO,2BAA2B;AAC3F,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,kBAAkB,QAAO,iBAAiB;AAClD,SAAQC,WAAW,QAAO,6BAA6B;AACvD,SAAQC,qBAAqB,QAAO,YAAY;AAChD,SAAQC,sBAAsB,EAAEC,sBAAsB,QAAO,cAAc;AAC3E,SAAQC,wBAAwB,QAAO,cAAc;AAErD,OAAO,MAAMC,mBAAmBR,YAAY;IAC1CS,QAAQ;IACRC,MAAM;IACNC,aAAa;IACbC,QAAQ;QACNC,QAAQZ,EAAEa,MAAM,CAAC;YAACC,aAAad,EAAEe,MAAM,GAAGC,IAAI;QAAE;QAChDC,aAAarB;QACbsB,UAAU;YAAC,KAAKrB;QAAyB;IAC3C;IACAsB,cAAcb;IACdc,SAAS,OAAOC;QACd,MAAM,EAACP,WAAW,EAAC,GAAGO,QAAQT,MAAM;QACpC,MAAM,EAACU,YAAYC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAC,GAAGJ,QAAQK,KAAK;QAC5D,MAAMC,gBAAgBvB,uBAAuBqB;QAC7C,IAAIA,UAAU,CAACE,eAAe;YAC5B,MAAM,IAAI7B,YAAY,kBAAkB,kBAAkB;gBAAC8B,QAAQ;YAAG;QACxE;QAEA,MAAMzB,sBAAsB;YAACkB;YAASP;YAAaS;QAAS;QAC5D,MAAMM,SAAS,MAAM5B,mBAAmB;YACtCa;YACAS;YACAC;YACAC,QAAQE,iBAAiBG;QAC3B;QAEA,OAAO;YACLC,SAASF,OAAOE,OAAO,CAACC,GAAG,CAAC9B;YAC5B+B,aAAaJ,OAAOK,UAAU,GAAG7B,uBAAuBwB,OAAOK,UAAU,IAAI;QAC/E;IACF;AACF,GAAG"}
1
+ {"version":3,"sources":["../../../src/presentation/routes/list-secrets.ts"],"sourcesContent":["import {listSecretsQuerySchema, listSecretsResponseSchema} from '@shipfox/api-secrets-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {listManagedSecrets} from '#core/index.js';\nimport {toSecretDto} from '#presentation/dto/index.js';\nimport type {ManagementAccessHelpers} from './auth.js';\nimport {decodeManagementCursor, encodeManagementCursor} from './cursor.js';\nimport {translateManagementError} from './errors.js';\n\nexport function listSecretsRoute(accessControl: ManagementAccessHelpers) {\n return defineRoute({\n method: 'GET',\n path: '/secrets',\n description: 'List user-managed secrets for a workspace or project scope.',\n schema: {\n params: z.object({workspaceId: z.string().uuid()}),\n querystring: listSecretsQuerySchema,\n response: {200: listSecretsResponseSchema},\n },\n errorHandler: translateManagementError,\n handler: async (request) => {\n const {workspaceId} = request.params;\n const {project_id: projectId, limit, cursor} = request.query;\n const decodedCursor = decodeManagementCursor(cursor);\n if (cursor && !decodedCursor) {\n throw new ClientError('Invalid cursor', 'invalid-cursor', {status: 400});\n }\n\n await accessControl.requireManagementRead({request, workspaceId, projectId});\n const result = await listManagedSecrets({\n workspaceId,\n projectId,\n limit,\n cursor: decodedCursor ?? undefined,\n });\n\n return {\n secrets: result.secrets.map(toSecretDto),\n next_cursor: result.nextCursor ? encodeManagementCursor(result.nextCursor) : null,\n };\n },\n });\n}\n"],"names":["listSecretsQuerySchema","listSecretsResponseSchema","ClientError","defineRoute","z","listManagedSecrets","toSecretDto","decodeManagementCursor","encodeManagementCursor","translateManagementError","listSecretsRoute","accessControl","method","path","description","schema","params","object","workspaceId","string","uuid","querystring","response","errorHandler","handler","request","project_id","projectId","limit","cursor","query","decodedCursor","status","requireManagementRead","result","undefined","secrets","map","next_cursor","nextCursor"],"mappings":"AAAA,SAAQA,sBAAsB,EAAEC,yBAAyB,QAAO,2BAA2B;AAC3F,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,kBAAkB,QAAO,iBAAiB;AAClD,SAAQC,WAAW,QAAO,6BAA6B;AAEvD,SAAQC,sBAAsB,EAAEC,sBAAsB,QAAO,cAAc;AAC3E,SAAQC,wBAAwB,QAAO,cAAc;AAErD,OAAO,SAASC,iBAAiBC,aAAsC;IACrE,OAAOR,YAAY;QACjBS,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,QAAQZ,EAAEa,MAAM,CAAC;gBAACC,aAAad,EAAEe,MAAM,GAAGC,IAAI;YAAE;YAChDC,aAAarB;YACbsB,UAAU;gBAAC,KAAKrB;YAAyB;QAC3C;QACAsB,cAAcd;QACde,SAAS,OAAOC;YACd,MAAM,EAACP,WAAW,EAAC,GAAGO,QAAQT,MAAM;YACpC,MAAM,EAACU,YAAYC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAC,GAAGJ,QAAQK,KAAK;YAC5D,MAAMC,gBAAgBxB,uBAAuBsB;YAC7C,IAAIA,UAAU,CAACE,eAAe;gBAC5B,MAAM,IAAI7B,YAAY,kBAAkB,kBAAkB;oBAAC8B,QAAQ;gBAAG;YACxE;YAEA,MAAMrB,cAAcsB,qBAAqB,CAAC;gBAACR;gBAASP;gBAAaS;YAAS;YAC1E,MAAMO,SAAS,MAAM7B,mBAAmB;gBACtCa;gBACAS;gBACAC;gBACAC,QAAQE,iBAAiBI;YAC3B;YAEA,OAAO;gBACLC,SAASF,OAAOE,OAAO,CAACC,GAAG,CAAC/B;gBAC5BgC,aAAaJ,OAAOK,UAAU,GAAG/B,uBAAuB0B,OAAOK,UAAU,IAAI;YAC/E;QACF;IACF;AACF"}
@@ -1,2 +1,3 @@
1
- export declare const listVariablesRoute: import("@shipfox/node-fastify").RouteDefinition;
1
+ import type { ManagementAccessHelpers } from './auth.js';
2
+ export declare function listVariablesRoute(accessControl: ManagementAccessHelpers): import("@shipfox/node-fastify").RouteDefinition;
2
3
  //# sourceMappingURL=list-variables.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list-variables.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-variables.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,kBAAkB,iDA+B7B,CAAC"}
1
+ {"version":3,"file":"list-variables.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-variables.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,WAAW,CAAC;AAIvD,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,uBAAuB,mDAiCxE"}