@shipfox/api-projects 12.0.0 → 12.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  $ shipfox-swc && shipfox-temporal-bundle dist/temporal/workflows/index.js
2
- Successfully compiled: 39 files with swc (229.15ms)
3
- 2026-08-04T08:17:10.541Z [INFO] asset workflow-bundle-601f98c1048b285735c6.js 3.17 MiB [emitted] [immutable] (name: main)
2
+ Successfully compiled: 39 files with swc (449.23ms)
3
+ 2026-08-06T13:12:47.464Z [INFO] asset workflow-bundle-601f98c1048b285735c6.js 3.17 MiB [emitted] [immutable] (name: main)
4
4
  orphan modules 33.5 KiB [orphan] 21 modules
5
5
  runtime modules 1.13 KiB 5 modules
6
6
  modules by path ../../../node_modules/.pnpm/ 970 KiB 196 modules
@@ -12,6 +12,6 @@ optional modules 30 bytes [optional]
12
12
  __temporal_custom_payload_converter (ignored) 15 bytes [optional] [built] [code generated]
13
13
  __temporal_custom_failure_converter (ignored) 15 bytes [optional] [built] [code generated]
14
14
  ../../shared/node/temporal/dist/workflow-error-interceptor.js 1.21 KiB [built] [code generated]
15
- webpack 5.107.2 compiled successfully in 4061 ms
16
- 2026-08-04T08:17:10.556Z [INFO] Workflow bundle created { size: '3.17MB' }
15
+ webpack 5.107.2 compiled successfully in 8227 ms
16
+ 2026-08-06T13:12:47.497Z [INFO] Workflow bundle created { size: '3.17MB' }
17
17
  /home/runner/work/shipfox/shipfox/libs/api/projects/dist/temporal/workflows/index.js: 3319553 bytes
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @shipfox/api-projects
2
2
 
3
+ ## 12.2.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 7901a60: Retry workspace workflow definition syncs when an integration connection becomes available.
8
+ - Updated dependencies [7901a60]
9
+ - @shipfox/api-integration-core-dto@12.2.0
10
+ - @shipfox/api-projects-dto@12.2.0
11
+ - @shipfox/node-opentelemetry@0.6.4
12
+ - @shipfox/node-fastify@0.4.2
13
+ - @shipfox/node-module@1.0.6
14
+ - @shipfox/node-temporal@0.4.5
15
+ - @shipfox/api-auth-context@12.2.0
16
+
3
17
  ## 12.0.0
4
18
 
5
19
  ### Major Changes
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,SAAS,EAAE,MAAM;CAI9B;AAED,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,SAAS,EAAE,MAAM;CAI9B;AAED,qBAAa,yBAA0B,SAAQ,KAAK;aAEhC,iBAAiB,EAAE,MAAM;aACzB,kBAAkB,EAAE,MAAM;aAC1B,0BAA0B,EAAE,MAAM;gBAFlC,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,EAAE,MAAM,EAC1B,0BAA0B,EAAE,MAAM;CAOrD;AAED,qBAAa,wBAAyB,SAAQ,KAAK;aACrB,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM;CAIzC"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,SAAS,EAAE,MAAM,EAG5B;CACF;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,YAAY,SAAS,EAAE,MAAM,EAG5B;CACF;AAED,qBAAa,yBAA0B,SAAQ,KAAK;aAEhC,iBAAiB,EAAE,MAAM;aACzB,kBAAkB,EAAE,MAAM;aAC1B,0BAA0B,EAAE,MAAM;IAHpD,YACkB,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,EAAE,MAAM,EAC1B,0BAA0B,EAAE,MAAM,EAMnD;CACF;AAED,qBAAa,wBAAyB,SAAQ,KAAK;aACrB,IAAI,EAAE,MAAM;IAAxC,YAA4B,IAAI,EAAE,MAAM,EAGvC;CACF"}
package/dist/db/db.d.ts CHANGED
@@ -192,7 +192,7 @@ export declare const schema: {
192
192
  generated: undefined;
193
193
  }, {}, {}>;
194
194
  };
195
- dialect: "pg";
195
+ dialect: 'pg';
196
196
  }>;
197
197
  projectsOutbox: import("drizzle-orm/pg-core").PgTableWithColumns<{
198
198
  name: "outbox";
@@ -386,7 +386,7 @@ export declare const schema: {
386
386
  generated: undefined;
387
387
  }, {}, {}>;
388
388
  };
389
- dialect: "pg";
389
+ dialect: 'pg';
390
390
  }>;
391
391
  projectsIntegrationEventDedup: import("drizzle-orm/pg-core").PgTableWithColumns<{
392
392
  name: "integration_event_dedup";
@@ -444,7 +444,7 @@ export declare const schema: {
444
444
  generated: undefined;
445
445
  }, {}, {}>;
446
446
  };
447
- dialect: "pg";
447
+ dialect: 'pg';
448
448
  }>;
449
449
  };
450
450
  export declare function db(): NodePgDatabase<{
@@ -640,7 +640,7 @@ export declare function db(): NodePgDatabase<{
640
640
  generated: undefined;
641
641
  }, {}, {}>;
642
642
  };
643
- dialect: "pg";
643
+ dialect: 'pg';
644
644
  }>;
645
645
  projectsOutbox: import("drizzle-orm/pg-core").PgTableWithColumns<{
646
646
  name: "outbox";
@@ -834,7 +834,7 @@ export declare function db(): NodePgDatabase<{
834
834
  generated: undefined;
835
835
  }, {}, {}>;
836
836
  };
837
- dialect: "pg";
837
+ dialect: 'pg';
838
838
  }>;
839
839
  projectsIntegrationEventDedup: import("drizzle-orm/pg-core").PgTableWithColumns<{
840
840
  name: "integration_event_dedup";
@@ -892,7 +892,7 @@ export declare function db(): NodePgDatabase<{
892
892
  generated: undefined;
893
893
  }, {}, {}>;
894
894
  };
895
- dialect: "pg";
895
+ dialect: 'pg';
896
896
  }>;
897
897
  }>;
898
898
  export type Tx = Parameters<Parameters<ReturnType<typeof db>['transaction']>[0]>[0];
@@ -54,6 +54,6 @@ export declare const projectsIntegrationEventDedup: import("drizzle-orm/pg-core"
54
54
  generated: undefined;
55
55
  }, {}, {}>;
56
56
  };
57
- dialect: "pg";
57
+ dialect: 'pg';
58
58
  }>;
59
59
  //# sourceMappingURL=integration-event-dedup.d.ts.map
@@ -190,6 +190,6 @@ export declare const projectsOutbox: import("drizzle-orm/pg-core").PgTableWithCo
190
190
  generated: undefined;
191
191
  }, {}, {}>;
192
192
  };
193
- dialect: "pg";
193
+ dialect: 'pg';
194
194
  }>;
195
195
  //# sourceMappingURL=outbox.d.ts.map
@@ -191,7 +191,7 @@ export declare const projects: import("drizzle-orm/pg-core").PgTableWithColumns<
191
191
  generated: undefined;
192
192
  }, {}, {}>;
193
193
  };
194
- dialect: "pg";
194
+ dialect: 'pg';
195
195
  }>;
196
196
  export type ProjectDb = typeof projects.$inferSelect;
197
197
  export type ProjectCreateDb = typeof projects.$inferInsert;
@@ -15,7 +15,7 @@ export declare function toProjectDto(project: Project): {
15
15
  export declare function toAdminProjectSummaryDto(project: AdminProjectSummary): {
16
16
  id: string;
17
17
  name: string;
18
- status: "active";
18
+ status: 'active';
19
19
  workspace_id: string;
20
20
  created_at: string;
21
21
  updated_at: string;
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/presentation/dto/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAEzD,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO;;;;;;;;;;;EAa5C;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,mBAAmB;;;;;;;EASpE"}
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/presentation/dto/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAEzD,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO;IAEzC,EAAE;IACF,YAAY;IACZ,IAAI;IACJ,IAAI;IACJ,MAAM;QACJ,aAAa;QACb,sBAAsB;;IAExB,UAAU;IACV,UAAU;EAEb;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,mBAAmB;IAEjE,EAAE;IACF,IAAI;IACJ,MAAM,EAAE,QAAQ;IAChB,YAAY;IACZ,UAAU;IACV,UAAU;EAEb"}
@@ -1 +1 @@
1
- {"version":3,"file":"inter-module.d.ts","sourceRoot":"","sources":["../../src/presentation/inter-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAAC,2BAA2B,EAAC,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAS/B,wBAAgB,qCAAqC,CAAC,MAAM,EAAE;IAC5D,YAAY,EAAE,IAAI,CAAC,wBAAwB,EAAE,yBAAyB,CAAC,CAAC;CACzE,GAAG,uBAAuB,CAAC,OAAO,2BAA2B,CAAC,CA0F9D"}
1
+ {"version":3,"file":"inter-module.d.ts","sourceRoot":"","sources":["../../src/presentation/inter-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAAC,2BAA2B,EAAC,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAU/B,wBAAgB,qCAAqC,CAAC,MAAM,EAAE;IAC5D,YAAY,EAAE,IAAI,CAAC,wBAAwB,EAAE,yBAAyB,CAAC,CAAC;CACzE,GAAG,uBAAuB,CAAC,OAAO,2BAA2B,CAAC,CAuG9D"}
@@ -1,6 +1,6 @@
1
1
  import { projectsInterModuleContract } from '@shipfox/api-projects-dto/inter-module';
2
2
  import { createInterModuleKnownError, defineInterModulePresentation } from '@shipfox/inter-module';
3
- import { getProjectById, getProjectBySource, getWorkspaceProjectCounts, resolveCheckoutTarget, updateProjectSourceMetadata } from '#db/projects.js';
3
+ import { getProjectById, getProjectBySource, getWorkspaceProjectCounts, listProjects, resolveCheckoutTarget, updateProjectSourceMetadata } from '#db/projects.js';
4
4
  export function createProjectsInterModulePresentation(params) {
5
5
  return defineInterModulePresentation(projectsInterModuleContract, {
6
6
  getProjectById: async ({ projectId })=>({
@@ -9,6 +9,25 @@ export function createProjectsInterModulePresentation(params) {
9
9
  getProjectBySource: async (input)=>({
10
10
  project: await getProjectBySource(input) ?? null
11
11
  }),
12
+ listProjectsByWorkspace: async ({ workspaceId, limit, cursor })=>{
13
+ const result = await listProjects({
14
+ workspaceId,
15
+ limit,
16
+ ...cursor ? {
17
+ cursor: {
18
+ createdAt: new Date(cursor.createdAt),
19
+ id: cursor.id
20
+ }
21
+ } : {}
22
+ });
23
+ return {
24
+ projects: result.projects,
25
+ nextCursor: result.nextCursor ? {
26
+ createdAt: result.nextCursor.createdAt.toISOString(),
27
+ id: result.nextCursor.id
28
+ } : null
29
+ };
30
+ },
12
31
  requireProjectForWorkspace: async ({ projectId, workspaceId })=>{
13
32
  const project = await getProjectById(projectId);
14
33
  if (project === undefined) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/presentation/inter-module.ts"],"sourcesContent":["import type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport {projectsInterModuleContract} from '@shipfox/api-projects-dto/inter-module';\nimport {\n createInterModuleKnownError,\n defineInterModulePresentation,\n type InterModulePresentation,\n} from '@shipfox/inter-module';\nimport {\n getProjectById,\n getProjectBySource,\n getWorkspaceProjectCounts,\n resolveCheckoutTarget,\n updateProjectSourceMetadata,\n} from '#db/projects.js';\n\nexport function createProjectsInterModulePresentation(params: {\n integrations: Pick<IntegrationsModuleClient, 'resolveSourceRepository'>;\n}): InterModulePresentation<typeof projectsInterModuleContract> {\n return defineInterModulePresentation(projectsInterModuleContract, {\n getProjectById: async ({projectId}) => ({project: (await getProjectById(projectId)) ?? null}),\n getProjectBySource: async (input) => ({\n project: (await getProjectBySource(input)) ?? null,\n }),\n requireProjectForWorkspace: async ({projectId, workspaceId}) => {\n const project = await getProjectById(projectId);\n if (project === undefined) {\n throw createInterModuleKnownError(\n projectsInterModuleContract.methods.requireProjectForWorkspace,\n 'project-not-found',\n {projectId},\n );\n }\n if (project.workspaceId !== workspaceId) {\n throw createInterModuleKnownError(\n projectsInterModuleContract.methods.requireProjectForWorkspace,\n 'project-workspace-mismatch',\n {projectId, workspaceId},\n );\n }\n return {project};\n },\n getWorkspaceProjectCounts: async ({workspaceIds}) => ({\n counts: await getWorkspaceProjectCounts({workspaceIds}),\n }),\n resolveCheckoutTarget: async (input) => {\n const target = await resolveCheckoutTarget(input);\n if (target === undefined) {\n throw createInterModuleKnownError(\n projectsInterModuleContract.methods.resolveCheckoutTarget,\n 'checkout-repository-not-authorized',\n {},\n );\n }\n\n if ('repository' in input.target) {\n const source = await params.integrations\n .resolveSourceRepository({\n workspaceId: input.workspaceId,\n connectionId: target.connectionId,\n externalRepositoryId: target.externalRepositoryId,\n })\n .catch(() => undefined);\n if (source === undefined) {\n throw createInterModuleKnownError(\n projectsInterModuleContract.methods.resolveCheckoutTarget,\n 'checkout-repository-not-authorized',\n {},\n );\n }\n\n const separator = input.target.repository.indexOf('/');\n const requestedOwner =\n separator === -1 ? input.defaults.owner : input.target.repository.slice(0, separator);\n const requestedName =\n separator === -1 ? input.target.repository : input.target.repository.slice(separator + 1);\n const repositoryMatches =\n source.repository.owner.toLowerCase() === requestedOwner.toLowerCase() &&\n source.repository.name.toLowerCase() === requestedName.toLowerCase();\n\n await updateProjectSourceMetadata({\n workspaceId: input.workspaceId,\n projectId: target.projectId,\n sourceConnectionId: source.connection.id,\n sourceExternalRepositoryId: source.repository.externalRepositoryId,\n sourceRepositoryOwner: source.repository.owner,\n sourceRepositoryName: source.repository.name,\n sourceDefaultBranch: source.repository.defaultBranch,\n });\n\n if (!repositoryMatches) {\n throw createInterModuleKnownError(\n projectsInterModuleContract.methods.resolveCheckoutTarget,\n 'checkout-repository-not-authorized',\n {},\n );\n }\n\n return {\n ...target,\n connectionId: source.connection.id,\n externalRepositoryId: source.repository.externalRepositoryId,\n };\n }\n\n return target;\n },\n });\n}\n"],"names":["projectsInterModuleContract","createInterModuleKnownError","defineInterModulePresentation","getProjectById","getProjectBySource","getWorkspaceProjectCounts","resolveCheckoutTarget","updateProjectSourceMetadata","createProjectsInterModulePresentation","params","projectId","project","input","requireProjectForWorkspace","workspaceId","undefined","methods","workspaceIds","counts","target","source","integrations","resolveSourceRepository","connectionId","externalRepositoryId","catch","separator","repository","indexOf","requestedOwner","defaults","owner","slice","requestedName","repositoryMatches","toLowerCase","name","sourceConnectionId","connection","id","sourceExternalRepositoryId","sourceRepositoryOwner","sourceRepositoryName","sourceDefaultBranch","defaultBranch"],"mappings":"AACA,SAAQA,2BAA2B,QAAO,yCAAyC;AACnF,SACEC,2BAA2B,EAC3BC,6BAA6B,QAExB,wBAAwB;AAC/B,SACEC,cAAc,EACdC,kBAAkB,EAClBC,yBAAyB,EACzBC,qBAAqB,EACrBC,2BAA2B,QACtB,kBAAkB;AAEzB,OAAO,SAASC,sCAAsCC,MAErD;IACC,OAAOP,8BAA8BF,6BAA6B;QAChEG,gBAAgB,OAAO,EAACO,SAAS,EAAC,GAAM,CAAA;gBAACC,SAAS,AAAC,MAAMR,eAAeO,cAAe;YAAI,CAAA;QAC3FN,oBAAoB,OAAOQ,QAAW,CAAA;gBACpCD,SAAS,AAAC,MAAMP,mBAAmBQ,UAAW;YAChD,CAAA;QACAC,4BAA4B,OAAO,EAACH,SAAS,EAAEI,WAAW,EAAC;YACzD,MAAMH,UAAU,MAAMR,eAAeO;YACrC,IAAIC,YAAYI,WAAW;gBACzB,MAAMd,4BACJD,4BAA4BgB,OAAO,CAACH,0BAA0B,EAC9D,qBACA;oBAACH;gBAAS;YAEd;YACA,IAAIC,QAAQG,WAAW,KAAKA,aAAa;gBACvC,MAAMb,4BACJD,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C9BJ,WAAWS,OAAOT,SAAS;oBAC3B2B,oBAAoBjB,OAAOkB,UAAU,CAACC,EAAE;oBACxCC,4BAA4BpB,OAAOO,UAAU,CAACH,oBAAoB;oBAClEiB,uBAAuBrB,OAAOO,UAAU,CAACI,KAAK;oBAC9CW,sBAAsBtB,OAAOO,UAAU,CAACS,IAAI;oBAC5CO,qBAAqBvB,OAAOO,UAAU,CAACiB,aAAa;gBACtD;gBAEA,IAAI,CAACV,mBAAmB;oBACtB,MAAMjC,4BACJD,4BAA4BgB,OAAO,CAACV,qBAAqB,EACzD,sCACA,CAAC;gBAEL;gBAEA,OAAO;oBACL,GAAGa,MAAM;oBACTI,cAAcH,OAAOkB,UAAU,CAACC,EAAE;oBAClCf,sBAAsBJ,OAAOO,UAAU,CAACH,oBAAoB;gBAC9D;YACF;YAEA,OAAOL;QACT;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/presentation/inter-module.ts"],"sourcesContent":["import type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport {projectsInterModuleContract} from '@shipfox/api-projects-dto/inter-module';\nimport {\n createInterModuleKnownError,\n defineInterModulePresentation,\n type InterModulePresentation,\n} from '@shipfox/inter-module';\nimport {\n getProjectById,\n getProjectBySource,\n getWorkspaceProjectCounts,\n listProjects,\n resolveCheckoutTarget,\n updateProjectSourceMetadata,\n} from '#db/projects.js';\n\nexport function createProjectsInterModulePresentation(params: {\n integrations: Pick<IntegrationsModuleClient, 'resolveSourceRepository'>;\n}): InterModulePresentation<typeof projectsInterModuleContract> {\n return defineInterModulePresentation(projectsInterModuleContract, {\n getProjectById: async ({projectId}) => ({project: (await getProjectById(projectId)) ?? null}),\n getProjectBySource: async (input) => ({\n project: (await getProjectBySource(input)) ?? null,\n }),\n listProjectsByWorkspace: async ({workspaceId, limit, cursor}) => {\n const result = await listProjects({\n workspaceId,\n limit,\n ...(cursor ? {cursor: {createdAt: new Date(cursor.createdAt), id: cursor.id}} : {}),\n });\n return {\n projects: result.projects,\n nextCursor: result.nextCursor\n ? {createdAt: result.nextCursor.createdAt.toISOString(), id: result.nextCursor.id}\n : null,\n };\n },\n requireProjectForWorkspace: async ({projectId, workspaceId}) => {\n const project = await getProjectById(projectId);\n if (project === undefined) {\n throw createInterModuleKnownError(\n projectsInterModuleContract.methods.requireProjectForWorkspace,\n 'project-not-found',\n {projectId},\n );\n }\n if (project.workspaceId !== workspaceId) {\n throw createInterModuleKnownError(\n projectsInterModuleContract.methods.requireProjectForWorkspace,\n 'project-workspace-mismatch',\n {projectId, workspaceId},\n );\n }\n return {project};\n },\n getWorkspaceProjectCounts: async ({workspaceIds}) => ({\n counts: await getWorkspaceProjectCounts({workspaceIds}),\n }),\n resolveCheckoutTarget: async (input) => {\n const target = await resolveCheckoutTarget(input);\n if (target === undefined) {\n throw createInterModuleKnownError(\n projectsInterModuleContract.methods.resolveCheckoutTarget,\n 'checkout-repository-not-authorized',\n {},\n );\n }\n\n if ('repository' in input.target) {\n const source = await params.integrations\n .resolveSourceRepository({\n workspaceId: input.workspaceId,\n connectionId: target.connectionId,\n externalRepositoryId: target.externalRepositoryId,\n })\n .catch(() => undefined);\n if (source === undefined) {\n throw createInterModuleKnownError(\n projectsInterModuleContract.methods.resolveCheckoutTarget,\n 'checkout-repository-not-authorized',\n {},\n );\n }\n\n const separator = input.target.repository.indexOf('/');\n const requestedOwner =\n separator === -1 ? input.defaults.owner : input.target.repository.slice(0, separator);\n const requestedName =\n separator === -1 ? input.target.repository : input.target.repository.slice(separator + 1);\n const repositoryMatches =\n source.repository.owner.toLowerCase() === requestedOwner.toLowerCase() &&\n source.repository.name.toLowerCase() === requestedName.toLowerCase();\n\n await updateProjectSourceMetadata({\n workspaceId: input.workspaceId,\n projectId: target.projectId,\n sourceConnectionId: source.connection.id,\n sourceExternalRepositoryId: source.repository.externalRepositoryId,\n sourceRepositoryOwner: source.repository.owner,\n sourceRepositoryName: source.repository.name,\n sourceDefaultBranch: source.repository.defaultBranch,\n });\n\n if (!repositoryMatches) {\n throw createInterModuleKnownError(\n projectsInterModuleContract.methods.resolveCheckoutTarget,\n 'checkout-repository-not-authorized',\n {},\n );\n }\n\n return {\n ...target,\n connectionId: source.connection.id,\n externalRepositoryId: source.repository.externalRepositoryId,\n };\n }\n\n return target;\n },\n });\n}\n"],"names":["projectsInterModuleContract","createInterModuleKnownError","defineInterModulePresentation","getProjectById","getProjectBySource","getWorkspaceProjectCounts","listProjects","resolveCheckoutTarget","updateProjectSourceMetadata","createProjectsInterModulePresentation","params","projectId","project","input","listProjectsByWorkspace","workspaceId","limit","cursor","result","createdAt","Date","id","projects","nextCursor","toISOString","requireProjectForWorkspace","undefined","methods","workspaceIds","counts","target","source","integrations","resolveSourceRepository","connectionId","externalRepositoryId","catch","separator","repository","indexOf","requestedOwner","defaults","owner","slice","requestedName","repositoryMatches","toLowerCase","name","sourceConnectionId","connection","sourceExternalRepositoryId","sourceRepositoryOwner","sourceRepositoryName","sourceDefaultBranch","defaultBranch"],"mappings":"AACA,SAAQA,2BAA2B,QAAO,yCAAyC;AACnF,SACEC,2BAA2B,EAC3BC,6BAA6B,QAExB,wBAAwB;AAC/B,SACEC,cAAc,EACdC,kBAAkB,EAClBC,yBAAyB,EACzBC,YAAY,EACZC,qBAAqB,EACrBC,2BAA2B,QACtB,kBAAkB;AAEzB,OAAO,SAASC,sCAAsCC,MAErD;IACC,OAAOR,8BAA8BF,6BAA6B;QAChEG,gBAAgB,OAAO,EAACQ,SAAS,EAAC,GAAM,CAAA;gBAACC,SAAS,AAAC,MAAMT,eAAeQ,cAAe;YAAI,CAAA;QAC3FP,oBAAoB,OAAOS,QAAW,CAAA;gBACpCD,SAAS,AAAC,MAAMR,mBAAmBS,UAAW;YAChD,CAAA;QACAC,yBAAyB,OAAO,EAACC,WAAW,EAAEC,KAAK,EAAEC,MAAM,EAAC;YAC1D,MAAMC,SAAS,MAAMZ,aAAa;gBAChCS;gBACAC;gBACA,GAAIC,SAAS;oBAACA,QAAQ;wBAACE,WAAW,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