@sidekick-coder/zenith-kit 0.0.10 → 0.0.12
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 +1791 -4
- package/dist/server/index.mjs +7290 -25
- package/dist/shared/chunk-CfYAbeIz.mjs +13 -0
- package/dist/shared/index.d.mts +142 -10
- package/dist/shared/index.mjs +168 -25
- package/eslint.config.mts +1 -0
- package/package.json +27 -3
- package/tsconfig.server.json +1 -1
- package/tsdown.config.ts +16 -2
|
@@ -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,11 +25,11 @@ 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>;
|
|
32
|
-
set(payload: EntryKey, value: any):
|
|
32
|
+
set(payload: EntryKey, value: any): this;
|
|
33
33
|
has(payload: EntryKey): boolean;
|
|
34
34
|
get<T>(payload: EntryKey): T;
|
|
35
35
|
singleton<T>(classConstructor: Constructor$1<T>): T;
|
|
@@ -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;
|
|
@@ -235,9 +256,6 @@ declare function unflatten(obj: any): Record<string, any>;
|
|
|
235
256
|
//#region src/shared/utils/formatBytes.d.ts
|
|
236
257
|
declare function formatBytes(bytes: number, decimals?: number): string;
|
|
237
258
|
//#endregion
|
|
238
|
-
//#region src/shared/utils/generateIndexFile.d.ts
|
|
239
|
-
declare function generateIndexFile(options: any): void;
|
|
240
|
-
//#endregion
|
|
241
259
|
//#region src/shared/utils/tryCatch.d.ts
|
|
242
260
|
interface Tryer {
|
|
243
261
|
(...args: any[]): any;
|
|
@@ -252,4 +270,118 @@ declare namespace tryCatch {
|
|
|
252
270
|
var sync: <T extends Tryer>(tryer: T) => TryCatchResult<T>;
|
|
253
271
|
}
|
|
254
272
|
//#endregion
|
|
255
|
-
|
|
273
|
+
//#region src/shared/schemas/permissionAssignmentSchema.d.ts
|
|
274
|
+
type PermissionAssignment = v.InferOutput<typeof permissionAssignmentSchema>;
|
|
275
|
+
declare const permissionAssignmentSchema: v.ObjectSchema<{
|
|
276
|
+
readonly id: v.NumberSchema<undefined>;
|
|
277
|
+
readonly permission_id: v.NumberSchema<undefined>;
|
|
278
|
+
readonly assignable_type: v.StringSchema<undefined>;
|
|
279
|
+
readonly assignable_id: v.StringSchema<undefined>;
|
|
280
|
+
readonly created_at: v.StringSchema<undefined>;
|
|
281
|
+
readonly updated_at: v.StringSchema<undefined>;
|
|
282
|
+
}, undefined>;
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/shared/schemas/permissionSchema.d.ts
|
|
285
|
+
type Permission = v.InferOutput<typeof permissionSchema>;
|
|
286
|
+
declare const permissionSchema: v.ObjectSchema<{
|
|
287
|
+
readonly id: v.NumberSchema<undefined>;
|
|
288
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
289
|
+
readonly description: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
290
|
+
readonly action: v.StringSchema<undefined>;
|
|
291
|
+
readonly subject: v.StringSchema<undefined>;
|
|
292
|
+
readonly conditions: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
293
|
+
readonly created_at: v.StringSchema<undefined>;
|
|
294
|
+
readonly updated_at: v.StringSchema<undefined>;
|
|
295
|
+
readonly expires_at: v.StringSchema<undefined>;
|
|
296
|
+
}, undefined>;
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/shared/schemas/tokenSchema.d.ts
|
|
299
|
+
type Token = v.InferOutput<typeof tokenSchema>;
|
|
300
|
+
declare const tokenSchema: v.ObjectSchema<{
|
|
301
|
+
readonly id: v.NumberSchema<undefined>;
|
|
302
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
303
|
+
readonly type: v.StringSchema<undefined>;
|
|
304
|
+
readonly user_id: v.NumberSchema<undefined>;
|
|
305
|
+
readonly token: v.StringSchema<undefined>;
|
|
306
|
+
readonly created_at: v.StringSchema<undefined>;
|
|
307
|
+
readonly updated_at: v.StringSchema<undefined>;
|
|
308
|
+
readonly expires_at: v.StringSchema<undefined>;
|
|
309
|
+
}, undefined>;
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/shared/exceptions/BaseException.d.ts
|
|
312
|
+
declare class BaseException extends Error {
|
|
313
|
+
statusCode: number;
|
|
314
|
+
constructor(message: string, statusCode?: number);
|
|
315
|
+
static fromError(error: Error): BaseException;
|
|
316
|
+
}
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/shared/exceptions/ShellException.d.ts
|
|
319
|
+
declare class ShellException extends BaseException {
|
|
320
|
+
output: string;
|
|
321
|
+
bin: string;
|
|
322
|
+
args: string[];
|
|
323
|
+
constructor(message: string, output: string, bin: string, args: string[]);
|
|
324
|
+
}
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/shared/facades/validator.d.ts
|
|
327
|
+
declare const validator: ValidatorService;
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/shared/entities/DriveEntryEntity.d.ts
|
|
330
|
+
declare class DriveEntry {
|
|
331
|
+
name: string;
|
|
332
|
+
path: string;
|
|
333
|
+
type: 'file' | 'directory';
|
|
334
|
+
metas: Record<string, any>;
|
|
335
|
+
constructor(data: DriveEntry);
|
|
336
|
+
}
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region src/shared/entities/ModuleManifestEntity.d.ts
|
|
339
|
+
interface ModuleManifestBuildImport {
|
|
340
|
+
from: string;
|
|
341
|
+
to?: string;
|
|
342
|
+
type: 'global_import';
|
|
343
|
+
}
|
|
344
|
+
interface ModuleManifestBuild {
|
|
345
|
+
imports?: ModuleManifestBuildImport[];
|
|
346
|
+
}
|
|
347
|
+
declare const ModuleManifest_base: {
|
|
348
|
+
new (...args: any[]): {
|
|
349
|
+
merge(data: Partial< /*elided*/any>): /*elided*/any;
|
|
350
|
+
};
|
|
351
|
+
from<T>(this: new () => T, data: Partial<T>): T;
|
|
352
|
+
} & Constructor;
|
|
353
|
+
declare class ModuleManifest extends ModuleManifest_base {
|
|
354
|
+
id: string;
|
|
355
|
+
name: string;
|
|
356
|
+
version: string;
|
|
357
|
+
description?: string;
|
|
358
|
+
enabled: boolean;
|
|
359
|
+
author?: string;
|
|
360
|
+
dependencies?: Record<string, string>;
|
|
361
|
+
build?: ModuleManifestBuild;
|
|
362
|
+
[key: string]: any;
|
|
363
|
+
}
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region src/shared/entities/ModuleEntity.d.ts
|
|
366
|
+
interface ModuleUpgradeInfo {
|
|
367
|
+
source: 'git' | 'zip';
|
|
368
|
+
[key: string]: any;
|
|
369
|
+
}
|
|
370
|
+
declare const Module_base: {
|
|
371
|
+
new (...args: any[]): {
|
|
372
|
+
merge(data: Partial< /*elided*/any>): /*elided*/any;
|
|
373
|
+
};
|
|
374
|
+
from<T>(this: new () => T, data: Partial<T>): T;
|
|
375
|
+
} & Constructor & Constructor<{}> & typeof LifecycleHook;
|
|
376
|
+
declare class Module extends Module_base {
|
|
377
|
+
id: string;
|
|
378
|
+
name: string;
|
|
379
|
+
enabled: boolean;
|
|
380
|
+
dependencies: Record<string, any>;
|
|
381
|
+
build: ModuleManifest['build'];
|
|
382
|
+
directory: string;
|
|
383
|
+
upgrade_info?: ModuleUpgradeInfo;
|
|
384
|
+
setData(data: Partial<Module | ModuleManifest>): void;
|
|
385
|
+
}
|
|
386
|
+
//#endregion
|
|
387
|
+
export { AnyClass, BaseException, ConfigService, Constructor, ContainerService, CookieService, DriveEntry as DriveEntryEntity, 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, mixin, permissionAssignmentSchema, permissionSchema, tokenSchema, tryCatch, unflatten, validator };
|
package/dist/shared/index.mjs
CHANGED
|
@@ -1,8 +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";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import path from "path";
|
|
4
|
+
import { format } from "date-fns";
|
|
5
|
+
import qs from "qs";
|
|
6
6
|
//#region src/shared/services/ConfigService.ts
|
|
7
7
|
var ConfigService = class {
|
|
8
8
|
entries;
|
|
@@ -104,7 +104,7 @@ var ConfigService = class {
|
|
|
104
104
|
};
|
|
105
105
|
//#endregion
|
|
106
106
|
//#region src/shared/services/ContainerService.ts
|
|
107
|
-
var
|
|
107
|
+
var ContainerService = class {
|
|
108
108
|
entries = /* @__PURE__ */ new Map();
|
|
109
109
|
loadFromRecord(record) {
|
|
110
110
|
Object.entries(record).forEach(([key, value]) => {
|
|
@@ -120,6 +120,7 @@ var DIService = class {
|
|
|
120
120
|
let key = payload;
|
|
121
121
|
if (typeof payload === "function" || typeof payload === "object") key = payload.name;
|
|
122
122
|
this.entries.set(key, value);
|
|
123
|
+
return this;
|
|
123
124
|
}
|
|
124
125
|
has(payload) {
|
|
125
126
|
let key = payload;
|
|
@@ -435,7 +436,12 @@ var LifecycleService = class {
|
|
|
435
436
|
}
|
|
436
437
|
async executeHookMethod(hook, method) {
|
|
437
438
|
await hook[method]();
|
|
438
|
-
if (
|
|
439
|
+
if (this.debug) this.logger.debug(`${method} ${hook.hook_id}`);
|
|
440
|
+
const subhooks = hook.subhooks || [];
|
|
441
|
+
for (const subhook of subhooks) {
|
|
442
|
+
await this.executeHookMethod(subhook, method);
|
|
443
|
+
if (this.debug) this.logger.debug(`${method} subhook ${subhook.hook_id} of ${hook.hook_id}`);
|
|
444
|
+
}
|
|
439
445
|
}
|
|
440
446
|
list(options) {
|
|
441
447
|
let hooks = Array.from(this.hooks.values());
|
|
@@ -467,6 +473,7 @@ var LifecycleService = class {
|
|
|
467
473
|
for (const hook of instances) {
|
|
468
474
|
this.hooks.set(hook.hook_id, hook);
|
|
469
475
|
if (this.debug) this.logger.debug("add " + hook.hook_id);
|
|
476
|
+
if (hook.subhooks) hook.subhooks.forEach((subhook) => this.add(subhook));
|
|
470
477
|
}
|
|
471
478
|
}
|
|
472
479
|
async register(options) {
|
|
@@ -618,6 +625,33 @@ var UploadService = class {
|
|
|
618
625
|
}
|
|
619
626
|
};
|
|
620
627
|
//#endregion
|
|
628
|
+
//#region src/shared/validators/url.ts
|
|
629
|
+
var url_exports = /* @__PURE__ */ __exportAll({
|
|
630
|
+
array: () => array,
|
|
631
|
+
arrayNumber: () => arrayNumber,
|
|
632
|
+
boolean: () => boolean,
|
|
633
|
+
date: () => date,
|
|
634
|
+
datetime: () => datetime,
|
|
635
|
+
number: () => number,
|
|
636
|
+
object: () => object
|
|
637
|
+
});
|
|
638
|
+
const number = () => v.pipe(v.union([v.string(), v.number()]), v.transform(Number), v.integer());
|
|
639
|
+
const boolean = () => v.pipe(v.union([v.string(), v.boolean()]), v.transform((v) => v === true || v === "true"));
|
|
640
|
+
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));
|
|
641
|
+
const datetime = () => v.pipe(v.union([v.string(), v.date()]), v.transform((v) => {
|
|
642
|
+
if (!v) return v;
|
|
643
|
+
if (v === "null") return null;
|
|
644
|
+
if (typeof v === "string") v = new Date(v);
|
|
645
|
+
return format(v, "yyyy-MM-dd HH:mm");
|
|
646
|
+
}));
|
|
647
|
+
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));
|
|
648
|
+
const arrayNumber = () => v.pipe(array(), v.transform((value) => value.map(Number)));
|
|
649
|
+
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) => {
|
|
650
|
+
const result = {};
|
|
651
|
+
for (const key in value) set(result, key, get(value, key));
|
|
652
|
+
return result;
|
|
653
|
+
}));
|
|
654
|
+
//#endregion
|
|
621
655
|
//#region src/shared/exceptions/BaseException.ts
|
|
622
656
|
var BaseException = class BaseException extends Error {
|
|
623
657
|
statusCode = 500;
|
|
@@ -632,12 +666,17 @@ var BaseException = class BaseException extends Error {
|
|
|
632
666
|
};
|
|
633
667
|
//#endregion
|
|
634
668
|
//#region src/shared/services/ValidatorService.ts
|
|
669
|
+
const extras = { url: url_exports };
|
|
635
670
|
var ValidatorService = class {
|
|
671
|
+
v = {
|
|
672
|
+
...v,
|
|
673
|
+
extras
|
|
674
|
+
};
|
|
636
675
|
create(cb) {
|
|
637
|
-
return cb(v);
|
|
676
|
+
return cb(this.v);
|
|
638
677
|
}
|
|
639
678
|
validate(payload, cb) {
|
|
640
|
-
const schema = typeof cb === "function" ? cb(v) : cb;
|
|
679
|
+
const schema = typeof cb === "function" ? cb(this.v) : cb;
|
|
641
680
|
const { output, issues, success } = v.safeParse(schema, payload);
|
|
642
681
|
if (!success) {
|
|
643
682
|
const flatten = v.flatten(issues);
|
|
@@ -655,7 +694,7 @@ var ValidatorService = class {
|
|
|
655
694
|
return output;
|
|
656
695
|
}
|
|
657
696
|
async validateAsync(payload, cb) {
|
|
658
|
-
const schema = typeof cb === "function" ? cb(v) : cb;
|
|
697
|
+
const schema = typeof cb === "function" ? cb(this.v) : cb;
|
|
659
698
|
const { output, issues, success } = await v.safeParseAsync(schema, payload);
|
|
660
699
|
if (!success) {
|
|
661
700
|
const error = /* @__PURE__ */ new Error("Validation failed");
|
|
@@ -670,29 +709,133 @@ var ValidatorService = class {
|
|
|
670
709
|
return output;
|
|
671
710
|
}
|
|
672
711
|
isValid(payload, cb) {
|
|
673
|
-
const schema = typeof cb === "function" ? cb(v) : cb;
|
|
712
|
+
const schema = typeof cb === "function" ? cb(this.v) : cb;
|
|
674
713
|
const { success } = v.safeParse(schema, payload);
|
|
675
714
|
return success;
|
|
676
715
|
}
|
|
677
716
|
};
|
|
717
|
+
//#endregion
|
|
718
|
+
//#region src/shared/schemas/permissionAssignmentSchema.ts
|
|
719
|
+
const permissionAssignmentSchema = v.object({
|
|
720
|
+
id: v.number(),
|
|
721
|
+
permission_id: v.number(),
|
|
722
|
+
assignable_type: v.string(),
|
|
723
|
+
assignable_id: v.string(),
|
|
724
|
+
created_at: v.string(),
|
|
725
|
+
updated_at: v.string()
|
|
726
|
+
});
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region src/shared/schemas/permissionSchema.ts
|
|
729
|
+
const permissionSchema = v.object({
|
|
730
|
+
id: v.number(),
|
|
731
|
+
name: v.nullable(v.string()),
|
|
732
|
+
description: v.nullable(v.string()),
|
|
733
|
+
action: v.string(),
|
|
734
|
+
subject: v.string(),
|
|
735
|
+
conditions: v.nullable(v.string()),
|
|
736
|
+
created_at: v.string(),
|
|
737
|
+
updated_at: v.string(),
|
|
738
|
+
expires_at: v.string()
|
|
739
|
+
});
|
|
740
|
+
//#endregion
|
|
741
|
+
//#region src/shared/schemas/tokenSchema.ts
|
|
742
|
+
const tokenSchema = v.object({
|
|
743
|
+
id: v.number(),
|
|
744
|
+
name: v.nullable(v.string()),
|
|
745
|
+
type: v.string(),
|
|
746
|
+
user_id: v.number(),
|
|
747
|
+
token: v.string(),
|
|
748
|
+
created_at: v.string(),
|
|
749
|
+
updated_at: v.string(),
|
|
750
|
+
expires_at: v.string()
|
|
751
|
+
});
|
|
752
|
+
//#endregion
|
|
753
|
+
//#region src/shared/exceptions/ShellException.ts
|
|
754
|
+
var ShellException = class extends BaseException {
|
|
755
|
+
output;
|
|
756
|
+
bin;
|
|
757
|
+
args;
|
|
758
|
+
constructor(message, output, bin, args) {
|
|
759
|
+
super(message, 501);
|
|
760
|
+
this.output = output;
|
|
761
|
+
this.bin = bin;
|
|
762
|
+
this.args = args;
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
//#endregion
|
|
766
|
+
//#region src/shared/facades/validator.ts
|
|
678
767
|
const validator = new ValidatorService();
|
|
679
768
|
//#endregion
|
|
680
|
-
//#region src/shared/
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
const filePath = path.relative(path.dirname(filename), file);
|
|
689
|
-
const hasDefaultExport = fs.readFileSync(file, "utf-8").includes("export default") && !filePath.includes("generateIndexFile.ts");
|
|
690
|
-
content += `export * from './${filePath}'\n`;
|
|
691
|
-
if (hasDefaultExport) content += `export { default as ${path.basename(file, ".ts")} } from './${filePath}'\n`;
|
|
692
|
-
}
|
|
769
|
+
//#region src/shared/entities/DriveEntryEntity.ts
|
|
770
|
+
var DriveEntry = class {
|
|
771
|
+
name;
|
|
772
|
+
path;
|
|
773
|
+
type;
|
|
774
|
+
metas = {};
|
|
775
|
+
constructor(data) {
|
|
776
|
+
Object.assign(this, data);
|
|
693
777
|
}
|
|
694
|
-
|
|
695
|
-
|
|
778
|
+
};
|
|
779
|
+
//#endregion
|
|
780
|
+
//#region src/shared/entities/LifecycleHook.ts
|
|
781
|
+
var LifecycleHook = class {
|
|
782
|
+
hook_id;
|
|
783
|
+
order;
|
|
784
|
+
subhooks;
|
|
785
|
+
constructor() {
|
|
786
|
+
if (!this.hook_id) this.hook_id = this.constructor.name;
|
|
787
|
+
}
|
|
788
|
+
async onRegister() {}
|
|
789
|
+
async onLoad() {}
|
|
790
|
+
async onBoot() {}
|
|
791
|
+
async onShutdown() {}
|
|
792
|
+
};
|
|
793
|
+
//#endregion
|
|
794
|
+
//#region src/shared/mixins/BaseEntityMixin.ts
|
|
795
|
+
function BaseEntity(Base) {
|
|
796
|
+
return class extends Base {
|
|
797
|
+
static from(data) {
|
|
798
|
+
const contructor = typeof this === "function" ? this : Base;
|
|
799
|
+
const instance = new contructor();
|
|
800
|
+
let payload = { ...data };
|
|
801
|
+
if (typeof contructor?.parse === "function") payload = contructor.parse(data);
|
|
802
|
+
if (typeof this?.parse === "function") payload = this.parse(data);
|
|
803
|
+
Object.assign(instance, payload);
|
|
804
|
+
return instance;
|
|
805
|
+
}
|
|
806
|
+
merge(data) {
|
|
807
|
+
Object.assign(this, data);
|
|
808
|
+
return this;
|
|
809
|
+
}
|
|
810
|
+
};
|
|
696
811
|
}
|
|
697
812
|
//#endregion
|
|
698
|
-
|
|
813
|
+
//#region src/shared/entities/ModuleEntity.ts
|
|
814
|
+
var Module = class extends compose(BaseEntity, mixin(LifecycleHook)) {
|
|
815
|
+
id;
|
|
816
|
+
name;
|
|
817
|
+
enabled = false;
|
|
818
|
+
dependencies = {};
|
|
819
|
+
build = {};
|
|
820
|
+
directory;
|
|
821
|
+
upgrade_info;
|
|
822
|
+
setData(data) {
|
|
823
|
+
const filtered = Object.fromEntries(Object.entries(data).filter(([, v]) => v !== void 0));
|
|
824
|
+
Object.assign(this, filtered);
|
|
825
|
+
this.hook_id = `module:${this.id}`;
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
//#endregion
|
|
829
|
+
//#region src/shared/entities/ModuleManifestEntity.ts
|
|
830
|
+
var ModuleManifest = class extends compose(BaseEntity) {
|
|
831
|
+
id;
|
|
832
|
+
name;
|
|
833
|
+
version;
|
|
834
|
+
description;
|
|
835
|
+
enabled;
|
|
836
|
+
author;
|
|
837
|
+
dependencies;
|
|
838
|
+
build;
|
|
839
|
+
};
|
|
840
|
+
//#endregion
|
|
841
|
+
export { BaseException, ConfigService, ContainerService, CookieService, DriveEntry as DriveEntryEntity, EmmitterService, LifecycleHook, LifecycleService, LoggerService, Module as ModuleEntity, ModuleManifest as ModuleManifestEntity, ShellException, TranslatorService, UploadService, ValidatorService, compose, composeWith, createId, flatten, formatBytes, 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.12",
|
|
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",
|
|
@@ -27,15 +32,19 @@
|
|
|
27
32
|
},
|
|
28
33
|
"scripts": {
|
|
29
34
|
"generate:indexes": "node indexes.js",
|
|
30
|
-
"build": "tsdown",
|
|
35
|
+
"build": "tsdown --dts",
|
|
31
36
|
"watch": "tsdown --watch",
|
|
32
37
|
"release": "node artisan.js release"
|
|
33
38
|
},
|
|
34
39
|
"devDependencies": {
|
|
35
40
|
"@eslint/js": "^9.39.4",
|
|
36
41
|
"@eslint/json": "^0.14.0",
|
|
42
|
+
"@types/js-yaml": "^4.0.9",
|
|
37
43
|
"@types/lodash-es": "^4.17.12",
|
|
44
|
+
"@types/mime": "^3.0.4",
|
|
45
|
+
"@types/ms": "^2.1.0",
|
|
38
46
|
"@types/node": "^25.6.0",
|
|
47
|
+
"@types/qs": "^6.15.0",
|
|
39
48
|
"@vue/tsconfig": "^0.9.1",
|
|
40
49
|
"commander": "^14.0.3",
|
|
41
50
|
"eslint": "^9.39.4",
|
|
@@ -45,11 +54,26 @@
|
|
|
45
54
|
"jiti": "^2.6.1",
|
|
46
55
|
"tsdown": "^0.21.9",
|
|
47
56
|
"typescript": "^6.0.3",
|
|
48
|
-
"typescript-eslint": "^8.58.2"
|
|
57
|
+
"typescript-eslint": "^8.58.2",
|
|
58
|
+
"vitest": "^3.2.4"
|
|
49
59
|
},
|
|
50
60
|
"dependencies": {
|
|
61
|
+
"@aws-sdk/client-s3": "^3.1039.0",
|
|
62
|
+
"@aws-sdk/lib-storage": "^3.1039.0",
|
|
63
|
+
"@aws-sdk/s3-request-presigner": "^3.1039.0",
|
|
64
|
+
"better-sqlite3": "^12.9.0",
|
|
65
|
+
"cli-table3": "^0.6.5",
|
|
66
|
+
"date-fns": "^4.1.0",
|
|
67
|
+
"dotenv": "^17.4.2",
|
|
51
68
|
"fast-glob": "^3.3.3",
|
|
69
|
+
"js-yaml": "^4.1.1",
|
|
70
|
+
"kysely": "^0.28.16",
|
|
52
71
|
"lodash-es": "^4.18.1",
|
|
72
|
+
"mime": "^4.1.0",
|
|
73
|
+
"ms": "^2.1.3",
|
|
74
|
+
"mysql2": "^3.22.3",
|
|
75
|
+
"pg": "^8.20.0",
|
|
76
|
+
"qs": "^6.15.1",
|
|
53
77
|
"valibot": "^1.3.1"
|
|
54
78
|
}
|
|
55
79
|
}
|
package/tsconfig.server.json
CHANGED
package/tsdown.config.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineConfig, globalLogger } from 'tsdown'
|
|
2
|
-
import { generateIndexFile } from './src/
|
|
2
|
+
import { generateIndexFile } from './src/server/utils/generateIndexFile'
|
|
3
3
|
|
|
4
4
|
export default defineConfig([
|
|
5
5
|
{
|
|
@@ -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
|
})
|