cloudcommerce 0.0.2 → 0.0.3
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 +13 -0
- package/README.md +2 -2
- package/package.json +7 -6
- package/packages/api/dist/index.d.ts +65 -0
- package/packages/api/dist/index.js +42 -24
- package/packages/api/dist/index.js.map +1 -1
- package/packages/api/dist/types/applications.d.ts +208 -0
- package/packages/api/dist/types/authentications.d.ts +97 -0
- package/packages/api/dist/types/brands.d.ts +148 -0
- package/packages/api/dist/types/carts.d.ts +292 -0
- package/packages/api/dist/types/categories.d.ts +190 -0
- package/packages/api/dist/types/collections.d.ts +151 -0
- package/packages/api/dist/types/customers.d.ts +495 -0
- package/packages/api/dist/types/grids.d.ts +149 -0
- package/packages/api/dist/types/orders.d.ts +1588 -0
- package/packages/api/dist/types/procedures.d.ts +139 -0
- package/packages/api/dist/types/products.d.ts +1284 -0
- package/packages/api/dist/types/stores.d.ts +120 -0
- package/packages/api/dist/types/triggers.d.ts +79 -0
- package/packages/api/dist/types.d.ts +65 -0
- package/packages/api/dist/types.js +2 -0
- package/packages/api/dist/types.js.map +1 -0
- package/packages/api/package.json +4 -2
- package/packages/api/scripts/build.mjs +5 -0
- package/packages/api/src/index.ts +46 -55
- 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/procedures.d.ts +139 -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/triggers.d.ts +79 -0
- package/packages/api/src/types.ts +74 -0
- package/packages/api/tests/types.test.ts +13 -0
- package/packages/apps/discounts/package.json +1 -1
- package/packages/storefront/package.json +1 -1
- package/{packages/api/tsconfig.json → tsconfig.json} +8 -3
- package/turbo.json +3 -0
|
@@ -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,79 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* Trigger object model
|
|
10
|
+
*/
|
|
11
|
+
export interface Triggers {
|
|
12
|
+
_id: string;
|
|
13
|
+
created_at: string;
|
|
14
|
+
updated_at: string;
|
|
15
|
+
store_id: number;
|
|
16
|
+
/**
|
|
17
|
+
* When event occurred, date and time in ISO 8601 standard representation
|
|
18
|
+
*/
|
|
19
|
+
datetime: string;
|
|
20
|
+
/**
|
|
21
|
+
* ID of used authentication, should be a valid hexadecimal
|
|
22
|
+
*/
|
|
23
|
+
authentication_id?: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Method (HTTP verb) of the event
|
|
26
|
+
*/
|
|
27
|
+
method: 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
|
28
|
+
/**
|
|
29
|
+
* Type of action taken
|
|
30
|
+
*/
|
|
31
|
+
action: 'create' | 'change' | 'delete';
|
|
32
|
+
/**
|
|
33
|
+
* API resource
|
|
34
|
+
*/
|
|
35
|
+
resource:
|
|
36
|
+
| 'authentications'
|
|
37
|
+
| 'products'
|
|
38
|
+
| 'categories'
|
|
39
|
+
| 'brands'
|
|
40
|
+
| 'collections'
|
|
41
|
+
| 'grids'
|
|
42
|
+
| 'customers'
|
|
43
|
+
| 'carts'
|
|
44
|
+
| 'orders'
|
|
45
|
+
| 'applications'
|
|
46
|
+
| 'stores';
|
|
47
|
+
/**
|
|
48
|
+
* Resource ID, if specified
|
|
49
|
+
*/
|
|
50
|
+
resource_id?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Subresource slug (which appears in the URL), if specified
|
|
53
|
+
*/
|
|
54
|
+
subresource?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Subresource ID, if specified
|
|
57
|
+
*/
|
|
58
|
+
subresource_id?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Document fields involved (created or updated) with the event
|
|
61
|
+
*/
|
|
62
|
+
fields?: string[];
|
|
63
|
+
/**
|
|
64
|
+
* Unique ID of created object, only for POST method
|
|
65
|
+
*/
|
|
66
|
+
inserted_id?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Request body, limitations: https://docs.mongodb.com/manual/reference/limits/#bson-documents
|
|
69
|
+
*/
|
|
70
|
+
body?: {
|
|
71
|
+
[k: string]: unknown;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Response received, limits: https://docs.mongodb.com/manual/reference/limits/#bson-documents
|
|
75
|
+
*/
|
|
76
|
+
response?: {
|
|
77
|
+
[k: string]: unknown;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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 ResponseBody<T> = T extends Config & {
|
|
29
|
+
method: 'post';
|
|
30
|
+
} ? {
|
|
31
|
+
_id: ResourceId;
|
|
32
|
+
} : T extends Config & {
|
|
33
|
+
method: 'put' | 'patch' | 'delete';
|
|
34
|
+
} ? null : T extends Config & {
|
|
35
|
+
method: 'get';
|
|
36
|
+
endpoint: `products/${ResourceId}`;
|
|
37
|
+
} ? Products : T extends Config & {
|
|
38
|
+
method: 'get';
|
|
39
|
+
endpoint: `categories/${ResourceId}`;
|
|
40
|
+
} ? Categories : T extends Config & {
|
|
41
|
+
method: 'get';
|
|
42
|
+
endpoint: `brands/${ResourceId}`;
|
|
43
|
+
} ? Brands : T extends Config & {
|
|
44
|
+
method: 'get';
|
|
45
|
+
endpoint: `collections/${ResourceId}`;
|
|
46
|
+
} ? Collections : T extends Config & {
|
|
47
|
+
method: 'get';
|
|
48
|
+
endpoint: `grids/${ResourceId}`;
|
|
49
|
+
} ? Grids : T extends Config & {
|
|
50
|
+
method: 'get';
|
|
51
|
+
endpoint: `carts/${ResourceId}`;
|
|
52
|
+
} ? Carts : T extends Config & {
|
|
53
|
+
method: 'get';
|
|
54
|
+
endpoint: `orders/${ResourceId}`;
|
|
55
|
+
} ? Orders : T extends Config & {
|
|
56
|
+
method: 'get';
|
|
57
|
+
endpoint: `customers/${ResourceId}`;
|
|
58
|
+
} ? Customers : T extends Config & {
|
|
59
|
+
method: 'get';
|
|
60
|
+
endpoint: `stores/${ResourceId}`;
|
|
61
|
+
} ? Stores : T extends Config & {
|
|
62
|
+
method: 'get';
|
|
63
|
+
endpoint: `applications/${ResourceId}`;
|
|
64
|
+
} ? Applications : any;
|
|
65
|
+
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.3",
|
|
4
4
|
"description": "E-Com Plus Cloud Commerce APIs client/adapter",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/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": "zx scripts/build.mjs",
|
|
20
|
+
"test": "tsc --noEmit --noImplicitAny"
|
|
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,28 @@ const env: { [key: string]: string } = (typeof window === 'object' && window)
|
|
|
29
6
|
|| {};
|
|
30
7
|
|
|
31
8
|
const def = {
|
|
32
|
-
middleware(
|
|
33
|
-
let url =
|
|
9
|
+
middleware(config: Config) {
|
|
10
|
+
let url = config.baseUrl || env.API_BASE_URL || 'https://ecomplus.io/v2';
|
|
34
11
|
if (!url) {
|
|
35
|
-
const storeId =
|
|
12
|
+
const storeId = config.storeId || env.ECOM_STORE_ID;
|
|
36
13
|
if (!storeId) {
|
|
37
|
-
throw new Error('`storeId` must be set in
|
|
14
|
+
throw new Error('`storeId` must be set in config or `ECOM_STORE_ID` env var');
|
|
38
15
|
}
|
|
39
16
|
url += `/:${storeId}`;
|
|
40
|
-
const lang =
|
|
17
|
+
const lang = config.lang || env.ECOM_LANG;
|
|
41
18
|
if (lang) {
|
|
42
19
|
url += `,lang:${lang}`;
|
|
43
20
|
}
|
|
44
21
|
}
|
|
45
|
-
if (
|
|
46
|
-
if (typeof
|
|
47
|
-
url += `?${
|
|
22
|
+
if (config.params) {
|
|
23
|
+
if (typeof config.params === 'string') {
|
|
24
|
+
url += `?${config.params}`;
|
|
48
25
|
} else {
|
|
49
26
|
// https://github.com/microsoft/TypeScript/issues/32951
|
|
50
|
-
url += `?${new URLSearchParams(
|
|
27
|
+
url += `?${new URLSearchParams(config.params as Record<string, string>)}`;
|
|
51
28
|
}
|
|
52
29
|
}
|
|
53
|
-
return `${url}/${
|
|
30
|
+
return `${url}/${config.endpoint}`;
|
|
54
31
|
},
|
|
55
32
|
};
|
|
56
33
|
|
|
@@ -59,38 +36,59 @@ const setMiddleware = (middleware: typeof def.middleware) => {
|
|
|
59
36
|
def.middleware = middleware;
|
|
60
37
|
};
|
|
61
38
|
|
|
62
|
-
const callApi = (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
39
|
+
const callApi = async <T extends Config>(config: T): Promise<Response & {
|
|
40
|
+
config: Config,
|
|
41
|
+
data: ResponseBody<T>,
|
|
42
|
+
}> => {
|
|
43
|
+
const url = def.middleware(config);
|
|
44
|
+
const { method, headers, timeout = 20000 } = config;
|
|
45
|
+
const abortController = new AbortController();
|
|
46
|
+
const timer = setTimeout(() => abortController.abort(), timeout);
|
|
47
|
+
const response = await fetch(url, {
|
|
48
|
+
method,
|
|
49
|
+
headers,
|
|
50
|
+
signal: abortController.signal,
|
|
51
|
+
});
|
|
52
|
+
clearTimeout(timer);
|
|
53
|
+
if (response.ok) {
|
|
54
|
+
return {
|
|
55
|
+
...response,
|
|
56
|
+
config,
|
|
57
|
+
data: await response.json(),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const error: any = new Error(response.statusText);
|
|
61
|
+
error.config = config;
|
|
62
|
+
error.response = response;
|
|
63
|
+
throw error;
|
|
66
64
|
};
|
|
67
65
|
|
|
68
|
-
const get = (endpoint: Endpoint,
|
|
69
|
-
...
|
|
66
|
+
const get = (endpoint: Endpoint, config: Exclude<Config, 'method'>) => callApi({
|
|
67
|
+
...config,
|
|
70
68
|
method: 'get',
|
|
71
69
|
endpoint,
|
|
72
70
|
});
|
|
73
71
|
|
|
74
|
-
const post = (endpoint: Endpoint,
|
|
75
|
-
...
|
|
72
|
+
const post = (endpoint: Endpoint, config: Exclude<Config, 'method'>) => callApi({
|
|
73
|
+
...config,
|
|
76
74
|
method: 'post',
|
|
77
75
|
endpoint,
|
|
78
76
|
});
|
|
79
77
|
|
|
80
|
-
const put = (endpoint: Endpoint,
|
|
81
|
-
...
|
|
78
|
+
const put = (endpoint: Endpoint, config: Exclude<Config, 'method'>) => callApi({
|
|
79
|
+
...config,
|
|
82
80
|
method: 'put',
|
|
83
81
|
endpoint,
|
|
84
82
|
});
|
|
85
83
|
|
|
86
|
-
const patch = (endpoint: Endpoint,
|
|
87
|
-
...
|
|
84
|
+
const patch = (endpoint: Endpoint, config: Exclude<Config, 'method'>) => callApi({
|
|
85
|
+
...config,
|
|
88
86
|
method: 'patch',
|
|
89
87
|
endpoint,
|
|
90
88
|
});
|
|
91
89
|
|
|
92
|
-
const del = (endpoint: Endpoint,
|
|
93
|
-
...
|
|
90
|
+
const del = (endpoint: Endpoint, config: Exclude<Config, 'method'>) => callApi({
|
|
91
|
+
...config,
|
|
94
92
|
method: 'delete',
|
|
95
93
|
endpoint,
|
|
96
94
|
});
|
|
@@ -112,10 +110,3 @@ export {
|
|
|
112
110
|
patch,
|
|
113
111
|
del,
|
|
114
112
|
};
|
|
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
|
+
}
|