@cloudcommerce/api 0.0.2 → 0.0.5

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.
@@ -1,5 +1,5 @@
1
- @cloudcommerce/api:build: cache hit, replaying output 77c93922e43c4ac3
1
+ @cloudcommerce/api:build: cache hit, replaying output 6f3e88d4d63cc69e
2
2
  @cloudcommerce/api:build: 
3
- @cloudcommerce/api:build: > @cloudcommerce/api@0.0.2-alpha.0 build /home/leo/code/ecomplus/cloud-commerce/packages/api
4
- @cloudcommerce/api:build: > tsc --build
3
+ @cloudcommerce/api:build: > @cloudcommerce/api@0.0.4 build /home/leo/code/ecomplus/cloud-commerce/packages/api
4
+ @cloudcommerce/api:build: > sh scripts/build.sh
5
5
  @cloudcommerce/api:build: 
@@ -0,0 +1,15 @@
1
+ @cloudcommerce/api:test: cache hit, replaying output 11fdf26ab00d55b5
2
+ @cloudcommerce/api:test: 
3
+ @cloudcommerce/api:test: > @cloudcommerce/api@0.0.4 test /home/leo/code/ecomplus/cloud-commerce/packages/api
4
+ @cloudcommerce/api:test: > tsc -p ../../tsconfig.test.json && vitest run
5
+ @cloudcommerce/api:test: 
6
+ @cloudcommerce/api:test: 
7
+ @cloudcommerce/api:test:  RUN v0.15.1 /home/leo/code/ecomplus/cloud-commerce/packages/api
8
+ @cloudcommerce/api:test: 
9
+ @cloudcommerce/api:test:  ✓ tests/index.test.ts > Read product and typecheck SKU
10
+ @cloudcommerce/api:test:  ✓ tests/index.test.ts > 404 with different Store ID from env
11
+ @cloudcommerce/api:test: 
12
+ @cloudcommerce/api:test: Test Files 1 passed (1)
13
+ @cloudcommerce/api:test:  Tests 2 passed (2)
14
+ @cloudcommerce/api:test:  Time 2.15s (in thread 804ms, 267.51%)
15
+ @cloudcommerce/api:test: 
package/lib/index.d.ts ADDED
@@ -0,0 +1,134 @@
1
+ import type { Endpoint, Config, ResponseBody } from './types';
2
+ declare const def: {
3
+ middleware(config: Config): string;
4
+ };
5
+ declare const setMiddleware: (middleware: (config: Config) => string) => void;
6
+ declare const api: {
7
+ <T extends Config>(config: T): Promise<Response & {
8
+ config: Config;
9
+ data: ResponseBody<T>;
10
+ }>;
11
+ get: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, config?: C | undefined) => Promise<Response & {
12
+ config: Config;
13
+ data: {
14
+ endpoint: E;
15
+ } extends infer T_1 ? T_1 extends {
16
+ endpoint: E;
17
+ } ? T_1 extends Config & {
18
+ method?: "get" | undefined;
19
+ endpoint: `products/${string}`;
20
+ } ? import("./types").Products : T_1 extends Config & {
21
+ method?: "get" | undefined;
22
+ endpoint: `categories/${string}`;
23
+ } ? import("./types").Categories : T_1 extends Config & {
24
+ method?: "get" | undefined;
25
+ endpoint: `brands/${string}`;
26
+ } ? import("./types").Brands : T_1 extends Config & {
27
+ method?: "get" | undefined;
28
+ endpoint: `collections/${string}`;
29
+ } ? import("./types").Collections : T_1 extends Config & {
30
+ method?: "get" | undefined;
31
+ endpoint: `grids/${string}`;
32
+ } ? import("./types").Grids : T_1 extends Config & {
33
+ method?: "get" | undefined;
34
+ endpoint: `carts/${string}`;
35
+ } ? import("./types").Carts : T_1 extends Config & {
36
+ method?: "get" | undefined;
37
+ endpoint: `orders/${string}`;
38
+ } ? import("./types").Orders : T_1 extends Config & {
39
+ method?: "get" | undefined;
40
+ endpoint: `customers/${string}`;
41
+ } ? import("./types").Customers : T_1 extends Config & {
42
+ method?: "get" | undefined;
43
+ endpoint: `stores/${string}`;
44
+ } ? import("./types").Stores : T_1 extends Config & {
45
+ method?: "get" | undefined;
46
+ endpoint: `applications/${string}`;
47
+ } ? import("./types").Applications : any : never : never;
48
+ }>;
49
+ post: (endpoint: Endpoint, config?: AbstractedConfig) => Promise<Response & {
50
+ config: Config;
51
+ data: {
52
+ _id: string & {
53
+ length: 24;
54
+ };
55
+ };
56
+ }>;
57
+ put: (endpoint: Endpoint, config?: AbstractedConfig) => Promise<Response & {
58
+ config: Config;
59
+ data: null;
60
+ }>;
61
+ patch: (endpoint: Endpoint, config?: AbstractedConfig) => Promise<Response & {
62
+ config: Config;
63
+ data: null;
64
+ }>;
65
+ del: (endpoint: Endpoint, config?: AbstractedConfig) => Promise<Response & {
66
+ config: Config;
67
+ data: null;
68
+ }>;
69
+ delete: (endpoint: Endpoint, config?: AbstractedConfig) => Promise<Response & {
70
+ config: Config;
71
+ data: null;
72
+ }>;
73
+ };
74
+ declare type AbstractedConfig = Omit<Config, 'endpoint' | 'method'>;
75
+ declare const get: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, config?: C | undefined) => Promise<Response & {
76
+ config: Config;
77
+ data: {
78
+ endpoint: E;
79
+ } extends infer T_1 ? T_1 extends {
80
+ endpoint: E;
81
+ } ? T_1 extends Config & {
82
+ method?: "get" | undefined;
83
+ endpoint: `products/${string}`;
84
+ } ? import("./types").Products : T_1 extends Config & {
85
+ method?: "get" | undefined;
86
+ endpoint: `categories/${string}`;
87
+ } ? import("./types").Categories : T_1 extends Config & {
88
+ method?: "get" | undefined;
89
+ endpoint: `brands/${string}`;
90
+ } ? import("./types").Brands : T_1 extends Config & {
91
+ method?: "get" | undefined;
92
+ endpoint: `collections/${string}`;
93
+ } ? import("./types").Collections : T_1 extends Config & {
94
+ method?: "get" | undefined;
95
+ endpoint: `grids/${string}`;
96
+ } ? import("./types").Grids : T_1 extends Config & {
97
+ method?: "get" | undefined;
98
+ endpoint: `carts/${string}`;
99
+ } ? import("./types").Carts : T_1 extends Config & {
100
+ method?: "get" | undefined;
101
+ endpoint: `orders/${string}`;
102
+ } ? import("./types").Orders : T_1 extends Config & {
103
+ method?: "get" | undefined;
104
+ endpoint: `customers/${string}`;
105
+ } ? import("./types").Customers : T_1 extends Config & {
106
+ method?: "get" | undefined;
107
+ endpoint: `stores/${string}`;
108
+ } ? import("./types").Stores : T_1 extends Config & {
109
+ method?: "get" | undefined;
110
+ endpoint: `applications/${string}`;
111
+ } ? import("./types").Applications : any : never : never;
112
+ }>;
113
+ declare const post: (endpoint: Endpoint, config?: AbstractedConfig) => Promise<Response & {
114
+ config: Config;
115
+ data: {
116
+ _id: string & {
117
+ length: 24;
118
+ };
119
+ };
120
+ }>;
121
+ declare const put: (endpoint: Endpoint, config?: AbstractedConfig) => Promise<Response & {
122
+ config: Config;
123
+ data: null;
124
+ }>;
125
+ declare const patch: (endpoint: Endpoint, config?: AbstractedConfig) => Promise<Response & {
126
+ config: Config;
127
+ data: null;
128
+ }>;
129
+ declare const del: (endpoint: Endpoint, config?: AbstractedConfig) => Promise<Response & {
130
+ config: Config;
131
+ data: null;
132
+ }>;
133
+ export default api;
134
+ export { setMiddleware, get, post, put, patch, del, };
package/lib/index.js ADDED
@@ -0,0 +1,89 @@
1
+ // @ts-ignore
2
+ const env = (typeof window === 'object' && window)
3
+ || (typeof process === 'object' && process && process.env)
4
+ || {};
5
+ const def = {
6
+ middleware(config) {
7
+ let url = config.baseUrl || env.API_BASE_URL || 'https://ecomplus.io/v2';
8
+ const storeId = config.storeId || env.ECOM_STORE_ID;
9
+ if (!storeId) {
10
+ throw new Error('`storeId` must be set in config or `ECOM_STORE_ID` env var');
11
+ }
12
+ url += `/:${storeId}`;
13
+ const lang = config.lang || env.ECOM_LANG;
14
+ if (lang) {
15
+ url += `,lang:${lang}`;
16
+ }
17
+ if (config.params) {
18
+ if (typeof config.params === 'string') {
19
+ url += `?${config.params}`;
20
+ } else {
21
+ // https://github.com/microsoft/TypeScript/issues/32951
22
+ url += `?${new URLSearchParams(config.params)}`;
23
+ }
24
+ }
25
+ return `${url}/${config.endpoint}`;
26
+ },
27
+ };
28
+ // eslint-disable-next-line no-unused-vars
29
+ const setMiddleware = (middleware) => {
30
+ def.middleware = middleware;
31
+ };
32
+ const api = async (config) => {
33
+ const url = def.middleware(config);
34
+ const { method, headers, timeout = 20000 } = config;
35
+ const abortController = new AbortController();
36
+ const timer = setTimeout(() => abortController.abort(), timeout);
37
+ const response = await fetch(url, {
38
+ method,
39
+ headers,
40
+ signal: abortController.signal,
41
+ });
42
+ clearTimeout(timer);
43
+ if (response.ok) {
44
+ return {
45
+ ...response,
46
+ config,
47
+ data: await response.json(),
48
+ };
49
+ }
50
+ const error = new Error(response.statusText);
51
+ error.config = config;
52
+ error.response = response;
53
+ error.statusCode = response.status;
54
+ throw error;
55
+ };
56
+ const get = (endpoint, config) => api({ ...config, endpoint });
57
+ const post = (endpoint, config) => api({
58
+ ...config,
59
+ method: 'post',
60
+ endpoint,
61
+ });
62
+ const put = (endpoint, config) => api({
63
+ ...config,
64
+ method: 'put',
65
+ endpoint,
66
+ });
67
+ const patch = (endpoint, config) => api({
68
+ ...config,
69
+ method: 'patch',
70
+ endpoint,
71
+ });
72
+ const del = (endpoint, config) => api({
73
+ ...config,
74
+ method: 'delete',
75
+ endpoint,
76
+ });
77
+ api.get = get;
78
+ api.post = post;
79
+ api.put = put;
80
+ api.patch = patch;
81
+ api.del = del;
82
+ api.delete = del;
83
+
84
+ export default api;
85
+
86
+ export {
87
+ setMiddleware, get, post, put, patch, del,
88
+ };
89
+ // # sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,aAAa;AACb,MAAM,GAAG,GAA8B,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC;OACxE,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC;OACvD,EAAE,CAAC;AAER,MAAM,GAAG,GAAG;IACV,UAAU,CAAC,MAAc;QACvB,IAAI,GAAG,GAAG,MAAM,CAAC,OAAO,IAAI,GAAG,CAAC,YAAY,IAAI,wBAAwB,CAAC;QACzE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,GAAG,CAAC,aAAa,CAAC;QACpD,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;SAC/E;QACD,GAAG,IAAI,KAAK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AClB,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,GACJ,CAAC"}
@@ -0,0 +1,208 @@
1
+ /* tslint:disable */
2
+ /**
3
+ * This file was automatically generated by json-schema-to-typescript.
4
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
+ * and run json-schema-to-typescript to regenerate this file.
6
+ */
7
+
8
+ export interface Applications {
9
+ _id: string;
10
+ created_at: string;
11
+ updated_at: string;
12
+ store_id: number;
13
+ /**
14
+ * ID of application on marketplace
15
+ */
16
+ app_id: number;
17
+ /**
18
+ * The working state of this app in the shop
19
+ */
20
+ state?: 'inactive' | 'active' | 'test';
21
+ /**
22
+ * App title
23
+ */
24
+ title: string;
25
+ /**
26
+ * App unique slug on marketplace, only lowercase letters, numbers and hyphen
27
+ */
28
+ slug?: string;
29
+ /**
30
+ * Whether this app is paid
31
+ */
32
+ paid?: boolean;
33
+ /**
34
+ * Installed application version, semver e.g. 1.0.0
35
+ */
36
+ version: string;
37
+ /**
38
+ * When app installation was updated, date and time in ISO 8601 standard representation
39
+ */
40
+ version_date?: string;
41
+ /**
42
+ * Type of app
43
+ */
44
+ type: 'dashboard' | 'storefront' | 'external';
45
+ /**
46
+ * Modules handled by this app
47
+ */
48
+ modules?: {
49
+ /**
50
+ * Triggered after each term searched on storefront
51
+ */
52
+ term_searched?: {
53
+ /**
54
+ * Whether current app is enabled to handle the module requests
55
+ */
56
+ enabled: boolean;
57
+ /**
58
+ * URL to receive POST request of respective module
59
+ */
60
+ endpoint: string;
61
+ };
62
+ /**
63
+ * Triggered after each cart saves on storefront, just before checkout
64
+ */
65
+ cart_confirmed?: {
66
+ /**
67
+ * Whether current app is enabled to handle the module requests
68
+ */
69
+ enabled: boolean;
70
+ /**
71
+ * URL to receive POST request of respective module
72
+ */
73
+ endpoint: string;
74
+ };
75
+ /**
76
+ * Triggered to calculate shipping options, must return calculated values and times
77
+ */
78
+ calculate_shipping?: {
79
+ /**
80
+ * Whether current app is enabled to handle the module requests
81
+ */
82
+ enabled: boolean;
83
+ /**
84
+ * URL to receive POST request of respective module
85
+ */
86
+ endpoint: string;
87
+ };
88
+ /**
89
+ * Triggered when listing payments, must return available methods
90
+ */
91
+ list_payments?: {
92
+ /**
93
+ * Whether current app is enabled to handle the module requests
94
+ */
95
+ enabled: boolean;
96
+ /**
97
+ * URL to receive POST request of respective module
98
+ */
99
+ endpoint: string;
100
+ };
101
+ /**
102
+ * Triggered to validate and apply discout value, must return discount and conditions
103
+ */
104
+ apply_discount?: {
105
+ /**
106
+ * Whether current app is enabled to handle the module requests
107
+ */
108
+ enabled: boolean;
109
+ /**
110
+ * URL to receive POST request of respective module
111
+ */
112
+ endpoint: string;
113
+ };
114
+ /**
115
+ * Triggered when order is being closed, must create payment transaction and return info
116
+ */
117
+ create_transaction?: {
118
+ /**
119
+ * Whether current app is enabled to handle the module requests
120
+ */
121
+ enabled: boolean;
122
+ /**
123
+ * URL to receive POST request of respective module
124
+ */
125
+ endpoint: string;
126
+ };
127
+ /**
128
+ * Triggered after each order created from storefront, could return custom fields
129
+ */
130
+ checkout_done?: {
131
+ /**
132
+ * Whether current app is enabled to handle the module requests
133
+ */
134
+ enabled: boolean;
135
+ /**
136
+ * URL to receive POST request of respective module
137
+ */
138
+ endpoint: string;
139
+ };
140
+ };
141
+ /**
142
+ * Configuration options for staff on admin dashboard, saved on app data
143
+ */
144
+ admin_settings?: {
145
+ /**
146
+ * Configuration field object, property name same as saved on data object
147
+ *
148
+ * This interface was referenced by `undefined`'s JSON-Schema definition
149
+ * via the `patternProperty` "^[a-z0-9_]{2,30}$".
150
+ */
151
+ [k: string]: {
152
+ /**
153
+ * JSON Schema (https://json-schema.org/specification.html) for field model
154
+ */
155
+ schema: {
156
+ [k: string]: unknown;
157
+ };
158
+ /**
159
+ * Whether the field value is private, saved in `hidden_data`
160
+ */
161
+ hide?: boolean;
162
+ };
163
+ };
164
+ /**
165
+ * Link to client side script (JS) to load on storefront
166
+ */
167
+ storefront_script_uri?: string;
168
+ /**
169
+ * Endpoint that receives POST back with authentication credentials, must be HTTPS
170
+ */
171
+ auth_callback_uri?: string;
172
+ /**
173
+ * If this app uses authentication, list the needed permissions
174
+ */
175
+ auth_scope?: {
176
+ /**
177
+ * Special scope to read authentications
178
+ */
179
+ authentications?: 'GET'[];
180
+ /**
181
+ * Requested resource, cannot be 'applications', 'authentications' or '$update' here
182
+ *
183
+ * This interface was referenced by `undefined`'s JSON-Schema definition
184
+ * via the `patternProperty` "^([$]?(?!app|aut|upd)([a-z][a-z0-9/_]{1,60}[^/]))$".
185
+ */
186
+ [k: string]: ('all' | 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE')[];
187
+ };
188
+ /**
189
+ * Application object data, schema free
190
+ */
191
+ data?: {
192
+ [k: string]: unknown;
193
+ };
194
+ /**
195
+ * Application private data, available only with authentication
196
+ */
197
+ hidden_data?: {
198
+ [k: string]: unknown;
199
+ };
200
+ /**
201
+ * Flags to associate additional info
202
+ */
203
+ flags?: string[];
204
+ /**
205
+ * Optional notes with additional info about this user
206
+ */
207
+ notes?: string;
208
+ }
@@ -0,0 +1,97 @@
1
+ /* tslint:disable */
2
+ /**
3
+ * This file was automatically generated by json-schema-to-typescript.
4
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
+ * and run json-schema-to-typescript to regenerate this file.
6
+ */
7
+
8
+ export interface Authentications {
9
+ _id: string;
10
+ created_at: string;
11
+ updated_at: string;
12
+ store_ids: number[];
13
+ /**
14
+ * Simple username for identification, only numbers and lowercase letters
15
+ */
16
+ username: string;
17
+ /**
18
+ * User language two letter code, sometimes with region, eg.: pt_br, fr, en_us
19
+ */
20
+ locale?: string;
21
+ /**
22
+ * User email address
23
+ */
24
+ email?: string;
25
+ /**
26
+ * User full name
27
+ */
28
+ name?: string;
29
+ /**
30
+ * User phone number
31
+ */
32
+ phone?: string;
33
+ /**
34
+ * MD5 hash generated with the user's password
35
+ */
36
+ pass_md5_hash?: string;
37
+ /**
38
+ * API key as a random 128 bytes hexadecimal number
39
+ */
40
+ api_key?: string;
41
+ /**
42
+ * Collection of resources allowed to user, each resource uri as object property
43
+ */
44
+ permissions?: {
45
+ /**
46
+ * Resource/Subresources/Third-level/ID
47
+ *
48
+ * This interface was referenced by `undefined`'s JSON-Schema definition
49
+ * via the `patternProperty` "^(([^/_][a-z0-9/_@:$+]{1,60}[^/])|[*])$".
50
+ */
51
+ [k: string]: ('all' | 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE')[];
52
+ };
53
+ /**
54
+ * List of dashboard cards chosen by user
55
+ */
56
+ panel_cards?: {
57
+ /**
58
+ * Unique identifier, card name using only lowercase, numbers and underscore
59
+ */
60
+ card_id: string;
61
+ /**
62
+ * Card title
63
+ */
64
+ title?: string;
65
+ /**
66
+ * Card text, usually a brief description
67
+ */
68
+ paragraph?: string;
69
+ /**
70
+ * Custom card calling MongoDB aggregate
71
+ */
72
+ custom_aggregation?: {
73
+ /**
74
+ * API resource
75
+ */
76
+ resource: 'products' | 'categories' | 'brands' | 'collections' | 'grids' | 'customers' | 'carts' | 'orders';
77
+ /**
78
+ * Aggregation pipeline
79
+ */
80
+ pipeline: {
81
+ [k: string]: unknown;
82
+ }[];
83
+ };
84
+ }[];
85
+ /**
86
+ * Whether the user is able to use builder and file manager to edit storefront
87
+ */
88
+ edit_storefront?: boolean;
89
+ /**
90
+ * Flags to associate additional info
91
+ */
92
+ flags?: string[];
93
+ /**
94
+ * Optional notes with additional info about this user
95
+ */
96
+ notes?: string;
97
+ }