@zapier/zapier-sdk 0.77.2 → 0.79.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 +16 -0
- package/dist/experimental.cjs +1278 -240
- package/dist/experimental.d.mts +22 -38
- package/dist/experimental.d.ts +22 -38
- package/dist/experimental.mjs +1269 -241
- package/dist/{index-kC0bJpsG.d.mts → index-DgX1b0Sv.d.mts} +4721 -3769
- package/dist/{index-kC0bJpsG.d.ts → index-DgX1b0Sv.d.ts} +4721 -3769
- package/dist/index.cjs +2815 -1784
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2806 -1785
- package/package.json +2 -2
package/dist/experimental.mjs
CHANGED
|
@@ -50,6 +50,7 @@ function canonicalInputSchema(schema) {
|
|
|
50
50
|
function buildRegistry({
|
|
51
51
|
sdk,
|
|
52
52
|
meta,
|
|
53
|
+
formatters,
|
|
53
54
|
packageFilter
|
|
54
55
|
}) {
|
|
55
56
|
const definitionsByKey = /* @__PURE__ */ new Map();
|
|
@@ -90,7 +91,7 @@ function buildRegistry({
|
|
|
90
91
|
(c) => typeof c === "string" ? c : c.key
|
|
91
92
|
),
|
|
92
93
|
resolvers: m.resolvers,
|
|
93
|
-
formatter:
|
|
94
|
+
formatter: formatters?.[key],
|
|
94
95
|
experimental: m.experimental,
|
|
95
96
|
packages: m.packages,
|
|
96
97
|
confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
|
|
@@ -516,8 +517,8 @@ function normalizeError(error, adaptError) {
|
|
|
516
517
|
);
|
|
517
518
|
}
|
|
518
519
|
function createFunction(coreFn, options) {
|
|
519
|
-
const { sdk, schema } = options;
|
|
520
|
-
const functionName = coreFn.name;
|
|
520
|
+
const { sdk, schema, name } = options;
|
|
521
|
+
const functionName = name || coreFn.name;
|
|
521
522
|
const namedFunctions = {
|
|
522
523
|
[functionName]: async function(callOptions) {
|
|
523
524
|
return runInMethodScope(async () => {
|
|
@@ -692,9 +693,6 @@ function createPaginatedFunction(coreFn, options) {
|
|
|
692
693
|
};
|
|
693
694
|
return namedFunctions[functionName];
|
|
694
695
|
}
|
|
695
|
-
function definePlugin(fn) {
|
|
696
|
-
return fn;
|
|
697
|
-
}
|
|
698
696
|
function createPluginMethod(sdk, config) {
|
|
699
697
|
const { name, inputSchema, handler, ...metaFields } = config;
|
|
700
698
|
const namedHandlers = {
|
|
@@ -763,8 +761,7 @@ function splitPluginContribution(result) {
|
|
|
763
761
|
}
|
|
764
762
|
var RESERVED_ROOT_KEYS = /* @__PURE__ */ new Set([
|
|
765
763
|
"context",
|
|
766
|
-
"getRegistry"
|
|
767
|
-
"addPlugin"
|
|
764
|
+
"getRegistry"
|
|
768
765
|
]);
|
|
769
766
|
function hasOwn(obj, key) {
|
|
770
767
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
@@ -778,15 +775,28 @@ function setOwn(target, key, value) {
|
|
|
778
775
|
});
|
|
779
776
|
}
|
|
780
777
|
function checkCollisions(target, source, kind, callerLabel, override) {
|
|
778
|
+
if (kind === "root key") {
|
|
779
|
+
checkRootKeyCollisions(target, Object.keys(source), override, callerLabel);
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
781
782
|
for (const key of Object.keys(source)) {
|
|
782
|
-
if (
|
|
783
|
+
if (!override && hasOwn(target, key)) {
|
|
784
|
+
throw new Error(
|
|
785
|
+
`${callerLabel}: duplicate ${kind} "${key}". If the override is intentional, pass { override: true } in the options.`
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
function checkRootKeyCollisions(target, keys, override, callerLabel) {
|
|
791
|
+
for (const key of keys) {
|
|
792
|
+
if (RESERVED_ROOT_KEYS.has(key)) {
|
|
783
793
|
throw new Error(
|
|
784
794
|
`${callerLabel}: plugin attempted to register reserved root key "${key}". The SDK uses this key for its own accessor; rename the plugin's method.`
|
|
785
795
|
);
|
|
786
796
|
}
|
|
787
797
|
if (!override && hasOwn(target, key)) {
|
|
788
798
|
throw new Error(
|
|
789
|
-
`${callerLabel}: duplicate
|
|
799
|
+
`${callerLabel}: duplicate root key "${key}". If the override is intentional, pass { override: true } in the options.`
|
|
790
800
|
);
|
|
791
801
|
}
|
|
792
802
|
}
|
|
@@ -837,7 +847,7 @@ function mergeContribution(propertiesTarget, contextTarget, contribution, option
|
|
|
837
847
|
function applyPluginContribution(acc, contribution, options) {
|
|
838
848
|
mergeContribution(acc.view, acc.context, contribution, options);
|
|
839
849
|
}
|
|
840
|
-
function wrapAsSdk(properties, context
|
|
850
|
+
function wrapAsSdk(properties, context) {
|
|
841
851
|
const sdk = {
|
|
842
852
|
...properties,
|
|
843
853
|
context,
|
|
@@ -849,9 +859,6 @@ function wrapAsSdk(properties, context, opts) {
|
|
|
849
859
|
});
|
|
850
860
|
}
|
|
851
861
|
};
|
|
852
|
-
if (opts?.addPlugin !== void 0) {
|
|
853
|
-
sdk.addPlugin = opts.addPlugin;
|
|
854
|
-
}
|
|
855
862
|
return sdk;
|
|
856
863
|
}
|
|
857
864
|
function wrapAccumulatorAsSdk(acc) {
|
|
@@ -870,126 +877,92 @@ function applyPluginToSdk(sdk, plugin, options) {
|
|
|
870
877
|
callerLabel: "addPlugin",
|
|
871
878
|
override: options.override === true
|
|
872
879
|
});
|
|
880
|
+
return contribution;
|
|
873
881
|
}
|
|
874
|
-
function
|
|
875
|
-
const
|
|
882
|
+
function resolveStack(head) {
|
|
883
|
+
const entries = [];
|
|
876
884
|
let node = head;
|
|
877
885
|
while (node) {
|
|
878
|
-
|
|
886
|
+
entries.unshift({ apply: node.entry, override: node.override });
|
|
879
887
|
node = node.prev;
|
|
880
888
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
889
|
+
return entries;
|
|
890
|
+
}
|
|
891
|
+
function composeStackHooks(hooks) {
|
|
892
|
+
let composed = {};
|
|
893
|
+
for (const h of hooks) composed = buildHooks(composed, h);
|
|
894
|
+
return composed;
|
|
895
|
+
}
|
|
896
|
+
function collapseStackEntries(entries, callerLabel) {
|
|
897
|
+
return (outerSdk) => {
|
|
898
|
+
const { context: outerContext, ...outerProperties } = outerSdk ?? {};
|
|
899
|
+
const viewAcc = createPluginAccumulator(outerProperties, outerContext);
|
|
900
|
+
const contribsAcc = createPluginAccumulator();
|
|
901
|
+
const hooks = [];
|
|
902
|
+
for (const { apply, override } of entries) {
|
|
903
|
+
const contribution = splitPluginContribution(
|
|
904
|
+
apply(viewAcc.view)
|
|
905
|
+
);
|
|
906
|
+
const hookless = { ...contribution, hooks: {} };
|
|
907
|
+
applyPluginContribution(viewAcc, hookless, { callerLabel, override });
|
|
908
|
+
applyPluginContribution(contribsAcc, hookless, { callerLabel, override });
|
|
909
|
+
hooks.push(contribution.hooks);
|
|
910
|
+
}
|
|
911
|
+
const stackHooks = composeStackHooks(hooks);
|
|
912
|
+
viewAcc.context.hooks = buildHooks(viewAcc.context.hooks, stackHooks);
|
|
913
|
+
contribsAcc.context.hooks = stackHooks;
|
|
914
|
+
const { context: _ignored, ...contributedRoot } = contribsAcc.view;
|
|
915
|
+
return {
|
|
916
|
+
...contributedRoot,
|
|
917
|
+
context: contribsAcc.context
|
|
918
|
+
};
|
|
919
|
+
};
|
|
896
920
|
}
|
|
897
|
-
function
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
921
|
+
function buildStackAccumulator(head, callerLabel) {
|
|
922
|
+
const entries = resolveStack(head);
|
|
923
|
+
const acc = createPluginAccumulator();
|
|
924
|
+
const hooks = [];
|
|
925
|
+
for (const { apply, override } of entries) {
|
|
902
926
|
const contribution = splitPluginContribution(
|
|
903
|
-
|
|
927
|
+
apply(acc.view)
|
|
904
928
|
);
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
...
|
|
908
|
-
|
|
909
|
-
hooks: { ...context.hooks }
|
|
910
|
-
};
|
|
911
|
-
mergeContribution(mergedProperties, mergedContext, contribution, {
|
|
912
|
-
callerLabel: "addPlugin",
|
|
913
|
-
override: options?.override === true
|
|
914
|
-
});
|
|
915
|
-
return buildSdk(
|
|
916
|
-
mergedProperties,
|
|
917
|
-
mergedContext
|
|
929
|
+
applyPluginContribution(
|
|
930
|
+
acc,
|
|
931
|
+
{ ...contribution, hooks: {} },
|
|
932
|
+
{ callerLabel, override }
|
|
918
933
|
);
|
|
919
|
-
|
|
920
|
-
return wrapAsSdk(properties, context, { addPlugin: addPlugin2 });
|
|
921
|
-
}
|
|
922
|
-
function withDeprecatedAddPlugin(sdk) {
|
|
923
|
-
const initialProperties = {};
|
|
924
|
-
for (const key of Object.keys(sdk)) {
|
|
925
|
-
if (key === "context" || key === "getRegistry" || key === "addPlugin") {
|
|
926
|
-
continue;
|
|
927
|
-
}
|
|
928
|
-
initialProperties[key] = sdk[key];
|
|
934
|
+
hooks.push(contribution.hooks);
|
|
929
935
|
}
|
|
930
|
-
|
|
931
|
-
return
|
|
932
|
-
initialProperties,
|
|
933
|
-
initialContext
|
|
934
|
-
);
|
|
936
|
+
acc.context.hooks = composeStackHooks(hooks);
|
|
937
|
+
return acc;
|
|
935
938
|
}
|
|
936
939
|
function composePlugins(...plugins) {
|
|
937
940
|
logDeprecation(
|
|
938
|
-
"composePlugins(...) is deprecated. Use createPluginStack().use(a).use(b).use(c).toPlugin() instead. The stack carries the same collision-detection and hook-composition behavior
|
|
939
|
-
);
|
|
940
|
-
let stack = buildPluginStack(
|
|
941
|
-
null,
|
|
942
|
-
"composePlugins"
|
|
941
|
+
"composePlugins(...) is deprecated. Use createPluginStack().use(a).use(b).use(c).toPlugin({ name }) instead. The stack carries the same collision-detection and hook-composition behavior and supports per-step { override: true } for intentional duplicates."
|
|
943
942
|
);
|
|
943
|
+
let head = null;
|
|
944
944
|
for (const plugin of plugins) {
|
|
945
|
-
|
|
945
|
+
head = { entry: plugin, override: false, prev: head };
|
|
946
946
|
}
|
|
947
|
-
|
|
947
|
+
const entries = resolveStack(head);
|
|
948
|
+
return collapseStackEntries(entries, "composePlugins");
|
|
948
949
|
}
|
|
949
950
|
function createPluginStack() {
|
|
950
951
|
return buildPluginStack(null, "createPluginStack");
|
|
951
952
|
}
|
|
952
953
|
function buildPluginStack(head, callerLabel) {
|
|
953
|
-
|
|
954
|
+
const stack = {
|
|
954
955
|
use(plugin, options) {
|
|
955
956
|
const next = {
|
|
956
|
-
|
|
957
|
-
plugin,
|
|
957
|
+
entry: plugin,
|
|
958
958
|
override: options?.override === true,
|
|
959
959
|
prev: head
|
|
960
960
|
};
|
|
961
961
|
return buildPluginStack(next, callerLabel);
|
|
962
962
|
},
|
|
963
963
|
toPlugin() {
|
|
964
|
-
const
|
|
965
|
-
|
|
966
|
-
while (node) {
|
|
967
|
-
ordered.unshift(node);
|
|
968
|
-
node = node.prev;
|
|
969
|
-
}
|
|
970
|
-
return (outerSdk) => {
|
|
971
|
-
const { context: outerContext, ...outerProperties } = outerSdk ?? {};
|
|
972
|
-
const viewAcc = createPluginAccumulator(outerProperties, outerContext);
|
|
973
|
-
const contribsAcc = createPluginAccumulator();
|
|
974
|
-
for (const { plugin: subPlugin, override } of ordered) {
|
|
975
|
-
const contribution = splitPluginContribution(
|
|
976
|
-
subPlugin(viewAcc.view)
|
|
977
|
-
);
|
|
978
|
-
applyPluginContribution(viewAcc, contribution, {
|
|
979
|
-
callerLabel,
|
|
980
|
-
override
|
|
981
|
-
});
|
|
982
|
-
applyPluginContribution(contribsAcc, contribution, {
|
|
983
|
-
callerLabel,
|
|
984
|
-
override
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
|
-
const { context: _ignored, ...contributedRoot } = contribsAcc.view;
|
|
988
|
-
return {
|
|
989
|
-
...contributedRoot,
|
|
990
|
-
context: contribsAcc.context
|
|
991
|
-
};
|
|
992
|
-
};
|
|
964
|
+
const entries = resolveStack(head);
|
|
965
|
+
return collapseStackEntries(entries, callerLabel);
|
|
993
966
|
},
|
|
994
967
|
toSdk() {
|
|
995
968
|
return wrapAccumulatorAsSdk(
|
|
@@ -997,6 +970,891 @@ function buildPluginStack(head, callerLabel) {
|
|
|
997
970
|
);
|
|
998
971
|
}
|
|
999
972
|
};
|
|
973
|
+
return stack;
|
|
974
|
+
}
|
|
975
|
+
function parseId(id) {
|
|
976
|
+
const at = id.lastIndexOf("/");
|
|
977
|
+
return at === -1 ? { name: id, namespace: void 0 } : { name: id.slice(at + 1), namespace: id.slice(0, at) };
|
|
978
|
+
}
|
|
979
|
+
function makeId(name, namespace, kind = "leaf") {
|
|
980
|
+
validateName(name, kind);
|
|
981
|
+
if (namespace !== void 0) validateNamespace(namespace);
|
|
982
|
+
return namespace ? `${namespace}/${name}` : name;
|
|
983
|
+
}
|
|
984
|
+
var NAME_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
985
|
+
var SEGMENT_RE = /^@?[A-Za-z0-9._-]+$/;
|
|
986
|
+
function validateName(name, kind) {
|
|
987
|
+
if (name === "") throw new Error("Plugin name must not be empty.");
|
|
988
|
+
if (kind === "leaf") {
|
|
989
|
+
if (!NAME_RE.test(name)) {
|
|
990
|
+
throw new Error(
|
|
991
|
+
`Plugin name "${name}" must be a valid JS identifier (it is the binding name).`
|
|
992
|
+
);
|
|
993
|
+
}
|
|
994
|
+
} else if (!SEGMENT_RE.test(name)) {
|
|
995
|
+
throw new Error(
|
|
996
|
+
`Plugin name "${name}" must be package-like (letters, digits, ".", "_", "-", optional leading "@") with no "/".`
|
|
997
|
+
);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
function validateNamespace(namespace) {
|
|
1001
|
+
if (namespace === "") throw new Error("Plugin namespace must not be empty.");
|
|
1002
|
+
for (const segment of namespace.split("/")) {
|
|
1003
|
+
if (!SEGMENT_RE.test(segment)) {
|
|
1004
|
+
throw new Error(
|
|
1005
|
+
`Plugin namespace "${namespace}" is invalid: each "/"-separated segment must be package-like (letters, digits, ".", "_", "-", optional leading "@").`
|
|
1006
|
+
);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
var LEAF_META_KEYS = [
|
|
1011
|
+
"description",
|
|
1012
|
+
"categories",
|
|
1013
|
+
"type",
|
|
1014
|
+
"itemType",
|
|
1015
|
+
"returnType",
|
|
1016
|
+
"outputSchema",
|
|
1017
|
+
"inputParameters",
|
|
1018
|
+
"packages",
|
|
1019
|
+
"experimental",
|
|
1020
|
+
"confirm",
|
|
1021
|
+
"deprecation",
|
|
1022
|
+
"aliases",
|
|
1023
|
+
"supportsJsonOutput"
|
|
1024
|
+
];
|
|
1025
|
+
function normalizeImports(deps) {
|
|
1026
|
+
if (!deps) return { plugins: [], bindings: [] };
|
|
1027
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1028
|
+
const bindings = [];
|
|
1029
|
+
const add = (binding, id) => {
|
|
1030
|
+
const priorId = seen.get(binding);
|
|
1031
|
+
if (priorId !== void 0 && priorId !== id) {
|
|
1032
|
+
throw new Error(
|
|
1033
|
+
`Import binding "${binding}" is declared twice. Two different plugins ("${priorId}" and "${id}") bind the same name; wrap one in selectExports to rename it.`
|
|
1034
|
+
);
|
|
1035
|
+
}
|
|
1036
|
+
if (priorId === void 0) {
|
|
1037
|
+
seen.set(binding, id);
|
|
1038
|
+
bindings.push({ binding, id });
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
for (const plugin of deps) {
|
|
1042
|
+
if (plugin.pluginType === "aggregate") {
|
|
1043
|
+
for (const [binding, child] of Object.entries(plugin.exports)) {
|
|
1044
|
+
add(binding, child.id);
|
|
1045
|
+
}
|
|
1046
|
+
} else {
|
|
1047
|
+
add(plugin.name, plugin.id);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
return { plugins: deps, bindings };
|
|
1051
|
+
}
|
|
1052
|
+
function collectLeafMeta(config) {
|
|
1053
|
+
let meta;
|
|
1054
|
+
for (const key of LEAF_META_KEYS) {
|
|
1055
|
+
if (config[key] !== void 0) (meta ?? (meta = {}))[key] = config[key];
|
|
1056
|
+
}
|
|
1057
|
+
return meta;
|
|
1058
|
+
}
|
|
1059
|
+
function defineMethod(config) {
|
|
1060
|
+
const deps = normalizeImports(config.imports);
|
|
1061
|
+
return {
|
|
1062
|
+
pluginType: "method",
|
|
1063
|
+
name: config.name,
|
|
1064
|
+
namespace: config.namespace,
|
|
1065
|
+
id: makeId(config.name, config.namespace),
|
|
1066
|
+
imports: deps.plugins,
|
|
1067
|
+
importBindings: deps.bindings,
|
|
1068
|
+
inputSchema: config.inputSchema,
|
|
1069
|
+
meta: collectLeafMeta(config),
|
|
1070
|
+
resolvers: config.resolvers,
|
|
1071
|
+
formatter: config.formatter,
|
|
1072
|
+
output: config.output,
|
|
1073
|
+
positional: config.positional,
|
|
1074
|
+
setup: config.setup,
|
|
1075
|
+
run: config.run
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
function defineFormatter(config) {
|
|
1079
|
+
const deps = normalizeImports(config.imports);
|
|
1080
|
+
return {
|
|
1081
|
+
imports: deps.plugins,
|
|
1082
|
+
importBindings: deps.bindings,
|
|
1083
|
+
fetchContext: config.fetchContext,
|
|
1084
|
+
format: config.format
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
function declareMethod(config) {
|
|
1088
|
+
const { name, namespace } = parseId(config.id);
|
|
1089
|
+
const id = makeId(name, namespace);
|
|
1090
|
+
return {
|
|
1091
|
+
pluginType: "method",
|
|
1092
|
+
name,
|
|
1093
|
+
namespace,
|
|
1094
|
+
id,
|
|
1095
|
+
standIn: true,
|
|
1096
|
+
imports: [],
|
|
1097
|
+
importBindings: [],
|
|
1098
|
+
run: () => {
|
|
1099
|
+
throw new Error(
|
|
1100
|
+
`Plugin "${id}" is a stand-in (declareMethod) with no implementation. Register the real plugin under this id.`
|
|
1101
|
+
);
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
function defineProperty(config) {
|
|
1106
|
+
const deps = normalizeImports(config.imports);
|
|
1107
|
+
return {
|
|
1108
|
+
pluginType: "property",
|
|
1109
|
+
name: config.name,
|
|
1110
|
+
namespace: config.namespace,
|
|
1111
|
+
id: makeId(config.name, config.namespace),
|
|
1112
|
+
imports: deps.plugins,
|
|
1113
|
+
importBindings: deps.bindings,
|
|
1114
|
+
setup: config.setup,
|
|
1115
|
+
value: config.value,
|
|
1116
|
+
get: config.get,
|
|
1117
|
+
meta: collectLeafMeta(config)
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
function declareProperty(config) {
|
|
1121
|
+
const { name, namespace } = parseId(config.id);
|
|
1122
|
+
return {
|
|
1123
|
+
pluginType: "property",
|
|
1124
|
+
name,
|
|
1125
|
+
namespace,
|
|
1126
|
+
id: makeId(name, namespace),
|
|
1127
|
+
standIn: true,
|
|
1128
|
+
imports: [],
|
|
1129
|
+
importBindings: []
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
function definePlugin(fnOrConfig) {
|
|
1133
|
+
if (typeof fnOrConfig === "function") return fnOrConfig;
|
|
1134
|
+
const config = fnOrConfig;
|
|
1135
|
+
const deps = normalizeImports(config.imports);
|
|
1136
|
+
return {
|
|
1137
|
+
pluginType: "aggregate",
|
|
1138
|
+
name: config.name,
|
|
1139
|
+
namespace: config.namespace,
|
|
1140
|
+
id: makeId(config.name, config.namespace, "aggregate"),
|
|
1141
|
+
imports: deps.plugins,
|
|
1142
|
+
importBindings: deps.bindings,
|
|
1143
|
+
exports: normalizeExports(config.exports),
|
|
1144
|
+
middleware: config.middleware
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
function normalizeExports(exports) {
|
|
1148
|
+
if (!exports) return {};
|
|
1149
|
+
const out = {};
|
|
1150
|
+
const add = (binding, leaf) => {
|
|
1151
|
+
const existing = out[binding];
|
|
1152
|
+
if (existing && existing.id !== leaf.id) {
|
|
1153
|
+
throw new Error(
|
|
1154
|
+
`definePlugin: duplicate export binding "${binding}". Two different plugins ("${existing.id}" and "${leaf.id}") bind the same name; wrap one in selectExports to rename it.`
|
|
1155
|
+
);
|
|
1156
|
+
}
|
|
1157
|
+
out[binding] = leaf;
|
|
1158
|
+
};
|
|
1159
|
+
for (const element of exports) {
|
|
1160
|
+
if (element.pluginType === "aggregate") {
|
|
1161
|
+
for (const [binding, child] of Object.entries(element.exports)) {
|
|
1162
|
+
add(binding, child);
|
|
1163
|
+
}
|
|
1164
|
+
} else {
|
|
1165
|
+
add(element.name, element);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
return out;
|
|
1169
|
+
}
|
|
1170
|
+
function fromFunctionPlugin(fn, config) {
|
|
1171
|
+
return {
|
|
1172
|
+
pluginType: "legacy",
|
|
1173
|
+
name: config.name,
|
|
1174
|
+
namespace: config.namespace,
|
|
1175
|
+
id: makeId(config.name, config.namespace, "aggregate"),
|
|
1176
|
+
imports: [],
|
|
1177
|
+
importBindings: [],
|
|
1178
|
+
run: fn
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
function defineLegacyMerge(args) {
|
|
1182
|
+
return {
|
|
1183
|
+
pluginType: "legacy-merge",
|
|
1184
|
+
name: args.name,
|
|
1185
|
+
namespace: args.namespace,
|
|
1186
|
+
id: makeId(args.name, args.namespace, "aggregate"),
|
|
1187
|
+
legacy: fromFunctionPlugin(args.legacy, {
|
|
1188
|
+
name: args.name,
|
|
1189
|
+
namespace: args.namespace
|
|
1190
|
+
}),
|
|
1191
|
+
plugin: args.plugin
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
function legacyGraphEntry(name, value, pluginMeta) {
|
|
1195
|
+
const { inputSchema, ...rest } = pluginMeta ?? {};
|
|
1196
|
+
const meta = Object.keys(rest).length ? rest : void 0;
|
|
1197
|
+
if (typeof value === "function") {
|
|
1198
|
+
return {
|
|
1199
|
+
pluginType: "method",
|
|
1200
|
+
name,
|
|
1201
|
+
value,
|
|
1202
|
+
chain: [],
|
|
1203
|
+
...inputSchema ? { inputSchema } : {},
|
|
1204
|
+
...meta ? { meta } : {}
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
return { pluginType: "property", name, value, ...meta ? { meta } : {} };
|
|
1208
|
+
}
|
|
1209
|
+
function adaptLegacyFormatter(legacy, sdk) {
|
|
1210
|
+
const legacyFetch = legacy.fetch;
|
|
1211
|
+
return {
|
|
1212
|
+
fetchContext: legacyFetch ? async ({ items, input, context }) => {
|
|
1213
|
+
let ctx = context;
|
|
1214
|
+
for (const item of items) {
|
|
1215
|
+
ctx = await legacyFetch(sdk, input, item, ctx);
|
|
1216
|
+
}
|
|
1217
|
+
return ctx;
|
|
1218
|
+
} : void 0,
|
|
1219
|
+
format: ({ item, context }) => legacy.format(item, context)
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
function normalizeFormatter(entry, sdk) {
|
|
1223
|
+
if (entry.pluginType !== "method") return void 0;
|
|
1224
|
+
if (entry.formatter) return entry.formatter;
|
|
1225
|
+
const legacy = entry.meta?.formatter;
|
|
1226
|
+
return legacy ? adaptLegacyFormatter(legacy, sdk) : void 0;
|
|
1227
|
+
}
|
|
1228
|
+
function pluginEntryMeta(entry) {
|
|
1229
|
+
if (entry.pluginType === "method" && entry.meta) {
|
|
1230
|
+
return entry.inputSchema ? { ...entry.meta, inputSchema: entry.inputSchema } : entry.meta;
|
|
1231
|
+
}
|
|
1232
|
+
if (entry.pluginType === "property" && entry.meta) return entry.meta;
|
|
1233
|
+
return void 0;
|
|
1234
|
+
}
|
|
1235
|
+
function buildSurfaceRegistry(context, packageFilter) {
|
|
1236
|
+
const meta = {};
|
|
1237
|
+
const surface = {};
|
|
1238
|
+
const entries = {};
|
|
1239
|
+
for (const [binding, id] of Object.entries(context.surface)) {
|
|
1240
|
+
const entry = context.plugins[id];
|
|
1241
|
+
if (!entry || entry.pluginType === "aggregate") continue;
|
|
1242
|
+
surface[binding] = entry.value;
|
|
1243
|
+
entries[binding] = entry;
|
|
1244
|
+
const m = pluginEntryMeta(entry);
|
|
1245
|
+
if (m) meta[binding] = m;
|
|
1246
|
+
}
|
|
1247
|
+
const formatters = {};
|
|
1248
|
+
for (const [binding, entry] of Object.entries(entries)) {
|
|
1249
|
+
const f = normalizeFormatter(entry, surface);
|
|
1250
|
+
if (f) formatters[binding] = f;
|
|
1251
|
+
}
|
|
1252
|
+
return buildRegistry({ sdk: surface, meta, formatters, packageFilter });
|
|
1253
|
+
}
|
|
1254
|
+
var dangerousContextPlugin = {
|
|
1255
|
+
pluginType: "property",
|
|
1256
|
+
name: "context",
|
|
1257
|
+
namespace: "kitcore",
|
|
1258
|
+
id: "kitcore/context",
|
|
1259
|
+
imports: [],
|
|
1260
|
+
importBindings: [],
|
|
1261
|
+
privileged: true
|
|
1262
|
+
};
|
|
1263
|
+
defineMethod({
|
|
1264
|
+
name: "getRegistry",
|
|
1265
|
+
namespace: "kitcore",
|
|
1266
|
+
imports: [dangerousContextPlugin],
|
|
1267
|
+
inputSchema: z.object({ package: z.string().optional() }).optional(),
|
|
1268
|
+
run: ({ imports, input }) => buildSurfaceRegistry(imports.context, input?.package)
|
|
1269
|
+
});
|
|
1270
|
+
function normalizeOutput(output) {
|
|
1271
|
+
if (output === void 0) return { type: "raw" };
|
|
1272
|
+
if (typeof output === "string") return { type: output };
|
|
1273
|
+
return output;
|
|
1274
|
+
}
|
|
1275
|
+
var CONTEXT = Symbol("kitcore.context");
|
|
1276
|
+
function getContext(sdk) {
|
|
1277
|
+
return sdk[CONTEXT];
|
|
1278
|
+
}
|
|
1279
|
+
function isResolverRef(value) {
|
|
1280
|
+
return "ref" in value;
|
|
1281
|
+
}
|
|
1282
|
+
function nestedResolvers(resolver) {
|
|
1283
|
+
const out = [];
|
|
1284
|
+
if (resolver.type === "object") {
|
|
1285
|
+
for (const field of Object.values(resolver.properties ?? {})) {
|
|
1286
|
+
if (!isResolverRef(field.resolver)) out.push(field.resolver);
|
|
1287
|
+
}
|
|
1288
|
+
out.push(...Object.values(resolver.definitions ?? {}));
|
|
1289
|
+
} else if (resolver.type === "array") {
|
|
1290
|
+
if (!isResolverRef(resolver.items)) out.push(resolver.items);
|
|
1291
|
+
out.push(...Object.values(resolver.definitions ?? {}));
|
|
1292
|
+
}
|
|
1293
|
+
return out;
|
|
1294
|
+
}
|
|
1295
|
+
function resolverImportEdges(resolver) {
|
|
1296
|
+
const out = [...resolver.imports];
|
|
1297
|
+
for (const child of nestedResolvers(resolver)) {
|
|
1298
|
+
out.push(...resolverImportEdges(child));
|
|
1299
|
+
}
|
|
1300
|
+
return out;
|
|
1301
|
+
}
|
|
1302
|
+
function methodAttachmentEdges(plugin) {
|
|
1303
|
+
const out = [];
|
|
1304
|
+
if (plugin.resolvers) {
|
|
1305
|
+
for (const resolver of Object.values(plugin.resolvers)) {
|
|
1306
|
+
out.push(...resolverImportEdges(resolver));
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
if (plugin.formatter) out.push(...plugin.formatter.imports);
|
|
1310
|
+
return out;
|
|
1311
|
+
}
|
|
1312
|
+
function edgesOf(plugin) {
|
|
1313
|
+
if (plugin.pluginType === "aggregate") {
|
|
1314
|
+
return [...Object.values(plugin.exports), ...plugin.imports];
|
|
1315
|
+
}
|
|
1316
|
+
if (plugin.pluginType === "method") {
|
|
1317
|
+
return [...plugin.imports, ...methodAttachmentEdges(plugin)];
|
|
1318
|
+
}
|
|
1319
|
+
return plugin.imports;
|
|
1320
|
+
}
|
|
1321
|
+
function isStandIn(plugin) {
|
|
1322
|
+
return (plugin.pluginType === "method" || plugin.pluginType === "property" || plugin.pluginType === "aggregate") && plugin.standIn === true;
|
|
1323
|
+
}
|
|
1324
|
+
function topoOrder(descriptors) {
|
|
1325
|
+
const order = [];
|
|
1326
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1327
|
+
const visit = (id) => {
|
|
1328
|
+
if (visited.has(id)) return;
|
|
1329
|
+
visited.add(id);
|
|
1330
|
+
const descriptor = descriptors.get(id);
|
|
1331
|
+
if (descriptor) for (const edge of edgesOf(descriptor)) visit(edge.id);
|
|
1332
|
+
order.push(id);
|
|
1333
|
+
};
|
|
1334
|
+
for (const id of descriptors.keys()) visit(id);
|
|
1335
|
+
return order;
|
|
1336
|
+
}
|
|
1337
|
+
function collectPlugins(root, materialized = /* @__PURE__ */ new Set()) {
|
|
1338
|
+
const byId = /* @__PURE__ */ new Map();
|
|
1339
|
+
const visit = (plugin) => {
|
|
1340
|
+
if (materialized.has(plugin.id)) return;
|
|
1341
|
+
const existing = byId.get(plugin.id);
|
|
1342
|
+
if (existing === plugin) return;
|
|
1343
|
+
if (existing) {
|
|
1344
|
+
const bothReal = !isStandIn(existing) && !isStandIn(plugin);
|
|
1345
|
+
if (bothReal) {
|
|
1346
|
+
throw new Error(
|
|
1347
|
+
`createSdk: duplicate plugin id "${plugin.id}". Two different plugins registered under the same id.`
|
|
1348
|
+
);
|
|
1349
|
+
}
|
|
1350
|
+
if (isStandIn(existing) && !isStandIn(plugin)) {
|
|
1351
|
+
byId.set(plugin.id, plugin);
|
|
1352
|
+
for (const edge of edgesOf(plugin)) visit(edge);
|
|
1353
|
+
}
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
byId.set(plugin.id, plugin);
|
|
1357
|
+
for (const edge of edgesOf(plugin)) visit(edge);
|
|
1358
|
+
};
|
|
1359
|
+
visit(root);
|
|
1360
|
+
for (const [id, plugin] of byId) {
|
|
1361
|
+
if (isStandIn(plugin)) {
|
|
1362
|
+
throw new Error(
|
|
1363
|
+
`createSdk: missing dependency "${id}". A plugin depends on it (via a stand-in) but no implementation was registered.`
|
|
1364
|
+
);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
return byId;
|
|
1368
|
+
}
|
|
1369
|
+
function bindValue(target, key, entry) {
|
|
1370
|
+
if (entry.pluginType === "property" && entry.getValue) {
|
|
1371
|
+
Object.defineProperty(target, key, {
|
|
1372
|
+
get: entry.getValue,
|
|
1373
|
+
enumerable: true,
|
|
1374
|
+
configurable: true
|
|
1375
|
+
});
|
|
1376
|
+
} else {
|
|
1377
|
+
Object.defineProperty(target, key, {
|
|
1378
|
+
value: entry.value,
|
|
1379
|
+
writable: true,
|
|
1380
|
+
enumerable: true,
|
|
1381
|
+
configurable: true
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
function buildSurface(context, ...maps) {
|
|
1386
|
+
const sdk = {};
|
|
1387
|
+
for (const map of maps) {
|
|
1388
|
+
Object.defineProperties(sdk, Object.getOwnPropertyDescriptors(map));
|
|
1389
|
+
}
|
|
1390
|
+
sdk.context = context;
|
|
1391
|
+
sdk[CONTEXT] = context;
|
|
1392
|
+
return sdk;
|
|
1393
|
+
}
|
|
1394
|
+
function buildImports(plugins, importBindings) {
|
|
1395
|
+
const imports = {};
|
|
1396
|
+
for (const { binding, id } of importBindings) {
|
|
1397
|
+
bindValue(imports, binding, plugins[id]);
|
|
1398
|
+
}
|
|
1399
|
+
return imports;
|
|
1400
|
+
}
|
|
1401
|
+
function mirrorLegacyRootKeys(context, rootKeys, meta) {
|
|
1402
|
+
const exports = {};
|
|
1403
|
+
for (const [name, value] of Object.entries(rootKeys)) {
|
|
1404
|
+
context.plugins[name] = legacyGraphEntry(name, value, meta[name]);
|
|
1405
|
+
exports[name] = value;
|
|
1406
|
+
}
|
|
1407
|
+
return exports;
|
|
1408
|
+
}
|
|
1409
|
+
function recordExportSurface(context, exports) {
|
|
1410
|
+
for (const [binding, child] of Object.entries(exports)) {
|
|
1411
|
+
context.surface[binding] = child.id;
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
function materialize(descriptors, context) {
|
|
1415
|
+
const states = /* @__PURE__ */ new Map();
|
|
1416
|
+
runLegacyPass(descriptors, context);
|
|
1417
|
+
buildMethodEntries(descriptors, context, states);
|
|
1418
|
+
buildEagerArtifacts(descriptors, context, states);
|
|
1419
|
+
bindAttachments(descriptors, context);
|
|
1420
|
+
resolveAggregates(descriptors, context);
|
|
1421
|
+
assembleMiddleware(descriptors, context);
|
|
1422
|
+
return context.plugins;
|
|
1423
|
+
}
|
|
1424
|
+
function bindResolver(resolver, plugins) {
|
|
1425
|
+
switch (resolver.type) {
|
|
1426
|
+
case "static":
|
|
1427
|
+
return {
|
|
1428
|
+
type: "static",
|
|
1429
|
+
requireParams: resolver.requireParams,
|
|
1430
|
+
requireCapabilities: resolver.requireCapabilities,
|
|
1431
|
+
inputType: resolver.inputType,
|
|
1432
|
+
placeholder: resolver.placeholder
|
|
1433
|
+
};
|
|
1434
|
+
case "constant":
|
|
1435
|
+
return {
|
|
1436
|
+
type: "constant",
|
|
1437
|
+
value: resolver.value,
|
|
1438
|
+
requireParams: resolver.requireParams,
|
|
1439
|
+
requireCapabilities: resolver.requireCapabilities
|
|
1440
|
+
};
|
|
1441
|
+
case "info":
|
|
1442
|
+
return { type: "info", text: resolver.text };
|
|
1443
|
+
case "object": {
|
|
1444
|
+
const imports = buildImports(plugins, resolver.importBindings);
|
|
1445
|
+
const bound = {
|
|
1446
|
+
type: "object",
|
|
1447
|
+
requireParams: resolver.requireParams,
|
|
1448
|
+
requireCapabilities: resolver.requireCapabilities
|
|
1449
|
+
};
|
|
1450
|
+
if (resolver.properties)
|
|
1451
|
+
bound.properties = bindFields(resolver.properties, plugins);
|
|
1452
|
+
if (resolver.definitions)
|
|
1453
|
+
bound.definitions = bindDefinitions(resolver.definitions, plugins);
|
|
1454
|
+
const { fetch: fetch2 } = resolver;
|
|
1455
|
+
if (fetch2) bound.fetch = ({ params }) => fetch2({ imports, params });
|
|
1456
|
+
return bound;
|
|
1457
|
+
}
|
|
1458
|
+
case "array": {
|
|
1459
|
+
const bound = {
|
|
1460
|
+
type: "array",
|
|
1461
|
+
requireParams: resolver.requireParams,
|
|
1462
|
+
requireCapabilities: resolver.requireCapabilities,
|
|
1463
|
+
minItems: resolver.minItems,
|
|
1464
|
+
maxItems: resolver.maxItems,
|
|
1465
|
+
items: isResolverRef(resolver.items) ? resolver.items : bindResolver(resolver.items, plugins)
|
|
1466
|
+
};
|
|
1467
|
+
if (resolver.definitions)
|
|
1468
|
+
bound.definitions = bindDefinitions(resolver.definitions, plugins);
|
|
1469
|
+
return bound;
|
|
1470
|
+
}
|
|
1471
|
+
default: {
|
|
1472
|
+
const imports = buildImports(plugins, resolver.importBindings);
|
|
1473
|
+
const bound = {
|
|
1474
|
+
type: "dynamic",
|
|
1475
|
+
requireParams: resolver.requireParams,
|
|
1476
|
+
requireCapabilities: resolver.requireCapabilities,
|
|
1477
|
+
inputType: resolver.inputType,
|
|
1478
|
+
placeholder: resolver.placeholder,
|
|
1479
|
+
prompt: resolver.prompt
|
|
1480
|
+
};
|
|
1481
|
+
const { fetch: fetch2, tryResolveWithoutPrompt } = resolver;
|
|
1482
|
+
if (fetch2)
|
|
1483
|
+
bound.fetch = ({ params, search }) => fetch2({ imports, params, search });
|
|
1484
|
+
if (tryResolveWithoutPrompt) {
|
|
1485
|
+
bound.tryResolveWithoutPrompt = ({ params }) => tryResolveWithoutPrompt({ imports, params });
|
|
1486
|
+
}
|
|
1487
|
+
return bound;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
function bindFields(fields, plugins) {
|
|
1492
|
+
const out = {};
|
|
1493
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
1494
|
+
out[key] = {
|
|
1495
|
+
...field,
|
|
1496
|
+
resolver: isResolverRef(field.resolver) ? field.resolver : bindResolver(field.resolver, plugins)
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
return out;
|
|
1500
|
+
}
|
|
1501
|
+
function bindDefinitions(definitions, plugins) {
|
|
1502
|
+
const out = {};
|
|
1503
|
+
for (const [key, def] of Object.entries(definitions)) {
|
|
1504
|
+
out[key] = bindResolver(def, plugins);
|
|
1505
|
+
}
|
|
1506
|
+
return out;
|
|
1507
|
+
}
|
|
1508
|
+
function bindFormatter(formatter, plugins) {
|
|
1509
|
+
const imports = buildImports(plugins, formatter.importBindings);
|
|
1510
|
+
const bound = { format: formatter.format };
|
|
1511
|
+
const { fetchContext } = formatter;
|
|
1512
|
+
if (fetchContext)
|
|
1513
|
+
bound.fetchContext = ({ items, input, context }) => fetchContext({ imports, items, input, context });
|
|
1514
|
+
return bound;
|
|
1515
|
+
}
|
|
1516
|
+
function bindAttachments(descriptors, context) {
|
|
1517
|
+
const plugins = context.plugins;
|
|
1518
|
+
for (const [id, descriptor] of descriptors) {
|
|
1519
|
+
if (descriptor.pluginType !== "method") continue;
|
|
1520
|
+
const entry = plugins[id];
|
|
1521
|
+
if (!entry || entry.pluginType !== "method") continue;
|
|
1522
|
+
if (descriptor.resolvers) {
|
|
1523
|
+
const bound = {};
|
|
1524
|
+
for (const [param, resolver] of Object.entries(descriptor.resolvers)) {
|
|
1525
|
+
bound[param] = bindResolver(resolver, plugins);
|
|
1526
|
+
}
|
|
1527
|
+
entry.resolvers = bound;
|
|
1528
|
+
}
|
|
1529
|
+
if (descriptor.formatter) {
|
|
1530
|
+
entry.formatter = bindFormatter(descriptor.formatter, plugins);
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
function runLegacyPass(descriptors, context) {
|
|
1535
|
+
const plugins = context.plugins;
|
|
1536
|
+
const compatView = new Proxy(
|
|
1537
|
+
{},
|
|
1538
|
+
{
|
|
1539
|
+
get: (_target, prop) => {
|
|
1540
|
+
if (prop === "context") return context;
|
|
1541
|
+
const entry = plugins[prop];
|
|
1542
|
+
return entry?.value;
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
);
|
|
1546
|
+
for (const id of topoOrder(descriptors)) {
|
|
1547
|
+
const descriptor = descriptors.get(id);
|
|
1548
|
+
if (!descriptor || descriptor.pluginType !== "legacy") continue;
|
|
1549
|
+
const { rootKeys, meta, hooks, contextRest } = splitPluginContribution(
|
|
1550
|
+
descriptor.run(compatView)
|
|
1551
|
+
);
|
|
1552
|
+
Object.assign(context.meta, meta);
|
|
1553
|
+
Object.assign(context, contextRest);
|
|
1554
|
+
context.hooks = buildHooks(context.hooks, hooks);
|
|
1555
|
+
const exports = mirrorLegacyRootKeys(context, rootKeys, meta);
|
|
1556
|
+
if (!("getRegistry" in exports)) {
|
|
1557
|
+
let getRegistry2 = function(options) {
|
|
1558
|
+
const sdk = this ?? exports;
|
|
1559
|
+
const meta2 = {};
|
|
1560
|
+
const formatters = {};
|
|
1561
|
+
for (const [binding, id2] of Object.entries(context.surface)) {
|
|
1562
|
+
const entry = context.plugins[id2];
|
|
1563
|
+
if (!entry || entry.pluginType === "aggregate") continue;
|
|
1564
|
+
const m = pluginEntryMeta(entry);
|
|
1565
|
+
if (m) meta2[binding] = m;
|
|
1566
|
+
const f = normalizeFormatter(entry, sdk);
|
|
1567
|
+
if (f) formatters[binding] = f;
|
|
1568
|
+
}
|
|
1569
|
+
Object.assign(meta2, context.meta);
|
|
1570
|
+
return buildRegistry({
|
|
1571
|
+
sdk,
|
|
1572
|
+
meta: meta2,
|
|
1573
|
+
formatters,
|
|
1574
|
+
packageFilter: options?.package
|
|
1575
|
+
});
|
|
1576
|
+
};
|
|
1577
|
+
exports.getRegistry = getRegistry2;
|
|
1578
|
+
plugins.getRegistry = {
|
|
1579
|
+
pluginType: "method",
|
|
1580
|
+
name: "getRegistry",
|
|
1581
|
+
value: getRegistry2,
|
|
1582
|
+
chain: []
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
plugins[id] = { pluginType: "aggregate", name: descriptor.name, exports };
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
function buildMethodEntries(descriptors, context, states) {
|
|
1589
|
+
const plugins = context.plugins;
|
|
1590
|
+
for (const [id, descriptor] of descriptors) {
|
|
1591
|
+
if (descriptor.pluginType !== "method") continue;
|
|
1592
|
+
const out = normalizeOutput(descriptor.output);
|
|
1593
|
+
const entry = {
|
|
1594
|
+
pluginType: "method",
|
|
1595
|
+
name: descriptor.name,
|
|
1596
|
+
chain: [],
|
|
1597
|
+
inputSchema: descriptor.inputSchema,
|
|
1598
|
+
// Derive the presentation type from the output mode when the author did
|
|
1599
|
+
// not set one; an explicit meta.type (e.g. "create") still wins.
|
|
1600
|
+
meta: out.type === "raw" || descriptor.meta?.type ? descriptor.meta : { ...descriptor.meta, type: out.type },
|
|
1601
|
+
output: out,
|
|
1602
|
+
// Replaced below; never called.
|
|
1603
|
+
value: () => void 0
|
|
1604
|
+
};
|
|
1605
|
+
const callRun = (input) => descriptor.run({
|
|
1606
|
+
imports: buildImports(plugins, descriptor.importBindings),
|
|
1607
|
+
state: states.get(id),
|
|
1608
|
+
input
|
|
1609
|
+
});
|
|
1610
|
+
const fold = (coreFn) => (input) => {
|
|
1611
|
+
let next = coreFn;
|
|
1612
|
+
for (const wrap of entry.chain) {
|
|
1613
|
+
const inner = next;
|
|
1614
|
+
next = (i) => wrap.run({
|
|
1615
|
+
imports: buildImports(plugins, wrap.owner.importBindings),
|
|
1616
|
+
next: inner,
|
|
1617
|
+
input: i
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
return next(input);
|
|
1621
|
+
};
|
|
1622
|
+
const sdk = { context };
|
|
1623
|
+
if (out.type === "list") {
|
|
1624
|
+
entry.value = createPaginatedFunction(
|
|
1625
|
+
fold(callRun),
|
|
1626
|
+
{
|
|
1627
|
+
sdk,
|
|
1628
|
+
schema: descriptor.inputSchema,
|
|
1629
|
+
name: descriptor.name,
|
|
1630
|
+
defaultPageSize: out.defaultPageSize,
|
|
1631
|
+
adaptPage: out.adaptPage
|
|
1632
|
+
}
|
|
1633
|
+
);
|
|
1634
|
+
} else if (out.type === "item") {
|
|
1635
|
+
const itemCore = async (input) => ({
|
|
1636
|
+
data: await callRun(input)
|
|
1637
|
+
});
|
|
1638
|
+
entry.value = createFunction(
|
|
1639
|
+
fold(itemCore),
|
|
1640
|
+
{ sdk, schema: descriptor.inputSchema, name: descriptor.name }
|
|
1641
|
+
);
|
|
1642
|
+
} else {
|
|
1643
|
+
entry.value = (rawInput) => {
|
|
1644
|
+
const input = descriptor.inputSchema ? descriptor.inputSchema.parse(rawInput) : rawInput;
|
|
1645
|
+
return fold(callRun)(input);
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
if (descriptor.positional) {
|
|
1649
|
+
const names = descriptor.positional;
|
|
1650
|
+
const canonicalValue = entry.value;
|
|
1651
|
+
entry.value = (...args) => {
|
|
1652
|
+
const packed = {};
|
|
1653
|
+
names.forEach((name, i) => {
|
|
1654
|
+
if (i < args.length) packed[name] = args[i];
|
|
1655
|
+
});
|
|
1656
|
+
return canonicalValue(packed);
|
|
1657
|
+
};
|
|
1658
|
+
entry.positional = names;
|
|
1659
|
+
}
|
|
1660
|
+
plugins[id] = entry;
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
function buildEagerArtifacts(descriptors, context, states) {
|
|
1664
|
+
const plugins = context.plugins;
|
|
1665
|
+
const built = /* @__PURE__ */ new Set();
|
|
1666
|
+
const building = /* @__PURE__ */ new Set();
|
|
1667
|
+
const ensureBuilt = (id) => {
|
|
1668
|
+
if (built.has(id)) return;
|
|
1669
|
+
const descriptor = descriptors.get(id);
|
|
1670
|
+
if (!descriptor || descriptor.pluginType === "aggregate" || descriptor.pluginType === "legacy") {
|
|
1671
|
+
built.add(id);
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
if (building.has(id)) {
|
|
1675
|
+
throw new Error(`createSdk: dependency cycle at "${id}".`);
|
|
1676
|
+
}
|
|
1677
|
+
building.add(id);
|
|
1678
|
+
for (const { id: depId } of descriptor.importBindings) ensureBuilt(depId);
|
|
1679
|
+
if (descriptor.pluginType === "method") {
|
|
1680
|
+
states.set(
|
|
1681
|
+
id,
|
|
1682
|
+
descriptor.setup ? descriptor.setup({
|
|
1683
|
+
imports: buildImports(plugins, descriptor.importBindings)
|
|
1684
|
+
}) : void 0
|
|
1685
|
+
);
|
|
1686
|
+
} else {
|
|
1687
|
+
states.set(
|
|
1688
|
+
id,
|
|
1689
|
+
descriptor.setup ? descriptor.setup({
|
|
1690
|
+
imports: buildImports(plugins, descriptor.importBindings)
|
|
1691
|
+
}) : void 0
|
|
1692
|
+
);
|
|
1693
|
+
if (descriptor.privileged) {
|
|
1694
|
+
plugins[id] = {
|
|
1695
|
+
pluginType: "property",
|
|
1696
|
+
name: descriptor.name,
|
|
1697
|
+
value: context,
|
|
1698
|
+
meta: descriptor.meta
|
|
1699
|
+
};
|
|
1700
|
+
} else if (descriptor.get) {
|
|
1701
|
+
const get = descriptor.get;
|
|
1702
|
+
const importBindings = descriptor.importBindings;
|
|
1703
|
+
plugins[id] = {
|
|
1704
|
+
pluginType: "property",
|
|
1705
|
+
name: descriptor.name,
|
|
1706
|
+
getValue: () => get({
|
|
1707
|
+
imports: buildImports(plugins, importBindings),
|
|
1708
|
+
state: states.get(id)
|
|
1709
|
+
}),
|
|
1710
|
+
meta: descriptor.meta
|
|
1711
|
+
};
|
|
1712
|
+
} else {
|
|
1713
|
+
plugins[id] = {
|
|
1714
|
+
pluginType: "property",
|
|
1715
|
+
name: descriptor.name,
|
|
1716
|
+
value: descriptor.value,
|
|
1717
|
+
meta: descriptor.meta
|
|
1718
|
+
};
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
building.delete(id);
|
|
1722
|
+
built.add(id);
|
|
1723
|
+
};
|
|
1724
|
+
for (const id of descriptors.keys()) ensureBuilt(id);
|
|
1725
|
+
}
|
|
1726
|
+
function resolveAggregates(descriptors, context) {
|
|
1727
|
+
const plugins = context.plugins;
|
|
1728
|
+
for (const [id, descriptor] of descriptors) {
|
|
1729
|
+
if (descriptor.pluginType !== "aggregate") continue;
|
|
1730
|
+
const exports = {};
|
|
1731
|
+
for (const [binding, child] of Object.entries(descriptor.exports)) {
|
|
1732
|
+
bindValue(exports, binding, plugins[child.id]);
|
|
1733
|
+
}
|
|
1734
|
+
plugins[id] = { pluginType: "aggregate", name: descriptor.name, exports };
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
function assembleMiddleware(descriptors, context) {
|
|
1738
|
+
const plugins = context.plugins;
|
|
1739
|
+
for (const id of topoOrder(descriptors)) {
|
|
1740
|
+
const descriptor = descriptors.get(id);
|
|
1741
|
+
if (!descriptor || descriptor.pluginType !== "aggregate" || !descriptor.middleware) {
|
|
1742
|
+
continue;
|
|
1743
|
+
}
|
|
1744
|
+
for (const [targetBinding, fn] of Object.entries(descriptor.middleware)) {
|
|
1745
|
+
const edge = descriptor.importBindings.find(
|
|
1746
|
+
(b) => b.binding === targetBinding
|
|
1747
|
+
);
|
|
1748
|
+
if (!edge) {
|
|
1749
|
+
throw new Error(
|
|
1750
|
+
`createSdk: middleware target "${targetBinding}" in plugin "${id}" is not a direct dependency. A middleware target must be a declared dependency of the wrapping plugin.`
|
|
1751
|
+
);
|
|
1752
|
+
}
|
|
1753
|
+
const target = plugins[edge.id];
|
|
1754
|
+
if (!target || target.pluginType !== "method") {
|
|
1755
|
+
throw new Error(
|
|
1756
|
+
`createSdk: middleware target "${targetBinding}" in plugin "${id}" does not resolve to a method.`
|
|
1757
|
+
);
|
|
1758
|
+
}
|
|
1759
|
+
if (target.output?.type === "list") {
|
|
1760
|
+
throw new Error(
|
|
1761
|
+
`createSdk: middleware target "${targetBinding}" in plugin "${id}" resolves to a list-output method, which does not support middleware yet.`
|
|
1762
|
+
);
|
|
1763
|
+
}
|
|
1764
|
+
target.chain.push({ run: fn, owner: descriptor });
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
function createSdk(root) {
|
|
1769
|
+
const context = { plugins: {}, meta: {}, hooks: {}, surface: {} };
|
|
1770
|
+
if (root.pluginType === "legacy-merge") {
|
|
1771
|
+
const { legacy, plugin } = root;
|
|
1772
|
+
const collectRoot = {
|
|
1773
|
+
pluginType: "aggregate",
|
|
1774
|
+
name: root.name,
|
|
1775
|
+
id: `${root.id}:merge`,
|
|
1776
|
+
imports: [legacy, plugin],
|
|
1777
|
+
importBindings: [],
|
|
1778
|
+
exports: {}
|
|
1779
|
+
};
|
|
1780
|
+
const plugins2 = materialize(collectPlugins(collectRoot), context);
|
|
1781
|
+
const legacyExports = plugins2[legacy.id].exports;
|
|
1782
|
+
let pluginSurface;
|
|
1783
|
+
if (plugin.pluginType === "aggregate") {
|
|
1784
|
+
pluginSurface = plugins2[plugin.id].exports;
|
|
1785
|
+
} else {
|
|
1786
|
+
pluginSurface = {};
|
|
1787
|
+
bindValue(pluginSurface, plugin.name, plugins2[plugin.id]);
|
|
1788
|
+
}
|
|
1789
|
+
for (const key of Object.keys(legacyExports)) context.surface[key] = key;
|
|
1790
|
+
if (plugin.pluginType === "aggregate") {
|
|
1791
|
+
recordExportSurface(context, plugin.exports);
|
|
1792
|
+
} else {
|
|
1793
|
+
context.surface[plugin.name] = plugin.id;
|
|
1794
|
+
}
|
|
1795
|
+
return buildSurface(context, legacyExports, pluginSurface);
|
|
1796
|
+
}
|
|
1797
|
+
const plugins = materialize(collectPlugins(root), context);
|
|
1798
|
+
if (root.pluginType === "method" || root.pluginType === "property") {
|
|
1799
|
+
context.surface[root.name] = root.id;
|
|
1800
|
+
const sdk = buildSurface(context);
|
|
1801
|
+
bindValue(sdk, root.name, plugins[root.id]);
|
|
1802
|
+
return sdk;
|
|
1803
|
+
}
|
|
1804
|
+
if (root.pluginType === "aggregate")
|
|
1805
|
+
recordExportSurface(context, root.exports);
|
|
1806
|
+
return buildSurface(context, plugins[root.id].exports);
|
|
1807
|
+
}
|
|
1808
|
+
function addModelPlugin(sdk, plugin, options = {}) {
|
|
1809
|
+
const override = options.override === true;
|
|
1810
|
+
const context = getContext(sdk);
|
|
1811
|
+
const surfaceKeys = plugin.pluginType === "aggregate" ? Object.keys(plugin.exports) : [plugin.name];
|
|
1812
|
+
checkRootKeyCollisions(sdk, surfaceKeys, override, "addPlugin");
|
|
1813
|
+
const materialized = new Set(Object.keys(context.plugins));
|
|
1814
|
+
if (override && materialized.has(plugin.id)) {
|
|
1815
|
+
throw new Error(
|
|
1816
|
+
`addPlugin: cannot override already-materialized plugin "${plugin.id}" on the incremental path. Rebuild the SDK with the replacement via createSdk.`
|
|
1817
|
+
);
|
|
1818
|
+
}
|
|
1819
|
+
materialize(collectPlugins(plugin, materialized), context);
|
|
1820
|
+
const entry = context.plugins[plugin.id];
|
|
1821
|
+
if (entry.pluginType === "aggregate") {
|
|
1822
|
+
Object.defineProperties(
|
|
1823
|
+
sdk,
|
|
1824
|
+
Object.getOwnPropertyDescriptors(entry.exports)
|
|
1825
|
+
);
|
|
1826
|
+
for (const [binding, child] of Object.entries(
|
|
1827
|
+
plugin.exports
|
|
1828
|
+
)) {
|
|
1829
|
+
context.surface[binding] = child.id;
|
|
1830
|
+
}
|
|
1831
|
+
} else {
|
|
1832
|
+
bindValue(sdk, plugin.name, entry);
|
|
1833
|
+
context.surface[plugin.name] = plugin.id;
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
function addPlugin(sdk, plugin, options) {
|
|
1837
|
+
if (typeof plugin === "function") {
|
|
1838
|
+
const record = sdk;
|
|
1839
|
+
const contribution = applyPluginToSdk(
|
|
1840
|
+
record,
|
|
1841
|
+
plugin,
|
|
1842
|
+
options ?? {}
|
|
1843
|
+
);
|
|
1844
|
+
const context = record[CONTEXT];
|
|
1845
|
+
if (context) {
|
|
1846
|
+
mirrorLegacyRootKeys(context, contribution.rootKeys, contribution.meta);
|
|
1847
|
+
for (const name of Object.keys(contribution.rootKeys)) {
|
|
1848
|
+
context.surface[name] = name;
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
return;
|
|
1852
|
+
}
|
|
1853
|
+
addModelPlugin(
|
|
1854
|
+
sdk,
|
|
1855
|
+
plugin,
|
|
1856
|
+
options ?? {}
|
|
1857
|
+
);
|
|
1000
1858
|
}
|
|
1001
1859
|
function createCorePlugin(options) {
|
|
1002
1860
|
return () => ({
|
|
@@ -1280,6 +2138,66 @@ var zapierCorePlugin = createCorePlugin({
|
|
|
1280
2138
|
function createZapierCoreStack() {
|
|
1281
2139
|
return createPluginStack().use(zapierCorePlugin);
|
|
1282
2140
|
}
|
|
2141
|
+
var GetProfileSchema = z.object({}).optional().describe("Get current user's profile information");
|
|
2142
|
+
var UserProfileItemSchema = z.object({
|
|
2143
|
+
id: z.string(),
|
|
2144
|
+
first_name: z.string(),
|
|
2145
|
+
last_name: z.string(),
|
|
2146
|
+
full_name: z.string(),
|
|
2147
|
+
email: z.string(),
|
|
2148
|
+
email_confirmed: z.boolean(),
|
|
2149
|
+
timezone: z.string()
|
|
2150
|
+
});
|
|
2151
|
+
|
|
2152
|
+
// src/formatters/userProfile.ts
|
|
2153
|
+
var userProfileItemFormatter = defineFormatter({
|
|
2154
|
+
format: ({
|
|
2155
|
+
item
|
|
2156
|
+
}) => {
|
|
2157
|
+
const details = [];
|
|
2158
|
+
if (item.email) {
|
|
2159
|
+
details.push({ text: item.email, style: "dim" });
|
|
2160
|
+
}
|
|
2161
|
+
if (item.timezone) {
|
|
2162
|
+
details.push({
|
|
2163
|
+
text: `Timezone: ${item.timezone}`,
|
|
2164
|
+
style: "accent"
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
return {
|
|
2168
|
+
title: item.full_name,
|
|
2169
|
+
hint: item.id,
|
|
2170
|
+
details
|
|
2171
|
+
};
|
|
2172
|
+
}
|
|
2173
|
+
});
|
|
2174
|
+
|
|
2175
|
+
// src/plugins/getProfile/index.ts
|
|
2176
|
+
var getProfilePlugin = defineMethod({
|
|
2177
|
+
name: "getProfile",
|
|
2178
|
+
imports: [dangerousContextPlugin],
|
|
2179
|
+
inputSchema: GetProfileSchema,
|
|
2180
|
+
output: "item",
|
|
2181
|
+
formatter: userProfileItemFormatter,
|
|
2182
|
+
categories: ["account"],
|
|
2183
|
+
itemType: "Profile",
|
|
2184
|
+
outputSchema: UserProfileItemSchema,
|
|
2185
|
+
run: async ({ imports }) => {
|
|
2186
|
+
const api = imports.context.api;
|
|
2187
|
+
const profile = await api.get("/zapier/api/v4/profile/", {
|
|
2188
|
+
authRequired: true
|
|
2189
|
+
});
|
|
2190
|
+
return {
|
|
2191
|
+
id: String(profile.public_id ?? profile.id),
|
|
2192
|
+
first_name: profile.first_name,
|
|
2193
|
+
last_name: profile.last_name,
|
|
2194
|
+
full_name: `${profile.first_name} ${profile.last_name}`,
|
|
2195
|
+
email: profile.email,
|
|
2196
|
+
email_confirmed: profile.email_confirmed,
|
|
2197
|
+
timezone: profile.timezone
|
|
2198
|
+
};
|
|
2199
|
+
}
|
|
2200
|
+
});
|
|
1283
2201
|
|
|
1284
2202
|
// src/constants.ts
|
|
1285
2203
|
var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
|
|
@@ -3400,8 +4318,63 @@ function parseApprovalReviewStreamPayload(parsed, toolNames) {
|
|
|
3400
4318
|
}
|
|
3401
4319
|
}
|
|
3402
4320
|
|
|
4321
|
+
// src/api/deprecation.ts
|
|
4322
|
+
var DEPRECATION_MESSAGE_HEADER = "zapier-sdk-deprecation-message";
|
|
4323
|
+
var DEPRECATION_ID_HEADER = "zapier-sdk-deprecation-id";
|
|
4324
|
+
var DEPRECATION_NOTICE_EVENT = "api:deprecation_notice";
|
|
4325
|
+
var displayedNoticeIds = /* @__PURE__ */ new Set();
|
|
4326
|
+
function handleDeprecationNotice({
|
|
4327
|
+
response,
|
|
4328
|
+
canSendDeprecationMessaging,
|
|
4329
|
+
onEvent
|
|
4330
|
+
}) {
|
|
4331
|
+
try {
|
|
4332
|
+
sniffDeprecationNotice({ response, canSendDeprecationMessaging, onEvent });
|
|
4333
|
+
} catch {
|
|
4334
|
+
}
|
|
4335
|
+
}
|
|
4336
|
+
function sniffDeprecationNotice({
|
|
4337
|
+
response,
|
|
4338
|
+
canSendDeprecationMessaging,
|
|
4339
|
+
onEvent
|
|
4340
|
+
}) {
|
|
4341
|
+
if (!canSendDeprecationMessaging) return;
|
|
4342
|
+
const message = response.headers?.get(DEPRECATION_MESSAGE_HEADER);
|
|
4343
|
+
if (!message) return;
|
|
4344
|
+
const id = response.headers.get(DEPRECATION_ID_HEADER) ?? message;
|
|
4345
|
+
if (!displayedNoticeIds.has(id)) {
|
|
4346
|
+
displayedNoticeIds.add(id);
|
|
4347
|
+
console.warn(`[zapier-sdk] Deprecation: ${message}`);
|
|
4348
|
+
}
|
|
4349
|
+
if (onEvent) {
|
|
4350
|
+
const payload = { id, message };
|
|
4351
|
+
const deprecation = parseDeprecationDate(
|
|
4352
|
+
response.headers.get("deprecation")
|
|
4353
|
+
);
|
|
4354
|
+
if (deprecation !== void 0) payload.deprecation = deprecation;
|
|
4355
|
+
const maybePromise = onEvent({
|
|
4356
|
+
type: DEPRECATION_NOTICE_EVENT,
|
|
4357
|
+
payload: { ...payload },
|
|
4358
|
+
timestamp: Date.now()
|
|
4359
|
+
});
|
|
4360
|
+
if (isPromiseLike(maybePromise)) {
|
|
4361
|
+
void Promise.resolve(maybePromise).catch(() => {
|
|
4362
|
+
});
|
|
4363
|
+
}
|
|
4364
|
+
}
|
|
4365
|
+
}
|
|
4366
|
+
function isPromiseLike(value) {
|
|
4367
|
+
return (typeof value === "object" || typeof value === "function") && value !== null && "then" in value && typeof value.then === "function";
|
|
4368
|
+
}
|
|
4369
|
+
function parseDeprecationDate(value) {
|
|
4370
|
+
if (!value) return void 0;
|
|
4371
|
+
const match = /^@(-?\d+)$/.exec(value.trim());
|
|
4372
|
+
if (!match) return void 0;
|
|
4373
|
+
return Number(match[1]) * 1e3;
|
|
4374
|
+
}
|
|
4375
|
+
|
|
3403
4376
|
// src/sdk-version.ts
|
|
3404
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
4377
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.79.0" : void 0) || "unknown";
|
|
3405
4378
|
|
|
3406
4379
|
// src/utils/open-url.ts
|
|
3407
4380
|
var nodePrefix = "node:";
|
|
@@ -3513,6 +4486,30 @@ var PollApprovalResponseSchema = z.object({
|
|
|
3513
4486
|
reason: z.string().optional()
|
|
3514
4487
|
});
|
|
3515
4488
|
var APPROVAL_MAX_POLLING_INTERVAL_MS = 5e3;
|
|
4489
|
+
function validateSdkPath(path) {
|
|
4490
|
+
if (!path.startsWith("/") || path.startsWith("//")) {
|
|
4491
|
+
throw new ZapierValidationError(
|
|
4492
|
+
`fetch expects a path starting with a single '/', got: ${path}`
|
|
4493
|
+
);
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
4496
|
+
function findPathConfigEntries({
|
|
4497
|
+
path,
|
|
4498
|
+
matchResolvedGatewayPath = false
|
|
4499
|
+
}) {
|
|
4500
|
+
const pathSegments = path.split("/").filter(Boolean);
|
|
4501
|
+
return Object.entries(pathConfig).filter(([configPath, config]) => {
|
|
4502
|
+
if (!matchResolvedGatewayPath) {
|
|
4503
|
+
return path === configPath || path.startsWith(`${configPath}/`);
|
|
4504
|
+
}
|
|
4505
|
+
const prefixSegments = (config.pathPrefix ?? configPath).split("/").filter(Boolean);
|
|
4506
|
+
return pathSegments.some(
|
|
4507
|
+
(_, startIndex) => prefixSegments.every(
|
|
4508
|
+
(segment, offset) => pathSegments[startIndex + offset] === segment
|
|
4509
|
+
)
|
|
4510
|
+
);
|
|
4511
|
+
}).map(([configPath, config]) => ({ configPath, config }));
|
|
4512
|
+
}
|
|
3516
4513
|
function parseRateLimitHeaders(response) {
|
|
3517
4514
|
const info = {};
|
|
3518
4515
|
const retryAfter = response.headers.get("retry-after");
|
|
@@ -3557,8 +4554,18 @@ var pathConfig = {
|
|
|
3557
4554
|
// e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
|
|
3558
4555
|
"/relay": {
|
|
3559
4556
|
authHeader: "X-Relay-Authorization",
|
|
3560
|
-
pathPrefix: "/api/v0/sdk/relay"
|
|
4557
|
+
pathPrefix: "/api/v0/sdk/relay",
|
|
4558
|
+
omitDeprecationMessaging: true
|
|
4559
|
+
},
|
|
4560
|
+
// The concrete gateway form of the relay route. Callers that pass the
|
|
4561
|
+
// already-prefixed path reach the same third-party upstreams, so it must
|
|
4562
|
+
// classify as relay too; without this entry it would match nothing and
|
|
4563
|
+
// sniff deprecation headers off a relay response.
|
|
4564
|
+
"/api/v0/sdk/relay": {
|
|
4565
|
+
omitDeprecationMessaging: true
|
|
3561
4566
|
},
|
|
4567
|
+
// Concrete sdkapi routes that do not live behind /api/v0/sdk/<service>.
|
|
4568
|
+
"/api/v0": {},
|
|
3562
4569
|
// e.g. /zapier -> https://sdkapi.zapier.com/api/v0/sdk/zapier/...
|
|
3563
4570
|
"/zapier": {
|
|
3564
4571
|
authHeader: "Authorization",
|
|
@@ -3707,17 +4714,50 @@ var ZapierApiClient = class {
|
|
|
3707
4714
|
* parallelism into the queue.
|
|
3708
4715
|
*/
|
|
3709
4716
|
this.rawFetch = async (path, init) => {
|
|
3710
|
-
|
|
3711
|
-
throw new ZapierValidationError(
|
|
3712
|
-
`fetch expects a path starting with '/', got: ${path}`
|
|
3713
|
-
);
|
|
3714
|
-
}
|
|
4717
|
+
validateSdkPath(path);
|
|
3715
4718
|
const { url, pathConfig: pathConfig2 } = this.buildUrl(path, init?.searchParams);
|
|
3716
4719
|
return this.withSemaphore(
|
|
3717
4720
|
{ url, method: init?.method ?? "GET", signal: init?.signal },
|
|
3718
4721
|
() => this.rawFetchUrl(url, init, pathConfig2)
|
|
3719
4722
|
);
|
|
3720
4723
|
};
|
|
4724
|
+
this.runApprovalFetchLoop = async ({
|
|
4725
|
+
path,
|
|
4726
|
+
init,
|
|
4727
|
+
maxRetries,
|
|
4728
|
+
approvalMode,
|
|
4729
|
+
approvalContext
|
|
4730
|
+
}) => {
|
|
4731
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
4732
|
+
const response = await this.rawFetch(path, init);
|
|
4733
|
+
if (response.status !== 403) {
|
|
4734
|
+
return { response };
|
|
4735
|
+
}
|
|
4736
|
+
const errorType = response.headers.get("x-zapier-error-type");
|
|
4737
|
+
if (errorType !== "approval_required") {
|
|
4738
|
+
return { response };
|
|
4739
|
+
}
|
|
4740
|
+
if (attempt === maxRetries) {
|
|
4741
|
+
return { response };
|
|
4742
|
+
}
|
|
4743
|
+
if (approvalMode === "disabled") {
|
|
4744
|
+
return { response };
|
|
4745
|
+
}
|
|
4746
|
+
if (!approvalContext) {
|
|
4747
|
+
return { response };
|
|
4748
|
+
}
|
|
4749
|
+
try {
|
|
4750
|
+
await this.runOneApprovalRound(
|
|
4751
|
+
approvalContext,
|
|
4752
|
+
approvalMode,
|
|
4753
|
+
init?.signal ?? void 0
|
|
4754
|
+
);
|
|
4755
|
+
} catch (error) {
|
|
4756
|
+
return { response, approvalRoundError: error };
|
|
4757
|
+
}
|
|
4758
|
+
}
|
|
4759
|
+
throw new ZapierApiError("Approval retry loop ended unexpectedly");
|
|
4760
|
+
};
|
|
3721
4761
|
/**
|
|
3722
4762
|
* Approval-aware HTTP fetch.
|
|
3723
4763
|
*
|
|
@@ -3747,46 +4787,62 @@ var ZapierApiClient = class {
|
|
|
3747
4787
|
* `max_retries_exceeded` instead.
|
|
3748
4788
|
*/
|
|
3749
4789
|
this.fetch = async (path, init) => {
|
|
4790
|
+
validateSdkPath(path);
|
|
3750
4791
|
const maxRetries = this.options.maxApprovalRetries ?? DEFAULT_MAX_APPROVAL_RETRIES;
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
}
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
4792
|
+
const { canSendDeprecationMessaging } = this.buildUrl(
|
|
4793
|
+
path,
|
|
4794
|
+
init?.searchParams
|
|
4795
|
+
);
|
|
4796
|
+
const approvalMode = this.options.approvalMode ?? getZapierApprovalMode() ?? getZapierDefaultApprovalMode();
|
|
4797
|
+
const approvalContext = init?.approvalContext;
|
|
4798
|
+
const { response, approvalRoundError } = await this.runApprovalFetchLoop({
|
|
4799
|
+
path,
|
|
4800
|
+
init,
|
|
4801
|
+
maxRetries,
|
|
4802
|
+
approvalMode,
|
|
4803
|
+
approvalContext
|
|
4804
|
+
});
|
|
4805
|
+
handleDeprecationNotice({
|
|
4806
|
+
response,
|
|
4807
|
+
canSendDeprecationMessaging,
|
|
4808
|
+
onEvent: this.options.onEvent
|
|
4809
|
+
});
|
|
4810
|
+
if (response.status !== 403) {
|
|
4811
|
+
return response;
|
|
4812
|
+
}
|
|
4813
|
+
const errorType = response.headers.get("x-zapier-error-type");
|
|
4814
|
+
if (errorType === "request_denied_by_policy") {
|
|
4815
|
+
const { data } = await this.parseResult(response);
|
|
4816
|
+
const { message, errors } = this.parseErrorResponse({
|
|
4817
|
+
status: response.status,
|
|
4818
|
+
statusText: response.statusText,
|
|
4819
|
+
data
|
|
4820
|
+
});
|
|
4821
|
+
throw new ZapierApprovalError(
|
|
4822
|
+
message || "Request explicitly denied by policy",
|
|
4823
|
+
{
|
|
4824
|
+
status: "policy_denied",
|
|
4825
|
+
statusCode: response.status,
|
|
4826
|
+
errors
|
|
4827
|
+
}
|
|
4828
|
+
);
|
|
4829
|
+
}
|
|
4830
|
+
if (errorType !== "approval_required") {
|
|
4831
|
+
return response;
|
|
4832
|
+
}
|
|
4833
|
+
if (approvalRoundError) {
|
|
4834
|
+
throw approvalRoundError;
|
|
4835
|
+
}
|
|
4836
|
+
if (approvalMode === "disabled") {
|
|
4837
|
+
throw new ZapierApprovalError(
|
|
4838
|
+
"Approvals are disabled. Set approvalMode to 'poll' or 'throw' (or ZAPIER_APPROVAL_MODE) to enable.",
|
|
4839
|
+
{ status: "approval_required" }
|
|
4840
|
+
);
|
|
4841
|
+
}
|
|
4842
|
+
if (!approvalContext) {
|
|
4843
|
+
throw new ZapierApiError(
|
|
4844
|
+
`Received 403 approval_required for ${path}, but the caller did not provide an approvalContext builder. Every approval-capable request must pass approvalContext so the SDK can create the approval with the correct policy context.`,
|
|
4845
|
+
{ statusCode: 403 }
|
|
3790
4846
|
);
|
|
3791
4847
|
}
|
|
3792
4848
|
throw new ZapierApprovalError(
|
|
@@ -4048,40 +5104,60 @@ var ZapierApiClient = class {
|
|
|
4048
5104
|
}
|
|
4049
5105
|
// Apply any special routing logic for configured paths.
|
|
4050
5106
|
applyPathConfiguration(path) {
|
|
4051
|
-
const
|
|
4052
|
-
|
|
4053
|
-
)
|
|
4054
|
-
|
|
5107
|
+
const matchingPathEntries = findPathConfigEntries({ path });
|
|
5108
|
+
const routingMatch = matchingPathEntries[0];
|
|
5109
|
+
const buildResult = (url2) => {
|
|
5110
|
+
const resolvedPathEntries = findPathConfigEntries({
|
|
5111
|
+
path: url2.pathname,
|
|
5112
|
+
matchResolvedGatewayPath: true
|
|
5113
|
+
});
|
|
5114
|
+
const deprecationPathMatches = [
|
|
5115
|
+
...matchingPathEntries,
|
|
5116
|
+
...resolvedPathEntries
|
|
5117
|
+
];
|
|
5118
|
+
const canSendDeprecationMessaging = deprecationPathMatches.length > 0 && deprecationPathMatches.every(
|
|
5119
|
+
({ config }) => config.omitDeprecationMessaging !== true
|
|
5120
|
+
);
|
|
5121
|
+
return {
|
|
5122
|
+
url: url2,
|
|
5123
|
+
pathConfig: routingMatch?.config,
|
|
5124
|
+
canSendDeprecationMessaging
|
|
5125
|
+
};
|
|
5126
|
+
};
|
|
4055
5127
|
let finalPath = path;
|
|
4056
|
-
if (config
|
|
4057
|
-
const pathWithoutPrefix = path.slice(
|
|
4058
|
-
finalPath = `${config.pathPrefix}${pathWithoutPrefix}`;
|
|
5128
|
+
if (routingMatch?.config.pathPrefix) {
|
|
5129
|
+
const pathWithoutPrefix = path.slice(routingMatch.configPath.length) || "/";
|
|
5130
|
+
finalPath = `${routingMatch.config.pathPrefix}${pathWithoutPrefix}`;
|
|
4059
5131
|
}
|
|
4060
5132
|
const zapierBaseUrl = getZapierBaseUrl(this.options.baseUrl);
|
|
4061
5133
|
if (zapierBaseUrl === this.options.baseUrl.replace(/\/$/, "")) {
|
|
4062
5134
|
const originalBaseUrl = new URL(this.options.baseUrl);
|
|
4063
5135
|
const finalBaseUrl = `https://sdkapi.${originalBaseUrl.hostname}`;
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
pathConfig: config
|
|
4067
|
-
};
|
|
5136
|
+
const url2 = new URL(finalPath, finalBaseUrl);
|
|
5137
|
+
return buildResult(url2);
|
|
4068
5138
|
}
|
|
4069
5139
|
const baseUrl = new URL(this.options.baseUrl);
|
|
4070
5140
|
const basePath = baseUrl.pathname.replace(/\/$/, "");
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
pathConfig: config
|
|
4074
|
-
};
|
|
5141
|
+
const url = new URL(basePath + finalPath, baseUrl.origin);
|
|
5142
|
+
return buildResult(url);
|
|
4075
5143
|
}
|
|
4076
5144
|
// Helper to build full URLs and return routing info
|
|
4077
5145
|
buildUrl(path, searchParams) {
|
|
4078
|
-
const {
|
|
5146
|
+
const {
|
|
5147
|
+
url,
|
|
5148
|
+
pathConfig: config,
|
|
5149
|
+
canSendDeprecationMessaging
|
|
5150
|
+
} = this.applyPathConfiguration(path);
|
|
4079
5151
|
if (searchParams) {
|
|
4080
5152
|
Object.entries(searchParams).forEach(([key, value]) => {
|
|
4081
5153
|
url.searchParams.set(key, value);
|
|
4082
5154
|
});
|
|
4083
5155
|
}
|
|
4084
|
-
return {
|
|
5156
|
+
return {
|
|
5157
|
+
url: url.toString(),
|
|
5158
|
+
pathConfig: config,
|
|
5159
|
+
canSendDeprecationMessaging
|
|
5160
|
+
};
|
|
4085
5161
|
}
|
|
4086
5162
|
// Helper to build headers
|
|
4087
5163
|
async buildHeaders(options = {}, pathConfig2) {
|
|
@@ -4645,67 +5721,6 @@ var apiPlugin = definePlugin(
|
|
|
4645
5721
|
};
|
|
4646
5722
|
}
|
|
4647
5723
|
);
|
|
4648
|
-
var GetProfileSchema = z.object({}).optional().describe("Get current user's profile information");
|
|
4649
|
-
var UserProfileItemSchema = z.object({
|
|
4650
|
-
id: z.string(),
|
|
4651
|
-
first_name: z.string(),
|
|
4652
|
-
last_name: z.string(),
|
|
4653
|
-
full_name: z.string(),
|
|
4654
|
-
email: z.string(),
|
|
4655
|
-
email_confirmed: z.boolean(),
|
|
4656
|
-
timezone: z.string()
|
|
4657
|
-
});
|
|
4658
|
-
|
|
4659
|
-
// src/formatters/userProfile.ts
|
|
4660
|
-
var userProfileItemFormatter = {
|
|
4661
|
-
format: (item) => {
|
|
4662
|
-
const details = [];
|
|
4663
|
-
if (item.email) {
|
|
4664
|
-
details.push({ text: item.email, style: "dim" });
|
|
4665
|
-
}
|
|
4666
|
-
if (item.timezone) {
|
|
4667
|
-
details.push({
|
|
4668
|
-
text: `Timezone: ${item.timezone}`,
|
|
4669
|
-
style: "accent"
|
|
4670
|
-
});
|
|
4671
|
-
}
|
|
4672
|
-
return {
|
|
4673
|
-
title: item.full_name,
|
|
4674
|
-
id: item.id,
|
|
4675
|
-
details
|
|
4676
|
-
};
|
|
4677
|
-
}
|
|
4678
|
-
};
|
|
4679
|
-
|
|
4680
|
-
// src/plugins/getProfile/index.ts
|
|
4681
|
-
var getProfilePlugin = definePlugin(
|
|
4682
|
-
(sdk) => createPluginMethod(sdk, {
|
|
4683
|
-
name: "getProfile",
|
|
4684
|
-
categories: ["account"],
|
|
4685
|
-
type: "item",
|
|
4686
|
-
itemType: "Profile",
|
|
4687
|
-
inputSchema: GetProfileSchema,
|
|
4688
|
-
outputSchema: UserProfileItemSchema,
|
|
4689
|
-
formatter: userProfileItemFormatter,
|
|
4690
|
-
handler: async ({ sdk: sdk2 }) => {
|
|
4691
|
-
const profile = await sdk2.context.api.get(
|
|
4692
|
-
"/zapier/api/v4/profile/",
|
|
4693
|
-
{ authRequired: true }
|
|
4694
|
-
);
|
|
4695
|
-
return {
|
|
4696
|
-
data: {
|
|
4697
|
-
id: String(profile.public_id ?? profile.id),
|
|
4698
|
-
first_name: profile.first_name,
|
|
4699
|
-
last_name: profile.last_name,
|
|
4700
|
-
full_name: `${profile.first_name} ${profile.last_name}`,
|
|
4701
|
-
email: profile.email,
|
|
4702
|
-
email_confirmed: profile.email_confirmed,
|
|
4703
|
-
timezone: profile.timezone
|
|
4704
|
-
}
|
|
4705
|
-
};
|
|
4706
|
-
}
|
|
4707
|
-
})
|
|
4708
|
-
);
|
|
4709
5724
|
|
|
4710
5725
|
// src/utils/pagination.ts
|
|
4711
5726
|
function extractCursorFromUrl(url) {
|
|
@@ -6380,7 +7395,7 @@ var actionResultItemFormatter = {
|
|
|
6380
7395
|
id: getStringProperty(obj, "id"),
|
|
6381
7396
|
key: getStringProperty(obj, "key"),
|
|
6382
7397
|
description: getStringProperty(obj, "description"),
|
|
6383
|
-
|
|
7398
|
+
raw: item,
|
|
6384
7399
|
details: []
|
|
6385
7400
|
};
|
|
6386
7401
|
}
|
|
@@ -10152,12 +11167,6 @@ var eventEmissionPlugin = definePlugin(
|
|
|
10152
11167
|
function createOptionsPlugin(options) {
|
|
10153
11168
|
return () => ({ context: { options } });
|
|
10154
11169
|
}
|
|
10155
|
-
function createSdk() {
|
|
10156
|
-
logDeprecation2(
|
|
10157
|
-
"createSdk() is deprecated. Build SDKs with createPluginStack().use(...).toSdk() instead. The chain pattern shares plugin closures (and their state) across derived SDKs in ways that are rarely what callers expect; stacks produce fresh closures per .toSdk() call."
|
|
10158
|
-
);
|
|
10159
|
-
return withDeprecatedAddPlugin(createZapierCoreStack().toSdk());
|
|
10160
|
-
}
|
|
10161
11170
|
function createZapierSdkWithoutRegistry(options = {}) {
|
|
10162
11171
|
logDeprecation2(
|
|
10163
11172
|
"createZapierSdkWithoutRegistry is deprecated; use createZapierSdk instead. getRegistry is now available on every sdk."
|
|
@@ -10165,10 +11174,22 @@ function createZapierSdkWithoutRegistry(options = {}) {
|
|
|
10165
11174
|
return createZapierSdk(options);
|
|
10166
11175
|
}
|
|
10167
11176
|
function createZapierSdkStack(options = {}) {
|
|
10168
|
-
return createZapierCoreStack().use(createOptionsPlugin(options)).use(eventEmissionPlugin).use(apiPlugin).use(manifestPlugin).use(capabilitiesPlugin).use(connectionsPlugin).use(listAppsPlugin).use(getAppPlugin).use(listConnectionsPlugin).use(getConnectionPlugin).use(findFirstConnectionPlugin).use(findUniqueConnectionPlugin).use(getConnectionStartUrlPlugin).use(waitForNewConnectionPlugin).use(createConnectionPlugin).use(listActionsPlugin).use(getActionPlugin).use(listActionInputFieldsPlugin).use(getActionInputFieldsSchemaPlugin).use(listActionInputFieldChoicesPlugin).use(listInputFieldsDeprecatedPlugin).use(getInputFieldsSchemaDeprecatedPlugin).use(listInputFieldChoicesDeprecatedPlugin).use(runActionPlugin).use(listAuthenticationsPlugin).use(getAuthenticationPlugin).use(findFirstAuthenticationPlugin).use(findUniqueAuthenticationPlugin).use(listClientCredentialsPlugin).use(createClientCredentialsPlugin).use(deleteClientCredentialsPlugin).use(fetchPlugin).use(requestPlugin).use(listTablesPlugin).use(getTablePlugin).use(deleteTablePlugin).use(createTablePlugin).use(listTableFieldsPlugin).use(createTableFieldsPlugin).use(deleteTableFieldsPlugin).use(listTableRecordsPlugin).use(getTableRecordPlugin).use(createTableRecordsPlugin).use(deleteTableRecordsPlugin).use(updateTableRecordsPlugin).use(appsPlugin)
|
|
11177
|
+
return createZapierCoreStack().use(createOptionsPlugin(options)).use(eventEmissionPlugin).use(apiPlugin).use(manifestPlugin).use(capabilitiesPlugin).use(connectionsPlugin).use(listAppsPlugin).use(getAppPlugin).use(listConnectionsPlugin).use(getConnectionPlugin).use(findFirstConnectionPlugin).use(findUniqueConnectionPlugin).use(getConnectionStartUrlPlugin).use(waitForNewConnectionPlugin).use(createConnectionPlugin).use(listActionsPlugin).use(getActionPlugin).use(listActionInputFieldsPlugin).use(getActionInputFieldsSchemaPlugin).use(listActionInputFieldChoicesPlugin).use(listInputFieldsDeprecatedPlugin).use(getInputFieldsSchemaDeprecatedPlugin).use(listInputFieldChoicesDeprecatedPlugin).use(runActionPlugin).use(listAuthenticationsPlugin).use(getAuthenticationPlugin).use(findFirstAuthenticationPlugin).use(findUniqueAuthenticationPlugin).use(listClientCredentialsPlugin).use(createClientCredentialsPlugin).use(deleteClientCredentialsPlugin).use(fetchPlugin).use(requestPlugin).use(listTablesPlugin).use(getTablePlugin).use(deleteTablePlugin).use(createTablePlugin).use(listTableFieldsPlugin).use(createTableFieldsPlugin).use(deleteTableFieldsPlugin).use(listTableRecordsPlugin).use(getTableRecordPlugin).use(createTableRecordsPlugin).use(deleteTableRecordsPlugin).use(updateTableRecordsPlugin).use(appsPlugin);
|
|
10169
11178
|
}
|
|
11179
|
+
var zapierSdkPlugin = definePlugin({
|
|
11180
|
+
namespace: "zapier",
|
|
11181
|
+
name: "sdk",
|
|
11182
|
+
exports: [getProfilePlugin]
|
|
11183
|
+
});
|
|
10170
11184
|
function createZapierSdk(options = {}) {
|
|
10171
|
-
return
|
|
11185
|
+
return createSdk(
|
|
11186
|
+
defineLegacyMerge({
|
|
11187
|
+
namespace: "zapier",
|
|
11188
|
+
name: "sdk-stack-merge",
|
|
11189
|
+
legacy: createZapierSdkStack(options).toPlugin(),
|
|
11190
|
+
plugin: zapierSdkPlugin
|
|
11191
|
+
})
|
|
11192
|
+
);
|
|
10172
11193
|
}
|
|
10173
11194
|
var TriggerInboxStatusSchema = z.union([
|
|
10174
11195
|
z.enum([
|
|
@@ -13308,10 +14329,17 @@ var registryPlugin = definePlugin((_sdk) => {
|
|
|
13308
14329
|
|
|
13309
14330
|
// src/experimental.ts
|
|
13310
14331
|
function createZapierSdkStack2(options = {}) {
|
|
13311
|
-
return createZapierCoreStack().use(createOptionsPlugin(options)).use(eventEmissionPlugin).use(apiPlugin).use(manifestPlugin).use(capabilitiesPlugin).use(connectionsPlugin).use(listAppsPlugin).use(getAppPlugin).use(listConnectionsPlugin).use(getConnectionPlugin).use(findFirstConnectionPlugin).use(findUniqueConnectionPlugin).use(getConnectionStartUrlPlugin).use(waitForNewConnectionPlugin).use(createConnectionPlugin).use(listActionsPlugin).use(getActionPlugin).use(listActionInputFieldsPlugin).use(getActionInputFieldsSchemaPlugin).use(listActionInputFieldChoicesPlugin).use(listInputFieldsDeprecatedPlugin).use(getInputFieldsSchemaDeprecatedPlugin).use(listInputFieldChoicesDeprecatedPlugin).use(runActionPlugin).use(listAuthenticationsPlugin).use(getAuthenticationPlugin).use(findFirstAuthenticationPlugin).use(findUniqueAuthenticationPlugin).use(listClientCredentialsPlugin).use(createClientCredentialsPlugin).use(deleteClientCredentialsPlugin).use(fetchPlugin).use(requestPlugin).use(listTriggerInboxesPlugin).use(createTriggerInboxPlugin).use(ensureTriggerInboxPlugin).use(getTriggerInboxPlugin).use(updateTriggerInboxPlugin).use(deleteTriggerInboxPlugin).use(pauseTriggerInboxPlugin).use(resumeTriggerInboxPlugin).use(listTriggerInboxMessagesPlugin).use(leaseTriggerInboxMessagesPlugin).use(ackTriggerInboxMessagesPlugin).use(releaseTriggerInboxMessagesPlugin).use(drainTriggerInboxPlugin).use(watchTriggerInboxPlugin).use(listTriggersPlugin).use(listTriggerInputFieldsPlugin).use(listTriggerInputFieldChoicesPlugin).use(getTriggerInputFieldsSchemaPlugin).use(listTablesPlugin).use(getTablePlugin).use(deleteTablePlugin).use(createTablePlugin).use(listTableFieldsPlugin).use(createTableFieldsPlugin).use(deleteTableFieldsPlugin).use(listTableRecordsPlugin).use(getTableRecordPlugin).use(createTableRecordsPlugin).use(deleteTableRecordsPlugin).use(updateTableRecordsPlugin).use(listWorkflowsPlugin).use(getWorkflowPlugin).use(createWorkflowPlugin).use(updateWorkflowPlugin).use(enableWorkflowPlugin).use(disableWorkflowPlugin).use(deleteWorkflowPlugin).use(listDurableRunsPlugin).use(getDurableRunPlugin).use(runDurablePlugin).use(cancelDurableRunPlugin).use(publishWorkflowVersionPlugin).use(listWorkflowVersionsPlugin).use(getWorkflowVersionPlugin).use(listWorkflowRunsPlugin).use(getWorkflowRunPlugin).use(getTriggerRunPlugin).use(triggerWorkflowPlugin).use(appsPlugin)
|
|
14332
|
+
return createZapierCoreStack().use(createOptionsPlugin(options)).use(eventEmissionPlugin).use(apiPlugin).use(manifestPlugin).use(capabilitiesPlugin).use(connectionsPlugin).use(listAppsPlugin).use(getAppPlugin).use(listConnectionsPlugin).use(getConnectionPlugin).use(findFirstConnectionPlugin).use(findUniqueConnectionPlugin).use(getConnectionStartUrlPlugin).use(waitForNewConnectionPlugin).use(createConnectionPlugin).use(listActionsPlugin).use(getActionPlugin).use(listActionInputFieldsPlugin).use(getActionInputFieldsSchemaPlugin).use(listActionInputFieldChoicesPlugin).use(listInputFieldsDeprecatedPlugin).use(getInputFieldsSchemaDeprecatedPlugin).use(listInputFieldChoicesDeprecatedPlugin).use(runActionPlugin).use(listAuthenticationsPlugin).use(getAuthenticationPlugin).use(findFirstAuthenticationPlugin).use(findUniqueAuthenticationPlugin).use(listClientCredentialsPlugin).use(createClientCredentialsPlugin).use(deleteClientCredentialsPlugin).use(fetchPlugin).use(requestPlugin).use(listTriggerInboxesPlugin).use(createTriggerInboxPlugin).use(ensureTriggerInboxPlugin).use(getTriggerInboxPlugin).use(updateTriggerInboxPlugin).use(deleteTriggerInboxPlugin).use(pauseTriggerInboxPlugin).use(resumeTriggerInboxPlugin).use(listTriggerInboxMessagesPlugin).use(leaseTriggerInboxMessagesPlugin).use(ackTriggerInboxMessagesPlugin).use(releaseTriggerInboxMessagesPlugin).use(drainTriggerInboxPlugin).use(watchTriggerInboxPlugin).use(listTriggersPlugin).use(listTriggerInputFieldsPlugin).use(listTriggerInputFieldChoicesPlugin).use(getTriggerInputFieldsSchemaPlugin).use(listTablesPlugin).use(getTablePlugin).use(deleteTablePlugin).use(createTablePlugin).use(listTableFieldsPlugin).use(createTableFieldsPlugin).use(deleteTableFieldsPlugin).use(listTableRecordsPlugin).use(getTableRecordPlugin).use(createTableRecordsPlugin).use(deleteTableRecordsPlugin).use(updateTableRecordsPlugin).use(listWorkflowsPlugin).use(getWorkflowPlugin).use(createWorkflowPlugin).use(updateWorkflowPlugin).use(enableWorkflowPlugin).use(disableWorkflowPlugin).use(deleteWorkflowPlugin).use(listDurableRunsPlugin).use(getDurableRunPlugin).use(runDurablePlugin).use(cancelDurableRunPlugin).use(publishWorkflowVersionPlugin).use(listWorkflowVersionsPlugin).use(getWorkflowVersionPlugin).use(listWorkflowRunsPlugin).use(getWorkflowRunPlugin).use(getTriggerRunPlugin).use(triggerWorkflowPlugin).use(appsPlugin);
|
|
13312
14333
|
}
|
|
13313
14334
|
function createZapierSdk2(options = {}) {
|
|
13314
|
-
return
|
|
14335
|
+
return createSdk(
|
|
14336
|
+
defineLegacyMerge({
|
|
14337
|
+
namespace: "zapier",
|
|
14338
|
+
name: "experimental-stack-merge",
|
|
14339
|
+
legacy: createZapierSdkStack2(options).toPlugin(),
|
|
14340
|
+
plugin: zapierSdkPlugin
|
|
14341
|
+
})
|
|
14342
|
+
);
|
|
13315
14343
|
}
|
|
13316
14344
|
|
|
13317
|
-
export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthMechanism, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, CORE_ERROR_SYMBOL, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CoreErrorCode, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, addPlugin, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createCorePlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierCoreStack, createZapierSdk2 as createZapierSdk, createZapierSdkStack2 as createZapierSdkStack, createZapierSdkWithoutRegistry, definePlugin, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, durableRunIdResolver, eventEmissionPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCoreErrorCause, getCoreErrorCode, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCoreError, isCredentialsFunction, isCredentialsObject, isPermanentHttpError, isPkceCredentials, isPositional, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation2 as logDeprecation, manifestPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings2 as resetDeprecationWarnings, resolveAuth, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runInMethodScope, runWithCallerContext, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError };
|
|
14345
|
+
export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthMechanism, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, CORE_ERROR_SYMBOL, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CoreErrorCode, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_APPROVAL_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DEPRECATION_NOTICE_EVENT, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, addPlugin, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, composePlugins, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createCorePlugin, createFunction, createMemoryCache, createOptionsPlugin, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierCoreStack, createZapierSdk2 as createZapierSdk, createZapierSdkStack2 as createZapierSdkStack, createZapierSdkWithoutRegistry, dangerousContextPlugin, declareMethod, declareProperty, defineLegacyMerge, defineMethod, definePlugin, defineProperty, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, durableRunIdResolver, eventEmissionPlugin, 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, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCoreError, isCredentialsFunction, isCredentialsObject, isPermanentHttpError, isPkceCredentials, isPositional, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation2 as logDeprecation, manifestPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings2 as resetDeprecationWarnings, resolveAuth, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runInMethodScope, runWithCallerContext, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError, zapierSdkPlugin };
|