@zapier/zapier-sdk 0.84.2 → 0.84.3
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 +6 -0
- package/dist/experimental.cjs +322 -180
- package/dist/experimental.d.mts +30 -4
- package/dist/experimental.d.ts +30 -4
- package/dist/experimental.mjs +322 -180
- package/dist/{index-DxgpC5hV.d.mts → index-B6Hbs-2p.d.mts} +166 -28
- package/dist/{index-DxgpC5hV.d.ts → index-B6Hbs-2p.d.ts} +166 -28
- package/dist/index.cjs +322 -180
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +322 -180
- package/package.json +2 -2
package/dist/experimental.cjs
CHANGED
|
@@ -203,7 +203,8 @@ function getCoreErrorCause(value) {
|
|
|
203
203
|
var CURSOR_VERSION = 1;
|
|
204
204
|
var CURSOR_SOURCE = {
|
|
205
205
|
API: "api",
|
|
206
|
-
SDK: "sdk"
|
|
206
|
+
SDK: "sdk",
|
|
207
|
+
CONCAT: "concat"
|
|
207
208
|
};
|
|
208
209
|
function encodeBase64(str) {
|
|
209
210
|
return btoa(
|
|
@@ -387,10 +388,32 @@ async function* paginateBuffered(pageFunction, pageOptions) {
|
|
|
387
388
|
}
|
|
388
389
|
}
|
|
389
390
|
var paginate = paginateBuffered;
|
|
391
|
+
function encodeConcatCursor(index, cursor) {
|
|
392
|
+
const envelope = {
|
|
393
|
+
v: CURSOR_VERSION,
|
|
394
|
+
source: CURSOR_SOURCE.CONCAT,
|
|
395
|
+
index,
|
|
396
|
+
cursor
|
|
397
|
+
};
|
|
398
|
+
return encodeBase64(JSON.stringify(envelope));
|
|
399
|
+
}
|
|
400
|
+
function decodeConcatCursor(incoming) {
|
|
401
|
+
if (!incoming) {
|
|
402
|
+
return { index: 0, cursor: void 0 };
|
|
403
|
+
}
|
|
404
|
+
try {
|
|
405
|
+
const envelope = JSON.parse(decodeBase64(incoming));
|
|
406
|
+
if (envelope.v === CURSOR_VERSION && envelope.source === CURSOR_SOURCE.CONCAT && typeof envelope.index === "number") {
|
|
407
|
+
return { index: envelope.index, cursor: envelope.cursor };
|
|
408
|
+
}
|
|
409
|
+
} catch {
|
|
410
|
+
}
|
|
411
|
+
return { index: 0, cursor: incoming };
|
|
412
|
+
}
|
|
390
413
|
function concatPaginated({
|
|
391
414
|
sources,
|
|
392
|
-
|
|
393
|
-
|
|
415
|
+
pageSize = 100,
|
|
416
|
+
cursor
|
|
394
417
|
}) {
|
|
395
418
|
if (sources.length === 0) {
|
|
396
419
|
const empty = { data: [] };
|
|
@@ -400,40 +423,24 @@ function concatPaginated({
|
|
|
400
423
|
}
|
|
401
424
|
});
|
|
402
425
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if (!
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
412
|
-
const next = await currentIterator.next();
|
|
413
|
-
if (next.done) {
|
|
414
|
-
sourceIndex++;
|
|
415
|
-
currentIterator = null;
|
|
426
|
+
const pageFunction = async (options) => {
|
|
427
|
+
let { index, cursor: sourceCursor } = decodeConcatCursor(options.cursor);
|
|
428
|
+
while (index < sources.length) {
|
|
429
|
+
const page = await sources[index]({ cursor: sourceCursor });
|
|
430
|
+
const hasMoreInSource = page.nextCursor != null;
|
|
431
|
+
if (page.data.length === 0 && !hasMoreInSource) {
|
|
432
|
+
index++;
|
|
433
|
+
sourceCursor = void 0;
|
|
416
434
|
continue;
|
|
417
435
|
}
|
|
418
|
-
let items = next.value.data;
|
|
419
|
-
if (dedupe) {
|
|
420
|
-
if (sourceIndex > 0) {
|
|
421
|
-
items = items.filter((item) => !seen.has(dedupe(item)));
|
|
422
|
-
}
|
|
423
|
-
for (const item of items) {
|
|
424
|
-
seen.add(dedupe(item));
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
const hasMoreInSource = next.value.nextCursor != null;
|
|
428
|
-
const hasMoreSources = sourceIndex < sources.length - 1;
|
|
429
436
|
return {
|
|
430
|
-
data:
|
|
431
|
-
nextCursor: hasMoreInSource
|
|
437
|
+
data: page.data,
|
|
438
|
+
nextCursor: hasMoreInSource ? encodeConcatCursor(index, page.nextCursor) : index < sources.length - 1 ? encodeConcatCursor(index + 1, void 0) : void 0
|
|
432
439
|
};
|
|
433
440
|
}
|
|
434
441
|
return { data: [] };
|
|
435
442
|
};
|
|
436
|
-
const iterator = paginateBuffered(pageFunction, { pageSize });
|
|
443
|
+
const iterator = paginateBuffered(pageFunction, { pageSize, cursor });
|
|
437
444
|
const firstPagePromise = iterator.next().then((result) => {
|
|
438
445
|
if (result.done) {
|
|
439
446
|
return { data: [] };
|
|
@@ -1285,6 +1292,7 @@ function defineResolver(config) {
|
|
|
1285
1292
|
getContext: config.getContext,
|
|
1286
1293
|
listItems: config.listItems,
|
|
1287
1294
|
prompt: config.prompt,
|
|
1295
|
+
validate: config.validate,
|
|
1288
1296
|
tryResolveWithoutPrompt: config.tryResolveWithoutPrompt,
|
|
1289
1297
|
tryResolveFromSearch: config.tryResolveFromSearch
|
|
1290
1298
|
};
|
|
@@ -1930,6 +1938,7 @@ function bindResolver(resolver, plugins) {
|
|
|
1930
1938
|
const {
|
|
1931
1939
|
getContext: getContext2,
|
|
1932
1940
|
listItems,
|
|
1941
|
+
validate,
|
|
1933
1942
|
tryResolveWithoutPrompt,
|
|
1934
1943
|
tryResolveFromSearch
|
|
1935
1944
|
} = resolver;
|
|
@@ -1943,6 +1952,9 @@ function bindResolver(resolver, plugins) {
|
|
|
1943
1952
|
};
|
|
1944
1953
|
if (getContext2)
|
|
1945
1954
|
bound.getContext = ({ input }) => getContext2({ imports, input });
|
|
1955
|
+
if (validate) {
|
|
1956
|
+
bound.validate = ({ value, input, context }) => validate({ imports, value, input, context });
|
|
1957
|
+
}
|
|
1946
1958
|
if (tryResolveWithoutPrompt) {
|
|
1947
1959
|
bound.tryResolveWithoutPrompt = ({ input }) => tryResolveWithoutPrompt({ imports, input });
|
|
1948
1960
|
}
|
|
@@ -2611,14 +2623,14 @@ function coerce(leaf, raw) {
|
|
|
2611
2623
|
}
|
|
2612
2624
|
async function validationError(leaf, value, state) {
|
|
2613
2625
|
if (leaf.resolver?.type !== "dynamic") return null;
|
|
2626
|
+
const validate = leaf.resolver.validate;
|
|
2627
|
+
if (!validate) return null;
|
|
2614
2628
|
const context = await resolveContext(leaf, state.resolved);
|
|
2615
|
-
const
|
|
2616
|
-
|
|
2629
|
+
const verdict = await validate({
|
|
2630
|
+
value,
|
|
2617
2631
|
input: mergeInput(state.resolved, leaf.extraInput),
|
|
2618
2632
|
context
|
|
2619
2633
|
});
|
|
2620
|
-
if (!config?.validate) return null;
|
|
2621
|
-
const verdict = config.validate(value);
|
|
2622
2634
|
if (verdict === true) return null;
|
|
2623
2635
|
return typeof verdict === "string" ? verdict : `${leaf.name}: invalid value`;
|
|
2624
2636
|
}
|
|
@@ -2744,20 +2756,36 @@ async function resolveContext(leaf, input) {
|
|
|
2744
2756
|
input: mergeInput(input, leaf.extraInput)
|
|
2745
2757
|
});
|
|
2746
2758
|
}
|
|
2747
|
-
|
|
2759
|
+
function firstPagePosition(opts = {}) {
|
|
2760
|
+
return {
|
|
2761
|
+
...opts.search !== void 0 ? { search: opts.search } : {},
|
|
2762
|
+
pageCursor: null,
|
|
2763
|
+
previousCursors: [],
|
|
2764
|
+
generation: opts.generation ?? 0
|
|
2765
|
+
};
|
|
2766
|
+
}
|
|
2767
|
+
async function fetchListing(leaf, input, position, context) {
|
|
2768
|
+
if (leaf.resolver?.type === "dynamic" && leaf.resolver.inputType === "search" && position.search === void 0) {
|
|
2769
|
+
return { position, items: [] };
|
|
2770
|
+
}
|
|
2748
2771
|
const page = await firstPage(
|
|
2749
2772
|
leaf.resolver?.type === "dynamic" ? leaf.resolver.listItems({
|
|
2750
2773
|
input: mergeInput(input, leaf.extraInput),
|
|
2751
|
-
context
|
|
2752
|
-
search:
|
|
2753
|
-
cursor:
|
|
2774
|
+
context,
|
|
2775
|
+
search: position.search,
|
|
2776
|
+
cursor: position.pageCursor ?? void 0
|
|
2754
2777
|
}) : void 0
|
|
2755
2778
|
);
|
|
2756
2779
|
return {
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2780
|
+
position,
|
|
2781
|
+
items: page.data,
|
|
2782
|
+
...page.nextCursor != null ? { nextCursor: page.nextCursor } : {}
|
|
2783
|
+
};
|
|
2784
|
+
}
|
|
2785
|
+
function toPagination(page) {
|
|
2786
|
+
return {
|
|
2787
|
+
position: page.position,
|
|
2788
|
+
...page.nextCursor !== void 0 ? { nextCursor: page.nextCursor } : {}
|
|
2761
2789
|
};
|
|
2762
2790
|
}
|
|
2763
2791
|
function toChoice(c) {
|
|
@@ -2777,23 +2805,32 @@ var AFFORDANCE = {
|
|
|
2777
2805
|
description: "Filter the options by a search term",
|
|
2778
2806
|
supply: "term"
|
|
2779
2807
|
},
|
|
2780
|
-
|
|
2808
|
+
nextPage: {
|
|
2809
|
+
action: "next_page",
|
|
2810
|
+
description: "Fetch the next page of options"
|
|
2811
|
+
},
|
|
2812
|
+
previousPage: {
|
|
2813
|
+
action: "previous_page",
|
|
2814
|
+
description: "Return to the previous page of options"
|
|
2815
|
+
},
|
|
2781
2816
|
skip: { action: "skip", description: "Omit this optional parameter" },
|
|
2782
2817
|
add: { action: "add", description: "Add another item" },
|
|
2783
2818
|
done: { action: "done", description: "Finish the list" },
|
|
2784
2819
|
retry: { action: "retry", description: "Retry loading the options" },
|
|
2785
2820
|
cancel: { action: "cancel", description: "Cancel resolution" }
|
|
2786
2821
|
};
|
|
2787
|
-
function selectActions(leaf,
|
|
2822
|
+
function selectActions(leaf, page, multiple) {
|
|
2788
2823
|
const searchMode = leaf.resolver?.type === "dynamic" && leaf.resolver.inputType === "search";
|
|
2789
|
-
if (searchMode &&
|
|
2824
|
+
if (searchMode && page.position.search === void 0 && page.items.length === 0) {
|
|
2790
2825
|
const actions2 = multiple ? [AFFORDANCE.search] : [AFFORDANCE.search, AFFORDANCE.custom];
|
|
2791
2826
|
if (!leaf.required) actions2.push(AFFORDANCE.skip);
|
|
2792
2827
|
return actions2;
|
|
2793
2828
|
}
|
|
2794
2829
|
const actions = multiple ? [AFFORDANCE.choose] : [AFFORDANCE.choose, AFFORDANCE.custom];
|
|
2795
2830
|
if (searchMode) actions.push(AFFORDANCE.search);
|
|
2796
|
-
if (
|
|
2831
|
+
if (page.nextCursor) actions.push(AFFORDANCE.nextPage);
|
|
2832
|
+
if (page.position.previousCursors.length > 0)
|
|
2833
|
+
actions.push(AFFORDANCE.previousPage);
|
|
2797
2834
|
if (!leaf.required) actions.push(AFFORDANCE.skip);
|
|
2798
2835
|
return actions;
|
|
2799
2836
|
}
|
|
@@ -2801,16 +2838,17 @@ function labeledMessage(leaf) {
|
|
|
2801
2838
|
if (!leaf.label) return void 0;
|
|
2802
2839
|
return `${leaf.label} (${leaf.required ? "required" : "optional"}):`;
|
|
2803
2840
|
}
|
|
2804
|
-
function selectQuestion(leaf, input,
|
|
2841
|
+
function selectQuestion(leaf, path, input, page, context) {
|
|
2805
2842
|
const resolver = leaf.resolver?.type === "dynamic" ? leaf.resolver : void 0;
|
|
2806
2843
|
const config = resolver?.prompt?.({
|
|
2807
|
-
items:
|
|
2844
|
+
items: page.items,
|
|
2808
2845
|
input: mergeInput(input, leaf.extraInput),
|
|
2809
2846
|
context
|
|
2810
2847
|
});
|
|
2811
2848
|
const multiple = config?.type === "checkbox";
|
|
2812
2849
|
return {
|
|
2813
2850
|
type: "select",
|
|
2851
|
+
path,
|
|
2814
2852
|
// A labeled field's title beats the resolver's message: per-field
|
|
2815
2853
|
// resolvers are shared across fields (one choices-fetcher for every
|
|
2816
2854
|
// field), so only the leaf knows which field is being asked.
|
|
@@ -2818,9 +2856,13 @@ function selectQuestion(leaf, input, listing, context) {
|
|
|
2818
2856
|
choices: (config?.choices ?? []).map(toChoice),
|
|
2819
2857
|
...multiple ? { multiple: true } : {},
|
|
2820
2858
|
...config?.notes?.length ? { notes: config.notes } : {},
|
|
2821
|
-
...
|
|
2859
|
+
...page.position.search !== void 0 ? { search: page.position.search } : {},
|
|
2822
2860
|
...resolver?.placeholder ? { placeholder: resolver.placeholder } : {},
|
|
2823
|
-
|
|
2861
|
+
page: {
|
|
2862
|
+
generation: page.position.generation,
|
|
2863
|
+
index: page.position.previousCursors.length
|
|
2864
|
+
},
|
|
2865
|
+
actions: selectActions(leaf, page, multiple)
|
|
2824
2866
|
};
|
|
2825
2867
|
}
|
|
2826
2868
|
function toControllerError(error) {
|
|
@@ -2842,6 +2884,7 @@ function failedResult(state, name, error) {
|
|
|
2842
2884
|
error: toControllerError(error),
|
|
2843
2885
|
question: {
|
|
2844
2886
|
type: "select",
|
|
2887
|
+
path: state.current ?? [],
|
|
2845
2888
|
message: `Could not load options for ${name}.`,
|
|
2846
2889
|
choices: [],
|
|
2847
2890
|
actions: [AFFORDANCE.retry, AFFORDANCE.cancel]
|
|
@@ -2849,27 +2892,15 @@ function failedResult(state, name, error) {
|
|
|
2849
2892
|
}
|
|
2850
2893
|
};
|
|
2851
2894
|
}
|
|
2852
|
-
async function buildQuestion(leaf, input) {
|
|
2895
|
+
async function buildQuestion(leaf, path, input) {
|
|
2853
2896
|
const optional = !leaf.required;
|
|
2854
2897
|
const resolver = leaf.resolver;
|
|
2855
2898
|
if (resolver?.type === "dynamic") {
|
|
2856
2899
|
const context = await resolveContext(leaf, input);
|
|
2857
|
-
|
|
2858
|
-
const listing2 = {
|
|
2859
|
-
items: [],
|
|
2860
|
-
cursor: void 0,
|
|
2861
|
-
search: void 0,
|
|
2862
|
-
exhausted: true
|
|
2863
|
-
};
|
|
2864
|
-
return {
|
|
2865
|
-
question: selectQuestion(leaf, input, listing2, context),
|
|
2866
|
-
listing: listing2
|
|
2867
|
-
};
|
|
2868
|
-
}
|
|
2869
|
-
const listing = await fetchListing(leaf, input, { context });
|
|
2900
|
+
const page = await fetchListing(leaf, input, firstPagePosition(), context);
|
|
2870
2901
|
return {
|
|
2871
|
-
question: selectQuestion(leaf, input,
|
|
2872
|
-
|
|
2902
|
+
question: selectQuestion(leaf, path, input, page, context),
|
|
2903
|
+
pagination: toPagination(page)
|
|
2873
2904
|
};
|
|
2874
2905
|
}
|
|
2875
2906
|
if (leaf.staticChoices) {
|
|
@@ -2878,6 +2909,7 @@ async function buildQuestion(leaf, input) {
|
|
|
2878
2909
|
return {
|
|
2879
2910
|
question: {
|
|
2880
2911
|
type: "select",
|
|
2912
|
+
path,
|
|
2881
2913
|
message: `Select ${leaf.name}:`,
|
|
2882
2914
|
choices: leaf.staticChoices,
|
|
2883
2915
|
actions: actions2
|
|
@@ -2891,6 +2923,7 @@ async function buildQuestion(leaf, input) {
|
|
|
2891
2923
|
return {
|
|
2892
2924
|
question: {
|
|
2893
2925
|
type: "input",
|
|
2926
|
+
path,
|
|
2894
2927
|
// The optional marker makes Enter-to-pass discoverable on a bare
|
|
2895
2928
|
// parameter; a labeled field carries its marker via labeledMessage.
|
|
2896
2929
|
message: labeledMessage(leaf) ?? `Enter ${leaf.name}${optional ? " (optional)" : ""}:`,
|
|
@@ -2905,6 +2938,7 @@ function collectionQuestion(t) {
|
|
|
2905
2938
|
if (t.count >= t.min) actions.push(AFFORDANCE.done);
|
|
2906
2939
|
return {
|
|
2907
2940
|
type: "collection",
|
|
2941
|
+
path: t.path,
|
|
2908
2942
|
message: `Add ${t.path[t.path.length - 1]}[${t.count}]?`,
|
|
2909
2943
|
container: "array",
|
|
2910
2944
|
count: t.count,
|
|
@@ -2918,6 +2952,7 @@ function collectionQuestion(t) {
|
|
|
2918
2952
|
function objectGateQuestion(path) {
|
|
2919
2953
|
return {
|
|
2920
2954
|
type: "collection",
|
|
2955
|
+
path,
|
|
2921
2956
|
message: `Add ${path[path.length - 1]}?`,
|
|
2922
2957
|
container: "object",
|
|
2923
2958
|
actions: [
|
|
@@ -2929,9 +2964,10 @@ function objectGateQuestion(path) {
|
|
|
2929
2964
|
]
|
|
2930
2965
|
};
|
|
2931
2966
|
}
|
|
2932
|
-
function optionalsGateQuestion(pending) {
|
|
2967
|
+
function optionalsGateQuestion(path, pending) {
|
|
2933
2968
|
return {
|
|
2934
2969
|
type: "collection",
|
|
2970
|
+
path,
|
|
2935
2971
|
// The prompt and its context ride separately so a host renders the info
|
|
2936
2972
|
// line above the confirm without composing any text of its own.
|
|
2937
2973
|
message: "Would you like to configure optional fields?",
|
|
@@ -3079,8 +3115,12 @@ async function askLeaf(state, path, leaf, opts = {}) {
|
|
|
3079
3115
|
state.current = path;
|
|
3080
3116
|
delete state.gate;
|
|
3081
3117
|
try {
|
|
3082
|
-
const { question,
|
|
3083
|
-
|
|
3118
|
+
const { question, pagination } = await buildQuestion(
|
|
3119
|
+
leaf,
|
|
3120
|
+
path,
|
|
3121
|
+
state.resolved
|
|
3122
|
+
);
|
|
3123
|
+
state.pagination = pagination;
|
|
3084
3124
|
return {
|
|
3085
3125
|
state,
|
|
3086
3126
|
result: {
|
|
@@ -3090,7 +3130,7 @@ async function askLeaf(state, path, leaf, opts = {}) {
|
|
|
3090
3130
|
}
|
|
3091
3131
|
};
|
|
3092
3132
|
} catch (error) {
|
|
3093
|
-
state.
|
|
3133
|
+
state.pagination = failedPagination(void 0, firstPagePosition());
|
|
3094
3134
|
return failedResult(state, leaf.name, error);
|
|
3095
3135
|
}
|
|
3096
3136
|
}
|
|
@@ -3100,13 +3140,13 @@ async function advance(ctx, state) {
|
|
|
3100
3140
|
if (!target) {
|
|
3101
3141
|
delete state.current;
|
|
3102
3142
|
delete state.gate;
|
|
3103
|
-
delete state.
|
|
3143
|
+
delete state.pagination;
|
|
3104
3144
|
return { state, result: finalize(ctx, state.resolved) };
|
|
3105
3145
|
}
|
|
3106
3146
|
if (target.kind === "array") {
|
|
3107
3147
|
state.current = target.path;
|
|
3108
3148
|
state.gate = "array";
|
|
3109
|
-
delete state.
|
|
3149
|
+
delete state.pagination;
|
|
3110
3150
|
return {
|
|
3111
3151
|
state,
|
|
3112
3152
|
result: { status: "ask", question: collectionQuestion(target) }
|
|
@@ -3115,7 +3155,7 @@ async function advance(ctx, state) {
|
|
|
3115
3155
|
if (target.kind === "object") {
|
|
3116
3156
|
state.current = target.path;
|
|
3117
3157
|
state.gate = "entry";
|
|
3118
|
-
delete state.
|
|
3158
|
+
delete state.pagination;
|
|
3119
3159
|
return {
|
|
3120
3160
|
state,
|
|
3121
3161
|
result: { status: "ask", question: objectGateQuestion(target.path) }
|
|
@@ -3124,12 +3164,12 @@ async function advance(ctx, state) {
|
|
|
3124
3164
|
if (target.kind === "optionals") {
|
|
3125
3165
|
state.current = target.path;
|
|
3126
3166
|
state.gate = "optionals";
|
|
3127
|
-
delete state.
|
|
3167
|
+
delete state.pagination;
|
|
3128
3168
|
return {
|
|
3129
3169
|
state,
|
|
3130
3170
|
result: {
|
|
3131
3171
|
status: "ask",
|
|
3132
|
-
question: optionalsGateQuestion(target.pending)
|
|
3172
|
+
question: optionalsGateQuestion(target.path, target.pending)
|
|
3133
3173
|
}
|
|
3134
3174
|
};
|
|
3135
3175
|
}
|
|
@@ -3180,13 +3220,13 @@ async function step(ctx, prior, action) {
|
|
|
3180
3220
|
if (action.type === "cancel") {
|
|
3181
3221
|
delete state.current;
|
|
3182
3222
|
delete state.gate;
|
|
3183
|
-
delete state.
|
|
3223
|
+
delete state.pagination;
|
|
3184
3224
|
return { state, result: { status: "cancelled" } };
|
|
3185
3225
|
}
|
|
3186
3226
|
const path = state.current;
|
|
3187
3227
|
if (!path) throw new Error("step called with no outstanding question");
|
|
3188
3228
|
const leaf = await leafAt(ctx, path, state.resolved);
|
|
3189
|
-
if (leaf && (action.type === "search" || action.type === "
|
|
3229
|
+
if (leaf && (action.type === "search" || action.type === "next_page" || action.type === "previous_page" || action.type === "retry")) {
|
|
3190
3230
|
return refine(ctx, state, leaf, path, action);
|
|
3191
3231
|
}
|
|
3192
3232
|
if (action.type === "add" || action.type === "done") {
|
|
@@ -3198,7 +3238,7 @@ async function step(ctx, prior, action) {
|
|
|
3198
3238
|
}
|
|
3199
3239
|
delete state.current;
|
|
3200
3240
|
delete state.gate;
|
|
3201
|
-
delete state.
|
|
3241
|
+
delete state.pagination;
|
|
3202
3242
|
if (action.type === "done") {
|
|
3203
3243
|
settle(state, path);
|
|
3204
3244
|
return advance(ctx, state);
|
|
@@ -3227,23 +3267,44 @@ async function step(ctx, prior, action) {
|
|
|
3227
3267
|
case "choose":
|
|
3228
3268
|
case "custom": {
|
|
3229
3269
|
if (leaf) {
|
|
3230
|
-
|
|
3270
|
+
let error;
|
|
3271
|
+
try {
|
|
3272
|
+
error = await validationError(leaf, action.value, state);
|
|
3273
|
+
} catch (thrown) {
|
|
3274
|
+
return failedResult(state, leaf.name, thrown);
|
|
3275
|
+
}
|
|
3231
3276
|
if (error) {
|
|
3232
|
-
if (state.
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3277
|
+
if (state.pagination && leaf.resolver?.type === "dynamic") {
|
|
3278
|
+
try {
|
|
3279
|
+
const context = await resolveContext(leaf, state.resolved);
|
|
3280
|
+
const page = await fetchListing(
|
|
3281
|
+
leaf,
|
|
3282
|
+
state.resolved,
|
|
3283
|
+
state.pagination.position,
|
|
3284
|
+
context
|
|
3285
|
+
);
|
|
3286
|
+
state.pagination = toPagination(page);
|
|
3287
|
+
return {
|
|
3288
|
+
state,
|
|
3289
|
+
result: {
|
|
3290
|
+
status: "ask",
|
|
3291
|
+
question: selectQuestion(
|
|
3292
|
+
leaf,
|
|
3293
|
+
path,
|
|
3294
|
+
state.resolved,
|
|
3295
|
+
page,
|
|
3296
|
+
context
|
|
3297
|
+
),
|
|
3298
|
+
error
|
|
3299
|
+
}
|
|
3300
|
+
};
|
|
3301
|
+
} catch (fetchError) {
|
|
3302
|
+
state.pagination = failedPagination(
|
|
3303
|
+
state.pagination,
|
|
3304
|
+
state.pagination.position
|
|
3305
|
+
);
|
|
3306
|
+
return failedResult(state, leaf.name, fetchError);
|
|
3307
|
+
}
|
|
3247
3308
|
}
|
|
3248
3309
|
return askLeaf(state, path, leaf, { error });
|
|
3249
3310
|
}
|
|
@@ -3262,15 +3323,11 @@ async function step(ctx, prior, action) {
|
|
|
3262
3323
|
throw new Error(`action "${action.type}" is not supported here`);
|
|
3263
3324
|
}
|
|
3264
3325
|
delete state.current;
|
|
3265
|
-
delete state.
|
|
3326
|
+
delete state.pagination;
|
|
3266
3327
|
return advance(ctx, state);
|
|
3267
3328
|
}
|
|
3268
3329
|
async function refine(ctx, state, leaf, path, action) {
|
|
3269
|
-
const
|
|
3270
|
-
search: state.listing?.search,
|
|
3271
|
-
cursor: state.listing?.cursor,
|
|
3272
|
-
priorItems: state.listing?.items ?? []
|
|
3273
|
-
};
|
|
3330
|
+
const position = positionAfter(state.pagination, action);
|
|
3274
3331
|
try {
|
|
3275
3332
|
if (action.type === "search") {
|
|
3276
3333
|
const exact = leaf.resolver?.type === "dynamic" ? await leaf.resolver.tryResolveFromSearch?.({
|
|
@@ -3280,32 +3337,62 @@ async function refine(ctx, state, leaf, path, action) {
|
|
|
3280
3337
|
if (exact) {
|
|
3281
3338
|
setAtPath(state.resolved, path, coerce(leaf, exact.resolvedValue));
|
|
3282
3339
|
delete state.current;
|
|
3283
|
-
delete state.
|
|
3340
|
+
delete state.pagination;
|
|
3284
3341
|
return advance(ctx, state);
|
|
3285
3342
|
}
|
|
3286
3343
|
}
|
|
3287
3344
|
const context = await resolveContext(leaf, state.resolved);
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
context
|
|
3291
|
-
});
|
|
3345
|
+
const page = await fetchListing(leaf, state.resolved, position, context);
|
|
3346
|
+
state.pagination = toPagination(page);
|
|
3292
3347
|
return {
|
|
3293
3348
|
state,
|
|
3294
3349
|
result: {
|
|
3295
3350
|
status: "ask",
|
|
3296
|
-
question: selectQuestion(leaf, state.resolved,
|
|
3351
|
+
question: selectQuestion(leaf, path, state.resolved, page, context)
|
|
3297
3352
|
}
|
|
3298
3353
|
};
|
|
3299
3354
|
} catch (error) {
|
|
3300
|
-
state.
|
|
3301
|
-
items: attempt.priorItems,
|
|
3302
|
-
search: attempt.search,
|
|
3303
|
-
cursor: attempt.cursor,
|
|
3304
|
-
exhausted: false
|
|
3305
|
-
};
|
|
3355
|
+
state.pagination = failedPagination(state.pagination, position);
|
|
3306
3356
|
return failedResult(state, leaf.name, error);
|
|
3307
3357
|
}
|
|
3308
3358
|
}
|
|
3359
|
+
function failedPagination(pagination, retryPosition) {
|
|
3360
|
+
return {
|
|
3361
|
+
position: pagination?.position ?? firstPagePosition(),
|
|
3362
|
+
...pagination?.nextCursor !== void 0 ? { nextCursor: pagination.nextCursor } : {},
|
|
3363
|
+
retryPosition
|
|
3364
|
+
};
|
|
3365
|
+
}
|
|
3366
|
+
function positionAfter(pagination, action) {
|
|
3367
|
+
const current = pagination?.position ?? firstPagePosition();
|
|
3368
|
+
switch (action.type) {
|
|
3369
|
+
case "search":
|
|
3370
|
+
return firstPagePosition({
|
|
3371
|
+
search: action.term,
|
|
3372
|
+
generation: current.generation + 1
|
|
3373
|
+
});
|
|
3374
|
+
case "next_page": {
|
|
3375
|
+
if (pagination?.nextCursor == null) return current;
|
|
3376
|
+
return {
|
|
3377
|
+
...current.search !== void 0 ? { search: current.search } : {},
|
|
3378
|
+
pageCursor: pagination.nextCursor,
|
|
3379
|
+
previousCursors: [...current.previousCursors, current.pageCursor],
|
|
3380
|
+
generation: current.generation
|
|
3381
|
+
};
|
|
3382
|
+
}
|
|
3383
|
+
case "previous_page": {
|
|
3384
|
+
if (current.previousCursors.length === 0) return current;
|
|
3385
|
+
return {
|
|
3386
|
+
...current.search !== void 0 ? { search: current.search } : {},
|
|
3387
|
+
pageCursor: current.previousCursors[current.previousCursors.length - 1],
|
|
3388
|
+
previousCursors: current.previousCursors.slice(0, -1),
|
|
3389
|
+
generation: current.generation
|
|
3390
|
+
};
|
|
3391
|
+
}
|
|
3392
|
+
case "retry":
|
|
3393
|
+
return pagination?.retryPosition ?? current;
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3309
3396
|
function toJsonSchema(schema) {
|
|
3310
3397
|
if (!schema) return void 0;
|
|
3311
3398
|
try {
|
|
@@ -5196,7 +5283,7 @@ function parseDeprecationDate(value) {
|
|
|
5196
5283
|
}
|
|
5197
5284
|
|
|
5198
5285
|
// src/sdk-version.ts
|
|
5199
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.84.
|
|
5286
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.84.3" : void 0) || "unknown";
|
|
5200
5287
|
|
|
5201
5288
|
// src/utils/open-url.ts
|
|
5202
5289
|
var nodePrefix = "node:";
|
|
@@ -8091,8 +8178,9 @@ var appKeyResolver = defineResolver({
|
|
|
8091
8178
|
},
|
|
8092
8179
|
listItems: ({
|
|
8093
8180
|
imports,
|
|
8094
|
-
search
|
|
8095
|
-
|
|
8181
|
+
search,
|
|
8182
|
+
cursor
|
|
8183
|
+
}) => imports.listApps({ search, cursor }),
|
|
8096
8184
|
prompt: ({ items }) => ({
|
|
8097
8185
|
type: "list",
|
|
8098
8186
|
message: "Select app:",
|
|
@@ -8113,9 +8201,11 @@ var actionTypeResolver = defineResolver({
|
|
|
8113
8201
|
imports,
|
|
8114
8202
|
input
|
|
8115
8203
|
}) => {
|
|
8116
|
-
const
|
|
8117
|
-
const
|
|
8118
|
-
|
|
8204
|
+
const types = /* @__PURE__ */ new Set();
|
|
8205
|
+
for await (const action of imports.listActions({ app: input.app }).items()) {
|
|
8206
|
+
types.add(action.action_type);
|
|
8207
|
+
}
|
|
8208
|
+
return { data: [...types].map((type) => ({ key: type, name: type })) };
|
|
8119
8209
|
},
|
|
8120
8210
|
prompt: ({ items }) => ({
|
|
8121
8211
|
type: "list",
|
|
@@ -8131,13 +8221,15 @@ var actionKeyResolver = defineResolver({
|
|
|
8131
8221
|
requireParameters: ["app", "actionType"],
|
|
8132
8222
|
listItems: async ({
|
|
8133
8223
|
imports,
|
|
8134
|
-
input
|
|
8224
|
+
input,
|
|
8225
|
+
cursor
|
|
8135
8226
|
}) => {
|
|
8136
|
-
const
|
|
8227
|
+
const page = await imports.listActions({ app: input.app, cursor });
|
|
8137
8228
|
return {
|
|
8138
|
-
data: data.filter(
|
|
8229
|
+
data: page.data.filter(
|
|
8139
8230
|
(action) => action.action_type === input.actionType && !action.is_hidden
|
|
8140
|
-
)
|
|
8231
|
+
),
|
|
8232
|
+
nextCursor: page.nextCursor
|
|
8141
8233
|
};
|
|
8142
8234
|
},
|
|
8143
8235
|
prompt: ({ items }) => ({
|
|
@@ -8254,9 +8346,10 @@ var connectionIdResolver = defineResolver({
|
|
|
8254
8346
|
}
|
|
8255
8347
|
return null;
|
|
8256
8348
|
},
|
|
8257
|
-
listItems: ({ imports, input, context }) => imports.listConnections({
|
|
8349
|
+
listItems: ({ imports, input, context, cursor }) => imports.listConnections({
|
|
8258
8350
|
app: input.app,
|
|
8259
|
-
includeShared: context?.canIncludeShared || void 0
|
|
8351
|
+
includeShared: context?.canIncludeShared || void 0,
|
|
8352
|
+
cursor
|
|
8260
8353
|
}),
|
|
8261
8354
|
prompt: ({ items, input, context }) => buildConnectionPrompt(
|
|
8262
8355
|
items,
|
|
@@ -8272,9 +8365,10 @@ var connectionIdGenericResolver = defineResolver({
|
|
|
8272
8365
|
);
|
|
8273
8366
|
return { canIncludeShared: canIncludeShared ?? false };
|
|
8274
8367
|
},
|
|
8275
|
-
listItems: ({ imports, input, context }) => imports.listConnections({
|
|
8368
|
+
listItems: ({ imports, input, context, cursor }) => imports.listConnections({
|
|
8276
8369
|
app: input.app,
|
|
8277
|
-
includeShared: context?.canIncludeShared || void 0
|
|
8370
|
+
includeShared: context?.canIncludeShared || void 0,
|
|
8371
|
+
cursor
|
|
8278
8372
|
}),
|
|
8279
8373
|
prompt: ({ items, input, context }) => buildConnectionPrompt(
|
|
8280
8374
|
items,
|
|
@@ -8302,12 +8396,13 @@ var listActionInputFieldChoicesRef = declareMethod({ id: "listActionInputFieldCh
|
|
|
8302
8396
|
var choiceResolver = defineResolver({
|
|
8303
8397
|
imports: [listActionInputFieldChoicesRef],
|
|
8304
8398
|
requireParameters: ["app", "action", "actionType"],
|
|
8305
|
-
listItems: ({ imports, input }) => imports.listActionInputFieldChoices({
|
|
8399
|
+
listItems: ({ imports, input, cursor }) => imports.listActionInputFieldChoices({
|
|
8306
8400
|
app: input.app,
|
|
8307
8401
|
action: input.action,
|
|
8308
8402
|
actionType: input.actionType,
|
|
8309
8403
|
connection: input.connection,
|
|
8310
|
-
inputField: input.inputField
|
|
8404
|
+
inputField: input.inputField,
|
|
8405
|
+
cursor
|
|
8311
8406
|
}),
|
|
8312
8407
|
prompt: ({ items }) => ({
|
|
8313
8408
|
type: "list",
|
|
@@ -8466,7 +8561,7 @@ var clientCredentialsNameResolver = defineResolver({
|
|
|
8466
8561
|
var listClientCredentialsRef = declareMethod({ id: "listClientCredentials" });
|
|
8467
8562
|
var clientIdResolver = defineResolver({
|
|
8468
8563
|
imports: [listClientCredentialsRef],
|
|
8469
|
-
listItems: ({ imports }) => imports.listClientCredentials({}),
|
|
8564
|
+
listItems: ({ imports, cursor }) => imports.listClientCredentials({ cursor }),
|
|
8470
8565
|
prompt: ({ items }) => ({
|
|
8471
8566
|
type: "list",
|
|
8472
8567
|
message: "Select client credentials to delete:",
|
|
@@ -8478,9 +8573,9 @@ var clientIdResolver = defineResolver({
|
|
|
8478
8573
|
});
|
|
8479
8574
|
|
|
8480
8575
|
// src/resolvers/tableId.ts
|
|
8481
|
-
var
|
|
8576
|
+
var listTablesInternalRef = declareMethod({ id: "listTablesInternal" });
|
|
8482
8577
|
var tableIdResolver = defineResolver({
|
|
8483
|
-
imports: [
|
|
8578
|
+
imports: [listTablesInternalRef, capabilitiesPluginRef],
|
|
8484
8579
|
getContext: async ({ imports }) => {
|
|
8485
8580
|
const includeShared = await imports.capabilities.hasCapability?.(
|
|
8486
8581
|
"canIncludeSharedTables"
|
|
@@ -8488,27 +8583,36 @@ var tableIdResolver = defineResolver({
|
|
|
8488
8583
|
return { includeShared: includeShared ?? false };
|
|
8489
8584
|
},
|
|
8490
8585
|
// Unlike connections, the tables API does not return personal tables first,
|
|
8491
|
-
// so we
|
|
8492
|
-
|
|
8586
|
+
// so we concatenate personal-only and shared-only slices to hoist own
|
|
8587
|
+
// tables above shared. The slices are disjoint by construction, so the
|
|
8588
|
+
// concatenation paginates with stateless cursors and needs no dedupe.
|
|
8589
|
+
listItems: ({ imports, context, cursor }) => {
|
|
8493
8590
|
const includeShared = context?.includeShared;
|
|
8494
8591
|
if (includeShared) {
|
|
8495
8592
|
return concatPaginated({
|
|
8496
8593
|
sources: [
|
|
8497
|
-
() => imports.
|
|
8498
|
-
() => imports.
|
|
8594
|
+
({ cursor: sourceCursor }) => imports.listTablesInternal({ cursor: sourceCursor }),
|
|
8595
|
+
({ cursor: sourceCursor }) => imports.listTablesInternal({
|
|
8596
|
+
includeShared: true,
|
|
8597
|
+
includePersonal: false,
|
|
8598
|
+
cursor: sourceCursor
|
|
8599
|
+
})
|
|
8499
8600
|
],
|
|
8500
|
-
|
|
8601
|
+
cursor
|
|
8501
8602
|
});
|
|
8502
8603
|
}
|
|
8503
|
-
return imports.
|
|
8604
|
+
return imports.listTablesInternal({ cursor });
|
|
8504
8605
|
},
|
|
8505
|
-
prompt: ({ items }) => ({
|
|
8606
|
+
prompt: ({ items, context }) => ({
|
|
8506
8607
|
type: "list",
|
|
8507
8608
|
message: "Select a table:",
|
|
8508
8609
|
choices: items.map((table) => ({
|
|
8509
8610
|
label: table.name,
|
|
8510
8611
|
value: table.id
|
|
8511
|
-
}))
|
|
8612
|
+
})),
|
|
8613
|
+
// The capability hint the legacy picker showed as a fake disabled row:
|
|
8614
|
+
// without it, a gated account just sees fewer tables with no explanation.
|
|
8615
|
+
...context?.includeShared ? {} : { notes: ["Shared tables are hidden for this account."] }
|
|
8512
8616
|
})
|
|
8513
8617
|
});
|
|
8514
8618
|
|
|
@@ -8516,7 +8620,7 @@ var tableIdResolver = defineResolver({
|
|
|
8516
8620
|
var listTriggerInboxesRef = declareMethod({ id: "listTriggerInboxes" });
|
|
8517
8621
|
var triggerInboxResolver = defineResolver({
|
|
8518
8622
|
imports: [listTriggerInboxesRef],
|
|
8519
|
-
listItems: ({ imports }) => imports.listTriggerInboxes({}),
|
|
8623
|
+
listItems: ({ imports, cursor }) => imports.listTriggerInboxes({ cursor }),
|
|
8520
8624
|
prompt: ({ items }) => ({
|
|
8521
8625
|
type: "list",
|
|
8522
8626
|
message: "Select a trigger inbox:",
|
|
@@ -8534,7 +8638,7 @@ var triggerInboxResolver = defineResolver({
|
|
|
8534
8638
|
var listWorkflowsRef = declareMethod({ id: "listWorkflows" });
|
|
8535
8639
|
var workflowIdResolver = defineResolver({
|
|
8536
8640
|
imports: [listWorkflowsRef],
|
|
8537
|
-
listItems: ({ imports }) => imports.listWorkflows({}),
|
|
8641
|
+
listItems: ({ imports, cursor }) => imports.listWorkflows({ cursor }),
|
|
8538
8642
|
prompt: ({ items }) => ({
|
|
8539
8643
|
type: "list",
|
|
8540
8644
|
message: "Select a workflow:",
|
|
@@ -8550,7 +8654,7 @@ var workflowIdResolver = defineResolver({
|
|
|
8550
8654
|
var listDurableRunsRef = declareMethod({ id: "listDurableRuns" });
|
|
8551
8655
|
var durableRunIdResolver = defineResolver({
|
|
8552
8656
|
imports: [listDurableRunsRef],
|
|
8553
|
-
listItems: ({ imports }) => imports.listDurableRuns({}),
|
|
8657
|
+
listItems: ({ imports, cursor }) => imports.listDurableRuns({ cursor }),
|
|
8554
8658
|
prompt: ({ items }) => ({
|
|
8555
8659
|
type: "list",
|
|
8556
8660
|
message: "Select a run:",
|
|
@@ -8567,7 +8671,14 @@ var listWorkflowVersionsRef = declareMethod({ id: "listWorkflowVersions" });
|
|
|
8567
8671
|
var workflowVersionIdResolver = defineResolver({
|
|
8568
8672
|
imports: [listWorkflowVersionsRef],
|
|
8569
8673
|
requireParameters: ["workflow"],
|
|
8570
|
-
listItems: ({
|
|
8674
|
+
listItems: ({
|
|
8675
|
+
imports,
|
|
8676
|
+
input,
|
|
8677
|
+
cursor
|
|
8678
|
+
}) => imports.listWorkflowVersions({
|
|
8679
|
+
workflow: input.workflow,
|
|
8680
|
+
cursor
|
|
8681
|
+
}),
|
|
8571
8682
|
prompt: ({ items }) => ({
|
|
8572
8683
|
type: "list",
|
|
8573
8684
|
message: "Select a workflow version:",
|
|
@@ -8583,7 +8694,11 @@ var listWorkflowRunsRef = declareMethod({ id: "listWorkflowRuns" });
|
|
|
8583
8694
|
var workflowRunIdResolver = defineResolver({
|
|
8584
8695
|
imports: [listWorkflowRunsRef],
|
|
8585
8696
|
requireParameters: ["workflow"],
|
|
8586
|
-
listItems: ({
|
|
8697
|
+
listItems: ({
|
|
8698
|
+
imports,
|
|
8699
|
+
input,
|
|
8700
|
+
cursor
|
|
8701
|
+
}) => imports.listWorkflowRuns({ workflow: input.workflow, cursor }),
|
|
8587
8702
|
prompt: ({ items }) => ({
|
|
8588
8703
|
type: "list",
|
|
8589
8704
|
message: "Select a workflow run:",
|
|
@@ -8601,8 +8716,9 @@ var triggerMessagesResolver = defineResolver({
|
|
|
8601
8716
|
requireParameters: ["inbox"],
|
|
8602
8717
|
listItems: ({
|
|
8603
8718
|
imports,
|
|
8604
|
-
input
|
|
8605
|
-
|
|
8719
|
+
input,
|
|
8720
|
+
cursor
|
|
8721
|
+
}) => imports.listTriggerInboxMessages({ inbox: input.inbox, cursor }),
|
|
8606
8722
|
prompt: ({ items }) => ({
|
|
8607
8723
|
type: "checkbox",
|
|
8608
8724
|
message: "Select messages:",
|
|
@@ -8875,9 +8991,10 @@ function recordChoices(records) {
|
|
|
8875
8991
|
var tableRecordIdResolver = defineResolver({
|
|
8876
8992
|
imports: [listTableRecordsRef],
|
|
8877
8993
|
requireParameters: ["table"],
|
|
8878
|
-
listItems: ({ imports, input }) => imports.listTableRecords({
|
|
8994
|
+
listItems: ({ imports, input, cursor }) => imports.listTableRecords({
|
|
8879
8995
|
table: input.table,
|
|
8880
|
-
keyMode: "names"
|
|
8996
|
+
keyMode: "names",
|
|
8997
|
+
cursor
|
|
8881
8998
|
}),
|
|
8882
8999
|
prompt: ({ items }) => ({
|
|
8883
9000
|
type: "list",
|
|
@@ -8888,16 +9005,17 @@ var tableRecordIdResolver = defineResolver({
|
|
|
8888
9005
|
var tableRecordIdsResolver = defineResolver({
|
|
8889
9006
|
imports: [listTableRecordsRef],
|
|
8890
9007
|
requireParameters: ["table"],
|
|
8891
|
-
listItems: ({ imports, input }) => imports.listTableRecords({
|
|
9008
|
+
listItems: ({ imports, input, cursor }) => imports.listTableRecords({
|
|
8892
9009
|
table: input.table,
|
|
8893
|
-
keyMode: "names"
|
|
9010
|
+
keyMode: "names",
|
|
9011
|
+
cursor
|
|
8894
9012
|
}),
|
|
8895
9013
|
prompt: ({ items }) => ({
|
|
8896
9014
|
type: "checkbox",
|
|
8897
9015
|
message: "Select records to delete:",
|
|
8898
|
-
choices: recordChoices(items)
|
|
8899
|
-
|
|
8900
|
-
})
|
|
9016
|
+
choices: recordChoices(items)
|
|
9017
|
+
}),
|
|
9018
|
+
validate: ({ value }) => Array.isArray(value) && value.length > 0 ? true : "Select at least one record"
|
|
8901
9019
|
});
|
|
8902
9020
|
|
|
8903
9021
|
// src/resolvers/tableFieldIds.ts
|
|
@@ -8905,6 +9023,8 @@ var listTableFieldsRef = declareMethod({ id: "listTableFields" });
|
|
|
8905
9023
|
var tableFieldIdsResolver = defineResolver({
|
|
8906
9024
|
imports: [listTableFieldsRef],
|
|
8907
9025
|
requireParameters: ["table"],
|
|
9026
|
+
// No cursor forwarding: the fields API is unpaginated (no cursor on the
|
|
9027
|
+
// response), so the listing is always exhausted after one page.
|
|
8908
9028
|
listItems: ({ imports, input }) => imports.listTableFields({ table: input.table }),
|
|
8909
9029
|
prompt: ({ items }) => ({
|
|
8910
9030
|
type: "checkbox",
|
|
@@ -8913,9 +9033,9 @@ var tableFieldIdsResolver = defineResolver({
|
|
|
8913
9033
|
label: field.name,
|
|
8914
9034
|
hint: [field.id, field.type],
|
|
8915
9035
|
value: field.id
|
|
8916
|
-
}))
|
|
8917
|
-
|
|
8918
|
-
})
|
|
9036
|
+
}))
|
|
9037
|
+
}),
|
|
9038
|
+
validate: ({ value }) => Array.isArray(value) && value.length > 0 ? true : "Select at least one field"
|
|
8919
9039
|
});
|
|
8920
9040
|
|
|
8921
9041
|
// src/resolvers/tableName.ts
|
|
@@ -13090,27 +13210,31 @@ var ListTablesOptionsSchema = zod.z.object({
|
|
|
13090
13210
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
13091
13211
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
13092
13212
|
}).describe("List tables available to the authenticated user");
|
|
13213
|
+
var ListTablesInternalOptionsSchema = ListTablesOptionsSchema.extend({
|
|
13214
|
+
includePersonal: zod.z.boolean().optional().describe(
|
|
13215
|
+
"Include your own tables (default true). Set false with includeShared to list only tables shared with you."
|
|
13216
|
+
)
|
|
13217
|
+
});
|
|
13093
13218
|
|
|
13094
|
-
// src/plugins/tables/
|
|
13095
|
-
var
|
|
13096
|
-
|
|
13097
|
-
// src/plugins/tables/listTables/index.ts
|
|
13098
|
-
var listTablesPlugin = defineMethod({
|
|
13099
|
-
name: "listTables",
|
|
13219
|
+
// src/plugins/tables/listTables/internal.ts
|
|
13220
|
+
var listTablesInternalPlugin = defineMethod({
|
|
13221
|
+
name: "listTablesInternal",
|
|
13100
13222
|
imports: [apiPluginRef, capabilitiesPluginRef],
|
|
13101
|
-
|
|
13102
|
-
itemType: "Table",
|
|
13103
|
-
inputSchema: ListTablesOptionsSchema,
|
|
13104
|
-
outputSchema: TableItemSchema,
|
|
13223
|
+
inputSchema: ListTablesInternalOptionsSchema,
|
|
13105
13224
|
output: {
|
|
13106
13225
|
type: "list",
|
|
13107
13226
|
adaptPage: adaptZapierPage,
|
|
13108
13227
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
13109
13228
|
},
|
|
13110
13229
|
run: async ({ imports, input }) => {
|
|
13111
|
-
|
|
13230
|
+
const includePersonal = input.includePersonal ?? true;
|
|
13231
|
+
const includeShared = input.includeShared ?? false;
|
|
13232
|
+
if (includeShared) {
|
|
13112
13233
|
await imports.capabilities.checkCapability("canIncludeSharedTables");
|
|
13113
13234
|
}
|
|
13235
|
+
if (!includePersonal && !includeShared) {
|
|
13236
|
+
return { data: [] };
|
|
13237
|
+
}
|
|
13114
13238
|
const api = imports.api;
|
|
13115
13239
|
const searchParams = {};
|
|
13116
13240
|
if (input.pageSize !== void 0) {
|
|
@@ -13126,23 +13250,18 @@ var listTablesPlugin = defineMethod({
|
|
|
13126
13250
|
if (input.search) {
|
|
13127
13251
|
searchParams.q = input.search;
|
|
13128
13252
|
}
|
|
13129
|
-
if (input.owner && input.owner !== "me" && !
|
|
13253
|
+
if (input.owner && input.owner !== "me" && !includeShared) {
|
|
13130
13254
|
throw new ZapierValidationError(
|
|
13131
13255
|
'The "owner" option requires "includeShared" to be true. Without includeShared, only your own tables are returned.'
|
|
13132
13256
|
);
|
|
13133
13257
|
}
|
|
13134
|
-
const owner =
|
|
13258
|
+
const owner = includeShared ? input.owner : "me";
|
|
13259
|
+
const needsProfileId = owner === "me" || !includePersonal && includeShared;
|
|
13260
|
+
const profileId = needsProfileId ? (await api.get("/zapier/api/v4/profile/", {
|
|
13261
|
+
authRequired: true
|
|
13262
|
+
})).id : void 0;
|
|
13135
13263
|
if (owner) {
|
|
13136
|
-
|
|
13137
|
-
const profile = await api.get("/zapier/api/v4/profile/", {
|
|
13138
|
-
authRequired: true
|
|
13139
|
-
});
|
|
13140
|
-
searchParams.owner_customuser_id = String(
|
|
13141
|
-
profile.id
|
|
13142
|
-
);
|
|
13143
|
-
} else {
|
|
13144
|
-
searchParams.owner_customuser_id = owner;
|
|
13145
|
-
}
|
|
13264
|
+
searchParams.owner_customuser_id = owner === "me" ? String(profileId) : owner;
|
|
13146
13265
|
}
|
|
13147
13266
|
if (input.cursor) {
|
|
13148
13267
|
searchParams.offset = input.cursor;
|
|
@@ -13152,12 +13271,35 @@ var listTablesPlugin = defineMethod({
|
|
|
13152
13271
|
authRequired: true
|
|
13153
13272
|
});
|
|
13154
13273
|
const response = ListTablesApiResponseSchema.parse(rawResponse);
|
|
13274
|
+
const apiItems = includePersonal ? response.data : response.data.filter(
|
|
13275
|
+
(item) => item.owner_zapier_customuser_id !== profileId
|
|
13276
|
+
);
|
|
13155
13277
|
return {
|
|
13156
|
-
data:
|
|
13278
|
+
data: apiItems.map(transformTableItem),
|
|
13157
13279
|
links: response.links
|
|
13158
13280
|
};
|
|
13159
13281
|
}
|
|
13160
13282
|
});
|
|
13283
|
+
|
|
13284
|
+
// src/plugins/tables/shared.ts
|
|
13285
|
+
var tableCategories = ["table"];
|
|
13286
|
+
|
|
13287
|
+
// src/plugins/tables/listTables/index.ts
|
|
13288
|
+
var listTablesPlugin = defineMethod({
|
|
13289
|
+
name: "listTables",
|
|
13290
|
+
imports: [listTablesInternalPlugin],
|
|
13291
|
+
categories: tableCategories,
|
|
13292
|
+
itemType: "Table",
|
|
13293
|
+
inputSchema: ListTablesOptionsSchema,
|
|
13294
|
+
outputSchema: TableItemSchema,
|
|
13295
|
+
output: "list",
|
|
13296
|
+
run: async ({ imports, input }) => {
|
|
13297
|
+
return await imports.listTablesInternal({
|
|
13298
|
+
...input,
|
|
13299
|
+
includePersonal: void 0
|
|
13300
|
+
});
|
|
13301
|
+
}
|
|
13302
|
+
});
|
|
13161
13303
|
var GetTableApiResponseSchema = zod.z.object({
|
|
13162
13304
|
data: TableApiItemSchema
|
|
13163
13305
|
});
|