@pkgverse/prismock 2.0.0-beta.1 → 2.0.0-beta.10
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/CHANGELOG.md +111 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +103 -63
- package/dist/lib/client.d.ts +26 -6
- package/dist/lib/extensions/result.d.ts +1 -1
- package/dist/lib/prismock.d.ts +1 -1
- package/package.json +15 -15
- package/dist/index.cjs +0 -5337
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# 1.0.0-beta.1 (2025-11-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* 🐛 🐛 add support for nested create with multiple items ([54e8731](https://github.com/JQuezada0/prismock/commit/54e873123bb03849dece0141799e769e23dd9b6e)), closes [#618](https://github.com/JQuezada0/prismock/issues/618)
|
|
7
|
+
* 🐛 Add support for nested select/include on create ([0ec8184](https://github.com/JQuezada0/prismock/commit/0ec81844440ffa78af1523097b421113afa0ed6b))
|
|
8
|
+
* 🐛 Correct Array.slice() with both skip + take ([40ba3c2](https://github.com/JQuezada0/prismock/commit/40ba3c2fbecd0e0fed9f98d993986b9e951531ca))
|
|
9
|
+
* 🐛 correctly manage nested operations with update ([a07ff92](https://github.com/JQuezada0/prismock/commit/a07ff929384fc11fa926b045e5b3dc8507b014cd))
|
|
10
|
+
* 🐛 correctly use default value ([0f3b1ca](https://github.com/JQuezada0/prismock/commit/0f3b1ca68fb09e70846f412ea772216f61c520c2)), closes [#560](https://github.com/JQuezada0/prismock/issues/560)
|
|
11
|
+
* 🐛 correctly use nested create ([e97fc7d](https://github.com/JQuezada0/prismock/commit/e97fc7dcb75bd90afaee8d2a6cefb9cf4329db70)), closes [#768](https://github.com/JQuezada0/prismock/issues/768)
|
|
12
|
+
* 🐛 create with no data ([665fb43](https://github.com/JQuezada0/prismock/commit/665fb4341537e752d1e31cb3bf76300a9c1eec87)), closes [#1096](https://github.com/JQuezada0/prismock/issues/1096)
|
|
13
|
+
* 🐛 don't include relations with include false ([ceae6ca](https://github.com/JQuezada0/prismock/commit/ceae6ca11261cee5f6ad7003c53f0abbfe975140)), closes [#953](https://github.com/JQuezada0/prismock/issues/953)
|
|
14
|
+
* 🐛 ensure we don't accept null from lt/lte filters ([34add0c](https://github.com/JQuezada0/prismock/commit/34add0cd5d290216294b26c4e14d2718cb8f31b1)), closes [#771](https://github.com/JQuezada0/prismock/issues/771)
|
|
15
|
+
* 🐛 find test ([6e9778d](https://github.com/JQuezada0/prismock/commit/6e9778de60ca045546311c5e496f8dad0ac7001c))
|
|
16
|
+
* 🐛 ignore undefined values given to update ([f3dbeca](https://github.com/JQuezada0/prismock/commit/f3dbecaef27aaec5c575a1612a0fa4665b0608f5))
|
|
17
|
+
* 🐛 make orderBy compatible with mysql & postgre ([2d5c4cd](https://github.com/JQuezada0/prismock/commit/2d5c4cd004403a80051583a45ef4ccd0a9b8ae23))
|
|
18
|
+
* 🐛 properly query with child: null ([2e7e30d](https://github.com/JQuezada0/prismock/commit/2e7e30dfc7608f707b46f3e6c57a7e16087a8a01)), closes [#1075](https://github.com/JQuezada0/prismock/issues/1075)
|
|
19
|
+
* 🐛 properly use create with many on update ([db17b3f](https://github.com/JQuezada0/prismock/commit/db17b3f974e8150d6f75ed934743950d9ccb14b4)), closes [#1016](https://github.com/JQuezada0/prismock/issues/1016)
|
|
20
|
+
* 🐛 remove duplicate include (in select and connect) ([8bac544](https://github.com/JQuezada0/prismock/commit/8bac54482fa7fb3f5d5dbaaaedc62b9f5af64cf0))
|
|
21
|
+
* add object id generation ([eeec13b](https://github.com/JQuezada0/prismock/commit/eeec13b99d770e19219899a5a06e2a65cfeb0144))
|
|
22
|
+
* allow non-scalar lists to be pushed ([8f8acbc](https://github.com/JQuezada0/prismock/commit/8f8acbc026ac4a5a58a93a8a3a59f269dea817a6))
|
|
23
|
+
* avoid using generated types ([eb0d880](https://github.com/JQuezada0/prismock/commit/eb0d880bcd55fc5a0f5404dd70f6dedb188a3dce))
|
|
24
|
+
* bug in scalar list push support that would push the push function of arrays onto each array ([4281ac7](https://github.com/JQuezada0/prismock/commit/4281ac753c71dbb479d0700952d3aa00419ec36d))
|
|
25
|
+
* createMany with update ([d727559](https://github.com/JQuezada0/prismock/commit/d727559b457cb37220c12477966d70bc947f8ec1))
|
|
26
|
+
* datetime querying ([83b9136](https://github.com/JQuezada0/prismock/commit/83b91364b85090080cd5fec639c68b6e3e25953b))
|
|
27
|
+
* deploy correctly ([218c1c1](https://github.com/JQuezada0/prismock/commit/218c1c146e86c175dcdff2f5c3de08a2b9d5af35))
|
|
28
|
+
* **deps:** update dependency bson to v4.7.1 ([9377451](https://github.com/JQuezada0/prismock/commit/9377451cb25afea299d31aea0b47430d84009d96))
|
|
29
|
+
* **deps:** update dependency bson to v4.7.2 ([3148ac2](https://github.com/JQuezada0/prismock/commit/3148ac281fd14f33c953ccabb18c634f40728519))
|
|
30
|
+
* **deps:** update dependency bson to v5 ([85da7e6](https://github.com/JQuezada0/prismock/commit/85da7e6a6d603052368bab12d23ed0db254a0d3b))
|
|
31
|
+
* **deps:** update dependency bson to v5.0.1 ([5893ea2](https://github.com/JQuezada0/prismock/commit/5893ea2c36df4396fde8a5ff3ed943e51c34bf72))
|
|
32
|
+
* **deps:** update dependency bson to v5.1.0 ([5494250](https://github.com/JQuezada0/prismock/commit/5494250b6dbad344f865126c709e5028290795ee))
|
|
33
|
+
* **deps:** update dependency bson to v5.2.0 ([b01a762](https://github.com/JQuezada0/prismock/commit/b01a762e787b7c315fe3a39e2f58268a264e5e64))
|
|
34
|
+
* **deps:** update dependency bson to v5.3.0 ([9aa563e](https://github.com/JQuezada0/prismock/commit/9aa563e67d208ac523bb85120ec18d3f036416cf))
|
|
35
|
+
* **deps:** update dependency bson to v5.4.0 ([0f9e91d](https://github.com/JQuezada0/prismock/commit/0f9e91dee718f91d72edcdaa75aa93c98ba19d53))
|
|
36
|
+
* **deps:** update dependency bson to v6 ([5e828b1](https://github.com/JQuezada0/prismock/commit/5e828b1b11bdd197384c9d5fc1b135daa2c2b68b))
|
|
37
|
+
* **deps:** update dependency bson to v6.1.0 ([8d3a678](https://github.com/JQuezada0/prismock/commit/8d3a67882b65d8dc62e8e248372e2053667b2736))
|
|
38
|
+
* **deps:** update dependency bson to v6.10.0 ([#1169](https://github.com/JQuezada0/prismock/issues/1169)) ([b4dbe16](https://github.com/JQuezada0/prismock/commit/b4dbe16dcd2b386b027120a6289223235e075e46))
|
|
39
|
+
* **deps:** update dependency bson to v6.10.0 ([#1169](https://github.com/JQuezada0/prismock/issues/1169)) ([df6fb97](https://github.com/JQuezada0/prismock/commit/df6fb97523cd8c5133b51999c3c4128a30317c0b))
|
|
40
|
+
* **deps:** update dependency bson to v6.10.1 ([#1188](https://github.com/JQuezada0/prismock/issues/1188)) ([48a341b](https://github.com/JQuezada0/prismock/commit/48a341ba35fac491b78796f6e346046fac7302bf))
|
|
41
|
+
* **deps:** update dependency bson to v6.10.1 ([#1188](https://github.com/JQuezada0/prismock/issues/1188)) ([b65bf33](https://github.com/JQuezada0/prismock/commit/b65bf33c46410377c82c80d6b613103cacb170e9))
|
|
42
|
+
* **deps:** update dependency bson to v6.10.2 ([#1233](https://github.com/JQuezada0/prismock/issues/1233)) ([9acea37](https://github.com/JQuezada0/prismock/commit/9acea37d643004415a31ea3e4c65c5400585ce00))
|
|
43
|
+
* **deps:** update dependency bson to v6.10.3 ([#1248](https://github.com/JQuezada0/prismock/issues/1248)) ([2739a47](https://github.com/JQuezada0/prismock/commit/2739a478ec9507ecdf275be87b6a5d798a3eff75))
|
|
44
|
+
* **deps:** update dependency bson to v6.10.4 ([#1351](https://github.com/JQuezada0/prismock/issues/1351)) ([68eb60e](https://github.com/JQuezada0/prismock/commit/68eb60e9ce3aec9224ac3be50af5e48b5cee4f4b))
|
|
45
|
+
* **deps:** update dependency bson to v6.2.0 ([db78832](https://github.com/JQuezada0/prismock/commit/db788323080b7d5b273da2c31d8c46a3590a7127))
|
|
46
|
+
* **deps:** update dependency bson to v6.3.0 ([6053c0e](https://github.com/JQuezada0/prismock/commit/6053c0eda0ddad7bc5ced6e9b936608d3485f2e4))
|
|
47
|
+
* **deps:** update dependency bson to v6.4.0 ([613f388](https://github.com/JQuezada0/prismock/commit/613f3884e6e7737e1d29f4eb831fc1992bc9cfa4))
|
|
48
|
+
* **deps:** update dependency bson to v6.5.0 ([88de544](https://github.com/JQuezada0/prismock/commit/88de544abd4daaa27002cae9f1341c109a238187))
|
|
49
|
+
* **deps:** update dependency bson to v6.6.0 ([78df73b](https://github.com/JQuezada0/prismock/commit/78df73b6fcb79bb3286d88331306a1a01393a48a))
|
|
50
|
+
* **deps:** update dependency bson to v6.7.0 ([f7aade0](https://github.com/JQuezada0/prismock/commit/f7aade0786514a86c864f4d049c2e8dc73a57ab0))
|
|
51
|
+
* **deps:** update dependency bson to v6.7.0 ([6d22abb](https://github.com/JQuezada0/prismock/commit/6d22abb3f53c0a655838b151f18d72c577f82794))
|
|
52
|
+
* **deps:** update dependency bson to v6.8.0 ([301e801](https://github.com/JQuezada0/prismock/commit/301e801f949604c8bac51f3285ef2cfa70ec86f8))
|
|
53
|
+
* **deps:** update dependency bson to v6.9.0 ([83c0645](https://github.com/JQuezada0/prismock/commit/83c0645079984b006df097a4af3af82af01e61b4))
|
|
54
|
+
* **deps:** update dependency bson to v6.9.0 ([9c63be1](https://github.com/JQuezada0/prismock/commit/9c63be1370d4abe5cadfb60daebd030000f6b82f))
|
|
55
|
+
* ensure the right data is stored ([9ba689f](https://github.com/JQuezada0/prismock/commit/9ba689fa7b81e2f39ef1860af5728ecdd1e2e1c9))
|
|
56
|
+
* **find-unique:** valid/fix all non-regression test ([b1c4a09](https://github.com/JQuezada0/prismock/commit/b1c4a09c2e9cabfdb1d214481e2d073ce0bff5ae))
|
|
57
|
+
* findFirst method ([ee42278](https://github.com/JQuezada0/prismock/commit/ee42278322bbcca9f5e5dd15d774e69810f624cf))
|
|
58
|
+
* fix issue with compound ids with default names ([ebcd75d](https://github.com/JQuezada0/prismock/commit/ebcd75df28a58b5fc805a5d473b5117753b9bc01))
|
|
59
|
+
* handle NOT when non-array ([1eb539f](https://github.com/JQuezada0/prismock/commit/1eb539f5f0b5d47bcca1e204e4c5d0d5175ba330))
|
|
60
|
+
* show right example with prismock client ([8473d1e](https://github.com/JQuezada0/prismock/commit/8473d1e37b34796bbd95841c74a04afe4f02631d))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### Features
|
|
64
|
+
|
|
65
|
+
* :technologist: delete raises PrismaClientKnownRequestError [#1082](https://github.com/JQuezada0/prismock/issues/1082) ([e1222b2](https://github.com/JQuezada0/prismock/commit/e1222b23938a318f8ffc03b4fedb715ff867d7f5))
|
|
66
|
+
* :technologist: findOrThrow raises PrismaClientKnownRequestError [#1082](https://github.com/JQuezada0/prismock/issues/1082) ([e820060](https://github.com/JQuezada0/prismock/commit/e820060faa31441c2d569caad282be224d640e70))
|
|
67
|
+
* :technologist: update raises PrismaClientKnownRequestError [#1082](https://github.com/JQuezada0/prismock/issues/1082) ([a911b08](https://github.com/JQuezada0/prismock/commit/a911b08c148c9804976bc3d2cfe73de9c1bddcdc))
|
|
68
|
+
* @[@unique](https://github.com/unique) support ([9f7d5fc](https://github.com/JQuezada0/prismock/commit/9f7d5fc5ace06af2b1feaa7c6502d585dcdf0a47))
|
|
69
|
+
* 🎸 actually keep references ([f018279](https://github.com/JQuezada0/prismock/commit/f01827952df51d2c226efc590844dfd5588fb3dd))
|
|
70
|
+
* 🎸 add aggregate operation ([f63f472](https://github.com/JQuezada0/prismock/commit/f63f4726824ebeffbeeacf5f922a739ff7ffb495))
|
|
71
|
+
* 🎸 add orderBy ([8bb30ca](https://github.com/JQuezada0/prismock/commit/8bb30ca5a84e04661f2a7c09d2692f1b3d2374aa))
|
|
72
|
+
* 🎸 add reset method ([20c313e](https://github.com/JQuezada0/prismock/commit/20c313ed869f0f4772b46605baea4d66c70216f3))
|
|
73
|
+
* 🎸 add support for $extends ([2cffbb1](https://github.com/JQuezada0/prismock/commit/2cffbb1c80c51d5c536eb8eddfe3f0a6c270cc68))
|
|
74
|
+
* 🎸 add support for connect under create operation ([56389b0](https://github.com/JQuezada0/prismock/commit/56389b0b52ef6826c95201f35a8fffddb41b8d70))
|
|
75
|
+
* 🎸 add support for cuid ([90abb33](https://github.com/JQuezada0/prismock/commit/90abb338801e058f0fd56f0f728fdac2eb3f2fdc))
|
|
76
|
+
* 🎸 add support for is ([c0ddd0e](https://github.com/JQuezada0/prismock/commit/c0ddd0ef3c4c99d1c0c3f15a0299510406154093)), closes [#823](https://github.com/JQuezada0/prismock/issues/823)
|
|
77
|
+
* 🎸 add support for nested create & createMany ([a6b5693](https://github.com/JQuezada0/prismock/commit/a6b5693de001798038f22ed79e98902778ae90c5)), closes [#431](https://github.com/JQuezada0/prismock/issues/431)
|
|
78
|
+
* 🎸 add support for nested filtering ([772f25a](https://github.com/JQuezada0/prismock/commit/772f25ad093780a7ea37ff47769dacd44c5ebb47)), closes [#242](https://github.com/JQuezada0/prismock/issues/242)
|
|
79
|
+
* 🎸 add support for nested upsert ([a91f674](https://github.com/JQuezada0/prismock/commit/a91f674fa11ebce7c7c6393073a307c3cdbb510e))
|
|
80
|
+
* 🎸 add support with multiple nested create ([37a72b9](https://github.com/JQuezada0/prismock/commit/37a72b9188dfa6023a308fa949babbcde7c89518))
|
|
81
|
+
* 🎸 complete client method for sql dbs ([d9c6636](https://github.com/JQuezada0/prismock/commit/d9c663635cc3f29c1e36fcfc9bb400072114cf38))
|
|
82
|
+
* 🎸 complete groupBy ([7f47010](https://github.com/JQuezada0/prismock/commit/7f470108f46133ba7c009de9f24e3a334d085057))
|
|
83
|
+
* 🎸 complete scalar push implementation ([598e4ac](https://github.com/JQuezada0/prismock/commit/598e4aca1a3fdd395a4aff7b854ac474234cd8ec))
|
|
84
|
+
* 🎸 complete support for nested upsert ([068ede6](https://github.com/JQuezada0/prismock/commit/068ede68d73ba4659b58470a1f27881c43128c9d))
|
|
85
|
+
* 🎸 complete update with create many ([643c796](https://github.com/JQuezada0/prismock/commit/643c7964ec1178e54aea15780f1ea64a39ea9437))
|
|
86
|
+
* 🎸 implement createManyAndReturn ([132eb1b](https://github.com/JQuezada0/prismock/commit/132eb1b8417e87454cced336610ea07327647a28)), closes [#988](https://github.com/JQuezada0/prismock/issues/988)
|
|
87
|
+
* 🎸 Keep existing references ([9f600d2](https://github.com/JQuezada0/prismock/commit/9f600d2a2c7502b3874d1fb951a4b7b38d0a814d))
|
|
88
|
+
* 🎸 return structuredClone of items for findOne & Many ([9167f15](https://github.com/JQuezada0/prismock/commit/9167f1503912257b086022c4e39cbdccf33d7fb8)), closes [#736](https://github.com/JQuezada0/prismock/issues/736)
|
|
89
|
+
* 🎸 sync mongodb config with base ([a087dfe](https://github.com/JQuezada0/prismock/commit/a087dfea054f0d0cbc353396fea16ca714fa9826))
|
|
90
|
+
* 🎸 sync with @prisma/internals API & config ([998f423](https://github.com/JQuezada0/prismock/commit/998f4232a9ddb770af59912762e5881e66d4721c)), closes [#806](https://github.com/JQuezada0/prismock/issues/806) [#810](https://github.com/JQuezada0/prismock/issues/810)
|
|
91
|
+
* add automated release pipeline ([ce9f453](https://github.com/JQuezada0/prismock/commit/ce9f453bbf8f4eb14f96d35e06d4d00fb38c0430))
|
|
92
|
+
* add deployment with npm semantic ([2f506e1](https://github.com/JQuezada0/prismock/commit/2f506e15b19a1ba25408f7daf8a802611c8dfaf0))
|
|
93
|
+
* add disconnect ([6a28317](https://github.com/JQuezada0/prismock/commit/6a2831751d66f3c05d5116cd0f1770de6750183f))
|
|
94
|
+
* add examples using PrismockClient ([27bacb0](https://github.com/JQuezada0/prismock/commit/27bacb037d4ef607e5fd449b609ad23576a9745d))
|
|
95
|
+
* add mongodb support ([098e16a](https://github.com/JQuezada0/prismock/commit/098e16ab33a23994908d2a2c9f4bc44ef8186b57))
|
|
96
|
+
* add prismock client ([657f47b](https://github.com/JQuezada0/prismock/commit/657f47bd736a43681b8e2203033c8bbddacfc0dc))
|
|
97
|
+
* add support for connectOrCreate ([4d1d12f](https://github.com/JQuezada0/prismock/commit/4d1d12fa1bfdc4fe1ac4e66391a6dbb3d61db789))
|
|
98
|
+
* add uuid ([36f3942](https://github.com/JQuezada0/prismock/commit/36f394202aab54bfe8248f74283ff1e59c2d91cf))
|
|
99
|
+
* allow custom client ([527e21a](https://github.com/JQuezada0/prismock/commit/527e21a4ac268e3d0269b74a13b507effa8406b3))
|
|
100
|
+
* allow custom client on generatePrismock ([db9da12](https://github.com/JQuezada0/prismock/commit/db9da12eb2a733c972c9caf7b82402ccd98526fd))
|
|
101
|
+
* **client:** allow creating prismock with a custom client location ([65f8717](https://github.com/JQuezada0/prismock/commit/65f871769ea78235b9b5e7f65280e7fbbe15bd85))
|
|
102
|
+
* complete create delegate with nested connect ([fd57329](https://github.com/JQuezada0/prismock/commit/fd573295519f73aca17cc59a74dbb11c63340c9a))
|
|
103
|
+
* complete support for connectOrCreate ([9c20dd2](https://github.com/JQuezada0/prismock/commit/9c20dd2f78e66425066bd915e77cd35553a44dd8))
|
|
104
|
+
* **delete:** add include and select support to delete methods ([beb57ed](https://github.com/JQuezada0/prismock/commit/beb57ed3be3b18968176563dc5eecfd9092d3e07))
|
|
105
|
+
* **groupBy:** implement core groupBy logic ([4b0115e](https://github.com/JQuezada0/prismock/commit/4b0115ec10ca73e4b91483bab91aaa202d6b037e))
|
|
106
|
+
* implement push for scalar lists ([d58188e](https://github.com/JQuezada0/prismock/commit/d58188e462ee5ef80e0acc7b37364c2b27a8e488))
|
|
107
|
+
* initial ([4da5f8b](https://github.com/JQuezada0/prismock/commit/4da5f8b4973866ac63eb884639c27d34385c29fd))
|
|
108
|
+
* **match:** add mode support in filter conditions and operators ([2ba7d34](https://github.com/JQuezada0/prismock/commit/2ba7d34a9be22a3a7a3250e634a267698c25a871))
|
|
109
|
+
* **orderBy:** added orderBy date support ([e8d22a5](https://github.com/JQuezada0/prismock/commit/e8d22a5eef5b865a93ff59436a2d941ac93ed4cc))
|
|
110
|
+
* support dbgenerated id type ([99c384f](https://github.com/JQuezada0/prismock/commit/99c384fca271a833d3a851167d72e4ccab86e6d9))
|
|
111
|
+
* support querying with bigint ([16d3c79](https://github.com/JQuezada0/prismock/commit/16d3c798f84b94db6c5361b64fcccb804b589b2c))
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { generatePrismock, generatePrismockSync } from './lib/prismock';
|
|
2
|
-
export { createPrismock,
|
|
2
|
+
export { createPrismock, createPrismockClient, Prismock, type PrismaModule, createPrismockClass } from './lib/client';
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
2
18
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
3
19
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
4
20
|
|
|
@@ -612,10 +628,7 @@ var require_src = __commonJS((exports, module) => {
|
|
|
612
628
|
});
|
|
613
629
|
|
|
614
630
|
// src/lib/prismock.ts
|
|
615
|
-
import path from "path";
|
|
616
|
-
import { getDMMF } from "@prisma/internals/dist/engine-commands/getDmmf";
|
|
617
|
-
import { getGenerator } from "@prisma/internals/dist/get-generators/getGenerators";
|
|
618
|
-
import { getSchema } from "@prisma/internals/dist/cli/getSchema";
|
|
631
|
+
import * as path from "path";
|
|
619
632
|
|
|
620
633
|
// src/lib/operations/aggregate.ts
|
|
621
634
|
function aggregate(args, items) {
|
|
@@ -4745,8 +4758,10 @@ function updateMany(args, current, delegates, onChange) {
|
|
|
4745
4758
|
onChange(updated);
|
|
4746
4759
|
return toUpdate;
|
|
4747
4760
|
}
|
|
4761
|
+
// node_modules/@prisma/client/package.json
|
|
4762
|
+
var version = "5.22.0";
|
|
4763
|
+
|
|
4748
4764
|
// src/lib/delegate.ts
|
|
4749
|
-
import { version as clientVersion } from "@prisma/client/package.json";
|
|
4750
4765
|
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";
|
|
4751
4766
|
function generateDelegate(model, data, name, properties, delegates, onChange) {
|
|
4752
4767
|
const delegate = {};
|
|
@@ -4756,7 +4771,7 @@ function generateDelegate(model, data, name, properties, delegates, onChange) {
|
|
|
4756
4771
|
if (deleted.length === 0)
|
|
4757
4772
|
return Promise.reject(new PrismaClientKnownRequestError(`No ${delegate.model.name} found`, {
|
|
4758
4773
|
code: "P2025",
|
|
4759
|
-
clientVersion,
|
|
4774
|
+
clientVersion: version,
|
|
4760
4775
|
meta: {
|
|
4761
4776
|
cause: "Record to delete does not exist.",
|
|
4762
4777
|
modelName: delegate.model.name
|
|
@@ -4773,7 +4788,7 @@ function generateDelegate(model, data, name, properties, delegates, onChange) {
|
|
|
4773
4788
|
const [update3] = updated;
|
|
4774
4789
|
return update3 ? Promise.resolve(update3) : Promise.reject(new PrismaClientKnownRequestError(`No ${delegate.model.name} found`, {
|
|
4775
4790
|
code: "P2025",
|
|
4776
|
-
clientVersion,
|
|
4791
|
+
clientVersion: version,
|
|
4777
4792
|
meta: {
|
|
4778
4793
|
cause: "Record to update not found.",
|
|
4779
4794
|
modelName: delegate.model.name
|
|
@@ -4819,7 +4834,7 @@ function generateDelegate(model, data, name, properties, delegates, onChange) {
|
|
|
4819
4834
|
if (!found)
|
|
4820
4835
|
return Promise.reject(new PrismaClientKnownRequestError(`No ${delegate.model.name} found`, {
|
|
4821
4836
|
code: "P2025",
|
|
4822
|
-
clientVersion
|
|
4837
|
+
clientVersion: version
|
|
4823
4838
|
}));
|
|
4824
4839
|
return Promise.resolve(found);
|
|
4825
4840
|
},
|
|
@@ -4828,7 +4843,7 @@ function generateDelegate(model, data, name, properties, delegates, onChange) {
|
|
|
4828
4843
|
if (!found)
|
|
4829
4844
|
return Promise.reject(new PrismaClientKnownRequestError(`No ${delegate.model.name} found`, {
|
|
4830
4845
|
code: "P2025",
|
|
4831
|
-
clientVersion
|
|
4846
|
+
clientVersion: version
|
|
4832
4847
|
}));
|
|
4833
4848
|
return Promise.resolve(found);
|
|
4834
4849
|
},
|
|
@@ -4857,13 +4872,11 @@ function generateDelegate(model, data, name, properties, delegates, onChange) {
|
|
|
4857
4872
|
return delegate;
|
|
4858
4873
|
}
|
|
4859
4874
|
|
|
4860
|
-
// src/lib/client.ts
|
|
4861
|
-
import { Prisma as Prisma2 } from "@prisma/client";
|
|
4862
|
-
|
|
4863
4875
|
// src/lib/extensions/model.ts
|
|
4864
4876
|
function applyModelExtensions(client, extensions) {
|
|
4865
4877
|
if (typeof extensions === "function") {
|
|
4866
|
-
|
|
4878
|
+
const extendedClient = extensions(client);
|
|
4879
|
+
return extendedClient;
|
|
4867
4880
|
}
|
|
4868
4881
|
const model = extensions.model ?? {};
|
|
4869
4882
|
const extendedModels = Object.keys(model);
|
|
@@ -4928,7 +4941,8 @@ function applyModelExtensions(client, extensions) {
|
|
|
4928
4941
|
// src/lib/extensions/query.ts
|
|
4929
4942
|
function applyQueryExtensions(client, extensions) {
|
|
4930
4943
|
if (typeof extensions === "function") {
|
|
4931
|
-
|
|
4944
|
+
const extendedClient = extensions(client);
|
|
4945
|
+
return extendedClient;
|
|
4932
4946
|
}
|
|
4933
4947
|
const queryExtendedModelMap = extensions.query ?? {};
|
|
4934
4948
|
const extendedModels = Object.keys(queryExtendedModelMap);
|
|
@@ -5091,7 +5105,8 @@ function buildResultExtendedModel(client, proxiedModels, modelExtensions, modelN
|
|
|
5091
5105
|
}
|
|
5092
5106
|
function applyResultExtensions(client, extensions) {
|
|
5093
5107
|
if (typeof extensions === "function") {
|
|
5094
|
-
|
|
5108
|
+
const extendedClient = extensions(client);
|
|
5109
|
+
return extendedClient;
|
|
5095
5110
|
}
|
|
5096
5111
|
const resultExtendedModelMap = extensions.result ?? {};
|
|
5097
5112
|
const extendedModels = Object.keys(resultExtendedModelMap);
|
|
@@ -5144,6 +5159,63 @@ function applyExtensions(client, extensions) {
|
|
|
5144
5159
|
}
|
|
5145
5160
|
|
|
5146
5161
|
// src/lib/client.ts
|
|
5162
|
+
class Prismock {
|
|
5163
|
+
__prismaModule;
|
|
5164
|
+
constructor(prismaModule) {
|
|
5165
|
+
this.__prismaModule = prismaModule;
|
|
5166
|
+
this.generate();
|
|
5167
|
+
}
|
|
5168
|
+
static async create(prismaModule) {
|
|
5169
|
+
return new Prismock(prismaModule);
|
|
5170
|
+
}
|
|
5171
|
+
static async createDefault() {
|
|
5172
|
+
const { Prisma: Prisma2, PrismaClient } = await import("@prisma/client");
|
|
5173
|
+
return new Prismock(Prisma2);
|
|
5174
|
+
}
|
|
5175
|
+
reset() {
|
|
5176
|
+
this.generate();
|
|
5177
|
+
}
|
|
5178
|
+
generate() {
|
|
5179
|
+
const { delegates, setData, getData } = generateDelegates({ models: this.__prismaModule.dmmf.datamodel.models });
|
|
5180
|
+
Object.entries({ ...delegates, setData, getData }).forEach(([key, value]) => {
|
|
5181
|
+
if (key in this)
|
|
5182
|
+
Object.assign(this[key], value);
|
|
5183
|
+
else
|
|
5184
|
+
Object.assign(this, { [key]: value });
|
|
5185
|
+
});
|
|
5186
|
+
}
|
|
5187
|
+
async $connect() {
|
|
5188
|
+
return Promise.resolve();
|
|
5189
|
+
}
|
|
5190
|
+
$disconnect() {
|
|
5191
|
+
return Promise.resolve();
|
|
5192
|
+
}
|
|
5193
|
+
$on() {}
|
|
5194
|
+
$use() {
|
|
5195
|
+
return this;
|
|
5196
|
+
}
|
|
5197
|
+
$executeRaw() {
|
|
5198
|
+
return Promise.resolve(0);
|
|
5199
|
+
}
|
|
5200
|
+
$executeRawUnsafe() {
|
|
5201
|
+
return Promise.resolve(0);
|
|
5202
|
+
}
|
|
5203
|
+
$queryRaw() {
|
|
5204
|
+
return Promise.resolve([]);
|
|
5205
|
+
}
|
|
5206
|
+
$queryRawUnsafe() {
|
|
5207
|
+
return Promise.resolve([]);
|
|
5208
|
+
}
|
|
5209
|
+
$extends(extensionDefs) {
|
|
5210
|
+
return applyExtensions(this, extensionDefs);
|
|
5211
|
+
}
|
|
5212
|
+
async $transaction(args) {
|
|
5213
|
+
if (Array.isArray(args)) {
|
|
5214
|
+
return Promise.all(args);
|
|
5215
|
+
}
|
|
5216
|
+
return args(this);
|
|
5217
|
+
}
|
|
5218
|
+
}
|
|
5147
5219
|
function generateClient(delegates, getData, setData) {
|
|
5148
5220
|
console.log("Deprecation notice: generatePrismock and generatePrismockSync should be replaced with PrismockClient. See https://github.com/morintd/prismock/blob/master/docs/generate-prismock-deprecated.md");
|
|
5149
5221
|
const client = {
|
|
@@ -5169,59 +5241,25 @@ function generateClient(delegates, getData, setData) {
|
|
|
5169
5241
|
}
|
|
5170
5242
|
};
|
|
5171
5243
|
}
|
|
5172
|
-
function
|
|
5173
|
-
|
|
5244
|
+
async function createPrismockClass(prismaModule) {
|
|
5245
|
+
const { Prisma: Prisma2 } = await import("@prisma/client");
|
|
5246
|
+
const c = class PrismockClientDefault extends Prismock {
|
|
5174
5247
|
constructor() {
|
|
5175
|
-
|
|
5176
|
-
}
|
|
5177
|
-
reset() {
|
|
5178
|
-
this.generate();
|
|
5179
|
-
}
|
|
5180
|
-
generate() {
|
|
5181
|
-
const { delegates, setData, getData } = generateDelegates({ models: instance.dmmf.datamodel.models });
|
|
5182
|
-
Object.entries({ ...delegates, setData, getData }).forEach(([key, value]) => {
|
|
5183
|
-
if (key in this)
|
|
5184
|
-
Object.assign(this[key], value);
|
|
5185
|
-
else
|
|
5186
|
-
Object.assign(this, { [key]: value });
|
|
5187
|
-
});
|
|
5188
|
-
}
|
|
5189
|
-
async $connect() {
|
|
5190
|
-
return Promise.resolve();
|
|
5191
|
-
}
|
|
5192
|
-
$disconnect() {
|
|
5193
|
-
return Promise.resolve();
|
|
5194
|
-
}
|
|
5195
|
-
$on() {}
|
|
5196
|
-
$use() {
|
|
5197
|
-
return this;
|
|
5198
|
-
}
|
|
5199
|
-
$executeRaw() {
|
|
5200
|
-
return Promise.resolve(0);
|
|
5201
|
-
}
|
|
5202
|
-
$executeRawUnsafe() {
|
|
5203
|
-
return Promise.resolve(0);
|
|
5204
|
-
}
|
|
5205
|
-
$queryRaw() {
|
|
5206
|
-
return Promise.resolve([]);
|
|
5207
|
-
}
|
|
5208
|
-
$queryRawUnsafe() {
|
|
5209
|
-
return Promise.resolve([]);
|
|
5210
|
-
}
|
|
5211
|
-
$extends(extensionDefs) {
|
|
5212
|
-
return applyExtensions(this, extensionDefs);
|
|
5213
|
-
}
|
|
5214
|
-
async $transaction(args) {
|
|
5215
|
-
if (Array.isArray(args)) {
|
|
5216
|
-
return Promise.all(args);
|
|
5217
|
-
}
|
|
5218
|
-
return args(this);
|
|
5248
|
+
super(Prisma2);
|
|
5219
5249
|
}
|
|
5220
5250
|
};
|
|
5251
|
+
return c;
|
|
5252
|
+
}
|
|
5253
|
+
async function createPrismock() {
|
|
5254
|
+
return await Prismock.createDefault();
|
|
5255
|
+
}
|
|
5256
|
+
async function createPrismockClient(prismaModule) {
|
|
5257
|
+
return await Prismock.create(prismaModule);
|
|
5221
5258
|
}
|
|
5222
|
-
var PrismockClient = createPrismock(Prisma2);
|
|
5223
5259
|
|
|
5224
5260
|
// src/lib/prismock.ts
|
|
5261
|
+
var PrismaInternals = await import("@prisma/internals");
|
|
5262
|
+
var { getDMMF, getGenerator, getSchema } = PrismaInternals;
|
|
5225
5263
|
async function generateDMMF(schemaPath) {
|
|
5226
5264
|
const pathToModule = schemaPath ?? __require.resolve(path.resolve(process.cwd(), "prisma/schema.prisma"));
|
|
5227
5265
|
const datamodel = await getSchema(pathToModule);
|
|
@@ -5284,6 +5322,8 @@ function generateDelegates(options) {
|
|
|
5284
5322
|
export {
|
|
5285
5323
|
generatePrismockSync,
|
|
5286
5324
|
generatePrismock,
|
|
5325
|
+
createPrismockClient,
|
|
5326
|
+
createPrismockClass,
|
|
5287
5327
|
createPrismock,
|
|
5288
|
-
|
|
5328
|
+
Prismock
|
|
5289
5329
|
};
|
package/dist/lib/client.d.ts
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as runtime from '@prisma/client/runtime/library';
|
|
1
|
+
import type { PrismaClient } from '@prisma/client';
|
|
2
|
+
import type * as runtime from '@prisma/client/runtime/library';
|
|
3
3
|
import { Delegate } from './delegate';
|
|
4
4
|
import { Data } from './prismock';
|
|
5
|
+
import { type ExtensionsDefinition } from './extensions';
|
|
5
6
|
type GetData = () => Data;
|
|
6
7
|
type SetData = (data: Data) => void;
|
|
7
|
-
interface PrismockData {
|
|
8
|
+
export interface PrismockData {
|
|
8
9
|
getData: GetData;
|
|
9
10
|
setData: SetData;
|
|
10
11
|
reset: () => void;
|
|
11
12
|
}
|
|
12
13
|
export type PrismockClientType<T = PrismaClient> = T & PrismockData;
|
|
14
|
+
export declare class Prismock<PC = PrismaClient> {
|
|
15
|
+
__prismaModule: PrismaModule<PC>;
|
|
16
|
+
protected constructor(prismaModule: PrismaModule<PC>);
|
|
17
|
+
static create<PC = PrismaClient>(prismaModule: PrismaModule<PC>): Promise<PrismockClientType<PC>>;
|
|
18
|
+
static createDefault(): Promise<PrismaClient<import(".prisma").Prisma.PrismaClientOptions, never, runtime.DefaultArgs> & PrismockData>;
|
|
19
|
+
reset(): void;
|
|
20
|
+
private generate;
|
|
21
|
+
$connect(): Promise<void>;
|
|
22
|
+
$disconnect(): Promise<void>;
|
|
23
|
+
$on(): void;
|
|
24
|
+
$use(): this;
|
|
25
|
+
$executeRaw(): Promise<number>;
|
|
26
|
+
$executeRawUnsafe(): Promise<number>;
|
|
27
|
+
$queryRaw(): Promise<never[]>;
|
|
28
|
+
$queryRawUnsafe(): Promise<never[]>;
|
|
29
|
+
$extends(extensionDefs: ExtensionsDefinition): PrismaClient<import(".prisma").Prisma.PrismaClientOptions, never, runtime.DefaultArgs>;
|
|
30
|
+
$transaction(args: any): Promise<any>;
|
|
31
|
+
}
|
|
13
32
|
export declare function generateClient<T = PrismaClient>(delegates: Record<string, Delegate>, getData: GetData, setData: SetData): PrismockClientType<T>;
|
|
14
|
-
type PrismaModule = {
|
|
33
|
+
export type PrismaModule<PC = PrismaClient> = {
|
|
15
34
|
dmmf: runtime.BaseDMMF;
|
|
16
35
|
};
|
|
17
|
-
export declare function
|
|
18
|
-
export declare
|
|
36
|
+
export declare function createPrismockClass(prismaModule?: PrismaModule): Promise<typeof PrismaClient>;
|
|
37
|
+
export declare function createPrismock(): Promise<PrismaClient<import(".prisma").Prisma.PrismaClientOptions, never, runtime.DefaultArgs> & PrismockData>;
|
|
38
|
+
export declare function createPrismockClient<PC = PrismaClient>(prismaModule: PrismaModule<PC>): Promise<PrismockClientType<PC>>;
|
|
19
39
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Prisma, PrismaClient } from "@prisma/client";
|
|
1
|
+
import { Prisma, type PrismaClient } from "@prisma/client";
|
|
2
2
|
import { type DefaultArgs, type ExtendsHook } from "@prisma/client/runtime/library";
|
|
3
3
|
export declare function applyResultExtensions(client: PrismaClient, extensions: Parameters<ExtendsHook<"define", Prisma.TypeMapCb, DefaultArgs>>[0]): PrismaClient;
|
package/dist/lib/prismock.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PrismaClient } from '@prisma/client';
|
|
2
2
|
import { DMMF } from '@prisma/generator-helper';
|
|
3
|
-
import { Generator } from '@prisma/internals
|
|
3
|
+
import type { Generator } from '@prisma/internals';
|
|
4
4
|
import { Delegate, DelegateProperties, Item } from './delegate';
|
|
5
5
|
import { PrismockClientType } from './client';
|
|
6
6
|
type Options = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pkgverse/prismock",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.10",
|
|
4
4
|
"description": "A mock for PrismaClient, dedicated to unit testing.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/JQuezada0/prismock"
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"packageManager": "bun@1.2.16",
|
|
11
11
|
"type": "module",
|
|
12
|
-
"main": "dist/index.cjs",
|
|
13
|
-
"
|
|
14
|
-
"module": "dist/index.mjs",
|
|
12
|
+
"main": "./dist/index.cjs",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"module": "./dist/index.mjs",
|
|
15
15
|
"exports": {
|
|
16
|
-
"
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
17
18
|
"import": "./dist/index.mjs",
|
|
18
19
|
"require": "./dist/index.cjs",
|
|
19
|
-
"types": "./dist/index.d.ts",
|
|
20
20
|
"default": "./dist/index.mjs"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "bun build:main & bun build:module & bun build:types",
|
|
34
34
|
"build:main": "bun build src/index.ts --outfile=dist/index.cjs --format=cjs --target=node --external=@prisma/*",
|
|
35
|
-
"build:module": "bun build
|
|
35
|
+
"build:module": "bun run build.ts",
|
|
36
36
|
"build:types": "tsgo -p tsconfig.json",
|
|
37
37
|
"lint": "eslint",
|
|
38
|
-
"test": "
|
|
38
|
+
"test": "vitest",
|
|
39
39
|
"db:init": "prisma migrate dev --name init",
|
|
40
40
|
"db:reset": "bun prisma migrate reset -f",
|
|
41
|
-
"test:coverage": "
|
|
41
|
+
"test:coverage": "vitest --coverage"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@commitlint/cli": "19.8.1",
|
|
@@ -50,11 +50,12 @@
|
|
|
50
50
|
"@semantic-release/github": "11.0.5",
|
|
51
51
|
"@semantic-release/npm": "12.0.2",
|
|
52
52
|
"@semantic-release/release-notes-generator": "14.1.0",
|
|
53
|
-
"@types/
|
|
53
|
+
"@types/bun": "1.3.3",
|
|
54
54
|
"@types/node": "22.18.1",
|
|
55
55
|
"@typescript-eslint/eslint-plugin": "8.43.0",
|
|
56
56
|
"@typescript-eslint/parser": "8.43.0",
|
|
57
57
|
"@typescript/native-preview": "7.0.0-dev.20250910.1",
|
|
58
|
+
"@vitest/coverage-v8": "4.0.14",
|
|
58
59
|
"cspell": "9.2.1",
|
|
59
60
|
"cz-conventional-changelog": "3.3.0",
|
|
60
61
|
"dotenv": "17.2.2",
|
|
@@ -62,7 +63,6 @@
|
|
|
62
63
|
"eslint-config-prettier": "10.1.8",
|
|
63
64
|
"eslint-config-standard": "17.1.0",
|
|
64
65
|
"eslint-plugin-import": "2.32.0",
|
|
65
|
-
"eslint-plugin-jest": "29.1.0",
|
|
66
66
|
"eslint-plugin-n": "17.21.3",
|
|
67
67
|
"eslint-plugin-prettier": "5.5.4",
|
|
68
68
|
"eslint-plugin-promise": "7.2.1",
|
|
@@ -71,17 +71,17 @@
|
|
|
71
71
|
"fp-ts": "2.16.11",
|
|
72
72
|
"fs-jetpack": "5.1.0",
|
|
73
73
|
"husky": "9.1.7",
|
|
74
|
-
"jest": "30.1.3",
|
|
75
|
-
"jest-mock-extended": "4.0.0",
|
|
76
74
|
"lint-staged": "16.1.6",
|
|
77
75
|
"prettier": "2.8.8",
|
|
78
76
|
"prisma": "5.22.0",
|
|
77
|
+
"release-it": "19.0.6",
|
|
79
78
|
"semantic-release": "24.2.7",
|
|
80
|
-
"ts-jest": "29.4.1",
|
|
81
79
|
"ts-node": "10.9.2",
|
|
82
80
|
"ts-toolbelt": "9.6.0",
|
|
83
81
|
"tsx": "4.20.6",
|
|
84
|
-
"typescript-eslint": "8.46.0"
|
|
82
|
+
"typescript-eslint": "8.46.0",
|
|
83
|
+
"vitest": "4.0.13",
|
|
84
|
+
"vitest-mock-extended": "3.1.0"
|
|
85
85
|
},
|
|
86
86
|
"files": [
|
|
87
87
|
"dist/**/*.{cjs,mjs,d.ts}",
|