@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 +6 -6
- package/lib/api.js.map +1 -1
- package/package.json +7 -2
- package/types.ts +7 -1
- package/.env +0 -3
- package/.turbo/turbo-build.log +0 -5
- package/.turbo/turbo-test.log +0 -322
- package/CHANGELOG.md +0 -1
- package/src/api.ts +0 -303
- package/tests/index.test.ts +0 -103
- package/tsconfig.json +0 -6
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
|
|
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?:
|
|
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
|
|
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?:
|
|
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
|
|
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
|
|
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;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAoBA,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,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ACH,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.
|
|
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.
|
|
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
package/.env
DELETED
package/.turbo/turbo-build.log
DELETED
package/.turbo/turbo-test.log
DELETED
|
@@ -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
|
-
[7m[1m[36m RUN [39m[22m[27m [36mv1.3.1[39m [90m/home/leo/code/ecomplus/cloud-commerce/packages/api[39m
|
|
8
|
-
|
|
9
|
-
[?25l [90m·[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
10
|
-
[90m·[39m Read product and typecheck SKU
|
|
11
|
-
[90m·[39m Find and read product by SKU
|
|
12
|
-
[90m·[39m 404 with different Store ID from env
|
|
13
|
-
[90m·[39m List categories and typecheck result
|
|
14
|
-
[90m·[39m 401 trying to list API events
|
|
15
|
-
[90m·[39m 401 to create category and body typecheck
|
|
16
|
-
[90m·[39m 204 to update products views
|
|
17
|
-
[?25l[?25l[?25l[?25l[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
18
|
-
[33m⠙[39m Read product and typecheck SKU
|
|
19
|
-
[90m·[39m Find and read product by SKU
|
|
20
|
-
[90m·[39m 404 with different Store ID from env
|
|
21
|
-
[90m·[39m List categories and typecheck result
|
|
22
|
-
[90m·[39m 401 trying to list API events
|
|
23
|
-
[90m·[39m 401 to create category and body typecheck
|
|
24
|
-
[90m·[39m 204 to update products views
|
|
25
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
26
|
-
[33m⠹[39m Read product and typecheck SKU
|
|
27
|
-
[90m·[39m Find and read product by SKU
|
|
28
|
-
[90m·[39m 404 with different Store ID from env
|
|
29
|
-
[90m·[39m List categories and typecheck result
|
|
30
|
-
[90m·[39m 401 trying to list API events
|
|
31
|
-
[90m·[39m 401 to create category and body typecheck
|
|
32
|
-
[90m·[39m 204 to update products views
|
|
33
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
34
|
-
[33m⠸[39m Read product and typecheck SKU
|
|
35
|
-
[90m·[39m Find and read product by SKU
|
|
36
|
-
[90m·[39m 404 with different Store ID from env
|
|
37
|
-
[90m·[39m List categories and typecheck result
|
|
38
|
-
[90m·[39m 401 trying to list API events
|
|
39
|
-
[90m·[39m 401 to create category and body typecheck
|
|
40
|
-
[90m·[39m 204 to update products views
|
|
41
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
42
|
-
[33m⠼[39m Read product and typecheck SKU
|
|
43
|
-
[90m·[39m Find and read product by SKU
|
|
44
|
-
[90m·[39m 404 with different Store ID from env
|
|
45
|
-
[90m·[39m List categories and typecheck result
|
|
46
|
-
[90m·[39m 401 trying to list API events
|
|
47
|
-
[90m·[39m 401 to create category and body typecheck
|
|
48
|
-
[90m·[39m 204 to update products views
|
|
49
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
50
|
-
[33m⠴[39m Read product and typecheck SKU
|
|
51
|
-
[90m·[39m Find and read product by SKU
|
|
52
|
-
[90m·[39m 404 with different Store ID from env
|
|
53
|
-
[90m·[39m List categories and typecheck result
|
|
54
|
-
[90m·[39m 401 trying to list API events
|
|
55
|
-
[90m·[39m 401 to create category and body typecheck
|
|
56
|
-
[90m·[39m 204 to update products views
|
|
57
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
58
|
-
[33m⠦[39m Read product and typecheck SKU
|
|
59
|
-
[90m·[39m Find and read product by SKU
|
|
60
|
-
[90m·[39m 404 with different Store ID from env
|
|
61
|
-
[90m·[39m List categories and typecheck result
|
|
62
|
-
[90m·[39m 401 trying to list API events
|
|
63
|
-
[90m·[39m 401 to create category and body typecheck
|
|
64
|
-
[90m·[39m 204 to update products views
|
|
65
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
66
|
-
[33m⠧[39m Read product and typecheck SKU
|
|
67
|
-
[90m·[39m Find and read product by SKU
|
|
68
|
-
[90m·[39m 404 with different Store ID from env
|
|
69
|
-
[90m·[39m List categories and typecheck result
|
|
70
|
-
[90m·[39m 401 trying to list API events
|
|
71
|
-
[90m·[39m 401 to create category and body typecheck
|
|
72
|
-
[90m·[39m 204 to update products views
|
|
73
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
74
|
-
[33m⠇[39m Read product and typecheck SKU
|
|
75
|
-
[90m·[39m Find and read product by SKU
|
|
76
|
-
[90m·[39m 404 with different Store ID from env
|
|
77
|
-
[90m·[39m List categories and typecheck result
|
|
78
|
-
[90m·[39m 401 trying to list API events
|
|
79
|
-
[90m·[39m 401 to create category and body typecheck
|
|
80
|
-
[90m·[39m 204 to update products views
|
|
81
|
-
[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G[90mstdout[2m | tests/index.test.ts[2m > [22m[2mRead product and typecheck SKU[22m[39m
|
|
82
|
-
GFJ4714
|
|
83
|
-
|
|
84
|
-
[?25l [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
85
|
-
[32m✓[39m Read product and typecheck SKU
|
|
86
|
-
[33m⠙[39m Find and read product by SKU
|
|
87
|
-
[90m·[39m 404 with different Store ID from env
|
|
88
|
-
[90m·[39m List categories and typecheck result
|
|
89
|
-
[90m·[39m 401 trying to list API events
|
|
90
|
-
[90m·[39m 401 to create category and body typecheck
|
|
91
|
-
[90m·[39m 204 to update products views
|
|
92
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
93
|
-
[32m✓[39m Read product and typecheck SKU
|
|
94
|
-
[33m⠹[39m Find and read product by SKU
|
|
95
|
-
[90m·[39m 404 with different Store ID from env
|
|
96
|
-
[90m·[39m List categories and typecheck result
|
|
97
|
-
[90m·[39m 401 trying to list API events
|
|
98
|
-
[90m·[39m 401 to create category and body typecheck
|
|
99
|
-
[90m·[39m 204 to update products views
|
|
100
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
101
|
-
[32m✓[39m Read product and typecheck SKU
|
|
102
|
-
[32m✓[39m Find and read product by SKU
|
|
103
|
-
[33m⠙[39m 404 with different Store ID from env
|
|
104
|
-
[90m·[39m List categories and typecheck result
|
|
105
|
-
[90m·[39m 401 trying to list API events
|
|
106
|
-
[90m·[39m 401 to create category and body typecheck
|
|
107
|
-
[90m·[39m 204 to update products views
|
|
108
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
109
|
-
[32m✓[39m Read product and typecheck SKU
|
|
110
|
-
[32m✓[39m Find and read product by SKU
|
|
111
|
-
[33m⠹[39m 404 with different Store ID from env
|
|
112
|
-
[90m·[39m List categories and typecheck result
|
|
113
|
-
[90m·[39m 401 trying to list API events
|
|
114
|
-
[90m·[39m 401 to create category and body typecheck
|
|
115
|
-
[90m·[39m 204 to update products views
|
|
116
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
117
|
-
[32m✓[39m Read product and typecheck SKU
|
|
118
|
-
[32m✓[39m Find and read product by SKU
|
|
119
|
-
[33m⠸[39m 404 with different Store ID from env
|
|
120
|
-
[90m·[39m List categories and typecheck result
|
|
121
|
-
[90m·[39m 401 trying to list API events
|
|
122
|
-
[90m·[39m 401 to create category and body typecheck
|
|
123
|
-
[90m·[39m 204 to update products views
|
|
124
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
125
|
-
[32m✓[39m Read product and typecheck SKU
|
|
126
|
-
[32m✓[39m Find and read product by SKU
|
|
127
|
-
[32m✓[39m 404 with different Store ID from env
|
|
128
|
-
[33m⠙[39m List categories and typecheck result
|
|
129
|
-
[90m·[39m 401 trying to list API events
|
|
130
|
-
[90m·[39m 401 to create category and body typecheck
|
|
131
|
-
[90m·[39m 204 to update products views
|
|
132
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
133
|
-
[32m✓[39m Read product and typecheck SKU
|
|
134
|
-
[32m✓[39m Find and read product by SKU
|
|
135
|
-
[32m✓[39m 404 with different Store ID from env
|
|
136
|
-
[33m⠹[39m List categories and typecheck result
|
|
137
|
-
[90m·[39m 401 trying to list API events
|
|
138
|
-
[90m·[39m 401 to create category and body typecheck
|
|
139
|
-
[90m·[39m 204 to update products views
|
|
140
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
141
|
-
[32m✓[39m Read product and typecheck SKU
|
|
142
|
-
[32m✓[39m Find and read product by SKU
|
|
143
|
-
[32m✓[39m 404 with different Store ID from env
|
|
144
|
-
[33m⠸[39m List categories and typecheck result
|
|
145
|
-
[90m·[39m 401 trying to list API events
|
|
146
|
-
[90m·[39m 401 to create category and body typecheck
|
|
147
|
-
[90m·[39m 204 to update products views
|
|
148
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
149
|
-
[32m✓[39m Read product and typecheck SKU
|
|
150
|
-
[32m✓[39m Find and read product by SKU
|
|
151
|
-
[32m✓[39m 404 with different Store ID from env
|
|
152
|
-
[33m⠼[39m List categories and typecheck result
|
|
153
|
-
[90m·[39m 401 trying to list API events
|
|
154
|
-
[90m·[39m 401 to create category and body typecheck
|
|
155
|
-
[90m·[39m 204 to update products views
|
|
156
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
157
|
-
[32m✓[39m Read product and typecheck SKU
|
|
158
|
-
[32m✓[39m Find and read product by SKU
|
|
159
|
-
[32m✓[39m 404 with different Store ID from env
|
|
160
|
-
[33m⠴[39m List categories and typecheck result
|
|
161
|
-
[90m·[39m 401 trying to list API events
|
|
162
|
-
[90m·[39m 401 to create category and body typecheck
|
|
163
|
-
[90m·[39m 204 to update products views
|
|
164
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
165
|
-
[32m✓[39m Read product and typecheck SKU
|
|
166
|
-
[32m✓[39m Find and read product by SKU
|
|
167
|
-
[32m✓[39m 404 with different Store ID from env
|
|
168
|
-
[33m⠦[39m List categories and typecheck result
|
|
169
|
-
[90m·[39m 401 trying to list API events
|
|
170
|
-
[90m·[39m 401 to create category and body typecheck
|
|
171
|
-
[90m·[39m 204 to update products views
|
|
172
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
173
|
-
[32m✓[39m Read product and typecheck SKU
|
|
174
|
-
[32m✓[39m Find and read product by SKU
|
|
175
|
-
[32m✓[39m 404 with different Store ID from env
|
|
176
|
-
[33m⠧[39m List categories and typecheck result
|
|
177
|
-
[90m·[39m 401 trying to list API events
|
|
178
|
-
[90m·[39m 401 to create category and body typecheck
|
|
179
|
-
[90m·[39m 204 to update products views
|
|
180
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
181
|
-
[32m✓[39m Read product and typecheck SKU
|
|
182
|
-
[32m✓[39m Find and read product by SKU
|
|
183
|
-
[32m✓[39m 404 with different Store ID from env
|
|
184
|
-
[33m⠇[39m List categories and typecheck result
|
|
185
|
-
[90m·[39m 401 trying to list API events
|
|
186
|
-
[90m·[39m 401 to create category and body typecheck
|
|
187
|
-
[90m·[39m 204 to update products views
|
|
188
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
189
|
-
[32m✓[39m Read product and typecheck SKU
|
|
190
|
-
[32m✓[39m Find and read product by SKU
|
|
191
|
-
[32m✓[39m 404 with different Store ID from env
|
|
192
|
-
[33m⠏[39m List categories and typecheck result
|
|
193
|
-
[90m·[39m 401 trying to list API events
|
|
194
|
-
[90m·[39m 401 to create category and body typecheck
|
|
195
|
-
[90m·[39m 204 to update products views
|
|
196
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
197
|
-
[32m✓[39m Read product and typecheck SKU
|
|
198
|
-
[32m✓[39m Find and read product by SKU
|
|
199
|
-
[32m✓[39m 404 with different Store ID from env
|
|
200
|
-
[33m⠋[39m List categories and typecheck result
|
|
201
|
-
[90m·[39m 401 trying to list API events
|
|
202
|
-
[90m·[39m 401 to create category and body typecheck
|
|
203
|
-
[90m·[39m 204 to update products views
|
|
204
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
205
|
-
[32m✓[39m Read product and typecheck SKU
|
|
206
|
-
[32m✓[39m Find and read product by SKU
|
|
207
|
-
[32m✓[39m 404 with different Store ID from env
|
|
208
|
-
[32m✓[39m List categories and typecheck result
|
|
209
|
-
[33m⠙[39m 401 trying to list API events
|
|
210
|
-
[90m·[39m 401 to create category and body typecheck
|
|
211
|
-
[90m·[39m 204 to update products views
|
|
212
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
213
|
-
[32m✓[39m Read product and typecheck SKU
|
|
214
|
-
[32m✓[39m Find and read product by SKU
|
|
215
|
-
[32m✓[39m 404 with different Store ID from env
|
|
216
|
-
[32m✓[39m List categories and typecheck result
|
|
217
|
-
[32m✓[39m 401 trying to list API events
|
|
218
|
-
[33m⠙[39m 401 to create category and body typecheck
|
|
219
|
-
[90m·[39m 204 to update products views
|
|
220
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
221
|
-
[32m✓[39m Read product and typecheck SKU
|
|
222
|
-
[32m✓[39m Find and read product by SKU
|
|
223
|
-
[32m✓[39m 404 with different Store ID from env
|
|
224
|
-
[32m✓[39m List categories and typecheck result
|
|
225
|
-
[32m✓[39m 401 trying to list API events
|
|
226
|
-
[33m⠹[39m 401 to create category and body typecheck
|
|
227
|
-
[90m·[39m 204 to update products views
|
|
228
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
229
|
-
[32m✓[39m Read product and typecheck SKU
|
|
230
|
-
[32m✓[39m Find and read product by SKU
|
|
231
|
-
[32m✓[39m 404 with different Store ID from env
|
|
232
|
-
[32m✓[39m List categories and typecheck result
|
|
233
|
-
[32m✓[39m 401 trying to list API events
|
|
234
|
-
[33m⠸[39m 401 to create category and body typecheck
|
|
235
|
-
[90m·[39m 204 to update products views
|
|
236
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
237
|
-
[32m✓[39m Read product and typecheck SKU
|
|
238
|
-
[32m✓[39m Find and read product by SKU
|
|
239
|
-
[32m✓[39m 404 with different Store ID from env
|
|
240
|
-
[32m✓[39m List categories and typecheck result
|
|
241
|
-
[32m✓[39m 401 trying to list API events
|
|
242
|
-
[32m✓[39m 401 to create category and body typecheck
|
|
243
|
-
[33m⠙[39m 204 to update products views
|
|
244
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
245
|
-
[32m✓[39m Read product and typecheck SKU
|
|
246
|
-
[32m✓[39m Find and read product by SKU
|
|
247
|
-
[32m✓[39m 404 with different Store ID from env
|
|
248
|
-
[32m✓[39m List categories and typecheck result
|
|
249
|
-
[32m✓[39m 401 trying to list API events
|
|
250
|
-
[32m✓[39m 401 to create category and body typecheck
|
|
251
|
-
[33m⠹[39m 204 to update products views
|
|
252
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
253
|
-
[32m✓[39m Read product and typecheck SKU
|
|
254
|
-
[32m✓[39m Find and read product by SKU
|
|
255
|
-
[32m✓[39m 404 with different Store ID from env
|
|
256
|
-
[32m✓[39m List categories and typecheck result
|
|
257
|
-
[32m✓[39m 401 trying to list API events
|
|
258
|
-
[32m✓[39m 401 to create category and body typecheck
|
|
259
|
-
[33m⠸[39m 204 to update products views
|
|
260
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
261
|
-
[32m✓[39m Read product and typecheck SKU
|
|
262
|
-
[32m✓[39m Find and read product by SKU
|
|
263
|
-
[32m✓[39m 404 with different Store ID from env
|
|
264
|
-
[32m✓[39m List categories and typecheck result
|
|
265
|
-
[32m✓[39m 401 trying to list API events
|
|
266
|
-
[32m✓[39m 401 to create category and body typecheck
|
|
267
|
-
[33m⠼[39m 204 to update products views
|
|
268
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
269
|
-
[32m✓[39m Read product and typecheck SKU
|
|
270
|
-
[32m✓[39m Find and read product by SKU
|
|
271
|
-
[32m✓[39m 404 with different Store ID from env
|
|
272
|
-
[32m✓[39m List categories and typecheck result
|
|
273
|
-
[32m✓[39m 401 trying to list API events
|
|
274
|
-
[32m✓[39m 401 to create category and body typecheck
|
|
275
|
-
[33m⠴[39m 204 to update products views
|
|
276
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
277
|
-
[32m✓[39m Read product and typecheck SKU
|
|
278
|
-
[32m✓[39m Find and read product by SKU
|
|
279
|
-
[32m✓[39m 404 with different Store ID from env
|
|
280
|
-
[32m✓[39m List categories and typecheck result
|
|
281
|
-
[32m✓[39m 401 trying to list API events
|
|
282
|
-
[32m✓[39m 401 to create category and body typecheck
|
|
283
|
-
[33m⠦[39m 204 to update products views
|
|
284
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
285
|
-
[32m✓[39m Read product and typecheck SKU
|
|
286
|
-
[32m✓[39m Find and read product by SKU
|
|
287
|
-
[32m✓[39m 404 with different Store ID from env
|
|
288
|
-
[32m✓[39m List categories and typecheck result
|
|
289
|
-
[32m✓[39m 401 trying to list API events
|
|
290
|
-
[32m✓[39m 401 to create category and body typecheck
|
|
291
|
-
[33m⠧[39m 204 to update products views
|
|
292
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m
|
|
293
|
-
[32m✓[39m Read product and typecheck SKU
|
|
294
|
-
[32m✓[39m Find and read product by SKU
|
|
295
|
-
[32m✓[39m 404 with different Store ID from env
|
|
296
|
-
[32m✓[39m List categories and typecheck result
|
|
297
|
-
[32m✓[39m 401 trying to list API events
|
|
298
|
-
[32m✓[39m 401 to create category and body typecheck
|
|
299
|
-
[33m⠇[39m 204 to update products views
|
|
300
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m[33m 648[2mms[22m[39m
|
|
301
|
-
[32m✓[39m Read product and typecheck SKU
|
|
302
|
-
[32m✓[39m Find and read product by SKU
|
|
303
|
-
[32m✓[39m 404 with different Store ID from env
|
|
304
|
-
[32m✓[39m List categories and typecheck result
|
|
305
|
-
[32m✓[39m 401 trying to list API events
|
|
306
|
-
[32m✓[39m 401 to create category and body typecheck
|
|
307
|
-
[32m✓[39m 204 to update products views
|
|
308
|
-
[?25l[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m [2mtests/[22mindex[2m.test.ts[22m[2m (7)[22m[33m 648[2mms[22m[39m
|
|
309
|
-
[32m✓[39m Read product and typecheck SKU
|
|
310
|
-
[32m✓[39m Find and read product by SKU
|
|
311
|
-
[32m✓[39m 404 with different Store ID from env
|
|
312
|
-
[32m✓[39m List categories and typecheck result
|
|
313
|
-
[32m✓[39m 401 trying to list API events
|
|
314
|
-
[32m✓[39m 401 to create category and body typecheck
|
|
315
|
-
[32m✓[39m 204 to update products views
|
|
316
|
-
|
|
317
|
-
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
318
|
-
[2m Tests [22m [1m[32m7 passed[39m[22m[90m (7)[39m
|
|
319
|
-
[2m Start at [22m 21:58:28
|
|
320
|
-
[2m Duration [22m 1.22s[2m (transform 127ms, setup 0ms, collect 116ms, tests 648ms, environment 0ms, prepare 141ms)[22m
|
|
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;
|
package/tests/index.test.ts
DELETED
|
@@ -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
|
-
});
|