@7365admin1/core 3.59.0 → 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 +20 -0
- package/dist/index.d.ts +13 -5
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/e2e/resident-self-signup-pinning.e2e.test.mjs +65 -0
- package/test/self-signup-files.test.mjs +276 -0
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: "" },
|
|
@@ -58210,6 +58220,24 @@ function useGuestManagementController() {
|
|
|
58210
58220
|
import Joi71 from "joi";
|
|
58211
58221
|
import { BadRequestError as BadRequestError127, logger as logger98 } from "@7365admin1/node-server-utils";
|
|
58212
58222
|
import { NotFoundError as NotFoundError37, UnauthorizedError as UnauthorizedError14 } from "@7365admin1/node-server-utils";
|
|
58223
|
+
|
|
58224
|
+
// src/utils/self-signup-files.util.ts
|
|
58225
|
+
function dropUnsentFiles(body) {
|
|
58226
|
+
if (!Array.isArray(body?.files))
|
|
58227
|
+
return body;
|
|
58228
|
+
return { ...body, files: body.files.filter((file) => file?.id) };
|
|
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
|
+
}
|
|
58239
|
+
|
|
58240
|
+
// src/controllers/person.controller.ts
|
|
58213
58241
|
function usePersonController() {
|
|
58214
58242
|
const {
|
|
58215
58243
|
getAll: _getAll,
|
|
@@ -58248,7 +58276,9 @@ function usePersonController() {
|
|
|
58248
58276
|
return actor;
|
|
58249
58277
|
}
|
|
58250
58278
|
async function addResidentSelfSignUp(req, res, next) {
|
|
58251
|
-
const
|
|
58279
|
+
const body = dropUnsentFiles(req.body);
|
|
58280
|
+
const notUploaded = unsentFileNames(req.body);
|
|
58281
|
+
const { error, value } = schemaResidentSelfSignUp.validate(body, {
|
|
58252
58282
|
abortEarly: false,
|
|
58253
58283
|
stripUnknown: true
|
|
58254
58284
|
});
|
|
@@ -58269,7 +58299,10 @@ function usePersonController() {
|
|
|
58269
58299
|
// "pending" or "active", so a caller who sent `platform: "web"` got a
|
|
58270
58300
|
// live account without anyone reviewing them.
|
|
58271
58301
|
status: SELF_SIGNUP_STATUS,
|
|
58272
|
-
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 } : {}
|
|
58273
58306
|
};
|
|
58274
58307
|
try {
|
|
58275
58308
|
const data = await _add(payload);
|