@shipfox/api-secrets 5.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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +28 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -15
- package/dist/index.js.map +1 -1
- package/dist/presentation/inter-module.d.ts +4 -0
- package/dist/presentation/inter-module.d.ts.map +1 -0
- package/dist/presentation/inter-module.js +73 -0
- package/dist/presentation/inter-module.js.map +1 -0
- package/dist/presentation/routes/auth.d.ts +14 -10
- package/dist/presentation/routes/auth.d.ts.map +1 -1
- package/dist/presentation/routes/auth.js +27 -11
- package/dist/presentation/routes/auth.js.map +1 -1
- package/dist/presentation/routes/batch-secrets.d.ts +2 -1
- package/dist/presentation/routes/batch-secrets.d.ts.map +1 -1
- package/dist/presentation/routes/batch-secrets.js +35 -34
- package/dist/presentation/routes/batch-secrets.js.map +1 -1
- package/dist/presentation/routes/batch-variables.d.ts +2 -1
- package/dist/presentation/routes/batch-variables.d.ts.map +1 -1
- package/dist/presentation/routes/batch-variables.js +35 -34
- package/dist/presentation/routes/batch-variables.js.map +1 -1
- package/dist/presentation/routes/delete-secret.d.ts +2 -1
- package/dist/presentation/routes/delete-secret.d.ts.map +1 -1
- package/dist/presentation/routes/delete-secret.js +33 -32
- package/dist/presentation/routes/delete-secret.js.map +1 -1
- package/dist/presentation/routes/delete-variable.d.ts +2 -1
- package/dist/presentation/routes/delete-variable.d.ts.map +1 -1
- package/dist/presentation/routes/delete-variable.js +33 -32
- package/dist/presentation/routes/delete-variable.js.map +1 -1
- package/dist/presentation/routes/errors.d.ts.map +1 -1
- package/dist/presentation/routes/errors.js +0 -6
- package/dist/presentation/routes/errors.js.map +1 -1
- package/dist/presentation/routes/get-variable.d.ts +2 -1
- package/dist/presentation/routes/get-variable.d.ts.map +1 -1
- package/dist/presentation/routes/get-variable.js +34 -33
- package/dist/presentation/routes/get-variable.js.map +1 -1
- package/dist/presentation/routes/index.d.ts +2 -1
- package/dist/presentation/routes/index.d.ts.map +1 -1
- package/dist/presentation/routes/index.js +21 -17
- package/dist/presentation/routes/index.js.map +1 -1
- package/dist/presentation/routes/list-secrets.d.ts +2 -1
- package/dist/presentation/routes/list-secrets.d.ts.map +1 -1
- package/dist/presentation/routes/list-secrets.js +40 -39
- package/dist/presentation/routes/list-secrets.js.map +1 -1
- package/dist/presentation/routes/list-variables.d.ts +2 -1
- package/dist/presentation/routes/list-variables.d.ts.map +1 -1
- package/dist/presentation/routes/list-variables.js +40 -39
- package/dist/presentation/routes/list-variables.js.map +1 -1
- package/dist/presentation/routes/put-secret.d.ts +2 -1
- package/dist/presentation/routes/put-secret.d.ts.map +1 -1
- package/dist/presentation/routes/put-secret.js +43 -42
- package/dist/presentation/routes/put-secret.js.map +1 -1
- package/dist/presentation/routes/put-variable.d.ts +2 -1
- package/dist/presentation/routes/put-variable.d.ts.map +1 -1
- package/dist/presentation/routes/put-variable.js +43 -42
- package/dist/presentation/routes/put-variable.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +11 -8
- package/src/index.ts +16 -5
- package/src/presentation/inter-module.test.ts +32 -0
- package/src/presentation/inter-module.ts +78 -0
- package/src/presentation/routes/auth.ts +65 -19
- package/src/presentation/routes/batch-secrets.ts +26 -24
- package/src/presentation/routes/batch-variables.ts +26 -24
- package/src/presentation/routes/delete-secret.ts +21 -19
- package/src/presentation/routes/delete-variable.ts +21 -19
- package/src/presentation/routes/errors.ts +0 -5
- package/src/presentation/routes/get-variable.ts +21 -19
- package/src/presentation/routes/index.ts +22 -17
- package/src/presentation/routes/list-secrets.ts +33 -31
- package/src/presentation/routes/list-variables.ts +33 -31
- package/src/presentation/routes/management.test.ts +32 -18
- package/src/presentation/routes/put-secret.ts +28 -26
- package/src/presentation/routes/put-variable.ts +28 -26
- package/tsconfig.build.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
$ shipfox-swc
|
|
2
|
-
Successfully compiled:
|
|
2
|
+
Successfully compiled: 52 files with swc (453.38ms)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @shipfox/api-secrets
|
|
2
2
|
|
|
3
|
+
## 6.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a42b575: Exposes Secrets through its inter-module contract and migrates Agent, integrations, and Workflows consumers.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- f73da5d: Enforces bounded API context imports and routes inter-module consumers through producer contracts.
|
|
12
|
+
- Updated dependencies [54ce48b]
|
|
13
|
+
- Updated dependencies [c0162b0]
|
|
14
|
+
- Updated dependencies [7ac43a4]
|
|
15
|
+
- Updated dependencies [a01e917]
|
|
16
|
+
- Updated dependencies [a42b575]
|
|
17
|
+
- Updated dependencies [8bdc149]
|
|
18
|
+
- Updated dependencies [3810996]
|
|
19
|
+
- Updated dependencies [b00ed29]
|
|
20
|
+
- Updated dependencies [8aa7cd3]
|
|
21
|
+
- Updated dependencies [81f9544]
|
|
22
|
+
- @shipfox/node-module@0.4.0
|
|
23
|
+
- @shipfox/node-drizzle@0.3.2
|
|
24
|
+
- @shipfox/node-outbox@0.2.4
|
|
25
|
+
- @shipfox/api-secrets-dto@6.0.0
|
|
26
|
+
- @shipfox/api-auth-context@6.0.0
|
|
27
|
+
- @shipfox/node-fastify@0.2.4
|
|
28
|
+
- @shipfox/inter-module@0.2.0
|
|
29
|
+
- @shipfox/api-projects-dto@6.0.0
|
|
30
|
+
|
|
3
31
|
## 5.0.0
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
|
|
1
2
|
import type { ShipfoxModule } from '@shipfox/node-module';
|
|
2
3
|
export { BUILTIN_LOCAL_STORE, DekUnwrapError, DekWrapError, deleteManagedSecret, deleteManagedVariable, deleteSecrets, deleteVariables, getManagedVariable, getSecret, getSecretsByNamespace, getVariable, getVariablesByNamespace, KekConfigurationError, KekVersionStrandedError, listManagedSecrets, listManagedVariables, NamespaceValidationError, resolveSecretStore, rotateWorkspaceDataKeys, SecretBatchScopeMismatchError, SecretDecryptionError, SecretKeyValidationError, SecretNotFoundError, type SecretStoreProvider, SecretValueTooLargeError, setManagedSecrets, setManagedVariables, setSecrets, setVariables, UnknownSecretStoreError, VariableNotFoundError, WorkspaceSecretCapExceededError, } from '#core/index.js';
|
|
4
|
+
export declare function createSecretsModule(projects: ProjectsModuleClient): ShipfoxModule;
|
|
3
5
|
export declare const secretsModule: ShipfoxModule;
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAEpE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAOxD,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,qBAAqB,EACrB,WAAW,EACX,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,6BAA6B,EAC7B,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,uBAAuB,EACvB,qBAAqB,EACrB,+BAA+B,GAChC,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,aAAa,CAUjF;AAGD,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,27 +2,41 @@ import { secretsEventSchemas } from '@shipfox/api-secrets-dto';
|
|
|
2
2
|
import { db, migrationsPath, secretsOutbox } from '#db/index.js';
|
|
3
3
|
import { registerSecretsServiceMetrics } from '#metrics/index.js';
|
|
4
4
|
import { secretsE2eRoutes } from '#presentation/e2eRoutes/index.js';
|
|
5
|
-
import {
|
|
5
|
+
import { createSecretsInterModulePresentation } from '#presentation/inter-module.js';
|
|
6
|
+
import { createSecretsRoutes } from '#presentation/routes/index.js';
|
|
6
7
|
export { BUILTIN_LOCAL_STORE, DekUnwrapError, DekWrapError, deleteManagedSecret, deleteManagedVariable, deleteSecrets, deleteVariables, getManagedVariable, getSecret, getSecretsByNamespace, getVariable, getVariablesByNamespace, KekConfigurationError, KekVersionStrandedError, listManagedSecrets, listManagedVariables, NamespaceValidationError, resolveSecretStore, rotateWorkspaceDataKeys, SecretBatchScopeMismatchError, SecretDecryptionError, SecretKeyValidationError, SecretNotFoundError, SecretValueTooLargeError, setManagedSecrets, setManagedVariables, setSecrets, setVariables, UnknownSecretStoreError, VariableNotFoundError, WorkspaceSecretCapExceededError } from '#core/index.js';
|
|
8
|
+
export function createSecretsModule(projects) {
|
|
9
|
+
return {
|
|
10
|
+
name: 'secrets',
|
|
11
|
+
database: {
|
|
12
|
+
db,
|
|
13
|
+
migrationsPath
|
|
14
|
+
},
|
|
15
|
+
routes: createSecretsRoutes(projects),
|
|
16
|
+
e2eRoutes: [
|
|
17
|
+
secretsE2eRoutes
|
|
18
|
+
],
|
|
19
|
+
metrics: registerSecretsServiceMetrics,
|
|
20
|
+
publishers: [
|
|
21
|
+
{
|
|
22
|
+
name: 'secrets',
|
|
23
|
+
table: secretsOutbox,
|
|
24
|
+
db,
|
|
25
|
+
eventSchemas: secretsEventSchemas
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
interModulePresentations: [
|
|
29
|
+
createSecretsInterModulePresentation()
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Migration setup imports this declaration only for the owned database metadata.
|
|
7
34
|
export const secretsModule = {
|
|
8
35
|
name: 'secrets',
|
|
9
36
|
database: {
|
|
10
37
|
db,
|
|
11
38
|
migrationsPath
|
|
12
|
-
}
|
|
13
|
-
routes: secretsRoutes,
|
|
14
|
-
e2eRoutes: [
|
|
15
|
-
secretsE2eRoutes
|
|
16
|
-
],
|
|
17
|
-
metrics: registerSecretsServiceMetrics,
|
|
18
|
-
publishers: [
|
|
19
|
-
{
|
|
20
|
-
name: 'secrets',
|
|
21
|
-
table: secretsOutbox,
|
|
22
|
-
db,
|
|
23
|
-
eventSchemas: secretsEventSchemas
|
|
24
|
-
}
|
|
25
|
-
]
|
|
39
|
+
}
|
|
26
40
|
};
|
|
27
41
|
|
|
28
42
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {secretsEventSchemas} from '@shipfox/api-secrets-dto';\nimport type {ShipfoxModule} from '@shipfox/node-module';\nimport {db, migrationsPath, secretsOutbox} from '#db/index.js';\nimport {registerSecretsServiceMetrics} from '#metrics/index.js';\nimport {secretsE2eRoutes} from '#presentation/e2eRoutes/index.js';\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport {secretsEventSchemas} from '@shipfox/api-secrets-dto';\nimport type {ShipfoxModule} from '@shipfox/node-module';\nimport {db, migrationsPath, secretsOutbox} from '#db/index.js';\nimport {registerSecretsServiceMetrics} from '#metrics/index.js';\nimport {secretsE2eRoutes} from '#presentation/e2eRoutes/index.js';\nimport {createSecretsInterModulePresentation} from '#presentation/inter-module.js';\nimport {createSecretsRoutes} from '#presentation/routes/index.js';\n\nexport {\n BUILTIN_LOCAL_STORE,\n DekUnwrapError,\n DekWrapError,\n deleteManagedSecret,\n deleteManagedVariable,\n deleteSecrets,\n deleteVariables,\n getManagedVariable,\n getSecret,\n getSecretsByNamespace,\n getVariable,\n getVariablesByNamespace,\n KekConfigurationError,\n KekVersionStrandedError,\n listManagedSecrets,\n listManagedVariables,\n NamespaceValidationError,\n resolveSecretStore,\n rotateWorkspaceDataKeys,\n SecretBatchScopeMismatchError,\n SecretDecryptionError,\n SecretKeyValidationError,\n SecretNotFoundError,\n type SecretStoreProvider,\n SecretValueTooLargeError,\n setManagedSecrets,\n setManagedVariables,\n setSecrets,\n setVariables,\n UnknownSecretStoreError,\n VariableNotFoundError,\n WorkspaceSecretCapExceededError,\n} from '#core/index.js';\n\nexport function createSecretsModule(projects: ProjectsModuleClient): ShipfoxModule {\n return {\n name: 'secrets',\n database: {db, migrationsPath},\n routes: createSecretsRoutes(projects),\n e2eRoutes: [secretsE2eRoutes],\n metrics: registerSecretsServiceMetrics,\n publishers: [{name: 'secrets', table: secretsOutbox, db, eventSchemas: secretsEventSchemas}],\n interModulePresentations: [createSecretsInterModulePresentation()],\n };\n}\n\n// Migration setup imports this declaration only for the owned database metadata.\nexport const secretsModule: ShipfoxModule = {\n name: 'secrets',\n database: {db, migrationsPath},\n};\n"],"names":["secretsEventSchemas","db","migrationsPath","secretsOutbox","registerSecretsServiceMetrics","secretsE2eRoutes","createSecretsInterModulePresentation","createSecretsRoutes","BUILTIN_LOCAL_STORE","DekUnwrapError","DekWrapError","deleteManagedSecret","deleteManagedVariable","deleteSecrets","deleteVariables","getManagedVariable","getSecret","getSecretsByNamespace","getVariable","getVariablesByNamespace","KekConfigurationError","KekVersionStrandedError","listManagedSecrets","listManagedVariables","NamespaceValidationError","resolveSecretStore","rotateWorkspaceDataKeys","SecretBatchScopeMismatchError","SecretDecryptionError","SecretKeyValidationError","SecretNotFoundError","SecretValueTooLargeError","setManagedSecrets","setManagedVariables","setSecrets","setVariables","UnknownSecretStoreError","VariableNotFoundError","WorkspaceSecretCapExceededError","createSecretsModule","projects","name","database","routes","e2eRoutes","metrics","publishers","table","eventSchemas","interModulePresentations","secretsModule"],"mappings":"AACA,SAAQA,mBAAmB,QAAO,2BAA2B;AAE7D,SAAQC,EAAE,EAAEC,cAAc,EAAEC,aAAa,QAAO,eAAe;AAC/D,SAAQC,6BAA6B,QAAO,oBAAoB;AAChE,SAAQC,gBAAgB,QAAO,mCAAmC;AAClE,SAAQC,oCAAoC,QAAO,gCAAgC;AACnF,SAAQC,mBAAmB,QAAO,gCAAgC;AAElE,SACEC,mBAAmB,EACnBC,cAAc,EACdC,YAAY,EACZC,mBAAmB,EACnBC,qBAAqB,EACrBC,aAAa,EACbC,eAAe,EACfC,kBAAkB,EAClBC,SAAS,EACTC,qBAAqB,EACrBC,WAAW,EACXC,uBAAuB,EACvBC,qBAAqB,EACrBC,uBAAuB,EACvBC,kBAAkB,EAClBC,oBAAoB,EACpBC,wBAAwB,EACxBC,kBAAkB,EAClBC,uBAAuB,EACvBC,6BAA6B,EAC7BC,qBAAqB,EACrBC,wBAAwB,EACxBC,mBAAmB,EAEnBC,wBAAwB,EACxBC,iBAAiB,EACjBC,mBAAmB,EACnBC,UAAU,EACVC,YAAY,EACZC,uBAAuB,EACvBC,qBAAqB,EACrBC,+BAA+B,QAC1B,iBAAiB;AAExB,OAAO,SAASC,oBAAoBC,QAA8B;IAChE,OAAO;QACLC,MAAM;QACNC,UAAU;YAACzC;YAAIC;QAAc;QAC7ByC,QAAQpC,oBAAoBiC;QAC5BI,WAAW;YAACvC;SAAiB;QAC7BwC,SAASzC;QACT0C,YAAY;YAAC;gBAACL,MAAM;gBAAWM,OAAO5C;gBAAeF;gBAAI+C,cAAchD;YAAmB;SAAE;QAC5FiD,0BAA0B;YAAC3C;SAAuC;IACpE;AACF;AAEA,iFAAiF;AACjF,OAAO,MAAM4C,gBAA+B;IAC1CT,MAAM;IACNC,UAAU;QAACzC;QAAIC;IAAc;AAC/B,EAAE"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { secretsInterModuleContract } from '@shipfox/api-secrets-dto/inter-module';
|
|
2
|
+
import { type InterModulePresentation } from '@shipfox/inter-module';
|
|
3
|
+
export declare function createSecretsInterModulePresentation(): InterModulePresentation<typeof secretsInterModuleContract>;
|
|
4
|
+
//# sourceMappingURL=inter-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inter-module.d.ts","sourceRoot":"","sources":["../../src/presentation/inter-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,0BAA0B,EAAC,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAY/B,wBAAgB,oCAAoC,IAAI,uBAAuB,CAC7E,OAAO,0BAA0B,CAClC,CAiCA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { secretsInterModuleContract } from '@shipfox/api-secrets-dto/inter-module';
|
|
2
|
+
import { createInterModuleKnownError, defineInterModulePresentation } from '@shipfox/inter-module';
|
|
3
|
+
import { deleteSecrets, getSecret, getSecretsByNamespace, getVariablesByNamespace, SecretDecryptionError, SecretValueTooLargeError, setSecrets, WorkspaceSecretCapExceededError } from '#core/index.js';
|
|
4
|
+
export function createSecretsInterModulePresentation() {
|
|
5
|
+
return defineInterModulePresentation(secretsInterModuleContract, {
|
|
6
|
+
getSecret: async (input)=>{
|
|
7
|
+
try {
|
|
8
|
+
const { store, ...params } = input;
|
|
9
|
+
return {
|
|
10
|
+
value: await getSecret({
|
|
11
|
+
...params,
|
|
12
|
+
...store === undefined ? {} : {
|
|
13
|
+
store
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
};
|
|
17
|
+
} catch (error) {
|
|
18
|
+
throw toGetKnownError('getSecret', error);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
getSecretsByNamespace: async (input)=>{
|
|
22
|
+
try {
|
|
23
|
+
const { store, ...params } = input;
|
|
24
|
+
return {
|
|
25
|
+
values: await getSecretsByNamespace({
|
|
26
|
+
...params,
|
|
27
|
+
...store === undefined ? {} : {
|
|
28
|
+
store
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
} catch (error) {
|
|
33
|
+
throw toGetKnownError('getSecretsByNamespace', error);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
getVariablesByNamespace: async (input)=>({
|
|
37
|
+
values: await getVariablesByNamespace(input)
|
|
38
|
+
}),
|
|
39
|
+
setSecrets: async (input)=>{
|
|
40
|
+
try {
|
|
41
|
+
await setSecrets(input);
|
|
42
|
+
return {};
|
|
43
|
+
} catch (error) {
|
|
44
|
+
throw toSetKnownError(error);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
deleteSecrets: async (input)=>({
|
|
48
|
+
deleted: await deleteSecrets(input)
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function toGetKnownError(methodName, error) {
|
|
53
|
+
if (error instanceof SecretDecryptionError) {
|
|
54
|
+
return createInterModuleKnownError(secretsInterModuleContract.methods[methodName], 'secret-decryption-failed', {});
|
|
55
|
+
}
|
|
56
|
+
return error;
|
|
57
|
+
}
|
|
58
|
+
function toSetKnownError(error) {
|
|
59
|
+
const method = secretsInterModuleContract.methods.setSecrets;
|
|
60
|
+
if (error instanceof SecretValueTooLargeError) {
|
|
61
|
+
return createInterModuleKnownError(method, 'value-too-large', {
|
|
62
|
+
maxBytes: error.maxBytes
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (error instanceof WorkspaceSecretCapExceededError) {
|
|
66
|
+
return createInterModuleKnownError(method, 'workspace-secret-cap-exceeded', {
|
|
67
|
+
cap: error.cap
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return error;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=inter-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/presentation/inter-module.ts"],"sourcesContent":["import {secretsInterModuleContract} from '@shipfox/api-secrets-dto/inter-module';\nimport {\n createInterModuleKnownError,\n defineInterModulePresentation,\n type InterModulePresentation,\n} from '@shipfox/inter-module';\nimport {\n deleteSecrets,\n getSecret,\n getSecretsByNamespace,\n getVariablesByNamespace,\n SecretDecryptionError,\n SecretValueTooLargeError,\n setSecrets,\n WorkspaceSecretCapExceededError,\n} from '#core/index.js';\n\nexport function createSecretsInterModulePresentation(): InterModulePresentation<\n typeof secretsInterModuleContract\n> {\n return defineInterModulePresentation(secretsInterModuleContract, {\n getSecret: async (input) => {\n try {\n const {store, ...params} = input;\n return {value: await getSecret({...params, ...(store === undefined ? {} : {store})})};\n } catch (error) {\n throw toGetKnownError('getSecret', error);\n }\n },\n getSecretsByNamespace: async (input) => {\n try {\n const {store, ...params} = input;\n return {\n values: await getSecretsByNamespace({...params, ...(store === undefined ? {} : {store})}),\n };\n } catch (error) {\n throw toGetKnownError('getSecretsByNamespace', error);\n }\n },\n getVariablesByNamespace: async (input) => ({\n values: await getVariablesByNamespace(input),\n }),\n setSecrets: async (input) => {\n try {\n await setSecrets(input);\n return {};\n } catch (error) {\n throw toSetKnownError(error);\n }\n },\n deleteSecrets: async (input) => ({deleted: await deleteSecrets(input)}),\n });\n}\n\nfunction toGetKnownError(\n methodName: 'getSecret' | 'getSecretsByNamespace',\n error: unknown,\n): unknown {\n if (error instanceof SecretDecryptionError) {\n return createInterModuleKnownError(\n secretsInterModuleContract.methods[methodName],\n 'secret-decryption-failed',\n {},\n );\n }\n return error;\n}\n\nfunction toSetKnownError(error: unknown): unknown {\n const method = secretsInterModuleContract.methods.setSecrets;\n if (error instanceof SecretValueTooLargeError) {\n return createInterModuleKnownError(method, 'value-too-large', {maxBytes: error.maxBytes});\n }\n if (error instanceof WorkspaceSecretCapExceededError) {\n return createInterModuleKnownError(method, 'workspace-secret-cap-exceeded', {cap: error.cap});\n }\n return error;\n}\n"],"names":["secretsInterModuleContract","createInterModuleKnownError","defineInterModulePresentation","deleteSecrets","getSecret","getSecretsByNamespace","getVariablesByNamespace","SecretDecryptionError","SecretValueTooLargeError","setSecrets","WorkspaceSecretCapExceededError","createSecretsInterModulePresentation","input","store","params","value","undefined","error","toGetKnownError","values","toSetKnownError","deleted","methodName","methods","method","maxBytes","cap"],"mappings":"AAAA,SAAQA,0BAA0B,QAAO,wCAAwC;AACjF,SACEC,2BAA2B,EAC3BC,6BAA6B,QAExB,wBAAwB;AAC/B,SACEC,aAAa,EACbC,SAAS,EACTC,qBAAqB,EACrBC,uBAAuB,EACvBC,qBAAqB,EACrBC,wBAAwB,EACxBC,UAAU,EACVC,+BAA+B,QAC1B,iBAAiB;AAExB,OAAO,SAASC;IAGd,OAAOT,8BAA8BF,4BAA4B;QAC/DI,WAAW,OAAOQ;YAChB,IAAI;gBACF,MAAM,EAACC,KAAK,EAAE,GAAGC,QAAO,GAAGF;gBAC3B,OAAO;oBAACG,OAAO,MAAMX,UAAU;wBAAC,GAAGU,MAAM;wBAAE,GAAID,UAAUG,YAAY,CAAC,IAAI;4BAACH;wBAAK,CAAC;oBAAC;gBAAE;YACtF,EAAE,OAAOI,OAAO;gBACd,MAAMC,gBAAgB,aAAaD;YACrC;QACF;QACAZ,uBAAuB,OAAOO;YAC5B,IAAI;gBACF,MAAM,EAACC,KAAK,EAAE,GAAGC,QAAO,GAAGF;gBAC3B,OAAO;oBACLO,QAAQ,MAAMd,sBAAsB;wBAAC,GAAGS,MAAM;wBAAE,GAAID,UAAUG,YAAY,CAAC,IAAI;4BAACH;wBAAK,CAAC;oBAAC;gBACzF;YACF,EAAE,OAAOI,OAAO;gBACd,MAAMC,gBAAgB,yBAAyBD;YACjD;QACF;QACAX,yBAAyB,OAAOM,QAAW,CAAA;gBACzCO,QAAQ,MAAMb,wBAAwBM;YACxC,CAAA;QACAH,YAAY,OAAOG;YACjB,IAAI;gBACF,MAAMH,WAAWG;gBACjB,OAAO,CAAC;YACV,EAAE,OAAOK,OAAO;gBACd,MAAMG,gBAAgBH;YACxB;QACF;QACAd,eAAe,OAAOS,QAAW,CAAA;gBAACS,SAAS,MAAMlB,cAAcS;YAAM,CAAA;IACvE;AACF;AAEA,SAASM,gBACPI,UAAiD,EACjDL,KAAc;IAEd,IAAIA,iBAAiBV,uBAAuB;QAC1C,OAAON,4BACLD,2BAA2BuB,OAAO,CAACD,WAAW,EAC9C,4BACA,CAAC;IAEL;IACA,OAAOL;AACT;AAEA,SAASG,gBAAgBH,KAAc;IACrC,MAAMO,SAASxB,2BAA2BuB,OAAO,CAACd,UAAU;IAC5D,IAAIQ,iBAAiBT,0BAA0B;QAC7C,OAAOP,4BAA4BuB,QAAQ,mBAAmB;YAACC,UAAUR,MAAMQ,QAAQ;QAAA;IACzF;IACA,IAAIR,iBAAiBP,iCAAiC;QACpD,OAAOT,4BAA4BuB,QAAQ,iCAAiC;YAACE,KAAKT,MAAMS,GAAG;QAAA;IAC7F;IACA,OAAOT;AACT"}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
import { type ProjectsModuleClient } from '@shipfox/api-projects-dto';
|
|
1
2
|
import type { FastifyRequest } from 'fastify';
|
|
2
3
|
export interface ManagementAccess {
|
|
3
4
|
workspaceId: string;
|
|
4
5
|
userId: string;
|
|
5
6
|
}
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
export interface ManagementAccessHelpers {
|
|
8
|
+
requireManagementRead(params: {
|
|
9
|
+
request: FastifyRequest;
|
|
10
|
+
workspaceId: string;
|
|
11
|
+
projectId?: string | undefined;
|
|
12
|
+
}): Promise<ManagementAccess>;
|
|
13
|
+
requireManagementWrite(params: {
|
|
14
|
+
request: FastifyRequest;
|
|
15
|
+
workspaceId: string;
|
|
16
|
+
projectId?: string | undefined;
|
|
17
|
+
}): Promise<ManagementAccess>;
|
|
18
|
+
}
|
|
19
|
+
export declare function createManagementAccess(projects: ProjectsModuleClient): ManagementAccessHelpers;
|
|
16
20
|
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,oBAAoB,EAA8B,MAAM,2BAA2B,CAAC;AAGjG,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAE5C,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,qBAAqB,CAAC,MAAM,EAAE;QAC5B,OAAO,EAAE,cAAc,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC9B,sBAAsB,CAAC,MAAM,EAAE;QAC7B,OAAO,EAAE,cAAc,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC/B;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,uBAAuB,CAa9F"}
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { requireWorkspaceAccess } from '@shipfox/api-auth-context';
|
|
2
|
-
import {
|
|
2
|
+
import { projectsInterModuleContract } from '@shipfox/api-projects-dto';
|
|
3
|
+
import { isInterModuleKnownError } from '@shipfox/inter-module';
|
|
3
4
|
import { ClientError } from '@shipfox/node-fastify';
|
|
4
|
-
export
|
|
5
|
+
export function createManagementAccess(projects) {
|
|
6
|
+
return {
|
|
7
|
+
requireManagementRead: (params)=>requireManagementRead(params, projects),
|
|
8
|
+
requireManagementWrite: (params)=>requireManagementWrite(params, projects)
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
async function requireManagementRead(params, projects) {
|
|
5
12
|
const membership = requireWorkspaceAccess({
|
|
6
13
|
request: params.request,
|
|
7
14
|
workspaceId: params.workspaceId
|
|
8
15
|
});
|
|
9
16
|
if (params.projectId) {
|
|
10
|
-
await requireProjectForWorkspace(
|
|
11
|
-
workspaceId: params.workspaceId,
|
|
12
|
-
projectId: params.projectId
|
|
13
|
-
});
|
|
17
|
+
await requireProjectForWorkspace(params.workspaceId, params.projectId, projects);
|
|
14
18
|
}
|
|
15
19
|
return {
|
|
16
20
|
workspaceId: params.workspaceId,
|
|
17
21
|
userId: membership.userId
|
|
18
22
|
};
|
|
19
23
|
}
|
|
20
|
-
|
|
24
|
+
async function requireManagementWrite(params, projects) {
|
|
21
25
|
const membership = requireWorkspaceAccess({
|
|
22
26
|
request: params.request,
|
|
23
27
|
workspaceId: params.workspaceId
|
|
@@ -28,15 +32,27 @@ export async function requireManagementWrite(params) {
|
|
|
28
32
|
});
|
|
29
33
|
}
|
|
30
34
|
if (params.projectId) {
|
|
31
|
-
await requireProjectForWorkspace(
|
|
32
|
-
workspaceId: params.workspaceId,
|
|
33
|
-
projectId: params.projectId
|
|
34
|
-
});
|
|
35
|
+
await requireProjectForWorkspace(params.workspaceId, params.projectId, projects);
|
|
35
36
|
}
|
|
36
37
|
return {
|
|
37
38
|
workspaceId: params.workspaceId,
|
|
38
39
|
userId: membership.userId
|
|
39
40
|
};
|
|
40
41
|
}
|
|
42
|
+
async function requireProjectForWorkspace(workspaceId, projectId, projects) {
|
|
43
|
+
try {
|
|
44
|
+
await projects.requireProjectForWorkspace({
|
|
45
|
+
workspaceId,
|
|
46
|
+
projectId
|
|
47
|
+
});
|
|
48
|
+
} catch (error) {
|
|
49
|
+
if (isInterModuleKnownError(projectsInterModuleContract.methods.requireProjectForWorkspace, error)) {
|
|
50
|
+
throw new ClientError('Project not found', 'project-not-found', {
|
|
51
|
+
status: 404
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
41
57
|
|
|
42
58
|
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/auth.ts"],"sourcesContent":["import {requireWorkspaceAccess} from '@shipfox/api-auth-context';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/auth.ts"],"sourcesContent":["import {requireWorkspaceAccess} from '@shipfox/api-auth-context';\nimport {type ProjectsModuleClient, projectsInterModuleContract} from '@shipfox/api-projects-dto';\nimport {isInterModuleKnownError} from '@shipfox/inter-module';\nimport {ClientError} from '@shipfox/node-fastify';\nimport type {FastifyRequest} from 'fastify';\n\nexport interface ManagementAccess {\n workspaceId: string;\n userId: string;\n}\n\nexport interface ManagementAccessHelpers {\n requireManagementRead(params: {\n request: FastifyRequest;\n workspaceId: string;\n projectId?: string | undefined;\n }): Promise<ManagementAccess>;\n requireManagementWrite(params: {\n request: FastifyRequest;\n workspaceId: string;\n projectId?: string | undefined;\n }): Promise<ManagementAccess>;\n}\n\nexport function createManagementAccess(projects: ProjectsModuleClient): ManagementAccessHelpers {\n return {\n requireManagementRead: (params: {\n request: FastifyRequest;\n workspaceId: string;\n projectId?: string | undefined;\n }) => requireManagementRead(params, projects),\n requireManagementWrite: (params: {\n request: FastifyRequest;\n workspaceId: string;\n projectId?: string | undefined;\n }) => requireManagementWrite(params, projects),\n };\n}\n\nasync function requireManagementRead(\n params: {\n request: FastifyRequest;\n workspaceId: string;\n projectId?: string | undefined;\n },\n projects: ProjectsModuleClient,\n): Promise<ManagementAccess> {\n const membership = requireWorkspaceAccess({\n request: params.request,\n workspaceId: params.workspaceId,\n });\n if (params.projectId) {\n await requireProjectForWorkspace(params.workspaceId, params.projectId, projects);\n }\n\n return {workspaceId: params.workspaceId, userId: membership.userId};\n}\n\nasync function requireManagementWrite(\n params: {\n request: FastifyRequest;\n workspaceId: string;\n projectId?: string | undefined;\n },\n projects: ProjectsModuleClient,\n): Promise<ManagementAccess> {\n const membership = requireWorkspaceAccess({\n request: params.request,\n workspaceId: params.workspaceId,\n });\n if (membership.role !== 'admin') {\n throw new ClientError('Workspace admin role required', 'forbidden', {status: 403});\n }\n if (params.projectId) {\n await requireProjectForWorkspace(params.workspaceId, params.projectId, projects);\n }\n\n return {workspaceId: params.workspaceId, userId: membership.userId};\n}\n\nasync function requireProjectForWorkspace(\n workspaceId: string,\n projectId: string,\n projects: ProjectsModuleClient,\n): Promise<void> {\n try {\n await projects.requireProjectForWorkspace({workspaceId, projectId});\n } catch (error) {\n if (\n isInterModuleKnownError(projectsInterModuleContract.methods.requireProjectForWorkspace, error)\n ) {\n throw new ClientError('Project not found', 'project-not-found', {status: 404});\n }\n throw error;\n }\n}\n"],"names":["requireWorkspaceAccess","projectsInterModuleContract","isInterModuleKnownError","ClientError","createManagementAccess","projects","requireManagementRead","params","requireManagementWrite","membership","request","workspaceId","projectId","requireProjectForWorkspace","userId","role","status","error","methods"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,4BAA4B;AACjE,SAAmCC,2BAA2B,QAAO,4BAA4B;AACjG,SAAQC,uBAAuB,QAAO,wBAAwB;AAC9D,SAAQC,WAAW,QAAO,wBAAwB;AAqBlD,OAAO,SAASC,uBAAuBC,QAA8B;IACnE,OAAO;QACLC,uBAAuB,CAACC,SAIlBD,sBAAsBC,QAAQF;QACpCG,wBAAwB,CAACD,SAInBC,uBAAuBD,QAAQF;IACvC;AACF;AAEA,eAAeC,sBACbC,MAIC,EACDF,QAA8B;IAE9B,MAAMI,aAAaT,uBAAuB;QACxCU,SAASH,OAAOG,OAAO;QACvBC,aAAaJ,OAAOI,WAAW;IACjC;IACA,IAAIJ,OAAOK,SAAS,EAAE;QACpB,MAAMC,2BAA2BN,OAAOI,WAAW,EAAEJ,OAAOK,SAAS,EAAEP;IACzE;IAEA,OAAO;QAACM,aAAaJ,OAAOI,WAAW;QAAEG,QAAQL,WAAWK,MAAM;IAAA;AACpE;AAEA,eAAeN,uBACbD,MAIC,EACDF,QAA8B;IAE9B,MAAMI,aAAaT,uBAAuB;QACxCU,SAASH,OAAOG,OAAO;QACvBC,aAAaJ,OAAOI,WAAW;IACjC;IACA,IAAIF,WAAWM,IAAI,KAAK,SAAS;QAC/B,MAAM,IAAIZ,YAAY,iCAAiC,aAAa;YAACa,QAAQ;QAAG;IAClF;IACA,IAAIT,OAAOK,SAAS,EAAE;QACpB,MAAMC,2BAA2BN,OAAOI,WAAW,EAAEJ,OAAOK,SAAS,EAAEP;IACzE;IAEA,OAAO;QAACM,aAAaJ,OAAOI,WAAW;QAAEG,QAAQL,WAAWK,MAAM;IAAA;AACpE;AAEA,eAAeD,2BACbF,WAAmB,EACnBC,SAAiB,EACjBP,QAA8B;IAE9B,IAAI;QACF,MAAMA,SAASQ,0BAA0B,CAAC;YAACF;YAAaC;QAAS;IACnE,EAAE,OAAOK,OAAO;QACd,IACEf,wBAAwBD,4BAA4BiB,OAAO,CAACL,0BAA0B,EAAEI,QACxF;YACA,MAAM,IAAId,YAAY,qBAAqB,qBAAqB;gBAACa,QAAQ;YAAG;QAC9E;QACA,MAAMC;IACR;AACF"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ManagementAccessHelpers } from './auth.js';
|
|
2
|
+
export declare function batchSecretsRoute(accessControl: ManagementAccessHelpers): import("@shipfox/node-fastify").RouteDefinition;
|
|
2
3
|
//# sourceMappingURL=batch-secrets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-secrets.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/batch-secrets.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"batch-secrets.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/batch-secrets.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,WAAW,CAAC;AAIvD,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,uBAAuB,mDAyBvE"}
|
|
@@ -3,42 +3,43 @@ import { defineRoute } from '@shipfox/node-fastify';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { setManagedSecrets } from '#core/index.js';
|
|
5
5
|
import { toSecretDto } from '#presentation/dto/index.js';
|
|
6
|
-
import { requireManagementWrite } from './auth.js';
|
|
7
6
|
import { translateManagementError } from './errors.js';
|
|
8
7
|
import { secretWarnings } from './warnings.js';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
export function batchSecretsRoute(accessControl) {
|
|
9
|
+
return defineRoute({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/secrets::batch',
|
|
12
|
+
description: 'Create or update multiple user-managed secrets in one scope.',
|
|
13
|
+
schema: {
|
|
14
|
+
params: z.object({
|
|
15
|
+
workspaceId: z.string().uuid()
|
|
16
|
+
}),
|
|
17
|
+
body: batchSecretsBodySchema,
|
|
18
|
+
response: {
|
|
19
|
+
200: batchSecretsResponseSchema
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
errorHandler: translateManagementError,
|
|
23
|
+
handler: async (request)=>{
|
|
24
|
+
const { workspaceId } = request.params;
|
|
25
|
+
const { project_id: projectId, entries } = request.body;
|
|
26
|
+
const access = await accessControl.requireManagementWrite({
|
|
27
|
+
request,
|
|
28
|
+
workspaceId,
|
|
29
|
+
projectId
|
|
30
|
+
});
|
|
31
|
+
const secrets = await setManagedSecrets({
|
|
32
|
+
workspaceId,
|
|
33
|
+
projectId,
|
|
34
|
+
actorId: access.userId,
|
|
35
|
+
entries
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
secrets: secrets.map(toSecretDto),
|
|
39
|
+
warnings: secretWarnings(entries)
|
|
40
|
+
};
|
|
20
41
|
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
handler: async (request)=>{
|
|
24
|
-
const { workspaceId } = request.params;
|
|
25
|
-
const { project_id: projectId, entries } = request.body;
|
|
26
|
-
const access = await requireManagementWrite({
|
|
27
|
-
request,
|
|
28
|
-
workspaceId,
|
|
29
|
-
projectId
|
|
30
|
-
});
|
|
31
|
-
const secrets = await setManagedSecrets({
|
|
32
|
-
workspaceId,
|
|
33
|
-
projectId,
|
|
34
|
-
actorId: access.userId,
|
|
35
|
-
entries
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
secrets: secrets.map(toSecretDto),
|
|
39
|
-
warnings: secretWarnings(entries)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
43
44
|
|
|
44
45
|
//# sourceMappingURL=batch-secrets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/batch-secrets.ts"],"sourcesContent":["import {batchSecretsBodySchema, batchSecretsResponseSchema} from '@shipfox/api-secrets-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {setManagedSecrets} from '#core/index.js';\nimport {toSecretDto} from '#presentation/dto/index.js';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/batch-secrets.ts"],"sourcesContent":["import {batchSecretsBodySchema, batchSecretsResponseSchema} from '@shipfox/api-secrets-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {setManagedSecrets} from '#core/index.js';\nimport {toSecretDto} from '#presentation/dto/index.js';\nimport type {ManagementAccessHelpers} from './auth.js';\nimport {translateManagementError} from './errors.js';\nimport {secretWarnings} from './warnings.js';\n\nexport function batchSecretsRoute(accessControl: ManagementAccessHelpers) {\n return defineRoute({\n method: 'POST',\n path: '/secrets::batch',\n description: 'Create or update multiple user-managed secrets in one scope.',\n schema: {\n params: z.object({workspaceId: z.string().uuid()}),\n body: batchSecretsBodySchema,\n response: {200: batchSecretsResponseSchema},\n },\n errorHandler: translateManagementError,\n handler: async (request) => {\n const {workspaceId} = request.params;\n const {project_id: projectId, entries} = request.body;\n const access = await accessControl.requireManagementWrite({request, workspaceId, projectId});\n const secrets = await setManagedSecrets({\n workspaceId,\n projectId,\n actorId: access.userId,\n entries,\n });\n\n return {secrets: secrets.map(toSecretDto), warnings: secretWarnings(entries)};\n },\n });\n}\n"],"names":["batchSecretsBodySchema","batchSecretsResponseSchema","defineRoute","z","setManagedSecrets","toSecretDto","translateManagementError","secretWarnings","batchSecretsRoute","accessControl","method","path","description","schema","params","object","workspaceId","string","uuid","body","response","errorHandler","handler","request","project_id","projectId","entries","access","requireManagementWrite","secrets","actorId","userId","map","warnings"],"mappings":"AAAA,SAAQA,sBAAsB,EAAEC,0BAA0B,QAAO,2BAA2B;AAC5F,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,iBAAiB,QAAO,iBAAiB;AACjD,SAAQC,WAAW,QAAO,6BAA6B;AAEvD,SAAQC,wBAAwB,QAAO,cAAc;AACrD,SAAQC,cAAc,QAAO,gBAAgB;AAE7C,OAAO,SAASC,kBAAkBC,aAAsC;IACtE,OAAOP,YAAY;QACjBQ,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,QAAQX,EAAEY,MAAM,CAAC;gBAACC,aAAab,EAAEc,MAAM,GAAGC,IAAI;YAAE;YAChDC,MAAMnB;YACNoB,UAAU;gBAAC,KAAKnB;YAA0B;QAC5C;QACAoB,cAAcf;QACdgB,SAAS,OAAOC;YACd,MAAM,EAACP,WAAW,EAAC,GAAGO,QAAQT,MAAM;YACpC,MAAM,EAACU,YAAYC,SAAS,EAAEC,OAAO,EAAC,GAAGH,QAAQJ,IAAI;YACrD,MAAMQ,SAAS,MAAMlB,cAAcmB,sBAAsB,CAAC;gBAACL;gBAASP;gBAAaS;YAAS;YAC1F,MAAMI,UAAU,MAAMzB,kBAAkB;gBACtCY;gBACAS;gBACAK,SAASH,OAAOI,MAAM;gBACtBL;YACF;YAEA,OAAO;gBAACG,SAASA,QAAQG,GAAG,CAAC3B;gBAAc4B,UAAU1B,eAAemB;YAAQ;QAC9E;IACF;AACF"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ManagementAccessHelpers } from './auth.js';
|
|
2
|
+
export declare function batchVariablesRoute(accessControl: ManagementAccessHelpers): import("@shipfox/node-fastify").RouteDefinition;
|
|
2
3
|
//# sourceMappingURL=batch-variables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-variables.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/batch-variables.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"batch-variables.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/batch-variables.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,WAAW,CAAC;AAIvD,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,uBAAuB,mDAyBzE"}
|
|
@@ -3,42 +3,43 @@ import { defineRoute } from '@shipfox/node-fastify';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { setManagedVariables } from '#core/index.js';
|
|
5
5
|
import { toVariableDto } from '#presentation/dto/index.js';
|
|
6
|
-
import { requireManagementWrite } from './auth.js';
|
|
7
6
|
import { translateManagementError } from './errors.js';
|
|
8
7
|
import { variableWarnings } from './warnings.js';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
export function batchVariablesRoute(accessControl) {
|
|
9
|
+
return defineRoute({
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/variables::batch',
|
|
12
|
+
description: 'Create or update multiple user-managed variables in one scope.',
|
|
13
|
+
schema: {
|
|
14
|
+
params: z.object({
|
|
15
|
+
workspaceId: z.string().uuid()
|
|
16
|
+
}),
|
|
17
|
+
body: batchVariablesBodySchema,
|
|
18
|
+
response: {
|
|
19
|
+
200: batchVariablesResponseSchema
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
errorHandler: translateManagementError,
|
|
23
|
+
handler: async (request)=>{
|
|
24
|
+
const { workspaceId } = request.params;
|
|
25
|
+
const { project_id: projectId, entries } = request.body;
|
|
26
|
+
const access = await accessControl.requireManagementWrite({
|
|
27
|
+
request,
|
|
28
|
+
workspaceId,
|
|
29
|
+
projectId
|
|
30
|
+
});
|
|
31
|
+
const variables = await setManagedVariables({
|
|
32
|
+
workspaceId,
|
|
33
|
+
projectId,
|
|
34
|
+
actorId: access.userId,
|
|
35
|
+
entries
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
variables: variables.map(toVariableDto),
|
|
39
|
+
warnings: variableWarnings(entries)
|
|
40
|
+
};
|
|
20
41
|
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
handler: async (request)=>{
|
|
24
|
-
const { workspaceId } = request.params;
|
|
25
|
-
const { project_id: projectId, entries } = request.body;
|
|
26
|
-
const access = await requireManagementWrite({
|
|
27
|
-
request,
|
|
28
|
-
workspaceId,
|
|
29
|
-
projectId
|
|
30
|
-
});
|
|
31
|
-
const variables = await setManagedVariables({
|
|
32
|
-
workspaceId,
|
|
33
|
-
projectId,
|
|
34
|
-
actorId: access.userId,
|
|
35
|
-
entries
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
variables: variables.map(toVariableDto),
|
|
39
|
-
warnings: variableWarnings(entries)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
43
44
|
|
|
44
45
|
//# sourceMappingURL=batch-variables.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/batch-variables.ts"],"sourcesContent":["import {batchVariablesBodySchema, batchVariablesResponseSchema} from '@shipfox/api-secrets-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {setManagedVariables} from '#core/index.js';\nimport {toVariableDto} from '#presentation/dto/index.js';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/batch-variables.ts"],"sourcesContent":["import {batchVariablesBodySchema, batchVariablesResponseSchema} from '@shipfox/api-secrets-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {setManagedVariables} from '#core/index.js';\nimport {toVariableDto} from '#presentation/dto/index.js';\nimport type {ManagementAccessHelpers} from './auth.js';\nimport {translateManagementError} from './errors.js';\nimport {variableWarnings} from './warnings.js';\n\nexport function batchVariablesRoute(accessControl: ManagementAccessHelpers) {\n return defineRoute({\n method: 'POST',\n path: '/variables::batch',\n description: 'Create or update multiple user-managed variables in one scope.',\n schema: {\n params: z.object({workspaceId: z.string().uuid()}),\n body: batchVariablesBodySchema,\n response: {200: batchVariablesResponseSchema},\n },\n errorHandler: translateManagementError,\n handler: async (request) => {\n const {workspaceId} = request.params;\n const {project_id: projectId, entries} = request.body;\n const access = await accessControl.requireManagementWrite({request, workspaceId, projectId});\n const variables = await setManagedVariables({\n workspaceId,\n projectId,\n actorId: access.userId,\n entries,\n });\n\n return {variables: variables.map(toVariableDto), warnings: variableWarnings(entries)};\n },\n });\n}\n"],"names":["batchVariablesBodySchema","batchVariablesResponseSchema","defineRoute","z","setManagedVariables","toVariableDto","translateManagementError","variableWarnings","batchVariablesRoute","accessControl","method","path","description","schema","params","object","workspaceId","string","uuid","body","response","errorHandler","handler","request","project_id","projectId","entries","access","requireManagementWrite","variables","actorId","userId","map","warnings"],"mappings":"AAAA,SAAQA,wBAAwB,EAAEC,4BAA4B,QAAO,2BAA2B;AAChG,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,mBAAmB,QAAO,iBAAiB;AACnD,SAAQC,aAAa,QAAO,6BAA6B;AAEzD,SAAQC,wBAAwB,QAAO,cAAc;AACrD,SAAQC,gBAAgB,QAAO,gBAAgB;AAE/C,OAAO,SAASC,oBAAoBC,aAAsC;IACxE,OAAOP,YAAY;QACjBQ,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,QAAQX,EAAEY,MAAM,CAAC;gBAACC,aAAab,EAAEc,MAAM,GAAGC,IAAI;YAAE;YAChDC,MAAMnB;YACNoB,UAAU;gBAAC,KAAKnB;YAA4B;QAC9C;QACAoB,cAAcf;QACdgB,SAAS,OAAOC;YACd,MAAM,EAACP,WAAW,EAAC,GAAGO,QAAQT,MAAM;YACpC,MAAM,EAACU,YAAYC,SAAS,EAAEC,OAAO,EAAC,GAAGH,QAAQJ,IAAI;YACrD,MAAMQ,SAAS,MAAMlB,cAAcmB,sBAAsB,CAAC;gBAACL;gBAASP;gBAAaS;YAAS;YAC1F,MAAMI,YAAY,MAAMzB,oBAAoB;gBAC1CY;gBACAS;gBACAK,SAASH,OAAOI,MAAM;gBACtBL;YACF;YAEA,OAAO;gBAACG,WAAWA,UAAUG,GAAG,CAAC3B;gBAAgB4B,UAAU1B,iBAAiBmB;YAAQ;QACtF;IACF;AACF"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ManagementAccessHelpers } from './auth.js';
|
|
2
|
+
export declare function deleteSecretRoute(accessControl: ManagementAccessHelpers): import("@shipfox/node-fastify").RouteDefinition;
|
|
2
3
|
//# sourceMappingURL=delete-secret.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-secret.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/delete-secret.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delete-secret.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/delete-secret.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,WAAW,CAAC;AAGvD,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,uBAAuB,mDAoBvE"}
|