@zapier/zapier-sdk 0.15.10 → 0.15.12

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 (108) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.cjs +520 -257
  3. package/dist/index.d.mts +184 -39
  4. package/dist/index.d.ts +3 -3
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/index.mjs +520 -258
  8. package/dist/plugins/eventEmission/builders.d.ts +3 -2
  9. package/dist/plugins/eventEmission/builders.d.ts.map +1 -1
  10. package/dist/plugins/eventEmission/builders.js +32 -0
  11. package/dist/plugins/eventEmission/index.d.ts +4 -2
  12. package/dist/plugins/eventEmission/index.d.ts.map +1 -1
  13. package/dist/plugins/eventEmission/index.js +8 -2
  14. package/dist/plugins/eventEmission/types.d.ts +10 -0
  15. package/dist/plugins/eventEmission/types.d.ts.map +1 -1
  16. package/dist/plugins/fetch/index.d.ts +2 -1
  17. package/dist/plugins/fetch/index.d.ts.map +1 -1
  18. package/dist/plugins/fetch/index.js +39 -11
  19. package/dist/plugins/findFirstAuthentication/index.d.ts +2 -1
  20. package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
  21. package/dist/plugins/findFirstAuthentication/index.js +7 -4
  22. package/dist/plugins/findFirstAuthentication/index.test.js +11 -4
  23. package/dist/plugins/findUniqueAuthentication/index.d.ts +2 -1
  24. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
  25. package/dist/plugins/findUniqueAuthentication/index.js +7 -4
  26. package/dist/plugins/findUniqueAuthentication/index.test.js +9 -2
  27. package/dist/plugins/getAction/index.d.ts +3 -1
  28. package/dist/plugins/getAction/index.d.ts.map +1 -1
  29. package/dist/plugins/getAction/index.js +9 -5
  30. package/dist/plugins/getAction/index.test.js +5 -3
  31. package/dist/plugins/getAction/schemas.d.ts +14 -0
  32. package/dist/plugins/getAction/schemas.d.ts.map +1 -1
  33. package/dist/plugins/getAction/schemas.js +2 -0
  34. package/dist/plugins/getApp/index.d.ts +2 -1
  35. package/dist/plugins/getApp/index.d.ts.map +1 -1
  36. package/dist/plugins/getApp/index.js +12 -5
  37. package/dist/plugins/getApp/index.test.js +7 -0
  38. package/dist/plugins/getAuthentication/index.d.ts +3 -1
  39. package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
  40. package/dist/plugins/getAuthentication/index.js +5 -3
  41. package/dist/plugins/getAuthentication/index.test.js +10 -1
  42. package/dist/plugins/getInputFieldsSchema/index.d.ts +2 -1
  43. package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
  44. package/dist/plugins/getInputFieldsSchema/index.js +5 -3
  45. package/dist/plugins/getInputFieldsSchema/index.test.js +3 -0
  46. package/dist/plugins/getProfile/index.d.ts +3 -1
  47. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  48. package/dist/plugins/getProfile/index.js +5 -3
  49. package/dist/plugins/listActions/index.d.ts +2 -1
  50. package/dist/plugins/listActions/index.d.ts.map +1 -1
  51. package/dist/plugins/listActions/index.js +19 -14
  52. package/dist/plugins/listActions/index.test.js +7 -0
  53. package/dist/plugins/listActions/schemas.d.ts +18 -4
  54. package/dist/plugins/listActions/schemas.d.ts.map +1 -1
  55. package/dist/plugins/listActions/schemas.js +2 -0
  56. package/dist/plugins/listApps/index.d.ts +2 -1
  57. package/dist/plugins/listApps/index.d.ts.map +1 -1
  58. package/dist/plugins/listApps/index.js +7 -3
  59. package/dist/plugins/listApps/index.test.js +7 -0
  60. package/dist/plugins/listAuthentications/index.d.ts +2 -1
  61. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  62. package/dist/plugins/listAuthentications/index.js +7 -3
  63. package/dist/plugins/listAuthentications/index.test.js +7 -0
  64. package/dist/plugins/listAuthentications/schemas.d.ts +18 -4
  65. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  66. package/dist/plugins/listAuthentications/schemas.js +2 -0
  67. package/dist/plugins/listInputFieldChoices/index.d.ts +3 -1
  68. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  69. package/dist/plugins/listInputFieldChoices/index.js +7 -3
  70. package/dist/plugins/listInputFieldChoices/index.test.js +5 -2
  71. package/dist/plugins/listInputFieldChoices/schemas.d.ts +4 -4
  72. package/dist/plugins/listInputFields/index.d.ts +3 -1
  73. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  74. package/dist/plugins/listInputFields/index.js +7 -4
  75. package/dist/plugins/listInputFields/index.test.js +3 -0
  76. package/dist/plugins/listInputFields/schemas.d.ts +4 -4
  77. package/dist/plugins/manifest/index.test.js +10 -1
  78. package/dist/plugins/request/index.d.ts +3 -1
  79. package/dist/plugins/request/index.d.ts.map +1 -1
  80. package/dist/plugins/request/index.js +5 -3
  81. package/dist/plugins/request/index.test.js +10 -1
  82. package/dist/plugins/request/schemas.d.ts +28 -0
  83. package/dist/plugins/request/schemas.d.ts.map +1 -1
  84. package/dist/plugins/request/schemas.js +2 -0
  85. package/dist/plugins/runAction/index.d.ts +3 -1
  86. package/dist/plugins/runAction/index.d.ts.map +1 -1
  87. package/dist/plugins/runAction/index.js +8 -3
  88. package/dist/plugins/runAction/index.test.js +20 -8
  89. package/dist/plugins/runAction/schemas.d.ts +4 -4
  90. package/dist/temporary-internal-core/schemas/apps/index.d.ts +21 -7
  91. package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +1 -1
  92. package/dist/temporary-internal-core/schemas/apps/index.js +2 -0
  93. package/dist/types/telemetry-events.d.ts +31 -2
  94. package/dist/types/telemetry-events.d.ts.map +1 -1
  95. package/dist/utils/function-utils.d.ts +42 -3
  96. package/dist/utils/function-utils.d.ts.map +1 -1
  97. package/dist/utils/function-utils.js +84 -9
  98. package/dist/utils/string-utils.d.ts +19 -0
  99. package/dist/utils/string-utils.d.ts.map +1 -1
  100. package/dist/utils/string-utils.js +21 -0
  101. package/dist/utils/string-utils.test.js +24 -1
  102. package/dist/utils/telemetry-utils.d.ts +44 -0
  103. package/dist/utils/telemetry-utils.d.ts.map +1 -0
  104. package/dist/utils/telemetry-utils.js +55 -0
  105. package/dist/utils/telemetry-utils.test.d.ts +2 -0
  106. package/dist/utils/telemetry-utils.test.d.ts.map +1 -0
  107. package/dist/utils/telemetry-utils.test.js +94 -0
  108. package/package.json +1 -1
@@ -3,10 +3,16 @@ import { GetAppSchema } from "./schemas";
3
3
  import { AppItemSchema } from "../../schemas/App";
4
4
  import { ZapierAppNotFoundError } from "../../types/errors";
5
5
  import { appKeyResolver } from "../../resolvers";
6
+ import { createTelemetryCallback } from "../../utils/telemetry-utils";
6
7
  // GetApp plugin depends on listApps SDK function
7
- export const getAppPlugin = ({ sdk }) => {
8
- const getApp = createFunction(async function getApp(options) {
9
- const appsIterator = sdk.listApps({ appKeys: [options.appKey] }).items();
8
+ export const getAppPlugin = ({ sdk, context }) => {
9
+ async function getApp(options) {
10
+ const appsIterator = sdk
11
+ .listApps({
12
+ appKeys: [options.appKey],
13
+ _telemetry: { isNested: true },
14
+ })
15
+ .items();
10
16
  for await (const app of appsIterator) {
11
17
  return {
12
18
  data: app,
@@ -15,10 +21,11 @@ export const getAppPlugin = ({ sdk }) => {
15
21
  throw new ZapierAppNotFoundError("App not found", {
16
22
  appKey: options.appKey,
17
23
  });
18
- }, GetAppSchema);
24
+ }
25
+ const getAppDefinition = createFunction(getApp, GetAppSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, getApp.name));
19
26
  // Return flat structure - getApp goes directly to SDK
20
27
  return {
21
- getApp,
28
+ getApp: getAppDefinition,
22
29
  context: {
23
30
  meta: {
24
31
  getApp: {
@@ -5,9 +5,16 @@ import { createSdk } from "../../sdk";
5
5
  import { apiPlugin } from "../api/index";
6
6
  import { listAppsPlugin } from "../listApps";
7
7
  import { manifestPlugin } from "../manifest";
8
+ import { eventEmissionPlugin } from "../eventEmission";
8
9
  function createTestSdk() {
9
10
  return createSdk()
11
+ .addPlugin(() => ({
12
+ context: {
13
+ options: {},
14
+ },
15
+ }))
10
16
  .addPlugin(apiPlugin, { fetch: global.fetch })
17
+ .addPlugin(eventEmissionPlugin)
11
18
  .addPlugin(manifestPlugin)
12
19
  .addPlugin(listAppsPlugin)
13
20
  .addPlugin(getAppPlugin);
@@ -1,6 +1,7 @@
1
1
  import type { Plugin } from "../../types/plugin";
2
2
  import type { ApiClient } from "../../api";
3
3
  import { GetAuthenticationSchema, type GetAuthenticationOptions, type GetAuthenticationResponse } from "./schemas";
4
+ import type { EventEmissionContext } from "../eventEmission";
4
5
  export interface GetAuthenticationPluginProvides {
5
6
  getAuthentication: (options: GetAuthenticationOptions) => Promise<GetAuthenticationResponse>;
6
7
  context: {
@@ -12,8 +13,9 @@ export interface GetAuthenticationPluginProvides {
12
13
  };
13
14
  }
14
15
  export declare const getAuthenticationPlugin: Plugin<{}, // no SDK dependencies
16
+ // no SDK dependencies
15
17
  {
16
18
  api: ApiClient;
17
- }, // requires api in context
19
+ } & EventEmissionContext, // requires api in context
18
20
  GetAuthenticationPluginProvides>;
19
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,uBAAuB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC/B,MAAM,WAAW,CAAC;AAKnB,MAAM,WAAW,+BAA+B;IAC9C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACxC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,iBAAiB,EAAE;gBACjB,WAAW,EAAE,OAAO,uBAAuB,CAAC;aAC7C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,+BAA+B,CA+BhC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,uBAAuB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC/B,MAAM,WAAW,CAAC;AAInB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,MAAM,WAAW,+BAA+B;IAC9C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACxC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,iBAAiB,EAAE;gBACjB,WAAW,EAAE,OAAO,uBAAuB,CAAC;aAC7C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,EAAE,EAAE,sBAAsB;AAC1B,AADI,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EAAE,0BAA0B;AACrE,+BAA+B,CAsChC,CAAC"}
@@ -2,15 +2,17 @@ import { GetAuthenticationSchema, } from "./schemas";
2
2
  import { createFunction } from "../../utils/function-utils";
3
3
  import { authenticationIdGenericResolver } from "../../resolvers";
4
4
  import { AuthenticationItemSchema } from "../../schemas/Auth";
5
+ import { createTelemetryCallback } from "../../utils/telemetry-utils";
5
6
  export const getAuthenticationPlugin = ({ context }) => {
6
- const getAuthentication = createFunction(async function getAuthentication(options) {
7
+ async function getAuthentication(options) {
7
8
  const { api } = context;
8
9
  // Call the SDK API endpoint, which will be routed to the handler via handlerOverride in pathConfig.
9
10
  // When the handler is migrated to SDK API, this same API call will go over the network.
10
11
  return await api.get(`/api/v0/authentications/${options.authenticationId}`);
11
- }, GetAuthenticationSchema);
12
+ }
13
+ const getAuthenticationDefinition = createFunction(getAuthentication, GetAuthenticationSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, getAuthentication.name));
12
14
  return {
13
- getAuthentication,
15
+ getAuthentication: getAuthenticationDefinition,
14
16
  context: {
15
17
  meta: {
16
18
  getAuthentication: {
@@ -2,6 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { ZapierValidationError } from "../../types/errors";
3
3
  import { getAuthenticationPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
+ import { eventEmissionPlugin } from "../eventEmission";
5
6
  const mockAuthenticationItem = {
6
7
  id: 123,
7
8
  date: "2021-01-01",
@@ -31,7 +32,15 @@ describe("getAuthentication plugin", () => {
31
32
  },
32
33
  });
33
34
  function createTestSdk() {
34
- return createSdk().addPlugin(apiPlugin).addPlugin(getAuthenticationPlugin);
35
+ return createSdk()
36
+ .addPlugin(() => ({
37
+ context: {
38
+ options: {},
39
+ },
40
+ }))
41
+ .addPlugin(apiPlugin)
42
+ .addPlugin(eventEmissionPlugin)
43
+ .addPlugin(getAuthenticationPlugin);
35
44
  }
36
45
  describe("input validation", () => {
37
46
  it("should throw validation error for missing authenticationId", async () => {
@@ -3,6 +3,7 @@ import type { ApiClient } from "../../api";
3
3
  import { GetInputFieldsSchemaSchema, type GetInputFieldsSchemaOptions as GetInputFieldsSchemaOptions } from "./schemas";
4
4
  import type { GetActionPluginProvides } from "../getAction";
5
5
  import type { GetVersionedImplementationId } from "../manifest/schemas";
6
+ import type { EventEmissionContext } from "../eventEmission";
6
7
  export interface GetInputFieldsSchemaPluginProvides {
7
8
  getInputFieldsSchema: (options: GetInputFieldsSchemaOptions) => Promise<{
8
9
  data: Record<string, unknown>;
@@ -18,5 +19,5 @@ export interface GetInputFieldsSchemaPluginProvides {
18
19
  export declare const getInputFieldsSchemaPlugin: Plugin<GetSdkType<GetActionPluginProvides>, {
19
20
  api: ApiClient;
20
21
  getVersionedImplementationId: GetVersionedImplementationId;
21
- }, GetInputFieldsSchemaPluginProvides>;
22
+ } & EventEmissionContext, GetInputFieldsSchemaPluginProvides>;
22
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getInputFieldsSchema/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,0BAA0B,EAC1B,KAAK,2BAA2B,IAAI,2BAA2B,EAChE,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAUxE,MAAM,WAAW,kCAAkC;IACjD,oBAAoB,EAAE,CACpB,OAAO,EAAE,2BAA2B,KACjC,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAChD,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,oBAAoB,EAAE;gBACpB,WAAW,EAAE,OAAO,0BAA0B,CAAC;aAChD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAC7C,UAAU,CAAC,uBAAuB,CAAC,EACnC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,EACD,kCAAkC,CAmEnC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getInputFieldsSchema/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,0BAA0B,EAC1B,KAAK,2BAA2B,IAAI,2BAA2B,EAChE,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAUxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,WAAW,kCAAkC;IACjD,oBAAoB,EAAE,CACpB,OAAO,EAAE,2BAA2B,KACjC,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAChD,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,oBAAoB,EAAE;gBACpB,WAAW,EAAE,OAAO,0BAA0B,CAAC;aAChD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAC7C,UAAU,CAAC,uBAAuB,CAAC,EACnC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,kCAAkC,CAyEnC,CAAC"}
@@ -3,8 +3,9 @@ import { ZapierConfigurationError } from "../../types/errors";
3
3
  import { createFunction } from "../../utils/function-utils";
4
4
  import { appKeyResolver, actionTypeResolver, actionKeyResolver, authenticationIdResolver, inputsAllOptionalResolver, } from "../../resolvers";
5
5
  import { fetchImplementationNeeds } from "../../services/implementations";
6
+ import { createTelemetryCallback } from "../../utils/telemetry-utils";
6
7
  export const getInputFieldsSchemaPlugin = ({ sdk, context }) => {
7
- const getInputFieldsSchema = createFunction(async function getInputFieldsSchema(options) {
8
+ async function getInputFieldsSchema(options) {
8
9
  const { api, getVersionedImplementationId } = context;
9
10
  const { appKey, actionKey, actionType, authenticationId = null, inputs, } = options;
10
11
  const selectedApi = await getVersionedImplementationId(appKey);
@@ -27,9 +28,10 @@ export const getInputFieldsSchemaPlugin = ({ sdk, context }) => {
27
28
  return {
28
29
  data: needsData.schema || {},
29
30
  };
30
- }, GetInputFieldsSchemaSchema);
31
+ }
32
+ const getInputFieldsSchemaDefinition = createFunction(getInputFieldsSchema, GetInputFieldsSchemaSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, getInputFieldsSchema.name));
31
33
  return {
32
- getInputFieldsSchema,
34
+ getInputFieldsSchema: getInputFieldsSchemaDefinition,
33
35
  context: {
34
36
  meta: {
35
37
  getInputFieldsSchema: {
@@ -6,6 +6,7 @@ import { getAppPlugin } from "../getApp";
6
6
  import { listActionsPlugin } from "../listActions";
7
7
  import { listAppsPlugin } from "../listApps";
8
8
  import { createSdk } from "../../sdk";
9
+ import { eventEmissionPlugin } from "../eventEmission";
9
10
  const mockSchema = {
10
11
  type: "object",
11
12
  properties: {
@@ -73,8 +74,10 @@ describe("getInputFieldsSchema plugin", () => {
73
74
  return createSdk({}, {}, {
74
75
  api: mockApiClient,
75
76
  meta: {},
77
+ options: {},
76
78
  getVersionedImplementationId: mockGetVersionedImplementationId,
77
79
  })
80
+ .addPlugin(eventEmissionPlugin)
78
81
  .addPlugin(listAppsPlugin)
79
82
  .addPlugin(listActionsPlugin)
80
83
  .addPlugin(getAppPlugin)
@@ -3,6 +3,7 @@ import type { ApiClient } from "../../api/types";
3
3
  import type { Plugin } from "../../types/plugin";
4
4
  import type { UserProfileItem } from "../../types/domain";
5
5
  import { GetProfileSchema } from "./schemas";
6
+ import type { EventEmissionContext } from "../eventEmission";
6
7
  export interface GetProfilePluginProvides {
7
8
  getProfile: (options?: GetProfileOptions) => Promise<{
8
9
  data: UserProfileItem;
@@ -16,8 +17,9 @@ export interface GetProfilePluginProvides {
16
17
  };
17
18
  }
18
19
  export declare const getProfilePlugin: Plugin<{}, // no SDK dependencies
20
+ // no SDK dependencies
19
21
  {
20
22
  api: ApiClient;
21
- }, // requires api in context
23
+ } & EventEmissionContext, // requires api and eventEmission in context
22
24
  GetProfilePluginProvides>;
23
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getProfile/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAI7C,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,CACV,OAAO,CAAC,EAAE,iBAAiB,KACxB,OAAO,CAAC;QAAE,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;IACxC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,WAAW,EAAE,OAAO,gBAAgB,CAAC;aACtC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,wBAAwB,CAoCzB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getProfile/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,CACV,OAAO,CAAC,EAAE,iBAAiB,KACxB,OAAO,CAAC;QAAE,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;IACxC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,WAAW,EAAE,OAAO,gBAAgB,CAAC;aACtC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,EAAE,EAAE,sBAAsB;AAC1B,AADI,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EAAE,4CAA4C;AACvF,wBAAwB,CA6CzB,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import { createFunction } from "../../utils/function-utils";
2
2
  import { GetProfileSchema } from "./schemas";
3
3
  import { UserProfileItemSchema } from "../../schemas/UserProfile";
4
+ import { createTelemetryCallback } from "../../utils/telemetry-utils";
4
5
  // Direct plugin function - takes options + sdk + context in one object
5
6
  export const getProfilePlugin = ({ context }) => {
6
- const getProfile = createFunction(async function getProfile() {
7
+ async function getProfile() {
7
8
  const profile = await context.api.get("/zapier/api/v4/profile/", {
8
9
  authRequired: true,
9
10
  });
@@ -15,10 +16,11 @@ export const getProfilePlugin = ({ context }) => {
15
16
  full_name: `${profile.first_name} ${profile.last_name}`, // Computed field
16
17
  },
17
18
  };
18
- }, GetProfileSchema);
19
+ }
20
+ const getProfileDefinition = createFunction(getProfile, GetProfileSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, getProfile.name));
19
21
  // Return flat structure - getProfile goes directly to SDK
20
22
  return {
21
- getProfile,
23
+ getProfile: getProfileDefinition,
22
24
  context: {
23
25
  meta: {
24
26
  getProfile: {
@@ -4,6 +4,7 @@ import type { ActionItem } from "../../types/domain";
4
4
  import { ListActionsSchema, type ListActionsOptions } from "./schemas";
5
5
  import type { ManifestPluginProvides } from "../manifest";
6
6
  import type { GetVersionedImplementationId } from "../manifest/schemas";
7
+ import type { EventEmissionContext } from "../eventEmission";
7
8
  export interface ListActionsPluginProvides {
8
9
  listActions: (options?: ListActionsOptions) => Promise<{
9
10
  data: ActionItem[];
@@ -25,5 +26,5 @@ export interface ListActionsPluginProvides {
25
26
  export declare const listActionsPlugin: Plugin<GetSdkType<ManifestPluginProvides>, {
26
27
  api: ApiClient;
27
28
  getVersionedImplementationId: GetVersionedImplementationId;
28
- }, ListActionsPluginProvides>;
29
+ } & EventEmissionContext, ListActionsPluginProvides>;
29
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listActions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,WAAW,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EACL,iBAAiB,EACjB,KAAK,kBAAkB,EAExB,MAAM,WAAW,CAAC;AAOnB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAGxE,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,OAAO,CAAC;QACrD,IAAI,EAAE,UAAU,EAAE,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC3D,KAAK,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;KACpC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,WAAW,EAAE;gBACX,WAAW,EAAE,OAAO,iBAAiB,CAAC;aACvC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC,UAAU,CAAC,sBAAsB,CAAC,EAClC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,EACD,yBAAyB,CAyF1B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listActions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,WAAW,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EACL,iBAAiB,EACjB,KAAK,kBAAkB,EAExB,MAAM,WAAW,CAAC;AAOnB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAI7D,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,OAAO,CAAC;QACrD,IAAI,EAAE,UAAU,EAAE,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC3D,KAAK,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;KACpC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,WAAW,EAAE;gBACX,WAAW,EAAE,OAAO,iBAAiB,CAAC;aACvC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC,UAAU,CAAC,sBAAsB,CAAC,EAClC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,yBAAyB,CAoG1B,CAAC"}
@@ -4,8 +4,21 @@ import { ActionItemSchema } from "../../schemas/Action";
4
4
  import { ZapierConfigurationError, ZapierAuthenticationError, } from "../../types/errors";
5
5
  import { createPaginatedFunction } from "../../utils/function-utils";
6
6
  import { appKeyResolver, actionTypeResolver } from "../../resolvers";
7
+ import { createTelemetryCallback } from "../../utils/telemetry-utils";
8
+ import { stripPageSuffix } from "../../utils/string-utils";
7
9
  export const listActionsPlugin = ({ context }) => {
8
- const listActions = createPaginatedFunction(async function listActionsPage(options) {
10
+ const methodMeta = {
11
+ categories: ["action"],
12
+ type: "list",
13
+ itemType: "Action",
14
+ inputSchema: ListActionsSchema,
15
+ outputSchema: ActionItemSchema,
16
+ resolvers: {
17
+ appKey: appKeyResolver,
18
+ actionType: actionTypeResolver,
19
+ },
20
+ };
21
+ async function listActionsPage(options) {
9
22
  const { api, getVersionedImplementationId } = context;
10
23
  // Use getVersionedImplementationId (optimized to check manifest first)
11
24
  const selectedApi = await getVersionedImplementationId(options.appKey);
@@ -48,22 +61,14 @@ export const listActionsPlugin = ({ context }) => {
48
61
  data: allActions,
49
62
  nextCursor: undefined,
50
63
  };
51
- }, ListActionsSchema);
64
+ }
65
+ const methodName = stripPageSuffix(listActionsPage.name);
66
+ const listActionsDefinition = createPaginatedFunction(listActionsPage, ListActionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
52
67
  return {
53
- listActions,
68
+ listActions: listActionsDefinition,
54
69
  context: {
55
70
  meta: {
56
- listActions: {
57
- categories: ["action"],
58
- type: "list",
59
- itemType: "Action",
60
- inputSchema: ListActionsSchema,
61
- outputSchema: ActionItemSchema,
62
- resolvers: {
63
- appKey: appKeyResolver,
64
- actionType: actionTypeResolver,
65
- },
66
- },
71
+ listActions: methodMeta,
67
72
  },
68
73
  },
69
74
  };
@@ -3,6 +3,7 @@ import { ZapierValidationError, ZapierAuthenticationError, ZapierConfigurationEr
3
3
  import { listActionsPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
5
  import { listAppsPlugin } from "../listApps";
6
+ import { eventEmissionPlugin } from "../eventEmission";
6
7
  const mockImplementationsResponse = {
7
8
  results: [
8
9
  {
@@ -60,11 +61,17 @@ describe("listActions plugin", () => {
60
61
  // Create a proper plugin chain with context dependencies
61
62
  // Build SDK with proper plugin composition, providing API in initial context
62
63
  return createSdk()
64
+ .addPlugin(() => ({
65
+ context: {
66
+ options: {},
67
+ },
68
+ }))
63
69
  .addPlugin(() => ({
64
70
  context: {
65
71
  api: mockApiClient,
66
72
  },
67
73
  }))
74
+ .addPlugin(eventEmissionPlugin)
68
75
  .addPlugin(() => ({
69
76
  context: {
70
77
  manifest: null,
@@ -10,18 +10,32 @@ export declare const ListActionsSchema: z.ZodObject<{
10
10
  pageSize: z.ZodOptional<z.ZodNumber>;
11
11
  maxItems: z.ZodOptional<z.ZodNumber>;
12
12
  cursor: z.ZodOptional<z.ZodString>;
13
+ } & {
14
+ _telemetry: z.ZodOptional<z.ZodObject<{
15
+ isNested: z.ZodOptional<z.ZodBoolean>;
16
+ }, "strip", z.ZodTypeAny, {
17
+ isNested?: boolean | undefined;
18
+ }, {
19
+ isNested?: boolean | undefined;
20
+ }>>;
13
21
  }, "strip", z.ZodTypeAny, {
14
22
  appKey: string;
15
23
  actionType?: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write" | undefined;
16
- pageSize?: number | undefined;
17
- maxItems?: number | undefined;
18
24
  cursor?: string | undefined;
25
+ maxItems?: number | undefined;
26
+ pageSize?: number | undefined;
27
+ _telemetry?: {
28
+ isNested?: boolean | undefined;
29
+ } | undefined;
19
30
  }, {
20
31
  appKey: string;
21
32
  actionType?: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write" | undefined;
22
- pageSize?: number | undefined;
23
- maxItems?: number | undefined;
24
33
  cursor?: string | undefined;
34
+ maxItems?: number | undefined;
35
+ pageSize?: number | undefined;
36
+ _telemetry?: {
37
+ isNested?: boolean | undefined;
38
+ } | undefined;
25
39
  }>;
26
40
  export type ListActionsOptions = z.infer<typeof ListActionsSchema>;
27
41
  export interface ListActionsPage {
@@ -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;AAKxB,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;AAG5B,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;EAoBoB,CAAC;AAGnD,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAGnE,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;AAKxB,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;AAI5B,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBoB,CAAC;AAGnD,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAGnE,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,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { AppKeyPropertySchema, ActionTypePropertySchema, } from "../../types/properties";
3
+ import { TelemetryMarkerSchema } from "../../utils/function-utils";
3
4
  // Pure Zod schema - no resolver metadata!
4
5
  export const ListActionsSchema = z
5
6
  .object({
@@ -17,4 +18,5 @@ export const ListActionsSchema = z
17
18
  .describe("Maximum total items to return across all pages"),
18
19
  cursor: z.string().optional().describe("Cursor to start from"),
19
20
  })
21
+ .merge(TelemetryMarkerSchema)
20
22
  .describe("List all actions for a specific app");
@@ -2,6 +2,7 @@ import type { GetContextType, Plugin } from "../../types/plugin";
2
2
  import { ListAppsSchema, type ListAppsOptions, type AppItem } from "./schemas";
3
3
  import type { ManifestPluginProvides } from "../manifest";
4
4
  import type { ApiPluginProvides } from "../api";
5
+ import type { EventEmissionContext } from "../eventEmission";
5
6
  export interface ListAppsPluginProvides {
6
7
  listApps: (options?: ListAppsOptions) => Promise<{
7
8
  data: AppItem[];
@@ -20,5 +21,5 @@ export interface ListAppsPluginProvides {
20
21
  };
21
22
  };
22
23
  }
23
- export declare const listAppsPlugin: Plugin<{}, GetContextType<ApiPluginProvides & ManifestPluginProvides>, ListAppsPluginProvides>;
24
+ export declare const listAppsPlugin: Plugin<{}, GetContextType<ApiPluginProvides & ManifestPluginProvides> & EventEmissionContext, ListAppsPluginProvides>;
24
25
  //# 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,cAAc,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EAEpB,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;QAC/C,IAAI,EAAE,OAAO,EAAE,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACxD,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,EAAE,EACF,cAAc,CAAC,iBAAiB,GAAG,sBAAsB,CAAC,EAC1D,sBAAsB,CAwEvB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EAEpB,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,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAI7D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;QAC/C,IAAI,EAAE,OAAO,EAAE,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACxD,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,EAAE,EACF,cAAc,CAAC,iBAAiB,GAAG,sBAAsB,CAAC,GACxD,oBAAoB,EACtB,sBAAsB,CAiFvB,CAAC"}
@@ -1,8 +1,10 @@
1
1
  import { createPaginatedFunction } from "../../utils/function-utils";
2
2
  import { ListAppsSchema, } from "./schemas";
3
3
  import { AppItemSchema } from "../../schemas/App";
4
+ import { createTelemetryCallback } from "../../utils/telemetry-utils";
5
+ import { stripPageSuffix } from "../../utils/string-utils";
4
6
  export const listAppsPlugin = ({ context }) => {
5
- const listApps = createPaginatedFunction(async function listAppsPage(options) {
7
+ async function listAppsPage(options) {
6
8
  const { api, resolveAppKeys } = context;
7
9
  const appKeys = options.appKeys ?? [];
8
10
  const appLocators = await resolveAppKeys({
@@ -46,10 +48,12 @@ export const listAppsPlugin = ({ context }) => {
46
48
  ...(options.cursor && { cursor: options.cursor }),
47
49
  },
48
50
  });
49
- }, ListAppsSchema);
51
+ }
52
+ const methodName = stripPageSuffix(listAppsPage.name);
53
+ const listAppsDefinition = createPaginatedFunction(listAppsPage, ListAppsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
50
54
  // Return flat structure - listApps goes directly to SDK
51
55
  return {
52
- listApps,
56
+ listApps: listAppsDefinition,
53
57
  context: {
54
58
  meta: {
55
59
  listApps: {
@@ -3,6 +3,7 @@ import { ZapierValidationError } from "../../types/errors";
3
3
  import { listAppsPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
5
  import { apiPlugin } from "../api/index";
6
+ import { eventEmissionPlugin } from "../eventEmission";
6
7
  const mockResolveAppKeys = vi
7
8
  .fn()
8
9
  .mockImplementation(async ({ appKeys }) => {
@@ -15,7 +16,13 @@ const mockResolveAppKeys = vi
15
16
  });
16
17
  function createTestSdk(mockFetch) {
17
18
  return createSdk()
19
+ .addPlugin(() => ({
20
+ context: {
21
+ options: {},
22
+ },
23
+ }))
18
24
  .addPlugin(apiPlugin, { fetch: mockFetch || global.fetch })
25
+ .addPlugin(eventEmissionPlugin)
19
26
  .addPlugin(() => ({
20
27
  context: {
21
28
  resolveAppKeys: mockResolveAppKeys,
@@ -4,6 +4,7 @@ import type { AuthenticationItem } from "../../types/domain";
4
4
  import { ListAuthenticationsSchema, type ListAuthenticationsOptions } from "./schemas";
5
5
  import type { GetVersionedImplementationId } from "../manifest/schemas";
6
6
  import type { ManifestPluginProvides } from "../manifest";
7
+ import type { EventEmissionContext } from "../eventEmission";
7
8
  export interface ListAuthenticationsPluginProvides {
8
9
  listAuthentications: (options?: ListAuthenticationsOptions) => Promise<{
9
10
  data: AuthenticationItem[];
@@ -25,5 +26,5 @@ export interface ListAuthenticationsPluginProvides {
25
26
  export declare const listAuthenticationsPlugin: Plugin<GetSdkType<ManifestPluginProvides>, {
26
27
  api: ApiClient;
27
28
  getVersionedImplementationId: GetVersionedImplementationId;
28
- }, ListAuthenticationsPluginProvides>;
29
+ } & EventEmissionContext, ListAuthenticationsPluginProvides>;
29
30
  //# sourceMappingURL=index.d.ts.map
@@ -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,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAI1D,MAAM,WAAW,iCAAiC;IAChD,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,0BAA0B,KAAK,OAAO,CAAC;QACrE,IAAI,EAAE,kBAAkB,EAAE,CAAC;QAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACnE,KAAK,IAAI,aAAa,CAAC,kBAAkB,CAAC,CAAC;KAC5C,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,mBAAmB,EAAE;gBACnB,WAAW,EAAE,OAAO,yBAAyB,CAAC;aAC/C,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,EACD,iCAAiC,CAyGlC,CAAC"}
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,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAI7D,MAAM,WAAW,iCAAiC;IAChD,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,0BAA0B,KAAK,OAAO,CAAC;QACrE,IAAI,EAAE,kBAAkB,EAAE,CAAC;QAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACnE,KAAK,IAAI,aAAa,CAAC,kBAAkB,CAAC,CAAC;KAC5C,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,mBAAmB,EAAE;gBACnB,WAAW,EAAE,OAAO,yBAAyB,CAAC;aAC/C,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,CA+GlC,CAAC"}
@@ -4,8 +4,10 @@ import { ZapierAuthenticationError } from "../../types/errors";
4
4
  import { createPaginatedFunction, extractCursor, } from "../../utils/function-utils";
5
5
  import { appKeyResolver } from "../../resolvers";
6
6
  import { AuthenticationItemSchema } from "../../schemas/Auth";
7
+ import { createTelemetryCallback } from "../../utils/telemetry-utils";
8
+ import { stripPageSuffix } from "../../utils/string-utils";
7
9
  export const listAuthenticationsPlugin = ({ context }) => {
8
- const listAuthentications = createPaginatedFunction(async function listAuthenticationsPage(options) {
10
+ async function listAuthenticationsPage(options) {
9
11
  const { api, getVersionedImplementationId } = context;
10
12
  // Build search parameters
11
13
  const searchParams = {};
@@ -64,9 +66,11 @@ export const listAuthenticationsPlugin = ({ context }) => {
64
66
  data: auths,
65
67
  nextCursor: extractCursor(data),
66
68
  };
67
- }, ListAuthenticationsSchema);
69
+ }
70
+ const methodName = stripPageSuffix(listAuthenticationsPage.name);
71
+ const listAuthenticationsDefinition = createPaginatedFunction(listAuthenticationsPage, ListAuthenticationsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
68
72
  return {
69
- listAuthentications,
73
+ listAuthentications: listAuthenticationsDefinition,
70
74
  context: {
71
75
  meta: {
72
76
  listAuthentications: {
@@ -2,6 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { ZapierValidationError, ZapierAuthenticationError, } from "../../types/errors";
3
3
  import { listAuthenticationsPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
+ import { eventEmissionPlugin } from "../eventEmission";
5
6
  const mockAuthenticationsResponse = {
6
7
  results: [
7
8
  {
@@ -85,7 +86,13 @@ describe("listAuthentications plugin", () => {
85
86
  });
86
87
  function createTestSdk() {
87
88
  return createSdk()
89
+ .addPlugin(() => ({
90
+ context: {
91
+ options: {},
92
+ },
93
+ }))
88
94
  .addPlugin(apiPlugin)
95
+ .addPlugin(eventEmissionPlugin)
89
96
  .addPlugin(manifestPlugin)
90
97
  .addPlugin(listAuthenticationsPlugin);
91
98
  }
@@ -14,13 +14,24 @@ export declare const ListAuthenticationsSchema: z.ZodObject<{
14
14
  pageSize: z.ZodOptional<z.ZodNumber>;
15
15
  maxItems: z.ZodOptional<z.ZodNumber>;
16
16
  cursor: z.ZodOptional<z.ZodString>;
17
+ } & {
18
+ _telemetry: z.ZodOptional<z.ZodObject<{
19
+ isNested: z.ZodOptional<z.ZodBoolean>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ isNested?: boolean | undefined;
22
+ }, {
23
+ isNested?: boolean | undefined;
24
+ }>>;
17
25
  }, "strip", z.ZodTypeAny, {
18
26
  search?: string | undefined;
19
27
  title?: string | undefined;
20
28
  appKey?: string | undefined;
21
- pageSize?: number | undefined;
22
- maxItems?: number | undefined;
23
29
  cursor?: string | undefined;
30
+ maxItems?: number | undefined;
31
+ pageSize?: number | undefined;
32
+ _telemetry?: {
33
+ isNested?: boolean | undefined;
34
+ } | undefined;
24
35
  accountId?: string | undefined;
25
36
  owner?: string | undefined;
26
37
  authenticationIds?: string[] | undefined;
@@ -28,9 +39,12 @@ export declare const ListAuthenticationsSchema: z.ZodObject<{
28
39
  search?: string | undefined;
29
40
  title?: string | undefined;
30
41
  appKey?: string | undefined;
31
- pageSize?: number | undefined;
32
- maxItems?: number | undefined;
33
42
  cursor?: string | undefined;
43
+ maxItems?: number | undefined;
44
+ pageSize?: number | undefined;
45
+ _telemetry?: {
46
+ isNested?: boolean | undefined;
47
+ } | undefined;
34
48
  accountId?: string | undefined;
35
49
  owner?: string | undefined;
36
50
  authenticationIds?: string[] | undefined;
@@ -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;AAG5B,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoC+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,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAI5B,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqC+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,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { AppKeyPropertySchema } from "../../types/properties";
3
+ import { TelemetryMarkerSchema } from "../../utils/function-utils";
3
4
  // Pure Zod schema - no resolver metadata!
4
5
  export const ListAuthenticationsSchema = z
5
6
  .object({
@@ -33,4 +34,5 @@ export const ListAuthenticationsSchema = z
33
34
  .describe("Maximum total items to return across all pages"),
34
35
  cursor: z.string().optional().describe("Cursor to start from"),
35
36
  })
37
+ .merge(TelemetryMarkerSchema)
36
38
  .describe("List available authentications with optional filtering");