@web-ts-toolkit/access-router 0.47.0 → 0.48.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 +22 -1
- package/advanced.d.mts +62 -1
- package/advanced.d.ts +62 -1
- package/advanced.js +28 -8
- package/advanced.mjs +28 -8
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +283 -100
- package/index.mjs +283 -100
- package/llms.txt +2 -1
- package/package.json +3 -3
- package/{parsers-BidvJUu7.d.mts → parsers-D6iK8khR.d.mts} +131 -1
- package/{parsers-BidvJUu7.d.ts → parsers-D6iK8khR.d.ts} +131 -1
package/index.js
CHANGED
|
@@ -193,6 +193,12 @@ function genPagination({
|
|
|
193
193
|
}
|
|
194
194
|
return { skip: _skip, limit: _limit };
|
|
195
195
|
}
|
|
196
|
+
function parseSelectParam(select) {
|
|
197
|
+
if (select === void 0) return void 0;
|
|
198
|
+
const values = Array.isArray(select) ? select : [select];
|
|
199
|
+
const fields = values.flatMap((value) => String(value).split(/[\s,]+/)).filter(Boolean);
|
|
200
|
+
return fields.length > 0 ? fields : void 0;
|
|
201
|
+
}
|
|
196
202
|
function normalizeSelect(select) {
|
|
197
203
|
if (Array.isArray(select)) return (0, import_utils2.flattenDeep)(select.map(normalizeSelect));
|
|
198
204
|
if ((0, import_utils2.isPlainObject)(select)) {
|
|
@@ -234,6 +240,15 @@ function getDocPermissions(modelName, doc) {
|
|
|
234
240
|
const permissions = getDocValue(doc, docPermissionField, {});
|
|
235
241
|
return (0, import_utils3.isPlainObject)(permissions) ? permissions : {};
|
|
236
242
|
}
|
|
243
|
+
function stripUnexposedDocPermissions(modelName, doc) {
|
|
244
|
+
const exposed = getModelOption(modelName, "exposedDocPermissionKeys");
|
|
245
|
+
if (exposed === void 0) return;
|
|
246
|
+
const docPermissionField = getModelOption(modelName, "documentPermissionField");
|
|
247
|
+
const current = getDocValue(doc, docPermissionField, void 0);
|
|
248
|
+
if (!(0, import_utils3.isPlainObject)(current)) return;
|
|
249
|
+
const keep = /* @__PURE__ */ new Set(["_view", "_edit", ...exposed]);
|
|
250
|
+
setDocValue(doc, docPermissionField, Object.fromEntries(Object.entries(current).filter(([key]) => keep.has(key))));
|
|
251
|
+
}
|
|
237
252
|
function toObject(doc) {
|
|
238
253
|
return isDocument(doc) ? doc.toObject() : doc;
|
|
239
254
|
}
|
|
@@ -1222,11 +1237,11 @@ var classifyPermissionSchema = (permissionSchema, modelPermissionPrefix) => {
|
|
|
1222
1237
|
}
|
|
1223
1238
|
if ((0, import_utils11.isBoolean)(value)) {
|
|
1224
1239
|
globalPermissionKeys[accessKey].push(schemaKey);
|
|
1225
|
-
|
|
1240
|
+
continue;
|
|
1226
1241
|
}
|
|
1227
1242
|
if (hasModelPermission(value, modelPermissionPrefix)) {
|
|
1228
1243
|
modelPermissionKeys[accessKey].push(schemaKey);
|
|
1229
|
-
|
|
1244
|
+
continue;
|
|
1230
1245
|
}
|
|
1231
1246
|
globalPermissionKeys[accessKey].push(schemaKey);
|
|
1232
1247
|
}
|
|
@@ -2477,7 +2492,8 @@ var Base = class {
|
|
|
2477
2492
|
...options,
|
|
2478
2493
|
access: "read",
|
|
2479
2494
|
lean: true,
|
|
2480
|
-
includePermissions: false
|
|
2495
|
+
includePermissions: false,
|
|
2496
|
+
includeFieldPermissions: false
|
|
2481
2497
|
};
|
|
2482
2498
|
const result = await svc.findOne(filter2, this.sanitizeIncludeArgs(args), trustedOptions);
|
|
2483
2499
|
if (result.success) {
|
|
@@ -2505,6 +2521,7 @@ var Base = class {
|
|
|
2505
2521
|
...options,
|
|
2506
2522
|
lean: true,
|
|
2507
2523
|
includePermissions: false,
|
|
2524
|
+
includeFieldPermissions: false,
|
|
2508
2525
|
includeCount: false
|
|
2509
2526
|
};
|
|
2510
2527
|
const trustedResult = await svc.find(filter2, trustedArgs, trustedOptions);
|
|
@@ -2635,7 +2652,7 @@ var Base = class {
|
|
|
2635
2652
|
include: nestedInclude,
|
|
2636
2653
|
overrides: { filter: authorized }
|
|
2637
2654
|
},
|
|
2638
|
-
{ access: "read", lean: true, includePermissions: false }
|
|
2655
|
+
{ access: "read", lean: true, includePermissions: false, includeFieldPermissions: false }
|
|
2639
2656
|
);
|
|
2640
2657
|
} catch (error2) {
|
|
2641
2658
|
const clientResult = this.getClientRequestErrorResult(error2);
|
|
@@ -2713,7 +2730,7 @@ var Base = class {
|
|
|
2713
2730
|
include: nestedInclude,
|
|
2714
2731
|
overrides: { filter: authorized }
|
|
2715
2732
|
},
|
|
2716
|
-
{ access: "read", lean: true, includePermissions: false }
|
|
2733
|
+
{ access: "read", lean: true, includePermissions: false, includeFieldPermissions: false }
|
|
2717
2734
|
);
|
|
2718
2735
|
} catch (error2) {
|
|
2719
2736
|
const clientResult = this.getClientRequestErrorResult(error2);
|
|
@@ -2798,7 +2815,7 @@ var Base = class {
|
|
|
2798
2815
|
include: nestedInclude,
|
|
2799
2816
|
overrides: { filter: authorized }
|
|
2800
2817
|
},
|
|
2801
|
-
{ includeCount: false, lean: true, includePermissions: false }
|
|
2818
|
+
{ includeCount: false, lean: true, includePermissions: false, includeFieldPermissions: false }
|
|
2802
2819
|
);
|
|
2803
2820
|
} catch (error2) {
|
|
2804
2821
|
const clientResult = this.getClientRequestErrorResult(error2);
|
|
@@ -3379,6 +3396,16 @@ async function getParentDoc(service, id, sub, args, options) {
|
|
|
3379
3396
|
}
|
|
3380
3397
|
|
|
3381
3398
|
// src/services/model-service-defaults.ts
|
|
3399
|
+
function applyPermissionsPosture(service, resolved) {
|
|
3400
|
+
const posture = service.getPermissionsPosture();
|
|
3401
|
+
if (posture.stripPermissionsField) {
|
|
3402
|
+
resolved.includePermissions = false;
|
|
3403
|
+
resolved.includeFieldPermissions = false;
|
|
3404
|
+
} else if (posture.disableFieldPermissions) {
|
|
3405
|
+
resolved.includeFieldPermissions = false;
|
|
3406
|
+
}
|
|
3407
|
+
return resolved;
|
|
3408
|
+
}
|
|
3382
3409
|
function resolveFindOneArgs(service, args = {}) {
|
|
3383
3410
|
return {
|
|
3384
3411
|
select: args.select ?? service.defaults.findOneArgs?.select,
|
|
@@ -3389,13 +3416,15 @@ function resolveFindOneArgs(service, args = {}) {
|
|
|
3389
3416
|
};
|
|
3390
3417
|
}
|
|
3391
3418
|
function resolveFindOneOptions(service, options = {}) {
|
|
3392
|
-
|
|
3419
|
+
const includePermissions = options.includePermissions ?? service.defaults.findOneOptions?.includePermissions ?? true;
|
|
3420
|
+
return applyPermissionsPosture(service, {
|
|
3393
3421
|
skim: options.skim ?? service.defaults.findOneOptions?.skim ?? false,
|
|
3394
|
-
includePermissions
|
|
3422
|
+
includePermissions,
|
|
3423
|
+
includeFieldPermissions: options.includeFieldPermissions ?? service.defaults.findOneOptions?.includeFieldPermissions ?? includePermissions,
|
|
3395
3424
|
access: options.access ?? service.defaults.findOneOptions?.access ?? "read",
|
|
3396
3425
|
populateAccess: options.populateAccess ?? service.defaults.findOneOptions?.populateAccess,
|
|
3397
3426
|
lean: options.lean ?? service.defaults.findOneOptions?.lean ?? false
|
|
3398
|
-
};
|
|
3427
|
+
});
|
|
3399
3428
|
}
|
|
3400
3429
|
function resolveFindByIdArgs(service, args = {}) {
|
|
3401
3430
|
return {
|
|
@@ -3406,13 +3435,15 @@ function resolveFindByIdArgs(service, args = {}) {
|
|
|
3406
3435
|
};
|
|
3407
3436
|
}
|
|
3408
3437
|
function resolveFindByIdOptions(service, options = {}) {
|
|
3409
|
-
|
|
3438
|
+
const includePermissions = options.includePermissions ?? service.defaults.findByIdOptions?.includePermissions ?? true;
|
|
3439
|
+
return applyPermissionsPosture(service, {
|
|
3410
3440
|
skim: options.skim ?? service.defaults.findByIdOptions?.skim ?? false,
|
|
3411
|
-
includePermissions
|
|
3441
|
+
includePermissions,
|
|
3442
|
+
includeFieldPermissions: options.includeFieldPermissions ?? service.defaults.findByIdOptions?.includeFieldPermissions ?? includePermissions,
|
|
3412
3443
|
access: options.access ?? service.defaults.findByIdOptions?.access ?? "read",
|
|
3413
3444
|
populateAccess: options.populateAccess ?? service.defaults.findByIdOptions?.populateAccess,
|
|
3414
3445
|
lean: options.lean ?? service.defaults.findByIdOptions?.lean ?? false
|
|
3415
|
-
};
|
|
3446
|
+
});
|
|
3416
3447
|
}
|
|
3417
3448
|
function resolveFindArgs(service, args = {}) {
|
|
3418
3449
|
return {
|
|
@@ -3428,13 +3459,15 @@ function resolveFindArgs(service, args = {}) {
|
|
|
3428
3459
|
};
|
|
3429
3460
|
}
|
|
3430
3461
|
function resolveFindOptions(service, options = {}) {
|
|
3431
|
-
|
|
3462
|
+
const includePermissions = options.includePermissions ?? service.defaults.findOptions?.includePermissions ?? true;
|
|
3463
|
+
return applyPermissionsPosture(service, {
|
|
3432
3464
|
skim: options.skim ?? service.defaults.findOptions?.skim ?? false,
|
|
3433
|
-
includePermissions
|
|
3465
|
+
includePermissions,
|
|
3466
|
+
includeFieldPermissions: options.includeFieldPermissions ?? service.defaults.findOptions?.includeFieldPermissions ?? includePermissions,
|
|
3434
3467
|
includeCount: options.includeCount ?? service.defaults.findOptions?.includeCount ?? false,
|
|
3435
3468
|
populateAccess: options.populateAccess ?? service.defaults.findOptions?.populateAccess ?? "read",
|
|
3436
3469
|
lean: options.lean ?? service.defaults.findOptions?.lean ?? false
|
|
3437
|
-
};
|
|
3470
|
+
});
|
|
3438
3471
|
}
|
|
3439
3472
|
function resolveCreateArgs(service, args = {}) {
|
|
3440
3473
|
return {
|
|
@@ -3442,11 +3475,13 @@ function resolveCreateArgs(service, args = {}) {
|
|
|
3442
3475
|
};
|
|
3443
3476
|
}
|
|
3444
3477
|
function resolveCreateOptions(service, options = {}) {
|
|
3445
|
-
|
|
3478
|
+
const includePermissions = options.includePermissions ?? service.defaults.createOptions?.includePermissions ?? true;
|
|
3479
|
+
return applyPermissionsPosture(service, {
|
|
3446
3480
|
skim: options.skim ?? service.defaults.createOptions?.skim ?? false,
|
|
3447
|
-
includePermissions
|
|
3481
|
+
includePermissions,
|
|
3482
|
+
includeFieldPermissions: options.includeFieldPermissions ?? service.defaults.createOptions?.includeFieldPermissions ?? includePermissions,
|
|
3448
3483
|
populateAccess: options.populateAccess ?? service.defaults.createOptions?.populateAccess ?? "read"
|
|
3449
|
-
};
|
|
3484
|
+
});
|
|
3450
3485
|
}
|
|
3451
3486
|
function resolveUpdateOneArgs(service, args = {}) {
|
|
3452
3487
|
return {
|
|
@@ -3455,11 +3490,13 @@ function resolveUpdateOneArgs(service, args = {}) {
|
|
|
3455
3490
|
};
|
|
3456
3491
|
}
|
|
3457
3492
|
function resolveUpdateOneOptions(service, options = {}) {
|
|
3458
|
-
|
|
3493
|
+
const includePermissions = options.includePermissions ?? service.defaults.updateOneOptions?.includePermissions ?? true;
|
|
3494
|
+
return applyPermissionsPosture(service, {
|
|
3459
3495
|
skim: options.skim ?? service.defaults.updateOneOptions?.skim ?? false,
|
|
3460
|
-
includePermissions
|
|
3496
|
+
includePermissions,
|
|
3497
|
+
includeFieldPermissions: options.includeFieldPermissions ?? service.defaults.updateOneOptions?.includeFieldPermissions ?? includePermissions,
|
|
3461
3498
|
populateAccess: options.populateAccess ?? service.defaults.updateOneOptions?.populateAccess ?? "read"
|
|
3462
|
-
};
|
|
3499
|
+
});
|
|
3463
3500
|
}
|
|
3464
3501
|
function resolveUpdateByIdArgs(service, args = {}) {
|
|
3465
3502
|
return {
|
|
@@ -3468,11 +3505,13 @@ function resolveUpdateByIdArgs(service, args = {}) {
|
|
|
3468
3505
|
};
|
|
3469
3506
|
}
|
|
3470
3507
|
function resolveUpdateByIdOptions(service, options = {}) {
|
|
3471
|
-
|
|
3508
|
+
const includePermissions = options.includePermissions ?? service.defaults.updateByIdOptions?.includePermissions ?? true;
|
|
3509
|
+
return applyPermissionsPosture(service, {
|
|
3472
3510
|
skim: options.skim ?? service.defaults.updateByIdOptions?.skim ?? false,
|
|
3473
|
-
includePermissions
|
|
3511
|
+
includePermissions,
|
|
3512
|
+
includeFieldPermissions: options.includeFieldPermissions ?? service.defaults.updateByIdOptions?.includeFieldPermissions ?? includePermissions,
|
|
3474
3513
|
populateAccess: options.populateAccess ?? service.defaults.updateByIdOptions?.populateAccess ?? "read"
|
|
3475
|
-
};
|
|
3514
|
+
});
|
|
3476
3515
|
}
|
|
3477
3516
|
function resolveUpsertArgs(service, args = {}) {
|
|
3478
3517
|
return {
|
|
@@ -3481,11 +3520,13 @@ function resolveUpsertArgs(service, args = {}) {
|
|
|
3481
3520
|
};
|
|
3482
3521
|
}
|
|
3483
3522
|
function resolveUpsertOptions(service, options = {}) {
|
|
3484
|
-
|
|
3523
|
+
const includePermissions = options.includePermissions ?? service.defaults.upsertOptions?.includePermissions ?? true;
|
|
3524
|
+
return applyPermissionsPosture(service, {
|
|
3485
3525
|
skim: options.skim ?? service.defaults.upsertOptions?.skim ?? false,
|
|
3486
|
-
includePermissions
|
|
3526
|
+
includePermissions,
|
|
3527
|
+
includeFieldPermissions: options.includeFieldPermissions ?? service.defaults.upsertOptions?.includeFieldPermissions ?? includePermissions,
|
|
3487
3528
|
populateAccess: options.populateAccess ?? service.defaults.upsertOptions?.populateAccess ?? "read"
|
|
3488
|
-
};
|
|
3529
|
+
});
|
|
3489
3530
|
}
|
|
3490
3531
|
function resolveExistsOptions(service, options = {}) {
|
|
3491
3532
|
return {
|
|
@@ -3547,6 +3588,27 @@ var Service = class extends Base {
|
|
|
3547
3588
|
getModelRouterOptions(modelName) {
|
|
3548
3589
|
return getModelOptions(modelName);
|
|
3549
3590
|
}
|
|
3591
|
+
/**
|
|
3592
|
+
* Router-level permission output postures (see `ModelRouterOptions`).
|
|
3593
|
+
* Absolute: they win over client input and per-operation `defaults`.
|
|
3594
|
+
*/
|
|
3595
|
+
getPermissionsPosture() {
|
|
3596
|
+
return {
|
|
3597
|
+
stripPermissionsField: this.options.stripPermissionsField ?? false,
|
|
3598
|
+
disableFieldPermissions: this.options.disableFieldPermissions ?? false
|
|
3599
|
+
};
|
|
3600
|
+
}
|
|
3601
|
+
/**
|
|
3602
|
+
* Router posture `stripPermissionsField`: drop the whole document
|
|
3603
|
+
* permissions field (including the empty placeholder) from output instead
|
|
3604
|
+
* of emitting permission metadata. Returns true when applied.
|
|
3605
|
+
*/
|
|
3606
|
+
stripPermissionsOutput(doc) {
|
|
3607
|
+
if (!this.options.stripPermissionsField) return false;
|
|
3608
|
+
const field = this.options.documentPermissionField;
|
|
3609
|
+
if (field) unsetDocPath(doc, field);
|
|
3610
|
+
return true;
|
|
3611
|
+
}
|
|
3550
3612
|
asServiceHookContext(context) {
|
|
3551
3613
|
return context;
|
|
3552
3614
|
}
|
|
@@ -3554,6 +3616,14 @@ var Service = class extends Base {
|
|
|
3554
3616
|
const extra = this.options?.sortableFields ?? [];
|
|
3555
3617
|
return extra.length > 0 ? [...allowedSortFields, ...extra] : allowedSortFields;
|
|
3556
3618
|
}
|
|
3619
|
+
/**
|
|
3620
|
+
* With `requireExplicitSelect`, an omitted client select behaves as an
|
|
3621
|
+
* `_id`-only projection, yielding field-less rows. Explicit selects pass
|
|
3622
|
+
* through untouched.
|
|
3623
|
+
*/
|
|
3624
|
+
resolveEffectiveSelect(select) {
|
|
3625
|
+
return this.options?.requireExplicitSelect && select === void 0 ? ["_id"] : select;
|
|
3626
|
+
}
|
|
3557
3627
|
beginOp(op, filter2, extra) {
|
|
3558
3628
|
const startedAt = Date.now();
|
|
3559
3629
|
debug({
|
|
@@ -3578,8 +3648,9 @@ var Service = class extends Base {
|
|
|
3578
3648
|
async findOne(filter2, args, options) {
|
|
3579
3649
|
const filterErrors = this.validateClientFilter(filter2);
|
|
3580
3650
|
if (filterErrors.length > 0) return { success: false, kind: "error", code: "bad_request" /* BadRequest */, errors: filterErrors };
|
|
3581
|
-
const { select, sort, populate, include, overrides } = this.resolveFindOneArgs(args);
|
|
3582
|
-
const
|
|
3651
|
+
const { select: requestedSelect, sort, populate, include, overrides } = this.resolveFindOneArgs(args);
|
|
3652
|
+
const select = this.resolveEffectiveSelect(requestedSelect);
|
|
3653
|
+
const { skim, includePermissions, includeFieldPermissions, access, populateAccess, lean } = this.resolveFindOneOptions(options);
|
|
3583
3654
|
const { filter: overrideFilter, select: overrideSelect, populate: overridePopulate } = overrides ?? {};
|
|
3584
3655
|
let parsedFilter;
|
|
3585
3656
|
let processedInclude;
|
|
@@ -3660,11 +3731,11 @@ var Service = class extends Base {
|
|
|
3660
3731
|
throw error2;
|
|
3661
3732
|
}
|
|
3662
3733
|
let includeDocPermissions = includePermissions;
|
|
3663
|
-
if (!includeDocPermissions && !skim) {
|
|
3734
|
+
if (!includeDocPermissions && (!skim || includeFieldPermissions)) {
|
|
3664
3735
|
includeDocPermissions = this.checkIfModelPermissionExists([access, "read", "update"]);
|
|
3665
3736
|
}
|
|
3666
3737
|
if (includeDocPermissions) doc = await this.addDocPermissions(doc, access, context);
|
|
3667
|
-
if (
|
|
3738
|
+
if (includeFieldPermissions) doc = await this.addFieldPermissions(doc, access, context);
|
|
3668
3739
|
doc = await this.trimOutputFields(
|
|
3669
3740
|
doc,
|
|
3670
3741
|
access,
|
|
@@ -3682,13 +3753,16 @@ var Service = class extends Base {
|
|
|
3682
3753
|
if (!shouldKeepCorrelatedRef(ref, keep)) unsetDocPath(doc, ref);
|
|
3683
3754
|
}
|
|
3684
3755
|
}
|
|
3685
|
-
if (!
|
|
3756
|
+
if (!this.stripPermissionsOutput(doc)) {
|
|
3757
|
+
if (!includePermissions && !includeFieldPermissions) doc = this.addEmptyPermissions(doc);
|
|
3758
|
+
stripUnexposedDocPermissions(this.modelName, doc);
|
|
3759
|
+
}
|
|
3686
3760
|
this.completeOp("findOne", startedAt, "success" /* Success */, _filter);
|
|
3687
3761
|
return { success: true, kind: "single", code: "success" /* Success */, data: doc, query, context };
|
|
3688
3762
|
}
|
|
3689
3763
|
async findById(id, args, options) {
|
|
3690
3764
|
const { select, populate, include, overrides } = this.resolveFindByIdArgs(args);
|
|
3691
|
-
const { skim, includePermissions, access, populateAccess, lean } = this.resolveFindByIdOptions(options);
|
|
3765
|
+
const { skim, includePermissions, includeFieldPermissions, access, populateAccess, lean } = this.resolveFindByIdOptions(options);
|
|
3692
3766
|
const { select: overrideSelect, populate: overridePopulate, idFilter: overrideIdFilter } = overrides ?? {};
|
|
3693
3767
|
const filter2 = overrideIdFilter ?? await this.genIDFilter(id);
|
|
3694
3768
|
if (filter2 === false) return { success: false, kind: "error", code: "forbidden" /* Forbidden */, query: { filter: filter2 } };
|
|
@@ -3703,14 +3777,25 @@ var Service = class extends Base {
|
|
|
3703
3777
|
populate: overridePopulate
|
|
3704
3778
|
}
|
|
3705
3779
|
},
|
|
3706
|
-
{ skim, includePermissions, access, populateAccess, lean }
|
|
3780
|
+
{ skim, includePermissions, includeFieldPermissions, access, populateAccess, lean }
|
|
3707
3781
|
);
|
|
3708
3782
|
}
|
|
3709
3783
|
async find(filter2, args, options, decorate) {
|
|
3710
3784
|
const filterErrors = this.validateClientFilter(filter2);
|
|
3711
3785
|
if (filterErrors.length > 0) return { success: false, kind: "error", code: "bad_request" /* BadRequest */, errors: filterErrors };
|
|
3712
|
-
const {
|
|
3713
|
-
|
|
3786
|
+
const {
|
|
3787
|
+
select: requestedSelect,
|
|
3788
|
+
populate,
|
|
3789
|
+
include,
|
|
3790
|
+
sort,
|
|
3791
|
+
skip,
|
|
3792
|
+
limit,
|
|
3793
|
+
page,
|
|
3794
|
+
pageSize,
|
|
3795
|
+
overrides
|
|
3796
|
+
} = this.resolveFindArgs(args);
|
|
3797
|
+
const select = this.resolveEffectiveSelect(requestedSelect);
|
|
3798
|
+
const { skim, includePermissions, includeFieldPermissions, includeCount, populateAccess, lean } = this.resolveFindOptions(options);
|
|
3714
3799
|
const { filter: overrideFilter, select: overrideSelect, populate: overridePopulate } = overrides ?? {};
|
|
3715
3800
|
let parsedFilter;
|
|
3716
3801
|
let processedInclude;
|
|
@@ -3794,16 +3879,16 @@ var Service = class extends Base {
|
|
|
3794
3879
|
}
|
|
3795
3880
|
throw error2;
|
|
3796
3881
|
}
|
|
3797
|
-
const fieldPermissionAccess =
|
|
3882
|
+
const fieldPermissionAccess = includeFieldPermissions ? await this.getFieldPermissionAccess(docs.map((doc) => doc._id)) : void 0;
|
|
3798
3883
|
docs = await Promise.all(
|
|
3799
3884
|
docs.map(async (doc, i) => {
|
|
3800
3885
|
this.asServiceHookContext(contexts[i]).fieldPermissionAccess = fieldPermissionAccess;
|
|
3801
3886
|
let includeDocPermissions = includePermissions;
|
|
3802
|
-
if (!includeDocPermissions && !skim) {
|
|
3887
|
+
if (!includeDocPermissions && (!skim || includeFieldPermissions)) {
|
|
3803
3888
|
includeDocPermissions = this.checkIfModelPermissionExists(["list", "read", "update"]);
|
|
3804
3889
|
}
|
|
3805
3890
|
if (includeDocPermissions) doc = await this.addDocPermissions(doc, "list", contexts[i]);
|
|
3806
|
-
if (
|
|
3891
|
+
if (includeFieldPermissions) doc = await this.addFieldPermissions(doc, "list", contexts[i]);
|
|
3807
3892
|
doc = await this.trimOutputFields(
|
|
3808
3893
|
doc,
|
|
3809
3894
|
"list",
|
|
@@ -3822,7 +3907,10 @@ var Service = class extends Base {
|
|
|
3822
3907
|
}
|
|
3823
3908
|
}
|
|
3824
3909
|
doc = await _decorate(doc, contexts[i]);
|
|
3825
|
-
if (!
|
|
3910
|
+
if (!this.stripPermissionsOutput(doc)) {
|
|
3911
|
+
if (!includePermissions && !includeFieldPermissions) doc = this.addEmptyPermissions(doc);
|
|
3912
|
+
stripUnexposedDocPermissions(this.modelName, doc);
|
|
3913
|
+
}
|
|
3826
3914
|
return doc;
|
|
3827
3915
|
})
|
|
3828
3916
|
);
|
|
@@ -3840,7 +3928,7 @@ var Service = class extends Base {
|
|
|
3840
3928
|
}
|
|
3841
3929
|
async create(data, args, options, decorate) {
|
|
3842
3930
|
const { populate } = this.resolveCreateArgs(args);
|
|
3843
|
-
const { skim, includePermissions, populateAccess } = this.resolveCreateOptions(options);
|
|
3931
|
+
const { skim, includePermissions, includeFieldPermissions, populateAccess } = this.resolveCreateOptions(options);
|
|
3844
3932
|
const isArr = Array.isArray(data);
|
|
3845
3933
|
let dataArr = isArr ? data : [data];
|
|
3846
3934
|
const { maxBulkItems, maxBulkConcurrency } = this.getRequestComplexity();
|
|
@@ -3947,15 +4035,18 @@ var Service = class extends Base {
|
|
|
3947
4035
|
contexts[index].currentDocument = doc;
|
|
3948
4036
|
contexts[index].finalDocumentSnapshot = doc.toObject({ virtuals: false });
|
|
3949
4037
|
let includeDocPermissions = includePermissions;
|
|
3950
|
-
if (!includeDocPermissions && !skim) {
|
|
4038
|
+
if (!includeDocPermissions && (!skim || includeFieldPermissions)) {
|
|
3951
4039
|
includeDocPermissions = this.checkIfModelPermissionExists(["create", "read", "update"]);
|
|
3952
4040
|
}
|
|
3953
4041
|
if (includeDocPermissions) doc = await this.addDocPermissions(doc, "create", contexts[index]);
|
|
3954
|
-
if (
|
|
4042
|
+
if (includeFieldPermissions) doc = await this.addFieldPermissions(doc, "read", contexts[index]);
|
|
3955
4043
|
if (resolvedPopulate.length > 0) await this.persist(() => populateDoc(doc, resolvedPopulate));
|
|
3956
4044
|
doc = await this.trimOutputFields(doc, "read", this.baseFieldsExt);
|
|
3957
4045
|
let outputDoc = await _decorate(doc, contexts[index]);
|
|
3958
|
-
if (!
|
|
4046
|
+
if (!this.stripPermissionsOutput(outputDoc)) {
|
|
4047
|
+
if (!includePermissions && !includeFieldPermissions) outputDoc = this.addEmptyPermissions(outputDoc);
|
|
4048
|
+
stripUnexposedDocPermissions(this.modelName, outputDoc);
|
|
4049
|
+
}
|
|
3959
4050
|
return outputDoc;
|
|
3960
4051
|
});
|
|
3961
4052
|
return {
|
|
@@ -3991,7 +4082,8 @@ var Service = class extends Base {
|
|
|
3991
4082
|
return { ...typedIssue, detail, pointer: `#/${index}` };
|
|
3992
4083
|
}
|
|
3993
4084
|
async new(args, options) {
|
|
3994
|
-
const { skim, includePermissions } = options ?? {};
|
|
4085
|
+
const { skim, includePermissions: requestedPermissions } = options ?? {};
|
|
4086
|
+
const includePermissions = this.options.stripPermissionsField ? false : requestedPermissions;
|
|
3995
4087
|
const data = await this.model.new();
|
|
3996
4088
|
let doc = data;
|
|
3997
4089
|
doc = await this.trimOutputFields(doc, "create", this.baseFieldsExt);
|
|
@@ -4000,7 +4092,10 @@ var Service = class extends Base {
|
|
|
4000
4092
|
includeDocPermissions = this.checkIfModelPermissionExists(["create", "read", "update"]);
|
|
4001
4093
|
}
|
|
4002
4094
|
if (includeDocPermissions) doc = await this.addDocPermissions(doc, "create", {});
|
|
4003
|
-
if (!
|
|
4095
|
+
if (!this.stripPermissionsOutput(doc)) {
|
|
4096
|
+
if (!includePermissions) doc = this.addEmptyPermissions(doc);
|
|
4097
|
+
stripUnexposedDocPermissions(this.modelName, doc);
|
|
4098
|
+
}
|
|
4004
4099
|
return {
|
|
4005
4100
|
success: true,
|
|
4006
4101
|
kind: "single",
|
|
@@ -4019,7 +4114,7 @@ var Service = class extends Base {
|
|
|
4019
4114
|
const filterErrors = this.validateClientFilter(filter2);
|
|
4020
4115
|
if (filterErrors.length > 0) return { success: false, kind: "error", code: "bad_request" /* BadRequest */, errors: filterErrors };
|
|
4021
4116
|
const { populate, overrides } = this.resolveUpdateOneArgs(args);
|
|
4022
|
-
const { skim, includePermissions, populateAccess } = this.resolveUpdateOneOptions(options);
|
|
4117
|
+
const { skim, includePermissions, includeFieldPermissions, populateAccess } = this.resolveUpdateOneOptions(options);
|
|
4023
4118
|
const { filter: overrideFilter, populate: overridePopulate } = overrides ?? {};
|
|
4024
4119
|
const [_filter, _populate] = await Promise.all([
|
|
4025
4120
|
overrideFilter ?? this.genFilter("update", filter2),
|
|
@@ -4096,22 +4191,25 @@ var Service = class extends Base {
|
|
|
4096
4191
|
this.asServiceHookContext(context).diff(doc);
|
|
4097
4192
|
await this.changes(doc.toObject({ virtuals: false }), context);
|
|
4098
4193
|
let includeDocPermissions = includePermissions;
|
|
4099
|
-
if (!includeDocPermissions && !skim) {
|
|
4194
|
+
if (!includeDocPermissions && (!skim || includeFieldPermissions)) {
|
|
4100
4195
|
includeDocPermissions = this.checkIfModelPermissionExists(["read", "update"]);
|
|
4101
4196
|
}
|
|
4102
4197
|
if (includeDocPermissions) doc = await this.addDocPermissions(doc, "update", context);
|
|
4103
|
-
if (
|
|
4198
|
+
if (includeFieldPermissions) doc = await this.addFieldPermissions(doc, "update", context);
|
|
4104
4199
|
if (_populate) await this.persist(() => populateDoc(doc, _populate));
|
|
4105
4200
|
doc = await this.trimOutputFields(doc, "read", this.baseFieldsExt);
|
|
4106
4201
|
let outputDoc = doc;
|
|
4107
4202
|
if ((0, import_utils17.isFunction)(decorate)) outputDoc = await decorate(outputDoc, context);
|
|
4108
|
-
if (!
|
|
4203
|
+
if (!this.stripPermissionsOutput(outputDoc)) {
|
|
4204
|
+
if (!includePermissions && !includeFieldPermissions) outputDoc = this.addEmptyPermissions(outputDoc);
|
|
4205
|
+
stripUnexposedDocPermissions(this.modelName, outputDoc);
|
|
4206
|
+
}
|
|
4109
4207
|
this.completeOp("updateOne", startedAt, "success" /* Success */, _filter);
|
|
4110
4208
|
return { success: true, kind: "single", code: "success" /* Success */, data: outputDoc, input: prepared };
|
|
4111
4209
|
}
|
|
4112
4210
|
async updateById(id, data, args = {}, options = {}, decorate) {
|
|
4113
4211
|
const { populate, overrides } = this.resolveUpdateByIdArgs(args);
|
|
4114
|
-
const { skim, includePermissions, populateAccess } = this.resolveUpdateByIdOptions(options);
|
|
4212
|
+
const { skim, includePermissions, includeFieldPermissions, populateAccess } = this.resolveUpdateByIdOptions(options);
|
|
4115
4213
|
const { populate: overridePopulate, idFilter: overrideIdFilter } = overrides;
|
|
4116
4214
|
const filter2 = overrideIdFilter ?? await this.genIDFilter(id);
|
|
4117
4215
|
if (filter2 === false) return { success: false, kind: "error", code: "forbidden" /* Forbidden */, query: { filter: filter2 } };
|
|
@@ -4124,7 +4222,7 @@ var Service = class extends Base {
|
|
|
4124
4222
|
populate: overridePopulate
|
|
4125
4223
|
}
|
|
4126
4224
|
},
|
|
4127
|
-
{ skim, includePermissions, populateAccess },
|
|
4225
|
+
{ skim, includePermissions, includeFieldPermissions, populateAccess },
|
|
4128
4226
|
decorate
|
|
4129
4227
|
);
|
|
4130
4228
|
}
|
|
@@ -4132,7 +4230,7 @@ var Service = class extends Base {
|
|
|
4132
4230
|
const filterErrors = this.validateClientFilter(filter2);
|
|
4133
4231
|
if (filterErrors.length > 0) return { success: false, kind: "error", code: "bad_request" /* BadRequest */, errors: filterErrors };
|
|
4134
4232
|
const { populate, overrides } = this.resolveUpsertArgs(args);
|
|
4135
|
-
const { skim, includePermissions, populateAccess } = this.resolveUpsertOptions(options);
|
|
4233
|
+
const { skim, includePermissions, includeFieldPermissions, populateAccess } = this.resolveUpsertOptions(options);
|
|
4136
4234
|
const { filter: overrideFilter, populate: overridePopulate } = overrides ?? {};
|
|
4137
4235
|
const _filter = await (overrideFilter ?? this.genFilter("update", filter2));
|
|
4138
4236
|
const query = { filter: _filter };
|
|
@@ -4154,7 +4252,7 @@ var Service = class extends Base {
|
|
|
4154
4252
|
populate: overridePopulate
|
|
4155
4253
|
}
|
|
4156
4254
|
},
|
|
4157
|
-
{ skim, includePermissions, populateAccess },
|
|
4255
|
+
{ skim, includePermissions, includeFieldPermissions, populateAccess },
|
|
4158
4256
|
decorate
|
|
4159
4257
|
);
|
|
4160
4258
|
} else {
|
|
@@ -4164,6 +4262,7 @@ var Service = class extends Base {
|
|
|
4164
4262
|
{
|
|
4165
4263
|
skim,
|
|
4166
4264
|
includePermissions,
|
|
4265
|
+
includeFieldPermissions,
|
|
4167
4266
|
populateAccess
|
|
4168
4267
|
},
|
|
4169
4268
|
decorate
|
|
@@ -4488,11 +4587,11 @@ var import_utils18 = require("@web-ts-toolkit/utils");
|
|
|
4488
4587
|
var PublicService = class extends Service {
|
|
4489
4588
|
async _list(filter2, args, options) {
|
|
4490
4589
|
const { select, populate, include, sort, skip, limit, page, pageSize, tasks } = this.resolvePublicListArgs(args);
|
|
4491
|
-
const { skim, includePermissions, includeCount, populateAccess, lean } = this.resolvePublicListOptions(options);
|
|
4590
|
+
const { skim, includePermissions, includeFieldPermissions, includeCount, populateAccess, lean } = this.resolvePublicListOptions(options);
|
|
4492
4591
|
const result = await this.find(
|
|
4493
4592
|
filter2,
|
|
4494
4593
|
{ select, populate, include, sort, skip, limit, page, pageSize },
|
|
4495
|
-
{ skim, includePermissions, includeCount, populateAccess, lean },
|
|
4594
|
+
{ skim, includePermissions, includeFieldPermissions, includeCount, populateAccess, lean },
|
|
4496
4595
|
async (doc, context) => {
|
|
4497
4596
|
doc = toObject(doc);
|
|
4498
4597
|
return this.decorate(doc, "list", context);
|
|
@@ -4514,11 +4613,11 @@ var PublicService = class extends Service {
|
|
|
4514
4613
|
}
|
|
4515
4614
|
async _create(data, args, options) {
|
|
4516
4615
|
const { select, populate, tasks } = this.resolvePublicCreateArgs(args);
|
|
4517
|
-
const { skim, includePermissions, populateAccess } = this.resolvePublicCreateOptions(options);
|
|
4616
|
+
const { skim, includePermissions, includeFieldPermissions, populateAccess } = this.resolvePublicCreateOptions(options);
|
|
4518
4617
|
const result = await this.create(
|
|
4519
4618
|
data,
|
|
4520
4619
|
{ populate },
|
|
4521
|
-
{ skim, includePermissions, populateAccess },
|
|
4620
|
+
{ skim, includePermissions, includeFieldPermissions, populateAccess },
|
|
4522
4621
|
async (doc, context) => {
|
|
4523
4622
|
let d = toObject(doc);
|
|
4524
4623
|
d = await this.decorate(d, "create", context);
|
|
@@ -4537,7 +4636,7 @@ var PublicService = class extends Service {
|
|
|
4537
4636
|
}
|
|
4538
4637
|
async _read(id, args, options) {
|
|
4539
4638
|
const { select, populate, include, tasks } = this.resolvePublicReadArgs(args);
|
|
4540
|
-
const { skim, includePermissions, tryList, populateAccess, lean } = this.resolvePublicReadOptions(options);
|
|
4639
|
+
const { skim, includePermissions, includeFieldPermissions, tryList, populateAccess, lean } = this.resolvePublicReadOptions(options);
|
|
4541
4640
|
let access = "read";
|
|
4542
4641
|
const idFilter = await this.genIDFilter(id);
|
|
4543
4642
|
let result = await this.findById(
|
|
@@ -4548,7 +4647,7 @@ var PublicService = class extends Service {
|
|
|
4548
4647
|
include,
|
|
4549
4648
|
overrides: { idFilter }
|
|
4550
4649
|
},
|
|
4551
|
-
{ skim, includePermissions, access, populateAccess, lean }
|
|
4650
|
+
{ skim, includePermissions, includeFieldPermissions, access, populateAccess, lean }
|
|
4552
4651
|
);
|
|
4553
4652
|
if (!result.success && (result.code === "bad_request" /* BadRequest */ || result.code === "forbidden" /* Forbidden */)) return result;
|
|
4554
4653
|
if (tryList && (!result.success || !result.data)) {
|
|
@@ -4565,7 +4664,7 @@ var PublicService = class extends Service {
|
|
|
4565
4664
|
include,
|
|
4566
4665
|
overrides: { idFilter }
|
|
4567
4666
|
},
|
|
4568
|
-
{ skim, includePermissions, access, populateAccess, lean }
|
|
4667
|
+
{ skim, includePermissions, includeFieldPermissions, access, populateAccess, lean }
|
|
4569
4668
|
);
|
|
4570
4669
|
}
|
|
4571
4670
|
if (!result.success) {
|
|
@@ -4578,7 +4677,7 @@ var PublicService = class extends Service {
|
|
|
4578
4677
|
}
|
|
4579
4678
|
async _readFilter(filter2, args, options) {
|
|
4580
4679
|
const { select, sort, populate, include, tasks } = this.resolvePublicReadFilterArgs(args);
|
|
4581
|
-
const { skim, includePermissions, tryList, populateAccess, lean } = this.resolvePublicReadOptions(options);
|
|
4680
|
+
const { skim, includePermissions, includeFieldPermissions, tryList, populateAccess, lean } = this.resolvePublicReadOptions(options);
|
|
4582
4681
|
let access = "read";
|
|
4583
4682
|
let result = await this.findOne(
|
|
4584
4683
|
filter2,
|
|
@@ -4589,7 +4688,7 @@ var PublicService = class extends Service {
|
|
|
4589
4688
|
include,
|
|
4590
4689
|
overrides: {}
|
|
4591
4690
|
},
|
|
4592
|
-
{ skim, includePermissions, access, populateAccess, lean }
|
|
4691
|
+
{ skim, includePermissions, includeFieldPermissions, access, populateAccess, lean }
|
|
4593
4692
|
);
|
|
4594
4693
|
if (!result.success && (result.code === "bad_request" /* BadRequest */ || result.code === "forbidden" /* Forbidden */)) return result;
|
|
4595
4694
|
if (tryList && (!result.success || !result.data)) {
|
|
@@ -4607,7 +4706,7 @@ var PublicService = class extends Service {
|
|
|
4607
4706
|
include,
|
|
4608
4707
|
overrides: {}
|
|
4609
4708
|
},
|
|
4610
|
-
{ skim, includePermissions, access, populateAccess, lean }
|
|
4709
|
+
{ skim, includePermissions, includeFieldPermissions, access, populateAccess, lean }
|
|
4611
4710
|
);
|
|
4612
4711
|
}
|
|
4613
4712
|
if (!result.success) {
|
|
@@ -4619,13 +4718,14 @@ var PublicService = class extends Service {
|
|
|
4619
4718
|
return { ...result, data: doc };
|
|
4620
4719
|
}
|
|
4621
4720
|
async _update(id, data, args, options) {
|
|
4622
|
-
const { select, populate, tasks } = this.resolvePublicUpdateArgs(args);
|
|
4623
|
-
const
|
|
4721
|
+
const { select: requestedSelect, populate, tasks } = this.resolvePublicUpdateArgs(args);
|
|
4722
|
+
const select = this.resolveEffectiveSelect(requestedSelect);
|
|
4723
|
+
const { skim, returningAll, includePermissions, includeFieldPermissions, populateAccess } = this.resolvePublicUpdateOptions(options);
|
|
4624
4724
|
const result = await this.updateById(
|
|
4625
4725
|
id,
|
|
4626
4726
|
data,
|
|
4627
4727
|
{ populate },
|
|
4628
|
-
{ skim, includePermissions, populateAccess },
|
|
4728
|
+
{ skim, includePermissions, includeFieldPermissions, populateAccess },
|
|
4629
4729
|
async (doc, context) => {
|
|
4630
4730
|
let d = toObject(doc);
|
|
4631
4731
|
d = await this.decorate(d, "update", context);
|
|
@@ -4665,6 +4765,7 @@ var PublicService = class extends Service {
|
|
|
4665
4765
|
return this._create(otherData, args, {
|
|
4666
4766
|
skim: options?.skim,
|
|
4667
4767
|
includePermissions: options?.includePermissions,
|
|
4768
|
+
includeFieldPermissions: options?.includeFieldPermissions,
|
|
4668
4769
|
populateAccess: options?.populateAccess
|
|
4669
4770
|
});
|
|
4670
4771
|
}
|
|
@@ -4694,9 +4795,11 @@ var PublicService = class extends Service {
|
|
|
4694
4795
|
};
|
|
4695
4796
|
}
|
|
4696
4797
|
resolvePublicListOptions(options = {}) {
|
|
4798
|
+
const includePermissions = options.includePermissions ?? this.defaults.publicListOptions?.includePermissions ?? false;
|
|
4697
4799
|
return {
|
|
4698
4800
|
skim: options.skim ?? this.defaults.publicListOptions?.skim ?? true,
|
|
4699
|
-
includePermissions
|
|
4801
|
+
includePermissions,
|
|
4802
|
+
includeFieldPermissions: options.includeFieldPermissions ?? this.defaults.publicListOptions?.includeFieldPermissions ?? includePermissions,
|
|
4700
4803
|
includeCount: options.includeCount ?? this.defaults.publicListOptions?.includeCount ?? false,
|
|
4701
4804
|
populateAccess: options.populateAccess ?? this.defaults.publicListOptions?.populateAccess ?? "read",
|
|
4702
4805
|
lean: options.lean ?? this.defaults.publicListOptions?.lean ?? true
|
|
@@ -4710,9 +4813,11 @@ var PublicService = class extends Service {
|
|
|
4710
4813
|
};
|
|
4711
4814
|
}
|
|
4712
4815
|
resolvePublicCreateOptions(options = {}) {
|
|
4816
|
+
const includePermissions = options.includePermissions ?? this.defaults.publicCreateOptions?.includePermissions ?? true;
|
|
4713
4817
|
return {
|
|
4714
4818
|
skim: options.skim ?? this.defaults.publicCreateOptions?.skim ?? false,
|
|
4715
|
-
includePermissions
|
|
4819
|
+
includePermissions,
|
|
4820
|
+
includeFieldPermissions: options.includeFieldPermissions ?? this.defaults.publicCreateOptions?.includeFieldPermissions ?? includePermissions,
|
|
4716
4821
|
populateAccess: options.populateAccess ?? this.defaults.publicCreateOptions?.populateAccess ?? "read"
|
|
4717
4822
|
};
|
|
4718
4823
|
}
|
|
@@ -4732,9 +4837,11 @@ var PublicService = class extends Service {
|
|
|
4732
4837
|
};
|
|
4733
4838
|
}
|
|
4734
4839
|
resolvePublicReadOptions(options = {}) {
|
|
4840
|
+
const includePermissions = options.includePermissions ?? this.defaults.publicReadOptions?.includePermissions ?? true;
|
|
4735
4841
|
return {
|
|
4736
4842
|
skim: options.skim ?? this.defaults.publicReadOptions?.skim ?? false,
|
|
4737
|
-
includePermissions
|
|
4843
|
+
includePermissions,
|
|
4844
|
+
includeFieldPermissions: options.includeFieldPermissions ?? this.defaults.publicReadOptions?.includeFieldPermissions ?? includePermissions,
|
|
4738
4845
|
tryList: options.tryList ?? this.defaults.publicReadOptions?.tryList ?? true,
|
|
4739
4846
|
populateAccess: options.populateAccess ?? this.defaults.publicReadOptions?.populateAccess,
|
|
4740
4847
|
lean: options.lean ?? this.defaults.publicReadOptions?.lean ?? false
|
|
@@ -4748,10 +4855,12 @@ var PublicService = class extends Service {
|
|
|
4748
4855
|
};
|
|
4749
4856
|
}
|
|
4750
4857
|
resolvePublicUpdateOptions(options = {}) {
|
|
4858
|
+
const includePermissions = options.includePermissions ?? this.defaults.publicUpdateOptions?.includePermissions ?? true;
|
|
4751
4859
|
return {
|
|
4752
4860
|
skim: options.skim ?? this.defaults.publicUpdateOptions?.skim ?? false,
|
|
4753
4861
|
returningAll: options.returningAll ?? this.defaults.publicUpdateOptions?.returningAll ?? true,
|
|
4754
|
-
includePermissions
|
|
4862
|
+
includePermissions,
|
|
4863
|
+
includeFieldPermissions: options.includeFieldPermissions ?? this.defaults.publicUpdateOptions?.includeFieldPermissions ?? includePermissions,
|
|
4755
4864
|
populateAccess: options.populateAccess ?? this.defaults.publicUpdateOptions?.populateAccess ?? "read"
|
|
4756
4865
|
};
|
|
4757
4866
|
}
|
|
@@ -6815,23 +6924,32 @@ var listQuerySchema = import_zod3.z.object({
|
|
|
6815
6924
|
page_size: positiveIntegerString.optional(),
|
|
6816
6925
|
skim: queryBooleanString.optional(),
|
|
6817
6926
|
include_permissions: queryBooleanString.optional(),
|
|
6927
|
+
include_field_permissions: queryBooleanString.optional(),
|
|
6818
6928
|
include_count: queryBooleanString.optional(),
|
|
6819
|
-
include_extra_headers: queryBooleanString.optional()
|
|
6929
|
+
include_extra_headers: queryBooleanString.optional(),
|
|
6930
|
+
select: stringOrStringArray.optional(),
|
|
6931
|
+
sort: import_zod3.z.string().optional().describe("Space-separated sort fields; prefix a field with - for descending order.")
|
|
6820
6932
|
}).passthrough();
|
|
6821
6933
|
var createQuerySchema = import_zod3.z.object({
|
|
6822
|
-
include_permissions: queryBooleanString.optional()
|
|
6934
|
+
include_permissions: queryBooleanString.optional(),
|
|
6935
|
+
include_field_permissions: queryBooleanString.optional()
|
|
6823
6936
|
}).passthrough();
|
|
6824
6937
|
var readQuerySchema = import_zod3.z.object({
|
|
6825
6938
|
include_permissions: queryBooleanString.optional(),
|
|
6826
|
-
|
|
6939
|
+
include_field_permissions: queryBooleanString.optional(),
|
|
6940
|
+
try_list: queryBooleanString.optional(),
|
|
6941
|
+
select: stringOrStringArray.optional()
|
|
6827
6942
|
}).passthrough();
|
|
6828
6943
|
var updateQuerySchema = import_zod3.z.object({
|
|
6829
6944
|
returning_all: queryBooleanString.optional(),
|
|
6830
|
-
include_permissions: queryBooleanString.optional()
|
|
6945
|
+
include_permissions: queryBooleanString.optional(),
|
|
6946
|
+
include_field_permissions: queryBooleanString.optional(),
|
|
6947
|
+
select: stringOrStringArray.optional()
|
|
6831
6948
|
}).passthrough();
|
|
6832
6949
|
var upsertQuerySchema = import_zod3.z.object({
|
|
6833
6950
|
returning_all: queryBooleanString.optional(),
|
|
6834
|
-
include_permissions: queryBooleanString.optional()
|
|
6951
|
+
include_permissions: queryBooleanString.optional(),
|
|
6952
|
+
include_field_permissions: queryBooleanString.optional()
|
|
6835
6953
|
}).passthrough();
|
|
6836
6954
|
var listBodySchema = import_zod3.z.object({
|
|
6837
6955
|
filter: objectOrArraySchema.optional(),
|
|
@@ -6847,6 +6965,7 @@ var listBodySchema = import_zod3.z.object({
|
|
|
6847
6965
|
options: import_zod3.z.object({
|
|
6848
6966
|
skim: import_zod3.z.boolean().optional(),
|
|
6849
6967
|
includePermissions: import_zod3.z.boolean().optional(),
|
|
6968
|
+
includeFieldPermissions: import_zod3.z.boolean().optional(),
|
|
6850
6969
|
includeCount: import_zod3.z.boolean().optional(),
|
|
6851
6970
|
includeExtraHeaders: import_zod3.z.boolean().optional(),
|
|
6852
6971
|
populateAccess: import_zod3.z.unknown().optional()
|
|
@@ -6865,6 +6984,7 @@ var readFilterBodySchema = import_zod3.z.object({
|
|
|
6865
6984
|
options: import_zod3.z.object({
|
|
6866
6985
|
skim: import_zod3.z.boolean().optional(),
|
|
6867
6986
|
includePermissions: import_zod3.z.boolean().optional(),
|
|
6987
|
+
includeFieldPermissions: import_zod3.z.boolean().optional(),
|
|
6868
6988
|
tryList: import_zod3.z.boolean().optional(),
|
|
6869
6989
|
populateAccess: import_zod3.z.unknown().optional()
|
|
6870
6990
|
}).passthrough().optional()
|
|
@@ -6877,6 +6997,7 @@ var readByIdBodySchema = import_zod3.z.object({
|
|
|
6877
6997
|
options: import_zod3.z.object({
|
|
6878
6998
|
skim: import_zod3.z.boolean().optional(),
|
|
6879
6999
|
includePermissions: import_zod3.z.boolean().optional(),
|
|
7000
|
+
includeFieldPermissions: import_zod3.z.boolean().optional(),
|
|
6880
7001
|
tryList: import_zod3.z.boolean().optional(),
|
|
6881
7002
|
populateAccess: import_zod3.z.unknown().optional()
|
|
6882
7003
|
}).passthrough().optional()
|
|
@@ -6888,6 +7009,7 @@ var advancedCreateBodySchema = import_zod3.z.object({
|
|
|
6888
7009
|
tasks: tasksSchema.optional(),
|
|
6889
7010
|
options: import_zod3.z.object({
|
|
6890
7011
|
includePermissions: import_zod3.z.boolean().optional(),
|
|
7012
|
+
includeFieldPermissions: import_zod3.z.boolean().optional(),
|
|
6891
7013
|
populateAccess: import_zod3.z.unknown().optional()
|
|
6892
7014
|
}).passthrough().optional()
|
|
6893
7015
|
}).passthrough();
|
|
@@ -6904,6 +7026,7 @@ var advancedUpdateBodySchema = import_zod3.z.object({
|
|
|
6904
7026
|
options: import_zod3.z.object({
|
|
6905
7027
|
returningAll: import_zod3.z.boolean().optional(),
|
|
6906
7028
|
includePermissions: import_zod3.z.boolean().optional(),
|
|
7029
|
+
includeFieldPermissions: import_zod3.z.boolean().optional(),
|
|
6907
7030
|
populateAccess: import_zod3.z.unknown().optional()
|
|
6908
7031
|
}).passthrough().optional()
|
|
6909
7032
|
}).passthrough();
|
|
@@ -6916,6 +7039,7 @@ var advancedUpsertBodySchema = import_zod3.z.object({
|
|
|
6916
7039
|
options: import_zod3.z.object({
|
|
6917
7040
|
returningAll: import_zod3.z.boolean().optional(),
|
|
6918
7041
|
includePermissions: import_zod3.z.boolean().optional(),
|
|
7042
|
+
includeFieldPermissions: import_zod3.z.boolean().optional(),
|
|
6919
7043
|
populateAccess: import_zod3.z.unknown().optional()
|
|
6920
7044
|
}).passthrough().optional()
|
|
6921
7045
|
}).passthrough();
|
|
@@ -6986,6 +7110,7 @@ var rootModelListArgsSchema = import_zod5.z.object({
|
|
|
6986
7110
|
var rootModelListOptionsSchema = import_zod5.z.object({
|
|
6987
7111
|
skim: import_zod5.z.boolean().optional(),
|
|
6988
7112
|
includePermissions: import_zod5.z.boolean().optional(),
|
|
7113
|
+
includeFieldPermissions: import_zod5.z.boolean().optional(),
|
|
6989
7114
|
includeCount: import_zod5.z.boolean().optional(),
|
|
6990
7115
|
populateAccess: import_zod5.z.unknown().optional(),
|
|
6991
7116
|
lean: import_zod5.z.boolean().optional()
|
|
@@ -7002,6 +7127,7 @@ var rootModelReadFilterArgsSchema = rootModelReadArgsSchema.extend({
|
|
|
7002
7127
|
var rootModelReadOptionsSchema = import_zod5.z.object({
|
|
7003
7128
|
skim: import_zod5.z.boolean().optional(),
|
|
7004
7129
|
includePermissions: import_zod5.z.boolean().optional(),
|
|
7130
|
+
includeFieldPermissions: import_zod5.z.boolean().optional(),
|
|
7005
7131
|
tryList: import_zod5.z.boolean().optional(),
|
|
7006
7132
|
populateAccess: import_zod5.z.unknown().optional(),
|
|
7007
7133
|
lean: import_zod5.z.boolean().optional()
|
|
@@ -7014,6 +7140,7 @@ var rootModelCreateArgsSchema = import_zod5.z.object({
|
|
|
7014
7140
|
var rootModelCreateOptionsSchema = import_zod5.z.object({
|
|
7015
7141
|
skim: import_zod5.z.boolean().optional(),
|
|
7016
7142
|
includePermissions: import_zod5.z.boolean().optional(),
|
|
7143
|
+
includeFieldPermissions: import_zod5.z.boolean().optional(),
|
|
7017
7144
|
populateAccess: import_zod5.z.unknown().optional()
|
|
7018
7145
|
}).passthrough();
|
|
7019
7146
|
var rootModelUpdateArgsSchema = import_zod5.z.object({
|
|
@@ -7025,6 +7152,7 @@ var rootModelUpdateOptionsSchema = import_zod5.z.object({
|
|
|
7025
7152
|
skim: import_zod5.z.boolean().optional(),
|
|
7026
7153
|
returningAll: import_zod5.z.boolean().optional(),
|
|
7027
7154
|
includePermissions: import_zod5.z.boolean().optional(),
|
|
7155
|
+
includeFieldPermissions: import_zod5.z.boolean().optional(),
|
|
7028
7156
|
populateAccess: import_zod5.z.unknown().optional()
|
|
7029
7157
|
}).passthrough();
|
|
7030
7158
|
var rootModelUpsertArgsSchema = rootModelUpdateArgsSchema;
|
|
@@ -7056,7 +7184,8 @@ var rootModelNewArgsSchema = import_zod5.z.object({
|
|
|
7056
7184
|
}).passthrough();
|
|
7057
7185
|
var rootModelNewOptionsSchema = import_zod5.z.object({
|
|
7058
7186
|
skim: import_zod5.z.boolean().optional(),
|
|
7059
|
-
includePermissions: import_zod5.z.boolean().optional()
|
|
7187
|
+
includePermissions: import_zod5.z.boolean().optional(),
|
|
7188
|
+
includeFieldPermissions: import_zod5.z.boolean().optional()
|
|
7060
7189
|
}).passthrough();
|
|
7061
7190
|
var rootModelQueryEntrySchema = import_zod5.z.union([
|
|
7062
7191
|
import_zod5.z.object({
|
|
@@ -7225,16 +7354,29 @@ function setModelCollectionRoutes(context) {
|
|
|
7225
7354
|
};
|
|
7226
7355
|
router.get("", async (req) => {
|
|
7227
7356
|
await context.assertAllowed(req, "list");
|
|
7228
|
-
const {
|
|
7357
|
+
const {
|
|
7358
|
+
skip,
|
|
7359
|
+
limit,
|
|
7360
|
+
page,
|
|
7361
|
+
page_size,
|
|
7362
|
+
skim,
|
|
7363
|
+
include_permissions,
|
|
7364
|
+
include_field_permissions,
|
|
7365
|
+
include_count,
|
|
7366
|
+
include_extra_headers,
|
|
7367
|
+
select,
|
|
7368
|
+
sort
|
|
7369
|
+
} = parseQuery(requestSchemas.listQuery, req.query);
|
|
7229
7370
|
const svc = context.getPublicService(req);
|
|
7230
7371
|
const includeCount = (0, import_utils27.parseBooleanString)(include_count);
|
|
7231
7372
|
const includeExtraHeaders = (0, import_utils27.parseBooleanString)(include_extra_headers);
|
|
7232
7373
|
const result = await svc._list(
|
|
7233
7374
|
{},
|
|
7234
|
-
{ skip, limit, page, pageSize: page_size },
|
|
7375
|
+
{ select: parseSelectParam(select), sort, skip, limit, page, pageSize: page_size },
|
|
7235
7376
|
{
|
|
7236
7377
|
skim: (0, import_utils27.parseBooleanString)(skim),
|
|
7237
7378
|
includePermissions: (0, import_utils27.parseBooleanString)(include_permissions),
|
|
7379
|
+
includeFieldPermissions: (0, import_utils27.parseBooleanString)(include_field_permissions),
|
|
7238
7380
|
includeCount
|
|
7239
7381
|
}
|
|
7240
7382
|
);
|
|
@@ -7257,7 +7399,7 @@ function setModelCollectionRoutes(context) {
|
|
|
7257
7399
|
);
|
|
7258
7400
|
const { filter: filter2, select, sort, populate, include, tasks, skip, limit, page, pageSize } = body;
|
|
7259
7401
|
const advancedOptions = body.options ?? {};
|
|
7260
|
-
const { skim, includePermissions, includeCount, includeExtraHeaders, populateAccess } = advancedOptions;
|
|
7402
|
+
const { skim, includePermissions, includeFieldPermissions, includeCount, includeExtraHeaders, populateAccess } = advancedOptions;
|
|
7261
7403
|
const svc = context.getPublicService(req);
|
|
7262
7404
|
const listFilter = filter2 ?? {};
|
|
7263
7405
|
const result = await svc._list(
|
|
@@ -7266,6 +7408,7 @@ function setModelCollectionRoutes(context) {
|
|
|
7266
7408
|
{
|
|
7267
7409
|
skim,
|
|
7268
7410
|
includePermissions,
|
|
7411
|
+
includeFieldPermissions,
|
|
7269
7412
|
includeCount,
|
|
7270
7413
|
populateAccess
|
|
7271
7414
|
}
|
|
@@ -7282,14 +7425,21 @@ function setModelCollectionRoutes(context) {
|
|
|
7282
7425
|
});
|
|
7283
7426
|
router.post("", async (req) => {
|
|
7284
7427
|
await context.assertAllowed(req, "create");
|
|
7285
|
-
const { include_permissions } = parseQuery(requestSchemas.createQuery, req.query);
|
|
7428
|
+
const { include_permissions, include_field_permissions } = parseQuery(requestSchemas.createQuery, req.query);
|
|
7286
7429
|
const data = await parseBodyWithSchema(
|
|
7287
7430
|
createBodySchema,
|
|
7288
7431
|
req.body,
|
|
7289
7432
|
context.getRequestSchema("requestSchemas.create")
|
|
7290
7433
|
);
|
|
7291
7434
|
const svc = context.getPublicService(req);
|
|
7292
|
-
const result = await svc._create(
|
|
7435
|
+
const result = await svc._create(
|
|
7436
|
+
data,
|
|
7437
|
+
{},
|
|
7438
|
+
{
|
|
7439
|
+
includePermissions: (0, import_utils27.parseBooleanString)(include_permissions),
|
|
7440
|
+
includeFieldPermissions: (0, import_utils27.parseBooleanString)(include_field_permissions)
|
|
7441
|
+
}
|
|
7442
|
+
);
|
|
7293
7443
|
handleResultError(result);
|
|
7294
7444
|
return formatModelCreatedResponse(result);
|
|
7295
7445
|
});
|
|
@@ -7303,7 +7453,7 @@ function setModelCollectionRoutes(context) {
|
|
|
7303
7453
|
});
|
|
7304
7454
|
router.post(`/${options.mutationRouteSegment}`, async (req) => {
|
|
7305
7455
|
await context.assertAllowed(req, "create");
|
|
7306
|
-
const { include_permissions } = parseQuery(requestSchemas.createQuery, req.query);
|
|
7456
|
+
const { include_permissions, include_field_permissions } = parseQuery(requestSchemas.createQuery, req.query);
|
|
7307
7457
|
const intermediateBody = await parseNestedBodyWithSchema(
|
|
7308
7458
|
advancedCreateBodySchema,
|
|
7309
7459
|
req.body,
|
|
@@ -7319,13 +7469,14 @@ function setModelCollectionRoutes(context) {
|
|
|
7319
7469
|
);
|
|
7320
7470
|
const { data: finalData, select: finalSelect, populate: finalPopulate, tasks: finalTasks } = finalBody;
|
|
7321
7471
|
const finalOptions = finalBody.options ?? {};
|
|
7322
|
-
const { includePermissions, populateAccess } = finalOptions;
|
|
7472
|
+
const { includePermissions, includeFieldPermissions, populateAccess } = finalOptions;
|
|
7323
7473
|
const svc = context.getPublicService(req);
|
|
7324
7474
|
const result = await svc._create(
|
|
7325
7475
|
finalData,
|
|
7326
7476
|
{ select: finalSelect, populate: finalPopulate, tasks: finalTasks },
|
|
7327
7477
|
{
|
|
7328
7478
|
includePermissions: includePermissions ?? (0, import_utils27.parseBooleanString)(include_permissions),
|
|
7479
|
+
includeFieldPermissions: includeFieldPermissions ?? (0, import_utils27.parseBooleanString)(include_field_permissions),
|
|
7329
7480
|
populateAccess
|
|
7330
7481
|
}
|
|
7331
7482
|
);
|
|
@@ -7343,7 +7494,7 @@ function setModelCollectionRoutes(context) {
|
|
|
7343
7494
|
router.get("/new", async (req) => {
|
|
7344
7495
|
await context.assertAllowed(req, "new");
|
|
7345
7496
|
const svc = context.getPublicService(req);
|
|
7346
|
-
const result = await svc._new({}, { includePermissions: false });
|
|
7497
|
+
const result = await svc._new({}, { includePermissions: false, includeFieldPermissions: false });
|
|
7347
7498
|
handleResultError(result);
|
|
7348
7499
|
return unwrapServiceData(result);
|
|
7349
7500
|
});
|
|
@@ -7411,13 +7562,17 @@ function setModelDocumentRoutes(context) {
|
|
|
7411
7562
|
router.get(`/:${options.idParam}`, async (req) => {
|
|
7412
7563
|
await context.assertAllowed(req, "read");
|
|
7413
7564
|
const id = parsePathParam(req.params[options.idParam], options.idParam);
|
|
7414
|
-
const { include_permissions, try_list } = parseQuery(
|
|
7565
|
+
const { include_permissions, include_field_permissions, try_list, select } = parseQuery(
|
|
7566
|
+
requestSchemas.readQuery,
|
|
7567
|
+
req.query
|
|
7568
|
+
);
|
|
7415
7569
|
const svc = context.getPublicService(req);
|
|
7416
7570
|
const result = await svc._read(
|
|
7417
7571
|
id,
|
|
7418
|
-
{},
|
|
7572
|
+
{ select: parseSelectParam(select) },
|
|
7419
7573
|
{
|
|
7420
7574
|
includePermissions: (0, import_utils27.parseBooleanString)(include_permissions),
|
|
7575
|
+
includeFieldPermissions: (0, import_utils27.parseBooleanString)(include_field_permissions),
|
|
7421
7576
|
tryList: (0, import_utils27.parseBooleanString)(try_list)
|
|
7422
7577
|
}
|
|
7423
7578
|
);
|
|
@@ -7440,12 +7595,18 @@ function setModelDocumentRoutes(context) {
|
|
|
7440
7595
|
);
|
|
7441
7596
|
const { filter: filter2, select, sort, populate, include, tasks } = body;
|
|
7442
7597
|
const advancedOptions = body.options ?? {};
|
|
7443
|
-
const { skim, includePermissions, tryList, populateAccess } = advancedOptions;
|
|
7598
|
+
const { skim, includePermissions, includeFieldPermissions, tryList, populateAccess } = advancedOptions;
|
|
7444
7599
|
const svc = context.getPublicService(req);
|
|
7445
7600
|
const result = await svc._readFilter(
|
|
7446
7601
|
filter2 ?? {},
|
|
7447
7602
|
{ select, sort, populate, include, tasks },
|
|
7448
|
-
{
|
|
7603
|
+
{
|
|
7604
|
+
skim,
|
|
7605
|
+
includePermissions,
|
|
7606
|
+
includeFieldPermissions,
|
|
7607
|
+
tryList,
|
|
7608
|
+
populateAccess
|
|
7609
|
+
}
|
|
7449
7610
|
);
|
|
7450
7611
|
handleResultError(result);
|
|
7451
7612
|
return unwrapServiceData(result);
|
|
@@ -7469,12 +7630,18 @@ function setModelDocumentRoutes(context) {
|
|
|
7469
7630
|
);
|
|
7470
7631
|
const { select, populate, include, tasks } = body;
|
|
7471
7632
|
const advancedOptions = body.options ?? {};
|
|
7472
|
-
const { skim, includePermissions, tryList, populateAccess } = advancedOptions;
|
|
7633
|
+
const { skim, includePermissions, includeFieldPermissions, tryList, populateAccess } = advancedOptions;
|
|
7473
7634
|
const svc = context.getPublicService(req);
|
|
7474
7635
|
const result = await svc._read(
|
|
7475
7636
|
id,
|
|
7476
7637
|
{ select, populate, include, tasks },
|
|
7477
|
-
{
|
|
7638
|
+
{
|
|
7639
|
+
skim,
|
|
7640
|
+
includePermissions,
|
|
7641
|
+
includeFieldPermissions,
|
|
7642
|
+
tryList,
|
|
7643
|
+
populateAccess
|
|
7644
|
+
}
|
|
7478
7645
|
);
|
|
7479
7646
|
handleResultError(result);
|
|
7480
7647
|
return unwrapServiceData(result);
|
|
@@ -7491,7 +7658,10 @@ function setModelDocumentRoutes(context) {
|
|
|
7491
7658
|
router.patch(`/:${options.idParam}`, async (req) => {
|
|
7492
7659
|
await context.assertAllowed(req, "update");
|
|
7493
7660
|
const id = parsePathParam(req.params[options.idParam], options.idParam);
|
|
7494
|
-
const { returning_all, include_permissions } = parseQuery(
|
|
7661
|
+
const { returning_all, include_permissions, include_field_permissions, select } = parseQuery(
|
|
7662
|
+
requestSchemas.updateQuery,
|
|
7663
|
+
req.query
|
|
7664
|
+
);
|
|
7495
7665
|
const data = await parseBodyWithSchema(
|
|
7496
7666
|
updateBodySchema,
|
|
7497
7667
|
req.body,
|
|
@@ -7501,10 +7671,11 @@ function setModelDocumentRoutes(context) {
|
|
|
7501
7671
|
const result = await svc._update(
|
|
7502
7672
|
id,
|
|
7503
7673
|
data,
|
|
7504
|
-
{},
|
|
7674
|
+
{ select: parseSelectParam(select) },
|
|
7505
7675
|
{
|
|
7506
7676
|
returningAll: (0, import_utils27.parseBooleanString)(returning_all),
|
|
7507
|
-
includePermissions: (0, import_utils27.parseBooleanString)(include_permissions)
|
|
7677
|
+
includePermissions: (0, import_utils27.parseBooleanString)(include_permissions),
|
|
7678
|
+
includeFieldPermissions: (0, import_utils27.parseBooleanString)(include_field_permissions)
|
|
7508
7679
|
}
|
|
7509
7680
|
);
|
|
7510
7681
|
handleResultError(result);
|
|
@@ -7521,7 +7692,10 @@ function setModelDocumentRoutes(context) {
|
|
|
7521
7692
|
router.patch(`/${options.mutationRouteSegment}/:${options.idParam}`, async (req) => {
|
|
7522
7693
|
await context.assertAllowed(req, "update");
|
|
7523
7694
|
const id = parsePathParam(req.params[options.idParam], options.idParam);
|
|
7524
|
-
const { returning_all, include_permissions } = parseQuery(
|
|
7695
|
+
const { returning_all, include_permissions, include_field_permissions } = parseQuery(
|
|
7696
|
+
requestSchemas.updateQuery,
|
|
7697
|
+
req.query
|
|
7698
|
+
);
|
|
7525
7699
|
const intermediateBody = await parseNestedBodyWithSchema(
|
|
7526
7700
|
advancedUpdateBodySchema,
|
|
7527
7701
|
req.body,
|
|
@@ -7543,7 +7717,7 @@ function setModelDocumentRoutes(context) {
|
|
|
7543
7717
|
);
|
|
7544
7718
|
const { data: finalData, select: finalSelect, populate: finalPopulate, tasks: finalTasks } = finalBody;
|
|
7545
7719
|
const finalOptions = finalBody.options ?? {};
|
|
7546
|
-
const { returningAll, includePermissions, populateAccess } = finalOptions;
|
|
7720
|
+
const { returningAll, includePermissions, includeFieldPermissions, populateAccess } = finalOptions;
|
|
7547
7721
|
const svc = context.getPublicService(req);
|
|
7548
7722
|
const result = await svc._update(
|
|
7549
7723
|
id,
|
|
@@ -7552,6 +7726,7 @@ function setModelDocumentRoutes(context) {
|
|
|
7552
7726
|
{
|
|
7553
7727
|
returningAll: returningAll ?? (0, import_utils27.parseBooleanString)(returning_all),
|
|
7554
7728
|
includePermissions: includePermissions ?? (0, import_utils27.parseBooleanString)(include_permissions),
|
|
7729
|
+
includeFieldPermissions: includeFieldPermissions ?? (0, import_utils27.parseBooleanString)(include_field_permissions),
|
|
7555
7730
|
populateAccess
|
|
7556
7731
|
}
|
|
7557
7732
|
);
|
|
@@ -7569,7 +7744,10 @@ function setModelDocumentRoutes(context) {
|
|
|
7569
7744
|
router.put(`/`, async (req) => {
|
|
7570
7745
|
await context.assertAllowed(req, "upsert");
|
|
7571
7746
|
const svc = context.getPublicService(req);
|
|
7572
|
-
const { returning_all, include_permissions } = parseQuery(
|
|
7747
|
+
const { returning_all, include_permissions, include_field_permissions } = parseQuery(
|
|
7748
|
+
requestSchemas.upsertQuery,
|
|
7749
|
+
req.query
|
|
7750
|
+
);
|
|
7573
7751
|
const body = await parseBodyWithSchema(
|
|
7574
7752
|
upsertBodySchema,
|
|
7575
7753
|
req.body,
|
|
@@ -7580,7 +7758,8 @@ function setModelDocumentRoutes(context) {
|
|
|
7580
7758
|
{},
|
|
7581
7759
|
{
|
|
7582
7760
|
returningAll: (0, import_utils27.parseBooleanString)(returning_all),
|
|
7583
|
-
includePermissions: (0, import_utils27.parseBooleanString)(include_permissions)
|
|
7761
|
+
includePermissions: (0, import_utils27.parseBooleanString)(include_permissions),
|
|
7762
|
+
includeFieldPermissions: (0, import_utils27.parseBooleanString)(include_field_permissions)
|
|
7584
7763
|
}
|
|
7585
7764
|
);
|
|
7586
7765
|
handleResultError(result);
|
|
@@ -7597,7 +7776,10 @@ function setModelDocumentRoutes(context) {
|
|
|
7597
7776
|
router.put(`/${options.mutationRouteSegment}`, async (req) => {
|
|
7598
7777
|
await context.assertAllowed(req, "upsert");
|
|
7599
7778
|
const svc = context.getPublicService(req);
|
|
7600
|
-
const { returning_all, include_permissions } = parseQuery(
|
|
7779
|
+
const { returning_all, include_permissions, include_field_permissions } = parseQuery(
|
|
7780
|
+
requestSchemas.upsertQuery,
|
|
7781
|
+
req.query
|
|
7782
|
+
);
|
|
7601
7783
|
const intermediateBody = await parseNestedBodyWithSchema(
|
|
7602
7784
|
advancedUpsertBodySchema,
|
|
7603
7785
|
req.body,
|
|
@@ -7619,13 +7801,14 @@ function setModelDocumentRoutes(context) {
|
|
|
7619
7801
|
);
|
|
7620
7802
|
const { data: finalData, select: finalSelect, populate: finalPopulate, tasks: finalTasks } = finalBody;
|
|
7621
7803
|
const finalOptions = finalBody.options ?? {};
|
|
7622
|
-
const { returningAll, includePermissions, populateAccess } = finalOptions;
|
|
7804
|
+
const { returningAll, includePermissions, includeFieldPermissions, populateAccess } = finalOptions;
|
|
7623
7805
|
const result = await svc._upsert(
|
|
7624
7806
|
finalData,
|
|
7625
7807
|
{ select: finalSelect, populate: finalPopulate, tasks: finalTasks },
|
|
7626
7808
|
{
|
|
7627
7809
|
returningAll: returningAll ?? (0, import_utils27.parseBooleanString)(returning_all),
|
|
7628
7810
|
includePermissions: includePermissions ?? (0, import_utils27.parseBooleanString)(include_permissions),
|
|
7811
|
+
includeFieldPermissions: includeFieldPermissions ?? (0, import_utils27.parseBooleanString)(include_field_permissions),
|
|
7629
7812
|
populateAccess
|
|
7630
7813
|
}
|
|
7631
7814
|
);
|