@shipfox/api-integration-spi 0.2.1 → 1.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 +1 -1
- package/CHANGELOG.md +34 -0
- package/dist/contracts.d.ts +17 -0
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +36 -0
- package/dist/contracts.js.map +1 -1
- package/dist/ports.d.ts +16 -1
- package/dist/ports.d.ts.map +1 -1
- package/dist/ports.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +14 -23
- package/src/contracts.test.ts +49 -0
- package/src/contracts.ts +67 -0
- package/src/ports.ts +15 -0
- package/tsconfig.build.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
$ shipfox-swc
|
|
2
|
-
Successfully compiled: 3 files with swc (
|
|
2
|
+
Successfully compiled: 3 files with swc (246.03ms)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @shipfox/api-integration-spi
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 54c820e: Capture the actor that caused a source-control event on the normalized trigger reference. `TriggerReference` gains a required `actor`, resolved from the webhook sender by the GitHub and Gitea providers and null for payloads that name none.
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- 24ef475: Adds provider-normalized repository, ref, and commit extraction for source-control trigger payloads.
|
|
12
|
+
- f13e8bb: Add Jira dynamic webhook registration and authenticated event ingestion through
|
|
13
|
+
the shared stored-webhook workflow. Update the SPI webhook request exports and
|
|
14
|
+
serialize Jira installation replacement across API replicas. Preserve Jira
|
|
15
|
+
delivery identifiers and require lifecycle callbacks for registration. Remove
|
|
16
|
+
the unused Jira webhook signing-secret configuration and allow HS256 verification
|
|
17
|
+
at a supplied receipt time.
|
|
18
|
+
- 869a792: Refresh source-backed project repository identity from GitHub repository and installation-repository events.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [f13e8bb]
|
|
23
|
+
- Updated dependencies [869a792]
|
|
24
|
+
- Updated dependencies [032d316]
|
|
25
|
+
- Updated dependencies [54c820e]
|
|
26
|
+
- Updated dependencies [cb0abfa]
|
|
27
|
+
- @shipfox/api-integration-core-dto@12.0.0
|
|
28
|
+
|
|
29
|
+
## 0.2.2
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- 4b85404: Adds versioned architecture identity to participating package artifacts during publication.
|
|
34
|
+
- Updated dependencies [4b85404]
|
|
35
|
+
- @shipfox/api-integration-core-dto@9.0.2
|
|
36
|
+
|
|
3
37
|
## 0.2.1
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/dist/contracts.d.ts
CHANGED
|
@@ -83,11 +83,19 @@ export interface CreateCheckoutSpecInput<Connection extends IntegrationConnectio
|
|
|
83
83
|
ref?: string | undefined;
|
|
84
84
|
permissions?: CheckoutPermissions | undefined;
|
|
85
85
|
}
|
|
86
|
+
export interface TriggerReference {
|
|
87
|
+
externalRepositoryId: string;
|
|
88
|
+
ref: string;
|
|
89
|
+
commit: string;
|
|
90
|
+
/** Provider handle of whoever caused the event, when the payload names one. */
|
|
91
|
+
actor: string | null;
|
|
92
|
+
}
|
|
86
93
|
export interface SourceControlProvider<Connection extends IntegrationConnection = IntegrationConnection> {
|
|
87
94
|
listRepositories(input: ListRepositoriesInput<Connection>): Promise<RepositoryPage>;
|
|
88
95
|
resolveRepository(input: ResolveRepositoryInput<Connection>): Promise<RepositorySnapshot>;
|
|
89
96
|
listFiles(input: ListFilesInput<Connection>): Promise<FilePage>;
|
|
90
97
|
fetchFile(input: FetchFileInput<Connection>): Promise<FileSnapshot>;
|
|
98
|
+
resolveTriggerReference(payload: unknown): TriggerReference | null;
|
|
91
99
|
createCheckoutSpec?(input: CreateCheckoutSpecInput<Connection>): Promise<CheckoutSpec>;
|
|
92
100
|
}
|
|
93
101
|
export type AgentToolSensitivity = 'read' | 'write';
|
|
@@ -172,4 +180,13 @@ export declare class ConnectionSlugConflictError extends Error {
|
|
|
172
180
|
export declare const MAX_REPOSITORY_FILE_BYTES = 1000000;
|
|
173
181
|
export declare function buildProviderRepositoryId(provider: IntegrationProviderKind, value: string): string;
|
|
174
182
|
export declare function parseProviderRepositoryId(externalRepositoryId: string, expectedProvider: IntegrationProviderKind): string;
|
|
183
|
+
/** Checks the constraints enforced by `git check-ref-format`. */
|
|
184
|
+
export declare function isValidGitRefName(ref: string): boolean;
|
|
185
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
186
|
+
export declare function asRecord(value: unknown): Record<string, unknown> | null;
|
|
187
|
+
export declare function nonEmptyString(value: unknown): string | null;
|
|
188
|
+
export declare function positiveInteger(value: unknown): number | null;
|
|
189
|
+
/** Validates a provider ref before it is passed to a git operation. */
|
|
190
|
+
export declare function isValidTriggerRef(ref: string): boolean;
|
|
191
|
+
export declare function isValidGitObjectId(value: string): boolean;
|
|
175
192
|
//# sourceMappingURL=contracts.d.ts.map
|
package/dist/contracts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAC7C,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,aAAa,CAAC;AACrE,MAAM,MAAM,oCAAoC,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAC7C,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,aAAa,C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C,EAAE,MAAM,GAAG,SAAS;CAKzD;AAED,qBAAa,2BAA4B,SAAQ,KAAK;gBACxC,KAAK,EAAE,OAAO;CAI3B;AAED,eAAO,MAAM,yBAAyB,UAAY,CAAC;AAEnD,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,uBAAuB,EACjC,KAAK,EAAE,MAAM,GACZ,MAAM,CAER;AAED,wBAAgB,yBAAyB,CACvC,oBAAoB,EAAE,MAAM,EAC5B,gBAAgB,EAAE,uBAAuB,GACxC,MAAM,CAuBR;AAED,iEAAiE;AACjE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CA2BtD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAEvE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAE5D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAE7D;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEzD"}
|
package/dist/contracts.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const GIT_OBJECT_ID_PATTERN = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i;
|
|
2
|
+
const ZERO_GIT_OBJECT_ID_PATTERN = /^0+$/;
|
|
1
3
|
export class IntegrationProviderError extends Error {
|
|
2
4
|
constructor(reason, message, retryAfterSeconds){
|
|
3
5
|
super(message), this.reason = reason, this.retryAfterSeconds = retryAfterSeconds;
|
|
@@ -31,5 +33,39 @@ export function parseProviderRepositoryId(externalRepositoryId, expectedProvider
|
|
|
31
33
|
}
|
|
32
34
|
return value;
|
|
33
35
|
}
|
|
36
|
+
/** Checks the constraints enforced by `git check-ref-format`. */ export function isValidGitRefName(ref) {
|
|
37
|
+
if (!ref || ref === '@' || ref.startsWith('-')) return false;
|
|
38
|
+
if (!ref.includes('/') || ref.startsWith('/') || ref.endsWith('/') || ref.includes('//') || ref.includes('..') || ref.includes('@{') || ref.endsWith('.')) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if ([
|
|
42
|
+
...ref
|
|
43
|
+
].some((character)=>{
|
|
44
|
+
const code = character.codePointAt(0) ?? 0;
|
|
45
|
+
return code <= 0x20 || code === 0x7f || '~^:?*[]\\'.includes(character);
|
|
46
|
+
})) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const components = ref.split('/');
|
|
50
|
+
return components.every((component)=>component.length > 0 && !component.startsWith('.') && !component.endsWith('.lock'));
|
|
51
|
+
}
|
|
52
|
+
export function isRecord(value) {
|
|
53
|
+
return typeof value === 'object' && value !== null;
|
|
54
|
+
}
|
|
55
|
+
export function asRecord(value) {
|
|
56
|
+
return isRecord(value) ? value : null;
|
|
57
|
+
}
|
|
58
|
+
export function nonEmptyString(value) {
|
|
59
|
+
return typeof value === 'string' && value.length > 0 ? value : null;
|
|
60
|
+
}
|
|
61
|
+
export function positiveInteger(value) {
|
|
62
|
+
return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : null;
|
|
63
|
+
}
|
|
64
|
+
/** Validates a provider ref before it is passed to a git operation. */ export function isValidTriggerRef(ref) {
|
|
65
|
+
return isValidGitRefName(ref);
|
|
66
|
+
}
|
|
67
|
+
export function isValidGitObjectId(value) {
|
|
68
|
+
return GIT_OBJECT_ID_PATTERN.test(value) && !ZERO_GIT_OBJECT_ID_PATTERN.test(value);
|
|
69
|
+
}
|
|
34
70
|
|
|
35
71
|
//# sourceMappingURL=contracts.js.map
|
package/dist/contracts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/contracts.ts"],"sourcesContent":["export type IntegrationProviderKind = string;\nexport type IntegrationCapability = 'source_control' | 'agent_tools';\nexport type IntegrationConnectionLifecycleStatus = 'active' | 'disabled' | 'error';\n\nexport interface IntegrationConnection<\n ProviderKind extends IntegrationProviderKind = IntegrationProviderKind,\n> {\n id: string;\n workspaceId: string;\n provider: ProviderKind;\n externalAccountId: string;\n slug: string;\n displayName: string;\n lifecycleStatus: IntegrationConnectionLifecycleStatus;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport type RepositoryVisibility = 'public' | 'private' | 'internal' | 'unknown';\n\nexport interface RepositorySnapshot {\n externalRepositoryId: string;\n owner: string;\n name: string;\n fullName: string;\n defaultBranch: string;\n visibility: RepositoryVisibility;\n cloneUrl: string;\n htmlUrl: string;\n}\n\nexport interface RepositoryPage {\n repositories: RepositorySnapshot[];\n nextCursor: string | null;\n}\n\nexport interface ListRepositoriesInput<\n Connection extends IntegrationConnection = IntegrationConnection,\n> {\n connection: Connection;\n limit: number;\n cursor?: string | undefined;\n search?: string | undefined;\n}\n\nexport interface ResolveRepositoryInput<\n Connection extends IntegrationConnection = IntegrationConnection,\n> {\n connection: Connection;\n externalRepositoryId: string;\n}\n\nexport interface FileSnapshot {\n path: string;\n ref: string;\n content: string;\n}\n\nexport interface FileEntry {\n path: string;\n type: 'file';\n size: number | null;\n}\n\nexport interface FilePage {\n files: FileEntry[];\n nextCursor: string | null;\n}\n\nexport interface ListFilesInput<Connection extends IntegrationConnection = IntegrationConnection>\n extends ResolveRepositoryInput<Connection> {\n ref: string;\n prefix: string;\n limit: number;\n cursor?: string | undefined;\n}\n\nexport interface FetchFileInput<Connection extends IntegrationConnection = IntegrationConnection>\n extends ResolveRepositoryInput<Connection> {\n ref: string;\n path: string;\n}\n\nexport interface CheckoutCredentials {\n username: string;\n token: string;\n expiresAt: Date;\n}\n\nexport interface CheckoutGitAuthor {\n name: string;\n email: string;\n}\n\nexport interface CheckoutPermissions {\n contents: 'read' | 'write';\n}\n\nexport interface CheckoutSpec {\n repositoryUrl: string;\n ref: string;\n credentials?: CheckoutCredentials | undefined;\n gitAuthor?: CheckoutGitAuthor | undefined;\n}\n\nexport interface CreateCheckoutSpecInput<\n Connection extends IntegrationConnection = IntegrationConnection,\n> extends ResolveRepositoryInput<Connection> {\n ref?: string | undefined;\n permissions?: CheckoutPermissions | undefined;\n}\n\nexport interface SourceControlProvider<\n Connection extends IntegrationConnection = IntegrationConnection,\n> {\n listRepositories(input: ListRepositoriesInput<Connection>): Promise<RepositoryPage>;\n resolveRepository(input: ResolveRepositoryInput<Connection>): Promise<RepositorySnapshot>;\n listFiles(input: ListFilesInput<Connection>): Promise<FilePage>;\n fetchFile(input: FetchFileInput<Connection>): Promise<FileSnapshot>;\n createCheckoutSpec?(input: CreateCheckoutSpecInput<Connection>): Promise<CheckoutSpec>;\n}\n\nexport type AgentToolSensitivity = 'read' | 'write';\nexport type AgentToolJsonSchema = Record<string, unknown>;\n\nexport interface AgentToolCatalogMethod<RequiredScope = unknown> {\n id: string;\n description: string;\n sensitivity: AgentToolSensitivity;\n sensitive: boolean;\n requiredScope: RequiredScope;\n}\n\nexport interface AgentToolCatalogEntry<RequiredScope = unknown> {\n id: string;\n description: string;\n sensitivity: AgentToolSensitivity;\n sensitive: boolean;\n requiredScope: RequiredScope;\n inputSchema: AgentToolJsonSchema;\n outputSchema?: AgentToolJsonSchema | undefined;\n methods?: readonly AgentToolCatalogMethod<RequiredScope>[] | undefined;\n}\n\nexport type AgentToolSelectorKind = 'family' | 'family_wildcard' | 'method' | 'standalone';\n\nexport interface AgentToolSelector {\n readonly token: string;\n readonly kind: AgentToolSelectorKind;\n readonly sensitivity: AgentToolSensitivity;\n readonly sensitive: boolean;\n}\n\nexport interface AgentToolSelectionCatalog {\n readonly selectors: readonly AgentToolSelector[];\n}\n\nexport interface AgentToolCallInput {\n toolId: string;\n arguments: Record<string, unknown>;\n}\n\nexport interface AgentToolSession<CallResult = unknown> {\n call(input: AgentToolCallInput): Promise<CallResult>;\n close?(): Promise<void>;\n}\n\nexport interface OpenAgentToolsSessionInput<\n Connection extends IntegrationConnection = IntegrationConnection,\n RequiredScope = unknown,\n ProviderScope = unknown,\n> {\n connection: Connection;\n tools: readonly AgentToolCatalogEntry<RequiredScope>[];\n scope: ProviderScope;\n}\n\nexport interface AgentToolsProvider<\n Connection extends IntegrationConnection = IntegrationConnection,\n RequiredScope = unknown,\n ProviderScope = unknown,\n CallResult = unknown,\n> {\n catalog():\n | readonly AgentToolCatalogEntry<RequiredScope>[]\n | Promise<readonly AgentToolCatalogEntry<RequiredScope>[]>;\n selectionCatalog(): AgentToolSelectionCatalog | Promise<AgentToolSelectionCatalog>;\n openSession(\n input: OpenAgentToolsSessionInput<Connection, RequiredScope, ProviderScope>,\n ): Promise<AgentToolSession<CallResult>>;\n}\n\nexport interface IntegrationProviderAdapters<\n Connection extends IntegrationConnection = IntegrationConnection,\n> {\n source_control?: SourceControlProvider<Connection> | undefined;\n agent_tools?: AgentToolsProvider<Connection> | undefined;\n}\n\n/** Processes one provider-neutral inbound webhook request. */\nexport interface WebhookRequestProcessor {\n process(\n request: import('@shipfox/api-integration-core-dto').StoredWebhookRequest,\n ): Promise<import('@shipfox/api-integration-core-dto').WebhookProcessingResult>;\n}\n\nexport interface IntegrationProvider<\n ProviderKind extends IntegrationProviderKind = IntegrationProviderKind,\n Route = unknown,\n Connection extends IntegrationConnection<ProviderKind> = IntegrationConnection<ProviderKind>,\n> {\n provider: ProviderKind;\n displayName: string;\n adapters?: IntegrationProviderAdapters<Connection> | undefined;\n routes?: Route[] | undefined;\n connectionExternalUrl?(connection: Connection): Promise<string | undefined>;\n deleteConnectionRecords?(connection: Connection, options: {tx: unknown}): Promise<void>;\n deleteConnectionSecrets?(connection: Connection): Promise<void>;\n}\n\nexport interface RegisteredIntegrationProvider<\n ProviderKind extends IntegrationProviderKind = IntegrationProviderKind,\n Route = unknown,\n Connection extends IntegrationConnection<ProviderKind> = IntegrationConnection<ProviderKind>,\n> extends IntegrationProvider<ProviderKind, Route, Connection> {\n adapters: IntegrationProviderAdapters<Connection>;\n capabilities: IntegrationCapability[];\n}\n\nexport type IntegrationProviderErrorReason =\n | 'repository-not-found'\n | 'installation-not-found'\n | 'file-not-found'\n | 'access-denied'\n | 'rate-limited'\n | 'timeout'\n | 'provider-unavailable'\n | 'malformed-provider-response'\n | 'content-too-large'\n | 'too-many-files';\n\nexport class IntegrationProviderError extends Error {\n constructor(\n public readonly reason: IntegrationProviderErrorReason,\n message: string,\n public readonly retryAfterSeconds?: number | undefined,\n ) {\n super(message);\n this.name = 'IntegrationProviderError';\n }\n}\n\nexport class ConnectionSlugConflictError extends Error {\n constructor(cause: unknown) {\n super('Could not allocate a unique integration connection slug. Try again.', {cause});\n this.name = 'ConnectionSlugConflictError';\n }\n}\n\nexport const MAX_REPOSITORY_FILE_BYTES = 1_000_000;\n\nexport function buildProviderRepositoryId(\n provider: IntegrationProviderKind,\n value: string,\n): string {\n return `${provider}:${value}`;\n}\n\nexport function parseProviderRepositoryId(\n externalRepositoryId: string,\n expectedProvider: IntegrationProviderKind,\n): string {\n const separatorIndex = externalRepositoryId.indexOf(':');\n if (separatorIndex <= 0) {\n throw new IntegrationProviderError(\n 'repository-not-found',\n `External repository id is missing a provider prefix: ${externalRepositoryId}`,\n );\n }\n const prefix = externalRepositoryId.slice(0, separatorIndex);\n const value = externalRepositoryId.slice(separatorIndex + 1);\n if (prefix !== expectedProvider) {\n throw new IntegrationProviderError(\n 'repository-not-found',\n `External repository id ${externalRepositoryId} is not owned by provider ${expectedProvider}`,\n );\n }\n if (!value) {\n throw new IntegrationProviderError(\n 'repository-not-found',\n `External repository id ${externalRepositoryId} is missing a provider-owned value`,\n );\n }\n return value;\n}\n"],"names":["IntegrationProviderError","Error","reason","message","retryAfterSeconds","name","ConnectionSlugConflictError","cause","MAX_REPOSITORY_FILE_BYTES","buildProviderRepositoryId","provider","value","parseProviderRepositoryId","externalRepositoryId","expectedProvider","separatorIndex","indexOf","prefix","slice"],"mappings":"AAiPA,OAAO,MAAMA,iCAAiCC;IAC5C,YACE,AAAgBC,MAAsC,EACtDC,OAAe,EACf,AAAgBC,iBAAsC,CACtD;QACA,KAAK,CAACD,eAJUD,SAAAA,aAEAE,oBAAAA;QAGhB,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMC,oCAAoCL;IAC/C,YAAYM,KAAc,CAAE;QAC1B,KAAK,CAAC,uEAAuE;YAACA;QAAK;QACnF,IAAI,CAACF,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMG,4BAA4B,UAAU;AAEnD,OAAO,SAASC,0BACdC,QAAiC,EACjCC,KAAa;IAEb,OAAO,GAAGD,SAAS,CAAC,EAAEC,OAAO;AAC/B;AAEA,OAAO,SAASC,0BACdC,oBAA4B,EAC5BC,gBAAyC;IAEzC,MAAMC,iBAAiBF,qBAAqBG,OAAO,CAAC;IACpD,IAAID,kBAAkB,GAAG;QACvB,MAAM,IAAIf,yBACR,wBACA,CAAC,qDAAqD,EAAEa,sBAAsB;IAElF;IACA,MAAMI,SAASJ,qBAAqBK,KAAK,CAAC,GAAGH;IAC7C,MAAMJ,QAAQE,qBAAqBK,KAAK,CAACH,iBAAiB;IAC1D,IAAIE,WAAWH,kBAAkB;QAC/B,MAAM,IAAId,yBACR,wBACA,CAAC,uBAAuB,EAAEa,qBAAqB,0BAA0B,EAAEC,kBAAkB;IAEjG;IACA,IAAI,CAACH,OAAO;QACV,MAAM,IAAIX,yBACR,wBACA,CAAC,uBAAuB,EAAEa,qBAAqB,kCAAkC,CAAC;IAEtF;IACA,OAAOF;AACT"}
|
|
1
|
+
{"version":3,"sources":["../src/contracts.ts"],"sourcesContent":["export type IntegrationProviderKind = string;\nexport type IntegrationCapability = 'source_control' | 'agent_tools';\nexport type IntegrationConnectionLifecycleStatus = 'active' | 'disabled' | 'error';\n\nconst GIT_OBJECT_ID_PATTERN = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i;\nconst ZERO_GIT_OBJECT_ID_PATTERN = /^0+$/;\n\nexport interface IntegrationConnection<\n ProviderKind extends IntegrationProviderKind = IntegrationProviderKind,\n> {\n id: string;\n workspaceId: string;\n provider: ProviderKind;\n externalAccountId: string;\n slug: string;\n displayName: string;\n lifecycleStatus: IntegrationConnectionLifecycleStatus;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport type RepositoryVisibility = 'public' | 'private' | 'internal' | 'unknown';\n\nexport interface RepositorySnapshot {\n externalRepositoryId: string;\n owner: string;\n name: string;\n fullName: string;\n defaultBranch: string;\n visibility: RepositoryVisibility;\n cloneUrl: string;\n htmlUrl: string;\n}\n\nexport interface RepositoryPage {\n repositories: RepositorySnapshot[];\n nextCursor: string | null;\n}\n\nexport interface ListRepositoriesInput<\n Connection extends IntegrationConnection = IntegrationConnection,\n> {\n connection: Connection;\n limit: number;\n cursor?: string | undefined;\n search?: string | undefined;\n}\n\nexport interface ResolveRepositoryInput<\n Connection extends IntegrationConnection = IntegrationConnection,\n> {\n connection: Connection;\n externalRepositoryId: string;\n}\n\nexport interface FileSnapshot {\n path: string;\n ref: string;\n content: string;\n}\n\nexport interface FileEntry {\n path: string;\n type: 'file';\n size: number | null;\n}\n\nexport interface FilePage {\n files: FileEntry[];\n nextCursor: string | null;\n}\n\nexport interface ListFilesInput<Connection extends IntegrationConnection = IntegrationConnection>\n extends ResolveRepositoryInput<Connection> {\n ref: string;\n prefix: string;\n limit: number;\n cursor?: string | undefined;\n}\n\nexport interface FetchFileInput<Connection extends IntegrationConnection = IntegrationConnection>\n extends ResolveRepositoryInput<Connection> {\n ref: string;\n path: string;\n}\n\nexport interface CheckoutCredentials {\n username: string;\n token: string;\n expiresAt: Date;\n}\n\nexport interface CheckoutGitAuthor {\n name: string;\n email: string;\n}\n\nexport interface CheckoutPermissions {\n contents: 'read' | 'write';\n}\n\nexport interface CheckoutSpec {\n repositoryUrl: string;\n ref: string;\n credentials?: CheckoutCredentials | undefined;\n gitAuthor?: CheckoutGitAuthor | undefined;\n}\n\nexport interface CreateCheckoutSpecInput<\n Connection extends IntegrationConnection = IntegrationConnection,\n> extends ResolveRepositoryInput<Connection> {\n ref?: string | undefined;\n permissions?: CheckoutPermissions | undefined;\n}\n\nexport interface TriggerReference {\n externalRepositoryId: string;\n ref: string;\n commit: string;\n /** Provider handle of whoever caused the event, when the payload names one. */\n actor: string | null;\n}\n\nexport interface SourceControlProvider<\n Connection extends IntegrationConnection = IntegrationConnection,\n> {\n listRepositories(input: ListRepositoriesInput<Connection>): Promise<RepositoryPage>;\n resolveRepository(input: ResolveRepositoryInput<Connection>): Promise<RepositorySnapshot>;\n listFiles(input: ListFilesInput<Connection>): Promise<FilePage>;\n fetchFile(input: FetchFileInput<Connection>): Promise<FileSnapshot>;\n resolveTriggerReference(payload: unknown): TriggerReference | null;\n createCheckoutSpec?(input: CreateCheckoutSpecInput<Connection>): Promise<CheckoutSpec>;\n}\n\nexport type AgentToolSensitivity = 'read' | 'write';\nexport type AgentToolJsonSchema = Record<string, unknown>;\n\nexport interface AgentToolCatalogMethod<RequiredScope = unknown> {\n id: string;\n description: string;\n sensitivity: AgentToolSensitivity;\n sensitive: boolean;\n requiredScope: RequiredScope;\n}\n\nexport interface AgentToolCatalogEntry<RequiredScope = unknown> {\n id: string;\n description: string;\n sensitivity: AgentToolSensitivity;\n sensitive: boolean;\n requiredScope: RequiredScope;\n inputSchema: AgentToolJsonSchema;\n outputSchema?: AgentToolJsonSchema | undefined;\n methods?: readonly AgentToolCatalogMethod<RequiredScope>[] | undefined;\n}\n\nexport type AgentToolSelectorKind = 'family' | 'family_wildcard' | 'method' | 'standalone';\n\nexport interface AgentToolSelector {\n readonly token: string;\n readonly kind: AgentToolSelectorKind;\n readonly sensitivity: AgentToolSensitivity;\n readonly sensitive: boolean;\n}\n\nexport interface AgentToolSelectionCatalog {\n readonly selectors: readonly AgentToolSelector[];\n}\n\nexport interface AgentToolCallInput {\n toolId: string;\n arguments: Record<string, unknown>;\n}\n\nexport interface AgentToolSession<CallResult = unknown> {\n call(input: AgentToolCallInput): Promise<CallResult>;\n close?(): Promise<void>;\n}\n\nexport interface OpenAgentToolsSessionInput<\n Connection extends IntegrationConnection = IntegrationConnection,\n RequiredScope = unknown,\n ProviderScope = unknown,\n> {\n connection: Connection;\n tools: readonly AgentToolCatalogEntry<RequiredScope>[];\n scope: ProviderScope;\n}\n\nexport interface AgentToolsProvider<\n Connection extends IntegrationConnection = IntegrationConnection,\n RequiredScope = unknown,\n ProviderScope = unknown,\n CallResult = unknown,\n> {\n catalog():\n | readonly AgentToolCatalogEntry<RequiredScope>[]\n | Promise<readonly AgentToolCatalogEntry<RequiredScope>[]>;\n selectionCatalog(): AgentToolSelectionCatalog | Promise<AgentToolSelectionCatalog>;\n openSession(\n input: OpenAgentToolsSessionInput<Connection, RequiredScope, ProviderScope>,\n ): Promise<AgentToolSession<CallResult>>;\n}\n\nexport interface IntegrationProviderAdapters<\n Connection extends IntegrationConnection = IntegrationConnection,\n> {\n source_control?: SourceControlProvider<Connection> | undefined;\n agent_tools?: AgentToolsProvider<Connection> | undefined;\n}\n\n/** Processes one provider-neutral inbound webhook request. */\nexport interface WebhookRequestProcessor {\n process(\n request: import('@shipfox/api-integration-core-dto').StoredWebhookRequest,\n ): Promise<import('@shipfox/api-integration-core-dto').WebhookProcessingResult>;\n}\n\nexport interface IntegrationProvider<\n ProviderKind extends IntegrationProviderKind = IntegrationProviderKind,\n Route = unknown,\n Connection extends IntegrationConnection<ProviderKind> = IntegrationConnection<ProviderKind>,\n> {\n provider: ProviderKind;\n displayName: string;\n adapters?: IntegrationProviderAdapters<Connection> | undefined;\n routes?: Route[] | undefined;\n connectionExternalUrl?(connection: Connection): Promise<string | undefined>;\n deleteConnectionRecords?(connection: Connection, options: {tx: unknown}): Promise<void>;\n deleteConnectionSecrets?(connection: Connection): Promise<void>;\n}\n\nexport interface RegisteredIntegrationProvider<\n ProviderKind extends IntegrationProviderKind = IntegrationProviderKind,\n Route = unknown,\n Connection extends IntegrationConnection<ProviderKind> = IntegrationConnection<ProviderKind>,\n> extends IntegrationProvider<ProviderKind, Route, Connection> {\n adapters: IntegrationProviderAdapters<Connection>;\n capabilities: IntegrationCapability[];\n}\n\nexport type IntegrationProviderErrorReason =\n | 'repository-not-found'\n | 'installation-not-found'\n | 'file-not-found'\n | 'access-denied'\n | 'rate-limited'\n | 'timeout'\n | 'provider-unavailable'\n | 'malformed-provider-response'\n | 'content-too-large'\n | 'too-many-files';\n\nexport class IntegrationProviderError extends Error {\n constructor(\n public readonly reason: IntegrationProviderErrorReason,\n message: string,\n public readonly retryAfterSeconds?: number | undefined,\n ) {\n super(message);\n this.name = 'IntegrationProviderError';\n }\n}\n\nexport class ConnectionSlugConflictError extends Error {\n constructor(cause: unknown) {\n super('Could not allocate a unique integration connection slug. Try again.', {cause});\n this.name = 'ConnectionSlugConflictError';\n }\n}\n\nexport const MAX_REPOSITORY_FILE_BYTES = 1_000_000;\n\nexport function buildProviderRepositoryId(\n provider: IntegrationProviderKind,\n value: string,\n): string {\n return `${provider}:${value}`;\n}\n\nexport function parseProviderRepositoryId(\n externalRepositoryId: string,\n expectedProvider: IntegrationProviderKind,\n): string {\n const separatorIndex = externalRepositoryId.indexOf(':');\n if (separatorIndex <= 0) {\n throw new IntegrationProviderError(\n 'repository-not-found',\n `External repository id is missing a provider prefix: ${externalRepositoryId}`,\n );\n }\n const prefix = externalRepositoryId.slice(0, separatorIndex);\n const value = externalRepositoryId.slice(separatorIndex + 1);\n if (prefix !== expectedProvider) {\n throw new IntegrationProviderError(\n 'repository-not-found',\n `External repository id ${externalRepositoryId} is not owned by provider ${expectedProvider}`,\n );\n }\n if (!value) {\n throw new IntegrationProviderError(\n 'repository-not-found',\n `External repository id ${externalRepositoryId} is missing a provider-owned value`,\n );\n }\n return value;\n}\n\n/** Checks the constraints enforced by `git check-ref-format`. */\nexport function isValidGitRefName(ref: string): boolean {\n if (!ref || ref === '@' || ref.startsWith('-')) return false;\n if (\n !ref.includes('/') ||\n ref.startsWith('/') ||\n ref.endsWith('/') ||\n ref.includes('//') ||\n ref.includes('..') ||\n ref.includes('@{') ||\n ref.endsWith('.')\n ) {\n return false;\n }\n if (\n [...ref].some((character) => {\n const code = character.codePointAt(0) ?? 0;\n return code <= 0x20 || code === 0x7f || '~^:?*[]\\\\'.includes(character);\n })\n ) {\n return false;\n }\n\n const components = ref.split('/');\n return components.every(\n (component) =>\n component.length > 0 && !component.startsWith('.') && !component.endsWith('.lock'),\n );\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nexport function asRecord(value: unknown): Record<string, unknown> | null {\n return isRecord(value) ? value : null;\n}\n\nexport function nonEmptyString(value: unknown): string | null {\n return typeof value === 'string' && value.length > 0 ? value : null;\n}\n\nexport function positiveInteger(value: unknown): number | null {\n return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : null;\n}\n\n/** Validates a provider ref before it is passed to a git operation. */\nexport function isValidTriggerRef(ref: string): boolean {\n return isValidGitRefName(ref);\n}\n\nexport function isValidGitObjectId(value: string): boolean {\n return GIT_OBJECT_ID_PATTERN.test(value) && !ZERO_GIT_OBJECT_ID_PATTERN.test(value);\n}\n"],"names":["GIT_OBJECT_ID_PATTERN","ZERO_GIT_OBJECT_ID_PATTERN","IntegrationProviderError","Error","reason","message","retryAfterSeconds","name","ConnectionSlugConflictError","cause","MAX_REPOSITORY_FILE_BYTES","buildProviderRepositoryId","provider","value","parseProviderRepositoryId","externalRepositoryId","expectedProvider","separatorIndex","indexOf","prefix","slice","isValidGitRefName","ref","startsWith","includes","endsWith","some","character","code","codePointAt","components","split","every","component","length","isRecord","asRecord","nonEmptyString","positiveInteger","Number","isInteger","isValidTriggerRef","isValidGitObjectId","test"],"mappings":"AAIA,MAAMA,wBAAwB;AAC9B,MAAMC,6BAA6B;AAwPnC,OAAO,MAAMC,iCAAiCC;I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IE,QAAQ,CAAC,SACbF,IAAIG,QAAQ,CAAC,MACb;QACA,OAAO;IACT;IACA,IACE;WAAIH;KAAI,CAACI,IAAI,CAAC,CAACC;QACb,MAAMC,OAAOD,UAAUE,WAAW,CAAC,MAAM;QACzC,OAAOD,QAAQ,QAAQA,SAAS,QAAQ,YAAYJ,QAAQ,CAACG;IAC/D,IACA;QACA,OAAO;IACT;IAEA,MAAMG,aAAaR,IAAIS,KAAK,CAAC;IAC7B,OAAOD,WAAWE,KAAK,CACrB,CAACC,YACCA,UAAUC,MAAM,GAAG,KAAK,CAACD,UAAUV,UAAU,CAAC,QAAQ,CAACU,UAAUR,QAAQ,CAAC;AAEhF;AAEA,OAAO,SAASU,SAAStB,KAAc;IACrC,OAAO,OAAOA,UAAU,YAAYA,UAAU;AAChD;AAEA,OAAO,SAASuB,SAASvB,KAAc;IACrC,OAAOsB,SAAStB,SAASA,QAAQ;AACnC;AAEA,OAAO,SAASwB,eAAexB,KAAc;IAC3C,OAAO,OAAOA,UAAU,YAAYA,MAAMqB,MAAM,GAAG,IAAIrB,QAAQ;AACjE;AAEA,OAAO,SAASyB,gBAAgBzB,KAAc;IAC5C,OAAO,OAAOA,UAAU,YAAY0B,OAAOC,SAAS,CAAC3B,UAAUA,QAAQ,IAAIA,QAAQ;AACrF;AAEA,qEAAqE,GACrE,OAAO,SAAS4B,kBAAkBnB,GAAW;IAC3C,OAAOD,kBAAkBC;AAC3B;AAEA,OAAO,SAASoB,mBAAmB7B,KAAa;IAC9C,OAAOb,sBAAsB2C,IAAI,CAAC9B,UAAU,CAACZ,2BAA2B0C,IAAI,CAAC9B;AAC/E"}
|
package/dist/ports.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IntegrationEventReceivedEvent, SourcePushPayload } from '@shipfox/api-integration-core-dto';
|
|
1
|
+
import type { IntegrationEventReceivedEvent, SourcePushPayload, SourceRepositoryIdentity } from '@shipfox/api-integration-core-dto';
|
|
2
2
|
import type { IntegrationConnection, IntegrationConnectionLifecycleStatus } from '#contracts.js';
|
|
3
3
|
export type IntegrationTx = any;
|
|
4
4
|
export type PublishIntegrationEventReceivedFn = (params: {
|
|
@@ -31,6 +31,21 @@ export type PublishSourcePushFn = (params: {
|
|
|
31
31
|
}) => Promise<{
|
|
32
32
|
published: boolean;
|
|
33
33
|
}>;
|
|
34
|
+
export type PublishSourceRepositoryUpdatedFn = (params: {
|
|
35
|
+
tx: IntegrationTx;
|
|
36
|
+
provider: string;
|
|
37
|
+
source: string;
|
|
38
|
+
workspaceId: string;
|
|
39
|
+
connectionId: string;
|
|
40
|
+
connectionName: string;
|
|
41
|
+
deliveryId: string;
|
|
42
|
+
receivedAt: string;
|
|
43
|
+
rawPayload: unknown;
|
|
44
|
+
event: string;
|
|
45
|
+
repositories: SourceRepositoryIdentity[];
|
|
46
|
+
}) => Promise<{
|
|
47
|
+
published: boolean;
|
|
48
|
+
}>;
|
|
34
49
|
export type RecordDeliveryOnlyFn = (params: {
|
|
35
50
|
tx: IntegrationTx;
|
|
36
51
|
provider: string;
|
package/dist/ports.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAC,qBAAqB,EAAE,oCAAoC,EAAC,MAAM,eAAe,CAAC;AAG/F,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC;AAEhC,MAAM,MAAM,iCAAiC,GAAG,CAAC,MAAM,EAAE;IACvD,EAAE,EAAE,aAAa,CAAC;IAClB,KAAK,EAAE,6BAA6B,CAAC;CACtC,KAA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from '@shipfox/api-integration-core-dto';\nimport type {IntegrationConnection, IntegrationConnectionLifecycleStatus} from '#contracts.js';\n\n// biome-ignore lint/suspicious/noExplicitAny: cross-package transaction handles stay opaque to provider packages\nexport type IntegrationTx = any;\n\nexport type PublishIntegrationEventReceivedFn = (params: {\n tx: IntegrationTx;\n event: IntegrationEventReceivedEvent;\n}) => Promise<{published: boolean}>;\n\nexport type CreateIntegrationConnectionFn = (\n params: {\n workspaceId: string;\n provider: string;\n externalAccountId: string;\n slug: string;\n displayName: string;\n lifecycleStatus?: IntegrationConnectionLifecycleStatus | undefined;\n },\n options?: {tx?: IntegrationTx},\n) => Promise<IntegrationConnection>;\n\nexport type PublishSourcePushFn = (params: {\n tx: IntegrationTx;\n provider: string;\n source: string;\n workspaceId: string;\n connectionId: string;\n connectionName: string;\n deliveryId: string;\n receivedAt: string;\n rawPayload: unknown;\n push: SourcePushPayload;\n}) => Promise<{published: boolean}>;\n\nexport type RecordDeliveryOnlyFn = (params: {\n tx: IntegrationTx;\n provider: string;\n deliveryId: string;\n}) => Promise<void>;\n\nexport type ClaimWebhookDeliveryFn = (params: {\n tx: IntegrationTx;\n provider: string;\n deliveryId: string;\n}) => Promise<{claimed: boolean}>;\n\nexport type GetIntegrationConnectionByIdFn = (\n id: string,\n options?: {tx?: IntegrationTx},\n) => Promise<IntegrationConnection | undefined>;\n\nexport type UpdateIntegrationConnectionLifecycleStatusFn = (\n params: {id: string; lifecycleStatus: IntegrationConnectionLifecycleStatus},\n options?: {tx?: IntegrationTx},\n) => Promise<IntegrationConnection | undefined>;\n\nexport type DeleteIntegrationConnectionFn = (\n params: {id: string},\n options?: {tx?: IntegrationTx},\n) => Promise<boolean>;\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/ports.ts"],"sourcesContent":["import type {\n IntegrationEventReceivedEvent,\n SourcePushPayload,\n SourceRepositoryIdentity,\n} from '@shipfox/api-integration-core-dto';\nimport type {IntegrationConnection, IntegrationConnectionLifecycleStatus} from '#contracts.js';\n\n// biome-ignore lint/suspicious/noExplicitAny: cross-package transaction handles stay opaque to provider packages\nexport type IntegrationTx = any;\n\nexport type PublishIntegrationEventReceivedFn = (params: {\n tx: IntegrationTx;\n event: IntegrationEventReceivedEvent;\n}) => Promise<{published: boolean}>;\n\nexport type CreateIntegrationConnectionFn = (\n params: {\n workspaceId: string;\n provider: string;\n externalAccountId: string;\n slug: string;\n displayName: string;\n lifecycleStatus?: IntegrationConnectionLifecycleStatus | undefined;\n },\n options?: {tx?: IntegrationTx},\n) => Promise<IntegrationConnection>;\n\nexport type PublishSourcePushFn = (params: {\n tx: IntegrationTx;\n provider: string;\n source: string;\n workspaceId: string;\n connectionId: string;\n connectionName: string;\n deliveryId: string;\n receivedAt: string;\n rawPayload: unknown;\n push: SourcePushPayload;\n}) => Promise<{published: boolean}>;\n\nexport type PublishSourceRepositoryUpdatedFn = (params: {\n tx: IntegrationTx;\n provider: string;\n source: string;\n workspaceId: string;\n connectionId: string;\n connectionName: string;\n deliveryId: string;\n receivedAt: string;\n rawPayload: unknown;\n event: string;\n repositories: SourceRepositoryIdentity[];\n}) => Promise<{published: boolean}>;\n\nexport type RecordDeliveryOnlyFn = (params: {\n tx: IntegrationTx;\n provider: string;\n deliveryId: string;\n}) => Promise<void>;\n\nexport type ClaimWebhookDeliveryFn = (params: {\n tx: IntegrationTx;\n provider: string;\n deliveryId: string;\n}) => Promise<{claimed: boolean}>;\n\nexport type GetIntegrationConnectionByIdFn = (\n id: string,\n options?: {tx?: IntegrationTx},\n) => Promise<IntegrationConnection | undefined>;\n\nexport type UpdateIntegrationConnectionLifecycleStatusFn = (\n params: {id: string; lifecycleStatus: IntegrationConnectionLifecycleStatus},\n options?: {tx?: IntegrationTx},\n) => Promise<IntegrationConnection | undefined>;\n\nexport type DeleteIntegrationConnectionFn = (\n params: {id: string},\n options?: {tx?: IntegrationTx},\n) => Promise<boolean>;\n"],"names":[],"mappings":"AA4EA,WAGsB"}
|