@codeqr/ts 0.24.0 → 0.25.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 +29 -0
- package/LICENSE +1 -1
- package/README.md +28 -28
- package/client.d.mts +10 -10
- package/client.d.mts.map +1 -1
- package/client.d.ts +10 -10
- package/client.d.ts.map +1 -1
- package/client.js +38 -38
- package/client.mjs +36 -36
- package/core/api-promise.d.mts +2 -2
- package/core/api-promise.d.ts +2 -2
- package/core/error.d.mts +2 -2
- package/core/error.d.ts +2 -2
- package/core/error.js +4 -4
- package/core/error.mjs +2 -2
- package/core/resource.d.mts +3 -3
- package/core/resource.d.ts +3 -3
- package/index.d.mts +3 -3
- package/index.d.ts +3 -3
- package/index.js +4 -4
- package/index.mjs +3 -3
- package/internal/parse.d.mts +2 -2
- package/internal/parse.d.ts +2 -2
- package/internal/shims.js +1 -1
- package/internal/shims.mjs +1 -1
- package/internal/uploads.d.mts +4 -4
- package/internal/uploads.d.ts +4 -4
- package/internal/utils/base64.js +2 -2
- package/internal/utils/base64.mjs +3 -3
- package/internal/utils/log.d.mts +3 -3
- package/internal/utils/log.d.ts +3 -3
- package/internal/utils/path.js +1 -1
- package/internal/utils/path.mjs +2 -2
- package/internal/utils/values.js +5 -5
- package/internal/utils/values.mjs +6 -6
- package/package.json +3 -3
- package/resources/analytics.d.mts +38 -5
- package/resources/analytics.d.mts.map +1 -1
- package/resources/analytics.d.ts +38 -5
- package/resources/analytics.d.ts.map +1 -1
- package/resources/domains.d.mts +26 -26
- package/resources/domains.d.mts.map +1 -1
- package/resources/domains.d.ts +26 -26
- package/resources/domains.d.ts.map +1 -1
- package/resources/domains.js +8 -8
- package/resources/domains.js.map +1 -1
- package/resources/domains.mjs +8 -8
- package/resources/domains.mjs.map +1 -1
- package/resources/events.d.mts +29 -72
- package/resources/events.d.mts.map +1 -1
- package/resources/events.d.ts +29 -72
- package/resources/events.d.ts.map +1 -1
- package/resources/index.d.mts +4 -4
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +4 -4
- package/resources/index.d.ts.map +1 -1
- package/resources/links/bulk.d.mts +14 -5
- package/resources/links/bulk.d.mts.map +1 -1
- package/resources/links/bulk.d.ts +14 -5
- package/resources/links/bulk.d.ts.map +1 -1
- package/resources/links/index.d.mts +1 -1
- package/resources/links/index.d.mts.map +1 -1
- package/resources/links/index.d.ts +1 -1
- package/resources/links/index.d.ts.map +1 -1
- package/resources/links/links.d.mts +263 -237
- package/resources/links/links.d.mts.map +1 -1
- package/resources/links/links.d.ts +263 -237
- package/resources/links/links.d.ts.map +1 -1
- package/resources/links/links.js +21 -21
- package/resources/links/links.js.map +1 -1
- package/resources/links/links.mjs +21 -21
- package/resources/links/links.mjs.map +1 -1
- package/resources/qrcodes/bulk.d.mts +84 -17
- package/resources/qrcodes/bulk.d.mts.map +1 -1
- package/resources/qrcodes/bulk.d.ts +84 -17
- package/resources/qrcodes/bulk.d.ts.map +1 -1
- package/resources/qrcodes/index.d.mts +1 -1
- package/resources/qrcodes/index.d.mts.map +1 -1
- package/resources/qrcodes/index.d.ts +1 -1
- package/resources/qrcodes/index.d.ts.map +1 -1
- package/resources/qrcodes/qrcodes.d.mts +409 -223
- package/resources/qrcodes/qrcodes.d.mts.map +1 -1
- package/resources/qrcodes/qrcodes.d.ts +409 -223
- package/resources/qrcodes/qrcodes.d.ts.map +1 -1
- package/resources/qrcodes/qrcodes.js +11 -11
- package/resources/qrcodes/qrcodes.js.map +1 -1
- package/resources/qrcodes/qrcodes.mjs +11 -11
- package/resources/qrcodes/qrcodes.mjs.map +1 -1
- package/resources/tags.d.mts +12 -12
- package/resources/tags.d.mts.map +1 -1
- package/resources/tags.d.ts +12 -12
- package/resources/tags.d.ts.map +1 -1
- package/resources/tags.js +6 -6
- package/resources/tags.js.map +1 -1
- package/resources/tags.mjs +6 -6
- package/resources/tags.mjs.map +1 -1
- package/resources/track.d.mts +12 -0
- package/resources/track.d.mts.map +1 -1
- package/resources/track.d.ts +12 -0
- package/resources/track.d.ts.map +1 -1
- package/src/client.ts +21 -21
- package/src/core/api-promise.ts +4 -4
- package/src/core/error.ts +2 -2
- package/src/core/resource.ts +3 -3
- package/src/index.ts +3 -3
- package/src/internal/parse.ts +2 -2
- package/src/internal/shims.ts +1 -1
- package/src/internal/uploads.ts +5 -5
- package/src/internal/utils/base64.ts +3 -3
- package/src/internal/utils/log.ts +3 -3
- package/src/internal/utils/path.ts +2 -2
- package/src/internal/utils/values.ts +6 -6
- package/src/resources/analytics.ts +45 -5
- package/src/resources/domains.ts +37 -37
- package/src/resources/events.ts +48 -82
- package/src/resources/index.ts +4 -4
- package/src/resources/links/bulk.ts +23 -6
- package/src/resources/links/index.ts +1 -1
- package/src/resources/links/links.ts +328 -257
- package/src/resources/qrcodes/bulk.ts +103 -17
- package/src/resources/qrcodes/index.ts +1 -1
- package/src/resources/qrcodes/qrcodes.ts +629 -368
- package/src/resources/tags.ts +16 -16
- package/src/resources/track.ts +14 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/client.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
var
|
|
2
|
+
var _CodeQR_instances, _a, _CodeQR_encoder, _CodeQR_baseURLOverridden;
|
|
3
3
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from "./internal/tslib.mjs";
|
|
4
4
|
import { uuid4 } from "./internal/utils/uuid.mjs";
|
|
5
5
|
import { validatePositiveInteger, isAbsoluteURL, safeJSON } from "./internal/utils/values.mjs";
|
|
@@ -27,11 +27,11 @@ import { readEnv } from "./internal/utils/env.mjs";
|
|
|
27
27
|
import { formatRequestDetails, loggerFor, parseLogLevel, } from "./internal/utils/log.mjs";
|
|
28
28
|
import { isEmptyObj } from "./internal/utils/values.mjs";
|
|
29
29
|
/**
|
|
30
|
-
* API Client for interfacing with the
|
|
30
|
+
* API Client for interfacing with the CodeQR API.
|
|
31
31
|
*/
|
|
32
|
-
export class
|
|
32
|
+
export class CodeQR {
|
|
33
33
|
/**
|
|
34
|
-
* API Client for interfacing with the
|
|
34
|
+
* API Client for interfacing with the CodeQR API.
|
|
35
35
|
*
|
|
36
36
|
* @param {string | undefined} [opts.apiKey=process.env['CODEQR_API_KEY'] ?? undefined]
|
|
37
37
|
* @param {string} [opts.baseURL=process.env['CODEQR_BASE_URL'] ?? https://api.codeqr.io] - Override the default base URL for the API.
|
|
@@ -43,8 +43,8 @@ export class Codeqr {
|
|
|
43
43
|
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
44
44
|
*/
|
|
45
45
|
constructor({ baseURL = readEnv('CODEQR_BASE_URL'), apiKey = readEnv('CODEQR_API_KEY'), ...opts } = {}) {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
_CodeQR_instances.add(this);
|
|
47
|
+
_CodeQR_encoder.set(this, void 0);
|
|
48
48
|
this.links = new API.Links(this);
|
|
49
49
|
this.qrcodes = new API.Qrcodes(this);
|
|
50
50
|
this.analytics = new API.Analytics(this);
|
|
@@ -54,7 +54,7 @@ export class Codeqr {
|
|
|
54
54
|
this.track = new API.Track(this);
|
|
55
55
|
this.projects = new API.Projects(this);
|
|
56
56
|
if (apiKey === undefined) {
|
|
57
|
-
throw new Errors.
|
|
57
|
+
throw new Errors.CodeQRError("The CODEQR_API_KEY environment variable is missing or empty; either provide it, or instantiate the CodeQR client with an apiKey option, like new CodeQR({ apiKey: 'My API Key' }).");
|
|
58
58
|
}
|
|
59
59
|
const options = {
|
|
60
60
|
apiKey,
|
|
@@ -74,7 +74,7 @@ export class Codeqr {
|
|
|
74
74
|
this.fetchOptions = options.fetchOptions;
|
|
75
75
|
this.maxRetries = options.maxRetries ?? 2;
|
|
76
76
|
this.fetch = options.fetch ?? Shims.getDefaultFetch();
|
|
77
|
-
__classPrivateFieldSet(this,
|
|
77
|
+
__classPrivateFieldSet(this, _CodeQR_encoder, Opts.FallbackEncoder, "f");
|
|
78
78
|
const customHeadersEnv = readEnv('CODEQR_CUSTOM_HEADERS');
|
|
79
79
|
if (customHeadersEnv) {
|
|
80
80
|
const parsed = {};
|
|
@@ -129,7 +129,7 @@ export class Codeqr {
|
|
|
129
129
|
return Errors.APIError.generate(status, error, message, headers);
|
|
130
130
|
}
|
|
131
131
|
buildURL(path, query, defaultBaseURL) {
|
|
132
|
-
const baseURL = (!__classPrivateFieldGet(this,
|
|
132
|
+
const baseURL = (!__classPrivateFieldGet(this, _CodeQR_instances, "m", _CodeQR_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL;
|
|
133
133
|
const url = isAbsoluteURL(path) ?
|
|
134
134
|
new URL(path)
|
|
135
135
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
@@ -428,7 +428,7 @@ export class Codeqr {
|
|
|
428
428
|
// content-type for those, and only elide it for operations with no body at
|
|
429
429
|
// all (e.g. GET/DELETE).
|
|
430
430
|
if (body == null && 'body' in options) {
|
|
431
|
-
return __classPrivateFieldGet(this,
|
|
431
|
+
return __classPrivateFieldGet(this, _CodeQR_encoder, "f").call(this, { body, headers: buildHeaders([rawHeaders]) });
|
|
432
432
|
}
|
|
433
433
|
return { bodyHeaders: undefined, body: undefined };
|
|
434
434
|
}
|
|
@@ -464,35 +464,35 @@ export class Codeqr {
|
|
|
464
464
|
};
|
|
465
465
|
}
|
|
466
466
|
else {
|
|
467
|
-
return __classPrivateFieldGet(this,
|
|
467
|
+
return __classPrivateFieldGet(this, _CodeQR_encoder, "f").call(this, { body, headers });
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
|
-
_a =
|
|
471
|
+
_a = CodeQR, _CodeQR_encoder = new WeakMap(), _CodeQR_instances = new WeakSet(), _CodeQR_baseURLOverridden = function _CodeQR_baseURLOverridden() {
|
|
472
472
|
return this.baseURL !== 'https://api.codeqr.io';
|
|
473
473
|
};
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
474
|
+
CodeQR.CodeQR = _a;
|
|
475
|
+
CodeQR.DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
476
|
+
CodeQR.CodeQRError = Errors.CodeQRError;
|
|
477
|
+
CodeQR.APIError = Errors.APIError;
|
|
478
|
+
CodeQR.APIConnectionError = Errors.APIConnectionError;
|
|
479
|
+
CodeQR.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
480
|
+
CodeQR.APIUserAbortError = Errors.APIUserAbortError;
|
|
481
|
+
CodeQR.NotFoundError = Errors.NotFoundError;
|
|
482
|
+
CodeQR.ConflictError = Errors.ConflictError;
|
|
483
|
+
CodeQR.RateLimitError = Errors.RateLimitError;
|
|
484
|
+
CodeQR.BadRequestError = Errors.BadRequestError;
|
|
485
|
+
CodeQR.AuthenticationError = Errors.AuthenticationError;
|
|
486
|
+
CodeQR.InternalServerError = Errors.InternalServerError;
|
|
487
|
+
CodeQR.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
488
|
+
CodeQR.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
489
|
+
CodeQR.toFile = Uploads.toFile;
|
|
490
|
+
CodeQR.Links = Links;
|
|
491
|
+
CodeQR.Qrcodes = Qrcodes;
|
|
492
|
+
CodeQR.Analytics = Analytics;
|
|
493
|
+
CodeQR.Events = Events;
|
|
494
|
+
CodeQR.Tags = Tags;
|
|
495
|
+
CodeQR.Domains = Domains;
|
|
496
|
+
CodeQR.Track = Track;
|
|
497
|
+
CodeQR.Projects = Projects;
|
|
498
498
|
//# sourceMappingURL=client.mjs.map
|
package/core/api-promise.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type CodeQR } from "../client.mjs";
|
|
2
2
|
import { type PromiseOrValue } from "../internal/types.mjs";
|
|
3
3
|
import { APIResponseProps } from "../internal/parse.mjs";
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ export declare class APIPromise<T> extends Promise<T> {
|
|
|
10
10
|
private responsePromise;
|
|
11
11
|
private parseResponse;
|
|
12
12
|
private parsedPromise;
|
|
13
|
-
constructor(client:
|
|
13
|
+
constructor(client: CodeQR, responsePromise: Promise<APIResponseProps>, parseResponse?: (client: CodeQR, props: APIResponseProps) => PromiseOrValue<T>);
|
|
14
14
|
_thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U>;
|
|
15
15
|
/**
|
|
16
16
|
* Gets the raw `Response` instance instead of parsing the response
|
package/core/api-promise.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type CodeQR } from "../client.js";
|
|
2
2
|
import { type PromiseOrValue } from "../internal/types.js";
|
|
3
3
|
import { APIResponseProps } from "../internal/parse.js";
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ export declare class APIPromise<T> extends Promise<T> {
|
|
|
10
10
|
private responsePromise;
|
|
11
11
|
private parseResponse;
|
|
12
12
|
private parsedPromise;
|
|
13
|
-
constructor(client:
|
|
13
|
+
constructor(client: CodeQR, responsePromise: Promise<APIResponseProps>, parseResponse?: (client: CodeQR, props: APIResponseProps) => PromiseOrValue<T>);
|
|
14
14
|
_thenUnwrap<U>(transform: (data: T, props: APIResponseProps) => U): APIPromise<U>;
|
|
15
15
|
/**
|
|
16
16
|
* Gets the raw `Response` instance instead of parsing the response
|
package/core/error.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class CodeQRError extends Error {
|
|
2
2
|
}
|
|
3
|
-
export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends
|
|
3
|
+
export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends CodeQRError {
|
|
4
4
|
/** HTTP status for the response that caused the error */
|
|
5
5
|
readonly status: TStatus;
|
|
6
6
|
/** HTTP headers for the response that caused the error */
|
package/core/error.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class CodeQRError extends Error {
|
|
2
2
|
}
|
|
3
|
-
export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends
|
|
3
|
+
export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends CodeQRError {
|
|
4
4
|
/** HTTP status for the response that caused the error */
|
|
5
5
|
readonly status: TStatus;
|
|
6
6
|
/** HTTP headers for the response that caused the error */
|
package/core/error.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.InternalServerError = exports.RateLimitError = exports.UnprocessableEntityError = exports.ConflictError = exports.NotFoundError = exports.PermissionDeniedError = exports.AuthenticationError = exports.BadRequestError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIUserAbortError = exports.APIError = exports.
|
|
4
|
+
exports.InternalServerError = exports.RateLimitError = exports.UnprocessableEntityError = exports.ConflictError = exports.NotFoundError = exports.PermissionDeniedError = exports.AuthenticationError = exports.BadRequestError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIUserAbortError = exports.APIError = exports.CodeQRError = void 0;
|
|
5
5
|
const errors_1 = require("../internal/errors.js");
|
|
6
|
-
class
|
|
6
|
+
class CodeQRError extends Error {
|
|
7
7
|
}
|
|
8
|
-
exports.
|
|
9
|
-
class APIError extends
|
|
8
|
+
exports.CodeQRError = CodeQRError;
|
|
9
|
+
class APIError extends CodeQRError {
|
|
10
10
|
constructor(status, error, message, headers) {
|
|
11
11
|
super(`${APIError.makeMessage(status, error, message)}`);
|
|
12
12
|
this.status = status;
|
package/core/error.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
import { castToError } from "../internal/errors.mjs";
|
|
3
|
-
export class
|
|
3
|
+
export class CodeQRError extends Error {
|
|
4
4
|
}
|
|
5
|
-
export class APIError extends
|
|
5
|
+
export class APIError extends CodeQRError {
|
|
6
6
|
constructor(status, error, message, headers) {
|
|
7
7
|
super(`${APIError.makeMessage(status, error, message)}`);
|
|
8
8
|
this.status = status;
|
package/core/resource.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CodeQR } from "../client.mjs";
|
|
2
2
|
export declare abstract class APIResource {
|
|
3
|
-
protected _client:
|
|
4
|
-
constructor(client:
|
|
3
|
+
protected _client: CodeQR;
|
|
4
|
+
constructor(client: CodeQR);
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=resource.d.mts.map
|
package/core/resource.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CodeQR } from "../client.js";
|
|
2
2
|
export declare abstract class APIResource {
|
|
3
|
-
protected _client:
|
|
4
|
-
constructor(client:
|
|
3
|
+
protected _client: CodeQR;
|
|
4
|
+
constructor(client: CodeQR);
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=resource.d.ts.map
|
package/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { CodeQR as default } from "./client.mjs";
|
|
2
2
|
export { type Uploadable, toFile } from "./core/uploads.mjs";
|
|
3
3
|
export { APIPromise } from "./core/api-promise.mjs";
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
4
|
+
export { CodeQR, type ClientOptions } from "./client.mjs";
|
|
5
|
+
export { CodeQRError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.mjs";
|
|
6
6
|
//# sourceMappingURL=index.d.mts.map
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { CodeQR as default } from "./client.js";
|
|
2
2
|
export { type Uploadable, toFile } from "./core/uploads.js";
|
|
3
3
|
export { APIPromise } from "./core/api-promise.js";
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
4
|
+
export { CodeQR, type ClientOptions } from "./client.js";
|
|
5
|
+
export { CodeQRError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -4,17 +4,17 @@ exports = module.exports = function (...args) {
|
|
|
4
4
|
return new exports.default(...args)
|
|
5
5
|
}
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.
|
|
7
|
+
exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.CodeQRError = exports.CodeQR = exports.APIPromise = exports.toFile = exports.default = void 0;
|
|
8
8
|
var client_1 = require("./client.js");
|
|
9
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return client_1.
|
|
9
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return client_1.CodeQR; } });
|
|
10
10
|
var uploads_1 = require("./core/uploads.js");
|
|
11
11
|
Object.defineProperty(exports, "toFile", { enumerable: true, get: function () { return uploads_1.toFile; } });
|
|
12
12
|
var api_promise_1 = require("./core/api-promise.js");
|
|
13
13
|
Object.defineProperty(exports, "APIPromise", { enumerable: true, get: function () { return api_promise_1.APIPromise; } });
|
|
14
14
|
var client_2 = require("./client.js");
|
|
15
|
-
Object.defineProperty(exports, "
|
|
15
|
+
Object.defineProperty(exports, "CodeQR", { enumerable: true, get: function () { return client_2.CodeQR; } });
|
|
16
16
|
var error_1 = require("./core/error.js");
|
|
17
|
-
Object.defineProperty(exports, "
|
|
17
|
+
Object.defineProperty(exports, "CodeQRError", { enumerable: true, get: function () { return error_1.CodeQRError; } });
|
|
18
18
|
Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return error_1.APIError; } });
|
|
19
19
|
Object.defineProperty(exports, "APIConnectionError", { enumerable: true, get: function () { return error_1.APIConnectionError; } });
|
|
20
20
|
Object.defineProperty(exports, "APIConnectionTimeoutError", { enumerable: true, get: function () { return error_1.APIConnectionTimeoutError; } });
|
package/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
export {
|
|
2
|
+
export { CodeQR as default } from "./client.mjs";
|
|
3
3
|
export { toFile } from "./core/uploads.mjs";
|
|
4
4
|
export { APIPromise } from "./core/api-promise.mjs";
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
5
|
+
export { CodeQR } from "./client.mjs";
|
|
6
|
+
export { CodeQRError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.mjs";
|
|
7
7
|
//# sourceMappingURL=index.mjs.map
|
package/internal/parse.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FinalRequestOptions } from "./request-options.mjs";
|
|
2
|
-
import { type
|
|
2
|
+
import { type CodeQR } from "../client.mjs";
|
|
3
3
|
export type APIResponseProps = {
|
|
4
4
|
response: Response;
|
|
5
5
|
options: FinalRequestOptions;
|
|
@@ -8,5 +8,5 @@ export type APIResponseProps = {
|
|
|
8
8
|
retryOfRequestLogID: string | undefined;
|
|
9
9
|
startTime: number;
|
|
10
10
|
};
|
|
11
|
-
export declare function defaultParseResponse<T>(client:
|
|
11
|
+
export declare function defaultParseResponse<T>(client: CodeQR, props: APIResponseProps): Promise<T>;
|
|
12
12
|
//# sourceMappingURL=parse.d.mts.map
|
package/internal/parse.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FinalRequestOptions } from "./request-options.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type CodeQR } from "../client.js";
|
|
3
3
|
export type APIResponseProps = {
|
|
4
4
|
response: Response;
|
|
5
5
|
options: FinalRequestOptions;
|
|
@@ -8,5 +8,5 @@ export type APIResponseProps = {
|
|
|
8
8
|
retryOfRequestLogID: string | undefined;
|
|
9
9
|
startTime: number;
|
|
10
10
|
};
|
|
11
|
-
export declare function defaultParseResponse<T>(client:
|
|
11
|
+
export declare function defaultParseResponse<T>(client: CodeQR, props: APIResponseProps): Promise<T>;
|
|
12
12
|
//# sourceMappingURL=parse.d.ts.map
|
package/internal/shims.js
CHANGED
|
@@ -10,7 +10,7 @@ function getDefaultFetch() {
|
|
|
10
10
|
if (typeof fetch !== 'undefined') {
|
|
11
11
|
return fetch;
|
|
12
12
|
}
|
|
13
|
-
throw new Error('`fetch` is not defined as a global; Either pass `fetch` to the client, `new
|
|
13
|
+
throw new Error('`fetch` is not defined as a global; Either pass `fetch` to the client, `new CodeQR({ fetch })` or polyfill the global, `globalThis.fetch = fetch`');
|
|
14
14
|
}
|
|
15
15
|
function makeReadableStream(...args) {
|
|
16
16
|
const ReadableStream = globalThis.ReadableStream;
|
package/internal/shims.mjs
CHANGED
|
@@ -3,7 +3,7 @@ export function getDefaultFetch() {
|
|
|
3
3
|
if (typeof fetch !== 'undefined') {
|
|
4
4
|
return fetch;
|
|
5
5
|
}
|
|
6
|
-
throw new Error('`fetch` is not defined as a global; Either pass `fetch` to the client, `new
|
|
6
|
+
throw new Error('`fetch` is not defined as a global; Either pass `fetch` to the client, `new CodeQR({ fetch })` or polyfill the global, `globalThis.fetch = fetch`');
|
|
7
7
|
}
|
|
8
8
|
export function makeReadableStream(...args) {
|
|
9
9
|
const ReadableStream = globalThis.ReadableStream;
|
package/internal/uploads.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RequestOptions } from "./request-options.mjs";
|
|
2
2
|
import type { FilePropertyBag, Fetch } from "./builtin-types.mjs";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CodeQR } from "../client.mjs";
|
|
4
4
|
export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | DataView;
|
|
5
5
|
type FsReadStream = AsyncIterable<Uint8Array> & {
|
|
6
6
|
path: string | {
|
|
@@ -32,11 +32,11 @@ export declare const isAsyncIterable: (value: any) => value is AsyncIterable<any
|
|
|
32
32
|
* Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
|
|
33
33
|
* Otherwise returns the request as is.
|
|
34
34
|
*/
|
|
35
|
-
export declare const maybeMultipartFormRequestOptions: (opts: RequestOptions, fetch:
|
|
35
|
+
export declare const maybeMultipartFormRequestOptions: (opts: RequestOptions, fetch: CodeQR | Fetch) => Promise<RequestOptions>;
|
|
36
36
|
type MultipartFormRequestOptions = Omit<RequestOptions, 'body'> & {
|
|
37
37
|
body: unknown;
|
|
38
38
|
};
|
|
39
|
-
export declare const multipartFormRequestOptions: (opts: MultipartFormRequestOptions, fetch:
|
|
40
|
-
export declare const createForm: <T = Record<string, unknown>>(body: T | undefined, fetch:
|
|
39
|
+
export declare const multipartFormRequestOptions: (opts: MultipartFormRequestOptions, fetch: CodeQR | Fetch) => Promise<RequestOptions>;
|
|
40
|
+
export declare const createForm: <T = Record<string, unknown>>(body: T | undefined, fetch: CodeQR | Fetch) => Promise<FormData>;
|
|
41
41
|
export {};
|
|
42
42
|
//# sourceMappingURL=uploads.d.mts.map
|
package/internal/uploads.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RequestOptions } from "./request-options.js";
|
|
2
2
|
import type { FilePropertyBag, Fetch } from "./builtin-types.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { CodeQR } from "../client.js";
|
|
4
4
|
export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | DataView;
|
|
5
5
|
type FsReadStream = AsyncIterable<Uint8Array> & {
|
|
6
6
|
path: string | {
|
|
@@ -32,11 +32,11 @@ export declare const isAsyncIterable: (value: any) => value is AsyncIterable<any
|
|
|
32
32
|
* Returns a multipart/form-data request if any part of the given request body contains a File / Blob value.
|
|
33
33
|
* Otherwise returns the request as is.
|
|
34
34
|
*/
|
|
35
|
-
export declare const maybeMultipartFormRequestOptions: (opts: RequestOptions, fetch:
|
|
35
|
+
export declare const maybeMultipartFormRequestOptions: (opts: RequestOptions, fetch: CodeQR | Fetch) => Promise<RequestOptions>;
|
|
36
36
|
type MultipartFormRequestOptions = Omit<RequestOptions, 'body'> & {
|
|
37
37
|
body: unknown;
|
|
38
38
|
};
|
|
39
|
-
export declare const multipartFormRequestOptions: (opts: MultipartFormRequestOptions, fetch:
|
|
40
|
-
export declare const createForm: <T = Record<string, unknown>>(body: T | undefined, fetch:
|
|
39
|
+
export declare const multipartFormRequestOptions: (opts: MultipartFormRequestOptions, fetch: CodeQR | Fetch) => Promise<RequestOptions>;
|
|
40
|
+
export declare const createForm: <T = Record<string, unknown>>(body: T | undefined, fetch: CodeQR | Fetch) => Promise<FormData>;
|
|
41
41
|
export {};
|
|
42
42
|
//# sourceMappingURL=uploads.d.ts.map
|
package/internal/utils/base64.js
CHANGED
|
@@ -16,7 +16,7 @@ const toBase64 = (data) => {
|
|
|
16
16
|
if (typeof btoa !== 'undefined') {
|
|
17
17
|
return btoa(String.fromCharCode.apply(null, data));
|
|
18
18
|
}
|
|
19
|
-
throw new error_1.
|
|
19
|
+
throw new error_1.CodeQRError('Cannot generate base64 string; Expected `Buffer` or `btoa` to be defined');
|
|
20
20
|
};
|
|
21
21
|
exports.toBase64 = toBase64;
|
|
22
22
|
const fromBase64 = (str) => {
|
|
@@ -32,7 +32,7 @@ const fromBase64 = (str) => {
|
|
|
32
32
|
}
|
|
33
33
|
return buf;
|
|
34
34
|
}
|
|
35
|
-
throw new error_1.
|
|
35
|
+
throw new error_1.CodeQRError('Cannot decode base64 string; Expected `Buffer` or `atob` to be defined');
|
|
36
36
|
};
|
|
37
37
|
exports.fromBase64 = fromBase64;
|
|
38
38
|
//# sourceMappingURL=base64.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
import {
|
|
2
|
+
import { CodeQRError } from "../../core/error.mjs";
|
|
3
3
|
import { encodeUTF8 } from "./bytes.mjs";
|
|
4
4
|
export const toBase64 = (data) => {
|
|
5
5
|
if (!data)
|
|
@@ -13,7 +13,7 @@ export const toBase64 = (data) => {
|
|
|
13
13
|
if (typeof btoa !== 'undefined') {
|
|
14
14
|
return btoa(String.fromCharCode.apply(null, data));
|
|
15
15
|
}
|
|
16
|
-
throw new
|
|
16
|
+
throw new CodeQRError('Cannot generate base64 string; Expected `Buffer` or `btoa` to be defined');
|
|
17
17
|
};
|
|
18
18
|
export const fromBase64 = (str) => {
|
|
19
19
|
if (typeof globalThis.Buffer !== 'undefined') {
|
|
@@ -28,6 +28,6 @@ export const fromBase64 = (str) => {
|
|
|
28
28
|
}
|
|
29
29
|
return buf;
|
|
30
30
|
}
|
|
31
|
-
throw new
|
|
31
|
+
throw new CodeQRError('Cannot decode base64 string; Expected `Buffer` or `atob` to be defined');
|
|
32
32
|
};
|
|
33
33
|
//# sourceMappingURL=base64.mjs.map
|
package/internal/utils/log.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type CodeQR } from "../../client.mjs";
|
|
2
2
|
import { RequestOptions } from "../request-options.mjs";
|
|
3
3
|
type LogFn = (message: string, ...rest: unknown[]) => void;
|
|
4
4
|
export type Logger = {
|
|
@@ -8,8 +8,8 @@ export type Logger = {
|
|
|
8
8
|
debug: LogFn;
|
|
9
9
|
};
|
|
10
10
|
export type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug';
|
|
11
|
-
export declare const parseLogLevel: (maybeLevel: string | undefined, sourceName: string, client:
|
|
12
|
-
export declare function loggerFor(client:
|
|
11
|
+
export declare const parseLogLevel: (maybeLevel: string | undefined, sourceName: string, client: CodeQR) => LogLevel | undefined;
|
|
12
|
+
export declare function loggerFor(client: CodeQR): Logger;
|
|
13
13
|
export declare const formatRequestDetails: (details: {
|
|
14
14
|
options?: RequestOptions | undefined;
|
|
15
15
|
headers?: Headers | Record<string, string> | undefined;
|
package/internal/utils/log.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type CodeQR } from "../../client.js";
|
|
2
2
|
import { RequestOptions } from "../request-options.js";
|
|
3
3
|
type LogFn = (message: string, ...rest: unknown[]) => void;
|
|
4
4
|
export type Logger = {
|
|
@@ -8,8 +8,8 @@ export type Logger = {
|
|
|
8
8
|
debug: LogFn;
|
|
9
9
|
};
|
|
10
10
|
export type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug';
|
|
11
|
-
export declare const parseLogLevel: (maybeLevel: string | undefined, sourceName: string, client:
|
|
12
|
-
export declare function loggerFor(client:
|
|
11
|
+
export declare const parseLogLevel: (maybeLevel: string | undefined, sourceName: string, client: CodeQR) => LogLevel | undefined;
|
|
12
|
+
export declare function loggerFor(client: CodeQR): Logger;
|
|
13
13
|
export declare const formatRequestDetails: (details: {
|
|
14
14
|
options?: RequestOptions | undefined;
|
|
15
15
|
headers?: Headers | Record<string, string> | undefined;
|
package/internal/utils/path.js
CHANGED
|
@@ -65,7 +65,7 @@ const createPathTagFunction = (pathEncoder = encodeURIPath) => function path(sta
|
|
|
65
65
|
lastEnd = segment.start + segment.length;
|
|
66
66
|
return acc + spaces + arrows;
|
|
67
67
|
}, '');
|
|
68
|
-
throw new error_1.
|
|
68
|
+
throw new error_1.CodeQRError(`Path parameters result in path with invalid segments:\n${invalidSegments
|
|
69
69
|
.map((e) => e.error)
|
|
70
70
|
.join('\n')}\n${path}\n${underline}`);
|
|
71
71
|
}
|
package/internal/utils/path.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CodeQRError } from "../../core/error.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Percent-encode everything that isn't safe to have in a path without encoding safe chars.
|
|
4
4
|
*
|
|
@@ -61,7 +61,7 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) => function p
|
|
|
61
61
|
lastEnd = segment.start + segment.length;
|
|
62
62
|
return acc + spaces + arrows;
|
|
63
63
|
}, '');
|
|
64
|
-
throw new
|
|
64
|
+
throw new CodeQRError(`Path parameters result in path with invalid segments:\n${invalidSegments
|
|
65
65
|
.map((e) => e.error)
|
|
66
66
|
.join('\n')}\n${path}\n${underline}`);
|
|
67
67
|
}
|
package/internal/utils/values.js
CHANGED
|
@@ -40,17 +40,17 @@ function isObj(obj) {
|
|
|
40
40
|
}
|
|
41
41
|
const ensurePresent = (value) => {
|
|
42
42
|
if (value == null) {
|
|
43
|
-
throw new error_1.
|
|
43
|
+
throw new error_1.CodeQRError(`Expected a value to be given but received ${value} instead.`);
|
|
44
44
|
}
|
|
45
45
|
return value;
|
|
46
46
|
};
|
|
47
47
|
exports.ensurePresent = ensurePresent;
|
|
48
48
|
const validatePositiveInteger = (name, n) => {
|
|
49
49
|
if (typeof n !== 'number' || !Number.isInteger(n)) {
|
|
50
|
-
throw new error_1.
|
|
50
|
+
throw new error_1.CodeQRError(`${name} must be an integer`);
|
|
51
51
|
}
|
|
52
52
|
if (n < 0) {
|
|
53
|
-
throw new error_1.
|
|
53
|
+
throw new error_1.CodeQRError(`${name} must be a positive integer`);
|
|
54
54
|
}
|
|
55
55
|
return n;
|
|
56
56
|
};
|
|
@@ -60,7 +60,7 @@ const coerceInteger = (value) => {
|
|
|
60
60
|
return Math.round(value);
|
|
61
61
|
if (typeof value === 'string')
|
|
62
62
|
return parseInt(value, 10);
|
|
63
|
-
throw new error_1.
|
|
63
|
+
throw new error_1.CodeQRError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
64
64
|
};
|
|
65
65
|
exports.coerceInteger = coerceInteger;
|
|
66
66
|
const coerceFloat = (value) => {
|
|
@@ -68,7 +68,7 @@ const coerceFloat = (value) => {
|
|
|
68
68
|
return value;
|
|
69
69
|
if (typeof value === 'string')
|
|
70
70
|
return parseFloat(value);
|
|
71
|
-
throw new error_1.
|
|
71
|
+
throw new error_1.CodeQRError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
72
72
|
};
|
|
73
73
|
exports.coerceFloat = coerceFloat;
|
|
74
74
|
const coerceBoolean = (value) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
import {
|
|
2
|
+
import { CodeQRError } from "../../core/error.mjs";
|
|
3
3
|
// https://url.spec.whatwg.org/#url-scheme-string
|
|
4
4
|
const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
|
|
5
5
|
export const isAbsoluteURL = (url) => {
|
|
@@ -31,16 +31,16 @@ export function isObj(obj) {
|
|
|
31
31
|
}
|
|
32
32
|
export const ensurePresent = (value) => {
|
|
33
33
|
if (value == null) {
|
|
34
|
-
throw new
|
|
34
|
+
throw new CodeQRError(`Expected a value to be given but received ${value} instead.`);
|
|
35
35
|
}
|
|
36
36
|
return value;
|
|
37
37
|
};
|
|
38
38
|
export const validatePositiveInteger = (name, n) => {
|
|
39
39
|
if (typeof n !== 'number' || !Number.isInteger(n)) {
|
|
40
|
-
throw new
|
|
40
|
+
throw new CodeQRError(`${name} must be an integer`);
|
|
41
41
|
}
|
|
42
42
|
if (n < 0) {
|
|
43
|
-
throw new
|
|
43
|
+
throw new CodeQRError(`${name} must be a positive integer`);
|
|
44
44
|
}
|
|
45
45
|
return n;
|
|
46
46
|
};
|
|
@@ -49,14 +49,14 @@ export const coerceInteger = (value) => {
|
|
|
49
49
|
return Math.round(value);
|
|
50
50
|
if (typeof value === 'string')
|
|
51
51
|
return parseInt(value, 10);
|
|
52
|
-
throw new
|
|
52
|
+
throw new CodeQRError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
53
53
|
};
|
|
54
54
|
export const coerceFloat = (value) => {
|
|
55
55
|
if (typeof value === 'number')
|
|
56
56
|
return value;
|
|
57
57
|
if (typeof value === 'string')
|
|
58
58
|
return parseFloat(value);
|
|
59
|
-
throw new
|
|
59
|
+
throw new CodeQRError(`Could not coerce ${value} (type: ${typeof value}) into a number`);
|
|
60
60
|
};
|
|
61
61
|
export const coerceBoolean = (value) => {
|
|
62
62
|
if (typeof value === 'boolean')
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeqr/ts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The official TypeScript library for the
|
|
5
|
-
"author": "
|
|
3
|
+
"version": "0.25.0",
|
|
4
|
+
"description": "The official TypeScript library for the CodeQR API",
|
|
5
|
+
"author": "CodeQR <contact@codeqr.io>",
|
|
6
6
|
"types": "./index.d.ts",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"type": "commonjs",
|