@augment-vir/node 30.0.4 → 30.1.0

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,4 +1,4 @@
1
- import type { MaybePromise } from '@augment-vir/common';
1
+ import { type MaybePromise } from '@augment-vir/common';
2
2
  export declare function findAncestor(currentPath: string, callback: (path: string) => Promise<boolean>): Promise<string | undefined>;
3
3
  export declare function findAncestor(currentPath: string, callback: (path: string) => boolean): string | undefined;
4
4
  export declare function findAncestor(currentPath: string, callback: (path: string) => MaybePromise<boolean>): MaybePromise<string | undefined>;
@@ -1,5 +1,5 @@
1
1
  import { type Logger } from '@augment-vir/common';
2
- import type { MaybePromise, PartialWithUndefined } from '@augment-vir/core';
2
+ import { type MaybePromise, PartialWithUndefined } from '@augment-vir/core';
3
3
  import { ChildProcess } from 'node:child_process';
4
4
  import { ListenTarget } from 'typed-event-target';
5
5
  /**
@@ -1,4 +1,4 @@
1
- import type { MaybePromise } from '@augment-vir/core';
1
+ import { type MaybePromise } from '@augment-vir/core';
2
2
  /**
3
3
  * Runs a callback (which presumably runs a command within the given `containerName`) and kills the
4
4
  * given `containerName` container if the callback fails.
@@ -1,2 +1,2 @@
1
- import type { MaybePromise } from '@augment-vir/common';
1
+ import { type MaybePromise } from '@augment-vir/common';
2
2
  export declare function dockerTest(callback: () => MaybePromise<void>): () => MaybePromise<void>;
@@ -37,9 +37,13 @@ async function addModelDataObject(prismaClient, data) {
37
37
  }
38
38
  });
39
39
  }
40
+ const prismockKeys = [
41
+ 'getData',
42
+ 'setData',
43
+ ];
40
44
  export function getAllPrismaModelNames(prismaClient) {
41
45
  return Object.keys(prismaClient)
42
- .filter((key) => !key.startsWith('$') && !key.startsWith('_'))
46
+ .filter((key) => !key.startsWith('$') && !key.startsWith('_') && !prismockKeys.includes(key))
43
47
  .sort();
44
48
  }
45
49
  const defaultPrismaDumpDataOptions = {
@@ -50,21 +54,26 @@ export async function dumpData(prismaClient, options = {}) {
50
54
  const modelNames = getAllPrismaModelNames(prismaClient);
51
55
  const finalOptions = mergeDefinedProperties(defaultPrismaDumpDataOptions, options);
52
56
  const data = await arrayToObject(modelNames, async (modelName) => {
53
- const entries = await prismaClient[modelName].findMany(finalOptions.limit > 0
54
- ? {
55
- take: finalOptions.limit,
57
+ try {
58
+ const entries = await prismaClient[modelName].findMany(finalOptions.limit > 0
59
+ ? {
60
+ take: finalOptions.limit,
61
+ }
62
+ : {});
63
+ if (!entries.length) {
64
+ return undefined;
56
65
  }
57
- : {});
58
- if (!entries.length) {
59
- return undefined;
66
+ const filteredEntries = finalOptions.omitFields.length
67
+ ? entries.map((entry) => omitObjectKeys(entry, finalOptions.omitFields))
68
+ : entries;
69
+ return {
70
+ key: modelName,
71
+ value: filteredEntries,
72
+ };
73
+ }
74
+ catch (error) {
75
+ throw ensureErrorAndPrependMessage(error, `Failed to read data for model '${modelName}'`);
60
76
  }
61
- const filteredEntries = finalOptions.omitFields.length
62
- ? entries.map((entry) => omitObjectKeys(entry, finalOptions.omitFields))
63
- : entries;
64
- return {
65
- key: modelName,
66
- value: filteredEntries,
67
- };
68
77
  });
69
78
  return data;
70
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/node",
3
- "version": "30.0.4",
3
+ "version": "30.1.0",
4
4
  "description": "A collection of augments, helpers types, functions, and classes only for Node.js (backend) JavaScript environments.",
5
5
  "keywords": [
6
6
  "augment",
@@ -37,8 +37,8 @@
37
37
  "test:update": "npm test"
38
38
  },
39
39
  "dependencies": {
40
- "@augment-vir/assert": "^30.0.4",
41
- "@augment-vir/common": "^30.0.4",
40
+ "@augment-vir/assert": "^30.1.0",
41
+ "@augment-vir/common": "^30.1.0",
42
42
  "@date-vir/duration": "^6.0.0",
43
43
  "ansi-styles": "^6.2.1",
44
44
  "terminate": "^2.8.0",
@@ -46,7 +46,7 @@
46
46
  "typed-event-target": "^3.4.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@augment-vir/test": "^30.0.4",
49
+ "@augment-vir/test": "^30.1.0",
50
50
  "@prisma/client": "^5.19.1",
51
51
  "@types/node": "^22.5.5",
52
52
  "@web/dev-server-esbuild": "^1.0.2",