@lenne.tech/nest-server 8.6.19 → 8.6.20

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nest-server",
3
- "version": "8.6.19",
3
+ "version": "8.6.20",
4
4
  "description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
5
5
  "keywords": [
6
6
  "node",
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Wait a certain number of milliseconds
3
+ */
4
+ export function sleep(ms: number) {
5
+ return new Promise<void>((resolve) => {
6
+ setTimeout(() => {
7
+ resolve();
8
+ }, ms);
9
+ });
10
+ }
11
+
12
+ /**
13
+ * Wait a certain number of milliseconds
14
+ * Alias of sleep
15
+ */
16
+ export function wait(ms: number) {
17
+ return sleep(ms);
18
+ }
@@ -175,9 +175,10 @@ export function mapClasses<T = Record<string, any>>(
175
175
  }
176
176
 
177
177
  // Process input
178
- for (const [prop, value] of Object.entries(input)) {
179
- if (prop in mapping) {
180
- const targetClass = mapping[prop] as any;
178
+ for (const [prop, mapTarget] of Object.entries(mapping)) {
179
+ if (prop in input) {
180
+ const targetClass = mapTarget as any;
181
+ const value = input[prop];
181
182
 
182
183
  // Process array
183
184
  if (Array.isArray(value)) {
@@ -250,9 +251,10 @@ export async function mapClassesAsync<T = Record<string, any>>(
250
251
  }
251
252
 
252
253
  // Process input
253
- for (const [prop, value] of Object.entries(input)) {
254
- if (prop in mapping) {
255
- const targetClass = mapping[prop] as any;
254
+ for (const [prop, mapTarget] of Object.entries(mapping)) {
255
+ if (prop in input) {
256
+ const targetClass = mapTarget as any;
257
+ const value = input[prop];
256
258
 
257
259
  // Process array
258
260
  if (Array.isArray(value)) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Type for plain Inputs
2
+ * Type for plain inputs with only optional properties
3
3
  */
4
4
  export type PlainInput<T> = {
5
5
  [P in keyof T]?: Partial<T[P]> | Partial<PlainInput<T[P]>>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Type for plain object with only properties and no methods
3
+ */
4
+ export type RemoveMethods<T> = { [P in keyof T as T[P] extends (...args: any) => any ? never : P]: T[P] };
@@ -1,3 +1,6 @@
1
1
  import { Types } from 'mongoose';
2
2
 
3
- export type StringOrObjectId = string | Types.ObjectId | any;
3
+ /**
4
+ * Everything which will be used by getStringIds or getObjectIds (see helpers/db.helper.ts)
5
+ */
6
+ export type StringOrObjectId<T = any> = string | Types.ObjectId | T;
@@ -1,5 +1,5 @@
1
1
  import { NotFoundException } from '@nestjs/common';
2
- import { GridFSBucket, GridFSBucketReadStreamOptions } from 'mongodb';
2
+ import { GridFSBucket, GridFSBucketReadStream, GridFSBucketReadStreamOptions } from 'mongodb';
3
3
  import { Connection, Types } from 'mongoose';
4
4
  import { createBucket, MongoGridFSOptions, MongooseGridFS } from 'mongoose-gridfs';
5
5
  import { FilterArgs } from '../../common/args/filter.args';
@@ -115,7 +115,7 @@ export abstract class CoreFileService {
115
115
  if (!(await this.checkRights(id, { ...serviceOptions, checkInputType: 'id' }))) {
116
116
  return null;
117
117
  }
118
- return this.files.openDownloadStream(getObjectIds(id));
118
+ return this.files.openDownloadStream(getObjectIds(id)) as GridFSBucketReadStream;
119
119
  }
120
120
 
121
121
  /**
@@ -3,5 +3,6 @@
3
3
  */
4
4
  export interface FileServiceOptions {
5
5
  currentUser?: { id: any; hasRole: (roles: string[]) => boolean };
6
+ force?: boolean;
6
7
  roles?: string | string[];
7
8
  }
package/src/index.ts CHANGED
@@ -18,6 +18,7 @@ export * from './core/common/enums/logical-operator.enum';
18
18
  export * from './core/common/enums/process-type.enum';
19
19
  export * from './core/common/enums/role.enum';
20
20
  export * from './core/common/enums/sort-order.emum';
21
+ export * from './core/common/helpers/common.helper';
21
22
  export * from './core/common/helpers/config.helper';
22
23
  export * from './core/common/helpers/context.helper';
23
24
  export * from './core/common/helpers/db.helper';
@@ -61,6 +62,7 @@ export * from './core/common/types/field-selection.type';
61
62
  export * from './core/common/types/ids.type';
62
63
  export * from './core/common/types/maybe-promise.type';
63
64
  export * from './core/common/types/plain-input.type';
65
+ export * from './core/common/types/remove-methods.type';
64
66
  export * from './core/common/types/require-only-one.type';
65
67
  export * from './core/common/types/required-at-least-one.type';
66
68
  export * from './core/common/types/string-or-object-id.type';