@globalart/ddd 1.0.26 → 1.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1186 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +893 -0
- package/dist/index.d.ts +21 -1
- package/dist/index.js +43 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1186 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
let uuid = require("uuid");
|
|
25
|
+
uuid = __toESM(uuid);
|
|
26
|
+
let zod = require("zod");
|
|
27
|
+
zod = __toESM(zod);
|
|
28
|
+
let oxide_ts = require("oxide.ts");
|
|
29
|
+
oxide_ts = __toESM(oxide_ts);
|
|
30
|
+
let ts_pattern = require("ts-pattern");
|
|
31
|
+
ts_pattern = __toESM(ts_pattern);
|
|
32
|
+
let dequal = require("dequal");
|
|
33
|
+
dequal = __toESM(dequal);
|
|
34
|
+
let date_fns = require("date-fns");
|
|
35
|
+
date_fns = __toESM(date_fns);
|
|
36
|
+
let nanoid = require("nanoid");
|
|
37
|
+
nanoid = __toESM(nanoid);
|
|
38
|
+
|
|
39
|
+
//#region src/aggregate-root.ts
|
|
40
|
+
var AggregateRoot = class {
|
|
41
|
+
#domainEvents = [];
|
|
42
|
+
get domainEvents() {
|
|
43
|
+
return this.#domainEvents;
|
|
44
|
+
}
|
|
45
|
+
set domainEvents(events) {
|
|
46
|
+
this.#domainEvents = events;
|
|
47
|
+
}
|
|
48
|
+
addDomainEvent(event) {
|
|
49
|
+
this.#domainEvents.push(event);
|
|
50
|
+
}
|
|
51
|
+
removeEvents(events) {
|
|
52
|
+
this.#domainEvents = this.#domainEvents.filter((event) => !events.includes(event));
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/command.ts
|
|
58
|
+
var Command = class {
|
|
59
|
+
commandId;
|
|
60
|
+
correlationId;
|
|
61
|
+
causationId;
|
|
62
|
+
constructor(props) {
|
|
63
|
+
this.correlationId = props.correlationId ?? (0, uuid.v4)();
|
|
64
|
+
this.commandId = props.commandId ?? (0, uuid.v4)();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/event.ts
|
|
70
|
+
const eventSchema = (name, payload, meta) => zod.z.object({
|
|
71
|
+
id: zod.z.string().uuid(),
|
|
72
|
+
name: zod.z.literal(name),
|
|
73
|
+
operatorId: zod.z.string().optional(),
|
|
74
|
+
payload,
|
|
75
|
+
timestamp: zod.z.coerce.date(),
|
|
76
|
+
meta
|
|
77
|
+
});
|
|
78
|
+
var BaseEvent = class {
|
|
79
|
+
constructor(payload, operatorId, meta, id = (0, uuid.v4)(), timestamp = /* @__PURE__ */ new Date()) {
|
|
80
|
+
this.payload = payload;
|
|
81
|
+
this.operatorId = operatorId;
|
|
82
|
+
this.meta = meta;
|
|
83
|
+
this.id = id;
|
|
84
|
+
this.timestamp = timestamp;
|
|
85
|
+
}
|
|
86
|
+
toJSON() {
|
|
87
|
+
return {
|
|
88
|
+
id: this.id,
|
|
89
|
+
name: this.name,
|
|
90
|
+
operatorId: this.operatorId,
|
|
91
|
+
timestamp: this.timestamp.toISOString(),
|
|
92
|
+
payload: this.payload,
|
|
93
|
+
meta: this.meta
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/exception.base.ts
|
|
100
|
+
var ExceptionBase = class extends Error {
|
|
101
|
+
correlationId;
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
* @param message
|
|
105
|
+
* @param correlationId
|
|
106
|
+
* @param cause
|
|
107
|
+
* @param metadata
|
|
108
|
+
*/
|
|
109
|
+
constructor(message, correlationId, cause, metadata) {
|
|
110
|
+
super(message);
|
|
111
|
+
this.message = message;
|
|
112
|
+
this.cause = cause;
|
|
113
|
+
this.metadata = metadata;
|
|
114
|
+
Error.captureStackTrace(this, this.constructor);
|
|
115
|
+
this.correlationId = correlationId;
|
|
116
|
+
}
|
|
117
|
+
toJSON() {
|
|
118
|
+
return {
|
|
119
|
+
message: this.message,
|
|
120
|
+
code: this.code,
|
|
121
|
+
stack: this.stack,
|
|
122
|
+
correlationId: this.correlationId,
|
|
123
|
+
cause: JSON.stringify(this.cause),
|
|
124
|
+
metadata: this.metadata
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/filter/base.filter.ts
|
|
131
|
+
const baseFilter = zod.z.object({
|
|
132
|
+
field: zod.z.string().min(1),
|
|
133
|
+
relation: zod.z.string().min(1).optional()
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/filter/conjunction.ts
|
|
138
|
+
const $and = zod.z.literal("$and");
|
|
139
|
+
const $or = zod.z.literal("$or");
|
|
140
|
+
const $not = zod.z.literal("$not");
|
|
141
|
+
const conjunctions = zod.z.union([
|
|
142
|
+
$and,
|
|
143
|
+
$or,
|
|
144
|
+
$not
|
|
145
|
+
]);
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/utils.ts
|
|
149
|
+
function convertPropsToObject(props) {
|
|
150
|
+
const propsCopy = { ...props };
|
|
151
|
+
for (const prop in propsCopy) {
|
|
152
|
+
if (Array.isArray(propsCopy[prop])) propsCopy[prop] = propsCopy[prop].map((item) => {
|
|
153
|
+
return convertToPlainObject(item);
|
|
154
|
+
});
|
|
155
|
+
propsCopy[prop] = convertToPlainObject(propsCopy[prop]);
|
|
156
|
+
}
|
|
157
|
+
return propsCopy;
|
|
158
|
+
}
|
|
159
|
+
function convertToPlainObject(item) {
|
|
160
|
+
if (ValueObject.isValueObject(item)) return item.unpack();
|
|
161
|
+
return item;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/value-objects/value-object.ts
|
|
166
|
+
var ValueObject = class ValueObject {
|
|
167
|
+
constructor(props) {
|
|
168
|
+
this.props = props;
|
|
169
|
+
}
|
|
170
|
+
equals(vo) {
|
|
171
|
+
if (vo === null || vo === void 0) return false;
|
|
172
|
+
return (0, dequal.dequal)(vo, this);
|
|
173
|
+
}
|
|
174
|
+
static isValueObject(obj) {
|
|
175
|
+
return obj instanceof ValueObject;
|
|
176
|
+
}
|
|
177
|
+
unpack() {
|
|
178
|
+
if (this.isDomainPrimitive(this.props)) return this.props.value;
|
|
179
|
+
const propsCopy = convertPropsToObject(this.props);
|
|
180
|
+
return Object.freeze(propsCopy);
|
|
181
|
+
}
|
|
182
|
+
isDomainPrimitive(obj) {
|
|
183
|
+
if (Object.prototype.hasOwnProperty.call(obj, "value")) return true;
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/filter/fields/field-value.base.ts
|
|
190
|
+
var FieldValueBase = class extends ValueObject {};
|
|
191
|
+
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/filter/fields/boolean/boolean-field-value.ts
|
|
194
|
+
var BooleanFieldValue = class extends FieldValueBase {
|
|
195
|
+
constructor(value) {
|
|
196
|
+
super({ value });
|
|
197
|
+
}
|
|
198
|
+
accept(visitor) {
|
|
199
|
+
visitor.boolean(this);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/filter/fields/boolean/boolean-field.type.ts
|
|
205
|
+
const booleanFieldValue = zod.z.boolean().nullable();
|
|
206
|
+
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/filter/operators.ts
|
|
209
|
+
const $eq = zod.z.literal("$eq");
|
|
210
|
+
const $neq = zod.z.literal("$neq");
|
|
211
|
+
const $contains = zod.z.literal("$contains");
|
|
212
|
+
const $not_contains = zod.z.literal("$not_contains");
|
|
213
|
+
const $starts_with = zod.z.literal("$starts_with");
|
|
214
|
+
const $ends_with = zod.z.literal("$ends_with");
|
|
215
|
+
const $regex = zod.z.literal("$regex");
|
|
216
|
+
const $is_true = zod.z.literal("$is_true");
|
|
217
|
+
const $is_false = zod.z.literal("$is_false");
|
|
218
|
+
const $in = zod.z.literal("$in");
|
|
219
|
+
const $nin = zod.z.literal("$nin");
|
|
220
|
+
const $gt = zod.z.literal("$gt");
|
|
221
|
+
const $lt = zod.z.literal("$lt");
|
|
222
|
+
const $gte = zod.z.literal("$gte");
|
|
223
|
+
const $lte = zod.z.literal("$lte");
|
|
224
|
+
const $start_eq = zod.z.literal("$start_eq");
|
|
225
|
+
const $start_neq = zod.z.literal("$start_neq");
|
|
226
|
+
const $start_gt = zod.z.literal("$start_gt");
|
|
227
|
+
const $start_lt = zod.z.literal("$start_lt");
|
|
228
|
+
const $start_gte = zod.z.literal("$start_gte");
|
|
229
|
+
const $start_lte = zod.z.literal("$start_lte");
|
|
230
|
+
const $end_eq = zod.z.literal("$end_eq");
|
|
231
|
+
const $end_neq = zod.z.literal("$end_neq");
|
|
232
|
+
const $end_gt = zod.z.literal("$end_gt");
|
|
233
|
+
const $end_lt = zod.z.literal("$end_lt");
|
|
234
|
+
const $end_gte = zod.z.literal("$end_gte");
|
|
235
|
+
const $end_lte = zod.z.literal("$end_lte");
|
|
236
|
+
const $is_empty = zod.z.literal("$is_empty");
|
|
237
|
+
const $is_not_empty = zod.z.literal("$is_not_empty");
|
|
238
|
+
const $is_today = zod.z.literal("$is_today");
|
|
239
|
+
const $is_not_today = zod.z.literal("$is_not_today");
|
|
240
|
+
const $is_tomorrow = zod.z.literal("$is_tomorrow");
|
|
241
|
+
const $is_yesterday = zod.z.literal("$is_yesterday");
|
|
242
|
+
const $between = zod.z.literal("$between");
|
|
243
|
+
const $has_file_type = zod.z.literal("$has_file_type");
|
|
244
|
+
const $has_file_extension = zod.z.literal("$has_file_extension");
|
|
245
|
+
const $is_root = zod.z.literal("$is_root");
|
|
246
|
+
const $is_me = zod.z.literal("$is_me");
|
|
247
|
+
const $is_not_me = zod.z.literal("$is_not_me");
|
|
248
|
+
const operatorsWihtoutValue = zod.z.union([
|
|
249
|
+
$is_empty,
|
|
250
|
+
$is_not_empty,
|
|
251
|
+
$is_today,
|
|
252
|
+
$is_not_today,
|
|
253
|
+
$is_tomorrow,
|
|
254
|
+
$is_yesterday,
|
|
255
|
+
$is_root,
|
|
256
|
+
$is_me,
|
|
257
|
+
$is_not_me
|
|
258
|
+
]);
|
|
259
|
+
const isOperatorWithoutValue = (value) => operatorsWihtoutValue.safeParse(value).success;
|
|
260
|
+
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/filter/fields/boolean/boolean.filter.ts
|
|
263
|
+
const booleanFilterOperators = zod.z.union([$eq, $neq]);
|
|
264
|
+
const booleanFilterValue = zod.z.boolean().nullable();
|
|
265
|
+
const booleanFilter = zod.z.object({
|
|
266
|
+
type: zod.z.literal("boolean"),
|
|
267
|
+
operator: booleanFilterOperators,
|
|
268
|
+
value: booleanFilterValue
|
|
269
|
+
}).merge(baseFilter);
|
|
270
|
+
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region src/filter/fields/date/date-field-value.ts
|
|
273
|
+
var DateFieldValue = class extends FieldValueBase {
|
|
274
|
+
constructor(value) {
|
|
275
|
+
super({ value });
|
|
276
|
+
}
|
|
277
|
+
accept(visitor) {
|
|
278
|
+
visitor.date(this);
|
|
279
|
+
}
|
|
280
|
+
static fromNullableString(str) {
|
|
281
|
+
if (!str) return new this(null);
|
|
282
|
+
return new this(new Date(str));
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/filter/fields/date/date-field.type.ts
|
|
288
|
+
const dateFieldValue = zod.z.date().nullable();
|
|
289
|
+
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/filter/fields/date/date.filter.ts
|
|
292
|
+
const dateFilterOperators = zod.z.union([
|
|
293
|
+
$eq,
|
|
294
|
+
$neq,
|
|
295
|
+
$gt,
|
|
296
|
+
$gte,
|
|
297
|
+
$lt,
|
|
298
|
+
$lte,
|
|
299
|
+
$between,
|
|
300
|
+
$is_today,
|
|
301
|
+
$is_tomorrow,
|
|
302
|
+
$is_yesterday,
|
|
303
|
+
$is_not_today
|
|
304
|
+
]);
|
|
305
|
+
const dateFilterValue = zod.z.string().nullable().or(zod.z.tuple([zod.z.string(), zod.z.string()]));
|
|
306
|
+
const dateFilter = zod.z.object({
|
|
307
|
+
type: zod.z.literal("date"),
|
|
308
|
+
operator: dateFilterOperators,
|
|
309
|
+
value: dateFilterValue
|
|
310
|
+
}).merge(baseFilter);
|
|
311
|
+
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/filter/fields/number/number-field-value.ts
|
|
314
|
+
var NumberFieldValue = class extends FieldValueBase {
|
|
315
|
+
constructor(value) {
|
|
316
|
+
super({ value });
|
|
317
|
+
}
|
|
318
|
+
accept(visitor) {
|
|
319
|
+
visitor.number(this);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region src/filter/fields/number/number-field.type.ts
|
|
325
|
+
const numberFieldValue = zod.z.number().or(zod.z.null());
|
|
326
|
+
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region src/filter/fields/number/number.filter.ts
|
|
329
|
+
const numberFilterOperators = zod.z.union([
|
|
330
|
+
$eq,
|
|
331
|
+
$neq,
|
|
332
|
+
$gt,
|
|
333
|
+
$gte,
|
|
334
|
+
$lt,
|
|
335
|
+
$lte,
|
|
336
|
+
$is_empty,
|
|
337
|
+
$is_not_empty
|
|
338
|
+
]);
|
|
339
|
+
const numberFilterValue = zod.z.number().nullable();
|
|
340
|
+
const numberFilter = zod.z.object({
|
|
341
|
+
type: zod.z.literal("number"),
|
|
342
|
+
operator: numberFilterOperators,
|
|
343
|
+
value: numberFilterValue
|
|
344
|
+
}).merge(baseFilter);
|
|
345
|
+
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/filter/fields/string/string-field-value.ts
|
|
348
|
+
var StringFieldValue = class extends FieldValueBase {
|
|
349
|
+
constructor(value) {
|
|
350
|
+
super({ value });
|
|
351
|
+
}
|
|
352
|
+
accept(visitor) {
|
|
353
|
+
visitor.string(this);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/filter/fields/string/string-field.type.ts
|
|
359
|
+
const stringFieldValue = zod.z.string().nullable();
|
|
360
|
+
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region src/filter/fields/string/string.filter.ts
|
|
363
|
+
const stringFilterOperators = zod.z.union([
|
|
364
|
+
$eq,
|
|
365
|
+
$neq,
|
|
366
|
+
$contains,
|
|
367
|
+
$not_contains,
|
|
368
|
+
$starts_with,
|
|
369
|
+
$ends_with,
|
|
370
|
+
$regex,
|
|
371
|
+
$is_empty,
|
|
372
|
+
$is_not_empty
|
|
373
|
+
]);
|
|
374
|
+
const stringFilterValue = zod.z.string().nullable();
|
|
375
|
+
const stringFilter = zod.z.object({
|
|
376
|
+
type: zod.z.literal("string"),
|
|
377
|
+
operator: stringFilterOperators,
|
|
378
|
+
value: stringFilterValue
|
|
379
|
+
}).merge(baseFilter);
|
|
380
|
+
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/specification.ts
|
|
383
|
+
var CompositeSpecification = class {
|
|
384
|
+
and(s) {
|
|
385
|
+
return new And(this, s);
|
|
386
|
+
}
|
|
387
|
+
or(s) {
|
|
388
|
+
return new Or(this, s);
|
|
389
|
+
}
|
|
390
|
+
not() {
|
|
391
|
+
return new Not(this);
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
var And = class extends CompositeSpecification {
|
|
395
|
+
constructor(left, right) {
|
|
396
|
+
super();
|
|
397
|
+
this.left = left;
|
|
398
|
+
this.right = right;
|
|
399
|
+
}
|
|
400
|
+
isSatisfiedBy(t) {
|
|
401
|
+
return this.left.isSatisfiedBy(t) && this.right.isSatisfiedBy(t);
|
|
402
|
+
}
|
|
403
|
+
mutate(t) {
|
|
404
|
+
return this.left.mutate(t).and(this.right.mutate(t));
|
|
405
|
+
}
|
|
406
|
+
accept(v) {
|
|
407
|
+
return this.left.accept(v).and(this.right.accept(v));
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
var Or = class extends CompositeSpecification {
|
|
411
|
+
constructor(left, right) {
|
|
412
|
+
super();
|
|
413
|
+
this.left = left;
|
|
414
|
+
this.right = right;
|
|
415
|
+
}
|
|
416
|
+
isSatisfiedBy(t) {
|
|
417
|
+
return this.left.isSatisfiedBy(t) || this.right.isSatisfiedBy(t);
|
|
418
|
+
}
|
|
419
|
+
mutate(t) {
|
|
420
|
+
return this.left.mutate(t).orElse(() => this.right.mutate(t));
|
|
421
|
+
}
|
|
422
|
+
accept(v) {
|
|
423
|
+
v.or(this.left, this.right);
|
|
424
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
var Not = class extends CompositeSpecification {
|
|
428
|
+
constructor(spec) {
|
|
429
|
+
super();
|
|
430
|
+
this.spec = spec;
|
|
431
|
+
}
|
|
432
|
+
isSatisfiedBy(t) {
|
|
433
|
+
return !this.spec.isSatisfiedBy(t);
|
|
434
|
+
}
|
|
435
|
+
mutate() {
|
|
436
|
+
throw new Error("[Not.mutate] Method not implemented.");
|
|
437
|
+
}
|
|
438
|
+
accept(v) {
|
|
439
|
+
return this.spec.accept(v.not());
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
const and = (...specs) => {
|
|
443
|
+
if (!specs.length) return oxide_ts.None;
|
|
444
|
+
let s = specs[0];
|
|
445
|
+
for (const spec of specs.slice(1)) s = s.and(spec);
|
|
446
|
+
return (0, oxide_ts.Some)(s);
|
|
447
|
+
};
|
|
448
|
+
const andOptions = (...specs) => {
|
|
449
|
+
return and(...specs.filter((spec) => spec.isSome()).map((spec) => spec.unwrap()));
|
|
450
|
+
};
|
|
451
|
+
const or = (...specs) => {
|
|
452
|
+
if (!specs.length) return oxide_ts.None;
|
|
453
|
+
let s = specs[0];
|
|
454
|
+
for (const spec of specs.slice(1)) s = s.or(spec);
|
|
455
|
+
return (0, oxide_ts.Some)(s);
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
//#endregion
|
|
459
|
+
//#region src/filter/filter-specification.base.ts
|
|
460
|
+
var BaseFilterSpecification = class extends CompositeSpecification {
|
|
461
|
+
constructor(field, value, relation) {
|
|
462
|
+
super();
|
|
463
|
+
this.field = field;
|
|
464
|
+
this.value = value;
|
|
465
|
+
this.relation = relation;
|
|
466
|
+
}
|
|
467
|
+
mutate(t) {
|
|
468
|
+
throw new Error("Method not implemented.");
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region src/filter/specifications/boolean.specification.ts
|
|
474
|
+
var BooleanEqual = class extends BaseFilterSpecification {
|
|
475
|
+
isSatisfiedBy(value) {
|
|
476
|
+
return value instanceof BooleanFieldValue && this.value.equals(value);
|
|
477
|
+
}
|
|
478
|
+
accept(v) {
|
|
479
|
+
v.booleanEqual(this);
|
|
480
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
var BooleanNotEqual = class extends BaseFilterSpecification {
|
|
484
|
+
isSatisfiedBy(value) {
|
|
485
|
+
return value instanceof BooleanFieldValue && this.value.equals(value);
|
|
486
|
+
}
|
|
487
|
+
accept(v) {
|
|
488
|
+
v.booleanNotEqual(this);
|
|
489
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
//#endregion
|
|
494
|
+
//#region src/filter/specifications/date.specification.ts
|
|
495
|
+
var DateEqual = class extends BaseFilterSpecification {
|
|
496
|
+
isSatisfiedBy(value) {
|
|
497
|
+
return value instanceof DateFieldValue && value.equals(this.value);
|
|
498
|
+
}
|
|
499
|
+
accept(v) {
|
|
500
|
+
v.dateEqual(this);
|
|
501
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
var DateGreaterThan = class extends BaseFilterSpecification {
|
|
505
|
+
isSatisfiedBy(value) {
|
|
506
|
+
if (!(value instanceof DateFieldValue)) return false;
|
|
507
|
+
const d1 = value.unpack();
|
|
508
|
+
const d2 = this.value.unpack();
|
|
509
|
+
return !!d1 && !!d2 && (0, date_fns.isAfter)(d1, d2);
|
|
510
|
+
}
|
|
511
|
+
accept(v) {
|
|
512
|
+
v.dateGreaterThan(this);
|
|
513
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
var DateLessThan = class extends BaseFilterSpecification {
|
|
517
|
+
isSatisfiedBy(value) {
|
|
518
|
+
if (!(value instanceof DateFieldValue)) return false;
|
|
519
|
+
const d1 = value.unpack();
|
|
520
|
+
const d2 = this.value.unpack();
|
|
521
|
+
return !!d1 && !!d2 && (0, date_fns.isBefore)(d1, d2);
|
|
522
|
+
}
|
|
523
|
+
accept(v) {
|
|
524
|
+
v.dateLessThan(this);
|
|
525
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
var DateGreaterThanOrEqual = class extends BaseFilterSpecification {
|
|
529
|
+
isSatisfiedBy(value) {
|
|
530
|
+
if (!(value instanceof DateFieldValue)) return false;
|
|
531
|
+
const d1 = value.unpack();
|
|
532
|
+
const d2 = this.value.unpack();
|
|
533
|
+
return !!d1 && !!d2 && ((0, date_fns.isEqual)(d1, d2) || (0, date_fns.isAfter)(d1, d2));
|
|
534
|
+
}
|
|
535
|
+
accept(v) {
|
|
536
|
+
v.dateGreaterThanOrEqual(this);
|
|
537
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
var DateLessThanOrEqual = class extends BaseFilterSpecification {
|
|
541
|
+
isSatisfiedBy(value) {
|
|
542
|
+
if (!(value instanceof DateFieldValue)) return false;
|
|
543
|
+
const d1 = value.unpack();
|
|
544
|
+
const d2 = this.value.unpack();
|
|
545
|
+
return !!d1 && !!d2 && ((0, date_fns.isEqual)(d1, d2) || (0, date_fns.isBefore)(d1, d2));
|
|
546
|
+
}
|
|
547
|
+
accept(v) {
|
|
548
|
+
v.dateLessThanOrEqual(this);
|
|
549
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
var DateIsToday = class extends BaseFilterSpecification {
|
|
553
|
+
isSatisfiedBy(value) {
|
|
554
|
+
if (!(value instanceof DateFieldValue)) return false;
|
|
555
|
+
const date = value.unpack();
|
|
556
|
+
return !!date && (0, date_fns.isToday)(date);
|
|
557
|
+
}
|
|
558
|
+
accept(v) {
|
|
559
|
+
v.dateIsToday(this);
|
|
560
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
var DateIsTomorrow = class extends BaseFilterSpecification {
|
|
564
|
+
isSatisfiedBy(value) {
|
|
565
|
+
if (!(value instanceof DateFieldValue)) return false;
|
|
566
|
+
const date = value.unpack();
|
|
567
|
+
return !!date && (0, date_fns.isTomorrow)(date);
|
|
568
|
+
}
|
|
569
|
+
accept(v) {
|
|
570
|
+
v.dateIsTomorrow(this);
|
|
571
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
var DateIsYesterday = class extends BaseFilterSpecification {
|
|
575
|
+
isSatisfiedBy(value) {
|
|
576
|
+
if (!(value instanceof DateFieldValue)) return false;
|
|
577
|
+
const date = value.unpack();
|
|
578
|
+
return !!date && (0, date_fns.isYesterday)(date);
|
|
579
|
+
}
|
|
580
|
+
accept(v) {
|
|
581
|
+
v.dateIsYesterday(this);
|
|
582
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
var DateBetween = class extends BaseFilterSpecification {
|
|
586
|
+
constructor(field, dateStart, dateEnd, relation) {
|
|
587
|
+
super(field, new DateFieldValue(dateStart), relation);
|
|
588
|
+
this.field = field;
|
|
589
|
+
this.dateStart = dateStart;
|
|
590
|
+
this.dateEnd = dateEnd;
|
|
591
|
+
this.relation = relation;
|
|
592
|
+
}
|
|
593
|
+
isSatisfiedBy(value) {
|
|
594
|
+
if (!(value instanceof DateFieldValue)) return false;
|
|
595
|
+
const date = value.unpack();
|
|
596
|
+
return !!date && (0, date_fns.isWithinInterval)(date, {
|
|
597
|
+
start: this.dateStart,
|
|
598
|
+
end: this.dateEnd
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
accept(v) {
|
|
602
|
+
v.dateBetween(this);
|
|
603
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region src/filter/specifications/number.specification.ts
|
|
609
|
+
function isNil(value) {
|
|
610
|
+
return value === null || value === void 0;
|
|
611
|
+
}
|
|
612
|
+
function isNumber(value) {
|
|
613
|
+
return typeof value === "number";
|
|
614
|
+
}
|
|
615
|
+
var NumberEqual = class extends BaseFilterSpecification {
|
|
616
|
+
isSatisfiedBy(value) {
|
|
617
|
+
return value instanceof NumberFieldValue && value.equals(this.value);
|
|
618
|
+
}
|
|
619
|
+
accept(v) {
|
|
620
|
+
v.numberEqual(this);
|
|
621
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
var NumberGreaterThan = class extends BaseFilterSpecification {
|
|
625
|
+
isSatisfiedBy(value) {
|
|
626
|
+
if (!(value instanceof NumberFieldValue)) return false;
|
|
627
|
+
const n1 = value.unpack();
|
|
628
|
+
const n2 = this.value.unpack();
|
|
629
|
+
if (n1 === null && isNumber(n2)) return true;
|
|
630
|
+
return n1 !== null && n2 !== null && n1 > n2;
|
|
631
|
+
}
|
|
632
|
+
accept(v) {
|
|
633
|
+
v.numberGreaterThan(this);
|
|
634
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
var NumberLessThan = class extends BaseFilterSpecification {
|
|
638
|
+
isSatisfiedBy(value) {
|
|
639
|
+
if (!(value instanceof NumberFieldValue)) return false;
|
|
640
|
+
const n1 = value.unpack();
|
|
641
|
+
const n2 = this.value.unpack();
|
|
642
|
+
return n1 !== null && n2 !== null && n1 < n2;
|
|
643
|
+
}
|
|
644
|
+
accept(v) {
|
|
645
|
+
v.numberLessThan(this);
|
|
646
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
var NumberGreaterThanOrEqual = class extends BaseFilterSpecification {
|
|
650
|
+
isSatisfiedBy(value) {
|
|
651
|
+
if (!(value instanceof NumberFieldValue)) return false;
|
|
652
|
+
const n1 = value.unpack();
|
|
653
|
+
const n2 = this.value.unpack();
|
|
654
|
+
if (n1 === null && isNumber(n2)) return true;
|
|
655
|
+
return n1 !== null && n2 !== null && n1 >= n2;
|
|
656
|
+
}
|
|
657
|
+
accept(v) {
|
|
658
|
+
v.numberGreaterThanOrEqual(this);
|
|
659
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
var NumberLessThanOrEqual = class extends BaseFilterSpecification {
|
|
663
|
+
isSatisfiedBy(value) {
|
|
664
|
+
if (!(value instanceof NumberFieldValue)) return false;
|
|
665
|
+
const n1 = value.unpack();
|
|
666
|
+
const n2 = this.value.unpack();
|
|
667
|
+
return n1 !== null && n2 !== null && n1 <= n2;
|
|
668
|
+
}
|
|
669
|
+
accept(v) {
|
|
670
|
+
v.numberLessThanOrEqual(this);
|
|
671
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
var NumberEmpty = class extends BaseFilterSpecification {
|
|
675
|
+
constructor(field) {
|
|
676
|
+
super(field, new NumberFieldValue(null));
|
|
677
|
+
this.field = field;
|
|
678
|
+
}
|
|
679
|
+
isSatisfiedBy(value) {
|
|
680
|
+
return value instanceof NumberFieldValue && isNil(value.unpack());
|
|
681
|
+
}
|
|
682
|
+
accept(v) {
|
|
683
|
+
v.numberEmpty(this);
|
|
684
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
//#endregion
|
|
689
|
+
//#region src/filter/specifications/string.specification.ts
|
|
690
|
+
var StringEqual = class extends BaseFilterSpecification {
|
|
691
|
+
isSatisfiedBy(value) {
|
|
692
|
+
return value instanceof StringFieldValue && this.value.equals(value);
|
|
693
|
+
}
|
|
694
|
+
accept(v) {
|
|
695
|
+
v.stringEqual(this);
|
|
696
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
var StringNotEqual = class extends BaseFilterSpecification {
|
|
700
|
+
isSatisfiedBy(value) {
|
|
701
|
+
return value instanceof StringFieldValue && this.value.equals(value);
|
|
702
|
+
}
|
|
703
|
+
accept(v) {
|
|
704
|
+
v.stringNotEqual(this);
|
|
705
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
var StringContain = class extends BaseFilterSpecification {
|
|
709
|
+
isSatisfiedBy(value) {
|
|
710
|
+
if (!(value instanceof StringFieldValue)) return false;
|
|
711
|
+
const s1 = value.unpack();
|
|
712
|
+
const s2 = this.value.unpack();
|
|
713
|
+
return !!s1 && !!s2 && s1.includes(s2);
|
|
714
|
+
}
|
|
715
|
+
accept(v) {
|
|
716
|
+
v.stringContain(this);
|
|
717
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
var StringStartsWith = class extends BaseFilterSpecification {
|
|
721
|
+
isSatisfiedBy(value) {
|
|
722
|
+
if (!(value instanceof StringFieldValue)) return false;
|
|
723
|
+
const s1 = value.unpack();
|
|
724
|
+
const s2 = this.value.unpack();
|
|
725
|
+
return !!s1 && !!s2 && s1.startsWith(s2);
|
|
726
|
+
}
|
|
727
|
+
accept(v) {
|
|
728
|
+
v.stringStartsWith(this);
|
|
729
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
var StringEndsWith = class extends BaseFilterSpecification {
|
|
733
|
+
isSatisfiedBy(value) {
|
|
734
|
+
if (!(value instanceof StringFieldValue)) return false;
|
|
735
|
+
const s1 = value.unpack();
|
|
736
|
+
const s2 = this.value.unpack();
|
|
737
|
+
return !!s1 && !!s2 && s1.endsWith(s2);
|
|
738
|
+
}
|
|
739
|
+
accept(v) {
|
|
740
|
+
v.stringEndsWith(this);
|
|
741
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
742
|
+
}
|
|
743
|
+
};
|
|
744
|
+
var StringRegex = class extends BaseFilterSpecification {
|
|
745
|
+
isSatisfiedBy(value) {
|
|
746
|
+
if (!(value instanceof StringFieldValue)) return false;
|
|
747
|
+
const s1 = value.unpack();
|
|
748
|
+
const s2 = this.value.unpack();
|
|
749
|
+
return !!s1 && !!s2 && new RegExp(s2).test(s1);
|
|
750
|
+
}
|
|
751
|
+
accept(v) {
|
|
752
|
+
v.stringRegex(this);
|
|
753
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
754
|
+
}
|
|
755
|
+
};
|
|
756
|
+
var StringEmpty = class extends BaseFilterSpecification {
|
|
757
|
+
constructor(field) {
|
|
758
|
+
super(field, new StringFieldValue(null));
|
|
759
|
+
}
|
|
760
|
+
isSatisfiedBy(value) {
|
|
761
|
+
if (value instanceof StringFieldValue) return !value.unpack();
|
|
762
|
+
return !value;
|
|
763
|
+
}
|
|
764
|
+
accept(v) {
|
|
765
|
+
v.stringEmpty(this);
|
|
766
|
+
return (0, oxide_ts.Ok)(void 0);
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
//#endregion
|
|
771
|
+
//#region src/filter/filter.ts
|
|
772
|
+
const filterRoorFilter = (filters) => {
|
|
773
|
+
const filterTuple = [filters[0], ...filters.slice(1)];
|
|
774
|
+
const filter$1 = zod.z.union(filterTuple);
|
|
775
|
+
const group$1 = zod.z.lazy(() => zod.z.object({
|
|
776
|
+
conjunction: conjunctions,
|
|
777
|
+
children: zod.z.union([group$1, filter$1]).array().nonempty().optional()
|
|
778
|
+
}));
|
|
779
|
+
const filterOrGroupList$1 = filter$1.or(group$1).array();
|
|
780
|
+
return group$1.or(filterOrGroupList$1);
|
|
781
|
+
};
|
|
782
|
+
const filter = zod.z.discriminatedUnion("type", [
|
|
783
|
+
numberFilter,
|
|
784
|
+
stringFilter,
|
|
785
|
+
dateFilter,
|
|
786
|
+
booleanFilter
|
|
787
|
+
]);
|
|
788
|
+
const group = zod.z.lazy(() => zod.z.object({
|
|
789
|
+
conjunction: conjunctions,
|
|
790
|
+
children: zod.z.union([group, filter]).array().nonempty().optional()
|
|
791
|
+
}));
|
|
792
|
+
const filterOrGroup = filter.or(group);
|
|
793
|
+
const filterOrGroupList = filterOrGroup.array();
|
|
794
|
+
const rootFilter = filterOrGroup.or(filterOrGroupList);
|
|
795
|
+
const isGroup = (filterOrGroup$1) => {
|
|
796
|
+
return Reflect.has(filterOrGroup$1, "conjunction");
|
|
797
|
+
};
|
|
798
|
+
const isFilter = (filterOrGroup$1) => {
|
|
799
|
+
return Reflect.has(filterOrGroup$1, "type") && Reflect.has(filterOrGroup$1, "operator");
|
|
800
|
+
};
|
|
801
|
+
const operators = zod.z.union([numberFilterOperators, stringFilterOperators]);
|
|
802
|
+
const operatorsMap = { number: numberFilterOperators.options.map((v) => v.value) };
|
|
803
|
+
const convertStringFilter = (filter$1) => {
|
|
804
|
+
if (filter$1.value === void 0) return oxide_ts.None;
|
|
805
|
+
switch (filter$1.operator) {
|
|
806
|
+
case "$eq": return (0, oxide_ts.Some)(new StringEqual(filter$1.field, new StringFieldValue(filter$1.value), filter$1.relation));
|
|
807
|
+
case "$neq": return (0, oxide_ts.Some)(new StringNotEqual(filter$1.field, new StringFieldValue(filter$1.value), filter$1.relation));
|
|
808
|
+
case "$contains": return (0, oxide_ts.Some)(new StringContain(filter$1.field, new StringFieldValue(filter$1.value)));
|
|
809
|
+
case "$not_contains": return (0, oxide_ts.Some)(new StringContain(filter$1.field, new StringFieldValue(filter$1.value)).not());
|
|
810
|
+
case "$starts_with": return (0, oxide_ts.Some)(new StringStartsWith(filter$1.field, new StringFieldValue(filter$1.value)));
|
|
811
|
+
case "$ends_with": return (0, oxide_ts.Some)(new StringEndsWith(filter$1.field, new StringFieldValue(filter$1.value)));
|
|
812
|
+
case "$regex": return (0, oxide_ts.Some)(new StringRegex(filter$1.field, new StringFieldValue(filter$1.value)));
|
|
813
|
+
case "$is_empty": return (0, oxide_ts.Some)(new StringEmpty(filter$1.field));
|
|
814
|
+
case "$is_not_empty": return (0, oxide_ts.Some)(new StringEmpty(filter$1.field).not());
|
|
815
|
+
default: return oxide_ts.None;
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
const convertNumberFilter = (filter$1) => {
|
|
819
|
+
if (filter$1 === void 0) return oxide_ts.None;
|
|
820
|
+
switch (filter$1.operator) {
|
|
821
|
+
case "$eq": return (0, oxide_ts.Some)(new NumberEqual(filter$1.field, new NumberFieldValue(filter$1.value)));
|
|
822
|
+
case "$neq": return (0, oxide_ts.Some)(new NumberEqual(filter$1.field, new NumberFieldValue(filter$1.value)).not());
|
|
823
|
+
case "$gt": return (0, oxide_ts.Some)(new NumberGreaterThan(filter$1.field, new NumberFieldValue(filter$1.value)));
|
|
824
|
+
case "$gte": return (0, oxide_ts.Some)(new NumberGreaterThanOrEqual(filter$1.field, new NumberFieldValue(filter$1.value)));
|
|
825
|
+
case "$lt": return (0, oxide_ts.Some)(new NumberLessThan(filter$1.field, new NumberFieldValue(filter$1.value)));
|
|
826
|
+
case "$lte": return (0, oxide_ts.Some)(new NumberLessThanOrEqual(filter$1.field, new NumberFieldValue(filter$1.value)));
|
|
827
|
+
case "$is_empty": return (0, oxide_ts.Some)(new NumberEmpty(filter$1.field));
|
|
828
|
+
case "$is_not_empty": return (0, oxide_ts.Some)(new NumberEmpty(filter$1.field).not());
|
|
829
|
+
default: return oxide_ts.None;
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
const convertBooleanFilter = (filter$1) => {
|
|
833
|
+
if (filter$1 === void 0) return oxide_ts.None;
|
|
834
|
+
switch (filter$1.operator) {
|
|
835
|
+
case "$eq": return (0, oxide_ts.Some)(new BooleanEqual(filter$1.field, new BooleanFieldValue(filter$1.value)));
|
|
836
|
+
case "$neq": return (0, oxide_ts.Some)(new BooleanNotEqual(filter$1.field, new BooleanFieldValue(filter$1.value)));
|
|
837
|
+
}
|
|
838
|
+
return (0, oxide_ts.Some)(new BooleanEqual(filter$1.field, new BooleanFieldValue(filter$1.value)));
|
|
839
|
+
};
|
|
840
|
+
const convertDateFilter = (filter$1) => {
|
|
841
|
+
if (filter$1 === void 0) return oxide_ts.None;
|
|
842
|
+
switch (filter$1.operator) {
|
|
843
|
+
case "$eq": return (0, oxide_ts.Some)(new DateEqual(filter$1.field, DateFieldValue.fromNullableString(filter$1.value), filter$1.relation));
|
|
844
|
+
case "$between": return (0, oxide_ts.Some)(new DateBetween(filter$1.field, new Date(filter$1.value[0]), new Date(filter$1.value[1])));
|
|
845
|
+
}
|
|
846
|
+
return oxide_ts.None;
|
|
847
|
+
};
|
|
848
|
+
const convertFilter = (filter$1) => {
|
|
849
|
+
return (0, ts_pattern.match)(filter$1).returnType().with({ type: "number" }, (f) => convertNumberFilter(f)).with({ type: "string" }, (f) => convertStringFilter(f)).with({ type: "date" }, (f) => convertDateFilter(f)).with({ type: "boolean" }, (f) => convertBooleanFilter(f)).otherwise(() => oxide_ts.None);
|
|
850
|
+
};
|
|
851
|
+
const convertFilterOrGroup = (filterOrGroup$1) => {
|
|
852
|
+
if (isGroup(filterOrGroup$1)) return convertFilterOrGroupList(filterOrGroup$1.children, filterOrGroup$1.conjunction);
|
|
853
|
+
else if (isFilter(filterOrGroup$1)) return convertFilter(filterOrGroup$1);
|
|
854
|
+
return oxide_ts.None;
|
|
855
|
+
};
|
|
856
|
+
const convertFilterOrGroupList = (filterOrGroupList$1 = [], conjunction = "$and") => {
|
|
857
|
+
let spec = oxide_ts.None;
|
|
858
|
+
for (const filter$1 of filterOrGroupList$1) if (spec.isNone()) {
|
|
859
|
+
spec = convertFilterOrGroup(filter$1);
|
|
860
|
+
if (conjunction === "$not") return spec.map((s) => s.not());
|
|
861
|
+
} else if (isFilter(filter$1)) spec = spec.map((left) => {
|
|
862
|
+
const right = convertFilterOrGroup(filter$1);
|
|
863
|
+
if (right.isSome()) {
|
|
864
|
+
if (conjunction === "$and") return left.and(right.unwrap());
|
|
865
|
+
else if (conjunction === "$or") return left.or(right.unwrap());
|
|
866
|
+
return left.and(right.unwrap().not());
|
|
867
|
+
}
|
|
868
|
+
return left;
|
|
869
|
+
});
|
|
870
|
+
else if (isGroup(filter$1)) spec = convertFilterOrGroupList(filter$1.children, filter$1.conjunction);
|
|
871
|
+
return spec;
|
|
872
|
+
};
|
|
873
|
+
const convertFilterSpec = (filter$1) => {
|
|
874
|
+
if (Array.isArray(filter$1)) return convertFilterOrGroupList(filter$1);
|
|
875
|
+
return convertFilterOrGroup(filter$1);
|
|
876
|
+
};
|
|
877
|
+
function isEmptyNative(value) {
|
|
878
|
+
if (value == null) return true;
|
|
879
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
880
|
+
if (typeof value === "object") {
|
|
881
|
+
for (const _ in value) return false;
|
|
882
|
+
return true;
|
|
883
|
+
}
|
|
884
|
+
return false;
|
|
885
|
+
}
|
|
886
|
+
const isEmptyFilter = (filter$1) => isEmptyNative(filter$1);
|
|
887
|
+
|
|
888
|
+
//#endregion
|
|
889
|
+
//#region src/filter/root-filter.ts
|
|
890
|
+
var RootFilter = class extends ValueObject {
|
|
891
|
+
get value() {
|
|
892
|
+
return this.props;
|
|
893
|
+
}
|
|
894
|
+
get group() {
|
|
895
|
+
if (Array.isArray(this.value)) return {
|
|
896
|
+
conjunction: "$and",
|
|
897
|
+
children: this.value
|
|
898
|
+
};
|
|
899
|
+
if (isGroup(this.value)) return this.value;
|
|
900
|
+
return {
|
|
901
|
+
conjunction: "$and",
|
|
902
|
+
children: [this.value]
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
getSpec() {
|
|
906
|
+
return convertFilterSpec(this.value);
|
|
907
|
+
}
|
|
908
|
+
toJSON() {
|
|
909
|
+
return this.props;
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
//#endregion
|
|
914
|
+
//#region src/pagination.ts
|
|
915
|
+
const paginationSchema = zod.z.object({
|
|
916
|
+
limit: zod.z.coerce.number().positive().int().default(10).optional(),
|
|
917
|
+
offset: zod.z.coerce.number().nonnegative().int().default(0).optional()
|
|
918
|
+
});
|
|
919
|
+
const paginatedResponseSchema = paginationSchema.extend({ total: zod.z.number().nonnegative().int() });
|
|
920
|
+
|
|
921
|
+
//#endregion
|
|
922
|
+
//#region src/query.ts
|
|
923
|
+
var Query = class {};
|
|
924
|
+
|
|
925
|
+
//#endregion
|
|
926
|
+
//#region src/sort.ts
|
|
927
|
+
const sortingSchema = zod.z.record(zod.z.string(), zod.z.enum(["ASC", "DESC"]));
|
|
928
|
+
|
|
929
|
+
//#endregion
|
|
930
|
+
//#region src/value-objects/boolean.vo.ts
|
|
931
|
+
var BoolVO = class BoolVO extends ValueObject {
|
|
932
|
+
constructor(value) {
|
|
933
|
+
super({ value });
|
|
934
|
+
}
|
|
935
|
+
get value() {
|
|
936
|
+
return this.props.value;
|
|
937
|
+
}
|
|
938
|
+
static fromBoolean(value) {
|
|
939
|
+
return new BoolVO(value);
|
|
940
|
+
}
|
|
941
|
+
static True() {
|
|
942
|
+
return new BoolVO(true);
|
|
943
|
+
}
|
|
944
|
+
static False() {
|
|
945
|
+
return new BoolVO(false);
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
//#endregion
|
|
950
|
+
//#region src/value-objects/date.vo.ts
|
|
951
|
+
var DateVO = class DateVO extends ValueObject {
|
|
952
|
+
constructor(value) {
|
|
953
|
+
super({ value: new Date(value) });
|
|
954
|
+
}
|
|
955
|
+
get value() {
|
|
956
|
+
return this.props.value;
|
|
957
|
+
}
|
|
958
|
+
static fromDate(value) {
|
|
959
|
+
return new DateVO(value);
|
|
960
|
+
}
|
|
961
|
+
static now() {
|
|
962
|
+
return new DateVO(Date.now());
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
//#endregion
|
|
967
|
+
//#region src/value-objects/id.vo.ts
|
|
968
|
+
var ID = class extends ValueObject {
|
|
969
|
+
constructor(value) {
|
|
970
|
+
super({ value });
|
|
971
|
+
}
|
|
972
|
+
get value() {
|
|
973
|
+
return this.props.value;
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
//#endregion
|
|
978
|
+
//#region src/value-objects/nanoid.vo.ts
|
|
979
|
+
var NanoID = class NanoID extends ID {
|
|
980
|
+
static ALPHABETS = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
981
|
+
static createId(prefix = "", size = 5) {
|
|
982
|
+
const id = (0, nanoid.customAlphabet)(NanoID.ALPHABETS, size)();
|
|
983
|
+
return prefix + id;
|
|
984
|
+
}
|
|
985
|
+
get value() {
|
|
986
|
+
return this.props.value;
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
//#endregion
|
|
991
|
+
//#region src/value-objects/integer.vo.ts
|
|
992
|
+
var IntegerVO = class IntegerVO extends ValueObject {
|
|
993
|
+
constructor(value) {
|
|
994
|
+
super({ value });
|
|
995
|
+
}
|
|
996
|
+
get value() {
|
|
997
|
+
return this.props.value;
|
|
998
|
+
}
|
|
999
|
+
static fromNumber(value) {
|
|
1000
|
+
return new IntegerVO(value);
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
//#endregion
|
|
1005
|
+
//#region src/value-objects/string.vo.ts
|
|
1006
|
+
var StringVO = class StringVO extends ValueObject {
|
|
1007
|
+
constructor(value) {
|
|
1008
|
+
super({ value });
|
|
1009
|
+
}
|
|
1010
|
+
get value() {
|
|
1011
|
+
return this.props.value;
|
|
1012
|
+
}
|
|
1013
|
+
static fromString(value) {
|
|
1014
|
+
return new StringVO(value);
|
|
1015
|
+
}
|
|
1016
|
+
static empty() {
|
|
1017
|
+
return new StringVO("");
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
//#endregion
|
|
1022
|
+
//#region src/value-objects/uuid.vo.ts
|
|
1023
|
+
var UUID = class extends ID {
|
|
1024
|
+
static createId() {
|
|
1025
|
+
return (0, uuid.v4)();
|
|
1026
|
+
}
|
|
1027
|
+
get value() {
|
|
1028
|
+
return this.props.value;
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
|
|
1032
|
+
//#endregion
|
|
1033
|
+
//#region src/value-objects/email.vo.ts
|
|
1034
|
+
const emailSchema = zod.default.email();
|
|
1035
|
+
var EmailVO = class extends ValueObject {
|
|
1036
|
+
constructor(value) {
|
|
1037
|
+
super({ value });
|
|
1038
|
+
}
|
|
1039
|
+
static create(value) {
|
|
1040
|
+
return new this(emailSchema.parse(value));
|
|
1041
|
+
}
|
|
1042
|
+
get value() {
|
|
1043
|
+
return this.props.value;
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
//#endregion
|
|
1048
|
+
//#region src/value-objects/color.vo.ts
|
|
1049
|
+
const colorSchema = zod.default.hex();
|
|
1050
|
+
var ColorVO = class extends ValueObject {
|
|
1051
|
+
constructor(value) {
|
|
1052
|
+
super({ value });
|
|
1053
|
+
}
|
|
1054
|
+
static create(value) {
|
|
1055
|
+
return new this(colorSchema.parse(value));
|
|
1056
|
+
}
|
|
1057
|
+
get value() {
|
|
1058
|
+
return this.props.value;
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
|
|
1062
|
+
//#endregion
|
|
1063
|
+
exports.$between = $between;
|
|
1064
|
+
exports.$contains = $contains;
|
|
1065
|
+
exports.$end_eq = $end_eq;
|
|
1066
|
+
exports.$end_gt = $end_gt;
|
|
1067
|
+
exports.$end_gte = $end_gte;
|
|
1068
|
+
exports.$end_lt = $end_lt;
|
|
1069
|
+
exports.$end_lte = $end_lte;
|
|
1070
|
+
exports.$end_neq = $end_neq;
|
|
1071
|
+
exports.$ends_with = $ends_with;
|
|
1072
|
+
exports.$eq = $eq;
|
|
1073
|
+
exports.$gt = $gt;
|
|
1074
|
+
exports.$gte = $gte;
|
|
1075
|
+
exports.$has_file_extension = $has_file_extension;
|
|
1076
|
+
exports.$has_file_type = $has_file_type;
|
|
1077
|
+
exports.$in = $in;
|
|
1078
|
+
exports.$is_empty = $is_empty;
|
|
1079
|
+
exports.$is_false = $is_false;
|
|
1080
|
+
exports.$is_me = $is_me;
|
|
1081
|
+
exports.$is_not_empty = $is_not_empty;
|
|
1082
|
+
exports.$is_not_me = $is_not_me;
|
|
1083
|
+
exports.$is_not_today = $is_not_today;
|
|
1084
|
+
exports.$is_root = $is_root;
|
|
1085
|
+
exports.$is_today = $is_today;
|
|
1086
|
+
exports.$is_tomorrow = $is_tomorrow;
|
|
1087
|
+
exports.$is_true = $is_true;
|
|
1088
|
+
exports.$is_yesterday = $is_yesterday;
|
|
1089
|
+
exports.$lt = $lt;
|
|
1090
|
+
exports.$lte = $lte;
|
|
1091
|
+
exports.$neq = $neq;
|
|
1092
|
+
exports.$nin = $nin;
|
|
1093
|
+
exports.$not_contains = $not_contains;
|
|
1094
|
+
exports.$regex = $regex;
|
|
1095
|
+
exports.$start_eq = $start_eq;
|
|
1096
|
+
exports.$start_gt = $start_gt;
|
|
1097
|
+
exports.$start_gte = $start_gte;
|
|
1098
|
+
exports.$start_lt = $start_lt;
|
|
1099
|
+
exports.$start_lte = $start_lte;
|
|
1100
|
+
exports.$start_neq = $start_neq;
|
|
1101
|
+
exports.$starts_with = $starts_with;
|
|
1102
|
+
exports.AggregateRoot = AggregateRoot;
|
|
1103
|
+
exports.BaseEvent = BaseEvent;
|
|
1104
|
+
exports.BaseFilterSpecification = BaseFilterSpecification;
|
|
1105
|
+
exports.BoolVO = BoolVO;
|
|
1106
|
+
exports.BooleanEqual = BooleanEqual;
|
|
1107
|
+
exports.BooleanFieldValue = BooleanFieldValue;
|
|
1108
|
+
exports.BooleanNotEqual = BooleanNotEqual;
|
|
1109
|
+
exports.ColorVO = ColorVO;
|
|
1110
|
+
exports.Command = Command;
|
|
1111
|
+
exports.CompositeSpecification = CompositeSpecification;
|
|
1112
|
+
exports.DateBetween = DateBetween;
|
|
1113
|
+
exports.DateEqual = DateEqual;
|
|
1114
|
+
exports.DateFieldValue = DateFieldValue;
|
|
1115
|
+
exports.DateGreaterThan = DateGreaterThan;
|
|
1116
|
+
exports.DateGreaterThanOrEqual = DateGreaterThanOrEqual;
|
|
1117
|
+
exports.DateIsToday = DateIsToday;
|
|
1118
|
+
exports.DateIsTomorrow = DateIsTomorrow;
|
|
1119
|
+
exports.DateIsYesterday = DateIsYesterday;
|
|
1120
|
+
exports.DateLessThan = DateLessThan;
|
|
1121
|
+
exports.DateLessThanOrEqual = DateLessThanOrEqual;
|
|
1122
|
+
exports.DateVO = DateVO;
|
|
1123
|
+
exports.EmailVO = EmailVO;
|
|
1124
|
+
exports.ExceptionBase = ExceptionBase;
|
|
1125
|
+
exports.FieldValueBase = FieldValueBase;
|
|
1126
|
+
exports.ID = ID;
|
|
1127
|
+
exports.IntegerVO = IntegerVO;
|
|
1128
|
+
exports.NanoID = NanoID;
|
|
1129
|
+
exports.NumberEmpty = NumberEmpty;
|
|
1130
|
+
exports.NumberEqual = NumberEqual;
|
|
1131
|
+
exports.NumberFieldValue = NumberFieldValue;
|
|
1132
|
+
exports.NumberGreaterThan = NumberGreaterThan;
|
|
1133
|
+
exports.NumberGreaterThanOrEqual = NumberGreaterThanOrEqual;
|
|
1134
|
+
exports.NumberLessThan = NumberLessThan;
|
|
1135
|
+
exports.NumberLessThanOrEqual = NumberLessThanOrEqual;
|
|
1136
|
+
exports.Query = Query;
|
|
1137
|
+
exports.RootFilter = RootFilter;
|
|
1138
|
+
exports.StringContain = StringContain;
|
|
1139
|
+
exports.StringEmpty = StringEmpty;
|
|
1140
|
+
exports.StringEndsWith = StringEndsWith;
|
|
1141
|
+
exports.StringEqual = StringEqual;
|
|
1142
|
+
exports.StringFieldValue = StringFieldValue;
|
|
1143
|
+
exports.StringNotEqual = StringNotEqual;
|
|
1144
|
+
exports.StringRegex = StringRegex;
|
|
1145
|
+
exports.StringStartsWith = StringStartsWith;
|
|
1146
|
+
exports.StringVO = StringVO;
|
|
1147
|
+
exports.UUID = UUID;
|
|
1148
|
+
exports.ValueObject = ValueObject;
|
|
1149
|
+
exports.and = and;
|
|
1150
|
+
exports.andOptions = andOptions;
|
|
1151
|
+
exports.baseFilter = baseFilter;
|
|
1152
|
+
exports.booleanFieldValue = booleanFieldValue;
|
|
1153
|
+
exports.booleanFilter = booleanFilter;
|
|
1154
|
+
exports.booleanFilterOperators = booleanFilterOperators;
|
|
1155
|
+
exports.booleanFilterValue = booleanFilterValue;
|
|
1156
|
+
exports.conjunctions = conjunctions;
|
|
1157
|
+
exports.convertFilterSpec = convertFilterSpec;
|
|
1158
|
+
exports.convertPropsToObject = convertPropsToObject;
|
|
1159
|
+
exports.dateFieldValue = dateFieldValue;
|
|
1160
|
+
exports.dateFilter = dateFilter;
|
|
1161
|
+
exports.dateFilterOperators = dateFilterOperators;
|
|
1162
|
+
exports.dateFilterValue = dateFilterValue;
|
|
1163
|
+
exports.eventSchema = eventSchema;
|
|
1164
|
+
exports.filterOrGroupList = filterOrGroupList;
|
|
1165
|
+
exports.filterRoorFilter = filterRoorFilter;
|
|
1166
|
+
exports.isEmptyFilter = isEmptyFilter;
|
|
1167
|
+
exports.isFilter = isFilter;
|
|
1168
|
+
exports.isGroup = isGroup;
|
|
1169
|
+
exports.isOperatorWithoutValue = isOperatorWithoutValue;
|
|
1170
|
+
exports.numberFieldValue = numberFieldValue;
|
|
1171
|
+
exports.numberFilter = numberFilter;
|
|
1172
|
+
exports.numberFilterOperators = numberFilterOperators;
|
|
1173
|
+
exports.numberFilterValue = numberFilterValue;
|
|
1174
|
+
exports.operators = operators;
|
|
1175
|
+
exports.operatorsMap = operatorsMap;
|
|
1176
|
+
exports.operatorsWihtoutValue = operatorsWihtoutValue;
|
|
1177
|
+
exports.or = or;
|
|
1178
|
+
exports.paginatedResponseSchema = paginatedResponseSchema;
|
|
1179
|
+
exports.paginationSchema = paginationSchema;
|
|
1180
|
+
exports.rootFilter = rootFilter;
|
|
1181
|
+
exports.sortingSchema = sortingSchema;
|
|
1182
|
+
exports.stringFieldValue = stringFieldValue;
|
|
1183
|
+
exports.stringFilter = stringFilter;
|
|
1184
|
+
exports.stringFilterOperators = stringFilterOperators;
|
|
1185
|
+
exports.stringFilterValue = stringFilterValue;
|
|
1186
|
+
//# sourceMappingURL=index.cjs.map
|