@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
|
@@ -23,18 +23,18 @@ interface BaseActionTypeProxy {
|
|
|
23
23
|
items(): AsyncIterable<any>;
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
type ActionTypeProxy = BaseActionTypeProxy & Partial<FetchActionType>;
|
|
35
|
-
interface AppProxy {
|
|
26
|
+
type ActionTypeProxy = BaseActionTypeProxy;
|
|
27
|
+
type AppFetchFn = (url: string | URL, init?: RequestInit & {
|
|
28
|
+
connectionId?: ConnectionIdProperty;
|
|
29
|
+
/** @deprecated Use connectionId instead */
|
|
30
|
+
authenticationId?: AuthenticationIdProperty;
|
|
31
|
+
callbackUrl?: string;
|
|
32
|
+
}) => Promise<Response>;
|
|
33
|
+
type AppProxy = {
|
|
36
34
|
[type: string]: ActionTypeProxy;
|
|
37
|
-
}
|
|
35
|
+
} & {
|
|
36
|
+
fetch: AppFetchFn;
|
|
37
|
+
};
|
|
38
38
|
interface AppFactory {
|
|
39
39
|
(options: AppFactoryInput): AppProxy;
|
|
40
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/apps/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC9B,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,0BAA0B;;;;;iBAUpC,CAAC;AAGJ,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEhF,eAAO,MAAM,qBAAqB;;;iBAMW,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAGpE,UAAU,mBAAmB;IAC3B,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC;QAC9D,IAAI,EAAE,GAAG,EAAE,CAAC;QACZ,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,GAAG,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACpD,KAAK,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC;KAC7B,CAAC;CACL;AAGD,
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/apps/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC9B,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,0BAA0B;;;;;iBAUpC,CAAC;AAGJ,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEhF,eAAO,MAAM,qBAAqB;;;iBAMW,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAGpE,UAAU,mBAAmB;IAC3B,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC;QAC9D,IAAI,EAAE,GAAG,EAAE,CAAC;QACZ,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,GAAG,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACpD,KAAK,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC;KAC7B,CAAC;CACL;AAGD,KAAK,eAAe,GAAG,mBAAmB,CAAC;AAG3C,KAAK,UAAU,GAAG,CAChB,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,CAAC,EAAE,WAAW,GAAG;IACnB,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,2CAA2C;IAC3C,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,KACE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,KAAK,QAAQ,GAAG;IACd,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;CACjC,GAAG;IACF,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,UAAU,UAAU;IAClB,CAAC,OAAO,EAAE,eAAe,GAAG,QAAQ,CAAC;CACtC;AAGD,KAAK,mBAAmB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAAC;CACpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/deleteClientCredentials/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,6BAA6B,EAC7B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EACnC,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAK7D,MAAM,WAAW,qCAAqC;IACpD,uBAAuB,EAAE,CACvB,OAAO,EAAE,8BAA8B,KACpC,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC5C,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,uBAAuB,EAAE;gBACvB,WAAW,EAAE,OAAO,6BAA6B,CAAC;aACnD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAChD,EAAE,EACF;IACE,GAAG,EAAE,SAAS,CAAC;CAChB,GAAG,oBAAoB,EACxB,qCAAqC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/deleteClientCredentials/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,6BAA6B,EAC7B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EACnC,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAK7D,MAAM,WAAW,qCAAqC;IACpD,uBAAuB,EAAE,CACvB,OAAO,EAAE,8BAA8B,KACpC,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC5C,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,uBAAuB,EAAE;gBACvB,WAAW,EAAE,OAAO,6BAA6B,CAAC;aACnD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAChD,EAAE,EACF;IACE,GAAG,EAAE,SAAS,CAAC;CAChB,GAAG,oBAAoB,EACxB,qCAAqC,CA6DtC,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { clientIdResolver } from "../../resolvers";
|
|
|
6
6
|
export const deleteClientCredentialsPlugin = ({ context }) => {
|
|
7
7
|
async function deleteClientCredentials(options) {
|
|
8
8
|
const { api } = context;
|
|
9
|
-
await api.delete(`/api/v0/client-credentials/${options.clientId}`, {
|
|
9
|
+
await api.delete(`/api/v0/client-credentials/${options.clientId}`, undefined, {
|
|
10
10
|
customErrorHandler: ({ status }) => {
|
|
11
11
|
if (status === 401) {
|
|
12
12
|
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to delete client credentials or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,6BAA6B;CAAG;AAEjD,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK;QAC/C,SAAS,EAAE,qBAAqB,EAAE,CAAC;QACnC,UAAU,EAAE;YACV,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,EAAE,MAAM,CAAC;YACd,WAAW,EAAE,MAAM,CAAC;YACpB,SAAS,EAAE,MAAM,EAAE,CAAC;SACrB,EAAE,CAAC;KACL,CAAC;CACH;AAGD,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EAAE,wBAAwB;AAC5B,EAAE,EAAE,sBAAsB;AAC1B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,6BAA6B;CAAG;AAEjD,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK;QAC/C,SAAS,EAAE,qBAAqB,EAAE,CAAC;QACnC,UAAU,EAAE;YACV,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,EAAE,MAAM,CAAC;YACd,WAAW,EAAE,MAAM,CAAC;YACpB,SAAS,EAAE,MAAM,EAAE,CAAC;SACrB,EAAE,CAAC;KACL,CAAC;CACH;AAGD,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EAAE,wBAAwB;AAC5B,EAAE,EAAE,sBAAsB;AAC1B,sBAAsB,CA0JvB,CAAC"}
|
|
@@ -19,6 +19,9 @@ export const registryPlugin = ({ sdk, context }) => {
|
|
|
19
19
|
title: "Client Credentials",
|
|
20
20
|
titlePlural: "Client Credentials",
|
|
21
21
|
},
|
|
22
|
+
table: {
|
|
23
|
+
title: "Table",
|
|
24
|
+
},
|
|
22
25
|
http: {
|
|
23
26
|
title: "HTTP Request",
|
|
24
27
|
},
|
|
@@ -56,6 +59,7 @@ export const registryPlugin = ({ sdk, context }) => {
|
|
|
56
59
|
outputSchema: meta.outputSchema,
|
|
57
60
|
categories: meta.categories || [],
|
|
58
61
|
resolvers: meta.resolvers,
|
|
62
|
+
formatter: meta.formatter,
|
|
59
63
|
packages: meta.packages,
|
|
60
64
|
// Auto-infer confirm: "delete" from type: "delete" (all deletes should confirm)
|
|
61
65
|
confirm: meta.confirm ?? (meta.type === "delete" ? "delete" : undefined),
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Plugin } from "../../../types/plugin";
|
|
2
|
+
import type { ApiClient } from "../../../api";
|
|
3
|
+
import { CreateTableOptionsSchema, type CreateTableOptions, type CreateTableResult } from "./schemas";
|
|
4
|
+
import type { EventEmissionContext } from "../../eventEmission";
|
|
5
|
+
export interface CreateTablePluginProvides {
|
|
6
|
+
createTable: (options: CreateTableOptions) => Promise<CreateTableResult>;
|
|
7
|
+
context: {
|
|
8
|
+
meta: {
|
|
9
|
+
createTable: {
|
|
10
|
+
inputSchema: typeof CreateTableOptionsSchema;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare const createTablePlugin: Plugin<{}, {
|
|
16
|
+
api: ApiClient;
|
|
17
|
+
} & EventEmissionContext, CreateTablePluginProvides>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/createTable/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,EAGxB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAMhE,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,CAkE1B,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createFunction } from "../../../utils/function-utils";
|
|
2
|
+
import { CreateTableOptionsSchema, CreateTableApiResponseSchema, TableItemSchema, } from "./schemas";
|
|
3
|
+
import { createTelemetryCallback } from "../../../utils/telemetry-utils";
|
|
4
|
+
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
5
|
+
import { tableNameResolver } from "../../../resolvers";
|
|
6
|
+
import { transformTableItem } from "../utils";
|
|
7
|
+
export const createTablePlugin = ({ context }) => {
|
|
8
|
+
async function createTable(options) {
|
|
9
|
+
const { api } = context;
|
|
10
|
+
const rawResponse = await api.post("/tables/api/v1/tables", {
|
|
11
|
+
name: options.name,
|
|
12
|
+
description: options.description,
|
|
13
|
+
}, {
|
|
14
|
+
customErrorHandler: ({ status }) => {
|
|
15
|
+
if (status === 401) {
|
|
16
|
+
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to create tables or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
17
|
+
}
|
|
18
|
+
if (status === 403) {
|
|
19
|
+
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to create tables. (HTTP ${status})`, { statusCode: status });
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
},
|
|
23
|
+
authRequired: true,
|
|
24
|
+
});
|
|
25
|
+
const response = CreateTableApiResponseSchema.parse(rawResponse);
|
|
26
|
+
return {
|
|
27
|
+
data: transformTableItem(response.data),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const createTableDefinition = createFunction(createTable, CreateTableOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, createTable.name));
|
|
31
|
+
return {
|
|
32
|
+
createTable: createTableDefinition,
|
|
33
|
+
context: {
|
|
34
|
+
meta: {
|
|
35
|
+
createTable: {
|
|
36
|
+
categories: ["table"],
|
|
37
|
+
type: "create",
|
|
38
|
+
itemType: "Table",
|
|
39
|
+
inputSchema: CreateTableOptionsSchema,
|
|
40
|
+
outputSchema: TableItemSchema,
|
|
41
|
+
resolvers: {
|
|
42
|
+
name: tableNameResolver,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { FunctionOptions } from "../../../types/functions";
|
|
3
|
+
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
|
|
4
|
+
import { TableItemSchema, TableApiItemSchema, type TableItem, type TableApiItem } from "../listTables/schemas";
|
|
5
|
+
export { TableItemSchema, TableApiItemSchema };
|
|
6
|
+
export type { TableItem, TableApiItem };
|
|
7
|
+
export declare const CreateTableApiResponseSchema: z.ZodObject<{
|
|
8
|
+
data: z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
12
|
+
created_at: z.ZodString;
|
|
13
|
+
edited_at: z.ZodString;
|
|
14
|
+
kind: z.ZodEnum<{
|
|
15
|
+
table: "table";
|
|
16
|
+
virtual_table: "virtual_table";
|
|
17
|
+
}>;
|
|
18
|
+
owner_account_id: z.ZodNumber;
|
|
19
|
+
owner_user_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
20
|
+
owner_zapier_customuser_id: z.ZodNumber;
|
|
21
|
+
parent_table_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export type CreateTableApiResponse = z.infer<typeof CreateTableApiResponseSchema>;
|
|
25
|
+
export declare const CreateTableOptionsSchema: z.ZodObject<{
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
description: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type CreateTableOptions = z.infer<typeof CreateTableOptionsSchema> & FunctionOptions;
|
|
30
|
+
export interface CreateTableResult {
|
|
31
|
+
data: TableItem;
|
|
32
|
+
}
|
|
33
|
+
export type CreateTableError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
34
|
+
export interface CreateTableSdkFunction {
|
|
35
|
+
createTable: (options: CreateTableOptions) => Promise<CreateTableResult>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/createTable/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,EACf,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;AAExC,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;iBAEvC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAC1C,OAAO,4BAA4B,CACpC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;iBAQJ,CAAC;AAElC,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,GACvE,eAAe,CAAC;AAGlB,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,SAAS,CAAC;CACjB;AAGD,MAAM,MAAM,gBAAgB,GACxB,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC1E"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { TableItemSchema, TableApiItemSchema, } from "../listTables/schemas";
|
|
3
|
+
// Re-export for consumers
|
|
4
|
+
export { TableItemSchema, TableApiItemSchema };
|
|
5
|
+
export const CreateTableApiResponseSchema = z.object({
|
|
6
|
+
data: TableApiItemSchema,
|
|
7
|
+
});
|
|
8
|
+
export const CreateTableOptionsSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
name: z.string().min(1).describe("The name for the new table"),
|
|
11
|
+
description: z
|
|
12
|
+
.string()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("An optional description of the table"),
|
|
15
|
+
})
|
|
16
|
+
.describe("Create a new table");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Plugin } from "../../../types/plugin";
|
|
2
|
+
import type { ApiClient } from "../../../api";
|
|
3
|
+
import { CreateTableFieldsOptionsSchema, type CreateTableFieldsOptions, type CreateTableFieldsResult } from "./schemas";
|
|
4
|
+
import type { EventEmissionContext } from "../../eventEmission";
|
|
5
|
+
export interface CreateTableFieldsPluginProvides {
|
|
6
|
+
createTableFields: (options: CreateTableFieldsOptions) => Promise<CreateTableFieldsResult>;
|
|
7
|
+
context: {
|
|
8
|
+
meta: {
|
|
9
|
+
createTableFields: {
|
|
10
|
+
inputSchema: typeof CreateTableFieldsOptionsSchema;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare const createTableFieldsPlugin: Plugin<{}, {
|
|
16
|
+
api: ApiClient;
|
|
17
|
+
} & EventEmissionContext, CreateTableFieldsPluginProvides>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/createTableFields/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,EAG9B,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,CAmEhC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createFunction } from "../../../utils/function-utils";
|
|
2
|
+
import { CreateTableFieldsOptionsSchema, CreateTableFieldsApiResponseSchema, FieldItemSchema, } from "./schemas";
|
|
3
|
+
import { createTelemetryCallback } from "../../../utils/telemetry-utils";
|
|
4
|
+
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
5
|
+
import { tableIdResolver, tableFieldsResolver } from "../../../resolvers";
|
|
6
|
+
import { transformFieldItem } from "../utils";
|
|
7
|
+
export const createTableFieldsPlugin = ({ context }) => {
|
|
8
|
+
async function createTableFields(options) {
|
|
9
|
+
const { api } = context;
|
|
10
|
+
const rawResponse = await api.post(`/tables/api/v1/tables/${options.tableId}/fields`, {
|
|
11
|
+
new_fields: options.fields,
|
|
12
|
+
}, {
|
|
13
|
+
customErrorHandler: ({ status }) => {
|
|
14
|
+
if (status === 401) {
|
|
15
|
+
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to create fields or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
16
|
+
}
|
|
17
|
+
if (status === 403) {
|
|
18
|
+
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to create fields. (HTTP ${status})`, { statusCode: status });
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
},
|
|
22
|
+
authRequired: true,
|
|
23
|
+
});
|
|
24
|
+
const response = CreateTableFieldsApiResponseSchema.parse(rawResponse);
|
|
25
|
+
// Extract the 'new' field from each changeset item
|
|
26
|
+
return {
|
|
27
|
+
data: response.data.map((changeset) => transformFieldItem(changeset.new)),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const createTableFieldsDefinition = createFunction(createTableFields, CreateTableFieldsOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, createTableFields.name));
|
|
31
|
+
return {
|
|
32
|
+
createTableFields: createTableFieldsDefinition,
|
|
33
|
+
context: {
|
|
34
|
+
meta: {
|
|
35
|
+
createTableFields: {
|
|
36
|
+
categories: ["table"],
|
|
37
|
+
type: "create",
|
|
38
|
+
itemType: "Field",
|
|
39
|
+
inputSchema: CreateTableFieldsOptionsSchema,
|
|
40
|
+
outputSchema: FieldItemSchema,
|
|
41
|
+
resolvers: {
|
|
42
|
+
tableId: tableIdResolver,
|
|
43
|
+
fields: tableFieldsResolver,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -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
|
+
};
|