@zapier/zapier-sdk 0.42.0 → 0.43.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/CHANGELOG.md +12 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +309 -35
- package/dist/api/types.d.ts +29 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/constants.d.ts +25 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +32 -0
- package/dist/index.cjs +616 -197
- package/dist/index.d.mts +241 -408
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +611 -198
- package/dist/plugins/api/index.d.ts +5 -1
- package/dist/plugins/api/index.d.ts.map +1 -1
- package/dist/plugins/api/index.js +6 -3
- package/dist/plugins/apps/index.d.ts +2 -3
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/apps/index.js +1 -1
- package/dist/plugins/capabilities/index.d.ts +8 -6
- package/dist/plugins/capabilities/index.d.ts.map +1 -1
- package/dist/plugins/capabilities/index.js +3 -3
- package/dist/plugins/connections/index.d.ts +3 -1
- package/dist/plugins/connections/index.d.ts.map +1 -1
- package/dist/plugins/connections/index.js +2 -3
- package/dist/plugins/createClientCredentials/index.d.ts +6 -4
- package/dist/plugins/createClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/createClientCredentials/index.js +4 -3
- package/dist/plugins/createClientCredentials/schemas.d.ts +1 -0
- package/dist/plugins/createClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/createClientCredentials/schemas.js +6 -0
- package/dist/plugins/deleteClientCredentials/index.d.ts +6 -4
- package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.js +3 -3
- package/dist/plugins/deprecated/authentications.d.ts +9 -9
- package/dist/plugins/deprecated/authentications.d.ts.map +1 -1
- package/dist/plugins/deprecated/authentications.js +4 -4
- package/dist/plugins/eventEmission/index.d.ts +4 -5
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +8 -7
- package/dist/plugins/fetch/index.d.ts +6 -6
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +20 -6
- package/dist/plugins/findFirstConnection/index.d.ts +3 -4
- package/dist/plugins/findFirstConnection/index.d.ts.map +1 -1
- package/dist/plugins/findFirstConnection/index.js +2 -2
- package/dist/plugins/findUniqueConnection/index.d.ts +3 -4
- package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueConnection/index.js +2 -2
- package/dist/plugins/getAction/index.d.ts +7 -7
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +2 -2
- package/dist/plugins/getApp/index.d.ts +2 -3
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +2 -2
- package/dist/plugins/getConnection/index.d.ts +6 -6
- package/dist/plugins/getConnection/index.d.ts.map +1 -1
- package/dist/plugins/getConnection/index.js +3 -3
- package/dist/plugins/getInputFieldsSchema/index.d.ts +8 -6
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/getInputFieldsSchema/index.js +4 -4
- package/dist/plugins/getProfile/index.d.ts +6 -6
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +3 -3
- package/dist/plugins/listActions/index.d.ts +8 -6
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +3 -3
- package/dist/plugins/listApps/index.d.ts +3 -3
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +3 -3
- package/dist/plugins/listClientCredentials/index.d.ts +6 -4
- package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/listClientCredentials/index.js +3 -3
- package/dist/plugins/listConnections/index.d.ts +8 -6
- package/dist/plugins/listConnections/index.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.js +5 -5
- package/dist/plugins/listInputFieldChoices/index.d.ts +9 -8
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +4 -4
- package/dist/plugins/listInputFields/index.d.ts +8 -8
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +4 -4
- package/dist/plugins/manifest/index.d.ts +8 -3
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +2 -3
- package/dist/plugins/registry/index.d.ts +1 -2
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +3 -3
- package/dist/plugins/request/index.d.ts +3 -4
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +2 -2
- package/dist/plugins/runAction/index.d.ts +8 -8
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +17 -6
- package/dist/plugins/tables/createTable/index.d.ts +3 -5
- package/dist/plugins/tables/createTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTable/index.js +3 -3
- package/dist/plugins/tables/createTableFields/index.d.ts +3 -5
- package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableFields/index.js +3 -3
- package/dist/plugins/tables/createTableRecords/index.d.ts +3 -5
- package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableRecords/index.js +3 -3
- package/dist/plugins/tables/deleteTable/index.d.ts +5 -5
- package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.js +4 -4
- package/dist/plugins/tables/deleteTableFields/index.d.ts +3 -5
- package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableFields/index.js +3 -3
- package/dist/plugins/tables/deleteTableRecords/index.d.ts +3 -5
- package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableRecords/index.js +3 -3
- package/dist/plugins/tables/getTable/index.d.ts +3 -5
- package/dist/plugins/tables/getTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTable/index.js +3 -3
- package/dist/plugins/tables/getTableRecord/index.d.ts +3 -5
- package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTableRecord/index.js +3 -3
- package/dist/plugins/tables/listTableFields/index.d.ts +3 -5
- package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableFields/index.js +3 -3
- package/dist/plugins/tables/listTableRecords/index.d.ts +3 -3
- package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableRecords/index.js +3 -3
- package/dist/plugins/tables/listTables/index.d.ts +5 -3
- package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/index.js +4 -4
- package/dist/plugins/tables/updateTableRecords/index.d.ts +3 -5
- package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/updateTableRecords/index.js +3 -3
- package/dist/resolvers/connectionId.js +1 -1
- package/dist/resolvers/tableId.js +1 -1
- package/dist/sdk.d.ts +29 -257
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +33 -43
- package/dist/types/errors.d.ts +37 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +18 -0
- package/dist/types/plugin.d.ts +29 -48
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/plugin.js +7 -3
- package/dist/types/sdk.d.ts +9 -3
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/sdk.js +20 -0
- package/dist/utils/open-approval.d.ts +2 -0
- package/dist/utils/open-approval.d.ts.map +1 -0
- package/dist/utils/open-approval.js +13 -0
- package/dist/utils/open-url.d.ts +3 -0
- package/dist/utils/open-url.d.ts.map +1 -0
- package/dist/utils/open-url.js +72 -0
- package/package.json +3 -1
|
@@ -10,5 +10,9 @@ export interface ApiPluginProvides {
|
|
|
10
10
|
resolveCredentials: () => Promise<ResolvedCredentials | undefined>;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
export declare const apiPlugin: Plugin<{
|
|
13
|
+
export declare const apiPlugin: Plugin<{
|
|
14
|
+
context: {
|
|
15
|
+
options: BaseSdkOptions;
|
|
16
|
+
};
|
|
17
|
+
}, ApiPluginProvides>;
|
|
14
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAQnE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAG3D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE;QACP,GAAG,EAAE,SAAS,CAAC;QACf,kBAAkB,EAAE,MAAM,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;KACpE,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAQnE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAG3D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE;QACP,GAAG,EAAE,SAAS,CAAC;QACf,kBAAkB,EAAE,MAAM,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;KACpE,CAAC;CACH;AAED,eAAO,MAAM,SAAS,EAAE,MAAM,CAC5B;IAAE,OAAO,EAAE;QAAE,OAAO,EAAE,cAAc,CAAA;KAAE,CAAA;CAAE,EACxC,iBAAiB,CA8ClB,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { createZapierApi } from "../../api";
|
|
2
2
|
import { resolveCredentials } from "../../credentials";
|
|
3
3
|
import { ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, } from "../../constants";
|
|
4
|
-
|
|
5
|
-
export const apiPlugin = (params) => {
|
|
4
|
+
export const apiPlugin = (sdk) => {
|
|
6
5
|
// Extract all options - everything passed to the plugin
|
|
7
|
-
const { fetch: customFetch = globalThis.fetch, baseUrl = ZAPIER_BASE_URL, credentials, token, onEvent, debug = false, maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES, maxNetworkRetryDelayMs = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, } =
|
|
6
|
+
const { fetch: customFetch = globalThis.fetch, baseUrl = ZAPIER_BASE_URL, credentials, token, onEvent, debug = false, maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES, maxNetworkRetryDelayMs = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, isInteractive, approvalTimeoutMs, maxApprovalRetries, approvalMode, } = sdk.context.options;
|
|
8
7
|
// Create the API client - it will handle token resolution internally
|
|
9
8
|
const api = createZapierApi({
|
|
10
9
|
baseUrl,
|
|
@@ -15,6 +14,10 @@ export const apiPlugin = (params) => {
|
|
|
15
14
|
onEvent,
|
|
16
15
|
maxNetworkRetries,
|
|
17
16
|
maxNetworkRetryDelayMs,
|
|
17
|
+
isInteractive,
|
|
18
|
+
approvalTimeoutMs,
|
|
19
|
+
maxApprovalRetries,
|
|
20
|
+
approvalMode,
|
|
18
21
|
});
|
|
19
22
|
// Return flat structure with context only
|
|
20
23
|
return {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { ActionProxy } from "./schemas";
|
|
2
|
-
import type { Plugin
|
|
2
|
+
import type { Plugin } from "../../types/plugin";
|
|
3
3
|
import type { FetchPluginProvides } from "../fetch/index";
|
|
4
4
|
import type { RunActionPluginProvides } from "../runAction/index";
|
|
5
5
|
export interface AppsPluginProvides {
|
|
6
6
|
apps: ActionProxy;
|
|
7
7
|
}
|
|
8
|
-
export declare const appsPlugin: Plugin<
|
|
9
|
-
{}, // no context requirements
|
|
8
|
+
export declare const appsPlugin: Plugin<FetchPluginProvides & RunActionPluginProvides, // requires fetch + runAction in SDK, no context requirements
|
|
10
9
|
AppsPluginProvides>;
|
|
11
10
|
export type { ActionExecutionOptions, AppFactoryInput } from "./schemas";
|
|
12
11
|
export type { ActionExecutionResult } from "../../api/types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/apps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EAEZ,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/apps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EAEZ,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAGlE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,WAAW,CAAC;CACnB;AAuOD,eAAO,MAAM,UAAU,EAAE,MAAM,CAC7B,mBAAmB,GAAG,uBAAuB,EAAE,6DAA6D;AAC5G,kBAAkB,CAyBnB,CAAC;AAGF,YAAY,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACzE,YAAY,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAI7D,MAAM,WAAW,aAAa;CAAG"}
|
|
@@ -126,7 +126,7 @@ function createAppsProxy(options) {
|
|
|
126
126
|
return appsProxy;
|
|
127
127
|
}
|
|
128
128
|
// Direct plugin function - takes options + sdk + context in one object
|
|
129
|
-
export const appsPlugin = (
|
|
129
|
+
export const appsPlugin = (sdk) => {
|
|
130
130
|
// Return flat structure - apps goes directly to SDK
|
|
131
131
|
return {
|
|
132
132
|
apps: createAppsProxy({ sdk }),
|
|
@@ -10,13 +10,15 @@ export interface CapabilitiesContext {
|
|
|
10
10
|
export interface CapabilitiesPluginProvides {
|
|
11
11
|
context: CapabilitiesContext;
|
|
12
12
|
}
|
|
13
|
-
export declare const capabilitiesPlugin: Plugin<{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
export declare const capabilitiesPlugin: Plugin<{
|
|
14
|
+
context: {
|
|
15
|
+
options?: {
|
|
16
|
+
canIncludeSharedConnections?: boolean;
|
|
17
|
+
canIncludeSharedTables?: boolean;
|
|
18
|
+
canDeleteTables?: boolean;
|
|
19
|
+
};
|
|
20
|
+
getResolvedManifest: () => Promise<Manifest | null>;
|
|
18
21
|
};
|
|
19
|
-
getResolvedManifest: () => Promise<Manifest | null>;
|
|
20
22
|
}, CapabilitiesPluginProvides>;
|
|
21
23
|
export {};
|
|
22
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/capabilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE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,kBAAkB,EAAE,MAAM,CACrC;IACE,OAAO,EAAE;QACP,OAAO,CAAC,EAAE;YACR,2BAA2B,CAAC,EAAE,OAAO,CAAC;YACtC,sBAAsB,CAAC,EAAE,OAAO,CAAC;YACjC,eAAe,CAAC,EAAE,OAAO,CAAC;SAC3B,CAAC;QACF,mBAAmB,EAAE,MAAM,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;KACrD,CAAC;CACH,EACD,0BAA0B,CA8C3B,CAAC"}
|
|
@@ -36,8 +36,8 @@ function isEnabledByEnv(key) {
|
|
|
36
36
|
return false;
|
|
37
37
|
return undefined;
|
|
38
38
|
}
|
|
39
|
-
export const capabilitiesPlugin = (
|
|
40
|
-
const options = context.options ?? {};
|
|
39
|
+
export const capabilitiesPlugin = (sdk) => {
|
|
40
|
+
const options = sdk.context.options ?? {};
|
|
41
41
|
let cached;
|
|
42
42
|
/**
|
|
43
43
|
* Resolve each gated flag to true/false by checking (in priority order):
|
|
@@ -47,7 +47,7 @@ export const capabilitiesPlugin = ({ context }) => {
|
|
|
47
47
|
async function resolveFlags() {
|
|
48
48
|
if (cached)
|
|
49
49
|
return cached;
|
|
50
|
-
const manifest = await context.getResolvedManifest();
|
|
50
|
+
const manifest = await sdk.context.getResolvedManifest();
|
|
51
51
|
cached = {};
|
|
52
52
|
for (const flag of GATED_FLAGS) {
|
|
53
53
|
cached[flag] = Boolean(options[flag] ??
|
|
@@ -7,5 +7,7 @@ export interface ConnectionsPluginProvides {
|
|
|
7
7
|
getConnectionsMap: () => Promise<ConnectionsMap | null>;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
export declare const connectionsPlugin: Plugin<{
|
|
10
|
+
export declare const connectionsPlugin: Plugin<{
|
|
11
|
+
context: Pick<ManifestPluginProvides["context"], "getManifestConnections">;
|
|
12
|
+
}, ConnectionsPluginProvides>;
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/connections/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE;QACP,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;QAC1E,iBAAiB,EAAE,MAAM,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;KACzD,CAAC;CACH;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/connections/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE;QACP,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;QAC1E,iBAAiB,EAAE,MAAM,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;KACzD,CAAC;CACH;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC;IACE,OAAO,EAAE,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAAE,wBAAwB,CAAC,CAAC;CAC5E,EACD,yBAAyB,CAsB1B,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export const connectionsPlugin = (
|
|
2
|
-
const { context } = params;
|
|
1
|
+
export const connectionsPlugin = (sdk) => {
|
|
3
2
|
let cachedMap;
|
|
4
3
|
async function loadConnectionsMap() {
|
|
5
4
|
if (cachedMap === undefined) {
|
|
6
|
-
cachedMap = (await context.getManifestConnections()) ?? null;
|
|
5
|
+
cachedMap = (await sdk.context.getManifestConnections()) ?? null;
|
|
7
6
|
}
|
|
8
7
|
return cachedMap;
|
|
9
8
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Plugin } from "../../types/plugin";
|
|
2
2
|
import type { ApiClient } from "../../api";
|
|
3
3
|
import { CreateClientCredentialsSchema, type CreateClientCredentialsOptions, type CreateClientCredentialsResult } from "./schemas";
|
|
4
|
-
import type {
|
|
4
|
+
import type { EventEmissionProvides } from "../eventEmission";
|
|
5
5
|
export interface CreateClientCredentialsPluginProvides {
|
|
6
6
|
createClientCredentials: (options: CreateClientCredentialsOptions) => Promise<CreateClientCredentialsResult>;
|
|
7
7
|
context: {
|
|
@@ -12,7 +12,9 @@ export interface CreateClientCredentialsPluginProvides {
|
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
export declare const createClientCredentialsPlugin: Plugin<{
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
export declare const createClientCredentialsPlugin: Plugin<{
|
|
16
|
+
context: {
|
|
17
|
+
api: ApiClient;
|
|
18
|
+
};
|
|
19
|
+
} & EventEmissionProvides, CreateClientCredentialsPluginProvides>;
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/createClientCredentials/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,6BAA6B,EAC7B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EACnC,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/createClientCredentials/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,6BAA6B,EAC7B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EACnC,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAK9D,MAAM,WAAW,qCAAqC;IACpD,uBAAuB,EAAE,CACvB,OAAO,EAAE,8BAA8B,KACpC,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC5C,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,uBAAuB,EAAE;gBACvB,WAAW,EAAE,OAAO,6BAA6B,CAAC;aACnD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAChD;IACE,OAAO,EAAE;QACP,GAAG,EAAE,SAAS,CAAC;KAChB,CAAC;CACH,GAAG,qBAAqB,EACzB,qCAAqC,CAmEtC,CAAC"}
|
|
@@ -4,12 +4,13 @@ import { ClientCredentialsCreatedItemSchema } from "../../schemas/ClientCredenti
|
|
|
4
4
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
5
5
|
import { ZapierAuthenticationError } from "../../types/errors";
|
|
6
6
|
import { clientCredentialsNameResolver } from "../../resolvers";
|
|
7
|
-
export const createClientCredentialsPlugin = (
|
|
7
|
+
export const createClientCredentialsPlugin = (sdk) => {
|
|
8
8
|
async function createClientCredentials(options) {
|
|
9
|
-
const { api } = context;
|
|
9
|
+
const { api } = sdk.context;
|
|
10
10
|
const response = await api.post("/api/v0/client-credentials", {
|
|
11
11
|
name: options.name,
|
|
12
12
|
allowed_scopes: options.allowedScopes,
|
|
13
|
+
...(options.policy && { policy: options.policy }),
|
|
13
14
|
}, {
|
|
14
15
|
customErrorHandler: ({ status }) => {
|
|
15
16
|
if (status === 401) {
|
|
@@ -27,7 +28,7 @@ export const createClientCredentialsPlugin = ({ context }) => {
|
|
|
27
28
|
data: response.data,
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
|
-
const createClientCredentialsDefinition = createFunction(createClientCredentials, CreateClientCredentialsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, createClientCredentials.name));
|
|
31
|
+
const createClientCredentialsDefinition = createFunction(createClientCredentials, CreateClientCredentialsSchema, createTelemetryCallback(sdk.context.eventEmission.emitMethodCalled, createClientCredentials.name));
|
|
31
32
|
return {
|
|
32
33
|
createClientCredentials: createClientCredentialsDefinition,
|
|
33
34
|
context: {
|
|
@@ -8,6 +8,7 @@ export declare const CreateClientCredentialsSchema: z.ZodObject<{
|
|
|
8
8
|
external: "external";
|
|
9
9
|
credentials: "credentials";
|
|
10
10
|
}>>>;
|
|
11
|
+
policy: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
11
12
|
}, z.core.$strip>;
|
|
12
13
|
export type CreateClientCredentialsOptions = z.infer<typeof CreateClientCredentialsSchema> & FunctionOptions;
|
|
13
14
|
export interface CreateClientCredentialsResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/createClientCredentials/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uDAAuD,CAAC;AAE1G,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAC5B,eAAO,MAAM,6BAA6B
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/createClientCredentials/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uDAAuD,CAAC;AAE1G,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAC5B,eAAO,MAAM,6BAA6B;;;;;;;iBAc+B,CAAC;AAG1E,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAClD,OAAO,6BAA6B,CACrC,GACC,eAAe,CAAC;AAGlB,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,4BAA4B,CAAC;CACpC;AAGD,MAAM,MAAM,4BAA4B,GACpC,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,kCAAkC;IACjD,uBAAuB,EAAE,CACvB,OAAO,EAAE,8BAA8B,KACpC,OAAO,CAAC,6BAA6B,CAAC,CAAC;CAC7C"}
|
|
@@ -6,5 +6,11 @@ export const CreateClientCredentialsSchema = CreateClientCredentialsRequestSchem
|
|
|
6
6
|
.array(z.enum(["credentials", "external"]))
|
|
7
7
|
.default(["external"])
|
|
8
8
|
.describe("Scopes to allow for these credentials"),
|
|
9
|
+
// Temporarily hidden while we finalise work to make approvals/policies customer-facing.
|
|
10
|
+
policy: z
|
|
11
|
+
.record(z.string(), z.unknown())
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Policy document (JSON) to attach to the credentials")
|
|
14
|
+
.meta({ deprecated: true }),
|
|
9
15
|
})
|
|
10
16
|
.describe("Create new client credentials for the authenticated user");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Plugin } from "../../types/plugin";
|
|
2
2
|
import type { ApiClient } from "../../api";
|
|
3
3
|
import { DeleteClientCredentialsSchema, type DeleteClientCredentialsOptions, type DeleteClientCredentialsResult } from "./schemas";
|
|
4
|
-
import type {
|
|
4
|
+
import type { EventEmissionProvides } from "../eventEmission";
|
|
5
5
|
export interface DeleteClientCredentialsPluginProvides {
|
|
6
6
|
deleteClientCredentials: (options: DeleteClientCredentialsOptions) => Promise<DeleteClientCredentialsResult>;
|
|
7
7
|
context: {
|
|
@@ -12,7 +12,9 @@ export interface DeleteClientCredentialsPluginProvides {
|
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
export declare const deleteClientCredentialsPlugin: Plugin<{
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
export declare const deleteClientCredentialsPlugin: Plugin<{
|
|
16
|
+
context: {
|
|
17
|
+
api: ApiClient;
|
|
18
|
+
};
|
|
19
|
+
} & EventEmissionProvides, DeleteClientCredentialsPluginProvides>;
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/deleteClientCredentials/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,6BAA6B,EAC7B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EACnC,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/deleteClientCredentials/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,6BAA6B,EAC7B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EACnC,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAK9D,MAAM,WAAW,qCAAqC;IACpD,uBAAuB,EAAE,CACvB,OAAO,EAAE,8BAA8B,KACpC,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC5C,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,uBAAuB,EAAE;gBACvB,WAAW,EAAE,OAAO,6BAA6B,CAAC;aACnD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAChD;IACE,OAAO,EAAE;QACP,GAAG,EAAE,SAAS,CAAC;KAChB,CAAC;CACH,GAAG,qBAAqB,EACzB,qCAAqC,CA6DtC,CAAC"}
|
|
@@ -3,9 +3,9 @@ import { createFunction } from "../../utils/function-utils";
|
|
|
3
3
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
4
4
|
import { ZapierAuthenticationError } from "../../types/errors";
|
|
5
5
|
import { clientIdResolver } from "../../resolvers";
|
|
6
|
-
export const deleteClientCredentialsPlugin = (
|
|
6
|
+
export const deleteClientCredentialsPlugin = (sdk) => {
|
|
7
7
|
async function deleteClientCredentials(options) {
|
|
8
|
-
const { api } = context;
|
|
8
|
+
const { api } = sdk.context;
|
|
9
9
|
await api.delete(`/api/v0/client-credentials/${options.clientId}`, undefined, {
|
|
10
10
|
customErrorHandler: ({ status }) => {
|
|
11
11
|
if (status === 401) {
|
|
@@ -23,7 +23,7 @@ export const deleteClientCredentialsPlugin = ({ context }) => {
|
|
|
23
23
|
success: true,
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
const deleteClientCredentialsDefinition = createFunction(deleteClientCredentials, DeleteClientCredentialsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, deleteClientCredentials.name));
|
|
26
|
+
const deleteClientCredentialsDefinition = createFunction(deleteClientCredentials, DeleteClientCredentialsSchema, createTelemetryCallback(sdk.context.eventEmission.emitMethodCalled, deleteClientCredentials.name));
|
|
27
27
|
return {
|
|
28
28
|
deleteClientCredentials: deleteClientCredentialsDefinition,
|
|
29
29
|
context: {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - findFirstAuthentication -> findFirstConnection
|
|
12
12
|
* - findUniqueAuthentication -> findUniqueConnection
|
|
13
13
|
*/
|
|
14
|
-
import type { Plugin
|
|
14
|
+
import type { Plugin } from "../../types/plugin";
|
|
15
15
|
import type { ListConnectionsPluginProvides } from "../listConnections";
|
|
16
16
|
import type { GetConnectionPluginProvides } from "../getConnection";
|
|
17
17
|
import type { FindFirstConnectionPluginProvides } from "../findFirstConnection";
|
|
@@ -21,7 +21,7 @@ import { GetConnectionParamSchema } from "../getConnection/schemas";
|
|
|
21
21
|
import { FindFirstConnectionSchema } from "../findFirstConnection/schemas";
|
|
22
22
|
import { FindUniqueConnectionSchema } from "../findUniqueConnection/schemas";
|
|
23
23
|
export interface ListAuthenticationsPluginProvides {
|
|
24
|
-
listAuthentications:
|
|
24
|
+
listAuthentications: ListConnectionsPluginProvides["listConnections"];
|
|
25
25
|
context: {
|
|
26
26
|
meta: {
|
|
27
27
|
listAuthentications: {
|
|
@@ -31,7 +31,7 @@ export interface ListAuthenticationsPluginProvides {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
export interface GetAuthenticationPluginProvides {
|
|
34
|
-
getAuthentication:
|
|
34
|
+
getAuthentication: GetConnectionPluginProvides["getConnection"];
|
|
35
35
|
context: {
|
|
36
36
|
meta: {
|
|
37
37
|
getAuthentication: {
|
|
@@ -41,7 +41,7 @@ export interface GetAuthenticationPluginProvides {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
export interface FindFirstAuthenticationPluginProvides {
|
|
44
|
-
findFirstAuthentication:
|
|
44
|
+
findFirstAuthentication: FindFirstConnectionPluginProvides["findFirstConnection"];
|
|
45
45
|
context: {
|
|
46
46
|
meta: {
|
|
47
47
|
findFirstAuthentication: {
|
|
@@ -51,7 +51,7 @@ export interface FindFirstAuthenticationPluginProvides {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
export interface FindUniqueAuthenticationPluginProvides {
|
|
54
|
-
findUniqueAuthentication:
|
|
54
|
+
findUniqueAuthentication: FindUniqueConnectionPluginProvides["findUniqueConnection"];
|
|
55
55
|
context: {
|
|
56
56
|
meta: {
|
|
57
57
|
findUniqueAuthentication: {
|
|
@@ -63,17 +63,17 @@ export interface FindUniqueAuthenticationPluginProvides {
|
|
|
63
63
|
/**
|
|
64
64
|
* @deprecated Use listConnections instead
|
|
65
65
|
*/
|
|
66
|
-
export declare const listAuthenticationsPlugin: Plugin<
|
|
66
|
+
export declare const listAuthenticationsPlugin: Plugin<ListConnectionsPluginProvides, ListAuthenticationsPluginProvides>;
|
|
67
67
|
/**
|
|
68
68
|
* @deprecated Use getConnection instead
|
|
69
69
|
*/
|
|
70
|
-
export declare const getAuthenticationPlugin: Plugin<
|
|
70
|
+
export declare const getAuthenticationPlugin: Plugin<GetConnectionPluginProvides, GetAuthenticationPluginProvides>;
|
|
71
71
|
/**
|
|
72
72
|
* @deprecated Use findFirstConnection instead
|
|
73
73
|
*/
|
|
74
|
-
export declare const findFirstAuthenticationPlugin: Plugin<
|
|
74
|
+
export declare const findFirstAuthenticationPlugin: Plugin<FindFirstConnectionPluginProvides, FindFirstAuthenticationPluginProvides>;
|
|
75
75
|
/**
|
|
76
76
|
* @deprecated Use findUniqueConnection instead
|
|
77
77
|
*/
|
|
78
|
-
export declare const findUniqueAuthenticationPlugin: Plugin<
|
|
78
|
+
export declare const findUniqueAuthenticationPlugin: Plugin<FindUniqueConnectionPluginProvides, FindUniqueAuthenticationPluginProvides>;
|
|
79
79
|
//# sourceMappingURL=authentications.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentications.d.ts","sourceRoot":"","sources":["../../../src/plugins/deprecated/authentications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"authentications.d.ts","sourceRoot":"","sources":["../../../src/plugins/deprecated/authentications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAI7E,MAAM,WAAW,iCAAiC;IAChD,mBAAmB,EAAE,6BAA6B,CAAC,iBAAiB,CAAC,CAAC;IACtE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,mBAAmB,EAAE;gBACnB,WAAW,EAAE,OAAO,0BAA0B,CAAC;aAChD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,+BAA+B;IAC9C,iBAAiB,EAAE,2BAA2B,CAAC,eAAe,CAAC,CAAC;IAChE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,iBAAiB,EAAE;gBACjB,WAAW,EAAE,OAAO,wBAAwB,CAAC;aAC9C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,qCAAqC;IACpD,uBAAuB,EAAE,iCAAiC,CAAC,qBAAqB,CAAC,CAAC;IAClF,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,uBAAuB,EAAE;gBACvB,WAAW,EAAE,OAAO,yBAAyB,CAAC;aAC/C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,sCAAsC;IACrD,wBAAwB,EAAE,kCAAkC,CAAC,sBAAsB,CAAC,CAAC;IACrF,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,wBAAwB,EAAE;gBACxB,WAAW,EAAE,OAAO,0BAA0B,CAAC;aAChD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAC5C,6BAA6B,EAC7B,iCAAiC,CAejC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,2BAA2B,EAC3B,+BAA+B,CAe/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAChD,iCAAiC,EACjC,qCAAqC,CAerC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,MAAM,CACjD,kCAAkC,EAClC,sCAAsC,CAetC,CAAC"}
|
|
@@ -19,7 +19,7 @@ import { ConnectionItemSchema } from "../../schemas/Connection";
|
|
|
19
19
|
/**
|
|
20
20
|
* @deprecated Use listConnections instead
|
|
21
21
|
*/
|
|
22
|
-
export const listAuthenticationsPlugin = (
|
|
22
|
+
export const listAuthenticationsPlugin = (sdk) => ({
|
|
23
23
|
listAuthentications: sdk.listConnections,
|
|
24
24
|
context: {
|
|
25
25
|
meta: {
|
|
@@ -37,7 +37,7 @@ export const listAuthenticationsPlugin = ({ sdk }) => ({
|
|
|
37
37
|
/**
|
|
38
38
|
* @deprecated Use getConnection instead
|
|
39
39
|
*/
|
|
40
|
-
export const getAuthenticationPlugin = (
|
|
40
|
+
export const getAuthenticationPlugin = (sdk) => ({
|
|
41
41
|
getAuthentication: sdk.getConnection,
|
|
42
42
|
context: {
|
|
43
43
|
meta: {
|
|
@@ -55,7 +55,7 @@ export const getAuthenticationPlugin = ({ sdk }) => ({
|
|
|
55
55
|
/**
|
|
56
56
|
* @deprecated Use findFirstConnection instead
|
|
57
57
|
*/
|
|
58
|
-
export const findFirstAuthenticationPlugin = (
|
|
58
|
+
export const findFirstAuthenticationPlugin = (sdk) => ({
|
|
59
59
|
findFirstAuthentication: sdk.findFirstConnection,
|
|
60
60
|
context: {
|
|
61
61
|
meta: {
|
|
@@ -73,7 +73,7 @@ export const findFirstAuthenticationPlugin = ({ sdk }) => ({
|
|
|
73
73
|
/**
|
|
74
74
|
* @deprecated Use findUniqueConnection instead
|
|
75
75
|
*/
|
|
76
|
-
export const findUniqueAuthenticationPlugin = (
|
|
76
|
+
export const findUniqueAuthenticationPlugin = (sdk) => ({
|
|
77
77
|
findUniqueAuthentication: sdk.findUniqueConnection,
|
|
78
78
|
context: {
|
|
79
79
|
meta: {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* All events are emitted asynchronously and failures are silently handled.
|
|
6
6
|
*/
|
|
7
7
|
import type { Plugin } from "../../types/plugin";
|
|
8
|
+
import type { BaseSdkOptions } from "../../types/sdk";
|
|
8
9
|
import type { BaseEvent } from "../../types/telemetry-events";
|
|
9
10
|
import type { EventTransport, TransportConfig } from "./transport";
|
|
10
11
|
import type { MethodCalledEventData } from "./types";
|
|
@@ -32,11 +33,9 @@ export interface EventEmissionContext {
|
|
|
32
33
|
export interface EventEmissionProvides {
|
|
33
34
|
context: EventEmissionContext;
|
|
34
35
|
}
|
|
35
|
-
export declare const eventEmissionPlugin: Plugin<{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
trackingBaseUrl?: string;
|
|
39
|
-
baseUrl?: string;
|
|
36
|
+
export declare const eventEmissionPlugin: Plugin<{
|
|
37
|
+
context: {
|
|
38
|
+
options?: BaseSdkOptions;
|
|
40
39
|
};
|
|
41
40
|
}, EventEmissionProvides>;
|
|
42
41
|
export type { EventContext, ApplicationLifecycleEventData, EnhancedErrorEventData, MethodCalledEventData, } from "./types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAWnE,OAAO,KAAK,EAAgB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAyCnE;;;GAGG;AACH,wBAAgB,qBAAqB,SAEpC;AAGD,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,WAAW,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;CACrC;AAGD,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE;QACb,SAAS,EAAE,cAAc,CAAC;QAC1B,MAAM,EAAE,mBAAmB,CAAC;QAE5B,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;QAErD,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;QAEtC,gBAAgB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAAC;QAEpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;QAIvB,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACzC,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AAyFD,eAAO,MAAM,mBAAmB,EAAE,MAAM,CACtC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventE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YAAY,EACV,YAAY,EACZ,6BAA6B,EAC7B,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC1B,eAAe,EACf,eAAe,EACf,sBAAsB,GACvB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,cAAc,SAAS,CAAC"}
|
|
@@ -102,28 +102,29 @@ function getTransportConfig(options) {
|
|
|
102
102
|
endpoint,
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
export const eventEmissionPlugin = (
|
|
105
|
+
export const eventEmissionPlugin = (sdk) => {
|
|
106
|
+
const options = sdk.context.options ?? {};
|
|
106
107
|
const defaultTransport = getTransportConfig({
|
|
107
|
-
trackingBaseUrl:
|
|
108
|
-
baseUrl:
|
|
108
|
+
trackingBaseUrl: options.trackingBaseUrl,
|
|
109
|
+
baseUrl: options.baseUrl,
|
|
109
110
|
});
|
|
110
111
|
// Merge config: env var takes precedence over options, options take precedence over defaults
|
|
111
112
|
const config = {
|
|
112
|
-
enabled:
|
|
113
|
-
callContext:
|
|
113
|
+
enabled: options.eventEmission?.enabled ?? true,
|
|
114
|
+
callContext: options.eventEmission?.callContext,
|
|
114
115
|
transport:
|
|
115
116
|
// If env var is set, use it (defaultTransport will be from env)
|
|
116
117
|
globalThis.process?.env?.ZAPIER_SDK_TELEMETRY_TRANSPORT
|
|
117
118
|
? defaultTransport
|
|
118
119
|
: // Otherwise, use option transport or default
|
|
119
|
-
(
|
|
120
|
+
(options.eventEmission?.transport ?? defaultTransport),
|
|
120
121
|
};
|
|
121
122
|
// Create getUserContext promise for dynamic user context injection
|
|
122
123
|
const getUserContext = (async () => {
|
|
123
124
|
if (config.enabled) {
|
|
124
125
|
try {
|
|
125
126
|
const token = await resolveAuthToken({
|
|
126
|
-
...
|
|
127
|
+
...options,
|
|
127
128
|
});
|
|
128
129
|
if (token) {
|
|
129
130
|
return extractUserIdsFromJwt(token);
|
|
@@ -2,7 +2,7 @@ import type { Plugin } from "../../types/plugin";
|
|
|
2
2
|
import type { ApiClient } from "../../api";
|
|
3
3
|
import type { ConnectionsPluginProvides } from "../connections";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import type {
|
|
5
|
+
import type { EventEmissionProvides } from "../eventEmission";
|
|
6
6
|
export interface ZapierFetchInitOptions extends RequestInit {
|
|
7
7
|
/** @deprecated Use `connection` instead. */
|
|
8
8
|
connectionId?: string | number;
|
|
@@ -34,10 +34,10 @@ export interface FetchPluginProvides {
|
|
|
34
34
|
* Fetch plugin — the primary way to make authenticated HTTP requests through Zapier's Relay service.
|
|
35
35
|
* Mirrors the native fetch(url, init?) signature with additional Zapier-specific options.
|
|
36
36
|
*/
|
|
37
|
-
export declare const fetchPlugin: Plugin<{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} &
|
|
37
|
+
export declare const fetchPlugin: Plugin<{
|
|
38
|
+
context: {
|
|
39
|
+
api: ApiClient;
|
|
40
|
+
} & ConnectionsPluginProvides["context"];
|
|
41
|
+
} & EventEmissionProvides, // no SDK dependencies, requires api, connections, and eventEmission in context
|
|
42
42
|
FetchPluginProvides>;
|
|
43
43
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAMhE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/fetch/index.ts"],"names":[],"m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AAC,SAAS,CAAC,CAAC;CACpE,GAAG,qBAAqB,EAAE,+EAA+E;AAC1G,mBAAmB,CAiKpB,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { z } from "zod";
|
|
|
4
4
|
import { resolveConnectionId } from "../../utils/domain-utils";
|
|
5
5
|
import { combineAbortSignals, createTimeoutAbortSignal, } from "../../utils/abort-utils";
|
|
6
6
|
import { isPlainObject } from "../../utils/type-guard-utils";
|
|
7
|
+
import { buildHttpRequestContext } from "@zapier/policy-context";
|
|
7
8
|
// fetch() doesn't use createFunction/createPaginatedFunction (its signature
|
|
8
9
|
// doesn't fit the single-options-object pattern), so we wire up telemetry
|
|
9
10
|
// context tracking manually.
|
|
@@ -95,11 +96,11 @@ const validateFetchInit = createValidator(FetchInitSdkValidationSchema);
|
|
|
95
96
|
* Fetch plugin — the primary way to make authenticated HTTP requests through Zapier's Relay service.
|
|
96
97
|
* Mirrors the native fetch(url, init?) signature with additional Zapier-specific options.
|
|
97
98
|
*/
|
|
98
|
-
export const fetchPlugin = (
|
|
99
|
+
export const fetchPlugin = (sdk) => {
|
|
99
100
|
return {
|
|
100
101
|
fetch: async function fetch(url, init) {
|
|
101
102
|
return runWithTelemetryContext(async () => {
|
|
102
|
-
const { api } = context;
|
|
103
|
+
const { api } = sdk.context;
|
|
103
104
|
const startTime = Date.now();
|
|
104
105
|
const isNested = isTelemetryNested();
|
|
105
106
|
try {
|
|
@@ -111,7 +112,7 @@ export const fetchPlugin = ({ context }) => {
|
|
|
111
112
|
connectionId,
|
|
112
113
|
connection,
|
|
113
114
|
authenticationId,
|
|
114
|
-
resolveConnection: context.resolveConnection,
|
|
115
|
+
resolveConnection: sdk.context.resolveConnection,
|
|
115
116
|
label: "fetch",
|
|
116
117
|
});
|
|
117
118
|
const relayPath = transformUrlToRelayPath(url);
|
|
@@ -132,18 +133,31 @@ export const fetchPlugin = ({ context }) => {
|
|
|
132
133
|
if (maxTime !== undefined) {
|
|
133
134
|
headers["X-Zapier-Sdk-Max-Time"] = String(maxTime);
|
|
134
135
|
}
|
|
136
|
+
const upstreamUrl = new URL(url).toString();
|
|
137
|
+
const method = (fetchInit.method ?? "GET").toUpperCase();
|
|
135
138
|
const abortHandle = buildAbortHandle({
|
|
136
139
|
maxTimeSeconds: maxTime,
|
|
137
140
|
callerSignal: fetchInit.signal,
|
|
138
141
|
});
|
|
139
142
|
try {
|
|
140
143
|
const result = await api.fetch(relayPath, {
|
|
141
|
-
method
|
|
144
|
+
method,
|
|
142
145
|
body: fetchInit.body,
|
|
143
146
|
headers,
|
|
144
147
|
redirect: fetchInit.redirect,
|
|
145
148
|
signal: abortHandle?.signal,
|
|
146
149
|
authRequired: true,
|
|
150
|
+
approvalContext: () => buildHttpRequestContext({
|
|
151
|
+
method,
|
|
152
|
+
url: upstreamUrl,
|
|
153
|
+
headers,
|
|
154
|
+
body: typeof fetchInit.body === "string"
|
|
155
|
+
? fetchInit.body
|
|
156
|
+
: undefined,
|
|
157
|
+
connection_id: resolvedConnectionId
|
|
158
|
+
? String(resolvedConnectionId)
|
|
159
|
+
: undefined,
|
|
160
|
+
}),
|
|
147
161
|
});
|
|
148
162
|
const relayError = result.headers.get("x-relay-error");
|
|
149
163
|
if (relayError) {
|
|
@@ -152,7 +166,7 @@ export const fetchPlugin = ({ context }) => {
|
|
|
152
166
|
});
|
|
153
167
|
}
|
|
154
168
|
if (!isNested) {
|
|
155
|
-
context.eventEmission.emitMethodCalled({
|
|
169
|
+
sdk.context.eventEmission.emitMethodCalled({
|
|
156
170
|
method_name: "fetch",
|
|
157
171
|
execution_duration_ms: Date.now() - startTime,
|
|
158
172
|
success_flag: true,
|
|
@@ -177,7 +191,7 @@ export const fetchPlugin = ({ context }) => {
|
|
|
177
191
|
}
|
|
178
192
|
catch (error) {
|
|
179
193
|
if (!isNested) {
|
|
180
|
-
context.eventEmission.emitMethodCalled({
|
|
194
|
+
sdk.context.eventEmission.emitMethodCalled({
|
|
181
195
|
method_name: "fetch",
|
|
182
196
|
execution_duration_ms: Date.now() - startTime,
|
|
183
197
|
success_flag: false,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Plugin
|
|
1
|
+
import type { Plugin } from "../../types/plugin";
|
|
2
2
|
import type { ConnectionItem } from "../../types/domain";
|
|
3
3
|
import { FindFirstConnectionSchema, type FindFirstConnectionOptions } from "./schemas";
|
|
4
4
|
import type { ListConnectionsPluginProvides } from "../listConnections";
|
|
5
|
-
import type {
|
|
5
|
+
import type { EventEmissionProvides } from "../eventEmission";
|
|
6
6
|
export interface FindFirstConnectionPluginProvides {
|
|
7
7
|
findFirstConnection: (options?: FindFirstConnectionOptions) => Promise<{
|
|
8
8
|
data: ConnectionItem;
|
|
@@ -15,7 +15,6 @@ export interface FindFirstConnectionPluginProvides {
|
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
export declare const findFirstConnectionPlugin: Plugin<
|
|
19
|
-
EventEmissionContext, // requires eventEmission in context
|
|
18
|
+
export declare const findFirstConnectionPlugin: Plugin<ListConnectionsPluginProvides & EventEmissionProvides, // requires listConnections in SDK, eventEmission in context
|
|
20
19
|
FindFirstConnectionPluginProvides>;
|
|
21
20
|
//# sourceMappingURL=index.d.ts.map
|