@aeriajs/builtins 0.0.185 → 0.0.187
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/collections/file/index.d.ts +1 -1
- package/dist/collections/file/remove.d.ts +1 -1
- package/dist/collections/user/getActivationLink.d.ts +1 -1
- package/dist/collections/user/getCurrentUser.d.ts +10 -0
- package/dist/collections/user/getCurrentUser.js +5 -0
- package/dist/collections/user/getCurrentUser.mjs +5 -0
- package/dist/collections/user/index.d.ts +11 -1
- package/dist/index.d.ts +12 -2
- package/package.json +8 -8
|
@@ -252,7 +252,7 @@ export declare const file: Omit<import("@aeriajs/types").Collection<never>, "fun
|
|
|
252
252
|
httpStatus: import("@aeriajs/types").HTTPStatus.Forbidden;
|
|
253
253
|
}> | {
|
|
254
254
|
readonly _tag: "Error";
|
|
255
|
-
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.MalformedInput, unknown, import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound>;
|
|
255
|
+
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.InsecureOperator | import("@aeriajs/types").ACError.MalformedInput, unknown, import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound>;
|
|
256
256
|
readonly result: undefined;
|
|
257
257
|
}>;
|
|
258
258
|
removeAll: (payload: import("@aeriajs/types").RemoveAllPayload, context: import("@aeriajs/types").Context<typeof description>) => Promise<{
|
|
@@ -15,6 +15,6 @@ export declare const remove: (payload: RemovePayload<SchemaWithId<typeof descrip
|
|
|
15
15
|
httpStatus: import("@aeriajs/types").HTTPStatus.Forbidden;
|
|
16
16
|
}> | {
|
|
17
17
|
readonly _tag: "Error";
|
|
18
|
-
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.MalformedInput, unknown, import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound>;
|
|
18
|
+
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.InsecureOperator | import("@aeriajs/types").ACError.MalformedInput, unknown, import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound>;
|
|
19
19
|
readonly result: undefined;
|
|
20
20
|
}>;
|
|
@@ -7,7 +7,7 @@ export declare const getActivationLink: (payload: {
|
|
|
7
7
|
userId: ObjectId | string;
|
|
8
8
|
}, context: Context) => Promise<{
|
|
9
9
|
readonly _tag: "Error";
|
|
10
|
-
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.MalformedInput, unknown, HTTPStatus.BadRequest | HTTPStatus.Forbidden | HTTPStatus.NotFound>;
|
|
10
|
+
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.InsecureOperator | import("@aeriajs/types").ACError.MalformedInput, unknown, HTTPStatus.BadRequest | HTTPStatus.Forbidden | HTTPStatus.NotFound>;
|
|
11
11
|
readonly result: undefined;
|
|
12
12
|
} | Result.Error<{
|
|
13
13
|
readonly code: ActivationError.AlreadyActiveUser;
|
|
@@ -6,6 +6,16 @@ export declare enum ActivationError {
|
|
|
6
6
|
InvalidLink = "INVALID_LINK"
|
|
7
7
|
}
|
|
8
8
|
export declare const getCurrentUser: (_payload: undefined, context: Context<typeof description>) => Promise<{
|
|
9
|
+
readonly _tag: "Result";
|
|
10
|
+
readonly error: undefined;
|
|
11
|
+
readonly result: {
|
|
12
|
+
_id: null;
|
|
13
|
+
name: string;
|
|
14
|
+
email: string;
|
|
15
|
+
roles: string[];
|
|
16
|
+
active: boolean;
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
9
19
|
readonly _tag: "Result";
|
|
10
20
|
readonly error: undefined;
|
|
11
21
|
readonly result: import("@aeriajs/types").SchemaWithId<{
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCurrentUser = exports.ActivationError = void 0;
|
|
4
4
|
const types_1 = require("@aeriajs/types");
|
|
5
|
+
const authentication_js_1 = require("../../authentication.js");
|
|
5
6
|
var ActivationError;
|
|
6
7
|
(function (ActivationError) {
|
|
7
8
|
ActivationError["UserNotFound"] = "USER_NOT_FOUND";
|
|
@@ -12,6 +13,10 @@ const getCurrentUser = async (_payload, context) => {
|
|
|
12
13
|
if (!context.token.authenticated) {
|
|
13
14
|
throw new Error();
|
|
14
15
|
}
|
|
16
|
+
if (!context.token.sub) {
|
|
17
|
+
const { user } = await (0, authentication_js_1.defaultSuccessfulAuthentication)();
|
|
18
|
+
return types_1.Result.result(user);
|
|
19
|
+
}
|
|
15
20
|
const { error, result: user } = await context.collections.user.functions.get({
|
|
16
21
|
filters: {
|
|
17
22
|
_id: context.token.sub,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { Result } from "@aeriajs/types";
|
|
3
|
+
import { defaultSuccessfulAuthentication } from "../../authentication.mjs";
|
|
3
4
|
export var ActivationError = /* @__PURE__ */ ((ActivationError2) => {
|
|
4
5
|
ActivationError2["UserNotFound"] = "USER_NOT_FOUND";
|
|
5
6
|
ActivationError2["AlreadyActiveUser"] = "ALREADY_ACTIVE_USER";
|
|
@@ -10,6 +11,10 @@ export const getCurrentUser = async (_payload, context) => {
|
|
|
10
11
|
if (!context.token.authenticated) {
|
|
11
12
|
throw new Error();
|
|
12
13
|
}
|
|
14
|
+
if (!context.token.sub) {
|
|
15
|
+
const { user: user2 } = await defaultSuccessfulAuthentication();
|
|
16
|
+
return Result.result(user2);
|
|
17
|
+
}
|
|
13
18
|
const { error, result: user } = await context.collections.user.functions.get({
|
|
14
19
|
filters: {
|
|
15
20
|
_id: context.token.sub
|
|
@@ -449,6 +449,16 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
449
449
|
};
|
|
450
450
|
}>;
|
|
451
451
|
getCurrentUser: (_payload: undefined, context: import("@aeriajs/types").Context<typeof description>) => Promise<{
|
|
452
|
+
readonly _tag: "Result";
|
|
453
|
+
readonly error: undefined;
|
|
454
|
+
readonly result: {
|
|
455
|
+
_id: null;
|
|
456
|
+
name: string;
|
|
457
|
+
email: string;
|
|
458
|
+
roles: string[];
|
|
459
|
+
active: boolean;
|
|
460
|
+
};
|
|
461
|
+
} | {
|
|
452
462
|
readonly _tag: "Result";
|
|
453
463
|
readonly error: undefined;
|
|
454
464
|
readonly result: import("@aeriajs/types").SchemaWithId<{
|
|
@@ -557,7 +567,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
557
567
|
userId: import("@aeriajs/core").ObjectId | string;
|
|
558
568
|
}, context: import("@aeriajs/types").Context) => Promise<{
|
|
559
569
|
readonly _tag: "Error";
|
|
560
|
-
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.MalformedInput, unknown, import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound>;
|
|
570
|
+
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.InsecureOperator | import("@aeriajs/types").ACError.MalformedInput, unknown, import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound>;
|
|
561
571
|
readonly result: undefined;
|
|
562
572
|
} | import("@aeriajs/types").Result.Error<{
|
|
563
573
|
readonly code: import("./activate.js").ActivationError.AlreadyActiveUser;
|
package/dist/index.d.ts
CHANGED
|
@@ -196,7 +196,7 @@ export declare const collections: {
|
|
|
196
196
|
httpStatus: import("@aeriajs/types").HTTPStatus.Forbidden;
|
|
197
197
|
}> | {
|
|
198
198
|
readonly _tag: "Error";
|
|
199
|
-
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.MalformedInput, unknown, import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound>;
|
|
199
|
+
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.InsecureOperator | import("@aeriajs/types").ACError.MalformedInput, unknown, import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound>;
|
|
200
200
|
readonly result: undefined;
|
|
201
201
|
}>;
|
|
202
202
|
removeAll: (payload: import("@aeriajs/types").RemoveAllPayload, context: import("@aeriajs/types").Context<typeof import("./collections/file/description.js").description>) => Promise<{
|
|
@@ -878,6 +878,16 @@ export declare const collections: {
|
|
|
878
878
|
};
|
|
879
879
|
}>;
|
|
880
880
|
getCurrentUser: (_payload: undefined, context: import("@aeriajs/types").Context<typeof import("./collections/user/description.js").description>) => Promise<{
|
|
881
|
+
readonly _tag: "Result";
|
|
882
|
+
readonly error: undefined;
|
|
883
|
+
readonly result: {
|
|
884
|
+
_id: null;
|
|
885
|
+
name: string;
|
|
886
|
+
email: string;
|
|
887
|
+
roles: string[];
|
|
888
|
+
active: boolean;
|
|
889
|
+
};
|
|
890
|
+
} | {
|
|
881
891
|
readonly _tag: "Result";
|
|
882
892
|
readonly error: undefined;
|
|
883
893
|
readonly result: import("@aeriajs/types").SchemaWithId<{
|
|
@@ -986,7 +996,7 @@ export declare const collections: {
|
|
|
986
996
|
userId: import("mongodb").ObjectId | string;
|
|
987
997
|
}, context: import("@aeriajs/types").Context) => Promise<{
|
|
988
998
|
readonly _tag: "Error";
|
|
989
|
-
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.MalformedInput, unknown, import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound>;
|
|
999
|
+
readonly error: import("@aeriajs/types").EndpointError<import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound | import("@aeriajs/types").ACError.InsecureOperator | import("@aeriajs/types").ACError.MalformedInput, unknown, import("@aeriajs/types").HTTPStatus.BadRequest | import("@aeriajs/types").HTTPStatus.Forbidden | import("@aeriajs/types").HTTPStatus.NotFound>;
|
|
990
1000
|
readonly result: undefined;
|
|
991
1001
|
} | import("@aeriajs/types").Result.Error<{
|
|
992
1002
|
readonly code: import("./collections/user/activate.js").ActivationError.AlreadyActiveUser;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/builtins",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.187",
|
|
4
4
|
"description": "## Installation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
"mongodb": "^6.5.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@aeriajs/core": "^0.0.
|
|
49
|
-
"@aeriajs/common": "^0.0.
|
|
50
|
-
"@aeriajs/entrypoint": "^0.0.
|
|
51
|
-
"@aeriajs/types": "^0.0.
|
|
52
|
-
"@aeriajs/validation": "^0.0.
|
|
48
|
+
"@aeriajs/core": "^0.0.187",
|
|
49
|
+
"@aeriajs/common": "^0.0.114",
|
|
50
|
+
"@aeriajs/entrypoint": "^0.0.117",
|
|
51
|
+
"@aeriajs/types": "^0.0.97",
|
|
52
|
+
"@aeriajs/validation": "^0.0.117"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"test": "echo skipping",
|
|
56
|
-
"lint": "eslint
|
|
57
|
-
"lint:fix": "eslint
|
|
56
|
+
"lint": "eslint .",
|
|
57
|
+
"lint:fix": "eslint . --fix",
|
|
58
58
|
"build": "pnpm build:cjs && pnpm build:esm",
|
|
59
59
|
"build:cjs": "tsc",
|
|
60
60
|
"build:esm": "esbuild './src/**/*.ts' --outdir=dist --out-extension:.js=.mjs && pnpm build:esm-transform",
|