grafeo-ogm 2.0.0 → 2.1.1
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/CHANGELOG.md +105 -0
- package/dist/cjs/compilers/mutation.compiler.d.ts +7 -0
- package/dist/cjs/compilers/mutation.compiler.d.ts.map +1 -1
- package/dist/cjs/compilers/mutation.compiler.js +130 -36
- package/dist/cjs/compilers/mutation.compiler.js.map +1 -1
- package/dist/cjs/compilers/where.compiler.d.ts.map +1 -1
- package/dist/cjs/compilers/where.compiler.js +13 -4
- package/dist/cjs/compilers/where.compiler.js.map +1 -1
- package/dist/cjs/generator/type-emitters/utility-types.js +1 -1
- package/dist/cjs/utils/write-coercion.d.ts +62 -0
- package/dist/cjs/utils/write-coercion.d.ts.map +1 -0
- package/dist/cjs/utils/write-coercion.js +283 -0
- package/dist/cjs/utils/write-coercion.js.map +1 -0
- package/dist/esm/compilers/mutation.compiler.d.ts +7 -0
- package/dist/esm/compilers/mutation.compiler.d.ts.map +1 -1
- package/dist/esm/compilers/mutation.compiler.js +130 -36
- package/dist/esm/compilers/mutation.compiler.js.map +1 -1
- package/dist/esm/compilers/where.compiler.d.ts.map +1 -1
- package/dist/esm/compilers/where.compiler.js +13 -4
- package/dist/esm/compilers/where.compiler.js.map +1 -1
- package/dist/esm/generator/type-emitters/utility-types.js +1 -1
- package/dist/esm/utils/write-coercion.d.ts +62 -0
- package/dist/esm/utils/write-coercion.d.ts.map +1 -0
- package/dist/esm/utils/write-coercion.js +276 -0
- package/dist/esm/utils/write-coercion.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.coerceWriteValue = coerceWriteValue;
|
|
4
|
+
exports.wrapWriteExpr = wrapWriteExpr;
|
|
5
|
+
exports.wrapListItemExpr = wrapListItemExpr;
|
|
6
|
+
exports.wrapWhereParam = wrapWhereParam;
|
|
7
|
+
exports.resolveDefaultWriteValue = resolveDefaultWriteValue;
|
|
8
|
+
const neo4j_driver_1 = require("neo4j-driver");
|
|
9
|
+
const errors_1 = require("../errors");
|
|
10
|
+
/**
|
|
11
|
+
* GraphQL scalar types whose Neo4j storage type is INTEGER (Long).
|
|
12
|
+
*/
|
|
13
|
+
const INTEGER_SCALAR_TYPES = new Set(['Int', 'BigInt']);
|
|
14
|
+
/**
|
|
15
|
+
* Temporal scalar types → the Cypher constructor that parses their ISO
|
|
16
|
+
* string form into the native Neo4j temporal type. Writes wrap the
|
|
17
|
+
* *parameter* in the constructor instead of converting the value in JS,
|
|
18
|
+
* because Neo4j's own parsers handle everything JS `Date` cannot:
|
|
19
|
+
* nanosecond precision, bracket timezone names
|
|
20
|
+
* (`2024-01-15T10:30:00[America/New_York]`), and ISO-8601 durations.
|
|
21
|
+
*/
|
|
22
|
+
const TEMPORAL_CONSTRUCTORS = {
|
|
23
|
+
DateTime: 'datetime',
|
|
24
|
+
LocalDateTime: 'localdatetime',
|
|
25
|
+
Date: 'date',
|
|
26
|
+
Time: 'time',
|
|
27
|
+
LocalTime: 'localtime',
|
|
28
|
+
Duration: 'duration',
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Spatial scalar types → Cypher's `point()` constructor. Reads flatten a
|
|
32
|
+
* native Point into a plain `{ x, y[, z], srid }` object (ResultMapper),
|
|
33
|
+
* and `point()` accepts exactly that map back — `srid` key included — so
|
|
34
|
+
* wrapping makes the read → write round-trip exact. Without the wrapper
|
|
35
|
+
* the plain object is bound as a map property value, which Neo4j rejects
|
|
36
|
+
* at runtime ("Property values can only be of primitive types...").
|
|
37
|
+
*/
|
|
38
|
+
const POINT_SCALAR_TYPES = new Set(['Point', 'CartesianPoint']);
|
|
39
|
+
/**
|
|
40
|
+
* Where-operator suffixes whose parameter is compared against the field
|
|
41
|
+
* value (`''` = plain equality) and therefore needs the same constructor
|
|
42
|
+
* treatment as writes. String operators (`_CONTAINS`, `_STARTS_WITH`,
|
|
43
|
+
* `_MATCHES`, ...) are excluded — their params are strings by definition.
|
|
44
|
+
*/
|
|
45
|
+
const COMPARABLE_SUFFIXES = new Set([
|
|
46
|
+
'',
|
|
47
|
+
'_NOT',
|
|
48
|
+
'_GT',
|
|
49
|
+
'_GTE',
|
|
50
|
+
'_LT',
|
|
51
|
+
'_LTE',
|
|
52
|
+
'_IN',
|
|
53
|
+
'_NOT_IN',
|
|
54
|
+
]);
|
|
55
|
+
function isTemporalStringInput(value) {
|
|
56
|
+
return typeof value === 'string';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A plain object shaped like `point()` input: cartesian (`x`/`y`) or
|
|
60
|
+
* geographic (`longitude`/`latitude`), optionally with `z`/`height` and
|
|
61
|
+
* `srid`/`crs`. Driver Point instances are NOT inputs — they pack
|
|
62
|
+
* natively and `point()` would reject them.
|
|
63
|
+
*/
|
|
64
|
+
function isPointWriteInput(value) {
|
|
65
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
66
|
+
return false;
|
|
67
|
+
if ((0, neo4j_driver_1.isPoint)(value) || (0, neo4j_driver_1.isInt)(value))
|
|
68
|
+
return false;
|
|
69
|
+
const candidate = value;
|
|
70
|
+
const cartesian = typeof candidate.x === 'number' && typeof candidate.y === 'number';
|
|
71
|
+
const geographic = typeof candidate.longitude === 'number' &&
|
|
72
|
+
typeof candidate.latitude === 'number';
|
|
73
|
+
return cartesian || geographic;
|
|
74
|
+
}
|
|
75
|
+
function resolveWriteConstructor(propDef) {
|
|
76
|
+
const temporal = TEMPORAL_CONSTRUCTORS[propDef.type];
|
|
77
|
+
if (temporal !== undefined)
|
|
78
|
+
return { fn: temporal, wraps: isTemporalStringInput, arrayMode: 'any' };
|
|
79
|
+
if (POINT_SCALAR_TYPES.has(propDef.type))
|
|
80
|
+
return { fn: 'point', wraps: isPointWriteInput, arrayMode: 'all' };
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Decide whether a list of element values should be wrapped element-wise.
|
|
85
|
+
* `'any'` mode wraps as soon as one element is constructor input; `'all'`
|
|
86
|
+
* mode requires uniformity and throws on a mix, because the constructor
|
|
87
|
+
* cannot be applied to the already-native elements.
|
|
88
|
+
*/
|
|
89
|
+
function decideElementsWrap(elements, ctor, propDef) {
|
|
90
|
+
const defined = elements.filter((el) => el !== null && el !== undefined);
|
|
91
|
+
if (defined.length === 0)
|
|
92
|
+
return false;
|
|
93
|
+
const matches = defined.filter((el) => ctor.wraps(el)).length;
|
|
94
|
+
if (matches === 0)
|
|
95
|
+
return false;
|
|
96
|
+
if (ctor.arrayMode === 'any')
|
|
97
|
+
return true;
|
|
98
|
+
if (matches !== defined.length)
|
|
99
|
+
throw new errors_1.OGMError(`Mixed input representations for ${propDef.type} field "${propDef.name}": ` +
|
|
100
|
+
`some values are plain ${ctor.fn}() inputs, others are driver-native values. ` +
|
|
101
|
+
`${ctor.fn}() cannot be applied to an already-native value, so every value ` +
|
|
102
|
+
`must use the same representation.`);
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Coerce a JS write value bound for an `Int`/`BigInt`-typed schema field
|
|
107
|
+
* into a Neo4j Integer so the stored property is a Long, not a Double.
|
|
108
|
+
*
|
|
109
|
+
* The driver packs EVERY JS `number` as a Bolt FLOAT64 (packstream:
|
|
110
|
+
* `typeof x === 'number'` → `packFloat`) — `disableLosslessIntegers`
|
|
111
|
+
* only affects the read direction. Reads convert Integer → number
|
|
112
|
+
* (ResultMapper), so without write-side coercion the round-trip is
|
|
113
|
+
* asymmetric: every OGM-written Int property lands as a Double. Once a
|
|
114
|
+
* field holds a mixed Long/Double population, Long-typed consumers break
|
|
115
|
+
* (e.g. `apoc.coll.sortMulti` throws `java.lang.Double cannot be cast to
|
|
116
|
+
* class java.lang.Long`).
|
|
117
|
+
*
|
|
118
|
+
* Non-integral numbers and non-integer strings for Int/BigInt fields
|
|
119
|
+
* throw instead of truncating or storing a String property, matching the
|
|
120
|
+
* v1.14 contract of rejecting inputs that would be silently corrupted.
|
|
121
|
+
* Values the coercion doesn't own — null/undefined, driver Integer
|
|
122
|
+
* instances, fields of any other scalar type, or fields absent from the
|
|
123
|
+
* schema — pass through untouched.
|
|
124
|
+
*/
|
|
125
|
+
function coerceWriteValue(value, propDef) {
|
|
126
|
+
if (propDef === undefined || value === null || value === undefined)
|
|
127
|
+
return value;
|
|
128
|
+
if (!INTEGER_SCALAR_TYPES.has(propDef.type))
|
|
129
|
+
return value;
|
|
130
|
+
if (propDef.isArray) {
|
|
131
|
+
if (!Array.isArray(value))
|
|
132
|
+
return value;
|
|
133
|
+
return value.map((element) => coerceIntegerElement(element, propDef));
|
|
134
|
+
}
|
|
135
|
+
return coerceIntegerElement(value, propDef);
|
|
136
|
+
}
|
|
137
|
+
function coerceIntegerElement(value, propDef) {
|
|
138
|
+
if (value === null || value === undefined)
|
|
139
|
+
return value;
|
|
140
|
+
// `int()` accepts strings in every driver major — `toString()` keeps
|
|
141
|
+
// bigint inputs working regardless of the installed driver's overloads.
|
|
142
|
+
if (typeof value === 'bigint')
|
|
143
|
+
return (0, neo4j_driver_1.int)(value.toString());
|
|
144
|
+
if (typeof value === 'number') {
|
|
145
|
+
if (!Number.isInteger(value))
|
|
146
|
+
throw new errors_1.OGMError(`Expected an integer for ${propDef.type} field "${propDef.name}" but got ${value}. ` +
|
|
147
|
+
`Storing it would corrupt the property's integer type; pass a whole number ` +
|
|
148
|
+
`(or declare the field as Float).`);
|
|
149
|
+
return (0, neo4j_driver_1.int)(value);
|
|
150
|
+
}
|
|
151
|
+
if (typeof value === 'string') {
|
|
152
|
+
// The generated BigInt scalar declares `input: string` (64-bit values
|
|
153
|
+
// don't fit a JS number), so integer strings are the CANONICAL input
|
|
154
|
+
// shape for BigInt fields — binding them raw would store a String
|
|
155
|
+
// property. Same reject-don't-corrupt rule as numbers for anything
|
|
156
|
+
// that isn't a plain base-10 integer literal.
|
|
157
|
+
if (!/^-?\d+$/.test(value))
|
|
158
|
+
throw new errors_1.OGMError(`Expected an integer for ${propDef.type} field "${propDef.name}" but got the string "${value}". ` +
|
|
159
|
+
`Pass a base-10 integer literal string, a whole number, or a bigint.`);
|
|
160
|
+
return (0, neo4j_driver_1.int)(value);
|
|
161
|
+
}
|
|
162
|
+
// Already a driver Integer — pass through unchanged.
|
|
163
|
+
if ((0, neo4j_driver_1.isInt)(value))
|
|
164
|
+
return value;
|
|
165
|
+
return value;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Wrap a write RHS expression (`$param`, or an UNWIND item reference) in
|
|
169
|
+
* the field's Cypher constructor — temporal (`datetime()`, ...) for
|
|
170
|
+
* ISO-string inputs, `point()` for plain point maps — so the stored
|
|
171
|
+
* property is the native type the schema declares. Reads convert native
|
|
172
|
+
* values to plain JS (ResultMapper); this is the write half of the same
|
|
173
|
+
* round-trip symmetry issue #5 fixed for integers.
|
|
174
|
+
*
|
|
175
|
+
* Driver-native values (temporal instances, Point instances) bind raw.
|
|
176
|
+
* List fields wrap element-wise via a list comprehension, following the
|
|
177
|
+
* constructor's element rule (see WriteConstructor.arrayMode).
|
|
178
|
+
*/
|
|
179
|
+
function wrapWriteExpr(expr, value, propDef) {
|
|
180
|
+
if (propDef === undefined)
|
|
181
|
+
return expr;
|
|
182
|
+
const ctor = resolveWriteConstructor(propDef);
|
|
183
|
+
if (ctor === undefined)
|
|
184
|
+
return expr;
|
|
185
|
+
if (propDef.isArray) {
|
|
186
|
+
if (!Array.isArray(value))
|
|
187
|
+
return expr;
|
|
188
|
+
if (!decideElementsWrap(value, ctor, propDef))
|
|
189
|
+
return expr;
|
|
190
|
+
return `[wc_t IN ${expr} | ${ctor.fn}(wc_t)]`;
|
|
191
|
+
}
|
|
192
|
+
if (!ctor.wraps(value))
|
|
193
|
+
return expr;
|
|
194
|
+
return `${ctor.fn}(${expr})`;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Constructor wrapping for UNWIND item references (`item.prop`,
|
|
198
|
+
* `connItem.edge.prop`), where ONE Cypher expression serves EVERY item in
|
|
199
|
+
* the batch: the wrap decision must hold for all items' values for the
|
|
200
|
+
* key. A column mixing constructor inputs with driver-native values
|
|
201
|
+
* throws — a single expression cannot be correct for both.
|
|
202
|
+
*/
|
|
203
|
+
function wrapListItemExpr(expr, values, propDef) {
|
|
204
|
+
if (propDef === undefined)
|
|
205
|
+
return expr;
|
|
206
|
+
const ctor = resolveWriteConstructor(propDef);
|
|
207
|
+
if (ctor === undefined)
|
|
208
|
+
return expr;
|
|
209
|
+
if (propDef.isArray) {
|
|
210
|
+
const flattened = values
|
|
211
|
+
.filter((v) => Array.isArray(v))
|
|
212
|
+
.flat();
|
|
213
|
+
if (flattened.length === 0)
|
|
214
|
+
return expr;
|
|
215
|
+
if (!decideElementsWrap(flattened, ctor, propDef))
|
|
216
|
+
return expr;
|
|
217
|
+
return `[wc_t IN ${expr} | ${ctor.fn}(wc_t)]`;
|
|
218
|
+
}
|
|
219
|
+
const defined = values.filter((v) => v !== null && v !== undefined);
|
|
220
|
+
if (defined.length === 0)
|
|
221
|
+
return expr;
|
|
222
|
+
const matches = defined.filter((v) => ctor.wraps(v)).length;
|
|
223
|
+
if (matches === 0)
|
|
224
|
+
return expr;
|
|
225
|
+
if (matches !== defined.length)
|
|
226
|
+
throw new errors_1.OGMError(`Mixed input types for ${propDef.type} field "${propDef.name}": some items pass ` +
|
|
227
|
+
`plain ${ctor.fn}() inputs, others pass driver-native values. Batched writes ` +
|
|
228
|
+
`share one Cypher expression per field, so every item must use the same ` +
|
|
229
|
+
`representation.`);
|
|
230
|
+
return `${ctor.fn}(${expr})`;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Wrap a WHERE parameter reference for a constructor-typed field. With
|
|
234
|
+
* properties stored natively, comparing them to a raw string/map param is
|
|
235
|
+
* a cross-type comparison — Neo4j evaluates it to NULL and silently
|
|
236
|
+
* drops the row. `suffix` is the operator suffix (`''` for plain
|
|
237
|
+
* equality); only comparison-shaped operators wrap, and `_IN`/`_NOT_IN`
|
|
238
|
+
* wrap their list param element-wise.
|
|
239
|
+
*/
|
|
240
|
+
function wrapWhereParam(paramRef, value, propDef, suffix) {
|
|
241
|
+
if (propDef === undefined)
|
|
242
|
+
return paramRef;
|
|
243
|
+
const ctor = resolveWriteConstructor(propDef);
|
|
244
|
+
if (ctor === undefined)
|
|
245
|
+
return paramRef;
|
|
246
|
+
if (!COMPARABLE_SUFFIXES.has(suffix))
|
|
247
|
+
return paramRef;
|
|
248
|
+
if (suffix === '_IN' || suffix === '_NOT_IN') {
|
|
249
|
+
if (!Array.isArray(value))
|
|
250
|
+
return paramRef;
|
|
251
|
+
if (!decideElementsWrap(value, ctor, propDef))
|
|
252
|
+
return paramRef;
|
|
253
|
+
return `[wc_t IN ${paramRef} | ${ctor.fn}(wc_t)]`;
|
|
254
|
+
}
|
|
255
|
+
if (!ctor.wraps(value))
|
|
256
|
+
return paramRef;
|
|
257
|
+
return `${ctor.fn}(${paramRef})`;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Materialize a parsed `@default` into a driver-ready bound value. The
|
|
261
|
+
* parser stores every default as a string (`'true'`, `'5'`, `'WELCOME'`);
|
|
262
|
+
* conversion is by declared scalar type, and Int/BigInt defaults route
|
|
263
|
+
* through the same Integer coercion as user input. Temporal defaults stay
|
|
264
|
+
* ISO strings here — they get their constructor wrapper at the binding
|
|
265
|
+
* site like any other temporal write.
|
|
266
|
+
*/
|
|
267
|
+
function resolveDefaultWriteValue(propDef) {
|
|
268
|
+
const raw = propDef.defaultValue;
|
|
269
|
+
if (raw === undefined)
|
|
270
|
+
return undefined;
|
|
271
|
+
switch (propDef.type) {
|
|
272
|
+
case 'Boolean':
|
|
273
|
+
return raw === 'true';
|
|
274
|
+
case 'Float':
|
|
275
|
+
return Number(raw);
|
|
276
|
+
case 'Int':
|
|
277
|
+
case 'BigInt':
|
|
278
|
+
return coerceWriteValue(raw, propDef);
|
|
279
|
+
default:
|
|
280
|
+
return raw;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=write-coercion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-coercion.js","sourceRoot":"","sources":["../../../src/utils/write-coercion.ts"],"names":[],"mappings":";;AAwJA,4CAcC;AAiDD,sCAeC;AASD,4CA4BC;AAUD,wCAiBC;AAUD,4DAcC;AA9TD,+CAAmD;AACnD,sCAAqC;AAGrC;;GAEG;AACH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,qBAAqB,GAA2B;IACpD,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,EAAE;IACF,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,KAAK;IACL,SAAS;CACV,CAAC,CAAC;AAqBH,SAAS,qBAAqB,CAAC,KAAc;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrE,OAAO,KAAK,CAAC;IACf,IAAI,IAAA,sBAAO,EAAC,KAAK,CAAC,IAAI,IAAA,oBAA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OAAO,CAAC,YAAY,CAAC;IACjC,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,SAAS;YACZ,OAAO,GAAG,KAAK,MAAM,CAAC;QACxB,KAAK,OAAO;YACV,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;QACrB,KAAK,KAAK,CAAC;QACX,KAAK,QAAQ;YACX,OAAO,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACxC;YACE,OAAO,GAAG,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -120,6 +120,13 @@ export declare class MutationCompiler {
|
|
|
120
120
|
* Returns count of created nodes.
|
|
121
121
|
*/
|
|
122
122
|
compileCreateMany(data: Record<string, unknown>[], nodeDef: NodeDefinition, skipDuplicates?: boolean, labels?: string[]): MutationResult;
|
|
123
|
+
/**
|
|
124
|
+
* Resolve the PropertyDefinition of an edge (relationship) property so
|
|
125
|
+
* Int/BigInt edge writes get the same Integer coercion as node writes.
|
|
126
|
+
* Returns undefined when the relationship declares no properties type
|
|
127
|
+
* (the coercion then passes the value through untouched).
|
|
128
|
+
*/
|
|
129
|
+
private getEdgePropDef;
|
|
123
130
|
private buildCreateProperties;
|
|
124
131
|
private buildCreateRelationships;
|
|
125
132
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutation.compiler.d.ts","sourceRoot":"","sources":["../../../src/compilers/mutation.compiler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EACL,cAAc,
|
|
1
|
+
{"version":3,"file":"mutation.compiler.d.ts","sourceRoot":"","sources":["../../../src/compilers/mutation.compiler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAu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