@crombolo/schema 0.34.0 → 0.35.2

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/generate.ts +11 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/schema",
3
- "version": "0.34.0",
3
+ "version": "0.35.2",
4
4
  "description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Schema-as-code for crombolo: TOML document, media and member type definitions.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",
@@ -28,7 +28,7 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@crombolo/core": "0.34.0",
32
- "@crombolo/data": "0.34.0"
31
+ "@crombolo/core": "0.35.2",
32
+ "@crombolo/data": "0.35.2"
33
33
  }
34
34
  }
package/src/generate.ts CHANGED
@@ -85,10 +85,17 @@ function tsTypeFor(set: SchemaSet, dataTypeAlias: string): string {
85
85
  return 'boolean'
86
86
  case 'Umbraco.ContentPicker':
87
87
  return 'PublishedContent | null'
88
+ // These can name media, which is looked up as it is read (story 197): awaited.
88
89
  case 'Umbraco.MultiNodeTreePicker':
89
- return 'PublishedContent[]'
90
+ return 'Promise<PublishedContent[]>'
90
91
  case 'Umbraco.MultiUrlPicker':
91
- return 'Link[]'
92
+ return 'Promise<Link[]>'
93
+ case 'Umbraco.MediaPicker3':
94
+ return config.multiple === false
95
+ ? 'Promise<MediaWithCrops | null>'
96
+ : 'Promise<MediaWithCrops[]>'
97
+ case 'Umbraco.RichText':
98
+ return 'string | Promise<string>'
92
99
  case 'Umbraco.ElementPicker': {
93
100
  // `allowedContentTypes` is a comma-separated list of element type keys, as
94
101
  // Umbraco's AllowedContentTypeKeysParser reads it. Narrowing to those types
@@ -186,8 +193,10 @@ export function generateTypes(set: SchemaSet): string {
186
193
  'BlockGridItem',
187
194
  'BlockItem',
188
195
  'Link',
196
+ 'MediaWithCrops',
189
197
  'PublishedContent',
190
198
  'PublishedElement',
199
+ 'PublishedMedia',
191
200
  'TypedElement',
192
201
  ].filter((name) => new RegExp(`\\b${name}\\b`).test(body.split('\n').slice(2).join('\n')))
193
202
  if (used.length > 0)