@marinoscar/platform-db 0.0.0-stage → 0.1.0-next.11

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 (244) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/LICENSE +21 -0
  3. package/README.md +525 -2
  4. package/bin/platform.js +28 -0
  5. package/dist/baseline/deps.d.ts +32 -0
  6. package/dist/baseline/deps.d.ts.map +1 -0
  7. package/dist/baseline/deps.js +66 -0
  8. package/dist/baseline/deps.js.map +1 -0
  9. package/dist/baseline/errors.d.ts +36 -0
  10. package/dist/baseline/errors.d.ts.map +1 -0
  11. package/dist/baseline/errors.js +23 -0
  12. package/dist/baseline/errors.js.map +1 -0
  13. package/dist/baseline/fs.d.ts +9 -0
  14. package/dist/baseline/fs.d.ts.map +1 -0
  15. package/dist/baseline/fs.js +39 -0
  16. package/dist/baseline/fs.js.map +1 -0
  17. package/dist/baseline/index.d.ts +8 -0
  18. package/dist/baseline/index.d.ts.map +1 -0
  19. package/dist/baseline/index.js +24 -0
  20. package/dist/baseline/index.js.map +1 -0
  21. package/dist/baseline/mapping.d.ts +43 -0
  22. package/dist/baseline/mapping.d.ts.map +1 -0
  23. package/dist/baseline/mapping.js +80 -0
  24. package/dist/baseline/mapping.js.map +1 -0
  25. package/dist/baseline/normalise.d.ts +42 -0
  26. package/dist/baseline/normalise.d.ts.map +1 -0
  27. package/dist/baseline/normalise.js +133 -0
  28. package/dist/baseline/normalise.js.map +1 -0
  29. package/dist/baseline/plan.d.ts +66 -0
  30. package/dist/baseline/plan.d.ts.map +1 -0
  31. package/dist/baseline/plan.js +105 -0
  32. package/dist/baseline/plan.js.map +1 -0
  33. package/dist/baseline/report.d.ts +127 -0
  34. package/dist/baseline/report.d.ts.map +1 -0
  35. package/dist/baseline/report.js +89 -0
  36. package/dist/baseline/report.js.map +1 -0
  37. package/dist/baseline/run.d.ts +117 -0
  38. package/dist/baseline/run.d.ts.map +1 -0
  39. package/dist/baseline/run.js +358 -0
  40. package/dist/baseline/run.js.map +1 -0
  41. package/dist/bin/db-commands.d.ts +31 -0
  42. package/dist/bin/db-commands.d.ts.map +1 -0
  43. package/dist/bin/db-commands.js +311 -0
  44. package/dist/bin/db-commands.js.map +1 -0
  45. package/dist/bin/fs-io.d.ts +7 -0
  46. package/dist/bin/fs-io.d.ts.map +1 -0
  47. package/dist/bin/fs-io.js +45 -0
  48. package/dist/bin/fs-io.js.map +1 -0
  49. package/dist/bin/platform.d.ts +21 -0
  50. package/dist/bin/platform.d.ts.map +1 -0
  51. package/dist/bin/platform.js +99 -0
  52. package/dist/bin/platform.js.map +1 -0
  53. package/dist/compose/api.d.ts +84 -0
  54. package/dist/compose/api.d.ts.map +1 -0
  55. package/dist/compose/api.js +101 -0
  56. package/dist/compose/api.js.map +1 -0
  57. package/dist/compose/compose.d.ts +51 -0
  58. package/dist/compose/compose.d.ts.map +1 -0
  59. package/dist/compose/compose.js +177 -0
  60. package/dist/compose/compose.js.map +1 -0
  61. package/dist/compose/diff.d.ts +7 -0
  62. package/dist/compose/diff.d.ts.map +1 -0
  63. package/dist/compose/diff.js +68 -0
  64. package/dist/compose/diff.js.map +1 -0
  65. package/dist/compose/errors.d.ts +31 -0
  66. package/dist/compose/errors.d.ts.map +1 -0
  67. package/dist/compose/errors.js +35 -0
  68. package/dist/compose/errors.js.map +1 -0
  69. package/dist/compose/index.d.ts +3 -0
  70. package/dist/compose/index.d.ts.map +1 -0
  71. package/dist/compose/index.js +11 -0
  72. package/dist/compose/index.js.map +1 -0
  73. package/dist/compose/parse.d.ts +65 -0
  74. package/dist/compose/parse.d.ts.map +1 -0
  75. package/dist/compose/parse.js +122 -0
  76. package/dist/compose/parse.js.map +1 -0
  77. package/dist/drift/app-objects.d.ts +107 -0
  78. package/dist/drift/app-objects.d.ts.map +1 -0
  79. package/dist/drift/app-objects.js +193 -0
  80. package/dist/drift/app-objects.js.map +1 -0
  81. package/dist/drift/db-conformance.d.ts +52 -0
  82. package/dist/drift/db-conformance.d.ts.map +1 -0
  83. package/dist/drift/db-conformance.js +89 -0
  84. package/dist/drift/db-conformance.js.map +1 -0
  85. package/dist/drift/index.d.ts +8 -0
  86. package/dist/drift/index.d.ts.map +1 -0
  87. package/dist/drift/index.js +43 -0
  88. package/dist/drift/index.js.map +1 -0
  89. package/dist/drift/raw-sql-indexes.d.ts +106 -0
  90. package/dist/drift/raw-sql-indexes.d.ts.map +1 -0
  91. package/dist/drift/raw-sql-indexes.js +113 -0
  92. package/dist/drift/raw-sql-indexes.js.map +1 -0
  93. package/dist/drift/raw-sql-tripwire.d.ts +191 -0
  94. package/dist/drift/raw-sql-tripwire.d.ts.map +1 -0
  95. package/dist/drift/raw-sql-tripwire.js +422 -0
  96. package/dist/drift/raw-sql-tripwire.js.map +1 -0
  97. package/dist/drift/rls-policies.d.ts +226 -0
  98. package/dist/drift/rls-policies.d.ts.map +1 -0
  99. package/dist/drift/rls-policies.js +317 -0
  100. package/dist/drift/rls-policies.js.map +1 -0
  101. package/dist/drift/run.d.ts +152 -0
  102. package/dist/drift/run.d.ts.map +1 -0
  103. package/dist/drift/run.js +252 -0
  104. package/dist/drift/run.js.map +1 -0
  105. package/dist/drift/sql-expression.d.ts +27 -0
  106. package/dist/drift/sql-expression.d.ts.map +1 -0
  107. package/dist/drift/sql-expression.js +64 -0
  108. package/dist/drift/sql-expression.js.map +1 -0
  109. package/dist/index.d.ts +16 -0
  110. package/dist/index.d.ts.map +1 -0
  111. package/dist/index.js +33 -0
  112. package/dist/index.js.map +1 -0
  113. package/dist/lock/hash.d.ts +13 -0
  114. package/dist/lock/hash.d.ts.map +1 -0
  115. package/dist/lock/hash.js +19 -0
  116. package/dist/lock/hash.js.map +1 -0
  117. package/dist/lock/index.d.ts +5 -0
  118. package/dist/lock/index.d.ts.map +1 -0
  119. package/dist/lock/index.js +20 -0
  120. package/dist/lock/index.js.map +1 -0
  121. package/dist/lock/lock.d.ts +154 -0
  122. package/dist/lock/lock.d.ts.map +1 -0
  123. package/dist/lock/lock.js +151 -0
  124. package/dist/lock/lock.js.map +1 -0
  125. package/dist/lock/manifest.d.ts +68 -0
  126. package/dist/lock/manifest.d.ts.map +1 -0
  127. package/dist/lock/manifest.js +96 -0
  128. package/dist/lock/manifest.js.map +1 -0
  129. package/dist/lock/semver.d.ts +10 -0
  130. package/dist/lock/semver.d.ts.map +1 -0
  131. package/dist/lock/semver.js +13 -0
  132. package/dist/lock/semver.js.map +1 -0
  133. package/dist/seed/index.d.ts +5 -0
  134. package/dist/seed/index.d.ts.map +1 -0
  135. package/dist/seed/index.js +16 -0
  136. package/dist/seed/index.js.map +1 -0
  137. package/dist/seed/input.d.ts +52 -0
  138. package/dist/seed/input.d.ts.map +1 -0
  139. package/dist/seed/input.js +77 -0
  140. package/dist/seed/input.js.map +1 -0
  141. package/dist/seed/seed-platform.d.ts +41 -0
  142. package/dist/seed/seed-platform.d.ts.map +1 -0
  143. package/dist/seed/seed-platform.js +165 -0
  144. package/dist/seed/seed-platform.js.map +1 -0
  145. package/dist/seed/steps.d.ts +172 -0
  146. package/dist/seed/steps.d.ts.map +1 -0
  147. package/dist/seed/steps.js +136 -0
  148. package/dist/seed/steps.js.map +1 -0
  149. package/dist/seed/types.d.ts +287 -0
  150. package/dist/seed/types.d.ts.map +1 -0
  151. package/dist/seed/types.js +5 -0
  152. package/dist/seed/types.js.map +1 -0
  153. package/dist/sync/app-migrations.d.ts +52 -0
  154. package/dist/sync/app-migrations.d.ts.map +1 -0
  155. package/dist/sync/app-migrations.js +62 -0
  156. package/dist/sync/app-migrations.js.map +1 -0
  157. package/dist/sync/apply.d.ts +29 -0
  158. package/dist/sync/apply.d.ts.map +1 -0
  159. package/dist/sync/apply.js +38 -0
  160. package/dist/sync/apply.js.map +1 -0
  161. package/dist/sync/check.d.ts +59 -0
  162. package/dist/sync/check.d.ts.map +1 -0
  163. package/dist/sync/check.js +115 -0
  164. package/dist/sync/check.js.map +1 -0
  165. package/dist/sync/errors.d.ts +32 -0
  166. package/dist/sync/errors.d.ts.map +1 -0
  167. package/dist/sync/errors.js +23 -0
  168. package/dist/sync/errors.js.map +1 -0
  169. package/dist/sync/index.d.ts +10 -0
  170. package/dist/sync/index.d.ts.map +1 -0
  171. package/dist/sync/index.js +27 -0
  172. package/dist/sync/index.js.map +1 -0
  173. package/dist/sync/ledger.d.ts +65 -0
  174. package/dist/sync/ledger.d.ts.map +1 -0
  175. package/dist/sync/ledger.js +49 -0
  176. package/dist/sync/ledger.js.map +1 -0
  177. package/dist/sync/plan.d.ts +63 -0
  178. package/dist/sync/plan.d.ts.map +1 -0
  179. package/dist/sync/plan.js +86 -0
  180. package/dist/sync/plan.js.map +1 -0
  181. package/dist/sync/promote.d.ts +62 -0
  182. package/dist/sync/promote.d.ts.map +1 -0
  183. package/dist/sync/promote.js +95 -0
  184. package/dist/sync/promote.js.map +1 -0
  185. package/dist/sync/timestamps.d.ts +41 -0
  186. package/dist/sync/timestamps.d.ts.map +1 -0
  187. package/dist/sync/timestamps.js +68 -0
  188. package/dist/sync/timestamps.js.map +1 -0
  189. package/dist/sync/version.d.ts +28 -0
  190. package/dist/sync/version.d.ts.map +1 -0
  191. package/dist/sync/version.js +66 -0
  192. package/dist/sync/version.js.map +1 -0
  193. package/migrations/0001_initial/migration.sql +297 -0
  194. package/migrations/0002_add_personal_access_tokens/migration.sql +31 -0
  195. package/migrations/0003_add_credentials/migration.sql +20 -0
  196. package/migrations/0004_add_notification_deliveries/migration.sql +27 -0
  197. package/migrations/0005_drop_stale_uuid_defaults/migration.sql +35 -0
  198. package/migrations/0006_add_notifications/migration.sql +22 -0
  199. package/migrations/0007_add_push_subscriptions/migration.sql +25 -0
  200. package/migrations/0008_add_jobs/migration.sql +110 -0
  201. package/migrations/0009_add_worker_nodes/migration.sql +90 -0
  202. package/migrations/0010_add_database_backup_runs/migration.sql +104 -0
  203. package/migrations/0011_add_notification_broadcasts/migration.sql +57 -0
  204. package/migrations/0012_add_backup_run_job_link/migration.sql +87 -0
  205. package/migrations/0013_add_job_node_secrets/migration.sql +61 -0
  206. package/migrations/0014_add_backup_run_pg_dump_version/migration.sql +26 -0
  207. package/migrations/0015_add_job_claim_token/migration.sql +92 -0
  208. package/migrations/0016_add_ai_platform/migration.sql +108 -0
  209. package/migrations/0017_revoke_viewer_ai_use/migration.sql +32 -0
  210. package/migrations/0018_add_user_credentials/migration.sql +29 -0
  211. package/migrations/0019_add_device_session_credential_link/migration.sql +52 -0
  212. package/migrations/0020_add_worker_node_vitals/migration.sql +3 -0
  213. package/migrations/0021_add_job_trace_context/migration.sql +6 -0
  214. package/migrations/0022_add_retention_created_at_indexes/migration.sql +13 -0
  215. package/migrations/0023_add_organizations/migration.sql +142 -0
  216. package/migrations/0024_split_system_org_roles/migration.sql +131 -0
  217. package/migrations/0025_org_scoped_rls/migration.sql +215 -0
  218. package/migrations/0026_add_groups/migration.sql +165 -0
  219. package/migrations/0027_add_grants/migration.sql +117 -0
  220. package/migrations/0028_add_org_settings/migration.sql +49 -0
  221. package/migrations/0029_add_org_credentials/migration.sql +54 -0
  222. package/migrations/0030_add_jobs_org_id/migration.sql +18 -0
  223. package/migrations/0031_add_jobs_org_id_status_index/migration.sql +6 -0
  224. package/migrations/0032_add_broadcast_target_org/migration.sql +21 -0
  225. package/migrations/0033_add_android_app/migration.sql +60 -0
  226. package/migrations/0034_open_job_reason/migration.sql +16 -0
  227. package/migrations/0035_ai_usage_feature/migration.sql +37 -0
  228. package/migrations/0036_add_app_metadata/migration.sql +49 -0
  229. package/migrations/0037_open_sharing_vocabularies/migration.sql +97 -0
  230. package/migrations/manifest.json +379 -0
  231. package/package.json +78 -4
  232. package/raw-sql-indexes.json +94 -0
  233. package/rls-policies.json +74 -0
  234. package/schema/ai.prisma +444 -0
  235. package/schema/android-app.prisma +47 -0
  236. package/schema/base.prisma +11 -0
  237. package/schema/credentials.prisma +170 -0
  238. package/schema/db-backup.prisma +376 -0
  239. package/schema/identity.prisma +439 -0
  240. package/schema/jobs.prisma +760 -0
  241. package/schema/notifications.prisma +649 -0
  242. package/schema/settings.prisma +60 -0
  243. package/schema/sharing.prisma +223 -0
  244. package/schema/storage.prisma +84 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,88 @@
1
+ # @marinoscar/platform-db
2
+
3
+ ## 0.1.0-next.11
4
+
5
+ ## 0.1.0-next.10
6
+
7
+ ## 0.1.0-next.9
8
+
9
+ ## 0.1.0-next.8
10
+
11
+ ## 0.1.0-next.7
12
+
13
+ ## 0.1.0-next.6
14
+
15
+ ## 0.1.0-next.5
16
+
17
+ ## 0.1.0-next.4
18
+
19
+ ### Minor Changes
20
+
21
+ - a426fd8: Open the AI capability and operation vocabularies, add a custom-operation port, richer transcription results and per-feature usage (PP-14.17). API: `registerAiCapability` and `registerAiOperation` (the 14 built-in capabilities and the usage operations register through them; `AiCapability` and `AiUsageOperation` become `Builtin | (string & {})`; `AI_CAPABILITIES` stays as a deprecated alias of `BUILTIN_AI_CAPABILITIES`); `AiProviderAdapter.operations` and `AiService.forUser(...).run(operationId, input)` run an app's operation through the same gate pipeline as a built-in port (kill switch, schema-validated input and output, model and capability gates, key policy, rate limits, one usage row, one span), never logging or recording its input or output and refusing an output or an error that carries the key; `AiTranscriptionResult.extras` (speaker-labelled segments, language and any JSON, at most 64 KiB, dropped when malformed) reaches the run output, and a transcription's `providerOptions` is bounded to 4 KiB and never logged; `GET /api/admin/ai/capabilities` (`ai_config:read`) lists the vocabularies; the usage reports take a `feature` filter and group by `feature` and `operation`; `AiModule.forRoot({ pricing })` binds the `AI_PRICING` port and the admin and organization reports then carry `priced` and a `cost` per bucket. The provider conformance kit gains `operations.*` scenarios, `FakeAiProvider` gains `operations` and `transcriptionExtras`, and `ai-secret-egress` covers the new route and fields. Contract: `AI_CAPABILITY_ID_PATTERN`, `AI_OPERATION_ID_PATTERN`, `AI_FEATURE_ID_PATTERN` and the capability, operation and cost schemas. Web: `registerAiPlaygroundMode` (subpath `/ai/ui/playground-modes`; the six built-in modes register through it, DOM unchanged; the fixed `AI_PLAYGROUND_MODES` tuple and `AiModePlaceholder` are removed), `useAiCapabilities` and `registerAiCapabilityLabel` (the Models page filter and the override dialog list an app's capabilities), Feature and Operation breakdowns, a Cost tile and column on a priced usage report, and speaker-labelled transcripts. DB: migration `0035_ai_usage_feature` adds the nullable `feature` column to `ai_usage_events` and `ai_runs` and the `(org_id, feature, created_at)` index on usage (both tables are row-level-security tables, so the migration runs in the `app.rls_bypass` transaction form); apply it with `npm run db:sync`, then `prisma:migrate`. Back-compat: every existing route, shape and id is unchanged; rows written before the column have no feature. The OpenAPI document shows a pattern where the models list's `capability` query and a provider's `supportedCapabilities` showed an enum.
22
+ - deeb8b5: Add the notifications slice: `@marinoscar/platform-api/notifications` (`NotificationsModule.forRoot`, the event, channel and template registries with open channel ids and `registerNotificationChannel`, `NotificationsService` with org-aware policy, the `notifications` system namespace with an org layer that only tightens, runtime Web Push (VAPID) configuration on `SystemSettingsRowStore`, broadcasts with `targetOrgId` and the org-scoped `org_broadcasts:*` pair, the SSE stream on `NOTIFICATIONS_EVENT_BUS`, the email channel forwarding template attachments, the `notifications` conformance suite at `/notifications/testing`), `@Auth({ anyPermissions })` in the identity slice, a `SystemSettingsRowStore` row key that admits camelCase (`webPush`), `@marinoscar/platform-contract/notifications` (the wire shapes, `BROADCAST_CHUNK_SIZE`), `@marinoscar/platform-web/notifications/{headless,ui}` (`configureNotificationsWeb`, `NotificationProvider`, `usePushSubscriptionSync`, `NotificationBell` with slots, the banner and the four pages, the service-worker helpers `registerNotificationServiceWorkerHandlers`, `handlePushEvent`, `handleNotificationClick`, `handlePushSubscriptionChange`), any-of card permissions in the settings hub (`SettingsCardDef.permission: string | readonly string[]`, `cardPermissionGranted`), and the platform migration `0032_add_broadcast_target_org` (`notification_broadcasts.target_org_id`).
23
+ - da8a6f2: Add the `android-app` fragment (`AndroidAppRelease`, `sizeBytes` BigInt), `push_subscriptions.platform` and platform migration `0033_add_android_app` with the raw-SQL partial unique index `android_app_releases_one_current_uniq_idx` (listed in `raw-sql-indexes.json`) (#746).
24
+ - 1822636: App metadata on users and organizations, more extensible models, offline checks for app indexes and policies, and a seed hook (PP-14.27). DB: migration `0036_add_app_metadata` adds `metadata JSONB NOT NULL DEFAULT '{}'` to `users` and `organizations` (each with a CHECK that the document is an object of at most 32 KiB of `jsonb` text, a backstop to the writer's 16 KiB) and a unique `(id, org_id)` key on `ai_runs` and `grants`, the target of a composite foreign key from an org-owned app table (the migration runs in the `app.rls_bypass` transaction form because both are row-level-security tables); apply it with `npm run db:sync`, then `prisma:migrate`. `Role`, `Notification`, `NotificationDelivery`, `Credential` (non-secret relations only), `AiRun` and `Grant` become `// @extensible` (a back-relation changes no SQL); `Permission` stays closed, with the reason documented. `runDbConformance({ appRoot })` gains `app-schema-objects` (every `rawSqlIndexes` and `rlsPolicies` entry of `platform.lock` is created by an app migration and dropped by none, an index definition agrees with the SQL, an unlisted partial or expression index or policy fails; the package's own entries are read, not judged) and `app-migrations`; a `rlsPolicies` lock entry gains optional `usingSha256` and `checkSha256` (`normaliseSqlExpression`, `sqlExpressionSha256`, `platform db policies` prints them), so a weakened policy is caught without a database; `platform db sync` and `platform db check` refuse an app migration named like a package migration (`APP_MIGRATION_ID_COLLISION`) or added after the last sync with a timestamp before an installed platform migration (`APP_MIGRATION_OUT_OF_ORDER`; the lock records the app directories seen at the last sync in `appMigrations`). New exports: `checkAppSchemaObjects`, `assertAppSchemaObjects`, `readAppMigrations`, `scanAllIndexes`, `checkAppMigrations`, `LockRlsPolicy`. Seed: `seedPlatform(prisma, input, { log?, extras? })` runs `SeedStep { id, run(tx, ctx) }` steps after the platform's own, each in a transaction when the client has one, under the same log, validated before any write; `assertSeedIdempotent` proves a second run creates 0; a bare `SeedLogger` third argument still works and the five fixed seed tables are unchanged. API: `registerUserMetadataSchema` and `registerOrganizationMetadataSchema` (a closed zod object per namespace; secret-named fields and open shapes are refused at registration, secret-named keys and a document over 16 KiB at write) and the injectable `IdentityMetadataService` (`get`, `set`, `update` under a row lock, `delete`; users and organizations); no platform route returns the document. Back-compat: no existing table, column, route or response changes; the OpenAPI document is unchanged. A lock written before `appMigrations` skips the ordering rule until its next sync; an app with an unlisted partial index or policy now fails `app-schema-objects` until it lists them in `platform.lock`.
25
+ - f9737d4: Jobs carry their organization (#734): `Job.orgId` (`jobs.org_id`, nullable, FK `organizations(id)` `ON DELETE SET NULL`; NULL is a deployment-wide system job) and `Organization.jobs` in the `jobs` fragment. Migration `0030_add_jobs_org_id` adds the column (metadata-only) and the foreign key (`NOT VALID`, then `VALIDATE`); `0031_add_jobs_org_id_status_index` builds `jobs_org_id_status_idx` `(org_id, status)` `CONCURRENTLY`, alone in its migration. No row-level security on `jobs`, and `jobs_active_dedup_uniq_idx` is unchanged.
26
+ - 10ac7be: Add `OrgCredential` (`org_credentials`) to the `credentials` fragment (#735): an organization's own encrypted credentials, addressed by `(org_id, purpose, name)`, cascading with the organization, the last editor kept as provenance (SetNull). Migration `0029_add_org_credentials` creates the table with the FORCEd `org_credentials_org_isolation` row-level-security policy (listed in `RLS_POLICIES`).
27
+ - 42151ac: Put `org_id` on the tenant-scoped tables and turn row-level security on (#725, platform migration `0025_org_scoped_rls`). `storage_objects`, `storage_object_chunks` and `ai_runs` get a NOT NULL `org_id` (foreign key `RESTRICT`), `ai_usage_events` a nullable one (`SET NULL`), `audit_events` a nullable one (`SET NULL`, no policy). The four `org` tables get `ENABLE` and `FORCE ROW LEVEL SECURITY` and a `<table>_org_isolation` policy keyed on the transaction-local `app.org_id` or `app.rls_bypass`; a chunk references its object through the composite key `(object_id, org_id)`. Existing rows are backfilled to the default organization (system audit actions and catalogue usage events keep NULL). The application role must be NOSUPERUSER NOBYPASSRLS or every policy is inert.
28
+
29
+ `Organization` is now `// @extensible`. New: `RLS_POLICIES` (from the shipped `rls-policies.json`), `assertRlsPolicies`, `checkRlsPolicySources`, `scanRlsPolicies` and `checkRlsPolicies`; `platform db drift` asserts the policies against `pg_policies` and the forced flag against `pg_class` (the `rlsPolicies` list in `platform.lock` carries an app's own); `runDbConformance()` gains the policy tripwire. The manifest gains an optional `rls` flag (`platform db promote --rls --touches`), and `platform db baseline` stops with `RLS_OPT_IN_REQUIRED` before a migration flagged `rls` that sits above `--through` until the app passes `--allow-rls`; it also asserts the live policies up to `--through`.
30
+
31
+ - fc11b22: Add `OrgSettings` to the `settings` fragment and migration `0028_add_org_settings` (#733): one row per organization holding its settings overrides, with its own version, FORCEd row-level security and the `org_settings_org_isolation` policy (listed in `RLS_POLICIES`).
32
+ - b618459: Add `Organization`, `Membership` and `Invite` to the identity fragment (#721) and the nullable `org_id` columns on `refresh_tokens`, `personal_access_tokens` and `device_codes`, as platform migration `0023_add_organizations`. The migration backfills the default organization (slug `default`), one active membership per existing user and the default `org_id` on every existing credential row, and creates the raw-SQL partial unique index `organizations_default_uniq_idx` (exactly one default organization), now listed in `raw-sql-indexes.json`.
33
+
34
+ `seedPlatform` (`@marinoscar/platform-db/seed`) gains an idempotent default-organization step: it creates the organization only when none is flagged default, found by `isDefault` rather than by slug. `PlatformSeedInput.defaultOrganization` is optional; `SeedPrisma` gains an `organization` delegate and `SeedSummary` a `defaultOrganizationCreated` field.
35
+
36
+ - 52eab37: Add the `Grant` model and platform migration `0027_add_grants` to the `sharing` fragment (#729): the `GrantGranteeKind` enum (`user`, `group`, `link`) and the `grants` table, a polymorphic `(resource_type, resource_id)` share with a role, an optional expiry and a soft revocation, the link columns #730 needs, a NOT NULL `org_id` under a forced `grants_org_isolation` policy, and a composite `(grantee_group_id, org_id)` key so a grant can never name another organization's group. The raw-SQL partial unique indexes `grants_active_user_uniq_idx` and `grants_active_group_uniq_idx` allow one active grant per resource and grantee, and `grants_grantee_consistency_check` keeps the grantee columns consistent with the kind; `RAW_SQL_INDEXES` and `RLS_POLICIES` list them.
37
+ - 1404a97: Add the `sharing` fragment and platform migration `0026_add_groups` (#728): the `GroupRole` enum and the `Group` (`// @extensible`), `GroupMember` and `GroupInvite` models (tables `groups`, `group_members`, `group_invites`), each with a NOT NULL `org_id`, `ENABLE` and `FORCE ROW LEVEL SECURITY` and a `<table>_org_isolation` policy. Members and invites reach their group through the composite key `(group_id, org_id)` -> `groups (id, org_id)`, so a row can never name another organization's group. The raw-SQL partial unique index `group_invites_pending_uniq_idx` allows one pending invite per group and address; `RAW_SQL_INDEXES` and `RLS_POLICIES` list the new index and the three policies.
38
+ - 7f175f0: Split RBAC into system roles and org roles (#723), as platform migration `0024_split_system_org_roles`. The identity fragment gains the `RoleScope` enum (`system`, `org`), `Role.scope` and `Permission.scope` (default `system`), `Membership.roleId` (required, `onDelete: Restrict`) and `Invite.roleId` (nullable: NULL means the default org role). The migration creates the `org_admin` role, scopes `contributor`, `viewer` and the org permissions to `org`, moves the `admin` role's org-permission grants to `org_admin`, sets every membership's role from the user's global roles (`admin` to `org_admin`, else the highest of `contributor` and `viewer`, else `viewer`) and deletes the `user_roles` rows of org-scoped roles.
39
+
40
+ `seedPlatform` writes and refreshes the `scope` of a role or permission entry that declares one; `SeedNamedEntry` gains an optional `scope` and the package exports `SeedScope`.
41
+
42
+ - 8a0f3b9: Open the jobs and nodes vocabularies to an app (PP-14.19). Jobs: `registerRetentionPolicy` puts an app table on the nightly retention (the `retention` settings namespace is composed from the registry: schemas, defaults, merge and policy-by-policy read-compat; the platform's four keep their order and defaults, and the enqueue-only `RetentionPurgeTask` enqueues one purge per enabled policy whose handler is mounted); `registerJobReason` opens `jobs.reason`, with `reasonLabel` on the admin job row. Migration `0034_open_job_reason` turns `jobs.reason` from the `JobReason` enum into `TEXT`, keeping every stored value (apply it with `npm run db:sync`, then `prisma:migrate`; the table is rewritten under a short lock); `JobReason` becomes `BuiltinJobReason | (string & {})` and the contract's `reason` a pattern (`jobReasonSchema`), so the OpenAPI document shows a pattern where it showed an enum. Nodes: a heartbeat may carry `vitals.extra` (at most 16 numeric keys), `registerNodeVital` words them in the vitals dialog, which also lists the node's reported capabilities; relayed spans may be named `job.app.<name>` with attributes registered through `registerNodeSpanAttribute` (emitted as `job.app.<key>`), and a span that fails validation is now dropped and counted instead of failing its whole batch with a 400. CLI: `registerJobRequirement` and `registerProbedBinary` (with `versionArgs`) are exported from `@marinoscar/platform-cli/node` and used by the startup self-test and `node doctor`; `JobExecutor.vitals()` feeds `vitals.extra`. Back-compat: with only the built-ins nothing served changes; `JOB_REASONS` and `RETENTION_POLICY_KEYS` remain as deprecated aliases of `BUILTIN_JOB_REASONS` and `BUILTIN_RETENTION_POLICY_KEYS`. Upgrade the API before the nodes: an API that predates `vitals.extra` answers a heartbeat that carries it with a 400, and the CLI then stops sending vitals for the process.
43
+ - d35900e: Sharing: open group roles and persisted app grantee kinds. Migration `0037_open_sharing_vocabularies` turns `group_members.role`, `group_invites.role` and `grants.grantee_kind` from Prisma enums into text, adds the nullable `grants.grantee_ref` and relaxes `grants_grantee_consistency_check`; an app registers a group role with `registerGroupRole` and a persisted grantee kind with `registerGranteeKind({ persisted: true })`, and the share dialog and member role pickers read the registries.
44
+ - 74c4aff: Declare peer dependencies per slice (`packages/platform-slice-peers.json`, checked by `npm run check:slice-peers`) and make every peer that the universal slice does not need optional. `platform-api` now requires only what `core` needs (`@nestjs/common`, `@nestjs/core`, `@nestjs/swagger`, `@opentelemetry/api`, `@prisma/client`, `nestjs-zod`, `reflect-metadata`, `rxjs`, `zod`); `@nestjs/config`, `@nestjs/schedule`, `@nestjs/event-emitter`, `@nestjs/jwt`, `@nestjs/passport`, `passport`, `@nestjs/terminus` and `@prisma/client-runtime-utils` become optional peers an app installs for the slices that use them. `platform-web` requires only `@mui/material`, Emotion, `react` and `react-dom`; `@mui/icons-material`, `react-router-dom` and `zod` become optional. `platform-db` no longer lists `@prisma/client` (its seed takes the app's client structurally) and `prisma` becomes optional; `platform-cli`'s `react` becomes optional. An app that installed every peer needs no change; an app that imports only some slices can now install only their peers. The datatable no longer imports the undeclared transitive `@mui/utils`.
45
+
46
+ ### Patch Changes
47
+
48
+ - f6e319b: Documentation only: every slice README's Extension-point catalog links the new extension author guide (`docs/EXTENDING.md`); the email README no longer promises that a provider of `SmtpEmailProvider` in the app module replaces the transport (it does not reach the package's consumers; a transport registry is not supported yet); the AI READMEs say that a provider cannot be enabled from an app yet; the platform-db README documents `rlsPolicies` in `platform.lock` with the migration SQL for an app table protected by row-level security.
49
+ - fe73d7a: Documentation only: the overview READMEs list every shipped slice and subpath, and the stale "version 0.0.0" status lines are replaced.
50
+
51
+ ## 0.1.0-next.3
52
+
53
+ ## 0.1.0-next.2
54
+
55
+ ### Minor Changes
56
+
57
+ - c91cf7b: Add the `@marinoscar/platform-db/seed` slice: `seedPlatform(prisma, input)` upserts the platform's roles, permissions, default grants, the `global` system settings row and the initial administrator's allowlist entry (never deleting, never overwriting an admin-edited value), with `platformSeedInputFrom` and `readSeedSnapshot` to build the input from the registries' committed catalogs.
58
+ - 9734a55: `platform db baseline`: adopt the package migration history in a database that already has its schema, without re-running a migration. Dry run by default; `--apply` maps the app's directories to the platform migrations (exact hash, comment-stripped hash, or a `--map` file), refuses on a failed `_prisma_migrations` row, a live schema difference no declared deviation explains, or a missing raw-SQL index, then writes `platform.lock` and marks the migrations that have no directory applied with `prisma migrate resolve --applied`. `--through` adopts a database that is behind. Adds `runBaseline`, `proposeMapping`, `planBaseline`, `renderReport` and `createBaselineDeps`.
59
+
60
+ ### Patch Changes
61
+
62
+ - 2235f8a: `platform.lock` and `manifest.json` accept semantic versions with a prerelease or build suffix (`0.1.0-next.1`), so `platform db sync` at a prerelease package version writes a lock `parseLock` reads back. `compareVersions` orders versions by semver precedence (a prerelease is below its release, numeric identifiers compare numerically), and `nextPlatformVersion` gives a prerelease package the release it leads to. Adds `SEMVER_PATTERN`.
63
+
64
+ ## 0.1.0-next.1
65
+
66
+ ### Minor Changes
67
+
68
+ - 31c6b2a: Platform history v1: the base's 22 migrations ship in `migrations/` (`0001_initial` to `0022_add_retention_created_at_indexes`, byte-identical to the app copies) with a filled `manifest.json` (an entry may list the other slices it `touches`), and the raw-SQL index list becomes the exported `RAW_SQL_INDEXES` with a tripwire (`assertRawSqlIndexes`) that fails on an unlisted partial or expression index.
69
+
70
+ ### Patch Changes
71
+
72
+ - 521f3d2: Schema comments name `@marinoscar/platform-api/core` as the home of the secret cipher (comments only; no model change).
73
+
74
+ ## 0.1.0-next.0
75
+
76
+ ### Minor Changes
77
+
78
+ - ebaabe2: Ship the base Prisma schema as slice fragments with `// @extensible` models and `extend model`, plus the `platform db compose [--check]` composer that generates an app's `prisma/schema/` folder.
79
+ - a66fef1: First pre-release of the platform packages: the six-package scaffold (build formats, boundary lint, pack check, TSDoc and generated API reference, single-instance peer dependencies) plus the first slices.
80
+
81
+ - `@marinoscar/platform-api/core`: the typed registry primitive (`defineRegistry`, `Registry`, `RegistryError`, `RegistryFreezeService`, `withTemporaryEntries`).
82
+ - `@marinoscar/platform-api/testing`: the conformance harness (`runPlatformConformance`, `conformanceSuites`) with the `cron-enqueue-only` suite.
83
+ - `@marinoscar/platform-cli/core`: the CLI command and env-spec fragment registries.
84
+ - `@marinoscar/platform-cli/telemetry`: the node span relay and the telemetry env-spec fragment.
85
+ - `@marinoscar/platform-infra`: `infraFile()`, the `platform-infra` command (`sync` materialises fragments into an app) and the `telemetry` slice (collector and GreptimeDB compose fragments, collector config and overlay, typed manifest).
86
+ - `@marinoscar/platform-contract`, `@marinoscar/platform-web` and `@marinoscar/platform-db` ship their package scaffold only; their slices follow in later releases.
87
+
88
+ - a630d75: Migration tooling: the `platform` bin gains `platform db sync` (byte-copy package migrations into the app's `prisma/migrations` under app-local timestamps and record them in `prisma/platform.lock`), `platform db check` (offline lock verification; `--database` also compares `_prisma_migrations` checksums), `platform db promote` (turn an app-generated migration into a package migration) and `platform db drift` (migration history vs schema through a shadow database, plus the raw-SQL index assertion). Adds the `PlatformLock` and manifest models, `planSync`, `applySync`, `checkLock`, `checkLedger`, `promote` and `raw-sql-indexes.json`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 marinoscar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.