@solidstarters/solid-code-builder 1.0.32 → 1.0.34
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/dist/code-builder/index.d.ts +0 -4
- package/dist/code-builder/index.js +3 -4
- package/dist/code-builder/index.js.map +1 -1
- package/dist/code-builder/lib/field/FieldManager.d.ts +2 -1
- package/dist/code-builder/lib/field/FieldManager.js +3 -3
- package/dist/code-builder/lib/field/FieldManager.js.map +1 -1
- package/dist/code-builder/lib/field/db-helpers.d.ts +5 -0
- package/dist/code-builder/lib/field/db-helpers.js +22 -0
- package/dist/code-builder/lib/field/db-helpers.js.map +1 -0
- package/dist/code-builder/lib/field/decorator-managers/entity/ColumnDecoratorManager.d.ts +1 -2
- package/dist/code-builder/lib/field/decorator-managers/entity/ManyToOneDecoratorManager.js +5 -3
- package/dist/code-builder/lib/field/decorator-managers/entity/ManyToOneDecoratorManager.js.map +1 -1
- package/dist/code-builder/lib/field/decorator-managers/entity/PrimaryColumnDecoratorManager.d.ts +11 -0
- package/dist/code-builder/lib/field/decorator-managers/entity/PrimaryColumnDecoratorManager.js +16 -0
- package/dist/code-builder/lib/field/decorator-managers/entity/PrimaryColumnDecoratorManager.js.map +1 -0
- package/dist/code-builder/lib/field/field-managers/base/BaseFieldManagerForEntity.d.ts +6 -1
- package/dist/code-builder/lib/field/field-managers/base/BaseFieldManagerForEntity.js +18 -3
- package/dist/code-builder/lib/field/field-managers/base/BaseFieldManagerForEntity.js.map +1 -1
- package/dist/code-builder/lib/field/field-managers/long-text/LongTextFieldHandler.d.ts +2 -1
- package/dist/code-builder/lib/field/field-managers/long-text/LongTextFieldHandler.js +2 -2
- package/dist/code-builder/lib/field/field-managers/long-text/LongTextFieldHandler.js.map +1 -1
- package/dist/code-builder/lib/field/field-managers/long-text/LongTextFieldManagerForEntity.d.ts +2 -1
- package/dist/code-builder/lib/field/field-managers/long-text/LongTextFieldManagerForEntity.js +22 -2
- package/dist/code-builder/lib/field/field-managers/long-text/LongTextFieldManagerForEntity.js.map +1 -1
- package/dist/code-builder/lib/field/field-managers/rich-text/RichTextFieldHandler.d.ts +2 -1
- package/dist/code-builder/lib/field/field-managers/rich-text/RichTextFieldHandler.js +2 -2
- package/dist/code-builder/lib/field/field-managers/rich-text/RichTextFieldHandler.js.map +1 -1
- package/dist/code-builder/lib/field/field-managers/rich-text/RichTextFieldManagerForEntity.d.ts +2 -1
- package/dist/code-builder/lib/field/field-managers/rich-text/RichTextFieldManagerForEntity.js +21 -2
- package/dist/code-builder/lib/field/field-managers/rich-text/RichTextFieldManagerForEntity.js.map +1 -1
- package/dist/code-builder/lib/model/helpers.d.ts +1 -1
- package/dist/code-builder/lib/model/helpers.js +4 -4
- package/dist/code-builder/lib/model/helpers.js.map +1 -1
- package/dist/code-builder/lib/model/refresh-model.schema.json +15 -0
- package/dist/files/generate-model/entities/__model@dasherize__.entity.ts +2 -2
- package/dist/files/generate-model/repositories/__model@dasherize__.repository.ts +2 -0
- package/files/generate-model/entities/__model@dasherize__.entity.ts +2 -2
- package/files/generate-model/repositories/__model@dasherize__.repository.ts +2 -0
- package/package.json +1 -1
- package/src/code-builder/index.ts +8 -5
- package/src/code-builder/lib/field/FieldManager.ts +4 -2
- package/src/code-builder/lib/field/db-helpers.ts +22 -0
- package/src/code-builder/lib/field/decorator-managers/entity/ColumnDecoratorManager.ts +1 -1
- package/src/code-builder/lib/field/decorator-managers/entity/ManyToOneDecoratorManager.ts +8 -6
- package/src/code-builder/lib/field/decorator-managers/entity/PrimaryColumnDecoratorManager.ts +18 -0
- package/src/code-builder/lib/field/field-managers/base/BaseFieldManagerForEntity.ts +24 -3
- package/src/code-builder/lib/field/field-managers/long-text/LongTextFieldHandler.ts +5 -2
- package/src/code-builder/lib/field/field-managers/long-text/LongTextFieldManagerForEntity.ts +36 -6
- package/src/code-builder/lib/field/field-managers/rich-text/RichTextFieldHandler.ts +5 -2
- package/src/code-builder/lib/field/field-managers/rich-text/RichTextFieldManagerForEntity.ts +33 -6
- package/src/code-builder/lib/model/helpers.ts +5 -3
- package/src/code-builder/lib/model/refresh-model.schema.json +15 -0
package/src/code-builder/lib/field/field-managers/rich-text/RichTextFieldManagerForEntity.ts
CHANGED
|
@@ -2,33 +2,60 @@ import { Tree } from '@angular-devkit/schematics';
|
|
|
2
2
|
import ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
|
|
3
3
|
import { FieldManager, FieldType } from '../../FieldManager';
|
|
4
4
|
import { BaseFieldManagerForEntity } from '../base/BaseFieldManagerForEntity';
|
|
5
|
+
import { SupportedDatabases, transformColumnOptionForDatabase } from '../../db-helpers';
|
|
5
6
|
|
|
6
7
|
//FIXME Implementation pending
|
|
7
8
|
export class RichTextFieldManagerForEntity
|
|
8
9
|
extends BaseFieldManagerForEntity
|
|
9
|
-
implements FieldManager
|
|
10
|
-
{
|
|
10
|
+
implements FieldManager {
|
|
11
11
|
source: ts.SourceFile;
|
|
12
12
|
|
|
13
|
-
constructor(tree: Tree, moduleName: string, modelName: string, field: any, modelEnableSoftDelete: any) {
|
|
14
|
-
super(tree, moduleName, modelName, field, modelEnableSoftDelete);
|
|
13
|
+
constructor(tree: Tree, moduleName: string, modelName: string, field: any, modelEnableSoftDelete: any, dataSourceType?: SupportedDatabases) {
|
|
14
|
+
super(tree, moduleName, modelName, field, modelEnableSoftDelete, dataSourceType);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
fieldType(): FieldType {
|
|
18
18
|
return {
|
|
19
19
|
text: 'string',
|
|
20
|
-
node:
|
|
20
|
+
node: (_field: any) => ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
protected override additionalColumnDecoratorOptions(): Map<string, any> {
|
|
25
25
|
const options = new Map<string, any>();
|
|
26
|
+
if (this.field.max) {
|
|
27
|
+
options.set('length', transformColumnOptionForDatabase(
|
|
28
|
+
'length',
|
|
29
|
+
this.field.max,
|
|
30
|
+
this.field.ormType,
|
|
31
|
+
this.dataSourceType,
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
}
|
|
26
35
|
options.set('default', this.defaultValueInitializer(this.field.defaultValue)?.value ?? null);
|
|
27
|
-
return options;
|
|
36
|
+
return options;
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
protected override additionalColumnDecoratorOptionExpressions(): Map<string, ts.Expression | null> {
|
|
31
40
|
const options = new Map<string, ts.Expression | null>();
|
|
41
|
+
if (this.field.max) {
|
|
42
|
+
const lengthValue = transformColumnOptionForDatabase(
|
|
43
|
+
'length',
|
|
44
|
+
this.field.max,
|
|
45
|
+
this.field.ormType,
|
|
46
|
+
this.dataSourceType,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
if (typeof lengthValue === 'number') {
|
|
50
|
+
options.set('length', ts.factory.createNumericLiteral(lengthValue));
|
|
51
|
+
} else if (typeof lengthValue === 'string') {
|
|
52
|
+
options.set('length', ts.factory.createStringLiteral(lengthValue));
|
|
53
|
+
} else {
|
|
54
|
+
options.set('length', null);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
options.set('length', null);
|
|
58
|
+
}
|
|
32
59
|
options.set('default', this.defaultValueInitializer(this.field.defaultValue)?.expression ?? null);
|
|
33
60
|
return options
|
|
34
61
|
}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
ReplaceChangeSSS,
|
|
13
13
|
getFieldHandler,
|
|
14
14
|
} from '../field/FieldManager';
|
|
15
|
+
import { SupportedDatabases } from '../field/db-helpers';
|
|
15
16
|
|
|
16
17
|
export const SOLID_CORE_MODULE_NAME = 'solid-core';
|
|
17
18
|
export const SOLID_CORE_MODULE_NPM_PACKAGE_NAME = '@solidstarters/solid-core';
|
|
@@ -346,7 +347,8 @@ export function updateField(tree: Tree, options: any, field: any) {
|
|
|
346
347
|
options.module,
|
|
347
348
|
options.model,
|
|
348
349
|
field,
|
|
349
|
-
options.modelEnableSoftDelete
|
|
350
|
+
options.modelEnableSoftDelete,
|
|
351
|
+
options.dataSourceType as SupportedDatabases
|
|
350
352
|
);
|
|
351
353
|
const entityFieldChanges = fieldHandler.updateEntityField();
|
|
352
354
|
// console.log('entityFieldChanges:', entityFieldChanges.map((change) => change.changes));
|
|
@@ -533,9 +535,9 @@ export function calculateModuleFileImportPath(moduleName: string, internalPath:
|
|
|
533
535
|
return (moduleName === SOLID_CORE_MODULE_NAME) ? internalPath : SOLID_CORE_MODULE_NPM_PACKAGE_NAME;
|
|
534
536
|
}
|
|
535
537
|
|
|
536
|
-
export function
|
|
538
|
+
export function outputEntitySuperClassImport(isLegacyTable: boolean = false, isLegacyTableWithId: boolean = false, parentModel: string | null = null, parentModule: string = "solid-core") {
|
|
537
539
|
let importPath: string = SOLID_CORE_MODULE_NPM_PACKAGE_NAME;
|
|
538
|
-
let importSymbol: string = "CommonEntity";
|
|
540
|
+
let importSymbol: string = isLegacyTableWithId ? "LegacyCommonWithIdEntity" : isLegacyTable ? "LegacyCommonEntity" : "CommonEntity";
|
|
539
541
|
if (parentModel != null) {
|
|
540
542
|
importPath = parentModule === SOLID_CORE_MODULE_NAME ? SOLID_CORE_MODULE_NPM_PACKAGE_NAME : `src/${dasherize(parentModule)}/entities/${dasherize(parentModel)}.entity.ts`;
|
|
541
543
|
importSymbol = `${classify(parentModel)}`;
|
|
@@ -37,6 +37,21 @@
|
|
|
37
37
|
"description": "Whether the draft publish workflow is enabled for the model",
|
|
38
38
|
"default": "false"
|
|
39
39
|
},
|
|
40
|
+
"isLegacyTable": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"description": "Indicates whether the table is a legacy table",
|
|
43
|
+
"default": "false"
|
|
44
|
+
},
|
|
45
|
+
"isLegacyTableWithId": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "Indicates whether the legacy table has an 'id' column",
|
|
48
|
+
"default": "false"
|
|
49
|
+
},
|
|
50
|
+
"dataSourceType": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "The data source type of the model",
|
|
53
|
+
"enum": ["postgres", "mssql"]
|
|
54
|
+
},
|
|
40
55
|
"fields": {
|
|
41
56
|
"oneOf": [
|
|
42
57
|
{
|