@mj-biz-apps/contracts-entities 0.1.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.
- package/LICENSE +183 -0
- package/dist/ContractEntity.d.ts +181 -0
- package/dist/ContractEntity.d.ts.map +1 -0
- package/dist/ContractEntity.js +261 -0
- package/dist/ContractEntity.js.map +1 -0
- package/dist/ContractTemplateEntity.d.ts +50 -0
- package/dist/ContractTemplateEntity.d.ts.map +1 -0
- package/dist/ContractTemplateEntity.js +85 -0
- package/dist/ContractTemplateEntity.js.map +1 -0
- package/dist/ContractTemplateModificationEntity.d.ts +46 -0
- package/dist/ContractTemplateModificationEntity.d.ts.map +1 -0
- package/dist/ContractTemplateModificationEntity.js +72 -0
- package/dist/ContractTemplateModificationEntity.js.map +1 -0
- package/dist/ContractTemplateProvisionEntity.d.ts +45 -0
- package/dist/ContractTemplateProvisionEntity.d.ts.map +1 -0
- package/dist/ContractTemplateProvisionEntity.js +73 -0
- package/dist/ContractTemplateProvisionEntity.js.map +1 -0
- package/dist/ContractTypeEntity.d.ts +55 -0
- package/dist/ContractTypeEntity.d.ts.map +1 -0
- package/dist/ContractTypeEntity.js +82 -0
- package/dist/ContractTypeEntity.js.map +1 -0
- package/dist/contract-state.d.ts +49 -0
- package/dist/contract-state.d.ts.map +1 -0
- package/dist/contract-state.js +48 -0
- package/dist/contract-state.js.map +1 -0
- package/dist/generated/entity_subclasses.d.ts +1235 -0
- package/dist/generated/entity_subclasses.d.ts.map +1 -0
- package/dist/generated/entity_subclasses.js +1817 -0
- package/dist/generated/entity_subclasses.js.map +1 -0
- package/dist/generated/remote_operations.d.ts +1145 -0
- package/dist/generated/remote_operations.d.ts.map +1 -0
- package/dist/generated/remote_operations.js +426 -0
- package/dist/generated/remote_operations.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/required-field-prose.d.ts +48 -0
- package/dist/required-field-prose.d.ts.map +1 -0
- package/dist/required-field-prose.js +55 -0
- package/dist/required-field-prose.js.map +1 -0
- package/dist/value-list-validation.d.ts +69 -0
- package/dist/value-list-validation.d.ts.map +1 -0
- package/dist/value-list-validation.js +88 -0
- package/dist/value-list-validation.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The contract lifecycle — the VALUES only. The rule itself lives in SQL.
|
|
3
|
+
*
|
|
4
|
+
* `State` is derived, not stored (D-19 / ERD R-18): four of the old `Status` column's five values
|
|
5
|
+
* were projections of the dates and the two self-FKs, and a stored copy of a projection can only
|
|
6
|
+
* agree or lie. It is derived in exactly ONE place — the `CASE` in the app-owned layered base view
|
|
7
|
+
* (`V202608182001`) — and application code READS `contract.State`. It does not re-derive it.
|
|
8
|
+
*
|
|
9
|
+
* WHY THIS FILE NO LONGER CARRIES THE RULE (Marcelo, 2026-08-19). It used to hold
|
|
10
|
+
* `DeriveContractState()` for TypeScript and `StateSQL()` to render the same rule as T-SQL, on the
|
|
11
|
+
* reasoning that one module rendering both copies could not drift. That reasoning was wrong, and it
|
|
12
|
+
* failed in the most direct way available: the TypeScript branch for termination was tightened to
|
|
13
|
+
* "terminated before today", the view was not, and for several hours the same contract read `Active`
|
|
14
|
+
* in the browser and `Terminated` from every view-backed query. The guard did not fire because it
|
|
15
|
+
* compared the two renderings as TEXT, and text cannot see a semantic split.
|
|
16
|
+
*
|
|
17
|
+
* The lesson is not "write a better guard" — a guard that has to be right about two implementations
|
|
18
|
+
* is a third thing to get wrong. It is: **do not mirror a rule.** One definition, in one language.
|
|
19
|
+
* SQL wins here because the rule is time-dependent (`Expired` and `Active` turn over at midnight with
|
|
20
|
+
* no write to trigger them), so it must be evaluated at READ time, which is what a view does and what
|
|
21
|
+
* no amount of TypeScript can do for a row nobody has loaded.
|
|
22
|
+
*
|
|
23
|
+
* WHAT THAT COSTS, stated plainly: the rule can no longer be tested without a database, so
|
|
24
|
+
* `npx vitest run` cannot cover its semantics. Two things stand in for it. `contract-state.test.ts`
|
|
25
|
+
* asserts the committed migration's `CASE` matches the branches and precedence THIS TEST declares —
|
|
26
|
+
* an expectation owned by the test, checked against the single implementation, so it is not two
|
|
27
|
+
* implementations agreeing with each other. And `test-harnesses/state-equivalence.mjs` runs fixtures
|
|
28
|
+
* covering every state and the termination boundary through the deployed view and asserts the answers
|
|
29
|
+
* a person wrote down.
|
|
30
|
+
*
|
|
31
|
+
* A contract being EDITED therefore shows its last-saved state, not a live projection of unsaved
|
|
32
|
+
* dates. That is deliberate: a chip reacting to an unsaved date asserts something no query would
|
|
33
|
+
* agree with.
|
|
34
|
+
*
|
|
35
|
+
* @module @mj-biz-apps/contracts-entities
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* The six lifecycle states, in precedence order — first match wins (ERD §4.5).
|
|
39
|
+
*
|
|
40
|
+
* Kept in TypeScript because the CLIENT needs the vocabulary (chip colours, a filter pill, a typed
|
|
41
|
+
* `State` accessor) even though it does not own the rule. This is a value list, not a second
|
|
42
|
+
* implementation: nothing here decides which state a contract is in.
|
|
43
|
+
*
|
|
44
|
+
* The order is load-bearing documentation of the view's precedence, and
|
|
45
|
+
* `contract-state.test.ts` asserts the migration's `CASE` still matches it.
|
|
46
|
+
*/
|
|
47
|
+
export const CONTRACT_STATES = ['Terminated', 'Superseded', 'Expired', 'Active', 'Executed', 'Draft'];
|
|
48
|
+
//# sourceMappingURL=contract-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-state.js","sourceRoot":"","sources":["../src/contract-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAU,CAAC"}
|