@shipfox/api-definitions 4.0.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +64 -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 +6 -10
- package/dist/temporal/activities/sync-activities.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +30 -38
- 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 +9 -6
- package/src/temporal/activities/sync-activities.ts +14 -29
- package/tsconfig.build.tsbuildinfo +1 -1
package/dist/db/db.d.ts
CHANGED
|
@@ -535,7 +535,7 @@ export declare const schema: {
|
|
|
535
535
|
tableName: "sync_states";
|
|
536
536
|
dataType: "string";
|
|
537
537
|
columnType: "PgEnumColumn";
|
|
538
|
-
data: "no-workflow-files" | "invalid-definition" | "provider-repository-not-found" | "provider-file-not-found" | "provider-access-denied" | "provider-rate-limited" | "provider-timeout" | "provider-
|
|
538
|
+
data: "unknown" | "provider-unavailable" | "no-workflow-files" | "invalid-definition" | "provider-repository-not-found" | "provider-file-not-found" | "provider-access-denied" | "provider-rate-limited" | "provider-timeout" | "provider-malformed-response" | "content-too-large" | "too-many-files" | "connection-unavailable";
|
|
539
539
|
driverParam: string;
|
|
540
540
|
notNull: false;
|
|
541
541
|
hasDefault: false;
|
|
@@ -1172,7 +1172,7 @@ export declare function db(): NodePgDatabase<{
|
|
|
1172
1172
|
tableName: "sync_states";
|
|
1173
1173
|
dataType: "string";
|
|
1174
1174
|
columnType: "PgEnumColumn";
|
|
1175
|
-
data: "no-workflow-files" | "invalid-definition" | "provider-repository-not-found" | "provider-file-not-found" | "provider-access-denied" | "provider-rate-limited" | "provider-timeout" | "provider-
|
|
1175
|
+
data: "unknown" | "provider-unavailable" | "no-workflow-files" | "invalid-definition" | "provider-repository-not-found" | "provider-file-not-found" | "provider-access-denied" | "provider-rate-limited" | "provider-timeout" | "provider-malformed-response" | "content-too-large" | "too-many-files" | "connection-unavailable";
|
|
1176
1176
|
driverParam: string;
|
|
1177
1177
|
notNull: false;
|
|
1178
1178
|
hasDefault: false;
|
|
@@ -112,7 +112,7 @@ export declare const definitionSyncStates: import("drizzle-orm/pg-core").PgTable
|
|
|
112
112
|
tableName: "sync_states";
|
|
113
113
|
dataType: "string";
|
|
114
114
|
columnType: "PgEnumColumn";
|
|
115
|
-
data: "no-workflow-files" | "invalid-definition" | "provider-repository-not-found" | "provider-file-not-found" | "provider-access-denied" | "provider-rate-limited" | "provider-timeout" | "provider-
|
|
115
|
+
data: "unknown" | "provider-unavailable" | "no-workflow-files" | "invalid-definition" | "provider-repository-not-found" | "provider-file-not-found" | "provider-access-denied" | "provider-rate-limited" | "provider-timeout" | "provider-malformed-response" | "content-too-large" | "too-many-files" | "connection-unavailable";
|
|
116
116
|
driverParam: string;
|
|
117
117
|
notNull: false;
|
|
118
118
|
hasDefault: false;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto';
|
|
2
|
+
import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
|
|
2
3
|
import { type ShipfoxModule } from '@shipfox/node-module';
|
|
3
4
|
export type { WorkflowDefinition, WorkflowDefinitionPayload, WorkflowEnvTemplates, WorkflowModel, WorkflowModelJobCheckout, WorkflowSourceSnapshot, WorkflowSpec, } from '#core/index.js';
|
|
4
5
|
export { DEFAULT_JOB_CHECKOUT, DEFAULT_JOB_SUCCESS, DEFAULT_RUN_TIMEOUT_MS, normalizeWorkflowDocument, } from '#core/index.js';
|
|
5
6
|
export { db, definitionsOutbox, getDefinitionById, migrationsPath } from '#db/index.js';
|
|
6
|
-
export { routes } from '#presentation/index.js';
|
|
7
7
|
export interface CreateDefinitionsModuleOptions {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
loadWorkspaceConnectionSnapshot?: LoadWorkspaceConnectionSnapshot | undefined;
|
|
11
|
-
getIntegrationConnectionById?: GetIntegrationConnectionByIdFn | undefined;
|
|
8
|
+
projects: ProjectsModuleClient;
|
|
9
|
+
integrations: IntegrationsModuleClient;
|
|
12
10
|
}
|
|
13
|
-
export declare function createDefinitionsModule({
|
|
11
|
+
export declare function createDefinitionsModule({ projects, integrations, }: CreateDefinitionsModuleOptions): ShipfoxModule;
|
|
14
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,mCAAmC,CAAC;AAChF,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAMpE,OAAO,EAAC,KAAK,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AAY3E,YAAY,EACV,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,EACpB,aAAa,EACb,wBAAwB,EACxB,sBAAsB,EACtB,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,EAAE,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AAOtF,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,YAAY,EAAE,wBAAwB,CAAC;CACxC;AAED,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,YAAY,GACb,EAAE,8BAA8B,GAAG,aAAa,CA4BhD"}
|
package/dist/index.js
CHANGED
|
@@ -4,22 +4,19 @@ import { DEFINITION_RESOLVED, definitionsEventSchemas } from '@shipfox/api-defin
|
|
|
4
4
|
import { PROJECT_SOURCE_BOUND, PROJECT_SOURCE_COMMIT_OBSERVED } from '@shipfox/api-projects-dto';
|
|
5
5
|
import { subscriberFactory } from '@shipfox/node-module';
|
|
6
6
|
import { logger } from '@shipfox/node-opentelemetry';
|
|
7
|
+
import { createDefinitionsSourceControl } from '#core/integrations.js';
|
|
7
8
|
import { db, definitionsOutbox, migrationsPath } from '#db/index.js';
|
|
8
9
|
import { createDefinitionRoutes } from '#presentation/index.js';
|
|
10
|
+
import { createDefinitionsInterModulePresentation } from '#presentation/inter-module.js';
|
|
9
11
|
import { onProjectSourceBound, onProjectSourceCommitObserved } from '#presentation/subscribers/index.js';
|
|
10
12
|
import { createDefinitionSyncActivities, DEFINITIONS_TASK_QUEUE } from '#temporal/index.js';
|
|
11
13
|
export { DEFAULT_JOB_CHECKOUT, DEFAULT_JOB_SUCCESS, DEFAULT_RUN_TIMEOUT_MS, normalizeWorkflowDocument } from '#core/index.js';
|
|
12
14
|
export { db, definitionsOutbox, getDefinitionById, migrationsPath } from '#db/index.js';
|
|
13
|
-
export { routes } from '#presentation/index.js';
|
|
14
15
|
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
15
16
|
const workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');
|
|
16
17
|
const subscriber = subscriberFactory();
|
|
17
|
-
export function createDefinitionsModule({
|
|
18
|
-
const
|
|
19
|
-
agentToolSelectionCatalogs,
|
|
20
|
-
loadWorkspaceConnectionSnapshot,
|
|
21
|
-
getIntegrationConnectionById
|
|
22
|
-
};
|
|
18
|
+
export function createDefinitionsModule({ projects, integrations }) {
|
|
19
|
+
const sourceControl = createDefinitionsSourceControl(integrations);
|
|
23
20
|
return {
|
|
24
21
|
name: 'definitions',
|
|
25
22
|
database: {
|
|
@@ -27,9 +24,8 @@ export function createDefinitionsModule({ sourceControl, agentToolSelectionCatal
|
|
|
27
24
|
migrationsPath
|
|
28
25
|
},
|
|
29
26
|
routes: createDefinitionRoutes({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
getIntegrationConnectionById
|
|
27
|
+
projects,
|
|
28
|
+
integrations
|
|
33
29
|
}),
|
|
34
30
|
publishers: [
|
|
35
31
|
{
|
|
@@ -53,9 +49,12 @@ export function createDefinitionsModule({ sourceControl, agentToolSelectionCatal
|
|
|
53
49
|
{
|
|
54
50
|
taskQueue: DEFINITIONS_TASK_QUEUE,
|
|
55
51
|
workflowsPath,
|
|
56
|
-
activities: ()=>createDefinitionSyncActivities(sourceControl,
|
|
52
|
+
activities: ()=>createDefinitionSyncActivities(sourceControl, integrations),
|
|
57
53
|
workflows: []
|
|
58
54
|
}
|
|
55
|
+
],
|
|
56
|
+
interModulePresentations: [
|
|
57
|
+
createDefinitionsInterModulePresentation()
|
|
59
58
|
]
|
|
60
59
|
};
|
|
61
60
|
}
|
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 {\n DEFINITION_RESOLVED,\n type DefinitionsEventMap,\n definitionsEventSchemas,\n} from '@shipfox/api-definitions-dto';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {\n DEFINITION_RESOLVED,\n type DefinitionsEventMap,\n definitionsEventSchemas,\n} from '@shipfox/api-definitions-dto';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport {\n PROJECT_SOURCE_BOUND,\n PROJECT_SOURCE_COMMIT_OBSERVED,\n type ProjectsEventMap,\n} from '@shipfox/api-projects-dto';\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';\n\nexport type {\n WorkflowDefinition,\n WorkflowDefinitionPayload,\n WorkflowEnvTemplates,\n WorkflowModel,\n WorkflowModelJobCheckout,\n WorkflowSourceSnapshot,\n WorkflowSpec,\n} from '#core/index.js';\nexport {\n DEFAULT_JOB_CHECKOUT,\n DEFAULT_JOB_SUCCESS,\n DEFAULT_RUN_TIMEOUT_MS,\n normalizeWorkflowDocument,\n} from '#core/index.js';\nexport {db, definitionsOutbox, getDefinitionById, migrationsPath} from '#db/index.js';\n\nconst packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');\nconst workflowsPath = resolve(packageRoot, 'dist/temporal/workflows/index.js');\n\nconst subscriber = subscriberFactory<DefinitionsEventMap & ProjectsEventMap>();\n\nexport interface CreateDefinitionsModuleOptions {\n projects: ProjectsModuleClient;\n integrations: IntegrationsModuleClient;\n}\n\nexport function createDefinitionsModule({\n projects,\n integrations,\n}: CreateDefinitionsModuleOptions): ShipfoxModule {\n const sourceControl = createDefinitionsSourceControl(integrations);\n\n return {\n name: 'definitions',\n database: {db, migrationsPath},\n routes: createDefinitionRoutes({projects, integrations}),\n publishers: [\n {name: 'definitions', table: definitionsOutbox, db, eventSchemas: definitionsEventSchemas},\n ],\n subscribers: [\n subscriber(DEFINITION_RESOLVED, (_payload, event) => {\n logger().info({event}, 'Definition resolved');\n return Promise.resolve();\n }),\n subscriber(PROJECT_SOURCE_BOUND, onProjectSourceBound),\n subscriber(PROJECT_SOURCE_COMMIT_OBSERVED, onProjectSourceCommitObserved),\n ],\n workers: [\n {\n taskQueue: DEFINITIONS_TASK_QUEUE,\n workflowsPath,\n activities: () => createDefinitionSyncActivities(sourceControl, integrations),\n workflows: [],\n },\n ],\n interModulePresentations: [createDefinitionsInterModulePresentation()],\n };\n}\n"],"names":["dirname","resolve","fileURLToPath","DEFINITION_RESOLVED","definitionsEventSchemas","PROJECT_SOURCE_BOUND","PROJECT_SOURCE_COMMIT_OBSERVED","subscriberFactory","logger","createDefinitionsSourceControl","db","definitionsOutbox","migrationsPath","createDefinitionRoutes","createDefinitionsInterModulePresentation","onProjectSourceBound","onProjectSourceCommitObserved","createDefinitionSyncActivities","DEFINITIONS_TASK_QUEUE","DEFAULT_JOB_CHECKOUT","DEFAULT_JOB_SUCCESS","DEFAULT_RUN_TIMEOUT_MS","normalizeWorkflowDocument","getDefinitionById","packageRoot","url","workflowsPath","subscriber","createDefinitionsModule","projects","integrations","sourceControl","name","database","routes","publishers","table","eventSchemas","subscribers","_payload","event","info","Promise","workers","taskQueue","activities","workflows","interModulePresentations"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAY;AAC3C,SAAQC,aAAa,QAAO,WAAW;AACvC,SACEC,mBAAmB,EAEnBC,uBAAuB,QAClB,+BAA+B;AAGtC,SACEC,oBAAoB,EACpBC,8BAA8B,QAEzB,4BAA4B;AACnC,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,oBAAoB,EACpBC,6BAA6B,QACxB,qCAAqC;AAC5C,SAAQC,8BAA8B,EAAEC,sBAAsB,QAAO,qBAAqB;AAW1F,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,sBAAsB,EACtBC,yBAAyB,QACpB,iBAAiB;AACxB,SAAQZ,EAAE,EAAEC,iBAAiB,EAAEY,iBAAiB,EAAEX,cAAc,QAAO,eAAe;AAEtF,MAAMY,cAAcvB,QAAQD,QAAQE,cAAc,YAAYuB,GAAG,IAAI;AACrE,MAAMC,gBAAgBzB,QAAQuB,aAAa;AAE3C,MAAMG,aAAapB;AAOnB,OAAO,SAASqB,wBAAwB,EACtCC,QAAQ,EACRC,YAAY,EACmB;IAC/B,MAAMC,gBAAgBtB,+BAA+BqB;IAErD,OAAO;QACLE,MAAM;QACNC,UAAU;YAACvB;YAAIE;QAAc;QAC7BsB,QAAQrB,uBAAuB;YAACgB;YAAUC;QAAY;QACtDK,YAAY;YACV;gBAACH,MAAM;gBAAeI,OAAOzB;gBAAmBD;gBAAI2B,cAAcjC;YAAuB;SAC1F;QACDkC,aAAa;YACXX,WAAWxB,qBAAqB,CAACoC,UAAUC;gBACzChC,SAASiC,IAAI,CAAC;oBAACD;gBAAK,GAAG;gBACvB,OAAOE,QAAQzC,OAAO;YACxB;YACA0B,WAAWtB,sBAAsBU;YACjCY,WAAWrB,gCAAgCU;SAC5C;QACD2B,SAAS;YACP;gBACEC,WAAW1B;gBACXQ;gBACAmB,YAAY,IAAM5B,+BAA+Bc,eAAeD;gBAChEgB,WAAW,EAAE;YACf;SACD;QACDC,0BAA0B;YAACjC;SAA2C;IACxE;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createDefinitionRoutes
|
|
1
|
+
export { createDefinitionRoutes } from './routes/index.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/presentation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/presentation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/presentation/index.ts"],"sourcesContent":["export {createDefinitionRoutes
|
|
1
|
+
{"version":3,"sources":["../../src/presentation/index.ts"],"sourcesContent":["export {createDefinitionRoutes} from './routes/index.js';\n"],"names":["createDefinitionRoutes"],"mappings":"AAAA,SAAQA,sBAAsB,QAAO,oBAAoB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { definitionsInterModuleContract } from '@shipfox/api-definitions-dto/inter-module';
|
|
2
|
+
import { type InterModulePresentation } from '@shipfox/inter-module';
|
|
3
|
+
export declare function createDefinitionsInterModulePresentation(): InterModulePresentation<typeof definitionsInterModuleContract>;
|
|
4
|
+
//# sourceMappingURL=inter-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inter-module.d.ts","sourceRoot":"","sources":["../../src/presentation/inter-module.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,8BAA8B,EAAC,MAAM,2CAA2C,CAAC;AACzF,OAAO,EAAgC,KAAK,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AAGlG,wBAAgB,wCAAwC,IAAI,uBAAuB,CACjF,OAAO,8BAA8B,CACtC,CAiBA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createWorkflowModelSnapshot } from '@shipfox/api-definitions-dto';
|
|
2
|
+
import { definitionsInterModuleContract } from '@shipfox/api-definitions-dto/inter-module';
|
|
3
|
+
import { defineInterModulePresentation } from '@shipfox/inter-module';
|
|
4
|
+
import { getDefinitionById } from '#db/definitions.js';
|
|
5
|
+
export function createDefinitionsInterModulePresentation() {
|
|
6
|
+
return defineInterModulePresentation(definitionsInterModuleContract, {
|
|
7
|
+
getDefinitionForWorkflowRun: async ({ definitionId })=>{
|
|
8
|
+
const definition = await getDefinitionById(definitionId);
|
|
9
|
+
if (!definition) return {
|
|
10
|
+
definition: null
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
definition: {
|
|
14
|
+
id: definition.id,
|
|
15
|
+
projectId: definition.projectId,
|
|
16
|
+
name: definition.name,
|
|
17
|
+
model: createWorkflowModelSnapshot(definition.model),
|
|
18
|
+
sourceSnapshot: definition.sourceSnapshot
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=inter-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/presentation/inter-module.ts"],"sourcesContent":["import {createWorkflowModelSnapshot} from '@shipfox/api-definitions-dto';\nimport {definitionsInterModuleContract} from '@shipfox/api-definitions-dto/inter-module';\nimport {defineInterModulePresentation, type InterModulePresentation} from '@shipfox/inter-module';\nimport {getDefinitionById} from '#db/definitions.js';\n\nexport function createDefinitionsInterModulePresentation(): InterModulePresentation<\n typeof definitionsInterModuleContract\n> {\n return defineInterModulePresentation(definitionsInterModuleContract, {\n getDefinitionForWorkflowRun: async ({definitionId}) => {\n const definition = await getDefinitionById(definitionId);\n if (!definition) return {definition: null};\n\n return {\n definition: {\n id: definition.id,\n projectId: definition.projectId,\n name: definition.name,\n model: createWorkflowModelSnapshot(definition.model),\n sourceSnapshot: definition.sourceSnapshot,\n },\n };\n },\n });\n}\n"],"names":["createWorkflowModelSnapshot","definitionsInterModuleContract","defineInterModulePresentation","getDefinitionById","createDefinitionsInterModulePresentation","getDefinitionForWorkflowRun","definitionId","definition","id","projectId","name","model","sourceSnapshot"],"mappings":"AAAA,SAAQA,2BAA2B,QAAO,+BAA+B;AACzE,SAAQC,8BAA8B,QAAO,4CAA4C;AACzF,SAAQC,6BAA6B,QAAqC,wBAAwB;AAClG,SAAQC,iBAAiB,QAAO,qBAAqB;AAErD,OAAO,SAASC;IAGd,OAAOF,8BAA8BD,gCAAgC;QACnEI,6BAA6B,OAAO,EAACC,YAAY,EAAC;YAChD,MAAMC,aAAa,MAAMJ,kBAAkBG;YAC3C,IAAI,CAACC,YAAY,OAAO;gBAACA,YAAY;YAAI;YAEzC,OAAO;gBACLA,YAAY;oBACVC,IAAID,WAAWC,EAAE;oBACjBC,WAAWF,WAAWE,SAAS;oBAC/BC,MAAMH,WAAWG,IAAI;oBACrBC,OAAOX,4BAA4BO,WAAWI,KAAK;oBACnDC,gBAAgBL,WAAWK,cAAc;gBAC3C;YACF;QACF;IACF;AACF"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto';
|
|
2
|
+
import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
|
|
2
3
|
export interface CreateDefinitionRouteOptions {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
getIntegrationConnectionById?: GetIntegrationConnectionByIdFn | undefined;
|
|
4
|
+
projects: ProjectsModuleClient;
|
|
5
|
+
integrations?: IntegrationsModuleClient;
|
|
6
6
|
}
|
|
7
|
-
export declare function buildCreateDefinitionRoute(options
|
|
8
|
-
export declare const createDefinitionRoute: import("@shipfox/node-fastify").RouteDefinition;
|
|
7
|
+
export declare function buildCreateDefinitionRoute(options: CreateDefinitionRouteOptions): import("@shipfox/node-fastify").RouteDefinition;
|
|
9
8
|
//# sourceMappingURL=create-definition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/create-definition.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"create-definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/create-definition.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,mCAAmC,CAAC;AAChF,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAWpE,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,YAAY,CAAC,EAAE,wBAAwB,CAAC;CACzC;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,4BAA4B,mDA2D/E"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { createDefinitionBodySchema, definitionResponseSchema, definitionValidationErrorSchema } from '@shipfox/api-definitions-dto';
|
|
2
|
-
import { ProjectNotFoundError, requireProjectAccess } from '@shipfox/api-projects';
|
|
3
2
|
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
4
3
|
import { z } from 'zod';
|
|
5
4
|
import { DefinitionParseError } from '#core/errors.js';
|
|
6
5
|
import { hasAgentStepIntegrations } from '#core/has-agent-step-integrations.js';
|
|
6
|
+
import { loadIntegrationValidationContext } from '#core/integrations.js';
|
|
7
7
|
import { parseDefinition } from '#core/parse-definition.js';
|
|
8
8
|
import { upsertDefinition } from '#db/definitions.js';
|
|
9
9
|
import { toDefinitionDto } from '#presentation/dto/index.js';
|
|
10
|
-
|
|
10
|
+
import { requireProjectAccess } from './project-access.js';
|
|
11
|
+
export function buildCreateDefinitionRoute(options) {
|
|
11
12
|
return defineRoute({
|
|
12
13
|
method: 'POST',
|
|
13
14
|
path: '/',
|
|
@@ -33,27 +34,15 @@ export function buildCreateDefinitionRoute(options = {}) {
|
|
|
33
34
|
status: 400
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
|
-
if (error instanceof ProjectNotFoundError) {
|
|
37
|
-
throw new ClientError(error.message, 'project-not-found', {
|
|
38
|
-
status: 404
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
37
|
throw error;
|
|
42
38
|
},
|
|
43
39
|
handler: async (request)=>{
|
|
44
40
|
const { project_id: projectId, config_path, source, yaml: yamlString, sha, ref } = request.body;
|
|
45
|
-
const
|
|
46
|
-
request,
|
|
47
|
-
projectId
|
|
48
|
-
});
|
|
41
|
+
const project = await requireProjectAccess(request, projectId, options.projects);
|
|
49
42
|
const structurallyParsed = parseDefinition(yamlString);
|
|
50
|
-
const {
|
|
51
|
-
const parsed =
|
|
52
|
-
integrationValidationContext:
|
|
53
|
-
agentToolSelectionCatalogs,
|
|
54
|
-
workspaceConnectionSnapshot: await loadWorkspaceConnectionSnapshot(project.workspaceId),
|
|
55
|
-
defaultConnectionSlug: getIntegrationConnectionById === undefined ? undefined : (await getIntegrationConnectionById(project.sourceConnectionId))?.slug
|
|
56
|
-
}
|
|
43
|
+
const { integrations } = options;
|
|
44
|
+
const parsed = integrations !== undefined && hasAgentStepIntegrations(structurallyParsed.document) ? parseDefinition(yamlString, {
|
|
45
|
+
integrationValidationContext: await loadIntegrationValidationContext(integrations, project.workspaceId, project.sourceConnectionId)
|
|
57
46
|
}) : structurallyParsed;
|
|
58
47
|
const definition = await upsertDefinition({
|
|
59
48
|
projectId,
|
|
@@ -71,6 +60,5 @@ export function buildCreateDefinitionRoute(options = {}) {
|
|
|
71
60
|
}
|
|
72
61
|
});
|
|
73
62
|
}
|
|
74
|
-
export const createDefinitionRoute = buildCreateDefinitionRoute();
|
|
75
63
|
|
|
76
64
|
//# sourceMappingURL=create-definition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/create-definition.ts"],"sourcesContent":["import {\n createDefinitionBodySchema,\n definitionResponseSchema,\n definitionValidationErrorSchema,\n} from '@shipfox/api-definitions-dto';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/create-definition.ts"],"sourcesContent":["import {\n createDefinitionBodySchema,\n definitionResponseSchema,\n definitionValidationErrorSchema,\n} from '@shipfox/api-definitions-dto';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {DefinitionParseError} from '#core/errors.js';\nimport {hasAgentStepIntegrations} from '#core/has-agent-step-integrations.js';\nimport {loadIntegrationValidationContext} from '#core/integrations.js';\nimport {parseDefinition} from '#core/parse-definition.js';\nimport {upsertDefinition} from '#db/definitions.js';\nimport {toDefinitionDto} from '#presentation/dto/index.js';\nimport {requireProjectAccess} from './project-access.js';\n\nexport interface CreateDefinitionRouteOptions {\n projects: ProjectsModuleClient;\n integrations?: IntegrationsModuleClient;\n}\n\nexport function buildCreateDefinitionRoute(options: CreateDefinitionRouteOptions) {\n return defineRoute({\n method: 'POST',\n path: '/',\n description: 'Create or update a workflow definition',\n schema: {\n body: createDefinitionBodySchema,\n response: {\n 200: definitionResponseSchema,\n 400: z.object({\n code: z.string(),\n message: z.string().optional(),\n details: z.array(definitionValidationErrorSchema).optional(),\n }),\n 404: z.object({code: z.string()}),\n },\n },\n errorHandler: (error, _request, _reply) => {\n if (error instanceof DefinitionParseError) {\n throw new ClientError(error.message, 'invalid-workflow-definition', {\n details: error.details,\n status: 400,\n });\n }\n throw error;\n },\n handler: async (request) => {\n const {project_id: projectId, config_path, source, yaml: yamlString, sha, ref} = request.body;\n const project = await requireProjectAccess(request, projectId, options.projects);\n\n const structurallyParsed = parseDefinition(yamlString);\n const {integrations} = options;\n const parsed =\n integrations !== undefined && hasAgentStepIntegrations(structurallyParsed.document)\n ? parseDefinition(yamlString, {\n integrationValidationContext: await loadIntegrationValidationContext(\n integrations,\n project.workspaceId,\n project.sourceConnectionId,\n ),\n })\n : structurallyParsed;\n\n const definition = await upsertDefinition({\n projectId,\n workspaceId: project.workspaceId,\n configPath: config_path,\n source,\n name: parsed.document.name,\n document: parsed.document,\n model: parsed.model,\n sourceSnapshot: parsed.sourceSnapshot,\n sha,\n ref,\n });\n\n return toDefinitionDto(definition);\n },\n });\n}\n"],"names":["createDefinitionBodySchema","definitionResponseSchema","definitionValidationErrorSchema","ClientError","defineRoute","z","DefinitionParseError","hasAgentStepIntegrations","loadIntegrationValidationContext","parseDefinition","upsertDefinition","toDefinitionDto","requireProjectAccess","buildCreateDefinitionRoute","options","method","path","description","schema","body","response","object","code","string","message","optional","details","array","errorHandler","error","_request","_reply","status","handler","request","project_id","projectId","config_path","source","yaml","yamlString","sha","ref","project","projects","structurallyParsed","integrations","parsed","undefined","document","integrationValidationContext","workspaceId","sourceConnectionId","definition","configPath","name","model","sourceSnapshot"],"mappings":"AAAA,SACEA,0BAA0B,EAC1BC,wBAAwB,EACxBC,+BAA+B,QAC1B,+BAA+B;AAGtC,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,oBAAoB,QAAO,kBAAkB;AACrD,SAAQC,wBAAwB,QAAO,uCAAuC;AAC9E,SAAQC,gCAAgC,QAAO,wBAAwB;AACvE,SAAQC,eAAe,QAAO,4BAA4B;AAC1D,SAAQC,gBAAgB,QAAO,qBAAqB;AACpD,SAAQC,eAAe,QAAO,6BAA6B;AAC3D,SAAQC,oBAAoB,QAAO,sBAAsB;AAOzD,OAAO,SAASC,2BAA2BC,OAAqC;IAC9E,OAAOV,YAAY;QACjBW,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,MAAMnB;YACNoB,UAAU;gBACR,KAAKnB;gBACL,KAAKI,EAAEgB,MAAM,CAAC;oBACZC,MAAMjB,EAAEkB,MAAM;oBACdC,SAASnB,EAAEkB,MAAM,GAAGE,QAAQ;oBAC5BC,SAASrB,EAAEsB,KAAK,CAACzB,iCAAiCuB,QAAQ;gBAC5D;gBACA,KAAKpB,EAAEgB,MAAM,CAAC;oBAACC,MAAMjB,EAAEkB,MAAM;gBAAE;YACjC;QACF;QACAK,cAAc,CAACC,OAAOC,UAAUC;YAC9B,IAAIF,iBAAiBvB,sBAAsB;gBACzC,MAAM,IAAIH,YAAY0B,MAAML,OAAO,EAAE,+BAA+B;oBAClEE,SAASG,MAAMH,OAAO;oBACtBM,QAAQ;gBACV;YACF;YACA,MAAMH;QACR;QACAI,SAAS,OAAOC;YACd,MAAM,EAACC,YAAYC,SAAS,EAAEC,WAAW,EAAEC,MAAM,EAAEC,MAAMC,UAAU,EAAEC,GAAG,EAAEC,GAAG,EAAC,GAAGR,QAAQf,IAAI;YAC7F,MAAMwB,UAAU,MAAM/B,qBAAqBsB,SAASE,WAAWtB,QAAQ8B,QAAQ;YAE/E,MAAMC,qBAAqBpC,gBAAgB+B;YAC3C,MAAM,EAACM,YAAY,EAAC,GAAGhC;YACvB,MAAMiC,SACJD,iBAAiBE,aAAazC,yBAAyBsC,mBAAmBI,QAAQ,IAC9ExC,gBAAgB+B,YAAY;gBAC1BU,8BAA8B,MAAM1C,iCAClCsC,cACAH,QAAQQ,WAAW,EACnBR,QAAQS,kBAAkB;YAE9B,KACAP;YAEN,MAAMQ,aAAa,MAAM3C,iBAAiB;gBACxC0B;gBACAe,aAAaR,QAAQQ,WAAW;gBAChCG,YAAYjB;gBACZC;gBACAiB,MAAMR,OAAOE,QAAQ,CAACM,IAAI;gBAC1BN,UAAUF,OAAOE,QAAQ;gBACzBO,OAAOT,OAAOS,KAAK;gBACnBC,gBAAgBV,OAAOU,cAAc;gBACrChB;gBACAC;YACF;YAEA,OAAO/B,gBAAgB0C;QACzB;IACF;AACF"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
|
|
2
|
+
export declare function buildGetDefinitionRoute(projects: ProjectsModuleClient): import("@shipfox/node-fastify").RouteDefinition;
|
|
2
3
|
//# sourceMappingURL=get-definition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-definition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-definition.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/get-definition.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAOpE,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,oBAAoB,mDAyBrE"}
|
|
@@ -1,43 +1,34 @@
|
|
|
1
1
|
import { definitionResponseSchema } from '@shipfox/api-definitions-dto';
|
|
2
|
-
import { ProjectNotFoundError, requireProjectAccess } from '@shipfox/api-projects';
|
|
3
2
|
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
4
3
|
import { z } from 'zod';
|
|
5
4
|
import { getDefinitionById } from '#db/definitions.js';
|
|
6
5
|
import { toDefinitionDto } from '#presentation/dto/index.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
import { requireProjectAccess } from './project-access.js';
|
|
7
|
+
export function buildGetDefinitionRoute(projects) {
|
|
8
|
+
return defineRoute({
|
|
9
|
+
method: 'GET',
|
|
10
|
+
path: '/:id',
|
|
11
|
+
description: 'Get a definition by ID',
|
|
12
|
+
schema: {
|
|
13
|
+
params: z.object({
|
|
14
|
+
id: z.string().uuid()
|
|
15
|
+
}),
|
|
16
|
+
response: {
|
|
17
|
+
200: definitionResponseSchema
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
handler: async (request)=>{
|
|
21
|
+
const { id } = request.params;
|
|
22
|
+
const definition = await getDefinitionById(id);
|
|
23
|
+
if (!definition) {
|
|
24
|
+
throw new ClientError('Definition not found', 'not-found', {
|
|
25
|
+
status: 404
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
await requireProjectAccess(request, definition.projectId, projects);
|
|
29
|
+
return toDefinitionDto(definition);
|
|
17
30
|
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (error instanceof ProjectNotFoundError) {
|
|
21
|
-
throw new ClientError('Definition not found', 'not-found', {
|
|
22
|
-
status: 404
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
throw error;
|
|
26
|
-
},
|
|
27
|
-
handler: async (request)=>{
|
|
28
|
-
const { id } = request.params;
|
|
29
|
-
const definition = await getDefinitionById(id);
|
|
30
|
-
if (!definition) {
|
|
31
|
-
throw new ClientError('Definition not found', 'not-found', {
|
|
32
|
-
status: 404
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
await requireProjectAccess({
|
|
36
|
-
request,
|
|
37
|
-
projectId: definition.projectId
|
|
38
|
-
});
|
|
39
|
-
return toDefinitionDto(definition);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
42
33
|
|
|
43
34
|
//# sourceMappingURL=get-definition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/get-definition.ts"],"sourcesContent":["import {definitionResponseSchema} from '@shipfox/api-definitions-dto';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/get-definition.ts"],"sourcesContent":["import {definitionResponseSchema} from '@shipfox/api-definitions-dto';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto';\nimport {ClientError, defineRoute} from '@shipfox/node-fastify';\nimport {z} from 'zod';\nimport {getDefinitionById} from '#db/definitions.js';\nimport {toDefinitionDto} from '#presentation/dto/index.js';\nimport {requireProjectAccess} from './project-access.js';\n\nexport function buildGetDefinitionRoute(projects: ProjectsModuleClient) {\n return defineRoute({\n method: 'GET',\n path: '/:id',\n description: 'Get a definition by ID',\n schema: {\n params: z.object({\n id: z.string().uuid(),\n }),\n response: {\n 200: definitionResponseSchema,\n },\n },\n handler: async (request) => {\n const {id} = request.params;\n const definition = await getDefinitionById(id);\n\n if (!definition) {\n throw new ClientError('Definition not found', 'not-found', {status: 404});\n }\n await requireProjectAccess(request, definition.projectId, projects);\n\n return toDefinitionDto(definition);\n },\n });\n}\n"],"names":["definitionResponseSchema","ClientError","defineRoute","z","getDefinitionById","toDefinitionDto","requireProjectAccess","buildGetDefinitionRoute","projects","method","path","description","schema","params","object","id","string","uuid","response","handler","request","definition","status","projectId"],"mappings":"AAAA,SAAQA,wBAAwB,QAAO,+BAA+B;AAEtE,SAAQC,WAAW,EAAEC,WAAW,QAAO,wBAAwB;AAC/D,SAAQC,CAAC,QAAO,MAAM;AACtB,SAAQC,iBAAiB,QAAO,qBAAqB;AACrD,SAAQC,eAAe,QAAO,6BAA6B;AAC3D,SAAQC,oBAAoB,QAAO,sBAAsB;AAEzD,OAAO,SAASC,wBAAwBC,QAA8B;IACpE,OAAON,YAAY;QACjBO,QAAQ;QACRC,MAAM;QACNC,aAAa;QACbC,QAAQ;YACNC,QAAQV,EAAEW,MAAM,CAAC;gBACfC,IAAIZ,EAAEa,MAAM,GAAGC,IAAI;YACrB;YACAC,UAAU;gBACR,KAAKlB;YACP;QACF;QACAmB,SAAS,OAAOC;YACd,MAAM,EAACL,EAAE,EAAC,GAAGK,QAAQP,MAAM;YAC3B,MAAMQ,aAAa,MAAMjB,kBAAkBW;YAE3C,IAAI,CAACM,YAAY;gBACf,MAAM,IAAIpB,YAAY,wBAAwB,aAAa;oBAACqB,QAAQ;gBAAG;YACzE;YACA,MAAMhB,qBAAqBc,SAASC,WAAWE,SAAS,EAAEf;YAE1D,OAAOH,gBAAgBgB;QACzB;IACF;AACF"}
|
|
@@ -2,6 +2,5 @@ import type { RouteGroup } from '@shipfox/node-fastify';
|
|
|
2
2
|
import { type CreateDefinitionRouteOptions } from './create-definition.js';
|
|
3
3
|
export interface DefinitionRouteOptions extends CreateDefinitionRouteOptions {
|
|
4
4
|
}
|
|
5
|
-
export declare function createDefinitionRoutes(options
|
|
6
|
-
export declare const definitionRoutes: RouteGroup[];
|
|
5
|
+
export declare function createDefinitionRoutes(options: DefinitionRouteOptions): RouteGroup[];
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,wBAAwB,CAAC;AAKhC,MAAM,WAAW,sBAAuB,SAAQ,4BAA4B;CAAG;AAE/E,wBAAgB,sBAAsB,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,wBAAwB,CAAC;AAKhC,MAAM,WAAW,sBAAuB,SAAQ,4BAA4B;CAAG;AAE/E,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,sBAAsB,GAAG,UAAU,EAAE,CAapF"}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { AUTH_USER } from '@shipfox/api-auth-context';
|
|
2
2
|
import { buildCreateDefinitionRoute } from './create-definition.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { buildGetDefinitionRoute } from './get-definition.js';
|
|
4
|
+
import { buildListDefinitionsRoute } from './list-definitions.js';
|
|
5
5
|
import { validateDefinitionRoute } from './validate-definition.js';
|
|
6
|
-
export function createDefinitionRoutes(options
|
|
6
|
+
export function createDefinitionRoutes(options) {
|
|
7
7
|
return [
|
|
8
8
|
{
|
|
9
9
|
prefix: '/definitions',
|
|
10
10
|
auth: AUTH_USER,
|
|
11
11
|
routes: [
|
|
12
12
|
buildCreateDefinitionRoute(options),
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
buildListDefinitionsRoute(options.projects),
|
|
14
|
+
buildGetDefinitionRoute(options.projects),
|
|
15
15
|
validateDefinitionRoute
|
|
16
16
|
]
|
|
17
17
|
}
|
|
18
18
|
];
|
|
19
19
|
}
|
|
20
|
-
export const definitionRoutes = createDefinitionRoutes();
|
|
21
20
|
|
|
22
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/presentation/routes/index.ts"],"sourcesContent":["import {AUTH_USER} from '@shipfox/api-auth-context';\nimport type {RouteGroup} from '@shipfox/node-fastify';\nimport {\n buildCreateDefinitionRoute,\n type CreateDefinitionRouteOptions,\n} from './create-definition.js';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/presentation/routes/index.ts"],"sourcesContent":["import {AUTH_USER} from '@shipfox/api-auth-context';\nimport type {RouteGroup} from '@shipfox/node-fastify';\nimport {\n buildCreateDefinitionRoute,\n type CreateDefinitionRouteOptions,\n} from './create-definition.js';\nimport {buildGetDefinitionRoute} from './get-definition.js';\nimport {buildListDefinitionsRoute} from './list-definitions.js';\nimport {validateDefinitionRoute} from './validate-definition.js';\n\nexport interface DefinitionRouteOptions extends CreateDefinitionRouteOptions {}\n\nexport function createDefinitionRoutes(options: DefinitionRouteOptions): RouteGroup[] {\n return [\n {\n prefix: '/definitions',\n auth: AUTH_USER,\n routes: [\n buildCreateDefinitionRoute(options),\n buildListDefinitionsRoute(options.projects),\n buildGetDefinitionRoute(options.projects),\n validateDefinitionRoute,\n ],\n },\n ];\n}\n"],"names":["AUTH_USER","buildCreateDefinitionRoute","buildGetDefinitionRoute","buildListDefinitionsRoute","validateDefinitionRoute","createDefinitionRoutes","options","prefix","auth","routes","projects"],"mappings":"AAAA,SAAQA,SAAS,QAAO,4BAA4B;AAEpD,SACEC,0BAA0B,QAErB,yBAAyB;AAChC,SAAQC,uBAAuB,QAAO,sBAAsB;AAC5D,SAAQC,yBAAyB,QAAO,wBAAwB;AAChE,SAAQC,uBAAuB,QAAO,2BAA2B;AAIjE,OAAO,SAASC,uBAAuBC,OAA+B;IACpE,OAAO;QACL;YACEC,QAAQ;YACRC,MAAMR;YACNS,QAAQ;gBACNR,2BAA2BK;gBAC3BH,0BAA0BG,QAAQI,QAAQ;gBAC1CR,wBAAwBI,QAAQI,QAAQ;gBACxCN;aACD;QACH;KACD;AACH"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ProjectsModuleClient } from '@shipfox/api-projects-dto';
|
|
2
|
+
export declare function buildListDefinitionsRoute(projects: ProjectsModuleClient): import("@shipfox/node-fastify").RouteDefinition;
|
|
2
3
|
//# sourceMappingURL=list-definitions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-definitions.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-definitions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list-definitions.d.ts","sourceRoot":"","sources":["../../../src/presentation/routes/list-definitions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAQpE,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,oBAAoB,mDAiCvE"}
|
|
@@ -1,56 +1,47 @@
|
|
|
1
1
|
import { definitionListQuerySchema, definitionListResponseSchema } from '@shipfox/api-definitions-dto';
|
|
2
|
-
import { ProjectNotFoundError, requireProjectAccess } from '@shipfox/api-projects';
|
|
3
2
|
import { decodeStringIdCursor, encodeStringIdCursor } from '@shipfox/node-drizzle';
|
|
4
3
|
import { ClientError, defineRoute } from '@shipfox/node-fastify';
|
|
5
4
|
import { listDefinitions } from '#db/definitions.js';
|
|
6
5
|
import { getLatestDefinitionSyncState } from '#db/sync-states.js';
|
|
7
6
|
import { toDefinitionDto, toDefinitionSyncSummaryDto } from '#presentation/dto/index.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
import { requireProjectAccess } from './project-access.js';
|
|
8
|
+
export function buildListDefinitionsRoute(projects) {
|
|
9
|
+
return defineRoute({
|
|
10
|
+
method: 'GET',
|
|
11
|
+
path: '/',
|
|
12
|
+
description: 'List all definitions for a project',
|
|
13
|
+
schema: {
|
|
14
|
+
querystring: definitionListQuerySchema,
|
|
15
|
+
response: {
|
|
16
|
+
200: definitionListResponseSchema
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
handler: async (request)=>{
|
|
20
|
+
const { project_id: projectId, limit, cursor } = request.query;
|
|
21
|
+
const decodedCursor = decodeStringIdCursor(cursor);
|
|
22
|
+
if (cursor && !decodedCursor) {
|
|
23
|
+
throw new ClientError('Invalid cursor', 'invalid-cursor', {
|
|
24
|
+
status: 400
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const project = await requireProjectAccess(request, projectId, projects);
|
|
28
|
+
const result = await listDefinitions({
|
|
29
|
+
projectId,
|
|
30
|
+
limit,
|
|
31
|
+
cursor: decodedCursor
|
|
22
32
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const { project_id: projectId, limit, cursor } = request.query;
|
|
28
|
-
const decodedCursor = decodeStringIdCursor(cursor);
|
|
29
|
-
if (cursor && !decodedCursor) {
|
|
30
|
-
throw new ClientError('Invalid cursor', 'invalid-cursor', {
|
|
31
|
-
status: 400
|
|
33
|
+
const syncState = await getLatestDefinitionSyncState({
|
|
34
|
+
projectId,
|
|
35
|
+
sourceConnectionId: project.sourceConnectionId,
|
|
36
|
+
sourceExternalRepositoryId: project.sourceExternalRepositoryId
|
|
32
37
|
});
|
|
38
|
+
return {
|
|
39
|
+
definitions: result.definitions.map(toDefinitionDto),
|
|
40
|
+
sync: toDefinitionSyncSummaryDto(syncState),
|
|
41
|
+
next_cursor: result.nextCursor ? encodeStringIdCursor(result.nextCursor) : null
|
|
42
|
+
};
|
|
33
43
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
projectId
|
|
37
|
-
});
|
|
38
|
-
const result = await listDefinitions({
|
|
39
|
-
projectId,
|
|
40
|
-
limit,
|
|
41
|
-
cursor: decodedCursor
|
|
42
|
-
});
|
|
43
|
-
const syncState = await getLatestDefinitionSyncState({
|
|
44
|
-
projectId,
|
|
45
|
-
sourceConnectionId: project.sourceConnectionId,
|
|
46
|
-
sourceExternalRepositoryId: project.sourceExternalRepositoryId
|
|
47
|
-
});
|
|
48
|
-
return {
|
|
49
|
-
definitions: result.definitions.map(toDefinitionDto),
|
|
50
|
-
sync: toDefinitionSyncSummaryDto(syncState),
|
|
51
|
-
next_cursor: result.nextCursor ? encodeStringIdCursor(result.nextCursor) : null
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
55
46
|
|
|
56
47
|
//# sourceMappingURL=list-definitions.js.map
|