@cloudcommerce/api 0.0.3 → 0.0.4
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/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-test.log +8 -5
- package/dist/index.d.ts +0 -0
- package/dist/index.js +8 -10
- package/dist/index.js.map +1 -1
- package/dist/types/applications.d.ts +0 -0
- package/dist/types/authentications.d.ts +0 -0
- package/dist/types/brands.d.ts +0 -0
- package/dist/types/carts.d.ts +0 -0
- package/dist/types/categories.d.ts +0 -0
- package/dist/types/collections.d.ts +0 -0
- package/dist/types/customers.d.ts +0 -0
- package/dist/types/grids.d.ts +0 -0
- package/dist/types/orders.d.ts +0 -0
- package/dist/types/products.d.ts +0 -0
- package/dist/types/stores.d.ts +0 -0
- package/dist/types.d.ts +0 -0
- package/dist/types.js +0 -0
- package/dist/types.js.map +0 -0
- package/package.json +2 -2
- package/scripts/test.mjs +4 -0
- package/src/index.ts +8 -10
- package/tests/fetch-polyfill.js +21 -0
- package/tests/index.test.ts +14 -0
- package/dist/types/procedures.d.ts +0 -139
- package/dist/types/triggers.d.ts +0 -79
- package/src/types/procedures.d.ts +0 -139
- package/src/types/triggers.d.ts +0 -79
- package/tests/types.test.ts +0 -13
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
@cloudcommerce/api:build: cache hit, replaying output [
|
|
1
|
+
@cloudcommerce/api:build: cache hit, replaying output [2m95f3926a68635b20[0m
|
|
2
2
|
[35m@cloudcommerce/api:build: [0m
|
|
3
|
-
[35m@cloudcommerce/api:build: [0m> @cloudcommerce/api@0.0.
|
|
3
|
+
[35m@cloudcommerce/api:build: [0m> @cloudcommerce/api@0.0.3 build /home/leo/code/ecomplus/cloud-commerce/packages/api
|
|
4
4
|
[35m@cloudcommerce/api:build: [0m> zx scripts/build.mjs
|
|
5
5
|
[35m@cloudcommerce/api:build: [0m
|
|
6
6
|
[35m@cloudcommerce/api:build: [0m$ rm -rf dist
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
@cloudcommerce/api:test: cache hit, replaying output [
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
1
|
+
@cloudcommerce/api:test: cache hit, replaying output [2mb689b985522783d4[0m
|
|
2
|
+
[35m@cloudcommerce/api:test: [0m
|
|
3
|
+
[35m@cloudcommerce/api:test: [0m> @cloudcommerce/api@0.0.3 test /home/leo/code/ecomplus/cloud-commerce/packages/api
|
|
4
|
+
[35m@cloudcommerce/api:test: [0m> zx scripts/test.mjs
|
|
5
|
+
[35m@cloudcommerce/api:test: [0m
|
|
6
|
+
[35m@cloudcommerce/api:test: [0m$ tsc -p ../../tsconfig.test.json
|
|
7
|
+
[35m@cloudcommerce/api:test: [0m$ tsx tests/index.test.ts
|
|
8
|
+
[35m@cloudcommerce/api:test: [0m✓ Read product GFJ4714 and checked SKU type string
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -5,16 +5,14 @@ const env = (typeof window === 'object' && window)
|
|
|
5
5
|
const def = {
|
|
6
6
|
middleware(config) {
|
|
7
7
|
let url = config.baseUrl || env.API_BASE_URL || 'https://ecomplus.io/v2';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
url += `,lang:${lang}`;
|
|
17
|
-
}
|
|
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}`;
|
|
18
16
|
}
|
|
19
17
|
if (config.params) {
|
|
20
18
|
if (typeof config.params === 'string') {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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,
|
|
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,OAAO,EAAE,CAAC;QACtB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,SAAS,CAAC;QAC1C,IAAI,IAAI,EAAE;YACR,GAAG,IAAI,SAAS,IAAI,EAAE,CAAC;SACxB;QACD,IAAI,MAAM,CAAC,MAAM,EAAE;YACjB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/dist/types/brands.d.ts
CHANGED
|
File without changes
|
package/dist/types/carts.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/types/grids.d.ts
CHANGED
|
File without changes
|
package/dist/types/orders.d.ts
CHANGED
|
File without changes
|
package/dist/types/products.d.ts
CHANGED
|
File without changes
|
package/dist/types/stores.d.ts
CHANGED
|
File without changes
|
package/dist/types.d.ts
CHANGED
|
File without changes
|
package/dist/types.js
CHANGED
|
File without changes
|
package/dist/types.js.map
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "E-Com Plus Cloud Commerce APIs client/adapter",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
"homepage": "https://github.com/ecomplus/cloud-commerce/tree/main/packages/api#readme",
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "zx scripts/build.mjs",
|
|
20
|
-
"test": "
|
|
20
|
+
"test": "zx scripts/test.mjs"
|
|
21
21
|
}
|
|
22
22
|
}
|
package/scripts/test.mjs
ADDED
package/src/index.ts
CHANGED
|
@@ -8,16 +8,14 @@ const env: { [key: string]: string } = (typeof window === 'object' && window)
|
|
|
8
8
|
const def = {
|
|
9
9
|
middleware(config: Config) {
|
|
10
10
|
let url = config.baseUrl || env.API_BASE_URL || 'https://ecomplus.io/v2';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
url += `,lang:${lang}`;
|
|
20
|
-
}
|
|
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');
|
|
14
|
+
}
|
|
15
|
+
url += `/:${storeId}`;
|
|
16
|
+
const lang = config.lang || env.ECOM_LANG;
|
|
17
|
+
if (lang) {
|
|
18
|
+
url += `,lang:${lang}`;
|
|
21
19
|
}
|
|
22
20
|
if (config.params) {
|
|
23
21
|
if (typeof config.params === 'string') {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies, no-unused-vars */
|
|
2
|
+
|
|
3
|
+
import fetch, {
|
|
4
|
+
Blob,
|
|
5
|
+
blobFrom,
|
|
6
|
+
blobFromSync,
|
|
7
|
+
File,
|
|
8
|
+
fileFrom,
|
|
9
|
+
fileFromSync,
|
|
10
|
+
FormData,
|
|
11
|
+
Headers,
|
|
12
|
+
Request,
|
|
13
|
+
Response,
|
|
14
|
+
} from 'node-fetch';
|
|
15
|
+
|
|
16
|
+
if (!globalThis.fetch) {
|
|
17
|
+
globalThis.fetch = fetch;
|
|
18
|
+
globalThis.Headers = Headers;
|
|
19
|
+
globalThis.Request = Request;
|
|
20
|
+
globalThis.Response = Response;
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import './fetch-polyfill';
|
|
3
|
+
import callApi from '../src/index';
|
|
4
|
+
|
|
5
|
+
callApi({
|
|
6
|
+
storeId: 1056,
|
|
7
|
+
method: 'get',
|
|
8
|
+
endpoint: 'products/618041aa239b7206d3fc06de',
|
|
9
|
+
}).then(({ data }) => {
|
|
10
|
+
if (data.sku === 'string') {
|
|
11
|
+
console.log('\\o/');
|
|
12
|
+
}
|
|
13
|
+
console.info(`✓ Read product ${data.sku} and checked SKU type string`);
|
|
14
|
+
});
|
|
@@ -1,139 +0,0 @@
|
|
|
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
|
-
* Procedure object model
|
|
10
|
-
*/
|
|
11
|
-
export interface Procedures {
|
|
12
|
-
_id: string;
|
|
13
|
-
created_at: string;
|
|
14
|
-
updated_at: string;
|
|
15
|
-
store_id: number;
|
|
16
|
-
/**
|
|
17
|
-
* Procedure title
|
|
18
|
-
*/
|
|
19
|
-
title: string;
|
|
20
|
-
/**
|
|
21
|
-
* Short procedure description in plain text
|
|
22
|
-
*/
|
|
23
|
-
short_description?: string;
|
|
24
|
-
/**
|
|
25
|
-
* List of events that call this procedure
|
|
26
|
-
*/
|
|
27
|
-
triggers: {
|
|
28
|
-
/**
|
|
29
|
-
* Method (HTTP verb) of the event, if undefined will match any method
|
|
30
|
-
*/
|
|
31
|
-
method?: 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
|
32
|
-
/**
|
|
33
|
-
* Type of action taken, if undefined will match any action
|
|
34
|
-
*/
|
|
35
|
-
action?: 'create' | 'change' | 'delete';
|
|
36
|
-
/**
|
|
37
|
-
* API resource
|
|
38
|
-
*/
|
|
39
|
-
resource:
|
|
40
|
-
| 'authentications'
|
|
41
|
-
| 'products'
|
|
42
|
-
| 'categories'
|
|
43
|
-
| 'brands'
|
|
44
|
-
| 'collections'
|
|
45
|
-
| 'grids'
|
|
46
|
-
| 'customers'
|
|
47
|
-
| 'carts'
|
|
48
|
-
| 'orders'
|
|
49
|
-
| 'applications'
|
|
50
|
-
| 'stores';
|
|
51
|
-
/**
|
|
52
|
-
* Resource ID, if specified
|
|
53
|
-
*/
|
|
54
|
-
resource_id?: string;
|
|
55
|
-
/**
|
|
56
|
-
* Subresource slug (URL path), use wildcard `*` to match either none or any subresource
|
|
57
|
-
*/
|
|
58
|
-
subresource?: string | null;
|
|
59
|
-
/**
|
|
60
|
-
* Subresource ID, if specified
|
|
61
|
-
*/
|
|
62
|
-
subresource_id?: string;
|
|
63
|
-
/**
|
|
64
|
-
* Property created or updated with the event, if undefined will match any fields
|
|
65
|
-
*/
|
|
66
|
-
field?: string;
|
|
67
|
-
}[];
|
|
68
|
-
/**
|
|
69
|
-
* List of notifications to be sent when this procedure is called. In some properties you can use variables from trigger object with (tr.*) notation, eg.: (tr.body.name)
|
|
70
|
-
*/
|
|
71
|
-
webhooks: {
|
|
72
|
-
/**
|
|
73
|
-
* API where notification should be sent
|
|
74
|
-
*/
|
|
75
|
-
api: {
|
|
76
|
-
/**
|
|
77
|
-
* Use this property if webhook is to store API (api.e-com.plus)
|
|
78
|
-
*/
|
|
79
|
-
store_api?: {
|
|
80
|
-
/**
|
|
81
|
-
* API endpoint, such as /products.json, you can also include variables
|
|
82
|
-
*/
|
|
83
|
-
endpoint?: string;
|
|
84
|
-
/**
|
|
85
|
-
* API version
|
|
86
|
-
*/
|
|
87
|
-
version?: 'v1' | 'current';
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Use this property if webhook is to any external API (not api.e-com.plus)
|
|
91
|
-
*/
|
|
92
|
-
external_api?: {
|
|
93
|
-
/**
|
|
94
|
-
* Full URL to external API endpoint, you can also use variables here
|
|
95
|
-
*/
|
|
96
|
-
uri: string;
|
|
97
|
-
/**
|
|
98
|
-
* List of headers to be sent on the request
|
|
99
|
-
*/
|
|
100
|
-
headers?: {
|
|
101
|
-
/**
|
|
102
|
-
* Header field name, eg.: X-Access-Token
|
|
103
|
-
*/
|
|
104
|
-
name: string;
|
|
105
|
-
/**
|
|
106
|
-
* Header field value, you can also use variables here
|
|
107
|
-
*/
|
|
108
|
-
value: string;
|
|
109
|
-
}[];
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* Method (HTTP verb) to send request
|
|
114
|
-
*/
|
|
115
|
-
method: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
|
116
|
-
/**
|
|
117
|
-
* Send body on notification, if true and map_body undefined, trigger object will be sent
|
|
118
|
-
*/
|
|
119
|
-
send_body?: boolean;
|
|
120
|
-
/**
|
|
121
|
-
* Object to send, it is possible to use variables as properties values
|
|
122
|
-
*/
|
|
123
|
-
map_body?: {
|
|
124
|
-
[k: string]: unknown;
|
|
125
|
-
};
|
|
126
|
-
}[];
|
|
127
|
-
/**
|
|
128
|
-
* Tag to identify object, use only lowercase letters, digits and underscore
|
|
129
|
-
*/
|
|
130
|
-
tag?: string;
|
|
131
|
-
/**
|
|
132
|
-
* Flags to associate additional info
|
|
133
|
-
*/
|
|
134
|
-
flags?: string[];
|
|
135
|
-
/**
|
|
136
|
-
* Optional notes with additional info about this procedure
|
|
137
|
-
*/
|
|
138
|
-
notes?: string;
|
|
139
|
-
}
|
package/dist/types/triggers.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
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
|
-
* Procedure object model
|
|
10
|
-
*/
|
|
11
|
-
export interface Procedures {
|
|
12
|
-
_id: string;
|
|
13
|
-
created_at: string;
|
|
14
|
-
updated_at: string;
|
|
15
|
-
store_id: number;
|
|
16
|
-
/**
|
|
17
|
-
* Procedure title
|
|
18
|
-
*/
|
|
19
|
-
title: string;
|
|
20
|
-
/**
|
|
21
|
-
* Short procedure description in plain text
|
|
22
|
-
*/
|
|
23
|
-
short_description?: string;
|
|
24
|
-
/**
|
|
25
|
-
* List of events that call this procedure
|
|
26
|
-
*/
|
|
27
|
-
triggers: {
|
|
28
|
-
/**
|
|
29
|
-
* Method (HTTP verb) of the event, if undefined will match any method
|
|
30
|
-
*/
|
|
31
|
-
method?: 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
|
32
|
-
/**
|
|
33
|
-
* Type of action taken, if undefined will match any action
|
|
34
|
-
*/
|
|
35
|
-
action?: 'create' | 'change' | 'delete';
|
|
36
|
-
/**
|
|
37
|
-
* API resource
|
|
38
|
-
*/
|
|
39
|
-
resource:
|
|
40
|
-
| 'authentications'
|
|
41
|
-
| 'products'
|
|
42
|
-
| 'categories'
|
|
43
|
-
| 'brands'
|
|
44
|
-
| 'collections'
|
|
45
|
-
| 'grids'
|
|
46
|
-
| 'customers'
|
|
47
|
-
| 'carts'
|
|
48
|
-
| 'orders'
|
|
49
|
-
| 'applications'
|
|
50
|
-
| 'stores';
|
|
51
|
-
/**
|
|
52
|
-
* Resource ID, if specified
|
|
53
|
-
*/
|
|
54
|
-
resource_id?: string;
|
|
55
|
-
/**
|
|
56
|
-
* Subresource slug (URL path), use wildcard `*` to match either none or any subresource
|
|
57
|
-
*/
|
|
58
|
-
subresource?: string | null;
|
|
59
|
-
/**
|
|
60
|
-
* Subresource ID, if specified
|
|
61
|
-
*/
|
|
62
|
-
subresource_id?: string;
|
|
63
|
-
/**
|
|
64
|
-
* Property created or updated with the event, if undefined will match any fields
|
|
65
|
-
*/
|
|
66
|
-
field?: string;
|
|
67
|
-
}[];
|
|
68
|
-
/**
|
|
69
|
-
* List of notifications to be sent when this procedure is called. In some properties you can use variables from trigger object with (tr.*) notation, eg.: (tr.body.name)
|
|
70
|
-
*/
|
|
71
|
-
webhooks: {
|
|
72
|
-
/**
|
|
73
|
-
* API where notification should be sent
|
|
74
|
-
*/
|
|
75
|
-
api: {
|
|
76
|
-
/**
|
|
77
|
-
* Use this property if webhook is to store API (api.e-com.plus)
|
|
78
|
-
*/
|
|
79
|
-
store_api?: {
|
|
80
|
-
/**
|
|
81
|
-
* API endpoint, such as /products.json, you can also include variables
|
|
82
|
-
*/
|
|
83
|
-
endpoint?: string;
|
|
84
|
-
/**
|
|
85
|
-
* API version
|
|
86
|
-
*/
|
|
87
|
-
version?: 'v1' | 'current';
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Use this property if webhook is to any external API (not api.e-com.plus)
|
|
91
|
-
*/
|
|
92
|
-
external_api?: {
|
|
93
|
-
/**
|
|
94
|
-
* Full URL to external API endpoint, you can also use variables here
|
|
95
|
-
*/
|
|
96
|
-
uri: string;
|
|
97
|
-
/**
|
|
98
|
-
* List of headers to be sent on the request
|
|
99
|
-
*/
|
|
100
|
-
headers?: {
|
|
101
|
-
/**
|
|
102
|
-
* Header field name, eg.: X-Access-Token
|
|
103
|
-
*/
|
|
104
|
-
name: string;
|
|
105
|
-
/**
|
|
106
|
-
* Header field value, you can also use variables here
|
|
107
|
-
*/
|
|
108
|
-
value: string;
|
|
109
|
-
}[];
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* Method (HTTP verb) to send request
|
|
114
|
-
*/
|
|
115
|
-
method: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
|
116
|
-
/**
|
|
117
|
-
* Send body on notification, if true and map_body undefined, trigger object will be sent
|
|
118
|
-
*/
|
|
119
|
-
send_body?: boolean;
|
|
120
|
-
/**
|
|
121
|
-
* Object to send, it is possible to use variables as properties values
|
|
122
|
-
*/
|
|
123
|
-
map_body?: {
|
|
124
|
-
[k: string]: unknown;
|
|
125
|
-
};
|
|
126
|
-
}[];
|
|
127
|
-
/**
|
|
128
|
-
* Tag to identify object, use only lowercase letters, digits and underscore
|
|
129
|
-
*/
|
|
130
|
-
tag?: string;
|
|
131
|
-
/**
|
|
132
|
-
* Flags to associate additional info
|
|
133
|
-
*/
|
|
134
|
-
flags?: string[];
|
|
135
|
-
/**
|
|
136
|
-
* Optional notes with additional info about this procedure
|
|
137
|
-
*/
|
|
138
|
-
notes?: string;
|
|
139
|
-
}
|
package/src/types/triggers.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
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
|
-
}
|
package/tests/types.test.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
});
|