@polyprism/ts-interface 0.1.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 +21 -0
- package/README.md +72 -0
- package/dist/generator.d.ts +1 -0
- package/dist/generator.js +11 -0
- package/dist/generator.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Travis Fitzgerald
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @polyprism/ts-interface
|
|
2
|
+
|
|
3
|
+
TypeScript **interface** emitter for [PolyPrism](https://github.com/TravFitz/polyprism).
|
|
4
|
+
Emits `export interface User { ... }` types from your Prisma schema.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pnpm add -D prisma @polyprism/ts-interface
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Configure
|
|
13
|
+
|
|
14
|
+
```prisma
|
|
15
|
+
generator polyprismCodegen {
|
|
16
|
+
provider = "polyprism-ts-interface"
|
|
17
|
+
output = "../generated"
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
> ⚠️ The provider string is the **bin name** (no `@scope/` prefix). Bin
|
|
22
|
+
> names can't contain `/`, so you write `polyprism-ts-interface`, not
|
|
23
|
+
> `@polyprism/ts-interface`.
|
|
24
|
+
|
|
25
|
+
## Run
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm prisma generate
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Output
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// generated/User.ts
|
|
35
|
+
import type { Role } from "./enums/Role.js";
|
|
36
|
+
|
|
37
|
+
export interface User {
|
|
38
|
+
id: string;
|
|
39
|
+
email: string;
|
|
40
|
+
name: string | null;
|
|
41
|
+
role: Role;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Config options
|
|
46
|
+
|
|
47
|
+
All keys go on the `generator polyprismCodegen { ... }` block:
|
|
48
|
+
|
|
49
|
+
| Key | Default | Options |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `output` | — | Path to the output directory (relative to the schema). |
|
|
52
|
+
| `fileNaming` | `PascalCase` | `PascalCase` \| `camelCase` \| `kebab-case` \| `snake_case` \| `preserve` |
|
|
53
|
+
| `typeNaming` | `PascalCase` | `PascalCase` \| `camelCase` \| `snake_case` \| `preserve` |
|
|
54
|
+
| `fieldNaming` | `preserve` | `camelCase` \| `snake_case` \| `preserve` |
|
|
55
|
+
| `emitIndex` | `false` | `"true"` to emit a barrel `index.ts`. |
|
|
56
|
+
|
|
57
|
+
## Annotations
|
|
58
|
+
|
|
59
|
+
See the [root README](https://github.com/TravFitz/polyprism#annotation-reference)
|
|
60
|
+
for the seven supported `///` annotations: `@hide`, `@deprecated`, `@json`
|
|
61
|
+
(four forms), `@type`, `@name`, `@normalise`, `@coerce`.
|
|
62
|
+
|
|
63
|
+
## Sibling patterns
|
|
64
|
+
|
|
65
|
+
Same schema, different output shape — just swap the provider:
|
|
66
|
+
|
|
67
|
+
- [`@polyprism/ts-type`](https://www.npmjs.com/package/@polyprism/ts-type) — `export type User = { ... };`
|
|
68
|
+
- [`@polyprism/ts-class`](https://www.npmjs.com/package/@polyprism/ts-class) — `export class User { ... }` with real initializer expressions
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
[MIT](../../LICENSE) © Travis Fitzgerald
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineGenerator } from "@polyprism/core";
|
|
3
|
+
import { emit } from "./index.js";
|
|
4
|
+
defineGenerator({
|
|
5
|
+
manifest: {
|
|
6
|
+
prettyName: "PolyPrism TypeScript Interface",
|
|
7
|
+
defaultOutput: "./generated"
|
|
8
|
+
},
|
|
9
|
+
onGenerate: emit
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generator.ts"],"sourcesContent":["#!/usr/bin/env node\n// Prisma generator entry point for @polyprism/ts-interface.\n\nimport { defineGenerator } from \"@polyprism/core\";\n\nimport { emit } from \"./index.js\";\n\ndefineGenerator({\n manifest: {\n prettyName: \"PolyPrism TypeScript Interface\",\n defaultOutput: \"./generated\",\n },\n onGenerate: emit,\n});\n"],"mappings":";AAGA,SAAS,uBAAuB;AAEhC,SAAS,YAAY;AAErB,gBAAgB;AAAA,EACd,UAAU;AAAA,IACR,YAAY;AAAA,IACZ,eAAe;AAAA,EACjB;AAAA,EACA,YAAY;AACd,CAAC;","names":[]}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @polyprism/ts-interface — emits `export interface X { ... }` declarations.\n// Thin wrapper around @polyprism/ts-shared's emitModels with declarationStyle=\"interface\".\n\nimport type { GeneratorContext } from \"@polyprism/core\";\nimport { emitModels } from \"@polyprism/ts-shared\";\n\nexport async function emit(ctx: GeneratorContext): Promise<void> {\n await emitModels(ctx, { declarationStyle: \"interface\" });\n}\n"],"mappings":"AAIA,SAAS,kBAAkB;AAE3B,eAAsB,KAAK,KAAsC;AAC/D,QAAM,WAAW,KAAK,EAAE,kBAAkB,YAAY,CAAC;AACzD;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@polyprism/ts-interface",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript interface emitter for PolyPrism. Emits `export interface User { ... }` types from your Prisma schema.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Travis Fitzgerald",
|
|
8
|
+
"homepage": "https://github.com/TravFitz/polyprism/tree/main/packages/ts-interface",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/TravFitz/polyprism.git",
|
|
12
|
+
"directory": "packages/ts-interface"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/TravFitz/polyprism/issues"
|
|
16
|
+
},
|
|
17
|
+
"bin": {
|
|
18
|
+
"polyprism-ts-interface": "./dist/generator.js"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"polyprism-source": {
|
|
25
|
+
"types": "./src/index.ts",
|
|
26
|
+
"import": "./src/index.ts"
|
|
27
|
+
},
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"README.md"
|
|
35
|
+
],
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"prisma",
|
|
41
|
+
"prisma-generator",
|
|
42
|
+
"typescript",
|
|
43
|
+
"interface",
|
|
44
|
+
"codegen",
|
|
45
|
+
"polyprism"
|
|
46
|
+
],
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@polyprism/core": "0.1.0",
|
|
49
|
+
"@polyprism/ts-shared": "0.1.0"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsup",
|
|
53
|
+
"dev": "tsup --watch",
|
|
54
|
+
"typecheck": "tsc --noEmit",
|
|
55
|
+
"test": "vitest run --passWithNoTests"
|
|
56
|
+
}
|
|
57
|
+
}
|