nicot 1.1.23 → 1.1.24
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/build.js +167 -0
- package/dist/index.cjs +2210 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +2184 -0
- package/dist/index.mjs.map +7 -0
- package/index.ts +0 -2
- package/package.json +20 -7
- package/dist/index.js +0 -25
- package/dist/index.js.map +0 -1
- package/dist/src/bases/base-restful-controller.js +0 -53
- package/dist/src/bases/base-restful-controller.js.map +0 -1
- package/dist/src/bases/id-base.js +0 -58
- package/dist/src/bases/id-base.js.map +0 -1
- package/dist/src/bases/index.js +0 -20
- package/dist/src/bases/index.js.map +0 -1
- package/dist/src/bases/page-settings.js +0 -64
- package/dist/src/bases/page-settings.js.map +0 -1
- package/dist/src/bases/time-base.js +0 -53
- package/dist/src/bases/time-base.js.map +0 -1
- package/dist/src/crud-base.js +0 -480
- package/dist/src/crud-base.js.map +0 -1
- package/dist/src/decorators/access.js +0 -24
- package/dist/src/decorators/access.js.map +0 -1
- package/dist/src/decorators/index.js +0 -21
- package/dist/src/decorators/index.js.map +0 -1
- package/dist/src/decorators/pipes.js +0 -26
- package/dist/src/decorators/pipes.js.map +0 -1
- package/dist/src/decorators/property.js +0 -191
- package/dist/src/decorators/property.js.map +0 -1
- package/dist/src/decorators/query.js +0 -67
- package/dist/src/decorators/query.js.map +0 -1
- package/dist/src/dto/cursor-pagination.js +0 -89
- package/dist/src/dto/cursor-pagination.js.map +0 -1
- package/dist/src/dto/import-entry.js +0 -45
- package/dist/src/dto/import-entry.js.map +0 -1
- package/dist/src/dto/index.js +0 -19
- package/dist/src/dto/index.js.map +0 -1
- package/dist/src/restful.js +0 -415
- package/dist/src/restful.js.map +0 -1
- package/dist/src/utility/bigint.js +0 -16
- package/dist/src/utility/bigint.js.map +0 -1
- package/dist/src/utility/cursor-pagination-utils.js +0 -252
- package/dist/src/utility/cursor-pagination-utils.js.map +0 -1
- package/dist/src/utility/filter-relations.js +0 -91
- package/dist/src/utility/filter-relations.js.map +0 -1
- package/dist/src/utility/get-typeorm-relations.js +0 -50
- package/dist/src/utility/get-typeorm-relations.js.map +0 -1
- package/dist/src/utility/index.js +0 -18
- package/dist/src/utility/index.js.map +0 -1
- package/dist/src/utility/metadata.js +0 -21
- package/dist/src/utility/metadata.js.map +0 -1
- package/dist/src/utility/omit-type-exclude.js +0 -14
- package/dist/src/utility/omit-type-exclude.js.map +0 -1
- package/dist/src/utility/query-full-text-column-options.interface.js +0 -3
- package/dist/src/utility/query-full-text-column-options.interface.js.map +0 -1
- package/dist/src/utility/query.js +0 -49
- package/dist/src/utility/query.js.map +0 -1
- package/dist/src/utility/recursive-key-of.js +0 -4
- package/dist/src/utility/recursive-key-of.js.map +0 -1
- package/dist/src/utility/relation-def.js +0 -3
- package/dist/src/utility/relation-def.js.map +0 -1
- package/dist/src/utility/rename-class.js +0 -8
- package/dist/src/utility/rename-class.js.map +0 -1
- package/dist/src/utility/subject-registry.js +0 -19
- package/dist/src/utility/subject-registry.js.map +0 -1
- package/dist/src/utility/type-transformer.js +0 -22
- package/dist/src/utility/type-transformer.js.map +0 -1
- package/dist/src/utility/unshift-order-by.js +0 -18
- package/dist/src/utility/unshift-order-by.js.map +0 -1
package/build.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* build.js - node build.js [all|cjs|esm|types|clean] */
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { builtinModules } = require('module');
|
|
6
|
+
|
|
7
|
+
const DIST_DIR = 'dist';
|
|
8
|
+
|
|
9
|
+
/* ------------------------- utils ------------------------- */
|
|
10
|
+
function readJSONSafe(file, fallback = {}) {
|
|
11
|
+
try {
|
|
12
|
+
const p = path.resolve(process.cwd(), file);
|
|
13
|
+
const txt = fs.readFileSync(p, 'utf8');
|
|
14
|
+
return JSON.parse(txt);
|
|
15
|
+
} catch {
|
|
16
|
+
return fallback;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function uniq(arr) { return Array.from(new Set(arr)); }
|
|
20
|
+
function ensureDir(p) { fs.mkdirSync(p, { recursive: true }); }
|
|
21
|
+
function rimraf(p) { if (fs.existsSync(p)) fs.rmSync(p, { recursive: true, force: true }); }
|
|
22
|
+
|
|
23
|
+
function depsAsExternal(pkg) {
|
|
24
|
+
const dep = Object.keys(pkg.dependencies || {});
|
|
25
|
+
const peer = Object.keys(pkg.peerDependencies || {});
|
|
26
|
+
const names = uniq([...dep, ...peer]);
|
|
27
|
+
// 覆盖子路径导入(lodash/fp、react/jsx-runtime)
|
|
28
|
+
return uniq(names.flatMap((n) => [n, `${n}/*`]));
|
|
29
|
+
}
|
|
30
|
+
function nodeBuiltinsExternal() {
|
|
31
|
+
// 既包含 'fs' 也包含 'node:fs' 形式
|
|
32
|
+
return uniq([...builtinModules, ...builtinModules.map((m) => `node:${m}`)]);
|
|
33
|
+
}
|
|
34
|
+
async function loadEsbuild() {
|
|
35
|
+
try { return require('esbuild'); }
|
|
36
|
+
catch { const mod = await import('esbuild'); return mod.build ? mod : mod.default; }
|
|
37
|
+
}
|
|
38
|
+
function tsconfigPath() { return fs.existsSync('tsconfig.json') ? 'tsconfig.json' : undefined; }
|
|
39
|
+
function entryPointsFromPkg(/*pkg*/) { return ['index.ts']; }
|
|
40
|
+
|
|
41
|
+
/* ------------------------- esbuild builds ------------------------- */
|
|
42
|
+
async function buildOne(format, options) {
|
|
43
|
+
const esbuild = await loadEsbuild();
|
|
44
|
+
const { external, tsconfig, entryPoints } = options;
|
|
45
|
+
const isCjs = format === 'cjs';
|
|
46
|
+
const outfile = path.join(DIST_DIR, isCjs ? 'index.cjs' : 'index.mjs');
|
|
47
|
+
|
|
48
|
+
ensureDir(path.dirname(outfile));
|
|
49
|
+
console.log(`[build] ${format} -> ${outfile}`);
|
|
50
|
+
|
|
51
|
+
await esbuild.build({
|
|
52
|
+
entryPoints,
|
|
53
|
+
outfile,
|
|
54
|
+
bundle: true,
|
|
55
|
+
sourcemap: true,
|
|
56
|
+
format, // 'cjs' | 'esm'
|
|
57
|
+
platform: isCjs ? 'node' : 'neutral',
|
|
58
|
+
target: isCjs ? 'es2021' : 'esnext',
|
|
59
|
+
external, // deps + peerDeps + node builtins (含 node:*)
|
|
60
|
+
logLevel: 'info',
|
|
61
|
+
...(tsconfig ? { tsconfig } : {}),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* ------------------------- types via TypeScript API ------------------------- */
|
|
66
|
+
function buildTypesAPI(outDir = DIST_DIR) {
|
|
67
|
+
let ts;
|
|
68
|
+
try { ts = require('typescript'); }
|
|
69
|
+
catch {
|
|
70
|
+
console.error('[types] Missing dependency: typescript');
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const cfgPath = ts.findConfigFile('./', ts.sys.fileExists, 'tsconfig.json');
|
|
75
|
+
|
|
76
|
+
let fileNames, options;
|
|
77
|
+
if (cfgPath) {
|
|
78
|
+
// 读取 tsconfig.json
|
|
79
|
+
const { config } = ts.readConfigFile(cfgPath, ts.sys.readFile);
|
|
80
|
+
const parsed = ts.parseJsonConfigFileContent(config, ts.sys, path.dirname(cfgPath));
|
|
81
|
+
fileNames = parsed.fileNames;
|
|
82
|
+
options = parsed.options;
|
|
83
|
+
} else {
|
|
84
|
+
// 没有 tsconfig 的降级:仅用 index.ts
|
|
85
|
+
console.warn('[types] tsconfig.json not found; fallback to index.ts with basic options.');
|
|
86
|
+
fileNames = ['index.ts'].filter((f) => fs.existsSync(f));
|
|
87
|
+
options = {
|
|
88
|
+
moduleResolution: 99, // NodeNext(避免引入 enum 名字,用常量值)
|
|
89
|
+
target: 99, // ESNext
|
|
90
|
+
skipLibCheck: true,
|
|
91
|
+
strict: true,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 强制仅输出声明
|
|
96
|
+
options.declaration = true;
|
|
97
|
+
options.emitDeclarationOnly = true;
|
|
98
|
+
options.outDir = outDir;
|
|
99
|
+
// 为了不受 sourceMap/emit 等其它设置影响
|
|
100
|
+
options.noEmitOnError = false;
|
|
101
|
+
|
|
102
|
+
console.log('[types] Generating .d.ts ...');
|
|
103
|
+
const program = ts.createProgram(fileNames, options);
|
|
104
|
+
const pre = ts.getPreEmitDiagnostics(program);
|
|
105
|
+
const emitResult = program.emit();
|
|
106
|
+
const diagnostics = pre.concat(emitResult.diagnostics);
|
|
107
|
+
|
|
108
|
+
if (diagnostics.length) {
|
|
109
|
+
const formatHost = {
|
|
110
|
+
getCanonicalFileName: (p) => p,
|
|
111
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
112
|
+
getNewLine: () => ts.sys.newLine,
|
|
113
|
+
};
|
|
114
|
+
const message = ts.formatDiagnosticsWithColorAndContext(diagnostics, formatHost);
|
|
115
|
+
console.error(message);
|
|
116
|
+
if (emitResult.emitSkipped) {
|
|
117
|
+
throw new Error('[types] Type generation failed.');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
console.log('[types] Declarations generated.');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* ------------------------- main dispatcher ------------------------- */
|
|
124
|
+
(async function main() {
|
|
125
|
+
const sub = (process.argv[2] || 'all').toLowerCase(); // all | cjs | esm | types | clean
|
|
126
|
+
|
|
127
|
+
const pkg = readJSONSafe('package.json');
|
|
128
|
+
const externalFromPkg = depsAsExternal(pkg);
|
|
129
|
+
// 统一 external:依赖 + peer + Node 内置(含 node:*)
|
|
130
|
+
const external = uniq([...externalFromPkg, ...nodeBuiltinsExternal()]);
|
|
131
|
+
const tscPath = tsconfigPath();
|
|
132
|
+
const entryPoints = entryPointsFromPkg(pkg);
|
|
133
|
+
|
|
134
|
+
switch (sub) {
|
|
135
|
+
case 'clean': {
|
|
136
|
+
console.log('[clean] remove dist/');
|
|
137
|
+
rimraf(DIST_DIR);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case 'cjs': {
|
|
141
|
+
await buildOne('cjs', { external, tsconfig: tscPath, entryPoints });
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
case 'esm': {
|
|
145
|
+
await buildOne('esm', { external, tsconfig: tscPath, entryPoints });
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
case 'types': {
|
|
149
|
+
ensureDir(DIST_DIR);
|
|
150
|
+
buildTypesAPI(DIST_DIR);
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case 'all':
|
|
154
|
+
default: {
|
|
155
|
+
console.log('[clean] remove dist/');
|
|
156
|
+
rimraf(DIST_DIR);
|
|
157
|
+
await buildOne('cjs', { external, tsconfig: tscPath, entryPoints });
|
|
158
|
+
await buildOne('esm', { external, tsconfig: tscPath, entryPoints });
|
|
159
|
+
buildTypesAPI(DIST_DIR);
|
|
160
|
+
console.log('[build] Done.');
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
})().catch((err) => {
|
|
165
|
+
console.error('[build] Failed:', err);
|
|
166
|
+
process.exit(1);
|
|
167
|
+
});
|