@zapier/zapier-sdk 0.34.1 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +341 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +10 -2
- package/dist/api/types.d.ts +2 -1
- package/dist/api/types.d.ts.map +1 -1
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -0
- package/dist/formatters/index.d.ts +2 -0
- package/dist/formatters/index.d.ts.map +1 -0
- package/dist/formatters/index.js +1 -0
- package/dist/formatters/tableRecord.d.ts +6 -0
- package/dist/formatters/tableRecord.d.ts.map +1 -0
- package/dist/formatters/tableRecord.js +23 -0
- package/dist/index.cjs +2054 -191
- package/dist/index.d.mts +639 -59
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.mjs +2030 -192
- package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.js +1 -1
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +2 -1
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +5 -2
- package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/listClientCredentials/index.js +6 -4
- package/dist/plugins/listConnections/index.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.js +6 -4
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +2 -1
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +2 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +4 -0
- package/dist/plugins/runAction/index.d.ts +2 -0
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +73 -14
- package/dist/plugins/tables/createTable/index.d.ts +18 -0
- package/dist/plugins/tables/createTable/index.d.ts.map +1 -0
- package/dist/plugins/tables/createTable/index.js +48 -0
- package/dist/plugins/tables/createTable/schemas.d.ts +37 -0
- package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/createTable/schemas.js +16 -0
- package/dist/plugins/tables/createTableFields/index.d.ts +18 -0
- package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -0
- package/dist/plugins/tables/createTableFields/index.js +49 -0
- package/dist/plugins/tables/createTableFields/schemas.d.ts +192 -0
- package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/createTableFields/schemas.js +42 -0
- package/dist/plugins/tables/createTableRecords/index.d.ts +18 -0
- package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -0
- package/dist/plugins/tables/createTableRecords/index.js +67 -0
- package/dist/plugins/tables/createTableRecords/schemas.d.ts +57 -0
- package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/createTableRecords/schemas.js +35 -0
- package/dist/plugins/tables/deleteTable/index.d.ts +18 -0
- package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -0
- package/dist/plugins/tables/deleteTable/index.js +43 -0
- package/dist/plugins/tables/deleteTable/schemas.d.ts +15 -0
- package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/deleteTable/schemas.js +9 -0
- package/dist/plugins/tables/deleteTableFields/index.d.ts +18 -0
- package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -0
- package/dist/plugins/tables/deleteTableFields/index.js +50 -0
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts +16 -0
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/deleteTableFields/schemas.js +13 -0
- package/dist/plugins/tables/deleteTableRecords/index.d.ts +18 -0
- package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -0
- package/dist/plugins/tables/deleteTableRecords/index.js +44 -0
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +16 -0
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/deleteTableRecords/schemas.js +14 -0
- package/dist/plugins/tables/getTable/index.d.ts +20 -0
- package/dist/plugins/tables/getTable/index.d.ts.map +1 -0
- package/dist/plugins/tables/getTable/index.js +48 -0
- package/dist/plugins/tables/getTable/schemas.d.ts +34 -0
- package/dist/plugins/tables/getTable/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/getTable/schemas.js +15 -0
- package/dist/plugins/tables/getTableRecord/index.d.ts +18 -0
- package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -0
- package/dist/plugins/tables/getTableRecord/index.js +60 -0
- package/dist/plugins/tables/getTableRecord/schemas.d.ts +51 -0
- package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/getTableRecord/schemas.js +44 -0
- package/dist/plugins/tables/listTableFields/index.d.ts +18 -0
- package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -0
- package/dist/plugins/tables/listTableFields/index.js +58 -0
- package/dist/plugins/tables/listTableFields/schemas.d.ts +180 -0
- package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/listTableFields/schemas.js +77 -0
- package/dist/plugins/tables/listTableRecords/index.d.ts +24 -0
- package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -0
- package/dist/plugins/tables/listTableRecords/index.js +97 -0
- package/dist/plugins/tables/listTableRecords/schemas.d.ts +120 -0
- package/dist/plugins/tables/listTableRecords/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/listTableRecords/schemas.js +74 -0
- package/dist/plugins/tables/listTables/index.d.ts +24 -0
- package/dist/plugins/tables/listTables/index.d.ts.map +1 -0
- package/dist/plugins/tables/listTables/index.js +85 -0
- package/dist/plugins/tables/listTables/schemas.d.ts +78 -0
- package/dist/plugins/tables/listTables/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/listTables/schemas.js +63 -0
- package/dist/plugins/tables/updateTableRecords/index.d.ts +18 -0
- package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -0
- package/dist/plugins/tables/updateTableRecords/index.js +68 -0
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts +59 -0
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -0
- package/dist/plugins/tables/updateTableRecords/schemas.js +35 -0
- package/dist/plugins/tables/utils.d.ts +63 -0
- package/dist/plugins/tables/utils.d.ts.map +1 -0
- package/dist/plugins/tables/utils.js +262 -0
- package/dist/resolvers/index.d.ts +8 -0
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +8 -0
- package/dist/resolvers/tableFieldIds.d.ts +6 -0
- package/dist/resolvers/tableFieldIds.d.ts.map +1 -0
- package/dist/resolvers/tableFieldIds.js +19 -0
- package/dist/resolvers/tableFields.d.ts +3 -0
- package/dist/resolvers/tableFields.d.ts.map +1 -0
- package/dist/resolvers/tableFields.js +31 -0
- package/dist/resolvers/tableFilters.d.ts +5 -0
- package/dist/resolvers/tableFilters.d.ts.map +1 -0
- package/dist/resolvers/tableFilters.js +74 -0
- package/dist/resolvers/tableId.d.ts +4 -0
- package/dist/resolvers/tableId.d.ts.map +1 -0
- package/dist/resolvers/tableId.js +19 -0
- package/dist/resolvers/tableName.d.ts +3 -0
- package/dist/resolvers/tableName.d.ts.map +1 -0
- package/dist/resolvers/tableName.js +5 -0
- package/dist/resolvers/tableRecordId.d.ts +9 -0
- package/dist/resolvers/tableRecordId.d.ts.map +1 -0
- package/dist/resolvers/tableRecordId.js +48 -0
- package/dist/resolvers/tableRecords.d.ts +8 -0
- package/dist/resolvers/tableRecords.d.ts.map +1 -0
- package/dist/resolvers/tableRecords.js +77 -0
- package/dist/resolvers/tableSort.d.ts +5 -0
- package/dist/resolvers/tableSort.d.ts.map +1 -0
- package/dist/resolvers/tableSort.js +43 -0
- package/dist/sdk.d.ts +73 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +25 -0
- package/dist/types/sdk.d.ts +16 -1
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/function-utils.d.ts +2 -2
- package/dist/utils/function-utils.d.ts.map +1 -1
- package/dist/utils/function-utils.js +2 -3
- package/dist/utils/pagination-utils.d.ts +24 -0
- package/dist/utils/pagination-utils.d.ts.map +1 -1
- package/dist/utils/pagination-utils.js +78 -0
- package/dist/utils/schema-utils.d.ts +33 -5
- package/dist/utils/schema-utils.d.ts.map +1 -1
- package/package.json +7 -2
|
@@ -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/listActions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,WAAW,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EACL,iBAAiB,EACjB,KAAK,kBAAkB,EAExB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listActions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,WAAW,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EACL,iBAAiB,EACjB,KAAK,kBAAkB,EAExB,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAK7D,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,OAAO,CAAC;QACrD,IAAI,EAAE,UAAU,EAAE,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC3D,KAAK,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;KACpC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,WAAW,EAAE;gBACX,WAAW,EAAE,OAAO,iBAAiB,CAAC;aACvC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC,UAAU,CAAC,sBAAsB,CAAC,EAClC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,yBAAyB,CA2G1B,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { ListActionsSchema, } from "./schemas";
|
|
|
3
3
|
import { ActionItemSchema } from "../../schemas/Action";
|
|
4
4
|
import { ZapierConfigurationError, ZapierAuthenticationError, } from "../../types/errors";
|
|
5
5
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
6
|
+
import { DEFAULT_PAGE_SIZE } from "../../constants";
|
|
6
7
|
import { appKeyResolver, actionTypeResolver } from "../../resolvers";
|
|
7
8
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
8
9
|
import { stripPageSuffix } from "../../utils/string-utils";
|
|
@@ -69,7 +70,7 @@ export const listActionsPlugin = ({ context }) => {
|
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
const methodName = stripPageSuffix(listActionsPage.name);
|
|
72
|
-
const listActionsDefinition = createPaginatedFunction(listActionsPage, ListActionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
|
|
73
|
+
const listActionsDefinition = createPaginatedFunction(listActionsPage, ListActionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName, DEFAULT_PAGE_SIZE);
|
|
73
74
|
return {
|
|
74
75
|
listActions: listActionsDefinition,
|
|
75
76
|
context: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjE,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAI7D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,YAAY,CAAC,GAC5D,aAAa,CAAC,YAAY,CAAC,GAAG;QAC5B,KAAK,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;KACjC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR,WAAW,EAAE,OAAO,cAAc,CAAC;aACpC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EACF,cAAc,CAAC,iBAAiB,GAAG,sBAAsB,CAAC,GACxD,oBAAoB,EACtB,sBAAsB,CAkFvB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
2
|
+
import { DEFAULT_PAGE_SIZE } from "../../constants";
|
|
2
3
|
import { ListAppsSchema, } from "./schemas";
|
|
3
4
|
import { AppItemSchema } from "../../schemas/App";
|
|
4
5
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
@@ -43,13 +44,15 @@ export const listAppsPlugin = ({ context }) => {
|
|
|
43
44
|
searchParams: {
|
|
44
45
|
appKeys: implementationIds.join(","),
|
|
45
46
|
...(options.search && { search: options.search }),
|
|
46
|
-
|
|
47
|
+
...(options.pageSize !== undefined && {
|
|
48
|
+
pageSize: options.pageSize.toString(),
|
|
49
|
+
}),
|
|
47
50
|
...(options.cursor && { offset: options.cursor }),
|
|
48
51
|
},
|
|
49
52
|
});
|
|
50
53
|
}
|
|
51
54
|
const methodName = stripPageSuffix(listAppsPage.name);
|
|
52
|
-
const listAppsDefinition = createPaginatedFunction(listAppsPage, ListAppsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
|
|
55
|
+
const listAppsDefinition = createPaginatedFunction(listAppsPage, ListAppsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName, DEFAULT_PAGE_SIZE);
|
|
53
56
|
return {
|
|
54
57
|
listApps: listAppsDefinition,
|
|
55
58
|
context: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listClientCredentials/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uDAAuD,CAAC;AACnG,OAAO,EACL,gCAAgC,EAChC,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC/B,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listClientCredentials/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uDAAuD,CAAC;AACnG,OAAO,EACL,gCAAgC,EAChC,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC/B,MAAM,WAAW,CAAC;AAKnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAK7D,MAAM,WAAW,mCAAmC;IAClD,qBAAqB,EAAE,CACrB,OAAO,CAAC,EAAE,4BAA4B,KACnC,OAAO,CAAC,yBAAyB,CAAC,GACrC,aAAa,CAAC,yBAAyB,CAAC,GAAG;QACzC,KAAK,IAAI,aAAa,CAAC,qBAAqB,CAAC,CAAC;KAC/C,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,qBAAqB,EAAE;gBACrB,WAAW,EAAE,OAAO,gCAAgC,CAAC;aACtD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAC9C,EAAE,EACF;IACE,GAAG,EAAE,SAAS,CAAC;CAChB,GAAG,oBAAoB,EACxB,mCAAmC,CAsEpC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ListClientCredentialsQuerySchema, } from "./schemas";
|
|
2
2
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
3
|
+
import { DEFAULT_PAGE_SIZE } from "../../constants";
|
|
3
4
|
import { ClientCredentialsItemSchema } from "../../schemas/ClientCredentials";
|
|
4
5
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
5
6
|
import { stripPageSuffix } from "../../utils/string-utils";
|
|
@@ -7,9 +8,10 @@ import { ZapierAuthenticationError } from "../../types/errors";
|
|
|
7
8
|
export const listClientCredentialsPlugin = ({ context }) => {
|
|
8
9
|
async function listClientCredentialsPage(options) {
|
|
9
10
|
const { api } = context;
|
|
10
|
-
const searchParams = {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const searchParams = {};
|
|
12
|
+
if (options.pageSize !== undefined) {
|
|
13
|
+
searchParams.pageSize = options.pageSize.toString();
|
|
14
|
+
}
|
|
13
15
|
if (options.cursor) {
|
|
14
16
|
searchParams.offset = options.cursor;
|
|
15
17
|
}
|
|
@@ -30,7 +32,7 @@ export const listClientCredentialsPlugin = ({ context }) => {
|
|
|
30
32
|
return response;
|
|
31
33
|
}
|
|
32
34
|
const methodName = stripPageSuffix(listClientCredentialsPage.name);
|
|
33
|
-
const listClientCredentialsDefinition = createPaginatedFunction(listClientCredentialsPage, ListClientCredentialsQuerySchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
|
|
35
|
+
const listClientCredentialsDefinition = createPaginatedFunction(listClientCredentialsPage, ListClientCredentialsQuerySchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName, DEFAULT_PAGE_SIZE);
|
|
34
36
|
return {
|
|
35
37
|
listClientCredentials: listClientCredentialsDefinition,
|
|
36
38
|
context: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listConnections/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,EACL,0BAA0B,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACzB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listConnections/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,EACL,0BAA0B,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACzB,MAAM,WAAW,CAAC;AAKnB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAM7D,MAAM,WAAW,6BAA6B;IAC5C,eAAe,EAAE,CACf,OAAO,CAAC,EAAE,sBAAsB,KAC7B,OAAO,CAAC,mBAAmB,CAAC,GAC/B,aAAa,CAAC,mBAAmB,CAAC,GAAG;QACnC,KAAK,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC;KACxC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,eAAe,EAAE;gBACf,WAAW,EAAE,OAAO,0BAA0B,CAAC;aAChD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,UAAU,CAAC,sBAAsB,CAAC,EAClC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,6BAA6B,CA+G9B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ListConnectionsQuerySchema, } from "./schemas";
|
|
2
2
|
import { splitVersionedKey } from "../../utils/domain-utils";
|
|
3
3
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
4
|
+
import { DEFAULT_PAGE_SIZE } from "../../constants";
|
|
4
5
|
import { appKeyResolver } from "../../resolvers";
|
|
5
6
|
import { ConnectionItemSchema } from "../../schemas/Connection";
|
|
6
7
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
@@ -10,9 +11,10 @@ import { setMethodMetadata } from "../../utils/telemetry-context";
|
|
|
10
11
|
export const listConnectionsPlugin = ({ context }) => {
|
|
11
12
|
async function listConnectionsPage(options) {
|
|
12
13
|
const { api, getVersionedImplementationId } = context;
|
|
13
|
-
const searchParams = {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const searchParams = {};
|
|
15
|
+
if (options.pageSize !== undefined) {
|
|
16
|
+
searchParams.page_size = options.pageSize.toString();
|
|
17
|
+
}
|
|
16
18
|
// Resolve appKey to implementationId if provided
|
|
17
19
|
if (options.appKey) {
|
|
18
20
|
const implementationId = await getVersionedImplementationId(options.appKey);
|
|
@@ -67,7 +69,7 @@ export const listConnectionsPlugin = ({ context }) => {
|
|
|
67
69
|
return response;
|
|
68
70
|
}
|
|
69
71
|
const methodName = stripPageSuffix(listConnectionsPage.name);
|
|
70
|
-
const listConnectionsDefinition = createPaginatedFunction(listConnectionsPage, ListConnectionsQuerySchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
|
|
72
|
+
const listConnectionsDefinition = createPaginatedFunction(listConnectionsPage, ListConnectionsQuerySchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName, DEFAULT_PAGE_SIZE);
|
|
71
73
|
return {
|
|
72
74
|
listConnections: listConnectionsDefinition,
|
|
73
75
|
context: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFieldChoices/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EACL,2BAA2B,EAC3B,KAAK,4BAA4B,EAGlC,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFieldChoices/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EACL,2BAA2B,EAC3B,KAAK,4BAA4B,EAGlC,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAcxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAgB7D,MAAM,WAAW,mCAAmC;IAClD,qBAAqB,EAAE,CAAC,OAAO,EAAE,4BAA4B,KAAK,OAAO,CAAC;QACxE,IAAI,EAAE,oBAAoB,EAAE,CAAC;QAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACrE,KAAK,IAAI,aAAa,CAAC,oBAAoB,CAAC,CAAC;KAC9C,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,qBAAqB,EAAE;gBACrB,WAAW,EAAE,OAAO,2BAA2B,CAAC;aACjD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAC9C,UAAU,CAAC,uBAAuB,CAAC,EAAE,4BAA4B;AACjE,AADqC,4BAA4B;AACjE;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EAAE,2EAA2E;AACrG,mCAAmC,CA8JpC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ListInputFieldChoicesSchema, InputFieldChoiceItemSchema, } from "./schemas";
|
|
2
2
|
import { ZapierApiError, ZapierConfigurationError } from "../../types/errors";
|
|
3
3
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
4
|
+
import { DEFAULT_PAGE_SIZE } from "../../constants";
|
|
4
5
|
import { appKeyResolver, actionTypeResolver, actionKeyResolver, connectionIdResolver, inputFieldKeyResolver, inputsAllOptionalResolver, } from "../../resolvers";
|
|
5
6
|
import { fetchImplementationNeeds, fetchImplementationChoices, } from "../../services/implementations";
|
|
6
7
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
@@ -97,7 +98,7 @@ export const listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
97
98
|
};
|
|
98
99
|
}
|
|
99
100
|
const methodName = stripPageSuffix(listInputFieldChoicesPage.name);
|
|
100
|
-
const listInputFieldChoicesDefinition = createPaginatedFunction(listInputFieldChoicesPage, ListInputFieldChoicesSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
|
|
101
|
+
const listInputFieldChoicesDefinition = createPaginatedFunction(listInputFieldChoicesPage, ListInputFieldChoicesSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName, DEFAULT_PAGE_SIZE);
|
|
101
102
|
return {
|
|
102
103
|
listInputFieldChoices: listInputFieldChoicesDefinition,
|
|
103
104
|
context: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFields/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,qBAAqB,EACrB,KAAK,sBAAsB,EAE5B,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFields/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,qBAAqB,EACrB,KAAK,sBAAsB,EAE5B,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAYxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AA2J7D,MAAM,WAAW,6BAA6B;IAC5C,eAAe,EAAE,CAAC,OAAO,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC;QAC7D,IAAI,EAAE,aAAa,EAAE,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,aAAa,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC9D,KAAK,IAAI,aAAa,CAAC,cAAc,GAAG,aAAa,GAAG,YAAY,CAAC,CAAC;KACvE,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,eAAe,EAAE;gBACf,WAAW,EAAE,OAAO,qBAAqB,CAAC;aAC3C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,UAAU,CAAC,oBAAoB,GAAG,uBAAuB,CAAC,EAAE,uCAAuC;AACnG,AAD4D,uCAAuC;AACnG;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EAAE,2EAA2E;AACrG,6BAA6B,CAkG9B,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ListInputFieldsSchema, } from "./schemas";
|
|
2
2
|
import { ZapierConfigurationError } from "../../types/errors";
|
|
3
3
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
4
|
+
import { DEFAULT_PAGE_SIZE } from "../../constants";
|
|
4
5
|
import { appKeyResolver, actionTypeResolver, actionKeyResolver, connectionIdResolver, inputsAllOptionalResolver, } from "../../resolvers";
|
|
5
6
|
import { RootFieldItemSchema } from "../../schemas/Field";
|
|
6
7
|
import { toTitleCase, stripPageSuffix } from "../../utils/string-utils";
|
|
@@ -187,7 +188,7 @@ export const listInputFieldsPlugin = ({ sdk, context }) => {
|
|
|
187
188
|
};
|
|
188
189
|
}
|
|
189
190
|
const methodName = stripPageSuffix(listInputFieldsPage.name);
|
|
190
|
-
const listInputFieldsDefinition = createPaginatedFunction(listInputFieldsPage, ListInputFieldsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
|
|
191
|
+
const listInputFieldsDefinition = createPaginatedFunction(listInputFieldsPage, ListInputFieldsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName, DEFAULT_PAGE_SIZE);
|
|
191
192
|
return {
|
|
192
193
|
listInputFields: listInputFieldsDefinition,
|
|
193
194
|
context: {
|
|
@@ -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),
|
|
@@ -23,6 +23,8 @@ export interface RunActionPluginProvides {
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
+
export declare const CONTEXT_CACHE_TTL_MS = 60000;
|
|
27
|
+
export declare const CONTEXT_CACHE_MAX_SIZE = 500;
|
|
26
28
|
export declare const runActionPlugin: Plugin<GetSdkType<GetActionPluginProvides & GetAppPluginProvides>, // requires getAction and getApp in SDK
|
|
27
29
|
// requires getAction and getApp in SDK
|
|
28
30
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/runAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,eAAe,EACf,KAAK,gBAAgB,EAEtB,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAQtD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAK7D,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC;QACjD,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;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,WAAW,EAAE,OAAO,eAAe,CAAC;aACrC,CAAC;SACH,CAAC;KACH,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/runAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,eAAe,EACf,KAAK,gBAAgB,EAEtB,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAQtD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAK7D,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC;QACjD,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;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,WAAW,EAAE,OAAO,eAAe,CAAC;aACrC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAsFD,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAC3C,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,UAAU,CAAC,uBAAuB,GAAG,oBAAoB,CAAC,EAAE,uCAAuC;AACnG,AAD4D,uCAAuC;AACnG;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EAAE,4CAA4C;AACtE,uBAAuB,CAyLxB,CAAC"}
|
|
@@ -8,7 +8,7 @@ import { stripPageSuffix } from "../../utils/string-utils";
|
|
|
8
8
|
import { DEFAULT_ACTION_TIMEOUT_MS } from "../../constants";
|
|
9
9
|
import { setMethodMetadata } from "../../utils/telemetry-context";
|
|
10
10
|
async function executeAction(actionOptions) {
|
|
11
|
-
const { api, selectedApi, actionId, actionKey, actionType, executionOptions, connectionId, timeoutMs, } = actionOptions;
|
|
11
|
+
const { api, selectedApi, actionId, actionKey, actionType, executionOptions, cursor, connectionId, timeoutMs, } = actionOptions;
|
|
12
12
|
// Step 1: POST to /actions/v1/runs to start execution
|
|
13
13
|
const runRequestData = {
|
|
14
14
|
selected_api: selectedApi,
|
|
@@ -22,6 +22,9 @@ async function executeAction(actionOptions) {
|
|
|
22
22
|
if (connectionId !== null && connectionId !== undefined) {
|
|
23
23
|
runRequestData.authentication_id = connectionId;
|
|
24
24
|
}
|
|
25
|
+
if (cursor) {
|
|
26
|
+
runRequestData.page = cursor;
|
|
27
|
+
}
|
|
25
28
|
const runRequest = {
|
|
26
29
|
data: runRequestData,
|
|
27
30
|
};
|
|
@@ -39,21 +42,62 @@ async function executeAction(actionOptions) {
|
|
|
39
42
|
resultExtractor: (result) => result.data,
|
|
40
43
|
});
|
|
41
44
|
}
|
|
45
|
+
export const CONTEXT_CACHE_TTL_MS = 60000;
|
|
46
|
+
export const CONTEXT_CACHE_MAX_SIZE = 500;
|
|
42
47
|
export const runActionPlugin = ({ sdk, context }) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
// Intentionally kept inline — only this plugin needs this pattern today.
|
|
49
|
+
// If a second plugin needs a bounded TTL cache, extract to a shared utility.
|
|
50
|
+
const runActionContextCache = new Map();
|
|
51
|
+
function evictIfNeeded() {
|
|
52
|
+
if (runActionContextCache.size < CONTEXT_CACHE_MAX_SIZE)
|
|
53
|
+
return;
|
|
54
|
+
const now = Date.now();
|
|
55
|
+
let oldestKey;
|
|
56
|
+
let oldestExpiry = Infinity;
|
|
57
|
+
let evictedAny = false;
|
|
58
|
+
for (const [key, entry] of runActionContextCache) {
|
|
59
|
+
if (now >= entry.expiresAt) {
|
|
60
|
+
runActionContextCache.delete(key);
|
|
61
|
+
evictedAny = true;
|
|
62
|
+
}
|
|
63
|
+
else if (entry.expiresAt < oldestExpiry) {
|
|
64
|
+
oldestExpiry = entry.expiresAt;
|
|
65
|
+
oldestKey = key;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!evictedAny && oldestKey) {
|
|
69
|
+
runActionContextCache.delete(oldestKey);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function getRunActionContext(options) {
|
|
73
|
+
const { appKey, actionKey, actionType } = options;
|
|
74
|
+
const contextKey = `${appKey}:${actionKey}:${actionType}`;
|
|
75
|
+
const cached = runActionContextCache.get(contextKey);
|
|
76
|
+
if (cached && Date.now() < cached.expiresAt) {
|
|
77
|
+
return cached.promise;
|
|
78
|
+
}
|
|
79
|
+
const pendingContext = resolveRunActionContext(options).catch((error) => {
|
|
80
|
+
// Only delete our own entry — a later interleaved call for the same key
|
|
81
|
+
// may have already replaced it with a fresh promise.
|
|
82
|
+
const current = runActionContextCache.get(contextKey);
|
|
83
|
+
if (current?.promise === pendingContext) {
|
|
84
|
+
runActionContextCache.delete(contextKey);
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
});
|
|
88
|
+
evictIfNeeded();
|
|
89
|
+
runActionContextCache.set(contextKey, {
|
|
90
|
+
promise: pendingContext,
|
|
91
|
+
expiresAt: Date.now() + CONTEXT_CACHE_TTL_MS,
|
|
92
|
+
});
|
|
93
|
+
return pendingContext;
|
|
94
|
+
}
|
|
95
|
+
async function resolveRunActionContext(options) {
|
|
96
|
+
const { appKey, actionKey, actionType } = options;
|
|
48
97
|
const selectedApi = await context.getVersionedImplementationId(appKey);
|
|
49
98
|
if (!selectedApi) {
|
|
50
99
|
throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
|
|
51
100
|
}
|
|
52
|
-
setMethodMetadata({
|
|
53
|
-
selectedApi,
|
|
54
|
-
operationType: actionType,
|
|
55
|
-
operationKey: actionKey,
|
|
56
|
-
});
|
|
57
101
|
// Validate that the action exists using the getAction plugin
|
|
58
102
|
const actionData = await sdk.getAction({
|
|
59
103
|
appKey: appKey,
|
|
@@ -64,7 +108,19 @@ export const runActionPlugin = ({ sdk, context }) => {
|
|
|
64
108
|
if (actionData.data.action_type !== actionType) {
|
|
65
109
|
throw new ZapierValidationError(`Action type mismatch: expected ${actionType}, got ${actionData.data.action_type}`);
|
|
66
110
|
}
|
|
67
|
-
|
|
111
|
+
return { selectedApi, actionId: actionData.data.id };
|
|
112
|
+
}
|
|
113
|
+
async function runActionPage(options) {
|
|
114
|
+
const { api } = context;
|
|
115
|
+
const { appKey, actionKey, actionType, connectionId, authenticationId, inputs = {}, cursor, timeoutMs, } = options;
|
|
116
|
+
// Support both connectionId (new) and authenticationId (deprecated)
|
|
117
|
+
const resolvedConnectionId = connectionId ?? authenticationId;
|
|
118
|
+
const { selectedApi, actionId } = await getRunActionContext(options);
|
|
119
|
+
setMethodMetadata({
|
|
120
|
+
selectedApi,
|
|
121
|
+
operationType: actionType,
|
|
122
|
+
operationKey: actionKey,
|
|
123
|
+
});
|
|
68
124
|
// Execute the action using the Actions API (supports all action types)
|
|
69
125
|
const result = await executeAction({
|
|
70
126
|
api,
|
|
@@ -75,6 +131,7 @@ export const runActionPlugin = ({ sdk, context }) => {
|
|
|
75
131
|
actionKey,
|
|
76
132
|
actionType,
|
|
77
133
|
executionOptions: { inputs },
|
|
134
|
+
cursor,
|
|
78
135
|
connectionId: resolvedConnectionId,
|
|
79
136
|
timeoutMs,
|
|
80
137
|
});
|
|
@@ -88,13 +145,15 @@ export const runActionPlugin = ({ sdk, context }) => {
|
|
|
88
145
|
actionKey,
|
|
89
146
|
});
|
|
90
147
|
}
|
|
91
|
-
// Return the results array wrapped in data with empty nextCursor (no pagination for action execution)
|
|
92
148
|
return {
|
|
93
149
|
data: result.results || [],
|
|
94
|
-
nextCursor:
|
|
150
|
+
nextCursor: result.next_page,
|
|
95
151
|
};
|
|
96
152
|
}
|
|
97
153
|
const methodName = stripPageSuffix(runActionPage.name);
|
|
154
|
+
// No defaultPageSize — we leave the default to the Actions API rather than
|
|
155
|
+
// eagerly running more actions than the user intends to
|
|
156
|
+
// (and avoid potentially hitting app rate limits).
|
|
98
157
|
const runActionDefinition = createPaginatedFunction(runActionPage, RunActionSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
|
|
99
158
|
return {
|
|
100
159
|
runAction: runActionDefinition,
|
|
@@ -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
|
+
};
|