@zapier/zapier-sdk 0.45.2 → 0.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/client.d.ts.map +1 -1
  3. package/dist/api/client.js +24 -7
  4. package/dist/api/schemas.d.ts +5 -5
  5. package/dist/api/types.d.ts +17 -0
  6. package/dist/api/types.d.ts.map +1 -1
  7. package/dist/auth.d.ts +27 -6
  8. package/dist/auth.d.ts.map +1 -1
  9. package/dist/auth.js +130 -92
  10. package/dist/cache.d.ts +50 -0
  11. package/dist/cache.d.ts.map +1 -0
  12. package/dist/cache.js +47 -0
  13. package/dist/index.cjs +3108 -3695
  14. package/dist/index.d.mts +6735 -2188
  15. package/dist/index.d.ts +5 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +1 -0
  18. package/dist/index.mjs +3105 -3696
  19. package/dist/plugins/api/index.d.ts +22 -10
  20. package/dist/plugins/api/index.d.ts.map +1 -1
  21. package/dist/plugins/api/index.js +4 -4
  22. package/dist/plugins/apps/index.d.ts +108 -7
  23. package/dist/plugins/apps/index.d.ts.map +1 -1
  24. package/dist/plugins/apps/index.js +3 -4
  25. package/dist/plugins/capabilities/index.d.ts +9 -6
  26. package/dist/plugins/capabilities/index.d.ts.map +1 -1
  27. package/dist/plugins/capabilities/index.js +3 -2
  28. package/dist/plugins/connections/index.d.ts +15 -9
  29. package/dist/plugins/connections/index.d.ts.map +1 -1
  30. package/dist/plugins/connections/index.js +3 -2
  31. package/dist/plugins/createClientCredentials/index.d.ts +26 -14
  32. package/dist/plugins/createClientCredentials/index.d.ts.map +1 -1
  33. package/dist/plugins/createClientCredentials/index.js +16 -39
  34. package/dist/plugins/createClientCredentials/schemas.d.ts +0 -2
  35. package/dist/plugins/createClientCredentials/schemas.d.ts.map +1 -1
  36. package/dist/plugins/deleteClientCredentials/index.d.ts +20 -14
  37. package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
  38. package/dist/plugins/deleteClientCredentials/index.js +18 -37
  39. package/dist/plugins/deleteClientCredentials/schemas.d.ts +0 -2
  40. package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +1 -1
  41. package/dist/plugins/deprecated/authentications.d.ts +597 -41
  42. package/dist/plugins/deprecated/authentications.d.ts.map +1 -1
  43. package/dist/plugins/deprecated/authentications.js +9 -8
  44. package/dist/plugins/eventEmission/index.d.ts +9 -6
  45. package/dist/plugins/eventEmission/index.d.ts.map +1 -1
  46. package/dist/plugins/eventEmission/index.js +3 -2
  47. package/dist/plugins/fetch/index.d.ts +40 -17
  48. package/dist/plugins/fetch/index.d.ts.map +1 -1
  49. package/dist/plugins/fetch/index.js +6 -4
  50. package/dist/plugins/findFirstConnection/index.d.ts +109 -14
  51. package/dist/plugins/findFirstConnection/index.d.ts.map +1 -1
  52. package/dist/plugins/findFirstConnection/index.js +14 -26
  53. package/dist/plugins/findFirstConnection/schemas.d.ts +0 -2
  54. package/dist/plugins/findFirstConnection/schemas.d.ts.map +1 -1
  55. package/dist/plugins/findUniqueConnection/index.d.ts +109 -14
  56. package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -1
  57. package/dist/plugins/findUniqueConnection/index.js +14 -26
  58. package/dist/plugins/findUniqueConnection/schemas.d.ts +0 -2
  59. package/dist/plugins/findUniqueConnection/schemas.d.ts.map +1 -1
  60. package/dist/plugins/getAction/index.d.ts +68 -15
  61. package/dist/plugins/getAction/index.d.ts.map +1 -1
  62. package/dist/plugins/getAction/index.js +21 -31
  63. package/dist/plugins/getAction/schemas.d.ts +4 -6
  64. package/dist/plugins/getAction/schemas.d.ts.map +1 -1
  65. package/dist/plugins/getApp/index.d.ts +140 -14
  66. package/dist/plugins/getApp/index.d.ts.map +1 -1
  67. package/dist/plugins/getApp/index.js +16 -38
  68. package/dist/plugins/getApp/schemas.d.ts +0 -2
  69. package/dist/plugins/getApp/schemas.d.ts.map +1 -1
  70. package/dist/plugins/getConnection/index.d.ts +50 -16
  71. package/dist/plugins/getConnection/index.d.ts.map +1 -1
  72. package/dist/plugins/getConnection/index.js +22 -29
  73. package/dist/plugins/getConnection/schemas.d.ts +0 -2
  74. package/dist/plugins/getConnection/schemas.d.ts.map +1 -1
  75. package/dist/plugins/getInputFieldsSchema/index.d.ts +59 -13
  76. package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
  77. package/dist/plugins/getInputFieldsSchema/index.js +21 -32
  78. package/dist/plugins/getInputFieldsSchema/schemas.d.ts +4 -6
  79. package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +1 -1
  80. package/dist/plugins/getProfile/index.d.ts +25 -18
  81. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  82. package/dist/plugins/getProfile/index.js +13 -26
  83. package/dist/plugins/getProfile/schemas.d.ts +0 -8
  84. package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
  85. package/dist/plugins/getProfile/schemas.js +0 -1
  86. package/dist/plugins/listActions/index.d.ts +73 -23
  87. package/dist/plugins/listActions/index.d.ts.map +1 -1
  88. package/dist/plugins/listActions/index.js +25 -53
  89. package/dist/plugins/listActions/schemas.d.ts +4 -15
  90. package/dist/plugins/listActions/schemas.d.ts.map +1 -1
  91. package/dist/plugins/listApps/index.d.ts +121 -13
  92. package/dist/plugins/listApps/index.d.ts.map +1 -1
  93. package/dist/plugins/listApps/index.js +22 -31
  94. package/dist/plugins/listApps/schemas.d.ts +0 -2
  95. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  96. package/dist/plugins/listClientCredentials/index.d.ts +29 -16
  97. package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
  98. package/dist/plugins/listClientCredentials/index.js +17 -37
  99. package/dist/plugins/listClientCredentials/schemas.d.ts +0 -2
  100. package/dist/plugins/listClientCredentials/schemas.d.ts.map +1 -1
  101. package/dist/plugins/listConnections/index.d.ts +95 -17
  102. package/dist/plugins/listConnections/index.d.ts.map +1 -1
  103. package/dist/plugins/listConnections/index.js +25 -49
  104. package/dist/plugins/listConnections/schemas.d.ts +0 -2
  105. package/dist/plugins/listConnections/schemas.d.ts.map +1 -1
  106. package/dist/plugins/listInputFieldChoices/index.d.ts +77 -22
  107. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  108. package/dist/plugins/listInputFieldChoices/index.js +27 -50
  109. package/dist/plugins/listInputFieldChoices/schemas.d.ts +4 -6
  110. package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
  111. package/dist/plugins/listInputFields/index.d.ts +154 -22
  112. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  113. package/dist/plugins/listInputFields/index.js +28 -41
  114. package/dist/plugins/listInputFields/schemas.d.ts +4 -6
  115. package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
  116. package/dist/plugins/manifest/index.d.ts +40 -36
  117. package/dist/plugins/manifest/index.d.ts.map +1 -1
  118. package/dist/plugins/manifest/index.js +3 -2
  119. package/dist/plugins/registry/index.d.ts +11 -9
  120. package/dist/plugins/registry/index.d.ts.map +1 -1
  121. package/dist/plugins/registry/index.js +3 -2
  122. package/dist/plugins/request/index.d.ts +61 -15
  123. package/dist/plugins/request/index.d.ts.map +1 -1
  124. package/dist/plugins/request/index.js +14 -22
  125. package/dist/plugins/request/schemas.d.ts +0 -2
  126. package/dist/plugins/request/schemas.d.ts.map +1 -1
  127. package/dist/plugins/runAction/index.d.ts +137 -23
  128. package/dist/plugins/runAction/index.d.ts.map +1 -1
  129. package/dist/plugins/runAction/index.js +65 -78
  130. package/dist/plugins/runAction/schemas.d.ts +4 -14
  131. package/dist/plugins/runAction/schemas.d.ts.map +1 -1
  132. package/dist/plugins/tables/createTable/index.d.ts +43 -11
  133. package/dist/plugins/tables/createTable/index.d.ts.map +1 -1
  134. package/dist/plugins/tables/createTable/index.js +16 -44
  135. package/dist/plugins/tables/createTable/schemas.d.ts +0 -2
  136. package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -1
  137. package/dist/plugins/tables/createTableFields/index.d.ts +54 -11
  138. package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -1
  139. package/dist/plugins/tables/createTableFields/index.js +17 -41
  140. package/dist/plugins/tables/createTableFields/schemas.d.ts +21 -23
  141. package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -1
  142. package/dist/plugins/tables/createTableRecords/index.d.ts +47 -11
  143. package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -1
  144. package/dist/plugins/tables/createTableRecords/index.js +17 -43
  145. package/dist/plugins/tables/createTableRecords/schemas.d.ts +0 -2
  146. package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -1
  147. package/dist/plugins/tables/deleteTable/index.d.ts +36 -13
  148. package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
  149. package/dist/plugins/tables/deleteTable/index.js +18 -40
  150. package/dist/plugins/tables/deleteTable/schemas.d.ts +0 -2
  151. package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -1
  152. package/dist/plugins/tables/deleteTableFields/index.d.ts +36 -11
  153. package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -1
  154. package/dist/plugins/tables/deleteTableFields/index.js +17 -39
  155. package/dist/plugins/tables/deleteTableFields/schemas.d.ts +0 -2
  156. package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -1
  157. package/dist/plugins/tables/deleteTableRecords/index.d.ts +36 -11
  158. package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -1
  159. package/dist/plugins/tables/deleteTableRecords/index.js +18 -41
  160. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +0 -2
  161. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -1
  162. package/dist/plugins/tables/getTable/index.d.ts +43 -12
  163. package/dist/plugins/tables/getTable/index.d.ts.map +1 -1
  164. package/dist/plugins/tables/getTable/index.js +18 -43
  165. package/dist/plugins/tables/getTable/schemas.d.ts +0 -2
  166. package/dist/plugins/tables/getTable/schemas.d.ts.map +1 -1
  167. package/dist/plugins/tables/getTableRecord/index.d.ts +43 -11
  168. package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -1
  169. package/dist/plugins/tables/getTableRecord/index.js +18 -42
  170. package/dist/plugins/tables/getTableRecord/schemas.d.ts +0 -2
  171. package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -1
  172. package/dist/plugins/tables/listTableFields/index.d.ts +46 -11
  173. package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -1
  174. package/dist/plugins/tables/listTableFields/index.js +17 -41
  175. package/dist/plugins/tables/listTableFields/schemas.d.ts +12 -14
  176. package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -1
  177. package/dist/plugins/tables/listTableRecords/index.d.ts +66 -18
  178. package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -1
  179. package/dist/plugins/tables/listTableRecords/index.js +27 -50
  180. package/dist/plugins/tables/listTableRecords/schemas.d.ts +6 -8
  181. package/dist/plugins/tables/listTableRecords/schemas.d.ts.map +1 -1
  182. package/dist/plugins/tables/listTables/index.d.ts +53 -20
  183. package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
  184. package/dist/plugins/tables/listTables/index.js +24 -51
  185. package/dist/plugins/tables/listTables/schemas.d.ts +0 -2
  186. package/dist/plugins/tables/listTables/schemas.d.ts.map +1 -1
  187. package/dist/plugins/tables/shared.d.ts +10 -0
  188. package/dist/plugins/tables/shared.d.ts.map +1 -0
  189. package/dist/plugins/tables/shared.js +9 -0
  190. package/dist/plugins/tables/updateTableRecords/index.d.ts +49 -11
  191. package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -1
  192. package/dist/plugins/tables/updateTableRecords/index.js +20 -43
  193. package/dist/plugins/tables/updateTableRecords/schemas.d.ts +0 -2
  194. package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -1
  195. package/dist/plugins/tables/utils.d.ts.map +1 -1
  196. package/dist/plugins/tables/utils.js +1 -0
  197. package/dist/registry.d.ts.map +1 -1
  198. package/dist/registry.js +21 -1
  199. package/dist/resolvers/actionKey.d.ts +1 -2
  200. package/dist/resolvers/actionKey.d.ts.map +1 -1
  201. package/dist/resolvers/actionType.d.ts +1 -2
  202. package/dist/resolvers/actionType.d.ts.map +1 -1
  203. package/dist/schemas/Action.d.ts +1 -1
  204. package/dist/sdk.d.ts +2942 -2
  205. package/dist/sdk.d.ts.map +1 -1
  206. package/dist/types/credentials.d.ts +2 -1
  207. package/dist/types/credentials.d.ts.map +1 -1
  208. package/dist/types/credentials.js +2 -1
  209. package/dist/types/errors.d.ts +13 -10
  210. package/dist/types/errors.d.ts.map +1 -1
  211. package/dist/types/errors.js +15 -12
  212. package/dist/types/functions.d.ts +18 -2
  213. package/dist/types/functions.d.ts.map +1 -1
  214. package/dist/types/plugin.d.ts +1 -1
  215. package/dist/types/plugin.d.ts.map +1 -1
  216. package/dist/types/properties.d.ts +1 -1
  217. package/dist/types/registry.d.ts +1 -1
  218. package/dist/types/registry.d.ts.map +1 -1
  219. package/dist/types/sdk.d.ts +2 -0
  220. package/dist/types/sdk.d.ts.map +1 -1
  221. package/dist/types/sdk.js +1 -0
  222. package/dist/utils/function-utils.d.ts +11 -12
  223. package/dist/utils/function-utils.d.ts.map +1 -1
  224. package/dist/utils/plugin-utils.d.ts +168 -0
  225. package/dist/utils/plugin-utils.d.ts.map +1 -0
  226. package/dist/utils/plugin-utils.js +132 -0
  227. package/package.json +2 -4
@@ -1,83 +1,55 @@
1
+ import { definePlugin } from "../../utils/plugin-utils";
2
+ import { createPaginatedPluginMethod } from "../../utils/plugin-utils";
1
3
  import { normalizeActionItem } from "../../utils/domain-utils";
2
- import { ListActionsSchema, ListActionsInputSchema, } from "./schemas";
4
+ import { ListActionsInputSchema } from "./schemas";
3
5
  import { ActionItemSchema } from "../../schemas/Action";
4
- import { ZapierConfigurationError, ZapierAuthenticationError, } from "../../types/errors";
5
- import { createPaginatedFunction } from "../../utils/function-utils";
6
+ import { ZapierConfigurationError } from "../../types/errors";
6
7
  import { DEFAULT_PAGE_SIZE } from "../../constants";
7
8
  import { appKeyResolver, actionTypeResolver } from "../../resolvers";
8
- import { createTelemetryCallback } from "../../utils/telemetry-utils";
9
- import { stripPageSuffix } from "../../utils/string-utils";
10
9
  import { setMethodMetadata } from "../../utils/telemetry-context";
11
- export const listActionsPlugin = (sdk) => {
12
- const methodMeta = {
13
- categories: ["action"],
14
- type: "list",
15
- itemType: "Action",
16
- inputSchema: ListActionsSchema,
17
- outputSchema: ActionItemSchema,
18
- resolvers: {
19
- app: appKeyResolver,
20
- actionType: actionTypeResolver,
21
- },
22
- };
23
- async function listActionsPage(options) {
10
+ export const listActionsPlugin = definePlugin((sdk) => createPaginatedPluginMethod(sdk, {
11
+ name: "listActions",
12
+ categories: ["action"],
13
+ type: "list",
14
+ itemType: "Action",
15
+ inputSchema: ListActionsInputSchema,
16
+ outputSchema: ActionItemSchema,
17
+ defaultPageSize: DEFAULT_PAGE_SIZE,
18
+ resolvers: { app: appKeyResolver, actionType: actionTypeResolver },
19
+ handler: async ({ sdk, options, }) => {
24
20
  const { api, getVersionedImplementationId } = sdk.context;
25
21
  const appKey = "app" in options ? options.app : options.appKey;
26
- // Use getVersionedImplementationId (optimized to check manifest first)
27
22
  const selectedApi = await getVersionedImplementationId(appKey);
28
23
  if (!selectedApi) {
29
24
  throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
30
25
  }
31
- // operationKey is intentionally omitted — listActions is a list-level operation with no specific action key.
26
+ // operationKey intentionally omitted — listActions is a list-level
27
+ // operation with no specific action key.
32
28
  setMethodMetadata({
33
29
  selectedApi,
34
30
  operationType: options.actionType ?? null,
35
31
  });
36
- const searchParams = {
37
- global: "true",
38
- public_only: "true",
39
- selected_apis: selectedApi,
40
- };
41
32
  const data = await api.get("/zapier/api/v4/implementations/", {
42
- searchParams,
43
- customErrorHandler: ({ status }) => {
44
- if (status === 401) {
45
- return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access implementations or may be expired. (HTTP ${status})`, { statusCode: status });
46
- }
47
- if (status === 403) {
48
- return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to list implementations. (HTTP ${status})`, { statusCode: status });
49
- }
50
- return undefined;
33
+ searchParams: {
34
+ global: "true",
35
+ public_only: "true",
36
+ selected_apis: selectedApi,
51
37
  },
52
38
  });
53
39
  let allActions = [];
54
40
  for (const implementation of data.results || []) {
55
41
  if (implementation.actions) {
56
42
  for (const action of implementation.actions) {
57
- const actionWithContext = {
43
+ allActions.push(normalizeActionItem({
58
44
  ...action,
59
45
  selected_api: action.selected_api || implementation.selected_api,
60
- };
61
- allActions.push(normalizeActionItem(actionWithContext));
46
+ }));
62
47
  }
63
48
  }
64
49
  }
65
50
  if (options.actionType) {
66
51
  allActions = allActions.filter((action) => action.action_type === options.actionType);
67
52
  }
68
- return {
69
- data: allActions,
70
- nextCursor: undefined,
71
- };
72
- }
73
- const methodName = stripPageSuffix(listActionsPage.name);
74
- const listActionsDefinition = createPaginatedFunction(listActionsPage, ListActionsInputSchema, createTelemetryCallback(sdk.context.eventEmission.emitMethodCalled, methodName), methodName, DEFAULT_PAGE_SIZE);
75
- return {
76
- listActions: listActionsDefinition,
77
- context: {
78
- meta: {
79
- listActions: methodMeta,
80
- },
81
- },
82
- };
83
- };
53
+ return { data: allActions };
54
+ },
55
+ }));
@@ -1,17 +1,14 @@
1
1
  import { z } from "zod";
2
- import type { ActionItem } from "../../types/domain";
3
- import type { PaginatedSdkFunction } from "../../types/functions";
4
- import type { ZapierAuthenticationError, ZapierValidationError, ZapierUnknownError } from "../../types/errors";
5
2
  export declare const ListActionsSchema: z.ZodObject<{
6
3
  app: z.ZodString & {
7
4
  _def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
8
5
  };
9
6
  actionType: z.ZodOptional<z.ZodEnum<{
10
- search: "search";
11
7
  filter: "filter";
12
8
  read: "read";
13
9
  read_bulk: "read_bulk";
14
10
  run: "run";
11
+ search: "search";
15
12
  search_and_write: "search_and_write";
16
13
  search_or_write: "search_or_write";
17
14
  write: "write";
@@ -25,11 +22,11 @@ declare const ListActionsSchemaDeprecated: z.ZodObject<{
25
22
  _def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
26
23
  };
27
24
  actionType: z.ZodOptional<z.ZodEnum<{
28
- search: "search";
29
25
  filter: "filter";
30
26
  read: "read";
31
27
  read_bulk: "read_bulk";
32
28
  run: "run";
29
+ search: "search";
33
30
  search_and_write: "search_and_write";
34
31
  search_or_write: "search_or_write";
35
32
  write: "write";
@@ -43,11 +40,11 @@ export declare const ListActionsInputSchema: z.ZodUnion<readonly [z.ZodObject<{
43
40
  _def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
44
41
  };
45
42
  actionType: z.ZodOptional<z.ZodEnum<{
46
- search: "search";
47
43
  filter: "filter";
48
44
  read: "read";
49
45
  read_bulk: "read_bulk";
50
46
  run: "run";
47
+ search: "search";
51
48
  search_and_write: "search_and_write";
52
49
  search_or_write: "search_or_write";
53
50
  write: "write";
@@ -60,11 +57,11 @@ export declare const ListActionsInputSchema: z.ZodUnion<readonly [z.ZodObject<{
60
57
  _def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
61
58
  };
62
59
  actionType: z.ZodOptional<z.ZodEnum<{
63
- search: "search";
64
60
  filter: "filter";
65
61
  read: "read";
66
62
  read_bulk: "read_bulk";
67
63
  run: "run";
64
+ search: "search";
68
65
  search_and_write: "search_and_write";
69
66
  search_or_write: "search_or_write";
70
67
  write: "write";
@@ -77,13 +74,5 @@ export type ListActionsOptions = z.infer<typeof ListActionsSchema> | (Omit<z.inf
77
74
  /** @deprecated Use `app` instead. */
78
75
  appKey: z.infer<typeof ListActionsSchemaDeprecated>["appKey"];
79
76
  });
80
- export interface ListActionsPage {
81
- data: ActionItem[];
82
- nextCursor?: string;
83
- }
84
- export type ListActionsError = ZapierAuthenticationError | ZapierValidationError | ZapierUnknownError;
85
- export interface ListActionsSdkFunction {
86
- listActions: PaginatedSdkFunction<ListActionsOptions, ActionItem>;
87
- }
88
77
  export {};
89
78
  //# sourceMappingURL=schemas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listActions/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAgB5B,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;iBAWS,CAAC;AAGxC,QAAA,MAAM,2BAA2B;;;;;;;;;;;;;;;;;iBASF,CAAC;AAGhC,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAEA,CAAC;AAGpC,MAAM,MAAM,kBAAkB,GAC1B,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,GACjC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,EAAE,QAAQ,CAAC,GAAG;IAC7D,qCAAqC;IACrC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC,QAAQ,CAAC,CAAC;CAC/D,CAAC,CAAC;AAGP,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,MAAM,gBAAgB,GACxB,yBAAyB,GACzB,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,oBAAoB,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;CACnE"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listActions/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqBxB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;iBAWS,CAAC;AAGxC,QAAA,MAAM,2BAA2B;;;;;;;;;;;;;;;;;iBASF,CAAC;AAGhC,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAEA,CAAC;AAGpC,MAAM,MAAM,kBAAkB,GAC1B,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,GACjC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,EAAE,QAAQ,CAAC,GAAG;IAC7D,qCAAqC;IACrC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC,QAAQ,CAAC,CAAC;CAC/D,CAAC,CAAC"}
@@ -1,19 +1,127 @@
1
- import type { Plugin } from "../../types/plugin";
2
- import { ListAppsSchema, type ListAppsOptions, type ListAppsPage, type AppItem } from "./schemas";
3
- import type { ManifestPluginProvides } from "../manifest";
4
- import type { ApiPluginProvides } from "../api";
5
- import type { EventEmissionProvides } from "../eventEmission";
6
- export interface ListAppsPluginProvides {
7
- listApps: (options?: ListAppsOptions) => Promise<ListAppsPage> & AsyncIterable<ListAppsPage> & {
8
- items(): AsyncIterable<AppItem>;
1
+ export declare const listAppsPlugin: (sdk: {
2
+ context: {
3
+ api: import("../../api").ApiClient;
4
+ resolveCredentials: () => Promise<string | {
5
+ clientId: string;
6
+ clientSecret: string;
7
+ type?: "client_credentials" | undefined;
8
+ baseUrl?: string | undefined;
9
+ scope?: string | undefined;
10
+ } | {
11
+ clientId: string;
12
+ type?: "pkce" | undefined;
13
+ baseUrl?: string | undefined;
14
+ scope?: string | undefined;
15
+ } | undefined>;
16
+ };
17
+ } & {
18
+ context: {
19
+ getResolvedManifest: () => Promise<import("../manifest").Manifest | null>;
20
+ getVersionedImplementationId: (appKey: string) => Promise<string | null>;
21
+ resolveAppKeys: ({ appKeys }: {
22
+ appKeys: string[];
23
+ }) => Promise<import("../..").ResolvedAppLocator[]>;
24
+ updateManifestEntry: (options: import("../manifest").UpdateManifestEntryOptions) => Promise<import("../manifest").UpdateManifestEntryResult>;
25
+ addActionEntry: (options: import("../manifest").AddActionEntryOptions) => Promise<import("../manifest").AddActionEntryResult>;
26
+ findActionEntry: ({ name, manifest, }: {
27
+ name: string;
28
+ manifest: import("../manifest").Manifest;
29
+ }) => import("../manifest").ActionEntry | null;
30
+ listActionEntries: ({ configPath, }?: {
31
+ configPath?: string;
32
+ }) => Promise<Array<[string, import("../manifest").ActionEntry]>>;
33
+ deleteActionEntry: ({ name, configPath, skipWrite, }: {
34
+ name: string;
35
+ configPath?: string;
36
+ skipWrite?: boolean;
37
+ }) => Promise<import("../manifest").Manifest>;
38
+ hasActionEntry: ({ name, manifest, }: {
39
+ name: string;
40
+ manifest: import("../manifest").Manifest;
41
+ }) => boolean;
42
+ findManifestEntry: typeof import("../manifest").findManifestEntry;
43
+ readManifestFromFile: typeof import("../manifest").readManifestFromFile;
44
+ getManifestConnections: () => Promise<Record<string, {
45
+ connectionId: string | number;
46
+ }> | null>;
47
+ };
48
+ } & {
49
+ context: import("../eventEmission").EventEmissionContext;
50
+ } & {
51
+ context: {
52
+ meta: Record<string, import("../..").PluginMeta>;
9
53
  };
54
+ }) => {
55
+ listApps: (options?: ({
56
+ search?: string | undefined;
57
+ apps?: string[] | undefined;
58
+ appKeys?: string[] | undefined;
59
+ pageSize?: number | undefined;
60
+ maxItems?: number | undefined;
61
+ cursor?: string | undefined;
62
+ } & {
63
+ cursor?: string;
64
+ pageSize?: number;
65
+ maxItems?: number;
66
+ }) | undefined) => import("../..").PaginatedSdkResult<{
67
+ slug: string;
68
+ title: string;
69
+ key: string;
70
+ implementation_id: string;
71
+ description?: string | undefined;
72
+ is_hidden?: boolean | undefined;
73
+ auth_type?: string | undefined;
74
+ actions?: {
75
+ read?: number | undefined;
76
+ read_bulk?: number | undefined;
77
+ write?: number | undefined;
78
+ search?: number | undefined;
79
+ search_or_write?: number | undefined;
80
+ search_and_write?: number | undefined;
81
+ filter?: number | undefined;
82
+ } | undefined;
83
+ is_deprecated?: boolean | undefined;
84
+ is_beta?: boolean | undefined;
85
+ is_premium?: boolean | undefined;
86
+ age_in_days?: number | undefined;
87
+ banner?: string | undefined;
88
+ categories?: {
89
+ id: number;
90
+ name: string;
91
+ slug: string;
92
+ }[] | undefined;
93
+ images?: {
94
+ url_16x16?: string | undefined;
95
+ url_32x32?: string | undefined;
96
+ url_64x64?: string | undefined;
97
+ url_128x128?: string | undefined;
98
+ } | undefined;
99
+ popularity?: number | undefined;
100
+ has_filters?: boolean | undefined;
101
+ has_reads?: boolean | undefined;
102
+ has_searches?: boolean | undefined;
103
+ has_searches_or_writes?: boolean | undefined;
104
+ has_upfront_fields?: boolean | undefined;
105
+ has_writes?: boolean | undefined;
106
+ is_built_in?: boolean | undefined;
107
+ is_featured?: boolean | undefined;
108
+ is_invite?: boolean | undefined;
109
+ is_public?: boolean | undefined;
110
+ is_upcoming?: boolean | undefined;
111
+ visibility?: string | undefined;
112
+ primary_color?: string | undefined;
113
+ secondary_color?: string | undefined;
114
+ classification?: string | undefined;
115
+ api_docs_url?: string | undefined;
116
+ image?: string | undefined;
117
+ version?: string | undefined;
118
+ }>;
119
+ } & {
10
120
  context: {
11
121
  meta: {
12
- listApps: {
13
- inputSchema: typeof ListAppsSchema;
14
- };
122
+ listApps: import("../..").PluginMeta;
15
123
  };
16
124
  };
17
- }
18
- export declare const listAppsPlugin: Plugin<ApiPluginProvides & ManifestPluginProvides & EventEmissionProvides, ListAppsPluginProvides>;
125
+ };
126
+ export type ListAppsPluginProvides = ReturnType<typeof listAppsPlugin>;
19
127
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,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,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAI9D,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,iBAAiB,GAAG,sBAAsB,GAAG,qBAAqB,EAClE,sBAAsB,CAqFvB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAoEkzW,CAAC;;;;sBAAiX,CAAC;qBAAyB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAHztX,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -1,16 +1,21 @@
1
- import { createPaginatedFunction } from "../../utils/function-utils";
1
+ import { definePlugin } from "../../utils/plugin-utils";
2
+ import { createPaginatedPluginMethod } from "../../utils/plugin-utils";
2
3
  import { DEFAULT_PAGE_SIZE } from "../../constants";
3
- import { ListAppsSchema, } from "./schemas";
4
+ import { ListAppsSchema } from "./schemas";
4
5
  import { AppItemSchema } from "../../schemas/App";
5
- import { createTelemetryCallback } from "../../utils/telemetry-utils";
6
- import { stripPageSuffix } from "../../utils/string-utils";
7
- export const listAppsPlugin = (sdk) => {
8
- async function listAppsPage(options) {
6
+ import { extractCursor } from "../../utils/function-utils";
7
+ export const listAppsPlugin = definePlugin((sdk) => createPaginatedPluginMethod(sdk, {
8
+ name: "listApps",
9
+ categories: ["app"],
10
+ type: "list",
11
+ itemType: "App",
12
+ inputSchema: ListAppsSchema,
13
+ outputSchema: AppItemSchema,
14
+ defaultPageSize: DEFAULT_PAGE_SIZE,
15
+ handler: async ({ sdk, options }) => {
9
16
  const { api, resolveAppKeys } = sdk.context;
10
17
  const appKeys = options.apps ?? options.appKeys ?? [];
11
- const appLocators = await resolveAppKeys({
12
- appKeys: [...appKeys],
13
- });
18
+ const appLocators = await resolveAppKeys({ appKeys: [...appKeys] });
14
19
  const implementationNameToLocator = {};
15
20
  for (const locator of appLocators) {
16
21
  implementationNameToLocator[locator.implementationName] = [
@@ -26,9 +31,10 @@ export const listAppsPlugin = (sdk) => {
26
31
  if (duplicatedLookupAppKeys.length > 0) {
27
32
  throw new Error(`Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`);
28
33
  }
29
- // Step 2: Early return if user provided appKeys but they resolved to nothing AND no search
30
- // This prevents the handler from returning all apps when the user explicitly filtered
31
- // If search is provided, let the handler augment with search results
34
+ // Early return if user provided appKeys but they resolved to nothing
35
+ // AND no search. Prevents the handler from returning all apps when
36
+ // the user explicitly filtered. If search is provided, let the API
37
+ // augment with search results.
32
38
  if (appKeys.length > 0 && appLocators.length === 0 && !options.search) {
33
39
  return {
34
40
  data: [],
@@ -40,7 +46,7 @@ export const listAppsPlugin = (sdk) => {
40
46
  const version = locator.version || "latest";
41
47
  return `${locator.implementationName}@${version}`;
42
48
  });
43
- return await api.get("/api/v0/apps", {
49
+ return api.get("/api/v0/apps", {
44
50
  searchParams: {
45
51
  app_keys: implementationIds.join(","),
46
52
  ...(options.search && { search: options.search }),
@@ -50,21 +56,6 @@ export const listAppsPlugin = (sdk) => {
50
56
  ...(options.cursor && { offset: options.cursor }),
51
57
  },
52
58
  });
53
- }
54
- const methodName = stripPageSuffix(listAppsPage.name);
55
- const listAppsDefinition = createPaginatedFunction(listAppsPage, ListAppsSchema, createTelemetryCallback(sdk.context.eventEmission.emitMethodCalled, methodName), methodName, DEFAULT_PAGE_SIZE);
56
- return {
57
- listApps: listAppsDefinition,
58
- context: {
59
- meta: {
60
- listApps: {
61
- categories: ["app"],
62
- type: "list",
63
- itemType: "App",
64
- inputSchema: ListAppsSchema,
65
- outputSchema: AppItemSchema,
66
- },
67
- },
68
- },
69
- };
70
- };
59
+ },
60
+ extractCursor: (response) => extractCursor(response.links),
61
+ }));
@@ -12,7 +12,6 @@
12
12
  */
13
13
  import { z } from "zod";
14
14
  import type { PaginatedSdkFunction } from "../../types/functions";
15
- import type { ZapierApiError, ZapierValidationError } from "../../types/errors";
16
15
  import { AppItemSchema as AppItemSchemaBase, ListAppsResponseSchema as ListAppsResponseSchemaBase, type AppItem, type ListAppsResponse } from "@zapier/zapier-sdk-core/v0/schemas/apps";
17
16
  export { AppItemSchemaBase as AppItemSchema };
18
17
  export { ListAppsResponseSchemaBase as ListAppsResponseSchema };
@@ -38,7 +37,6 @@ export interface ListAppsPage {
38
37
  data: AppItem[];
39
38
  nextCursor?: string;
40
39
  }
41
- export type ListAppsError = ZapierApiError | ZapierValidationError;
42
40
  export interface ListAppsSdkFunction {
43
41
  listApps: PaginatedSdkFunction<ListAppsOptions | undefined, AppItem>;
44
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhF,OAAO,EACL,aAAa,IAAI,iBAAiB,EAClC,sBAAsB,IAAI,0BAA0B,EAEpD,KAAK,OAAO,EACZ,KAAK,gBAAgB,EACtB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,iBAAiB,IAAI,aAAa,EAAE,CAAC;AAC9C,OAAO,EAAE,0BAA0B,IAAI,sBAAsB,EAAE,CAAC;AAChE,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;;;;;iBA8BmC,CAAC;AAE/D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAG7D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,qBAAqB,CAAC;AAGnE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,oBAAoB,CAAC,eAAe,GAAG,SAAS,EAAE,OAAO,CAAC,CAAC;CACtE"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EACL,aAAa,IAAI,iBAAiB,EAClC,sBAAsB,IAAI,0BAA0B,EAEpD,KAAK,OAAO,EACZ,KAAK,gBAAgB,EACtB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,iBAAiB,IAAI,aAAa,EAAE,CAAC;AAC9C,OAAO,EAAE,0BAA0B,IAAI,sBAAsB,EAAE,CAAC;AAChE,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;;;;;iBA8BmC,CAAC;AAE/D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAG7D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,oBAAoB,CAAC,eAAe,GAAG,SAAS,EAAE,OAAO,CAAC,CAAC;CACtE"}
@@ -1,23 +1,36 @@
1
- import type { Plugin } from "../../types/plugin";
2
1
  import type { ApiClient } from "../../api";
3
- import type { ClientCredentialsItem } from "@zapier/zapier-sdk-core/v0/schemas/client-credentials";
4
- import { ListClientCredentialsQuerySchema, type ListClientCredentialsOptions, type ListClientCredentialsPage } from "./schemas";
5
- import type { EventEmissionProvides } from "../eventEmission";
6
- export interface ListClientCredentialsPluginProvides {
7
- listClientCredentials: (options?: ListClientCredentialsOptions) => Promise<ListClientCredentialsPage> & AsyncIterable<ListClientCredentialsPage> & {
8
- items(): AsyncIterable<ClientCredentialsItem>;
2
+ export declare const listClientCredentialsPlugin: (sdk: {
3
+ context: {
4
+ api: ApiClient;
9
5
  };
6
+ } & {
7
+ context: import("../eventEmission").EventEmissionContext;
8
+ } & {
10
9
  context: {
11
- meta: {
12
- listClientCredentials: {
13
- inputSchema: typeof ListClientCredentialsQuerySchema;
14
- };
15
- };
10
+ meta: Record<string, import("../..").PluginMeta>;
16
11
  };
17
- }
18
- export declare const listClientCredentialsPlugin: Plugin<{
12
+ }) => {
13
+ listClientCredentials: (options?: ({
14
+ pageSize?: number | undefined;
15
+ maxItems?: number | undefined;
16
+ cursor?: string | undefined;
17
+ } & {
18
+ cursor?: string;
19
+ pageSize?: number;
20
+ maxItems?: number;
21
+ }) | undefined) => import("../..").PaginatedSdkResult<{
22
+ client_id: string;
23
+ name: string;
24
+ allowed_scopes: ("external" | "credentials")[];
25
+ created_at?: string | null | undefined;
26
+ updated_at?: string | undefined;
27
+ }>;
28
+ } & {
19
29
  context: {
20
- api: ApiClient;
30
+ meta: {
31
+ listClientCredentials: import("../..").PluginMeta;
32
+ };
21
33
  };
22
- } & EventEmissionProvides, ListClientCredentialsPluginProvides>;
34
+ };
35
+ export type ListClientCredentialsPluginProvides = ReturnType<typeof listClientCredentialsPlugin>;
23
36
  //# sourceMappingURL=index.d.ts.map
@@ -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;AAKnB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAK9D,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;IACE,OAAO,EAAE;QACP,GAAG,EAAE,SAAS,CAAC;KAChB,CAAC;CACH,GAAG,qBAAqB,EACzB,mCAAmC,CAyEpC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listClientCredentials/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAQ3C,eAAO,MAAM,2BAA2B;aACrB;QAAE,GAAG,EAAE,SAAS,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BpC,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,UAAU,CAC1D,OAAO,2BAA2B,CACnC,CAAC"}
@@ -1,13 +1,18 @@
1
- import { ListClientCredentialsQuerySchema, } from "./schemas";
2
- import { createPaginatedFunction } from "../../utils/function-utils";
1
+ import { definePlugin } from "../../utils/plugin-utils";
2
+ import { createPaginatedPluginMethod } from "../../utils/plugin-utils";
3
+ import { ListClientCredentialsQuerySchema } from "./schemas";
4
+ import { extractCursor } from "../../utils/function-utils";
3
5
  import { DEFAULT_PAGE_SIZE } from "../../constants";
4
6
  import { ClientCredentialsItemSchema } from "../../schemas/ClientCredentials";
5
- import { createTelemetryCallback } from "../../utils/telemetry-utils";
6
- import { stripPageSuffix } from "../../utils/string-utils";
7
- import { ZapierAuthenticationError } from "../../types/errors";
8
- export const listClientCredentialsPlugin = (sdk) => {
9
- async function listClientCredentialsPage(options) {
10
- const { api } = sdk.context;
7
+ export const listClientCredentialsPlugin = definePlugin((sdk) => createPaginatedPluginMethod(sdk, {
8
+ name: "listClientCredentials",
9
+ categories: ["client-credentials"],
10
+ type: "list",
11
+ itemType: "ClientCredentials",
12
+ inputSchema: ListClientCredentialsQuerySchema,
13
+ outputSchema: ClientCredentialsItemSchema,
14
+ defaultPageSize: DEFAULT_PAGE_SIZE,
15
+ handler: async ({ sdk, options, }) => {
11
16
  const searchParams = {};
12
17
  if (options.pageSize !== undefined) {
13
18
  searchParams.page_size = options.pageSize.toString();
@@ -15,36 +20,11 @@ export const listClientCredentialsPlugin = (sdk) => {
15
20
  if (options.cursor) {
16
21
  searchParams.offset = options.cursor;
17
22
  }
18
- const response = await api.get("/api/v0/client-credentials", {
23
+ return sdk.context.api.get("/api/v0/client-credentials", {
19
24
  searchParams,
20
- customErrorHandler: ({ status }) => {
21
- if (status === 401) {
22
- return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access client credentials or may be expired. (HTTP ${status})`, { statusCode: status });
23
- }
24
- if (status === 403) {
25
- return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to list client credentials. (HTTP ${status})`, { statusCode: status });
26
- }
27
- return undefined;
28
- },
29
25
  authRequired: true,
30
26
  requiredScopes: ["credentials"],
31
27
  });
32
- return response;
33
- }
34
- const methodName = stripPageSuffix(listClientCredentialsPage.name);
35
- const listClientCredentialsDefinition = createPaginatedFunction(listClientCredentialsPage, ListClientCredentialsQuerySchema, createTelemetryCallback(sdk.context.eventEmission.emitMethodCalled, methodName), methodName, DEFAULT_PAGE_SIZE);
36
- return {
37
- listClientCredentials: listClientCredentialsDefinition,
38
- context: {
39
- meta: {
40
- listClientCredentials: {
41
- categories: ["client-credentials"],
42
- type: "list",
43
- itemType: "ClientCredentials",
44
- inputSchema: ListClientCredentialsQuerySchema,
45
- outputSchema: ClientCredentialsItemSchema,
46
- },
47
- },
48
- },
49
- };
50
- };
28
+ },
29
+ extractCursor: (response) => extractCursor(response.links),
30
+ }));
@@ -1,7 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import type { PaginatedSdkFunction } from "../../types/functions";
3
3
  import type { ClientCredentialsItem } from "@zapier/zapier-sdk-core/v0/schemas/client-credentials";
4
- import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../types/errors";
5
4
  export declare const ListClientCredentialsQuerySchema: z.ZodObject<{
6
5
  pageSize: z.ZodOptional<z.ZodNumber>;
7
6
  maxItems: z.ZodOptional<z.ZodNumber>;
@@ -12,7 +11,6 @@ export interface ListClientCredentialsPage {
12
11
  data: ClientCredentialsItem[];
13
12
  nextCursor?: string;
14
13
  }
15
- export type ListClientCredentialsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
16
14
  export interface ListClientCredentialsSdkFunction {
17
15
  listClientCredentials: PaginatedSdkFunction<ListClientCredentialsOptions, ClientCredentialsItem>;
18
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listClientCredentials/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uDAAuD,CAAC;AAEnG,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAC5B,eAAO,MAAM,gCAAgC;;;;iBAqBsB,CAAC;AAGpE,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,gCAAgC,CACxC,CAAC;AAGF,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,qBAAqB,EAAE,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,MAAM,0BAA0B,GAClC,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,gCAAgC;IAC/C,qBAAqB,EAAE,oBAAoB,CACzC,4BAA4B,EAC5B,qBAAqB,CACtB,CAAC;CACH"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listClientCredentials/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uDAAuD,CAAC;AAEnG,eAAO,MAAM,gCAAgC;;;;iBAqBsB,CAAC;AAGpE,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,gCAAgC,CACxC,CAAC;AAGF,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,qBAAqB,EAAE,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,gCAAgC;IAC/C,qBAAqB,EAAE,oBAAoB,CACzC,4BAA4B,EAC5B,qBAAqB,CACtB,CAAC;CACH"}