@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,192 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { FunctionOptions } from "../../../types/functions";
|
|
3
|
+
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
|
|
4
|
+
import { FieldTypeSchema, FieldItemSchema, type FieldItem } from "../listTableFields/schemas";
|
|
5
|
+
export { FieldTypeSchema, FieldItemSchema };
|
|
6
|
+
export type { FieldItem };
|
|
7
|
+
export declare const CreateTableFieldsApiResponseSchema: z.ZodObject<{
|
|
8
|
+
data: z.ZodArray<z.ZodObject<{
|
|
9
|
+
new: z.ZodObject<{
|
|
10
|
+
id: z.ZodNumber;
|
|
11
|
+
type: z.ZodEnum<{
|
|
12
|
+
string: "string";
|
|
13
|
+
number: "number";
|
|
14
|
+
boolean: "boolean";
|
|
15
|
+
link: "link";
|
|
16
|
+
email: "email";
|
|
17
|
+
uuid: "uuid";
|
|
18
|
+
text: "text";
|
|
19
|
+
datetime: "datetime";
|
|
20
|
+
decimal: "decimal";
|
|
21
|
+
json: "json";
|
|
22
|
+
multiple_string: "multiple_string";
|
|
23
|
+
labeled_string: "labeled_string";
|
|
24
|
+
multiple_labeled_string: "multiple_labeled_string";
|
|
25
|
+
multiple_text: "multiple_text";
|
|
26
|
+
multiple_boolean: "multiple_boolean";
|
|
27
|
+
multiple_number: "multiple_number";
|
|
28
|
+
multiple_decimal: "multiple_decimal";
|
|
29
|
+
multiple_datetime: "multiple_datetime";
|
|
30
|
+
multiple_uuid: "multiple_uuid";
|
|
31
|
+
multiple_json: "multiple_json";
|
|
32
|
+
formula: "formula";
|
|
33
|
+
button_trigger_zap: "button_trigger_zap";
|
|
34
|
+
button_continue_zap: "button_continue_zap";
|
|
35
|
+
multiple_email: "multiple_email";
|
|
36
|
+
multiple_link: "multiple_link";
|
|
37
|
+
currency: "currency";
|
|
38
|
+
phone_number: "phone_number";
|
|
39
|
+
ai_formula: "ai_formula";
|
|
40
|
+
linked_record: "linked_record";
|
|
41
|
+
multiple_linked_record: "multiple_linked_record";
|
|
42
|
+
}>;
|
|
43
|
+
name: z.ZodString;
|
|
44
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
45
|
+
edited_at: z.ZodOptional<z.ZodString>;
|
|
46
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
47
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
48
|
+
is_order_field: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
is_filter_field: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
is_selected_field: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
old: z.ZodNullable<z.ZodObject<{
|
|
53
|
+
id: z.ZodNumber;
|
|
54
|
+
type: z.ZodEnum<{
|
|
55
|
+
string: "string";
|
|
56
|
+
number: "number";
|
|
57
|
+
boolean: "boolean";
|
|
58
|
+
link: "link";
|
|
59
|
+
email: "email";
|
|
60
|
+
uuid: "uuid";
|
|
61
|
+
text: "text";
|
|
62
|
+
datetime: "datetime";
|
|
63
|
+
decimal: "decimal";
|
|
64
|
+
json: "json";
|
|
65
|
+
multiple_string: "multiple_string";
|
|
66
|
+
labeled_string: "labeled_string";
|
|
67
|
+
multiple_labeled_string: "multiple_labeled_string";
|
|
68
|
+
multiple_text: "multiple_text";
|
|
69
|
+
multiple_boolean: "multiple_boolean";
|
|
70
|
+
multiple_number: "multiple_number";
|
|
71
|
+
multiple_decimal: "multiple_decimal";
|
|
72
|
+
multiple_datetime: "multiple_datetime";
|
|
73
|
+
multiple_uuid: "multiple_uuid";
|
|
74
|
+
multiple_json: "multiple_json";
|
|
75
|
+
formula: "formula";
|
|
76
|
+
button_trigger_zap: "button_trigger_zap";
|
|
77
|
+
button_continue_zap: "button_continue_zap";
|
|
78
|
+
multiple_email: "multiple_email";
|
|
79
|
+
multiple_link: "multiple_link";
|
|
80
|
+
currency: "currency";
|
|
81
|
+
phone_number: "phone_number";
|
|
82
|
+
ai_formula: "ai_formula";
|
|
83
|
+
linked_record: "linked_record";
|
|
84
|
+
multiple_linked_record: "multiple_linked_record";
|
|
85
|
+
}>;
|
|
86
|
+
name: z.ZodString;
|
|
87
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
88
|
+
edited_at: z.ZodOptional<z.ZodString>;
|
|
89
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
90
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
91
|
+
is_order_field: z.ZodOptional<z.ZodBoolean>;
|
|
92
|
+
is_filter_field: z.ZodOptional<z.ZodBoolean>;
|
|
93
|
+
is_selected_field: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
}, z.core.$strip>>;
|
|
95
|
+
kind: z.ZodEnum<{
|
|
96
|
+
created: "created";
|
|
97
|
+
updated: "updated";
|
|
98
|
+
deleted: "deleted";
|
|
99
|
+
}>;
|
|
100
|
+
}, z.core.$strip>>;
|
|
101
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
102
|
+
did_change: z.ZodBoolean;
|
|
103
|
+
}, z.core.$strip>>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
export type CreateTableFieldsApiResponse = z.infer<typeof CreateTableFieldsApiResponseSchema>;
|
|
106
|
+
export declare const NewFieldSchema: z.ZodObject<{
|
|
107
|
+
type: z.ZodEnum<{
|
|
108
|
+
string: "string";
|
|
109
|
+
number: "number";
|
|
110
|
+
boolean: "boolean";
|
|
111
|
+
link: "link";
|
|
112
|
+
email: "email";
|
|
113
|
+
uuid: "uuid";
|
|
114
|
+
text: "text";
|
|
115
|
+
datetime: "datetime";
|
|
116
|
+
decimal: "decimal";
|
|
117
|
+
json: "json";
|
|
118
|
+
multiple_string: "multiple_string";
|
|
119
|
+
labeled_string: "labeled_string";
|
|
120
|
+
multiple_labeled_string: "multiple_labeled_string";
|
|
121
|
+
multiple_text: "multiple_text";
|
|
122
|
+
multiple_boolean: "multiple_boolean";
|
|
123
|
+
multiple_number: "multiple_number";
|
|
124
|
+
multiple_decimal: "multiple_decimal";
|
|
125
|
+
multiple_datetime: "multiple_datetime";
|
|
126
|
+
multiple_uuid: "multiple_uuid";
|
|
127
|
+
multiple_json: "multiple_json";
|
|
128
|
+
formula: "formula";
|
|
129
|
+
button_trigger_zap: "button_trigger_zap";
|
|
130
|
+
button_continue_zap: "button_continue_zap";
|
|
131
|
+
multiple_email: "multiple_email";
|
|
132
|
+
multiple_link: "multiple_link";
|
|
133
|
+
currency: "currency";
|
|
134
|
+
phone_number: "phone_number";
|
|
135
|
+
ai_formula: "ai_formula";
|
|
136
|
+
linked_record: "linked_record";
|
|
137
|
+
multiple_linked_record: "multiple_linked_record";
|
|
138
|
+
}>;
|
|
139
|
+
name: z.ZodString;
|
|
140
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
141
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
142
|
+
}, z.core.$strip>;
|
|
143
|
+
export type NewField = z.infer<typeof NewFieldSchema>;
|
|
144
|
+
export declare const CreateTableFieldsOptionsSchema: z.ZodObject<{
|
|
145
|
+
tableId: z.ZodString;
|
|
146
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
147
|
+
type: z.ZodEnum<{
|
|
148
|
+
string: "string";
|
|
149
|
+
number: "number";
|
|
150
|
+
boolean: "boolean";
|
|
151
|
+
link: "link";
|
|
152
|
+
email: "email";
|
|
153
|
+
uuid: "uuid";
|
|
154
|
+
text: "text";
|
|
155
|
+
datetime: "datetime";
|
|
156
|
+
decimal: "decimal";
|
|
157
|
+
json: "json";
|
|
158
|
+
multiple_string: "multiple_string";
|
|
159
|
+
labeled_string: "labeled_string";
|
|
160
|
+
multiple_labeled_string: "multiple_labeled_string";
|
|
161
|
+
multiple_text: "multiple_text";
|
|
162
|
+
multiple_boolean: "multiple_boolean";
|
|
163
|
+
multiple_number: "multiple_number";
|
|
164
|
+
multiple_decimal: "multiple_decimal";
|
|
165
|
+
multiple_datetime: "multiple_datetime";
|
|
166
|
+
multiple_uuid: "multiple_uuid";
|
|
167
|
+
multiple_json: "multiple_json";
|
|
168
|
+
formula: "formula";
|
|
169
|
+
button_trigger_zap: "button_trigger_zap";
|
|
170
|
+
button_continue_zap: "button_continue_zap";
|
|
171
|
+
multiple_email: "multiple_email";
|
|
172
|
+
multiple_link: "multiple_link";
|
|
173
|
+
currency: "currency";
|
|
174
|
+
phone_number: "phone_number";
|
|
175
|
+
ai_formula: "ai_formula";
|
|
176
|
+
linked_record: "linked_record";
|
|
177
|
+
multiple_linked_record: "multiple_linked_record";
|
|
178
|
+
}>;
|
|
179
|
+
name: z.ZodString;
|
|
180
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
181
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
182
|
+
}, z.core.$strip>>;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
export type CreateTableFieldsOptions = z.infer<typeof CreateTableFieldsOptionsSchema> & FunctionOptions;
|
|
185
|
+
export interface CreateTableFieldsResult {
|
|
186
|
+
data: FieldItem[];
|
|
187
|
+
}
|
|
188
|
+
export type CreateTableFieldsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
189
|
+
export interface CreateTableFieldsSdkFunction {
|
|
190
|
+
createTableFields: (options: CreateTableFieldsOptions) => Promise<CreateTableFieldsResult>;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/createTableFields/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;AAC/B,OAAO,EACL,eAAe,EAEf,eAAe,EACf,KAAK,SAAS,EACf,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC;AAC5C,YAAY,EAAE,SAAS,EAAE,CAAC;AAS1B,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAO7C,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,kCAAkC,CAC1C,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAWzB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAWQ,CAAC;AAEpD,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,GACC,eAAe,CAAC;AAGlB,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,SAAS,EAAE,CAAC;CACnB;AAGD,MAAM,MAAM,sBAAsB,GAC9B,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACvC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { FieldTypeSchema, FieldApiItemSchema, FieldItemSchema, } from "../listTableFields/schemas";
|
|
3
|
+
// Re-export for consumers
|
|
4
|
+
export { FieldTypeSchema, FieldItemSchema };
|
|
5
|
+
// The API returns a changeset format with new/old/kind for each field
|
|
6
|
+
const FieldChangesetItemSchema = z.object({
|
|
7
|
+
new: FieldApiItemSchema,
|
|
8
|
+
old: FieldApiItemSchema.nullable(),
|
|
9
|
+
kind: z.enum(["created", "updated", "deleted"]),
|
|
10
|
+
});
|
|
11
|
+
export const CreateTableFieldsApiResponseSchema = z.object({
|
|
12
|
+
data: z.array(FieldChangesetItemSchema),
|
|
13
|
+
meta: z
|
|
14
|
+
.object({
|
|
15
|
+
did_change: z.boolean(),
|
|
16
|
+
})
|
|
17
|
+
.optional(),
|
|
18
|
+
});
|
|
19
|
+
export const NewFieldSchema = z.object({
|
|
20
|
+
type: FieldTypeSchema.describe("The data type of the field"),
|
|
21
|
+
name: z.string().min(1).describe("The display name of the field"),
|
|
22
|
+
options: z
|
|
23
|
+
.record(z.string(), z.unknown())
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Data configuration options for the field"),
|
|
26
|
+
config: z
|
|
27
|
+
.record(z.string(), z.unknown())
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("Display configuration for the field"),
|
|
30
|
+
});
|
|
31
|
+
export const CreateTableFieldsOptionsSchema = z
|
|
32
|
+
.object({
|
|
33
|
+
tableId: z
|
|
34
|
+
.string()
|
|
35
|
+
.regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID")
|
|
36
|
+
.describe("The unique identifier of the table"),
|
|
37
|
+
fields: z
|
|
38
|
+
.array(NewFieldSchema)
|
|
39
|
+
.min(1)
|
|
40
|
+
.describe("Array of field definitions to create"),
|
|
41
|
+
})
|
|
42
|
+
.describe("Create one or more fields in a table");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Plugin } from "../../../types/plugin";
|
|
2
|
+
import type { ApiClient } from "../../../api";
|
|
3
|
+
import { CreateTableRecordsOptionsSchema, type CreateTableRecordsOptions, type CreateTableRecordsResult } from "./schemas";
|
|
4
|
+
import type { EventEmissionContext } from "../../eventEmission";
|
|
5
|
+
export interface CreateTableRecordsPluginProvides {
|
|
6
|
+
createTableRecords: (options: CreateTableRecordsOptions) => Promise<CreateTableRecordsResult>;
|
|
7
|
+
context: {
|
|
8
|
+
meta: {
|
|
9
|
+
createTableRecords: {
|
|
10
|
+
inputSchema: typeof CreateTableRecordsOptionsSchema;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare const createTableRecordsPlugin: Plugin<{}, {
|
|
16
|
+
api: ApiClient;
|
|
17
|
+
} & EventEmissionContext, CreateTableRecordsPluginProvides>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/createTableRecords/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EACL,+BAA+B,EAG/B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC9B,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAYhE,MAAM,WAAW,gCAAgC;IAC/C,kBAAkB,EAAE,CAClB,OAAO,EAAE,yBAAyB,KAC/B,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACvC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,kBAAkB,EAAE;gBAClB,WAAW,EAAE,OAAO,+BAA+B,CAAC;aACrD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAC3C,EAAE,EACF;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EACzC,gCAAgC,CAsFjC,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createFunction } from "../../../utils/function-utils";
|
|
2
|
+
import { CreateTableRecordsOptionsSchema, CreateTableRecordsApiResponseSchema, RecordItemSchema, } from "./schemas";
|
|
3
|
+
import { createTelemetryCallback } from "../../../utils/telemetry-utils";
|
|
4
|
+
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
5
|
+
import { tableIdResolver, tableRecordsResolver } from "../../../resolvers";
|
|
6
|
+
import { tableRecordFormatter } from "../../../formatters";
|
|
7
|
+
import { createFieldKeyTranslator, transformRecordItem, throwOnRecordErrors, throwOnResponseErrors, } from "../utils";
|
|
8
|
+
export const createTableRecordsPlugin = ({ context }) => {
|
|
9
|
+
async function createTableRecords(options) {
|
|
10
|
+
const { api } = context;
|
|
11
|
+
const translator = await createFieldKeyTranslator({
|
|
12
|
+
api,
|
|
13
|
+
tableId: options.tableId,
|
|
14
|
+
keyMode: options.keyMode,
|
|
15
|
+
});
|
|
16
|
+
const rawResponse = await api.post(`/tables/api/v1/tables/${options.tableId}/records`, {
|
|
17
|
+
new_records: options.records.map((record) => ({
|
|
18
|
+
data: translator.translateInput(record.data),
|
|
19
|
+
})),
|
|
20
|
+
}, {
|
|
21
|
+
customErrorHandler: ({ status }) => {
|
|
22
|
+
if (status === 401) {
|
|
23
|
+
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to create records or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
24
|
+
}
|
|
25
|
+
if (status === 403) {
|
|
26
|
+
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to create records. (HTTP ${status})`, { statusCode: status });
|
|
27
|
+
}
|
|
28
|
+
if (status === 404) {
|
|
29
|
+
return new Error(`Table not found: ${options.tableId}`);
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
},
|
|
33
|
+
authRequired: true,
|
|
34
|
+
});
|
|
35
|
+
throwOnResponseErrors(rawResponse);
|
|
36
|
+
const response = CreateTableRecordsApiResponseSchema.parse(rawResponse);
|
|
37
|
+
for (const changeset of response.data) {
|
|
38
|
+
throwOnRecordErrors(changeset.new);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
data: response.data.map((changeset) => ({
|
|
42
|
+
...transformRecordItem(changeset.new),
|
|
43
|
+
data: translator.translateOutput(changeset.new.data),
|
|
44
|
+
})),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const createTableRecordsDefinition = createFunction(createTableRecords, CreateTableRecordsOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, createTableRecords.name));
|
|
48
|
+
return {
|
|
49
|
+
createTableRecords: createTableRecordsDefinition,
|
|
50
|
+
context: {
|
|
51
|
+
meta: {
|
|
52
|
+
createTableRecords: {
|
|
53
|
+
categories: ["table"],
|
|
54
|
+
type: "create",
|
|
55
|
+
itemType: "Record",
|
|
56
|
+
inputSchema: CreateTableRecordsOptionsSchema,
|
|
57
|
+
outputSchema: RecordItemSchema,
|
|
58
|
+
resolvers: {
|
|
59
|
+
tableId: tableIdResolver,
|
|
60
|
+
records: tableRecordsResolver,
|
|
61
|
+
},
|
|
62
|
+
formatter: tableRecordFormatter,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { FunctionOptions } 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 CreateTableRecordsApiResponseSchema: z.ZodObject<{
|
|
8
|
+
data: z.ZodArray<z.ZodObject<{
|
|
9
|
+
change_id: z.ZodString;
|
|
10
|
+
old: z.ZodNullable<z.ZodObject<{
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
13
|
+
created_at: z.ZodString;
|
|
14
|
+
edited_at: z.ZodString;
|
|
15
|
+
schema_revision_id: z.ZodNumber;
|
|
16
|
+
errors: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
17
|
+
orig_data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
18
|
+
is_source_record: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
19
|
+
}, z.core.$strip>>;
|
|
20
|
+
new: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
23
|
+
created_at: z.ZodString;
|
|
24
|
+
edited_at: z.ZodString;
|
|
25
|
+
schema_revision_id: z.ZodNumber;
|
|
26
|
+
errors: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
27
|
+
orig_data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
28
|
+
is_source_record: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
changed_field_ids: z.ZodNullable<z.ZodArray<z.ZodNumber>>;
|
|
31
|
+
record_id: z.ZodString;
|
|
32
|
+
}, z.core.$strip>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type CreateTableRecordsApiResponse = z.infer<typeof CreateTableRecordsApiResponseSchema>;
|
|
35
|
+
export declare const NewRecordSchema: z.ZodObject<{
|
|
36
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type NewRecord = z.infer<typeof NewRecordSchema>;
|
|
39
|
+
export declare const CreateTableRecordsOptionsSchema: z.ZodObject<{
|
|
40
|
+
tableId: z.ZodString;
|
|
41
|
+
records: z.ZodArray<z.ZodObject<{
|
|
42
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
keyMode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
45
|
+
names: "names";
|
|
46
|
+
ids: "ids";
|
|
47
|
+
}>>>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
export type CreateTableRecordsOptions = z.infer<typeof CreateTableRecordsOptionsSchema> & FunctionOptions;
|
|
50
|
+
export interface CreateTableRecordsResult {
|
|
51
|
+
data: RecordItem[];
|
|
52
|
+
}
|
|
53
|
+
export type CreateTableRecordsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
54
|
+
export interface CreateTableRecordsSdkFunction {
|
|
55
|
+
createTableRecords: (options: CreateTableRecordsOptions) => Promise<CreateTableRecordsResult>;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/createTableRecords/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;AAC/B,OAAO,EAEL,gBAAgB,EAChB,KAAK,UAAU,EAChB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,YAAY,EAAE,UAAU,EAAE,CAAC;AAW3B,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;iBAE9C,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CACjD,OAAO,mCAAmC,CAC3C,CAAC;AAEF,eAAO,MAAM,eAAe;;iBAI1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,+BAA+B;;;;;;;;;iBAaQ,CAAC;AAErD,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,GACC,eAAe,CAAC;AAElB,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,UAAU,EAAE,CAAC;CACpB;AAED,MAAM,MAAM,uBAAuB,GAC/B,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,6BAA6B;IAC5C,kBAAkB,EAAE,CAClB,OAAO,EAAE,yBAAyB,KAC/B,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACxC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
// The API returns changesets with old/new values
|
|
7
|
+
const RecordChangesetSchema = z.object({
|
|
8
|
+
change_id: z.string(),
|
|
9
|
+
old: RecordApiItemSchema.nullable(),
|
|
10
|
+
new: RecordApiItemSchema,
|
|
11
|
+
changed_field_ids: z.array(z.number()).nullable(),
|
|
12
|
+
record_id: z.string(),
|
|
13
|
+
});
|
|
14
|
+
export const CreateTableRecordsApiResponseSchema = z.object({
|
|
15
|
+
data: z.array(RecordChangesetSchema),
|
|
16
|
+
});
|
|
17
|
+
export const NewRecordSchema = z.object({
|
|
18
|
+
data: z
|
|
19
|
+
.record(z.string(), z.unknown())
|
|
20
|
+
.describe("The field values for the record, keyed by field ID"),
|
|
21
|
+
});
|
|
22
|
+
export const CreateTableRecordsOptionsSchema = z
|
|
23
|
+
.object({
|
|
24
|
+
tableId: z
|
|
25
|
+
.string()
|
|
26
|
+
.regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID")
|
|
27
|
+
.describe("The unique identifier of the table"),
|
|
28
|
+
records: z
|
|
29
|
+
.array(NewRecordSchema)
|
|
30
|
+
.min(1)
|
|
31
|
+
.max(100)
|
|
32
|
+
.describe("Array of records to create (max 100)"),
|
|
33
|
+
keyMode: KeyModeSchema,
|
|
34
|
+
})
|
|
35
|
+
.describe("Create one or more records in a table");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Plugin } from "../../../types/plugin";
|
|
2
|
+
import type { ApiClient } from "../../../api";
|
|
3
|
+
import { DeleteTableOptionsSchema, type DeleteTableOptions, type DeleteTableResult } from "./schemas";
|
|
4
|
+
import type { EventEmissionContext } from "../../eventEmission";
|
|
5
|
+
export interface DeleteTablePluginProvides {
|
|
6
|
+
deleteTable: (options: DeleteTableOptions) => Promise<DeleteTableResult>;
|
|
7
|
+
context: {
|
|
8
|
+
meta: {
|
|
9
|
+
deleteTable: {
|
|
10
|
+
inputSchema: typeof DeleteTableOptionsSchema;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare const deleteTablePlugin: Plugin<{}, {
|
|
16
|
+
api: ApiClient;
|
|
17
|
+
} & EventEmissionContext, DeleteTablePluginProvides>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTable/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EACL,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAKhE,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACzE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,WAAW,EAAE;gBACX,WAAW,EAAE,OAAO,wBAAwB,CAAC;aAC9C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC,EAAE,EACF;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EACzC,yBAAyB,CAyD1B,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createFunction } from "../../../utils/function-utils";
|
|
2
|
+
import { DeleteTableOptionsSchema, } from "./schemas";
|
|
3
|
+
import { createTelemetryCallback } from "../../../utils/telemetry-utils";
|
|
4
|
+
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
5
|
+
import { tableIdResolver } from "../../../resolvers";
|
|
6
|
+
export const deleteTablePlugin = ({ context }) => {
|
|
7
|
+
async function deleteTable(options) {
|
|
8
|
+
const { api } = context;
|
|
9
|
+
await api.delete(`/tables/api/v1/tables/${options.tableId}`, undefined, {
|
|
10
|
+
customErrorHandler: ({ status }) => {
|
|
11
|
+
if (status === 401) {
|
|
12
|
+
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to delete tables or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
13
|
+
}
|
|
14
|
+
if (status === 403) {
|
|
15
|
+
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to delete tables. (HTTP ${status})`, { statusCode: status });
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
},
|
|
19
|
+
authRequired: true,
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
success: true,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const deleteTableDefinition = createFunction(deleteTable, DeleteTableOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, deleteTable.name));
|
|
26
|
+
return {
|
|
27
|
+
deleteTable: deleteTableDefinition,
|
|
28
|
+
context: {
|
|
29
|
+
meta: {
|
|
30
|
+
deleteTable: {
|
|
31
|
+
categories: ["table"],
|
|
32
|
+
type: "delete",
|
|
33
|
+
itemType: "Table",
|
|
34
|
+
inputSchema: DeleteTableOptionsSchema,
|
|
35
|
+
resolvers: {
|
|
36
|
+
tableId: tableIdResolver,
|
|
37
|
+
},
|
|
38
|
+
confirm: "delete",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { FunctionOptions } from "../../../types/functions";
|
|
3
|
+
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierNotFoundError, ZapierUnknownError } from "../../../types/errors";
|
|
4
|
+
export declare const DeleteTableOptionsSchema: z.ZodObject<{
|
|
5
|
+
tableId: z.ZodString;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export type DeleteTableOptions = z.infer<typeof DeleteTableOptionsSchema> & FunctionOptions;
|
|
8
|
+
export interface DeleteTableResult {
|
|
9
|
+
success: boolean;
|
|
10
|
+
}
|
|
11
|
+
export type DeleteTableError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierNotFoundError | ZapierUnknownError;
|
|
12
|
+
export interface DeleteTableSdkFunction {
|
|
13
|
+
deleteTable: (options: DeleteTableOptions) => Promise<DeleteTableResult>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTable/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,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,wBAAwB;;iBAOE,CAAC;AAExC,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,GACvE,eAAe,CAAC;AAGlB,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;CAClB;AAGD,MAAM,MAAM,gBAAgB,GACxB,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,mBAAmB,GACnB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC1E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const DeleteTableOptionsSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
tableId: z
|
|
5
|
+
.string()
|
|
6
|
+
.regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID")
|
|
7
|
+
.describe("The unique identifier of the table to delete"),
|
|
8
|
+
})
|
|
9
|
+
.describe("Delete a table by its ID");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Plugin } from "../../../types/plugin";
|
|
2
|
+
import type { ApiClient } from "../../../api";
|
|
3
|
+
import { DeleteTableFieldsOptionsSchema, type DeleteTableFieldsOptions, type DeleteTableFieldsResult } from "./schemas";
|
|
4
|
+
import type { EventEmissionContext } from "../../eventEmission";
|
|
5
|
+
export interface DeleteTableFieldsPluginProvides {
|
|
6
|
+
deleteTableFields: (options: DeleteTableFieldsOptions) => Promise<DeleteTableFieldsResult>;
|
|
7
|
+
context: {
|
|
8
|
+
meta: {
|
|
9
|
+
deleteTableFields: {
|
|
10
|
+
inputSchema: typeof DeleteTableFieldsOptionsSchema;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare const deleteTableFieldsPlugin: Plugin<{}, {
|
|
16
|
+
api: ApiClient;
|
|
17
|
+
} & EventEmissionContext, DeleteTableFieldsPluginProvides>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTableFields/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EACL,8BAA8B,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC7B,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAMhE,MAAM,WAAW,+BAA+B;IAC9C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACtC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,iBAAiB,EAAE;gBACjB,WAAW,EAAE,OAAO,8BAA8B,CAAC;aACpD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,EAAE,EACF;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EACzC,+BAA+B,CAoEhC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createFunction } from "../../../utils/function-utils";
|
|
2
|
+
import { DeleteTableFieldsOptionsSchema, } from "./schemas";
|
|
3
|
+
import { createTelemetryCallback } from "../../../utils/telemetry-utils";
|
|
4
|
+
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
5
|
+
import { tableIdResolver, tableFieldIdsResolver } from "../../../resolvers";
|
|
6
|
+
import { resolveFieldKeys } from "../utils";
|
|
7
|
+
export const deleteTableFieldsPlugin = ({ context }) => {
|
|
8
|
+
async function deleteTableFields(options) {
|
|
9
|
+
const { api } = context;
|
|
10
|
+
const numericFieldIds = await resolveFieldKeys({
|
|
11
|
+
api,
|
|
12
|
+
tableId: options.tableId,
|
|
13
|
+
fieldKeys: options.fieldKeys,
|
|
14
|
+
});
|
|
15
|
+
await api.delete(`/tables/api/v1/tables/${options.tableId}/fields`, { field_ids: numericFieldIds }, {
|
|
16
|
+
customErrorHandler: ({ status }) => {
|
|
17
|
+
if (status === 401) {
|
|
18
|
+
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to delete fields or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
19
|
+
}
|
|
20
|
+
if (status === 403) {
|
|
21
|
+
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to delete fields. (HTTP ${status})`, { statusCode: status });
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
},
|
|
25
|
+
authRequired: true,
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
success: true,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const deleteTableFieldsDefinition = createFunction(deleteTableFields, DeleteTableFieldsOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, deleteTableFields.name));
|
|
32
|
+
return {
|
|
33
|
+
deleteTableFields: deleteTableFieldsDefinition,
|
|
34
|
+
context: {
|
|
35
|
+
meta: {
|
|
36
|
+
deleteTableFields: {
|
|
37
|
+
categories: ["table"],
|
|
38
|
+
type: "delete",
|
|
39
|
+
itemType: "Field",
|
|
40
|
+
inputSchema: DeleteTableFieldsOptionsSchema,
|
|
41
|
+
resolvers: {
|
|
42
|
+
tableId: tableIdResolver,
|
|
43
|
+
fieldKeys: tableFieldIdsResolver,
|
|
44
|
+
},
|
|
45
|
+
confirm: "delete",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { FunctionOptions } from "../../../types/functions";
|
|
3
|
+
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierNotFoundError, ZapierUnknownError } from "../../../types/errors";
|
|
4
|
+
export declare const DeleteTableFieldsOptionsSchema: z.ZodObject<{
|
|
5
|
+
tableId: z.ZodString;
|
|
6
|
+
fieldKeys: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type DeleteTableFieldsOptions = z.infer<typeof DeleteTableFieldsOptionsSchema> & FunctionOptions;
|
|
9
|
+
export interface DeleteTableFieldsResult {
|
|
10
|
+
success: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type DeleteTableFieldsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierNotFoundError | ZapierUnknownError;
|
|
13
|
+
export interface DeleteTableFieldsSdkFunction {
|
|
14
|
+
deleteTableFields: (options: DeleteTableFieldsOptions) => Promise<DeleteTableFieldsResult>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTableFields/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,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,8BAA8B;;;iBAaU,CAAC;AAEtD,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,GACC,eAAe,CAAC;AAGlB,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,CAAC;CAClB;AAGD,MAAM,MAAM,sBAAsB,GAC9B,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,mBAAmB,GACnB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACvC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const DeleteTableFieldsOptionsSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
tableId: z
|
|
5
|
+
.string()
|
|
6
|
+
.regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID")
|
|
7
|
+
.describe("The unique identifier of the table"),
|
|
8
|
+
fieldKeys: z
|
|
9
|
+
.array(z.union([z.string(), z.number()]))
|
|
10
|
+
.min(1)
|
|
11
|
+
.describe('Fields to delete. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'),
|
|
12
|
+
})
|
|
13
|
+
.describe("Delete one or more fields from a table");
|