@aeriajs/core 0.0.180 → 0.0.181

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.
@@ -5,6 +5,5 @@ export * from './isValidCollection.js';
5
5
  export * from './makePagination.js';
6
6
  export * from './normalizeProjection.js';
7
7
  export * from './preload.js';
8
- export * from './prepareCreate.js';
9
8
  export * from './reference.js';
10
9
  export * from './traverseDocument.js';
@@ -21,6 +21,5 @@ __exportStar(require("./isValidCollection.js"), exports);
21
21
  __exportStar(require("./makePagination.js"), exports);
22
22
  __exportStar(require("./normalizeProjection.js"), exports);
23
23
  __exportStar(require("./preload.js"), exports);
24
- __exportStar(require("./prepareCreate.js"), exports);
25
24
  __exportStar(require("./reference.js"), exports);
26
25
  __exportStar(require("./traverseDocument.js"), exports);
@@ -6,6 +6,5 @@ export * from "./isValidCollection.mjs";
6
6
  export * from "./makePagination.mjs";
7
7
  export * from "./normalizeProjection.mjs";
8
8
  export * from "./preload.mjs";
9
- export * from "./prepareCreate.mjs";
10
9
  export * from "./reference.mjs";
11
10
  export * from "./traverseDocument.mjs";
@@ -28,6 +28,14 @@ const insertErrorSchema = () => (0, common_1.endpointErrorSchema)({
28
28
  ],
29
29
  });
30
30
  exports.insertErrorSchema = insertErrorSchema;
31
+ const prepareCreate = (doc, description) => {
32
+ const result = {};
33
+ if (description.defaults) {
34
+ Object.assign(result, description.defaults);
35
+ }
36
+ Object.assign(result, doc);
37
+ return result;
38
+ };
31
39
  const internalInsert = async (payload, context) => {
32
40
  const isUpdate = !!('_id' in payload.what && payload.what._id);
33
41
  const { error, result: what } = await (0, index_js_1.traverseDocument)(payload.what, context.description, {
@@ -59,7 +67,7 @@ const internalInsert = async (payload, context) => {
59
67
  : null;
60
68
  let newId = docId;
61
69
  if (!newId) {
62
- const content = (0, index_js_1.prepareCreate)(what, context.description);
70
+ const content = prepareCreate(what, context.description);
63
71
  const now = new Date();
64
72
  Object.assign(content, {
65
73
  created_at: now,
@@ -3,7 +3,7 @@ import { ObjectId } from "mongodb";
3
3
  import { Result, HTTPStatus, ACError, ValidationErrorCode, TraverseError } from "@aeriajs/types";
4
4
  import { useSecurity, applyWriteMiddlewares } from "@aeriajs/security";
5
5
  import { endpointErrorSchema } from "@aeriajs/common";
6
- import { traverseDocument, prepareCreate } from "../collection/index.mjs";
6
+ import { traverseDocument } from "../collection/index.mjs";
7
7
  import { get } from "./get.mjs";
8
8
  export const insertErrorSchema = () => endpointErrorSchema({
9
9
  httpStatus: [
@@ -25,6 +25,14 @@ export const insertErrorSchema = () => endpointErrorSchema({
25
25
  TraverseError.InvalidTempfile
26
26
  ]
27
27
  });
28
+ const prepareCreate = (doc, description) => {
29
+ const result = {};
30
+ if (description.defaults) {
31
+ Object.assign(result, description.defaults);
32
+ }
33
+ Object.assign(result, doc);
34
+ return result;
35
+ };
28
36
  const internalInsert = async (payload, context) => {
29
37
  const isUpdate = !!("_id" in payload.what && payload.what._id);
30
38
  const { error, result: what } = await traverseDocument(payload.what, context.description, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/core",
3
- "version": "0.0.180",
3
+ "version": "0.0.181",
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.180",
46
- "@aeriajs/common": "^0.0.110",
47
- "@aeriajs/entrypoint": "^0.0.113",
48
- "@aeriajs/http": "^0.0.124",
49
- "@aeriajs/security": "^0.0.180",
50
- "@aeriajs/types": "^0.0.93",
51
- "@aeriajs/validation": "^0.0.113"
45
+ "@aeriajs/builtins": "^0.0.181",
46
+ "@aeriajs/common": "^0.0.111",
47
+ "@aeriajs/entrypoint": "^0.0.114",
48
+ "@aeriajs/http": "^0.0.125",
49
+ "@aeriajs/security": "^0.0.181",
50
+ "@aeriajs/types": "^0.0.94",
51
+ "@aeriajs/validation": "^0.0.114"
52
52
  },
53
53
  "dependencies": {
54
54
  "mongodb": "^6.5.0",
@@ -1,2 +0,0 @@
1
- import type { Description } from '@aeriajs/types';
2
- export declare const prepareCreate: (doc: Record<string, unknown>, description: Description) => Record<string, unknown>;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareCreate = void 0;
4
- const prepareCreate = (doc, description) => {
5
- const result = {};
6
- if (description.defaults) {
7
- Object.assign(result, description.defaults);
8
- }
9
- Object.assign(result, doc);
10
- return result;
11
- };
12
- exports.prepareCreate = prepareCreate;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- export const prepareCreate = (doc, description) => {
3
- const result = {};
4
- if (description.defaults) {
5
- Object.assign(result, description.defaults);
6
- }
7
- Object.assign(result, doc);
8
- return result;
9
- };