@shipfox/api-integration-spi 1.1.0 → 2.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 +23 -0
- package/dist/contracts.d.ts +31 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +12 -2
- package/dist/contracts.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/contracts.test.ts +24 -0
- package/src/contracts.ts +38 -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 (320.95ms)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @shipfox/api-integration-spi
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 18e9bad: Adds source-control ref resolution that pins branch and tag names to commits.
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- 1b71a66: Exposes each provider's event catalog and the fixed-event providers on the integration validation context. Every provider now refuses the reserved `manual` and `cron` connection slugs.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [18e9bad]
|
|
16
|
+
- Updated dependencies [c44641f]
|
|
17
|
+
- Updated dependencies [1b71a66]
|
|
18
|
+
- @shipfox/api-integration-core-dto@14.0.0
|
|
19
|
+
|
|
20
|
+
## 1.1.1
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- f2b20af: Preserve GitHub provider rejection details and classify terminal agent-tool failures without reporting them as provider outages.
|
|
25
|
+
|
|
3
26
|
## 1.1.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
package/dist/contracts.d.ts
CHANGED
|
@@ -37,6 +37,13 @@ export interface ResolveRepositoryInput<Connection extends IntegrationConnection
|
|
|
37
37
|
connection: Connection;
|
|
38
38
|
externalRepositoryId: string;
|
|
39
39
|
}
|
|
40
|
+
export interface ResolveRefInput<Connection extends IntegrationConnection = IntegrationConnection> extends ResolveRepositoryInput<Connection> {
|
|
41
|
+
ref: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ResolvedRef {
|
|
44
|
+
ref: string;
|
|
45
|
+
commit: string;
|
|
46
|
+
}
|
|
40
47
|
export interface FileSnapshot {
|
|
41
48
|
path: string;
|
|
42
49
|
ref: string;
|
|
@@ -96,6 +103,11 @@ export interface SourceControlProvider<Connection extends IntegrationConnection
|
|
|
96
103
|
listFiles(input: ListFilesInput<Connection>): Promise<FilePage>;
|
|
97
104
|
fetchFile(input: FetchFileInput<Connection>): Promise<FileSnapshot>;
|
|
98
105
|
resolveTriggerReference(payload: unknown): TriggerReference | null;
|
|
106
|
+
/**
|
|
107
|
+
* Pins a branch or tag name to the commit it currently points at.
|
|
108
|
+
* The snapshot can become unreachable before a caller uses it.
|
|
109
|
+
*/
|
|
110
|
+
resolveRef(input: ResolveRefInput<Connection>): Promise<ResolvedRef>;
|
|
99
111
|
createCheckoutSpec?(input: CreateCheckoutSpecInput<Connection>): Promise<CheckoutSpec>;
|
|
100
112
|
}
|
|
101
113
|
export type AgentToolSensitivity = 'read' | 'write';
|
|
@@ -156,6 +168,13 @@ export interface WebhookRequestProcessor {
|
|
|
156
168
|
export interface IntegrationProvider<ProviderKind extends IntegrationProviderKind = IntegrationProviderKind, Route = unknown, Connection extends IntegrationConnection<ProviderKind> = IntegrationConnection<ProviderKind>> {
|
|
157
169
|
provider: ProviderKind;
|
|
158
170
|
displayName: string;
|
|
171
|
+
/**
|
|
172
|
+
* The event names this provider documents for its handler.
|
|
173
|
+
* Provider-minted names are never treated as a closed set by validation; the
|
|
174
|
+
* catalog is a curated diagnostic aid and may omit provider events. Providers
|
|
175
|
+
* without a documented catalog, including built-in trigger sources, omit it.
|
|
176
|
+
*/
|
|
177
|
+
eventCatalog?: import('@shipfox/api-integration-core-dto').IntegrationEventCatalog | undefined;
|
|
159
178
|
adapters?: IntegrationProviderAdapters<Connection> | undefined;
|
|
160
179
|
routes?: Route[] | undefined;
|
|
161
180
|
connectionExternalUrl?(connection: Connection): Promise<string | undefined>;
|
|
@@ -172,11 +191,12 @@ export interface RegisteredIntegrationProvider<ProviderKind extends IntegrationP
|
|
|
172
191
|
adapters: IntegrationProviderAdapters<Connection>;
|
|
173
192
|
capabilities: IntegrationCapability[];
|
|
174
193
|
}
|
|
175
|
-
export type IntegrationProviderErrorReason = 'repository-not-found' | 'installation-not-found' | 'file-not-found' | 'access-denied' | 'rate-limited' | 'timeout' | 'provider-unavailable' | 'malformed-provider-response' | 'content-too-large' | 'too-many-files';
|
|
194
|
+
export type IntegrationProviderErrorReason = 'repository-not-found' | 'installation-not-found' | 'file-not-found' | 'ref-not-found' | 'ref-invalid' | 'access-denied' | 'rate-limited' | 'timeout' | 'provider-unavailable' | 'provider-rejected' | 'malformed-provider-response' | 'content-too-large' | 'too-many-files';
|
|
176
195
|
export declare class IntegrationProviderError extends Error {
|
|
177
196
|
readonly reason: IntegrationProviderErrorReason;
|
|
178
197
|
readonly retryAfterSeconds?: number | undefined;
|
|
179
|
-
|
|
198
|
+
readonly status?: number | undefined;
|
|
199
|
+
constructor(reason: IntegrationProviderErrorReason, message: string, retryAfterSeconds?: number | undefined, status?: number | undefined);
|
|
180
200
|
}
|
|
181
201
|
export declare class ConnectionSlugConflictError extends Error {
|
|
182
202
|
constructor(cause: unknown);
|
|
@@ -192,5 +212,14 @@ export declare function nonEmptyString(value: unknown): string | null;
|
|
|
192
212
|
export declare function positiveInteger(value: unknown): number | null;
|
|
193
213
|
/** Validates a provider ref before it is passed to a git operation. */
|
|
194
214
|
export declare function isValidTriggerRef(ref: string): boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Validates a ref the platform may resolve to a commit: any safe git ref name
|
|
217
|
+
* except pull-request refs. Raw object ids do not satisfy the safe git ref
|
|
218
|
+
* name rules because valid refs must contain a slash. `refs/pull/N/head` can
|
|
219
|
+
* point at a fork and providers serve any commit in the repository network by
|
|
220
|
+
* SHA, so accepting names only keeps resolutions on refs a member pushed to
|
|
221
|
+
* the project repository.
|
|
222
|
+
*/
|
|
223
|
+
export declare function isValidResolvableRef(ref: string): boolean;
|
|
195
224
|
export declare function isValidGitObjectId(value: string): boolean;
|
|
196
225
|
//# 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;AAKnF,MAAM,WAAW,qBAAqB,CACpC,YAAY,SAAS,uBAAuB,GAAG,uBAAuB;IAEtE,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,YAAY,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,oCAAoC,CAAC;IACtD,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAEjF,MAAM,WAAW,kBAAkB;IACjC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,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AAG,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;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEzD"}
|
package/dist/contracts.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const GIT_OBJECT_ID_PATTERN = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i;
|
|
2
2
|
const ZERO_GIT_OBJECT_ID_PATTERN = /^0+$/;
|
|
3
3
|
export class IntegrationProviderError extends Error {
|
|
4
|
-
constructor(reason, message, retryAfterSeconds){
|
|
5
|
-
super(message), this.reason = reason, this.retryAfterSeconds = retryAfterSeconds;
|
|
4
|
+
constructor(reason, message, retryAfterSeconds, status){
|
|
5
|
+
super(message), this.reason = reason, this.retryAfterSeconds = retryAfterSeconds, this.status = status;
|
|
6
6
|
this.name = 'IntegrationProviderError';
|
|
7
7
|
}
|
|
8
8
|
}
|
|
@@ -64,6 +64,16 @@ export function positiveInteger(value) {
|
|
|
64
64
|
/** Validates a provider ref before it is passed to a git operation. */ export function isValidTriggerRef(ref) {
|
|
65
65
|
return isValidGitRefName(ref);
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Validates a ref the platform may resolve to a commit: any safe git ref name
|
|
69
|
+
* except pull-request refs. Raw object ids do not satisfy the safe git ref
|
|
70
|
+
* name rules because valid refs must contain a slash. `refs/pull/N/head` can
|
|
71
|
+
* point at a fork and providers serve any commit in the repository network by
|
|
72
|
+
* SHA, so accepting names only keeps resolutions on refs a member pushed to
|
|
73
|
+
* the project repository.
|
|
74
|
+
*/ export function isValidResolvableRef(ref) {
|
|
75
|
+
return isValidTriggerRef(ref) && !ref.startsWith('refs/pull/');
|
|
76
|
+
}
|
|
67
77
|
export function isValidGitObjectId(value) {
|
|
68
78
|
return GIT_OBJECT_ID_PATTERN.test(value) && !ZERO_GIT_OBJECT_ID_PATTERN.test(value);
|
|
69
79
|
}
|
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\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 /** Prepares provider-owned remote cleanup and returns a callback for after local deletion commits. */\n deleteConnectionRemoteResources?(\n connection: Connection,\n ): Promise<(() => Promise<void>) | undefined>;\n /** Serializes connection deletion with provider operations that can recreate remote resources. */\n withConnectionDeletionLock?(connection: Connection, fn: () => Promise<void>): Promise<void>;\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;AA8PnC,OAAO,MAAMC,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,qDAAq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B,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"}
|
|
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 ResolveRefInput<Connection extends IntegrationConnection = IntegrationConnection>\n extends ResolveRepositoryInput<Connection> {\n ref: string;\n}\n\nexport interface ResolvedRef {\n ref: string;\n commit: 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 /**\n * Pins a branch or tag name to the commit it currently points at.\n * The snapshot can become unreachable before a caller uses it.\n */\n resolveRef(input: ResolveRefInput<Connection>): Promise<ResolvedRef>;\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 /**\n * The event names this provider documents for its handler.\n * Provider-minted names are never treated as a closed set by validation; the\n * catalog is a curated diagnostic aid and may omit provider events. Providers\n * without a documented catalog, including built-in trigger sources, omit it.\n */\n eventCatalog?: import('@shipfox/api-integration-core-dto').IntegrationEventCatalog | undefined;\n adapters?: IntegrationProviderAdapters<Connection> | undefined;\n routes?: Route[] | undefined;\n connectionExternalUrl?(connection: Connection): Promise<string | undefined>;\n /** Prepares provider-owned remote cleanup and returns a callback for after local deletion commits. */\n deleteConnectionRemoteResources?(\n connection: Connection,\n ): Promise<(() => Promise<void>) | undefined>;\n /** Serializes connection deletion with provider operations that can recreate remote resources. */\n withConnectionDeletionLock?(connection: Connection, fn: () => Promise<void>): Promise<void>;\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 | 'ref-not-found'\n | 'ref-invalid'\n | 'access-denied'\n | 'rate-limited'\n | 'timeout'\n | 'provider-unavailable'\n | 'provider-rejected'\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 public readonly status?: 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\n/**\n * Validates a ref the platform may resolve to a commit: any safe git ref name\n * except pull-request refs. Raw object ids do not satisfy the safe git ref\n * name rules because valid refs must contain a slash. `refs/pull/N/head` can\n * point at a fork and providers serve any commit in the repository network by\n * SHA, so accepting names only keeps resolutions on refs a member pushed to\n * the project repository.\n */\nexport function isValidResolvableRef(ref: string): boolean {\n return isValidTriggerRef(ref) && !ref.startsWith('refs/pull/');\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","status","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","isValidResolvableRef","isValidGitObjectId","test"],"mappings":"AAIA,MAAMA,wBAAwB;AAC9B,MAAMC,6BAA6B;AAuRnC,OAAO,MAAMC,iCAAiCC;IAC5C,YACE,AAAgBC,MAAsC,EACtDC,OAAe,EACf,AAAgBC,iBAAsC,EACtD,AAAgBC,MAA2B,CAC3C;QACA,KAAK,CAACF,eALUD,SAAAA,aAEAE,oBAAAA,wBACAC,SAAAA;QAGhB,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMC,oCAAoCN;IAC/C,YAAYO,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,IAAIhB,yBACR,wBACA,CAAC,qDAAqD,EAAEc,sBAAsB;IAElF;IACA,MAAMI,SAASJ,qBAAqBK,KAAK,CAAC,GAAGH;IAC7C,MAAMJ,QAAQE,qBAAqBK,KAAK,CAACH,iBAAiB;IAC1D,IAAIE,WAAWH,kBAAkB;QAC/B,MAAM,IAAIf,yBACR,wBACA,CAAC,uBAAuB,EAAEc,qBAAqB,0BAA0B,EAAEC,kBAAkB;IAEjG;IACA,IAAI,CAACH,OAAO;QACV,MAAM,IAAIZ,yBACR,wBACA,CAAC,uBAAuB,EAAEc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