@crombolo/api-delivery 0.63.0 → 0.65.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/package.json +4 -4
- package/src/output.ts +5 -0
- package/src/settings.ts +7 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/api-delivery",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.1",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Umbraco's Content Delivery API for crombolo: published content and media as JSON, served from the published cache.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@crombolo/core": "0.
|
|
32
|
-
"@crombolo/contracts": "0.
|
|
33
|
-
"@crombolo/render": "0.
|
|
31
|
+
"@crombolo/core": "0.65.1",
|
|
32
|
+
"@crombolo/contracts": "0.65.1",
|
|
33
|
+
"@crombolo/render": "0.65.1"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/output.ts
CHANGED
|
@@ -368,6 +368,11 @@ export async function deliveryValue(
|
|
|
368
368
|
return {
|
|
369
369
|
items: await inOrder(list<BlockItem>(converted), (i) => blockItem(i, ctx, expand, include)),
|
|
370
370
|
}
|
|
371
|
+
// One item, as a list's are, or null (story 345).
|
|
372
|
+
case 'Umbraco.SingleBlock':
|
|
373
|
+
return converted && typeof converted === 'object' && 'content' in converted
|
|
374
|
+
? await blockItem(converted as BlockItem, ctx, expand, include)
|
|
375
|
+
: null
|
|
371
376
|
case 'Umbraco.BlockGrid': {
|
|
372
377
|
const columns = Number(config.gridColumns) || 12
|
|
373
378
|
return {
|
package/src/settings.ts
CHANGED
|
@@ -67,7 +67,8 @@ export function resolveDeliveryApiSettings(options: DeliveryApiOptions = {}): De
|
|
|
67
67
|
const code = options.memberAuthorization?.authorizationCodeFlow ?? {}
|
|
68
68
|
const credentials = options.memberAuthorization?.clientCredentialsFlow ?? {}
|
|
69
69
|
return {
|
|
70
|
-
|
|
70
|
+
// Story 348: on, serving what the site publishes to anyone, unless a site says otherwise.
|
|
71
|
+
enabled: options.enabled ?? true,
|
|
71
72
|
publicAccess: options.publicAccess ?? true,
|
|
72
73
|
apiKey: options.apiKey?.trim() ? options.apiKey : undefined,
|
|
73
74
|
allowedContentTypeAliases: [...(options.allowedContentTypeAliases ?? [])].filter(
|
|
@@ -81,9 +82,11 @@ export function resolveDeliveryApiSettings(options: DeliveryApiOptions = {}): De
|
|
|
81
82
|
publicAccess: options.media?.publicAccess ?? true,
|
|
82
83
|
},
|
|
83
84
|
cors: {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
// Any origin for public reads unless a list is given, an empty one included;
|
|
86
|
+
// none for a private API, whose key must not be usable from any page.
|
|
87
|
+
allowedOrigins: [
|
|
88
|
+
...(options.cors?.allowedOrigins ?? ((options.publicAccess ?? true) ? ['*'] : [])),
|
|
89
|
+
].filter((origin): origin is string => typeof origin === 'string' && origin.trim() !== ''),
|
|
87
90
|
},
|
|
88
91
|
preview: {
|
|
89
92
|
url: options.preview?.url?.trim() || undefined,
|