@air/api-core 0.5.0 → 0.5.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/dist/index.cjs +1 -1
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -360,7 +360,7 @@ var AirBase = class {
|
|
|
360
360
|
const url = new URL(`${this.baseURL}${path}`);
|
|
361
361
|
if (query) {
|
|
362
362
|
for (const [key, value] of Object.entries(query)) {
|
|
363
|
-
if (value === void 0) continue;
|
|
363
|
+
if (value === void 0 || value === null) continue;
|
|
364
364
|
if (Array.isArray(value)) {
|
|
365
365
|
for (const v of value) {
|
|
366
366
|
url.searchParams.append(key, v);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
interface CursorPageParams {
|
|
2
2
|
limit?: number;
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Cursor from a previous list response. `null` requests the first page and
|
|
5
|
+
* is omitted from the query string.
|
|
6
|
+
* When `pagination.cursor` is `null` there are no more pages. Stop, or use
|
|
7
|
+
* `hasNextPage()` / `for await`. Passing that `null` back in starts over
|
|
8
|
+
* at page 1.
|
|
9
|
+
*/
|
|
10
|
+
cursor?: string | null;
|
|
4
11
|
}
|
|
5
12
|
interface CursorPageResponse<T> {
|
|
6
13
|
data: T[];
|
|
@@ -34,10 +41,11 @@ declare class PagePromise<T> extends Promise<CursorPage<T>> implements AsyncIter
|
|
|
34
41
|
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
35
42
|
}
|
|
36
43
|
|
|
44
|
+
type QueryParam = string | string[] | number | boolean | null | undefined;
|
|
37
45
|
interface RequestOptions {
|
|
38
46
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
39
47
|
path: string;
|
|
40
|
-
query?: Record<string,
|
|
48
|
+
query?: Record<string, QueryParam>;
|
|
41
49
|
body?: unknown;
|
|
42
50
|
headers?: Record<string, string>;
|
|
43
51
|
timeout?: number;
|
|
@@ -66,7 +74,7 @@ declare class AirBase {
|
|
|
66
74
|
constructor(options?: AirBaseOptions);
|
|
67
75
|
get fetchFn(): typeof globalThis.fetch;
|
|
68
76
|
request<T>(options: RequestOptions): Promise<T>;
|
|
69
|
-
requestCursorPage<T>(options: RequestOptions, query?: Record<string,
|
|
77
|
+
requestCursorPage<T>(options: RequestOptions, query?: Record<string, QueryParam>): PagePromise<T>;
|
|
70
78
|
private _executeRequest;
|
|
71
79
|
private _buildURL;
|
|
72
80
|
}
|
|
@@ -178,4 +186,4 @@ interface PKCEChallenge {
|
|
|
178
186
|
*/
|
|
179
187
|
declare function generatePKCEChallenge(): PKCEChallenge;
|
|
180
188
|
|
|
181
|
-
export { APIError, AirBase, type AirBaseOptions, AuthenticationError, BadRequestError, type BuildAuthorizationUrlOptions, ConnectionError, CursorPage, type CursorPageParams, type CursorPageResponse, type ExchangeAuthorizationCodeOptions, InternalServerError, NotFoundError, type OAuthAccessToken, type OAuthClientAuthMethod, type PKCEChallenge, PagePromise, PermissionError, RateLimitError, type RequestOptions, TimeoutError, VERSION, buildAuthorizationUrl, exchangeAuthorizationCode, generatePKCEChallenge, getRetryDelay, isRetryableError, retryWithBackoff };
|
|
189
|
+
export { APIError, AirBase, type AirBaseOptions, AuthenticationError, BadRequestError, type BuildAuthorizationUrlOptions, ConnectionError, CursorPage, type CursorPageParams, type CursorPageResponse, type ExchangeAuthorizationCodeOptions, InternalServerError, NotFoundError, type OAuthAccessToken, type OAuthClientAuthMethod, type PKCEChallenge, PagePromise, PermissionError, type QueryParam, RateLimitError, type RequestOptions, TimeoutError, VERSION, buildAuthorizationUrl, exchangeAuthorizationCode, generatePKCEChallenge, getRetryDelay, isRetryableError, retryWithBackoff };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
interface CursorPageParams {
|
|
2
2
|
limit?: number;
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Cursor from a previous list response. `null` requests the first page and
|
|
5
|
+
* is omitted from the query string.
|
|
6
|
+
* When `pagination.cursor` is `null` there are no more pages. Stop, or use
|
|
7
|
+
* `hasNextPage()` / `for await`. Passing that `null` back in starts over
|
|
8
|
+
* at page 1.
|
|
9
|
+
*/
|
|
10
|
+
cursor?: string | null;
|
|
4
11
|
}
|
|
5
12
|
interface CursorPageResponse<T> {
|
|
6
13
|
data: T[];
|
|
@@ -34,10 +41,11 @@ declare class PagePromise<T> extends Promise<CursorPage<T>> implements AsyncIter
|
|
|
34
41
|
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
35
42
|
}
|
|
36
43
|
|
|
44
|
+
type QueryParam = string | string[] | number | boolean | null | undefined;
|
|
37
45
|
interface RequestOptions {
|
|
38
46
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
39
47
|
path: string;
|
|
40
|
-
query?: Record<string,
|
|
48
|
+
query?: Record<string, QueryParam>;
|
|
41
49
|
body?: unknown;
|
|
42
50
|
headers?: Record<string, string>;
|
|
43
51
|
timeout?: number;
|
|
@@ -66,7 +74,7 @@ declare class AirBase {
|
|
|
66
74
|
constructor(options?: AirBaseOptions);
|
|
67
75
|
get fetchFn(): typeof globalThis.fetch;
|
|
68
76
|
request<T>(options: RequestOptions): Promise<T>;
|
|
69
|
-
requestCursorPage<T>(options: RequestOptions, query?: Record<string,
|
|
77
|
+
requestCursorPage<T>(options: RequestOptions, query?: Record<string, QueryParam>): PagePromise<T>;
|
|
70
78
|
private _executeRequest;
|
|
71
79
|
private _buildURL;
|
|
72
80
|
}
|
|
@@ -178,4 +186,4 @@ interface PKCEChallenge {
|
|
|
178
186
|
*/
|
|
179
187
|
declare function generatePKCEChallenge(): PKCEChallenge;
|
|
180
188
|
|
|
181
|
-
export { APIError, AirBase, type AirBaseOptions, AuthenticationError, BadRequestError, type BuildAuthorizationUrlOptions, ConnectionError, CursorPage, type CursorPageParams, type CursorPageResponse, type ExchangeAuthorizationCodeOptions, InternalServerError, NotFoundError, type OAuthAccessToken, type OAuthClientAuthMethod, type PKCEChallenge, PagePromise, PermissionError, RateLimitError, type RequestOptions, TimeoutError, VERSION, buildAuthorizationUrl, exchangeAuthorizationCode, generatePKCEChallenge, getRetryDelay, isRetryableError, retryWithBackoff };
|
|
189
|
+
export { APIError, AirBase, type AirBaseOptions, AuthenticationError, BadRequestError, type BuildAuthorizationUrlOptions, ConnectionError, CursorPage, type CursorPageParams, type CursorPageResponse, type ExchangeAuthorizationCodeOptions, InternalServerError, NotFoundError, type OAuthAccessToken, type OAuthClientAuthMethod, type PKCEChallenge, PagePromise, PermissionError, type QueryParam, RateLimitError, type RequestOptions, TimeoutError, VERSION, buildAuthorizationUrl, exchangeAuthorizationCode, generatePKCEChallenge, getRetryDelay, isRetryableError, retryWithBackoff };
|
package/dist/index.js
CHANGED
|
@@ -316,7 +316,7 @@ var AirBase = class {
|
|
|
316
316
|
const url = new URL(`${this.baseURL}${path}`);
|
|
317
317
|
if (query) {
|
|
318
318
|
for (const [key, value] of Object.entries(query)) {
|
|
319
|
-
if (value === void 0) continue;
|
|
319
|
+
if (value === void 0 || value === null) continue;
|
|
320
320
|
if (Array.isArray(value)) {
|
|
321
321
|
for (const v of value) {
|
|
322
322
|
url.searchParams.append(key, v);
|