@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/api/abstract-api.d.ts +1 -0
- package/dist/api/sales/index.d.ts +4 -2
- package/dist/api/sales/types.d.ts +8 -1
- package/dist/index.cjs +28 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -9
- package/dist/index.js.map +1 -1
- package/dist/lib/platform/index.d.ts +1 -1
- package/dist/lib/platform/node.d.ts +6 -3
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type ArcAPIOptions, ArcAbstractAPI } from '../abstract-api.js';
|
|
2
|
-
import type { CreateEnterpriseGroupPayload, CreateEnterpriseGroupResponse, 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
7
|
export declare class ArcSalesV2 extends ArcAbstractAPI {
|
|
8
8
|
constructor(options: ArcAPIOptions);
|
|
9
|
-
|
|
9
|
+
getEnterpriseGroups(params: CreateEnterpriseGroupParams): Promise<CreateEnterpriseGroupResponse>;
|
|
10
|
+
createEnterpriseGroup(params: CreateEnterpriseGroupParams, payload: CreateEnterpriseGroupPayload): Promise<CreateEnterpriseGroupResponse>;
|
|
11
|
+
createNonce(website: string, enterpriseGroupId: number): Promise<CreateNonceResponse>;
|
|
10
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,6 +83,9 @@ export type Refund = {
|
|
|
83
83
|
tax: number;
|
|
84
84
|
providerReference?: string;
|
|
85
85
|
};
|
|
86
|
+
export type CreateEnterpriseGroupParams = {
|
|
87
|
+
site: string;
|
|
88
|
+
};
|
|
86
89
|
export type CreateEnterpriseGroupPayload = {
|
|
87
90
|
name: string;
|
|
88
91
|
sku: string;
|
|
@@ -93,4 +96,8 @@ export type CreateEnterpriseGroupResponse = {
|
|
|
93
96
|
nonceExpirationInDays: number;
|
|
94
97
|
id: number;
|
|
95
98
|
};
|
|
99
|
+
export type CreateNonceResponse = {
|
|
100
|
+
nonce: string;
|
|
101
|
+
expires: string;
|
|
102
|
+
};
|
|
96
103
|
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -5,8 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var axios = require('axios');
|
|
6
6
|
var rateLimit = require('axios-rate-limit');
|
|
7
7
|
var axiosRetry = require('axios-retry');
|
|
8
|
-
var
|
|
8
|
+
var fs = require('node:fs');
|
|
9
|
+
var path = require('node:path');
|
|
9
10
|
var FormData = require('form-data');
|
|
11
|
+
var ws = require('ws');
|
|
10
12
|
var encode = require('base32-encode');
|
|
11
13
|
var uuid = require('uuid');
|
|
12
14
|
var assert = require('node:assert');
|
|
@@ -91,7 +93,7 @@ class ArcAbstractAPI {
|
|
|
91
93
|
// apply retry
|
|
92
94
|
const retry = typeof axiosRetry === 'function' ? axiosRetry : axiosRetry.default;
|
|
93
95
|
retry(this.client, {
|
|
94
|
-
retries:
|
|
96
|
+
retries: options.maxRetries || 10,
|
|
95
97
|
retryDelay: axiosRetry.exponentialDelay,
|
|
96
98
|
retryCondition: (err) => this.retryCondition(err),
|
|
97
99
|
});
|
|
@@ -296,12 +298,10 @@ class ArcIdentity extends ArcAbstractAPI {
|
|
|
296
298
|
}
|
|
297
299
|
}
|
|
298
300
|
|
|
299
|
-
const importNodeModule = async (moduleId) => await import(moduleId);
|
|
300
301
|
const modules = {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
form_data: () => importNodeModule('form-data'),
|
|
302
|
+
fs: () => Promise.resolve(fs),
|
|
303
|
+
path: () => Promise.resolve(path),
|
|
304
|
+
form_data: () => Promise.resolve(FormData),
|
|
305
305
|
};
|
|
306
306
|
|
|
307
307
|
var platform = {
|
|
@@ -711,6 +711,7 @@ class ArcSales extends ArcAbstractAPI {
|
|
|
711
711
|
super({ ...options, apiPath: 'sales/api/v1' });
|
|
712
712
|
}
|
|
713
713
|
async migrate(params, payload) {
|
|
714
|
+
const FormData = await platform.form_data();
|
|
714
715
|
const form = new FormData();
|
|
715
716
|
form.append('file', JSON.stringify(payload), { filename: 'subs.json', contentType: 'application/json' });
|
|
716
717
|
const { data } = await this.client.post('/migrate', form, {
|
|
@@ -726,8 +727,26 @@ class ArcSalesV2 extends ArcAbstractAPI {
|
|
|
726
727
|
constructor(options) {
|
|
727
728
|
super({ ...options, apiPath: 'sales/api/v2' });
|
|
728
729
|
}
|
|
729
|
-
async
|
|
730
|
-
const { data } = await this.client.
|
|
730
|
+
async getEnterpriseGroups(params) {
|
|
731
|
+
const { data } = await this.client.get('/subscriptions/enterprise', {
|
|
732
|
+
params: {
|
|
733
|
+
'arc-site': params.site,
|
|
734
|
+
},
|
|
735
|
+
});
|
|
736
|
+
return data;
|
|
737
|
+
}
|
|
738
|
+
async createEnterpriseGroup(params, payload) {
|
|
739
|
+
const { data } = await this.client.post('/subscriptions/enterprise', payload, {
|
|
740
|
+
params: {
|
|
741
|
+
'arc-site': params.site,
|
|
742
|
+
},
|
|
743
|
+
});
|
|
744
|
+
return data;
|
|
745
|
+
}
|
|
746
|
+
async createNonce(website, enterpriseGroupId) {
|
|
747
|
+
const { data } = await this.client.get(`/subscriptions/enterprise/${enterpriseGroupId}`, {
|
|
748
|
+
params: { 'arc-site': website },
|
|
749
|
+
});
|
|
731
750
|
return data;
|
|
732
751
|
}
|
|
733
752
|
}
|