@zapier/zapier-sdk 0.33.4 → 0.34.1
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 +36 -36
- package/dist/index.cjs +113 -46
- package/dist/index.d.mts +32 -17
- package/dist/index.mjs +113 -46
- package/dist/plugins/apps/schemas.d.ts +11 -11
- package/dist/plugins/apps/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/schemas.js +3 -1
- package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFields/schemas.js +3 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +1 -0
- package/dist/plugins/runAction/schemas.d.ts.map +1 -1
- package/dist/plugins/runAction/schemas.js +3 -1
- package/dist/types/errors.d.ts +14 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +13 -0
- package/dist/types/functions.d.ts +4 -5
- package/dist/types/functions.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +2 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/pagination-utils.d.ts +8 -2
- package/dist/utils/pagination-utils.d.ts.map +1 -1
- package/dist/utils/pagination-utils.js +101 -44
- package/package.json +2 -2
package/dist/types/errors.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export interface ErrorOptions {
|
|
|
24
24
|
*/
|
|
25
25
|
export declare abstract class ZapierError extends Error {
|
|
26
26
|
abstract readonly name: string;
|
|
27
|
+
abstract readonly code: string;
|
|
27
28
|
statusCode?: number;
|
|
28
29
|
errors?: ApiError[];
|
|
29
30
|
cause?: unknown;
|
|
@@ -35,6 +36,7 @@ export declare abstract class ZapierError extends Error {
|
|
|
35
36
|
*/
|
|
36
37
|
export declare class ZapierApiError extends ZapierError {
|
|
37
38
|
readonly name = "ZapierApiError";
|
|
39
|
+
readonly code: "ZAPIER_API_ERROR";
|
|
38
40
|
constructor(message: string, options?: ErrorOptions);
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
@@ -42,6 +44,7 @@ export declare class ZapierApiError extends ZapierError {
|
|
|
42
44
|
*/
|
|
43
45
|
export declare class ZapierAppNotFoundError extends ZapierError {
|
|
44
46
|
readonly name = "ZapierAppNotFoundError";
|
|
47
|
+
readonly code: "ZAPIER_APP_NOT_FOUND_ERROR";
|
|
45
48
|
appKey?: string;
|
|
46
49
|
constructor(message: string, options?: ErrorOptions & {
|
|
47
50
|
appKey?: string;
|
|
@@ -52,6 +55,7 @@ export declare class ZapierAppNotFoundError extends ZapierError {
|
|
|
52
55
|
*/
|
|
53
56
|
export declare class ZapierValidationError extends ZapierError {
|
|
54
57
|
readonly name = "ZapierValidationError";
|
|
58
|
+
readonly code: "ZAPIER_VALIDATION_ERROR";
|
|
55
59
|
details?: unknown;
|
|
56
60
|
constructor(message: string, options?: ErrorOptions & {
|
|
57
61
|
details?: unknown;
|
|
@@ -62,6 +66,7 @@ export declare class ZapierValidationError extends ZapierError {
|
|
|
62
66
|
*/
|
|
63
67
|
export declare class ZapierUnknownError extends ZapierError {
|
|
64
68
|
readonly name = "ZapierUnknownError";
|
|
69
|
+
readonly code: "ZAPIER_UNKNOWN_ERROR";
|
|
65
70
|
constructor(message: string, options?: ErrorOptions);
|
|
66
71
|
}
|
|
67
72
|
/**
|
|
@@ -69,6 +74,7 @@ export declare class ZapierUnknownError extends ZapierError {
|
|
|
69
74
|
*/
|
|
70
75
|
export declare class ZapierAuthenticationError extends ZapierError {
|
|
71
76
|
readonly name = "ZapierAuthenticationError";
|
|
77
|
+
readonly code: "ZAPIER_AUTHENTICATION_ERROR";
|
|
72
78
|
constructor(message: string, options?: ErrorOptions);
|
|
73
79
|
}
|
|
74
80
|
/**
|
|
@@ -76,6 +82,7 @@ export declare class ZapierAuthenticationError extends ZapierError {
|
|
|
76
82
|
*/
|
|
77
83
|
export declare class ZapierResourceNotFoundError extends ZapierError {
|
|
78
84
|
readonly name = "ZapierResourceNotFoundError";
|
|
85
|
+
readonly code: "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
|
|
79
86
|
resourceType?: string;
|
|
80
87
|
resourceId?: string;
|
|
81
88
|
constructor(message: string, options?: ErrorOptions & {
|
|
@@ -88,6 +95,7 @@ export declare class ZapierResourceNotFoundError extends ZapierError {
|
|
|
88
95
|
*/
|
|
89
96
|
export declare class ZapierConfigurationError extends ZapierError {
|
|
90
97
|
readonly name = "ZapierConfigurationError";
|
|
98
|
+
readonly code: "ZAPIER_CONFIGURATION_ERROR";
|
|
91
99
|
configType?: string;
|
|
92
100
|
constructor(message: string, options?: ErrorOptions & {
|
|
93
101
|
configType?: string;
|
|
@@ -98,6 +106,7 @@ export declare class ZapierConfigurationError extends ZapierError {
|
|
|
98
106
|
*/
|
|
99
107
|
export declare class ZapierBundleError extends ZapierError {
|
|
100
108
|
readonly name = "ZapierBundleError";
|
|
109
|
+
readonly code: "ZAPIER_BUNDLE_ERROR";
|
|
101
110
|
buildErrors?: string[];
|
|
102
111
|
constructor(message: string, options?: ErrorOptions & {
|
|
103
112
|
buildErrors?: string[];
|
|
@@ -108,6 +117,7 @@ export declare class ZapierBundleError extends ZapierError {
|
|
|
108
117
|
*/
|
|
109
118
|
export declare class ZapierTimeoutError extends ZapierError {
|
|
110
119
|
readonly name = "ZapierTimeoutError";
|
|
120
|
+
readonly code: "ZAPIER_TIMEOUT_ERROR";
|
|
111
121
|
attempts?: number;
|
|
112
122
|
maxAttempts?: number;
|
|
113
123
|
constructor(message: string, options?: ErrorOptions & {
|
|
@@ -121,6 +131,7 @@ export declare class ZapierTimeoutError extends ZapierError {
|
|
|
121
131
|
*/
|
|
122
132
|
export declare class ZapierActionError extends ZapierError {
|
|
123
133
|
readonly name = "ZapierActionError";
|
|
134
|
+
readonly code: "ZAPIER_ACTION_ERROR";
|
|
124
135
|
appKey?: string;
|
|
125
136
|
actionKey?: string;
|
|
126
137
|
constructor(message: string, options?: ErrorOptions & {
|
|
@@ -134,6 +145,7 @@ export declare class ZapierActionError extends ZapierError {
|
|
|
134
145
|
*/
|
|
135
146
|
export declare class ZapierNotFoundError extends ZapierError {
|
|
136
147
|
readonly name = "ZapierNotFoundError";
|
|
148
|
+
readonly code: "ZAPIER_NOT_FOUND_ERROR";
|
|
137
149
|
constructor(message: string, options?: ErrorOptions);
|
|
138
150
|
}
|
|
139
151
|
/**
|
|
@@ -154,6 +166,7 @@ export interface RateLimitInfo {
|
|
|
154
166
|
*/
|
|
155
167
|
export declare class ZapierRateLimitError extends ZapierError {
|
|
156
168
|
readonly name = "ZapierRateLimitError";
|
|
169
|
+
readonly code: "ZAPIER_RATE_LIMIT_ERROR";
|
|
157
170
|
rateLimit: RateLimitInfo;
|
|
158
171
|
retries: number;
|
|
159
172
|
constructor(message: string, options?: ErrorOptions & {
|
|
@@ -167,6 +180,7 @@ export declare class ZapierRateLimitError extends ZapierError {
|
|
|
167
180
|
*/
|
|
168
181
|
export declare class ZapierRelayError extends ZapierError {
|
|
169
182
|
readonly name = "ZapierRelayError";
|
|
183
|
+
readonly code: "ZAPIER_RELAY_ERROR";
|
|
170
184
|
constructor(message: string, options?: ErrorOptions);
|
|
171
185
|
}
|
|
172
186
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;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AM,EAAE,OAAO,GAAE,YAAiB;CAGxD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CA8D7D"}
|
package/dist/types/errors.js
CHANGED
|
@@ -20,6 +20,7 @@ export class ZapierApiError extends ZapierError {
|
|
|
20
20
|
constructor(message, options = {}) {
|
|
21
21
|
super(message, options);
|
|
22
22
|
this.name = "ZapierApiError";
|
|
23
|
+
this.code = "ZAPIER_API_ERROR";
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
@@ -29,6 +30,7 @@ export class ZapierAppNotFoundError extends ZapierError {
|
|
|
29
30
|
constructor(message, options = {}) {
|
|
30
31
|
super(message, options);
|
|
31
32
|
this.name = "ZapierAppNotFoundError";
|
|
33
|
+
this.code = "ZAPIER_APP_NOT_FOUND_ERROR";
|
|
32
34
|
this.appKey = options.appKey;
|
|
33
35
|
}
|
|
34
36
|
}
|
|
@@ -39,6 +41,7 @@ export class ZapierValidationError extends ZapierError {
|
|
|
39
41
|
constructor(message, options = {}) {
|
|
40
42
|
super(message, options);
|
|
41
43
|
this.name = "ZapierValidationError";
|
|
44
|
+
this.code = "ZAPIER_VALIDATION_ERROR";
|
|
42
45
|
this.details = options.details;
|
|
43
46
|
}
|
|
44
47
|
}
|
|
@@ -49,6 +52,7 @@ export class ZapierUnknownError extends ZapierError {
|
|
|
49
52
|
constructor(message, options = {}) {
|
|
50
53
|
super(message, options);
|
|
51
54
|
this.name = "ZapierUnknownError";
|
|
55
|
+
this.code = "ZAPIER_UNKNOWN_ERROR";
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
58
|
/**
|
|
@@ -58,6 +62,7 @@ export class ZapierAuthenticationError extends ZapierError {
|
|
|
58
62
|
constructor(message, options = {}) {
|
|
59
63
|
super(message, options);
|
|
60
64
|
this.name = "ZapierAuthenticationError";
|
|
65
|
+
this.code = "ZAPIER_AUTHENTICATION_ERROR";
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
68
|
/**
|
|
@@ -67,6 +72,7 @@ export class ZapierResourceNotFoundError extends ZapierError {
|
|
|
67
72
|
constructor(message, options = {}) {
|
|
68
73
|
super(message, options);
|
|
69
74
|
this.name = "ZapierResourceNotFoundError";
|
|
75
|
+
this.code = "ZAPIER_RESOURCE_NOT_FOUND_ERROR";
|
|
70
76
|
this.resourceType = options.resourceType;
|
|
71
77
|
this.resourceId = options.resourceId;
|
|
72
78
|
}
|
|
@@ -78,6 +84,7 @@ export class ZapierConfigurationError extends ZapierError {
|
|
|
78
84
|
constructor(message, options = {}) {
|
|
79
85
|
super(message, options);
|
|
80
86
|
this.name = "ZapierConfigurationError";
|
|
87
|
+
this.code = "ZAPIER_CONFIGURATION_ERROR";
|
|
81
88
|
this.configType = options.configType;
|
|
82
89
|
}
|
|
83
90
|
}
|
|
@@ -88,6 +95,7 @@ export class ZapierBundleError extends ZapierError {
|
|
|
88
95
|
constructor(message, options = {}) {
|
|
89
96
|
super(message, options);
|
|
90
97
|
this.name = "ZapierBundleError";
|
|
98
|
+
this.code = "ZAPIER_BUNDLE_ERROR";
|
|
91
99
|
this.buildErrors = options.buildErrors;
|
|
92
100
|
}
|
|
93
101
|
}
|
|
@@ -98,6 +106,7 @@ export class ZapierTimeoutError extends ZapierError {
|
|
|
98
106
|
constructor(message, options = {}) {
|
|
99
107
|
super(message, options);
|
|
100
108
|
this.name = "ZapierTimeoutError";
|
|
109
|
+
this.code = "ZAPIER_TIMEOUT_ERROR";
|
|
101
110
|
this.attempts = options.attempts;
|
|
102
111
|
this.maxAttempts = options.maxAttempts;
|
|
103
112
|
}
|
|
@@ -110,6 +119,7 @@ export class ZapierActionError extends ZapierError {
|
|
|
110
119
|
constructor(message, options = {}) {
|
|
111
120
|
super(message, options);
|
|
112
121
|
this.name = "ZapierActionError";
|
|
122
|
+
this.code = "ZAPIER_ACTION_ERROR";
|
|
113
123
|
this.appKey = options.appKey;
|
|
114
124
|
this.actionKey = options.actionKey;
|
|
115
125
|
}
|
|
@@ -125,6 +135,7 @@ export class ZapierNotFoundError extends ZapierError {
|
|
|
125
135
|
constructor(message, options = {}) {
|
|
126
136
|
super(message, options);
|
|
127
137
|
this.name = "ZapierNotFoundError";
|
|
138
|
+
this.code = "ZAPIER_NOT_FOUND_ERROR";
|
|
128
139
|
}
|
|
129
140
|
}
|
|
130
141
|
/**
|
|
@@ -134,6 +145,7 @@ export class ZapierRateLimitError extends ZapierError {
|
|
|
134
145
|
constructor(message, options = {}) {
|
|
135
146
|
super(message, options);
|
|
136
147
|
this.name = "ZapierRateLimitError";
|
|
148
|
+
this.code = "ZAPIER_RATE_LIMIT_ERROR";
|
|
137
149
|
this.rateLimit = options.rateLimit ?? {};
|
|
138
150
|
this.retries = options.retries ?? 0;
|
|
139
151
|
}
|
|
@@ -146,6 +158,7 @@ export class ZapierRelayError extends ZapierError {
|
|
|
146
158
|
constructor(message, options = {}) {
|
|
147
159
|
super(message, options);
|
|
148
160
|
this.name = "ZapierRelayError";
|
|
161
|
+
this.code = "ZAPIER_RELAY_ERROR";
|
|
149
162
|
}
|
|
150
163
|
}
|
|
151
164
|
/**
|
|
@@ -16,12 +16,11 @@ export interface FunctionOptions {
|
|
|
16
16
|
/** Custom fetch implementation */
|
|
17
17
|
fetch?: typeof globalThis.fetch;
|
|
18
18
|
}
|
|
19
|
-
export
|
|
20
|
-
data:
|
|
21
|
-
}> & AsyncIterable<{
|
|
22
|
-
data: TItem[];
|
|
19
|
+
export interface SdkPage<T = unknown> {
|
|
20
|
+
data: T[];
|
|
23
21
|
nextCursor?: string;
|
|
24
|
-
}
|
|
22
|
+
}
|
|
23
|
+
export type PaginatedSdkFunction<TOptions, TItem> = (options: TOptions) => Promise<SdkPage<TItem>> & AsyncIterable<SdkPage<TItem>> & {
|
|
25
24
|
items(): AsyncIterable<TItem>;
|
|
26
25
|
};
|
|
27
26
|
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/types/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C;;GAEG;AAGH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,2CAA2C;IAC3C,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kCAAkC;IAClC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAGD,MAAM,MAAM,oBAAoB,CAAC,QAAQ,EAAE,KAAK,IAAI,CAClD,OAAO,EAAE,QAAQ,KACd,OAAO,CAAC
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/types/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C;;GAEG;AAGH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,2CAA2C;IAC3C,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kCAAkC;IAClC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,OAAO;IAClC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,MAAM,oBAAoB,CAAC,QAAQ,EAAE,KAAK,IAAI,CAClD,OAAO,EAAE,QAAQ,KACd,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAC1B,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG;IAC9B,KAAK,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;CAC/B,CAAC"}
|
package/dist/types/sdk.d.ts
CHANGED
|
@@ -126,6 +126,8 @@ export interface FunctionRegistryEntry {
|
|
|
126
126
|
deprecatedParameters?: string[];
|
|
127
127
|
/** Short flag aliases for CLI options (e.g., { request: "X", header: "H" }) */
|
|
128
128
|
aliases?: Record<string, string>;
|
|
129
|
+
/** Defaults to true. Set to false to suppress --json (e.g. login/logout/init). */
|
|
130
|
+
supportsJsonOutput: boolean;
|
|
129
131
|
}
|
|
130
132
|
export interface FunctionDeprecation {
|
|
131
133
|
/** User-facing deprecation message for why/how to migrate */
|
package/dist/types/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/types/sdk.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAIpD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuD/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAGlE,OAAO,KAAK,EAAE,0BAA0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jB;AAGD,MAAM,WAAW,kBACf,SAAQ,0BAA0B,EAChC,wBAAwB,EACxB,8BAA8B,EAC9B,+BAA+B,EAC/B,uBAAuB;CAE1B;AAUD,MAAM,WAAW,SACf,SAAQ,UAAU,CAChB,sBAAsB,GACpB,mBAAmB,GACnB,kBAAkB,GAClB,sBAAsB,GACtB,sBAAsB,GACtB,oBAAoB,GACpB,yBAAyB,GACzB,uBAAuB,GACvB,uBAAuB,GAEvB,6BAA6B,GAC7B,2BAA2B,GAC3B,iCAAiC,GACjC,kCAAkC,GAElC,iCAAiC,GACjC,+BAA+B,GAC/B,qCAAqC,GACrC,sCAAsC,GACtC,mCAAmC,GACnC,qCAAqC,GACrC,qCAAqC,GACrC,6BAA6B,GAC7B,kCAAkC,GAClC,mCAAmC,GACnC,qBAAqB,GACrB,wBAAwB,GACxB,qBAAqB,GACrB,iBAAiB,CACpB;IAED,IAAI,EAAE,WAAW,GAAG,aAAa,CAAC;CACnC"}
|
|
@@ -7,14 +7,20 @@ type TPageOptions<TOptions> = TOptions extends undefined ? {
|
|
|
7
7
|
maxItems?: number;
|
|
8
8
|
pageSize?: number;
|
|
9
9
|
};
|
|
10
|
+
export declare function decodeIncomingCursor(incoming?: string): {
|
|
11
|
+
offset: number;
|
|
12
|
+
cursor: string | undefined;
|
|
13
|
+
};
|
|
10
14
|
export declare function createPrefixedCursor(prefix: string, cursor: string | undefined): string;
|
|
11
15
|
export declare function splitPrefixedCursor(cursor: string | undefined, prefixes?: string[]): [string | undefined, string | undefined];
|
|
12
16
|
/**
|
|
13
|
-
* Utility for paginating through API endpoints that return cursor-based pages
|
|
17
|
+
* Utility for paginating through API endpoints that return cursor-based pages.
|
|
18
|
+
* Accepts and yields SDK-encoded cursor envelopes. Any incoming cursor is decoded
|
|
19
|
+
* before being passed to the page function; all outgoing cursors are encoded.
|
|
14
20
|
*
|
|
15
21
|
* @param pageFunction - Function that fetches a single page with {data, nextCursor} structure
|
|
16
22
|
* @param pageOptions - Options to pass to the page function (cursor will be managed automatically)
|
|
17
|
-
* @returns Async iterator that yields pages
|
|
23
|
+
* @returns Async iterator that yields pages with encoded cursors
|
|
18
24
|
*/
|
|
19
25
|
export declare function paginateMaxItems<TOptions, TPage extends {
|
|
20
26
|
data: any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination-utils.d.ts","sourceRoot":"","sources":["../../src/utils/pagination-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pagination-utils.d.ts","sourceRoot":"","sources":["../../src/utils/pagination-utils.ts"],"names":[],"mappings":"AAsBA,KAAK,YAAY,CAAC,QAAQ,IAAI,QAAQ,SAAS,SAAS,GACpD;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GACzD,QAAQ,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAmCzE,wBAAgB,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAyBA;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,CAKR;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,QAAQ,CAAC,EAAE,MAAM,EAAE,GAClB,CAAC,MAAM,GAAG,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,CAkB1C;AAuDD;;;;;;;;GAQG;AACH,wBAAuB,gBAAgB,CACrC,QAAQ,EACR,KAAK,SAAS;IAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,EAElD,YAAY,EAAE,CACZ,OAAO,EAAE,QAAQ,GAAG;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,KACE,OAAO,CAAC,KAAK,CAAC,EACnB,WAAW,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,GACnC,qBAAqB,CAAC,KAAK,CAAC,CAkB9B;AAED,wBAAuB,gBAAgB,CACrC,QAAQ,EACR,KAAK,SAAS;IAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,EAElD,YAAY,EAAE,CACZ,OAAO,EAAE,QAAQ,GAAG;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,KACE,OAAO,CAAC,KAAK,CAAC,EACnB,WAAW,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,GACnC,qBAAqB,CAAC,KAAK,CAAC,CA2H9B;AAED,eAAO,MAAM,QAAQ,yBAAmB,CAAC"}
|
|
@@ -1,29 +1,53 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const CURSOR_VERSION = 1;
|
|
2
|
+
const CURSOR_SOURCE = {
|
|
3
|
+
API: "api",
|
|
4
|
+
SDK: "sdk",
|
|
5
|
+
};
|
|
6
|
+
function encodeBase64(str) {
|
|
7
|
+
return btoa(Array.from(new TextEncoder().encode(str), (b) => String.fromCharCode(b)).join(""));
|
|
8
|
+
}
|
|
9
|
+
function decodeBase64(str) {
|
|
10
|
+
return new TextDecoder().decode(Uint8Array.from(atob(str), (c) => c.charCodeAt(0)));
|
|
11
|
+
}
|
|
12
|
+
function encodeApiCursor(cursor) {
|
|
13
|
+
const envelope = {
|
|
14
|
+
v: CURSOR_VERSION,
|
|
15
|
+
source: CURSOR_SOURCE.API,
|
|
16
|
+
cursor,
|
|
17
|
+
};
|
|
18
|
+
return encodeBase64(JSON.stringify(envelope));
|
|
19
|
+
}
|
|
20
|
+
function encodeSdkCursor(offset, cursor) {
|
|
21
|
+
const envelope = {
|
|
22
|
+
v: CURSOR_VERSION,
|
|
23
|
+
source: CURSOR_SOURCE.SDK,
|
|
24
|
+
cursor,
|
|
25
|
+
offset,
|
|
26
|
+
};
|
|
27
|
+
return encodeBase64(JSON.stringify(envelope));
|
|
28
|
+
}
|
|
29
|
+
export function decodeIncomingCursor(incoming) {
|
|
30
|
+
if (!incoming) {
|
|
31
|
+
return { offset: 0, cursor: undefined };
|
|
5
32
|
}
|
|
6
33
|
try {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
34
|
+
const decoded = decodeBase64(incoming);
|
|
35
|
+
const envelope = JSON.parse(decoded);
|
|
36
|
+
if (envelope.v !== CURSOR_VERSION) {
|
|
37
|
+
return { offset: 0, cursor: incoming };
|
|
10
38
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return [0, cursor];
|
|
39
|
+
if (envelope.source === CURSOR_SOURCE.SDK) {
|
|
40
|
+
return { offset: envelope.offset ?? 0, cursor: envelope.cursor };
|
|
14
41
|
}
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
42
|
+
if (envelope.source === CURSOR_SOURCE.API) {
|
|
43
|
+
return { offset: 0, cursor: envelope.cursor };
|
|
17
44
|
}
|
|
18
|
-
return
|
|
45
|
+
return { offset: 0, cursor: incoming };
|
|
19
46
|
}
|
|
20
47
|
catch {
|
|
21
|
-
return
|
|
48
|
+
return { offset: 0, cursor: incoming };
|
|
22
49
|
}
|
|
23
50
|
}
|
|
24
|
-
function createOffsetCursor(offset, currentCursor) {
|
|
25
|
-
return JSON.stringify([offsetCursorMarker, offset, currentCursor]);
|
|
26
|
-
}
|
|
27
51
|
export function createPrefixedCursor(prefix, cursor) {
|
|
28
52
|
if (!cursor) {
|
|
29
53
|
return `${prefix}::`;
|
|
@@ -45,13 +69,10 @@ export function splitPrefixedCursor(cursor, prefixes) {
|
|
|
45
69
|
return [prefix, cursor];
|
|
46
70
|
}
|
|
47
71
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @param pageFunction - Function that fetches a single page with {data, nextCursor} structure
|
|
51
|
-
* @param pageOptions - Options to pass to the page function (cursor will be managed automatically)
|
|
52
|
-
* @returns Async iterator that yields pages
|
|
72
|
+
* Internal primitive: paginates through a page function using raw (unencoded) cursors.
|
|
73
|
+
* Encoding and decoding of cursors is the responsibility of the public wrappers.
|
|
53
74
|
*/
|
|
54
|
-
|
|
75
|
+
async function* paginateMaxItemsWithUnencodedCursor(pageFunction, pageOptions) {
|
|
55
76
|
let cursor = pageOptions?.cursor;
|
|
56
77
|
let totalItemsYielded = 0;
|
|
57
78
|
const maxItems = pageOptions?.maxItems;
|
|
@@ -68,12 +89,11 @@ export async function* paginateMaxItems(pageFunction, pageOptions) {
|
|
|
68
89
|
if (maxItems !== undefined) {
|
|
69
90
|
const remainingItems = maxItems - totalItemsYielded;
|
|
70
91
|
if (page.data.length >= remainingItems) {
|
|
71
|
-
|
|
92
|
+
yield {
|
|
72
93
|
...page,
|
|
73
94
|
data: page.data.slice(0, remainingItems),
|
|
74
95
|
nextCursor: undefined,
|
|
75
96
|
};
|
|
76
|
-
yield yieldedPage;
|
|
77
97
|
break;
|
|
78
98
|
}
|
|
79
99
|
}
|
|
@@ -82,18 +102,60 @@ export async function* paginateMaxItems(pageFunction, pageOptions) {
|
|
|
82
102
|
cursor = page.nextCursor;
|
|
83
103
|
} while (cursor);
|
|
84
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Utility for paginating through API endpoints that return cursor-based pages.
|
|
107
|
+
* Accepts and yields SDK-encoded cursor envelopes. Any incoming cursor is decoded
|
|
108
|
+
* before being passed to the page function; all outgoing cursors are encoded.
|
|
109
|
+
*
|
|
110
|
+
* @param pageFunction - Function that fetches a single page with {data, nextCursor} structure
|
|
111
|
+
* @param pageOptions - Options to pass to the page function (cursor will be managed automatically)
|
|
112
|
+
* @returns Async iterator that yields pages with encoded cursors
|
|
113
|
+
*/
|
|
114
|
+
export async function* paginateMaxItems(pageFunction, pageOptions) {
|
|
115
|
+
const { cursor } = decodeIncomingCursor(pageOptions?.cursor);
|
|
116
|
+
const options = {
|
|
117
|
+
...(pageOptions || {}),
|
|
118
|
+
cursor,
|
|
119
|
+
};
|
|
120
|
+
for await (const page of paginateMaxItemsWithUnencodedCursor(pageFunction, options)) {
|
|
121
|
+
yield {
|
|
122
|
+
...page,
|
|
123
|
+
nextCursor: page.nextCursor
|
|
124
|
+
? encodeApiCursor(page.nextCursor)
|
|
125
|
+
: undefined,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
85
129
|
export async function* paginateBuffered(pageFunction, pageOptions) {
|
|
86
130
|
const pageSize = pageOptions?.pageSize;
|
|
87
|
-
const
|
|
131
|
+
const { offset: cursorOffset, cursor: initialCursor } = decodeIncomingCursor(pageOptions?.cursor);
|
|
132
|
+
const requestedMaxItems = pageOptions?.maxItems;
|
|
88
133
|
const options = {
|
|
89
134
|
...(pageOptions || {}),
|
|
90
|
-
cursor:
|
|
135
|
+
cursor: initialCursor,
|
|
136
|
+
// SDK cursors can carry an offset into a raw backend page. Since maxItems
|
|
137
|
+
// is expected to be relative to the resumed position, we add that offset
|
|
138
|
+
// so raw pagination still yields enough items after offset slicing.
|
|
139
|
+
maxItems: requestedMaxItems !== undefined && cursorOffset > 0
|
|
140
|
+
? requestedMaxItems + cursorOffset
|
|
141
|
+
: requestedMaxItems,
|
|
91
142
|
};
|
|
92
|
-
|
|
143
|
+
if (!pageSize) {
|
|
144
|
+
for await (const page of paginateMaxItemsWithUnencodedCursor(pageFunction, options)) {
|
|
145
|
+
yield {
|
|
146
|
+
...page,
|
|
147
|
+
nextCursor: page.nextCursor
|
|
148
|
+
? encodeApiCursor(page.nextCursor)
|
|
149
|
+
: undefined,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
93
154
|
let bufferedPages = [];
|
|
94
155
|
let isFirstPage = true;
|
|
95
|
-
let
|
|
96
|
-
for await (let page of
|
|
156
|
+
let rawCursor;
|
|
157
|
+
for await (let page of paginateMaxItemsWithUnencodedCursor(pageFunction, options)) {
|
|
158
|
+
const nextRawCursor = page.nextCursor;
|
|
97
159
|
if (isFirstPage) {
|
|
98
160
|
isFirstPage = false;
|
|
99
161
|
if (cursorOffset) {
|
|
@@ -103,16 +165,11 @@ export async function* paginateBuffered(pageFunction, pageOptions) {
|
|
|
103
165
|
};
|
|
104
166
|
}
|
|
105
167
|
}
|
|
106
|
-
|
|
107
|
-
yield page;
|
|
108
|
-
cursor = page.nextCursor;
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
const bufferedLength = bufferedPages.reduce((acc, page) => acc + page.data.length, 0);
|
|
168
|
+
const bufferedLength = bufferedPages.reduce((acc, p) => acc + p.data.length, 0);
|
|
112
169
|
// If we don't have enough to fill a page, buffer this page.
|
|
113
170
|
if (bufferedLength + page.data.length < pageSize) {
|
|
114
171
|
bufferedPages.push(page);
|
|
115
|
-
|
|
172
|
+
rawCursor = nextRawCursor;
|
|
116
173
|
continue;
|
|
117
174
|
}
|
|
118
175
|
// Let's yield a page from our buffered pages.
|
|
@@ -125,24 +182,24 @@ export async function* paginateBuffered(pageFunction, pageOptions) {
|
|
|
125
182
|
yield {
|
|
126
183
|
...page,
|
|
127
184
|
data: pageItems,
|
|
128
|
-
nextCursor:
|
|
185
|
+
nextCursor: nextRawCursor ? encodeApiCursor(nextRawCursor) : undefined,
|
|
129
186
|
};
|
|
130
187
|
bufferedPages = [];
|
|
131
|
-
|
|
188
|
+
rawCursor = nextRawCursor;
|
|
132
189
|
continue;
|
|
133
190
|
}
|
|
134
191
|
// Yield our items with a cursor to offset into this page.
|
|
135
192
|
yield {
|
|
136
193
|
...page,
|
|
137
194
|
data: pageItems,
|
|
138
|
-
nextCursor:
|
|
195
|
+
nextCursor: encodeSdkCursor(page.data.length - remainingItems.length, rawCursor),
|
|
139
196
|
};
|
|
140
197
|
while (remainingItems.length > pageSize) {
|
|
141
|
-
const
|
|
198
|
+
const chunkItems = remainingItems.splice(0, pageSize);
|
|
142
199
|
yield {
|
|
143
200
|
...page,
|
|
144
|
-
data:
|
|
145
|
-
nextCursor:
|
|
201
|
+
data: chunkItems,
|
|
202
|
+
nextCursor: encodeSdkCursor(page.data.length - remainingItems.length, rawCursor),
|
|
146
203
|
};
|
|
147
204
|
}
|
|
148
205
|
bufferedPages = [
|
|
@@ -151,7 +208,7 @@ export async function* paginateBuffered(pageFunction, pageOptions) {
|
|
|
151
208
|
data: remainingItems,
|
|
152
209
|
},
|
|
153
210
|
];
|
|
154
|
-
|
|
211
|
+
rawCursor = nextRawCursor;
|
|
155
212
|
}
|
|
156
213
|
if (bufferedPages.length > 0) {
|
|
157
214
|
const lastBufferedPage = bufferedPages.slice(-1)[0];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.1",
|
|
4
4
|
"description": "Complete Zapier SDK - combines all Zapier SDK packages",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"tsup": "^8.5.0",
|
|
47
47
|
"typescript": "^5.8.3",
|
|
48
48
|
"vitest": "^3.2.3",
|
|
49
|
-
"@zapier/zapier-sdk-cli-login": "0.8.
|
|
49
|
+
"@zapier/zapier-sdk-cli-login": "0.8.3"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsup",
|