@puntjes/sdk 0.0.0-stage → 2.0.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/LICENSE +20 -0
- package/README.md +152 -2
- package/dist/auth/token-source.d.ts +20 -0
- package/dist/auth/token-source.js +105 -0
- package/dist/auth/token-store.d.ts +21 -0
- package/dist/auth/token-store.js +13 -0
- package/dist/create-puntjes.d.ts +25 -0
- package/dist/create-puntjes.js +48 -0
- package/dist/errors.d.ts +55 -0
- package/dist/errors.js +60 -0
- package/dist/generated/client/client.gen.d.ts +2 -0
- package/dist/generated/client/client.gen.js +216 -0
- package/dist/generated/client/index.d.ts +10 -0
- package/dist/generated/client/index.js +6 -0
- package/dist/generated/client/types.gen.d.ts +120 -0
- package/dist/generated/client/types.gen.js +2 -0
- package/dist/generated/client/utils.gen.d.ts +37 -0
- package/dist/generated/client/utils.gen.js +228 -0
- package/dist/generated/client.gen.d.ts +12 -0
- package/dist/generated/client.gen.js +3 -0
- package/dist/generated/core/auth.gen.d.ts +25 -0
- package/dist/generated/core/auth.gen.js +14 -0
- package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
- package/dist/generated/core/bodySerializer.gen.js +57 -0
- package/dist/generated/core/params.gen.d.ts +43 -0
- package/dist/generated/core/params.gen.js +109 -0
- package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
- package/dist/generated/core/pathSerializer.gen.js +106 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/generated/core/queryKeySerializer.gen.js +92 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/generated/core/serverSentEvents.gen.js +132 -0
- package/dist/generated/core/types.gen.d.ts +83 -0
- package/dist/generated/core/types.gen.js +2 -0
- package/dist/generated/core/utils.gen.d.ts +19 -0
- package/dist/generated/core/utils.gen.js +87 -0
- package/dist/generated/error-codes.gen.d.ts +56 -0
- package/dist/generated/error-codes.gen.js +110 -0
- package/dist/generated/index.d.ts +2 -0
- package/dist/generated/index.js +2 -0
- package/dist/generated/sdk.gen.d.ts +69 -0
- package/dist/generated/sdk.gen.js +323 -0
- package/dist/generated/types.gen.d.ts +2794 -0
- package/dist/generated/types.gen.js +2 -0
- package/dist/http/auth-fetch.d.ts +8 -0
- package/dist/http/auth-fetch.js +24 -0
- package/dist/http/error-body.d.ts +18 -0
- package/dist/http/error-body.js +75 -0
- package/dist/http/error-fetch.d.ts +3 -0
- package/dist/http/error-fetch.js +22 -0
- package/dist/http/fetch.d.ts +9 -0
- package/dist/http/fetch.js +4 -0
- package/dist/http/retry-fetch.d.ts +16 -0
- package/dist/http/retry-fetch.js +93 -0
- package/dist/idempotency-key.d.ts +2 -0
- package/dist/idempotency-key.js +4 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8 -0
- package/dist/paginate.d.ts +10 -0
- package/dist/paginate.js +16 -0
- package/dist/wallet-pass.d.ts +5 -0
- package/dist/wallet-pass.js +12 -0
- package/package.json +45 -4
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TokenSource } from '../auth/token-source.js';
|
|
2
|
+
import type { Fetch } from './fetch.js';
|
|
3
|
+
/**
|
|
4
|
+
* The innermost layer. The generated client marks each operation that needs a token with a placeholder header; this
|
|
5
|
+
* layer puts the current token there on every attempt, with one new grant and one resend after a 401. A public
|
|
6
|
+
* operation carries no header and passes untouched.
|
|
7
|
+
*/
|
|
8
|
+
export declare function authFetch(next: Fetch, tokens: TokenSource): Fetch;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The innermost layer. The generated client marks each operation that needs a token with a placeholder header; this
|
|
3
|
+
* layer puts the current token there on every attempt, with one new grant and one resend after a 401. A public
|
|
4
|
+
* operation carries no header and passes untouched.
|
|
5
|
+
*/
|
|
6
|
+
export function authFetch(next, tokens) {
|
|
7
|
+
return async (request, init) => {
|
|
8
|
+
if (!request.headers.has('Authorization')) {
|
|
9
|
+
return next(request, init);
|
|
10
|
+
}
|
|
11
|
+
const token = await tokens.get();
|
|
12
|
+
const response = await next(signed(request.clone(), token), init);
|
|
13
|
+
if (response.status !== 401) {
|
|
14
|
+
return response;
|
|
15
|
+
}
|
|
16
|
+
await tokens.forget(token);
|
|
17
|
+
return next(signed(request, await tokens.get()), init);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function signed(request, token) {
|
|
21
|
+
const headers = new Headers(request.headers);
|
|
22
|
+
headers.set('Authorization', `Bearer ${token}`);
|
|
23
|
+
return new Request(request, { headers });
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PuntjesError } from '../errors.js';
|
|
2
|
+
export declare const RATE_LIMITED = "RATE_LIMITED";
|
|
3
|
+
export declare const PLAN_LIMIT_EXCEEDED = "PLAN_LIMIT_EXCEEDED";
|
|
4
|
+
export interface ErrorBody {
|
|
5
|
+
status: number;
|
|
6
|
+
code: string;
|
|
7
|
+
message: string;
|
|
8
|
+
requestId: string | null;
|
|
9
|
+
details: Record<string, unknown> | null;
|
|
10
|
+
isJson: boolean;
|
|
11
|
+
excerpt: string;
|
|
12
|
+
}
|
|
13
|
+
/** Reads the error envelope of a response that is already buffered. Never throws on a malformed body. */
|
|
14
|
+
export declare function readErrorBody(response: Response): Promise<ErrorBody>;
|
|
15
|
+
/** The family error for a non-2xx response. */
|
|
16
|
+
export declare function toError(response: Response): Promise<PuntjesError>;
|
|
17
|
+
/** The wait a `Retry-After` header asks for, in milliseconds, never negative; null when it says nothing usable. */
|
|
18
|
+
export declare function retryAfter(header: string | null, now: number): number | null;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { AuthenticationError, ConflictError, ForbiddenError, NotFoundError, PlanLimitExceededError, PuntjesError, RateLimitError, ServerError, TransportError, ValidationError, } from '../errors.js';
|
|
2
|
+
export const RATE_LIMITED = 'RATE_LIMITED';
|
|
3
|
+
export const PLAN_LIMIT_EXCEEDED = 'PLAN_LIMIT_EXCEEDED';
|
|
4
|
+
/** Reads the error envelope of a response that is already buffered. Never throws on a malformed body. */
|
|
5
|
+
export async function readErrorBody(response) {
|
|
6
|
+
const status = response.status;
|
|
7
|
+
const text = await response.clone().text();
|
|
8
|
+
const excerpt = text.slice(0, 200);
|
|
9
|
+
const fallback = `The Puntjes API returned HTTP ${status}.`;
|
|
10
|
+
const headerId = response.headers.get('X-Request-ID');
|
|
11
|
+
let root;
|
|
12
|
+
try {
|
|
13
|
+
root = JSON.parse(text);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return { status, code: 'NON_JSON_RESPONSE', message: fallback, requestId: headerId, details: null, isJson: false, excerpt };
|
|
17
|
+
}
|
|
18
|
+
const error = isObject(root) && isObject(root.error) ? root.error : {};
|
|
19
|
+
return {
|
|
20
|
+
status,
|
|
21
|
+
code: stringOrNull(error.code) ?? 'UNKNOWN_ERROR',
|
|
22
|
+
message: stringOrNull(error.message) ?? fallback,
|
|
23
|
+
requestId: stringOrNull(error.request_id) ?? headerId,
|
|
24
|
+
details: isObject(error.details) ? error.details : null,
|
|
25
|
+
isJson: true,
|
|
26
|
+
excerpt,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** The family error for a non-2xx response. */
|
|
30
|
+
export async function toError(response) {
|
|
31
|
+
const body = await readErrorBody(response);
|
|
32
|
+
if (!body.isJson) {
|
|
33
|
+
return body.status >= 500
|
|
34
|
+
? new ServerError(`The Puntjes API returned HTTP ${body.status} with a non-JSON body, likely a proxy answering for a failing backend: ${body.excerpt}`, { status: body.status, rawCode: body.code, requestId: body.requestId })
|
|
35
|
+
: new TransportError(`The Puntjes API returned a non-JSON error response (HTTP ${body.status}): ${body.excerpt}`, {
|
|
36
|
+
status: body.status,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
const init = { status: body.status, rawCode: body.code, requestId: body.requestId, details: body.details };
|
|
40
|
+
const { status, code, message } = body;
|
|
41
|
+
if (status === 429 && code === PLAN_LIMIT_EXCEEDED)
|
|
42
|
+
return new PlanLimitExceededError(message, init);
|
|
43
|
+
if (status === 429)
|
|
44
|
+
return new RateLimitError(message, { ...init, retryAfter: retryAfter(response.headers.get('Retry-After'), Date.now()) });
|
|
45
|
+
if (status === 422 && code === 'VALIDATION_ERROR')
|
|
46
|
+
return new ValidationError(message, init);
|
|
47
|
+
if (status === 401)
|
|
48
|
+
return new AuthenticationError(message, init);
|
|
49
|
+
if (status === 403)
|
|
50
|
+
return new ForbiddenError(message, init);
|
|
51
|
+
if (status === 404)
|
|
52
|
+
return new NotFoundError(message, init);
|
|
53
|
+
if (status === 409)
|
|
54
|
+
return new ConflictError(message, init);
|
|
55
|
+
if (status >= 500)
|
|
56
|
+
return new ServerError(message, init);
|
|
57
|
+
return new PuntjesError(message, init);
|
|
58
|
+
}
|
|
59
|
+
/** The wait a `Retry-After` header asks for, in milliseconds, never negative; null when it says nothing usable. */
|
|
60
|
+
export function retryAfter(header, now) {
|
|
61
|
+
if (header === null || header.trim() === '') {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
if (/^\d+$/.test(header.trim())) {
|
|
65
|
+
return Number(header.trim()) * 1000;
|
|
66
|
+
}
|
|
67
|
+
const date = Date.parse(header);
|
|
68
|
+
return Number.isNaN(date) ? null : Math.max(0, date - now);
|
|
69
|
+
}
|
|
70
|
+
function isObject(value) {
|
|
71
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
72
|
+
}
|
|
73
|
+
function stringOrNull(value) {
|
|
74
|
+
return typeof value === 'string' ? value : null;
|
|
75
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TransportError } from '../errors.js';
|
|
2
|
+
import { isNetworkFailure } from './retry-fetch.js';
|
|
3
|
+
import { toError } from './error-body.js';
|
|
4
|
+
/** The outermost layer: a non-2xx response becomes its family error, a failed connection a `TransportError`. */
|
|
5
|
+
export function errorFetch(next) {
|
|
6
|
+
return async (request, init) => {
|
|
7
|
+
let response;
|
|
8
|
+
try {
|
|
9
|
+
response = await next(request, init);
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (!isNetworkFailure(error) || request.signal.aborted) {
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
15
|
+
throw new TransportError(`The Puntjes API could not be reached: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
16
|
+
}
|
|
17
|
+
if (response.ok) {
|
|
18
|
+
return response;
|
|
19
|
+
}
|
|
20
|
+
throw await toError(response);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One layer of the transport. `signal` travels beside the request, never inside it: a signal a `Request` derives from
|
|
3
|
+
* its parent is lost when garbage collection takes an intermediate `Request`, and the abort then never arrives.
|
|
4
|
+
*/
|
|
5
|
+
export type Fetch = (request: Request, init?: {
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
}) => Promise<Response>;
|
|
8
|
+
/** Lets a layer chain that takes a `Request` stand where the generated client expects the global `fetch`. */
|
|
9
|
+
export declare function asGlobalFetch(chain: Fetch): typeof fetch;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Fetch } from './fetch.js';
|
|
2
|
+
export interface RetryOptions {
|
|
3
|
+
maxRetries: number;
|
|
4
|
+
retryBaseDelay: number;
|
|
5
|
+
timeout: number;
|
|
6
|
+
sleep: (ms: number, signal: AbortSignal) => Promise<void>;
|
|
7
|
+
/** The token grant repeats on every method, because a grant changes nothing on the server. */
|
|
8
|
+
repeatEveryMethod?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Sends a request again after a network failure, a timed-out attempt, a 5xx or a RATE_LIMITED 429. A POST repeats
|
|
12
|
+
* only when its JSON body carries an `idempotency_key`. Every attempt sends a fresh copy and buffers the answer.
|
|
13
|
+
*/
|
|
14
|
+
export declare function retryFetch(next: Fetch, options: RetryOptions): Fetch;
|
|
15
|
+
/** fetch rejects with a TypeError when the connection fails or the body breaks while it is read. */
|
|
16
|
+
export declare function isNetworkFailure(error: unknown): boolean;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { TransportError } from '../errors.js';
|
|
2
|
+
import { RATE_LIMITED, readErrorBody, retryAfter } from './error-body.js';
|
|
3
|
+
const SAFE_METHODS = new Set(['GET', 'HEAD', 'PUT', 'PATCH', 'DELETE']);
|
|
4
|
+
/**
|
|
5
|
+
* Sends a request again after a network failure, a timed-out attempt, a 5xx or a RATE_LIMITED 429. A POST repeats
|
|
6
|
+
* only when its JSON body carries an `idempotency_key`. Every attempt sends a fresh copy and buffers the answer.
|
|
7
|
+
*/
|
|
8
|
+
export function retryFetch(next, options) {
|
|
9
|
+
return async (request) => {
|
|
10
|
+
const body = request.body === null ? null : await request.arrayBuffer();
|
|
11
|
+
const retries = options.repeatEveryMethod || isSafeToRepeat(request.method, body) ? options.maxRetries : 0;
|
|
12
|
+
for (let attempt = 0;; attempt++) {
|
|
13
|
+
const attemptSignal = new AbortController();
|
|
14
|
+
let timedOut = false;
|
|
15
|
+
const timer = setTimeout(() => {
|
|
16
|
+
timedOut = true;
|
|
17
|
+
attemptSignal.abort(new DOMException('The attempt timed out.', 'TimeoutError'));
|
|
18
|
+
}, options.timeout);
|
|
19
|
+
const forwardAbort = () => attemptSignal.abort(request.signal.reason);
|
|
20
|
+
request.signal.addEventListener('abort', forwardAbort, { once: true });
|
|
21
|
+
const signal = attemptSignal.signal;
|
|
22
|
+
let response;
|
|
23
|
+
try {
|
|
24
|
+
if (request.signal.aborted) {
|
|
25
|
+
throw request.signal.reason;
|
|
26
|
+
}
|
|
27
|
+
const sent = await next(withBody(request, body), { signal });
|
|
28
|
+
const buffered = await sent.arrayBuffer();
|
|
29
|
+
response = new Response(buffered.byteLength === 0 ? null : buffered, sent);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (request.signal.aborted) {
|
|
33
|
+
throw request.signal.reason;
|
|
34
|
+
}
|
|
35
|
+
if (!timedOut && !isNetworkFailure(error)) {
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
if (attempt < retries) {
|
|
39
|
+
await options.sleep(delay(options, attempt), request.signal);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (timedOut) {
|
|
43
|
+
throw new TransportError(`The Puntjes API did not answer within ${options.timeout / 1000} seconds.`, { cause: error });
|
|
44
|
+
}
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
request.signal.removeEventListener('abort', forwardAbort);
|
|
50
|
+
}
|
|
51
|
+
if (attempt >= retries || !(await isTransient(response))) {
|
|
52
|
+
return response;
|
|
53
|
+
}
|
|
54
|
+
await options.sleep(retryAfter(response.headers.get('Retry-After'), Date.now()) ?? delay(options, attempt), request.signal);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** fetch rejects with a TypeError when the connection fails or the body breaks while it is read. */
|
|
59
|
+
export function isNetworkFailure(error) {
|
|
60
|
+
return error instanceof TypeError;
|
|
61
|
+
}
|
|
62
|
+
function withBody(request, body) {
|
|
63
|
+
// oxlint-disable-next-line unicorn/no-invalid-fetch-options -- a GET has a null body and takes the first branch
|
|
64
|
+
return body === null ? new Request(request) : new Request(request, { body });
|
|
65
|
+
}
|
|
66
|
+
function isSafeToRepeat(method, body) {
|
|
67
|
+
if (SAFE_METHODS.has(method)) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
return method === 'POST' && carriesIdempotencyKey(body);
|
|
71
|
+
}
|
|
72
|
+
function carriesIdempotencyKey(body) {
|
|
73
|
+
if (body === null || body.byteLength === 0) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
const json = JSON.parse(new TextDecoder().decode(body));
|
|
78
|
+
return typeof json === 'object' && json !== null && typeof json.idempotency_key === 'string'
|
|
79
|
+
&& json.idempotency_key !== '';
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function isTransient(response) {
|
|
86
|
+
if (response.status >= 500) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return response.status === 429 && (await readErrorBody(response)).code === RATE_LIMITED;
|
|
90
|
+
}
|
|
91
|
+
function delay(options, attempt) {
|
|
92
|
+
return options.retryBaseDelay * 2 ** attempt;
|
|
93
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { InMemoryTokenStore, type AccessToken, type TokenStore } from './auth/token-store.js';
|
|
2
|
+
export { createPuntjes, DEFAULT_BASE_URL, type PuntjesOptions } from './create-puntjes.js';
|
|
3
|
+
export { AuthenticationError, ConflictError, ForbiddenError, NotFoundError, PlanLimitExceededError, PuntjesError, RateLimitError, ServerError, TransportError, ValidationError, } from './errors.js';
|
|
4
|
+
export { idempotencyKey } from './idempotency-key.js';
|
|
5
|
+
export { paginate, type Page } from './paginate.js';
|
|
6
|
+
export { walletPass } from './wallet-pass.js';
|
|
7
|
+
export { ErrorCode, errorCodeStatus, isErrorCode } from './generated/error-codes.gen.js';
|
|
8
|
+
export { PuntjesApi } from './generated/sdk.gen.js';
|
|
9
|
+
export type * from './generated/types.gen.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { InMemoryTokenStore } from './auth/token-store.js';
|
|
2
|
+
export { createPuntjes, DEFAULT_BASE_URL } from './create-puntjes.js';
|
|
3
|
+
export { AuthenticationError, ConflictError, ForbiddenError, NotFoundError, PlanLimitExceededError, PuntjesError, RateLimitError, ServerError, TransportError, ValidationError, } from './errors.js';
|
|
4
|
+
export { idempotencyKey } from './idempotency-key.js';
|
|
5
|
+
export { paginate } from './paginate.js';
|
|
6
|
+
export { walletPass } from './wallet-pass.js';
|
|
7
|
+
export { ErrorCode, errorCodeStatus, isErrorCode } from './generated/error-codes.gen.js';
|
|
8
|
+
export { PuntjesApi } from './generated/sdk.gen.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PaginationMeta } from './generated/types.gen.js';
|
|
2
|
+
export interface Page<T> {
|
|
3
|
+
data: T[];
|
|
4
|
+
meta: PaginationMeta;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Walks a paginated call page by page from page 1, until the last page in its meta, or until the server answers a page
|
|
8
|
+
* other than the one asked for.
|
|
9
|
+
*/
|
|
10
|
+
export declare function paginate<T>(fetchPage: (page: number) => Promise<Page<T>>): AsyncGenerator<T>;
|
package/dist/paginate.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walks a paginated call page by page from page 1, until the last page in its meta, or until the server answers a page
|
|
3
|
+
* other than the one asked for.
|
|
4
|
+
*/
|
|
5
|
+
export async function* paginate(fetchPage) {
|
|
6
|
+
for (let page = 1;; page++) {
|
|
7
|
+
const { data, meta } = await fetchPage(page);
|
|
8
|
+
if (meta.current_page !== page) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
yield* data;
|
|
12
|
+
if (page >= meta.last_page) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PuntjesApi } from './generated/sdk.gen.js';
|
|
2
|
+
/** Downloads a customer's wallet pass file. The generated client knows only the JSON answer of this call. */
|
|
3
|
+
export declare const walletPass: {
|
|
4
|
+
apple(puntjes: PuntjesApi, customer: string): Promise<Uint8Array>;
|
|
5
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Downloads a customer's wallet pass file. The generated client knows only the JSON answer of this call. */
|
|
2
|
+
export const walletPass = {
|
|
3
|
+
async apple(puntjes, customer) {
|
|
4
|
+
const { data } = await puntjes.downloadWalletPass({
|
|
5
|
+
path: { customer },
|
|
6
|
+
query: { platform: 'apple' },
|
|
7
|
+
headers: { Accept: 'application/vnd.apple.pkpass' },
|
|
8
|
+
parseAs: 'arrayBuffer',
|
|
9
|
+
});
|
|
10
|
+
return new Uint8Array(data);
|
|
11
|
+
},
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puntjes/sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "The official TypeScript client for the Puntjes loyalty API.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/PuntjesApp/puntjes-typescript.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://puntjes.app/docs/sdks",
|
|
12
|
+
"bugs": "https://github.com/PuntjesApp/puntjes-typescript/issues",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"puntjes",
|
|
15
|
+
"loyalty",
|
|
16
|
+
"api",
|
|
17
|
+
"sdk"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20"
|
|
21
|
+
},
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"scripts": {
|
|
33
|
+
"generate": "openapi-ts && node tools/codegen.ts",
|
|
34
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"lint": "oxlint src tools tests examples --ignore-pattern 'src/generated/**'",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"prepublishOnly": "npm run build"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@hey-api/openapi-ts": "0.99.0",
|
|
42
|
+
"@types/node": "22.20.5",
|
|
43
|
+
"oxlint": "1.87.0",
|
|
44
|
+
"typescript": "5.9.3",
|
|
45
|
+
"vitest": "5.0.3"
|
|
46
|
+
}
|
|
47
|
+
}
|