@sidekick-coder/zenith-kit 0.0.10 → 0.0.11
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/server/index.d.mts +621 -4
- package/dist/server/index.mjs +1258 -4
- package/dist/shared/chunk-CfYAbeIz.mjs +13 -0
- package/dist/shared/index.d.mts +132 -6
- package/dist/shared/index.mjs +167 -9
- package/eslint.config.mts +1 -0
- package/package.json +15 -2
- package/tsconfig.server.json +1 -1
- package/tsdown.config.ts +15 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
package/dist/shared/index.d.mts
CHANGED
|
@@ -25,7 +25,7 @@ declare class ConfigService {
|
|
|
25
25
|
//#region src/shared/services/ContainerService.d.ts
|
|
26
26
|
type Constructor$1<T = object> = new (...args: any[]) => T;
|
|
27
27
|
type EntryKey = string | symbol | Constructor$1;
|
|
28
|
-
declare class
|
|
28
|
+
declare class ContainerService {
|
|
29
29
|
private entries;
|
|
30
30
|
loadFromRecord(record: Record<string, any>): void;
|
|
31
31
|
toRecord(): Record<string, any>;
|
|
@@ -203,27 +203,48 @@ declare class UploadService {
|
|
|
203
203
|
single(name: string): void;
|
|
204
204
|
multiple(name: string): void;
|
|
205
205
|
}
|
|
206
|
+
declare namespace url_d_exports {
|
|
207
|
+
export { array, arrayNumber, boolean, date, datetime, number, object };
|
|
208
|
+
}
|
|
209
|
+
declare const number: () => v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, v.TransformAction<any, number>, v.IntegerAction<number, undefined>]>;
|
|
210
|
+
declare const boolean: () => v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.BooleanSchema<undefined>], undefined>, v.TransformAction<string | boolean, boolean>]>;
|
|
211
|
+
declare const date: () => v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.DateSchema<undefined>], undefined>, v.TransformAction<string | Date, Date>, v.TransformAction<Date, string | Date>]>;
|
|
212
|
+
declare const datetime: () => v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.DateSchema<undefined>], undefined>, v.TransformAction<string | Date, string | Date>]>;
|
|
213
|
+
declare const array: <T extends v.BaseSchema<any, any, any>>(schema?: T) => v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, v.TransformAction<string | string[], string[]>, v.ArraySchema<T, undefined>]>;
|
|
214
|
+
declare const arrayNumber: () => v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, v.TransformAction<string | string[], string[]>, v.ArraySchema<v.BaseSchema<any, any, any>, undefined>]>, v.TransformAction<any[], number[]>]>;
|
|
215
|
+
declare const object: () => v.SchemaWithPipe<readonly [v.UnionSchema<[v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.AnySchema, undefined>], undefined>, v.TransformAction<string | {
|
|
216
|
+
[x: string]: any;
|
|
217
|
+
}, {
|
|
218
|
+
[x: string]: any;
|
|
219
|
+
}>, v.TransformAction<{
|
|
220
|
+
[x: string]: any;
|
|
221
|
+
}, Record<string, any>>]>;
|
|
206
222
|
//#endregion
|
|
207
223
|
//#region src/shared/services/ValidatorService.d.ts
|
|
208
|
-
|
|
224
|
+
declare const extras: {
|
|
225
|
+
url: typeof url_d_exports;
|
|
226
|
+
};
|
|
227
|
+
type Valibot = typeof v & {
|
|
228
|
+
extras: typeof extras;
|
|
229
|
+
};
|
|
209
230
|
type ValibotSchema = v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>;
|
|
210
231
|
type ValibotSchemaAsync = v.BaseSchemaAsync<unknown, unknown, v.BaseIssue<unknown>>;
|
|
211
232
|
interface ValidatorCallback<T extends ValibotSchema> {
|
|
212
|
-
(_v:
|
|
233
|
+
(_v: Valibot): T;
|
|
213
234
|
}
|
|
214
235
|
type ValidatorCallbackAsync<T extends ValibotSchemaAsync> = {
|
|
215
|
-
(_v:
|
|
236
|
+
(_v: Valibot): T;
|
|
216
237
|
};
|
|
217
238
|
type ValidatorResult<T extends v.ObjectEntries> = v.InferOutput<v.ObjectSchema<T, undefined>>;
|
|
218
239
|
type ValidatePayload<T extends ValibotSchema = ValibotSchema> = ValidatorCallback<T> | T;
|
|
219
240
|
type ValidateResult<T extends ValidatePayload> = T extends ValibotSchema ? v.InferOutput<T> : T extends ValidatorCallback<infer U> ? v.InferOutput<U> : unknown;
|
|
220
241
|
declare class ValidatorService {
|
|
242
|
+
v: Valibot;
|
|
221
243
|
create<T extends ValibotSchema>(cb: ValidatorCallback<T>): T;
|
|
222
244
|
validate<T extends ValibotSchema>(payload: any, cb: ValidatePayload<T>): v.InferOutput<T>;
|
|
223
245
|
validateAsync<T extends ValibotSchemaAsync>(payload: any, cb: ValidatorCallbackAsync<T> | T): Promise<v.InferOutput<T>>;
|
|
224
246
|
isValid<T extends ValibotSchema>(payload: any, cb: ValidatePayload<T>): boolean;
|
|
225
247
|
}
|
|
226
|
-
declare const validator: ValidatorService;
|
|
227
248
|
//#endregion
|
|
228
249
|
//#region src/shared/utils/createId.d.ts
|
|
229
250
|
declare function createId(prefix?: string): string;
|
|
@@ -252,4 +273,109 @@ declare namespace tryCatch {
|
|
|
252
273
|
var sync: <T extends Tryer>(tryer: T) => TryCatchResult<T>;
|
|
253
274
|
}
|
|
254
275
|
//#endregion
|
|
255
|
-
|
|
276
|
+
//#region src/shared/schemas/permissionAssignmentSchema.d.ts
|
|
277
|
+
type PermissionAssignment = v.InferOutput<typeof permissionAssignmentSchema>;
|
|
278
|
+
declare const permissionAssignmentSchema: v.ObjectSchema<{
|
|
279
|
+
readonly id: v.NumberSchema<undefined>;
|
|
280
|
+
readonly permission_id: v.NumberSchema<undefined>;
|
|
281
|
+
readonly assignable_type: v.StringSchema<undefined>;
|
|
282
|
+
readonly assignable_id: v.StringSchema<undefined>;
|
|
283
|
+
readonly created_at: v.StringSchema<undefined>;
|
|
284
|
+
readonly updated_at: v.StringSchema<undefined>;
|
|
285
|
+
}, undefined>;
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/shared/schemas/permissionSchema.d.ts
|
|
288
|
+
type Permission = v.InferOutput<typeof permissionSchema>;
|
|
289
|
+
declare const permissionSchema: v.ObjectSchema<{
|
|
290
|
+
readonly id: v.NumberSchema<undefined>;
|
|
291
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
292
|
+
readonly description: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
293
|
+
readonly action: v.StringSchema<undefined>;
|
|
294
|
+
readonly subject: v.StringSchema<undefined>;
|
|
295
|
+
readonly conditions: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
296
|
+
readonly created_at: v.StringSchema<undefined>;
|
|
297
|
+
readonly updated_at: v.StringSchema<undefined>;
|
|
298
|
+
readonly expires_at: v.StringSchema<undefined>;
|
|
299
|
+
}, undefined>;
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/shared/schemas/tokenSchema.d.ts
|
|
302
|
+
type Token = v.InferOutput<typeof tokenSchema>;
|
|
303
|
+
declare const tokenSchema: v.ObjectSchema<{
|
|
304
|
+
readonly id: v.NumberSchema<undefined>;
|
|
305
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
306
|
+
readonly type: v.StringSchema<undefined>;
|
|
307
|
+
readonly user_id: v.NumberSchema<undefined>;
|
|
308
|
+
readonly token: v.StringSchema<undefined>;
|
|
309
|
+
readonly created_at: v.StringSchema<undefined>;
|
|
310
|
+
readonly updated_at: v.StringSchema<undefined>;
|
|
311
|
+
readonly expires_at: v.StringSchema<undefined>;
|
|
312
|
+
}, undefined>;
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/shared/exceptions/BaseException.d.ts
|
|
315
|
+
declare class BaseException extends Error {
|
|
316
|
+
statusCode: number;
|
|
317
|
+
constructor(message: string, statusCode?: number);
|
|
318
|
+
static fromError(error: Error): BaseException;
|
|
319
|
+
}
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/shared/exceptions/ShellException.d.ts
|
|
322
|
+
declare class ShellException extends BaseException {
|
|
323
|
+
output: string;
|
|
324
|
+
bin: string;
|
|
325
|
+
args: string[];
|
|
326
|
+
constructor(message: string, output: string, bin: string, args: string[]);
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/shared/facades/validator.d.ts
|
|
330
|
+
declare const validator: ValidatorService;
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region src/shared/entities/ModuleManifestEntity.d.ts
|
|
333
|
+
interface ModuleManifestBuildImport {
|
|
334
|
+
from: string;
|
|
335
|
+
to?: string;
|
|
336
|
+
type: 'global_import';
|
|
337
|
+
}
|
|
338
|
+
interface ModuleManifestBuild {
|
|
339
|
+
imports?: ModuleManifestBuildImport[];
|
|
340
|
+
}
|
|
341
|
+
declare const ModuleManifest_base: {
|
|
342
|
+
new (...args: any[]): {
|
|
343
|
+
merge(data: Partial< /*elided*/any>): /*elided*/any;
|
|
344
|
+
};
|
|
345
|
+
from<T>(this: new () => T, data: Partial<T>): T;
|
|
346
|
+
} & Constructor;
|
|
347
|
+
declare class ModuleManifest extends ModuleManifest_base {
|
|
348
|
+
id: string;
|
|
349
|
+
name: string;
|
|
350
|
+
version: string;
|
|
351
|
+
description?: string;
|
|
352
|
+
enabled: boolean;
|
|
353
|
+
author?: string;
|
|
354
|
+
dependencies?: Record<string, string>;
|
|
355
|
+
build?: ModuleManifestBuild;
|
|
356
|
+
[key: string]: any;
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/shared/entities/ModuleEntity.d.ts
|
|
360
|
+
interface ModuleUpgradeInfo {
|
|
361
|
+
source: 'git' | 'zip';
|
|
362
|
+
[key: string]: any;
|
|
363
|
+
}
|
|
364
|
+
declare const Module_base: {
|
|
365
|
+
new (...args: any[]): {
|
|
366
|
+
merge(data: Partial< /*elided*/any>): /*elided*/any;
|
|
367
|
+
};
|
|
368
|
+
from<T>(this: new () => T, data: Partial<T>): T;
|
|
369
|
+
} & Constructor & Constructor<{}> & typeof LifecycleHook;
|
|
370
|
+
declare class Module extends Module_base {
|
|
371
|
+
id: string;
|
|
372
|
+
name: string;
|
|
373
|
+
enabled: boolean;
|
|
374
|
+
dependencies: Record<string, any>;
|
|
375
|
+
build: ModuleManifest['build'];
|
|
376
|
+
directory: string;
|
|
377
|
+
upgrade_info?: ModuleUpgradeInfo;
|
|
378
|
+
setData(data: Partial<Module | ModuleManifest>): void;
|
|
379
|
+
}
|
|
380
|
+
//#endregion
|
|
381
|
+
export { AnyClass, BaseException, ConfigService, Constructor, ContainerService, CookieService, EmmitterService, EmmitterServiceOptions, LifecycleHook, LifecycleService, LoggerService, Mixin, Module as ModuleEntity, ModuleManifestBuild, ModuleManifestBuildImport, ModuleManifest as ModuleManifestEntity, PartialBy, Permission, PermissionAssignment, PublicData, ShellException, Token, TranslatorService, UnionToIntersection, UploadService, Valibot, ValibotSchema, ValibotSchemaAsync, ValidatePayload, ValidateResult, ValidatorCallback, ValidatorCallbackAsync, ValidatorResult, ValidatorService, compose, composeWith, createId, flatten, formatBytes, generateIndexFile, mixin, permissionAssignmentSchema, permissionSchema, tokenSchema, tryCatch, unflatten, validator };
|
package/dist/shared/index.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
|
|
1
2
|
import { debounce, get, has, set, unset } from "lodash-es";
|
|
2
3
|
import * as v from "valibot";
|
|
4
|
+
import { format } from "date-fns";
|
|
5
|
+
import qs from "qs";
|
|
3
6
|
import fg from "fast-glob";
|
|
4
7
|
import fs from "fs";
|
|
5
8
|
import path from "path";
|
|
@@ -104,7 +107,7 @@ var ConfigService = class {
|
|
|
104
107
|
};
|
|
105
108
|
//#endregion
|
|
106
109
|
//#region src/shared/services/ContainerService.ts
|
|
107
|
-
var
|
|
110
|
+
var ContainerService = class {
|
|
108
111
|
entries = /* @__PURE__ */ new Map();
|
|
109
112
|
loadFromRecord(record) {
|
|
110
113
|
Object.entries(record).forEach(([key, value]) => {
|
|
@@ -435,7 +438,12 @@ var LifecycleService = class {
|
|
|
435
438
|
}
|
|
436
439
|
async executeHookMethod(hook, method) {
|
|
437
440
|
await hook[method]();
|
|
438
|
-
if (
|
|
441
|
+
if (this.debug) this.logger.debug(`${method} ${hook.hook_id}`);
|
|
442
|
+
const subhooks = hook.subhooks || [];
|
|
443
|
+
for (const subhook of subhooks) {
|
|
444
|
+
await this.executeHookMethod(subhook, method);
|
|
445
|
+
if (this.debug) this.logger.debug(`${method} subhook ${subhook.hook_id} of ${hook.hook_id}`);
|
|
446
|
+
}
|
|
439
447
|
}
|
|
440
448
|
list(options) {
|
|
441
449
|
let hooks = Array.from(this.hooks.values());
|
|
@@ -467,6 +475,7 @@ var LifecycleService = class {
|
|
|
467
475
|
for (const hook of instances) {
|
|
468
476
|
this.hooks.set(hook.hook_id, hook);
|
|
469
477
|
if (this.debug) this.logger.debug("add " + hook.hook_id);
|
|
478
|
+
if (hook.subhooks) hook.subhooks.forEach((subhook) => this.add(subhook));
|
|
470
479
|
}
|
|
471
480
|
}
|
|
472
481
|
async register(options) {
|
|
@@ -618,6 +627,33 @@ var UploadService = class {
|
|
|
618
627
|
}
|
|
619
628
|
};
|
|
620
629
|
//#endregion
|
|
630
|
+
//#region src/shared/validators/url.ts
|
|
631
|
+
var url_exports = /* @__PURE__ */ __exportAll({
|
|
632
|
+
array: () => array,
|
|
633
|
+
arrayNumber: () => arrayNumber,
|
|
634
|
+
boolean: () => boolean,
|
|
635
|
+
date: () => date,
|
|
636
|
+
datetime: () => datetime,
|
|
637
|
+
number: () => number,
|
|
638
|
+
object: () => object
|
|
639
|
+
});
|
|
640
|
+
const number = () => v.pipe(v.union([v.string(), v.number()]), v.transform(Number), v.integer());
|
|
641
|
+
const boolean = () => v.pipe(v.union([v.string(), v.boolean()]), v.transform((v) => v === true || v === "true"));
|
|
642
|
+
const date = () => v.pipe(v.union([v.string(), v.date()]), v.transform((v) => v instanceof Date ? v : new Date(v)), v.transform((v) => v ? format(v, "yyyy-MM-dd") : v));
|
|
643
|
+
const datetime = () => v.pipe(v.union([v.string(), v.date()]), v.transform((v) => {
|
|
644
|
+
if (!v) return v;
|
|
645
|
+
if (v === "null") return null;
|
|
646
|
+
if (typeof v === "string") v = new Date(v);
|
|
647
|
+
return format(v, "yyyy-MM-dd HH:mm");
|
|
648
|
+
}));
|
|
649
|
+
const array = (schema = v.any()) => v.pipe(v.union([v.string(), v.array(v.string())]), v.transform((value) => Array.isArray(value) ? value : value.split(",")), v.array(schema));
|
|
650
|
+
const arrayNumber = () => v.pipe(array(), v.transform((value) => value.map(Number)));
|
|
651
|
+
const object = () => v.pipe(v.union([v.string(), v.record(v.string(), v.any())]), v.transform((value) => typeof value === "string" ? qs.parse(value) : value), v.transform((value) => {
|
|
652
|
+
const result = {};
|
|
653
|
+
for (const key in value) set(result, key, get(value, key));
|
|
654
|
+
return result;
|
|
655
|
+
}));
|
|
656
|
+
//#endregion
|
|
621
657
|
//#region src/shared/exceptions/BaseException.ts
|
|
622
658
|
var BaseException = class BaseException extends Error {
|
|
623
659
|
statusCode = 500;
|
|
@@ -632,12 +668,17 @@ var BaseException = class BaseException extends Error {
|
|
|
632
668
|
};
|
|
633
669
|
//#endregion
|
|
634
670
|
//#region src/shared/services/ValidatorService.ts
|
|
671
|
+
const extras = { url: url_exports };
|
|
635
672
|
var ValidatorService = class {
|
|
673
|
+
v = {
|
|
674
|
+
...v,
|
|
675
|
+
extras
|
|
676
|
+
};
|
|
636
677
|
create(cb) {
|
|
637
|
-
return cb(v);
|
|
678
|
+
return cb(this.v);
|
|
638
679
|
}
|
|
639
680
|
validate(payload, cb) {
|
|
640
|
-
const schema = typeof cb === "function" ? cb(v) : cb;
|
|
681
|
+
const schema = typeof cb === "function" ? cb(this.v) : cb;
|
|
641
682
|
const { output, issues, success } = v.safeParse(schema, payload);
|
|
642
683
|
if (!success) {
|
|
643
684
|
const flatten = v.flatten(issues);
|
|
@@ -655,7 +696,7 @@ var ValidatorService = class {
|
|
|
655
696
|
return output;
|
|
656
697
|
}
|
|
657
698
|
async validateAsync(payload, cb) {
|
|
658
|
-
const schema = typeof cb === "function" ? cb(v) : cb;
|
|
699
|
+
const schema = typeof cb === "function" ? cb(this.v) : cb;
|
|
659
700
|
const { output, issues, success } = await v.safeParseAsync(schema, payload);
|
|
660
701
|
if (!success) {
|
|
661
702
|
const error = /* @__PURE__ */ new Error("Validation failed");
|
|
@@ -670,20 +711,25 @@ var ValidatorService = class {
|
|
|
670
711
|
return output;
|
|
671
712
|
}
|
|
672
713
|
isValid(payload, cb) {
|
|
673
|
-
const schema = typeof cb === "function" ? cb(v) : cb;
|
|
714
|
+
const schema = typeof cb === "function" ? cb(this.v) : cb;
|
|
674
715
|
const { success } = v.safeParse(schema, payload);
|
|
675
716
|
return success;
|
|
676
717
|
}
|
|
677
718
|
};
|
|
678
|
-
const validator = new ValidatorService();
|
|
679
719
|
//#endregion
|
|
680
720
|
//#region src/shared/utils/generateIndexFile.ts
|
|
681
721
|
function generateIndexFile(options) {
|
|
682
722
|
const folders = options.folders;
|
|
683
723
|
const filename = options.filename;
|
|
724
|
+
const defaultIgnore = [
|
|
725
|
+
"**/index.ts",
|
|
726
|
+
"**/*.spec.ts",
|
|
727
|
+
"**/*.test.ts"
|
|
728
|
+
];
|
|
729
|
+
const ignore = options.ignore || [];
|
|
684
730
|
let content = "";
|
|
685
731
|
for (const folder of folders) {
|
|
686
|
-
const files = fg.sync(`${folder}/**/*.ts`, { ignore: [
|
|
732
|
+
const files = fg.sync(`${folder}/**/*.ts`, { ignore: [...defaultIgnore, ...ignore] });
|
|
687
733
|
for (const file of files) {
|
|
688
734
|
const filePath = path.relative(path.dirname(filename), file);
|
|
689
735
|
const hasDefaultExport = fs.readFileSync(file, "utf-8").includes("export default") && !filePath.includes("generateIndexFile.ts");
|
|
@@ -695,4 +741,116 @@ function generateIndexFile(options) {
|
|
|
695
741
|
fs.writeFileSync(filename, content);
|
|
696
742
|
}
|
|
697
743
|
//#endregion
|
|
698
|
-
|
|
744
|
+
//#region src/shared/schemas/permissionAssignmentSchema.ts
|
|
745
|
+
const permissionAssignmentSchema = v.object({
|
|
746
|
+
id: v.number(),
|
|
747
|
+
permission_id: v.number(),
|
|
748
|
+
assignable_type: v.string(),
|
|
749
|
+
assignable_id: v.string(),
|
|
750
|
+
created_at: v.string(),
|
|
751
|
+
updated_at: v.string()
|
|
752
|
+
});
|
|
753
|
+
//#endregion
|
|
754
|
+
//#region src/shared/schemas/permissionSchema.ts
|
|
755
|
+
const permissionSchema = v.object({
|
|
756
|
+
id: v.number(),
|
|
757
|
+
name: v.nullable(v.string()),
|
|
758
|
+
description: v.nullable(v.string()),
|
|
759
|
+
action: v.string(),
|
|
760
|
+
subject: v.string(),
|
|
761
|
+
conditions: v.nullable(v.string()),
|
|
762
|
+
created_at: v.string(),
|
|
763
|
+
updated_at: v.string(),
|
|
764
|
+
expires_at: v.string()
|
|
765
|
+
});
|
|
766
|
+
//#endregion
|
|
767
|
+
//#region src/shared/schemas/tokenSchema.ts
|
|
768
|
+
const tokenSchema = v.object({
|
|
769
|
+
id: v.number(),
|
|
770
|
+
name: v.nullable(v.string()),
|
|
771
|
+
type: v.string(),
|
|
772
|
+
user_id: v.number(),
|
|
773
|
+
token: v.string(),
|
|
774
|
+
created_at: v.string(),
|
|
775
|
+
updated_at: v.string(),
|
|
776
|
+
expires_at: v.string()
|
|
777
|
+
});
|
|
778
|
+
//#endregion
|
|
779
|
+
//#region src/shared/exceptions/ShellException.ts
|
|
780
|
+
var ShellException = class extends BaseException {
|
|
781
|
+
output;
|
|
782
|
+
bin;
|
|
783
|
+
args;
|
|
784
|
+
constructor(message, output, bin, args) {
|
|
785
|
+
super(message, 501);
|
|
786
|
+
this.output = output;
|
|
787
|
+
this.bin = bin;
|
|
788
|
+
this.args = args;
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
//#endregion
|
|
792
|
+
//#region src/shared/facades/validator.ts
|
|
793
|
+
const validator = new ValidatorService();
|
|
794
|
+
//#endregion
|
|
795
|
+
//#region src/shared/entities/LifecycleHook.ts
|
|
796
|
+
var LifecycleHook = class {
|
|
797
|
+
hook_id;
|
|
798
|
+
order;
|
|
799
|
+
subhooks;
|
|
800
|
+
constructor() {
|
|
801
|
+
if (!this.hook_id) this.hook_id = this.constructor.name;
|
|
802
|
+
}
|
|
803
|
+
async onRegister() {}
|
|
804
|
+
async onLoad() {}
|
|
805
|
+
async onBoot() {}
|
|
806
|
+
async onShutdown() {}
|
|
807
|
+
};
|
|
808
|
+
//#endregion
|
|
809
|
+
//#region src/shared/mixins/BaseEntityMixin.ts
|
|
810
|
+
function BaseEntity(Base) {
|
|
811
|
+
return class extends Base {
|
|
812
|
+
static from(data) {
|
|
813
|
+
const contructor = typeof this === "function" ? this : Base;
|
|
814
|
+
const instance = new contructor();
|
|
815
|
+
let payload = { ...data };
|
|
816
|
+
if (typeof contructor?.parse === "function") payload = contructor.parse(data);
|
|
817
|
+
if (typeof this?.parse === "function") payload = this.parse(data);
|
|
818
|
+
Object.assign(instance, payload);
|
|
819
|
+
return instance;
|
|
820
|
+
}
|
|
821
|
+
merge(data) {
|
|
822
|
+
Object.assign(this, data);
|
|
823
|
+
return this;
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
//#endregion
|
|
828
|
+
//#region src/shared/entities/ModuleEntity.ts
|
|
829
|
+
var Module = class extends compose(BaseEntity, mixin(LifecycleHook)) {
|
|
830
|
+
id;
|
|
831
|
+
name;
|
|
832
|
+
enabled = false;
|
|
833
|
+
dependencies = {};
|
|
834
|
+
build = {};
|
|
835
|
+
directory;
|
|
836
|
+
upgrade_info;
|
|
837
|
+
setData(data) {
|
|
838
|
+
const filtered = Object.fromEntries(Object.entries(data).filter(([, v]) => v !== void 0));
|
|
839
|
+
Object.assign(this, filtered);
|
|
840
|
+
this.hook_id = `module:${this.id}`;
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
//#endregion
|
|
844
|
+
//#region src/shared/entities/ModuleManifestEntity.ts
|
|
845
|
+
var ModuleManifest = class extends compose(BaseEntity) {
|
|
846
|
+
id;
|
|
847
|
+
name;
|
|
848
|
+
version;
|
|
849
|
+
description;
|
|
850
|
+
enabled;
|
|
851
|
+
author;
|
|
852
|
+
dependencies;
|
|
853
|
+
build;
|
|
854
|
+
};
|
|
855
|
+
//#endregion
|
|
856
|
+
export { BaseException, ConfigService, ContainerService, CookieService, EmmitterService, LifecycleHook, LifecycleService, LoggerService, Module as ModuleEntity, ModuleManifest as ModuleManifestEntity, ShellException, TranslatorService, UploadService, ValidatorService, compose, composeWith, createId, flatten, formatBytes, generateIndexFile, mixin, permissionAssignmentSchema, permissionSchema, tokenSchema, tryCatch, unflatten, validator };
|
package/eslint.config.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sidekick-coder/zenith-kit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A collection of utilities and tools for building language servers and related applications.",
|
|
6
6
|
"keywords": [],
|
|
@@ -13,6 +13,11 @@
|
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
|
+
"imports": {
|
|
17
|
+
"#client/*": "./src/client/*",
|
|
18
|
+
"#server/*": "./src/server/*",
|
|
19
|
+
"#shared/*": "./src/shared/*"
|
|
20
|
+
},
|
|
16
21
|
"exports": {
|
|
17
22
|
"./shared": {
|
|
18
23
|
"import": "./dist/shared/index.mjs",
|
|
@@ -36,6 +41,7 @@
|
|
|
36
41
|
"@eslint/json": "^0.14.0",
|
|
37
42
|
"@types/lodash-es": "^4.17.12",
|
|
38
43
|
"@types/node": "^25.6.0",
|
|
44
|
+
"@types/qs": "^6.15.0",
|
|
39
45
|
"@vue/tsconfig": "^0.9.1",
|
|
40
46
|
"commander": "^14.0.3",
|
|
41
47
|
"eslint": "^9.39.4",
|
|
@@ -45,11 +51,18 @@
|
|
|
45
51
|
"jiti": "^2.6.1",
|
|
46
52
|
"tsdown": "^0.21.9",
|
|
47
53
|
"typescript": "^6.0.3",
|
|
48
|
-
"typescript-eslint": "^8.58.2"
|
|
54
|
+
"typescript-eslint": "^8.58.2",
|
|
55
|
+
"vitest": "^3.2.4"
|
|
49
56
|
},
|
|
50
57
|
"dependencies": {
|
|
58
|
+
"better-sqlite3": "^12.9.0",
|
|
59
|
+
"date-fns": "^4.1.0",
|
|
51
60
|
"fast-glob": "^3.3.3",
|
|
61
|
+
"kysely": "^0.28.16",
|
|
52
62
|
"lodash-es": "^4.18.1",
|
|
63
|
+
"mysql2": "^3.22.3",
|
|
64
|
+
"pg": "^8.20.0",
|
|
65
|
+
"qs": "^6.15.1",
|
|
53
66
|
"valibot": "^1.3.1"
|
|
54
67
|
}
|
|
55
68
|
}
|
package/tsconfig.server.json
CHANGED
package/tsdown.config.ts
CHANGED
|
@@ -9,7 +9,14 @@ export default defineConfig([
|
|
|
9
9
|
hooks(hooks) {
|
|
10
10
|
hooks.hook('build:before', async () => {
|
|
11
11
|
generateIndexFile({
|
|
12
|
-
folders: [
|
|
12
|
+
folders: [
|
|
13
|
+
'src/shared/services',
|
|
14
|
+
'src/shared/utils',
|
|
15
|
+
'src/shared/schemas',
|
|
16
|
+
'src/shared/exceptions',
|
|
17
|
+
'src/shared/facades',
|
|
18
|
+
'src/shared/entities',
|
|
19
|
+
],
|
|
13
20
|
filename: 'src/shared/index.ts'
|
|
14
21
|
})
|
|
15
22
|
|
|
@@ -26,7 +33,14 @@ export default defineConfig([
|
|
|
26
33
|
generateIndexFile({
|
|
27
34
|
folders: [
|
|
28
35
|
'src/server/services',
|
|
36
|
+
'src/server/repositories',
|
|
29
37
|
'src/server/gateways',
|
|
38
|
+
'src/server/mixins',
|
|
39
|
+
'src/server/facades',
|
|
40
|
+
'src/server/contracts',
|
|
41
|
+
'src/server/loaders',
|
|
42
|
+
'src/server/entities',
|
|
43
|
+
'src/server/utils',
|
|
30
44
|
],
|
|
31
45
|
filename: 'src/server/index.ts'
|
|
32
46
|
})
|