@crombolo/data 0.56.0 → 0.57.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 +4 -3
- package/src/index.ts +7 -0
- package/src/repositories/bundle-grants.ts +22 -2
- package/src/repositories/bundles.ts +20 -1
- package/src/repositories/extension-settings.ts +51 -0
- package/src/repositories/transfer-runs.ts +22 -0
- package/src/repositories/trusted-signers.ts +101 -0
- package/src/schema/bundle-grant-reach.ts +24 -0
- package/src/schema/bundle-kind.ts +26 -0
- package/src/schema/extension-settings.ts +31 -0
- package/src/schema/plan.ts +10 -0
- package/src/schema/transfer-run-bundle-type.ts +27 -0
- package/src/schema/trusted-signers.ts +38 -0
- package/src/tables.gen.ts +23 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.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",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
20
20
|
"exports": {
|
|
21
|
-
".": "./src/index.ts"
|
|
21
|
+
".": "./src/index.ts",
|
|
22
|
+
"./tables-builder": "./src/custom-tables/builder.ts"
|
|
22
23
|
},
|
|
23
24
|
"files": [
|
|
24
25
|
"src",
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
"access": "public"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@crombolo/core": "0.
|
|
32
|
+
"@crombolo/core": "0.57.0",
|
|
32
33
|
"kysely": "0.29.6"
|
|
33
34
|
}
|
|
34
35
|
}
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ export * from './repositories/document-listing.ts'
|
|
|
29
29
|
export * from './repositories/documents.ts'
|
|
30
30
|
export * from './repositories/domains.ts'
|
|
31
31
|
export * from './repositories/dynamic-roots.ts'
|
|
32
|
+
export * from './repositories/extension-settings.ts'
|
|
32
33
|
export * from './repositories/external-logins.ts'
|
|
33
34
|
export * from './repositories/folders.ts'
|
|
34
35
|
export * from './repositories/form-entries.ts'
|
|
@@ -50,6 +51,7 @@ export * from './repositories/tags.ts'
|
|
|
50
51
|
export * from './repositories/templates.ts'
|
|
51
52
|
export * from './repositories/transfer-answers.ts'
|
|
52
53
|
export * from './repositories/transfer-runs.ts'
|
|
54
|
+
export * from './repositories/trusted-signers.ts'
|
|
53
55
|
export * from './repositories/two-factor.ts'
|
|
54
56
|
export * from './repositories/user-data.ts'
|
|
55
57
|
export * from './repositories/users.ts'
|
|
@@ -61,7 +63,9 @@ export * from './schema/audit-log.ts'
|
|
|
61
63
|
export * from './schema/built-in-content-types.ts'
|
|
62
64
|
export * from './schema/built-in-media-types.ts'
|
|
63
65
|
export * from './schema/built-in-member-types.ts'
|
|
66
|
+
export * from './schema/bundle-grant-reach.ts'
|
|
64
67
|
export * from './schema/bundle-grants.ts'
|
|
68
|
+
export * from './schema/bundle-kind.ts'
|
|
65
69
|
export * from './schema/bundle-package.ts'
|
|
66
70
|
export * from './schema/bundle-schema-picks.ts'
|
|
67
71
|
export * from './schema/bundles-disabled.ts'
|
|
@@ -80,6 +84,7 @@ export * from './schema/delivery-member-tokens.ts'
|
|
|
80
84
|
export * from './schema/diagnostics.ts'
|
|
81
85
|
export * from './schema/drop-assistant.ts'
|
|
82
86
|
export * from './schema/elements.ts'
|
|
87
|
+
export * from './schema/extension-settings.ts'
|
|
83
88
|
export * from './schema/form-library.ts'
|
|
84
89
|
export * from './schema/form-library-types.ts'
|
|
85
90
|
export * from './schema/form-permission-prefix.ts'
|
|
@@ -110,9 +115,11 @@ export * from './schema/since-version.ts'
|
|
|
110
115
|
export * from './schema/site-search.ts'
|
|
111
116
|
export * from './schema/site-settings-types.ts'
|
|
112
117
|
export * from './schema/transfer-answers.ts'
|
|
118
|
+
export * from './schema/transfer-run-bundle-type.ts'
|
|
113
119
|
export * from './schema/transfer-run-package.ts'
|
|
114
120
|
export * from './schema/transfer-runs.ts'
|
|
115
121
|
export * from './schema/trashed-date.ts'
|
|
122
|
+
export * from './schema/trusted-signers.ts'
|
|
116
123
|
export * from './schema/two-factor.ts'
|
|
117
124
|
export * from './schema/upgrade-report.ts'
|
|
118
125
|
export * from './schema/users-localisation.ts'
|
|
@@ -11,8 +11,20 @@ export interface BundleGrant {
|
|
|
11
11
|
packageName: string
|
|
12
12
|
version: string
|
|
13
13
|
permissions: string[]
|
|
14
|
+
/** What its `http.outbound` may reach (story 308); empty when it was granted none. */
|
|
15
|
+
origins: string[]
|
|
16
|
+
/**
|
|
17
|
+
* Whom it acts for under `actAs`: `installer:<user key>`, `caller`, or
|
|
18
|
+
* `user:<user key>`; null when it acts as itself.
|
|
19
|
+
*/
|
|
20
|
+
actAs: string | null
|
|
14
21
|
grantedBy: string | null
|
|
15
22
|
grantedAt: Date
|
|
23
|
+
/**
|
|
24
|
+
* Someone granted it (story 309): false for the row `disable` keeps for a
|
|
25
|
+
* bundle never granted, which grants nothing.
|
|
26
|
+
*/
|
|
27
|
+
recorded: boolean
|
|
16
28
|
/** Who disabled the bundle, and when; null while it may run. */
|
|
17
29
|
disabledBy: string | null
|
|
18
30
|
disabledAt: Date | null
|
|
@@ -41,8 +53,11 @@ export class BundleGrantRepository {
|
|
|
41
53
|
packageName: row.package_name,
|
|
42
54
|
version: row.version,
|
|
43
55
|
permissions: permissionsOf(row.permissions),
|
|
56
|
+
origins: row.origins ? permissionsOf(row.origins) : [],
|
|
57
|
+
actAs: row.act_as ?? null,
|
|
44
58
|
grantedBy: row.granted_by ?? null,
|
|
45
59
|
grantedAt: DbDate.fromDb(row.granted_at) ?? new Date(0),
|
|
60
|
+
recorded: (DbDate.fromDb(row.granted_at)?.getTime() ?? 0) > 0,
|
|
46
61
|
disabledBy: row.disabled_by ?? null,
|
|
47
62
|
disabledAt: row.disabled_at ? (DbDate.fromDb(row.disabled_at) ?? null) : null,
|
|
48
63
|
}))
|
|
@@ -53,11 +68,15 @@ export class BundleGrantRepository {
|
|
|
53
68
|
}
|
|
54
69
|
|
|
55
70
|
/** Records what a bundle is approved for, keeping whether it is disabled. */
|
|
56
|
-
async grant(
|
|
71
|
+
async grant(
|
|
72
|
+
grant: Omit<BundleGrant, 'grantedAt' | 'recorded' | 'disabledBy' | 'disabledAt'>,
|
|
73
|
+
): Promise<void> {
|
|
57
74
|
const values = {
|
|
58
75
|
package_name: grant.packageName,
|
|
59
76
|
version: grant.version,
|
|
60
77
|
permissions: JSON.stringify(grant.permissions),
|
|
78
|
+
origins: JSON.stringify(grant.origins),
|
|
79
|
+
act_as: grant.actAs,
|
|
61
80
|
granted_by: grant.grantedBy,
|
|
62
81
|
granted_at: DbDate.toDb(new Date()),
|
|
63
82
|
}
|
|
@@ -85,7 +104,8 @@ export class BundleGrantRepository {
|
|
|
85
104
|
version: bundle.version,
|
|
86
105
|
permissions: JSON.stringify([]),
|
|
87
106
|
granted_by: null,
|
|
88
|
-
|
|
107
|
+
// Not a grant: nobody granted it anything (story 309).
|
|
108
|
+
granted_at: DbDate.toDb(new Date(0)),
|
|
89
109
|
...disabled,
|
|
90
110
|
})
|
|
91
111
|
.onConflict((conflict) => conflict.column('bundle_id').doUpdateSet(disabled))
|
|
@@ -11,6 +11,8 @@ import type { Db } from '../database.ts'
|
|
|
11
11
|
import { DbDate, fromDbBool } from '../dialect.ts'
|
|
12
12
|
import { sql } from '../query.ts'
|
|
13
13
|
|
|
14
|
+
export type BundleDefinitionKind = 'extension' | 'site'
|
|
15
|
+
|
|
14
16
|
export interface Bundle {
|
|
15
17
|
id: string
|
|
16
18
|
name: string
|
|
@@ -33,6 +35,11 @@ export interface Bundle {
|
|
|
33
35
|
*/
|
|
34
36
|
packageName: string | null
|
|
35
37
|
packageVersion: string | null
|
|
38
|
+
/**
|
|
39
|
+
* What it builds (story 312): an extension for other sites, or a site bundle
|
|
40
|
+
* to move this site. Not in Umbraco's definition either.
|
|
41
|
+
*/
|
|
42
|
+
kind: BundleDefinitionKind
|
|
36
43
|
createDate: Date
|
|
37
44
|
updateDate: Date
|
|
38
45
|
}
|
|
@@ -40,12 +47,13 @@ export interface Bundle {
|
|
|
40
47
|
/** A definition to store; `id` is assigned when it is new, the dates always. */
|
|
41
48
|
export type BundleInput = Omit<
|
|
42
49
|
Bundle,
|
|
43
|
-
'id' | 'createDate' | 'updateDate' | 'packageName' | 'packageVersion'
|
|
50
|
+
'id' | 'createDate' | 'updateDate' | 'packageName' | 'packageVersion' | 'kind'
|
|
44
51
|
>
|
|
45
52
|
|
|
46
53
|
interface Row {
|
|
47
54
|
id: string
|
|
48
55
|
name: string
|
|
56
|
+
kind: string
|
|
49
57
|
content_node_id: string | null
|
|
50
58
|
content_load_child_nodes: unknown
|
|
51
59
|
media_load_child_nodes: unknown
|
|
@@ -83,6 +91,7 @@ const COLUMNS = [
|
|
|
83
91
|
'dictionary_items',
|
|
84
92
|
'package_name',
|
|
85
93
|
'package_version',
|
|
94
|
+
'kind',
|
|
86
95
|
'create_date',
|
|
87
96
|
'update_date',
|
|
88
97
|
] as const
|
|
@@ -135,6 +144,7 @@ const hydrate = (row: Row): Bundle => ({
|
|
|
135
144
|
dictionaryItems: list(row.dictionary_items),
|
|
136
145
|
packageName: row.package_name ?? null,
|
|
137
146
|
packageVersion: row.package_version ?? null,
|
|
147
|
+
kind: row.kind === 'site' ? 'site' : 'extension',
|
|
138
148
|
createDate: DbDate.fromDb(row.create_date) ?? new Date(0),
|
|
139
149
|
updateDate: DbDate.fromDb(row.update_date) ?? new Date(0),
|
|
140
150
|
})
|
|
@@ -248,6 +258,7 @@ export class BundleRepository {
|
|
|
248
258
|
id,
|
|
249
259
|
packageName: null,
|
|
250
260
|
packageVersion: null,
|
|
261
|
+
kind: 'extension',
|
|
251
262
|
createDate: now,
|
|
252
263
|
updateDate: now,
|
|
253
264
|
}
|
|
@@ -262,6 +273,14 @@ export class BundleRepository {
|
|
|
262
273
|
}
|
|
263
274
|
|
|
264
275
|
/** The npm package a definition is built as; null clears a value back to its default. */
|
|
276
|
+
async setKind(id: string, kind: BundleDefinitionKind): Promise<void> {
|
|
277
|
+
await this.#db.q
|
|
278
|
+
.updateTable('bundle')
|
|
279
|
+
.set({ kind, update_date: DbDate.toDb(new Date()) })
|
|
280
|
+
.where('id', '=', id)
|
|
281
|
+
.execute()
|
|
282
|
+
}
|
|
283
|
+
|
|
265
284
|
async setPackage(
|
|
266
285
|
id: string,
|
|
267
286
|
pkg: { name: string | null; version: string | null },
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An extension's settings as set in the back office (story 310), each stored as
|
|
3
|
+
* JSON; a secret arrives already sealed. docs/bundles.md, "Settings".
|
|
4
|
+
*/
|
|
5
|
+
import type { Db } from '../database.ts'
|
|
6
|
+
import { DbDate } from '../dialect.ts'
|
|
7
|
+
|
|
8
|
+
export class ExtensionSettingRepository {
|
|
9
|
+
constructor(private readonly db: Db) {}
|
|
10
|
+
|
|
11
|
+
/** Every stored value, by extension and key. */
|
|
12
|
+
async all(): Promise<Map<string, Record<string, unknown>>> {
|
|
13
|
+
const rows = await this.db.q.selectFrom('extension_setting').selectAll().execute()
|
|
14
|
+
const out = new Map<string, Record<string, unknown>>()
|
|
15
|
+
for (const row of rows) {
|
|
16
|
+
const values = out.get(row.bundle_id) ?? {}
|
|
17
|
+
try {
|
|
18
|
+
values[row.setting_key] = JSON.parse(row.value) as unknown
|
|
19
|
+
} catch {
|
|
20
|
+
continue
|
|
21
|
+
}
|
|
22
|
+
out.set(row.bundle_id, values)
|
|
23
|
+
}
|
|
24
|
+
return out
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** One extension's stored values. */
|
|
28
|
+
async of(bundleId: string): Promise<Record<string, unknown>> {
|
|
29
|
+
return (await this.all()).get(bundleId) ?? {}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Sets one value, or with `undefined` takes it back to its default. */
|
|
33
|
+
async set(bundleId: string, key: string, value: unknown, by: string | null): Promise<void> {
|
|
34
|
+
await this.db.q
|
|
35
|
+
.deleteFrom('extension_setting')
|
|
36
|
+
.where('bundle_id', '=', bundleId)
|
|
37
|
+
.where('setting_key', '=', key)
|
|
38
|
+
.execute()
|
|
39
|
+
if (value === undefined) return
|
|
40
|
+
await this.db.q
|
|
41
|
+
.insertInto('extension_setting')
|
|
42
|
+
.values({
|
|
43
|
+
bundle_id: bundleId,
|
|
44
|
+
setting_key: key,
|
|
45
|
+
value: JSON.stringify(value),
|
|
46
|
+
updated_by: by,
|
|
47
|
+
updated_at: DbDate.toDb(new Date()),
|
|
48
|
+
})
|
|
49
|
+
.execute()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -28,6 +28,10 @@ export interface TransferRun {
|
|
|
28
28
|
/** The npm package the content arrived in, and its version. */
|
|
29
29
|
packageName: string | null
|
|
30
30
|
packageVersion: string | null
|
|
31
|
+
/** A site package's or an extension's (story 306); null for a run before that was recorded. */
|
|
32
|
+
bundleType: 'site' | 'extension' | null
|
|
33
|
+
/** Who signed its bundle, a key's fingerprint or a CI source's repository (story 316); null when nobody did. */
|
|
34
|
+
signedBy?: string | null
|
|
31
35
|
direction: TransferDirection
|
|
32
36
|
revertsRunId: string | null
|
|
33
37
|
schemaStateId: number
|
|
@@ -67,6 +71,8 @@ export class TransferRunRepository {
|
|
|
67
71
|
bundle_label: run.bundleLabel,
|
|
68
72
|
package_name: run.packageName,
|
|
69
73
|
package_version: run.packageVersion,
|
|
74
|
+
bundle_type: run.bundleType,
|
|
75
|
+
signed_by: run.signedBy ?? null,
|
|
70
76
|
direction: run.direction,
|
|
71
77
|
reverts_run_id: run.revertsRunId,
|
|
72
78
|
schema_state_id: run.schemaStateId,
|
|
@@ -134,6 +140,19 @@ export class TransferRunRepository {
|
|
|
134
140
|
return row ? mapRun(row) : undefined
|
|
135
141
|
}
|
|
136
142
|
|
|
143
|
+
/** The versions of a package one signer's bundles brought, in applied imports (story 316). */
|
|
144
|
+
async versionsSignedBy(signer: string, packageName: string): Promise<string[]> {
|
|
145
|
+
const rows = await this.#db.q
|
|
146
|
+
.selectFrom('content_transfer_run')
|
|
147
|
+
.select('package_version')
|
|
148
|
+
.where('direction', '=', 'import')
|
|
149
|
+
.where('status', '=', 'applied')
|
|
150
|
+
.where('signed_by', '=', signer)
|
|
151
|
+
.where('package_name', '=', packageName)
|
|
152
|
+
.execute()
|
|
153
|
+
return rows.flatMap((row) => (row.package_version ? [row.package_version] : []))
|
|
154
|
+
}
|
|
155
|
+
|
|
137
156
|
/** The latest standing import, narrowed by the caller. */
|
|
138
157
|
#standing() {
|
|
139
158
|
return this.#db.q
|
|
@@ -205,6 +224,9 @@ function mapRun(row: Record<string, unknown>): TransferRun {
|
|
|
205
224
|
bundleLabel: (row.bundle_label as string | null) ?? null,
|
|
206
225
|
packageName: (row.package_name as string | null) ?? null,
|
|
207
226
|
packageVersion: (row.package_version as string | null) ?? null,
|
|
227
|
+
bundleType:
|
|
228
|
+
row.bundle_type === 'site' || row.bundle_type === 'extension' ? row.bundle_type : null,
|
|
229
|
+
signedBy: (row.signed_by as string | null) ?? null,
|
|
208
230
|
direction: String(row.direction) as TransferDirection,
|
|
209
231
|
revertsRunId: (row.reverts_run_id as string | null) ?? null,
|
|
210
232
|
schemaStateId: Number(row.schema_state_id),
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The keys and CI sources a site trusts to sign the site bundles it applies
|
|
3
|
+
* (story 316), as an administrator manages them in Settings.
|
|
4
|
+
*/
|
|
5
|
+
import { randomUUID } from 'node:crypto'
|
|
6
|
+
import type { Db } from '../database.ts'
|
|
7
|
+
import { DbDate } from '../dialect.ts'
|
|
8
|
+
|
|
9
|
+
export type TrustedSignerKind = 'user' | 'site' | 'source'
|
|
10
|
+
|
|
11
|
+
export interface TrustedSigner {
|
|
12
|
+
id: string
|
|
13
|
+
kind: TrustedSignerKind
|
|
14
|
+
name: string
|
|
15
|
+
/** A key's public line; null for a CI source. */
|
|
16
|
+
publicKey: string | null
|
|
17
|
+
fingerprint: string | null
|
|
18
|
+
/** A CI source, `org/repo@v*`; null for a key. */
|
|
19
|
+
source: string | null
|
|
20
|
+
addedBy: string | null
|
|
21
|
+
addedAt: Date
|
|
22
|
+
lastSignedAt: Date | null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const map = (row: Record<string, unknown>): TrustedSigner => ({
|
|
26
|
+
id: String(row.id),
|
|
27
|
+
kind: row.kind === 'site' ? 'site' : row.kind === 'source' ? 'source' : 'user',
|
|
28
|
+
name: String(row.name),
|
|
29
|
+
publicKey: (row.public_key as string | null) ?? null,
|
|
30
|
+
fingerprint: (row.fingerprint as string | null) ?? null,
|
|
31
|
+
source: (row.source as string | null) ?? null,
|
|
32
|
+
addedBy: (row.added_by as string | null) ?? null,
|
|
33
|
+
addedAt: DbDate.fromDb(row.added_at) ?? new Date(0),
|
|
34
|
+
lastSignedAt: DbDate.fromDb(row.last_signed_at) ?? null,
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export class TrustedSignerRepository {
|
|
38
|
+
readonly #db: Db
|
|
39
|
+
constructor(db: Db) {
|
|
40
|
+
this.#db = db
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async all(): Promise<TrustedSigner[]> {
|
|
44
|
+
const rows = await this.#db.q
|
|
45
|
+
.selectFrom('trusted_signer')
|
|
46
|
+
.selectAll()
|
|
47
|
+
.orderBy('added_at')
|
|
48
|
+
.execute()
|
|
49
|
+
return rows.map((row) => map(row as Record<string, unknown>))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async add(
|
|
53
|
+
signer: Pick<
|
|
54
|
+
TrustedSigner,
|
|
55
|
+
'kind' | 'name' | 'publicKey' | 'fingerprint' | 'source' | 'addedBy'
|
|
56
|
+
>,
|
|
57
|
+
): Promise<TrustedSigner> {
|
|
58
|
+
const id = randomUUID()
|
|
59
|
+
const now = new Date()
|
|
60
|
+
await this.#db.q
|
|
61
|
+
.insertInto('trusted_signer')
|
|
62
|
+
.values({
|
|
63
|
+
id,
|
|
64
|
+
kind: signer.kind,
|
|
65
|
+
name: signer.name,
|
|
66
|
+
public_key: signer.publicKey,
|
|
67
|
+
fingerprint: signer.fingerprint,
|
|
68
|
+
source: signer.source,
|
|
69
|
+
added_by: signer.addedBy,
|
|
70
|
+
added_at: DbDate.toDb(now),
|
|
71
|
+
})
|
|
72
|
+
.execute()
|
|
73
|
+
return { ...signer, id, addedAt: now, lastSignedAt: null }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async rename(id: string, name: string): Promise<boolean> {
|
|
77
|
+
const result = await this.#db.q
|
|
78
|
+
.updateTable('trusted_signer')
|
|
79
|
+
.set({ name })
|
|
80
|
+
.where('id', '=', id)
|
|
81
|
+
.executeTakeFirst()
|
|
82
|
+
return Number(result.numUpdatedRows) > 0
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async remove(id: string): Promise<boolean> {
|
|
86
|
+
const result = await this.#db.q
|
|
87
|
+
.deleteFrom('trusted_signer')
|
|
88
|
+
.where('id', '=', id)
|
|
89
|
+
.executeTakeFirst()
|
|
90
|
+
return Number(result.numDeletedRows) > 0
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Notes that a signer's bundle was applied, for the list's "last signed". */
|
|
94
|
+
async signed(id: string): Promise<void> {
|
|
95
|
+
await this.#db.q
|
|
96
|
+
.updateTable('trusted_signer')
|
|
97
|
+
.set({ last_signed_at: DbDate.toDb(new Date()) })
|
|
98
|
+
.where('id', '=', id)
|
|
99
|
+
.execute()
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration 066 — what a grant covers beyond the permissions' names (story
|
|
3
|
+
* 308): the origins its `http.outbound` may reach, and whom `actAs` acts for.
|
|
4
|
+
* Nullable: a grant before this one covered neither.
|
|
5
|
+
*/
|
|
6
|
+
import type { Db } from '../database.ts'
|
|
7
|
+
import type { Migration } from '../migrations.ts'
|
|
8
|
+
import { schemaOps } from '../schema-ops.ts'
|
|
9
|
+
import { STATE_TRANSFER_RUN_BUNDLE_TYPE } from './transfer-run-bundle-type.ts'
|
|
10
|
+
|
|
11
|
+
export const STATE_BUNDLE_GRANT_REACH = '{c3e7a512-0066-4f0b-9d61-a8b2c4e60066}'
|
|
12
|
+
|
|
13
|
+
export const bundleGrantReachMigration: Migration = {
|
|
14
|
+
from: STATE_TRANSFER_RUN_BUNDLE_TYPE,
|
|
15
|
+
to: STATE_BUNDLE_GRANT_REACH,
|
|
16
|
+
name: 'AddBundleGrantReach',
|
|
17
|
+
kind: 'expand',
|
|
18
|
+
release: '0.57.0',
|
|
19
|
+
async up(db: Db) {
|
|
20
|
+
const ops = schemaOps(db)
|
|
21
|
+
await ops.addColumn('bundle_grant', 'origins', db.dialect.types.text)
|
|
22
|
+
await ops.addColumn('bundle_grant', 'act_as', db.dialect.types.varchar(80))
|
|
23
|
+
},
|
|
24
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration 068 — what a Bundle Editor definition builds (story 312): an
|
|
3
|
+
* extension for other sites, or a site bundle to move this site. Every
|
|
4
|
+
* definition before it built an extension (story 306).
|
|
5
|
+
*/
|
|
6
|
+
import type { Db } from '../database.ts'
|
|
7
|
+
import type { Migration } from '../migrations.ts'
|
|
8
|
+
import { sql } from '../query.ts'
|
|
9
|
+
import { STATE_EXTENSION_SETTINGS } from './extension-settings.ts'
|
|
10
|
+
|
|
11
|
+
export const STATE_BUNDLE_KIND = '{d4f8b623-0068-4c1a-8e72-b9c3d5f70068}'
|
|
12
|
+
|
|
13
|
+
export const bundleKindMigration: Migration = {
|
|
14
|
+
from: STATE_EXTENSION_SETTINGS,
|
|
15
|
+
to: STATE_BUNDLE_KIND,
|
|
16
|
+
name: 'AddBundleKind',
|
|
17
|
+
kind: 'expand',
|
|
18
|
+
release: '0.57.0',
|
|
19
|
+
async up(db: Db) {
|
|
20
|
+
const t = db.dialect.types
|
|
21
|
+
await db.q.schema
|
|
22
|
+
.alterTable('bundle')
|
|
23
|
+
.addColumn('kind', sql.raw(t.varchar(16)), (c) => c.notNull().defaultTo('extension'))
|
|
24
|
+
.execute()
|
|
25
|
+
},
|
|
26
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration 067 — an extension's settings as an administrator set them in the
|
|
3
|
+
* back office (story 310). The config's values are not kept here: they lock the
|
|
4
|
+
* setting instead. A secret is kept sealed with the site's key.
|
|
5
|
+
*/
|
|
6
|
+
import type { Db } from '../database.ts'
|
|
7
|
+
import type { Migration } from '../migrations.ts'
|
|
8
|
+
import { sql } from '../query.ts'
|
|
9
|
+
import { STATE_BUNDLE_GRANT_REACH } from './bundle-grant-reach.ts'
|
|
10
|
+
|
|
11
|
+
export const STATE_EXTENSION_SETTINGS = '{c3e7a512-0067-4f0b-9d61-a8b2c4e60067}'
|
|
12
|
+
|
|
13
|
+
export const extensionSettingsMigration: Migration = {
|
|
14
|
+
from: STATE_BUNDLE_GRANT_REACH,
|
|
15
|
+
to: STATE_EXTENSION_SETTINGS,
|
|
16
|
+
name: 'AddExtensionSettings',
|
|
17
|
+
kind: 'expand',
|
|
18
|
+
release: '0.57.0',
|
|
19
|
+
async up(db: Db) {
|
|
20
|
+
const t = db.dialect.types
|
|
21
|
+
await db.q.schema
|
|
22
|
+
.createTable('extension_setting')
|
|
23
|
+
.addColumn('bundle_id', sql.raw(t.varchar(64)), (c) => c.notNull())
|
|
24
|
+
.addColumn('setting_key', sql.raw(t.varchar(64)), (c) => c.notNull())
|
|
25
|
+
.addColumn('value', sql.raw(t.text), (c) => c.notNull())
|
|
26
|
+
.addColumn('updated_by', sql.raw(t.varchar(255)))
|
|
27
|
+
.addColumn('updated_at', sql.raw(t.timestamp), (c) => c.notNull())
|
|
28
|
+
.addPrimaryKeyConstraint('pk_extension_setting', ['bundle_id', 'setting_key'])
|
|
29
|
+
.execute()
|
|
30
|
+
},
|
|
31
|
+
}
|
package/src/schema/plan.ts
CHANGED
|
@@ -18,7 +18,9 @@ import { approvalsMigration } from './approvals.ts'
|
|
|
18
18
|
import { assistantMigration } from './assistant.ts'
|
|
19
19
|
import { auditLogMigration } from './audit-log.ts'
|
|
20
20
|
import { bundleComponentsMigration } from './bundle-components.ts'
|
|
21
|
+
import { bundleGrantReachMigration } from './bundle-grant-reach.ts'
|
|
21
22
|
import { bundleGrantsMigration } from './bundle-grants.ts'
|
|
23
|
+
import { bundleKindMigration } from './bundle-kind.ts'
|
|
22
24
|
import { bundlePackageMigration } from './bundle-package.ts'
|
|
23
25
|
import { bundleSchemaPicksMigration } from './bundle-schema-picks.ts'
|
|
24
26
|
import { bundlesDisabledMigration } from './bundles-disabled.ts'
|
|
@@ -37,6 +39,7 @@ import { deliveryMemberTokensMigration } from './delivery-member-tokens.ts'
|
|
|
37
39
|
import { diagnosticsMigration } from './diagnostics.ts'
|
|
38
40
|
import { dropAssistantMigration } from './drop-assistant.ts'
|
|
39
41
|
import { elementsMigration } from './elements.ts'
|
|
42
|
+
import { extensionSettingsMigration } from './extension-settings.ts'
|
|
40
43
|
import { formLibraryMigration } from './form-library.ts'
|
|
41
44
|
import { formPermissionPrefixMigration } from './form-permission-prefix.ts'
|
|
42
45
|
import { formPermissionsMigration } from './form-permissions.ts'
|
|
@@ -69,9 +72,11 @@ import { sinceVersionMigration } from './since-version.ts'
|
|
|
69
72
|
import { siteSearchMigration } from './site-search.ts'
|
|
70
73
|
import { siteSettingsTypesMigration } from './site-settings-types.ts'
|
|
71
74
|
import { transferAnswersMigration } from './transfer-answers.ts'
|
|
75
|
+
import { transferRunBundleTypeMigration } from './transfer-run-bundle-type.ts'
|
|
72
76
|
import { transferRunPackageMigration } from './transfer-run-package.ts'
|
|
73
77
|
import { transferRunsMigration } from './transfer-runs.ts'
|
|
74
78
|
import { trashedDateMigration } from './trashed-date.ts'
|
|
79
|
+
import { trustedSignersMigration } from './trusted-signers.ts'
|
|
75
80
|
import { twoFactorMigration } from './two-factor.ts'
|
|
76
81
|
import { upgradeReportMigration } from './upgrade-report.ts'
|
|
77
82
|
import { usersLocalisationMigration } from './users-localisation.ts'
|
|
@@ -143,4 +148,9 @@ export const cromboloPlan = new MigrationPlan([
|
|
|
143
148
|
mediaTreeOrderMigration,
|
|
144
149
|
searchRemovalsMigration,
|
|
145
150
|
imageAltTextMigration,
|
|
151
|
+
transferRunBundleTypeMigration,
|
|
152
|
+
bundleGrantReachMigration,
|
|
153
|
+
extensionSettingsMigration,
|
|
154
|
+
bundleKindMigration,
|
|
155
|
+
trustedSignersMigration,
|
|
146
156
|
])
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration 065 — a transfer run records what kind of bundle it applied (story
|
|
3
|
+
* 306): a site package, which `site revert` puts back, or an extension's
|
|
4
|
+
* content, which uninstalling it does. Nullable: a run before this one was
|
|
5
|
+
* never asked.
|
|
6
|
+
*/
|
|
7
|
+
import type { Db } from '../database.ts'
|
|
8
|
+
import type { Migration } from '../migrations.ts'
|
|
9
|
+
import { schemaOps } from '../schema-ops.ts'
|
|
10
|
+
import { STATE_IMAGE_ALT_TEXT } from './image-alt-text.ts'
|
|
11
|
+
|
|
12
|
+
export const STATE_TRANSFER_RUN_BUNDLE_TYPE = '{c3e7a512-0065-4f0b-9d61-a8b2c4e60065}'
|
|
13
|
+
|
|
14
|
+
export const transferRunBundleTypeMigration: Migration = {
|
|
15
|
+
from: STATE_IMAGE_ALT_TEXT,
|
|
16
|
+
to: STATE_TRANSFER_RUN_BUNDLE_TYPE,
|
|
17
|
+
name: 'AddTransferRunBundleType',
|
|
18
|
+
kind: 'expand',
|
|
19
|
+
release: '0.57.0',
|
|
20
|
+
async up(db: Db) {
|
|
21
|
+
await schemaOps(db).addColumn(
|
|
22
|
+
'content_transfer_run',
|
|
23
|
+
'bundle_type',
|
|
24
|
+
db.dialect.types.varchar(16),
|
|
25
|
+
)
|
|
26
|
+
},
|
|
27
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration 069 — the keys and CI sources a site trusts to sign the site
|
|
3
|
+
* bundles it applies (story 316), and who signed each applied run's bundle, so
|
|
4
|
+
* an older version from the same signer is refused.
|
|
5
|
+
*/
|
|
6
|
+
import type { Db } from '../database.ts'
|
|
7
|
+
import type { Migration } from '../migrations.ts'
|
|
8
|
+
import { sql } from '../query.ts'
|
|
9
|
+
import { STATE_BUNDLE_KIND } from './bundle-kind.ts'
|
|
10
|
+
|
|
11
|
+
export const STATE_TRUSTED_SIGNERS = '{e5a9c734-0069-4d2b-9f83-cad4e6081069}'
|
|
12
|
+
|
|
13
|
+
export const trustedSignersMigration: Migration = {
|
|
14
|
+
from: STATE_BUNDLE_KIND,
|
|
15
|
+
to: STATE_TRUSTED_SIGNERS,
|
|
16
|
+
name: 'AddTrustedSigners',
|
|
17
|
+
kind: 'expand',
|
|
18
|
+
release: '0.57.0',
|
|
19
|
+
async up(db: Db) {
|
|
20
|
+
const t = db.dialect.types
|
|
21
|
+
await db.q.schema
|
|
22
|
+
.createTable('trusted_signer')
|
|
23
|
+
.addColumn('id', sql.raw(t.varchar(36)), (c) => c.primaryKey())
|
|
24
|
+
.addColumn('kind', sql.raw(t.varchar(16)), (c) => c.notNull())
|
|
25
|
+
.addColumn('name', sql.raw(t.varchar(255)), (c) => c.notNull())
|
|
26
|
+
.addColumn('public_key', sql.raw(t.text))
|
|
27
|
+
.addColumn('fingerprint', sql.raw(t.varchar(64)))
|
|
28
|
+
.addColumn('source', sql.raw(t.varchar(255)))
|
|
29
|
+
.addColumn('added_by', sql.raw(t.varchar(255)))
|
|
30
|
+
.addColumn('added_at', sql.raw(t.timestamp), (c) => c.notNull())
|
|
31
|
+
.addColumn('last_signed_at', sql.raw(t.timestamp))
|
|
32
|
+
.execute()
|
|
33
|
+
await db.q.schema
|
|
34
|
+
.alterTable('content_transfer_run')
|
|
35
|
+
.addColumn('signed_by', sql.raw(t.varchar(255)))
|
|
36
|
+
.execute()
|
|
37
|
+
},
|
|
38
|
+
}
|
package/src/tables.gen.ts
CHANGED
|
@@ -100,6 +100,7 @@ export interface CoreTables {
|
|
|
100
100
|
dictionary_items: string
|
|
101
101
|
element_ids: string | null
|
|
102
102
|
id: string
|
|
103
|
+
kind: Generated<string>
|
|
103
104
|
languages: string
|
|
104
105
|
media_ids: string
|
|
105
106
|
media_load_child_nodes: Bool
|
|
@@ -113,11 +114,13 @@ export interface CoreTables {
|
|
|
113
114
|
update_date: Timestamp
|
|
114
115
|
}
|
|
115
116
|
bundle_grant: {
|
|
117
|
+
act_as: string | null
|
|
116
118
|
bundle_id: string
|
|
117
119
|
disabled_at: Timestamp | null
|
|
118
120
|
disabled_by: string | null
|
|
119
121
|
granted_at: Timestamp
|
|
120
122
|
granted_by: string | null
|
|
123
|
+
origins: string | null
|
|
121
124
|
package_name: string
|
|
122
125
|
permissions: string
|
|
123
126
|
version: string
|
|
@@ -223,6 +226,7 @@ export interface CoreTables {
|
|
|
223
226
|
applied_by: string | null
|
|
224
227
|
bundle_id: string
|
|
225
228
|
bundle_label: string | null
|
|
229
|
+
bundle_type: string | null
|
|
226
230
|
direction: string
|
|
227
231
|
finished_at: Timestamp | null
|
|
228
232
|
id: string
|
|
@@ -231,6 +235,7 @@ export interface CoreTables {
|
|
|
231
235
|
package_version: string | null
|
|
232
236
|
reverts_run_id: string | null
|
|
233
237
|
schema_state_id: number
|
|
238
|
+
signed_by: string | null
|
|
234
239
|
started_at: Timestamp
|
|
235
240
|
status: string
|
|
236
241
|
}
|
|
@@ -367,6 +372,13 @@ export interface CoreTables {
|
|
|
367
372
|
node_id: number
|
|
368
373
|
sort_order: number
|
|
369
374
|
}
|
|
375
|
+
extension_setting: {
|
|
376
|
+
bundle_id: string
|
|
377
|
+
setting_key: string
|
|
378
|
+
updated_at: Timestamp
|
|
379
|
+
updated_by: string | null
|
|
380
|
+
value: string
|
|
381
|
+
}
|
|
370
382
|
external_login: {
|
|
371
383
|
create_date: Timestamp
|
|
372
384
|
id: Generated<number>
|
|
@@ -739,6 +751,17 @@ export interface CoreTables {
|
|
|
739
751
|
target_kind: string
|
|
740
752
|
under_target: string | null
|
|
741
753
|
}
|
|
754
|
+
trusted_signer: {
|
|
755
|
+
added_at: Timestamp
|
|
756
|
+
added_by: string | null
|
|
757
|
+
fingerprint: string | null
|
|
758
|
+
id: string
|
|
759
|
+
kind: string
|
|
760
|
+
last_signed_at: Timestamp | null
|
|
761
|
+
name: string
|
|
762
|
+
public_key: string | null
|
|
763
|
+
source: string | null
|
|
764
|
+
}
|
|
742
765
|
two_factor_login: {
|
|
743
766
|
create_date: Timestamp
|
|
744
767
|
id: Generated<number>
|