@vulog/aima-business 1.2.44 → 1.2.46

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.
Files changed (2) hide show
  1. package/README.md +208 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,208 @@
1
+ # @vulog/aima-business
2
+
3
+ Business account management — CRUD operations, users, cost centers, invoices, trips, and Stripe integration.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install @vulog/aima-business @vulog/aima-client @vulog/aima-core
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { getClient } from '@vulog/aima-client';
15
+ import { getBusinessById, getBusinessUsers } from '@vulog/aima-business';
16
+
17
+ const client = getClient({ /* ClientOptions */ });
18
+
19
+ const business = await getBusinessById(client, 'business-uuid');
20
+ const users = await getBusinessUsers(client, 'business-uuid', { page: 0, pageSize: 50 });
21
+ ```
22
+
23
+ ## API Reference
24
+
25
+ ### Business CRUD
26
+
27
+ | Function | Signature | Description |
28
+ |----------|-----------|-------------|
29
+ | `getBusinesses` | `(client, options?: PaginableOptions<{ name?; status?; updateSince? }>) => Promise<PaginableResponse<Business>>` | Retrieve a paginated list of businesses |
30
+ | `getBusinessById` | `(client, businessId: string) => Promise<Business>` | Retrieve a business by UUID |
31
+ | `createBusiness` | `(client, body: CreateBusinessBody) => Promise<Business>` | Create a new business — `name` required |
32
+ | `updateBusiness` | `(client, businessId: string, body: UpdateBusinessBody) => Promise<Business>` | Update a business — all fields optional |
33
+ | `getBusinessContacts` | `(client, businessId: string) => Promise<BusinessContact[]>` | Retrieve contacts for a business |
34
+ | `getBusinessPaymentDetails` | `(client, businessId: string) => Promise<BusinessPaymentDetails>` | Retrieve payment details for a business |
35
+ | `updateBusinessProfileStatus` | `(client, businessId: string, status: string) => Promise<void>` | Update the profile status of a business |
36
+ | `archiveBusinessProfile` | `(client, businessId: string, userId: string, profileId: string) => Promise<void>` | Archive a business profile |
37
+ | `deactivateBusinessProfile` | `(client, businessId: string, profileId: string) => Promise<void>` | Deactivate a business profile |
38
+ | `addBusinessCredit` | `(client, businessId: string, body: { amount: number; expirationDate: string }) => Promise<void>` | Add credit to a business |
39
+ | `chargeBusinessProduct` | `(client, businessId: string, body: ChargeBusinessProductBody) => Promise<void>` | Charge a product to a business |
40
+ | `redeemBusinessPromoCode` | `(client, businessId: string, reference: string) => Promise<void>` | Redeem a promo code for a business |
41
+ | `sendBusinessIban` | `(client, businessId: string, body: { iban: string; entityId?: string }) => Promise<void>` | Submit an IBAN for a business |
42
+ | `getBusinessProducts` | `(client) => Promise<BusinessProduct[]>` | Retrieve all available business products |
43
+ | `getBusinessBillingGroups` | `(client) => Promise<BusinessBillingGroup[]>` | Retrieve all billing groups |
44
+
45
+ #### createBusiness / updateBusiness — optional fields
46
+
47
+ `legalName`, `phoneNumber`, `faxNumber`, `email`, `vat`, `ein`, `registrationUrl`, `comment`, `paymentType`, `locale`, `invoiceFrequency`, `status`, `nationality`, `pec`, `legalForm`, `fiscalCode`, `taxNumberCountry`, `communityTaxNumber`, `sdicemCode`, `mandatoryTripNotes`, `billingAddress`, `address`, `billingGroup`
48
+
49
+ #### chargeBusinessProduct — body fields
50
+
51
+ | Field | Type | Required |
52
+ |-------|------|----------|
53
+ | `productId` | `string` | Yes |
54
+ | `amount` | `number` | Yes |
55
+ | `userId` | `string` | No |
56
+ | `productNotes` | `string` | No |
57
+ | `serviceId` | `string` | No |
58
+
59
+ ### Business Users
60
+
61
+ | Function | Signature | Description |
62
+ |----------|-----------|-------------|
63
+ | `getBusinessUsers` | `(client, businessId: string, options?: PaginableOptions<{ role?; status? }>) => Promise<PaginableResponse<BusinessUser>>` | Retrieve users for a business |
64
+ | `getBusinessUserById` | `(client, businessId: string, userId: string) => Promise<BusinessUser>` | Retrieve a business user by ID |
65
+ | `getBusinessUserGlobalById` | `(client, userId: string) => Promise<BusinessUser>` | Retrieve a business user globally by ID |
66
+ | `listBusinessUsersGlobal` | `(client, body: { userIds: string[] }) => Promise<BusinessUser[]>` | Retrieve multiple business users by ID list (min 1) |
67
+ | `addUserToBusiness` | `(client, businessId: string, userId: string, data?: AddUserToBusinessData) => Promise<BusinessUserProfile>` | Add an existing user to a business |
68
+ | `bulkAddBusinessUsers` | `(client, businessId: string, file: Blob \| Buffer, locale?: string) => Promise<any>` | Bulk add users via multipart file upload |
69
+ | `inviteBusinessUser` | `(client, businessId: string, params: InviteBusinessUserParams) => Promise<void>` | Invite a new user to a business by email |
70
+ | `updateBusinessUserProfile` | `(client, businessId: string, userId: string, profileId: string, body: UpdateBusinessUserProfileBody) => Promise<BusinessUserProfile>` | Update a user's business profile |
71
+ | `searchBusinessUsersByName` | `(client, businessId: string, name: string) => Promise<BusinessUser[]>` | Search business users by name |
72
+ | `searchBusinessUsersGlobal` | `(client, name: string) => Promise<BusinessUser[]>` | Search all business users by name |
73
+ | `setBusinessOwner` | `(client, businessId: string, userId: string) => Promise<void>` | Set a user as the business owner |
74
+ | `removeBusinessOwner` | `(client, businessId: string, userId: string) => Promise<void>` | Remove the owner role from a user |
75
+ | `setDelegatedAdmin` | `(client, businessId: string, userId: string) => Promise<void>` | Grant delegated admin role to a user |
76
+ | `removeDelegatedAdmin` | `(client, businessId: string, userId: string) => Promise<void>` | Remove delegated admin role from a user |
77
+
78
+ #### inviteBusinessUser — params
79
+
80
+ | Field | Type | Required |
81
+ |-------|------|----------|
82
+ | `email` | `string` | Yes |
83
+ | `firstName` | `string` | No |
84
+ | `lastName` | `string` | No |
85
+ | `costCenterId` | `string` | No |
86
+ | `locale` | `string` | No |
87
+
88
+ #### addUserToBusiness / updateBusinessUserProfile — optional fields
89
+
90
+ `email`, `emailConsent`, `requestId` (add only), `costCenterId`
91
+
92
+ ### Cost Centers
93
+
94
+ | Function | Signature | Description |
95
+ |----------|-----------|-------------|
96
+ | `getBusinessCostCenters` | `(client, businessId: string) => Promise<CostCenter[]>` | Retrieve all cost centers for a business |
97
+ | `getBusinessCostCenterById` | `(client, businessId: string, costCenterId: string) => Promise<CostCenter>` | Retrieve a cost center by ID |
98
+ | `createBusinessCostCenter` | `(client, businessId: string, body: { name: string; value: string }) => Promise<CostCenter>` | Create a cost center |
99
+ | `updateBusinessCostCenter` | `(client, businessId: string, costCenterId: string, body: { name?; value? }) => Promise<CostCenter>` | Update a cost center |
100
+ | `deleteBusinessCostCenter` | `(client, businessId: string, costCenterId: string) => Promise<void>` | Delete a cost center |
101
+
102
+ ### Invitations
103
+
104
+ | Function | Signature | Description |
105
+ |----------|-----------|-------------|
106
+ | `getBusinessInviteLink` | `(client, businessId: string, params: InviteParams) => Promise<BusinessInviteLink>` | Generate an invite link for a business |
107
+ | `getInvitationRequest` | `(client, invitationId: string) => Promise<InvitationRequest>` | Retrieve an invitation request by ID |
108
+ | `deleteInvitationRequest` | `(client, invitationId: string) => Promise<void>` | Delete an invitation request |
109
+
110
+ #### getBusinessInviteLink — params
111
+
112
+ | Field | Type | Required |
113
+ |-------|------|----------|
114
+ | `email` | `string` | Yes |
115
+ | `firstName` | `string` | No |
116
+ | `lastName` | `string` | No |
117
+ | `costCenterId` | `string` | No |
118
+
119
+ ### Invoices
120
+
121
+ | Function | Signature | Description |
122
+ |----------|-----------|-------------|
123
+ | `getBusinessInvoices` | `(client, entityId: string, options?: PaginableOptions<{ fromDate?; toDate? }>) => Promise<PaginableResponse<BusinessInvoice>>` | Retrieve invoices for an entity |
124
+ | `getBusinessInvoiceProducts` | `(client, entityId: string, invoiceId: string) => Promise<any[]>` | Retrieve line item products for a business invoice |
125
+ | `getBusinessInvoiceTrips` | `(client, entityId: string, invoiceId: string) => Promise<any[]>` | Retrieve trips associated with a business invoice |
126
+ | `getInvoicePdf` | `(client, invoiceId: string) => Promise<ArrayBuffer \| null>` | Download an invoice as PDF — returns `null` when empty |
127
+ | `getInvoiceRefundableAmount` | `(client, invoiceId: string) => Promise<InvoiceRefundableAmount>` | Retrieve the refundable amount for an invoice |
128
+ | `getInvoiceRefundNote` | `(client, invoiceId: string, paymentRefundPspReference?: string) => Promise<InvoiceRefundNote>` | Retrieve a refund note for an invoice |
129
+ | `refundInvoice` | `(client, invoiceId: string, body?: { amount?: number; note?: string \| null }) => Promise<void>` | Issue a refund for an invoice |
130
+ | `refundInvoiceAmount` | `(client, invoiceId: string, amount: number) => Promise<void>` | **@deprecated** Use `refundInvoice` instead |
131
+ | `setInvoiceExternalPayment` | `(client, invoiceId: string, body: SetExternalPaymentBody) => Promise<void>` | Mark an invoice as paid externally |
132
+ | `updateInvoiceStatus` | `(client, invoiceId: string, status: string) => Promise<void>` | Update the status of an invoice |
133
+
134
+ #### setInvoiceExternalPayment — body fields
135
+
136
+ | Field | Type | Required |
137
+ |-------|------|----------|
138
+ | `requesterId` | `string` | Yes |
139
+ | `notes` | `string` | No |
140
+ | `paymentMethod` | `string` | No |
141
+
142
+ ### Trips & Entity Billing
143
+
144
+ | Function | Signature | Description |
145
+ |----------|-----------|-------------|
146
+ | `getOngoingTrips` | `(client, businessId: string, options?: PaginableOptions) => Promise<PaginableResponse<BusinessTrip>>` | Retrieve ongoing trips for a business |
147
+ | `getBusinessTripById` | `(client, tripId: string) => Promise<BusinessTrip>` | Retrieve a business trip by ID |
148
+ | `getOngoingTripNotes` | `(client, tripId: string) => Promise<TripNote[]>` | Retrieve notes for an ongoing trip |
149
+ | `addTripNote` | `(client, tripId: string, body: { content: string }) => Promise<TripNote>` | Add a note to a trip |
150
+ | `getEntityBalance` | `(client, entityId: string) => Promise<EntityBalance>` | Retrieve the balance for an entity |
151
+ | `getEntityProducts` | `(client, entityId: string, options: PaginableOptions<EntityProductsFilters>) => Promise<PaginableResponse<any>>` | Retrieve product usage for an entity |
152
+ | `getEntityTrips` | `(client, entityId: string, options: PaginableOptions<EntityTripsFilters>) => Promise<PaginableResponse<any>>` | Retrieve trips for an entity |
153
+ | `getEntityTripsCost` | `(client, entityId: string, options: PaginableOptions<EntityTripsCostFilters>) => Promise<PaginableResponse<any>>` | Retrieve trip costs for an entity |
154
+
155
+ #### getEntityProducts — filter fields
156
+
157
+ | Field | Type | Required |
158
+ |-------|------|----------|
159
+ | `period` | `string` | Yes |
160
+ | `user` | `string` | No |
161
+ | `productDetailsType` | `'UNIT' \| 'ACCUMULATIVE' \| 'DEFAULT'` | No |
162
+
163
+ #### getEntityTrips — filter fields
164
+
165
+ | Field | Type | Required |
166
+ |-------|------|----------|
167
+ | `period` | `string` | Yes |
168
+ | `user` | `string` | No |
169
+ | `costCenterIds` | `string[]` | No |
170
+
171
+ #### getEntityTripsCost — filter fields
172
+
173
+ | Field | Type | Required |
174
+ |-------|------|----------|
175
+ | `startDate` | `string` | Yes |
176
+ | `endDate` | `string` | Yes |
177
+ | `tripId` | `string` | No |
178
+
179
+ ### Stripe
180
+
181
+ | Function | Signature | Description |
182
+ |----------|-----------|-------------|
183
+ | `getStripePublishableKey` | `(client) => Promise<StripeConfig>` | Retrieve the Stripe publishable key |
184
+ | `getStripeSetup` | `(client, businessId: string) => Promise<StripeSetup>` | Retrieve Stripe setup for a business |
185
+ | `addStripePayment` | `(client, businessId: string) => Promise<StripeSetup>` | **@deprecated** |
186
+
187
+ ## Types
188
+
189
+ | Type | Description |
190
+ |------|-------------|
191
+ | `Business` | Business record |
192
+ | `BusinessContact` | Contact associated with a business |
193
+ | `CostCenter` | Cost center record |
194
+ | `BusinessPaymentDetails` | Payment configuration for a business |
195
+ | `BusinessUser` | User within a business context |
196
+ | `BusinessUserProfile` | User profile within a business |
197
+ | `BusinessInviteLink` | Generated invite link |
198
+ | `InvitationRequest` | Pending invitation record |
199
+ | `EntityBalance` | Financial balance for an entity |
200
+ | `BusinessBillingGroup` | Billing group configuration |
201
+ | `StripeSetup` | Stripe setup details |
202
+ | `StripeConfig` | Stripe publishable key config |
203
+ | `BusinessInvoice` | Invoice in a business context |
204
+ | `InvoiceRefundNote` | Refund note for a business invoice |
205
+ | `InvoiceRefundableAmount` | Refundable amount details |
206
+ | `BusinessTrip` | Trip in a business context |
207
+ | `TripNote` | Note attached to a trip |
208
+ | `BusinessProduct` | Product available for businesses |
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vulog/aima-business",
3
3
  "type": "module",
4
- "version": "1.2.44",
4
+ "version": "1.2.46",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.cts",
@@ -32,8 +32,8 @@
32
32
  "author": "Vulog",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@vulog/aima-client": "1.2.44",
36
- "@vulog/aima-core": "1.2.44"
35
+ "@vulog/aima-client": "1.2.46",
36
+ "@vulog/aima-core": "1.2.46"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "zod": "^4.3.6"