@vulog/aima-promocode 1.2.30 → 1.2.32
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 +67 -0
- package/dist/index.d.cts +55 -0
- package/dist/index.d.mts +41 -36
- package/dist/index.mjs +54 -80
- package/package.json +21 -8
- package/{tsup.config.ts → tsdown.config.ts} +1 -1
- package/dist/index.d.ts +0 -50
- package/dist/index.js +0 -119
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
//#region src/checkInvitationCode.ts
|
|
4
|
+
const checkInvitationCode = async (client, referralCode) => {
|
|
5
|
+
const result = zod.z.string().trim().min(1).safeParse(referralCode);
|
|
6
|
+
if (!result.success) throw new TypeError("Invalid referralCode", { cause: result.error.issues });
|
|
7
|
+
return client.get(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/invitation/check/${referralCode}`).then(({ data }) => data).catch((error) => {
|
|
8
|
+
if (error.formattedError?.status === 404) return;
|
|
9
|
+
throw error;
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/getPromoCode.ts
|
|
14
|
+
const getPromoCodeByReference = async (client, reference) => {
|
|
15
|
+
const result = zod.z.string().trim().min(1).safeParse(reference);
|
|
16
|
+
if (!result.success) throw new TypeError("Invalid reference", { cause: result.error.issues });
|
|
17
|
+
return client.get(`boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/promoCodes?reference=${reference}`).then(({ data: [r] }) => r);
|
|
18
|
+
};
|
|
19
|
+
const getPromoCodeById = async (client, id) => {
|
|
20
|
+
const result = zod.z.number().positive().safeParse(id);
|
|
21
|
+
if (!result.success) throw new TypeError("Invalid id", { cause: result.error.issues });
|
|
22
|
+
return client.get(`boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/promoCodes/${id}`).then(({ data }) => data).catch((error) => {
|
|
23
|
+
if (error.formattedError?.status === 404) return;
|
|
24
|
+
throw error;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/submitPromoCode.ts
|
|
29
|
+
const schema$1 = zod.z.object({
|
|
30
|
+
userId: zod.z.string().uuid(),
|
|
31
|
+
entityId: zod.z.string().uuid(),
|
|
32
|
+
code: zod.z.string().min(1)
|
|
33
|
+
});
|
|
34
|
+
const submitPromoCode = async (client, userId, entityId, code) => {
|
|
35
|
+
const result = schema$1.safeParse({
|
|
36
|
+
userId,
|
|
37
|
+
entityId,
|
|
38
|
+
code
|
|
39
|
+
});
|
|
40
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
41
|
+
return client.put(`boapi/proxy/user/billing/fleets/${client.clientOptions.fleetId}/promoCodes/redeem/${code}`, {
|
|
42
|
+
userId,
|
|
43
|
+
entityId
|
|
44
|
+
}).then(({ data }) => data);
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/submitReferral.ts
|
|
48
|
+
const schema = zod.z.object({
|
|
49
|
+
userId: zod.z.string().uuid(),
|
|
50
|
+
entityId: zod.z.string().uuid(),
|
|
51
|
+
code: zod.z.string().min(1)
|
|
52
|
+
});
|
|
53
|
+
const submitReferral = async (client, userId, entityId, code) => {
|
|
54
|
+
const result = schema.safeParse({
|
|
55
|
+
userId,
|
|
56
|
+
entityId,
|
|
57
|
+
code
|
|
58
|
+
});
|
|
59
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
60
|
+
await client.post(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/invitation/users/${userId}/entity/${entityId}/redeem/${code}`);
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
exports.checkInvitationCode = checkInvitationCode;
|
|
64
|
+
exports.getPromoCodeById = getPromoCodeById;
|
|
65
|
+
exports.getPromoCodeByReference = getPromoCodeByReference;
|
|
66
|
+
exports.submitPromoCode = submitPromoCode;
|
|
67
|
+
exports.submitReferral = submitReferral;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Client } from "@vulog/aima-client";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
type ProductGroup = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
status: 'ACTIVE' | 'INACTIVE';
|
|
8
|
+
};
|
|
9
|
+
type PromoCodeUsage = {
|
|
10
|
+
id: number;
|
|
11
|
+
walletUsage: 'TRIP' | 'PRODUCTS';
|
|
12
|
+
discountCategory: 'CREDITS';
|
|
13
|
+
percentage: number;
|
|
14
|
+
amount: number;
|
|
15
|
+
cappedPercentage: null;
|
|
16
|
+
isOneTimeUsage: boolean;
|
|
17
|
+
productGroup?: ProductGroup | null;
|
|
18
|
+
};
|
|
19
|
+
type PromoCode = {
|
|
20
|
+
reference: string;
|
|
21
|
+
walletType: string;
|
|
22
|
+
status: 'ACTIVE' | 'INACTIVE';
|
|
23
|
+
validityDuration: number;
|
|
24
|
+
effectiveDate: string;
|
|
25
|
+
expiryDate: string;
|
|
26
|
+
validityEndDate: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
id: number;
|
|
29
|
+
fleetId: string;
|
|
30
|
+
registration: boolean;
|
|
31
|
+
maxUses: number;
|
|
32
|
+
usages: PromoCodeUsage[];
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
};
|
|
35
|
+
type ReferralInfo = {
|
|
36
|
+
referralUserId: string;
|
|
37
|
+
referralCode: string;
|
|
38
|
+
referralPromocodeId: number;
|
|
39
|
+
refereePromocodeId: number;
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/checkInvitationCode.d.ts
|
|
43
|
+
declare const checkInvitationCode: (client: Client, referralCode: string) => Promise<ReferralInfo | undefined>;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/getPromoCode.d.ts
|
|
46
|
+
declare const getPromoCodeByReference: (client: Client, reference: string) => Promise<PromoCode | undefined>;
|
|
47
|
+
declare const getPromoCodeById: (client: Client, id: number) => Promise<PromoCode | undefined>;
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/submitPromoCode.d.ts
|
|
50
|
+
declare const submitPromoCode: (client: Client, userId: string, entityId: string, code: string) => Promise<string>;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/submitReferral.d.ts
|
|
53
|
+
declare const submitReferral: (client: Client, userId: string, entityId: string, code: string) => Promise<void>;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { ProductGroup, PromoCode, PromoCodeUsage, ReferralInfo, checkInvitationCode, getPromoCodeById, getPromoCodeByReference, submitPromoCode, submitReferral };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,50 +1,55 @@
|
|
|
1
|
-
import { Client } from
|
|
1
|
+
import { Client } from "@vulog/aima-client";
|
|
2
2
|
|
|
3
|
+
//#region src/types.d.ts
|
|
3
4
|
type ProductGroup = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
status: 'ACTIVE' | 'INACTIVE';
|
|
7
8
|
};
|
|
8
9
|
type PromoCodeUsage = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
id: number;
|
|
11
|
+
walletUsage: 'TRIP' | 'PRODUCTS';
|
|
12
|
+
discountCategory: 'CREDITS';
|
|
13
|
+
percentage: number;
|
|
14
|
+
amount: number;
|
|
15
|
+
cappedPercentage: null;
|
|
16
|
+
isOneTimeUsage: boolean;
|
|
17
|
+
productGroup?: ProductGroup | null;
|
|
17
18
|
};
|
|
18
19
|
type PromoCode = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
reference: string;
|
|
21
|
+
walletType: string;
|
|
22
|
+
status: 'ACTIVE' | 'INACTIVE';
|
|
23
|
+
validityDuration: number;
|
|
24
|
+
effectiveDate: string;
|
|
25
|
+
expiryDate: string;
|
|
26
|
+
validityEndDate: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
id: number;
|
|
29
|
+
fleetId: string;
|
|
30
|
+
registration: boolean;
|
|
31
|
+
maxUses: number;
|
|
32
|
+
usages: PromoCodeUsage[];
|
|
33
|
+
[key: string]: any;
|
|
33
34
|
};
|
|
34
35
|
type ReferralInfo = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
referralUserId: string;
|
|
37
|
+
referralCode: string;
|
|
38
|
+
referralPromocodeId: number;
|
|
39
|
+
refereePromocodeId: number;
|
|
39
40
|
};
|
|
40
|
-
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/checkInvitationCode.d.ts
|
|
41
43
|
declare const checkInvitationCode: (client: Client, referralCode: string) => Promise<ReferralInfo | undefined>;
|
|
42
|
-
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/getPromoCode.d.ts
|
|
43
46
|
declare const getPromoCodeByReference: (client: Client, reference: string) => Promise<PromoCode | undefined>;
|
|
44
47
|
declare const getPromoCodeById: (client: Client, id: number) => Promise<PromoCode | undefined>;
|
|
45
|
-
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/submitPromoCode.d.ts
|
|
46
50
|
declare const submitPromoCode: (client: Client, userId: string, entityId: string, code: string) => Promise<string>;
|
|
47
|
-
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/submitReferral.d.ts
|
|
48
53
|
declare const submitReferral: (client: Client, userId: string, entityId: string, code: string) => Promise<void>;
|
|
49
|
-
|
|
50
|
-
export {
|
|
54
|
+
//#endregion
|
|
55
|
+
export { ProductGroup, PromoCode, PromoCodeUsage, ReferralInfo, checkInvitationCode, getPromoCodeById, getPromoCodeByReference, submitPromoCode, submitReferral };
|
package/dist/index.mjs
CHANGED
|
@@ -1,88 +1,62 @@
|
|
|
1
|
-
// src/checkInvitationCode.ts
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (error.formattedError?.status === 404) {
|
|
12
|
-
return void 0;
|
|
13
|
-
}
|
|
14
|
-
throw error;
|
|
15
|
-
});
|
|
2
|
+
//#region src/checkInvitationCode.ts
|
|
3
|
+
const checkInvitationCode = async (client, referralCode) => {
|
|
4
|
+
const result = z.string().trim().min(1).safeParse(referralCode);
|
|
5
|
+
if (!result.success) throw new TypeError("Invalid referralCode", { cause: result.error.issues });
|
|
6
|
+
return client.get(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/invitation/check/${referralCode}`).then(({ data }) => data).catch((error) => {
|
|
7
|
+
if (error.formattedError?.status === 404) return;
|
|
8
|
+
throw error;
|
|
9
|
+
});
|
|
16
10
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
throw new TypeError("Invalid reference", {
|
|
24
|
-
cause: result.error.issues
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return client.get(`boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/promoCodes?reference=${reference}`).then(({ data: [r] }) => r);
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/getPromoCode.ts
|
|
13
|
+
const getPromoCodeByReference = async (client, reference) => {
|
|
14
|
+
const result = z.string().trim().min(1).safeParse(reference);
|
|
15
|
+
if (!result.success) throw new TypeError("Invalid reference", { cause: result.error.issues });
|
|
16
|
+
return client.get(`boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/promoCodes?reference=${reference}`).then(({ data: [r] }) => r);
|
|
28
17
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return client.get(`boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/promoCodes/${id}`).then(({ data }) => data).catch((error) => {
|
|
37
|
-
if (error.formattedError?.status === 404) {
|
|
38
|
-
return void 0;
|
|
39
|
-
}
|
|
40
|
-
throw error;
|
|
41
|
-
});
|
|
18
|
+
const getPromoCodeById = async (client, id) => {
|
|
19
|
+
const result = z.number().positive().safeParse(id);
|
|
20
|
+
if (!result.success) throw new TypeError("Invalid id", { cause: result.error.issues });
|
|
21
|
+
return client.get(`boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/promoCodes/${id}`).then(({ data }) => data).catch((error) => {
|
|
22
|
+
if (error.formattedError?.status === 404) return;
|
|
23
|
+
throw error;
|
|
24
|
+
});
|
|
42
25
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
code: z3.string().min(1)
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/submitPromoCode.ts
|
|
28
|
+
const schema$1 = z.object({
|
|
29
|
+
userId: z.string().uuid(),
|
|
30
|
+
entityId: z.string().uuid(),
|
|
31
|
+
code: z.string().min(1)
|
|
50
32
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
33
|
+
const submitPromoCode = async (client, userId, entityId, code) => {
|
|
34
|
+
const result = schema$1.safeParse({
|
|
35
|
+
userId,
|
|
36
|
+
entityId,
|
|
37
|
+
code
|
|
38
|
+
});
|
|
39
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
40
|
+
return client.put(`boapi/proxy/user/billing/fleets/${client.clientOptions.fleetId}/promoCodes/redeem/${code}`, {
|
|
41
|
+
userId,
|
|
42
|
+
entityId
|
|
43
|
+
}).then(({ data }) => data);
|
|
62
44
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
code: z4.string().min(1)
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/submitReferral.ts
|
|
47
|
+
const schema = z.object({
|
|
48
|
+
userId: z.string().uuid(),
|
|
49
|
+
entityId: z.string().uuid(),
|
|
50
|
+
code: z.string().min(1)
|
|
70
51
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/invitation/users/${userId}/entity/${entityId}/redeem/${code}`
|
|
80
|
-
);
|
|
81
|
-
};
|
|
82
|
-
export {
|
|
83
|
-
checkInvitationCode,
|
|
84
|
-
getPromoCodeById,
|
|
85
|
-
getPromoCodeByReference,
|
|
86
|
-
submitPromoCode,
|
|
87
|
-
submitReferral
|
|
52
|
+
const submitReferral = async (client, userId, entityId, code) => {
|
|
53
|
+
const result = schema.safeParse({
|
|
54
|
+
userId,
|
|
55
|
+
entityId,
|
|
56
|
+
code
|
|
57
|
+
});
|
|
58
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
59
|
+
await client.post(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/invitation/users/${userId}/entity/${entityId}/redeem/${code}`);
|
|
88
60
|
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { checkInvitationCode, getPromoCodeById, getPromoCodeByReference, submitPromoCode, submitReferral };
|
package/package.json
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulog/aima-promocode",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.2.32",
|
|
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": "
|
|
10
|
-
"test": "vitest run",
|
|
21
|
+
"build": "tsdown",
|
|
22
|
+
"dev": "tsdown --watch",
|
|
23
|
+
"test": "vitest run --passWithNoTests",
|
|
11
24
|
"test:watch": "vitest",
|
|
12
25
|
"lint": "eslint src/**/* --ext .ts"
|
|
13
26
|
},
|
|
@@ -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.32",
|
|
37
|
+
"@vulog/aima-core": "1.2.32"
|
|
25
38
|
},
|
|
26
39
|
"peerDependencies": {
|
|
27
40
|
"zod": "^3.25.76"
|
package/dist/index.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Client } from '@vulog/aima-client';
|
|
2
|
-
|
|
3
|
-
type ProductGroup = {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
status: 'ACTIVE' | 'INACTIVE';
|
|
7
|
-
};
|
|
8
|
-
type PromoCodeUsage = {
|
|
9
|
-
id: number;
|
|
10
|
-
walletUsage: 'TRIP' | 'PRODUCTS';
|
|
11
|
-
discountCategory: 'CREDITS';
|
|
12
|
-
percentage: number;
|
|
13
|
-
amount: number;
|
|
14
|
-
cappedPercentage: null;
|
|
15
|
-
isOneTimeUsage: boolean;
|
|
16
|
-
productGroup?: ProductGroup | null;
|
|
17
|
-
};
|
|
18
|
-
type PromoCode = {
|
|
19
|
-
reference: string;
|
|
20
|
-
walletType: string;
|
|
21
|
-
status: 'ACTIVE' | 'INACTIVE';
|
|
22
|
-
validityDuration: number;
|
|
23
|
-
effectiveDate: string;
|
|
24
|
-
expiryDate: string;
|
|
25
|
-
validityEndDate: string;
|
|
26
|
-
description?: string;
|
|
27
|
-
id: number;
|
|
28
|
-
fleetId: string;
|
|
29
|
-
registration: boolean;
|
|
30
|
-
maxUses: number;
|
|
31
|
-
usages: PromoCodeUsage[];
|
|
32
|
-
[key: string]: any;
|
|
33
|
-
};
|
|
34
|
-
type ReferralInfo = {
|
|
35
|
-
referralUserId: string;
|
|
36
|
-
referralCode: string;
|
|
37
|
-
referralPromocodeId: number;
|
|
38
|
-
refereePromocodeId: number;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
declare const checkInvitationCode: (client: Client, referralCode: string) => Promise<ReferralInfo | undefined>;
|
|
42
|
-
|
|
43
|
-
declare const getPromoCodeByReference: (client: Client, reference: string) => Promise<PromoCode | undefined>;
|
|
44
|
-
declare const getPromoCodeById: (client: Client, id: number) => Promise<PromoCode | undefined>;
|
|
45
|
-
|
|
46
|
-
declare const submitPromoCode: (client: Client, userId: string, entityId: string, code: string) => Promise<string>;
|
|
47
|
-
|
|
48
|
-
declare const submitReferral: (client: Client, userId: string, entityId: string, code: string) => Promise<void>;
|
|
49
|
-
|
|
50
|
-
export { type ProductGroup, type PromoCode, type PromoCodeUsage, type ReferralInfo, checkInvitationCode, getPromoCodeById, getPromoCodeByReference, submitPromoCode, submitReferral };
|
package/dist/index.js
DELETED
|
@@ -1,119 +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
|
-
checkInvitationCode: () => checkInvitationCode,
|
|
24
|
-
getPromoCodeById: () => getPromoCodeById,
|
|
25
|
-
getPromoCodeByReference: () => getPromoCodeByReference,
|
|
26
|
-
submitPromoCode: () => submitPromoCode,
|
|
27
|
-
submitReferral: () => submitReferral
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(index_exports);
|
|
30
|
-
|
|
31
|
-
// src/checkInvitationCode.ts
|
|
32
|
-
var import_zod = require("zod");
|
|
33
|
-
var checkInvitationCode = async (client, referralCode) => {
|
|
34
|
-
const result = import_zod.z.string().trim().min(1).safeParse(referralCode);
|
|
35
|
-
if (!result.success) {
|
|
36
|
-
throw new TypeError("Invalid referralCode", {
|
|
37
|
-
cause: result.error.issues
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
return client.get(`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/invitation/check/${referralCode}`).then(({ data }) => data).catch((error) => {
|
|
41
|
-
if (error.formattedError?.status === 404) {
|
|
42
|
-
return void 0;
|
|
43
|
-
}
|
|
44
|
-
throw error;
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// src/getPromoCode.ts
|
|
49
|
-
var import_zod2 = require("zod");
|
|
50
|
-
var getPromoCodeByReference = async (client, reference) => {
|
|
51
|
-
const result = import_zod2.z.string().trim().min(1).safeParse(reference);
|
|
52
|
-
if (!result.success) {
|
|
53
|
-
throw new TypeError("Invalid reference", {
|
|
54
|
-
cause: result.error.issues
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return client.get(`boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/promoCodes?reference=${reference}`).then(({ data: [r] }) => r);
|
|
58
|
-
};
|
|
59
|
-
var getPromoCodeById = async (client, id) => {
|
|
60
|
-
const result = import_zod2.z.number().positive().safeParse(id);
|
|
61
|
-
if (!result.success) {
|
|
62
|
-
throw new TypeError("Invalid id", {
|
|
63
|
-
cause: result.error.issues
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return client.get(`boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/promoCodes/${id}`).then(({ data }) => data).catch((error) => {
|
|
67
|
-
if (error.formattedError?.status === 404) {
|
|
68
|
-
return void 0;
|
|
69
|
-
}
|
|
70
|
-
throw error;
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// src/submitPromoCode.ts
|
|
75
|
-
var import_zod3 = require("zod");
|
|
76
|
-
var schema = import_zod3.z.object({
|
|
77
|
-
userId: import_zod3.z.string().uuid(),
|
|
78
|
-
entityId: import_zod3.z.string().uuid(),
|
|
79
|
-
code: import_zod3.z.string().min(1)
|
|
80
|
-
});
|
|
81
|
-
var submitPromoCode = async (client, userId, entityId, code) => {
|
|
82
|
-
const result = schema.safeParse({ userId, entityId, code });
|
|
83
|
-
if (!result.success) {
|
|
84
|
-
throw new TypeError("Invalid args", {
|
|
85
|
-
cause: result.error.issues
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
return client.put(`boapi/proxy/user/billing/fleets/${client.clientOptions.fleetId}/promoCodes/redeem/${code}`, {
|
|
89
|
-
userId,
|
|
90
|
-
entityId
|
|
91
|
-
}).then(({ data }) => data);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
// src/submitReferral.ts
|
|
95
|
-
var import_zod4 = require("zod");
|
|
96
|
-
var schema2 = import_zod4.z.object({
|
|
97
|
-
userId: import_zod4.z.string().uuid(),
|
|
98
|
-
entityId: import_zod4.z.string().uuid(),
|
|
99
|
-
code: import_zod4.z.string().min(1)
|
|
100
|
-
});
|
|
101
|
-
var submitReferral = async (client, userId, entityId, code) => {
|
|
102
|
-
const result = schema2.safeParse({ userId, entityId, code });
|
|
103
|
-
if (!result.success) {
|
|
104
|
-
throw new TypeError("Invalid args", {
|
|
105
|
-
cause: result.error.issues
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
await client.post(
|
|
109
|
-
`boapi/proxy/user/fleets/${client.clientOptions.fleetId}/invitation/users/${userId}/entity/${entityId}/redeem/${code}`
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
-
0 && (module.exports = {
|
|
114
|
-
checkInvitationCode,
|
|
115
|
-
getPromoCodeById,
|
|
116
|
-
getPromoCodeByReference,
|
|
117
|
-
submitPromoCode,
|
|
118
|
-
submitReferral
|
|
119
|
-
});
|
|
File without changes
|