@augment-vir/node 31.41.0 → 31.42.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.
- package/dist/augments/terminal/shell.js +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +6 -6
- package/src/augments/terminal/shell.ts +1 -0
- package/src/index.ts +0 -1
- package/dist/augments/prisma.d.ts +0 -157
- package/dist/augments/prisma.js +0 -156
- package/dist/prisma/disable-ci-env.mock.d.ts +0 -2
- package/dist/prisma/disable-ci-env.mock.js +0 -81
- package/dist/prisma/model-data.d.ts +0 -88
- package/dist/prisma/model-data.js +0 -84
- package/dist/prisma/prisma-client.d.ts +0 -5
- package/dist/prisma/prisma-client.js +0 -25
- package/dist/prisma/prisma-database.d.ts +0 -11
- package/dist/prisma/prisma-database.js +0 -30
- package/dist/prisma/prisma-database.mock.d.ts +0 -1
- package/dist/prisma/prisma-database.mock.js +0 -25
- package/dist/prisma/prisma-errors.d.ts +0 -37
- package/dist/prisma/prisma-errors.js +0 -43
- package/dist/prisma/prisma-migrations.d.ts +0 -24
- package/dist/prisma/prisma-migrations.js +0 -98
- package/dist/prisma/run-prisma-command.d.ts +0 -29
- package/dist/prisma/run-prisma-command.js +0 -67
- package/src/augments/prisma.ts +0 -177
- package/src/prisma/disable-ci-env.mock.ts +0 -88
- package/src/prisma/model-data.ts +0 -252
- package/src/prisma/prisma-client.ts +0 -45
- package/src/prisma/prisma-database.mock.ts +0 -31
- package/src/prisma/prisma-database.ts +0 -60
- package/src/prisma/prisma-errors.ts +0 -45
- package/src/prisma/prisma-migrations.ts +0 -153
- package/src/prisma/run-prisma-command.ts +0 -94
|
@@ -102,6 +102,7 @@ export function streamShellCommand(command, cwd, shell = 'bash', env = process.e
|
|
|
102
102
|
if (exitCode != undefined) {
|
|
103
103
|
execException.code = exitCode;
|
|
104
104
|
}
|
|
105
|
+
/* node:coverage ignore next 3: idk how to get this to trigger */
|
|
105
106
|
if (exitSignal != undefined) {
|
|
106
107
|
execException.signal = exitSignal;
|
|
107
108
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ export * from './augments/path/os-path.js';
|
|
|
16
16
|
export * from './augments/path/resolve-import.js';
|
|
17
17
|
export * from './augments/path/root.js';
|
|
18
18
|
export * from './augments/path/sanitize-path.js';
|
|
19
|
-
export * from './augments/prisma.js';
|
|
20
19
|
export * from './augments/terminal/question.js';
|
|
21
20
|
export * from './augments/terminal/relevant-args.js';
|
|
22
21
|
export * from './augments/terminal/run-cli-script.js';
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,6 @@ export * from './augments/path/os-path.js';
|
|
|
16
16
|
export * from './augments/path/resolve-import.js';
|
|
17
17
|
export * from './augments/path/root.js';
|
|
18
18
|
export * from './augments/path/sanitize-path.js';
|
|
19
|
-
export * from './augments/prisma.js';
|
|
20
19
|
export * from './augments/terminal/question.js';
|
|
21
20
|
export * from './augments/terminal/relevant-args.js';
|
|
22
21
|
export * from './augments/terminal/run-cli-script.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@augment-vir/node",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.42.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",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"test:update": "npm test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@augment-vir/assert": "^31.
|
|
42
|
-
"@augment-vir/common": "^31.
|
|
43
|
-
"@date-vir/duration": "^
|
|
41
|
+
"@augment-vir/assert": "^31.42.0",
|
|
42
|
+
"@augment-vir/common": "^31.42.0",
|
|
43
|
+
"@date-vir/duration": "^8.0.0",
|
|
44
44
|
"ansi-styles": "^6.2.3",
|
|
45
45
|
"sanitize-filename": "^1.6.3",
|
|
46
46
|
"terminate": "^2.8.0",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"typed-event-target": "^4.1.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@augment-vir/test": "^31.
|
|
52
|
+
"@augment-vir/test": "^31.42.0",
|
|
53
53
|
"@prisma/client": "^6.17.1",
|
|
54
|
-
"@types/node": "^24.
|
|
54
|
+
"@types/node": "^24.9.1",
|
|
55
55
|
"@web/dev-server-esbuild": "^1.0.4",
|
|
56
56
|
"@web/test-runner": "^0.20.2",
|
|
57
57
|
"@web/test-runner-commands": "^0.9.0",
|
|
@@ -136,6 +136,7 @@ export function streamShellCommand(
|
|
|
136
136
|
if (exitCode != undefined) {
|
|
137
137
|
execException.code = exitCode;
|
|
138
138
|
}
|
|
139
|
+
/* node:coverage ignore next 3: idk how to get this to trigger */
|
|
139
140
|
if (exitSignal != undefined) {
|
|
140
141
|
execException.signal = exitSignal;
|
|
141
142
|
}
|
package/src/index.ts
CHANGED
|
@@ -16,7 +16,6 @@ export * from './augments/path/os-path.js';
|
|
|
16
16
|
export * from './augments/path/resolve-import.js';
|
|
17
17
|
export * from './augments/path/root.js';
|
|
18
18
|
export * from './augments/path/sanitize-path.js';
|
|
19
|
-
export * from './augments/prisma.js';
|
|
20
19
|
export * from './augments/terminal/question.js';
|
|
21
20
|
export * from './augments/terminal/relevant-args.js';
|
|
22
21
|
export * from './augments/terminal/run-cli-script.js';
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { addData, dumpData } from '../prisma/model-data.js';
|
|
2
|
-
import { generatePrismaClient, isGeneratedPrismaClientCurrent } from '../prisma/prisma-client.js';
|
|
3
|
-
import { doesPrismaDiffExist, getPrismaDiff, resetDevPrismaDatabase } from '../prisma/prisma-database.js';
|
|
4
|
-
import { applyPrismaMigrationsToDev, applyPrismaMigrationsToProd, createPrismaMigration, getMigrationStatus } from '../prisma/prisma-migrations.js';
|
|
5
|
-
export type { PrismaAddDataData as PrismaAddModelData, PrismaDataDumpOptions, PrismaDumpOutput, } from '../prisma/model-data.js';
|
|
6
|
-
export * from '../prisma/prisma-errors.js';
|
|
7
|
-
export type { PrismaMigrationStatus } from '../prisma/prisma-migrations.js';
|
|
8
|
-
export { prismaCommandsThatSupportNoHints, runPrismaCommand } from '../prisma/run-prisma-command.js';
|
|
9
|
-
/**
|
|
10
|
-
* Centralized Prisma API from `@augment-vir/node`.
|
|
11
|
-
*
|
|
12
|
-
* ## Prisma flows
|
|
13
|
-
*
|
|
14
|
-
* - Deploy to production
|
|
15
|
-
*
|
|
16
|
-
* - `prisma.migration.applyProd()`
|
|
17
|
-
* - Update dev environment
|
|
18
|
-
*
|
|
19
|
-
* - Apply migrations: `prisma.migration.applyDev`
|
|
20
|
-
*
|
|
21
|
-
* - If throws {@link PrismaMigrationNeededError}, prompt user for a new migration name and pass it to
|
|
22
|
-
* `prisma.migration.create`
|
|
23
|
-
* - If throws {@link PrismaResetNeededError}, reset the database with `prisma.database.resetDev`
|
|
24
|
-
* - Generate client: `prisma.client.isCurrent`
|
|
25
|
-
*
|
|
26
|
-
* - If `false`, run `prisma.client.generate`
|
|
27
|
-
*
|
|
28
|
-
* @deprecated Use the `prisma-vir` package instead.
|
|
29
|
-
* @category Prisma : Node
|
|
30
|
-
* @category Package : @augment-vir/node
|
|
31
|
-
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
32
|
-
*/
|
|
33
|
-
export declare const prisma: {
|
|
34
|
-
migration: {
|
|
35
|
-
/**
|
|
36
|
-
* Get current migration status.
|
|
37
|
-
*
|
|
38
|
-
* @see https://www.prisma.io/docs/orm/reference/prisma-cli-reference#migrate-status
|
|
39
|
-
*/
|
|
40
|
-
status: typeof getMigrationStatus;
|
|
41
|
-
/**
|
|
42
|
-
* Creates a new migration.
|
|
43
|
-
*
|
|
44
|
-
* @see https://www.prisma.io/docs/orm/reference/prisma-cli-reference#migrate-dev
|
|
45
|
-
*/
|
|
46
|
-
create: typeof createPrismaMigration;
|
|
47
|
-
/**
|
|
48
|
-
* Apply all migrations. Meant for a production environment.
|
|
49
|
-
*
|
|
50
|
-
* @see https://www.prisma.io/docs/orm/reference/prisma-cli-reference#migrate-deploy
|
|
51
|
-
*/
|
|
52
|
-
applyProd: typeof applyPrismaMigrationsToProd;
|
|
53
|
-
/**
|
|
54
|
-
* Apply all migrations. Meant for a development environment, with less protections than
|
|
55
|
-
* `prisma.migration.applyProd()`
|
|
56
|
-
*
|
|
57
|
-
* @throws `PrismaMigrationNeededError` when a new migration is required so the user needs
|
|
58
|
-
* to input a name.
|
|
59
|
-
* @throws `PrismaResetNeededError` when there's a migration mismatch with the database and
|
|
60
|
-
* it needs to be reset.
|
|
61
|
-
* @see https://www.prisma.io/docs/orm/reference/prisma-cli-reference#migrate-dev
|
|
62
|
-
*/
|
|
63
|
-
applyDev: typeof applyPrismaMigrationsToDev;
|
|
64
|
-
};
|
|
65
|
-
database: {
|
|
66
|
-
/**
|
|
67
|
-
* Force resets a dev database to match the current Prisma schema and migrations.
|
|
68
|
-
*
|
|
69
|
-
* **This will destroy all data. Do not use in production.**
|
|
70
|
-
*
|
|
71
|
-
* @see https://www.prisma.io/docs/orm/reference/prisma-cli-reference#migrate-reset
|
|
72
|
-
*/
|
|
73
|
-
resetDev: typeof resetDevPrismaDatabase;
|
|
74
|
-
/**
|
|
75
|
-
* Uses `prisma.database.diff` to detect if there are any differences between the current
|
|
76
|
-
* database and the Prisma schema that should control it.
|
|
77
|
-
*/
|
|
78
|
-
hasDiff: typeof doesPrismaDiffExist;
|
|
79
|
-
/**
|
|
80
|
-
* Gets a string list of all differences between the current database and the Prisma schema
|
|
81
|
-
* that should control it.
|
|
82
|
-
*
|
|
83
|
-
* @see https://www.prisma.io/docs/orm/reference/prisma-cli-reference#migrate-diff
|
|
84
|
-
*/
|
|
85
|
-
diff: typeof getPrismaDiff;
|
|
86
|
-
};
|
|
87
|
-
client: {
|
|
88
|
-
/**
|
|
89
|
-
* Runs Prisma generators included in the given Prisma schema (which usually includes the
|
|
90
|
-
* Prisma JS client). This will work even if the database doesn't exist yet.
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
*
|
|
94
|
-
* ```ts
|
|
95
|
-
* import {prisma} from '@augment-vir/node';
|
|
96
|
-
*
|
|
97
|
-
* prisma.client.generate('../../prisma/schema.prisma');
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
generate: typeof generatePrismaClient;
|
|
101
|
-
/**
|
|
102
|
-
* Detects if the current generated Prisma JS Client was generated from the current Prisma
|
|
103
|
-
* schema.
|
|
104
|
-
*/
|
|
105
|
-
isCurrent: typeof isGeneratedPrismaClientCurrent;
|
|
106
|
-
/**
|
|
107
|
-
* Adds a collection of create data entries to a database through a `PrismaClient` instance.
|
|
108
|
-
* This is particularly useful for setting up mocks in a mock PrismaClient.
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
*
|
|
112
|
-
* ```ts
|
|
113
|
-
* import {addPrismaModelData} from '@augment-vir/common';
|
|
114
|
-
* import {PrismaClient} from '@prisma/client';
|
|
115
|
-
*
|
|
116
|
-
* await addPrismaModelData(new PrismaClient(), [
|
|
117
|
-
* {
|
|
118
|
-
* user: {
|
|
119
|
-
* mockUser1: {
|
|
120
|
-
* first_name: 'one',
|
|
121
|
-
* id: 123,
|
|
122
|
-
* // etc.
|
|
123
|
-
* },
|
|
124
|
-
* mockUser2: {
|
|
125
|
-
* first_name: 'two',
|
|
126
|
-
* id: 124,
|
|
127
|
-
* authRole: 'user',
|
|
128
|
-
* // etc.
|
|
129
|
-
* },
|
|
130
|
-
* },
|
|
131
|
-
* },
|
|
132
|
-
* {
|
|
133
|
-
* region: [
|
|
134
|
-
* {
|
|
135
|
-
* id: 1,
|
|
136
|
-
* name: 'North America',
|
|
137
|
-
* // etc.
|
|
138
|
-
* },
|
|
139
|
-
* {
|
|
140
|
-
* id: 2,
|
|
141
|
-
* name: 'Europe',
|
|
142
|
-
* // etc.
|
|
143
|
-
* },
|
|
144
|
-
* ],
|
|
145
|
-
* },
|
|
146
|
-
* ]);
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
addData: typeof addData;
|
|
150
|
-
/**
|
|
151
|
-
* Dump data from the current database through a `PrismaClient` instance.
|
|
152
|
-
*
|
|
153
|
-
* @see {@link PrismaDataDumpOptions}
|
|
154
|
-
*/
|
|
155
|
-
dumpData: typeof dumpData;
|
|
156
|
-
};
|
|
157
|
-
};
|
package/dist/augments/prisma.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
2
|
-
import { addData, dumpData } from '../prisma/model-data.js';
|
|
3
|
-
import { generatePrismaClient, isGeneratedPrismaClientCurrent } from '../prisma/prisma-client.js';
|
|
4
|
-
import { doesPrismaDiffExist, getPrismaDiff, resetDevPrismaDatabase, } from '../prisma/prisma-database.js';
|
|
5
|
-
import { applyPrismaMigrationsToDev, applyPrismaMigrationsToProd, createPrismaMigration, getMigrationStatus, } from '../prisma/prisma-migrations.js';
|
|
6
|
-
export * from '../prisma/prisma-errors.js';
|
|
7
|
-
export { prismaCommandsThatSupportNoHints, runPrismaCommand } from '../prisma/run-prisma-command.js';
|
|
8
|
-
/**
|
|
9
|
-
* Centralized Prisma API from `@augment-vir/node`.
|
|
10
|
-
*
|
|
11
|
-
* ## Prisma flows
|
|
12
|
-
*
|
|
13
|
-
* - Deploy to production
|
|
14
|
-
*
|
|
15
|
-
* - `prisma.migration.applyProd()`
|
|
16
|
-
* - Update dev environment
|
|
17
|
-
*
|
|
18
|
-
* - Apply migrations: `prisma.migration.applyDev`
|
|
19
|
-
*
|
|
20
|
-
* - If throws {@link PrismaMigrationNeededError}, prompt user for a new migration name and pass it to
|
|
21
|
-
* `prisma.migration.create`
|
|
22
|
-
* - If throws {@link PrismaResetNeededError}, reset the database with `prisma.database.resetDev`
|
|
23
|
-
* - Generate client: `prisma.client.isCurrent`
|
|
24
|
-
*
|
|
25
|
-
* - If `false`, run `prisma.client.generate`
|
|
26
|
-
*
|
|
27
|
-
* @deprecated Use the `prisma-vir` package instead.
|
|
28
|
-
* @category Prisma : Node
|
|
29
|
-
* @category Package : @augment-vir/node
|
|
30
|
-
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
31
|
-
*/
|
|
32
|
-
export const prisma = {
|
|
33
|
-
migration: {
|
|
34
|
-
/**
|
|
35
|
-
* Get current migration status.
|
|
36
|
-
*
|
|
37
|
-
* @see https://www.prisma.io/docs/orm/reference/prisma-cli-reference#migrate-status
|
|
38
|
-
*/
|
|
39
|
-
status: getMigrationStatus,
|
|
40
|
-
/**
|
|
41
|
-
* Creates a new migration.
|
|
42
|
-
*
|
|
43
|
-
* @see https://www.prisma.io/docs/orm/reference/prisma-cli-reference#migrate-dev
|
|
44
|
-
*/
|
|
45
|
-
create: createPrismaMigration,
|
|
46
|
-
/**
|
|
47
|
-
* Apply all migrations. Meant for a production environment.
|
|
48
|
-
*
|
|
49
|
-
* @see https://www.prisma.io/docs/orm/reference/prisma-cli-reference#migrate-deploy
|
|
50
|
-
*/
|
|
51
|
-
applyProd: applyPrismaMigrationsToProd,
|
|
52
|
-
/**
|
|
53
|
-
* Apply all migrations. Meant for a development environment, with less protections than
|
|
54
|
-
* `prisma.migration.applyProd()`
|
|
55
|
-
*
|
|
56
|
-
* @throws `PrismaMigrationNeededError` when a new migration is required so the user needs
|
|
57
|
-
* to input a name.
|
|
58
|
-
* @throws `PrismaResetNeededError` when there's a migration mismatch with the database and
|
|
59
|
-
* it needs to be reset.
|
|
60
|
-
* @see https://www.prisma.io/docs/orm/reference/prisma-cli-reference#migrate-dev
|
|
61
|
-
*/
|
|
62
|
-
applyDev: applyPrismaMigrationsToDev,
|
|
63
|
-
},
|
|
64
|
-
database: {
|
|
65
|
-
/**
|
|
66
|
-
* Force resets a dev database to match the current Prisma schema and migrations.
|
|
67
|
-
*
|
|
68
|
-
* **This will destroy all data. Do not use in production.**
|
|
69
|
-
*
|
|
70
|
-
* @see https://www.prisma.io/docs/orm/reference/prisma-cli-reference#migrate-reset
|
|
71
|
-
*/
|
|
72
|
-
resetDev: resetDevPrismaDatabase,
|
|
73
|
-
/**
|
|
74
|
-
* Uses `prisma.database.diff` to detect if there are any differences between the current
|
|
75
|
-
* database and the Prisma schema that should control it.
|
|
76
|
-
*/
|
|
77
|
-
hasDiff: doesPrismaDiffExist,
|
|
78
|
-
/**
|
|
79
|
-
* Gets a string list of all differences between the current database and the Prisma schema
|
|
80
|
-
* that should control it.
|
|
81
|
-
*
|
|
82
|
-
* @see https://www.prisma.io/docs/orm/reference/prisma-cli-reference#migrate-diff
|
|
83
|
-
*/
|
|
84
|
-
diff: getPrismaDiff,
|
|
85
|
-
},
|
|
86
|
-
client: {
|
|
87
|
-
/**
|
|
88
|
-
* Runs Prisma generators included in the given Prisma schema (which usually includes the
|
|
89
|
-
* Prisma JS client). This will work even if the database doesn't exist yet.
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
*
|
|
93
|
-
* ```ts
|
|
94
|
-
* import {prisma} from '@augment-vir/node';
|
|
95
|
-
*
|
|
96
|
-
* prisma.client.generate('../../prisma/schema.prisma');
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
generate: generatePrismaClient,
|
|
100
|
-
/**
|
|
101
|
-
* Detects if the current generated Prisma JS Client was generated from the current Prisma
|
|
102
|
-
* schema.
|
|
103
|
-
*/
|
|
104
|
-
isCurrent: isGeneratedPrismaClientCurrent,
|
|
105
|
-
/**
|
|
106
|
-
* Adds a collection of create data entries to a database through a `PrismaClient` instance.
|
|
107
|
-
* This is particularly useful for setting up mocks in a mock PrismaClient.
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
*
|
|
111
|
-
* ```ts
|
|
112
|
-
* import {addPrismaModelData} from '@augment-vir/common';
|
|
113
|
-
* import {PrismaClient} from '@prisma/client';
|
|
114
|
-
*
|
|
115
|
-
* await addPrismaModelData(new PrismaClient(), [
|
|
116
|
-
* {
|
|
117
|
-
* user: {
|
|
118
|
-
* mockUser1: {
|
|
119
|
-
* first_name: 'one',
|
|
120
|
-
* id: 123,
|
|
121
|
-
* // etc.
|
|
122
|
-
* },
|
|
123
|
-
* mockUser2: {
|
|
124
|
-
* first_name: 'two',
|
|
125
|
-
* id: 124,
|
|
126
|
-
* authRole: 'user',
|
|
127
|
-
* // etc.
|
|
128
|
-
* },
|
|
129
|
-
* },
|
|
130
|
-
* },
|
|
131
|
-
* {
|
|
132
|
-
* region: [
|
|
133
|
-
* {
|
|
134
|
-
* id: 1,
|
|
135
|
-
* name: 'North America',
|
|
136
|
-
* // etc.
|
|
137
|
-
* },
|
|
138
|
-
* {
|
|
139
|
-
* id: 2,
|
|
140
|
-
* name: 'Europe',
|
|
141
|
-
* // etc.
|
|
142
|
-
* },
|
|
143
|
-
* ],
|
|
144
|
-
* },
|
|
145
|
-
* ]);
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
addData,
|
|
149
|
-
/**
|
|
150
|
-
* Dump data from the current database through a `PrismaClient` instance.
|
|
151
|
-
*
|
|
152
|
-
* @see {@link PrismaDataDumpOptions}
|
|
153
|
-
*/
|
|
154
|
-
dumpData,
|
|
155
|
-
},
|
|
156
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// cspell:disable
|
|
2
|
-
import { arrayToObject } from '@augment-vir/common';
|
|
3
|
-
/**
|
|
4
|
-
* These are all the env flags that Prisma reads for determining if it's being executed within a CI
|
|
5
|
-
* environment. This list was retrieved from
|
|
6
|
-
* https://github.com/prisma/prisma/blob/075d31287c90b757fd9bd8d9b36032e6349fa671/packages/internals/src/utils/isCi.ts.
|
|
7
|
-
*/
|
|
8
|
-
const prismaCiFlags = [
|
|
9
|
-
'CI',
|
|
10
|
-
'CONTINUOUS_INTEGRATION',
|
|
11
|
-
'BUILD_NUMBER',
|
|
12
|
-
'RUN_ID',
|
|
13
|
-
'AGOLA_GIT_REF',
|
|
14
|
-
'AC_APPCIRCLE',
|
|
15
|
-
'APPVEYOR',
|
|
16
|
-
'CODEBUILD',
|
|
17
|
-
'TF_BUILD',
|
|
18
|
-
'bamboo_planKey',
|
|
19
|
-
'BITBUCKET_COMMIT',
|
|
20
|
-
'BITRISE_IO',
|
|
21
|
-
'BUDDY_WORKSPACE_ID',
|
|
22
|
-
'BUILDKITE',
|
|
23
|
-
'CIRCLECI',
|
|
24
|
-
'CIRRUS_CI',
|
|
25
|
-
'CF_BUILD_ID',
|
|
26
|
-
'CM_BUILD_ID',
|
|
27
|
-
'CI_NAME',
|
|
28
|
-
'DRONE',
|
|
29
|
-
'DSARI',
|
|
30
|
-
'EARTHLY_CI',
|
|
31
|
-
'EAS_BUILD',
|
|
32
|
-
'GERRIT_PROJECT',
|
|
33
|
-
'GITEA_ACTIONS',
|
|
34
|
-
'GITHUB_ACTIONS',
|
|
35
|
-
'GITLAB_CI',
|
|
36
|
-
'GOCD',
|
|
37
|
-
'BUILDER_OUTPUT',
|
|
38
|
-
'HARNESS_BUILD_ID',
|
|
39
|
-
'JENKINS_URL',
|
|
40
|
-
'BUILD_ID',
|
|
41
|
-
'LAYERCI',
|
|
42
|
-
'MAGNUM',
|
|
43
|
-
'NETLIFY',
|
|
44
|
-
'NEVERCODE',
|
|
45
|
-
'PROW_JOB_ID',
|
|
46
|
-
'RELEASE_BUILD_ID',
|
|
47
|
-
'RENDER',
|
|
48
|
-
'SAILCI',
|
|
49
|
-
'HUDSON',
|
|
50
|
-
'JENKINS_URL',
|
|
51
|
-
'BUILD_ID',
|
|
52
|
-
'SCREWDRIVER',
|
|
53
|
-
'SEMAPHORE',
|
|
54
|
-
'SOURCEHUT',
|
|
55
|
-
'STRIDER',
|
|
56
|
-
'TASK_ID',
|
|
57
|
-
'RUN_ID',
|
|
58
|
-
'TEAMCITY_VERSION',
|
|
59
|
-
'TRAVIS',
|
|
60
|
-
'VELA',
|
|
61
|
-
'NOW_BUILDER',
|
|
62
|
-
'APPCENTER_BUILD_ID',
|
|
63
|
-
'CI_XCODE_PROJECT',
|
|
64
|
-
'XCS',
|
|
65
|
-
];
|
|
66
|
-
export function testWithNonCiEnv(callback) {
|
|
67
|
-
return async () => {
|
|
68
|
-
const usedKeys = prismaCiFlags.filter((ciFlag) => ciFlag in process.env);
|
|
69
|
-
/** For already non-CI environments. */
|
|
70
|
-
/* node:coverage ignore next 6 */
|
|
71
|
-
const originalEnvValues = arrayToObject(usedKeys, (key) => {
|
|
72
|
-
return {
|
|
73
|
-
key,
|
|
74
|
-
value: process.env[key],
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
usedKeys.forEach((key) => delete process.env[key]);
|
|
78
|
-
await callback();
|
|
79
|
-
usedKeys.forEach((key) => (process.env[key] = originalEnvValues[key]));
|
|
80
|
-
};
|
|
81
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { type BasePrismaClient, type BaseTypeMap, type FirstLetterLowercase, type PartialWithUndefined, type PrismaAllModelsCreate, type PrismaBasicModel, type PrismaModelName } from '@augment-vir/common';
|
|
2
|
-
import { type IsAny } from 'type-fest';
|
|
3
|
-
/**
|
|
4
|
-
* Params for `prisma.client.addData()`. This is similar to {@link PrismaAllModelsCreate} but allows
|
|
5
|
-
* an array of {@link PrismaAllModelsCreate} for sequential data creation.
|
|
6
|
-
*
|
|
7
|
-
* @deprecated Use the `prisma-vir` package instead.
|
|
8
|
-
* @category Prisma : Node
|
|
9
|
-
* @category Package : @augment-vir/node
|
|
10
|
-
* @example
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* import {PrismaAddModelData} from '@augment-vir/common';
|
|
14
|
-
* import {type PrismaClient} from '@prisma/client';
|
|
15
|
-
*
|
|
16
|
-
* const mockData: PrismaAddModelData<PrismaClient> = [
|
|
17
|
-
* {
|
|
18
|
-
* user: {
|
|
19
|
-
* mockUser1: {
|
|
20
|
-
* first_name: 'one',
|
|
21
|
-
* id: 123,
|
|
22
|
-
* // etc.
|
|
23
|
-
* },
|
|
24
|
-
* mockUser2: {
|
|
25
|
-
* first_name: 'two',
|
|
26
|
-
* id: 124,
|
|
27
|
-
* authRole: 'user',
|
|
28
|
-
* // etc.
|
|
29
|
-
* },
|
|
30
|
-
* },
|
|
31
|
-
* },
|
|
32
|
-
* {
|
|
33
|
-
* region: [
|
|
34
|
-
* {
|
|
35
|
-
* id: 1,
|
|
36
|
-
* name: 'North America',
|
|
37
|
-
* // etc.
|
|
38
|
-
* },
|
|
39
|
-
* {
|
|
40
|
-
* id: 2,
|
|
41
|
-
* name: 'Europe',
|
|
42
|
-
* // etc.
|
|
43
|
-
* },
|
|
44
|
-
* ],
|
|
45
|
-
* },
|
|
46
|
-
* ];
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
50
|
-
*/
|
|
51
|
-
export type PrismaAddDataData<PrismaClient extends BasePrismaClient, TypeMap extends BaseTypeMap> = Readonly<PrismaAllModelsCreate<PrismaClient, TypeMap>> | ReadonlyArray<Readonly<PrismaAllModelsCreate<PrismaClient, TypeMap>>>;
|
|
52
|
-
export declare function addData<const PrismaClient extends BasePrismaClient, const TypeMap extends BaseTypeMap>(prismaClient: Readonly<PrismaClient>, data: IsAny<PrismaClient> extends true ? any : PrismaAddDataData<PrismaClient, TypeMap>): Promise<void>;
|
|
53
|
-
/** These are not the real model names, they are the names on the PrismaClient (which are lowercase). */
|
|
54
|
-
export declare function getAllPrismaModelKeys(prismaClient: BasePrismaClient): string[];
|
|
55
|
-
/**
|
|
56
|
-
* Options for `prisma.client.dumpData`.
|
|
57
|
-
*
|
|
58
|
-
* @deprecated Use the `prisma-vir` package instead.
|
|
59
|
-
* @category Prisma : Node
|
|
60
|
-
* @category Package : @augment-vir/node
|
|
61
|
-
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
62
|
-
*/
|
|
63
|
-
export type PrismaDataDumpOptions = {
|
|
64
|
-
/**
|
|
65
|
-
* The max number of entries to load per model. Set to `0` to remove this limit altogether
|
|
66
|
-
* (which could be _very_ expensive for your database).
|
|
67
|
-
*
|
|
68
|
-
* @default 100
|
|
69
|
-
*/
|
|
70
|
-
limit: number;
|
|
71
|
-
/**
|
|
72
|
-
* Strings to omit from the dumped data. For testability, omitting date or UUID id fields is a
|
|
73
|
-
* common practice.
|
|
74
|
-
*/
|
|
75
|
-
omitFields: string[];
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Output for `prisma.client.dumpData`.
|
|
79
|
-
*
|
|
80
|
-
* @deprecated Use the `prisma-vir` package instead.
|
|
81
|
-
* @category Prisma : Node
|
|
82
|
-
* @category Package : @augment-vir/node
|
|
83
|
-
* @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node)
|
|
84
|
-
*/
|
|
85
|
-
export type PrismaDumpOutput<TypeMap extends BaseTypeMap> = Partial<{
|
|
86
|
-
[Model in PrismaModelName<TypeMap> as FirstLetterLowercase<Model>]: PrismaBasicModel<TypeMap, Model>[];
|
|
87
|
-
}>;
|
|
88
|
-
export declare function dumpData<const TypeMap extends BaseTypeMap>(prismaClient: BasePrismaClient, options?: Readonly<PartialWithUndefined<PrismaDataDumpOptions>>): Promise<PrismaDumpOutput<TypeMap>>;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
2
|
-
import { assert, check } from '@augment-vir/assert';
|
|
3
|
-
import { arrayToObject, awaitedForEach, ensureErrorAndPrependMessage, filterMap, getObjectTypedEntries, getObjectTypedValues, mergeDefinedProperties, omitObjectKeys, prismaModelCreateExclude, prismaModelCreateOmitId, setFirstLetterCasing, StringCase, } from '@augment-vir/common';
|
|
4
|
-
export async function addData(prismaClient, data) {
|
|
5
|
-
const dataArray = (check.isArray(data) ? data : [data]);
|
|
6
|
-
await awaitedForEach(dataArray, async (dataEntry) => {
|
|
7
|
-
await addModelDataObject(prismaClient, dataEntry);
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
async function addModelDataObject(prismaClient, data) {
|
|
11
|
-
/** Add the mock data to the mock prisma client. */
|
|
12
|
-
await awaitedForEach(getObjectTypedEntries(data), async ([modelName, mockData,]) => {
|
|
13
|
-
/**
|
|
14
|
-
* This type is dumbed down to just `AnyObject[]` because the union of all possible
|
|
15
|
-
* model data is just way too big (and not helpful as the inputs to this function are
|
|
16
|
-
* already type guarded).
|
|
17
|
-
*/
|
|
18
|
-
const mockModelInstances = Array.isArray(mockData)
|
|
19
|
-
? mockData
|
|
20
|
-
: getObjectTypedValues(mockData);
|
|
21
|
-
const modelApi = prismaClient[setFirstLetterCasing(modelName, StringCase.Lower)];
|
|
22
|
-
assert.isDefined(modelApi, `No PrismaClient API found for model '${modelName}'`);
|
|
23
|
-
try {
|
|
24
|
-
const allData = filterMap(mockModelInstances, (entry) => {
|
|
25
|
-
return entry;
|
|
26
|
-
}, (mapped, modelEntry) => !modelEntry[prismaModelCreateExclude]);
|
|
27
|
-
await awaitedForEach(allData, async (modelEntry) => {
|
|
28
|
-
if (modelEntry[prismaModelCreateOmitId]) {
|
|
29
|
-
modelEntry = omitObjectKeys(modelEntry, ['id']);
|
|
30
|
-
}
|
|
31
|
-
await modelApi.create({
|
|
32
|
-
data: modelEntry,
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
throw ensureErrorAndPrependMessage(error, `Failed to create many '${modelName}' entries.\n\n${JSON.stringify(mockModelInstances, null, 4)}\n\n`);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
const prismockKeys = [
|
|
42
|
-
'getData',
|
|
43
|
-
'setData',
|
|
44
|
-
];
|
|
45
|
-
/** These are not the real model names, they are the names on the PrismaClient (which are lowercase). */
|
|
46
|
-
export function getAllPrismaModelKeys(prismaClient) {
|
|
47
|
-
return Object.keys(prismaClient)
|
|
48
|
-
.filter((key) => !key.startsWith('$') &&
|
|
49
|
-
!key.startsWith('_') &&
|
|
50
|
-
!prismockKeys.includes(key) &&
|
|
51
|
-
key !== 'constructor')
|
|
52
|
-
.sort();
|
|
53
|
-
}
|
|
54
|
-
const defaultPrismaDumpDataOptions = {
|
|
55
|
-
limit: 100,
|
|
56
|
-
omitFields: [],
|
|
57
|
-
};
|
|
58
|
-
export async function dumpData(prismaClient, options = {}) {
|
|
59
|
-
const modelNames = getAllPrismaModelKeys(prismaClient);
|
|
60
|
-
const finalOptions = mergeDefinedProperties(defaultPrismaDumpDataOptions, options);
|
|
61
|
-
const data = await arrayToObject(modelNames, async (modelName) => {
|
|
62
|
-
try {
|
|
63
|
-
const entries = await prismaClient[modelName].findMany(finalOptions.limit > 0
|
|
64
|
-
? {
|
|
65
|
-
take: finalOptions.limit,
|
|
66
|
-
}
|
|
67
|
-
: {});
|
|
68
|
-
if (!entries.length) {
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
const filteredEntries = finalOptions.omitFields.length
|
|
72
|
-
? entries.map((entry) => omitObjectKeys(entry, finalOptions.omitFields))
|
|
73
|
-
: entries;
|
|
74
|
-
return {
|
|
75
|
-
key: modelName,
|
|
76
|
-
value: filteredEntries,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
throw ensureErrorAndPrependMessage(error, `Failed to read data for model '${modelName}'`);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
return data;
|
|
84
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare function generatePrismaClient(schemaFilePath: string, env?: Record<string, string>): Promise<void>;
|
|
2
|
-
export declare function isGeneratedPrismaClientCurrent({ jsClientOutputDir, schemaFilePath, }: {
|
|
3
|
-
schemaFilePath: string;
|
|
4
|
-
jsClientOutputDir: string;
|
|
5
|
-
}): Promise<boolean>;
|