@ordersail/storefront-sdk 0.6.0 → 0.8.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/README.md +82 -12
- package/dist/http.d.ts +27 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +71 -20
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/resources/brands.d.ts +2 -2
- package/dist/resources/brands.d.ts.map +1 -1
- package/dist/resources/brands.js +2 -2
- package/dist/resources/brands.js.map +1 -1
- package/dist/resources/cart.d.ts.map +1 -1
- package/dist/resources/cart.js +5 -5
- package/dist/resources/cart.js.map +1 -1
- package/dist/resources/categories.d.ts +2 -2
- package/dist/resources/categories.d.ts.map +1 -1
- package/dist/resources/categories.js +2 -2
- package/dist/resources/categories.js.map +1 -1
- package/dist/resources/checkout.js +4 -4
- package/dist/resources/checkout.js.map +1 -1
- package/dist/resources/customer.d.ts +1 -1
- package/dist/resources/customer.d.ts.map +1 -1
- package/dist/resources/customer.js +4 -4
- package/dist/resources/customer.js.map +1 -1
- package/dist/resources/products.d.ts +1 -1
- package/dist/resources/products.d.ts.map +1 -1
- package/dist/resources/products.js +2 -2
- package/dist/resources/products.js.map +1 -1
- package/dist/types.gen.d.ts +289 -115
- package/dist/types.gen.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ Inside this monorepo it's consumed via the npm workspace protocol instead
|
|
|
25
25
|
import { StorefrontClient, ApiError } from "@ordersail/storefront-sdk";
|
|
26
26
|
|
|
27
27
|
const storefront = new StorefrontClient(
|
|
28
|
-
"https://
|
|
28
|
+
"https://storefront.ordersail.com",
|
|
29
29
|
"sfk_...", // your account's app key — see "Auth model" below
|
|
30
30
|
);
|
|
31
31
|
|
|
@@ -40,6 +40,40 @@ try {
|
|
|
40
40
|
}
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
`baseUrl` is the bare host. The API is versioned in its paths (every route
|
|
44
|
+
lives under `/v1`), and the SDK adds that prefix itself, so a given SDK
|
|
45
|
+
release always talks to the API version it was generated from.
|
|
46
|
+
|
|
47
|
+
### Upgrading from 0.7.x
|
|
48
|
+
|
|
49
|
+
**0.8.0 changes how errors arrive.** Every API error now has one body, and
|
|
50
|
+
`ApiError` carries it as typed fields: branch on `err.code` (see
|
|
51
|
+
[Error handling](#error-handling)) instead of `err.status` or the message.
|
|
52
|
+
Two behaviours change with it:
|
|
53
|
+
|
|
54
|
+
- The client refreshes the customer's token only on `invalid_access_token`.
|
|
55
|
+
A bad app key or wrong credentials no longer trigger a refresh and retry.
|
|
56
|
+
- `ApiError`'s constructor changed. If you construct one yourself (in tests,
|
|
57
|
+
say), pass `(message, status, body?)`.
|
|
58
|
+
|
|
59
|
+
0.7.x clients keep working against the new API, but every `ApiError.message`
|
|
60
|
+
is the generic `Request failed (<status>)`.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm install @ordersail/storefront-sdk@^0.8.0
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Upgrading from 0.6.x
|
|
67
|
+
|
|
68
|
+
**0.7.0 is a breaking change.** storefront-api now serves every route under
|
|
69
|
+
`/v1`, so 0.6.x clients, which call unprefixed paths, get `404` on every
|
|
70
|
+
request. Upgrading is just the package bump; `baseUrl` stays the bare host
|
|
71
|
+
(don't append `/v1` yourself):
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install @ordersail/storefront-sdk@^0.7.0
|
|
75
|
+
```
|
|
76
|
+
|
|
43
77
|
## Resources
|
|
44
78
|
|
|
45
79
|
| Resource | Method | Throws `ApiError`? |
|
|
@@ -66,22 +100,58 @@ try {
|
|
|
66
100
|
|
|
67
101
|
## Error handling
|
|
68
102
|
|
|
69
|
-
Every
|
|
70
|
-
|
|
103
|
+
Every failed call throws `ApiError` (from `@ordersail/storefront-sdk`). Every
|
|
104
|
+
API error has the same shape, so one handler covers them all:
|
|
71
105
|
|
|
72
106
|
```ts
|
|
73
107
|
export class ApiError extends Error {
|
|
74
|
-
readonly status: number; // the HTTP status
|
|
75
|
-
readonly
|
|
108
|
+
readonly status: number; // the HTTP status
|
|
109
|
+
readonly code: ApiErrorCode | undefined; // what to branch on, e.g. "email_taken"
|
|
110
|
+
readonly type: ApiErrorType | undefined; // the broad category, e.g. "invalid_request_error"
|
|
111
|
+
readonly message: string; // for people — show it, never parse it
|
|
112
|
+
readonly param: string | undefined; // the request field at fault, when there is one
|
|
113
|
+
readonly details: Record<string, unknown> | undefined; // data specific to the code
|
|
114
|
+
readonly requestId: string | undefined; // quote this when reporting a problem
|
|
115
|
+
readonly docUrl: string | undefined; // the code's reference page
|
|
76
116
|
}
|
|
77
117
|
```
|
|
78
118
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
119
|
+
**Branch on `code`, never on `message`.** Codes are part of the SDK's
|
|
120
|
+
contract; messages can be reworded at any time. `ApiErrorCode` is the union of
|
|
121
|
+
every code the API returns, and `isApiError` narrows a caught value:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { isApiError } from "@ordersail/storefront-sdk";
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
await client.signUp(form);
|
|
128
|
+
} catch (err) {
|
|
129
|
+
if (isApiError(err, "email_taken")) {
|
|
130
|
+
setFieldError(err.param ?? "email", "That email already has an account.");
|
|
131
|
+
} else if (isApiError(err, "validation_failed")) {
|
|
132
|
+
// details.fields lists every failing field as { param, message }
|
|
133
|
+
for (const { param, message } of err.details.fields) setFieldError(param, message);
|
|
134
|
+
} else {
|
|
135
|
+
throw err;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
A few codes worth knowing:
|
|
141
|
+
|
|
142
|
+
| Code | When |
|
|
143
|
+
|---|---|
|
|
144
|
+
| `invalid_app_key` | The `x-app-key` is missing, wrong or revoked. A configuration problem — fix the key. |
|
|
145
|
+
| `invalid_access_token` | The customer's access token is missing, expired or invalid. The client refreshes and retries this one for you. |
|
|
146
|
+
| `invalid_credentials` | `signIn` with a wrong email or password. |
|
|
147
|
+
| `email_taken` | `signUp` (or a profile update) with an email that already has an account. |
|
|
148
|
+
| `validation_failed` | A request field failed validation; `param` is the first, `details.fields` lists all. |
|
|
149
|
+
| `not_found` | The resource doesn't exist (single-resource reads return `undefined` instead). |
|
|
150
|
+
| `internal_error` | Something failed on OrderSail's side. The message is always generic; quote `requestId`. |
|
|
151
|
+
|
|
152
|
+
`code` is `undefined` only when the response carried no error body at all (a
|
|
153
|
+
proxy's or the network's error page); `message` is then
|
|
154
|
+
`` `Request failed (${status})` ``.
|
|
85
155
|
|
|
86
156
|
## Auth model
|
|
87
157
|
|
|
@@ -113,7 +183,7 @@ reload, not `client.refreshToken` read once:
|
|
|
113
183
|
|
|
114
184
|
```ts
|
|
115
185
|
const storefront = new StorefrontClient(
|
|
116
|
-
"https://
|
|
186
|
+
"https://storefront.ordersail.com",
|
|
117
187
|
"sfk_...",
|
|
118
188
|
undefined, // cartToken — restore the same way if you have one saved
|
|
119
189
|
localStorage.getItem("refreshToken") ?? undefined,
|
package/dist/http.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { components } from "./types.gen.js";
|
|
1
2
|
export type DoRequest<T> = () => Promise<{
|
|
2
3
|
data?: T;
|
|
3
4
|
error?: unknown;
|
|
@@ -8,10 +9,34 @@ export type DoFn = <T>(request: DoRequest<T>) => Promise<{
|
|
|
8
9
|
error?: unknown;
|
|
9
10
|
response: Response;
|
|
10
11
|
}>;
|
|
12
|
+
export type ErrorBody = components["schemas"]["ErrorResponse"]["error"];
|
|
13
|
+
export type ApiErrorCode = ErrorBody["code"];
|
|
14
|
+
export type ApiErrorType = ErrorBody["type"];
|
|
11
15
|
export declare class ApiError extends Error {
|
|
12
16
|
readonly status: number;
|
|
13
|
-
|
|
17
|
+
readonly type: ApiErrorType | undefined;
|
|
18
|
+
readonly code: ApiErrorCode | undefined;
|
|
19
|
+
readonly param: string | undefined;
|
|
20
|
+
readonly docUrl: string | undefined;
|
|
21
|
+
readonly requestId: string | undefined;
|
|
22
|
+
readonly details: Record<string, unknown> | undefined;
|
|
23
|
+
constructor(message: string, status: number, body?: ErrorBody);
|
|
14
24
|
}
|
|
25
|
+
export interface ApiErrorDetails {
|
|
26
|
+
validation_failed: {
|
|
27
|
+
fields: {
|
|
28
|
+
param: string;
|
|
29
|
+
message: string;
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
type DetailsFor<C extends ApiErrorCode> = C extends keyof ApiErrorDetails ? ApiErrorDetails[C] : Record<string, unknown> | undefined;
|
|
34
|
+
export declare function isApiError<C extends ApiErrorCode>(err: unknown, code?: C): err is ApiError & {
|
|
35
|
+
code: C;
|
|
36
|
+
details: DetailsFor<C>;
|
|
37
|
+
};
|
|
38
|
+
export declare function readErrorBody(body: unknown): ErrorBody | undefined;
|
|
39
|
+
export declare function isStaleTokenError(body: unknown): boolean;
|
|
15
40
|
export declare function unwrap<T>(result: {
|
|
16
41
|
data?: T;
|
|
17
42
|
error?: unknown;
|
|
@@ -22,4 +47,5 @@ export declare function unwrapOrUndefinedOn<T>(result: {
|
|
|
22
47
|
error?: unknown;
|
|
23
48
|
response: Response;
|
|
24
49
|
}, expectedStatus: number): T | undefined;
|
|
50
|
+
export {};
|
|
25
51
|
//# sourceMappingURL=http.d.ts.map
|
package/dist/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC;IACvC,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,OAAO,C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AAUD,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,EACzD,cAAc,EAAE,MAAM,GACrB,CAAC,GAAG,SAAS,CAKf"}
|
package/dist/http.js
CHANGED
|
@@ -1,41 +1,92 @@
|
|
|
1
|
-
// A non-2xx response from the API.
|
|
2
|
-
//
|
|
1
|
+
// A non-2xx response from the API.
|
|
2
|
+
//
|
|
3
|
+
// - `code` is what to branch on (`email_taken`, `invalid_credentials`, …). It's
|
|
4
|
+
// undefined only when the response carried no error body at all (a proxy's
|
|
5
|
+
// or the network's error page).
|
|
6
|
+
// - `type` is the broad category (`invalid_request_error`, `api_error`, …).
|
|
7
|
+
// - `message` is the server's message, or `Request failed (<status>)` when
|
|
8
|
+
// there was no error body.
|
|
9
|
+
// - `param` names the request field at fault, when there is one; on
|
|
10
|
+
// `validation_failed`, `details.fields` lists every failing field.
|
|
11
|
+
// - `requestId` is the request's x-request-id: quote it when reporting a
|
|
12
|
+
// problem.
|
|
3
13
|
export class ApiError extends Error {
|
|
4
14
|
status;
|
|
5
|
-
|
|
15
|
+
type;
|
|
16
|
+
code;
|
|
17
|
+
param;
|
|
18
|
+
docUrl;
|
|
19
|
+
requestId;
|
|
20
|
+
details;
|
|
21
|
+
constructor(message, status, body) {
|
|
6
22
|
super(message);
|
|
7
|
-
this.status = status;
|
|
8
23
|
this.name = "ApiError";
|
|
24
|
+
this.status = status;
|
|
25
|
+
this.type = body?.type;
|
|
26
|
+
this.code = body?.code;
|
|
27
|
+
this.param = body?.param;
|
|
28
|
+
this.docUrl = body?.doc_url;
|
|
29
|
+
this.requestId = body?.request_id ?? undefined;
|
|
30
|
+
this.details = body?.details;
|
|
9
31
|
}
|
|
10
32
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
33
|
+
// Narrows an unknown caught value to an ApiError, optionally with a given
|
|
34
|
+
// code, and narrows `details` to that code's shape:
|
|
35
|
+
//
|
|
36
|
+
// catch (err) {
|
|
37
|
+
// if (isApiError(err, "validation_failed")) {
|
|
38
|
+
// for (const { param, message } of err.details.fields) showFieldError(param, message);
|
|
39
|
+
// }
|
|
40
|
+
// }
|
|
41
|
+
export function isApiError(err, code) {
|
|
42
|
+
return err instanceof ApiError && (code === undefined || err.code === code);
|
|
43
|
+
}
|
|
44
|
+
// The envelope's `error` object, or undefined when the body isn't one.
|
|
45
|
+
export function readErrorBody(body) {
|
|
46
|
+
if (!body || typeof body !== "object" || !("error" in body))
|
|
47
|
+
return undefined;
|
|
48
|
+
const error = body.error;
|
|
49
|
+
if (!error || typeof error !== "object")
|
|
50
|
+
return undefined;
|
|
51
|
+
const { code, message } = error;
|
|
52
|
+
return typeof code === "string" && typeof message === "string"
|
|
53
|
+
? error
|
|
15
54
|
: undefined;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
55
|
+
}
|
|
56
|
+
// Whether a 401 is one a token refresh could fix: the customer guard's
|
|
57
|
+
// `invalid_access_token`. Any other 401 — a bad app key, wrong credentials —
|
|
58
|
+
// would fail again after a refresh.
|
|
59
|
+
export function isStaleTokenError(body) {
|
|
60
|
+
return readErrorBody(body)?.code === "invalid_access_token";
|
|
61
|
+
}
|
|
62
|
+
function toApiError(result) {
|
|
63
|
+
const body = readErrorBody(result.error);
|
|
64
|
+
return new ApiError(body?.message ?? `Request failed (${result.response.status})`, result.response.status, body);
|
|
21
65
|
}
|
|
22
66
|
// openapi-fetch resolves non-2xx as { error } rather than throwing. Resource
|
|
23
|
-
// methods
|
|
24
|
-
//
|
|
67
|
+
// methods use this so callers can `try/catch` an ApiError.
|
|
68
|
+
//
|
|
69
|
+
// Success is `response.ok`, not "data is defined": an endpoint with no body
|
|
70
|
+
// (204) legitimately resolves with `data: undefined` on success.
|
|
25
71
|
export function unwrap(result) {
|
|
26
|
-
if (result.
|
|
72
|
+
if (result.response.ok)
|
|
27
73
|
return result.data;
|
|
28
|
-
throw
|
|
74
|
+
throw toApiError(result);
|
|
29
75
|
}
|
|
30
76
|
// A few reads have exactly one well-understood "no data" outcome (a lookup
|
|
31
77
|
// miss, or "not currently signed in") — anything else is a real failure and
|
|
32
78
|
// should surface as ApiError just like a mutation, not collapse to the same
|
|
33
79
|
// undefined a caller can't distinguish from the expected case.
|
|
80
|
+
//
|
|
81
|
+
// A bad app key is never the expected outcome, even on a read whose expected
|
|
82
|
+
// status is 401: it's a misconfigured integration, and reading it as "not
|
|
83
|
+
// signed in" would hide that.
|
|
34
84
|
export function unwrapOrUndefinedOn(result, expectedStatus) {
|
|
35
|
-
if (result.
|
|
85
|
+
if (result.response.ok)
|
|
36
86
|
return result.data;
|
|
37
|
-
|
|
87
|
+
const misconfigured = readErrorBody(result.error)?.code === "invalid_app_key";
|
|
88
|
+
if (result.response.status === expectedStatus && !misconfigured)
|
|
38
89
|
return undefined;
|
|
39
|
-
throw
|
|
90
|
+
throw toApiError(result);
|
|
40
91
|
}
|
|
41
92
|
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAuBA,mCAAmC;AACnC,EAAE;AACF,gFAAgF;AAChF,6EAA6E;AAC7E,kCAAkC;AAClC,4EAA4E;AAC5E,2EAA2E;AAC3E,6BAA6B;AAC7B,oEAAoE;AACpE,qEAAqE;AACrE,yEAAyE;AACzE,aAAa;AACb,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,MAAM,CAAS;IACf,IAAI,CAA2B;IAC/B,IAAI,CAA2B;IAC/B,KAAK,CAAqB;IAC1B,MAAM,CAAqB;IAC3B,SAAS,CAAqB;IAC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MAAM,CAAC,CAAC;AAC3B,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Client } from "openapi-fetch";
|
|
2
2
|
import type { paths, components } from "./types.gen.js";
|
|
3
|
-
export { ApiError } from "./http.js";
|
|
3
|
+
export { ApiError, isApiError, type ApiErrorCode, type ApiErrorDetails, type ApiErrorType, type ErrorBody, } from "./http.js";
|
|
4
4
|
import { createProductsResource } from "./resources/products.js";
|
|
5
5
|
import { createCategoriesResource } from "./resources/categories.js";
|
|
6
6
|
import { createBrandsResource } from "./resources/brands.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAqB,EAAE,KAAK,MAAM,EAAmB,MAAM,eAAe,CAAC;AAC3E,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAqB,EAAE,KAAK,MAAM,EAAmB,MAAM,eAAe,CAAC;AAC3E,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAOxD,OAAO,EACL,QAAQ,EACR,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,SAAS,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAA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E,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;IACpD,QAAQ,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;IAIpD,OAAO,CAAC,cAAc,CAKpB;gBAGA,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,uBAAuB;IAkC7B,MAAM,CAAC,MAAM,EAAE,iBAAiB;IAYhC,MAAM,CAAC,WAAW,EAAE,iBAAiB;IA2B3C,kBAAkB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;YAWnC,kBAAkB;IA2B1B,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB7B,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,iBAAiB;YAQX,EAAE;CAiBjB"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import createClient, {} from "openapi-fetch";
|
|
2
|
-
import { unwrap, unwrapOrUndefinedOn } from "./http.js";
|
|
3
|
-
export { ApiError } from "./http.js";
|
|
2
|
+
import { isStaleTokenError, unwrap, unwrapOrUndefinedOn, } from "./http.js";
|
|
3
|
+
export { ApiError, isApiError, } from "./http.js";
|
|
4
4
|
import { createProductsResource } from "./resources/products.js";
|
|
5
5
|
import { createCategoriesResource } from "./resources/categories.js";
|
|
6
6
|
import { createBrandsResource } from "./resources/brands.js";
|
|
@@ -73,7 +73,7 @@ export class StorefrontClient {
|
|
|
73
73
|
this.customer = createCustomerResource(this.client, doRequest);
|
|
74
74
|
}
|
|
75
75
|
async signUp(signup) {
|
|
76
|
-
const result = await this.client.POST("/auth/signup", { body: signup });
|
|
76
|
+
const result = await this.client.POST("/v1/auth/signup", { body: signup });
|
|
77
77
|
const tokens = unwrap(result);
|
|
78
78
|
this.supersedeSession();
|
|
79
79
|
this.accessToken = tokens.access_token;
|
|
@@ -84,7 +84,7 @@ export class StorefrontClient {
|
|
|
84
84
|
// sends the current cart token (if any) so the backend can claim the
|
|
85
85
|
// guest cart into the newly-signed-in customer's account
|
|
86
86
|
async signIn(credentials) {
|
|
87
|
-
const result = await this.client.POST("/auth/signin", {
|
|
87
|
+
const result = await this.client.POST("/v1/auth/signin", {
|
|
88
88
|
body: credentials,
|
|
89
89
|
headers: this.cartToken ? { "x-cart-token": this.cartToken } : {},
|
|
90
90
|
});
|
|
@@ -127,7 +127,7 @@ export class StorefrontClient {
|
|
|
127
127
|
return undefined;
|
|
128
128
|
}
|
|
129
129
|
const generation = this.sessionGeneration;
|
|
130
|
-
const result = await this.client.POST("/auth/token/refresh", {
|
|
130
|
+
const result = await this.client.POST("/v1/auth/token/refresh", {
|
|
131
131
|
body: { refresh_token: this.refreshToken },
|
|
132
132
|
});
|
|
133
133
|
// logged out or signed in as someone else while this was in flight —
|
|
@@ -156,7 +156,7 @@ export class StorefrontClient {
|
|
|
156
156
|
this.emitTokensChanged();
|
|
157
157
|
if (refreshToken) {
|
|
158
158
|
try {
|
|
159
|
-
await this.client.POST("/auth/logout", {
|
|
159
|
+
await this.client.POST("/v1/auth/logout", {
|
|
160
160
|
body: { refresh_token: refreshToken },
|
|
161
161
|
});
|
|
162
162
|
}
|
|
@@ -182,7 +182,9 @@ export class StorefrontClient {
|
|
|
182
182
|
async do(request) {
|
|
183
183
|
const accessTokenSent = this.accessToken;
|
|
184
184
|
const result = await request();
|
|
185
|
-
|
|
185
|
+
// only a stale access token is worth a refresh; a bad app key or any
|
|
186
|
+
// other 401 would just fail again
|
|
187
|
+
if (result.response.status === 401 && isStaleTokenError(result.error)) {
|
|
186
188
|
// if another call already refreshed while this one was in flight, its
|
|
187
189
|
// 401 is stale — retry with the new token rather than rotating again
|
|
188
190
|
if (this.accessToken === accessTokenSent) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA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,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAC;IACL,CAAC;IAED,kGAAkG;IAC1F,KAAK,CAAC,EAAE,CACd,OAAyE;QAEzE,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,OAAO,EAAE,CAAC;QAC/B,qEAAqE;QACrE,kCAAkC;QAClC,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACtE,sEAAsE;YACtE,qEAAqE;YACrE,IAAI,IAAI,CAAC,WAAW,KAAK,eAAe,EAAE,CAAC;gBACzC,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAClC,CAAC;YACD,OAAO,MAAM,OAAO,EAAE,CAAC;QACzB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Client } from "openapi-fetch";
|
|
2
2
|
import type { paths } from "../types.gen.js";
|
|
3
3
|
export declare function createBrandsResource(client: Client<paths>): {
|
|
4
|
-
list: (query?: paths["/brands"]["get"]["parameters"]["query"]) => Promise<{
|
|
4
|
+
list: (query?: paths["/v1/brands"]["get"]["parameters"]["query"]) => Promise<{
|
|
5
5
|
items: {
|
|
6
6
|
id: number;
|
|
7
7
|
name: string;
|
|
@@ -11,7 +11,7 @@ export declare function createBrandsResource(client: Client<paths>): {
|
|
|
11
11
|
limit: number;
|
|
12
12
|
offset: number;
|
|
13
13
|
}>;
|
|
14
|
-
getById: (id: number, query?: paths["/brands/{id}"]["get"]["parameters"]["query"]) => Promise<{
|
|
14
|
+
getById: (id: number, query?: paths["/v1/brands/{id}"]["get"]["parameters"]["query"]) => Promise<{
|
|
15
15
|
id: number;
|
|
16
16
|
name: string;
|
|
17
17
|
products: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brands.d.ts","sourceRoot":"","sources":["../../src/resources/brands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC;mBAI7C,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"brands.d.ts","sourceRoot":"","sources":["../../src/resources/brands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC;mBAI7C,KAAK,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC;;;;;;;;;;kBAOpD,MAAM,UACH,KAAK,CAAC,iBAAiB,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;EAWlE"}
|
package/dist/resources/brands.js
CHANGED
|
@@ -3,14 +3,14 @@ export function createBrandsResource(client) {
|
|
|
3
3
|
return {
|
|
4
4
|
// no legitimate "empty" case for a list — any non-2xx is a real failure
|
|
5
5
|
list: async (query = {}) => {
|
|
6
|
-
const result = await client.GET("/brands", { params: { query } });
|
|
6
|
+
const result = await client.GET("/v1/brands", { params: { query } });
|
|
7
7
|
return unwrap(result);
|
|
8
8
|
},
|
|
9
9
|
getById: async (id, query = {}) => {
|
|
10
10
|
const path = {
|
|
11
11
|
id: String(id),
|
|
12
12
|
};
|
|
13
|
-
const result = await client.GET("/brands/{id}", {
|
|
13
|
+
const result = await client.GET("/v1/brands/{id}", {
|
|
14
14
|
params: { path, query },
|
|
15
15
|
});
|
|
16
16
|
return unwrapOrUndefinedOn(result, 404);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brands.js","sourceRoot":"","sources":["../../src/resources/brands.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,UAAU,oBAAoB,CAAC,MAAqB;IACxD,OAAO;QACL,wEAAwE;QACxE,IAAI,EAAE,KAAK,EACT,
|
|
1
|
+
{"version":3,"file":"brands.js","sourceRoot":"","sources":["../../src/resources/brands.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,UAAU,oBAAoB,CAAC,MAAqB;IACxD,OAAO;QACL,wEAAwE;QACxE,IAAI,EAAE,KAAK,EACT,QAA2D,EAAE,EAC7D,EAAE;YACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YACrE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,EAAE,KAAK,EACZ,EAAU,EACV,QAAgE,EAAE,EAClE,EAAE;YACF,MAAM,IAAI,GAA0D;gBAClE,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC;aACf,CAAC;YACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE;gBACjD,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;aACxB,CAAC,CAAC;YACH,OAAO,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC1C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../src/resources/cart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAKzD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,EACrB,YAAY,EAAE,MAAM,MAAM,GAAG,SAAS,EACtC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;oBAoBb,UAAU,CAAC,SAAS,CAAC,CAAC,gBAAgB,CAAC;;
|
|
1
|
+
{"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../src/resources/cart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAKzD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,EACrB,YAAY,EAAE,MAAM,MAAM,GAAG,SAAS,EACtC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;oBAoBb,UAAU,CAAC,SAAS,CAAC,CAAC,gBAAgB,CAAC;;eA4Cs4S,qBAAsB;;;;;;;;;;;;;;;;;;;;;;4BA7B58S,MAAM,QACX,UAAU,CAAC,SAAS,CAAC,CAAC,mBAAmB,CAAC;;;;;;;;;;;;;;;;;;4BAYpB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAevC"}
|
package/dist/resources/cart.js
CHANGED
|
@@ -18,7 +18,7 @@ export function createCartResource(client, getCartToken, setCartToken) {
|
|
|
18
18
|
}
|
|
19
19
|
return {
|
|
20
20
|
addItem: async (body) => {
|
|
21
|
-
const result = await client.POST("/cart/items", {
|
|
21
|
+
const result = await client.POST("/v1/cart/items", {
|
|
22
22
|
body,
|
|
23
23
|
headers: cartHeaders(),
|
|
24
24
|
});
|
|
@@ -26,12 +26,12 @@ export function createCartResource(client, getCartToken, setCartToken) {
|
|
|
26
26
|
},
|
|
27
27
|
// 404 = no cart yet for this token — the everyday first-visit case
|
|
28
28
|
get: async () => {
|
|
29
|
-
const result = await client.GET("/cart", { headers: cartHeaders() });
|
|
29
|
+
const result = await client.GET("/v1/cart", { headers: cartHeaders() });
|
|
30
30
|
return unwrapOrUndefinedOn(result, 404);
|
|
31
31
|
},
|
|
32
32
|
updateItem: async (variantId, body) => {
|
|
33
33
|
const path = { variantId: String(variantId) };
|
|
34
|
-
const result = await client.PATCH("/cart/items/{variantId}", {
|
|
34
|
+
const result = await client.PATCH("/v1/cart/items/{variantId}", {
|
|
35
35
|
params: { path },
|
|
36
36
|
body,
|
|
37
37
|
headers: cartHeaders(),
|
|
@@ -40,14 +40,14 @@ export function createCartResource(client, getCartToken, setCartToken) {
|
|
|
40
40
|
},
|
|
41
41
|
removeItem: async (variantId) => {
|
|
42
42
|
const path = { variantId: String(variantId) };
|
|
43
|
-
const result = await client.DELETE("/cart/items/{variantId}", {
|
|
43
|
+
const result = await client.DELETE("/v1/cart/items/{variantId}", {
|
|
44
44
|
params: { path },
|
|
45
45
|
headers: cartHeaders(),
|
|
46
46
|
});
|
|
47
47
|
return unwrap(result);
|
|
48
48
|
},
|
|
49
49
|
clear: async () => {
|
|
50
|
-
const result = await client.DELETE("/cart", { headers: cartHeaders() });
|
|
50
|
+
const result = await client.DELETE("/v1/cart", { headers: cartHeaders() });
|
|
51
51
|
return unwrap(result);
|
|
52
52
|
},
|
|
53
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart.js","sourceRoot":"","sources":["../../src/resources/cart.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEzC,MAAM,UAAU,kBAAkB,CAChC,MAAqB,EACrB,YAAsC,EACtC,YAAqC;IAErC,0EAA0E;IAC1E,wEAAwE;IACxE,gEAAgE;IAChE,SAAS,WAAW;QA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AM,CAAC,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Client } from "openapi-fetch";
|
|
2
2
|
import type { paths } from "../types.gen.js";
|
|
3
3
|
export declare function createCategoriesResource(client: Client<paths>): {
|
|
4
|
-
list: (query?: paths["/categories"]["get"]["parameters"]["query"]) => Promise<{
|
|
4
|
+
list: (query?: paths["/v1/categories"]["get"]["parameters"]["query"]) => Promise<{
|
|
5
5
|
items: {
|
|
6
6
|
id: number;
|
|
7
7
|
name: string;
|
|
@@ -11,7 +11,7 @@ export declare function createCategoriesResource(client: Client<paths>): {
|
|
|
11
11
|
limit: number;
|
|
12
12
|
offset: number;
|
|
13
13
|
}>;
|
|
14
|
-
getById: (id: number, query?: paths["/categories/{id}"]["get"]["parameters"]["query"]) => Promise<{
|
|
14
|
+
getById: (id: number, query?: paths["/v1/categories/{id}"]["get"]["parameters"]["query"]) => Promise<{
|
|
15
15
|
id: number;
|
|
16
16
|
name: string;
|
|
17
17
|
products: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"categories.d.ts","sourceRoot":"","sources":["../../src/resources/categories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC;mBAIjD,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"categories.d.ts","sourceRoot":"","sources":["../../src/resources/categories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC;mBAIjD,KAAK,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC;;;;;;;;;;kBAOxD,MAAM,UACH,KAAK,CAAC,qBAAqB,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;EAWtE"}
|
|
@@ -3,14 +3,14 @@ export function createCategoriesResource(client) {
|
|
|
3
3
|
return {
|
|
4
4
|
// no legitimate "empty" case for a list — any non-2xx is a real failure
|
|
5
5
|
list: async (query = {}) => {
|
|
6
|
-
const result = await client.GET("/categories", { params: { query } });
|
|
6
|
+
const result = await client.GET("/v1/categories", { params: { query } });
|
|
7
7
|
return unwrap(result);
|
|
8
8
|
},
|
|
9
9
|
getById: async (id, query = {}) => {
|
|
10
10
|
const path = {
|
|
11
11
|
id: String(id),
|
|
12
12
|
};
|
|
13
|
-
const result = await client.GET("/categories/{id}", {
|
|
13
|
+
const result = await client.GET("/v1/categories/{id}", {
|
|
14
14
|
params: { path, query },
|
|
15
15
|
});
|
|
16
16
|
return unwrapOrUndefinedOn(result, 404);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"categories.js","sourceRoot":"","sources":["../../src/resources/categories.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,UAAU,wBAAwB,CAAC,MAAqB;IAC5D,OAAO;QACL,wEAAwE;QACxE,IAAI,EAAE,KAAK,EACT,
|
|
1
|
+
{"version":3,"file":"categories.js","sourceRoot":"","sources":["../../src/resources/categories.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,UAAU,wBAAwB,CAAC,MAAqB;IAC5D,OAAO;QACL,wEAAwE;QACxE,IAAI,EAAE,KAAK,EACT,QAA+D,EAAE,EACjE,EAAE;YACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YACzE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,EAAE,KAAK,EACZ,EAAU,EACV,QAAoE,EAAE,EACtE,EAAE;YACF,MAAM,IAAI,GAA8D;gBACtE,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC;aACf,CAAC;YACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE;gBACrD,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;aACxB,CAAC,CAAC;YACH,OAAO,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC1C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -8,11 +8,11 @@ export function createCheckoutResource(client, getCartToken) {
|
|
|
8
8
|
return {
|
|
9
9
|
// no legitimate "empty" case — always returns a body (ready: boolean)
|
|
10
10
|
getConfig: async () => {
|
|
11
|
-
const result = await client.GET("/checkout/config");
|
|
11
|
+
const result = await client.GET("/v1/checkout/config");
|
|
12
12
|
return unwrap(result);
|
|
13
13
|
},
|
|
14
14
|
createSession: async (body) => {
|
|
15
|
-
const result = await client.POST("/checkout/session", {
|
|
15
|
+
const result = await client.POST("/v1/checkout/session", {
|
|
16
16
|
body,
|
|
17
17
|
headers: cartHeaders(),
|
|
18
18
|
});
|
|
@@ -21,14 +21,14 @@ export function createCheckoutResource(client, getCartToken) {
|
|
|
21
21
|
// 404 = no connected Stripe account, or an unknown/expired session id
|
|
22
22
|
getSessionStatus: async (sessionId) => {
|
|
23
23
|
const path = { sessionId };
|
|
24
|
-
const result = await client.GET("/checkout/session/{sessionId}", {
|
|
24
|
+
const result = await client.GET("/v1/checkout/session/{sessionId}", {
|
|
25
25
|
params: { path },
|
|
26
26
|
});
|
|
27
27
|
return unwrapOrUndefinedOn(result, 404);
|
|
28
28
|
},
|
|
29
29
|
// no legitimate "empty" case — a computed result, not a lookup
|
|
30
30
|
getShippingOptions: async (body) => {
|
|
31
|
-
const result = await client.POST("/checkout/shipping-options", { body });
|
|
31
|
+
const result = await client.POST("/v1/checkout/shipping-options", { body });
|
|
32
32
|
return unwrap(result);
|
|
33
33
|
},
|
|
34
34
|
};
|