@htilabs/platform-common-models 0.54.0 → 0.56.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 (41) hide show
  1. package/README.md +90 -0
  2. package/dist/authz/index.cjs +353 -2
  3. package/dist/authz/index.cjs.map +1 -1
  4. package/dist/authz/index.d.cts +330 -9
  5. package/dist/authz/index.d.ts +330 -9
  6. package/dist/authz/index.js +339 -1
  7. package/dist/authz/index.js.map +1 -1
  8. package/dist/{index-XWSYon40.d.cts → index-Bj-s0nZy.d.cts} +1 -1
  9. package/dist/{index-Bh1zO_Vu.d.ts → index-DvAypMJV.d.ts} +1 -1
  10. package/dist/index.cjs +503 -2
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +4 -4
  13. package/dist/index.d.ts +4 -4
  14. package/dist/index.js +483 -2
  15. package/dist/index.js.map +1 -1
  16. package/dist/models/index.d.cts +2 -2
  17. package/dist/models/index.d.ts +2 -2
  18. package/dist/schemas/index.d.cts +25 -25
  19. package/dist/schemas/index.d.ts +25 -25
  20. package/dist/sharing-ceiling/index.cjs +152 -2
  21. package/dist/sharing-ceiling/index.cjs.map +1 -1
  22. package/dist/sharing-ceiling/index.d.cts +214 -2
  23. package/dist/sharing-ceiling/index.d.ts +214 -2
  24. package/dist/sharing-ceiling/index.js +145 -2
  25. package/dist/sharing-ceiling/index.js.map +1 -1
  26. package/package.json +1 -1
  27. package/src/__tests__/authz-resolve.test.ts +5 -0
  28. package/src/__tests__/authz-viewing-policy.test.ts +685 -0
  29. package/src/__tests__/authz-viewing-scope.test.ts +1037 -0
  30. package/src/__tests__/core-function-default-bounds.test.ts +2 -2
  31. package/src/authz/functionDoor.ts +4 -4
  32. package/src/authz/index.ts +2 -0
  33. package/src/authz/resolveEffectiveFunctions.ts +6 -4
  34. package/src/authz/viewingPolicy.ts +525 -0
  35. package/src/authz/viewingScope.ts +359 -0
  36. package/src/sharingCeiling/__tests__/fireShareEvent.test.ts +437 -0
  37. package/src/sharingCeiling/fireShareEvent.ts +352 -0
  38. package/src/sharingCeiling/index.ts +4 -0
  39. package/src/sharingCeiling/resolve.ts +31 -5
  40. package/dist/{cvcEntry-D787utvP.d.cts → cvcEntry-BLeRivoF.d.cts} +8 -8
  41. package/dist/{cvcEntry-D787utvP.d.ts → cvcEntry-BLeRivoF.d.ts} +8 -8
@@ -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-D787utvP.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-BLeRivoF.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-XWSYon40.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-Bj-s0nZy.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-D787utvP.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-BLeRivoF.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-Bh1zO_Vu.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-DvAypMJV.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-D787utvP.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-BLeRivoF.cjs';
4
4
  export { A as AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS, a as AddAgencyOrgTypeFieldsOptions, 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, m as mirrorOrgTypeFields, o as orgTypeFieldsDiffer, j as orgTypeSchemaDefinition, r as resolveEffectiveOrgType, k as resolveEffectiveOrgTypeFields, v as vspTwoStepHolds, l as vspTwoStepHoldsOnUpdate } from '../agency-DYCv839V.cjs';
5
5
  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';
6
6
  import '../org-type-D_FG4KdN.cjs';
@@ -136,12 +136,12 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
136
136
  number?: string | null | undefined;
137
137
  type?: string | null | undefined;
138
138
  safeToContact?: boolean | null | undefined;
139
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
139
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
140
140
  }, mongoose.Document<unknown, {}, {
141
141
  number?: string | null | undefined;
142
142
  type?: string | null | undefined;
143
143
  safeToContact?: boolean | null | undefined;
144
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
144
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
145
145
  }, {
146
146
  id: string;
147
147
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
@@ -150,7 +150,7 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
150
150
  number?: string | null | undefined;
151
151
  type?: string | null | undefined;
152
152
  safeToContact?: boolean | null | undefined;
153
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
153
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
154
154
  } & {
155
155
  _id: mongoose.Types.ObjectId;
156
156
  } & {
@@ -161,7 +161,7 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
161
161
  number?: string | null | undefined;
162
162
  type?: string | null | undefined;
163
163
  safeToContact?: boolean | null | undefined;
164
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
164
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
165
165
  } & {
166
166
  _id: mongoose.Types.ObjectId;
167
167
  } & {
@@ -223,11 +223,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
223
223
  raceOtherText?: string | null | undefined;
224
224
  genderOtherText?: string | null | undefined;
225
225
  accommodationOtherText?: string | null | undefined;
226
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
227
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
228
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
229
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
230
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
226
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
227
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
228
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
229
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
230
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
231
231
  }, mongoose.Document<unknown, {}, {
232
232
  race: number[];
233
233
  ethnicity: number[];
@@ -247,11 +247,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
247
247
  raceOtherText?: string | null | undefined;
248
248
  genderOtherText?: string | null | undefined;
249
249
  accommodationOtherText?: string | null | undefined;
250
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
251
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
252
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
253
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
254
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
250
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
251
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
252
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
253
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
254
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
255
255
  }, {
256
256
  id: string;
257
257
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
@@ -275,11 +275,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
275
275
  raceOtherText?: string | null | undefined;
276
276
  genderOtherText?: string | null | undefined;
277
277
  accommodationOtherText?: string | null | undefined;
278
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
279
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
280
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
281
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
282
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
278
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
279
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
280
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
281
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
282
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
283
283
  } & {
284
284
  _id: mongoose.Types.ObjectId;
285
285
  } & {
@@ -305,11 +305,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
305
305
  raceOtherText?: string | null | undefined;
306
306
  genderOtherText?: string | null | undefined;
307
307
  accommodationOtherText?: string | null | undefined;
308
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
309
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
310
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
311
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
312
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
308
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
309
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
310
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
311
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
312
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
313
313
  } & {
314
314
  _id: mongoose.Types.ObjectId;
315
315
  } & {
@@ -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-D787utvP.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-BLeRivoF.js';
4
4
  export { A as AGENCY_ORG_TYPE_VALIDATED_UPDATE_OPS, a as AddAgencyOrgTypeFieldsOptions, 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, m as mirrorOrgTypeFields, o as orgTypeFieldsDiffer, j as orgTypeSchemaDefinition, r as resolveEffectiveOrgType, k as resolveEffectiveOrgTypeFields, v as vspTwoStepHolds, l as vspTwoStepHoldsOnUpdate } from '../agency-Ca4pCOOf.js';
5
5
  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';
6
6
  import '../org-type-BYQb9Qzq.js';
@@ -136,12 +136,12 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
136
136
  number?: string | null | undefined;
137
137
  type?: string | null | undefined;
138
138
  safeToContact?: boolean | null | undefined;
139
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
139
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
140
140
  }, mongoose.Document<unknown, {}, {
141
141
  number?: string | null | undefined;
142
142
  type?: string | null | undefined;
143
143
  safeToContact?: boolean | null | undefined;
144
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
144
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
145
145
  }, {
146
146
  id: string;
147
147
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
@@ -150,7 +150,7 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
150
150
  number?: string | null | undefined;
151
151
  type?: string | null | undefined;
152
152
  safeToContact?: boolean | null | undefined;
153
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
153
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
154
154
  } & {
155
155
  _id: mongoose.Types.ObjectId;
156
156
  } & {
@@ -161,7 +161,7 @@ declare const phoneSchema: Schema<any, mongoose.Model<any, any, any, any, any, a
161
161
  number?: string | null | undefined;
162
162
  type?: string | null | undefined;
163
163
  safeToContact?: boolean | null | undefined;
164
- dataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
164
+ dataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
165
165
  } & {
166
166
  _id: mongoose.Types.ObjectId;
167
167
  } & {
@@ -223,11 +223,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
223
223
  raceOtherText?: string | null | undefined;
224
224
  genderOtherText?: string | null | undefined;
225
225
  accommodationOtherText?: string | null | undefined;
226
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
227
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
228
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
229
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
230
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
226
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
227
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
228
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
229
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
230
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
231
231
  }, mongoose.Document<unknown, {}, {
232
232
  race: number[];
233
233
  ethnicity: number[];
@@ -247,11 +247,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
247
247
  raceOtherText?: string | null | undefined;
248
248
  genderOtherText?: string | null | undefined;
249
249
  accommodationOtherText?: string | null | undefined;
250
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
251
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
252
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
253
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
254
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
250
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
251
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
252
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
253
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
254
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
255
255
  }, {
256
256
  id: string;
257
257
  }, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
@@ -275,11 +275,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
275
275
  raceOtherText?: string | null | undefined;
276
276
  genderOtherText?: string | null | undefined;
277
277
  accommodationOtherText?: string | null | undefined;
278
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
279
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
280
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
281
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
282
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
278
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
279
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
280
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
281
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
282
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
283
283
  } & {
284
284
  _id: mongoose.Types.ObjectId;
285
285
  } & {
@@ -305,11 +305,11 @@ declare const demographicsSchema: Schema<any, mongoose.Model<any, any, any, any,
305
305
  raceOtherText?: string | null | undefined;
306
306
  genderOtherText?: string | null | undefined;
307
307
  accommodationOtherText?: string | null | undefined;
308
- ageDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
309
- sexDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
310
- genderDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
311
- raceDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
312
- ethnicityDataQuality?: "data_not_collected" | "client_doesnt_know" | "client_prefers_not_to_answer" | null | undefined;
308
+ ageDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
309
+ sexDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
310
+ genderDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
311
+ raceDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
312
+ ethnicityDataQuality?: "client_doesnt_know" | "client_prefers_not_to_answer" | "data_not_collected" | null | undefined;
313
313
  } & {
314
314
  _id: mongoose.Types.ObjectId;
315
315
  } & {
@@ -25,10 +25,12 @@ __export(sharingCeiling_exports, {
25
25
  HTI_SHARE_PLATFORM_STARTER: () => HTI_SHARE_PLATFORM_STARTER,
26
26
  HTI_SHARE_PLATFORM_STARTER_SOURCE: () => HTI_SHARE_PLATFORM_STARTER_SOURCE,
27
27
  INFORMATION_SCOPE_FIELD_HOME_ROWS: () => INFORMATION_SCOPE_FIELD_HOME_ROWS,
28
+ SHARE_EVENT: () => SHARE_EVENT,
28
29
  SHARE_LEVEL_LABEL: () => SHARE_LEVEL_LABEL,
29
30
  SHARE_PLATFORM_STATE_LABEL: () => SHARE_PLATFORM_STATE_LABEL,
30
31
  SHARE_POSTURE_RANK: () => SHARE_POSTURE_RANK,
31
32
  SHARE_REPORTING_PURPOSES: () => SHARE_REPORTING_PURPOSES,
33
+ SHARE_TRIGGER_EVENTS: () => SHARE_TRIGGER_EVENTS,
32
34
  SHARING_CEILING_DEFAULT_ROW_KEY: () => SHARING_CEILING_DEFAULT_ROW_KEY,
33
35
  SHARING_CEILING_EXTERNAL_ROW_KEY: () => SHARING_CEILING_EXTERNAL_ROW_KEY,
34
36
  SHARING_CEILING_SCOPE_VERSION: () => SHARING_CEILING_SCOPE_VERSION,
@@ -37,6 +39,8 @@ __export(sharingCeiling_exports, {
37
39
  ceilingCoverage: () => ceilingCoverage,
38
40
  derivePlatformDefault: () => derivePlatformDefault,
39
41
  effectiveCeiling: () => effectiveCeiling,
42
+ fireShareEvent: () => fireShareEvent,
43
+ firedShareKey: () => firedShareKey,
40
44
  hasOwnScopeContent: () => hasOwnScopeContent,
41
45
  intersectSharingCeilingLists: () => intersectSharingCeilingLists,
42
46
  isCeilingCoverageRow: () => isCeilingCoverageRow,
@@ -46,6 +50,7 @@ __export(sharingCeiling_exports, {
46
50
  maskSelectionToCeiling: () => maskSelectionToCeiling,
47
51
  matchTeamRow: () => matchTeamRow,
48
52
  platformDefaultFor: () => platformDefaultFor,
53
+ policyIsShareListener: () => policyIsShareListener,
49
54
  resolveShare: () => resolveShare,
50
55
  rowsExpandedByCeiling: () => rowsExpandedByCeiling,
51
56
  rowsOutsideCeiling: () => rowsOutsideCeiling,
@@ -54,7 +59,9 @@ __export(sharingCeiling_exports, {
54
59
  scopeListStrictlyCovers: () => scopeListStrictlyCovers,
55
60
  scopeRowWithinCeiling: () => scopeRowWithinCeiling,
56
61
  shareDefaultScopeFor: () => shareDefaultScopeFor,
62
+ shareListenersFor: () => shareListenersFor,
57
63
  shareRowCeiling: () => shareRowCeiling,
64
+ shareTriggerLabel: () => shareTriggerLabel,
58
65
  sharingCeilingCellList: () => sharingCeilingCellList,
59
66
  sharingCeilingRowKey: () => sharingCeilingRowKey,
60
67
  sharingScopeEditsFromCells: () => sharingScopeEditsFromCells,
@@ -1001,7 +1008,9 @@ function resolveShare(input) {
1001
1008
  const teamExcludedItems = [];
1002
1009
  let teamExcludedReason = null;
1003
1010
  const outside = (covered) => items.filter(
1004
- (r) => !covered(r) && !items.some((d) => d !== r && covered(d) && scope.ancestorsOf(d).includes(r))
1011
+ (r) => !covered(r) && !items.some(
1012
+ (d) => d !== r && covered(d) && scope.ancestorsOf(d).includes(r)
1013
+ )
1005
1014
  );
1006
1015
  const addExcluded = (rows, why) => {
1007
1016
  for (const r of rows)
@@ -1071,7 +1080,8 @@ function resolveShare(input) {
1071
1080
  const why = `Outside what your team's \u201C${tcNamed?.name}\u201D policy allows`;
1072
1081
  const outRows = /* @__PURE__ */ new Set();
1073
1082
  if (tcScope !== null && !scopeListStrictlyCovers(scope, tcScope, g)) {
1074
- for (const r of outside((x) => scopeListCovers(scope, tcScope, g, x))) outRows.add(r);
1083
+ for (const r of outside((x) => scopeListCovers(scope, tcScope, g, x)))
1084
+ outRows.add(r);
1075
1085
  }
1076
1086
  const tcRows = own2(tcItems, g);
1077
1087
  if (isStringList2(tcRows)) {
@@ -1129,6 +1139,139 @@ function resolveShare(input) {
1129
1139
  rulePath
1130
1140
  };
1131
1141
  }
1142
+
1143
+ // src/sharingCeiling/fireShareEvent.ts
1144
+ var SHARE_TRIGGER_EVENTS = Object.freeze([
1145
+ { code: "sessionSubmitted", label: "Session submitted", group: "case" },
1146
+ { code: "caseOpened", label: "Case opened", group: "case" },
1147
+ { code: "caseStatusChanged", label: "Case status changed", group: "case" },
1148
+ { code: "caseCloseRuled", label: "Case closed", group: "case" },
1149
+ {
1150
+ code: "determinationIssued",
1151
+ label: "Determination issued",
1152
+ group: "case"
1153
+ },
1154
+ { code: "serviceLogged", label: "Service logged", group: "case" },
1155
+ { code: "noteAdded", label: "Note added", group: "case" },
1156
+ { code: "shareClaimed", label: "Share you sent claimed", group: "share" },
1157
+ {
1158
+ code: "referralClaimed",
1159
+ label: "Referral you sent claimed",
1160
+ group: "share"
1161
+ },
1162
+ {
1163
+ code: "shareAcknowledged",
1164
+ label: "Share you sent acknowledged",
1165
+ group: "share"
1166
+ }
1167
+ ]);
1168
+ var SHARE_EVENT = Object.freeze({
1169
+ SESSION_SUBMITTED: "sessionSubmitted",
1170
+ CASE_CLOSED: "caseCloseRuled"
1171
+ });
1172
+ function shareTriggerLabel(code) {
1173
+ return SHARE_TRIGGER_EVENTS.find((t) => t.code === code)?.label ?? code;
1174
+ }
1175
+ var str = (v) => typeof v === "string" && v !== "";
1176
+ function policyIsShareListener(p) {
1177
+ if (p === null || p === void 0 || typeof p !== "object") return false;
1178
+ if (p.active === false) return false;
1179
+ if (p.cadences?.ongoing !== true) return false;
1180
+ const on = p.trigger?.on;
1181
+ if (!Array.isArray(on) || !on.some(str)) return false;
1182
+ return p.trigger?.answers !== "received";
1183
+ }
1184
+ function linkTarget(a) {
1185
+ const withTeam = a.with !== null && typeof a.with === "object" && a.with.type === "team" && str(a.with.id) ? a.with.id : null;
1186
+ if (str(a.partnerId)) {
1187
+ return {
1188
+ recipient: { kind: "partner", id: a.partnerId },
1189
+ partnerTeamId: withTeam
1190
+ };
1191
+ }
1192
+ if (withTeam !== null) {
1193
+ return {
1194
+ recipient: { kind: "sibling_team", teamId: withTeam },
1195
+ partnerTeamId: null
1196
+ };
1197
+ }
1198
+ return null;
1199
+ }
1200
+ var targetKey = (l) => l.recipient.kind === "partner" ? ["partner", l.recipient.id, l.partnerTeamId] : ["team", l.recipient.teamId, null];
1201
+ function rowAgrees(rows, a, target) {
1202
+ const row = rows.find(
1203
+ (r) => r !== null && typeof r === "object" && r.id === a.teamRowId
1204
+ );
1205
+ if (row === void 0 || row.myTeamId !== a.teamId) return false;
1206
+ const theirTeam = row.their?.type === "team" && str(row.their.id) ? row.their.id : null;
1207
+ return target.recipient.kind === "sibling_team" ? theirTeam === target.recipient.teamId : theirTeam === target.partnerTeamId;
1208
+ }
1209
+ function shareListenersFor(policies, teamId, options = {}) {
1210
+ if (!Array.isArray(policies) || !str(teamId)) return [];
1211
+ const cells = attachmentIndexFromPolicies(policies).teamRows;
1212
+ const rows = Array.isArray(options.teamRows) ? options.teamRows : null;
1213
+ const out = [];
1214
+ const seen = /* @__PURE__ */ new Set();
1215
+ for (const p of policies) {
1216
+ if (!policyIsShareListener(p) || !str(p.id) || !str(p.purpose)) continue;
1217
+ const events = (p.trigger?.on ?? []).filter(str);
1218
+ if (str(options.event) && !events.includes(options.event)) continue;
1219
+ for (const a of Array.isArray(p.assignments) ? p.assignments : []) {
1220
+ if (a === null || typeof a !== "object" || a.scope !== "team_pair")
1221
+ continue;
1222
+ if (!str(a.teamRowId) || a.teamId !== teamId) continue;
1223
+ if (cells[a.teamRowId]?.[p.purpose] !== p.id) continue;
1224
+ const target = linkTarget(a);
1225
+ if (target === null) continue;
1226
+ if (rows !== null && !rowAgrees(rows, a, target)) continue;
1227
+ if (target.recipient.kind === "sibling_team" && target.recipient.teamId === teamId)
1228
+ continue;
1229
+ const dedupe = JSON.stringify([p.id, ...targetKey(target)]);
1230
+ if (seen.has(dedupe)) continue;
1231
+ seen.add(dedupe);
1232
+ out.push({
1233
+ policy: {
1234
+ id: p.id,
1235
+ familyId: str(p.familyId) ? p.familyId : p.id,
1236
+ name: str(p.name) ? p.name : p.id,
1237
+ version: parseInt(String(p.version), 10) || 1
1238
+ },
1239
+ purpose: p.purpose,
1240
+ fromTeamId: teamId,
1241
+ teamRowId: a.teamRowId,
1242
+ ...target,
1243
+ events
1244
+ });
1245
+ }
1246
+ }
1247
+ return out;
1248
+ }
1249
+ function firedShareKey(event, ref, listener) {
1250
+ return JSON.stringify([
1251
+ event,
1252
+ ref,
1253
+ listener.policy.id,
1254
+ listener.fromTeamId,
1255
+ ...targetKey(listener)
1256
+ ]);
1257
+ }
1258
+ function fireShareEvent(policies, event, options = {}) {
1259
+ if (event === null || event === void 0 || !str(event.event)) return [];
1260
+ const session = str(event.sessionId) ? event.sessionId : null;
1261
+ const kase = str(event.caseId) ? event.caseId : null;
1262
+ const ref = str(event.ref) ? event.ref : event.event === SHARE_EVENT.SESSION_SUBMITTED ? session ?? kase : kase ?? session;
1263
+ const done = new Set(options.alreadyFired ?? []);
1264
+ const fired = [];
1265
+ for (const l of shareListenersFor(policies, event.teamId, {
1266
+ event: event.event,
1267
+ teamRows: options.teamRows ?? null
1268
+ })) {
1269
+ const key = firedShareKey(event.event, ref, l);
1270
+ if (done.has(key)) continue;
1271
+ fired.push({ ...l, event: event.event, ref, key });
1272
+ }
1273
+ return fired;
1274
+ }
1132
1275
  // Annotate the CommonJS export names for ESM import in node:
1133
1276
  0 && (module.exports = {
1134
1277
  HTI_SHARE_PLATFORM_PURPOSE_ENABLED,
@@ -1136,10 +1279,12 @@ function resolveShare(input) {
1136
1279
  HTI_SHARE_PLATFORM_STARTER,
1137
1280
  HTI_SHARE_PLATFORM_STARTER_SOURCE,
1138
1281
  INFORMATION_SCOPE_FIELD_HOME_ROWS,
1282
+ SHARE_EVENT,
1139
1283
  SHARE_LEVEL_LABEL,
1140
1284
  SHARE_PLATFORM_STATE_LABEL,
1141
1285
  SHARE_POSTURE_RANK,
1142
1286
  SHARE_REPORTING_PURPOSES,
1287
+ SHARE_TRIGGER_EVENTS,
1143
1288
  SHARING_CEILING_DEFAULT_ROW_KEY,
1144
1289
  SHARING_CEILING_EXTERNAL_ROW_KEY,
1145
1290
  SHARING_CEILING_SCOPE_VERSION,
@@ -1148,6 +1293,8 @@ function resolveShare(input) {
1148
1293
  ceilingCoverage,
1149
1294
  derivePlatformDefault,
1150
1295
  effectiveCeiling,
1296
+ fireShareEvent,
1297
+ firedShareKey,
1151
1298
  hasOwnScopeContent,
1152
1299
  intersectSharingCeilingLists,
1153
1300
  isCeilingCoverageRow,
@@ -1157,6 +1304,7 @@ function resolveShare(input) {
1157
1304
  maskSelectionToCeiling,
1158
1305
  matchTeamRow,
1159
1306
  platformDefaultFor,
1307
+ policyIsShareListener,
1160
1308
  resolveShare,
1161
1309
  rowsExpandedByCeiling,
1162
1310
  rowsOutsideCeiling,
@@ -1165,7 +1313,9 @@ function resolveShare(input) {
1165
1313
  scopeListStrictlyCovers,
1166
1314
  scopeRowWithinCeiling,
1167
1315
  shareDefaultScopeFor,
1316
+ shareListenersFor,
1168
1317
  shareRowCeiling,
1318
+ shareTriggerLabel,
1169
1319
  sharingCeilingCellList,
1170
1320
  sharingCeilingRowKey,
1171
1321
  sharingScopeEditsFromCells,