@crombolo/data 0.78.0 → 0.79.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/plan.ts +2 -0
- package/src/schema/seed.ts +2 -1
- package/src/schema/workspace-places.ts +51 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.79.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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@crombolo/core": "0.
|
|
32
|
+
"@crombolo/core": "0.79.0",
|
|
33
33
|
"kysely": "0.29.6"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/src/index.ts
CHANGED
|
@@ -161,6 +161,7 @@ export * from './schema/workspace-conflicts.ts'
|
|
|
161
161
|
export * from './schema/workspace-errors.ts'
|
|
162
162
|
export * from './schema/workspace-links.ts'
|
|
163
163
|
export * from './schema/workspace-merge.ts'
|
|
164
|
+
export * from './schema/workspace-places.ts'
|
|
164
165
|
export * from './schema/workspace-privacy.ts'
|
|
165
166
|
export * from './schema/workspace-processes.ts'
|
|
166
167
|
export * from './schema/workspace-schedules.ts'
|
package/src/schema/plan.ts
CHANGED
|
@@ -105,6 +105,7 @@ import { workspaceConflictsMigration } from './workspace-conflicts.ts'
|
|
|
105
105
|
import { workspaceErrorsMigration } from './workspace-errors.ts'
|
|
106
106
|
import { workspaceLinksMigration } from './workspace-links.ts'
|
|
107
107
|
import { workspaceMergeMigration } from './workspace-merge.ts'
|
|
108
|
+
import { workspacePlacesMigration } from './workspace-places.ts'
|
|
108
109
|
import { workspacePrivacyMigration } from './workspace-privacy.ts'
|
|
109
110
|
import { workspaceProcessesMigration } from './workspace-processes.ts'
|
|
110
111
|
import { workspaceSchedulesMigration } from './workspace-schedules.ts'
|
|
@@ -209,4 +210,5 @@ export const cromboloPlan = new MigrationPlan([
|
|
|
209
210
|
groupStartKeysMigration,
|
|
210
211
|
workspaceErrorsMigration,
|
|
211
212
|
workspaceSchedulesMigration,
|
|
213
|
+
workspacePlacesMigration,
|
|
212
214
|
])
|
package/src/schema/seed.ts
CHANGED
|
@@ -186,7 +186,8 @@ export const BUILT_IN_GROUPS = [
|
|
|
186
186
|
name: 'Translators',
|
|
187
187
|
icon: 'icon-globe',
|
|
188
188
|
hasAccessToAllLanguages: true,
|
|
189
|
-
|
|
189
|
+
// Story 419: Translation is a place under Content, which it needs too.
|
|
190
|
+
sections: ['content', 'translation'],
|
|
190
191
|
},
|
|
191
192
|
{
|
|
192
193
|
id: 5,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration 098 — Content is what a workspace holds (story 419). Library and
|
|
3
|
+
* Translation are places under Content, so a group holding either without Content
|
|
4
|
+
* gains Content, which opens nothing by itself; and languages are Translation's, so a
|
|
5
|
+
* group holding Structure without Translation gains Translation, keeping the
|
|
6
|
+
* languages it could change. Nobody loses anything they could open.
|
|
7
|
+
*/
|
|
8
|
+
import type { Db } from '../database.ts'
|
|
9
|
+
import type { Migration } from '../migrations.ts'
|
|
10
|
+
import { STATE_WORKSPACE_SCHEDULES } from './workspace-schedules.ts'
|
|
11
|
+
|
|
12
|
+
export const STATE_WORKSPACE_PLACES = '{4e7a1c93-0098-4b6d-a2f5-7c1e9d3b0098}'
|
|
13
|
+
|
|
14
|
+
/** Each grant a group gains (`alias`) from one it holds (`from`). */
|
|
15
|
+
const GAINS: ReadonlyArray<{ alias: string; from: readonly string[] }> = [
|
|
16
|
+
{ alias: 'content', from: ['library', 'translation'] },
|
|
17
|
+
{ alias: 'translation', from: ['structure'] },
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
export const workspacePlacesMigration: Migration = {
|
|
21
|
+
from: STATE_WORKSPACE_SCHEDULES,
|
|
22
|
+
to: STATE_WORKSPACE_PLACES,
|
|
23
|
+
name: 'AddWorkspacePlaces',
|
|
24
|
+
kind: 'expand',
|
|
25
|
+
release: '0.79.0',
|
|
26
|
+
async up(db: Db) {
|
|
27
|
+
for (const { alias, from } of GAINS)
|
|
28
|
+
await db.q
|
|
29
|
+
.insertInto('user_group_section')
|
|
30
|
+
.columns(['user_group_id', 'app_alias'])
|
|
31
|
+
.expression((eb) =>
|
|
32
|
+
eb
|
|
33
|
+
.selectFrom('user_group_section as held')
|
|
34
|
+
.select(['held.user_group_id', eb.val(alias).as('app_alias')])
|
|
35
|
+
.where('held.app_alias', 'in', [...from])
|
|
36
|
+
.where((w) =>
|
|
37
|
+
w.not(
|
|
38
|
+
w.exists(
|
|
39
|
+
w
|
|
40
|
+
.selectFrom('user_group_section as has')
|
|
41
|
+
.select('has.app_alias')
|
|
42
|
+
.whereRef('has.user_group_id', '=', 'held.user_group_id')
|
|
43
|
+
.where('has.app_alias', '=', alias),
|
|
44
|
+
),
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
.distinct(),
|
|
48
|
+
)
|
|
49
|
+
.execute()
|
|
50
|
+
},
|
|
51
|
+
}
|