@zapier/zapier-sdk 0.34.0 → 0.35.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/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 +1828 -35
- package/dist/index.d.mts +644 -70
- 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 +1807 -36
- package/dist/plugins/apps/schemas.d.ts +11 -11
- package/dist/plugins/apps/schemas.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.js +1 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +4 -0
- 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 +95 -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 +83 -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/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 +2 -2
|
@@ -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;AAqBhE,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,CAoFzB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createPaginatedFunction } from "../../../utils/function-utils";
|
|
2
|
+
import { ListTablesApiResponseSchema, ListTablesOptionsSchema, TableItemSchema, } from "./schemas";
|
|
3
|
+
import { createTelemetryCallback } from "../../../utils/telemetry-utils";
|
|
4
|
+
import { stripPageSuffix } from "../../../utils/string-utils";
|
|
5
|
+
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
6
|
+
import { transformTableItem } from "../utils";
|
|
7
|
+
function extractNextCursor(links) {
|
|
8
|
+
if (!links?.next) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const url = new URL(links.next);
|
|
13
|
+
const offset = url.searchParams.get("offset");
|
|
14
|
+
return offset || undefined;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export const listTablesPlugin = ({ context }) => {
|
|
21
|
+
async function listTablesPage(options) {
|
|
22
|
+
const { api } = context;
|
|
23
|
+
const searchParams = {
|
|
24
|
+
limit: options.pageSize.toString(),
|
|
25
|
+
};
|
|
26
|
+
if (options?.tableIds && options.tableIds.length > 0) {
|
|
27
|
+
searchParams.ids = options.tableIds.join(",");
|
|
28
|
+
}
|
|
29
|
+
if (options?.kind) {
|
|
30
|
+
searchParams.kind = options.kind;
|
|
31
|
+
}
|
|
32
|
+
if (options?.search) {
|
|
33
|
+
searchParams.q = options.search;
|
|
34
|
+
}
|
|
35
|
+
if (options?.owner) {
|
|
36
|
+
let ownerId = options.owner;
|
|
37
|
+
if (ownerId === "me") {
|
|
38
|
+
const profile = await api.get("/zapier/api/v4/profile/", {
|
|
39
|
+
authRequired: true,
|
|
40
|
+
});
|
|
41
|
+
ownerId = String(profile.id);
|
|
42
|
+
}
|
|
43
|
+
searchParams.owner_customuser_id = ownerId;
|
|
44
|
+
}
|
|
45
|
+
if (options.cursor) {
|
|
46
|
+
searchParams.offset = options.cursor;
|
|
47
|
+
}
|
|
48
|
+
const rawResponse = await api.get("/tables/api/v1/tables", {
|
|
49
|
+
searchParams,
|
|
50
|
+
customErrorHandler: ({ status }) => {
|
|
51
|
+
if (status === 401) {
|
|
52
|
+
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to list tables or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
53
|
+
}
|
|
54
|
+
if (status === 403) {
|
|
55
|
+
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to list tables. (HTTP ${status})`, { statusCode: status });
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
},
|
|
59
|
+
authRequired: true,
|
|
60
|
+
});
|
|
61
|
+
const response = ListTablesApiResponseSchema.parse(rawResponse);
|
|
62
|
+
return {
|
|
63
|
+
data: response.data.map(transformTableItem),
|
|
64
|
+
nextCursor: extractNextCursor(response.links),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const methodName = stripPageSuffix(listTablesPage.name);
|
|
68
|
+
const listTablesDefinition = createPaginatedFunction(listTablesPage, ListTablesOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
|
|
69
|
+
return {
|
|
70
|
+
listTables: listTablesDefinition,
|
|
71
|
+
context: {
|
|
72
|
+
meta: {
|
|
73
|
+
listTables: {
|
|
74
|
+
categories: ["table"],
|
|
75
|
+
type: "list",
|
|
76
|
+
itemType: "Table",
|
|
77
|
+
inputSchema: ListTablesOptionsSchema,
|
|
78
|
+
outputSchema: TableItemSchema,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { PaginatedSdkFunction } from "../../../types/functions";
|
|
3
|
+
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
|
|
4
|
+
export declare const TableApiItemSchema: z.ZodObject<{
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8
|
+
created_at: z.ZodString;
|
|
9
|
+
edited_at: z.ZodString;
|
|
10
|
+
kind: z.ZodEnum<{
|
|
11
|
+
table: "table";
|
|
12
|
+
virtual_table: "virtual_table";
|
|
13
|
+
}>;
|
|
14
|
+
owner_account_id: z.ZodNumber;
|
|
15
|
+
owner_user_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
16
|
+
owner_zapier_customuser_id: z.ZodNumber;
|
|
17
|
+
parent_table_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type TableApiItem = z.infer<typeof TableApiItemSchema>;
|
|
20
|
+
export declare const ListTablesApiResponseSchema: z.ZodObject<{
|
|
21
|
+
data: z.ZodArray<z.ZodObject<{
|
|
22
|
+
id: z.ZodString;
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
25
|
+
created_at: z.ZodString;
|
|
26
|
+
edited_at: z.ZodString;
|
|
27
|
+
kind: z.ZodEnum<{
|
|
28
|
+
table: "table";
|
|
29
|
+
virtual_table: "virtual_table";
|
|
30
|
+
}>;
|
|
31
|
+
owner_account_id: z.ZodNumber;
|
|
32
|
+
owner_user_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
33
|
+
owner_zapier_customuser_id: z.ZodNumber;
|
|
34
|
+
parent_table_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
35
|
+
}, z.core.$strip>>;
|
|
36
|
+
links: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
next: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
38
|
+
}, z.core.$strip>>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export type ListTablesApiResponse = z.infer<typeof ListTablesApiResponseSchema>;
|
|
41
|
+
export declare const TableItemSchema: z.ZodObject<{
|
|
42
|
+
id: z.ZodString;
|
|
43
|
+
name: z.ZodString;
|
|
44
|
+
description: z.ZodOptional<z.ZodString>;
|
|
45
|
+
created_at: z.ZodString;
|
|
46
|
+
edited_at: z.ZodString;
|
|
47
|
+
kind: z.ZodEnum<{
|
|
48
|
+
table: "table";
|
|
49
|
+
virtual_table: "virtual_table";
|
|
50
|
+
}>;
|
|
51
|
+
owner_account_id: z.ZodString;
|
|
52
|
+
profile_id: z.ZodString;
|
|
53
|
+
parent_table_id: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
export type TableItem = z.infer<typeof TableItemSchema>;
|
|
56
|
+
export declare const ListTablesOptionsSchema: z.ZodObject<{
|
|
57
|
+
tableIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
58
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
59
|
+
table: "table";
|
|
60
|
+
virtual_table: "virtual_table";
|
|
61
|
+
both: "both";
|
|
62
|
+
}>>;
|
|
63
|
+
search: z.ZodOptional<z.ZodString>;
|
|
64
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
65
|
+
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
66
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
export type ListTablesOptions = z.infer<typeof ListTablesOptionsSchema>;
|
|
70
|
+
export interface ListTablesPage {
|
|
71
|
+
data: TableItem[];
|
|
72
|
+
nextCursor?: string;
|
|
73
|
+
}
|
|
74
|
+
export type ListTablesError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
75
|
+
export interface ListTablesSdkFunction {
|
|
76
|
+
listTables: PaginatedSdkFunction<ListTablesOptions, TableItem>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTables/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;AAE/B,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;iBAW7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;iBAOtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,eAAe;;;;;;;;;;;;;iBAU1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;iBAgC0B,CAAC;AAE/D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAGxE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,MAAM,eAAe,GACvB,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,oBAAoB,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;CAChE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const TableApiItemSchema = z.object({
|
|
3
|
+
id: z.string(),
|
|
4
|
+
name: z.string(),
|
|
5
|
+
description: z.string().nullable().optional(),
|
|
6
|
+
created_at: z.string(),
|
|
7
|
+
edited_at: z.string(),
|
|
8
|
+
kind: z.enum(["table", "virtual_table"]),
|
|
9
|
+
owner_account_id: z.number(),
|
|
10
|
+
owner_user_id: z.number().nullable().optional(),
|
|
11
|
+
owner_zapier_customuser_id: z.number(),
|
|
12
|
+
parent_table_id: z.string().nullable().optional(),
|
|
13
|
+
});
|
|
14
|
+
export const ListTablesApiResponseSchema = z.object({
|
|
15
|
+
data: z.array(TableApiItemSchema),
|
|
16
|
+
links: z
|
|
17
|
+
.object({
|
|
18
|
+
next: z.string().nullable().optional(),
|
|
19
|
+
})
|
|
20
|
+
.optional(),
|
|
21
|
+
});
|
|
22
|
+
export const TableItemSchema = z.object({
|
|
23
|
+
id: z.string(),
|
|
24
|
+
name: z.string(),
|
|
25
|
+
description: z.string().optional(),
|
|
26
|
+
created_at: z.string(),
|
|
27
|
+
edited_at: z.string(),
|
|
28
|
+
kind: z.enum(["table", "virtual_table"]),
|
|
29
|
+
owner_account_id: z.string(),
|
|
30
|
+
profile_id: z.string(),
|
|
31
|
+
parent_table_id: z.string().optional(),
|
|
32
|
+
});
|
|
33
|
+
export const ListTablesOptionsSchema = z
|
|
34
|
+
.object({
|
|
35
|
+
tableIds: z
|
|
36
|
+
.array(z.string())
|
|
37
|
+
.optional()
|
|
38
|
+
.describe("Filter by specific table IDs"),
|
|
39
|
+
kind: z
|
|
40
|
+
.enum(["table", "virtual_table", "both"])
|
|
41
|
+
.optional()
|
|
42
|
+
.describe("Filter by table type"),
|
|
43
|
+
search: z
|
|
44
|
+
.string()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe("Search term to filter tables by name"),
|
|
47
|
+
owner: z
|
|
48
|
+
.string()
|
|
49
|
+
.optional()
|
|
50
|
+
.describe('Filter by table owner. Use "me" for the current user, or a numeric user ID.'),
|
|
51
|
+
pageSize: z
|
|
52
|
+
.number()
|
|
53
|
+
.min(1)
|
|
54
|
+
.optional()
|
|
55
|
+
.describe("Number of tables per page"),
|
|
56
|
+
maxItems: z
|
|
57
|
+
.number()
|
|
58
|
+
.min(1)
|
|
59
|
+
.optional()
|
|
60
|
+
.describe("Maximum total items to return across all pages"),
|
|
61
|
+
cursor: z.string().optional().describe("Cursor to start from"),
|
|
62
|
+
})
|
|
63
|
+
.describe("List tables available to the authenticated user");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Plugin } from "../../../types/plugin";
|
|
2
|
+
import type { ApiClient } from "../../../api";
|
|
3
|
+
import { UpdateTableRecordsOptionsSchema, type UpdateTableRecordsOptions, type UpdateTableRecordsResult } from "./schemas";
|
|
4
|
+
import type { EventEmissionContext } from "../../eventEmission";
|
|
5
|
+
export interface UpdateTableRecordsPluginProvides {
|
|
6
|
+
updateTableRecords: (options: UpdateTableRecordsOptions) => Promise<UpdateTableRecordsResult>;
|
|
7
|
+
context: {
|
|
8
|
+
meta: {
|
|
9
|
+
updateTableRecords: {
|
|
10
|
+
inputSchema: typeof UpdateTableRecordsOptionsSchema;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare const updateTableRecordsPlugin: Plugin<{}, {
|
|
16
|
+
api: ApiClient;
|
|
17
|
+
} & EventEmissionContext, UpdateTableRecordsPluginProvides>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/updateTableRecords/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;AAehE,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,CAuFjC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createFunction } from "../../../utils/function-utils";
|
|
2
|
+
import { UpdateTableRecordsOptionsSchema, UpdateTableRecordsApiResponseSchema, RecordItemSchema, } from "./schemas";
|
|
3
|
+
import { createTelemetryCallback } from "../../../utils/telemetry-utils";
|
|
4
|
+
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
5
|
+
import { tableIdResolver, tableUpdateRecordsResolver, } from "../../../resolvers";
|
|
6
|
+
import { tableRecordFormatter } from "../../../formatters";
|
|
7
|
+
import { createFieldKeyTranslator, transformRecordItem, throwOnRecordErrors, throwOnResponseErrors, } from "../utils";
|
|
8
|
+
export const updateTableRecordsPlugin = ({ context }) => {
|
|
9
|
+
async function updateTableRecords(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.patch(`/tables/api/v1/tables/${options.tableId}/records`, {
|
|
17
|
+
updated_records: options.records.map((record) => ({
|
|
18
|
+
id: record.id,
|
|
19
|
+
data: translator.translateInput(record.data),
|
|
20
|
+
})),
|
|
21
|
+
}, {
|
|
22
|
+
customErrorHandler: ({ status }) => {
|
|
23
|
+
if (status === 401) {
|
|
24
|
+
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to update records or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
25
|
+
}
|
|
26
|
+
if (status === 403) {
|
|
27
|
+
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to update records. (HTTP ${status})`, { statusCode: status });
|
|
28
|
+
}
|
|
29
|
+
if (status === 404) {
|
|
30
|
+
return new Error(`Table not found: ${options.tableId}`);
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
},
|
|
34
|
+
authRequired: true,
|
|
35
|
+
});
|
|
36
|
+
throwOnResponseErrors(rawResponse);
|
|
37
|
+
const response = UpdateTableRecordsApiResponseSchema.parse(rawResponse);
|
|
38
|
+
for (const changeset of response.data) {
|
|
39
|
+
throwOnRecordErrors(changeset.new);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
data: response.data.map((changeset) => ({
|
|
43
|
+
...transformRecordItem(changeset.new),
|
|
44
|
+
data: translator.translateOutput(changeset.new.data),
|
|
45
|
+
})),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const updateTableRecordsDefinition = createFunction(updateTableRecords, UpdateTableRecordsOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, updateTableRecords.name));
|
|
49
|
+
return {
|
|
50
|
+
updateTableRecords: updateTableRecordsDefinition,
|
|
51
|
+
context: {
|
|
52
|
+
meta: {
|
|
53
|
+
updateTableRecords: {
|
|
54
|
+
categories: ["table"],
|
|
55
|
+
type: "update",
|
|
56
|
+
itemType: "Record",
|
|
57
|
+
inputSchema: UpdateTableRecordsOptionsSchema,
|
|
58
|
+
outputSchema: RecordItemSchema,
|
|
59
|
+
resolvers: {
|
|
60
|
+
tableId: tableIdResolver,
|
|
61
|
+
records: tableUpdateRecordsResolver,
|
|
62
|
+
},
|
|
63
|
+
formatter: tableRecordFormatter,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
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 UpdateTableRecordsApiResponseSchema: 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 UpdateTableRecordsApiResponse = z.infer<typeof UpdateTableRecordsApiResponseSchema>;
|
|
35
|
+
export declare const UpdateRecordSchema: z.ZodObject<{
|
|
36
|
+
id: z.ZodString;
|
|
37
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export type UpdateRecord = z.infer<typeof UpdateRecordSchema>;
|
|
40
|
+
export declare const UpdateTableRecordsOptionsSchema: z.ZodObject<{
|
|
41
|
+
tableId: z.ZodString;
|
|
42
|
+
records: z.ZodArray<z.ZodObject<{
|
|
43
|
+
id: z.ZodString;
|
|
44
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
keyMode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
47
|
+
names: "names";
|
|
48
|
+
ids: "ids";
|
|
49
|
+
}>>>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
export type UpdateTableRecordsOptions = z.infer<typeof UpdateTableRecordsOptionsSchema> & FunctionOptions;
|
|
52
|
+
export interface UpdateTableRecordsResult {
|
|
53
|
+
data: RecordItem[];
|
|
54
|
+
}
|
|
55
|
+
export type UpdateTableRecordsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
56
|
+
export interface UpdateTableRecordsSdkFunction {
|
|
57
|
+
updateTableRecords: (options: UpdateTableRecordsOptions) => Promise<UpdateTableRecordsResult>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/updateTableRecords/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;AAU3B,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;iBAE9C,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CACjD,OAAO,mCAAmC,CAC3C,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;iBAK7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,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
|
+
const RecordChangesetSchema = z.object({
|
|
7
|
+
change_id: z.string(),
|
|
8
|
+
old: RecordApiItemSchema.nullable(),
|
|
9
|
+
new: RecordApiItemSchema,
|
|
10
|
+
changed_field_ids: z.array(z.number()).nullable(),
|
|
11
|
+
record_id: z.string(),
|
|
12
|
+
});
|
|
13
|
+
export const UpdateTableRecordsApiResponseSchema = z.object({
|
|
14
|
+
data: z.array(RecordChangesetSchema),
|
|
15
|
+
});
|
|
16
|
+
export const UpdateRecordSchema = z.object({
|
|
17
|
+
id: z.string().describe("The record ID to update"),
|
|
18
|
+
data: z
|
|
19
|
+
.record(z.string(), z.unknown())
|
|
20
|
+
.describe("The field values to update, keyed by field key"),
|
|
21
|
+
});
|
|
22
|
+
export const UpdateTableRecordsOptionsSchema = 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(UpdateRecordSchema)
|
|
30
|
+
.min(1)
|
|
31
|
+
.max(100)
|
|
32
|
+
.describe("Array of records to update (max 100)"),
|
|
33
|
+
keyMode: KeyModeSchema,
|
|
34
|
+
})
|
|
35
|
+
.describe("Update one or more records in a table");
|