@aeriajs/core 0.0.144 → 0.0.146

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.
@@ -44,7 +44,7 @@ const preferredRemove = async (targetId, reference, parentContext) => {
44
44
  const internalCascadingRemove = async (target, refMap, context) => {
45
45
  for (const refName in refMap) {
46
46
  const reference = refMap[refName];
47
- if (!reference || !target[refName]) {
47
+ if (!target[refName]) {
48
48
  continue;
49
49
  }
50
50
  if (reference.isInline || reference.referencedCollection === 'file') {
@@ -42,7 +42,7 @@ const preferredRemove = async (targetId, reference, parentContext) => {
42
42
  const internalCascadingRemove = async (target, refMap, context) => {
43
43
  for (const refName in refMap) {
44
44
  const reference = refMap[refName];
45
- if (!reference || !target[refName]) {
45
+ if (!target[refName]) {
46
46
  continue;
47
47
  }
48
48
  if (reference.isInline || reference.referencedCollection === "file") {
@@ -11,9 +11,9 @@ export type Reference = {
11
11
  isRecursive?: boolean;
12
12
  deepReferences?: ReferenceMap;
13
13
  referencedCollection?: string;
14
- populatedProperties?: string[];
14
+ indexes?: string[];
15
15
  };
16
- export type ReferenceMap = Record<string, Reference | undefined>;
16
+ export type ReferenceMap = Record<string, Reference>;
17
17
  export type PipelineStage = {};
18
18
  export type BuildLookupPipelineOptions = {
19
19
  rootPipeline?: PipelineStage[];
@@ -35,8 +35,8 @@ const getReferences = async (properties, options = {}) => {
35
35
  }
36
36
  const indexes = refProperty.indexes
37
37
  ? refProperty.indexes
38
- : description.indexes || [];
39
- reference.populatedProperties = (refProperty.populate || []).concat(indexes.filter((index) => typeof index === 'string'));
38
+ : description.indexes || Object.keys(description.properties).slice(0, 1);
39
+ reference.indexes = (refProperty.populate || []).concat(indexes.filter((index) => typeof index === 'string'));
40
40
  }
41
41
  else {
42
42
  const entrypoint = 'items' in property
@@ -166,9 +166,6 @@ const recurseSetStage = (reference, path, parentElem, options = {
166
166
  if (reference.deepReferences) {
167
167
  const stages = [];
168
168
  for (const [subRefName, subReference] of Object.entries(reference.deepReferences)) {
169
- if (!subReference) {
170
- continue;
171
- }
172
169
  let newElem;
173
170
  if (reference.isRecursive) {
174
171
  newElem = {
@@ -251,9 +248,6 @@ const buildLookupPipeline = (refMap, options = {}) => {
251
248
  const pipeline = [];
252
249
  const setProperties = [];
253
250
  for (const [refName, reference] of Object.entries(refMap)) {
254
- if (!reference) {
255
- continue;
256
- }
257
251
  if (project) {
258
252
  if (!project.includes(refName)) {
259
253
  continue;
@@ -275,13 +269,13 @@ const buildLookupPipeline = (refMap, options = {}) => {
275
269
  const tempName = getTempName(path.concat(refName));
276
270
  const lookupPipeline = [];
277
271
  tempNames.unshift(tempName);
278
- if (reference.populatedProperties && reference.populatedProperties.length > 0) {
279
- const lookupPopulate = reference.populatedProperties;
272
+ if (reference.indexes && reference.indexes.length > 0) {
273
+ const lookupPopulate = reference.indexes;
280
274
  if (reference.deepReferences) {
281
275
  lookupPopulate.push(...Object.keys(reference.deepReferences));
282
276
  }
283
277
  lookupPipeline.push({
284
- $project: Object.fromEntries(reference.populatedProperties.map((index) => [
278
+ $project: Object.fromEntries(reference.indexes.map((index) => [
285
279
  index,
286
280
  1,
287
281
  ])),
@@ -35,8 +35,8 @@ export const getReferences = async (properties, options = {}) => {
35
35
  if (Object.keys(deepReferences).length > 0) {
36
36
  reference.deepReferences = deepReferences;
37
37
  }
38
- const indexes = refProperty.indexes ? refProperty.indexes : description.indexes || [];
39
- reference.populatedProperties = (refProperty.populate || []).concat(indexes.filter((index) => typeof index === "string"));
38
+ const indexes = refProperty.indexes ? refProperty.indexes : description.indexes || Object.keys(description.properties).slice(0, 1);
39
+ reference.indexes = (refProperty.populate || []).concat(indexes.filter((index) => typeof index === "string"));
40
40
  } else {
41
41
  const entrypoint = "items" in property ? property.items : property;
42
42
  if ("properties" in entrypoint) {
@@ -155,9 +155,6 @@ export const recurseSetStage = (reference, path, parentElem, options = {
155
155
  if (reference.deepReferences) {
156
156
  const stages = [];
157
157
  for (const [subRefName, subReference] of Object.entries(reference.deepReferences)) {
158
- if (!subReference) {
159
- continue;
160
- }
161
158
  let newElem;
162
159
  if (reference.isRecursive) {
163
160
  newElem = {
@@ -240,9 +237,6 @@ export const buildLookupPipeline = (refMap, options = {}) => {
240
237
  const pipeline = [];
241
238
  const setProperties = [];
242
239
  for (const [refName, reference] of Object.entries(refMap)) {
243
- if (!reference) {
244
- continue;
245
- }
246
240
  if (project) {
247
241
  if (!project.includes(refName)) {
248
242
  continue;
@@ -264,13 +258,13 @@ export const buildLookupPipeline = (refMap, options = {}) => {
264
258
  const tempName = getTempName(path.concat(refName));
265
259
  const lookupPipeline = [];
266
260
  tempNames.unshift(tempName);
267
- if (reference.populatedProperties && reference.populatedProperties.length > 0) {
268
- const lookupPopulate = reference.populatedProperties;
261
+ if (reference.indexes && reference.indexes.length > 0) {
262
+ const lookupPopulate = reference.indexes;
269
263
  if (reference.deepReferences) {
270
264
  lookupPopulate.push(...Object.keys(reference.deepReferences));
271
265
  }
272
266
  lookupPipeline.push({
273
- $project: Object.fromEntries(reference.populatedProperties.map((index) => [
267
+ $project: Object.fromEntries(reference.indexes.map((index) => [
274
268
  index,
275
269
  1
276
270
  ]))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/core",
3
- "version": "0.0.144",
3
+ "version": "0.0.146",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "aeriaMain": "tests/fixtures/aeriaMain.js",
@@ -42,13 +42,13 @@
42
42
  "mongodb-memory-server": "^9.2.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@aeriajs/builtins": "^0.0.144",
46
- "@aeriajs/common": "^0.0.89",
47
- "@aeriajs/entrypoint": "^0.0.91",
48
- "@aeriajs/http": "^0.0.101",
49
- "@aeriajs/security": "^0.0.144",
50
- "@aeriajs/types": "^0.0.77",
51
- "@aeriajs/validation": "^0.0.92"
45
+ "@aeriajs/builtins": "^0.0.146",
46
+ "@aeriajs/common": "^0.0.90",
47
+ "@aeriajs/entrypoint": "^0.0.92",
48
+ "@aeriajs/http": "^0.0.102",
49
+ "@aeriajs/security": "^0.0.146",
50
+ "@aeriajs/types": "^0.0.78",
51
+ "@aeriajs/validation": "^0.0.93"
52
52
  },
53
53
  "dependencies": {
54
54
  "mongodb": "^6.5.0",