@zapier/zapier-sdk 0.88.0 → 0.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +105 -0
- package/dist/{chunk-IXLMFSFV.mjs → chunk-NOPKQ333.mjs} +366 -144
- package/dist/{chunk-AVB4LBN5.cjs → chunk-UBI5FOL5.cjs} +367 -143
- package/dist/experimental.cjs +492 -342
- package/dist/experimental.d.mts +119 -3
- package/dist/experimental.d.ts +119 -3
- package/dist/experimental.mjs +144 -2
- package/dist/{index-CGfO1ZB1.d.mts → index-BBBkZ80x.d.mts} +155 -20
- package/dist/{index-CGfO1ZB1.d.ts → index-BBBkZ80x.d.ts} +155 -20
- package/dist/index.cjs +278 -270
- 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
|
@@ -173,12 +173,19 @@ function composeVoid(existing, added) {
|
|
|
173
173
|
isolated.add(composed);
|
|
174
174
|
return composed;
|
|
175
175
|
}
|
|
176
|
+
function composeAnnotators(existing, added) {
|
|
177
|
+
if (!existing) return added;
|
|
178
|
+
if (!added) return existing;
|
|
179
|
+
return (ctx) => ({ ...existing(ctx), ...added(ctx) });
|
|
180
|
+
}
|
|
176
181
|
function buildHooks(existing, added) {
|
|
177
182
|
const result = {};
|
|
178
183
|
const start2 = composeVoid(existing.onMethodStart, added.onMethodStart);
|
|
179
184
|
if (start2) result.onMethodStart = start2;
|
|
180
185
|
const end = composeVoid(existing.onMethodEnd, added.onMethodEnd);
|
|
181
186
|
if (end) result.onMethodEnd = end;
|
|
187
|
+
const annotator = composeAnnotators(existing.annotator, added.annotator);
|
|
188
|
+
if (annotator) result.annotator = annotator;
|
|
182
189
|
return result;
|
|
183
190
|
}
|
|
184
191
|
function createDeprecationLogger(tag) {
|
|
@@ -580,11 +587,14 @@ function generateCallId() {
|
|
|
580
587
|
}
|
|
581
588
|
return null;
|
|
582
589
|
}
|
|
583
|
-
function rootCallContext(
|
|
590
|
+
function rootCallContext({
|
|
591
|
+
callOrigin = "surface"
|
|
592
|
+
} = {}) {
|
|
584
593
|
return {
|
|
585
594
|
callId: generateCallId(),
|
|
586
595
|
depth: 0,
|
|
587
596
|
annotations: {},
|
|
597
|
+
callOrigin,
|
|
588
598
|
[CALL_CONTEXT_BRAND]: true
|
|
589
599
|
};
|
|
590
600
|
}
|
|
@@ -593,6 +603,7 @@ function childCallContext(parent) {
|
|
|
593
603
|
callId: parent.callId,
|
|
594
604
|
depth: parent.depth + 1,
|
|
595
605
|
annotations: {},
|
|
606
|
+
callOrigin: parent.callOrigin,
|
|
596
607
|
[CALL_CONTEXT_BRAND]: true
|
|
597
608
|
};
|
|
598
609
|
}
|
|
@@ -614,6 +625,28 @@ var INTERNAL_CALL = Symbol("kitcore.internalCall");
|
|
|
614
625
|
function resolveCallContext(secondArg) {
|
|
615
626
|
return isCallContext(secondArg) ? secondArg : rootCallContext();
|
|
616
627
|
}
|
|
628
|
+
var hookAnnotatorReentrancy = 0;
|
|
629
|
+
function applyAnnotations({
|
|
630
|
+
context,
|
|
631
|
+
methodName,
|
|
632
|
+
input,
|
|
633
|
+
hookAnnotator,
|
|
634
|
+
methodAnnotator
|
|
635
|
+
}) {
|
|
636
|
+
if (hookAnnotator && !isInsideObserver() && context.depth === 0 && context.callOrigin !== "internal" && hookAnnotatorReentrancy === 0) {
|
|
637
|
+
hookAnnotatorReentrancy++;
|
|
638
|
+
try {
|
|
639
|
+
Object.assign(context.annotations, hookAnnotator({ methodName, input }));
|
|
640
|
+
} catch {
|
|
641
|
+
} finally {
|
|
642
|
+
hookAnnotatorReentrancy--;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
try {
|
|
646
|
+
Object.assign(context.annotations, methodAnnotator?.(input));
|
|
647
|
+
} catch {
|
|
648
|
+
}
|
|
649
|
+
}
|
|
617
650
|
function signalDeprecation(context, methodName, getDeprecation) {
|
|
618
651
|
if (isInsideObserver()) return;
|
|
619
652
|
const deprecation = getDeprecation?.();
|
|
@@ -639,7 +672,7 @@ function normalizeError(error, adaptError) {
|
|
|
639
672
|
);
|
|
640
673
|
}
|
|
641
674
|
function createFunction(coreFn, options) {
|
|
642
|
-
const { sdk, schema, name, getDeprecation } = options;
|
|
675
|
+
const { sdk, schema, name, annotator, getDeprecation } = options;
|
|
643
676
|
const functionName = name || coreFn.name;
|
|
644
677
|
const namedFunctions = {
|
|
645
678
|
[functionName]: async function(callOptions) {
|
|
@@ -653,14 +686,26 @@ function createFunction(coreFn, options) {
|
|
|
653
686
|
const normalizedOptions = callOptions ?? {};
|
|
654
687
|
const args = [normalizedOptions];
|
|
655
688
|
const depth = Math.max(context.depth, getCurrentDepth());
|
|
656
|
-
const
|
|
689
|
+
const insideObserver = isInsideObserver();
|
|
690
|
+
const hooks = insideObserver ? void 0 : sdk.context.hooks;
|
|
657
691
|
const adaptError = resolveCoreOptions(sdk.context)?.adaptError;
|
|
658
|
-
|
|
692
|
+
applyAnnotations({
|
|
693
|
+
context,
|
|
694
|
+
methodName: functionName,
|
|
695
|
+
input: normalizedOptions,
|
|
696
|
+
hookAnnotator: hooks?.annotator,
|
|
697
|
+
methodAnnotator: annotator
|
|
698
|
+
});
|
|
699
|
+
const hookBase = {
|
|
659
700
|
methodName: functionName,
|
|
660
701
|
args,
|
|
661
702
|
isPaginated: false,
|
|
662
|
-
depth
|
|
663
|
-
|
|
703
|
+
depth,
|
|
704
|
+
callId: context.callId,
|
|
705
|
+
callOrigin: context.callOrigin,
|
|
706
|
+
annotations: context.annotations
|
|
707
|
+
};
|
|
708
|
+
hooks?.onMethodStart?.({ ...hookBase });
|
|
664
709
|
try {
|
|
665
710
|
let result;
|
|
666
711
|
if (schema) {
|
|
@@ -682,20 +727,14 @@ function createFunction(coreFn, options) {
|
|
|
682
727
|
result = await coreFn(normalizedOptions, context);
|
|
683
728
|
}
|
|
684
729
|
hooks?.onMethodEnd?.({
|
|
685
|
-
|
|
686
|
-
args,
|
|
687
|
-
isPaginated: false,
|
|
688
|
-
depth,
|
|
730
|
+
...hookBase,
|
|
689
731
|
durationMs: Date.now() - startTime
|
|
690
732
|
});
|
|
691
733
|
return result;
|
|
692
734
|
} catch (error) {
|
|
693
735
|
const normalizedError = normalizeError(error, adaptError);
|
|
694
736
|
hooks?.onMethodEnd?.({
|
|
695
|
-
|
|
696
|
-
args,
|
|
697
|
-
isPaginated: false,
|
|
698
|
-
depth,
|
|
737
|
+
...hookBase,
|
|
699
738
|
durationMs: Date.now() - startTime,
|
|
700
739
|
error: normalizedError
|
|
701
740
|
});
|
|
@@ -707,7 +746,7 @@ function createFunction(coreFn, options) {
|
|
|
707
746
|
return namedFunctions[functionName];
|
|
708
747
|
}
|
|
709
748
|
function createRawFunction(coreFn, options) {
|
|
710
|
-
const { sdk, name, schema, positional, getDeprecation } = options;
|
|
749
|
+
const { sdk, name, schema, positional, annotator, getDeprecation } = options;
|
|
711
750
|
return function(rawInput) {
|
|
712
751
|
const internal = arguments[1];
|
|
713
752
|
const context = resolveCallContext(internal);
|
|
@@ -717,23 +756,32 @@ function createRawFunction(coreFn, options) {
|
|
|
717
756
|
return runInMethodScope(() => {
|
|
718
757
|
const startTime = Date.now();
|
|
719
758
|
const depth = Math.max(context.depth, getCurrentDepth());
|
|
720
|
-
const
|
|
759
|
+
const insideObserver = isInsideObserver();
|
|
760
|
+
const hooks = insideObserver ? void 0 : sdk.context.hooks;
|
|
721
761
|
const adaptError = resolveCoreOptions(sdk.context)?.adaptError;
|
|
722
762
|
const input = schema ? rawInput ?? {} : rawInput;
|
|
763
|
+
applyAnnotations({
|
|
764
|
+
context,
|
|
765
|
+
methodName: name,
|
|
766
|
+
input,
|
|
767
|
+
hookAnnotator: hooks?.annotator,
|
|
768
|
+
methodAnnotator: annotator
|
|
769
|
+
});
|
|
723
770
|
const record = input;
|
|
724
771
|
const args = positional ? positional.filter((key) => record?.[key] !== void 0).map((key) => record?.[key]) : [input];
|
|
725
|
-
|
|
772
|
+
const hookBase = {
|
|
726
773
|
methodName: name,
|
|
727
774
|
args,
|
|
728
775
|
isPaginated: false,
|
|
729
|
-
depth
|
|
730
|
-
|
|
776
|
+
depth,
|
|
777
|
+
callId: context.callId,
|
|
778
|
+
callOrigin: context.callOrigin,
|
|
779
|
+
annotations: context.annotations
|
|
780
|
+
};
|
|
781
|
+
hooks?.onMethodStart?.({ ...hookBase });
|
|
731
782
|
const fireEnd = (error) => {
|
|
732
783
|
hooks?.onMethodEnd?.({
|
|
733
|
-
|
|
734
|
-
args,
|
|
735
|
-
isPaginated: false,
|
|
736
|
-
depth,
|
|
784
|
+
...hookBase,
|
|
737
785
|
durationMs: Date.now() - startTime,
|
|
738
786
|
...error ? { error } : {}
|
|
739
787
|
});
|
|
@@ -800,7 +848,15 @@ function createPageFunction(coreFn, {
|
|
|
800
848
|
return namedFunctions[functionName];
|
|
801
849
|
}
|
|
802
850
|
function createPaginatedFunction(coreFn, options) {
|
|
803
|
-
const {
|
|
851
|
+
const {
|
|
852
|
+
sdk,
|
|
853
|
+
schema,
|
|
854
|
+
name,
|
|
855
|
+
defaultPageSize,
|
|
856
|
+
adaptPage,
|
|
857
|
+
annotator,
|
|
858
|
+
getDeprecation
|
|
859
|
+
} = options;
|
|
804
860
|
const pageFunction = createPageFunction(coreFn, { sdk, adaptPage });
|
|
805
861
|
const functionName = name || coreFn.name;
|
|
806
862
|
const namedFunctions = {
|
|
@@ -815,14 +871,26 @@ function createPaginatedFunction(coreFn, options) {
|
|
|
815
871
|
const normalizedOptions = callOptions ?? {};
|
|
816
872
|
const args = [normalizedOptions];
|
|
817
873
|
const depth = Math.max(context.depth, getCurrentDepth());
|
|
818
|
-
const
|
|
874
|
+
const insideObserver = isInsideObserver();
|
|
875
|
+
const hooks = insideObserver ? void 0 : sdk.context.hooks;
|
|
819
876
|
const adaptError = resolveCoreOptions(sdk.context)?.adaptError;
|
|
820
|
-
|
|
877
|
+
applyAnnotations({
|
|
878
|
+
context,
|
|
879
|
+
methodName: functionName,
|
|
880
|
+
input: normalizedOptions,
|
|
881
|
+
hookAnnotator: hooks?.annotator,
|
|
882
|
+
methodAnnotator: annotator
|
|
883
|
+
});
|
|
884
|
+
const hookBase = {
|
|
821
885
|
methodName: functionName,
|
|
822
886
|
args,
|
|
823
887
|
isPaginated: true,
|
|
824
|
-
depth
|
|
825
|
-
|
|
888
|
+
depth,
|
|
889
|
+
callId: context.callId,
|
|
890
|
+
callOrigin: context.callOrigin,
|
|
891
|
+
annotations: context.annotations
|
|
892
|
+
};
|
|
893
|
+
hooks?.onMethodStart?.({ ...hookBase });
|
|
826
894
|
try {
|
|
827
895
|
const validatedOptions = {
|
|
828
896
|
...normalizedOptions,
|
|
@@ -848,19 +916,13 @@ function createPaginatedFunction(coreFn, options) {
|
|
|
848
916
|
firstPagePromise.then(
|
|
849
917
|
() => {
|
|
850
918
|
hooks.onMethodEnd({
|
|
851
|
-
|
|
852
|
-
args,
|
|
853
|
-
isPaginated: true,
|
|
854
|
-
depth,
|
|
919
|
+
...hookBase,
|
|
855
920
|
durationMs: Date.now() - startTime
|
|
856
921
|
});
|
|
857
922
|
},
|
|
858
923
|
(error) => {
|
|
859
924
|
hooks.onMethodEnd({
|
|
860
|
-
|
|
861
|
-
args,
|
|
862
|
-
isPaginated: true,
|
|
863
|
-
depth,
|
|
925
|
+
...hookBase,
|
|
864
926
|
durationMs: Date.now() - startTime,
|
|
865
927
|
error: error instanceof Error ? error : new Error(String(error))
|
|
866
928
|
});
|
|
@@ -899,10 +961,7 @@ function createPaginatedFunction(coreFn, options) {
|
|
|
899
961
|
} catch (error) {
|
|
900
962
|
const normalizedError = normalizeError(error, adaptError);
|
|
901
963
|
hooks?.onMethodEnd?.({
|
|
902
|
-
|
|
903
|
-
args,
|
|
904
|
-
isPaginated: true,
|
|
905
|
-
depth,
|
|
964
|
+
...hookBase,
|
|
906
965
|
durationMs: Date.now() - startTime,
|
|
907
966
|
error: normalizedError
|
|
908
967
|
});
|
|
@@ -1318,6 +1377,7 @@ function defineMethod(config) {
|
|
|
1318
1377
|
meta: collectLeafMeta(config),
|
|
1319
1378
|
resolvers: config.resolvers,
|
|
1320
1379
|
formatter: config.formatter,
|
|
1380
|
+
annotator: config.annotator,
|
|
1321
1381
|
output: config.output,
|
|
1322
1382
|
positional: config.positional,
|
|
1323
1383
|
setup: config.setup,
|
|
@@ -1477,7 +1537,8 @@ function defineHook(config) {
|
|
|
1477
1537
|
setup: config.setup,
|
|
1478
1538
|
dispose: config.dispose,
|
|
1479
1539
|
wrap: config.wrap,
|
|
1480
|
-
observe: config.observe
|
|
1540
|
+
observe: config.observe,
|
|
1541
|
+
annotator: config.annotator
|
|
1481
1542
|
};
|
|
1482
1543
|
}
|
|
1483
1544
|
function declarePlugin(config) {
|
|
@@ -1903,7 +1964,14 @@ function collectPlugins(root, materialized = /* @__PURE__ */ new Set(), configur
|
|
|
1903
1964
|
}
|
|
1904
1965
|
return byId;
|
|
1905
1966
|
}
|
|
1906
|
-
function bindValue(
|
|
1967
|
+
function bindValue({
|
|
1968
|
+
target,
|
|
1969
|
+
key,
|
|
1970
|
+
entry,
|
|
1971
|
+
bindMode = "surface",
|
|
1972
|
+
ctx,
|
|
1973
|
+
frameworkOrigin = false
|
|
1974
|
+
}) {
|
|
1907
1975
|
if (entry.pluginType === "property" && entry.getValue) {
|
|
1908
1976
|
Object.defineProperty(target, key, {
|
|
1909
1977
|
get: entry.getValue,
|
|
@@ -1911,7 +1979,7 @@ function bindValue(target, key, entry, callType = "surface", ctx) {
|
|
|
1911
1979
|
configurable: true
|
|
1912
1980
|
});
|
|
1913
1981
|
} else {
|
|
1914
|
-
const value =
|
|
1982
|
+
const value = bindMode === "internal" && entry.pluginType === "method" ? entry.bindInternal?.({ ctx, frameworkOrigin }) ?? entry.internalValue ?? entry.value : entry.value;
|
|
1915
1983
|
Object.defineProperty(target, key, {
|
|
1916
1984
|
value,
|
|
1917
1985
|
writable: true,
|
|
@@ -1929,7 +1997,12 @@ function buildSurface(context, ...maps) {
|
|
|
1929
1997
|
sdk[CONTEXT] = context;
|
|
1930
1998
|
return sdk;
|
|
1931
1999
|
}
|
|
1932
|
-
function buildImports(
|
|
2000
|
+
function buildImports({
|
|
2001
|
+
plugins,
|
|
2002
|
+
importBindings,
|
|
2003
|
+
ctx,
|
|
2004
|
+
frameworkOrigin = false
|
|
2005
|
+
}) {
|
|
1933
2006
|
const imports = {};
|
|
1934
2007
|
for (const { binding, id, optional } of importBindings) {
|
|
1935
2008
|
const entry = plugins[id];
|
|
@@ -1942,10 +2015,31 @@ function buildImports(plugins, importBindings, ctx) {
|
|
|
1942
2015
|
});
|
|
1943
2016
|
continue;
|
|
1944
2017
|
}
|
|
1945
|
-
bindValue(
|
|
2018
|
+
bindValue({
|
|
2019
|
+
target: imports,
|
|
2020
|
+
key: binding,
|
|
2021
|
+
entry,
|
|
2022
|
+
bindMode: "internal",
|
|
2023
|
+
ctx,
|
|
2024
|
+
frameworkOrigin
|
|
2025
|
+
});
|
|
1946
2026
|
}
|
|
1947
2027
|
return imports;
|
|
1948
2028
|
}
|
|
2029
|
+
function bindInternalTwin({
|
|
2030
|
+
ctx,
|
|
2031
|
+
frameworkOrigin,
|
|
2032
|
+
withContext,
|
|
2033
|
+
internalValue
|
|
2034
|
+
}) {
|
|
2035
|
+
if (ctx) {
|
|
2036
|
+
return (...args) => withContext(childCallContext(ctx))(...args);
|
|
2037
|
+
}
|
|
2038
|
+
if (frameworkOrigin) {
|
|
2039
|
+
return (...args) => withContext(rootCallContext({ callOrigin: "internal" }))(...args);
|
|
2040
|
+
}
|
|
2041
|
+
return internalValue;
|
|
2042
|
+
}
|
|
1949
2043
|
function mirrorLegacyRootKeys(context, rootKeys, meta) {
|
|
1950
2044
|
const exports = {};
|
|
1951
2045
|
for (const [name, value] of Object.entries(rootKeys)) {
|
|
@@ -2009,7 +2103,11 @@ function bindResolver(resolver, plugins) {
|
|
|
2009
2103
|
case "info":
|
|
2010
2104
|
return { type: "info", text: resolver.text };
|
|
2011
2105
|
case "object": {
|
|
2012
|
-
const imports = buildImports(
|
|
2106
|
+
const imports = buildImports({
|
|
2107
|
+
plugins,
|
|
2108
|
+
importBindings: resolver.importBindings,
|
|
2109
|
+
frameworkOrigin: true
|
|
2110
|
+
});
|
|
2013
2111
|
const bound = {
|
|
2014
2112
|
type: "object",
|
|
2015
2113
|
requireParameters: resolver.requireParameters
|
|
@@ -2050,7 +2148,11 @@ function bindResolver(resolver, plugins) {
|
|
|
2050
2148
|
return bound;
|
|
2051
2149
|
}
|
|
2052
2150
|
case "dynamic": {
|
|
2053
|
-
const imports = buildImports(
|
|
2151
|
+
const imports = buildImports({
|
|
2152
|
+
plugins,
|
|
2153
|
+
importBindings: resolver.importBindings,
|
|
2154
|
+
frameworkOrigin: true
|
|
2155
|
+
});
|
|
2054
2156
|
const {
|
|
2055
2157
|
getContext: getContext2,
|
|
2056
2158
|
listItems,
|
|
@@ -2105,7 +2207,11 @@ function bindDefinitions(definitions, plugins) {
|
|
|
2105
2207
|
return out;
|
|
2106
2208
|
}
|
|
2107
2209
|
function bindFormatter(formatter, plugins) {
|
|
2108
|
-
const imports = buildImports(
|
|
2210
|
+
const imports = buildImports({
|
|
2211
|
+
plugins,
|
|
2212
|
+
importBindings: formatter.importBindings,
|
|
2213
|
+
frameworkOrigin: true
|
|
2214
|
+
});
|
|
2109
2215
|
const bound = { format: formatter.format };
|
|
2110
2216
|
const { getContext: getContext2 } = formatter;
|
|
2111
2217
|
if (getContext2)
|
|
@@ -2192,17 +2298,32 @@ function buildMethodEntries(descriptors, context, states) {
|
|
|
2192
2298
|
// Replaced below; never called.
|
|
2193
2299
|
value: () => void 0
|
|
2194
2300
|
};
|
|
2195
|
-
const callRun = (input, ctx) =>
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2301
|
+
const callRun = (input, ctx) => {
|
|
2302
|
+
const callContext = ctx ?? rootCallContext();
|
|
2303
|
+
return descriptor.run({
|
|
2304
|
+
imports: buildImports({
|
|
2305
|
+
plugins,
|
|
2306
|
+
importBindings: descriptor.importBindings,
|
|
2307
|
+
ctx: callContext
|
|
2308
|
+
}),
|
|
2309
|
+
state: states.get(id),
|
|
2310
|
+
input,
|
|
2311
|
+
callContext,
|
|
2312
|
+
annotate: (metadata) => {
|
|
2313
|
+
Object.assign(callContext.annotations, metadata);
|
|
2314
|
+
}
|
|
2315
|
+
});
|
|
2316
|
+
};
|
|
2200
2317
|
const fold = (coreFn) => (input, ctx) => {
|
|
2201
2318
|
let next = (i) => coreFn(i, ctx);
|
|
2202
2319
|
for (const wrap of entry.chain) {
|
|
2203
2320
|
const inner = next;
|
|
2204
2321
|
next = (i) => wrap.run({
|
|
2205
|
-
imports: buildImports(
|
|
2322
|
+
imports: buildImports({
|
|
2323
|
+
plugins,
|
|
2324
|
+
importBindings: wrap.owner.importBindings,
|
|
2325
|
+
ctx
|
|
2326
|
+
}),
|
|
2206
2327
|
next: inner,
|
|
2207
2328
|
input: i,
|
|
2208
2329
|
// Overwritten by the chain item's own closure with the owning
|
|
@@ -2213,6 +2334,8 @@ function buildMethodEntries(descriptors, context, states) {
|
|
|
2213
2334
|
return next(input);
|
|
2214
2335
|
};
|
|
2215
2336
|
const sdk = { context };
|
|
2337
|
+
const methodAnnotator = descriptor.annotator;
|
|
2338
|
+
const boundAnnotator = methodAnnotator ? (input) => methodAnnotator({ input }) : void 0;
|
|
2216
2339
|
if (out.type === "list") {
|
|
2217
2340
|
entry.value = createPaginatedFunction(
|
|
2218
2341
|
fold(callRun),
|
|
@@ -2222,6 +2345,7 @@ function buildMethodEntries(descriptors, context, states) {
|
|
|
2222
2345
|
name: descriptor.name,
|
|
2223
2346
|
defaultPageSize: out.defaultPageSize,
|
|
2224
2347
|
adaptPage: out.adaptPage,
|
|
2348
|
+
annotator: boundAnnotator,
|
|
2225
2349
|
getDeprecation: () => entry.meta?.deprecation
|
|
2226
2350
|
}
|
|
2227
2351
|
);
|
|
@@ -2233,6 +2357,7 @@ function buildMethodEntries(descriptors, context, states) {
|
|
|
2233
2357
|
sdk,
|
|
2234
2358
|
schema: descriptor.inputSchema,
|
|
2235
2359
|
name: descriptor.name,
|
|
2360
|
+
annotator: boundAnnotator,
|
|
2236
2361
|
getDeprecation: () => entry.meta?.deprecation
|
|
2237
2362
|
}
|
|
2238
2363
|
);
|
|
@@ -2244,6 +2369,7 @@ function buildMethodEntries(descriptors, context, states) {
|
|
|
2244
2369
|
name: descriptor.name,
|
|
2245
2370
|
schema: descriptor.skipInputValidation ? void 0 : descriptor.inputSchema,
|
|
2246
2371
|
positional: descriptor.positional,
|
|
2372
|
+
annotator: boundAnnotator,
|
|
2247
2373
|
// The boundary reads the deprecation LIVE off the entry, so a
|
|
2248
2374
|
// deprecation merged after build (defineMethodOverride, addPlugin)
|
|
2249
2375
|
// fires too.
|
|
@@ -2264,12 +2390,22 @@ function buildMethodEntries(descriptors, context, states) {
|
|
|
2264
2390
|
const internalValue = (...args) => canonicalValue(pack(args), INTERNAL_CALL);
|
|
2265
2391
|
entry.value = (...args) => canonicalValue(pack(args));
|
|
2266
2392
|
entry.internalValue = internalValue;
|
|
2267
|
-
entry.bindInternal = (
|
|
2393
|
+
entry.bindInternal = (opts) => bindInternalTwin({
|
|
2394
|
+
...opts,
|
|
2395
|
+
withContext: (context2) => {
|
|
2396
|
+
return (...args) => canonicalValue(pack(args), context2);
|
|
2397
|
+
},
|
|
2398
|
+
internalValue
|
|
2399
|
+
});
|
|
2268
2400
|
entry.positional = names;
|
|
2269
2401
|
} else {
|
|
2270
2402
|
const internalValue = (input) => canonicalValue(input, INTERNAL_CALL);
|
|
2271
2403
|
entry.internalValue = internalValue;
|
|
2272
|
-
entry.bindInternal = (
|
|
2404
|
+
entry.bindInternal = (opts) => bindInternalTwin({
|
|
2405
|
+
...opts,
|
|
2406
|
+
withContext: (context2) => (input) => canonicalValue(input, context2),
|
|
2407
|
+
internalValue
|
|
2408
|
+
});
|
|
2273
2409
|
}
|
|
2274
2410
|
plugins[id] = entry;
|
|
2275
2411
|
}
|
|
@@ -2295,8 +2431,14 @@ function buildEagerArtifacts(descriptors, context, states) {
|
|
|
2295
2431
|
if (!dispose) return;
|
|
2296
2432
|
context.disposers?.push({
|
|
2297
2433
|
id,
|
|
2434
|
+
// Teardown is framework-internal: an SDK method a `dispose` calls runs
|
|
2435
|
+
// on an internal-origin root (dropped from telemetry).
|
|
2298
2436
|
dispose: (input) => dispose({
|
|
2299
|
-
imports: buildImports(
|
|
2437
|
+
imports: buildImports({
|
|
2438
|
+
plugins,
|
|
2439
|
+
importBindings: descriptor.importBindings,
|
|
2440
|
+
frameworkOrigin: true
|
|
2441
|
+
}),
|
|
2300
2442
|
state: states.get(id),
|
|
2301
2443
|
input
|
|
2302
2444
|
})
|
|
@@ -2306,7 +2448,10 @@ function buildEagerArtifacts(descriptors, context, states) {
|
|
|
2306
2448
|
states.set(
|
|
2307
2449
|
id,
|
|
2308
2450
|
descriptor.setup ? descriptor.setup({
|
|
2309
|
-
imports: buildImports(
|
|
2451
|
+
imports: buildImports({
|
|
2452
|
+
plugins,
|
|
2453
|
+
importBindings: descriptor.importBindings
|
|
2454
|
+
})
|
|
2310
2455
|
}) : void 0
|
|
2311
2456
|
);
|
|
2312
2457
|
recordDisposer();
|
|
@@ -2318,14 +2463,20 @@ function buildEagerArtifacts(descriptors, context, states) {
|
|
|
2318
2463
|
states.set(
|
|
2319
2464
|
id,
|
|
2320
2465
|
descriptor.setup ? descriptor.setup({
|
|
2321
|
-
imports: buildImports(
|
|
2466
|
+
imports: buildImports({
|
|
2467
|
+
plugins,
|
|
2468
|
+
importBindings: descriptor.importBindings
|
|
2469
|
+
})
|
|
2322
2470
|
}) : void 0
|
|
2323
2471
|
);
|
|
2324
2472
|
} else {
|
|
2325
2473
|
states.set(
|
|
2326
2474
|
id,
|
|
2327
2475
|
descriptor.setup ? descriptor.setup({
|
|
2328
|
-
imports: buildImports(
|
|
2476
|
+
imports: buildImports({
|
|
2477
|
+
plugins,
|
|
2478
|
+
importBindings: descriptor.importBindings
|
|
2479
|
+
})
|
|
2329
2480
|
}) : void 0
|
|
2330
2481
|
);
|
|
2331
2482
|
if (descriptor.privileged) {
|
|
@@ -2343,7 +2494,7 @@ function buildEagerArtifacts(descriptors, context, states) {
|
|
|
2343
2494
|
pluginType: "property",
|
|
2344
2495
|
name: descriptor.name,
|
|
2345
2496
|
getValue: () => get({
|
|
2346
|
-
imports: buildImports(plugins, importBindings),
|
|
2497
|
+
imports: buildImports({ plugins, importBindings }),
|
|
2347
2498
|
state: states.get(id)
|
|
2348
2499
|
}),
|
|
2349
2500
|
meta: descriptor.meta,
|
|
@@ -2379,7 +2530,7 @@ function resolvePlugin(sdk, ref) {
|
|
|
2379
2530
|
return entry.getValue();
|
|
2380
2531
|
}
|
|
2381
2532
|
if (entry.pluginType === "method" && entry.internalValue) {
|
|
2382
|
-
return entry.internalValue;
|
|
2533
|
+
return entry.bindInternal?.({ frameworkOrigin: true }) ?? entry.internalValue;
|
|
2383
2534
|
}
|
|
2384
2535
|
return entry.value;
|
|
2385
2536
|
}
|
|
@@ -2414,7 +2565,7 @@ function resolveAggregates(descriptors, context) {
|
|
|
2414
2565
|
if (descriptor.pluginType !== "aggregate") continue;
|
|
2415
2566
|
const exports = {};
|
|
2416
2567
|
for (const [binding, child] of Object.entries(descriptor.exports)) {
|
|
2417
|
-
bindValue(exports, binding, plugins[child.id]);
|
|
2568
|
+
bindValue({ target: exports, key: binding, entry: plugins[child.id] });
|
|
2418
2569
|
}
|
|
2419
2570
|
plugins[id] = { pluginType: "aggregate", name: descriptor.name, exports };
|
|
2420
2571
|
}
|
|
@@ -2457,23 +2608,39 @@ function assembleHooks(descriptors, context, states) {
|
|
|
2457
2608
|
const plugins = context.plugins;
|
|
2458
2609
|
for (const id of topoOrder(descriptors)) {
|
|
2459
2610
|
const descriptor = descriptors.get(id);
|
|
2460
|
-
if (!descriptor || descriptor.pluginType !== "hook" || !descriptor.observe) {
|
|
2611
|
+
if (!descriptor || descriptor.pluginType !== "hook" || !descriptor.observe && !descriptor.annotator) {
|
|
2461
2612
|
continue;
|
|
2462
2613
|
}
|
|
2463
|
-
const { observe } = descriptor;
|
|
2464
|
-
const imports = buildImports(plugins, descriptor.importBindings);
|
|
2614
|
+
const { observe, annotator } = descriptor;
|
|
2465
2615
|
const state = states.get(id);
|
|
2466
2616
|
const contributed = {};
|
|
2467
|
-
if (observe
|
|
2468
|
-
const
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2617
|
+
if (observe?.onMethodStart || observe?.onMethodEnd) {
|
|
2618
|
+
const imports = buildImports({
|
|
2619
|
+
plugins,
|
|
2620
|
+
importBindings: descriptor.importBindings,
|
|
2621
|
+
frameworkOrigin: true
|
|
2622
|
+
});
|
|
2623
|
+
if (observe.onMethodStart) {
|
|
2624
|
+
const onStart = observe.onMethodStart;
|
|
2625
|
+
contributed.onMethodStart = (input) => {
|
|
2626
|
+
runIsolatedObserver(() => onStart({ imports, input, state }));
|
|
2627
|
+
};
|
|
2628
|
+
}
|
|
2629
|
+
if (observe.onMethodEnd) {
|
|
2630
|
+
const onEnd = observe.onMethodEnd;
|
|
2631
|
+
contributed.onMethodEnd = (input) => {
|
|
2632
|
+
runIsolatedObserver(() => onEnd({ imports, input, state }));
|
|
2633
|
+
};
|
|
2634
|
+
}
|
|
2472
2635
|
}
|
|
2473
|
-
if (
|
|
2474
|
-
const
|
|
2475
|
-
contributed.
|
|
2476
|
-
|
|
2636
|
+
if (annotator) {
|
|
2637
|
+
const annotatorFn = annotator;
|
|
2638
|
+
contributed.annotator = ({ methodName, input }) => {
|
|
2639
|
+
try {
|
|
2640
|
+
return annotatorFn({ methodName, input, state });
|
|
2641
|
+
} catch {
|
|
2642
|
+
return {};
|
|
2643
|
+
}
|
|
2477
2644
|
};
|
|
2478
2645
|
}
|
|
2479
2646
|
context.hooks = buildHooks(context.hooks, contributed);
|
|
@@ -2507,7 +2674,11 @@ function createSdk(root, options) {
|
|
|
2507
2674
|
pluginSurface = plugins2[plugin.id].exports;
|
|
2508
2675
|
} else {
|
|
2509
2676
|
pluginSurface = {};
|
|
2510
|
-
bindValue(
|
|
2677
|
+
bindValue({
|
|
2678
|
+
target: pluginSurface,
|
|
2679
|
+
key: plugin.name,
|
|
2680
|
+
entry: plugins2[plugin.id]
|
|
2681
|
+
});
|
|
2511
2682
|
}
|
|
2512
2683
|
for (const key of Object.keys(legacyExports)) context.surface[key] = key;
|
|
2513
2684
|
if (plugin.pluginType === "aggregate") {
|
|
@@ -2524,7 +2695,7 @@ function createSdk(root, options) {
|
|
|
2524
2695
|
if (root.pluginType === "method" || root.pluginType === "property") {
|
|
2525
2696
|
context.surface[root.name] = root.id;
|
|
2526
2697
|
const sdk = buildSurface(context);
|
|
2527
|
-
bindValue(sdk, root.name, plugins[root.id]);
|
|
2698
|
+
bindValue({ target: sdk, key: root.name, entry: plugins[root.id] });
|
|
2528
2699
|
return sdk;
|
|
2529
2700
|
}
|
|
2530
2701
|
if (root.pluginType === "aggregate")
|
|
@@ -2556,7 +2727,7 @@ function addModelPlugin(sdk, plugin, options = {}) {
|
|
|
2556
2727
|
context.surface[binding] = child.id;
|
|
2557
2728
|
}
|
|
2558
2729
|
} else {
|
|
2559
|
-
bindValue(sdk, plugin.name, entry);
|
|
2730
|
+
bindValue({ target: sdk, key: plugin.name, entry });
|
|
2560
2731
|
context.surface[plugin.name] = plugin.id;
|
|
2561
2732
|
}
|
|
2562
2733
|
}
|
|
@@ -5828,7 +5999,7 @@ function parseDeprecationDate(value) {
|
|
|
5828
5999
|
}
|
|
5829
6000
|
|
|
5830
6001
|
// src/sdk-version.ts
|
|
5831
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
6002
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.89.0" : void 0) || "unknown";
|
|
5832
6003
|
|
|
5833
6004
|
// src/utils/open-url.ts
|
|
5834
6005
|
var nodePrefix = "node:";
|
|
@@ -9086,6 +9257,29 @@ var workflowVersionIdResolver = defineResolver({
|
|
|
9086
9257
|
})
|
|
9087
9258
|
});
|
|
9088
9259
|
|
|
9260
|
+
// src/resolvers/workflowDraftId.ts
|
|
9261
|
+
var listWorkflowDraftsRef = declareMethod({ id: "listWorkflowDrafts" });
|
|
9262
|
+
var workflowDraftIdResolver = defineResolver({
|
|
9263
|
+
imports: [listWorkflowDraftsRef],
|
|
9264
|
+
requireParameters: ["workflow"],
|
|
9265
|
+
listItems: ({
|
|
9266
|
+
imports,
|
|
9267
|
+
input,
|
|
9268
|
+
cursor
|
|
9269
|
+
}) => imports.listWorkflowDrafts({
|
|
9270
|
+
workflow: input.workflow,
|
|
9271
|
+
cursor
|
|
9272
|
+
}),
|
|
9273
|
+
prompt: ({ items }) => ({
|
|
9274
|
+
type: "list",
|
|
9275
|
+
message: "Select a workflow draft:",
|
|
9276
|
+
choices: items.map((d) => ({
|
|
9277
|
+
label: `${d.slug} \u2014 last edited ${d.last_edited_at ?? "never"}`,
|
|
9278
|
+
value: d.id
|
|
9279
|
+
}))
|
|
9280
|
+
})
|
|
9281
|
+
});
|
|
9282
|
+
|
|
9089
9283
|
// src/resolvers/workflowRunId.ts
|
|
9090
9284
|
var listWorkflowRunsRef = declareMethod({ id: "listWorkflowRuns" });
|
|
9091
9285
|
var workflowRunIdResolver = defineResolver({
|
|
@@ -9758,18 +9952,6 @@ var tableSortResolver = defineResolver({
|
|
|
9758
9952
|
}
|
|
9759
9953
|
});
|
|
9760
9954
|
|
|
9761
|
-
// src/plugins/eventEmission/method-metadata.ts
|
|
9762
|
-
var SCOPE_KEY = "methodMetadata";
|
|
9763
|
-
function setMethodMetadata(metadata) {
|
|
9764
|
-
const scope2 = getCurrentScope();
|
|
9765
|
-
if (!scope2) return;
|
|
9766
|
-
const existing = scope2[SCOPE_KEY];
|
|
9767
|
-
scope2[SCOPE_KEY] = { ...existing, ...metadata };
|
|
9768
|
-
}
|
|
9769
|
-
function getMethodMetadata() {
|
|
9770
|
-
return getCurrentScope()?.[SCOPE_KEY];
|
|
9771
|
-
}
|
|
9772
|
-
|
|
9773
9955
|
// src/plugins/listActions/index.ts
|
|
9774
9956
|
var listActionsPlugin = defineMethod({
|
|
9775
9957
|
name: "listActions",
|
|
@@ -9787,7 +9969,7 @@ var listActionsPlugin = defineMethod({
|
|
|
9787
9969
|
// of listing every action. `getAction` (where `actionType` is required) keeps
|
|
9788
9970
|
// the resolver.
|
|
9789
9971
|
resolvers: { app: appKeyResolver },
|
|
9790
|
-
run: async ({ imports, input }) => {
|
|
9972
|
+
run: async ({ imports, input, annotate }) => {
|
|
9791
9973
|
const api = imports.api;
|
|
9792
9974
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
9793
9975
|
const appKey = "app" in input ? input.app : input.appKey;
|
|
@@ -9798,10 +9980,7 @@ var listActionsPlugin = defineMethod({
|
|
|
9798
9980
|
{ configType: "current_implementation_id" }
|
|
9799
9981
|
);
|
|
9800
9982
|
}
|
|
9801
|
-
|
|
9802
|
-
selectedApi,
|
|
9803
|
-
operationType: input.actionType ?? null
|
|
9804
|
-
});
|
|
9983
|
+
annotate({ selectedApi });
|
|
9805
9984
|
const data = await api.get(
|
|
9806
9985
|
"/zapier/api/v4/implementations/",
|
|
9807
9986
|
{
|
|
@@ -9856,10 +10035,6 @@ var getActionPlugin = defineMethod({
|
|
|
9856
10035
|
const appKey = "app" in input ? input.app : input.appKey;
|
|
9857
10036
|
const actionKey = "action" in input ? input.action : input.actionKey;
|
|
9858
10037
|
const { actionType } = input;
|
|
9859
|
-
setMethodMetadata({
|
|
9860
|
-
operationType: actionType,
|
|
9861
|
-
operationKey: actionKey
|
|
9862
|
-
});
|
|
9863
10038
|
for await (const action of imports.listActions({ app: appKey }).items()) {
|
|
9864
10039
|
if ((action.key === actionKey || action.id === actionKey) && action.action_type === actionType) {
|
|
9865
10040
|
return { data: action };
|
|
@@ -9952,9 +10127,10 @@ var runActionPlugin = defineMethod({
|
|
|
9952
10127
|
inputs: inputsResolver
|
|
9953
10128
|
},
|
|
9954
10129
|
// A per-SDK-instance TTL cache of resolved (selectedApi, actionId), built once
|
|
9955
|
-
// in setup so it persists across calls.
|
|
9956
|
-
// (`
|
|
9957
|
-
|
|
10130
|
+
// in setup so it persists across calls. The imports it resolves through
|
|
10131
|
+
// (`manifest.getVersionedImplementationId`, `getAction`) are threaded in per
|
|
10132
|
+
// call from `run`, not captured here.
|
|
10133
|
+
setup: () => {
|
|
9958
10134
|
const cache = /* @__PURE__ */ new Map();
|
|
9959
10135
|
function evictIfNeeded() {
|
|
9960
10136
|
if (cache.size < CONTEXT_CACHE_MAX_SIZE) return;
|
|
@@ -9974,7 +10150,7 @@ var runActionPlugin = defineMethod({
|
|
|
9974
10150
|
if (!evictedAny && oldestKey) cache.delete(oldestKey);
|
|
9975
10151
|
}
|
|
9976
10152
|
async function resolveRunActionContext(options) {
|
|
9977
|
-
const { appKey, actionKey, actionType } = options;
|
|
10153
|
+
const { imports, appKey, actionKey, actionType } = options;
|
|
9978
10154
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
9979
10155
|
const selectedApi = await getVersionedImplementationId(appKey);
|
|
9980
10156
|
if (!selectedApi) {
|
|
@@ -10013,7 +10189,7 @@ var runActionPlugin = defineMethod({
|
|
|
10013
10189
|
}
|
|
10014
10190
|
return { getRunActionContext };
|
|
10015
10191
|
},
|
|
10016
|
-
run: async ({ imports, input, state }) => {
|
|
10192
|
+
run: async ({ imports, input, state, annotate }) => {
|
|
10017
10193
|
const api = imports.api;
|
|
10018
10194
|
const resolveConnection = imports.connections.resolveConnection;
|
|
10019
10195
|
const appKey = "app" in input ? input.app : input.appKey;
|
|
@@ -10034,15 +10210,12 @@ var runActionPlugin = defineMethod({
|
|
|
10034
10210
|
resolveConnection
|
|
10035
10211
|
});
|
|
10036
10212
|
const { selectedApi, actionId } = await state.getRunActionContext({
|
|
10213
|
+
imports,
|
|
10037
10214
|
appKey,
|
|
10038
10215
|
actionKey,
|
|
10039
10216
|
actionType
|
|
10040
10217
|
});
|
|
10041
|
-
|
|
10042
|
-
selectedApi,
|
|
10043
|
-
operationType: actionType,
|
|
10044
|
-
operationKey: actionKey
|
|
10045
|
-
});
|
|
10218
|
+
annotate({ selectedApi });
|
|
10046
10219
|
const result = await executeAction({
|
|
10047
10220
|
api,
|
|
10048
10221
|
selectedApi,
|
|
@@ -10678,7 +10851,11 @@ var listActionInputFieldsPlugin = defineMethod({
|
|
|
10678
10851
|
// metadata; the engine permits a resolver importing its host.
|
|
10679
10852
|
inputs: inputsAllOptionalResolver
|
|
10680
10853
|
},
|
|
10681
|
-
run: async ({
|
|
10854
|
+
run: async ({
|
|
10855
|
+
imports,
|
|
10856
|
+
input,
|
|
10857
|
+
annotate
|
|
10858
|
+
}) => {
|
|
10682
10859
|
const api = imports.api;
|
|
10683
10860
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
10684
10861
|
const resolveConnection = imports.connections.resolveConnection;
|
|
@@ -10698,11 +10875,7 @@ var listActionInputFieldsPlugin = defineMethod({
|
|
|
10698
10875
|
{ configType: "current_implementation_id" }
|
|
10699
10876
|
);
|
|
10700
10877
|
}
|
|
10701
|
-
|
|
10702
|
-
selectedApi,
|
|
10703
|
-
operationType: actionType,
|
|
10704
|
-
operationKey: actionKey
|
|
10705
|
-
});
|
|
10878
|
+
annotate({ selectedApi });
|
|
10706
10879
|
const { data: action } = await imports.getAction({
|
|
10707
10880
|
app: appKey,
|
|
10708
10881
|
actionType,
|
|
@@ -10813,7 +10986,11 @@ var listActionInputFieldChoicesPlugin = defineMethod({
|
|
|
10813
10986
|
inputField: inputFieldKeyResolver,
|
|
10814
10987
|
inputs: inputsAllOptionalResolver
|
|
10815
10988
|
},
|
|
10816
|
-
run: async ({
|
|
10989
|
+
run: async ({
|
|
10990
|
+
imports,
|
|
10991
|
+
input,
|
|
10992
|
+
annotate
|
|
10993
|
+
}) => {
|
|
10817
10994
|
const api = imports.api;
|
|
10818
10995
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
10819
10996
|
const resolveConnection = imports.connections.resolveConnection;
|
|
@@ -10842,11 +11019,7 @@ var listActionInputFieldChoicesPlugin = defineMethod({
|
|
|
10842
11019
|
{ configType: "current_implementation_id" }
|
|
10843
11020
|
);
|
|
10844
11021
|
}
|
|
10845
|
-
|
|
10846
|
-
selectedApi,
|
|
10847
|
-
operationType: actionType,
|
|
10848
|
-
operationKey: actionKey
|
|
10849
|
-
});
|
|
11022
|
+
annotate({ selectedApi });
|
|
10850
11023
|
const { data: action } = await imports.getAction({
|
|
10851
11024
|
app: appKey,
|
|
10852
11025
|
actionType,
|
|
@@ -10975,7 +11148,8 @@ var getActionInputFieldsSchemaPlugin = defineMethod({
|
|
|
10975
11148
|
},
|
|
10976
11149
|
run: async ({
|
|
10977
11150
|
imports,
|
|
10978
|
-
input
|
|
11151
|
+
input,
|
|
11152
|
+
annotate
|
|
10979
11153
|
}) => {
|
|
10980
11154
|
const api = imports.api;
|
|
10981
11155
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
@@ -10996,11 +11170,7 @@ var getActionInputFieldsSchemaPlugin = defineMethod({
|
|
|
10996
11170
|
{ configType: "current_implementation_id" }
|
|
10997
11171
|
);
|
|
10998
11172
|
}
|
|
10999
|
-
|
|
11000
|
-
selectedApi,
|
|
11001
|
-
operationType: actionType,
|
|
11002
|
-
operationKey: actionKey
|
|
11003
|
-
});
|
|
11173
|
+
annotate({ selectedApi });
|
|
11004
11174
|
const { data: action } = await imports.getAction({
|
|
11005
11175
|
app: appKey,
|
|
11006
11176
|
actionType,
|
|
@@ -11123,7 +11293,11 @@ var listConnectionsPlugin = defineMethod({
|
|
|
11123
11293
|
adaptPage: adaptZapierPage,
|
|
11124
11294
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
11125
11295
|
},
|
|
11126
|
-
run: async ({
|
|
11296
|
+
run: async ({
|
|
11297
|
+
imports,
|
|
11298
|
+
input,
|
|
11299
|
+
annotate
|
|
11300
|
+
}) => {
|
|
11127
11301
|
const resolveConnection = imports.connections.resolveConnection;
|
|
11128
11302
|
const api = imports.api;
|
|
11129
11303
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
@@ -11138,7 +11312,7 @@ var listConnectionsPlugin = defineMethod({
|
|
|
11138
11312
|
if (appKey) {
|
|
11139
11313
|
const implementationId = await getVersionedImplementationId(appKey);
|
|
11140
11314
|
if (implementationId) {
|
|
11141
|
-
|
|
11315
|
+
annotate({ selectedApi: implementationId });
|
|
11142
11316
|
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
11143
11317
|
searchParams.app_key = versionlessSelectedApi;
|
|
11144
11318
|
} else {
|
|
@@ -11654,12 +11828,12 @@ var getConnectionStartUrlPlugin = defineMethod({
|
|
|
11654
11828
|
outputSchema: GetConnectionStartUrlItemSchema,
|
|
11655
11829
|
output: "item",
|
|
11656
11830
|
resolvers: { app: appKeyResolver },
|
|
11657
|
-
run: async ({ imports, input }) => {
|
|
11831
|
+
run: async ({ imports, input, annotate }) => {
|
|
11658
11832
|
const api = imports.api;
|
|
11659
11833
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
11660
11834
|
const versionedKey = await getVersionedImplementationId(input.app);
|
|
11661
11835
|
const selectedApi = versionedKey ? versionedKey.split("@")[0] : input.app;
|
|
11662
|
-
|
|
11836
|
+
annotate({ selectedApi });
|
|
11663
11837
|
const response = await api.post(
|
|
11664
11838
|
START_PATH,
|
|
11665
11839
|
{ selected_api: selectedApi },
|
|
@@ -11718,12 +11892,12 @@ var waitForNewConnectionPlugin = defineMethod({
|
|
|
11718
11892
|
outputSchema: WaitForNewConnectionItemSchema,
|
|
11719
11893
|
output: "item",
|
|
11720
11894
|
resolvers: { app: appKeyResolver },
|
|
11721
|
-
run: async ({ imports, input }) => {
|
|
11895
|
+
run: async ({ imports, input, annotate }) => {
|
|
11722
11896
|
const api = imports.api;
|
|
11723
11897
|
const getVersionedImplementationId = imports.manifest.getVersionedImplementationId;
|
|
11724
11898
|
const versionedKey = await getVersionedImplementationId(input.app);
|
|
11725
11899
|
const appKey = versionedKey ? versionedKey.split("@")[0] : input.app;
|
|
11726
|
-
|
|
11900
|
+
annotate({ selectedApi: appKey });
|
|
11727
11901
|
try {
|
|
11728
11902
|
const top = await api.poll(CONNECTIONS_PATH, {
|
|
11729
11903
|
searchParams: {
|
|
@@ -11841,11 +12015,11 @@ var createConnectionPlugin = defineMethod({
|
|
|
11841
12015
|
]
|
|
11842
12016
|
})
|
|
11843
12017
|
}),
|
|
11844
|
-
run: async ({ imports, input }) => {
|
|
12018
|
+
run: async ({ imports, input, annotate }) => {
|
|
11845
12019
|
const { data: start2 } = await imports.getConnectionStartUrl({
|
|
11846
12020
|
app: input.app
|
|
11847
12021
|
});
|
|
11848
|
-
|
|
12022
|
+
annotate({ selectedApi: start2.app });
|
|
11849
12023
|
console.error(
|
|
11850
12024
|
`
|
|
11851
12025
|
Open this URL to complete the connection:
|
|
@@ -12100,6 +12274,10 @@ var triggerInboxItemFormatter = defineFormatter({
|
|
|
12100
12274
|
|
|
12101
12275
|
// src/plugins/triggers/shared.ts
|
|
12102
12276
|
var triggerCategories = ["trigger"];
|
|
12277
|
+
function deriveReadOperation() {
|
|
12278
|
+
const annotations = { operationType: "read" };
|
|
12279
|
+
return { ...annotations };
|
|
12280
|
+
}
|
|
12103
12281
|
|
|
12104
12282
|
// src/plugins/triggers/utils.ts
|
|
12105
12283
|
var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -12145,6 +12323,7 @@ var createTriggerInboxPlugin = defineMethod({
|
|
|
12145
12323
|
outputSchema: TriggerInboxItemSchema,
|
|
12146
12324
|
output: "item",
|
|
12147
12325
|
formatter: triggerInboxItemFormatter,
|
|
12326
|
+
annotator: deriveReadOperation,
|
|
12148
12327
|
// actionKeyResolver and inputsResolver depend on actionType, which is always
|
|
12149
12328
|
// "read" for triggers. Pin it as a constant resolver so it's seeded into
|
|
12150
12329
|
// resolvedParams without polluting the user-facing schema (where it would
|
|
@@ -12249,6 +12428,7 @@ var ensureTriggerInboxPlugin = defineMethod({
|
|
|
12249
12428
|
outputSchema: TriggerInboxItemSchema,
|
|
12250
12429
|
output: "item",
|
|
12251
12430
|
formatter: triggerInboxItemFormatter,
|
|
12431
|
+
annotator: deriveReadOperation,
|
|
12252
12432
|
// actionKeyResolver and inputsResolver depend on actionType, which is always
|
|
12253
12433
|
// "read" for triggers. Pin it as a constant resolver so it's seeded into
|
|
12254
12434
|
// resolvedParams without polluting the user-facing schema.
|
|
@@ -13553,6 +13733,7 @@ var listTriggerInputFieldsPlugin = defineMethod({
|
|
|
13553
13733
|
outputSchema: RootFieldItemSchema,
|
|
13554
13734
|
output: { type: "list", defaultPageSize: DEFAULT_PAGE_SIZE },
|
|
13555
13735
|
formatter: rootFieldItemFormatter,
|
|
13736
|
+
annotator: deriveReadOperation,
|
|
13556
13737
|
// actionKeyResolver and inputsAllOptionalResolver depend on actionType. Pin it
|
|
13557
13738
|
// to "read" so they resolve correctly without the user setting it.
|
|
13558
13739
|
resolvers: {
|
|
@@ -13599,6 +13780,7 @@ var listTriggerInputFieldChoicesPlugin = defineMethod({
|
|
|
13599
13780
|
outputSchema: InputFieldChoiceItemSchema,
|
|
13600
13781
|
output: { type: "list", defaultPageSize: DEFAULT_PAGE_SIZE },
|
|
13601
13782
|
formatter: inputFieldChoiceItemFormatter,
|
|
13783
|
+
annotator: deriveReadOperation,
|
|
13602
13784
|
resolvers: {
|
|
13603
13785
|
app: appKeyResolver,
|
|
13604
13786
|
action: actionKeyResolver,
|
|
@@ -13642,6 +13824,7 @@ var getTriggerInputFieldsSchemaPlugin = defineMethod({
|
|
|
13642
13824
|
// Passthrough: getActionInputFieldsSchema already returns `{ data }`, so
|
|
13643
13825
|
// `output: "raw"` surfaces that envelope unchanged.
|
|
13644
13826
|
output: "raw",
|
|
13827
|
+
annotator: deriveReadOperation,
|
|
13645
13828
|
resolvers: {
|
|
13646
13829
|
app: appKeyResolver,
|
|
13647
13830
|
action: actionKeyResolver,
|
|
@@ -14759,6 +14942,14 @@ function buildMethodCalledEvent(data, context = {}) {
|
|
|
14759
14942
|
}
|
|
14760
14943
|
|
|
14761
14944
|
// src/plugins/eventEmission/event-emission-hook.ts
|
|
14945
|
+
function readMethodMetadata(annotations) {
|
|
14946
|
+
const readString = (value) => typeof value === "string" ? value : null;
|
|
14947
|
+
return {
|
|
14948
|
+
selectedApi: readString(annotations.selectedApi),
|
|
14949
|
+
operationType: readString(annotations.operationType),
|
|
14950
|
+
operationKey: readString(annotations.operationKey)
|
|
14951
|
+
};
|
|
14952
|
+
}
|
|
14762
14953
|
function computeArgumentCount(args) {
|
|
14763
14954
|
if (args.length === 1) {
|
|
14764
14955
|
const arg0 = args[0];
|
|
@@ -14769,9 +14960,18 @@ function computeArgumentCount(args) {
|
|
|
14769
14960
|
return args.filter((a) => a !== void 0).length;
|
|
14770
14961
|
}
|
|
14771
14962
|
function makeMethodEndHook(emitMethodCalled) {
|
|
14772
|
-
return ({
|
|
14773
|
-
|
|
14774
|
-
|
|
14963
|
+
return ({
|
|
14964
|
+
methodName,
|
|
14965
|
+
args,
|
|
14966
|
+
isPaginated,
|
|
14967
|
+
depth,
|
|
14968
|
+
callOrigin,
|
|
14969
|
+
annotations,
|
|
14970
|
+
durationMs,
|
|
14971
|
+
error
|
|
14972
|
+
}) => {
|
|
14973
|
+
if (callOrigin === "internal" || depth > 0) return;
|
|
14974
|
+
const metadata = readMethodMetadata(annotations);
|
|
14775
14975
|
emitMethodCalled({
|
|
14776
14976
|
method_name: methodName,
|
|
14777
14977
|
execution_duration_ms: durationMs,
|
|
@@ -14780,13 +14980,34 @@ function makeMethodEndHook(emitMethodCalled) {
|
|
|
14780
14980
|
error_type: error?.constructor.name ?? null,
|
|
14781
14981
|
argument_count: computeArgumentCount(args),
|
|
14782
14982
|
is_paginated: isPaginated,
|
|
14783
|
-
selected_api: metadata
|
|
14784
|
-
operation_type: metadata
|
|
14785
|
-
operation_key: metadata
|
|
14983
|
+
selected_api: metadata.selectedApi ?? null,
|
|
14984
|
+
operation_type: metadata.operationType ?? null,
|
|
14985
|
+
operation_key: metadata.operationKey ?? null
|
|
14786
14986
|
});
|
|
14787
14987
|
};
|
|
14788
14988
|
}
|
|
14789
14989
|
|
|
14990
|
+
// src/plugins/eventEmission/annotator.ts
|
|
14991
|
+
function zapierAnnotate({ input }) {
|
|
14992
|
+
const annotations = {};
|
|
14993
|
+
if (typeof input === "object" && input !== null) {
|
|
14994
|
+
const record = input;
|
|
14995
|
+
if (typeof record.actionType === "string") {
|
|
14996
|
+
annotations.operationType = record.actionType;
|
|
14997
|
+
}
|
|
14998
|
+
const operationKey = record.action ?? record.actionKey;
|
|
14999
|
+
if (typeof operationKey === "string") {
|
|
15000
|
+
annotations.operationKey = operationKey;
|
|
15001
|
+
}
|
|
15002
|
+
}
|
|
15003
|
+
return { ...annotations };
|
|
15004
|
+
}
|
|
15005
|
+
var operationAnnotatorPlugin = defineHook({
|
|
15006
|
+
namespace: "zapier",
|
|
15007
|
+
name: "operationAnnotator",
|
|
15008
|
+
annotator: ({ input }) => zapierAnnotate({ input })
|
|
15009
|
+
});
|
|
15010
|
+
|
|
14790
15011
|
// src/plugins/eventEmission/index.ts
|
|
14791
15012
|
var TELEMETRY_EMIT_TIMEOUT_MILLISECONDS = 300;
|
|
14792
15013
|
var registeredListeners = {};
|
|
@@ -15187,7 +15408,8 @@ var zapierSdkPlugin = definePlugin({
|
|
|
15187
15408
|
connectionsPlugin,
|
|
15188
15409
|
capabilitiesPlugin,
|
|
15189
15410
|
eventEmissionPlugin,
|
|
15190
|
-
eventEmissionHookPlugin
|
|
15411
|
+
eventEmissionHookPlugin,
|
|
15412
|
+
operationAnnotatorPlugin
|
|
15191
15413
|
],
|
|
15192
15414
|
exports: [
|
|
15193
15415
|
// The registry reporter: previously synthesized by the legacy merge,
|
|
@@ -15669,6 +15891,7 @@ exports.manifestPlugin = manifestPlugin;
|
|
|
15669
15891
|
exports.manifestPluginRef = manifestPluginRef;
|
|
15670
15892
|
exports.omitExports = omitExports;
|
|
15671
15893
|
exports.openEnum = openEnum;
|
|
15894
|
+
exports.operationAnnotatorPlugin = operationAnnotatorPlugin;
|
|
15672
15895
|
exports.parseConcurrencyEnvVar = parseConcurrencyEnvVar;
|
|
15673
15896
|
exports.readManifestFromFile = readManifestFromFile;
|
|
15674
15897
|
exports.registryPlugin = registryPlugin;
|
|
@@ -15702,6 +15925,7 @@ exports.toTitleCase = toTitleCase;
|
|
|
15702
15925
|
exports.triggerInboxResolver = triggerInboxResolver;
|
|
15703
15926
|
exports.triggerMessagesResolver = triggerMessagesResolver;
|
|
15704
15927
|
exports.updateTableRecordsPlugin = updateTableRecordsPlugin;
|
|
15928
|
+
exports.workflowDraftIdResolver = workflowDraftIdResolver;
|
|
15705
15929
|
exports.workflowIdResolver = workflowIdResolver;
|
|
15706
15930
|
exports.workflowRunIdResolver = workflowRunIdResolver;
|
|
15707
15931
|
exports.workflowVersionIdResolver = workflowVersionIdResolver;
|