@cloudcommerce/api 2.9.0 → 2.10.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/lib/api.d.ts CHANGED
@@ -36,7 +36,7 @@ declare const api: {
36
36
  config: Config;
37
37
  data: ResponseBody<T>;
38
38
  }>;
39
- get: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, config?: C | undefined) => Promise<Response & {
39
+ get: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, config?: C) => Promise<Response & {
40
40
  config: Config;
41
41
  data: ResponseBody<C & {
42
42
  endpoint: E;
@@ -45,7 +45,7 @@ declare const api: {
45
45
  post: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, body: RequestBody<{
46
46
  endpoint: E;
47
47
  method: 'post';
48
- }>, config?: (E extends "login" | "authenticate" ? AbstractedConfig : C) | undefined) => Promise<Response & {
48
+ }>, config?: E extends 'login' | 'authenticate' ? AbstractedConfig : C) => Promise<Response & {
49
49
  config: Config;
50
50
  data: E extends "login" ? {
51
51
  _id: import("../types.d").ResourceId;
@@ -83,7 +83,7 @@ declare const api: {
83
83
  }>;
84
84
  };
85
85
  type AbstractedConfig = Omit<Config, 'endpoint' | 'method'>;
86
- declare const get: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, config?: C | undefined) => Promise<Response & {
86
+ declare const get: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, config?: C) => Promise<Response & {
87
87
  config: Config;
88
88
  data: ResponseBody<C & {
89
89
  endpoint: E;
@@ -92,7 +92,7 @@ declare const get: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E,
92
92
  declare const post: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, body: RequestBody<{
93
93
  endpoint: E;
94
94
  method: 'post';
95
- }>, config?: (E extends "login" | "authenticate" ? AbstractedConfig : C) | undefined) => Promise<Response & {
95
+ }>, config?: E extends 'login' | 'authenticate' ? AbstractedConfig : C) => Promise<Response & {
96
96
  config: Config;
97
97
  data: E extends "login" ? {
98
98
  _id: import("../types.d").ResourceId;
@@ -109,14 +109,14 @@ declare const post: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E
109
109
  declare const put: <E extends import("../types.d").ResourceAndFind | `products/${import("../types.d").ResourceId}/${string}` | `categories/${import("../types.d").ResourceId}/${string}` | `brands/${import("../types.d").ResourceId}/${string}` | `collections/${import("../types.d").ResourceId}/${string}` | `grids/${import("../types.d").ResourceId}/${string}` | `carts/${import("../types.d").ResourceId}/${string}` | `orders/${import("../types.d").ResourceId}/${string}` | `customers/${import("../types.d").ResourceId}/${string}` | `stores/${import("../types.d").ResourceId}/${string}` | `applications/${import("../types.d").ResourceId}/${string}` | `authentications/${import("../types.d").ResourceId}/${string}` | `products/${string}:${string}/${string}` | `categories/${string}:${string}/${string}` | `brands/${string}:${string}/${string}` | `collections/${string}:${string}/${string}` | `grids/${string}:${string}/${string}` | `carts/${string}:${string}/${string}` | `orders/${string}:${string}/${string}` | `customers/${string}:${string}/${string}` | `stores/${string}:${string}/${string}` | `applications/${string}:${string}/${string}` | `authentications/${string}:${string}/${string}` | `stores/me/${string}` | `authentications/me/${string}` | `slugs/${string}` | (("search/v1" | `search/v1?${string}`) | "search/_els" | `search/_els?${string}`) | ("search/v1/history" | `search/v1/history?${string}`) | ("events/products" | "events/categories" | "events/brands" | "events/collections" | "events/grids" | "events/carts" | "events/orders" | "events/customers" | "events/stores" | "events/applications" | "events/authentications" | `events/products/${import("../types.d").ResourceId}` | `events/categories/${import("../types.d").ResourceId}` | `events/brands/${import("../types.d").ResourceId}` | `events/collections/${import("../types.d").ResourceId}` | `events/grids/${import("../types.d").ResourceId}` | `events/carts/${import("../types.d").ResourceId}` | `events/orders/${import("../types.d").ResourceId}` | `events/customers/${import("../types.d").ResourceId}` | `events/stores/${import("../types.d").ResourceId}` | `events/applications/${import("../types.d").ResourceId}` | `events/authentications/${import("../types.d").ResourceId}` | "events/me") | "login" | "authenticate" | "ask-auth-callback" | "check-username" | "$aggregate/products" | "$aggregate/categories" | "$aggregate/brands" | "$aggregate/collections" | "$aggregate/grids" | "$aggregate/carts" | "$aggregate/orders" | "$aggregate/customers" | "schemas/products" | "schemas/categories" | "schemas/brands" | "schemas/collections" | "schemas/grids" | "schemas/carts" | "schemas/orders" | "schemas/customers" | "schemas/stores" | "schemas/applications" | "schemas/authentications", C extends AbstractedConfig>(endpoint: E, body: RequestBody<{
110
110
  endpoint: E;
111
111
  method: 'put';
112
- }>, config?: C | undefined) => Promise<Response & {
112
+ }>, config?: C) => Promise<Response & {
113
113
  config: Config;
114
114
  data: null;
115
115
  }>;
116
116
  declare const patch: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, body: RequestBody<{
117
117
  endpoint: E;
118
118
  method: 'patch';
119
- }>, config?: C | undefined) => Promise<Response & {
119
+ }>, config?: C) => Promise<Response & {
120
120
  config: Config;
121
121
  data: null;
122
122
  }>;
package/lib/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAoBA,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;IAC1B,UAAU,CAAC,UAAU,GAAG,EAAE,CAAC;CAC5B;AAED,MAAM,IAAI,GAAG,CACX,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,EAAE,GAAG,CAAC;OAC1C,UAAU,CACS,CAAC;AAEzB,MAAM,QAAS,SAAQ,KAAK;IAM1B,YACE,MAAc,EACd,QAA+B,EAC/B,GAAY,EACZ,YAAqB,KAAK;QAE1B,IAAI,QAAQ,EAAE;YACZ,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;YAC3B,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;YAC1B,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;SACnC;aAAM;YACL,KAAK,CAAC,GAAG,IAAI,eAAe,CAAC,CAAC;SAC/B;QACD,IAAI,C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,MAAM,EAAE,OAAO;QACf,QAAQ;QACR,IAAI;KACL,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,GAAG,GAAG,CAAC,QAAkB,EAAE,MAAyB,EAAE,EAAE,CAAC,GAAG,CAAC;IACjE,GAAG,MAAM;IACT,MAAM,EAAE,QAAQ;IAChB,QAAQ;CACT,CAAC,CAAC;AAEH,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;AACd,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;AAChB,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;AACd,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;AAClB,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;AACd,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;AAEjB,eAAe,GAAG,CAAC;AAEnB,OAAO,EACL,aAAa,EACb,GAAG,EACH,IAAI,EACJ,GAAG,EACH,KAAK,EACL,GAAG,EACH,QAAQ,GACT,CAAC"}
package/package.json CHANGED
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "name": "@cloudcommerce/api",
3
3
  "type": "module",
4
- "version": "2.9.0",
4
+ "version": "2.10.0",
5
5
  "description": "E-Com Plus Cloud Commerce APIs client/adapter",
6
6
  "main": "lib/api.js",
7
7
  "types": "lib/api.d.ts",
8
8
  "exports": {
9
9
  ".": "./lib/api.js",
10
- "./types": "./types.d.ts"
10
+ "./types": "./types.ts"
11
11
  },
12
+ "files": [
13
+ "/lib",
14
+ "/types",
15
+ "/*.{js,mjs,ts}"
16
+ ],
12
17
  "repository": {
13
18
  "type": "git",
14
19
  "url": "git+https://github.com/ecomplus/cloud-commerce.git",
package/types.ts CHANGED
@@ -1,2 +1,8 @@
1
1
  /* eslint-disable */
2
- export * from './types.d';
2
+ export type * from './types.d';
3
+ export type {
4
+ ApiError,
5
+ ApiConfig,
6
+ ApiEndpoint,
7
+ ApiErrorBody,
8
+ } from './lib/api.d';
package/.env DELETED
@@ -1,3 +0,0 @@
1
- ECOM_AUTHENTICATION_ID=5e1f287962887026009bb97f
2
- ECOM_API_KEY=9f58cf44dbaf2e69a841b5a3570f42e9a64df1d63af06395773210398d8230d221171a8c652aa73530cc1b1ada968ec5eae6b49c0d6382ba574b659057036d73
3
- ECOM_STORE_ID=1056
@@ -1,5 +0,0 @@
1
-
2
-
3
- > @cloudcommerce/api@2.8.8 build /home/leo/code/ecomplus/cloud-commerce/packages/api
4
- > bash ../../scripts/build-lib.sh
5
-
@@ -1,322 +0,0 @@
1
-
2
-
3
- > @cloudcommerce/api@2.8.8 test /home/leo/code/ecomplus/cloud-commerce/packages/api
4
- > tsc -p ../../tsconfig.test.json && vitest run
5
-
6
-
7
-  RUN  v1.3.1 /home/leo/code/ecomplus/cloud-commerce/packages/api
8
-
9
- [?25l · tests/index.test.ts (7)
10
- · Read product and typecheck SKU
11
- · Find and read product by SKU
12
- · 404 with different Store ID from env
13
- · List categories and typecheck result
14
- · 401 trying to list API events
15
- · 401 to create category and body typecheck
16
- · 204 to update products views
17
- [?25l[?25l[?25l[?25l[?25l ❯ tests/index.test.ts (7)
18
- ⠙ Read product and typecheck SKU
19
- · Find and read product by SKU
20
- · 404 with different Store ID from env
21
- · List categories and typecheck result
22
- · 401 trying to list API events
23
- · 401 to create category and body typecheck
24
- · 204 to update products views
25
- [?25l ❯ tests/index.test.ts (7)
26
- ⠹ Read product and typecheck SKU
27
- · Find and read product by SKU
28
- · 404 with different Store ID from env
29
- · List categories and typecheck result
30
- · 401 trying to list API events
31
- · 401 to create category and body typecheck
32
- · 204 to update products views
33
- [?25l ❯ tests/index.test.ts (7)
34
- ⠸ Read product and typecheck SKU
35
- · Find and read product by SKU
36
- · 404 with different Store ID from env
37
- · List categories and typecheck result
38
- · 401 trying to list API events
39
- · 401 to create category and body typecheck
40
- · 204 to update products views
41
- [?25l ❯ tests/index.test.ts (7)
42
- ⠼ Read product and typecheck SKU
43
- · Find and read product by SKU
44
- · 404 with different Store ID from env
45
- · List categories and typecheck result
46
- · 401 trying to list API events
47
- · 401 to create category and body typecheck
48
- · 204 to update products views
49
- [?25l ❯ tests/index.test.ts (7)
50
- ⠴ Read product and typecheck SKU
51
- · Find and read product by SKU
52
- · 404 with different Store ID from env
53
- · List categories and typecheck result
54
- · 401 trying to list API events
55
- · 401 to create category and body typecheck
56
- · 204 to update products views
57
- [?25l ❯ tests/index.test.ts (7)
58
- ⠦ Read product and typecheck SKU
59
- · Find and read product by SKU
60
- · 404 with different Store ID from env
61
- · List categories and typecheck result
62
- · 401 trying to list API events
63
- · 401 to create category and body typecheck
64
- · 204 to update products views
65
- [?25l ❯ tests/index.test.ts (7)
66
- ⠧ Read product and typecheck SKU
67
- · Find and read product by SKU
68
- · 404 with different Store ID from env
69
- · List categories and typecheck result
70
- · 401 trying to list API events
71
- · 401 to create category and body typecheck
72
- · 204 to update products views
73
- [?25l ❯ tests/index.test.ts (7)
74
- ⠇ Read product and typecheck SKU
75
- · Find and read product by SKU
76
- · 404 with different Store ID from env
77
- · List categories and typecheck result
78
- · 401 trying to list API events
79
- · 401 to create category and body typecheck
80
- · 204 to update products views
81
- stdout | tests/index.test.ts > Read product and typecheck SKU
82
- GFJ4714
83
-
84
- [?25l ❯ tests/index.test.ts (7)
85
- ✓ Read product and typecheck SKU
86
- ⠙ Find and read product by SKU
87
- · 404 with different Store ID from env
88
- · List categories and typecheck result
89
- · 401 trying to list API events
90
- · 401 to create category and body typecheck
91
- · 204 to update products views
92
- [?25l ❯ tests/index.test.ts (7)
93
- ✓ Read product and typecheck SKU
94
- ⠹ Find and read product by SKU
95
- · 404 with different Store ID from env
96
- · List categories and typecheck result
97
- · 401 trying to list API events
98
- · 401 to create category and body typecheck
99
- · 204 to update products views
100
- [?25l ❯ tests/index.test.ts (7)
101
- ✓ Read product and typecheck SKU
102
- ✓ Find and read product by SKU
103
- ⠙ 404 with different Store ID from env
104
- · List categories and typecheck result
105
- · 401 trying to list API events
106
- · 401 to create category and body typecheck
107
- · 204 to update products views
108
- [?25l ❯ tests/index.test.ts (7)
109
- ✓ Read product and typecheck SKU
110
- ✓ Find and read product by SKU
111
- ⠹ 404 with different Store ID from env
112
- · List categories and typecheck result
113
- · 401 trying to list API events
114
- · 401 to create category and body typecheck
115
- · 204 to update products views
116
- [?25l ❯ tests/index.test.ts (7)
117
- ✓ Read product and typecheck SKU
118
- ✓ Find and read product by SKU
119
- ⠸ 404 with different Store ID from env
120
- · List categories and typecheck result
121
- · 401 trying to list API events
122
- · 401 to create category and body typecheck
123
- · 204 to update products views
124
- [?25l ❯ tests/index.test.ts (7)
125
- ✓ Read product and typecheck SKU
126
- ✓ Find and read product by SKU
127
- ✓ 404 with different Store ID from env
128
- ⠙ List categories and typecheck result
129
- · 401 trying to list API events
130
- · 401 to create category and body typecheck
131
- · 204 to update products views
132
- [?25l ❯ tests/index.test.ts (7)
133
- ✓ Read product and typecheck SKU
134
- ✓ Find and read product by SKU
135
- ✓ 404 with different Store ID from env
136
- ⠹ List categories and typecheck result
137
- · 401 trying to list API events
138
- · 401 to create category and body typecheck
139
- · 204 to update products views
140
- [?25l ❯ tests/index.test.ts (7)
141
- ✓ Read product and typecheck SKU
142
- ✓ Find and read product by SKU
143
- ✓ 404 with different Store ID from env
144
- ⠸ List categories and typecheck result
145
- · 401 trying to list API events
146
- · 401 to create category and body typecheck
147
- · 204 to update products views
148
- [?25l ❯ tests/index.test.ts (7)
149
- ✓ Read product and typecheck SKU
150
- ✓ Find and read product by SKU
151
- ✓ 404 with different Store ID from env
152
- ⠼ List categories and typecheck result
153
- · 401 trying to list API events
154
- · 401 to create category and body typecheck
155
- · 204 to update products views
156
- [?25l ❯ tests/index.test.ts (7)
157
- ✓ Read product and typecheck SKU
158
- ✓ Find and read product by SKU
159
- ✓ 404 with different Store ID from env
160
- ⠴ List categories and typecheck result
161
- · 401 trying to list API events
162
- · 401 to create category and body typecheck
163
- · 204 to update products views
164
- [?25l ❯ tests/index.test.ts (7)
165
- ✓ Read product and typecheck SKU
166
- ✓ Find and read product by SKU
167
- ✓ 404 with different Store ID from env
168
- ⠦ List categories and typecheck result
169
- · 401 trying to list API events
170
- · 401 to create category and body typecheck
171
- · 204 to update products views
172
- [?25l ❯ tests/index.test.ts (7)
173
- ✓ Read product and typecheck SKU
174
- ✓ Find and read product by SKU
175
- ✓ 404 with different Store ID from env
176
- ⠧ List categories and typecheck result
177
- · 401 trying to list API events
178
- · 401 to create category and body typecheck
179
- · 204 to update products views
180
- [?25l ❯ tests/index.test.ts (7)
181
- ✓ Read product and typecheck SKU
182
- ✓ Find and read product by SKU
183
- ✓ 404 with different Store ID from env
184
- ⠇ List categories and typecheck result
185
- · 401 trying to list API events
186
- · 401 to create category and body typecheck
187
- · 204 to update products views
188
- [?25l ❯ tests/index.test.ts (7)
189
- ✓ Read product and typecheck SKU
190
- ✓ Find and read product by SKU
191
- ✓ 404 with different Store ID from env
192
- ⠏ List categories and typecheck result
193
- · 401 trying to list API events
194
- · 401 to create category and body typecheck
195
- · 204 to update products views
196
- [?25l ❯ tests/index.test.ts (7)
197
- ✓ Read product and typecheck SKU
198
- ✓ Find and read product by SKU
199
- ✓ 404 with different Store ID from env
200
- ⠋ List categories and typecheck result
201
- · 401 trying to list API events
202
- · 401 to create category and body typecheck
203
- · 204 to update products views
204
- [?25l ❯ tests/index.test.ts (7)
205
- ✓ Read product and typecheck SKU
206
- ✓ Find and read product by SKU
207
- ✓ 404 with different Store ID from env
208
- ✓ List categories and typecheck result
209
- ⠙ 401 trying to list API events
210
- · 401 to create category and body typecheck
211
- · 204 to update products views
212
- [?25l ❯ tests/index.test.ts (7)
213
- ✓ Read product and typecheck SKU
214
- ✓ Find and read product by SKU
215
- ✓ 404 with different Store ID from env
216
- ✓ List categories and typecheck result
217
- ✓ 401 trying to list API events
218
- ⠙ 401 to create category and body typecheck
219
- · 204 to update products views
220
- [?25l ❯ tests/index.test.ts (7)
221
- ✓ Read product and typecheck SKU
222
- ✓ Find and read product by SKU
223
- ✓ 404 with different Store ID from env
224
- ✓ List categories and typecheck result
225
- ✓ 401 trying to list API events
226
- ⠹ 401 to create category and body typecheck
227
- · 204 to update products views
228
- [?25l ❯ tests/index.test.ts (7)
229
- ✓ Read product and typecheck SKU
230
- ✓ Find and read product by SKU
231
- ✓ 404 with different Store ID from env
232
- ✓ List categories and typecheck result
233
- ✓ 401 trying to list API events
234
- ⠸ 401 to create category and body typecheck
235
- · 204 to update products views
236
- [?25l ❯ tests/index.test.ts (7)
237
- ✓ Read product and typecheck SKU
238
- ✓ Find and read product by SKU
239
- ✓ 404 with different Store ID from env
240
- ✓ List categories and typecheck result
241
- ✓ 401 trying to list API events
242
- ✓ 401 to create category and body typecheck
243
- ⠙ 204 to update products views
244
- [?25l ❯ tests/index.test.ts (7)
245
- ✓ Read product and typecheck SKU
246
- ✓ Find and read product by SKU
247
- ✓ 404 with different Store ID from env
248
- ✓ List categories and typecheck result
249
- ✓ 401 trying to list API events
250
- ✓ 401 to create category and body typecheck
251
- ⠹ 204 to update products views
252
- [?25l ❯ tests/index.test.ts (7)
253
- ✓ Read product and typecheck SKU
254
- ✓ Find and read product by SKU
255
- ✓ 404 with different Store ID from env
256
- ✓ List categories and typecheck result
257
- ✓ 401 trying to list API events
258
- ✓ 401 to create category and body typecheck
259
- ⠸ 204 to update products views
260
- [?25l ❯ tests/index.test.ts (7)
261
- ✓ Read product and typecheck SKU
262
- ✓ Find and read product by SKU
263
- ✓ 404 with different Store ID from env
264
- ✓ List categories and typecheck result
265
- ✓ 401 trying to list API events
266
- ✓ 401 to create category and body typecheck
267
- ⠼ 204 to update products views
268
- [?25l ❯ tests/index.test.ts (7)
269
- ✓ Read product and typecheck SKU
270
- ✓ Find and read product by SKU
271
- ✓ 404 with different Store ID from env
272
- ✓ List categories and typecheck result
273
- ✓ 401 trying to list API events
274
- ✓ 401 to create category and body typecheck
275
- ⠴ 204 to update products views
276
- [?25l ❯ tests/index.test.ts (7)
277
- ✓ Read product and typecheck SKU
278
- ✓ Find and read product by SKU
279
- ✓ 404 with different Store ID from env
280
- ✓ List categories and typecheck result
281
- ✓ 401 trying to list API events
282
- ✓ 401 to create category and body typecheck
283
- ⠦ 204 to update products views
284
- [?25l ❯ tests/index.test.ts (7)
285
- ✓ Read product and typecheck SKU
286
- ✓ Find and read product by SKU
287
- ✓ 404 with different Store ID from env
288
- ✓ List categories and typecheck result
289
- ✓ 401 trying to list API events
290
- ✓ 401 to create category and body typecheck
291
- ⠧ 204 to update products views
292
- [?25l ❯ tests/index.test.ts (7)
293
- ✓ Read product and typecheck SKU
294
- ✓ Find and read product by SKU
295
- ✓ 404 with different Store ID from env
296
- ✓ List categories and typecheck result
297
- ✓ 401 trying to list API events
298
- ✓ 401 to create category and body typecheck
299
- ⠇ 204 to update products views
300
- [?25l ✓ tests/index.test.ts (7) 648ms
301
- ✓ Read product and typecheck SKU
302
- ✓ Find and read product by SKU
303
- ✓ 404 with different Store ID from env
304
- ✓ List categories and typecheck result
305
- ✓ 401 trying to list API events
306
- ✓ 401 to create category and body typecheck
307
- ✓ 204 to update products views
308
- [?25l ✓ tests/index.test.ts (7) 648ms
309
- ✓ Read product and typecheck SKU
310
- ✓ Find and read product by SKU
311
- ✓ 404 with different Store ID from env
312
- ✓ List categories and typecheck result
313
- ✓ 401 trying to list API events
314
- ✓ 401 to create category and body typecheck
315
- ✓ 204 to update products views
316
-
317
-  Test Files  1 passed (1)
318
-  Tests  7 passed (7)
319
-  Start at  21:58:28
320
-  Duration  1.22s (transform 127ms, setup 0ms, collect 116ms, tests 648ms, environment 0ms, prepare 141ms)
321
-
322
- [?25h
package/CHANGELOG.md DELETED
@@ -1 +0,0 @@
1
- Please refer to GitHub [repository releases](https://github.com/ecomplus/cloud-commerce/releases) or monorepo unified [CHANGELOG.md](https://github.com/ecomplus/cloud-commerce/blob/main/CHANGELOG.md).
package/src/api.ts DELETED
@@ -1,303 +0,0 @@
1
- import type {
2
- ResourceOpQuery,
3
- Endpoint,
4
- Config,
5
- ResponseBody,
6
- RequestBody,
7
- ErrorBody,
8
- } from '../types.d';
9
-
10
- declare global {
11
- /* eslint-disable no-var, vars-on-top */
12
- // @ts-ignore
13
- var $apiMergeConfig: Partial<Config> | undefined;
14
- // eslint-disable-next-line
15
- var __apiCache: Record<string, {
16
- timestamp: number,
17
- res: Response & { data: any },
18
- }>;
19
- /* eslint-enable no-var */
20
- }
21
- if (!globalThis.__apiCache) {
22
- globalThis.__apiCache = {};
23
- }
24
-
25
- const _env = (
26
- (typeof process === 'object' && process?.env)
27
- || globalThis
28
- ) as Record<string, any>;
29
-
30
- class ApiError extends Error {
31
- config: Config;
32
- response?: Response & { data?: ErrorBody };
33
- statusCode?: number;
34
- data?: ErrorBody;
35
- isTimeout: boolean;
36
- constructor(
37
- config: Config,
38
- response?: ApiError['response'],
39
- msg?: string,
40
- isTimeout: boolean = false,
41
- ) {
42
- if (response) {
43
- super(response.statusText);
44
- this.data = response.data;
45
- this.statusCode = response.status;
46
- } else {
47
- super(msg || 'Request error');
48
- }
49
- this.config = config;
50
- this.response = response;
51
- this.isTimeout = isTimeout;
52
- }
53
- }
54
-
55
- const def = {
56
- middleware(config: Config) {
57
- const headers: Headers | Record<string, string> = { ...config.headers };
58
- if (!config.isNoAuth) {
59
- if (config.accessToken) {
60
- // eslint-disable-next-line dot-notation
61
- headers['Authorization'] = `Bearer ${config.accessToken}`;
62
- } else {
63
- const authenticationId = config.authenticationId || _env.ECOM_AUTHENTICATION_ID;
64
- const apiKey = config.apiKey || _env.ECOM_API_KEY;
65
- if (authenticationId && apiKey) {
66
- const rawAuth = `${authenticationId}:${apiKey}`;
67
- const base64Auth = typeof Buffer === 'function'
68
- ? Buffer.from(rawAuth).toString('base64') : btoa(rawAuth);
69
- // eslint-disable-next-line dot-notation
70
- headers['Authorization'] = `Basic ${base64Auth}`;
71
- }
72
- }
73
- }
74
- let url = config.baseUrl || _env.API_BASE_URL || 'https://ecomplus.io/v2';
75
- const { endpoint, params } = config;
76
- if (
77
- endpoint !== 'login'
78
- && endpoint !== 'authenticate'
79
- && endpoint !== 'ask-auth-callback'
80
- && endpoint !== 'check-username'
81
- ) {
82
- const storeId = config.storeId || _env.ECOM_STORE_ID;
83
- if (!storeId) {
84
- throw new Error('`storeId` must be set in config or `ECOM_STORE_ID` env var');
85
- }
86
- url += `/:${storeId}`;
87
- const lang = config.lang || _env.ECOM_LANG;
88
- if (lang) {
89
- url += `,lang:${lang}`;
90
- }
91
- }
92
- url += `/${endpoint}`;
93
- if (typeof params === 'string') {
94
- url += `?${params}`;
95
- } else {
96
- const paramsObj: Exclude<typeof params, string> = params || {};
97
- (['fields', 'sort'] as const)
98
- .forEach((param) => {
99
- const value = config[param];
100
- if (value && !paramsObj[param]) {
101
- paramsObj[param] = value.join(',');
102
- }
103
- });
104
- (['limit', 'offset', 'count', 'buckets', 'concise', 'verbose'] as const)
105
- .forEach((param) => {
106
- const value = config[param];
107
- if (value && !paramsObj[param]) {
108
- paramsObj[param] = value;
109
- }
110
- });
111
- if (Object.keys(paramsObj).length) {
112
- const searchParams = new URLSearchParams();
113
- Object.keys(paramsObj).forEach((key) => {
114
- const values = paramsObj[key];
115
- if (Array.isArray(values)) {
116
- values.forEach((value: string | number) => {
117
- // https://github.com/microsoft/TypeScript/issues/32951
118
- searchParams.append(key, value as string);
119
- });
120
- } else if (values !== undefined) {
121
- searchParams.append(key, values as string);
122
- }
123
- });
124
- url += `?${searchParams.toString()}`;
125
- }
126
- }
127
- return { url, headers };
128
- },
129
- };
130
-
131
- const setMiddleware = (middleware: typeof def.middleware) => {
132
- def.middleware = middleware;
133
- };
134
-
135
- const api = async <T extends Config & { body?: any, data?: any }>(
136
- requestConfig: T,
137
- _retries = 0,
138
- ): Promise<Response & {
139
- config: Config,
140
- data: ResponseBody<T>,
141
- }> => {
142
- const config = globalThis.$apiMergeConfig
143
- ? { ...globalThis.$apiMergeConfig, ...requestConfig }
144
- : requestConfig;
145
- const { url, headers } = def.middleware(config);
146
- const method = config.method?.toUpperCase() || 'GET';
147
- const {
148
- timeout = 20000,
149
- maxRetries = 3,
150
- cacheMaxAge = Number(_env.API_CACHE_MAX_AGE) || 120000 /* 2 minutes */,
151
- } = config;
152
- const canCache = method === 'GET' && config.canCache;
153
- let cacheKey: string | undefined;
154
- if (canCache) {
155
- cacheKey = `${url}${JSON.stringify(headers)}`;
156
- const cached = globalThis.__apiCache[cacheKey];
157
- if (cached && Date.now() - cached.timestamp <= cacheMaxAge) {
158
- return { ...cached.res, config };
159
- }
160
- }
161
- const bodyObject = config.body || config.data;
162
- let body: string | undefined;
163
- if (bodyObject) {
164
- body = JSON.stringify(bodyObject);
165
- headers['Content-Type'] = 'application/json';
166
- }
167
-
168
- const abortController = new AbortController();
169
- let isTimeout = false;
170
- const timer = setTimeout(() => {
171
- abortController.abort();
172
- isTimeout = true;
173
- }, timeout);
174
- let response: Response & { data?: any } | undefined;
175
- try {
176
- response = await (config.fetch || fetch)(url, {
177
- method,
178
- headers,
179
- body,
180
- signal: abortController.signal,
181
- });
182
- } catch (err: any) {
183
- let msg = err.message;
184
- if (err.cause) {
185
- msg += ` - ${err.cause}`;
186
- }
187
- throw new ApiError(config, response, msg, isTimeout);
188
- }
189
- clearTimeout(timer);
190
-
191
- if (response) {
192
- if (response.ok) {
193
- const res = response as Response & { data: any, config: Config };
194
- res.data = response.status !== 204 ? await response.json() : null;
195
- if (canCache && cacheKey) {
196
- globalThis.__apiCache[cacheKey] = {
197
- timestamp: Date.now(),
198
- res: res as Response & { data: any },
199
- };
200
- }
201
- res.config = config;
202
- return res;
203
- }
204
- const { status } = response;
205
- if (maxRetries < _retries && (status === 429 || status >= 500)) {
206
- const retryAfter = response.headers.get('retry-after');
207
- return new Promise((resolve, reject) => {
208
- setTimeout(() => {
209
- api(requestConfig, _retries + 1).then(resolve).catch(reject);
210
- }, (retryAfter && parseInt(retryAfter, 10) * 1000) || 5000);
211
- });
212
- }
213
- }
214
- try {
215
- response.data = await response?.json() as ErrorBody;
216
- } catch (e) {
217
- //
218
- }
219
- throw new ApiError(config, response);
220
- };
221
-
222
- type AbstractedConfig = Omit<Config, 'endpoint' | 'method'>;
223
-
224
- const get = <E extends Endpoint, C extends AbstractedConfig>(
225
- endpoint: E,
226
- config?: C,
227
- ): Promise<Response & {
228
- config: Config,
229
- data: ResponseBody<C & { endpoint: E }>,
230
- }> => {
231
- // @ts-ignore
232
- return api({ ...config, endpoint });
233
- };
234
-
235
- const post = <E extends Endpoint, C extends AbstractedConfig>(
236
- endpoint: E,
237
- body: RequestBody<{ endpoint: E, method: 'post' }>,
238
- config?: E extends 'login' | 'authenticate' ? AbstractedConfig : C,
239
- ) => {
240
- return api({
241
- ...config,
242
- method: 'post',
243
- endpoint,
244
- body,
245
- });
246
- };
247
-
248
- const put = <E extends Exclude<Endpoint, ResourceOpQuery>, C extends AbstractedConfig>(
249
- endpoint: E,
250
- body: RequestBody<{ endpoint: E, method: 'put' }>,
251
- config?: C,
252
- ) => {
253
- return api({
254
- ...config,
255
- method: 'put',
256
- endpoint,
257
- body,
258
- });
259
- };
260
-
261
- const patch = <E extends Endpoint, C extends AbstractedConfig>(
262
- endpoint: E,
263
- body: RequestBody<{ endpoint: E, method: 'patch' }>,
264
- config?: C,
265
- ) => {
266
- return api({
267
- ...config,
268
- method: 'patch',
269
- endpoint,
270
- body,
271
- });
272
- };
273
-
274
- const del = (endpoint: Endpoint, config?: AbstractedConfig) => api({
275
- ...config,
276
- method: 'delete',
277
- endpoint,
278
- });
279
-
280
- api.get = get;
281
- api.post = post;
282
- api.put = put;
283
- api.patch = patch;
284
- api.del = del;
285
- api.delete = del;
286
-
287
- export default api;
288
-
289
- export {
290
- setMiddleware,
291
- get,
292
- post,
293
- put,
294
- patch,
295
- del,
296
- ApiError,
297
- };
298
-
299
- export type ApiEndpoint = Endpoint;
300
-
301
- export type ApiConfig = Config;
302
-
303
- export type ApiErrorBody = ErrorBody;
@@ -1,103 +0,0 @@
1
- import * as dotenv from 'dotenv';
2
- import { test, expect } from 'vitest';
3
- import api, { type ApiError } from '../src/api';
4
-
5
- const productId = '618041aa239b7206d3fc06de' as string & { length: 24 };
6
- test('Read product and typecheck SKU', async () => {
7
- const { data } = await api({
8
- storeId: 1056,
9
- endpoint: `products/${productId}`,
10
- });
11
- if (data.sku === '123') {
12
- console.log('\\o/');
13
- }
14
- console.log(data.sku);
15
- expect(data.sku).toBeTypeOf('string');
16
- expect(data._id).toBe(productId);
17
- });
18
-
19
- test('Find and read product by SKU', async () => {
20
- const { data } = await api({
21
- storeId: 1056,
22
- endpoint: 'products/sku:GFJ4714',
23
- });
24
- expect(data.sku).toBe('GFJ4714');
25
- });
26
-
27
- test('404 with different Store ID from env', async () => {
28
- try {
29
- const { data } = await api.get(`products/${productId}`, {
30
- storeId: 1011,
31
- });
32
- console.log(data);
33
- throw new Error('Should have thrown not found');
34
- } catch (err: any) {
35
- const error = err as ApiError;
36
- expect(error.statusCode).toBe(404);
37
- expect(error.response?.status).toBe(404);
38
- }
39
- });
40
-
41
- test('List categories and typecheck result', async () => {
42
- process.env.ECOM_STORE_ID = '1056';
43
- const { data } = await api.get('categories', {
44
- fields: ['name'] as const,
45
- });
46
- if (!data.result.length) {
47
- console.log('Any category found');
48
- }
49
- expect(Array.isArray(data.result)).toBe(true);
50
- expect(data.result[0].name).toBeTypeOf('string');
51
- // @ts-ignore
52
- expect(data.result[0].slug).toBeTypeOf('undefined');
53
- expect(data.meta).toBeTypeOf('object');
54
- expect(data.meta.offset).toBeTypeOf('number');
55
- const { data: data2 } = await api.get('categories', {
56
- limit: 1,
57
- });
58
- expect(data2.result.length).toBe(1);
59
- const { data: data3 } = await api.get('categories', {
60
- params: {
61
- slug: 'this-slug-doesnt-exists-123',
62
- },
63
- });
64
- expect(data3.result.length).toBe(0);
65
- });
66
-
67
- test('401 trying to list API events', async () => {
68
- try {
69
- const { data } = await api.get('events/orders');
70
- console.log(data);
71
- console.log(data.result[0].modified_fields);
72
- throw new Error('Should have thrown unauthorized');
73
- } catch (err: any) {
74
- const error = err as ApiError;
75
- expect(error.statusCode).toBe(401);
76
- expect(error.response?.status).toBe(401);
77
- }
78
- });
79
-
80
- test('401 to create category and body typecheck', async () => {
81
- try {
82
- const { data } = await api.post('categories', {
83
- name: 'Test category',
84
- }, {
85
- accessToken: 'invalid',
86
- });
87
- console.log(data._id);
88
- throw new Error('Should have thrown unauthorized');
89
- } catch (err: any) {
90
- const error = err as ApiError;
91
- expect(error.statusCode).toBe(401);
92
- expect(error.response?.status).toBe(401);
93
- }
94
- });
95
-
96
- test('204 to update products views', async () => {
97
- dotenv.config();
98
- const isAuthenticating = !!process.env.ECOM_API_KEY;
99
- const { status } = await api.patch(`products/${productId}`, {
100
- views: 100,
101
- });
102
- expect(status).toBe(isAuthenticating ? 204 : 401);
103
- });
package/tsconfig.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "declaration": true
5
- }
6
- }