@mj-biz-apps/contracts-core-entities-server 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.
Files changed (34) hide show
  1. package/LICENSE +183 -0
  2. package/dist/ContractEntityServer.d.ts +352 -0
  3. package/dist/ContractEntityServer.d.ts.map +1 -0
  4. package/dist/ContractEntityServer.js +729 -0
  5. package/dist/ContractEntityServer.js.map +1 -0
  6. package/dist/ContractTemplateEntityServer.d.ts +39 -0
  7. package/dist/ContractTemplateEntityServer.d.ts.map +1 -0
  8. package/dist/ContractTemplateEntityServer.js +99 -0
  9. package/dist/ContractTemplateEntityServer.js.map +1 -0
  10. package/dist/ContractTemplateModificationEntityServer.d.ts +119 -0
  11. package/dist/ContractTemplateModificationEntityServer.d.ts.map +1 -0
  12. package/dist/ContractTemplateModificationEntityServer.js +242 -0
  13. package/dist/ContractTemplateModificationEntityServer.js.map +1 -0
  14. package/dist/ContractTemplateProvisionEntityServer.d.ts +74 -0
  15. package/dist/ContractTemplateProvisionEntityServer.d.ts.map +1 -0
  16. package/dist/ContractTemplateProvisionEntityServer.js +171 -0
  17. package/dist/ContractTemplateProvisionEntityServer.js.map +1 -0
  18. package/dist/ContractTypeEntityServers.d.ts +28 -0
  19. package/dist/ContractTypeEntityServers.d.ts.map +1 -0
  20. package/dist/ContractTypeEntityServers.js +65 -0
  21. package/dist/ContractTypeEntityServers.js.map +1 -0
  22. package/dist/SupersedeOperation.d.ts +53 -0
  23. package/dist/SupersedeOperation.d.ts.map +1 -0
  24. package/dist/SupersedeOperation.js +112 -0
  25. package/dist/SupersedeOperation.js.map +1 -0
  26. package/dist/delete-guard.d.ts +89 -0
  27. package/dist/delete-guard.d.ts.map +1 -0
  28. package/dist/delete-guard.js +107 -0
  29. package/dist/delete-guard.js.map +1 -0
  30. package/dist/index.d.ts +15 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +49 -0
  33. package/dist/index.js.map +1 -0
  34. package/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;;;wCAG4B,IAAI,CAAC,EAAE,mCAAmC,UAAU,IAAI,EACpF,SAAS,EACT,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,0CAA0C,EAAE,EAC9E,IAAI,CAAC,kBAAkB,CAC1B,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACK,KAAK,CAAC,oBAAoB;QAC9B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CACjC;;uDAE2C;QAC3C,yFAAyF;QACzF,yFAAyF;QACzF,0FAA0F;QAC1F,2FAA2F;QAC3F,sDAAsD;QACtD,SAAS,EACT,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,4BAA4B,EAAE,EAC/D,IAAI,CAAC,kBAAkB,CAC1B,CAAC;QAEF,MAAM,QAAQ,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC;QAC3C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACX,2FAA2F;gBACvF,0FAA0F;gBAC1F,gFAAgF,CACvF,CAAC;QACN,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ,CAAA;AA/yBY,oBAAoB;IADhC,aAAa,CAAC,UAAU,EAAE,iCAAiC,CAAC;GAChD,oBAAoB,CA+yBhC;;AAED,yDAAyD;AACzD,MAAM,UAAU,wBAAwB;IACpC,KAAK,oBAAoB,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @fileoverview `ContractTemplateEntityServer` — deleting an agreement version.
3
+ *
4
+ * A template version is a HISTORICAL RECORD: a customer who signed in June 2026 stays bound to the
5
+ * June 2026 version, so the version never goes away. Deleting one that contracts incorporate would
6
+ * erase what those customers actually agreed to. Retiring is a `Status` change on the template's TYPE,
7
+ * not a delete.
8
+ *
9
+ * Both dependencies are reported, not just the first: a template almost always has provisions AND
10
+ * contracts, and being refused twice in a row for two different reasons is the worst version of this.
11
+ *
12
+ * @module @mj-biz-apps/contracts-core-entities-server
13
+ */
14
+ import { type EntityDeleteOptions, ValidationResult } from '@memberjunction/core';
15
+ import { ContractTemplateEntity } from '@mj-biz-apps/contracts-entities';
16
+ export declare class ContractTemplateEntityServer extends ContractTemplateEntity {
17
+ /**
18
+ * PUBLISHING REQUIRES A READABLE VERSION.
19
+ *
20
+ * Publishing is the moment a version stops being editable and starts being referenceable, so it is
21
+ * the right and only moment to insist the standard terms can actually be read. R-12's `IsUsable`
22
+ * says whether they can: a `SourceURL`, or a file linked through `__mj.FileEntityRecordLink`.
23
+ *
24
+ * WHY THIS IS NOT `this.IsUsable`. That field is derived in the view and reflects what was LOADED,
25
+ * so a save that sets `SourceURL` and `Status = 'Published'` together would be judged on the old
26
+ * value and wrongly refused. The URL half is therefore read from the in-memory field and only the
27
+ * file half costs a query — and only when the URL is absent and the record is actually being
28
+ * published, so an ordinary save pays nothing.
29
+ *
30
+ * Server-side because the file half is a cross-entity read the browser has no business doing.
31
+ */
32
+ ValidateAsync(): Promise<ValidationResult>;
33
+ /** Whether a file is attached to this template — the other half of R-12's `IsUsable`. */
34
+ private hasLinkedDocument;
35
+ Delete(options?: EntityDeleteOptions): Promise<boolean>;
36
+ }
37
+ /** Anti-tree-shake anchor — see the note in index.ts. */
38
+ export declare function LoadContractTemplateEntityServer(): void;
39
+ //# sourceMappingURL=ContractTemplateEntityServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractTemplateEntityServer.d.ts","sourceRoot":"","sources":["../src/ContractTemplateEntityServer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAEH,KAAK,mBAAmB,EAGxB,gBAAgB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,sBAAsB,EAAsB,MAAM,iCAAiC,CAAC;AAK7F,qBACa,4BAA6B,SAAQ,sBAAsB;IACpE;;;;;;;;;;;;;;OAcG;IACmB,aAAa,IAAI,OAAO,CAAC,gBAAgB,CAAC;IA2BhE,yFAAyF;YAC3E,iBAAiB;IAoBT,MAAM,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;CAwBhF;AAED,yDAAyD;AACzD,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD"}
@@ -0,0 +1,99 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ /**
8
+ * @fileoverview `ContractTemplateEntityServer` — deleting an agreement version.
9
+ *
10
+ * A template version is a HISTORICAL RECORD: a customer who signed in June 2026 stays bound to the
11
+ * June 2026 version, so the version never goes away. Deleting one that contracts incorporate would
12
+ * erase what those customers actually agreed to. Retiring is a `Status` change on the template's TYPE,
13
+ * not a delete.
14
+ *
15
+ * Both dependencies are reported, not just the first: a template almost always has provisions AND
16
+ * contracts, and being refused twice in a row for two different reasons is the worst version of this.
17
+ *
18
+ * @module @mj-biz-apps/contracts-core-entities-server
19
+ */
20
+ import { BaseEntity, ValidationErrorInfo, ValidationErrorType, } from '@memberjunction/core';
21
+ import { RegisterClass } from '@memberjunction/global';
22
+ import { ContractTemplateEntity, TEMPLATE_PUBLISHED } from '@mj-biz-apps/contracts-entities';
23
+ import { GuardedDelete, plural } from './delete-guard.js';
24
+ /* Extends the SHARED subclass so the one-way-publish rule and the value-list guard reach an API
25
+ * caller too, not just a browser. Same reason `ContractEntityServer extends ContractEntity`. */
26
+ let ContractTemplateEntityServer = class ContractTemplateEntityServer extends ContractTemplateEntity {
27
+ /**
28
+ * PUBLISHING REQUIRES A READABLE VERSION.
29
+ *
30
+ * Publishing is the moment a version stops being editable and starts being referenceable, so it is
31
+ * the right and only moment to insist the standard terms can actually be read. R-12's `IsUsable`
32
+ * says whether they can: a `SourceURL`, or a file linked through `__mj.FileEntityRecordLink`.
33
+ *
34
+ * WHY THIS IS NOT `this.IsUsable`. That field is derived in the view and reflects what was LOADED,
35
+ * so a save that sets `SourceURL` and `Status = 'Published'` together would be judged on the old
36
+ * value and wrongly refused. The URL half is therefore read from the in-memory field and only the
37
+ * file half costs a query — and only when the URL is absent and the record is actually being
38
+ * published, so an ordinary save pays nothing.
39
+ *
40
+ * Server-side because the file half is a cross-entity read the browser has no business doing.
41
+ */
42
+ async ValidateAsync() {
43
+ const result = await super.ValidateAsync();
44
+ const statusField = this.GetFieldByName('Status');
45
+ const publishingNow = String(statusField?.Value ?? '') === TEMPLATE_PUBLISHED &&
46
+ String(statusField?.OldValue ?? '') !== TEMPLATE_PUBLISHED;
47
+ if (!publishingNow)
48
+ return result;
49
+ const hasUrl = String(this.SourceURL ?? '').trim().length > 0;
50
+ if (hasUrl || (await this.hasLinkedDocument()))
51
+ return result;
52
+ result.Success = false;
53
+ result.Errors.push(new ValidationErrorInfo('Status', `"${this.Name ?? this.ID}" cannot be published: it records no source URL and has no attached ` +
54
+ `document, so nobody could read the terms it names. Publishing makes a version referenceable ` +
55
+ `and freezes it, so this is the moment it has to be readable. Add a URL or attach the ` +
56
+ `agreement document first.`, TEMPLATE_PUBLISHED, ValidationErrorType.Failure));
57
+ return result;
58
+ }
59
+ /** Whether a file is attached to this template — the other half of R-12's `IsUsable`. */
60
+ async hasLinkedDocument() {
61
+ const result = await this.RunViewProviderToUse.RunView({
62
+ EntityName: 'MJ: File Entity Record Links',
63
+ ExtraFilter: `EntityID = (SELECT ID FROM __mj.Entity WHERE Name = 'MJ_BizApps_Contracts: Contract Templates') ` +
64
+ `AND RecordID = '${this.ID}'`,
65
+ ResultType: 'count_only',
66
+ }, this.ContextCurrentUser);
67
+ if (!result?.Success) {
68
+ throw new Error(`Could not check whether a document is attached to this agreement version: ` +
69
+ `${result?.ErrorMessage ?? 'unknown error'}. Publishing was not attempted.`);
70
+ }
71
+ return (result.TotalRowCount ?? 0) > 0;
72
+ }
73
+ async Delete(options) {
74
+ return GuardedDelete(this, options, `Template "${this.Name ?? this.ID}" cannot be deleted.`, [
75
+ {
76
+ EntityName: 'MJ_BizApps_Contracts: Contracts',
77
+ Filter: `ContractTemplateID = '${this.ID}'`,
78
+ Describe: (n) => `${plural(n, 'contract')} ${n === 1 ? 'incorporates' : 'incorporate'} this version as ` +
79
+ `${n === 1 ? 'its' : 'their'} standard terms — deleting it would erase what those ` +
80
+ `customers agreed to. A signed version is a historical record; retire the template's type ` +
81
+ `instead of deleting the version.`,
82
+ },
83
+ {
84
+ EntityName: 'MJ_BizApps_Contracts: Contract Template Provisions',
85
+ Filter: `ContractTemplateID = '${this.ID}'`,
86
+ Describe: (n) => `It also still holds ${plural(n, 'provision')}.`,
87
+ },
88
+ ], (o) => super.Delete(o));
89
+ }
90
+ };
91
+ ContractTemplateEntityServer = __decorate([
92
+ RegisterClass(BaseEntity, 'MJ_BizApps_Contracts: Contract Templates')
93
+ ], ContractTemplateEntityServer);
94
+ export { ContractTemplateEntityServer };
95
+ /** Anti-tree-shake anchor — see the note in index.ts. */
96
+ export function LoadContractTemplateEntityServer() {
97
+ void ContractTemplateEntityServer;
98
+ }
99
+ //# sourceMappingURL=ContractTemplateEntityServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractTemplateEntityServer.js","sourceRoot":"","sources":["../src/ContractTemplateEntityServer.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACH,UAAU,EAEV,mBAAmB,EACnB,mBAAmB,GAEtB,MAAM,sBAAs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AAK,CAAC,MAAM,CAAC,CAAC,CAAC,CACzB,CAAC;IACN,CAAC;CACJ,CAAA;AAxFY,4BAA4B;IADxC,aAAa,CAAC,UAAU,EAAE,0CAA0C,CAAC;GACzD,4BAA4B,CAwFxC;;AAED,yDAAyD;AACzD,MAAM,UAAU,gCAAgC;IAC5C,KAAK,4BAA4B,CAAC;AACtC,CAAC"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * @fileoverview `ContractTemplateModificationEntityServer` — the two rules a modification needs that
3
+ * only the server can enforce.
4
+ *
5
+ * Both exist because a modification can be saved on its OWN, not just as part of its contract's
6
+ * graph: the row has a custom form reachable from the editor's Open action (D-22), and admins can
7
+ * reach the generated form directly. Rules that only ran on the parent's save would be bypassed by
8
+ * either path.
9
+ *
10
+ * @module @mj-biz-apps/contracts-core-entities-server
11
+ */
12
+ import { ValidationResult } from '@memberjunction/core';
13
+ import { ContractTemplateModificationEntity } from '@mj-biz-apps/contracts-entities';
14
+ export declare class ContractTemplateModificationEntityServer extends ContractTemplateModificationEntity {
15
+ /**
16
+ * THE PROVISION MUST BELONG TO A TEMPLATE AT OR ABOVE THIS CONTRACT IN THE TREE (R-4).
17
+ *
18
+ * This rule is why the modification row carries no `ContractTemplateID` of its own (ERD R-16). An
19
+ * earlier design stored the template beside the provision, which meant the row could say it
20
+ * modified template B's clause on a contract that incorporates template A — a stored copy of a
21
+ * derivable fact, free to disagree with it. Removing the column made the disagreement impossible
22
+ * to *express*; this check makes the remaining relationship impossible to *violate*.
23
+ *
24
+ * ⚠ THIS COMPARED AGAINST THE CONTRACT'S OWN SINGLE `ContractTemplateID` UNTIL R-4, and that was
25
+ * too narrow — it made the change-order mechanism unusable. A change order carries no template of
26
+ * its own (its type has `TemplateRequired = false`) but is the CHILD of a contract that does, and a
27
+ * modification recorded ON the change order is where the negotiated wording physically lives. Under
28
+ * the old rule every such modification was refused, because the change order's own
29
+ * `ContractTemplateID` is null and the provision's template matched nothing. Ruled by Marcelo
30
+ * 2026-08-20: *"a modification may point at any template at or above it in the tree."*
31
+ *
32
+ * So the comparison is now against the ANCESTOR SET — every template reachable at or above this
33
+ * modification's contract by walking `ParentContractID`. One recursive walk, one row per level, and
34
+ * chains are 1–3 deep; the same shape R-3 uses, bounded the same way for the same reason (an
35
+ * already-corrupt ring must terminate rather than spin).
36
+ *
37
+ * It needs joins the browser has no business doing, so it cannot live on the shared class. The UI
38
+ * never offers an out-of-tree provision anyway — the picker filters by the contract's template
39
+ * (§6.6) — so in normal use this never fires. It is the backstop for the standalone form, an API
40
+ * caller, and a contract whose template was changed after modifications were recorded against the
41
+ * old one.
42
+ *
43
+ * A contract whose whole ancestry carries NO template is exempt rather than rejected: an SOW
44
+ * legitimately has none (Amith, 2026-08-18), and refusing to record what an SOW negotiated because
45
+ * there is no versioned template to check against would block real work to satisfy a rule about a
46
+ * document that does not exist.
47
+ */
48
+ ValidateAsync(): Promise<ValidationResult>;
49
+ /**
50
+ * R-10 — is there ALREADY a saved modification of this provision on this contract?
51
+ *
52
+ * The half the browser cannot answer. `ContractEntity.Validate()` catches duplicates among the rows
53
+ * staged in one graph save with no query; this catches a row colliding with one already in the
54
+ * table, which is the standalone-form and API path — and the path where the user has no sibling
55
+ * rows on screen to notice the collision themselves.
56
+ *
57
+ * `ID <> '<this>'` matters and is easy to forget: without it, every ordinary re-save of an existing
58
+ * modification would find ITSELF and refuse. On a create `this.ID` is a generated UUID that matches
59
+ * no row, so the exclusion is harmless there.
60
+ *
61
+ * `UQ_ContractTemplateModification_Contract_Provision` remains the floor. This exists for the
62
+ * message, which is the reason accounting gives for its own duplicated uniqueness checks.
63
+ */
64
+ private duplicateAlreadySaved;
65
+ /**
66
+ * Force the parent contract's `HasModifications` true after a standalone save.
67
+ *
68
+ * The shared `ContractEntity.Validate()` refuses to CLEAR the flag while rows exist, which covers
69
+ * the graph path. It cannot cover this one: saving a modification directly never runs the
70
+ * contract's validation at all, so a row could be added to a contract still marked unmodified —
71
+ * and that contract then reads as "standard agreement, no need to open the PDF" while carrying a
72
+ * recorded deviation. That is the single most misleading state this app could produce.
73
+ *
74
+ * Done AFTER the save, and only when the save succeeded: the flag should follow the row's
75
+ * existence, not anticipate it. Skipped when the parent already has it set, so the ordinary graph
76
+ * path costs nothing. A failure to update the parent is logged and does NOT fail the save — the
77
+ * modification is the user's work and is correctly stored; the flag is a derived warning, and
78
+ * losing the save to fix a warning would be the wrong trade. The next contract save reconciles it.
79
+ */
80
+ Save(): Promise<boolean>;
81
+ /**
82
+ * Set the parent's flag — THROUGH THE ENTITY, not a raw `UPDATE`.
83
+ *
84
+ * The first version of this did `UPDATE … SET HasModifications = 1`, which worked and was wrong.
85
+ * Rule 4 of this schema is "audit is MJ's": `TrackRecordChanges` is on, and *who marked this
86
+ * contract as modified, and when* is exactly the question someone asks during a dispute over what
87
+ * was agreed. A raw `UPDATE` bypasses `MJ: Record Changes` entirely, so that flip would have been
88
+ * the one state transition in the app with no audit trail — on the field whose whole purpose is to
89
+ * warn a reader that the paper differs from the standard. It also skips cache invalidation, so a
90
+ * long-lived client could keep showing the old value. Caught on review of PR #9.
91
+ *
92
+ * Loading a whole entity to set one bit is more expensive than one statement. That is the right
93
+ * trade here and only here: this runs when a modification is saved OUTSIDE its contract's graph,
94
+ * which is the uncommon path, and it no-ops when the flag is already true — so the ordinary graph
95
+ * save never reaches it.
96
+ */
97
+ private forceParentFlag;
98
+ /**
99
+ * The provision's template name and the contract's tree, when the provision sits outside it.
100
+ * Returns null when it is inside the tree, or when the tree carries no template at all.
101
+ *
102
+ * Returns NAMES rather than a boolean so the message can say which is which — "that provision
103
+ * belongs to the 2024 agreement; this contract and its parents reference the 2026 one" is
104
+ * actionable, where "invalid provision" sends the user back to a picker with no idea what to pick.
105
+ *
106
+ * ONE STATEMENT, not two reads and a comparison in TypeScript. The walk has to happen in SQL
107
+ * (a recursive ancestor set is not something `RunView` can express), and once the query is there
108
+ * anyway, resolving the provision's template in the same statement costs nothing extra. This is a
109
+ * deliberate reversal of the note the previous implementation carried, which preferred two
110
+ * metadata-mediated `RunView`s over one join; that trade made sense when the rule was a
111
+ * single-row equality check and does not survive the rule becoming a tree walk.
112
+ */
113
+ private provisionOutsideContractTemplate;
114
+ /** Narrowing cast to the concrete provider, which is what a server-side subclass always has. */
115
+ private get db();
116
+ }
117
+ /** Anti-tree-shake anchor — see the note in index.ts. */
118
+ export declare function LoadContractTemplateModificationEntityServer(): void;
119
+ //# sourceMappingURL=ContractTemplateModificationEntityServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractTemplateModificationEntityServer.d.ts","sourceRoot":"","sources":["../src/ContractTemplateModificationEntityServer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAOH,gBAAgB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAkB,kCAAkC,EAAE,MAAM,iCAAiC,CAAC;AAYrG,qBACa,wCAAyC,SAAQ,kCAAkC;IAC5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACmB,aAAa,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAqChE;;;;;;;;;;;;;;OAcG;YACW,qBAAqB;IAuBnC;;;;;;;;;;;;;;OAcG;IACmB,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAe9C;;;;;;;;;;;;;;;OAeG;YACW,eAAe;IAkB7B;;;;;;;;;;;;;;OAcG;YACW,gCAAgC;IAkD9C,gGAAgG;IAChG,OAAO,KAAK,EAAE,GAEb;CACJ;AAED,yDAAyD;AACzD,wBAAgB,4CAA4C,IAAI,IAAI,CAEnE"}
@@ -0,0 +1,242 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ /**
8
+ * @fileoverview `ContractTemplateModificationEntityServer` — the two rules a modification needs that
9
+ * only the server can enforce.
10
+ *
11
+ * Both exist because a modification can be saved on its OWN, not just as part of its contract's
12
+ * graph: the row has a custom form reachable from the editor's Open action (D-22), and admins can
13
+ * reach the generated form directly. Rules that only ran on the parent's save would be bypassed by
14
+ * either path.
15
+ *
16
+ * @module @mj-biz-apps/contracts-core-entities-server
17
+ */
18
+ import { BaseEntity, LogError, Metadata, ValidationErrorInfo, ValidationErrorType, } from '@memberjunction/core';
19
+ import { RegisterClass } from '@memberjunction/global';
20
+ import { ContractTemplateModificationEntity } from '@mj-biz-apps/contracts-entities';
21
+ /** Guards an ID before it is interpolated into the ancestor walk. */
22
+ const UUID_SHAPE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
23
+ /*
24
+ * EXTENDS THE SHARED SUBCLASS, not the generated one. It used to extend the generated class directly,
25
+ * which meant the server was the one tier that did NOT get the shared class's rules: a modification
26
+ * saved through GraphQL or the standalone form skipped them, so the useful required-field prose would
27
+ * have reached a browser and not an API caller. The same reason `ContractEntityServer extends
28
+ * ContractEntity` rather than the generated class.
29
+ */
30
+ let ContractTemplateModificationEntityServer = class ContractTemplateModificationEntityServer extends ContractTemplateModificationEntity {
31
+ /**
32
+ * THE PROVISION MUST BELONG TO A TEMPLATE AT OR ABOVE THIS CONTRACT IN THE TREE (R-4).
33
+ *
34
+ * This rule is why the modification row carries no `ContractTemplateID` of its own (ERD R-16). An
35
+ * earlier design stored the template beside the provision, which meant the row could say it
36
+ * modified template B's clause on a contract that incorporates template A — a stored copy of a
37
+ * derivable fact, free to disagree with it. Removing the column made the disagreement impossible
38
+ * to *express*; this check makes the remaining relationship impossible to *violate*.
39
+ *
40
+ * ⚠ THIS COMPARED AGAINST THE CONTRACT'S OWN SINGLE `ContractTemplateID` UNTIL R-4, and that was
41
+ * too narrow — it made the change-order mechanism unusable. A change order carries no template of
42
+ * its own (its type has `TemplateRequired = false`) but is the CHILD of a contract that does, and a
43
+ * modification recorded ON the change order is where the negotiated wording physically lives. Under
44
+ * the old rule every such modification was refused, because the change order's own
45
+ * `ContractTemplateID` is null and the provision's template matched nothing. Ruled by Marcelo
46
+ * 2026-08-20: *"a modification may point at any template at or above it in the tree."*
47
+ *
48
+ * So the comparison is now against the ANCESTOR SET — every template reachable at or above this
49
+ * modification's contract by walking `ParentContractID`. One recursive walk, one row per level, and
50
+ * chains are 1–3 deep; the same shape R-3 uses, bounded the same way for the same reason (an
51
+ * already-corrupt ring must terminate rather than spin).
52
+ *
53
+ * It needs joins the browser has no business doing, so it cannot live on the shared class. The UI
54
+ * never offers an out-of-tree provision anyway — the picker filters by the contract's template
55
+ * (§6.6) — so in normal use this never fires. It is the backstop for the standalone form, an API
56
+ * caller, and a contract whose template was changed after modifications were recorded against the
57
+ * old one.
58
+ *
59
+ * A contract whose whole ancestry carries NO template is exempt rather than rejected: an SOW
60
+ * legitimately has none (Amith, 2026-08-18), and refusing to record what an SOW negotiated because
61
+ * there is no versioned template to check against would block real work to satisfy a rule about a
62
+ * document that does not exist.
63
+ */
64
+ async ValidateAsync() {
65
+ const result = await super.ValidateAsync();
66
+ if (this.ContractID && this.ContractTemplateProvisionID) {
67
+ const mismatch = await this.provisionOutsideContractTemplate();
68
+ if (mismatch) {
69
+ result.Success = false;
70
+ result.Errors.push(new ValidationErrorInfo('ContractTemplateProvisionID', `That provision belongs to "${mismatch.ProvisionTemplate}", but this contract and its ` +
71
+ `parents reference "${mismatch.ContractTemplate}". A modification can only deviate from a ` +
72
+ `provision of an agreement version this contract actually sits under.`, this.ContractTemplateProvisionID, ValidationErrorType.Failure));
73
+ }
74
+ }
75
+ if (this.ContractID && this.ContractTemplateProvisionID && (await this.duplicateAlreadySaved())) {
76
+ result.Success = false;
77
+ result.Errors.push(new ValidationErrorInfo('ContractTemplateProvisionID', `This contract already records a modification for that provision. A contract states ONE ` +
78
+ `negotiated wording per standard clause — edit the existing modification rather than ` +
79
+ `adding a second one.`, this.ContractTemplateProvisionID, ValidationErrorType.Failure));
80
+ }
81
+ return result;
82
+ }
83
+ /**
84
+ * R-10 — is there ALREADY a saved modification of this provision on this contract?
85
+ *
86
+ * The half the browser cannot answer. `ContractEntity.Validate()` catches duplicates among the rows
87
+ * staged in one graph save with no query; this catches a row colliding with one already in the
88
+ * table, which is the standalone-form and API path — and the path where the user has no sibling
89
+ * rows on screen to notice the collision themselves.
90
+ *
91
+ * `ID <> '<this>'` matters and is easy to forget: without it, every ordinary re-save of an existing
92
+ * modification would find ITSELF and refuse. On a create `this.ID` is a generated UUID that matches
93
+ * no row, so the exclusion is harmless there.
94
+ *
95
+ * `UQ_ContractTemplateModification_Contract_Provision` remains the floor. This exists for the
96
+ * message, which is the reason accounting gives for its own duplicated uniqueness checks.
97
+ */
98
+ async duplicateAlreadySaved() {
99
+ const result = await this.RunViewProviderToUse.RunView({
100
+ EntityName: 'MJ_BizApps_Contracts: Contract Template Modifications',
101
+ ExtraFilter: `ContractID = '${this.ContractID}' ` +
102
+ `AND ContractTemplateProvisionID = '${this.ContractTemplateProvisionID}' ` +
103
+ `AND ID <> '${this.ID}'`,
104
+ ResultType: 'count_only',
105
+ }, this.ContextCurrentUser);
106
+ if (!result?.Success) {
107
+ // Must not read as "no duplicate" — that would wave through the collision this guards, and
108
+ // the raw unique-index error would arrive instead of the sentence.
109
+ throw new Error(`Could not check for an existing modification of this provision: ` +
110
+ `${result?.ErrorMessage ?? 'unknown error'}.`);
111
+ }
112
+ return (result.TotalRowCount ?? 0) > 0;
113
+ }
114
+ /**
115
+ * Force the parent contract's `HasModifications` true after a standalone save.
116
+ *
117
+ * The shared `ContractEntity.Validate()` refuses to CLEAR the flag while rows exist, which covers
118
+ * the graph path. It cannot cover this one: saving a modification directly never runs the
119
+ * contract's validation at all, so a row could be added to a contract still marked unmodified —
120
+ * and that contract then reads as "standard agreement, no need to open the PDF" while carrying a
121
+ * recorded deviation. That is the single most misleading state this app could produce.
122
+ *
123
+ * Done AFTER the save, and only when the save succeeded: the flag should follow the row's
124
+ * existence, not anticipate it. Skipped when the parent already has it set, so the ordinary graph
125
+ * path costs nothing. A failure to update the parent is logged and does NOT fail the save — the
126
+ * modification is the user's work and is correctly stored; the flag is a derived warning, and
127
+ * losing the save to fix a warning would be the wrong trade. The next contract save reconciles it.
128
+ */
129
+ async Save() {
130
+ const saved = await super.Save();
131
+ if (saved) {
132
+ try {
133
+ await this.forceParentFlag();
134
+ }
135
+ catch (err) {
136
+ LogError(`Modification ${this.ID} saved, but could not set HasModifications on contract ` +
137
+ `${this.ContractID}: ${err}`);
138
+ }
139
+ }
140
+ return saved;
141
+ }
142
+ /**
143
+ * Set the parent's flag — THROUGH THE ENTITY, not a raw `UPDATE`.
144
+ *
145
+ * The first version of this did `UPDATE … SET HasModifications = 1`, which worked and was wrong.
146
+ * Rule 4 of this schema is "audit is MJ's": `TrackRecordChanges` is on, and *who marked this
147
+ * contract as modified, and when* is exactly the question someone asks during a dispute over what
148
+ * was agreed. A raw `UPDATE` bypasses `MJ: Record Changes` entirely, so that flip would have been
149
+ * the one state transition in the app with no audit trail — on the field whose whole purpose is to
150
+ * warn a reader that the paper differs from the standard. It also skips cache invalidation, so a
151
+ * long-lived client could keep showing the old value. Caught on review of PR #9.
152
+ *
153
+ * Loading a whole entity to set one bit is more expensive than one statement. That is the right
154
+ * trade here and only here: this runs when a modification is saved OUTSIDE its contract's graph,
155
+ * which is the uncommon path, and it no-ops when the flag is already true — so the ordinary graph
156
+ * save never reaches it.
157
+ */
158
+ async forceParentFlag() {
159
+ const md = new Metadata();
160
+ // Typed as the SHARED class, but the ClassFactory hands back ContractEntityServer here — it is
161
+ // registered later, so it wins on the server. That is deliberate: the flag flip should run the
162
+ // contract's own server rules, not bypass them.
163
+ const contract = await md.GetEntityObject('MJ_BizApps_Contracts: Contracts', this.ContextCurrentUser);
164
+ if (!(await contract.Load(this.ContractID))) {
165
+ throw new Error(`contract ${this.ContractID} could not be loaded`);
166
+ }
167
+ // Already true is the common case — leave it alone rather than writing a Record Change that
168
+ // says nothing happened.
169
+ if (contract.HasModifications === true)
170
+ return;
171
+ contract.HasModifications = true;
172
+ if (!(await contract.Save())) {
173
+ throw new Error(contract.LatestResult?.Message ?? 'save returned false');
174
+ }
175
+ }
176
+ /**
177
+ * The provision's template name and the contract's tree, when the provision sits outside it.
178
+ * Returns null when it is inside the tree, or when the tree carries no template at all.
179
+ *
180
+ * Returns NAMES rather than a boolean so the message can say which is which — "that provision
181
+ * belongs to the 2024 agreement; this contract and its parents reference the 2026 one" is
182
+ * actionable, where "invalid provision" sends the user back to a picker with no idea what to pick.
183
+ *
184
+ * ONE STATEMENT, not two reads and a comparison in TypeScript. The walk has to happen in SQL
185
+ * (a recursive ancestor set is not something `RunView` can express), and once the query is there
186
+ * anyway, resolving the provision's template in the same statement costs nothing extra. This is a
187
+ * deliberate reversal of the note the previous implementation carried, which preferred two
188
+ * metadata-mediated `RunView`s over one join; that trade made sense when the rule was a
189
+ * single-row equality check and does not survive the rule becoming a tree walk.
190
+ */
191
+ async provisionOutsideContractTemplate() {
192
+ if (!UUID_SHAPE.test(this.ContractID) || !UUID_SHAPE.test(this.ContractTemplateProvisionID)) {
193
+ throw new Error(`Refusing to check the provision's template: '${this.ContractID}' or ` +
194
+ `'${this.ContractTemplateProvisionID}' is not a UUID.`);
195
+ }
196
+ const rows = await this.db.ExecuteSQL(`WITH ancestry AS (
197
+ SELECT [ID], [ParentContractID], [ContractTemplateID], 1 AS Depth
198
+ FROM __mj_BizAppsContracts.[Contract]
199
+ WHERE [ID] = '${this.ContractID}'
200
+ UNION ALL
201
+ SELECT c.[ID], c.[ParentContractID], c.[ContractTemplateID], a.Depth + 1
202
+ FROM __mj_BizAppsContracts.[Contract] c
203
+ JOIN ancestry a ON c.[ID] = a.[ParentContractID]
204
+ WHERE a.Depth < 50
205
+ ),
206
+ tmpl AS (
207
+ SELECT DISTINCT t.[ID], t.[Name]
208
+ FROM ancestry a
209
+ JOIN __mj_BizAppsContracts.[ContractTemplate] t ON t.[ID] = a.[ContractTemplateID]
210
+ )
211
+ SELECT
212
+ CAST(pt.[ID] AS NVARCHAR(36)) AS ProvisionTemplateID,
213
+ pt.[Name] AS ProvisionTemplate,
214
+ (SELECT STRING_AGG(x.[Name], N', ') FROM tmpl x) AS AncestorTemplates,
215
+ CASE WHEN EXISTS (SELECT 1 FROM tmpl x WHERE x.[ID] = pt.[ID])
216
+ THEN 1 ELSE 0 END AS InTree
217
+ FROM __mj_BizAppsContracts.[ContractTemplateProvision] p
218
+ JOIN __mj_BizAppsContracts.[ContractTemplate] pt ON pt.[ID] = p.[ContractTemplateID]
219
+ WHERE p.[ID] = '${this.ContractTemplateProvisionID}';`, undefined, { isMutation: false, description: 'R-4 provision-in-ancestor-templates check' }, this.ContextCurrentUser);
220
+ const row = rows?.[0];
221
+ // No provision row, or it is inside the tree: nothing to say.
222
+ if (!row || row.InTree === 1)
223
+ return null;
224
+ // The whole ancestry carries no template — the SOW case, exempt by ruling.
225
+ if (!row.AncestorTemplates)
226
+ return null;
227
+ return { ProvisionTemplate: row.ProvisionTemplate, ContractTemplate: row.AncestorTemplates };
228
+ }
229
+ /** Narrowing cast to the concrete provider, which is what a server-side subclass always has. */
230
+ get db() {
231
+ return this.ProviderToUse;
232
+ }
233
+ };
234
+ ContractTemplateModificationEntityServer = __decorate([
235
+ RegisterClass(BaseEntity, 'MJ_BizApps_Contracts: Contract Template Modifications')
236
+ ], ContractTemplateModificationEntityServer);
237
+ export { ContractTemplateModificationEntityServer };
238
+ /** Anti-tree-shake anchor — see the note in index.ts. */
239
+ export function LoadContractTemplateModificationEntityServer() {
240
+ void ContractTemplateModificationEntityServer;
241
+ }
242
+ //# sourceMappingURL=ContractTemplateModificationEntityServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractTemplateModificationEntityServer.js","sourceRoot":"","sources":["../src/ContractTemplateModificationEntityServer.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACH,UAAU,EAEV,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,mBAAmB,GAEtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAkB,kCAAkC,EAAE,MAAM,iCAAiC,CAAC;AAErG,qEAAqE;AACrE,MAAM,UAAU,GAAG,+EAA+E,CAAC;AAEnG;;;;;;GAMG;AAEI,IAAM,wCAAwC,GAA9C,MAAM,wCAAyC,SAAQ,kCAAkC;IAC5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACa,KAAK,CAAC,aAAa;QAC/B,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,aAAa,EAAE,CAAC;QAE3C,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,2BAA2B,EAAE,CAAC;YACtD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,gCAAgC,EAAE,CAAC;YAC/D,IAAI,QAAQ,EAAE,CAAC;gBACX,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;gBACvB,MAAM,CAAC,MAAM,CAAC,IAAI,CACd,IAAI,mBAAmB,CACnB,6BAA6B,EAC7B,8BAA8B,QAAQ,CAAC,iBAAiB,+BAA+B;oBACnF,sBAAsB,QAAQ,CAAC,gBAAgB,4CAA4C;oBAC3F,sEAAsE,EAC1E,IAAI,CAAC,2BAA2B,EAChC,mBAAmB,CAAC,OAAO,CAC9B,CACJ,CAAC;YACN,CAAC;QACL,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,2BAA2B,IAAI,CAAC,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC,EAAE,CAAC;YAC9F,MAAM,CAAC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AU;;;;;;;;;;;;;;;;;;;;gCAoBjB,IAAI,CAAC,2BAA2B,IAAI,EACxD,SAAS,EACT,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,2CAA2C,EAAE,EAC/E,IAAI,CAAC,kBAAkB,CAC1B,CAAC;QAEF,MAAM,GAAG,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACtB,8DAA8D;QAC9D,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAC1C,2EAA2E;QAC3E,IAAI,CAAC,GAAG,CAAC,iBAAiB;YAAE,OAAO,IAAI,CAAC;QACxC,OAAO,EAAE,iBAAiB,EAAE,GAAG,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,GAAG,CAAC,iBAAiB,EAAE,CAAC;IACjG,CAAC;IAED,gGAAgG;IAChG,IAAY,EAAE;QACV,OAAO,IAAI,CAAC,aAAgD,CAAC;IACjE,CAAC;CACJ,CAAA;AAlPY,wCAAwC;IADpD,aAAa,CAAC,UAAU,EAAE,uDAAuD,CAAC;GACtE,wCAAwC,CAkPpD;;AAED,yDAAyD;AACzD,MAAM,UAAU,4CAA4C;IACxD,KAAK,wCAAwC,CAAC;AAClD,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @fileoverview `ContractTemplateProvisionEntityServer` — a signed clause is a historical record.
3
+ *
4
+ * Two rules, both about the same fact: once a contract incorporates a template, that template's
5
+ * provisions are what somebody agreed to.
6
+ *
7
+ * **R-1** the TERMS (`ProvisionNumber`, `Title`, `ProvisionText`) cannot change, and the provision
8
+ * cannot be deleted, while any contract references its template.
9
+ * **R-8** and independently of R-1, a provision cannot be deleted while modifications cite it.
10
+ *
11
+ * ## The trigger is the floor; this class exists for the sentence
12
+ *
13
+ * `trg_ContractTemplateProvision_Immutability` (V202608200100) enforces R-1 against ANY writer — raw
14
+ * SQL, a future service, another app, a data load — because rewriting signed terms is the case where a
15
+ * bypass is silent corruption rather than a bad edit in our own UI. What a trigger cannot do is
16
+ * explain itself: it reaches the user as a raw SQL error naming no field.
17
+ *
18
+ * **That is not a nicety here, it is a correctness requirement for R-8.** R-8's whole point is that a
19
+ * refused delete reads as a sentence instead of a constraint. If this class checked only the
20
+ * modification dependency and let the trigger catch the template-referenced case, then deleting an
21
+ * unmodified provision of a referenced template would sail past the guard and die in the database —
22
+ * producing exactly the raw error R-8 was written to eliminate. So the code half must cover **both**
23
+ * conditions the trigger covers, or the guard has a hole shaped like the trigger.
24
+ *
25
+ * @module @mj-biz-apps/contracts-core-entities-server
26
+ */
27
+ import { type EntityDeleteOptions, ValidationResult } from '@memberjunction/core';
28
+ import { ContractTemplateProvisionEntity } from '@mj-biz-apps/contracts-entities';
29
+ export declare class ContractTemplateProvisionEntityServer extends ContractTemplateProvisionEntity {
30
+ /**
31
+ * R-1 — refuse an edit to the terms of a provision whose template is referenced.
32
+ *
33
+ * Gated on `IsSaved` (a provision being created cannot have been agreed to yet) and on a field
34
+ * actually being dirty, so the ordinary save of an unreferenced or cosmetically-edited provision
35
+ * pays **nothing** — no probe at all. The reference count runs only when a frozen field really
36
+ * changed, which is the shape that makes belt-and-braces affordable.
37
+ *
38
+ * Compares `OldValue` to `Value` in memory rather than probing the database, for the same reason
39
+ * `GLAccountEntityServer` does: the entity already knows what it loaded. One error per changed
40
+ * field, each naming that field, so the form marks the offending input rather than showing a banner.
41
+ */
42
+ ValidateAsync(): Promise<ValidationResult>;
43
+ /**
44
+ * Both delete conditions — R-8's modifications, and R-1's referenced template.
45
+ *
46
+ * Reported together rather than first-wins, so someone is not refused twice for two reasons.
47
+ */
48
+ Delete(options?: EntityDeleteOptions): Promise<boolean>;
49
+ /**
50
+ * Whether a field's value differs from what was loaded.
51
+ *
52
+ * Trimmed string comparison: `ProvisionText` is free text, and MJ round-trips trailing whitespace
53
+ * inconsistently enough that treating `"x "` as an edit to `"x"` would refuse a save nobody meant
54
+ * to make. The trigger uses exact comparison, so the code is very slightly more permissive than the
55
+ * floor — which is the correct direction for the pair: the code never permits something the trigger
56
+ * would reject on a DIFFERENT value, it only declines to complain about a whitespace-only diff that
57
+ * the trigger would also see. If that ever diverges materially the trigger still holds the line.
58
+ */
59
+ private fieldChanged;
60
+ /**
61
+ * Whether this provision's template is PUBLISHED.
62
+ *
63
+ * ⚠ THIS USED TO ASK "do any contracts reference the template", and that gate was wrong in BOTH
64
+ * directions (V202608200900). Too strict: a provision added after a contract referenced the
65
+ * template was never part of what anyone signed, yet became immediately unremovable — and the live
66
+ * data had referenced templates still being authored, which the rule stranded with no way to
67
+ * finish. Too loose: it said nothing about INSERT, so a clause could be ADDED to a signed version.
68
+ * Publication is now an explicit act and the gate reads it directly.
69
+ */
70
+ private templateIsPublished;
71
+ }
72
+ /** Anti-tree-shake anchor — see the note in index.ts. */
73
+ export declare function LoadContractTemplateProvisionEntityServer(): void;
74
+ //# sourceMappingURL=ContractTemplateProvisionEntityServer.d.ts.map