@aiquants/governance-drizzle 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +40 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +789 -0
- package/dist/index.d.ts +789 -0
- package/dist/index.js +1 -0
- package/package.json +84 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AI Quants
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @aiquants/governance-drizzle
|
|
2
|
+
|
|
3
|
+
Drizzle ORM models and schema definitions for the Enterprise Knowledge Governance platform (`dbo` schema on Microsoft SQL Server).
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Provides strictly typed Drizzle models for the 3 governance tables:
|
|
8
|
+
|
|
9
|
+
1. `TdDocumentAuthority` (`dbo.td_document_authority`): Bi-temporal document authority tiers (1-5), validity windows (`datetimeoffset(7)`), transaction audit times, and approval status.
|
|
10
|
+
2. `TdPolicyConflicts` (`dbo.td_policy_conflicts`): Detected policy conflicts, diffs (`mssqlJson`), severity, resolution workflow status, and arbitration decisions.
|
|
11
|
+
3. `TdGovernanceGoldenBenchmark` (`dbo.td_governance_golden_benchmark`): Evaluation benchmark queries, expected citations (`mssqlJson<string[]>`), confidentiality levels, and active flags.
|
|
12
|
+
|
|
13
|
+
## Key Features
|
|
14
|
+
|
|
15
|
+
- **Strict DDL Alignment**: 100% synchronized with SQL Server physical DDL schemas, data types, lengths, precisions, nullabilities, and named `PK_*` constraints.
|
|
16
|
+
- **Bi-temporal Timestamp Precision**: `datetimeoffset(7)` for legal/business validity and transaction time; `datetime2(7)` for UTC audit columns.
|
|
17
|
+
- **Single Source of Truth (SSOT)**: Domain types imported from canonical packages (`TenantId` from `@aiquants/enrichment-core`; `AuthorityTier` and `ConfidentialityLevel` from `@aiquants/governance-core`; `ApprovalStatus`, `PolicyConflictSeverity`, and `PolicyConflictResolutionStatus` strictly aligned with SQL Server CHECK constraints).
|
|
18
|
+
- **JSON Column Safety**: `mssqlJson` custom type with zero-allocation base type and fail-fast deserialization on malformed data.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm add @aiquants/governance-drizzle @aiquants/governance-core @aiquants/enrichment-core drizzle-orm
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import {
|
|
30
|
+
TdDocumentAuthority,
|
|
31
|
+
TdPolicyConflicts,
|
|
32
|
+
TdGovernanceGoldenBenchmark,
|
|
33
|
+
type TdDocumentAuthoritySelect,
|
|
34
|
+
type TdPolicyConflictsSelect,
|
|
35
|
+
} from "@aiquants/governance-drizzle"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var mssqlCore=require('drizzle-orm/mssql-core');var o=mssqlCore.mssqlSchema("dbo");var A=o.table("td_document_authority",{id:mssqlCore.bigint("id",{mode:"number"}).identity().notNull(),tenantId:mssqlCore.nvarchar("tenant_id",{length:64}).$type().notNull(),metadataId:mssqlCore.bigint("metadata_id",{mode:"number"}).notNull(),authorityTier:mssqlCore.tinyint("authority_tier").$type().notNull(),policyCategory:mssqlCore.nvarchar("policy_category",{length:50}).notNull(),validFrom:mssqlCore.datetimeoffset("valid_from",{precision:7}).notNull(),validUntil:mssqlCore.datetimeoffset("valid_until",{precision:7}),txCreatedAt:mssqlCore.datetimeoffset("tx_created_at",{precision:7}).notNull(),txSupersededAt:mssqlCore.datetimeoffset("tx_superseded_at",{precision:7}),replacesMetadataId:mssqlCore.bigint("replaces_metadata_id",{mode:"number"}),supersededByMetadataId:mssqlCore.bigint("superseded_by_metadata_id",{mode:"number"}),approvalStatus:mssqlCore.nvarchar("approval_status",{length:20}).$type().notNull(),createdAt:mssqlCore.datetime2("created_at",{precision:7}).notNull(),createdBy:mssqlCore.nvarchar("created_by",{length:100}).notNull(),updatedAt:mssqlCore.datetime2("updated_at",{precision:7}).notNull(),updatedBy:mssqlCore.nvarchar("updated_by",{length:100}).notNull()},t=>[mssqlCore.primaryKey({name:"PK_td_document_authority",columns:[t.id]})]);var _=mssqlCore.customType({dataType(){return "nvarchar(max)"},toDriver(t){return t==null?null:typeof t=="string"?t:JSON.stringify(t)},fromDriver(t){return t==null||t===""?null:typeof t!="string"?t:JSON.parse(t)}}),i=t=>_(t).$type();var B=o.table("td_governance_golden_benchmark",{id:mssqlCore.bigint("id",{mode:"number"}).identity().notNull(),tenantId:mssqlCore.nvarchar("tenant_id",{length:64}).$type().notNull(),caseId:mssqlCore.nvarchar("case_id",{length:64}).notNull(),queryText:mssqlCore.nvarchar("query_text",{length:"max"}).notNull(),category:mssqlCore.nvarchar("category",{length:32}).notNull(),expectedChunkUidsJson:i("expected_chunk_uids_json").notNull(),expectedAnswerKeywordsJson:i("expected_answer_keywords_json"),confidentialityLevel:mssqlCore.nvarchar("confidentiality_level",{length:20}).$type().notNull(),isActive:mssqlCore.bit("is_active").notNull(),createdAt:mssqlCore.datetime2("created_at",{precision:7}).notNull(),createdBy:mssqlCore.nvarchar("created_by",{length:100}).notNull(),updatedAt:mssqlCore.datetime2("updated_at",{precision:7}).notNull(),updatedBy:mssqlCore.nvarchar("updated_by",{length:100}).notNull()},t=>[mssqlCore.primaryKey({name:"PK_td_governance_golden_benchmark",columns:[t.id]})]);var q=o.table("td_policy_conflicts",{id:mssqlCore.bigint("id",{mode:"number"}).identity().notNull(),tenantId:mssqlCore.nvarchar("tenant_id",{length:64}).$type().notNull(),sourceMetadataId:mssqlCore.bigint("source_metadata_id",{mode:"number"}).notNull(),targetMetadataId:mssqlCore.bigint("target_metadata_id",{mode:"number"}).notNull(),conflictSummary:mssqlCore.nvarchar("conflict_summary",{length:1e3}).notNull(),detectedRuleDiff:i("detected_rule_diff"),severity:mssqlCore.nvarchar("severity",{length:20}).$type().notNull(),resolutionStatus:mssqlCore.nvarchar("resolution_status",{length:20}).$type().notNull(),arbitrationDecision:mssqlCore.nvarchar("arbitration_decision",{length:"max"}),resolvedBy:mssqlCore.nvarchar("resolved_by",{length:100}),createdAt:mssqlCore.datetime2("created_at",{precision:7}).notNull(),createdBy:mssqlCore.nvarchar("created_by",{length:100}).notNull(),updatedAt:mssqlCore.datetime2("updated_at",{precision:7}).notNull(),updatedBy:mssqlCore.nvarchar("updated_by",{length:100}).notNull()},t=>[mssqlCore.primaryKey({name:"PK_td_policy_conflicts",columns:[t.id]})]);exports.TdDocumentAuthority=A;exports.TdGovernanceGoldenBenchmark=B;exports.TdPolicyConflicts=q;exports.dbo=o;exports.mssqlJson=i;
|