@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.
Files changed (156) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +341 -0
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +10 -2
  5. package/dist/api/types.d.ts +2 -1
  6. package/dist/api/types.d.ts.map +1 -1
  7. package/dist/constants.d.ts +4 -0
  8. package/dist/constants.d.ts.map +1 -1
  9. package/dist/constants.js +4 -0
  10. package/dist/formatters/index.d.ts +2 -0
  11. package/dist/formatters/index.d.ts.map +1 -0
  12. package/dist/formatters/index.js +1 -0
  13. package/dist/formatters/tableRecord.d.ts +6 -0
  14. package/dist/formatters/tableRecord.d.ts.map +1 -0
  15. package/dist/formatters/tableRecord.js +23 -0
  16. package/dist/index.cjs +2054 -191
  17. package/dist/index.d.mts +639 -59
  18. package/dist/index.d.ts +13 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +13 -0
  21. package/dist/index.mjs +2030 -192
  22. package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
  23. package/dist/plugins/deleteClientCredentials/index.js +1 -1
  24. package/dist/plugins/listActions/index.d.ts.map +1 -1
  25. package/dist/plugins/listActions/index.js +2 -1
  26. package/dist/plugins/listApps/index.d.ts.map +1 -1
  27. package/dist/plugins/listApps/index.js +5 -2
  28. package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
  29. package/dist/plugins/listClientCredentials/index.js +6 -4
  30. package/dist/plugins/listConnections/index.d.ts.map +1 -1
  31. package/dist/plugins/listConnections/index.js +6 -4
  32. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  33. package/dist/plugins/listInputFieldChoices/index.js +2 -1
  34. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  35. package/dist/plugins/listInputFields/index.js +2 -1
  36. package/dist/plugins/registry/index.d.ts.map +1 -1
  37. package/dist/plugins/registry/index.js +4 -0
  38. package/dist/plugins/runAction/index.d.ts +2 -0
  39. package/dist/plugins/runAction/index.d.ts.map +1 -1
  40. package/dist/plugins/runAction/index.js +73 -14
  41. package/dist/plugins/tables/createTable/index.d.ts +18 -0
  42. package/dist/plugins/tables/createTable/index.d.ts.map +1 -0
  43. package/dist/plugins/tables/createTable/index.js +48 -0
  44. package/dist/plugins/tables/createTable/schemas.d.ts +37 -0
  45. package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -0
  46. package/dist/plugins/tables/createTable/schemas.js +16 -0
  47. package/dist/plugins/tables/createTableFields/index.d.ts +18 -0
  48. package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -0
  49. package/dist/plugins/tables/createTableFields/index.js +49 -0
  50. package/dist/plugins/tables/createTableFields/schemas.d.ts +192 -0
  51. package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -0
  52. package/dist/plugins/tables/createTableFields/schemas.js +42 -0
  53. package/dist/plugins/tables/createTableRecords/index.d.ts +18 -0
  54. package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -0
  55. package/dist/plugins/tables/createTableRecords/index.js +67 -0
  56. package/dist/plugins/tables/createTableRecords/schemas.d.ts +57 -0
  57. package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -0
  58. package/dist/plugins/tables/createTableRecords/schemas.js +35 -0
  59. package/dist/plugins/tables/deleteTable/index.d.ts +18 -0
  60. package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -0
  61. package/dist/plugins/tables/deleteTable/index.js +43 -0
  62. package/dist/plugins/tables/deleteTable/schemas.d.ts +15 -0
  63. package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -0
  64. package/dist/plugins/tables/deleteTable/schemas.js +9 -0
  65. package/dist/plugins/tables/deleteTableFields/index.d.ts +18 -0
  66. package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -0
  67. package/dist/plugins/tables/deleteTableFields/index.js +50 -0
  68. package/dist/plugins/tables/deleteTableFields/schemas.d.ts +16 -0
  69. package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -0
  70. package/dist/plugins/tables/deleteTableFields/schemas.js +13 -0
  71. package/dist/plugins/tables/deleteTableRecords/index.d.ts +18 -0
  72. package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -0
  73. package/dist/plugins/tables/deleteTableRecords/index.js +44 -0
  74. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +16 -0
  75. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -0
  76. package/dist/plugins/tables/deleteTableRecords/schemas.js +14 -0
  77. package/dist/plugins/tables/getTable/index.d.ts +20 -0
  78. package/dist/plugins/tables/getTable/index.d.ts.map +1 -0
  79. package/dist/plugins/tables/getTable/index.js +48 -0
  80. package/dist/plugins/tables/getTable/schemas.d.ts +34 -0
  81. package/dist/plugins/tables/getTable/schemas.d.ts.map +1 -0
  82. package/dist/plugins/tables/getTable/schemas.js +15 -0
  83. package/dist/plugins/tables/getTableRecord/index.d.ts +18 -0
  84. package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -0
  85. package/dist/plugins/tables/getTableRecord/index.js +60 -0
  86. package/dist/plugins/tables/getTableRecord/schemas.d.ts +51 -0
  87. package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -0
  88. package/dist/plugins/tables/getTableRecord/schemas.js +44 -0
  89. package/dist/plugins/tables/listTableFields/index.d.ts +18 -0
  90. package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -0
  91. package/dist/plugins/tables/listTableFields/index.js +58 -0
  92. package/dist/plugins/tables/listTableFields/schemas.d.ts +180 -0
  93. package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -0
  94. package/dist/plugins/tables/listTableFields/schemas.js +77 -0
  95. package/dist/plugins/tables/listTableRecords/index.d.ts +24 -0
  96. package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -0
  97. package/dist/plugins/tables/listTableRecords/index.js +97 -0
  98. package/dist/plugins/tables/listTableRecords/schemas.d.ts +120 -0
  99. package/dist/plugins/tables/listTableRecords/schemas.d.ts.map +1 -0
  100. package/dist/plugins/tables/listTableRecords/schemas.js +74 -0
  101. package/dist/plugins/tables/listTables/index.d.ts +24 -0
  102. package/dist/plugins/tables/listTables/index.d.ts.map +1 -0
  103. package/dist/plugins/tables/listTables/index.js +85 -0
  104. package/dist/plugins/tables/listTables/schemas.d.ts +78 -0
  105. package/dist/plugins/tables/listTables/schemas.d.ts.map +1 -0
  106. package/dist/plugins/tables/listTables/schemas.js +63 -0
  107. package/dist/plugins/tables/updateTableRecords/index.d.ts +18 -0
  108. package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -0
  109. package/dist/plugins/tables/updateTableRecords/index.js +68 -0
  110. package/dist/plugins/tables/updateTableRecords/schemas.d.ts +59 -0
  111. package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -0
  112. package/dist/plugins/tables/updateTableRecords/schemas.js +35 -0
  113. package/dist/plugins/tables/utils.d.ts +63 -0
  114. package/dist/plugins/tables/utils.d.ts.map +1 -0
  115. package/dist/plugins/tables/utils.js +262 -0
  116. package/dist/resolvers/index.d.ts +8 -0
  117. package/dist/resolvers/index.d.ts.map +1 -1
  118. package/dist/resolvers/index.js +8 -0
  119. package/dist/resolvers/tableFieldIds.d.ts +6 -0
  120. package/dist/resolvers/tableFieldIds.d.ts.map +1 -0
  121. package/dist/resolvers/tableFieldIds.js +19 -0
  122. package/dist/resolvers/tableFields.d.ts +3 -0
  123. package/dist/resolvers/tableFields.d.ts.map +1 -0
  124. package/dist/resolvers/tableFields.js +31 -0
  125. package/dist/resolvers/tableFilters.d.ts +5 -0
  126. package/dist/resolvers/tableFilters.d.ts.map +1 -0
  127. package/dist/resolvers/tableFilters.js +74 -0
  128. package/dist/resolvers/tableId.d.ts +4 -0
  129. package/dist/resolvers/tableId.d.ts.map +1 -0
  130. package/dist/resolvers/tableId.js +19 -0
  131. package/dist/resolvers/tableName.d.ts +3 -0
  132. package/dist/resolvers/tableName.d.ts.map +1 -0
  133. package/dist/resolvers/tableName.js +5 -0
  134. package/dist/resolvers/tableRecordId.d.ts +9 -0
  135. package/dist/resolvers/tableRecordId.d.ts.map +1 -0
  136. package/dist/resolvers/tableRecordId.js +48 -0
  137. package/dist/resolvers/tableRecords.d.ts +8 -0
  138. package/dist/resolvers/tableRecords.d.ts.map +1 -0
  139. package/dist/resolvers/tableRecords.js +77 -0
  140. package/dist/resolvers/tableSort.d.ts +5 -0
  141. package/dist/resolvers/tableSort.d.ts.map +1 -0
  142. package/dist/resolvers/tableSort.js +43 -0
  143. package/dist/sdk.d.ts +73 -1
  144. package/dist/sdk.d.ts.map +1 -1
  145. package/dist/sdk.js +25 -0
  146. package/dist/types/sdk.d.ts +16 -1
  147. package/dist/types/sdk.d.ts.map +1 -1
  148. package/dist/utils/function-utils.d.ts +2 -2
  149. package/dist/utils/function-utils.d.ts.map +1 -1
  150. package/dist/utils/function-utils.js +2 -3
  151. package/dist/utils/pagination-utils.d.ts +24 -0
  152. package/dist/utils/pagination-utils.d.ts.map +1 -1
  153. package/dist/utils/pagination-utils.js +78 -0
  154. package/dist/utils/schema-utils.d.ts +33 -5
  155. package/dist/utils/schema-utils.d.ts.map +1 -1
  156. package/package.json +7 -2
@@ -0,0 +1,18 @@
1
+ import type { Plugin } from "../../../types/plugin";
2
+ import type { ApiClient } from "../../../api";
3
+ import { DeleteTableRecordsOptionsSchema, type DeleteTableRecordsOptions, type DeleteTableRecordsResult } from "./schemas";
4
+ import type { EventEmissionContext } from "../../eventEmission";
5
+ export interface DeleteTableRecordsPluginProvides {
6
+ deleteTableRecords: (options: DeleteTableRecordsOptions) => Promise<DeleteTableRecordsResult>;
7
+ context: {
8
+ meta: {
9
+ deleteTableRecords: {
10
+ inputSchema: typeof DeleteTableRecordsOptionsSchema;
11
+ };
12
+ };
13
+ };
14
+ }
15
+ export declare const deleteTableRecordsPlugin: Plugin<{}, {
16
+ api: ApiClient;
17
+ } & EventEmissionContext, DeleteTableRecordsPluginProvides>;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTableRecords/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EACL,+BAA+B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC9B,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAKhE,MAAM,WAAW,gCAAgC;IAC/C,kBAAkB,EAAE,CAClB,OAAO,EAAE,yBAAyB,KAC/B,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACvC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,kBAAkB,EAAE;gBAClB,WAAW,EAAE,OAAO,+BAA+B,CAAC;aACrD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAC3C,EAAE,EACF;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EACzC,gCAAgC,CA8DjC,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { createFunction } from "../../../utils/function-utils";
2
+ import { DeleteTableRecordsOptionsSchema, } from "./schemas";
3
+ import { createTelemetryCallback } from "../../../utils/telemetry-utils";
4
+ import { ZapierAuthenticationError } from "../../../types/errors";
5
+ import { tableIdResolver, tableRecordIdsResolver } from "../../../resolvers";
6
+ export const deleteTableRecordsPlugin = ({ context }) => {
7
+ async function deleteTableRecords(options) {
8
+ const { api } = context;
9
+ await api.delete(`/tables/api/v1/tables/${options.tableId}/records`, { record_ids: options.recordIds }, {
10
+ customErrorHandler: ({ status }) => {
11
+ if (status === 401) {
12
+ return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to delete records or may be expired. (HTTP ${status})`, { statusCode: status });
13
+ }
14
+ if (status === 403) {
15
+ return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to delete records. (HTTP ${status})`, { statusCode: status });
16
+ }
17
+ return undefined;
18
+ },
19
+ authRequired: true,
20
+ });
21
+ return {
22
+ success: true,
23
+ };
24
+ }
25
+ const deleteTableRecordsDefinition = createFunction(deleteTableRecords, DeleteTableRecordsOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, deleteTableRecords.name));
26
+ return {
27
+ deleteTableRecords: deleteTableRecordsDefinition,
28
+ context: {
29
+ meta: {
30
+ deleteTableRecords: {
31
+ categories: ["table"],
32
+ type: "delete",
33
+ itemType: "Record",
34
+ inputSchema: DeleteTableRecordsOptionsSchema,
35
+ resolvers: {
36
+ tableId: tableIdResolver,
37
+ recordIds: tableRecordIdsResolver,
38
+ },
39
+ confirm: "delete",
40
+ },
41
+ },
42
+ },
43
+ };
44
+ };
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ import type { FunctionOptions } from "../../../types/functions";
3
+ import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
4
+ export declare const DeleteTableRecordsOptionsSchema: z.ZodObject<{
5
+ tableId: z.ZodString;
6
+ recordIds: z.ZodArray<z.ZodString>;
7
+ }, z.core.$strip>;
8
+ export type DeleteTableRecordsOptions = z.infer<typeof DeleteTableRecordsOptionsSchema> & FunctionOptions;
9
+ export interface DeleteTableRecordsResult {
10
+ success: boolean;
11
+ }
12
+ export type DeleteTableRecordsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
13
+ export interface DeleteTableRecordsSdkFunction {
14
+ deleteTableRecords: (options: DeleteTableRecordsOptions) => Promise<DeleteTableRecordsResult>;
15
+ }
16
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTableRecords/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;AAE/B,eAAO,MAAM,+BAA+B;;;iBAcU,CAAC;AAEvD,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,GACC,eAAe,CAAC;AAElB,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,uBAAuB,GAC/B,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,6BAA6B;IAC5C,kBAAkB,EAAE,CAClB,OAAO,EAAE,yBAAyB,KAC/B,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACxC"}
@@ -0,0 +1,14 @@
1
+ import { z } from "zod";
2
+ export const DeleteTableRecordsOptionsSchema = z
3
+ .object({
4
+ tableId: z
5
+ .string()
6
+ .regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID")
7
+ .describe("The unique identifier of the table"),
8
+ recordIds: z
9
+ .array(z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID"))
10
+ .min(1)
11
+ .max(100)
12
+ .describe("Array of record IDs to delete (max 100)"),
13
+ })
14
+ .describe("Delete one or more records from a table");
@@ -0,0 +1,20 @@
1
+ import type { Plugin } from "../../../types/plugin";
2
+ import type { ApiClient } from "../../../api";
3
+ import { GetTableOptionsSchema, type GetTableOptions, type TableItem } from "./schemas";
4
+ import type { EventEmissionContext } from "../../eventEmission";
5
+ export interface GetTablePluginProvides {
6
+ getTable: (options: GetTableOptions) => Promise<{
7
+ data: TableItem;
8
+ }>;
9
+ context: {
10
+ meta: {
11
+ getTable: {
12
+ inputSchema: typeof GetTableOptionsSchema;
13
+ };
14
+ };
15
+ };
16
+ }
17
+ export declare const getTablePlugin: Plugin<{}, {
18
+ api: ApiClient;
19
+ } & EventEmissionContext, GetTablePluginProvides>;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/getTable/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAEL,qBAAqB,EAErB,KAAK,eAAe,EACpB,KAAK,SAAS,EACf,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAMhE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IACrE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR,WAAW,EAAE,OAAO,qBAAqB,CAAC;aAC3C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EACF;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EACzC,sBAAsB,CAgEvB,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { createFunction } from "../../../utils/function-utils";
2
+ import { GetTableApiResponseSchema, GetTableOptionsSchema, TableItemSchema, } from "./schemas";
3
+ import { createTelemetryCallback } from "../../../utils/telemetry-utils";
4
+ import { ZapierAuthenticationError } from "../../../types/errors";
5
+ import { tableIdResolver } from "../../../resolvers";
6
+ import { transformTableItem } from "../utils";
7
+ export const getTablePlugin = ({ context }) => {
8
+ async function getTable(options) {
9
+ const { api } = context;
10
+ const rawResponse = await api.get(`/tables/api/v1/tables/${options.tableId}`, {
11
+ customErrorHandler: ({ status }) => {
12
+ if (status === 401) {
13
+ return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access this table or may be expired. (HTTP ${status})`, { statusCode: status });
14
+ }
15
+ if (status === 403) {
16
+ return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to access this table. (HTTP ${status})`, { statusCode: status });
17
+ }
18
+ if (status === 404) {
19
+ return new Error(`Table not found: ${options.tableId}`);
20
+ }
21
+ return undefined;
22
+ },
23
+ authRequired: true,
24
+ });
25
+ const response = GetTableApiResponseSchema.parse(rawResponse);
26
+ return {
27
+ data: transformTableItem(response.data),
28
+ };
29
+ }
30
+ const getTableDefinition = createFunction(getTable, GetTableOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, getTable.name));
31
+ return {
32
+ getTable: getTableDefinition,
33
+ context: {
34
+ meta: {
35
+ getTable: {
36
+ categories: ["table"],
37
+ type: "item",
38
+ itemType: "Table",
39
+ inputSchema: GetTableOptionsSchema,
40
+ outputSchema: TableItemSchema,
41
+ resolvers: {
42
+ tableId: tableIdResolver,
43
+ },
44
+ },
45
+ },
46
+ },
47
+ };
48
+ };
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
3
+ import { TableItemSchema, TableApiItemSchema, type TableItem, type TableApiItem } from "../listTables/schemas";
4
+ export { TableItemSchema, TableApiItemSchema };
5
+ export type { TableItem, TableApiItem };
6
+ export declare const GetTableApiResponseSchema: z.ZodObject<{
7
+ data: z.ZodObject<{
8
+ id: z.ZodString;
9
+ name: z.ZodString;
10
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
+ created_at: z.ZodString;
12
+ edited_at: z.ZodString;
13
+ kind: z.ZodEnum<{
14
+ table: "table";
15
+ virtual_table: "virtual_table";
16
+ }>;
17
+ owner_account_id: z.ZodNumber;
18
+ owner_user_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
19
+ owner_zapier_customuser_id: z.ZodNumber;
20
+ parent_table_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
21
+ }, z.core.$strip>;
22
+ }, z.core.$strip>;
23
+ export type GetTableApiResponse = z.infer<typeof GetTableApiResponseSchema>;
24
+ export declare const GetTableOptionsSchema: z.ZodObject<{
25
+ tableId: z.ZodString;
26
+ }, z.core.$strip>;
27
+ export type GetTableOptions = z.infer<typeof GetTableOptionsSchema>;
28
+ export type GetTableError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
29
+ export interface GetTableSdkFunction {
30
+ getTable: (options: GetTableOptions) => Promise<{
31
+ data: TableItem;
32
+ }>;
33
+ }
34
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/getTable/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,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,yBAAyB;;;;;;;;;;;;;;;;iBAEpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,qBAAqB;;iBAO4B,CAAC;AAE/D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAGpE,MAAM,MAAM,aAAa,GACrB,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CACtE"}
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ import { TableItemSchema, TableApiItemSchema, } from "../listTables/schemas";
3
+ // Re-export for consumers
4
+ export { TableItemSchema, TableApiItemSchema };
5
+ export const GetTableApiResponseSchema = z.object({
6
+ data: TableApiItemSchema,
7
+ });
8
+ export const GetTableOptionsSchema = z
9
+ .object({
10
+ tableId: z
11
+ .string()
12
+ .regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID")
13
+ .describe("The unique identifier of the table to retrieve"),
14
+ })
15
+ .describe("Get detailed information about a specific table");
@@ -0,0 +1,18 @@
1
+ import type { Plugin } from "../../../types/plugin";
2
+ import type { ApiClient } from "../../../api";
3
+ import { GetTableRecordOptionsSchema, type GetTableRecordOptions, type GetTableRecordResult } from "./schemas";
4
+ import type { EventEmissionContext } from "../../eventEmission";
5
+ export interface GetTableRecordPluginProvides {
6
+ getTableRecord: (options: GetTableRecordOptions) => Promise<GetTableRecordResult>;
7
+ context: {
8
+ meta: {
9
+ getTableRecord: {
10
+ inputSchema: typeof GetTableRecordOptionsSchema;
11
+ };
12
+ };
13
+ };
14
+ }
15
+ export declare const getTableRecordPlugin: Plugin<{}, {
16
+ api: ApiClient;
17
+ } & EventEmissionContext, GetTableRecordPluginProvides>;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/getTableRecord/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,2BAA2B,EAG3B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAQhE,MAAM,WAAW,4BAA4B;IAC3C,cAAc,EAAE,CACd,OAAO,EAAE,qBAAqB,KAC3B,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACnC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,cAAc,EAAE;gBACd,WAAW,EAAE,OAAO,2BAA2B,CAAC;aACjD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,oBAAoB,EAAE,MAAM,CACvC,EAAE,EACF;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EACzC,4BAA4B,CA4E7B,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { createFunction } from "../../../utils/function-utils";
2
+ import { GetTableRecordOptionsSchema, GetTableRecordApiResponseSchema, RecordItemSchema, } from "./schemas";
3
+ import { createTelemetryCallback } from "../../../utils/telemetry-utils";
4
+ import { ZapierAuthenticationError } from "../../../types/errors";
5
+ import { tableIdResolver, tableRecordIdResolver } from "../../../resolvers";
6
+ import { tableRecordFormatter } from "../../../formatters";
7
+ import { createFieldKeyTranslator } from "../utils";
8
+ import { transformRecordItem } from "../utils";
9
+ export const getTableRecordPlugin = ({ context }) => {
10
+ async function getTableRecord(options) {
11
+ const { api } = context;
12
+ const rawResponse = await api.get(`/tables/api/v1/tables/${options.tableId}/records/${options.recordId}`, {
13
+ customErrorHandler: ({ status }) => {
14
+ if (status === 401) {
15
+ return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access this record 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 access this record. (HTTP ${status})`, { statusCode: status });
19
+ }
20
+ if (status === 404) {
21
+ return new Error(`Record not found: ${options.recordId}`);
22
+ }
23
+ return undefined;
24
+ },
25
+ authRequired: true,
26
+ });
27
+ const response = GetTableRecordApiResponseSchema.parse(rawResponse);
28
+ const translator = await createFieldKeyTranslator({
29
+ api,
30
+ tableId: options.tableId,
31
+ keyMode: options.keyMode,
32
+ });
33
+ return {
34
+ data: {
35
+ ...transformRecordItem(response.data),
36
+ data: translator.translateOutput(response.data.data),
37
+ },
38
+ };
39
+ }
40
+ const getTableRecordDefinition = createFunction(getTableRecord, GetTableRecordOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, getTableRecord.name));
41
+ return {
42
+ getTableRecord: getTableRecordDefinition,
43
+ context: {
44
+ meta: {
45
+ getTableRecord: {
46
+ categories: ["table"],
47
+ type: "item",
48
+ itemType: "Record",
49
+ inputSchema: GetTableRecordOptionsSchema,
50
+ outputSchema: RecordItemSchema,
51
+ resolvers: {
52
+ tableId: tableIdResolver,
53
+ recordId: tableRecordIdResolver,
54
+ },
55
+ formatter: tableRecordFormatter,
56
+ },
57
+ },
58
+ },
59
+ };
60
+ };
@@ -0,0 +1,51 @@
1
+ import { z } from "zod";
2
+ import type { FunctionOptions } from "../../../types/functions";
3
+ import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
4
+ export declare const RecordApiItemSchema: z.ZodObject<{
5
+ id: z.ZodString;
6
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
7
+ created_at: z.ZodString;
8
+ edited_at: z.ZodString;
9
+ schema_revision_id: z.ZodNumber;
10
+ errors: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
11
+ orig_data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
12
+ is_source_record: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
13
+ }, z.core.$strip>;
14
+ export type RecordApiItem = z.infer<typeof RecordApiItemSchema>;
15
+ export declare const RecordItemSchema: z.ZodObject<{
16
+ id: z.ZodString;
17
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
18
+ created_at: z.ZodString;
19
+ edited_at: z.ZodString;
20
+ }, z.core.$strip>;
21
+ export type RecordItem = z.infer<typeof RecordItemSchema>;
22
+ export declare const GetTableRecordApiResponseSchema: z.ZodObject<{
23
+ data: z.ZodObject<{
24
+ id: z.ZodString;
25
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
26
+ created_at: z.ZodString;
27
+ edited_at: z.ZodString;
28
+ schema_revision_id: z.ZodNumber;
29
+ errors: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
30
+ orig_data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
31
+ is_source_record: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
32
+ }, z.core.$strip>;
33
+ }, z.core.$strip>;
34
+ export type GetTableRecordApiResponse = z.infer<typeof GetTableRecordApiResponseSchema>;
35
+ export declare const GetTableRecordOptionsSchema: z.ZodObject<{
36
+ tableId: z.ZodString;
37
+ recordId: z.ZodString;
38
+ keyMode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
39
+ names: "names";
40
+ ids: "ids";
41
+ }>>>;
42
+ }, z.core.$strip>;
43
+ export type GetTableRecordOptions = z.infer<typeof GetTableRecordOptionsSchema> & FunctionOptions;
44
+ export interface GetTableRecordResult {
45
+ data: RecordItem;
46
+ }
47
+ export type GetTableRecordError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
48
+ export interface GetTableRecordSdkFunction {
49
+ getTableRecord: (options: GetTableRecordOptions) => Promise<GetTableRecordResult>;
50
+ }
51
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/getTableRecord/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;AAI/B,eAAO,MAAM,mBAAmB;;;;;;;;;iBAS9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAUhE,eAAO,MAAM,gBAAgB;;;;;iBAO3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,+BAA+B;;;;;;;;;;;iBAE1C,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;;;;;iBAYa,CAAC;AAEtD,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CACzC,OAAO,2BAA2B,CACnC,GACC,eAAe,CAAC;AAElB,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,MAAM,mBAAmB,GAC3B,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,yBAAyB;IACxC,cAAc,EAAE,CACd,OAAO,EAAE,qBAAqB,KAC3B,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACpC"}
@@ -0,0 +1,44 @@
1
+ import { z } from "zod";
2
+ import { withFormatter } from "../../../utils/schema-utils";
3
+ import { KeyModeSchema } from "../utils";
4
+ export const RecordApiItemSchema = z.object({
5
+ id: z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID"),
6
+ data: z.record(z.string(), z.unknown()),
7
+ created_at: z.string(),
8
+ edited_at: z.string(),
9
+ schema_revision_id: z.number(),
10
+ errors: z.record(z.string(), z.unknown()).nullable().optional(),
11
+ orig_data: z.record(z.string(), z.unknown()).nullable().optional(),
12
+ is_source_record: z.boolean().nullable().optional(),
13
+ });
14
+ // SDK output schema (simplified)
15
+ const RecordItemSchemaBase = z.object({
16
+ id: z.string(),
17
+ data: z.record(z.string(), z.unknown()),
18
+ created_at: z.string(),
19
+ edited_at: z.string(),
20
+ });
21
+ export const RecordItemSchema = withFormatter(RecordItemSchemaBase, {
22
+ format: (item) => ({
23
+ title: `Record ${item.id}`,
24
+ id: item.id,
25
+ data: item.data,
26
+ details: [],
27
+ }),
28
+ });
29
+ export const GetTableRecordApiResponseSchema = z.object({
30
+ data: RecordApiItemSchema,
31
+ });
32
+ export const GetTableRecordOptionsSchema = z
33
+ .object({
34
+ tableId: z
35
+ .string()
36
+ .regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID")
37
+ .describe("The unique identifier of the table"),
38
+ recordId: z
39
+ .string()
40
+ .regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")
41
+ .describe("The unique identifier of the record"),
42
+ keyMode: KeyModeSchema,
43
+ })
44
+ .describe("Get a single record from a table by ID");
@@ -0,0 +1,18 @@
1
+ import type { Plugin } from "../../../types/plugin";
2
+ import type { ApiClient } from "../../../api";
3
+ import { ListTableFieldsOptionsSchema, type ListTableFieldsOptions, type ListTableFieldsResult } from "./schemas";
4
+ import type { EventEmissionContext } from "../../eventEmission";
5
+ export interface ListTableFieldsPluginProvides {
6
+ listTableFields: (options: ListTableFieldsOptions) => Promise<ListTableFieldsResult>;
7
+ context: {
8
+ meta: {
9
+ listTableFields: {
10
+ inputSchema: typeof ListTableFieldsOptionsSchema;
11
+ };
12
+ };
13
+ };
14
+ }
15
+ export declare const listTableFieldsPlugin: Plugin<{}, {
16
+ api: ApiClient;
17
+ } & EventEmissionContext, ListTableFieldsPluginProvides>;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTableFields/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,4BAA4B,EAG5B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC3B,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAMhE,MAAM,WAAW,6BAA6B;IAC5C,eAAe,EAAE,CACf,OAAO,EAAE,sBAAsB,KAC5B,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACpC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,eAAe,EAAE;gBACf,WAAW,EAAE,OAAO,4BAA4B,CAAC;aAClD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,EAAE,EACF;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EACzC,6BAA6B,CA6E9B,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { createFunction } from "../../../utils/function-utils";
2
+ import { ListTableFieldsOptionsSchema, ListTableFieldsApiResponseSchema, FieldItemSchema, } from "./schemas";
3
+ import { createTelemetryCallback } from "../../../utils/telemetry-utils";
4
+ import { ZapierAuthenticationError } from "../../../types/errors";
5
+ import { tableIdResolver } from "../../../resolvers";
6
+ import { resolveFieldKeys, transformFieldItem } from "../utils";
7
+ export const listTableFieldsPlugin = ({ context }) => {
8
+ async function listTableFields(options) {
9
+ const { api } = context;
10
+ const searchParams = {};
11
+ if (options.fieldKeys && options.fieldKeys.length > 0) {
12
+ const numericIds = await resolveFieldKeys({
13
+ api,
14
+ tableId: options.tableId,
15
+ fieldKeys: options.fieldKeys,
16
+ });
17
+ searchParams.field_ids = numericIds.join(",");
18
+ }
19
+ const rawResponse = await api.get(`/tables/api/v1/tables/${options.tableId}/fields`, {
20
+ searchParams: Object.keys(searchParams).length > 0 ? searchParams : undefined,
21
+ customErrorHandler: ({ status }) => {
22
+ if (status === 401) {
23
+ return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access this table or may be expired. (HTTP ${status})`, { statusCode: status });
24
+ }
25
+ if (status === 403) {
26
+ return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to access this table. (HTTP ${status})`, { statusCode: status });
27
+ }
28
+ if (status === 404) {
29
+ return new Error(`Table not found: ${options.tableId}`);
30
+ }
31
+ return undefined;
32
+ },
33
+ authRequired: true,
34
+ });
35
+ const response = ListTableFieldsApiResponseSchema.parse(rawResponse);
36
+ return {
37
+ data: response.data.map(transformFieldItem),
38
+ };
39
+ }
40
+ const listTableFieldsDefinition = createFunction(listTableFields, ListTableFieldsOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, listTableFields.name));
41
+ return {
42
+ listTableFields: listTableFieldsDefinition,
43
+ context: {
44
+ meta: {
45
+ listTableFields: {
46
+ categories: ["table"],
47
+ type: "list",
48
+ itemType: "Field",
49
+ inputSchema: ListTableFieldsOptionsSchema,
50
+ outputSchema: FieldItemSchema,
51
+ resolvers: {
52
+ tableId: tableIdResolver,
53
+ },
54
+ },
55
+ },
56
+ },
57
+ };
58
+ };