@vulog/aima-billing 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.js DELETED
@@ -1,231 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- addCredits: () => addCredits,
34
- chargeProduct: () => chargeProduct,
35
- getInvoiceById: () => getInvoiceById,
36
- getRefundableAmount: () => getRefundableAmount,
37
- getUserCreditsByEntityId: () => getUserCreditsByEntityId,
38
- getWalletsByEntity: () => getWalletsByEntity,
39
- payInvoice: () => payInvoice,
40
- refund: () => refund,
41
- updateWallet: () => updateWallet
42
- });
43
- module.exports = __toCommonJS(index_exports);
44
-
45
- // src/chargeProduct.ts
46
- var import_zod = __toESM(require("zod"));
47
- var schema = import_zod.default.object({
48
- productId: import_zod.default.string().trim().min(1).uuid(),
49
- serviceId: import_zod.default.string().trim().min(1).uuid().nullable().optional(),
50
- amount: import_zod.default.number().min(0),
51
- userId: import_zod.default.string().trim().min(1).uuid(),
52
- entityId: import_zod.default.string().trim().min(1).uuid(),
53
- subscriptionId: import_zod.default.string().trim().min(1).uuid().nullable().optional(),
54
- productNotes: import_zod.default.string().trim().nullable().optional(),
55
- originId: import_zod.default.string().trim().nullable().optional(),
56
- chargeProductRequestId: import_zod.default.string().trim().min(1).uuid().nullable().optional(),
57
- additionalInfo: import_zod.default.object({
58
- manualPayment: import_zod.default.boolean().optional()
59
- }).optional()
60
- });
61
- var chargeProduct = async (client, info) => {
62
- const result = schema.safeParse(info);
63
- if (!result.success) {
64
- throw new TypeError("Invalid args", {
65
- cause: result.error.issues
66
- });
67
- }
68
- return client.post(`/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/product`, info).then(({ data }) => data);
69
- };
70
-
71
- // src/getUserCreditsByEntityId.ts
72
- var import_zod2 = require("zod");
73
- var getUserCreditsByEntityId = async (client, id) => {
74
- const result = import_zod2.z.string().trim().min(1).uuid().safeParse(id);
75
- if (!result.success) {
76
- throw new TypeError("Invalid id", {
77
- cause: result.error.issues
78
- });
79
- }
80
- return client.get(`/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/wallet/entity/${id}`).then(({ data }) => data);
81
- };
82
-
83
- // src/addCredits.ts
84
- var import_zod3 = __toESM(require("zod"));
85
- var schema2 = import_zod3.default.object({
86
- initialAmount: import_zod3.default.number().min(0),
87
- validityStartDate: import_zod3.default.string().datetime(),
88
- validityEndDate: import_zod3.default.string().datetime(),
89
- notes: import_zod3.default.string().trim().nullable().optional(),
90
- discountCategory: import_zod3.default.enum(["CREDITS", "PERCENTAGE"]),
91
- oneTimeUsage: import_zod3.default.boolean().optional(),
92
- entityId: import_zod3.default.string().trim().min(1).uuid(),
93
- type: import_zod3.default.enum(["LOCAL", "GLOBAL", "PERIODIC"]),
94
- usage: import_zod3.default.enum(["TRIP", "REGISTRATION", "PRODUCTS", "ALL"])
95
- });
96
- var addCredits = async (client, payload) => {
97
- const result = schema2.safeParse(payload);
98
- if (!result.success) {
99
- throw new TypeError("Invalid args", {
100
- cause: result.error.issues
101
- });
102
- }
103
- return client.post(
104
- `/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/entities/${payload.entityId}/wallets`,
105
- result.data
106
- ).then(({ data }) => data);
107
- };
108
-
109
- // src/getInvoiceById.ts
110
- var import_zod4 = require("zod");
111
- var getInvoiceById = async (client, id) => {
112
- const result = import_zod4.z.string().trim().min(1).uuid().safeParse(id);
113
- if (!result.success) {
114
- throw new Error("Invalid invoice ID");
115
- }
116
- return client.get(`/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${id}`).then(({ data }) => data);
117
- };
118
-
119
- // src/getRefundableAmount.ts
120
- var import_zod5 = __toESM(require("zod"));
121
- var schema3 = import_zod5.default.string().trim().min(1);
122
- var getRefundableAmount = async (client, invoiceId) => {
123
- const result = schema3.safeParse(invoiceId);
124
- if (!result.success) {
125
- throw new TypeError("Invalid args", {
126
- cause: result.error.issues
127
- });
128
- }
129
- return client.get(
130
- `/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${invoiceId}/refundableAmount`
131
- ).then(({ data }) => data);
132
- };
133
-
134
- // src/refund.ts
135
- var import_zod6 = __toESM(require("zod"));
136
- var schema4 = import_zod6.default.object({
137
- amount: import_zod6.default.number().min(0).optional(),
138
- note: import_zod6.default.string().trim().nullable().optional(),
139
- paymentIntentPspReference: import_zod6.default.string().trim().min(1).optional()
140
- });
141
- var refund = async (client, payload) => {
142
- const result = schema4.safeParse(payload);
143
- if (!result.success) {
144
- throw new TypeError("Invalid args", {
145
- cause: result.error.issues
146
- });
147
- }
148
- const filteredData = Object.fromEntries(
149
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
150
- Object.entries(result.data).filter(([_, value]) => value !== void 0 && value !== null)
151
- );
152
- return client.post(
153
- `/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${payload.invoiceId}/refund`,
154
- // filter boolean fields
155
- filteredData
156
- ).then(({ data }) => data);
157
- };
158
-
159
- // src/getWalletsByEntity.ts
160
- var import_zod7 = require("zod");
161
- var getWalletsByEntity = async (client, entityId) => {
162
- const result = import_zod7.z.string().trim().min(1).uuid().safeParse(entityId);
163
- if (!result.success) {
164
- throw new TypeError("Invalid entityId", {
165
- cause: result.error.issues
166
- });
167
- }
168
- return client.get(`/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/wallet/entity/${entityId}`).then(({ data }) => data);
169
- };
170
-
171
- // src/updateWallet.ts
172
- var import_zod8 = require("zod");
173
- var paths = ["/availableAmount", "/percentage"];
174
- var schema5 = import_zod8.z.object({
175
- walletId: import_zod8.z.string().trim().min(1).uuid(),
176
- actions: import_zod8.z.array(
177
- import_zod8.z.object({
178
- op: import_zod8.z.enum(["replace"]),
179
- path: import_zod8.z.enum(paths),
180
- value: import_zod8.z.string().min(1)
181
- })
182
- ).min(1).max(1)
183
- });
184
- var updateWallet = async (client, walletId, actions) => {
185
- const result = schema5.safeParse({ walletId, actions });
186
- if (!result.success) {
187
- throw new TypeError("Invalid args", {
188
- cause: result.error.issues
189
- });
190
- }
191
- await client.patch(`/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/wallets/${walletId}`, actions, {
192
- headers: {
193
- "Content-Type": "application/json-patch+json"
194
- }
195
- });
196
- };
197
-
198
- // src/payInvoice.ts
199
- var import_zod9 = __toESM(require("zod"));
200
- var schema6 = import_zod9.default.object({
201
- invoiceId: import_zod9.default.string().trim().min(1).uuid(),
202
- manualPayment: import_zod9.default.object({
203
- requiresActionReturnUrl: import_zod9.default.string().default(""),
204
- online: import_zod9.default.boolean().default(true),
205
- scope: import_zod9.default.enum(["RENTAL", "DEPOSIT"])
206
- })
207
- });
208
- var payInvoice = async (client, invoiceId, manualPayment) => {
209
- const result = schema6.safeParse({ invoiceId, manualPayment });
210
- if (!result.success) {
211
- throw new TypeError("Invalid args", {
212
- cause: result.error.issues
213
- });
214
- }
215
- return client.post(
216
- `/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${result.data.invoiceId}/payment`,
217
- result.data.manualPayment
218
- ).then(({ data }) => data);
219
- };
220
- // Annotate the CommonJS export names for ESM import in node:
221
- 0 && (module.exports = {
222
- addCredits,
223
- chargeProduct,
224
- getInvoiceById,
225
- getRefundableAmount,
226
- getUserCreditsByEntityId,
227
- getWalletsByEntity,
228
- payInvoice,
229
- refund,
230
- updateWallet
231
- });
File without changes