@anu8151/adonisjs-blueprint 0.3.9 → 0.4.1
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/{base_generator-ClKso0XJ.d.ts → base_generator-DOMn-U0f.d.ts} +1 -320
- package/build/{event_generator-B83LtJmu.d.ts → event_generator-DVSh_7fH.d.ts} +1 -1
- package/build/{job_generator-GmmbUvVL.d.ts → job_generator-BxEjVVDl.d.ts} +1 -1
- package/build/{mail_generator-B-TNNzl3.d.ts → mail_generator-2j0SThZE.d.ts} +1 -1
- package/build/{notification_generator-C8kSV8HA.d.ts → notification_generator-BvDpMRu-.d.ts} +1 -1
- package/build/{service_generator-Slb920qs.d.ts → service_generator-DkhvTVzm.d.ts} +1 -1
- package/build/src/commands/main.d.ts +10 -0
- package/build/src/commands/main.js +36 -1
- package/build/types-DGOelf2A.d.ts +321 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as Macroable, r as Exception, t as HookHandler } from "./types-DGOelf2A.js";
|
|
1
2
|
import { Codemods } from "@adonisjs/core/ace/codemods";
|
|
2
3
|
import { AssemblerRcFile } from "@adonisjs/assembler/types";
|
|
3
4
|
import diagnostics_channel from "node:diagnostics_channel";
|
|
@@ -309,84 +310,6 @@ declare class StubsManager {
|
|
|
309
310
|
})): Promise<string[]>;
|
|
310
311
|
}
|
|
311
312
|
//#endregion
|
|
312
|
-
//#region node_modules/@poppinss/exception/build/src/exception.d.ts
|
|
313
|
-
/**
|
|
314
|
-
* Create a custom error class with the ability to define the error
|
|
315
|
-
* code, status, and the help text.
|
|
316
|
-
*
|
|
317
|
-
* ```js
|
|
318
|
-
* export class FileNotFoundException extends Exception {
|
|
319
|
-
* static status = 500
|
|
320
|
-
* static code = 'E_FILE_NOT_FOUND'
|
|
321
|
-
* }
|
|
322
|
-
*
|
|
323
|
-
* throw new FileNotFoundException(
|
|
324
|
-
* `Unable to find file from ${filePath} location`
|
|
325
|
-
* )
|
|
326
|
-
* ```
|
|
327
|
-
*/
|
|
328
|
-
declare class Exception extends Error {
|
|
329
|
-
/**
|
|
330
|
-
* Define the error metadata as static properties to avoid
|
|
331
|
-
* setting them repeatedly on the error instance
|
|
332
|
-
*/
|
|
333
|
-
static help?: string;
|
|
334
|
-
static code?: string;
|
|
335
|
-
static status?: number;
|
|
336
|
-
static message?: string;
|
|
337
|
-
/**
|
|
338
|
-
* Name of the class that raised the exception.
|
|
339
|
-
*/
|
|
340
|
-
name: string;
|
|
341
|
-
/**
|
|
342
|
-
* Optional help description for the error. You can use it to define additional
|
|
343
|
-
* human readable information for the error.
|
|
344
|
-
*/
|
|
345
|
-
help?: string;
|
|
346
|
-
/**
|
|
347
|
-
* A machine readable error code. This will allow the error handling logic
|
|
348
|
-
* to narrow down exceptions based upon the error code.
|
|
349
|
-
*/
|
|
350
|
-
code?: string;
|
|
351
|
-
/**
|
|
352
|
-
* A status code for the error. Usually helpful when converting errors
|
|
353
|
-
* to HTTP responses.
|
|
354
|
-
*/
|
|
355
|
-
status: number;
|
|
356
|
-
constructor(message?: string, options?: ErrorOptions & {
|
|
357
|
-
code?: string;
|
|
358
|
-
status?: number;
|
|
359
|
-
});
|
|
360
|
-
get [Symbol.toStringTag](): string;
|
|
361
|
-
toString(): string;
|
|
362
|
-
}
|
|
363
|
-
declare class InvalidArgumentsException extends Exception {
|
|
364
|
-
static code: string;
|
|
365
|
-
static status: number;
|
|
366
|
-
}
|
|
367
|
-
declare class RuntimeException extends Exception {
|
|
368
|
-
static code: string;
|
|
369
|
-
static status: number;
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Helper to create an anonymous error class.
|
|
373
|
-
*
|
|
374
|
-
* ```ts
|
|
375
|
-
*
|
|
376
|
-
* const E_RESOURCE_NOT_FOUND = createError<[number]>(
|
|
377
|
-
* 'Unable to find resource with id %d',
|
|
378
|
-
* 'E_RESOURCE_NOT_FOUND'
|
|
379
|
-
* )
|
|
380
|
-
* const id = 1
|
|
381
|
-
* throw new E_RESOURCE_NOT_FOUND([id])
|
|
382
|
-
*```
|
|
383
|
-
*/
|
|
384
|
-
declare function createError<T extends any[] = never>(message: string, code: string, status?: number): typeof Exception & T extends never ? {
|
|
385
|
-
new (args?: any, options?: ErrorOptions): Exception;
|
|
386
|
-
} : {
|
|
387
|
-
new (args: T, options?: ErrorOptions): Exception;
|
|
388
|
-
};
|
|
389
|
-
//#endregion
|
|
390
313
|
//#region node_modules/@adonisjs/fold/build/src/resolver.d.ts
|
|
391
314
|
/**
|
|
392
315
|
* Container resolver exposes the APIs to resolve bindings. You can think
|
|
@@ -1527,248 +1450,6 @@ declare function parseBindingReference(binding: string | [LazyImport<Constructor
|
|
|
1527
1450
|
*/
|
|
1528
1451
|
declare const containerMake: diagnostics_channel.TracingChannel<"adonisjs.container.make", ContainerMakeTracingData>;
|
|
1529
1452
|
//#endregion
|
|
1530
|
-
//#region node_modules/@poppinss/macroable/build/index.d.ts
|
|
1531
|
-
/**
|
|
1532
|
-
* Abstract class that adds capabilities for extending classes from outside-in,
|
|
1533
|
-
* in the form of macros, instance properties, and getters.
|
|
1534
|
-
*
|
|
1535
|
-
* @example
|
|
1536
|
-
* ```ts
|
|
1537
|
-
* class User extends Macroable {
|
|
1538
|
-
* name: string
|
|
1539
|
-
* constructor(name: string) {
|
|
1540
|
-
* super()
|
|
1541
|
-
* this.name = name
|
|
1542
|
-
* }
|
|
1543
|
-
* }
|
|
1544
|
-
*
|
|
1545
|
-
* // Add a macro
|
|
1546
|
-
* User.macro('greet', function() {
|
|
1547
|
-
* return `Hello, ${this.name}`
|
|
1548
|
-
* })
|
|
1549
|
-
*
|
|
1550
|
-
* // Add a getter
|
|
1551
|
-
* User.getter('upperName', function() {
|
|
1552
|
-
* return this.name.toUpperCase()
|
|
1553
|
-
* })
|
|
1554
|
-
*
|
|
1555
|
-
* const user = new User('John')
|
|
1556
|
-
* user.greet() // "Hello, John"
|
|
1557
|
-
* user.upperName // "JOHN"
|
|
1558
|
-
* ```
|
|
1559
|
-
*/
|
|
1560
|
-
declare abstract class Macroable {
|
|
1561
|
-
/**
|
|
1562
|
-
* Set of instance properties that will be added to each instance during construction.
|
|
1563
|
-
* Each entry contains a key and value pair representing the property name and its value.
|
|
1564
|
-
*/
|
|
1565
|
-
protected static instanceMacros: Set<{
|
|
1566
|
-
key: string | symbol | number;
|
|
1567
|
-
value: unknown;
|
|
1568
|
-
}>;
|
|
1569
|
-
/**
|
|
1570
|
-
* Adds a macro (property or method) to the class prototype.
|
|
1571
|
-
* Macros are standard properties that get added to the class prototype,
|
|
1572
|
-
* making them available on all instances of the class.
|
|
1573
|
-
*
|
|
1574
|
-
* @param name - The name of the property or method to add
|
|
1575
|
-
* @param value - The value to assign to the property or method
|
|
1576
|
-
*
|
|
1577
|
-
* @example
|
|
1578
|
-
* ```ts
|
|
1579
|
-
* // Add a property macro
|
|
1580
|
-
* MyClass.macro('version', '1.0.0')
|
|
1581
|
-
*
|
|
1582
|
-
* // Add a method macro
|
|
1583
|
-
* MyClass.macro('greet', function() {
|
|
1584
|
-
* return 'Hello!'
|
|
1585
|
-
* })
|
|
1586
|
-
*
|
|
1587
|
-
* const instance = new MyClass()
|
|
1588
|
-
* instance.version // "1.0.0"
|
|
1589
|
-
* instance.greet() // "Hello!"
|
|
1590
|
-
* ```
|
|
1591
|
-
*/
|
|
1592
|
-
static macro<T extends {
|
|
1593
|
-
new (...args: any[]): any;
|
|
1594
|
-
}, K extends keyof InstanceType<T>>(this: T, name: K, value: InstanceType<T>[K]): void;
|
|
1595
|
-
/**
|
|
1596
|
-
* Adds an instance property that will be assigned to each instance during construction.
|
|
1597
|
-
* Unlike macros which are added to the prototype, instance properties are unique to each instance.
|
|
1598
|
-
*
|
|
1599
|
-
* @param name - The name of the property to add to instances
|
|
1600
|
-
* @param value - The value to assign to the property on each instance
|
|
1601
|
-
*
|
|
1602
|
-
* @example
|
|
1603
|
-
* ```ts
|
|
1604
|
-
* // Add an instance method
|
|
1605
|
-
* MyClass.instanceProperty('save', function() {
|
|
1606
|
-
* console.log('Saving...', this.id)
|
|
1607
|
-
* })
|
|
1608
|
-
*
|
|
1609
|
-
* const { save } = new MyClass()
|
|
1610
|
-
* save()
|
|
1611
|
-
* ```
|
|
1612
|
-
*/
|
|
1613
|
-
static instanceProperty<T extends {
|
|
1614
|
-
new (...args: any[]): any;
|
|
1615
|
-
}, K extends keyof InstanceType<T>>(this: T, name: K, value: InstanceType<T>[K]): void;
|
|
1616
|
-
/**
|
|
1617
|
-
* Adds a getter property to the class prototype using Object.defineProperty.
|
|
1618
|
-
* Getters are computed properties that are evaluated each time they are accessed,
|
|
1619
|
-
* unless the singleton flag is enabled.
|
|
1620
|
-
*
|
|
1621
|
-
* @param name - The name of the getter property
|
|
1622
|
-
* @param accumulator - Function that computes and returns the property value
|
|
1623
|
-
* @param singleton - If true, the getter value is cached after first access
|
|
1624
|
-
*
|
|
1625
|
-
* @example
|
|
1626
|
-
* ```ts
|
|
1627
|
-
* // Add a regular getter
|
|
1628
|
-
* MyClass.getter('timestamp', function() {
|
|
1629
|
-
* return Date.now()
|
|
1630
|
-
* })
|
|
1631
|
-
*
|
|
1632
|
-
* // Add a singleton getter (cached after first access)
|
|
1633
|
-
* MyClass.getter('config', function() {
|
|
1634
|
-
* return loadConfig()
|
|
1635
|
-
* }, true)
|
|
1636
|
-
*
|
|
1637
|
-
* const instance = new MyClass()
|
|
1638
|
-
* instance.timestamp // Computed each time
|
|
1639
|
-
* instance.config // Computed once, then cached
|
|
1640
|
-
* ```
|
|
1641
|
-
*/
|
|
1642
|
-
static getter<T extends {
|
|
1643
|
-
new (...args: any[]): any;
|
|
1644
|
-
}, K extends keyof InstanceType<T>>(this: T, name: K, accumulator: () => InstanceType<T>[K], singleton?: boolean): void;
|
|
1645
|
-
/**
|
|
1646
|
-
* Constructor that applies all registered instance properties to the new instance.
|
|
1647
|
-
* This method iterates through the instanceMacros set and assigns each property
|
|
1648
|
-
* to the instance, binding functions to the instance context.
|
|
1649
|
-
*/
|
|
1650
|
-
constructor();
|
|
1651
|
-
}
|
|
1652
|
-
//#endregion
|
|
1653
|
-
//#region node_modules/@poppinss/hooks/build/src/runner.d.ts
|
|
1654
|
-
/**
|
|
1655
|
-
* Runner allows running a set of specific hook handlers for a given
|
|
1656
|
-
* event. You can grab the instance of the runner using the "hook.runner" method.
|
|
1657
|
-
*
|
|
1658
|
-
* ```ts
|
|
1659
|
-
* const hooks = new Hooks()
|
|
1660
|
-
*
|
|
1661
|
-
* await hooks.runner('saving').run()
|
|
1662
|
-
* ```
|
|
1663
|
-
*/
|
|
1664
|
-
declare class Runner<HookArgs extends any[], CleanUpArgs extends any[]> {
|
|
1665
|
-
#private;
|
|
1666
|
-
action: string;
|
|
1667
|
-
/**
|
|
1668
|
-
* Find if cleanup is pending or not
|
|
1669
|
-
*
|
|
1670
|
-
* @example
|
|
1671
|
-
* ```ts
|
|
1672
|
-
* const runner = hooks.runner('saving')
|
|
1673
|
-
* await runner.run()
|
|
1674
|
-
*
|
|
1675
|
-
* if (runner.isCleanupPending) {
|
|
1676
|
-
* await runner.cleanup()
|
|
1677
|
-
* }
|
|
1678
|
-
* ```
|
|
1679
|
-
*/
|
|
1680
|
-
get isCleanupPending(): boolean;
|
|
1681
|
-
/**
|
|
1682
|
-
* Create a new Runner instance
|
|
1683
|
-
*
|
|
1684
|
-
* @param action - The name of the event/action this runner handles
|
|
1685
|
-
* @param hookHandlers - Optional set of hook handlers to initialize with
|
|
1686
|
-
*
|
|
1687
|
-
* @example
|
|
1688
|
-
* ```ts
|
|
1689
|
-
* const runner = new Runner('saving', new Set([handler1, handler2]))
|
|
1690
|
-
* ```
|
|
1691
|
-
*/
|
|
1692
|
-
constructor(action: string, hookHandlers?: Set<HookHandler<HookArgs, CleanUpArgs> | HookHandlerProvider<HookArgs, CleanUpArgs>>);
|
|
1693
|
-
/**
|
|
1694
|
-
* Ignore specific or all hook handlers. Calling this
|
|
1695
|
-
* method multiple times will result in overwriting
|
|
1696
|
-
* the existing state.
|
|
1697
|
-
*
|
|
1698
|
-
* @param handlersToIgnore - Array of handler names to ignore, or undefined to skip all hooks
|
|
1699
|
-
*
|
|
1700
|
-
* @example
|
|
1701
|
-
* ```ts
|
|
1702
|
-
* // Skip specific handlers
|
|
1703
|
-
* runner.without(['hashPassword', 'validateEmail']).run()
|
|
1704
|
-
*
|
|
1705
|
-
* // Skip all handlers
|
|
1706
|
-
* runner.without().run()
|
|
1707
|
-
* ```
|
|
1708
|
-
*/
|
|
1709
|
-
without(handlersToIgnore?: string[]): this;
|
|
1710
|
-
/**
|
|
1711
|
-
* Execute handlers
|
|
1712
|
-
*
|
|
1713
|
-
* @param data - Arguments to pass to the hook handlers
|
|
1714
|
-
*
|
|
1715
|
-
* @example
|
|
1716
|
-
* ```ts
|
|
1717
|
-
* const runner = hooks.runner('saving')
|
|
1718
|
-
* await runner.run(user, { email: 'new@example.com' })
|
|
1719
|
-
* ```
|
|
1720
|
-
*/
|
|
1721
|
-
run(...data: HookArgs): Promise<void>;
|
|
1722
|
-
/**
|
|
1723
|
-
* Execute handlers in reverse order
|
|
1724
|
-
*
|
|
1725
|
-
* @param data - Arguments to pass to the hook handlers
|
|
1726
|
-
*
|
|
1727
|
-
* @example
|
|
1728
|
-
* ```ts
|
|
1729
|
-
* const runner = hooks.runner('deleting')
|
|
1730
|
-
* await runner.runReverse(user)
|
|
1731
|
-
* ```
|
|
1732
|
-
*/
|
|
1733
|
-
runReverse(...data: HookArgs): Promise<void>;
|
|
1734
|
-
/**
|
|
1735
|
-
* Execute cleanup actions
|
|
1736
|
-
*
|
|
1737
|
-
* @param data - Arguments to pass to the cleanup handlers
|
|
1738
|
-
*
|
|
1739
|
-
* @example
|
|
1740
|
-
* ```ts
|
|
1741
|
-
* const runner = hooks.runner('saving')
|
|
1742
|
-
* await runner.run(user)
|
|
1743
|
-
*
|
|
1744
|
-
* // Later, cleanup any resources
|
|
1745
|
-
* await runner.cleanup(user)
|
|
1746
|
-
* ```
|
|
1747
|
-
*/
|
|
1748
|
-
cleanup(...data: CleanUpArgs): Promise<void>;
|
|
1749
|
-
}
|
|
1750
|
-
//#endregion
|
|
1751
|
-
//#region node_modules/@poppinss/hooks/build/src/types.d.ts
|
|
1752
|
-
/**
|
|
1753
|
-
* Shape of the cleanup handler
|
|
1754
|
-
*/
|
|
1755
|
-
type CleanupHandler<Args extends any[]> = (...args: Args) => void | Promise<void>;
|
|
1756
|
-
/**
|
|
1757
|
-
* Shape of the hook handler
|
|
1758
|
-
*/
|
|
1759
|
-
type HookHandler<Args extends any[], CleanUpArgs extends any[]> = (...args: Args) => void | CleanupHandler<CleanUpArgs> | Promise<void> | Promise<CleanupHandler<CleanUpArgs>>;
|
|
1760
|
-
/**
|
|
1761
|
-
* Extracts args from a hook handler type
|
|
1762
|
-
*/
|
|
1763
|
-
type ExtractHookHandlerArgs<Handler> = Handler extends HookHandler<infer A, infer B> ? [A, B] : never;
|
|
1764
|
-
/**
|
|
1765
|
-
* Hook represented as an object with handle method
|
|
1766
|
-
*/
|
|
1767
|
-
type HookHandlerProvider<Args extends any[], CleanUpArgs extends any[]> = {
|
|
1768
|
-
name: string;
|
|
1769
|
-
handle(event: string, ...args: Args): void | CleanupHandler<CleanUpArgs> | Promise<void> | Promise<CleanupHandler<CleanUpArgs>>;
|
|
1770
|
-
};
|
|
1771
|
-
//#endregion
|
|
1772
1453
|
//#region node_modules/@adonisjs/application/build/src/feature_flags.d.ts
|
|
1773
1454
|
/**
|
|
1774
1455
|
* A light weight implementation of feature flags to conditionally enable
|
|
@@ -1 +1,11 @@
|
|
|
1
1
|
export declare const commands: (() => Promise<typeof import("./erase.js")>)[];
|
|
2
|
+
/**
|
|
3
|
+
* Metadata for the commands.
|
|
4
|
+
* Used by Ace Kernel to display help/list.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getMetaData(): Promise<import("@adonisjs/ace/types").CommandMetaData[]>;
|
|
7
|
+
/**
|
|
8
|
+
* Loads a command by its name.
|
|
9
|
+
* Used by Ace Kernel when running a command.
|
|
10
|
+
*/
|
|
11
|
+
export declare function load(commandName: string): Promise<any>;
|
|
@@ -6,5 +6,40 @@ const commands = [
|
|
|
6
6
|
() => import("./stubs.js"),
|
|
7
7
|
() => import("./init.js")
|
|
8
8
|
];
|
|
9
|
+
/**
|
|
10
|
+
* Metadata for the commands.
|
|
11
|
+
* Used by Ace Kernel to display help/list.
|
|
12
|
+
*/
|
|
13
|
+
async function getMetaData() {
|
|
14
|
+
const [build, erase, trace, stubs, init] = await Promise.all([
|
|
15
|
+
import("./build.js"),
|
|
16
|
+
import("./erase.js"),
|
|
17
|
+
import("./trace.js"),
|
|
18
|
+
import("./stubs.js"),
|
|
19
|
+
import("./init.js")
|
|
20
|
+
]);
|
|
21
|
+
return [
|
|
22
|
+
build.default.serialize(),
|
|
23
|
+
erase.default.serialize(),
|
|
24
|
+
trace.default.serialize(),
|
|
25
|
+
stubs.default.serialize(),
|
|
26
|
+
init.default.serialize()
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Loads a command by its name.
|
|
31
|
+
* Used by Ace Kernel when running a command.
|
|
32
|
+
*/
|
|
33
|
+
async function load(commandName) {
|
|
34
|
+
const map = {
|
|
35
|
+
"blueprint:build": () => import("./build.js"),
|
|
36
|
+
"blueprint:erase": () => import("./erase.js"),
|
|
37
|
+
"blueprint:trace": () => import("./trace.js"),
|
|
38
|
+
"blueprint:stubs": () => import("./stubs.js"),
|
|
39
|
+
"blueprint:init": () => import("./init.js")
|
|
40
|
+
};
|
|
41
|
+
if (map[commandName]) return map[commandName]();
|
|
42
|
+
throw new Error(`Command "${commandName}" not found`);
|
|
43
|
+
}
|
|
9
44
|
//#endregion
|
|
10
|
-
export { commands };
|
|
45
|
+
export { commands, getMetaData, load };
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
//#region node_modules/@poppinss/exception/build/src/exception.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Create a custom error class with the ability to define the error
|
|
4
|
+
* code, status, and the help text.
|
|
5
|
+
*
|
|
6
|
+
* ```js
|
|
7
|
+
* export class FileNotFoundException extends Exception {
|
|
8
|
+
* static status = 500
|
|
9
|
+
* static code = 'E_FILE_NOT_FOUND'
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* throw new FileNotFoundException(
|
|
13
|
+
* `Unable to find file from ${filePath} location`
|
|
14
|
+
* )
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare class Exception extends Error {
|
|
18
|
+
/**
|
|
19
|
+
* Define the error metadata as static properties to avoid
|
|
20
|
+
* setting them repeatedly on the error instance
|
|
21
|
+
*/
|
|
22
|
+
static help?: string;
|
|
23
|
+
static code?: string;
|
|
24
|
+
static status?: number;
|
|
25
|
+
static message?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Name of the class that raised the exception.
|
|
28
|
+
*/
|
|
29
|
+
name: string;
|
|
30
|
+
/**
|
|
31
|
+
* Optional help description for the error. You can use it to define additional
|
|
32
|
+
* human readable information for the error.
|
|
33
|
+
*/
|
|
34
|
+
help?: string;
|
|
35
|
+
/**
|
|
36
|
+
* A machine readable error code. This will allow the error handling logic
|
|
37
|
+
* to narrow down exceptions based upon the error code.
|
|
38
|
+
*/
|
|
39
|
+
code?: string;
|
|
40
|
+
/**
|
|
41
|
+
* A status code for the error. Usually helpful when converting errors
|
|
42
|
+
* to HTTP responses.
|
|
43
|
+
*/
|
|
44
|
+
status: number;
|
|
45
|
+
constructor(message?: string, options?: ErrorOptions & {
|
|
46
|
+
code?: string;
|
|
47
|
+
status?: number;
|
|
48
|
+
});
|
|
49
|
+
get [Symbol.toStringTag](): string;
|
|
50
|
+
toString(): string;
|
|
51
|
+
}
|
|
52
|
+
declare class InvalidArgumentsException extends Exception {
|
|
53
|
+
static code: string;
|
|
54
|
+
static status: number;
|
|
55
|
+
}
|
|
56
|
+
declare class RuntimeException extends Exception {
|
|
57
|
+
static code: string;
|
|
58
|
+
static status: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Helper to create an anonymous error class.
|
|
62
|
+
*
|
|
63
|
+
* ```ts
|
|
64
|
+
*
|
|
65
|
+
* const E_RESOURCE_NOT_FOUND = createError<[number]>(
|
|
66
|
+
* 'Unable to find resource with id %d',
|
|
67
|
+
* 'E_RESOURCE_NOT_FOUND'
|
|
68
|
+
* )
|
|
69
|
+
* const id = 1
|
|
70
|
+
* throw new E_RESOURCE_NOT_FOUND([id])
|
|
71
|
+
*```
|
|
72
|
+
*/
|
|
73
|
+
declare function createError<T extends any[] = never>(message: string, code: string, status?: number): typeof Exception & T extends never ? {
|
|
74
|
+
new (args?: any, options?: ErrorOptions): Exception;
|
|
75
|
+
} : {
|
|
76
|
+
new (args: T, options?: ErrorOptions): Exception;
|
|
77
|
+
};
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region node_modules/@poppinss/macroable/build/index.d.ts
|
|
80
|
+
/**
|
|
81
|
+
* Abstract class that adds capabilities for extending classes from outside-in,
|
|
82
|
+
* in the form of macros, instance properties, and getters.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* class User extends Macroable {
|
|
87
|
+
* name: string
|
|
88
|
+
* constructor(name: string) {
|
|
89
|
+
* super()
|
|
90
|
+
* this.name = name
|
|
91
|
+
* }
|
|
92
|
+
* }
|
|
93
|
+
*
|
|
94
|
+
* // Add a macro
|
|
95
|
+
* User.macro('greet', function() {
|
|
96
|
+
* return `Hello, ${this.name}`
|
|
97
|
+
* })
|
|
98
|
+
*
|
|
99
|
+
* // Add a getter
|
|
100
|
+
* User.getter('upperName', function() {
|
|
101
|
+
* return this.name.toUpperCase()
|
|
102
|
+
* })
|
|
103
|
+
*
|
|
104
|
+
* const user = new User('John')
|
|
105
|
+
* user.greet() // "Hello, John"
|
|
106
|
+
* user.upperName // "JOHN"
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
declare abstract class Macroable {
|
|
110
|
+
/**
|
|
111
|
+
* Set of instance properties that will be added to each instance during construction.
|
|
112
|
+
* Each entry contains a key and value pair representing the property name and its value.
|
|
113
|
+
*/
|
|
114
|
+
protected static instanceMacros: Set<{
|
|
115
|
+
key: string | symbol | number;
|
|
116
|
+
value: unknown;
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* Adds a macro (property or method) to the class prototype.
|
|
120
|
+
* Macros are standard properties that get added to the class prototype,
|
|
121
|
+
* making them available on all instances of the class.
|
|
122
|
+
*
|
|
123
|
+
* @param name - The name of the property or method to add
|
|
124
|
+
* @param value - The value to assign to the property or method
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* // Add a property macro
|
|
129
|
+
* MyClass.macro('version', '1.0.0')
|
|
130
|
+
*
|
|
131
|
+
* // Add a method macro
|
|
132
|
+
* MyClass.macro('greet', function() {
|
|
133
|
+
* return 'Hello!'
|
|
134
|
+
* })
|
|
135
|
+
*
|
|
136
|
+
* const instance = new MyClass()
|
|
137
|
+
* instance.version // "1.0.0"
|
|
138
|
+
* instance.greet() // "Hello!"
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
static macro<T extends {
|
|
142
|
+
new (...args: any[]): any;
|
|
143
|
+
}, K extends keyof InstanceType<T>>(this: T, name: K, value: InstanceType<T>[K]): void;
|
|
144
|
+
/**
|
|
145
|
+
* Adds an instance property that will be assigned to each instance during construction.
|
|
146
|
+
* Unlike macros which are added to the prototype, instance properties are unique to each instance.
|
|
147
|
+
*
|
|
148
|
+
* @param name - The name of the property to add to instances
|
|
149
|
+
* @param value - The value to assign to the property on each instance
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* // Add an instance method
|
|
154
|
+
* MyClass.instanceProperty('save', function() {
|
|
155
|
+
* console.log('Saving...', this.id)
|
|
156
|
+
* })
|
|
157
|
+
*
|
|
158
|
+
* const { save } = new MyClass()
|
|
159
|
+
* save()
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
static instanceProperty<T extends {
|
|
163
|
+
new (...args: any[]): any;
|
|
164
|
+
}, K extends keyof InstanceType<T>>(this: T, name: K, value: InstanceType<T>[K]): void;
|
|
165
|
+
/**
|
|
166
|
+
* Adds a getter property to the class prototype using Object.defineProperty.
|
|
167
|
+
* Getters are computed properties that are evaluated each time they are accessed,
|
|
168
|
+
* unless the singleton flag is enabled.
|
|
169
|
+
*
|
|
170
|
+
* @param name - The name of the getter property
|
|
171
|
+
* @param accumulator - Function that computes and returns the property value
|
|
172
|
+
* @param singleton - If true, the getter value is cached after first access
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* // Add a regular getter
|
|
177
|
+
* MyClass.getter('timestamp', function() {
|
|
178
|
+
* return Date.now()
|
|
179
|
+
* })
|
|
180
|
+
*
|
|
181
|
+
* // Add a singleton getter (cached after first access)
|
|
182
|
+
* MyClass.getter('config', function() {
|
|
183
|
+
* return loadConfig()
|
|
184
|
+
* }, true)
|
|
185
|
+
*
|
|
186
|
+
* const instance = new MyClass()
|
|
187
|
+
* instance.timestamp // Computed each time
|
|
188
|
+
* instance.config // Computed once, then cached
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
static getter<T extends {
|
|
192
|
+
new (...args: any[]): any;
|
|
193
|
+
}, K extends keyof InstanceType<T>>(this: T, name: K, accumulator: () => InstanceType<T>[K], singleton?: boolean): void;
|
|
194
|
+
/**
|
|
195
|
+
* Constructor that applies all registered instance properties to the new instance.
|
|
196
|
+
* This method iterates through the instanceMacros set and assigns each property
|
|
197
|
+
* to the instance, binding functions to the instance context.
|
|
198
|
+
*/
|
|
199
|
+
constructor();
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region node_modules/@poppinss/hooks/build/src/runner.d.ts
|
|
203
|
+
/**
|
|
204
|
+
* Runner allows running a set of specific hook handlers for a given
|
|
205
|
+
* event. You can grab the instance of the runner using the "hook.runner" method.
|
|
206
|
+
*
|
|
207
|
+
* ```ts
|
|
208
|
+
* const hooks = new Hooks()
|
|
209
|
+
*
|
|
210
|
+
* await hooks.runner('saving').run()
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
declare class Runner<HookArgs extends any[], CleanUpArgs extends any[]> {
|
|
214
|
+
#private;
|
|
215
|
+
action: string;
|
|
216
|
+
/**
|
|
217
|
+
* Find if cleanup is pending or not
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```ts
|
|
221
|
+
* const runner = hooks.runner('saving')
|
|
222
|
+
* await runner.run()
|
|
223
|
+
*
|
|
224
|
+
* if (runner.isCleanupPending) {
|
|
225
|
+
* await runner.cleanup()
|
|
226
|
+
* }
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
get isCleanupPending(): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Create a new Runner instance
|
|
232
|
+
*
|
|
233
|
+
* @param action - The name of the event/action this runner handles
|
|
234
|
+
* @param hookHandlers - Optional set of hook handlers to initialize with
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* const runner = new Runner('saving', new Set([handler1, handler2]))
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
constructor(action: string, hookHandlers?: Set<HookHandler<HookArgs, CleanUpArgs> | HookHandlerProvider<HookArgs, CleanUpArgs>>);
|
|
242
|
+
/**
|
|
243
|
+
* Ignore specific or all hook handlers. Calling this
|
|
244
|
+
* method multiple times will result in overwriting
|
|
245
|
+
* the existing state.
|
|
246
|
+
*
|
|
247
|
+
* @param handlersToIgnore - Array of handler names to ignore, or undefined to skip all hooks
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```ts
|
|
251
|
+
* // Skip specific handlers
|
|
252
|
+
* runner.without(['hashPassword', 'validateEmail']).run()
|
|
253
|
+
*
|
|
254
|
+
* // Skip all handlers
|
|
255
|
+
* runner.without().run()
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
without(handlersToIgnore?: string[]): this;
|
|
259
|
+
/**
|
|
260
|
+
* Execute handlers
|
|
261
|
+
*
|
|
262
|
+
* @param data - Arguments to pass to the hook handlers
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```ts
|
|
266
|
+
* const runner = hooks.runner('saving')
|
|
267
|
+
* await runner.run(user, { email: 'new@example.com' })
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
run(...data: HookArgs): Promise<void>;
|
|
271
|
+
/**
|
|
272
|
+
* Execute handlers in reverse order
|
|
273
|
+
*
|
|
274
|
+
* @param data - Arguments to pass to the hook handlers
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```ts
|
|
278
|
+
* const runner = hooks.runner('deleting')
|
|
279
|
+
* await runner.runReverse(user)
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
runReverse(...data: HookArgs): Promise<void>;
|
|
283
|
+
/**
|
|
284
|
+
* Execute cleanup actions
|
|
285
|
+
*
|
|
286
|
+
* @param data - Arguments to pass to the cleanup handlers
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```ts
|
|
290
|
+
* const runner = hooks.runner('saving')
|
|
291
|
+
* await runner.run(user)
|
|
292
|
+
*
|
|
293
|
+
* // Later, cleanup any resources
|
|
294
|
+
* await runner.cleanup(user)
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
cleanup(...data: CleanUpArgs): Promise<void>;
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region node_modules/@poppinss/hooks/build/src/types.d.ts
|
|
301
|
+
/**
|
|
302
|
+
* Shape of the cleanup handler
|
|
303
|
+
*/
|
|
304
|
+
type CleanupHandler<Args extends any[]> = (...args: Args) => void | Promise<void>;
|
|
305
|
+
/**
|
|
306
|
+
* Shape of the hook handler
|
|
307
|
+
*/
|
|
308
|
+
type HookHandler<Args extends any[], CleanUpArgs extends any[]> = (...args: Args) => void | CleanupHandler<CleanUpArgs> | Promise<void> | Promise<CleanupHandler<CleanUpArgs>>;
|
|
309
|
+
/**
|
|
310
|
+
* Extracts args from a hook handler type
|
|
311
|
+
*/
|
|
312
|
+
type ExtractHookHandlerArgs<Handler> = Handler extends HookHandler<infer A, infer B> ? [A, B] : never;
|
|
313
|
+
/**
|
|
314
|
+
* Hook represented as an object with handle method
|
|
315
|
+
*/
|
|
316
|
+
type HookHandlerProvider<Args extends any[], CleanUpArgs extends any[]> = {
|
|
317
|
+
name: string;
|
|
318
|
+
handle(event: string, ...args: Args): void | CleanupHandler<CleanUpArgs> | Promise<void> | Promise<CleanupHandler<CleanUpArgs>>;
|
|
319
|
+
};
|
|
320
|
+
//#endregion
|
|
321
|
+
export { Macroable as n, Exception as r, HookHandler as t };
|