@aeriajs/builtins 0.0.192 → 0.0.194

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.
@@ -1,7 +1,7 @@
1
1
  import type { RouteContext, SchemaWithId, TokenRecipient } from '@aeriajs/types';
2
2
  import type { description } from './collections/user/description.js';
3
3
  type User = SchemaWithId<typeof description>;
4
- export type TokenableUser = Pick<User, '_id' | 'name' | 'email' | 'roles' | 'active'>;
4
+ export type TokenableUser = Pick<User, '_id' | 'name' | 'email' | 'roles' | 'active' | 'picture'>;
5
5
  export type SuccessfulAuthentication = {
6
6
  user: TokenableUser;
7
7
  token: TokenRecipient;
@@ -11,6 +11,7 @@ const successfulAuthentication = async (user, context) => {
11
11
  const tokenContent = {
12
12
  sub: user._id,
13
13
  roles: user.roles,
14
+ picture: user.picture,
14
15
  userinfo: {},
15
16
  };
16
17
  if (context.config.security.authenticationRateLimiting) {
@@ -9,6 +9,7 @@ export const successfulAuthentication = async (user, context) => {
9
9
  const tokenContent = {
10
10
  sub: user._id,
11
11
  roles: user.roles,
12
+ picture: user.picture,
12
13
  userinfo: {}
13
14
  };
14
15
  if (context.config.security.authenticationRateLimiting) {
@@ -1,3 +1,5 @@
1
+ import { ObjectId } from 'mongodb';
2
+ export declare const getFileLink: (fileId: ObjectId) => Promise<string>;
1
3
  export declare const description: {
2
4
  readonly $id: "file";
3
5
  readonly icon: "paperclip";
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.description = void 0;
3
+ exports.description = exports.getFileLink = void 0;
4
4
  const mongodb_1 = require("mongodb");
5
5
  const core_1 = require("@aeriajs/core");
6
6
  const entrypoint_1 = require("@aeriajs/entrypoint");
7
- const link = async (fileId) => {
8
- const config = await (0, entrypoint_1.getConfig)();
9
- return `${config.publicUrl || ''}/file/${fileId}`;
10
- };
11
7
  const timestamp = (lastModified) => lastModified instanceof Date
12
8
  ? new Date(lastModified).getTime()
13
9
  : 'fresh';
10
+ const getFileLink = async (fileId) => {
11
+ const config = await (0, entrypoint_1.getConfig)();
12
+ return `${config.publicUrl || ''}/file/${fileId}`;
13
+ };
14
+ exports.getFileLink = getFileLink;
14
15
  exports.description = (0, core_1.defineDescription)({
15
16
  $id: 'file',
16
17
  icon: 'paperclip',
@@ -48,14 +49,14 @@ exports.description = (0, core_1.defineDescription)({
48
49
  link: {
49
50
  getter: async (doc) => {
50
51
  if ('_id' in doc && 'last_modified' in doc && doc._id instanceof mongodb_1.ObjectId) {
51
- return `${await link(doc._id)}/${timestamp(doc.last_modified)}`;
52
+ return `${await (0, exports.getFileLink)(doc._id)}/${timestamp(doc.last_modified)}`;
52
53
  }
53
54
  },
54
55
  },
55
56
  download_link: {
56
57
  getter: async (doc) => {
57
58
  if ('_id' in doc && 'last_modified' in doc && doc._id instanceof mongodb_1.ObjectId) {
58
- return `${await link(doc._id)}/download/${timestamp(doc.last_modified)}`;
59
+ return `${await (0, exports.getFileLink)(doc._id)}/download/${timestamp(doc.last_modified)}`;
59
60
  }
60
61
  },
61
62
  },
@@ -2,11 +2,11 @@
2
2
  import { ObjectId } from "mongodb";
3
3
  import { defineDescription } from "@aeriajs/core";
4
4
  import { getConfig } from "@aeriajs/entrypoint";
5
- const link = async (fileId) => {
5
+ const timestamp = (lastModified) => lastModified instanceof Date ? new Date(lastModified).getTime() : "fresh";
6
+ export const getFileLink = async (fileId) => {
6
7
  const config = await getConfig();
7
8
  return `${config.publicUrl || ""}/file/${fileId}`;
8
9
  };
9
- const timestamp = (lastModified) => lastModified instanceof Date ? new Date(lastModified).getTime() : "fresh";
10
10
  export const description = defineDescription({
11
11
  $id: "file",
12
12
  icon: "paperclip",
@@ -44,14 +44,14 @@ export const description = defineDescription({
44
44
  link: {
45
45
  getter: async (doc) => {
46
46
  if ("_id" in doc && "last_modified" in doc && doc._id instanceof ObjectId) {
47
- return `${await link(doc._id)}/${timestamp(doc.last_modified)}`;
47
+ return `${await getFileLink(doc._id)}/${timestamp(doc.last_modified)}`;
48
48
  }
49
49
  }
50
50
  },
51
51
  download_link: {
52
52
  getter: async (doc) => {
53
53
  if ("_id" in doc && "last_modified" in doc && doc._id instanceof ObjectId) {
54
- return `${await link(doc._id)}/download/${timestamp(doc.last_modified)}`;
54
+ return `${await getFileLink(doc._id)}/download/${timestamp(doc.last_modified)}`;
55
55
  }
56
56
  }
57
57
  }
@@ -59,7 +59,7 @@ export declare const createAccount: (payload: Partial<PackReferences<SchemaWithI
59
59
  readonly accept: readonly ["image/*"];
60
60
  };
61
61
  readonly picture: {
62
- readonly getter: (doc: object) => string | undefined;
62
+ readonly getter: (doc: object) => Promise<string> | undefined;
63
63
  };
64
64
  readonly group: {
65
65
  readonly type: "string";
@@ -48,7 +48,7 @@ export declare const description: {
48
48
  readonly accept: readonly ["image/*"];
49
49
  };
50
50
  readonly picture: {
51
- readonly getter: (doc: object) => string | undefined;
51
+ readonly getter: (doc: object) => Promise<string> | undefined;
52
52
  };
53
53
  readonly group: {
54
54
  readonly type: "string";
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.description = void 0;
4
4
  const core_1 = require("@aeriajs/core");
5
+ const description_js_1 = require("../file/description.js");
5
6
  /**
6
7
  * This description complies with JWT claims specified in RFC-7519.
7
8
  * Reference: https://www.iana.org/assignments/jwt/jwt.xhtml#claims
@@ -72,8 +73,8 @@ exports.description = (0, core_1.defineDescription)({
72
73
  },
73
74
  picture: {
74
75
  getter: (doc) => {
75
- if ('picture_file' in doc && doc.picture_file instanceof Object && 'link' in doc.picture_file && typeof doc.picture_file.link === 'string') {
76
- return doc.picture_file.link;
76
+ if ('picture_file' in doc && doc.picture_file && typeof doc.picture_file === 'object' && '_id' in doc.picture_file && doc.picture_file._id instanceof core_1.ObjectId) {
77
+ return (0, description_js_1.getFileLink)(doc.picture_file._id);
77
78
  }
78
79
  },
79
80
  },
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
- import { defineDescription } from "@aeriajs/core";
2
+ import { defineDescription, ObjectId } from "@aeriajs/core";
3
+ import { getFileLink } from "../file/description.mjs";
3
4
  export const description = defineDescription({
4
5
  $id: "user",
5
6
  icon: "users",
@@ -66,8 +67,8 @@ export const description = defineDescription({
66
67
  },
67
68
  picture: {
68
69
  getter: (doc) => {
69
- if ("picture_file" in doc && doc.picture_file instanceof Object && "link" in doc.picture_file && typeof doc.picture_file.link === "string") {
70
- return doc.picture_file.link;
70
+ if ("picture_file" in doc && doc.picture_file && typeof doc.picture_file === "object" && "_id" in doc.picture_file && doc.picture_file._id instanceof ObjectId) {
71
+ return getFileLink(doc.picture_file._id);
71
72
  }
72
73
  }
73
74
  },
@@ -64,7 +64,7 @@ export declare const getCurrentUser: (_payload: undefined, context: Context<type
64
64
  readonly accept: readonly ["image/*"];
65
65
  };
66
66
  readonly picture: {
67
- readonly getter: (doc: object) => string | undefined;
67
+ readonly getter: (doc: object) => Promise<string> | undefined;
68
68
  };
69
69
  readonly group: {
70
70
  readonly type: "string";
@@ -47,7 +47,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
47
47
  readonly accept: readonly ["image/*"];
48
48
  };
49
49
  readonly picture: {
50
- readonly getter: (doc: object) => string | undefined;
50
+ readonly getter: (doc: object) => Promise<string> | undefined;
51
51
  };
52
52
  readonly group: {
53
53
  readonly type: "string";
@@ -148,7 +148,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
148
148
  readonly accept: readonly ["image/*"];
149
149
  };
150
150
  readonly picture: {
151
- readonly getter: (doc: object) => string | undefined;
151
+ readonly getter: (doc: object) => Promise<string> | undefined;
152
152
  };
153
153
  readonly group: {
154
154
  readonly type: "string";
@@ -370,7 +370,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
370
370
  readonly accept: readonly ["image/*"];
371
371
  };
372
372
  readonly picture: {
373
- readonly getter: (doc: object) => string | undefined;
373
+ readonly getter: (doc: object) => Promise<string> | undefined;
374
374
  };
375
375
  readonly group: {
376
376
  readonly type: "string";
@@ -507,7 +507,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
507
507
  readonly accept: readonly ["image/*"];
508
508
  };
509
509
  readonly picture: {
510
- readonly getter: (doc: object) => string | undefined;
510
+ readonly getter: (doc: object) => Promise<string> | undefined;
511
511
  };
512
512
  readonly group: {
513
513
  readonly type: "string";
package/dist/index.d.ts CHANGED
@@ -510,7 +510,7 @@ export declare const collections: {
510
510
  readonly accept: readonly ["image/*"];
511
511
  };
512
512
  readonly picture: {
513
- readonly getter: (doc: object) => string | undefined;
513
+ readonly getter: (doc: object) => Promise<string> | undefined;
514
514
  };
515
515
  readonly group: {
516
516
  readonly type: "string";
@@ -611,7 +611,7 @@ export declare const collections: {
611
611
  readonly accept: readonly ["image/*"];
612
612
  };
613
613
  readonly picture: {
614
- readonly getter: (doc: object) => string | undefined;
614
+ readonly getter: (doc: object) => Promise<string> | undefined;
615
615
  };
616
616
  readonly group: {
617
617
  readonly type: "string";
@@ -833,7 +833,7 @@ export declare const collections: {
833
833
  readonly accept: readonly ["image/*"];
834
834
  };
835
835
  readonly picture: {
836
- readonly getter: (doc: object) => string | undefined;
836
+ readonly getter: (doc: object) => Promise<string> | undefined;
837
837
  };
838
838
  readonly group: {
839
839
  readonly type: "string";
@@ -970,7 +970,7 @@ export declare const collections: {
970
970
  readonly accept: readonly ["image/*"];
971
971
  };
972
972
  readonly picture: {
973
- readonly getter: (doc: object) => string | undefined;
973
+ readonly getter: (doc: object) => Promise<string> | undefined;
974
974
  };
975
975
  readonly group: {
976
976
  readonly type: "string";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/builtins",
3
- "version": "0.0.192",
3
+ "version": "0.0.194",
4
4
  "description": "## Installation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -45,11 +45,11 @@
45
45
  "mongodb": "^6.5.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "@aeriajs/core": "^0.0.192",
49
- "@aeriajs/common": "^0.0.118",
50
- "@aeriajs/entrypoint": "^0.0.121",
51
- "@aeriajs/types": "^0.0.101",
52
- "@aeriajs/validation": "^0.0.121"
48
+ "@aeriajs/core": "^0.0.194",
49
+ "@aeriajs/common": "^0.0.119",
50
+ "@aeriajs/entrypoint": "^0.0.122",
51
+ "@aeriajs/types": "^0.0.102",
52
+ "@aeriajs/validation": "^0.0.123"
53
53
  },
54
54
  "scripts": {
55
55
  "test": "echo skipping",