@astram/core 1.7.0 → 1.9.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.
@@ -26,6 +26,12 @@ export declare const FRAMEWORK_SCHEMA_SUFFIXES: Readonly<{
26
26
  readonly authz: "_authz";
27
27
  readonly audit: "_audit";
28
28
  }>;
29
+ /** Selects the layout: `four` (default, unset) or `single` (single-database-layout spec §5.A, ADR-0041). */
30
+ export declare const FRAMEWORK_DB_LAYOUT_ENV = "SHIELD_DB_LAYOUT";
31
+ /** The single database name when `SHIELD_DB_LAYOUT=single`. Validated by {@link SCHEMA_NAME_PATTERN}. */
32
+ export declare const FRAMEWORK_DB_NAME_ENV = "SHIELD_DB_NAME";
33
+ /** Must be exactly `1` for the single layout: the operator accepts the reduced isolation. */
34
+ export declare const FRAMEWORK_DB_LAYOUT_ACK_ENV = "SHIELD_DB_LAYOUT_ACK_REDUCED_ISOLATION";
29
35
  /** The resolved framework database names. Always frozen. */
30
36
  export interface FrameworkSchemas {
31
37
  readonly namespace: string;
@@ -38,6 +44,12 @@ export interface FrameworkSchemas {
38
44
  * (which behaves exactly like unset).
39
45
  */
40
46
  readonly isDefault: boolean;
47
+ /**
48
+ * `'single'` when all four modules share one database (`SHIELD_DB_LAYOUT=single`; then
49
+ * `namespace` and the four names all equal `SHIELD_DB_NAME`). Absent in the four-database
50
+ * layout, so today's output is unchanged (single-database-layout spec §5.A, ADR-0041).
51
+ */
52
+ readonly layout?: 'single';
41
53
  }
42
54
  /** Thrown for an invalid framework database configuration. Never carries a secret. */
43
55
  export declare class FrameworkSchemaConfigError extends Error {
@@ -1 +1 @@
1
- {"version":3,"file":"framework-schemas.d.ts","sourceRoot":"","sources":["../../src/database/framework-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,mDAAmD;AACnD,eAAO,MAAM,0BAA0B,wBAAwB,CAAC;AAEhE,8EAA8E;AAC9E,eAAO,MAAM,8BAA8B,WAAW,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,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAChD,SAAS,uBAAuB,EAAE,CAepC"}
@@ -29,6 +29,12 @@ export const FRAMEWORK_SCHEMA_SUFFIXES = Object.freeze({
29
29
  authz: '_authz',
30
30
  audit: '_audit',
31
31
  });
32
+ /** Selects the layout: `four` (default, unset) or `single` (single-database-layout spec §5.A, ADR-0041). */
33
+ export const FRAMEWORK_DB_LAYOUT_ENV = 'SHIELD_DB_LAYOUT';
34
+ /** The single database name when `SHIELD_DB_LAYOUT=single`. Validated by {@link SCHEMA_NAME_PATTERN}. */
35
+ export const FRAMEWORK_DB_NAME_ENV = 'SHIELD_DB_NAME';
36
+ /** Must be exactly `1` for the single layout: the operator accepts the reduced isolation. */
37
+ export const FRAMEWORK_DB_LAYOUT_ACK_ENV = 'SHIELD_DB_LAYOUT_ACK_REDUCED_ISOLATION';
32
38
  /** Thrown for an invalid framework database configuration. Never carries a secret. */
33
39
  export class FrameworkSchemaConfigError extends Error {
34
40
  constructor(message) {
@@ -46,11 +52,42 @@ function namesFor(namespace, isDefault) {
46
52
  isDefault,
47
53
  });
48
54
  }
55
+ // Single layout (single-database-layout spec §5.A): fail closed; values are never echoed.
56
+ function resolveSingle(env) {
57
+ const name = env[FRAMEWORK_DB_NAME_ENV];
58
+ if (typeof name !== 'string' || !SCHEMA_NAME_PATTERN.test(name)) {
59
+ throw new FrameworkSchemaConfigError(`${FRAMEWORK_DB_NAME_ENV} is required and must be a valid database name when ` +
60
+ `${FRAMEWORK_DB_LAYOUT_ENV}=single; expected ${SCHEMA_NAME_PATTERN.source}`);
61
+ }
62
+ if (env[FRAMEWORK_DB_LAYOUT_ACK_ENV] !== '1') {
63
+ throw new FrameworkSchemaConfigError(`${FRAMEWORK_DB_LAYOUT_ACK_ENV}=1 is required when ${FRAMEWORK_DB_LAYOUT_ENV}=single ` +
64
+ '(the single database layout reduces isolation; ADR-0041)');
65
+ }
66
+ if (env[FRAMEWORK_DB_NAMESPACE_ENV] !== undefined) {
67
+ throw new FrameworkSchemaConfigError(`${FRAMEWORK_DB_NAMESPACE_ENV} must not be set when ${FRAMEWORK_DB_LAYOUT_ENV}=single; ` +
68
+ `use ${FRAMEWORK_DB_NAME_ENV}`);
69
+ }
70
+ return Object.freeze({
71
+ namespace: name,
72
+ app: name,
73
+ identity: name,
74
+ authz: name,
75
+ audit: name,
76
+ isDefault: false,
77
+ layout: 'single',
78
+ });
79
+ }
49
80
  /**
50
81
  * Resolve the four framework database names from an env-like record.
51
82
  * @throws FrameworkSchemaConfigError when `SHIELD_DB_NAMESPACE` is set but empty or invalid.
52
83
  */
53
84
  export function resolveFrameworkSchemas(env) {
85
+ const layout = env[FRAMEWORK_DB_LAYOUT_ENV];
86
+ if (layout !== undefined && layout !== 'four' && layout !== 'single') {
87
+ throw new FrameworkSchemaConfigError(`${FRAMEWORK_DB_LAYOUT_ENV} must be "four" or "single" (unset for the default "four")`);
88
+ }
89
+ if (layout === 'single')
90
+ return resolveSingle(env);
54
91
  const raw = env[FRAMEWORK_DB_NAMESPACE_ENV];
55
92
  if (raw === undefined)
56
93
  return namesFor(DEFAULT_FRAMEWORK_DB_NAMESPACE, true);
@@ -104,6 +141,14 @@ export function assertFrameworkSchemaNames(schemas, label) {
104
141
  for (const key of ['app', 'identity', 'authz', 'audit']) {
105
142
  assertSchemaName(schemas[key], `${label}.${key}`);
106
143
  }
144
+ // Four equal names are one database: only the single layout may say so (spec §5.A, ADR-0041).
145
+ const single = schemas.layout === 'single';
146
+ const allEqual = schemas.app === schemas.identity &&
147
+ schemas.app === schemas.authz &&
148
+ schemas.app === schemas.audit;
149
+ if (single !== allEqual) {
150
+ throw new FrameworkSchemaConfigError(`${label} names must be four distinct databases, or one database with layout "single"`);
151
+ }
107
152
  return schemas;
108
153
  }
109
154
  /**
@@ -122,8 +167,16 @@ export function assertFrameworkSchemaNames(schemas, label) {
122
167
  */
123
168
  export function frameworkSchemasForMigration(ctx, env) {
124
169
  const given = ctx?.schemas;
125
- if (given !== undefined)
170
+ // An older migrate (pinned core ignores the layout) may pass four-layout names while the env
171
+ // asks for the single layout: refuse before any DDL (AC-11).
172
+ if (given !== undefined &&
173
+ !(env[FRAMEWORK_DB_LAYOUT_ENV] === 'single' && given.layout !== 'single')) {
126
174
  return assertFrameworkSchemaNames(given, 'ctx.schemas');
175
+ }
176
+ if (env[FRAMEWORK_DB_LAYOUT_ENV] === 'single') {
177
+ throw new FrameworkSchemaConfigError(`${FRAMEWORK_DB_LAYOUT_ENV}=single but this @astram/migrate does not pass ctx.schemas; ` +
178
+ 'upgrade @astram/migrate');
179
+ }
127
180
  const ns = env[FRAMEWORK_DB_NAMESPACE_ENV];
128
181
  if (ns !== undefined && ns !== DEFAULT_FRAMEWORK_DB_NAMESPACE) {
129
182
  throw new FrameworkSchemaConfigError(`${FRAMEWORK_DB_NAMESPACE_ENV} is set but this @astram/migrate does not pass ctx.schemas; ` +
@@ -174,7 +227,15 @@ function ledgerTable(env) {
174
227
  export function resolveMigrationLedgerLocation(schemas, env) {
175
228
  const ddl = env.DDL_DB_NAME;
176
229
  let database;
177
- if (schemas.isDefault) {
230
+ if (schemas.layout === 'single') {
231
+ if (ddl !== undefined && ddl !== schemas.app) {
232
+ throw new FrameworkSchemaConfigError(`DDL_DB_NAME must be ${schemas.app} or unset when ${FRAMEWORK_DB_LAYOUT_ENV}=single ` +
233
+ `(${FRAMEWORK_DB_NAME_ENV}): the migration ledger lives in ${schemas.app} ` +
234
+ '(single-database-layout spec §5.A).');
235
+ }
236
+ database = schemas.app;
237
+ }
238
+ else if (schemas.isDefault) {
178
239
  database =
179
240
  ddl === undefined
180
241
  ? assertSchemaName(schemas.app, 'ledger')
@@ -1 +1 @@
1
- {"version":3,"file":"framework-schemas.js","sourceRoot":"","sources":["../../src/database/framework-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,mDAAmD;AACnD,MAAM,CAAC,MAAM,0BAA0B,GAAG,qBAAqB,CAAC;A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CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAC9E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** Framework tables, keyed by the module whose database holds them in the four layout. Deeply frozen. */
2
+ export declare const FRAMEWORK_TABLES: Readonly<{
3
+ app: readonly string[];
4
+ identity: readonly string[];
5
+ authz: readonly string[];
6
+ audit: readonly string[];
7
+ }>;
8
+ /** Framework stored routines. */
9
+ export declare const FRAMEWORK_ROUTINES: readonly string[];
10
+ /**
11
+ * True when `name` is a framework table or the migration ledger table (case-insensitive: MariaDB
12
+ * table-name case rules vary by platform). `ledgerTable` defaults to `schema_migrations`; a custom
13
+ * ledger name replaces the default.
14
+ */
15
+ export declare function isReservedFrameworkTable(name: string, ledgerTable?: string): boolean;
16
+ //# sourceMappingURL=framework-tables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework-tables.d.ts","sourceRoot":"","sources":["../../src/database/framework-tables.ts"],"names":[],"mappings":"AASA,yGAAyG;AACzG,eAAO,MAAM,gBAAgB;;;;;EAqC3B,CAAC;AAEH,iCAAiC;AACjC,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAmC,CAAC;AAIpF;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,MAAuC,GACnD,OAAO,CAGT"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Framework-owned tables and routines per module (single-database-layout spec §5.A, ADR-0041).
3
+ *
4
+ * In the single layout all four modules share one database, so a table name must not collide
5
+ * with a framework table (or the migration ledger). This list is the one published source.
6
+ * Pure and zero-dep (ADR-0003).
7
+ */
8
+ import { DEFAULT_MIGRATION_LEDGER_TABLE } from './framework-schemas.js';
9
+ /** Framework tables, keyed by the module whose database holds them in the four layout. Deeply frozen. */
10
+ export const FRAMEWORK_TABLES = Object.freeze({
11
+ app: Object.freeze([
12
+ 'companies',
13
+ 'users',
14
+ 'roles',
15
+ 'departments',
16
+ 'branches',
17
+ 'company_membership',
18
+ 'membership_posting',
19
+ 'company_departments',
20
+ 'company_branches',
21
+ 'shared_resource',
22
+ 'service_account',
23
+ 'stored_file',
24
+ ]),
25
+ identity: Object.freeze([
26
+ 'identity_credential',
27
+ 'session',
28
+ 'refresh_token',
29
+ 'mfa_device',
30
+ 'password_reset_token',
31
+ 'mfa_recovery_code',
32
+ 'email_change_token',
33
+ ]),
34
+ authz: Object.freeze([
35
+ 'permission',
36
+ 'role_permission',
37
+ 'authz_permission_version',
38
+ 'access_bundle',
39
+ 'access_bundle_permission',
40
+ 'record_permission_rule',
41
+ 'record_share',
42
+ 'scope_closure',
43
+ 'service_account_key',
44
+ 'cross_tenant_grant',
45
+ ]),
46
+ audit: Object.freeze(['audit_log']),
47
+ });
48
+ /** Framework stored routines. */
49
+ export const FRAMEWORK_ROUTINES = Object.freeze(['prune_audit']);
50
+ const RESERVED = new Set(Object.values(FRAMEWORK_TABLES).flat());
51
+ /**
52
+ * True when `name` is a framework table or the migration ledger table (case-insensitive: MariaDB
53
+ * table-name case rules vary by platform). `ledgerTable` defaults to `schema_migrations`; a custom
54
+ * ledger name replaces the default.
55
+ */
56
+ export function isReservedFrameworkTable(name, ledgerTable = DEFAULT_MIGRATION_LEDGER_TABLE) {
57
+ const n = name.toLowerCase();
58
+ return RESERVED.has(n) || n === ledgerTable.toLowerCase();
59
+ }
60
+ //# sourceMappingURL=framework-tables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework-tables.js","sourceRoot":"","sources":["../../src/database/framework-tables.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,8BAA8B,EAAE,M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kSchemaNameSet, MigrationSchemasContext, } from './framework-schemas.js';
7
7
  export { DEFAULT_FRAMEWORK_DB_NAMESPACE, FRAMEWORK_DB_NAMESPACE_ENV, FRAMEWORK_DB_NAMESPACE_PATTERN, FRAMEWORK_SCHEMA_SUFFIXES, FrameworkSchemaConfigError, frameworkAccountName, resolveFrameworkSchemas, SCHEMA_NAME_PATTERN, assertSchemaName, assertFrameworkSchemaNames, frameworkSchemasForMigration, DEFAULT_MIGRATION_LEDGER_TABLE, MIGRATION_LEDGER_TABLE_PATTERN, resolveMigrationLedgerLocation, LEDGER_DATABASE_NAME_PATTERN, assertLedgerDatabaseName, migrationLedgerCandidates, } from './framework-schemas.js';
8
8
  export type { MigrationLedgerLocation } from './framework-schemas.js';
9
+ export { FRAMEWORK_DB_LAYOUT_ENV, FRAMEWORK_DB_NAME_ENV, FRAMEWORK_DB_LAYOUT_ACK_ENV, } from './framework-schemas.js';
10
+ export { FRAMEWORK_TABLES, FRAMEWORK_ROUTINES, isReservedFrameworkTable, } from './framework-tables.js';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC1B,8BAA8B,EAC9B,yBAAyB,EACzB,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB,EAEvB,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,4BAA4B,EAE5B,8BAA8B,EAC9B,8BAA8B,EAC9B,8BAA8B,EAG9B,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC1B,8BAA8B,EAC9B,yBAAyB,EACzB,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB,EAEvB,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,4BAA4B,EAE5B,8BAA8B,EAC9B,8BAA8B,EAC9B,8BAA8B,EAG9B,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAEL,uBAAuB,EACvB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC"}
@@ -11,4 +11,8 @@ DEFAULT_MIGRATION_LEDGER_TABLE, MIGRATION_LEDGER_TABLE_PATTERN, resolveMigration
11
11
  // G-007 QA P1/P2-3: the boot check's candidate ledger locations and the operator ledger-name
12
12
  // check (append-only).
13
13
  LEDGER_DATABASE_NAME_PATTERN, assertLedgerDatabaseName, migrationLedgerCandidates, } from './framework-schemas.js';
14
+ export {
15
+ // G-008 single-database layout (spec §5.A, ADR-0041; append-only).
16
+ FRAMEWORK_DB_LAYOUT_ENV, FRAMEWORK_DB_NAME_ENV, FRAMEWORK_DB_LAYOUT_ACK_ENV, } from './framework-schemas.js';
17
+ export { FRAMEWORK_TABLES, FRAMEWORK_ROUTINES, isReservedFrameworkTable, } from './framework-tables.js';
14
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC1B,8BAA8B,EAC9B,yBAAyB,EACzB,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB;AACvB,sFAAsF;AACtF,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,4BAA4B;AAC5B,sFAAsF;AACtF,8BAA8B,EAC9B,8BAA8B,EAC9B,8BAA8B;AAC9B,6FAA6F;AAC7F,uBAAuB;AACvB,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC1B,8BAA8B,EAC9B,yBAAyB,EACzB,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB;AACvB,sFAAsF;AACtF,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,EAC1B,4BAA4B;AAC5B,sFAAsF;AACtF,8BAA8B,EAC9B,8BAA8B,EAC9B,8BAA8B;AAC9B,6FAA6F;AAC7F,uBAAuB;AACvB,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAEhC,OAAO;AACL,mEAAmE;AACnE,uBAAuB,EACvB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -44,4 +44,5 @@ export * from './metadata/index.js';
44
44
  export * from './admin/index.js';
45
45
  export * from './storage/index.js';
46
46
  export * from './database/index.js';
47
+ export * from './messaging/index.js';
47
48
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,qBAAqB,CAAC;AAKpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,qBAAqB,CAAC;AAKpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -50,4 +50,6 @@ export * from './admin/index.js';
50
50
  export * from './storage/index.js';
51
51
  // Framework database names (configurable-framework-db, ADR-0037) — append-only.
52
52
  export * from './database/index.js';
53
+ // Message delivery ports (G-010) — append-only.
54
+ export * from './messaging/index.js';
53
55
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,kEAAkE;AAClE,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AAEnC,mFAAmF;AACnF,cAAc,qBAAqB,CAAC;AAEpC,4EAA4E;AAC5E,iFAAiF;AACjF,6EAA6E;AAC7E,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AAEnC,gFAAgF;AAChF,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,kEAAkE;AAClE,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AAEnC,mFAAmF;AACnF,cAAc,qBAAqB,CAAC;AAEpC,4EAA4E;AAC5E,iFAAiF;AACjF,6EAA6E;AAC7E,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AAEnC,gFAAgF;AAChF,cAAc,qBAAqB,CAAC;AAEpC,gDAAgD;AAChD,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Engine seam: **Messaging** — framework messages (password reset, invite, email-change
3
+ * confirmation, security notices) leave through a channel port (G-010,
4
+ * docs/features/message-delivery/SPEC.md). Core defines the ports and the failure class; the
5
+ * provider adapters ship in `@astram/messaging` and guard binds, bounds and audits them.
6
+ *
7
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / fs imports.
8
+ */
9
+ export type { MessageChannel, MessagePurpose, EmailMessage, SmsMessage, WhatsAppMessage, DeliveryReceipt, SendOptions, CancellationSignal, MessageProvider, EmailProvider, SmsProvider, WhatsAppProvider, DeliveryFailureClass, } from './ports.js';
10
+ export { MESSAGE_PURPOSES, MessageDeliveryError, isE164PhoneNumber } from './ports.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messaging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EACV,cAAc,EACd,cAAc,EACd,YAAY,EACZ,UAAU,EACV,eAAe,EACf,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Engine seam: **Messaging** — framework messages (password reset, invite, email-change
3
+ * confirmation, security notices) leave through a channel port (G-010,
4
+ * docs/features/message-delivery/SPEC.md). Core defines the ports and the failure class; the
5
+ * provider adapters ship in `@astram/messaging` and guard binds, bounds and audits them.
6
+ *
7
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / fs imports.
8
+ */
9
+ export { MESSAGE_PURPOSES, MessageDeliveryError, isE164PhoneNumber } from './ports.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messaging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Message delivery ports (G-010, docs/features/message-delivery/SPEC.md R1). One port per channel,
3
+ * each with its own message shape. Adapters (SMTP, Brevo, SendGrid, Mailgun) ship in
4
+ * `@astram/messaging`; guard binds and audits them. SMS and WhatsApp are ports only until users
5
+ * carry phone numbers (OD-1).
6
+ *
7
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / fs imports.
8
+ */
9
+ /** The channels a provider can serve. */
10
+ export type MessageChannel = 'email' | 'sms' | 'whatsapp';
11
+ /** Why the framework sends a message. Recorded on every `message.sent` / `message.failed` row. */
12
+ export declare const MESSAGE_PURPOSES: readonly ["password_reset", "invite", "email_change_confirm", "security_notice"];
13
+ export type MessagePurpose = (typeof MESSAGE_PURPOSES)[number];
14
+ /** An email built by the framework. `html` interpolations are already escaped by the builder. */
15
+ export interface EmailMessage {
16
+ to: string;
17
+ subject: string;
18
+ html: string;
19
+ text: string;
20
+ }
21
+ /** An SMS. `to` is an E.164 number (`isE164PhoneNumber`). */
22
+ export interface SmsMessage {
23
+ to: string;
24
+ text: string;
25
+ }
26
+ /**
27
+ * A WhatsApp business-initiated message. Providers accept only pre-approved templates for these,
28
+ * so the message names a template and its positional parameters instead of free text.
29
+ */
30
+ export interface WhatsAppMessage {
31
+ to: string;
32
+ template: string;
33
+ language: string;
34
+ params: readonly string[];
35
+ }
36
+ /** What a provider returns for an accepted message: its name and its own id, for audit. */
37
+ export interface DeliveryReceipt {
38
+ provider: string;
39
+ messageId?: string;
40
+ }
41
+ /**
42
+ * The part of an `AbortSignal` a provider needs. Core compiles without DOM or Node types, so the
43
+ * port names the shape; a platform `AbortSignal` satisfies it.
44
+ */
45
+ export interface CancellationSignal {
46
+ readonly aborted: boolean;
47
+ addEventListener(type: 'abort', listener: () => void): void;
48
+ }
49
+ /** Per-send options. The signal aborts the send when the caller's bound expires. */
50
+ export interface SendOptions {
51
+ signal: CancellationSignal;
52
+ }
53
+ /**
54
+ * A provider adapter for one channel. `send` resolves with a receipt or rejects with a
55
+ * `MessageDeliveryError`. `probe` checks reachability and credentials WITHOUT sending a message.
56
+ */
57
+ export interface MessageProvider<M> {
58
+ readonly name: string;
59
+ send(message: M, options: SendOptions): Promise<DeliveryReceipt>;
60
+ probe?(options: SendOptions): Promise<void>;
61
+ }
62
+ export type EmailProvider = MessageProvider<EmailMessage>;
63
+ export type SmsProvider = MessageProvider<SmsMessage>;
64
+ export type WhatsAppProvider = MessageProvider<WhatsAppMessage>;
65
+ /**
66
+ * How a send failed. `transient` (network, 429, 5xx) may be retried once; `permanent` (other 4xx,
67
+ * bad credentials, rejected recipient) never is; `timeout` means the bound expired.
68
+ */
69
+ export type DeliveryFailureClass = 'transient' | 'permanent' | 'timeout';
70
+ /**
71
+ * A classified delivery failure. The message is built from fixed parts only (provider name,
72
+ * class, HTTP status): never a provider response body, recipient, token or credential.
73
+ */
74
+ export declare class MessageDeliveryError extends Error {
75
+ readonly failureClass: DeliveryFailureClass;
76
+ readonly provider: string;
77
+ readonly status?: number;
78
+ constructor(failureClass: DeliveryFailureClass, provider: string, detail?: {
79
+ status?: number;
80
+ });
81
+ }
82
+ /** True for an E.164 number: `+`, a non-zero country digit, 7–15 digits in all, nothing else. */
83
+ export declare function isE164PhoneNumber(value: string): boolean;
84
+ //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/messaging/ports.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,yCAAyC;AACzC,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,CAAC;AAE1D,kGAAkG;AAClG,eAAO,MAAM,gBAAgB,kFAKlB,CAAC;AACZ,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,iGAAiG;AACjG,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,6DAA6D;AAC7D,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;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AAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAGvB,YAAY,EAAE,oBAAoB,EAClC,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO;CASnC;AAID,iGAAiG;AACjG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAExD"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Message delivery ports (G-010, docs/features/message-delivery/SPEC.md R1). One port per channel,
3
+ * each with its own message shape. Adapters (SMTP, Brevo, SendGrid, Mailgun) ship in
4
+ * `@astram/messaging`; guard binds and audits them. SMS and WhatsApp are ports only until users
5
+ * carry phone numbers (OD-1).
6
+ *
7
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / fs imports.
8
+ */
9
+ /** Why the framework sends a message. Recorded on every `message.sent` / `message.failed` row. */
10
+ export const MESSAGE_PURPOSES = Object.freeze([
11
+ 'password_reset',
12
+ 'invite',
13
+ 'email_change_confirm',
14
+ 'security_notice',
15
+ ]);
16
+ /**
17
+ * A classified delivery failure. The message is built from fixed parts only (provider name,
18
+ * class, HTTP status): never a provider response body, recipient, token or credential.
19
+ */
20
+ export class MessageDeliveryError extends Error {
21
+ failureClass;
22
+ provider;
23
+ status;
24
+ constructor(failureClass, provider, detail = {}) {
25
+ const status = detail.status !== undefined ? `, HTTP ${detail.status}` : '';
26
+ super(`${provider} delivery failed (${failureClass}${status})`);
27
+ this.name = 'MessageDeliveryError';
28
+ this.failureClass = failureClass;
29
+ this.provider = provider;
30
+ if (detail.status !== undefined)
31
+ this.status = detail.status;
32
+ }
33
+ }
34
+ const E164 = /^\+[1-9]\d{6,14}$/;
35
+ /** True for an E.164 number: `+`, a non-zero country digit, 7–15 digits in all, nothing else. */
36
+ export function isE164PhoneNumber(value) {
37
+ return E164.test(value);
38
+ }
39
+ //# sourceMappingURL=ports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.js","sourceRoot":"","sources":["../../src/messaging/ports.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,kGAAkG;AAClG,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,gBAAgB;IAChB,QAAQ;IACR,sBAAsB;IACtB,iBAAiB;CACT,CAAC,CAAC;AAoEZ;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,YAAY,CAAuB;IACnC,QAAQ,CAAS;IACjB,MAAM,CAAU;IAEzB,YACE,YAAkC,EAClC,QAAgB,EAChB,SAA8B,EAAE;QAEhC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,KAAK,CAAC,GAAG,QAAQ,qBAAqB,YAAY,GAAG,MAAM,GAAG,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/D,CAAC;CACF;AAED,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC,iGAAiG;AACjG,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC"}
@@ -12,7 +12,7 @@
12
12
  * pattern admits no quote, backtick, dot or whitespace.
13
13
  */
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.LEDGER_DATABASE_NAME_PATTERN = exports.MIGRATION_LEDGER_TABLE_PATTERN = exports.DEFAULT_MIGRATION_LEDGER_TABLE = exports.SCHEMA_NAME_PATTERN = exports.FrameworkSchemaConfigError = exports.FRAMEWORK_SCHEMA_SUFFIXES = exports.FRAMEWORK_DB_NAMESPACE_PATTERN = exports.DEFAULT_FRAMEWORK_DB_NAMESPACE = exports.FRAMEWORK_DB_NAMESPACE_ENV = void 0;
15
+ exports.LEDGER_DATABASE_NAME_PATTERN = exports.MIGRATION_LEDGER_TABLE_PATTERN = exports.DEFAULT_MIGRATION_LEDGER_TABLE = exports.SCHEMA_NAME_PATTERN = exports.FrameworkSchemaConfigError = exports.FRAMEWORK_DB_LAYOUT_ACK_ENV = exports.FRAMEWORK_DB_NAME_ENV = exports.FRAMEWORK_DB_LAYOUT_ENV = exports.FRAMEWORK_SCHEMA_SUFFIXES = exports.FRAMEWORK_DB_NAMESPACE_PATTERN = exports.DEFAULT_FRAMEWORK_DB_NAMESPACE = exports.FRAMEWORK_DB_NAMESPACE_ENV = void 0;
16
16
  exports.resolveFrameworkSchemas = resolveFrameworkSchemas;
17
17
  exports.frameworkAccountName = frameworkAccountName;
18
18
  exports.assertSchemaName = assertSchemaName;
@@ -40,6 +40,12 @@ exports.FRAMEWORK_SCHEMA_SUFFIXES = Object.freeze({
40
40
  authz: '_authz',
41
41
  audit: '_audit',
42
42
  });
43
+ /** Selects the layout: `four` (default, unset) or `single` (single-database-layout spec §5.A, ADR-0041). */
44
+ exports.FRAMEWORK_DB_LAYOUT_ENV = 'SHIELD_DB_LAYOUT';
45
+ /** The single database name when `SHIELD_DB_LAYOUT=single`. Validated by {@link SCHEMA_NAME_PATTERN}. */
46
+ exports.FRAMEWORK_DB_NAME_ENV = 'SHIELD_DB_NAME';
47
+ /** Must be exactly `1` for the single layout: the operator accepts the reduced isolation. */
48
+ exports.FRAMEWORK_DB_LAYOUT_ACK_ENV = 'SHIELD_DB_LAYOUT_ACK_REDUCED_ISOLATION';
43
49
  /** Thrown for an invalid framework database configuration. Never carries a secret. */
44
50
  class FrameworkSchemaConfigError extends Error {
45
51
  constructor(message) {
@@ -58,11 +64,42 @@ function namesFor(namespace, isDefault) {
58
64
  isDefault,
59
65
  });
60
66
  }
67
+ // Single layout (single-database-layout spec §5.A): fail closed; values are never echoed.
68
+ function resolveSingle(env) {
69
+ const name = env[exports.FRAMEWORK_DB_NAME_ENV];
70
+ if (typeof name !== 'string' || !exports.SCHEMA_NAME_PATTERN.test(name)) {
71
+ throw new FrameworkSchemaConfigError(`${exports.FRAMEWORK_DB_NAME_ENV} is required and must be a valid database name when ` +
72
+ `${exports.FRAMEWORK_DB_LAYOUT_ENV}=single; expected ${exports.SCHEMA_NAME_PATTERN.source}`);
73
+ }
74
+ if (env[exports.FRAMEWORK_DB_LAYOUT_ACK_ENV] !== '1') {
75
+ throw new FrameworkSchemaConfigError(`${exports.FRAMEWORK_DB_LAYOUT_ACK_ENV}=1 is required when ${exports.FRAMEWORK_DB_LAYOUT_ENV}=single ` +
76
+ '(the single database layout reduces isolation; ADR-0041)');
77
+ }
78
+ if (env[exports.FRAMEWORK_DB_NAMESPACE_ENV] !== undefined) {
79
+ throw new FrameworkSchemaConfigError(`${exports.FRAMEWORK_DB_NAMESPACE_ENV} must not be set when ${exports.FRAMEWORK_DB_LAYOUT_ENV}=single; ` +
80
+ `use ${exports.FRAMEWORK_DB_NAME_ENV}`);
81
+ }
82
+ return Object.freeze({
83
+ namespace: name,
84
+ app: name,
85
+ identity: name,
86
+ authz: name,
87
+ audit: name,
88
+ isDefault: false,
89
+ layout: 'single',
90
+ });
91
+ }
61
92
  /**
62
93
  * Resolve the four framework database names from an env-like record.
63
94
  * @throws FrameworkSchemaConfigError when `SHIELD_DB_NAMESPACE` is set but empty or invalid.
64
95
  */
65
96
  function resolveFrameworkSchemas(env) {
97
+ const layout = env[exports.FRAMEWORK_DB_LAYOUT_ENV];
98
+ if (layout !== undefined && layout !== 'four' && layout !== 'single') {
99
+ throw new FrameworkSchemaConfigError(`${exports.FRAMEWORK_DB_LAYOUT_ENV} must be "four" or "single" (unset for the default "four")`);
100
+ }
101
+ if (layout === 'single')
102
+ return resolveSingle(env);
66
103
  const raw = env[exports.FRAMEWORK_DB_NAMESPACE_ENV];
67
104
  if (raw === undefined)
68
105
  return namesFor(exports.DEFAULT_FRAMEWORK_DB_NAMESPACE, true);
@@ -116,6 +153,14 @@ function assertFrameworkSchemaNames(schemas, label) {
116
153
  for (const key of ['app', 'identity', 'authz', 'audit']) {
117
154
  assertSchemaName(schemas[key], `${label}.${key}`);
118
155
  }
156
+ // Four equal names are one database: only the single layout may say so (spec §5.A, ADR-0041).
157
+ const single = schemas.layout === 'single';
158
+ const allEqual = schemas.app === schemas.identity &&
159
+ schemas.app === schemas.authz &&
160
+ schemas.app === schemas.audit;
161
+ if (single !== allEqual) {
162
+ throw new FrameworkSchemaConfigError(`${label} names must be four distinct databases, or one database with layout "single"`);
163
+ }
119
164
  return schemas;
120
165
  }
121
166
  /**
@@ -134,8 +179,16 @@ function assertFrameworkSchemaNames(schemas, label) {
134
179
  */
135
180
  function frameworkSchemasForMigration(ctx, env) {
136
181
  const given = ctx?.schemas;
137
- if (given !== undefined)
182
+ // An older migrate (pinned core ignores the layout) may pass four-layout names while the env
183
+ // asks for the single layout: refuse before any DDL (AC-11).
184
+ if (given !== undefined &&
185
+ !(env[exports.FRAMEWORK_DB_LAYOUT_ENV] === 'single' && given.layout !== 'single')) {
138
186
  return assertFrameworkSchemaNames(given, 'ctx.schemas');
187
+ }
188
+ if (env[exports.FRAMEWORK_DB_LAYOUT_ENV] === 'single') {
189
+ throw new FrameworkSchemaConfigError(`${exports.FRAMEWORK_DB_LAYOUT_ENV}=single but this @astram/migrate does not pass ctx.schemas; ` +
190
+ 'upgrade @astram/migrate');
191
+ }
139
192
  const ns = env[exports.FRAMEWORK_DB_NAMESPACE_ENV];
140
193
  if (ns !== undefined && ns !== exports.DEFAULT_FRAMEWORK_DB_NAMESPACE) {
141
194
  throw new FrameworkSchemaConfigError(`${exports.FRAMEWORK_DB_NAMESPACE_ENV} is set but this @astram/migrate does not pass ctx.schemas; ` +
@@ -186,7 +239,15 @@ function ledgerTable(env) {
186
239
  function resolveMigrationLedgerLocation(schemas, env) {
187
240
  const ddl = env.DDL_DB_NAME;
188
241
  let database;
189
- if (schemas.isDefault) {
242
+ if (schemas.layout === 'single') {
243
+ if (ddl !== undefined && ddl !== schemas.app) {
244
+ throw new FrameworkSchemaConfigError(`DDL_DB_NAME must be ${schemas.app} or unset when ${exports.FRAMEWORK_DB_LAYOUT_ENV}=single ` +
245
+ `(${exports.FRAMEWORK_DB_NAME_ENV}): the migration ledger lives in ${schemas.app} ` +
246
+ '(single-database-layout spec §5.A).');
247
+ }
248
+ database = schemas.app;
249
+ }
250
+ else if (schemas.isDefault) {
190
251
  database =
191
252
  ddl === undefined
192
253
  ? assertSchemaName(schemas.app, 'ledger')
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FRAMEWORK_ROUTINES = exports.FRAMEWORK_TABLES = void 0;
4
+ exports.isReservedFrameworkTable = isReservedFrameworkTable;
5
+ /**
6
+ * Framework-owned tables and routines per module (single-database-layout spec §5.A, ADR-0041).
7
+ *
8
+ * In the single layout all four modules share one database, so a table name must not collide
9
+ * with a framework table (or the migration ledger). This list is the one published source.
10
+ * Pure and zero-dep (ADR-0003).
11
+ */
12
+ const framework_schemas_js_1 = require("./framework-schemas.js");
13
+ /** Framework tables, keyed by the module whose database holds them in the four layout. Deeply frozen. */
14
+ exports.FRAMEWORK_TABLES = Object.freeze({
15
+ app: Object.freeze([
16
+ 'companies',
17
+ 'users',
18
+ 'roles',
19
+ 'departments',
20
+ 'branches',
21
+ 'company_membership',
22
+ 'membership_posting',
23
+ 'company_departments',
24
+ 'company_branches',
25
+ 'shared_resource',
26
+ 'service_account',
27
+ 'stored_file',
28
+ ]),
29
+ identity: Object.freeze([
30
+ 'identity_credential',
31
+ 'session',
32
+ 'refresh_token',
33
+ 'mfa_device',
34
+ 'password_reset_token',
35
+ 'mfa_recovery_code',
36
+ 'email_change_token',
37
+ ]),
38
+ authz: Object.freeze([
39
+ 'permission',
40
+ 'role_permission',
41
+ 'authz_permission_version',
42
+ 'access_bundle',
43
+ 'access_bundle_permission',
44
+ 'record_permission_rule',
45
+ 'record_share',
46
+ 'scope_closure',
47
+ 'service_account_key',
48
+ 'cross_tenant_grant',
49
+ ]),
50
+ audit: Object.freeze(['audit_log']),
51
+ });
52
+ /** Framework stored routines. */
53
+ exports.FRAMEWORK_ROUTINES = Object.freeze(['prune_audit']);
54
+ const RESERVED = new Set(Object.values(exports.FRAMEWORK_TABLES).flat());
55
+ /**
56
+ * True when `name` is a framework table or the migration ledger table (case-insensitive: MariaDB
57
+ * table-name case rules vary by platform). `ledgerTable` defaults to `schema_migrations`; a custom
58
+ * ledger name replaces the default.
59
+ */
60
+ function isReservedFrameworkTable(name, ledgerTable = framework_schemas_js_1.DEFAULT_MIGRATION_LEDGER_TABLE) {
61
+ const n = name.toLowerCase();
62
+ return RESERVED.has(n) || n === ledgerTable.toLowerCase();
63
+ }
@@ -5,7 +5,7 @@
5
5
  * Pure + zero-dep (ADR-0003).
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.migrationLedgerCandidates = exports.assertLedgerDatabaseName = exports.LEDGER_DATABASE_NAME_PATTERN = exports.resolveMigrationLedgerLocation = exports.MIGRATION_LEDGER_TABLE_PATTERN = exports.DEFAULT_MIGRATION_LEDGER_TABLE = exports.frameworkSchemasForMigration = exports.assertFrameworkSchemaNames = exports.assertSchemaName = exports.SCHEMA_NAME_PATTERN = exports.resolveFrameworkSchemas = exports.frameworkAccountName = exports.FrameworkSchemaConfigError = exports.FRAMEWORK_SCHEMA_SUFFIXES = exports.FRAMEWORK_DB_NAMESPACE_PATTERN = exports.FRAMEWORK_DB_NAMESPACE_ENV = exports.DEFAULT_FRAMEWORK_DB_NAMESPACE = void 0;
8
+ exports.isReservedFrameworkTable = exports.FRAMEWORK_ROUTINES = exports.FRAMEWORK_TABLES = exports.FRAMEWORK_DB_LAYOUT_ACK_ENV = exports.FRAMEWORK_DB_NAME_ENV = exports.FRAMEWORK_DB_LAYOUT_ENV = exports.migrationLedgerCandidates = exports.assertLedgerDatabaseName = exports.LEDGER_DATABASE_NAME_PATTERN = exports.resolveMigrationLedgerLocation = exports.MIGRATION_LEDGER_TABLE_PATTERN = exports.DEFAULT_MIGRATION_LEDGER_TABLE = exports.frameworkSchemasForMigration = exports.assertFrameworkSchemaNames = exports.assertSchemaName = exports.SCHEMA_NAME_PATTERN = exports.resolveFrameworkSchemas = exports.frameworkAccountName = exports.FrameworkSchemaConfigError = exports.FRAMEWORK_SCHEMA_SUFFIXES = exports.FRAMEWORK_DB_NAMESPACE_PATTERN = exports.FRAMEWORK_DB_NAMESPACE_ENV = exports.DEFAULT_FRAMEWORK_DB_NAMESPACE = void 0;
9
9
  var framework_schemas_js_1 = require("./framework-schemas.js");
10
10
  Object.defineProperty(exports, "DEFAULT_FRAMEWORK_DB_NAMESPACE", { enumerable: true, get: function () { return framework_schemas_js_1.DEFAULT_FRAMEWORK_DB_NAMESPACE; } });
11
11
  Object.defineProperty(exports, "FRAMEWORK_DB_NAMESPACE_ENV", { enumerable: true, get: function () { return framework_schemas_js_1.FRAMEWORK_DB_NAMESPACE_ENV; } });
@@ -28,3 +28,12 @@ Object.defineProperty(exports, "resolveMigrationLedgerLocation", { enumerable: t
28
28
  Object.defineProperty(exports, "LEDGER_DATABASE_NAME_PATTERN", { enumerable: true, get: function () { return framework_schemas_js_1.LEDGER_DATABASE_NAME_PATTERN; } });
29
29
  Object.defineProperty(exports, "assertLedgerDatabaseName", { enumerable: true, get: function () { return framework_schemas_js_1.assertLedgerDatabaseName; } });
30
30
  Object.defineProperty(exports, "migrationLedgerCandidates", { enumerable: true, get: function () { return framework_schemas_js_1.migrationLedgerCandidates; } });
31
+ var framework_schemas_js_2 = require("./framework-schemas.js");
32
+ // G-008 single-database layout (spec §5.A, ADR-0041; append-only).
33
+ Object.defineProperty(exports, "FRAMEWORK_DB_LAYOUT_ENV", { enumerable: true, get: function () { return framework_schemas_js_2.FRAMEWORK_DB_LAYOUT_ENV; } });
34
+ Object.defineProperty(exports, "FRAMEWORK_DB_NAME_ENV", { enumerable: true, get: function () { return framework_schemas_js_2.FRAMEWORK_DB_NAME_ENV; } });
35
+ Object.defineProperty(exports, "FRAMEWORK_DB_LAYOUT_ACK_ENV", { enumerable: true, get: function () { return framework_schemas_js_2.FRAMEWORK_DB_LAYOUT_ACK_ENV; } });
36
+ var framework_tables_js_1 = require("./framework-tables.js");
37
+ Object.defineProperty(exports, "FRAMEWORK_TABLES", { enumerable: true, get: function () { return framework_tables_js_1.FRAMEWORK_TABLES; } });
38
+ Object.defineProperty(exports, "FRAMEWORK_ROUTINES", { enumerable: true, get: function () { return framework_tables_js_1.FRAMEWORK_ROUTINES; } });
39
+ Object.defineProperty(exports, "isReservedFrameworkTable", { enumerable: true, get: function () { return framework_tables_js_1.isReservedFrameworkTable; } });
package/dist-cjs/index.js CHANGED
@@ -66,3 +66,5 @@ __exportStar(require("./admin/index.js"), exports);
66
66
  __exportStar(require("./storage/index.js"), exports);
67
67
  // Framework database names (configurable-framework-db, ADR-0037) — append-only.
68
68
  __exportStar(require("./database/index.js"), exports);
69
+ // Message delivery ports (G-010) — append-only.
70
+ __exportStar(require("./messaging/index.js"), exports);
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * Engine seam: **Messaging** — framework messages (password reset, invite, email-change
4
+ * confirmation, security notices) leave through a channel port (G-010,
5
+ * docs/features/message-delivery/SPEC.md). Core defines the ports and the failure class; the
6
+ * provider adapters ship in `@astram/messaging` and guard binds, bounds and audits them.
7
+ *
8
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / fs imports.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.isE164PhoneNumber = exports.MessageDeliveryError = exports.MESSAGE_PURPOSES = void 0;
12
+ var ports_js_1 = require("./ports.js");
13
+ Object.defineProperty(exports, "MESSAGE_PURPOSES", { enumerable: true, get: function () { return ports_js_1.MESSAGE_PURPOSES; } });
14
+ Object.defineProperty(exports, "MessageDeliveryError", { enumerable: true, get: function () { return ports_js_1.MessageDeliveryError; } });
15
+ Object.defineProperty(exports, "isE164PhoneNumber", { enumerable: true, get: function () { return ports_js_1.isE164PhoneNumber; } });
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * Message delivery ports (G-010, docs/features/message-delivery/SPEC.md R1). One port per channel,
4
+ * each with its own message shape. Adapters (SMTP, Brevo, SendGrid, Mailgun) ship in
5
+ * `@astram/messaging`; guard binds and audits them. SMS and WhatsApp are ports only until users
6
+ * carry phone numbers (OD-1).
7
+ *
8
+ * ADR-0003: framework-agnostic — no framework / HTTP / DB / fs imports.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.MessageDeliveryError = exports.MESSAGE_PURPOSES = void 0;
12
+ exports.isE164PhoneNumber = isE164PhoneNumber;
13
+ /** Why the framework sends a message. Recorded on every `message.sent` / `message.failed` row. */
14
+ exports.MESSAGE_PURPOSES = Object.freeze([
15
+ 'password_reset',
16
+ 'invite',
17
+ 'email_change_confirm',
18
+ 'security_notice',
19
+ ]);
20
+ /**
21
+ * A classified delivery failure. The message is built from fixed parts only (provider name,
22
+ * class, HTTP status): never a provider response body, recipient, token or credential.
23
+ */
24
+ class MessageDeliveryError extends Error {
25
+ failureClass;
26
+ provider;
27
+ status;
28
+ constructor(failureClass, provider, detail = {}) {
29
+ const status = detail.status !== undefined ? `, HTTP ${detail.status}` : '';
30
+ super(`${provider} delivery failed (${failureClass}${status})`);
31
+ this.name = 'MessageDeliveryError';
32
+ this.failureClass = failureClass;
33
+ this.provider = provider;
34
+ if (detail.status !== undefined)
35
+ this.status = detail.status;
36
+ }
37
+ }
38
+ exports.MessageDeliveryError = MessageDeliveryError;
39
+ const E164 = /^\+[1-9]\d{6,14}$/;
40
+ /** True for an E.164 number: `+`, a non-zero country digit, 7–15 digits in all, nothing else. */
41
+ function isE164PhoneNumber(value) {
42
+ return E164.test(value);
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astram/core",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "license": "MIT",
5
5
  "description": "Astram framework — sealed security core (Identity, Authentication, Session, Risk, Authorization, Audit). ZERO framework deps — the portable decision brain (ADR-0003). The frozen public contract consumers build against; installed, not edited (ADR-0023).",
6
6
  "type": "module",