@crombolo/data 0.25.0 → 0.26.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/data",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "SQLite and Postgres storage for crombolo: schema, migrations and repositories.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",
@@ -28,6 +28,6 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@crombolo/core": "0.25.0"
31
+ "@crombolo/core": "0.26.0"
32
32
  }
33
33
  }
@@ -5,7 +5,7 @@
5
5
  * contract only in a major, and only removing what an earlier release added.
6
6
  * `docs/bundles.md`, Part 4.
7
7
  */
8
- import { isMajorRelease } from '../migrations.ts'
8
+ import { mayShipContract } from '../migrations.ts'
9
9
  import {
10
10
  type ColumnSpec,
11
11
  type Op,
@@ -424,9 +424,9 @@ export function compileBundleTables(tables: BundleTables, version?: string): Com
424
424
  const problem = apply(working, op, step)
425
425
  if (problem) problems.push(problem)
426
426
  }
427
- if (kind === 'contract' && !isMajorRelease(step.release))
427
+ if (kind === 'contract' && !mayShipContract(step.release))
428
428
  problems.push(
429
- `${label} removes something in ${step.release}, but a contract may only ship in a major release of the bundle (x.0.0)`,
429
+ `${label} removes something in ${step.release}, but from the bundle's 1.0 a contract may only ship in one of its major releases (x.0.0)`,
430
430
  )
431
431
  schema = working
432
432
 
package/src/index.ts CHANGED
@@ -63,6 +63,7 @@ export * from './schema/content-seed.ts'
63
63
  export * from './schema/created-packages.ts'
64
64
  export * from './schema/delivery-member-tokens.ts'
65
65
  export * from './schema/diagnostics.ts'
66
+ export * from './schema/drop-assistant.ts'
66
67
  export * from './schema/elements.ts'
67
68
  export * from './schema/form-permission-prefix.ts'
68
69
  export * from './schema/group-permissions.ts'
package/src/migrations.ts CHANGED
@@ -86,6 +86,16 @@ export function isMajorRelease(release: string): boolean {
86
86
  return major >= 1 && minor === 0 && patch === 0
87
87
  }
88
88
 
89
+ /**
90
+ * Whether a release may carry a contract: any release before 1.0, where
91
+ * breaking changes are allowed, and from then on only a major (`x.0.0`), since
92
+ * minors and patches are rolled under live nodes and must only add.
93
+ */
94
+ export function mayShipContract(release: string): boolean {
95
+ const [major = 0] = release.split(/[.+-]/).map(Number)
96
+ return major === 0 || isMajorRelease(release)
97
+ }
98
+
89
99
  export class MigrationPlan {
90
100
  readonly migrations: readonly Migration[]
91
101
  readonly stateKey: string
@@ -123,9 +133,9 @@ export class MigrationPlan {
123
133
  throw new Error(
124
134
  `Contract migration '${migration.name}' (${migration.release}) may only remove what an earlier release added; '${expand.name}' is ${expand.release}.`,
125
135
  )
126
- if (!isMajorRelease(migration.release))
136
+ if (!mayShipContract(migration.release))
127
137
  throw new Error(
128
- `Contract migration '${migration.name}' ships in ${migration.release}, but a contract may only ship in a major release (x.0.0): minors and patches are rolled under live nodes and must only add.`,
138
+ `Contract migration '${migration.name}' ships in ${migration.release}, but from 1.0 a contract may only ship in a major release (x.0.0): minors and patches are rolled under live nodes and must only add.`,
129
139
  )
130
140
  }
131
141
  seen.set(migration.name, migration)
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Migration 048 — the AI assistant leaves the CMS (story 179), and its
3
+ * changesets with it. Migration 017 created the two tables and stays in the
4
+ * chain as history. `IF EXISTS`, so a replay is harmless.
5
+ */
6
+ import type { Db } from '../database.ts'
7
+ import type { Migration } from '../migrations.ts'
8
+ import { STATE_CONTENT_CHECKPOINT } from './content-checkpoint.ts'
9
+
10
+ export const STATE_DROP_ASSISTANT = '{9c4a1e72-0048-4b5d-8e26-7f3d1a9c5b48}'
11
+
12
+ export const dropAssistantMigration: Migration = {
13
+ from: STATE_CONTENT_CHECKPOINT,
14
+ to: STATE_DROP_ASSISTANT,
15
+ name: 'DropAssistantTables',
16
+ kind: 'contract',
17
+ contracts: 'AddAssistantChangesets',
18
+ release: '0.26.0',
19
+ async up(db: Db) {
20
+ await db.exec('DROP TABLE IF EXISTS assistant_change')
21
+ await db.exec('DROP TABLE IF EXISTS assistant_changeset')
22
+ },
23
+ }
@@ -30,6 +30,7 @@ import { contentNotificationsMigration } from './content-notifications.ts'
30
30
  import { createdPackagesMigration } from './created-packages.ts'
31
31
  import { deliveryMemberTokensMigration } from './delivery-member-tokens.ts'
32
32
  import { diagnosticsMigration } from './diagnostics.ts'
33
+ import { dropAssistantMigration } from './drop-assistant.ts'
33
34
  import { elementsMigration } from './elements.ts'
34
35
  import { formPermissionPrefixMigration } from './form-permission-prefix.ts'
35
36
  import { formPermissionsMigration } from './form-permissions.ts'
@@ -109,4 +110,5 @@ export const cromboloPlan = new MigrationPlan([
109
110
  mediaPermissionsMigration,
110
111
  contentEventsMigration,
111
112
  contentCheckpointMigration,
113
+ dropAssistantMigration,
112
114
  ])
@@ -10,7 +10,7 @@
10
10
  * `content_transfer_change` holds, per node, the event the node was at before
11
11
  * the run and the published event it was serving — which is exactly what
12
12
  * "restore the previously-live state" means. Shape follows
13
- * `assistant_changeset`/`assistant_change`: a header with its items.
13
+ * migration 017's changesets: a header with its items.
14
14
  */
15
15
  import type { Db } from '../database.ts'
16
16
  import type { Migration } from '../migrations.ts'