@relayfile/sdk 0.7.8 → 0.7.9

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/dist/setup.d.ts CHANGED
@@ -74,6 +74,34 @@ export declare class WorkspaceHandle {
74
74
  waitForNotion(options?: WaitForConnectionOptions): Promise<void>;
75
75
  isConnected(provider: WorkspaceIntegrationProvider, connectionId: string): Promise<boolean>;
76
76
  disconnectIntegration(provider: WorkspaceIntegrationProvider, _connectionId?: string): Promise<void>;
77
+ /**
78
+ * Bind an existing Nango connection to this workspace + provider slot
79
+ * without going through the OAuth re-mint flow. Use this when an operator
80
+ * has already minted the connection out-of-band (Nango UI, third-party
81
+ * setup) and just wants Cloud to start routing sync webhooks for it.
82
+ *
83
+ * The Cloud-side adopt route validates that the Nango connection exists
84
+ * upstream and that its end-user/workspace tag matches this workspace.
85
+ * On success returns the bound `connectionId` and, when a stale prior
86
+ * row was atomically replaced, a `replacedConnectionId` so callers can
87
+ * surface that a migration happened.
88
+ *
89
+ * Failure modes (HTTP body carries `code`):
90
+ * - `connection_not_found` (404): Nango doesn't know this connectionId
91
+ * - `workspace_mismatch` (409): connection belongs to a different
92
+ * workspace; the body includes `pathWorkspaceId` and
93
+ * `connectionWorkspaceId`
94
+ * - `existing_connection_live_or_unknown` (409): a different
95
+ * connection is already bound here and is either still live
96
+ * upstream or has indeterminate state; operator must disconnect
97
+ * first
98
+ */
99
+ adoptIntegration(provider: WorkspaceIntegrationProvider, connectionId: string, options?: {
100
+ providerConfigKey?: string;
101
+ }): Promise<{
102
+ connectionId: string;
103
+ replacedConnectionId?: string;
104
+ }>;
77
105
  getToken(): string;
78
106
  requestJson(options: Omit<CloudRequestOptions, "tokenProvider">): Promise<unknown>;
79
107
  mountEnv(options?: WorkspaceMountEnvOptions): WorkspaceMountEnv;
package/dist/setup.js CHANGED
@@ -388,6 +388,58 @@ export class WorkspaceHandle {
388
388
  });
389
389
  this._pendingConnections.delete(provider);
390
390
  }
391
+ /**
392
+ * Bind an existing Nango connection to this workspace + provider slot
393
+ * without going through the OAuth re-mint flow. Use this when an operator
394
+ * has already minted the connection out-of-band (Nango UI, third-party
395
+ * setup) and just wants Cloud to start routing sync webhooks for it.
396
+ *
397
+ * The Cloud-side adopt route validates that the Nango connection exists
398
+ * upstream and that its end-user/workspace tag matches this workspace.
399
+ * On success returns the bound `connectionId` and, when a stale prior
400
+ * row was atomically replaced, a `replacedConnectionId` so callers can
401
+ * surface that a migration happened.
402
+ *
403
+ * Failure modes (HTTP body carries `code`):
404
+ * - `connection_not_found` (404): Nango doesn't know this connectionId
405
+ * - `workspace_mismatch` (409): connection belongs to a different
406
+ * workspace; the body includes `pathWorkspaceId` and
407
+ * `connectionWorkspaceId`
408
+ * - `existing_connection_live_or_unknown` (409): a different
409
+ * connection is already bound here and is either still live
410
+ * upstream or has indeterminate state; operator must disconnect
411
+ * first
412
+ */
413
+ async adoptIntegration(provider, connectionId, options = {}) {
414
+ assertProvider(provider);
415
+ const trimmedConnectionId = connectionId?.trim();
416
+ if (!trimmedConnectionId) {
417
+ throw new Error("connectionId is required to adopt an integration");
418
+ }
419
+ const body = { connectionId: trimmedConnectionId };
420
+ const providerConfigKey = options.providerConfigKey?.trim();
421
+ if (providerConfigKey) {
422
+ body.providerConfigKey = providerConfigKey;
423
+ }
424
+ const response = (await this._setup.requestJson({
425
+ operation: "adoptIntegration",
426
+ method: "POST",
427
+ path: `api/v1/workspaces/${encodeURIComponent(this.workspaceId)}/integrations/${encodeURIComponent(provider)}/adopt`,
428
+ body,
429
+ tokenProvider: async () => this.getOrRefreshToken()
430
+ }));
431
+ const boundConnectionId = typeof response.connectionId === "string" && response.connectionId.trim()
432
+ ? response.connectionId.trim()
433
+ : trimmedConnectionId;
434
+ const replacedConnectionId = typeof response.replacedConnectionId === "string" &&
435
+ response.replacedConnectionId.trim()
436
+ ? response.replacedConnectionId.trim()
437
+ : undefined;
438
+ this._pendingConnections.delete(provider);
439
+ return replacedConnectionId
440
+ ? { connectionId: boundConnectionId, replacedConnectionId }
441
+ : { connectionId: boundConnectionId };
442
+ }
391
443
  getToken() {
392
444
  return this._token;
393
445
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relayfile/sdk",
3
- "version": "0.7.8",
3
+ "version": "0.7.9",
4
4
  "description": "TypeScript SDK for relayfile — real-time filesystem for humans and agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "prepublishOnly": "npm run build"
23
23
  },
24
24
  "dependencies": {
25
- "@relayfile/core": "0.7.8"
25
+ "@relayfile/core": "0.7.9"
26
26
  },
27
27
  "devDependencies": {
28
28
  "typescript": "^5.7.3",