@shipfox/api-server 13.1.0 → 14.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.
@@ -1,2 +1,2 @@
1
1
  $ shipfox-swc
2
- Successfully compiled: 7 files with swc (635.4ms)
2
+ Successfully compiled: 7 files with swc (574.21ms)
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @shipfox/api-server
2
2
 
3
+ ## 14.0.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 98597b7: Adds an `agentModule` factory option to `DefaultModulesOptions` so hosts can replace the standard Agent module while keeping a scoped Secrets client and a single inter-module transport.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [c0fc35b]
12
+ - Updated dependencies [05c7c4d]
13
+ - Updated dependencies [f7b3db8]
14
+ - Updated dependencies [a97890f]
15
+ - Updated dependencies [69a92c4]
16
+ - Updated dependencies [09924ca]
17
+ - Updated dependencies [110e8dd]
18
+ - Updated dependencies [4f30864]
19
+ - Updated dependencies [18e9bad]
20
+ - Updated dependencies [5e87483]
21
+ - Updated dependencies [a4df8d9]
22
+ - Updated dependencies [aeaa0de]
23
+ - Updated dependencies [c44641f]
24
+ - Updated dependencies [b6c7871]
25
+ - Updated dependencies [1b71a66]
26
+ - Updated dependencies [b766ee3]
27
+ - @shipfox/api-definitions-dto@14.0.0
28
+ - @shipfox/api-definitions@14.0.0
29
+ - @shipfox/api-triggers@14.0.0
30
+ - @shipfox/api-runners-dto@14.0.0
31
+ - @shipfox/api-runners@14.0.0
32
+ - @shipfox/api-agent-dto@14.0.0
33
+ - @shipfox/api-agent@14.0.0
34
+ - @shipfox/api-workflows@14.0.0
35
+ - @shipfox/api-workflows-dto@14.0.0
36
+ - @shipfox/api-integration-core@14.0.0
37
+ - @shipfox/api-integration-core-dto@14.0.0
38
+ - @shipfox/api-projects-dto@14.0.0
39
+ - @shipfox/api-dispatcher@12.2.0
40
+ - @shipfox/api-workspaces@14.0.0
41
+ - @shipfox/api-logs@14.0.0
42
+ - @shipfox/api-projects@14.0.0
43
+ - @shipfox/api-secrets@14.0.0
44
+
3
45
  ## 13.1.0
4
46
 
5
47
  ### Patch Changes
package/README.md CHANGED
@@ -5,6 +5,7 @@ Runs a Shipfox API server.
5
5
  ## What it does
6
6
 
7
7
  - **`defaultModules()`**: Returns the standard module list.
8
+ - **`DefaultAgentModuleFactory`**: Builds the Agent module with a scoped Secrets client.
8
9
  - **`DefaultAuthModuleFactory`**: Builds the Auth module with the composed Workspaces client.
9
10
  - **`createServer()`**: Builds an API server. The caller owns process signals.
10
11
  - **`runServer()`**: Starts the server. It listens for SIGTERM and SIGINT.
@@ -46,6 +47,25 @@ const modules = await defaultModules({
46
47
  });
47
48
  ```
48
49
 
50
+ To replace the Agent module, use the Agent factory. It receives the composed
51
+ Secrets operations used by Agent, and its returned module is included in the
52
+ standard composition before presentation registration and transport sealing:
53
+
54
+ ```ts
55
+ import {createAgentModule} from '@shipfox/api-agent';
56
+
57
+ const modules = await defaultModules({
58
+ agentModule: ({secrets}) => createAgentModule({secrets, managedProvider}),
59
+ });
60
+ ```
61
+
62
+ The standard `createAgentModule` validates Agent configuration during
63
+ composition. A custom factory that does not call it owns equivalent validation.
64
+ Its module must declare the `agent` database namespace and present the canonical
65
+ Agent inter-module contract. The scoped Secrets client exposes only the
66
+ operations used by Agent. Treat a custom module as trusted code with access to
67
+ those operations.
68
+
49
69
  Load the instrumentation entry before feature modules:
50
70
 
51
71
  ```sh
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { type DefaultAuthModuleFactory, type DefaultModulesExtension, type DefaultModulesOptions, type DefaultRunnersModuleFactory, defaultModules, } from './modules.js';
1
+ export { type DefaultAgentModuleFactory, type DefaultAuthModuleFactory, type DefaultModulesExtension, type DefaultModulesOptions, type DefaultRunnersModuleFactory, defaultModules, } from './modules.js';
2
2
  export { createLoginMethodsRoute } from './routes/login-methods.js';
3
3
  export type { CreateServerOptions, RunServerOptions, ServerHandle } from './server.js';
4
4
  export { createServer, runServer } from './server.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,YAAY,EAAC,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AACrF,OAAO,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,YAAY,EAAC,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AACrF,OAAO,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n type DefaultAuthModuleFactory,\n type DefaultModulesExtension,\n type DefaultModulesOptions,\n type DefaultRunnersModuleFactory,\n defaultModules,\n} from './modules.js';\nexport {createLoginMethodsRoute} from './routes/login-methods.js';\nexport type {CreateServerOptions, RunServerOptions, ServerHandle} from './server.js';\nexport {createServer, runServer} from './server.js';\n"],"names":["defaultModules","createLoginMethodsRoute","createServer","runServer"],"mappings":"AAAA,SAKEA,cAAc,QACT,eAAe;AACtB,SAAQC,uBAAuB,QAAO,4BAA4B;AAElE,SAAQC,YAAY,EAAEC,SAAS,QAAO,cAAc"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {\n type DefaultAgentModuleFactory,\n type DefaultAuthModuleFactory,\n type DefaultModulesExtension,\n type DefaultModulesOptions,\n type DefaultRunnersModuleFactory,\n defaultModules,\n} from './modules.js';\nexport {createLoginMethodsRoute} from './routes/login-methods.js';\nexport type {CreateServerOptions, RunServerOptions, ServerHandle} from './server.js';\nexport {createServer, runServer} from './server.js';\n"],"names":["defaultModules","createLoginMethodsRoute","createServer","runServer"],"mappings":"AAAA,SAMEA,cAAc,QACT,eAAe;AACtB,SAAQC,uBAAuB,QAAO,4BAA4B;AAElE,SAAQC,YAAY,EAAEC,SAAS,QAAO,cAAc"}
package/dist/modules.d.ts CHANGED
@@ -1,16 +1,28 @@
1
1
  import { type AuthInterModuleClient } from '@shipfox/api-auth-dto/inter-module';
2
2
  import { type WebhookDeliverySource } from '@shipfox/api-integration-core';
3
+ import { type SecretsInterModuleClient } from '@shipfox/api-secrets-dto/inter-module';
3
4
  import { type WorkspacesInterModuleClient } from '@shipfox/api-workspaces-dto/inter-module';
4
5
  import type { ShipfoxModule } from '@shipfox/node-module';
5
6
  export interface DefaultModulesOptions {
6
7
  webhookDeliverySource?: WebhookDeliverySource | undefined;
7
8
  authModule?: DefaultAuthModuleFactory | undefined;
9
+ agentModule?: DefaultAgentModuleFactory | undefined;
8
10
  runnersModule?: DefaultRunnersModuleFactory | undefined;
9
11
  extension?: DefaultModulesExtension | undefined;
10
12
  }
11
13
  export type DefaultAuthModuleFactory = (options: {
12
14
  workspaces: WorkspacesInterModuleClient;
13
15
  }) => ShipfoxModule;
16
+ /**
17
+ * Builds the Agent module in the standard composition slot. The default
18
+ * factory validates Agent configuration through `createAgentModule`; a custom
19
+ * factory owns equivalent validation when it does not delegate to that
20
+ * factory. Custom modules must preserve the `agent` database namespace and
21
+ * canonical Agent presentation required by the composed clients.
22
+ */
23
+ export type DefaultAgentModuleFactory = (options: {
24
+ secrets: Pick<SecretsInterModuleClient, 'deleteSecrets' | 'getSecretsByNamespace' | 'setSecrets'>;
25
+ }) => ShipfoxModule;
14
26
  export type DefaultRunnersModuleFactory = (options: {
15
27
  auth: AuthInterModuleClient;
16
28
  }) => ShipfoxModule;
@@ -1 +1 @@
1
- {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,oCAAoC,CAAC;AAK5C,OAAO,EAA4B,KAAK,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AAapG,OAAO,EACL,KAAK,2BAA2B,EAEjC,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAOxD,MAAM,WAAW,qBAAqB;IACpC,qBAAqB,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAC;IAC1D,UAAU,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;IAClD,aAAa,CAAC,EAAE,2BAA2B,GAAG,SAAS,CAAC;IACxD,SAAS,CAAC,EAAE,uBAAuB,GAAG,SAAS,CAAC;CACjD;AAED,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,EAAE;IAC/C,UAAU,EAAE,2BAA2B,CAAC;CACzC,KAAK,aAAa,CAAC;AACpB,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,EAAE;IAAC,IAAI,EAAE,qBAAqB,CAAA;CAAC,KAAK,aAAa,CAAC;AACpG,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,EAAE;IAC9C,UAAU,EAAE,2BAA2B,CAAC;CACzC,KAAK,aAAa,EAAE,CAAC;AAEtB,wBAAsB,cAAc,CAClC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,aAAa,EAAE,CAAC,CAiJ1B"}
1
+ {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[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139,10 @@ export async function defaultModules(options = {}) {
139
139
  const extensionModules = options.extension?.({
140
140
  workspaces: workspacesClient
141
141
  }) ?? [];
142
+ const agentModule = (options.agentModule ?? createAgentModule)({
143
+ secrets: createAgentSecretsClient(secretsClient)
144
+ });
145
+ if (options.agentModule) validateCustomAgentModule(agentModule);
142
146
  const modules = [
143
147
  emailChallengesModule,
144
148
  (options.authModule ?? createAuthModule)({
@@ -150,9 +154,7 @@ export async function defaultModules(options = {}) {
150
154
  runners: runnersClient
151
155
  }),
152
156
  createSecretsModule(projectsClient),
153
- createAgentModule({
154
- secrets: secretsClient
155
- }),
157
+ agentModule,
156
158
  integrations.module,
157
159
  projectsModule,
158
160
  definitionsModule,
@@ -188,5 +190,23 @@ export async function defaultModules(options = {}) {
188
190
  interModuleTransport.seal();
189
191
  return modules;
190
192
  }
193
+ function createAgentSecretsClient(secretsClient) {
194
+ return {
195
+ deleteSecrets: (input, options)=>secretsClient.deleteSecrets(input, options),
196
+ getSecretsByNamespace: (input, options)=>secretsClient.getSecretsByNamespace(input, options),
197
+ setSecrets: (input, options)=>secretsClient.setSecrets(input, options)
198
+ };
199
+ }
200
+ function validateCustomAgentModule(module) {
201
+ const databases = module.database ? Array.isArray(module.database) ? module.database : [
202
+ module.database
203
+ ] : [];
204
+ if (!databases.some(({ databaseNamespace })=>databaseNamespace === agentInterModuleContract.module)) {
205
+ throw new Error('Custom agentModule must declare database namespace "agent" for the Agent module.');
206
+ }
207
+ if (!module.interModulePresentations?.some(({ contract })=>contract === agentInterModuleContract)) {
208
+ throw new Error('Custom agentModule must present the canonical "agent" inter-module contract.');
209
+ }
210
+ }
191
211
 
192
212
  //# sourceMappingURL=modules.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/modules.ts"],"sourcesContent":["import {annotationsModule} from '@shipfox/annotations';\nimport {annotationsInterModuleContract} from '@shipfox/annotations-dto/inter-module';\nimport {createAgentModule} from '@shipfox/api-agent';\nimport {agentInterModuleContract} from '@shipfox/api-agent-dto/inter-module';\nimport {createAuthModule} from '@shipfox/api-auth';\nimport {config as authConfig} from '@shipfox/api-auth/config';\nimport {\n type AuthInterModuleClient,\n authInterModuleContract,\n} from '@shipfox/api-auth-dto/inter-module';\nimport {createDefinitionsModule} from '@shipfox/api-definitions';\nimport {definitionsInterModuleContract} from '@shipfox/api-definitions-dto/inter-module';\nimport {dispatcherModule} from '@shipfox/api-dispatcher';\nimport {emailChallengesModule} from '@shipfox/api-email-challenges';\nimport {createIntegrationsContext, type WebhookDeliverySource} from '@shipfox/api-integration-core';\nimport {integrationsInterModuleContract} from '@shipfox/api-integration-core-dto/inter-module';\nimport {createLogsModule} from '@shipfox/api-logs';\nimport {createProjectsModule} from '@shipfox/api-projects';\nimport {projectsInterModuleContract} from '@shipfox/api-projects-dto/inter-module';\nimport {createRunnersModule} from '@shipfox/api-runners';\nimport {runnersInterModuleContract} from '@shipfox/api-runners-dto/inter-module';\nimport {createSecretsModule} from '@shipfox/api-secrets';\nimport {secretsInterModuleContract} from '@shipfox/api-secrets-dto/inter-module';\nimport {createTriggersModule} from '@shipfox/api-triggers';\nimport {createWorkflowsModule} from '@shipfox/api-workflows';\nimport {workflowsInterModuleContract} from '@shipfox/api-workflows-dto/inter-module';\nimport {createWorkspacesModule} from '@shipfox/api-workspaces';\nimport {\n type WorkspacesInterModuleClient,\n workspacesInterModuleContract,\n} from '@shipfox/api-workspaces-dto/inter-module';\nimport {reportError} from '@shipfox/node-error-monitoring';\nimport {durationToSeconds} from '@shipfox/node-jwt';\nimport type {ShipfoxModule} from '@shipfox/node-module';\nimport {\n createInMemoryInterModuleTransport,\n registerInterModulePresentations,\n} from '@shipfox/node-module/inter-module';\nimport {logger} from '@shipfox/node-opentelemetry';\n\nexport interface DefaultModulesOptions {\n webhookDeliverySource?: WebhookDeliverySource | undefined;\n authModule?: DefaultAuthModuleFactory | undefined;\n runnersModule?: DefaultRunnersModuleFactory | undefined;\n extension?: DefaultModulesExtension | undefined;\n}\n\nexport type DefaultAuthModuleFactory = (options: {\n workspaces: WorkspacesInterModuleClient;\n}) => ShipfoxModule;\nexport type DefaultRunnersModuleFactory = (options: {auth: AuthInterModuleClient}) => ShipfoxModule;\nexport type DefaultModulesExtension = (options: {\n workspaces: WorkspacesInterModuleClient;\n}) => ShipfoxModule[];\n\nexport async function defaultModules(\n options: DefaultModulesOptions = {},\n): Promise<ShipfoxModule[]> {\n const interModuleTransport = createInMemoryInterModuleTransport({\n reportInternalError: (error, context) => {\n logger().error(\n {err: error, module: context.module, method: context.method, phase: context.phase},\n 'Inter-module call failed unexpectedly',\n );\n reportError(error, {\n boundary: 'inter-module',\n operation: `${context.module}.${context.method}`,\n tags: {module: context.module, method: context.method, phase: context.phase},\n });\n },\n });\n const workflowsClient = interModuleTransport.createClient(workflowsInterModuleContract);\n const authClient = interModuleTransport.createClient(authInterModuleContract);\n const agentClient = interModuleTransport.createClient(agentInterModuleContract);\n const runnersClient = interModuleTransport.createClient(runnersInterModuleContract);\n const projectsClient = interModuleTransport.createClient(projectsInterModuleContract);\n const definitionsClient = interModuleTransport.createClient(definitionsInterModuleContract);\n const annotationsClient = interModuleTransport.createClient(annotationsInterModuleContract);\n const secretsClient = interModuleTransport.createClient(secretsInterModuleContract);\n const workspacesClient = interModuleTransport.createClient(workspacesInterModuleContract);\n const integrationsClient = interModuleTransport.createClient(integrationsInterModuleContract);\n const integrations = await createIntegrationsContext({\n workspaces: workspacesClient,\n secrets: {\n deleteSecrets: async (params) => (await secretsClient.deleteSecrets(params)).deleted,\n linear: {\n getSecret: async (params) =>\n (\n await secretsClient.getSecret({\n ...params,\n namespace: `system/integrations/linear/${params.namespace}`,\n })\n ).value,\n setSecrets: async (params) => {\n const {editedBy, ...secretParams} = params;\n await secretsClient.setSecrets({\n ...secretParams,\n namespace: `system/integrations/linear/${secretParams.namespace}`,\n ...(editedBy === undefined ? {} : {editedBy}),\n });\n },\n deleteSecrets: async (params) =>\n (\n await secretsClient.deleteSecrets({\n ...params,\n namespace: `system/integrations/linear/${params.namespace}`,\n })\n ).deleted,\n },\n jira: {\n getSecret: async (params) =>\n (\n await secretsClient.getSecret({\n ...params,\n namespace: `system/integrations/jira/${params.namespace}`,\n })\n ).value,\n setSecrets: async (params) => {\n const {editedBy, ...secretParams} = params;\n await secretsClient.setSecrets({\n ...secretParams,\n namespace: `system/integrations/jira/${secretParams.namespace}`,\n ...(editedBy === undefined ? {} : {editedBy}),\n });\n },\n deleteSecrets: async (params) =>\n (\n await secretsClient.deleteSecrets({\n ...params,\n namespace: `system/integrations/jira/${params.namespace}`,\n })\n ).deleted,\n },\n slack: {\n getSecret: async (params) =>\n (\n await secretsClient.getSecret({\n ...params,\n namespace: `system/integrations/slack/${params.namespace}`,\n })\n ).value,\n setSecrets: async (params) => {\n const {editedBy, ...secretParams} = params;\n await secretsClient.setSecrets({\n ...secretParams,\n namespace: `system/integrations/slack/${secretParams.namespace}`,\n ...(editedBy === undefined ? {} : {editedBy}),\n });\n },\n deleteSecrets: async (params) =>\n (\n await secretsClient.deleteSecrets({\n ...params,\n namespace: `system/integrations/slack/${params.namespace}`,\n })\n ).deleted,\n },\n },\n agentTools: {workflows: workflowsClient},\n webhookDeliverySource: options.webhookDeliverySource,\n });\n const projectsModule = createProjectsModule({integrations: integrationsClient, auth: authClient});\n const definitionsModule = createDefinitionsModule({\n projects: projectsClient,\n agent: agentClient,\n integrations: integrationsClient,\n });\n const extensionModules = options.extension?.({workspaces: workspacesClient}) ?? [];\n\n const modules = [\n emailChallengesModule,\n (options.authModule ?? createAuthModule)({workspaces: workspacesClient}),\n createWorkspacesModule({auth: authClient, projects: projectsClient, runners: runnersClient}),\n createSecretsModule(projectsClient),\n createAgentModule({secrets: secretsClient}),\n integrations.module,\n projectsModule,\n definitionsModule,\n createWorkflowsModule({\n annotations: annotationsClient,\n agent: agentClient,\n definitions: definitionsClient,\n auth: authClient,\n projects: projectsClient,\n runners: runnersClient,\n secrets: secretsClient,\n workspaces: workspacesClient,\n integrations: integrationsClient,\n }),\n annotationsModule,\n (options.runnersModule ?? createRunnersModule)({auth: authClient}),\n createLogsModule({\n workflows: workflowsClient,\n jobLeaseTokenTtlSeconds: durationToSeconds(authConfig.AUTH_JOB_LEASE_TOKEN_EXPIRES_IN),\n }),\n createTriggersModule({workflows: workflowsClient}),\n dispatcherModule,\n ...extensionModules,\n ];\n registerInterModulePresentations({transport: interModuleTransport, modules});\n interModuleTransport.seal();\n return modules;\n}\n"],"names":["annotationsModule","annotationsInterModuleContract","createAgentModule","agentInterModuleContract","createAuthModule","config","authConfig","authInterModuleContract","createDefinitionsModule","definitionsInterModuleContract","dispatcherModule","emailChallengesModule","createIntegrationsContext","integrationsInterModuleContract","createLogsModule","createProjectsModule","projectsInterModuleContract","createRunnersModule","runnersInterModuleContract","createSecretsModule","secretsInterModuleContract","createTriggersModule","createWorkflowsModule","workflowsInterModuleContract","createWorkspacesModule","workspacesInterModuleContract","reportError","durationToSeconds","createInMemoryInterModuleTransport","registerInterModulePresentations","logger","defaultModules","options","interModuleTransport","reportInternalError","error","context","err","module","method","phase","boundary","operation","tags","workflowsClient","createClient","authClient","agentClient","runnersClient","projectsClient","definitionsClient","annotationsClient","secretsClient","workspacesClient","integrationsClient","integrations","workspaces","secrets","deleteSecrets","params","deleted","linear","getSecret","namespace","value","setSecrets","editedBy","secretParams","undefined","jira","slack","agentTools","workflows","webhookDeliverySource","projectsModule","auth","definitionsModule","projects","agent","extensionModules","extension","modules","authModule","runners","annotations","definitions","runnersModule","jobLeaseTokenTtlSeconds","AUTH_JOB_LEASE_TOKEN_EXPIRES_IN","transport","seal"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,uBAAuB;AACvD,SAAQC,8BAA8B,QAAO,wCAAwC;AACrF,SAAQC,iBAAiB,QAAO,qBAAqB;AACrD,SAAQC,wBAAwB,QAAO,sCAAsC;AAC7E,SAAQC,gBAAgB,QAAO,oBAAoB;AACnD,SAAQC,UAAUC,UAAU,QAAO,2BAA2B;AAC9D,SAEEC,uBAAuB,QAClB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AC,0BAA0B,EAAEJ,OAAOI,SAAS,EAAE;oBAC5D,EAAC,EACDH,OAAO;YACb;QACF;QACAW,YAAY;YAACC,WAAW5B;QAAe;QACvC6B,uBAAuBzC,QAAQyC,qBAAqB;IACtD;IACA,MAAMC,iBAAiB3D,qBAAqB;QAACwC,cAAcD;QAAoBqB,MAAM7B;IAAU;IAC/F,MAAM8B,oBAAoBpE,wBAAwB;QAChDqE,UAAU5B;QACV6B,OAAO/B;QACPQ,cAAcD;IAChB;IACA,MAAMyB,mBAAmB/C,QAAQgD,SAAS,GAAG;QAACxB,YAAYH;IAAgB,MAAM,EAAE;IAElF,MAAM4B,UAAU;QACdtE;QACCqB,CAAAA,QAAQkD,UAAU,IAAI9E,gBAAe,EAAG;YAACoD,YAAYH;QAAgB;QACtE7B,uBAAuB;YAACmD,MAAM7B;YAAY+B,UAAU5B;YAAgBkC,SAASnC;QAAa;QAC1F7B,oBAAoB8B;QACpB/C,kBAAkB;YAACuD,SAASL;QAAa;QACzCG,aAAajB,MAAM;QACnBoC;QACAE;QACAtD,sBAAsB;YACpB8D,aAAajC;YACb2B,OAAO/B;YACPsC,aAAanC;YACbyB,MAAM7B;YACN+B,UAAU5B;YACVkC,SAASnC;YACTS,SAASL;YACTI,YAAYH;YACZE,cAAcD;QAChB;QACAtD;QACCgC,CAAAA,QAAQsD,aAAa,IAAIrE,mBAAkB,EAAG;YAAC0D,MAAM7B;QAAU;QAChEhC,iBAAiB;YACf0D,WAAW5B;YACX2C,yBAAyB5D,kBAAkBrB,WAAWkF,+BAA+B;QACvF;QACAnE,qBAAqB;YAACmD,WAAW5B;QAAe;QAChDlC;WACGqE;KACJ;IACDlD,iCAAiC;QAAC4D,WAAWxD;QAAsBgD;IAAO;IAC1EhD,qBAAqByD,IAAI;IACzB,OAAOT;AACT"}
1
+ {"version":3,"sources":["../src/modules.ts"],"sourcesContent":["import {annotationsModule} from '@shipfox/annotations';\nimport {annotationsInterModuleContract} from '@shipfox/annotations-dto/inter-module';\nimport {createAgentModule} from '@shipfox/api-agent';\nimport {agentInterModuleContract} from '@shipfox/api-agent-dto/inter-module';\nimport {createAuthModule} from '@shipfox/api-auth';\nimport {config as authConfig} from '@shipfox/api-auth/config';\nimport {\n type AuthInterModuleClient,\n authInterModuleContract,\n} from '@shipfox/api-auth-dto/inter-module';\nimport {createDefinitionsModule} from '@shipfox/api-definitions';\nimport {definitionsInterModuleContract} from '@shipfox/api-definitions-dto/inter-module';\nimport {dispatcherModule} from '@shipfox/api-dispatcher';\nimport {emailChallengesModule} from '@shipfox/api-email-challenges';\nimport {createIntegrationsContext, type WebhookDeliverySource} from '@shipfox/api-integration-core';\nimport {integrationsInterModuleContract} from '@shipfox/api-integration-core-dto/inter-module';\nimport {createLogsModule} from '@shipfox/api-logs';\nimport {createProjectsModule} from '@shipfox/api-projects';\nimport {projectsInterModuleContract} from '@shipfox/api-projects-dto/inter-module';\nimport {createRunnersModule} from '@shipfox/api-runners';\nimport {runnersInterModuleContract} from '@shipfox/api-runners-dto/inter-module';\nimport {createSecretsModule} from '@shipfox/api-secrets';\nimport {\n type SecretsInterModuleClient,\n secretsInterModuleContract,\n} from '@shipfox/api-secrets-dto/inter-module';\nimport {createTriggersModule} from '@shipfox/api-triggers';\nimport {createWorkflowsModule} from '@shipfox/api-workflows';\nimport {workflowsInterModuleContract} from '@shipfox/api-workflows-dto/inter-module';\nimport {createWorkspacesModule} from '@shipfox/api-workspaces';\nimport {\n type WorkspacesInterModuleClient,\n workspacesInterModuleContract,\n} from '@shipfox/api-workspaces-dto/inter-module';\nimport {reportError} from '@shipfox/node-error-monitoring';\nimport {durationToSeconds} from '@shipfox/node-jwt';\nimport type {ShipfoxModule} from '@shipfox/node-module';\nimport {\n createInMemoryInterModuleTransport,\n registerInterModulePresentations,\n} from '@shipfox/node-module/inter-module';\nimport {logger} from '@shipfox/node-opentelemetry';\n\nexport interface DefaultModulesOptions {\n webhookDeliverySource?: WebhookDeliverySource | undefined;\n authModule?: DefaultAuthModuleFactory | undefined;\n agentModule?: DefaultAgentModuleFactory | undefined;\n runnersModule?: DefaultRunnersModuleFactory | undefined;\n extension?: DefaultModulesExtension | undefined;\n}\n\nexport type DefaultAuthModuleFactory = (options: {\n workspaces: WorkspacesInterModuleClient;\n}) => ShipfoxModule;\n\n/**\n * Builds the Agent module in the standard composition slot. The default\n * factory validates Agent configuration through `createAgentModule`; a custom\n * factory owns equivalent validation when it does not delegate to that\n * factory. Custom modules must preserve the `agent` database namespace and\n * canonical Agent presentation required by the composed clients.\n */\nexport type DefaultAgentModuleFactory = (options: {\n secrets: Pick<SecretsInterModuleClient, 'deleteSecrets' | 'getSecretsByNamespace' | 'setSecrets'>;\n}) => ShipfoxModule;\nexport type DefaultRunnersModuleFactory = (options: {auth: AuthInterModuleClient}) => ShipfoxModule;\nexport type DefaultModulesExtension = (options: {\n workspaces: WorkspacesInterModuleClient;\n}) => ShipfoxModule[];\n\nexport async function defaultModules(\n options: DefaultModulesOptions = {},\n): Promise<ShipfoxModule[]> {\n const interModuleTransport = createInMemoryInterModuleTransport({\n reportInternalError: (error, context) => {\n logger().error(\n {err: error, module: context.module, method: context.method, phase: context.phase},\n 'Inter-module call failed unexpectedly',\n );\n reportError(error, {\n boundary: 'inter-module',\n operation: `${context.module}.${context.method}`,\n tags: {module: context.module, method: context.method, phase: context.phase},\n });\n },\n });\n const workflowsClient = interModuleTransport.createClient(workflowsInterModuleContract);\n const authClient = interModuleTransport.createClient(authInterModuleContract);\n const agentClient = interModuleTransport.createClient(agentInterModuleContract);\n const runnersClient = interModuleTransport.createClient(runnersInterModuleContract);\n const projectsClient = interModuleTransport.createClient(projectsInterModuleContract);\n const definitionsClient = interModuleTransport.createClient(definitionsInterModuleContract);\n const annotationsClient = interModuleTransport.createClient(annotationsInterModuleContract);\n const secretsClient = interModuleTransport.createClient(secretsInterModuleContract);\n const workspacesClient = interModuleTransport.createClient(workspacesInterModuleContract);\n const integrationsClient = interModuleTransport.createClient(integrationsInterModuleContract);\n const integrations = await createIntegrationsContext({\n workspaces: workspacesClient,\n secrets: {\n deleteSecrets: async (params) => (await secretsClient.deleteSecrets(params)).deleted,\n linear: {\n getSecret: async (params) =>\n (\n await secretsClient.getSecret({\n ...params,\n namespace: `system/integrations/linear/${params.namespace}`,\n })\n ).value,\n setSecrets: async (params) => {\n const {editedBy, ...secretParams} = params;\n await secretsClient.setSecrets({\n ...secretParams,\n namespace: `system/integrations/linear/${secretParams.namespace}`,\n ...(editedBy === undefined ? {} : {editedBy}),\n });\n },\n deleteSecrets: async (params) =>\n (\n await secretsClient.deleteSecrets({\n ...params,\n namespace: `system/integrations/linear/${params.namespace}`,\n })\n ).deleted,\n },\n jira: {\n getSecret: async (params) =>\n (\n await secretsClient.getSecret({\n ...params,\n namespace: `system/integrations/jira/${params.namespace}`,\n })\n ).value,\n setSecrets: async (params) => {\n const {editedBy, ...secretParams} = params;\n await secretsClient.setSecrets({\n ...secretParams,\n namespace: `system/integrations/jira/${secretParams.namespace}`,\n ...(editedBy === undefined ? {} : {editedBy}),\n });\n },\n deleteSecrets: async (params) =>\n (\n await secretsClient.deleteSecrets({\n ...params,\n namespace: `system/integrations/jira/${params.namespace}`,\n })\n ).deleted,\n },\n slack: {\n getSecret: async (params) =>\n (\n await secretsClient.getSecret({\n ...params,\n namespace: `system/integrations/slack/${params.namespace}`,\n })\n ).value,\n setSecrets: async (params) => {\n const {editedBy, ...secretParams} = params;\n await secretsClient.setSecrets({\n ...secretParams,\n namespace: `system/integrations/slack/${secretParams.namespace}`,\n ...(editedBy === undefined ? {} : {editedBy}),\n });\n },\n deleteSecrets: async (params) =>\n (\n await secretsClient.deleteSecrets({\n ...params,\n namespace: `system/integrations/slack/${params.namespace}`,\n })\n ).deleted,\n },\n },\n agentTools: {workflows: workflowsClient},\n webhookDeliverySource: options.webhookDeliverySource,\n });\n const projectsModule = createProjectsModule({integrations: integrationsClient, auth: authClient});\n const definitionsModule = createDefinitionsModule({\n projects: projectsClient,\n agent: agentClient,\n integrations: integrationsClient,\n });\n const extensionModules = options.extension?.({workspaces: workspacesClient}) ?? [];\n const agentModule = (options.agentModule ?? createAgentModule)({\n secrets: createAgentSecretsClient(secretsClient),\n });\n if (options.agentModule) validateCustomAgentModule(agentModule);\n\n const modules = [\n emailChallengesModule,\n (options.authModule ?? createAuthModule)({workspaces: workspacesClient}),\n createWorkspacesModule({auth: authClient, projects: projectsClient, runners: runnersClient}),\n createSecretsModule(projectsClient),\n agentModule,\n integrations.module,\n projectsModule,\n definitionsModule,\n createWorkflowsModule({\n annotations: annotationsClient,\n agent: agentClient,\n definitions: definitionsClient,\n auth: authClient,\n projects: projectsClient,\n runners: runnersClient,\n secrets: secretsClient,\n workspaces: workspacesClient,\n integrations: integrationsClient,\n }),\n annotationsModule,\n (options.runnersModule ?? createRunnersModule)({auth: authClient}),\n createLogsModule({\n workflows: workflowsClient,\n jobLeaseTokenTtlSeconds: durationToSeconds(authConfig.AUTH_JOB_LEASE_TOKEN_EXPIRES_IN),\n }),\n createTriggersModule({workflows: workflowsClient}),\n dispatcherModule,\n ...extensionModules,\n ];\n registerInterModulePresentations({transport: interModuleTransport, modules});\n interModuleTransport.seal();\n return modules;\n}\n\ntype AgentModuleSecretsClient = Pick<\n SecretsInterModuleClient,\n 'deleteSecrets' | 'getSecretsByNamespace' | 'setSecrets'\n>;\n\nfunction createAgentSecretsClient(\n secretsClient: SecretsInterModuleClient,\n): AgentModuleSecretsClient {\n return {\n deleteSecrets: (input, options) => secretsClient.deleteSecrets(input, options),\n getSecretsByNamespace: (input, options) => secretsClient.getSecretsByNamespace(input, options),\n setSecrets: (input, options) => secretsClient.setSecrets(input, options),\n };\n}\n\nfunction validateCustomAgentModule(module: ShipfoxModule): void {\n const databases = module.database\n ? Array.isArray(module.database)\n ? module.database\n : [module.database]\n : [];\n if (\n !databases.some(({databaseNamespace}) => databaseNamespace === agentInterModuleContract.module)\n ) {\n throw new Error(\n 'Custom agentModule must declare database namespace \"agent\" for the Agent module.',\n );\n }\n\n if (\n !module.interModulePresentations?.some(({contract}) => contract === agentInterModuleContract)\n ) {\n throw new Error('Custom agentModule must present the canonical \"agent\" inter-module contract.');\n }\n}\n"],"names":["annotationsModule","annotationsInterModuleContract","createAgentModule","agentInterModuleContract","createAuthModule","config","authConfig","authInterModuleContract","createDefinitionsModule","definitionsInterModuleContract","dispatcherModule","emailChallengesModule","createIntegrationsContext","integrationsInterModuleContract","createLogsModule","createProjectsModule","projectsInterModuleContract","createRunnersModule","runnersInterModuleContract","createSecretsModule","secretsInterModuleContract","createTriggersModule","createWorkflowsModule","workflowsInterModuleContract","createWorkspacesModule","workspacesInterModuleContract","reportError","durationToSeconds","createInMemoryInterModuleTransport","registerInterModulePresentations","logger","defaultModules","options","interModuleTransport","reportInternalError","error","context","err","module","method","phase","boundary","operation","tags","workflowsClient","createClient","authClient","agentClient","runnersClient","projectsClient","definitionsClient","annotationsClient","secretsClient","workspacesClient","integrationsClient","integrations","workspaces","secrets","deleteSecrets","params","deleted","linear","getSecret","namespace","value","setSecrets","editedBy","secretParams","undefined","jira","slack","agentTools","workflows","webhookDeliverySource","projectsModule","auth","definitionsModule","projects","agent","extensionModules","extension","agentModule","createAgentSecretsClient","validateCustomAgentModule","modules","authModule","runners","annotations","definitions","runnersModule","jobLeaseTokenTtlSeconds","AUTH_JOB_LEASE_TOKEN_EXPIRES_IN","transport","seal","input","getSecretsByNamespace","databases","database","Array","isArray","some","databaseNamespace","Error","interModulePresentations","contract"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,uBAAuB;AACvD,SAAQC,8BAA8B,QAAO,wCAAwC;AACrF,SAAQC,iBAAiB,QAAO,qBAAqB;AACrD,SAAQC,wBAAwB,QAAO,sCAAsC;AAC7E,SAAQC,gBAAgB,QAAO,oBAAoB;AACnD,SAAQC,UAAUC,UAAU,QAAO,2BAA2B;AAC9D,SAEEC,uBAAuB,QAClB,qCAAqC;AAC5C,SAAQC,uBAAuB,QAAO,2BAA2B;AACjE,SAAQC,8BAA8B,QAAO,4CAA4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