oneentry 1.0.73 → 1.0.75
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/README.md +9 -2
- package/dist/base/asyncModules.js +7 -4
- package/dist/base/syncModules.d.ts +2 -0
- package/dist/base/syncModules.js +8 -0
- package/dist/formsData/formsDataInterfaces.d.ts +4 -11
- package/dist/orders/ordersApi.d.ts +2 -2
- package/dist/orders/ordersApi.js +2 -2
- package/dist/orders/ordersInterfaces.d.ts +5 -3
- package/dist/payments/paymentsInterfaces.d.ts +5 -1
- package/dist/users/usersInterfaces.d.ts +2 -0
- package/dist/web-socket/wsApi.d.ts +11 -0
- package/dist/web-socket/wsApi.js +23 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ To install the AsyncModules Headless CMS SDK in your project, run the following
|
|
|
18
18
|
npm install oneentry
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
## Get Started
|
|
22
22
|
|
|
23
23
|
To use the AsyncModules Headless CMS SDK in your project, import the defineOneEntry function:
|
|
24
24
|
```js
|
|
@@ -101,6 +101,12 @@ const api = defineOneEntry('https://my-project.oneentry.cloud', {
|
|
|
101
101
|
})
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
+
If you have chosen to configure tokens yourself, you can pass the token to the method as follows.
|
|
105
|
+
The intermediate method allows you to pass an access token to the request. Then call the required method.
|
|
106
|
+
This method (setAccessToken) should not be called if the method does not require user authorization.
|
|
107
|
+
```js
|
|
108
|
+
const user = api.Users.setAccessToken('my.access.token').getUser()
|
|
109
|
+
```
|
|
104
110
|
|
|
105
111
|
>If you chose token protection to ensure connection security, just pass your token to the function as an optional parameter.
|
|
106
112
|
|
|
@@ -3351,7 +3357,8 @@ Example return:
|
|
|
3351
3357
|
"id": 1764,
|
|
3352
3358
|
"updatedDate": "2024-06-21T09:53:28.898Z",
|
|
3353
3359
|
"version": 10,
|
|
3354
|
-
"identifier": "my-id"
|
|
3360
|
+
"identifier": "my-id",
|
|
3361
|
+
"paymentUrl": "https://paymewntlink.com"
|
|
3355
3362
|
}
|
|
3356
3363
|
```
|
|
3357
3364
|
<details>
|
|
@@ -6,16 +6,19 @@ class AsyncModules extends syncModules_1.default {
|
|
|
6
6
|
super(state);
|
|
7
7
|
this._url = this.state.url;
|
|
8
8
|
this.state = state;
|
|
9
|
-
this._NO_FETCH = !!(typeof process === 'object' && process.versions);
|
|
10
9
|
try {
|
|
11
|
-
|
|
12
|
-
this.
|
|
10
|
+
if (typeof process === 'object' && +process.versions.node.split('.')[0] < 18) {
|
|
11
|
+
this._NO_FETCH = true;
|
|
12
|
+
this._https = require('https');
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
else {
|
|
15
|
+
this._NO_FETCH = false;
|
|
15
16
|
this._https = null;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
catch (e) {
|
|
20
|
+
this._NO_FETCH = false;
|
|
21
|
+
this._https = null;
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
async _fetchGet(path) {
|
|
@@ -11,4 +11,6 @@ export default abstract class SyncModules {
|
|
|
11
11
|
protected _normalizePostBody(body: any, langCode?: string): any;
|
|
12
12
|
protected _clearArray(data: Record<string, any>): any;
|
|
13
13
|
protected _dataPostProcess(data: any, langCode?: string): any;
|
|
14
|
+
setAccessToken(accessToken: string): this;
|
|
15
|
+
setRefreshToken(refreshToken: string): this;
|
|
14
16
|
}
|
package/dist/base/syncModules.js
CHANGED
|
@@ -68,5 +68,13 @@ class SyncModules {
|
|
|
68
68
|
const result = this._clearArray(normalize);
|
|
69
69
|
return result;
|
|
70
70
|
}
|
|
71
|
+
setAccessToken(accessToken) {
|
|
72
|
+
this.state.accessToken = accessToken;
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
setRefreshToken(refreshToken) {
|
|
76
|
+
this.state.refreshToken = refreshToken;
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
71
79
|
}
|
|
72
80
|
exports.default = SyncModules;
|
|
@@ -29,28 +29,21 @@ interface IFormsDataEntity {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Contains an array of data form objects with the following values
|
|
32
|
-
*
|
|
33
|
-
* @property {string} marker Form data marker.
|
|
34
|
-
*
|
|
35
|
-
* @property {string} value Form data value.
|
|
36
32
|
*/
|
|
37
|
-
|
|
38
|
-
marker?: string;
|
|
39
|
-
value?: string;
|
|
40
|
-
}
|
|
33
|
+
type FormDataType = IBodyTypeStringNumberFloat | IBodyTypeTimeDate | IBodyTypeText | IBodyTypeTextWithHeader | IBodyTypeImageGroupOfImages | IBodyTypeFile | IBodyTypeRadioButtonList | Record<string, any>;
|
|
41
34
|
/**
|
|
42
35
|
* interface to create an object of information about saving data using the form
|
|
43
36
|
*
|
|
44
37
|
* @property {number} id
|
|
45
38
|
* @property {string} formIdentifier - The identifier of the page.
|
|
46
39
|
* @property {Date | string} time - Date and time of form modification
|
|
47
|
-
* @property {
|
|
40
|
+
* @property {Array<FormDataType>} formData - The identifier of the page.
|
|
48
41
|
*/
|
|
49
42
|
interface IFormsPost {
|
|
50
43
|
id?: number;
|
|
51
44
|
formIdentifier: string;
|
|
52
45
|
time?: Date | string;
|
|
53
|
-
formData: Array<
|
|
46
|
+
formData: Array<FormDataType>;
|
|
54
47
|
}
|
|
55
48
|
/**
|
|
56
49
|
* @property {string} marker - marker name
|
|
@@ -168,4 +161,4 @@ interface IBodyTypeRadioButtonList {
|
|
|
168
161
|
};
|
|
169
162
|
}>;
|
|
170
163
|
}
|
|
171
|
-
export { IFormsPost, IFormsData,
|
|
164
|
+
export { IFormsPost, IFormsData, FormDataType, IFormsDataEntity, IBodyTypeStringNumberFloat, IBodyTypeTimeDate, IBodyTypeText, IBodyTypeTextWithHeader, IBodyTypeImageGroupOfImages, IBodyTypeFile, IBodyTypeRadioButtonList };
|
|
@@ -38,7 +38,7 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
|
|
|
38
38
|
*/
|
|
39
39
|
createOrder(marker: string, data: IOrderData, langCode?: string): Promise<IBaseOrdersEntity>;
|
|
40
40
|
/**
|
|
41
|
-
* Getting all
|
|
41
|
+
* Getting all orders from the orders storage object created by the user
|
|
42
42
|
*
|
|
43
43
|
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
44
44
|
* @param {number} marker - Textual identifier of the order storage object
|
|
@@ -48,7 +48,7 @@ export default class OrdersApi extends AsyncModules implements IOrdersApi {
|
|
|
48
48
|
*/
|
|
49
49
|
getAllOrdersByMarker(marker: string, langCode?: string, limit?: number, offset?: number): Promise<Array<IOrdersByMarkersEntity>>;
|
|
50
50
|
/**
|
|
51
|
-
* Changing an order in the
|
|
51
|
+
* Changing an order in the orders storage
|
|
52
52
|
*
|
|
53
53
|
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
54
54
|
* @param marker - The text identifier of the order storage object
|
package/dist/orders/ordersApi.js
CHANGED
|
@@ -45,7 +45,7 @@ class OrdersApi extends asyncModules_1.default {
|
|
|
45
45
|
return this._normalizeData(result);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Getting all
|
|
48
|
+
* Getting all orders from the orders storage object created by the user
|
|
49
49
|
*
|
|
50
50
|
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
51
51
|
* @param {number} marker - Textual identifier of the order storage object
|
|
@@ -58,7 +58,7 @@ class OrdersApi extends asyncModules_1.default {
|
|
|
58
58
|
return this._normalizeData(result.items);
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
* Changing an order in the
|
|
61
|
+
* Changing an order in the orders storage
|
|
62
62
|
*
|
|
63
63
|
* @description This method requires user authorization. For more information about configuring the authorization module, see the documentation in the configuration settings section of the SDK.
|
|
64
64
|
* @param marker - The text identifier of the order storage object
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @property {function} updateOrderByMarkerAndId - Changing an order in the order store.
|
|
7
7
|
* @property {function} getAllOrders - Getting all the order storage objects.
|
|
8
8
|
* @property {function} getAllOrdersByMarker - Getting one order storage object by marker.
|
|
9
|
+
* @property {function} setAccessToken - Only for custom authorization. An intermediate method for setting up an access token.
|
|
9
10
|
|
|
10
11
|
*/
|
|
11
12
|
interface IOrdersApi {
|
|
@@ -14,6 +15,7 @@ interface IOrdersApi {
|
|
|
14
15
|
updateOrderByMarkerAndId(marker: string, id: number, data: IOrderData, langCode?: string): Promise<IBaseOrdersEntity>;
|
|
15
16
|
getAllOrders(langCode?: string, limit?: number, offset?: number): Promise<Array<IOrdersEntity>>;
|
|
16
17
|
getAllOrdersByMarker(marker: string, langCode?: string, limit?: number, offset?: number): Promise<Array<IOrdersByMarkersEntity>>;
|
|
18
|
+
setAccessToken(accessToken: string): IOrdersApi;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* @property {string} filename
|
|
@@ -31,9 +33,9 @@ interface IOrderProducts {
|
|
|
31
33
|
id: number;
|
|
32
34
|
title: string;
|
|
33
35
|
sku: string | null;
|
|
34
|
-
price:
|
|
36
|
+
price: number;
|
|
35
37
|
quantity: number | null;
|
|
36
|
-
previewImage: IPicture
|
|
38
|
+
previewImage: Array<IPicture>;
|
|
37
39
|
}
|
|
38
40
|
/**
|
|
39
41
|
* @property {string} marker - Marker of form field.
|
|
@@ -42,7 +44,7 @@ interface IOrderProducts {
|
|
|
42
44
|
*/
|
|
43
45
|
interface IOrdersFormData {
|
|
44
46
|
marker: string;
|
|
45
|
-
value:
|
|
47
|
+
value: any;
|
|
46
48
|
type: string;
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @property {function} getAccounts - Get all payment accounts as an array.
|
|
9
9
|
* @property {function} getAccountById - Get a single payment account object by its identifier.
|
|
10
10
|
* @property {function} webhookStripe - Webhook for Stripe.
|
|
11
|
-
*
|
|
11
|
+
* @property {function} setAccessToken - Only for custom authorization. An intermediate method for setting up an access token.
|
|
12
12
|
*/
|
|
13
13
|
interface IPaymentsApi {
|
|
14
14
|
getSessions(limit: number, offset: number): Promise<Array<ISessionEntity>>;
|
|
@@ -18,6 +18,7 @@ interface IPaymentsApi {
|
|
|
18
18
|
getAccounts(): Promise<Array<IAccountsEntity>>;
|
|
19
19
|
getAccountById(id: number): Promise<IAccountsEntity>;
|
|
20
20
|
webhookStripe(): Promise<boolean>;
|
|
21
|
+
setAccessToken(accessToken: string): IPaymentsApi;
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
*
|
|
@@ -49,6 +50,7 @@ interface IIntent {
|
|
|
49
50
|
* @property {number} id - Object identifier.
|
|
50
51
|
* @property {string} updatedDate - Object modification date.
|
|
51
52
|
* @property {string} type - Type may be 'session' or 'intent'.
|
|
53
|
+
* @property {string} status - payment status.
|
|
52
54
|
* @property {number} orderId - Order identifier.
|
|
53
55
|
* @property {number} paymentAccountId - Payment account object identifier.
|
|
54
56
|
* @property {string} paymentUrl - Payment link.
|
|
@@ -62,12 +64,14 @@ interface ISessionEntity {
|
|
|
62
64
|
paymentAccountId: number;
|
|
63
65
|
paymentUrl: string;
|
|
64
66
|
clientSecret: string;
|
|
67
|
+
status: string;
|
|
65
68
|
}
|
|
66
69
|
interface ICreateSessionEntity {
|
|
67
70
|
id: number;
|
|
68
71
|
updatedDate: string;
|
|
69
72
|
version: number;
|
|
70
73
|
identifier: string;
|
|
74
|
+
paymentUrl: string;
|
|
71
75
|
}
|
|
72
76
|
/**
|
|
73
77
|
* @interface
|
|
@@ -4,10 +4,12 @@ import { IAuthFormData } from "../auth-provider/authProvidersInterfaces";
|
|
|
4
4
|
*
|
|
5
5
|
* @property {function} subscribeByMarker - Getting the data of an authorized user.
|
|
6
6
|
* @property {function} unsubscribeByMarker - Updating a single user object.
|
|
7
|
+
* @property {function} setAccessToken - Only for custom authorization. An intermediate method for setting up an access token.
|
|
7
8
|
*/
|
|
8
9
|
interface IUsers {
|
|
9
10
|
getUser(langCode?: string): Promise<IUserEntity>;
|
|
10
11
|
updateUser(data: IUserBody, langCode?: string): Promise<boolean>;
|
|
12
|
+
setAccessToken(accessToken: string): IUsers;
|
|
11
13
|
}
|
|
12
14
|
interface IUserEntity {
|
|
13
15
|
id: number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import AsyncModules from "../base/asyncModules";
|
|
2
|
+
import StateModule from "../base/stateModule";
|
|
3
|
+
/**
|
|
4
|
+
* Controllers for working with users
|
|
5
|
+
*/
|
|
6
|
+
export default class UsersApi extends AsyncModules {
|
|
7
|
+
protected state: StateModule;
|
|
8
|
+
protected _url: string;
|
|
9
|
+
constructor(state: StateModule);
|
|
10
|
+
connect(): Promise<import("socket.io-client").Socket<import("@socket.io/component-emitter").DefaultEventsMap, import("@socket.io/component-emitter").DefaultEventsMap>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const asyncModules_1 = require("../base/asyncModules");
|
|
4
|
+
const socket_io_client_1 = require("socket.io-client");
|
|
5
|
+
/**
|
|
6
|
+
* Controllers for working with users
|
|
7
|
+
*/
|
|
8
|
+
class UsersApi extends asyncModules_1.default {
|
|
9
|
+
constructor(state) {
|
|
10
|
+
super(state);
|
|
11
|
+
this._url = state.url + '/api/content/ws';
|
|
12
|
+
}
|
|
13
|
+
async connect() {
|
|
14
|
+
const socket = (0, socket_io_client_1.io)(this._url, {
|
|
15
|
+
extraHeaders: {
|
|
16
|
+
"Authorization": this.state.accessToken,
|
|
17
|
+
"x-app-token": this.state.token
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return socket;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = UsersApi;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oneentry",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.75",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@types/jest": "^29.5.11",
|
|
23
23
|
"@types/node": "^20.10.5",
|
|
24
24
|
"jest": "^29.7.0",
|
|
25
|
+
"socket.io-client": "^4.7.5",
|
|
25
26
|
"ts-jest": "^29.1.1",
|
|
26
27
|
"typescript": "^5.3.3"
|
|
27
28
|
}
|