@crombolo/data 0.50.0 → 0.51.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 +2 -2
- package/src/cluster.ts +20 -5
- package/src/index.ts +1 -0
- package/src/schema/built-in-media-types.ts +11 -0
- package/src/schema/image-alt-text.ts +76 -0
- package/src/schema/plan.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.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.51.1",
|
|
32
32
|
"kysely": "0.29.6"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/cluster.ts
CHANGED
|
@@ -9,10 +9,16 @@ import { sql } from './query.ts'
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* `views` is a code change, not a data one: a template was written, so every
|
|
12
|
-
* node has to look at its views tree again.
|
|
13
|
-
* published cache; this one makes a node take a new snapshot.
|
|
12
|
+
* node has to look at its views tree again. `schema` and `content` invalidate
|
|
13
|
+
* the published cache; this one makes a node take a new snapshot. `public-files`
|
|
14
|
+
* is a site's `public/` folder changed by something a watcher cannot see, so a
|
|
15
|
+
* node lists it again (story 285).
|
|
14
16
|
*/
|
|
15
|
-
export type CacheInstructionKind = 'schema' | 'content' | 'components'
|
|
17
|
+
export type CacheInstructionKind = 'schema' | 'content' | 'components' | 'public-files'
|
|
18
|
+
|
|
19
|
+
/** Kinds about a site's files, not published content: they move no checkpoint. */
|
|
20
|
+
const isFileChange = (kind: CacheInstructionKind) =>
|
|
21
|
+
kind === 'components' || kind === 'public-files'
|
|
16
22
|
|
|
17
23
|
export interface CacheInstruction {
|
|
18
24
|
id: number
|
|
@@ -65,7 +71,7 @@ export function instructionEffects(
|
|
|
65
71
|
kind: CacheInstructionKind,
|
|
66
72
|
payload: Record<string, unknown>,
|
|
67
73
|
): InstructionEffects {
|
|
68
|
-
if (kind
|
|
74
|
+
if (isFileChange(kind)) return { pages: false, media: 'keep' }
|
|
69
75
|
if (kind === 'schema') return { pages: true, media: 'clear' }
|
|
70
76
|
const fields = Object.keys(payload)
|
|
71
77
|
const keys = strings(payload.media)
|
|
@@ -123,7 +129,7 @@ export async function appendCacheInstruction(
|
|
|
123
129
|
instruction: { kind: CacheInstructionKind; payload?: Record<string, unknown>; by?: string },
|
|
124
130
|
): Promise<number | null> {
|
|
125
131
|
return db.transaction(async (tx) => {
|
|
126
|
-
const checkpoint = instruction.kind
|
|
132
|
+
const checkpoint = isFileChange(instruction.kind) ? null : await advanceCheckpoint(tx)
|
|
127
133
|
await tx.q
|
|
128
134
|
.insertInto('cache_instruction')
|
|
129
135
|
.values({
|
|
@@ -223,6 +229,15 @@ export async function latestCacheInstructionId(db: Db): Promise<number> {
|
|
|
223
229
|
return Number(row?.n ?? 0)
|
|
224
230
|
}
|
|
225
231
|
|
|
232
|
+
/** The oldest instruction still held, or undefined when there are none. */
|
|
233
|
+
export async function oldestCacheInstructionId(db: Db): Promise<number | undefined> {
|
|
234
|
+
const row = await db.q
|
|
235
|
+
.selectFrom('cache_instruction')
|
|
236
|
+
.select((eb) => eb.fn.min('id').as('n'))
|
|
237
|
+
.executeTakeFirst()
|
|
238
|
+
return row?.n === null || row?.n === undefined ? undefined : Number(row.n)
|
|
239
|
+
}
|
|
240
|
+
|
|
226
241
|
export async function cacheInstructionsAfter(db: Db, afterId: number): Promise<CacheInstruction[]> {
|
|
227
242
|
const rows = await db.q
|
|
228
243
|
.selectFrom('cache_instruction')
|
package/src/index.ts
CHANGED
|
@@ -85,6 +85,7 @@ export * from './schema/form-library-types.ts'
|
|
|
85
85
|
export * from './schema/form-permission-prefix.ts'
|
|
86
86
|
export * from './schema/group-permissions.ts'
|
|
87
87
|
export * from './schema/identity.ts'
|
|
88
|
+
export * from './schema/image-alt-text.ts'
|
|
88
89
|
export * from './schema/jobs.ts'
|
|
89
90
|
export * from './schema/log-viewer.ts'
|
|
90
91
|
export * from './schema/media-access.ts'
|
|
@@ -50,6 +50,10 @@ export interface BuiltInMediaType {
|
|
|
50
50
|
properties: BuiltInMediaProperty[]
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/** What describes an image to someone who cannot see it (story 168). */
|
|
54
|
+
export const IMAGE_ALT_TEXT_ALIAS = 'altText'
|
|
55
|
+
export const IMAGE_ALT_TEXT_KEY = '4d1f8a26-7c39-4e0b-a5d2-6b9c0e3f1a64'
|
|
56
|
+
|
|
53
57
|
const extension = (key: string): BuiltInMediaProperty => ({
|
|
54
58
|
key,
|
|
55
59
|
alias: 'umbracoExtension',
|
|
@@ -111,6 +115,13 @@ export const BUILT_IN_MEDIA_TYPES: readonly BuiltInMediaType[] = [
|
|
|
111
115
|
pixels('854087f6-648b-40ed-bc98-b8a9789e80b9', 'umbracoHeight'),
|
|
112
116
|
bytes('bd4c5ace-26e3-4a8b-af1a-e8206a35fa07'),
|
|
113
117
|
extension('f7786fe8-724a-4ed0-b244-72546db32a92'),
|
|
118
|
+
{
|
|
119
|
+
key: IMAGE_ALT_TEXT_KEY,
|
|
120
|
+
alias: IMAGE_ALT_TEXT_ALIAS,
|
|
121
|
+
name: 'Alternative text',
|
|
122
|
+
dataType: 'textstring',
|
|
123
|
+
mandatory: false,
|
|
124
|
+
},
|
|
114
125
|
],
|
|
115
126
|
},
|
|
116
127
|
{
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration 064: alt text on the Image media type (story 168), which a fresh
|
|
3
|
+
* site gets from `BUILT_IN_MEDIA_TYPES`. One statement, so the plan can show it:
|
|
4
|
+
* a site with its own `altText` keeps it, and one with no Image yet is about to
|
|
5
|
+
* be given the field with the type.
|
|
6
|
+
*/
|
|
7
|
+
import { SYSTEM_MEDIA_TYPE_KEYS } from '@crombolo/core'
|
|
8
|
+
import type { Db } from '../database.ts'
|
|
9
|
+
import type { Migration } from '../migrations.ts'
|
|
10
|
+
import { sql } from '../query.ts'
|
|
11
|
+
import { IMAGE_ALT_TEXT_ALIAS, IMAGE_ALT_TEXT_KEY } from './built-in-media-types.ts'
|
|
12
|
+
import { STATE_SEARCH_REMOVALS } from './search-removals.ts'
|
|
13
|
+
|
|
14
|
+
export const STATE_IMAGE_ALT_TEXT = '{c3e7a512-0064-4f0b-9d61-a8b2c4e60064}'
|
|
15
|
+
|
|
16
|
+
const TEXTSTRING_DATA_TYPE = '0cc0eba1-9960-42c9-bf9b-60e150b429ae'
|
|
17
|
+
|
|
18
|
+
export const imageAltTextMigration: Migration = {
|
|
19
|
+
from: STATE_SEARCH_REMOVALS,
|
|
20
|
+
to: STATE_IMAGE_ALT_TEXT,
|
|
21
|
+
name: 'AddImageAltText',
|
|
22
|
+
kind: 'expand',
|
|
23
|
+
release: '0.51.0',
|
|
24
|
+
async up(db: Db) {
|
|
25
|
+
const no = sql.lit(db.dialect.boolValue(false))
|
|
26
|
+
await db.q
|
|
27
|
+
.insertInto('property_type')
|
|
28
|
+
.columns([
|
|
29
|
+
'unique_id',
|
|
30
|
+
'data_type_id',
|
|
31
|
+
'content_type_id',
|
|
32
|
+
'property_type_group_id',
|
|
33
|
+
'alias',
|
|
34
|
+
'name',
|
|
35
|
+
'sort_order',
|
|
36
|
+
'mandatory',
|
|
37
|
+
'label_on_top',
|
|
38
|
+
'variations',
|
|
39
|
+
])
|
|
40
|
+
.expression(
|
|
41
|
+
db.q
|
|
42
|
+
.selectFrom(['node as image', 'node as text_type'])
|
|
43
|
+
.where('image.unique_id', '=', SYSTEM_MEDIA_TYPE_KEYS.Image)
|
|
44
|
+
.where('text_type.unique_id', '=', TEXTSTRING_DATA_TYPE)
|
|
45
|
+
.where(({ exists, not, selectFrom }) =>
|
|
46
|
+
not(
|
|
47
|
+
exists(
|
|
48
|
+
selectFrom('property_type as p')
|
|
49
|
+
.select('p.id')
|
|
50
|
+
.whereRef('p.content_type_id', '=', 'image.id')
|
|
51
|
+
.where('p.alias', '=', IMAGE_ALT_TEXT_ALIAS),
|
|
52
|
+
),
|
|
53
|
+
),
|
|
54
|
+
)
|
|
55
|
+
.select(({ selectFrom }) => [
|
|
56
|
+
sql.lit(IMAGE_ALT_TEXT_KEY).as('unique_id'),
|
|
57
|
+
'text_type.id as data_type_id',
|
|
58
|
+
'image.id as content_type_id',
|
|
59
|
+
selectFrom('property_type_group as g')
|
|
60
|
+
.select((group) => group.fn.min('g.id').as('id'))
|
|
61
|
+
.whereRef('g.content_type_node_id', '=', 'image.id')
|
|
62
|
+
.as('property_type_group_id'),
|
|
63
|
+
sql.lit(IMAGE_ALT_TEXT_ALIAS).as('alias'),
|
|
64
|
+
sql.lit('Alternative text').as('name'),
|
|
65
|
+
selectFrom('property_type as p')
|
|
66
|
+
.select((type) => type.fn.countAll().as('n'))
|
|
67
|
+
.whereRef('p.content_type_id', '=', 'image.id')
|
|
68
|
+
.as('sort_order'),
|
|
69
|
+
no.as('mandatory'),
|
|
70
|
+
no.as('label_on_top'),
|
|
71
|
+
sql.lit(0).as('variations'),
|
|
72
|
+
]),
|
|
73
|
+
)
|
|
74
|
+
.execute()
|
|
75
|
+
},
|
|
76
|
+
}
|
package/src/schema/plan.ts
CHANGED
|
@@ -44,6 +44,7 @@ import { formWorkflowsMigration } from './form-workflows.ts'
|
|
|
44
44
|
import { formsMigration } from './forms.ts'
|
|
45
45
|
import { groupPermissionsMigration } from './group-permissions.ts'
|
|
46
46
|
import { identityMigration } from './identity.ts'
|
|
47
|
+
import { imageAltTextMigration } from './image-alt-text.ts'
|
|
47
48
|
import { jobsMigration } from './jobs.ts'
|
|
48
49
|
import { logViewerMigration } from './log-viewer.ts'
|
|
49
50
|
import { mediaAccessMigration } from './media-access.ts'
|
|
@@ -141,4 +142,5 @@ export const cromboloPlan = new MigrationPlan([
|
|
|
141
142
|
remoteTrustMigration,
|
|
142
143
|
mediaTreeOrderMigration,
|
|
143
144
|
searchRemovalsMigration,
|
|
145
|
+
imageAltTextMigration,
|
|
144
146
|
])
|