webspresso 0.0.100 → 0.0.102
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/.agents/ADMIN.md +47 -4
- package/.agents/AGENTS.md +3 -1
- package/.agents/ARCHITECTURE.md +11 -0
- package/.agents/AUTH.md +63 -0
- package/.agents/CLI.md +81 -0
- package/.agents/CONVENTIONS.md +4 -0
- package/.agents/EMAIL.md +84 -2
- package/.agents/EVENTS.md +179 -0
- package/.agents/ORM.md +59 -0
- package/.agents/PLUGINS.md +32 -6
- package/.agents/ROUTING.md +163 -3
- package/.agents/skills/webspresso-framework/SKILL.md +32 -0
- package/.agents/skills/webspresso-routing-and-api/SKILL.md +4 -4
- package/AGENTS.md +7 -0
- package/README.md +18 -5
- package/bin/commands/add-tailwind.js +10 -0
- package/bin/commands/build.js +34 -0
- package/bin/commands/db-makemigrations.js +83 -0
- package/bin/commands/list.js +96 -0
- package/bin/commands/make-command.js +93 -0
- package/bin/commands/make-event.js +80 -0
- package/bin/commands/make-factory.js +72 -0
- package/bin/commands/make-mail.js +93 -0
- package/bin/commands/make-policy.js +106 -0
- package/bin/commands/routes.js +8 -0
- package/bin/commands/run.js +195 -0
- package/bin/webspresso.js +17 -0
- package/core/applySchema.js +18 -1
- package/core/auth/bouncer.js +196 -0
- package/core/auth/index.js +10 -0
- package/core/auth/middleware.js +15 -1
- package/core/commands/define-command.js +48 -0
- package/core/commands/index.js +18 -0
- package/core/commands/registry.js +156 -0
- package/core/commands/runner.js +76 -0
- package/core/compression/compressible.js +1 -1
- package/core/compression/middleware.js +35 -251
- package/core/content/service.js +8 -2
- package/core/events/discovery.js +142 -0
- package/core/events/dispatcher.js +552 -0
- package/core/events/index.js +23 -0
- package/core/events/signal.js +92 -0
- package/core/forms/flash.js +234 -0
- package/core/forms/form-builder.js +214 -0
- package/core/forms/index.js +16 -0
- package/core/mail/index.js +23 -0
- package/core/mail/mailable.js +250 -0
- package/core/mail/mailer.js +184 -0
- package/core/mail/transports.js +238 -0
- package/core/orm/factory.js +250 -0
- package/core/orm/index.js +6 -0
- package/core/orm/migrations/diff.js +185 -0
- package/core/orm/migrations/index.js +22 -4
- package/core/orm/model.js +4 -0
- package/index.d.ts +422 -1
- package/index.js +111 -16
- package/package.json +9 -5
- package/plugins/admin-panel/api.js +509 -3
- package/plugins/admin-panel/index.js +29 -0
- package/plugins/content/models/content-entry.js +4 -3
- package/plugins/content/models/content-type.js +4 -3
- package/plugins/cors.js +2 -2
- package/plugins/csrf/index.js +1 -1
- package/plugins/email/index.js +48 -0
- package/plugins/email/preview-handler.js +555 -0
- package/plugins/email/service.js +23 -12
- package/plugins/email/transport.js +30 -11
- package/plugins/file-manager/index.js +13 -0
- package/plugins/index.js +2 -0
- package/plugins/lazy.js +258 -0
- package/plugins/redirect/index.js +1 -1
- package/src/api/api-loader.js +18 -2
- package/src/api/validation-i18n.js +231 -0
- package/src/app-context.js +48 -6
- package/src/dev-reload/index.js +9 -1
- package/src/discovery/route-manifest.js +197 -0
- package/src/discovery/scan-routes.js +80 -5
- package/src/file-router.js +153 -91
- package/src/helpers.js +143 -0
- package/src/njk-frontmatter.js +17 -1
- package/src/pages/page-loader.js +1 -1
- package/src/plugin-manager.js +12 -0
- package/src/routing/cascading.js +14 -10
- package/src/routing/route-table.js +1 -1
- package/src/server.js +243 -34
- package/src/services/builtins/system.js +4 -6
- package/src/services/registry.js +12 -2
- package/src/template/precompile.js +247 -0
package/index.d.ts
CHANGED
|
@@ -68,6 +68,14 @@ export interface CreateAppOptions {
|
|
|
68
68
|
compression?: boolean | CompressionOptions;
|
|
69
69
|
/** Shutdown and lifecycle configuration */
|
|
70
70
|
shutdown?: ShutdownOptions;
|
|
71
|
+
/**
|
|
72
|
+
* Ahead-Of-Time (AOT) route manifest: boolean to enable/disable loading, or explicit path to manifest JSON file
|
|
73
|
+
*/
|
|
74
|
+
routesManifest?: boolean | string;
|
|
75
|
+
/**
|
|
76
|
+
* Precompiled Nunjucks templates: boolean to enable/disable loading, or explicit path to compiled bundle file
|
|
77
|
+
*/
|
|
78
|
+
precompiledTemplates?: boolean | string;
|
|
71
79
|
/** Development tooling and DX options */
|
|
72
80
|
dev?: {
|
|
73
81
|
banner?: boolean;
|
|
@@ -509,6 +517,8 @@ export function getAppContext(): {
|
|
|
509
517
|
db: DatabaseInstance | null;
|
|
510
518
|
shutdownManager: ShutdownManager | null;
|
|
511
519
|
serviceRegistry: ServiceRegistry | null;
|
|
520
|
+
events?: any;
|
|
521
|
+
mailer?: Mailer | null;
|
|
512
522
|
};
|
|
513
523
|
|
|
514
524
|
export function getDb(): DatabaseInstance;
|
|
@@ -523,12 +533,18 @@ export function getServiceRegistry(): ServiceRegistry | null;
|
|
|
523
533
|
|
|
524
534
|
export function hasServiceRegistry(): boolean;
|
|
525
535
|
|
|
536
|
+
export function getMailer(): Mailer | null;
|
|
537
|
+
|
|
538
|
+
export function hasMailer(): boolean;
|
|
539
|
+
|
|
526
540
|
export function resetAppContext(): void;
|
|
527
541
|
|
|
528
542
|
export function setAppContext(partial: {
|
|
529
543
|
db?: DatabaseInstance | null;
|
|
530
544
|
shutdownManager?: ShutdownManager | null;
|
|
531
545
|
serviceRegistry?: ServiceRegistry | null;
|
|
546
|
+
events?: any;
|
|
547
|
+
mailer?: Mailer | null;
|
|
532
548
|
}): void;
|
|
533
549
|
|
|
534
550
|
// --- File router ---
|
|
@@ -649,6 +665,25 @@ export function detectLocale(
|
|
|
649
665
|
defaultLocale: string
|
|
650
666
|
): string;
|
|
651
667
|
|
|
668
|
+
export interface TranslateValidationIssuesOptions {
|
|
669
|
+
req?: Request;
|
|
670
|
+
t?: Translator;
|
|
671
|
+
locale?: string;
|
|
672
|
+
pagesDir?: string;
|
|
673
|
+
routeDir?: string;
|
|
674
|
+
isDev?: boolean;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
export function translateValidationIssues<T = unknown>(
|
|
678
|
+
issues: T[],
|
|
679
|
+
options?: TranslateValidationIssuesOptions
|
|
680
|
+
): T[];
|
|
681
|
+
|
|
682
|
+
export function getTranslatorForRequest(
|
|
683
|
+
req?: Request,
|
|
684
|
+
options?: { pagesDir?: string; routeDir?: string; isDev?: boolean }
|
|
685
|
+
): { t: Translator; locale: string };
|
|
686
|
+
|
|
652
687
|
export function parseNjkFrontmatter(content: string): {
|
|
653
688
|
body: string;
|
|
654
689
|
fm: Record<string, unknown> | null;
|
|
@@ -672,6 +707,125 @@ export function loadNjkRouteTemplate(
|
|
|
672
707
|
|
|
673
708
|
export function clearNjkFrontmatterCaches(): void;
|
|
674
709
|
|
|
710
|
+
// --- Forms & Flash subsystem (AdonisJS & Django-inspired) ---
|
|
711
|
+
|
|
712
|
+
export interface FlashMessages {
|
|
713
|
+
old?: Record<string, any>;
|
|
714
|
+
errors?: Record<string, string[]>;
|
|
715
|
+
[key: string]: any;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
export function createFlashMiddleware(options?: { cookieName?: string }): import('express').RequestHandler;
|
|
719
|
+
|
|
720
|
+
export function normalizeErrors(errors: any): Record<string, string[]>;
|
|
721
|
+
|
|
722
|
+
export interface FieldRenderOptions {
|
|
723
|
+
label?: string;
|
|
724
|
+
type?: string;
|
|
725
|
+
placeholder?: string;
|
|
726
|
+
required?: boolean;
|
|
727
|
+
disabled?: boolean;
|
|
728
|
+
readonly?: boolean;
|
|
729
|
+
className?: string;
|
|
730
|
+
wrapperClass?: string;
|
|
731
|
+
errorClass?: string;
|
|
732
|
+
showError?: boolean;
|
|
733
|
+
rows?: number;
|
|
734
|
+
selectOptions?: (string | { label: string; value: any })[];
|
|
735
|
+
helpText?: string;
|
|
736
|
+
value?: any;
|
|
737
|
+
default?: any;
|
|
738
|
+
attributes?: Record<string, string>;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
export function renderField(name: string, options?: FieldRenderOptions, ctx?: { req?: any; res?: any }): string;
|
|
742
|
+
|
|
743
|
+
export interface FormForOptions {
|
|
744
|
+
action?: string;
|
|
745
|
+
method?: string;
|
|
746
|
+
exclude?: string[];
|
|
747
|
+
include?: string[];
|
|
748
|
+
submitLabel?: string;
|
|
749
|
+
csrf?: boolean;
|
|
750
|
+
formClass?: string;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
export function renderFormFor(modelOrRepo: any, options?: FormForOptions, ctx?: { req?: any; res?: any }): string;
|
|
754
|
+
|
|
755
|
+
// --- Authorization & Bouncer (AdonisJS Bouncer & Django Permissions-inspired) ---
|
|
756
|
+
|
|
757
|
+
export class Bouncer {
|
|
758
|
+
constructor(user?: any, policyManager?: any);
|
|
759
|
+
user: any;
|
|
760
|
+
forUser(user: any): Bouncer;
|
|
761
|
+
allows(actionOrPolicy: string | Function, ...args: any[]): boolean;
|
|
762
|
+
denies(actionOrPolicy: string | Function, ...args: any[]): boolean;
|
|
763
|
+
authorize(actionOrPolicy: string | Function, ...args: any[]): boolean;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
export function createBouncer(user?: any, policyManager?: any): Bouncer;
|
|
767
|
+
|
|
768
|
+
export function createBouncerMiddleware(options?: { policyManager?: any }): import('express').RequestHandler;
|
|
769
|
+
|
|
770
|
+
export function definePolicy(name: string, rules: Record<string, (user: any, ...args: any[]) => boolean | Promise<boolean>>): void;
|
|
771
|
+
|
|
772
|
+
export function defineGate(name: string, callback: (user: any, ...args: any[]) => boolean | Promise<boolean>): void;
|
|
773
|
+
|
|
774
|
+
export function can(user: any, action: string, policy?: string | null, resource?: any): boolean;
|
|
775
|
+
|
|
776
|
+
export function cannot(user: any, action: string, policy?: string | null, resource?: any): boolean;
|
|
777
|
+
|
|
778
|
+
export function authorize(user: any, action: string, policy?: string | null, resource?: any): void;
|
|
779
|
+
|
|
780
|
+
// --- Decoupled Events & Signals (AdonisJS Events & Django Signals-inspired) ---
|
|
781
|
+
|
|
782
|
+
export interface EventListenerOptions {
|
|
783
|
+
sender?: any;
|
|
784
|
+
priority?: number;
|
|
785
|
+
once?: boolean;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
export class EventDispatcher {
|
|
789
|
+
constructor(options?: { queue?: any; maxListeners?: number; logger?: any });
|
|
790
|
+
on(event: string, handler: Function, options?: EventListenerOptions): () => void;
|
|
791
|
+
once(event: string, handler: Function, options?: EventListenerOptions): () => void;
|
|
792
|
+
off(event: string, handler: Function): this;
|
|
793
|
+
onAny(handler: (eventName: string, data: any, meta: any) => any, options?: { priority?: number; once?: boolean }): () => void;
|
|
794
|
+
emit(eventOrInstance: string | object, data?: any, options?: { sender?: any }): boolean;
|
|
795
|
+
emitAsync(eventOrInstance: string | object, data?: any, options?: { sender?: any }): Promise<Array<{ status: 'fulfilled' | 'rejected'; value?: any; reason?: any }>>;
|
|
796
|
+
emitParallel(eventOrInstance: string | object, data?: any, options?: { sender?: any }): Promise<Array<{ status: 'fulfilled' | 'rejected'; value?: any; reason?: any }>>;
|
|
797
|
+
emitSerial(eventOrInstance: string | object, data?: any, options?: { sender?: any }): Promise<any[]>;
|
|
798
|
+
emitWaterfall(eventOrInstance: string | object, initialData: any, options?: { sender?: any }): Promise<any>;
|
|
799
|
+
listenAndQueue(event: string, jobName: string, queueOptions?: Record<string, unknown>): () => void;
|
|
800
|
+
bridgeOrm(modelEvents?: any): () => void;
|
|
801
|
+
setQueue(queueManager: any): this;
|
|
802
|
+
eventNames(): string[];
|
|
803
|
+
listenerCount(event?: string): number;
|
|
804
|
+
removeAllListeners(event?: string): this;
|
|
805
|
+
clear(): void;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
export function createEventDispatcher(options?: { queue?: any; maxListeners?: number; logger?: any }): EventDispatcher;
|
|
809
|
+
|
|
810
|
+
export const events: EventDispatcher;
|
|
811
|
+
|
|
812
|
+
export class Signal {
|
|
813
|
+
constructor(name: string, dispatcher: EventDispatcher);
|
|
814
|
+
name: string;
|
|
815
|
+
dispatcher: EventDispatcher;
|
|
816
|
+
connect(receiver: Function, options?: EventListenerOptions): () => void;
|
|
817
|
+
disconnect(receiver: Function): this;
|
|
818
|
+
send(data?: any, options?: { sender?: any }): boolean;
|
|
819
|
+
sendAsync(data?: any, options?: { sender?: any }): Promise<Array<{ status: 'fulfilled' | 'rejected'; value?: any; reason?: any }>>;
|
|
820
|
+
sendSerial(data?: any, options?: { sender?: any }): Promise<any[]>;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
export function defineSignal(name: string, dispatcher?: EventDispatcher): Signal;
|
|
824
|
+
|
|
825
|
+
export function defineListener(event: string | string[], handler: Function, options?: EventListenerOptions): { event: string | string[]; handle: Function; [key: string]: any };
|
|
826
|
+
|
|
827
|
+
export function loadListeners(dirPath: string, dispatcher: EventDispatcher, options?: { logger?: any }): Array<{ file: string; event: string; handler: Function }>;
|
|
828
|
+
|
|
675
829
|
// --- Helpers / assets ---
|
|
676
830
|
|
|
677
831
|
export function createHelpers(context: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -1160,6 +1314,8 @@ export interface MigrationManager {
|
|
|
1160
1314
|
getConfig(): MigrationConfig & { directory: string; tableName: string };
|
|
1161
1315
|
hasTable(): Promise<boolean>;
|
|
1162
1316
|
unlock(): Promise<void>;
|
|
1317
|
+
diff(options?: { models?: ModelDefinition<any>[]; includeDrops?: boolean }): Promise<{ hasChanges: boolean; changes: Array<any> }>;
|
|
1318
|
+
makeMigrations(options?: { modelsDir?: string; dryRun?: boolean; includeDrops?: boolean; name?: string }): Promise<{ hasChanges: boolean; created: Array<any>; skipped: Array<any> }>;
|
|
1163
1319
|
}
|
|
1164
1320
|
|
|
1165
1321
|
export interface WebspressoModels {
|
|
@@ -1226,6 +1382,30 @@ export function createMemoryCacheProvider(options?: OrmMemoryCacheOptions): {
|
|
|
1226
1382
|
getSizeStats(): { entries: number; tags: number };
|
|
1227
1383
|
};
|
|
1228
1384
|
|
|
1385
|
+
// --- ORM: Model Factory & Seeding (AdonisJS Lucid-inspired) ---
|
|
1386
|
+
|
|
1387
|
+
export interface FactoryBuilder<T = Record<string, any>> {
|
|
1388
|
+
count(n: number): FactoryBuilder<T>;
|
|
1389
|
+
state(...stateNames: string[]): FactoryBuilder<T>;
|
|
1390
|
+
apply(...stateNames: string[]): FactoryBuilder<T>;
|
|
1391
|
+
merge(overrides: Partial<T>): FactoryBuilder<T>;
|
|
1392
|
+
make(overrides?: Partial<T>): T | T[];
|
|
1393
|
+
create(options: { db?: DatabaseInstance | Repository<T>; merge?: Partial<T> } | DatabaseInstance | Repository<T>): Promise<T | T[]>;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
export function defineFactory<T = Record<string, any>>(
|
|
1397
|
+
modelName: string,
|
|
1398
|
+
definitionFn: (ctx: { faker: any; index: number }) => Partial<T>
|
|
1399
|
+
): FactoryBuilder<T> & {
|
|
1400
|
+
state(name: string, handler: ((ctx: { faker: any; index: number; current: Partial<T> }) => Partial<T>) | Partial<T>): FactoryBuilder<T>;
|
|
1401
|
+
registerState(name: string, handler: ((ctx: { faker: any; index: number; current: Partial<T> }) => Partial<T>) | Partial<T>): FactoryBuilder<T>;
|
|
1402
|
+
};
|
|
1403
|
+
|
|
1404
|
+
// --- ORM: Schema Diff & Makemigrations (Django-inspired) ---
|
|
1405
|
+
|
|
1406
|
+
export function diffSchema(options: { knex: Knex; models?: ModelDefinition<any>[]; includeDrops?: boolean }): Promise<{ hasChanges: boolean; changes: Array<any> }>;
|
|
1407
|
+
export function makeMigrations(options: { knex: Knex; modelsDir?: string; migrationDir?: string; dryRun?: boolean; includeDrops?: boolean; name?: string }): Promise<{ hasChanges: boolean; created: Array<any>; skipped: Array<any> }>;
|
|
1408
|
+
|
|
1229
1409
|
// --- ORM: nanoid / zod ---
|
|
1230
1410
|
|
|
1231
1411
|
export function generateNanoid(options?: { maxLength?: number } | number): string;
|
|
@@ -1408,9 +1588,38 @@ export interface AdminPanelPluginOptions {
|
|
|
1408
1588
|
windowMs?: number;
|
|
1409
1589
|
blockDurationMs?: number;
|
|
1410
1590
|
};
|
|
1591
|
+
/** Lazy / On-Demand mount: defers plugin initialization until first request to adminPath or service execution */
|
|
1592
|
+
lazy?: boolean | LazyPluginOptions;
|
|
1411
1593
|
[key: string]: unknown;
|
|
1412
1594
|
}
|
|
1413
1595
|
|
|
1596
|
+
export interface LazyPluginOptions {
|
|
1597
|
+
name?: string;
|
|
1598
|
+
prefix?: string | string[];
|
|
1599
|
+
services?: string[];
|
|
1600
|
+
helpers?: string[];
|
|
1601
|
+
events?: string[];
|
|
1602
|
+
dependencies?: Record<string, string> | string[];
|
|
1603
|
+
csp?: Record<string, string[]>;
|
|
1604
|
+
onHydrate?: (realPlugin: WebspressoPlugin) => void;
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
export interface LazyPlugin extends WebspressoPlugin {
|
|
1608
|
+
isLazy: true;
|
|
1609
|
+
readonly isHydrated: boolean;
|
|
1610
|
+
hydrate(): WebspressoPlugin;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
export function lazyPlugin(
|
|
1614
|
+
pluginFactory: (() => WebspressoPlugin) | WebspressoPlugin,
|
|
1615
|
+
lazyOptions?: LazyPluginOptions
|
|
1616
|
+
): LazyPlugin;
|
|
1617
|
+
|
|
1618
|
+
export function defineLazyPlugin(
|
|
1619
|
+
pluginFactory: (() => WebspressoPlugin) | WebspressoPlugin,
|
|
1620
|
+
lazyOptions?: LazyPluginOptions
|
|
1621
|
+
): LazyPlugin;
|
|
1622
|
+
|
|
1414
1623
|
export function adminPanelPlugin(options?: AdminPanelPluginOptions): WebspressoPlugin;
|
|
1415
1624
|
|
|
1416
1625
|
export function dataExchangePlugin(options?: Record<string, unknown>): WebspressoPlugin;
|
|
@@ -1567,11 +1776,73 @@ export function emailPlugin(options?: EmailPluginOptions): WebspressoPlugin & {
|
|
|
1567
1776
|
isTransportReady(): boolean;
|
|
1568
1777
|
loadFromManifest(chunks: any): void;
|
|
1569
1778
|
emailPluginOptionsFromManifest(manifest: any): any;
|
|
1779
|
+
mailer?: Mailer;
|
|
1780
|
+
Mailable?: typeof Mailable;
|
|
1781
|
+
getOutbox?(): any[];
|
|
1782
|
+
clearOutbox?(): void;
|
|
1783
|
+
lastMessage?(): any;
|
|
1570
1784
|
};
|
|
1571
1785
|
dispose?(): void;
|
|
1572
1786
|
shutdown?(): void;
|
|
1573
1787
|
};
|
|
1574
1788
|
|
|
1789
|
+
export class Mailable {
|
|
1790
|
+
constructor();
|
|
1791
|
+
to(recipient: string | string[] | any, name?: string): this;
|
|
1792
|
+
from(address: string, name?: string): this;
|
|
1793
|
+
replyTo(address: string): this;
|
|
1794
|
+
cc(recipient: string | string[]): this;
|
|
1795
|
+
bcc(recipient: string | string[]): this;
|
|
1796
|
+
subject(subj: string): this;
|
|
1797
|
+
template(tplName: string): this;
|
|
1798
|
+
html(htmlContent: string): this;
|
|
1799
|
+
text(textContent: string): this;
|
|
1800
|
+
mjml(mjmlContent: string): this;
|
|
1801
|
+
view(templateOrData: string | Record<string, unknown>, data?: Record<string, unknown>): this;
|
|
1802
|
+
data(keyOrObj: string | Record<string, unknown>, value?: any): this;
|
|
1803
|
+
attach(attachment: any): this;
|
|
1804
|
+
header(key: string, value: string): this;
|
|
1805
|
+
prepare(): void;
|
|
1806
|
+
build(): void;
|
|
1807
|
+
toMessage(): Record<string, any>;
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
export class Mailer {
|
|
1811
|
+
constructor(options?: any);
|
|
1812
|
+
send(mailableOrOptions: Mailable | Record<string, any>): Promise<any>;
|
|
1813
|
+
preview(mailableOrOptions: Mailable | Record<string, any>): Promise<any>;
|
|
1814
|
+
getOutbox(): any[];
|
|
1815
|
+
clearOutbox(): void;
|
|
1816
|
+
lastMessage(): any;
|
|
1817
|
+
verify(): Promise<any>;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
export function createMailer(options?: any): Mailer;
|
|
1821
|
+
|
|
1822
|
+
export class MemoryTransport {
|
|
1823
|
+
outbox: any[];
|
|
1824
|
+
constructor(options?: any);
|
|
1825
|
+
sendMail(mailOptions: any): Promise<any>;
|
|
1826
|
+
getOutbox(): any[];
|
|
1827
|
+
clearOutbox(): void;
|
|
1828
|
+
lastMessage(): any;
|
|
1829
|
+
findById(id: string): any;
|
|
1830
|
+
verify(): Promise<boolean>;
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
export class ConsoleTransport {
|
|
1834
|
+
constructor(options?: any);
|
|
1835
|
+
sendMail(mailOptions: any): Promise<any>;
|
|
1836
|
+
verify(): Promise<boolean>;
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
export class FileTransport {
|
|
1840
|
+
dir: string;
|
|
1841
|
+
constructor(options?: any);
|
|
1842
|
+
sendMail(mailOptions: any): Promise<any>;
|
|
1843
|
+
verify(): Promise<boolean>;
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1575
1846
|
export function recaptchaPlugin(options?: Record<string, unknown>): WebspressoPlugin;
|
|
1576
1847
|
|
|
1577
1848
|
export interface SwaggerPluginOptions {
|
|
@@ -2927,11 +3198,14 @@ export interface ApiContext<TBody = any, TParams = Record<string, string>, TQuer
|
|
|
2927
3198
|
query: TQuery;
|
|
2928
3199
|
body: TBody;
|
|
2929
3200
|
input: { body?: TBody; params?: TParams; query?: TQuery; headers?: Record<string, string> };
|
|
3201
|
+
locale: string;
|
|
3202
|
+
t: Translator;
|
|
2930
3203
|
service: WebspressoServiceCaller;
|
|
2931
3204
|
module: string | null;
|
|
2932
3205
|
config: Record<string, unknown>;
|
|
2933
3206
|
logger: Console;
|
|
2934
3207
|
db: unknown;
|
|
3208
|
+
sse?: (sourceOrOptions?: any, maybeOptions?: any) => any;
|
|
2935
3209
|
}
|
|
2936
3210
|
|
|
2937
3211
|
export interface DefineApiOptions<TResult = any, TBody = any, TParams = Record<string, string>, TQuery = Record<string, string>> {
|
|
@@ -2998,7 +3272,21 @@ export function scanRoutes(options?: {
|
|
|
2998
3272
|
pages?: boolean | { dir?: string; prefix?: string };
|
|
2999
3273
|
api?: boolean | { dir?: string; prefix?: string };
|
|
3000
3274
|
modules?: boolean | { dir?: string };
|
|
3001
|
-
}): RouteDescriptor[];
|
|
3275
|
+
}): RouteDescriptor[] & { scannedPagesFiles?: string[]; scannedPagesDir?: string | null };
|
|
3276
|
+
|
|
3277
|
+
export function discoverAppRoutes(options?: {
|
|
3278
|
+
rootDir?: string;
|
|
3279
|
+
pages?: boolean | { dir?: string; prefix?: string };
|
|
3280
|
+
api?: boolean | { dir?: string; prefix?: string };
|
|
3281
|
+
modules?: boolean | { dir?: string };
|
|
3282
|
+
routes?: Array<{ method?: string; path: string }>;
|
|
3283
|
+
isDev?: boolean;
|
|
3284
|
+
}): {
|
|
3285
|
+
descriptors: RouteDescriptor[];
|
|
3286
|
+
routeTable: RouteTable;
|
|
3287
|
+
scannedPagesFiles: string[];
|
|
3288
|
+
scannedPagesDir: string | null;
|
|
3289
|
+
};
|
|
3002
3290
|
|
|
3003
3291
|
export function parseFileRoute(
|
|
3004
3292
|
relativePath: string,
|
|
@@ -3010,6 +3298,88 @@ export function compileRouteTable(
|
|
|
3010
3298
|
options?: { explicitRoutes?: Array<{ method?: string; path: string }>; isDev?: boolean }
|
|
3011
3299
|
): RouteTable;
|
|
3012
3300
|
|
|
3301
|
+
export function generateRouteManifest(options?: {
|
|
3302
|
+
rootDir?: string;
|
|
3303
|
+
pages?: boolean | string | { dir?: string; prefix?: string };
|
|
3304
|
+
api?: boolean | string | { dir?: string; prefix?: string };
|
|
3305
|
+
modules?: boolean | { dir?: string };
|
|
3306
|
+
pagesDir?: string;
|
|
3307
|
+
outDir?: string;
|
|
3308
|
+
outFile?: string;
|
|
3309
|
+
silent?: boolean;
|
|
3310
|
+
}): {
|
|
3311
|
+
manifest: {
|
|
3312
|
+
version: number;
|
|
3313
|
+
generatedAt: string;
|
|
3314
|
+
pagesDirRel: string;
|
|
3315
|
+
scannedPagesFiles: string[];
|
|
3316
|
+
routes: Array<{
|
|
3317
|
+
type: 'page' | 'api';
|
|
3318
|
+
method: string;
|
|
3319
|
+
path: string;
|
|
3320
|
+
source: string;
|
|
3321
|
+
module?: string | null;
|
|
3322
|
+
moduleConfig?: { name?: string } | null;
|
|
3323
|
+
}>;
|
|
3324
|
+
};
|
|
3325
|
+
manifestPath: string;
|
|
3326
|
+
routeCount: number;
|
|
3327
|
+
scannedFilesCount: number;
|
|
3328
|
+
};
|
|
3329
|
+
|
|
3330
|
+
export function loadRouteManifest(options?: {
|
|
3331
|
+
rootDir?: string;
|
|
3332
|
+
manifestPath?: string;
|
|
3333
|
+
}): {
|
|
3334
|
+
manifest: {
|
|
3335
|
+
version: number;
|
|
3336
|
+
generatedAt: string;
|
|
3337
|
+
pagesDirRel: string;
|
|
3338
|
+
scannedPagesFiles: string[];
|
|
3339
|
+
routes: Array<{
|
|
3340
|
+
type: 'page' | 'api';
|
|
3341
|
+
method: string;
|
|
3342
|
+
path: string;
|
|
3343
|
+
source: string;
|
|
3344
|
+
module?: string | null;
|
|
3345
|
+
moduleConfig?: { name?: string } | null;
|
|
3346
|
+
}>;
|
|
3347
|
+
};
|
|
3348
|
+
descriptors: RouteDescriptor[] & { scannedPagesFiles?: string[]; scannedPagesDir?: string | null };
|
|
3349
|
+
} | null;
|
|
3350
|
+
|
|
3351
|
+
export function precompileTemplates(options?: {
|
|
3352
|
+
rootDir?: string;
|
|
3353
|
+
viewsDir?: string;
|
|
3354
|
+
pagesDir?: string;
|
|
3355
|
+
outDir?: string;
|
|
3356
|
+
outFile?: string;
|
|
3357
|
+
env?: any;
|
|
3358
|
+
}): {
|
|
3359
|
+
templateCount: number;
|
|
3360
|
+
manifestPath: string;
|
|
3361
|
+
bundle: {
|
|
3362
|
+
version: number;
|
|
3363
|
+
generatedAt: string;
|
|
3364
|
+
templates: Record<string, string>;
|
|
3365
|
+
frontmatter: Record<string, any>;
|
|
3366
|
+
};
|
|
3367
|
+
};
|
|
3368
|
+
|
|
3369
|
+
export function loadPrecompiledTemplates(options?: {
|
|
3370
|
+
rootDir?: string;
|
|
3371
|
+
bundlePath?: string;
|
|
3372
|
+
}): {
|
|
3373
|
+
loader: any;
|
|
3374
|
+
templateCount: number;
|
|
3375
|
+
bundle: {
|
|
3376
|
+
version: number;
|
|
3377
|
+
generatedAt: string;
|
|
3378
|
+
templates: Record<string, string>;
|
|
3379
|
+
frontmatter: Record<string, any>;
|
|
3380
|
+
};
|
|
3381
|
+
} | null;
|
|
3382
|
+
|
|
3013
3383
|
export interface GenerateTypesOptions {
|
|
3014
3384
|
/** Root directory of the project (default: process.cwd()) */
|
|
3015
3385
|
rootDir?: string;
|
|
@@ -3422,3 +3792,54 @@ export namespace sessions {
|
|
|
3422
3792
|
};
|
|
3423
3793
|
}
|
|
3424
3794
|
|
|
3795
|
+
// Custom Management Commands (Django & Adonis Ace-inspired)
|
|
3796
|
+
export interface CommandOption {
|
|
3797
|
+
flags: string;
|
|
3798
|
+
description?: string;
|
|
3799
|
+
defaultValue?: any;
|
|
3800
|
+
}
|
|
3801
|
+
|
|
3802
|
+
export interface CommandExecutionContext {
|
|
3803
|
+
db: any;
|
|
3804
|
+
queue: any;
|
|
3805
|
+
services: any;
|
|
3806
|
+
mailer: any;
|
|
3807
|
+
events: any;
|
|
3808
|
+
logger: any;
|
|
3809
|
+
args: string[];
|
|
3810
|
+
flags: Record<string, any>;
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3813
|
+
export interface CommandDefinition {
|
|
3814
|
+
name: string;
|
|
3815
|
+
description?: string;
|
|
3816
|
+
options?: CommandOption[];
|
|
3817
|
+
handle: (ctx: CommandExecutionContext) => Promise<any> | any;
|
|
3818
|
+
}
|
|
3819
|
+
|
|
3820
|
+
export interface CommandRegistry {
|
|
3821
|
+
register(cmd: CommandDefinition): CommandDefinition;
|
|
3822
|
+
reload(): void;
|
|
3823
|
+
has(name: string): boolean;
|
|
3824
|
+
get(name: string): CommandDefinition | null;
|
|
3825
|
+
list(): CommandDefinition[];
|
|
3826
|
+
names(): string[];
|
|
3827
|
+
readonly commandsDir: string;
|
|
3828
|
+
}
|
|
3829
|
+
|
|
3830
|
+
export function defineCommand(definition: CommandDefinition): CommandDefinition;
|
|
3831
|
+
export function createCommandRegistry(options?: { commandsDir?: string; autoLoad?: boolean }): CommandRegistry;
|
|
3832
|
+
export function executeCommand(
|
|
3833
|
+
commandDef: CommandDefinition,
|
|
3834
|
+
executionOptions?: Partial<CommandExecutionContext>
|
|
3835
|
+
): Promise<{ success: boolean; result?: any; error?: Error; durationMs: number }>;
|
|
3836
|
+
|
|
3837
|
+
export namespace commands {
|
|
3838
|
+
export {
|
|
3839
|
+
defineCommand,
|
|
3840
|
+
createCommandRegistry,
|
|
3841
|
+
executeCommand,
|
|
3842
|
+
};
|
|
3843
|
+
}
|
|
3844
|
+
|
|
3845
|
+
|