@zapier/zapier-sdk 0.18.1 → 0.18.3

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 (57) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +17 -17
  3. package/dist/api/router.d.ts.map +1 -1
  4. package/dist/api/router.js +1 -7
  5. package/dist/api/router.test.js +1 -7
  6. package/dist/api/schemas.d.ts +0 -49
  7. package/dist/api/schemas.d.ts.map +1 -1
  8. package/dist/api/schemas.js +0 -28
  9. package/dist/api/types.d.ts +2 -1
  10. package/dist/api/types.d.ts.map +1 -1
  11. package/dist/api/types.js +0 -10
  12. package/dist/index.cjs +38 -301
  13. package/dist/index.d.mts +114 -207
  14. package/dist/index.mjs +38 -301
  15. package/dist/plugins/findFirstAuthentication/index.test.js +2 -2
  16. package/dist/plugins/findUniqueAuthentication/index.test.js +2 -2
  17. package/dist/plugins/getAuthentication/index.d.ts +3 -3
  18. package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
  19. package/dist/plugins/getAuthentication/index.js +3 -5
  20. package/dist/plugins/getAuthentication/index.test.js +4 -16
  21. package/dist/plugins/getAuthentication/schemas.d.ts +2 -4
  22. package/dist/plugins/getAuthentication/schemas.d.ts.map +1 -1
  23. package/dist/plugins/getAuthentication/schemas.js +1 -1
  24. package/dist/plugins/listAuthentications/index.d.ts +4 -10
  25. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  26. package/dist/plugins/listAuthentications/index.js +19 -31
  27. package/dist/plugins/listAuthentications/index.test.js +347 -127
  28. package/dist/plugins/listAuthentications/schemas.d.ts +7 -7
  29. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  30. package/dist/plugins/listAuthentications/schemas.js +10 -16
  31. package/dist/schemas/Auth.d.ts +11 -11
  32. package/dist/schemas/Auth.d.ts.map +1 -1
  33. package/dist/schemas/Auth.js +2 -12
  34. package/dist/sdk.d.ts +4 -2
  35. package/dist/sdk.d.ts.map +1 -1
  36. package/dist/temporary-internal-core/index.d.ts +0 -2
  37. package/dist/temporary-internal-core/index.d.ts.map +1 -1
  38. package/dist/temporary-internal-core/index.js +0 -2
  39. package/dist/temporary-internal-core/utils/transformations.d.ts +0 -14
  40. package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -1
  41. package/dist/temporary-internal-core/utils/transformations.js +0 -38
  42. package/dist/utils/domain-utils.d.ts +2 -15
  43. package/dist/utils/domain-utils.d.ts.map +1 -1
  44. package/dist/utils/domain-utils.js +0 -38
  45. package/dist/utils/function-utils.d.ts +1 -0
  46. package/dist/utils/function-utils.d.ts.map +1 -1
  47. package/dist/utils/function-utils.js +15 -3
  48. package/package.json +2 -1
  49. package/dist/temporary-internal-core/handlers/getAuthentication.d.ts +0 -94
  50. package/dist/temporary-internal-core/handlers/getAuthentication.d.ts.map +0 -1
  51. package/dist/temporary-internal-core/handlers/getAuthentication.js +0 -68
  52. package/dist/temporary-internal-core/handlers/getAuthentication.test.d.ts +0 -2
  53. package/dist/temporary-internal-core/handlers/getAuthentication.test.d.ts.map +0 -1
  54. package/dist/temporary-internal-core/handlers/getAuthentication.test.js +0 -248
  55. package/dist/temporary-internal-core/schemas/authentications/index.d.ts +0 -150
  56. package/dist/temporary-internal-core/schemas/authentications/index.d.ts.map +0 -1
  57. package/dist/temporary-internal-core/schemas/authentications/index.js +0 -97
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listAuthentications/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,yBAAyB,EACzB,KAAK,0BAA0B,EAEhC,MAAM,WAAW,CAAC;AAUnB,OAAO,KAAK,EAAE,4BAA4B,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M,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAK7D,MAAM,WAAW,iCAAiC;IAChD,mBAAmB,EAAE,CACnB,OAAO,CAAC,EAAE,0BAA0B,KACjC,OAAO,CAAC,uBAAuB,CAAC,GACnC,aAAa,CAAC,uBAAuB,CAAC,GAAG;QACvC,KAAK,IAAI,aAAa,CAAC,kBAAkB,CAAC,CAAC;KAC5C,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,mBAAmB,EAAE;gBACnB,WAAW,EAAE,OAAO,8BAA8B,CAAC;aACpD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAC5C,UAAU,CAAC,sBAAsB,CAAC,EAClC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,iCAAiC,CAiGlC,CAAC"}
@@ -1,49 +1,46 @@
1
- import { ListAuthenticationsSchema, } from "./schemas";
2
- import { normalizeAuthenticationItem, splitVersionedKey, } from "../../utils/domain-utils";
3
- import { ZapierAuthenticationError } from "../../types/errors";
4
- import { createPaginatedFunction, extractCursor, } from "../../utils/function-utils";
1
+ import { ListAuthenticationsQuerySchema, } from "./schemas";
2
+ import { splitVersionedKey } from "../../utils/domain-utils";
3
+ import { createPaginatedFunction } from "../../utils/function-utils";
5
4
  import { appKeyResolver } from "../../resolvers";
6
5
  import { AuthenticationItemSchema } from "../../schemas/Auth";
7
6
  import { createTelemetryCallback } from "../../utils/telemetry-utils";
8
7
  import { stripPageSuffix } from "../../utils/string-utils";
8
+ import { ZapierAuthenticationError } from "../../types/errors";
9
9
  export const listAuthenticationsPlugin = ({ context }) => {
10
10
  async function listAuthenticationsPage(options) {
11
11
  const { api, getVersionedImplementationId } = context;
12
- // Build search parameters
13
- const searchParams = {};
14
- // Handle appKey filtering by getting the selected_api first
12
+ const searchParams = {
13
+ pageSize: options.pageSize.toString(),
14
+ };
15
+ // Resolve appKey to implementationId if provided
15
16
  if (options.appKey) {
16
17
  const implementationId = await getVersionedImplementationId(options.appKey);
17
18
  if (implementationId) {
19
+ // Extract versionless app key to pass to handler
18
20
  const [versionlessSelectedApi] = splitVersionedKey(implementationId);
19
- searchParams.versionless_selected_api = versionlessSelectedApi;
21
+ searchParams.appKey = versionlessSelectedApi;
20
22
  }
21
23
  }
22
- // Add authenticationIds as ids parameter if provided
24
+ // Pass other filter options as searchParams
23
25
  if (options.authenticationIds && options.authenticationIds.length > 0) {
24
- searchParams.ids = options.authenticationIds.join(",");
26
+ searchParams.authenticationIds = options.authenticationIds.join(",");
25
27
  }
26
- // Add other query parameters if provided
27
- // Use title as search if no explicit search provided
28
28
  if (options.search) {
29
29
  searchParams.search = options.search;
30
30
  }
31
- else if (options.title) {
32
- searchParams.search = options.title;
31
+ if (options.title) {
32
+ searchParams.title = options.title;
33
33
  }
34
34
  if (options.accountId) {
35
- searchParams.account_id = options.accountId;
35
+ searchParams.accountId = options.accountId;
36
36
  }
37
37
  if (options.owner) {
38
38
  searchParams.owner = options.owner;
39
39
  }
40
- // pageSize is now guaranteed to be set by the higher-order function
41
- searchParams.limit = options.pageSize.toString();
42
40
  if (options.cursor) {
43
- // Convert cursor back to offset for the API
44
41
  searchParams.offset = options.cursor;
45
42
  }
46
- const data = await api.get("/zapier/api/v4/authentications/", {
43
+ const response = await api.get("/api/v0/authentications", {
47
44
  searchParams,
48
45
  customErrorHandler: ({ status }) => {
49
46
  if (status === 401) {
@@ -56,19 +53,10 @@ export const listAuthenticationsPlugin = ({ context }) => {
56
53
  },
57
54
  authRequired: true,
58
55
  });
59
- // Transform API response and filter by exact title match if specified
60
- let auths = (data.results || []).map((auth) => normalizeAuthenticationItem(auth));
61
- // Filter by exact title match if specified
62
- if (options.title) {
63
- auths = auths.filter((auth) => auth.title === options.title);
64
- }
65
- return {
66
- data: auths,
67
- nextCursor: extractCursor(data),
68
- };
56
+ return response;
69
57
  }
70
58
  const methodName = stripPageSuffix(listAuthenticationsPage.name);
71
- const listAuthenticationsDefinition = createPaginatedFunction(listAuthenticationsPage, ListAuthenticationsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
59
+ const listAuthenticationsDefinition = createPaginatedFunction(listAuthenticationsPage, ListAuthenticationsQuerySchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
72
60
  return {
73
61
  listAuthentications: listAuthenticationsDefinition,
74
62
  context: {
@@ -77,7 +65,7 @@ export const listAuthenticationsPlugin = ({ context }) => {
77
65
  categories: ["authentication"],
78
66
  type: "list",
79
67
  itemType: "Authentication",
80
- inputSchema: ListAuthenticationsSchema,
68
+ inputSchema: ListAuthenticationsQuerySchema,
81
69
  outputSchema: AuthenticationItemSchema,
82
70
  resolvers: {
83
71
  appKey: appKeyResolver,