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