@aburi/effects-prisma 0.4.1 → 0.4.2

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.
Files changed (2) hide show
  1. package/dist/index.d.mts +1 -56
  2. package/package.json +7 -5
package/dist/index.d.mts CHANGED
@@ -1,53 +1,23 @@
1
1
  import { CallCandidate, ClassifyContext, Confidence, EffectClassification, EffectPlugin, ImportEdge, PluginContext } from "@aburi/types";
2
2
 
3
3
  //#region src/classify.d.ts
4
- /**
5
- * Classify a CallCandidate against Prisma Client conventions.
6
- *
7
- * Two shapes are accepted once the file imports a Prisma Client module (`hasPrismaImport`):
8
- * - `<...>.<model>.<verb>` (3+ segments) — a model delegate call. The client segment is
9
- * what separates it from two-segment collisions such as Express `router.create(...)`.
10
- * - `<...>.$transaction` (2+ segments) — the transaction API on the client itself.
11
- *
12
- * The import gate is not a receiver check: `this.cache.items.delete(key)` is a `Map` and
13
- * `session.user.update(fields)` an object, both three segments with a delegate verb in a
14
- * file that also uses Prisma. A literal first argument rules a call out — no Prisma method
15
- * takes one — and the receiver plus argument count decide the tier, downgrading rather
16
- * than dropping (`receiverConfidence`). A model addressed through brackets arrives as
17
- * `<computed>` and supplies the third segment without a model, so there the receiver must
18
- * name a client outright.
19
- *
20
- * Throws on a malformed target (`assertNonEmptySegments`): an upstream contract violation,
21
- * not a classification decision. Pure with respect to plugin state (effect-plugin.md).
22
- */
23
4
  declare function classifyPrismaCall(call: CallCandidate, ctx: ClassifyContext): EffectClassification | null;
24
5
  //#endregion
25
6
  //#region src/constants.d.ts
26
- /** Plugin name: the manifest's `name` and the prefix of every thrown message. */
27
7
  declare const EFFECTS_PRISMA_PLUGIN_NAME: "effects-prisma";
28
- /** derivedBy namespace shared by the classifier's tag builder and the manifest. */
29
8
  declare const EFFECTS_PRISMA_DERIVED_BY_PREFIX: "effects-plugin:prisma";
30
9
  //#endregion
31
10
  //#region src/imports.d.ts
32
- /** True when the file imports a Prisma Client module; see `hasMatchingImport`. */
33
11
  declare function hasPrismaImport(imports: readonly ImportEdge[], filePath: string): boolean;
34
12
  //#endregion
35
13
  //#region src/manifest.d.ts
36
- /** See `defineEffectsManifest` for why `provides` claims no vocabulary of its own. */
37
14
  declare const effectsPrismaManifest: import("@aburi/plugin-registry/plugin-input").EffectsPluginManifest<"effects-prisma", "effects-plugin:prisma">;
38
15
  //#endregion
39
16
  //#region src/methods.d.ts
40
- /**
41
- * Prisma model delegate method vocabulary. Each `_LIST` is the single source of truth for
42
- * its union type and runtime `Set`. Only methods that map onto core `db.read` / `db.write`
43
- * are listed; metadata accessors, raw SQL escapes and connection lifecycle stay out, so the
44
- * plugin returns `null` for them and downstream effect plugins get a chance.
45
- */
46
17
  declare const PRISMA_READ_METHODS_LIST: readonly ["findUnique", "findUniqueOrThrow", "findFirst", "findFirstOrThrow", "findMany", "count", "aggregate", "groupBy"];
47
18
  declare const PRISMA_WRITE_METHODS_LIST: readonly ["create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany"];
48
19
  type PrismaReadMethod = (typeof PRISMA_READ_METHODS_LIST)[number];
49
20
  type PrismaWriteMethod = (typeof PRISMA_WRITE_METHODS_LIST)[number];
50
- /** Top-level client method: `prisma.$transaction(...)`. Not nested under a model. */
51
21
  type PrismaTransactionMethod = "$transaction";
52
22
  declare const PRISMA_READ_METHODS: ReadonlySet<PrismaReadMethod>;
53
23
  declare const PRISMA_WRITE_METHODS: ReadonlySet<PrismaWriteMethod>;
@@ -57,46 +27,21 @@ declare function isPrismaWriteMethod(name: string): name is PrismaWriteMethod;
57
27
  declare function isPrismaTransactionMethod(name: string): name is PrismaTransactionMethod;
58
28
  //#endregion
59
29
  //#region src/plugin.d.ts
60
- /**
61
- * Prisma effect plugin: maps `prisma.<model>.<verb>` and `prisma.$transaction` call
62
- * expressions onto the core `db.read` / `db.write` / `db.transaction` vocabulary. `classify`
63
- * is pure (effect-plugin.md) and throws on a malformed CallCandidate — an
64
- * upstream contract violation, surfaced rather than swallowed.
65
- */
66
30
  declare class PrismaEffectsPlugin implements EffectPlugin {
67
31
  readonly manifest: import("@aburi/plugin-registry/plugin-input").EffectsPluginManifest<"effects-prisma", "effects-plugin:prisma">;
68
32
  init(_ctx: PluginContext): Promise<void>;
69
33
  classify(call: CallCandidate, ctx: ClassifyContext): EffectClassification | null;
70
34
  }
71
- /** Ready-to-register instance; left unannotated so the manifest literals stay visible. */
35
+ /** Left unannotated so the manifest literals stay visible. */
72
36
  declare const prismaEffectsPlugin: PrismaEffectsPlugin;
73
37
  //#endregion
74
38
  //#region src/receivers.d.ts
75
- /**
76
- * The words a Prisma Client binding is spelled with. The callee string is all a classifier
77
- * sees (effect-plugin.md), and matching is per word (`identifierWords`): `prisma`,
78
- * `prismaClient`, `readReplicaDb` and `_prisma` count; `cache`, `router`, `items` and
79
- * `feedback` do not. `tx` / `trx` cover the interactive-transaction callback parameter.
80
- *
81
- * Deliberately absent: `client`, which would hand an SDK's `apiClient.users.update(payload)`
82
- * — spelled exactly like a delegate call — a high-confidence `db.write`; `transaction`,
83
- * which names a domain noun (`paymentTransaction`) far more often than a client; and
84
- * `datasource`, which `identifierWords("dataSource")` splits so only the all-lowercase form
85
- * ever matched. See docs/design/effect-plugin.md.
86
- */
87
39
  declare const PRISMA_CLIENT_WORDS_LIST: readonly ["prisma", "db", "database", "orm", "tx", "trx"];
88
40
  type PrismaClientWord = (typeof PRISMA_CLIENT_WORDS_LIST)[number];
89
41
  declare const PRISMA_CLIENT_WORDS: ReadonlySet<PrismaClientWord>;
90
- /** True when `segment` spells a word this package recognizes as a Prisma client binding. */
91
42
  declare function namesPrismaClient(segment: string): boolean;
92
- /**
93
- * The most arguments a Prisma call takes before it stops looking like Prisma's own API: a
94
- * delegate method takes one options object or nothing; `$transaction(fn, { timeout })`
95
- * takes two.
96
- */
97
43
  declare const PRISMA_DELEGATE_MAX_ARGUMENTS = 1;
98
44
  declare const PRISMA_TRANSACTION_MAX_ARGUMENTS = 2;
99
- /** `receiverConfidence` under this package's client vocabulary. */
100
45
  declare function classificationConfidence(clientSegment: string | undefined, call: CallCandidate, maxArguments: number): Confidence;
101
46
  //#endregion
102
47
  export { EFFECTS_PRISMA_DERIVED_BY_PREFIX, EFFECTS_PRISMA_PLUGIN_NAME, PRISMA_CLIENT_WORDS, PRISMA_DELEGATE_MAX_ARGUMENTS, PRISMA_READ_METHODS, PRISMA_TRANSACTION_MAX_ARGUMENTS, PRISMA_TRANSACTION_METHOD, PRISMA_WRITE_METHODS, type PrismaClientWord, PrismaEffectsPlugin, type PrismaReadMethod, type PrismaTransactionMethod, type PrismaWriteMethod, classificationConfidence, classifyPrismaCall, effectsPrismaManifest, hasPrismaImport, isPrismaReadMethod, isPrismaTransactionMethod, isPrismaWriteMethod, namesPrismaClient, prismaEffectsPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aburi/effects-prisma",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
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
5
  "license": "Apache-2.0",
6
6
  "author": "kage1020",
@@ -32,16 +32,18 @@
32
32
  "access": "public"
33
33
  },
34
34
  "dependencies": {
35
- "@aburi/plugin-registry": "0.5.0",
36
- "@aburi/types": "0.5.0"
35
+ "@aburi/plugin-registry": "0.5.1",
36
+ "@aburi/types": "0.6.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^26.0.1",
40
40
  "tsdown": "^0.22.3",
41
41
  "typescript": "^6.0.3",
42
42
  "vitest": "^4.1.11",
43
- "@aburi/lang-typescript": "0.5.0",
44
- "@aburi/test-support": "0.0.1"
43
+ "@aburi/core": "0.6.0",
44
+ "@aburi/lang-typescript": "0.6.0",
45
+ "@aburi/test-harness": "0.0.1",
46
+ "@aburi/test-support": "0.0.2"
45
47
  },
46
48
  "scripts": {
47
49
  "build": "tsdown",