@spfn/core 0.1.0-alpha.82 → 0.1.0-alpha.84
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/cache/index.js +6 -136
- package/dist/cache/index.js.map +1 -1
- package/dist/codegen/generators/index.js +6 -134
- package/dist/codegen/generators/index.js.map +1 -1
- package/dist/codegen/index.d.ts +5 -0
- package/dist/codegen/index.js +21 -145
- package/dist/codegen/index.js.map +1 -1
- package/dist/db/index.d.ts +1 -0
- package/dist/db/index.js +41 -135
- package/dist/db/index.js.map +1 -1
- package/dist/env/index.js +6 -134
- package/dist/env/index.js.map +1 -1
- package/dist/events/index.d.ts +183 -0
- package/dist/events/index.js +77 -0
- package/dist/events/index.js.map +1 -0
- package/dist/index.js +174 -180
- package/dist/index.js.map +1 -1
- package/dist/logger/index.d.ts +90 -34
- package/dist/logger/index.js +7 -137
- package/dist/logger/index.js.map +1 -1
- package/dist/middleware/index.js +22 -138
- package/dist/middleware/index.js.map +1 -1
- package/dist/route/index.js +12 -152
- package/dist/route/index.js.map +1 -1
- package/dist/server/index.d.ts +110 -4
- package/dist/server/index.js +174 -180
- package/dist/server/index.js.map +1 -1
- package/package.json +7 -4
package/dist/codegen/index.d.ts
CHANGED
|
@@ -27,7 +27,12 @@ declare class CodegenOrchestrator {
|
|
|
27
27
|
private readonly debug;
|
|
28
28
|
private isGenerating;
|
|
29
29
|
private pendingRegenerations;
|
|
30
|
+
private watcher?;
|
|
30
31
|
constructor(options: OrchestratorOptions);
|
|
32
|
+
/**
|
|
33
|
+
* Close watcher and cleanup resources
|
|
34
|
+
*/
|
|
35
|
+
close(): Promise<void>;
|
|
31
36
|
/**
|
|
32
37
|
* Check if generator should run for given trigger
|
|
33
38
|
*/
|
package/dist/codegen/index.js
CHANGED
|
@@ -1,78 +1,12 @@
|
|
|
1
1
|
import { watch } from 'chokidar';
|
|
2
2
|
import { join, relative } from 'path';
|
|
3
3
|
import mm from 'micromatch';
|
|
4
|
-
import
|
|
5
|
-
import { existsSync, mkdirSync, accessSync, constants, writeFileSync, unlinkSync, createWriteStream, statSync, readdirSync, renameSync, readFileSync } from 'fs';
|
|
4
|
+
import { existsSync, mkdirSync, createWriteStream, statSync, readdirSync, renameSync, unlinkSync, accessSync, constants, writeFileSync, readFileSync } from 'fs';
|
|
6
5
|
import { readdir, stat, mkdir, writeFile } from 'fs/promises';
|
|
7
6
|
import * as ts from 'typescript';
|
|
8
7
|
import { createJiti } from 'jiti';
|
|
9
8
|
|
|
10
9
|
// src/codegen/core/orchestrator.ts
|
|
11
|
-
var PinoAdapter = class _PinoAdapter {
|
|
12
|
-
logger;
|
|
13
|
-
constructor(config) {
|
|
14
|
-
const isDevelopment = process.env.NODE_ENV === "development";
|
|
15
|
-
const transport = isDevelopment ? {
|
|
16
|
-
target: "pino-pretty",
|
|
17
|
-
options: {
|
|
18
|
-
colorize: true,
|
|
19
|
-
translateTime: "HH:MM:ss.l",
|
|
20
|
-
ignore: "pid,hostname",
|
|
21
|
-
singleLine: false,
|
|
22
|
-
messageFormat: "{module} {msg}",
|
|
23
|
-
errorLikeObjectKeys: ["err", "error"]
|
|
24
|
-
}
|
|
25
|
-
} : void 0;
|
|
26
|
-
try {
|
|
27
|
-
this.logger = pino({
|
|
28
|
-
level: config.level,
|
|
29
|
-
// 기본 필드
|
|
30
|
-
base: config.module ? { module: config.module } : void 0,
|
|
31
|
-
// Transport (pretty print in development if available)
|
|
32
|
-
transport
|
|
33
|
-
});
|
|
34
|
-
} catch (error) {
|
|
35
|
-
this.logger = pino({
|
|
36
|
-
level: config.level,
|
|
37
|
-
base: config.module ? { module: config.module } : void 0
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
child(module) {
|
|
42
|
-
const childLogger = new _PinoAdapter({ level: this.logger.level, module });
|
|
43
|
-
childLogger.logger = this.logger.child({ module });
|
|
44
|
-
return childLogger;
|
|
45
|
-
}
|
|
46
|
-
debug(message, context) {
|
|
47
|
-
this.logger.debug(context || {}, message);
|
|
48
|
-
}
|
|
49
|
-
info(message, context) {
|
|
50
|
-
this.logger.info(context || {}, message);
|
|
51
|
-
}
|
|
52
|
-
warn(message, errorOrContext, context) {
|
|
53
|
-
if (errorOrContext instanceof Error) {
|
|
54
|
-
this.logger.warn({ err: errorOrContext, ...context }, message);
|
|
55
|
-
} else {
|
|
56
|
-
this.logger.warn(errorOrContext || {}, message);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
error(message, errorOrContext, context) {
|
|
60
|
-
if (errorOrContext instanceof Error) {
|
|
61
|
-
this.logger.error({ err: errorOrContext, ...context }, message);
|
|
62
|
-
} else {
|
|
63
|
-
this.logger.error(errorOrContext || {}, message);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
fatal(message, errorOrContext, context) {
|
|
67
|
-
if (errorOrContext instanceof Error) {
|
|
68
|
-
this.logger.fatal({ err: errorOrContext, ...context }, message);
|
|
69
|
-
} else {
|
|
70
|
-
this.logger.fatal(errorOrContext || {}, message);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
async close() {
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
10
|
|
|
77
11
|
// src/logger/types.ts
|
|
78
12
|
var LOG_LEVEL_PRIORITY = {
|
|
@@ -713,7 +647,7 @@ function validateConfig() {
|
|
|
713
647
|
}
|
|
714
648
|
}
|
|
715
649
|
|
|
716
|
-
// src/logger/
|
|
650
|
+
// src/logger/factory.ts
|
|
717
651
|
function initializeTransports() {
|
|
718
652
|
const transports = [];
|
|
719
653
|
const consoleConfig = getConsoleConfig();
|
|
@@ -724,74 +658,12 @@ function initializeTransports() {
|
|
|
724
658
|
}
|
|
725
659
|
return transports;
|
|
726
660
|
}
|
|
727
|
-
var CustomAdapter = class _CustomAdapter {
|
|
728
|
-
logger;
|
|
729
|
-
constructor(config) {
|
|
730
|
-
this.logger = new Logger({
|
|
731
|
-
level: config.level,
|
|
732
|
-
module: config.module,
|
|
733
|
-
transports: initializeTransports()
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
child(module) {
|
|
737
|
-
const adapter = new _CustomAdapter({ level: this.logger.level, module });
|
|
738
|
-
adapter.logger = this.logger.child(module);
|
|
739
|
-
return adapter;
|
|
740
|
-
}
|
|
741
|
-
debug(message, context) {
|
|
742
|
-
this.logger.debug(message, context);
|
|
743
|
-
}
|
|
744
|
-
info(message, context) {
|
|
745
|
-
this.logger.info(message, context);
|
|
746
|
-
}
|
|
747
|
-
warn(message, errorOrContext, context) {
|
|
748
|
-
if (errorOrContext instanceof Error) {
|
|
749
|
-
this.logger.warn(message, errorOrContext, context);
|
|
750
|
-
} else {
|
|
751
|
-
this.logger.warn(message, errorOrContext);
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
error(message, errorOrContext, context) {
|
|
755
|
-
if (errorOrContext instanceof Error) {
|
|
756
|
-
this.logger.error(message, errorOrContext, context);
|
|
757
|
-
} else {
|
|
758
|
-
this.logger.error(message, errorOrContext);
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
fatal(message, errorOrContext, context) {
|
|
762
|
-
if (errorOrContext instanceof Error) {
|
|
763
|
-
this.logger.fatal(message, errorOrContext, context);
|
|
764
|
-
} else {
|
|
765
|
-
this.logger.fatal(message, errorOrContext);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
async close() {
|
|
769
|
-
await this.logger.close();
|
|
770
|
-
}
|
|
771
|
-
};
|
|
772
|
-
|
|
773
|
-
// src/logger/adapter-factory.ts
|
|
774
|
-
function createAdapter(type) {
|
|
775
|
-
const level = getDefaultLogLevel();
|
|
776
|
-
switch (type) {
|
|
777
|
-
case "pino":
|
|
778
|
-
return new PinoAdapter({ level });
|
|
779
|
-
case "custom":
|
|
780
|
-
return new CustomAdapter({ level });
|
|
781
|
-
default:
|
|
782
|
-
return new PinoAdapter({ level });
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
function getAdapterType() {
|
|
786
|
-
const adapterEnv = process.env.LOGGER_ADAPTER;
|
|
787
|
-
if (adapterEnv === "custom" || adapterEnv === "pino") {
|
|
788
|
-
return adapterEnv;
|
|
789
|
-
}
|
|
790
|
-
return "pino";
|
|
791
|
-
}
|
|
792
661
|
function initializeLogger() {
|
|
793
662
|
validateConfig();
|
|
794
|
-
return
|
|
663
|
+
return new Logger({
|
|
664
|
+
level: getDefaultLogLevel(),
|
|
665
|
+
transports: initializeTransports()
|
|
666
|
+
});
|
|
795
667
|
}
|
|
796
668
|
var logger = initializeLogger();
|
|
797
669
|
|
|
@@ -803,11 +675,24 @@ var CodegenOrchestrator = class {
|
|
|
803
675
|
debug;
|
|
804
676
|
isGenerating = false;
|
|
805
677
|
pendingRegenerations = /* @__PURE__ */ new Set();
|
|
678
|
+
watcher;
|
|
806
679
|
constructor(options) {
|
|
807
680
|
this.generators = options.generators;
|
|
808
681
|
this.cwd = options.cwd ?? process.cwd();
|
|
809
682
|
this.debug = options.debug ?? false;
|
|
810
683
|
}
|
|
684
|
+
/**
|
|
685
|
+
* Close watcher and cleanup resources
|
|
686
|
+
*/
|
|
687
|
+
async close() {
|
|
688
|
+
if (this.watcher) {
|
|
689
|
+
if (this.debug) {
|
|
690
|
+
orchestratorLogger.info("Closing watcher");
|
|
691
|
+
}
|
|
692
|
+
await this.watcher.close();
|
|
693
|
+
this.watcher = void 0;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
811
696
|
/**
|
|
812
697
|
* Check if generator should run for given trigger
|
|
813
698
|
*/
|
|
@@ -876,7 +761,7 @@ var CodegenOrchestrator = class {
|
|
|
876
761
|
cwd: this.cwd
|
|
877
762
|
});
|
|
878
763
|
}
|
|
879
|
-
|
|
764
|
+
this.watcher = watch(watchDirs, {
|
|
880
765
|
ignored: /(^|[\/\\])\../,
|
|
881
766
|
// ignore dotfiles
|
|
882
767
|
persistent: true,
|
|
@@ -933,16 +818,7 @@ var CodegenOrchestrator = class {
|
|
|
933
818
|
await handleChange(next, "change");
|
|
934
819
|
}
|
|
935
820
|
};
|
|
936
|
-
watcher.on("add", (path) => handleChange(path, "add")).on("change", (path) => handleChange(path, "change")).on("unlink", (path) => handleChange(path, "unlink"));
|
|
937
|
-
process.on("SIGINT", () => {
|
|
938
|
-
if (this.debug) {
|
|
939
|
-
orchestratorLogger.info("Shutting down watch mode");
|
|
940
|
-
}
|
|
941
|
-
watcher.close();
|
|
942
|
-
process.exit(0);
|
|
943
|
-
});
|
|
944
|
-
await new Promise(() => {
|
|
945
|
-
});
|
|
821
|
+
this.watcher.on("add", (path) => handleChange(path, "add")).on("change", (path) => handleChange(path, "change")).on("unlink", (path) => handleChange(path, "unlink"));
|
|
946
822
|
}
|
|
947
823
|
};
|
|
948
824
|
var scannerLogger = logger.child("contract-scanner");
|