@vulog/aima-mobility-plans 1.2.30 → 1.2.31
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.cjs +55 -0
- package/dist/index.d.cts +70 -0
- package/dist/index.d.mts +58 -55
- package/dist/index.mjs +44 -70
- package/package.json +20 -7
- package/{tsup.config.ts → tsdown.config.ts} +1 -1
- package/dist/index.d.ts +0 -67
- package/dist/index.js +0 -107
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
//#region src/getPlans.ts
|
|
4
|
+
const schema$3 = zod.z.object({ status: zod.z.enum(["ACTIVE", "INACTIVE"]) });
|
|
5
|
+
const getPlans = async (client, status) => {
|
|
6
|
+
const result = schema$3.safeParse({ status });
|
|
7
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
8
|
+
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/plans?size=1000&status=${status}`).then(({ data }) => data);
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/getUserPlans.ts
|
|
12
|
+
const schema$2 = zod.z.object({ entityId: zod.z.string().uuid() });
|
|
13
|
+
const getUserPlans = async (client, entityId) => {
|
|
14
|
+
const result = schema$2.safeParse({ entityId });
|
|
15
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
16
|
+
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/subscriptions?entityId=${entityId}&status=ACTIVE,PAYMENT_PENDING,ACTIVATION_PENDING`).then(({ data }) => data);
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/unsubscribe.ts
|
|
20
|
+
const schema$1 = zod.z.object({
|
|
21
|
+
subscriptionId: zod.z.string().uuid(),
|
|
22
|
+
profileId: zod.z.string().uuid()
|
|
23
|
+
});
|
|
24
|
+
const unsubscribe = async (client, subscriptionId, profileId) => {
|
|
25
|
+
const result = schema$1.safeParse({
|
|
26
|
+
subscriptionId,
|
|
27
|
+
profileId
|
|
28
|
+
});
|
|
29
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
30
|
+
return client.post(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/subscriptions/${subscriptionId}/unsubscribe`, { profileId }).then(({ data }) => data).catch((err) => {
|
|
31
|
+
throw new Error("Unsubscribe failed", { cause: err });
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/subscribe.ts
|
|
36
|
+
const schema = zod.z.object({
|
|
37
|
+
planId: zod.z.string().uuid(),
|
|
38
|
+
profileId: zod.z.string().uuid()
|
|
39
|
+
});
|
|
40
|
+
const subscribe = async (client, planId, profileId) => {
|
|
41
|
+
const result = schema.safeParse({
|
|
42
|
+
planId,
|
|
43
|
+
profileId
|
|
44
|
+
});
|
|
45
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
46
|
+
return client.post(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/subscriptions`, {
|
|
47
|
+
planId,
|
|
48
|
+
profileId
|
|
49
|
+
}).then(({ data }) => data);
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
exports.getPlans = getPlans;
|
|
53
|
+
exports.getUserPlans = getUserPlans;
|
|
54
|
+
exports.subscribe = subscribe;
|
|
55
|
+
exports.unsubscribe = unsubscribe;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Client } from "@vulog/aima-client";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
type Status = 'ACTIVE' | 'INACTIVE';
|
|
5
|
+
type Plan = {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
fleetId: string;
|
|
9
|
+
period: 'WEEK' | 'MONTH' | 'YEAR';
|
|
10
|
+
productId: string;
|
|
11
|
+
systemCreditIncluded: number;
|
|
12
|
+
price: number;
|
|
13
|
+
cities: {
|
|
14
|
+
cityId: string;
|
|
15
|
+
serviceIds: string[];
|
|
16
|
+
}[];
|
|
17
|
+
status: Status;
|
|
18
|
+
periodicTimeWallet: {
|
|
19
|
+
freeMinutes: number;
|
|
20
|
+
freeMinutesFrequency: 'DAILY' | 'WEEKLY' | 'MONTHLY';
|
|
21
|
+
};
|
|
22
|
+
services: string[];
|
|
23
|
+
};
|
|
24
|
+
type Subscription = [{
|
|
25
|
+
id: string;
|
|
26
|
+
profileId: string;
|
|
27
|
+
plan: Plan;
|
|
28
|
+
fleetId: string;
|
|
29
|
+
expiryDate: Date | null;
|
|
30
|
+
unsubscribeDate: Date | null;
|
|
31
|
+
activationDate: Date | null;
|
|
32
|
+
invoiceIds: string[];
|
|
33
|
+
status: 'ACTIVE' | 'PAYMENT_PENDING' | 'ACTIVATION_PENDING';
|
|
34
|
+
}];
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/getPlans.d.ts
|
|
37
|
+
declare const getPlans: (client: Client, status: Status) => Promise<Plan[]>;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/getUserPlans.d.ts
|
|
40
|
+
declare const getUserPlans: (client: Client, entityId: string) => Promise<Subscription[]>;
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/unsubscribe.d.ts
|
|
43
|
+
type UnsubscribeResponse = {
|
|
44
|
+
id: string;
|
|
45
|
+
profileId: string;
|
|
46
|
+
plan: Plan;
|
|
47
|
+
fleetId: string;
|
|
48
|
+
expiryDate: string;
|
|
49
|
+
unsubscribeDate: string;
|
|
50
|
+
activationDate: string;
|
|
51
|
+
invoiceIds: string[];
|
|
52
|
+
status: 'ACTIVE' | 'PAYMENT_PENDING' | 'ACTIVATION_PENDING';
|
|
53
|
+
};
|
|
54
|
+
declare const unsubscribe: (client: Client, subscriptionId: string, profileId: string) => Promise<UnsubscribeResponse>;
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/subscribe.d.ts
|
|
57
|
+
type SubscribeResponse = {
|
|
58
|
+
id: string;
|
|
59
|
+
profileId: string;
|
|
60
|
+
plan: Plan;
|
|
61
|
+
fleetId: string;
|
|
62
|
+
expiryDate: string | null;
|
|
63
|
+
unsubscribeDate: string | null;
|
|
64
|
+
activationDate: string | null;
|
|
65
|
+
invoiceIds: string[];
|
|
66
|
+
status: 'ACTIVE' | 'PAYMENT_PENDING' | 'ACTIVATION_PENDING';
|
|
67
|
+
};
|
|
68
|
+
declare const subscribe: (client: Client, planId: string, profileId: string) => Promise<SubscribeResponse>;
|
|
69
|
+
//#endregion
|
|
70
|
+
export { type Plan, type Status, type Subscription, getPlans, getUserPlans, subscribe, unsubscribe };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,67 +1,70 @@
|
|
|
1
|
-
import { Client } from
|
|
1
|
+
import { Client } from "@vulog/aima-client";
|
|
2
2
|
|
|
3
|
+
//#region src/types.d.ts
|
|
3
4
|
type Status = 'ACTIVE' | 'INACTIVE';
|
|
4
5
|
type Plan = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
fleetId: string;
|
|
9
|
+
period: 'WEEK' | 'MONTH' | 'YEAR';
|
|
10
|
+
productId: string;
|
|
11
|
+
systemCreditIncluded: number;
|
|
12
|
+
price: number;
|
|
13
|
+
cities: {
|
|
14
|
+
cityId: string;
|
|
15
|
+
serviceIds: string[];
|
|
16
|
+
}[];
|
|
17
|
+
status: Status;
|
|
18
|
+
periodicTimeWallet: {
|
|
19
|
+
freeMinutes: number;
|
|
20
|
+
freeMinutesFrequency: 'DAILY' | 'WEEKLY' | 'MONTHLY';
|
|
21
|
+
};
|
|
22
|
+
services: string[];
|
|
22
23
|
};
|
|
23
|
-
type Subscription = [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
type Subscription = [{
|
|
25
|
+
id: string;
|
|
26
|
+
profileId: string;
|
|
27
|
+
plan: Plan;
|
|
28
|
+
fleetId: string;
|
|
29
|
+
expiryDate: Date | null;
|
|
30
|
+
unsubscribeDate: Date | null;
|
|
31
|
+
activationDate: Date | null;
|
|
32
|
+
invoiceIds: string[];
|
|
33
|
+
status: 'ACTIVE' | 'PAYMENT_PENDING' | 'ACTIVATION_PENDING';
|
|
34
|
+
}];
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/getPlans.d.ts
|
|
37
37
|
declare const getPlans: (client: Client, status: Status) => Promise<Plan[]>;
|
|
38
|
-
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/getUserPlans.d.ts
|
|
39
40
|
declare const getUserPlans: (client: Client, entityId: string) => Promise<Subscription[]>;
|
|
40
|
-
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/unsubscribe.d.ts
|
|
41
43
|
type UnsubscribeResponse = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
id: string;
|
|
45
|
+
profileId: string;
|
|
46
|
+
plan: Plan;
|
|
47
|
+
fleetId: string;
|
|
48
|
+
expiryDate: string;
|
|
49
|
+
unsubscribeDate: string;
|
|
50
|
+
activationDate: string;
|
|
51
|
+
invoiceIds: string[];
|
|
52
|
+
status: 'ACTIVE' | 'PAYMENT_PENDING' | 'ACTIVATION_PENDING';
|
|
51
53
|
};
|
|
52
54
|
declare const unsubscribe: (client: Client, subscriptionId: string, profileId: string) => Promise<UnsubscribeResponse>;
|
|
53
|
-
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/subscribe.d.ts
|
|
54
57
|
type SubscribeResponse = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
id: string;
|
|
59
|
+
profileId: string;
|
|
60
|
+
plan: Plan;
|
|
61
|
+
fleetId: string;
|
|
62
|
+
expiryDate: string | null;
|
|
63
|
+
unsubscribeDate: string | null;
|
|
64
|
+
activationDate: string | null;
|
|
65
|
+
invoiceIds: string[];
|
|
66
|
+
status: 'ACTIVE' | 'PAYMENT_PENDING' | 'ACTIVATION_PENDING';
|
|
64
67
|
};
|
|
65
68
|
declare const subscribe: (client: Client, planId: string, profileId: string) => Promise<SubscribeResponse>;
|
|
66
|
-
|
|
67
|
-
export { type Plan, type Status, type Subscription, getPlans, getUserPlans, subscribe, unsubscribe };
|
|
69
|
+
//#endregion
|
|
70
|
+
export { type Plan, type Status, type Subscription, getPlans, getUserPlans, subscribe, unsubscribe };
|
package/dist/index.mjs
CHANGED
|
@@ -1,77 +1,51 @@
|
|
|
1
|
-
// src/getPlans.ts
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
throw new TypeError("Invalid args", {
|
|
10
|
-
cause: result.error.issues
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/plans?size=1000&status=${status}`).then(({ data }) => data);
|
|
2
|
+
//#region src/getPlans.ts
|
|
3
|
+
const schema$3 = z.object({ status: z.enum(["ACTIVE", "INACTIVE"]) });
|
|
4
|
+
const getPlans = async (client, status) => {
|
|
5
|
+
const result = schema$3.safeParse({ status });
|
|
6
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
7
|
+
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/plans?size=1000&status=${status}`).then(({ data }) => data);
|
|
14
8
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const result = schema2.safeParse({ entityId });
|
|
23
|
-
if (!result.success) {
|
|
24
|
-
throw new TypeError("Invalid args", {
|
|
25
|
-
cause: result.error.issues
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/subscriptions?entityId=${entityId}&status=ACTIVE,PAYMENT_PENDING,ACTIVATION_PENDING`).then(({ data }) => data);
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/getUserPlans.ts
|
|
11
|
+
const schema$2 = z.object({ entityId: z.string().uuid() });
|
|
12
|
+
const getUserPlans = async (client, entityId) => {
|
|
13
|
+
const result = schema$2.safeParse({ entityId });
|
|
14
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
15
|
+
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/subscriptions?entityId=${entityId}&status=ACTIVE,PAYMENT_PENDING,ACTIVATION_PENDING`).then(({ data }) => data);
|
|
29
16
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
profileId: z3.string().uuid()
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/unsubscribe.ts
|
|
19
|
+
const schema$1 = z.object({
|
|
20
|
+
subscriptionId: z.string().uuid(),
|
|
21
|
+
profileId: z.string().uuid()
|
|
36
22
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
profileId
|
|
48
|
-
}
|
|
49
|
-
).then(({ data }) => data).catch((err) => {
|
|
50
|
-
throw new Error("Unsubscribe failed", { cause: err });
|
|
51
|
-
});
|
|
23
|
+
const unsubscribe = async (client, subscriptionId, profileId) => {
|
|
24
|
+
const result = schema$1.safeParse({
|
|
25
|
+
subscriptionId,
|
|
26
|
+
profileId
|
|
27
|
+
});
|
|
28
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
29
|
+
return client.post(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/subscriptions/${subscriptionId}/unsubscribe`, { profileId }).then(({ data }) => data).catch((err) => {
|
|
30
|
+
throw new Error("Unsubscribe failed", { cause: err });
|
|
31
|
+
});
|
|
52
32
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
profileId: z4.string().uuid()
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/subscribe.ts
|
|
35
|
+
const schema = z.object({
|
|
36
|
+
planId: z.string().uuid(),
|
|
37
|
+
profileId: z.string().uuid()
|
|
59
38
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}).then(({ data }) => data);
|
|
71
|
-
};
|
|
72
|
-
export {
|
|
73
|
-
getPlans,
|
|
74
|
-
getUserPlans,
|
|
75
|
-
subscribe,
|
|
76
|
-
unsubscribe
|
|
39
|
+
const subscribe = async (client, planId, profileId) => {
|
|
40
|
+
const result = schema.safeParse({
|
|
41
|
+
planId,
|
|
42
|
+
profileId
|
|
43
|
+
});
|
|
44
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
45
|
+
return client.post(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/subscriptions`, {
|
|
46
|
+
planId,
|
|
47
|
+
profileId
|
|
48
|
+
}).then(({ data }) => data);
|
|
77
49
|
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { getPlans, getUserPlans, subscribe, unsubscribe };
|
package/package.json
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulog/aima-mobility-plans",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.2.31",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
5
6
|
"module": "dist/index.mjs",
|
|
6
|
-
"types": "dist/index.d.
|
|
7
|
+
"types": "dist/index.d.cts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.cts",
|
|
16
|
+
"default": "./dist/index.cjs"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
7
20
|
"scripts": {
|
|
8
|
-
"build": "
|
|
9
|
-
"dev": "
|
|
21
|
+
"build": "tsdown",
|
|
22
|
+
"dev": "tsdown --watch",
|
|
10
23
|
"test": "vitest run",
|
|
11
24
|
"test:watch": "vitest",
|
|
12
25
|
"lint": "eslint src/**/* --ext .ts"
|
|
@@ -20,8 +33,8 @@
|
|
|
20
33
|
"author": "Vulog",
|
|
21
34
|
"license": "MIT",
|
|
22
35
|
"dependencies": {
|
|
23
|
-
"@vulog/aima-client": "1.2.
|
|
24
|
-
"@vulog/aima-core": "1.2.
|
|
36
|
+
"@vulog/aima-client": "1.2.31",
|
|
37
|
+
"@vulog/aima-core": "1.2.31"
|
|
25
38
|
},
|
|
26
39
|
"peerDependencies": {
|
|
27
40
|
"zod": "^3.25.76"
|
package/dist/index.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Client } from '@vulog/aima-client';
|
|
2
|
-
|
|
3
|
-
type Status = 'ACTIVE' | 'INACTIVE';
|
|
4
|
-
type Plan = {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
fleetId: string;
|
|
8
|
-
period: 'WEEK' | 'MONTH' | 'YEAR';
|
|
9
|
-
productId: string;
|
|
10
|
-
systemCreditIncluded: number;
|
|
11
|
-
price: number;
|
|
12
|
-
cities: {
|
|
13
|
-
cityId: string;
|
|
14
|
-
serviceIds: string[];
|
|
15
|
-
}[];
|
|
16
|
-
status: Status;
|
|
17
|
-
periodicTimeWallet: {
|
|
18
|
-
freeMinutes: number;
|
|
19
|
-
freeMinutesFrequency: 'DAILY' | 'WEEKLY' | 'MONTHLY';
|
|
20
|
-
};
|
|
21
|
-
services: string[];
|
|
22
|
-
};
|
|
23
|
-
type Subscription = [
|
|
24
|
-
{
|
|
25
|
-
id: string;
|
|
26
|
-
profileId: string;
|
|
27
|
-
plan: Plan;
|
|
28
|
-
fleetId: string;
|
|
29
|
-
expiryDate: Date | null;
|
|
30
|
-
unsubscribeDate: Date | null;
|
|
31
|
-
activationDate: Date | null;
|
|
32
|
-
invoiceIds: string[];
|
|
33
|
-
status: 'ACTIVE' | 'PAYMENT_PENDING' | 'ACTIVATION_PENDING';
|
|
34
|
-
}
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
declare const getPlans: (client: Client, status: Status) => Promise<Plan[]>;
|
|
38
|
-
|
|
39
|
-
declare const getUserPlans: (client: Client, entityId: string) => Promise<Subscription[]>;
|
|
40
|
-
|
|
41
|
-
type UnsubscribeResponse = {
|
|
42
|
-
id: string;
|
|
43
|
-
profileId: string;
|
|
44
|
-
plan: Plan;
|
|
45
|
-
fleetId: string;
|
|
46
|
-
expiryDate: string;
|
|
47
|
-
unsubscribeDate: string;
|
|
48
|
-
activationDate: string;
|
|
49
|
-
invoiceIds: string[];
|
|
50
|
-
status: 'ACTIVE' | 'PAYMENT_PENDING' | 'ACTIVATION_PENDING';
|
|
51
|
-
};
|
|
52
|
-
declare const unsubscribe: (client: Client, subscriptionId: string, profileId: string) => Promise<UnsubscribeResponse>;
|
|
53
|
-
|
|
54
|
-
type SubscribeResponse = {
|
|
55
|
-
id: string;
|
|
56
|
-
profileId: string;
|
|
57
|
-
plan: Plan;
|
|
58
|
-
fleetId: string;
|
|
59
|
-
expiryDate: string | null;
|
|
60
|
-
unsubscribeDate: string | null;
|
|
61
|
-
activationDate: string | null;
|
|
62
|
-
invoiceIds: string[];
|
|
63
|
-
status: 'ACTIVE' | 'PAYMENT_PENDING' | 'ACTIVATION_PENDING';
|
|
64
|
-
};
|
|
65
|
-
declare const subscribe: (client: Client, planId: string, profileId: string) => Promise<SubscribeResponse>;
|
|
66
|
-
|
|
67
|
-
export { type Plan, type Status, type Subscription, getPlans, getUserPlans, subscribe, unsubscribe };
|
package/dist/index.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
getPlans: () => getPlans,
|
|
24
|
-
getUserPlans: () => getUserPlans,
|
|
25
|
-
subscribe: () => subscribe,
|
|
26
|
-
unsubscribe: () => unsubscribe
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
|
|
30
|
-
// src/getPlans.ts
|
|
31
|
-
var import_zod = require("zod");
|
|
32
|
-
var schema = import_zod.z.object({
|
|
33
|
-
status: import_zod.z.enum(["ACTIVE", "INACTIVE"])
|
|
34
|
-
});
|
|
35
|
-
var getPlans = async (client, status) => {
|
|
36
|
-
const result = schema.safeParse({ status });
|
|
37
|
-
if (!result.success) {
|
|
38
|
-
throw new TypeError("Invalid args", {
|
|
39
|
-
cause: result.error.issues
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/plans?size=1000&status=${status}`).then(({ data }) => data);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// src/getUserPlans.ts
|
|
46
|
-
var import_zod2 = require("zod");
|
|
47
|
-
var schema2 = import_zod2.z.object({
|
|
48
|
-
entityId: import_zod2.z.string().uuid()
|
|
49
|
-
});
|
|
50
|
-
var getUserPlans = async (client, entityId) => {
|
|
51
|
-
const result = schema2.safeParse({ entityId });
|
|
52
|
-
if (!result.success) {
|
|
53
|
-
throw new TypeError("Invalid args", {
|
|
54
|
-
cause: result.error.issues
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/subscriptions?entityId=${entityId}&status=ACTIVE,PAYMENT_PENDING,ACTIVATION_PENDING`).then(({ data }) => data);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
// src/unsubscribe.ts
|
|
61
|
-
var import_zod3 = require("zod");
|
|
62
|
-
var schema3 = import_zod3.z.object({
|
|
63
|
-
subscriptionId: import_zod3.z.string().uuid(),
|
|
64
|
-
profileId: import_zod3.z.string().uuid()
|
|
65
|
-
});
|
|
66
|
-
var unsubscribe = async (client, subscriptionId, profileId) => {
|
|
67
|
-
const result = schema3.safeParse({ subscriptionId, profileId });
|
|
68
|
-
if (!result.success) {
|
|
69
|
-
throw new TypeError("Invalid args", {
|
|
70
|
-
cause: result.error.issues
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return client.post(
|
|
74
|
-
`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/subscriptions/${subscriptionId}/unsubscribe`,
|
|
75
|
-
{
|
|
76
|
-
profileId
|
|
77
|
-
}
|
|
78
|
-
).then(({ data }) => data).catch((err) => {
|
|
79
|
-
throw new Error("Unsubscribe failed", { cause: err });
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// src/subscribe.ts
|
|
84
|
-
var import_zod4 = require("zod");
|
|
85
|
-
var schema4 = import_zod4.z.object({
|
|
86
|
-
planId: import_zod4.z.string().uuid(),
|
|
87
|
-
profileId: import_zod4.z.string().uuid()
|
|
88
|
-
});
|
|
89
|
-
var subscribe = async (client, planId, profileId) => {
|
|
90
|
-
const result = schema4.safeParse({ planId, profileId });
|
|
91
|
-
if (!result.success) {
|
|
92
|
-
throw new TypeError("Invalid args", {
|
|
93
|
-
cause: result.error.issues
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return client.post(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/subscriptions`, {
|
|
97
|
-
planId,
|
|
98
|
-
profileId
|
|
99
|
-
}).then(({ data }) => data);
|
|
100
|
-
};
|
|
101
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
-
0 && (module.exports = {
|
|
103
|
-
getPlans,
|
|
104
|
-
getUserPlans,
|
|
105
|
-
subscribe,
|
|
106
|
-
unsubscribe
|
|
107
|
-
});
|
|
File without changes
|