@zapier/zapier-sdk 0.18.2 → 0.18.4
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 +13 -13
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +0 -18
- package/dist/api/schemas.d.ts +0 -158
- package/dist/api/schemas.d.ts.map +1 -1
- package/dist/api/schemas.js +0 -95
- package/dist/api/types.d.ts +2 -1
- package/dist/api/types.d.ts.map +1 -1
- package/dist/index.cjs +400 -808
- package/dist/index.d.mts +67 -122
- package/dist/index.mjs +401 -809
- package/dist/plugins/findFirstAuthentication/index.test.js +2 -2
- package/dist/plugins/findUniqueAuthentication/index.test.js +2 -2
- package/dist/plugins/listApps/index.d.ts +2 -8
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +4 -6
- package/dist/plugins/listApps/index.test.js +62 -82
- package/dist/plugins/listApps/schemas.d.ts +35 -14
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/schemas.js +44 -14
- 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 +363 -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/App.d.ts +28 -28
- package/dist/schemas/App.d.ts.map +1 -1
- package/dist/schemas/App.js +3 -8
- package/dist/sdk.d.ts +2 -2
- package/dist/sdk.test.js +12 -9
- 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 -2
- package/dist/api/client.integration.test.d.ts +0 -5
- package/dist/api/client.integration.test.d.ts.map +0 -1
- package/dist/api/client.integration.test.js +0 -318
- package/dist/api/client.methods.test.d.ts +0 -2
- package/dist/api/client.methods.test.d.ts.map +0 -1
- package/dist/api/client.methods.test.js +0 -158
- package/dist/api/router.d.ts +0 -16
- package/dist/api/router.d.ts.map +0 -1
- package/dist/api/router.js +0 -31
- package/dist/api/router.test.d.ts +0 -2
- package/dist/api/router.test.d.ts.map +0 -1
- package/dist/api/router.test.js +0 -103
- package/dist/temporary-internal-core/handlers/listApps.d.ts +0 -67
- package/dist/temporary-internal-core/handlers/listApps.d.ts.map +0 -1
- package/dist/temporary-internal-core/handlers/listApps.js +0 -134
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts +0 -2
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +0 -1
- package/dist/temporary-internal-core/handlers/listApps.test.js +0 -367
- package/dist/temporary-internal-core/index.d.ts +0 -18
- package/dist/temporary-internal-core/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/index.js +0 -18
- package/dist/temporary-internal-core/schemas/apps/index.d.ts +0 -175
- package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/schemas/apps/index.js +0 -97
- package/dist/temporary-internal-core/schemas/errors/index.d.ts +0 -139
- package/dist/temporary-internal-core/schemas/errors/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/schemas/errors/index.js +0 -129
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts +0 -127
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/schemas/implementations/index.js +0 -79
- package/dist/temporary-internal-core/types/handler.d.ts +0 -51
- package/dist/temporary-internal-core/types/handler.d.ts.map +0 -1
- package/dist/temporary-internal-core/types/handler.js +0 -8
- package/dist/temporary-internal-core/types/index.d.ts +0 -5
- package/dist/temporary-internal-core/types/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/types/index.js +0 -4
- package/dist/temporary-internal-core/utils/app-locators.d.ts +0 -34
- package/dist/temporary-internal-core/utils/app-locators.d.ts.map +0 -1
- package/dist/temporary-internal-core/utils/app-locators.js +0 -39
- package/dist/temporary-internal-core/utils/string-utils.d.ts +0 -28
- package/dist/temporary-internal-core/utils/string-utils.d.ts.map +0 -1
- package/dist/temporary-internal-core/utils/string-utils.js +0 -52
- package/dist/temporary-internal-core/utils/transformations.d.ts +0 -32
- package/dist/temporary-internal-core/utils/transformations.d.ts.map +0 -1
- package/dist/temporary-internal-core/utils/transformations.js +0 -74
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { PaginatedSdkFunction } from "../../types/functions";
|
|
3
|
-
import type { AuthenticationItem } from "
|
|
3
|
+
import type { AuthenticationItem } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
|
|
4
4
|
import type { ZapierAuthenticationError, ZapierApiError, ZapierAppNotFoundError, ZapierValidationError, ZapierUnknownError } from "../../types/errors";
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const ListAuthenticationsQuerySchema: z.ZodObject<{
|
|
6
|
+
search: z.ZodOptional<z.ZodString>;
|
|
7
|
+
title: z.ZodOptional<z.ZodString>;
|
|
8
|
+
accountId: z.ZodOptional<z.ZodString>;
|
|
9
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
6
10
|
appKey: z.ZodOptional<z.ZodString & {
|
|
7
11
|
_def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
|
|
8
12
|
}>;
|
|
9
13
|
authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
-
search: z.ZodOptional<z.ZodString>;
|
|
11
|
-
title: z.ZodOptional<z.ZodString>;
|
|
12
|
-
accountId: z.ZodOptional<z.ZodString>;
|
|
13
|
-
owner: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"me">]>>;
|
|
14
14
|
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
15
15
|
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
16
16
|
cursor: z.ZodOptional<z.ZodString>;
|
|
@@ -18,7 +18,7 @@ export declare const ListAuthenticationsSchema: z.ZodObject<{
|
|
|
18
18
|
isNested: z.ZodOptional<z.ZodBoolean>;
|
|
19
19
|
}, z.core.$strip>>;
|
|
20
20
|
}, z.core.$strip>;
|
|
21
|
-
export type ListAuthenticationsOptions = z.infer<typeof
|
|
21
|
+
export type ListAuthenticationsOptions = z.infer<typeof ListAuthenticationsQuerySchema>;
|
|
22
22
|
export interface ListAuthenticationsPage {
|
|
23
23
|
data: AuthenticationItem[];
|
|
24
24
|
nextCursor?: string;
|
|
@@ -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,
|
|
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,oDAAoD,CAAC;AAE7F,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;iBA+B0B,CAAC;AAGtE,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,8BAA8B,CACtC,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,37 +1,31 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { AppKeyPropertySchema } from "../../types/properties";
|
|
3
|
+
import { ListAuthenticationsQuerySchema as ListAuthenticationsQueryBase } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
|
|
3
4
|
import { TelemetryMarkerSchema } from "../../utils/function-utils";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export const ListAuthenticationsQuerySchema = ListAuthenticationsQueryBase.omit({
|
|
6
|
+
offset: true,
|
|
7
|
+
})
|
|
8
|
+
.extend({
|
|
9
|
+
// Override appKey with our custom schema (array type, different description)
|
|
7
10
|
appKey: AppKeyPropertySchema.optional().describe("App key of authentications to list (e.g., 'SlackCLIAPI' or slug like 'github')"),
|
|
11
|
+
// Override authenticationIds to be an array instead of comma-separated string
|
|
8
12
|
authenticationIds: z
|
|
9
13
|
.array(z.string())
|
|
10
14
|
.optional()
|
|
11
15
|
.describe("List of authentication IDs to filter by"),
|
|
12
|
-
|
|
13
|
-
.string()
|
|
14
|
-
.optional()
|
|
15
|
-
.describe("Search term to filter authentications by title"),
|
|
16
|
-
title: z
|
|
17
|
-
.string()
|
|
18
|
-
.optional()
|
|
19
|
-
.describe("Filter authentications by exact title match"),
|
|
20
|
-
accountId: z.string().optional().describe("Filter by account ID"),
|
|
21
|
-
owner: z
|
|
22
|
-
.union([z.string(), z.literal("me")])
|
|
23
|
-
.optional()
|
|
24
|
-
.describe("Filter by owner, 'me' for your own authentications or a specific user ID"),
|
|
16
|
+
// Override pageSize to make optional (needs to be fixed in `zapier-sdk-core`)
|
|
25
17
|
pageSize: z
|
|
26
18
|
.number()
|
|
27
19
|
.min(1)
|
|
28
20
|
.optional()
|
|
29
21
|
.describe("Number of authentications per page"),
|
|
22
|
+
// SDK specific property for pagination/iterator helpers
|
|
30
23
|
maxItems: z
|
|
31
24
|
.number()
|
|
32
25
|
.min(1)
|
|
33
26
|
.optional()
|
|
34
27
|
.describe("Maximum total items to return across all pages"),
|
|
28
|
+
// SDK specific property for pagination/iterator helpers
|
|
35
29
|
cursor: z.string().optional().describe("Cursor to start from"),
|
|
36
30
|
})
|
|
37
31
|
.merge(TelemetryMarkerSchema)
|
package/dist/schemas/App.d.ts
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import type { z } from "zod";
|
|
2
2
|
export { FormattedItem, FormatMetadata } from "../utils/schema-utils";
|
|
3
3
|
export declare const AppItemSchema: z.ZodObject<{
|
|
4
|
+
slug: z.ZodString;
|
|
5
|
+
age_in_days: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
auth_type: z.ZodOptional<z.ZodString>;
|
|
7
|
+
banner: z.ZodOptional<z.ZodString>;
|
|
4
8
|
categories: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
5
9
|
id: z.ZodNumber;
|
|
6
10
|
name: z.ZodString;
|
|
7
11
|
slug: z.ZodString;
|
|
8
12
|
}, z.core.$strip>>>;
|
|
9
|
-
actions: z.ZodOptional<z.ZodObject<{
|
|
10
|
-
read: z.ZodOptional<z.ZodNumber>;
|
|
11
|
-
read_bulk: z.ZodOptional<z.ZodNumber>;
|
|
12
|
-
write: z.ZodOptional<z.ZodNumber>;
|
|
13
|
-
search: z.ZodOptional<z.ZodNumber>;
|
|
14
|
-
search_or_write: z.ZodOptional<z.ZodNumber>;
|
|
15
|
-
search_and_write: z.ZodOptional<z.ZodNumber>;
|
|
16
|
-
filter: z.ZodOptional<z.ZodNumber>;
|
|
17
|
-
}, z.core.$strip>>;
|
|
18
|
-
description: z.ZodOptional<z.ZodString>;
|
|
19
|
-
is_hidden: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
-
age_in_days: z.ZodOptional<z.ZodNumber>;
|
|
21
|
-
api_docs_url: z.ZodOptional<z.ZodString>;
|
|
22
|
-
banner: z.ZodOptional<z.ZodString>;
|
|
23
|
-
image: z.ZodOptional<z.ZodString>;
|
|
24
13
|
images: z.ZodOptional<z.ZodObject<{
|
|
25
14
|
url_16x16: z.ZodOptional<z.ZodString>;
|
|
26
15
|
url_32x32: z.ZodOptional<z.ZodString>;
|
|
27
16
|
url_64x64: z.ZodOptional<z.ZodString>;
|
|
28
17
|
url_128x128: z.ZodOptional<z.ZodString>;
|
|
29
18
|
}, z.core.$strip>>;
|
|
30
|
-
is_beta: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
-
is_built_in: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
-
is_featured: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
-
is_premium: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
-
is_public: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
-
is_upcoming: z.ZodOptional<z.ZodBoolean>;
|
|
36
19
|
popularity: z.ZodOptional<z.ZodNumber>;
|
|
37
|
-
primary_color: z.ZodOptional<z.ZodString>;
|
|
38
|
-
slug: z.ZodString;
|
|
39
|
-
auth_type: z.ZodOptional<z.ZodString>;
|
|
40
|
-
is_deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
-
secondary_color: z.ZodOptional<z.ZodString>;
|
|
42
20
|
has_filters: z.ZodOptional<z.ZodBoolean>;
|
|
43
21
|
has_reads: z.ZodOptional<z.ZodBoolean>;
|
|
44
22
|
has_searches: z.ZodOptional<z.ZodBoolean>;
|
|
45
23
|
has_searches_or_writes: z.ZodOptional<z.ZodBoolean>;
|
|
46
24
|
has_upfront_fields: z.ZodOptional<z.ZodBoolean>;
|
|
47
25
|
has_writes: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
+
is_beta: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
is_built_in: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
is_deprecated: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
is_featured: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
is_hidden: z.ZodOptional<z.ZodBoolean>;
|
|
48
31
|
is_invite: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
-
|
|
32
|
+
is_premium: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
is_public: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
is_upcoming: z.ZodOptional<z.ZodBoolean>;
|
|
50
35
|
visibility: z.ZodOptional<z.ZodString>;
|
|
36
|
+
actions: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
read: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
read_bulk: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
write: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
search: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
search_or_write: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
search_and_write: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
filter: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
description: z.ZodOptional<z.ZodString>;
|
|
46
|
+
primary_color: z.ZodOptional<z.ZodString>;
|
|
47
|
+
secondary_color: z.ZodOptional<z.ZodString>;
|
|
51
48
|
classification: z.ZodOptional<z.ZodString>;
|
|
49
|
+
api_docs_url: z.ZodOptional<z.ZodString>;
|
|
50
|
+
image: z.ZodOptional<z.ZodString>;
|
|
52
51
|
title: z.ZodString;
|
|
53
52
|
key: z.ZodString;
|
|
54
53
|
implementation_id: z.ZodString;
|
|
54
|
+
version: z.ZodOptional<z.ZodString>;
|
|
55
55
|
}, z.core.$strip>;
|
|
56
56
|
export type AppItem = z.infer<typeof AppItemSchema>;
|
|
57
57
|
//# sourceMappingURL=App.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/schemas/App.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/schemas/App.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAK7B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMtE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoBxB,CAAC;AAMH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
package/dist/schemas/App.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
1
|
import { withFormatter } from "../utils/schema-utils";
|
|
3
|
-
import {
|
|
2
|
+
import { AppItemSchema as AppItemSchemaBase } from "@zapier/zapier-sdk-core/v0/schemas/apps";
|
|
4
3
|
import { toSnakeCase } from "../utils/string-utils";
|
|
5
4
|
// ============================================================================
|
|
6
|
-
// App Item Schema (
|
|
5
|
+
// App Item Schema (wraps core schema with SDK-specific formatting)
|
|
7
6
|
// ============================================================================
|
|
8
|
-
export const AppItemSchema = withFormatter(
|
|
9
|
-
title: z.string(), // Mapped from name
|
|
10
|
-
key: z.string(), // Extracted from id (base part without version)
|
|
11
|
-
implementation_id: z.string(), // Mapped from id (full versioned ID)
|
|
12
|
-
}), {
|
|
7
|
+
export const AppItemSchema = withFormatter(AppItemSchemaBase, {
|
|
13
8
|
format: (item) => {
|
|
14
9
|
// Create additional keys if slug exists
|
|
15
10
|
const additionalKeys = [];
|
package/dist/sdk.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOption
|
|
|
46
46
|
} & {
|
|
47
47
|
meta: {
|
|
48
48
|
listApps: {
|
|
49
|
-
inputSchema: typeof import("./
|
|
49
|
+
inputSchema: typeof import("./plugins/listApps/schemas").ListAppsSchema;
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
52
|
} & {
|
|
@@ -94,7 +94,7 @@ export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOption
|
|
|
94
94
|
} & {
|
|
95
95
|
meta: {
|
|
96
96
|
listAuthentications: {
|
|
97
|
-
inputSchema: typeof import("./plugins/listAuthentications/schemas").
|
|
97
|
+
inputSchema: typeof import("./plugins/listAuthentications/schemas").ListAuthenticationsQuerySchema;
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
100
|
} & {
|
package/dist/sdk.test.js
CHANGED
|
@@ -162,8 +162,9 @@ describe("Environment Variable Support", () => {
|
|
|
162
162
|
ok: true,
|
|
163
163
|
status: 200,
|
|
164
164
|
json: async () => ({
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
data: [],
|
|
166
|
+
links: { next: null },
|
|
167
|
+
meta: { count: 0, limit: 100, offset: 0 },
|
|
167
168
|
}),
|
|
168
169
|
headers: new Headers(),
|
|
169
170
|
});
|
|
@@ -178,7 +179,7 @@ describe("Environment Variable Support", () => {
|
|
|
178
179
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
179
180
|
const [actualUrl] = mockFetch.mock.calls[0];
|
|
180
181
|
expect(actualUrl).toMatch(new RegExp(`^${customBaseUrl}`));
|
|
181
|
-
expect(actualUrl).toContain("/api/
|
|
182
|
+
expect(actualUrl).toContain("/api/v0/");
|
|
182
183
|
});
|
|
183
184
|
it("should use default base URL when ZAPIER_BASE_URL is not set", async () => {
|
|
184
185
|
// Ensure environment variable is not set
|
|
@@ -191,8 +192,9 @@ describe("Environment Variable Support", () => {
|
|
|
191
192
|
ok: true,
|
|
192
193
|
status: 200,
|
|
193
194
|
json: async () => ({
|
|
194
|
-
|
|
195
|
-
|
|
195
|
+
data: [],
|
|
196
|
+
links: { next: null },
|
|
197
|
+
meta: { count: 0, limit: 100, offset: 0 },
|
|
196
198
|
}),
|
|
197
199
|
headers: new Headers(),
|
|
198
200
|
});
|
|
@@ -207,7 +209,7 @@ describe("Environment Variable Support", () => {
|
|
|
207
209
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
208
210
|
const [actualUrl] = mockFetch.mock.calls[0];
|
|
209
211
|
expect(actualUrl).toMatch(/^https:\/\/sdkapi\.zapier\.com/);
|
|
210
|
-
expect(actualUrl).toContain("/api/
|
|
212
|
+
expect(actualUrl).toContain("/api/v0/");
|
|
211
213
|
});
|
|
212
214
|
it("should use explicit baseUrl option for SDK API requests", async () => {
|
|
213
215
|
// Clear environment variable to ensure we're testing the explicit option
|
|
@@ -221,8 +223,9 @@ describe("Environment Variable Support", () => {
|
|
|
221
223
|
ok: true,
|
|
222
224
|
status: 200,
|
|
223
225
|
json: async () => ({
|
|
224
|
-
|
|
225
|
-
|
|
226
|
+
data: [],
|
|
227
|
+
links: { next: null },
|
|
228
|
+
meta: { count: 0, limit: 100, offset: 0 },
|
|
226
229
|
}),
|
|
227
230
|
headers: new Headers(),
|
|
228
231
|
});
|
|
@@ -238,7 +241,7 @@ describe("Environment Variable Support", () => {
|
|
|
238
241
|
expect(mockFetch).toHaveBeenCalledTimes(1);
|
|
239
242
|
const [actualUrl] = mockFetch.mock.calls[0];
|
|
240
243
|
expect(actualUrl).toMatch(new RegExp(`^${customBaseUrl}`));
|
|
241
|
-
expect(actualUrl).toContain("/api/
|
|
244
|
+
expect(actualUrl).toContain("/api/v0/");
|
|
242
245
|
});
|
|
243
246
|
it("should accept authClientId in SDK options", async () => {
|
|
244
247
|
delete process.env.ZAPIER_BASE_URL;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Domain utility functions for working with app identifiers and data normalization
|
|
3
3
|
*/
|
|
4
|
-
import type { Action,
|
|
5
|
-
import type { ActionItem, AppItem
|
|
4
|
+
import type { Action, ImplementationMeta } from "../api/types";
|
|
5
|
+
import type { ActionItem, AppItem } from "../types/domain";
|
|
6
6
|
/**
|
|
7
7
|
* Splits a versioned key to extract the base key and version
|
|
8
8
|
*
|
|
@@ -21,19 +21,6 @@ export declare function splitVersionedKey(versionedKey: string): [string, string
|
|
|
21
21
|
* @returns Normalized AppItem with essential fields only
|
|
22
22
|
*/
|
|
23
23
|
export declare function normalizeImplementationMetaToAppItem(implementationMeta: ImplementationMeta): AppItem;
|
|
24
|
-
/**
|
|
25
|
-
* Converts an API Authentication to an AuthenticationItem with normalized field names
|
|
26
|
-
*
|
|
27
|
-
* @param auth - Raw Authentication from API
|
|
28
|
-
* @param options - Additional fields to include
|
|
29
|
-
* @param options.app_key - selected_api from implementations endpoint
|
|
30
|
-
* @param options.app_version - Version extracted from selected_api
|
|
31
|
-
* @returns Normalized AuthenticationItem
|
|
32
|
-
*/
|
|
33
|
-
export declare function normalizeAuthenticationItem(auth: Authentication, options?: {
|
|
34
|
-
app_key?: string;
|
|
35
|
-
app_version?: string;
|
|
36
|
-
}): AuthenticationItem;
|
|
37
24
|
export declare function normalizeActionItem(action: Action): ActionItem;
|
|
38
25
|
/**
|
|
39
26
|
* Groups app keys by their type based on format patterns
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-utils.d.ts","sourceRoot":"","sources":["../../src/utils/domain-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"domain-utils.d.ts","sourceRoot":"","sources":["../../src/utils/domain-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,E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rB,UAAU,IAAI,kBAAkB,CAElC;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,kBAAkB,GAAG,MAAM,CAEzE"}
|
|
@@ -37,44 +37,6 @@ export function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
|
37
37
|
version: appVersion,
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Converts an API Authentication to an AuthenticationItem with normalized field names
|
|
42
|
-
*
|
|
43
|
-
* @param auth - Raw Authentication from API
|
|
44
|
-
* @param options - Additional fields to include
|
|
45
|
-
* @param options.app_key - selected_api from implementations endpoint
|
|
46
|
-
* @param options.app_version - Version extracted from selected_api
|
|
47
|
-
* @returns Normalized AuthenticationItem
|
|
48
|
-
*/
|
|
49
|
-
export function normalizeAuthenticationItem(auth, options = {}) {
|
|
50
|
-
// Extract app key and version from selected_api if not provided
|
|
51
|
-
let appKey = options.app_key;
|
|
52
|
-
let appVersion = options.app_version;
|
|
53
|
-
if (auth.selected_api) {
|
|
54
|
-
const [extractedAppKey, extractedVersion] = splitVersionedKey(auth.selected_api);
|
|
55
|
-
// Use extracted app key if not provided in options
|
|
56
|
-
if (!appKey) {
|
|
57
|
-
appKey = extractedAppKey;
|
|
58
|
-
}
|
|
59
|
-
// Use extracted version if not provided in options
|
|
60
|
-
if (!appVersion) {
|
|
61
|
-
appVersion = extractedVersion;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const { selected_api: selectedApi, customuser_id: profileId, id, account_id: accountId, ...restOfAuth } = auth;
|
|
65
|
-
return {
|
|
66
|
-
...restOfAuth, // Pass through all other API response fields except selected_api
|
|
67
|
-
id: String(id), // Convert to string
|
|
68
|
-
account_id: String(accountId), // Convert to string
|
|
69
|
-
implementation_id: selectedApi, // Rename selected_api to implementation_id
|
|
70
|
-
title: auth.title || auth.label || undefined, // Coerce title from label if missing
|
|
71
|
-
is_expired: auth.is_stale, // Map is_stale to is_expired
|
|
72
|
-
expired_at: auth.marked_stale_at, // Map marked_stale_at to expired_at
|
|
73
|
-
app_key: appKey, // App key from implementations endpoint or parsed from selected_api
|
|
74
|
-
app_version: appVersion, // Version from selected_api or provided
|
|
75
|
-
profile_id: profileId != null ? String(profileId) : undefined, // Map customuser_id to profile_id, convert to string
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
40
|
export function normalizeActionItem(action) {
|
|
79
41
|
const { name, type, selected_api: selectedApi } = action;
|
|
80
42
|
// Split version from selected_api
|
|
@@ -30,6 +30,7 @@ export interface TelemetryCallbacks {
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Helper function to extract cursor from pagination data
|
|
33
|
+
* Supports JSON:API style `links.next` URLs by extracting the `offset` parameter.
|
|
33
34
|
*/
|
|
34
35
|
export declare function extractCursor(data: {
|
|
35
36
|
next?: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-utils.d.ts","sourceRoot":"","sources":["../../src/utils/function-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;iBAMhC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE;QACtB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,OAAO,CAAC;KACtB,KAAK,IAAI,CAAC;CACZ;
|
|
1
|
+
{"version":3,"file":"function-utils.d.ts","sourceRoot":"","sources":["../../src/utils/function-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH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OAAO,IAAI,OAAO,SAAS;IAAE,IAAI,EAAE,MAAM,KAAK,CAAA;CAAE,GAC1D,KAAK,SAAS,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,GACpC,KAAK,GACL,KAAK,GACP,OAAO,SAAS,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,GACtC,KAAK,GACL,OAAO,CAAC;AAEd,wBAAgB,uBAAuB,CACrC,QAAQ,EACR,OAAO,EACP,cAAc,SAAS,QAAQ,GAAG,QAAQ,EAE1C,MAAM,EAAE,CAAC,OAAO,EAAE,QAAQ,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,OAAO,CAAC,EACtE,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,EACpC,SAAS,CAAC,EAAE,kBAAkB,EAC9B,oBAAoB,CAAC,EAAE,MAAM,GAC5B,CACD,OAAO,CAAC,EAAE,QAAQ,GAAG;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,KACE,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,GACpC,aAAa,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,GAAG;IACxC,KAAK,IAAI,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;CAC3C,CAgHF"}
|
|
@@ -18,6 +18,7 @@ export const TelemetryMarkerSchema = z.object({
|
|
|
18
18
|
});
|
|
19
19
|
/**
|
|
20
20
|
* Helper function to extract cursor from pagination data
|
|
21
|
+
* Supports JSON:API style `links.next` URLs by extracting the `offset` parameter.
|
|
21
22
|
*/
|
|
22
23
|
export function extractCursor(data) {
|
|
23
24
|
if (!data?.next) {
|
|
@@ -123,10 +124,21 @@ function createPageFunction(coreFn) {
|
|
|
123
124
|
const result = await coreFn(options);
|
|
124
125
|
// If result already has a data property, ensure it's an array
|
|
125
126
|
if (result && typeof result === "object" && "data" in result) {
|
|
126
|
-
const
|
|
127
|
+
const paginatedResult = result;
|
|
128
|
+
// Support both nextCursor and JSON:API links.next format
|
|
129
|
+
let nextCursor;
|
|
130
|
+
if (paginatedResult.nextCursor) {
|
|
131
|
+
nextCursor = paginatedResult.nextCursor;
|
|
132
|
+
}
|
|
133
|
+
else if (paginatedResult.links?.next) {
|
|
134
|
+
// Extract cursor from fully qualified URL (JSON:API spec format)
|
|
135
|
+
nextCursor = extractCursor({ next: paginatedResult.links.next });
|
|
136
|
+
}
|
|
127
137
|
return {
|
|
128
|
-
data: Array.isArray(data)
|
|
129
|
-
|
|
138
|
+
data: Array.isArray(paginatedResult.data)
|
|
139
|
+
? paginatedResult.data
|
|
140
|
+
: [paginatedResult.data],
|
|
141
|
+
nextCursor,
|
|
130
142
|
};
|
|
131
143
|
}
|
|
132
144
|
// If result is an array, wrap in {data: result}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.4",
|
|
4
4
|
"description": "Complete Zapier SDK - combines all Zapier SDK packages",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@zapier/zapier-sdk-core": "^0.5.
|
|
39
|
+
"@zapier/zapier-sdk-core": "^0.5.1",
|
|
40
40
|
"zod": "4.2.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.integration.test.d.ts","sourceRoot":"","sources":["../../src/api/client.integration.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|