@zapier/zapier-sdk 0.45.2 → 0.46.1
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/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +24 -7
- package/dist/api/schemas.d.ts +5 -5
- package/dist/api/types.d.ts +17 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/auth.d.ts +27 -6
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +130 -92
- package/dist/cache.d.ts +50 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +47 -0
- package/dist/index.cjs +3108 -3695
- package/dist/index.d.mts +6735 -2188
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.mjs +3105 -3696
- package/dist/plugins/api/index.d.ts +22 -10
- package/dist/plugins/api/index.d.ts.map +1 -1
- package/dist/plugins/api/index.js +4 -4
- package/dist/plugins/apps/index.d.ts +108 -7
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/apps/index.js +3 -4
- package/dist/plugins/capabilities/index.d.ts +9 -6
- package/dist/plugins/capabilities/index.d.ts.map +1 -1
- package/dist/plugins/capabilities/index.js +3 -2
- package/dist/plugins/connections/index.d.ts +15 -9
- package/dist/plugins/connections/index.d.ts.map +1 -1
- package/dist/plugins/connections/index.js +3 -2
- package/dist/plugins/createClientCredentials/index.d.ts +26 -14
- package/dist/plugins/createClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/createClientCredentials/index.js +16 -39
- package/dist/plugins/createClientCredentials/schemas.d.ts +0 -2
- package/dist/plugins/createClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.d.ts +20 -14
- package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.js +18 -37
- package/dist/plugins/deleteClientCredentials/schemas.d.ts +0 -2
- package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/deprecated/authentications.d.ts +597 -41
- package/dist/plugins/deprecated/authentications.d.ts.map +1 -1
- package/dist/plugins/deprecated/authentications.js +9 -8
- package/dist/plugins/eventEmission/index.d.ts +9 -6
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +3 -2
- package/dist/plugins/fetch/index.d.ts +40 -17
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +6 -4
- package/dist/plugins/findFirstConnection/index.d.ts +109 -14
- package/dist/plugins/findFirstConnection/index.d.ts.map +1 -1
- package/dist/plugins/findFirstConnection/index.js +14 -26
- package/dist/plugins/findFirstConnection/schemas.d.ts +0 -2
- package/dist/plugins/findFirstConnection/schemas.d.ts.map +1 -1
- package/dist/plugins/findUniqueConnection/index.d.ts +109 -14
- package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueConnection/index.js +14 -26
- package/dist/plugins/findUniqueConnection/schemas.d.ts +0 -2
- package/dist/plugins/findUniqueConnection/schemas.d.ts.map +1 -1
- package/dist/plugins/getAction/index.d.ts +68 -15
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +21 -31
- package/dist/plugins/getAction/schemas.d.ts +4 -6
- package/dist/plugins/getAction/schemas.d.ts.map +1 -1
- package/dist/plugins/getApp/index.d.ts +140 -14
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +16 -38
- package/dist/plugins/getApp/schemas.d.ts +0 -2
- package/dist/plugins/getApp/schemas.d.ts.map +1 -1
- package/dist/plugins/getConnection/index.d.ts +50 -16
- package/dist/plugins/getConnection/index.d.ts.map +1 -1
- package/dist/plugins/getConnection/index.js +22 -29
- package/dist/plugins/getConnection/schemas.d.ts +0 -2
- package/dist/plugins/getConnection/schemas.d.ts.map +1 -1
- package/dist/plugins/getInputFieldsSchema/index.d.ts +59 -13
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/getInputFieldsSchema/index.js +21 -32
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +4 -6
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.d.ts +25 -18
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +13 -26
- package/dist/plugins/getProfile/schemas.d.ts +0 -8
- package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
- package/dist/plugins/getProfile/schemas.js +0 -1
- package/dist/plugins/listActions/index.d.ts +73 -23
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +25 -53
- package/dist/plugins/listActions/schemas.d.ts +4 -15
- package/dist/plugins/listActions/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/index.d.ts +121 -13
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +22 -31
- package/dist/plugins/listApps/schemas.d.ts +0 -2
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listClientCredentials/index.d.ts +29 -16
- package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/listClientCredentials/index.js +17 -37
- package/dist/plugins/listClientCredentials/schemas.d.ts +0 -2
- package/dist/plugins/listClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.d.ts +95 -17
- package/dist/plugins/listConnections/index.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.js +25 -49
- package/dist/plugins/listConnections/schemas.d.ts +0 -2
- package/dist/plugins/listConnections/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.d.ts +77 -22
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +27 -50
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +4 -6
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.d.ts +154 -22
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +28 -41
- package/dist/plugins/listInputFields/schemas.d.ts +4 -6
- package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/index.d.ts +40 -36
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +3 -2
- package/dist/plugins/registry/index.d.ts +11 -9
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +3 -2
- package/dist/plugins/request/index.d.ts +61 -15
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +14 -22
- package/dist/plugins/request/schemas.d.ts +0 -2
- package/dist/plugins/request/schemas.d.ts.map +1 -1
- package/dist/plugins/runAction/index.d.ts +137 -23
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +65 -78
- package/dist/plugins/runAction/schemas.d.ts +4 -14
- package/dist/plugins/runAction/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTable/index.d.ts +43 -11
- package/dist/plugins/tables/createTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTable/index.js +16 -44
- package/dist/plugins/tables/createTable/schemas.d.ts +0 -2
- package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTableFields/index.d.ts +54 -11
- package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableFields/index.js +17 -41
- package/dist/plugins/tables/createTableFields/schemas.d.ts +21 -23
- package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTableRecords/index.d.ts +47 -11
- package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableRecords/index.js +17 -43
- package/dist/plugins/tables/createTableRecords/schemas.d.ts +0 -2
- package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.d.ts +36 -13
- package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.js +18 -40
- package/dist/plugins/tables/deleteTable/schemas.d.ts +0 -2
- package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableFields/index.d.ts +36 -11
- package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableFields/index.js +17 -39
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts +0 -2
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableRecords/index.d.ts +36 -11
- package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableRecords/index.js +18 -41
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +0 -2
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/getTable/index.d.ts +43 -12
- package/dist/plugins/tables/getTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTable/index.js +18 -43
- package/dist/plugins/tables/getTable/schemas.d.ts +0 -2
- package/dist/plugins/tables/getTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/getTableRecord/index.d.ts +43 -11
- package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTableRecord/index.js +18 -42
- package/dist/plugins/tables/getTableRecord/schemas.d.ts +0 -2
- package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTableFields/index.d.ts +46 -11
- package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableFields/index.js +17 -41
- package/dist/plugins/tables/listTableFields/schemas.d.ts +12 -14
- package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTableRecords/index.d.ts +66 -18
- package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableRecords/index.js +27 -50
- package/dist/plugins/tables/listTableRecords/schemas.d.ts +6 -8
- package/dist/plugins/tables/listTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/index.d.ts +53 -20
- package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/index.js +24 -51
- package/dist/plugins/tables/listTables/schemas.d.ts +0 -2
- package/dist/plugins/tables/listTables/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/shared.d.ts +10 -0
- package/dist/plugins/tables/shared.d.ts.map +1 -0
- package/dist/plugins/tables/shared.js +9 -0
- package/dist/plugins/tables/updateTableRecords/index.d.ts +49 -11
- package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/updateTableRecords/index.js +20 -43
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts +0 -2
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/utils.d.ts.map +1 -1
- package/dist/plugins/tables/utils.js +1 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +21 -1
- package/dist/resolvers/actionKey.d.ts +1 -2
- package/dist/resolvers/actionKey.d.ts.map +1 -1
- package/dist/resolvers/actionType.d.ts +1 -2
- package/dist/resolvers/actionType.d.ts.map +1 -1
- package/dist/schemas/Action.d.ts +1 -1
- package/dist/sdk.d.ts +2942 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/types/credentials.d.ts +2 -1
- package/dist/types/credentials.d.ts.map +1 -1
- package/dist/types/credentials.js +2 -1
- package/dist/types/errors.d.ts +13 -10
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +15 -12
- package/dist/types/functions.d.ts +18 -2
- package/dist/types/functions.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +1 -1
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/properties.d.ts +1 -1
- package/dist/types/registry.d.ts +1 -1
- package/dist/types/registry.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +2 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/sdk.js +1 -0
- package/dist/utils/function-utils.d.ts +11 -12
- package/dist/utils/function-utils.d.ts.map +1 -1
- package/dist/utils/plugin-utils.d.ts +168 -0
- package/dist/utils/plugin-utils.d.ts.map +1 -0
- package/dist/utils/plugin-utils.js +132 -0
- package/package.json +2 -4
|
@@ -1,16 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export declare const createTablePlugin: (sdk: {
|
|
2
|
+
context: {
|
|
3
|
+
api: import("../../../api").ApiClient;
|
|
4
|
+
resolveCredentials: () => Promise<string | {
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret: string;
|
|
7
|
+
type?: "client_credentials" | undefined;
|
|
8
|
+
baseUrl?: string | undefined;
|
|
9
|
+
scope?: string | undefined;
|
|
10
|
+
} | {
|
|
11
|
+
clientId: string;
|
|
12
|
+
type?: "pkce" | undefined;
|
|
13
|
+
baseUrl?: string | undefined;
|
|
14
|
+
scope?: string | undefined;
|
|
15
|
+
} | undefined>;
|
|
16
|
+
};
|
|
17
|
+
} & {
|
|
18
|
+
context: import("../../eventEmission").EventEmissionContext;
|
|
19
|
+
} & {
|
|
20
|
+
context: {
|
|
21
|
+
meta: Record<string, import("../../..").PluginMeta>;
|
|
22
|
+
};
|
|
23
|
+
}) => {
|
|
24
|
+
createTable: (options?: {
|
|
25
|
+
name: string;
|
|
26
|
+
description?: string | undefined;
|
|
27
|
+
} | undefined) => Promise<{
|
|
28
|
+
data: {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
created_at: string;
|
|
32
|
+
edited_at: string;
|
|
33
|
+
kind: "table" | "virtual_table";
|
|
34
|
+
account_id: string;
|
|
35
|
+
profile_id: string;
|
|
36
|
+
description?: string | undefined;
|
|
37
|
+
parent_table_id?: string | undefined;
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
40
|
+
} & {
|
|
7
41
|
context: {
|
|
8
42
|
meta: {
|
|
9
|
-
createTable:
|
|
10
|
-
inputSchema: typeof CreateTableOptionsSchema;
|
|
11
|
-
};
|
|
43
|
+
createTable: import("../../..").PluginMeta;
|
|
12
44
|
};
|
|
13
45
|
};
|
|
14
|
-
}
|
|
15
|
-
export
|
|
46
|
+
};
|
|
47
|
+
export type CreateTablePluginProvides = ReturnType<typeof createTablePlugin>;
|
|
16
48
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/createTable/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/createTable/index.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoB7B,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -1,48 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { definePlugin } from "../../../utils/plugin-utils";
|
|
2
|
+
import { createPluginMethod } from "../../../utils/plugin-utils";
|
|
2
3
|
import { CreateTableOptionsSchema, CreateTableApiResponseSchema, TableItemSchema, } from "./schemas";
|
|
3
|
-
import { createTelemetryCallback } from "../../../utils/telemetry-utils";
|
|
4
|
-
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
5
4
|
import { tableNameResolver } from "../../../resolvers";
|
|
6
5
|
import { transformTableItem } from "../utils";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
});
|
|
6
|
+
import { tablesDefaults } from "../shared";
|
|
7
|
+
export const createTablePlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
8
|
+
...tablesDefaults,
|
|
9
|
+
name: "createTable",
|
|
10
|
+
type: "create",
|
|
11
|
+
itemType: "Table",
|
|
12
|
+
inputSchema: CreateTableOptionsSchema,
|
|
13
|
+
outputSchema: TableItemSchema,
|
|
14
|
+
resolvers: { name: tableNameResolver },
|
|
15
|
+
handler: async ({ sdk, options }) => {
|
|
16
|
+
const rawResponse = await sdk.context.api.post("/tables/api/v1/tables", { name: options.name, description: options.description }, { authRequired: true });
|
|
25
17
|
const response = CreateTableApiResponseSchema.parse(rawResponse);
|
|
26
|
-
return {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
const createTableDefinition = createFunction(createTable, CreateTableOptionsSchema, createTelemetryCallback(sdk.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
|
-
};
|
|
18
|
+
return { data: transformTableItem(response.data) };
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { FunctionOptions } from "../../../types/functions";
|
|
3
|
-
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
|
|
4
3
|
import { TableItemSchema, TableApiItemSchema, type TableItem, type TableApiItem } from "../listTables/schemas";
|
|
5
4
|
export { TableItemSchema, TableApiItemSchema };
|
|
6
5
|
export type { TableItem, TableApiItem };
|
|
@@ -32,7 +31,6 @@ export type CreateTableOptions = z.infer<typeof CreateTableOptionsSchema> & Func
|
|
|
32
31
|
export interface CreateTableResult {
|
|
33
32
|
data: TableItem;
|
|
34
33
|
}
|
|
35
|
-
export type CreateTableError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
36
34
|
export interface CreateTableSdkFunction {
|
|
37
35
|
createTable: (options: CreateTableOptions) => Promise<CreateTableResult>;
|
|
38
36
|
}
|
|
@@ -1 +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,
|
|
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,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,WAAW,sBAAsB;IACrC,WAAW,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC1E"}
|
|
@@ -1,16 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export declare const createTableFieldsPlugin: (sdk: {
|
|
2
|
+
context: {
|
|
3
|
+
api: import("../../../api").ApiClient;
|
|
4
|
+
resolveCredentials: () => Promise<string | {
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret: string;
|
|
7
|
+
type?: "client_credentials" | undefined;
|
|
8
|
+
baseUrl?: string | undefined;
|
|
9
|
+
scope?: string | undefined;
|
|
10
|
+
} | {
|
|
11
|
+
clientId: string;
|
|
12
|
+
type?: "pkce" | undefined;
|
|
13
|
+
baseUrl?: string | undefined;
|
|
14
|
+
scope?: string | undefined;
|
|
15
|
+
} | undefined>;
|
|
16
|
+
};
|
|
17
|
+
} & {
|
|
18
|
+
context: import("../../eventEmission").EventEmissionContext;
|
|
19
|
+
} & {
|
|
20
|
+
context: {
|
|
21
|
+
meta: Record<string, import("../../..").PluginMeta>;
|
|
22
|
+
};
|
|
23
|
+
}) => {
|
|
24
|
+
createTableFields: (options?: {
|
|
25
|
+
table: string;
|
|
26
|
+
fields: {
|
|
27
|
+
type: "string" | "number" | "boolean" | "text" | "datetime" | "decimal" | "json" | "email" | "link" | "multiple_string" | "labeled_string" | "multiple_labeled_string" | "multiple_text" | "multiple_boolean" | "multiple_number" | "multiple_decimal" | "multiple_datetime" | "uuid" | "multiple_uuid" | "multiple_json" | "formula" | "button_trigger_zap" | "button_continue_zap" | "multiple_email" | "multiple_link" | "currency" | "phone_number" | "ai_formula" | "linked_record" | "multiple_linked_record";
|
|
28
|
+
name: string;
|
|
29
|
+
options?: Record<string, unknown> | undefined;
|
|
30
|
+
config?: Record<string, unknown> | undefined;
|
|
31
|
+
}[];
|
|
32
|
+
} | {
|
|
33
|
+
tableId: string;
|
|
34
|
+
fields: {
|
|
35
|
+
type: "string" | "number" | "boolean" | "text" | "datetime" | "decimal" | "json" | "email" | "link" | "multiple_string" | "labeled_string" | "multiple_labeled_string" | "multiple_text" | "multiple_boolean" | "multiple_number" | "multiple_decimal" | "multiple_datetime" | "uuid" | "multiple_uuid" | "multiple_json" | "formula" | "button_trigger_zap" | "button_continue_zap" | "multiple_email" | "multiple_link" | "currency" | "phone_number" | "ai_formula" | "linked_record" | "multiple_linked_record";
|
|
36
|
+
name: string;
|
|
37
|
+
options?: Record<string, unknown> | undefined;
|
|
38
|
+
config?: Record<string, unknown> | undefined;
|
|
39
|
+
}[];
|
|
40
|
+
} | undefined) => Promise<{
|
|
41
|
+
data: {
|
|
42
|
+
id: string;
|
|
43
|
+
type: "string" | "number" | "boolean" | "text" | "datetime" | "decimal" | "json" | "email" | "link" | "multiple_string" | "labeled_string" | "multiple_labeled_string" | "multiple_text" | "multiple_boolean" | "multiple_number" | "multiple_decimal" | "multiple_datetime" | "uuid" | "multiple_uuid" | "multiple_json" | "formula" | "button_trigger_zap" | "button_continue_zap" | "multiple_email" | "multiple_link" | "currency" | "phone_number" | "ai_formula" | "linked_record" | "multiple_linked_record";
|
|
44
|
+
name: string;
|
|
45
|
+
created_at?: string | undefined;
|
|
46
|
+
edited_at?: string | undefined;
|
|
47
|
+
options?: Record<string, unknown> | undefined;
|
|
48
|
+
config?: Record<string, unknown> | undefined;
|
|
49
|
+
}[];
|
|
50
|
+
}>;
|
|
51
|
+
} & {
|
|
7
52
|
context: {
|
|
8
53
|
meta: {
|
|
9
|
-
createTableFields:
|
|
10
|
-
inputSchema: typeof CreateTableFieldsOptionsSchema;
|
|
11
|
-
};
|
|
54
|
+
createTableFields: import("../../..").PluginMeta;
|
|
12
55
|
};
|
|
13
56
|
};
|
|
14
|
-
}
|
|
15
|
-
export
|
|
57
|
+
};
|
|
58
|
+
export type CreateTableFieldsPluginProvides = ReturnType<typeof createTableFieldsPlugin>;
|
|
16
59
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/createTableFields/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/createTableFields/index.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BnC,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG,UAAU,CACtD,OAAO,uBAAuB,CAC/B,CAAC"}
|
|
@@ -1,50 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
1
|
+
import { definePlugin } from "../../../utils/plugin-utils";
|
|
2
|
+
import { createPluginMethod } from "../../../utils/plugin-utils";
|
|
3
|
+
import { CreateTableFieldsOptionsInputSchema, CreateTableFieldsApiResponseSchema, FieldItemSchema, } from "./schemas";
|
|
5
4
|
import { tableIdResolver, tableFieldsResolver } from "../../../resolvers";
|
|
6
5
|
import { transformFieldItem } from "../utils";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import { tablesDefaults } from "../shared";
|
|
7
|
+
export const createTableFieldsPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
8
|
+
...tablesDefaults,
|
|
9
|
+
name: "createTableFields",
|
|
10
|
+
type: "create",
|
|
11
|
+
itemType: "Field",
|
|
12
|
+
inputSchema: CreateTableFieldsOptionsInputSchema,
|
|
13
|
+
outputSchema: FieldItemSchema,
|
|
14
|
+
resolvers: { table: tableIdResolver, fields: tableFieldsResolver },
|
|
15
|
+
handler: async ({ sdk, options }) => {
|
|
10
16
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
11
|
-
const rawResponse = await api.post(`/tables/api/v1/tables/${tableId}/fields`, {
|
|
12
|
-
new_fields: options.fields,
|
|
13
|
-
}, {
|
|
14
|
-
customErrorHandler: ({ status }) => {
|
|
15
|
-
if (status === 401) {
|
|
16
|
-
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to create fields 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 fields. (HTTP ${status})`, { statusCode: status });
|
|
20
|
-
}
|
|
21
|
-
return undefined;
|
|
22
|
-
},
|
|
17
|
+
const rawResponse = await sdk.context.api.post(`/tables/api/v1/tables/${tableId}/fields`, { new_fields: options.fields }, {
|
|
23
18
|
authRequired: true,
|
|
19
|
+
resource: { type: "table", id: tableId },
|
|
24
20
|
});
|
|
25
21
|
const response = CreateTableFieldsApiResponseSchema.parse(rawResponse);
|
|
26
|
-
// Extract the 'new' field from each changeset item
|
|
27
22
|
return {
|
|
28
23
|
data: response.data.map((changeset) => transformFieldItem(changeset.new)),
|
|
29
24
|
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
createTableFields: createTableFieldsDefinition,
|
|
34
|
-
context: {
|
|
35
|
-
meta: {
|
|
36
|
-
createTableFields: {
|
|
37
|
-
categories: ["table"],
|
|
38
|
-
type: "create",
|
|
39
|
-
itemType: "Field",
|
|
40
|
-
inputSchema: CreateTableFieldsOptionsSchema,
|
|
41
|
-
outputSchema: FieldItemSchema,
|
|
42
|
-
resolvers: {
|
|
43
|
-
table: tableIdResolver,
|
|
44
|
-
fields: tableFieldsResolver,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
};
|
|
25
|
+
},
|
|
26
|
+
}));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { FunctionOptions } from "../../../types/functions";
|
|
3
|
-
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
|
|
4
3
|
import { FieldTypeSchema, FieldItemSchema, type FieldItem } from "../listTableFields/schemas";
|
|
5
4
|
export { FieldTypeSchema, FieldItemSchema };
|
|
6
5
|
export type { FieldItem };
|
|
@@ -12,13 +11,12 @@ export declare const CreateTableFieldsApiResponseSchema: z.ZodObject<{
|
|
|
12
11
|
string: "string";
|
|
13
12
|
number: "number";
|
|
14
13
|
boolean: "boolean";
|
|
15
|
-
link: "link";
|
|
16
|
-
email: "email";
|
|
17
|
-
uuid: "uuid";
|
|
18
14
|
text: "text";
|
|
19
15
|
datetime: "datetime";
|
|
20
16
|
decimal: "decimal";
|
|
21
17
|
json: "json";
|
|
18
|
+
email: "email";
|
|
19
|
+
link: "link";
|
|
22
20
|
multiple_string: "multiple_string";
|
|
23
21
|
labeled_string: "labeled_string";
|
|
24
22
|
multiple_labeled_string: "multiple_labeled_string";
|
|
@@ -27,6 +25,7 @@ export declare const CreateTableFieldsApiResponseSchema: z.ZodObject<{
|
|
|
27
25
|
multiple_number: "multiple_number";
|
|
28
26
|
multiple_decimal: "multiple_decimal";
|
|
29
27
|
multiple_datetime: "multiple_datetime";
|
|
28
|
+
uuid: "uuid";
|
|
30
29
|
multiple_uuid: "multiple_uuid";
|
|
31
30
|
multiple_json: "multiple_json";
|
|
32
31
|
formula: "formula";
|
|
@@ -55,13 +54,12 @@ export declare const CreateTableFieldsApiResponseSchema: z.ZodObject<{
|
|
|
55
54
|
string: "string";
|
|
56
55
|
number: "number";
|
|
57
56
|
boolean: "boolean";
|
|
58
|
-
link: "link";
|
|
59
|
-
email: "email";
|
|
60
|
-
uuid: "uuid";
|
|
61
57
|
text: "text";
|
|
62
58
|
datetime: "datetime";
|
|
63
59
|
decimal: "decimal";
|
|
64
60
|
json: "json";
|
|
61
|
+
email: "email";
|
|
62
|
+
link: "link";
|
|
65
63
|
multiple_string: "multiple_string";
|
|
66
64
|
labeled_string: "labeled_string";
|
|
67
65
|
multiple_labeled_string: "multiple_labeled_string";
|
|
@@ -70,6 +68,7 @@ export declare const CreateTableFieldsApiResponseSchema: z.ZodObject<{
|
|
|
70
68
|
multiple_number: "multiple_number";
|
|
71
69
|
multiple_decimal: "multiple_decimal";
|
|
72
70
|
multiple_datetime: "multiple_datetime";
|
|
71
|
+
uuid: "uuid";
|
|
73
72
|
multiple_uuid: "multiple_uuid";
|
|
74
73
|
multiple_json: "multiple_json";
|
|
75
74
|
formula: "formula";
|
|
@@ -108,13 +107,12 @@ export declare const NewFieldSchema: z.ZodObject<{
|
|
|
108
107
|
string: "string";
|
|
109
108
|
number: "number";
|
|
110
109
|
boolean: "boolean";
|
|
111
|
-
link: "link";
|
|
112
|
-
email: "email";
|
|
113
|
-
uuid: "uuid";
|
|
114
110
|
text: "text";
|
|
115
111
|
datetime: "datetime";
|
|
116
112
|
decimal: "decimal";
|
|
117
113
|
json: "json";
|
|
114
|
+
email: "email";
|
|
115
|
+
link: "link";
|
|
118
116
|
multiple_string: "multiple_string";
|
|
119
117
|
labeled_string: "labeled_string";
|
|
120
118
|
multiple_labeled_string: "multiple_labeled_string";
|
|
@@ -123,6 +121,7 @@ export declare const NewFieldSchema: z.ZodObject<{
|
|
|
123
121
|
multiple_number: "multiple_number";
|
|
124
122
|
multiple_decimal: "multiple_decimal";
|
|
125
123
|
multiple_datetime: "multiple_datetime";
|
|
124
|
+
uuid: "uuid";
|
|
126
125
|
multiple_uuid: "multiple_uuid";
|
|
127
126
|
multiple_json: "multiple_json";
|
|
128
127
|
formula: "formula";
|
|
@@ -150,13 +149,12 @@ export declare const CreateTableFieldsOptionsSchema: z.ZodObject<{
|
|
|
150
149
|
string: "string";
|
|
151
150
|
number: "number";
|
|
152
151
|
boolean: "boolean";
|
|
153
|
-
link: "link";
|
|
154
|
-
email: "email";
|
|
155
|
-
uuid: "uuid";
|
|
156
152
|
text: "text";
|
|
157
153
|
datetime: "datetime";
|
|
158
154
|
decimal: "decimal";
|
|
159
155
|
json: "json";
|
|
156
|
+
email: "email";
|
|
157
|
+
link: "link";
|
|
160
158
|
multiple_string: "multiple_string";
|
|
161
159
|
labeled_string: "labeled_string";
|
|
162
160
|
multiple_labeled_string: "multiple_labeled_string";
|
|
@@ -165,6 +163,7 @@ export declare const CreateTableFieldsOptionsSchema: z.ZodObject<{
|
|
|
165
163
|
multiple_number: "multiple_number";
|
|
166
164
|
multiple_decimal: "multiple_decimal";
|
|
167
165
|
multiple_datetime: "multiple_datetime";
|
|
166
|
+
uuid: "uuid";
|
|
168
167
|
multiple_uuid: "multiple_uuid";
|
|
169
168
|
multiple_json: "multiple_json";
|
|
170
169
|
formula: "formula";
|
|
@@ -190,13 +189,12 @@ declare const CreateTableFieldsOptionsSchemaDeprecated: z.ZodObject<{
|
|
|
190
189
|
string: "string";
|
|
191
190
|
number: "number";
|
|
192
191
|
boolean: "boolean";
|
|
193
|
-
link: "link";
|
|
194
|
-
email: "email";
|
|
195
|
-
uuid: "uuid";
|
|
196
192
|
text: "text";
|
|
197
193
|
datetime: "datetime";
|
|
198
194
|
decimal: "decimal";
|
|
199
195
|
json: "json";
|
|
196
|
+
email: "email";
|
|
197
|
+
link: "link";
|
|
200
198
|
multiple_string: "multiple_string";
|
|
201
199
|
labeled_string: "labeled_string";
|
|
202
200
|
multiple_labeled_string: "multiple_labeled_string";
|
|
@@ -205,6 +203,7 @@ declare const CreateTableFieldsOptionsSchemaDeprecated: z.ZodObject<{
|
|
|
205
203
|
multiple_number: "multiple_number";
|
|
206
204
|
multiple_decimal: "multiple_decimal";
|
|
207
205
|
multiple_datetime: "multiple_datetime";
|
|
206
|
+
uuid: "uuid";
|
|
208
207
|
multiple_uuid: "multiple_uuid";
|
|
209
208
|
multiple_json: "multiple_json";
|
|
210
209
|
formula: "formula";
|
|
@@ -232,13 +231,12 @@ export declare const CreateTableFieldsOptionsInputSchema: z.ZodUnion<readonly [z
|
|
|
232
231
|
string: "string";
|
|
233
232
|
number: "number";
|
|
234
233
|
boolean: "boolean";
|
|
235
|
-
link: "link";
|
|
236
|
-
email: "email";
|
|
237
|
-
uuid: "uuid";
|
|
238
234
|
text: "text";
|
|
239
235
|
datetime: "datetime";
|
|
240
236
|
decimal: "decimal";
|
|
241
237
|
json: "json";
|
|
238
|
+
email: "email";
|
|
239
|
+
link: "link";
|
|
242
240
|
multiple_string: "multiple_string";
|
|
243
241
|
labeled_string: "labeled_string";
|
|
244
242
|
multiple_labeled_string: "multiple_labeled_string";
|
|
@@ -247,6 +245,7 @@ export declare const CreateTableFieldsOptionsInputSchema: z.ZodUnion<readonly [z
|
|
|
247
245
|
multiple_number: "multiple_number";
|
|
248
246
|
multiple_decimal: "multiple_decimal";
|
|
249
247
|
multiple_datetime: "multiple_datetime";
|
|
248
|
+
uuid: "uuid";
|
|
250
249
|
multiple_uuid: "multiple_uuid";
|
|
251
250
|
multiple_json: "multiple_json";
|
|
252
251
|
formula: "formula";
|
|
@@ -271,13 +270,12 @@ export declare const CreateTableFieldsOptionsInputSchema: z.ZodUnion<readonly [z
|
|
|
271
270
|
string: "string";
|
|
272
271
|
number: "number";
|
|
273
272
|
boolean: "boolean";
|
|
274
|
-
link: "link";
|
|
275
|
-
email: "email";
|
|
276
|
-
uuid: "uuid";
|
|
277
273
|
text: "text";
|
|
278
274
|
datetime: "datetime";
|
|
279
275
|
decimal: "decimal";
|
|
280
276
|
json: "json";
|
|
277
|
+
email: "email";
|
|
278
|
+
link: "link";
|
|
281
279
|
multiple_string: "multiple_string";
|
|
282
280
|
labeled_string: "labeled_string";
|
|
283
281
|
multiple_labeled_string: "multiple_labeled_string";
|
|
@@ -286,6 +284,7 @@ export declare const CreateTableFieldsOptionsInputSchema: z.ZodUnion<readonly [z
|
|
|
286
284
|
multiple_number: "multiple_number";
|
|
287
285
|
multiple_decimal: "multiple_decimal";
|
|
288
286
|
multiple_datetime: "multiple_datetime";
|
|
287
|
+
uuid: "uuid";
|
|
289
288
|
multiple_uuid: "multiple_uuid";
|
|
290
289
|
multiple_json: "multiple_json";
|
|
291
290
|
formula: "formula";
|
|
@@ -311,7 +310,6 @@ export type CreateTableFieldsOptions = (z.infer<typeof CreateTableFieldsOptionsS
|
|
|
311
310
|
export interface CreateTableFieldsResult {
|
|
312
311
|
data: FieldItem[];
|
|
313
312
|
}
|
|
314
|
-
export type CreateTableFieldsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
315
313
|
export interface CreateTableFieldsSdkFunction {
|
|
316
314
|
createTableFields: (options: CreateTableFieldsOptions) => Promise<CreateTableFieldsResult>;
|
|
317
315
|
}
|
|
@@ -1 +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;AAEhE,OAAO,
|
|
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;AAEhE,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;AAYtD,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMD,CAAC;AAG3C,QAAA,MAAM,wCAAwC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAOf,CAAC;AAGhC,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAKP,CAAC;AAG1C,MAAM,MAAM,wBAAwB,GAChC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,GAAG,eAAe,CAAC,GAClE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,wCAAwC,CAAC,EAAE,SAAS,CAAC,GACxE,eAAe,GAAG;IAChB,uCAAuC;IACvC,OAAO,EAAE,CAAC,CAAC,KAAK,CACd,OAAO,wCAAwC,CAChD,CAAC,SAAS,CAAC,CAAC;CACd,CAAC,CAAC;AAGT,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,SAAS,EAAE,CAAC;CACnB;AAGD,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACvC"}
|
|
@@ -1,16 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export declare const createTableRecordsPlugin: (sdk: {
|
|
2
|
+
context: {
|
|
3
|
+
api: import("../../../api").ApiClient;
|
|
4
|
+
resolveCredentials: () => Promise<string | {
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret: string;
|
|
7
|
+
type?: "client_credentials" | undefined;
|
|
8
|
+
baseUrl?: string | undefined;
|
|
9
|
+
scope?: string | undefined;
|
|
10
|
+
} | {
|
|
11
|
+
clientId: string;
|
|
12
|
+
type?: "pkce" | undefined;
|
|
13
|
+
baseUrl?: string | undefined;
|
|
14
|
+
scope?: string | undefined;
|
|
15
|
+
} | undefined>;
|
|
16
|
+
};
|
|
17
|
+
} & {
|
|
18
|
+
context: import("../../eventEmission").EventEmissionContext;
|
|
19
|
+
} & {
|
|
20
|
+
context: {
|
|
21
|
+
meta: Record<string, import("../../..").PluginMeta>;
|
|
22
|
+
};
|
|
23
|
+
}) => {
|
|
24
|
+
createTableRecords: (options?: {
|
|
25
|
+
table: string;
|
|
26
|
+
records: {
|
|
27
|
+
data: Record<string, unknown>;
|
|
28
|
+
}[];
|
|
29
|
+
keyMode: "names" | "ids";
|
|
30
|
+
} | {
|
|
31
|
+
tableId: string;
|
|
32
|
+
records: {
|
|
33
|
+
data: Record<string, unknown>;
|
|
34
|
+
}[];
|
|
35
|
+
keyMode: "names" | "ids";
|
|
36
|
+
} | undefined) => Promise<{
|
|
37
|
+
data: {
|
|
38
|
+
data: Record<string, unknown>;
|
|
39
|
+
id: string;
|
|
40
|
+
created_at: string;
|
|
41
|
+
edited_at: string;
|
|
42
|
+
}[];
|
|
43
|
+
}>;
|
|
44
|
+
} & {
|
|
7
45
|
context: {
|
|
8
46
|
meta: {
|
|
9
|
-
createTableRecords:
|
|
10
|
-
inputSchema: typeof CreateTableRecordsOptionsSchema;
|
|
11
|
-
};
|
|
47
|
+
createTableRecords: import("../../..").PluginMeta;
|
|
12
48
|
};
|
|
13
49
|
};
|
|
14
|
-
}
|
|
15
|
-
export
|
|
50
|
+
};
|
|
51
|
+
export type CreateTableRecordsPluginProvides = ReturnType<typeof createTableRecordsPlugin>;
|
|
16
52
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/createTableRecords/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/createTableRecords/index.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CpC,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG,UAAU,CACvD,OAAO,wBAAwB,CAChC,CAAC"}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
1
|
+
import { definePlugin } from "../../../utils/plugin-utils";
|
|
2
|
+
import { createPluginMethod } from "../../../utils/plugin-utils";
|
|
3
|
+
import { CreateTableRecordsOptionsInputSchema, CreateTableRecordsApiResponseSchema, RecordItemSchema, } from "./schemas";
|
|
5
4
|
import { tableIdResolver, tableRecordsResolver } from "../../../resolvers";
|
|
6
5
|
import { tableRecordFormatter } from "../../../formatters";
|
|
7
6
|
import { createFieldKeyTranslator, transformRecordItem, throwOnRecordErrors, throwOnResponseErrors, } from "../utils";
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import { tablesDefaults } from "../shared";
|
|
8
|
+
export const createTableRecordsPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
9
|
+
...tablesDefaults,
|
|
10
|
+
name: "createTableRecords",
|
|
11
|
+
type: "create",
|
|
12
|
+
itemType: "Record",
|
|
13
|
+
inputSchema: CreateTableRecordsOptionsInputSchema,
|
|
14
|
+
outputSchema: RecordItemSchema,
|
|
15
|
+
resolvers: { table: tableIdResolver, records: tableRecordsResolver },
|
|
16
|
+
formatter: tableRecordFormatter,
|
|
17
|
+
handler: async ({ sdk, options }) => {
|
|
10
18
|
const { api } = sdk.context;
|
|
11
19
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
12
20
|
const translator = await createFieldKeyTranslator({
|
|
@@ -18,21 +26,7 @@ export const createTableRecordsPlugin = (sdk) => {
|
|
|
18
26
|
new_records: options.records.map((record) => ({
|
|
19
27
|
data: translator.translateInput(record.data),
|
|
20
28
|
})),
|
|
21
|
-
}, {
|
|
22
|
-
customErrorHandler: ({ status }) => {
|
|
23
|
-
if (status === 401) {
|
|
24
|
-
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to create 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 create records. (HTTP ${status})`, { statusCode: status });
|
|
28
|
-
}
|
|
29
|
-
if (status === 404) {
|
|
30
|
-
return new Error(`Table not found: ${tableId}`);
|
|
31
|
-
}
|
|
32
|
-
return undefined;
|
|
33
|
-
},
|
|
34
|
-
authRequired: true,
|
|
35
|
-
});
|
|
29
|
+
}, { authRequired: true, resource: { type: "table", id: tableId } });
|
|
36
30
|
throwOnResponseErrors(rawResponse);
|
|
37
31
|
const response = CreateTableRecordsApiResponseSchema.parse(rawResponse);
|
|
38
32
|
for (const changeset of response.data) {
|
|
@@ -44,25 +38,5 @@ export const createTableRecordsPlugin = (sdk) => {
|
|
|
44
38
|
data: translator.translateOutput(changeset.new.data),
|
|
45
39
|
})),
|
|
46
40
|
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
createTableRecords: createTableRecordsDefinition,
|
|
51
|
-
context: {
|
|
52
|
-
meta: {
|
|
53
|
-
createTableRecords: {
|
|
54
|
-
categories: ["table"],
|
|
55
|
-
type: "create",
|
|
56
|
-
itemType: "Record",
|
|
57
|
-
inputSchema: CreateTableRecordsOptionsSchema,
|
|
58
|
-
outputSchema: RecordItemSchema,
|
|
59
|
-
resolvers: {
|
|
60
|
-
table: tableIdResolver,
|
|
61
|
-
records: tableRecordsResolver,
|
|
62
|
-
},
|
|
63
|
-
formatter: tableRecordFormatter,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
};
|
|
41
|
+
},
|
|
42
|
+
}));
|