@zapier/zapier-sdk 0.34.1 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +341 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +10 -2
- package/dist/api/types.d.ts +2 -1
- package/dist/api/types.d.ts.map +1 -1
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -0
- package/dist/formatters/index.d.ts +2 -0
- package/dist/formatters/index.d.ts.map +1 -0
- package/dist/formatters/index.js +1 -0
- package/dist/formatters/tableRecord.d.ts +6 -0
- package/dist/formatters/tableRecord.d.ts.map +1 -0
- package/dist/formatters/tableRecord.js +23 -0
- package/dist/index.cjs +2054 -191
- package/dist/index.d.mts +639 -59
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.mjs +2030 -192
- package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.js +1 -1
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +2 -1
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +5 -2
- package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/listClientCredentials/index.js +6 -4
- package/dist/plugins/listConnections/index.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.js +6 -4
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +2 -1
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +2 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +4 -0
- package/dist/plugins/runAction/index.d.ts +2 -0
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +73 -14
- package/dist/plugins/tables/createTable/index.d.ts +18 -0
- package/dist/plugins/tables/createTable/index.d.ts.map +1 -0
- package/dist/plugins/tables/createTable/index.js +48 -0
- package/dist/plugins/tables/createTable/schemas.d.ts +37 -0
- package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/createTable/schemas.js +16 -0
- package/dist/plugins/tables/createTableFields/index.d.ts +18 -0
- package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -0
- package/dist/plugins/tables/createTableFields/index.js +49 -0
- package/dist/plugins/tables/createTableFields/schemas.d.ts +192 -0
- package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/createTableFields/schemas.js +42 -0
- package/dist/plugins/tables/createTableRecords/index.d.ts +18 -0
- package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -0
- package/dist/plugins/tables/createTableRecords/index.js +67 -0
- package/dist/plugins/tables/createTableRecords/schemas.d.ts +57 -0
- package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/createTableRecords/schemas.js +35 -0
- package/dist/plugins/tables/deleteTable/index.d.ts +18 -0
- package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -0
- package/dist/plugins/tables/deleteTable/index.js +43 -0
- package/dist/plugins/tables/deleteTable/schemas.d.ts +15 -0
- package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/deleteTable/schemas.js +9 -0
- package/dist/plugins/tables/deleteTableFields/index.d.ts +18 -0
- package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -0
- package/dist/plugins/tables/deleteTableFields/index.js +50 -0
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts +16 -0
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/deleteTableFields/schemas.js +13 -0
- package/dist/plugins/tables/deleteTableRecords/index.d.ts +18 -0
- package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -0
- package/dist/plugins/tables/deleteTableRecords/index.js +44 -0
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +16 -0
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/deleteTableRecords/schemas.js +14 -0
- package/dist/plugins/tables/getTable/index.d.ts +20 -0
- package/dist/plugins/tables/getTable/index.d.ts.map +1 -0
- package/dist/plugins/tables/getTable/index.js +48 -0
- package/dist/plugins/tables/getTable/schemas.d.ts +34 -0
- package/dist/plugins/tables/getTable/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/getTable/schemas.js +15 -0
- package/dist/plugins/tables/getTableRecord/index.d.ts +18 -0
- package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -0
- package/dist/plugins/tables/getTableRecord/index.js +60 -0
- package/dist/plugins/tables/getTableRecord/schemas.d.ts +51 -0
- package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/getTableRecord/schemas.js +44 -0
- package/dist/plugins/tables/listTableFields/index.d.ts +18 -0
- package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -0
- package/dist/plugins/tables/listTableFields/index.js +58 -0
- package/dist/plugins/tables/listTableFields/schemas.d.ts +180 -0
- package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/listTableFields/schemas.js +77 -0
- package/dist/plugins/tables/listTableRecords/index.d.ts +24 -0
- package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -0
- package/dist/plugins/tables/listTableRecords/index.js +97 -0
- package/dist/plugins/tables/listTableRecords/schemas.d.ts +120 -0
- package/dist/plugins/tables/listTableRecords/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/listTableRecords/schemas.js +74 -0
- package/dist/plugins/tables/listTables/index.d.ts +24 -0
- package/dist/plugins/tables/listTables/index.d.ts.map +1 -0
- package/dist/plugins/tables/listTables/index.js +85 -0
- package/dist/plugins/tables/listTables/schemas.d.ts +78 -0
- package/dist/plugins/tables/listTables/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/listTables/schemas.js +63 -0
- package/dist/plugins/tables/updateTableRecords/index.d.ts +18 -0
- package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -0
- package/dist/plugins/tables/updateTableRecords/index.js +68 -0
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts +59 -0
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/updateTableRecords/schemas.js +35 -0
- package/dist/plugins/tables/utils.d.ts +63 -0
- package/dist/plugins/tables/utils.d.ts.map +1 -0
- package/dist/plugins/tables/utils.js +262 -0
- package/dist/resolvers/index.d.ts +8 -0
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +8 -0
- package/dist/resolvers/tableFieldIds.d.ts +6 -0
- package/dist/resolvers/tableFieldIds.d.ts.map +1 -0
- package/dist/resolvers/tableFieldIds.js +19 -0
- package/dist/resolvers/tableFields.d.ts +3 -0
- package/dist/resolvers/tableFields.d.ts.map +1 -0
- package/dist/resolvers/tableFields.js +31 -0
- package/dist/resolvers/tableFilters.d.ts +5 -0
- package/dist/resolvers/tableFilters.d.ts.map +1 -0
- package/dist/resolvers/tableFilters.js +74 -0
- package/dist/resolvers/tableId.d.ts +4 -0
- package/dist/resolvers/tableId.d.ts.map +1 -0
- package/dist/resolvers/tableId.js +19 -0
- package/dist/resolvers/tableName.d.ts +3 -0
- package/dist/resolvers/tableName.d.ts.map +1 -0
- package/dist/resolvers/tableName.js +5 -0
- package/dist/resolvers/tableRecordId.d.ts +9 -0
- package/dist/resolvers/tableRecordId.d.ts.map +1 -0
- package/dist/resolvers/tableRecordId.js +48 -0
- package/dist/resolvers/tableRecords.d.ts +8 -0
- package/dist/resolvers/tableRecords.d.ts.map +1 -0
- package/dist/resolvers/tableRecords.js +77 -0
- package/dist/resolvers/tableSort.d.ts +5 -0
- package/dist/resolvers/tableSort.d.ts.map +1 -0
- package/dist/resolvers/tableSort.js +43 -0
- package/dist/sdk.d.ts +73 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +25 -0
- package/dist/types/sdk.d.ts +16 -1
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/function-utils.d.ts +2 -2
- package/dist/utils/function-utils.d.ts.map +1 -1
- package/dist/utils/function-utils.js +2 -3
- package/dist/utils/pagination-utils.d.ts +24 -0
- package/dist/utils/pagination-utils.d.ts.map +1 -1
- package/dist/utils/pagination-utils.js +78 -0
- package/dist/utils/schema-utils.d.ts +33 -5
- package/dist/utils/schema-utils.d.ts.map +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { FunctionOptions } from "../../../types/functions";
|
|
3
|
+
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
|
|
4
|
+
export declare const FieldTypeSchema: z.ZodEnum<{
|
|
5
|
+
string: "string";
|
|
6
|
+
number: "number";
|
|
7
|
+
boolean: "boolean";
|
|
8
|
+
link: "link";
|
|
9
|
+
email: "email";
|
|
10
|
+
uuid: "uuid";
|
|
11
|
+
text: "text";
|
|
12
|
+
datetime: "datetime";
|
|
13
|
+
decimal: "decimal";
|
|
14
|
+
json: "json";
|
|
15
|
+
multiple_string: "multiple_string";
|
|
16
|
+
labeled_string: "labeled_string";
|
|
17
|
+
multiple_labeled_string: "multiple_labeled_string";
|
|
18
|
+
multiple_text: "multiple_text";
|
|
19
|
+
multiple_boolean: "multiple_boolean";
|
|
20
|
+
multiple_number: "multiple_number";
|
|
21
|
+
multiple_decimal: "multiple_decimal";
|
|
22
|
+
multiple_datetime: "multiple_datetime";
|
|
23
|
+
multiple_uuid: "multiple_uuid";
|
|
24
|
+
multiple_json: "multiple_json";
|
|
25
|
+
formula: "formula";
|
|
26
|
+
button_trigger_zap: "button_trigger_zap";
|
|
27
|
+
button_continue_zap: "button_continue_zap";
|
|
28
|
+
multiple_email: "multiple_email";
|
|
29
|
+
multiple_link: "multiple_link";
|
|
30
|
+
currency: "currency";
|
|
31
|
+
phone_number: "phone_number";
|
|
32
|
+
ai_formula: "ai_formula";
|
|
33
|
+
linked_record: "linked_record";
|
|
34
|
+
multiple_linked_record: "multiple_linked_record";
|
|
35
|
+
}>;
|
|
36
|
+
export type FieldType = z.infer<typeof FieldTypeSchema>;
|
|
37
|
+
export declare const FieldApiItemSchema: z.ZodObject<{
|
|
38
|
+
id: z.ZodNumber;
|
|
39
|
+
type: z.ZodEnum<{
|
|
40
|
+
string: "string";
|
|
41
|
+
number: "number";
|
|
42
|
+
boolean: "boolean";
|
|
43
|
+
link: "link";
|
|
44
|
+
email: "email";
|
|
45
|
+
uuid: "uuid";
|
|
46
|
+
text: "text";
|
|
47
|
+
datetime: "datetime";
|
|
48
|
+
decimal: "decimal";
|
|
49
|
+
json: "json";
|
|
50
|
+
multiple_string: "multiple_string";
|
|
51
|
+
labeled_string: "labeled_string";
|
|
52
|
+
multiple_labeled_string: "multiple_labeled_string";
|
|
53
|
+
multiple_text: "multiple_text";
|
|
54
|
+
multiple_boolean: "multiple_boolean";
|
|
55
|
+
multiple_number: "multiple_number";
|
|
56
|
+
multiple_decimal: "multiple_decimal";
|
|
57
|
+
multiple_datetime: "multiple_datetime";
|
|
58
|
+
multiple_uuid: "multiple_uuid";
|
|
59
|
+
multiple_json: "multiple_json";
|
|
60
|
+
formula: "formula";
|
|
61
|
+
button_trigger_zap: "button_trigger_zap";
|
|
62
|
+
button_continue_zap: "button_continue_zap";
|
|
63
|
+
multiple_email: "multiple_email";
|
|
64
|
+
multiple_link: "multiple_link";
|
|
65
|
+
currency: "currency";
|
|
66
|
+
phone_number: "phone_number";
|
|
67
|
+
ai_formula: "ai_formula";
|
|
68
|
+
linked_record: "linked_record";
|
|
69
|
+
multiple_linked_record: "multiple_linked_record";
|
|
70
|
+
}>;
|
|
71
|
+
name: z.ZodString;
|
|
72
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
73
|
+
edited_at: z.ZodOptional<z.ZodString>;
|
|
74
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
75
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
76
|
+
is_order_field: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
is_filter_field: z.ZodOptional<z.ZodBoolean>;
|
|
78
|
+
is_selected_field: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
export type FieldApiItem = z.infer<typeof FieldApiItemSchema>;
|
|
81
|
+
export declare const ListTableFieldsApiResponseSchema: z.ZodObject<{
|
|
82
|
+
data: z.ZodArray<z.ZodObject<{
|
|
83
|
+
id: z.ZodNumber;
|
|
84
|
+
type: z.ZodEnum<{
|
|
85
|
+
string: "string";
|
|
86
|
+
number: "number";
|
|
87
|
+
boolean: "boolean";
|
|
88
|
+
link: "link";
|
|
89
|
+
email: "email";
|
|
90
|
+
uuid: "uuid";
|
|
91
|
+
text: "text";
|
|
92
|
+
datetime: "datetime";
|
|
93
|
+
decimal: "decimal";
|
|
94
|
+
json: "json";
|
|
95
|
+
multiple_string: "multiple_string";
|
|
96
|
+
labeled_string: "labeled_string";
|
|
97
|
+
multiple_labeled_string: "multiple_labeled_string";
|
|
98
|
+
multiple_text: "multiple_text";
|
|
99
|
+
multiple_boolean: "multiple_boolean";
|
|
100
|
+
multiple_number: "multiple_number";
|
|
101
|
+
multiple_decimal: "multiple_decimal";
|
|
102
|
+
multiple_datetime: "multiple_datetime";
|
|
103
|
+
multiple_uuid: "multiple_uuid";
|
|
104
|
+
multiple_json: "multiple_json";
|
|
105
|
+
formula: "formula";
|
|
106
|
+
button_trigger_zap: "button_trigger_zap";
|
|
107
|
+
button_continue_zap: "button_continue_zap";
|
|
108
|
+
multiple_email: "multiple_email";
|
|
109
|
+
multiple_link: "multiple_link";
|
|
110
|
+
currency: "currency";
|
|
111
|
+
phone_number: "phone_number";
|
|
112
|
+
ai_formula: "ai_formula";
|
|
113
|
+
linked_record: "linked_record";
|
|
114
|
+
multiple_linked_record: "multiple_linked_record";
|
|
115
|
+
}>;
|
|
116
|
+
name: z.ZodString;
|
|
117
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
118
|
+
edited_at: z.ZodOptional<z.ZodString>;
|
|
119
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
120
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
121
|
+
is_order_field: z.ZodOptional<z.ZodBoolean>;
|
|
122
|
+
is_filter_field: z.ZodOptional<z.ZodBoolean>;
|
|
123
|
+
is_selected_field: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
+
}, z.core.$strip>>;
|
|
125
|
+
}, z.core.$strip>;
|
|
126
|
+
export type ListTableFieldsApiResponse = z.infer<typeof ListTableFieldsApiResponseSchema>;
|
|
127
|
+
export declare const FieldItemSchema: z.ZodObject<{
|
|
128
|
+
id: z.ZodString;
|
|
129
|
+
type: z.ZodEnum<{
|
|
130
|
+
string: "string";
|
|
131
|
+
number: "number";
|
|
132
|
+
boolean: "boolean";
|
|
133
|
+
link: "link";
|
|
134
|
+
email: "email";
|
|
135
|
+
uuid: "uuid";
|
|
136
|
+
text: "text";
|
|
137
|
+
datetime: "datetime";
|
|
138
|
+
decimal: "decimal";
|
|
139
|
+
json: "json";
|
|
140
|
+
multiple_string: "multiple_string";
|
|
141
|
+
labeled_string: "labeled_string";
|
|
142
|
+
multiple_labeled_string: "multiple_labeled_string";
|
|
143
|
+
multiple_text: "multiple_text";
|
|
144
|
+
multiple_boolean: "multiple_boolean";
|
|
145
|
+
multiple_number: "multiple_number";
|
|
146
|
+
multiple_decimal: "multiple_decimal";
|
|
147
|
+
multiple_datetime: "multiple_datetime";
|
|
148
|
+
multiple_uuid: "multiple_uuid";
|
|
149
|
+
multiple_json: "multiple_json";
|
|
150
|
+
formula: "formula";
|
|
151
|
+
button_trigger_zap: "button_trigger_zap";
|
|
152
|
+
button_continue_zap: "button_continue_zap";
|
|
153
|
+
multiple_email: "multiple_email";
|
|
154
|
+
multiple_link: "multiple_link";
|
|
155
|
+
currency: "currency";
|
|
156
|
+
phone_number: "phone_number";
|
|
157
|
+
ai_formula: "ai_formula";
|
|
158
|
+
linked_record: "linked_record";
|
|
159
|
+
multiple_linked_record: "multiple_linked_record";
|
|
160
|
+
}>;
|
|
161
|
+
name: z.ZodString;
|
|
162
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
163
|
+
edited_at: z.ZodOptional<z.ZodString>;
|
|
164
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
165
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
export type FieldItem = z.infer<typeof FieldItemSchema>;
|
|
168
|
+
export declare const ListTableFieldsOptionsSchema: z.ZodObject<{
|
|
169
|
+
tableId: z.ZodString;
|
|
170
|
+
fieldKeys: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
171
|
+
}, z.core.$strip>;
|
|
172
|
+
export type ListTableFieldsOptions = z.infer<typeof ListTableFieldsOptionsSchema> & FunctionOptions;
|
|
173
|
+
export interface ListTableFieldsResult {
|
|
174
|
+
data: FieldItem[];
|
|
175
|
+
}
|
|
176
|
+
export type ListTableFieldsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
177
|
+
export interface ListTableFieldsSdkFunction {
|
|
178
|
+
listTableFields: (options: ListTableFieldsOptions) => Promise<ListTableFieldsResult>;
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTableFields/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+B1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAW7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAE3C,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,gCAAgC,CACxC,CAAC;AAYF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAM1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,4BAA4B;;;iBAaH,CAAC;AAEvC,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAC1C,OAAO,4BAA4B,CACpC,GACC,eAAe,CAAC;AAGlB,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,SAAS,EAAE,CAAC;CACnB;AAGD,MAAM,MAAM,oBAAoB,GAC5B,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,0BAA0B;IACzC,eAAe,EAAE,CACf,OAAO,EAAE,sBAAsB,KAC5B,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACrC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { withFormatter } from "../../../utils/schema-utils";
|
|
3
|
+
export const FieldTypeSchema = z.enum([
|
|
4
|
+
"string",
|
|
5
|
+
"multiple_string",
|
|
6
|
+
"labeled_string",
|
|
7
|
+
"multiple_labeled_string",
|
|
8
|
+
"text",
|
|
9
|
+
"multiple_text",
|
|
10
|
+
"boolean",
|
|
11
|
+
"multiple_boolean",
|
|
12
|
+
"number",
|
|
13
|
+
"multiple_number",
|
|
14
|
+
"decimal",
|
|
15
|
+
"multiple_decimal",
|
|
16
|
+
"datetime",
|
|
17
|
+
"multiple_datetime",
|
|
18
|
+
"uuid",
|
|
19
|
+
"multiple_uuid",
|
|
20
|
+
"json",
|
|
21
|
+
"multiple_json",
|
|
22
|
+
"formula",
|
|
23
|
+
"button_trigger_zap",
|
|
24
|
+
"button_continue_zap",
|
|
25
|
+
"email",
|
|
26
|
+
"multiple_email",
|
|
27
|
+
"link",
|
|
28
|
+
"multiple_link",
|
|
29
|
+
"currency",
|
|
30
|
+
"phone_number",
|
|
31
|
+
"ai_formula",
|
|
32
|
+
"linked_record",
|
|
33
|
+
"multiple_linked_record",
|
|
34
|
+
]);
|
|
35
|
+
export const FieldApiItemSchema = z.object({
|
|
36
|
+
id: z.number(),
|
|
37
|
+
type: FieldTypeSchema,
|
|
38
|
+
name: z.string(),
|
|
39
|
+
created_at: z.string().optional(),
|
|
40
|
+
edited_at: z.string().optional(),
|
|
41
|
+
options: z.record(z.string(), z.unknown()).optional(),
|
|
42
|
+
config: z.record(z.string(), z.unknown()).optional(),
|
|
43
|
+
is_order_field: z.boolean().optional(),
|
|
44
|
+
is_filter_field: z.boolean().optional(),
|
|
45
|
+
is_selected_field: z.boolean().optional(),
|
|
46
|
+
});
|
|
47
|
+
export const ListTableFieldsApiResponseSchema = z.object({
|
|
48
|
+
data: z.array(FieldApiItemSchema),
|
|
49
|
+
});
|
|
50
|
+
const FieldItemSchemaBase = z.object({
|
|
51
|
+
id: z.string(),
|
|
52
|
+
type: FieldTypeSchema,
|
|
53
|
+
name: z.string(),
|
|
54
|
+
created_at: z.string().optional(),
|
|
55
|
+
edited_at: z.string().optional(),
|
|
56
|
+
options: z.record(z.string(), z.unknown()).optional(),
|
|
57
|
+
config: z.record(z.string(), z.unknown()).optional(),
|
|
58
|
+
});
|
|
59
|
+
export const FieldItemSchema = withFormatter(FieldItemSchemaBase, {
|
|
60
|
+
format: (item) => ({
|
|
61
|
+
title: item.name,
|
|
62
|
+
id: item.id,
|
|
63
|
+
details: [{ text: `Type: ${item.type}`, style: "dim" }],
|
|
64
|
+
}),
|
|
65
|
+
});
|
|
66
|
+
export const ListTableFieldsOptionsSchema = z
|
|
67
|
+
.object({
|
|
68
|
+
tableId: z
|
|
69
|
+
.string()
|
|
70
|
+
.regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID")
|
|
71
|
+
.describe("The unique identifier of the table"),
|
|
72
|
+
fieldKeys: z
|
|
73
|
+
.array(z.union([z.string(), z.number()]))
|
|
74
|
+
.optional()
|
|
75
|
+
.describe('Filter by specific fields. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'),
|
|
76
|
+
})
|
|
77
|
+
.describe("List fields for a table");
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { GetContextType, Plugin } from "../../../types/plugin";
|
|
2
|
+
import { ListTableRecordsOptionsSchema, type ListTableRecordsOptions, type RecordItem } from "./schemas";
|
|
3
|
+
import type { ApiPluginProvides } from "../../api";
|
|
4
|
+
import type { EventEmissionContext } from "../../eventEmission";
|
|
5
|
+
export interface ListTableRecordsPluginProvides {
|
|
6
|
+
listTableRecords: (options: ListTableRecordsOptions) => Promise<{
|
|
7
|
+
data: RecordItem[];
|
|
8
|
+
nextCursor?: string;
|
|
9
|
+
}> & AsyncIterable<{
|
|
10
|
+
data: RecordItem[];
|
|
11
|
+
nextCursor?: string;
|
|
12
|
+
}> & {
|
|
13
|
+
items(): AsyncIterable<RecordItem>;
|
|
14
|
+
};
|
|
15
|
+
context: {
|
|
16
|
+
meta: {
|
|
17
|
+
listTableRecords: {
|
|
18
|
+
inputSchema: typeof ListTableRecordsOptionsSchema;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare const listTableRecordsPlugin: Plugin<{}, GetContextType<ApiPluginProvides> & EventEmissionContext, ListTableRecordsPluginProvides>;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTableRecords/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAEL,6BAA6B,EAE7B,KAAK,uBAAuB,EAC5B,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AA6BhE,MAAM,WAAW,8BAA8B;IAC7C,gBAAgB,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC;QAC9D,IAAI,EAAE,UAAU,EAAE,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC3D,KAAK,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;KACpC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,gBAAgB,EAAE;gBAChB,WAAW,EAAE,OAAO,6BAA6B,CAAC;aACnD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,sBAAsB,EAAE,MAAM,CACzC,EAAE,EACF,cAAc,CAAC,iBAAiB,CAAC,GAAG,oBAAoB,EACxD,8BAA8B,CA+G/B,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createPaginatedFunction } from "../../../utils/function-utils";
|
|
2
|
+
import { ListTableRecordsApiResponseSchema, ListTableRecordsOptionsSchema, RecordItemSchema, } from "./schemas";
|
|
3
|
+
import { createTelemetryCallback } from "../../../utils/telemetry-utils";
|
|
4
|
+
import { stripPageSuffix } from "../../../utils/string-utils";
|
|
5
|
+
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
6
|
+
import { tableIdResolver, tableFiltersResolver, tableSortResolver, } from "../../../resolvers";
|
|
7
|
+
import { tableRecordFormatter } from "../../../formatters";
|
|
8
|
+
import { createFieldKeyTranslator, transformRecordItem, throwOnResponseErrors, } from "../utils";
|
|
9
|
+
import { DEFAULT_PAGE_SIZE } from "../../../constants";
|
|
10
|
+
function extractNextCursor(meta) {
|
|
11
|
+
if (!meta?.pagination?.has_more || !meta.pagination.end_cursor) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
return meta.pagination.end_cursor;
|
|
15
|
+
}
|
|
16
|
+
export const listTableRecordsPlugin = ({ context }) => {
|
|
17
|
+
async function listTableRecordsPage(options) {
|
|
18
|
+
const { api } = context;
|
|
19
|
+
const translator = await createFieldKeyTranslator({
|
|
20
|
+
api,
|
|
21
|
+
tableId: options.tableId,
|
|
22
|
+
keyMode: options.keyMode,
|
|
23
|
+
});
|
|
24
|
+
const body = {};
|
|
25
|
+
if (options.pageSize !== undefined) {
|
|
26
|
+
body.limit = options.pageSize;
|
|
27
|
+
}
|
|
28
|
+
if (options.filters) {
|
|
29
|
+
body.filters = options.filters.map((f) => ({
|
|
30
|
+
key: translator.translateFieldKey(f.fieldKey),
|
|
31
|
+
operator: f.operator,
|
|
32
|
+
value: f.value,
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
if (options.sort) {
|
|
36
|
+
body.orders = [
|
|
37
|
+
{
|
|
38
|
+
key: translator.translateFieldKey(options.sort.fieldKey),
|
|
39
|
+
direction: options.sort.direction,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
if (options.cursor) {
|
|
44
|
+
body.cursor_query = {
|
|
45
|
+
query_type: "window",
|
|
46
|
+
start_cursor: options.cursor,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const rawResponse = await api.post(`/tables/api/v1/tables/${options.tableId}/records/query`, body, {
|
|
50
|
+
searchParams: { allow_nested_queries: "true" },
|
|
51
|
+
customErrorHandler: ({ status }) => {
|
|
52
|
+
if (status === 401) {
|
|
53
|
+
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access this table or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
54
|
+
}
|
|
55
|
+
if (status === 403) {
|
|
56
|
+
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to access this table. (HTTP ${status})`, { statusCode: status });
|
|
57
|
+
}
|
|
58
|
+
if (status === 404) {
|
|
59
|
+
return new Error(`Table not found: ${options.tableId}`);
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
},
|
|
63
|
+
authRequired: true,
|
|
64
|
+
});
|
|
65
|
+
throwOnResponseErrors(rawResponse);
|
|
66
|
+
const response = ListTableRecordsApiResponseSchema.parse(rawResponse);
|
|
67
|
+
return {
|
|
68
|
+
data: response.data.map((item) => ({
|
|
69
|
+
...transformRecordItem(item),
|
|
70
|
+
data: translator.translateOutput(item.data),
|
|
71
|
+
})),
|
|
72
|
+
nextCursor: extractNextCursor(response.meta),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const methodName = stripPageSuffix(listTableRecordsPage.name);
|
|
76
|
+
const listTableRecordsDefinition = createPaginatedFunction(listTableRecordsPage, ListTableRecordsOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName, DEFAULT_PAGE_SIZE);
|
|
77
|
+
return {
|
|
78
|
+
listTableRecords: listTableRecordsDefinition,
|
|
79
|
+
context: {
|
|
80
|
+
meta: {
|
|
81
|
+
listTableRecords: {
|
|
82
|
+
categories: ["table"],
|
|
83
|
+
type: "list",
|
|
84
|
+
itemType: "Record",
|
|
85
|
+
inputSchema: ListTableRecordsOptionsSchema,
|
|
86
|
+
outputSchema: RecordItemSchema,
|
|
87
|
+
resolvers: {
|
|
88
|
+
tableId: tableIdResolver,
|
|
89
|
+
filters: tableFiltersResolver,
|
|
90
|
+
sort: tableSortResolver,
|
|
91
|
+
},
|
|
92
|
+
formatter: tableRecordFormatter,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { PaginatedSdkFunction } from "../../../types/functions";
|
|
3
|
+
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
|
|
4
|
+
import { RecordItemSchema, type RecordItem } from "../getTableRecord/schemas";
|
|
5
|
+
export { RecordItemSchema };
|
|
6
|
+
export type { RecordItem };
|
|
7
|
+
export declare const ListTableRecordsApiResponseSchema: z.ZodObject<{
|
|
8
|
+
data: z.ZodArray<z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
11
|
+
created_at: z.ZodString;
|
|
12
|
+
edited_at: z.ZodString;
|
|
13
|
+
schema_revision_id: z.ZodNumber;
|
|
14
|
+
errors: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
15
|
+
orig_data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
16
|
+
is_source_record: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
19
|
+
pagination: z.ZodOptional<z.ZodObject<{
|
|
20
|
+
start_cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
21
|
+
end_cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
22
|
+
has_more: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
has_less: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type ListTableRecordsApiResponse = z.infer<typeof ListTableRecordsApiResponseSchema>;
|
|
28
|
+
declare const FilterOperatorSchema: z.ZodEnum<{
|
|
29
|
+
in: "in";
|
|
30
|
+
search: "search";
|
|
31
|
+
contains: "contains";
|
|
32
|
+
gt: "gt";
|
|
33
|
+
gte: "gte";
|
|
34
|
+
lt: "lt";
|
|
35
|
+
lte: "lte";
|
|
36
|
+
exact: "exact";
|
|
37
|
+
different: "different";
|
|
38
|
+
icontains: "icontains";
|
|
39
|
+
range: "range";
|
|
40
|
+
isnull: "isnull";
|
|
41
|
+
startswith: "startswith";
|
|
42
|
+
is_within: "is_within";
|
|
43
|
+
}>;
|
|
44
|
+
export type FilterOperator = z.infer<typeof FilterOperatorSchema>;
|
|
45
|
+
declare const FilterConditionSchema: z.ZodObject<{
|
|
46
|
+
fieldKey: z.ZodString;
|
|
47
|
+
operator: z.ZodEnum<{
|
|
48
|
+
in: "in";
|
|
49
|
+
search: "search";
|
|
50
|
+
contains: "contains";
|
|
51
|
+
gt: "gt";
|
|
52
|
+
gte: "gte";
|
|
53
|
+
lt: "lt";
|
|
54
|
+
lte: "lte";
|
|
55
|
+
exact: "exact";
|
|
56
|
+
different: "different";
|
|
57
|
+
icontains: "icontains";
|
|
58
|
+
range: "range";
|
|
59
|
+
isnull: "isnull";
|
|
60
|
+
startswith: "startswith";
|
|
61
|
+
is_within: "is_within";
|
|
62
|
+
}>;
|
|
63
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export type FilterCondition = z.infer<typeof FilterConditionSchema>;
|
|
66
|
+
export declare const SortConditionSchema: z.ZodObject<{
|
|
67
|
+
fieldKey: z.ZodString;
|
|
68
|
+
direction: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
69
|
+
asc: "asc";
|
|
70
|
+
desc: "desc";
|
|
71
|
+
}>>>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
export type SortCondition = z.infer<typeof SortConditionSchema>;
|
|
74
|
+
export declare const ListTableRecordsOptionsSchema: z.ZodObject<{
|
|
75
|
+
tableId: z.ZodString;
|
|
76
|
+
filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
77
|
+
fieldKey: z.ZodString;
|
|
78
|
+
operator: z.ZodEnum<{
|
|
79
|
+
in: "in";
|
|
80
|
+
search: "search";
|
|
81
|
+
contains: "contains";
|
|
82
|
+
gt: "gt";
|
|
83
|
+
gte: "gte";
|
|
84
|
+
lt: "lt";
|
|
85
|
+
lte: "lte";
|
|
86
|
+
exact: "exact";
|
|
87
|
+
different: "different";
|
|
88
|
+
icontains: "icontains";
|
|
89
|
+
range: "range";
|
|
90
|
+
isnull: "isnull";
|
|
91
|
+
startswith: "startswith";
|
|
92
|
+
is_within: "is_within";
|
|
93
|
+
}>;
|
|
94
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
95
|
+
}, z.core.$strip>>>;
|
|
96
|
+
sort: z.ZodOptional<z.ZodObject<{
|
|
97
|
+
fieldKey: z.ZodString;
|
|
98
|
+
direction: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
99
|
+
asc: "asc";
|
|
100
|
+
desc: "desc";
|
|
101
|
+
}>>>;
|
|
102
|
+
}, z.core.$strip>>;
|
|
103
|
+
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
104
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
105
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
106
|
+
keyMode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
107
|
+
names: "names";
|
|
108
|
+
ids: "ids";
|
|
109
|
+
}>>>;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
export type ListTableRecordsOptions = z.infer<typeof ListTableRecordsOptionsSchema>;
|
|
112
|
+
export interface ListTableRecordsPage {
|
|
113
|
+
data: RecordItem[];
|
|
114
|
+
nextCursor?: string;
|
|
115
|
+
}
|
|
116
|
+
export type ListTableRecordsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
117
|
+
export interface ListTableRecordsSdkFunction {
|
|
118
|
+
listTableRecords: PaginatedSdkFunction<ListTableRecordsOptions, RecordItem>;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTableRecords/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,gBAAgB,EAChB,KAAK,UAAU,EAChB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;iBAc5C,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,iCAAiC,CACzC,CAAC;AAEF,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;EAexB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;iBAIzB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAIpE,eAAO,MAAM,mBAAmB;;;;;;iBAK9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyBgC,CAAC;AAE3E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,qBAAqB,GAC7B,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,2BAA2B;IAC1C,gBAAgB,EAAE,oBAAoB,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;CAC7E"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { RecordApiItemSchema, RecordItemSchema, } from "../getTableRecord/schemas";
|
|
3
|
+
import { KeyModeSchema } from "../utils";
|
|
4
|
+
// Re-export for consumers
|
|
5
|
+
export { RecordItemSchema };
|
|
6
|
+
export const ListTableRecordsApiResponseSchema = z.object({
|
|
7
|
+
data: z.array(RecordApiItemSchema),
|
|
8
|
+
meta: z
|
|
9
|
+
.object({
|
|
10
|
+
pagination: z
|
|
11
|
+
.object({
|
|
12
|
+
start_cursor: z.string().nullable().optional(),
|
|
13
|
+
end_cursor: z.string().nullable().optional(),
|
|
14
|
+
has_more: z.boolean().optional(),
|
|
15
|
+
has_less: z.boolean().optional(),
|
|
16
|
+
})
|
|
17
|
+
.optional(),
|
|
18
|
+
})
|
|
19
|
+
.optional(),
|
|
20
|
+
});
|
|
21
|
+
const FilterOperatorSchema = z.enum([
|
|
22
|
+
"exact",
|
|
23
|
+
"different",
|
|
24
|
+
"contains",
|
|
25
|
+
"icontains",
|
|
26
|
+
"gte",
|
|
27
|
+
"gt",
|
|
28
|
+
"lt",
|
|
29
|
+
"lte",
|
|
30
|
+
"range",
|
|
31
|
+
"in",
|
|
32
|
+
"isnull",
|
|
33
|
+
"startswith",
|
|
34
|
+
"search",
|
|
35
|
+
"is_within",
|
|
36
|
+
]);
|
|
37
|
+
const FilterConditionSchema = z.object({
|
|
38
|
+
fieldKey: z.string().describe("The field key to filter on (e.g. f1, f2)"),
|
|
39
|
+
operator: FilterOperatorSchema.describe("The comparison operator"),
|
|
40
|
+
value: z.unknown().optional().describe("The value to compare against"),
|
|
41
|
+
});
|
|
42
|
+
const SortDirectionSchema = z.enum(["asc", "desc"]);
|
|
43
|
+
export const SortConditionSchema = z.object({
|
|
44
|
+
fieldKey: z.string().describe("The field key to sort by"),
|
|
45
|
+
direction: SortDirectionSchema.optional()
|
|
46
|
+
.default("asc")
|
|
47
|
+
.describe("Sort direction"),
|
|
48
|
+
});
|
|
49
|
+
export const ListTableRecordsOptionsSchema = z
|
|
50
|
+
.object({
|
|
51
|
+
tableId: z
|
|
52
|
+
.string()
|
|
53
|
+
.regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID")
|
|
54
|
+
.describe("The unique identifier of the table"),
|
|
55
|
+
filters: z
|
|
56
|
+
.array(FilterConditionSchema)
|
|
57
|
+
.optional()
|
|
58
|
+
.describe("Filter conditions for the query"),
|
|
59
|
+
sort: SortConditionSchema.optional().describe("Sort records by a field"),
|
|
60
|
+
pageSize: z
|
|
61
|
+
.number()
|
|
62
|
+
.min(1)
|
|
63
|
+
.max(1000)
|
|
64
|
+
.optional()
|
|
65
|
+
.describe("Number of records per page (max 1000)"),
|
|
66
|
+
maxItems: z
|
|
67
|
+
.number()
|
|
68
|
+
.min(1)
|
|
69
|
+
.optional()
|
|
70
|
+
.describe("Maximum total items to return across all pages"),
|
|
71
|
+
cursor: z.string().optional().describe("Cursor to start from"),
|
|
72
|
+
keyMode: KeyModeSchema,
|
|
73
|
+
})
|
|
74
|
+
.describe("List records in a table with optional filtering and sorting");
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { GetContextType, Plugin } from "../../../types/plugin";
|
|
2
|
+
import { ListTablesOptionsSchema, type ListTablesOptions, type TableItem } from "./schemas";
|
|
3
|
+
import type { ApiPluginProvides } from "../../api";
|
|
4
|
+
import type { EventEmissionContext } from "../../eventEmission";
|
|
5
|
+
export interface ListTablesPluginProvides {
|
|
6
|
+
listTables: (options?: ListTablesOptions) => Promise<{
|
|
7
|
+
data: TableItem[];
|
|
8
|
+
nextCursor?: string;
|
|
9
|
+
}> & AsyncIterable<{
|
|
10
|
+
data: TableItem[];
|
|
11
|
+
nextCursor?: string;
|
|
12
|
+
}> & {
|
|
13
|
+
items(): AsyncIterable<TableItem>;
|
|
14
|
+
};
|
|
15
|
+
context: {
|
|
16
|
+
meta: {
|
|
17
|
+
listTables: {
|
|
18
|
+
inputSchema: typeof ListTablesOptionsSchema;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare const listTablesPlugin: Plugin<{}, GetContextType<ApiPluginProvides> & EventEmissionContext, ListTablesPluginProvides>;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTables/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAEL,uBAAuB,EAEvB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAsBhE,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,KAAK,OAAO,CAAC;QACnD,IAAI,EAAE,SAAS,EAAE,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC1D,KAAK,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;KACnC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,WAAW,EAAE,OAAO,uBAAuB,CAAC;aAC7C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,EAAE,EACF,cAAc,CAAC,iBAAiB,CAAC,GAAG,oBAAoB,EACxD,wBAAwB,CAsFzB,CAAC"}
|