oneentry 1.0.119 → 1.0.120

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.
@@ -47,7 +47,7 @@ export default class AttributesSetsApi extends AsyncModules implements IAttribut
47
47
  * @param {string} [marker] - marker of the attribute set object
48
48
  * @param {string} [langCode] - Language code.
49
49
  *
50
- * @returns Returns one object ContentPositionAttributesSetDto of the attribute set
50
+ * @returns Returns one object of the attribute set
51
51
  */
52
52
  getAttributeSetByMarker(marker: string, langCode?: string): Promise<IAttributeSetsEntity | IError>;
53
53
  }
@@ -67,7 +67,7 @@ class AttributesSetsApi extends asyncModules_1.default {
67
67
  * @param {string} [marker] - marker of the attribute set object
68
68
  * @param {string} [langCode] - Language code.
69
69
  *
70
- * @returns Returns one object ContentPositionAttributesSetDto of the attribute set
70
+ * @returns Returns one object of the attribute set
71
71
  */
72
72
  async getAttributeSetByMarker(marker, langCode = this.state.lang) {
73
73
  const result = await this._fetchGet(`/marker/${marker}/?langCode=${langCode}`);
@@ -117,6 +117,10 @@ export default class AuthProviderApi extends AsyncModules implements IAuthProvid
117
117
  * @param {string} [code] - Service code
118
118
  * @param {string} [newPassword] - New password
119
119
  * @param {string} [repeatPassword] - Optional variable contains repeat new password for validation
120
+ *
121
+ * @example
122
+ * await AuthProvider.changePassword('email', userIdentifier, type, code, newPassword, repeatPassword);
123
+ *
120
124
  */
121
125
  changePassword(marker: string, userIdentifier: string, type: number, code: string, newPassword: string, repeatPassword?: string): Promise<boolean | IError>;
122
126
  /**
@@ -177,6 +177,10 @@ class AuthProviderApi extends asyncModules_1.default {
177
177
  * @param {string} [code] - Service code
178
178
  * @param {string} [newPassword] - New password
179
179
  * @param {string} [repeatPassword] - Optional variable contains repeat new password for validation
180
+ *
181
+ * @example
182
+ * await AuthProvider.changePassword('email', userIdentifier, type, code, newPassword, repeatPassword);
183
+ *
180
184
  */
181
185
  async changePassword(marker, userIdentifier, type, code, newPassword, repeatPassword) {
182
186
  const data = {
@@ -182,9 +182,14 @@ class AsyncModules extends syncModules_1.default {
182
182
  };
183
183
  if (data instanceof FormData || data instanceof Blob) {
184
184
  delete options.headers['Content-Type'];
185
+ options.headers = {
186
+ ...options.headers,
187
+ accept: 'application/json',
188
+ };
189
+ options.body = data;
185
190
  }
186
- if (data) {
187
- options['body'] = JSON.stringify(data);
191
+ else if (data) {
192
+ options.body = JSON.stringify(data);
188
193
  }
189
194
  if (this.state.accessToken) {
190
195
  options.headers['Authorization'] = 'Bearer ' + this.state.accessToken;
@@ -256,6 +256,7 @@ class SyncModules {
256
256
  * @returns normalized Attrs
257
257
  */
258
258
  _normalizeAttr(data) {
259
+ // for regular attributes
259
260
  if ('attributeValues' in data) {
260
261
  for (const attr in data.attributeValues) {
261
262
  // normalize numbers
@@ -278,6 +279,26 @@ class SyncModules {
278
279
  attributeValues: this._sortAttributes(data.attributeValues),
279
280
  };
280
281
  }
282
+ // for forms attributes
283
+ if ('attributes' in data) {
284
+ const d = data.attributes;
285
+ for (const attr in d) {
286
+ // normalize numbers
287
+ if (d[attr].type === 'integer' || d[attr].type === 'float') {
288
+ d[attr].value = Number(d[attr].value);
289
+ }
290
+ // add timeIntervals
291
+ if (d[attr].type === 'timeInterval') {
292
+ const schedules = d[attr].value;
293
+ // console.log(JSON.stringify(schedules));
294
+ if (Array.isArray(schedules) && schedules.length > 0) {
295
+ const result = this._addTimeIntervalsToSchedules(schedules);
296
+ d[attr].value = result;
297
+ }
298
+ }
299
+ }
300
+ return data;
301
+ }
281
302
  return data;
282
303
  }
283
304
  /**
@@ -1,4 +1,4 @@
1
- type Types = 'forCatalogProducts' | 'forBasketPage' | 'forErrorPage' | 'forCatalogPages' | 'forProductPreview' | 'forProductPage' | 'forSimilarProductBlock' | 'forStatisticProductBlock' | 'forProductBlock' | 'forForm' | 'forFormField' | 'forNewsPage' | 'forNewsBlock' | 'forNewsPreview' | 'forOneNewsPage' | 'forUsualPage' | 'forTextBlock' | 'forSlider' | 'forSliderBlock' | 'forOrder' | 'service' | 'none';
1
+ type Types = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'none';
2
2
  /**
3
3
  * @param {string} [token] - If your project is protected by a token, specify this token in this parameter.
4
4
  * @param {string} [langCode] - specify the default language to avoid specifying it in every request.
@@ -12,7 +12,7 @@ export default class BlocksApi extends AsyncModules implements IBlocks {
12
12
  /**
13
13
  * Get blocks by parameters.
14
14
  *
15
- * @param {BlockType} [type] - Available values : forCatalogProducts, forBasketPage, forErrorPage, forCatalogPages, forProductPreview, forProductPage, forSimilarProductBlock, forStatisticProductBlock, forProductBlock, forForm, forFormField, forNewsPage, forNewsBlock, forNewsPreview, forOneNewsPage, forUsualPage, forTextBlock, forSlider, forOrder, service
15
+ * @param {BlockType} [type] - Available values : product | error_page | catalog_page | product_preview | similar_products_block | product_block | form | common_page | common_block | order | none
16
16
  * @param {string} [langCode] - Language code. Default "en_US"
17
17
  * @param {number} [offset] - Parameter for pagination. Default 0
18
18
  * @param {number} [limit] - Parameter for pagination. Default 30
@@ -15,7 +15,7 @@ class BlocksApi extends asyncModules_1.default {
15
15
  /**
16
16
  * Get blocks by parameters.
17
17
  *
18
- * @param {BlockType} [type] - Available values : forCatalogProducts, forBasketPage, forErrorPage, forCatalogPages, forProductPreview, forProductPage, forSimilarProductBlock, forStatisticProductBlock, forProductBlock, forForm, forFormField, forNewsPage, forNewsBlock, forNewsPreview, forOneNewsPage, forUsualPage, forTextBlock, forSlider, forOrder, service
18
+ * @param {BlockType} [type] - Available values : product | error_page | catalog_page | product_preview | similar_products_block | product_block | form | common_page | common_block | order | none
19
19
  * @param {string} [langCode] - Language code. Default "en_US"
20
20
  * @param {number} [offset] - Parameter for pagination. Default 0
21
21
  * @param {number} [limit] - Parameter for pagination. Default 30
@@ -42,7 +42,7 @@ class BlocksApi extends asyncModules_1.default {
42
42
  delete block.customSettings;
43
43
  delete block.attributesSetIdentifier;
44
44
  delete block.productPageUrls;
45
- if (block.type === 'forSimilarProductBlock') {
45
+ if (block.type === 'similar_products_block') {
46
46
  try {
47
47
  await this.getSimilarProducts(block.identifier, langCode, offset, limit).then((result) => {
48
48
  block.similarProducts = result;
@@ -52,7 +52,7 @@ class BlocksApi extends asyncModules_1.default {
52
52
  block.similarProducts = [];
53
53
  }
54
54
  }
55
- else if (block.type === 'forProductBlock') {
55
+ else if (block.type === 'product_block') {
56
56
  try {
57
57
  await this.getProductsByBlockMarker(block.identifier, langCode, offset, limit).then((result) => {
58
58
  block.products = result;
@@ -93,7 +93,7 @@ class BlocksApi extends asyncModules_1.default {
93
93
  delete normalizeResponse.attributesSetIdentifier;
94
94
  delete normalizeResponse.productPageUrls;
95
95
  if (this.state.multipleResponse) {
96
- if (normalizeResponse.type === 'forSimilarProductBlock') {
96
+ if (normalizeResponse.type === 'similar_products_block') {
97
97
  try {
98
98
  await this.getSimilarProducts(normalizeResponse.identifier, langCode, offset, limit).then((result) => {
99
99
  normalizeResponse.similarProducts = result;
@@ -103,7 +103,7 @@ class BlocksApi extends asyncModules_1.default {
103
103
  normalizeResponse.similarProducts = [];
104
104
  }
105
105
  }
106
- else if (normalizeResponse.type === 'forProductBlock') {
106
+ else if (normalizeResponse.type === 'product_block') {
107
107
  try {
108
108
  await this.getProductsByBlockMarker(normalizeResponse.identifier, langCode, offset, limit).then((result) => {
109
109
  normalizeResponse.products = result;
@@ -71,5 +71,5 @@ interface ISearchBlock {
71
71
  /**
72
72
  * BlockType
73
73
  */
74
- type BlockType = 'forCatalogProducts' | 'forBasketPage' | 'forErrorPage' | 'forCatalogPages' | 'forProductPreview' | 'forProductPage' | 'forSimilarProductBlock' | 'forStatisticProductBlock' | 'forProductBlock' | 'forForm' | 'forFormField' | 'forNewsPage' | 'forNewsBlock' | 'forNewsPreview' | 'forOneNewsPage' | 'forUsualPage' | 'forTextBlock' | 'forSlider' | 'forOrder' | 'service' | 'none';
74
+ type BlockType = 'product' | 'error_page' | 'catalog_page' | 'product_preview' | 'similar_products_block' | 'product_block' | 'form' | 'common_page' | 'common_block' | 'order' | 'service' | 'none';
75
75
  export type { BlockType, IBlockEntity, IBlocks, IBlocksResponse, ISearchBlock };
@@ -26,7 +26,7 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
26
26
  *
27
27
  * @returns Uploads a file to an Amazon S3-compatible cloud file storage
28
28
  */
29
- upload(data: File | Blob, fileQuery?: IUploadingQuery): Promise<IUploadingReturns | IError>;
29
+ upload(file: File | Blob, fileQuery?: IUploadingQuery): Promise<IUploadingReturns | IError>;
30
30
  /**
31
31
  * Deletes a file from the cloud file storage.
32
32
  *
@@ -38,10 +38,10 @@ class FileUploadingApi extends asyncModules_1.default {
38
38
  *
39
39
  * @returns Uploads a file to an Amazon S3-compatible cloud file storage
40
40
  */
41
- async upload(data, fileQuery) {
41
+ async upload(file, fileQuery) {
42
42
  const query = { ...this._defaultQuery, ...fileQuery };
43
43
  const body = new FormData();
44
- body.append('files', data);
44
+ body.append('files', file);
45
45
  const result = await this._fetchPost('?' + this._queryParamsToString(query), body);
46
46
  return result;
47
47
  }
@@ -7,7 +7,7 @@ import type { IError } from '../base/utils';
7
7
  * @property {function} getFile - Get file by parameters.
8
8
  */
9
9
  interface IFileUploading {
10
- upload(data: File, fileQuery?: IUploadingQuery): Promise<IUploadingReturns | IError>;
10
+ upload(data: File | Blob, fileQuery?: IUploadingQuery): Promise<IUploadingReturns | IError>;
11
11
  delete(filename: string, fileQuery?: IUploadingQuery): Promise<any | IError>;
12
12
  getFile(id: number, type: string, entity: string, filename?: string): Promise<Blob | IError>;
13
13
  }
@@ -30,9 +30,6 @@ interface IUploadingQuery {
30
30
  type: string | null;
31
31
  entity: string | null;
32
32
  id: number | null;
33
- width: number | null;
34
- height: string | null;
35
- compress: boolean | null;
36
33
  [key: string]: string | number | boolean | null;
37
34
  }
38
35
  /**
@@ -41,9 +38,10 @@ interface IUploadingQuery {
41
38
  * @property {string} downloadLink - Link for downloading the file.
42
39
  * @property {number} size - Size of the file in bytes.
43
40
  */
44
- interface IUploadingReturns {
41
+ interface IUploadingReturn {
45
42
  filename: string;
46
43
  downloadLink: string;
47
44
  size: number;
48
45
  }
46
+ type IUploadingReturns = IUploadingReturn[];
49
47
  export type { IFileEntity, IFileUploading, IUploadingQuery, IUploadingReturns };
@@ -50,9 +50,10 @@ class FormsDataApi extends asyncModules_1.default {
50
50
  */
51
51
  async postFormsData(body, langCode = this.state.lang) {
52
52
  const formData = {};
53
+ // filter spam and button fields
53
54
  formData[langCode] = Array.isArray(body.formData)
54
- ? body.formData
55
- : [body.formData];
55
+ ? body.formData.filter((fd) => fd.type !== 'spam' && fd.type !== 'button')
56
+ : [body.formData].filter((fd) => fd.type !== 'spam' && fd.type !== 'button');
56
57
  body.formData = formData;
57
58
  const result = await this._fetchPost(``, body);
58
59
  return this._dataPostProcess(result);
@@ -1,3 +1,4 @@
1
+ import type { IUploadingQuery } from 'file-uploading/fileUploadingInterfaces';
1
2
  import type { IError } from '../base/utils';
2
3
  /**
3
4
  * Represents a interface object of Forms Api.
@@ -56,6 +57,7 @@ interface IFormsPost {
56
57
  formIdentifier: string;
57
58
  time?: Date | string;
58
59
  formData: Array<FormDataType>;
60
+ fileQuery?: IUploadingQuery;
59
61
  }
60
62
  /**
61
63
  * @property {string} marker - marker name
@@ -1,4 +1,5 @@
1
- import type { IError, Types } from '../base/utils';
1
+ import type { BlockType } from 'blocks/blocksInterfaces';
2
+ import type { IError } from '../base/utils';
2
3
  /**
3
4
  * Represents an interface object of General Type Api.
4
5
  *
@@ -16,6 +17,6 @@ interface IGeneralTypes {
16
17
  */
17
18
  interface IGeneralTypesEntity {
18
19
  id: number;
19
- type: Types;
20
+ type: BlockType;
20
21
  }
21
22
  export type { IGeneralTypes, IGeneralTypesEntity };
@@ -51,7 +51,7 @@ export default class IntegrationCollectionsApi extends AsyncModules implements I
51
51
  *
52
52
  * @param {string} [marker] - Collection marker.
53
53
  *
54
- * @returns Returns object MarkerValidDto with value true if text identifier (marker) exists or false if not
54
+ * @returns Returns object with value true if text identifier (marker) exists or false if not
55
55
  */
56
56
  validateICollectionMarker(marker: string): Promise<{
57
57
  valid: boolean;
@@ -102,7 +102,7 @@ export default class IntegrationCollectionsApi extends AsyncModules implements I
102
102
  *
103
103
  * @param {string} [marker] - text identifier of the collection
104
104
  * @param {number} [id] - row id
105
- * @param {any} [body] - Object UpdateCollectionRowDto for updating a record in the collection
105
+ * @param {any} [body] - Object for updating a record in the collection
106
106
  *
107
107
  * const body = {
108
108
  "formIdentifier": "collection-form",
@@ -119,7 +119,7 @@ export default class IntegrationCollectionsApi extends AsyncModules implements I
119
119
  *
120
120
  * @param {string} [langCode] - language code
121
121
  *
122
- * @returns Returns object UpdateCollectionRowDto
122
+ * @returns Returns object
123
123
  */
124
124
  updateICollectionRow(marker: string, id: number, body: {
125
125
  formIdentifier: string;
@@ -71,7 +71,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
71
71
  *
72
72
  * @param {string} [marker] - Collection marker.
73
73
  *
74
- * @returns Returns object MarkerValidDto with value true if text identifier (marker) exists or false if not
74
+ * @returns Returns object with value true if text identifier (marker) exists or false if not
75
75
  */
76
76
  async validateICollectionMarker(marker) {
77
77
  const result = await this._fetchGet(`/marker-validation/${marker}/`);
@@ -132,7 +132,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
132
132
  *
133
133
  * @param {string} [marker] - text identifier of the collection
134
134
  * @param {number} [id] - row id
135
- * @param {any} [body] - Object UpdateCollectionRowDto for updating a record in the collection
135
+ * @param {any} [body] - Object for updating a record in the collection
136
136
  *
137
137
  * const body = {
138
138
  "formIdentifier": "collection-form",
@@ -149,7 +149,7 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
149
149
  *
150
150
  * @param {string} [langCode] - language code
151
151
  *
152
- * @returns Returns object UpdateCollectionRowDto
152
+ * @returns Returns object
153
153
  */
154
154
  async updateICollectionRow(marker, id, body, langCode = this.state.lang) {
155
155
  const response = await this._fetchPut(`/marker/${marker}/rows/${id}/?` + `langCode=${langCode}`, body);
@@ -112,7 +112,7 @@ class PageApi extends asyncModules_1.default {
112
112
  }
113
113
  }
114
114
  const staffModule = new StaffModule(this.state);
115
- if (normalizeResponse.type === 'forSimilarProductBlock') {
115
+ if (normalizeResponse.type === 'similar_products_block') {
116
116
  try {
117
117
  await staffModule
118
118
  .getSimilarProducts(normalizeResponse.identifier, langCode)
@@ -124,7 +124,7 @@ class PageApi extends asyncModules_1.default {
124
124
  normalizeResponse.similarProducts = [];
125
125
  }
126
126
  }
127
- else if (normalizeResponse.type === 'forProductBlock') {
127
+ else if (normalizeResponse.type === 'product_block') {
128
128
  try {
129
129
  await staffModule
130
130
  .getProductsByBlockMarker(normalizeResponse.identifier, langCode)
@@ -35,19 +35,6 @@ export default class PaymentsApi extends AsyncModules implements IPaymentsApi {
35
35
  * @returns
36
36
  */
37
37
  getSessionByOrderId(id: number): Promise<IAccountsEntity | IError>;
38
- /**
39
- * Update payment session 🔐
40
- *
41
- * @param id - order identifier
42
- * @param body - Request body
43
- *
44
- * @param body.status
45
- * @param body.paymentUrl
46
- */
47
- updateSessionById(id: number, body: {
48
- status: string;
49
- paymentUrl: string;
50
- }): Promise<any | IError>;
51
38
  /**
52
39
  * Creation of payment session.
53
40
  * @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,19 +51,6 @@ class PaymentsApi extends asyncModules_1.default {
51
51
  const result = await this._fetchGet(`/sessions/order/${id}`);
52
52
  return result;
53
53
  }
54
- /**
55
- * Update payment session 🔐
56
- *
57
- * @param id - order identifier
58
- * @param body - Request body
59
- *
60
- * @param body.status
61
- * @param body.paymentUrl
62
- */
63
- async updateSessionById(id, body) {
64
- const result = await this._fetchPut(`/sessions/${id}`, body);
65
- return this._normalizeData(result);
66
- }
67
54
  /**
68
55
  * Creation of payment session.
69
56
  * @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.
@@ -1,5 +1,6 @@
1
1
  import AsyncModules from '../base/asyncModules';
2
2
  import type StateModule from '../base/stateModule';
3
+ import type { IError } from '../base/utils';
3
4
  import type { ISystem } from './systemInterfaces';
4
5
  /**
5
6
  * Controllers for working with system - system
@@ -8,6 +9,27 @@ export default class SystemApi extends AsyncModules implements ISystem {
8
9
  protected state: StateModule;
9
10
  protected _url: string;
10
11
  constructor(state: StateModule);
12
+ /**
13
+ * test404
14
+ * @returns
15
+ */
11
16
  test404(): Promise<any>;
17
+ /**
18
+ * test500
19
+ * @returns
20
+ */
12
21
  test500(): Promise<any>;
22
+ /**
23
+ * validateCapcha
24
+ * @param event
25
+ * @param event.token -
26
+ * @param event.expectedAction -
27
+ * @param event.siteKey -
28
+ * @returns
29
+ */
30
+ validateCapcha(event: {
31
+ token: string;
32
+ expectedAction: string;
33
+ siteKey: string;
34
+ }): Promise<any | IError>;
13
35
  }
@@ -13,13 +13,36 @@ class SystemApi extends asyncModules_1.default {
13
13
  super(state);
14
14
  this._url = state.url + '/api/content/system';
15
15
  }
16
+ /**
17
+ * test404
18
+ * @returns
19
+ */
16
20
  async test404() {
17
21
  const result = await this._fetchGet('/test404');
18
22
  return result;
19
23
  }
24
+ /**
25
+ * test500
26
+ * @returns
27
+ */
20
28
  async test500() {
21
29
  const result = await this._fetchGet('/test500');
22
30
  return result;
23
31
  }
32
+ /**
33
+ * validateCapcha
34
+ * @param event
35
+ * @param event.token -
36
+ * @param event.expectedAction -
37
+ * @param event.siteKey -
38
+ * @returns
39
+ */
40
+ async validateCapcha(event) {
41
+ const data = {
42
+ event,
43
+ };
44
+ const result = await this._fetchPost('/captcha/validate', data);
45
+ return result;
46
+ }
24
47
  }
25
48
  exports.default = SystemApi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneentry",
3
- "version": "1.0.119",
3
+ "version": "1.0.120",
4
4
  "description": "OneEntry NPM package",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,7 +8,7 @@
8
8
  "/dist"
9
9
  ],
10
10
  "scripts": {
11
- "productionBuild": "run-s lint testAll build readme",
11
+ "productionBuild": "run-s lint testAll build",
12
12
  "testAll": "run-s admins attributesets authProvider blocks fileuploading forms formsdata generaltypes integrationcollections locales menus orders pages payments payments productstatuses products templates templatespreview users",
13
13
  "admins": "npx jest src/admins/tests/admins.spec.ts",
14
14
  "attributesets": "npx jest src/attribute-sets/tests/attributesets.spec.ts",
@@ -30,8 +30,7 @@
30
30
  "templatespreview": "npx jest src/templates-preview/tests/templatespreview.spec.ts",
31
31
  "users": "npx jest src/users/tests/users.spec.ts",
32
32
  "lint": "npx eslint",
33
- "build": "npx tsc",
34
- "readme": "node ./src/readme.js"
33
+ "build": "npx tsc"
35
34
  },
36
35
  "bin": {
37
36
  "oneentry": "./configure.js"