Skip to content

Commit 9c96643

Browse files
calvinbrewerclaude
authored andcommitted
refactor(prisma-next): consume @cipherstash/stack/adapter-kit, drop the eql/v3 graduation
The branch had graduated DOMAIN_REGISTRY / factoryForDomain / stripDomainSchema onto the public eql/v3 barrel while adapter-kit still exported the same symbols — two doors to one registry. Revert the graduation and import through adapter-kit, the seam the Drizzle and Supabase adapters already consume (PR #655 review, item 3). Also make v3Authored return a fresh descriptor per invocation so a caller mutation cannot alter later contracts (review). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 10c434b commit 9c96643

5 files changed

Lines changed: 36 additions & 37 deletions

File tree

.changeset/eql-v3-stack-domain-registry-exports.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/prisma-next/src/exports/column-types.ts

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
* `AuthoringArgRef.default`.
2626
*/
2727

28-
import {
29-
type AnyEncryptedV3Column,
30-
stripDomainSchema,
31-
types,
32-
} from '@cipherstash/stack/eql/v3'
28+
// `stripDomainSchema` is adapter-seam surface (`adapter-kit`), same import
29+
// route as the Drizzle and Supabase adapters; `types` and the column union
30+
// stay on the public authoring entry.
31+
import { stripDomainSchema } from '@cipherstash/stack/adapter-kit'
32+
import type { AnyEncryptedV3Column } from '@cipherstash/stack/eql/v3'
33+
import { types } from '@cipherstash/stack/eql/v3'
3334
import {
3435
CIPHERSTASH_BIGINT_CODEC_ID,
3536
CIPHERSTASH_BOOLEAN_CODEC_ID,
@@ -97,19 +98,25 @@ function v3Authored<C extends AnyEncryptedV3Column>(
9798
): () => V3ColumnDescriptor<C> {
9899
const probe = make('__probe__')
99100
const nativeType = probe.getEqlType()
100-
const descriptor = {
101-
codecId: toV3CodecId(stripDomainSchema(nativeType)),
102-
nativeType,
103-
typeParams: {
104-
// Narrowing assertion, mirrors ../v3/catalog.ts: `build()` widens
105-
// `cast_as` in the bundled d.ts; the value is the domain's literal.
106-
castAs: probe.build().cast_as as V3CastAs,
107-
capabilities: probe.getQueryCapabilities(),
108-
},
109-
// Narrowing assertion: runtime strings are the literals the getters
110-
// declare; `toV3CodecId` returns `string` by signature.
111-
} as V3ColumnDescriptor<C>
112-
return () => descriptor
101+
const codecId = toV3CodecId(stripDomainSchema(nativeType))
102+
// Narrowing assertion, mirrors ../v3/catalog.ts: `build()` widens
103+
// `cast_as` in the bundled d.ts; the value is the domain's literal.
104+
const castAs = probe.build().cast_as as V3CastAs
105+
const capabilities = probe.getQueryCapabilities()
106+
// A FRESH descriptor per invocation: descriptors flow into caller-owned
107+
// contract structures, so a shared instance would let one caller's
108+
// mutation alter every later contract (call-order-dependent output).
109+
return () =>
110+
({
111+
codecId,
112+
nativeType,
113+
typeParams: {
114+
castAs,
115+
capabilities: { ...capabilities },
116+
},
117+
// Narrowing assertion: runtime strings are the literals the getters
118+
// declare; `toV3CodecId` returns `string` by signature.
119+
}) as V3ColumnDescriptor<C>
113120
}
114121

115122
// Each factory has a DISTINCT return type (V3ColumnDescriptor<EncryptedXColumn>);

packages/prisma-next/src/v3/catalog.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010
* prettified transform decode would have to invert. The `eql-v3` token is a
1111
* logical version tag, NOT the operator schema.
1212
*/
13+
// The registry is adapter-seam surface (`adapter-kit`), consumed here the same
14+
// way the Drizzle and Supabase adapters consume it; the public `eql/v3` entry
15+
// stays end-user authoring API only (see stack's `adapter-kit.ts` header).
1316
import {
1417
type AnyEncryptedV3Column,
1518
DOMAIN_REGISTRY,
16-
type QueryCapabilities,
17-
type V3ColumnFactory,
18-
} from '@cipherstash/stack/eql/v3'
19+
} from '@cipherstash/stack/adapter-kit'
20+
import type { QueryCapabilities } from '@cipherstash/stack/eql/v3'
21+
22+
type V3ColumnFactory = (name: string) => AnyEncryptedV3Column
1923

2024
export type V3CastAs =
2125
| 'string'

packages/prisma-next/test/v3/catalog-invariants.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { DOMAIN_REGISTRY } from '@cipherstash/stack/eql/v3'
1+
// The domain registry is adapter-seam surface: the eql/v3 barrel no
2+
// longer exports it, so it ships from adapter-kit (the same import
3+
// route `src/v3/catalog.ts` uses).
4+
import { DOMAIN_REGISTRY } from '@cipherstash/stack/adapter-kit'
25
import { describe, expect, it } from 'vitest'
36
import {
47
EXPOSED_DOMAIN_ENTRIES,

packages/stack/src/eql/v3/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ export {
6262
EncryptedTimestampOrdOreColumn,
6363
TEXT_SEARCH_EQL_TYPE,
6464
} from './columns'
65-
export {
66-
DOMAIN_REGISTRY,
67-
factoryForDomain,
68-
stripDomainSchema,
69-
type V3ColumnFactory,
70-
} from './domain-registry'
7165
export type {
7266
AnyV3Table,
7367
ColumnsOf,

0 commit comments

Comments
 (0)