@code.store/arcxp-sdk-ts 5.1.2 → 5.1.6

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.
@@ -7,6 +7,7 @@ export type ArcAbstractAPIOptions = {
7
7
  };
8
8
  apiPath: string;
9
9
  maxRPS?: number;
10
+ maxRetries?: number;
10
11
  };
11
12
  export type ArcAPIOptions = Omit<ArcAbstractAPIOptions, 'apiPath'>;
12
13
  export declare abstract class ArcAbstractAPI {
@@ -12,7 +12,7 @@ import { ArcProtoCenter } from './photo-center/index.js';
12
12
  import { ArcRedirect } from './redirect/index.js';
13
13
  import { ArcRetailEvents } from './retail-events/index.js';
14
14
  import { ArcDeveloperRetail } from './developer-retail/index.js';
15
- import { ArcSales } from './sales/index.js';
15
+ import { ArcSales, ArcSalesV2 } from './sales/index.js';
16
16
  import { ArcSigningService } from './signing-service/index.js';
17
17
  import { ArcSite } from './site/index.js';
18
18
  import { ArcTags } from './tags/index.js';
@@ -25,6 +25,7 @@ export declare const ArcAPI: (options: ArcAPIOptions) => {
25
25
  Redirect: ArcRedirect;
26
26
  MigrationCenter: ArcMigrationCenter;
27
27
  Sales: ArcSales;
28
+ SalesV2: ArcSalesV2;
28
29
  Site: ArcSite;
29
30
  Websked: ArcWebsked;
30
31
  Content: ArcContent;
@@ -1,6 +1,12 @@
1
1
  import { type ArcAPIOptions, ArcAbstractAPI } from '../abstract-api.js';
2
- import type { MigrateBatchSubscriptionsParams, MigrateBatchSubscriptionsPayload, MigrateBatchSubscriptionsResponse } from './types.js';
2
+ import type { CreateEnterpriseGroupParams, CreateEnterpriseGroupPayload, CreateEnterpriseGroupResponse, CreateNonceResponse, MigrateBatchSubscriptionsParams, MigrateBatchSubscriptionsPayload, MigrateBatchSubscriptionsResponse } from './types.js';
3
3
  export declare class ArcSales extends ArcAbstractAPI {
4
4
  constructor(options: ArcAPIOptions);
5
5
  migrate(params: MigrateBatchSubscriptionsParams, payload: MigrateBatchSubscriptionsPayload): Promise<MigrateBatchSubscriptionsResponse>;
6
6
  }
7
+ export declare class ArcSalesV2 extends ArcAbstractAPI {
8
+ constructor(options: ArcAPIOptions);
9
+ getEnterpriseGroups(params: CreateEnterpriseGroupParams): Promise<CreateEnterpriseGroupResponse>;
10
+ createEnterpriseGroup(params: CreateEnterpriseGroupParams, payload: CreateEnterpriseGroupPayload): Promise<CreateEnterpriseGroupResponse>;
11
+ createNonce(website: string, enterpriseGroupId: number): Promise<CreateNonceResponse>;
12
+ }
@@ -1,5 +1,5 @@
1
- import type { UserAttribute } from '../identity/types';
2
1
  import type { Website } from '../../types/ans-types';
2
+ import type { UserAttribute } from '../identity/types';
3
3
  export type MigrateBatchSubscriptionsPayload = {
4
4
  subscriptions: (PaidSubscription | FreeSubscription | SharedSubscription | LinkedSubscription)[];
5
5
  payments: PaymentInfo[];
@@ -83,4 +83,21 @@ export type Refund = {
83
83
  tax: number;
84
84
  providerReference?: string;
85
85
  };
86
+ export type CreateEnterpriseGroupParams = {
87
+ site: string;
88
+ };
89
+ export type CreateEnterpriseGroupPayload = {
90
+ name: string;
91
+ sku: string;
92
+ };
93
+ export type CreateEnterpriseGroupResponse = {
94
+ name: string;
95
+ sku: string;
96
+ nonceExpirationInDays: number;
97
+ id: number;
98
+ };
99
+ export type CreateNonceResponse = {
100
+ nonce: string;
101
+ expires: string;
102
+ };
86
103
  export {};
package/dist/index.cjs CHANGED
@@ -6,7 +6,6 @@ var axios = require('axios');
6
6
  var rateLimit = require('axios-rate-limit');
7
7
  var axiosRetry = require('axios-retry');
8
8
  var ws = require('ws');
9
- var FormData = require('form-data');
10
9
  var encode = require('base32-encode');
11
10
  var uuid = require('uuid');
12
11
  var assert = require('node:assert');
@@ -91,7 +90,7 @@ class ArcAbstractAPI {
91
90
  // apply retry
92
91
  const retry = typeof axiosRetry === 'function' ? axiosRetry : axiosRetry.default;
93
92
  retry(this.client, {
94
- retries: 5,
93
+ retries: options.maxRetries || 10,
95
94
  retryDelay: axiosRetry.exponentialDelay,
96
95
  retryCondition: (err) => this.retryCondition(err),
97
96
  });
@@ -711,6 +710,7 @@ class ArcSales extends ArcAbstractAPI {
711
710
  super({ ...options, apiPath: 'sales/api/v1' });
712
711
  }
713
712
  async migrate(params, payload) {
713
+ const FormData = await platform.form_data();
714
714
  const form = new FormData();
715
715
  form.append('file', JSON.stringify(payload), { filename: 'subs.json', contentType: 'application/json' });
716
716
  const { data } = await this.client.post('/migrate', form, {
@@ -722,6 +722,33 @@ class ArcSales extends ArcAbstractAPI {
722
722
  return data;
723
723
  }
724
724
  }
725
+ class ArcSalesV2 extends ArcAbstractAPI {
726
+ constructor(options) {
727
+ super({ ...options, apiPath: 'sales/api/v2' });
728
+ }
729
+ async getEnterpriseGroups(params) {
730
+ const { data } = await this.client.get('/subscriptions/enterprise', {
731
+ params: {
732
+ 'arc-site': params.site,
733
+ },
734
+ });
735
+ return data;
736
+ }
737
+ async createEnterpriseGroup(params, payload) {
738
+ const { data } = await this.client.post('/subscriptions/enterprise', payload, {
739
+ params: {
740
+ 'arc-site': params.site,
741
+ },
742
+ });
743
+ return data;
744
+ }
745
+ async createNonce(website, enterpriseGroupId) {
746
+ const { data } = await this.client.get(`/subscriptions/enterprise/${enterpriseGroupId}`, {
747
+ params: { 'arc-site': website },
748
+ });
749
+ return data;
750
+ }
751
+ }
725
752
 
726
753
  class ArcSigningService extends ArcAbstractAPI {
727
754
  constructor(options) {
@@ -854,6 +881,7 @@ const ArcAPI = (options) => {
854
881
  Redirect: new ArcRedirect(options),
855
882
  MigrationCenter: new ArcMigrationCenter(options),
856
883
  Sales: new ArcSales(options),
884
+ SalesV2: new ArcSalesV2(options),
857
885
  Site: new ArcSite(options),
858
886
  Websked: new ArcWebsked(options),
859
887
  Content: new ArcContent(options),