@crombolo/data 0.0.0-stage → 0.9.1

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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +69 -0
  3. package/package.json +31 -4
  4. package/src/change-report.ts +166 -0
  5. package/src/cluster.ts +108 -0
  6. package/src/database.ts +121 -0
  7. package/src/dialect.ts +128 -0
  8. package/src/index.ts +60 -0
  9. package/src/locks.ts +103 -0
  10. package/src/maintenance.ts +51 -0
  11. package/src/migrations.ts +431 -0
  12. package/src/node-ref.ts +107 -0
  13. package/src/pending.ts +25 -0
  14. package/src/repositories/bundles.ts +191 -0
  15. package/src/repositories/content-types.ts +831 -0
  16. package/src/repositories/data-types.ts +222 -0
  17. package/src/repositories/dictionary.ts +259 -0
  18. package/src/repositories/documents.ts +2389 -0
  19. package/src/repositories/domains.ts +108 -0
  20. package/src/repositories/folders.ts +120 -0
  21. package/src/repositories/form-entries.ts +314 -0
  22. package/src/repositories/form-workflows.ts +213 -0
  23. package/src/repositories/languages.ts +108 -0
  24. package/src/repositories/log-searches.ts +33 -0
  25. package/src/repositories/members.ts +427 -0
  26. package/src/repositories/nodes.ts +361 -0
  27. package/src/repositories/notifications.ts +54 -0
  28. package/src/repositories/public-access.ts +187 -0
  29. package/src/repositories/redirects.ts +274 -0
  30. package/src/repositories/references.ts +162 -0
  31. package/src/repositories/tags.ts +93 -0
  32. package/src/repositories/templates.ts +114 -0
  33. package/src/repositories/transfer-runs.ts +190 -0
  34. package/src/repositories/user-data.ts +90 -0
  35. package/src/repositories/users.ts +898 -0
  36. package/src/schema/assistant.ts +74 -0
  37. package/src/schema/built-in-content-types.ts +106 -0
  38. package/src/schema/built-in-media-types.ts +335 -0
  39. package/src/schema/built-in-member-types.ts +61 -0
  40. package/src/schema/bundle-components.ts +49 -0
  41. package/src/schema/bundles-rename.ts +32 -0
  42. package/src/schema/change-report.ts +46 -0
  43. package/src/schema/client-id-prefix.ts +43 -0
  44. package/src/schema/content-editing.ts +50 -0
  45. package/src/schema/content-seed.ts +586 -0
  46. package/src/schema/content.ts +263 -0
  47. package/src/schema/created-packages.ts +56 -0
  48. package/src/schema/elements.ts +62 -0
  49. package/src/schema/form-permission-prefix.ts +50 -0
  50. package/src/schema/form-permissions.ts +26 -0
  51. package/src/schema/form-workflows.ts +54 -0
  52. package/src/schema/forms.ts +63 -0
  53. package/src/schema/group-permissions.ts +20 -0
  54. package/src/schema/identity.ts +176 -0
  55. package/src/schema/log-viewer.ts +68 -0
  56. package/src/schema/member-property-type.ts +30 -0
  57. package/src/schema/members.ts +97 -0
  58. package/src/schema/plan.ts +73 -0
  59. package/src/schema/public-access.ts +56 -0
  60. package/src/schema/recycle-bin.ts +21 -0
  61. package/src/schema/redirects.ts +57 -0
  62. package/src/schema/rich-text-ui.ts +34 -0
  63. package/src/schema/seed.ts +298 -0
  64. package/src/schema/server-role.ts +21 -0
  65. package/src/schema/since-version.ts +26 -0
  66. package/src/schema/transfer-runs.ts +71 -0
  67. package/src/schema/upgrade-report.ts +43 -0
  68. package/src/schema/users-localisation.ts +85 -0
  69. package/src/schema/values.ts +108 -0
  70. package/src/schema-ops.ts +35 -0
  71. package/src/schema-state.ts +196 -0
  72. package/README.md +0 -3
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Migration 018 — `upgrade_report` becomes `change_report`: the same stable
3
+ * findings shape, now shared by the pre-upgrade check and content transfer.
4
+ *
5
+ * `source` and `scope` exist because a run resolves whatever it no longer
6
+ * reports. Unscoped, a content check would resolve every open upgrade finding,
7
+ * a development boot would wipe a transfer report on every restart, and
8
+ * checking one bundle would resolve another's. The sweep filters on both.
9
+ *
10
+ * A rename is not expand, and the lint that says so is right in general: the
11
+ * rule keeps the previous release's code able to read an upgraded database.
12
+ * At 0.x there is no deployed node to protect and `upgrade_report` shipped in
13
+ * this same pre-release line, so the exception is taken deliberately here and
14
+ * comes off at 1.0.
15
+ */
16
+ import type { Db } from '../database.ts'
17
+ import type { Migration } from '../migrations.ts'
18
+ import { schemaOps } from '../schema-ops.ts'
19
+ import { STATE_ASSISTANT } from './assistant.ts'
20
+
21
+ export const STATE_CHANGE_REPORT = '{6f1d4a8e-0018-4a3f-9c62-7d5b1e8a3c92}'
22
+
23
+ export const changeReportMigration: Migration = {
24
+ from: STATE_ASSISTANT,
25
+ to: STATE_CHANGE_REPORT,
26
+ name: 'RenameUpgradeReportToChangeReport',
27
+ kind: 'expand',
28
+ release: '0.3.0',
29
+ async up(db: Db) {
30
+ const t = db.dialect.types
31
+ const ops = schemaOps(db)
32
+ await ops.renameTable('upgrade_report', 'change_report')
33
+ // Both dialects keep an index across a table rename, under its old name.
34
+ await ops.dropIndex('ix_upgrade_report_subject', 'change_report')
35
+ await ops.addColumn('change_report', 'source', `${t.varchar(20)} NOT NULL DEFAULT 'upgrade'`)
36
+ await ops.addColumn('change_report', 'scope', t.varchar(64))
37
+ await ops.addIndex('ix_change_report_subject', 'change_report', [
38
+ 'source',
39
+ 'scope',
40
+ 'code',
41
+ 'subject_key',
42
+ 'property_alias',
43
+ 'culture',
44
+ ])
45
+ },
46
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Migration 020 — API-user client IDs carry crombolo's own prefix.
3
+ *
4
+ * The prefix exists so an API user's client ID cannot collide with the
5
+ * backoffice client's own, which is `umbraco-back-office` and is not ours to
6
+ * rename: the vendored client sends it on every authorize call. The API-user
7
+ * prefix *is* ours, and it put Umbraco's name on a string administrators type
8
+ * and paste into their own integration config.
9
+ *
10
+ * Only the ID moves. `secret_hash` is untouched, so an existing credential
11
+ * keeps working once the caller sends the new ID — no secret has to be
12
+ * re-issued.
13
+ *
14
+ * The two prefixes are spelled out rather than imported. A migration has to
15
+ * describe what it did on the day it ran, and a constant someone later edits
16
+ * would quietly rewrite history.
17
+ */
18
+ import type { Db } from '../database.ts'
19
+ import type { Migration } from '../migrations.ts'
20
+ import { STATE_TRANSFER_RUNS } from './transfer-runs.ts'
21
+
22
+ export const STATE_CLIENT_ID_PREFIX = '{6f1d4a8e-0020-4b7d-8e41-6c2a9f3d5e84}'
23
+
24
+ const OLD_PREFIX = 'umbraco-back-office-'
25
+ const NEW_PREFIX = 'crombolo-back-office-'
26
+
27
+ export const clientIdPrefixMigration: Migration = {
28
+ from: STATE_TRANSFER_RUNS,
29
+ to: STATE_CLIENT_ID_PREFIX,
30
+ name: 'RenameClientIdPrefix',
31
+ kind: 'expand',
32
+ release: '0.3.0',
33
+ async up(db: Db) {
34
+ // `client_id` is the primary key and nothing references it, so this is an
35
+ // update in place. SUBSTR is 1-based in both dialects.
36
+ await db.exec(
37
+ `UPDATE user_client_credential
38
+ SET client_id = ? || SUBSTR(client_id, ?)
39
+ WHERE client_id LIKE ?`,
40
+ [NEW_PREFIX, OLD_PREFIX.length + 1, `${OLD_PREFIX}%`],
41
+ )
42
+ },
43
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Migration 010 — what the document action menu stores beyond versions:
3
+ * scheduled publishing (Umbraco's `umbracoContentSchedule`), per-user
4
+ * notification subscriptions (`umbracoUser2NodeNotify`) and culture and
5
+ * hostnames (`umbracoDomain`), snake-cased.
6
+ */
7
+ import type { Db } from '../database.ts'
8
+ import type { Migration } from '../migrations.ts'
9
+ import { STATE_RICH_TEXT_UI } from './rich-text-ui.ts'
10
+
11
+ export const STATE_CONTENT_EDITING = '{6f1d4a8e-0010-4c21-9d3a-8b1e5c7a2f10}'
12
+
13
+ export const contentEditingMigration: Migration = {
14
+ from: STATE_RICH_TEXT_UI,
15
+ to: STATE_CONTENT_EDITING,
16
+ name: 'AddContentEditingTables',
17
+ kind: 'expand',
18
+ release: '0.3.0',
19
+ async up(db: Db) {
20
+ const t = db.dialect.types
21
+ await db.exec(
22
+ `CREATE TABLE content_schedule (
23
+ id ${t.identity},
24
+ node_id ${t.integer} NOT NULL REFERENCES node (id),
25
+ language_id ${t.integer} NULL REFERENCES language (id),
26
+ action ${t.varchar(16)} NOT NULL,
27
+ date ${t.timestamp} NOT NULL
28
+ )`,
29
+ )
30
+ await db.exec('CREATE INDEX ix_content_schedule_date ON content_schedule (date)')
31
+ await db.exec(
32
+ `CREATE TABLE user_notification (
33
+ user_id ${t.integer} NOT NULL REFERENCES user_account (id),
34
+ node_id ${t.integer} NOT NULL REFERENCES node (id),
35
+ action ${t.varchar(64)} NOT NULL,
36
+ PRIMARY KEY (user_id, node_id, action)
37
+ )`,
38
+ )
39
+ await db.exec(
40
+ `CREATE TABLE domain (
41
+ id ${t.identity},
42
+ node_id ${t.integer} NOT NULL REFERENCES node (id),
43
+ language_id ${t.integer} NULL REFERENCES language (id),
44
+ domain_name ${t.textCi} NOT NULL,
45
+ sort_order ${t.integer} NOT NULL
46
+ )`,
47
+ )
48
+ await db.exec('CREATE UNIQUE INDEX ix_domain_name ON domain (domain_name)')
49
+ },
50
+ }