@aeriajs/core 0.0.139 → 0.0.141

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.
@@ -6,7 +6,7 @@ const types_1 = require("@aeriajs/types");
6
6
  const common_1 = require("@aeriajs/common");
7
7
  const index_js_1 = require("../collection/index.js");
8
8
  const internalGetAll = async (payload, context) => {
9
- const { limit = context.config.paginationLimit, sort, project = [], offset = 0, } = payload;
9
+ const { limit = context.config.paginationLimit, sort, project, offset = 0, } = payload;
10
10
  const filters = payload.filters || {};
11
11
  const $text = payload.filters && '$text' in payload.filters
12
12
  ? payload.filters.$text
@@ -15,7 +15,7 @@ const internalGetAll = async (payload, context) => {
15
15
  delete filters.$text;
16
16
  }
17
17
  const pipeline = [];
18
- const references = await (0, index_js_1.getReferences)(context.description.properties, {
18
+ const refMap = await (0, index_js_1.getReferences)(context.description.properties, {
19
19
  memoize: context.description.$id,
20
20
  });
21
21
  if ($text) {
@@ -53,28 +53,29 @@ const internalGetAll = async (payload, context) => {
53
53
  pipeline.push({
54
54
  $limit: limit,
55
55
  });
56
- const projection = (0, index_js_1.normalizeProjection)(project, context.description);
57
- if (projection) {
58
- pipeline.push({
59
- $project: projection,
60
- });
56
+ if (project) {
57
+ const projection = (0, index_js_1.normalizeProjection)(project, context.description);
58
+ if (projection) {
59
+ pipeline.push({
60
+ $project: projection,
61
+ });
62
+ }
61
63
  }
62
- pipeline.push(...await (0, index_js_1.buildLookupPipeline)(references, {
64
+ pipeline.push(...(0, index_js_1.buildLookupPipeline)(refMap, {
63
65
  memoize: context.description.$id,
64
66
  project: payload.populate
65
67
  ? payload.populate
66
68
  : project,
67
- properties: context.description.properties,
68
69
  }));
69
- if (Object.keys(references).length > 0 && preferredSort) {
70
+ if (Object.keys(refMap).length > 0 && preferredSort) {
70
71
  pipeline.push({
71
72
  $sort: preferredSort,
72
73
  });
73
74
  }
74
75
  const result = await context.collection.model.aggregate(pipeline).toArray();
75
76
  const documents = [];
76
- for (const document of result) {
77
- documents.push((0, common_1.throwIfError)(await (0, index_js_1.traverseDocument)((0, index_js_1.fill)(document, context.description), context.description, {
77
+ for (const doc of result) {
78
+ documents.push((0, common_1.throwIfError)(await (0, index_js_1.traverseDocument)(doc, context.description, {
78
79
  getters: true,
79
80
  fromProperties: true,
80
81
  recurseReferences: true,
@@ -6,14 +6,13 @@ import {
6
6
  traverseDocument,
7
7
  normalizeProjection,
8
8
  getReferences,
9
- buildLookupPipeline,
10
- fill
9
+ buildLookupPipeline
11
10
  } from "../collection/index.mjs";
12
11
  const internalGetAll = async (payload, context) => {
13
12
  const {
14
13
  limit = context.config.paginationLimit,
15
14
  sort,
16
- project = [],
15
+ project,
17
16
  offset = 0
18
17
  } = payload;
19
18
  const filters = payload.filters || {};
@@ -22,7 +21,7 @@ const internalGetAll = async (payload, context) => {
22
21
  delete filters.$text;
23
22
  }
24
23
  const pipeline = [];
25
- const references = await getReferences(context.description.properties, {
24
+ const refMap = await getReferences(context.description.properties, {
26
25
  memoize: context.description.$id
27
26
  });
28
27
  if ($text) {
@@ -56,26 +55,27 @@ const internalGetAll = async (payload, context) => {
56
55
  pipeline.push({
57
56
  $limit: limit
58
57
  });
59
- const projection = normalizeProjection(project, context.description);
60
- if (projection) {
61
- pipeline.push({
62
- $project: projection
63
- });
58
+ if (project) {
59
+ const projection = normalizeProjection(project, context.description);
60
+ if (projection) {
61
+ pipeline.push({
62
+ $project: projection
63
+ });
64
+ }
64
65
  }
65
- pipeline.push(...await buildLookupPipeline(references, {
66
+ pipeline.push(...buildLookupPipeline(refMap, {
66
67
  memoize: context.description.$id,
67
- project: payload.populate ? payload.populate : project,
68
- properties: context.description.properties
68
+ project: payload.populate ? payload.populate : project
69
69
  }));
70
- if (Object.keys(references).length > 0 && preferredSort) {
70
+ if (Object.keys(refMap).length > 0 && preferredSort) {
71
71
  pipeline.push({
72
72
  $sort: preferredSort
73
73
  });
74
74
  }
75
75
  const result = await context.collection.model.aggregate(pipeline).toArray();
76
76
  const documents = [];
77
- for (const document of result) {
78
- documents.push(throwIfError(await traverseDocument(fill(document, context.description), context.description, {
77
+ for (const doc of result) {
78
+ documents.push(throwIfError(await traverseDocument(doc, context.description, {
79
79
  getters: true,
80
80
  fromProperties: true,
81
81
  recurseReferences: true,
@@ -70,7 +70,7 @@ const internalInsert = async (payload, context) => {
70
70
  }, content);
71
71
  }
72
72
  let doc;
73
- if (context.collection.originalFunctions.get) {
73
+ if (context.collection.originalFunctions?.get) {
74
74
  doc = (0, common_1.throwIfError)(await context.collection.originalFunctions.get({
75
75
  filters: {
76
76
  _id: newId,
@@ -60,7 +60,7 @@ const internalInsert = async (payload, context) => {
60
60
  }, content);
61
61
  }
62
62
  let doc;
63
- if (context.collection.originalFunctions.get) {
63
+ if (context.collection.originalFunctions?.get) {
64
64
  doc = throwIfError(await context.collection.originalFunctions.get({
65
65
  filters: {
66
66
  _id: newId
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@aeriajs/core",
3
- "version": "0.0.139",
3
+ "version": "0.0.141",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
+ "aeriaMain": "tests/fixtures/aeriaMain.js",
6
7
  "module": "dist/index.mjs",
7
8
  "types": "dist/index.d.ts",
8
9
  "publishConfig": {
@@ -41,11 +42,11 @@
41
42
  "mongodb-memory-server": "^9.2.0"
42
43
  },
43
44
  "peerDependencies": {
44
- "@aeriajs/builtins": "^0.0.139",
45
+ "@aeriajs/builtins": "^0.0.141",
45
46
  "@aeriajs/common": "^0.0.88",
46
47
  "@aeriajs/entrypoint": "^0.0.90",
47
48
  "@aeriajs/http": "^0.0.99",
48
- "@aeriajs/security": "^0.0.139",
49
+ "@aeriajs/security": "^0.0.141",
49
50
  "@aeriajs/types": "^0.0.76",
50
51
  "@aeriajs/validation": "^0.0.91"
51
52
  },
@@ -57,7 +58,7 @@
57
58
  "mongodb-memory-server": "^9.2.0"
58
59
  },
59
60
  "scripts": {
60
- "test": "TS_NODE_COMPILER_OPTIONS=\"$(cat ../compilerOptions.json)\" mocha -r ts-node/register tests/*.spec.ts",
61
+ "test": "vitest run",
61
62
  "lint": "eslint src",
62
63
  "lint:fix": "eslint src --fix",
63
64
  "build": "pnpm build:cjs && pnpm build:esm",