@noormdev/sdk 1.0.0-alpha.36 → 1.0.0-alpha.38
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.
- package/dist/index.d.ts +67 -19
- package/dist/index.js +97574 -87
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -70,6 +70,32 @@ export interface ConnectionResult {
|
|
|
70
70
|
* - verbose: All events including debug
|
|
71
71
|
*/
|
|
72
72
|
export type LogLevel = "silent" | "error" | "warn" | "info" | "verbose";
|
|
73
|
+
/**
|
|
74
|
+
* Access policy data model.
|
|
75
|
+
*
|
|
76
|
+
* Roles live on the config, not the actor — the actor is a channel (who is
|
|
77
|
+
* asking), and each config declares what each channel is allowed to do.
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* A config-scoped access level. Ordered loosest to strictest in practice:
|
|
81
|
+
* `viewer` reads only, `operator` writes and confirms destructive ops,
|
|
82
|
+
* `admin` is frictionless.
|
|
83
|
+
*/
|
|
84
|
+
export type Role = "viewer" | "operator" | "admin";
|
|
85
|
+
/**
|
|
86
|
+
* Who is asking — CLI/TUI/SDK callers are `user`, the MCP server is `mcp`.
|
|
87
|
+
* Not an identity system; there are no user accounts.
|
|
88
|
+
*/
|
|
89
|
+
export type Channel = "user" | "mcp";
|
|
90
|
+
/**
|
|
91
|
+
* Per-channel access for a config. `mcp: false` means the config is
|
|
92
|
+
* invisible on the MCP channel — not a role, and never consulted by
|
|
93
|
+
* `checkPolicy` (visibility is enforced upstream of policy).
|
|
94
|
+
*/
|
|
95
|
+
export interface ConfigAccess {
|
|
96
|
+
user: Role;
|
|
97
|
+
mcp: Role | false;
|
|
98
|
+
}
|
|
73
99
|
/**
|
|
74
100
|
* Full configuration object.
|
|
75
101
|
*
|
|
@@ -79,7 +105,7 @@ export type LogLevel = "silent" | "error" | "warn" | "info" | "verbose";
|
|
|
79
105
|
* name: 'dev',
|
|
80
106
|
* type: 'local',
|
|
81
107
|
* isTest: false,
|
|
82
|
-
*
|
|
108
|
+
* access: { user: 'admin', mcp: 'admin' },
|
|
83
109
|
* connection: {
|
|
84
110
|
* dialect: 'postgres',
|
|
85
111
|
* host: 'localhost',
|
|
@@ -95,7 +121,12 @@ export interface Config {
|
|
|
95
121
|
name: string;
|
|
96
122
|
type: "local" | "remote";
|
|
97
123
|
isTest: boolean;
|
|
98
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Per-channel access roles — the source of truth for policy checks
|
|
126
|
+
* (`checkPolicy`/`guarded` from `core/policy`). Every config materialized
|
|
127
|
+
* through `parseConfig`/state load has it populated.
|
|
128
|
+
*/
|
|
129
|
+
access: ConfigAccess;
|
|
99
130
|
connection: ConnectionConfig;
|
|
100
131
|
identity?: string;
|
|
101
132
|
}
|
|
@@ -780,13 +811,6 @@ export interface SchemaValidationResult {
|
|
|
780
811
|
/** Non-blocking warnings about potential issues. */
|
|
781
812
|
warnings: string[];
|
|
782
813
|
}
|
|
783
|
-
/**
|
|
784
|
-
* Settings Types
|
|
785
|
-
*
|
|
786
|
-
* Settings define project-wide build behavior and stage configuration.
|
|
787
|
-
* Unlike encrypted configs (credentials), settings are version controlled
|
|
788
|
-
* and shared across the team via .noorm/settings.yml
|
|
789
|
-
*/
|
|
790
814
|
/**
|
|
791
815
|
* Secret type hints for CLI input handling.
|
|
792
816
|
*
|
|
@@ -822,7 +846,7 @@ export interface StageSecret {
|
|
|
822
846
|
* Stage defaults that can be overridden when creating a config.
|
|
823
847
|
*
|
|
824
848
|
* These provide initial values. Some are enforceable constraints:
|
|
825
|
-
* - protected: true -
|
|
849
|
+
* - protected: true - Clamped as an access ceiling at resolution, not an override-block (`resolver.ts`)
|
|
826
850
|
* - isTest: true - Cannot be overridden to false
|
|
827
851
|
* - dialect - Cannot be changed after creation
|
|
828
852
|
*/
|
|
@@ -835,6 +859,7 @@ export interface StageDefaults {
|
|
|
835
859
|
password?: string;
|
|
836
860
|
ssl?: boolean;
|
|
837
861
|
isTest?: boolean;
|
|
862
|
+
/** Settings-stage vocabulary — distinct from the removed `Config.protected`; see docs/spec/config-access-roles.md. */
|
|
838
863
|
protected?: boolean;
|
|
839
864
|
}
|
|
840
865
|
/**
|
|
@@ -876,7 +901,7 @@ export interface Stage {
|
|
|
876
901
|
export interface RuleMatch {
|
|
877
902
|
/** Config name (exact match) */
|
|
878
903
|
name?: string;
|
|
879
|
-
/**
|
|
904
|
+
/** Settings-stage vocabulary — distinct from the removed `Config.protected`; matched against `guarded(config)`. */
|
|
880
905
|
protected?: boolean;
|
|
881
906
|
/** Test database flag */
|
|
882
907
|
isTest?: boolean;
|
|
@@ -1493,6 +1518,8 @@ export interface BatchChangeOptions extends ChangeOptions {
|
|
|
1493
1518
|
* projectRoot: '/project',
|
|
1494
1519
|
* changesDir: '/project/changes',
|
|
1495
1520
|
* sqlDir: '/project/sql',
|
|
1521
|
+
* access: { user: 'admin', mcp: 'admin' },
|
|
1522
|
+
* channel: 'user',
|
|
1496
1523
|
* }
|
|
1497
1524
|
* ```
|
|
1498
1525
|
*/
|
|
@@ -1509,6 +1536,14 @@ export interface ChangeContext {
|
|
|
1509
1536
|
changesDir: string;
|
|
1510
1537
|
/** Schema directory for resolving .txt references */
|
|
1511
1538
|
sqlDir: string;
|
|
1539
|
+
/**
|
|
1540
|
+
* Config's per-channel access roles. `executeChange`/`revertChange`
|
|
1541
|
+
* gate on this once, at the core seam, so SDK/TUI/CLI callers inherit
|
|
1542
|
+
* one enforcement path instead of re-implementing the check per caller.
|
|
1543
|
+
*/
|
|
1544
|
+
access: ConfigAccess;
|
|
1545
|
+
/** Caller channel for the policy gate — `user` for CLI/TUI/SDK, `mcp` for MCP. */
|
|
1546
|
+
channel: Channel;
|
|
1512
1547
|
/** Config object for template context */
|
|
1513
1548
|
config?: Record<string, unknown>;
|
|
1514
1549
|
/** Secrets for template context */
|
|
@@ -1888,11 +1923,6 @@ declare class ChangeManager {
|
|
|
1888
1923
|
*/
|
|
1889
1924
|
load(name: string): Promise<Change>;
|
|
1890
1925
|
}
|
|
1891
|
-
/**
|
|
1892
|
-
* SDK Types.
|
|
1893
|
-
*
|
|
1894
|
-
* All interfaces and types for the noorm programmatic SDK.
|
|
1895
|
-
*/
|
|
1896
1926
|
/**
|
|
1897
1927
|
* Options for creating an SDK context.
|
|
1898
1928
|
*
|
|
@@ -1932,6 +1962,12 @@ export interface CreateContextOptions {
|
|
|
1932
1962
|
requireTest?: boolean;
|
|
1933
1963
|
/** Stage name for stage defaults (from settings.yml) */
|
|
1934
1964
|
stage?: string;
|
|
1965
|
+
/**
|
|
1966
|
+
* Which caller channel this context represents for access-policy checks
|
|
1967
|
+
* (`checkPolicy` in `src/sdk/guards.ts`). SDK/CLI/TUI callers are `user`;
|
|
1968
|
+
* pass `'mcp'` when the context backs an MCP session. Default: `'user'`.
|
|
1969
|
+
*/
|
|
1970
|
+
channel?: Channel;
|
|
1935
1971
|
}
|
|
1936
1972
|
/**
|
|
1937
1973
|
* Options for build operations.
|
|
@@ -3235,6 +3271,11 @@ export interface TransferOptions {
|
|
|
3235
3271
|
exportPath?: string;
|
|
3236
3272
|
/** Passphrase for .dtzx export encryption. */
|
|
3237
3273
|
passphrase?: string;
|
|
3274
|
+
/**
|
|
3275
|
+
* Caller channel for the `db:reset` policy gate against the
|
|
3276
|
+
* destination config (the write target). Default: `'user'`.
|
|
3277
|
+
*/
|
|
3278
|
+
channel?: Channel;
|
|
3238
3279
|
}
|
|
3239
3280
|
/**
|
|
3240
3281
|
* Plan for a single table transfer.
|
|
@@ -3485,6 +3526,11 @@ export interface UpdateEvents {
|
|
|
3485
3526
|
"update:installing": {
|
|
3486
3527
|
version: string;
|
|
3487
3528
|
};
|
|
3529
|
+
"update:progress": {
|
|
3530
|
+
version: string;
|
|
3531
|
+
received: number;
|
|
3532
|
+
total: number;
|
|
3533
|
+
};
|
|
3488
3534
|
"update:complete": {
|
|
3489
3535
|
previousVersion: string;
|
|
3490
3536
|
newVersion: string;
|
|
@@ -4382,11 +4428,13 @@ export declare class RequireTestError extends Error {
|
|
|
4382
4428
|
constructor(configName: string);
|
|
4383
4429
|
}
|
|
4384
4430
|
/**
|
|
4385
|
-
* Error thrown when
|
|
4431
|
+
* Error thrown when the config's access policy blocks a destructive
|
|
4432
|
+
* operation — either the role denies it outright, or the role requires
|
|
4433
|
+
* confirmation the SDK cannot provide interactively.
|
|
4386
4434
|
*
|
|
4387
4435
|
* @example
|
|
4388
4436
|
* ```typescript
|
|
4389
|
-
* // config.
|
|
4437
|
+
* // config.access.user is 'operator' — db:reset requires confirmation the SDK can't give
|
|
4390
4438
|
* await ctx.noorm.db.truncate() // Throws ProtectedConfigError
|
|
4391
4439
|
* ```
|
|
4392
4440
|
*/
|
|
@@ -4394,7 +4442,7 @@ export declare class ProtectedConfigError extends Error {
|
|
|
4394
4442
|
readonly configName: string;
|
|
4395
4443
|
readonly operation: string;
|
|
4396
4444
|
readonly name: "ProtectedConfigError";
|
|
4397
|
-
constructor(configName: string, operation: string);
|
|
4445
|
+
constructor(configName: string, operation: string, reason?: string);
|
|
4398
4446
|
}
|
|
4399
4447
|
/**
|
|
4400
4448
|
* Create an SDK context for programmatic database access.
|