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,74 @@
|
|
|
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
|
+
|
|
12
|
+
type Resource = 'products'
|
|
13
|
+
| 'categories'
|
|
14
|
+
| 'brands'
|
|
15
|
+
| 'collections'
|
|
16
|
+
| 'grids'
|
|
17
|
+
| 'carts'
|
|
18
|
+
| 'orders'
|
|
19
|
+
| 'customers'
|
|
20
|
+
| 'stores'
|
|
21
|
+
| 'applications';
|
|
22
|
+
|
|
23
|
+
type ResourceId = string & { length: 24 };
|
|
24
|
+
|
|
25
|
+
type ResourceAndId = `${Resource}/${ResourceId}`;
|
|
26
|
+
|
|
27
|
+
type Endpoint = Resource | ResourceAndId | `${ResourceAndId}/${string}`;
|
|
28
|
+
|
|
29
|
+
type Method = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
30
|
+
|
|
31
|
+
type Config = {
|
|
32
|
+
baseUrl?: string,
|
|
33
|
+
storeId?: number,
|
|
34
|
+
lang?: string,
|
|
35
|
+
method: Method,
|
|
36
|
+
endpoint: Endpoint,
|
|
37
|
+
params?: Record<string, string | number>,
|
|
38
|
+
headers?: Record<string, string>,
|
|
39
|
+
timeout?: number,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type ResponseBody<T> =
|
|
43
|
+
T extends Config & { method: 'post' } ? { _id: ResourceId } :
|
|
44
|
+
T extends Config & { method: 'put' | 'patch' | 'delete' } ? null :
|
|
45
|
+
T extends Config & { method: 'get', endpoint: `products/${ResourceId}` } ? Products :
|
|
46
|
+
T extends Config & { method: 'get', endpoint: `categories/${ResourceId}` } ? Categories :
|
|
47
|
+
T extends Config & { method: 'get', endpoint: `brands/${ResourceId}` } ? Brands :
|
|
48
|
+
T extends Config & { method: 'get', endpoint: `collections/${ResourceId}` } ? Collections :
|
|
49
|
+
T extends Config & { method: 'get', endpoint: `grids/${ResourceId}` } ? Grids :
|
|
50
|
+
T extends Config & { method: 'get', endpoint: `carts/${ResourceId}` } ? Carts :
|
|
51
|
+
T extends Config & { method: 'get', endpoint: `orders/${ResourceId}` } ? Orders :
|
|
52
|
+
T extends Config & { method: 'get', endpoint: `customers/${ResourceId}` } ? Customers :
|
|
53
|
+
T extends Config & { method: 'get', endpoint: `stores/${ResourceId}` } ? Stores :
|
|
54
|
+
T extends Config & { method: 'get', endpoint: `applications/${ResourceId}` } ? Applications :
|
|
55
|
+
any
|
|
56
|
+
|
|
57
|
+
export type {
|
|
58
|
+
Products,
|
|
59
|
+
Categories,
|
|
60
|
+
Brands,
|
|
61
|
+
Collections,
|
|
62
|
+
Grids,
|
|
63
|
+
Carts,
|
|
64
|
+
Orders,
|
|
65
|
+
Customers,
|
|
66
|
+
Stores,
|
|
67
|
+
Applications,
|
|
68
|
+
Resource,
|
|
69
|
+
ResourceAndId,
|
|
70
|
+
Endpoint,
|
|
71
|
+
Method,
|
|
72
|
+
Config,
|
|
73
|
+
ResponseBody,
|
|
74
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import callApi from '../src/index';
|
|
2
|
+
|
|
3
|
+
callApi({
|
|
4
|
+
storeId: 1056,
|
|
5
|
+
method: 'get',
|
|
6
|
+
endpoint: 'products/618041aa239b7206d3fc06de',
|
|
7
|
+
}).then(({ data }) => {
|
|
8
|
+
if (data.sku === '123') {
|
|
9
|
+
console.log('123');
|
|
10
|
+
} else {
|
|
11
|
+
console.log(data._id);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
12
|
|
|
13
13
|
/* Language and Environment */
|
|
14
|
-
"target": "
|
|
14
|
+
"target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
15
|
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
16
|
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
17
|
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
/* Modules */
|
|
27
27
|
"module": "es2020", /* Specify what module code is generated. */
|
|
28
|
-
// "rootDir": "
|
|
28
|
+
// "rootDir": "src", /* Specify the root folder within your source files. */
|
|
29
29
|
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
30
30
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
31
31
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
@@ -97,5 +97,10 @@
|
|
|
97
97
|
/* Completeness */
|
|
98
98
|
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
99
99
|
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
100
|
-
}
|
|
100
|
+
},
|
|
101
|
+
"exclude": [
|
|
102
|
+
"**/dist/**",
|
|
103
|
+
"**/node_modules/**",
|
|
104
|
+
"**/tests/**"
|
|
105
|
+
]
|
|
101
106
|
}
|