@tstdl/base 0.88.4 → 0.88.6

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,6 +1,6 @@
1
1
  import { NotFoundError } from '../../error/not-found.error.js';
2
2
  import { objectKeys } from '../../utils/object/object.js';
3
- import { assertDefined, isNullOrUndefined } from '../../utils/type-guards.js';
3
+ import { assertDefined, isNull, isNullOrUndefined } from '../../utils/type-guards.js';
4
4
  import { mongoDocumentFromMaybeNewEntity, toEntity, toMongoDocument, toMongoProjection, toNewEntity, toProjectedEntity } from './model/document.js';
5
5
  import { MongoBulk } from './mongo-bulk.js';
6
6
  import { replaceOneOperation, updateOneOperation } from './operations.js';
@@ -116,18 +116,18 @@ export class MongoBaseRepository {
116
116
  }
117
117
  async tryLoadByFilterAndDelete(filter, options) {
118
118
  const result = await this.collection.findOneAndDelete(filter, options);
119
- if (result.value == undefined) {
119
+ if (isNull(result)) {
120
120
  return undefined;
121
121
  }
122
- return toEntity(result.value);
122
+ return toEntity(result);
123
123
  }
124
124
  async loadByFilterAndUpdate(filter, update, options) {
125
125
  const entity = await this.tryLoadByFilterAndUpdate(filter, update, options);
126
126
  return throwIfUndefinedElsePass(entity, this.collection.collectionName);
127
127
  }
128
128
  async tryLoadByFilterAndUpdate(filter, update, options) {
129
- const { value: document } = await this.collection.findOneAndUpdate(filter, update, options);
130
- if (document == undefined) {
129
+ const document = await this.collection.findOneAndUpdate(filter, update, options);
130
+ if (isNull(document)) {
131
131
  return undefined;
132
132
  }
133
133
  return toEntity(document);
@@ -15,7 +15,7 @@ import { encodeUtf8 } from '../../utils/encoding.js';
15
15
  import { composeAsyncMiddleware } from '../../utils/middleware.js';
16
16
  import { objectEntries } from '../../utils/object/object.js';
17
17
  import { readableStreamFromPromise } from '../../utils/stream/readable-stream-from-promise.js';
18
- import { isDefined, isObject, isUndefined } from '../../utils/type-guards.js';
18
+ import { isArray, isDefined, isObject, isUndefined } from '../../utils/type-guards.js';
19
19
  import { buildUrl } from '../../utils/url-builder.js';
20
20
  import { HttpHeaders } from '../http-headers.js';
21
21
  import { HttpError, HttpErrorReason } from '../http.error.js';
@@ -284,7 +284,7 @@ function mapParameters(request, baseUrl) {
284
284
  if (request.mapParametersToQuery) {
285
285
  for (const entry of parameterEntries) {
286
286
  const [parameter, value] = entry;
287
- if (isUndefined(value) || isObject(value)) {
287
+ if (isUndefined(value) || (isObject(value) && !isArray(value))) {
288
288
  continue;
289
289
  }
290
290
  for (const val of toArray(value)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.88.4",
3
+ "version": "0.88.6",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -120,7 +120,7 @@
120
120
  "./utils/string": "./utils/object/index.js"
121
121
  },
122
122
  "dependencies": {
123
- "disposablestack": "^1.1.1",
123
+ "disposablestack": "^1.1",
124
124
  "luxon": "^3.4",
125
125
  "reflect-metadata": "^0.1",
126
126
  "rxjs": "^7.8",
@@ -159,9 +159,9 @@
159
159
  "koa": "^2.14",
160
160
  "minio": "^7.1",
161
161
  "mjml": "^4.14",
162
- "mongodb": "^5.8",
162
+ "mongodb": "^6.1",
163
163
  "nodemailer": "^6.9",
164
- "playwright": "^1.37",
164
+ "playwright": "^1.38",
165
165
  "preact": "^10.17",
166
166
  "preact-render-to-string": "^6.2",
167
167
  "undici": "^5.24",
package/utils/merge.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-return */
2
- import { assertArray, assertMap, assertObject, assertSet, isArray, isMap, isObject, isSet, isUndefined } from './type-guards.js';
2
+ import { assertArray, assertLiteralObject, assertMap, assertSet, isArray, isLiteralObject, isMap, isSet, isUndefined } from './type-guards.js';
3
3
  export function merge(a, b) {
4
4
  if (isUndefined(a)) {
5
5
  return b;
@@ -7,8 +7,8 @@ export function merge(a, b) {
7
7
  if (isUndefined(b)) {
8
8
  return a;
9
9
  }
10
- if (isObject(a)) {
11
- assertObject(b, 'Cannot merge object into non-object.');
10
+ if (isLiteralObject(a)) {
11
+ assertLiteralObject(b, 'Cannot merge object into non-object.');
12
12
  return { ...a, ...b };
13
13
  }
14
14
  else if (isArray(a)) {
@@ -78,6 +78,12 @@ export declare const assertSymbol: AssertFunction<symbol>;
78
78
  export declare const assertNotSymbol: AssertNotFunction<symbol>;
79
79
  export declare const assertSymbolPass: AssertPassFunction<symbol>;
80
80
  export declare const assertNotSymbolPass: AssertNotPassFunction<symbol>;
81
+ export declare const isLiteralObject: IsFunction<object>;
82
+ export declare const isNotLiteralObject: IsNotFunction<object>;
83
+ export declare const assertLiteralObject: AssertFunction<object>;
84
+ export declare const assertNotLiteralObject: AssertNotFunction<object>;
85
+ export declare const assertLiteralObjectPass: AssertPassFunction<object>;
86
+ export declare const assertNotLiteralObjectPass: AssertNotPassFunction<object>;
81
87
  export declare const isObject: IsFunction<object>;
82
88
  export declare const isNotObject: IsNotFunction<object>;
83
89
  export declare const assertObject: AssertFunction<object>;
@@ -104,7 +104,14 @@ export const assertSymbol = symbolGuards.assertSymbol;
104
104
  export const assertNotSymbol = symbolGuards.assertNotSymbol;
105
105
  export const assertSymbolPass = symbolGuards.assertSymbolPass;
106
106
  export const assertNotSymbolPass = symbolGuards.assertNotSymbolPass;
107
- const objectGuards = createGuards('object', (value) => (typeof value == 'object') && (value != null) && (Reflect.getPrototypeOf(value) == Object.prototype) && (Reflect.getPrototypeOf(value).constructor == Object));
107
+ const literalObjectGuards = createGuards('literal object', (value) => (typeof value == 'object') && (value != null) && (Reflect.getPrototypeOf(value) == Object.prototype) && (Reflect.getPrototypeOf(value).constructor == Object));
108
+ export const isLiteralObject = literalObjectGuards.isLiteralObject;
109
+ export const isNotLiteralObject = literalObjectGuards.isNotLiteralObject;
110
+ export const assertLiteralObject = literalObjectGuards.assertLiteralObject;
111
+ export const assertNotLiteralObject = literalObjectGuards.assertNotLiteralObject;
112
+ export const assertLiteralObjectPass = literalObjectGuards.assertLiteralObjectPass;
113
+ export const assertNotLiteralObjectPass = literalObjectGuards.assertNotLiteralObjectPass;
114
+ const objectGuards = createGuards('object', (value) => (typeof value == 'object') && (value != null));
108
115
  export const isObject = objectGuards.isObject;
109
116
  export const isNotObject = objectGuards.isNotObject;
110
117
  export const assertObject = objectGuards.assertObject;