@crombolo/data 0.42.1 → 0.43.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/NOTICE +9 -0
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/overview.ts +78 -0
- package/src/workflow-store.ts +4 -3
package/NOTICE
CHANGED
|
@@ -27,6 +27,15 @@ The Umbraco backoffice
|
|
|
27
27
|
@umbraco-cms/backoffice 18.2.0 — MIT — https://github.com/umbraco/Umbraco-CMS
|
|
28
28
|
@umbraco-ui/uui 2.0.2 — MIT — https://github.com/umbraco/Umbraco.UI
|
|
29
29
|
|
|
30
|
+
The Lato fonts
|
|
31
|
+
-------------
|
|
32
|
+
LatoLatin-*.woff2 — Copyright (c) 2011-2015 by tyPoland Lukasz Dziedzic, with
|
|
33
|
+
Reserved Font Name "Lato" — SIL Open Font License 1.1 — https://www.latofonts.com
|
|
34
|
+
Shipped unmodified, as @umbraco-ui/uui ships them, in @crombolo/backoffice-dist
|
|
35
|
+
under `dist/assets/fonts/`, with the licence beside them as `OFL.txt`
|
|
36
|
+
(`packages/backoffice-dist/licenses/Lato-OFL.txt` in this repository). The
|
|
37
|
+
fonts carry the same notice in their own metadata.
|
|
38
|
+
|
|
30
39
|
Static files from the Umbraco client source tree
|
|
31
40
|
------------------------------------------------
|
|
32
41
|
css/umb-css.css, css/rte-content.css, css/umbraco-blockgridlayout.css
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.1",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. SQLite and Postgres storage for crombolo: schema, migrations and repositories.",
|
|
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.
|
|
31
|
+
"@crombolo/core": "0.43.1",
|
|
32
32
|
"kysely": "0.29.6"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/index.ts
CHANGED
package/src/overview.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the back office's Overview shows about a page beyond a content query's
|
|
3
|
+
* answer (story 236): its type's name, who last changed it, and the keys from
|
|
4
|
+
* the root down to it, which permissions are checked against.
|
|
5
|
+
*/
|
|
6
|
+
import { ObjectTypes } from '@crombolo/core'
|
|
7
|
+
import type { Db } from './database.ts'
|
|
8
|
+
import { fromDbBool } from './dialect.ts'
|
|
9
|
+
|
|
10
|
+
export interface OverviewPageFacts {
|
|
11
|
+
key: string
|
|
12
|
+
name: string
|
|
13
|
+
contentTypeName: string
|
|
14
|
+
/** The user who saved the current version, by name; null when nobody signed in did. */
|
|
15
|
+
author: string | null
|
|
16
|
+
/** Ancestor keys, then the page's own. */
|
|
17
|
+
chain: string[]
|
|
18
|
+
trashed: boolean
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The facts for each page that still exists, by key. */
|
|
22
|
+
export async function overviewPageFacts(
|
|
23
|
+
db: Db,
|
|
24
|
+
keys: readonly string[],
|
|
25
|
+
): Promise<Map<string, OverviewPageFacts>> {
|
|
26
|
+
const out = new Map<string, OverviewPageFacts>()
|
|
27
|
+
const wanted = [...new Set(keys.map((k) => k.toLowerCase()))]
|
|
28
|
+
if (wanted.length === 0) return out
|
|
29
|
+
const rows = await db.q
|
|
30
|
+
.selectFrom('node as n')
|
|
31
|
+
.innerJoin('content as c', 'c.node_id', 'n.id')
|
|
32
|
+
.innerJoin('node as tn', 'tn.id', 'c.content_type_id')
|
|
33
|
+
.leftJoin('content_version as cv', (join) =>
|
|
34
|
+
join
|
|
35
|
+
.onRef('cv.node_id', '=', 'n.id')
|
|
36
|
+
.on('cv.current', '=', db.dialect.boolValue(true) as boolean),
|
|
37
|
+
)
|
|
38
|
+
.leftJoin('user_account as u', 'u.id', 'cv.user_id')
|
|
39
|
+
.select([
|
|
40
|
+
'n.unique_id as key',
|
|
41
|
+
'n.text as name',
|
|
42
|
+
'n.path as path',
|
|
43
|
+
'n.trashed as trashed',
|
|
44
|
+
'tn.text as typeName',
|
|
45
|
+
'u.user_name as author',
|
|
46
|
+
])
|
|
47
|
+
.where('n.node_object_type', '=', ObjectTypes.Document)
|
|
48
|
+
.where('n.unique_id', 'in', wanted)
|
|
49
|
+
.execute()
|
|
50
|
+
const ancestorIds = new Set<number>()
|
|
51
|
+
for (const row of rows)
|
|
52
|
+
for (const id of String(row.path).split(',').map(Number)) if (id > 0) ancestorIds.add(id)
|
|
53
|
+
const keyOf = new Map<number, string>()
|
|
54
|
+
if (ancestorIds.size > 0)
|
|
55
|
+
for (const n of await db.q
|
|
56
|
+
.selectFrom('node')
|
|
57
|
+
.select(['id', 'unique_id'])
|
|
58
|
+
.where('id', 'in', [...ancestorIds])
|
|
59
|
+
.execute())
|
|
60
|
+
keyOf.set(Number(n.id), String(n.unique_id))
|
|
61
|
+
for (const row of rows) {
|
|
62
|
+
const chain = String(row.path)
|
|
63
|
+
.split(',')
|
|
64
|
+
.map(Number)
|
|
65
|
+
.filter((id) => id > 0)
|
|
66
|
+
.map((id) => keyOf.get(id))
|
|
67
|
+
.filter((k): k is string => k !== undefined)
|
|
68
|
+
out.set(String(row.key), {
|
|
69
|
+
key: String(row.key),
|
|
70
|
+
name: String(row.name ?? ''),
|
|
71
|
+
contentTypeName: String(row.typeName ?? ''),
|
|
72
|
+
author: row.author === null || row.author === undefined ? null : String(row.author),
|
|
73
|
+
chain,
|
|
74
|
+
trashed: fromDbBool(row.trashed),
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
return out
|
|
78
|
+
}
|
package/src/workflow-store.ts
CHANGED
|
@@ -74,8 +74,9 @@ export interface WorkflowSyncReport {
|
|
|
74
74
|
* Stores the workflows and applies each changed one's `on-change` to the
|
|
75
75
|
* requests in flight under it: `keep` leaves them on the version they started
|
|
76
76
|
* with, `restart` starts them again from the first stage of the new one, and
|
|
77
|
-
* `withdraw` ends them. A workflow that is gone
|
|
78
|
-
*
|
|
77
|
+
* `withdraw` ends them. A workflow that is gone covers nothing, so its requests
|
|
78
|
+
* are withdrawn whatever it said: approving one would only publish a page its
|
|
79
|
+
* author may publish already.
|
|
79
80
|
*/
|
|
80
81
|
export async function syncWorkflows(
|
|
81
82
|
db: Db,
|
|
@@ -92,7 +93,7 @@ export async function syncWorkflows(
|
|
|
92
93
|
const now = current.get(id)
|
|
93
94
|
if (was && now && was.version === now.version) continue
|
|
94
95
|
report.changed.push((now ?? was)?.workflow.alias ?? id)
|
|
95
|
-
const rule =
|
|
96
|
+
const rule = now ? (now.workflow.onChange ?? 'keep') : 'withdraw'
|
|
96
97
|
for (const request of await requests.waitingUnder(id)) {
|
|
97
98
|
if (request.workflowVersion === now?.version) continue
|
|
98
99
|
if (rule === 'keep') {
|