@crombolo/data 0.39.0 → 0.40.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/repositories/content-types.ts +24 -2
- package/src/schema/plan.ts +2 -0
- package/src/schema/site-settings-types.ts +27 -0
- package/src/site-search.ts +2 -0
- package/src/tables.gen.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.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.40.0",
|
|
32
32
|
"kysely": "0.29.6"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/index.ts
CHANGED
|
@@ -97,6 +97,7 @@ export * from './schema/search-index.ts'
|
|
|
97
97
|
export * from './schema/seed.ts'
|
|
98
98
|
export * from './schema/since-version.ts'
|
|
99
99
|
export * from './schema/site-search.ts'
|
|
100
|
+
export * from './schema/site-settings-types.ts'
|
|
100
101
|
export * from './schema/transfer-answers.ts'
|
|
101
102
|
export * from './schema/transfer-run-package.ts'
|
|
102
103
|
export * from './schema/transfer-runs.ts'
|
|
@@ -47,11 +47,12 @@ async function propertySignature(db: Db, contentTypeNodeId: number): Promise<str
|
|
|
47
47
|
.execute()
|
|
48
48
|
const [type] = await db.q
|
|
49
49
|
.selectFrom('content_type')
|
|
50
|
-
.select('site_search')
|
|
50
|
+
.select(['site_search', 'site_settings'])
|
|
51
51
|
.where('node_id', '=', contentTypeNodeId)
|
|
52
52
|
.execute()
|
|
53
53
|
return [
|
|
54
|
-
|
|
54
|
+
// A site's settings page is never searched (story 058).
|
|
55
|
+
`site:${type ? fromDbBool(type.site_search) && !fromDbBool(type.site_settings) : true}`,
|
|
55
56
|
...rows.map(
|
|
56
57
|
(row) =>
|
|
57
58
|
`${row.id}:${row.alias}:${row.variations}:${row.data_type_id}:${fromDbBool(row.searchable)}:${row.site_search}`,
|
|
@@ -367,6 +368,12 @@ export class ContentTypeRepository {
|
|
|
367
368
|
.set({ site_search: bool(aggregate.siteSearch) })
|
|
368
369
|
.where('node_id', '=', nodeId)
|
|
369
370
|
.execute()
|
|
371
|
+
if (aggregate.siteSettings !== undefined)
|
|
372
|
+
await tx.q
|
|
373
|
+
.updateTable('content_type')
|
|
374
|
+
.set({ site_settings: bool(aggregate.siteSettings) })
|
|
375
|
+
.where('node_id', '=', nodeId)
|
|
376
|
+
.execute()
|
|
370
377
|
|
|
371
378
|
// ---- groups: upsert by key
|
|
372
379
|
const groupIdByKey = new Map<string, number>()
|
|
@@ -688,6 +695,19 @@ export class ContentTypeRepository {
|
|
|
688
695
|
return new Map(rows.map((r) => [normaliseUuid(String(r.unique_id)), String(r.alias)]))
|
|
689
696
|
}
|
|
690
697
|
|
|
698
|
+
/** The aliases of the types that are a site's settings (story 058). */
|
|
699
|
+
async siteSettingsAliases(): Promise<string[]> {
|
|
700
|
+
const rows = await this.#db.q
|
|
701
|
+
.selectFrom('content_type as ct')
|
|
702
|
+
.innerJoin('node as n', 'n.id', 'ct.node_id')
|
|
703
|
+
.select('ct.alias')
|
|
704
|
+
.where('ct.retired_at', 'is', null)
|
|
705
|
+
.where('ct.site_settings', '=', this.#db.dialect.boolValue(true) as boolean)
|
|
706
|
+
.where('n.node_object_type', '=', this.#objectType)
|
|
707
|
+
.execute()
|
|
708
|
+
return rows.map((row) => String(row.alias))
|
|
709
|
+
}
|
|
710
|
+
|
|
691
711
|
async move(key: string, parentKey: string | null): Promise<boolean> {
|
|
692
712
|
const node = await this.#nodes.byKey(key)
|
|
693
713
|
if (!node || node.objectType !== this.#objectType) return false
|
|
@@ -904,6 +924,7 @@ export class ContentTypeRepository {
|
|
|
904
924
|
'ct.keep_latest_version_per_day_for_days',
|
|
905
925
|
'ct.since_version',
|
|
906
926
|
'ct.site_search',
|
|
927
|
+
'ct.site_settings',
|
|
907
928
|
'ss.version as since_v',
|
|
908
929
|
'ss.revision as since_r',
|
|
909
930
|
])
|
|
@@ -1034,6 +1055,7 @@ export class ContentTypeRepository {
|
|
|
1034
1055
|
isElement: fromDbBool(type.is_element),
|
|
1035
1056
|
allowedInLibrary: fromDbBool(type.allow_in_library),
|
|
1036
1057
|
siteSearch: fromDbBool(type.site_search),
|
|
1058
|
+
siteSettings: fromDbBool(type.site_settings),
|
|
1037
1059
|
collectionKey: type.list_view ? normaliseUuid(String(type.list_view)) : null,
|
|
1038
1060
|
cleanup: {
|
|
1039
1061
|
preventCleanup: fromDbBool(type.prevent_cleanup),
|
package/src/schema/plan.ts
CHANGED
|
@@ -60,6 +60,7 @@ import { searchIndexMigration } from './search-index.ts'
|
|
|
60
60
|
import { serverRoleMigration } from './server-role.ts'
|
|
61
61
|
import { sinceVersionMigration } from './since-version.ts'
|
|
62
62
|
import { siteSearchMigration } from './site-search.ts'
|
|
63
|
+
import { siteSettingsTypesMigration } from './site-settings-types.ts'
|
|
63
64
|
import { transferAnswersMigration } from './transfer-answers.ts'
|
|
64
65
|
import { transferRunPackageMigration } from './transfer-run-package.ts'
|
|
65
66
|
import { transferRunsMigration } from './transfer-runs.ts'
|
|
@@ -127,4 +128,5 @@ export const cromboloPlan = new MigrationPlan([
|
|
|
127
128
|
bundleGrantsMigration,
|
|
128
129
|
jobsMigration,
|
|
129
130
|
bundlesDisabledMigration,
|
|
131
|
+
siteSettingsTypesMigration,
|
|
130
132
|
])
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration 057: a content type can be a site's settings (story 058). Its page,
|
|
3
|
+
* a direct child of a root, holds that site's settings and has no address.
|
|
4
|
+
*/
|
|
5
|
+
import type { Db } from '../database.ts'
|
|
6
|
+
import type { Migration } from '../migrations.ts'
|
|
7
|
+
import { schemaOps } from '../schema-ops.ts'
|
|
8
|
+
import { STATE_BUNDLES_DISABLED } from './bundles-disabled.ts'
|
|
9
|
+
|
|
10
|
+
export const STATE_SITE_SETTINGS_TYPES = '{4b198f00-0057-4ca8-bc39-97d92fca0057}'
|
|
11
|
+
|
|
12
|
+
export const siteSettingsTypesMigration: Migration = {
|
|
13
|
+
from: STATE_BUNDLES_DISABLED,
|
|
14
|
+
to: STATE_SITE_SETTINGS_TYPES,
|
|
15
|
+
name: 'AddSiteSettingsTypes',
|
|
16
|
+
kind: 'expand',
|
|
17
|
+
release: '0.40.0',
|
|
18
|
+
async up(db: Db) {
|
|
19
|
+
const t = db.dialect.types
|
|
20
|
+
const postgres = db.dialect.name === 'postgres'
|
|
21
|
+
await schemaOps(db).addColumn(
|
|
22
|
+
'content_type',
|
|
23
|
+
'site_settings',
|
|
24
|
+
`${t.boolean} NOT NULL DEFAULT ${postgres ? 'FALSE' : '0'}`,
|
|
25
|
+
)
|
|
26
|
+
},
|
|
27
|
+
}
|
package/src/site-search.ts
CHANGED
|
@@ -71,6 +71,7 @@ export async function siteEntriesFor(db: Db, nodeId: number): Promise<SiteSearch
|
|
|
71
71
|
'n.trashed',
|
|
72
72
|
'c.content_type_id',
|
|
73
73
|
'ct.site_search',
|
|
74
|
+
'ct.site_settings',
|
|
74
75
|
'ct.is_element',
|
|
75
76
|
'd.published',
|
|
76
77
|
eb
|
|
@@ -87,6 +88,7 @@ export async function siteEntriesFor(db: Db, nodeId: number): Promise<SiteSearch
|
|
|
87
88
|
fromDbBool(node.trashed) ||
|
|
88
89
|
!fromDbBool(node.published) ||
|
|
89
90
|
!fromDbBool(node.site_search) ||
|
|
91
|
+
fromDbBool(node.site_settings) ||
|
|
90
92
|
fromDbBool(node.is_element) ||
|
|
91
93
|
Number(node.components) === 0
|
|
92
94
|
)
|