@spinajs/rbac-http-user 2.0.470 → 2.0.471
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/lib/cjs/controllers/LoginController.d.ts +35 -3
- package/lib/cjs/controllers/LoginController.d.ts.map +1 -1
- package/lib/cjs/controllers/LoginController.js +37 -10
- package/lib/cjs/controllers/LoginController.js.map +1 -1
- package/lib/cjs/controllers/TwoFactorAuthController.d.ts +39 -3
- package/lib/cjs/controllers/TwoFactorAuthController.d.ts.map +1 -1
- package/lib/cjs/controllers/TwoFactorAuthController.js +35 -0
- package/lib/cjs/controllers/TwoFactorAuthController.js.map +1 -1
- package/lib/cjs/controllers/UserController.d.ts +37 -3
- package/lib/cjs/controllers/UserController.d.ts.map +1 -1
- package/lib/cjs/controllers/UserController.js +33 -0
- package/lib/cjs/controllers/UserController.js.map +1 -1
- package/lib/cjs/controllers/UserMetadataController.d.ts +134 -11
- package/lib/cjs/controllers/UserMetadataController.d.ts.map +1 -1
- package/lib/cjs/controllers/UserMetadataController.js +130 -8
- package/lib/cjs/controllers/UserMetadataController.js.map +1 -1
- package/lib/cjs/dto/metadata-dto.d.ts +3 -0
- package/lib/cjs/dto/metadata-dto.d.ts.map +1 -1
- package/lib/cjs/dto/metadata-dto.js +3 -3
- package/lib/cjs/dto/metadata-dto.js.map +1 -1
- package/lib/cjs/dto/password-dto.d.ts +3 -0
- package/lib/cjs/dto/password-dto.d.ts.map +1 -1
- package/lib/cjs/dto/password-dto.js +3 -3
- package/lib/cjs/dto/password-dto.js.map +1 -1
- package/lib/cjs/dto/token-dto.d.ts +2 -0
- package/lib/cjs/dto/token-dto.d.ts.map +1 -1
- package/lib/cjs/dto/token-dto.js +2 -1
- package/lib/cjs/dto/token-dto.js.map +1 -1
- package/lib/cjs/dto/userLogin-dto.d.ts +3 -1
- package/lib/cjs/dto/userLogin-dto.d.ts.map +1 -1
- package/lib/cjs/dto/userLogin-dto.js +2 -2
- package/lib/cjs/dto/userLogin-dto.js.map +1 -1
- package/lib/mjs/controllers/LoginController.d.ts +35 -3
- package/lib/mjs/controllers/LoginController.d.ts.map +1 -1
- package/lib/mjs/controllers/LoginController.js +37 -10
- package/lib/mjs/controllers/LoginController.js.map +1 -1
- package/lib/mjs/controllers/TwoFactorAuthController.d.ts +39 -3
- package/lib/mjs/controllers/TwoFactorAuthController.d.ts.map +1 -1
- package/lib/mjs/controllers/TwoFactorAuthController.js +36 -1
- package/lib/mjs/controllers/TwoFactorAuthController.js.map +1 -1
- package/lib/mjs/controllers/UserController.d.ts +37 -3
- package/lib/mjs/controllers/UserController.d.ts.map +1 -1
- package/lib/mjs/controllers/UserController.js +33 -0
- package/lib/mjs/controllers/UserController.js.map +1 -1
- package/lib/mjs/controllers/UserMetadataController.d.ts +134 -11
- package/lib/mjs/controllers/UserMetadataController.d.ts.map +1 -1
- package/lib/mjs/controllers/UserMetadataController.js +130 -8
- package/lib/mjs/controllers/UserMetadataController.js.map +1 -1
- package/lib/mjs/dto/metadata-dto.d.ts +3 -0
- package/lib/mjs/dto/metadata-dto.d.ts.map +1 -1
- package/lib/mjs/dto/metadata-dto.js +3 -3
- package/lib/mjs/dto/metadata-dto.js.map +1 -1
- package/lib/mjs/dto/password-dto.d.ts +3 -0
- package/lib/mjs/dto/password-dto.d.ts.map +1 -1
- package/lib/mjs/dto/password-dto.js +3 -3
- package/lib/mjs/dto/password-dto.js.map +1 -1
- package/lib/mjs/dto/token-dto.d.ts +2 -0
- package/lib/mjs/dto/token-dto.d.ts.map +1 -1
- package/lib/mjs/dto/token-dto.js +2 -1
- package/lib/mjs/dto/token-dto.js.map +1 -1
- package/lib/mjs/dto/userLogin-dto.d.ts +3 -1
- package/lib/mjs/dto/userLogin-dto.d.ts.map +1 -1
- package/lib/mjs/dto/userLogin-dto.js +2 -2
- package/lib/mjs/dto/userLogin-dto.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +11 -11
|
@@ -19,11 +19,28 @@ import { TwoFacRouteEnabled } from '../policies/2FaPolicy.js';
|
|
|
19
19
|
import { AutoinjectService } from '@spinajs/configuration';
|
|
20
20
|
import { Autoinject } from '@spinajs/di';
|
|
21
21
|
import { QueueService } from '@spinajs/queue';
|
|
22
|
-
import { User, NotAuthorizedPolicy
|
|
22
|
+
import { User, NotAuthorizedPolicy } from "@spinajs/rbac-http";
|
|
23
23
|
import { auth2Fa, disableUser2Fa } from "./../actions/2fa.js";
|
|
24
24
|
import { enableUser2Fa } from "../actions/2fa.js";
|
|
25
25
|
import { InvalidOperation } from '@spinajs/exceptions';
|
|
26
|
+
/**
|
|
27
|
+
* Two-factor authentication (TOTP) management.
|
|
28
|
+
* Enables, disables, and verifies TOTP-based two-factor authentication for users.
|
|
29
|
+
* All routes are only available when 2FA is enabled in the system configuration.
|
|
30
|
+
* The caller must be logged in but does NOT need to be fully authorized (2FA verified),
|
|
31
|
+
* allowing these routes to be used during the 2FA verification step itself.
|
|
32
|
+
* @tags Two-Factor Authentication
|
|
33
|
+
*/
|
|
26
34
|
let TwoFactorAuthController = class TwoFactorAuthController extends BaseController {
|
|
35
|
+
/**
|
|
36
|
+
* Enable two-factor authentication
|
|
37
|
+
* Generates a TOTP secret for the authenticated user and returns the OTP provisioning URI
|
|
38
|
+
* to be scanned by an authenticator app. Throws if 2FA is already enabled for the user.
|
|
39
|
+
* @security cookieAuth
|
|
40
|
+
* @returns {IEnable2faResponse} OTP provisioning URI to scan with an authenticator app
|
|
41
|
+
* @response 400 Two-factor authentication is already enabled for this user
|
|
42
|
+
* @response 401 Unauthorized — valid session required
|
|
43
|
+
*/
|
|
27
44
|
async enable2fa(user) {
|
|
28
45
|
if (user.Metadata['2fa:enabled']) {
|
|
29
46
|
throw new InvalidOperation(`User ${user.Uuid} already has 2fa enabled`);
|
|
@@ -33,6 +50,15 @@ let TwoFactorAuthController = class TwoFactorAuthController extends BaseControll
|
|
|
33
50
|
otp: result
|
|
34
51
|
});
|
|
35
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Disable two-factor authentication
|
|
55
|
+
* Removes the TOTP secret and disables 2FA for the authenticated user.
|
|
56
|
+
* Throws if 2FA is not currently enabled for the user.
|
|
57
|
+
* @security cookieAuth
|
|
58
|
+
* @response 200 Two-factor authentication disabled successfully
|
|
59
|
+
* @response 400 Two-factor authentication is not enabled for this user
|
|
60
|
+
* @response 401 Unauthorized — valid session required
|
|
61
|
+
*/
|
|
36
62
|
async disable2Fa(user) {
|
|
37
63
|
if (!user.Metadata['2fa:enabled']) {
|
|
38
64
|
throw new InvalidOperation(`User ${user.Uuid} already has 2fa disabled`);
|
|
@@ -40,6 +66,15 @@ let TwoFactorAuthController = class TwoFactorAuthController extends BaseControll
|
|
|
40
66
|
await disableUser2Fa(user);
|
|
41
67
|
return new Ok();
|
|
42
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Verify TOTP token
|
|
71
|
+
* Validates the provided TOTP token against the user's 2FA secret. On success, marks the session
|
|
72
|
+
* as fully authorized and returns the user profile with RBAC grants — identical to a full login response.
|
|
73
|
+
* @security cookieAuth
|
|
74
|
+
* @returns {IUserWithGrants} User profile merged with RBAC grants on successful 2FA verification
|
|
75
|
+
* @response 403 Invalid or expired TOTP token
|
|
76
|
+
* @response 401 Unauthorized — valid session required
|
|
77
|
+
*/
|
|
43
78
|
async verifyToken(logged, token, session) {
|
|
44
79
|
try {
|
|
45
80
|
await auth2Fa(logged, token.Token);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TwoFactorAuthController.js","sourceRoot":"","sources":["../../../src/controllers/TwoFactorAuthController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC3F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DAAC;AAYf;IADZ,GAAG,CAAC,YAAY,CAAC;IACM,WAAA,IAAI,EAAE,CAAA;;qCAAO,SAAS;;wDAU7C;AAYY;IADZ,GAAG,CAAC,aAAa,CAAC;IACM,WAAA,IAAI,EAAE,CAAA;;qCAAO,SAAS;;yDAO9C;AAYY;IADZ,IAAI,CAAC,YAAY,CAAC;IACO,WAAA,IAAI,EAAE,CAAA;IAAqB,WAAA,IAAI,EAAE,CAAA;IAAmB,WAAA,OAAO,EAAE,CAAA;;qCAA9C,SAAS,EAAiB,QAAQ;;0DA2C1E;AAxGQ,uBAAuB;IAHnC,QAAQ,CAAC,MAAM,CAAC;IAChB,MAAM,CAAC,kBAAkB,CAAC;IAC1B,MAAM,CAAC,mBAAmB,CAAC;GACf,uBAAuB,CAyGnC"}
|
|
@@ -1,13 +1,47 @@
|
|
|
1
1
|
import { PasswordDto } from '../dto/password-dto.js';
|
|
2
2
|
import { User as UserModel, PasswordProvider, SessionProvider, AccessControl } from '@spinajs/rbac';
|
|
3
3
|
import { BaseController, Ok } from '@spinajs/http';
|
|
4
|
+
import { IGrantsMap } from '@spinajs/rbac-http';
|
|
5
|
+
/**
|
|
6
|
+
* Current user profile management.
|
|
7
|
+
* Allows an authenticated user to read and modify their own account — refresh profile data,
|
|
8
|
+
* view their RBAC grants, and change their password.
|
|
9
|
+
* @tags User
|
|
10
|
+
*/
|
|
4
11
|
export declare class UserController extends BaseController {
|
|
5
12
|
protected PasswordProvider: PasswordProvider;
|
|
6
13
|
protected CoockieSecret: string;
|
|
7
14
|
protected SessionProvider: SessionProvider;
|
|
8
15
|
protected AC: AccessControl;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Refresh current user profile
|
|
18
|
+
* Reloads the authenticated user's record from the database (including metadata) and
|
|
19
|
+
* updates the session with the latest data. Returns the refreshed user data.
|
|
20
|
+
* @security cookieAuth
|
|
21
|
+
* @returns {IUserProfile} Refreshed user profile data
|
|
22
|
+
* @response 401 Unauthorized — valid session required
|
|
23
|
+
* @response 403 Forbidden — insufficient permissions
|
|
24
|
+
*/
|
|
25
|
+
refresh(user: UserModel, ssid: string): Promise<Ok<import("@spinajs/orm").ModelData<UserModel>>>;
|
|
26
|
+
/**
|
|
27
|
+
* Get current user grants
|
|
28
|
+
* Returns the flattened RBAC grants for the authenticated user, combining all roles
|
|
29
|
+
* the user is assigned to into a single permission map keyed by resource.
|
|
30
|
+
* @security cookieAuth
|
|
31
|
+
* @returns {IGrantsMap} Combined RBAC grants map: resource → action → permission descriptor
|
|
32
|
+
* @response 401 Unauthorized — valid session required
|
|
33
|
+
* @response 403 Forbidden — insufficient permissions
|
|
34
|
+
*/
|
|
35
|
+
getGrants(user: UserModel): Promise<Ok<IGrantsMap>>;
|
|
36
|
+
/**
|
|
37
|
+
* Change own password
|
|
38
|
+
* Changes the authenticated user's password. Requires the current (old) password for verification.
|
|
39
|
+
* The new password and its confirmation must match.
|
|
40
|
+
* @security cookieAuth
|
|
41
|
+
* @response 400 Old password is incorrect, or new passwords do not match
|
|
42
|
+
* @response 401 Unauthorized — valid session required
|
|
43
|
+
* @response 403 Forbidden — insufficient permissions
|
|
44
|
+
*/
|
|
45
|
+
newPassword(user: UserModel, pwd: PasswordDto): Promise<Ok<unknown>>;
|
|
12
46
|
}
|
|
13
47
|
//# sourceMappingURL=UserController.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserController.d.ts","sourceRoot":"","sources":["../../../src/controllers/UserController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAgD,aAAa,EAAE,MAAM,eAAe,CAAC;AAClJ,OAAO,EAAE,cAAc,EAAiB,EAAE,EAA+B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"UserController.d.ts","sourceRoot":"","sources":["../../../src/controllers/UserController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAgD,aAAa,EAAE,MAAM,eAAe,CAAC;AAClJ,OAAO,EAAE,cAAc,EAAiB,EAAE,EAA+B,MAAM,eAAe,CAAC;AAM/F,OAAO,EAAgD,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAK9F;;;;;GAKG;AACH,qBAGa,cAAe,SAAQ,cAAc;IAEhD,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAG7C,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC;IAGhC,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC;IAG3C,SAAS,CAAC,EAAE,EAAE,aAAa,CAAC;IAE5B;;;;;;;;OAQG;IAGU,OAAO,CAAS,IAAI,EAAE,SAAS,EAAY,IAAI,EAAE,MAAM;IAiBpE;;;;;;;;OAQG;IAGU,SAAS,CAAS,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;IAUxE;;;;;;;;OAQG;IAGU,WAAW,CAAS,IAAI,EAAE,SAAS,EAAU,GAAG,EAAE,WAAW;CAkB3E"}
|
|
@@ -19,7 +19,22 @@ import { Config } from '@spinajs/configuration';
|
|
|
19
19
|
import * as cs from 'cookie-signature';
|
|
20
20
|
import { AuthorizedPolicy, Permission, Resource, User } from '@spinajs/rbac-http';
|
|
21
21
|
import { _chain, _either } from '@spinajs/util';
|
|
22
|
+
/**
|
|
23
|
+
* Current user profile management.
|
|
24
|
+
* Allows an authenticated user to read and modify their own account — refresh profile data,
|
|
25
|
+
* view their RBAC grants, and change their password.
|
|
26
|
+
* @tags User
|
|
27
|
+
*/
|
|
22
28
|
let UserController = class UserController extends BaseController {
|
|
29
|
+
/**
|
|
30
|
+
* Refresh current user profile
|
|
31
|
+
* Reloads the authenticated user's record from the database (including metadata) and
|
|
32
|
+
* updates the session with the latest data. Returns the refreshed user data.
|
|
33
|
+
* @security cookieAuth
|
|
34
|
+
* @returns {IUserProfile} Refreshed user profile data
|
|
35
|
+
* @response 401 Unauthorized — valid session required
|
|
36
|
+
* @response 403 Forbidden — insufficient permissions
|
|
37
|
+
*/
|
|
23
38
|
async refresh(user, ssid) {
|
|
24
39
|
// get user data from db
|
|
25
40
|
await user.refresh();
|
|
@@ -34,12 +49,30 @@ let UserController = class UserController extends BaseController {
|
|
|
34
49
|
}
|
|
35
50
|
return new Ok(user.dehydrate());
|
|
36
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Get current user grants
|
|
54
|
+
* Returns the flattened RBAC grants for the authenticated user, combining all roles
|
|
55
|
+
* the user is assigned to into a single permission map keyed by resource.
|
|
56
|
+
* @security cookieAuth
|
|
57
|
+
* @returns {IGrantsMap} Combined RBAC grants map: resource → action → permission descriptor
|
|
58
|
+
* @response 401 Unauthorized — valid session required
|
|
59
|
+
* @response 403 Forbidden — insufficient permissions
|
|
60
|
+
*/
|
|
37
61
|
async getGrants(user) {
|
|
38
62
|
const grants = this.AC.getGrants();
|
|
39
63
|
const userGrants = user.Role.map(r => _unwindGrants(r, grants));
|
|
40
64
|
const combinedGrants = Object.assign({}, ...userGrants);
|
|
41
65
|
return new Ok(combinedGrants);
|
|
42
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Change own password
|
|
69
|
+
* Changes the authenticated user's password. Requires the current (old) password for verification.
|
|
70
|
+
* The new password and its confirmation must match.
|
|
71
|
+
* @security cookieAuth
|
|
72
|
+
* @response 400 Old password is incorrect, or new passwords do not match
|
|
73
|
+
* @response 401 Unauthorized — valid session required
|
|
74
|
+
* @response 403 Forbidden — insufficient permissions
|
|
75
|
+
*/
|
|
43
76
|
async newPassword(user, pwd) {
|
|
44
77
|
if (pwd.Password !== pwd.ConfirmPassword) {
|
|
45
78
|
throw new InvalidArgument('password does not match');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserController.js","sourceRoot":"","sources":["../../../src/controllers/UserController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAClJ,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"UserController.js","sourceRoot":"","sources":["../../../src/controllers/UserController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAClJ,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;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AM,CAAC;IAChB,QAAQ,CAAC,MAAM,CAAC;IAChB,MAAM,CAAC,gBAAgB,CAAC;GACZ,cAAc,CA2F1B"}
|
|
@@ -2,22 +2,145 @@ import { Ok, BaseController } from '@spinajs/http';
|
|
|
2
2
|
import { User as UserModel, UserMetadata } from '@spinajs/rbac';
|
|
3
3
|
import { PaginationDTO, OrderDTO, IFilterRequest } from '@spinajs/orm-http';
|
|
4
4
|
import { UserMetadataDto } from '../dto/metadata-dto.js';
|
|
5
|
+
import { FilterableUserMetadata } from '../models/FilterableUserMetadata.js';
|
|
6
|
+
/**
|
|
7
|
+
* User metadata management.
|
|
8
|
+
* Provides CRUD operations for key-value metadata entries attached to user accounts.
|
|
9
|
+
* Admin routes operate on any user (identified by UUID), while own routes operate on the
|
|
10
|
+
* currently authenticated user's metadata.
|
|
11
|
+
* @tags User Metadata
|
|
12
|
+
*/
|
|
5
13
|
export declare class UserMetadataController extends BaseController {
|
|
6
14
|
/**
|
|
7
|
-
*
|
|
15
|
+
* List metadata for a specific user (admin)
|
|
16
|
+
* Returns a paginated, filtered, and ordered list of metadata entries for the given user.
|
|
17
|
+
* @security cookieAuth
|
|
18
|
+
* @param user User UUID path parameter
|
|
19
|
+
* @param pagination.page Page number (zero-based)
|
|
20
|
+
* @param pagination.limit Number of entries per page
|
|
21
|
+
* @param order.column Column to sort by (default: Id)
|
|
22
|
+
* @param order.order Sort direction: ASC or DESC (default: DESC)
|
|
23
|
+
* @returns {IUserMetadataEntry[]} Paginated list of metadata entries for the user
|
|
24
|
+
* @response 401 Unauthorized — valid session required
|
|
25
|
+
* @response 403 Forbidden — readAny permission required
|
|
26
|
+
* @response 404 User not found
|
|
8
27
|
*/
|
|
9
|
-
readUserMeta(user: UserModel, pagination?: PaginationDTO, order?: OrderDTO, filter?: IFilterRequest): Promise<Ok
|
|
10
|
-
getUserMeta(user: UserModel, key: string): Promise<Ok>;
|
|
11
|
-
addUserMetadata(user: UserModel, metadata: UserMetadata): Promise<Ok>;
|
|
12
|
-
updateUserMetadata(meta: UserMetadata, _user: UserModel, data: UserMetadataDto): Promise<Ok>;
|
|
13
|
-
deleteUserMetadata(user: UserModel, meta: number): Promise<Ok>;
|
|
28
|
+
readUserMeta(user: UserModel, pagination?: PaginationDTO, order?: OrderDTO, filter?: IFilterRequest): Promise<Ok<import("@spinajs/orm").ISelectQueryBuilder<FilterableUserMetadata[]> & import("@spinajs/orm").QueryScope>>;
|
|
14
29
|
/**
|
|
15
|
-
*
|
|
30
|
+
* Get a single metadata entry for a specific user (admin)
|
|
31
|
+
* Retrieves one metadata entry by key for the given user.
|
|
32
|
+
* @security cookieAuth
|
|
33
|
+
* @param user User UUID path parameter
|
|
34
|
+
* @param key Metadata key to retrieve
|
|
35
|
+
* @returns {IUserMetadataEntry} Single metadata entry for the user
|
|
36
|
+
* @response 401 Unauthorized — valid session required
|
|
37
|
+
* @response 403 Forbidden — readAny permission required
|
|
38
|
+
* @response 404 User or metadata key not found
|
|
39
|
+
*/
|
|
40
|
+
getUserMeta(user: UserModel, key: string): Promise<Ok<UserMetadata>>;
|
|
41
|
+
/**
|
|
42
|
+
* Add or update metadata for a specific user (admin)
|
|
43
|
+
* Inserts a new metadata entry for the given user, or updates it if the key already exists.
|
|
44
|
+
* @security cookieAuth
|
|
45
|
+
* @param user User UUID path parameter
|
|
46
|
+
* @response 200 Metadata created or updated successfully
|
|
47
|
+
* @response 401 Unauthorized — valid session required
|
|
48
|
+
* @response 403 Forbidden — updateAny permission required
|
|
49
|
+
* @response 404 User not found
|
|
50
|
+
*/
|
|
51
|
+
addUserMetadata(user: UserModel, metadata: UserMetadata): Promise<Ok<any>>;
|
|
52
|
+
/**
|
|
53
|
+
* Update a metadata entry for a specific user (admin)
|
|
54
|
+
* Updates Key, Value, and Type of an existing metadata entry identified by Id or Key.
|
|
55
|
+
* @security cookieAuth
|
|
56
|
+
* @param _user User UUID path parameter (used for authorization scope)
|
|
57
|
+
* @param meta Metadata Id or Key to update
|
|
58
|
+
|
|
59
|
+
* @response 200 Metadata updated successfully
|
|
60
|
+
* @response 401 Unauthorized — valid session required
|
|
61
|
+
* @response 403 Forbidden — updateAny permission required
|
|
62
|
+
* @response 404 User or metadata entry not found
|
|
63
|
+
*/
|
|
64
|
+
updateUserMetadata(meta: UserMetadata, _user: UserModel, data: UserMetadataDto): Promise<Ok<any>>;
|
|
65
|
+
/**
|
|
66
|
+
* Delete a metadata entry for a specific user (admin)
|
|
67
|
+
* Permanently removes a metadata entry by Id from the given user's metadata.
|
|
68
|
+
* @security cookieAuth
|
|
69
|
+
* @param user User UUID path parameter
|
|
70
|
+
* @param meta Metadata Id to delete
|
|
71
|
+
* @response 200 Metadata deleted successfully
|
|
72
|
+
* @response 401 Unauthorized — valid session required
|
|
73
|
+
* @response 403 Forbidden — deleteAny permission required
|
|
74
|
+
* @response 404 User or metadata entry not found
|
|
75
|
+
*/
|
|
76
|
+
deleteUserMetadata(user: UserModel, meta: number): Promise<Ok<any>>;
|
|
77
|
+
/**
|
|
78
|
+
* List own metadata
|
|
79
|
+
* Returns a paginated, filtered, and ordered list of metadata entries for the authenticated user.
|
|
80
|
+
* @security cookieAuth
|
|
81
|
+
* @param pagination.page Page number (zero-based)
|
|
82
|
+
* @param pagination.limit Number of entries per page
|
|
83
|
+
* @param order.column Column to sort by (default: Id)
|
|
84
|
+
* @param order.order Sort direction: ASC or DESC (default: DESC)
|
|
85
|
+
* @returns {IUserMetadataEntry[]} Paginated list of own metadata entries
|
|
86
|
+
* @response 401 Unauthorized — valid session required
|
|
87
|
+
* @response 403 Forbidden — readOwn permission required
|
|
88
|
+
*/
|
|
89
|
+
/**
|
|
90
|
+
* List own metadata
|
|
91
|
+
* Returns a paginated, filtered, and ordered list of metadata entries for the authenticated user.
|
|
92
|
+
* @security cookieAuth
|
|
93
|
+
* @param pagination.page Page number (zero-based)
|
|
94
|
+
* @param pagination.limit Number of entries per page
|
|
95
|
+
* @param order.column Column to sort by (default: Id)
|
|
96
|
+
* @param order.order Sort direction: ASC or DESC (default: DESC)
|
|
97
|
+
* @returns {IUserMetadataEntry[]} Paginated list of own metadata entries
|
|
98
|
+
* @response 401 Unauthorized — valid session required
|
|
99
|
+
* @response 403 Forbidden — readOwn permission required
|
|
100
|
+
*/
|
|
101
|
+
readMeta(pagination?: PaginationDTO, order?: OrderDTO, filter?: IFilterRequest): Promise<Ok<import("@spinajs/orm").ISelectQueryBuilder<FilterableUserMetadata[]> & import("@spinajs/orm").QueryScope>>;
|
|
102
|
+
/**
|
|
103
|
+
* Get own metadata entry by key
|
|
104
|
+
* Retrieves a single metadata entry by key for the authenticated user.
|
|
105
|
+
* @security cookieAuth
|
|
106
|
+
* @param key Metadata key to retrieve
|
|
107
|
+
* @returns {IUserMetadataEntry} Single own metadata entry by key
|
|
108
|
+
* @response 401 Unauthorized — valid session required
|
|
109
|
+
* @response 403 Forbidden — readOwn permission required
|
|
110
|
+
* @response 404 Metadata key not found
|
|
111
|
+
*/
|
|
112
|
+
getMeta(key: string): Promise<Ok<UserMetadata>>;
|
|
113
|
+
/**
|
|
114
|
+
* Add or update own metadata
|
|
115
|
+
* Inserts a new metadata entry for the authenticated user, or updates it if the key already exists.
|
|
116
|
+
* @security cookieAuth
|
|
117
|
+
* @response 200 Metadata created or updated successfully
|
|
118
|
+
* @response 401 Unauthorized — valid session required
|
|
119
|
+
* @response 403 Forbidden — updateOwn permission required
|
|
16
120
|
*/
|
|
17
|
-
readMeta(pagination?: PaginationDTO, order?: OrderDTO, filter?: IFilterRequest): Promise<Ok>;
|
|
18
|
-
getMeta(key: string): Promise<Ok>;
|
|
19
121
|
addMetadata(metadata: UserMetadata): Promise<void>;
|
|
20
|
-
|
|
21
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Update own metadata entry
|
|
124
|
+
* Updates Key, Value, and Type of an existing metadata entry identified by Id or Key.
|
|
125
|
+
* @security cookieAuth
|
|
126
|
+
* @param meta Metadata Id or Key to update
|
|
127
|
+
|
|
128
|
+
* @response 200 Metadata updated successfully
|
|
129
|
+
* @response 401 Unauthorized — valid session required
|
|
130
|
+
* @response 403 Forbidden — updateOwn permission required
|
|
131
|
+
* @response 404 Metadata entry not found
|
|
132
|
+
*/
|
|
133
|
+
updateMetadata(meta: string, data: UserMetadataDto): Promise<Ok<any>>;
|
|
134
|
+
/**
|
|
135
|
+
* Delete own metadata entry
|
|
136
|
+
* Permanently removes a metadata entry by Id from the authenticated user's metadata.
|
|
137
|
+
* @security cookieAuth
|
|
138
|
+
* @param meta Metadata Id to delete
|
|
139
|
+
* @response 200 Metadata deleted successfully
|
|
140
|
+
* @response 401 Unauthorized — valid session required
|
|
141
|
+
* @response 403 Forbidden — deleteOwn permission required
|
|
142
|
+
* @response 404 Metadata entry not found
|
|
143
|
+
*/
|
|
144
|
+
deleteMetadata(meta: number): Promise<Ok<any>>;
|
|
22
145
|
}
|
|
23
146
|
//# sourceMappingURL=UserMetadataController.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMetadataController.d.ts","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,EAAE,EAAwC,cAAc,EAAS,MAAM,eAAe,CAAC;AAChH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAW,aAAa,EAAE,QAAQ,EAAU,cAAc,EAAa,MAAM,mBAAmB,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"UserMetadataController.d.ts","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,EAAE,EAAwC,cAAc,EAAS,MAAM,eAAe,CAAC;AAChH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAW,aAAa,EAAE,QAAQ,EAAU,cAAc,EAAa,MAAM,mBA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
|
18
18
|
import { InsertBehaviour, SortOrder } from '@spinajs/orm';
|
|
19
19
|
import { FilterableUserMetadata } from '../models/FilterableUserMetadata.js';
|
|
20
|
+
/**
|
|
21
|
+
* User metadata management.
|
|
22
|
+
* Provides CRUD operations for key-value metadata entries attached to user accounts.
|
|
23
|
+
* Admin routes operate on any user (identified by UUID), while own routes operate on the
|
|
24
|
+
* currently authenticated user's metadata.
|
|
25
|
+
* @tags User Metadata
|
|
26
|
+
*/
|
|
20
27
|
let UserMetadataController = class UserMetadataController extends BaseController {
|
|
21
28
|
/**
|
|
22
|
-
*
|
|
29
|
+
* List metadata for a specific user (admin)
|
|
30
|
+
* Returns a paginated, filtered, and ordered list of metadata entries for the given user.
|
|
31
|
+
* @security cookieAuth
|
|
32
|
+
* @param user User UUID path parameter
|
|
33
|
+
* @param pagination.page Page number (zero-based)
|
|
34
|
+
* @param pagination.limit Number of entries per page
|
|
35
|
+
* @param order.column Column to sort by (default: Id)
|
|
36
|
+
* @param order.order Sort direction: ASC or DESC (default: DESC)
|
|
37
|
+
* @returns {IUserMetadataEntry[]} Paginated list of metadata entries for the user
|
|
38
|
+
* @response 401 Unauthorized — valid session required
|
|
39
|
+
* @response 403 Forbidden — readAny permission required
|
|
40
|
+
* @response 404 User not found
|
|
23
41
|
*/
|
|
24
42
|
async readUserMeta(user, pagination, order, filter) {
|
|
25
43
|
return new Ok(FilterableUserMetadata.select().where({
|
|
26
44
|
user_id: user.Id
|
|
27
|
-
}).filter(filter?.filters, filter?.op)
|
|
28
|
-
.take(pagination?.limit ??
|
|
29
|
-
.skip(pagination?.limit * pagination?.page
|
|
45
|
+
}).filter(filter?.filters ?? [], filter?.op)
|
|
46
|
+
.take(pagination?.limit ?? 0)
|
|
47
|
+
.skip((pagination?.limit ?? 0) * (pagination?.page ?? 0))
|
|
30
48
|
.order(order?.column ?? 'Id', order?.order ?? SortOrder.DESC));
|
|
31
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Get a single metadata entry for a specific user (admin)
|
|
52
|
+
* Retrieves one metadata entry by key for the given user.
|
|
53
|
+
* @security cookieAuth
|
|
54
|
+
* @param user User UUID path parameter
|
|
55
|
+
* @param key Metadata key to retrieve
|
|
56
|
+
* @returns {IUserMetadataEntry} Single metadata entry for the user
|
|
57
|
+
* @response 401 Unauthorized — valid session required
|
|
58
|
+
* @response 403 Forbidden — readAny permission required
|
|
59
|
+
* @response 404 User or metadata key not found
|
|
60
|
+
*/
|
|
32
61
|
async getUserMeta(user, key) {
|
|
33
62
|
return new Ok(UserMetadata.where({
|
|
34
63
|
Key: key,
|
|
35
64
|
user_id: user.Id
|
|
36
65
|
}).firstOrFail());
|
|
37
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Add or update metadata for a specific user (admin)
|
|
69
|
+
* Inserts a new metadata entry for the given user, or updates it if the key already exists.
|
|
70
|
+
* @security cookieAuth
|
|
71
|
+
* @param user User UUID path parameter
|
|
72
|
+
* @response 200 Metadata created or updated successfully
|
|
73
|
+
* @response 401 Unauthorized — valid session required
|
|
74
|
+
* @response 403 Forbidden — updateAny permission required
|
|
75
|
+
* @response 404 User not found
|
|
76
|
+
*/
|
|
38
77
|
async addUserMetadata(user, metadata) {
|
|
39
78
|
metadata.User.attach(user);
|
|
40
79
|
await metadata.insert(InsertBehaviour.InsertOrUpdate);
|
|
41
80
|
return new Ok();
|
|
42
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Update a metadata entry for a specific user (admin)
|
|
84
|
+
* Updates Key, Value, and Type of an existing metadata entry identified by Id or Key.
|
|
85
|
+
* @security cookieAuth
|
|
86
|
+
* @param _user User UUID path parameter (used for authorization scope)
|
|
87
|
+
* @param meta Metadata Id or Key to update
|
|
88
|
+
|
|
89
|
+
* @response 200 Metadata updated successfully
|
|
90
|
+
* @response 401 Unauthorized — valid session required
|
|
91
|
+
* @response 403 Forbidden — updateAny permission required
|
|
92
|
+
* @response 404 User or metadata entry not found
|
|
93
|
+
*/
|
|
43
94
|
async updateUserMetadata(meta, _user, data) {
|
|
44
95
|
await meta.update({
|
|
45
96
|
Key: data.Key,
|
|
@@ -48,6 +99,17 @@ let UserMetadataController = class UserMetadataController extends BaseController
|
|
|
48
99
|
});
|
|
49
100
|
return new Ok();
|
|
50
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Delete a metadata entry for a specific user (admin)
|
|
104
|
+
* Permanently removes a metadata entry by Id from the given user's metadata.
|
|
105
|
+
* @security cookieAuth
|
|
106
|
+
* @param user User UUID path parameter
|
|
107
|
+
* @param meta Metadata Id to delete
|
|
108
|
+
* @response 200 Metadata deleted successfully
|
|
109
|
+
* @response 401 Unauthorized — valid session required
|
|
110
|
+
* @response 403 Forbidden — deleteAny permission required
|
|
111
|
+
* @response 404 User or metadata entry not found
|
|
112
|
+
*/
|
|
51
113
|
async deleteUserMetadata(user, meta) {
|
|
52
114
|
await UserMetadata.destroy().where({
|
|
53
115
|
Id: meta,
|
|
@@ -56,22 +118,72 @@ let UserMetadataController = class UserMetadataController extends BaseController
|
|
|
56
118
|
return new Ok();
|
|
57
119
|
}
|
|
58
120
|
/**
|
|
59
|
-
*
|
|
121
|
+
* List own metadata
|
|
122
|
+
* Returns a paginated, filtered, and ordered list of metadata entries for the authenticated user.
|
|
123
|
+
* @security cookieAuth
|
|
124
|
+
* @param pagination.page Page number (zero-based)
|
|
125
|
+
* @param pagination.limit Number of entries per page
|
|
126
|
+
* @param order.column Column to sort by (default: Id)
|
|
127
|
+
* @param order.order Sort direction: ASC or DESC (default: DESC)
|
|
128
|
+
* @returns {IUserMetadataEntry[]} Paginated list of own metadata entries
|
|
129
|
+
* @response 401 Unauthorized — valid session required
|
|
130
|
+
* @response 403 Forbidden — readOwn permission required
|
|
131
|
+
*/
|
|
132
|
+
/**
|
|
133
|
+
* List own metadata
|
|
134
|
+
* Returns a paginated, filtered, and ordered list of metadata entries for the authenticated user.
|
|
135
|
+
* @security cookieAuth
|
|
136
|
+
* @param pagination.page Page number (zero-based)
|
|
137
|
+
* @param pagination.limit Number of entries per page
|
|
138
|
+
* @param order.column Column to sort by (default: Id)
|
|
139
|
+
* @param order.order Sort direction: ASC or DESC (default: DESC)
|
|
140
|
+
* @returns {IUserMetadataEntry[]} Paginated list of own metadata entries
|
|
141
|
+
* @response 401 Unauthorized — valid session required
|
|
142
|
+
* @response 403 Forbidden — readOwn permission required
|
|
60
143
|
*/
|
|
61
144
|
async readMeta(pagination, order, filter) {
|
|
62
|
-
return new Ok(FilterableUserMetadata.select().filter(filter?.filters, filter?.op)
|
|
63
|
-
.take(pagination?.limit ??
|
|
64
|
-
.skip(pagination?.limit * pagination?.page
|
|
145
|
+
return new Ok(FilterableUserMetadata.select().filter(filter?.filters ?? [], filter?.op)
|
|
146
|
+
.take(pagination?.limit ?? 0)
|
|
147
|
+
.skip((pagination?.limit ?? 0) * (pagination?.page ?? 0))
|
|
65
148
|
.order(order?.column ?? 'Id', order?.order ?? SortOrder.DESC));
|
|
66
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Get own metadata entry by key
|
|
152
|
+
* Retrieves a single metadata entry by key for the authenticated user.
|
|
153
|
+
* @security cookieAuth
|
|
154
|
+
* @param key Metadata key to retrieve
|
|
155
|
+
* @returns {IUserMetadataEntry} Single own metadata entry by key
|
|
156
|
+
* @response 401 Unauthorized — valid session required
|
|
157
|
+
* @response 403 Forbidden — readOwn permission required
|
|
158
|
+
* @response 404 Metadata key not found
|
|
159
|
+
*/
|
|
67
160
|
async getMeta(key) {
|
|
68
161
|
return new Ok(UserMetadata.where({
|
|
69
162
|
Key: key,
|
|
70
163
|
}).firstOrFail());
|
|
71
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Add or update own metadata
|
|
167
|
+
* Inserts a new metadata entry for the authenticated user, or updates it if the key already exists.
|
|
168
|
+
* @security cookieAuth
|
|
169
|
+
* @response 200 Metadata created or updated successfully
|
|
170
|
+
* @response 401 Unauthorized — valid session required
|
|
171
|
+
* @response 403 Forbidden — updateOwn permission required
|
|
172
|
+
*/
|
|
72
173
|
async addMetadata(metadata) {
|
|
73
174
|
await metadata.insert(InsertBehaviour.InsertOrUpdate);
|
|
74
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Update own metadata entry
|
|
178
|
+
* Updates Key, Value, and Type of an existing metadata entry identified by Id or Key.
|
|
179
|
+
* @security cookieAuth
|
|
180
|
+
* @param meta Metadata Id or Key to update
|
|
181
|
+
|
|
182
|
+
* @response 200 Metadata updated successfully
|
|
183
|
+
* @response 401 Unauthorized — valid session required
|
|
184
|
+
* @response 403 Forbidden — updateOwn permission required
|
|
185
|
+
* @response 404 Metadata entry not found
|
|
186
|
+
*/
|
|
75
187
|
async updateMetadata(meta, data) {
|
|
76
188
|
await UserMetadata.update({
|
|
77
189
|
Key: data.Key,
|
|
@@ -80,6 +192,16 @@ let UserMetadataController = class UserMetadataController extends BaseController
|
|
|
80
192
|
}).where("Key", meta).orWhere("Id", meta);
|
|
81
193
|
return new Ok();
|
|
82
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Delete own metadata entry
|
|
197
|
+
* Permanently removes a metadata entry by Id from the authenticated user's metadata.
|
|
198
|
+
* @security cookieAuth
|
|
199
|
+
* @param meta Metadata Id to delete
|
|
200
|
+
* @response 200 Metadata deleted successfully
|
|
201
|
+
* @response 401 Unauthorized — valid session required
|
|
202
|
+
* @response 403 Forbidden — deleteOwn permission required
|
|
203
|
+
* @response 404 Metadata entry not found
|
|
204
|
+
*/
|
|
83
205
|
async deleteMetadata(meta) {
|
|
84
206
|
await UserMetadata.destroy().where({
|
|
85
207
|
Id: meta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMetadataController.js","sourceRoot":"","sources":["../../../src/controllers/UserMetadataController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAA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S,CAAC,CAAC;IACF,WAAA,KAAK,EAAE,CAAA;;;;qDAI5B;AAYY;IAFZ,IAAI,CAAC,UAAU,CAAC;IAChB,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;IACA,WAAA,OAAO,EAAE,CAAA;;qCAAW,YAAY;;yDAEzD;AAeY;IAFZ,KAAK,CAAC,gBAAgB,CAAC;IACvB,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;IACG,WAAA,KAAK,EAAE,CAAA;IAAgB,WAAA,IAAI,EAAE,CAAA;;6CAAO,eAAe;;4DAQ/E;AAcY;IAFZ,GAAG,CAAC,gBAAgB,CAAC;IACrB,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;IACG,WAAA,KAAK,EAAE,CAAA;;;;4DAMnC;AA1PQ,sBAAsB;IAHlC,QAAQ,CAAC,MAAM,CAAC;IAChB,QAAQ,CAAC,eAAe,CAAC;IACzB,MAAM,CAAC,gBAAgB,CAAC;GACZ,sBAAsB,CA2PlC"}
|
|
@@ -7,13 +7,16 @@ export declare const MetadataDtoSchema: {
|
|
|
7
7
|
type: string;
|
|
8
8
|
maxLength: number;
|
|
9
9
|
minLength: number;
|
|
10
|
+
description: string;
|
|
10
11
|
};
|
|
11
12
|
Value: {
|
|
12
13
|
type: string;
|
|
14
|
+
description: string;
|
|
13
15
|
};
|
|
14
16
|
Type: {
|
|
15
17
|
type: string;
|
|
16
18
|
enum: string[];
|
|
19
|
+
description: string;
|
|
17
20
|
};
|
|
18
21
|
};
|
|
19
22
|
required: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-dto.d.ts","sourceRoot":"","sources":["../../../src/dto/metadata-dto.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"metadata-dto.d.ts","sourceRoot":"","sources":["../../../src/dto/metadata-dto.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;CAU7B,CAAC;AAEF,qBACa,eAAe;IACjB,GAAG,EAAG,MAAM,CAAC;IACb,KAAK,EAAG,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;gBACjE,IAAI,EAAE,GAAG;CAGxB"}
|
|
@@ -13,9 +13,9 @@ export const MetadataDtoSchema = {
|
|
|
13
13
|
title: 'User metadata DTO',
|
|
14
14
|
type: 'object',
|
|
15
15
|
properties: {
|
|
16
|
-
Key: { type: 'string', maxLength: 255, minLength: 6 },
|
|
17
|
-
Value: { type: 'string' },
|
|
18
|
-
Type: { type:
|
|
16
|
+
Key: { type: 'string', maxLength: 255, minLength: 6, description: 'Metadata key (dot-notation supported, e.g. user:niceName)' },
|
|
17
|
+
Value: { type: 'string', description: 'Metadata value stored as a string regardless of Type' },
|
|
18
|
+
Type: { type: 'string', enum: ['number', 'float', 'string', 'json', 'boolean', 'datetime'], description: 'Declared value type used for serialization/deserialization' },
|
|
19
19
|
},
|
|
20
20
|
required: ['Key', 'Type'],
|
|
21
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-dto.js","sourceRoot":"","sources":["../../../src/dto/metadata-dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,mBAAmB;IAC1B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"metadata-dto.js","sourceRoot":"","sources":["../../../src/dto/metadata-dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAA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