cloudcommerce 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.
- package/{.eslintrc.js → .eslintrc.cjs} +4 -4
- package/.github/renovate.json +2 -1
- package/CHANGELOG.md +34 -0
- package/README.md +2 -2
- package/package.json +11 -7
- package/packages/api/lib/index.d.ts +134 -0
- package/packages/api/lib/index.js +89 -0
- package/packages/api/lib/index.js.map +1 -0
- package/packages/api/lib/types/applications.d.ts +208 -0
- package/packages/api/lib/types/authentications.d.ts +97 -0
- package/packages/api/lib/types/brands.d.ts +148 -0
- package/packages/api/lib/types/carts.d.ts +292 -0
- package/packages/api/lib/types/categories.d.ts +190 -0
- package/packages/api/lib/types/collections.d.ts +151 -0
- package/packages/api/lib/types/customers.d.ts +495 -0
- package/packages/api/lib/types/grids.d.ts +149 -0
- package/packages/api/lib/types/orders.d.ts +1588 -0
- package/packages/api/lib/types/products.d.ts +1284 -0
- package/packages/api/lib/types/stores.d.ts +120 -0
- package/packages/api/lib/types.d.ts +39 -0
- package/packages/api/lib/types.js +2 -0
- package/packages/api/lib/types.js.map +1 -0
- package/packages/api/package.json +5 -3
- package/packages/api/scripts/build.sh +6 -0
- package/packages/api/src/index.ts +66 -72
- package/packages/api/src/types/applications.d.ts +208 -0
- package/packages/api/src/types/authentications.d.ts +97 -0
- package/packages/api/src/types/brands.d.ts +148 -0
- package/packages/api/src/types/carts.d.ts +292 -0
- package/packages/api/src/types/categories.d.ts +190 -0
- package/packages/api/src/types/collections.d.ts +151 -0
- package/packages/api/src/types/customers.d.ts +495 -0
- package/packages/api/src/types/grids.d.ts +149 -0
- package/packages/api/src/types/orders.d.ts +1588 -0
- package/packages/api/src/types/products.d.ts +1284 -0
- package/packages/api/src/types/stores.d.ts +120 -0
- package/packages/api/src/types.ts +76 -0
- package/packages/api/tests/fetch-polyfill.js +21 -0
- package/packages/api/tests/index.test.ts +30 -0
- package/packages/api/tsconfig.json +2 -97
- package/packages/apps/discounts/package.json +1 -1
- package/packages/storefront/package.json +3 -2
- package/tsconfig.json +107 -0
- package/tsconfig.test.json +11 -0
- package/turbo.json +9 -1
- package/vite.config.ts +12 -0
- package/packages/api/dist/index.js +0 -73
- package/packages/api/dist/index.js.map +0 -1
|
@@ -0,0 +1,120 @@
|
|
|
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 Stores {
|
|
9
|
+
_id: string;
|
|
10
|
+
created_at: string;
|
|
11
|
+
updated_at: string;
|
|
12
|
+
store_id: number;
|
|
13
|
+
/**
|
|
14
|
+
* Store name
|
|
15
|
+
*/
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* Simple description of store
|
|
19
|
+
*/
|
|
20
|
+
description?: string;
|
|
21
|
+
/**
|
|
22
|
+
* ID of store main segment, get options and IDs at /segments.json
|
|
23
|
+
*/
|
|
24
|
+
segment_id: number;
|
|
25
|
+
/**
|
|
26
|
+
* Responsible person or organization document type
|
|
27
|
+
*/
|
|
28
|
+
doc_type: 'CPF' | 'CNPJ';
|
|
29
|
+
/**
|
|
30
|
+
* Responsible person or organization document number (only numbers)
|
|
31
|
+
*/
|
|
32
|
+
doc_number: string;
|
|
33
|
+
/**
|
|
34
|
+
* Municipal or state registration if exists
|
|
35
|
+
*/
|
|
36
|
+
inscription_type?: 'State' | 'Municipal';
|
|
37
|
+
/**
|
|
38
|
+
* Municipal or state registration number (with characters) if exists
|
|
39
|
+
*/
|
|
40
|
+
inscription_number?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Registered company name or responsible fullname
|
|
43
|
+
*/
|
|
44
|
+
corporate_name: string;
|
|
45
|
+
/**
|
|
46
|
+
* Full registered address of company
|
|
47
|
+
*/
|
|
48
|
+
address?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Financial contact phone
|
|
51
|
+
*/
|
|
52
|
+
phone?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Name of company representative for commercial contact
|
|
55
|
+
*/
|
|
56
|
+
representant_name?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Email address of company representative
|
|
59
|
+
*/
|
|
60
|
+
representant_email?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Public email address for news and general contact
|
|
63
|
+
*/
|
|
64
|
+
contact_email?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Email address to receive notifications, invoices and vouchers
|
|
67
|
+
*/
|
|
68
|
+
financial_email: string;
|
|
69
|
+
/**
|
|
70
|
+
* Image link to shop's logo
|
|
71
|
+
*/
|
|
72
|
+
logo?: {
|
|
73
|
+
/**
|
|
74
|
+
* Image link
|
|
75
|
+
*/
|
|
76
|
+
url: string;
|
|
77
|
+
/**
|
|
78
|
+
* Image size (width x height) in px, such as 100x50 (100px width, 50px height)
|
|
79
|
+
*/
|
|
80
|
+
size?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Alternative text, HTML alt tag (important for SEO)
|
|
83
|
+
*/
|
|
84
|
+
alt?: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Preferred sales channel domain name, with subdomain if any
|
|
88
|
+
*/
|
|
89
|
+
domain?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Preferred shop homepage link (full URI)
|
|
92
|
+
*/
|
|
93
|
+
homepage?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Main colors to compose shop's visual identity
|
|
96
|
+
*/
|
|
97
|
+
brand_colors?: {
|
|
98
|
+
/**
|
|
99
|
+
* Primary color RGB code with #
|
|
100
|
+
*/
|
|
101
|
+
primary?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Secondary color RGB code with #
|
|
104
|
+
*/
|
|
105
|
+
secondary?: string;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Public contact phone
|
|
109
|
+
*/
|
|
110
|
+
contact_phone?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Secondary public contact phone, commonly a cell phone number
|
|
113
|
+
*/
|
|
114
|
+
contact_cellphone?: string;
|
|
115
|
+
sales_channels?: {
|
|
116
|
+
channel_id: string;
|
|
117
|
+
type?: 'ecommerce' | 'mobile' | 'pos' | 'button' | 'social' | 'chatbot' | 'live';
|
|
118
|
+
title?: string;
|
|
119
|
+
}[];
|
|
120
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Products } from './types/products';
|
|
2
|
+
import type { Categories } from './types/categories';
|
|
3
|
+
import type { Brands } from './types/brands';
|
|
4
|
+
import type { Collections } from './types/collections';
|
|
5
|
+
import type { Grids } from './types/grids';
|
|
6
|
+
import type { Carts } from './types/carts';
|
|
7
|
+
import type { Orders } from './types/orders';
|
|
8
|
+
import type { Customers } from './types/customers';
|
|
9
|
+
import type { Stores } from './types/stores';
|
|
10
|
+
import type { Applications } from './types/applications';
|
|
11
|
+
declare type Resource = 'products' | 'categories' | 'brands' | 'collections' | 'grids' | 'carts' | 'orders' | 'customers' | 'stores' | 'applications';
|
|
12
|
+
declare type ResourceId = string & {
|
|
13
|
+
length: 24;
|
|
14
|
+
};
|
|
15
|
+
declare type ResourceAndId = `${Resource}/${ResourceId}`;
|
|
16
|
+
declare type Endpoint = Resource | ResourceAndId | `${ResourceAndId}/${string}`;
|
|
17
|
+
declare type Method = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
18
|
+
declare type Config = {
|
|
19
|
+
baseUrl?: string;
|
|
20
|
+
storeId?: number;
|
|
21
|
+
lang?: string;
|
|
22
|
+
method?: Method;
|
|
23
|
+
endpoint: Endpoint;
|
|
24
|
+
params?: Record<string, string | number>;
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
timeout?: number;
|
|
27
|
+
};
|
|
28
|
+
declare type ReadConfig<endpoint> = Config & {
|
|
29
|
+
method?: 'get';
|
|
30
|
+
endpoint: endpoint;
|
|
31
|
+
};
|
|
32
|
+
declare type ResponseBody<T> = T extends Config & {
|
|
33
|
+
method: 'post';
|
|
34
|
+
} ? {
|
|
35
|
+
_id: ResourceId;
|
|
36
|
+
} : T extends Config & {
|
|
37
|
+
method: 'put' | 'patch' | 'delete';
|
|
38
|
+
} ? null : T extends ReadConfig<`products/${ResourceId}`> ? Products : T extends ReadConfig<`categories/${ResourceId}`> ? Categories : T extends ReadConfig<`brands/${ResourceId}`> ? Brands : T extends ReadConfig<`collections/${ResourceId}`> ? Collections : T extends ReadConfig<`grids/${ResourceId}`> ? Grids : T extends ReadConfig<`carts/${ResourceId}`> ? Carts : T extends ReadConfig<`orders/${ResourceId}`> ? Orders : T extends ReadConfig<`customers/${ResourceId}`> ? Customers : T extends ReadConfig<`stores/${ResourceId}`> ? Stores : T extends ReadConfig<`applications/${ResourceId}`> ? Applications : any;
|
|
39
|
+
export type { Products, Categories, Brands, Collections, Grids, Carts, Orders, Customers, Stores, Applications, Resource, ResourceAndId, Endpoint, Method, Config, ResponseBody, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "E-Com Plus Cloud Commerce APIs client/adapter",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "git+https://github.com/ecomplus/cloud-commerce.git",
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
},
|
|
16
17
|
"homepage": "https://github.com/ecomplus/cloud-commerce/tree/main/packages/api#readme",
|
|
17
18
|
"scripts": {
|
|
18
|
-
"build": "
|
|
19
|
+
"build": "sh scripts/build.sh",
|
|
20
|
+
"test": "tsc -p ../../tsconfig.test.json && vitest run"
|
|
19
21
|
}
|
|
20
22
|
}
|
|
@@ -1,27 +1,4 @@
|
|
|
1
|
-
type
|
|
2
|
-
| 'categories'
|
|
3
|
-
| 'brands'
|
|
4
|
-
| 'collections'
|
|
5
|
-
| 'grids'
|
|
6
|
-
| 'carts'
|
|
7
|
-
| 'orders'
|
|
8
|
-
| 'customers'
|
|
9
|
-
| 'stores'
|
|
10
|
-
| 'applications';
|
|
11
|
-
|
|
12
|
-
type Endpoint = Resource | `${Resource}/${string}`;
|
|
13
|
-
|
|
14
|
-
type Method = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
15
|
-
|
|
16
|
-
type ReqOptions = {
|
|
17
|
-
baseUrl?: string,
|
|
18
|
-
storeId?: number,
|
|
19
|
-
lang?: string,
|
|
20
|
-
method: Method,
|
|
21
|
-
endpoint: Endpoint,
|
|
22
|
-
params?: Record<string, string | number>,
|
|
23
|
-
headers?: Record<string, string>,
|
|
24
|
-
};
|
|
1
|
+
import type { Endpoint, Config, ResponseBody } from './types';
|
|
25
2
|
|
|
26
3
|
// @ts-ignore
|
|
27
4
|
const env: { [key: string]: string } = (typeof window === 'object' && window)
|
|
@@ -29,28 +6,26 @@ const env: { [key: string]: string } = (typeof window === 'object' && window)
|
|
|
29
6
|
|| {};
|
|
30
7
|
|
|
31
8
|
const def = {
|
|
32
|
-
middleware(
|
|
33
|
-
let url =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
throw new Error('`storeId` must be set in options or `ECOM_STORE_ID` env var');
|
|
38
|
-
}
|
|
39
|
-
url += `/:${storeId}`;
|
|
40
|
-
const lang = options.lang || env.ECOM_LANG;
|
|
41
|
-
if (lang) {
|
|
42
|
-
url += `,lang:${lang}`;
|
|
43
|
-
}
|
|
9
|
+
middleware(config: Config) {
|
|
10
|
+
let url = config.baseUrl || env.API_BASE_URL || 'https://ecomplus.io/v2';
|
|
11
|
+
const storeId = config.storeId || env.ECOM_STORE_ID;
|
|
12
|
+
if (!storeId) {
|
|
13
|
+
throw new Error('`storeId` must be set in config or `ECOM_STORE_ID` env var');
|
|
44
14
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
15
|
+
url += `/:${storeId}`;
|
|
16
|
+
const lang = config.lang || env.ECOM_LANG;
|
|
17
|
+
if (lang) {
|
|
18
|
+
url += `,lang:${lang}`;
|
|
19
|
+
}
|
|
20
|
+
if (config.params) {
|
|
21
|
+
if (typeof config.params === 'string') {
|
|
22
|
+
url += `?${config.params}`;
|
|
48
23
|
} else {
|
|
49
24
|
// https://github.com/microsoft/TypeScript/issues/32951
|
|
50
|
-
url += `?${new URLSearchParams(
|
|
25
|
+
url += `?${new URLSearchParams(config.params as Record<string, string>)}`;
|
|
51
26
|
}
|
|
52
27
|
}
|
|
53
|
-
return `${url}/${
|
|
28
|
+
return `${url}/${config.endpoint}`;
|
|
54
29
|
},
|
|
55
30
|
};
|
|
56
31
|
|
|
@@ -59,50 +34,76 @@ const setMiddleware = (middleware: typeof def.middleware) => {
|
|
|
59
34
|
def.middleware = middleware;
|
|
60
35
|
};
|
|
61
36
|
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
37
|
+
const api = async <T extends Config>(config: T): Promise<Response & {
|
|
38
|
+
config: Config,
|
|
39
|
+
data: ResponseBody<T>,
|
|
40
|
+
}> => {
|
|
41
|
+
const url = def.middleware(config);
|
|
42
|
+
const { method, headers, timeout = 20000 } = config;
|
|
43
|
+
const abortController = new AbortController();
|
|
44
|
+
const timer = setTimeout(() => abortController.abort(), timeout);
|
|
45
|
+
const response = await fetch(url, {
|
|
46
|
+
method,
|
|
47
|
+
headers,
|
|
48
|
+
signal: abortController.signal,
|
|
49
|
+
});
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
if (response.ok) {
|
|
52
|
+
return {
|
|
53
|
+
...response,
|
|
54
|
+
config,
|
|
55
|
+
data: await response.json(),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const error: any = new Error(response.statusText);
|
|
59
|
+
error.config = config;
|
|
60
|
+
error.response = response;
|
|
61
|
+
error.statusCode = response.status;
|
|
62
|
+
throw error;
|
|
66
63
|
};
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
...options,
|
|
70
|
-
method: 'get',
|
|
71
|
-
endpoint,
|
|
72
|
-
});
|
|
65
|
+
type AbstractedConfig = Omit<Config, 'endpoint' | 'method'>;
|
|
73
66
|
|
|
74
|
-
const
|
|
75
|
-
|
|
67
|
+
const get = <E extends Endpoint, C extends AbstractedConfig>(
|
|
68
|
+
endpoint: E,
|
|
69
|
+
config?: C,
|
|
70
|
+
): Promise<Response & {
|
|
71
|
+
config: Config,
|
|
72
|
+
data: ResponseBody<{ endpoint: E }>,
|
|
73
|
+
}> => api({ ...config, endpoint });
|
|
74
|
+
|
|
75
|
+
const post = (endpoint: Endpoint, config?: AbstractedConfig) => api({
|
|
76
|
+
...config,
|
|
76
77
|
method: 'post',
|
|
77
78
|
endpoint,
|
|
78
79
|
});
|
|
79
80
|
|
|
80
|
-
const put = (endpoint: Endpoint,
|
|
81
|
-
...
|
|
81
|
+
const put = (endpoint: Endpoint, config?: AbstractedConfig) => api({
|
|
82
|
+
...config,
|
|
82
83
|
method: 'put',
|
|
83
84
|
endpoint,
|
|
84
85
|
});
|
|
85
86
|
|
|
86
|
-
const patch = (endpoint: Endpoint,
|
|
87
|
-
...
|
|
87
|
+
const patch = (endpoint: Endpoint, config?: AbstractedConfig) => api({
|
|
88
|
+
...config,
|
|
88
89
|
method: 'patch',
|
|
89
90
|
endpoint,
|
|
90
91
|
});
|
|
91
92
|
|
|
92
|
-
const del = (endpoint: Endpoint,
|
|
93
|
-
...
|
|
93
|
+
const del = (endpoint: Endpoint, config?: AbstractedConfig) => api({
|
|
94
|
+
...config,
|
|
94
95
|
method: 'delete',
|
|
95
96
|
endpoint,
|
|
96
97
|
});
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
api.get = get;
|
|
100
|
+
api.post = post;
|
|
101
|
+
api.put = put;
|
|
102
|
+
api.patch = patch;
|
|
103
|
+
api.del = del;
|
|
104
|
+
api.delete = del;
|
|
104
105
|
|
|
105
|
-
export default
|
|
106
|
+
export default api;
|
|
106
107
|
|
|
107
108
|
export {
|
|
108
109
|
setMiddleware,
|
|
@@ -112,10 +113,3 @@ export {
|
|
|
112
113
|
patch,
|
|
113
114
|
del,
|
|
114
115
|
};
|
|
115
|
-
|
|
116
|
-
export type {
|
|
117
|
-
Resource,
|
|
118
|
-
Endpoint,
|
|
119
|
-
Method,
|
|
120
|
-
ReqOptions,
|
|
121
|
-
};
|
|
@@ -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
|
+
}
|