@livex/contracts 0.1.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 +11 -0
- package/dist/chunk-NVGKCJYM.js +83 -0
- package/dist/index.cjs +436 -0
- package/dist/index.d.cts +1277 -0
- package/dist/index.d.ts +1277 -0
- package/dist/index.js +327 -0
- package/dist/validators.cjs +117 -0
- package/dist/validators.d.cts +16 -0
- package/dist/validators.d.ts +16 -0
- package/dist/validators.js +10 -0
- package/messages/booking.confirmed.schema.json +35 -0
- package/messages/webhook.payment.received.schema.json +17 -0
- package/openapi/livex.v1.json +303 -0
- package/package.json +51 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import {
|
|
2
|
+
booking_confirmed_schema_default,
|
|
3
|
+
validateBookingConfirmed,
|
|
4
|
+
validateWebhookPaymentReceived,
|
|
5
|
+
validators,
|
|
6
|
+
webhook_payment_received_schema_default
|
|
7
|
+
} from "./chunk-NVGKCJYM.js";
|
|
8
|
+
|
|
9
|
+
// openapi/livex.v1.json
|
|
10
|
+
var livex_v1_default = {
|
|
11
|
+
openapi: "3.1.0",
|
|
12
|
+
info: {
|
|
13
|
+
title: "LIVEX API",
|
|
14
|
+
version: "1.0.0",
|
|
15
|
+
description: "Contratos v1 del MVP: cat\xE1logo, disponibilidad, bookings y webhooks de pago.",
|
|
16
|
+
license: { name: "MIT", url: "https://opensource.org/licenses/MIT" }
|
|
17
|
+
},
|
|
18
|
+
servers: [{ url: "https://api.livex.app/v1" }],
|
|
19
|
+
security: [
|
|
20
|
+
{ BearerAuth: [] }
|
|
21
|
+
],
|
|
22
|
+
paths: {
|
|
23
|
+
"/experiences": {
|
|
24
|
+
get: {
|
|
25
|
+
summary: "Listar experiencias",
|
|
26
|
+
operationId: "listExperiences",
|
|
27
|
+
security: [],
|
|
28
|
+
parameters: [
|
|
29
|
+
{ name: "q", in: "query", schema: { type: "string" } },
|
|
30
|
+
{ name: "categoryId", in: "query", schema: { type: "string", format: "uuid" } },
|
|
31
|
+
{ name: "limit", in: "query", schema: { type: "integer", minimum: 1, maximum: 100, default: 20 } },
|
|
32
|
+
{ name: "offset", in: "query", schema: { type: "integer", minimum: 0, default: 0 } }
|
|
33
|
+
],
|
|
34
|
+
responses: {
|
|
35
|
+
"200": {
|
|
36
|
+
description: "OK",
|
|
37
|
+
content: {
|
|
38
|
+
"application/json": {
|
|
39
|
+
schema: {
|
|
40
|
+
type: "object",
|
|
41
|
+
properties: {
|
|
42
|
+
items: { type: "array", items: { $ref: "#/components/schemas/ExperienceSummary" } },
|
|
43
|
+
total: { type: "integer" }
|
|
44
|
+
},
|
|
45
|
+
required: ["items", "total"]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"/experiences/{experienceId}": {
|
|
55
|
+
get: {
|
|
56
|
+
summary: "Detalle de experiencia",
|
|
57
|
+
operationId: "getExperience",
|
|
58
|
+
security: [],
|
|
59
|
+
parameters: [
|
|
60
|
+
{ name: "experienceId", in: "path", required: true, schema: { type: "string", format: "uuid" } }
|
|
61
|
+
],
|
|
62
|
+
responses: {
|
|
63
|
+
"200": {
|
|
64
|
+
description: "OK",
|
|
65
|
+
content: { "application/json": { schema: { $ref: "#/components/schemas/Experience" } } }
|
|
66
|
+
},
|
|
67
|
+
"400": { $ref: "#/components/responses/BadRequest" },
|
|
68
|
+
"404": { $ref: "#/components/responses/NotFound" }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"/availability": {
|
|
73
|
+
get: {
|
|
74
|
+
summary: "Consultar disponibilidad por experiencia y fecha",
|
|
75
|
+
operationId: "getAvailability",
|
|
76
|
+
security: [],
|
|
77
|
+
parameters: [
|
|
78
|
+
{ name: "experienceId", in: "query", required: true, schema: { type: "string", format: "uuid" } },
|
|
79
|
+
{ name: "date", in: "query", required: true, schema: { type: "string", format: "date" } }
|
|
80
|
+
],
|
|
81
|
+
responses: {
|
|
82
|
+
"200": {
|
|
83
|
+
description: "OK",
|
|
84
|
+
content: {
|
|
85
|
+
"application/json": {
|
|
86
|
+
schema: { type: "array", items: { $ref: "#/components/schemas/AvailabilitySlot" } }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"400": { $ref: "#/components/responses/BadRequest" }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"/bookings": {
|
|
95
|
+
post: {
|
|
96
|
+
summary: "Crear booking (pending + lock de inventario)",
|
|
97
|
+
operationId: "createBooking",
|
|
98
|
+
parameters: [
|
|
99
|
+
{
|
|
100
|
+
name: "Idempotency-Key",
|
|
101
|
+
in: "header",
|
|
102
|
+
required: true,
|
|
103
|
+
description: "Requerido para evitar duplicados en creaci\xF3n.",
|
|
104
|
+
schema: { type: "string", maxLength: 128 }
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
requestBody: {
|
|
108
|
+
required: true,
|
|
109
|
+
content: { "application/json": { schema: { $ref: "#/components/schemas/CreateBookingInput" } } }
|
|
110
|
+
},
|
|
111
|
+
responses: {
|
|
112
|
+
"201": {
|
|
113
|
+
description: "Creado",
|
|
114
|
+
headers: {
|
|
115
|
+
Location: { schema: { type: "string" }, description: "URL del booking creado." }
|
|
116
|
+
},
|
|
117
|
+
content: { "application/json": { schema: { $ref: "#/components/schemas/Booking" } } }
|
|
118
|
+
},
|
|
119
|
+
"400": { $ref: "#/components/responses/BadRequest" },
|
|
120
|
+
"409": { $ref: "#/components/responses/Conflict" },
|
|
121
|
+
"422": { $ref: "#/components/responses/UnprocessableEntity" }
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"/bookings/{bookingId}": {
|
|
126
|
+
get: {
|
|
127
|
+
summary: "Obtener booking por ID",
|
|
128
|
+
operationId: "getBooking",
|
|
129
|
+
parameters: [
|
|
130
|
+
{ name: "bookingId", in: "path", required: true, schema: { type: "string", format: "uuid" } }
|
|
131
|
+
],
|
|
132
|
+
responses: {
|
|
133
|
+
"200": { description: "OK", content: { "application/json": { schema: { $ref: "#/components/schemas/Booking" } } } },
|
|
134
|
+
"400": { $ref: "#/components/responses/BadRequest" },
|
|
135
|
+
"404": { $ref: "#/components/responses/NotFound" }
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"/webhooks/payments/{provider}": {
|
|
140
|
+
post: {
|
|
141
|
+
summary: "Webhook de pagos (firma validada por API)",
|
|
142
|
+
operationId: "paymentsWebhook",
|
|
143
|
+
security: [],
|
|
144
|
+
parameters: [
|
|
145
|
+
{ name: "provider", in: "path", required: true, schema: { type: "string", enum: ["wompi", "epayco", "other"] } }
|
|
146
|
+
],
|
|
147
|
+
requestBody: {
|
|
148
|
+
required: true,
|
|
149
|
+
content: {
|
|
150
|
+
"application/json": { schema: { $ref: "#/components/schemas/PaymentWebhookPayload" } }
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
responses: {
|
|
154
|
+
"202": { description: "Aceptado para procesamiento as\xEDncrono" },
|
|
155
|
+
"400": { $ref: "#/components/responses/BadRequest" },
|
|
156
|
+
"401": { $ref: "#/components/responses/Unauthorized" }
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
components: {
|
|
162
|
+
securitySchemes: {
|
|
163
|
+
BearerAuth: {
|
|
164
|
+
type: "http",
|
|
165
|
+
scheme: "bearer",
|
|
166
|
+
bearerFormat: "JWT"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
schemas: {
|
|
170
|
+
UUID: { type: "string", format: "uuid" },
|
|
171
|
+
Money: {
|
|
172
|
+
type: "object",
|
|
173
|
+
properties: {
|
|
174
|
+
amount: { type: "integer", minimum: 0, description: "Centavos" },
|
|
175
|
+
currency: { type: "string", minLength: 3, maxLength: 3, example: "COP" }
|
|
176
|
+
},
|
|
177
|
+
required: ["amount", "currency"],
|
|
178
|
+
additionalProperties: false
|
|
179
|
+
},
|
|
180
|
+
ExperienceSummary: {
|
|
181
|
+
type: "object",
|
|
182
|
+
properties: {
|
|
183
|
+
id: { $ref: "#/components/schemas/UUID" },
|
|
184
|
+
title: { type: "string" },
|
|
185
|
+
coverImageUrl: { type: "string", format: "uri" },
|
|
186
|
+
city: { type: "string" },
|
|
187
|
+
country: { type: "string" },
|
|
188
|
+
ratingAvg: { type: "number", minimum: 0, maximum: 5 },
|
|
189
|
+
ratingCount: { type: "integer", minimum: 0 },
|
|
190
|
+
fromPrice: { $ref: "#/components/schemas/Money" }
|
|
191
|
+
},
|
|
192
|
+
required: ["id", "title", "fromPrice"]
|
|
193
|
+
},
|
|
194
|
+
Experience: {
|
|
195
|
+
allOf: [
|
|
196
|
+
{ $ref: "#/components/schemas/ExperienceSummary" },
|
|
197
|
+
{
|
|
198
|
+
type: "object",
|
|
199
|
+
properties: {
|
|
200
|
+
description: { type: "string" },
|
|
201
|
+
includes: { type: "array", items: { type: "string" } },
|
|
202
|
+
notIncludes: { type: "array", items: { type: "string" } },
|
|
203
|
+
images: { type: "array", items: { type: "string", format: "uri" } },
|
|
204
|
+
status: { type: "string", enum: ["draft", "under_review", "active", "rejected"] }
|
|
205
|
+
},
|
|
206
|
+
required: ["status"]
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
},
|
|
210
|
+
AvailabilitySlot: {
|
|
211
|
+
type: "object",
|
|
212
|
+
properties: {
|
|
213
|
+
slotId: { $ref: "#/components/schemas/UUID" },
|
|
214
|
+
start: { type: "string", format: "date-time" },
|
|
215
|
+
end: { type: "string", format: "date-time" },
|
|
216
|
+
capacity: { type: "integer", minimum: 1 },
|
|
217
|
+
remaining: { type: "integer", minimum: 0 },
|
|
218
|
+
price: { $ref: "#/components/schemas/Money" }
|
|
219
|
+
},
|
|
220
|
+
required: ["slotId", "start", "end", "capacity", "remaining", "price"]
|
|
221
|
+
},
|
|
222
|
+
CreateBookingInput: {
|
|
223
|
+
type: "object",
|
|
224
|
+
properties: {
|
|
225
|
+
experienceId: { $ref: "#/components/schemas/UUID" },
|
|
226
|
+
slotId: { $ref: "#/components/schemas/UUID" },
|
|
227
|
+
quantity: { type: "integer", minimum: 1 },
|
|
228
|
+
buyer: {
|
|
229
|
+
type: "object",
|
|
230
|
+
properties: {
|
|
231
|
+
fullName: { type: "string" },
|
|
232
|
+
email: { type: "string", format: "email" },
|
|
233
|
+
phone: { type: "string" }
|
|
234
|
+
},
|
|
235
|
+
required: ["fullName", "email"]
|
|
236
|
+
},
|
|
237
|
+
payment: {
|
|
238
|
+
type: "object",
|
|
239
|
+
properties: {
|
|
240
|
+
method: { type: "string", enum: ["card", "pse", "cash", "other"] },
|
|
241
|
+
provider: { type: "string", enum: ["wompi", "epayco", "other"] }
|
|
242
|
+
},
|
|
243
|
+
required: ["method", "provider"]
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
required: ["experienceId", "slotId", "quantity", "buyer", "payment"],
|
|
247
|
+
additionalProperties: false
|
|
248
|
+
},
|
|
249
|
+
Booking: {
|
|
250
|
+
type: "object",
|
|
251
|
+
properties: {
|
|
252
|
+
id: { $ref: "#/components/schemas/UUID" },
|
|
253
|
+
status: { type: "string", enum: ["pending", "confirmed", "completed", "cancelled", "refunded", "expired"] },
|
|
254
|
+
experienceId: { $ref: "#/components/schemas/UUID" },
|
|
255
|
+
slotId: { $ref: "#/components/schemas/UUID" },
|
|
256
|
+
quantity: { type: "integer", minimum: 1 },
|
|
257
|
+
total: { $ref: "#/components/schemas/Money" },
|
|
258
|
+
createdAt: { type: "string", format: "date-time" }
|
|
259
|
+
},
|
|
260
|
+
required: ["id", "status", "experienceId", "slotId", "quantity", "total", "createdAt"]
|
|
261
|
+
},
|
|
262
|
+
PaymentWebhookPayload: {
|
|
263
|
+
type: "object",
|
|
264
|
+
properties: {
|
|
265
|
+
event: { type: "string", example: "transaction.updated" },
|
|
266
|
+
data: {
|
|
267
|
+
type: "object",
|
|
268
|
+
properties: {
|
|
269
|
+
providerRef: { type: "string" },
|
|
270
|
+
status: { type: "string", enum: ["APPROVED", "DECLINED", "VOIDED", "ERROR", "PENDING"] },
|
|
271
|
+
amountInCents: { type: "integer", minimum: 0 },
|
|
272
|
+
currency: { type: "string", minLength: 3, maxLength: 3 },
|
|
273
|
+
bookingId: { type: "string", format: "uuid", description: "Opcional si el flujo incluye referencia directa al booking." }
|
|
274
|
+
},
|
|
275
|
+
required: ["providerRef", "status", "amountInCents", "currency"]
|
|
276
|
+
},
|
|
277
|
+
sentAt: { type: "string", format: "date-time" }
|
|
278
|
+
},
|
|
279
|
+
required: ["event", "data"]
|
|
280
|
+
},
|
|
281
|
+
Error: {
|
|
282
|
+
type: "object",
|
|
283
|
+
properties: {
|
|
284
|
+
error_code: { type: "string" },
|
|
285
|
+
message: { type: "string" },
|
|
286
|
+
details: { type: ["object", "null"] }
|
|
287
|
+
},
|
|
288
|
+
required: ["error_code", "message"]
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
responses: {
|
|
292
|
+
BadRequest: {
|
|
293
|
+
description: "Solicitud inv\xE1lida",
|
|
294
|
+
content: { "application/json": { schema: { $ref: "#/components/schemas/Error" } } }
|
|
295
|
+
},
|
|
296
|
+
Unauthorized: { description: "No autorizado" },
|
|
297
|
+
NotFound: {
|
|
298
|
+
description: "No encontrado",
|
|
299
|
+
content: { "application/json": { schema: { $ref: "#/components/schemas/Error" } } }
|
|
300
|
+
},
|
|
301
|
+
Conflict: {
|
|
302
|
+
description: "Conflicto (idempotencia, duplicado, etc.)",
|
|
303
|
+
content: { "application/json": { schema: { $ref: "#/components/schemas/Error" } } }
|
|
304
|
+
},
|
|
305
|
+
UnprocessableEntity: {
|
|
306
|
+
description: "Validaci\xF3n fallida",
|
|
307
|
+
content: { "application/json": { schema: { $ref: "#/components/schemas/Error" } } }
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
// src/types.db.ts
|
|
314
|
+
var types_db_exports = {};
|
|
315
|
+
|
|
316
|
+
// src/index.ts
|
|
317
|
+
var BookingConfirmed = booking_confirmed_schema_default;
|
|
318
|
+
var WebhookPaymentReceived = webhook_payment_received_schema_default;
|
|
319
|
+
export {
|
|
320
|
+
BookingConfirmed,
|
|
321
|
+
types_db_exports as DB,
|
|
322
|
+
WebhookPaymentReceived,
|
|
323
|
+
livex_v1_default as openapi,
|
|
324
|
+
validateBookingConfirmed,
|
|
325
|
+
validateWebhookPaymentReceived,
|
|
326
|
+
validators
|
|
327
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
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/validators.ts
|
|
31
|
+
var validators_exports = {};
|
|
32
|
+
__export(validators_exports, {
|
|
33
|
+
validateBookingConfirmed: () => validateBookingConfirmed,
|
|
34
|
+
validateWebhookPaymentReceived: () => validateWebhookPaymentReceived,
|
|
35
|
+
validators: () => validators
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(validators_exports);
|
|
38
|
+
var import_ajv = __toESM(require("ajv"), 1);
|
|
39
|
+
var import_ajv_formats = __toESM(require("ajv-formats"), 1);
|
|
40
|
+
|
|
41
|
+
// messages/booking.confirmed.schema.json
|
|
42
|
+
var booking_confirmed_schema_default = {
|
|
43
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
44
|
+
$id: "https://contracts.livex.app/messages/booking.confirmed.schema.json",
|
|
45
|
+
title: "booking.confirmed",
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: {
|
|
48
|
+
eventType: { const: "booking.confirmed" },
|
|
49
|
+
eventId: { type: "string", format: "uuid" },
|
|
50
|
+
occurredAt: { type: "string", format: "date-time" },
|
|
51
|
+
booking: {
|
|
52
|
+
type: "object",
|
|
53
|
+
properties: {
|
|
54
|
+
id: { type: "string", format: "uuid" },
|
|
55
|
+
experienceId: { type: "string", format: "uuid" },
|
|
56
|
+
slotId: { type: "string", format: "uuid" },
|
|
57
|
+
quantity: { type: "integer", minimum: 1 },
|
|
58
|
+
totalInCents: { type: "integer", minimum: 0 },
|
|
59
|
+
currency: { type: "string", minLength: 3, maxLength: 3 }
|
|
60
|
+
},
|
|
61
|
+
required: ["id", "experienceId", "slotId", "quantity", "totalInCents", "currency"]
|
|
62
|
+
},
|
|
63
|
+
payment: {
|
|
64
|
+
type: "object",
|
|
65
|
+
properties: {
|
|
66
|
+
provider: { type: "string" },
|
|
67
|
+
providerRef: { type: "string" }
|
|
68
|
+
},
|
|
69
|
+
required: ["provider", "providerRef"]
|
|
70
|
+
},
|
|
71
|
+
request_id: { type: "string" }
|
|
72
|
+
},
|
|
73
|
+
required: ["eventType", "eventId", "occurredAt", "booking", "payment"],
|
|
74
|
+
additionalProperties: false
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// messages/webhook.payment.received.schema.json
|
|
78
|
+
var webhook_payment_received_schema_default = {
|
|
79
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
80
|
+
$id: "https://contracts.livex.app/messages/webhook.payment.received.schema.json",
|
|
81
|
+
title: "webhook.payment.received",
|
|
82
|
+
type: "object",
|
|
83
|
+
properties: {
|
|
84
|
+
eventType: { const: "webhook.payment.received" },
|
|
85
|
+
eventId: { type: "string", format: "uuid" },
|
|
86
|
+
provider: { type: "string", enum: ["wompi", "epayco", "other"] },
|
|
87
|
+
provider_event_id: { type: "string" },
|
|
88
|
+
payload: { type: "object" },
|
|
89
|
+
receivedAt: { type: "string", format: "date-time" }
|
|
90
|
+
},
|
|
91
|
+
required: ["eventType", "eventId", "provider", "provider_event_id", "payload", "receivedAt"],
|
|
92
|
+
additionalProperties: false
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// src/validators.ts
|
|
96
|
+
var ajv = new import_ajv.default({ allErrors: true, strict: true });
|
|
97
|
+
(0, import_ajv_formats.default)(ajv);
|
|
98
|
+
var _validateBookingConfirmed = ajv.compile(booking_confirmed_schema_default);
|
|
99
|
+
var _validateWebhookPaymentReceived = ajv.compile(webhook_payment_received_schema_default);
|
|
100
|
+
function validateBookingConfirmed(payload) {
|
|
101
|
+
const ok = _validateBookingConfirmed(payload);
|
|
102
|
+
return { ok, errors: _validateBookingConfirmed.errors ?? null };
|
|
103
|
+
}
|
|
104
|
+
function validateWebhookPaymentReceived(payload) {
|
|
105
|
+
const ok = _validateWebhookPaymentReceived(payload);
|
|
106
|
+
return { ok, errors: _validateWebhookPaymentReceived.errors ?? null };
|
|
107
|
+
}
|
|
108
|
+
var validators = {
|
|
109
|
+
bookingConfirmed: validateBookingConfirmed,
|
|
110
|
+
webhookPaymentReceived: validateWebhookPaymentReceived
|
|
111
|
+
};
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
validateBookingConfirmed,
|
|
115
|
+
validateWebhookPaymentReceived,
|
|
116
|
+
validators
|
|
117
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as ajv from 'ajv';
|
|
2
|
+
|
|
3
|
+
declare function validateBookingConfirmed(payload: unknown): {
|
|
4
|
+
ok: boolean;
|
|
5
|
+
errors: ajv.ErrorObject<string, Record<string, any>, unknown>[] | null;
|
|
6
|
+
};
|
|
7
|
+
declare function validateWebhookPaymentReceived(payload: unknown): {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
errors: ajv.ErrorObject<string, Record<string, any>, unknown>[] | null;
|
|
10
|
+
};
|
|
11
|
+
declare const validators: {
|
|
12
|
+
bookingConfirmed: typeof validateBookingConfirmed;
|
|
13
|
+
webhookPaymentReceived: typeof validateWebhookPaymentReceived;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { validateBookingConfirmed, validateWebhookPaymentReceived, validators };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as ajv from 'ajv';
|
|
2
|
+
|
|
3
|
+
declare function validateBookingConfirmed(payload: unknown): {
|
|
4
|
+
ok: boolean;
|
|
5
|
+
errors: ajv.ErrorObject<string, Record<string, any>, unknown>[] | null;
|
|
6
|
+
};
|
|
7
|
+
declare function validateWebhookPaymentReceived(payload: unknown): {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
errors: ajv.ErrorObject<string, Record<string, any>, unknown>[] | null;
|
|
10
|
+
};
|
|
11
|
+
declare const validators: {
|
|
12
|
+
bookingConfirmed: typeof validateBookingConfirmed;
|
|
13
|
+
webhookPaymentReceived: typeof validateWebhookPaymentReceived;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { validateBookingConfirmed, validateWebhookPaymentReceived, validators };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://contracts.livex.app/messages/booking.confirmed.schema.json",
|
|
4
|
+
"title": "booking.confirmed",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"eventType": { "const": "booking.confirmed" },
|
|
8
|
+
"eventId": { "type": "string", "format": "uuid" },
|
|
9
|
+
"occurredAt": { "type": "string", "format": "date-time" },
|
|
10
|
+
"booking": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"properties": {
|
|
13
|
+
"id": { "type": "string", "format": "uuid" },
|
|
14
|
+
"experienceId": { "type": "string", "format": "uuid" },
|
|
15
|
+
"slotId": { "type": "string", "format": "uuid" },
|
|
16
|
+
"quantity": { "type": "integer", "minimum": 1 },
|
|
17
|
+
"totalInCents": { "type": "integer", "minimum": 0 },
|
|
18
|
+
"currency": { "type": "string", "minLength": 3, "maxLength": 3 }
|
|
19
|
+
},
|
|
20
|
+
"required": ["id","experienceId","slotId","quantity","totalInCents","currency"]
|
|
21
|
+
},
|
|
22
|
+
"payment": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"properties": {
|
|
25
|
+
"provider": { "type": "string" },
|
|
26
|
+
"providerRef": { "type": "string" }
|
|
27
|
+
},
|
|
28
|
+
"required": ["provider","providerRef"]
|
|
29
|
+
},
|
|
30
|
+
"request_id": { "type": "string" }
|
|
31
|
+
},
|
|
32
|
+
"required": ["eventType","eventId","occurredAt","booking","payment"],
|
|
33
|
+
"additionalProperties": false
|
|
34
|
+
}
|
|
35
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://contracts.livex.app/messages/webhook.payment.received.schema.json",
|
|
4
|
+
"title": "webhook.payment.received",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"eventType": { "const": "webhook.payment.received" },
|
|
8
|
+
"eventId": { "type": "string", "format": "uuid" },
|
|
9
|
+
"provider": { "type": "string", "enum": ["wompi","epayco","other"] },
|
|
10
|
+
"provider_event_id": { "type": "string" },
|
|
11
|
+
"payload": { "type": "object" },
|
|
12
|
+
"receivedAt": { "type": "string", "format": "date-time" }
|
|
13
|
+
},
|
|
14
|
+
"required": ["eventType","eventId","provider","provider_event_id","payload","receivedAt"],
|
|
15
|
+
"additionalProperties": false
|
|
16
|
+
}
|
|
17
|
+
|