@code.store/arcxp-sdk-ts 5.1.3 → 5.1.7

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/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import axios from 'axios';
2
2
  import * as rateLimit from 'axios-rate-limit';
3
3
  import axiosRetry from 'axios-retry';
4
- import * as ws from 'ws';
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
5
6
  import FormData from 'form-data';
7
+ import * as ws from 'ws';
6
8
  import encode from 'base32-encode';
7
9
  import { v5 } from 'uuid';
8
10
  import assert from 'node:assert';
@@ -67,7 +69,7 @@ class ArcAbstractAPI {
67
69
  // apply retry
68
70
  const retry = typeof axiosRetry === 'function' ? axiosRetry : axiosRetry.default;
69
71
  retry(this.client, {
70
- retries: 5,
72
+ retries: options.maxRetries || 10,
71
73
  retryDelay: axiosRetry.exponentialDelay,
72
74
  retryCondition: (err) => this.retryCondition(err),
73
75
  });
@@ -272,12 +274,10 @@ class ArcIdentity extends ArcAbstractAPI {
272
274
  }
273
275
  }
274
276
 
275
- const importNodeModule = async (moduleId) => await import(moduleId);
276
277
  const modules = {
277
- // make it like that so static analyzer of webpack won't bundle it
278
- fs: () => importNodeModule('node:fs'),
279
- path: () => importNodeModule('node:path'),
280
- form_data: () => importNodeModule('form-data'),
278
+ fs: () => Promise.resolve(fs),
279
+ path: () => Promise.resolve(path),
280
+ form_data: () => Promise.resolve(FormData),
281
281
  };
282
282
 
283
283
  var platform = {
@@ -687,6 +687,7 @@ class ArcSales extends ArcAbstractAPI {
687
687
  super({ ...options, apiPath: 'sales/api/v1' });
688
688
  }
689
689
  async migrate(params, payload) {
690
+ const FormData = await platform.form_data();
690
691
  const form = new FormData();
691
692
  form.append('file', JSON.stringify(payload), { filename: 'subs.json', contentType: 'application/json' });
692
693
  const { data } = await this.client.post('/migrate', form, {
@@ -702,8 +703,26 @@ class ArcSalesV2 extends ArcAbstractAPI {
702
703
  constructor(options) {
703
704
  super({ ...options, apiPath: 'sales/api/v2' });
704
705
  }
705
- async createEnterpriseGroup(payload) {
706
- const { data } = await this.client.post('/subscriptions/enterprise', payload);
706
+ async getEnterpriseGroups(params) {
707
+ const { data } = await this.client.get('/subscriptions/enterprise', {
708
+ params: {
709
+ 'arc-site': params.site,
710
+ },
711
+ });
712
+ return data;
713
+ }
714
+ async createEnterpriseGroup(params, payload) {
715
+ const { data } = await this.client.post('/subscriptions/enterprise', payload, {
716
+ params: {
717
+ 'arc-site': params.site,
718
+ },
719
+ });
720
+ return data;
721
+ }
722
+ async createNonce(website, enterpriseGroupId) {
723
+ const { data } = await this.client.get(`/subscriptions/enterprise/${enterpriseGroupId}`, {
724
+ params: { 'arc-site': website },
725
+ });
707
726
  return data;
708
727
  }
709
728
  }