@htilabs/platform-common-models 0.42.0 → 0.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/dist/{index-uz57Fic9.d.ts → index-BHSRMJvd.d.ts} +1 -1
- package/dist/{index-1pWiqEBC.d.cts → index-DF469Qgd.d.cts} +1 -1
- package/dist/index.cjs +10 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/models/index.d.cts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/schemas/index.d.cts +25 -25
- package/dist/schemas/index.d.ts +25 -25
- package/dist/sharing-ceiling/index.cjs +10 -10
- package/dist/sharing-ceiling/index.cjs.map +1 -1
- package/dist/sharing-ceiling/index.d.cts +9 -2
- package/dist/sharing-ceiling/index.d.ts +9 -2
- package/dist/sharing-ceiling/index.js +10 -10
- package/dist/sharing-ceiling/index.js.map +1 -1
- package/package.json +1 -1
- package/src/sharingCeiling/__tests__/resolveShare.test.ts +114 -0
- package/src/sharingCeiling/resolve.ts +32 -17
- package/dist/{cvcEntry-DAuhe0cd.d.cts → cvcEntry-DQEoFVL2.d.cts} +8 -8
- package/dist/{cvcEntry-DAuhe0cd.d.ts → cvcEntry-DQEoFVL2.d.ts} +8 -8
package/package.json
CHANGED
|
@@ -1105,6 +1105,120 @@ describe("resolveShare — the four states on a share", () => {
|
|
|
1105
1105
|
});
|
|
1106
1106
|
});
|
|
1107
1107
|
|
|
1108
|
+
// ─── 0.42.1 — a grouping named through its rows is not withheld as a unit ──
|
|
1109
|
+
|
|
1110
|
+
describe("a governing list that names a grouping's rows keeps the grouping (0.42.1)", () => {
|
|
1111
|
+
it("names seven screen summaries → the other summaries and the full rows are out, instrument_summary is not, and the row ceiling lists the seven", () => {
|
|
1112
|
+
const seven = [
|
|
1113
|
+
"summary_initial_screen",
|
|
1114
|
+
"summary_ae_intake",
|
|
1115
|
+
"summary_ida",
|
|
1116
|
+
"summary_lap",
|
|
1117
|
+
"summary_danger_assessment",
|
|
1118
|
+
"summary_stalking_assessment",
|
|
1119
|
+
"summary_injury_and_strangulation",
|
|
1120
|
+
];
|
|
1121
|
+
const policies = seeds().map((p) =>
|
|
1122
|
+
p.id === "pol-referral-agency-standard"
|
|
1123
|
+
? { ...p, edited: true, infoScope: ["risk", ...seven] }
|
|
1124
|
+
: p,
|
|
1125
|
+
);
|
|
1126
|
+
const r = read(
|
|
1127
|
+
{
|
|
1128
|
+
purpose: "referral",
|
|
1129
|
+
sender: { accountId: A, teamId: T2 },
|
|
1130
|
+
recipient: { kind: "partner", id: "okcpd" },
|
|
1131
|
+
},
|
|
1132
|
+
policies,
|
|
1133
|
+
);
|
|
1134
|
+
const e = r.scope["instruments"];
|
|
1135
|
+
expect(e?.allowed).toBe(true);
|
|
1136
|
+
expect(e?.excludedItems).not.toContain("instrument_summary");
|
|
1137
|
+
expect(e?.excludedItems).toContain("summary_hope_scale");
|
|
1138
|
+
for (const s of seven) expect(e?.excludedItems).not.toContain(s);
|
|
1139
|
+
const ceiling = shareRowCeiling(r, scope);
|
|
1140
|
+
for (const s of seven) expect(ceiling).toContain(s);
|
|
1141
|
+
expect(ceiling).not.toContain("instrument_summary");
|
|
1142
|
+
expect(ceiling).not.toContain("summary_hope_scale");
|
|
1143
|
+
});
|
|
1144
|
+
|
|
1145
|
+
/** The audit's shared assertion: only the named summary leaves; the grouping is not withheld as a unit. */
|
|
1146
|
+
const lapOnly = (r: ReturnType<typeof read>, list: "excludedItems" | "teamExcludedItems") => {
|
|
1147
|
+
const e = r.scope["instruments"];
|
|
1148
|
+
expect(e?.allowed).toBe(true);
|
|
1149
|
+
expect(e?.[list]).not.toContain("instrument_summary");
|
|
1150
|
+
expect(e?.[list]).not.toContain("summary_lap");
|
|
1151
|
+
expect(e?.[list]).toContain("summary_hope_scale");
|
|
1152
|
+
const ceiling = shareRowCeiling(r, scope);
|
|
1153
|
+
expect(ceiling).toContain("summary_lap");
|
|
1154
|
+
expect(ceiling).not.toContain("summary_hope_scale");
|
|
1155
|
+
expect(ceiling).not.toContain("instrument_summary");
|
|
1156
|
+
};
|
|
1157
|
+
|
|
1158
|
+
it("clamp 5 — the legacy cell chain's list names summary_lap under the starter → only summary_lap leaves", () => {
|
|
1159
|
+
// the account default is synced (not edited) → the starter governs; the legacy list is the ceiling
|
|
1160
|
+
const r = read({
|
|
1161
|
+
purpose: "referral",
|
|
1162
|
+
sender: { accountId: A, teamId: T2 },
|
|
1163
|
+
recipient: { kind: "partner", id: "okcpd" },
|
|
1164
|
+
legacyCeiling: ["identifying", "risk", "summary_lap"],
|
|
1165
|
+
});
|
|
1166
|
+
expect(r.governing?.edited).toBe(false);
|
|
1167
|
+
lapOnly(r, "excludedItems");
|
|
1168
|
+
});
|
|
1169
|
+
|
|
1170
|
+
it("5c — the GOVERNING policy's field-group limit (infoScopeItems) keeps only summary_lap → only summary_lap leaves", () => {
|
|
1171
|
+
const policies = seeds().map((p) =>
|
|
1172
|
+
p.id === "pol-referral-agency-standard"
|
|
1173
|
+
? {
|
|
1174
|
+
...p,
|
|
1175
|
+
edited: true,
|
|
1176
|
+
infoScope: ["identifying", "risk", "instruments"],
|
|
1177
|
+
infoScopeItems: { instruments: ["summary_lap"] },
|
|
1178
|
+
}
|
|
1179
|
+
: p,
|
|
1180
|
+
);
|
|
1181
|
+
const r = read(
|
|
1182
|
+
{
|
|
1183
|
+
purpose: "referral",
|
|
1184
|
+
sender: { accountId: A, teamId: T2 },
|
|
1185
|
+
recipient: { kind: "partner", id: "okcpd" },
|
|
1186
|
+
},
|
|
1187
|
+
policies,
|
|
1188
|
+
);
|
|
1189
|
+
expect(r.governing?.id).toBe("pol-referral-agency-standard");
|
|
1190
|
+
expect(r.teamCeiling).toBeNull();
|
|
1191
|
+
lapOnly(r, "excludedItems");
|
|
1192
|
+
});
|
|
1193
|
+
|
|
1194
|
+
it("5d — the team ceiling's category list names summary_lap over a governing policy that allows instruments → only summary_lap leaves", () => {
|
|
1195
|
+
const policies = seeds().map((p) =>
|
|
1196
|
+
p.id === "pol-zz8-team"
|
|
1197
|
+
? { ...p, infoScope: ["identifying", "risk", "summary_lap"] }
|
|
1198
|
+
: p.id === "pol-zz8-palomar"
|
|
1199
|
+
? { ...p, infoScope: ["identifying", "risk", "instruments"] }
|
|
1200
|
+
: p,
|
|
1201
|
+
);
|
|
1202
|
+
const r = read({ purpose: "referral" }, policies);
|
|
1203
|
+
expect(r.teamCeiling?.id).toBe("pol-zz8-team");
|
|
1204
|
+
expect(r.scope["instruments"]?.excludedItems).not.toContain("summary_hope_scale");
|
|
1205
|
+
lapOnly(r, "teamExcludedItems");
|
|
1206
|
+
});
|
|
1207
|
+
|
|
1208
|
+
it("5d — the team ceiling's field-group limit (infoScopeItems) keeps only summary_lap → only summary_lap leaves", () => {
|
|
1209
|
+
const policies = seeds().map((p) =>
|
|
1210
|
+
p.id === "pol-zz8-team"
|
|
1211
|
+
? { ...p, infoScope: null, infoScopeItems: { instruments: ["summary_lap"] } }
|
|
1212
|
+
: p.id === "pol-zz8-palomar"
|
|
1213
|
+
? { ...p, infoScope: ["identifying", "instruments"] }
|
|
1214
|
+
: p,
|
|
1215
|
+
);
|
|
1216
|
+
const r = read({ purpose: "referral" }, policies);
|
|
1217
|
+
expect(r.teamCeiling?.id).toBe("pol-zz8-team");
|
|
1218
|
+
lapOnly(r, "teamExcludedItems");
|
|
1219
|
+
});
|
|
1220
|
+
});
|
|
1221
|
+
|
|
1108
1222
|
// ─── The helpers the apps adopt with ────────────────────────────────────────
|
|
1109
1223
|
|
|
1110
1224
|
describe("platformDefaultFor / legacyCeiling as an answer / shareRowCeiling", () => {
|
|
@@ -265,10 +265,17 @@ export interface ShareCategoryEntry {
|
|
|
265
265
|
readonly platformRequired: { readonly rulePath: string } | null;
|
|
266
266
|
/** Rows under the platform safety floor — never leave. */
|
|
267
267
|
readonly floorItems: string[];
|
|
268
|
-
/**
|
|
268
|
+
/**
|
|
269
|
+
* Rows the governing list / the account's heightened toggles / the ceiling leave out. A code is
|
|
270
|
+
* withheld when it OR AN ANCESTOR is listed here. Since 0.42.1 a grouping is listed only when
|
|
271
|
+
* nothing beneath it is covered — when a list names some of its rows, the grouping is NOT listed
|
|
272
|
+
* and its uncovered rows are listed one by one instead. So a grouping code's absence here does
|
|
273
|
+
* not mean the whole grouping may leave: for a send decision read `shareRowCeiling` +
|
|
274
|
+
* `rowsOverCeiling`, never a grouping-code check against `excludedItems` alone.
|
|
275
|
+
*/
|
|
269
276
|
readonly excludedItems: string[];
|
|
270
277
|
readonly excludedReason: string | null;
|
|
271
|
-
/** Rows the sending team's own policy leaves out (5d). */
|
|
278
|
+
/** Rows the sending team's own policy leaves out (5d). Same shape and same caveat as `excludedItems`. */
|
|
272
279
|
readonly teamExcludedItems: string[];
|
|
273
280
|
readonly teamExcludedReason: string | null;
|
|
274
281
|
}
|
|
@@ -1109,6 +1116,20 @@ export function resolveShare(input: ShareResolveInput): ShareResolution {
|
|
|
1109
1116
|
let excludedReason: string | null = null;
|
|
1110
1117
|
const teamExcludedItems: string[] = [];
|
|
1111
1118
|
let teamExcludedReason: string | null = null;
|
|
1119
|
+
// A row is OUTSIDE a list only when neither it nor anything beneath it is covered: a grouping
|
|
1120
|
+
// whose rows the list names by name (`instrument_summary` named only through `summary_lap`)
|
|
1121
|
+
// is not withheld as a unit — its uncovered rows are, each at its own grain (0.42.1; the
|
|
1122
|
+
// Thread inside-ceiling adoption found the whole grouping dropped with its named rows).
|
|
1123
|
+
// Latent gap: a grouping that carries its OWN fields (INFORMATION_SCOPE_FIELD_HOME_ROWS) and
|
|
1124
|
+
// whose children are all named, but not itself, is not withheld here — its own fields would
|
|
1125
|
+
// then leave, contrary to coverage rule 2 (`ceilingCoverage`, hasOwnContent → false). No live
|
|
1126
|
+
// grouping has own content today; whoever adds a field-homed grouping must handle it here.
|
|
1127
|
+
const outside = (covered: (r: string) => boolean): string[] =>
|
|
1128
|
+
items.filter(
|
|
1129
|
+
(r) =>
|
|
1130
|
+
!covered(r) &&
|
|
1131
|
+
!items.some((d) => d !== r && covered(d) && scope.ancestorsOf(d).includes(r)),
|
|
1132
|
+
);
|
|
1112
1133
|
const addExcluded = (rows: readonly string[], why: string): void => {
|
|
1113
1134
|
for (const r of rows)
|
|
1114
1135
|
if (!floorItems.includes(r) && !excludedItems.includes(r))
|
|
@@ -1160,7 +1181,7 @@ export function resolveShare(input: ShareResolveInput): ShareResolution {
|
|
|
1160
1181
|
!scopeListStrictlyCovers(scope, groupCeiling, g)
|
|
1161
1182
|
) {
|
|
1162
1183
|
addExcluded(
|
|
1163
|
-
|
|
1184
|
+
outside((r) => scopeListCovers(scope, groupCeiling, g, r)),
|
|
1164
1185
|
"Outside the payload for this purpose",
|
|
1165
1186
|
);
|
|
1166
1187
|
}
|
|
@@ -1181,19 +1202,17 @@ export function resolveShare(input: ShareResolveInput): ShareResolution {
|
|
|
1181
1202
|
!scopeListStrictlyCovers(scope, govList, g)
|
|
1182
1203
|
) {
|
|
1183
1204
|
addExcluded(
|
|
1184
|
-
|
|
1205
|
+
outside((r) => scopeListCovers(scope, govList, g, r)),
|
|
1185
1206
|
`Outside what the “${govName}” policy allows for this purpose`,
|
|
1186
1207
|
);
|
|
1187
1208
|
}
|
|
1188
1209
|
const govRows = polScopeBinds ? own<unknown>(govItems, g) : undefined;
|
|
1189
1210
|
if (allowed && !req && isStringList(govRows)) {
|
|
1190
1211
|
const keep = new Set(govRows);
|
|
1212
|
+
const kept = (r: string): boolean =>
|
|
1213
|
+
keep.has(r) || scope.ancestorsOf(r).some((a) => a !== g && keep.has(a));
|
|
1191
1214
|
addExcluded(
|
|
1192
|
-
|
|
1193
|
-
(r) =>
|
|
1194
|
-
!keep.has(r) &&
|
|
1195
|
-
!scope.ancestorsOf(r).some((a) => a !== g && keep.has(a)),
|
|
1196
|
-
),
|
|
1215
|
+
outside(kept),
|
|
1197
1216
|
`Outside what the “${govName}” policy allows for this purpose`,
|
|
1198
1217
|
);
|
|
1199
1218
|
}
|
|
@@ -1211,18 +1230,14 @@ export function resolveShare(input: ShareResolveInput): ShareResolution {
|
|
|
1211
1230
|
const why = `Outside what your team's “${tcNamed?.name}” policy allows`;
|
|
1212
1231
|
const outRows = new Set<string>();
|
|
1213
1232
|
if (tcScope !== null && !scopeListStrictlyCovers(scope, tcScope, g)) {
|
|
1214
|
-
for (const r of
|
|
1215
|
-
if (!scopeListCovers(scope, tcScope, g, r)) outRows.add(r);
|
|
1233
|
+
for (const r of outside((x) => scopeListCovers(scope, tcScope, g, x))) outRows.add(r);
|
|
1216
1234
|
}
|
|
1217
1235
|
const tcRows = own<unknown>(tcItems, g);
|
|
1218
1236
|
if (isStringList(tcRows)) {
|
|
1219
1237
|
const keep = new Set(tcRows);
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
!scope.ancestorsOf(r).some((a) => a !== g && keep.has(a))
|
|
1224
|
-
)
|
|
1225
|
-
outRows.add(r);
|
|
1238
|
+
const kept = (r: string): boolean =>
|
|
1239
|
+
keep.has(r) || scope.ancestorsOf(r).some((a) => a !== g && keep.has(a));
|
|
1240
|
+
for (const r of outside(kept)) outRows.add(r);
|
|
1226
1241
|
}
|
|
1227
1242
|
for (const r of outRows)
|
|
1228
1243
|
if (!floorItems.includes(r) && !excludedItems.includes(r))
|
|
@@ -233,18 +233,18 @@ type SectionQuestionRef = InferRawDocType<typeof sectionQuestionRefSchema>;
|
|
|
233
233
|
declare const guidanceSchema: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
234
234
|
_id: false;
|
|
235
235
|
}, {
|
|
236
|
-
type: "tip" | "warning" | "prompt";
|
|
237
236
|
text: string;
|
|
238
|
-
}, mongoose.Document<unknown, {}, {
|
|
239
237
|
type: "tip" | "warning" | "prompt";
|
|
238
|
+
}, mongoose.Document<unknown, {}, {
|
|
240
239
|
text: string;
|
|
240
|
+
type: "tip" | "warning" | "prompt";
|
|
241
241
|
}, {
|
|
242
242
|
id: string;
|
|
243
243
|
}, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
|
|
244
244
|
_id: false;
|
|
245
245
|
}>> & Omit<{
|
|
246
|
-
type: "tip" | "warning" | "prompt";
|
|
247
246
|
text: string;
|
|
247
|
+
type: "tip" | "warning" | "prompt";
|
|
248
248
|
} & {
|
|
249
249
|
_id: mongoose.Types.ObjectId;
|
|
250
250
|
} & {
|
|
@@ -252,8 +252,8 @@ declare const guidanceSchema: Schema<any, mongoose.Model<any, any, any, any, any
|
|
|
252
252
|
}, "id"> & {
|
|
253
253
|
id: string;
|
|
254
254
|
}, unknown, {
|
|
255
|
-
type: "tip" | "warning" | "prompt";
|
|
256
255
|
text: string;
|
|
256
|
+
type: "tip" | "warning" | "prompt";
|
|
257
257
|
} & {
|
|
258
258
|
_id: mongoose.Types.ObjectId;
|
|
259
259
|
} & {
|
|
@@ -294,18 +294,18 @@ declare const sectionSchemaDefinition: {
|
|
|
294
294
|
type: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
295
295
|
_id: false;
|
|
296
296
|
}, {
|
|
297
|
-
type: "tip" | "warning" | "prompt";
|
|
298
297
|
text: string;
|
|
299
|
-
}, mongoose.Document<unknown, {}, {
|
|
300
298
|
type: "tip" | "warning" | "prompt";
|
|
299
|
+
}, mongoose.Document<unknown, {}, {
|
|
301
300
|
text: string;
|
|
301
|
+
type: "tip" | "warning" | "prompt";
|
|
302
302
|
}, {
|
|
303
303
|
id: string;
|
|
304
304
|
}, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
|
|
305
305
|
_id: false;
|
|
306
306
|
}>> & Omit<{
|
|
307
|
-
type: "tip" | "warning" | "prompt";
|
|
308
307
|
text: string;
|
|
308
|
+
type: "tip" | "warning" | "prompt";
|
|
309
309
|
} & {
|
|
310
310
|
_id: mongoose.Types.ObjectId;
|
|
311
311
|
} & {
|
|
@@ -313,8 +313,8 @@ declare const sectionSchemaDefinition: {
|
|
|
313
313
|
}, "id"> & {
|
|
314
314
|
id: string;
|
|
315
315
|
}, unknown, {
|
|
316
|
-
type: "tip" | "warning" | "prompt";
|
|
317
316
|
text: string;
|
|
317
|
+
type: "tip" | "warning" | "prompt";
|
|
318
318
|
} & {
|
|
319
319
|
_id: mongoose.Types.ObjectId;
|
|
320
320
|
} & {
|
|
@@ -233,18 +233,18 @@ type SectionQuestionRef = InferRawDocType<typeof sectionQuestionRefSchema>;
|
|
|
233
233
|
declare const guidanceSchema: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
234
234
|
_id: false;
|
|
235
235
|
}, {
|
|
236
|
-
type: "tip" | "warning" | "prompt";
|
|
237
236
|
text: string;
|
|
238
|
-
}, mongoose.Document<unknown, {}, {
|
|
239
237
|
type: "tip" | "warning" | "prompt";
|
|
238
|
+
}, mongoose.Document<unknown, {}, {
|
|
240
239
|
text: string;
|
|
240
|
+
type: "tip" | "warning" | "prompt";
|
|
241
241
|
}, {
|
|
242
242
|
id: string;
|
|
243
243
|
}, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
|
|
244
244
|
_id: false;
|
|
245
245
|
}>> & Omit<{
|
|
246
|
-
type: "tip" | "warning" | "prompt";
|
|
247
246
|
text: string;
|
|
247
|
+
type: "tip" | "warning" | "prompt";
|
|
248
248
|
} & {
|
|
249
249
|
_id: mongoose.Types.ObjectId;
|
|
250
250
|
} & {
|
|
@@ -252,8 +252,8 @@ declare const guidanceSchema: Schema<any, mongoose.Model<any, any, any, any, any
|
|
|
252
252
|
}, "id"> & {
|
|
253
253
|
id: string;
|
|
254
254
|
}, unknown, {
|
|
255
|
-
type: "tip" | "warning" | "prompt";
|
|
256
255
|
text: string;
|
|
256
|
+
type: "tip" | "warning" | "prompt";
|
|
257
257
|
} & {
|
|
258
258
|
_id: mongoose.Types.ObjectId;
|
|
259
259
|
} & {
|
|
@@ -294,18 +294,18 @@ declare const sectionSchemaDefinition: {
|
|
|
294
294
|
type: Schema<any, mongoose.Model<any, any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
295
295
|
_id: false;
|
|
296
296
|
}, {
|
|
297
|
-
type: "tip" | "warning" | "prompt";
|
|
298
297
|
text: string;
|
|
299
|
-
}, mongoose.Document<unknown, {}, {
|
|
300
298
|
type: "tip" | "warning" | "prompt";
|
|
299
|
+
}, mongoose.Document<unknown, {}, {
|
|
301
300
|
text: string;
|
|
301
|
+
type: "tip" | "warning" | "prompt";
|
|
302
302
|
}, {
|
|
303
303
|
id: string;
|
|
304
304
|
}, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
|
|
305
305
|
_id: false;
|
|
306
306
|
}>> & Omit<{
|
|
307
|
-
type: "tip" | "warning" | "prompt";
|
|
308
307
|
text: string;
|
|
308
|
+
type: "tip" | "warning" | "prompt";
|
|
309
309
|
} & {
|
|
310
310
|
_id: mongoose.Types.ObjectId;
|
|
311
311
|
} & {
|
|
@@ -313,8 +313,8 @@ declare const sectionSchemaDefinition: {
|
|
|
313
313
|
}, "id"> & {
|
|
314
314
|
id: string;
|
|
315
315
|
}, unknown, {
|
|
316
|
-
type: "tip" | "warning" | "prompt";
|
|
317
316
|
text: string;
|
|
317
|
+
type: "tip" | "warning" | "prompt";
|
|
318
318
|
} & {
|
|
319
319
|
_id: mongoose.Types.ObjectId;
|
|
320
320
|
} & {
|