@htilabs/platform-common-models 0.40.0 → 0.41.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 (46) hide show
  1. package/README.md +51 -0
  2. package/dist/{index-uz57Fic9.d.ts → index-BHSRMJvd.d.ts} +1 -1
  3. package/dist/{index-1pWiqEBC.d.cts → index-DF469Qgd.d.cts} +1 -1
  4. package/dist/index.cjs +51 -0
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +3 -3
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.js +47 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/models/index.d.cts +2 -2
  11. package/dist/models/index.d.ts +2 -2
  12. package/dist/schemas/index.d.cts +25 -25
  13. package/dist/schemas/index.d.ts +25 -25
  14. package/dist/share-rules/index.cjs +822 -0
  15. package/dist/share-rules/index.cjs.map +1 -0
  16. package/dist/share-rules/index.d.cts +804 -0
  17. package/dist/share-rules/index.d.ts +804 -0
  18. package/dist/share-rules/index.js +736 -0
  19. package/dist/share-rules/index.js.map +1 -0
  20. package/dist/sharing-ceiling/index.cjs +51 -0
  21. package/dist/sharing-ceiling/index.cjs.map +1 -1
  22. package/dist/sharing-ceiling/index.d.cts +87 -1
  23. package/dist/sharing-ceiling/index.d.ts +87 -1
  24. package/dist/sharing-ceiling/index.js +47 -0
  25. package/dist/sharing-ceiling/index.js.map +1 -1
  26. package/package.json +6 -1
  27. package/src/shareRules/__tests__/caseShareLane.test.ts +259 -0
  28. package/src/shareRules/__tests__/magicLinkAddresses.test.ts +107 -0
  29. package/src/shareRules/__tests__/platformApps.test.ts +133 -0
  30. package/src/shareRules/__tests__/releaseTerms.test.ts +358 -0
  31. package/src/shareRules/__tests__/senderRoiPosture.test.ts +284 -0
  32. package/src/shareRules/__tests__/sharingMethods.test.ts +105 -0
  33. package/src/shareRules/caseShareLane.ts +289 -0
  34. package/src/shareRules/index.ts +31 -0
  35. package/src/shareRules/magicLinkAddresses.ts +185 -0
  36. package/src/shareRules/platformApps.ts +168 -0
  37. package/src/shareRules/releaseTerms.ts +359 -0
  38. package/src/shareRules/reportPurposes.ts +50 -0
  39. package/src/shareRules/senderRoiPosture.ts +296 -0
  40. package/src/shareRules/sharingMethods.ts +204 -0
  41. package/src/sharingCeiling/__tests__/threadLift.test.ts +353 -0
  42. package/src/sharingCeiling/coverage.ts +63 -0
  43. package/src/sharingCeiling/defaults.ts +106 -0
  44. package/src/sharingCeiling/index.ts +7 -0
  45. package/dist/{cvcEntry-DAuhe0cd.d.cts → cvcEntry-DQEoFVL2.d.cts} +8 -8
  46. package/dist/{cvcEntry-DAuhe0cd.d.ts → cvcEntry-DQEoFVL2.d.ts} +8 -8
package/README.md CHANGED
@@ -16,6 +16,57 @@ Package exports are organized into a public root API and a small number of
16
16
  dedicated subpaths (`/validation`, `/cvcs`) — consult `package.json` for the
17
17
  authoritative `exports` map.
18
18
 
19
+ ## share-rules + sharing-ceiling defaults / 0.41.0 (additive)
20
+
21
+ PAVE is adopting the shared Next Steps share window Thread already uses. The
22
+ app-independent share rules it needs lived in Thread's `@thread/shared`; this
23
+ release LIFTS them here so both apps and both servers run one copy.
24
+ **Behaviour and copy are Thread's, unchanged** (thread develop `f021be2`); the
25
+ Thread unit tests for each function are ported beside it.
26
+
27
+ `@htilabs/platform-common-models/sharing-ceiling` (and the root) gains:
28
+
29
+ - `shareDefaultScopeFor(edits, purpose, { starter?, purposeOverrides? })` →
30
+ `{ off, accountDefault }` — the account's per-purpose default (the
31
+ prototype's name): the account's `__default__` cell for the purpose, else
32
+ the platform starter's `scopeByPurpose[purpose]`; `[]` when the purpose is
33
+ off or the store could not be read (`edits === null`). Thread's
34
+ `accountSharePurposePolicy` is the same function (an alias, not a wrapper).
35
+ - `isPermittedByCeiling(scope, ceiling, code)` and
36
+ `intersectSharingCeilingLists(scope, a, b)` — Thread's two coverage
37
+ readers, with the tree passed as `scope` like every other reader here
38
+ (Thread bound its own resolver; its re-point keeps the two-argument forms).
39
+
40
+ New subpath `@htilabs/platform-common-models/share-rules` (not on the root;
41
+ pure — no mongoose, no I/O, no React, no SOT import):
42
+
43
+ - magic link: `derivesOffPlatformRecipient`, `magicLinkAddresses`,
44
+ `magicLinkAddressOverflow`, `magicLinkToText`,
45
+ `magicLinkConfidentialOverflow`, `magicLinkPocHasVisibleAddress`,
46
+ `magicLinkConfidentialOnly`, `MAGIC_LINK_MAX_ADDRESSES` (25);
47
+ - release terms (R19 method / R21 end date): `operativeReleaseOf`,
48
+ `releaseListedMethods`, `releaseMethodRefusal`, `shareExpiryUnderRelease`,
49
+ `releaseEndOfDay` / `releaseEndDay`, `shareMethodOf`,
50
+ `isBrokeredSharingMethod`, the exemptions;
51
+ - the CaseShare lane: `caseShareLandingLane`, `pickDefaultShareTeam`,
52
+ `caseShareLaneMismatch`, the refusal codes and sentences (Thread's, which
53
+ name Thread, and Thread's recorded LEADS deviation — unchanged);
54
+ - the sender's release posture: `readAuthoredRoiPosture`,
55
+ `resolveAgencyRoiPosture`, `senderRoiPostureForTeam`,
56
+ `resolveSenderRoiPosture`, `vspReleasePosture`;
57
+ - what they stand on, moved with them: `recipientPlatformFromApps`,
58
+ `recipientUsesApp`, `agencyIdKey`, `teamLandingApp` / `teamLandsIn*`;
59
+ the share-method vocabulary `SHARING_METHOD` / `SHARING_METHOD_LABELS` and
60
+ the CVC-332 release-method reading (`RELEASE_METHOD*`,
61
+ `normalizeReleaseMethod`, `readReleaseMethods`,
62
+ `sharingMethodOfReleaseMethod`, …; Thread's zod write schema stays in
63
+ Thread); the report purposes `ROI_WAIVER_EXEMPT_PURPOSES` /
64
+ `isRoiWaiverExemptPurpose`.
65
+
66
+ Release-basis codes are NOT converged here: the one basis reason these rules
67
+ read, `roi_on_file` (Thread's `on_file`; CVC-331 `signed_release`), is kept
68
+ and marked `CVC-331 convergence owed (Kickoff 12)`.
69
+
19
70
  ## age / 0.40.0 (additive)
20
71
 
21
72
  New subpath `@htilabs/platform-common-models/age` (also on the package root):
@@ -1,4 +1,4 @@
1
- import { F as Form, l as buildFormSchema, h as Section, q as buildSectionSchema, Q as Question, o as buildQuestionSchema, f as ScoringRule, p as buildScoringRuleSchema, P as PlatformFunction, m as buildPlatformFunctionSchema, d as PlatformRole, n as buildPlatformRoleSchema, b as CvcRegistry, k as buildCvcRegistrySchema, a as CvcEntry, j as buildCvcEntrySchema } from './cvcEntry-DAuhe0cd.js';
1
+ import { F as Form, l as buildFormSchema, h as Section, q as buildSectionSchema, Q as Question, o as buildQuestionSchema, f as ScoringRule, p as buildScoringRuleSchema, P as PlatformFunction, m as buildPlatformFunctionSchema, d as PlatformRole, n as buildPlatformRoleSchema, b as CvcRegistry, k as buildCvcRegistrySchema, a as CvcEntry, j as buildCvcEntrySchema } from './cvcEntry-DQEoFVL2.js';
2
2
  import * as mongoose from 'mongoose';
3
3
  import { HydratedDocument, Connection, Model } from 'mongoose';
4
4
 
@@ -1,4 +1,4 @@
1
- import { F as Form, l as buildFormSchema, h as Section, q as buildSectionSchema, Q as Question, o as buildQuestionSchema, f as ScoringRule, p as buildScoringRuleSchema, P as PlatformFunction, m as buildPlatformFunctionSchema, d as PlatformRole, n as buildPlatformRoleSchema, b as CvcRegistry, k as buildCvcRegistrySchema, a as CvcEntry, j as buildCvcEntrySchema } from './cvcEntry-DAuhe0cd.cjs';
1
+ import { F as Form, l as buildFormSchema, h as Section, q as buildSectionSchema, Q as Question, o as buildQuestionSchema, f as ScoringRule, p as buildScoringRuleSchema, P as PlatformFunction, m as buildPlatformFunctionSchema, d as PlatformRole, n as buildPlatformRoleSchema, b as CvcRegistry, k as buildCvcRegistrySchema, a as CvcEntry, j as buildCvcEntrySchema } from './cvcEntry-DQEoFVL2.cjs';
2
2
  import * as mongoose from 'mongoose';
3
3
  import { HydratedDocument, Connection, Model } from 'mongoose';
4
4
 
package/dist/index.cjs CHANGED
@@ -541,6 +541,7 @@ __export(src_exports, {
541
541
  WHY_NOT_REPORTING_AXES: () => WHY_NOT_REPORTING_AXES,
542
542
  WhyNotKeys: () => WhyNotKeys,
543
543
  accommodationTypeSot: () => accommodationType_v1_0_0_default,
544
+ accountSharePurposePolicy: () => accountSharePurposePolicy,
544
545
  actionStepCompletionStatusSot: () => actionStepCompletionStatus_v1_0_0_default,
545
546
  actionStepTypeSot: () => actionStepType_v1_0_0_default,
546
547
  activityTypeSot: () => activityType_v1_0_0_default,
@@ -683,6 +684,7 @@ __export(src_exports, {
683
684
  incidentParticipationRolesSot: () => incidentParticipationRoles_v1_1_0_default,
684
685
  incomeBenefitsSourcesSot: () => incomeBenefitsSources_v1_1_0_default,
685
686
  inferenceTypeSot: () => inferenceType_v1_0_0_default,
687
+ intersectSharingCeilingLists: () => intersectSharingCeilingLists,
686
688
  investigativeRequestTypeSot: () => investigativeRequestType_v1_0_0_default,
687
689
  isAgencyTypeKey: () => isAgencyTypeKey,
688
690
  isCanonEvaluableFunction: () => isCanonEvaluableFunction,
@@ -699,6 +701,7 @@ __export(src_exports, {
699
701
  isLiveOrganizationProgram: () => isLiveOrganizationProgram,
700
702
  isNeverPickableServiceMechanism: () => isNeverPickableServiceMechanism,
701
703
  isOrgTypeKey: () => isOrgTypeKey,
704
+ isPermittedByCeiling: () => isPermittedByCeiling,
702
705
  isProgramReviewStatus: () => isProgramReviewStatus,
703
706
  isProtectedRelationship: () => isProtectedRelationship,
704
707
  isReportAuthorityOrgType: () => isReportAuthorityOrgType,
@@ -842,6 +845,7 @@ __export(src_exports, {
842
845
  severityFollowUpSot: () => severityFollowUp_v1_0_0_default,
843
846
  sexProviderSubroleSot: () => sexProviderSubrole_v1_0_0_default,
844
847
  shareCadenceSot: () => shareCadence_v1_0_0_default,
848
+ shareDefaultScopeFor: () => shareDefaultScopeFor,
845
849
  sharePurposeSot: () => sharePurpose_v1_0_0_default,
846
850
  shareResponseReasonSot: () => shareResponseReason_v1_0_0_default,
847
851
  sharingCeilingCellList: () => sharingCeilingCellList,
@@ -16602,6 +16606,49 @@ function maskSelectionToCeiling(scope, selection, allowed) {
16602
16606
  for (const code of outside) sel = subtractRow(scope, sel, code);
16603
16607
  return withSystemInfo(sel.filter((c) => facts.isLive(c)));
16604
16608
  }
16609
+ function isPermittedByCeiling(scope, ceiling, code) {
16610
+ if (ceiling === null || ceiling.allowed === null) return true;
16611
+ if (scope.ancestorsOf(code).includes("system")) {
16612
+ return true;
16613
+ }
16614
+ if (scope.row(code) === void 0) return false;
16615
+ return scopeRowWithinCeiling(scope, ceiling.allowed, code);
16616
+ }
16617
+ function intersectSharingCeilingLists(scope, a, b) {
16618
+ const left = [...a];
16619
+ const right = [...b];
16620
+ const within = (list, code) => scopeRowWithinCeiling(scope, list, code);
16621
+ return [
16622
+ .../* @__PURE__ */ new Set([
16623
+ ...left.filter((code) => within(right, code)),
16624
+ ...right.filter((code) => within(left, code))
16625
+ ])
16626
+ ];
16627
+ }
16628
+
16629
+ // src/sharingCeiling/defaults.ts
16630
+ function shareDefaultScopeFor(edits, purpose, opts = {}) {
16631
+ const off = isSharingPurposeDisabled(purpose, opts.purposeOverrides ?? null);
16632
+ if (off || edits === null || edits === void 0) {
16633
+ return { off, accountDefault: [] };
16634
+ }
16635
+ const starter = opts.starter ?? HTI_SHARE_PLATFORM_STARTER;
16636
+ const authored = edits[SHARING_CEILING_DEFAULT_ROW_KEY]?.[purpose];
16637
+ if (Array.isArray(authored)) {
16638
+ return {
16639
+ off,
16640
+ accountDefault: authored.filter(
16641
+ (v) => typeof v === "string"
16642
+ )
16643
+ };
16644
+ }
16645
+ const platform = starter.scopeByPurpose[purpose];
16646
+ return {
16647
+ off,
16648
+ accountDefault: Array.isArray(platform) ? platform.filter((v) => typeof v === "string") : []
16649
+ };
16650
+ }
16651
+ var accountSharePurposePolicy = shareDefaultScopeFor;
16605
16652
 
16606
16653
  // src/validation/cvc.ts
16607
16654
  var import_zod = require("zod");
@@ -69769,6 +69816,7 @@ var CVC_197_VALUES = selectableCodes(
69769
69816
  WHY_NOT_REPORTING_AXES,
69770
69817
  WhyNotKeys,
69771
69818
  accommodationTypeSot,
69819
+ accountSharePurposePolicy,
69772
69820
  actionStepCompletionStatusSot,
69773
69821
  actionStepTypeSot,
69774
69822
  activityTypeSot,
@@ -69911,6 +69959,7 @@ var CVC_197_VALUES = selectableCodes(
69911
69959
  incidentParticipationRolesSot,
69912
69960
  incomeBenefitsSourcesSot,
69913
69961
  inferenceTypeSot,
69962
+ intersectSharingCeilingLists,
69914
69963
  investigativeRequestTypeSot,
69915
69964
  isAgencyTypeKey,
69916
69965
  isCanonEvaluableFunction,
@@ -69927,6 +69976,7 @@ var CVC_197_VALUES = selectableCodes(
69927
69976
  isLiveOrganizationProgram,
69928
69977
  isNeverPickableServiceMechanism,
69929
69978
  isOrgTypeKey,
69979
+ isPermittedByCeiling,
69930
69980
  isProgramReviewStatus,
69931
69981
  isProtectedRelationship,
69932
69982
  isReportAuthorityOrgType,
@@ -70070,6 +70120,7 @@ var CVC_197_VALUES = selectableCodes(
70070
70120
  severityFollowUpSot,
70071
70121
  sexProviderSubroleSot,
70072
70122
  shareCadenceSot,
70123
+ shareDefaultScopeFor,
70073
70124
  sharePurposeSot,
70074
70125
  shareResponseReasonSot,
70075
70126
  sharingCeilingCellList,