@lifeaz/lors-helper 1.0.0
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/README.md +14 -0
- package/dist/main.d.ts +569 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +321 -0
- package/package.json +59 -0
- package/src/main.ts +443 -0
package/dist/main.js
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const uuidSchema = z.custom((v) => typeof v === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(v));
|
|
3
|
+
const dayjsSchema = z.custom((v) => v != null && typeof v.isValid === "function");
|
|
4
|
+
export const LangSchema = z.union([z.literal('fr'), z.literal('en'), z.literal('nl'), z.literal('de'), z.literal('it'), z.literal('es')]);
|
|
5
|
+
export const ProfileTypeSchema = z.union([z.literal('_Individual_'), z.literal('_Small_Business_'), z.literal('_Company_')]);
|
|
6
|
+
export const CartStepSchema = z.union([z.literal('_Profile_'), z.literal('_Offers_'), z.literal('_Information_'), z.literal('_Options_'), z.literal('_Delivery_'), z.literal('_Payment_')]);
|
|
7
|
+
export const CartStatusSchema = z.union([z.literal('_Draft_'), z.literal('_Pending_'), z.literal('_Paid_'), z.literal('_Abandoned_'), z.literal('_Cancelled_')]);
|
|
8
|
+
export const OrderStatusSchema = z.union([z.literal('_Pending_'), z.literal('_Paid_'), z.literal('_In_Production_'), z.literal('_In_Delivery_'), z.literal('_Delivered_'), z.literal('_Cancelled_'), z.literal('_Refunded_')]);
|
|
9
|
+
export const PaymentStatusSchema = z.union([z.literal('_Open_'), z.literal('_Pending_'), z.literal('_Authorized_'), z.literal('_Paid_'), z.literal('_Failed_'), z.literal('_Cancelled_'), z.literal('_Expired_'), z.literal('_Refunded_'), z.literal('_Chargeback_')]);
|
|
10
|
+
export const ItemCategorySchema = z.union([z.literal('_Solution_'), z.literal('_Warranty_'), z.literal('_Accessory_'), z.literal('_Training_'), z.literal('_Delivery_')]);
|
|
11
|
+
export const OfferTypeSchema = z.union([z.literal('_Purchase_'), z.literal('_Rental_')]);
|
|
12
|
+
export const PriceRecurrenceSchema = z.union([z.literal('_One_Time_'), z.literal('_Monthly_'), z.literal('_Annually_')]);
|
|
13
|
+
export const PaymentFrequencySchema = z.union([z.literal('_Monthly_'), z.literal('_Annually_')]);
|
|
14
|
+
export const PaymentMethodSchema = z.union([z.literal('_Card_'), z.literal('_PayPal_'), z.literal('_SEPA_'), z.literal('_Alma_4x_')]);
|
|
15
|
+
export const PaymentProviderSchema = z.union([z.literal('_Mollie_'), z.literal('_Alma_')]);
|
|
16
|
+
export const DeliveryMethodSchema = z.union([z.literal('_Standard_'), z.literal('_Express_')]);
|
|
17
|
+
export const DiscountValueTypeSchema = z.union([z.literal('_Percentage_'), z.literal('_Fixed_Amount_')]);
|
|
18
|
+
export const DiscountTargetScopeSchema = z.union([z.literal('_Whole_Cart_'), z.literal('_Specific_Items_'), z.literal('_Item_Category_'), z.literal('_Delivery_')]);
|
|
19
|
+
export const SurfaceSchema = z.union([z.literal('_All_'), z.literal('_Checkout_'), z.literal('_Storefront_')]);
|
|
20
|
+
export const OperationAssetTypeSchema = z.union([z.literal('_Banner_Header_'), z.literal('_Banner_Mini_'), z.literal('_Banner_Sub_Header_'), z.literal('_Hero_'), z.literal('_Popup_Welcome_'), z.literal('_Popup_Operation_'), z.literal('_Popup_Technical_'), z.literal('_Strikethrough_Price_'), z.literal('_Discount_Section_'), z.literal('_Tag_'), z.literal('_Text_Banner_'), z.literal('_Page_Background_')]);
|
|
21
|
+
export const AddressTypeSchema = z.union([z.literal('_Delivery_'), z.literal('_Billing_')]);
|
|
22
|
+
export const AddressConfidenceSchema = z.union([z.literal('_Verified_'), z.literal('_Partial_')]);
|
|
23
|
+
export const TermsTypeSchema = z.union([z.literal('_Terms_Of_Use_'), z.literal('_Terms_Of_Sales_')]);
|
|
24
|
+
export const TestimonialTypeSchema = z.union([z.literal('_Text_'), z.literal('_Image_'), z.literal('_Video_')]);
|
|
25
|
+
export const CartItemSourceSchema = z.union([z.literal('_User_'), z.literal('_System_')]);
|
|
26
|
+
export const AmountSchema = z.object({
|
|
27
|
+
excl: z.number(),
|
|
28
|
+
vat: z.number(),
|
|
29
|
+
incl: z.number(),
|
|
30
|
+
});
|
|
31
|
+
export const GeozoneSchema = z.object({
|
|
32
|
+
id: uuidSchema,
|
|
33
|
+
name: z.string(),
|
|
34
|
+
});
|
|
35
|
+
export const CountrySchema = z.object({
|
|
36
|
+
id: uuidSchema,
|
|
37
|
+
geozone: GeozoneSchema,
|
|
38
|
+
iso: z.string(),
|
|
39
|
+
phonePrefix: z.string(),
|
|
40
|
+
name: z.string(),
|
|
41
|
+
});
|
|
42
|
+
export const StateSchema = z.object({
|
|
43
|
+
id: uuidSchema,
|
|
44
|
+
country: CountrySchema,
|
|
45
|
+
name: z.string(),
|
|
46
|
+
iso: z.string(),
|
|
47
|
+
});
|
|
48
|
+
export const CoordinatesSchema = z.object({
|
|
49
|
+
lat: z.number(),
|
|
50
|
+
lng: z.number(),
|
|
51
|
+
});
|
|
52
|
+
export const AddressSchema = z.object({
|
|
53
|
+
id: uuidSchema,
|
|
54
|
+
stringified: z.string(),
|
|
55
|
+
confidence: AddressConfidenceSchema,
|
|
56
|
+
country: CountrySchema.nullable(),
|
|
57
|
+
state: StateSchema.nullable(),
|
|
58
|
+
alias: z.string().nullable(),
|
|
59
|
+
line: z.string(),
|
|
60
|
+
details: z.string().nullable(),
|
|
61
|
+
postcode: z.string().nullable(),
|
|
62
|
+
city: z.string().nullable(),
|
|
63
|
+
placeId: z.string().nullable(),
|
|
64
|
+
coordinates: CoordinatesSchema.nullable(),
|
|
65
|
+
});
|
|
66
|
+
export const ContactSchema = z.object({
|
|
67
|
+
id: uuidSchema,
|
|
68
|
+
firstName: z.string(),
|
|
69
|
+
lastName: z.string(),
|
|
70
|
+
email: z.string().nullable(),
|
|
71
|
+
phone: z.string().nullable(),
|
|
72
|
+
company: z.string().nullable(),
|
|
73
|
+
vatNumber: z.string().nullable(),
|
|
74
|
+
});
|
|
75
|
+
export const TermsSchema = z.object({
|
|
76
|
+
id: uuidSchema,
|
|
77
|
+
type: TermsTypeSchema,
|
|
78
|
+
lang: LangSchema,
|
|
79
|
+
label: z.string(),
|
|
80
|
+
url: z.string(),
|
|
81
|
+
version: dayjsSchema,
|
|
82
|
+
});
|
|
83
|
+
export const CartTermsAcceptanceSchema = z.object({
|
|
84
|
+
id: uuidSchema,
|
|
85
|
+
termsId: uuidSchema,
|
|
86
|
+
acceptedAt: dayjsSchema,
|
|
87
|
+
});
|
|
88
|
+
export const CartTermsViewSchema = z.object({
|
|
89
|
+
current: z.array(TermsSchema),
|
|
90
|
+
required: z.array(TermsTypeSchema),
|
|
91
|
+
accepted: z.array(CartTermsAcceptanceSchema),
|
|
92
|
+
});
|
|
93
|
+
export const ItemPriceSchema = z.object({
|
|
94
|
+
recurrence: PriceRecurrenceSchema,
|
|
95
|
+
amount: z.number(),
|
|
96
|
+
currency: z.string(),
|
|
97
|
+
});
|
|
98
|
+
export const ItemSchema = z.object({
|
|
99
|
+
id: uuidSchema,
|
|
100
|
+
category: ItemCategorySchema,
|
|
101
|
+
offerType: OfferTypeSchema.nullable(),
|
|
102
|
+
sku: z.string().nullable(),
|
|
103
|
+
name: z.string().nullable(),
|
|
104
|
+
description: z.string().nullable(),
|
|
105
|
+
isMainOffer: z.boolean(),
|
|
106
|
+
visible: z.boolean(),
|
|
107
|
+
maxPerCart: z.number().int().positive().nullable(),
|
|
108
|
+
prices: z.array(ItemPriceSchema),
|
|
109
|
+
allowedProfiles: z.array(ProfileTypeSchema),
|
|
110
|
+
});
|
|
111
|
+
export const CartItemSchema = z.object({
|
|
112
|
+
id: uuidSchema,
|
|
113
|
+
cartId: uuidSchema,
|
|
114
|
+
itemId: uuidSchema,
|
|
115
|
+
quantity: z.number().int().positive(),
|
|
116
|
+
addedBy: CartItemSourceSchema,
|
|
117
|
+
category: ItemCategorySchema,
|
|
118
|
+
offerType: OfferTypeSchema.nullable(),
|
|
119
|
+
sku: z.string().nullable(),
|
|
120
|
+
isMainOffer: z.boolean(),
|
|
121
|
+
visible: z.boolean(),
|
|
122
|
+
maxPerCart: z.number().int().positive().nullable(),
|
|
123
|
+
});
|
|
124
|
+
export const PricingContextSchema = z.object({
|
|
125
|
+
cartId: uuidSchema,
|
|
126
|
+
profile: ProfileTypeSchema.nullable(),
|
|
127
|
+
offerType: OfferTypeSchema.nullable(),
|
|
128
|
+
countryIso: z.string(),
|
|
129
|
+
});
|
|
130
|
+
export const PricingLineSchema = z.object({
|
|
131
|
+
cartItemId: uuidSchema,
|
|
132
|
+
itemId: uuidSchema,
|
|
133
|
+
quantity: z.number().int().positive(),
|
|
134
|
+
category: ItemCategorySchema,
|
|
135
|
+
sku: z.string().nullable(),
|
|
136
|
+
name: z.string().nullable(),
|
|
137
|
+
recurrence: PriceRecurrenceSchema,
|
|
138
|
+
currency: z.string(),
|
|
139
|
+
unit: AmountSchema,
|
|
140
|
+
line: AmountSchema,
|
|
141
|
+
vatRate: z.number(),
|
|
142
|
+
countryIso: z.string(),
|
|
143
|
+
matchKind: z.string().nullable(),
|
|
144
|
+
});
|
|
145
|
+
export const PricingRecurrenceTotalSchema = z.object({
|
|
146
|
+
recurrence: PriceRecurrenceSchema,
|
|
147
|
+
currency: z.string(),
|
|
148
|
+
gross: AmountSchema,
|
|
149
|
+
discount: AmountSchema,
|
|
150
|
+
net: AmountSchema,
|
|
151
|
+
countryIso: z.string(),
|
|
152
|
+
});
|
|
153
|
+
export const AppliedDiscountBucketSchema = z.object({
|
|
154
|
+
excl: z.number(),
|
|
155
|
+
vat: z.number(),
|
|
156
|
+
incl: z.number(),
|
|
157
|
+
});
|
|
158
|
+
export const AppliedDiscountSchema = z.object({
|
|
159
|
+
cartDiscountId: uuidSchema,
|
|
160
|
+
discountId: uuidSchema,
|
|
161
|
+
code: z.string(),
|
|
162
|
+
label: z.string().nullable(),
|
|
163
|
+
targetScope: DiscountTargetScopeSchema,
|
|
164
|
+
valueType: DiscountValueTypeSchema,
|
|
165
|
+
appliesToOneTime: z.boolean(),
|
|
166
|
+
appliesToRecurring: z.boolean(),
|
|
167
|
+
stackable: z.boolean(),
|
|
168
|
+
value: z.number().nullable(),
|
|
169
|
+
byRecurrence: z.record(z.string(), AppliedDiscountBucketSchema),
|
|
170
|
+
});
|
|
171
|
+
export const CartTotalSchema = z.object({
|
|
172
|
+
currency: z.string(),
|
|
173
|
+
oneTime: z.object({
|
|
174
|
+
excl: z.number(),
|
|
175
|
+
incl: z.number(),
|
|
176
|
+
}),
|
|
177
|
+
recurring: z.object({
|
|
178
|
+
excl: z.number(),
|
|
179
|
+
incl: z.number(),
|
|
180
|
+
frequency: PaymentFrequencySchema.nullable(),
|
|
181
|
+
}),
|
|
182
|
+
});
|
|
183
|
+
export const CartPricingSchema = z.object({
|
|
184
|
+
context: PricingContextSchema,
|
|
185
|
+
lines: z.array(PricingLineSchema),
|
|
186
|
+
totalsByRecurrence: z.record(z.string(), PricingRecurrenceTotalSchema),
|
|
187
|
+
appliedDiscounts: z.array(AppliedDiscountSchema),
|
|
188
|
+
total: CartTotalSchema,
|
|
189
|
+
});
|
|
190
|
+
export const CartSchema = z.object({
|
|
191
|
+
id: uuidSchema,
|
|
192
|
+
reference: z.string(),
|
|
193
|
+
secret: z.string(),
|
|
194
|
+
status: CartStatusSchema,
|
|
195
|
+
currentStep: CartStepSchema,
|
|
196
|
+
maxReachedStep: CartStepSchema,
|
|
197
|
+
profile: ProfileTypeSchema.nullable(),
|
|
198
|
+
offerType: OfferTypeSchema.nullable(),
|
|
199
|
+
paymentMethod: PaymentMethodSchema.nullable(),
|
|
200
|
+
paymentFrequency: PaymentFrequencySchema.nullable(),
|
|
201
|
+
deliveryMethod: DeliveryMethodSchema.nullable(),
|
|
202
|
+
devices: z.number().int().nonnegative(),
|
|
203
|
+
locale: LangSchema,
|
|
204
|
+
vatNumber: z.string().nullable(),
|
|
205
|
+
multiAddressesCallback: z.boolean(),
|
|
206
|
+
createdAt: dayjsSchema,
|
|
207
|
+
updatedAt: dayjsSchema,
|
|
208
|
+
});
|
|
209
|
+
export const OrderSchema = z.object({
|
|
210
|
+
id: uuidSchema,
|
|
211
|
+
reference: z.string(),
|
|
212
|
+
secret: z.string(),
|
|
213
|
+
status: OrderStatusSchema,
|
|
214
|
+
cartId: uuidSchema,
|
|
215
|
+
profile: ProfileTypeSchema,
|
|
216
|
+
offerType: OfferTypeSchema,
|
|
217
|
+
paymentFrequency: PaymentFrequencySchema.nullable(),
|
|
218
|
+
deliveryMethod: DeliveryMethodSchema,
|
|
219
|
+
currency: z.string(),
|
|
220
|
+
oneTime: AmountSchema,
|
|
221
|
+
recurring: AmountSchema,
|
|
222
|
+
createdAt: dayjsSchema,
|
|
223
|
+
updatedAt: dayjsSchema,
|
|
224
|
+
});
|
|
225
|
+
export const OperationSummarySchema = z.object({
|
|
226
|
+
id: uuidSchema,
|
|
227
|
+
slug: z.string(),
|
|
228
|
+
name: z.string(),
|
|
229
|
+
description: z.string().nullable(),
|
|
230
|
+
startsAt: dayjsSchema,
|
|
231
|
+
endsAt: dayjsSchema,
|
|
232
|
+
priority: z.number().int(),
|
|
233
|
+
autoApplyDiscount: z.boolean(),
|
|
234
|
+
discountId: uuidSchema.nullable(),
|
|
235
|
+
discountCode: z.string().nullable(),
|
|
236
|
+
discountLabel: z.string().nullable(),
|
|
237
|
+
discountValueType: DiscountValueTypeSchema.nullable(),
|
|
238
|
+
discountValue: z.number().nullable(),
|
|
239
|
+
});
|
|
240
|
+
export const OperationAssetSchema = z.object({
|
|
241
|
+
id: uuidSchema,
|
|
242
|
+
operationId: uuidSchema,
|
|
243
|
+
type: OperationAssetTypeSchema,
|
|
244
|
+
surface: SurfaceSchema,
|
|
245
|
+
lang: LangSchema.nullable(),
|
|
246
|
+
order: z.number().int(),
|
|
247
|
+
pageUrlPattern: z.string().nullable(),
|
|
248
|
+
content: z.unknown(),
|
|
249
|
+
styles: z.unknown().nullable(),
|
|
250
|
+
createdAt: dayjsSchema,
|
|
251
|
+
updatedAt: dayjsSchema,
|
|
252
|
+
});
|
|
253
|
+
export const OperationItemPricingSchema = z.object({
|
|
254
|
+
id: uuidSchema,
|
|
255
|
+
operationId: uuidSchema,
|
|
256
|
+
itemId: uuidSchema,
|
|
257
|
+
profile: ProfileTypeSchema,
|
|
258
|
+
recurrence: PriceRecurrenceSchema,
|
|
259
|
+
originalExclVat: z.number(),
|
|
260
|
+
discountedExclVat: z.number(),
|
|
261
|
+
currency: z.string(),
|
|
262
|
+
sku: z.string().nullable(),
|
|
263
|
+
});
|
|
264
|
+
export const OperationDetailSchema = OperationSummarySchema.extend({
|
|
265
|
+
assets: z.array(OperationAssetSchema),
|
|
266
|
+
itemsPricing: z.array(OperationItemPricingSchema),
|
|
267
|
+
});
|
|
268
|
+
export const TestimonialSchema = z.object({
|
|
269
|
+
id: uuidSchema,
|
|
270
|
+
lang: LangSchema,
|
|
271
|
+
type: TestimonialTypeSchema,
|
|
272
|
+
author: z.string(),
|
|
273
|
+
content: z.string().nullable(),
|
|
274
|
+
altText: z.string().nullable(),
|
|
275
|
+
imageUrl: z.string().nullable(),
|
|
276
|
+
videoUrl: z.string().nullable(),
|
|
277
|
+
rating: z.number().int().min(1).max(5).nullable(),
|
|
278
|
+
publishedAt: dayjsSchema,
|
|
279
|
+
order: z.number().int(),
|
|
280
|
+
});
|
|
281
|
+
export const TestimonialCategorySchema = z.object({
|
|
282
|
+
id: uuidSchema,
|
|
283
|
+
lang: LangSchema,
|
|
284
|
+
name: z.string(),
|
|
285
|
+
order: z.number().int(),
|
|
286
|
+
});
|
|
287
|
+
export const HelpArticleSchema = z.object({
|
|
288
|
+
id: uuidSchema,
|
|
289
|
+
title: z.string(),
|
|
290
|
+
body: z.string(),
|
|
291
|
+
order: z.number().int(),
|
|
292
|
+
});
|
|
293
|
+
export const HelpCategorySchema = z.object({
|
|
294
|
+
id: uuidSchema,
|
|
295
|
+
parentId: uuidSchema.nullable(),
|
|
296
|
+
lang: LangSchema,
|
|
297
|
+
name: z.string(),
|
|
298
|
+
description: z.string().nullable(),
|
|
299
|
+
logoUrl: z.string().nullable(),
|
|
300
|
+
order: z.number().int(),
|
|
301
|
+
articles: z.array(HelpArticleSchema),
|
|
302
|
+
subCategories: z.array(z.lazy(() => HelpCategorySchema)),
|
|
303
|
+
});
|
|
304
|
+
export const HelpPageSchema = z.object({
|
|
305
|
+
id: uuidSchema,
|
|
306
|
+
slug: z.string(),
|
|
307
|
+
name: z.string(),
|
|
308
|
+
createdAt: dayjsSchema,
|
|
309
|
+
});
|
|
310
|
+
export const ContactRequestInputSchema = z.object({
|
|
311
|
+
firstName: z.string().min(1),
|
|
312
|
+
lastName: z.string().min(1),
|
|
313
|
+
email: z.string().email(),
|
|
314
|
+
phone: z.string().min(1),
|
|
315
|
+
company: z.string().nullable().optional(),
|
|
316
|
+
devices: z.number().int().nonnegative().optional(),
|
|
317
|
+
content: z.string().min(1).max(5000),
|
|
318
|
+
captchaToken: z.string().min(1),
|
|
319
|
+
profile: ProfileTypeSchema.optional(),
|
|
320
|
+
locale: LangSchema.optional(),
|
|
321
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lifeaz/lors-helper",
|
|
3
|
+
"description": "Lifeaz Online Retail Storefront Helper",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"versionCode": "200000001",
|
|
6
|
+
"main": "dist/main.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"src/main.ts"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/main.d.ts",
|
|
14
|
+
"bun": "./src/main.ts",
|
|
15
|
+
"import": "./dist/main.js",
|
|
16
|
+
"require": "./dist/main.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"types": "dist/main.d.ts",
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=20"
|
|
23
|
+
},
|
|
24
|
+
"cpu": [
|
|
25
|
+
"x86",
|
|
26
|
+
"x64",
|
|
27
|
+
"arm64"
|
|
28
|
+
],
|
|
29
|
+
"keywords": [
|
|
30
|
+
"lifeaz",
|
|
31
|
+
"lors",
|
|
32
|
+
"helper"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"prepare": "bash ./.scripts/hooks-install.sh",
|
|
36
|
+
"build": "bunx tsc && bunx tsc-alias",
|
|
37
|
+
"prepublishOnly": "bun run build",
|
|
38
|
+
"build:version": "bash ./.scripts/bump.sh",
|
|
39
|
+
"build:version:ensure": "bash ./.scripts/bump.sh --no-build"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"dayjs": "^1.11.20",
|
|
43
|
+
"uuidv7": "^1.2.1",
|
|
44
|
+
"zod": "^4.3.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^24.3.0",
|
|
48
|
+
"rimraf": "^6.0.1",
|
|
49
|
+
"typescript": "^5.8.3",
|
|
50
|
+
"zod": "^4.3.6"
|
|
51
|
+
},
|
|
52
|
+
"lifeaz": {
|
|
53
|
+
"version": {
|
|
54
|
+
"short": 1,
|
|
55
|
+
"full": "1.0.0-b4",
|
|
56
|
+
"code": "100000004"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|