@zapier/zapier-sdk 0.41.2 → 0.42.1
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/README.md +1 -0
- package/dist/index.cjs +376 -219
- package/dist/index.d.mts +174 -424
- 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 +376 -220
- 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 +2 -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 +3 -3
- 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 +18 -23
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +88 -28
- package/dist/plugins/fetch/schemas.d.ts +8 -0
- package/dist/plugins/fetch/schemas.d.ts.map +1 -1
- package/dist/plugins/fetch/schemas.js +21 -12
- 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 +5 -5
- 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/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 +2 -3
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/abort-utils.d.ts +64 -0
- package/dist/utils/abort-utils.d.ts.map +1 -0
- package/dist/utils/abort-utils.js +107 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -517,7 +517,7 @@ function createAppsProxy(options) {
|
|
|
517
517
|
});
|
|
518
518
|
return appsProxy;
|
|
519
519
|
}
|
|
520
|
-
var appsPlugin = (
|
|
520
|
+
var appsPlugin = (sdk) => {
|
|
521
521
|
return {
|
|
522
522
|
apps: createAppsProxy({ sdk }),
|
|
523
523
|
context: {
|
|
@@ -544,6 +544,20 @@ var appsPlugin = ({ sdk }) => {
|
|
|
544
544
|
var FetchUrlSchema = zod.z.union([zod.z.string(), zod.z.instanceof(URL)]).describe(
|
|
545
545
|
"The full URL of the API endpoint to call (proxied through Zapier's Relay service)"
|
|
546
546
|
);
|
|
547
|
+
var FetchInitZapierFieldsSchema = zod.z.object({
|
|
548
|
+
connectionId: ConnectionIdPropertySchema.optional().meta({
|
|
549
|
+
deprecated: true
|
|
550
|
+
}),
|
|
551
|
+
connection: ConnectionPropertySchema.optional(),
|
|
552
|
+
/** @deprecated Use connection instead */
|
|
553
|
+
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
554
|
+
deprecated: true
|
|
555
|
+
}),
|
|
556
|
+
callbackUrl: zod.z.string().optional().describe("URL to send async response to (makes request async)"),
|
|
557
|
+
maxTime: zod.z.number().int().positive().optional().describe(
|
|
558
|
+
"Maximum seconds to wait for a response. Honored on a best-effort basis; the server may silently enforce a lower ceiling."
|
|
559
|
+
)
|
|
560
|
+
});
|
|
547
561
|
var FetchInitSchema = zod.z.object({
|
|
548
562
|
method: zod.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method for the request (defaults to GET)"),
|
|
549
563
|
headers: zod.z.record(zod.z.string(), zod.z.string()).optional().describe("HTTP headers to include in the request"),
|
|
@@ -554,17 +568,8 @@ var FetchInitSchema = zod.z.object({
|
|
|
554
568
|
zod.z.record(zod.z.string(), zod.z.unknown())
|
|
555
569
|
]).optional().describe(
|
|
556
570
|
"Request body \u2014 plain objects and JSON strings are auto-detected and Content-Type is set accordingly"
|
|
557
|
-
)
|
|
558
|
-
|
|
559
|
-
deprecated: true
|
|
560
|
-
}),
|
|
561
|
-
connection: ConnectionPropertySchema.optional(),
|
|
562
|
-
/** @deprecated Use connection instead */
|
|
563
|
-
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
564
|
-
deprecated: true
|
|
565
|
-
}),
|
|
566
|
-
callbackUrl: zod.z.string().optional().describe("URL to send async response to (makes request async)")
|
|
567
|
-
}).optional().describe(
|
|
571
|
+
)
|
|
572
|
+
}).extend(FetchInitZapierFieldsSchema.shape).optional().describe(
|
|
568
573
|
"Request options including method, headers, body, and authentication"
|
|
569
574
|
).meta({
|
|
570
575
|
aliases: { connectionId: "connection", authenticationId: "connection" }
|
|
@@ -717,6 +722,82 @@ function isResolvedAppLocator(appLocator) {
|
|
|
717
722
|
return !!appLocator.implementationName;
|
|
718
723
|
}
|
|
719
724
|
|
|
725
|
+
// src/utils/abort-utils.ts
|
|
726
|
+
function getAbortSignalApi() {
|
|
727
|
+
const api = AbortSignal;
|
|
728
|
+
return { any: api.any };
|
|
729
|
+
}
|
|
730
|
+
function createTimeoutError(timeoutMs) {
|
|
731
|
+
if (typeof DOMException !== "undefined") {
|
|
732
|
+
return new DOMException(
|
|
733
|
+
`The operation timed out after ${timeoutMs}ms`,
|
|
734
|
+
"TimeoutError"
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
const error = new Error(`The operation timed out after ${timeoutMs}ms`);
|
|
738
|
+
error.name = "TimeoutError";
|
|
739
|
+
return error;
|
|
740
|
+
}
|
|
741
|
+
function createTimeoutAbortSignal({
|
|
742
|
+
timeoutMs
|
|
743
|
+
}) {
|
|
744
|
+
const controller = new AbortController();
|
|
745
|
+
let timer = setTimeout(() => {
|
|
746
|
+
timer = void 0;
|
|
747
|
+
controller.abort(createTimeoutError(timeoutMs));
|
|
748
|
+
}, timeoutMs);
|
|
749
|
+
const maybeUnref = timer.unref;
|
|
750
|
+
if (typeof maybeUnref === "function") {
|
|
751
|
+
maybeUnref.call(timer);
|
|
752
|
+
}
|
|
753
|
+
return {
|
|
754
|
+
signal: controller.signal,
|
|
755
|
+
dispose: () => {
|
|
756
|
+
if (timer !== void 0) {
|
|
757
|
+
clearTimeout(timer);
|
|
758
|
+
timer = void 0;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
function combineAbortSignals({
|
|
764
|
+
handles,
|
|
765
|
+
abortSignalApi = getAbortSignalApi()
|
|
766
|
+
}) {
|
|
767
|
+
if (handles.length === 0) return void 0;
|
|
768
|
+
if (handles.length === 1) return handles[0];
|
|
769
|
+
const disposeInputs = () => {
|
|
770
|
+
for (const handle of handles) handle.dispose();
|
|
771
|
+
};
|
|
772
|
+
if (abortSignalApi.any) {
|
|
773
|
+
return {
|
|
774
|
+
signal: abortSignalApi.any(handles.map((h) => h.signal)),
|
|
775
|
+
dispose: disposeInputs
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
const controller = new AbortController();
|
|
779
|
+
const listeners = [];
|
|
780
|
+
for (const { signal: source } of handles) {
|
|
781
|
+
if (source.aborted) {
|
|
782
|
+
controller.abort(source.reason);
|
|
783
|
+
return { signal: controller.signal, dispose: disposeInputs };
|
|
784
|
+
}
|
|
785
|
+
const handler = () => controller.abort(source.reason);
|
|
786
|
+
source.addEventListener("abort", handler, { once: true });
|
|
787
|
+
listeners.push({ source, handler });
|
|
788
|
+
}
|
|
789
|
+
return {
|
|
790
|
+
signal: controller.signal,
|
|
791
|
+
dispose: () => {
|
|
792
|
+
for (const { source, handler } of listeners) {
|
|
793
|
+
source.removeEventListener("abort", handler);
|
|
794
|
+
}
|
|
795
|
+
listeners.length = 0;
|
|
796
|
+
disposeInputs();
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
|
|
720
801
|
// src/utils/type-guard-utils.ts
|
|
721
802
|
function isPlainObject(value) {
|
|
722
803
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -752,6 +833,34 @@ function getMethodMetadata() {
|
|
|
752
833
|
return telemetryStore.getStore()?.methodMetadata;
|
|
753
834
|
}
|
|
754
835
|
|
|
836
|
+
// src/utils/validation.ts
|
|
837
|
+
var validate = (schema, input) => {
|
|
838
|
+
const result = schema.safeParse(input);
|
|
839
|
+
if (!result.success) {
|
|
840
|
+
const errorMessages = result.error.issues.map((error) => {
|
|
841
|
+
const path = error.path.length > 0 ? error.path.join(".") : "input";
|
|
842
|
+
return `${path}: ${error.message}`;
|
|
843
|
+
});
|
|
844
|
+
const message = `Validation failed:
|
|
845
|
+
${errorMessages.join("\n ")}`;
|
|
846
|
+
throw new ZapierValidationError(message, {
|
|
847
|
+
details: {
|
|
848
|
+
zodErrors: result.error.issues,
|
|
849
|
+
input
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
return result.data;
|
|
854
|
+
};
|
|
855
|
+
function createValidator(schema) {
|
|
856
|
+
return function validateFn(input) {
|
|
857
|
+
return validate(schema, input);
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
var validateOptions = (schema, options) => {
|
|
861
|
+
return validate(schema, options);
|
|
862
|
+
};
|
|
863
|
+
|
|
755
864
|
// src/plugins/fetch/index.ts
|
|
756
865
|
function transformUrlToRelayPath(url) {
|
|
757
866
|
const targetUrl = new URL(url);
|
|
@@ -789,26 +898,59 @@ function inferContentType(body) {
|
|
|
789
898
|
}
|
|
790
899
|
return void 0;
|
|
791
900
|
}
|
|
792
|
-
|
|
901
|
+
function rewrapIfMaxTimeTimeout({
|
|
902
|
+
error,
|
|
903
|
+
abortSignal,
|
|
904
|
+
maxTimeSeconds
|
|
905
|
+
}) {
|
|
906
|
+
if (maxTimeSeconds === void 0 || !abortSignal?.aborted) return error;
|
|
907
|
+
const reason = abortSignal.reason;
|
|
908
|
+
if (!reason || reason.name !== "TimeoutError") return error;
|
|
909
|
+
return new ZapierTimeoutError(
|
|
910
|
+
`fetch timed out after ${maxTimeSeconds}s (maxTime)`,
|
|
911
|
+
{ cause: error }
|
|
912
|
+
);
|
|
913
|
+
}
|
|
914
|
+
function buildAbortHandle({
|
|
915
|
+
maxTimeSeconds,
|
|
916
|
+
callerSignal
|
|
917
|
+
}) {
|
|
918
|
+
const handles = [];
|
|
919
|
+
if (callerSignal) handles.push({ signal: callerSignal, dispose: () => {
|
|
920
|
+
} });
|
|
921
|
+
if (maxTimeSeconds !== void 0) {
|
|
922
|
+
handles.push(
|
|
923
|
+
createTimeoutAbortSignal({ timeoutMs: maxTimeSeconds * 1e3 })
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
return combineAbortSignals({ handles });
|
|
927
|
+
}
|
|
928
|
+
var FetchInitSdkValidationSchema = zod.z.looseObject(FetchInitZapierFieldsSchema.shape).optional();
|
|
929
|
+
var validateFetchInit = createValidator(FetchInitSdkValidationSchema);
|
|
930
|
+
var fetchPlugin = (sdk) => {
|
|
793
931
|
return {
|
|
794
932
|
fetch: async function fetch2(url, init) {
|
|
795
933
|
return runWithTelemetryContext(async () => {
|
|
796
|
-
const { api } = context;
|
|
934
|
+
const { api } = sdk.context;
|
|
797
935
|
const startTime = Date.now();
|
|
798
936
|
const isNested = isTelemetryNested();
|
|
799
937
|
try {
|
|
938
|
+
if (init) {
|
|
939
|
+
validateFetchInit(init);
|
|
940
|
+
}
|
|
800
941
|
const {
|
|
801
942
|
connectionId,
|
|
802
943
|
connection,
|
|
803
944
|
authenticationId,
|
|
804
945
|
callbackUrl,
|
|
946
|
+
maxTime,
|
|
805
947
|
...fetchInit
|
|
806
948
|
} = init || {};
|
|
807
949
|
const resolvedConnectionId = await resolveConnectionId({
|
|
808
950
|
connectionId,
|
|
809
951
|
connection,
|
|
810
952
|
authenticationId,
|
|
811
|
-
resolveConnection: context.resolveConnection,
|
|
953
|
+
resolveConnection: sdk.context.resolveConnection,
|
|
812
954
|
label: "fetch"
|
|
813
955
|
});
|
|
814
956
|
const relayPath = transformUrlToRelayPath(url);
|
|
@@ -832,35 +974,52 @@ var fetchPlugin = ({ context }) => {
|
|
|
832
974
|
if (callbackUrl) {
|
|
833
975
|
headers["X-Relay-Callback-Url"] = callbackUrl;
|
|
834
976
|
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
authRequired: true
|
|
977
|
+
if (maxTime !== void 0) {
|
|
978
|
+
headers["X-Zapier-Sdk-Max-Time"] = String(maxTime);
|
|
979
|
+
}
|
|
980
|
+
const abortHandle = buildAbortHandle({
|
|
981
|
+
maxTimeSeconds: maxTime,
|
|
982
|
+
callerSignal: fetchInit.signal
|
|
842
983
|
});
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
984
|
+
try {
|
|
985
|
+
const result = await api.fetch(relayPath, {
|
|
986
|
+
method: fetchInit.method ?? "GET",
|
|
987
|
+
body: fetchInit.body,
|
|
988
|
+
headers,
|
|
989
|
+
redirect: fetchInit.redirect,
|
|
990
|
+
signal: abortHandle?.signal,
|
|
991
|
+
authRequired: true
|
|
847
992
|
});
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
993
|
+
const relayError = result.headers.get("x-relay-error");
|
|
994
|
+
if (relayError) {
|
|
995
|
+
throw new ZapierRelayError(relayError, {
|
|
996
|
+
statusCode: result.status
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
if (!isNested) {
|
|
1000
|
+
sdk.context.eventEmission.emitMethodCalled({
|
|
1001
|
+
method_name: "fetch",
|
|
1002
|
+
execution_duration_ms: Date.now() - startTime,
|
|
1003
|
+
success_flag: true,
|
|
1004
|
+
error_message: null,
|
|
1005
|
+
error_type: null,
|
|
1006
|
+
argument_count: init ? 2 : 1,
|
|
1007
|
+
is_paginated: false
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
return result;
|
|
1011
|
+
} catch (error) {
|
|
1012
|
+
throw rewrapIfMaxTimeTimeout({
|
|
1013
|
+
error,
|
|
1014
|
+
abortSignal: abortHandle?.signal,
|
|
1015
|
+
maxTimeSeconds: maxTime
|
|
858
1016
|
});
|
|
1017
|
+
} finally {
|
|
1018
|
+
abortHandle?.dispose();
|
|
859
1019
|
}
|
|
860
|
-
return result;
|
|
861
1020
|
} catch (error) {
|
|
862
1021
|
if (!isNested) {
|
|
863
|
-
context.eventEmission.emitMethodCalled({
|
|
1022
|
+
sdk.context.eventEmission.emitMethodCalled({
|
|
864
1023
|
method_name: "fetch",
|
|
865
1024
|
execution_duration_ms: Date.now() - startTime,
|
|
866
1025
|
success_flag: false,
|
|
@@ -1145,34 +1304,6 @@ function toIterable(source) {
|
|
|
1145
1304
|
return { [Symbol.asyncIterator]: () => source[Symbol.asyncIterator]() };
|
|
1146
1305
|
}
|
|
1147
1306
|
|
|
1148
|
-
// src/utils/validation.ts
|
|
1149
|
-
var validate = (schema, input) => {
|
|
1150
|
-
const result = schema.safeParse(input);
|
|
1151
|
-
if (!result.success) {
|
|
1152
|
-
const errorMessages = result.error.issues.map((error) => {
|
|
1153
|
-
const path = error.path.length > 0 ? error.path.join(".") : "input";
|
|
1154
|
-
return `${path}: ${error.message}`;
|
|
1155
|
-
});
|
|
1156
|
-
const message = `Validation failed:
|
|
1157
|
-
${errorMessages.join("\n ")}`;
|
|
1158
|
-
throw new ZapierValidationError(message, {
|
|
1159
|
-
details: {
|
|
1160
|
-
zodErrors: result.error.issues,
|
|
1161
|
-
input
|
|
1162
|
-
}
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1165
|
-
return result.data;
|
|
1166
|
-
};
|
|
1167
|
-
function createValidator(schema) {
|
|
1168
|
-
return function validateFn(input) {
|
|
1169
|
-
return validate(schema, input);
|
|
1170
|
-
};
|
|
1171
|
-
}
|
|
1172
|
-
var validateOptions = (schema, options) => {
|
|
1173
|
-
return validate(schema, options);
|
|
1174
|
-
};
|
|
1175
|
-
|
|
1176
1307
|
// src/utils/function-utils.ts
|
|
1177
1308
|
function extractCursor(data) {
|
|
1178
1309
|
if (!data?.next) {
|
|
@@ -1452,9 +1583,9 @@ function createTelemetryCallback(emitMethodCalled, methodName) {
|
|
|
1452
1583
|
}
|
|
1453
1584
|
|
|
1454
1585
|
// src/plugins/listApps/index.ts
|
|
1455
|
-
var listAppsPlugin = (
|
|
1586
|
+
var listAppsPlugin = (sdk) => {
|
|
1456
1587
|
async function listAppsPage(options) {
|
|
1457
|
-
const { api, resolveAppKeys: resolveAppKeys2 } = context;
|
|
1588
|
+
const { api, resolveAppKeys: resolveAppKeys2 } = sdk.context;
|
|
1458
1589
|
const appKeys = options.apps ?? options.appKeys ?? [];
|
|
1459
1590
|
const appLocators = await resolveAppKeys2({
|
|
1460
1591
|
appKeys: [...appKeys]
|
|
@@ -1498,7 +1629,10 @@ var listAppsPlugin = ({ context }) => {
|
|
|
1498
1629
|
const listAppsDefinition = createPaginatedFunction(
|
|
1499
1630
|
listAppsPage,
|
|
1500
1631
|
ListAppsSchema,
|
|
1501
|
-
createTelemetryCallback(
|
|
1632
|
+
createTelemetryCallback(
|
|
1633
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
1634
|
+
methodName
|
|
1635
|
+
),
|
|
1502
1636
|
methodName,
|
|
1503
1637
|
DEFAULT_PAGE_SIZE
|
|
1504
1638
|
);
|
|
@@ -1939,7 +2073,7 @@ var actionKeyResolver = {
|
|
|
1939
2073
|
|
|
1940
2074
|
// src/resolvers/connectionId.ts
|
|
1941
2075
|
async function fetchConnections(sdk, resolvedParams) {
|
|
1942
|
-
const context = sdk.
|
|
2076
|
+
const context = sdk.context;
|
|
1943
2077
|
const includeShared = await context.hasCapability?.(
|
|
1944
2078
|
"canIncludeSharedConnections"
|
|
1945
2079
|
);
|
|
@@ -2107,7 +2241,7 @@ var tableIdResolver = {
|
|
|
2107
2241
|
type: "dynamic",
|
|
2108
2242
|
requireCapabilities: ["canIncludeSharedTables"],
|
|
2109
2243
|
fetch: async (sdk) => {
|
|
2110
|
-
const context = sdk.
|
|
2244
|
+
const context = sdk.context;
|
|
2111
2245
|
const includeShared = await context.hasCapability?.(
|
|
2112
2246
|
"canIncludeSharedTables"
|
|
2113
2247
|
);
|
|
@@ -2747,7 +2881,7 @@ var tableSortResolver = {
|
|
|
2747
2881
|
};
|
|
2748
2882
|
|
|
2749
2883
|
// src/plugins/listActions/index.ts
|
|
2750
|
-
var listActionsPlugin = (
|
|
2884
|
+
var listActionsPlugin = (sdk) => {
|
|
2751
2885
|
const methodMeta = {
|
|
2752
2886
|
categories: ["action"],
|
|
2753
2887
|
type: "list",
|
|
@@ -2760,7 +2894,7 @@ var listActionsPlugin = ({ context }) => {
|
|
|
2760
2894
|
}
|
|
2761
2895
|
};
|
|
2762
2896
|
async function listActionsPage(options) {
|
|
2763
|
-
const { api, getVersionedImplementationId } = context;
|
|
2897
|
+
const { api, getVersionedImplementationId } = sdk.context;
|
|
2764
2898
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
2765
2899
|
const selectedApi = await getVersionedImplementationId(appKey);
|
|
2766
2900
|
if (!selectedApi) {
|
|
@@ -2825,7 +2959,10 @@ var listActionsPlugin = ({ context }) => {
|
|
|
2825
2959
|
const listActionsDefinition = createPaginatedFunction(
|
|
2826
2960
|
listActionsPage,
|
|
2827
2961
|
ListActionsInputSchema,
|
|
2828
|
-
createTelemetryCallback(
|
|
2962
|
+
createTelemetryCallback(
|
|
2963
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
2964
|
+
methodName
|
|
2965
|
+
),
|
|
2829
2966
|
methodName,
|
|
2830
2967
|
DEFAULT_PAGE_SIZE
|
|
2831
2968
|
);
|
|
@@ -3148,9 +3285,9 @@ function transformNeedsToFields(needs) {
|
|
|
3148
3285
|
}
|
|
3149
3286
|
return rootFields;
|
|
3150
3287
|
}
|
|
3151
|
-
var listInputFieldsPlugin = (
|
|
3288
|
+
var listInputFieldsPlugin = (sdk) => {
|
|
3152
3289
|
async function listInputFieldsPage(options) {
|
|
3153
|
-
const { api, getVersionedImplementationId } = context;
|
|
3290
|
+
const { api, getVersionedImplementationId } = sdk.context;
|
|
3154
3291
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
3155
3292
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
3156
3293
|
const { actionType, connection, connectionId, authenticationId, inputs } = options;
|
|
@@ -3158,7 +3295,7 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
|
|
|
3158
3295
|
connection,
|
|
3159
3296
|
connectionId,
|
|
3160
3297
|
authenticationId,
|
|
3161
|
-
resolveConnection: context.resolveConnection
|
|
3298
|
+
resolveConnection: sdk.context.resolveConnection
|
|
3162
3299
|
});
|
|
3163
3300
|
const selectedApi = await getVersionedImplementationId(appKey);
|
|
3164
3301
|
if (!selectedApi) {
|
|
@@ -3196,7 +3333,10 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
|
|
|
3196
3333
|
const listInputFieldsDefinition = createPaginatedFunction(
|
|
3197
3334
|
listInputFieldsPage,
|
|
3198
3335
|
ListInputFieldsInputSchema,
|
|
3199
|
-
createTelemetryCallback(
|
|
3336
|
+
createTelemetryCallback(
|
|
3337
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
3338
|
+
methodName
|
|
3339
|
+
),
|
|
3200
3340
|
methodName,
|
|
3201
3341
|
DEFAULT_PAGE_SIZE
|
|
3202
3342
|
);
|
|
@@ -3299,12 +3439,12 @@ var ConnectionItemSchema = withFormatter(connections.ConnectionItemSchema, {
|
|
|
3299
3439
|
});
|
|
3300
3440
|
|
|
3301
3441
|
// src/plugins/listConnections/index.ts
|
|
3302
|
-
var listConnectionsPlugin = (
|
|
3442
|
+
var listConnectionsPlugin = (sdk) => {
|
|
3303
3443
|
async function listConnectionsPage(options) {
|
|
3304
3444
|
if (options.includeShared) {
|
|
3305
|
-
await context.checkCapability("canIncludeSharedConnections");
|
|
3445
|
+
await sdk.context.checkCapability("canIncludeSharedConnections");
|
|
3306
3446
|
}
|
|
3307
|
-
const { api, getVersionedImplementationId } = context;
|
|
3447
|
+
const { api, getVersionedImplementationId } = sdk.context;
|
|
3308
3448
|
const searchParams = {};
|
|
3309
3449
|
if (options.pageSize !== void 0) {
|
|
3310
3450
|
searchParams.page_size = options.pageSize.toString();
|
|
@@ -3327,7 +3467,7 @@ var listConnectionsPlugin = ({ context }) => {
|
|
|
3327
3467
|
connectionRefs.map(
|
|
3328
3468
|
(ref) => resolveConnectionId({
|
|
3329
3469
|
connection: ref,
|
|
3330
|
-
resolveConnection: context.resolveConnection
|
|
3470
|
+
resolveConnection: sdk.context.resolveConnection
|
|
3331
3471
|
})
|
|
3332
3472
|
)
|
|
3333
3473
|
);
|
|
@@ -3393,7 +3533,10 @@ var listConnectionsPlugin = ({ context }) => {
|
|
|
3393
3533
|
const listConnectionsDefinition = createPaginatedFunction(
|
|
3394
3534
|
listConnectionsPage,
|
|
3395
3535
|
ListConnectionsQuerySchema,
|
|
3396
|
-
createTelemetryCallback(
|
|
3536
|
+
createTelemetryCallback(
|
|
3537
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
3538
|
+
methodName
|
|
3539
|
+
),
|
|
3397
3540
|
methodName,
|
|
3398
3541
|
DEFAULT_PAGE_SIZE
|
|
3399
3542
|
);
|
|
@@ -3469,9 +3612,9 @@ var ClientCredentialsCreatedItemSchema = withFormatter(
|
|
|
3469
3612
|
);
|
|
3470
3613
|
|
|
3471
3614
|
// src/plugins/listClientCredentials/index.ts
|
|
3472
|
-
var listClientCredentialsPlugin = (
|
|
3615
|
+
var listClientCredentialsPlugin = (sdk) => {
|
|
3473
3616
|
async function listClientCredentialsPage(options) {
|
|
3474
|
-
const { api } = context;
|
|
3617
|
+
const { api } = sdk.context;
|
|
3475
3618
|
const searchParams = {};
|
|
3476
3619
|
if (options.pageSize !== void 0) {
|
|
3477
3620
|
searchParams.pageSize = options.pageSize.toString();
|
|
@@ -3508,7 +3651,10 @@ var listClientCredentialsPlugin = ({ context }) => {
|
|
|
3508
3651
|
const listClientCredentialsDefinition = createPaginatedFunction(
|
|
3509
3652
|
listClientCredentialsPage,
|
|
3510
3653
|
ListClientCredentialsQuerySchema,
|
|
3511
|
-
createTelemetryCallback(
|
|
3654
|
+
createTelemetryCallback(
|
|
3655
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
3656
|
+
methodName
|
|
3657
|
+
),
|
|
3512
3658
|
methodName,
|
|
3513
3659
|
DEFAULT_PAGE_SIZE
|
|
3514
3660
|
);
|
|
@@ -3532,9 +3678,9 @@ var CreateClientCredentialsSchema = clientCredentials.CreateClientCredentialsReq
|
|
|
3532
3678
|
}).describe("Create new client credentials for the authenticated user");
|
|
3533
3679
|
|
|
3534
3680
|
// src/plugins/createClientCredentials/index.ts
|
|
3535
|
-
var createClientCredentialsPlugin = (
|
|
3681
|
+
var createClientCredentialsPlugin = (sdk) => {
|
|
3536
3682
|
async function createClientCredentials(options) {
|
|
3537
|
-
const { api } = context;
|
|
3683
|
+
const { api } = sdk.context;
|
|
3538
3684
|
const response = await api.post(
|
|
3539
3685
|
"/api/v0/client-credentials",
|
|
3540
3686
|
{
|
|
@@ -3569,7 +3715,7 @@ var createClientCredentialsPlugin = ({ context }) => {
|
|
|
3569
3715
|
createClientCredentials,
|
|
3570
3716
|
CreateClientCredentialsSchema,
|
|
3571
3717
|
createTelemetryCallback(
|
|
3572
|
-
context.eventEmission.emitMethodCalled,
|
|
3718
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
3573
3719
|
createClientCredentials.name
|
|
3574
3720
|
)
|
|
3575
3721
|
);
|
|
@@ -3597,9 +3743,9 @@ var DeleteClientCredentialsSchema = zod.z.object({
|
|
|
3597
3743
|
}).describe("Delete client credentials by client ID");
|
|
3598
3744
|
|
|
3599
3745
|
// src/plugins/deleteClientCredentials/index.ts
|
|
3600
|
-
var deleteClientCredentialsPlugin = (
|
|
3746
|
+
var deleteClientCredentialsPlugin = (sdk) => {
|
|
3601
3747
|
async function deleteClientCredentials(options) {
|
|
3602
|
-
const { api } = context;
|
|
3748
|
+
const { api } = sdk.context;
|
|
3603
3749
|
await api.delete(
|
|
3604
3750
|
`/api/v0/client-credentials/${options.clientId}`,
|
|
3605
3751
|
void 0,
|
|
@@ -3631,7 +3777,7 @@ var deleteClientCredentialsPlugin = ({ context }) => {
|
|
|
3631
3777
|
deleteClientCredentials,
|
|
3632
3778
|
DeleteClientCredentialsSchema,
|
|
3633
3779
|
createTelemetryCallback(
|
|
3634
|
-
context.eventEmission.emitMethodCalled,
|
|
3780
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
3635
3781
|
deleteClientCredentials.name
|
|
3636
3782
|
)
|
|
3637
3783
|
);
|
|
@@ -3662,7 +3808,7 @@ var GetAppSchemaDeprecated = zod.z.object({
|
|
|
3662
3808
|
var GetAppInputSchema = zod.z.union([GetAppSchema, GetAppSchemaDeprecated]).describe(GetAppDescription);
|
|
3663
3809
|
|
|
3664
3810
|
// src/plugins/getApp/index.ts
|
|
3665
|
-
var getAppPlugin = (
|
|
3811
|
+
var getAppPlugin = (sdk) => {
|
|
3666
3812
|
async function getApp(options) {
|
|
3667
3813
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
3668
3814
|
const appsIterable = sdk.listApps({
|
|
@@ -3681,7 +3827,7 @@ var getAppPlugin = ({ sdk, context }) => {
|
|
|
3681
3827
|
getApp,
|
|
3682
3828
|
GetAppInputSchema,
|
|
3683
3829
|
createTelemetryCallback(
|
|
3684
|
-
context.eventEmission.emitMethodCalled,
|
|
3830
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
3685
3831
|
getApp.name
|
|
3686
3832
|
)
|
|
3687
3833
|
);
|
|
@@ -3717,7 +3863,7 @@ var GetActionSchemaDeprecated = zod.z.object({
|
|
|
3717
3863
|
var GetActionInputSchema = zod.z.union([GetActionSchema, GetActionSchemaDeprecated]).describe(GetActionDescription);
|
|
3718
3864
|
|
|
3719
3865
|
// src/plugins/getAction/index.ts
|
|
3720
|
-
var getActionPlugin = (
|
|
3866
|
+
var getActionPlugin = (sdk) => {
|
|
3721
3867
|
async function getAction(options) {
|
|
3722
3868
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
3723
3869
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
@@ -3740,7 +3886,7 @@ var getActionPlugin = ({ sdk, context }) => {
|
|
|
3740
3886
|
getAction,
|
|
3741
3887
|
GetActionInputSchema,
|
|
3742
3888
|
createTelemetryCallback(
|
|
3743
|
-
context.eventEmission.emitMethodCalled,
|
|
3889
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
3744
3890
|
getAction.name
|
|
3745
3891
|
)
|
|
3746
3892
|
);
|
|
@@ -3777,9 +3923,9 @@ var GetConnectionParamSchema = zod.z.object({
|
|
|
3777
3923
|
});
|
|
3778
3924
|
|
|
3779
3925
|
// src/plugins/getConnection/index.ts
|
|
3780
|
-
var getConnectionPlugin = (
|
|
3926
|
+
var getConnectionPlugin = (sdk) => {
|
|
3781
3927
|
async function getConnection(options) {
|
|
3782
|
-
const { api } = context;
|
|
3928
|
+
const { api } = sdk.context;
|
|
3783
3929
|
const resolvedConnectionId = options.connection ?? options.connectionId ?? options.authenticationId;
|
|
3784
3930
|
if (!resolvedConnectionId) {
|
|
3785
3931
|
throw new Error("connection is required");
|
|
@@ -3796,7 +3942,7 @@ var getConnectionPlugin = ({ context }) => {
|
|
|
3796
3942
|
getConnection,
|
|
3797
3943
|
GetConnectionParamSchema,
|
|
3798
3944
|
createTelemetryCallback(
|
|
3799
|
-
context.eventEmission.emitMethodCalled,
|
|
3945
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
3800
3946
|
getConnection.name
|
|
3801
3947
|
)
|
|
3802
3948
|
);
|
|
@@ -3830,7 +3976,7 @@ var FindFirstConnectionSchema = ListConnectionsQuerySchema.omit({
|
|
|
3830
3976
|
}).describe("Find the first connection matching the criteria");
|
|
3831
3977
|
|
|
3832
3978
|
// src/plugins/findFirstConnection/index.ts
|
|
3833
|
-
var findFirstConnectionPlugin = (
|
|
3979
|
+
var findFirstConnectionPlugin = (sdk) => {
|
|
3834
3980
|
async function findFirstConnection(options = {}) {
|
|
3835
3981
|
const connectionsResponse = await sdk.listConnections({
|
|
3836
3982
|
...options,
|
|
@@ -3850,7 +3996,7 @@ var findFirstConnectionPlugin = ({ sdk, context }) => {
|
|
|
3850
3996
|
findFirstConnection,
|
|
3851
3997
|
FindFirstConnectionSchema,
|
|
3852
3998
|
createTelemetryCallback(
|
|
3853
|
-
context.eventEmission.emitMethodCalled,
|
|
3999
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
3854
4000
|
findFirstConnection.name
|
|
3855
4001
|
)
|
|
3856
4002
|
);
|
|
@@ -3881,7 +4027,7 @@ var FindUniqueConnectionSchema = ListConnectionsQuerySchema.omit({
|
|
|
3881
4027
|
}).describe("Find a unique connection matching the criteria");
|
|
3882
4028
|
|
|
3883
4029
|
// src/plugins/findUniqueConnection/index.ts
|
|
3884
|
-
var findUniqueConnectionPlugin = (
|
|
4030
|
+
var findUniqueConnectionPlugin = (sdk) => {
|
|
3885
4031
|
async function findUniqueConnection(options = {}) {
|
|
3886
4032
|
const connectionsResponse = await sdk.listConnections({
|
|
3887
4033
|
...options,
|
|
@@ -3907,7 +4053,7 @@ var findUniqueConnectionPlugin = ({ sdk, context }) => {
|
|
|
3907
4053
|
findUniqueConnection,
|
|
3908
4054
|
FindUniqueConnectionSchema,
|
|
3909
4055
|
createTelemetryCallback(
|
|
3910
|
-
context.eventEmission.emitMethodCalled,
|
|
4056
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
3911
4057
|
findUniqueConnection.name
|
|
3912
4058
|
)
|
|
3913
4059
|
);
|
|
@@ -4010,7 +4156,7 @@ async function executeAction(actionOptions) {
|
|
|
4010
4156
|
}
|
|
4011
4157
|
var CONTEXT_CACHE_TTL_MS = 6e4;
|
|
4012
4158
|
var CONTEXT_CACHE_MAX_SIZE = 500;
|
|
4013
|
-
var runActionPlugin = (
|
|
4159
|
+
var runActionPlugin = (sdk) => {
|
|
4014
4160
|
const runActionContextCache = /* @__PURE__ */ new Map();
|
|
4015
4161
|
function evictIfNeeded() {
|
|
4016
4162
|
if (runActionContextCache.size < CONTEXT_CACHE_MAX_SIZE) return;
|
|
@@ -4054,7 +4200,7 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
4054
4200
|
}
|
|
4055
4201
|
async function resolveRunActionContext(options) {
|
|
4056
4202
|
const { appKey, actionKey, actionType } = options;
|
|
4057
|
-
const selectedApi = await context.getVersionedImplementationId(appKey);
|
|
4203
|
+
const selectedApi = await sdk.context.getVersionedImplementationId(appKey);
|
|
4058
4204
|
if (!selectedApi) {
|
|
4059
4205
|
throw new ZapierConfigurationError(
|
|
4060
4206
|
"No current_implementation_id found for app",
|
|
@@ -4074,7 +4220,7 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
4074
4220
|
return { selectedApi, actionId: actionData.data.id };
|
|
4075
4221
|
}
|
|
4076
4222
|
async function runActionPage(options) {
|
|
4077
|
-
const { api } = context;
|
|
4223
|
+
const { api } = sdk.context;
|
|
4078
4224
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
4079
4225
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
4080
4226
|
const {
|
|
@@ -4090,7 +4236,7 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
4090
4236
|
connectionId,
|
|
4091
4237
|
connection,
|
|
4092
4238
|
authenticationId,
|
|
4093
|
-
resolveConnection: context.resolveConnection
|
|
4239
|
+
resolveConnection: sdk.context.resolveConnection
|
|
4094
4240
|
});
|
|
4095
4241
|
const { selectedApi, actionId } = await getRunActionContext({
|
|
4096
4242
|
appKey,
|
|
@@ -4133,7 +4279,10 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
4133
4279
|
const runActionDefinition = createPaginatedFunction(
|
|
4134
4280
|
runActionPage,
|
|
4135
4281
|
RunActionInputSchema,
|
|
4136
|
-
createTelemetryCallback(
|
|
4282
|
+
createTelemetryCallback(
|
|
4283
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
4284
|
+
methodName
|
|
4285
|
+
),
|
|
4137
4286
|
methodName
|
|
4138
4287
|
);
|
|
4139
4288
|
return {
|
|
@@ -4193,7 +4342,7 @@ function resetDeprecationWarnings() {
|
|
|
4193
4342
|
}
|
|
4194
4343
|
|
|
4195
4344
|
// src/plugins/request/index.ts
|
|
4196
|
-
var requestPlugin = (
|
|
4345
|
+
var requestPlugin = (sdk) => {
|
|
4197
4346
|
async function request(options) {
|
|
4198
4347
|
logDeprecation("request() is deprecated. Use fetch() instead.");
|
|
4199
4348
|
const {
|
|
@@ -4218,7 +4367,7 @@ var requestPlugin = ({ sdk, context }) => {
|
|
|
4218
4367
|
request,
|
|
4219
4368
|
RelayRequestSchema,
|
|
4220
4369
|
createTelemetryCallback(
|
|
4221
|
-
context.eventEmission.emitMethodCalled,
|
|
4370
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
4222
4371
|
request.name
|
|
4223
4372
|
)
|
|
4224
4373
|
);
|
|
@@ -4527,9 +4676,8 @@ async function resolveAppKeys({
|
|
|
4527
4676
|
});
|
|
4528
4677
|
return slugResolvedLocators.filter(isResolvedAppLocator);
|
|
4529
4678
|
}
|
|
4530
|
-
var manifestPlugin = (
|
|
4531
|
-
const {
|
|
4532
|
-
const { api, options } = context;
|
|
4679
|
+
var manifestPlugin = (sdk) => {
|
|
4680
|
+
const { api, options } = sdk.context;
|
|
4533
4681
|
const { manifestPath = DEFAULT_CONFIG_PATH, manifest } = options || {};
|
|
4534
4682
|
let resolvedManifest;
|
|
4535
4683
|
async function resolveManifest() {
|
|
@@ -4740,9 +4888,9 @@ var UserProfileItemSchema = withFormatter(
|
|
|
4740
4888
|
);
|
|
4741
4889
|
|
|
4742
4890
|
// src/plugins/getProfile/index.ts
|
|
4743
|
-
var getProfilePlugin = (
|
|
4891
|
+
var getProfilePlugin = (sdk) => {
|
|
4744
4892
|
async function getProfile() {
|
|
4745
|
-
const profile = await context.api.get(
|
|
4893
|
+
const profile = await sdk.context.api.get(
|
|
4746
4894
|
"/zapier/api/v4/profile/",
|
|
4747
4895
|
{
|
|
4748
4896
|
authRequired: true
|
|
@@ -4764,7 +4912,7 @@ var getProfilePlugin = ({ context }) => {
|
|
|
4764
4912
|
getProfile,
|
|
4765
4913
|
GetProfileSchema,
|
|
4766
4914
|
createTelemetryCallback(
|
|
4767
|
-
context.eventEmission.emitMethodCalled,
|
|
4915
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
4768
4916
|
getProfile.name
|
|
4769
4917
|
)
|
|
4770
4918
|
);
|
|
@@ -5951,7 +6099,7 @@ var createZapierApi = (options) => {
|
|
|
5951
6099
|
};
|
|
5952
6100
|
|
|
5953
6101
|
// src/plugins/api/index.ts
|
|
5954
|
-
var apiPlugin = (
|
|
6102
|
+
var apiPlugin = (sdk) => {
|
|
5955
6103
|
const {
|
|
5956
6104
|
fetch: customFetch = globalThis.fetch,
|
|
5957
6105
|
baseUrl = ZAPIER_BASE_URL,
|
|
@@ -5961,7 +6109,7 @@ var apiPlugin = (params) => {
|
|
|
5961
6109
|
debug = false,
|
|
5962
6110
|
maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES,
|
|
5963
6111
|
maxNetworkRetryDelayMs = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS
|
|
5964
|
-
} =
|
|
6112
|
+
} = sdk.context.options;
|
|
5965
6113
|
const api = createZapierApi({
|
|
5966
6114
|
baseUrl,
|
|
5967
6115
|
credentials,
|
|
@@ -6076,12 +6224,11 @@ async function batch(tasks, options = {}) {
|
|
|
6076
6224
|
}
|
|
6077
6225
|
|
|
6078
6226
|
// src/plugins/connections/index.ts
|
|
6079
|
-
var connectionsPlugin = (
|
|
6080
|
-
const { context } = params;
|
|
6227
|
+
var connectionsPlugin = (sdk) => {
|
|
6081
6228
|
let cachedMap;
|
|
6082
6229
|
async function loadConnectionsMap() {
|
|
6083
6230
|
if (cachedMap === void 0) {
|
|
6084
|
-
cachedMap = await context.getManifestConnections() ?? null;
|
|
6231
|
+
cachedMap = await sdk.context.getManifestConnections() ?? null;
|
|
6085
6232
|
}
|
|
6086
6233
|
return cachedMap;
|
|
6087
6234
|
}
|
|
@@ -6128,12 +6275,12 @@ function isEnabledByEnv(key) {
|
|
|
6128
6275
|
if (value === "false" || value === "0") return false;
|
|
6129
6276
|
return void 0;
|
|
6130
6277
|
}
|
|
6131
|
-
var capabilitiesPlugin = (
|
|
6132
|
-
const options = context.options ?? {};
|
|
6278
|
+
var capabilitiesPlugin = (sdk) => {
|
|
6279
|
+
const options = sdk.context.options ?? {};
|
|
6133
6280
|
let cached;
|
|
6134
6281
|
async function resolveFlags() {
|
|
6135
6282
|
if (cached) return cached;
|
|
6136
|
-
const manifest = await context.getResolvedManifest();
|
|
6283
|
+
const manifest = await sdk.context.getResolvedManifest();
|
|
6137
6284
|
cached = {};
|
|
6138
6285
|
for (const flag of GATED_FLAGS) {
|
|
6139
6286
|
cached[flag] = Boolean(
|
|
@@ -6219,12 +6366,12 @@ function extractNextCursor(links) {
|
|
|
6219
6366
|
return void 0;
|
|
6220
6367
|
}
|
|
6221
6368
|
}
|
|
6222
|
-
var listTablesPlugin = (
|
|
6369
|
+
var listTablesPlugin = (sdk) => {
|
|
6223
6370
|
async function listTablesPage(options) {
|
|
6224
6371
|
if (options.includeShared) {
|
|
6225
|
-
await context.checkCapability("canIncludeSharedTables");
|
|
6372
|
+
await sdk.context.checkCapability("canIncludeSharedTables");
|
|
6226
6373
|
}
|
|
6227
|
-
const { api } = context;
|
|
6374
|
+
const { api } = sdk.context;
|
|
6228
6375
|
const searchParams = {};
|
|
6229
6376
|
if (options.pageSize !== void 0) {
|
|
6230
6377
|
searchParams.limit = options.pageSize.toString();
|
|
@@ -6289,7 +6436,10 @@ var listTablesPlugin = ({ context }) => {
|
|
|
6289
6436
|
const listTablesDefinition = createPaginatedFunction(
|
|
6290
6437
|
listTablesPage,
|
|
6291
6438
|
ListTablesOptionsSchema,
|
|
6292
|
-
createTelemetryCallback(
|
|
6439
|
+
createTelemetryCallback(
|
|
6440
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
6441
|
+
methodName
|
|
6442
|
+
),
|
|
6293
6443
|
methodName,
|
|
6294
6444
|
DEFAULT_PAGE_SIZE
|
|
6295
6445
|
);
|
|
@@ -6321,9 +6471,9 @@ var GetTableOptionsSchemaDeprecated = zod.z.object({
|
|
|
6321
6471
|
var GetTableOptionsInputSchema = zod.z.union([GetTableOptionsSchema, GetTableOptionsSchemaDeprecated]).describe(GetTableDescription);
|
|
6322
6472
|
|
|
6323
6473
|
// src/plugins/tables/getTable/index.ts
|
|
6324
|
-
var getTablePlugin = (
|
|
6474
|
+
var getTablePlugin = (sdk) => {
|
|
6325
6475
|
async function getTable(options) {
|
|
6326
|
-
const { api } = context;
|
|
6476
|
+
const { api } = sdk.context;
|
|
6327
6477
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
6328
6478
|
const rawResponse = await api.get(`/tables/api/v1/tables/${tableId}`, {
|
|
6329
6479
|
customErrorHandler: ({ status }) => {
|
|
@@ -6355,7 +6505,7 @@ var getTablePlugin = ({ context }) => {
|
|
|
6355
6505
|
getTable,
|
|
6356
6506
|
GetTableOptionsInputSchema,
|
|
6357
6507
|
createTelemetryCallback(
|
|
6358
|
-
context.eventEmission.emitMethodCalled,
|
|
6508
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
6359
6509
|
getTable.name
|
|
6360
6510
|
)
|
|
6361
6511
|
);
|
|
@@ -6386,9 +6536,9 @@ var CreateTableOptionsSchema = zod.z.object({
|
|
|
6386
6536
|
}).describe("Create a new table");
|
|
6387
6537
|
|
|
6388
6538
|
// src/plugins/tables/createTable/index.ts
|
|
6389
|
-
var createTablePlugin = (
|
|
6539
|
+
var createTablePlugin = (sdk) => {
|
|
6390
6540
|
async function createTable(options) {
|
|
6391
|
-
const { api } = context;
|
|
6541
|
+
const { api } = sdk.context;
|
|
6392
6542
|
const rawResponse = await api.post(
|
|
6393
6543
|
"/tables/api/v1/tables",
|
|
6394
6544
|
{
|
|
@@ -6423,7 +6573,7 @@ var createTablePlugin = ({ context }) => {
|
|
|
6423
6573
|
createTable,
|
|
6424
6574
|
CreateTableOptionsSchema,
|
|
6425
6575
|
createTelemetryCallback(
|
|
6426
|
-
context.eventEmission.emitMethodCalled,
|
|
6576
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
6427
6577
|
createTable.name
|
|
6428
6578
|
)
|
|
6429
6579
|
);
|
|
@@ -6455,10 +6605,10 @@ var DeleteTableOptionsSchemaDeprecated = zod.z.object({
|
|
|
6455
6605
|
var DeleteTableOptionsInputSchema = zod.z.union([DeleteTableOptionsSchema, DeleteTableOptionsSchemaDeprecated]).describe(DeleteTableDescription);
|
|
6456
6606
|
|
|
6457
6607
|
// src/plugins/tables/deleteTable/index.ts
|
|
6458
|
-
var deleteTablePlugin = (
|
|
6608
|
+
var deleteTablePlugin = (sdk) => {
|
|
6459
6609
|
async function deleteTable(options) {
|
|
6460
|
-
await context.checkCapability("canDeleteTables");
|
|
6461
|
-
const { api } = context;
|
|
6610
|
+
await sdk.context.checkCapability("canDeleteTables");
|
|
6611
|
+
const { api } = sdk.context;
|
|
6462
6612
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
6463
6613
|
await api.delete(`/tables/api/v1/tables/${tableId}`, void 0, {
|
|
6464
6614
|
customErrorHandler: ({ status }) => {
|
|
@@ -6486,7 +6636,7 @@ var deleteTablePlugin = ({ context }) => {
|
|
|
6486
6636
|
deleteTable,
|
|
6487
6637
|
DeleteTableOptionsInputSchema,
|
|
6488
6638
|
createTelemetryCallback(
|
|
6489
|
-
context.eventEmission.emitMethodCalled,
|
|
6639
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
6490
6640
|
deleteTable.name
|
|
6491
6641
|
)
|
|
6492
6642
|
);
|
|
@@ -6510,9 +6660,9 @@ var deleteTablePlugin = ({ context }) => {
|
|
|
6510
6660
|
};
|
|
6511
6661
|
|
|
6512
6662
|
// src/plugins/tables/listTableFields/index.ts
|
|
6513
|
-
var listTableFieldsPlugin = (
|
|
6663
|
+
var listTableFieldsPlugin = (sdk) => {
|
|
6514
6664
|
async function listTableFields(options) {
|
|
6515
|
-
const { api } = context;
|
|
6665
|
+
const { api } = sdk.context;
|
|
6516
6666
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
6517
6667
|
const fieldKeys = "fields" in options ? options.fields : options.fieldKeys;
|
|
6518
6668
|
const searchParams = {};
|
|
@@ -6558,7 +6708,7 @@ var listTableFieldsPlugin = ({ context }) => {
|
|
|
6558
6708
|
listTableFields,
|
|
6559
6709
|
ListTableFieldsOptionsInputSchema,
|
|
6560
6710
|
createTelemetryCallback(
|
|
6561
|
-
context.eventEmission.emitMethodCalled,
|
|
6711
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
6562
6712
|
listTableFields.name
|
|
6563
6713
|
)
|
|
6564
6714
|
);
|
|
@@ -6613,9 +6763,9 @@ var CreateTableFieldsOptionsInputSchema = zod.z.union([
|
|
|
6613
6763
|
]).describe(CreateTableFieldsDescription);
|
|
6614
6764
|
|
|
6615
6765
|
// src/plugins/tables/createTableFields/index.ts
|
|
6616
|
-
var createTableFieldsPlugin = (
|
|
6766
|
+
var createTableFieldsPlugin = (sdk) => {
|
|
6617
6767
|
async function createTableFields(options) {
|
|
6618
|
-
const { api } = context;
|
|
6768
|
+
const { api } = sdk.context;
|
|
6619
6769
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
6620
6770
|
const rawResponse = await api.post(
|
|
6621
6771
|
`/tables/api/v1/tables/${tableId}/fields`,
|
|
@@ -6650,7 +6800,7 @@ var createTableFieldsPlugin = ({ context }) => {
|
|
|
6650
6800
|
createTableFields,
|
|
6651
6801
|
CreateTableFieldsOptionsInputSchema,
|
|
6652
6802
|
createTelemetryCallback(
|
|
6653
|
-
context.eventEmission.emitMethodCalled,
|
|
6803
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
6654
6804
|
createTableFields.name
|
|
6655
6805
|
)
|
|
6656
6806
|
);
|
|
@@ -6690,9 +6840,9 @@ var DeleteTableFieldsOptionsInputSchema = zod.z.union([
|
|
|
6690
6840
|
]).describe(DeleteTableFieldsDescription);
|
|
6691
6841
|
|
|
6692
6842
|
// src/plugins/tables/deleteTableFields/index.ts
|
|
6693
|
-
var deleteTableFieldsPlugin = (
|
|
6843
|
+
var deleteTableFieldsPlugin = (sdk) => {
|
|
6694
6844
|
async function deleteTableFields(options) {
|
|
6695
|
-
const { api } = context;
|
|
6845
|
+
const { api } = sdk.context;
|
|
6696
6846
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
6697
6847
|
const fieldKeys = "fields" in options ? options.fields : options.fieldKeys;
|
|
6698
6848
|
const numericFieldIds = await resolveFieldKeys({
|
|
@@ -6730,7 +6880,7 @@ var deleteTableFieldsPlugin = ({ context }) => {
|
|
|
6730
6880
|
deleteTableFields,
|
|
6731
6881
|
DeleteTableFieldsOptionsInputSchema,
|
|
6732
6882
|
createTelemetryCallback(
|
|
6733
|
-
context.eventEmission.emitMethodCalled,
|
|
6883
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
6734
6884
|
deleteTableFields.name
|
|
6735
6885
|
)
|
|
6736
6886
|
);
|
|
@@ -6817,9 +6967,9 @@ var tableRecordFormatter = {
|
|
|
6817
6967
|
};
|
|
6818
6968
|
|
|
6819
6969
|
// src/plugins/tables/getTableRecord/index.ts
|
|
6820
|
-
var getTableRecordPlugin = (
|
|
6970
|
+
var getTableRecordPlugin = (sdk) => {
|
|
6821
6971
|
async function getTableRecord(options) {
|
|
6822
|
-
const { api } = context;
|
|
6972
|
+
const { api } = sdk.context;
|
|
6823
6973
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
6824
6974
|
const recordId = "record" in options ? options.record : options.recordId;
|
|
6825
6975
|
const rawResponse = await api.get(
|
|
@@ -6863,7 +7013,7 @@ var getTableRecordPlugin = ({ context }) => {
|
|
|
6863
7013
|
getTableRecord,
|
|
6864
7014
|
GetTableRecordOptionsInputSchema,
|
|
6865
7015
|
createTelemetryCallback(
|
|
6866
|
-
context.eventEmission.emitMethodCalled,
|
|
7016
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
6867
7017
|
getTableRecord.name
|
|
6868
7018
|
)
|
|
6869
7019
|
);
|
|
@@ -6951,9 +7101,9 @@ function extractNextCursor2(meta) {
|
|
|
6951
7101
|
}
|
|
6952
7102
|
return meta.pagination.end_cursor;
|
|
6953
7103
|
}
|
|
6954
|
-
var listTableRecordsPlugin = (
|
|
7104
|
+
var listTableRecordsPlugin = (sdk) => {
|
|
6955
7105
|
async function listTableRecordsPage(options) {
|
|
6956
|
-
const { api } = context;
|
|
7106
|
+
const { api } = sdk.context;
|
|
6957
7107
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
6958
7108
|
const translator = await createFieldKeyTranslator({
|
|
6959
7109
|
api,
|
|
@@ -7025,7 +7175,10 @@ var listTableRecordsPlugin = ({ context }) => {
|
|
|
7025
7175
|
const listTableRecordsDefinition = createPaginatedFunction(
|
|
7026
7176
|
listTableRecordsPage,
|
|
7027
7177
|
ListTableRecordsOptionsInputSchema,
|
|
7028
|
-
createTelemetryCallback(
|
|
7178
|
+
createTelemetryCallback(
|
|
7179
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
7180
|
+
methodName
|
|
7181
|
+
),
|
|
7029
7182
|
methodName,
|
|
7030
7183
|
DEFAULT_PAGE_SIZE
|
|
7031
7184
|
);
|
|
@@ -7080,9 +7233,9 @@ var CreateTableRecordsOptionsInputSchema = zod.z.union([
|
|
|
7080
7233
|
]).describe(CreateTableRecordsDescription);
|
|
7081
7234
|
|
|
7082
7235
|
// src/plugins/tables/createTableRecords/index.ts
|
|
7083
|
-
var createTableRecordsPlugin = (
|
|
7236
|
+
var createTableRecordsPlugin = (sdk) => {
|
|
7084
7237
|
async function createTableRecords(options) {
|
|
7085
|
-
const { api } = context;
|
|
7238
|
+
const { api } = sdk.context;
|
|
7086
7239
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
7087
7240
|
const translator = await createFieldKeyTranslator({
|
|
7088
7241
|
api,
|
|
@@ -7134,7 +7287,7 @@ var createTableRecordsPlugin = ({ context }) => {
|
|
|
7134
7287
|
createTableRecords,
|
|
7135
7288
|
CreateTableRecordsOptionsInputSchema,
|
|
7136
7289
|
createTelemetryCallback(
|
|
7137
|
-
context.eventEmission.emitMethodCalled,
|
|
7290
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
7138
7291
|
createTableRecords.name
|
|
7139
7292
|
)
|
|
7140
7293
|
);
|
|
@@ -7173,9 +7326,9 @@ var DeleteTableRecordsOptionsInputSchema = zod.z.union([
|
|
|
7173
7326
|
]).describe(DeleteTableRecordsDescription);
|
|
7174
7327
|
|
|
7175
7328
|
// src/plugins/tables/deleteTableRecords/index.ts
|
|
7176
|
-
var deleteTableRecordsPlugin = (
|
|
7329
|
+
var deleteTableRecordsPlugin = (sdk) => {
|
|
7177
7330
|
async function deleteTableRecords(options) {
|
|
7178
|
-
const { api } = context;
|
|
7331
|
+
const { api } = sdk.context;
|
|
7179
7332
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
7180
7333
|
const recordIds = "records" in options ? options.records : options.recordIds;
|
|
7181
7334
|
await api.delete(
|
|
@@ -7208,7 +7361,7 @@ var deleteTableRecordsPlugin = ({ context }) => {
|
|
|
7208
7361
|
deleteTableRecords,
|
|
7209
7362
|
DeleteTableRecordsOptionsInputSchema,
|
|
7210
7363
|
createTelemetryCallback(
|
|
7211
|
-
context.eventEmission.emitMethodCalled,
|
|
7364
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
7212
7365
|
deleteTableRecords.name
|
|
7213
7366
|
)
|
|
7214
7367
|
);
|
|
@@ -7262,9 +7415,9 @@ var UpdateTableRecordsOptionsInputSchema = zod.z.union([
|
|
|
7262
7415
|
]).describe(UpdateTableRecordsDescription);
|
|
7263
7416
|
|
|
7264
7417
|
// src/plugins/tables/updateTableRecords/index.ts
|
|
7265
|
-
var updateTableRecordsPlugin = (
|
|
7418
|
+
var updateTableRecordsPlugin = (sdk) => {
|
|
7266
7419
|
async function updateTableRecords(options) {
|
|
7267
|
-
const { api } = context;
|
|
7420
|
+
const { api } = sdk.context;
|
|
7268
7421
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
7269
7422
|
const translator = await createFieldKeyTranslator({
|
|
7270
7423
|
api,
|
|
@@ -7317,7 +7470,7 @@ var updateTableRecordsPlugin = ({ context }) => {
|
|
|
7317
7470
|
updateTableRecords,
|
|
7318
7471
|
UpdateTableRecordsOptionsInputSchema,
|
|
7319
7472
|
createTelemetryCallback(
|
|
7320
|
-
context.eventEmission.emitMethodCalled,
|
|
7473
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
7321
7474
|
updateTableRecords.name
|
|
7322
7475
|
)
|
|
7323
7476
|
);
|
|
@@ -7343,8 +7496,8 @@ var updateTableRecordsPlugin = ({ context }) => {
|
|
|
7343
7496
|
};
|
|
7344
7497
|
|
|
7345
7498
|
// src/plugins/registry/index.ts
|
|
7346
|
-
var registryPlugin = (
|
|
7347
|
-
const metaKeys = Object.keys(context.meta || {});
|
|
7499
|
+
var registryPlugin = (sdk) => {
|
|
7500
|
+
const metaKeys = Object.keys(sdk.context.meta || {});
|
|
7348
7501
|
const categoryDefinitions = {
|
|
7349
7502
|
account: {
|
|
7350
7503
|
title: "Account"
|
|
@@ -7389,7 +7542,7 @@ var registryPlugin = ({ sdk, context }) => {
|
|
|
7389
7542
|
}
|
|
7390
7543
|
return false;
|
|
7391
7544
|
}).map((key) => {
|
|
7392
|
-
const meta = context.meta[key];
|
|
7545
|
+
const meta = sdk.context.meta[key];
|
|
7393
7546
|
return {
|
|
7394
7547
|
name: key,
|
|
7395
7548
|
description: meta.description,
|
|
@@ -7457,7 +7610,7 @@ var registryPlugin = ({ sdk, context }) => {
|
|
|
7457
7610
|
};
|
|
7458
7611
|
|
|
7459
7612
|
// src/plugins/deprecated/authentications.ts
|
|
7460
|
-
var listAuthenticationsPlugin = (
|
|
7613
|
+
var listAuthenticationsPlugin = (sdk) => ({
|
|
7461
7614
|
listAuthentications: sdk.listConnections,
|
|
7462
7615
|
context: {
|
|
7463
7616
|
meta: {
|
|
@@ -7472,7 +7625,7 @@ var listAuthenticationsPlugin = ({ sdk }) => ({
|
|
|
7472
7625
|
}
|
|
7473
7626
|
}
|
|
7474
7627
|
});
|
|
7475
|
-
var getAuthenticationPlugin = (
|
|
7628
|
+
var getAuthenticationPlugin = (sdk) => ({
|
|
7476
7629
|
getAuthentication: sdk.getConnection,
|
|
7477
7630
|
context: {
|
|
7478
7631
|
meta: {
|
|
@@ -7487,7 +7640,7 @@ var getAuthenticationPlugin = ({ sdk }) => ({
|
|
|
7487
7640
|
}
|
|
7488
7641
|
}
|
|
7489
7642
|
});
|
|
7490
|
-
var findFirstAuthenticationPlugin = (
|
|
7643
|
+
var findFirstAuthenticationPlugin = (sdk) => ({
|
|
7491
7644
|
findFirstAuthentication: sdk.findFirstConnection,
|
|
7492
7645
|
context: {
|
|
7493
7646
|
meta: {
|
|
@@ -7502,7 +7655,7 @@ var findFirstAuthenticationPlugin = ({ sdk }) => ({
|
|
|
7502
7655
|
}
|
|
7503
7656
|
}
|
|
7504
7657
|
});
|
|
7505
|
-
var findUniqueAuthenticationPlugin = (
|
|
7658
|
+
var findUniqueAuthenticationPlugin = (sdk) => ({
|
|
7506
7659
|
findUniqueAuthentication: sdk.findUniqueConnection,
|
|
7507
7660
|
context: {
|
|
7508
7661
|
meta: {
|
|
@@ -7565,9 +7718,9 @@ var GetInputFieldsSchemaSchemaDeprecated = zod.z.object({
|
|
|
7565
7718
|
var GetInputFieldsSchemaInputSchema = zod.z.union([GetInputFieldsSchemaSchema, GetInputFieldsSchemaSchemaDeprecated]).describe(GetInputFieldsSchemaDescription);
|
|
7566
7719
|
|
|
7567
7720
|
// src/plugins/getInputFieldsSchema/index.ts
|
|
7568
|
-
var getInputFieldsSchemaPlugin = (
|
|
7721
|
+
var getInputFieldsSchemaPlugin = (sdk) => {
|
|
7569
7722
|
async function getInputFieldsSchema(options) {
|
|
7570
|
-
const { api, getVersionedImplementationId } = context;
|
|
7723
|
+
const { api, getVersionedImplementationId } = sdk.context;
|
|
7571
7724
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
7572
7725
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
7573
7726
|
const { actionType, connection, connectionId, authenticationId, inputs } = options;
|
|
@@ -7575,7 +7728,7 @@ var getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
|
7575
7728
|
connection,
|
|
7576
7729
|
connectionId,
|
|
7577
7730
|
authenticationId,
|
|
7578
|
-
resolveConnection: context.resolveConnection
|
|
7731
|
+
resolveConnection: sdk.context.resolveConnection
|
|
7579
7732
|
});
|
|
7580
7733
|
const selectedApi = await getVersionedImplementationId(appKey);
|
|
7581
7734
|
if (!selectedApi) {
|
|
@@ -7610,7 +7763,7 @@ var getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
|
7610
7763
|
getInputFieldsSchema,
|
|
7611
7764
|
GetInputFieldsSchemaInputSchema,
|
|
7612
7765
|
createTelemetryCallback(
|
|
7613
|
-
context.eventEmission.emitMethodCalled,
|
|
7766
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
7614
7767
|
getInputFieldsSchema.name
|
|
7615
7768
|
)
|
|
7616
7769
|
);
|
|
@@ -7704,9 +7857,9 @@ function transformNeedChoicesToInputFieldChoiceItem(choice) {
|
|
|
7704
7857
|
value: choice.value
|
|
7705
7858
|
};
|
|
7706
7859
|
}
|
|
7707
|
-
var listInputFieldChoicesPlugin = (
|
|
7860
|
+
var listInputFieldChoicesPlugin = (sdk) => {
|
|
7708
7861
|
async function listInputFieldChoicesPage(options) {
|
|
7709
|
-
const { api, getVersionedImplementationId } = context;
|
|
7862
|
+
const { api, getVersionedImplementationId } = sdk.context;
|
|
7710
7863
|
const appKey = "app" in options ? options.app : options.appKey;
|
|
7711
7864
|
const actionKey = "action" in options ? options.action : options.actionKey;
|
|
7712
7865
|
const inputFieldKey = "inputField" in options ? options.inputField : options.inputFieldKey;
|
|
@@ -7723,7 +7876,7 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
7723
7876
|
connection,
|
|
7724
7877
|
connectionId,
|
|
7725
7878
|
authenticationId,
|
|
7726
|
-
resolveConnection: context.resolveConnection
|
|
7879
|
+
resolveConnection: sdk.context.resolveConnection
|
|
7727
7880
|
});
|
|
7728
7881
|
const selectedApi = await getVersionedImplementationId(appKey);
|
|
7729
7882
|
if (!selectedApi) {
|
|
@@ -7801,7 +7954,10 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
7801
7954
|
const listInputFieldChoicesDefinition = createPaginatedFunction(
|
|
7802
7955
|
listInputFieldChoicesPage,
|
|
7803
7956
|
ListInputFieldChoicesInputSchema,
|
|
7804
|
-
createTelemetryCallback(
|
|
7957
|
+
createTelemetryCallback(
|
|
7958
|
+
sdk.context.eventEmission.emitMethodCalled,
|
|
7959
|
+
methodName
|
|
7960
|
+
),
|
|
7805
7961
|
methodName,
|
|
7806
7962
|
DEFAULT_PAGE_SIZE
|
|
7807
7963
|
);
|
|
@@ -8173,19 +8329,20 @@ function getTransportConfig(options) {
|
|
|
8173
8329
|
endpoint
|
|
8174
8330
|
};
|
|
8175
8331
|
}
|
|
8176
|
-
var eventEmissionPlugin = (
|
|
8332
|
+
var eventEmissionPlugin = (sdk) => {
|
|
8333
|
+
const options = sdk.context.options ?? {};
|
|
8177
8334
|
const defaultTransport = getTransportConfig({
|
|
8178
|
-
trackingBaseUrl:
|
|
8179
|
-
baseUrl:
|
|
8335
|
+
trackingBaseUrl: options.trackingBaseUrl,
|
|
8336
|
+
baseUrl: options.baseUrl
|
|
8180
8337
|
});
|
|
8181
8338
|
const config = {
|
|
8182
|
-
enabled:
|
|
8183
|
-
callContext:
|
|
8339
|
+
enabled: options.eventEmission?.enabled ?? true,
|
|
8340
|
+
callContext: options.eventEmission?.callContext,
|
|
8184
8341
|
transport: (
|
|
8185
8342
|
// If env var is set, use it (defaultTransport will be from env)
|
|
8186
8343
|
globalThis.process?.env?.ZAPIER_SDK_TELEMETRY_TRANSPORT ? defaultTransport : (
|
|
8187
8344
|
// Otherwise, use option transport or default
|
|
8188
|
-
|
|
8345
|
+
options.eventEmission?.transport ?? defaultTransport
|
|
8189
8346
|
)
|
|
8190
8347
|
)
|
|
8191
8348
|
};
|
|
@@ -8193,7 +8350,7 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
8193
8350
|
if (config.enabled) {
|
|
8194
8351
|
try {
|
|
8195
8352
|
const token = await resolveAuthToken({
|
|
8196
|
-
...
|
|
8353
|
+
...options
|
|
8197
8354
|
});
|
|
8198
8355
|
if (token) {
|
|
8199
8356
|
return extractUserIdsFromJwt(token);
|
|
@@ -8443,55 +8600,54 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
8443
8600
|
};
|
|
8444
8601
|
|
|
8445
8602
|
// src/sdk.ts
|
|
8446
|
-
function
|
|
8603
|
+
function createOptionsPlugin(options) {
|
|
8604
|
+
return () => ({ context: { options } });
|
|
8605
|
+
}
|
|
8606
|
+
function createSdk() {
|
|
8607
|
+
return buildSdk({}, { meta: {} });
|
|
8608
|
+
}
|
|
8609
|
+
function buildSdk(properties, context) {
|
|
8610
|
+
const frozenContext = Object.freeze(context);
|
|
8447
8611
|
return {
|
|
8448
|
-
...
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8612
|
+
...properties,
|
|
8613
|
+
get context() {
|
|
8614
|
+
return frozenContext;
|
|
8615
|
+
},
|
|
8616
|
+
getContext: () => frozenContext,
|
|
8617
|
+
// runtime compat shim, not in types
|
|
8618
|
+
addPlugin(plugin) {
|
|
8455
8619
|
const pluginResult = plugin({
|
|
8456
|
-
|
|
8457
|
-
context:
|
|
8458
|
-
...initialContext,
|
|
8459
|
-
// Add the options that createSdk was called with to context
|
|
8460
|
-
options
|
|
8461
|
-
},
|
|
8462
|
-
...addPluginOptions
|
|
8620
|
+
...properties,
|
|
8621
|
+
context: frozenContext
|
|
8463
8622
|
});
|
|
8464
|
-
const { context: pluginContext, ...
|
|
8465
|
-
const
|
|
8466
|
-
let
|
|
8467
|
-
...
|
|
8468
|
-
|
|
8469
|
-
meta: initialContext.meta || {}
|
|
8623
|
+
const { context: pluginContext, ...pluginProperties } = pluginResult;
|
|
8624
|
+
const mergedProperties = { ...properties, ...pluginProperties };
|
|
8625
|
+
let mergedContext = {
|
|
8626
|
+
...context,
|
|
8627
|
+
meta: context.meta || {}
|
|
8470
8628
|
};
|
|
8471
8629
|
if (pluginContext) {
|
|
8472
|
-
const { meta: pluginMeta, ...
|
|
8473
|
-
|
|
8474
|
-
...
|
|
8475
|
-
...
|
|
8630
|
+
const { meta: pluginMeta, ...pluginContextRest } = pluginContext;
|
|
8631
|
+
mergedContext = {
|
|
8632
|
+
...mergedContext,
|
|
8633
|
+
...pluginContextRest
|
|
8476
8634
|
};
|
|
8477
8635
|
if (pluginMeta) {
|
|
8478
|
-
|
|
8479
|
-
...
|
|
8480
|
-
meta: {
|
|
8481
|
-
...newContext.meta,
|
|
8482
|
-
// Existing meta (now guaranteed to exist)
|
|
8483
|
-
...pluginMeta
|
|
8484
|
-
// New meta from plugin
|
|
8485
|
-
}
|
|
8636
|
+
mergedContext = {
|
|
8637
|
+
...mergedContext,
|
|
8638
|
+
meta: { ...mergedContext.meta, ...pluginMeta }
|
|
8486
8639
|
};
|
|
8487
8640
|
}
|
|
8488
8641
|
}
|
|
8489
|
-
return
|
|
8642
|
+
return buildSdk(
|
|
8643
|
+
mergedProperties,
|
|
8644
|
+
mergedContext
|
|
8645
|
+
);
|
|
8490
8646
|
}
|
|
8491
8647
|
};
|
|
8492
8648
|
}
|
|
8493
8649
|
function createZapierSdkWithoutRegistry(options = {}) {
|
|
8494
|
-
return createSdk(options).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(capabilitiesPlugin).addPlugin(connectionsPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(getInputFieldsSchemaPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listConnectionsPlugin).addPlugin(getConnectionPlugin).addPlugin(findFirstConnectionPlugin).addPlugin(findUniqueConnectionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(listTablesPlugin).addPlugin(getTablePlugin).addPlugin(deleteTablePlugin).addPlugin(createTablePlugin).addPlugin(listTableFieldsPlugin).addPlugin(createTableFieldsPlugin).addPlugin(deleteTableFieldsPlugin).addPlugin(getTableRecordPlugin).addPlugin(listTableRecordsPlugin).addPlugin(createTableRecordsPlugin).addPlugin(deleteTableRecordsPlugin).addPlugin(updateTableRecordsPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
|
|
8650
|
+
return createSdk().addPlugin(createOptionsPlugin(options)).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(capabilitiesPlugin).addPlugin(connectionsPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(getInputFieldsSchemaPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listConnectionsPlugin).addPlugin(getConnectionPlugin).addPlugin(findFirstConnectionPlugin).addPlugin(findUniqueConnectionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(listTablesPlugin).addPlugin(getTablePlugin).addPlugin(deleteTablePlugin).addPlugin(createTablePlugin).addPlugin(listTableFieldsPlugin).addPlugin(createTableFieldsPlugin).addPlugin(deleteTableFieldsPlugin).addPlugin(getTableRecordPlugin).addPlugin(listTableRecordsPlugin).addPlugin(createTableRecordsPlugin).addPlugin(deleteTableRecordsPlugin).addPlugin(updateTableRecordsPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
|
|
8495
8651
|
}
|
|
8496
8652
|
function createZapierSdk(options = {}) {
|
|
8497
8653
|
return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
|
|
@@ -8607,6 +8763,7 @@ exports.connectionsPlugin = connectionsPlugin;
|
|
|
8607
8763
|
exports.createBaseEvent = createBaseEvent;
|
|
8608
8764
|
exports.createClientCredentialsPlugin = createClientCredentialsPlugin;
|
|
8609
8765
|
exports.createFunction = createFunction;
|
|
8766
|
+
exports.createOptionsPlugin = createOptionsPlugin;
|
|
8610
8767
|
exports.createSdk = createSdk;
|
|
8611
8768
|
exports.createTableFieldsPlugin = createTableFieldsPlugin;
|
|
8612
8769
|
exports.createTablePlugin = createTablePlugin;
|