@voyant-travel/distribution 0.109.8
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/LICENSE +201 -0
- package/README.md +42 -0
- package/dist/booking-extension.d.ts +168 -0
- package/dist/booking-extension.d.ts.map +1 -0
- package/dist/booking-extension.js +102 -0
- package/dist/channel-push/admin-routes.d.ts +31 -0
- package/dist/channel-push/admin-routes.d.ts.map +1 -0
- package/dist/channel-push/admin-routes.js +165 -0
- package/dist/channel-push/availability-push.d.ts +76 -0
- package/dist/channel-push/availability-push.d.ts.map +1 -0
- package/dist/channel-push/availability-push.js +236 -0
- package/dist/channel-push/booking-push-helpers.d.ts +36 -0
- package/dist/channel-push/booking-push-helpers.d.ts.map +1 -0
- package/dist/channel-push/booking-push-helpers.js +169 -0
- package/dist/channel-push/booking-push.d.ts +108 -0
- package/dist/channel-push/booking-push.d.ts.map +1 -0
- package/dist/channel-push/booking-push.js +335 -0
- package/dist/channel-push/boundary-sql.d.ts +23 -0
- package/dist/channel-push/boundary-sql.d.ts.map +1 -0
- package/dist/channel-push/boundary-sql.js +75 -0
- package/dist/channel-push/content-push.d.ts +60 -0
- package/dist/channel-push/content-push.d.ts.map +1 -0
- package/dist/channel-push/content-push.js +252 -0
- package/dist/channel-push/index.d.ts +15 -0
- package/dist/channel-push/index.d.ts.map +1 -0
- package/dist/channel-push/index.js +18 -0
- package/dist/channel-push/plugin.d.ts +18 -0
- package/dist/channel-push/plugin.d.ts.map +1 -0
- package/dist/channel-push/plugin.js +21 -0
- package/dist/channel-push/reconciler.d.ts +85 -0
- package/dist/channel-push/reconciler.d.ts.map +1 -0
- package/dist/channel-push/reconciler.js +179 -0
- package/dist/channel-push/subscriber.d.ts +40 -0
- package/dist/channel-push/subscriber.d.ts.map +1 -0
- package/dist/channel-push/subscriber.js +199 -0
- package/dist/channel-push/types.d.ts +43 -0
- package/dist/channel-push/types.d.ts.map +1 -0
- package/dist/channel-push/types.js +32 -0
- package/dist/channel-push/workflows.d.ts +56 -0
- package/dist/channel-push/workflows.d.ts.map +1 -0
- package/dist/channel-push/workflows.js +100 -0
- package/dist/external-refs/index.d.ts +11 -0
- package/dist/external-refs/index.d.ts.map +1 -0
- package/dist/external-refs/index.js +12 -0
- package/dist/external-refs/routes.d.ts +253 -0
- package/dist/external-refs/routes.d.ts.map +1 -0
- package/dist/external-refs/routes.js +52 -0
- package/dist/external-refs/schema.d.ts +251 -0
- package/dist/external-refs/schema.d.ts.map +1 -0
- package/dist/external-refs/schema.js +32 -0
- package/dist/external-refs/service.d.ts +82 -0
- package/dist/external-refs/service.d.ts.map +1 -0
- package/dist/external-refs/service.js +112 -0
- package/dist/external-refs/validation.d.ts +91 -0
- package/dist/external-refs/validation.d.ts.map +1 -0
- package/dist/external-refs/validation.js +40 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/interface-types.d.ts +128 -0
- package/dist/interface-types.d.ts.map +1 -0
- package/dist/interface-types.js +1 -0
- package/dist/interface.d.ts +10 -0
- package/dist/interface.d.ts.map +1 -0
- package/dist/interface.js +286 -0
- package/dist/rate-limit.d.ts +69 -0
- package/dist/rate-limit.d.ts.map +1 -0
- package/dist/rate-limit.js +135 -0
- package/dist/routes/batch.d.ts +200 -0
- package/dist/routes/batch.d.ts.map +1 -0
- package/dist/routes/batch.js +52 -0
- package/dist/routes/env.d.ts +8 -0
- package/dist/routes/env.d.ts.map +1 -0
- package/dist/routes/env.js +1 -0
- package/dist/routes/inventory.d.ts +604 -0
- package/dist/routes/inventory.d.ts.map +1 -0
- package/dist/routes/inventory.js +138 -0
- package/dist/routes/settlements.d.ts +1649 -0
- package/dist/routes/settlements.d.ts.map +1 -0
- package/dist/routes/settlements.js +265 -0
- package/dist/routes.d.ts +3909 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +323 -0
- package/dist/schema-automation.d.ts +680 -0
- package/dist/schema-automation.d.ts.map +1 -0
- package/dist/schema-automation.js +76 -0
- package/dist/schema-core.d.ts +1674 -0
- package/dist/schema-core.d.ts.map +1 -0
- package/dist/schema-core.js +227 -0
- package/dist/schema-finance.d.ts +1372 -0
- package/dist/schema-finance.d.ts.map +1 -0
- package/dist/schema-finance.js +153 -0
- package/dist/schema-inventory.d.ts +855 -0
- package/dist/schema-inventory.d.ts.map +1 -0
- package/dist/schema-inventory.js +102 -0
- package/dist/schema-push-intents.d.ts +387 -0
- package/dist/schema-push-intents.d.ts.map +1 -0
- package/dist/schema-push-intents.js +77 -0
- package/dist/schema-relations.d.ts +95 -0
- package/dist/schema-relations.d.ts.map +1 -0
- package/dist/schema-relations.js +196 -0
- package/dist/schema-shared.d.ts +24 -0
- package/dist/schema-shared.d.ts.map +1 -0
- package/dist/schema-shared.js +123 -0
- package/dist/schema.d.ts +9 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +8 -0
- package/dist/service/channels.d.ts +167 -0
- package/dist/service/channels.d.ts.map +1 -0
- package/dist/service/channels.js +305 -0
- package/dist/service/commercial.d.ts +385 -0
- package/dist/service/commercial.d.ts.map +1 -0
- package/dist/service/commercial.js +248 -0
- package/dist/service/helpers.d.ts +10 -0
- package/dist/service/helpers.d.ts.map +1 -0
- package/dist/service/helpers.js +7 -0
- package/dist/service/inventory.d.ts +193 -0
- package/dist/service/inventory.d.ts.map +1 -0
- package/dist/service/inventory.js +154 -0
- package/dist/service/settlement-policies.d.ts +325 -0
- package/dist/service/settlement-policies.d.ts.map +1 -0
- package/dist/service/settlement-policies.js +272 -0
- package/dist/service/settlements.d.ts +357 -0
- package/dist/service/settlements.d.ts.map +1 -0
- package/dist/service/settlements.js +319 -0
- package/dist/service/types.d.ts +60 -0
- package/dist/service/types.d.ts.map +1 -0
- package/dist/service/types.js +1 -0
- package/dist/service.d.ts +1418 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +17 -0
- package/dist/suppliers/index.d.ts +15 -0
- package/dist/suppliers/index.d.ts.map +1 -0
- package/dist/suppliers/index.js +23 -0
- package/dist/suppliers/routes.d.ts +1202 -0
- package/dist/suppliers/routes.d.ts.map +1 -0
- package/dist/suppliers/routes.js +290 -0
- package/dist/suppliers/schema.d.ts +1272 -0
- package/dist/suppliers/schema.d.ts.map +1 -0
- package/dist/suppliers/schema.js +219 -0
- package/dist/suppliers/service-aggregates.d.ts +23 -0
- package/dist/suppliers/service-aggregates.d.ts.map +1 -0
- package/dist/suppliers/service-aggregates.js +51 -0
- package/dist/suppliers/service-core.d.ts +89 -0
- package/dist/suppliers/service-core.d.ts.map +1 -0
- package/dist/suppliers/service-core.js +164 -0
- package/dist/suppliers/service-identity.d.ts +162 -0
- package/dist/suppliers/service-identity.d.ts.map +1 -0
- package/dist/suppliers/service-identity.js +101 -0
- package/dist/suppliers/service-operations.d.ts +1500 -0
- package/dist/suppliers/service-operations.d.ts.map +1 -0
- package/dist/suppliers/service-operations.js +157 -0
- package/dist/suppliers/service-shared.d.ts +45 -0
- package/dist/suppliers/service-shared.d.ts.map +1 -0
- package/dist/suppliers/service-shared.js +294 -0
- package/dist/suppliers/service.d.ts +41 -0
- package/dist/suppliers/service.d.ts.map +1 -0
- package/dist/suppliers/service.js +40 -0
- package/dist/suppliers/validation.d.ts +2 -0
- package/dist/suppliers/validation.d.ts.map +1 -0
- package/dist/suppliers/validation.js +1 -0
- package/dist/validation.d.ts +1371 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +445 -0
- package/dist/webhook-deliveries.d.ts +86 -0
- package/dist/webhook-deliveries.d.ts.map +1 -0
- package/dist/webhook-deliveries.js +296 -0
- package/package.json +71 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAUvB,eAAO,MAAM,iBAAiB;;;;;;;;EAQ5B,CAAA;AACF,eAAO,MAAM,mBAAmB;;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;;;;;;;;;;;;;;iBAW/C,CAAA;AACF,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;iBAAuC,CAAA;AAC1F,eAAO,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;iBAAiD,CAAA;AACpG,eAAO,MAAM,yCAAyC;;;;;;;;;;;;iBAKpD,CAAA;AAEF,eAAO,MAAM,mCAAmC;;;;;;;;;;;iBAO9C,CAAA;AACF,eAAO,MAAM,qCAAqC;;;;;;;;;;;iBAAsC,CAAA;AACxF,eAAO,MAAM,qCAAqC;;;;;;;;;;;iBAAgD,CAAA;AAClG,eAAO,MAAM,wCAAwC;;;;;;;;;iBAGnD,CAAA"}
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { booleanQueryParam } from "@voyant-travel/db/helpers";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const paginationSchema = z.object({
|
|
4
|
+
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
5
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
6
|
+
});
|
|
7
|
+
const isoDateSchema = z.string().date();
|
|
8
|
+
const isoDateTimeSchema = z.string().datetime();
|
|
9
|
+
export const channelKindSchema = z.enum([
|
|
10
|
+
"direct",
|
|
11
|
+
"affiliate",
|
|
12
|
+
"ota",
|
|
13
|
+
"reseller",
|
|
14
|
+
"marketplace",
|
|
15
|
+
"api_partner",
|
|
16
|
+
"connect",
|
|
17
|
+
]);
|
|
18
|
+
export const channelStatusSchema = z.enum(["active", "inactive", "pending", "archived"]);
|
|
19
|
+
export const channelContractStatusSchema = z.enum(["draft", "active", "expired", "terminated"]);
|
|
20
|
+
export const distributionPaymentOwnerSchema = z.enum(["operator", "channel", "split"]);
|
|
21
|
+
export const distributionCancellationOwnerSchema = z.enum(["operator", "channel", "mixed"]);
|
|
22
|
+
export const channelCommissionScopeSchema = z.enum(["booking", "product", "rate", "category"]);
|
|
23
|
+
export const channelCommissionTypeSchema = z.enum(["fixed", "percentage"]);
|
|
24
|
+
export const channelWebhookStatusSchema = z.enum(["pending", "processed", "failed", "ignored"]);
|
|
25
|
+
export const channelAllotmentReleaseModeSchema = z.enum(["automatic", "manual"]);
|
|
26
|
+
export const channelAllotmentUnsoldActionSchema = z.enum([
|
|
27
|
+
"release_to_general_pool",
|
|
28
|
+
"expire",
|
|
29
|
+
"retain",
|
|
30
|
+
]);
|
|
31
|
+
export const channelSettlementRunStatusSchema = z.enum(["draft", "open", "posted", "paid", "void"]);
|
|
32
|
+
export const channelSettlementItemStatusSchema = z.enum([
|
|
33
|
+
"pending",
|
|
34
|
+
"approved",
|
|
35
|
+
"disputed",
|
|
36
|
+
"paid",
|
|
37
|
+
"void",
|
|
38
|
+
]);
|
|
39
|
+
export const channelReconciliationRunStatusSchema = z.enum([
|
|
40
|
+
"draft",
|
|
41
|
+
"running",
|
|
42
|
+
"completed",
|
|
43
|
+
"archived",
|
|
44
|
+
]);
|
|
45
|
+
export const channelReconciliationIssueTypeSchema = z.enum([
|
|
46
|
+
"missing_booking",
|
|
47
|
+
"status_mismatch",
|
|
48
|
+
"amount_mismatch",
|
|
49
|
+
"cancel_mismatch",
|
|
50
|
+
"missing_payout",
|
|
51
|
+
"other",
|
|
52
|
+
]);
|
|
53
|
+
export const channelReconciliationSeveritySchema = z.enum(["info", "warning", "error"]);
|
|
54
|
+
export const channelReconciliationResolutionStatusSchema = z.enum(["open", "ignored", "resolved"]);
|
|
55
|
+
export const channelReleaseExecutionStatusSchema = z.enum([
|
|
56
|
+
"pending",
|
|
57
|
+
"completed",
|
|
58
|
+
"skipped",
|
|
59
|
+
"failed",
|
|
60
|
+
]);
|
|
61
|
+
export const channelReleaseExecutionActionSchema = z.enum([
|
|
62
|
+
"released",
|
|
63
|
+
"expired",
|
|
64
|
+
"retained",
|
|
65
|
+
"manual_override",
|
|
66
|
+
]);
|
|
67
|
+
export const channelSettlementPolicyFrequencySchema = z.enum([
|
|
68
|
+
"manual",
|
|
69
|
+
"daily",
|
|
70
|
+
"weekly",
|
|
71
|
+
"monthly",
|
|
72
|
+
]);
|
|
73
|
+
export const channelReconciliationPolicyFrequencySchema = z.enum([
|
|
74
|
+
"manual",
|
|
75
|
+
"daily",
|
|
76
|
+
"weekly",
|
|
77
|
+
"monthly",
|
|
78
|
+
]);
|
|
79
|
+
export const channelReleaseScheduleKindSchema = z.enum(["manual", "hourly", "daily"]);
|
|
80
|
+
export const channelRemittanceExceptionStatusSchema = z.enum([
|
|
81
|
+
"open",
|
|
82
|
+
"investigating",
|
|
83
|
+
"resolved",
|
|
84
|
+
"ignored",
|
|
85
|
+
]);
|
|
86
|
+
export const channelSettlementApprovalStatusSchema = z.enum(["pending", "approved", "rejected"]);
|
|
87
|
+
export const channelCoreSchema = z.object({
|
|
88
|
+
name: z.string().min(1),
|
|
89
|
+
description: z.string().nullable().optional(),
|
|
90
|
+
kind: channelKindSchema,
|
|
91
|
+
status: channelStatusSchema.default("active"),
|
|
92
|
+
website: z
|
|
93
|
+
.string()
|
|
94
|
+
.url()
|
|
95
|
+
.nullable()
|
|
96
|
+
.optional()
|
|
97
|
+
.or(z.literal(""))
|
|
98
|
+
.transform((value) => value || null),
|
|
99
|
+
contactName: z.string().nullable().optional(),
|
|
100
|
+
contactEmail: z.string().email().nullable().optional(),
|
|
101
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
102
|
+
});
|
|
103
|
+
export const insertChannelSchema = channelCoreSchema;
|
|
104
|
+
export const updateChannelSchema = channelCoreSchema.partial();
|
|
105
|
+
export const channelListQuerySchema = paginationSchema.extend({
|
|
106
|
+
kind: channelKindSchema.optional(),
|
|
107
|
+
status: channelStatusSchema.optional(),
|
|
108
|
+
});
|
|
109
|
+
export const channelContractCoreSchema = z.object({
|
|
110
|
+
channelId: z.string(),
|
|
111
|
+
supplierId: z.string().nullable().optional(),
|
|
112
|
+
status: channelContractStatusSchema.default("draft"),
|
|
113
|
+
startsAt: isoDateSchema,
|
|
114
|
+
endsAt: isoDateSchema.nullable().optional(),
|
|
115
|
+
paymentOwner: distributionPaymentOwnerSchema.default("operator"),
|
|
116
|
+
cancellationOwner: distributionCancellationOwnerSchema.default("operator"),
|
|
117
|
+
settlementTerms: z.string().nullable().optional(),
|
|
118
|
+
notes: z.string().nullable().optional(),
|
|
119
|
+
});
|
|
120
|
+
export const insertChannelContractSchema = channelContractCoreSchema;
|
|
121
|
+
export const updateChannelContractSchema = channelContractCoreSchema.partial();
|
|
122
|
+
export const channelContractListQuerySchema = paginationSchema.extend({
|
|
123
|
+
channelId: z.string().optional(),
|
|
124
|
+
supplierId: z.string().optional(),
|
|
125
|
+
status: channelContractStatusSchema.optional(),
|
|
126
|
+
});
|
|
127
|
+
export const channelCommissionRuleCoreSchema = z.object({
|
|
128
|
+
contractId: z.string(),
|
|
129
|
+
scope: channelCommissionScopeSchema,
|
|
130
|
+
productId: z.string().nullable().optional(),
|
|
131
|
+
externalRateId: z.string().nullable().optional(),
|
|
132
|
+
externalCategoryId: z.string().nullable().optional(),
|
|
133
|
+
commissionType: channelCommissionTypeSchema,
|
|
134
|
+
amountCents: z.number().int().min(0).nullable().optional(),
|
|
135
|
+
percentBasisPoints: z.number().int().min(0).nullable().optional(),
|
|
136
|
+
validFrom: isoDateSchema.nullable().optional(),
|
|
137
|
+
validTo: isoDateSchema.nullable().optional(),
|
|
138
|
+
});
|
|
139
|
+
export const insertChannelCommissionRuleSchema = channelCommissionRuleCoreSchema;
|
|
140
|
+
export const updateChannelCommissionRuleSchema = channelCommissionRuleCoreSchema.partial();
|
|
141
|
+
export const channelCommissionRuleListQuerySchema = paginationSchema.extend({
|
|
142
|
+
contractId: z.string().optional(),
|
|
143
|
+
productId: z.string().optional(),
|
|
144
|
+
scope: channelCommissionScopeSchema.optional(),
|
|
145
|
+
});
|
|
146
|
+
export const channelProductMappingCoreSchema = z.object({
|
|
147
|
+
channelId: z.string(),
|
|
148
|
+
productId: z.string(),
|
|
149
|
+
externalProductId: z.string().min(1).nullable().optional(),
|
|
150
|
+
externalRateId: z.string().nullable().optional(),
|
|
151
|
+
externalCategoryId: z.string().nullable().optional(),
|
|
152
|
+
active: z.boolean().default(true),
|
|
153
|
+
});
|
|
154
|
+
export const insertChannelProductMappingSchema = channelProductMappingCoreSchema;
|
|
155
|
+
export const updateChannelProductMappingSchema = channelProductMappingCoreSchema.partial();
|
|
156
|
+
export const channelProductMappingListQuerySchema = paginationSchema.extend({
|
|
157
|
+
channelId: z.string().optional(),
|
|
158
|
+
productId: z.string().optional(),
|
|
159
|
+
active: booleanQueryParam.optional(),
|
|
160
|
+
});
|
|
161
|
+
export const channelBookingLinkCoreSchema = z.object({
|
|
162
|
+
channelId: z.string(),
|
|
163
|
+
bookingId: z.string(),
|
|
164
|
+
externalBookingId: z.string().nullable().optional(),
|
|
165
|
+
externalReference: z.string().nullable().optional(),
|
|
166
|
+
externalStatus: z.string().nullable().optional(),
|
|
167
|
+
bookedAtExternal: isoDateTimeSchema.nullable().optional(),
|
|
168
|
+
lastSyncedAt: isoDateTimeSchema.nullable().optional(),
|
|
169
|
+
});
|
|
170
|
+
export const insertChannelBookingLinkSchema = channelBookingLinkCoreSchema;
|
|
171
|
+
export const updateChannelBookingLinkSchema = channelBookingLinkCoreSchema.partial();
|
|
172
|
+
export const channelBookingLinkListQuerySchema = paginationSchema.extend({
|
|
173
|
+
channelId: z.string().optional(),
|
|
174
|
+
bookingId: z.string().optional(),
|
|
175
|
+
externalBookingId: z.string().optional(),
|
|
176
|
+
});
|
|
177
|
+
export const channelWebhookEventCoreSchema = z.object({
|
|
178
|
+
channelId: z.string(),
|
|
179
|
+
eventType: z.string().min(1),
|
|
180
|
+
externalEventId: z.string().nullable().optional(),
|
|
181
|
+
payload: z.record(z.string(), z.unknown()),
|
|
182
|
+
receivedAt: isoDateTimeSchema.nullable().optional(),
|
|
183
|
+
processedAt: isoDateTimeSchema.nullable().optional(),
|
|
184
|
+
status: channelWebhookStatusSchema.default("pending"),
|
|
185
|
+
errorMessage: z.string().nullable().optional(),
|
|
186
|
+
});
|
|
187
|
+
export const insertChannelWebhookEventSchema = channelWebhookEventCoreSchema;
|
|
188
|
+
export const updateChannelWebhookEventSchema = channelWebhookEventCoreSchema.partial();
|
|
189
|
+
export const channelWebhookEventListQuerySchema = paginationSchema.extend({
|
|
190
|
+
channelId: z.string().optional(),
|
|
191
|
+
status: channelWebhookStatusSchema.optional(),
|
|
192
|
+
eventType: z.string().optional(),
|
|
193
|
+
});
|
|
194
|
+
export const channelInventoryAllotmentCoreSchema = z.object({
|
|
195
|
+
channelId: z.string(),
|
|
196
|
+
contractId: z.string().nullable().optional(),
|
|
197
|
+
productId: z.string(),
|
|
198
|
+
optionId: z.string().nullable().optional(),
|
|
199
|
+
startTimeId: z.string().nullable().optional(),
|
|
200
|
+
validFrom: isoDateSchema.nullable().optional(),
|
|
201
|
+
validTo: isoDateSchema.nullable().optional(),
|
|
202
|
+
guaranteedCapacity: z.number().int().min(0).nullable().optional(),
|
|
203
|
+
maxCapacity: z.number().int().min(0).nullable().optional(),
|
|
204
|
+
active: z.boolean().default(true),
|
|
205
|
+
notes: z.string().nullable().optional(),
|
|
206
|
+
});
|
|
207
|
+
export const insertChannelInventoryAllotmentSchema = channelInventoryAllotmentCoreSchema;
|
|
208
|
+
export const updateChannelInventoryAllotmentSchema = channelInventoryAllotmentCoreSchema.partial();
|
|
209
|
+
export const channelInventoryAllotmentListQuerySchema = paginationSchema.extend({
|
|
210
|
+
channelId: z.string().optional(),
|
|
211
|
+
contractId: z.string().optional(),
|
|
212
|
+
productId: z.string().optional(),
|
|
213
|
+
optionId: z.string().optional(),
|
|
214
|
+
startTimeId: z.string().optional(),
|
|
215
|
+
active: booleanQueryParam.optional(),
|
|
216
|
+
});
|
|
217
|
+
export const channelInventoryAllotmentTargetCoreSchema = z.object({
|
|
218
|
+
allotmentId: z.string(),
|
|
219
|
+
slotId: z.string().nullable().optional(),
|
|
220
|
+
startTimeId: z.string().nullable().optional(),
|
|
221
|
+
dateLocal: isoDateSchema.nullable().optional(),
|
|
222
|
+
guaranteedCapacity: z.number().int().min(0).nullable().optional(),
|
|
223
|
+
maxCapacity: z.number().int().min(0).nullable().optional(),
|
|
224
|
+
soldCapacity: z.number().int().min(0).nullable().optional(),
|
|
225
|
+
remainingCapacity: z.number().int().min(0).nullable().optional(),
|
|
226
|
+
active: z.boolean().default(true),
|
|
227
|
+
});
|
|
228
|
+
export const insertChannelInventoryAllotmentTargetSchema = channelInventoryAllotmentTargetCoreSchema;
|
|
229
|
+
export const updateChannelInventoryAllotmentTargetSchema = channelInventoryAllotmentTargetCoreSchema.partial();
|
|
230
|
+
export const channelInventoryAllotmentTargetListQuerySchema = paginationSchema.extend({
|
|
231
|
+
allotmentId: z.string().optional(),
|
|
232
|
+
slotId: z.string().optional(),
|
|
233
|
+
startTimeId: z.string().optional(),
|
|
234
|
+
dateLocal: isoDateSchema.optional(),
|
|
235
|
+
active: booleanQueryParam.optional(),
|
|
236
|
+
});
|
|
237
|
+
export const channelInventoryReleaseRuleCoreSchema = z.object({
|
|
238
|
+
allotmentId: z.string(),
|
|
239
|
+
releaseMode: channelAllotmentReleaseModeSchema.default("automatic"),
|
|
240
|
+
releaseDaysBeforeStart: z.number().int().min(0).nullable().optional(),
|
|
241
|
+
releaseHoursBeforeStart: z.number().int().min(0).nullable().optional(),
|
|
242
|
+
unsoldAction: channelAllotmentUnsoldActionSchema.default("release_to_general_pool"),
|
|
243
|
+
notes: z.string().nullable().optional(),
|
|
244
|
+
});
|
|
245
|
+
export const insertChannelInventoryReleaseRuleSchema = channelInventoryReleaseRuleCoreSchema;
|
|
246
|
+
export const updateChannelInventoryReleaseRuleSchema = channelInventoryReleaseRuleCoreSchema.partial();
|
|
247
|
+
export const channelInventoryReleaseRuleListQuerySchema = paginationSchema.extend({
|
|
248
|
+
allotmentId: z.string().optional(),
|
|
249
|
+
releaseMode: channelAllotmentReleaseModeSchema.optional(),
|
|
250
|
+
});
|
|
251
|
+
export const channelSettlementRunCoreSchema = z.object({
|
|
252
|
+
channelId: z.string(),
|
|
253
|
+
contractId: z.string().nullable().optional(),
|
|
254
|
+
status: channelSettlementRunStatusSchema.default("draft"),
|
|
255
|
+
currencyCode: z.string().nullable().optional(),
|
|
256
|
+
periodStart: isoDateSchema.nullable().optional(),
|
|
257
|
+
periodEnd: isoDateSchema.nullable().optional(),
|
|
258
|
+
statementReference: z.string().nullable().optional(),
|
|
259
|
+
generatedAt: isoDateTimeSchema.nullable().optional(),
|
|
260
|
+
postedAt: isoDateTimeSchema.nullable().optional(),
|
|
261
|
+
paidAt: isoDateTimeSchema.nullable().optional(),
|
|
262
|
+
notes: z.string().nullable().optional(),
|
|
263
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
264
|
+
});
|
|
265
|
+
export const insertChannelSettlementRunSchema = channelSettlementRunCoreSchema;
|
|
266
|
+
export const updateChannelSettlementRunSchema = channelSettlementRunCoreSchema.partial();
|
|
267
|
+
export const channelSettlementRunListQuerySchema = paginationSchema.extend({
|
|
268
|
+
channelId: z.string().optional(),
|
|
269
|
+
contractId: z.string().optional(),
|
|
270
|
+
status: channelSettlementRunStatusSchema.optional(),
|
|
271
|
+
});
|
|
272
|
+
export const channelSettlementItemCoreSchema = z.object({
|
|
273
|
+
settlementRunId: z.string(),
|
|
274
|
+
bookingLinkId: z.string().nullable().optional(),
|
|
275
|
+
bookingId: z.string().nullable().optional(),
|
|
276
|
+
commissionRuleId: z.string().nullable().optional(),
|
|
277
|
+
status: channelSettlementItemStatusSchema.default("pending"),
|
|
278
|
+
grossAmountCents: z.number().int().default(0),
|
|
279
|
+
commissionAmountCents: z.number().int().default(0),
|
|
280
|
+
netRemittanceAmountCents: z.number().int().default(0),
|
|
281
|
+
currencyCode: z.string().nullable().optional(),
|
|
282
|
+
remittanceDueAt: isoDateTimeSchema.nullable().optional(),
|
|
283
|
+
paidAt: isoDateTimeSchema.nullable().optional(),
|
|
284
|
+
notes: z.string().nullable().optional(),
|
|
285
|
+
});
|
|
286
|
+
export const insertChannelSettlementItemSchema = channelSettlementItemCoreSchema;
|
|
287
|
+
export const updateChannelSettlementItemSchema = channelSettlementItemCoreSchema.partial();
|
|
288
|
+
export const channelSettlementItemListQuerySchema = paginationSchema.extend({
|
|
289
|
+
settlementRunId: z.string().optional(),
|
|
290
|
+
bookingLinkId: z.string().optional(),
|
|
291
|
+
bookingId: z.string().optional(),
|
|
292
|
+
status: channelSettlementItemStatusSchema.optional(),
|
|
293
|
+
});
|
|
294
|
+
export const channelReconciliationRunCoreSchema = z.object({
|
|
295
|
+
channelId: z.string(),
|
|
296
|
+
contractId: z.string().nullable().optional(),
|
|
297
|
+
status: channelReconciliationRunStatusSchema.default("draft"),
|
|
298
|
+
periodStart: isoDateSchema.nullable().optional(),
|
|
299
|
+
periodEnd: isoDateSchema.nullable().optional(),
|
|
300
|
+
externalReportReference: z.string().nullable().optional(),
|
|
301
|
+
startedAt: isoDateTimeSchema.nullable().optional(),
|
|
302
|
+
completedAt: isoDateTimeSchema.nullable().optional(),
|
|
303
|
+
notes: z.string().nullable().optional(),
|
|
304
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
305
|
+
});
|
|
306
|
+
export const insertChannelReconciliationRunSchema = channelReconciliationRunCoreSchema;
|
|
307
|
+
export const updateChannelReconciliationRunSchema = channelReconciliationRunCoreSchema.partial();
|
|
308
|
+
export const channelReconciliationRunListQuerySchema = paginationSchema.extend({
|
|
309
|
+
channelId: z.string().optional(),
|
|
310
|
+
contractId: z.string().optional(),
|
|
311
|
+
status: channelReconciliationRunStatusSchema.optional(),
|
|
312
|
+
});
|
|
313
|
+
export const channelReconciliationItemCoreSchema = z.object({
|
|
314
|
+
reconciliationRunId: z.string(),
|
|
315
|
+
bookingLinkId: z.string().nullable().optional(),
|
|
316
|
+
bookingId: z.string().nullable().optional(),
|
|
317
|
+
externalBookingId: z.string().nullable().optional(),
|
|
318
|
+
issueType: channelReconciliationIssueTypeSchema.default("other"),
|
|
319
|
+
severity: channelReconciliationSeveritySchema.default("warning"),
|
|
320
|
+
resolutionStatus: channelReconciliationResolutionStatusSchema.default("open"),
|
|
321
|
+
notes: z.string().nullable().optional(),
|
|
322
|
+
resolvedAt: isoDateTimeSchema.nullable().optional(),
|
|
323
|
+
});
|
|
324
|
+
export const insertChannelReconciliationItemSchema = channelReconciliationItemCoreSchema;
|
|
325
|
+
export const updateChannelReconciliationItemSchema = channelReconciliationItemCoreSchema.partial();
|
|
326
|
+
export const channelReconciliationItemListQuerySchema = paginationSchema.extend({
|
|
327
|
+
reconciliationRunId: z.string().optional(),
|
|
328
|
+
bookingLinkId: z.string().optional(),
|
|
329
|
+
bookingId: z.string().optional(),
|
|
330
|
+
issueType: channelReconciliationIssueTypeSchema.optional(),
|
|
331
|
+
resolutionStatus: channelReconciliationResolutionStatusSchema.optional(),
|
|
332
|
+
});
|
|
333
|
+
export const channelInventoryReleaseExecutionCoreSchema = z.object({
|
|
334
|
+
allotmentId: z.string(),
|
|
335
|
+
releaseRuleId: z.string().nullable().optional(),
|
|
336
|
+
targetId: z.string().nullable().optional(),
|
|
337
|
+
slotId: z.string().nullable().optional(),
|
|
338
|
+
actionTaken: channelReleaseExecutionActionSchema.default("released"),
|
|
339
|
+
status: channelReleaseExecutionStatusSchema.default("pending"),
|
|
340
|
+
releasedCapacity: z.number().int().min(0).nullable().optional(),
|
|
341
|
+
executedAt: isoDateTimeSchema.nullable().optional(),
|
|
342
|
+
notes: z.string().nullable().optional(),
|
|
343
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
344
|
+
});
|
|
345
|
+
export const insertChannelInventoryReleaseExecutionSchema = channelInventoryReleaseExecutionCoreSchema;
|
|
346
|
+
export const updateChannelInventoryReleaseExecutionSchema = channelInventoryReleaseExecutionCoreSchema.partial();
|
|
347
|
+
export const channelInventoryReleaseExecutionListQuerySchema = paginationSchema.extend({
|
|
348
|
+
allotmentId: z.string().optional(),
|
|
349
|
+
releaseRuleId: z.string().optional(),
|
|
350
|
+
targetId: z.string().optional(),
|
|
351
|
+
slotId: z.string().optional(),
|
|
352
|
+
status: channelReleaseExecutionStatusSchema.optional(),
|
|
353
|
+
});
|
|
354
|
+
export const channelSettlementPolicyCoreSchema = z.object({
|
|
355
|
+
channelId: z.string(),
|
|
356
|
+
contractId: z.string().nullable().optional(),
|
|
357
|
+
frequency: channelSettlementPolicyFrequencySchema.default("manual"),
|
|
358
|
+
autoGenerate: z.boolean().default(false),
|
|
359
|
+
approvalRequired: z.boolean().default(false),
|
|
360
|
+
remittanceDaysAfterPeriodEnd: z.number().int().min(0).nullable().optional(),
|
|
361
|
+
minimumPayoutAmountCents: z.number().int().min(0).nullable().optional(),
|
|
362
|
+
currencyCode: z.string().nullable().optional(),
|
|
363
|
+
active: z.boolean().default(true),
|
|
364
|
+
notes: z.string().nullable().optional(),
|
|
365
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
366
|
+
});
|
|
367
|
+
export const insertChannelSettlementPolicySchema = channelSettlementPolicyCoreSchema;
|
|
368
|
+
export const updateChannelSettlementPolicySchema = channelSettlementPolicyCoreSchema.partial();
|
|
369
|
+
export const channelSettlementPolicyListQuerySchema = paginationSchema.extend({
|
|
370
|
+
channelId: z.string().optional(),
|
|
371
|
+
contractId: z.string().optional(),
|
|
372
|
+
frequency: channelSettlementPolicyFrequencySchema.optional(),
|
|
373
|
+
active: booleanQueryParam.optional(),
|
|
374
|
+
});
|
|
375
|
+
export const channelReconciliationPolicyCoreSchema = z.object({
|
|
376
|
+
channelId: z.string(),
|
|
377
|
+
contractId: z.string().nullable().optional(),
|
|
378
|
+
frequency: channelReconciliationPolicyFrequencySchema.default("manual"),
|
|
379
|
+
autoRun: z.boolean().default(false),
|
|
380
|
+
compareGrossAmounts: z.boolean().default(true),
|
|
381
|
+
compareStatuses: z.boolean().default(true),
|
|
382
|
+
compareCancellations: z.boolean().default(true),
|
|
383
|
+
amountToleranceCents: z.number().int().min(0).nullable().optional(),
|
|
384
|
+
active: z.boolean().default(true),
|
|
385
|
+
notes: z.string().nullable().optional(),
|
|
386
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
387
|
+
});
|
|
388
|
+
export const insertChannelReconciliationPolicySchema = channelReconciliationPolicyCoreSchema;
|
|
389
|
+
export const updateChannelReconciliationPolicySchema = channelReconciliationPolicyCoreSchema.partial();
|
|
390
|
+
export const channelReconciliationPolicyListQuerySchema = paginationSchema.extend({
|
|
391
|
+
channelId: z.string().optional(),
|
|
392
|
+
contractId: z.string().optional(),
|
|
393
|
+
frequency: channelReconciliationPolicyFrequencySchema.optional(),
|
|
394
|
+
active: booleanQueryParam.optional(),
|
|
395
|
+
});
|
|
396
|
+
export const channelReleaseScheduleCoreSchema = z.object({
|
|
397
|
+
releaseRuleId: z.string(),
|
|
398
|
+
scheduleKind: channelReleaseScheduleKindSchema.default("manual"),
|
|
399
|
+
nextRunAt: isoDateTimeSchema.nullable().optional(),
|
|
400
|
+
lastRunAt: isoDateTimeSchema.nullable().optional(),
|
|
401
|
+
active: z.boolean().default(true),
|
|
402
|
+
notes: z.string().nullable().optional(),
|
|
403
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
404
|
+
});
|
|
405
|
+
export const insertChannelReleaseScheduleSchema = channelReleaseScheduleCoreSchema;
|
|
406
|
+
export const updateChannelReleaseScheduleSchema = channelReleaseScheduleCoreSchema.partial();
|
|
407
|
+
export const channelReleaseScheduleListQuerySchema = paginationSchema.extend({
|
|
408
|
+
releaseRuleId: z.string().optional(),
|
|
409
|
+
scheduleKind: channelReleaseScheduleKindSchema.optional(),
|
|
410
|
+
active: booleanQueryParam.optional(),
|
|
411
|
+
});
|
|
412
|
+
export const channelRemittanceExceptionCoreSchema = z.object({
|
|
413
|
+
channelId: z.string(),
|
|
414
|
+
settlementItemId: z.string().nullable().optional(),
|
|
415
|
+
reconciliationItemId: z.string().nullable().optional(),
|
|
416
|
+
exceptionType: z.string().min(1),
|
|
417
|
+
severity: channelReconciliationSeveritySchema.default("warning"),
|
|
418
|
+
status: channelRemittanceExceptionStatusSchema.default("open"),
|
|
419
|
+
openedAt: isoDateTimeSchema.nullable().optional(),
|
|
420
|
+
resolvedAt: isoDateTimeSchema.nullable().optional(),
|
|
421
|
+
notes: z.string().nullable().optional(),
|
|
422
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
423
|
+
});
|
|
424
|
+
export const insertChannelRemittanceExceptionSchema = channelRemittanceExceptionCoreSchema;
|
|
425
|
+
export const updateChannelRemittanceExceptionSchema = channelRemittanceExceptionCoreSchema.partial();
|
|
426
|
+
export const channelRemittanceExceptionListQuerySchema = paginationSchema.extend({
|
|
427
|
+
channelId: z.string().optional(),
|
|
428
|
+
settlementItemId: z.string().optional(),
|
|
429
|
+
reconciliationItemId: z.string().optional(),
|
|
430
|
+
status: channelRemittanceExceptionStatusSchema.optional(),
|
|
431
|
+
});
|
|
432
|
+
export const channelSettlementApprovalCoreSchema = z.object({
|
|
433
|
+
settlementRunId: z.string(),
|
|
434
|
+
approverUserId: z.string().nullable().optional(),
|
|
435
|
+
status: channelSettlementApprovalStatusSchema.default("pending"),
|
|
436
|
+
decidedAt: isoDateTimeSchema.nullable().optional(),
|
|
437
|
+
notes: z.string().nullable().optional(),
|
|
438
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
439
|
+
});
|
|
440
|
+
export const insertChannelSettlementApprovalSchema = channelSettlementApprovalCoreSchema;
|
|
441
|
+
export const updateChannelSettlementApprovalSchema = channelSettlementApprovalCoreSchema.partial();
|
|
442
|
+
export const channelSettlementApprovalListQuerySchema = paginationSchema.extend({
|
|
443
|
+
settlementRunId: z.string().optional(),
|
|
444
|
+
status: channelSettlementApprovalStatusSchema.optional(),
|
|
445
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `prepareOutboundEnvelope` — the ONLY allowed write path into
|
|
3
|
+
* `webhook_deliveries`. Enforces the redaction guarantees called for in
|
|
4
|
+
* channel-push-architecture §11.3:
|
|
5
|
+
*
|
|
6
|
+
* 1. Drops sensitive headers (Authorization, Cookie, X-Api-Key, …).
|
|
7
|
+
* 2. Bounds request/response excerpts to 4 KB so the table doesn't
|
|
8
|
+
* become a body archive.
|
|
9
|
+
* 3. Hashes the request body (SHA-256 over canonical JSON or raw
|
|
10
|
+
* text) so retries can be correlated and drift detected without
|
|
11
|
+
* exposing payloads.
|
|
12
|
+
*
|
|
13
|
+
* v2 will add per-flow PII redactors here (booking-traveler payloads,
|
|
14
|
+
* email/phone shapes); v1 keeps the envelope minimal and documents the
|
|
15
|
+
* redactor as the future home of those rules.
|
|
16
|
+
*
|
|
17
|
+
* Direct INSERTs into `webhook_deliveries` from anywhere except this
|
|
18
|
+
* helper are a lint violation per §11.3.
|
|
19
|
+
*/
|
|
20
|
+
import type { AnyDrizzleDb } from "@voyant-travel/db";
|
|
21
|
+
import { type InfraWebhookDelivery } from "@voyant-travel/db/schema/infra";
|
|
22
|
+
export interface OutboundEnvelopeInput {
|
|
23
|
+
sourceModule: string;
|
|
24
|
+
sourceEvent: string;
|
|
25
|
+
sourceEntityModule?: string;
|
|
26
|
+
sourceEntityId?: string;
|
|
27
|
+
subscriptionId?: string;
|
|
28
|
+
targetUrl: string;
|
|
29
|
+
targetKind?: string;
|
|
30
|
+
targetRef?: string;
|
|
31
|
+
requestMethod: string;
|
|
32
|
+
requestHeaders?: Record<string, string>;
|
|
33
|
+
requestBody?: unknown;
|
|
34
|
+
attemptNumber?: number;
|
|
35
|
+
parentDeliveryId?: string;
|
|
36
|
+
idempotencyKey?: string;
|
|
37
|
+
/** When set, the row starts in "pending" / `scheduledFor`. v1 dispatches inline. */
|
|
38
|
+
scheduledFor?: Date;
|
|
39
|
+
}
|
|
40
|
+
export interface OutboundEnvelopeResultInput {
|
|
41
|
+
responseStatus?: number;
|
|
42
|
+
responseHeaders?: Record<string, string>;
|
|
43
|
+
responseBody?: unknown;
|
|
44
|
+
errorClass?: InfraWebhookDelivery["errorClass"];
|
|
45
|
+
errorMessage?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface PreparedEnvelope {
|
|
48
|
+
/** The persisted (in-flight) row — caller updates it with the result. */
|
|
49
|
+
delivery: InfraWebhookDelivery;
|
|
50
|
+
/** Finalize the envelope after the upstream call returns or throws. */
|
|
51
|
+
complete: (result: OutboundEnvelopeResultInput) => Promise<InfraWebhookDelivery>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Begin an outbound delivery: redacts the request, persists an
|
|
55
|
+
* in-flight row, and returns a `complete()` finisher the caller invokes
|
|
56
|
+
* with the response (or error).
|
|
57
|
+
*
|
|
58
|
+
* Usage:
|
|
59
|
+
* const env = await prepareOutboundEnvelope(db, { ... })
|
|
60
|
+
* try {
|
|
61
|
+
* const res = await fetch(...)
|
|
62
|
+
* await env.complete({ responseStatus: res.status, ... })
|
|
63
|
+
* } catch (err) {
|
|
64
|
+
* await env.complete({ errorClass: "network", errorMessage: String(err) })
|
|
65
|
+
* }
|
|
66
|
+
*/
|
|
67
|
+
export declare function prepareOutboundEnvelope(db: AnyDrizzleDb, input: OutboundEnvelopeInput): Promise<PreparedEnvelope>;
|
|
68
|
+
export declare function redactHeaders(headers: Record<string, string> | undefined): Record<string, string> | null;
|
|
69
|
+
/**
|
|
70
|
+
* Recursively redact PII from a JSON-serializable body. Every key whose
|
|
71
|
+
* lowercased name matches `REDACTED_BODY_KEYS` is replaced with
|
|
72
|
+
* `[REDACTED]`; remaining string values get email/phone shapes
|
|
73
|
+
* scrubbed. This protects channel-push booking payloads (which carry
|
|
74
|
+
* traveler contact info) from leaking into the delivery log per §11.3.
|
|
75
|
+
*
|
|
76
|
+
* Exported for callers that want to redact bodies before passing them
|
|
77
|
+
* to other sinks (logs, error reporters).
|
|
78
|
+
*/
|
|
79
|
+
export declare function redactBodyPii(value: unknown): unknown;
|
|
80
|
+
/**
|
|
81
|
+
* Scrub email/phone shapes from a free-text string. The patterns are
|
|
82
|
+
* coarse on purpose — false positives (e.g. a phone-shaped tracking id)
|
|
83
|
+
* are preferable to leaks.
|
|
84
|
+
*/
|
|
85
|
+
export declare function redactStringPii(text: string): string;
|
|
86
|
+
//# sourceMappingURL=webhook-deliveries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-deliveries.d.ts","sourceRoot":"","sources":["../src/webhook-deliveries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,gCAAgC,CAAA;AAmEvC,MAAM,WAAW,qBAAqB;IAEpC,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;IAGvB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAGlB,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,WAAW,CAAC,EAAE,OAAO,CAAA;IAGrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,cAAc,CAAC,EAAE,MAAM,CAAA;IAGvB,oFAAoF;IACpF,YAAY,CAAC,EAAE,IAAI,CAAA;CACpB;AAED,MAAM,WAAW,2BAA2B;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAA;IAC/C,YAAY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