@htilabs/platform-common-models 0.80.0 → 0.81.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.
@@ -1,3 +1,3 @@
1
- export { a as CvcEntry, b as CvcRegistry, F as Form, P as PlatformFunction, d as PlatformRole, Q as Question, f as ScoringRule, h as Section } from '../cvcEntry-BLeRivoF.cjs';
1
+ export { a as CvcEntry, b as CvcRegistry, F as Form, P as PlatformFunction, d as PlatformRole, Q as Question, f as ScoringRule, h as Section } from '../cvcEntry-DAuhe0cd.cjs';
2
2
  import 'mongoose';
3
- export { C as CvcEntryDoc, a as CvcRegistryDoc, F as FormDoc, P as PlatformFunctionDoc, b as PlatformModels, c as PlatformRoleDoc, Q as QuestionDoc, S as ScoringRuleDoc, d as SectionDoc, g as createPlatformModels, h as cvcEntryModel, i as cvcRegistryModel, j as formModel, p as platformFunctionModel, k as platformRoleModel, q as questionModel, s as scoringRuleModel, l as sectionModel } from '../index-Bj-s0nZy.cjs';
3
+ export { C as CvcEntryDoc, a as CvcRegistryDoc, F as FormDoc, P as PlatformFunctionDoc, b as PlatformModels, c as PlatformRoleDoc, Q as QuestionDoc, S as ScoringRuleDoc, d as SectionDoc, g as createPlatformModels, h as cvcEntryModel, i as cvcRegistryModel, j as formModel, p as platformFunctionModel, k as platformRoleModel, q as questionModel, s as scoringRuleModel, l as sectionModel } from '../index-1pWiqEBC.cjs';
@@ -1,3 +1,3 @@
1
- export { a as CvcEntry, b as CvcRegistry, F as Form, P as PlatformFunction, d as PlatformRole, Q as Question, f as ScoringRule, h as Section } from '../cvcEntry-BLeRivoF.js';
1
+ export { a as CvcEntry, b as CvcRegistry, F as Form, P as PlatformFunction, d as PlatformRole, Q as Question, f as ScoringRule, h as Section } from '../cvcEntry-DAuhe0cd.js';
2
2
  import 'mongoose';
3
- export { C as CvcEntryDoc, a as CvcRegistryDoc, F as FormDoc, P as PlatformFunctionDoc, b as PlatformModels, c as PlatformRoleDoc, Q as QuestionDoc, S as ScoringRuleDoc, d as SectionDoc, g as createPlatformModels, h as cvcEntryModel, i as cvcRegistryModel, j as formModel, p as platformFunctionModel, k as platformRoleModel, q as questionModel, s as scoringRuleModel, l as sectionModel } from '../index-DvAypMJV.js';
3
+ export { C as CvcEntryDoc, a as CvcRegistryDoc, F as FormDoc, P as PlatformFunctionDoc, b as PlatformModels, c as PlatformRoleDoc, Q as QuestionDoc, S as ScoringRuleDoc, d as SectionDoc, g as createPlatformModels, h as cvcEntryModel, i as cvcRegistryModel, j as formModel, p as platformFunctionModel, k as platformRoleModel, q as questionModel, s as scoringRuleModel, l as sectionModel } from '../index-uz57Fic9.js';
@@ -1,6 +1,6 @@
1
1
  import * as mongoose from 'mongoose';
2
2
  import { InferRawDocType, Schema } from 'mongoose';
3
- export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-BLeRivoF.cjs';
3
+ export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-DAuhe0cd.cjs';
4
4
  import { a as AddAgencyOrgTypeFieldsOptions } from '../agency-BXvE4yWu.cjs';
5
5
  export { A as AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS, b as AgencyOrgTypeFields, O as ORG_TYPE_FIELD_NAMES, c as OrgTypeFieldName, d as OrgTypeFields, e as OrgTypeFieldsHolder, V as VSP_TWO_STEP_ISSUE, f as addAgencyOrgTypeFields, g as addOrgTypeFields, h as agencyOrgTypeSchemaDefinition, i as applyRunValidatorsIfUnset, j as installVspTwoStepHooks, m as mirrorOrgTypeFields, o as orgTypeFieldsDiffer, k as orgTypeSchemaDefinition, r as resolveEffectiveOrgType, l as resolveEffectiveOrgTypeFields, v as vspTwoStepHolds, n as vspTwoStepHoldsOnUpdate } from '../agency-BXvE4yWu.cjs';
6
6
  export { P as PROGRAM_REVIEW_STATUS, a as PROGRAM_REVIEW_STATUS_VALUES, b as ProgramReviewStatus, i as isLiveOrganizationProgram, c as isProgramReviewStatus } from '../vocabulary-Cxhi9EGt.cjs';
@@ -1,6 +1,6 @@
1
1
  import * as mongoose from 'mongoose';
2
2
  import { InferRawDocType, Schema } from 'mongoose';
3
- export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-BLeRivoF.js';
3
+ export { C as Choice, a as CvcEntry, b as CvcRegistry, F as Form, c as FormSectionRef, G as Guidance, L as Layout, P as PlatformFunction, d as PlatformRole, Q as Question, S as ScoringCondition, e as ScoringRecommendation, f as ScoringRule, g as ScoringThreshold, h as Section, i as SectionQuestionRef, V as VisibilityRule, j as buildCvcEntrySchema, k as buildCvcRegistrySchema, l as buildFormSchema, m as buildPlatformFunctionSchema, n as buildPlatformRoleSchema, o as buildQuestionSchema, p as buildScoringRuleSchema, q as buildSectionSchema, r as choiceSchema, s as cvcEntrySchemaDefinition, t as cvcEntrySchemaOptions, u as cvcRegistrySchemaDefinition, v as cvcRegistrySchemaOptions, w as formSchemaDefinition, x as formSchemaOptions, y as formSectionRefSchema, z as guidanceSchema, A as layoutSchema, B as platformFunctionSchemaDefinition, D as platformFunctionSchemaOptions, E as platformRoleSchemaDefinition, H as platformRoleSchemaOptions, I as questionSchemaDefinition, J as questionSchemaOptions, K as scoringConditionSchema, M as scoringRecommendationSchema, N as scoringRuleSchemaDefinition, O as scoringRuleSchemaOptions, R as scoringThresholdSchema, T as sectionQuestionRefSchema, U as sectionSchemaDefinition, W as sectionSchemaOptions, X as visibilityRuleSchema } from '../cvcEntry-DAuhe0cd.js';
4
4
  import { a as AddAgencyOrgTypeFieldsOptions } from '../agency-NEW6NOGD.js';
5
5
  export { A as AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS, b as AgencyOrgTypeFields, O as ORG_TYPE_FIELD_NAMES, c as OrgTypeFieldName, d as OrgTypeFields, e as OrgTypeFieldsHolder, V as VSP_TWO_STEP_ISSUE, f as addAgencyOrgTypeFields, g as addOrgTypeFields, h as agencyOrgTypeSchemaDefinition, i as applyRunValidatorsIfUnset, j as installVspTwoStepHooks, m as mirrorOrgTypeFields, o as orgTypeFieldsDiffer, k as orgTypeSchemaDefinition, r as resolveEffectiveOrgType, l as resolveEffectiveOrgTypeFields, v as vspTwoStepHolds, n as vspTwoStepHoldsOnUpdate } from '../agency-NEW6NOGD.js';
6
6
  export { P as PROGRAM_REVIEW_STATUS, a as PROGRAM_REVIEW_STATUS_VALUES, b as ProgramReviewStatus, i as isLiveOrganizationProgram, c as isProgramReviewStatus } from '../vocabulary-Cxhi9EGt.js';
@@ -361,10 +361,11 @@ function treeFacts(scope) {
361
361
  const coverageChildren = memoize(
362
362
  (code) => Object.freeze(scope.childrenOf(code).filter(isCoverageRow))
363
363
  );
364
+ const kindHomed = kindHomedRows(scope);
364
365
  const hasOwnContent = memoize((code) => {
365
366
  const row = scope.row(code);
366
367
  if (row === void 0) return false;
367
- const homed = INFORMATION_SCOPE_FIELD_HOME_ROWS.has(code) || row.kindRow !== void 0 && INFORMATION_SCOPE_FIELD_HOME_ROWS.has(row.kindRow);
368
+ const homed = INFORMATION_SCOPE_FIELD_HOME_ROWS.has(code) || kindHomed.has(code);
368
369
  if (!homed) return false;
369
370
  return !scope.childrenOf(code).some((c) => scope.row(c)?.rowType === "category_rest" && isLive(c));
370
371
  });
@@ -379,6 +380,28 @@ function treeFacts(scope) {
379
380
  factsCache.set(scope, facts);
380
381
  return facts;
381
382
  }
383
+ function kindHomedRows(scope) {
384
+ const perKind = /* @__PURE__ */ new Map();
385
+ const kinds = /* @__PURE__ */ new Map();
386
+ for (const r of scope.rows) {
387
+ if (r.status === "retired" || r.kindBranch === null) continue;
388
+ if (r.rowType === "person_type") kinds.set(r.kindBranch, r.scopeCode);
389
+ else if (r.kindRow !== void 0) perKind.set(`${r.kindBranch}\0${r.kindRow}`, r.scopeCode);
390
+ }
391
+ const out = /* @__PURE__ */ new Set();
392
+ for (const home of INFORMATION_SCOPE_FIELD_HOME_ROWS) {
393
+ const row = scope.row(home);
394
+ if (row === void 0 || row.specialDataType === "criminal_intelligence") continue;
395
+ const chain = scope.ancestorsOf(home);
396
+ if (scope.row(chain[chain.length - 1])?.rowType !== "branch") continue;
397
+ for (const [kind, root] of kinds) {
398
+ if (chain.includes(root)) continue;
399
+ const hit = chain.map((c) => perKind.get(`${kind}\0${c}`)).find((c) => c !== void 0);
400
+ if (hit !== void 0) out.add(hit);
401
+ }
402
+ }
403
+ return out;
404
+ }
382
405
  function asCeilingSet(allowed) {
383
406
  if (allowed === null) return null;
384
407
  if (allowed instanceof Set) return allowed;
@@ -403,6 +426,7 @@ function ceilingCoverage(scope, allowed) {
403
426
  let out;
404
427
  if (!facts.isLive(code)) out = false;
405
428
  else if (set === null) out = true;
429
+ else if (facts.underFloor(code)) out = set.has(code);
406
430
  else if (scope.ancestorsOf(code).some((c) => set.has(c))) out = true;
407
431
  else if (facts.hasOwnContent(code)) out = false;
408
432
  else {
@@ -500,6 +524,10 @@ function maskSelectionToCeiling(scope, selection, allowed) {
500
524
  for (const child of scope.childrenOf(code)) if (!sel.includes(child)) sel.push(child);
501
525
  }
502
526
  for (const code of outside) sel = subtractRow(scope, sel, code);
527
+ if (asCeilingSet(allowed) !== null) {
528
+ const within = ceilingCoverage(scope, allowed);
529
+ sel = sel.filter((c) => !facts.underFloor(c) || within(c));
530
+ }
503
531
  return withSystemInfo(sel.filter((c) => facts.isLive(c)));
504
532
  }
505
533
  function isPermittedByCeiling(scope, ceiling, code) {
@@ -781,7 +809,8 @@ function shareRowCeiling(resolution, scope) {
781
809
  ...e.teamExcludedItems,
782
810
  ...e.floorItems
783
811
  ]);
784
- if (withheld.size === 0) {
812
+ const onlyFloorWithheld = [...withheld].every((r) => e.floorItems.includes(r));
813
+ if (withheld.size === 0 || onlyFloorWithheld && hasOwnScopeContent(scope, g)) {
785
814
  out.push(g);
786
815
  continue;
787
816
  }
@@ -1173,7 +1202,8 @@ function resolveShare(input) {
1173
1202
  teamExcludedItems.push(r);
1174
1203
  if (teamExcludedItems.length > 0) teamExcludedReason = why;
1175
1204
  }
1176
- if (allowed && (!req || platformRequired !== null) && leaves.length > 0) {
1205
+ const floorOnlyOwnContent = leaves.length > 0 && leaves.every((r) => floorItems.includes(r)) && hasOwnScopeContent(scope, g);
1206
+ if (allowed && (!req || platformRequired !== null) && leaves.length > 0 && !floorOnlyOwnContent) {
1177
1207
  const gone = new Set(
1178
1208
  [...floorItems, ...excludedItems, ...teamExcludedItems].filter(
1179
1209
  (r) => leaves.includes(r)