@shipfox/api-definitions 5.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.
- package/.turbo/turbo-build.log +11 -13
- package/CHANGELOG.md +49 -0
- package/dist/core/entities/workflow-definition.d.ts +2 -5
- package/dist/core/entities/workflow-definition.d.ts.map +1 -1
- package/dist/core/entities/workflow-definition.js.map +1 -1
- package/dist/core/entities/workflow-model.d.ts +1 -137
- package/dist/core/entities/workflow-model.d.ts.map +1 -1
- package/dist/core/entities/workflow-model.js.map +1 -1
- package/dist/core/integrations.d.ts +25 -0
- package/dist/core/integrations.d.ts.map +1 -0
- package/dist/core/integrations.js +30 -0
- package/dist/core/integrations.js.map +1 -0
- package/dist/core/sync-definitions.d.ts +2 -2
- package/dist/core/sync-definitions.d.ts.map +1 -1
- package/dist/core/sync-definitions.js +23 -14
- package/dist/core/sync-definitions.js.map +1 -1
- package/dist/core/workflow-model/constants.d.ts +1 -1
- package/dist/core/workflow-model/constants.d.ts.map +1 -1
- package/dist/core/workflow-model/constants.js +1 -1
- package/dist/core/workflow-model/constants.js.map +1 -1
- package/dist/core/workflow-model/normalize-job-checkout.d.ts +2 -2
- package/dist/core/workflow-model/normalize-job-checkout.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-job-checkout.js +2 -6
- package/dist/core/workflow-model/normalize-job-checkout.js.map +1 -1
- package/dist/core/workflow-model/normalize-job-success.d.ts +2 -1
- package/dist/core/workflow-model/normalize-job-success.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-job-success.js +2 -1
- package/dist/core/workflow-model/normalize-job-success.js.map +1 -1
- package/dist/db/db.d.ts +2 -2
- package/dist/db/schema/sync-states.d.ts +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -11
- package/dist/index.js.map +1 -1
- package/dist/presentation/index.d.ts +1 -1
- package/dist/presentation/index.d.ts.map +1 -1
- package/dist/presentation/index.js +1 -1
- package/dist/presentation/index.js.map +1 -1
- package/dist/presentation/inter-module.d.ts +4 -0
- package/dist/presentation/inter-module.d.ts.map +1 -0
- package/dist/presentation/inter-module.js +25 -0
- package/dist/presentation/inter-module.js.map +1 -0
- package/dist/presentation/routes/create-definition.d.ts +5 -6
- package/dist/presentation/routes/create-definition.d.ts.map +1 -1
- package/dist/presentation/routes/create-definition.js +7 -19
- package/dist/presentation/routes/create-definition.js.map +1 -1
- package/dist/presentation/routes/get-definition.d.ts +2 -1
- package/dist/presentation/routes/get-definition.d.ts.map +1 -1
- package/dist/presentation/routes/get-definition.js +26 -35
- package/dist/presentation/routes/get-definition.js.map +1 -1
- package/dist/presentation/routes/index.d.ts +1 -2
- package/dist/presentation/routes/index.d.ts.map +1 -1
- package/dist/presentation/routes/index.js +5 -6
- package/dist/presentation/routes/index.js.map +1 -1
- package/dist/presentation/routes/list-definitions.d.ts +2 -1
- package/dist/presentation/routes/list-definitions.d.ts.map +1 -1
- package/dist/presentation/routes/list-definitions.js +36 -45
- package/dist/presentation/routes/list-definitions.js.map +1 -1
- package/dist/presentation/routes/project-access.d.ts +10 -0
- package/dist/presentation/routes/project-access.d.ts.map +1 -0
- package/dist/presentation/routes/project-access.js +17 -0
- package/dist/presentation/routes/project-access.js.map +1 -0
- package/dist/temporal/activities/sync-activities.d.ts +3 -9
- package/dist/temporal/activities/sync-activities.d.ts.map +1 -1
- package/dist/temporal/activities/sync-activities.js +10 -14
- package/dist/temporal/activities/sync-activities.js.map +1 -1
- package/dist/temporal/workflows/index.bundle.js +17195 -3337
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +16 -32
- package/src/core/entities/workflow-definition.ts +3 -6
- package/src/core/entities/workflow-model.ts +1 -162
- package/src/core/integrations.ts +39 -0
- package/src/core/sync-definitions.test.ts +19 -17
- package/src/core/sync-definitions.ts +26 -20
- package/src/core/workflow-model/constants.ts +1 -1
- package/src/core/workflow-model/normalize-job-checkout.ts +2 -5
- package/src/core/workflow-model/normalize-job-success.ts +2 -1
- package/src/db/definitions.test.ts +68 -7
- package/src/index.ts +12 -31
- package/src/presentation/index.ts +1 -1
- package/src/presentation/inter-module.ts +25 -0
- package/src/presentation/routes/create-definition.test.ts +59 -63
- package/src/presentation/routes/create-definition.ts +15 -34
- package/src/presentation/routes/get-definition.test.ts +14 -8
- package/src/presentation/routes/get-definition.ts +25 -28
- package/src/presentation/routes/index.test.ts +8 -1
- package/src/presentation/routes/index.ts +5 -7
- package/src/presentation/routes/list-definitions.test.ts +8 -7
- package/src/presentation/routes/list-definitions.ts +33 -36
- package/src/presentation/routes/project-access.ts +16 -0
- package/src/temporal/activities/sync-activities.test.ts +14 -6
- package/src/temporal/activities/sync-activities.ts +20 -33
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/list-definitions.ts"],"sourcesContent":["import {\n definitionListQuerySchema,\n definitionListResponseSchema,\n} from '@shipfox/api-definitions-dto';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/list-definitions.ts"],"sourcesContent":["import {\n definitionListQuerySchema,\n definitionListResponseSchema,\n} from '@shipfox/api-definitions-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport {decodeStringIdCursor, encodeStringIdCursor} from '@shipfox/node-drizzle';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {listDefinitions} from '#db/definitions.js';\nimport {getLatestDefinitionSyncState} from '#db/sync-states.js';\nimport {toDefinitionDto, toDefinitionSyncSummaryDto} from '#presentation/dto/index.js';\nimport {requireProjectAccess} from './project-access.js';\n\nexport function buildListDefinitionsRoute(projects: ProjectsModuleClient) {\n return defineRoute({\n method: 'GET',\n path: '/',\n description: 'List all definitions for a project',\n schema: {\n querystring: definitionListQuerySchema,\n response: {\n 200: definitionListResponseSchema,\n },\n },\n handler: async (request) => {\n const {project_id: projectId, limit, cursor} = request.query;\n const decodedCursor = decodeStringIdCursor(cursor);\n if (cursor && !decodedCursor) {\n throw new ClientError('Invalid cursor', 'invalid-cursor', {status: 400});\n }\n\n const project = await requireProjectAccess(request, projectId, projects);\n const result = await listDefinitions({projectId, limit, cursor: decodedCursor});\n const syncState = await getLatestDefinitionSyncState({\n projectId,\n sourceConnectionId: project.sourceConnectionId,\n sourceExternalRepositoryId: project.sourceExternalRepositoryId,\n });\n\n return {\n definitions: result.definitions.map(toDefinitionDto),\n sync: toDefinitionSyncSummaryDto(syncState),\n next_cursor: result.nextCursor ? encodeStringIdCursor(result.nextCursor) : null,\n };\n },\n });\n}\n"],"names":["definitionListQuerySchema","definitionListResponseSchema","decodeStringIdCursor","encodeStringIdCursor","ClientError","defineRoute","listDefinitions","getLatestDefinitionSyncState","toDefinitionDto","toDefinitionSyncSummaryDto","requireProjectAccess","buildListDefinitionsRoute","projects","method","path","description","schema","querystring","response","handler","request","project_id","projectId","limit","cursor","query","decodedCursor","status","project","result","syncState","sourceConnectionId","sourceExternalRepositoryId","definitions","map","sync","next_cursor","nextCursor"],"mappings":"AAAA,SACEA,yBAAyB,EACzBC,4BAA4B,QACvB,+BAA+B;AAEtC,SAAQC,oBAAoB,EAAEC,oBAAoB,QAAO,wBAAwB;AACjF,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,eAAe,QAAO,qBAAqB;AACnD,SAAQC,4BAA4B,QAAO,qBAAqB;AAChE,SAAQC,eAAe,EAAEC,0BAA0B,QAAO,6BAA6B;AACvF,SAAQC,oBAAoB,QAAO,sBAAsB;AAEzD,OAAO,SAASC,0BAA0BC,QAA8B;IACtE,OAAOP,YAAY;QACjBQ,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,aAAajB;YACbkB,UAAU;gBACR,KAAKjB;YACP;QACF;QACAkB,SAAS,OAAOC;YACd,MAAM,EAACC,YAAYC,SAAS,EAAEC,KAAK,EAAEC,MAAM,EAAC,GAAGJ,QAAQK,KAAK;YAC5D,MAAMC,gBAAgBxB,qBAAqBsB;YAC3C,IAAIA,UAAU,CAACE,eAAe;gBAC5B,MAAM,IAAItB,YAAY,kBAAkB,kBAAkB;oBAACuB,QAAQ;gBAAG;YACxE;YAEA,MAAMC,UAAU,MAAMlB,qBAAqBU,SAASE,WAAWV;YAC/D,MAAMiB,SAAS,MAAMvB,gBAAgB;gBAACgB;gBAAWC;gBAAOC,QAAQE;YAAa;YAC7E,MAAMI,YAAY,MAAMvB,6BAA6B;gBACnDe;gBACAS,oBAAoBH,QAAQG,kBAAkB;gBAC9CC,4BAA4BJ,QAAQI,0BAA0B;YAChE;YAEA,OAAO;gBACLC,aAAaJ,OAAOI,WAAW,CAACC,GAAG,CAAC1B;gBACpC2B,MAAM1B,2BAA2BqB;gBACjCM,aAAaP,OAAOQ,UAAU,GAAGlC,qBAAqB0B,OAAOQ,UAAU,IAAI;YAC7E;QACF;IACF;AACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
|
|
2
|
+
import type { FastifyRequest } from 'fastify';
|
|
3
|
+
export declare function requireProjectAccess(request: FastifyRequest, projectId: string, projects: ProjectsModuleClient): Promise<{
|
|
4
|
+
id: string;
|
|
5
|
+
workspaceId: string;
|
|
6
|
+
sourceConnectionId: string;
|
|
7
|
+
sourceExternalRepositoryId: string;
|
|
8
|
+
name: string;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=project-access.d.ts.map
|
|
@@ -0,0 +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,2BAA2B,CAAC;AAEpE,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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { requireWorkspaceAccess } from '@shipfox/api-auth-context';
|
|
2
|
+
import { ClientError } from '@shipfox/node-fastify';
|
|
3
|
+
export async function requireProjectAccess(request, projectId, projects) {
|
|
4
|
+
const { project } = await projects.getProjectById({
|
|
5
|
+
projectId
|
|
6
|
+
});
|
|
7
|
+
if (project === null) throw new ClientError('Project not found', 'project-not-found', {
|
|
8
|
+
status: 404
|
|
9
|
+
});
|
|
10
|
+
requireWorkspaceAccess({
|
|
11
|
+
request,
|
|
12
|
+
workspaceId: project.workspaceId
|
|
13
|
+
});
|
|
14
|
+
return project;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=project-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/project-access.ts"],"sourcesContent":["import {requireWorkspaceAccess} from '@shipfox/api-auth-context';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport {ClientError} from '@shipfox/node-fastify';\nimport type {FastifyRequest} from 'fastify';\n\nexport async function requireProjectAccess(\n request: FastifyRequest,\n projectId: string,\n projects: ProjectsModuleClient,\n) {\n const {project} = await projects.getProjectById({projectId});\n if (project === null)\n throw new ClientError('Project not found', 'project-not-found', {status: 404});\n requireWorkspaceAccess({request, workspaceId: project.workspaceId});\n return project;\n}\n"],"names":["requireWorkspaceAccess","ClientError","requireProjectAccess","request","projectId","projects","project","getProjectById","status","workspaceId"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,4BAA4B;AAEjE,SAAQC,WAAW,QAAO,wBAAwB;AAGlD,OAAO,eAAeC,qBACpBC,OAAuB,EACvBC,SAAiB,EACjBC,QAA8B;IAE9B,MAAM,EAACC,OAAO,EAAC,GAAG,MAAMD,SAASE,cAAc,CAAC;QAACH;IAAS;IAC1D,IAAIE,YAAY,MACd,MAAM,IAAIL,YAAY,qBAAqB,qBAAqB;QAACO,QAAQ;IAAG;IAC9ER,uBAAuB;QAACG;QAASM,aAAaH,QAAQG,WAAW;IAAA;IACjE,OAAOH;AACT"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto';
|
|
2
2
|
import type { DefinitionSyncErrorCode } from '#core/entities/sync-state.js';
|
|
3
|
+
import type { DefinitionsSourceControl } from '#core/integrations.js';
|
|
3
4
|
export interface SyncWorkflowInput {
|
|
4
5
|
projectId: string;
|
|
5
6
|
workspaceId: string;
|
|
@@ -30,14 +31,7 @@ export interface FetchAndApplyActivityResult {
|
|
|
30
31
|
appliedCount: number;
|
|
31
32
|
deletedCount: number;
|
|
32
33
|
}
|
|
33
|
-
export
|
|
34
|
-
agentToolSelectionCatalogs: AgentToolSelectionCatalogs;
|
|
35
|
-
loadWorkspaceConnectionSnapshot: LoadWorkspaceConnectionSnapshot;
|
|
36
|
-
getIntegrationConnectionById: (id: string) => Promise<{
|
|
37
|
-
slug: string;
|
|
38
|
-
} | undefined>;
|
|
39
|
-
}
|
|
40
|
-
export declare function createDefinitionSyncActivities(sourceControl: IntegrationSourceControlService, integrationValidation?: DefinitionSyncIntegrationValidationOptions | undefined): {
|
|
34
|
+
export declare function createDefinitionSyncActivities(sourceControl: DefinitionsSourceControl, integrations?: IntegrationsModuleClient | undefined): {
|
|
41
35
|
prepareDefinitionSync: (input: SyncWorkflowInput) => Promise<PrepareSyncResult>;
|
|
42
36
|
discoverDefinitionWorkflows: (input: SyncRefScopedInput) => Promise<DiscoverWorkflowsActivityResult>;
|
|
43
37
|
fetchAndApplyDefinitionWorkflows: (input: FetchAndApplyActivityInput) => Promise<FetchAndApplyActivityResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-activities.d.ts","sourceRoot":"","sources":["../../../src/temporal/activities/sync-activities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
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S;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,12 +1,14 @@
|
|
|
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';
|
|
5
|
+
import { loadIntegrationValidationContext } from '#core/integrations.js';
|
|
4
6
|
import { applyVcsDefinitionsBatch, markDefinitionSyncState } from '#db/index.js';
|
|
5
|
-
export function createDefinitionSyncActivities(sourceControl,
|
|
7
|
+
export function createDefinitionSyncActivities(sourceControl, integrations) {
|
|
6
8
|
return {
|
|
7
9
|
prepareDefinitionSync: createPrepareDefinitionSyncActivity(sourceControl),
|
|
8
10
|
discoverDefinitionWorkflows: createDiscoverDefinitionWorkflowsActivity(sourceControl),
|
|
9
|
-
fetchAndApplyDefinitionWorkflows: createFetchAndApplyActivity(sourceControl,
|
|
11
|
+
fetchAndApplyDefinitionWorkflows: createFetchAndApplyActivity(sourceControl, integrations),
|
|
10
12
|
markDefinitionSyncSucceeded: createMarkSyncSucceededActivity(),
|
|
11
13
|
markDefinitionSyncFailed: createMarkSyncFailedActivity()
|
|
12
14
|
};
|
|
@@ -47,7 +49,7 @@ function createDiscoverDefinitionWorkflowsActivity(sourceControl) {
|
|
|
47
49
|
});
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
|
-
function createFetchAndApplyActivity(sourceControl,
|
|
52
|
+
function createFetchAndApplyActivity(sourceControl, integrations) {
|
|
51
53
|
return async function fetchAndApplyDefinitionWorkflows(input) {
|
|
52
54
|
return await runWithPermanentTranslation(async ()=>{
|
|
53
55
|
const definitions = await fetchAndParseWorkflows({
|
|
@@ -57,13 +59,8 @@ function createFetchAndApplyActivity(sourceControl, integrationValidation) {
|
|
|
57
59
|
onProgress: (path)=>Context.current().heartbeat({
|
|
58
60
|
path
|
|
59
61
|
}),
|
|
60
|
-
loadIntegrationValidationContext:
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
agentToolSelectionCatalogs: integrationValidation.agentToolSelectionCatalogs,
|
|
64
|
-
workspaceConnectionSnapshot: await integrationValidation.loadWorkspaceConnectionSnapshot(input.workspaceId),
|
|
65
|
-
defaultConnectionSlug: sourceConnection?.slug
|
|
66
|
-
};
|
|
62
|
+
loadIntegrationValidationContext: integrations === undefined ? undefined : async ()=>{
|
|
63
|
+
return await loadIntegrationValidationContext(integrations, input.workspaceId, input.sourceConnectionId);
|
|
67
64
|
}
|
|
68
65
|
});
|
|
69
66
|
return await applyVcsDefinitionsBatch({
|
|
@@ -118,10 +115,9 @@ async function runWithPermanentTranslation(operation) {
|
|
|
118
115
|
throw error;
|
|
119
116
|
}
|
|
120
117
|
const failure = classifySyncFailure(error);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
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;
|
|
125
121
|
}
|
|
126
122
|
}
|
|
127
123
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/temporal/activities/sync-activities.ts"],"sourcesContent":["import type {\n AgentToolSelectionCatalogs,\n IntegrationSourceControlService,\n LoadWorkspaceConnectionSnapshot,\n} from '@shipfox/api-integration-core';\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 {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 DefinitionSyncIntegrationValidationOptions {\n agentToolSelectionCatalogs: AgentToolSelectionCatalogs;\n loadWorkspaceConnectionSnapshot: LoadWorkspaceConnectionSnapshot;\n getIntegrationConnectionById: (id: string) => Promise<{slug: string} | undefined>;\n}\n\nexport function createDefinitionSyncActivities(\n sourceControl: IntegrationSourceControlService,\n integrationValidation?: DefinitionSyncIntegrationValidationOptions | undefined,\n) {\n return {\n prepareDefinitionSync: createPrepareDefinitionSyncActivity(sourceControl),\n discoverDefinitionWorkflows: createDiscoverDefinitionWorkflowsActivity(sourceControl),\n fetchAndApplyDefinitionWorkflows: createFetchAndApplyActivity(\n sourceControl,\n integrationValidation,\n ),\n markDefinitionSyncSucceeded: createMarkSyncSucceededActivity(),\n markDefinitionSyncFailed: createMarkSyncFailedActivity(),\n };\n}\n\nfunction createPrepareDefinitionSyncActivity(sourceControl: IntegrationSourceControlService) {\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: IntegrationSourceControlService) {\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: IntegrationSourceControlService,\n integrationValidation?: DefinitionSyncIntegrationValidationOptions | 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 integrationValidation === undefined\n ? undefined\n : async () => {\n const sourceConnection = await integrationValidation.getIntegrationConnectionById(\n input.sourceConnectionId,\n );\n return {\n agentToolSelectionCatalogs: integrationValidation.agentToolSelectionCatalogs,\n workspaceConnectionSnapshot:\n await integrationValidation.loadWorkspaceConnectionSnapshot(input.workspaceId),\n defaultConnectionSlug: sourceConnection?.slug,\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","applyVcsDefinitionsBatch","markDefinitionSyncState","createDefinitionSyncActivities","sourceControl","integrationValidation","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","loadIntegrationValidationContext","undefined","sourceConnection","getIntegrationConnectionById","agentToolSelectionCatalogs","workspaceConnectionSnapshot","loadWorkspaceConnectionSnapshot","workspaceId","defaultConnectionSlug","slug","upserts","map","entry","configPath","name","document","definition","model","sourceSnapshot","contentHash","code","message","operation","error","failure","retryable","nonRetryable"],"mappings":"AAKA,SAAQA,OAAO,QAAO,uBAAuB;AAC7C,SAAQC,kBAAkB,QAAO,qBAAqB;AAEtD,SACEC,mBAAmB,EACnBC,qBAAqB,EACrBC,sBAAsB,EACtBC,iBAAiB,EACjBC,mBAAmB,QACd,iBAAiB;AACxB,SAAQC,wBAAwB,EAAEC,uBAAuB,QAAO,eAAe;AA6C/E,OAAO,SAASC,+BACdC,aAA8C,EAC9CC,qBAA8E;IAE9E,OAAO;QACLC,uBAAuBC,oCAAoCH;QAC3DI,6BAA6BC,0CAA0CL;QACvEM,kCAAkCC,4BAChCP,eACAC;QAEFO,6BAA6BC;QAC7BC,0BAA0BC;IAC5B;AACF;AAEA,SAASR,oCAAoCH,aAA8C;IACzF,OAAO,eAAeE,sBACpBU,KAAwB;QAExB,OAAO,MAAMC,4BAA4B;YACvC,MAAMC,YAAYF,MAAME,SAAS,IAAI,AAAC,CAAA,MAAMnB,kBAAkB;gBAAC,GAAGiB,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;gBACl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wBAC7BC,gBAAgBN,MAAMI,UAAU,CAACE,cAAc;wBAC/CC,aAAaP,MAAMO,WAAW;oBAChC,CAAA;YACF;QACF;IACF;AACF;AAEA,SAASzC;IACP,OAAO,eAAeD,4BAA4BI,KAAyB;QACzE,MAAMd,wBAAwB;YAC5BkB,WAAWJ,MAAMI,SAAS;YAC1BC,oBAAoBL,MAAMK,kBAAkB;YAC5CC,4BAA4BN,MAAMM,0BAA0B;YAC5DH,KAAKH,MAAME,SAAS;YACpBK,QAAQ;YACRC,eAAe;YACfC,kBAAkB;YAClBG,YAAY,IAAID;QAClB;IACF;AACF;AAEA,SAASZ;IACP,OAAO,eAAeD,yBACpBE,KAAkC;QAElC,MAAMd,wBAAwB;YAC5BkB,WAAWJ,MAAMI,SAAS;YAC1BC,oBAAoBL,MAAMK,kBAAkB;YAC5CC,4BAA4BN,MAAMM,0BAA0B;YAC5DH,KAAKH,MAAME,SAAS,IAAIlB;YACxBuB,QAAQ;YACRC,eAAeR,MAAMuC,IAAI;YACzB9B,kBAAkBT,MAAMwC,OAAO;YAC/B5B,YAAY,IAAID;QAClB;IACF;AACF;AAEA,eAAeV,4BAA+BwC,SAA2B;IACvE,IAAI;QACF,OAAO,MAAMA;IACf,EAAE,OAAOC,OAAO;QACd,IAAIA,iBAAiB/D,oBAAoB;YACvC,MAAM+D;QACR;QACA,MAAMC,UAAU/D,oBAAoB8D;QACpC,IAAI,CAACC,QAAQC,SAAS,EAAE;YACtB,MAAMjE,mBAAmBkE,YAAY,CAACF,QAAQH,OAAO,EAAEG,QAAQJ,IAAI;QACrE;QACA,MAAM5D,mBAAmBiE,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;gBAClBC,WAAW,IAAIC;gBACfC,YAAY;YACd;YAEA,OAAO;gBAACV;gBAAWW,iBAAiBb,MAAMa,eAAe;YAAA;QAC3D;IACF;AACF;AAEA,SAASpB,0CAA0CL,aAAuC;IACxF,OAAO,eAAeI,4BACpBQ,KAAyB;QAEzB,OAAO,MAAMC,4BAA4B;YACvC,OAAO,MAAMrB,sBAAsB;gBACjC,GAAGoB,KAAK;gBACRG,KAAKH,MAAM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