@zapier/zapier-sdk 0.18.2 → 0.18.4

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 (85) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +13 -13
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +0 -18
  5. package/dist/api/schemas.d.ts +0 -158
  6. package/dist/api/schemas.d.ts.map +1 -1
  7. package/dist/api/schemas.js +0 -95
  8. package/dist/api/types.d.ts +2 -1
  9. package/dist/api/types.d.ts.map +1 -1
  10. package/dist/index.cjs +400 -808
  11. package/dist/index.d.mts +67 -122
  12. package/dist/index.mjs +401 -809
  13. package/dist/plugins/findFirstAuthentication/index.test.js +2 -2
  14. package/dist/plugins/findUniqueAuthentication/index.test.js +2 -2
  15. package/dist/plugins/listApps/index.d.ts +2 -8
  16. package/dist/plugins/listApps/index.d.ts.map +1 -1
  17. package/dist/plugins/listApps/index.js +4 -6
  18. package/dist/plugins/listApps/index.test.js +62 -82
  19. package/dist/plugins/listApps/schemas.d.ts +35 -14
  20. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  21. package/dist/plugins/listApps/schemas.js +44 -14
  22. package/dist/plugins/listAuthentications/index.d.ts +4 -10
  23. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  24. package/dist/plugins/listAuthentications/index.js +19 -31
  25. package/dist/plugins/listAuthentications/index.test.js +363 -127
  26. package/dist/plugins/listAuthentications/schemas.d.ts +7 -7
  27. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  28. package/dist/plugins/listAuthentications/schemas.js +10 -16
  29. package/dist/schemas/App.d.ts +28 -28
  30. package/dist/schemas/App.d.ts.map +1 -1
  31. package/dist/schemas/App.js +3 -8
  32. package/dist/sdk.d.ts +2 -2
  33. package/dist/sdk.test.js +12 -9
  34. package/dist/utils/domain-utils.d.ts +2 -15
  35. package/dist/utils/domain-utils.d.ts.map +1 -1
  36. package/dist/utils/domain-utils.js +0 -38
  37. package/dist/utils/function-utils.d.ts +1 -0
  38. package/dist/utils/function-utils.d.ts.map +1 -1
  39. package/dist/utils/function-utils.js +15 -3
  40. package/package.json +2 -2
  41. package/dist/api/client.integration.test.d.ts +0 -5
  42. package/dist/api/client.integration.test.d.ts.map +0 -1
  43. package/dist/api/client.integration.test.js +0 -318
  44. package/dist/api/client.methods.test.d.ts +0 -2
  45. package/dist/api/client.methods.test.d.ts.map +0 -1
  46. package/dist/api/client.methods.test.js +0 -158
  47. package/dist/api/router.d.ts +0 -16
  48. package/dist/api/router.d.ts.map +0 -1
  49. package/dist/api/router.js +0 -31
  50. package/dist/api/router.test.d.ts +0 -2
  51. package/dist/api/router.test.d.ts.map +0 -1
  52. package/dist/api/router.test.js +0 -103
  53. package/dist/temporary-internal-core/handlers/listApps.d.ts +0 -67
  54. package/dist/temporary-internal-core/handlers/listApps.d.ts.map +0 -1
  55. package/dist/temporary-internal-core/handlers/listApps.js +0 -134
  56. package/dist/temporary-internal-core/handlers/listApps.test.d.ts +0 -2
  57. package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +0 -1
  58. package/dist/temporary-internal-core/handlers/listApps.test.js +0 -367
  59. package/dist/temporary-internal-core/index.d.ts +0 -18
  60. package/dist/temporary-internal-core/index.d.ts.map +0 -1
  61. package/dist/temporary-internal-core/index.js +0 -18
  62. package/dist/temporary-internal-core/schemas/apps/index.d.ts +0 -175
  63. package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +0 -1
  64. package/dist/temporary-internal-core/schemas/apps/index.js +0 -97
  65. package/dist/temporary-internal-core/schemas/errors/index.d.ts +0 -139
  66. package/dist/temporary-internal-core/schemas/errors/index.d.ts.map +0 -1
  67. package/dist/temporary-internal-core/schemas/errors/index.js +0 -129
  68. package/dist/temporary-internal-core/schemas/implementations/index.d.ts +0 -127
  69. package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +0 -1
  70. package/dist/temporary-internal-core/schemas/implementations/index.js +0 -79
  71. package/dist/temporary-internal-core/types/handler.d.ts +0 -51
  72. package/dist/temporary-internal-core/types/handler.d.ts.map +0 -1
  73. package/dist/temporary-internal-core/types/handler.js +0 -8
  74. package/dist/temporary-internal-core/types/index.d.ts +0 -5
  75. package/dist/temporary-internal-core/types/index.d.ts.map +0 -1
  76. package/dist/temporary-internal-core/types/index.js +0 -4
  77. package/dist/temporary-internal-core/utils/app-locators.d.ts +0 -34
  78. package/dist/temporary-internal-core/utils/app-locators.d.ts.map +0 -1
  79. package/dist/temporary-internal-core/utils/app-locators.js +0 -39
  80. package/dist/temporary-internal-core/utils/string-utils.d.ts +0 -28
  81. package/dist/temporary-internal-core/utils/string-utils.d.ts.map +0 -1
  82. package/dist/temporary-internal-core/utils/string-utils.js +0 -52
  83. package/dist/temporary-internal-core/utils/transformations.d.ts +0 -32
  84. package/dist/temporary-internal-core/utils/transformations.d.ts.map +0 -1
  85. package/dist/temporary-internal-core/utils/transformations.js +0 -74
@@ -1,16 +1,16 @@
1
1
  import { z } from "zod";
2
2
  import type { PaginatedSdkFunction } from "../../types/functions";
3
- import type { AuthenticationItem } from "../../types/domain";
3
+ import type { AuthenticationItem } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
4
4
  import type { ZapierAuthenticationError, ZapierApiError, ZapierAppNotFoundError, ZapierValidationError, ZapierUnknownError } from "../../types/errors";
5
- export declare const ListAuthenticationsSchema: z.ZodObject<{
5
+ export declare const ListAuthenticationsQuerySchema: z.ZodObject<{
6
+ search: z.ZodOptional<z.ZodString>;
7
+ title: z.ZodOptional<z.ZodString>;
8
+ accountId: z.ZodOptional<z.ZodString>;
9
+ owner: z.ZodOptional<z.ZodString>;
6
10
  appKey: z.ZodOptional<z.ZodString & {
7
11
  _def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
8
12
  }>;
9
13
  authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
10
- search: z.ZodOptional<z.ZodString>;
11
- title: z.ZodOptional<z.ZodString>;
12
- accountId: z.ZodOptional<z.ZodString>;
13
- owner: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"me">]>>;
14
14
  pageSize: z.ZodOptional<z.ZodNumber>;
15
15
  maxItems: z.ZodOptional<z.ZodNumber>;
16
16
  cursor: z.ZodOptional<z.ZodString>;
@@ -18,7 +18,7 @@ export declare const ListAuthenticationsSchema: z.ZodObject<{
18
18
  isNested: z.ZodOptional<z.ZodBoolean>;
19
19
  }, z.core.$strip>>;
20
20
  }, z.core.$strip>;
21
- export type ListAuthenticationsOptions = z.infer<typeof ListAuthenticationsSchema>;
21
+ export type ListAuthenticationsOptions = z.infer<typeof ListAuthenticationsQuerySchema>;
22
22
  export interface ListAuthenticationsPage {
23
23
  data: AuthenticationItem[];
24
24
  nextCursor?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listAuthentications/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAI5B,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;iBAqC+B,CAAC;AAGtE,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,yBAAyB,CACjC,CAAC;AAGF,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,MAAM,wBAAwB,GAChC,yBAAyB,GACzB,cAAc,GACd,sBAAsB,GACtB,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,8BAA8B;IAC7C,mBAAmB,EAAE,oBAAoB,CACvC,0BAA0B,EAC1B,kBAAkB,CACnB,CAAC;CACH"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listAuthentications/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AAE7F,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;iBA+B0B,CAAC;AAGtE,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,8BAA8B,CACtC,CAAC;AAGF,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,MAAM,wBAAwB,GAChC,yBAAyB,GACzB,cAAc,GACd,sBAAsB,GACtB,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,8BAA8B;IAC7C,mBAAmB,EAAE,oBAAoB,CACvC,0BAA0B,EAC1B,kBAAkB,CACnB,CAAC;CACH"}
@@ -1,37 +1,31 @@
1
1
  import { z } from "zod";
2
2
  import { AppKeyPropertySchema } from "../../types/properties";
3
+ import { ListAuthenticationsQuerySchema as ListAuthenticationsQueryBase } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
3
4
  import { TelemetryMarkerSchema } from "../../utils/function-utils";
4
- // Pure Zod schema - no resolver metadata!
5
- export const ListAuthenticationsSchema = z
6
- .object({
5
+ export const ListAuthenticationsQuerySchema = ListAuthenticationsQueryBase.omit({
6
+ offset: true,
7
+ })
8
+ .extend({
9
+ // Override appKey with our custom schema (array type, different description)
7
10
  appKey: AppKeyPropertySchema.optional().describe("App key of authentications to list (e.g., 'SlackCLIAPI' or slug like 'github')"),
11
+ // Override authenticationIds to be an array instead of comma-separated string
8
12
  authenticationIds: z
9
13
  .array(z.string())
10
14
  .optional()
11
15
  .describe("List of authentication IDs to filter by"),
12
- search: z
13
- .string()
14
- .optional()
15
- .describe("Search term to filter authentications by title"),
16
- title: z
17
- .string()
18
- .optional()
19
- .describe("Filter authentications by exact title match"),
20
- accountId: z.string().optional().describe("Filter by account ID"),
21
- owner: z
22
- .union([z.string(), z.literal("me")])
23
- .optional()
24
- .describe("Filter by owner, 'me' for your own authentications or a specific user ID"),
16
+ // Override pageSize to make optional (needs to be fixed in `zapier-sdk-core`)
25
17
  pageSize: z
26
18
  .number()
27
19
  .min(1)
28
20
  .optional()
29
21
  .describe("Number of authentications per page"),
22
+ // SDK specific property for pagination/iterator helpers
30
23
  maxItems: z
31
24
  .number()
32
25
  .min(1)
33
26
  .optional()
34
27
  .describe("Maximum total items to return across all pages"),
28
+ // SDK specific property for pagination/iterator helpers
35
29
  cursor: z.string().optional().describe("Cursor to start from"),
36
30
  })
37
31
  .merge(TelemetryMarkerSchema)
@@ -1,57 +1,57 @@
1
- import { z } from "zod";
1
+ import type { z } from "zod";
2
2
  export { FormattedItem, FormatMetadata } from "../utils/schema-utils";
3
3
  export declare const AppItemSchema: z.ZodObject<{
4
+ slug: z.ZodString;
5
+ age_in_days: z.ZodOptional<z.ZodNumber>;
6
+ auth_type: z.ZodOptional<z.ZodString>;
7
+ banner: z.ZodOptional<z.ZodString>;
4
8
  categories: z.ZodOptional<z.ZodArray<z.ZodObject<{
5
9
  id: z.ZodNumber;
6
10
  name: z.ZodString;
7
11
  slug: z.ZodString;
8
12
  }, z.core.$strip>>>;
9
- actions: z.ZodOptional<z.ZodObject<{
10
- read: z.ZodOptional<z.ZodNumber>;
11
- read_bulk: z.ZodOptional<z.ZodNumber>;
12
- write: z.ZodOptional<z.ZodNumber>;
13
- search: z.ZodOptional<z.ZodNumber>;
14
- search_or_write: z.ZodOptional<z.ZodNumber>;
15
- search_and_write: z.ZodOptional<z.ZodNumber>;
16
- filter: z.ZodOptional<z.ZodNumber>;
17
- }, z.core.$strip>>;
18
- description: z.ZodOptional<z.ZodString>;
19
- is_hidden: z.ZodOptional<z.ZodBoolean>;
20
- age_in_days: z.ZodOptional<z.ZodNumber>;
21
- api_docs_url: z.ZodOptional<z.ZodString>;
22
- banner: z.ZodOptional<z.ZodString>;
23
- image: z.ZodOptional<z.ZodString>;
24
13
  images: z.ZodOptional<z.ZodObject<{
25
14
  url_16x16: z.ZodOptional<z.ZodString>;
26
15
  url_32x32: z.ZodOptional<z.ZodString>;
27
16
  url_64x64: z.ZodOptional<z.ZodString>;
28
17
  url_128x128: z.ZodOptional<z.ZodString>;
29
18
  }, z.core.$strip>>;
30
- is_beta: z.ZodOptional<z.ZodBoolean>;
31
- is_built_in: z.ZodOptional<z.ZodBoolean>;
32
- is_featured: z.ZodOptional<z.ZodBoolean>;
33
- is_premium: z.ZodOptional<z.ZodBoolean>;
34
- is_public: z.ZodOptional<z.ZodBoolean>;
35
- is_upcoming: z.ZodOptional<z.ZodBoolean>;
36
19
  popularity: z.ZodOptional<z.ZodNumber>;
37
- primary_color: z.ZodOptional<z.ZodString>;
38
- slug: z.ZodString;
39
- auth_type: z.ZodOptional<z.ZodString>;
40
- is_deprecated: z.ZodOptional<z.ZodBoolean>;
41
- secondary_color: z.ZodOptional<z.ZodString>;
42
20
  has_filters: z.ZodOptional<z.ZodBoolean>;
43
21
  has_reads: z.ZodOptional<z.ZodBoolean>;
44
22
  has_searches: z.ZodOptional<z.ZodBoolean>;
45
23
  has_searches_or_writes: z.ZodOptional<z.ZodBoolean>;
46
24
  has_upfront_fields: z.ZodOptional<z.ZodBoolean>;
47
25
  has_writes: z.ZodOptional<z.ZodBoolean>;
26
+ is_beta: z.ZodOptional<z.ZodBoolean>;
27
+ is_built_in: z.ZodOptional<z.ZodBoolean>;
28
+ is_deprecated: z.ZodOptional<z.ZodBoolean>;
29
+ is_featured: z.ZodOptional<z.ZodBoolean>;
30
+ is_hidden: z.ZodOptional<z.ZodBoolean>;
48
31
  is_invite: z.ZodOptional<z.ZodBoolean>;
49
- version: z.ZodOptional<z.ZodString>;
32
+ is_premium: z.ZodOptional<z.ZodBoolean>;
33
+ is_public: z.ZodOptional<z.ZodBoolean>;
34
+ is_upcoming: z.ZodOptional<z.ZodBoolean>;
50
35
  visibility: z.ZodOptional<z.ZodString>;
36
+ actions: z.ZodOptional<z.ZodObject<{
37
+ read: z.ZodOptional<z.ZodNumber>;
38
+ read_bulk: z.ZodOptional<z.ZodNumber>;
39
+ write: z.ZodOptional<z.ZodNumber>;
40
+ search: z.ZodOptional<z.ZodNumber>;
41
+ search_or_write: z.ZodOptional<z.ZodNumber>;
42
+ search_and_write: z.ZodOptional<z.ZodNumber>;
43
+ filter: z.ZodOptional<z.ZodNumber>;
44
+ }, z.core.$strip>>;
45
+ description: z.ZodOptional<z.ZodString>;
46
+ primary_color: z.ZodOptional<z.ZodString>;
47
+ secondary_color: z.ZodOptional<z.ZodString>;
51
48
  classification: z.ZodOptional<z.ZodString>;
49
+ api_docs_url: z.ZodOptional<z.ZodString>;
50
+ image: z.ZodOptional<z.ZodString>;
52
51
  title: z.ZodString;
53
52
  key: z.ZodString;
54
53
  implementation_id: z.ZodString;
54
+ version: z.ZodOptional<z.ZodString>;
55
55
  }, z.core.$strip>;
56
56
  export type AppItem = z.infer<typeof AppItemSchema>;
57
57
  //# sourceMappingURL=App.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/schemas/App.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMtE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2BzB,CAAC;AAMF,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/schemas/App.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAK7B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMtE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoBxB,CAAC;AAMH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -1,15 +1,10 @@
1
- import { z } from "zod";
2
1
  import { withFormatter } from "../utils/schema-utils";
3
- import { ImplementationMetaSchema } from "../api/schemas";
2
+ import { AppItemSchema as AppItemSchemaBase } from "@zapier/zapier-sdk-core/v0/schemas/apps";
4
3
  import { toSnakeCase } from "../utils/string-utils";
5
4
  // ============================================================================
6
- // App Item Schema (extends ImplementationMetaSchema with transformed fields)
5
+ // App Item Schema (wraps core schema with SDK-specific formatting)
7
6
  // ============================================================================
8
- export const AppItemSchema = withFormatter(ImplementationMetaSchema.omit({ name: true, id: true }).extend({
9
- title: z.string(), // Mapped from name
10
- key: z.string(), // Extracted from id (base part without version)
11
- implementation_id: z.string(), // Mapped from id (full versioned ID)
12
- }), {
7
+ export const AppItemSchema = withFormatter(AppItemSchemaBase, {
13
8
  format: (item) => {
14
9
  // Create additional keys if slug exists
15
10
  const additionalKeys = [];
package/dist/sdk.d.ts CHANGED
@@ -46,7 +46,7 @@ export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOption
46
46
  } & {
47
47
  meta: {
48
48
  listApps: {
49
- inputSchema: typeof import("./temporary-internal-core").ListAppsOptionsSchema;
49
+ inputSchema: typeof import("./plugins/listApps/schemas").ListAppsSchema;
50
50
  };
51
51
  };
52
52
  } & {
@@ -94,7 +94,7 @@ export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOption
94
94
  } & {
95
95
  meta: {
96
96
  listAuthentications: {
97
- inputSchema: typeof import("./plugins/listAuthentications/schemas").ListAuthenticationsSchema;
97
+ inputSchema: typeof import("./plugins/listAuthentications/schemas").ListAuthenticationsQuerySchema;
98
98
  };
99
99
  };
100
100
  } & {
package/dist/sdk.test.js CHANGED
@@ -162,8 +162,9 @@ describe("Environment Variable Support", () => {
162
162
  ok: true,
163
163
  status: 200,
164
164
  json: async () => ({
165
- results: [],
166
- meta: { next_cursor: null },
165
+ data: [],
166
+ links: { next: null },
167
+ meta: { count: 0, limit: 100, offset: 0 },
167
168
  }),
168
169
  headers: new Headers(),
169
170
  });
@@ -178,7 +179,7 @@ describe("Environment Variable Support", () => {
178
179
  expect(mockFetch).toHaveBeenCalledTimes(1);
179
180
  const [actualUrl] = mockFetch.mock.calls[0];
180
181
  expect(actualUrl).toMatch(new RegExp(`^${customBaseUrl}`));
181
- expect(actualUrl).toContain("/api/v4/");
182
+ expect(actualUrl).toContain("/api/v0/");
182
183
  });
183
184
  it("should use default base URL when ZAPIER_BASE_URL is not set", async () => {
184
185
  // Ensure environment variable is not set
@@ -191,8 +192,9 @@ describe("Environment Variable Support", () => {
191
192
  ok: true,
192
193
  status: 200,
193
194
  json: async () => ({
194
- results: [],
195
- meta: { next_cursor: null },
195
+ data: [],
196
+ links: { next: null },
197
+ meta: { count: 0, limit: 100, offset: 0 },
196
198
  }),
197
199
  headers: new Headers(),
198
200
  });
@@ -207,7 +209,7 @@ describe("Environment Variable Support", () => {
207
209
  expect(mockFetch).toHaveBeenCalledTimes(1);
208
210
  const [actualUrl] = mockFetch.mock.calls[0];
209
211
  expect(actualUrl).toMatch(/^https:\/\/sdkapi\.zapier\.com/);
210
- expect(actualUrl).toContain("/api/v4/");
212
+ expect(actualUrl).toContain("/api/v0/");
211
213
  });
212
214
  it("should use explicit baseUrl option for SDK API requests", async () => {
213
215
  // Clear environment variable to ensure we're testing the explicit option
@@ -221,8 +223,9 @@ describe("Environment Variable Support", () => {
221
223
  ok: true,
222
224
  status: 200,
223
225
  json: async () => ({
224
- results: [],
225
- meta: { next_cursor: null },
226
+ data: [],
227
+ links: { next: null },
228
+ meta: { count: 0, limit: 100, offset: 0 },
226
229
  }),
227
230
  headers: new Headers(),
228
231
  });
@@ -238,7 +241,7 @@ describe("Environment Variable Support", () => {
238
241
  expect(mockFetch).toHaveBeenCalledTimes(1);
239
242
  const [actualUrl] = mockFetch.mock.calls[0];
240
243
  expect(actualUrl).toMatch(new RegExp(`^${customBaseUrl}`));
241
- expect(actualUrl).toContain("/api/v4/");
244
+ expect(actualUrl).toContain("/api/v0/");
242
245
  });
243
246
  it("should accept authClientId in SDK options", async () => {
244
247
  delete process.env.ZAPIER_BASE_URL;
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Domain utility functions for working with app identifiers and data normalization
3
3
  */
4
- import type { Action, Authentication, ImplementationMeta } from "../api/types";
5
- import type { ActionItem, AppItem, AuthenticationItem } from "../types/domain";
4
+ import type { Action, ImplementationMeta } from "../api/types";
5
+ import type { ActionItem, AppItem } from "../types/domain";
6
6
  /**
7
7
  * Splits a versioned key to extract the base key and version
8
8
  *
@@ -21,19 +21,6 @@ export declare function splitVersionedKey(versionedKey: string): [string, string
21
21
  * @returns Normalized AppItem with essential fields only
22
22
  */
23
23
  export declare function normalizeImplementationMetaToAppItem(implementationMeta: ImplementationMeta): AppItem;
24
- /**
25
- * Converts an API Authentication to an AuthenticationItem with normalized field names
26
- *
27
- * @param auth - Raw Authentication from API
28
- * @param options - Additional fields to include
29
- * @param options.app_key - selected_api from implementations endpoint
30
- * @param options.app_version - Version extracted from selected_api
31
- * @returns Normalized AuthenticationItem
32
- */
33
- export declare function normalizeAuthenticationItem(auth: Authentication, options?: {
34
- app_key?: string;
35
- app_version?: string;
36
- }): AuthenticationItem;
37
24
  export declare function normalizeActionItem(action: Action): ActionItem;
38
25
  /**
39
26
  * Groups app keys by their type based on format patterns
@@ -1 +1 @@
1
- {"version":3,"file":"domain-utils.d.ts","sourceRoot":"","sources":["../../src/utils/domain-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE/E;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,GACnB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAQ9B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,kBAAkB,EAAE,kBAAkB,GACrC,OAAO,CAYT;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,cAAc,EACpB,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GACvD,kBAAkB,CAyCpB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAsB9D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG;IAC9D,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAgCA;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG;IACrD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAUA;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5C;AAED,wBAAgB,gB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AC9D,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAgCA;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG;IACrD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAUA;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5C;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOtD;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY1D;AAED,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AACD,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAI9C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAkBvD;AAED,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,UAAU,GACrB,UAAU,IAAI,kBAAkB,CAElC;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,kBAAkB,GAAG,MAAM,CAEzE"}
@@ -37,44 +37,6 @@ export function normalizeImplementationMetaToAppItem(implementationMeta) {
37
37
  version: appVersion,
38
38
  };
39
39
  }
40
- /**
41
- * Converts an API Authentication to an AuthenticationItem with normalized field names
42
- *
43
- * @param auth - Raw Authentication from API
44
- * @param options - Additional fields to include
45
- * @param options.app_key - selected_api from implementations endpoint
46
- * @param options.app_version - Version extracted from selected_api
47
- * @returns Normalized AuthenticationItem
48
- */
49
- export function normalizeAuthenticationItem(auth, options = {}) {
50
- // Extract app key and version from selected_api if not provided
51
- let appKey = options.app_key;
52
- let appVersion = options.app_version;
53
- if (auth.selected_api) {
54
- const [extractedAppKey, extractedVersion] = splitVersionedKey(auth.selected_api);
55
- // Use extracted app key if not provided in options
56
- if (!appKey) {
57
- appKey = extractedAppKey;
58
- }
59
- // Use extracted version if not provided in options
60
- if (!appVersion) {
61
- appVersion = extractedVersion;
62
- }
63
- }
64
- const { selected_api: selectedApi, customuser_id: profileId, id, account_id: accountId, ...restOfAuth } = auth;
65
- return {
66
- ...restOfAuth, // Pass through all other API response fields except selected_api
67
- id: String(id), // Convert to string
68
- account_id: String(accountId), // Convert to string
69
- implementation_id: selectedApi, // Rename selected_api to implementation_id
70
- title: auth.title || auth.label || undefined, // Coerce title from label if missing
71
- is_expired: auth.is_stale, // Map is_stale to is_expired
72
- expired_at: auth.marked_stale_at, // Map marked_stale_at to expired_at
73
- app_key: appKey, // App key from implementations endpoint or parsed from selected_api
74
- app_version: appVersion, // Version from selected_api or provided
75
- profile_id: profileId != null ? String(profileId) : undefined, // Map customuser_id to profile_id, convert to string
76
- };
77
- }
78
40
  export function normalizeActionItem(action) {
79
41
  const { name, type, selected_api: selectedApi } = action;
80
42
  // Split version from selected_api
@@ -30,6 +30,7 @@ export interface TelemetryCallbacks {
30
30
  }
31
31
  /**
32
32
  * Helper function to extract cursor from pagination data
33
+ * Supports JSON:API style `links.next` URLs by extracting the `offset` parameter.
33
34
  */
34
35
  export declare function extractCursor(data: {
35
36
  next?: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"function-utils.d.ts","sourceRoot":"","sources":["../../src/utils/function-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;iBAMhC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,C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AAC,EACtE,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,EACpC,SAAS,CAAC,EAAE,kBAAkB,EAC9B,oBAAoB,CAAC,EAAE,MAAM,GAC5B,CACD,OAAO,CAAC,EAAE,QAAQ,GAAG;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,KACE,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,GACpC,aAAa,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,GAAG;IACxC,KAAK,IAAI,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;CAC3C,CAgHF"}
@@ -18,6 +18,7 @@ export const TelemetryMarkerSchema = z.object({
18
18
  });
19
19
  /**
20
20
  * Helper function to extract cursor from pagination data
21
+ * Supports JSON:API style `links.next` URLs by extracting the `offset` parameter.
21
22
  */
22
23
  export function extractCursor(data) {
23
24
  if (!data?.next) {
@@ -123,10 +124,21 @@ function createPageFunction(coreFn) {
123
124
  const result = await coreFn(options);
124
125
  // If result already has a data property, ensure it's an array
125
126
  if (result && typeof result === "object" && "data" in result) {
126
- const data = result.data;
127
+ const paginatedResult = result;
128
+ // Support both nextCursor and JSON:API links.next format
129
+ let nextCursor;
130
+ if (paginatedResult.nextCursor) {
131
+ nextCursor = paginatedResult.nextCursor;
132
+ }
133
+ else if (paginatedResult.links?.next) {
134
+ // Extract cursor from fully qualified URL (JSON:API spec format)
135
+ nextCursor = extractCursor({ next: paginatedResult.links.next });
136
+ }
127
137
  return {
128
- data: Array.isArray(data) ? data : [data],
129
- nextCursor: result.nextCursor,
138
+ data: Array.isArray(paginatedResult.data)
139
+ ? paginatedResult.data
140
+ : [paginatedResult.data],
141
+ nextCursor,
130
142
  };
131
143
  }
132
144
  // If result is an array, wrap in {data: result}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk",
3
- "version": "0.18.2",
3
+ "version": "0.18.4",
4
4
  "description": "Complete Zapier SDK - combines all Zapier SDK packages",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -36,7 +36,7 @@
36
36
  "access": "public"
37
37
  },
38
38
  "dependencies": {
39
- "@zapier/zapier-sdk-core": "^0.5.0",
39
+ "@zapier/zapier-sdk-core": "^0.5.1",
40
40
  "zod": "4.2.1"
41
41
  },
42
42
  "peerDependencies": {
@@ -1,5 +0,0 @@
1
- /**
2
- * Integration tests for API client handler override mechanism
3
- */
4
- export {};
5
- //# sourceMappingURL=client.integration.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.integration.test.d.ts","sourceRoot":"","sources":["../../src/api/client.integration.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}