@nhtio/lucid-resourceful 1.20261021.2 → 1.20261109.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{index-D2_5jiWy.js → index-BBctNPro.js} +85 -9
- package/{index-D2_5jiWy.js.map → index-BBctNPro.js.map} +1 -1
- package/{index-CLB6pSi4.cjs → index-COWpCL_r.cjs} +85 -9
- package/{index-CLB6pSi4.cjs.map → index-COWpCL_r.cjs.map} +1 -1
- package/index.cjs +1 -1
- package/index.mjs +1 -1
- package/integration/provider.cjs +1 -1
- package/integration/provider.mjs +1 -1
- package/package.json +24 -24
- package/router/utils.cjs +1 -1
- package/router/utils.mjs +1 -1
- package/router.cjs +1 -1
- package/router.mjs +1 -1
|
@@ -15357,6 +15357,8 @@ class ODataToLucidTranslator {
|
|
|
15357
15357
|
}
|
|
15358
15358
|
// (date/math helper mappings removed in favor of dialect-aware #getSqlFns())
|
|
15359
15359
|
}
|
|
15360
|
+
const MIN_DOTNET_DATETIME = DateTime.utc(1, 1, 1);
|
|
15361
|
+
const MAX_DOTNET_DATETIME = DateTime.utc(9999, 12, 31, 23, 59, 59, 999);
|
|
15360
15362
|
const encoder = (_key, value) => {
|
|
15361
15363
|
if (value instanceof Date) {
|
|
15362
15364
|
return DateTime.fromJSDate(value).toISO();
|
|
@@ -15500,12 +15502,6 @@ const coerceEntityForIeee754 = (entity, model, ieee754Compatible, metaCache, vis
|
|
|
15500
15502
|
if (serializeAs === null) continue;
|
|
15501
15503
|
const jsonKey = serializeAs || propertyKey;
|
|
15502
15504
|
if (!(jsonKey in entity)) continue;
|
|
15503
|
-
if (isInstanceOf(prop.definition.type, "ResourcefulDateType", ResourcefulDateType)) {
|
|
15504
|
-
const date = entity[jsonKey];
|
|
15505
|
-
if (date instanceof DateTime) entity[jsonKey] = date.toISODate();
|
|
15506
|
-
else if (date instanceof Date) entity[jsonKey] = DateTime.fromJSDate(date).toISODate();
|
|
15507
|
-
continue;
|
|
15508
|
-
}
|
|
15509
15505
|
if (!isIeee754CompatibleRelevantType(prop.definition.type)) continue;
|
|
15510
15506
|
coerceNumericField(entity, jsonKey, ieee754Compatible);
|
|
15511
15507
|
continue;
|
|
@@ -15546,6 +15542,75 @@ const coerceEntityForIeee754 = (entity, model, ieee754Compatible, metaCache, vis
|
|
|
15546
15542
|
}
|
|
15547
15543
|
}
|
|
15548
15544
|
};
|
|
15545
|
+
const toLuxonDateTime = (raw) => {
|
|
15546
|
+
if (raw instanceof DateTime) return raw;
|
|
15547
|
+
if (raw instanceof Date) return DateTime.fromJSDate(raw);
|
|
15548
|
+
if (typeof raw === "string") return DateTime.fromISO(raw, { setZone: true });
|
|
15549
|
+
if (raw && typeof raw === "object" && raw.isLuxonDateTime === true && typeof raw.toISO === "function") {
|
|
15550
|
+
const iso = raw.toISO();
|
|
15551
|
+
return iso ? DateTime.fromISO(iso, { setZone: true }) : void 0;
|
|
15552
|
+
}
|
|
15553
|
+
return void 0;
|
|
15554
|
+
};
|
|
15555
|
+
const coerceDateValueToRange = (raw, kind, nullable) => {
|
|
15556
|
+
const date = toLuxonDateTime(raw);
|
|
15557
|
+
if (!date?.isValid) return void 0;
|
|
15558
|
+
if (kind === "date") {
|
|
15559
|
+
if (date.year < 1 || date.year > 9999) {
|
|
15560
|
+
return nullable ? null : date.year < 1 ? "0001-01-01" : "9999-12-31";
|
|
15561
|
+
}
|
|
15562
|
+
return typeof raw === "string" ? void 0 : date.toISODate();
|
|
15563
|
+
}
|
|
15564
|
+
const millis = date.toUTC().toMillis();
|
|
15565
|
+
const below = date.year < 1 || millis < MIN_DOTNET_DATETIME.toMillis();
|
|
15566
|
+
if (below || date.year > 9999 || millis > MAX_DOTNET_DATETIME.toMillis()) {
|
|
15567
|
+
return nullable ? null : below ? MIN_DOTNET_DATETIME.toISO() : MAX_DOTNET_DATETIME.toISO();
|
|
15568
|
+
}
|
|
15569
|
+
return void 0;
|
|
15570
|
+
};
|
|
15571
|
+
const coerceEntityDateRange = (entity, model, metaCache, visited = /* @__PURE__ */ new WeakSet()) => {
|
|
15572
|
+
if (visited.has(entity)) return;
|
|
15573
|
+
visited.add(entity);
|
|
15574
|
+
const meta = metaCache.get(model);
|
|
15575
|
+
if (!meta) return;
|
|
15576
|
+
for (const [propertyKey, prop] of Object.entries(meta.properties)) {
|
|
15577
|
+
if (prop.kind === "column" || prop.kind === "computedAccessor") {
|
|
15578
|
+
const serializeAs = prop.lucidDefinitions?.serializeAs;
|
|
15579
|
+
if (serializeAs === null) continue;
|
|
15580
|
+
const key = serializeAs || propertyKey;
|
|
15581
|
+
if (!(key in entity)) continue;
|
|
15582
|
+
const dateType = isInstanceOf(
|
|
15583
|
+
prop.definition.type,
|
|
15584
|
+
"ResourcefulDateType",
|
|
15585
|
+
ResourcefulDateType
|
|
15586
|
+
);
|
|
15587
|
+
if (!dateType && !isInstanceOf(prop.definition.type, "ResourcefulDateTimeType", ResourcefulDateTimeType))
|
|
15588
|
+
continue;
|
|
15589
|
+
const coerced = coerceDateValueToRange(
|
|
15590
|
+
entity[key],
|
|
15591
|
+
dateType ? "date" : "dateTime",
|
|
15592
|
+
prop.definition.nullable
|
|
15593
|
+
);
|
|
15594
|
+
if (coerced !== void 0) entity[key] = coerced;
|
|
15595
|
+
continue;
|
|
15596
|
+
}
|
|
15597
|
+
if (prop.kind !== "relationship" || !(propertyKey in entity)) continue;
|
|
15598
|
+
const nested = entity[propertyKey];
|
|
15599
|
+
if (!nested || typeof nested !== "object") continue;
|
|
15600
|
+
let related = null;
|
|
15601
|
+
try {
|
|
15602
|
+
const candidate = prop.relatedModel();
|
|
15603
|
+
if (isResourcefulModel(candidate)) related = candidate;
|
|
15604
|
+
} catch {
|
|
15605
|
+
}
|
|
15606
|
+
if (!related) continue;
|
|
15607
|
+
if (Array.isArray(nested)) {
|
|
15608
|
+
for (const item of nested)
|
|
15609
|
+
if (item && typeof item === "object")
|
|
15610
|
+
coerceEntityDateRange(item, related, metaCache, visited);
|
|
15611
|
+
} else coerceEntityDateRange(nested, related, metaCache, visited);
|
|
15612
|
+
}
|
|
15613
|
+
};
|
|
15549
15614
|
const modelRelationshipSyncPayloadSchema = validator.object({
|
|
15550
15615
|
ruids: validator.array().items(validator.alternatives().try(validator.string().required(), validator.number().integer().required())).required()
|
|
15551
15616
|
});
|
|
@@ -15839,6 +15904,7 @@ class ResourcefulModelController2 {
|
|
|
15839
15904
|
const applyIeee754Coercion = (jsonEntity) => {
|
|
15840
15905
|
if (!coercionModel) return;
|
|
15841
15906
|
if (!jsonEntity || typeof jsonEntity !== "object" || Array.isArray(jsonEntity)) return;
|
|
15907
|
+
coerceEntityDateRange(jsonEntity, coercionModel, metaCache);
|
|
15842
15908
|
coerceEntityForIeee754(
|
|
15843
15909
|
jsonEntity,
|
|
15844
15910
|
coercionModel,
|
|
@@ -15898,6 +15964,9 @@ class ResourcefulModelController2 {
|
|
|
15898
15964
|
const dNs = "http://docs.oasis-open.org/odata/ns/data";
|
|
15899
15965
|
const buildEntry = (entity, meta) => {
|
|
15900
15966
|
const obj = coercionModel ? serializeResourcefulDates(toJsonEntity(entity), coercionModel) : toJsonEntity(entity);
|
|
15967
|
+
if (coercionModel && isObject$1(obj)) {
|
|
15968
|
+
coerceEntityDateRange(obj, coercionModel, metaCache);
|
|
15969
|
+
}
|
|
15901
15970
|
const entryAttrs = stripUndefinedValuesFromObject$1({
|
|
15902
15971
|
"metadata:context": include("context") ? meta.context : void 0,
|
|
15903
15972
|
"metadata:etag": include("etag") ? meta.etag : void 0
|
|
@@ -16396,7 +16465,14 @@ class ResourcefulModelController2 {
|
|
|
16396
16465
|
if (!(relationship in record)) {
|
|
16397
16466
|
throw new E_RELATIONSHIP_NOT_FOUND_EXCEPTION();
|
|
16398
16467
|
}
|
|
16399
|
-
|
|
16468
|
+
let value = record[relationship];
|
|
16469
|
+
const propertyDefinition = model.$resourcefulColumns.get(relationship) ?? model.$resourcefulComputedAccessors.get(relationship);
|
|
16470
|
+
const columnType = propertyDefinition?.type;
|
|
16471
|
+
const dateKind = isInstanceOf(columnType, "ResourcefulDateType", ResourcefulDateType) ? "date" : isInstanceOf(columnType, "ResourcefulDateTimeType", ResourcefulDateTimeType) ? "dateTime" : void 0;
|
|
16472
|
+
if (dateKind) {
|
|
16473
|
+
const coerced = coerceDateValueToRange(value, dateKind, propertyDefinition.nullable);
|
|
16474
|
+
if (coerced !== void 0) value = coerced;
|
|
16475
|
+
}
|
|
16400
16476
|
ctx.response.header("Content-Type", "text/plain; charset=utf-8");
|
|
16401
16477
|
return ctx.response.status(200).send(value === null ? "" : String(value));
|
|
16402
16478
|
}
|
|
@@ -17496,7 +17572,7 @@ async function configure(command) {
|
|
|
17496
17572
|
}
|
|
17497
17573
|
]);
|
|
17498
17574
|
}
|
|
17499
|
-
const version = "1.
|
|
17575
|
+
const version = "1.20261109.0";
|
|
17500
17576
|
export {
|
|
17501
17577
|
registerRelationCacheTargetsForModel as a,
|
|
17502
17578
|
resourcefulColumn as b,
|
|
@@ -17513,4 +17589,4 @@ export {
|
|
|
17513
17589
|
version as v,
|
|
17514
17590
|
withResourceful as w
|
|
17515
17591
|
};
|
|
17516
|
-
//# sourceMappingURL=index-
|
|
17592
|
+
//# sourceMappingURL=index-BBctNPro.js.map
|