@zapier/zapier-sdk 0.15.10 → 0.15.11
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.
- package/CHANGELOG.md +6 -0
- package/dist/index.cjs +583 -337
- package/dist/index.d.mts +184 -39
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +583 -338
- package/dist/plugins/eventEmission/builders.d.ts +3 -2
- package/dist/plugins/eventEmission/builders.d.ts.map +1 -1
- package/dist/plugins/eventEmission/builders.js +32 -0
- package/dist/plugins/eventEmission/index.d.ts +4 -2
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +8 -2
- package/dist/plugins/eventEmission/types.d.ts +10 -0
- package/dist/plugins/eventEmission/types.d.ts.map +1 -1
- package/dist/plugins/fetch/index.d.ts +2 -1
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +39 -11
- package/dist/plugins/findFirstAuthentication/index.d.ts +2 -1
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findFirstAuthentication/index.js +4 -2
- package/dist/plugins/findFirstAuthentication/index.test.js +11 -4
- package/dist/plugins/findUniqueAuthentication/index.d.ts +2 -1
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueAuthentication/index.js +4 -2
- package/dist/plugins/findUniqueAuthentication/index.test.js +9 -2
- package/dist/plugins/getAction/index.d.ts +3 -1
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +6 -3
- package/dist/plugins/getAction/index.test.js +5 -3
- package/dist/plugins/getAction/schemas.d.ts +14 -0
- package/dist/plugins/getAction/schemas.d.ts.map +1 -1
- package/dist/plugins/getAction/schemas.js +2 -0
- package/dist/plugins/getApp/index.d.ts +2 -1
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +9 -3
- package/dist/plugins/getApp/index.test.js +7 -0
- package/dist/plugins/getAuthentication/index.d.ts +3 -1
- package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/getAuthentication/index.js +2 -1
- package/dist/plugins/getAuthentication/index.test.js +10 -1
- package/dist/plugins/getInputFieldsSchema/index.d.ts +2 -1
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/getInputFieldsSchema/index.js +2 -1
- package/dist/plugins/getInputFieldsSchema/index.test.js +3 -0
- package/dist/plugins/getProfile/index.d.ts +3 -1
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +2 -1
- package/dist/plugins/listActions/index.d.ts +2 -1
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +14 -12
- package/dist/plugins/listActions/index.test.js +7 -0
- package/dist/plugins/listActions/schemas.d.ts +18 -4
- package/dist/plugins/listActions/schemas.d.ts.map +1 -1
- package/dist/plugins/listActions/schemas.js +2 -0
- package/dist/plugins/listApps/index.d.ts +2 -1
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +2 -1
- package/dist/plugins/listApps/index.test.js +7 -0
- package/dist/plugins/listAuthentications/index.d.ts +2 -1
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/index.js +2 -1
- package/dist/plugins/listAuthentications/index.test.js +7 -0
- package/dist/plugins/listAuthentications/schemas.d.ts +18 -4
- package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/schemas.js +2 -0
- package/dist/plugins/listInputFieldChoices/index.d.ts +3 -1
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +2 -1
- package/dist/plugins/listInputFieldChoices/index.test.js +5 -2
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +4 -4
- package/dist/plugins/listInputFields/index.d.ts +3 -1
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +2 -1
- package/dist/plugins/listInputFields/index.test.js +3 -0
- package/dist/plugins/listInputFields/schemas.d.ts +4 -4
- package/dist/plugins/manifest/index.test.js +10 -1
- package/dist/plugins/request/index.d.ts +3 -1
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +2 -1
- package/dist/plugins/request/index.test.js +10 -1
- package/dist/plugins/request/schemas.d.ts +28 -0
- package/dist/plugins/request/schemas.d.ts.map +1 -1
- package/dist/plugins/request/schemas.js +2 -0
- package/dist/plugins/runAction/index.d.ts +3 -1
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +3 -1
- package/dist/plugins/runAction/index.test.js +20 -8
- package/dist/plugins/runAction/schemas.d.ts +4 -4
- package/dist/temporary-internal-core/schemas/apps/index.d.ts +21 -7
- package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +1 -1
- package/dist/temporary-internal-core/schemas/apps/index.js +2 -0
- package/dist/types/telemetry-events.d.ts +31 -2
- package/dist/types/telemetry-events.d.ts.map +1 -1
- package/dist/utils/function-utils.d.ts +42 -3
- package/dist/utils/function-utils.d.ts.map +1 -1
- package/dist/utils/function-utils.js +83 -8
- package/dist/utils/telemetry-utils.d.ts +32 -0
- package/dist/utils/telemetry-utils.d.ts.map +1 -0
- package/dist/utils/telemetry-utils.js +43 -0
- package/dist/utils/telemetry-utils.test.d.ts +2 -0
- package/dist/utils/telemetry-utils.test.d.ts.map +1 -0
- package/dist/utils/telemetry-utils.test.js +94 -0
- package/package.json +1 -1
|
@@ -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;
|
|
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,CAoChC,CAAC"}
|
|
@@ -2,13 +2,14 @@ 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
7
|
const getAuthentication = createFunction(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
|
+
}, GetAuthenticationSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, "getAuthentication"));
|
|
12
13
|
return {
|
|
13
14
|
getAuthentication,
|
|
14
15
|
context: {
|
|
@@ -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()
|
|
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,
|
|
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,CAuEnC,CAAC"}
|
|
@@ -3,6 +3,7 @@ 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
8
|
const getInputFieldsSchema = createFunction(async function getInputFieldsSchema(options) {
|
|
8
9
|
const { api, getVersionedImplementationId } = context;
|
|
@@ -27,7 +28,7 @@ export const getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
|
27
28
|
return {
|
|
28
29
|
data: needsData.schema || {},
|
|
29
30
|
};
|
|
30
|
-
}, GetInputFieldsSchemaSchema);
|
|
31
|
+
}, GetInputFieldsSchemaSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, "getInputFieldsSchema"));
|
|
31
32
|
return {
|
|
32
33
|
getInputFieldsSchema,
|
|
33
34
|
context: {
|
|
@@ -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;
|
|
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,CA2CzB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
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
7
|
const getProfile = createFunction(async function getProfile() {
|
|
@@ -15,7 +16,7 @@ export const getProfilePlugin = ({ context }) => {
|
|
|
15
16
|
full_name: `${profile.first_name} ${profile.last_name}`, // Computed field
|
|
16
17
|
},
|
|
17
18
|
};
|
|
18
|
-
}, GetProfileSchema);
|
|
19
|
+
}, GetProfileSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, "getProfile"));
|
|
19
20
|
// Return flat structure - getProfile goes directly to SDK
|
|
20
21
|
return {
|
|
21
22
|
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;
|
|
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;AAG7D,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,CAkG1B,CAAC"}
|
|
@@ -4,7 +4,19 @@ 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";
|
|
7
8
|
export const listActionsPlugin = ({ context }) => {
|
|
9
|
+
const methodMeta = {
|
|
10
|
+
categories: ["action"],
|
|
11
|
+
type: "list",
|
|
12
|
+
itemType: "Action",
|
|
13
|
+
inputSchema: ListActionsSchema,
|
|
14
|
+
outputSchema: ActionItemSchema,
|
|
15
|
+
resolvers: {
|
|
16
|
+
appKey: appKeyResolver,
|
|
17
|
+
actionType: actionTypeResolver,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
8
20
|
const listActions = createPaginatedFunction(async function listActionsPage(options) {
|
|
9
21
|
const { api, getVersionedImplementationId } = context;
|
|
10
22
|
// Use getVersionedImplementationId (optimized to check manifest first)
|
|
@@ -48,22 +60,12 @@ export const listActionsPlugin = ({ context }) => {
|
|
|
48
60
|
data: allActions,
|
|
49
61
|
nextCursor: undefined,
|
|
50
62
|
};
|
|
51
|
-
}, ListActionsSchema);
|
|
63
|
+
}, ListActionsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, "listActions"));
|
|
52
64
|
return {
|
|
53
65
|
listActions,
|
|
54
66
|
context: {
|
|
55
67
|
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
|
-
},
|
|
68
|
+
listActions: methodMeta,
|
|
67
69
|
},
|
|
68
70
|
},
|
|
69
71
|
};
|
|
@@ -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;
|
|
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
|
|
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;
|
|
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;AAG7D,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,CA6EvB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
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";
|
|
4
5
|
export const listAppsPlugin = ({ context }) => {
|
|
5
6
|
const listApps = createPaginatedFunction(async function listAppsPage(options) {
|
|
6
7
|
const { api, resolveAppKeys } = context;
|
|
@@ -46,7 +47,7 @@ export const listAppsPlugin = ({ context }) => {
|
|
|
46
47
|
...(options.cursor && { cursor: options.cursor }),
|
|
47
48
|
},
|
|
48
49
|
});
|
|
49
|
-
}, ListAppsSchema);
|
|
50
|
+
}, ListAppsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, "listApps"));
|
|
50
51
|
// Return flat structure - listApps goes directly to SDK
|
|
51
52
|
return {
|
|
52
53
|
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;
|
|
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;AAG7D,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,CA6GlC,CAAC"}
|
|
@@ -4,6 +4,7 @@ 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";
|
|
7
8
|
export const listAuthenticationsPlugin = ({ context }) => {
|
|
8
9
|
const listAuthentications = createPaginatedFunction(async function listAuthenticationsPage(options) {
|
|
9
10
|
const { api, getVersionedImplementationId } = context;
|
|
@@ -64,7 +65,7 @@ export const listAuthenticationsPlugin = ({ context }) => {
|
|
|
64
65
|
data: auths,
|
|
65
66
|
nextCursor: extractCursor(data),
|
|
66
67
|
};
|
|
67
|
-
}, ListAuthenticationsSchema);
|
|
68
|
+
}, ListAuthenticationsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, "listAuthentications"));
|
|
68
69
|
return {
|
|
69
70
|
listAuthentications,
|
|
70
71
|
context: {
|
|
@@ -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;
|
|
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");
|
|
@@ -4,6 +4,7 @@ import type { InputFieldChoiceItem } from "./schemas";
|
|
|
4
4
|
import { ListInputFieldChoicesSchema, type ListInputFieldChoicesOptions } from "./schemas";
|
|
5
5
|
import type { GetActionPluginProvides } from "../getAction";
|
|
6
6
|
import type { GetVersionedImplementationId } from "../manifest/schemas";
|
|
7
|
+
import type { EventEmissionContext } from "../eventEmission";
|
|
7
8
|
export interface ListInputFieldChoicesPluginProvides {
|
|
8
9
|
listInputFieldChoices: (options: ListInputFieldChoicesOptions) => Promise<{
|
|
9
10
|
data: InputFieldChoiceItem[];
|
|
@@ -23,9 +24,10 @@ export interface ListInputFieldChoicesPluginProvides {
|
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
export declare const listInputFieldChoicesPlugin: Plugin<GetSdkType<GetActionPluginProvides>, // requires getAction in SDK
|
|
27
|
+
// requires getAction in SDK
|
|
26
28
|
{
|
|
27
29
|
api: ApiClient;
|
|
28
30
|
getVersionedImplementationId: GetVersionedImplementationId;
|
|
29
|
-
}, // requires api and
|
|
31
|
+
} & EventEmissionContext, // requires api, getVersionedImplementationId, and eventEmission in context
|
|
30
32
|
ListInputFieldChoicesPluginProvides>;
|
|
31
33
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFieldChoices/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,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EACL,2BAA2B,EAC3B,KAAK,4BAA4B,EAGlC,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFieldChoices/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,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EACL,2BAA2B,EAC3B,KAAK,4BAA4B,EAGlC,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAcxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAc7D,MAAM,WAAW,mCAAmC;IAClD,qBAAqB,EAAE,CAAC,OAAO,EAAE,4BAA4B,KAAK,OAAO,CAAC;QACxE,IAAI,EAAE,oBAAoB,EAAE,CAAC;QAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACrE,KAAK,IAAI,aAAa,CAAC,oBAAoB,CAAC,CAAC;KAC9C,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,qBAAqB,EAAE;gBACrB,WAAW,EAAE,OAAO,2BAA2B,CAAC;aACjD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAC9C,UAAU,CAAC,uBAAuB,CAAC,EAAE,4BAA4B;AACjE,AADqC,4BAA4B;AACjE;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EAAE,2EAA2E;AACrG,mCAAmC,CAgJpC,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { ZapierApiError, ZapierConfigurationError } from "../../types/errors";
|
|
|
3
3
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
4
4
|
import { appKeyResolver, actionTypeResolver, actionKeyResolver, authenticationIdResolver, inputFieldKeyResolver, inputsAllOptionalResolver, } from "../../resolvers";
|
|
5
5
|
import { fetchImplementationNeeds, fetchImplementationChoices, } from "../../services/implementations";
|
|
6
|
+
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
6
7
|
// Transform NeedChoices to InputFieldChoiceItem
|
|
7
8
|
function transformNeedChoicesToInputFieldChoiceItem(choice) {
|
|
8
9
|
return {
|
|
@@ -85,7 +86,7 @@ export const listInputFieldChoicesPlugin = ({ context, sdk }) => {
|
|
|
85
86
|
data: choices,
|
|
86
87
|
nextCursor,
|
|
87
88
|
};
|
|
88
|
-
}, ListInputFieldChoicesSchema);
|
|
89
|
+
}, ListInputFieldChoicesSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, "listInputFieldChoices"));
|
|
89
90
|
return {
|
|
90
91
|
listInputFieldChoices,
|
|
91
92
|
context: {
|
|
@@ -3,6 +3,7 @@ import { ZapierValidationError, ZapierApiError } from "../../types/errors";
|
|
|
3
3
|
import { listInputFieldChoicesPlugin } from "./index";
|
|
4
4
|
import { createSdk } from "../../sdk";
|
|
5
5
|
import { GetActionSchema } from "../getAction/schemas";
|
|
6
|
+
import { eventEmissionPlugin } from "../eventEmission";
|
|
6
7
|
const mockChoices = [
|
|
7
8
|
{
|
|
8
9
|
key: "general",
|
|
@@ -125,8 +126,10 @@ describe("listInputFieldChoices plugin", () => {
|
|
|
125
126
|
return createSdk({}, {}, {
|
|
126
127
|
api: mockApiClient,
|
|
127
128
|
meta: {},
|
|
129
|
+
options: {},
|
|
128
130
|
getVersionedImplementationId: mockGetVersionedImplementationId,
|
|
129
131
|
})
|
|
132
|
+
.addPlugin(eventEmissionPlugin)
|
|
130
133
|
.addPlugin(mockGetActionPlugin)
|
|
131
134
|
.addPlugin(listInputFieldChoicesPlugin);
|
|
132
135
|
}
|
|
@@ -340,11 +343,11 @@ describe("listInputFieldChoices plugin", () => {
|
|
|
340
343
|
actionKey: "send_message",
|
|
341
344
|
inputFieldKey: "channel",
|
|
342
345
|
});
|
|
343
|
-
expect(mockGetAction).toHaveBeenCalledWith({
|
|
346
|
+
expect(mockGetAction).toHaveBeenCalledWith(expect.objectContaining({
|
|
344
347
|
appKey: "slack",
|
|
345
348
|
actionType: "read",
|
|
346
349
|
actionKey: "send_message",
|
|
347
|
-
});
|
|
350
|
+
}));
|
|
348
351
|
expect(mockApiClient.post).toHaveBeenCalledWith("/zapier/api/v4/implementations/choices/", {
|
|
349
352
|
action_id: "core:123",
|
|
350
353
|
input_field_id: "channel",
|