@rhino-dev/rhino-nestjs 4.8.0 → 4.9.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/dist/constants/defaults.d.ts +12 -0
- package/dist/constants/defaults.js +16 -0
- package/dist/constants/defaults.js.map +1 -0
- package/dist/controllers/global.controller.d.ts +32 -6
- package/dist/controllers/global.controller.js +97 -38
- package/dist/controllers/global.controller.js.map +1 -1
- package/dist/exporters/postman-exporter.js +41 -11
- package/dist/exporters/postman-exporter.js.map +1 -1
- package/dist/interfaces/rhino-config.interface.d.ts +95 -4
- package/dist/rhino.config.d.ts +6 -0
- package/dist/rhino.config.js +12 -0
- package/dist/rhino.config.js.map +1 -1
- package/dist/services/query-builder.service.d.ts +9 -2
- package/dist/services/query-builder.service.js +19 -61
- package/dist/services/query-builder.service.js.map +1 -1
- package/dist/services/resource.service.d.ts +1 -1
- package/dist/services/resource.service.js +10 -2
- package/dist/services/resource.service.js.map +1 -1
- package/dist/services/serializer.service.d.ts +11 -0
- package/dist/services/serializer.service.js +22 -9
- package/dist/services/serializer.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/argument-binder.d.ts +45 -0
- package/dist/utils/argument-binder.js +83 -0
- package/dist/utils/argument-binder.js.map +1 -0
- package/dist/utils/computed-attribute-spec.d.ts +36 -0
- package/dist/utils/computed-attribute-spec.js +50 -0
- package/dist/utils/computed-attribute-spec.js.map +1 -0
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.SerializerService = exports.BASE_HIDDEN_COLUMNS = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const rhino_config_1 = require("../rhino.config");
|
|
18
|
+
const computed_attribute_spec_1 = require("../utils/computed-attribute-spec");
|
|
18
19
|
exports.BASE_HIDDEN_COLUMNS = [
|
|
19
20
|
'password',
|
|
20
21
|
'rememberToken',
|
|
@@ -63,7 +64,7 @@ let SerializerService = class SerializerService {
|
|
|
63
64
|
serializeOne(record, reg, ctx) {
|
|
64
65
|
if (!record)
|
|
65
66
|
return record;
|
|
66
|
-
const { user, organization, computedAttributes } = this.normalizeCtx(ctx);
|
|
67
|
+
const { user, organization, computedAttributes, computedAttributeArgs } = this.normalizeCtx(ctx);
|
|
67
68
|
let result = { ...record };
|
|
68
69
|
if (reg.computedAttributes) {
|
|
69
70
|
Object.assign(result, reg.computedAttributes(record, user));
|
|
@@ -71,7 +72,7 @@ let SerializerService = class SerializerService {
|
|
|
71
72
|
// Merge the OPT-IN record-level computed attributes the client selected.
|
|
72
73
|
// Nothing is evaluated unless it was asked for by name. Merged BEFORE
|
|
73
74
|
// policy filtering, so the blacklist/whitelist below still govern them.
|
|
74
|
-
Object.assign(result, this.resolveRecordComputed(record, reg, computedAttributes, user));
|
|
75
|
+
Object.assign(result, this.resolveRecordComputed(record, reg, computedAttributes, user, computedAttributeArgs));
|
|
75
76
|
for (const col of exports.BASE_HIDDEN_COLUMNS) {
|
|
76
77
|
delete result[col];
|
|
77
78
|
}
|
|
@@ -106,8 +107,12 @@ let SerializerService = class SerializerService {
|
|
|
106
107
|
* Names that are not declared are silently skipped — the controller has
|
|
107
108
|
* already rejected unknown/forbidden names with a 403, and a direct
|
|
108
109
|
* serializer caller must not be able to force an arbitrary call.
|
|
110
|
+
*
|
|
111
|
+
* An attribute that declares a required parameter is likewise skipped when
|
|
112
|
+
* `args` carries no entry for it, so an existing caller that passes only
|
|
113
|
+
* names gets a missing key rather than a callable invoked with nothing.
|
|
109
114
|
*/
|
|
110
|
-
resolveRecordComputed(record, reg, names, user) {
|
|
115
|
+
resolveRecordComputed(record, reg, names, user, args) {
|
|
111
116
|
if (!names || names.length === 0)
|
|
112
117
|
return {};
|
|
113
118
|
const declared = reg.recordComputedAttributes;
|
|
@@ -115,24 +120,32 @@ let SerializerService = class SerializerService {
|
|
|
115
120
|
return {};
|
|
116
121
|
const out = {};
|
|
117
122
|
for (const name of names) {
|
|
118
|
-
|
|
123
|
+
// Own-key lookup so a prototype key can never resolve to a member.
|
|
124
|
+
const spec = (0, computed_attribute_spec_1.lookupComputedAttribute)(declared, name);
|
|
125
|
+
if (!spec)
|
|
119
126
|
continue;
|
|
120
|
-
|
|
127
|
+
const hasArgs = !!args && Object.prototype.hasOwnProperty.call(args, name);
|
|
128
|
+
if (!hasArgs && (0, computed_attribute_spec_1.computedAttributeRequiresArguments)(spec))
|
|
121
129
|
continue;
|
|
122
|
-
const entry =
|
|
123
|
-
out[name] =
|
|
130
|
+
const entry = spec.using;
|
|
131
|
+
out[name] =
|
|
132
|
+
typeof entry === 'function' ? entry(record, user, hasArgs ? args[name] : {}) : entry;
|
|
124
133
|
}
|
|
125
134
|
return out;
|
|
126
135
|
}
|
|
127
136
|
normalizeCtx(ctx) {
|
|
128
|
-
// New call shape: { user, organization, computedAttributes }
|
|
137
|
+
// New call shape: { user, organization, computedAttributes, computedAttributeArgs }
|
|
129
138
|
if (ctx &&
|
|
130
139
|
typeof ctx === 'object' &&
|
|
131
|
-
('user' in ctx ||
|
|
140
|
+
('user' in ctx ||
|
|
141
|
+
'organization' in ctx ||
|
|
142
|
+
'computedAttributes' in ctx ||
|
|
143
|
+
'computedAttributeArgs' in ctx)) {
|
|
132
144
|
return {
|
|
133
145
|
user: ctx.user,
|
|
134
146
|
organization: ctx.organization,
|
|
135
147
|
computedAttributes: ctx.computedAttributes,
|
|
148
|
+
computedAttributeArgs: ctx.computedAttributeArgs,
|
|
136
149
|
};
|
|
137
150
|
}
|
|
138
151
|
// Legacy call shape: a bare user (or null/undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.service.js","sourceRoot":"","sources":["../../src/services/serializer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsD;AAEtD,kDAAqD;
|
|
1
|
+
{"version":3,"file":"serializer.service.js","sourceRoot":"","sources":["../../src/services/serializer.service.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