@crombolo/data 0.50.0 → 0.51.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 +2 -2
- 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.0",
|
|
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.0",
|
|
32
32
|
"kysely": "0.29.6"
|
|
33
33
|
}
|
|
34
34
|
}
|
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
|
])
|