vona-module-a-version 5.0.18 → 5.0.21
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/.metadata/index.d.ts +42 -35
- package/dist/index.js +92 -93
- package/package.json +1 -1
|
@@ -32,6 +32,13 @@ export interface IModuleEntity {
|
|
|
32
32
|
export type EntityVersionTableName = 'aVersion';
|
|
33
33
|
export type EntityVersionInitTableName = 'aVersionInit';
|
|
34
34
|
export type EntityViewRecordTableName = 'aViewRecord';
|
|
35
|
+
declare module 'vona-module-a-database' {
|
|
36
|
+
interface ITableRecord {
|
|
37
|
+
'aVersion': never;
|
|
38
|
+
'aVersionInit': never;
|
|
39
|
+
'aViewRecord': never;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
35
42
|
declare module 'vona-module-a-version' {
|
|
36
43
|
interface IEntityOptionsVersion {
|
|
37
44
|
fields?: TypeEntityOptionsFields<EntityVersion, IEntityOptionsVersion['_fieldsMore_']>;
|
|
@@ -63,6 +70,40 @@ export interface IModuleModel {
|
|
|
63
70
|
'viewRecord': ModelViewRecord;
|
|
64
71
|
}
|
|
65
72
|
/** model: end */
|
|
73
|
+
/** service: begin */
|
|
74
|
+
export * from '../service/database.ts';
|
|
75
|
+
export * from '../service/version.ts';
|
|
76
|
+
import 'vona';
|
|
77
|
+
declare module 'vona-module-a-bean' {
|
|
78
|
+
interface IServiceRecord {
|
|
79
|
+
'a-version:database': never;
|
|
80
|
+
'a-version:version': never;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
declare module 'vona-module-a-version' {
|
|
84
|
+
interface ServiceDatabase {
|
|
85
|
+
}
|
|
86
|
+
interface ServiceVersion {
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** service: end */
|
|
90
|
+
/** service: begin */
|
|
91
|
+
import type { ServiceDatabase } from '../service/database.ts';
|
|
92
|
+
import type { ServiceVersion } from '../service/version.ts';
|
|
93
|
+
export interface IModuleService {
|
|
94
|
+
'database': ServiceDatabase;
|
|
95
|
+
'version': ServiceVersion;
|
|
96
|
+
}
|
|
97
|
+
/** service: end */
|
|
98
|
+
/** service: begin */
|
|
99
|
+
import 'vona';
|
|
100
|
+
declare module 'vona' {
|
|
101
|
+
interface IBeanRecordGeneral {
|
|
102
|
+
'a-version.service.database': ServiceDatabase;
|
|
103
|
+
'a-version.service.version': ServiceVersion;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/** service: end */
|
|
66
107
|
/** event: begin */
|
|
67
108
|
export * from '../bean/event.versionDone.ts';
|
|
68
109
|
import 'vona';
|
|
@@ -121,40 +162,6 @@ declare module 'vona-module-a-version' {
|
|
|
121
162
|
interface StartupInstanceInit {
|
|
122
163
|
}
|
|
123
164
|
}
|
|
124
|
-
/** startup: end */
|
|
125
|
-
/** service: begin */
|
|
126
|
-
export * from '../service/database.ts';
|
|
127
|
-
export * from '../service/version.ts';
|
|
128
|
-
import 'vona';
|
|
129
|
-
declare module 'vona-module-a-web' {
|
|
130
|
-
interface IServiceRecord {
|
|
131
|
-
'a-version:database': never;
|
|
132
|
-
'a-version:version': never;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
declare module 'vona-module-a-version' {
|
|
136
|
-
interface ServiceDatabase {
|
|
137
|
-
}
|
|
138
|
-
interface ServiceVersion {
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
/** service: end */
|
|
142
|
-
/** service: begin */
|
|
143
|
-
import type { ServiceDatabase } from '../service/database.ts';
|
|
144
|
-
import type { ServiceVersion } from '../service/version.ts';
|
|
145
|
-
export interface IModuleService {
|
|
146
|
-
'database': ServiceDatabase;
|
|
147
|
-
'version': ServiceVersion;
|
|
148
|
-
}
|
|
149
|
-
/** service: end */
|
|
150
|
-
/** service: begin */
|
|
151
|
-
import 'vona';
|
|
152
|
-
declare module 'vona' {
|
|
153
|
-
interface IBeanRecordGeneral {
|
|
154
|
-
'a-version.service.database': ServiceDatabase;
|
|
155
|
-
'a-version.service.version': ServiceVersion;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
165
|
export declare const locales: {
|
|
159
166
|
'en-us': {
|
|
160
167
|
ModuleOld: string;
|
|
@@ -178,8 +185,8 @@ export interface ScopeModuleAVersion {
|
|
|
178
185
|
locale: TypeModuleLocales<(typeof locales)[TypeLocaleBase]>;
|
|
179
186
|
entity: IModuleEntity;
|
|
180
187
|
model: IModuleModel;
|
|
181
|
-
event: IModuleEvent;
|
|
182
188
|
service: IModuleService;
|
|
189
|
+
event: IModuleEvent;
|
|
183
190
|
}
|
|
184
191
|
import 'vona';
|
|
185
192
|
declare module 'vona' {
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { BeanInfo, ClassMapped, BeanBase, BeanScopeBase } from 'vona';
|
|
2
2
|
import { Entity, EntityBaseSimple, Model, BeanModelBase } from 'vona-module-a-database';
|
|
3
3
|
import { Api } from 'vona-module-a-openapi';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import moment from 'moment';
|
|
6
|
+
import { Service, Scope } from 'vona-module-a-bean';
|
|
4
7
|
import { Event, BeanEventBase } from 'vona-module-a-event';
|
|
5
8
|
import fse from 'fs-extra';
|
|
6
9
|
import { Meta } from 'vona-module-a-meta';
|
|
7
10
|
import { Startup } from 'vona-module-a-startup';
|
|
8
|
-
import chalk from 'chalk';
|
|
9
|
-
import moment from 'moment';
|
|
10
|
-
import { Service } from 'vona-module-a-web';
|
|
11
|
-
import { Scope } from 'vona-module-a-bean';
|
|
12
11
|
|
|
13
12
|
function _applyDecoratedDescriptor(i, e, r, n, l) {
|
|
14
13
|
var a = {};
|
|
@@ -106,94 +105,11 @@ let ModelViewRecord = (_dec$8 = Model({
|
|
|
106
105
|
}), _dec$8(_class$8 = _dec2$8(_class$8 = class ModelViewRecord extends BeanModelBase {}) || _class$8) || _class$8);
|
|
107
106
|
|
|
108
107
|
var _dec$7, _dec2$7, _class$7;
|
|
109
|
-
let EventVersionDone = (_dec$7 = Event(), _dec2$7 = BeanInfo({
|
|
110
|
-
module: "a-version"
|
|
111
|
-
}), _dec$7(_class$7 = _dec2$7(_class$7 = class EventVersionDone extends BeanEventBase {}) || _class$7) || _class$7);
|
|
112
|
-
|
|
113
|
-
var _dec$6, _dec2$6, _class$6;
|
|
114
|
-
let MetaVersion = (_dec$6 = Meta(), _dec2$6 = BeanInfo({
|
|
115
|
-
module: "a-version"
|
|
116
|
-
}), _dec$6(_class$6 = _dec2$6(_class$6 = class MetaVersion extends BeanBase {
|
|
117
|
-
async update(options) {
|
|
118
|
-
if (options.version === 1) {
|
|
119
|
-
const entity = this.scope.entity.versionInit;
|
|
120
|
-
await this.bean.model.createTable(entity.$table, table => {
|
|
121
|
-
table.basicFieldsSimple({
|
|
122
|
-
deleted: false,
|
|
123
|
-
iid: false
|
|
124
|
-
});
|
|
125
|
-
table.string(entity.instanceName, 255);
|
|
126
|
-
table.string(entity.module, 255);
|
|
127
|
-
table.integer(entity.version);
|
|
128
|
-
});
|
|
129
|
-
const entity2 = this.scope.entity.viewRecord;
|
|
130
|
-
await this.bean.model.createTable(entity2.$table, table => {
|
|
131
|
-
table.basicFieldsSimple({
|
|
132
|
-
deleted: true,
|
|
133
|
-
iid: false
|
|
134
|
-
});
|
|
135
|
-
table.string(entity2.viewName, 255);
|
|
136
|
-
table.text(entity2.viewSql);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
async init(options) {
|
|
141
|
-
if (options.version === 1) {
|
|
142
|
-
// remove publicDir
|
|
143
|
-
await this._removePublicDir();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
async _removePublicDir() {
|
|
147
|
-
// only for test/dev env
|
|
148
|
-
if (this.app.meta.isProd) return;
|
|
149
|
-
// path
|
|
150
|
-
const publicPath = await this.app.util.getPublicPathPhysical();
|
|
151
|
-
// remove
|
|
152
|
-
await fse.remove(publicPath);
|
|
153
|
-
}
|
|
154
|
-
}) || _class$6) || _class$6);
|
|
155
|
-
|
|
156
|
-
var _dec$5, _dec2$5, _class$5;
|
|
157
|
-
let StartupDatabaseInit = (_dec$5 = Startup({
|
|
158
|
-
debounce: true
|
|
159
|
-
}), _dec2$5 = BeanInfo({
|
|
160
|
-
module: "a-version"
|
|
161
|
-
}), _dec$5(_class$5 = _dec2$5(_class$5 = class StartupDatabaseInit extends BeanBase {
|
|
162
|
-
async execute() {
|
|
163
|
-
return await this.scope.service.database.databaseInitStartup();
|
|
164
|
-
}
|
|
165
|
-
}) || _class$5) || _class$5);
|
|
166
|
-
|
|
167
|
-
var _dec$4, _dec2$4, _class$4;
|
|
168
|
-
let StartupDatabaseName = (_dec$4 = Startup({
|
|
169
|
-
dependencies: 'a-version:databaseInit'
|
|
170
|
-
}), _dec2$4 = BeanInfo({
|
|
171
|
-
module: "a-version"
|
|
172
|
-
}), _dec$4(_class$4 = _dec2$4(_class$4 = class StartupDatabaseName extends BeanBase {
|
|
173
|
-
async execute() {
|
|
174
|
-
return await this.scope.service.database.databaseNameStartup();
|
|
175
|
-
}
|
|
176
|
-
}) || _class$4) || _class$4);
|
|
177
|
-
|
|
178
|
-
var _dec$3, _dec2$3, _class$3;
|
|
179
|
-
let StartupInstanceInit = (_dec$3 = Startup({
|
|
180
|
-
instance: true,
|
|
181
|
-
debounce: true
|
|
182
|
-
}), _dec2$3 = BeanInfo({
|
|
183
|
-
module: "a-version"
|
|
184
|
-
}), _dec$3(_class$3 = _dec2$3(_class$3 = class StartupInstanceInit extends BeanBase {
|
|
185
|
-
async execute(options) {
|
|
186
|
-
const beanVersion = this.scope.service.version;
|
|
187
|
-
return await beanVersion.instanceInitStartup(options);
|
|
188
|
-
}
|
|
189
|
-
}) || _class$3) || _class$3);
|
|
190
|
-
|
|
191
|
-
var _dec$2, _dec2$2, _class$2;
|
|
192
108
|
const __separator = '-';
|
|
193
109
|
const __timeFormat = `YYYYMMDD${__separator}HHmmss`;
|
|
194
|
-
let ServiceDatabase = (_dec$
|
|
110
|
+
let ServiceDatabase = (_dec$7 = Service(), _dec2$7 = BeanInfo({
|
|
195
111
|
module: "a-version"
|
|
196
|
-
}), _dec$
|
|
112
|
+
}), _dec$7(_class$7 = _dec2$7(_class$7 = class ServiceDatabase extends BeanBase {
|
|
197
113
|
get configDatabase() {
|
|
198
114
|
return this.app.config.database;
|
|
199
115
|
}
|
|
@@ -276,12 +192,12 @@ let ServiceDatabase = (_dec$2 = Service(), _dec2$2 = BeanInfo({
|
|
|
276
192
|
this.$logger.silly(chalk.cyan(`database: ${databaseName}, pid: ${process.pid}`));
|
|
277
193
|
}
|
|
278
194
|
}
|
|
279
|
-
}) || _class$
|
|
195
|
+
}) || _class$7) || _class$7);
|
|
280
196
|
|
|
281
|
-
var _dec$
|
|
282
|
-
let ServiceVersion = (_dec$
|
|
197
|
+
var _dec$6, _dec2$6, _class$6;
|
|
198
|
+
let ServiceVersion = (_dec$6 = Service(), _dec2$6 = BeanInfo({
|
|
283
199
|
module: "a-version"
|
|
284
|
-
}), _dec$
|
|
200
|
+
}), _dec$6(_class$6 = _dec2$6(_class$6 = class ServiceVersion extends BeanBase {
|
|
285
201
|
async instanceInitStartup(options) {
|
|
286
202
|
const instanceBase = options?.configInstanceBase;
|
|
287
203
|
await this.__instanceInit(this.ctx.instanceName, instanceBase);
|
|
@@ -530,6 +446,89 @@ let ServiceVersion = (_dec$1 = Service(), _dec2$1 = BeanInfo({
|
|
|
530
446
|
if (!beanVersion && throwErrorIfEmpty) throw new Error(`meta.version not exists for ${moduleName}`);
|
|
531
447
|
return beanVersion;
|
|
532
448
|
}
|
|
449
|
+
}) || _class$6) || _class$6);
|
|
450
|
+
|
|
451
|
+
var _dec$5, _dec2$5, _class$5;
|
|
452
|
+
let EventVersionDone = (_dec$5 = Event(), _dec2$5 = BeanInfo({
|
|
453
|
+
module: "a-version"
|
|
454
|
+
}), _dec$5(_class$5 = _dec2$5(_class$5 = class EventVersionDone extends BeanEventBase {}) || _class$5) || _class$5);
|
|
455
|
+
|
|
456
|
+
var _dec$4, _dec2$4, _class$4;
|
|
457
|
+
let MetaVersion = (_dec$4 = Meta(), _dec2$4 = BeanInfo({
|
|
458
|
+
module: "a-version"
|
|
459
|
+
}), _dec$4(_class$4 = _dec2$4(_class$4 = class MetaVersion extends BeanBase {
|
|
460
|
+
async update(options) {
|
|
461
|
+
if (options.version === 1) {
|
|
462
|
+
const entity = this.scope.entity.versionInit;
|
|
463
|
+
await this.bean.model.createTable(entity.$table, table => {
|
|
464
|
+
table.basicFieldsSimple({
|
|
465
|
+
deleted: false,
|
|
466
|
+
iid: false
|
|
467
|
+
});
|
|
468
|
+
table.string(entity.instanceName, 255);
|
|
469
|
+
table.string(entity.module, 255);
|
|
470
|
+
table.integer(entity.version);
|
|
471
|
+
});
|
|
472
|
+
const entity2 = this.scope.entity.viewRecord;
|
|
473
|
+
await this.bean.model.createTable(entity2.$table, table => {
|
|
474
|
+
table.basicFieldsSimple({
|
|
475
|
+
deleted: true,
|
|
476
|
+
iid: false
|
|
477
|
+
});
|
|
478
|
+
table.string(entity2.viewName, 255);
|
|
479
|
+
table.text(entity2.viewSql);
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
async init(options) {
|
|
484
|
+
if (options.version === 1) {
|
|
485
|
+
// remove publicDir
|
|
486
|
+
await this._removePublicDir();
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
async _removePublicDir() {
|
|
490
|
+
// only for test/dev env
|
|
491
|
+
if (this.app.meta.isProd) return;
|
|
492
|
+
// path
|
|
493
|
+
const publicPath = await this.app.util.getPublicPathPhysical();
|
|
494
|
+
// remove
|
|
495
|
+
await fse.remove(publicPath);
|
|
496
|
+
}
|
|
497
|
+
}) || _class$4) || _class$4);
|
|
498
|
+
|
|
499
|
+
var _dec$3, _dec2$3, _class$3;
|
|
500
|
+
let StartupDatabaseInit = (_dec$3 = Startup({
|
|
501
|
+
debounce: true
|
|
502
|
+
}), _dec2$3 = BeanInfo({
|
|
503
|
+
module: "a-version"
|
|
504
|
+
}), _dec$3(_class$3 = _dec2$3(_class$3 = class StartupDatabaseInit extends BeanBase {
|
|
505
|
+
async execute() {
|
|
506
|
+
return await this.scope.service.database.databaseInitStartup();
|
|
507
|
+
}
|
|
508
|
+
}) || _class$3) || _class$3);
|
|
509
|
+
|
|
510
|
+
var _dec$2, _dec2$2, _class$2;
|
|
511
|
+
let StartupDatabaseName = (_dec$2 = Startup({
|
|
512
|
+
dependencies: 'a-version:databaseInit'
|
|
513
|
+
}), _dec2$2 = BeanInfo({
|
|
514
|
+
module: "a-version"
|
|
515
|
+
}), _dec$2(_class$2 = _dec2$2(_class$2 = class StartupDatabaseName extends BeanBase {
|
|
516
|
+
async execute() {
|
|
517
|
+
return await this.scope.service.database.databaseNameStartup();
|
|
518
|
+
}
|
|
519
|
+
}) || _class$2) || _class$2);
|
|
520
|
+
|
|
521
|
+
var _dec$1, _dec2$1, _class$1;
|
|
522
|
+
let StartupInstanceInit = (_dec$1 = Startup({
|
|
523
|
+
instance: true,
|
|
524
|
+
debounce: true
|
|
525
|
+
}), _dec2$1 = BeanInfo({
|
|
526
|
+
module: "a-version"
|
|
527
|
+
}), _dec$1(_class$1 = _dec2$1(_class$1 = class StartupInstanceInit extends BeanBase {
|
|
528
|
+
async execute(options) {
|
|
529
|
+
const beanVersion = this.scope.service.version;
|
|
530
|
+
return await beanVersion.instanceInitStartup(options);
|
|
531
|
+
}
|
|
533
532
|
}) || _class$1) || _class$1);
|
|
534
533
|
|
|
535
534
|
var locale_en_us = {
|