@tsofist/schema-forge 2.7.0 → 2.9.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/lib/types/db.types.d.ts +40 -1
- package/lib/validator.js +12 -0
- package/package.json +1 -1
package/lib/types/db.types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayMay } from '@tsofist/stem';
|
|
1
|
+
import { ArrayMay, HexString } from '@tsofist/stem';
|
|
2
2
|
/**
|
|
3
3
|
* Database index types.
|
|
4
4
|
*
|
|
@@ -14,6 +14,8 @@ export declare const DBIndexTypeList: readonly ["btree", "hash", "gin", "gist",
|
|
|
14
14
|
export type DBIndexType = (typeof DBIndexTypeList)[number];
|
|
15
15
|
/**
|
|
16
16
|
* Database index options.
|
|
17
|
+
*
|
|
18
|
+
* @see https://dbml.dbdiagram.io/docs/#index-definition dbml spec
|
|
17
19
|
*/
|
|
18
20
|
export type DBIndexOptions = {
|
|
19
21
|
/**
|
|
@@ -31,10 +33,27 @@ export type DBIndexOptions = {
|
|
|
31
33
|
* @default false
|
|
32
34
|
*/
|
|
33
35
|
unique?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Is it a primary key
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
pk?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Any important notes.
|
|
43
|
+
* Can be used in DDL.
|
|
44
|
+
*/
|
|
45
|
+
note?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Any important developer comments.
|
|
48
|
+
* Can't be used in DDL.
|
|
49
|
+
*/
|
|
50
|
+
comment?: string;
|
|
34
51
|
};
|
|
35
52
|
export type DBIndexOptionsDef<B extends boolean = boolean> = ArrayMay<DBIndexOptions | string | B>;
|
|
36
53
|
/**
|
|
37
54
|
* Database entity options.
|
|
55
|
+
*
|
|
56
|
+
* @see https://dbml.dbdiagram.io/docs/#table-definition dbml spec
|
|
38
57
|
*/
|
|
39
58
|
export type DBEntityOptions = {
|
|
40
59
|
/**
|
|
@@ -53,5 +72,25 @@ export type DBEntityOptions = {
|
|
|
53
72
|
indexes?: {
|
|
54
73
|
[field: string]: DBIndexOptionsDef<true>;
|
|
55
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* Any important notes.
|
|
77
|
+
* Can be used in DDL.
|
|
78
|
+
*/
|
|
79
|
+
note?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Any important developer comments.
|
|
82
|
+
* Can't be used in DDL.
|
|
83
|
+
*/
|
|
84
|
+
comment?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Table name alias.
|
|
87
|
+
*/
|
|
88
|
+
alias?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Settings.
|
|
91
|
+
*/
|
|
92
|
+
settings?: {
|
|
93
|
+
headercolor: HexString;
|
|
94
|
+
};
|
|
56
95
|
};
|
|
57
96
|
export type DBEntityOptionsDef = DBEntityOptions | string;
|
package/lib/validator.js
CHANGED
|
@@ -334,10 +334,13 @@ function addJSDocKeywords(engine) {
|
|
|
334
334
|
const DBIndexOptionsProperties = {
|
|
335
335
|
name: { type: 'string', pattern: IXNamePattern },
|
|
336
336
|
unique: { type: 'boolean' },
|
|
337
|
+
pk: { type: 'boolean' },
|
|
337
338
|
type: {
|
|
338
339
|
type: 'string',
|
|
339
340
|
enum: db_types_1.DBIndexTypeList,
|
|
340
341
|
},
|
|
342
|
+
note: { type: 'string' },
|
|
343
|
+
comment: { type: 'string' },
|
|
341
344
|
};
|
|
342
345
|
const DBIndexSchema = {
|
|
343
346
|
type: ['string', 'boolean', 'object', 'array'],
|
|
@@ -373,6 +376,15 @@ function addJSDocKeywords(engine) {
|
|
|
373
376
|
pattern: NestedPropertyNamePattern,
|
|
374
377
|
},
|
|
375
378
|
},
|
|
379
|
+
note: { type: 'string' },
|
|
380
|
+
comment: { type: 'string' },
|
|
381
|
+
alias: { type: 'string' },
|
|
382
|
+
settings: {
|
|
383
|
+
type: 'object',
|
|
384
|
+
properties: {
|
|
385
|
+
headercolor: { type: 'string' },
|
|
386
|
+
},
|
|
387
|
+
},
|
|
376
388
|
},
|
|
377
389
|
},
|
|
378
390
|
});
|