@zapier/zapier-sdk 0.34.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) 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/formatters/index.d.ts +2 -0
  8. package/dist/formatters/index.d.ts.map +1 -0
  9. package/dist/formatters/index.js +1 -0
  10. package/dist/formatters/tableRecord.d.ts +6 -0
  11. package/dist/formatters/tableRecord.d.ts.map +1 -0
  12. package/dist/formatters/tableRecord.js +23 -0
  13. package/dist/index.cjs +1828 -35
  14. package/dist/index.d.mts +644 -70
  15. package/dist/index.d.ts +13 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +13 -0
  18. package/dist/index.mjs +1807 -36
  19. package/dist/plugins/apps/schemas.d.ts +11 -11
  20. package/dist/plugins/apps/schemas.d.ts.map +1 -1
  21. package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
  22. package/dist/plugins/deleteClientCredentials/index.js +1 -1
  23. package/dist/plugins/registry/index.d.ts.map +1 -1
  24. package/dist/plugins/registry/index.js +4 -0
  25. package/dist/plugins/tables/createTable/index.d.ts +18 -0
  26. package/dist/plugins/tables/createTable/index.d.ts.map +1 -0
  27. package/dist/plugins/tables/createTable/index.js +48 -0
  28. package/dist/plugins/tables/createTable/schemas.d.ts +37 -0
  29. package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -0
  30. package/dist/plugins/tables/createTable/schemas.js +16 -0
  31. package/dist/plugins/tables/createTableFields/index.d.ts +18 -0
  32. package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -0
  33. package/dist/plugins/tables/createTableFields/index.js +49 -0
  34. package/dist/plugins/tables/createTableFields/schemas.d.ts +192 -0
  35. package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -0
  36. package/dist/plugins/tables/createTableFields/schemas.js +42 -0
  37. package/dist/plugins/tables/createTableRecords/index.d.ts +18 -0
  38. package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -0
  39. package/dist/plugins/tables/createTableRecords/index.js +67 -0
  40. package/dist/plugins/tables/createTableRecords/schemas.d.ts +57 -0
  41. package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -0
  42. package/dist/plugins/tables/createTableRecords/schemas.js +35 -0
  43. package/dist/plugins/tables/deleteTable/index.d.ts +18 -0
  44. package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -0
  45. package/dist/plugins/tables/deleteTable/index.js +43 -0
  46. package/dist/plugins/tables/deleteTable/schemas.d.ts +15 -0
  47. package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -0
  48. package/dist/plugins/tables/deleteTable/schemas.js +9 -0
  49. package/dist/plugins/tables/deleteTableFields/index.d.ts +18 -0
  50. package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -0
  51. package/dist/plugins/tables/deleteTableFields/index.js +50 -0
  52. package/dist/plugins/tables/deleteTableFields/schemas.d.ts +16 -0
  53. package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -0
  54. package/dist/plugins/tables/deleteTableFields/schemas.js +13 -0
  55. package/dist/plugins/tables/deleteTableRecords/index.d.ts +18 -0
  56. package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -0
  57. package/dist/plugins/tables/deleteTableRecords/index.js +44 -0
  58. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +16 -0
  59. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -0
  60. package/dist/plugins/tables/deleteTableRecords/schemas.js +14 -0
  61. package/dist/plugins/tables/getTable/index.d.ts +20 -0
  62. package/dist/plugins/tables/getTable/index.d.ts.map +1 -0
  63. package/dist/plugins/tables/getTable/index.js +48 -0
  64. package/dist/plugins/tables/getTable/schemas.d.ts +34 -0
  65. package/dist/plugins/tables/getTable/schemas.d.ts.map +1 -0
  66. package/dist/plugins/tables/getTable/schemas.js +15 -0
  67. package/dist/plugins/tables/getTableRecord/index.d.ts +18 -0
  68. package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -0
  69. package/dist/plugins/tables/getTableRecord/index.js +60 -0
  70. package/dist/plugins/tables/getTableRecord/schemas.d.ts +51 -0
  71. package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -0
  72. package/dist/plugins/tables/getTableRecord/schemas.js +44 -0
  73. package/dist/plugins/tables/listTableFields/index.d.ts +18 -0
  74. package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -0
  75. package/dist/plugins/tables/listTableFields/index.js +58 -0
  76. package/dist/plugins/tables/listTableFields/schemas.d.ts +180 -0
  77. package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -0
  78. package/dist/plugins/tables/listTableFields/schemas.js +77 -0
  79. package/dist/plugins/tables/listTableRecords/index.d.ts +24 -0
  80. package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -0
  81. package/dist/plugins/tables/listTableRecords/index.js +95 -0
  82. package/dist/plugins/tables/listTableRecords/schemas.d.ts +120 -0
  83. package/dist/plugins/tables/listTableRecords/schemas.d.ts.map +1 -0
  84. package/dist/plugins/tables/listTableRecords/schemas.js +74 -0
  85. package/dist/plugins/tables/listTables/index.d.ts +24 -0
  86. package/dist/plugins/tables/listTables/index.d.ts.map +1 -0
  87. package/dist/plugins/tables/listTables/index.js +83 -0
  88. package/dist/plugins/tables/listTables/schemas.d.ts +78 -0
  89. package/dist/plugins/tables/listTables/schemas.d.ts.map +1 -0
  90. package/dist/plugins/tables/listTables/schemas.js +63 -0
  91. package/dist/plugins/tables/updateTableRecords/index.d.ts +18 -0
  92. package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -0
  93. package/dist/plugins/tables/updateTableRecords/index.js +68 -0
  94. package/dist/plugins/tables/updateTableRecords/schemas.d.ts +59 -0
  95. package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -0
  96. package/dist/plugins/tables/updateTableRecords/schemas.js +35 -0
  97. package/dist/plugins/tables/utils.d.ts +63 -0
  98. package/dist/plugins/tables/utils.d.ts.map +1 -0
  99. package/dist/plugins/tables/utils.js +262 -0
  100. package/dist/resolvers/index.d.ts +8 -0
  101. package/dist/resolvers/index.d.ts.map +1 -1
  102. package/dist/resolvers/index.js +8 -0
  103. package/dist/resolvers/tableFieldIds.d.ts +6 -0
  104. package/dist/resolvers/tableFieldIds.d.ts.map +1 -0
  105. package/dist/resolvers/tableFieldIds.js +19 -0
  106. package/dist/resolvers/tableFields.d.ts +3 -0
  107. package/dist/resolvers/tableFields.d.ts.map +1 -0
  108. package/dist/resolvers/tableFields.js +31 -0
  109. package/dist/resolvers/tableFilters.d.ts +5 -0
  110. package/dist/resolvers/tableFilters.d.ts.map +1 -0
  111. package/dist/resolvers/tableFilters.js +74 -0
  112. package/dist/resolvers/tableId.d.ts +4 -0
  113. package/dist/resolvers/tableId.d.ts.map +1 -0
  114. package/dist/resolvers/tableId.js +19 -0
  115. package/dist/resolvers/tableName.d.ts +3 -0
  116. package/dist/resolvers/tableName.d.ts.map +1 -0
  117. package/dist/resolvers/tableName.js +5 -0
  118. package/dist/resolvers/tableRecordId.d.ts +9 -0
  119. package/dist/resolvers/tableRecordId.d.ts.map +1 -0
  120. package/dist/resolvers/tableRecordId.js +48 -0
  121. package/dist/resolvers/tableRecords.d.ts +8 -0
  122. package/dist/resolvers/tableRecords.d.ts.map +1 -0
  123. package/dist/resolvers/tableRecords.js +77 -0
  124. package/dist/resolvers/tableSort.d.ts +5 -0
  125. package/dist/resolvers/tableSort.d.ts.map +1 -0
  126. package/dist/resolvers/tableSort.js +43 -0
  127. package/dist/sdk.d.ts +73 -1
  128. package/dist/sdk.d.ts.map +1 -1
  129. package/dist/sdk.js +25 -0
  130. package/dist/types/sdk.d.ts +16 -1
  131. package/dist/types/sdk.d.ts.map +1 -1
  132. package/dist/utils/pagination-utils.d.ts +24 -0
  133. package/dist/utils/pagination-utils.d.ts.map +1 -1
  134. package/dist/utils/pagination-utils.js +78 -0
  135. package/dist/utils/schema-utils.d.ts +33 -5
  136. package/dist/utils/schema-utils.d.ts.map +1 -1
  137. package/package.json +2 -2
@@ -0,0 +1,57 @@
1
+ import { z } from "zod";
2
+ import type { FunctionOptions } from "../../../types/functions";
3
+ import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
4
+ import { RecordItemSchema, type RecordItem } from "../getTableRecord/schemas";
5
+ export { RecordItemSchema };
6
+ export type { RecordItem };
7
+ export declare const CreateTableRecordsApiResponseSchema: z.ZodObject<{
8
+ data: z.ZodArray<z.ZodObject<{
9
+ change_id: z.ZodString;
10
+ old: z.ZodNullable<z.ZodObject<{
11
+ id: z.ZodString;
12
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
13
+ created_at: z.ZodString;
14
+ edited_at: z.ZodString;
15
+ schema_revision_id: z.ZodNumber;
16
+ errors: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
17
+ orig_data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
18
+ is_source_record: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
19
+ }, z.core.$strip>>;
20
+ new: z.ZodObject<{
21
+ id: z.ZodString;
22
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
23
+ created_at: z.ZodString;
24
+ edited_at: z.ZodString;
25
+ schema_revision_id: z.ZodNumber;
26
+ errors: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
27
+ orig_data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
28
+ is_source_record: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
29
+ }, z.core.$strip>;
30
+ changed_field_ids: z.ZodNullable<z.ZodArray<z.ZodNumber>>;
31
+ record_id: z.ZodString;
32
+ }, z.core.$strip>>;
33
+ }, z.core.$strip>;
34
+ export type CreateTableRecordsApiResponse = z.infer<typeof CreateTableRecordsApiResponseSchema>;
35
+ export declare const NewRecordSchema: z.ZodObject<{
36
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
37
+ }, z.core.$strip>;
38
+ export type NewRecord = z.infer<typeof NewRecordSchema>;
39
+ export declare const CreateTableRecordsOptionsSchema: z.ZodObject<{
40
+ tableId: z.ZodString;
41
+ records: z.ZodArray<z.ZodObject<{
42
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
43
+ }, z.core.$strip>>;
44
+ keyMode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
45
+ names: "names";
46
+ ids: "ids";
47
+ }>>>;
48
+ }, z.core.$strip>;
49
+ export type CreateTableRecordsOptions = z.infer<typeof CreateTableRecordsOptionsSchema> & FunctionOptions;
50
+ export interface CreateTableRecordsResult {
51
+ data: RecordItem[];
52
+ }
53
+ export type CreateTableRecordsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
54
+ export interface CreateTableRecordsSdkFunction {
55
+ createTableRecords: (options: CreateTableRecordsOptions) => Promise<CreateTableRecordsResult>;
56
+ }
57
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/createTableRecords/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,gBAAgB,EAChB,KAAK,UAAU,EAChB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,YAAY,EAAE,UAAU,EAAE,CAAC;AAW3B,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;iBAE9C,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CACjD,OAAO,mCAAmC,CAC3C,CAAC;AAEF,eAAO,MAAM,eAAe;;iBAI1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,+BAA+B;;;;;;;;;iBAaQ,CAAC;AAErD,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,GACC,eAAe,CAAC;AAElB,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,UAAU,EAAE,CAAC;CACpB;AAED,MAAM,MAAM,uBAAuB,GAC/B,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,6BAA6B;IAC5C,kBAAkB,EAAE,CAClB,OAAO,EAAE,yBAAyB,KAC/B,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACxC"}
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import { RecordApiItemSchema, RecordItemSchema, } from "../getTableRecord/schemas";
3
+ import { KeyModeSchema } from "../utils";
4
+ // Re-export for consumers
5
+ export { RecordItemSchema };
6
+ // The API returns changesets with old/new values
7
+ const RecordChangesetSchema = z.object({
8
+ change_id: z.string(),
9
+ old: RecordApiItemSchema.nullable(),
10
+ new: RecordApiItemSchema,
11
+ changed_field_ids: z.array(z.number()).nullable(),
12
+ record_id: z.string(),
13
+ });
14
+ export const CreateTableRecordsApiResponseSchema = z.object({
15
+ data: z.array(RecordChangesetSchema),
16
+ });
17
+ export const NewRecordSchema = z.object({
18
+ data: z
19
+ .record(z.string(), z.unknown())
20
+ .describe("The field values for the record, keyed by field ID"),
21
+ });
22
+ export const CreateTableRecordsOptionsSchema = z
23
+ .object({
24
+ tableId: z
25
+ .string()
26
+ .regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID")
27
+ .describe("The unique identifier of the table"),
28
+ records: z
29
+ .array(NewRecordSchema)
30
+ .min(1)
31
+ .max(100)
32
+ .describe("Array of records to create (max 100)"),
33
+ keyMode: KeyModeSchema,
34
+ })
35
+ .describe("Create one or more records in a table");
@@ -0,0 +1,18 @@
1
+ import type { Plugin } from "../../../types/plugin";
2
+ import type { ApiClient } from "../../../api";
3
+ import { DeleteTableOptionsSchema, type DeleteTableOptions, type DeleteTableResult } from "./schemas";
4
+ import type { EventEmissionContext } from "../../eventEmission";
5
+ export interface DeleteTablePluginProvides {
6
+ deleteTable: (options: DeleteTableOptions) => Promise<DeleteTableResult>;
7
+ context: {
8
+ meta: {
9
+ deleteTable: {
10
+ inputSchema: typeof DeleteTableOptionsSchema;
11
+ };
12
+ };
13
+ };
14
+ }
15
+ export declare const deleteTablePlugin: Plugin<{}, {
16
+ api: ApiClient;
17
+ } & EventEmissionContext, DeleteTablePluginProvides>;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTable/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,EACxB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAKhE,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,CAyD1B,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { createFunction } from "../../../utils/function-utils";
2
+ import { DeleteTableOptionsSchema, } from "./schemas";
3
+ import { createTelemetryCallback } from "../../../utils/telemetry-utils";
4
+ import { ZapierAuthenticationError } from "../../../types/errors";
5
+ import { tableIdResolver } from "../../../resolvers";
6
+ export const deleteTablePlugin = ({ context }) => {
7
+ async function deleteTable(options) {
8
+ const { api } = context;
9
+ await api.delete(`/tables/api/v1/tables/${options.tableId}`, undefined, {
10
+ customErrorHandler: ({ status }) => {
11
+ if (status === 401) {
12
+ return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to delete tables 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 tables. (HTTP ${status})`, { statusCode: status });
16
+ }
17
+ return undefined;
18
+ },
19
+ authRequired: true,
20
+ });
21
+ return {
22
+ success: true,
23
+ };
24
+ }
25
+ const deleteTableDefinition = createFunction(deleteTable, DeleteTableOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, deleteTable.name));
26
+ return {
27
+ deleteTable: deleteTableDefinition,
28
+ context: {
29
+ meta: {
30
+ deleteTable: {
31
+ categories: ["table"],
32
+ type: "delete",
33
+ itemType: "Table",
34
+ inputSchema: DeleteTableOptionsSchema,
35
+ resolvers: {
36
+ tableId: tableIdResolver,
37
+ },
38
+ confirm: "delete",
39
+ },
40
+ },
41
+ },
42
+ };
43
+ };
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ import type { FunctionOptions } from "../../../types/functions";
3
+ import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierNotFoundError, ZapierUnknownError } from "../../../types/errors";
4
+ export declare const DeleteTableOptionsSchema: z.ZodObject<{
5
+ tableId: z.ZodString;
6
+ }, z.core.$strip>;
7
+ export type DeleteTableOptions = z.infer<typeof DeleteTableOptionsSchema> & FunctionOptions;
8
+ export interface DeleteTableResult {
9
+ success: boolean;
10
+ }
11
+ export type DeleteTableError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierNotFoundError | ZapierUnknownError;
12
+ export interface DeleteTableSdkFunction {
13
+ deleteTable: (options: DeleteTableOptions) => Promise<DeleteTableResult>;
14
+ }
15
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTable/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,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,wBAAwB;;iBAOE,CAAC;AAExC,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,GACvE,eAAe,CAAC;AAGlB,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;CAClB;AAGD,MAAM,MAAM,gBAAgB,GACxB,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,mBAAmB,GACnB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC1E"}
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ export const DeleteTableOptionsSchema = 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 to delete"),
8
+ })
9
+ .describe("Delete a table by its ID");
@@ -0,0 +1,18 @@
1
+ import type { Plugin } from "../../../types/plugin";
2
+ import type { ApiClient } from "../../../api";
3
+ import { DeleteTableFieldsOptionsSchema, type DeleteTableFieldsOptions, type DeleteTableFieldsResult } from "./schemas";
4
+ import type { EventEmissionContext } from "../../eventEmission";
5
+ export interface DeleteTableFieldsPluginProvides {
6
+ deleteTableFields: (options: DeleteTableFieldsOptions) => Promise<DeleteTableFieldsResult>;
7
+ context: {
8
+ meta: {
9
+ deleteTableFields: {
10
+ inputSchema: typeof DeleteTableFieldsOptionsSchema;
11
+ };
12
+ };
13
+ };
14
+ }
15
+ export declare const deleteTableFieldsPlugin: Plugin<{}, {
16
+ api: ApiClient;
17
+ } & EventEmissionContext, DeleteTableFieldsPluginProvides>;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTableFields/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,EAC9B,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,CAoEhC,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { createFunction } from "../../../utils/function-utils";
2
+ import { DeleteTableFieldsOptionsSchema, } from "./schemas";
3
+ import { createTelemetryCallback } from "../../../utils/telemetry-utils";
4
+ import { ZapierAuthenticationError } from "../../../types/errors";
5
+ import { tableIdResolver, tableFieldIdsResolver } from "../../../resolvers";
6
+ import { resolveFieldKeys } from "../utils";
7
+ export const deleteTableFieldsPlugin = ({ context }) => {
8
+ async function deleteTableFields(options) {
9
+ const { api } = context;
10
+ const numericFieldIds = await resolveFieldKeys({
11
+ api,
12
+ tableId: options.tableId,
13
+ fieldKeys: options.fieldKeys,
14
+ });
15
+ await api.delete(`/tables/api/v1/tables/${options.tableId}/fields`, { field_ids: numericFieldIds }, {
16
+ customErrorHandler: ({ status }) => {
17
+ if (status === 401) {
18
+ return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to delete fields or may be expired. (HTTP ${status})`, { statusCode: status });
19
+ }
20
+ if (status === 403) {
21
+ return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to delete fields. (HTTP ${status})`, { statusCode: status });
22
+ }
23
+ return undefined;
24
+ },
25
+ authRequired: true,
26
+ });
27
+ return {
28
+ success: true,
29
+ };
30
+ }
31
+ const deleteTableFieldsDefinition = createFunction(deleteTableFields, DeleteTableFieldsOptionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, deleteTableFields.name));
32
+ return {
33
+ deleteTableFields: deleteTableFieldsDefinition,
34
+ context: {
35
+ meta: {
36
+ deleteTableFields: {
37
+ categories: ["table"],
38
+ type: "delete",
39
+ itemType: "Field",
40
+ inputSchema: DeleteTableFieldsOptionsSchema,
41
+ resolvers: {
42
+ tableId: tableIdResolver,
43
+ fieldKeys: tableFieldIdsResolver,
44
+ },
45
+ confirm: "delete",
46
+ },
47
+ },
48
+ },
49
+ };
50
+ };
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ import type { FunctionOptions } from "../../../types/functions";
3
+ import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierNotFoundError, ZapierUnknownError } from "../../../types/errors";
4
+ export declare const DeleteTableFieldsOptionsSchema: z.ZodObject<{
5
+ tableId: z.ZodString;
6
+ fieldKeys: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
7
+ }, z.core.$strip>;
8
+ export type DeleteTableFieldsOptions = z.infer<typeof DeleteTableFieldsOptionsSchema> & FunctionOptions;
9
+ export interface DeleteTableFieldsResult {
10
+ success: boolean;
11
+ }
12
+ export type DeleteTableFieldsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierNotFoundError | ZapierUnknownError;
13
+ export interface DeleteTableFieldsSdkFunction {
14
+ deleteTableFields: (options: DeleteTableFieldsOptions) => Promise<DeleteTableFieldsResult>;
15
+ }
16
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTableFields/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,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,8BAA8B;;;iBAaU,CAAC;AAEtD,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,GACC,eAAe,CAAC;AAGlB,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,CAAC;CAClB;AAGD,MAAM,MAAM,sBAAsB,GAC9B,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,mBAAmB,GACnB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACvC"}
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ export const DeleteTableFieldsOptionsSchema = 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
+ fieldKeys: z
9
+ .array(z.union([z.string(), z.number()]))
10
+ .min(1)
11
+ .describe('Fields to delete. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'),
12
+ })
13
+ .describe("Delete one or more fields from a table");
@@ -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
+ };