@astram/identity 0.10.0 → 0.12.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.
Files changed (127) hide show
  1. package/dist/auth-facts-keys.d.ts +16 -0
  2. package/dist/auth-facts-keys.d.ts.map +1 -1
  3. package/dist/auth-facts-keys.js +26 -10
  4. package/dist/cross-tenant-grant.object.d.ts +2 -2
  5. package/dist/cross-tenant-grant.object.d.ts.map +1 -1
  6. package/dist/cross-tenant-grant.object.js +8 -4
  7. package/dist/features/audit/directory-label-resolver.d.ts +4 -1
  8. package/dist/features/audit/directory-label-resolver.d.ts.map +1 -1
  9. package/dist/features/audit/directory-label-resolver.js +8 -5
  10. package/dist/features/audit/mariadb-audit-reader.d.ts +5 -1
  11. package/dist/features/audit/mariadb-audit-reader.d.ts.map +1 -1
  12. package/dist/features/audit/mariadb-audit-reader.js +10 -2
  13. package/dist/features/authz/access-bundle-reconcile.job.d.ts +4 -1
  14. package/dist/features/authz/access-bundle-reconcile.job.d.ts.map +1 -1
  15. package/dist/features/authz/access-bundle-reconcile.job.js +7 -4
  16. package/dist/features/authz/access-bundle-store.d.ts +4 -1
  17. package/dist/features/authz/access-bundle-store.d.ts.map +1 -1
  18. package/dist/features/authz/access-bundle-store.js +19 -16
  19. package/dist/features/authz/catalog-bootstrap.provider.d.ts +4 -1
  20. package/dist/features/authz/catalog-bootstrap.provider.d.ts.map +1 -1
  21. package/dist/features/authz/catalog-bootstrap.provider.js +37 -6
  22. package/dist/features/authz/catalog-reconcile.job.d.ts +3 -1
  23. package/dist/features/authz/catalog-reconcile.job.d.ts.map +1 -1
  24. package/dist/features/authz/catalog-reconcile.job.js +3 -2
  25. package/dist/features/authz/db-permission-facts.adapter.d.ts +9 -3
  26. package/dist/features/authz/db-permission-facts.adapter.d.ts.map +1 -1
  27. package/dist/features/authz/db-permission-facts.adapter.js +22 -16
  28. package/dist/features/authz/grant-admin.service.d.ts +4 -1
  29. package/dist/features/authz/grant-admin.service.d.ts.map +1 -1
  30. package/dist/features/authz/grant-admin.service.js +32 -37
  31. package/dist/features/authz/grant-ceiling.d.ts +6 -1
  32. package/dist/features/authz/grant-ceiling.d.ts.map +1 -1
  33. package/dist/features/authz/grant-ceiling.js +19 -16
  34. package/dist/features/authz/mariadb-catalog-store.d.ts +4 -1
  35. package/dist/features/authz/mariadb-catalog-store.d.ts.map +1 -1
  36. package/dist/features/authz/mariadb-catalog-store.js +10 -7
  37. package/dist/features/authz/permission-version.bumper.d.ts +6 -1
  38. package/dist/features/authz/permission-version.bumper.d.ts.map +1 -1
  39. package/dist/features/authz/permission-version.bumper.js +13 -11
  40. package/dist/features/authz/record-authorization.d.ts +8 -2
  41. package/dist/features/authz/record-authorization.d.ts.map +1 -1
  42. package/dist/features/authz/record-authorization.js +8 -4
  43. package/dist/features/authz/role-binding.d.ts +3 -2
  44. package/dist/features/authz/role-binding.d.ts.map +1 -1
  45. package/dist/features/authz/role-binding.js +7 -8
  46. package/dist/features/company/company-hierarchy.service.d.ts +6 -1
  47. package/dist/features/company/company-hierarchy.service.d.ts.map +1 -1
  48. package/dist/features/company/company-hierarchy.service.js +17 -16
  49. package/dist/features/cross-tenant/cross-tenant-grant-read.service.d.ts +11 -6
  50. package/dist/features/cross-tenant/cross-tenant-grant-read.service.d.ts.map +1 -1
  51. package/dist/features/cross-tenant/cross-tenant-grant-read.service.js +24 -19
  52. package/dist/features/files/files.controller.d.ts +27 -0
  53. package/dist/features/files/files.controller.d.ts.map +1 -0
  54. package/dist/features/files/files.controller.js +94 -0
  55. package/dist/features/files/files.service.d.ts +87 -0
  56. package/dist/features/files/files.service.d.ts.map +1 -0
  57. package/dist/features/files/files.service.js +311 -0
  58. package/dist/features/framework-schemas.token.d.ts +8 -0
  59. package/dist/features/framework-schemas.token.d.ts.map +1 -0
  60. package/dist/features/framework-schemas.token.js +10 -0
  61. package/dist/features/identity-feature.module.d.ts +29 -1
  62. package/dist/features/identity-feature.module.d.ts.map +1 -1
  63. package/dist/features/identity-feature.module.js +168 -41
  64. package/dist/features/membership/membership-checker.d.ts +7 -1
  65. package/dist/features/membership/membership-checker.d.ts.map +1 -1
  66. package/dist/features/membership/membership-checker.js +9 -4
  67. package/dist/features/migration-ledger-check.d.ts +15 -0
  68. package/dist/features/migration-ledger-check.d.ts.map +1 -0
  69. package/dist/features/migration-ledger-check.js +26 -0
  70. package/dist/features/policy/policy.service.d.ts +2 -1
  71. package/dist/features/policy/policy.service.d.ts.map +1 -1
  72. package/dist/features/policy/policy.service.js +15 -0
  73. package/dist/features/scope/scope-closure.service.d.ts +8 -1
  74. package/dist/features/scope/scope-closure.service.d.ts.map +1 -1
  75. package/dist/features/scope/scope-closure.service.js +22 -19
  76. package/dist/features/scope/scope-subtree.resolver.d.ts +7 -1
  77. package/dist/features/scope/scope-subtree.resolver.d.ts.map +1 -1
  78. package/dist/features/scope/scope-subtree.resolver.js +9 -4
  79. package/dist/features/service-account/lock-service-accounts.d.ts +3 -1
  80. package/dist/features/service-account/lock-service-accounts.d.ts.map +1 -1
  81. package/dist/features/service-account/lock-service-accounts.js +4 -4
  82. package/dist/features/service-account/no-expiry-key-report.d.ts +9 -3
  83. package/dist/features/service-account/no-expiry-key-report.d.ts.map +1 -1
  84. package/dist/features/service-account/no-expiry-key-report.js +17 -10
  85. package/dist/features/service-account/service-account.store.d.ts +8 -1
  86. package/dist/features/service-account/service-account.store.d.ts.map +1 -1
  87. package/dist/features/service-account/service-account.store.js +19 -14
  88. package/dist/features/share/share.service.d.ts +19 -2
  89. package/dist/features/share/share.service.d.ts.map +1 -1
  90. package/dist/features/share/share.service.js +36 -2
  91. package/dist/features/user/user.service.d.ts +7 -3
  92. package/dist/features/user/user.service.d.ts.map +1 -1
  93. package/dist/features/user/user.service.js +12 -4
  94. package/dist/index.d.ts +9 -0
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +13 -1
  97. package/dist/objects.d.ts.map +1 -1
  98. package/dist/objects.js +2 -0
  99. package/dist/record-share.object.d.ts +1 -1
  100. package/dist/record-share.object.d.ts.map +1 -1
  101. package/dist/record-share.object.js +7 -3
  102. package/dist/schema.d.ts +15 -2
  103. package/dist/schema.d.ts.map +1 -1
  104. package/dist/schema.js +17 -2
  105. package/dist/service-account.object.d.ts +3 -2
  106. package/dist/service-account.object.d.ts.map +1 -1
  107. package/dist/service-account.object.js +4 -2
  108. package/dist/stored-file.object.d.ts +35 -0
  109. package/dist/stored-file.object.d.ts.map +1 -0
  110. package/dist/stored-file.object.js +94 -0
  111. package/migrations/1710000000001-CreateIdentityOrgModel.cjs +14 -4
  112. package/migrations/1710000000002-CreateMembershipAndPostings.cjs +14 -4
  113. package/migrations/1710000000003-CreateIdentityCredential.cjs +14 -4
  114. package/migrations/1710000000004-CreateSessionTables.cjs +14 -4
  115. package/migrations/1710000000005-CreateMfaAndTokenSurface.cjs +14 -4
  116. package/migrations/1710000000010-CreateAuditLog.cjs +14 -4
  117. package/migrations/1710000000011-CreateCrossTenantGrant.cjs +15 -4
  118. package/migrations/1710000000012-SeedCrossTenantGrantPerms.cjs +15 -4
  119. package/migrations/1710000000013-CreateSharedResource.cjs +14 -4
  120. package/migrations/1710000000018-CreateServiceAccount.cjs +13 -4
  121. package/migrations/1710000000019-AddSessionMustReenroll.cjs +14 -4
  122. package/migrations/1710000000020-CreateEmailChangeToken.cjs +15 -5
  123. package/migrations/1710000000021-AddUsersEmailUniqueIndex.cjs +24 -13
  124. package/migrations/1710000000022-CreateStoredFile.cjs +53 -0
  125. package/migrations/1710000000099-SeedDevIdentity.cjs +14 -6
  126. package/migrations/1710000000100-SeedDevTenantBAndRoot.cjs +14 -6
  127. package/package.json +8 -4
@@ -22,6 +22,7 @@ const list_query_js_1 = require("../shared/list-query.js");
22
22
  const grant_ceiling_js_1 = require("../authz/grant-ceiling.js");
23
23
  const identity_errors_js_1 = require("../shared/identity-errors.js");
24
24
  const email_address_changer_token_js_1 = require("./email-address-changer.token.js");
25
+ const framework_schemas_token_js_1 = require("../framework-schemas.token.js");
25
26
  /**
26
27
  * KI #87: `users` has two unique keys besides the PK, `IDX_users_username` (migration 001) and
27
28
  * `uq_users_email` (021, `utf8mb4_unicode_ci`: folds case, accents, width, trailing spaces). The
@@ -77,9 +78,13 @@ let UserService = UserService_1 = class UserService {
77
78
  versionBump;
78
79
  emailAddresses;
79
80
  logger = new common_1.Logger(UserService_1.name);
80
- /** The engine's audit sink, used on the email helper's transaction (no pool of its own). */
81
- emailAudit = new engine_1.MariaDbAuditSink({});
82
- constructor(records, ceiling, resetTokens, emailSender, sessions, versionBump, emailAddresses) {
81
+ /**
82
+ * The engine's audit sink, used on the email helper's transaction (no pool of its own), on the
83
+ * audit database forRoot resolved (`IDENTITY_FRAMEWORK_SCHEMAS`); absent (a hand-built
84
+ * service) ⇒ the sink resolves `SHIELD_DB_NAMESPACE` itself.
85
+ */
86
+ emailAudit;
87
+ constructor(records, ceiling, resetTokens, emailSender, sessions, versionBump, emailAddresses, schemas) {
83
88
  this.records = records;
84
89
  this.ceiling = ceiling;
85
90
  this.resetTokens = resetTokens;
@@ -87,6 +92,7 @@ let UserService = UserService_1 = class UserService {
87
92
  this.sessions = sessions;
88
93
  this.versionBump = versionBump;
89
94
  this.emailAddresses = emailAddresses;
95
+ this.emailAudit = new engine_1.MariaDbAuditSink(schemas ? { schema: schemas.audit } : {});
90
96
  }
91
97
  /**
92
98
  * Create a user. With `companyUuid`, the user is created AND attached (one active membership) in
@@ -288,6 +294,8 @@ exports.UserService = UserService = UserService_1 = __decorate([
288
294
  __param(5, (0, common_1.Inject)(posting_version_bump_js_1.POSTING_VERSION_BUMP)),
289
295
  __param(6, (0, common_1.Optional)()),
290
296
  __param(6, (0, common_1.Inject)(email_address_changer_token_js_1.IDENTITY_EMAIL_ADDRESS_CHANGER)),
297
+ __param(7, (0, common_1.Optional)()),
298
+ __param(7, (0, common_1.Inject)(framework_schemas_token_js_1.IDENTITY_FRAMEWORK_SCHEMAS)),
291
299
  __metadata("design:paramtypes", [engine_1.RecordsService,
292
- grant_ceiling_js_1.GrantCeiling, Object, Object, Object, Object, Object])
300
+ grant_ceiling_js_1.GrantCeiling, Object, Object, Object, Object, Object, Object])
293
301
  ], UserService);
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export { MembershipPosting } from './membership-posting.object.js';
14
14
  export { CompanyDepartment } from './company-department.object.js';
15
15
  export { CompanyBranch } from './company-branch.object.js';
16
16
  export { ServiceAccount } from './service-account.object.js';
17
+ export { StoredFile } from './stored-file.object.js';
17
18
  export { identityMigrationsDir } from './migrations-dir.js';
18
19
  /**
19
20
  * All identity objects, registered with the engine at boot (same set + order as before).
@@ -29,6 +30,9 @@ export { identityObjects } from './objects.js';
29
30
  * control-plane keys WITHOUT guard importing this package.
30
31
  */
31
32
  export { identityAuthActionKeys, identityControlPlaneKeys } from './auth-facts-keys.js';
33
+ /** KI #70: the same key universe with the consumer's `extraObjects` (pass the SAME list to
34
+ * `IdentityFeatureModule.forRoot({ extraObjects })`). */
35
+ export { buildIdentityAuthKeys, type IdentityAuthKeys } from './auth-facts-keys.js';
32
36
  /**
33
37
  * The framework-owned identity FEATURE module (company/user/role CRUD). The consumer imports
34
38
  * `IdentityFeatureModule.forRoot()` in one line alongside `ShieldModule.forRoot(...)` (ADR-0026);
@@ -36,6 +40,11 @@ export { identityAuthActionKeys, identityControlPlaneKeys } from './auth-facts-k
36
40
  * `identityObjects`, and mounts the CRUD controllers — no separate engine setup needed.
37
41
  */
38
42
  export { IdentityFeatureModule } from './features/identity-feature.module.js';
43
+ /**
44
+ * Stored files (file-storage SPEC §5 I-K): `store` / `open` / `remove` on the engine pipe, provided
45
+ * and exported by `IdentityFeatureModule`. Apps call it from their own `@Classified` routes.
46
+ */
47
+ export { FilesService, type StoreFileInput, type StoredFileSummary, type OpenedFile, } from './features/files/files.service.js';
39
48
  /**
40
49
  * The ADR-0011 per-request session-facts reader (ALS hot path), re-exported so a consumer
41
50
  * that wants to construct it directly can do so.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;GAIG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;;;GAMG;AACH,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAExF;;;;;GAKG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAU9E;;;GAGG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF;;;;;;GAMG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEpF;;;;;;;GAOG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D;;;;GAIG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;;;GAMG;AACH,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACxF;0DAC0D;AAC1D,OAAO,EAAE,qBAAqB,EAAE,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEpF;;;;;GAKG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E;;;GAGG;AACH,OAAO,EACL,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,UAAU,GAChB,MAAM,mCAAmC,CAAC;AAU3C;;;GAGG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF;;;;;;GAMG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEpF;;;;;;;GAOG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DbMembershipChecker = exports.DbScopeSubtreeResolver = exports.AlsSessionFactsReader = exports.IdentityFeatureModule = exports.identityControlPlaneKeys = exports.identityAuthActionKeys = exports.identityObjects = exports.identityMigrationsDir = exports.ServiceAccount = exports.CompanyBranch = exports.CompanyDepartment = exports.MembershipPosting = exports.CompanyMembership = exports.Branch = exports.Department = exports.Role = exports.User = exports.Company = void 0;
3
+ exports.DbMembershipChecker = exports.DbScopeSubtreeResolver = exports.AlsSessionFactsReader = exports.FilesService = exports.IdentityFeatureModule = exports.buildIdentityAuthKeys = exports.identityControlPlaneKeys = exports.identityAuthActionKeys = exports.identityObjects = exports.identityMigrationsDir = exports.StoredFile = exports.ServiceAccount = exports.CompanyBranch = exports.CompanyDepartment = exports.MembershipPosting = exports.CompanyMembership = exports.Branch = exports.Department = exports.Role = exports.User = exports.Company = void 0;
4
4
  /**
5
5
  * @astram/identity — the framework-owned identity + tenancy model.
6
6
  * The 9 identity object classes (relocated from the consumer app in Sub-plan B) +
@@ -27,6 +27,8 @@ var company_branch_object_js_1 = require("./company-branch.object.js");
27
27
  Object.defineProperty(exports, "CompanyBranch", { enumerable: true, get: function () { return company_branch_object_js_1.CompanyBranch; } });
28
28
  var service_account_object_js_1 = require("./service-account.object.js");
29
29
  Object.defineProperty(exports, "ServiceAccount", { enumerable: true, get: function () { return service_account_object_js_1.ServiceAccount; } });
30
+ var stored_file_object_js_1 = require("./stored-file.object.js");
31
+ Object.defineProperty(exports, "StoredFile", { enumerable: true, get: function () { return stored_file_object_js_1.StoredFile; } });
30
32
  var migrations_dir_js_1 = require("./migrations-dir.js");
31
33
  Object.defineProperty(exports, "identityMigrationsDir", { enumerable: true, get: function () { return migrations_dir_js_1.identityMigrationsDir; } });
32
34
  /**
@@ -46,6 +48,10 @@ Object.defineProperty(exports, "identityObjects", { enumerable: true, get: funct
46
48
  var auth_facts_keys_js_1 = require("./auth-facts-keys.js");
47
49
  Object.defineProperty(exports, "identityAuthActionKeys", { enumerable: true, get: function () { return auth_facts_keys_js_1.identityAuthActionKeys; } });
48
50
  Object.defineProperty(exports, "identityControlPlaneKeys", { enumerable: true, get: function () { return auth_facts_keys_js_1.identityControlPlaneKeys; } });
51
+ /** KI #70: the same key universe with the consumer's `extraObjects` (pass the SAME list to
52
+ * `IdentityFeatureModule.forRoot({ extraObjects })`). */
53
+ var auth_facts_keys_js_2 = require("./auth-facts-keys.js");
54
+ Object.defineProperty(exports, "buildIdentityAuthKeys", { enumerable: true, get: function () { return auth_facts_keys_js_2.buildIdentityAuthKeys; } });
49
55
  /**
50
56
  * The framework-owned identity FEATURE module (company/user/role CRUD). The consumer imports
51
57
  * `IdentityFeatureModule.forRoot()` in one line alongside `ShieldModule.forRoot(...)` (ADR-0026);
@@ -54,6 +60,12 @@ Object.defineProperty(exports, "identityControlPlaneKeys", { enumerable: true, g
54
60
  */
55
61
  var identity_feature_module_js_1 = require("./features/identity-feature.module.js");
56
62
  Object.defineProperty(exports, "IdentityFeatureModule", { enumerable: true, get: function () { return identity_feature_module_js_1.IdentityFeatureModule; } });
63
+ /**
64
+ * Stored files (file-storage SPEC §5 I-K): `store` / `open` / `remove` on the engine pipe, provided
65
+ * and exported by `IdentityFeatureModule`. Apps call it from their own `@Classified` routes.
66
+ */
67
+ var files_service_js_1 = require("./features/files/files.service.js");
68
+ Object.defineProperty(exports, "FilesService", { enumerable: true, get: function () { return files_service_js_1.FilesService; } });
57
69
  /*
58
70
  * The record-tier authorization: since 0.7 (security hardening Phase 9 #7)
59
71
  * `IdentityFeatureModule.forRoot({ extraObjects })` builds it and provides it to `ShieldModule`
@@ -1 +1 @@
1
- {"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../src/objects.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAetD,6FAA6F;AAC7F,eAAO,MAAM,eAAe,EAAE,SAAS,eAAe,EAcrD,CAAC"}
1
+ {"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../src/objects.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAgBtD,6FAA6F;AAC7F,eAAO,MAAM,eAAe,EAAE,SAAS,eAAe,EAerD,CAAC"}
package/dist/objects.js CHANGED
@@ -14,6 +14,7 @@ const cross_tenant_grant_object_js_1 = require("./cross-tenant-grant.object.js")
14
14
  const record_share_object_js_1 = require("./record-share.object.js");
15
15
  const shared_resource_object_js_1 = require("./shared-resource.object.js");
16
16
  const service_account_object_js_1 = require("./service-account.object.js");
17
+ const stored_file_object_js_1 = require("./stored-file.object.js");
17
18
  /** All identity objects, registered with the engine at boot (same set + order as before). */
18
19
  exports.identityObjects = [
19
20
  company_object_js_1.Company,
@@ -29,4 +30,5 @@ exports.identityObjects = [
29
30
  record_share_object_js_1.RecordShare,
30
31
  shared_resource_object_js_1.SharedResource,
31
32
  service_account_object_js_1.ServiceAccount,
33
+ stored_file_object_js_1.StoredFile,
32
34
  ];
@@ -11,7 +11,7 @@
11
11
  * posture as `cross_tenant_grant`/`role`. `system: true` (never `owned`/`tenantScoped`) — the
12
12
  * table's own columns (`rs_tenant_uuid`, `rs_granted_by`) + the writer's owner-bound encode the
13
13
  * isolation; the pipe's owner/tenant baseline is not involved. Action vocabulary is NOT the CRUD
14
- * verbs — see `@astram/guard`'s `identity-actions.ts` `actionsFor('record_share')` →
14
+ * verbs: it opts out (`crudActions: false`, ADR-0038) and declares exactly `@astram/guard`'s
15
15
  * `RECORD_SHARE_ACTIONS` (`share`/`read`).
16
16
  *
17
17
  * Mirrors `cross-tenant-grant.object.ts`'s shape (system, PK only satisfies `validateAccess`).
@@ -1 +1 @@
1
- {"version":3,"file":"record-share.object.d.ts","sourceRoot":"","sources":["../src/record-share.object.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAOa,WAAW;IAEtB,IAAI,EAAG,MAAM,CAAC;IAGd,UAAU,EAAG,MAAM,CAAC;IAGpB,UAAU,EAAG,MAAM,CAAC;CACrB"}
1
+ {"version":3,"file":"record-share.object.d.ts","sourceRoot":"","sources":["../src/record-share.object.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;GAiBG;AACH,qBASa,WAAW;IAEtB,IAAI,EAAG,MAAM,CAAC;IAGd,UAAU,EAAG,MAAM,CAAC;IAGpB,UAAU,EAAG,MAAM,CAAC;CACrB"}
@@ -11,8 +11,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.RecordShare = void 0;
13
13
  const engine_1 = require("@astram/engine");
14
- /** The physical schema `record_share` lives in (migration 1710000000014). */
15
- const SCHEMA = 'shield_authz';
14
+ const guard_1 = require("@astram/guard");
15
+ /** The authz-database token `record_share` lives in (migration 1710000000014); the engine
16
+ * resolves it at registration (ADR-0037). */
17
+ const SCHEMA = engine_1.FRAMEWORK_SCHEMA.authz;
16
18
  /**
17
19
  * `record_share` — an AUTHORITY-ONLY @ObjectType, never CRUD'd through the RecordEngine pipe
18
20
  * (list-scoping engine Phase 6, §9.2). Its sole purpose is to give `record_share` an entry in the
@@ -26,7 +28,7 @@ const SCHEMA = 'shield_authz';
26
28
  * posture as `cross_tenant_grant`/`role`. `system: true` (never `owned`/`tenantScoped`) — the
27
29
  * table's own columns (`rs_tenant_uuid`, `rs_granted_by`) + the writer's owner-bound encode the
28
30
  * isolation; the pipe's owner/tenant baseline is not involved. Action vocabulary is NOT the CRUD
29
- * verbs — see `@astram/guard`'s `identity-actions.ts` `actionsFor('record_share')` →
31
+ * verbs: it opts out (`crudActions: false`, ADR-0038) and declares exactly `@astram/guard`'s
30
32
  * `RECORD_SHARE_ACTIONS` (`share`/`read`).
31
33
  *
32
34
  * Mirrors `cross-tenant-grant.object.ts`'s shape (system, PK only satisfies `validateAccess`).
@@ -55,6 +57,8 @@ exports.RecordShare = RecordShare = __decorate([
55
57
  table: 'record_share',
56
58
  schema: SCHEMA,
57
59
  access: { plane: 'control', system: true },
60
+ crudActions: false,
61
+ actions: guard_1.RECORD_SHARE_ACTIONS,
58
62
  }),
59
63
  (0, engine_1.PrimaryKey)({ kind: 'uuid', column: 'rs_uuid' })
60
64
  ], RecordShare);
package/dist/schema.d.ts CHANGED
@@ -1,3 +1,16 @@
1
- /** The physical schema every identity table lives in (single-source). */
2
- export declare const SCHEMA = "shield_app";
1
+ import { type FrameworkSchemas } from '@astram/core';
2
+ /**
3
+ * The schema every identity table declares (single-source): the app-database token, resolved by
4
+ * the engine at registration to `<namespace>_app` (configurable-framework-db, ADR-0037). It is
5
+ * never a database name: SQL built outside the engine uses {@link IdentitySchemaNames}.
6
+ */
7
+ export declare const SCHEMA: "{{framework_schema:app}}";
8
+ /** The resolved framework database names identity SQL needs (`FrameworkSchemas` fits). */
9
+ export type IdentitySchemaNames = Pick<FrameworkSchemas, 'app' | 'authz'>;
10
+ /**
11
+ * The framework database names from `SHIELD_DB_NAMESPACE` (unset ⇒ `shield_*`), for a class built
12
+ * without explicit names. Call at construction (boot) only, never per request; an invalid
13
+ * namespace throws (fail closed). `IdentityFeatureModule.forRoot` always passes its names.
14
+ */
15
+ export declare function frameworkSchemasFromEnv(): FrameworkSchemas;
3
16
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,eAAO,MAAM,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAG9E;;;;GAIG;AACH,eAAO,MAAM,MAAM,4BAAuB,CAAC;AAE3C,0FAA0F;AAC1F,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,OAAO,CAAC,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,gBAAgB,CAE1D"}
package/dist/schema.js CHANGED
@@ -1,5 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SCHEMA = void 0;
4
- /** The physical schema every identity table lives in (single-source). */
5
- exports.SCHEMA = 'shield_app';
4
+ exports.frameworkSchemasFromEnv = frameworkSchemasFromEnv;
5
+ const core_1 = require("@astram/core");
6
+ const engine_1 = require("@astram/engine");
7
+ /**
8
+ * The schema every identity table declares (single-source): the app-database token, resolved by
9
+ * the engine at registration to `<namespace>_app` (configurable-framework-db, ADR-0037). It is
10
+ * never a database name: SQL built outside the engine uses {@link IdentitySchemaNames}.
11
+ */
12
+ exports.SCHEMA = engine_1.FRAMEWORK_SCHEMA.app;
13
+ /**
14
+ * The framework database names from `SHIELD_DB_NAMESPACE` (unset ⇒ `shield_*`), for a class built
15
+ * without explicit names. Call at construction (boot) only, never per request; an invalid
16
+ * namespace throws (fail closed). `IdentityFeatureModule.forRoot` always passes its names.
17
+ */
18
+ function frameworkSchemasFromEnv() {
19
+ return (0, core_1.resolveFrameworkSchemas)(process.env);
20
+ }
@@ -18,8 +18,9 @@
18
18
  * is IN their reachable subtree (a cross-tenant id is invisible → 404, no existence leak). Root
19
19
  * spans all. This is the read/write wall that makes "own tenant only" structural, not handler-level.
20
20
  *
21
- * Action vocabulary is administration, not CRUD data ops — see `@astram/guard`'s
22
- * `identity-actions.ts` (`read`/`manage` for `service_account`).
21
+ * Action vocabulary (ADR-0038): the CRUD verbs administer the account row, plus the declared
22
+ * `manage_keys` (issue/rotate/revoke its `ask_…` keys), giving `read, create, update, delete,
23
+ * manage_keys` — the same set as `@astram/guard`'s `SERVICE_ACCOUNT_ACTIONS`.
23
24
  */
24
25
  export declare class ServiceAccount {
25
26
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"service-account.object.d.ts","sourceRoot":"","sources":["../src/service-account.object.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAQa,cAAc;IAEzB,EAAE,EAAG,MAAM,CAAC;IAGZ,QAAQ,EAAG,MAAM,CAAC;IAGlB,KAAK,EAAG,MAAM,CAAC;IAGf,MAAM,EAAG,MAAM,CAAC;IAGhB,WAAW,EAAG,MAAM,CAAC;CACtB"}
1
+ {"version":3,"file":"service-account.object.d.ts","sourceRoot":"","sources":["../src/service-account.object.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBASa,cAAc;IAEzB,EAAE,EAAG,MAAM,CAAC;IAGZ,QAAQ,EAAG,MAAM,CAAC;IAGlB,KAAK,EAAG,MAAM,CAAC;IAGf,MAAM,EAAG,MAAM,CAAC;IAGhB,WAAW,EAAG,MAAM,CAAC;CACtB"}
@@ -32,8 +32,9 @@ const schema_1 = require("./schema");
32
32
  * is IN their reachable subtree (a cross-tenant id is invisible → 404, no existence leak). Root
33
33
  * spans all. This is the read/write wall that makes "own tenant only" structural, not handler-level.
34
34
  *
35
- * Action vocabulary is administration, not CRUD data ops — see `@astram/guard`'s
36
- * `identity-actions.ts` (`read`/`manage` for `service_account`).
35
+ * Action vocabulary (ADR-0038): the CRUD verbs administer the account row, plus the declared
36
+ * `manage_keys` (issue/rotate/revoke its `ask_…` keys), giving `read, create, update, delete,
37
+ * manage_keys` — the same set as `@astram/guard`'s `SERVICE_ACCOUNT_ACTIONS`.
37
38
  */
38
39
  let ServiceAccount = class ServiceAccount {
39
40
  id;
@@ -69,6 +70,7 @@ exports.ServiceAccount = ServiceAccount = __decorate([
69
70
  table: 'service_account',
70
71
  schema: schema_1.SCHEMA,
71
72
  access: { plane: 'control', system: true },
73
+ actions: ['manage_keys'],
72
74
  readScope: { kind: 'nodeColumn', column: 'sa_tenant_id' },
73
75
  }),
74
76
  (0, engine_1.PrimaryKey)({ kind: 'uuid', column: 'sa_id' })
@@ -0,0 +1,35 @@
1
+ /**
2
+ * stored_file — the metadata record of one uploaded file (file-storage SPEC §4).
3
+ *
4
+ * The bytes live in the object store under `storageKey` (`t/<tenantId>/<uuid>`, built by the
5
+ * server); this row is what the engine gates, audits and lists. Table DDL:
6
+ * `migrations/1710000000022-CreateStoredFile.cjs` (columns mirror the fields below exactly).
7
+ *
8
+ * ACCESS: `{ tenantScoped: true, owned: true, plane: 'data' }` — tenant business content, owned by
9
+ * the uploader. `plane: 'data'` keeps the capped root out by construction.
10
+ *
11
+ * SERVER-STAMPED: `tenantId` (`trusted: 'tenantId'`) and `ownerId` (`trusted: 'actorId'`) are
12
+ * overwritten from the session on create and never re-stamped on update; client input is ignored.
13
+ *
14
+ * CREATE-ONLY: the five content fields are `immutable` — a patch can never re-point a record at
15
+ * other bytes or change what the bytes claim to be.
16
+ */
17
+ export declare class StoredFile {
18
+ uuid: string;
19
+ /** Server-stamped tenant boundary (engine overwrites from the session; never client). */
20
+ tenantId: string;
21
+ /** Server-stamped uploader (the owner; engine overwrites from the session; never client). */
22
+ ownerId: string;
23
+ /** `t/<tenantId>/<uuid>`, server-built; never returned to the client. */
24
+ storageKey: string;
25
+ /** Lower-case hex sha256 of the stored bytes. */
26
+ sha256: string;
27
+ /** Canonical type from the intake allowlist, never the client header. */
28
+ contentType: string;
29
+ sizeBytes: number;
30
+ /** Sanitized display name. */
31
+ originalName: string;
32
+ /** UTC epoch ms, set by the service. */
33
+ createdAt: number;
34
+ }
35
+ //# sourceMappingURL=stored-file.object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-file.object.d.ts","sourceRoot":"","sources":["../src/stored-file.object.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AACH,qBAOa,UAAU;IAErB,IAAI,EAAG,MAAM,CAAC;IAEd,yFAAyF;IAEzF,QAAQ,EAAG,MAAM,CAAC;IAElB,6FAA6F;IAE7F,OAAO,EAAG,MAAM,CAAC;IAEjB,yEAAyE;IAEzE,UAAU,EAAG,MAAM,CAAC;IAEpB,iDAAiD;IAEjD,MAAM,EAAG,MAAM,CAAC;IAEhB,yEAAyE;IAEzE,WAAW,EAAG,MAAM,CAAC;IAGrB,SAAS,EAAG,MAAM,CAAC;IAEnB,8BAA8B;IAE9B,YAAY,EAAG,MAAM,CAAC;IAEtB,wCAAwC;IAExC,SAAS,EAAG,MAAM,CAAC;CACpB"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.StoredFile = void 0;
13
+ const engine_1 = require("@astram/engine");
14
+ const schema_1 = require("./schema");
15
+ /**
16
+ * stored_file — the metadata record of one uploaded file (file-storage SPEC §4).
17
+ *
18
+ * The bytes live in the object store under `storageKey` (`t/<tenantId>/<uuid>`, built by the
19
+ * server); this row is what the engine gates, audits and lists. Table DDL:
20
+ * `migrations/1710000000022-CreateStoredFile.cjs` (columns mirror the fields below exactly).
21
+ *
22
+ * ACCESS: `{ tenantScoped: true, owned: true, plane: 'data' }` — tenant business content, owned by
23
+ * the uploader. `plane: 'data'` keeps the capped root out by construction.
24
+ *
25
+ * SERVER-STAMPED: `tenantId` (`trusted: 'tenantId'`) and `ownerId` (`trusted: 'actorId'`) are
26
+ * overwritten from the session on create and never re-stamped on update; client input is ignored.
27
+ *
28
+ * CREATE-ONLY: the five content fields are `immutable` — a patch can never re-point a record at
29
+ * other bytes or change what the bytes claim to be.
30
+ */
31
+ let StoredFile = class StoredFile {
32
+ uuid;
33
+ /** Server-stamped tenant boundary (engine overwrites from the session; never client). */
34
+ tenantId;
35
+ /** Server-stamped uploader (the owner; engine overwrites from the session; never client). */
36
+ ownerId;
37
+ /** `t/<tenantId>/<uuid>`, server-built; never returned to the client. */
38
+ storageKey;
39
+ /** Lower-case hex sha256 of the stored bytes. */
40
+ sha256;
41
+ /** Canonical type from the intake allowlist, never the client header. */
42
+ contentType;
43
+ sizeBytes;
44
+ /** Sanitized display name. */
45
+ originalName;
46
+ /** UTC epoch ms, set by the service. */
47
+ createdAt;
48
+ };
49
+ exports.StoredFile = StoredFile;
50
+ __decorate([
51
+ (0, engine_1.Field)({ column: 'sf_uuid', type: 'uuid', role: 'primaryKey' }),
52
+ __metadata("design:type", String)
53
+ ], StoredFile.prototype, "uuid", void 0);
54
+ __decorate([
55
+ (0, engine_1.Field)({ column: 'sf_tenant_id', type: 'uuid', trusted: 'tenantId' }),
56
+ __metadata("design:type", String)
57
+ ], StoredFile.prototype, "tenantId", void 0);
58
+ __decorate([
59
+ (0, engine_1.Field)({ column: 'sf_owner_id', type: 'uuid', trusted: 'actorId' }),
60
+ __metadata("design:type", String)
61
+ ], StoredFile.prototype, "ownerId", void 0);
62
+ __decorate([
63
+ (0, engine_1.Field)({ column: 'sf_storage_key', type: 'string', required: true, immutable: true }),
64
+ __metadata("design:type", String)
65
+ ], StoredFile.prototype, "storageKey", void 0);
66
+ __decorate([
67
+ (0, engine_1.Field)({ column: 'sf_sha256', type: 'string', required: true, immutable: true }),
68
+ __metadata("design:type", String)
69
+ ], StoredFile.prototype, "sha256", void 0);
70
+ __decorate([
71
+ (0, engine_1.Field)({ column: 'sf_content_type', type: 'string', required: true, immutable: true }),
72
+ __metadata("design:type", String)
73
+ ], StoredFile.prototype, "contentType", void 0);
74
+ __decorate([
75
+ (0, engine_1.Field)({ column: 'sf_size_bytes', type: 'number', required: true, immutable: true }),
76
+ __metadata("design:type", Number)
77
+ ], StoredFile.prototype, "sizeBytes", void 0);
78
+ __decorate([
79
+ (0, engine_1.Field)({ column: 'sf_original_name', type: 'string', required: true, immutable: true }),
80
+ __metadata("design:type", String)
81
+ ], StoredFile.prototype, "originalName", void 0);
82
+ __decorate([
83
+ (0, engine_1.Field)({ column: 'sf_created_at', type: 'number', required: true }),
84
+ __metadata("design:type", Number)
85
+ ], StoredFile.prototype, "createdAt", void 0);
86
+ exports.StoredFile = StoredFile = __decorate([
87
+ (0, engine_1.ObjectType)({
88
+ typeKey: 'stored_file',
89
+ table: 'stored_file',
90
+ schema: schema_1.SCHEMA,
91
+ access: { tenantScoped: true, owned: true, plane: 'data' },
92
+ }),
93
+ (0, engine_1.PrimaryKey)({ kind: 'uuid', column: 'sf_uuid' })
94
+ ], StoredFile);
@@ -14,8 +14,14 @@
14
14
  */
15
15
  const { Company, User, Role, Department, Branch } = require('@astram/identity');
16
16
  const { columnForRole, reflectObjectType } = require('@astram/engine');
17
+ const { frameworkSchemasForMigration } = require('@astram/core');
18
+
19
+ // Database names come from `ctx.schemas` (SHIELD_DB_NAMESPACE, ADR-0037); under an older
20
+ // @astram/migrate without it, the default names apply only while the namespace is unset.
21
+ // replacesChecksums: every checksum this file had in a published release (git release tags), so
22
+ // an existing ledger row is accepted and updated, not reported as drift (ADR-0037).
23
+ const replacesChecksums = ['027818f28b12088392ba5f2194a842ef36815aa34b9df7669683c9cdf24c316f'];
17
24
 
18
- const SCHEMA = 'shield_app';
19
25
  const TS = 'TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP';
20
26
 
21
27
  // Reflect the @ObjectType/@Field metadata off each decorated class into its registration
@@ -30,7 +36,9 @@ const BranchReg = reflectObjectType(Branch);
30
36
  // Resolve a column by role from a reflected object registration (single source of truth).
31
37
  const col = (reg, role) => columnForRole(reg, role);
32
38
 
33
- async function up({ query }) {
39
+ async function up(ctx) {
40
+ const { query } = ctx;
41
+ const SCHEMA = frameworkSchemasForMigration(ctx, process.env).app;
34
42
  // companies (the tenant) — hierarchy + type + status.
35
43
  await query(`CREATE TABLE IF NOT EXISTS \`${SCHEMA}\`.\`${CompanyReg.table}\` (
36
44
  ${col(CompanyReg, 'primaryKey')} VARCHAR(36) NOT NULL,
@@ -89,7 +97,9 @@ async function up({ query }) {
89
97
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`);
90
98
  }
91
99
 
92
- async function down({ query }) {
100
+ async function down(ctx) {
101
+ const { query } = ctx;
102
+ const SCHEMA = frameworkSchemasForMigration(ctx, process.env).app;
93
103
  // Reverse dependency order — membership tables (1710000000002) drop first via their
94
104
  // own down(); here drop the catalogs + principal + tenant.
95
105
  for (const t of [BranchReg.table, DepartmentReg.table, RoleReg.table, UserReg.table, CompanyReg.table]) {
@@ -97,4 +107,4 @@ async function down({ query }) {
97
107
  }
98
108
  }
99
109
 
100
- module.exports = { up, down };
110
+ module.exports = { up, down, replacesChecksums };
@@ -15,8 +15,14 @@ const {
15
15
  CompanyMembership, MembershipPosting, CompanyDepartment, CompanyBranch,
16
16
  } = require('@astram/identity');
17
17
  const { columnForRole, reflectObjectType } = require('@astram/engine');
18
+ const { frameworkSchemasForMigration } = require('@astram/core');
19
+
20
+ // Database names come from `ctx.schemas` (SHIELD_DB_NAMESPACE, ADR-0037); under an older
21
+ // @astram/migrate without it, the default names apply only while the namespace is unset.
22
+ // replacesChecksums: every checksum this file had in a published release (git release tags), so
23
+ // an existing ledger row is accepted and updated, not reported as drift (ADR-0037).
24
+ const replacesChecksums = ['a214c2b29d1b21093851d3644581b17757a78e2341b50c67c7b9b3846c5dfc9e'];
18
25
 
19
- const SCHEMA = 'shield_app';
20
26
  const TS = 'TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP';
21
27
 
22
28
  // The decorated classes carry NO static `.table` — @ObjectType/@Field metadata is read
@@ -34,7 +40,9 @@ const CompanyDepartmentReg = reflectObjectType(CompanyDepartment);
34
40
  const CompanyBranchReg = reflectObjectType(CompanyBranch);
35
41
  const col = (reg, role) => columnForRole(reg, role);
36
42
 
37
- async function up({ query }) {
43
+ async function up(ctx) {
44
+ const { query } = ctx;
45
+ const SCHEMA = frameworkSchemasForMigration(ctx, process.env).app;
38
46
  // company_membership — first-class membership + active-tenant pointer.
39
47
  await query(`CREATE TABLE IF NOT EXISTS \`${SCHEMA}\`.\`${CompanyMembershipReg.table}\` (
40
48
  ${col(CompanyMembershipReg, 'primaryKey')} VARCHAR(36) NOT NULL,
@@ -102,10 +110,12 @@ async function up({ query }) {
102
110
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`);
103
111
  }
104
112
 
105
- async function down({ query }) {
113
+ async function down(ctx) {
114
+ const { query } = ctx;
115
+ const SCHEMA = frameworkSchemasForMigration(ctx, process.env).app;
106
116
  for (const t of [MembershipPostingReg.table, CompanyBranchReg.table, CompanyDepartmentReg.table, CompanyMembershipReg.table]) {
107
117
  await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`${t}\``);
108
118
  }
109
119
  }
110
120
 
111
- module.exports = { up, down };
121
+ module.exports = { up, down, replacesChecksums };
@@ -25,9 +25,17 @@
25
25
  * Idempotent (CREATE TABLE IF NOT EXISTS).
26
26
  */
27
27
 
28
- const SCHEMA = 'shield_identity';
28
+ const { frameworkSchemasForMigration } = require('@astram/core');
29
29
 
30
- async function up({ query }) {
30
+ // Database names come from `ctx.schemas` (SHIELD_DB_NAMESPACE, ADR-0037); under an older
31
+ // @astram/migrate without it, the default names apply only while the namespace is unset.
32
+ // replacesChecksums: every checksum this file had in a published release (git release tags), so
33
+ // an existing ledger row is accepted and updated, not reported as drift (ADR-0037).
34
+ const replacesChecksums = ['440923cce54f25764ca53fd68d3e18d7069207b22c3f2afb5551469a0279a1aa'];
35
+
36
+ async function up(ctx) {
37
+ const { query } = ctx;
38
+ const SCHEMA = frameworkSchemasForMigration(ctx, process.env).identity;
31
39
  // identity_credential — one row per login principal. Resolved by
32
40
  // ic_identity_hint (username/email) at login. ic_password_hash is the
33
41
  // Argon2id encoded hash the engine verifies against. Whether the principal
@@ -51,8 +59,10 @@ async function up({ query }) {
51
59
  );
52
60
  }
53
61
 
54
- async function down({ query }) {
62
+ async function down(ctx) {
63
+ const { query } = ctx;
64
+ const SCHEMA = frameworkSchemasForMigration(ctx, process.env).identity;
55
65
  await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`identity_credential\``);
56
66
  }
57
67
 
58
- module.exports = { up, down };
68
+ module.exports = { up, down, replacesChecksums };
@@ -23,9 +23,17 @@
23
23
  * Idempotent (CREATE TABLE IF NOT EXISTS).
24
24
  */
25
25
 
26
- const SCHEMA = 'shield_identity';
26
+ const { frameworkSchemasForMigration } = require('@astram/core');
27
27
 
28
- async function up({ query }) {
28
+ // Database names come from `ctx.schemas` (SHIELD_DB_NAMESPACE, ADR-0037); under an older
29
+ // @astram/migrate without it, the default names apply only while the namespace is unset.
30
+ // replacesChecksums: every checksum this file had in a published release (git release tags), so
31
+ // an existing ledger row is accepted and updated, not reported as drift (ADR-0037).
32
+ const replacesChecksums = ['882c6700cb00a977a1dc5038de0a1e107a279a28312a44359f5c8f8efa595c83'];
33
+
34
+ async function up(ctx) {
35
+ const { query } = ctx;
36
+ const SCHEMA = frameworkSchemasForMigration(ctx, process.env).identity;
29
37
  // session — the authoritative session record (written at login; read/updated
30
38
  // at refresh + revocation). s_absolute_expires_at_ms anchors the ADR-0015
31
39
  // absolute cap (from login, never reset). Status ∈ active|rotated|revoked|expired.
@@ -70,10 +78,12 @@ async function up({ query }) {
70
78
  );
71
79
  }
72
80
 
73
- async function down({ query }) {
81
+ async function down(ctx) {
82
+ const { query } = ctx;
83
+ const SCHEMA = frameworkSchemasForMigration(ctx, process.env).identity;
74
84
  // Child before parent — refresh_token FK-references session.
75
85
  await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`refresh_token\``);
76
86
  await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`session\``);
77
87
  }
78
88
 
79
- module.exports = { up, down };
89
+ module.exports = { up, down, replacesChecksums };
@@ -39,9 +39,17 @@
39
39
  * Idempotent (CREATE TABLE IF NOT EXISTS).
40
40
  */
41
41
 
42
- const SCHEMA = 'shield_identity';
42
+ const { frameworkSchemasForMigration } = require('@astram/core');
43
43
 
44
- async function up({ query }) {
44
+ // Database names come from `ctx.schemas` (SHIELD_DB_NAMESPACE, ADR-0037); under an older
45
+ // @astram/migrate without it, the default names apply only while the namespace is unset.
46
+ // replacesChecksums: every checksum this file had in a published release (git release tags), so
47
+ // an existing ledger row is accepted and updated, not reported as drift (ADR-0037).
48
+ const replacesChecksums = ['47015938e94c86373d0947828f6cb5019aff90d414391eccb8c52b40c81d7612'];
49
+
50
+ async function up(ctx) {
51
+ const { query } = ctx;
52
+ const SCHEMA = frameworkSchemasForMigration(ctx, process.env).identity;
45
53
  await query(
46
54
  `CREATE TABLE IF NOT EXISTS \`${SCHEMA}\`.\`mfa_device\` (
47
55
  md_id VARCHAR(36) NOT NULL,
@@ -79,10 +87,12 @@ async function up({ query }) {
79
87
  );
80
88
  }
81
89
 
82
- async function down({ query }) {
90
+ async function down(ctx) {
91
+ const { query } = ctx;
92
+ const SCHEMA = frameworkSchemasForMigration(ctx, process.env).identity;
83
93
  for (const t of ['mfa_recovery_code', 'password_reset_token', 'mfa_device']) {
84
94
  await query(`DROP TABLE IF EXISTS \`${SCHEMA}\`.\`${t}\``);
85
95
  }
86
96
  }
87
97
 
88
- module.exports = { up, down };
98
+ module.exports = { up, down, replacesChecksums };