@shipfox/api-definitions 6.0.0 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,19 @@
1
1
  $ shipfox-swc && shipfox-temporal-bundle dist/temporal/workflows/index.js
2
- Successfully compiled: 72 files with swc (669.81ms)
3
- 2026-07-21T08:11:36.825Z [INFO] asset workflow-bundle-5046e0cf40917a545f36.js 1.46 MiB [emitted] [immutable] (name: main)
4
- runtime modules 670 bytes 3 modules
5
- modules by path ../../../node_modules/.pnpm/ 424 KiB
6
- modules by path ../../../node_modules/.pnpm/@temporalio+common@1.18.1/node_modules/@temporal...(truncated) 155 KiB 34 modules
7
- modules by path ../../../node_modules/.pnpm/@temporalio+workflow@1.18.1/node_modules/@tempor...(truncated) 201 KiB 26 modules
8
- modules by path ../../../node_modules/.pnpm/nexus-rpc@0.0.2/node_modules/nexus-rpc/lib/ 22.3 KiB 13 modules
9
- + 2 modules
10
- modules by path ./dist/ 4.33 KiB
2
+ Successfully compiled: 72 files with swc (667.85ms)
3
+ 2026-07-22T13:12:41.791Z [INFO] asset workflow-bundle-2e2f2f4d6c035dc8e198.js 3.18 MiB [emitted] [immutable] (name: main)
4
+ orphan modules 33.5 KiB [orphan] 21 modules
5
+ runtime modules 1.13 KiB 5 modules
6
+ modules by path ../../../node_modules/.pnpm/ 970 KiB 196 modules
7
+ modules by path ./dist/ 4.72 KiB
11
8
  modules by path ./dist/temporal/workflows/*.js 3.28 KiB
12
9
  ./dist/temporal/workflows/index.js 64 bytes [built] [code generated]
13
10
  ./dist/temporal/workflows/definition-sync.js 3.22 KiB [built] [code generated]
14
- ./dist/temporal/workflows/index-autogenerated-entrypoint.cjs 530 bytes [built] [code generated]
11
+ ./dist/temporal/workflows/index-autogenerated-entrypoint.cjs 936 bytes [built] [code generated]
15
12
  ./dist/core/entities/sync-state.js 543 bytes [built] [code generated]
16
13
  optional modules 30 bytes [optional]
17
14
  __temporal_custom_payload_converter (ignored) 15 bytes [optional] [built] [code generated]
18
15
  __temporal_custom_failure_converter (ignored) 15 bytes [optional] [built] [code generated]
19
- webpack 5.107.2 compiled successfully in 4575 ms
20
- 2026-07-21T08:11:36.846Z [INFO] Workflow bundle created { size: '1.46MB' }
21
- /home/runner/work/shipfox/shipfox/libs/api/definitions/dist/temporal/workflows/index.js: 1528210 bytes
16
+ ../../shared/node/temporal/dist/workflow-error-interceptor.js 1.21 KiB [built] [code generated]
17
+ webpack 5.107.2 compiled successfully in 6914 ms
18
+ 2026-07-22T13:12:41.815Z [INFO] Workflow bundle created { size: '3.18MB' }
19
+ /home/runner/work/shipfox/shipfox/libs/api/definitions/dist/temporal/workflows/index.js: 3332889 bytes
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @shipfox/api-definitions
2
2
 
3
+ ## 7.1.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [ac42c96]
8
+ - Updated dependencies [6ce08c0]
9
+ - @shipfox/node-error-monitoring@0.2.0
10
+ - @shipfox/node-fastify@0.3.0
11
+ - @shipfox/node-module@0.5.0
12
+ - @shipfox/node-temporal@0.4.0
13
+ - @shipfox/node-opentelemetry@0.6.0
14
+ - @shipfox/api-auth-context@7.1.0
15
+
3
16
  ## 6.0.0
4
17
 
5
18
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"sync-activities.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/sync-activities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,mCAAmC,CAAC;AAGhF,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAQ1E,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;CACtB;AAED,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,wBAAwB,EACvC,YAAY,CAAC,EAAE,wBAAwB,GAAG,SAAS;mCAa1C,iBAAiB,KACvB,OAAO,CAAC,iBAAiB,CAAC;yCAuBpB,kBAAkB,KACxB,OAAO,CAAC,+BAA+B,CAAC;8CAgBlC,0BAA0B,KAChC,OAAO,CAAC,2BAA2B,CAAC;yCAqCkB,kBAAkB,KAAG,OAAO,CAAC,IAAI,CAAC;sCAgBlF,2BAA2B,KACjC,OAAO,CAAC,IAAI,CAAC;EApGjB"}
1
+ {"version":3,"file":"sync-activities.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/sync-activities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,mCAAmC,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AA2B,CAAC;yCAqCkB,kBAAkB,KAAG,OAAO,CAAC,IAAI,CAAC;sCAgBlF,2BAA2B,KACjC,OAAO,CAAC,IAAI,CAAC;EApGjB"}
@@ -1,3 +1,4 @@
1
+ import { markErrorReported } from '@shipfox/node-error-monitoring';
1
2
  import { Context } from '@temporalio/activity';
2
3
  import { ApplicationFailure } from '@temporalio/common';
3
4
  import { classifySyncFailure, discoverWorkflowFiles, fetchAndParseWorkflows, resolveSyncSource, UNRESOLVED_SYNC_REF } from '#core/index.js';
@@ -114,10 +115,9 @@ async function runWithPermanentTranslation(operation) {
114
115
  throw error;
115
116
  }
116
117
  const failure = classifySyncFailure(error);
117
- if (!failure.retryable) {
118
- throw ApplicationFailure.nonRetryable(failure.message, failure.code);
119
- }
120
- throw ApplicationFailure.retryable(failure.message, failure.code);
118
+ const translatedError = failure.retryable ? ApplicationFailure.retryable(failure.message, failure.code) : ApplicationFailure.nonRetryable(failure.message, failure.code);
119
+ if (failure.code !== 'unknown') markErrorReported(translatedError);
120
+ throw translatedError;
121
121
  }
122
122
  }
123
123
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/temporal/activities/sync-activities.ts"],"sourcesContent":["import type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto';\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 function createDefinitionSyncActivities(\n sourceControl: DefinitionsSourceControl,\n integrations?: IntegrationsModuleClient | undefined,\n) {\n return {\n prepareDefinitionSync: createPrepareDefinitionSyncActivity(sourceControl),\n discoverDefinitionWorkflows: createDiscoverDefinitionWorkflowsActivity(sourceControl),\n fetchAndApplyDefinitionWorkflows: createFetchAndApplyActivity(sourceControl, integrations),\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(sourceControl: DefinitionsSourceControl) {\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 });\n });\n };\n}\n\nfunction createFetchAndApplyActivity(\n sourceControl: DefinitionsSourceControl,\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 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 if (!failure.retryable) {\n throw ApplicationFailure.nonRetryable(failure.message, failure.code);\n }\n throw ApplicationFailure.retryable(failure.message, failure.code);\n }\n}\n"],"names":["Context","ApplicationFailure","classifySyncFailure","discoverWorkflowFiles","fetchAndParseWorkflows","resolveSyncSource","UNRESOLVED_SYNC_REF","loadIntegrationValidationContext","applyVcsDefinitionsBatch","markDefinitionSyncState","createDefinitionSyncActivities","sourceControl","integrations","prepareDefinitionSync","createPrepareDefinitionSyncActivity","discoverDefinitionWorkflows","createDiscoverDefinitionWorkflowsActivity","fetchAndApplyDefinitionWorkflows","createFetchAndApplyActivity","markDefinitionSyncSucceeded","createMarkSyncSucceededActivity","markDefinitionSyncFailed","createMarkSyncFailedActivity","input","runWithPermanentTranslation","sourceRef","ref","projectId","sourceConnectionId","sourceExternalRepositoryId","status","lastErrorCode","lastErrorMessage","startedAt","Date","finishedAt","sourceCommitSha","definitions","onProgress","path","current","heartbeat","undefined","workspaceId","upserts","map","entry","configPath","name","document","definition","model","sourceSnapshot","contentHash","code","message","operation","error","failure","retryable","nonRetryable"],"mappings":"AACA,SAAQA,OAAO,QAAO,uBAAuB;AAC7C,SAAQC,kBAAkB,QAAO,qBAAqB;AAEtD,SACEC,mBAAmB,EACnBC,qBAAqB,EACrBC,sBAAsB,EACtBC,iBAAiB,EACjBC,mBAAmB,QACd,iBAAiB;AAExB,SAAQC,gCAAgC,QAAO,wBAAwB;AACvE,SAAQC,wBAAwB,EAAEC,uBAAuB,QAAO,eAAe;AAuC/E,OAAO,SAASC,+BACdC,aAAuC,EACvCC,YAAmD;IAEnD,OAAO;QACLC,uBAAuBC,oCAAoCH;QAC3DI,6BAA6BC,0CAA0CL;QACvEM,kCAAkCC,4BAA4BP,eAAeC;QAC7EO,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,EAAEG,QAAQJ,IAAI;QACrE;QACA,MAAMrD,mBAAmB0D,SAAS,CAACD,QAAQH,OAAO,EAAEG,QAAQJ,IAAI;IAClE;AACF"}
1
+ {"version":3,"sources":["../../../src/temporal/activities/sync-activities.ts"],"sourcesContent":["import type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto';\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 function createDefinitionSyncActivities(\n sourceControl: DefinitionsSourceControl,\n integrations?: IntegrationsModuleClient | undefined,\n) {\n return {\n prepareDefinitionSync: createPrepareDefinitionSyncActivity(sourceControl),\n discoverDefinitionWorkflows: createDiscoverDefinitionWorkflowsActivity(sourceControl),\n fetchAndApplyDefinitionWorkflows: createFetchAndApplyActivity(sourceControl, integrations),\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(sourceControl: DefinitionsSourceControl) {\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 });\n });\n };\n}\n\nfunction createFetchAndApplyActivity(\n sourceControl: DefinitionsSourceControl,\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 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","integrations","prepareDefinitionSync","createPrepareDefinitionSyncActivity","discoverDefinitionWorkflows","createDiscoverDefinitionWorkflowsActivity","fetchAndApplyDefinitionWorkflows","createFetchAndApplyActivity","markDefinitionSyncSucceeded","createMarkSyncSucceededActivity","markDefinitionSyncFailed","createMarkSyncFailedActivity","input","runWithPermanentTranslation","sourceRef","ref","projectId","sourceConnectionId","sourceExternalRepositoryId","status","lastErrorCode","lastErrorMessage","startedAt","Date","finishedAt","sourceCommitSha","definitions","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":"AACA,SAAQA,iBAAiB,QAAO,iCAAiC;AACjE,SAAQC,OAAO,QAAO,uBAAuB;AAC7C,SAAQC,kBAAkB,QAAO,qBAAqB;AAEtD,SACEC,mBAAmB,EACnBC,qBAAqB,EACrBC,sBAAsB,EACtBC,iBAAiB,EACjBC,mBAAmB,QACd,iBAAiB;AAExB,SAAQC,gCAAgC,QAAO,wBAAwB;AACvE,SAAQC,wBAAwB,EAAEC,uBAAuB,QAAO,eAAe;AAuC/E,OAAO,SAASC,+BACdC,aAAuC,EACvCC,YAAmD;IAEnD,OAAO;QACLC,uBAAuBC,oCAAoCH;QAC3DI,6BAA6BC,0CAA0CL;QACvEM,kCAAkCC,4BAA4BP,eAAeC;QAC7EO,6BAA6BC;QAC7BC,0BAA0BC;IAC5B;AACF;AAEA,SAASR,oCAAoCH,aAAuC;IAClF,OAAO,eAAeE,sBACpBU,KAAwB;QAExB,OAAO,MAAMC,4BAA4B;YACvC,MAAMC,YAAYF,MAAME,SAAS,IAAI,AAAC,CAAA,MAAMpB,kBAAkB;gBAAC,GAAGkB,KAAK;gBAAEZ;YAAa,EAAC,EAAGe,GAAG;YAE7F,MAAMjB,wBAAwB;gBAC5BkB,WAAWJ,MAAMI,SAAS;gBAC1BC,oBAAoBL,MAAMK,kBAAkB;gBAC5CC,4BAA4BN,MAAMM,0BAA0B;gBAC5DH,KAAKD;gBACLK,QAAQ;gBACRC,eAAe;gBACfC,kBAAkB;gB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