@prisma-next/sqlite 0.10.0-dev.26 → 0.10.0-dev.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -47
- package/dist/config.d.mts +18 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +36 -0
- package/dist/config.mjs.map +1 -0
- package/dist/contract-builder.d.mts +29 -0
- package/dist/contract-builder.d.mts.map +1 -0
- package/dist/contract-builder.mjs +17 -0
- package/dist/contract-builder.mjs.map +1 -0
- package/dist/control.d.mts +11 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +21 -0
- package/dist/control.mjs.map +1 -0
- package/dist/migration.d.mts +1 -0
- package/dist/migration.mjs +2 -0
- package/dist/runtime.d.mts +1 -1
- package/package.json +25 -15
- package/src/config/define-config.ts +55 -0
- package/src/contract/define-contract.ts +126 -0
- package/src/exports/config.ts +2 -0
- package/src/exports/contract-builder.ts +17 -0
- package/src/exports/control.ts +29 -0
- package/src/exports/migration.ts +1 -0
package/README.md
CHANGED
|
@@ -1,67 +1,97 @@
|
|
|
1
1
|
# @prisma-next/sqlite
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
One-package SQLite setup for Prisma Next. Install this single package to get config, runtime, contract authoring, control-plane access, and migration helpers — no reach-ins to internal packages required.
|
|
4
4
|
|
|
5
5
|
## Package Classification
|
|
6
6
|
|
|
7
7
|
- **Domain**: extensions
|
|
8
8
|
- **Layer**: adapters
|
|
9
|
-
- **
|
|
9
|
+
- **Planes**: shared (config, contract-builder), migration (control, migration), runtime (runtime)
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Quick Start
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
```typescript
|
|
14
|
+
// prisma-next.config.ts
|
|
15
|
+
import { defineConfig } from '@prisma-next/sqlite/config';
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
export default defineConfig({
|
|
18
|
+
contract: './prisma/contract.prisma',
|
|
19
|
+
db: { connection: 'path/to/app.db' },
|
|
20
|
+
});
|
|
21
|
+
```
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
```typescript
|
|
24
|
+
// prisma/contract.ts
|
|
25
|
+
import { defineContract, field, model } from '@prisma-next/sqlite/contract-builder';
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
export default defineContract({
|
|
28
|
+
models: {
|
|
29
|
+
User: model('User', { fields: { id: field.id.uuidv4() } }),
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
```
|
|
24
33
|
|
|
25
|
-
|
|
26
|
-
- Build typed SQL surface from the execution context via `sql-query-builder-new`
|
|
27
|
-
- Build ORM surface from the execution context
|
|
28
|
-
- Normalize runtime binding input (file path or `:memory:`)
|
|
29
|
-
- Lazily instantiate runtime resources on first `db.runtime()` or `db.connect(...)` call
|
|
30
|
-
- Connect the internal SQLite driver through `db.connect(...)` or from initial binding options
|
|
31
|
-
- Memoize runtime so repeated `db.runtime()` calls return one instance
|
|
34
|
+
## Exports
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
### `@prisma-next/sqlite/config`
|
|
37
|
+
|
|
38
|
+
Simplified `defineConfig` that pre-wires all SQLite internals (family, target, adapter, driver, contract providers). Accepts `contract`, `db.connection`, `extensions`, and `migrations.dir`.
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { defineConfig } from '@prisma-next/sqlite/config';
|
|
42
|
+
|
|
43
|
+
export default defineConfig({
|
|
44
|
+
contract: './prisma/contract.prisma',
|
|
45
|
+
db: { connection: 'path/to/app.db' },
|
|
46
|
+
migrations: { dir: 'migrations/app' },
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### `@prisma-next/sqlite/contract-builder`
|
|
51
|
+
|
|
52
|
+
TypeScript contract authoring DSL (`defineContract`, `field`, `model`, `rel`, …). The `defineContract` facade pre-binds `family` and `target` — callers do not pass those fields.
|
|
34
53
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
- **`@prisma-next/sql-contract`** for contract types (contract validation flows through the `ContractSerializer` SPI on the SQL family target descriptor; the `sqlite<Contract>(...)` facade wraps it)
|
|
44
|
-
|
|
45
|
-
## Architecture
|
|
46
|
-
|
|
47
|
-
```mermaid
|
|
48
|
-
flowchart TD
|
|
49
|
-
App[App Code] --> Client["sqlite(...)"]
|
|
50
|
-
Client --> Static["Roots: sql orm context stack"]
|
|
51
|
-
Client --> Lazy["runtime()"]
|
|
52
|
-
|
|
53
|
-
Lazy --> Instantiate[instantiateExecutionStack]
|
|
54
|
-
Lazy --> Bind["Resolve binding: path or :memory:"]
|
|
55
|
-
Bind --> DB["DatabaseSync via node:sqlite"]
|
|
56
|
-
Lazy --> Runtime[createRuntime]
|
|
57
|
-
|
|
58
|
-
Runtime --> Target["@prisma-next/target-sqlite"]
|
|
59
|
-
Runtime --> Adapter["@prisma-next/adapter-sqlite"]
|
|
60
|
-
Runtime --> Driver["@prisma-next/driver-sqlite"]
|
|
61
|
-
Runtime --> SqlRuntime["@prisma-next/sql-runtime"]
|
|
62
|
-
Runtime --> ExecPlane["@prisma-next/framework-components/execution"]
|
|
54
|
+
```typescript
|
|
55
|
+
import { defineContract, field, model } from '@prisma-next/sqlite/contract-builder';
|
|
56
|
+
|
|
57
|
+
export default defineContract({
|
|
58
|
+
models: {
|
|
59
|
+
User: model('User', { fields: { id: field.id.uuidv4() } }),
|
|
60
|
+
},
|
|
61
|
+
});
|
|
63
62
|
```
|
|
64
63
|
|
|
64
|
+
### `@prisma-next/sqlite/control`
|
|
65
|
+
|
|
66
|
+
Control-plane client factory. Collapses the family + target + adapter + driver wiring into a single call.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { createSqliteControlClient } from '@prisma-next/sqlite/control';
|
|
70
|
+
|
|
71
|
+
const control = createSqliteControlClient({
|
|
72
|
+
connection: 'path/to/app.db',
|
|
73
|
+
});
|
|
74
|
+
await control.dbUpdate({ migrations: { dir: 'migrations/app' } });
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### `@prisma-next/sqlite/migration`
|
|
78
|
+
|
|
79
|
+
Re-exports all migration operation helpers from `@prisma-next/target-sqlite/migration` (`Migration`, `MigrationCLI`, `createTable`, `addColumn`, `dropTable`, `createIndex`, `dropIndex`, `dropColumn`, `recreateTable`, `dataTransform`, `placeholder`, `rawSql`).
|
|
80
|
+
|
|
81
|
+
### `@prisma-next/sqlite/runtime`
|
|
82
|
+
|
|
83
|
+
Composes the SQLite execution stack and returns typed query roots (`db.sql`, `db.orm`, `db.context`, `db.stack`).
|
|
84
|
+
|
|
85
|
+
## Dependencies
|
|
86
|
+
|
|
87
|
+
This package bundles all the transitive dependencies needed for a SQLite Prisma Next project:
|
|
88
|
+
|
|
89
|
+
- `@prisma-next/target-sqlite` (target descriptor + migration surface)
|
|
90
|
+
- `@prisma-next/adapter-sqlite` (adapter descriptor)
|
|
91
|
+
- `@prisma-next/driver-sqlite` (driver descriptor)
|
|
92
|
+
- `@prisma-next/sql-contract-ts` (TypeScript contract authoring)
|
|
93
|
+
- `@prisma-next/sql-contract` (contract type definitions)
|
|
94
|
+
|
|
65
95
|
## Related Docs
|
|
66
96
|
|
|
67
97
|
- Architecture: `docs/Architecture Overview.md`
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PrismaNextConfig } from "@prisma-next/config/config-types";
|
|
2
|
+
import { ControlExtensionDescriptor } from "@prisma-next/framework-components/control";
|
|
3
|
+
|
|
4
|
+
//#region src/config/define-config.d.ts
|
|
5
|
+
interface SqliteConfigOptions {
|
|
6
|
+
readonly contract: string;
|
|
7
|
+
readonly db?: {
|
|
8
|
+
readonly connection?: string;
|
|
9
|
+
};
|
|
10
|
+
readonly extensions?: readonly ControlExtensionDescriptor<'sql', 'sqlite'>[];
|
|
11
|
+
readonly migrations?: {
|
|
12
|
+
readonly dir?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
declare function defineConfig(options: SqliteConfigOptions): PrismaNextConfig<'sql', 'sqlite'>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { type SqliteConfigOptions, defineConfig };
|
|
18
|
+
//# sourceMappingURL=config.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../src/config/define-config.ts"],"mappings":";;;;UAYiB,mBAAA;EAAA,SACN,QAAA;EAAA,SACA,EAAA;IAAA,SACE,UAAA;EAAA;EAAA,SAEF,UAAA,YAAsB,0BAAA;EAAA,SACtB,UAAA;IAAA,SACE,GAAA;EAAA;AAAA;AAAA,iBAYG,YAAA,CAAa,OAAA,EAAS,mBAAA,GAAsB,gBAAA"}
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import sqliteAdapter from "@prisma-next/adapter-sqlite/control";
|
|
2
|
+
import { defineConfig as defineConfig$1 } from "@prisma-next/config/config-types";
|
|
3
|
+
import sqliteDriver from "@prisma-next/driver-sqlite/control";
|
|
4
|
+
import sql from "@prisma-next/family-sql/control";
|
|
5
|
+
import { prismaContract } from "@prisma-next/sql-contract-psl/provider";
|
|
6
|
+
import { typescriptContractFromPath } from "@prisma-next/sql-contract-ts/config-types";
|
|
7
|
+
import sqlite from "@prisma-next/target-sqlite/control";
|
|
8
|
+
import { ifDefined } from "@prisma-next/utils/defined";
|
|
9
|
+
import { extname } from "pathe";
|
|
10
|
+
//#region src/config/define-config.ts
|
|
11
|
+
function deriveOutputPath(contractPath) {
|
|
12
|
+
const ext = extname(contractPath);
|
|
13
|
+
if (ext.length === 0) return `${contractPath}.json`;
|
|
14
|
+
return `${contractPath.slice(0, -ext.length)}.json`;
|
|
15
|
+
}
|
|
16
|
+
function defineConfig(options) {
|
|
17
|
+
const extensions = options.extensions ?? [];
|
|
18
|
+
const output = deriveOutputPath(options.contract);
|
|
19
|
+
return defineConfig$1({
|
|
20
|
+
family: sql,
|
|
21
|
+
target: sqlite,
|
|
22
|
+
adapter: sqliteAdapter,
|
|
23
|
+
driver: sqliteDriver,
|
|
24
|
+
extensionPacks: extensions,
|
|
25
|
+
contract: extname(options.contract) === ".ts" ? typescriptContractFromPath(options.contract, output) : prismaContract(options.contract, {
|
|
26
|
+
output,
|
|
27
|
+
target: sqlite
|
|
28
|
+
}),
|
|
29
|
+
...ifDefined("db", options.db),
|
|
30
|
+
...ifDefined("migrations", options.migrations)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { defineConfig };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.mjs","names":["coreDefineConfig"],"sources":["../src/config/define-config.ts"],"sourcesContent":["import sqliteAdapter from '@prisma-next/adapter-sqlite/control';\nimport type { PrismaNextConfig } from '@prisma-next/config/config-types';\nimport { defineConfig as coreDefineConfig } from '@prisma-next/config/config-types';\nimport sqliteDriver from '@prisma-next/driver-sqlite/control';\nimport sql from '@prisma-next/family-sql/control';\nimport type { ControlExtensionDescriptor } from '@prisma-next/framework-components/control';\nimport { prismaContract } from '@prisma-next/sql-contract-psl/provider';\nimport { typescriptContractFromPath } from '@prisma-next/sql-contract-ts/config-types';\nimport sqlite from '@prisma-next/target-sqlite/control';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { extname } from 'pathe';\n\nexport interface SqliteConfigOptions {\n readonly contract: string;\n readonly db?: {\n readonly connection?: string;\n };\n readonly extensions?: readonly ControlExtensionDescriptor<'sql', 'sqlite'>[];\n readonly migrations?: {\n readonly dir?: string;\n };\n}\n\nfunction deriveOutputPath(contractPath: string): string {\n const ext = extname(contractPath);\n if (ext.length === 0) {\n return `${contractPath}.json`;\n }\n return `${contractPath.slice(0, -ext.length)}.json`;\n}\n\nexport function defineConfig(options: SqliteConfigOptions): PrismaNextConfig<'sql', 'sqlite'> {\n const extensions = options.extensions ?? [];\n const output = deriveOutputPath(options.contract);\n const ext = extname(options.contract);\n\n const contractConfig =\n ext === '.ts'\n ? typescriptContractFromPath(options.contract, output)\n : prismaContract(options.contract, {\n output,\n target: sqlite,\n });\n\n return coreDefineConfig({\n family: sql,\n target: sqlite,\n adapter: sqliteAdapter,\n driver: sqliteDriver,\n extensionPacks: extensions,\n contract: contractConfig,\n ...ifDefined('db', options.db),\n ...ifDefined('migrations', options.migrations),\n });\n}\n"],"mappings":";;;;;;;;;;AAuBA,SAAS,iBAAiB,cAA8B;CACtD,MAAM,MAAM,QAAQ,aAAa;CACjC,IAAI,IAAI,WAAW,GACjB,OAAO,GAAG,aAAa;CAEzB,OAAO,GAAG,aAAa,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC;;AAG/C,SAAgB,aAAa,SAAiE;CAC5F,MAAM,aAAa,QAAQ,cAAc,EAAE;CAC3C,MAAM,SAAS,iBAAiB,QAAQ,SAAS;CAWjD,OAAOA,eAAiB;EACtB,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,gBAAgB;EAChB,UAhBU,QAAQ,QAAQ,SAGvB,KAAK,QACJ,2BAA2B,QAAQ,UAAU,OAAO,GACpD,eAAe,QAAQ,UAAU;GAC/B;GACA,QAAQ;GACT,CAAC;EASN,GAAG,UAAU,MAAM,QAAQ,GAAG;EAC9B,GAAG,UAAU,cAAc,QAAQ,WAAW;EAC/C,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ComposedAuthoringHelpers, ComposedAuthoringHelpers as ComposedAuthoringHelpers$1, ContractDefinition, ContractInput, ContractInput as ContractInput$1, ContractModelBuilder, FieldNode, ForeignKeyNode, IndexNode, ModelLike, ModelLike as ModelLike$1, ModelNode, PrimaryKeyNode, RelationNode, ScalarFieldBuilder, UniqueConstraintNode, defineContract as defineContract$1, field, model, rel } from "@prisma-next/sql-contract-ts/contract-builder";
|
|
2
|
+
import sqlFamilyPack from "@prisma-next/family-sql/pack";
|
|
3
|
+
import sqlitePack from "@prisma-next/target-sqlite/pack";
|
|
4
|
+
import { ExtensionPackRef } from "@prisma-next/framework-components/components";
|
|
5
|
+
import { StorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
6
|
+
|
|
7
|
+
//#region src/contract/define-contract.d.ts
|
|
8
|
+
type SqlFamily = typeof sqlFamilyPack;
|
|
9
|
+
type SqlitePack = typeof sqlitePack;
|
|
10
|
+
type TypesConstraint = Record<string, StorageTypeInstance>;
|
|
11
|
+
type ModelsConstraint = Record<string, ModelLike$1>;
|
|
12
|
+
type SqliteResult<Types extends TypesConstraint, Models extends ModelsConstraint, ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined, Capabilities extends Record<string, Record<string, boolean>> | undefined> = Omit<ReturnType<typeof defineContract$1<SqlFamily, SqlitePack, Types, Models, ExtensionPacks, Capabilities>>, 'target' | 'targetFamily'> & {
|
|
13
|
+
readonly target: SqlitePack['targetId'];
|
|
14
|
+
readonly targetFamily: SqlFamily['familyId'];
|
|
15
|
+
};
|
|
16
|
+
type SqliteBaseScaffold<ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined, Capabilities extends Record<string, Record<string, boolean>> | undefined> = Omit<ContractInput$1<SqlFamily, SqlitePack, Record<never, never>, Record<never, never>, ExtensionPacks, Capabilities>, 'family' | 'target' | 'types' | 'models'>;
|
|
17
|
+
type SqliteDefinition<Types extends TypesConstraint, Models extends ModelsConstraint, ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined, Capabilities extends Record<string, Record<string, boolean>> | undefined> = SqliteBaseScaffold<ExtensionPacks, Capabilities> & {
|
|
18
|
+
readonly types?: Types;
|
|
19
|
+
readonly models?: Models;
|
|
20
|
+
};
|
|
21
|
+
type SqliteScaffold<ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined, Capabilities extends Record<string, Record<string, boolean>> | undefined> = SqliteBaseScaffold<ExtensionPacks, Capabilities>;
|
|
22
|
+
declare function defineContract<const Types extends TypesConstraint = Record<never, never>, const Models extends ModelsConstraint = Record<never, never>, const ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined = undefined, const Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined>(definition: SqliteDefinition<Types, Models, ExtensionPacks, Capabilities>): SqliteResult<Types, Models, ExtensionPacks, Capabilities>;
|
|
23
|
+
declare function defineContract<const Types extends TypesConstraint = Record<never, never>, const Models extends ModelsConstraint = Record<never, never>, const ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined = undefined, const Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined>(scaffold: SqliteScaffold<ExtensionPacks, Capabilities>, factory: (helpers: ComposedAuthoringHelpers$1<SqlFamily, SqlitePack, ExtensionPacks>) => {
|
|
24
|
+
readonly types?: Types;
|
|
25
|
+
readonly models?: Models;
|
|
26
|
+
}): SqliteResult<Types, Models, ExtensionPacks, Capabilities>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { type ComposedAuthoringHelpers, type ContractDefinition, type ContractInput, type ContractModelBuilder, type FieldNode, type ForeignKeyNode, type IndexNode, type ModelLike, type ModelNode, type PrimaryKeyNode, type RelationNode, type ScalarFieldBuilder, type UniqueConstraintNode, defineContract, field, model, rel };
|
|
29
|
+
//# sourceMappingURL=contract-builder.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../src/contract/define-contract.ts"],"mappings":";;;;;;;KAWK,SAAA,UAAmB,aAAA;AAAA,KACnB,UAAA,UAAoB,UAAA;AAAA,KAEpB,eAAA,GAAkB,MAAA,SAAe,mBAAA;AAAA,KACjC,gBAAA,GAAmB,MAAA,SAAe,WAAA;AAAA,KAMlC,YAAA,eACW,eAAA,iBACC,gBAAA,yBACQ,MAAA,SAAe,gBAAA,mDACjB,MAAA,SAAe,MAAA,kCAClC,IAAA,CACF,UAAA,QACS,gBAAA,CAAmB,SAAA,EAAW,UAAA,EAAY,KAAA,EAAO,MAAA,EAAQ,cAAA,EAAgB,YAAA;EAAA,SAIzE,MAAA,EAAQ,UAAA;EAAA,SACR,YAAA,EAAc,SAAA;AAAA;AAAA,KAMpB,kBAAA,wBACoB,MAAA,SAAe,gBAAA,mDACjB,MAAA,SAAe,MAAA,kCAClC,IAAA,CACF,eAAA,CACE,SAAA,EACA,UAAA,EACA,MAAA,gBACA,MAAA,gBACA,cAAA,EACA,YAAA;AAAA,KAMC,gBAAA,eACW,eAAA,iBACC,gBAAA,yBACQ,MAAA,SAAe,gBAAA,mDACjB,MAAA,SAAe,MAAA,kCAClC,kBAAA,CAAmB,cAAA,EAAgB,YAAA;EAAA,SAC5B,KAAA,GAAQ,KAAA;EAAA,SACR,MAAA,GAAS,MAAA;AAAA;AAAA,KAIf,cAAA,wBACoB,MAAA,SAAe,gBAAA,mDACjB,MAAA,SAAe,MAAA,kCAClC,kBAAA,CAAmB,cAAA,EAAgB,YAAA;AAAA,iBAGvB,cAAA,qBACM,eAAA,GAAkB,MAAA,qCACjB,gBAAA,GAAmB,MAAA,6CAEpC,MAAA,SAAe,gBAAA,qEAEQ,MAAA,SAAe,MAAA,2CAAA,CAE1C,UAAA,EAAY,gBAAA,CAAiB,KAAA,EAAO,MAAA,EAAQ,cAAA,EAAgB,YAAA,IAC3D,YAAA,CAAa,KAAA,EAAO,MAAA,EAAQ,cAAA,EAAgB,YAAA;AAAA,iBAG/B,cAAA,qBACM,eAAA,GAAkB,MAAA,qCACjB,gBAAA,GAAmB,MAAA,6CAEpC,MAAA,SAAe,gBAAA,qEAEQ,MAAA,SAAe,MAAA,2CAAA,CAE1C,QAAA,EAAU,cAAA,CAAe,cAAA,EAAgB,YAAA,GACzC,OAAA,GAAU,OAAA,EAAS,0BAAA,CAAyB,SAAA,EAAW,UAAA,EAAY,cAAA;EAAA,SACxD,KAAA,GAAQ,KAAA;EAAA,SACR,MAAA,GAAS,MAAA;AAAA,IAEnB,YAAA,CAAa,KAAA,EAAO,MAAA,EAAQ,cAAA,EAAgB,YAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineContract as defineContract$1, field, model, rel } from "@prisma-next/sql-contract-ts/contract-builder";
|
|
2
|
+
import sqlFamilyPack from "@prisma-next/family-sql/pack";
|
|
3
|
+
import sqlitePack from "@prisma-next/target-sqlite/pack";
|
|
4
|
+
//#region src/contract/define-contract.ts
|
|
5
|
+
function defineContract(scaffold, factory) {
|
|
6
|
+
const full = {
|
|
7
|
+
...scaffold,
|
|
8
|
+
family: sqlFamilyPack,
|
|
9
|
+
target: sqlitePack
|
|
10
|
+
};
|
|
11
|
+
if (factory !== void 0) return defineContract$1(full, factory);
|
|
12
|
+
return defineContract$1(full);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { defineContract, field, model, rel };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=contract-builder.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-builder.mjs","names":["baseDefineContract"],"sources":["../src/contract/define-contract.ts"],"sourcesContent":["import sqlFamilyPack from '@prisma-next/family-sql/pack';\nimport type { ExtensionPackRef } from '@prisma-next/framework-components/components';\nimport type { StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport type {\n ComposedAuthoringHelpers,\n ContractInput,\n ModelLike,\n} from '@prisma-next/sql-contract-ts/contract-builder';\nimport { defineContract as baseDefineContract } from '@prisma-next/sql-contract-ts/contract-builder';\nimport sqlitePack from '@prisma-next/target-sqlite/pack';\n\ntype SqlFamily = typeof sqlFamilyPack;\ntype SqlitePack = typeof sqlitePack;\n\ntype TypesConstraint = Record<string, StorageTypeInstance>;\ntype ModelsConstraint = Record<string, ModelLike>;\n\n// Return type threaded with all inferred type params.\n// We override target/targetFamily via intersection to preserve the literal values\n// ('sqlite', 'sql') even when TypeScript defers conditional-type evaluation on\n// unresolved generic params.\ntype SqliteResult<\n Types extends TypesConstraint,\n Models extends ModelsConstraint,\n ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined,\n Capabilities extends Record<string, Record<string, boolean>> | undefined,\n> = Omit<\n ReturnType<\n typeof baseDefineContract<SqlFamily, SqlitePack, Types, Models, ExtensionPacks, Capabilities>\n >,\n 'target' | 'targetFamily'\n> & {\n readonly target: SqlitePack['targetId'];\n readonly targetFamily: SqlFamily['familyId'];\n};\n\n// Scaffold that carries all ContractInput fields EXCEPT family, target, types, models.\n// Built from ContractInput with concrete Record<never, never> defaults to avoid\n// the ContractInput Models constraint (which requires ContractModelBuilder, not ModelLike).\ntype SqliteBaseScaffold<\n ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined,\n Capabilities extends Record<string, Record<string, boolean>> | undefined,\n> = Omit<\n ContractInput<\n SqlFamily,\n SqlitePack,\n Record<never, never>,\n Record<never, never>,\n ExtensionPacks,\n Capabilities\n >,\n 'family' | 'target' | 'types' | 'models'\n>;\n\n// Definition form: inline types + models (uses ModelLike for models, not ContractModelBuilder)\ntype SqliteDefinition<\n Types extends TypesConstraint,\n Models extends ModelsConstraint,\n ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined,\n Capabilities extends Record<string, Record<string, boolean>> | undefined,\n> = SqliteBaseScaffold<ExtensionPacks, Capabilities> & {\n readonly types?: Types;\n readonly models?: Models;\n};\n\n// Factory form: scaffold without types/models (factory provides them)\ntype SqliteScaffold<\n ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined,\n Capabilities extends Record<string, Record<string, boolean>> | undefined,\n> = SqliteBaseScaffold<ExtensionPacks, Capabilities>;\n\n// Overload 1: definition form (models/types inline in scaffold)\nexport function defineContract<\n const Types extends TypesConstraint = Record<never, never>,\n const Models extends ModelsConstraint = Record<never, never>,\n const ExtensionPacks extends\n | Record<string, ExtensionPackRef<'sql', string>>\n | undefined = undefined,\n const Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined,\n>(\n definition: SqliteDefinition<Types, Models, ExtensionPacks, Capabilities>,\n): SqliteResult<Types, Models, ExtensionPacks, Capabilities>;\n\n// Overload 2: factory form (scaffold without models/types; factory provides them)\nexport function defineContract<\n const Types extends TypesConstraint = Record<never, never>,\n const Models extends ModelsConstraint = Record<never, never>,\n const ExtensionPacks extends\n | Record<string, ExtensionPackRef<'sql', string>>\n | undefined = undefined,\n const Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined,\n>(\n scaffold: SqliteScaffold<ExtensionPacks, Capabilities>,\n factory: (helpers: ComposedAuthoringHelpers<SqlFamily, SqlitePack, ExtensionPacks>) => {\n readonly types?: Types;\n readonly models?: Models;\n },\n): SqliteResult<Types, Models, ExtensionPacks, Capabilities>;\n\n// Implementation — the runtime type is richer than the wide impl signature;\n// as unknown is safe because every declared overload produces a SqliteResult.\nexport function defineContract(\n scaffold: Omit<ContractInput, 'family' | 'target'>,\n factory?: (helpers: ComposedAuthoringHelpers<SqlFamily, SqlitePack, undefined>) => {\n readonly types?: TypesConstraint;\n readonly models?: ModelsConstraint;\n },\n): SqliteResult<TypesConstraint, ModelsConstraint, undefined, undefined> {\n const full = {\n ...scaffold,\n family: sqlFamilyPack,\n target: sqlitePack,\n } as ContractInput;\n if (factory !== undefined) {\n return baseDefineContract(\n full,\n factory as Parameters<typeof baseDefineContract>[1],\n ) as unknown as SqliteResult<TypesConstraint, ModelsConstraint, undefined, undefined>;\n }\n return baseDefineContract(full) as unknown as SqliteResult<\n TypesConstraint,\n ModelsConstraint,\n undefined,\n undefined\n >;\n}\n"],"mappings":";;;;AAqGA,SAAgB,eACd,UACA,SAIuE;CACvE,MAAM,OAAO;EACX,GAAG;EACH,QAAQ;EACR,QAAQ;EACT;CACD,IAAI,YAAY,KAAA,GACd,OAAOA,iBACL,MACA,QACD;CAEH,OAAOA,iBAAmB,KAAK"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ControlClient, ControlClientOptions } from "@prisma-next/cli/control-api";
|
|
2
|
+
|
|
3
|
+
//#region src/exports/control.d.ts
|
|
4
|
+
interface SqliteControlClientOptions {
|
|
5
|
+
readonly connection?: string;
|
|
6
|
+
readonly extensionPacks?: ControlClientOptions['extensionPacks'];
|
|
7
|
+
}
|
|
8
|
+
declare function createSqliteControlClient(options?: SqliteControlClientOptions): ControlClient;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { type ControlClient, SqliteControlClientOptions, createSqliteControlClient };
|
|
11
|
+
//# sourceMappingURL=control.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/exports/control.ts"],"mappings":";;;UAWiB,0BAAA;EAAA,SACN,UAAA;EAAA,SACA,cAAA,GAAiB,oBAAA;AAAA;AAAA,iBAGZ,yBAAA,CAA0B,OAAA,GAAS,0BAAA,GAAkC,aAAA"}
|
package/dist/control.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import sqliteAdapter from "@prisma-next/adapter-sqlite/control";
|
|
2
|
+
import sqliteDriver from "@prisma-next/driver-sqlite/control";
|
|
3
|
+
import sql from "@prisma-next/family-sql/control";
|
|
4
|
+
import sqlite from "@prisma-next/target-sqlite/control";
|
|
5
|
+
import { ifDefined } from "@prisma-next/utils/defined";
|
|
6
|
+
import { createControlClient } from "@prisma-next/cli/control-api";
|
|
7
|
+
//#region src/exports/control.ts
|
|
8
|
+
function createSqliteControlClient(options = {}) {
|
|
9
|
+
return createControlClient({
|
|
10
|
+
family: sql,
|
|
11
|
+
target: sqlite,
|
|
12
|
+
adapter: sqliteAdapter,
|
|
13
|
+
driver: sqliteDriver,
|
|
14
|
+
...ifDefined("connection", options.connection),
|
|
15
|
+
...ifDefined("extensionPacks", options.extensionPacks)
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { createSqliteControlClient };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=control.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.mjs","names":[],"sources":["../src/exports/control.ts"],"sourcesContent":["import sqliteAdapter from '@prisma-next/adapter-sqlite/control';\nimport {\n type ControlClient,\n type ControlClientOptions,\n createControlClient,\n} from '@prisma-next/cli/control-api';\nimport sqliteDriver from '@prisma-next/driver-sqlite/control';\nimport sql from '@prisma-next/family-sql/control';\nimport sqlite from '@prisma-next/target-sqlite/control';\nimport { ifDefined } from '@prisma-next/utils/defined';\n\nexport interface SqliteControlClientOptions {\n readonly connection?: string;\n readonly extensionPacks?: ControlClientOptions['extensionPacks'];\n}\n\nexport function createSqliteControlClient(options: SqliteControlClientOptions = {}): ControlClient {\n const clientOptions: ControlClientOptions = {\n family: sql,\n target: sqlite,\n adapter: sqliteAdapter,\n driver: sqliteDriver,\n ...ifDefined('connection', options.connection),\n ...ifDefined('extensionPacks', options.extensionPacks),\n };\n return createControlClient(clientOptions);\n}\n\nexport type { ControlClient };\n"],"mappings":";;;;;;;AAgBA,SAAgB,0BAA0B,UAAsC,EAAE,EAAiB;CASjG,OAAO,oBAAoB;EAPzB,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,GAAG,UAAU,cAAc,QAAQ,WAAW;EAC9C,GAAG,UAAU,kBAAkB,QAAQ,eAAe;EAEhB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma-next/target-sqlite/migration";
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { orm } from "@prisma-next/sql-orm-client";
|
|
2
2
|
import { BindSiteParams, Declaration, ExecutionContext, ParamsFromDeclaration, PreparedStatement, Runtime, RuntimeVerifyOptions, SqlExecutionStackWithDriver, SqlMiddleware, SqlRuntimeExtensionDescriptor } from "@prisma-next/sql-runtime";
|
|
3
|
+
import { ExtractCodecTypes, SqlStorage } from "@prisma-next/sql-contract/types";
|
|
3
4
|
import { Contract } from "@prisma-next/contract/types";
|
|
4
5
|
import { Db } from "@prisma-next/sql-builder/types";
|
|
5
|
-
import { ExtractCodecTypes, SqlStorage } from "@prisma-next/sql-contract/types";
|
|
6
6
|
import { CodecTypesBase } from "@prisma-next/sql-relational-core/expression";
|
|
7
7
|
import { SqlQueryPlan } from "@prisma-next/sql-relational-core/plan";
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/sqlite",
|
|
3
|
-
"version": "0.10.0-dev.
|
|
3
|
+
"version": "0.10.0-dev.27",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "One-liner lazy SQLite client composition for Prisma Next",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/adapter-sqlite": "0.10.0-dev.
|
|
10
|
-
"@prisma-next/
|
|
11
|
-
"@prisma-next/
|
|
12
|
-
"@prisma-next/
|
|
13
|
-
"@prisma-next/
|
|
14
|
-
"@prisma-next/sql
|
|
15
|
-
"@prisma-next/
|
|
16
|
-
"@prisma-next/sql-
|
|
17
|
-
"@prisma-next/sql-
|
|
18
|
-
"@prisma-next/sql-
|
|
19
|
-
"@prisma-next/
|
|
9
|
+
"@prisma-next/adapter-sqlite": "0.10.0-dev.27",
|
|
10
|
+
"@prisma-next/cli": "0.10.0-dev.27",
|
|
11
|
+
"@prisma-next/config": "0.10.0-dev.27",
|
|
12
|
+
"@prisma-next/contract": "0.10.0-dev.27",
|
|
13
|
+
"@prisma-next/driver-sqlite": "0.10.0-dev.27",
|
|
14
|
+
"@prisma-next/family-sql": "0.10.0-dev.27",
|
|
15
|
+
"@prisma-next/framework-components": "0.10.0-dev.27",
|
|
16
|
+
"@prisma-next/sql-builder": "0.10.0-dev.27",
|
|
17
|
+
"@prisma-next/sql-contract": "0.10.0-dev.27",
|
|
18
|
+
"@prisma-next/sql-contract-psl": "0.10.0-dev.27",
|
|
19
|
+
"@prisma-next/sql-contract-ts": "0.10.0-dev.27",
|
|
20
|
+
"@prisma-next/sql-orm-client": "0.10.0-dev.27",
|
|
21
|
+
"@prisma-next/sql-relational-core": "0.10.0-dev.27",
|
|
22
|
+
"@prisma-next/sql-runtime": "0.10.0-dev.27",
|
|
23
|
+
"@prisma-next/target-sqlite": "0.10.0-dev.27",
|
|
24
|
+
"@prisma-next/utils": "0.10.0-dev.27",
|
|
25
|
+
"pathe": "^2.0.3"
|
|
20
26
|
},
|
|
21
27
|
"devDependencies": {
|
|
22
|
-
"@prisma-next/test-utils": "0.10.0-dev.
|
|
23
|
-
"@prisma-next/tsconfig": "0.10.0-dev.
|
|
24
|
-
"@prisma-next/tsdown": "0.10.0-dev.
|
|
28
|
+
"@prisma-next/test-utils": "0.10.0-dev.27",
|
|
29
|
+
"@prisma-next/tsconfig": "0.10.0-dev.27",
|
|
30
|
+
"@prisma-next/tsdown": "0.10.0-dev.27",
|
|
25
31
|
"tsdown": "0.22.0",
|
|
26
32
|
"typescript": "5.9.3",
|
|
27
33
|
"vitest": "4.1.6"
|
|
@@ -36,6 +42,10 @@
|
|
|
36
42
|
"directory": "packages/3-extensions/sqlite"
|
|
37
43
|
},
|
|
38
44
|
"exports": {
|
|
45
|
+
"./config": "./dist/config.mjs",
|
|
46
|
+
"./contract-builder": "./dist/contract-builder.mjs",
|
|
47
|
+
"./control": "./dist/control.mjs",
|
|
48
|
+
"./migration": "./dist/migration.mjs",
|
|
39
49
|
"./runtime": "./dist/runtime.mjs",
|
|
40
50
|
"./package.json": "./package.json"
|
|
41
51
|
},
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import sqliteAdapter from '@prisma-next/adapter-sqlite/control';
|
|
2
|
+
import type { PrismaNextConfig } from '@prisma-next/config/config-types';
|
|
3
|
+
import { defineConfig as coreDefineConfig } from '@prisma-next/config/config-types';
|
|
4
|
+
import sqliteDriver from '@prisma-next/driver-sqlite/control';
|
|
5
|
+
import sql from '@prisma-next/family-sql/control';
|
|
6
|
+
import type { ControlExtensionDescriptor } from '@prisma-next/framework-components/control';
|
|
7
|
+
import { prismaContract } from '@prisma-next/sql-contract-psl/provider';
|
|
8
|
+
import { typescriptContractFromPath } from '@prisma-next/sql-contract-ts/config-types';
|
|
9
|
+
import sqlite from '@prisma-next/target-sqlite/control';
|
|
10
|
+
import { ifDefined } from '@prisma-next/utils/defined';
|
|
11
|
+
import { extname } from 'pathe';
|
|
12
|
+
|
|
13
|
+
export interface SqliteConfigOptions {
|
|
14
|
+
readonly contract: string;
|
|
15
|
+
readonly db?: {
|
|
16
|
+
readonly connection?: string;
|
|
17
|
+
};
|
|
18
|
+
readonly extensions?: readonly ControlExtensionDescriptor<'sql', 'sqlite'>[];
|
|
19
|
+
readonly migrations?: {
|
|
20
|
+
readonly dir?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function deriveOutputPath(contractPath: string): string {
|
|
25
|
+
const ext = extname(contractPath);
|
|
26
|
+
if (ext.length === 0) {
|
|
27
|
+
return `${contractPath}.json`;
|
|
28
|
+
}
|
|
29
|
+
return `${contractPath.slice(0, -ext.length)}.json`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function defineConfig(options: SqliteConfigOptions): PrismaNextConfig<'sql', 'sqlite'> {
|
|
33
|
+
const extensions = options.extensions ?? [];
|
|
34
|
+
const output = deriveOutputPath(options.contract);
|
|
35
|
+
const ext = extname(options.contract);
|
|
36
|
+
|
|
37
|
+
const contractConfig =
|
|
38
|
+
ext === '.ts'
|
|
39
|
+
? typescriptContractFromPath(options.contract, output)
|
|
40
|
+
: prismaContract(options.contract, {
|
|
41
|
+
output,
|
|
42
|
+
target: sqlite,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return coreDefineConfig({
|
|
46
|
+
family: sql,
|
|
47
|
+
target: sqlite,
|
|
48
|
+
adapter: sqliteAdapter,
|
|
49
|
+
driver: sqliteDriver,
|
|
50
|
+
extensionPacks: extensions,
|
|
51
|
+
contract: contractConfig,
|
|
52
|
+
...ifDefined('db', options.db),
|
|
53
|
+
...ifDefined('migrations', options.migrations),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import sqlFamilyPack from '@prisma-next/family-sql/pack';
|
|
2
|
+
import type { ExtensionPackRef } from '@prisma-next/framework-components/components';
|
|
3
|
+
import type { StorageTypeInstance } from '@prisma-next/sql-contract/types';
|
|
4
|
+
import type {
|
|
5
|
+
ComposedAuthoringHelpers,
|
|
6
|
+
ContractInput,
|
|
7
|
+
ModelLike,
|
|
8
|
+
} from '@prisma-next/sql-contract-ts/contract-builder';
|
|
9
|
+
import { defineContract as baseDefineContract } from '@prisma-next/sql-contract-ts/contract-builder';
|
|
10
|
+
import sqlitePack from '@prisma-next/target-sqlite/pack';
|
|
11
|
+
|
|
12
|
+
type SqlFamily = typeof sqlFamilyPack;
|
|
13
|
+
type SqlitePack = typeof sqlitePack;
|
|
14
|
+
|
|
15
|
+
type TypesConstraint = Record<string, StorageTypeInstance>;
|
|
16
|
+
type ModelsConstraint = Record<string, ModelLike>;
|
|
17
|
+
|
|
18
|
+
// Return type threaded with all inferred type params.
|
|
19
|
+
// We override target/targetFamily via intersection to preserve the literal values
|
|
20
|
+
// ('sqlite', 'sql') even when TypeScript defers conditional-type evaluation on
|
|
21
|
+
// unresolved generic params.
|
|
22
|
+
type SqliteResult<
|
|
23
|
+
Types extends TypesConstraint,
|
|
24
|
+
Models extends ModelsConstraint,
|
|
25
|
+
ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined,
|
|
26
|
+
Capabilities extends Record<string, Record<string, boolean>> | undefined,
|
|
27
|
+
> = Omit<
|
|
28
|
+
ReturnType<
|
|
29
|
+
typeof baseDefineContract<SqlFamily, SqlitePack, Types, Models, ExtensionPacks, Capabilities>
|
|
30
|
+
>,
|
|
31
|
+
'target' | 'targetFamily'
|
|
32
|
+
> & {
|
|
33
|
+
readonly target: SqlitePack['targetId'];
|
|
34
|
+
readonly targetFamily: SqlFamily['familyId'];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Scaffold that carries all ContractInput fields EXCEPT family, target, types, models.
|
|
38
|
+
// Built from ContractInput with concrete Record<never, never> defaults to avoid
|
|
39
|
+
// the ContractInput Models constraint (which requires ContractModelBuilder, not ModelLike).
|
|
40
|
+
type SqliteBaseScaffold<
|
|
41
|
+
ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined,
|
|
42
|
+
Capabilities extends Record<string, Record<string, boolean>> | undefined,
|
|
43
|
+
> = Omit<
|
|
44
|
+
ContractInput<
|
|
45
|
+
SqlFamily,
|
|
46
|
+
SqlitePack,
|
|
47
|
+
Record<never, never>,
|
|
48
|
+
Record<never, never>,
|
|
49
|
+
ExtensionPacks,
|
|
50
|
+
Capabilities
|
|
51
|
+
>,
|
|
52
|
+
'family' | 'target' | 'types' | 'models'
|
|
53
|
+
>;
|
|
54
|
+
|
|
55
|
+
// Definition form: inline types + models (uses ModelLike for models, not ContractModelBuilder)
|
|
56
|
+
type SqliteDefinition<
|
|
57
|
+
Types extends TypesConstraint,
|
|
58
|
+
Models extends ModelsConstraint,
|
|
59
|
+
ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined,
|
|
60
|
+
Capabilities extends Record<string, Record<string, boolean>> | undefined,
|
|
61
|
+
> = SqliteBaseScaffold<ExtensionPacks, Capabilities> & {
|
|
62
|
+
readonly types?: Types;
|
|
63
|
+
readonly models?: Models;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Factory form: scaffold without types/models (factory provides them)
|
|
67
|
+
type SqliteScaffold<
|
|
68
|
+
ExtensionPacks extends Record<string, ExtensionPackRef<'sql', string>> | undefined,
|
|
69
|
+
Capabilities extends Record<string, Record<string, boolean>> | undefined,
|
|
70
|
+
> = SqliteBaseScaffold<ExtensionPacks, Capabilities>;
|
|
71
|
+
|
|
72
|
+
// Overload 1: definition form (models/types inline in scaffold)
|
|
73
|
+
export function defineContract<
|
|
74
|
+
const Types extends TypesConstraint = Record<never, never>,
|
|
75
|
+
const Models extends ModelsConstraint = Record<never, never>,
|
|
76
|
+
const ExtensionPacks extends
|
|
77
|
+
| Record<string, ExtensionPackRef<'sql', string>>
|
|
78
|
+
| undefined = undefined,
|
|
79
|
+
const Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined,
|
|
80
|
+
>(
|
|
81
|
+
definition: SqliteDefinition<Types, Models, ExtensionPacks, Capabilities>,
|
|
82
|
+
): SqliteResult<Types, Models, ExtensionPacks, Capabilities>;
|
|
83
|
+
|
|
84
|
+
// Overload 2: factory form (scaffold without models/types; factory provides them)
|
|
85
|
+
export function defineContract<
|
|
86
|
+
const Types extends TypesConstraint = Record<never, never>,
|
|
87
|
+
const Models extends ModelsConstraint = Record<never, never>,
|
|
88
|
+
const ExtensionPacks extends
|
|
89
|
+
| Record<string, ExtensionPackRef<'sql', string>>
|
|
90
|
+
| undefined = undefined,
|
|
91
|
+
const Capabilities extends Record<string, Record<string, boolean>> | undefined = undefined,
|
|
92
|
+
>(
|
|
93
|
+
scaffold: SqliteScaffold<ExtensionPacks, Capabilities>,
|
|
94
|
+
factory: (helpers: ComposedAuthoringHelpers<SqlFamily, SqlitePack, ExtensionPacks>) => {
|
|
95
|
+
readonly types?: Types;
|
|
96
|
+
readonly models?: Models;
|
|
97
|
+
},
|
|
98
|
+
): SqliteResult<Types, Models, ExtensionPacks, Capabilities>;
|
|
99
|
+
|
|
100
|
+
// Implementation — the runtime type is richer than the wide impl signature;
|
|
101
|
+
// as unknown is safe because every declared overload produces a SqliteResult.
|
|
102
|
+
export function defineContract(
|
|
103
|
+
scaffold: Omit<ContractInput, 'family' | 'target'>,
|
|
104
|
+
factory?: (helpers: ComposedAuthoringHelpers<SqlFamily, SqlitePack, undefined>) => {
|
|
105
|
+
readonly types?: TypesConstraint;
|
|
106
|
+
readonly models?: ModelsConstraint;
|
|
107
|
+
},
|
|
108
|
+
): SqliteResult<TypesConstraint, ModelsConstraint, undefined, undefined> {
|
|
109
|
+
const full = {
|
|
110
|
+
...scaffold,
|
|
111
|
+
family: sqlFamilyPack,
|
|
112
|
+
target: sqlitePack,
|
|
113
|
+
} as ContractInput;
|
|
114
|
+
if (factory !== undefined) {
|
|
115
|
+
return baseDefineContract(
|
|
116
|
+
full,
|
|
117
|
+
factory as Parameters<typeof baseDefineContract>[1],
|
|
118
|
+
) as unknown as SqliteResult<TypesConstraint, ModelsConstraint, undefined, undefined>;
|
|
119
|
+
}
|
|
120
|
+
return baseDefineContract(full) as unknown as SqliteResult<
|
|
121
|
+
TypesConstraint,
|
|
122
|
+
ModelsConstraint,
|
|
123
|
+
undefined,
|
|
124
|
+
undefined
|
|
125
|
+
>;
|
|
126
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
ComposedAuthoringHelpers,
|
|
3
|
+
ContractDefinition,
|
|
4
|
+
ContractInput,
|
|
5
|
+
ContractModelBuilder,
|
|
6
|
+
FieldNode,
|
|
7
|
+
ForeignKeyNode,
|
|
8
|
+
IndexNode,
|
|
9
|
+
ModelLike,
|
|
10
|
+
ModelNode,
|
|
11
|
+
PrimaryKeyNode,
|
|
12
|
+
RelationNode,
|
|
13
|
+
ScalarFieldBuilder,
|
|
14
|
+
UniqueConstraintNode,
|
|
15
|
+
} from '@prisma-next/sql-contract-ts/contract-builder';
|
|
16
|
+
export { field, model, rel } from '@prisma-next/sql-contract-ts/contract-builder';
|
|
17
|
+
export { defineContract } from '../contract/define-contract';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import sqliteAdapter from '@prisma-next/adapter-sqlite/control';
|
|
2
|
+
import {
|
|
3
|
+
type ControlClient,
|
|
4
|
+
type ControlClientOptions,
|
|
5
|
+
createControlClient,
|
|
6
|
+
} from '@prisma-next/cli/control-api';
|
|
7
|
+
import sqliteDriver from '@prisma-next/driver-sqlite/control';
|
|
8
|
+
import sql from '@prisma-next/family-sql/control';
|
|
9
|
+
import sqlite from '@prisma-next/target-sqlite/control';
|
|
10
|
+
import { ifDefined } from '@prisma-next/utils/defined';
|
|
11
|
+
|
|
12
|
+
export interface SqliteControlClientOptions {
|
|
13
|
+
readonly connection?: string;
|
|
14
|
+
readonly extensionPacks?: ControlClientOptions['extensionPacks'];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function createSqliteControlClient(options: SqliteControlClientOptions = {}): ControlClient {
|
|
18
|
+
const clientOptions: ControlClientOptions = {
|
|
19
|
+
family: sql,
|
|
20
|
+
target: sqlite,
|
|
21
|
+
adapter: sqliteAdapter,
|
|
22
|
+
driver: sqliteDriver,
|
|
23
|
+
...ifDefined('connection', options.connection),
|
|
24
|
+
...ifDefined('extensionPacks', options.extensionPacks),
|
|
25
|
+
};
|
|
26
|
+
return createControlClient(clientOptions);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type { ControlClient };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@prisma-next/target-sqlite/migration';
|