@zenorm/generate 1.10.0 → 1.10.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/dist/generate.js CHANGED
@@ -97,9 +97,13 @@ async function generate(tables, cfg) {
97
97
  const tablesFilename = path.join(outputDir, config.tablesFilename + '.ts');
98
98
  console.log(`write tables file: ${tablesFilename}`);
99
99
  await fs_1.promises.writeFile(tablesFilename, structs.filter(i => i !== null).join('\n'));
100
+ const imports = ['createRepositoryQuery'];
101
+ if (config.generateRepositories || config.bindQuery) {
102
+ imports.push('QueryParam');
103
+ }
100
104
  const repositories = [
101
105
  ...remark,
102
- `import { ${(config.generateRepositories || config.bindQuery) ? `QueryParam, UpdateRow, ` : ''}createRepositoryQuery } from '${zenormName}';`,
106
+ `import { ${imports.join(', ')} } from '${zenormName}';`,
103
107
  `import * as _tables from './_tables';`,
104
108
  ...models.map(({ name, className }) => `import _${className} from './${name}';`),
105
109
  ];
@@ -135,7 +139,7 @@ async function generate(tables, cfg) {
135
139
  repositories.push(` /** 保存当前实例数据 */`);
136
140
  repositories.push(` save() { return ${className}.repository.save(this); }`);
137
141
  repositories.push(` /** 更新当前实例数据 */`);
138
- repositories.push(` update(data: UpdateRow<${className}>) { return ${className}.repository.update(this, data); }`);
142
+ repositories.push(` update(data: Partial<${className}>) { return ${className}.repository.update(this, data); }`);
139
143
  repositories.push(` /** 删除当前实例数据 */`);
140
144
  repositories.push(` delete() { return ${className}.repository.delete(this); }`);
141
145
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zenorm/generate",
3
3
  "description": "Easy ORM, easy query. easy typing! Auto generate typescript declaration.",
4
- "version": "1.10.0",
4
+ "version": "1.10.1",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "homepage": "https://zenorm.node.ltd",
@@ -15,7 +15,7 @@
15
15
  ],
16
16
  "scripts": {
17
17
  "build": "rimraf dist && tsc",
18
- "prepublishOnly": "npm run build",
18
+ "prepack": "npm run build",
19
19
  "gen": "cd test && ts-node ../src/bin/zenorm-generate.ts config.json",
20
20
  "t1": "cd test && cross-env DEBUG=* ts-node t1"
21
21
  },
@@ -35,10 +35,11 @@
35
35
  "rimraf": "^4.4.1",
36
36
  "ts-node": "^10.9.1",
37
37
  "typescript": "^5.0.4",
38
- "zenorm": "^3.34.0"
38
+ "zenorm": "^3.38.0"
39
39
  },
40
40
  "dependencies": {
41
41
  "pascal-case": "^3.1.2",
42
42
  "snake-case": "^3.0.4"
43
- }
43
+ },
44
+ "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
44
45
  }
package/CHANGELOG.md DELETED
@@ -1,52 +0,0 @@
1
- # Changelog
2
-
3
- ## [1.10.0] - 2023-8-29
4
- - getOrCreate
5
-
6
- ## [1.9.1] - 2023-8-9
7
- - 默认选项: staticMethods=true
8
-
9
- ## [1.9.0] - 2023-8-9
10
- - 增加配置选项: staticMethods instanceMethods
11
-
12
- ## [1.8.1] - 2023-5-19
13
- - fix: 使用 global 继承时构造函数缺少 super 调用
14
-
15
- ## [1.8.0] - 2023-5-18
16
- - 撤销 [1.6.0] 的修改,动态 as 功能无法满足需求
17
-
18
- ## [1.7.0] - 2023-5-18
19
- - 构造器增加 pkval 参数
20
-
21
- ## [1.6.0] - 2023-5-18
22
- - 使用构造器提前初始化对象的属性,用于优化 v8 对象缓存机制
23
-
24
- ## [1.5.0] - 2023-4-19
25
- - 更新: update 方法使用 UpdateRow<M>
26
-
27
- ## [1.4.0] - 2023-3-29
28
- - createRepositoryQuery 添加表描述
29
- - 如果没有主键 pkType = never
30
-
31
- ## [1.3.1] - 2023-3-27
32
- - fix: windows 换行符问题
33
-
34
- ## [1.3.0] - 2023-3-25
35
- - update: bindQuery 增加 save, update, delete
36
-
37
- ## [1.2.0] - 2023-3-24
38
- - update: bindQuery 改为函数形式
39
-
40
- ## [1.1.1] - 2023-3-24
41
- - fix: 生成格式少个空格和空行
42
- - update: bindQuery 增加 count 和 exists
43
- - 补充注释说明
44
-
45
- ## [1.1.0] - 2023-3-24
46
- - 新增: 绑定静态 Query
47
-
48
- ## [1.0.0] - 2023-3-23
49
- - 完善
50
-
51
- ## [0.0.1] - 2023-3-23
52
- - 从 zenorm@3.25.0 分离为独立项目