@zapier/zapier-sdk 0.84.2 → 0.84.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +125 -121
- package/dist/experimental.cjs +328 -180
- package/dist/experimental.d.mts +54 -4
- package/dist/experimental.d.ts +54 -4
- package/dist/experimental.mjs +328 -180
- package/dist/{index-DxgpC5hV.d.mts → index-ChZuXQDn.d.mts} +205 -28
- package/dist/{index-DxgpC5hV.d.ts → index-ChZuXQDn.d.ts} +205 -28
- package/dist/index.cjs +328 -180
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +328 -180
- package/package.json +3 -3
package/dist/index.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 {
|
|
@@ -5342,7 +5429,7 @@ function parseDeprecationDate(value) {
|
|
|
5342
5429
|
}
|
|
5343
5430
|
|
|
5344
5431
|
// src/sdk-version.ts
|
|
5345
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.84.
|
|
5432
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.84.4" : void 0) || "unknown";
|
|
5346
5433
|
|
|
5347
5434
|
// src/utils/open-url.ts
|
|
5348
5435
|
var nodePrefix = "node:";
|
|
@@ -6919,6 +7006,7 @@ function transformConnectionItem(item) {
|
|
|
6919
7006
|
is_private: item.is_private,
|
|
6920
7007
|
shared_with_all: item.shared_with_all,
|
|
6921
7008
|
title: item.title,
|
|
7009
|
+
slug: item.slug,
|
|
6922
7010
|
lastchanged: item.lastchanged,
|
|
6923
7011
|
is_stale: item.is_stale,
|
|
6924
7012
|
is_shared: item.is_shared,
|
|
@@ -8079,8 +8167,9 @@ var appKeyResolver = defineResolver({
|
|
|
8079
8167
|
},
|
|
8080
8168
|
listItems: ({
|
|
8081
8169
|
imports,
|
|
8082
|
-
search
|
|
8083
|
-
|
|
8170
|
+
search,
|
|
8171
|
+
cursor
|
|
8172
|
+
}) => imports.listApps({ search, cursor }),
|
|
8084
8173
|
prompt: ({ items }) => ({
|
|
8085
8174
|
type: "list",
|
|
8086
8175
|
message: "Select app:",
|
|
@@ -8101,9 +8190,11 @@ var actionTypeResolver = defineResolver({
|
|
|
8101
8190
|
imports,
|
|
8102
8191
|
input
|
|
8103
8192
|
}) => {
|
|
8104
|
-
const
|
|
8105
|
-
const
|
|
8106
|
-
|
|
8193
|
+
const types = /* @__PURE__ */ new Set();
|
|
8194
|
+
for await (const action of imports.listActions({ app: input.app }).items()) {
|
|
8195
|
+
types.add(action.action_type);
|
|
8196
|
+
}
|
|
8197
|
+
return { data: [...types].map((type) => ({ key: type, name: type })) };
|
|
8107
8198
|
},
|
|
8108
8199
|
prompt: ({ items }) => ({
|
|
8109
8200
|
type: "list",
|
|
@@ -8119,13 +8210,15 @@ var actionKeyResolver = defineResolver({
|
|
|
8119
8210
|
requireParameters: ["app", "actionType"],
|
|
8120
8211
|
listItems: async ({
|
|
8121
8212
|
imports,
|
|
8122
|
-
input
|
|
8213
|
+
input,
|
|
8214
|
+
cursor
|
|
8123
8215
|
}) => {
|
|
8124
|
-
const
|
|
8216
|
+
const page = await imports.listActions({ app: input.app, cursor });
|
|
8125
8217
|
return {
|
|
8126
|
-
data: data.filter(
|
|
8218
|
+
data: page.data.filter(
|
|
8127
8219
|
(action) => action.action_type === input.actionType && !action.is_hidden
|
|
8128
|
-
)
|
|
8220
|
+
),
|
|
8221
|
+
nextCursor: page.nextCursor
|
|
8129
8222
|
};
|
|
8130
8223
|
},
|
|
8131
8224
|
prompt: ({ items }) => ({
|
|
@@ -8242,9 +8335,10 @@ var connectionIdResolver = defineResolver({
|
|
|
8242
8335
|
}
|
|
8243
8336
|
return null;
|
|
8244
8337
|
},
|
|
8245
|
-
listItems: ({ imports, input, context }) => imports.listConnections({
|
|
8338
|
+
listItems: ({ imports, input, context, cursor }) => imports.listConnections({
|
|
8246
8339
|
app: input.app,
|
|
8247
|
-
includeShared: context?.canIncludeShared || void 0
|
|
8340
|
+
includeShared: context?.canIncludeShared || void 0,
|
|
8341
|
+
cursor
|
|
8248
8342
|
}),
|
|
8249
8343
|
prompt: ({ items, input, context }) => buildConnectionPrompt(
|
|
8250
8344
|
items,
|
|
@@ -8260,9 +8354,10 @@ var connectionIdGenericResolver = defineResolver({
|
|
|
8260
8354
|
);
|
|
8261
8355
|
return { canIncludeShared: canIncludeShared ?? false };
|
|
8262
8356
|
},
|
|
8263
|
-
listItems: ({ imports, input, context }) => imports.listConnections({
|
|
8357
|
+
listItems: ({ imports, input, context, cursor }) => imports.listConnections({
|
|
8264
8358
|
app: input.app,
|
|
8265
|
-
includeShared: context?.canIncludeShared || void 0
|
|
8359
|
+
includeShared: context?.canIncludeShared || void 0,
|
|
8360
|
+
cursor
|
|
8266
8361
|
}),
|
|
8267
8362
|
prompt: ({ items, input, context }) => buildConnectionPrompt(
|
|
8268
8363
|
items,
|
|
@@ -8290,12 +8385,13 @@ var listActionInputFieldChoicesRef = declareMethod({ id: "listActionInputFieldCh
|
|
|
8290
8385
|
var choiceResolver = defineResolver({
|
|
8291
8386
|
imports: [listActionInputFieldChoicesRef],
|
|
8292
8387
|
requireParameters: ["app", "action", "actionType"],
|
|
8293
|
-
listItems: ({ imports, input }) => imports.listActionInputFieldChoices({
|
|
8388
|
+
listItems: ({ imports, input, cursor }) => imports.listActionInputFieldChoices({
|
|
8294
8389
|
app: input.app,
|
|
8295
8390
|
action: input.action,
|
|
8296
8391
|
actionType: input.actionType,
|
|
8297
8392
|
connection: input.connection,
|
|
8298
|
-
inputField: input.inputField
|
|
8393
|
+
inputField: input.inputField,
|
|
8394
|
+
cursor
|
|
8299
8395
|
}),
|
|
8300
8396
|
prompt: ({ items }) => ({
|
|
8301
8397
|
type: "list",
|
|
@@ -8454,7 +8550,7 @@ var clientCredentialsNameResolver = defineResolver({
|
|
|
8454
8550
|
var listClientCredentialsRef = declareMethod({ id: "listClientCredentials" });
|
|
8455
8551
|
var clientIdResolver = defineResolver({
|
|
8456
8552
|
imports: [listClientCredentialsRef],
|
|
8457
|
-
listItems: ({ imports }) => imports.listClientCredentials({}),
|
|
8553
|
+
listItems: ({ imports, cursor }) => imports.listClientCredentials({ cursor }),
|
|
8458
8554
|
prompt: ({ items }) => ({
|
|
8459
8555
|
type: "list",
|
|
8460
8556
|
message: "Select client credentials to delete:",
|
|
@@ -8466,9 +8562,9 @@ var clientIdResolver = defineResolver({
|
|
|
8466
8562
|
});
|
|
8467
8563
|
|
|
8468
8564
|
// src/resolvers/tableId.ts
|
|
8469
|
-
var
|
|
8565
|
+
var listTablesInternalRef = declareMethod({ id: "listTablesInternal" });
|
|
8470
8566
|
var tableIdResolver = defineResolver({
|
|
8471
|
-
imports: [
|
|
8567
|
+
imports: [listTablesInternalRef, capabilitiesPluginRef],
|
|
8472
8568
|
getContext: async ({ imports }) => {
|
|
8473
8569
|
const includeShared = await imports.capabilities.hasCapability?.(
|
|
8474
8570
|
"canIncludeSharedTables"
|
|
@@ -8476,27 +8572,36 @@ var tableIdResolver = defineResolver({
|
|
|
8476
8572
|
return { includeShared: includeShared ?? false };
|
|
8477
8573
|
},
|
|
8478
8574
|
// Unlike connections, the tables API does not return personal tables first,
|
|
8479
|
-
// so we
|
|
8480
|
-
|
|
8575
|
+
// so we concatenate personal-only and shared-only slices to hoist own
|
|
8576
|
+
// tables above shared. The slices are disjoint by construction, so the
|
|
8577
|
+
// concatenation paginates with stateless cursors and needs no dedupe.
|
|
8578
|
+
listItems: ({ imports, context, cursor }) => {
|
|
8481
8579
|
const includeShared = context?.includeShared;
|
|
8482
8580
|
if (includeShared) {
|
|
8483
8581
|
return concatPaginated({
|
|
8484
8582
|
sources: [
|
|
8485
|
-
() => imports.
|
|
8486
|
-
() => imports.
|
|
8583
|
+
({ cursor: sourceCursor }) => imports.listTablesInternal({ cursor: sourceCursor }),
|
|
8584
|
+
({ cursor: sourceCursor }) => imports.listTablesInternal({
|
|
8585
|
+
includeShared: true,
|
|
8586
|
+
includePersonal: false,
|
|
8587
|
+
cursor: sourceCursor
|
|
8588
|
+
})
|
|
8487
8589
|
],
|
|
8488
|
-
|
|
8590
|
+
cursor
|
|
8489
8591
|
});
|
|
8490
8592
|
}
|
|
8491
|
-
return imports.
|
|
8593
|
+
return imports.listTablesInternal({ cursor });
|
|
8492
8594
|
},
|
|
8493
|
-
prompt: ({ items }) => ({
|
|
8595
|
+
prompt: ({ items, context }) => ({
|
|
8494
8596
|
type: "list",
|
|
8495
8597
|
message: "Select a table:",
|
|
8496
8598
|
choices: items.map((table) => ({
|
|
8497
8599
|
label: table.name,
|
|
8498
8600
|
value: table.id
|
|
8499
|
-
}))
|
|
8601
|
+
})),
|
|
8602
|
+
// The capability hint the legacy picker showed as a fake disabled row:
|
|
8603
|
+
// without it, a gated account just sees fewer tables with no explanation.
|
|
8604
|
+
...context?.includeShared ? {} : { notes: ["Shared tables are hidden for this account."] }
|
|
8500
8605
|
})
|
|
8501
8606
|
});
|
|
8502
8607
|
|
|
@@ -8504,7 +8609,7 @@ var tableIdResolver = defineResolver({
|
|
|
8504
8609
|
var listTriggerInboxesRef = declareMethod({ id: "listTriggerInboxes" });
|
|
8505
8610
|
var triggerInboxResolver = defineResolver({
|
|
8506
8611
|
imports: [listTriggerInboxesRef],
|
|
8507
|
-
listItems: ({ imports }) => imports.listTriggerInboxes({}),
|
|
8612
|
+
listItems: ({ imports, cursor }) => imports.listTriggerInboxes({ cursor }),
|
|
8508
8613
|
prompt: ({ items }) => ({
|
|
8509
8614
|
type: "list",
|
|
8510
8615
|
message: "Select a trigger inbox:",
|
|
@@ -8522,7 +8627,7 @@ var triggerInboxResolver = defineResolver({
|
|
|
8522
8627
|
var listWorkflowsRef = declareMethod({ id: "listWorkflows" });
|
|
8523
8628
|
var workflowIdResolver = defineResolver({
|
|
8524
8629
|
imports: [listWorkflowsRef],
|
|
8525
|
-
listItems: ({ imports }) => imports.listWorkflows({}),
|
|
8630
|
+
listItems: ({ imports, cursor }) => imports.listWorkflows({ cursor }),
|
|
8526
8631
|
prompt: ({ items }) => ({
|
|
8527
8632
|
type: "list",
|
|
8528
8633
|
message: "Select a workflow:",
|
|
@@ -8538,7 +8643,7 @@ var workflowIdResolver = defineResolver({
|
|
|
8538
8643
|
var listDurableRunsRef = declareMethod({ id: "listDurableRuns" });
|
|
8539
8644
|
var durableRunIdResolver = defineResolver({
|
|
8540
8645
|
imports: [listDurableRunsRef],
|
|
8541
|
-
listItems: ({ imports }) => imports.listDurableRuns({}),
|
|
8646
|
+
listItems: ({ imports, cursor }) => imports.listDurableRuns({ cursor }),
|
|
8542
8647
|
prompt: ({ items }) => ({
|
|
8543
8648
|
type: "list",
|
|
8544
8649
|
message: "Select a run:",
|
|
@@ -8555,7 +8660,14 @@ var listWorkflowVersionsRef = declareMethod({ id: "listWorkflowVersions" });
|
|
|
8555
8660
|
var workflowVersionIdResolver = defineResolver({
|
|
8556
8661
|
imports: [listWorkflowVersionsRef],
|
|
8557
8662
|
requireParameters: ["workflow"],
|
|
8558
|
-
listItems: ({
|
|
8663
|
+
listItems: ({
|
|
8664
|
+
imports,
|
|
8665
|
+
input,
|
|
8666
|
+
cursor
|
|
8667
|
+
}) => imports.listWorkflowVersions({
|
|
8668
|
+
workflow: input.workflow,
|
|
8669
|
+
cursor
|
|
8670
|
+
}),
|
|
8559
8671
|
prompt: ({ items }) => ({
|
|
8560
8672
|
type: "list",
|
|
8561
8673
|
message: "Select a workflow version:",
|
|
@@ -8571,7 +8683,11 @@ var listWorkflowRunsRef = declareMethod({ id: "listWorkflowRuns" });
|
|
|
8571
8683
|
var workflowRunIdResolver = defineResolver({
|
|
8572
8684
|
imports: [listWorkflowRunsRef],
|
|
8573
8685
|
requireParameters: ["workflow"],
|
|
8574
|
-
listItems: ({
|
|
8686
|
+
listItems: ({
|
|
8687
|
+
imports,
|
|
8688
|
+
input,
|
|
8689
|
+
cursor
|
|
8690
|
+
}) => imports.listWorkflowRuns({ workflow: input.workflow, cursor }),
|
|
8575
8691
|
prompt: ({ items }) => ({
|
|
8576
8692
|
type: "list",
|
|
8577
8693
|
message: "Select a workflow run:",
|
|
@@ -8589,8 +8705,9 @@ var triggerMessagesResolver = defineResolver({
|
|
|
8589
8705
|
requireParameters: ["inbox"],
|
|
8590
8706
|
listItems: ({
|
|
8591
8707
|
imports,
|
|
8592
|
-
input
|
|
8593
|
-
|
|
8708
|
+
input,
|
|
8709
|
+
cursor
|
|
8710
|
+
}) => imports.listTriggerInboxMessages({ inbox: input.inbox, cursor }),
|
|
8594
8711
|
prompt: ({ items }) => ({
|
|
8595
8712
|
type: "checkbox",
|
|
8596
8713
|
message: "Select messages:",
|
|
@@ -8863,9 +8980,10 @@ function recordChoices(records) {
|
|
|
8863
8980
|
var tableRecordIdResolver = defineResolver({
|
|
8864
8981
|
imports: [listTableRecordsRef],
|
|
8865
8982
|
requireParameters: ["table"],
|
|
8866
|
-
listItems: ({ imports, input }) => imports.listTableRecords({
|
|
8983
|
+
listItems: ({ imports, input, cursor }) => imports.listTableRecords({
|
|
8867
8984
|
table: input.table,
|
|
8868
|
-
keyMode: "names"
|
|
8985
|
+
keyMode: "names",
|
|
8986
|
+
cursor
|
|
8869
8987
|
}),
|
|
8870
8988
|
prompt: ({ items }) => ({
|
|
8871
8989
|
type: "list",
|
|
@@ -8876,16 +8994,17 @@ var tableRecordIdResolver = defineResolver({
|
|
|
8876
8994
|
var tableRecordIdsResolver = defineResolver({
|
|
8877
8995
|
imports: [listTableRecordsRef],
|
|
8878
8996
|
requireParameters: ["table"],
|
|
8879
|
-
listItems: ({ imports, input }) => imports.listTableRecords({
|
|
8997
|
+
listItems: ({ imports, input, cursor }) => imports.listTableRecords({
|
|
8880
8998
|
table: input.table,
|
|
8881
|
-
keyMode: "names"
|
|
8999
|
+
keyMode: "names",
|
|
9000
|
+
cursor
|
|
8882
9001
|
}),
|
|
8883
9002
|
prompt: ({ items }) => ({
|
|
8884
9003
|
type: "checkbox",
|
|
8885
9004
|
message: "Select records to delete:",
|
|
8886
|
-
choices: recordChoices(items)
|
|
8887
|
-
|
|
8888
|
-
})
|
|
9005
|
+
choices: recordChoices(items)
|
|
9006
|
+
}),
|
|
9007
|
+
validate: ({ value }) => Array.isArray(value) && value.length > 0 ? true : "Select at least one record"
|
|
8889
9008
|
});
|
|
8890
9009
|
|
|
8891
9010
|
// src/resolvers/tableFieldIds.ts
|
|
@@ -8893,6 +9012,8 @@ var listTableFieldsRef = declareMethod({ id: "listTableFields" });
|
|
|
8893
9012
|
var tableFieldIdsResolver = defineResolver({
|
|
8894
9013
|
imports: [listTableFieldsRef],
|
|
8895
9014
|
requireParameters: ["table"],
|
|
9015
|
+
// No cursor forwarding: the fields API is unpaginated (no cursor on the
|
|
9016
|
+
// response), so the listing is always exhausted after one page.
|
|
8896
9017
|
listItems: ({ imports, input }) => imports.listTableFields({ table: input.table }),
|
|
8897
9018
|
prompt: ({ items }) => ({
|
|
8898
9019
|
type: "checkbox",
|
|
@@ -8901,9 +9022,9 @@ var tableFieldIdsResolver = defineResolver({
|
|
|
8901
9022
|
label: field.name,
|
|
8902
9023
|
hint: [field.id, field.type],
|
|
8903
9024
|
value: field.id
|
|
8904
|
-
}))
|
|
8905
|
-
|
|
8906
|
-
})
|
|
9025
|
+
}))
|
|
9026
|
+
}),
|
|
9027
|
+
validate: ({ value }) => Array.isArray(value) && value.length > 0 ? true : "Select at least one field"
|
|
8907
9028
|
});
|
|
8908
9029
|
|
|
8909
9030
|
// src/resolvers/tableName.ts
|
|
@@ -10540,6 +10661,11 @@ var ConnectionItemSchema = connections.ConnectionItemSchema;
|
|
|
10540
10661
|
// src/formatters/connection.ts
|
|
10541
10662
|
function formatConnectionItem(item) {
|
|
10542
10663
|
const details = [];
|
|
10664
|
+
const appKey = item.app_key ?? "unknown";
|
|
10665
|
+
details.push({
|
|
10666
|
+
text: item.slug ? `App: ${appKey} | App Slug: ${item.slug}` : `App: ${appKey}`,
|
|
10667
|
+
style: "accent"
|
|
10668
|
+
});
|
|
10543
10669
|
if (item.identifier) {
|
|
10544
10670
|
details.push({
|
|
10545
10671
|
text: `Identifier: ${item.identifier}`,
|
|
@@ -13147,27 +13273,31 @@ var ListTablesOptionsSchema = zod.z.object({
|
|
|
13147
13273
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
13148
13274
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
13149
13275
|
}).describe("List tables available to the authenticated user");
|
|
13276
|
+
var ListTablesInternalOptionsSchema = ListTablesOptionsSchema.extend({
|
|
13277
|
+
includePersonal: zod.z.boolean().optional().describe(
|
|
13278
|
+
"Include your own tables (default true). Set false with includeShared to list only tables shared with you."
|
|
13279
|
+
)
|
|
13280
|
+
});
|
|
13150
13281
|
|
|
13151
|
-
// src/plugins/tables/
|
|
13152
|
-
var
|
|
13153
|
-
|
|
13154
|
-
// src/plugins/tables/listTables/index.ts
|
|
13155
|
-
var listTablesPlugin = defineMethod({
|
|
13156
|
-
name: "listTables",
|
|
13282
|
+
// src/plugins/tables/listTables/internal.ts
|
|
13283
|
+
var listTablesInternalPlugin = defineMethod({
|
|
13284
|
+
name: "listTablesInternal",
|
|
13157
13285
|
imports: [apiPluginRef, capabilitiesPluginRef],
|
|
13158
|
-
|
|
13159
|
-
itemType: "Table",
|
|
13160
|
-
inputSchema: ListTablesOptionsSchema,
|
|
13161
|
-
outputSchema: TableItemSchema,
|
|
13286
|
+
inputSchema: ListTablesInternalOptionsSchema,
|
|
13162
13287
|
output: {
|
|
13163
13288
|
type: "list",
|
|
13164
13289
|
adaptPage: adaptZapierPage,
|
|
13165
13290
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
13166
13291
|
},
|
|
13167
13292
|
run: async ({ imports, input }) => {
|
|
13168
|
-
|
|
13293
|
+
const includePersonal = input.includePersonal ?? true;
|
|
13294
|
+
const includeShared = input.includeShared ?? false;
|
|
13295
|
+
if (includeShared) {
|
|
13169
13296
|
await imports.capabilities.checkCapability("canIncludeSharedTables");
|
|
13170
13297
|
}
|
|
13298
|
+
if (!includePersonal && !includeShared) {
|
|
13299
|
+
return { data: [] };
|
|
13300
|
+
}
|
|
13171
13301
|
const api = imports.api;
|
|
13172
13302
|
const searchParams = {};
|
|
13173
13303
|
if (input.pageSize !== void 0) {
|
|
@@ -13183,23 +13313,18 @@ var listTablesPlugin = defineMethod({
|
|
|
13183
13313
|
if (input.search) {
|
|
13184
13314
|
searchParams.q = input.search;
|
|
13185
13315
|
}
|
|
13186
|
-
if (input.owner && input.owner !== "me" && !
|
|
13316
|
+
if (input.owner && input.owner !== "me" && !includeShared) {
|
|
13187
13317
|
throw new ZapierValidationError(
|
|
13188
13318
|
'The "owner" option requires "includeShared" to be true. Without includeShared, only your own tables are returned.'
|
|
13189
13319
|
);
|
|
13190
13320
|
}
|
|
13191
|
-
const owner =
|
|
13321
|
+
const owner = includeShared ? input.owner : "me";
|
|
13322
|
+
const needsProfileId = owner === "me" || !includePersonal && includeShared;
|
|
13323
|
+
const profileId = needsProfileId ? (await api.get("/zapier/api/v4/profile/", {
|
|
13324
|
+
authRequired: true
|
|
13325
|
+
})).id : void 0;
|
|
13192
13326
|
if (owner) {
|
|
13193
|
-
|
|
13194
|
-
const profile = await api.get("/zapier/api/v4/profile/", {
|
|
13195
|
-
authRequired: true
|
|
13196
|
-
});
|
|
13197
|
-
searchParams.owner_customuser_id = String(
|
|
13198
|
-
profile.id
|
|
13199
|
-
);
|
|
13200
|
-
} else {
|
|
13201
|
-
searchParams.owner_customuser_id = owner;
|
|
13202
|
-
}
|
|
13327
|
+
searchParams.owner_customuser_id = owner === "me" ? String(profileId) : owner;
|
|
13203
13328
|
}
|
|
13204
13329
|
if (input.cursor) {
|
|
13205
13330
|
searchParams.offset = input.cursor;
|
|
@@ -13209,12 +13334,35 @@ var listTablesPlugin = defineMethod({
|
|
|
13209
13334
|
authRequired: true
|
|
13210
13335
|
});
|
|
13211
13336
|
const response = ListTablesApiResponseSchema.parse(rawResponse);
|
|
13337
|
+
const apiItems = includePersonal ? response.data : response.data.filter(
|
|
13338
|
+
(item) => item.owner_zapier_customuser_id !== profileId
|
|
13339
|
+
);
|
|
13212
13340
|
return {
|
|
13213
|
-
data:
|
|
13341
|
+
data: apiItems.map(transformTableItem),
|
|
13214
13342
|
links: response.links
|
|
13215
13343
|
};
|
|
13216
13344
|
}
|
|
13217
13345
|
});
|
|
13346
|
+
|
|
13347
|
+
// src/plugins/tables/shared.ts
|
|
13348
|
+
var tableCategories = ["table"];
|
|
13349
|
+
|
|
13350
|
+
// src/plugins/tables/listTables/index.ts
|
|
13351
|
+
var listTablesPlugin = defineMethod({
|
|
13352
|
+
name: "listTables",
|
|
13353
|
+
imports: [listTablesInternalPlugin],
|
|
13354
|
+
categories: tableCategories,
|
|
13355
|
+
itemType: "Table",
|
|
13356
|
+
inputSchema: ListTablesOptionsSchema,
|
|
13357
|
+
outputSchema: TableItemSchema,
|
|
13358
|
+
output: "list",
|
|
13359
|
+
run: async ({ imports, input }) => {
|
|
13360
|
+
return await imports.listTablesInternal({
|
|
13361
|
+
...input,
|
|
13362
|
+
includePersonal: void 0
|
|
13363
|
+
});
|
|
13364
|
+
}
|
|
13365
|
+
});
|
|
13218
13366
|
var GetTableApiResponseSchema = zod.z.object({
|
|
13219
13367
|
data: TableApiItemSchema
|
|
13220
13368
|
});
|