@shipfox/api-definitions 11.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.
- package/.turbo/turbo-build.log +13 -12
- package/CHANGELOG.md +106 -0
- package/dist/core/entities/index.d.ts +1 -0
- package/dist/core/entities/index.d.ts.map +1 -1
- package/dist/core/entities/index.js +1 -0
- package/dist/core/entities/index.js.map +1 -1
- package/dist/core/entities/sync-state.d.ts +5 -1
- package/dist/core/entities/sync-state.d.ts.map +1 -1
- package/dist/core/entities/sync-state.js +10 -0
- package/dist/core/entities/sync-state.js.map +1 -1
- package/dist/core/entities/validation-warning.d.ts +6 -0
- package/dist/core/entities/validation-warning.d.ts.map +1 -0
- package/dist/core/entities/validation-warning.js +3 -0
- package/dist/core/entities/validation-warning.js.map +1 -0
- package/dist/core/errors.d.ts +2 -2
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/integrations.d.ts +1 -1
- package/dist/core/parse-definition.d.ts +9 -7
- package/dist/core/parse-definition.d.ts.map +1 -1
- package/dist/core/parse-definition.js +14 -2
- package/dist/core/parse-definition.js.map +1 -1
- package/dist/core/sync-definitions.d.ts +2 -0
- package/dist/core/sync-definitions.d.ts.map +1 -1
- package/dist/core/sync-definitions.js +6 -5
- package/dist/core/sync-definitions.js.map +1 -1
- package/dist/core/validate-definition.d.ts +9 -5
- package/dist/core/validate-definition.d.ts.map +1 -1
- package/dist/core/validate-definition.js +23 -2
- package/dist/core/validate-definition.js.map +1 -1
- package/dist/core/workflow-model/index.d.ts +1 -1
- package/dist/core/workflow-model/index.d.ts.map +1 -1
- package/dist/core/workflow-model/index.js.map +1 -1
- package/dist/core/workflow-model/invalid-workflow-model-error.d.ts +3 -1
- package/dist/core/workflow-model/invalid-workflow-model-error.d.ts.map +1 -1
- package/dist/core/workflow-model/invalid-workflow-model-error.js.map +1 -1
- package/dist/core/workflow-model/normalize-if-condition.d.ts +0 -1
- package/dist/core/workflow-model/normalize-if-condition.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-if-condition.js +0 -1
- package/dist/core/workflow-model/normalize-if-condition.js.map +1 -1
- package/dist/core/workflow-model/normalize-job-checkout.d.ts +15 -3
- package/dist/core/workflow-model/normalize-job-checkout.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-job-checkout.js +83 -4
- package/dist/core/workflow-model/normalize-job-checkout.js.map +1 -1
- package/dist/core/workflow-model/normalize-job-listening.js +0 -1
- package/dist/core/workflow-model/normalize-job-listening.js.map +1 -1
- package/dist/core/workflow-model/normalize-job-success.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-job-success.js +0 -1
- package/dist/core/workflow-model/normalize-job-success.js.map +1 -1
- package/dist/core/workflow-model/normalize-jobs.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-jobs.js +315 -74
- package/dist/core/workflow-model/normalize-jobs.js.map +1 -1
- package/dist/core/workflow-model/normalize-step-gate.js +0 -1
- package/dist/core/workflow-model/normalize-step-gate.js.map +1 -1
- package/dist/core/workflow-model/normalize-triggers.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-triggers.js +0 -1
- package/dist/core/workflow-model/normalize-triggers.js.map +1 -1
- package/dist/core/workflow-model/normalize-workflow-document.d.ts +3 -0
- package/dist/core/workflow-model/normalize-workflow-document.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-workflow-document.js +34 -4
- package/dist/core/workflow-model/normalize-workflow-document.js.map +1 -1
- package/dist/core/workflow-model/parse-interpolation-field.d.ts +1 -1
- package/dist/core/workflow-model/parse-interpolation-field.d.ts.map +1 -1
- package/dist/core/workflow-model/parse-interpolation-field.js +27 -57
- package/dist/core/workflow-model/parse-interpolation-field.js.map +1 -1
- package/dist/core/workflow-model/validate-literal-name.d.ts +12 -0
- package/dist/core/workflow-model/validate-literal-name.d.ts.map +1 -0
- package/dist/core/workflow-model/validate-literal-name.js +36 -0
- package/dist/core/workflow-model/validate-literal-name.js.map +1 -0
- package/dist/core/workflow-model/validate-predicate-expression.d.ts +1 -2
- package/dist/core/workflow-model/validate-predicate-expression.d.ts.map +1 -1
- package/dist/core/workflow-model/validate-predicate-expression.js +31 -90
- package/dist/core/workflow-model/validate-predicate-expression.js.map +1 -1
- package/dist/core/workflow-model/validation-issue.d.ts +2 -1
- package/dist/core/workflow-model/validation-issue.d.ts.map +1 -1
- package/dist/core/workflow-model/validation-issue.js +8 -2
- package/dist/core/workflow-model/validation-issue.js.map +1 -1
- package/dist/core/workflow-model/workflow-field-label.d.ts.map +1 -1
- package/dist/core/workflow-model/workflow-field-label.js +16 -2
- package/dist/core/workflow-model/workflow-field-label.js.map +1 -1
- package/dist/core/workflow-yaml/invalid-workflow-yaml-error.d.ts.map +1 -1
- package/dist/db/db.d.ts +48 -10
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/schema/definitions.d.ts +1 -1
- package/dist/db/schema/outbox.d.ts +1 -1
- package/dist/db/schema/sync-states.d.ts +22 -3
- package/dist/db/schema/sync-states.d.ts.map +1 -1
- package/dist/db/schema/sync-states.js +3 -1
- package/dist/db/schema/sync-states.js.map +1 -1
- package/dist/db/sync-states.d.ts +2 -1
- package/dist/db/sync-states.d.ts.map +1 -1
- package/dist/db/sync-states.js +4 -0
- package/dist/db/sync-states.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/presentation/dto/definition.d.ts.map +1 -1
- package/dist/presentation/dto/definition.js +2 -1
- package/dist/presentation/dto/definition.js.map +1 -1
- package/dist/presentation/routes/project-access.d.ts +1 -0
- package/dist/presentation/routes/project-access.d.ts.map +1 -1
- package/dist/presentation/routes/validate-definition.d.ts.map +1 -1
- package/dist/presentation/routes/validate-definition.js +5 -3
- package/dist/presentation/routes/validate-definition.js.map +1 -1
- package/dist/presentation/subscribers/index.d.ts +1 -0
- package/dist/presentation/subscribers/index.d.ts.map +1 -1
- package/dist/presentation/subscribers/index.js +1 -0
- package/dist/presentation/subscribers/index.js.map +1 -1
- package/dist/presentation/subscribers/on-integration-connection-available.d.ts +5 -0
- package/dist/presentation/subscribers/on-integration-connection-available.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-integration-connection-available.js +32 -0
- package/dist/presentation/subscribers/on-integration-connection-available.js.map +1 -0
- package/dist/presentation/subscribers/start-definition-sync.d.ts +1 -0
- package/dist/presentation/subscribers/start-definition-sync.d.ts.map +1 -1
- package/dist/presentation/subscribers/start-definition-sync.js +30 -17
- package/dist/presentation/subscribers/start-definition-sync.js.map +1 -1
- package/dist/temporal/activities/sync-activities.d.ts +6 -2
- package/dist/temporal/activities/sync-activities.d.ts.map +1 -1
- package/dist/temporal/activities/sync-activities.js +8 -1
- package/dist/temporal/activities/sync-activities.js.map +1 -1
- package/dist/temporal/workflows/definition-sync.js +4 -1
- package/dist/temporal/workflows/definition-sync.js.map +1 -1
- package/dist/temporal/workflows/index.bundle.js +9029 -3
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/drizzle/0002_lumpy_ben_parker.sql +1 -0
- package/drizzle/meta/0002_snapshot.json +534 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +17 -17
- package/src/core/entities/index.ts +1 -0
- package/src/core/entities/sync-state.ts +23 -0
- package/src/core/entities/validation-warning.ts +5 -0
- package/src/core/parse-definition-warnings.test.ts +33 -0
- package/src/core/parse-definition.test.ts +7 -1
- package/src/core/parse-definition.ts +28 -10
- package/src/core/sync-definitions.test.ts +39 -0
- package/src/core/sync-definitions.ts +14 -4
- package/src/core/validate-definition.test.ts +128 -0
- package/src/core/validate-definition.ts +39 -8
- package/src/core/workflow-model/README.md +2 -2
- package/src/core/workflow-model/index.ts +1 -0
- package/src/core/workflow-model/invalid-workflow-model-error.ts +8 -3
- package/src/core/workflow-model/normalize-if-condition.ts +0 -2
- package/src/core/workflow-model/normalize-job-checkout.ts +105 -8
- package/src/core/workflow-model/normalize-job-listening.ts +0 -1
- package/src/core/workflow-model/normalize-job-success.ts +0 -1
- package/src/core/workflow-model/normalize-jobs.ts +335 -90
- package/src/core/workflow-model/normalize-step-gate.ts +0 -1
- package/src/core/workflow-model/normalize-triggers.ts +0 -1
- package/src/core/workflow-model/normalize-workflow-document.test.ts +876 -202
- package/src/core/workflow-model/normalize-workflow-document.ts +29 -4
- package/src/core/workflow-model/parse-interpolation-field.ts +50 -79
- package/src/core/workflow-model/validate-literal-name.ts +64 -0
- package/src/core/workflow-model/validate-predicate-expression.test.ts +153 -15
- package/src/core/workflow-model/validate-predicate-expression.ts +52 -120
- package/src/core/workflow-model/validation-issue.ts +4 -0
- package/src/core/workflow-model/workflow-field-label.ts +16 -2
- package/src/core/workflow-yaml/README.md +2 -2
- package/src/db/schema/sync-states.ts +4 -1
- package/src/db/sync-states.test.ts +57 -0
- package/src/db/sync-states.ts +6 -0
- package/src/index.ts +12 -1
- package/src/presentation/dto/definition.ts +1 -0
- package/src/presentation/routes/list-definitions.test.ts +1 -0
- package/src/presentation/routes/validate-definition.test.ts +1 -0
- package/src/presentation/routes/validate-definition.ts +7 -1
- package/src/presentation/subscribers/index.ts +1 -0
- package/src/presentation/subscribers/on-integration-connection-available.test.ts +132 -0
- package/src/presentation/subscribers/on-integration-connection-available.ts +44 -0
- package/src/presentation/subscribers/start-definition-sync.ts +35 -19
- package/src/temporal/activities/sync-activities.test.ts +16 -0
- package/src/temporal/activities/sync-activities.ts +18 -3
- package/src/temporal/workflows/definition-sync.ts +1 -1
- package/test/agent-validation-catalog.ts +17 -0
- package/test/fixtures/valid-listening-job.yml +2 -1
- package/tsconfig.build.tsbuildinfo +1 -1
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
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/dto/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,wBAAwB,EAAC,MAAM,8BAA8B,CAAC;AAC1F,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AAG9E,wBAAgB,eAAe,CAAC,UAAU,EAAE,kBAAkB,GAAG,aAAa,CAmB7E;AAED,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,mBAAmB,GAAG,SAAS,GACzC,wBAAwB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/dto/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,wBAAwB,EAAC,MAAM,8BAA8B,CAAC;AAC1F,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AAG9E,wBAAgB,eAAe,CAAC,UAAU,EAAE,kBAAkB,GAAG,aAAa,CAmB7E;AAED,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,mBAAmB,GAAG,SAAS,GACzC,wBAAwB,GAAG,IAAI,CAajC"}
|
|
@@ -28,7 +28,8 @@ export function toDefinitionSyncSummaryDto(syncState) {
|
|
|
28
28
|
started_at: syncState.startedAt?.toISOString() ?? null,
|
|
29
29
|
finished_at: syncState.finishedAt?.toISOString() ?? null,
|
|
30
30
|
last_error_code: syncState.lastErrorCode,
|
|
31
|
-
last_error_message: syncState.lastErrorMessage
|
|
31
|
+
last_error_message: syncState.lastErrorMessage,
|
|
32
|
+
warnings: syncState.warnings
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/dto/definition.ts"],"sourcesContent":["import type {DefinitionDto, DefinitionSyncSummaryDto} from '@shipfox/api-definitions-dto';\nimport type {DefinitionSyncState} from '#core/entities/sync-state.js';\nimport type {WorkflowDefinition} from '#core/entities/workflow-definition.js';\nimport {UNRESOLVED_SYNC_REF} from '#core/sync-definitions.js';\n\nexport function toDefinitionDto(definition: WorkflowDefinition): DefinitionDto {\n const manualEntry = Object.entries(definition.document.triggers ?? {}).find(\n ([, trigger]) => trigger.source === 'manual',\n );\n return {\n id: definition.id,\n project_id: definition.projectId,\n config_path: definition.configPath,\n source: definition.source,\n sha: definition.sha,\n ref: definition.ref,\n name: definition.name,\n workflow_document: definition.document,\n workflow_model: definition.model,\n manual_trigger: manualEntry ? {name: manualEntry[0]} : null,\n fetched_at: definition.fetchedAt.toISOString(),\n created_at: definition.createdAt.toISOString(),\n updated_at: definition.updatedAt.toISOString(),\n };\n}\n\nexport function toDefinitionSyncSummaryDto(\n syncState: DefinitionSyncState | undefined,\n): DefinitionSyncSummaryDto | null {\n if (!syncState) return null;\n\n return {\n ref: syncState.ref === UNRESOLVED_SYNC_REF ? null : syncState.ref,\n status: syncState.status,\n last_sync_at: (syncState.finishedAt ?? syncState.updatedAt).toISOString(),\n started_at: syncState.startedAt?.toISOString() ?? null,\n finished_at: syncState.finishedAt?.toISOString() ?? null,\n last_error_code: syncState.lastErrorCode,\n last_error_message: syncState.lastErrorMessage,\n };\n}\n"],"names":["UNRESOLVED_SYNC_REF","toDefinitionDto","definition","manualEntry","Object","entries","document","triggers","find","trigger","source","id","project_id","projectId","config_path","configPath","sha","ref","name","workflow_document","workflow_model","model","manual_trigger","fetched_at","fetchedAt","toISOString","created_at","createdAt","updated_at","updatedAt","toDefinitionSyncSummaryDto","syncState","status","last_sync_at","finishedAt","started_at","startedAt","finished_at","last_error_code","lastErrorCode","last_error_message","lastErrorMessage"],"mappings":"AAGA,SAAQA,mBAAmB,QAAO,4BAA4B;AAE9D,OAAO,SAASC,gBAAgBC,UAA8B;IAC5D,MAAMC,cAAcC,OAAOC,OAAO,CAACH,WAAWI,QAAQ,CAACC,QAAQ,IAAI,CAAC,GAAGC,IAAI,CACzE,CAAC,GAAGC,QAAQ,GAAKA,QAAQC,MAAM,KAAK;IAEtC,OAAO;QACLC,IAAIT,WAAWS,EAAE;QACjBC,YAAYV,WAAWW,SAAS;QAChCC,aAAaZ,WAAWa,UAAU;QAClCL,QAAQR,WAAWQ,MAAM;QACzBM,KAAKd,WAAWc,GAAG;QACnBC,KAAKf,WAAWe,GAAG;QACnBC,MAAMhB,WAAWgB,IAAI;QACrBC,mBAAmBjB,WAAWI,QAAQ;QACtCc,gBAAgBlB,WAAWmB,KAAK;QAChCC,gBAAgBnB,cAAc;YAACe,MAAMf,WAAW,CAAC,EAAE;QAAA,IAAI;QACvDoB,YAAYrB,WAAWsB,SAAS,CAACC,WAAW;QAC5CC,YAAYxB,WAAWyB,SAAS,CAACF,WAAW;QAC5CG,YAAY1B,WAAW2B,SAAS,CAACJ,WAAW;IAC9C;AACF;AAEA,OAAO,SAASK,2BACdC,SAA0C;IAE1C,IAAI,CAACA,WAAW,OAAO;IAEvB,OAAO;QACLd,KAAKc,UAAUd,GAAG,KAAKjB,sBAAsB,OAAO+B,UAAUd,GAAG;QACjEe,QAAQD,UAAUC,MAAM;QACxBC,cAAc,AAACF,CAAAA,UAAUG,UAAU,IAAIH,UAAUF,SAAS,AAAD,EAAGJ,WAAW;QACvEU,YAAYJ,UAAUK,SAAS,EAAEX,iBAAiB;QAClDY,aAAaN,UAAUG,UAAU,EAAET,iBAAiB;QACpDa,iBAAiBP,UAAUQ,aAAa;QACxCC,oBAAoBT,UAAUU,gBAAgB;
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/dto/definition.ts"],"sourcesContent":["import type {DefinitionDto, DefinitionSyncSummaryDto} from '@shipfox/api-definitions-dto';\nimport type {DefinitionSyncState} from '#core/entities/sync-state.js';\nimport type {WorkflowDefinition} from '#core/entities/workflow-definition.js';\nimport {UNRESOLVED_SYNC_REF} from '#core/sync-definitions.js';\n\nexport function toDefinitionDto(definition: WorkflowDefinition): DefinitionDto {\n const manualEntry = Object.entries(definition.document.triggers ?? {}).find(\n ([, trigger]) => trigger.source === 'manual',\n );\n return {\n id: definition.id,\n project_id: definition.projectId,\n config_path: definition.configPath,\n source: definition.source,\n sha: definition.sha,\n ref: definition.ref,\n name: definition.name,\n workflow_document: definition.document,\n workflow_model: definition.model,\n manual_trigger: manualEntry ? {name: manualEntry[0]} : null,\n fetched_at: definition.fetchedAt.toISOString(),\n created_at: definition.createdAt.toISOString(),\n updated_at: definition.updatedAt.toISOString(),\n };\n}\n\nexport function toDefinitionSyncSummaryDto(\n syncState: DefinitionSyncState | undefined,\n): DefinitionSyncSummaryDto | null {\n if (!syncState) return null;\n\n return {\n ref: syncState.ref === UNRESOLVED_SYNC_REF ? null : syncState.ref,\n status: syncState.status,\n last_sync_at: (syncState.finishedAt ?? syncState.updatedAt).toISOString(),\n started_at: syncState.startedAt?.toISOString() ?? null,\n finished_at: syncState.finishedAt?.toISOString() ?? null,\n last_error_code: syncState.lastErrorCode,\n last_error_message: syncState.lastErrorMessage,\n warnings: syncState.warnings,\n };\n}\n"],"names":["UNRESOLVED_SYNC_REF","toDefinitionDto","definition","manualEntry","Object","entries","document","triggers","find","trigger","source","id","project_id","projectId","config_path","configPath","sha","ref","name","workflow_document","workflow_model","model","manual_trigger","fetched_at","fetchedAt","toISOString","created_at","createdAt","updated_at","updatedAt","toDefinitionSyncSummaryDto","syncState","status","last_sync_at","finishedAt","started_at","startedAt","finished_at","last_error_code","lastErrorCode","last_error_message","lastErrorMessage","warnings"],"mappings":"AAGA,SAAQA,mBAAmB,QAAO,4BAA4B;AAE9D,OAAO,SAASC,gBAAgBC,UAA8B;IAC5D,MAAMC,cAAcC,OAAOC,OAAO,CAACH,WAAWI,QAAQ,CAACC,QAAQ,IAAI,CAAC,GAAGC,IAAI,CACzE,CAAC,GAAGC,QAAQ,GAAKA,QAAQC,MAAM,KAAK;IAEtC,OAAO;QACLC,IAAIT,WAAWS,EAAE;QACjBC,YAAYV,WAAWW,SAAS;QAChCC,aAAaZ,WAAWa,UAAU;QAClCL,QAAQR,WAAWQ,MAAM;QACzBM,KAAKd,WAAWc,GAAG;QACnBC,KAAKf,WAAWe,GAAG;QACnBC,MAAMhB,WAAWgB,IAAI;QACrBC,mBAAmBjB,WAAWI,QAAQ;QACtCc,gBAAgBlB,WAAWmB,KAAK;QAChCC,gBAAgBnB,cAAc;YAACe,MAAMf,WAAW,CAAC,EAAE;QAAA,IAAI;QACvDoB,YAAYrB,WAAWsB,SAAS,CAACC,WAAW;QAC5CC,YAAYxB,WAAWyB,SAAS,CAACF,WAAW;QAC5CG,YAAY1B,WAAW2B,SAAS,CAACJ,WAAW;IAC9C;AACF;AAEA,OAAO,SAASK,2BACdC,SAA0C;IAE1C,IAAI,CAACA,WAAW,OAAO;IAEvB,OAAO;QACLd,KAAKc,UAAUd,GAAG,KAAKjB,sBAAsB,OAAO+B,UAAUd,GAAG;QACjEe,QAAQD,UAAUC,MAAM;QACxBC,cAAc,AAACF,CAAAA,UAAUG,UAAU,IAAIH,UAAUF,SAAS,AAAD,EAAGJ,WAAW;QACvEU,YAAYJ,UAAUK,SAAS,EAAEX,iBAAiB;QAClDY,aAAaN,UAAUG,UAAU,EAAET,iBAAiB;QACpDa,iBAAiBP,UAAUQ,aAAa;QACxCC,oBAAoBT,UAAUU,gBAAgB;QAC9CC,UAAUX,UAAUW,QAAQ;IAC9B;AACF"}
|
|
@@ -5,6 +5,7 @@ export declare function requireProjectAccess(request: FastifyRequest, projectId:
|
|
|
5
5
|
workspaceId: string;
|
|
6
6
|
sourceConnectionId: string;
|
|
7
7
|
sourceExternalRepositoryId: string;
|
|
8
|
+
sourceRepositoryOwner?: string | null | undefined;
|
|
8
9
|
name: string;
|
|
9
10
|
}>;
|
|
10
11
|
//# sourceMappingURL=project-access.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-access.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/project-access.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAEjF,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAE5C,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,oBAAoB
|
|
1
|
+
{"version":3,"file":"project-access.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/project-access.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wCAAwC,CAAC;AAEjF,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,SAAS,CAAC;AAE5C,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,oBAAoB;;;;;;;GAO/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/validate-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"validate-definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/validate-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AA2BhF,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,sBAAsB,mDA6BzE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { definitionDtoSchema, definitionValidationErrorSchema } from '@shipfox/api-definitions-dto';
|
|
1
|
+
import { definitionDtoSchema, definitionValidationErrorSchema, definitionValidationWarningSchema } from '@shipfox/api-definitions-dto';
|
|
2
2
|
import { defineRoute } from '@shipfox/node-fastify';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { validateDefinition } from '#core/validate-definition.js';
|
|
@@ -9,7 +9,8 @@ const validationResultSchema = z.union([
|
|
|
9
9
|
z.object({
|
|
10
10
|
valid: z.literal(true),
|
|
11
11
|
workflow_document: definitionDtoSchema.shape.workflow_document,
|
|
12
|
-
workflow_model: definitionDtoSchema.shape.workflow_model
|
|
12
|
+
workflow_model: definitionDtoSchema.shape.workflow_model,
|
|
13
|
+
warnings: z.array(definitionValidationWarningSchema)
|
|
13
14
|
}),
|
|
14
15
|
z.object({
|
|
15
16
|
valid: z.literal(false),
|
|
@@ -36,7 +37,8 @@ export function buildValidateDefinitionRoute(agent) {
|
|
|
36
37
|
return {
|
|
37
38
|
valid: true,
|
|
38
39
|
workflow_document: result.definition.document,
|
|
39
|
-
workflow_model: result.definition.model
|
|
40
|
+
workflow_model: result.definition.model,
|
|
41
|
+
warnings: result.warnings
|
|
40
42
|
};
|
|
41
43
|
}
|
|
42
44
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/validate-definition.ts"],"sourcesContent":["import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {definitionDtoSchema
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/validate-definition.ts"],"sourcesContent":["import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport {\n definitionDtoSchema,\n definitionValidationErrorSchema,\n definitionValidationWarningSchema,\n} from '@shipfox/api-definitions-dto';\nimport {defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {validateDefinition} from '#core/validate-definition.js';\n\nconst validateBodySchema = z.object({\n yaml: z.string().min(1).max(1_000_000),\n});\n\nconst validationResultSchema = z.union([\n z.object({\n valid: z.literal(true),\n workflow_document: definitionDtoSchema.shape.workflow_document,\n workflow_model: definitionDtoSchema.shape.workflow_model,\n warnings: z.array(definitionValidationWarningSchema),\n }),\n z.object({\n valid: z.literal(false),\n errors: z.array(definitionValidationErrorSchema),\n }),\n]);\n\nexport function buildValidateDefinitionRoute(agent: AgentInterModuleClient) {\n return defineRoute({\n method: 'POST',\n path: '/validate',\n description: 'Validate a workflow definition without persisting',\n schema: {\n body: validateBodySchema,\n response: {\n 200: validationResultSchema,\n },\n },\n handler: async (request) => {\n const {yaml} = request.body;\n const result = validateDefinition(yaml, {\n agentValidationCatalog: await agent.getValidationCatalog({}),\n });\n\n if (result.valid) {\n return {\n valid: true as const,\n workflow_document: result.definition.document,\n workflow_model: result.definition.model,\n warnings: result.warnings,\n };\n }\n\n return result;\n },\n });\n}\n"],"names":["definitionDtoSchema","definitionValidationErrorSchema","definitionValidationWarningSchema","defineRoute","z","validateDefinition","validateBodySchema","object","yaml","string","min","max","validationResultSchema","union","valid","literal","workflow_document","shape","workflow_model","warnings","array","errors","buildValidateDefinitionRoute","agent","method","path","description","schema","body","response","handler","request","result","agentValidationCatalog","getValidationCatalog","definition","document","model"],"mappings":"AACA,SACEA,mBAAmB,EACnBC,+BAA+B,EAC/BC,iCAAiC,QAC5B,+BAA+B;AACtC,SAAQC,WAAW,QAAO,wBAAwB;AAClD,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,kBAAkB,QAAO,+BAA+B;AAEhE,MAAMC,qBAAqBF,EAAEG,MAAM,CAAC;IAClCC,MAAMJ,EAAEK,MAAM,GAAGC,GAAG,CAAC,GAAGC,GAAG,CAAC;AAC9B;AAEA,MAAMC,yBAAyBR,EAAES,KAAK,CAAC;IACrCT,EAAEG,MAAM,CAAC;QACPO,OAAOV,EAAEW,OAAO,CAAC;QACjBC,mBAAmBhB,oBAAoBiB,KAAK,CAACD,iBAAiB;QAC9DE,gBAAgBlB,oBAAoBiB,KAAK,CAACC,cAAc;QACxDC,UAAUf,EAAEgB,KAAK,CAAClB;IACpB;IACAE,EAAEG,MAAM,CAAC;QACPO,OAAOV,EAAEW,OAAO,CAAC;QACjBM,QAAQjB,EAAEgB,KAAK,CAACnB;IAClB;CACD;AAED,OAAO,SAASqB,6BAA6BC,KAA6B;IACxE,OAAOpB,YAAY;QACjBqB,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,MAAMtB;YACNuB,UAAU;gBACR,KAAKjB;YACP;QACF;QACAkB,SAAS,OAAOC;YACd,MAAM,EAACvB,IAAI,EAAC,GAAGuB,QAAQH,IAAI;YAC3B,MAAMI,SAAS3B,mBAAmBG,MAAM;gBACtCyB,wBAAwB,MAAMV,MAAMW,oBAAoB,CAAC,CAAC;YAC5D;YAEA,IAAIF,OAAOlB,KAAK,EAAE;gBAChB,OAAO;oBACLA,OAAO;oBACPE,mBAAmBgB,OAAOG,UAAU,CAACC,QAAQ;oBAC7ClB,gBAAgBc,OAAOG,UAAU,CAACE,KAAK;oBACvClB,UAAUa,OAAOb,QAAQ;gBAC3B;YACF;YAEA,OAAOa;QACT;IACF;AACF"}
|
|
@@ -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 +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;
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import type { AgentInterModuleClient } from '@shipfox/api-agent-dto/inter-module';
|
|
2
2
|
import type { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto/inter-module';
|
|
3
|
-
import type { DefinitionSyncErrorCode } from '#core/entities/sync-state.js';
|
|
3
|
+
import type { DefinitionSyncErrorCode, DefinitionSyncWarning } from '#core/entities/sync-state.js';
|
|
4
4
|
import type { DefinitionsSourceControl } from '#core/integrations.js';
|
|
5
5
|
export interface SyncWorkflowInput {
|
|
6
6
|
projectId: string;
|
|
@@ -31,6 +31,10 @@ export interface DiscoverWorkflowsActivityResult {
|
|
|
31
31
|
export interface FetchAndApplyActivityResult {
|
|
32
32
|
appliedCount: number;
|
|
33
33
|
deletedCount: number;
|
|
34
|
+
warnings: DefinitionSyncWarning[];
|
|
35
|
+
}
|
|
36
|
+
export interface MarkSyncSucceededActivityInput extends SyncRefScopedInput {
|
|
37
|
+
warnings?: readonly DefinitionSyncWarning[] | undefined;
|
|
34
38
|
}
|
|
35
39
|
export interface DefinitionSyncActivityOptions {
|
|
36
40
|
workflowPath: string;
|
|
@@ -39,7 +43,7 @@ export declare function createDefinitionSyncActivities(sourceControl: Definition
|
|
|
39
43
|
prepareDefinitionSync: (input: SyncWorkflowInput) => Promise<PrepareSyncResult>;
|
|
40
44
|
discoverDefinitionWorkflows: (input: SyncRefScopedInput) => Promise<DiscoverWorkflowsActivityResult>;
|
|
41
45
|
fetchAndApplyDefinitionWorkflows: (input: FetchAndApplyActivityInput) => Promise<FetchAndApplyActivityResult>;
|
|
42
|
-
markDefinitionSyncSucceeded: (input:
|
|
46
|
+
markDefinitionSyncSucceeded: (input: MarkSyncSucceededActivityInput) => Promise<void>;
|
|
43
47
|
markDefinitionSyncFailed: (input: MarkSyncFailedActivityInput) => Promise<void>;
|
|
44
48
|
};
|
|
45
49
|
//# sourceMappingURL=sync-activities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-activities.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/sync-activities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAI7F,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"sync-activities.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/sync-activities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAI7F,OAAO,KAAK,EAAC,uBAAuB,EAAE,qBAAqB,EAAC,MAAM,8BAA8B,CAAC;AAQjG,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,uBAAuB,CAAC;AAIpE,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,MAAM,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,2BAA4B,SAAQ,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC;IACvF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,MAAM,WAAW,+BAA+B;IAC9C,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,2BAA2B;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,qBAAqB,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE,QAAQ,CAAC,EAAE,SAAS,qBAAqB,EAAE,GAAG,SAAS,CAAC;CACzD;AAED,MAAM,WAAW,6BAA6B;IAC5C,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,wBAAwB,EACvC,KAAK,EAAE,sBAAsB,EAC7B,YAAY,CAAC,EAAE,wBAAwB,GAAG,SAAS,EACnD,OAAO,CAAC,EAAE,6BAA6B,GAAG,SAAS;IAGjD,qBAAqB,UAiBd,iBAAiB,KACvB,OAAO,CAAC,iBAAiB,CAAC;IAjB3B,2BAA2B,UA4CpB,kBAAkB,KACxB,OAAO,CAAC,+BAA+B,CAAC;IAzCzC,gCAAgC,UA2DzB,0BAA0B,KAChC,OAAO,CAAC,2BAA2B,CAAC;IAvDrC,2BAA2B,UAmGpB,8BAA8B,KACpC,OAAO,CAAC,IAAI,CAAC;IAnGd,wBAAwB,UAoHjB,2BAA2B,KACjC,OAAO,CAAC,IAAI,CAAC;EAnHjB"}
|
|
@@ -28,6 +28,7 @@ function createPrepareDefinitionSyncActivity(sourceControl) {
|
|
|
28
28
|
status: 'syncing',
|
|
29
29
|
lastErrorCode: null,
|
|
30
30
|
lastErrorMessage: null,
|
|
31
|
+
warnings: [],
|
|
31
32
|
startedAt: new Date(),
|
|
32
33
|
finishedAt: null
|
|
33
34
|
});
|
|
@@ -65,7 +66,7 @@ function createFetchAndApplyActivity(sourceControl, agent, integrations) {
|
|
|
65
66
|
return await loadIntegrationValidationContext(integrations, input.workspaceId, input.sourceConnectionId);
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
|
-
|
|
69
|
+
const result = await applyVcsDefinitionsBatch({
|
|
69
70
|
projectId: input.projectId,
|
|
70
71
|
workspaceId: input.workspaceId,
|
|
71
72
|
ref: input.sourceRef,
|
|
@@ -78,6 +79,10 @@ function createFetchAndApplyActivity(sourceControl, agent, integrations) {
|
|
|
78
79
|
contentHash: entry.contentHash
|
|
79
80
|
}))
|
|
80
81
|
});
|
|
82
|
+
return {
|
|
83
|
+
...result,
|
|
84
|
+
warnings: definitions.flatMap((entry)=>entry.warnings)
|
|
85
|
+
};
|
|
81
86
|
});
|
|
82
87
|
};
|
|
83
88
|
}
|
|
@@ -91,6 +96,7 @@ function createMarkSyncSucceededActivity() {
|
|
|
91
96
|
status: 'succeeded',
|
|
92
97
|
lastErrorCode: null,
|
|
93
98
|
lastErrorMessage: null,
|
|
99
|
+
warnings: input.warnings ?? [],
|
|
94
100
|
finishedAt: new Date()
|
|
95
101
|
});
|
|
96
102
|
};
|
|
@@ -105,6 +111,7 @@ function createMarkSyncFailedActivity() {
|
|
|
105
111
|
status: 'failed',
|
|
106
112
|
lastErrorCode: input.code,
|
|
107
113
|
lastErrorMessage: input.message,
|
|
114
|
+
warnings: [],
|
|
108
115
|
finishedAt: new Date()
|
|
109
116
|
});
|
|
110
117
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/temporal/activities/sync-activities.ts"],"sourcesContent":["import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport {markErrorReported} from '@shipfox/node-error-monitoring';\nimport {Context} from '@temporalio/activity';\nimport {ApplicationFailure} from '@temporalio/common';\nimport type {DefinitionSyncErrorCode} from '#core/entities/sync-state.js';\nimport {\n classifySyncFailure,\n discoverWorkflowFiles,\n fetchAndParseWorkflows,\n resolveSyncSource,\n UNRESOLVED_SYNC_REF,\n} from '#core/index.js';\nimport type {DefinitionsSourceControl} from '#core/integrations.js';\nimport {loadIntegrationValidationContext} from '#core/integrations.js';\nimport {applyVcsDefinitionsBatch, markDefinitionSyncState} from '#db/index.js';\n\nexport interface SyncWorkflowInput {\n projectId: string;\n workspaceId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n sourceRef?: string | undefined;\n sourceCommitSha?: string | undefined;\n}\n\nexport interface SyncRefScopedInput extends SyncWorkflowInput {\n sourceRef: string;\n}\n\nexport interface FetchAndApplyActivityInput extends SyncRefScopedInput {\n paths: string[];\n}\n\nexport interface MarkSyncFailedActivityInput extends Omit<SyncWorkflowInput, 'sourceRef'> {\n sourceRef: string | null;\n code: DefinitionSyncErrorCode;\n message: string;\n}\n\nexport interface PrepareSyncResult {\n sourceRef: string;\n sourceCommitSha?: string | undefined;\n}\n\nexport interface DiscoverWorkflowsActivityResult {\n paths: string[];\n}\n\nexport interface FetchAndApplyActivityResult {\n appliedCount: number;\n deletedCount: number;\n}\n\nexport interface DefinitionSyncActivityOptions {\n workflowPath: string;\n}\n\nexport function createDefinitionSyncActivities(\n sourceControl: DefinitionsSourceControl,\n agent: AgentInterModuleClient,\n integrations?: IntegrationsModuleClient | undefined,\n options?: DefinitionSyncActivityOptions | undefined,\n) {\n return {\n prepareDefinitionSync: createPrepareDefinitionSyncActivity(sourceControl),\n discoverDefinitionWorkflows: createDiscoverDefinitionWorkflowsActivity(\n sourceControl,\n options?.workflowPath,\n ),\n fetchAndApplyDefinitionWorkflows: createFetchAndApplyActivity(\n sourceControl,\n agent,\n integrations,\n ),\n markDefinitionSyncSucceeded: createMarkSyncSucceededActivity(),\n markDefinitionSyncFailed: createMarkSyncFailedActivity(),\n };\n}\n\nfunction createPrepareDefinitionSyncActivity(sourceControl: DefinitionsSourceControl) {\n return async function prepareDefinitionSync(\n input: SyncWorkflowInput,\n ): Promise<PrepareSyncResult> {\n return await runWithPermanentTranslation(async () => {\n const sourceRef = input.sourceRef ?? (await resolveSyncSource({...input, sourceControl})).ref;\n\n await markDefinitionSyncState({\n projectId: input.projectId,\n sourceConnectionId: input.sourceConnectionId,\n sourceExternalRepositoryId: input.sourceExternalRepositoryId,\n ref: sourceRef,\n status: 'syncing',\n lastErrorCode: null,\n lastErrorMessage: null,\n startedAt: new Date(),\n finishedAt: null,\n });\n\n return {sourceRef, sourceCommitSha: input.sourceCommitSha};\n });\n };\n}\n\nfunction createDiscoverDefinitionWorkflowsActivity(\n sourceControl: DefinitionsSourceControl,\n workflowPath?: string | undefined,\n) {\n return async function discoverDefinitionWorkflows(\n input: SyncRefScopedInput,\n ): Promise<DiscoverWorkflowsActivityResult> {\n return await runWithPermanentTranslation(async () => {\n return await discoverWorkflowFiles({\n ...input,\n ref: input.sourceCommitSha ?? input.sourceRef,\n sourceControl,\n workflowPath,\n });\n });\n };\n}\n\nfunction createFetchAndApplyActivity(\n sourceControl: DefinitionsSourceControl,\n agent: AgentInterModuleClient,\n integrations?: IntegrationsModuleClient | undefined,\n) {\n return async function fetchAndApplyDefinitionWorkflows(\n input: FetchAndApplyActivityInput,\n ): Promise<FetchAndApplyActivityResult> {\n return await runWithPermanentTranslation(async () => {\n const definitions = await fetchAndParseWorkflows({\n ...input,\n ref: input.sourceCommitSha ?? input.sourceRef,\n sourceControl,\n agentValidationCatalog: await agent.getValidationCatalog({}),\n onProgress: (path) => Context.current().heartbeat({path}),\n loadIntegrationValidationContext:\n integrations === undefined\n ? undefined\n : async () => {\n return await loadIntegrationValidationContext(\n integrations,\n input.workspaceId,\n input.sourceConnectionId,\n );\n },\n });\n\n return await applyVcsDefinitionsBatch({\n projectId: input.projectId,\n workspaceId: input.workspaceId,\n ref: input.sourceRef,\n upserts: definitions.map((entry) => ({\n configPath: entry.path,\n name: entry.name,\n document: entry.definition.document,\n model: entry.definition.model,\n sourceSnapshot: entry.definition.sourceSnapshot,\n contentHash: entry.contentHash,\n })),\n });\n });\n };\n}\n\nfunction createMarkSyncSucceededActivity() {\n return async function markDefinitionSyncSucceeded(input: SyncRefScopedInput): Promise<void> {\n await markDefinitionSyncState({\n projectId: input.projectId,\n sourceConnectionId: input.sourceConnectionId,\n sourceExternalRepositoryId: input.sourceExternalRepositoryId,\n ref: input.sourceRef,\n status: 'succeeded',\n lastErrorCode: null,\n lastErrorMessage: null,\n finishedAt: new Date(),\n });\n };\n}\n\nfunction createMarkSyncFailedActivity() {\n return async function markDefinitionSyncFailed(\n input: MarkSyncFailedActivityInput,\n ): Promise<void> {\n await markDefinitionSyncState({\n projectId: input.projectId,\n sourceConnectionId: input.sourceConnectionId,\n sourceExternalRepositoryId: input.sourceExternalRepositoryId,\n ref: input.sourceRef ?? UNRESOLVED_SYNC_REF,\n status: 'failed',\n lastErrorCode: input.code,\n lastErrorMessage: input.message,\n finishedAt: new Date(),\n });\n };\n}\n\nasync function runWithPermanentTranslation<T>(operation: () => Promise<T>): Promise<T> {\n try {\n return await operation();\n } catch (error) {\n if (error instanceof ApplicationFailure) {\n throw error;\n }\n const failure = classifySyncFailure(error);\n const translatedError = failure.retryable\n ? ApplicationFailure.retryable(failure.message, failure.code)\n : ApplicationFailure.nonRetryable(failure.message, failure.code);\n if (failure.code !== 'unknown') markErrorReported(translatedError);\n throw translatedError;\n }\n}\n"],"names":["markErrorReported","Context","ApplicationFailure","classifySyncFailure","discoverWorkflowFiles","fetchAndParseWorkflows","resolveSyncSource","UNRESOLVED_SYNC_REF","loadIntegrationValidationContext","applyVcsDefinitionsBatch","markDefinitionSyncState","createDefinitionSyncActivities","sourceControl","agent","integrations","options","prepareDefinitionSync","createPrepareDefinitionSyncActivity","discoverDefinitionWorkflows","createDiscoverDefinitionWorkflowsActivity","workflowPath","fetchAndApplyDefinitionWorkflows","createFetchAndApplyActivity","markDefinitionSyncSucceeded","createMarkSyncSucceededActivity","markDefinitionSyncFailed","createMarkSyncFailedActivity","input","runWithPermanentTranslation","sourceRef","ref","projectId","sourceConnectionId","sourceExternalRepositoryId","status","lastErrorCode","lastErrorMessage","startedAt","Date","finishedAt","sourceCommitSha","definitions","agentValidationCatalog","getValidationCatalog","onProgress","path","current","heartbeat","undefined","workspaceId","upserts","map","entry","configPath","name","document","definition","model","sourceSnapshot","contentHash","code","message","operation","error","failure","translatedError","retryable","nonRetryable"],"mappings":"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"}
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/activities/sync-activities.ts"],"sourcesContent":["import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport {markErrorReported} from '@shipfox/node-error-monitoring';\nimport {Context} from '@temporalio/activity';\nimport {ApplicationFailure} from '@temporalio/common';\nimport type {DefinitionSyncErrorCode, DefinitionSyncWarning} from '#core/entities/sync-state.js';\nimport {\n classifySyncFailure,\n discoverWorkflowFiles,\n fetchAndParseWorkflows,\n resolveSyncSource,\n UNRESOLVED_SYNC_REF,\n} from '#core/index.js';\nimport type {DefinitionsSourceControl} from '#core/integrations.js';\nimport {loadIntegrationValidationContext} from '#core/integrations.js';\nimport {applyVcsDefinitionsBatch, markDefinitionSyncState} from '#db/index.js';\n\nexport interface SyncWorkflowInput {\n projectId: string;\n workspaceId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n sourceRef?: string | undefined;\n sourceCommitSha?: string | undefined;\n}\n\nexport interface SyncRefScopedInput extends SyncWorkflowInput {\n sourceRef: string;\n}\n\nexport interface FetchAndApplyActivityInput extends SyncRefScopedInput {\n paths: string[];\n}\n\nexport interface MarkSyncFailedActivityInput extends Omit<SyncWorkflowInput, 'sourceRef'> {\n sourceRef: string | null;\n code: DefinitionSyncErrorCode;\n message: string;\n}\n\nexport interface PrepareSyncResult {\n sourceRef: string;\n sourceCommitSha?: string | undefined;\n}\n\nexport interface DiscoverWorkflowsActivityResult {\n paths: string[];\n}\n\nexport interface FetchAndApplyActivityResult {\n appliedCount: number;\n deletedCount: number;\n warnings: DefinitionSyncWarning[];\n}\n\nexport interface MarkSyncSucceededActivityInput extends SyncRefScopedInput {\n warnings?: readonly DefinitionSyncWarning[] | undefined;\n}\n\nexport interface DefinitionSyncActivityOptions {\n workflowPath: string;\n}\n\nexport function createDefinitionSyncActivities(\n sourceControl: DefinitionsSourceControl,\n agent: AgentInterModuleClient,\n integrations?: IntegrationsModuleClient | undefined,\n options?: DefinitionSyncActivityOptions | undefined,\n) {\n return {\n prepareDefinitionSync: createPrepareDefinitionSyncActivity(sourceControl),\n discoverDefinitionWorkflows: createDiscoverDefinitionWorkflowsActivity(\n sourceControl,\n options?.workflowPath,\n ),\n fetchAndApplyDefinitionWorkflows: createFetchAndApplyActivity(\n sourceControl,\n agent,\n integrations,\n ),\n markDefinitionSyncSucceeded: createMarkSyncSucceededActivity(),\n markDefinitionSyncFailed: createMarkSyncFailedActivity(),\n };\n}\n\nfunction createPrepareDefinitionSyncActivity(sourceControl: DefinitionsSourceControl) {\n return async function prepareDefinitionSync(\n input: SyncWorkflowInput,\n ): Promise<PrepareSyncResult> {\n return await runWithPermanentTranslation(async () => {\n const sourceRef = input.sourceRef ?? (await resolveSyncSource({...input, sourceControl})).ref;\n\n await markDefinitionSyncState({\n projectId: input.projectId,\n sourceConnectionId: input.sourceConnectionId,\n sourceExternalRepositoryId: input.sourceExternalRepositoryId,\n ref: sourceRef,\n status: 'syncing',\n lastErrorCode: null,\n lastErrorMessage: null,\n warnings: [],\n startedAt: new Date(),\n finishedAt: null,\n });\n\n return {sourceRef, sourceCommitSha: input.sourceCommitSha};\n });\n };\n}\n\nfunction createDiscoverDefinitionWorkflowsActivity(\n sourceControl: DefinitionsSourceControl,\n workflowPath?: string | undefined,\n) {\n return async function discoverDefinitionWorkflows(\n input: SyncRefScopedInput,\n ): Promise<DiscoverWorkflowsActivityResult> {\n return await runWithPermanentTranslation(async () => {\n return await discoverWorkflowFiles({\n ...input,\n ref: input.sourceCommitSha ?? input.sourceRef,\n sourceControl,\n workflowPath,\n });\n });\n };\n}\n\nfunction createFetchAndApplyActivity(\n sourceControl: DefinitionsSourceControl,\n agent: AgentInterModuleClient,\n integrations?: IntegrationsModuleClient | undefined,\n) {\n return async function fetchAndApplyDefinitionWorkflows(\n input: FetchAndApplyActivityInput,\n ): Promise<FetchAndApplyActivityResult> {\n return await runWithPermanentTranslation(async () => {\n const definitions = await fetchAndParseWorkflows({\n ...input,\n ref: input.sourceCommitSha ?? input.sourceRef,\n sourceControl,\n agentValidationCatalog: await agent.getValidationCatalog({}),\n onProgress: (path) => Context.current().heartbeat({path}),\n loadIntegrationValidationContext:\n integrations === undefined\n ? undefined\n : async () => {\n return await loadIntegrationValidationContext(\n integrations,\n input.workspaceId,\n input.sourceConnectionId,\n );\n },\n });\n\n const result = await applyVcsDefinitionsBatch({\n projectId: input.projectId,\n workspaceId: input.workspaceId,\n ref: input.sourceRef,\n upserts: definitions.map((entry) => ({\n configPath: entry.path,\n name: entry.name,\n document: entry.definition.document,\n model: entry.definition.model,\n sourceSnapshot: entry.definition.sourceSnapshot,\n contentHash: entry.contentHash,\n })),\n });\n\n return {\n ...result,\n warnings: definitions.flatMap((entry) => entry.warnings),\n };\n });\n };\n}\n\nfunction createMarkSyncSucceededActivity() {\n return async function markDefinitionSyncSucceeded(\n input: MarkSyncSucceededActivityInput,\n ): Promise<void> {\n await markDefinitionSyncState({\n projectId: input.projectId,\n sourceConnectionId: input.sourceConnectionId,\n sourceExternalRepositoryId: input.sourceExternalRepositoryId,\n ref: input.sourceRef,\n status: 'succeeded',\n lastErrorCode: null,\n lastErrorMessage: null,\n warnings: input.warnings ?? [],\n finishedAt: new Date(),\n });\n };\n}\n\nfunction createMarkSyncFailedActivity() {\n return async function markDefinitionSyncFailed(\n input: MarkSyncFailedActivityInput,\n ): Promise<void> {\n await markDefinitionSyncState({\n projectId: input.projectId,\n sourceConnectionId: input.sourceConnectionId,\n sourceExternalRepositoryId: input.sourceExternalRepositoryId,\n ref: input.sourceRef ?? UNRESOLVED_SYNC_REF,\n status: 'failed',\n lastErrorCode: input.code,\n lastErrorMessage: input.message,\n warnings: [],\n finishedAt: new Date(),\n });\n };\n}\n\nasync function runWithPermanentTranslation<T>(operation: () => Promise<T>): Promise<T> {\n try {\n return await operation();\n } catch (error) {\n if (error instanceof ApplicationFailure) {\n throw error;\n }\n const failure = classifySyncFailure(error);\n const translatedError = failure.retryable\n ? ApplicationFailure.retryable(failure.message, failure.code)\n : ApplicationFailure.nonRetryable(failure.message, failure.code);\n if (failure.code !== 'unknown') markErrorReported(translatedError);\n throw translatedError;\n }\n}\n"],"names":["markErrorReported","Context","ApplicationFailure","classifySyncFailure","discoverWorkflowFiles","fetchAndParseWorkflows","resolveSyncSource","UNRESOLVED_SYNC_REF","loadIntegrationValidationContext","applyVcsDefinitionsBatch","markDefinitionSyncState","createDefinitionSyncActivities","sourceControl","agent","integrations","options","prepareDefinitionSync","createPrepareDefinitionSyncActivity","discoverDefinitionWorkflows","createDiscoverDefinitionWorkflowsActivity","workflowPath","fetchAndApplyDefinitionWorkflows","createFetchAndApplyActivity","markDefinitionSyncSucceeded","createMarkSyncSucceededActivity","markDefinitionSyncFailed","createMarkSyncFailedActivity","input","runWithPermanentTranslation","sourceRef","ref","projectId","sourceConnectionId","sourceExternalRepositoryId","status","lastErrorCode","lastErrorMessage","warnings","startedAt","Date","finishedAt","sourceCommitSha","definitions","agentValidationCatalog","getValidationCatalog","onProgress","path","current","heartbeat","undefined","workspaceId","result","upserts","map","entry","configPath","name","document","definition","model","sourceSnapshot","contentHash","flatMap","code","message","operation","error","failure","translatedError","retryable","nonRetryable"],"mappings":"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"}
|
|
@@ -36,7 +36,10 @@ export async function definitionSyncWorkflow(input) {
|
|
|
36
36
|
...source,
|
|
37
37
|
paths
|
|
38
38
|
});
|
|
39
|
-
await markDefinitionSyncSucceeded(
|
|
39
|
+
await markDefinitionSyncSucceeded({
|
|
40
|
+
...source,
|
|
41
|
+
warnings: applied.warnings
|
|
42
|
+
});
|
|
40
43
|
return {
|
|
41
44
|
sourceRef,
|
|
42
45
|
appliedCount: applied.appliedCount,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/temporal/workflows/definition-sync.ts"],"sourcesContent":["import {ActivityFailure, ApplicationFailure, proxyActivities} from '@temporalio/workflow';\nimport {\n type DefinitionSyncErrorCode,\n isDefinitionSyncErrorCode,\n} from '#core/entities/sync-state.js';\nimport type {createDefinitionSyncActivities} from '../activities/index.js';\n\nexport interface DefinitionSyncWorkflowInput {\n projectId: string;\n workspaceId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n sourceRef?: string | undefined;\n sourceCommitSha?: string | undefined;\n}\n\nexport interface DefinitionSyncWorkflowResult {\n sourceRef: string;\n appliedCount: number;\n deletedCount: number;\n}\n\nconst PROVIDER_RETRY = {\n initialInterval: '5 seconds',\n backoffCoefficient: 2,\n maximumInterval: '1 minute',\n maximumAttempts: 5,\n} as const;\n\nconst DB_RETRY = {\n initialInterval: '1 second',\n backoffCoefficient: 2,\n maximumInterval: '15 seconds',\n maximumAttempts: 5,\n} as const;\n\nconst {prepareDefinitionSync, discoverDefinitionWorkflows, fetchAndApplyDefinitionWorkflows} =\n proxyActivities<ReturnType<typeof createDefinitionSyncActivities>>({\n startToCloseTimeout: '5 minutes',\n heartbeatTimeout: '30 seconds',\n retry: PROVIDER_RETRY,\n });\n\nconst {markDefinitionSyncSucceeded, markDefinitionSyncFailed} = proxyActivities<\n ReturnType<typeof createDefinitionSyncActivities>\n>({\n startToCloseTimeout: '30 seconds',\n retry: DB_RETRY,\n});\n\nexport async function definitionSyncWorkflow(\n input: DefinitionSyncWorkflowInput,\n): Promise<DefinitionSyncWorkflowResult> {\n let sourceRef: string | null = null;\n\n try {\n const prepared = await prepareDefinitionSync(input);\n sourceRef = prepared.sourceRef;\n\n const source = {\n ...input,\n sourceRef: prepared.sourceRef,\n sourceCommitSha: prepared.sourceCommitSha,\n };\n const {paths} = await discoverDefinitionWorkflows(source);\n const applied = await fetchAndApplyDefinitionWorkflows({...source, paths});\n\n await markDefinitionSyncSucceeded(source);\n\n return {\n sourceRef,\n appliedCount: applied.appliedCount,\n deletedCount: applied.deletedCount,\n };\n } catch (error) {\n const {code, message} = classifyWorkflowError(error);\n try {\n await markDefinitionSyncFailed({...input, sourceRef, code, message});\n } catch (markFailedError) {\n const failureOptions = {\n message: `Definition sync failed with ${code}: ${message}; additionally failed to persist failure state: ${formatWorkflowError(markFailedError)}`,\n type: 'definition-sync-failure-persistence-failed',\n nonRetryable: true,\n details: [\n {\n syncFailureCode: code,\n syncFailureMessage: message,\n failurePersistenceMessage: formatWorkflowError(markFailedError),\n },\n ],\n };\n throw ApplicationFailure.create(\n error instanceof Error ? {...failureOptions, cause: error} : failureOptions,\n );\n }\n throw error;\n }\n}\n\nexport function classifyWorkflowError(error: unknown): {\n code: DefinitionSyncErrorCode;\n message: string;\n} {\n if (error instanceof ActivityFailure && error.cause instanceof ApplicationFailure) {\n return classifyWorkflowError(error.cause);\n }\n if (error instanceof ApplicationFailure) {\n const code = isDefinitionSyncErrorCode(error.type) ? error.type : 'unknown';\n return {code, message: error.message ?? code};\n }\n return {code: 'unknown', message: error instanceof Error ? error.message : String(error)};\n}\n\nfunction formatWorkflowError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],"names":["ActivityFailure","ApplicationFailure","proxyActivities","isDefinitionSyncErrorCode","PROVIDER_RETRY","initialInterval","backoffCoefficient","maximumInterval","maximumAttempts","DB_RETRY","prepareDefinitionSync","discoverDefinitionWorkflows","fetchAndApplyDefinitionWorkflows","startToCloseTimeout","heartbeatTimeout","retry","markDefinitionSyncSucceeded","markDefinitionSyncFailed","definitionSyncWorkflow","input","sourceRef","prepared","source","sourceCommitSha","paths","applied","appliedCount","deletedCount","error","code","message","classifyWorkflowError","markFailedError","failureOptions","formatWorkflowError","type","nonRetryable","details","syncFailureCode","syncFailureMessage","failurePersistenceMessage","create","Error","cause","String"],"mappings":"AAAA,SAAQA,eAAe,EAAEC,kBAAkB,EAAEC,eAAe,QAAO,uBAAuB;AAC1F,SAEEC,yBAAyB,QACpB,+BAA+B;AAkBtC,MAAMC,iBAAiB;IACrBC,iBAAiB;IACjBC,oBAAoB;IACpBC,iBAAiB;IACjBC,iBAAiB;AACnB;AAEA,MAAMC,WAAW;IACfJ,iBAAiB;IACjBC,oBAAoB;IACpBC,iBAAiB;IACjBC,iBAAiB;AACnB;AAEA,MAAM,EAACE,qBAAqB,EAAEC,2BAA2B,EAAEC,gCAAgC,EAAC,GAC1FV,gBAAmE;IACjEW,qBAAqB;IACrBC,kBAAkB;IAClBC,OAAOX;AACT;AAEF,MAAM,EAACY,2BAA2B,EAAEC,wBAAwB,EAAC,GAAGf,gBAE9D;IACAW,qBAAqB;IACrBE,OAAON;AACT;AAEA,OAAO,eAAeS,uBACpBC,KAAkC;IAElC,IAAIC,YAA2B;IAE/B,IAAI;QACF,MAAMC,WAAW,MAAMX,sBAAsBS;QAC7CC,YAAYC,SAASD,SAAS;QAE9B,MAAME,SAAS;YACb,GAAGH,KAAK;YACRC,WAAWC,SAASD,SAAS;YAC7BG,iBAAiBF,SAASE,eAAe;QAC3C;QACA,MAAM,EAACC,KAAK,EAAC,GAAG,MAAMb,4BAA4BW;QAClD,MAAMG,UAAU,MAAMb,iCAAiC;YAAC,GAAGU,MAAM;YAAEE;QAAK;QAExE,MAAMR,
|
|
1
|
+
{"version":3,"sources":["../../../src/temporal/workflows/definition-sync.ts"],"sourcesContent":["import {ActivityFailure, ApplicationFailure, proxyActivities} from '@temporalio/workflow';\nimport {\n type DefinitionSyncErrorCode,\n isDefinitionSyncErrorCode,\n} from '#core/entities/sync-state.js';\nimport type {createDefinitionSyncActivities} from '../activities/index.js';\n\nexport interface DefinitionSyncWorkflowInput {\n projectId: string;\n workspaceId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n sourceRef?: string | undefined;\n sourceCommitSha?: string | undefined;\n}\n\nexport interface DefinitionSyncWorkflowResult {\n sourceRef: string;\n appliedCount: number;\n deletedCount: number;\n}\n\nconst PROVIDER_RETRY = {\n initialInterval: '5 seconds',\n backoffCoefficient: 2,\n maximumInterval: '1 minute',\n maximumAttempts: 5,\n} as const;\n\nconst DB_RETRY = {\n initialInterval: '1 second',\n backoffCoefficient: 2,\n maximumInterval: '15 seconds',\n maximumAttempts: 5,\n} as const;\n\nconst {prepareDefinitionSync, discoverDefinitionWorkflows, fetchAndApplyDefinitionWorkflows} =\n proxyActivities<ReturnType<typeof createDefinitionSyncActivities>>({\n startToCloseTimeout: '5 minutes',\n heartbeatTimeout: '30 seconds',\n retry: PROVIDER_RETRY,\n });\n\nconst {markDefinitionSyncSucceeded, markDefinitionSyncFailed} = proxyActivities<\n ReturnType<typeof createDefinitionSyncActivities>\n>({\n startToCloseTimeout: '30 seconds',\n retry: DB_RETRY,\n});\n\nexport async function definitionSyncWorkflow(\n input: DefinitionSyncWorkflowInput,\n): Promise<DefinitionSyncWorkflowResult> {\n let sourceRef: string | null = null;\n\n try {\n const prepared = await prepareDefinitionSync(input);\n sourceRef = prepared.sourceRef;\n\n const source = {\n ...input,\n sourceRef: prepared.sourceRef,\n sourceCommitSha: prepared.sourceCommitSha,\n };\n const {paths} = await discoverDefinitionWorkflows(source);\n const applied = await fetchAndApplyDefinitionWorkflows({...source, paths});\n\n await markDefinitionSyncSucceeded({...source, warnings: applied.warnings});\n\n return {\n sourceRef,\n appliedCount: applied.appliedCount,\n deletedCount: applied.deletedCount,\n };\n } catch (error) {\n const {code, message} = classifyWorkflowError(error);\n try {\n await markDefinitionSyncFailed({...input, sourceRef, code, message});\n } catch (markFailedError) {\n const failureOptions = {\n message: `Definition sync failed with ${code}: ${message}; additionally failed to persist failure state: ${formatWorkflowError(markFailedError)}`,\n type: 'definition-sync-failure-persistence-failed',\n nonRetryable: true,\n details: [\n {\n syncFailureCode: code,\n syncFailureMessage: message,\n failurePersistenceMessage: formatWorkflowError(markFailedError),\n },\n ],\n };\n throw ApplicationFailure.create(\n error instanceof Error ? {...failureOptions, cause: error} : failureOptions,\n );\n }\n throw error;\n }\n}\n\nexport function classifyWorkflowError(error: unknown): {\n code: DefinitionSyncErrorCode;\n message: string;\n} {\n if (error instanceof ActivityFailure && error.cause instanceof ApplicationFailure) {\n return classifyWorkflowError(error.cause);\n }\n if (error instanceof ApplicationFailure) {\n const code = isDefinitionSyncErrorCode(error.type) ? error.type : 'unknown';\n return {code, message: error.message ?? code};\n }\n return {code: 'unknown', message: error instanceof Error ? error.message : String(error)};\n}\n\nfunction formatWorkflowError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],"names":["ActivityFailure","ApplicationFailure","proxyActivities","isDefinitionSyncErrorCode","PROVIDER_RETRY","initialInterval","backoffCoefficient","maximumInterval","maximumAttempts","DB_RETRY","prepareDefinitionSync","discoverDefinitionWorkflows","fetchAndApplyDefinitionWorkflows","startToCloseTimeout","heartbeatTimeout","retry","markDefinitionSyncSucceeded","markDefinitionSyncFailed","definitionSyncWorkflow","input","sourceRef","prepared","source","sourceCommitSha","paths","applied","warnings","appliedCount","deletedCount","error","code","message","classifyWorkflowError","markFailedError","failureOptions","formatWorkflowError","type","nonRetryable","details","syncFailureCode","syncFailureMessage","failurePersistenceMessage","create","Error","cause","String"],"mappings":"AAAA,SAAQA,eAAe,EAAEC,kBAAkB,EAAEC,eAAe,QAAO,uBAAuB;AAC1F,SAEEC,yBAAyB,QACpB,+BAA+B;AAkBtC,MAAMC,iBAAiB;IACrBC,iBAAiB;IACjBC,oBAAoB;IACpBC,iBAAiB;IACjBC,iBAAiB;AACnB;AAEA,MAAMC,WAAW;IACfJ,iBAAiB;IACjBC,oBAAoB;IACpBC,iBAAiB;IACjBC,iBAAiB;AACnB;AAEA,MAAM,EAACE,qBAAqB,EAAEC,2BAA2B,EAAEC,gCAAgC,EAAC,GAC1FV,gBAAmE;IACjEW,qBAAqB;IACrBC,kBAAkB;IAClBC,OAAOX;AACT;AAEF,MAAM,EAACY,2BAA2B,EAAEC,wBAAwB,EAAC,GAAGf,gBAE9D;IACAW,qBAAqB;IACrBE,OAAON;AACT;AAEA,OAAO,eAAeS,uBACpBC,KAAkC;IAElC,IAAIC,YAA2B;IAE/B,IAAI;QACF,MAAMC,WAAW,MAAMX,sBAAsBS;QAC7CC,YAAYC,SAASD,SAAS;QAE9B,MAAME,SAAS;YACb,GAAGH,KAAK;YACRC,WAAWC,SAASD,SAAS;YAC7BG,iBAAiBF,SAASE,eAAe;QAC3C;QACA,MAAM,EAACC,KAAK,EAAC,GAAG,MAAMb,4BAA4BW;QAClD,MAAMG,UAAU,MAAMb,iCAAiC;YAAC,GAAGU,MAAM;YAAEE;QAAK;QAExE,MAAMR,4BAA4B;YAAC,GAAGM,MAAM;YAAEI,UAAUD,QAAQC,QAAQ;QAAA;QAExE,OAAO;YACLN;YACAO,cAAcF,QAAQE,YAAY;YAClCC,cAAcH,QAAQG,YAAY;QACpC;IACF,EAAE,OAAOC,OAAO;QACd,MAAM,EAACC,IAAI,EAAEC,OAAO,EAAC,GAAGC,sBAAsBH;QAC9C,IAAI;YACF,MAAMZ,yBAAyB;gBAAC,GAAGE,KAAK;gBAAEC;gBAAWU;gBAAMC;YAAO;QACpE,EAAE,OAAOE,iBAAiB;YACxB,MAAMC,iBAAiB;gBACrBH,SAAS,CAAC,4BAA4B,EAAED,KAAK,EAAE,EAAEC,QAAQ,gDAAgD,EAAEI,oBAAoBF,kBAAkB;gBACjJG,MAAM;gBACNC,cAAc;gBACdC,SAAS;oBACP;wBACEC,iBAAiBT;wBACjBU,oBAAoBT;wBACpBU,2BAA2BN,oBAAoBF;oBACjD;iBACD;YACH;YACA,MAAMhC,mBAAmByC,MAAM,CAC7Bb,iBAAiBc,QAAQ;gBAAC,GAAGT,cAAc;gBAAEU,OAAOf;YAAK,IAAIK;QAEjE;QACA,MAAML;IACR;AACF;AAEA,OAAO,SAASG,sBAAsBH,KAAc;IAIlD,IAAIA,iBAAiB7B,mBAAmB6B,MAAMe,KAAK,YAAY3C,oBAAoB;QACjF,OAAO+B,sBAAsBH,MAAMe,KAAK;IAC1C;IACA,IAAIf,iBAAiB5B,oBAAoB;QACvC,MAAM6B,OAAO3B,0BAA0B0B,MAAMO,IAAI,IAAIP,MAAMO,IAAI,GAAG;QAClE,OAAO;YAACN;YAAMC,SAASF,MAAME,OAAO,IAAID;QAAI;IAC9C;IACA,OAAO;QAACA,MAAM;QAAWC,SAASF,iBAAiBc,QAAQd,MAAME,OAAO,GAAGc,OAAOhB;IAAM;AAC1F;AAEA,SAASM,oBAAoBN,KAAc;IACzC,OAAOA,iBAAiBc,QAAQd,MAAME,OAAO,GAAGc,OAAOhB;AACzD"}
|