@venizia/ignis 0.2.0-11 → 0.2.0-12
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/components/auth/models/entities/policy-definition.model.d.ts +29 -0
- package/dist/components/auth/models/entities/policy-definition.model.d.ts.map +1 -1
- package/dist/components/auth/models/entities/policy-definition.model.js +48 -1
- package/dist/components/auth/models/entities/policy-definition.model.js.map +1 -1
- package/package.json +3 -3
|
@@ -22,6 +22,7 @@ declare const buildCommonPolicyDefinitionColumns: <ExtraVariant extends string =
|
|
|
22
22
|
action: import("drizzle-orm/pg-core").PgTextBuilderInitial<"action", [string, ...string[]]>;
|
|
23
23
|
effect: import("drizzle-orm").$Type<import("drizzle-orm/pg-core").PgTextBuilderInitial<"effect", [string, ...string[]]>, TAuthorizationDecision>;
|
|
24
24
|
domain: import("drizzle-orm/pg-core").PgTextBuilderInitial<"domain", [string, ...string[]]>;
|
|
25
|
+
domainType: import("drizzle-orm/pg-core").PgTextBuilderInitial<"domain_type", [string, ...string[]]>;
|
|
25
26
|
metadata: import("drizzle-orm/pg-core").PgJsonbBuilderInitial<"metadata">;
|
|
26
27
|
};
|
|
27
28
|
export type TPolicyDefinitionCommonColumns<ExtraVariant extends string = never> = ReturnType<typeof buildCommonPolicyDefinitionColumns<ExtraVariant>>;
|
|
@@ -30,10 +31,38 @@ type TPolicyDefinitionColumnDef<Opts extends TPolicyDefinitionOptions<string> |
|
|
|
30
31
|
} ? TPolicyDefinitionCommonColumns<TExtraPolicyVariantOf<Opts>> & {
|
|
31
32
|
subjectId: ReturnType<typeof text>;
|
|
32
33
|
targetId: ReturnType<typeof text>;
|
|
34
|
+
domainId: ReturnType<typeof text>;
|
|
33
35
|
} : TPolicyDefinitionCommonColumns<TExtraPolicyVariantOf<Opts>> & {
|
|
34
36
|
subjectId: ReturnType<typeof integer>;
|
|
35
37
|
targetId: ReturnType<typeof integer>;
|
|
38
|
+
domainId: ReturnType<typeof integer>;
|
|
36
39
|
};
|
|
37
40
|
export declare const extraPolicyDefinitionColumns: <const Opts extends TPolicyDefinitionOptions<string> | undefined = undefined>(opts?: Opts) => TPolicyDefinitionColumnDef<Opts>;
|
|
41
|
+
/**
|
|
42
|
+
* The three legal `(domain_type, domain_id)` pairs, as CHECK predicate TEXT for a migration.
|
|
43
|
+
*
|
|
44
|
+
* Text, not a Drizzle `SQL` object, because that is where this constraint actually goes: a column
|
|
45
|
+
* reference inside a Drizzle `sql` template renders schema-qualified (`"table"."column"`), which is
|
|
46
|
+
* not valid inside a table-level CHECK. Migrations here are raw SQL, so the helper matches them.
|
|
47
|
+
*
|
|
48
|
+
* ```sql
|
|
49
|
+
* ALTER TABLE policy_definitions
|
|
50
|
+
* ADD CONSTRAINT policy_definition_domain_shape
|
|
51
|
+
* CHECK (<policyDefinitionDomainShapeCheck()>);
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* Both directions are enforced, because half a constraint still admits half the broken rows: an
|
|
55
|
+
* absent or sentinel type REQUIRES a null id, and a typed domain REQUIRES a non-null one.
|
|
56
|
+
* The `IS NOT NULL` guard on the last branch looks redundant next to `NOT IN` and is not: a NULL
|
|
57
|
+
* `domain_type` makes `NOT IN` evaluate to NULL, and a CHECK only rejects on FALSE - so without it,
|
|
58
|
+
* an id with no type PASSES. Verified against a real Postgres, not reasoned about.
|
|
59
|
+
*
|
|
60
|
+
* `ANY_MEMBER` is refused outright - null already means it, and one state reachable two ways is the
|
|
61
|
+
* bug this column split exists to remove.
|
|
62
|
+
*/
|
|
63
|
+
export declare const policyDefinitionDomainShapeCheck: (opts?: {
|
|
64
|
+
domainTypeColumn?: string;
|
|
65
|
+
domainIdColumn?: string;
|
|
66
|
+
}) => string;
|
|
38
67
|
export {};
|
|
39
68
|
//# sourceMappingURL=policy-definition.model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-definition.model.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/models/entities/policy-definition.model.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAA+B,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"policy-definition.model.d.ts","sourceRoot":"","sources":["../../../../../src/components/auth/models/entities/policy-definition.model.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAA+B,MAAM,uBAAuB,CAAC;AAEjG,OAAO,EAAE,OAAO,EAAS,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,MAAM,wBAAwB,CAAC,YAAY,SAAS,MAAM,GAAG,KAAK,IAAI;IAC1E,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC7B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;CAC7C,CAAC;AAEF,gGAAgG;AAChG,KAAK,qBAAqB,CAAC,IAAI,IAAI,IAAI,SAAS;IAC9C,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,YAAY,SAAS,MAAM,CAAC,CAAC;CAClE,GACG,YAAY,GACZ,KAAK,CAAC;AAEV,iHAAiH;AACjH,QAAA,MAAM,kCAAkC,GAAI,YAAY,SAAS,MAAM,GAAG,KAAK;;;;;;;;;CA4B7E,CAAC;AAEH,MAAM,MAAM,8BAA8B,CAAC,YAAY,SAAS,MAAM,GAAG,KAAK,IAAI,UAAU,CAC1F,OAAO,kCAAkC,CAAC,YAAY,CAAC,CACxD,CAAC;AAEF,KAAK,0BAA0B,CAC7B,IAAI,SAAS,wBAAwB,CAAC,MAAM,CAAC,GAAG,SAAS,GAAG,SAAS,IACnE,IAAI,SAAS;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GACjC,8BAA8B,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,GAAG;IAC5D,SAAS,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;IACnC,QAAQ,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;IAClC,QAAQ,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;CACnC,GACD,8BAA8B,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,GAAG;IAC5D,SAAS,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;IACtC,QAAQ,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;IACrC,QAAQ,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;CACtC,CAAC;AAEN,eAAO,MAAM,4BAA4B,GACvC,KAAK,CAAC,IAAI,SAAS,wBAAwB,CAAC,MAAM,CAAC,GAAG,SAAS,GAAG,SAAS,EAE3E,OAAO,IAAI,KACV,0BAA0B,CAAC,IAAI,CA4BjC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,gCAAgC,GAAI,OAAO;IACtD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,KAAG,MAaH,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extraPolicyDefinitionColumns = void 0;
|
|
3
|
+
exports.policyDefinitionDomainShapeCheck = exports.extraPolicyDefinitionColumns = void 0;
|
|
4
4
|
const core_1 = require("@venizia/ignis-helpers/core");
|
|
5
|
+
const ignis_kernel_1 = require("@venizia/ignis-kernel");
|
|
5
6
|
const pg_core_1 = require("drizzle-orm/pg-core");
|
|
6
7
|
/** Column shape is inferred, never hand-declared, so it can never drift from the `$type<>()` narrowing below. */
|
|
7
8
|
const buildCommonPolicyDefinitionColumns = () => ({
|
|
@@ -16,7 +17,15 @@ const buildCommonPolicyDefinitionColumns = () => ({
|
|
|
16
17
|
// the casbin effect evaluator itself reads this value, so an unknown effect is a correctness
|
|
17
18
|
// bug in enforcement, not a harmless unselected row.
|
|
18
19
|
effect: (0, pg_core_1.text)('effect').$type(),
|
|
20
|
+
// Being replaced by `domain_type` + `domain_id`; still the READ source, so both are written.
|
|
21
|
+
// The two-column form is what `subject`/`target` already use, and what the domain-closure CTE
|
|
22
|
+
// joins on - the concatenated token was the odd one out.
|
|
19
23
|
domain: (0, pg_core_1.text)('domain'),
|
|
24
|
+
// `null` IS `ANY_MEMBER`, not "unknown" - the adapter has always defaulted a null domain to it.
|
|
25
|
+
// A scope literal (`SYSTEM_WIDE`) sits here with a null `domain_id`; a typed domain carries both.
|
|
26
|
+
// `ANY_MEMBER` must never be written here explicitly: two spellings for one state is a bug
|
|
27
|
+
// waiting to happen. `policyDefinitionDomainShapeSql` enforces all three rules as a CHECK.
|
|
28
|
+
domainType: (0, pg_core_1.text)('domain_type'),
|
|
20
29
|
// Nullable: only subset grants populate it, and a consumer may map its own column instead.
|
|
21
30
|
metadata: (0, pg_core_1.jsonb)('metadata'),
|
|
22
31
|
});
|
|
@@ -29,6 +38,7 @@ const extraPolicyDefinitionColumns = (opts) => {
|
|
|
29
38
|
...common,
|
|
30
39
|
subjectId: (0, pg_core_1.integer)('subject_id').notNull(),
|
|
31
40
|
targetId: (0, pg_core_1.integer)('target_id').notNull(),
|
|
41
|
+
domainId: (0, pg_core_1.integer)('domain_id'),
|
|
32
42
|
};
|
|
33
43
|
}
|
|
34
44
|
case 'string': {
|
|
@@ -36,6 +46,7 @@ const extraPolicyDefinitionColumns = (opts) => {
|
|
|
36
46
|
...common,
|
|
37
47
|
subjectId: (0, pg_core_1.text)('subject_id').notNull(),
|
|
38
48
|
targetId: (0, pg_core_1.text)('target_id').notNull(),
|
|
49
|
+
domainId: (0, pg_core_1.text)('domain_id'),
|
|
39
50
|
};
|
|
40
51
|
}
|
|
41
52
|
default: {
|
|
@@ -46,4 +57,40 @@ const extraPolicyDefinitionColumns = (opts) => {
|
|
|
46
57
|
}
|
|
47
58
|
};
|
|
48
59
|
exports.extraPolicyDefinitionColumns = extraPolicyDefinitionColumns;
|
|
60
|
+
/**
|
|
61
|
+
* The three legal `(domain_type, domain_id)` pairs, as CHECK predicate TEXT for a migration.
|
|
62
|
+
*
|
|
63
|
+
* Text, not a Drizzle `SQL` object, because that is where this constraint actually goes: a column
|
|
64
|
+
* reference inside a Drizzle `sql` template renders schema-qualified (`"table"."column"`), which is
|
|
65
|
+
* not valid inside a table-level CHECK. Migrations here are raw SQL, so the helper matches them.
|
|
66
|
+
*
|
|
67
|
+
* ```sql
|
|
68
|
+
* ALTER TABLE policy_definitions
|
|
69
|
+
* ADD CONSTRAINT policy_definition_domain_shape
|
|
70
|
+
* CHECK (<policyDefinitionDomainShapeCheck()>);
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* Both directions are enforced, because half a constraint still admits half the broken rows: an
|
|
74
|
+
* absent or sentinel type REQUIRES a null id, and a typed domain REQUIRES a non-null one.
|
|
75
|
+
* The `IS NOT NULL` guard on the last branch looks redundant next to `NOT IN` and is not: a NULL
|
|
76
|
+
* `domain_type` makes `NOT IN` evaluate to NULL, and a CHECK only rejects on FALSE - so without it,
|
|
77
|
+
* an id with no type PASSES. Verified against a real Postgres, not reasoned about.
|
|
78
|
+
*
|
|
79
|
+
* `ANY_MEMBER` is refused outright - null already means it, and one state reachable two ways is the
|
|
80
|
+
* bug this column split exists to remove.
|
|
81
|
+
*/
|
|
82
|
+
const policyDefinitionDomainShapeCheck = (opts) => {
|
|
83
|
+
const { domainTypeColumn = 'domain_type', domainIdColumn = 'domain_id' } = opts ?? {};
|
|
84
|
+
const { ANY_MEMBER, SYSTEM_WIDE } = ignis_kernel_1.AuthorizationDomainScopes;
|
|
85
|
+
return [
|
|
86
|
+
`(${domainTypeColumn} IS NULL AND ${domainIdColumn} IS NULL)`,
|
|
87
|
+
`OR (${domainTypeColumn} = '${SYSTEM_WIDE}' AND ${domainIdColumn} IS NULL)`,
|
|
88
|
+
`OR (
|
|
89
|
+
${domainTypeColumn} IS NOT NULL
|
|
90
|
+
AND ${domainTypeColumn} NOT IN ('${ANY_MEMBER}', '${SYSTEM_WIDE}')
|
|
91
|
+
AND ${domainIdColumn} IS NOT NULL
|
|
92
|
+
)`,
|
|
93
|
+
].join('\n');
|
|
94
|
+
};
|
|
95
|
+
exports.policyDefinitionDomainShapeCheck = policyDefinitionDomainShapeCheck;
|
|
49
96
|
//# sourceMappingURL=policy-definition.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-definition.model.js","sourceRoot":"","sources":["../../../../../src/components/auth/models/entities/policy-definition.model.ts"],"names":[],"mappings":";;;AAAA,sDAAuD;AAEvD,iDAA2D;AAoB3D,iHAAiH;AACjH,MAAM,kCAAkC,GAAG,GAAwC,EAAE,CAAC,CAAC;IACrF,gGAAgG;IAChG,oDAAoD;IACpD,OAAO,EAAE,IAAA,cAAI,EAAC,SAAS,CAAC,CAAC,KAAK,EAA8C,CAAC,OAAO,EAAE;IACtF,WAAW,EAAE,IAAA,cAAI,EAAC,cAAc,CAAC,CAAC,OAAO,EAAE;IAC3C,UAAU,EAAE,IAAA,cAAI,EAAC,aAAa,CAAC,CAAC,OAAO,EAAE;IAEzC,mGAAmG;IACnG,MAAM,EAAE,IAAA,cAAI,EAAC,QAAQ,CAAC;IAEtB,6FAA6F;IAC7F,6FAA6F;IAC7F,qDAAqD;IACrD,MAAM,EAAE,IAAA,cAAI,EAAC,QAAQ,CAAC,CAAC,KAAK,EAA0B;
|
|
1
|
+
{"version":3,"file":"policy-definition.model.js","sourceRoot":"","sources":["../../../../../src/components/auth/models/entities/policy-definition.model.ts"],"names":[],"mappings":";;;AAAA,sDAAuD;AAEvD,wDAAkE;AAClE,iDAA2D;AAoB3D,iHAAiH;AACjH,MAAM,kCAAkC,GAAG,GAAwC,EAAE,CAAC,CAAC;IACrF,gGAAgG;IAChG,oDAAoD;IACpD,OAAO,EAAE,IAAA,cAAI,EAAC,SAAS,CAAC,CAAC,KAAK,EAA8C,CAAC,OAAO,EAAE;IACtF,WAAW,EAAE,IAAA,cAAI,EAAC,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C,CAAC,OAAO,EAAE;gBACrC,QAAQ,EAAE,IAAA,cAAI,EAAC,WAAW,CAAC;aACQ,CAAC;QACxC,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,IAAA,eAAQ,EAAC;gBACb,OAAO,EAAE,2DAA2D,MAAM,EAAE;aAC7E,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAhCW,QAAA,4BAA4B,gCAgCvC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,MAAM,gCAAgC,GAAG,CAAC,IAGhD,EAAU,EAAE;IACX,MAAM,EAAE,gBAAgB,GAAG,aAAa,EAAE,cAAc,GAAG,WAAW,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;IACtF,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,wCAAyB,CAAC;IAE9D,OAAO;QACL,IAAI,gBAAgB,gBAAgB,cAAc,WAAW;QAC7D,OAAO,gBAAgB,OAAO,WAAW,SAAS,cAAc,WAAW;QAC3E;QACI,gBAAgB;YACZ,gBAAgB,aAAa,UAAU,OAAO,WAAW;YACzD,cAAc;MACpB;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC,CAAC;AAhBW,QAAA,gCAAgC,oCAgB3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ignis",
|
|
3
|
-
"version": "0.2.0-
|
|
3
|
+
"version": "0.2.0-12",
|
|
4
4
|
"description": "High-performance TypeScript server infrastructure combining LoopBack 4 enterprise architecture (decorator-based DI, repository pattern, component system) with Hono speed (~140k req/s). Features auto-generated OpenAPI docs, Drizzle ORM type-safe SQL, JWT/Basic authentication, Casbin authorization, convention-based bootstrapping, and pluggable components for health checks, Swagger UI, mail, Socket.IO, and static assets. Built for Bun and Node.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"access-control",
|
|
@@ -199,11 +199,11 @@
|
|
|
199
199
|
},
|
|
200
200
|
"dependencies": {
|
|
201
201
|
"@venizia/ignis-boot": "^0.2.0-7",
|
|
202
|
-
"@venizia/ignis-connectors": "^0.2.0-
|
|
202
|
+
"@venizia/ignis-connectors": "^0.2.0-12",
|
|
203
203
|
"@venizia/ignis-filter": "^0.2.0-5",
|
|
204
204
|
"@venizia/ignis-helpers": "^0.2.0-8",
|
|
205
205
|
"@venizia/ignis-inversion": "^0.2.0-3",
|
|
206
|
-
"@venizia/ignis-kernel": "^0.2.0-
|
|
206
|
+
"@venizia/ignis-kernel": "^0.2.0-12",
|
|
207
207
|
"lodash": "^4.18.1",
|
|
208
208
|
"reflect-metadata": "^0.2.2",
|
|
209
209
|
"zod": "^4.4.3"
|