@prisma-next/target-postgres 0.0.1
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 +62 -0
- package/dist/exports/control.d.ts +8 -0
- package/dist/exports/control.js +55 -0
- package/dist/exports/control.js.map +1 -0
- package/dist/exports/runtime.d.ts +13 -0
- package/dist/exports/runtime.js +55 -0
- package/dist/exports/runtime.js.map +1 -0
- package/package.json +42 -0
- package/packs/manifest.json +10 -0
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @prisma-next/target-postgres
|
|
2
|
+
|
|
3
|
+
Postgres target pack for Prisma Next.
|
|
4
|
+
|
|
5
|
+
## Package Classification
|
|
6
|
+
|
|
7
|
+
- **Domain**: extensions
|
|
8
|
+
- **Layer**: targets
|
|
9
|
+
- **Plane**: multi-plane (migration, runtime)
|
|
10
|
+
|
|
11
|
+
## Purpose
|
|
12
|
+
|
|
13
|
+
Provides the Postgres target descriptor (`TargetDescriptor`) for CLI config. The target descriptor includes the target manifest with capabilities and type information.
|
|
14
|
+
|
|
15
|
+
## Responsibilities
|
|
16
|
+
|
|
17
|
+
- **Target Descriptor Export**: Exports the Postgres `TargetDescriptor` for use in CLI configuration files
|
|
18
|
+
- **Manifest Loading**: Loads the Postgres target manifest from `packs/manifest.json` with capabilities and type information
|
|
19
|
+
- **Multi-Plane Support**: Provides both migration-plane (CLI) and runtime-plane entry points for the Postgres target
|
|
20
|
+
|
|
21
|
+
This package spans multiple planes:
|
|
22
|
+
- **Migration plane** (`src/exports/cli.ts`): CLI entry point that exports `TargetDescriptor` for config files
|
|
23
|
+
- **Runtime plane** (`src/exports/runtime.ts`): Runtime entry point for target-specific runtime code (future)
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Migration Plane (CLI)
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import postgres from '@prisma-next/target-postgres/control';
|
|
31
|
+
|
|
32
|
+
// postgres is a TargetDescriptor with:
|
|
33
|
+
// - kind: 'target'
|
|
34
|
+
// - id: 'postgres'
|
|
35
|
+
// - family: 'sql'
|
|
36
|
+
// - manifest: ExtensionPackManifest
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Runtime Plane
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// Runtime entry point (future)
|
|
43
|
+
import { ... } from '@prisma-next/target-postgres/runtime';
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Architecture
|
|
47
|
+
|
|
48
|
+
This package provides both CLI and runtime entry points for the Postgres target. The CLI entry point loads the target manifest from `packs/manifest.json` and exports it as a `TargetDescriptor`. The runtime entry point will provide target-specific runtime functionality in the future.
|
|
49
|
+
|
|
50
|
+
## Dependencies
|
|
51
|
+
|
|
52
|
+
- **`@prisma-next/cli`**: CLI descriptor types (`TargetDescriptor`, `ExtensionPackManifest`)
|
|
53
|
+
- **`arktype`**: Runtime validation
|
|
54
|
+
|
|
55
|
+
**Dependents:**
|
|
56
|
+
- CLI configuration files import this package to register the Postgres target
|
|
57
|
+
|
|
58
|
+
## Exports
|
|
59
|
+
|
|
60
|
+
- `./cli`: Migration entry point for `TargetDescriptor`
|
|
61
|
+
- `./runtime`: Runtime entry point for target-specific runtime code (future)
|
|
62
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ControlTargetDescriptor, ControlTargetInstance } from '@prisma-next/core-control-plane/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Postgres target descriptor for CLI config.
|
|
5
|
+
*/
|
|
6
|
+
declare const postgresTargetDescriptor: ControlTargetDescriptor<'sql', 'postgres', ControlTargetInstance<'sql', 'postgres'>>;
|
|
7
|
+
|
|
8
|
+
export { postgresTargetDescriptor as default };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// src/exports/control.ts
|
|
2
|
+
import { readFileSync } from "fs";
|
|
3
|
+
import { dirname, join } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { type } from "arktype";
|
|
6
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
var __dirname = dirname(__filename);
|
|
8
|
+
var TypesImportSpecSchema = type({
|
|
9
|
+
package: "string",
|
|
10
|
+
named: "string",
|
|
11
|
+
alias: "string"
|
|
12
|
+
});
|
|
13
|
+
var ExtensionPackManifestSchema = type({
|
|
14
|
+
id: "string",
|
|
15
|
+
version: "string",
|
|
16
|
+
"targets?": type({ "[string]": type({ "minVersion?": "string" }) }),
|
|
17
|
+
"capabilities?": "Record<string, unknown>",
|
|
18
|
+
"types?": type({
|
|
19
|
+
"codecTypes?": type({
|
|
20
|
+
import: TypesImportSpecSchema
|
|
21
|
+
}),
|
|
22
|
+
"operationTypes?": type({
|
|
23
|
+
import: TypesImportSpecSchema
|
|
24
|
+
})
|
|
25
|
+
}),
|
|
26
|
+
"operations?": "unknown[]"
|
|
27
|
+
});
|
|
28
|
+
function loadTargetManifest() {
|
|
29
|
+
const manifestPath = join(__dirname, "../../packs/manifest.json");
|
|
30
|
+
const manifestJson = JSON.parse(readFileSync(manifestPath, "utf-8"));
|
|
31
|
+
const result = ExtensionPackManifestSchema(manifestJson);
|
|
32
|
+
if (result instanceof type.errors) {
|
|
33
|
+
const messages = result.map((p) => p.message).join("; ");
|
|
34
|
+
throw new Error(`Invalid target manifest structure at ${manifestPath}: ${messages}`);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
var postgresTargetDescriptor = {
|
|
39
|
+
kind: "target",
|
|
40
|
+
familyId: "sql",
|
|
41
|
+
targetId: "postgres",
|
|
42
|
+
id: "postgres",
|
|
43
|
+
manifest: loadTargetManifest(),
|
|
44
|
+
create() {
|
|
45
|
+
return {
|
|
46
|
+
familyId: "sql",
|
|
47
|
+
targetId: "postgres"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var control_default = postgresTargetDescriptor;
|
|
52
|
+
export {
|
|
53
|
+
control_default as default
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/control.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { ExtensionPackManifest } from '@prisma-next/contract/pack-manifest-types';\nimport type {\n ControlTargetDescriptor,\n ControlTargetInstance,\n} from '@prisma-next/core-control-plane/types';\nimport { type } from 'arktype';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nconst TypesImportSpecSchema = type({\n package: 'string',\n named: 'string',\n alias: 'string',\n});\n\nconst ExtensionPackManifestSchema = type({\n id: 'string',\n version: 'string',\n 'targets?': type({ '[string]': type({ 'minVersion?': 'string' }) }),\n 'capabilities?': 'Record<string, unknown>',\n 'types?': type({\n 'codecTypes?': type({\n import: TypesImportSpecSchema,\n }),\n 'operationTypes?': type({\n import: TypesImportSpecSchema,\n }),\n }),\n 'operations?': 'unknown[]',\n});\n\n/**\n * Loads the target manifest from packs/manifest.json.\n */\nfunction loadTargetManifest(): ExtensionPackManifest {\n const manifestPath = join(__dirname, '../../packs/manifest.json');\n const manifestJson = JSON.parse(readFileSync(manifestPath, 'utf-8'));\n\n const result = ExtensionPackManifestSchema(manifestJson);\n if (result instanceof type.errors) {\n const messages = result.map((p: { message: string }) => p.message).join('; ');\n throw new Error(`Invalid target manifest structure at ${manifestPath}: ${messages}`);\n }\n\n return result as ExtensionPackManifest;\n}\n\n/**\n * Postgres target descriptor for CLI config.\n */\nconst postgresTargetDescriptor: ControlTargetDescriptor<\n 'sql',\n 'postgres',\n ControlTargetInstance<'sql', 'postgres'>\n> = {\n kind: 'target',\n familyId: 'sql',\n targetId: 'postgres',\n id: 'postgres',\n manifest: loadTargetManifest(),\n create(): ControlTargetInstance<'sql', 'postgres'> {\n return {\n familyId: 'sql',\n targetId: 'postgres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+1,13 @@
|
|
|
1
|
+
import { RuntimeTargetDescriptor, RuntimeTargetInstance } from '@prisma-next/core-execution-plane/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Postgres runtime target instance interface.
|
|
5
|
+
*/
|
|
6
|
+
interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Postgres target descriptor for runtime plane.
|
|
10
|
+
*/
|
|
11
|
+
declare const postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<'sql', 'postgres', PostgresRuntimeTargetInstance>;
|
|
12
|
+
|
|
13
|
+
export { type PostgresRuntimeTargetInstance, postgresRuntimeTargetDescriptor as default };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// src/exports/runtime.ts
|
|
2
|
+
import { readFileSync } from "fs";
|
|
3
|
+
import { dirname, join } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { type } from "arktype";
|
|
6
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
var __dirname = dirname(__filename);
|
|
8
|
+
var TypesImportSpecSchema = type({
|
|
9
|
+
package: "string",
|
|
10
|
+
named: "string",
|
|
11
|
+
alias: "string"
|
|
12
|
+
});
|
|
13
|
+
var ExtensionPackManifestSchema = type({
|
|
14
|
+
id: "string",
|
|
15
|
+
version: "string",
|
|
16
|
+
"targets?": type({ "[string]": type({ "minVersion?": "string" }) }),
|
|
17
|
+
"capabilities?": "Record<string, unknown>",
|
|
18
|
+
"types?": type({
|
|
19
|
+
"codecTypes?": type({
|
|
20
|
+
import: TypesImportSpecSchema
|
|
21
|
+
}),
|
|
22
|
+
"operationTypes?": type({
|
|
23
|
+
import: TypesImportSpecSchema
|
|
24
|
+
})
|
|
25
|
+
}),
|
|
26
|
+
"operations?": "unknown[]"
|
|
27
|
+
});
|
|
28
|
+
function loadTargetManifest() {
|
|
29
|
+
const manifestPath = join(__dirname, "../../packs/manifest.json");
|
|
30
|
+
const manifestJson = JSON.parse(readFileSync(manifestPath, "utf-8"));
|
|
31
|
+
const result = ExtensionPackManifestSchema(manifestJson);
|
|
32
|
+
if (result instanceof type.errors) {
|
|
33
|
+
const messages = result.map((p) => p.message).join("; ");
|
|
34
|
+
throw new Error(`Invalid target manifest structure at ${manifestPath}: ${messages}`);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
var postgresRuntimeTargetDescriptor = {
|
|
39
|
+
kind: "target",
|
|
40
|
+
familyId: "sql",
|
|
41
|
+
targetId: "postgres",
|
|
42
|
+
id: "postgres",
|
|
43
|
+
manifest: loadTargetManifest(),
|
|
44
|
+
create() {
|
|
45
|
+
return {
|
|
46
|
+
familyId: "sql",
|
|
47
|
+
targetId: "postgres"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var runtime_default = postgresRuntimeTargetDescriptor;
|
|
52
|
+
export {
|
|
53
|
+
runtime_default as default
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/runtime.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { ExtensionPackManifest } from '@prisma-next/contract/pack-manifest-types';\nimport type {\n RuntimeTargetDescriptor,\n RuntimeTargetInstance,\n} from '@prisma-next/core-execution-plane/types';\nimport { type } from 'arktype';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nconst TypesImportSpecSchema = type({\n package: 'string',\n named: 'string',\n alias: 'string',\n});\n\nconst ExtensionPackManifestSchema = type({\n id: 'string',\n version: 'string',\n 'targets?': type({ '[string]': type({ 'minVersion?': 'string' }) }),\n 'capabilities?': 'Record<string, unknown>',\n 'types?': type({\n 'codecTypes?': type({\n import: TypesImportSpecSchema,\n }),\n 'operationTypes?': type({\n import: TypesImportSpecSchema,\n }),\n }),\n 'operations?': 'unknown[]',\n});\n\n/**\n * Loads the target manifest from packs/manifest.json.\n */\nfunction loadTargetManifest(): ExtensionPackManifest {\n const manifestPath = join(__dirname, '../../packs/manifest.json');\n const manifestJson = JSON.parse(readFileSync(manifestPath, 'utf-8'));\n\n const result = ExtensionPackManifestSchema(manifestJson);\n if (result instanceof type.errors) {\n const messages = result.map((p: { message: string }) => p.message).join('; ');\n throw new Error(`Invalid target manifest structure at ${manifestPath}: ${messages}`);\n }\n\n return result as ExtensionPackManifest;\n}\n\n/**\n * Postgres runtime target instance interface.\n */\nexport interface PostgresRuntimeTargetInstance extends RuntimeTargetInstance<'sql', 'postgres'> {}\n\n/**\n * Postgres target descriptor for runtime plane.\n */\nconst postgresRuntimeTargetDescriptor: RuntimeTargetDescriptor<\n 'sql',\n 'postgres',\n PostgresRuntimeTargetInstance\n> = {\n kind: 'target',\n familyId: 'sql',\n targetId: 'postgres',\n id: 'postgres',\n manifest: loadTargetManifest(),\n create(): PostgresRuntimeTargetInstance {\n return {\n familyId: 'sql',\n targetId: 'postgres',\n };\n },\n};\n\nexport default postgresRuntimeTargetDescriptor;\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAqB;AAM9B,SAAS,YAAY;AAErB,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,QAAQ,UAAU;AAEpC,IAAM,wBAAwB,KAAK;AAAA,EACjC,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AACT,CAAC;AAED,IAAM,8BAA8B,KAAK;AAAA,EACvC,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,YAAY,KAAK,EAAE,YAAY,KAAK,EAAE,eAAe,SAAS,CAAC,EAAE,CAAC;AAAA,EAClE,iBAAiB;AAAA,EACjB,UAAU,KAAK;AAAA,IACb,eAAe,KAAK;AAAA,MAClB,QAAQ;AAAA,IACV,CAAC;AAAA,IACD,mBAAmB,KAAK;AAAA,MACtB,QAAQ;AAAA,IACV,CAAC;AAAA,EACH,CAAC;AAAA,EACD,eAAe;AACjB,CAAC;AAKD,SAAS,qBAA4C;AACnD,QAAM,eAAe,KAAK,WAAW,2BAA2B;AAChE,QAAM,eAAe,KAAK,MAAM,aAAa,cAAc,OAAO,CAAC;AAEnE,QAAM,SAAS,4BAA4B,YAAY;AACvD,MAAI,kBAAkB,KAAK,QAAQ;AACjC,UAAM,WAAW,OAAO,IAAI,CAAC,MAA2B,EAAE,OAAO,EAAE,KAAK,IAAI;AAC5E,UAAM,IAAI,MAAM,wCAAwC,YAAY,KAAK,QAAQ,EAAE;AAAA,EACrF;AAEA,SAAO;AACT;AAUA,IAAM,kCAIF;AAAA,EACF,MAAM;AAAA,EACN,UAAU;AAAA,EACV,UAAU;AAAA,EACV,IAAI;AAAA,EACJ,UAAU,mBAAmB;AAAA,EAC7B,SAAwC;AACtC,WAAO;AAAA,MACL,UAAU;AAAA,MACV,UAAU;AAAA,IACZ;AAAA,EACF;AACF;AAEA,IAAO,kBAAQ;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@prisma-next/target-postgres",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"description": "Postgres target pack for Prisma Next",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsup --config tsup.config.ts",
|
|
9
|
+
"test": "vitest run --passWithNoTests",
|
|
10
|
+
"test:coverage": "vitest run --coverage --passWithNoTests",
|
|
11
|
+
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
12
|
+
"lint": "biome check . --config-path ../../../../biome.json --error-on-warnings",
|
|
13
|
+
"clean": "node ../../../../scripts/clean.mjs"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@prisma-next/cli": "workspace:*",
|
|
17
|
+
"@prisma-next/contract": "workspace:*",
|
|
18
|
+
"@prisma-next/core-control-plane": "workspace:*",
|
|
19
|
+
"@prisma-next/core-execution-plane": "workspace:*",
|
|
20
|
+
"arktype": "^2.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@prisma-next/test-utils": "workspace:*",
|
|
24
|
+
"tsup": "^8.3.0",
|
|
25
|
+
"typescript": "^5.9.3",
|
|
26
|
+
"vitest": "^2.1.1"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"packs"
|
|
31
|
+
],
|
|
32
|
+
"exports": {
|
|
33
|
+
"./control": {
|
|
34
|
+
"types": "./dist/exports/control.d.ts",
|
|
35
|
+
"import": "./dist/exports/control.js"
|
|
36
|
+
},
|
|
37
|
+
"./runtime": {
|
|
38
|
+
"types": "./dist/exports/runtime.d.ts",
|
|
39
|
+
"import": "./dist/exports/runtime.js"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|