@zapier/zapier-sdk 0.87.1 → 0.88.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 +22 -0
- package/README.md +44 -44
- package/dist/{chunk-WVAZCBUJ.mjs → chunk-BLFXMYSW.mjs} +467 -215
- package/dist/{chunk-S6IN256D.cjs → chunk-KQTYZL5Y.cjs} +473 -219
- package/dist/define.d.mts +2 -2
- package/dist/define.d.ts +2 -2
- package/dist/experimental.cjs +354 -346
- package/dist/experimental.d.mts +20 -2
- package/dist/experimental.d.ts +20 -2
- package/dist/experimental.mjs +2 -2
- package/dist/{index-CBvczsOD.d.mts → index-DeefnmJr.d.mts} +221 -28
- package/dist/{index-CBvczsOD.d.ts → index-DeefnmJr.d.ts} +221 -28
- package/dist/index.cjs +282 -274
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
|
@@ -171,12 +171,19 @@ function composeVoid(existing, added) {
|
|
|
171
171
|
isolated.add(composed);
|
|
172
172
|
return composed;
|
|
173
173
|
}
|
|
174
|
+
function composeAnnotators(existing, added) {
|
|
175
|
+
if (!existing) return added;
|
|
176
|
+
if (!added) return existing;
|
|
177
|
+
return (ctx) => ({ ...existing(ctx), ...added(ctx) });
|
|
178
|
+
}
|
|
174
179
|
function buildHooks(existing, added) {
|
|
175
180
|
const result = {};
|
|
176
181
|
const start2 = composeVoid(existing.onMethodStart, added.onMethodStart);
|
|
177
182
|
if (start2) result.onMethodStart = start2;
|
|
178
183
|
const end = composeVoid(existing.onMethodEnd, added.onMethodEnd);
|
|
179
184
|
if (end) result.onMethodEnd = end;
|
|
185
|
+
const annotator = composeAnnotators(existing.annotator, added.annotator);
|
|
186
|
+
if (annotator) result.annotator = annotator;
|
|
180
187
|
return result;
|
|
181
188
|
}
|
|
182
189
|
function createDeprecationLogger(tag) {
|
|
@@ -578,11 +585,14 @@ function generateCallId() {
|
|
|
578
585
|
}
|
|
579
586
|
return null;
|
|
580
587
|
}
|
|
581
|
-
function rootCallContext(
|
|
588
|
+
function rootCallContext({
|
|
589
|
+
callOrigin = "surface"
|
|
590
|
+
} = {}) {
|
|
582
591
|
return {
|
|
583
592
|
callId: generateCallId(),
|
|
584
593
|
depth: 0,
|
|
585
594
|
annotations: {},
|
|
595
|
+
callOrigin,
|
|
586
596
|
[CALL_CONTEXT_BRAND]: true
|
|
587
597
|
};
|
|
588
598
|
}
|
|
@@ -591,6 +601,7 @@ function childCallContext(parent) {
|
|
|
591
601
|
callId: parent.callId,
|
|
592
602
|
depth: parent.depth + 1,
|
|
593
603
|
annotations: {},
|
|
604
|
+
callOrigin: parent.callOrigin,
|
|
594
605
|
[CALL_CONTEXT_BRAND]: true
|
|
595
606
|
};
|
|
596
607
|
}
|
|
@@ -612,6 +623,28 @@ var INTERNAL_CALL = Symbol("kitcore.internalCall");
|
|
|
612
623
|
function resolveCallContext(secondArg) {
|
|
613
624
|
return isCallContext(secondArg) ? secondArg : rootCallContext();
|
|
614
625
|
}
|
|
626
|
+
var hookAnnotatorReentrancy = 0;
|
|
627
|
+
function applyAnnotations({
|
|
628
|
+
context,
|
|
629
|
+
methodName,
|
|
630
|
+
input,
|
|
631
|
+
hookAnnotator,
|
|
632
|
+
methodAnnotator
|
|
633
|
+
}) {
|
|
634
|
+
if (hookAnnotator && !isInsideObserver() && context.depth === 0 && context.callOrigin !== "internal" && hookAnnotatorReentrancy === 0) {
|
|
635
|
+
hookAnnotatorReentrancy++;
|
|
636
|
+
try {
|
|
637
|
+
Object.assign(context.annotations, hookAnnotator({ methodName, input }));
|
|
638
|
+
} catch {
|
|
639
|
+
} finally {
|
|
640
|
+
hookAnnotatorReentrancy--;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
try {
|
|
644
|
+
Object.assign(context.annotations, methodAnnotator?.(input));
|
|
645
|
+
} catch {
|
|
646
|
+
}
|
|
647
|
+
}
|
|
615
648
|
function signalDeprecation(context, methodName, getDeprecation) {
|
|
616
649
|
if (isInsideObserver()) return;
|
|
617
650
|
const deprecation = getDeprecation?.();
|
|
@@ -637,7 +670,7 @@ function normalizeError(error, adaptError) {
|
|
|
637
670
|
);
|
|
638
671
|
}
|
|
639
672
|
function createFunction(coreFn, options) {
|
|
640
|
-
const { sdk, schema, name, getDeprecation } = options;
|
|
673
|
+
const { sdk, schema, name, annotator, getDeprecation } = options;
|
|
641
674
|
const functionName = name || coreFn.name;
|
|
642
675
|
const namedFunctions = {
|
|
643
676
|
[functionName]: async function(callOptions) {
|
|
@@ -651,14 +684,26 @@ function createFunction(coreFn, options) {
|
|
|
651
684
|
const normalizedOptions = callOptions ?? {};
|
|
652
685
|
const args = [normalizedOptions];
|
|
653
686
|
const depth = Math.max(context.depth, getCurrentDepth());
|
|
654
|
-
const
|
|
687
|
+
const insideObserver = isInsideObserver();
|
|
688
|
+
const hooks = insideObserver ? void 0 : sdk.context.hooks;
|
|
655
689
|
const adaptError = resolveCoreOptions(sdk.context)?.adaptError;
|
|
656
|
-
|
|
690
|
+
applyAnnotations({
|
|
691
|
+
context,
|
|
692
|
+
methodName: functionName,
|
|
693
|
+
input: normalizedOptions,
|
|
694
|
+
hookAnnotator: hooks?.annotator,
|
|
695
|
+
methodAnnotator: annotator
|
|
696
|
+
});
|
|
697
|
+
const hookBase = {
|
|
657
698
|
methodName: functionName,
|
|
658
699
|
args,
|
|
659
700
|
isPaginated: false,
|
|
660
|
-
depth
|
|
661
|
-
|
|
701
|
+
depth,
|
|
702
|
+
callId: context.callId,
|
|
703
|
+
callOrigin: context.callOrigin,
|
|
704
|
+
annotations: context.annotations
|
|
705
|
+
};
|
|
706
|
+
hooks?.onMethodStart?.({ ...hookBase });
|
|
662
707
|
try {
|
|
663
708
|
let result;
|
|
664
709
|
if (schema) {
|
|
@@ -680,20 +725,14 @@ function createFunction(coreFn, options) {
|
|
|
680
725
|
result = await coreFn(normalizedOptions, context);
|
|
681
726
|
}
|
|
682
727
|
hooks?.onMethodEnd?.({
|
|
683
|
-
|
|
684
|
-
args,
|
|
685
|
-
isPaginated: false,
|
|
686
|
-
depth,
|
|
728
|
+
...hookBase,
|
|
687
729
|
durationMs: Date.now() - startTime
|
|
688
730
|
});
|
|
689
731
|
return result;
|
|
690
732
|
} catch (error) {
|
|
691
733
|
const normalizedError = normalizeError(error, adaptError);
|
|
692
734
|
hooks?.onMethodEnd?.({
|
|
693
|
-
|
|
694
|
-
args,
|
|
695
|
-
isPaginated: false,
|
|
696
|
-
depth,
|
|
735
|
+
...hookBase,
|
|
697
736
|
durationMs: Date.now() - startTime,
|
|
698
737
|
error: normalizedError
|
|
699
738
|
});
|
|
@@ -705,7 +744,7 @@ function createFunction(coreFn, options) {
|
|
|
705
744
|
return namedFunctions[functionName];
|
|
706
745
|
}
|
|
707
746
|
function createRawFunction(coreFn, options) {
|
|
708
|
-
const { sdk, name, schema, positional, getDeprecation } = options;
|
|
747
|
+
const { sdk, name, schema, positional, annotator, getDeprecation } = options;
|
|
709
748
|
return function(rawInput) {
|
|
710
749
|
const internal = arguments[1];
|
|
711
750
|
const context = resolveCallContext(internal);
|
|
@@ -715,23 +754,32 @@ function createRawFunction(coreFn, options) {
|
|
|
715
754
|
return runInMethodScope(() => {
|
|
716
755
|
const startTime = Date.now();
|
|
717
756
|
const depth = Math.max(context.depth, getCurrentDepth());
|
|
718
|
-
const
|
|
757
|
+
const insideObserver = isInsideObserver();
|
|
758
|
+
const hooks = insideObserver ? void 0 : sdk.context.hooks;
|
|
719
759
|
const adaptError = resolveCoreOptions(sdk.context)?.adaptError;
|
|
720
760
|
const input = schema ? rawInput ?? {} : rawInput;
|
|
761
|
+
applyAnnotations({
|
|
762
|
+
context,
|
|
763
|
+
methodName: name,
|
|
764
|
+
input,
|
|
765
|
+
hookAnnotator: hooks?.annotator,
|
|
766
|
+
methodAnnotator: annotator
|
|
767
|
+
});
|
|
721
768
|
const record = input;
|
|
722
769
|
const args = positional ? positional.filter((key) => record?.[key] !== void 0).map((key) => record?.[key]) : [input];
|
|
723
|
-
|
|
770
|
+
const hookBase = {
|
|
724
771
|
methodName: name,
|
|
725
772
|
args,
|
|
726
773
|
isPaginated: false,
|
|
727
|
-
depth
|
|
728
|
-
|
|
774
|
+
depth,
|
|
775
|
+
callId: context.callId,
|
|
776
|
+
callOrigin: context.callOrigin,
|
|
777
|
+
annotations: context.annotations
|
|
778
|
+
};
|
|
779
|
+
hooks?.onMethodStart?.({ ...hookBase });
|
|
729
780
|
const fireEnd = (error) => {
|
|
730
781
|
hooks?.onMethodEnd?.({
|
|
731
|
-
|
|
732
|
-
args,
|
|
733
|
-
isPaginated: false,
|
|
734
|
-
depth,
|
|
782
|
+
...hookBase,
|
|
735
783
|
durationMs: Date.now() - startTime,
|
|
736
784
|
...error ? { error } : {}
|
|
737
785
|
});
|
|
@@ -798,7 +846,15 @@ function createPageFunction(coreFn, {
|
|
|
798
846
|
return namedFunctions[functionName];
|
|
799
847
|
}
|
|
800
848
|
function createPaginatedFunction(coreFn, options) {
|
|
801
|
-
const {
|
|
849
|
+
const {
|
|
850
|
+
sdk,
|
|
851
|
+
schema,
|
|
852
|
+
name,
|
|
853
|
+
defaultPageSize,
|
|
854
|
+
adaptPage,
|
|
855
|
+
annotator,
|
|
856
|
+
getDeprecation
|
|
857
|
+
} = options;
|
|
802
858
|
const pageFunction = createPageFunction(coreFn, { sdk, adaptPage });
|
|
803
859
|
const functionName = name || coreFn.name;
|
|
804
860
|
const namedFunctions = {
|
|
@@ -813,14 +869,26 @@ function createPaginatedFunction(coreFn, options) {
|
|
|
813
869
|
const normalizedOptions = callOptions ?? {};
|
|
814
870
|
const args = [normalizedOptions];
|
|
815
871
|
const depth = Math.max(context.depth, getCurrentDepth());
|
|
816
|
-
const
|
|
872
|
+
const insideObserver = isInsideObserver();
|
|
873
|
+
const hooks = insideObserver ? void 0 : sdk.context.hooks;
|
|
817
874
|
const adaptError = resolveCoreOptions(sdk.context)?.adaptError;
|
|
818
|
-
|
|
875
|
+
applyAnnotations({
|
|
876
|
+
context,
|
|
877
|
+
methodName: functionName,
|
|
878
|
+
input: normalizedOptions,
|
|
879
|
+
hookAnnotator: hooks?.annotator,
|
|
880
|
+
methodAnnotator: annotator
|
|
881
|
+
});
|
|
882
|
+
const hookBase = {
|
|
819
883
|
methodName: functionName,
|
|
820
884
|
args,
|
|
821
885
|
isPaginated: true,
|
|
822
|
-
depth
|
|
823
|
-
|
|
886
|
+
depth,
|
|
887
|
+
callId: context.callId,
|
|
888
|
+
callOrigin: context.callOrigin,
|
|
889
|
+
annotations: context.annotations
|
|
890
|
+
};
|
|
891
|
+
hooks?.onMethodStart?.({ ...hookBase });
|
|
824
892
|
try {
|
|
825
893
|
const validatedOptions = {
|
|
826
894
|
...normalizedOptions,
|
|
@@ -846,19 +914,13 @@ function createPaginatedFunction(coreFn, options) {
|
|
|
846
914
|
firstPagePromise.then(
|
|
847
915
|
() => {
|
|
848
916
|
hooks.onMethodEnd({
|
|
849
|
-
|
|
850
|
-
args,
|
|
851
|
-
isPaginated: true,
|
|
852
|
-
depth,
|
|
917
|
+
...hookBase,
|
|
853
918
|
durationMs: Date.now() - startTime
|
|
854
919
|
});
|
|
855
920
|
},
|
|
856
921
|
(error) => {
|
|
857
922
|
hooks.onMethodEnd({
|
|
858
|
-
|
|
859
|
-
args,
|
|
860
|
-
isPaginated: true,
|
|
861
|
-
depth,
|
|
923
|
+
...hookBase,
|
|
862
924
|
durationMs: Date.now() - startTime,
|
|
863
925
|
error: error instanceof Error ? error : new Error(String(error))
|
|
864
926
|
});
|
|
@@ -897,10 +959,7 @@ function createPaginatedFunction(coreFn, options) {
|
|
|
897
959
|
} catch (error) {
|
|
898
960
|
const normalizedError = normalizeError(error, adaptError);
|
|
899
961
|
hooks?.onMethodEnd?.({
|
|
900
|
-
|
|
901
|
-
args,
|
|
902
|
-
isPaginated: true,
|
|
903
|
-
depth,
|
|
962
|
+
...hookBase,
|
|
904
963
|
durationMs: Date.now() - startTime,
|
|
905
964
|
error: normalizedError
|
|
906
965
|
});
|
|
@@ -1316,6 +1375,7 @@ function defineMethod(config) {
|
|
|
1316
1375
|
meta: collectLeafMeta(config),
|
|
1317
1376
|
resolvers: config.resolvers,
|
|
1318
1377
|
formatter: config.formatter,
|
|
1378
|
+
annotator: config.annotator,
|
|
1319
1379
|
output: config.output,
|
|
1320
1380
|
positional: config.positional,
|
|
1321
1381
|
setup: config.setup,
|
|
@@ -1475,7 +1535,8 @@ function defineHook(config) {
|
|
|
1475
1535
|
setup: config.setup,
|
|
1476
1536
|
dispose: config.dispose,
|
|
1477
1537
|
wrap: config.wrap,
|
|
1478
|
-
observe: config.observe
|
|
1538
|
+
observe: config.observe,
|
|
1539
|
+
annotator: config.annotator
|
|
1479
1540
|
};
|
|
1480
1541
|
}
|
|
1481
1542
|
function declarePlugin(config) {
|
|
@@ -1901,7 +1962,14 @@ function collectPlugins(root, materialized = /* @__PURE__ */ new Set(), configur
|
|
|
1901
1962
|
}
|
|
1902
1963
|
return byId;
|
|
1903
1964
|
}
|
|
1904
|
-
function bindValue(
|
|
1965
|
+
function bindValue({
|
|
1966
|
+
target,
|
|
1967
|
+
key,
|
|
1968
|
+
entry,
|
|
1969
|
+
bindMode = "surface",
|
|
1970
|
+
ctx,
|
|
1971
|
+
frameworkOrigin = false
|
|
1972
|
+
}) {
|
|
1905
1973
|
if (entry.pluginType === "property" && entry.getValue) {
|
|
1906
1974
|
Object.defineProperty(target, key, {
|
|
1907
1975
|
get: entry.getValue,
|
|
@@ -1909,7 +1977,7 @@ function bindValue(target, key, entry, callType = "surface", ctx) {
|
|
|
1909
1977
|
configurable: true
|
|
1910
1978
|
});
|
|
1911
1979
|
} else {
|
|
1912
|
-
const value =
|
|
1980
|
+
const value = bindMode === "internal" && entry.pluginType === "method" ? entry.bindInternal?.({ ctx, frameworkOrigin }) ?? entry.internalValue ?? entry.value : entry.value;
|
|
1913
1981
|
Object.defineProperty(target, key, {
|
|
1914
1982
|
value,
|
|
1915
1983
|
writable: true,
|
|
@@ -1927,7 +1995,12 @@ function buildSurface(context, ...maps) {
|
|
|
1927
1995
|
sdk[CONTEXT] = context;
|
|
1928
1996
|
return sdk;
|
|
1929
1997
|
}
|
|
1930
|
-
function buildImports(
|
|
1998
|
+
function buildImports({
|
|
1999
|
+
plugins,
|
|
2000
|
+
importBindings,
|
|
2001
|
+
ctx,
|
|
2002
|
+
frameworkOrigin = false
|
|
2003
|
+
}) {
|
|
1931
2004
|
const imports = {};
|
|
1932
2005
|
for (const { binding, id, optional } of importBindings) {
|
|
1933
2006
|
const entry = plugins[id];
|
|
@@ -1940,10 +2013,31 @@ function buildImports(plugins, importBindings, ctx) {
|
|
|
1940
2013
|
});
|
|
1941
2014
|
continue;
|
|
1942
2015
|
}
|
|
1943
|
-
bindValue(
|
|
2016
|
+
bindValue({
|
|
2017
|
+
target: imports,
|
|
2018
|
+
key: binding,
|
|
2019
|
+
entry,
|
|
2020
|
+
bindMode: "internal",
|
|
2021
|
+
ctx,
|
|
2022
|
+
frameworkOrigin
|
|
2023
|
+
});
|
|
1944
2024
|
}
|
|
1945
2025
|
return imports;
|
|
1946
2026
|
}
|
|
2027
|
+
function bindInternalTwin({
|
|
2028
|
+
ctx,
|
|
2029
|
+
frameworkOrigin,
|
|
2030
|
+
withContext,
|
|
2031
|
+
internalValue
|
|
2032
|
+
}) {
|
|
2033
|
+
if (ctx) {
|
|
2034
|
+
return (...args) => withContext(childCallContext(ctx))(...args);
|
|
2035
|
+
}
|
|
2036
|
+
if (frameworkOrigin) {
|
|
2037
|
+
return (...args) => withContext(rootCallContext({ callOrigin: "internal" }))(...args);
|
|
2038
|
+
}
|
|
2039
|
+
return internalValue;
|
|
2040
|
+
}
|
|
1947
2041
|
function mirrorLegacyRootKeys(context, rootKeys, meta) {
|
|
1948
2042
|
const exports = {};
|
|
1949
2043
|
for (const [name, value] of Object.entries(rootKeys)) {
|
|
@@ -2007,7 +2101,11 @@ function bindResolver(resolver, plugins) {
|
|
|
2007
2101
|
case "info":
|
|
2008
2102
|
return { type: "info", text: resolver.text };
|
|
2009
2103
|
case "object": {
|
|
2010
|
-
const imports = buildImports(
|
|
2104
|
+
const imports = buildImports({
|
|
2105
|
+
plugins,
|
|
2106
|
+
importBindings: resolver.importBindings,
|
|
2107
|
+
frameworkOrigin: true
|
|
2108
|
+
});
|
|
2011
2109
|
const bound = {
|
|
2012
2110
|
type: "object",
|
|
2013
2111
|
requireParameters: resolver.requireParameters
|
|
@@ -2048,7 +2146,11 @@ function bindResolver(resolver, plugins) {
|
|
|
2048
2146
|
return bound;
|
|
2049
2147
|
}
|
|
2050
2148
|
case "dynamic": {
|
|
2051
|
-
const imports = buildImports(
|
|
2149
|
+
const imports = buildImports({
|
|
2150
|
+
plugins,
|
|
2151
|
+
importBindings: resolver.importBindings,
|
|
2152
|
+
frameworkOrigin: true
|
|
2153
|
+
});
|
|
2052
2154
|
const {
|
|
2053
2155
|
getContext: getContext2,
|
|
2054
2156
|
listItems,
|
|
@@ -2103,7 +2205,11 @@ function bindDefinitions(definitions, plugins) {
|
|
|
2103
2205
|
return out;
|
|
2104
2206
|
}
|
|
2105
2207
|
function bindFormatter(formatter, plugins) {
|
|
2106
|
-
const imports = buildImports(
|
|
2208
|
+
const imports = buildImports({
|
|
2209
|
+
plugins,
|
|
2210
|
+
importBindings: formatter.importBindings,
|
|
2211
|
+
frameworkOrigin: true
|
|
2212
|
+
});
|
|
2107
2213
|
const bound = { format: formatter.format };
|
|
2108
2214
|
const { getContext: getContext2 } = formatter;
|
|
2109
2215
|
if (getContext2)
|
|
@@ -2190,17 +2296,32 @@ function buildMethodEntries(descriptors, context, states) {
|
|
|
2190
2296
|
// Replaced below; never called.
|
|
2191
2297
|
value: () => void 0
|
|
2192
2298
|
};
|
|
2193
|
-
const callRun = (input, ctx) =>
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2299
|
+
const callRun = (input, ctx) => {
|
|
2300
|
+
const callContext = ctx ?? rootCallContext();
|
|
2301
|
+
return descriptor.run({
|
|
2302
|
+
imports: buildImports({
|
|
2303
|
+
plugins,
|
|
2304
|
+
importBindings: descriptor.importBindings,
|
|
2305
|
+
ctx: callContext
|
|
2306
|
+
}),
|
|
2307
|
+
state: states.get(id),
|
|
2308
|
+
input,
|
|
2309
|
+
callContext,
|
|
2310
|
+
annotate: (metadata) => {
|
|
2311
|
+
Object.assign(callContext.annotations, metadata);
|
|
2312
|
+
}
|
|
2313
|
+
});
|
|
2314
|
+
};
|
|
2198
2315
|
const fold = (coreFn) => (input, ctx) => {
|
|
2199
2316
|
let next = (i) => coreFn(i, ctx);
|
|
2200
2317
|
for (const wrap of entry.chain) {
|
|
2201
2318
|
const inner = next;
|
|
2202
2319
|
next = (i) => wrap.run({
|
|
2203
|
-
imports: buildImports(
|
|
2320
|
+
imports: buildImports({
|
|
2321
|
+
plugins,
|
|
2322
|
+
importBindings: wrap.owner.importBindings,
|
|
2323
|
+
ctx
|
|
2324
|
+
}),
|
|
2204
2325
|
next: inner,
|
|
2205
2326
|
input: i,
|
|
2206
2327
|
// Overwritten by the chain item's own closure with the owning
|
|
@@ -2211,6 +2332,8 @@ function buildMethodEntries(descriptors, context, states) {
|
|
|
2211
2332
|
return next(input);
|
|
2212
2333
|
};
|
|
2213
2334
|
const sdk = { context };
|
|
2335
|
+
const methodAnnotator = descriptor.annotator;
|
|
2336
|
+
const boundAnnotator = methodAnnotator ? (input) => methodAnnotator({ input }) : void 0;
|
|
2214
2337
|
if (out.type === "list") {
|
|
2215
2338
|
entry.value = createPaginatedFunction(
|
|
2216
2339
|
fold(callRun),
|
|
@@ -2220,6 +2343,7 @@ function buildMethodEntries(descriptors, context, states) {
|
|
|
2220
2343
|
name: descriptor.name,
|
|
2221
2344
|
defaultPageSize: out.defaultPageSize,
|
|
2222
2345
|
adaptPage: out.adaptPage,
|
|
2346
|
+
annotator: boundAnnotator,
|
|
2223
2347
|
getDeprecation: () => entry.meta?.deprecation
|
|
2224
2348
|
}
|
|
2225
2349
|
);
|
|
@@ -2231,6 +2355,7 @@ function buildMethodEntries(descriptors, context, states) {
|
|
|
2231
2355
|
sdk,
|
|
2232
2356
|
schema: descriptor.inputSchema,
|
|
2233
2357
|
name: descriptor.name,
|
|
2358
|
+
annotator: boundAnnotator,
|
|
2234
2359
|
getDeprecation: () => entry.meta?.deprecation
|
|
2235
2360
|
}
|
|
2236
2361
|
);
|
|
@@ -2242,6 +2367,7 @@ function buildMethodEntries(descriptors, context, states) {
|
|
|
2242
2367
|
name: descriptor.name,
|
|
2243
2368
|
schema: descriptor.skipInputValidation ? void 0 : descriptor.inputSchema,
|
|
2244
2369
|
positional: descriptor.positional,
|
|
2370
|
+
annotator: boundAnnotator,
|
|
2245
2371
|
// The boundary reads the deprecation LIVE off the entry, so a
|
|
2246
2372
|
// deprecation merged after build (defineMethodOverride, addPlugin)
|
|
2247
2373
|
// fires too.
|
|
@@ -2262,12 +2388,22 @@ function buildMethodEntries(descriptors, context, states) {
|
|
|
2262
2388
|
const internalValue = (...args) => canonicalValue(pack(args), INTERNAL_CALL);
|
|
2263
2389
|
entry.value = (...args) => canonicalValue(pack(args));
|
|
2264
2390
|
entry.internalValue = internalValue;
|
|
2265
|
-
entry.bindInternal = (
|
|
2391
|
+
entry.bindInternal = (opts) => bindInternalTwin({
|
|
2392
|
+
...opts,
|
|
2393
|
+
withContext: (context2) => {
|
|
2394
|
+
return (...args) => canonicalValue(pack(args), context2);
|
|
2395
|
+
},
|
|
2396
|
+
internalValue
|
|
2397
|
+
});
|
|
2266
2398
|
entry.positional = names;
|
|
2267
2399
|
} else {
|
|
2268
2400
|
const internalValue = (input) => canonicalValue(input, INTERNAL_CALL);
|
|
2269
2401
|
entry.internalValue = internalValue;
|
|
2270
|
-
entry.bindInternal = (
|
|
2402
|
+
entry.bindInternal = (opts) => bindInternalTwin({
|
|
2403
|
+
...opts,
|
|
2404
|
+
withContext: (context2) => (input) => canonicalValue(input, context2),
|
|
2405
|
+
internalValue
|
|
2406
|
+
});
|
|
2271
2407
|
}
|
|
2272
2408
|
plugins[id] = entry;
|
|
2273
2409
|
}
|
|
@@ -2293,8 +2429,14 @@ function buildEagerArtifacts(descriptors, context, states) {
|
|
|
2293
2429
|
if (!dispose) return;
|
|
2294
2430
|
context.disposers?.push({
|
|
2295
2431
|
id,
|
|
2432
|
+
// Teardown is framework-internal: an SDK method a `dispose` calls runs
|
|
2433
|
+
// on an internal-origin root (dropped from telemetry).
|
|
2296
2434
|
dispose: (input) => dispose({
|
|
2297
|
-
imports: buildImports(
|
|
2435
|
+
imports: buildImports({
|
|
2436
|
+
plugins,
|
|
2437
|
+
importBindings: descriptor.importBindings,
|
|
2438
|
+
frameworkOrigin: true
|
|
2439
|
+
}),
|
|
2298
2440
|
state: states.get(id),
|
|
2299
2441
|
input
|
|
2300
2442
|
})
|
|
@@ -2304,7 +2446,10 @@ function buildEagerArtifacts(descriptors, context, states) {
|
|
|
2304
2446
|
states.set(
|
|
2305
2447
|
id,
|
|
2306
2448
|
descriptor.setup ? descriptor.setup({
|
|
2307
|
-
imports: buildImports(
|
|
2449
|
+
imports: buildImports({
|
|
2450
|
+
plugins,
|
|
2451
|
+
importBindings: descriptor.importBindings
|
|
2452
|
+
})
|
|
2308
2453
|
}) : void 0
|
|
2309
2454
|
);
|
|
2310
2455
|
recordDisposer();
|
|
@@ -2316,14 +2461,20 @@ function buildEagerArtifacts(descriptors, context, states) {
|
|
|
2316
2461
|
states.set(
|
|
2317
2462
|
id,
|
|
2318
2463
|
descriptor.setup ? descriptor.setup({
|
|
2319
|
-
imports: buildImports(
|
|
2464
|
+
imports: buildImports({
|
|
2465
|
+
plugins,
|
|
2466
|
+
importBindings: descriptor.importBindings
|
|
2467
|
+
})
|
|
2320
2468
|
}) : void 0
|
|
2321
2469
|
);
|
|
2322
2470
|
} else {
|
|
2323
2471
|
states.set(
|
|
2324
2472
|
id,
|
|
2325
2473
|
descriptor.setup ? descriptor.setup({
|
|
2326
|
-
imports: buildImports(
|
|
2474
|
+
imports: buildImports({
|
|
2475
|
+
plugins,
|
|
2476
|
+
importBindings: descriptor.importBindings
|
|
2477
|
+
})
|
|
2327
2478
|
}) : void 0
|
|
2328
2479
|
);
|
|
2329
2480
|
if (descriptor.privileged) {
|
|
@@ -2341,7 +2492,7 @@ function buildEagerArtifacts(descriptors, context, states) {
|
|
|
2341
2492
|
pluginType: "property",
|
|
2342
2493
|
name: descriptor.name,
|
|
2343
2494
|
getValue: () => get({
|
|
2344
|
-
imports: buildImports(plugins, importBindings),
|
|
2495
|
+
imports: buildImports({ plugins, importBindings }),
|
|
2345
2496
|
state: states.get(id)
|
|
2346
2497
|
}),
|
|
2347
2498
|
meta: descriptor.meta,
|
|
@@ -2377,7 +2528,7 @@ function resolvePlugin(sdk, ref) {
|
|
|
2377
2528
|
return entry.getValue();
|
|
2378
2529
|
}
|
|
2379
2530
|
if (entry.pluginType === "method" && entry.internalValue) {
|
|
2380
|
-
return entry.internalValue;
|
|
2531
|
+
return entry.bindInternal?.({ frameworkOrigin: true }) ?? entry.internalValue;
|
|
2381
2532
|
}
|
|
2382
2533
|
return entry.value;
|
|
2383
2534
|
}
|
|
@@ -2412,7 +2563,7 @@ function resolveAggregates(descriptors, context) {
|
|
|
2412
2563
|
if (descriptor.pluginType !== "aggregate") continue;
|
|
2413
2564
|
const exports = {};
|
|
2414
2565
|
for (const [binding, child] of Object.entries(descriptor.exports)) {
|
|
2415
|
-
bindValue(exports, binding, plugins[child.id]);
|
|
2566
|
+
bindValue({ target: exports, key: binding, entry: plugins[child.id] });
|
|
2416
2567
|
}
|
|
2417
2568
|
plugins[id] = { pluginType: "aggregate", name: descriptor.name, exports };
|
|
2418
2569
|
}
|
|
@@ -2455,23 +2606,39 @@ function assembleHooks(descriptors, context, states) {
|
|
|
2455
2606
|
const plugins = context.plugins;
|
|
2456
2607
|
for (const id of topoOrder(descriptors)) {
|
|
2457
2608
|
const descriptor = descriptors.get(id);
|
|
2458
|
-
if (!descriptor || descriptor.pluginType !== "hook" || !descriptor.observe) {
|
|
2609
|
+
if (!descriptor || descriptor.pluginType !== "hook" || !descriptor.observe && !descriptor.annotator) {
|
|
2459
2610
|
continue;
|
|
2460
2611
|
}
|
|
2461
|
-
const { observe } = descriptor;
|
|
2462
|
-
const imports = buildImports(plugins, descriptor.importBindings);
|
|
2612
|
+
const { observe, annotator } = descriptor;
|
|
2463
2613
|
const state = states.get(id);
|
|
2464
2614
|
const contributed = {};
|
|
2465
|
-
if (observe
|
|
2466
|
-
const
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2615
|
+
if (observe?.onMethodStart || observe?.onMethodEnd) {
|
|
2616
|
+
const imports = buildImports({
|
|
2617
|
+
plugins,
|
|
2618
|
+
importBindings: descriptor.importBindings,
|
|
2619
|
+
frameworkOrigin: true
|
|
2620
|
+
});
|
|
2621
|
+
if (observe.onMethodStart) {
|
|
2622
|
+
const onStart = observe.onMethodStart;
|
|
2623
|
+
contributed.onMethodStart = (input) => {
|
|
2624
|
+
runIsolatedObserver(() => onStart({ imports, input, state }));
|
|
2625
|
+
};
|
|
2626
|
+
}
|
|
2627
|
+
if (observe.onMethodEnd) {
|
|
2628
|
+
const onEnd = observe.onMethodEnd;
|
|
2629
|
+
contributed.onMethodEnd = (input) => {
|
|
2630
|
+
runIsolatedObserver(() => onEnd({ imports, input, state }));
|
|
2631
|
+
};
|
|
2632
|
+
}
|
|
2470
2633
|
}
|
|
2471
|
-
if (
|
|
2472
|
-
const
|
|
2473
|
-
contributed.
|
|
2474
|
-
|
|
2634
|
+
if (annotator) {
|
|
2635
|
+
const annotatorFn = annotator;
|
|
2636
|
+
contributed.annotator = ({ methodName, input }) => {
|
|
2637
|
+
try {
|
|
2638
|
+
return annotatorFn({ methodName, input, state });
|
|
2639
|
+
} catch {
|
|
2640
|
+
return {};
|
|
2641
|
+
}
|
|
2475
2642
|
};
|
|
2476
2643
|
}
|
|
2477
2644
|
context.hooks = buildHooks(context.hooks, contributed);
|
|
@@ -2505,7 +2672,11 @@ function createSdk(root, options) {
|
|
|
2505
2672
|
pluginSurface = plugins2[plugin.id].exports;
|
|
2506
2673
|
} else {
|
|
2507
2674
|
pluginSurface = {};
|
|
2508
|
-
bindValue(
|
|
2675
|
+
bindValue({
|
|
2676
|
+
target: pluginSurface,
|
|
2677
|
+
key: plugin.name,
|
|
2678
|
+
entry: plugins2[plugin.id]
|
|
2679
|
+
});
|
|
2509
2680
|
}
|
|
2510
2681
|
for (const key of Object.keys(legacyExports)) context.surface[key] = key;
|
|
2511
2682
|
if (plugin.pluginType === "aggregate") {
|
|
@@ -2522,7 +2693,7 @@ function createSdk(root, options) {
|
|
|
2522
2693
|
if (root.pluginType === "method" || root.pluginType === "property") {
|
|
2523
2694
|
context.surface[root.name] = root.id;
|
|
2524
2695
|
const sdk = buildSurface(context);
|
|
2525
|
-
bindValue(sdk, root.name, plugins[root.id]);
|
|
2696
|
+
bindValue({ target: sdk, key: root.name, entry: plugins[root.id] });
|
|
2526
2697
|
return sdk;
|
|
2527
2698
|
}
|
|
2528
2699
|
if (root.pluginType === "aggregate")
|
|
@@ -2554,7 +2725,7 @@ function addModelPlugin(sdk, plugin, options = {}) {
|
|
|
2554
2725
|
context.surface[binding] = child.id;
|
|
2555
2726
|
}
|
|
2556
2727
|
} else {
|
|
2557
|
-
bindValue(sdk, plugin.name, entry);
|
|
2728
|
+
bindValue({ target: sdk, key: plugin.name, entry });
|
|
2558
2729
|
context.surface[plugin.name] = plugin.id;
|
|
2559
2730
|
}
|
|
2560
2731
|
}
|
|
@@ -3853,7 +4024,7 @@ function getZapierSdkService() {
|
|
|
3853
4024
|
}
|
|
3854
4025
|
var MAX_PAGE_LIMIT = 1e4;
|
|
3855
4026
|
var DEFAULT_PAGE_SIZE = 100;
|
|
3856
|
-
var
|
|
4027
|
+
var DEFAULT_ACTION_TIMEOUT_MILLISECONDS = 18e4;
|
|
3857
4028
|
function parseIntEnvVar(name) {
|
|
3858
4029
|
const value = globalThis.process?.env?.[name];
|
|
3859
4030
|
if (value === void 0) return void 0;
|
|
@@ -3867,7 +4038,10 @@ function parseIntEnvVar(name) {
|
|
|
3867
4038
|
return parsed;
|
|
3868
4039
|
}
|
|
3869
4040
|
var ZAPIER_MAX_NETWORK_RETRIES = parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRIES") ?? 3;
|
|
3870
|
-
var
|
|
4041
|
+
var maxNetworkRetryDelaySecondsEnv = parseIntEnvVar(
|
|
4042
|
+
"ZAPIER_MAX_NETWORK_RETRY_DELAY_SECONDS"
|
|
4043
|
+
);
|
|
4044
|
+
var ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS = (maxNetworkRetryDelaySecondsEnv != null ? maxNetworkRetryDelaySecondsEnv * 1e3 : void 0) ?? parseIntEnvVar("ZAPIER_MAX_NETWORK_RETRY_DELAY_MS") ?? 6e4;
|
|
3871
4045
|
var MAX_CONCURRENCY_LIMIT = 1e4;
|
|
3872
4046
|
function parseConcurrencyEnvVar(name) {
|
|
3873
4047
|
const value = globalThis.process?.env?.[name];
|
|
@@ -3898,7 +4072,7 @@ function getZapierDefaultApprovalMode() {
|
|
|
3898
4072
|
const isInteractive = !!globalThis.process?.stdin?.isTTY && !!globalThis.process?.stdout?.isTTY;
|
|
3899
4073
|
return isInteractive ? "poll" : "throw";
|
|
3900
4074
|
}
|
|
3901
|
-
var
|
|
4075
|
+
var DEFAULT_APPROVAL_TIMEOUT_MILLISECONDS = 10 * 60 * 1e3;
|
|
3902
4076
|
var DEFAULT_MAX_APPROVAL_RETRIES = 2;
|
|
3903
4077
|
|
|
3904
4078
|
// src/types/properties.ts
|
|
@@ -3940,8 +4114,11 @@ var OffsetPropertySchema = z.number().int().min(0).default(0).describe("Number o
|
|
|
3940
4114
|
var OutputPropertySchema = z.string().describe("Output file path");
|
|
3941
4115
|
var DebugPropertySchema = z.boolean().default(false).describe("Enable debug logging");
|
|
3942
4116
|
var ParamsPropertySchema = z.record(z.string(), z.unknown()).describe("Additional parameters");
|
|
3943
|
-
var
|
|
3944
|
-
`Maximum time to wait for action completion in
|
|
4117
|
+
var ActionTimeoutSecondsPropertySchema = z.number().min(1).optional().describe(
|
|
4118
|
+
`Maximum time to wait for action completion in seconds (default: ${DEFAULT_ACTION_TIMEOUT_MILLISECONDS / 1e3})`
|
|
4119
|
+
);
|
|
4120
|
+
var ActionTimeoutMillisecondsPropertySchema = z.number().min(1e3).optional().describe(
|
|
4121
|
+
`Maximum time to wait for action completion in milliseconds (default: ${DEFAULT_ACTION_TIMEOUT_MILLISECONDS})`
|
|
3945
4122
|
);
|
|
3946
4123
|
var TablePropertySchema = withPositional(
|
|
3947
4124
|
z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table")
|
|
@@ -4349,11 +4526,18 @@ var ActionExecutionInputSchema = z.object({
|
|
|
4349
4526
|
authenticationId: AuthenticationIdPropertySchema.optional().meta({
|
|
4350
4527
|
deprecated: true
|
|
4351
4528
|
}),
|
|
4352
|
-
|
|
4529
|
+
timeoutSeconds: ActionTimeoutSecondsPropertySchema,
|
|
4530
|
+
/** @deprecated Use `timeoutSeconds` instead. */
|
|
4531
|
+
timeoutMs: ActionTimeoutMillisecondsPropertySchema.meta({
|
|
4532
|
+
deprecated: true
|
|
4533
|
+
})
|
|
4353
4534
|
}).describe(
|
|
4354
4535
|
"Execute an action with the given inputs for the bound app, as an alternative to runAction"
|
|
4355
4536
|
).meta({
|
|
4356
|
-
aliases: {
|
|
4537
|
+
aliases: {
|
|
4538
|
+
connectionId: "connection",
|
|
4539
|
+
authenticationId: "connection"
|
|
4540
|
+
}
|
|
4357
4541
|
});
|
|
4358
4542
|
var AppFactoryInputSchema = z.object({
|
|
4359
4543
|
/** @deprecated Use `connection` instead. */
|
|
@@ -4531,19 +4715,19 @@ function createDebugFetch(options) {
|
|
|
4531
4715
|
|
|
4532
4716
|
// src/utils/retry-utils.ts
|
|
4533
4717
|
var MAX_CONSECUTIVE_ERRORS = 3;
|
|
4534
|
-
var
|
|
4535
|
-
var
|
|
4718
|
+
var BASE_ERROR_BACKOFF_MILLISECONDS = 1e3;
|
|
4719
|
+
var BASE_EXPONENTIAL_BACKOFF_MILLISECONDS = 1e3;
|
|
4536
4720
|
var JITTER_FACTOR = 0.5;
|
|
4537
4721
|
function calculateErrorBackoffMs(baseInterval, errorCount) {
|
|
4538
4722
|
const jitter = Math.random() * JITTER_FACTOR * baseInterval;
|
|
4539
4723
|
const errorBackoff = Math.min(
|
|
4540
|
-
|
|
4724
|
+
BASE_ERROR_BACKOFF_MILLISECONDS * (errorCount / 2),
|
|
4541
4725
|
baseInterval * 2
|
|
4542
4726
|
// Cap error backoff at 2x the base interval
|
|
4543
4727
|
);
|
|
4544
4728
|
return Math.floor(baseInterval + jitter + errorBackoff);
|
|
4545
4729
|
}
|
|
4546
|
-
function calculateExponentialBackoffMs(attempt, baseDelayMs =
|
|
4730
|
+
function calculateExponentialBackoffMs(attempt, baseDelayMs = BASE_EXPONENTIAL_BACKOFF_MILLISECONDS) {
|
|
4547
4731
|
const baseDelay = baseDelayMs * Math.pow(2, attempt - 1);
|
|
4548
4732
|
const jitter = Math.random() * JITTER_FACTOR * baseDelay;
|
|
4549
4733
|
return Math.floor(baseDelay + jitter);
|
|
@@ -4646,11 +4830,11 @@ function combineAbortSignals({
|
|
|
4646
4830
|
}
|
|
4647
4831
|
|
|
4648
4832
|
// src/api/polling.ts
|
|
4649
|
-
var
|
|
4833
|
+
var DEFAULT_TIMEOUT_MILLISECONDS = 18e4;
|
|
4650
4834
|
var DEFAULT_SUCCESS_STATUS = 200;
|
|
4651
4835
|
var DEFAULT_PENDING_STATUS = 202;
|
|
4652
|
-
var
|
|
4653
|
-
var
|
|
4836
|
+
var DEFAULT_INITIAL_DELAY_MILLISECONDS = 50;
|
|
4837
|
+
var DEFAULT_MAX_POLLING_INTERVAL_MILLISECONDS = 6e4;
|
|
4654
4838
|
var POLLING_STAGES = [
|
|
4655
4839
|
[125, 125],
|
|
4656
4840
|
// Up to 125ms: poll every 125ms
|
|
@@ -4666,11 +4850,11 @@ var POLLING_STAGES = [
|
|
|
4666
4850
|
// Up to 60s: poll every 5s
|
|
4667
4851
|
[18e4, 1e4]
|
|
4668
4852
|
// Up to 3min: poll every 10s
|
|
4669
|
-
// Beyond 3min: use
|
|
4853
|
+
// Beyond 3min: use DEFAULT_MAX_POLLING_INTERVAL_MILLISECONDS (60s)
|
|
4670
4854
|
];
|
|
4671
4855
|
function getPollingInterval(elapsedMs) {
|
|
4672
4856
|
const stage = POLLING_STAGES.find(([threshold]) => elapsedMs < threshold);
|
|
4673
|
-
return stage ? stage[1] :
|
|
4857
|
+
return stage ? stage[1] : DEFAULT_MAX_POLLING_INTERVAL_MILLISECONDS;
|
|
4674
4858
|
}
|
|
4675
4859
|
function makeAbortError() {
|
|
4676
4860
|
if (typeof DOMException !== "undefined") {
|
|
@@ -4728,8 +4912,8 @@ var processResponse = async (response, successStatus, pendingStatus, isPending,
|
|
|
4728
4912
|
async function pollUntilComplete(options) {
|
|
4729
4913
|
const {
|
|
4730
4914
|
fetchPoll,
|
|
4731
|
-
timeoutMs =
|
|
4732
|
-
initialDelay =
|
|
4915
|
+
timeoutMs = DEFAULT_TIMEOUT_MILLISECONDS,
|
|
4916
|
+
initialDelay = DEFAULT_INITIAL_DELAY_MILLISECONDS,
|
|
4733
4917
|
successStatus = DEFAULT_SUCCESS_STATUS,
|
|
4734
4918
|
pendingStatus = DEFAULT_PENDING_STATUS,
|
|
4735
4919
|
isPending,
|
|
@@ -5176,7 +5360,7 @@ function clearTokenCache() {
|
|
|
5176
5360
|
cachedCliLogin = void 0;
|
|
5177
5361
|
cachedDefaultCache = void 0;
|
|
5178
5362
|
}
|
|
5179
|
-
var
|
|
5363
|
+
var TOKEN_EXPIRATION_BUFFER_MILLISECONDS = 5 * 60 * 1e3;
|
|
5180
5364
|
async function resolveCache(options) {
|
|
5181
5365
|
if (options.cache) return options.cache;
|
|
5182
5366
|
if (cachedDefaultCache !== void 0) return cachedDefaultCache;
|
|
@@ -5197,7 +5381,7 @@ async function resolveCache(options) {
|
|
|
5197
5381
|
}
|
|
5198
5382
|
function entryIsValid(entry) {
|
|
5199
5383
|
if (entry.expiresAt === void 0) return true;
|
|
5200
|
-
return entry.expiresAt > Date.now() +
|
|
5384
|
+
return entry.expiresAt > Date.now() + TOKEN_EXPIRATION_BUFFER_MILLISECONDS;
|
|
5201
5385
|
}
|
|
5202
5386
|
async function readCachedToken(cacheKey, cache) {
|
|
5203
5387
|
const cached = await cache.get(cacheKey);
|
|
@@ -5813,7 +5997,7 @@ function parseDeprecationDate(value) {
|
|
|
5813
5997
|
}
|
|
5814
5998
|
|
|
5815
5999
|
// src/sdk-version.ts
|
|
5816
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
6000
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.88.1" : void 0) || "unknown";
|
|
5817
6001
|
|
|
5818
6002
|
// src/utils/open-url.ts
|
|
5819
6003
|
var nodePrefix = "node:";
|
|
@@ -5924,7 +6108,7 @@ var PollApprovalResponseSchema = z.object({
|
|
|
5924
6108
|
mode: ApprovalModeSchema.optional(),
|
|
5925
6109
|
reason: z.string().optional()
|
|
5926
6110
|
});
|
|
5927
|
-
var
|
|
6111
|
+
var APPROVAL_MAX_POLLING_INTERVAL_MILLISECONDS = 5e3;
|
|
5928
6112
|
function validateSdkPath(path) {
|
|
5929
6113
|
if (!path.startsWith("/") || path.startsWith("//")) {
|
|
5930
6114
|
throw new ZapierValidationError(
|
|
@@ -6089,7 +6273,7 @@ var ZapierApiClient = class {
|
|
|
6089
6273
|
}
|
|
6090
6274
|
const rateLimitInfo = parseRateLimitHeaders(response);
|
|
6091
6275
|
const delayMs = rateLimitInfo.retryAfterMs ?? calculateExponentialBackoffMs(retries + 1);
|
|
6092
|
-
if (delayMs > this.
|
|
6276
|
+
if (delayMs > this.maxNetworkRetryDelayMilliseconds || retries >= this.maxNetworkRetries) {
|
|
6093
6277
|
throw new ZapierRateLimitError("Rate limited", {
|
|
6094
6278
|
statusCode: 429,
|
|
6095
6279
|
rateLimit: rateLimitInfo,
|
|
@@ -6346,8 +6530,8 @@ var ZapierApiClient = class {
|
|
|
6346
6530
|
authRequired: options.authRequired,
|
|
6347
6531
|
signal: options.signal
|
|
6348
6532
|
}),
|
|
6349
|
-
initialDelay: options.initialDelay,
|
|
6350
|
-
timeoutMs: options.timeoutMs,
|
|
6533
|
+
initialDelay: options.initialDelayMilliseconds ?? options.initialDelay,
|
|
6534
|
+
timeoutMs: options.timeoutMilliseconds ?? options.timeoutMs,
|
|
6351
6535
|
successStatus: options.successStatus,
|
|
6352
6536
|
pendingStatus: options.pendingStatus,
|
|
6353
6537
|
isPending: options.isPending,
|
|
@@ -6356,7 +6540,7 @@ var ZapierApiClient = class {
|
|
|
6356
6540
|
});
|
|
6357
6541
|
};
|
|
6358
6542
|
this.maxNetworkRetries = options.maxNetworkRetries ?? ZAPIER_MAX_NETWORK_RETRIES;
|
|
6359
|
-
this.
|
|
6543
|
+
this.maxNetworkRetryDelayMilliseconds = options.maxNetworkRetryDelayMilliseconds ?? options.maxNetworkRetryDelayMs ?? ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS;
|
|
6360
6544
|
const requested = options.maxConcurrentRequests;
|
|
6361
6545
|
const limit = requested === void 0 || Number.isNaN(requested) ? ZAPIER_MAX_CONCURRENT_REQUESTS : requested;
|
|
6362
6546
|
if (limit !== Infinity && (!Number.isInteger(limit) || limit < 1 || limit > MAX_CONCURRENCY_LIMIT)) {
|
|
@@ -6931,7 +7115,7 @@ var ZapierApiClient = class {
|
|
|
6931
7115
|
}
|
|
6932
7116
|
await openApproval(approval.approval_url);
|
|
6933
7117
|
}
|
|
6934
|
-
const timeoutMs = this.options.approvalTimeoutMs ??
|
|
7118
|
+
const timeoutMs = this.options.approvalTimeoutMilliseconds ?? this.options.approvalTimeoutMs ?? DEFAULT_APPROVAL_TIMEOUT_MILLISECONDS;
|
|
6935
7119
|
let streamAbortController;
|
|
6936
7120
|
let streamPromise;
|
|
6937
7121
|
let removeStreamAbortListener;
|
|
@@ -6971,7 +7155,7 @@ var ZapierApiClient = class {
|
|
|
6971
7155
|
})
|
|
6972
7156
|
),
|
|
6973
7157
|
timeoutMs,
|
|
6974
|
-
maxPollingIntervalMs:
|
|
7158
|
+
maxPollingIntervalMs: APPROVAL_MAX_POLLING_INTERVAL_MILLISECONDS,
|
|
6975
7159
|
signal,
|
|
6976
7160
|
isPending: (body2) => {
|
|
6977
7161
|
const parsed = PollApprovalResponseSchema.safeParse(body2);
|
|
@@ -7151,8 +7335,10 @@ var apiPlugin = defineProperty({
|
|
|
7151
7335
|
onEvent,
|
|
7152
7336
|
debug = false,
|
|
7153
7337
|
maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES,
|
|
7154
|
-
|
|
7338
|
+
maxNetworkRetryDelaySeconds,
|
|
7339
|
+
maxNetworkRetryDelayMs,
|
|
7155
7340
|
maxConcurrentRequests = ZAPIER_MAX_CONCURRENT_REQUESTS,
|
|
7341
|
+
approvalTimeoutSeconds,
|
|
7156
7342
|
approvalTimeoutMs,
|
|
7157
7343
|
maxApprovalRetries,
|
|
7158
7344
|
approvalMode,
|
|
@@ -7167,9 +7353,9 @@ var apiPlugin = defineProperty({
|
|
|
7167
7353
|
fetch: customFetch,
|
|
7168
7354
|
onEvent,
|
|
7169
7355
|
maxNetworkRetries,
|
|
7170
|
-
maxNetworkRetryDelayMs,
|
|
7356
|
+
maxNetworkRetryDelayMilliseconds: (maxNetworkRetryDelaySeconds != null ? maxNetworkRetryDelaySeconds * 1e3 : maxNetworkRetryDelayMs) ?? ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS,
|
|
7171
7357
|
maxConcurrentRequests,
|
|
7172
|
-
approvalTimeoutMs,
|
|
7358
|
+
approvalTimeoutMilliseconds: approvalTimeoutSeconds != null ? approvalTimeoutSeconds * 1e3 : approvalTimeoutMs,
|
|
7173
7359
|
maxApprovalRetries,
|
|
7174
7360
|
approvalMode,
|
|
7175
7361
|
openAutoModeApprovalsInBrowser,
|
|
@@ -7877,9 +8063,13 @@ var FetchInitZapierFieldsSchema = z.object({
|
|
|
7877
8063
|
deprecated: true
|
|
7878
8064
|
}),
|
|
7879
8065
|
callbackUrl: z.string().optional().describe("URL to send async response to (makes request async)"),
|
|
8066
|
+
maxTimeSeconds: z.number().int().positive().optional().describe(
|
|
8067
|
+
"Maximum seconds to wait for a response. Honored on a best-effort basis; the server may silently enforce a lower ceiling."
|
|
8068
|
+
),
|
|
8069
|
+
/** @deprecated Use `maxTimeSeconds` instead. */
|
|
7880
8070
|
maxTime: z.number().int().positive().optional().describe(
|
|
7881
8071
|
"Maximum seconds to wait for a response. Honored on a best-effort basis; the server may silently enforce a lower ceiling."
|
|
7882
|
-
)
|
|
8072
|
+
).meta({ deprecated: true })
|
|
7883
8073
|
});
|
|
7884
8074
|
var FetchInitSchema = z.object({
|
|
7885
8075
|
method: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).optional().describe("HTTP method for the request (defaults to GET)"),
|
|
@@ -7895,7 +8085,11 @@ var FetchInitSchema = z.object({
|
|
|
7895
8085
|
}).extend(FetchInitZapierFieldsSchema.shape).optional().describe(
|
|
7896
8086
|
"Request options including method, headers, body, and authentication"
|
|
7897
8087
|
).meta({
|
|
7898
|
-
aliases: {
|
|
8088
|
+
aliases: {
|
|
8089
|
+
connectionId: "connection",
|
|
8090
|
+
authenticationId: "connection",
|
|
8091
|
+
maxTime: "maxTimeSeconds"
|
|
8092
|
+
}
|
|
7899
8093
|
});
|
|
7900
8094
|
var FetchInputSchema = z.object({
|
|
7901
8095
|
url: FetchUrlSchema,
|
|
@@ -7946,7 +8140,7 @@ function rewrapIfMaxTimeTimeout({
|
|
|
7946
8140
|
const reason = abortSignal.reason;
|
|
7947
8141
|
if (!reason || reason.name !== "TimeoutError") return error;
|
|
7948
8142
|
return new ZapierTimeoutError(
|
|
7949
|
-
`fetch timed out after ${maxTimeSeconds}s (
|
|
8143
|
+
`fetch timed out after ${maxTimeSeconds}s (maxTimeSeconds)`,
|
|
7950
8144
|
{ cause: error }
|
|
7951
8145
|
);
|
|
7952
8146
|
}
|
|
@@ -8011,9 +8205,11 @@ var fetchPlugin = defineMethod({
|
|
|
8011
8205
|
connection,
|
|
8012
8206
|
authenticationId,
|
|
8013
8207
|
callbackUrl,
|
|
8208
|
+
maxTimeSeconds: maxTimeSecondsInput,
|
|
8014
8209
|
maxTime,
|
|
8015
8210
|
...fetchInit
|
|
8016
8211
|
} = init || {};
|
|
8212
|
+
const maxTimeSeconds = maxTimeSecondsInput ?? maxTime;
|
|
8017
8213
|
const resolvedConnectionId = await resolveConnectionId({
|
|
8018
8214
|
connectionId,
|
|
8019
8215
|
connection,
|
|
@@ -8042,13 +8238,13 @@ var fetchPlugin = defineMethod({
|
|
|
8042
8238
|
if (callbackUrl) {
|
|
8043
8239
|
headers["X-Relay-Callback-Url"] = callbackUrl;
|
|
8044
8240
|
}
|
|
8045
|
-
if (
|
|
8046
|
-
headers["X-Zapier-Sdk-Max-Time"] = String(
|
|
8241
|
+
if (maxTimeSeconds !== void 0) {
|
|
8242
|
+
headers["X-Zapier-Sdk-Max-Time"] = String(maxTimeSeconds);
|
|
8047
8243
|
}
|
|
8048
8244
|
const upstreamUrl = new URL(url).toString();
|
|
8049
8245
|
const method = (fetchInit.method ?? "GET").toUpperCase();
|
|
8050
8246
|
const abortHandle = buildAbortHandle({
|
|
8051
|
-
maxTimeSeconds
|
|
8247
|
+
maxTimeSeconds,
|
|
8052
8248
|
callerSignal: fetchInit.signal
|
|
8053
8249
|
});
|
|
8054
8250
|
try {
|
|
@@ -8078,7 +8274,7 @@ var fetchPlugin = defineMethod({
|
|
|
8078
8274
|
throw rewrapIfMaxTimeTimeout({
|
|
8079
8275
|
error,
|
|
8080
8276
|
abortSignal: abortHandle?.signal,
|
|
8081
|
-
maxTimeSeconds
|
|
8277
|
+
maxTimeSeconds
|
|
8082
8278
|
});
|
|
8083
8279
|
} finally {
|
|
8084
8280
|
abortHandle?.dispose();
|
|
@@ -8098,7 +8294,9 @@ var RunActionBaseSchema = z.object({
|
|
|
8098
8294
|
inputs: InputsPropertySchema.optional().describe(
|
|
8099
8295
|
"Input parameters for the action"
|
|
8100
8296
|
),
|
|
8101
|
-
|
|
8297
|
+
timeoutSeconds: ActionTimeoutSecondsPropertySchema,
|
|
8298
|
+
/** @deprecated Use `timeoutSeconds` instead. */
|
|
8299
|
+
timeoutMs: ActionTimeoutMillisecondsPropertySchema.meta({ deprecated: true }),
|
|
8102
8300
|
pageSize: z.number().min(1).optional().describe("Number of results per page"),
|
|
8103
8301
|
maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
8104
8302
|
cursor: z.string().optional().describe("Cursor to start from")
|
|
@@ -9729,18 +9927,6 @@ var tableSortResolver = defineResolver({
|
|
|
9729
9927
|
}
|
|
9730
9928
|
});
|
|
9731
9929
|
|
|
9732
|
-
// src/plugins/eventEmission/method-metadata.ts
|
|
9733
|
-
var SCOPE_KEY = "methodMetadata";
|
|
9734
|
-
function setMethodMetadata(metadata) {
|
|
9735
|
-
const scope2 = getCurrentScope();
|
|
9736
|
-
if (!scope2) return;
|
|
9737
|
-
const existing = scope2[SCOPE_KEY];
|
|
9738
|
-
scope2[SCOPE_KEY] = { ...existing, ...metadata };
|
|
9739
|
-
}
|
|
9740
|
-
function getMethodMetadata() {
|
|
9741
|
-
return getCurrentScope()?.[SCOPE_KEY];
|
|
9742
|
-
}
|
|
9743
|
-
|
|
9744
9930
|
// src/plugins/listActions/index.ts
|
|
9745
9931
|
var listActionsPlugin = defineMethod({
|
|
9746
9932
|
name: "listActions",
|
|
@@ -9758,7 +9944,7 @@ var listActionsPlugin = defineMethod({
|
|
|
9758
9944
|
// of listing every action. `getAction` (where `actionType` is required) keeps
|
|
9759
9945
|
// the resolver.
|
|
9760
9946
|
resolvers: { app: appKeyResolver },
|
|
9761
|
-
run: async ({ imports, input }) => {
|
|
9947
|
+
run: async ({ imports, input, annotate }) => {
|
|
9762
9948
|
const api = imports.api;
|
|
9763
9949
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
9764
9950
|
const appKey = "app" in input ? input.app : input.appKey;
|
|
@@ -9769,10 +9955,7 @@ var listActionsPlugin = defineMethod({
|
|
|
9769
9955
|
{ configType: "current_implementation_id" }
|
|
9770
9956
|
);
|
|
9771
9957
|
}
|
|
9772
|
-
|
|
9773
|
-
selectedApi,
|
|
9774
|
-
operationType: input.actionType ?? null
|
|
9775
|
-
});
|
|
9958
|
+
annotate({ selectedApi });
|
|
9776
9959
|
const data = await api.get(
|
|
9777
9960
|
"/zapier/api/v4/implementations/",
|
|
9778
9961
|
{
|
|
@@ -9827,10 +10010,6 @@ var getActionPlugin = defineMethod({
|
|
|
9827
10010
|
const appKey = "app" in input ? input.app : input.appKey;
|
|
9828
10011
|
const actionKey = "action" in input ? input.action : input.actionKey;
|
|
9829
10012
|
const { actionType } = input;
|
|
9830
|
-
setMethodMetadata({
|
|
9831
|
-
operationType: actionType,
|
|
9832
|
-
operationKey: actionKey
|
|
9833
|
-
});
|
|
9834
10013
|
for await (const action of imports.listActions({ app: appKey }).items()) {
|
|
9835
10014
|
if ((action.key === actionKey || action.id === actionKey) && action.action_type === actionType) {
|
|
9836
10015
|
return { data: action };
|
|
@@ -9852,7 +10031,7 @@ async function executeAction(actionOptions) {
|
|
|
9852
10031
|
executionOptions,
|
|
9853
10032
|
cursor,
|
|
9854
10033
|
connectionId,
|
|
9855
|
-
|
|
10034
|
+
timeoutMilliseconds
|
|
9856
10035
|
} = actionOptions;
|
|
9857
10036
|
const runRequestData = {
|
|
9858
10037
|
selected_api: selectedApi,
|
|
@@ -9888,7 +10067,7 @@ async function executeAction(actionOptions) {
|
|
|
9888
10067
|
return await api.poll(`/zapier/api/actions/v1/runs/${runId}`, {
|
|
9889
10068
|
successStatus: 200,
|
|
9890
10069
|
pendingStatus: 202,
|
|
9891
|
-
|
|
10070
|
+
timeoutMilliseconds: timeoutMilliseconds ?? DEFAULT_ACTION_TIMEOUT_MILLISECONDS,
|
|
9892
10071
|
resource: { type: "run", id: runId },
|
|
9893
10072
|
isPending: (result) => {
|
|
9894
10073
|
const data = result?.data;
|
|
@@ -9897,7 +10076,7 @@ async function executeAction(actionOptions) {
|
|
|
9897
10076
|
resultExtractor: (result) => result.data
|
|
9898
10077
|
});
|
|
9899
10078
|
}
|
|
9900
|
-
var
|
|
10079
|
+
var CONTEXT_CACHE_TTL_MILLISECONDS = 6e4;
|
|
9901
10080
|
var CONTEXT_CACHE_MAX_SIZE = 500;
|
|
9902
10081
|
var runActionPlugin = defineMethod({
|
|
9903
10082
|
name: "runAction",
|
|
@@ -9923,9 +10102,10 @@ var runActionPlugin = defineMethod({
|
|
|
9923
10102
|
inputs: inputsResolver
|
|
9924
10103
|
},
|
|
9925
10104
|
// A per-SDK-instance TTL cache of resolved (selectedApi, actionId), built once
|
|
9926
|
-
// in setup so it persists across calls.
|
|
9927
|
-
// (`
|
|
9928
|
-
|
|
10105
|
+
// in setup so it persists across calls. The imports it resolves through
|
|
10106
|
+
// (`manifest.getVersionedImplementationId`, `getAction`) are threaded in per
|
|
10107
|
+
// call from `run`, not captured here.
|
|
10108
|
+
setup: () => {
|
|
9929
10109
|
const cache = /* @__PURE__ */ new Map();
|
|
9930
10110
|
function evictIfNeeded() {
|
|
9931
10111
|
if (cache.size < CONTEXT_CACHE_MAX_SIZE) return;
|
|
@@ -9945,7 +10125,7 @@ var runActionPlugin = defineMethod({
|
|
|
9945
10125
|
if (!evictedAny && oldestKey) cache.delete(oldestKey);
|
|
9946
10126
|
}
|
|
9947
10127
|
async function resolveRunActionContext(options) {
|
|
9948
|
-
const { appKey, actionKey, actionType } = options;
|
|
10128
|
+
const { imports, appKey, actionKey, actionType } = options;
|
|
9949
10129
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
9950
10130
|
const selectedApi = await getVersionedImplementationId(appKey);
|
|
9951
10131
|
if (!selectedApi) {
|
|
@@ -9978,13 +10158,13 @@ var runActionPlugin = defineMethod({
|
|
|
9978
10158
|
evictIfNeeded();
|
|
9979
10159
|
cache.set(contextKey, {
|
|
9980
10160
|
promise: pending,
|
|
9981
|
-
expiresAt: Date.now() +
|
|
10161
|
+
expiresAt: Date.now() + CONTEXT_CACHE_TTL_MILLISECONDS
|
|
9982
10162
|
});
|
|
9983
10163
|
return pending;
|
|
9984
10164
|
}
|
|
9985
10165
|
return { getRunActionContext };
|
|
9986
10166
|
},
|
|
9987
|
-
run: async ({ imports, input, state }) => {
|
|
10167
|
+
run: async ({ imports, input, state, annotate }) => {
|
|
9988
10168
|
const api = imports.api;
|
|
9989
10169
|
const resolveConnection = imports.connections.resolveConnection;
|
|
9990
10170
|
const appKey = "app" in input ? input.app : input.appKey;
|
|
@@ -9995,9 +10175,9 @@ var runActionPlugin = defineMethod({
|
|
|
9995
10175
|
connection,
|
|
9996
10176
|
authenticationId,
|
|
9997
10177
|
inputs = {},
|
|
9998
|
-
cursor
|
|
9999
|
-
timeoutMs
|
|
10178
|
+
cursor
|
|
10000
10179
|
} = input;
|
|
10180
|
+
const timeoutMilliseconds = input.timeoutSeconds != null ? input.timeoutSeconds * 1e3 : input.timeoutMs;
|
|
10001
10181
|
const resolvedConnectionId = await resolveConnectionId({
|
|
10002
10182
|
connectionId,
|
|
10003
10183
|
connection,
|
|
@@ -10005,15 +10185,12 @@ var runActionPlugin = defineMethod({
|
|
|
10005
10185
|
resolveConnection
|
|
10006
10186
|
});
|
|
10007
10187
|
const { selectedApi, actionId } = await state.getRunActionContext({
|
|
10188
|
+
imports,
|
|
10008
10189
|
appKey,
|
|
10009
10190
|
actionKey,
|
|
10010
10191
|
actionType
|
|
10011
10192
|
});
|
|
10012
|
-
|
|
10013
|
-
selectedApi,
|
|
10014
|
-
operationType: actionType,
|
|
10015
|
-
operationKey: actionKey
|
|
10016
|
-
});
|
|
10193
|
+
annotate({ selectedApi });
|
|
10017
10194
|
const result = await executeAction({
|
|
10018
10195
|
api,
|
|
10019
10196
|
selectedApi,
|
|
@@ -10025,7 +10202,7 @@ var runActionPlugin = defineMethod({
|
|
|
10025
10202
|
executionOptions: { inputs },
|
|
10026
10203
|
cursor,
|
|
10027
10204
|
connectionId: resolvedConnectionId,
|
|
10028
|
-
|
|
10205
|
+
timeoutMilliseconds
|
|
10029
10206
|
});
|
|
10030
10207
|
if (result.errors && result.errors.length > 0) {
|
|
10031
10208
|
const errorMessage2 = result.errors.map(
|
|
@@ -10082,6 +10259,7 @@ function createActionFunction(appKey, actionType, actionKey, imports, pinnedAuth
|
|
|
10082
10259
|
connectionId: providedConnectionId,
|
|
10083
10260
|
connection: providedConnection,
|
|
10084
10261
|
authenticationId: providedAuthenticationId,
|
|
10262
|
+
timeoutSeconds,
|
|
10085
10263
|
timeoutMs
|
|
10086
10264
|
} = actionOptions;
|
|
10087
10265
|
const { connectionId, connection } = resolveProxyConnection({
|
|
@@ -10098,6 +10276,7 @@ function createActionFunction(appKey, actionType, actionKey, imports, pinnedAuth
|
|
|
10098
10276
|
action: actionKey,
|
|
10099
10277
|
inputs,
|
|
10100
10278
|
connection: connectionId ?? connection,
|
|
10279
|
+
timeoutSeconds,
|
|
10101
10280
|
timeoutMs
|
|
10102
10281
|
});
|
|
10103
10282
|
};
|
|
@@ -10647,7 +10826,11 @@ var listActionInputFieldsPlugin = defineMethod({
|
|
|
10647
10826
|
// metadata; the engine permits a resolver importing its host.
|
|
10648
10827
|
inputs: inputsAllOptionalResolver
|
|
10649
10828
|
},
|
|
10650
|
-
run: async ({
|
|
10829
|
+
run: async ({
|
|
10830
|
+
imports,
|
|
10831
|
+
input,
|
|
10832
|
+
annotate
|
|
10833
|
+
}) => {
|
|
10651
10834
|
const api = imports.api;
|
|
10652
10835
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
10653
10836
|
const resolveConnection = imports.connections.resolveConnection;
|
|
@@ -10667,11 +10850,7 @@ var listActionInputFieldsPlugin = defineMethod({
|
|
|
10667
10850
|
{ configType: "current_implementation_id" }
|
|
10668
10851
|
);
|
|
10669
10852
|
}
|
|
10670
|
-
|
|
10671
|
-
selectedApi,
|
|
10672
|
-
operationType: actionType,
|
|
10673
|
-
operationKey: actionKey
|
|
10674
|
-
});
|
|
10853
|
+
annotate({ selectedApi });
|
|
10675
10854
|
const { data: action } = await imports.getAction({
|
|
10676
10855
|
app: appKey,
|
|
10677
10856
|
actionType,
|
|
@@ -10782,7 +10961,11 @@ var listActionInputFieldChoicesPlugin = defineMethod({
|
|
|
10782
10961
|
inputField: inputFieldKeyResolver,
|
|
10783
10962
|
inputs: inputsAllOptionalResolver
|
|
10784
10963
|
},
|
|
10785
|
-
run: async ({
|
|
10964
|
+
run: async ({
|
|
10965
|
+
imports,
|
|
10966
|
+
input,
|
|
10967
|
+
annotate
|
|
10968
|
+
}) => {
|
|
10786
10969
|
const api = imports.api;
|
|
10787
10970
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
10788
10971
|
const resolveConnection = imports.connections.resolveConnection;
|
|
@@ -10811,11 +10994,7 @@ var listActionInputFieldChoicesPlugin = defineMethod({
|
|
|
10811
10994
|
{ configType: "current_implementation_id" }
|
|
10812
10995
|
);
|
|
10813
10996
|
}
|
|
10814
|
-
|
|
10815
|
-
selectedApi,
|
|
10816
|
-
operationType: actionType,
|
|
10817
|
-
operationKey: actionKey
|
|
10818
|
-
});
|
|
10997
|
+
annotate({ selectedApi });
|
|
10819
10998
|
const { data: action } = await imports.getAction({
|
|
10820
10999
|
app: appKey,
|
|
10821
11000
|
actionType,
|
|
@@ -10944,7 +11123,8 @@ var getActionInputFieldsSchemaPlugin = defineMethod({
|
|
|
10944
11123
|
},
|
|
10945
11124
|
run: async ({
|
|
10946
11125
|
imports,
|
|
10947
|
-
input
|
|
11126
|
+
input,
|
|
11127
|
+
annotate
|
|
10948
11128
|
}) => {
|
|
10949
11129
|
const api = imports.api;
|
|
10950
11130
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
@@ -10965,11 +11145,7 @@ var getActionInputFieldsSchemaPlugin = defineMethod({
|
|
|
10965
11145
|
{ configType: "current_implementation_id" }
|
|
10966
11146
|
);
|
|
10967
11147
|
}
|
|
10968
|
-
|
|
10969
|
-
selectedApi,
|
|
10970
|
-
operationType: actionType,
|
|
10971
|
-
operationKey: actionKey
|
|
10972
|
-
});
|
|
11148
|
+
annotate({ selectedApi });
|
|
10973
11149
|
const { data: action } = await imports.getAction({
|
|
10974
11150
|
app: appKey,
|
|
10975
11151
|
actionType,
|
|
@@ -11092,7 +11268,11 @@ var listConnectionsPlugin = defineMethod({
|
|
|
11092
11268
|
adaptPage: adaptZapierPage,
|
|
11093
11269
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
11094
11270
|
},
|
|
11095
|
-
run: async ({
|
|
11271
|
+
run: async ({
|
|
11272
|
+
imports,
|
|
11273
|
+
input,
|
|
11274
|
+
annotate
|
|
11275
|
+
}) => {
|
|
11096
11276
|
const resolveConnection = imports.connections.resolveConnection;
|
|
11097
11277
|
const api = imports.api;
|
|
11098
11278
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
@@ -11107,7 +11287,7 @@ var listConnectionsPlugin = defineMethod({
|
|
|
11107
11287
|
if (appKey) {
|
|
11108
11288
|
const implementationId = await getVersionedImplementationId(appKey);
|
|
11109
11289
|
if (implementationId) {
|
|
11110
|
-
|
|
11290
|
+
annotate({ selectedApi: implementationId });
|
|
11111
11291
|
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
11112
11292
|
searchParams.app_key = versionlessSelectedApi;
|
|
11113
11293
|
} else {
|
|
@@ -11623,12 +11803,12 @@ var getConnectionStartUrlPlugin = defineMethod({
|
|
|
11623
11803
|
outputSchema: GetConnectionStartUrlItemSchema,
|
|
11624
11804
|
output: "item",
|
|
11625
11805
|
resolvers: { app: appKeyResolver },
|
|
11626
|
-
run: async ({ imports, input }) => {
|
|
11806
|
+
run: async ({ imports, input, annotate }) => {
|
|
11627
11807
|
const api = imports.api;
|
|
11628
11808
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
11629
11809
|
const versionedKey = await getVersionedImplementationId(input.app);
|
|
11630
11810
|
const selectedApi = versionedKey ? versionedKey.split("@")[0] : input.app;
|
|
11631
|
-
|
|
11811
|
+
annotate({ selectedApi });
|
|
11632
11812
|
const response = await api.post(
|
|
11633
11813
|
START_PATH,
|
|
11634
11814
|
{ selected_api: selectedApi },
|
|
@@ -11649,12 +11829,18 @@ var WaitForNewConnectionSchema = z.object({
|
|
|
11649
11829
|
startedAt: z.number().int().nonnegative().describe(
|
|
11650
11830
|
"Unix timestamp (seconds). Only connections whose `date` is at or after this value count as 'new'. Prefer the `startedAt` returned by `get-connection-start-url` \u2014 it's server-stamped, so the comparison isn't thrown off by client clock skew. If you mint the timestamp yourself, capture it *before* showing the start URL so a fast OAuth completion isn't missed."
|
|
11651
11831
|
),
|
|
11832
|
+
timeoutSeconds: z.number().int().positive().optional().describe("How long to wait before giving up. Default 5 minutes (300)."),
|
|
11833
|
+
/** @deprecated Use `timeoutSeconds` instead. */
|
|
11652
11834
|
timeoutMs: z.number().int().positive().optional().describe(
|
|
11653
11835
|
"How long to wait before giving up. Default 5 minutes (300_000)."
|
|
11836
|
+
).meta({ deprecated: true }),
|
|
11837
|
+
pollIntervalMilliseconds: z.number().int().positive().optional().describe(
|
|
11838
|
+
"Delay before the first poll request, in ms. Default 3 seconds (3_000). Subsequent polling cadence is managed by the SDK's polling primitive (backoff with sane defaults)."
|
|
11654
11839
|
),
|
|
11840
|
+
/** @deprecated Use `pollIntervalMilliseconds` instead. */
|
|
11655
11841
|
pollIntervalMs: z.number().int().positive().optional().describe(
|
|
11656
11842
|
"Delay before the first poll request, in ms. Default 3 seconds (3_000). Subsequent polling cadence is managed by the SDK's polling primitive (backoff with sane defaults)."
|
|
11657
|
-
)
|
|
11843
|
+
).meta({ deprecated: true })
|
|
11658
11844
|
}).describe(
|
|
11659
11845
|
"Wait for a new connection to appear for the given app. Polls `/api/v0/connections` with server-side `ordering=-date` until the most recent matching row's `date` is at or after the started-at timestamp, then returns it. Pair with `get-connection-start-url` \u2014 that mints the URL the user opens, this waits for the resulting connection to land. Errors with a timeout after the configured timeout (default 5 min). Example (JS):\n\n```ts\nconst { data: { url, app, startedAt } } = await zapier.getConnectionStartUrl({ app: 'slack' });\n// show `url` to the user via the channel they're reading from\nconst { data: conn } = await zapier.waitForNewConnection({ app, startedAt });\n```"
|
|
11660
11846
|
);
|
|
@@ -11681,12 +11867,12 @@ var waitForNewConnectionPlugin = defineMethod({
|
|
|
11681
11867
|
outputSchema: WaitForNewConnectionItemSchema,
|
|
11682
11868
|
output: "item",
|
|
11683
11869
|
resolvers: { app: appKeyResolver },
|
|
11684
|
-
run: async ({ imports, input }) => {
|
|
11870
|
+
run: async ({ imports, input, annotate }) => {
|
|
11685
11871
|
const api = imports.api;
|
|
11686
11872
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
11687
11873
|
const versionedKey = await getVersionedImplementationId(input.app);
|
|
11688
11874
|
const appKey = versionedKey ? versionedKey.split("@")[0] : input.app;
|
|
11689
|
-
|
|
11875
|
+
annotate({ selectedApi: appKey });
|
|
11690
11876
|
try {
|
|
11691
11877
|
const top = await api.poll(CONNECTIONS_PATH, {
|
|
11692
11878
|
searchParams: {
|
|
@@ -11701,8 +11887,8 @@ var waitForNewConnectionPlugin = defineMethod({
|
|
|
11701
11887
|
page_size: "1"
|
|
11702
11888
|
},
|
|
11703
11889
|
authRequired: true,
|
|
11704
|
-
|
|
11705
|
-
|
|
11890
|
+
timeoutMilliseconds: input.timeoutSeconds != null ? input.timeoutSeconds * 1e3 : input.timeoutMs ?? 3e5,
|
|
11891
|
+
initialDelayMilliseconds: input.pollIntervalMilliseconds ?? input.pollIntervalMs ?? 3e3,
|
|
11706
11892
|
isPending: (body) => {
|
|
11707
11893
|
const rows = body.data ?? [];
|
|
11708
11894
|
const head = rows[0];
|
|
@@ -11752,12 +11938,20 @@ var CreateConnectionSchema = z.object({
|
|
|
11752
11938
|
browser: z.enum(["auto", "always", "never"]).default("auto").describe(
|
|
11753
11939
|
"When to auto-open the URL in a browser. `auto` (default) opens in local sessions and skips opening in CI / SSH / headless-Linux. `always` forces the open attempt. `never` skips it. The URL is always printed to stderr regardless \u2014 a failed or skipped open degrades gracefully to copy-paste."
|
|
11754
11940
|
),
|
|
11941
|
+
timeoutSeconds: z.number().int().positive().optional().describe(
|
|
11942
|
+
"How long to wait for the user to complete the connection flow before giving up. Default 5 minutes (300)."
|
|
11943
|
+
),
|
|
11944
|
+
/** @deprecated Use `timeoutSeconds` instead. */
|
|
11755
11945
|
timeoutMs: z.number().int().positive().optional().describe(
|
|
11756
11946
|
"How long to wait for the user to complete the connection flow before giving up. Default 5 minutes (300_000)."
|
|
11947
|
+
).meta({ deprecated: true }),
|
|
11948
|
+
pollIntervalMilliseconds: z.number().int().positive().optional().describe(
|
|
11949
|
+
"Delay before the first poll request, in ms. Default 3 seconds (3_000). Subsequent polling cadence is managed by the SDK's polling primitive (backoff with sane defaults)."
|
|
11757
11950
|
),
|
|
11951
|
+
/** @deprecated Use `pollIntervalMilliseconds` instead. */
|
|
11758
11952
|
pollIntervalMs: z.number().int().positive().optional().describe(
|
|
11759
11953
|
"Delay before the first poll request, in ms. Default 3 seconds (3_000). Subsequent polling cadence is managed by the SDK's polling primitive (backoff with sane defaults)."
|
|
11760
|
-
)
|
|
11954
|
+
).meta({ deprecated: true })
|
|
11761
11955
|
}).describe(
|
|
11762
11956
|
"Create a new app connection, end-to-end. Mints the start URL via `get-connection-start-url`, prints it to stderr, opportunistically opens it in a browser when it looks safe to do so (skipping CI / SSH / headless-Linux by default \u2014 pass `--browser always` to force, `--browser never` to suppress), then polls via `wait-for-new-connection` until the user completes OAuth and the new connection appears. Returns the connection.\n\nThis is the right command for most callers. Reach for the lower-level building blocks when you want either of: (a) hand off the URL and *not* block on completion \u2014 call `get-connection-start-url` alone, no `wait-for-new-connection` needed, or (b) do something custom between minting the URL and waiting \u2014 call `get-connection-start-url`, do your work (email or DM the URL, render a QR code, etc.), then `wait-for-new-connection`."
|
|
11763
11957
|
);
|
|
@@ -11796,11 +11990,11 @@ var createConnectionPlugin = defineMethod({
|
|
|
11796
11990
|
]
|
|
11797
11991
|
})
|
|
11798
11992
|
}),
|
|
11799
|
-
run: async ({ imports, input }) => {
|
|
11993
|
+
run: async ({ imports, input, annotate }) => {
|
|
11800
11994
|
const { data: start2 } = await imports.getConnectionStartUrl({
|
|
11801
11995
|
app: input.app
|
|
11802
11996
|
});
|
|
11803
|
-
|
|
11997
|
+
annotate({ selectedApi: start2.app });
|
|
11804
11998
|
console.error(
|
|
11805
11999
|
`
|
|
11806
12000
|
Open this URL to complete the connection:
|
|
@@ -11819,8 +12013,9 @@ Open this URL to complete the connection:
|
|
|
11819
12013
|
// Server-stamped mint time: measured on the same clock as a connection's
|
|
11820
12014
|
// `date`, so the freshness check is immune to client/server clock skew.
|
|
11821
12015
|
startedAt: start2.startedAt,
|
|
12016
|
+
timeoutSeconds: input.timeoutSeconds,
|
|
11822
12017
|
timeoutMs: input.timeoutMs,
|
|
11823
|
-
|
|
12018
|
+
pollIntervalMilliseconds: input.pollIntervalMilliseconds ?? input.pollIntervalMs
|
|
11824
12019
|
});
|
|
11825
12020
|
return {
|
|
11826
12021
|
data: CreateConnectionItemSchema.parse({
|
|
@@ -12054,6 +12249,10 @@ var triggerInboxItemFormatter = defineFormatter({
|
|
|
12054
12249
|
|
|
12055
12250
|
// src/plugins/triggers/shared.ts
|
|
12056
12251
|
var triggerCategories = ["trigger"];
|
|
12252
|
+
function deriveReadOperation() {
|
|
12253
|
+
const annotations = { operationType: "read" };
|
|
12254
|
+
return { ...annotations };
|
|
12255
|
+
}
|
|
12057
12256
|
|
|
12058
12257
|
// src/plugins/triggers/utils.ts
|
|
12059
12258
|
var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -12099,6 +12298,7 @@ var createTriggerInboxPlugin = defineMethod({
|
|
|
12099
12298
|
outputSchema: TriggerInboxItemSchema,
|
|
12100
12299
|
output: "item",
|
|
12101
12300
|
formatter: triggerInboxItemFormatter,
|
|
12301
|
+
annotator: deriveReadOperation,
|
|
12102
12302
|
// actionKeyResolver and inputsResolver depend on actionType, which is always
|
|
12103
12303
|
// "read" for triggers. Pin it as a constant resolver so it's seeded into
|
|
12104
12304
|
// resolvedParams without polluting the user-facing schema (where it would
|
|
@@ -12203,6 +12403,7 @@ var ensureTriggerInboxPlugin = defineMethod({
|
|
|
12203
12403
|
outputSchema: TriggerInboxItemSchema,
|
|
12204
12404
|
output: "item",
|
|
12205
12405
|
formatter: triggerInboxItemFormatter,
|
|
12406
|
+
annotator: deriveReadOperation,
|
|
12206
12407
|
// actionKeyResolver and inputsResolver depend on actionType, which is always
|
|
12207
12408
|
// "read" for triggers. Pin it as a constant resolver so it's seeded into
|
|
12208
12409
|
// resolvedParams without polluting the user-facing schema.
|
|
@@ -13179,9 +13380,9 @@ async function* readInboxEvents({
|
|
|
13179
13380
|
}
|
|
13180
13381
|
|
|
13181
13382
|
// src/plugins/triggers/watchTriggerInbox/index.ts
|
|
13182
|
-
var
|
|
13183
|
-
var
|
|
13184
|
-
var
|
|
13383
|
+
var SSE_RECONNECT_BACKOFF_MILLISECONDS = [500, 1e3, 2e3, 5e3];
|
|
13384
|
+
var DEFAULT_SAFETY_DRAIN_INTERVAL_MILLISECONDS = 3e5;
|
|
13385
|
+
var SSE_HEALTHY_CONNECTION_MILLISECONDS = 5e3;
|
|
13185
13386
|
var ERROR_BACKOFF_CAP = 4;
|
|
13186
13387
|
function createDrainLatch() {
|
|
13187
13388
|
let pending = false;
|
|
@@ -13239,7 +13440,7 @@ async function drainRunner({
|
|
|
13239
13440
|
consecutiveErrors = Math.min(consecutiveErrors + 1, ERROR_BACKOFF_CAP);
|
|
13240
13441
|
errorAttempts += 1;
|
|
13241
13442
|
const delay = calculateErrorBackoffMs(
|
|
13242
|
-
|
|
13443
|
+
BASE_ERROR_BACKOFF_MILLISECONDS,
|
|
13243
13444
|
consecutiveErrors
|
|
13244
13445
|
);
|
|
13245
13446
|
const statusCode = errorStatusCode(error);
|
|
@@ -13305,7 +13506,7 @@ async function sseLoop({
|
|
|
13305
13506
|
})) {
|
|
13306
13507
|
drainRequest.request();
|
|
13307
13508
|
}
|
|
13308
|
-
if (connected && Date.now() - connectedAt >=
|
|
13509
|
+
if (connected && Date.now() - connectedAt >= SSE_HEALTHY_CONNECTION_MILLISECONDS) {
|
|
13309
13510
|
attempt = 0;
|
|
13310
13511
|
}
|
|
13311
13512
|
} catch (err) {
|
|
@@ -13329,8 +13530,11 @@ async function sseLoop({
|
|
|
13329
13530
|
transientError = err;
|
|
13330
13531
|
}
|
|
13331
13532
|
if (signal.aborted) return;
|
|
13332
|
-
const delay =
|
|
13333
|
-
attempt = Math.min(
|
|
13533
|
+
const delay = SSE_RECONNECT_BACKOFF_MILLISECONDS[Math.min(attempt, SSE_RECONNECT_BACKOFF_MILLISECONDS.length - 1)];
|
|
13534
|
+
attempt = Math.min(
|
|
13535
|
+
attempt + 1,
|
|
13536
|
+
SSE_RECONNECT_BACKOFF_MILLISECONDS.length - 1
|
|
13537
|
+
);
|
|
13334
13538
|
if (transientError !== void 0 && debug) {
|
|
13335
13539
|
const statusCode = errorStatusCode(transientError);
|
|
13336
13540
|
const errorMsg = errorMessage(transientError);
|
|
@@ -13387,7 +13591,7 @@ var watchTriggerInboxPlugin = defineMethod({
|
|
|
13387
13591
|
const { concurrency, leaseLimit } = resolveConcurrencyAndLease(input);
|
|
13388
13592
|
const inboxId = await resolveTriggerInboxId({ api, inbox: input.inbox });
|
|
13389
13593
|
if (input.signal?.aborted) return;
|
|
13390
|
-
const safetyDrainMs = input.maxDrainIntervalSeconds !== void 0 ? input.maxDrainIntervalSeconds * 1e3 :
|
|
13594
|
+
const safetyDrainMs = input.maxDrainIntervalSeconds !== void 0 ? input.maxDrainIntervalSeconds * 1e3 : DEFAULT_SAFETY_DRAIN_INTERVAL_MILLISECONDS;
|
|
13391
13595
|
const stop = new AbortController();
|
|
13392
13596
|
const combined = combineAbortSignals({
|
|
13393
13597
|
handles: [
|
|
@@ -13504,6 +13708,7 @@ var listTriggerInputFieldsPlugin = defineMethod({
|
|
|
13504
13708
|
outputSchema: RootFieldItemSchema,
|
|
13505
13709
|
output: { type: "list", defaultPageSize: DEFAULT_PAGE_SIZE },
|
|
13506
13710
|
formatter: rootFieldItemFormatter,
|
|
13711
|
+
annotator: deriveReadOperation,
|
|
13507
13712
|
// actionKeyResolver and inputsAllOptionalResolver depend on actionType. Pin it
|
|
13508
13713
|
// to "read" so they resolve correctly without the user setting it.
|
|
13509
13714
|
resolvers: {
|
|
@@ -13550,6 +13755,7 @@ var listTriggerInputFieldChoicesPlugin = defineMethod({
|
|
|
13550
13755
|
outputSchema: InputFieldChoiceItemSchema,
|
|
13551
13756
|
output: { type: "list", defaultPageSize: DEFAULT_PAGE_SIZE },
|
|
13552
13757
|
formatter: inputFieldChoiceItemFormatter,
|
|
13758
|
+
annotator: deriveReadOperation,
|
|
13553
13759
|
resolvers: {
|
|
13554
13760
|
app: appKeyResolver,
|
|
13555
13761
|
action: actionKeyResolver,
|
|
@@ -13593,6 +13799,7 @@ var getTriggerInputFieldsSchemaPlugin = defineMethod({
|
|
|
13593
13799
|
// Passthrough: getActionInputFieldsSchema already returns `{ data }`, so
|
|
13594
13800
|
// `output: "raw"` surfaces that envelope unchanged.
|
|
13595
13801
|
output: "raw",
|
|
13802
|
+
annotator: deriveReadOperation,
|
|
13596
13803
|
resolvers: {
|
|
13597
13804
|
app: appKeyResolver,
|
|
13598
13805
|
action: actionKeyResolver,
|
|
@@ -14416,7 +14623,7 @@ var updateTableRecordsPlugin = defineMethod({
|
|
|
14416
14623
|
|
|
14417
14624
|
// src/plugins/eventEmission/transport.ts
|
|
14418
14625
|
var DEFAULT_RETRY_ATTEMPTS = 2;
|
|
14419
|
-
var
|
|
14626
|
+
var DEFAULT_RETRY_DELAY_MILLISECONDS = 300;
|
|
14420
14627
|
function createHttpTransport(config) {
|
|
14421
14628
|
const delay = async (ms) => {
|
|
14422
14629
|
return new Promise((resolve2) => {
|
|
@@ -14441,12 +14648,12 @@ function createHttpTransport(config) {
|
|
|
14441
14648
|
body: JSON.stringify(payload)
|
|
14442
14649
|
});
|
|
14443
14650
|
if (!response.ok && attemptsLeft > 1) {
|
|
14444
|
-
await delay(config.retryDelayMs ||
|
|
14651
|
+
await delay(config.retryDelayMs || DEFAULT_RETRY_DELAY_MILLISECONDS);
|
|
14445
14652
|
return emitWithRetry(subject, event, attemptsLeft - 1);
|
|
14446
14653
|
}
|
|
14447
14654
|
} catch (error) {
|
|
14448
14655
|
if (attemptsLeft > 1) {
|
|
14449
|
-
await delay(config.retryDelayMs ||
|
|
14656
|
+
await delay(config.retryDelayMs || DEFAULT_RETRY_DELAY_MILLISECONDS);
|
|
14450
14657
|
return emitWithRetry(subject, event, attemptsLeft - 1);
|
|
14451
14658
|
}
|
|
14452
14659
|
throw error;
|
|
@@ -14710,6 +14917,14 @@ function buildMethodCalledEvent(data, context = {}) {
|
|
|
14710
14917
|
}
|
|
14711
14918
|
|
|
14712
14919
|
// src/plugins/eventEmission/event-emission-hook.ts
|
|
14920
|
+
function readMethodMetadata(annotations) {
|
|
14921
|
+
const readString = (value) => typeof value === "string" ? value : null;
|
|
14922
|
+
return {
|
|
14923
|
+
selectedApi: readString(annotations.selectedApi),
|
|
14924
|
+
operationType: readString(annotations.operationType),
|
|
14925
|
+
operationKey: readString(annotations.operationKey)
|
|
14926
|
+
};
|
|
14927
|
+
}
|
|
14713
14928
|
function computeArgumentCount(args) {
|
|
14714
14929
|
if (args.length === 1) {
|
|
14715
14930
|
const arg0 = args[0];
|
|
@@ -14720,9 +14935,18 @@ function computeArgumentCount(args) {
|
|
|
14720
14935
|
return args.filter((a) => a !== void 0).length;
|
|
14721
14936
|
}
|
|
14722
14937
|
function makeMethodEndHook(emitMethodCalled) {
|
|
14723
|
-
return ({
|
|
14724
|
-
|
|
14725
|
-
|
|
14938
|
+
return ({
|
|
14939
|
+
methodName,
|
|
14940
|
+
args,
|
|
14941
|
+
isPaginated,
|
|
14942
|
+
depth,
|
|
14943
|
+
callOrigin,
|
|
14944
|
+
annotations,
|
|
14945
|
+
durationMs,
|
|
14946
|
+
error
|
|
14947
|
+
}) => {
|
|
14948
|
+
if (callOrigin === "internal" || depth > 0) return;
|
|
14949
|
+
const metadata = readMethodMetadata(annotations);
|
|
14726
14950
|
emitMethodCalled({
|
|
14727
14951
|
method_name: methodName,
|
|
14728
14952
|
execution_duration_ms: durationMs,
|
|
@@ -14731,15 +14955,36 @@ function makeMethodEndHook(emitMethodCalled) {
|
|
|
14731
14955
|
error_type: error?.constructor.name ?? null,
|
|
14732
14956
|
argument_count: computeArgumentCount(args),
|
|
14733
14957
|
is_paginated: isPaginated,
|
|
14734
|
-
selected_api: metadata
|
|
14735
|
-
operation_type: metadata
|
|
14736
|
-
operation_key: metadata
|
|
14958
|
+
selected_api: metadata.selectedApi ?? null,
|
|
14959
|
+
operation_type: metadata.operationType ?? null,
|
|
14960
|
+
operation_key: metadata.operationKey ?? null
|
|
14737
14961
|
});
|
|
14738
14962
|
};
|
|
14739
14963
|
}
|
|
14740
14964
|
|
|
14965
|
+
// src/plugins/eventEmission/annotator.ts
|
|
14966
|
+
function zapierAnnotate({ input }) {
|
|
14967
|
+
const annotations = {};
|
|
14968
|
+
if (typeof input === "object" && input !== null) {
|
|
14969
|
+
const record = input;
|
|
14970
|
+
if (typeof record.actionType === "string") {
|
|
14971
|
+
annotations.operationType = record.actionType;
|
|
14972
|
+
}
|
|
14973
|
+
const operationKey = record.action ?? record.actionKey;
|
|
14974
|
+
if (typeof operationKey === "string") {
|
|
14975
|
+
annotations.operationKey = operationKey;
|
|
14976
|
+
}
|
|
14977
|
+
}
|
|
14978
|
+
return { ...annotations };
|
|
14979
|
+
}
|
|
14980
|
+
var operationAnnotatorPlugin = defineHook({
|
|
14981
|
+
namespace: "zapier",
|
|
14982
|
+
name: "operationAnnotator",
|
|
14983
|
+
annotator: ({ input }) => zapierAnnotate({ input })
|
|
14984
|
+
});
|
|
14985
|
+
|
|
14741
14986
|
// src/plugins/eventEmission/index.ts
|
|
14742
|
-
var
|
|
14987
|
+
var TELEMETRY_EMIT_TIMEOUT_MILLISECONDS = 300;
|
|
14743
14988
|
var registeredListeners = {};
|
|
14744
14989
|
function removeExistingListeners() {
|
|
14745
14990
|
const events = [
|
|
@@ -14785,7 +15030,7 @@ async function emitWithTimeout(transport, subject, event) {
|
|
|
14785
15030
|
await Promise.race([
|
|
14786
15031
|
transport.emit(subject, event),
|
|
14787
15032
|
new Promise((resolve2) => {
|
|
14788
|
-
const timer = setTimeout(resolve2,
|
|
15033
|
+
const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MILLISECONDS);
|
|
14789
15034
|
if (typeof timer.unref === "function") {
|
|
14790
15035
|
timer.unref();
|
|
14791
15036
|
}
|
|
@@ -15138,7 +15383,8 @@ var zapierSdkPlugin = definePlugin({
|
|
|
15138
15383
|
connectionsPlugin,
|
|
15139
15384
|
capabilitiesPlugin,
|
|
15140
15385
|
eventEmissionPlugin,
|
|
15141
|
-
eventEmissionHookPlugin
|
|
15386
|
+
eventEmissionHookPlugin,
|
|
15387
|
+
operationAnnotatorPlugin
|
|
15142
15388
|
],
|
|
15143
15389
|
exports: [
|
|
15144
15390
|
// The registry reporter: previously synthesized by the legacy merge,
|
|
@@ -15224,14 +15470,14 @@ function createZapierSdk(options = {}) {
|
|
|
15224
15470
|
|
|
15225
15471
|
// src/utils/batch-utils.ts
|
|
15226
15472
|
var DEFAULT_CONCURRENCY = 10;
|
|
15227
|
-
var
|
|
15228
|
-
var
|
|
15473
|
+
var BATCH_START_DELAY_MILLISECONDS = 25;
|
|
15474
|
+
var DEFAULT_BATCH_TIMEOUT_MILLISECONDS = 18e4;
|
|
15229
15475
|
async function batch(tasks, options = {}) {
|
|
15230
15476
|
const {
|
|
15231
15477
|
concurrency = DEFAULT_CONCURRENCY,
|
|
15232
15478
|
retry = true,
|
|
15233
|
-
batchDelay =
|
|
15234
|
-
timeoutMs =
|
|
15479
|
+
batchDelay = BATCH_START_DELAY_MILLISECONDS,
|
|
15480
|
+
timeoutMs = DEFAULT_BATCH_TIMEOUT_MILLISECONDS,
|
|
15235
15481
|
taskTimeoutMs
|
|
15236
15482
|
} = options;
|
|
15237
15483
|
if (concurrency <= 0) {
|
|
@@ -15324,11 +15570,15 @@ var BaseSdkOptionsSchema = z.object({
|
|
|
15324
15570
|
*/
|
|
15325
15571
|
maxNetworkRetries: z.number().optional().describe("Max retries for rate-limited requests (default: 3).").meta({ valueHint: "count" }),
|
|
15326
15572
|
/**
|
|
15327
|
-
* Maximum delay in
|
|
15573
|
+
* Maximum delay in seconds to wait for a rate-limit retry.
|
|
15328
15574
|
* If the server requests a longer delay, the request fails immediately.
|
|
15329
|
-
* Default is
|
|
15575
|
+
* Default is 60 (60 seconds).
|
|
15330
15576
|
*/
|
|
15331
|
-
|
|
15577
|
+
maxNetworkRetryDelaySeconds: z.number().optional().describe(
|
|
15578
|
+
"Max delay in seconds to wait for a rate-limit retry (default: 60)."
|
|
15579
|
+
).meta({ valueHint: "seconds" }),
|
|
15580
|
+
/** @deprecated Use `maxNetworkRetryDelaySeconds` instead. */
|
|
15581
|
+
maxNetworkRetryDelayMs: z.number().optional().describe("Max delay in ms to wait for retry (default: 60000).").meta({ valueHint: "ms", deprecated: true }),
|
|
15332
15582
|
/**
|
|
15333
15583
|
* Maximum number of concurrent in-flight HTTP requests per client.
|
|
15334
15584
|
* Requests beyond this limit queue in FIFO order until a slot frees.
|
|
@@ -15347,7 +15597,9 @@ var BaseSdkOptionsSchema = z.object({
|
|
|
15347
15597
|
]).optional().describe(
|
|
15348
15598
|
`Max concurrent in-flight HTTP requests (default: 200, max: ${MAX_CONCURRENCY_LIMIT}).`
|
|
15349
15599
|
).meta({ valueHint: "count" }),
|
|
15350
|
-
|
|
15600
|
+
approvalTimeoutSeconds: z.number().optional().describe("Timeout in seconds for approval polling. Default: 600 (10 min).").meta({ valueHint: "seconds" }),
|
|
15601
|
+
/** @deprecated Use `approvalTimeoutSeconds` instead. */
|
|
15602
|
+
approvalTimeoutMs: z.number().optional().describe("Timeout in ms for approval polling. Default: 600000 (10 min).").meta({ valueHint: "ms", deprecated: true }),
|
|
15351
15603
|
maxApprovalRetries: z.number().optional().describe(
|
|
15352
15604
|
"Maximum number of sequential approval rounds per request (one per gating policy) before giving up. Default: 2."
|
|
15353
15605
|
),
|
|
@@ -15381,4 +15633,4 @@ var registryPlugin = (_sdk) => {
|
|
|
15381
15633
|
return {};
|
|
15382
15634
|
};
|
|
15383
15635
|
|
|
15384
|
-
export { API_ID, ActionKeyPropertySchema, ActionPropertySchema,
|
|
15636
|
+
export { API_ID, ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMillisecondsPropertySchema, ActionTimeoutSecondsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthMechanism, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONNECTIONS_ID, CONTEXT, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MILLISECONDS, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CoreCancelledSignal, CoreDisposeError, CoreErrorCode, CoreSignal, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MILLISECONDS, DEFAULT_APPROVAL_TIMEOUT_MILLISECONDS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DEPRECATION_NOTICE_EVENT, DebugPropertySchema, DrainTriggerInboxSchema, EVENT_EMISSION_ID, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MANIFEST_ID, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RESOLVE_CREDENTIALS_ID, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, SDK_OPTIONS_ID, TablePropertySchema, TablesPropertySchema, TriggerInboxKeyPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, WatchTriggerInboxSchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, addPlugin, apiPlugin, apiPluginRef, appKeyResolver, appsPlugin, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, connectionsPluginRef, createBaseEvent, createClientCredentialsPlugin, createController, createCorePlugin, createFunction, createMemoryCache, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierSdk, createZapierSdkWithoutRegistry, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, defineFormatter, defineLegacyMerge, defineMethod, defineMethodOverride, definePlugin, defineProperty, defineResolver, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, disposeSdk, durableRunIdResolver, eventEmissionHookPlugin, eventEmissionPlugin, eventEmissionPluginRef, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, fromFunctionPlugin, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getRegistryPlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCoreCancelledSignal, isCoreError, isCoreSignal, isCredentialsFunction, isCredentialsObject, isPermanentHttpError, isPkceCredentials, isPositional, isZapierAbortDrainSignal, isZapierActionError, isZapierAppNotFoundError, isZapierApprovalError, isZapierAuthenticationError, isZapierBundleError, isZapierConflictError, isZapierError, isZapierNotFoundError, isZapierRateLimitError, isZapierReleaseTriggerMessageSignal, isZapierResourceNotFoundError, isZapierSignal, isZapierTimeoutError, isZapierValidationError, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation2 as logDeprecation, manifestPlugin, manifestPluginRef, omitExports, openEnum, operationAnnotatorPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings2 as resetDeprecationWarnings, resolveAuth, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, resolveCredentialsPlugin, resolveCredentialsPluginRef, resolvePlugin, runActionPlugin, runInMethodScope, runWithCallerContext, runWithTelemetryContext, sdkOptionsPluginRef, selectExports, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError, zapierCoreOptions, zapierSdkPlugin };
|