@7365admin1/core 3.59.1 → 3.59.2
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/CHANGELOG.md +10 -0
- package/dist/index.d.ts +13 -5
- package/dist/index.js +24 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/resident-self-signup-pinning.e2e.test.mjs +65 -0
- package/test/self-signup-files.test.mjs +125 -3
package/dist/index.mjs
CHANGED
|
@@ -17173,6 +17173,11 @@ var schemaPerson = Joi17.object({
|
|
|
17173
17173
|
plates: Joi17.array().items(schemaPlate).optional().allow(null),
|
|
17174
17174
|
isOwner: Joi17.boolean().required(),
|
|
17175
17175
|
files: Joi17.array().items(schemaFiles).optional().allow(null),
|
|
17176
|
+
// Set by `addResidentSelfSignUp`, not by any caller: it is absent from the
|
|
17177
|
+
// self-signup allow-list, which validates with `stripUnknown`. It is named
|
|
17178
|
+
// here only because `MPerson` runs `schemaPerson` over the finished payload
|
|
17179
|
+
// and Joi refuses unknown keys.
|
|
17180
|
+
filesNotUploaded: Joi17.array().items(Joi17.string()).optional(),
|
|
17176
17181
|
password: Joi17.string().optional().allow(null, ""),
|
|
17177
17182
|
plateNumber: Joi17.string().optional().allow(null, ""),
|
|
17178
17183
|
platform: Joi17.string().valid("web", "mobile").optional().allow(null, ""),
|
|
@@ -17329,6 +17334,11 @@ function MPerson(value) {
|
|
|
17329
17334
|
plates: value.plates ?? [],
|
|
17330
17335
|
isOwner: value.isOwner ?? false,
|
|
17331
17336
|
files: value.files ?? [],
|
|
17337
|
+
// Conditional, because this return is a WHITELIST: everything not named
|
|
17338
|
+
// here is dropped on the way to the database, and a bare
|
|
17339
|
+
// `filesNotUploaded: value.filesNotUploaded` would add an `undefined` key
|
|
17340
|
+
// to every person ever written. Absent when every upload landed.
|
|
17341
|
+
...value.filesNotUploaded?.length ? { filesNotUploaded: value.filesNotUploaded } : {},
|
|
17332
17342
|
plateNumber: value.plateNumber ?? "",
|
|
17333
17343
|
platForm: value.platform ?? "",
|
|
17334
17344
|
approvedBy: value.approvedBy ?? { id: "", name: "" },
|
|
@@ -58217,6 +58227,15 @@ function dropUnsentFiles(body) {
|
|
|
58217
58227
|
return body;
|
|
58218
58228
|
return { ...body, files: body.files.filter((file) => file?.id) };
|
|
58219
58229
|
}
|
|
58230
|
+
var MAX_UNSENT_FILE_NAMES = 10;
|
|
58231
|
+
var MAX_UNSENT_FILE_NAME_LENGTH = 120;
|
|
58232
|
+
function unsentFileNames(body) {
|
|
58233
|
+
if (!body || !Array.isArray(body.files))
|
|
58234
|
+
return [];
|
|
58235
|
+
return body.files.filter((file) => file && !file.id).slice(0, MAX_UNSENT_FILE_NAMES).map(
|
|
58236
|
+
(file) => typeof file.name === "string" && file.name.trim() ? file.name.trim().slice(0, MAX_UNSENT_FILE_NAME_LENGTH) : "Unnamed document"
|
|
58237
|
+
);
|
|
58238
|
+
}
|
|
58220
58239
|
|
|
58221
58240
|
// src/controllers/person.controller.ts
|
|
58222
58241
|
function usePersonController() {
|
|
@@ -58258,6 +58277,7 @@ function usePersonController() {
|
|
|
58258
58277
|
}
|
|
58259
58278
|
async function addResidentSelfSignUp(req, res, next) {
|
|
58260
58279
|
const body = dropUnsentFiles(req.body);
|
|
58280
|
+
const notUploaded = unsentFileNames(req.body);
|
|
58261
58281
|
const { error, value } = schemaResidentSelfSignUp.validate(body, {
|
|
58262
58282
|
abortEarly: false,
|
|
58263
58283
|
stripUnknown: true
|
|
@@ -58279,7 +58299,10 @@ function usePersonController() {
|
|
|
58279
58299
|
// "pending" or "active", so a caller who sent `platform: "web"` got a
|
|
58280
58300
|
// live account without anyone reviewing them.
|
|
58281
58301
|
status: SELF_SIGNUP_STATUS,
|
|
58282
|
-
platform: SELF_SIGNUP_PLATFORM
|
|
58302
|
+
platform: SELF_SIGNUP_PLATFORM,
|
|
58303
|
+
// Pinned the same way, and omitted entirely when every upload landed, so
|
|
58304
|
+
// a normal registration is written exactly as it is written today.
|
|
58305
|
+
...notUploaded.length > 0 ? { filesNotUploaded: notUploaded } : {}
|
|
58283
58306
|
};
|
|
58284
58307
|
try {
|
|
58285
58308
|
const data = await _add(payload);
|