@zapier/zapier-sdk 0.77.2 → 0.78.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 +10 -0
- package/dist/experimental.cjs +1057 -178
- package/dist/experimental.d.mts +22 -38
- package/dist/experimental.d.ts +22 -38
- package/dist/experimental.mjs +1049 -179
- package/dist/{index-kC0bJpsG.d.mts → index-BgbftweS.d.mts} +4793 -3885
- package/dist/{index-kC0bJpsG.d.ts → index-BgbftweS.d.ts} +4793 -3885
- package/dist/index.cjs +2489 -1617
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2481 -1618
- 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";
|
|
@@ -3401,7 +4319,7 @@ function parseApprovalReviewStreamPayload(parsed, toolNames) {
|
|
|
3401
4319
|
}
|
|
3402
4320
|
|
|
3403
4321
|
// src/sdk-version.ts
|
|
3404
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
4322
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.78.0" : void 0) || "unknown";
|
|
3405
4323
|
|
|
3406
4324
|
// src/utils/open-url.ts
|
|
3407
4325
|
var nodePrefix = "node:";
|
|
@@ -4645,67 +5563,6 @@ var apiPlugin = definePlugin(
|
|
|
4645
5563
|
};
|
|
4646
5564
|
}
|
|
4647
5565
|
);
|
|
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
5566
|
|
|
4710
5567
|
// src/utils/pagination.ts
|
|
4711
5568
|
function extractCursorFromUrl(url) {
|
|
@@ -6380,7 +7237,7 @@ var actionResultItemFormatter = {
|
|
|
6380
7237
|
id: getStringProperty(obj, "id"),
|
|
6381
7238
|
key: getStringProperty(obj, "key"),
|
|
6382
7239
|
description: getStringProperty(obj, "description"),
|
|
6383
|
-
|
|
7240
|
+
raw: item,
|
|
6384
7241
|
details: []
|
|
6385
7242
|
};
|
|
6386
7243
|
}
|
|
@@ -10152,12 +11009,6 @@ var eventEmissionPlugin = definePlugin(
|
|
|
10152
11009
|
function createOptionsPlugin(options) {
|
|
10153
11010
|
return () => ({ context: { options } });
|
|
10154
11011
|
}
|
|
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
11012
|
function createZapierSdkWithoutRegistry(options = {}) {
|
|
10162
11013
|
logDeprecation2(
|
|
10163
11014
|
"createZapierSdkWithoutRegistry is deprecated; use createZapierSdk instead. getRegistry is now available on every sdk."
|
|
@@ -10165,10 +11016,22 @@ function createZapierSdkWithoutRegistry(options = {}) {
|
|
|
10165
11016
|
return createZapierSdk(options);
|
|
10166
11017
|
}
|
|
10167
11018
|
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)
|
|
11019
|
+
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
11020
|
}
|
|
11021
|
+
var zapierSdkPlugin = definePlugin({
|
|
11022
|
+
namespace: "zapier",
|
|
11023
|
+
name: "sdk",
|
|
11024
|
+
exports: [getProfilePlugin]
|
|
11025
|
+
});
|
|
10170
11026
|
function createZapierSdk(options = {}) {
|
|
10171
|
-
return
|
|
11027
|
+
return createSdk(
|
|
11028
|
+
defineLegacyMerge({
|
|
11029
|
+
namespace: "zapier",
|
|
11030
|
+
name: "sdk-stack-merge",
|
|
11031
|
+
legacy: createZapierSdkStack(options).toPlugin(),
|
|
11032
|
+
plugin: zapierSdkPlugin
|
|
11033
|
+
})
|
|
11034
|
+
);
|
|
10172
11035
|
}
|
|
10173
11036
|
var TriggerInboxStatusSchema = z.union([
|
|
10174
11037
|
z.enum([
|
|
@@ -13308,10 +14171,17 @@ var registryPlugin = definePlugin((_sdk) => {
|
|
|
13308
14171
|
|
|
13309
14172
|
// src/experimental.ts
|
|
13310
14173
|
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)
|
|
14174
|
+
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
14175
|
}
|
|
13313
14176
|
function createZapierSdk2(options = {}) {
|
|
13314
|
-
return
|
|
14177
|
+
return createSdk(
|
|
14178
|
+
defineLegacyMerge({
|
|
14179
|
+
namespace: "zapier",
|
|
14180
|
+
name: "experimental-stack-merge",
|
|
14181
|
+
legacy: createZapierSdkStack2(options).toPlugin(),
|
|
14182
|
+
plugin: zapierSdkPlugin
|
|
14183
|
+
})
|
|
14184
|
+
);
|
|
13315
14185
|
}
|
|
13316
14186
|
|
|
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 };
|
|
14187
|
+
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, 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 };
|