@aeriajs/builtins 0.0.71 → 0.0.73

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
  /// <reference types="node" />
2
2
  import type { Context } from '@aeriajs/types';
3
3
  import type { description } from './description.js';
4
- import fs from 'fs';
4
+ import * as fs from 'fs';
5
5
  export declare enum FileReadError {
6
6
  DocumentNotFound = "DOCUMENT_NOT_FOUND",
7
7
  FileNotFound = "FILE_NOT_FOUND"
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.download = exports.FileReadError = void 0;
7
4
  const core_1 = require("@aeriajs/core");
8
5
  const common_1 = require("@aeriajs/common");
9
- const fs_1 = __importDefault(require("fs"));
6
+ const fs = require("fs");
10
7
  var FileReadError;
11
8
  (function (FileReadError) {
12
9
  FileReadError["DocumentNotFound"] = "DOCUMENT_NOT_FOUND";
@@ -33,7 +30,7 @@ exports.download = (0, core_1.defineExposedFunction)(async (payload, context) =>
33
30
  }
34
31
  let stat;
35
32
  try {
36
- stat = await fs_1.default.promises.stat(file.absolute_path);
33
+ stat = await fs.promises.stat(file.absolute_path);
37
34
  }
38
35
  catch (e) {
39
36
  context.response.writeHead(404, {
@@ -60,7 +57,7 @@ exports.download = (0, core_1.defineExposedFunction)(async (payload, context) =>
60
57
  : ''}name=${encodeURI(file.name)}`,
61
58
  });
62
59
  }
63
- return fs_1.default.createReadStream(file.absolute_path, {
60
+ return fs.createReadStream(file.absolute_path, {
64
61
  start,
65
62
  end,
66
63
  });
@@ -73,5 +70,5 @@ exports.download = (0, core_1.defineExposedFunction)(async (payload, context) =>
73
70
  : ''}name=${encodeURI(file.name)}`,
74
71
  });
75
72
  }
76
- return fs_1.default.createReadStream(file.absolute_path);
73
+ return fs.createReadStream(file.absolute_path);
77
74
  });
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  import { defineExposedFunction, ObjectId } from "@aeriajs/core";
3
3
  import { left } from "@aeriajs/common";
4
- import fs from "fs";
4
+ import * as fs from "fs";
5
5
  export var FileReadError = /* @__PURE__ */ ((FileReadError2) => {
6
6
  FileReadError2["DocumentNotFound"] = "DOCUMENT_NOT_FOUND";
7
7
  FileReadError2["FileNotFound"] = "FILE_NOT_FOUND";
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.remove = void 0;
7
4
  const core_1 = require("@aeriajs/core");
8
- const promises_1 = __importDefault(require("fs/promises"));
5
+ const fs = require("fs/promises");
9
6
  exports.remove = (0, core_1.defineExposedFunction)(async (payload, context) => {
10
7
  const file = await context.collection.model.findOne({
11
8
  _id: payload.filters._id,
@@ -18,7 +15,7 @@ exports.remove = (0, core_1.defineExposedFunction)(async (payload, context) => {
18
15
  throw new Error('');
19
16
  }
20
17
  try {
21
- await promises_1.default.unlink(file.absolute_path);
18
+ await fs.unlink(file.absolute_path);
22
19
  }
23
20
  catch (err) {
24
21
  console.trace(err);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  import { defineExposedFunction, remove as originalRemove } from "@aeriajs/core";
3
- import fs from "fs/promises";
3
+ import * as fs from "fs/promises";
4
4
  export const remove = defineExposedFunction(async (payload, context) => {
5
5
  const file = await context.collection.model.findOne({
6
6
  _id: payload.filters._id
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.removeAll = void 0;
7
4
  const core_1 = require("@aeriajs/core");
8
- const promises_1 = __importDefault(require("fs/promises"));
5
+ const fs = require("fs/promises");
9
6
  exports.removeAll = (0, core_1.defineExposedFunction)(async (payload, context) => {
10
7
  const files = context.collection.model.find({
11
8
  _id: {
@@ -19,7 +16,7 @@ exports.removeAll = (0, core_1.defineExposedFunction)(async (payload, context) =
19
16
  let file;
20
17
  while (file = await files.next()) {
21
18
  try {
22
- await promises_1.default.unlink(file.absolute_path);
19
+ await fs.unlink(file.absolute_path);
23
20
  }
24
21
  catch (err) {
25
22
  console.trace(err);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  import { defineExposedFunction, remove as originalRemoveAll } from "@aeriajs/core";
3
- import fs from "fs/promises";
3
+ import * as fs from "fs/promises";
4
4
  export const removeAll = defineExposedFunction(async (payload, context) => {
5
5
  const files = context.collection.model.find({
6
6
  _id: {
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.activate = exports.ActivationErrors = void 0;
7
4
  const core_1 = require("@aeriajs/core");
8
5
  const common_1 = require("@aeriajs/common");
9
- const bcrypt_1 = __importDefault(require("bcrypt"));
6
+ const bcrypt = require("bcrypt");
10
7
  var ActivationErrors;
11
8
  (function (ActivationErrors) {
12
9
  ActivationErrors["UserNotFound"] = "USER_NOT_FOUND";
@@ -31,7 +28,7 @@ exports.activate = (0, core_1.defineExposedFunction)(async (payload, context) =>
31
28
  if (user.active) {
32
29
  return (0, common_1.left)(ActivationErrors.AlreadyActiveUser);
33
30
  }
34
- const equal = await bcrypt_1.default.compare(user._id.toString(), token);
31
+ const equal = await bcrypt.compare(user._id.toString(), token);
35
32
  if (!equal) {
36
33
  return (0, common_1.left)(ActivationErrors.InvalidLink);
37
34
  }
@@ -46,7 +43,7 @@ exports.activate = (0, core_1.defineExposedFunction)(async (payload, context) =>
46
43
  }, {
47
44
  $set: {
48
45
  active: true,
49
- password: await bcrypt_1.default.hash(payload.password, 10),
46
+ password: await bcrypt.hash(payload.password, 10),
50
47
  },
51
48
  });
52
49
  return (0, common_1.right)(true);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  import { defineExposedFunction, ObjectId } from "@aeriajs/core";
3
3
  import { left, right } from "@aeriajs/common";
4
- import bcrypt from "bcrypt";
4
+ import * as bcrypt from "bcrypt";
5
5
  export var ActivationErrors = /* @__PURE__ */ ((ActivationErrors2) => {
6
6
  ActivationErrors2["UserNotFound"] = "USER_NOT_FOUND";
7
7
  ActivationErrors2["AlreadyActiveUser"] = "ALREADY_ACTIVE_USER";
@@ -1,13 +1,10 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.createAccount = void 0;
7
4
  const core_1 = require("@aeriajs/core");
8
5
  const common_1 = require("@aeriajs/common");
9
6
  const validation_1 = require("@aeriajs/validation");
10
- const bcrypt_1 = __importDefault(require("bcrypt"));
7
+ const bcrypt = require("bcrypt");
11
8
  exports.createAccount = (0, core_1.defineExposedFunction)(async (payload, context) => {
12
9
  const user = Object.assign({}, payload);
13
10
  if (!context.config.security.allowSignup) {
@@ -48,7 +45,7 @@ exports.createAccount = (0, core_1.defineExposedFunction)(async (payload, contex
48
45
  Object.assign(user, context.config.security.signupDefaults);
49
46
  }
50
47
  if (user.password) {
51
- user.password = await bcrypt_1.default.hash(user.password, 10);
48
+ user.password = await bcrypt.hash(user.password, 10);
52
49
  }
53
50
  if (!context.token.authenticated) {
54
51
  Object.assign(user, {
@@ -2,7 +2,7 @@
2
2
  import { defineExposedFunction } from "@aeriajs/core";
3
3
  import { isLeft, unwrapEither, left, right } from "@aeriajs/common";
4
4
  import { validate } from "@aeriajs/validation";
5
- import bcrypt from "bcrypt";
5
+ import * as bcrypt from "bcrypt";
6
6
  export const createAccount = defineExposedFunction(async (payload, context) => {
7
7
  const user = Object.assign({}, payload);
8
8
  if (!context.config.security.allowSignup) {
@@ -1 +1,2 @@
1
+ import type { ObjectId } from '@aeriajs/core';
1
2
  export declare const getActivationLink: (userId: ObjectId) => Promise<string>;
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getActivationLink = void 0;
7
4
  const entrypoint_1 = require("@aeriajs/entrypoint");
8
- const bcrypt_1 = __importDefault(require("bcrypt"));
5
+ const bcrypt = require("bcrypt");
9
6
  const getActivationLink = async (userId) => {
10
7
  const config = await (0, entrypoint_1.getConfig)();
11
- const activationToken = await bcrypt_1.default.hash(userId.toString(), 10);
8
+ const activationToken = await bcrypt.hash(userId.toString(), 10);
12
9
  const link = `${config.publicUrl}/user/activate?u=${userId.toString()}&t=${activationToken}`;
13
10
  return link;
14
11
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  import { getConfig } from "@aeriajs/entrypoint";
3
- import bcrypt from "bcrypt";
3
+ import * as bcrypt from "bcrypt";
4
4
  export const getActivationLink = async (userId) => {
5
5
  const config = await getConfig();
6
6
  const activationToken = await bcrypt.hash(userId.toString(), 10);
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getInfo = exports.ActivationErrors = void 0;
7
4
  const core_1 = require("@aeriajs/core");
8
5
  const common_1 = require("@aeriajs/common");
9
- const bcrypt_1 = __importDefault(require("bcrypt"));
6
+ const bcrypt = require("bcrypt");
10
7
  var ActivationErrors;
11
8
  (function (ActivationErrors) {
12
9
  ActivationErrors["UserNotFound"] = "USER_NOT_FOUND";
@@ -27,7 +24,7 @@ exports.getInfo = (0, core_1.defineExposedFunction)(async (payload, context) =>
27
24
  if (user.active) {
28
25
  return (0, common_1.left)(ActivationErrors.AlreadyActiveUser);
29
26
  }
30
- const equal = await bcrypt_1.default.compare(user._id.toString(), token);
27
+ const equal = await bcrypt.compare(user._id.toString(), token);
31
28
  if (!equal) {
32
29
  return (0, common_1.left)(ActivationErrors.InvalidLink);
33
30
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  import { defineExposedFunction, ObjectId } from "@aeriajs/core";
3
3
  import { left, right } from "@aeriajs/common";
4
- import bcrypt from "bcrypt";
4
+ import * as bcrypt from "bcrypt";
5
5
  export var ActivationErrors = /* @__PURE__ */ ((ActivationErrors2) => {
6
6
  ActivationErrors2["UserNotFound"] = "USER_NOT_FOUND";
7
7
  ActivationErrors2["AlreadyActiveUser"] = "ALREADY_ACTIVE_USER";
@@ -613,7 +613,7 @@ export declare const user: Omit<import("@aeriajs/types").Collection<{
613
613
  };
614
614
  };
615
615
  }>, "name" | "roles" | "email" | "active"> & {
616
- _id: any;
616
+ _id: import("@aeriajs/core").ObjectId | null;
617
617
  };
618
618
  token: import("@aeriajs/types").TokenRecipient;
619
619
  } | {
@@ -1172,7 +1172,7 @@ export declare const user: Omit<import("@aeriajs/types").Collection<{
1172
1172
  readonly name: any;
1173
1173
  readonly email: any;
1174
1174
  }>>;
1175
- readonly getActivationLink: (userId: ObjectId) => Promise<string>;
1175
+ readonly getActivationLink: (userId: import("@aeriajs/core").ObjectId) => Promise<string>;
1176
1176
  };
1177
1177
  accessControl: {
1178
1178
  roles: {
@@ -1899,7 +1899,7 @@ export declare const user: Omit<import("@aeriajs/types").Collection<{
1899
1899
  };
1900
1900
  };
1901
1901
  }>, "name" | "roles" | "email" | "active"> & {
1902
- _id: any;
1902
+ _id: import("@aeriajs/core").ObjectId | null;
1903
1903
  };
1904
1904
  token: import("@aeriajs/types").TokenRecipient;
1905
1905
  } | {
@@ -2458,7 +2458,7 @@ export declare const user: Omit<import("@aeriajs/types").Collection<{
2458
2458
  readonly name: any;
2459
2459
  readonly email: any;
2460
2460
  }>>;
2461
- readonly getActivationLink: (userId: ObjectId) => Promise<string>;
2461
+ readonly getActivationLink: (userId: import("@aeriajs/core").ObjectId) => Promise<string>;
2462
2462
  };
2463
2463
  functionContracts: {
2464
2464
  readonly get?: import("@aeriajs/types").Contract | undefined;
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.insert = void 0;
7
- const bcrypt_1 = __importDefault(require("bcrypt"));
8
4
  const core_1 = require("@aeriajs/core");
5
+ const bcrypt = require("bcrypt");
9
6
  const insert = async (payload, context) => {
10
7
  if (payload.what.password) {
11
- payload.what.password = await bcrypt_1.default.hash(payload.what.password, 10);
8
+ payload.what.password = await bcrypt.hash(payload.what.password, 10);
12
9
  }
13
10
  return (0, core_1.insert)(payload, context);
14
11
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- import bcrypt from "bcrypt";
3
2
  import { defineFunctionAttributes, insert as originalInsert } from "@aeriajs/core";
3
+ import * as bcrypt from "bcrypt";
4
4
  export const insert = async (payload, context) => {
5
5
  if (payload.what.password) {
6
6
  payload.what.password = await bcrypt.hash(payload.what.password, 10);
@@ -111,7 +111,7 @@ export declare const describe: (contextOrPayload: RouteContext | Payload) => Pro
111
111
  };
112
112
  };
113
113
  }>, "name" | "roles" | "email" | "active"> & {
114
- _id: any;
114
+ _id: import("@aeriajs/core").ObjectId | null;
115
115
  };
116
116
  token: import("@aeriajs/types").TokenRecipient;
117
117
  } | {
package/dist/index.d.ts CHANGED
@@ -1798,7 +1798,7 @@ export declare const collections: {
1798
1798
  };
1799
1799
  };
1800
1800
  }>, "name" | "roles" | "email" | "active"> & {
1801
- _id: any;
1801
+ _id: import("mongodb").ObjectId | null;
1802
1802
  };
1803
1803
  token: import("@aeriajs/types").TokenRecipient;
1804
1804
  } | {
@@ -2357,7 +2357,7 @@ export declare const collections: {
2357
2357
  readonly name: any;
2358
2358
  readonly email: any;
2359
2359
  }>>;
2360
- readonly getActivationLink: (userId: ObjectId) => Promise<string>;
2360
+ readonly getActivationLink: (userId: import("mongodb").ObjectId) => Promise<string>;
2361
2361
  };
2362
2362
  accessControl: {
2363
2363
  roles: {
@@ -3084,7 +3084,7 @@ export declare const collections: {
3084
3084
  };
3085
3085
  };
3086
3086
  }>, "name" | "roles" | "email" | "active"> & {
3087
- _id: any;
3087
+ _id: import("mongodb").ObjectId | null;
3088
3088
  };
3089
3089
  token: import("@aeriajs/types").TokenRecipient;
3090
3090
  } | {
@@ -3643,7 +3643,7 @@ export declare const collections: {
3643
3643
  readonly name: any;
3644
3644
  readonly email: any;
3645
3645
  }>>;
3646
- readonly getActivationLink: (userId: ObjectId) => Promise<string>;
3646
+ readonly getActivationLink: (userId: import("mongodb").ObjectId) => Promise<string>;
3647
3647
  };
3648
3648
  functionContracts: {
3649
3649
  readonly get?: import("@aeriajs/types").Contract | undefined;
package/dist/index.js CHANGED
@@ -10,25 +10,13 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
15
  };
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
28
16
  Object.defineProperty(exports, "__esModule", { value: true });
29
17
  exports.collections = exports.systemFunctions = void 0;
30
18
  __exportStar(require("./collections/index.js"), exports);
31
- exports.systemFunctions = __importStar(require("./functions/index.js"));
19
+ exports.systemFunctions = require("./functions/index.js");
32
20
  const index_js_1 = require("./collections/index.js");
33
21
  exports.collections = {
34
22
  file: index_js_1.file,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/builtins",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "description": "## Installation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -46,12 +46,12 @@
46
46
  "mongodb": "^6.5.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "@aeriajs/access-control": "^0.0.38",
50
- "@aeriajs/core": "^0.0.71",
51
- "@aeriajs/common": "^0.0.38",
52
- "@aeriajs/entrypoint": "^0.0.38",
53
- "@aeriajs/types": "^0.0.35",
54
- "@aeriajs/validation": "^0.0.41"
49
+ "@aeriajs/access-control": "^0.0.40",
50
+ "@aeriajs/core": "^0.0.73",
51
+ "@aeriajs/common": "^0.0.40",
52
+ "@aeriajs/entrypoint": "^0.0.40",
53
+ "@aeriajs/types": "^0.0.37",
54
+ "@aeriajs/validation": "^0.0.43"
55
55
  },
56
56
  "scripts": {
57
57
  "test": "echo skipping",