@adviser/cement 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +39 -0
  3. package/adviser-cement-0.0.1.tgz +0 -0
  4. package/file_service.d.ts +17 -0
  5. package/file_service.d.ts.map +1 -0
  6. package/file_service.js +3 -0
  7. package/file_service.js.map +1 -0
  8. package/index.d.ts +10 -0
  9. package/index.d.ts.map +1 -0
  10. package/index.js +26 -0
  11. package/index.js.map +1 -0
  12. package/logger.d.ts +31 -0
  13. package/logger.d.ts.map +1 -0
  14. package/logger.js +11 -0
  15. package/logger.js.map +1 -0
  16. package/logger.test.d.ts +2 -0
  17. package/logger.test.d.ts.map +1 -0
  18. package/logger.test.js +228 -0
  19. package/logger.test.js.map +1 -0
  20. package/logger_impl.d.ts +46 -0
  21. package/logger_impl.d.ts.map +1 -0
  22. package/logger_impl.js +260 -0
  23. package/logger_impl.js.map +1 -0
  24. package/mock_file_service.d.ts +20 -0
  25. package/mock_file_service.d.ts.map +1 -0
  26. package/mock_file_service.js +80 -0
  27. package/mock_file_service.js.map +1 -0
  28. package/node_file_service.d.ts +15 -0
  29. package/node_file_service.d.ts.map +1 -0
  30. package/node_file_service.js +78 -0
  31. package/node_file_service.js.map +1 -0
  32. package/node_sys_abstraction.d.ts +91 -0
  33. package/node_sys_abstraction.d.ts.map +1 -0
  34. package/node_sys_abstraction.js +265 -0
  35. package/node_sys_abstraction.js.map +1 -0
  36. package/node_sys_abstraction.test.d.ts +2 -0
  37. package/node_sys_abstraction.test.d.ts.map +1 -0
  38. package/node_sys_abstraction.test.js +123 -0
  39. package/node_sys_abstraction.test.js.map +1 -0
  40. package/package.json +40 -0
  41. package/sys_abstraction.d.ts +35 -0
  42. package/sys_abstraction.d.ts.map +1 -0
  43. package/sys_abstraction.js +35 -0
  44. package/sys_abstraction.js.map +1 -0
  45. package/test/log_collector.d.ts +22 -0
  46. package/test/log_collector.d.ts.map +1 -0
  47. package/test/log_collector.js +65 -0
  48. package/test/log_collector.js.map +1 -0
  49. package/test/mock_logger.d.ts +13 -0
  50. package/test/mock_logger.d.ts.map +1 -0
  51. package/test/mock_logger.js +23 -0
  52. package/test/mock_logger.js.map +1 -0
  53. package/test/mock_logger.test.d.ts +2 -0
  54. package/test/mock_logger.test.d.ts.map +1 -0
  55. package/test/mock_logger.test.js +49 -0
  56. package/test/mock_logger.test.js.map +1 -0
  57. package/test/test-exit-handler.d.ts +1 -0
  58. package/test/test-exit-handler.d.ts.map +1 -0
  59. package/test/test-exit-handler.js +76 -0
  60. package/test/test-exit-handler.js.map +1 -0
  61. package/time.d.ts +13 -0
  62. package/time.d.ts.map +1 -0
  63. package/time.js +18 -0
  64. package/time.js.map +1 -0
@@ -0,0 +1,46 @@
1
+ import { Level, Logger, WithLogger } from "./logger";
2
+ import { SysAbstraction } from "./sys_abstraction";
3
+ type JsonRecord = Record<string, string | number | boolean | unknown>;
4
+ export declare class LogWriter {
5
+ readonly _out: WritableStream<Uint8Array>;
6
+ readonly _toFlush: Array<() => Promise<void>>;
7
+ readonly modules: Set<string>;
8
+ constructor(out: WritableStream<Uint8Array>);
9
+ write(encoded: Uint8Array): void;
10
+ _flushIsRunning: boolean;
11
+ _flushDoneFns: (() => void)[];
12
+ _flush(toFlush?: Array<() => Promise<void>> | undefined, done?: () => void): void;
13
+ }
14
+ export interface LoggerImplParams {
15
+ readonly out?: WritableStream<Uint8Array>;
16
+ readonly logWriter?: LogWriter;
17
+ readonly sys?: SysAbstraction;
18
+ readonly withAttributes?: JsonRecord;
19
+ }
20
+ export declare class LoggerImpl implements Logger {
21
+ readonly _sys: SysAbstraction;
22
+ readonly _attributes: JsonRecord;
23
+ readonly _withAttributes: JsonRecord;
24
+ readonly _logWriter: LogWriter;
25
+ constructor(params?: LoggerImplParams);
26
+ Module(key: string): Logger;
27
+ SetDebug(...modules: (string | string[])[]): Logger;
28
+ Timestamp(): Logger;
29
+ Warn(): Logger;
30
+ Log(): Logger;
31
+ Debug(): Logger;
32
+ Error(): Logger;
33
+ Info(): Logger;
34
+ Err(err: unknown): Logger;
35
+ WithLevel(l: Level): Logger;
36
+ Str(key: string, value: string): Logger;
37
+ Any(key: string, value: string | number | boolean | JsonRecord): Logger;
38
+ Dur(key: string, nsec: number): Logger;
39
+ Uint64(key: string, value: number): Logger;
40
+ Flush(): Promise<void>;
41
+ With(): WithLogger;
42
+ _resetAttributes(fn: () => void): void;
43
+ Msg(...args: string[]): void;
44
+ }
45
+ export {};
46
+ //# sourceMappingURL=logger_impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger_impl.d.ts","sourceRoot":"","sources":["../src/logger_impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC;AAEtE,qBAAa,SAAS;IACpB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAC1C,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAAM;IACnD,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;gBAE9B,GAAG,EAAE,cAAc,CAAC,UAAU,CAAC;IAI3C,KAAK,CAAC,OAAO,EAAE,UAAU;IAkBzB,eAAe,UAAS;IACxB,aAAa,SAAe,IAAI,IAAI;IACpC,MAAM,CAAC,OAAO,GAAE,KAAK,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAqB,EAAE,IAAI,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI;CA4B7F;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC,UAAU,CAA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AAG,IAAI;IAOtC,GAAG,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI;CAqB7B"}
package/logger_impl.js ADDED
@@ -0,0 +1,260 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoggerImpl = exports.LogWriter = void 0;
4
+ const logger_1 = require("./logger");
5
+ const node_sys_abstraction_1 = require("./node_sys_abstraction");
6
+ const encoder = new TextEncoder();
7
+ class LogWriter {
8
+ constructor(out) {
9
+ this._toFlush = [];
10
+ this.modules = new Set();
11
+ this._flushIsRunning = false;
12
+ this._flushDoneFns = Array();
13
+ this._out = out;
14
+ }
15
+ write(encoded) {
16
+ const my = async () => {
17
+ try {
18
+ const writer = this._out.getWriter();
19
+ await writer.ready;
20
+ await writer.write(encoded);
21
+ await writer.releaseLock();
22
+ }
23
+ catch (err) {
24
+ console.error("Chunk error:", err);
25
+ }
26
+ };
27
+ this._toFlush.push(my);
28
+ this._flush();
29
+ }
30
+ _flush(toFlush = undefined, done) {
31
+ if (done) {
32
+ this._flushDoneFns.push(done);
33
+ }
34
+ if (this._toFlush.length == 0) {
35
+ this._flushIsRunning = false;
36
+ this._flushDoneFns.forEach((fn) => fn());
37
+ this._flushDoneFns = [];
38
+ return;
39
+ }
40
+ if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {
41
+ this._flushIsRunning = true;
42
+ }
43
+ else if (!toFlush) {
44
+ return;
45
+ }
46
+ const my = this._toFlush.shift();
47
+ my().finally(() => {
48
+ this._flush(this._toFlush);
49
+ });
50
+ }
51
+ }
52
+ exports.LogWriter = LogWriter;
53
+ class LoggerImpl {
54
+ constructor(params) {
55
+ this._attributes = {};
56
+ if (!params) {
57
+ params = {};
58
+ }
59
+ if (!params.sys) {
60
+ this._sys = new node_sys_abstraction_1.NodeSysAbstraction();
61
+ }
62
+ else {
63
+ this._sys = params.sys;
64
+ }
65
+ if (params.logWriter) {
66
+ this._logWriter = params.logWriter;
67
+ }
68
+ else {
69
+ if (!params.out) {
70
+ this._logWriter = new LogWriter(this._sys.Stdout());
71
+ }
72
+ else {
73
+ this._logWriter = new LogWriter(params.out);
74
+ }
75
+ }
76
+ if (!params.withAttributes) {
77
+ this._withAttributes = {};
78
+ }
79
+ else {
80
+ this._withAttributes = Object.assign({}, params.withAttributes);
81
+ }
82
+ this._attributes = Object.assign({}, this._withAttributes);
83
+ }
84
+ Module(key) {
85
+ this._attributes["module"] = key;
86
+ this._withAttributes["module"] = key;
87
+ return this;
88
+ }
89
+ SetDebug(...modules) {
90
+ for (const m of modules.flat()) {
91
+ const parts = m
92
+ .split(",")
93
+ .map((s) => s.trim())
94
+ .filter((s) => s.length > 0);
95
+ for (const p of parts) {
96
+ this._logWriter.modules.add(p);
97
+ }
98
+ }
99
+ return this;
100
+ }
101
+ Timestamp() {
102
+ this._attributes["ts"] = this._sys.Time().Now().toISOString();
103
+ return this;
104
+ }
105
+ Warn() {
106
+ this._attributes["level"] = logger_1.Level.WARN;
107
+ return this;
108
+ }
109
+ Log() {
110
+ return this;
111
+ }
112
+ Debug() {
113
+ this._attributes["level"] = logger_1.Level.DEBUG;
114
+ return this;
115
+ }
116
+ Error() {
117
+ this._attributes["level"] = logger_1.Level.ERROR;
118
+ return this;
119
+ }
120
+ Info() {
121
+ this._attributes["level"] = logger_1.Level.INFO;
122
+ return this;
123
+ }
124
+ Err(err) {
125
+ if (err instanceof Error) {
126
+ this._attributes["error"] = err.message;
127
+ }
128
+ else {
129
+ this._attributes["error"] = "" + err;
130
+ }
131
+ return this;
132
+ }
133
+ WithLevel(l) {
134
+ this._attributes["level"] = l;
135
+ return this;
136
+ }
137
+ Str(key, value) {
138
+ this._attributes[key] = value;
139
+ return this;
140
+ }
141
+ Any(key, value) {
142
+ this._attributes[key] = value;
143
+ return this;
144
+ }
145
+ Dur(key, nsec) {
146
+ this._attributes[key] = `${nsec}ms`;
147
+ return this;
148
+ }
149
+ Uint64(key, value) {
150
+ this._attributes[key] = value;
151
+ return this;
152
+ }
153
+ async Flush() {
154
+ return new Promise((resolve) => {
155
+ this._logWriter._flush(undefined, resolve);
156
+ });
157
+ }
158
+ With() {
159
+ return new WithLoggerBuilder(new LoggerImpl({
160
+ logWriter: this._logWriter,
161
+ sys: this._sys,
162
+ withAttributes: Object.assign({ module: this._attributes["module"] }, this._withAttributes),
163
+ }));
164
+ }
165
+ _resetAttributes(fn) {
166
+ fn();
167
+ Object.keys(this._attributes).forEach((key) => {
168
+ delete this._attributes[key];
169
+ });
170
+ Object.assign(this._attributes, this._withAttributes);
171
+ }
172
+ Msg(...args) {
173
+ this._resetAttributes(() => {
174
+ if (this._attributes["level"] === logger_1.Level.DEBUG) {
175
+ if (typeof this._attributes["module"] !== "string") {
176
+ return;
177
+ }
178
+ if (!this._logWriter.modules.has(this._attributes["module"])) {
179
+ return;
180
+ }
181
+ }
182
+ this._attributes["msg"] = args.join(" ");
183
+ if (typeof this._attributes["msg"] === "string" && !this._attributes["msg"].trim().length) {
184
+ delete this._attributes["msg"];
185
+ }
186
+ if (this._attributes["ts"] === "ETERNITY") {
187
+ this.Timestamp();
188
+ }
189
+ const encoded = encoder.encode(JSON.stringify(this._attributes) + "\n");
190
+ this._logWriter.write(encoded);
191
+ });
192
+ }
193
+ }
194
+ exports.LoggerImpl = LoggerImpl;
195
+ class WithLoggerBuilder {
196
+ constructor(li) {
197
+ this._li = li;
198
+ }
199
+ Logger() {
200
+ Object.assign(this._li._withAttributes, this._li._attributes);
201
+ return this._li;
202
+ }
203
+ Module(key) {
204
+ this._li.Module(key);
205
+ return this;
206
+ }
207
+ SetDebug(...modules) {
208
+ this._li.SetDebug(...modules);
209
+ return this;
210
+ }
211
+ Str(key, value) {
212
+ this._li.Str(key, value);
213
+ return this;
214
+ }
215
+ Log() {
216
+ this._li.Log();
217
+ return this;
218
+ }
219
+ WithLevel(level) {
220
+ this._li.WithLevel(level);
221
+ return this;
222
+ }
223
+ Error() {
224
+ this._li.Error();
225
+ return this;
226
+ }
227
+ Warn() {
228
+ this._li.Error();
229
+ return this;
230
+ }
231
+ Debug() {
232
+ this._li.Debug();
233
+ return this;
234
+ }
235
+ Err(err) {
236
+ this._li.Err(err);
237
+ return this;
238
+ }
239
+ Info() {
240
+ this._li.Info();
241
+ return this;
242
+ }
243
+ Timestamp() {
244
+ this._li._attributes["ts"] = "ETERNITY";
245
+ return this;
246
+ }
247
+ Any(key, value) {
248
+ this._li.Any(key, value);
249
+ return this;
250
+ }
251
+ Dur(key, nsec) {
252
+ this._li.Dur(key, nsec);
253
+ return this;
254
+ }
255
+ Uint64(key, value) {
256
+ this._li.Uint64(key, value);
257
+ return this;
258
+ }
259
+ }
260
+ //# sourceMappingURL=logger_impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger_impl.js","sourceRoot":"","sources":["../src/logger_impl.ts"],"names":[],"mappings":";;;AACA,qCAAqD;AACrD,iEAA4D;AAG5D,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAIlC,MAAa,SAAS;IAKpB,YAAY,GAA+B;QAHlC,aAAQ,GAA+B,EAAE,CAAC;QAC1C,YAAO,GAAgB,IAAI,GAAG,EAAE,CAAC;QAwB1C,oBAAe,GAAG,KAAK,CAAC;QACxB,kBAAa,GAAG,KAAK,EAAc,CAAC;QAtBlC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,OAAmB;QACvB,MAAM,EAAE,GAAG,KAAK,IAAI,EAAE;YAGpB,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;gBACrC,MAAM,MAAM,CAAC,KAAK,CAAC;gBACnB,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAC5B,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;YAC7B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,C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,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI;QACF,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,SAAS;QACP,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,GAAG,CAAC,GAAW,EAAE,KAAiB;QAChC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,GAAG,CAAC,GAAW,EAAE,IAAY;QAC3B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,CAAC,GAAW,EAAE,KAAa;QAC/B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import { FileService, NamedWritableStream } from "./file_service";
2
+ export interface FileCollector {
3
+ readonly name: string;
4
+ content: string;
5
+ }
6
+ export declare class MockFileService implements FileService {
7
+ readonly baseDir: string;
8
+ constructor(baseDir?: string);
9
+ nodeImport(fname: string): string;
10
+ readFileString(fname: string): Promise<string>;
11
+ dirname(fname: string): string;
12
+ basename(fname: string): string;
13
+ join(...paths: string[]): string;
14
+ relative(from: string, to?: string): string;
15
+ abs(fname: string): string;
16
+ isAbsolute(fname: string): boolean;
17
+ readonly files: Record<string, FileCollector>;
18
+ create(fname: string): Promise<NamedWritableStream>;
19
+ }
20
+ //# sourceMappingURL=mock_file_service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock_file_service.d.ts","sourceRoot":"","sources":["../src/mock_file_service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAElE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,eAAgB,YAAW,WAAW;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBACb,OAAO,GAAE,MAAsB;IAI3C,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IASjC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI9C,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI9B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI/B,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;IAIhC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAU3C,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAS1B,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIlC,QAAQ,CAAC,KAAK,gCAAuC;IAE/C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CA0B1D"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MockFileService = void 0;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const promises_1 = __importDefault(require("node:fs/promises"));
9
+ class MockFileService {
10
+ constructor(baseDir = process.cwd()) {
11
+ this.files = {};
12
+ this.baseDir = this.abs(baseDir);
13
+ }
14
+ nodeImport(fname) {
15
+ if (node_path_1.default.isAbsolute(fname)) {
16
+ return fname;
17
+ }
18
+ else {
19
+ return "./" + node_path_1.default.normalize(fname);
20
+ }
21
+ }
22
+ readFileString(fname) {
23
+ return promises_1.default.readFile(fname, { encoding: "utf-8" });
24
+ }
25
+ dirname(fname) {
26
+ return node_path_1.default.dirname(fname);
27
+ }
28
+ basename(fname) {
29
+ return node_path_1.default.basename(fname);
30
+ }
31
+ join(...paths) {
32
+ return node_path_1.default.join(...paths);
33
+ }
34
+ relative(from, to) {
35
+ if (to === undefined) {
36
+ to = from;
37
+ from = process.cwd();
38
+ }
39
+ const ret = node_path_1.default.relative(from, to);
40
+ return ret;
41
+ }
42
+ abs(fname) {
43
+ if (this.isAbsolute(fname)) {
44
+ return fname;
45
+ }
46
+ else {
47
+ const cwd = process.cwd();
48
+ return node_path_1.default.resolve(cwd, fname);
49
+ }
50
+ }
51
+ isAbsolute(fname) {
52
+ return node_path_1.default.isAbsolute(fname);
53
+ }
54
+ async create(fname) {
55
+ let oName = fname;
56
+ if (!node_path_1.default.isAbsolute(fname)) {
57
+ oName = this.abs(fname);
58
+ }
59
+ const fc = {
60
+ name: oName,
61
+ content: "",
62
+ };
63
+ this.files[oName] = fc;
64
+ const decoder = new TextDecoder();
65
+ return {
66
+ name: oName,
67
+ stream: new WritableStream({
68
+ write(chunk) {
69
+ fc.content = fc.content + decoder.decode(chunk);
70
+ },
71
+ close() { },
72
+ abort() {
73
+ throw new Error("not implemented");
74
+ },
75
+ }),
76
+ };
77
+ }
78
+ }
79
+ exports.MockFileService = MockFileService;
80
+ //# sourceMappingURL=mock_file_service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock_file_service.js","sourceRoot":"","sources":["../src/mock_file_service.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,gEAAkC;AAQlC,MAAa,eAAe;IAE1B,YAAY,UAAkB,OAAO,CAAC,GAAG,EAAE;QAoDlC,UAAK,GAAG,EAAmC,CAAC;QAnDnD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC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ACH,CAAC;IAED,UAAU,CAAC,KAAa;QACtB,OAAO,mBAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAID,KAAK,CAAC,MAAM,CAAC,KAAa;QACxB,IAAI,KAAK,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,mBAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;QAED,MAAM,EAAE,GAAG;YACT,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,EAAE;SACZ,CAAC;QACF,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAElC,OAAO;YACL,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,IAAI,cAAc,CAAa;gBACrC,KAAK,CAAC,KAAK;oBACT,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAClD,CAAC;gBACD,KAAK,KAAI,CAAC;gBACV,KAAK;oBACH,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;gBACrC,CAAC;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF;AAlFD,0CAkFC"}
@@ -0,0 +1,15 @@
1
+ import { FileService, NamedWritableStream } from "./file_service";
2
+ export declare class NodeFileService implements FileService {
3
+ readonly baseDir: string;
4
+ constructor(baseDir?: string);
5
+ nodeImport(fname: string): string;
6
+ readFileString(fname: string): Promise<string>;
7
+ dirname(fname: string): string;
8
+ basename(fname: string): string;
9
+ join(...paths: string[]): string;
10
+ relative(from: string, to?: string): string;
11
+ abs(fname: string): string;
12
+ isAbsolute(fname: string): boolean;
13
+ create(fname: string): Promise<NamedWritableStream>;
14
+ }
15
+ //# sourceMappingURL=node_file_service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node_file_service.d.ts","sourceRoot":"","sources":["../src/node_file_service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAElE,qBAAa,eAAgB,YAAW,WAAW;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBACb,OAAO,GAAE,MAAsB;IAI3C,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IASjC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI9C,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAG9B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI/B,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;IAIhC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAU3C,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAS1B,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI5B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAwB1D"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NodeFileService = void 0;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ class NodeFileService {
10
+ constructor(baseDir = process.cwd()) {
11
+ this.baseDir = this.abs(baseDir);
12
+ }
13
+ nodeImport(fname) {
14
+ if (node_path_1.default.isAbsolute(fname)) {
15
+ return fname;
16
+ }
17
+ else {
18
+ return "./" + node_path_1.default.normalize(fname);
19
+ }
20
+ }
21
+ readFileString(fname) {
22
+ return node_fs_1.default.promises.readFile(fname, { encoding: "utf-8" });
23
+ }
24
+ dirname(fname) {
25
+ return node_path_1.default.dirname(fname);
26
+ }
27
+ basename(fname) {
28
+ return node_path_1.default.basename(fname);
29
+ }
30
+ join(...paths) {
31
+ return node_path_1.default.join(...paths);
32
+ }
33
+ relative(from, to) {
34
+ if (to === undefined) {
35
+ to = from;
36
+ from = process.cwd();
37
+ }
38
+ const ret = node_path_1.default.relative(from, to);
39
+ return ret;
40
+ }
41
+ abs(fname) {
42
+ if (node_path_1.default.isAbsolute(fname)) {
43
+ return fname;
44
+ }
45
+ else {
46
+ const cwd = process.cwd();
47
+ return node_path_1.default.resolve(cwd, fname);
48
+ }
49
+ }
50
+ isAbsolute(fname) {
51
+ return node_path_1.default.isAbsolute(fname);
52
+ }
53
+ async create(fname) {
54
+ let oName = fname;
55
+ if (!node_path_1.default.isAbsolute(fname)) {
56
+ oName = this.abs(fname);
57
+ }
58
+ const base = node_path_1.default.dirname(oName);
59
+ await node_fs_1.default.promises.mkdir(base, { recursive: true });
60
+ const out = node_fs_1.default.createWriteStream(oName);
61
+ return {
62
+ name: oName,
63
+ stream: new WritableStream({
64
+ write(chunk) {
65
+ out.write(chunk);
66
+ },
67
+ close() {
68
+ out.close();
69
+ },
70
+ abort() {
71
+ throw new Error("not implemented");
72
+ },
73
+ }),
74
+ };
75
+ }
76
+ }
77
+ exports.NodeFileService = NodeFileService;
78
+ //# sourceMappingURL=node_file_service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node_file_service.js","sourceRoot":"","sources":["../src/node_file_service.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,sDAAyB;AAGzB,MAAa,eAAe;IAE1B,YAAY,UAAkB,OAAO,CAAC,GAAG,EAAE;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,UAAU,CAAC,KAAa;QAEtB,IAAI,mBAAI,CAAC,U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AC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa;QACxB,IAAI,KAAK,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,mBAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC1B,CAAC;QAED,MAAM,IAAI,GAAG,mBAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACjC,MAAM,iBAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,MAAM,GAAG,GAAG,iBAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO;YACL,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,IAAI,cAAc,CAAa;gBACrC,KAAK,CAAC,KAAK;oBACT,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACnB,CAAC;gBACD,KAAK;oBACH,GAAG,CAAC,KAAK,EAAE,CAAC;gBACd,CAAC;gBACD,KAAK;oBACH,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;gBACrC,CAAC;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF;AA7ED,0CA6EC"}
@@ -0,0 +1,91 @@
1
+ import { IDMode, RandomMode, SysAbstraction, SystemService, TimeMode, VoidFunc } from "./sys_abstraction";
2
+ import { FileService } from "./file_service";
3
+ import { NodeFileService } from "./node_file_service";
4
+ import { Time } from "./time";
5
+ declare class SysTime extends Time {
6
+ Now(): Date;
7
+ Sleep(duration: number): Promise<void>;
8
+ }
9
+ export declare class ConstTime extends Time {
10
+ Now(): Date;
11
+ Sleep(duration: number): Promise<void>;
12
+ }
13
+ export declare class StepTime extends Time {
14
+ _step: Date;
15
+ constructor();
16
+ Now(): Date;
17
+ Sleep(duration: number): Promise<void>;
18
+ }
19
+ export declare function TimeFactory(timeMode: TimeMode): Time;
20
+ export declare class RandomService {
21
+ readonly _mode: RandomMode;
22
+ _step: number;
23
+ constructor(mode: RandomMode);
24
+ Random0ToValue(value: number): number;
25
+ }
26
+ export interface SystemAbstractionImplParams {
27
+ readonly TimeMode?: TimeMode;
28
+ readonly IdMode?: IDMode;
29
+ readonly Stdout?: WritableStream<Uint8Array>;
30
+ readonly Stderr?: WritableStream<Uint8Array>;
31
+ readonly RandomMode?: RandomMode;
32
+ readonly FileSystem?: FileService;
33
+ readonly SystemService?: SystemService;
34
+ }
35
+ export declare class IdService {
36
+ readonly _mode: IDMode;
37
+ _step: number;
38
+ constructor(mode?: IDMode);
39
+ NextId(): string;
40
+ }
41
+ interface ExitHandler {
42
+ readonly hdl: VoidFunc;
43
+ readonly id: string;
44
+ }
45
+ export interface ExitService {
46
+ injectExitHandlers(hdls: ExitHandler[]): void;
47
+ exit(code: number): void;
48
+ }
49
+ export declare class ExitServiceImpl implements ExitService {
50
+ constructor();
51
+ _exitHandlers: ExitHandler[];
52
+ injectExitHandlers(hdls: ExitHandler[]): void;
53
+ invoked: boolean;
54
+ readonly _handleExit: () => Promise<void>;
55
+ exit(code: number): void;
56
+ }
57
+ export declare class NodeSystemService implements SystemService {
58
+ static readonly _exitHandlers: ExitHandler[];
59
+ readonly _exitService: ExitServiceImpl;
60
+ constructor();
61
+ Env(): Record<string, string>;
62
+ Args(): string[];
63
+ OnExit(hdl: VoidFunc): VoidFunc;
64
+ Exit(code: number): void;
65
+ }
66
+ export declare class NodeSysAbstraction implements SysAbstraction {
67
+ static readonly _time: SysTime;
68
+ static readonly _stdout: WritableStream<any>;
69
+ static readonly _stderr: WritableStream<any>;
70
+ static readonly _idService: IdService;
71
+ static readonly _randomService: RandomService;
72
+ static readonly _fileSystem: NodeFileService;
73
+ static readonly _systemService: NodeSystemService;
74
+ readonly _time: Time;
75
+ readonly _stdout: WritableStream;
76
+ readonly _stderr: WritableStream;
77
+ readonly _idService: IdService;
78
+ readonly _randomService: RandomService;
79
+ readonly _fileSystem: FileService;
80
+ readonly _systemService: SystemService;
81
+ constructor(params?: SystemAbstractionImplParams);
82
+ Time(): Time;
83
+ NextId(): string;
84
+ Random0ToValue(value: number): number;
85
+ Stdout(): WritableStream;
86
+ Stderr(): WritableStream;
87
+ System(): SystemService;
88
+ FileSystem(): FileService;
89
+ }
90
+ export {};
91
+ //# sourceMappingURL=node_sys_abstraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node_sys_abstraction.d.ts","sourceRoot":"","sources":["../src/node_sys_abstraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC1G,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,cAAM,OAAQ,SAAQ,IAAI;IACxB,GAAG,IAAI,IAAI;IAGX,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAOvC;AAED,qBAAa,SAAU,SAAQ,IAAI;IACjC,GAAG,IAAI,IAAI;IAIX,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGvC;AAED,qBAAa,QAAS,SAAQ,IAAI;IAChC,KAAK,EAAE,IAAI,CAAC;;IAKZ,GAAG;IAQH,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAIvC;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAUpD;AAID,qBAAa,aAAa;IACxB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAK;gBACN,IAAI,EAAE,UAAU;IAG5B,cAAc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