@crombolo/core 0.65.1 → 0.67.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/package.json +3 -2
- package/src/permission-names.ts +4 -0
- package/src/permissions.ts +14 -1
- package/src/property-values.ts +19 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.67.0",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Domain model, entity keys and shared contracts for crombolo. No I/O.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@crombolo/common": "0.
|
|
32
|
+
"@crombolo/common": "0.67.0",
|
|
33
|
+
"marked": "^18.0.14"
|
|
33
34
|
}
|
|
34
35
|
}
|
package/src/permission-names.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* publish and the rest exist for pages, Library items, media and forms alike.
|
|
6
6
|
*/
|
|
7
7
|
import {
|
|
8
|
+
CliTokenPermissions,
|
|
8
9
|
DocumentPermissions,
|
|
9
10
|
ElementPermissions,
|
|
10
11
|
FormPermissions,
|
|
@@ -93,6 +94,9 @@ export const PERMISSION_NAMES: readonly PermissionName[] = [
|
|
|
93
94
|
ApplyStructure: "Change a site's definitions, views, styles or code from a bundle or push",
|
|
94
95
|
InstallCode: 'Install the code a bundle carries',
|
|
95
96
|
}),
|
|
97
|
+
...area('tokens', CliTokenPermissions, {
|
|
98
|
+
Create: 'Create tokens that let scripts run commands as you',
|
|
99
|
+
}),
|
|
96
100
|
]
|
|
97
101
|
|
|
98
102
|
export type PermissionLookup =
|
package/src/permissions.ts
CHANGED
|
@@ -73,12 +73,24 @@ const REMOTE_VERBS: ReadonlySet<string> = new Set(Object.values(RemotePermission
|
|
|
73
73
|
/** A remote verb: a group holding one is only an administrator's to fill (story 302). */
|
|
74
74
|
export const isRemotePermission = (verb: string): boolean => REMOTE_VERBS.has(verb)
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Command-line tokens (story 351): creating one, and using it, which is
|
|
78
|
+
* checked each time. Group-wide, held in the groups' fallback permissions, and
|
|
79
|
+
* explicit, so an administrator holds it only while a group of theirs names it.
|
|
80
|
+
*/
|
|
81
|
+
export const CliTokenPermissions = {
|
|
82
|
+
Create: 'Crombolo.CliTokens.Create',
|
|
83
|
+
} as const
|
|
84
|
+
|
|
76
85
|
/**
|
|
77
86
|
* Permissions an administrator does not hold by being one (story 241): only a
|
|
78
87
|
* group that names them grants them, so installing code on a site is always a
|
|
79
88
|
* choice somebody made and the audit log recorded.
|
|
80
89
|
*/
|
|
81
|
-
export const EXPLICIT_PERMISSIONS: ReadonlySet<string> = new Set([
|
|
90
|
+
export const EXPLICIT_PERMISSIONS: ReadonlySet<string> = new Set([
|
|
91
|
+
RemotePermissions.InstallCode,
|
|
92
|
+
CliTokenPermissions.Create,
|
|
93
|
+
])
|
|
82
94
|
|
|
83
95
|
/**
|
|
84
96
|
* Media (story 088). Umbraco has no media verbs: a group with the Media section
|
|
@@ -143,6 +155,7 @@ export const KNOWN_PERMISSIONS: ReadonlySet<string> = new Set([
|
|
|
143
155
|
...Object.values(RemotePermissions),
|
|
144
156
|
...Object.values(MediaPermissions),
|
|
145
157
|
...Object.values(ElementPermissions),
|
|
158
|
+
...Object.values(CliTokenPermissions),
|
|
146
159
|
])
|
|
147
160
|
|
|
148
161
|
export const ADMIN_GROUP_ALIAS = 'admin'
|
package/src/property-values.ts
CHANGED
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
* stored and returned as is.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { marked } from 'marked'
|
|
7
8
|
import { BLOCK_EDITORS } from './blocks.ts'
|
|
8
9
|
|
|
9
10
|
export const RICH_TEXT_EDITOR_ALIAS = 'Umbraco.RichText'
|
|
10
11
|
export const UPLOAD_FIELD_EDITOR_ALIAS = 'Umbraco.UploadField'
|
|
11
12
|
export const IMAGE_CROPPER_EDITOR_ALIAS = 'Umbraco.ImageCropper'
|
|
13
|
+
export const MARKDOWN_EDITOR_ALIAS = 'Umbraco.MarkdownEditor'
|
|
12
14
|
|
|
13
15
|
/** Editors whose value names an uploaded file, and so may arrive with a temporary file. */
|
|
14
16
|
export const FILE_VALUE_EDITORS: ReadonlySet<string> = new Set([
|
|
@@ -21,17 +23,22 @@ export const JSON_VALUE_EDITORS: ReadonlySet<string> = new Set([
|
|
|
21
23
|
...BLOCK_EDITORS,
|
|
22
24
|
'Umbraco.CheckBoxList',
|
|
23
25
|
'Umbraco.ColorPicker',
|
|
26
|
+
// The date and time pickers send `{ date, timeZone }`, the entity data picker `{ ids }`.
|
|
27
|
+
'Umbraco.DateOnly',
|
|
28
|
+
'Umbraco.DateTimeUnspecified',
|
|
24
29
|
'Umbraco.DateTimeWithTimeZone',
|
|
25
30
|
'Umbraco.DropDown.Flexible',
|
|
26
31
|
// A `Guid[]` of the elements picked, not the `umb://…` references a content
|
|
27
32
|
// picker stores.
|
|
28
33
|
'Umbraco.ElementPicker',
|
|
34
|
+
'Umbraco.EntityDataPicker',
|
|
29
35
|
'Umbraco.ImageCropper',
|
|
30
36
|
'Umbraco.MediaPicker3',
|
|
31
37
|
'Umbraco.MultipleTextstring',
|
|
32
38
|
'Umbraco.MultiUrlPicker',
|
|
33
39
|
'Umbraco.Slider',
|
|
34
40
|
'Umbraco.Tags',
|
|
41
|
+
'Umbraco.TimeOnly',
|
|
35
42
|
])
|
|
36
43
|
|
|
37
44
|
export interface RichTextValue {
|
|
@@ -131,10 +138,21 @@ export function toEditorValue(editorAlias: string | undefined, stored: unknown):
|
|
|
131
138
|
return parsed !== null && typeof parsed === 'object' ? parsed : stored
|
|
132
139
|
}
|
|
133
140
|
|
|
134
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* Markdown as HTML, GitHub-flavoured, as Umbraco's value converter gives it (story
|
|
143
|
+
* 357). The editors' own markup, so not sanitised, as rich text is not.
|
|
144
|
+
*/
|
|
145
|
+
export function markdownToHtml(text: unknown): string | null {
|
|
146
|
+
if (typeof text !== 'string' || text.trim() === '') return null
|
|
147
|
+
return marked.parse(text, { async: false, gfm: true })
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** The value a template receives: rich text is its markup, Markdown its HTML, an upload its URL. */
|
|
135
151
|
export function toPublishedValue(editorAlias: string | undefined, stored: unknown): unknown {
|
|
136
152
|
const value = toEditorValue(editorAlias, stored)
|
|
137
153
|
if (editorAlias === RICH_TEXT_EDITOR_ALIAS && value) return (value as RichTextValue).markup
|
|
154
|
+
if (editorAlias === MARKDOWN_EDITOR_ALIAS && value !== null && value !== undefined)
|
|
155
|
+
return markdownToHtml(value)
|
|
138
156
|
if (editorAlias === UPLOAD_FIELD_EDITOR_ALIAS)
|
|
139
157
|
return (value as { src: string } | null)?.src ?? null
|
|
140
158
|
return value
|