@zapier/zapier-sdk 0.5.1 → 0.6.0
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 +19 -0
- package/README.md +107 -83
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/schemas.d.ts +6 -6
- package/dist/api/types.d.ts +7 -7
- package/dist/api/types.d.ts.map +1 -1
- package/dist/index.cjs +343 -67
- package/dist/index.d.mts +416 -347
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.mjs +343 -67
- package/dist/plugins/api/index.js +1 -1
- package/dist/plugins/apps/types.d.ts +1 -1
- package/dist/plugins/apps/types.d.ts.map +1 -1
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findFirstAuthentication/index.js +1 -0
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueAuthentication/index.js +1 -0
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +1 -0
- package/dist/plugins/getAction/index.test.js +1 -1
- package/dist/plugins/getApp/index.d.ts +6 -3
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +8 -18
- package/dist/plugins/getApp/index.test.js +2 -0
- package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/getAuthentication/index.js +1 -0
- package/dist/plugins/getAuthentication/index.test.js +12 -1
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +1 -0
- package/dist/plugins/listActions/index.d.ts +5 -3
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +6 -6
- package/dist/plugins/listActions/index.test.js +26 -74
- package/dist/plugins/listActions/schemas.d.ts +4 -4
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +1 -0
- package/dist/plugins/listApps/schemas.d.ts +2 -2
- package/dist/plugins/listAuthentications/index.d.ts +4 -2
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/index.js +9 -12
- package/dist/plugins/listAuthentications/index.test.js +33 -40
- package/dist/plugins/listAuthentications/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 +5 -5
- package/dist/plugins/listInputFields/index.test.js +10 -8
- package/dist/plugins/listInputFields/schemas.d.ts +4 -4
- package/dist/plugins/lockVersion/index.d.ts +24 -0
- package/dist/plugins/lockVersion/index.d.ts.map +1 -0
- package/dist/plugins/lockVersion/index.js +72 -0
- package/dist/plugins/lockVersion/index.test.d.ts +2 -0
- package/dist/plugins/lockVersion/index.test.d.ts.map +1 -0
- package/dist/plugins/lockVersion/index.test.js +129 -0
- package/dist/plugins/lockVersion/schemas.d.ts +10 -0
- package/dist/plugins/lockVersion/schemas.d.ts.map +1 -0
- package/dist/plugins/lockVersion/schemas.js +6 -0
- package/dist/plugins/manifest/index.d.ts +24 -0
- package/dist/plugins/manifest/index.d.ts.map +1 -0
- package/dist/plugins/manifest/index.js +119 -0
- package/dist/plugins/manifest/index.test.d.ts +2 -0
- package/dist/plugins/manifest/index.test.d.ts.map +1 -0
- package/dist/plugins/manifest/index.test.js +331 -0
- package/dist/plugins/manifest/schemas.d.ts +64 -0
- package/dist/plugins/manifest/schemas.d.ts.map +1 -0
- package/dist/plugins/manifest/schemas.js +25 -0
- package/dist/plugins/registry/index.d.ts +9 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +68 -3
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +1 -0
- package/dist/plugins/request/index.test.js +6 -1
- package/dist/plugins/request/schemas.d.ts +4 -4
- package/dist/plugins/runAction/index.d.ts +2 -0
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +5 -5
- package/dist/plugins/runAction/index.test.js +9 -8
- package/dist/plugins/runAction/schemas.d.ts +4 -4
- package/dist/schemas/Auth.d.ts +4 -4
- package/dist/schemas/Field.d.ts.map +1 -1
- package/dist/sdk.d.ts +3 -3
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +18 -7
- package/dist/sdk.test.js +1 -1
- package/dist/types/errors.d.ts +6 -6
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/events.d.ts +1 -1
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +10 -2
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +13 -2
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/validation.test.js +2 -1
- package/package.json +2 -2
- package/src/api/client.ts +3 -3
- package/src/api/index.ts +2 -0
- package/src/api/types.ts +15 -7
- package/src/index.ts +0 -2
- package/src/plugins/api/index.ts +1 -1
- package/src/plugins/apps/types.ts +1 -1
- package/src/plugins/findFirstAuthentication/index.ts +1 -0
- package/src/plugins/findUniqueAuthentication/index.ts +1 -0
- package/src/plugins/getAction/index.test.ts +1 -1
- package/src/plugins/getAction/index.ts +1 -0
- package/src/plugins/getApp/index.test.ts +2 -0
- package/src/plugins/getApp/index.ts +12 -24
- package/src/plugins/getAuthentication/index.test.ts +13 -3
- package/src/plugins/getAuthentication/index.ts +1 -0
- package/src/plugins/getProfile/index.ts +1 -0
- package/src/plugins/listActions/index.test.ts +30 -89
- package/src/plugins/listActions/index.ts +34 -27
- package/src/plugins/listApps/index.ts +1 -0
- package/src/plugins/listAuthentications/index.test.ts +38 -47
- package/src/plugins/listAuthentications/index.ts +21 -18
- package/src/plugins/listInputFields/index.test.ts +12 -9
- package/src/plugins/listInputFields/index.ts +10 -6
- package/src/plugins/lockVersion/index.test.ts +176 -0
- package/src/plugins/lockVersion/index.ts +112 -0
- package/src/plugins/lockVersion/schemas.ts +9 -0
- package/src/plugins/manifest/index.test.ts +439 -0
- package/src/plugins/manifest/index.ts +171 -0
- package/src/plugins/manifest/schemas.ts +53 -0
- package/src/plugins/registry/index.ts +89 -8
- package/src/plugins/request/index.test.ts +8 -4
- package/src/plugins/request/index.ts +1 -0
- package/src/plugins/runAction/index.test.ts +9 -8
- package/src/plugins/runAction/index.ts +18 -9
- package/src/schemas/Field.ts +5 -2
- package/src/sdk.test.ts +1 -1
- package/src/sdk.ts +22 -7
- package/src/types/errors.ts +9 -6
- package/src/types/events.ts +1 -1
- package/src/types/plugin.ts +14 -2
- package/src/types/sdk.ts +15 -1
- package/src/utils/validation.test.ts +2 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/findFirstAuthentication/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,6BAA6B,EAC7B,KAAK,8BAA8B,EACpC,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAEhF,MAAM,WAAW,qCAAqC;IACpD,uBAAuB,EAAE,CACvB,OAAO,CAAC,EAAE,8BAA8B,KACrC,OAAO,CAAC;QAAE,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IAClD,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,uBAAuB,EAAE;gBACvB,WAAW,EAAE,OAAO,6BAA6B,CAAC;aACnD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAChD,UAAU,CAAC,iCAAiC,CAAC,EAAE,sCAAsC;AACrF,EAAE,EAAE,0BAA0B;AAC9B,qCAAqC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/findFirstAuthentication/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,6BAA6B,EAC7B,KAAK,8BAA8B,EACpC,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAEhF,MAAM,WAAW,qCAAqC;IACpD,uBAAuB,EAAE,CACvB,OAAO,CAAC,EAAE,8BAA8B,KACrC,OAAO,CAAC;QAAE,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IAClD,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,uBAAuB,EAAE;gBACvB,WAAW,EAAE,OAAO,6BAA6B,CAAC;aACnD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAChD,UAAU,CAAC,iCAAiC,CAAC,EAAE,sCAAsC;AACrF,EAAE,EAAE,0BAA0B;AAC9B,qCAAqC,CA8BtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/findUniqueAuthentication/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,8BAA8B,EAC9B,KAAK,+BAA+B,EACrC,MAAM,WAAW,CAAC;AAMnB,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAEhF,MAAM,WAAW,sCAAsC;IACrD,wBAAwB,EAAE,CACxB,OAAO,CAAC,EAAE,+BAA+B,KACtC,OAAO,CAAC;QAAE,IAAI,EAAE,kBAAkB,CAAA;KAAE,CAAC,CAAC;IAC3C,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,wBAAwB,EAAE;gBACxB,WAAW,EAAE,OAAO,8BAA8B,CAAC;aACpD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,8BAA8B,EAAE,MAAM,CACjD,UAAU,CAAC,iCAAiC,CAAC,EAAE,sCAAsC;AACrF,EAAE,EAAE,0BAA0B;AAC9B,sCAAsC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/findUniqueAuthentication/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,8BAA8B,EAC9B,KAAK,+BAA+B,EACrC,MAAM,WAAW,CAAC;AAMnB,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAEhF,MAAM,WAAW,sCAAsC;IACrD,wBAAwB,EAAE,CACxB,OAAO,CAAC,EAAE,+BAA+B,KACtC,OAAO,CAAC;QAAE,IAAI,EAAE,kBAAkB,CAAA;KAAE,CAAC,CAAC;IAC3C,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,wBAAwB,EAAE;gBACxB,WAAW,EAAE,OAAO,8BAA8B,CAAC;aACpD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,8BAA8B,EAAE,MAAM,CACjD,UAAU,CAAC,iCAAiC,CAAC,EAAE,sCAAsC;AACrF,EAAE,EAAE,0BAA0B;AAC9B,sCAAsC,CA2CvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAction/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,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IACxE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,WAAW,EAAE,OAAO,eAAe,CAAC;aACrC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,UAAU,CAAC,yBAAyB,CAAC,EAAE,8BAA8B;AACrE;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAction/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,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IACxE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,WAAW,EAAE,OAAO,eAAe,CAAC;aACrC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,UAAU,CAAC,yBAAyB,CAAC,EAAE,8BAA8B;AACrE;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,uBAAuB,CAmCxB,CAAC"}
|
|
@@ -52,7 +52,7 @@ describe("getAction plugin", () => {
|
|
|
52
52
|
},
|
|
53
53
|
});
|
|
54
54
|
// Build SDK with proper plugin composition, providing API in initial context
|
|
55
|
-
return createSdk({}, { api: mockApiClient, meta: {} })
|
|
55
|
+
return createSdk({}, {}, { api: mockApiClient, meta: {} })
|
|
56
56
|
.addPlugin(mockListActionsPlugin)
|
|
57
57
|
.addPlugin(getActionPlugin);
|
|
58
58
|
}
|
|
@@ -2,8 +2,9 @@ import type { Plugin } from "../../types/plugin";
|
|
|
2
2
|
import { GetAppSchema } from "./schemas";
|
|
3
3
|
import type { GetAppOptions } from "./schemas";
|
|
4
4
|
import type { AppItem } from "../../types/domain";
|
|
5
|
-
import type { ListAppsPluginProvides } from "../listApps";
|
|
6
5
|
import type { GetSdkType } from "../../types/plugin";
|
|
6
|
+
import { GetImplementation } from "../manifest/schemas";
|
|
7
|
+
import { ManifestPluginProvides } from "../manifest";
|
|
7
8
|
export interface GetAppPluginProvides {
|
|
8
9
|
getApp: (options: GetAppOptions) => Promise<{
|
|
9
10
|
data: AppItem;
|
|
@@ -16,7 +17,9 @@ export interface GetAppPluginProvides {
|
|
|
16
17
|
};
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
|
-
export declare const getAppPlugin: Plugin<GetSdkType<
|
|
20
|
-
{
|
|
20
|
+
export declare const getAppPlugin: Plugin<GetSdkType<ManifestPluginProvides>, // depends on manifest plugin with getImplementation in context
|
|
21
|
+
{
|
|
22
|
+
getImplementation: GetImplementation;
|
|
23
|
+
}, //
|
|
21
24
|
GetAppPluginProvides>;
|
|
22
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getApp/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getApp/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGrD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC/D,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,WAAW,EAAE,OAAO,YAAY,CAAC;aAClC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,eAAO,MAAM,YAAY,EAAE,MAAM,CAC/B,UAAU,CAAC,sBAAsB,CAAC,EAAE,+DAA+D;AACnG;IAAE,iBAAiB,EAAE,iBAAiB,CAAA;CAAE,EAAE,EAAE;AAC5C,oBAAoB,CA2BrB,CAAC"}
|
|
@@ -2,27 +2,16 @@ import { createFunction } from "../../utils/function-utils";
|
|
|
2
2
|
import { GetAppSchema } from "./schemas";
|
|
3
3
|
import { ZapierAppNotFoundError } from "../../types/errors";
|
|
4
4
|
// GetApp plugin depends on listApps SDK function
|
|
5
|
-
export const getAppPlugin = ({
|
|
5
|
+
export const getAppPlugin = ({ context }) => {
|
|
6
6
|
const getApp = createFunction(async function getApp(options) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
appKeys: [appKey],
|
|
13
|
-
})
|
|
14
|
-
.items();
|
|
15
|
-
// Get the first (and should be only) result
|
|
16
|
-
const apps = [];
|
|
17
|
-
for await (const app of appsIterator) {
|
|
18
|
-
apps.push(app);
|
|
19
|
-
break; // Only need the first result
|
|
20
|
-
}
|
|
21
|
-
if (apps.length === 0) {
|
|
22
|
-
throw new ZapierAppNotFoundError(appKey);
|
|
7
|
+
const app = await context.getImplementation(options.appKey);
|
|
8
|
+
if (!app) {
|
|
9
|
+
throw new ZapierAppNotFoundError("App not found", {
|
|
10
|
+
appKey: options.appKey,
|
|
11
|
+
});
|
|
23
12
|
}
|
|
24
13
|
return {
|
|
25
|
-
data:
|
|
14
|
+
data: app,
|
|
26
15
|
};
|
|
27
16
|
}, GetAppSchema);
|
|
28
17
|
// Return flat structure - getApp goes directly to SDK
|
|
@@ -31,6 +20,7 @@ export const getAppPlugin = ({ sdk }) => {
|
|
|
31
20
|
context: {
|
|
32
21
|
meta: {
|
|
33
22
|
getApp: {
|
|
23
|
+
categories: ["app"],
|
|
34
24
|
inputSchema: GetAppSchema,
|
|
35
25
|
},
|
|
36
26
|
},
|
|
@@ -4,10 +4,12 @@ import { getAppPlugin } from "./index";
|
|
|
4
4
|
import { createSdk } from "../../sdk";
|
|
5
5
|
import { apiPlugin } from "../api/index";
|
|
6
6
|
import { listAppsPlugin } from "../listApps";
|
|
7
|
+
import { manifestPlugin } from "../manifest";
|
|
7
8
|
function createTestSdk() {
|
|
8
9
|
return createSdk()
|
|
9
10
|
.addPlugin(apiPlugin, { fetch: global.fetch })
|
|
10
11
|
.addPlugin(listAppsPlugin)
|
|
12
|
+
.addPlugin(manifestPlugin)
|
|
11
13
|
.addPlugin(getAppPlugin);
|
|
12
14
|
}
|
|
13
15
|
describe("getApp plugin", () => {
|
|
@@ -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;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,uBAAuB,EACvB,KAAK,wBAAwB,EAC9B,MAAM,WAAW,CAAC;AAQnB,MAAM,WAAW,+BAA+B;IAC9C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC;QAAE,IAAI,EAAE,kBAAkB,CAAA;KAAE,CAAC,CAAC;IAC3C,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,
|
|
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;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,uBAAuB,EACvB,KAAK,wBAAwB,EAC9B,MAAM,WAAW,CAAC;AAQnB,MAAM,WAAW,+BAA+B;IAC9C,iBAAiB,EAAE,CACjB,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC;QAAE,IAAI,EAAE,kBAAkB,CAAA;KAAE,CAAC,CAAC;IAC3C,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,CAuDhC,CAAC"}
|
|
@@ -2,6 +2,8 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
|
2
2
|
import { ZapierValidationError, ZapierAuthenticationError, ZapierResourceNotFoundError, } from "../../types/errors";
|
|
3
3
|
import { getAuthenticationPlugin } from "./index";
|
|
4
4
|
import { createSdk } from "../../sdk";
|
|
5
|
+
import { manifestPlugin } from "../manifest";
|
|
6
|
+
import { listAppsPlugin } from "../listApps";
|
|
5
7
|
const mockAuthenticationResponse = {
|
|
6
8
|
id: 123,
|
|
7
9
|
date: "2021-01-01",
|
|
@@ -23,8 +25,17 @@ describe("getAuthentication plugin", () => {
|
|
|
23
25
|
get: vi.fn().mockResolvedValue(mockAuthenticationResponse),
|
|
24
26
|
};
|
|
25
27
|
});
|
|
28
|
+
const apiPlugin = () => ({
|
|
29
|
+
context: {
|
|
30
|
+
api: mockApiClient,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
26
33
|
function createTestSdk() {
|
|
27
|
-
return createSdk(
|
|
34
|
+
return createSdk()
|
|
35
|
+
.addPlugin(apiPlugin)
|
|
36
|
+
.addPlugin(listAppsPlugin)
|
|
37
|
+
.addPlugin(manifestPlugin)
|
|
38
|
+
.addPlugin(getAuthenticationPlugin);
|
|
28
39
|
}
|
|
29
40
|
describe("schema validation", () => {
|
|
30
41
|
it("should throw validation error for missing authenticationId", async () => {
|
|
@@ -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;AAG7C,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,
|
|
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,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,CA8BzB,CAAC"}
|
|
@@ -2,7 +2,8 @@ import type { Plugin, GetSdkType } from "../../types/plugin";
|
|
|
2
2
|
import type { ApiClient } from "../../api";
|
|
3
3
|
import type { ActionItem } from "../../types/domain";
|
|
4
4
|
import { ListActionsSchema, type ListActionsOptions } from "./schemas";
|
|
5
|
-
import
|
|
5
|
+
import { ManifestPluginProvides } from "../manifest";
|
|
6
|
+
import { GetVersionedImplementationId } from "../manifest/schemas";
|
|
6
7
|
export interface ListActionsPluginProvides {
|
|
7
8
|
listActions: (options?: ListActionsOptions) => Promise<{
|
|
8
9
|
data: ActionItem[];
|
|
@@ -20,9 +21,10 @@ export interface ListActionsPluginProvides {
|
|
|
20
21
|
};
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
export declare const listActionsPlugin: Plugin<GetSdkType<
|
|
24
|
+
export declare const listActionsPlugin: Plugin<GetSdkType<ManifestPluginProvides>, // requires getApp in SDK
|
|
24
25
|
{
|
|
25
26
|
api: ApiClient;
|
|
26
|
-
|
|
27
|
+
getVersionedImplementationId: GetVersionedImplementationId;
|
|
28
|
+
}, // requires api and getVersionedImplementationId in context
|
|
27
29
|
ListActionsPluginProvides>;
|
|
28
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,
|
|
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;AAMnB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAEnE,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,OAAO,CAAC;QACrD,IAAI,EAAE,UAAU,EAAE,CAAC;KACpB,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,EAAE,yBAAyB;AAC7D;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,EAAE,2DAA2D;AAC9D,yBAAyB,CAkF1B,CAAC"}
|
|
@@ -2,19 +2,18 @@ import { normalizeActionItem } from "../../utils/domain-utils";
|
|
|
2
2
|
import { ListActionsSchema, } from "./schemas";
|
|
3
3
|
import { ZapierConfigurationError, ZapierAuthenticationError, } from "../../types/errors";
|
|
4
4
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
5
|
-
export const listActionsPlugin = ({
|
|
5
|
+
export const listActionsPlugin = ({ context }) => {
|
|
6
6
|
const listActions = createPaginatedFunction(async function listActionsPage(options) {
|
|
7
|
-
const { api } = context;
|
|
7
|
+
const { api, getVersionedImplementationId } = context;
|
|
8
8
|
// Use the getApp function from the SDK (dependency injection)
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
if (!implementationId) {
|
|
9
|
+
const selectedApi = await getVersionedImplementationId(options.appKey);
|
|
10
|
+
if (!selectedApi) {
|
|
12
11
|
throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
|
|
13
12
|
}
|
|
14
13
|
const searchParams = {
|
|
15
14
|
global: "true",
|
|
16
15
|
public_only: "true",
|
|
17
|
-
selected_apis:
|
|
16
|
+
selected_apis: selectedApi,
|
|
18
17
|
};
|
|
19
18
|
const data = await api.get("/api/v4/implementations/", {
|
|
20
19
|
searchParams,
|
|
@@ -53,6 +52,7 @@ export const listActionsPlugin = ({ sdk, context }) => {
|
|
|
53
52
|
context: {
|
|
54
53
|
meta: {
|
|
55
54
|
listActions: {
|
|
55
|
+
categories: ["action"],
|
|
56
56
|
inputSchema: ListActionsSchema,
|
|
57
57
|
},
|
|
58
58
|
},
|
|
@@ -2,17 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
|
2
2
|
import { ZapierValidationError, ZapierAuthenticationError, ZapierConfigurationError, } from "../../types/errors";
|
|
3
3
|
import { listActionsPlugin } from "./index";
|
|
4
4
|
import { createSdk } from "../../sdk";
|
|
5
|
-
import {
|
|
6
|
-
const mockAppResponse = {
|
|
7
|
-
data: {
|
|
8
|
-
slug: "slack",
|
|
9
|
-
name: "Slack",
|
|
10
|
-
current_implementation_id: "SlackCLIAPI@1.20.0",
|
|
11
|
-
key: "slack",
|
|
12
|
-
title: "Slack",
|
|
13
|
-
hex_color: "#4A154B",
|
|
14
|
-
},
|
|
15
|
-
};
|
|
5
|
+
import { listAppsPlugin } from "../listApps";
|
|
16
6
|
const mockImplementationsResponse = {
|
|
17
7
|
results: [
|
|
18
8
|
{
|
|
@@ -55,29 +45,35 @@ const mockEmptyImplementationsResponse = {
|
|
|
55
45
|
};
|
|
56
46
|
describe("listActions plugin", () => {
|
|
57
47
|
let mockApiClient;
|
|
58
|
-
let
|
|
48
|
+
let mockGetVersionedImplementationId;
|
|
59
49
|
beforeEach(() => {
|
|
60
50
|
vi.clearAllMocks();
|
|
61
51
|
mockApiClient = {
|
|
62
52
|
get: vi.fn().mockResolvedValue(mockImplementationsResponse),
|
|
63
53
|
};
|
|
64
|
-
|
|
54
|
+
mockGetVersionedImplementationId = vi
|
|
55
|
+
.fn()
|
|
56
|
+
.mockResolvedValue("SlackCLIAPI@1.21.1");
|
|
65
57
|
});
|
|
66
58
|
function createTestSdk() {
|
|
67
59
|
// Create a proper plugin chain with context dependencies
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
// Build SDK with proper plugin composition, providing API in initial context
|
|
61
|
+
return createSdk()
|
|
62
|
+
.addPlugin(() => ({
|
|
70
63
|
context: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
inputSchema: GetAppSchema,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
64
|
+
api: mockApiClient,
|
|
65
|
+
getVersionedImplementationId: mockGetVersionedImplementationId,
|
|
76
66
|
},
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
67
|
+
}))
|
|
68
|
+
.addPlugin(listAppsPlugin)
|
|
69
|
+
.addPlugin(() => ({
|
|
70
|
+
context: {
|
|
71
|
+
manifest: null,
|
|
72
|
+
getManifestEntry: () => null,
|
|
73
|
+
getVersionedImplementationId: mockGetVersionedImplementationId,
|
|
74
|
+
getImplementation: () => Promise.resolve(null),
|
|
75
|
+
},
|
|
76
|
+
}))
|
|
81
77
|
.addPlugin(listActionsPlugin);
|
|
82
78
|
}
|
|
83
79
|
describe("schema validation", () => {
|
|
@@ -332,9 +328,7 @@ describe("listActions plugin", () => {
|
|
|
332
328
|
it("should call getApp to get implementation ID", async () => {
|
|
333
329
|
const sdk = createTestSdk();
|
|
334
330
|
await sdk.listActions({ appKey: "slack" });
|
|
335
|
-
expect(
|
|
336
|
-
appKey: "slack",
|
|
337
|
-
});
|
|
331
|
+
expect(mockGetVersionedImplementationId).toHaveBeenCalledWith("slack");
|
|
338
332
|
});
|
|
339
333
|
it("should pass correct search parameters to implementations API", async () => {
|
|
340
334
|
const sdk = createTestSdk();
|
|
@@ -343,29 +337,19 @@ describe("listActions plugin", () => {
|
|
|
343
337
|
searchParams: expect.objectContaining({
|
|
344
338
|
global: "true",
|
|
345
339
|
public_only: "true",
|
|
346
|
-
selected_apis: "SlackCLIAPI",
|
|
340
|
+
selected_apis: "SlackCLIAPI@1.21.1",
|
|
347
341
|
}),
|
|
348
342
|
}));
|
|
349
343
|
});
|
|
350
344
|
});
|
|
351
345
|
describe("error handling", () => {
|
|
352
346
|
it("should throw ZapierConfigurationError when app has no current_implementation_id", async () => {
|
|
353
|
-
|
|
354
|
-
data: {
|
|
355
|
-
...mockAppResponse.data,
|
|
356
|
-
current_implementation_id: undefined, // Missing implementation ID
|
|
357
|
-
},
|
|
358
|
-
});
|
|
347
|
+
mockGetVersionedImplementationId.mockResolvedValue(null);
|
|
359
348
|
const sdk = createTestSdk();
|
|
360
349
|
await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(ZapierConfigurationError);
|
|
361
350
|
});
|
|
362
351
|
it("should throw ZapierConfigurationError when current_implementation_id is empty", async () => {
|
|
363
|
-
|
|
364
|
-
data: {
|
|
365
|
-
...mockAppResponse.data,
|
|
366
|
-
current_implementation_id: "", // Empty implementation ID
|
|
367
|
-
},
|
|
368
|
-
});
|
|
352
|
+
mockGetVersionedImplementationId.mockResolvedValue("");
|
|
369
353
|
const sdk = createTestSdk();
|
|
370
354
|
await expect(sdk.listActions({ appKey: "slack" })).rejects.toThrow(ZapierConfigurationError);
|
|
371
355
|
});
|
|
@@ -418,44 +402,12 @@ describe("listActions plugin", () => {
|
|
|
418
402
|
const result = await sdk.listActions({ appKey: "slack" });
|
|
419
403
|
expect(result.data).toHaveLength(0);
|
|
420
404
|
});
|
|
421
|
-
it("should propagate
|
|
422
|
-
|
|
405
|
+
it("should propagate getVersionedImplementationId errors", async () => {
|
|
406
|
+
mockGetVersionedImplementationId.mockRejectedValue(new Error("App not found"));
|
|
423
407
|
const sdk = createTestSdk();
|
|
424
408
|
await expect(sdk.listActions({ appKey: "nonexistent" })).rejects.toThrow("App not found");
|
|
425
409
|
});
|
|
426
410
|
});
|
|
427
|
-
describe("implementation ID extraction", () => {
|
|
428
|
-
it("should extract implementation name from versioned ID", async () => {
|
|
429
|
-
mockGetApp.mockResolvedValue({
|
|
430
|
-
data: {
|
|
431
|
-
...mockAppResponse.data,
|
|
432
|
-
current_implementation_id: "CustomAPIName@2.5.0",
|
|
433
|
-
},
|
|
434
|
-
});
|
|
435
|
-
const sdk = createTestSdk();
|
|
436
|
-
await sdk.listActions({ appKey: "slack" });
|
|
437
|
-
expect(mockApiClient.get).toHaveBeenCalledWith("/api/v4/implementations/", expect.objectContaining({
|
|
438
|
-
searchParams: expect.objectContaining({
|
|
439
|
-
selected_apis: "CustomAPIName", // Extracted name without version
|
|
440
|
-
}),
|
|
441
|
-
}));
|
|
442
|
-
});
|
|
443
|
-
it("should handle implementation ID without version", async () => {
|
|
444
|
-
mockGetApp.mockResolvedValue({
|
|
445
|
-
data: {
|
|
446
|
-
...mockAppResponse.data,
|
|
447
|
-
current_implementation_id: "PlainAPIName",
|
|
448
|
-
},
|
|
449
|
-
});
|
|
450
|
-
const sdk = createTestSdk();
|
|
451
|
-
await sdk.listActions({ appKey: "slack" });
|
|
452
|
-
expect(mockApiClient.get).toHaveBeenCalledWith("/api/v4/implementations/", expect.objectContaining({
|
|
453
|
-
searchParams: expect.objectContaining({
|
|
454
|
-
selected_apis: "PlainAPIName", // Used as-is
|
|
455
|
-
}),
|
|
456
|
-
}));
|
|
457
|
-
});
|
|
458
|
-
});
|
|
459
411
|
describe("context and metadata", () => {
|
|
460
412
|
it("should provide context with meta information", () => {
|
|
461
413
|
const sdk = createTestSdk();
|
|
@@ -8,14 +8,14 @@ export declare const ListActionsSchema: z.ZodObject<{
|
|
|
8
8
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
10
|
appKey: string;
|
|
11
|
-
maxItems?: number | undefined;
|
|
12
|
-
pageSize?: number | undefined;
|
|
13
11
|
actionType?: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write" | undefined;
|
|
12
|
+
pageSize?: number | undefined;
|
|
13
|
+
maxItems?: number | undefined;
|
|
14
14
|
}, {
|
|
15
15
|
appKey: string;
|
|
16
|
-
maxItems?: number | undefined;
|
|
17
|
-
pageSize?: number | undefined;
|
|
18
16
|
actionType?: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write" | undefined;
|
|
17
|
+
pageSize?: number | undefined;
|
|
18
|
+
maxItems?: number | undefined;
|
|
19
19
|
}>;
|
|
20
20
|
export type ListActionsOptions = z.infer<typeof ListActionsSchema>;
|
|
21
21
|
export interface ListActionsPage {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AASlD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,GACnE,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;AAGD,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AASlD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,GACnE,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;AAGD,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,sBAAsB,CAyFvB,CAAC"}
|
|
@@ -14,13 +14,13 @@ export declare const ListAppsSchema: z.ZodObject<{
|
|
|
14
14
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
15
15
|
}, "strip", z.ZodTypeAny, {
|
|
16
16
|
search?: string | undefined;
|
|
17
|
-
maxItems?: number | undefined;
|
|
18
17
|
pageSize?: number | undefined;
|
|
18
|
+
maxItems?: number | undefined;
|
|
19
19
|
appKeys?: string[] | undefined;
|
|
20
20
|
}, {
|
|
21
21
|
search?: string | undefined;
|
|
22
|
-
maxItems?: number | undefined;
|
|
23
22
|
pageSize?: number | undefined;
|
|
23
|
+
maxItems?: number | undefined;
|
|
24
24
|
appKeys?: string[] | undefined;
|
|
25
25
|
}>;
|
|
26
26
|
export type ListAppsOptions = z.infer<typeof ListAppsSchema>;
|
|
@@ -2,7 +2,8 @@ import type { Plugin, GetSdkType } from "../../types/plugin";
|
|
|
2
2
|
import type { ApiClient } from "../../api";
|
|
3
3
|
import type { AuthenticationItem } from "../../types/domain";
|
|
4
4
|
import { ListAuthenticationsSchema, type ListAuthenticationsOptions } from "./schemas";
|
|
5
|
-
import
|
|
5
|
+
import { GetVersionedImplementationId } from "../manifest/schemas";
|
|
6
|
+
import { ManifestPluginProvides } from "../manifest";
|
|
6
7
|
export interface ListAuthenticationsPluginProvides {
|
|
7
8
|
listAuthentications: (options?: ListAuthenticationsOptions) => Promise<{
|
|
8
9
|
data: AuthenticationItem[];
|
|
@@ -20,9 +21,10 @@ export interface ListAuthenticationsPluginProvides {
|
|
|
20
21
|
};
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
export declare const listAuthenticationsPlugin: Plugin<GetSdkType<
|
|
24
|
+
export declare const listAuthenticationsPlugin: Plugin<GetSdkType<ManifestPluginProvides>, // requires getApp in SDK
|
|
24
25
|
{
|
|
25
26
|
api: ApiClient;
|
|
27
|
+
getVersionedImplementationId: GetVersionedImplementationId;
|
|
26
28
|
}, // requires api in context
|
|
27
29
|
ListAuthenticationsPluginProvides>;
|
|
28
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;
|
|
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,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,WAAW,iCAAiC;IAChD,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,0BAA0B,KAAK,OAAO,CAAC;QACrE,IAAI,EAAE,kBAAkB,EAAE,CAAC;KAC5B,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,EAAE,yBAAyB;AAC7D;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,EAAE,0BAA0B;AAC7B,iCAAiC,CA+FlC,CAAC"}
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import { ListAuthenticationsSchema, } from "./schemas";
|
|
2
|
-
import { normalizeAuthenticationItem } from "../../utils/domain-utils";
|
|
2
|
+
import { normalizeAuthenticationItem, splitVersionedKey, } from "../../utils/domain-utils";
|
|
3
3
|
import { ZapierAuthenticationError } from "../../types/errors";
|
|
4
4
|
import { createPaginatedFunction, extractCursor, } from "../../utils/function-utils";
|
|
5
|
-
export const listAuthenticationsPlugin = ({
|
|
5
|
+
export const listAuthenticationsPlugin = ({ context }) => {
|
|
6
6
|
const listAuthentications = createPaginatedFunction(async function listAuthenticationsPage(options) {
|
|
7
|
-
const { api } = context;
|
|
7
|
+
const { api, getVersionedImplementationId } = context;
|
|
8
8
|
// Build search parameters
|
|
9
9
|
const searchParams = {};
|
|
10
10
|
// Handle appKey filtering by getting the selected_api first
|
|
11
11
|
if (options.appKey) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (selectedApi) {
|
|
17
|
-
// Use versionless_selected_api to find auths across all app versions
|
|
18
|
-
// Extract the base name without the version (e.g., "SlackCLIAPI" from "SlackCLIAPI@1.21.1")
|
|
19
|
-
const versionlessApi = selectedApi.split("@")[0];
|
|
20
|
-
searchParams.versionless_selected_api = versionlessApi;
|
|
12
|
+
const implementationId = await getVersionedImplementationId(options.appKey);
|
|
13
|
+
if (implementationId) {
|
|
14
|
+
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
15
|
+
searchParams.versionless_selected_api = versionlessSelectedApi;
|
|
21
16
|
}
|
|
22
17
|
}
|
|
23
18
|
// Add other query parameters if provided
|
|
@@ -40,6 +35,7 @@ export const listAuthenticationsPlugin = ({ sdk, context }) => {
|
|
|
40
35
|
// Convert cursor back to offset for the API
|
|
41
36
|
searchParams.offset = options.cursor;
|
|
42
37
|
}
|
|
38
|
+
console.log({ searchParams });
|
|
43
39
|
const data = await api.get("/api/v4/authentications/", {
|
|
44
40
|
searchParams,
|
|
45
41
|
customErrorHandler: ({ status }) => {
|
|
@@ -69,6 +65,7 @@ export const listAuthenticationsPlugin = ({ sdk, context }) => {
|
|
|
69
65
|
context: {
|
|
70
66
|
meta: {
|
|
71
67
|
listAuthentications: {
|
|
68
|
+
categories: ["authentication"],
|
|
72
69
|
inputSchema: ListAuthenticationsSchema,
|
|
73
70
|
},
|
|
74
71
|
},
|