@voxgig/system 0.3.0 → 0.4.2
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/system.d.ts +9 -1
- package/dist/system.js +37 -2
- package/dist/system.js.map +1 -1
- package/package.json +7 -7
- package/system.ts +64 -1
package/dist/system.d.ts
CHANGED
|
@@ -4,9 +4,17 @@ import { MakeSrv } from './srv/make';
|
|
|
4
4
|
declare function messages(seneca: any, options: any, reload: any): void;
|
|
5
5
|
declare function prepare(seneca: any, require: any): void;
|
|
6
6
|
declare function Local(this: any, options: any): void;
|
|
7
|
+
declare type LiveOptions = {
|
|
8
|
+
srv: {
|
|
9
|
+
name: string;
|
|
10
|
+
folder: string;
|
|
11
|
+
};
|
|
12
|
+
options: Record<string, any>;
|
|
13
|
+
};
|
|
14
|
+
declare function Live(this: any, options: LiveOptions): void;
|
|
7
15
|
declare const System: {
|
|
8
16
|
messages: typeof messages;
|
|
9
17
|
prepare: typeof prepare;
|
|
10
18
|
};
|
|
11
19
|
export type { Msg };
|
|
12
|
-
export { System, MakeSrv, Utility, Local, };
|
|
20
|
+
export { System, MakeSrv, Utility, Local, Live, };
|
package/dist/system.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.Local = exports.Utility = exports.MakeSrv = exports.System = void 0;
|
|
7
|
+
exports.Live = exports.Local = exports.Utility = exports.MakeSrv = exports.System = void 0;
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const utility_1 = require("./lib/utility");
|
|
@@ -17,7 +17,7 @@ function messages(seneca, options, reload) {
|
|
|
17
17
|
let model = seneca.context.model;
|
|
18
18
|
let srvmodel = model.main.srv[srvname];
|
|
19
19
|
let msgs = srvmsgs(srvmodel, model);
|
|
20
|
-
console.log('SYSTEM: MESSAGES FOUND', srvname, msgs);
|
|
20
|
+
console.log('SYSTEM: MESSAGES FOUND', srvname, msgs.map(m => m.pattern));
|
|
21
21
|
for (let msg of msgs) {
|
|
22
22
|
seneca.message(msg.pattern, reload(actpath(msg), { options }));
|
|
23
23
|
}
|
|
@@ -62,6 +62,41 @@ function Local(options) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
exports.Local = Local;
|
|
65
|
+
function Live(options) {
|
|
66
|
+
const model = this.context.model;
|
|
67
|
+
const srvname = options.srv.name;
|
|
68
|
+
let srvdef = model.main.srv[srvname];
|
|
69
|
+
srvdef.name = srvname;
|
|
70
|
+
let deps = srvdef.deps || {};
|
|
71
|
+
let srvs = Object
|
|
72
|
+
.entries(deps)
|
|
73
|
+
.reduce(((srvdefs, dep) => {
|
|
74
|
+
let depname = dep[0];
|
|
75
|
+
let depsrv = model.main.srv[depname];
|
|
76
|
+
depsrv.name = depname;
|
|
77
|
+
srvdefs.push(depsrv);
|
|
78
|
+
return srvdefs;
|
|
79
|
+
}), []);
|
|
80
|
+
srvs.push(srvdef);
|
|
81
|
+
useSrvs(this, srvs, options, model);
|
|
82
|
+
}
|
|
83
|
+
exports.Live = Live;
|
|
84
|
+
function useSrvs(seneca, srvs, options, model) {
|
|
85
|
+
const folder = options.srv.folder;
|
|
86
|
+
// index by srv name, overrides model
|
|
87
|
+
const srvOptions = options.options || {};
|
|
88
|
+
for (const srv of srvs) {
|
|
89
|
+
let name = srv.name;
|
|
90
|
+
let srvpath = path_1.default.join(folder, name, name + '-srv.js');
|
|
91
|
+
if (fs_1.default.existsSync(srvpath)) {
|
|
92
|
+
let srvopts = deep({}, srv.options, srvOptions[name]);
|
|
93
|
+
seneca.root.use(srvpath, srvopts);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
seneca.log.warn('srv-not-found', { name, srvpath: srvpath });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
65
100
|
const System = {
|
|
66
101
|
messages,
|
|
67
102
|
prepare,
|
package/dist/system.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.js","sourceRoot":"","sources":["../system.ts"],"names":[],"mappings":";AAAA,+CAA+C;;;;;;AAG/C,gDAAuB;AACvB,4CAAmB;AAOnB,2CAAuC;
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["../system.ts"],"names":[],"mappings":";AAAA,+CAA+C;;;;;;AAG/C,gDAAuB;AACvB,4CAAmB;AAOnB,2CAAuC;AAyJrC,wFAzJO,iBAAO,OAyJP;AAvJT,qCAAoC;AAsJlC,wFAtJO,cAAO,OAsJP;AAnJT,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,iBAAO,CAAA;AAGjC,SAAS,QAAQ,CAAC,MAAW,EAAE,OAAY,EAAE,MAAW;IACtD,IAAI,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IAEhE,IAAI,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAA;IAChC,IAAI,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAEtC,IAAI,IAAI,GAAG,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;IACnC,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,EACjC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA,EAAE,CAAA,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;IAEnC,KAAK,IAAI,GAAG,IAAI,IAAI,EAAE;QACpB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;KAC/D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"dist/system.d.ts",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"LICENSE"
|
|
37
37
|
],
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/jest": "^28.1.
|
|
40
|
-
"esbuild": "^0.
|
|
39
|
+
"@types/jest": "^28.1.7",
|
|
40
|
+
"esbuild": "^0.15.3",
|
|
41
41
|
"esbuild-jest": "^0.5.0",
|
|
42
|
-
"jest": "^28.1.
|
|
43
|
-
"ts-jest": "^28.0.
|
|
42
|
+
"jest": "^28.1.3",
|
|
43
|
+
"ts-jest": "^28.0.8",
|
|
44
44
|
"typescript": "^4.7.4"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@jsonic/jsonic-next": "^2.
|
|
48
|
-
"patrun": "^7.2.
|
|
47
|
+
"@jsonic/jsonic-next": "^2.3.0",
|
|
48
|
+
"patrun": "^7.2.5"
|
|
49
49
|
}
|
|
50
50
|
}
|
package/system.ts
CHANGED
|
@@ -24,7 +24,8 @@ function messages(seneca: any, options: any, reload: any) {
|
|
|
24
24
|
let srvmodel = model.main.srv[srvname]
|
|
25
25
|
|
|
26
26
|
let msgs = srvmsgs(srvmodel, model)
|
|
27
|
-
console.log('SYSTEM: MESSAGES FOUND', srvname,
|
|
27
|
+
console.log('SYSTEM: MESSAGES FOUND', srvname,
|
|
28
|
+
msgs.map(m=>m.pattern))
|
|
28
29
|
|
|
29
30
|
for (let msg of msgs) {
|
|
30
31
|
seneca.message(msg.pattern, reload(actpath(msg), { options }))
|
|
@@ -86,6 +87,67 @@ function Local(this: any, options: any) {
|
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
|
|
90
|
+
type LiveOptions = {
|
|
91
|
+
srv: {
|
|
92
|
+
name: string,
|
|
93
|
+
folder: string,
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
// Srv options by name
|
|
97
|
+
options: Record<string, any>
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
function Live(
|
|
102
|
+
this: any,
|
|
103
|
+
options: LiveOptions
|
|
104
|
+
) {
|
|
105
|
+
const model = this.context.model
|
|
106
|
+
const srvname = options.srv.name
|
|
107
|
+
|
|
108
|
+
let srvdef = model.main.srv[srvname]
|
|
109
|
+
srvdef.name = srvname
|
|
110
|
+
|
|
111
|
+
let deps = srvdef.deps || {}
|
|
112
|
+
|
|
113
|
+
let srvs = Object
|
|
114
|
+
.entries(deps)
|
|
115
|
+
.reduce(((srvdefs, dep) => {
|
|
116
|
+
let depname = dep[0]
|
|
117
|
+
let depsrv = model.main.srv[depname]
|
|
118
|
+
depsrv.name = depname
|
|
119
|
+
srvdefs.push(depsrv)
|
|
120
|
+
return srvdefs
|
|
121
|
+
}), ([] as any[]))
|
|
122
|
+
|
|
123
|
+
srvs.push(srvdef)
|
|
124
|
+
|
|
125
|
+
useSrvs(this, srvs, options, model)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
function useSrvs(seneca: any, srvs: any[], options: LiveOptions, model: any) {
|
|
130
|
+
const folder = options.srv.folder
|
|
131
|
+
|
|
132
|
+
// index by srv name, overrides model
|
|
133
|
+
const srvOptions = options.options || {}
|
|
134
|
+
|
|
135
|
+
for (const srv of srvs) {
|
|
136
|
+
let name = srv.name
|
|
137
|
+
let srvpath = Path.join(folder, name, name + '-srv.js')
|
|
138
|
+
|
|
139
|
+
if (Fs.existsSync(srvpath)) {
|
|
140
|
+
let srvopts = deep({}, srv.options, srvOptions[name])
|
|
141
|
+
seneca.root.use(srvpath, srvopts)
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
seneca.log.warn('srv-not-found', { name, srvpath: srvpath })
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
89
151
|
|
|
90
152
|
const System = {
|
|
91
153
|
messages,
|
|
@@ -102,4 +164,5 @@ export {
|
|
|
102
164
|
MakeSrv,
|
|
103
165
|
Utility,
|
|
104
166
|
Local,
|
|
167
|
+
Live,
|
|
105
168
|
}
|