@aburi/effects-prisma 0.1.0 → 0.3.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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 kage1020
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -13,7 +13,7 @@ Recognised shapes:
13
13
  | `<client>.$transaction(...)` | `db.transaction` |
14
14
 
15
15
  Raw SQL (`$queryRaw` / `$executeRaw` / `$queryRawUnsafe` / `$executeRawUnsafe`)
16
- is intentionally **not** classified in v0.1 — statically distinguishing a read
16
+ is intentionally **not** classified today — statically distinguishing a read
17
17
  raw query from a write raw query would require SQL parsing, which is out of the
18
18
  current scope. A future revision may add it under a `medium` confidence tier.
19
19
 
@@ -37,4 +37,4 @@ import { prismaEffectsPlugin } from "@aburi/effects-prisma"
37
37
 
38
38
  ## See also
39
39
 
40
- - [`design/details/effect-plugin.md`](../../design/details/effect-plugin.md)
40
+ - [`docs/design/effect-plugin.md`](../../docs/design/effect-plugin.md)
package/dist/index.d.mts CHANGED
@@ -1,12 +1,6 @@
1
1
  import { CallCandidate, ClassifyContext, EffectClassification, EffectPlugin, ImportEdge, PluginContext } from "@aburi/types";
2
2
 
3
3
  //#region src/classify.d.ts
4
- /**
5
- * Shared derivedBy namespace. `manifest.ts` imports this same const for its
6
- * `derivedByPrefixes` entry, so the classifier's tag builder and the registry
7
- * declaration cannot drift.
8
- */
9
- declare const EFFECTS_PRISMA_DERIVED_BY_PREFIX: "effects-plugin:prisma";
10
4
  /**
11
5
  * Classify a CallCandidate against Prisma Client conventions.
12
6
  *
@@ -29,18 +23,32 @@ declare const EFFECTS_PRISMA_DERIVED_BY_PREFIX: "effects-plugin:prisma";
29
23
  */
30
24
  declare function classifyPrismaCall(call: CallCandidate, ctx: ClassifyContext): EffectClassification | null;
31
25
  //#endregion
26
+ //#region src/constants.d.ts
27
+ /**
28
+ * Package-relative plugin name. Doubles as the prefix of every thrown message, so a caught
29
+ * exception names the plugin that rejected the input. `manifest.ts` declares the same
30
+ * string as `name`.
31
+ */
32
+ declare const EFFECTS_PRISMA_PLUGIN_NAME: "effects-prisma";
33
+ /**
34
+ * Shared derivedBy namespace. `manifest.ts` imports this same const for its
35
+ * `derivedByPrefixes` entry, so the classifier's tag builder and the registry
36
+ * declaration cannot drift.
37
+ */
38
+ declare const EFFECTS_PRISMA_DERIVED_BY_PREFIX: "effects-plugin:prisma";
39
+ //#endregion
32
40
  //#region src/imports.d.ts
33
41
  /**
34
42
  * True when the file's import list contains any recognized Prisma Client module. An
35
- * empty source string on an ImportEdge is rejected: the language plugin's contract is
36
- * to emit normalized non-empty specifiers, and treating `""` as unmatched would silently
37
- * hide upstream bugs.
43
+ * empty source string on an ImportEdge is rejected by the shared guard: the language
44
+ * plugin's contract is to emit normalized non-empty specifiers, and treating `""` as
45
+ * unmatched would silently hide upstream bugs.
38
46
  *
39
- * Validation runs across every edge before the match check so ImportEdge order does
40
- * not make throw behavior non-deterministic. Using `.some()` alone would short-circuit
41
- * on the first match and never notice a broken edge that happens to sit later.
47
+ * `filePath` is required and threaded into any thrown error message so a caught
48
+ * exception in production tooling (CI logs, error reporters) points directly at the
49
+ * offending source file rather than a bare "empty source" string.
42
50
  */
43
- declare function hasPrismaImport(imports: readonly ImportEdge[]): boolean;
51
+ declare function hasPrismaImport(imports: readonly ImportEdge[], filePath: string): boolean;
44
52
  //#endregion
45
53
  //#region src/manifest.d.ts
46
54
  /**
@@ -50,12 +58,12 @@ declare function hasPrismaImport(imports: readonly ImportEdge[]): boolean;
50
58
  * The plugin returns core-owned effect ids (`db.read` / `db.write` / `db.transaction`)
51
59
  * from `classify()`; per extension-vocab.md §5.1 core vocab lives in the reserved
52
60
  * namespace and MUST NOT appear in a plugin's `provides.effects`. The plugin's own
53
- * `x-prisma:*` namespace has no v0.1 bindings — model-specific effects would sit there
61
+ * `x-prisma:*` namespace currently has no bindings — model-specific effects would sit there
54
62
  * once introduced. `derivedByPrefixes` shares its literal with the classifier's tag
55
63
  * builder so both stay in lockstep across edits.
56
64
  */
57
65
  declare const effectsPrismaManifest: {
58
- readonly $schema: "https://aburi.dev/schema/aburi.plugin.v1.json";
66
+ readonly $schema: "https://aburi.kage1020.com/schema/aburi.plugin.v1.json";
59
67
  readonly name: "effects-prisma";
60
68
  readonly version: "0.0.0";
61
69
  readonly type: "effects";
@@ -112,7 +120,7 @@ declare function isPrismaTransactionMethod(name: string): name is PrismaTransact
112
120
  */
113
121
  declare class PrismaEffectsPlugin implements EffectPlugin {
114
122
  readonly manifest: {
115
- readonly $schema: "https://aburi.dev/schema/aburi.plugin.v1.json";
123
+ readonly $schema: "https://aburi.kage1020.com/schema/aburi.plugin.v1.json";
116
124
  readonly name: "effects-prisma";
117
125
  readonly version: "0.0.0";
118
126
  readonly type: "effects";
@@ -141,5 +149,5 @@ declare class PrismaEffectsPlugin implements EffectPlugin {
141
149
  */
142
150
  declare const prismaEffectsPlugin: PrismaEffectsPlugin;
143
151
  //#endregion
144
- export { EFFECTS_PRISMA_DERIVED_BY_PREFIX, PRISMA_READ_METHODS, PRISMA_TRANSACTION_METHOD, PRISMA_WRITE_METHODS, PrismaEffectsPlugin, type PrismaReadMethod, type PrismaTransactionMethod, type PrismaWriteMethod, classifyPrismaCall, effectsPrismaManifest, hasPrismaImport, isPrismaReadMethod, isPrismaTransactionMethod, isPrismaWriteMethod, prismaEffectsPlugin };
152
+ export { EFFECTS_PRISMA_DERIVED_BY_PREFIX, EFFECTS_PRISMA_PLUGIN_NAME, PRISMA_READ_METHODS, PRISMA_TRANSACTION_METHOD, PRISMA_WRITE_METHODS, PrismaEffectsPlugin, type PrismaReadMethod, type PrismaTransactionMethod, type PrismaWriteMethod, classifyPrismaCall, effectsPrismaManifest, hasPrismaImport, isPrismaReadMethod, isPrismaTransactionMethod, isPrismaWriteMethod, prismaEffectsPlugin };
145
153
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/classify.ts","../src/imports.ts","../src/manifest.ts","../src/methods.ts","../src/plugin.ts"],"mappings":";;;;;AASA;;;cAAa,gCAAA;AAAmE;AAsBhF;;;;;;;;;;;;;;AAGuB;;;;ACDvB;ADxBgF,iBAsBhE,kBAAA,CACd,IAAA,EAAM,aAAA,EACN,GAAA,EAAK,eAAA,GACJ,oBAAA;;;;;;;;AAAoB;;;;ACDvB;iBAAgB,eAAA,CAAgB,OAA8B,WAAZ,UAAU;;;;;;ADxB5D;;;;AAAgF;AAsBhF;;;cEjBa,qBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;AFLb;;;;AAAgF;AAsBhF;;;;;cGlBM,wBAAA;AAAA,cAWA,yBAAA;AAAA,KAYM,gBAAA,WAA2B,wBAAwB;AAAA,KACnD,iBAAA,WAA4B,yBAAyB;;KAGrD,uBAAA;AAAA,cAEC,mBAAA,EAAqB,WAAW,CAAC,gBAAA;AAAA,cACjC,oBAAA,EAAsB,WAAW,CAAC,iBAAA;AAAA,cAGlC,yBAAA,EAA2B,uBAAwC;AAAA,iBAEhE,kBAAA,CAAmB,IAAA,WAAe,IAAA,IAAQ,gBAAgB;AAAA,iBAI1D,mBAAA,CAAoB,IAAA,WAAe,IAAA,IAAQ,iBAAiB;AAAA,iBAI5D,yBAAA,CAA0B,IAAA,WAAe,IAAA,IAAQ,uBAAuB;;;;;AH/CxF;;;;AAAgF;AAsBhF;;;cIXM,mBAAA,YAA+B,YAAA;EAAA,SAC1B,QAAA;IAAA;;;;;;;;;;;;;;;;EAEH,IAAA,CAAK,IAAA,EAAM,aAAA,GAAgB,OAAA;EAEjC,QAAA,CAAS,IAAA,EAAM,aAAA,EAAe,GAAA,EAAK,eAAA,GAAkB,oBAAA;AAAA;;;AFXvD;;;;;;cEwBa,mBAAA,EAAmB,mBAA4B"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/classify.ts","../src/constants.ts","../src/imports.ts","../src/manifest.ts","../src/methods.ts","../src/plugin.ts"],"mappings":";;;;;AA0BA;;;;;;;;;;;;;;AAGuB;;;;iBAHP,kBAAA,CACd,IAAA,EAAM,aAAA,EACN,GAAA,EAAK,eAAA,GACJ,oBAAA;;;;;;AAHH;;cCjBa,0BAAA;;;;;;cAOA,gCAAA;;;ADaU;;;;ACpBvB;;;;AAAmE;AAOnE;ADauB,iBEWP,eAAA,CAAgB,OAAA,WAAkB,UAAU,IAAI,QAAA;;;;;;AFdhE;;;;;;;;cGZa,qBAAA;EAAA;;;;;;;;;;;;;;;;;;;;;AHYb;;;;;;;;;;cIbM,wBAAA;AAAA,cAWA,yBAAA;AAAA,KAYM,gBAAA,WAA2B,wBAAwB;AAAA,KACnD,iBAAA,WAA4B,yBAAyB;AJR1C;AAAA,KIWX,uBAAA;AAAA,cAEC,mBAAA,EAAqB,WAAW,CAAC,gBAAA;AAAA,cACjC,oBAAA,EAAsB,WAAW,CAAC,iBAAA;AAAA,cAGlC,yBAAA,EAA2B,uBAAwC;AAAA,iBAEhE,kBAAA,CAAmB,IAAA,WAAe,IAAA,IAAQ,gBAAgB;AAAA,iBAI1D,mBAAA,CAAoB,IAAA,WAAe,IAAA,IAAQ,iBAAiB;AAAA,iBAI5D,yBAAA,CAA0B,IAAA,WAAe,IAAA,IAAQ,uBAAuB;;;;;AJ9BxF;;;;;;;;cKNM,mBAAA,YAA+B,YAAA;EAAA,SAC1B,QAAA;IAAA;;;;;;;;;;;;;;;;EAEH,IAAA,CAAK,IAAA,EAAM,aAAA,GAAgB,OAAA;EAEjC,QAAA,CAAS,IAAA,EAAM,aAAA,EAAe,GAAA,EAAK,eAAA,GAAkB,oBAAA;AAAA;;;AHevD;;;;;;cGFa,mBAAA,EAAmB,mBAA4B"}
package/dist/index.mjs CHANGED
@@ -1,3 +1,20 @@
1
+ import { assertNonEmptySegments, hasMatchingImport } from "@aburi/plugin-registry/plugin-input";
2
+
3
+ //#region src/constants.ts
4
+ /**
5
+ * Package-relative plugin name. Doubles as the prefix of every thrown message, so a caught
6
+ * exception names the plugin that rejected the input. `manifest.ts` declares the same
7
+ * string as `name`.
8
+ */
9
+ const EFFECTS_PRISMA_PLUGIN_NAME = "effects-prisma";
10
+ /**
11
+ * Shared derivedBy namespace. `manifest.ts` imports this same const for its
12
+ * `derivedByPrefixes` entry, so the classifier's tag builder and the registry
13
+ * declaration cannot drift.
14
+ */
15
+ const EFFECTS_PRISMA_DERIVED_BY_PREFIX = "effects-plugin:prisma";
16
+
17
+ //#endregion
1
18
  //#region src/imports.ts
2
19
  /**
3
20
  * npm module specifiers that expose a `PrismaClient`. Any file that pulls in one of
@@ -14,19 +31,25 @@
14
31
  */
15
32
  const PRISMA_CLIENT_MODULES_LIST = ["@prisma/client", "@prisma/client/edge"];
16
33
  const PRISMA_CLIENT_MODULES = new Set(PRISMA_CLIENT_MODULES_LIST);
34
+ /** Membership test against the closed set of Prisma Client entry points. */
35
+ function isPrismaClientModule(source) {
36
+ return PRISMA_CLIENT_MODULES.has(source);
37
+ }
17
38
  /**
18
39
  * True when the file's import list contains any recognized Prisma Client module. An
19
- * empty source string on an ImportEdge is rejected: the language plugin's contract is
20
- * to emit normalized non-empty specifiers, and treating `""` as unmatched would silently
21
- * hide upstream bugs.
40
+ * empty source string on an ImportEdge is rejected by the shared guard: the language
41
+ * plugin's contract is to emit normalized non-empty specifiers, and treating `""` as
42
+ * unmatched would silently hide upstream bugs.
22
43
  *
23
- * Validation runs across every edge before the match check so ImportEdge order does
24
- * not make throw behavior non-deterministic. Using `.some()` alone would short-circuit
25
- * on the first match and never notice a broken edge that happens to sit later.
44
+ * `filePath` is required and threaded into any thrown error message so a caught
45
+ * exception in production tooling (CI logs, error reporters) points directly at the
46
+ * offending source file rather than a bare "empty source" string.
26
47
  */
27
- function hasPrismaImport(imports) {
28
- for (const edge of imports) if (edge.source.length === 0) throw new Error("effects-prisma: ImportEdge.source is empty — language plugin emitted an unnormalized import edge");
29
- return imports.some((edge) => PRISMA_CLIENT_MODULES.has(edge.source));
48
+ function hasPrismaImport(imports, filePath) {
49
+ return hasMatchingImport(imports, {
50
+ plugin: EFFECTS_PRISMA_PLUGIN_NAME,
51
+ filePath
52
+ }, isPrismaClientModule);
30
53
  }
31
54
 
32
55
  //#endregion
@@ -81,12 +104,6 @@ function isPrismaTransactionMethod(name) {
81
104
  //#endregion
82
105
  //#region src/classify.ts
83
106
  /**
84
- * Shared derivedBy namespace. `manifest.ts` imports this same const for its
85
- * `derivedByPrefixes` entry, so the classifier's tag builder and the registry
86
- * declaration cannot drift.
87
- */
88
- const EFFECTS_PRISMA_DERIVED_BY_PREFIX = "effects-plugin:prisma";
89
- /**
90
107
  * Classify a CallCandidate against Prisma Client conventions.
91
108
  *
92
109
  * Recognition strategy:
@@ -107,9 +124,12 @@ const EFFECTS_PRISMA_DERIVED_BY_PREFIX = "effects-plugin:prisma";
107
124
  * timeout budget the core enforces (effect-plugin.md §5.1.1).
108
125
  */
109
126
  function classifyPrismaCall(call, ctx) {
110
- const parts = assertNonEmptySegments(call.target);
111
- if (!hasPrismaImport(ctx.file.imports)) return null;
112
- const method = parts.at(-1);
127
+ const origin = {
128
+ plugin: EFFECTS_PRISMA_PLUGIN_NAME,
129
+ filePath: ctx.file.path
130
+ };
131
+ const { segments: parts, last: method } = assertNonEmptySegments(call.target, origin);
132
+ if (!hasPrismaImport(ctx.file.imports, ctx.file.path)) return null;
113
133
  if (isPrismaTransactionMethod(method)) {
114
134
  if (parts.length < 2) return null;
115
135
  return {
@@ -131,19 +151,6 @@ function classifyPrismaCall(call, ctx) {
131
151
  };
132
152
  return null;
133
153
  }
134
- /**
135
- * Split `target` on `.` and reject any shape a well-formed language plugin would never
136
- * emit: an empty target, or one with an empty segment (leading, trailing, or adjacent
137
- * dots). A malformed target here would otherwise slip through the length gate and
138
- * false-classify — e.g. `"prisma..create"` has three segments and would match a write
139
- * verb — so this is the fail-fast the sibling classifiers apply at their entry points.
140
- */
141
- function assertNonEmptySegments(target) {
142
- if (target.length === 0) throw new Error("effects-prisma: CallCandidate.target is empty — language plugin emitted an unnormalized callee");
143
- const parts = target.split(".");
144
- for (const segment of parts) if (segment.length === 0) throw new Error(`effects-prisma: CallCandidate.target "${target}" has empty segment(s) — language plugin emitted an unnormalized callee`);
145
- return parts;
146
- }
147
154
 
148
155
  //#endregion
149
156
  //#region src/manifest.ts
@@ -154,13 +161,13 @@ function assertNonEmptySegments(target) {
154
161
  * The plugin returns core-owned effect ids (`db.read` / `db.write` / `db.transaction`)
155
162
  * from `classify()`; per extension-vocab.md §5.1 core vocab lives in the reserved
156
163
  * namespace and MUST NOT appear in a plugin's `provides.effects`. The plugin's own
157
- * `x-prisma:*` namespace has no v0.1 bindings — model-specific effects would sit there
164
+ * `x-prisma:*` namespace currently has no bindings — model-specific effects would sit there
158
165
  * once introduced. `derivedByPrefixes` shares its literal with the classifier's tag
159
166
  * builder so both stay in lockstep across edits.
160
167
  */
161
168
  const effectsPrismaManifest = {
162
- $schema: "https://aburi.dev/schema/aburi.plugin.v1.json",
163
- name: "effects-prisma",
169
+ $schema: "https://aburi.kage1020.com/schema/aburi.plugin.v1.json",
170
+ name: EFFECTS_PRISMA_PLUGIN_NAME,
164
171
  version: "0.0.0",
165
172
  type: "effects",
166
173
  engines: { aburi: "*" },
@@ -204,5 +211,5 @@ var PrismaEffectsPlugin = class {
204
211
  const prismaEffectsPlugin = new PrismaEffectsPlugin();
205
212
 
206
213
  //#endregion
207
- export { EFFECTS_PRISMA_DERIVED_BY_PREFIX, PRISMA_READ_METHODS, PRISMA_TRANSACTION_METHOD, PRISMA_WRITE_METHODS, PrismaEffectsPlugin, classifyPrismaCall, effectsPrismaManifest, hasPrismaImport, isPrismaReadMethod, isPrismaTransactionMethod, isPrismaWriteMethod, prismaEffectsPlugin };
214
+ export { EFFECTS_PRISMA_DERIVED_BY_PREFIX, EFFECTS_PRISMA_PLUGIN_NAME, PRISMA_READ_METHODS, PRISMA_TRANSACTION_METHOD, PRISMA_WRITE_METHODS, PrismaEffectsPlugin, classifyPrismaCall, effectsPrismaManifest, hasPrismaImport, isPrismaReadMethod, isPrismaTransactionMethod, isPrismaWriteMethod, prismaEffectsPlugin };
208
215
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/imports.ts","../src/methods.ts","../src/classify.ts","../src/manifest.ts","../src/plugin.ts"],"sourcesContent":["import type { ImportEdge } from \"@aburi/types\"\n\n/**\n * npm module specifiers that expose a `PrismaClient`. Any file that pulls in one of\n * these is treated as a Prisma consumer; files that reference the identifier without\n * importing Prisma are ignored so an unrelated `db.user.findMany()` from another ORM\n * does not get miscategorized.\n *\n * - `@prisma/client` — the default Prisma Client entry since v4.\n * - `@prisma/client/edge` — the Edge runtime entry used by Vercel Edge, Cloudflare\n * Workers, and Prisma Accelerate. Different bundle, same delegate surface.\n *\n * The set is a literal source of truth. Extending the plugin for community builds or a\n * future Prisma bundle is a table edit here.\n */\nconst PRISMA_CLIENT_MODULES_LIST = [\"@prisma/client\", \"@prisma/client/edge\"] as const\n\nexport type PrismaClientModule = (typeof PRISMA_CLIENT_MODULES_LIST)[number]\n\nexport const PRISMA_CLIENT_MODULES: ReadonlySet<PrismaClientModule> = new Set(\n PRISMA_CLIENT_MODULES_LIST,\n)\n\n/**\n * True when the file's import list contains any recognized Prisma Client module. An\n * empty source string on an ImportEdge is rejected: the language plugin's contract is\n * to emit normalized non-empty specifiers, and treating `\"\"` as unmatched would silently\n * hide upstream bugs.\n *\n * Validation runs across every edge before the match check so ImportEdge order does\n * not make throw behavior non-deterministic. Using `.some()` alone would short-circuit\n * on the first match and never notice a broken edge that happens to sit later.\n */\nexport function hasPrismaImport(imports: readonly ImportEdge[]): boolean {\n for (const edge of imports) {\n if (edge.source.length === 0) {\n throw new Error(\n \"effects-prisma: ImportEdge.source is empty — language plugin emitted an unnormalized import edge\",\n )\n }\n }\n return imports.some((edge) => (PRISMA_CLIENT_MODULES as ReadonlySet<string>).has(edge.source))\n}\n","/**\n * Prisma model delegate method vocabulary.\n *\n * Each `_LIST` is the single source of truth — the union type and the runtime `Set` are\n * both derived from it, so extending the vocabulary is a table edit in exactly one\n * place. Extending as Prisma ships new delegate methods keeps the classifier honest\n * without a code rewrite.\n *\n * Only methods that map cleanly onto core `db.read` / `db.write` vocabulary are listed.\n * Delegate helpers whose semantics do not match (metadata accessors, raw SQL escapes,\n * connection lifecycle) stay out — the plugin returns `null` for them so downstream\n * effect plugins get a chance.\n */\nconst PRISMA_READ_METHODS_LIST = [\n \"findUnique\",\n \"findUniqueOrThrow\",\n \"findFirst\",\n \"findFirstOrThrow\",\n \"findMany\",\n \"count\",\n \"aggregate\",\n \"groupBy\",\n] as const\n\nconst PRISMA_WRITE_METHODS_LIST = [\n \"create\",\n \"createMany\",\n \"createManyAndReturn\",\n \"update\",\n \"updateMany\",\n \"updateManyAndReturn\",\n \"upsert\",\n \"delete\",\n \"deleteMany\",\n] as const\n\nexport type PrismaReadMethod = (typeof PRISMA_READ_METHODS_LIST)[number]\nexport type PrismaWriteMethod = (typeof PRISMA_WRITE_METHODS_LIST)[number]\n\n/** Top-level client method: `prisma.$transaction(...)`. Not nested under a model. */\nexport type PrismaTransactionMethod = \"$transaction\"\n\nexport const PRISMA_READ_METHODS: ReadonlySet<PrismaReadMethod> = new Set(PRISMA_READ_METHODS_LIST)\nexport const PRISMA_WRITE_METHODS: ReadonlySet<PrismaWriteMethod> = new Set(\n PRISMA_WRITE_METHODS_LIST,\n)\nexport const PRISMA_TRANSACTION_METHOD: PrismaTransactionMethod = \"$transaction\"\n\nexport function isPrismaReadMethod(name: string): name is PrismaReadMethod {\n return (PRISMA_READ_METHODS as ReadonlySet<string>).has(name)\n}\n\nexport function isPrismaWriteMethod(name: string): name is PrismaWriteMethod {\n return (PRISMA_WRITE_METHODS as ReadonlySet<string>).has(name)\n}\n\nexport function isPrismaTransactionMethod(name: string): name is PrismaTransactionMethod {\n return name === PRISMA_TRANSACTION_METHOD\n}\n","import type { CallCandidate, ClassifyContext, EffectClassification } from \"@aburi/types\"\nimport { hasPrismaImport } from \"./imports\"\nimport { isPrismaReadMethod, isPrismaTransactionMethod, isPrismaWriteMethod } from \"./methods\"\n\n/**\n * Shared derivedBy namespace. `manifest.ts` imports this same const for its\n * `derivedByPrefixes` entry, so the classifier's tag builder and the registry\n * declaration cannot drift.\n */\nexport const EFFECTS_PRISMA_DERIVED_BY_PREFIX = \"effects-plugin:prisma\" as const\n\n/**\n * Classify a CallCandidate against Prisma Client conventions.\n *\n * Recognition strategy:\n * 1. The owning file must import a Prisma Client module (see `hasPrismaImport`). No\n * import → `null`, so callers can chain other effect plugins after this one.\n * 2. The target is split on `.`; the plugin looks at the trailing segments to match\n * Prisma's fixed client surface. Two shapes are accepted:\n * - `<...>.<model>.<verb>` (3+ segments) — a model delegate call. The client\n * segment stops two-segment method collisions (Express `router.create(...)`)\n * from false-classifying.\n * - `<...>.$transaction` (2+ segments) — the top-level transaction API on the\n * client itself.\n * 3. Malformed targets (empty string, adjacent / leading / trailing dots) throw — the\n * language plugin's contract is a normalized non-empty callee, so a violation\n * here is an upstream bug we surface loudly instead of silently miscategorizing.\n *\n * The function is a pure lookup — no I/O, no state, no async — matching the per-call\n * timeout budget the core enforces (effect-plugin.md §5.1.1).\n */\nexport function classifyPrismaCall(\n call: CallCandidate,\n ctx: ClassifyContext,\n): EffectClassification | null {\n // Fail-fast runs BEFORE the import gate so a malformed target throws on every file,\n // not just the ~1% that import Prisma. Ordering the other way lets the same bug\n // surface only in Prisma-consuming files and stay silent everywhere else —\n // catastrophic for reproducing upstream language-plugin bugs.\n const parts = assertNonEmptySegments(call.target)\n\n if (!hasPrismaImport(ctx.file.imports)) return null\n\n // `parts` is guaranteed non-empty by `assertNonEmptySegments`, but `at()`'s general\n // signature still widens to `string | undefined`. `.at(-1) as string` records the\n // intent without a non-null assertion (Biome disallows `!` under noNonNullAssertion).\n const method = parts.at(-1) as string\n\n if (isPrismaTransactionMethod(method)) {\n // Bare `$transaction()` (single segment) is not a Prisma call — the transaction\n // API only makes sense as a method on the client (`<client>.$transaction(...)`).\n if (parts.length < 2) return null\n return {\n effectId: \"db.transaction\",\n confidence: \"high\",\n derivedBy: `${EFFECTS_PRISMA_DERIVED_BY_PREFIX}:tx`,\n }\n }\n\n // Model delegate calls need `<client>.<model>.<verb>` to distinguish them from\n // unrelated two-segment method calls (Express `router.create(...)`, an Array's\n // hypothetical `.findMany` collision) that would otherwise false-positive in files\n // that colocate Prisma with another library.\n if (parts.length < 3) return null\n\n if (isPrismaReadMethod(method)) {\n return {\n effectId: \"db.read\",\n confidence: \"high\",\n derivedBy: `${EFFECTS_PRISMA_DERIVED_BY_PREFIX}:read`,\n }\n }\n\n if (isPrismaWriteMethod(method)) {\n return {\n effectId: \"db.write\",\n confidence: \"high\",\n derivedBy: `${EFFECTS_PRISMA_DERIVED_BY_PREFIX}:write`,\n }\n }\n\n return null\n}\n\n/**\n * A non-empty split — after `assertNonEmptySegments` runs there is guaranteed to be at\n * least one segment, so the tuple type reflects that.\n */\ntype NonEmptySegments = readonly [string, ...string[]]\n\n/**\n * Split `target` on `.` and reject any shape a well-formed language plugin would never\n * emit: an empty target, or one with an empty segment (leading, trailing, or adjacent\n * dots). A malformed target here would otherwise slip through the length gate and\n * false-classify — e.g. `\"prisma..create\"` has three segments and would match a write\n * verb — so this is the fail-fast the sibling classifiers apply at their entry points.\n */\nfunction assertNonEmptySegments(target: string): NonEmptySegments {\n if (target.length === 0) {\n throw new Error(\n \"effects-prisma: CallCandidate.target is empty — language plugin emitted an unnormalized callee\",\n )\n }\n const parts = target.split(\".\")\n for (const segment of parts) {\n if (segment.length === 0) {\n throw new Error(\n `effects-prisma: CallCandidate.target \"${target}\" has empty segment(s) — language plugin emitted an unnormalized callee`,\n )\n }\n }\n // Split of a non-empty string yields at least one segment, and the loop above ruled\n // out empty segments — the tuple assertion here reflects a proven invariant.\n return parts as unknown as NonEmptySegments\n}\n","import type { EffectsManifest } from \"@aburi/types\"\nimport { EFFECTS_PRISMA_DERIVED_BY_PREFIX } from \"./classify\"\n\n/**\n * Manifest for `@aburi/effects-prisma`. `as const satisfies EffectsManifest` keeps\n * every literal narrow so downstream registry checks see the exact shape.\n *\n * The plugin returns core-owned effect ids (`db.read` / `db.write` / `db.transaction`)\n * from `classify()`; per extension-vocab.md §5.1 core vocab lives in the reserved\n * namespace and MUST NOT appear in a plugin's `provides.effects`. The plugin's own\n * `x-prisma:*` namespace has no v0.1 bindings — model-specific effects would sit there\n * once introduced. `derivedByPrefixes` shares its literal with the classifier's tag\n * builder so both stay in lockstep across edits.\n */\nexport const effectsPrismaManifest = {\n $schema: \"https://aburi.dev/schema/aburi.plugin.v1.json\",\n name: \"effects-prisma\",\n version: \"0.0.0\",\n type: \"effects\",\n engines: { aburi: \"*\" },\n provides: {\n effects: [],\n effectPrefixes: [],\n extKinds: [],\n extKindPrefixes: [],\n derivedByPrefixes: [EFFECTS_PRISMA_DERIVED_BY_PREFIX],\n frameworks: [],\n },\n} as const satisfies EffectsManifest\n","import type {\n CallCandidate,\n ClassifyContext,\n EffectClassification,\n EffectPlugin,\n PluginContext,\n} from \"@aburi/types\"\nimport { classifyPrismaCall } from \"./classify\"\nimport { effectsPrismaManifest } from \"./manifest\"\n\n/**\n * Prisma effect plugin. Sits behind the language plugin's `walkBody` output, mapping\n * `prisma.<model>.<verb>` and `prisma.$transaction` call expressions into the core\n * `db.read` / `db.write` / `db.transaction` effect vocabulary.\n *\n * `init` and `classify` are both pure with respect to plugin state — no lazy resources,\n * no per-run caches — so repeated invocations against the same CallCandidate produce\n * identical results. This matches the per-call timeout contract in\n * effect-plugin.md §5.1.1 and the \"pure classifier\" recommendation in §11.1.\n */\nclass PrismaEffectsPlugin implements EffectPlugin {\n readonly manifest = effectsPrismaManifest\n\n async init(_ctx: PluginContext): Promise<void> {}\n\n classify(call: CallCandidate, ctx: ClassifyContext): EffectClassification | null {\n return classifyPrismaCall(call, ctx)\n }\n}\n\n/**\n * Ready-to-register instance. Callers pass this to `@aburi/plugin-registry` or a scan\n * pipeline. The type annotation is omitted deliberately: `class implements EffectPlugin`\n * already enforces the structural contract, and inferring the narrow class type keeps\n * the manifest literals (`readonly [\"effects-plugin:prisma\"]`, `\"effects-prisma\"`)\n * visible to consumers that want to compare against them without a separate manifest\n * import.\n */\nexport const prismaEffectsPlugin = new PrismaEffectsPlugin()\n\nexport { PrismaEffectsPlugin }\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,6BAA6B,CAAC,kBAAkB,qBAAqB;AAI3E,MAAa,wBAAyD,IAAI,IACxE,0BACF;;;;;;;;;;;AAYA,SAAgB,gBAAgB,SAAyC;CACvE,KAAK,MAAM,QAAQ,SACjB,IAAI,KAAK,OAAO,WAAW,GACzB,MAAM,IAAI,MACR,kGACF;CAGJ,OAAO,QAAQ,MAAM,SAAU,sBAA8C,IAAI,KAAK,MAAM,CAAC;AAC/F;;;;;;;;;;;;;;;;;AC7BA,MAAM,2BAA2B;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,4BAA4B;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAQA,MAAa,sBAAqD,IAAI,IAAI,wBAAwB;AAClG,MAAa,uBAAuD,IAAI,IACtE,yBACF;AACA,MAAa,4BAAqD;AAElE,SAAgB,mBAAmB,MAAwC;CACzE,OAAQ,oBAA4C,IAAI,IAAI;AAC9D;AAEA,SAAgB,oBAAoB,MAAyC;CAC3E,OAAQ,qBAA6C,IAAI,IAAI;AAC/D;AAEA,SAAgB,0BAA0B,MAA+C;CACvF,OAAO,SAAS;AAClB;;;;;;;;;ACjDA,MAAa,mCAAmC;;;;;;;;;;;;;;;;;;;;;AAsBhD,SAAgB,mBACd,MACA,KAC6B;CAK7B,MAAM,QAAQ,uBAAuB,KAAK,MAAM;CAEhD,IAAI,CAAC,gBAAgB,IAAI,KAAK,OAAO,GAAG,OAAO;CAK/C,MAAM,SAAS,MAAM,GAAG,EAAE;CAE1B,IAAI,0BAA0B,MAAM,GAAG;EAGrC,IAAI,MAAM,SAAS,GAAG,OAAO;EAC7B,OAAO;GACL,UAAU;GACV,YAAY;GACZ,WAAW,GAAG,iCAAiC;EACjD;CACF;CAMA,IAAI,MAAM,SAAS,GAAG,OAAO;CAE7B,IAAI,mBAAmB,MAAM,GAC3B,OAAO;EACL,UAAU;EACV,YAAY;EACZ,WAAW,GAAG,iCAAiC;CACjD;CAGF,IAAI,oBAAoB,MAAM,GAC5B,OAAO;EACL,UAAU;EACV,YAAY;EACZ,WAAW,GAAG,iCAAiC;CACjD;CAGF,OAAO;AACT;;;;;;;;AAeA,SAAS,uBAAuB,QAAkC;CAChE,IAAI,OAAO,WAAW,GACpB,MAAM,IAAI,MACR,gGACF;CAEF,MAAM,QAAQ,OAAO,MAAM,GAAG;CAC9B,KAAK,MAAM,WAAW,OACpB,IAAI,QAAQ,WAAW,GACrB,MAAM,IAAI,MACR,yCAAyC,OAAO,wEAClD;CAKJ,OAAO;AACT;;;;;;;;;;;;;;;ACpGA,MAAa,wBAAwB;CACnC,SAAS;CACT,MAAM;CACN,SAAS;CACT,MAAM;CACN,SAAS,EAAE,OAAO,IAAI;CACtB,UAAU;EACR,SAAS,CAAC;EACV,gBAAgB,CAAC;EACjB,UAAU,CAAC;EACX,iBAAiB,CAAC;EAClB,mBAAmB,CAAC,gCAAgC;EACpD,YAAY,CAAC;CACf;AACF;;;;;;;;;;;;;;ACRA,IAAM,sBAAN,MAAkD;CAChD,AAAS,WAAW;CAEpB,MAAM,KAAK,MAAoC,CAAC;CAEhD,SAAS,MAAqB,KAAmD;EAC/E,OAAO,mBAAmB,MAAM,GAAG;CACrC;AACF;;;;;;;;;AAUA,MAAa,sBAAsB,IAAI,oBAAoB"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/constants.ts","../src/imports.ts","../src/methods.ts","../src/classify.ts","../src/manifest.ts","../src/plugin.ts"],"sourcesContent":["// Plugin identity, kept in a leaf module so `classify.ts`, `imports.ts`, and `manifest.ts`\n// can all reach it without importing each other. Putting these next to the classifier\n// instead would make `imports.ts → classify.ts → imports.ts` a cycle.\n\n/**\n * Package-relative plugin name. Doubles as the prefix of every thrown message, so a caught\n * exception names the plugin that rejected the input. `manifest.ts` declares the same\n * string as `name`.\n */\nexport const EFFECTS_PRISMA_PLUGIN_NAME = \"effects-prisma\" as const\n\n/**\n * Shared derivedBy namespace. `manifest.ts` imports this same const for its\n * `derivedByPrefixes` entry, so the classifier's tag builder and the registry\n * declaration cannot drift.\n */\nexport const EFFECTS_PRISMA_DERIVED_BY_PREFIX = \"effects-plugin:prisma\" as const\n","import { hasMatchingImport } from \"@aburi/plugin-registry/plugin-input\"\nimport type { ImportEdge } from \"@aburi/types\"\nimport { EFFECTS_PRISMA_PLUGIN_NAME } from \"./constants\"\n\n/**\n * npm module specifiers that expose a `PrismaClient`. Any file that pulls in one of\n * these is treated as a Prisma consumer; files that reference the identifier without\n * importing Prisma are ignored so an unrelated `db.user.findMany()` from another ORM\n * does not get miscategorized.\n *\n * - `@prisma/client` — the default Prisma Client entry since v4.\n * - `@prisma/client/edge` — the Edge runtime entry used by Vercel Edge, Cloudflare\n * Workers, and Prisma Accelerate. Different bundle, same delegate surface.\n *\n * The set is a literal source of truth. Extending the plugin for community builds or a\n * future Prisma bundle is a table edit here.\n */\nconst PRISMA_CLIENT_MODULES_LIST = [\"@prisma/client\", \"@prisma/client/edge\"] as const\n\nexport type PrismaClientModule = (typeof PRISMA_CLIENT_MODULES_LIST)[number]\n\nexport const PRISMA_CLIENT_MODULES: ReadonlySet<PrismaClientModule> = new Set(\n PRISMA_CLIENT_MODULES_LIST,\n)\n\n/** Membership test against the closed set of Prisma Client entry points. */\nfunction isPrismaClientModule(source: string): boolean {\n return (PRISMA_CLIENT_MODULES as ReadonlySet<string>).has(source)\n}\n\n/**\n * True when the file's import list contains any recognized Prisma Client module. An\n * empty source string on an ImportEdge is rejected by the shared guard: the language\n * plugin's contract is to emit normalized non-empty specifiers, and treating `\"\"` as\n * unmatched would silently hide upstream bugs.\n *\n * `filePath` is required and threaded into any thrown error message so a caught\n * exception in production tooling (CI logs, error reporters) points directly at the\n * offending source file rather than a bare \"empty source\" string.\n */\nexport function hasPrismaImport(imports: readonly ImportEdge[], filePath: string): boolean {\n return hasMatchingImport(\n imports,\n { plugin: EFFECTS_PRISMA_PLUGIN_NAME, filePath },\n isPrismaClientModule,\n )\n}\n","/**\n * Prisma model delegate method vocabulary.\n *\n * Each `_LIST` is the single source of truth — the union type and the runtime `Set` are\n * both derived from it, so extending the vocabulary is a table edit in exactly one\n * place. Extending as Prisma ships new delegate methods keeps the classifier honest\n * without a code rewrite.\n *\n * Only methods that map cleanly onto core `db.read` / `db.write` vocabulary are listed.\n * Delegate helpers whose semantics do not match (metadata accessors, raw SQL escapes,\n * connection lifecycle) stay out — the plugin returns `null` for them so downstream\n * effect plugins get a chance.\n */\nconst PRISMA_READ_METHODS_LIST = [\n \"findUnique\",\n \"findUniqueOrThrow\",\n \"findFirst\",\n \"findFirstOrThrow\",\n \"findMany\",\n \"count\",\n \"aggregate\",\n \"groupBy\",\n] as const\n\nconst PRISMA_WRITE_METHODS_LIST = [\n \"create\",\n \"createMany\",\n \"createManyAndReturn\",\n \"update\",\n \"updateMany\",\n \"updateManyAndReturn\",\n \"upsert\",\n \"delete\",\n \"deleteMany\",\n] as const\n\nexport type PrismaReadMethod = (typeof PRISMA_READ_METHODS_LIST)[number]\nexport type PrismaWriteMethod = (typeof PRISMA_WRITE_METHODS_LIST)[number]\n\n/** Top-level client method: `prisma.$transaction(...)`. Not nested under a model. */\nexport type PrismaTransactionMethod = \"$transaction\"\n\nexport const PRISMA_READ_METHODS: ReadonlySet<PrismaReadMethod> = new Set(PRISMA_READ_METHODS_LIST)\nexport const PRISMA_WRITE_METHODS: ReadonlySet<PrismaWriteMethod> = new Set(\n PRISMA_WRITE_METHODS_LIST,\n)\nexport const PRISMA_TRANSACTION_METHOD: PrismaTransactionMethod = \"$transaction\"\n\nexport function isPrismaReadMethod(name: string): name is PrismaReadMethod {\n return (PRISMA_READ_METHODS as ReadonlySet<string>).has(name)\n}\n\nexport function isPrismaWriteMethod(name: string): name is PrismaWriteMethod {\n return (PRISMA_WRITE_METHODS as ReadonlySet<string>).has(name)\n}\n\nexport function isPrismaTransactionMethod(name: string): name is PrismaTransactionMethod {\n return name === PRISMA_TRANSACTION_METHOD\n}\n","import { assertNonEmptySegments, type PluginInputOrigin } from \"@aburi/plugin-registry/plugin-input\"\nimport type { CallCandidate, ClassifyContext, EffectClassification } from \"@aburi/types\"\nimport { EFFECTS_PRISMA_DERIVED_BY_PREFIX, EFFECTS_PRISMA_PLUGIN_NAME } from \"./constants\"\nimport { hasPrismaImport } from \"./imports\"\nimport { isPrismaReadMethod, isPrismaTransactionMethod, isPrismaWriteMethod } from \"./methods\"\n\n/**\n * Classify a CallCandidate against Prisma Client conventions.\n *\n * Recognition strategy:\n * 1. The owning file must import a Prisma Client module (see `hasPrismaImport`). No\n * import → `null`, so callers can chain other effect plugins after this one.\n * 2. The target is split on `.`; the plugin looks at the trailing segments to match\n * Prisma's fixed client surface. Two shapes are accepted:\n * - `<...>.<model>.<verb>` (3+ segments) — a model delegate call. The client\n * segment stops two-segment method collisions (Express `router.create(...)`)\n * from false-classifying.\n * - `<...>.$transaction` (2+ segments) — the top-level transaction API on the\n * client itself.\n * 3. Malformed targets (empty string, adjacent / leading / trailing dots) throw — the\n * language plugin's contract is a normalized non-empty callee, so a violation\n * here is an upstream bug we surface loudly instead of silently miscategorizing.\n *\n * The function is a pure lookup — no I/O, no state, no async — matching the per-call\n * timeout budget the core enforces (effect-plugin.md §5.1.1).\n */\nexport function classifyPrismaCall(\n call: CallCandidate,\n ctx: ClassifyContext,\n): EffectClassification | null {\n const origin: PluginInputOrigin = { plugin: EFFECTS_PRISMA_PLUGIN_NAME, filePath: ctx.file.path }\n\n // Fail-fast runs BEFORE the import gate — see `assertNonEmptySegments` for why the\n // order is load-bearing.\n const { segments: parts, last: method } = assertNonEmptySegments(call.target, origin)\n\n if (!hasPrismaImport(ctx.file.imports, ctx.file.path)) return null\n\n if (isPrismaTransactionMethod(method)) {\n // Bare `$transaction()` (single segment) is not a Prisma call — the transaction\n // API only makes sense as a method on the client (`<client>.$transaction(...)`).\n if (parts.length < 2) return null\n return {\n effectId: \"db.transaction\",\n confidence: \"high\",\n derivedBy: `${EFFECTS_PRISMA_DERIVED_BY_PREFIX}:tx`,\n }\n }\n\n // Model delegate calls need `<client>.<model>.<verb>` to distinguish them from\n // unrelated two-segment method calls (Express `router.create(...)`, an Array's\n // hypothetical `.findMany` collision) that would otherwise false-positive in files\n // that colocate Prisma with another library.\n if (parts.length < 3) return null\n\n if (isPrismaReadMethod(method)) {\n return {\n effectId: \"db.read\",\n confidence: \"high\",\n derivedBy: `${EFFECTS_PRISMA_DERIVED_BY_PREFIX}:read`,\n }\n }\n\n if (isPrismaWriteMethod(method)) {\n return {\n effectId: \"db.write\",\n confidence: \"high\",\n derivedBy: `${EFFECTS_PRISMA_DERIVED_BY_PREFIX}:write`,\n }\n }\n\n return null\n}\n","import type { EffectsManifest } from \"@aburi/types\"\nimport { EFFECTS_PRISMA_DERIVED_BY_PREFIX, EFFECTS_PRISMA_PLUGIN_NAME } from \"./constants\"\n\n/**\n * Manifest for `@aburi/effects-prisma`. `as const satisfies EffectsManifest` keeps\n * every literal narrow so downstream registry checks see the exact shape.\n *\n * The plugin returns core-owned effect ids (`db.read` / `db.write` / `db.transaction`)\n * from `classify()`; per extension-vocab.md §5.1 core vocab lives in the reserved\n * namespace and MUST NOT appear in a plugin's `provides.effects`. The plugin's own\n * `x-prisma:*` namespace currently has no bindings — model-specific effects would sit there\n * once introduced. `derivedByPrefixes` shares its literal with the classifier's tag\n * builder so both stay in lockstep across edits.\n */\nexport const effectsPrismaManifest = {\n $schema: \"https://aburi.kage1020.com/schema/aburi.plugin.v1.json\",\n name: EFFECTS_PRISMA_PLUGIN_NAME,\n version: \"0.0.0\",\n type: \"effects\",\n engines: { aburi: \"*\" },\n provides: {\n effects: [],\n effectPrefixes: [],\n extKinds: [],\n extKindPrefixes: [],\n derivedByPrefixes: [EFFECTS_PRISMA_DERIVED_BY_PREFIX],\n frameworks: [],\n },\n} as const satisfies EffectsManifest\n","import type {\n CallCandidate,\n ClassifyContext,\n EffectClassification,\n EffectPlugin,\n PluginContext,\n} from \"@aburi/types\"\nimport { classifyPrismaCall } from \"./classify\"\nimport { effectsPrismaManifest } from \"./manifest\"\n\n/**\n * Prisma effect plugin. Sits behind the language plugin's `walkBody` output, mapping\n * `prisma.<model>.<verb>` and `prisma.$transaction` call expressions into the core\n * `db.read` / `db.write` / `db.transaction` effect vocabulary.\n *\n * `init` and `classify` are both pure with respect to plugin state — no lazy resources,\n * no per-run caches — so repeated invocations against the same CallCandidate produce\n * identical results. This matches the per-call timeout contract in\n * effect-plugin.md §5.1.1 and the \"pure classifier\" recommendation in §11.1.\n */\nclass PrismaEffectsPlugin implements EffectPlugin {\n readonly manifest = effectsPrismaManifest\n\n async init(_ctx: PluginContext): Promise<void> {}\n\n classify(call: CallCandidate, ctx: ClassifyContext): EffectClassification | null {\n return classifyPrismaCall(call, ctx)\n }\n}\n\n/**\n * Ready-to-register instance. Callers pass this to `@aburi/plugin-registry` or a scan\n * pipeline. The type annotation is omitted deliberately: `class implements EffectPlugin`\n * already enforces the structural contract, and inferring the narrow class type keeps\n * the manifest literals (`readonly [\"effects-plugin:prisma\"]`, `\"effects-prisma\"`)\n * visible to consumers that want to compare against them without a separate manifest\n * import.\n */\nexport const prismaEffectsPlugin = new PrismaEffectsPlugin()\n\nexport { PrismaEffectsPlugin }\n"],"mappings":";;;;;;;;AASA,MAAa,6BAA6B;;;;;;AAO1C,MAAa,mCAAmC;;;;;;;;;;;;;;;;;ACChD,MAAM,6BAA6B,CAAC,kBAAkB,qBAAqB;AAI3E,MAAa,wBAAyD,IAAI,IACxE,0BACF;;AAGA,SAAS,qBAAqB,QAAyB;CACrD,OAAQ,sBAA8C,IAAI,MAAM;AAClE;;;;;;;;;;;AAYA,SAAgB,gBAAgB,SAAgC,UAA2B;CACzF,OAAO,kBACL,SACA;EAAE,QAAQ;EAA4B;CAAS,GAC/C,oBACF;AACF;;;;;;;;;;;;;;;;;ACjCA,MAAM,2BAA2B;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,4BAA4B;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAQA,MAAa,sBAAqD,IAAI,IAAI,wBAAwB;AAClG,MAAa,uBAAuD,IAAI,IACtE,yBACF;AACA,MAAa,4BAAqD;AAElE,SAAgB,mBAAmB,MAAwC;CACzE,OAAQ,oBAA4C,IAAI,IAAI;AAC9D;AAEA,SAAgB,oBAAoB,MAAyC;CAC3E,OAAQ,qBAA6C,IAAI,IAAI;AAC/D;AAEA,SAAgB,0BAA0B,MAA+C;CACvF,OAAO,SAAS;AAClB;;;;;;;;;;;;;;;;;;;;;;;;AChCA,SAAgB,mBACd,MACA,KAC6B;CAC7B,MAAM,SAA4B;EAAE,QAAQ;EAA4B,UAAU,IAAI,KAAK;CAAK;CAIhG,MAAM,EAAE,UAAU,OAAO,MAAM,WAAW,uBAAuB,KAAK,QAAQ,MAAM;CAEpF,IAAI,CAAC,gBAAgB,IAAI,KAAK,SAAS,IAAI,KAAK,IAAI,GAAG,OAAO;CAE9D,IAAI,0BAA0B,MAAM,GAAG;EAGrC,IAAI,MAAM,SAAS,GAAG,OAAO;EAC7B,OAAO;GACL,UAAU;GACV,YAAY;GACZ,WAAW,GAAG,iCAAiC;EACjD;CACF;CAMA,IAAI,MAAM,SAAS,GAAG,OAAO;CAE7B,IAAI,mBAAmB,MAAM,GAC3B,OAAO;EACL,UAAU;EACV,YAAY;EACZ,WAAW,GAAG,iCAAiC;CACjD;CAGF,IAAI,oBAAoB,MAAM,GAC5B,OAAO;EACL,UAAU;EACV,YAAY;EACZ,WAAW,GAAG,iCAAiC;CACjD;CAGF,OAAO;AACT;;;;;;;;;;;;;;;AC1DA,MAAa,wBAAwB;CACnC,SAAS;CACT,MAAM;CACN,SAAS;CACT,MAAM;CACN,SAAS,EAAE,OAAO,IAAI;CACtB,UAAU;EACR,SAAS,CAAC;EACV,gBAAgB,CAAC;EACjB,UAAU,CAAC;EACX,iBAAiB,CAAC;EAClB,mBAAmB,CAAC,gCAAgC;EACpD,YAAY,CAAC;CACf;AACF;;;;;;;;;;;;;;ACRA,IAAM,sBAAN,MAAkD;CAChD,AAAS,WAAW;CAEpB,MAAM,KAAK,MAAoC,CAAC;CAEhD,SAAS,MAAqB,KAAmD;EAC/E,OAAO,mBAAmB,MAAM,GAAG;CACrC;AACF;;;;;;;;;AAUA,MAAa,sBAAsB,IAAI,oBAAoB"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@aburi/effects-prisma",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Aburi Prisma effects plugin: classifies prisma.<model>.<verb> and prisma.$transaction call expressions into core db.read / db.write / db.transaction effects",
5
- "license": "MIT",
5
+ "license": "Apache-2.0",
6
6
  "author": "kage1020",
7
7
  "homepage": "https://github.com/kage1020/Aburi/tree/main/packages/effects-prisma#readme",
8
8
  "bugs": {
@@ -33,14 +33,15 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@aburi/types": "0.1.0"
36
+ "@aburi/plugin-registry": "0.3.0",
37
+ "@aburi/types": "0.3.0"
37
38
  },
38
39
  "devDependencies": {
39
40
  "@types/node": "^26.0.1",
40
41
  "tsdown": "^0.22.3",
41
42
  "typescript": "^6.0.3",
42
43
  "vitest": "^4.1.9",
43
- "@aburi/lang-typescript": "0.1.0"
44
+ "@aburi/lang-typescript": "0.3.0"
44
45
  },
45
46
  "scripts": {
46
47
  "build": "tsdown",
package/src/classify.ts CHANGED
@@ -1,14 +1,9 @@
1
+ import { assertNonEmptySegments, type PluginInputOrigin } from "@aburi/plugin-registry/plugin-input"
1
2
  import type { CallCandidate, ClassifyContext, EffectClassification } from "@aburi/types"
3
+ import { EFFECTS_PRISMA_DERIVED_BY_PREFIX, EFFECTS_PRISMA_PLUGIN_NAME } from "./constants"
2
4
  import { hasPrismaImport } from "./imports"
3
5
  import { isPrismaReadMethod, isPrismaTransactionMethod, isPrismaWriteMethod } from "./methods"
4
6
 
5
- /**
6
- * Shared derivedBy namespace. `manifest.ts` imports this same const for its
7
- * `derivedByPrefixes` entry, so the classifier's tag builder and the registry
8
- * declaration cannot drift.
9
- */
10
- export const EFFECTS_PRISMA_DERIVED_BY_PREFIX = "effects-plugin:prisma" as const
11
-
12
7
  /**
13
8
  * Classify a CallCandidate against Prisma Client conventions.
14
9
  *
@@ -33,18 +28,13 @@ export function classifyPrismaCall(
33
28
  call: CallCandidate,
34
29
  ctx: ClassifyContext,
35
30
  ): EffectClassification | null {
36
- // Fail-fast runs BEFORE the import gate so a malformed target throws on every file,
37
- // not just the ~1% that import Prisma. Ordering the other way lets the same bug
38
- // surface only in Prisma-consuming files and stay silent everywhere else —
39
- // catastrophic for reproducing upstream language-plugin bugs.
40
- const parts = assertNonEmptySegments(call.target)
31
+ const origin: PluginInputOrigin = { plugin: EFFECTS_PRISMA_PLUGIN_NAME, filePath: ctx.file.path }
41
32
 
42
- if (!hasPrismaImport(ctx.file.imports)) return null
33
+ // Fail-fast runs BEFORE the import gate — see `assertNonEmptySegments` for why the
34
+ // order is load-bearing.
35
+ const { segments: parts, last: method } = assertNonEmptySegments(call.target, origin)
43
36
 
44
- // `parts` is guaranteed non-empty by `assertNonEmptySegments`, but `at()`'s general
45
- // signature still widens to `string | undefined`. `.at(-1) as string` records the
46
- // intent without a non-null assertion (Biome disallows `!` under noNonNullAssertion).
47
- const method = parts.at(-1) as string
37
+ if (!hasPrismaImport(ctx.file.imports, ctx.file.path)) return null
48
38
 
49
39
  if (isPrismaTransactionMethod(method)) {
50
40
  // Bare `$transaction()` (single segment) is not a Prisma call — the transaction
@@ -81,35 +71,3 @@ export function classifyPrismaCall(
81
71
 
82
72
  return null
83
73
  }
84
-
85
- /**
86
- * A non-empty split — after `assertNonEmptySegments` runs there is guaranteed to be at
87
- * least one segment, so the tuple type reflects that.
88
- */
89
- type NonEmptySegments = readonly [string, ...string[]]
90
-
91
- /**
92
- * Split `target` on `.` and reject any shape a well-formed language plugin would never
93
- * emit: an empty target, or one with an empty segment (leading, trailing, or adjacent
94
- * dots). A malformed target here would otherwise slip through the length gate and
95
- * false-classify — e.g. `"prisma..create"` has three segments and would match a write
96
- * verb — so this is the fail-fast the sibling classifiers apply at their entry points.
97
- */
98
- function assertNonEmptySegments(target: string): NonEmptySegments {
99
- if (target.length === 0) {
100
- throw new Error(
101
- "effects-prisma: CallCandidate.target is empty — language plugin emitted an unnormalized callee",
102
- )
103
- }
104
- const parts = target.split(".")
105
- for (const segment of parts) {
106
- if (segment.length === 0) {
107
- throw new Error(
108
- `effects-prisma: CallCandidate.target "${target}" has empty segment(s) — language plugin emitted an unnormalized callee`,
109
- )
110
- }
111
- }
112
- // Split of a non-empty string yields at least one segment, and the loop above ruled
113
- // out empty segments — the tuple assertion here reflects a proven invariant.
114
- return parts as unknown as NonEmptySegments
115
- }
@@ -0,0 +1,17 @@
1
+ // Plugin identity, kept in a leaf module so `classify.ts`, `imports.ts`, and `manifest.ts`
2
+ // can all reach it without importing each other. Putting these next to the classifier
3
+ // instead would make `imports.ts → classify.ts → imports.ts` a cycle.
4
+
5
+ /**
6
+ * Package-relative plugin name. Doubles as the prefix of every thrown message, so a caught
7
+ * exception names the plugin that rejected the input. `manifest.ts` declares the same
8
+ * string as `name`.
9
+ */
10
+ export const EFFECTS_PRISMA_PLUGIN_NAME = "effects-prisma" as const
11
+
12
+ /**
13
+ * Shared derivedBy namespace. `manifest.ts` imports this same const for its
14
+ * `derivedByPrefixes` entry, so the classifier's tag builder and the registry
15
+ * declaration cannot drift.
16
+ */
17
+ export const EFFECTS_PRISMA_DERIVED_BY_PREFIX = "effects-plugin:prisma" as const
package/src/imports.ts CHANGED
@@ -1,4 +1,6 @@
1
+ import { hasMatchingImport } from "@aburi/plugin-registry/plugin-input"
1
2
  import type { ImportEdge } from "@aburi/types"
3
+ import { EFFECTS_PRISMA_PLUGIN_NAME } from "./constants"
2
4
 
3
5
  /**
4
6
  * npm module specifiers that expose a `PrismaClient`. Any file that pulls in one of
@@ -21,23 +23,25 @@ export const PRISMA_CLIENT_MODULES: ReadonlySet<PrismaClientModule> = new Set(
21
23
  PRISMA_CLIENT_MODULES_LIST,
22
24
  )
23
25
 
26
+ /** Membership test against the closed set of Prisma Client entry points. */
27
+ function isPrismaClientModule(source: string): boolean {
28
+ return (PRISMA_CLIENT_MODULES as ReadonlySet<string>).has(source)
29
+ }
30
+
24
31
  /**
25
32
  * True when the file's import list contains any recognized Prisma Client module. An
26
- * empty source string on an ImportEdge is rejected: the language plugin's contract is
27
- * to emit normalized non-empty specifiers, and treating `""` as unmatched would silently
28
- * hide upstream bugs.
33
+ * empty source string on an ImportEdge is rejected by the shared guard: the language
34
+ * plugin's contract is to emit normalized non-empty specifiers, and treating `""` as
35
+ * unmatched would silently hide upstream bugs.
29
36
  *
30
- * Validation runs across every edge before the match check so ImportEdge order does
31
- * not make throw behavior non-deterministic. Using `.some()` alone would short-circuit
32
- * on the first match and never notice a broken edge that happens to sit later.
37
+ * `filePath` is required and threaded into any thrown error message so a caught
38
+ * exception in production tooling (CI logs, error reporters) points directly at the
39
+ * offending source file rather than a bare "empty source" string.
33
40
  */
34
- export function hasPrismaImport(imports: readonly ImportEdge[]): boolean {
35
- for (const edge of imports) {
36
- if (edge.source.length === 0) {
37
- throw new Error(
38
- "effects-prisma: ImportEdge.source is empty — language plugin emitted an unnormalized import edge",
39
- )
40
- }
41
- }
42
- return imports.some((edge) => (PRISMA_CLIENT_MODULES as ReadonlySet<string>).has(edge.source))
41
+ export function hasPrismaImport(imports: readonly ImportEdge[], filePath: string): boolean {
42
+ return hasMatchingImport(
43
+ imports,
44
+ { plugin: EFFECTS_PRISMA_PLUGIN_NAME, filePath },
45
+ isPrismaClientModule,
46
+ )
43
47
  }
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { classifyPrismaCall, EFFECTS_PRISMA_DERIVED_BY_PREFIX } from "./classify"
1
+ export { classifyPrismaCall } from "./classify"
2
+ export { EFFECTS_PRISMA_DERIVED_BY_PREFIX, EFFECTS_PRISMA_PLUGIN_NAME } from "./constants"
2
3
  export { hasPrismaImport } from "./imports"
3
4
  export { effectsPrismaManifest } from "./manifest"
4
5
  export {
package/src/manifest.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { EffectsManifest } from "@aburi/types"
2
- import { EFFECTS_PRISMA_DERIVED_BY_PREFIX } from "./classify"
2
+ import { EFFECTS_PRISMA_DERIVED_BY_PREFIX, EFFECTS_PRISMA_PLUGIN_NAME } from "./constants"
3
3
 
4
4
  /**
5
5
  * Manifest for `@aburi/effects-prisma`. `as const satisfies EffectsManifest` keeps
@@ -8,13 +8,13 @@ import { EFFECTS_PRISMA_DERIVED_BY_PREFIX } from "./classify"
8
8
  * The plugin returns core-owned effect ids (`db.read` / `db.write` / `db.transaction`)
9
9
  * from `classify()`; per extension-vocab.md §5.1 core vocab lives in the reserved
10
10
  * namespace and MUST NOT appear in a plugin's `provides.effects`. The plugin's own
11
- * `x-prisma:*` namespace has no v0.1 bindings — model-specific effects would sit there
11
+ * `x-prisma:*` namespace currently has no bindings — model-specific effects would sit there
12
12
  * once introduced. `derivedByPrefixes` shares its literal with the classifier's tag
13
13
  * builder so both stay in lockstep across edits.
14
14
  */
15
15
  export const effectsPrismaManifest = {
16
- $schema: "https://aburi.dev/schema/aburi.plugin.v1.json",
17
- name: "effects-prisma",
16
+ $schema: "https://aburi.kage1020.com/schema/aburi.plugin.v1.json",
17
+ name: EFFECTS_PRISMA_PLUGIN_NAME,
18
18
  version: "0.0.0",
19
19
  type: "effects",
20
20
  engines: { aburi: "*" },