@augment-vir/node 30.0.5 → 30.2.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,5 +1,5 @@
|
|
|
1
1
|
import { log } from '@augment-vir/common';
|
|
2
|
-
import { convertDuration
|
|
2
|
+
import { convertDuration } from '@date-vir/duration';
|
|
3
3
|
import { createInterface } from 'node:readline';
|
|
4
4
|
const defaultAskQuestionOptions = {
|
|
5
5
|
timeout: { seconds: 60 },
|
|
@@ -37,7 +37,7 @@ export async function askQuestion(questionToAsk, { hideUserInput = defaultAskQue
|
|
|
37
37
|
process.kill(process.pid, 'SIGINT');
|
|
38
38
|
});
|
|
39
39
|
return new Promise((resolve, reject) => {
|
|
40
|
-
const timeoutMs = convertDuration(timeout,
|
|
40
|
+
const timeoutMs = convertDuration(timeout, { milliseconds: true }).milliseconds;
|
|
41
41
|
const timeoutId = timeoutMs
|
|
42
42
|
? setTimeout(() => {
|
|
43
43
|
cliInterface.close();
|
|
@@ -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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
59
|
-
|
|
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
|
|
3
|
+
"version": "30.2.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,18 +37,18 @@
|
|
|
37
37
|
"test:update": "npm test"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@augment-vir/assert": "^30.0
|
|
41
|
-
"@augment-vir/common": "^30.0
|
|
42
|
-
"@date-vir/duration": "^6.0.
|
|
40
|
+
"@augment-vir/assert": "^30.2.0",
|
|
41
|
+
"@augment-vir/common": "^30.2.0",
|
|
42
|
+
"@date-vir/duration": "^6.0.1",
|
|
43
43
|
"ansi-styles": "^6.2.1",
|
|
44
44
|
"terminate": "^2.8.0",
|
|
45
45
|
"type-fest": "^4.26.1",
|
|
46
46
|
"typed-event-target": "^3.4.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@augment-vir/test": "^30.0
|
|
50
|
-
"@prisma/client": "^5.
|
|
51
|
-
"@types/node": "^22.
|
|
49
|
+
"@augment-vir/test": "^30.2.0",
|
|
50
|
+
"@prisma/client": "^5.20.0",
|
|
51
|
+
"@types/node": "^22.7.4",
|
|
52
52
|
"@web/dev-server-esbuild": "^1.0.2",
|
|
53
53
|
"@web/test-runner": "^0.19.0",
|
|
54
54
|
"@web/test-runner-commands": "^0.9.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"c8": "^10.1.2",
|
|
58
58
|
"concurrently": "^9.0.1",
|
|
59
59
|
"istanbul-smart-text-reporter": "^1.1.4",
|
|
60
|
-
"prisma": "^5.
|
|
60
|
+
"prisma": "^5.20.0"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=22"
|