@htilabs/platform-common-models 0.59.0 → 0.60.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.
- package/README.md +18 -1
- package/dist/index.cjs +10 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/org-directory/index.cjs +5 -4
- package/dist/org-directory/index.cjs.map +1 -1
- package/dist/org-directory/index.d.cts +15 -7
- package/dist/org-directory/index.d.ts +15 -7
- package/dist/org-directory/index.js +5 -4
- package/dist/org-directory/index.js.map +1 -1
- package/dist/points-of-contact/index.cjs +4 -3
- package/dist/points-of-contact/index.cjs.map +1 -1
- package/dist/points-of-contact/index.js +4 -3
- package/dist/points-of-contact/index.js.map +1 -1
- package/dist/schemas/index.cjs +10 -6
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +8 -4
- package/dist/schemas/index.d.ts +8 -4
- package/dist/schemas/index.js +10 -6
- package/dist/schemas/index.js.map +1 -1
- package/package.json +1 -1
- package/src/orgDirectory/__tests__/orgRecord.test.ts +6 -3
- package/src/orgDirectory/orgRecord.ts +14 -6
- package/src/orgDirectory/rules.ts +3 -2
- package/src/schemas/organization.ts +7 -4
package/package.json
CHANGED
|
@@ -152,7 +152,7 @@ describe("arrival and the listed rule", () => {
|
|
|
152
152
|
expect(orgArrivalStamp({ app: " Thread ", userId: "u1", sessionId: "s1" })).toEqual({
|
|
153
153
|
reviewStatus: "pending",
|
|
154
154
|
addedInApp: "thread",
|
|
155
|
-
|
|
155
|
+
addedBy: "u1",
|
|
156
156
|
addedInSession: "s1",
|
|
157
157
|
});
|
|
158
158
|
expect(orgArrivalStamp({ app: "pave", userId: "u1" })).not.toHaveProperty("addedInSession");
|
|
@@ -227,7 +227,7 @@ describe("the read view carries the record", () => {
|
|
|
227
227
|
vspPrivateNonprofit: true,
|
|
228
228
|
reviewStatus: "pending",
|
|
229
229
|
addedInApp: "thread",
|
|
230
|
-
|
|
230
|
+
addedBy: "u1",
|
|
231
231
|
status: 1,
|
|
232
232
|
});
|
|
233
233
|
expect(view).toMatchObject({
|
|
@@ -240,7 +240,7 @@ describe("the read view carries the record", () => {
|
|
|
240
240
|
vspPrivateNonprofit: true,
|
|
241
241
|
reviewStatus: "pending",
|
|
242
242
|
addedInApp: "thread",
|
|
243
|
-
|
|
243
|
+
addedBy: "u1",
|
|
244
244
|
addedInSession: null,
|
|
245
245
|
status: 1,
|
|
246
246
|
listed: true,
|
|
@@ -273,6 +273,9 @@ describe("the read view carries the record", () => {
|
|
|
273
273
|
reviewStatus: "rejected",
|
|
274
274
|
});
|
|
275
275
|
expect(view?.shortName).toBe("TPD");
|
|
276
|
+
expect(toDirectoryOrganizationView({ _id: ID, name: "x", addedByUserId: "u9" })?.addedBy).toBe(
|
|
277
|
+
"u9",
|
|
278
|
+
);
|
|
276
279
|
expect(view?.vsp).toBe(false);
|
|
277
280
|
expect(view?.vspPrivateNonprofit).toBeNull();
|
|
278
281
|
expect(view?.listed).toBe(false);
|
|
@@ -96,21 +96,23 @@ export const ORG_RECORD_FIELD_NAMES = Object.freeze([
|
|
|
96
96
|
"vspPrivateNonprofit",
|
|
97
97
|
"reviewStatus",
|
|
98
98
|
"addedInApp",
|
|
99
|
-
"
|
|
100
|
-
"addedInSession",
|
|
99
|
+
"addedBy",
|
|
101
100
|
] as const);
|
|
102
101
|
export type OrgRecordFieldName = (typeof ORG_RECORD_FIELD_NAMES)[number];
|
|
103
102
|
|
|
104
103
|
/**
|
|
105
104
|
* Stored on the row today and NOT part of the Org definition (UDD Org § 5,
|
|
106
|
-
* "As built today, and not part of this definition"; Org.v1
|
|
107
|
-
* `
|
|
105
|
+
* "As built today, and not part of this definition"; Org.v1's runtime-overlay
|
|
106
|
+
* five: `isCustom`, `added_in_session`, `added_by_user_id`, `type_override`,
|
|
107
|
+
* `division`). PAVE 2.0 writes them; every model declares
|
|
108
108
|
* them so no app silently drops another app's value. `typeKey` is the CVC-48
|
|
109
109
|
* key PAVE writes beside a numeric `type` and retires with the type migration.
|
|
110
110
|
*/
|
|
111
111
|
export const ORG_AS_BUILT_FIELD_NAMES = Object.freeze([
|
|
112
112
|
"requiresROI",
|
|
113
113
|
"isCustom",
|
|
114
|
+
"addedByUserId",
|
|
115
|
+
"addedInSession",
|
|
114
116
|
"division",
|
|
115
117
|
"typeOverride",
|
|
116
118
|
"typeKey",
|
|
@@ -212,13 +214,19 @@ export type OrgVspWrite = z.infer<typeof OrgVspWriteSchema>;
|
|
|
212
214
|
/**
|
|
213
215
|
* How an organization arrived. Never taken from a request body: the server
|
|
214
216
|
* stamps it from the authenticated caller ({@link orgArrivalStamp}).
|
|
217
|
+
*
|
|
218
|
+
* The same three facts, under the same names, as a Program, a Service Listing
|
|
219
|
+
* and a Point of contact carry (`added_by` · `added_in_app` · `review_status`;
|
|
220
|
+
* UDD ratification request R17, "how an organization arrived"). The older
|
|
221
|
+
* runtime-overlay names on the row (`addedByUserId`, `isCustom`) are as-built
|
|
222
|
+
* extras; `addedInSession` is carried as on the program row.
|
|
215
223
|
*/
|
|
216
224
|
export interface OrgArrival {
|
|
217
225
|
reviewStatus: OrgReviewStatus;
|
|
218
226
|
/** The app the organization was added in: `thread`, `pave`, `leads`, `platform`. */
|
|
219
227
|
addedInApp: string;
|
|
220
228
|
/** The adding user's platform `users._id`, as a string. */
|
|
221
|
-
|
|
229
|
+
addedBy: string;
|
|
222
230
|
/** The session it was added in, when there was one. */
|
|
223
231
|
addedInSession?: string;
|
|
224
232
|
}
|
|
@@ -241,7 +249,7 @@ export function orgArrivalStamp(input: {
|
|
|
241
249
|
return {
|
|
242
250
|
reviewStatus: ORG_REVIEW_STATUS.PENDING,
|
|
243
251
|
addedInApp: app,
|
|
244
|
-
|
|
252
|
+
addedBy: userId,
|
|
245
253
|
...(session ? { addedInSession: session } : {}),
|
|
246
254
|
};
|
|
247
255
|
}
|
|
@@ -153,7 +153,8 @@ export interface DirectoryOrganizationView {
|
|
|
153
153
|
/** pending · confirmed · rejected for an organization added inside an app; null on a steward row. */
|
|
154
154
|
reviewStatus: OrgReviewStatus | null;
|
|
155
155
|
addedInApp: string | null;
|
|
156
|
-
addedByUserId
|
|
156
|
+
/** Who added it (a platform `users._id`); a pre-0.60 row's `addedByUserId` reads here too. */
|
|
157
|
+
addedBy: string | null;
|
|
157
158
|
addedInSession: string | null;
|
|
158
159
|
/** The stored lifecycle code (1 active, 2 inactive), else null. */
|
|
159
160
|
status: number | null;
|
|
@@ -201,7 +202,7 @@ export function toDirectoryOrganizationView(raw: unknown): DirectoryOrganization
|
|
|
201
202
|
vspPrivateNonprofit: vsp === true ? flag(r.vspPrivateNonprofit) : null,
|
|
202
203
|
reviewStatus,
|
|
203
204
|
addedInApp: line(r.addedInApp),
|
|
204
|
-
|
|
205
|
+
addedBy: line(r.addedBy) ?? line(r.addedByUserId),
|
|
205
206
|
addedInSession: line(r.addedInSession),
|
|
206
207
|
status,
|
|
207
208
|
listed: isListedOrganization({ status, reviewStatus }),
|
|
@@ -83,8 +83,7 @@ export const orgRecordSchemaDefinition = {
|
|
|
83
83
|
/** The app it was added in (`thread`, `pave`, `leads`, `platform`). */
|
|
84
84
|
addedInApp: { type: String },
|
|
85
85
|
/** The adding user's platform `users._id`. */
|
|
86
|
-
|
|
87
|
-
addedInSession: { type: String },
|
|
86
|
+
addedBy: { type: String },
|
|
88
87
|
};
|
|
89
88
|
|
|
90
89
|
/**
|
|
@@ -95,6 +94,9 @@ export const orgAsBuiltSchemaDefinition = {
|
|
|
95
94
|
/** Informational only: the release check reads the sender's `vsp` (GDR § 5.17 clause 2). */
|
|
96
95
|
requiresROI: { type: Boolean },
|
|
97
96
|
isCustom: { type: Boolean },
|
|
97
|
+
/** The pre-0.60 spelling of `addedBy`; PAVE 2.0 rows carry it. */
|
|
98
|
+
addedByUserId: { type: String },
|
|
99
|
+
addedInSession: { type: String },
|
|
98
100
|
division: { type: String },
|
|
99
101
|
typeOverride: { type: String },
|
|
100
102
|
/** The CVC-48 key PAVE writes beside a numeric `type`; retires with the type migration. */
|
|
@@ -141,10 +143,11 @@ const EXPECTED_INSTANCE: Record<string, string> = {
|
|
|
141
143
|
vspPrivateNonprofit: "Boolean",
|
|
142
144
|
reviewStatus: "String",
|
|
143
145
|
addedInApp: "String",
|
|
144
|
-
|
|
145
|
-
addedInSession: "String",
|
|
146
|
+
addedBy: "String",
|
|
146
147
|
requiresROI: "Boolean",
|
|
147
148
|
isCustom: "Boolean",
|
|
149
|
+
addedByUserId: "String",
|
|
150
|
+
addedInSession: "String",
|
|
148
151
|
division: "String",
|
|
149
152
|
typeOverride: "String",
|
|
150
153
|
typeKey: "String",
|