@a_team/prisma 3.0.22-win → 3.1.0-macos
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/README.md +81 -31
- package/dist/client/edge.js +16 -4
- package/dist/client/index-browser.js +12 -0
- package/dist/client/index.d.ts +318 -1
- package/dist/client/index.js +18 -6
- package/dist/client/{query_engine-windows.dll.node → libquery_engine-darwin-arm64.dylib.node} +0 -0
- package/dist/client/package.json +1 -1
- package/dist/client/schema.prisma +35 -10
- package/dist/client/wasm.js +12 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,58 +1,108 @@
|
|
|
1
|
-
#
|
|
1
|
+
# A.Team prisma library
|
|
2
2
|
|
|
3
|
-
This package contains a shared Prisma schema, organized into [multiple files](https://www.prisma.io/blog/organize-your-prisma-schema-with-multi-file-support), to be used across multiple projects.
|
|
3
|
+
- This package contains a shared Prisma schema, organized into [multiple files](https://www.prisma.io/blog/organize-your-prisma-schema-with-multi-file-support), to be used across multiple projects.
|
|
4
|
+
- By centralizing the schema definitions, we ensure consistency and reduce duplication of effort:
|
|
5
|
+
- **Consistency**: We are targeting the same MongoDB database. If we use different schema definition files, there's a risk of having inconsistent model definitions, which could lead to conflicts and data overrides.
|
|
6
|
+
- **Efficiency**: A single schema definition can reduce redundant work. Currently, the schema file has over 300 lines, and this could easily grow to 1000+ lines as we onboard more collections. By working collaboratively on a single schema definition, we can streamline our efforts and improve the overall quality.
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
1. **Efficiency**: A single schema definition can reduce redundant work. Currently, the schema file has over 300 lines, and this could easily grow to 1000+ lines as we onboard more collections. By working collaboratively on a single schema definition, we can streamline our efforts and improve the overall quality.
|
|
8
|
+
### Installation
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
- To install this package, add the following optional dependencies (where `X.Y.Z` represents the version):
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
```json
|
|
13
|
+
"optionalDependencies": {
|
|
14
|
+
"@a_team/prisma-win": "npm:@a_team/prisma@X.Y.Z-win",
|
|
15
|
+
"@a_team/prisma-macos": "npm:@a_team/prisma@X.Y.Z-macos",
|
|
16
|
+
"@a_team/prisma-linux": "npm:@a_team/prisma@X.Y.Z-linux"
|
|
17
|
+
}
|
|
14
18
|
```
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
- Add the following script as `postinstall` & change per need in your service:
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
const path = require('path');
|
|
25
|
+
|
|
26
|
+
const getPlatformPackage = () => {
|
|
27
|
+
switch (process.platform) {
|
|
28
|
+
case 'darwin':
|
|
29
|
+
return '@a_team/prisma-macos';
|
|
30
|
+
case 'win32':
|
|
31
|
+
return '@a_team/prisma-win';
|
|
32
|
+
default:
|
|
33
|
+
return '@a_team/prisma-linux';
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const platformPackage = getPlatformPackage();
|
|
38
|
+
const nodeModulesPath = path.join(__dirname, '..', 'node_modules');
|
|
39
|
+
const sourcePath = path.join(nodeModulesPath, platformPackage);
|
|
40
|
+
const targetPath = path.join(nodeModulesPath, '@a_team/prisma');
|
|
41
|
+
|
|
42
|
+
if (fs.existsSync(sourcePath)) {
|
|
43
|
+
if (fs.existsSync(targetPath)) {
|
|
44
|
+
fs.rmSync(targetPath, { recursive: true, force: true });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
fs.renameSync(sourcePath, targetPath);
|
|
48
|
+
console.log(`Renamed ${platformPackage} to @a_team/prisma`);
|
|
49
|
+
} else {
|
|
50
|
+
console.error(`Platform-specific package ${platformPackage} not found`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
17
53
|
|
|
18
|
-
|
|
54
|
+
```
|
|
19
55
|
|
|
20
|
-
|
|
21
|
-
import { PrismaClient } from "@prisma/client";
|
|
56
|
+
- The script above will link the required OS dependency as the main one.
|
|
22
57
|
|
|
23
|
-
|
|
24
|
-
```
|
|
58
|
+
### Usage
|
|
25
59
|
|
|
26
|
-
|
|
60
|
+
- To use the library:
|
|
27
61
|
|
|
28
|
-
|
|
62
|
+
```typescript
|
|
63
|
+
import { ATeamPrismaClient } from '@a_team/prisma';
|
|
29
64
|
|
|
30
|
-
|
|
65
|
+
export class DbClient extends ATeamPrismaClient {
|
|
66
|
+
constructor(connectionUrl: string) {
|
|
67
|
+
super(connectionUrl);
|
|
68
|
+
}
|
|
31
69
|
|
|
32
|
-
|
|
33
|
-
|
|
70
|
+
async onModuleInit() {
|
|
71
|
+
await this.connect();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async onModuleDestroy() {
|
|
75
|
+
await this.disconnect();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
34
78
|
```
|
|
35
79
|
|
|
36
|
-
|
|
80
|
+
### Playground
|
|
37
81
|
|
|
38
|
-
|
|
82
|
+
- The playground is a dedicated space where you can test and experiment with the prisma client and schema.
|
|
83
|
+
- It contains various scripts that demonstrate how to interact with your database models.
|
|
84
|
+
- Before running any playground scripts, make sure to set up your environment variables. First, copy the `.env.sample` file to `.env`:
|
|
39
85
|
|
|
40
86
|
```sh
|
|
41
|
-
|
|
87
|
+
cp .env.sample .env
|
|
42
88
|
```
|
|
43
89
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
To publish updates to this package, use the following command:
|
|
90
|
+
- Then, fill in the required environment variables in the `.env` file.
|
|
91
|
+
- To run a playground script, use the following command:
|
|
47
92
|
|
|
48
93
|
```sh
|
|
49
|
-
|
|
94
|
+
npx ts-node playground/missionSpec.ts
|
|
50
95
|
```
|
|
51
96
|
|
|
52
|
-
|
|
97
|
+
### Publishing a new version
|
|
53
98
|
|
|
54
|
-
|
|
99
|
+
- Pull the latest changes on the `main` branch and push the following tag to the repository:
|
|
55
100
|
|
|
56
|
-
|
|
101
|
+
```bash
|
|
102
|
+
git tag v<major>.<minor>.<patch> # matches v0.0.1
|
|
103
|
+
git push origin tag v<major>.<minor>.<patch> # runs the publishing process
|
|
104
|
+
```
|
|
57
105
|
|
|
58
|
-
|
|
106
|
+
- This tag creates the new package versions needed and pushes them towards the npm repository,
|
|
107
|
+
- A `release` on the `github` repository is generated,
|
|
108
|
+
- A slack notification is sent to the required channel with the release changes.
|