@ebitex/commerce-sdk 0.0.0-stage → 0.1.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 +201 -0
- package/README.md +34 -3
- package/dist/client.d.ts +42 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +101 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +23 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +30 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/query.d.ts +20 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +58 -0
- package/dist/query.js.map +1 -0
- package/dist/types.d.ts +108 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +39 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @ebitex/commerce-sdk
|
|
2
|
+
|
|
3
|
+
A client for the ebitex Commerce Delivery API. It reads a store's catalogue (products, prices, availability and categories) and its live stock, from a server or a browser, with no runtime dependencies.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { createCommerceClient } from '@ebitex/commerce-sdk'
|
|
7
|
+
|
|
8
|
+
const commerce = createCommerceClient({ apiKey: 'ebx_your_key' })
|
|
9
|
+
|
|
10
|
+
const store = await commerce.store()
|
|
11
|
+
const page = await commerce.products({ search: 'trail', limit: 12 })
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
A key restricted to your site's origins is browser-safe and may be shipped to a browser. A key with no restriction is a server key: keep it on a server.
|
|
15
|
+
|
|
16
|
+
## Prices
|
|
17
|
+
|
|
18
|
+
A price is whole minor units beside a currency (`amountMinor`, `currency`) and the same amount as the store's own decimal string (`amount`). Show `amount`; do arithmetic on `amountMinor`. A variant with no price has `price: null`: unpriced, which is not free.
|
|
19
|
+
|
|
20
|
+
## Availability and stock
|
|
21
|
+
|
|
22
|
+
Product reads carry each variant's `availability` (`inStock`, `backorder` or `outOfStock`), up to a few minutes old, for display. `stock(skus)` is never cached and is the authority to confirm against before you take an order. A server key is told counts (`available`); a browser-safe key only if the store allows it, and otherwise `available` is absent from every item.
|
|
23
|
+
|
|
24
|
+
## Paging
|
|
25
|
+
|
|
26
|
+
`eachPage()` and `eachProduct()` capture the query once and replay it unchanged with each cursor, because a cursor belongs to the query that produced it.
|
|
27
|
+
|
|
28
|
+
## Errors
|
|
29
|
+
|
|
30
|
+
A non-success response throws `CommerceApiError` with `status`, `code` (`invalid_cursor`, `rate_limited`, …), `requestId` (quote it to support) and, on a `429`, `retryAfterSeconds`. A product that is not available is `null` from `product()`, not an error, unless you pass `throwIfMissing`. A request the client refuses to send (a limit of zero, more than 50 keys) throws the same error with `local: true` and the server's own code. A network failure is a `CommerceNetworkError` that keeps its cause and never puts the URL in its message.
|
|
31
|
+
|
|
32
|
+
## Licence
|
|
33
|
+
|
|
34
|
+
Apache-2.0.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CategoryList, Product, ProductBatch, ProductResponse, ProductsPage, ProductsQuery, StockResult, StoreInfo } from './types.js';
|
|
2
|
+
export declare const DEFAULT_BASE_URL = "https://api.ebitex.io";
|
|
3
|
+
export interface CommerceClientOptions {
|
|
4
|
+
/** A delivery key bound to one store. A server key may be told stock counts and must never reach a browser; a browser-safe key is restricted to origins or addresses. */
|
|
5
|
+
apiKey: string;
|
|
6
|
+
/** Defaults to `https://api.ebitex.io`. */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/** Defaults to the global `fetch`. Wrap it to add retries, a cache or tracing: the client adds none of its own. */
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
}
|
|
11
|
+
export interface CallOptions {
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}
|
|
14
|
+
export interface CommerceClient {
|
|
15
|
+
/** The store this key reads: its key, name, currency and whether its prices include tax. */
|
|
16
|
+
store(options?: CallOptions): Promise<StoreInfo>;
|
|
17
|
+
/** One page of products. */
|
|
18
|
+
products<A = Record<string, unknown>>(query?: ProductsQuery, options?: CallOptions): Promise<ProductsPage<A>>;
|
|
19
|
+
/** Every page of a query as an async iterator. The query is captured once and replayed unchanged for each page. */
|
|
20
|
+
eachPage<A = Record<string, unknown>>(query?: Omit<ProductsQuery, 'cursor'>, options?: CallOptions): AsyncGenerator<ProductsPage<A>, void, undefined>;
|
|
21
|
+
/** Every product a query matches, one at a time. */
|
|
22
|
+
eachProduct<A = Record<string, unknown>>(query?: Omit<ProductsQuery, 'cursor'>, options?: CallOptions): AsyncGenerator<Product<A>, void, undefined>;
|
|
23
|
+
/** Up to 50 products by key in one round trip, in the order asked; the keys that are not available are in `missing`. */
|
|
24
|
+
productsByKeys<A = Record<string, unknown>>(keys: readonly string[], options?: CallOptions): Promise<ProductBatch<A>>;
|
|
25
|
+
/** One product, or `null` when there is none available to this key. `throwIfMissing` makes that an error. */
|
|
26
|
+
product<A = Record<string, unknown>>(key: string, options?: CallOptions & {
|
|
27
|
+
throwIfMissing?: boolean;
|
|
28
|
+
}): Promise<Product<A> | null>;
|
|
29
|
+
/** The primitive under `product`: keeps the `ETag`, and sends `If-None-Match` when given, so an unchanged product is `notModified`. */
|
|
30
|
+
productResponse<A = Record<string, unknown>>(key: string, options?: CallOptions & {
|
|
31
|
+
ifNoneMatch?: string;
|
|
32
|
+
}): Promise<ProductResponse<A>>;
|
|
33
|
+
/** The categories the store's products use. */
|
|
34
|
+
categories(options?: CallOptions): Promise<CategoryList>;
|
|
35
|
+
/**
|
|
36
|
+
* Live stock for up to 50 SKUs: never cached, so it is the authority a checkout confirms against (the product reads' availability is for display, up to a few minutes old).
|
|
37
|
+
* Counts appear only when the key may see them; see `StockItem.available`. Budgeted tighter than the other reads, so call it when you need it, not on every render.
|
|
38
|
+
*/
|
|
39
|
+
stock(skus: readonly string[], options?: CallOptions): Promise<StockResult>;
|
|
40
|
+
}
|
|
41
|
+
export declare function createCommerceClient(options: CommerceClientOptions): CommerceClient;
|
|
42
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3I,eAAO,MAAM,gBAAgB,0BAA0B,CAAA;AAIvD,MAAM,WAAW,qBAAqB;IACpC,yKAAyK;IACzK,MAAM,EAAE,MAAM,CAAA;IACd,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,mHAAmH;IACnH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,4FAA4F;IAC5F,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;IAChD,4BAA4B;IAC5B,QAAQ,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,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AA;KAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAA;IACxI,+CAA+C;IAC/C,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IACxD;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;CAC5E;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAoEnF"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { CommerceApiError, CommerceNetworkError } from './errors.js';
|
|
2
|
+
import { buildKeysQuery, buildProductsQuery } from './query.js';
|
|
3
|
+
export const DEFAULT_BASE_URL = 'https://api.ebitex.io';
|
|
4
|
+
const ROOT = '/commerce/delivery/v1';
|
|
5
|
+
export function createCommerceClient(options) {
|
|
6
|
+
if (!options.apiKey)
|
|
7
|
+
throw new TypeError('createCommerceClient needs an apiKey.');
|
|
8
|
+
const base = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
9
|
+
const doFetch = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
10
|
+
async function send(path, query, init = {}) {
|
|
11
|
+
const headers = { Authorization: `Bearer ${options.apiKey}`, Accept: 'application/json' };
|
|
12
|
+
if (init.ifNoneMatch)
|
|
13
|
+
headers['If-None-Match'] = init.ifNoneMatch;
|
|
14
|
+
const url = `${base}${ROOT}${path}${query ? `?${query}` : ''}`;
|
|
15
|
+
try {
|
|
16
|
+
return await doFetch(url, { method: 'GET', headers, signal: init.signal });
|
|
17
|
+
}
|
|
18
|
+
catch (cause) {
|
|
19
|
+
if (cause instanceof DOMException && cause.name === 'AbortError')
|
|
20
|
+
throw cause;
|
|
21
|
+
// The message carries no URL: it can hold a search term, and logs are not a place for a shopper's query.
|
|
22
|
+
throw new CommerceNetworkError('The Commerce Delivery API could not be reached.', { cause });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function json(response) {
|
|
26
|
+
if (response.ok)
|
|
27
|
+
return (await response.json());
|
|
28
|
+
throw await toError(response);
|
|
29
|
+
}
|
|
30
|
+
async function* eachPage(query = {}, call = {}) {
|
|
31
|
+
if (query.cursor) {
|
|
32
|
+
throw new CommerceApiError(400, 'invalid_cursor', 'eachPage and eachProduct start from the beginning; to resume, call products() with a cursor.', null, null, true);
|
|
33
|
+
}
|
|
34
|
+
const frozen = { ...query };
|
|
35
|
+
let cursor;
|
|
36
|
+
for (;;) {
|
|
37
|
+
const page = await json(await send('/products', buildProductsQuery({ ...frozen, cursor }), call));
|
|
38
|
+
yield page;
|
|
39
|
+
if (!page.nextCursor)
|
|
40
|
+
return;
|
|
41
|
+
cursor = page.nextCursor;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function productResponse(key, opts = {}) {
|
|
45
|
+
if (!key)
|
|
46
|
+
throw new CommerceApiError(400, 'invalid_keys', 'A product key is required.', null, null, true);
|
|
47
|
+
const response = await send(`/products/${encodeURIComponent(key)}`, '', opts);
|
|
48
|
+
const etag = response.headers.get('ETag');
|
|
49
|
+
if (response.status === 304)
|
|
50
|
+
return { status: 'notModified', etag };
|
|
51
|
+
if (response.status === 404) {
|
|
52
|
+
const error = await toError(response);
|
|
53
|
+
if (error.code === 'product_not_found')
|
|
54
|
+
return { status: 'missing' };
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
return { status: 'ok', product: await json(response), etag };
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
store: async (call) => json(await send('/store', '', call)),
|
|
61
|
+
products: async (query, call) => json(await send('/products', buildProductsQuery(query), call)),
|
|
62
|
+
eachPage,
|
|
63
|
+
async *eachProduct(query = {}, call = {}) {
|
|
64
|
+
for await (const page of eachPage(query, call))
|
|
65
|
+
yield* page.items;
|
|
66
|
+
},
|
|
67
|
+
productsByKeys: async (keys, call) => json(await send('/products', buildKeysQuery(keys, 'product keys'), call)),
|
|
68
|
+
async product(key, opts = {}) {
|
|
69
|
+
const result = await productResponse(key, opts);
|
|
70
|
+
if (result.status === 'ok')
|
|
71
|
+
return result.product;
|
|
72
|
+
if (opts.throwIfMissing)
|
|
73
|
+
throw new CommerceApiError(404, 'product_not_found', 'No product with that key is available.', null, null, true);
|
|
74
|
+
return null;
|
|
75
|
+
},
|
|
76
|
+
productResponse,
|
|
77
|
+
categories: async (call) => json(await send('/categories', '', call)),
|
|
78
|
+
stock: async (skus, call) => json(await send('/stock', buildKeysQuery(skus, 'SKUs'), call)),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async function toError(response) {
|
|
82
|
+
const requestId = response.headers.get('X-Request-Id');
|
|
83
|
+
const retryAfter = Number(response.headers.get('Retry-After'));
|
|
84
|
+
let code = response.status === 401 ? 'unauthorized' : 'error';
|
|
85
|
+
let message = `The Commerce Delivery API answered ${response.status}.`;
|
|
86
|
+
let bodyRequestId = null;
|
|
87
|
+
try {
|
|
88
|
+
const body = (await response.json());
|
|
89
|
+
if (typeof body.error === 'string')
|
|
90
|
+
code = body.error;
|
|
91
|
+
if (typeof body.message === 'string' && body.message)
|
|
92
|
+
message = body.message;
|
|
93
|
+
if (typeof body.requestId === 'string')
|
|
94
|
+
bodyRequestId = body.requestId;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// An error with no JSON body (an edge page, an empty 401) still has a status and a request id.
|
|
98
|
+
}
|
|
99
|
+
return new CommerceApiError(response.status, code, message, requestId ?? bodyRequestId, Number.isFinite(retryAfter) && response.headers.has('Retry-After') ? retryAfter : null);
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EA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C,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAgE,CAAA;QACnG,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;YAAE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAA;QACrD,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC5E,IAAI,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ;YAAE,aAAa,GAAG,IAAI,CAAC,SAAS,CAAA;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,+FAA+F;IACjG,CAAC;IACD,OAAO,IAAI,gBAAgB,CACzB,QAAQ,CAAC,MAAM,EACf,IAAI,EACJ,OAAO,EACP,SAAS,IAAI,aAAa,EAC1B,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CACvF,CAAA;AACH,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** The server answered with a non-success status, or the request was refused before it was sent. */
|
|
2
|
+
export declare class CommerceApiError extends Error {
|
|
3
|
+
readonly name = "CommerceApiError";
|
|
4
|
+
/** The HTTP status; 400 for a request this client refused to send. */
|
|
5
|
+
readonly status: number;
|
|
6
|
+
/** The server's error code (`invalid_cursor`, `product_not_found`, `rate_limited`, …), or `unauthorized` / `error` when the body carried none. */
|
|
7
|
+
readonly code: string;
|
|
8
|
+
/** The `X-Request-Id` to quote to support, or null when the request never reached the server. */
|
|
9
|
+
readonly requestId: string | null;
|
|
10
|
+
/** From `Retry-After` on a `429`. */
|
|
11
|
+
readonly retryAfterSeconds: number | null;
|
|
12
|
+
/** True when this client refused the request itself, before any network call. */
|
|
13
|
+
readonly local: boolean;
|
|
14
|
+
constructor(status: number, code: string, message: string, requestId?: string | null, retryAfterSeconds?: number | null, local?: boolean);
|
|
15
|
+
}
|
|
16
|
+
/** The request could not complete: no connection, a DNS failure, an aborted request. `cause` is the underlying error. */
|
|
17
|
+
export declare class CommerceNetworkError extends Error {
|
|
18
|
+
readonly name = "CommerceNetworkError";
|
|
19
|
+
constructor(message: string, options?: {
|
|
20
|
+
cause?: unknown;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,sBAAqB;IAClC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,kJAAkJ;IAClJ,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,iGAAiG;IACjG,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,qCAAqC;IACrC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;IACzC,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;gBAGrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,MAAM,GAAG,IAAW,EAC/B,iBAAiB,GAAE,MAAM,GAAG,IAAW,EACvC,KAAK,UAAQ;CAShB;AAED,yHAAyH;AACzH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,0BAAyB;gBAE1B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAG3D"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** The server answered with a non-success status, or the request was refused before it was sent. */
|
|
2
|
+
export class CommerceApiError extends Error {
|
|
3
|
+
name = 'CommerceApiError';
|
|
4
|
+
/** The HTTP status; 400 for a request this client refused to send. */
|
|
5
|
+
status;
|
|
6
|
+
/** The server's error code (`invalid_cursor`, `product_not_found`, `rate_limited`, …), or `unauthorized` / `error` when the body carried none. */
|
|
7
|
+
code;
|
|
8
|
+
/** The `X-Request-Id` to quote to support, or null when the request never reached the server. */
|
|
9
|
+
requestId;
|
|
10
|
+
/** From `Retry-After` on a `429`. */
|
|
11
|
+
retryAfterSeconds;
|
|
12
|
+
/** True when this client refused the request itself, before any network call. */
|
|
13
|
+
local;
|
|
14
|
+
constructor(status, code, message, requestId = null, retryAfterSeconds = null, local = false) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.status = status;
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.requestId = requestId;
|
|
19
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
20
|
+
this.local = local;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** The request could not complete: no connection, a DNS failure, an aborted request. `cause` is the underlying error. */
|
|
24
|
+
export class CommerceNetworkError extends Error {
|
|
25
|
+
name = 'CommerceNetworkError';
|
|
26
|
+
constructor(message, options) {
|
|
27
|
+
super(message, options);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,IAAI,GAAG,kBAAkB,CAAA;IAClC,sEAAsE;IAC7D,MAAM,CAAQ;IACvB,kJAAkJ;IACzI,IAAI,CAAQ;IACrB,iGAAiG;IACxF,SAAS,CAAe;IACjC,qCAAqC;IAC5B,iBAAiB,CAAe;IACzC,iFAAiF;IACxE,KAAK,CAAS;IAEvB,YACE,MAAc,EACd,IAAY,EACZ,OAAe,EACf,YAA2B,IAAI,EAC/B,oBAAmC,IAAI,EACvC,KAAK,GAAG,KAAK;QAEb,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;QAC1C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF;AAED,yHAAyH;AACzH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,IAAI,GAAG,sBAAsB,CAAA;IAEtC,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACzB,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createCommerceClient, DEFAULT_BASE_URL } from './client.js';
|
|
2
|
+
export type { CallOptions, CommerceClient, CommerceClientOptions } from './client.js';
|
|
3
|
+
export { CommerceApiError, CommerceNetworkError } from './errors.js';
|
|
4
|
+
export { buildKeysQuery, buildProductsQuery, Limits } from './query.js';
|
|
5
|
+
export type { Availability, Category, CategoryList, MediaReference, Money, OptionAxis, Product, ProductBatch, ProductResponse, ProductSort, ProductsPage, ProductsQuery, StockItem, StockResult, StoreInfo, Variant, } from './types.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACpE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACrF,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACvE,YAAY,EACV,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,KAAK,EACL,UAAU,EACV,OAAO,EACP,YAAY,EACZ,eAAe,EACf,WAAW,EACX,YAAY,EACZ,aAAa,EACb,SAAS,EACT,WAAW,EACX,SAAS,EACT,OAAO,GACR,MAAM,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEpE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/query.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ProductsQuery } from './types.js';
|
|
2
|
+
/** The limits the API documents. The server stays the authority: these only refuse, early, what it would refuse. */
|
|
3
|
+
export declare const Limits: {
|
|
4
|
+
readonly maxPageSize: 100;
|
|
5
|
+
readonly maxBatchKeys: 50;
|
|
6
|
+
readonly maxSearch: 100;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* `encodeURIComponent` leaves `! ' ( ) *` alone; RFC 3986 percent-encoding, which the .NET client uses, does not. Escaping them here makes the two
|
|
10
|
+
* produce the same string for the same query, which `query-cases.json` asserts in both suites.
|
|
11
|
+
*/
|
|
12
|
+
export declare function encode(value: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* The query string for a product listing, in one fixed order so equal queries are equal strings, with the mistakes the server would refuse refused first.
|
|
15
|
+
* A cursor is bound to the query that produced it, so it is only valid replayed with exactly the same other parameters; nothing here rewrites them.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildProductsQuery(query?: ProductsQuery): string;
|
|
18
|
+
/** The query string for reading products by key (a batch) or stock by SKU: one to fifty comma-separated values. */
|
|
19
|
+
export declare function buildKeysQuery(keys: readonly string[], what?: 'product keys' | 'SKUs'): string;
|
|
20
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,YAAY,CAAA;AAE5D,oHAAoH;AACpH,eAAO,MAAM,MAAM;;;;CAIT,CAAA;AAMV;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,GAAE,aAAkB,GAAG,MAAM,CA2BpE;AAED,mHAAmH;AACnH,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,GAAE,cAAc,GAAG,MAAuB,GAAG,MAAM,CAQ9G"}
|
package/dist/query.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CommerceApiError } from './errors.js';
|
|
2
|
+
/** The limits the API documents. The server stays the authority: these only refuse, early, what it would refuse. */
|
|
3
|
+
export const Limits = {
|
|
4
|
+
maxPageSize: 100,
|
|
5
|
+
maxBatchKeys: 50,
|
|
6
|
+
maxSearch: 100,
|
|
7
|
+
};
|
|
8
|
+
const SORTS = ['name', 'createdUtc'];
|
|
9
|
+
const local = (code, message) => new CommerceApiError(400, code, message, null, null, true);
|
|
10
|
+
/**
|
|
11
|
+
* `encodeURIComponent` leaves `! ' ( ) *` alone; RFC 3986 percent-encoding, which the .NET client uses, does not. Escaping them here makes the two
|
|
12
|
+
* produce the same string for the same query, which `query-cases.json` asserts in both suites.
|
|
13
|
+
*/
|
|
14
|
+
export function encode(value) {
|
|
15
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (c) => '%' + c.charCodeAt(0).toString(16).toUpperCase());
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The query string for a product listing, in one fixed order so equal queries are equal strings, with the mistakes the server would refuse refused first.
|
|
19
|
+
* A cursor is bound to the query that produced it, so it is only valid replayed with exactly the same other parameters; nothing here rewrites them.
|
|
20
|
+
*/
|
|
21
|
+
export function buildProductsQuery(query = {}) {
|
|
22
|
+
const parts = [];
|
|
23
|
+
const category = query.category?.trim();
|
|
24
|
+
if (category)
|
|
25
|
+
parts.push(`category=${encode(category)}`);
|
|
26
|
+
const search = query.search?.trim();
|
|
27
|
+
if (search) {
|
|
28
|
+
if (search.length > Limits.maxSearch)
|
|
29
|
+
throw local('invalid_search', `search is at most ${Limits.maxSearch} characters.`);
|
|
30
|
+
parts.push(`search=${encode(search)}`);
|
|
31
|
+
}
|
|
32
|
+
if (query.sort !== undefined) {
|
|
33
|
+
if (!SORTS.includes(query.sort))
|
|
34
|
+
throw local('invalid_sort', "sort is 'name' or 'createdUtc'.");
|
|
35
|
+
parts.push(`sort=${query.sort}`);
|
|
36
|
+
}
|
|
37
|
+
if (query.limit !== undefined) {
|
|
38
|
+
if (!Number.isInteger(query.limit) || query.limit < 1 || query.limit > Limits.maxPageSize) {
|
|
39
|
+
throw local('invalid_limit', `limit is a whole number from 1 to ${Limits.maxPageSize}.`);
|
|
40
|
+
}
|
|
41
|
+
parts.push(`limit=${query.limit}`);
|
|
42
|
+
}
|
|
43
|
+
if (query.cursor)
|
|
44
|
+
parts.push(`cursor=${encode(query.cursor)}`);
|
|
45
|
+
return parts.join('&');
|
|
46
|
+
}
|
|
47
|
+
/** The query string for reading products by key (a batch) or stock by SKU: one to fifty comma-separated values. */
|
|
48
|
+
export function buildKeysQuery(keys, what = 'product keys') {
|
|
49
|
+
if (keys.length < 1 || keys.length > Limits.maxBatchKeys) {
|
|
50
|
+
throw local('invalid_keys', `Ask for 1 to ${Limits.maxBatchKeys} ${what} at a time.`);
|
|
51
|
+
}
|
|
52
|
+
for (const key of keys) {
|
|
53
|
+
if (!key || key.includes(','))
|
|
54
|
+
throw local('invalid_keys', 'A key cannot be empty or contain a comma.');
|
|
55
|
+
}
|
|
56
|
+
return `keys=${keys.map(encode).join(',')}`;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAG9C,oHAAoH;AACpH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,WAAW,EAAE,GAAG;IAChB,YAAY,EAAE,EAAE;IAChB,SAAS,EAAE,GAAG;CACN,CAAA;AAEV,MAAM,KAAK,GAA2B,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;AAE5D,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,OAAe,EAAoB,EAAE,CAAC,IAAI,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAE7H;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;AAC/G,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAuB,EAAE;IAC1D,MAAM,KAAK,GAAa,EAAE,CAAA;IAE1B,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAA;IACvC,IAAI,QA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C,CAAA;AACxB,CAAC;AAED,mHAAmH;AACnH,MAAM,UAAU,cAAc,CAAC,IAAuB,EAAE,OAAgC,cAAc;IACpG,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;QACzD,MAAM,KAAK,CAAC,cAAc,EAAE,gBAAgB,MAAM,CAAC,YAAY,IAAI,IAAI,aAAa,CAAC,CAAA;IACvF,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,MAAM,KAAK,CAAC,cAAc,EAAE,2CAA2C,CAAC,CAAA;IACzG,CAAC;IACD,OAAO,QAAQ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;AAC7C,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/** What a variant's stock looks like to a buyer. A status, never a count: a count comes only from `stock()`. */
|
|
2
|
+
export type Availability = 'inStock' | 'backorder' | 'outOfStock';
|
|
3
|
+
/** A price as the Store holds it: whole minor units beside a currency, and the same amount as the Store's own decimal string. Never a float. */
|
|
4
|
+
export interface Money {
|
|
5
|
+
amountMinor: number;
|
|
6
|
+
currency: string;
|
|
7
|
+
/** The amount as a decimal string in the currency's own exponent (`"89.50"`, `"5000"` for JPY). Show this; do arithmetic on `amountMinor`. */
|
|
8
|
+
amount: string;
|
|
9
|
+
/** Whether the stored price already includes tax: the Store's setting. */
|
|
10
|
+
taxIncluded: boolean;
|
|
11
|
+
compareAtMinor: number | null;
|
|
12
|
+
compareAt: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface Variant {
|
|
15
|
+
sku: string;
|
|
16
|
+
/** Option axis name to the chosen value (`{ Size: "41" }`). Empty for a product with no options. */
|
|
17
|
+
options: Record<string, string>;
|
|
18
|
+
/** `null` when the variant has no price in this Store: unpriced, which is not zero. */
|
|
19
|
+
price: Money | null;
|
|
20
|
+
availability: Availability;
|
|
21
|
+
}
|
|
22
|
+
export interface OptionAxis {
|
|
23
|
+
name: string;
|
|
24
|
+
values: string[];
|
|
25
|
+
}
|
|
26
|
+
/** A reference to an Assets item. Commerce stores no files; resolve it through Assets. */
|
|
27
|
+
export interface MediaReference {
|
|
28
|
+
provider: string;
|
|
29
|
+
key: string;
|
|
30
|
+
/** 0 is the primary image. */
|
|
31
|
+
position: number;
|
|
32
|
+
}
|
|
33
|
+
/** A category as a buyer's program sees it: `path` is what the `category` filter takes. */
|
|
34
|
+
export interface Category {
|
|
35
|
+
path: string;
|
|
36
|
+
name: string;
|
|
37
|
+
}
|
|
38
|
+
export interface Product<A = Record<string, unknown>> {
|
|
39
|
+
key: string;
|
|
40
|
+
name: string;
|
|
41
|
+
/** The product type's key. */
|
|
42
|
+
type: string;
|
|
43
|
+
attributes: A;
|
|
44
|
+
primaryCategory: Category | null;
|
|
45
|
+
categories: Category[];
|
|
46
|
+
media: MediaReference[];
|
|
47
|
+
axes: OptionAxis[];
|
|
48
|
+
variants: Variant[];
|
|
49
|
+
createdUtc: string;
|
|
50
|
+
updatedUtc: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ProductsPage<A = Record<string, unknown>> {
|
|
53
|
+
items: Product<A>[];
|
|
54
|
+
/** Pass to `products({ ..., cursor })` for the next page; `null` on the last. */
|
|
55
|
+
nextCursor: string | null;
|
|
56
|
+
}
|
|
57
|
+
export interface ProductBatch<A = Record<string, unknown>> {
|
|
58
|
+
/** In the order asked. */
|
|
59
|
+
items: Product<A>[];
|
|
60
|
+
/** The keys that are not available to this key (unknown, unlisted, draft or archived: indistinguishable on purpose). */
|
|
61
|
+
missing: string[];
|
|
62
|
+
}
|
|
63
|
+
export interface CategoryList {
|
|
64
|
+
items: Category[];
|
|
65
|
+
}
|
|
66
|
+
export interface StoreInfo {
|
|
67
|
+
key: string;
|
|
68
|
+
name: string;
|
|
69
|
+
currency: string;
|
|
70
|
+
pricesIncludeTax: boolean;
|
|
71
|
+
}
|
|
72
|
+
export interface StockItem {
|
|
73
|
+
sku: string;
|
|
74
|
+
status: Availability;
|
|
75
|
+
/**
|
|
76
|
+
* Units available now. Present for a tracked variant when the key may see counts: always for a server key, and for a browser-safe key only when the store allows it. Absent (not null) otherwise, and for an untracked variant.
|
|
77
|
+
*/
|
|
78
|
+
available?: number;
|
|
79
|
+
}
|
|
80
|
+
export interface StockResult {
|
|
81
|
+
items: StockItem[];
|
|
82
|
+
/** The SKUs that are not available to this key. */
|
|
83
|
+
missing: string[];
|
|
84
|
+
}
|
|
85
|
+
export type ProductSort = 'name' | 'createdUtc';
|
|
86
|
+
export interface ProductsQuery {
|
|
87
|
+
/** A category path (`range/running`), as returned in `Category.path`. */
|
|
88
|
+
category?: string;
|
|
89
|
+
/** A case-insensitive prefix of the product name, at most 100 characters. */
|
|
90
|
+
search?: string;
|
|
91
|
+
/** `name` (the default) or `createdUtc`. */
|
|
92
|
+
sort?: ProductSort;
|
|
93
|
+
/** 1 to 100; the server's default is 25. */
|
|
94
|
+
limit?: number;
|
|
95
|
+
/** The `nextCursor` of the previous page, replayed with exactly the same other parameters. */
|
|
96
|
+
cursor?: string;
|
|
97
|
+
}
|
|
98
|
+
export type ProductResponse<A = Record<string, unknown>> = {
|
|
99
|
+
status: 'ok';
|
|
100
|
+
product: Product<A>;
|
|
101
|
+
etag: string | null;
|
|
102
|
+
} | {
|
|
103
|
+
status: 'notModified';
|
|
104
|
+
etag: string | null;
|
|
105
|
+
} | {
|
|
106
|
+
status: 'missing';
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,WA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C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,8FAA8F;IAC9F,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACnD;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC1D;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC9C;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,CAAA"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ebitex/commerce-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@ebitex/commerce-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The client for the ebitex Commerce Delivery API: read a store's catalogue (products, prices, availability, categories) and live stock, for a server or a browser.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ebitex",
|
|
7
|
+
"commerce",
|
|
8
|
+
"catalogue",
|
|
9
|
+
"headless-commerce",
|
|
10
|
+
"delivery-api"
|
|
11
|
+
],
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"homepage": "https://developers.ebitex.io/reference/commerce-sdk/",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -p tsconfig.build.json",
|
|
30
|
+
"lint": "oxlint",
|
|
31
|
+
"test": "vitest run"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^24.0.0",
|
|
35
|
+
"oxlint": "^1.71.0",
|
|
36
|
+
"typescript": "~6.0.2",
|
|
37
|
+
"vitest": "^4.1.10"
|
|
38
|
+
}
|
|
39
|
+
}
|