@lssm/lib.schema 0.0.0-canary-20251217083314 → 0.0.0-canary-20251220002821
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/dist/EnumType.d.ts +30 -32
- package/dist/EnumType.d.ts.map +1 -0
- package/dist/FieldType.d.ts +20 -23
- package/dist/FieldType.d.ts.map +1 -0
- package/dist/ScalarTypeEnum.d.ts +24 -28
- package/dist/ScalarTypeEnum.d.ts.map +1 -0
- package/dist/SchemaModel.d.ts +35 -35
- package/dist/SchemaModel.d.ts.map +1 -0
- package/dist/entity/defineEntity.d.ts +56 -60
- package/dist/entity/defineEntity.d.ts.map +1 -0
- package/dist/entity/generator.d.ts +17 -21
- package/dist/entity/generator.d.ts.map +1 -0
- package/dist/entity/index.d.ts +4 -4
- package/dist/entity/index.d.ts.map +1 -0
- package/dist/entity/types.d.ts +100 -104
- package/dist/entity/types.d.ts.map +1 -0
- package/dist/index.d.ts +6 -9
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -9
- package/package.json +17 -28
- package/dist/EnumType.js +0 -56
- package/dist/FieldType.js +0 -49
- package/dist/ScalarTypeEnum.js +0 -236
- package/dist/SchemaModel.js +0 -39
- package/dist/entity/defineEntity.js +0 -236
- package/dist/entity/generator.js +0 -217
- package/dist/entity/index.js +0 -5
- package/dist/entity/types.js +0 -1
package/dist/entity/types.d.ts
CHANGED
|
@@ -1,145 +1,141 @@
|
|
|
1
|
-
import * as z from
|
|
2
|
-
|
|
3
|
-
//#region src/entity/types.d.ts
|
|
4
|
-
|
|
1
|
+
import * as z from 'zod';
|
|
5
2
|
/**
|
|
6
3
|
* Prisma scalar types that can be used in entity field definitions.
|
|
7
4
|
*/
|
|
8
|
-
type PrismaScalarType = 'String' | 'Int' | 'Float' | 'Boolean' | 'DateTime' | 'Json' | 'BigInt' | 'Decimal' | 'Bytes';
|
|
5
|
+
export type PrismaScalarType = 'String' | 'Int' | 'Float' | 'Boolean' | 'DateTime' | 'Json' | 'BigInt' | 'Decimal' | 'Bytes';
|
|
9
6
|
/**
|
|
10
7
|
* Prisma field modifiers.
|
|
11
8
|
*/
|
|
12
|
-
interface PrismaFieldModifiers {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
export interface PrismaFieldModifiers {
|
|
10
|
+
/** Field is optional (nullable) */
|
|
11
|
+
isOptional?: boolean;
|
|
12
|
+
/** Field is an array */
|
|
13
|
+
isArray?: boolean;
|
|
14
|
+
/** Field is unique */
|
|
15
|
+
isUnique?: boolean;
|
|
16
|
+
/** Field is the primary key (use @id) */
|
|
17
|
+
isId?: boolean;
|
|
18
|
+
/** Default value expression (e.g., 'cuid()', 'now()', 'autoincrement()') */
|
|
19
|
+
default?: string | number | boolean;
|
|
20
|
+
/** Field is auto-updated on record update (e.g., @updatedAt) */
|
|
21
|
+
updatedAt?: boolean;
|
|
22
|
+
/** Database column name override */
|
|
23
|
+
map?: string;
|
|
24
|
+
/** Database column type override */
|
|
25
|
+
dbType?: string;
|
|
29
26
|
}
|
|
30
27
|
/**
|
|
31
28
|
* Scalar field definition for an entity.
|
|
32
29
|
*/
|
|
33
|
-
interface EntityScalarField extends PrismaFieldModifiers {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
export interface EntityScalarField extends PrismaFieldModifiers {
|
|
31
|
+
kind: 'scalar';
|
|
32
|
+
type: PrismaScalarType;
|
|
33
|
+
/** Zod schema for validation */
|
|
34
|
+
zod?: z.ZodType;
|
|
35
|
+
/** Human-readable description (becomes Prisma /// comment) */
|
|
36
|
+
description?: string;
|
|
40
37
|
}
|
|
41
38
|
/**
|
|
42
39
|
* Enum field definition for an entity.
|
|
43
40
|
*/
|
|
44
|
-
interface EntityEnumField extends PrismaFieldModifiers {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
export interface EntityEnumField extends PrismaFieldModifiers {
|
|
42
|
+
kind: 'enum';
|
|
43
|
+
/** Name of the enum type */
|
|
44
|
+
enumName: string;
|
|
45
|
+
/** Enum values (for inline enum definition) */
|
|
46
|
+
values?: readonly string[];
|
|
47
|
+
/** Zod schema for validation */
|
|
48
|
+
zod?: z.ZodType;
|
|
49
|
+
/** Human-readable description */
|
|
50
|
+
description?: string;
|
|
54
51
|
}
|
|
55
52
|
/**
|
|
56
53
|
* Relation types supported by Prisma.
|
|
57
54
|
*/
|
|
58
|
-
type RelationType = 'hasOne' | 'hasMany' | 'belongsTo';
|
|
55
|
+
export type RelationType = 'hasOne' | 'hasMany' | 'belongsTo';
|
|
59
56
|
/**
|
|
60
57
|
* Relation field definition for an entity.
|
|
61
58
|
*/
|
|
62
|
-
interface EntityRelationField {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
59
|
+
export interface EntityRelationField {
|
|
60
|
+
kind: 'relation';
|
|
61
|
+
type: RelationType;
|
|
62
|
+
/** Target entity name */
|
|
63
|
+
target: string;
|
|
64
|
+
/** Foreign key field(s) on this model (for belongsTo) */
|
|
65
|
+
fields?: string[];
|
|
66
|
+
/** Referenced field(s) on the target model */
|
|
67
|
+
references?: string[];
|
|
68
|
+
/** Relation name for disambiguation */
|
|
69
|
+
name?: string;
|
|
70
|
+
/** On delete action */
|
|
71
|
+
onDelete?: 'Cascade' | 'SetNull' | 'Restrict' | 'NoAction' | 'SetDefault';
|
|
72
|
+
/** On update action */
|
|
73
|
+
onUpdate?: 'Cascade' | 'SetNull' | 'Restrict' | 'NoAction' | 'SetDefault';
|
|
74
|
+
/** Human-readable description */
|
|
75
|
+
description?: string;
|
|
79
76
|
}
|
|
80
77
|
/**
|
|
81
78
|
* Union of all entity field types.
|
|
82
79
|
*/
|
|
83
|
-
type EntityField = EntityScalarField | EntityEnumField | EntityRelationField;
|
|
80
|
+
export type EntityField = EntityScalarField | EntityEnumField | EntityRelationField;
|
|
84
81
|
/**
|
|
85
82
|
* Index definition for an entity.
|
|
86
83
|
*/
|
|
87
|
-
interface EntityIndex {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
export interface EntityIndex {
|
|
85
|
+
/** Fields included in the index */
|
|
86
|
+
fields: string[];
|
|
87
|
+
/** Index is unique constraint */
|
|
88
|
+
unique?: boolean;
|
|
89
|
+
/** Index name override */
|
|
90
|
+
name?: string;
|
|
91
|
+
/** Sort order per field */
|
|
92
|
+
sort?: Record<string, 'Asc' | 'Desc'>;
|
|
93
|
+
/** Index type */
|
|
94
|
+
type?: 'BTree' | 'Hash' | 'Gist' | 'Gin';
|
|
98
95
|
}
|
|
99
96
|
/**
|
|
100
97
|
* Enum definition that can be shared across entities.
|
|
101
98
|
*/
|
|
102
|
-
interface EntityEnumDef {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
99
|
+
export interface EntityEnumDef {
|
|
100
|
+
/** Enum name */
|
|
101
|
+
name: string;
|
|
102
|
+
/** Enum values */
|
|
103
|
+
values: readonly string[];
|
|
104
|
+
/** Postgres schema where the enum is defined */
|
|
105
|
+
schema?: string;
|
|
106
|
+
/** Human-readable description */
|
|
107
|
+
description?: string;
|
|
111
108
|
}
|
|
112
109
|
/**
|
|
113
110
|
* Complete entity specification for database-backed models.
|
|
114
111
|
*/
|
|
115
|
-
interface EntitySpec<TFields extends Record<string, EntityField> = Record<string, EntityField>> {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
112
|
+
export interface EntitySpec<TFields extends Record<string, EntityField> = Record<string, EntityField>> {
|
|
113
|
+
/** Entity/model name (PascalCase) */
|
|
114
|
+
name: string;
|
|
115
|
+
/** Human-readable description (becomes Prisma /// comment) */
|
|
116
|
+
description?: string;
|
|
117
|
+
/** Postgres schema name (default: 'public') */
|
|
118
|
+
schema?: string;
|
|
119
|
+
/** Database table name override */
|
|
120
|
+
map?: string;
|
|
121
|
+
/** Field definitions */
|
|
122
|
+
fields: TFields;
|
|
123
|
+
/** Index definitions */
|
|
124
|
+
indexes?: EntityIndex[];
|
|
125
|
+
/** Enum definitions used by this entity */
|
|
126
|
+
enums?: EntityEnumDef[];
|
|
127
|
+
/** Module/domain this entity belongs to (for schema composition) */
|
|
128
|
+
module?: string;
|
|
132
129
|
}
|
|
133
130
|
/**
|
|
134
131
|
* Module schema contribution for composition.
|
|
135
132
|
*/
|
|
136
|
-
interface ModuleSchemaContribution {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
133
|
+
export interface ModuleSchemaContribution {
|
|
134
|
+
/** Module identifier (e.g., '@lssm/lib.identity-rbac') */
|
|
135
|
+
moduleId: string;
|
|
136
|
+
/** Entity specs provided by this module */
|
|
137
|
+
entities: EntitySpec[];
|
|
138
|
+
/** Shared enum definitions */
|
|
139
|
+
enums?: EntityEnumDef[];
|
|
143
140
|
}
|
|
144
|
-
//#
|
|
145
|
-
export { EntityEnumDef, EntityEnumField, EntityField, EntityIndex, EntityRelationField, EntityScalarField, EntitySpec, ModuleSchemaContribution, PrismaFieldModifiers, PrismaScalarType, RelationType };
|
|
141
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/entity/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,KAAK,GACL,OAAO,GACP,SAAS,GACT,UAAU,GACV,MAAM,GACN,QAAQ,GACR,SAAS,GACT,OAAO,CAAC;AAEZ;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,mCAAmC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wBAAwB;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yCAAyC;IACzC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IACpC,gEAAgE;IAChE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oCAAoC;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,gBAAgB,CAAC;IACvB,gCAAgC;IAChC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC;IAChB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,oBAAoB;IAC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
|
-
|
|
7
|
-
import { PrismaGeneratorOptions, composeModuleSchemas, generateEntityFragment, generateEnumFragment, generatePrismaSchema } from "./entity/generator.js";
|
|
8
|
-
import "./entity/index.js";
|
|
9
|
-
export { AnyEnumType, AnyFieldType, AnySchemaModel, EntityEnumDef, EntityEnumField, EntityField, EntityIndex, EntityRelationField, EntityScalarField, EntitySpec, EnumType, FieldType, FieldTypeConfig, ModuleSchemaContribution, PrismaFieldModifiers, PrismaGeneratorOptions, PrismaScalarType, RelationType, ScalarTypeEnum, SchemaFieldConfig, SchemaModel, SchemaModelConfig, SchemaModelFieldsAnyConfig, TopLevelZodFromModel, ZodFieldType, ZodSchemaModel, ZodShapeFromFields, composeModuleSchemas, defineEntity, defineEntityEnum, defineEnum, defineSchemaModel, field, generateEntityFragment, generateEnumFragment, generatePrismaSchema, index };
|
|
1
|
+
export * from './FieldType';
|
|
2
|
+
export * from './ScalarTypeEnum';
|
|
3
|
+
export * from './SchemaModel';
|
|
4
|
+
export * from './EnumType';
|
|
5
|
+
export * from './entity';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
|