@cms0/cms0 0.0.11 → 0.0.13
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.cjs
CHANGED
|
@@ -5,6 +5,64 @@ exports.cms0 = cms0;
|
|
|
5
5
|
const schema_descriptors_1 = require("@cms0/cms0/schema-descriptors");
|
|
6
6
|
const shared_1 = require("@cms0/shared");
|
|
7
7
|
const COLLECTION_SHAPE_ERROR = "Invalid collection response. Expected array or { items, total }.";
|
|
8
|
+
function normalizeUploadsPath(uploadsPath) {
|
|
9
|
+
const raw = uploadsPath?.trim() || "/uploads";
|
|
10
|
+
const withLeadingSlash = raw.startsWith("/") ? raw : `/${raw}`;
|
|
11
|
+
const normalized = withLeadingSlash.replace(/\/+$/, "");
|
|
12
|
+
return normalized || "/uploads";
|
|
13
|
+
}
|
|
14
|
+
function normalizeAssetBaseUrl(baseUrl) {
|
|
15
|
+
const trimmed = baseUrl?.trim() ?? "";
|
|
16
|
+
return trimmed.replace(/\/+$/, "");
|
|
17
|
+
}
|
|
18
|
+
function encodeFilenameForUrl(filename) {
|
|
19
|
+
const normalized = filename.replace(/\\/g, "/").replace(/^\/+/, "").trim();
|
|
20
|
+
if (!normalized)
|
|
21
|
+
return "";
|
|
22
|
+
return normalized
|
|
23
|
+
.split("/")
|
|
24
|
+
.filter(Boolean)
|
|
25
|
+
.map((segment) => encodeURIComponent(segment))
|
|
26
|
+
.join("/");
|
|
27
|
+
}
|
|
28
|
+
function buildAssetUrlBuilder(apiBaseUrl, assetOptions) {
|
|
29
|
+
const uploadsPath = normalizeUploadsPath(assetOptions?.uploadsPath);
|
|
30
|
+
const explicitBaseUrl = normalizeAssetBaseUrl(assetOptions?.baseUrl);
|
|
31
|
+
if (explicitBaseUrl) {
|
|
32
|
+
return (filename) => `${explicitBaseUrl}${uploadsPath}/${encodeFilenameForUrl(filename)}`;
|
|
33
|
+
}
|
|
34
|
+
let inferredBaseUrl = "";
|
|
35
|
+
try {
|
|
36
|
+
inferredBaseUrl = new URL(apiBaseUrl).origin;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
inferredBaseUrl = "";
|
|
40
|
+
}
|
|
41
|
+
return (filename) => `${inferredBaseUrl}${uploadsPath}/${encodeFilenameForUrl(filename)}`;
|
|
42
|
+
}
|
|
43
|
+
function maybeAttachAssetUrl(value, assetUrlBuilder) {
|
|
44
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
45
|
+
return value;
|
|
46
|
+
const source = value;
|
|
47
|
+
const filename = typeof source.filename === "string" ? source.filename.trim() : "";
|
|
48
|
+
if (!filename)
|
|
49
|
+
return value;
|
|
50
|
+
const isAssetShape = typeof source.mimeType === "string" ||
|
|
51
|
+
typeof source.extension === "string" ||
|
|
52
|
+
typeof source.size === "number" ||
|
|
53
|
+
typeof source.width === "number" ||
|
|
54
|
+
typeof source.height === "number" ||
|
|
55
|
+
typeof source.length === "number";
|
|
56
|
+
if (!isAssetShape)
|
|
57
|
+
return value;
|
|
58
|
+
const existingUrl = typeof source.url === "string" && source.url.trim().length > 0
|
|
59
|
+
? source.url
|
|
60
|
+
: null;
|
|
61
|
+
return {
|
|
62
|
+
...source,
|
|
63
|
+
url: existingUrl ?? assetUrlBuilder(filename),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
8
66
|
function toPlainText(value) {
|
|
9
67
|
if (typeof value === "string")
|
|
10
68
|
return value;
|
|
@@ -99,6 +157,9 @@ function coerceCustomTypeValue(descriptor, value, options) {
|
|
|
99
157
|
return value;
|
|
100
158
|
if (customType === "RichText")
|
|
101
159
|
return coerceRichTextValue(value);
|
|
160
|
+
if (customType === "File" || customType === "Image" || customType === "Video") {
|
|
161
|
+
return maybeAttachAssetUrl(value, options?.assetUrlBuilder ?? ((filename) => filename));
|
|
162
|
+
}
|
|
102
163
|
if (customType === "LocalizedString") {
|
|
103
164
|
return coerceLocalizedStringValue(value, options?.locale, options?.defaultLocale);
|
|
104
165
|
}
|
|
@@ -228,9 +289,16 @@ function extractModelRefId(raw, modelName, options) {
|
|
|
228
289
|
if (found)
|
|
229
290
|
return found;
|
|
230
291
|
}
|
|
231
|
-
const
|
|
232
|
-
if (
|
|
233
|
-
|
|
292
|
+
const allowObjectIdFallback = options?.allowObjectIdFallback ?? true;
|
|
293
|
+
if (allowObjectIdFallback) {
|
|
294
|
+
const keys = Object.keys(object);
|
|
295
|
+
const hasOnlyId = keys.length === 1 && keys[0] === "id";
|
|
296
|
+
if (hasOnlyId) {
|
|
297
|
+
const byId = extractId(object);
|
|
298
|
+
if (byId)
|
|
299
|
+
return byId;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
234
302
|
return null;
|
|
235
303
|
}
|
|
236
304
|
function formatValidationError(name, error) {
|
|
@@ -325,12 +393,14 @@ async function normalizeObjectField(descriptor, path, raw, context, trail, isCol
|
|
|
325
393
|
output[propertyName] = coerceCustomTypeValue(propertyDescriptor, source[propertyName], {
|
|
326
394
|
locale: context.options.locale,
|
|
327
395
|
defaultLocale: context.options.defaultLocale,
|
|
396
|
+
assetUrlBuilder: context.options.assetUrlBuilder,
|
|
328
397
|
});
|
|
329
398
|
continue;
|
|
330
399
|
}
|
|
331
400
|
if (isModelRefDescriptor(propertyDescriptor)) {
|
|
332
401
|
const refId = extractModelRefId(source, propertyDescriptor.model, {
|
|
333
402
|
propertyName,
|
|
403
|
+
allowObjectIdFallback: false,
|
|
334
404
|
});
|
|
335
405
|
output[propertyName] = await normalizeModelRef(propertyDescriptor.model, refId, context, trail, false);
|
|
336
406
|
continue;
|
|
@@ -347,6 +417,7 @@ async function normalizeObjectField(descriptor, path, raw, context, trail, isCol
|
|
|
347
417
|
output[propertyName] = coerceCustomTypeValue(propertyDescriptor, normalizedChild, {
|
|
348
418
|
locale: context.options.locale,
|
|
349
419
|
defaultLocale: context.options.defaultLocale,
|
|
420
|
+
assetUrlBuilder: context.options.assetUrlBuilder,
|
|
350
421
|
});
|
|
351
422
|
continue;
|
|
352
423
|
}
|
|
@@ -362,6 +433,7 @@ async function normalizeObjectField(descriptor, path, raw, context, trail, isCol
|
|
|
362
433
|
output[propertyName] = coerceCustomTypeValue(propertyDescriptor, normalizedChild, {
|
|
363
434
|
locale: context.options.locale,
|
|
364
435
|
defaultLocale: context.options.defaultLocale,
|
|
436
|
+
assetUrlBuilder: context.options.assetUrlBuilder,
|
|
365
437
|
});
|
|
366
438
|
}
|
|
367
439
|
}
|
|
@@ -370,7 +442,12 @@ async function normalizeObjectField(descriptor, path, raw, context, trail, isCol
|
|
|
370
442
|
if (rowId)
|
|
371
443
|
output.id = rowId;
|
|
372
444
|
}
|
|
373
|
-
|
|
445
|
+
if (typeof source.url === "string" &&
|
|
446
|
+
source.url.trim().length > 0 &&
|
|
447
|
+
typeof output.filename === "string") {
|
|
448
|
+
output.url = source.url;
|
|
449
|
+
}
|
|
450
|
+
return maybeAttachAssetUrl(output, context.options.assetUrlBuilder);
|
|
374
451
|
}
|
|
375
452
|
async function normalizeArrayField(descriptor, path, raw, context, trail) {
|
|
376
453
|
const envelope = ensureCollectionEnvelope(raw, path);
|
|
@@ -389,7 +466,9 @@ async function normalizeArrayField(descriptor, path, raw, context, trail) {
|
|
|
389
466
|
}
|
|
390
467
|
if (isModelRefDescriptor(itemDescriptor)) {
|
|
391
468
|
const resolved = await Promise.all(envelope.items.map(async (row) => {
|
|
392
|
-
const refId = extractModelRefId(row, itemDescriptor.model
|
|
469
|
+
const refId = extractModelRefId(row, itemDescriptor.model, {
|
|
470
|
+
allowObjectIdFallback: false,
|
|
471
|
+
});
|
|
393
472
|
return normalizeModelRef(itemDescriptor.model, refId, context, trail, true);
|
|
394
473
|
}));
|
|
395
474
|
return resolved;
|
|
@@ -413,6 +492,7 @@ async function normalizeField(descriptor, path, raw, context, trail, isCollectio
|
|
|
413
492
|
return coerceCustomTypeValue(descriptor, value, {
|
|
414
493
|
locale: context.options.locale,
|
|
415
494
|
defaultLocale: context.options.defaultLocale,
|
|
495
|
+
assetUrlBuilder: context.options.assetUrlBuilder,
|
|
416
496
|
});
|
|
417
497
|
}
|
|
418
498
|
if (isModelRefDescriptor(descriptor)) {
|
|
@@ -424,6 +504,7 @@ async function normalizeField(descriptor, path, raw, context, trail, isCollectio
|
|
|
424
504
|
return coerceCustomTypeValue(descriptor, normalized, {
|
|
425
505
|
locale: context.options.locale,
|
|
426
506
|
defaultLocale: context.options.defaultLocale,
|
|
507
|
+
assetUrlBuilder: context.options.assetUrlBuilder,
|
|
427
508
|
});
|
|
428
509
|
}
|
|
429
510
|
if (isObjectDescriptor(descriptor)) {
|
|
@@ -431,6 +512,7 @@ async function normalizeField(descriptor, path, raw, context, trail, isCollectio
|
|
|
431
512
|
return coerceCustomTypeValue(descriptor, normalized, {
|
|
432
513
|
locale: context.options.locale,
|
|
433
514
|
defaultLocale: context.options.defaultLocale,
|
|
515
|
+
assetUrlBuilder: context.options.assetUrlBuilder,
|
|
434
516
|
});
|
|
435
517
|
}
|
|
436
518
|
return raw;
|
|
@@ -518,7 +600,7 @@ function validateResult(resource, result, descriptor, includeIdMode, zodSchemas,
|
|
|
518
600
|
throw new Error(formatValidationError(modelName, parsed.error));
|
|
519
601
|
}
|
|
520
602
|
}
|
|
521
|
-
async function runResource(resource, descriptor, baseUrl, apiKey, defaultLocale, zodSchemas, modelZodSchemas, options, byId) {
|
|
603
|
+
async function runResource(resource, descriptor, baseUrl, apiKey, defaultLocale, assetUrlBuilder, zodSchemas, modelZodSchemas, options, byId) {
|
|
522
604
|
const responseMode = options?.response ?? "normalized";
|
|
523
605
|
const includeIdMode = resolveIncludeIdMode(options?.includeId);
|
|
524
606
|
const resolveModelRefs = options?.resolveModelRefs !== false;
|
|
@@ -562,6 +644,7 @@ async function runResource(resource, descriptor, baseUrl, apiKey, defaultLocale,
|
|
|
562
644
|
resolveModelRefs,
|
|
563
645
|
locale,
|
|
564
646
|
defaultLocale,
|
|
647
|
+
assetUrlBuilder,
|
|
565
648
|
},
|
|
566
649
|
};
|
|
567
650
|
if (resource.isCollection && !byId) {
|
|
@@ -592,13 +675,14 @@ async function runResource(resource, descriptor, baseUrl, apiKey, defaultLocale,
|
|
|
592
675
|
function createCmsClient(descriptor, config) {
|
|
593
676
|
const baseUrl = normalizeBaseUrl(config.apiConfig?.baseUrl);
|
|
594
677
|
const apiKey = config.apiConfig?.key;
|
|
678
|
+
const assetUrlBuilder = buildAssetUrlBuilder(baseUrl, config.assets);
|
|
595
679
|
const registry = createResourceRegistry(descriptor);
|
|
596
680
|
const rootKeys = Array.from(registry.roots.keys());
|
|
597
681
|
const modelKeys = Array.from(registry.models.keys());
|
|
598
682
|
const { zodSchemas, modelZodSchemas } = (0, shared_1.buildZodSchemasFromDescriptor)(descriptor);
|
|
599
683
|
const buildModelAccessor = (entry) => {
|
|
600
|
-
const accessor = (async (options) => runResource(entry, descriptor, baseUrl, apiKey, config.defaultLocale, zodSchemas, modelZodSchemas, options));
|
|
601
|
-
accessor.byId = async (id, options) => runResource(entry, descriptor, baseUrl, apiKey, config.defaultLocale, zodSchemas, modelZodSchemas, options, id);
|
|
684
|
+
const accessor = (async (options) => runResource(entry, descriptor, baseUrl, apiKey, config.defaultLocale, assetUrlBuilder, zodSchemas, modelZodSchemas, options));
|
|
685
|
+
accessor.byId = async (id, options) => runResource(entry, descriptor, baseUrl, apiKey, config.defaultLocale, assetUrlBuilder, zodSchemas, modelZodSchemas, options, id);
|
|
602
686
|
return accessor;
|
|
603
687
|
};
|
|
604
688
|
const modelsProxy = new Proxy({}, {
|
|
@@ -628,7 +712,7 @@ function createCmsClient(descriptor, config) {
|
|
|
628
712
|
if (!entry) {
|
|
629
713
|
unknownKeyError(property, rootKeys, []);
|
|
630
714
|
}
|
|
631
|
-
return async (options) => runResource(entry, descriptor, baseUrl, apiKey, config.defaultLocale, zodSchemas, modelZodSchemas, options);
|
|
715
|
+
return async (options) => runResource(entry, descriptor, baseUrl, apiKey, config.defaultLocale, assetUrlBuilder, zodSchemas, modelZodSchemas, options);
|
|
632
716
|
},
|
|
633
717
|
});
|
|
634
718
|
return rootProxy;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
import { schemaDescriptor } from "@cms0/cms0/schema-descriptors";
|
|
2
2
|
import { buildZodSchemasFromDescriptor, } from "@cms0/shared";
|
|
3
3
|
const COLLECTION_SHAPE_ERROR = "Invalid collection response. Expected array or { items, total }.";
|
|
4
|
+
function normalizeUploadsPath(uploadsPath) {
|
|
5
|
+
const raw = uploadsPath?.trim() || "/uploads";
|
|
6
|
+
const withLeadingSlash = raw.startsWith("/") ? raw : `/${raw}`;
|
|
7
|
+
const normalized = withLeadingSlash.replace(/\/+$/, "");
|
|
8
|
+
return normalized || "/uploads";
|
|
9
|
+
}
|
|
10
|
+
function normalizeAssetBaseUrl(baseUrl) {
|
|
11
|
+
const trimmed = baseUrl?.trim() ?? "";
|
|
12
|
+
return trimmed.replace(/\/+$/, "");
|
|
13
|
+
}
|
|
14
|
+
function encodeFilenameForUrl(filename) {
|
|
15
|
+
const normalized = filename.replace(/\\/g, "/").replace(/^\/+/, "").trim();
|
|
16
|
+
if (!normalized)
|
|
17
|
+
return "";
|
|
18
|
+
return normalized
|
|
19
|
+
.split("/")
|
|
20
|
+
.filter(Boolean)
|
|
21
|
+
.map((segment) => encodeURIComponent(segment))
|
|
22
|
+
.join("/");
|
|
23
|
+
}
|
|
24
|
+
function buildAssetUrlBuilder(apiBaseUrl, assetOptions) {
|
|
25
|
+
const uploadsPath = normalizeUploadsPath(assetOptions?.uploadsPath);
|
|
26
|
+
const explicitBaseUrl = normalizeAssetBaseUrl(assetOptions?.baseUrl);
|
|
27
|
+
if (explicitBaseUrl) {
|
|
28
|
+
return (filename) => `${explicitBaseUrl}${uploadsPath}/${encodeFilenameForUrl(filename)}`;
|
|
29
|
+
}
|
|
30
|
+
let inferredBaseUrl = "";
|
|
31
|
+
try {
|
|
32
|
+
inferredBaseUrl = new URL(apiBaseUrl).origin;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
inferredBaseUrl = "";
|
|
36
|
+
}
|
|
37
|
+
return (filename) => `${inferredBaseUrl}${uploadsPath}/${encodeFilenameForUrl(filename)}`;
|
|
38
|
+
}
|
|
39
|
+
function maybeAttachAssetUrl(value, assetUrlBuilder) {
|
|
40
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
41
|
+
return value;
|
|
42
|
+
const source = value;
|
|
43
|
+
const filename = typeof source.filename === "string" ? source.filename.trim() : "";
|
|
44
|
+
if (!filename)
|
|
45
|
+
return value;
|
|
46
|
+
const isAssetShape = typeof source.mimeType === "string" ||
|
|
47
|
+
typeof source.extension === "string" ||
|
|
48
|
+
typeof source.size === "number" ||
|
|
49
|
+
typeof source.width === "number" ||
|
|
50
|
+
typeof source.height === "number" ||
|
|
51
|
+
typeof source.length === "number";
|
|
52
|
+
if (!isAssetShape)
|
|
53
|
+
return value;
|
|
54
|
+
const existingUrl = typeof source.url === "string" && source.url.trim().length > 0
|
|
55
|
+
? source.url
|
|
56
|
+
: null;
|
|
57
|
+
return {
|
|
58
|
+
...source,
|
|
59
|
+
url: existingUrl ?? assetUrlBuilder(filename),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
4
62
|
function toPlainText(value) {
|
|
5
63
|
if (typeof value === "string")
|
|
6
64
|
return value;
|
|
@@ -95,6 +153,9 @@ function coerceCustomTypeValue(descriptor, value, options) {
|
|
|
95
153
|
return value;
|
|
96
154
|
if (customType === "RichText")
|
|
97
155
|
return coerceRichTextValue(value);
|
|
156
|
+
if (customType === "File" || customType === "Image" || customType === "Video") {
|
|
157
|
+
return maybeAttachAssetUrl(value, options?.assetUrlBuilder ?? ((filename) => filename));
|
|
158
|
+
}
|
|
98
159
|
if (customType === "LocalizedString") {
|
|
99
160
|
return coerceLocalizedStringValue(value, options?.locale, options?.defaultLocale);
|
|
100
161
|
}
|
|
@@ -224,9 +285,16 @@ function extractModelRefId(raw, modelName, options) {
|
|
|
224
285
|
if (found)
|
|
225
286
|
return found;
|
|
226
287
|
}
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
229
|
-
|
|
288
|
+
const allowObjectIdFallback = options?.allowObjectIdFallback ?? true;
|
|
289
|
+
if (allowObjectIdFallback) {
|
|
290
|
+
const keys = Object.keys(object);
|
|
291
|
+
const hasOnlyId = keys.length === 1 && keys[0] === "id";
|
|
292
|
+
if (hasOnlyId) {
|
|
293
|
+
const byId = extractId(object);
|
|
294
|
+
if (byId)
|
|
295
|
+
return byId;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
230
298
|
return null;
|
|
231
299
|
}
|
|
232
300
|
function formatValidationError(name, error) {
|
|
@@ -321,12 +389,14 @@ async function normalizeObjectField(descriptor, path, raw, context, trail, isCol
|
|
|
321
389
|
output[propertyName] = coerceCustomTypeValue(propertyDescriptor, source[propertyName], {
|
|
322
390
|
locale: context.options.locale,
|
|
323
391
|
defaultLocale: context.options.defaultLocale,
|
|
392
|
+
assetUrlBuilder: context.options.assetUrlBuilder,
|
|
324
393
|
});
|
|
325
394
|
continue;
|
|
326
395
|
}
|
|
327
396
|
if (isModelRefDescriptor(propertyDescriptor)) {
|
|
328
397
|
const refId = extractModelRefId(source, propertyDescriptor.model, {
|
|
329
398
|
propertyName,
|
|
399
|
+
allowObjectIdFallback: false,
|
|
330
400
|
});
|
|
331
401
|
output[propertyName] = await normalizeModelRef(propertyDescriptor.model, refId, context, trail, false);
|
|
332
402
|
continue;
|
|
@@ -343,6 +413,7 @@ async function normalizeObjectField(descriptor, path, raw, context, trail, isCol
|
|
|
343
413
|
output[propertyName] = coerceCustomTypeValue(propertyDescriptor, normalizedChild, {
|
|
344
414
|
locale: context.options.locale,
|
|
345
415
|
defaultLocale: context.options.defaultLocale,
|
|
416
|
+
assetUrlBuilder: context.options.assetUrlBuilder,
|
|
346
417
|
});
|
|
347
418
|
continue;
|
|
348
419
|
}
|
|
@@ -358,6 +429,7 @@ async function normalizeObjectField(descriptor, path, raw, context, trail, isCol
|
|
|
358
429
|
output[propertyName] = coerceCustomTypeValue(propertyDescriptor, normalizedChild, {
|
|
359
430
|
locale: context.options.locale,
|
|
360
431
|
defaultLocale: context.options.defaultLocale,
|
|
432
|
+
assetUrlBuilder: context.options.assetUrlBuilder,
|
|
361
433
|
});
|
|
362
434
|
}
|
|
363
435
|
}
|
|
@@ -366,7 +438,12 @@ async function normalizeObjectField(descriptor, path, raw, context, trail, isCol
|
|
|
366
438
|
if (rowId)
|
|
367
439
|
output.id = rowId;
|
|
368
440
|
}
|
|
369
|
-
|
|
441
|
+
if (typeof source.url === "string" &&
|
|
442
|
+
source.url.trim().length > 0 &&
|
|
443
|
+
typeof output.filename === "string") {
|
|
444
|
+
output.url = source.url;
|
|
445
|
+
}
|
|
446
|
+
return maybeAttachAssetUrl(output, context.options.assetUrlBuilder);
|
|
370
447
|
}
|
|
371
448
|
async function normalizeArrayField(descriptor, path, raw, context, trail) {
|
|
372
449
|
const envelope = ensureCollectionEnvelope(raw, path);
|
|
@@ -385,7 +462,9 @@ async function normalizeArrayField(descriptor, path, raw, context, trail) {
|
|
|
385
462
|
}
|
|
386
463
|
if (isModelRefDescriptor(itemDescriptor)) {
|
|
387
464
|
const resolved = await Promise.all(envelope.items.map(async (row) => {
|
|
388
|
-
const refId = extractModelRefId(row, itemDescriptor.model
|
|
465
|
+
const refId = extractModelRefId(row, itemDescriptor.model, {
|
|
466
|
+
allowObjectIdFallback: false,
|
|
467
|
+
});
|
|
389
468
|
return normalizeModelRef(itemDescriptor.model, refId, context, trail, true);
|
|
390
469
|
}));
|
|
391
470
|
return resolved;
|
|
@@ -409,6 +488,7 @@ async function normalizeField(descriptor, path, raw, context, trail, isCollectio
|
|
|
409
488
|
return coerceCustomTypeValue(descriptor, value, {
|
|
410
489
|
locale: context.options.locale,
|
|
411
490
|
defaultLocale: context.options.defaultLocale,
|
|
491
|
+
assetUrlBuilder: context.options.assetUrlBuilder,
|
|
412
492
|
});
|
|
413
493
|
}
|
|
414
494
|
if (isModelRefDescriptor(descriptor)) {
|
|
@@ -420,6 +500,7 @@ async function normalizeField(descriptor, path, raw, context, trail, isCollectio
|
|
|
420
500
|
return coerceCustomTypeValue(descriptor, normalized, {
|
|
421
501
|
locale: context.options.locale,
|
|
422
502
|
defaultLocale: context.options.defaultLocale,
|
|
503
|
+
assetUrlBuilder: context.options.assetUrlBuilder,
|
|
423
504
|
});
|
|
424
505
|
}
|
|
425
506
|
if (isObjectDescriptor(descriptor)) {
|
|
@@ -427,6 +508,7 @@ async function normalizeField(descriptor, path, raw, context, trail, isCollectio
|
|
|
427
508
|
return coerceCustomTypeValue(descriptor, normalized, {
|
|
428
509
|
locale: context.options.locale,
|
|
429
510
|
defaultLocale: context.options.defaultLocale,
|
|
511
|
+
assetUrlBuilder: context.options.assetUrlBuilder,
|
|
430
512
|
});
|
|
431
513
|
}
|
|
432
514
|
return raw;
|
|
@@ -514,7 +596,7 @@ function validateResult(resource, result, descriptor, includeIdMode, zodSchemas,
|
|
|
514
596
|
throw new Error(formatValidationError(modelName, parsed.error));
|
|
515
597
|
}
|
|
516
598
|
}
|
|
517
|
-
async function runResource(resource, descriptor, baseUrl, apiKey, defaultLocale, zodSchemas, modelZodSchemas, options, byId) {
|
|
599
|
+
async function runResource(resource, descriptor, baseUrl, apiKey, defaultLocale, assetUrlBuilder, zodSchemas, modelZodSchemas, options, byId) {
|
|
518
600
|
const responseMode = options?.response ?? "normalized";
|
|
519
601
|
const includeIdMode = resolveIncludeIdMode(options?.includeId);
|
|
520
602
|
const resolveModelRefs = options?.resolveModelRefs !== false;
|
|
@@ -558,6 +640,7 @@ async function runResource(resource, descriptor, baseUrl, apiKey, defaultLocale,
|
|
|
558
640
|
resolveModelRefs,
|
|
559
641
|
locale,
|
|
560
642
|
defaultLocale,
|
|
643
|
+
assetUrlBuilder,
|
|
561
644
|
},
|
|
562
645
|
};
|
|
563
646
|
if (resource.isCollection && !byId) {
|
|
@@ -588,13 +671,14 @@ async function runResource(resource, descriptor, baseUrl, apiKey, defaultLocale,
|
|
|
588
671
|
export function createCmsClient(descriptor, config) {
|
|
589
672
|
const baseUrl = normalizeBaseUrl(config.apiConfig?.baseUrl);
|
|
590
673
|
const apiKey = config.apiConfig?.key;
|
|
674
|
+
const assetUrlBuilder = buildAssetUrlBuilder(baseUrl, config.assets);
|
|
591
675
|
const registry = createResourceRegistry(descriptor);
|
|
592
676
|
const rootKeys = Array.from(registry.roots.keys());
|
|
593
677
|
const modelKeys = Array.from(registry.models.keys());
|
|
594
678
|
const { zodSchemas, modelZodSchemas } = buildZodSchemasFromDescriptor(descriptor);
|
|
595
679
|
const buildModelAccessor = (entry) => {
|
|
596
|
-
const accessor = (async (options) => runResource(entry, descriptor, baseUrl, apiKey, config.defaultLocale, zodSchemas, modelZodSchemas, options));
|
|
597
|
-
accessor.byId = async (id, options) => runResource(entry, descriptor, baseUrl, apiKey, config.defaultLocale, zodSchemas, modelZodSchemas, options, id);
|
|
680
|
+
const accessor = (async (options) => runResource(entry, descriptor, baseUrl, apiKey, config.defaultLocale, assetUrlBuilder, zodSchemas, modelZodSchemas, options));
|
|
681
|
+
accessor.byId = async (id, options) => runResource(entry, descriptor, baseUrl, apiKey, config.defaultLocale, assetUrlBuilder, zodSchemas, modelZodSchemas, options, id);
|
|
598
682
|
return accessor;
|
|
599
683
|
};
|
|
600
684
|
const modelsProxy = new Proxy({}, {
|
|
@@ -624,7 +708,7 @@ export function createCmsClient(descriptor, config) {
|
|
|
624
708
|
if (!entry) {
|
|
625
709
|
unknownKeyError(property, rootKeys, []);
|
|
626
710
|
}
|
|
627
|
-
return async (options) => runResource(entry, descriptor, baseUrl, apiKey, config.defaultLocale, zodSchemas, modelZodSchemas, options);
|
|
711
|
+
return async (options) => runResource(entry, descriptor, baseUrl, apiKey, config.defaultLocale, assetUrlBuilder, zodSchemas, modelZodSchemas, options);
|
|
628
712
|
},
|
|
629
713
|
});
|
|
630
714
|
return rootProxy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/custom-types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG,QAAQ,CAAC;AAE5B,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/custom-types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG,QAAQ,CAAC;AAE5B,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ type QueryValue = string | number | boolean | null | undefined;
|
|
|
5
5
|
type QueryParam = QueryValue | QueryValue[];
|
|
6
6
|
export type CmsQuery = Record<string, QueryParam>;
|
|
7
7
|
export type CmsResponseMode = "normalized" | "envelope" | "raw";
|
|
8
|
+
export interface CmsAssetOptions {
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
uploadsPath?: string;
|
|
11
|
+
}
|
|
8
12
|
export interface CmsAccessorOptions {
|
|
9
13
|
query?: CmsQuery;
|
|
10
14
|
response?: CmsResponseMode;
|
|
@@ -64,6 +68,7 @@ export interface Cms0Options {
|
|
|
64
68
|
apiConfig: Cms0APIConfig;
|
|
65
69
|
locales?: string[];
|
|
66
70
|
defaultLocale?: string;
|
|
71
|
+
assets?: CmsAssetOptions;
|
|
67
72
|
}
|
|
68
73
|
type PrimitiveValueFromDescriptor<TypeName extends string> = TypeName extends "string" ? string : TypeName extends "number" ? number : TypeName extends "boolean" ? boolean : any;
|
|
69
74
|
type ApplyDescriptorFlags<Descriptor, Value> = Descriptor extends {
|
|
@@ -95,8 +100,16 @@ type InferDescriptorField<Descriptor, ModelMap extends Record<string, any>> = Ap
|
|
|
95
100
|
type InferDescriptorModels<Models extends Record<string, any>> = {
|
|
96
101
|
[ModelName in keyof Models]: Models[ModelName] extends {
|
|
97
102
|
properties: infer Properties extends Record<string, any>;
|
|
98
|
-
} ? InferDescriptorObject<Properties, InferDescriptorModels<Models
|
|
103
|
+
} ? WithInferredAssetUrl<InferDescriptorObject<Properties, InferDescriptorModels<Models>>, Properties> : any;
|
|
99
104
|
};
|
|
105
|
+
type WithInferredAssetUrl<Shape, Properties extends Record<string, any>> = Properties extends {
|
|
106
|
+
filename: any;
|
|
107
|
+
extension: any;
|
|
108
|
+
mimeType: any;
|
|
109
|
+
size: any;
|
|
110
|
+
} ? Shape & {
|
|
111
|
+
url: string;
|
|
112
|
+
} : Shape;
|
|
100
113
|
type InferDescriptorRoots<Roots extends Record<string, any>, Models extends Record<string, any>> = {
|
|
101
114
|
[RootKey in keyof Roots]: InferDescriptorField<Roots[RootKey], Models>;
|
|
102
115
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts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