@coffre/db 0.4.6 → 0.5.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 (45) hide show
  1. package/dist/connect.d.ts +1 -1
  2. package/dist/{database-edkMkG02.d.ts → database-C63WjCrC.d.ts} +1 -1
  3. package/dist/dialect.d.ts +1 -1
  4. package/dist/grants.d.ts +105 -10
  5. package/dist/grants.js +207 -7
  6. package/dist/hyperdrive.d.ts +1 -1
  7. package/dist/index.d.ts +2 -2
  8. package/dist/log.d.ts +392 -2
  9. package/dist/log.js +53 -1
  10. package/dist/migrate.d.ts +41 -4
  11. package/dist/migrate.js +95 -8
  12. package/dist/migrations/postgres/0002_instance_roles.sql +4 -0
  13. package/dist/migrations/postgres/0003_credential_scopes.sql +4 -0
  14. package/dist/migrations/postgres/meta/0002_snapshot.json +2860 -0
  15. package/dist/migrations/postgres/meta/0003_snapshot.json +2872 -0
  16. package/dist/migrations/postgres/meta/_journal.json +14 -0
  17. package/dist/migrations/sqlite/0002_instance_roles.sql +2 -0
  18. package/dist/migrations/sqlite/0003_credential_scopes.sql +2 -0
  19. package/dist/migrations/sqlite/meta/0002_snapshot.json +2594 -0
  20. package/dist/migrations/sqlite/meta/0003_snapshot.json +2608 -0
  21. package/dist/migrations/sqlite/meta/_journal.json +14 -0
  22. package/dist/portable.d.ts +2 -2
  23. package/dist/{schema-BqCB3XFm.d.ts → schema-a7PkFgea.d.ts} +68 -0
  24. package/dist/schema-sqlite.d.ts +76 -0
  25. package/dist/schema-sqlite.js +4 -0
  26. package/dist/schema-version.d.ts +1 -1
  27. package/dist/schema-version.js +60 -26
  28. package/dist/schema.d.ts +1 -1
  29. package/dist/schema.js +4 -0
  30. package/package.json +2 -2
  31. package/src/grants.ts +272 -11
  32. package/src/log.ts +66 -2
  33. package/src/migrate.ts +111 -6
  34. package/src/migrations/postgres/0002_instance_roles.sql +4 -0
  35. package/src/migrations/postgres/0003_credential_scopes.sql +4 -0
  36. package/src/migrations/postgres/meta/0002_snapshot.json +2860 -0
  37. package/src/migrations/postgres/meta/0003_snapshot.json +2872 -0
  38. package/src/migrations/postgres/meta/_journal.json +14 -0
  39. package/src/migrations/sqlite/0002_instance_roles.sql +2 -0
  40. package/src/migrations/sqlite/0003_credential_scopes.sql +2 -0
  41. package/src/migrations/sqlite/meta/0002_snapshot.json +2594 -0
  42. package/src/migrations/sqlite/meta/0003_snapshot.json +2608 -0
  43. package/src/migrations/sqlite/meta/_journal.json +14 -0
  44. package/src/schema.sqlite.ts +6 -0
  45. package/src/schema.ts +11 -1
@@ -15,6 +15,20 @@
15
15
  "when": 1791242675074,
16
16
  "tag": "0001_mcp_approvals",
17
17
  "breakpoints": true
18
+ },
19
+ {
20
+ "idx": 2,
21
+ "version": "6",
22
+ "when": 1791619334012,
23
+ "tag": "0002_instance_roles",
24
+ "breakpoints": true
25
+ },
26
+ {
27
+ "idx": 3,
28
+ "version": "6",
29
+ "when": 1791676487593,
30
+ "tag": "0003_credential_scopes",
31
+ "breakpoints": true
18
32
  }
19
33
  ]
20
34
  }
@@ -204,6 +204,8 @@ export const vaultMembers = sqliteTable(
204
204
  principal: text().primaryKey(),
205
205
  status: text().notNull(),
206
206
  owner: flag('owner').notNull().default(false),
207
+ role: text(),
208
+ scope: text(),
207
209
  generation: integer().notNull().default(0),
208
210
  createdAt: integer('created_at', { mode: 'number' }).notNull(),
209
211
  createdBy: text('created_by').notNull(),
@@ -478,6 +480,8 @@ export const serviceBindings = sqliteTable(
478
480
  jwksUri: text('jwks_uri').notNull(),
479
481
  // JSON, sorted by claim name.
480
482
  claims: text().notNull(),
483
+ // What the credentials it issues reach (`CredentialScope`), JSON; null on a binding of 0.4 the app has not sealed yet.
484
+ scope: text(),
481
485
  label: text(),
482
486
  createdAt: createdAt(),
483
487
  createdBy: text('created_by').notNull(),
@@ -637,6 +641,8 @@ export const credentials = sqliteTable(
637
641
  // The member it acts as, `user:<email>` or `token:<id>`, under the generation it was issued in.
638
642
  principal: text().notNull(),
639
643
  identityId: text('identity_id'),
644
+ // What a service token reaches (`CredentialScope`), JSON: null for a session, one a binding issued (its binding's), or one of 0.4 the app has not sealed yet.
645
+ scope: text(),
640
646
  label: text(),
641
647
  createdAt: createdAt(),
642
648
  createdBy: text('created_by').notNull(),
package/src/schema.ts CHANGED
@@ -204,9 +204,15 @@ export const vaultMembers = pgTable(
204
204
  {
205
205
  principal: text().primaryKey(),
206
206
  status: text().notNull(),
207
- // An instance owner, who manages every project and member. Root admins
207
+ // An owner of 0.4: an Admin, unless `role` says otherwise. Written as
208
+ // whether `role` administers, for a vault of 0.4 to read. Root admins
208
209
  // come from the vault's configuration, never from a row.
209
210
  owner: boolean().notNull().default(false),
211
+ // A person's instance role (`INSTANCE_ROLES` in @coffre/core/access),
212
+ // and where it applies, as JSON (`Scope`, projects by id); null on a row
213
+ // no vault of 0.5 has written, which `owner` says all of.
214
+ role: text(),
215
+ scope: text(),
210
216
  // Advanced by each removal. A session, token or linked account issued
211
217
  // under an older generation is dead, whatever its own row says.
212
218
  generation: integer().notNull().default(0),
@@ -519,6 +525,8 @@ export const serviceBindings = pgTable(
519
525
  jwksUri: text('jwks_uri').notNull(),
520
526
  // JSON, sorted by claim name.
521
527
  claims: text().notNull(),
528
+ // What the credentials it issues reach (`CredentialScope`), JSON; null on a binding of 0.4 the app has not sealed yet.
529
+ scope: text(),
522
530
  label: text(),
523
531
  createdAt: createdAt(),
524
532
  createdBy: text('created_by').notNull(),
@@ -702,6 +710,8 @@ export const credentials = pgTable(
702
710
  // The member it acts as, `user:<email>` or `token:<id>`, under the generation it was issued in.
703
711
  principal: text().notNull(),
704
712
  identityId: uuid('identity_id'),
713
+ // What a service token reaches (`CredentialScope`), JSON: null for a session, one a binding issued (its binding's), or one of 0.4 the app has not sealed yet.
714
+ scope: text(),
705
715
  label: text(),
706
716
  createdAt: createdAt(),
707
717
  createdBy: text('created_by').notNull(),