@cms0/cms0 0.2.5 → 0.2.6
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/cjs/index-old-1.cjs +866 -0
- package/dist/cjs/index.cjs +66 -18
- package/dist/esm/index-old-1.js +862 -0
- package/dist/esm/index.js +66 -18
- package/dist/types/index-old-1.d.ts +175 -0
- package/dist/types/index-old-1.d.ts.map +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -484,12 +484,19 @@ async function normalizeObjectField(descriptor, path, raw, context, trail, isCol
|
|
|
484
484
|
}
|
|
485
485
|
if (isArrayDescriptor(propertyDescriptor)) {
|
|
486
486
|
const childPath = `${path}/${propertyName}`;
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
487
|
+
const inlineChildRaw = source[propertyName];
|
|
488
|
+
if (inlineChildRaw === null) {
|
|
489
|
+
output[propertyName] = null;
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
const childRaw = inlineChildRaw !== undefined
|
|
493
|
+
? inlineChildRaw
|
|
494
|
+
: await context.requestJson(childPath, {
|
|
495
|
+
query: {
|
|
496
|
+
raw: 1,
|
|
497
|
+
...(context.options.locale ? { locale: context.options.locale } : {}),
|
|
498
|
+
},
|
|
499
|
+
});
|
|
493
500
|
const normalizedChild = await normalizeArrayField(propertyDescriptor, childPath, childRaw, context, trail);
|
|
494
501
|
output[propertyName] = coerceCustomTypeValue(propertyDescriptor, normalizedChild, {
|
|
495
502
|
locale: context.options.locale,
|
|
@@ -500,12 +507,19 @@ async function normalizeObjectField(descriptor, path, raw, context, trail, isCol
|
|
|
500
507
|
}
|
|
501
508
|
if (isObjectDescriptor(propertyDescriptor)) {
|
|
502
509
|
const childPath = `${path}/${propertyName}`;
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
510
|
+
const inlineChildRaw = source[propertyName];
|
|
511
|
+
if (inlineChildRaw === null) {
|
|
512
|
+
output[propertyName] = null;
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
const childRaw = inlineChildRaw !== undefined
|
|
516
|
+
? inlineChildRaw
|
|
517
|
+
: await context.requestJson(childPath, {
|
|
518
|
+
query: {
|
|
519
|
+
raw: 1,
|
|
520
|
+
...(context.options.locale ? { locale: context.options.locale } : {}),
|
|
521
|
+
},
|
|
522
|
+
});
|
|
509
523
|
const normalizedChild = await normalizeObjectField(propertyDescriptor, childPath, childRaw, context, trail, false);
|
|
510
524
|
output[propertyName] = coerceCustomTypeValue(propertyDescriptor, normalizedChild, {
|
|
511
525
|
locale: context.options.locale,
|
|
@@ -752,13 +766,47 @@ async function runResource(resource, descriptor, baseUrl, apiKey, defaultLocale,
|
|
|
752
766
|
if (locale && query.locale === undefined) {
|
|
753
767
|
query.locale = locale;
|
|
754
768
|
}
|
|
755
|
-
const
|
|
769
|
+
const useResolvedEndpoint = shouldNormalize &&
|
|
770
|
+
!byId &&
|
|
771
|
+
resource.kind === "root" &&
|
|
772
|
+
!resource.isCollection &&
|
|
773
|
+
isObjectDescriptor(resource.descriptor) &&
|
|
774
|
+
resolveModelRefs;
|
|
775
|
+
if (useResolvedEndpoint && query.resolveModelRefs === undefined) {
|
|
776
|
+
query.resolveModelRefs = 1;
|
|
777
|
+
}
|
|
778
|
+
const normalizePath = byId
|
|
756
779
|
? `${resource.path}/${encodeURIComponent(byId)}`
|
|
757
780
|
: resource.path;
|
|
758
|
-
const
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
781
|
+
const requestPath = useResolvedEndpoint
|
|
782
|
+
? `_resolved/${encodeURIComponent(resource.key)}`
|
|
783
|
+
: normalizePath;
|
|
784
|
+
let rawData;
|
|
785
|
+
if (useResolvedEndpoint) {
|
|
786
|
+
try {
|
|
787
|
+
rawData = await requestJson(baseUrl, apiKey, requestPath, {
|
|
788
|
+
query,
|
|
789
|
+
signal: options?.signal,
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
catch (resolvedError) {
|
|
793
|
+
try {
|
|
794
|
+
rawData = await requestJson(baseUrl, apiKey, normalizePath, {
|
|
795
|
+
query,
|
|
796
|
+
signal: options?.signal,
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
catch {
|
|
800
|
+
throw resolvedError;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
rawData = await requestJson(baseUrl, apiKey, requestPath, {
|
|
806
|
+
query,
|
|
807
|
+
signal: options?.signal,
|
|
808
|
+
});
|
|
809
|
+
}
|
|
762
810
|
if (!shouldNormalize) {
|
|
763
811
|
return rawData;
|
|
764
812
|
}
|
|
@@ -804,7 +852,7 @@ async function runResource(resource, descriptor, baseUrl, apiKey, defaultLocale,
|
|
|
804
852
|
validateResult(resource, normalizedItems, descriptor, includeIdMode, zodSchemas, modelZodSchemas);
|
|
805
853
|
return normalizedItems;
|
|
806
854
|
}
|
|
807
|
-
const normalized = await normalizeField(resource.descriptor,
|
|
855
|
+
const normalized = await normalizeField(resource.descriptor, normalizePath, rawData, context, new Set(), false);
|
|
808
856
|
validateResult(resource, normalized, descriptor, includeIdMode, zodSchemas, modelZodSchemas);
|
|
809
857
|
return normalized;
|
|
810
858
|
}
|