@shipfox/api-definitions 12.0.0 → 12.2.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 (45) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +25 -0
  3. package/dist/core/entities/sync-state.d.ts +1 -1
  4. package/dist/core/entities/sync-state.d.ts.map +1 -1
  5. package/dist/core/errors.d.ts +2 -2
  6. package/dist/core/errors.d.ts.map +1 -1
  7. package/dist/core/integrations.d.ts +1 -1
  8. package/dist/core/workflow-model/invalid-workflow-model-error.d.ts +1 -1
  9. package/dist/core/workflow-model/invalid-workflow-model-error.d.ts.map +1 -1
  10. package/dist/core/workflow-model/invalid-workflow-model-error.js.map +1 -1
  11. package/dist/core/workflow-model/normalize-jobs.js +5 -29
  12. package/dist/core/workflow-model/normalize-jobs.js.map +1 -1
  13. package/dist/core/workflow-yaml/invalid-workflow-yaml-error.d.ts.map +1 -1
  14. package/dist/db/db.d.ts +10 -10
  15. package/dist/db/schema/definitions.d.ts +1 -1
  16. package/dist/db/schema/outbox.d.ts +1 -1
  17. package/dist/db/schema/sync-states.d.ts +3 -3
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +3 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/presentation/routes/project-access.d.ts +1 -1
  22. package/dist/presentation/subscribers/index.d.ts +1 -0
  23. package/dist/presentation/subscribers/index.d.ts.map +1 -1
  24. package/dist/presentation/subscribers/index.js +1 -0
  25. package/dist/presentation/subscribers/index.js.map +1 -1
  26. package/dist/presentation/subscribers/on-integration-connection-available.d.ts +5 -0
  27. package/dist/presentation/subscribers/on-integration-connection-available.d.ts.map +1 -0
  28. package/dist/presentation/subscribers/on-integration-connection-available.js +32 -0
  29. package/dist/presentation/subscribers/on-integration-connection-available.js.map +1 -0
  30. package/dist/presentation/subscribers/start-definition-sync.d.ts +1 -0
  31. package/dist/presentation/subscribers/start-definition-sync.d.ts.map +1 -1
  32. package/dist/presentation/subscribers/start-definition-sync.js +30 -17
  33. package/dist/presentation/subscribers/start-definition-sync.js.map +1 -1
  34. package/dist/temporal/activities/sync-activities.d.ts.map +1 -1
  35. package/dist/tsconfig.test.tsbuildinfo +1 -1
  36. package/package.json +13 -13
  37. package/src/core/workflow-model/invalid-workflow-model-error.ts +0 -1
  38. package/src/core/workflow-model/normalize-jobs.ts +5 -41
  39. package/src/core/workflow-model/normalize-workflow-document.test.ts +140 -13
  40. package/src/index.ts +12 -1
  41. package/src/presentation/subscribers/index.ts +1 -0
  42. package/src/presentation/subscribers/on-integration-connection-available.test.ts +132 -0
  43. package/src/presentation/subscribers/on-integration-connection-available.ts +44 -0
  44. package/src/presentation/subscribers/start-definition-sync.ts +35 -19
  45. package/tsconfig.build.tsbuildinfo +1 -1
package/dist/db/db.d.ts CHANGED
@@ -228,7 +228,7 @@ export declare const schema: {
228
228
  generated: undefined;
229
229
  }, {}, {}>;
230
230
  };
231
- dialect: "pg";
231
+ dialect: 'pg';
232
232
  }>;
233
233
  definitionsOutbox: import("drizzle-orm/pg-core").PgTableWithColumns<{
234
234
  name: "outbox";
@@ -422,7 +422,7 @@ export declare const schema: {
422
422
  generated: undefined;
423
423
  }, {}, {}>;
424
424
  };
425
- dialect: "pg";
425
+ dialect: 'pg';
426
426
  }>;
427
427
  definitionSyncStates: import("drizzle-orm/pg-core").PgTableWithColumns<{
428
428
  name: "sync_states";
@@ -518,7 +518,7 @@ export declare const schema: {
518
518
  tableName: "sync_states";
519
519
  dataType: "string";
520
520
  columnType: "PgEnumColumn";
521
- data: "pending" | "syncing" | "succeeded" | "failed";
521
+ data: "failed" | "pending" | "succeeded" | "syncing";
522
522
  driverParam: string;
523
523
  notNull: true;
524
524
  hasDefault: true;
@@ -535,7 +535,7 @@ export declare const schema: {
535
535
  tableName: "sync_states";
536
536
  dataType: "string";
537
537
  columnType: "PgEnumColumn";
538
- data: "unknown" | "provider-unavailable" | "no-workflow-files" | "invalid-definition" | "provider-repository-not-found" | "provider-file-not-found" | "provider-access-denied" | "provider-rate-limited" | "provider-timeout" | "provider-malformed-response" | "content-too-large" | "too-many-files" | "connection-unavailable";
538
+ data: "connection-unavailable" | "content-too-large" | "invalid-definition" | "no-workflow-files" | "provider-access-denied" | "provider-file-not-found" | "provider-malformed-response" | "provider-rate-limited" | "provider-repository-not-found" | "provider-timeout" | "provider-unavailable" | "too-many-files" | "unknown";
539
539
  driverParam: string;
540
540
  notNull: false;
541
541
  hasDefault: false;
@@ -652,7 +652,7 @@ export declare const schema: {
652
652
  generated: undefined;
653
653
  }, {}, {}>;
654
654
  };
655
- dialect: "pg";
655
+ dialect: 'pg';
656
656
  }>;
657
657
  };
658
658
  export declare function db(): NodePgDatabase<{
@@ -884,7 +884,7 @@ export declare function db(): NodePgDatabase<{
884
884
  generated: undefined;
885
885
  }, {}, {}>;
886
886
  };
887
- dialect: "pg";
887
+ dialect: 'pg';
888
888
  }>;
889
889
  definitionsOutbox: import("drizzle-orm/pg-core").PgTableWithColumns<{
890
890
  name: "outbox";
@@ -1078,7 +1078,7 @@ export declare function db(): NodePgDatabase<{
1078
1078
  generated: undefined;
1079
1079
  }, {}, {}>;
1080
1080
  };
1081
- dialect: "pg";
1081
+ dialect: 'pg';
1082
1082
  }>;
1083
1083
  definitionSyncStates: import("drizzle-orm/pg-core").PgTableWithColumns<{
1084
1084
  name: "sync_states";
@@ -1174,7 +1174,7 @@ export declare function db(): NodePgDatabase<{
1174
1174
  tableName: "sync_states";
1175
1175
  dataType: "string";
1176
1176
  columnType: "PgEnumColumn";
1177
- data: "pending" | "syncing" | "succeeded" | "failed";
1177
+ data: "failed" | "pending" | "succeeded" | "syncing";
1178
1178
  driverParam: string;
1179
1179
  notNull: true;
1180
1180
  hasDefault: true;
@@ -1191,7 +1191,7 @@ export declare function db(): NodePgDatabase<{
1191
1191
  tableName: "sync_states";
1192
1192
  dataType: "string";
1193
1193
  columnType: "PgEnumColumn";
1194
- data: "unknown" | "provider-unavailable" | "no-workflow-files" | "invalid-definition" | "provider-repository-not-found" | "provider-file-not-found" | "provider-access-denied" | "provider-rate-limited" | "provider-timeout" | "provider-malformed-response" | "content-too-large" | "too-many-files" | "connection-unavailable";
1194
+ data: "connection-unavailable" | "content-too-large" | "invalid-definition" | "no-workflow-files" | "provider-access-denied" | "provider-file-not-found" | "provider-malformed-response" | "provider-rate-limited" | "provider-repository-not-found" | "provider-timeout" | "provider-unavailable" | "too-many-files" | "unknown";
1195
1195
  driverParam: string;
1196
1196
  notNull: false;
1197
1197
  hasDefault: false;
@@ -1308,7 +1308,7 @@ export declare function db(): NodePgDatabase<{
1308
1308
  generated: undefined;
1309
1309
  }, {}, {}>;
1310
1310
  };
1311
- dialect: "pg";
1311
+ dialect: 'pg';
1312
1312
  }>;
1313
1313
  }>;
1314
1314
  export declare function closeDb(): void;
@@ -228,7 +228,7 @@ export declare const workflowDefinitions: import("drizzle-orm/pg-core").PgTableW
228
228
  generated: undefined;
229
229
  }, {}, {}>;
230
230
  };
231
- dialect: "pg";
231
+ dialect: 'pg';
232
232
  }>;
233
233
  export type DefinitionDb = typeof workflowDefinitions.$inferSelect;
234
234
  export type DefinitionCreateDb = typeof workflowDefinitions.$inferInsert;
@@ -190,6 +190,6 @@ export declare const definitionsOutbox: import("drizzle-orm/pg-core").PgTableWit
190
190
  generated: undefined;
191
191
  }, {}, {}>;
192
192
  };
193
- dialect: "pg";
193
+ dialect: 'pg';
194
194
  }>;
195
195
  //# sourceMappingURL=outbox.d.ts.map
@@ -95,7 +95,7 @@ export declare const definitionSyncStates: import("drizzle-orm/pg-core").PgTable
95
95
  tableName: "sync_states";
96
96
  dataType: "string";
97
97
  columnType: "PgEnumColumn";
98
- data: "pending" | "syncing" | "succeeded" | "failed";
98
+ data: "failed" | "pending" | "succeeded" | "syncing";
99
99
  driverParam: string;
100
100
  notNull: true;
101
101
  hasDefault: true;
@@ -112,7 +112,7 @@ export declare const definitionSyncStates: import("drizzle-orm/pg-core").PgTable
112
112
  tableName: "sync_states";
113
113
  dataType: "string";
114
114
  columnType: "PgEnumColumn";
115
- data: "unknown" | "provider-unavailable" | "no-workflow-files" | "invalid-definition" | "provider-repository-not-found" | "provider-file-not-found" | "provider-access-denied" | "provider-rate-limited" | "provider-timeout" | "provider-malformed-response" | "content-too-large" | "too-many-files" | "connection-unavailable";
115
+ data: "connection-unavailable" | "content-too-large" | "invalid-definition" | "no-workflow-files" | "provider-access-denied" | "provider-file-not-found" | "provider-malformed-response" | "provider-rate-limited" | "provider-repository-not-found" | "provider-timeout" | "provider-unavailable" | "too-many-files" | "unknown";
116
116
  driverParam: string;
117
117
  notNull: false;
118
118
  hasDefault: false;
@@ -229,7 +229,7 @@ export declare const definitionSyncStates: import("drizzle-orm/pg-core").PgTable
229
229
  generated: undefined;
230
230
  }, {}, {}>;
231
231
  };
232
- dialect: "pg";
232
+ dialect: 'pg';
233
233
  }>;
234
234
  export type DefinitionSyncStateDb = typeof definitionSyncStates.$inferSelect;
235
235
  export type DefinitionSyncStateCreateDb = typeof definitionSyncStates.$inferInsert;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAMhF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAM7F,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAC,KAAK,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AAa3E,YAAY,EACV,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,aAAa,EACb,wBAAwB,EACxB,sBAAsB,EACtB,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,EAAE,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AAOtF,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,YAAY,EAAE,wBAAwB,CAAC;CACxC;AAED,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,KAAK,EACL,YAAY,GACb,EAAE,8BAA8B,GAAG,aAAa,CA+BhD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAUhF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAM7F,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAC,KAAK,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AAc3E,YAAY,EACV,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,aAAa,EACb,wBAAwB,EACxB,sBAAsB,EACtB,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,EAAE,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AAStF,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,YAAY,EAAE,wBAAwB,CAAC;CACxC;AAED,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,KAAK,EACL,YAAY,GACb,EAAE,8BAA8B,GAAG,aAAa,CAmChD"}
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { dirname, resolve } from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import { DEFINITION_RESOLVED, definitionsEventSchemas } from '@shipfox/api-definitions-dto';
4
+ import { INTEGRATION_CONNECTION_AVAILABLE } from '@shipfox/api-integration-core-dto';
4
5
  import { PROJECT_SOURCE_BOUND, PROJECT_SOURCE_COMMIT_OBSERVED } from '@shipfox/api-projects-dto';
5
6
  import { subscriberFactory } from '@shipfox/node-module';
6
7
  import { logger } from '@shipfox/node-opentelemetry';
@@ -8,7 +9,7 @@ import { createDefinitionsSourceControl } from '#core/integrations.js';
8
9
  import { db, definitionsOutbox, migrationsPath } from '#db/index.js';
9
10
  import { createDefinitionRoutes } from '#presentation/index.js';
10
11
  import { createDefinitionsInterModulePresentation } from '#presentation/inter-module.js';
11
- import { onProjectSourceBound, onProjectSourceCommitObserved } from '#presentation/subscribers/index.js';
12
+ import { createOnIntegrationConnectionAvailable, onProjectSourceBound, onProjectSourceCommitObserved } from '#presentation/subscribers/index.js';
12
13
  import { createDefinitionSyncActivities, DEFINITIONS_TASK_QUEUE } from '#temporal/index.js';
13
14
  import { definitionWorkflowPath } from './config.js';
14
15
  export { DEFAULT_JOB_CHECKOUT, DEFAULT_JOB_SUCCESS, DEFAULT_RUN_TIMEOUT_MS, normalizeWorkflowDocument } from '#core/index.js';
@@ -45,6 +46,7 @@ export function createDefinitionsModule({ projects, agent, integrations }) {
45
46
  }, 'Definition resolved');
46
47
  return Promise.resolve();
47
48
  }),
49
+ subscriber(INTEGRATION_CONNECTION_AVAILABLE, createOnIntegrationConnectionAvailable(projects)),
48
50
  subscriber(PROJECT_SOURCE_BOUND, onProjectSourceBound),
49
51
  subscriber(PROJECT_SOURCE_COMMIT_OBSERVED, onProjectSourceCommitObserved)
50
52
  ],
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {\n DEFINITION_RESOLVED,\n type DefinitionsEventMap,\n definitionsEventSchemas,\n} from '@shipfox/api-definitions-dto';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport {\n PROJECT_SOURCE_BOUND,\n PROJECT_SOURCE_COMMIT_OBSERVED,\n type ProjectsEventMap,\n} from '@shipfox/api-projects-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {type ShipfoxModule, subscriberFactory} from '@shipfox/node-module';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {createDefinitionsSourceControl} from '#core/integrations.js';\nimport {db, definitionsOutbox, migrationsPath} from '#db/index.js';\nimport {createDefinitionRoutes} from '#presentation/index.js';\nimport {createDefinitionsInterModulePresentation} from '#presentation/inter-module.js';\nimport {\n onProjectSourceBound,\n onProjectSourceCommitObserved,\n} from '#presentation/subscribers/index.js';\nimport {createDefinitionSyncActivities, DEFINITIONS_TASK_QUEUE} from '#temporal/index.js';\nimport {definitionWorkflowPath} from './config.js';\n\nexport type {\n WorkflowDefinition,\n WorkflowDefinitionPayload,\n WorkflowEnvTemplates,\n WorkflowModel,\n WorkflowModelJobCheckout,\n WorkflowSourceSnapshot,\n WorkflowSpec,\n} from '#core/index.js';\nexport {\n DEFAULT_JOB_CHECKOUT,\n DEFAULT_JOB_SUCCESS,\n DEFAULT_RUN_TIMEOUT_MS,\n normalizeWorkflowDocument,\n} from '#core/index.js';\nexport {db, definitionsOutbox, getDefinitionById, migrationsPath} from '#db/index.js';\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');\nconst workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');\n\nconst subscriber = subscriberFactory<DefinitionsEventMap & ProjectsEventMap>();\n\nexport interface CreateDefinitionsModuleOptions {\n projects: ProjectsModuleClient;\n agent: AgentInterModuleClient;\n integrations: IntegrationsModuleClient;\n}\n\nexport function createDefinitionsModule({\n projects,\n agent,\n integrations,\n}: CreateDefinitionsModuleOptions): ShipfoxModule {\n const sourceControl = createDefinitionsSourceControl(integrations);\n\n return {\n name: 'definitions',\n database: {db, migrationsPath, databaseNamespace: 'definitions'},\n routes: createDefinitionRoutes({projects, agent, integrations}),\n publishers: [\n {name: 'definitions', table: definitionsOutbox, db, eventSchemas: definitionsEventSchemas},\n ],\n subscribers: [\n subscriber(DEFINITION_RESOLVED, (_payload, event) => {\n logger().info({event}, 'Definition resolved');\n return Promise.resolve();\n }),\n subscriber(PROJECT_SOURCE_BOUND, onProjectSourceBound),\n subscriber(PROJECT_SOURCE_COMMIT_OBSERVED, onProjectSourceCommitObserved),\n ],\n workers: [\n {\n taskQueue: DEFINITIONS_TASK_QUEUE,\n workflowsPath,\n activities: () =>\n createDefinitionSyncActivities(sourceControl, agent, integrations, {\n workflowPath: definitionWorkflowPath,\n }),\n workflows: [],\n },\n ],\n interModulePresentations: [createDefinitionsInterModulePresentation()],\n };\n}\n"],"names":["dirname","resolve","fileURLToPath","DEFINITION_RESOLVED","definitionsEventSchemas","PROJECT_SOURCE_BOUND","PROJECT_SOURCE_COMMIT_OBSERVED","subscriberFactory","logger","createDefinitionsSourceControl","db","definitionsOutbox","migrationsPath","createDefinitionRoutes","createDefinitionsInterModulePresentation","onProjectSourceBound","onProjectSourceCommitObserved","createDefinitionSyncActivities","DEFINITIONS_TASK_QUEUE","definitionWorkflowPath","DEFAULT_JOB_CHECKOUT","DEFAULT_JOB_SUCCESS","DEFAULT_RUN_TIMEOUT_MS","normalizeWorkflowDocument","getDefinitionById","packageRoot","url","workflowsPath","subscriber","createDefinitionsModule","projects","agent","integrations","sourceControl","name","database","databaseNamespace","routes","publishers","table","eventSchemas","subscribers","_payload","event","info","Promise","workers","taskQueue","activities","workflowPath","workflows","interModulePresentations"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAY;AAC3C,SAAQC,aAAa,QAAO,WAAW;AAEvC,SACEC,mBAAmB,EAEnBC,uBAAuB,QAClB,+BAA+B;AAEtC,S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;QACD8B,SAAS;YACP;gBACEC,WAAW7B;gBACXS;gBACAqB,YAAY,IACV/B,+BAA+BgB,eAAeF,OAAOC,cAAc;wBACjEiB,cAAc9B;oBAChB;gBACF+B,WAAW,EAAE;YACf;SACD;QACDC,0BAA0B;YAACrC;SAA2C;IACxE;AACF"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {\n DEFINITION_RESOLVED,\n type DefinitionsEventMap,\n definitionsEventSchemas,\n} from '@shipfox/api-definitions-dto';\nimport {\n INTEGRATION_CONNECTION_AVAILABLE,\n type IntegrationsEventMap,\n} from '@shipfox/api-integration-core-dto';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport {\n PROJECT_SOURCE_BOUND,\n PROJECT_SOURCE_COMMIT_OBSERVED,\n type ProjectsEventMap,\n} from '@shipfox/api-projects-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {type ShipfoxModule, subscriberFactory} from '@shipfox/node-module';\nimport {logger} from '@shipfox/node-opentelemetry';\nimport {createDefinitionsSourceControl} from '#core/integrations.js';\nimport {db, definitionsOutbox, migrationsPath} from '#db/index.js';\nimport {createDefinitionRoutes} from '#presentation/index.js';\nimport {createDefinitionsInterModulePresentation} from '#presentation/inter-module.js';\nimport {\n createOnIntegrationConnectionAvailable,\n onProjectSourceBound,\n onProjectSourceCommitObserved,\n} from '#presentation/subscribers/index.js';\nimport {createDefinitionSyncActivities, DEFINITIONS_TASK_QUEUE} from '#temporal/index.js';\nimport {definitionWorkflowPath} from './config.js';\n\nexport type {\n WorkflowDefinition,\n WorkflowDefinitionPayload,\n WorkflowEnvTemplates,\n WorkflowModel,\n WorkflowModelJobCheckout,\n WorkflowSourceSnapshot,\n WorkflowSpec,\n} from '#core/index.js';\nexport {\n DEFAULT_JOB_CHECKOUT,\n DEFAULT_JOB_SUCCESS,\n DEFAULT_RUN_TIMEOUT_MS,\n normalizeWorkflowDocument,\n} from '#core/index.js';\nexport {db, definitionsOutbox, getDefinitionById, migrationsPath} from '#db/index.js';\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');\nconst workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');\n\nconst subscriber = subscriberFactory<\n DefinitionsEventMap & IntegrationsEventMap & ProjectsEventMap\n>();\n\nexport interface CreateDefinitionsModuleOptions {\n projects: ProjectsModuleClient;\n agent: AgentInterModuleClient;\n integrations: IntegrationsModuleClient;\n}\n\nexport function createDefinitionsModule({\n projects,\n agent,\n integrations,\n}: CreateDefinitionsModuleOptions): ShipfoxModule {\n const sourceControl = createDefinitionsSourceControl(integrations);\n\n return {\n name: 'definitions',\n database: {db, migrationsPath, databaseNamespace: 'definitions'},\n routes: createDefinitionRoutes({projects, agent, integrations}),\n publishers: [\n {name: 'definitions', table: definitionsOutbox, db, eventSchemas: definitionsEventSchemas},\n ],\n subscribers: [\n subscriber(DEFINITION_RESOLVED, (_payload, event) => {\n logger().info({event}, 'Definition resolved');\n return Promise.resolve();\n }),\n subscriber(\n INTEGRATION_CONNECTION_AVAILABLE,\n createOnIntegrationConnectionAvailable(projects),\n ),\n subscriber(PROJECT_SOURCE_BOUND, onProjectSourceBound),\n subscriber(PROJECT_SOURCE_COMMIT_OBSERVED, onProjectSourceCommitObserved),\n ],\n workers: [\n {\n taskQueue: DEFINITIONS_TASK_QUEUE,\n workflowsPath,\n activities: () =>\n createDefinitionSyncActivities(sourceControl, agent, integrations, {\n workflowPath: definitionWorkflowPath,\n }),\n workflows: [],\n },\n ],\n interModulePresentations: [createDefinitionsInterModulePresentation()],\n };\n}\n"],"names":["dirname","resolve","fileURLToPath","DEFINITION_RESOLVED","definitionsEventSchemas","INTEGRATION_CONNECTION_AVAILABLE","PROJECT_SOURCE_BOUND","PROJECT_SOURCE_COMMIT_OBSERVED","subscriberFactory","logger","createDefinitionsSourceControl","db","definitionsOutbox","migrationsPath","createDefinitionRoutes","createDefinitionsInterModulePresentation","createOnIntegrationConnectionAvailable","onProjectSourceBound","onProjectSourceCommitObserved","createDefinitionSyncActivities","DEFINITIONS_TASK_QUEUE","definitionWorkflowPath","DEFAULT_JOB_CHECKOUT","DEFAULT_JOB_SUCCESS","DEFAULT_RUN_TIMEOUT_MS","normalizeWorkflowDocument","getDefinitionById","packageRoot","url","workflowsPath","subscriber","createDefinitionsModule","projects","agent","integrations","sourceControl","name","database","databaseNamespace","routes","publishers","table","eventSchemas","subscribers","_payload","event","info","Promise","workers","taskQueue","activities","workflowPath","workflows","interModulePresentations"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAY;AAC3C,SAAQC,aAAa,QAAO,WAAW;AAEvC,SACEC,mBAAmB,EAEnBC,uBAAuB,QAClB,+BAA+B;AACtC,SACEC,gCAAgC,QAE3B,oCAAoC;AAE3C,SACEC,oBAAoB,EACpBC,8BAA8B,QAEzB,4BAA4B;AAEnC,SAA4BC,iBAAiB,QAAO,uBAAuB;AAC3E,SAAQC,MAAM,QAAO,8BAA8B;AACnD,SAAQC,8BAA8B,QAAO,wBAAwB;AACrE,SAAQC,EAAE,EAAEC,iBAAiB,EAAEC,cAAc,QAAO,eAAe;AACnE,SAAQC,sBAAsB,QAAO,yBAAyB;AAC9D,SAAQC,wCAAwC,QAAO,gCAAgC;AACvF,SACEC,sCAAsC,EACtCC,oBAAoB,EACpBC,6BAA6B,QACxB,qCAAqC;AAC5C,SAAQC,8BAA8B,EAAEC,sBAAsB,QAAO,qBAAqB;AAC1F,SAAQC,sBAAsB,QAAO,cAAc;AAWnD,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,sBAAsB,EACtBC,yBAAyB,QACpB,iBAAiB;AACxB,SAAQd,EAAE,EAAEC,iBAAiB,EAAEc,iBAAiB,EAAEb,cAAc,QAAO,eAAe;AAEtF,MAAMc,cAAc1B,QAAQD,QAAQE,cAAc,YAAY0B,GAAG,IAAI;AACrE,MAAMC,gBAAgB5B,QAAQ0B,aAAa;AAE3C,MAAMG,aAAatB;AAUnB,OAAO,SAASuB,wBAAwB,EACtCC,QAAQ,EACRC,KAAK,EACLC,YAAY,EACmB;IAC/B,MAAMC,gBAAgBzB,+BAA+BwB;IAErD,OAAO;QACLE,MAAM;QACNC,UAAU;YAAC1B;YAAIE;YAAgByB,mBAAmB;QAAa;QAC/DC,QAAQzB,uBAAuB;YAACkB;YAAUC;YAAOC;QAAY;QAC7DM,YAAY;YACV;gBAACJ,MAAM;gBAAeK,OAAO7B;gBAAmBD;gBAAI+B,cAActC;YAAuB;SAC1F;QACDuC,aAAa;YACXb,WAAW3B,qBAAqB,CAACyC,UAAUC;gBACzCpC,SAASqC,IAAI,CAAC;oBAACD;gBAAK,GAAG;gBACvB,OAAOE,QAAQ9C,OAAO;YACxB;YACA6B,WACEzB,kCACAW,uCAAuCgB;YAEzCF,WAAWxB,sBAAsBW;YACjCa,WAAWvB,gCAAgCW;SAC5C;QACD8B,SAAS;YACP;gBACEC,WAAW7B;gBACXS;gBACAqB,YAAY,IACV/B,+BAA+BgB,eAAeF,OAAOC,cAAc;wBACjEiB,cAAc9B;oBAChB;gBACF+B,WAAW,EAAE;YACf;SACD;QACDC,0BAA0B;YAACtC;SAA2C;IACxE;AACF"}
@@ -5,7 +5,7 @@ export declare function requireProjectAccess(request: FastifyRequest, projectId:
5
5
  workspaceId: string;
6
6
  sourceConnectionId: string;
7
7
  sourceExternalRepositoryId: string;
8
- name: string;
9
8
  sourceRepositoryOwner?: string | null | undefined;
9
+ name: string;
10
10
  }>;
11
11
  //# sourceMappingURL=project-access.d.ts.map
@@ -1,3 +1,4 @@
1
+ export { createOnIntegrationConnectionAvailable } from './on-integration-connection-available.js';
1
2
  export { onProjectSourceBound } from './on-project-source-bound.js';
2
3
  export { onProjectSourceCommitObserved } from './on-project-source-commit-observed.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAC,6BAA6B,EAAC,MAAM,wCAAwC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sCAAsC,EAAC,MAAM,0CAA0C,CAAC;AAChG,OAAO,EAAC,oBAAoB,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAC,6BAA6B,EAAC,MAAM,wCAAwC,CAAC"}
@@ -1,3 +1,4 @@
1
+ export { createOnIntegrationConnectionAvailable } from './on-integration-connection-available.js';
1
2
  export { onProjectSourceBound } from './on-project-source-bound.js';
2
3
  export { onProjectSourceCommitObserved } from './on-project-source-commit-observed.js';
3
4
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/presentation/subscribers/index.ts"],"sourcesContent":["export {onProjectSourceBound} from './on-project-source-bound.js';\nexport {onProjectSourceCommitObserved} from './on-project-source-commit-observed.js';\n"],"names":["onProjectSourceBound","onProjectSourceCommitObserved"],"mappings":"AAAA,SAAQA,oBAAoB,QAAO,+BAA+B;AAClE,SAAQC,6BAA6B,QAAO,yCAAyC"}
1
+ {"version":3,"sources":["../../../src/presentation/subscribers/index.ts"],"sourcesContent":["export {createOnIntegrationConnectionAvailable} from './on-integration-connection-available.js';\nexport {onProjectSourceBound} from './on-project-source-bound.js';\nexport {onProjectSourceCommitObserved} from './on-project-source-commit-observed.js';\n"],"names":["createOnIntegrationConnectionAvailable","onProjectSourceBound","onProjectSourceCommitObserved"],"mappings":"AAAA,SAAQA,sCAAsC,QAAO,2CAA2C;AAChG,SAAQC,oBAAoB,QAAO,+BAA+B;AAClE,SAAQC,6BAA6B,QAAO,yCAAyC"}
@@ -0,0 +1,5 @@
1
+ import type { IntegrationConnectionAvailableEvent } from '@shipfox/api-integration-core-dto';
2
+ import type { ProjectsModuleClient } from '@shipfox/api-projects-dto/inter-module';
3
+ import type { DomainEvent } from '@shipfox/node-outbox';
4
+ export declare function createOnIntegrationConnectionAvailable(projects: Pick<ProjectsModuleClient, 'listProjectsByWorkspace'>): (payload: IntegrationConnectionAvailableEvent, event: DomainEvent<IntegrationConnectionAvailableEvent>) => Promise<void>;
5
+ //# sourceMappingURL=on-integration-connection-available.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"on-integration-connection-available.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/on-integration-connection-available.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,mCAAmC,EAAC,MAAM,mCAAmC,CAAC;AAC3F,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAEjF,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAMtD,wBAAgB,sCAAsC,CACpD,QAAQ,EAAE,IAAI,CAAC,oBAAoB,EAAE,yBAAyB,CAAC,aAGpD,mCAAmC,SACrC,WAAW,CAAC,mCAAmC,CAAC,KACtD,OAAO,CAAC,IAAI,CAAC,CA4BjB"}
@@ -0,0 +1,32 @@
1
+ import { boundedMap } from '@shipfox/node-module';
2
+ import { startDefinitionSync } from './start-definition-sync.js';
3
+ const PROJECT_PAGE_SIZE = 100;
4
+ const SYNC_START_CONCURRENCY = 10;
5
+ export function createOnIntegrationConnectionAvailable(projects) {
6
+ return async function onIntegrationConnectionAvailable(payload, event) {
7
+ let cursor;
8
+ do {
9
+ const page = await projects.listProjectsByWorkspace({
10
+ workspaceId: payload.workspaceId,
11
+ limit: PROJECT_PAGE_SIZE,
12
+ ...cursor ? {
13
+ cursor
14
+ } : {}
15
+ });
16
+ await boundedMap(page.projects, SYNC_START_CONCURRENCY, async (project)=>{
17
+ await startDefinitionSync({
18
+ projectId: project.id,
19
+ workspaceId: project.workspaceId,
20
+ sourceConnectionId: project.sourceConnectionId,
21
+ externalRepositoryId: project.sourceExternalRepositoryId,
22
+ requestId: `integration:${event.id}`
23
+ });
24
+ }, {
25
+ stopOnError: true
26
+ });
27
+ cursor = page.nextCursor ?? undefined;
28
+ }while (cursor)
29
+ };
30
+ }
31
+
32
+ //# sourceMappingURL=on-integration-connection-available.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/presentation/subscribers/on-integration-connection-available.ts"],"sourcesContent":["import type {IntegrationConnectionAvailableEvent} from '@shipfox/api-integration-core-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {boundedMap} from '@shipfox/node-module';\nimport type {DomainEvent} from '@shipfox/node-outbox';\nimport {startDefinitionSync} from './start-definition-sync.js';\n\nconst PROJECT_PAGE_SIZE = 100;\nconst SYNC_START_CONCURRENCY = 10;\n\nexport function createOnIntegrationConnectionAvailable(\n projects: Pick<ProjectsModuleClient, 'listProjectsByWorkspace'>,\n) {\n return async function onIntegrationConnectionAvailable(\n payload: IntegrationConnectionAvailableEvent,\n event: DomainEvent<IntegrationConnectionAvailableEvent>,\n ): Promise<void> {\n let cursor: {createdAt: string; id: string} | undefined;\n\n do {\n const page = await projects.listProjectsByWorkspace({\n workspaceId: payload.workspaceId,\n limit: PROJECT_PAGE_SIZE,\n ...(cursor ? {cursor} : {}),\n });\n\n await boundedMap(\n page.projects,\n SYNC_START_CONCURRENCY,\n async (project) => {\n await startDefinitionSync({\n projectId: project.id,\n workspaceId: project.workspaceId,\n sourceConnectionId: project.sourceConnectionId,\n externalRepositoryId: project.sourceExternalRepositoryId,\n requestId: `integration:${event.id}`,\n });\n },\n {stopOnError: true},\n );\n\n cursor = page.nextCursor ?? undefined;\n } while (cursor);\n };\n}\n"],"names":["boundedMap","startDefinitionSync","PROJECT_PAGE_SIZE","SYNC_START_CONCURRENCY","createOnIntegrationConnectionAvailable","projects","onIntegrationConnectionAvailable","payload","event","cursor","page","listProjectsByWorkspace","workspaceId","limit","project","projectId","id","sourceConnectionId","externalRepositoryId","sourceExternalRepositoryId","requestId","stopOnError","nextCursor","undefined"],"mappings":"AAEA,SAAQA,UAAU,QAAO,uBAAuB;AAEhD,SAAQC,mBAAmB,QAAO,6BAA6B;AAE/D,MAAMC,oBAAoB;AAC1B,MAAMC,yBAAyB;AAE/B,OAAO,SAASC,uCACdC,QAA+D;IAE/D,OAAO,eAAeC,iCACpBC,OAA4C,EAC5CC,KAAuD;QAEvD,IAAIC;QAEJ,GAAG;YACD,MAAMC,OAAO,MAAML,SAASM,uBAAuB,CAAC;gBAClDC,aAAaL,QAAQK,WAAW;gBAChCC,OAAOX;gBACP,GAAIO,SAAS;oBAACA;gBAAM,IAAI,CAAC,CAAC;YAC5B;YAEA,MAAMT,WACJU,KAAKL,QAAQ,EACbF,wBACA,OAAOW;gBACL,MAAMb,oBAAoB;oBACxBc,WAAWD,QAAQE,EAAE;oBACrBJ,aAAaE,QAAQF,WAAW;oBAChCK,oBAAoBH,QAAQG,kBAAkB;oBAC9CC,sBAAsBJ,QAAQK,0BAA0B;oBACxDC,WAAW,CAAC,YAAY,EAAEZ,MAAMQ,EAAE,EAAE;gBACtC;YACF,GACA;gBAACK,aAAa;YAAI;YAGpBZ,SAASC,KAAKY,UAAU,IAAIC;QAC9B,QAASd,OAAQ;IACnB;AACF"}
@@ -5,6 +5,7 @@ export interface StartDefinitionSyncParams {
5
5
  externalRepositoryId: string;
6
6
  sourceRef?: string | undefined;
7
7
  sourceCommitSha?: string | undefined;
8
+ requestId?: string | undefined;
8
9
  }
9
10
  export declare function startDefinitionSync(params: StartDefinitionSyncParams): Promise<void>;
10
11
  //# sourceMappingURL=start-definition-sync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"start-definition-sync.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/start-definition-sync.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmB1F"}
1
+ {"version":3,"file":"start-definition-sync.d.ts","sourceRoot":"","sources":["../../../src/presentation/subscribers/start-definition-sync.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B1F"}
@@ -2,25 +2,38 @@ import { temporalClient } from '@shipfox/node-temporal';
2
2
  import { DEFINITION_SYNC_WORKFLOW, DEFINITIONS_TASK_QUEUE } from '#temporal/index.js';
3
3
  export async function startDefinitionSync(params) {
4
4
  const workflowId = buildWorkflowId(params);
5
- await temporalClient().workflow.start(DEFINITION_SYNC_WORKFLOW, {
6
- taskQueue: DEFINITIONS_TASK_QUEUE,
7
- workflowId,
8
- workflowIdConflictPolicy: 'USE_EXISTING',
9
- workflowIdReusePolicy: 'ALLOW_DUPLICATE',
10
- args: [
11
- {
12
- projectId: params.projectId,
13
- workspaceId: params.workspaceId,
14
- sourceConnectionId: params.sourceConnectionId,
15
- sourceExternalRepositoryId: params.externalRepositoryId,
16
- sourceRef: params.sourceRef,
17
- sourceCommitSha: params.sourceCommitSha
18
- }
19
- ]
20
- });
5
+ try {
6
+ await temporalClient().workflow.start(DEFINITION_SYNC_WORKFLOW, {
7
+ taskQueue: DEFINITIONS_TASK_QUEUE,
8
+ workflowId,
9
+ workflowIdConflictPolicy: 'USE_EXISTING',
10
+ workflowIdReusePolicy: params.requestId ? 'REJECT_DUPLICATE' : 'ALLOW_DUPLICATE',
11
+ args: [
12
+ {
13
+ projectId: params.projectId,
14
+ workspaceId: params.workspaceId,
15
+ sourceConnectionId: params.sourceConnectionId,
16
+ sourceExternalRepositoryId: params.externalRepositoryId,
17
+ sourceRef: params.sourceRef,
18
+ sourceCommitSha: params.sourceCommitSha
19
+ }
20
+ ]
21
+ });
22
+ } catch (error) {
23
+ if (params.requestId && error instanceof Error && error.name === 'WorkflowExecutionAlreadyStartedError') {
24
+ return;
25
+ }
26
+ throw error;
27
+ }
21
28
  }
22
29
  function buildWorkflowId(params) {
23
- return params.sourceCommitSha ? `definition-sync:${params.projectId}:${params.sourceCommitSha}` : `definition-sync:${params.projectId}:bind`;
30
+ if (params.sourceCommitSha) {
31
+ return `definition-sync:${params.projectId}:${params.sourceCommitSha}`;
32
+ }
33
+ if (params.requestId) {
34
+ return `definition-sync:${params.projectId}:${params.requestId}`;
35
+ }
36
+ return `definition-sync:${params.projectId}:bind`;
24
37
  }
25
38
 
26
39
  //# sourceMappingURL=start-definition-sync.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/presentation/subscribers/start-definition-sync.ts"],"sourcesContent":["import {temporalClient} from '@shipfox/node-temporal';\nimport {DEFINITION_SYNC_WORKFLOW, DEFINITIONS_TASK_QUEUE} from '#temporal/index.js';\n\nexport interface StartDefinitionSyncParams {\n projectId: string;\n workspaceId: string;\n sourceConnectionId: string;\n externalRepositoryId: string;\n sourceRef?: string | undefined;\n sourceCommitSha?: string | undefined;\n}\n\nexport async function startDefinitionSync(params: StartDefinitionSyncParams): Promise<void> {\n const workflowId = buildWorkflowId(params);\n\n await temporalClient().workflow.start(DEFINITION_SYNC_WORKFLOW, {\n taskQueue: DEFINITIONS_TASK_QUEUE,\n workflowId,\n workflowIdConflictPolicy: 'USE_EXISTING',\n workflowIdReusePolicy: 'ALLOW_DUPLICATE',\n args: [\n {\n projectId: params.projectId,\n workspaceId: params.workspaceId,\n sourceConnectionId: params.sourceConnectionId,\n sourceExternalRepositoryId: params.externalRepositoryId,\n sourceRef: params.sourceRef,\n sourceCommitSha: params.sourceCommitSha,\n },\n ],\n });\n}\n\nfunction buildWorkflowId(params: StartDefinitionSyncParams): string {\n return params.sourceCommitSha\n ? `definition-sync:${params.projectId}:${params.sourceCommitSha}`\n : `definition-sync:${params.projectId}:bind`;\n}\n"],"names":["temporalClient","DEFINITION_SYNC_WORKFLOW","DEFINITIONS_TASK_QUEUE","startDefinitionSync","params","workflowId","buildWorkflowId","workflow","start","taskQueue","workflowIdConflictPolicy","workflowIdReusePolicy","args","projectId","workspaceId","sourceConnectionId","sourceExternalRepositoryId","externalRepositoryId","sourceRef","sourceCommitSha"],"mappings":"AAAA,SAAQA,cAAc,QAAO,yBAAyB;AACtD,SAAQC,wBAAwB,EAAEC,sBAAsB,QAAO,qBAAqB;AAWpF,OAAO,eAAeC,oBAAoBC,MAAiC;IACzE,MAAMC,aAAaC,gBAAgBF;IAEnC,MAAMJ,iBAAiBO,QAAQ,CAACC,KAAK,CAACP,0BAA0B;QAC9DQ,WAAWP;QACXG;QACAK,0BAA0B;QAC1BC,uBAAuB;QACvBC,MAAM;YACJ;gBACEC,WAAWT,OAAOS,SAAS;gBAC3BC,aAAaV,OAAOU,WAAW;gBAC/BC,oBAAoBX,OAAOW,kBAAkB;gBAC7CC,4BAA4BZ,OAAOa,oBAAoB;gBACvDC,WAAWd,OAAOc,SAAS;gBAC3BC,iBAAiBf,OAAOe,eAAe;YACzC;SACD;IACH;AACF;AAEA,SAASb,gBAAgBF,MAAiC;IACxD,OAAOA,OAAOe,eAAe,GACzB,CAAC,gBAAgB,EAAEf,OAAOS,SAAS,CAAC,CAAC,EAAET,OAAOe,eAAe,EAAE,GAC/D,CAAC,gBAAgB,EAAEf,OAAOS,SAAS,CAAC,KAAK,CAAC;AAChD"}
1
+ {"version":3,"sources":["../../../src/presentation/subscribers/start-definition-sync.ts"],"sourcesContent":["import {temporalClient} from '@shipfox/node-temporal';\nimport {DEFINITION_SYNC_WORKFLOW, DEFINITIONS_TASK_QUEUE} from '#temporal/index.js';\n\nexport interface StartDefinitionSyncParams {\n projectId: string;\n workspaceId: string;\n sourceConnectionId: string;\n externalRepositoryId: string;\n sourceRef?: string | undefined;\n sourceCommitSha?: string | undefined;\n requestId?: string | undefined;\n}\n\nexport async function startDefinitionSync(params: StartDefinitionSyncParams): Promise<void> {\n const workflowId = buildWorkflowId(params);\n\n try {\n await temporalClient().workflow.start(DEFINITION_SYNC_WORKFLOW, {\n taskQueue: DEFINITIONS_TASK_QUEUE,\n workflowId,\n workflowIdConflictPolicy: 'USE_EXISTING',\n workflowIdReusePolicy: params.requestId ? 'REJECT_DUPLICATE' : 'ALLOW_DUPLICATE',\n args: [\n {\n projectId: params.projectId,\n workspaceId: params.workspaceId,\n sourceConnectionId: params.sourceConnectionId,\n sourceExternalRepositoryId: params.externalRepositoryId,\n sourceRef: params.sourceRef,\n sourceCommitSha: params.sourceCommitSha,\n },\n ],\n });\n } catch (error) {\n if (\n params.requestId &&\n error instanceof Error &&\n error.name === 'WorkflowExecutionAlreadyStartedError'\n ) {\n return;\n }\n throw error;\n }\n}\n\nfunction buildWorkflowId(params: StartDefinitionSyncParams): string {\n if (params.sourceCommitSha) {\n return `definition-sync:${params.projectId}:${params.sourceCommitSha}`;\n }\n if (params.requestId) {\n return `definition-sync:${params.projectId}:${params.requestId}`;\n }\n return `definition-sync:${params.projectId}:bind`;\n}\n"],"names":["temporalClient","DEFINITION_SYNC_WORKFLOW","DEFINITIONS_TASK_QUEUE","startDefinitionSync","params","workflowId","buildWorkflowId","workflow","start","taskQueue","workflowIdConflictPolicy","workflowIdReusePolicy","requestId","args","projectId","workspaceId","sourceConnectionId","sourceExternalRepositoryId","externalRepositoryId","sourceRef","sourceCommitSha","error","Error","name"],"mappings":"AAAA,SAAQA,cAAc,QAAO,yBAAyB;AACtD,SAAQC,wBAAwB,EAAEC,sBAAsB,QAAO,qBAAqB;AAYpF,OAAO,eAAeC,oBAAoBC,MAAiC;IACzE,MAAMC,aAAaC,gBAAgBF;IAEnC,IAAI;QACF,MAAMJ,iBAAiBO,QAAQ,CAACC,KAAK,CAACP,0BAA0B;YAC9DQ,WAAWP;YACXG;YACAK,0BAA0B;YAC1BC,uBAAuBP,OAAOQ,SAAS,GAAG,qBAAqB;YAC/DC,MAAM;gBACJ;oBACEC,WAAWV,OAAOU,SAAS;oBAC3BC,aAAaX,OAAOW,WAAW;oBAC/BC,oBAAoBZ,OAAOY,kBAAkB;oBAC7CC,4BAA4Bb,OAAOc,oBAAoB;oBACvDC,WAAWf,OAAOe,SAAS;oBAC3BC,iBAAiBhB,OAAOgB,eAAe;gBACzC;aACD;QACH;IACF,EAAE,OAAOC,OAAO;QACd,IACEjB,OAAOQ,SAAS,IAChBS,iBAAiBC,SACjBD,MAAME,IAAI,KAAK,wCACf;YACA;QACF;QACA,MAAMF;IACR;AACF;AAEA,SAASf,gBAAgBF,MAAiC;IACxD,IAAIA,OAAOgB,eAAe,EAAE;QAC1B,OAAO,CAAC,gBAAgB,EAAEhB,OAAOU,SAAS,CAAC,CAAC,EAAEV,OAAOgB,eAAe,EAAE;IACxE;IACA,IAAIhB,OAAOQ,SAAS,EAAE;QACpB,OAAO,CAAC,gBAAgB,EAAER,OAAOU,SAAS,CAAC,CAAC,EAAEV,OAAOQ,SAAS,EAAE;IAClE;IACA,OAAO,CAAC,gBAAgB,EAAER,OAAOU,SAAS,CAAC,KAAK,CAAC;AACnD"}
@@ -1 +1 @@
1
- {"version":3,"file":"sync-activities.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/sync-activities.ts"],"names":[],"mappings":"A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