@orieljs/events 0.1.0-alpha.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/LICENSE +202 -0
- package/NOTICE +9 -0
- package/dist/index.d.ts +159 -0
- package/dist/index.js +350 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Oriel
|
|
2
|
+
Copyright 2026 meeeet-dev and Oriel contributors
|
|
3
|
+
|
|
4
|
+
This product includes software developed by the Oriel project
|
|
5
|
+
(https://orieljs.vercel.app, https://github.com/orieljs).
|
|
6
|
+
|
|
7
|
+
Oriel is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
8
|
+
The Oriel name and logo are not covered by that license; see TRADEMARKS.md
|
|
9
|
+
(https://github.com/orieljs/framework/blob/main/TRADEMARKS.md).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { Job, EventDispatcher, ClassRegistry, Class, Listener, OrielError, Container, ListenerClass } from '@orieljs/contracts';
|
|
2
|
+
import * as _orieljs_support from '@orieljs/support';
|
|
3
|
+
import { ServiceProvider } from '@orieljs/support';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Wraps a queued listener call as a job (Laravel's CallQueuedListener). Always queueable: Dispatcher only ever
|
|
7
|
+
* builds one after it already decided the wrapped listener wants queueing, so this wrapper's own queueability is
|
|
8
|
+
* unconditional — set on its prototype below — unlike the structural, opt-in check `isQueueableListener()` runs on
|
|
9
|
+
* the wrapped listener itself. Forwards `failed()`, `displayName()`, `retryUntil()` and `middleware()` to a fresh
|
|
10
|
+
* instance of the wrapped listener (the Queue/Bus protocol), so a failing queued listener's own
|
|
11
|
+
* `failed()` hook runs, `queue:failed`/`displayName()` shows the listener's own class name instead of
|
|
12
|
+
* `CallQueuedListener`, and a listener's own `retryUntil()`/`middleware()` are honoured. `delay` (like `queue`,
|
|
13
|
+
* `connection`, `tries`, `backoff`, `timeout`) is a plain field, copied by `Dispatcher.queue()` from
|
|
14
|
+
* `queueOptionsOf()` — never a method — so it needs no forwarding here.
|
|
15
|
+
*/
|
|
16
|
+
declare class CallQueuedListener implements Job {
|
|
17
|
+
readonly listenerClass: string;
|
|
18
|
+
readonly method: string;
|
|
19
|
+
readonly data: unknown[];
|
|
20
|
+
connection?: string;
|
|
21
|
+
queue?: string;
|
|
22
|
+
delay?: number;
|
|
23
|
+
tries?: number;
|
|
24
|
+
backoff?: number | number[];
|
|
25
|
+
timeout?: number;
|
|
26
|
+
constructor(listenerClass: string, method: string, data: unknown[]);
|
|
27
|
+
/** A fresh listener instance, resolved through the container (never called with constructor arguments — DI only). */
|
|
28
|
+
private resolve;
|
|
29
|
+
handle(): Promise<void>;
|
|
30
|
+
failed(error: unknown): Promise<void>;
|
|
31
|
+
displayName(): string;
|
|
32
|
+
retryUntil(): unknown;
|
|
33
|
+
middleware(): unknown[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Imports every module under `directory` (recursively), registers each discoverable listener class into `registry`
|
|
38
|
+
* and calls `dispatcher.listen()` for it. Returns the registered names. Safe to call more than once for the same
|
|
39
|
+
* `dispatcher` (a worker process re-importing the same files re-registers each class in `ClassRegistry` — already
|
|
40
|
+
* idempotent — but is not `listen()`ed again).
|
|
41
|
+
*/
|
|
42
|
+
declare function discoverListeners(directory: string, dispatcher: EventDispatcher, registry: ClassRegistry): Promise<string[]>;
|
|
43
|
+
|
|
44
|
+
declare const Event: _orieljs_support.Facade<EventDispatcher, object>;
|
|
45
|
+
/** Laravel's event() helper: dispatches through the current container's EventDispatcher. */
|
|
46
|
+
declare function event(eventValue: object | string, payload?: unknown[]): Promise<unknown[]>;
|
|
47
|
+
|
|
48
|
+
/** A [ListenerClass, methodName] pair, e.g. [Subscriber, 'onUserRegistered']. */
|
|
49
|
+
type ListenerTuple<E> = [Class<object>, string];
|
|
50
|
+
declare function isListenerTuple(value: unknown): value is ListenerTuple<unknown>;
|
|
51
|
+
/** A class with a handle() method on its prototype, as opposed to a plain closure listener. */
|
|
52
|
+
declare function isListenerClass(value: unknown): value is Class<{
|
|
53
|
+
handle(...args: unknown[]): unknown;
|
|
54
|
+
}>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* `config('events.listen')`'s shape. Laravel's EventServiceProvider::$listen is a PHP array keyed by FQCN string
|
|
58
|
+
* constants; TypeScript object keys must be strings, so a real class reference can't be a plain-object key without
|
|
59
|
+
* losing type safety. This is a list of [event, listeners] pairs instead, so either side can be a class reference:
|
|
60
|
+
* [[UserRegistered, [SendWelcomeEmail]], ['order.shipped', [NotifyWarehouse]]]
|
|
61
|
+
*/
|
|
62
|
+
type EventListenMap = Array<[Class<unknown> | string, Array<Listener<unknown> | ListenerTuple<unknown>>]>;
|
|
63
|
+
declare class EventServiceProvider extends ServiceProvider {
|
|
64
|
+
register(): void;
|
|
65
|
+
boot(): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
declare class InvalidListenerError extends Error implements OrielError {
|
|
69
|
+
readonly kind: "Server";
|
|
70
|
+
readonly name = "InvalidListenerError";
|
|
71
|
+
constructor(event: string);
|
|
72
|
+
}
|
|
73
|
+
declare class EventsNeedBusDispatcherError extends Error implements OrielError {
|
|
74
|
+
readonly kind: "Server";
|
|
75
|
+
readonly name = "EventsNeedBusDispatcherError";
|
|
76
|
+
constructor(listenerName: string);
|
|
77
|
+
}
|
|
78
|
+
declare class EventsNeedClassRegistryError extends Error implements OrielError {
|
|
79
|
+
readonly kind: "Server";
|
|
80
|
+
readonly name = "EventsNeedClassRegistryError";
|
|
81
|
+
constructor(listenerName: string);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
type EventKey = Class<unknown> | string;
|
|
85
|
+
type Registration<E> = ((...args: any[]) => unknown) | ListenerClass<E> | ListenerTuple<E>;
|
|
86
|
+
/**
|
|
87
|
+
* Laravel's Illuminate\Events\Dispatcher, on top of Oriel's Container. dispatch() and until() share run(), which
|
|
88
|
+
* mirrors Dispatcher::dispatch($event, $payload, $halt): halt=true (until()) returns the first non-undefined
|
|
89
|
+
* response and stops; either way, a literal `false` response stops the remaining listeners.
|
|
90
|
+
*/
|
|
91
|
+
declare class Dispatcher implements EventDispatcher {
|
|
92
|
+
protected readonly container: Container;
|
|
93
|
+
private readonly listeners;
|
|
94
|
+
constructor(container: Container);
|
|
95
|
+
listen<E>(events: Class<E> | string | Array<Class<E> | string>, listener: Registration<E>): void;
|
|
96
|
+
hasListeners(event: Class<unknown> | string): boolean;
|
|
97
|
+
forget(event: Class<unknown> | string): void;
|
|
98
|
+
/** Introspection for the event:list command. Not part of the EventDispatcher contract. */
|
|
99
|
+
registeredEvents(): Array<{
|
|
100
|
+
event: string;
|
|
101
|
+
listeners: number;
|
|
102
|
+
}>;
|
|
103
|
+
subscribe(subscriber: Class<{
|
|
104
|
+
subscribe(events: EventDispatcher): void;
|
|
105
|
+
}>): void;
|
|
106
|
+
dispatch(event: object | string, payload?: unknown[]): Promise<unknown[]>;
|
|
107
|
+
/** Stops at the first listener whose response isn't undefined, and returns it. */
|
|
108
|
+
until(event: object | string, payload?: unknown[]): Promise<unknown>;
|
|
109
|
+
private run;
|
|
110
|
+
/**
|
|
111
|
+
* Exact-key listeners first, in registration order, then every matching wildcard pattern's listeners. Both the
|
|
112
|
+
* exact-key list and the set of matching wildcard patterns (and their listeners) are snapshotted into plain
|
|
113
|
+
* arrays before the first listener runs, so a listener that registers another listener for this same event (or
|
|
114
|
+
* a new matching wildcard) while running does not also run in this dispatch — it only runs starting with the
|
|
115
|
+
* next one, like Laravel.
|
|
116
|
+
*/
|
|
117
|
+
protected listenersFor(key: EventKey): Iterable<{
|
|
118
|
+
listener: Registration<unknown>;
|
|
119
|
+
wildcard: boolean;
|
|
120
|
+
}>;
|
|
121
|
+
private wildcardPatternsFor;
|
|
122
|
+
/**
|
|
123
|
+
* Instantiates class/tuple listeners through the container (listener classes have DI-only constructors, so this
|
|
124
|
+
* is cheap and side-effect-free even when the listener turns out to be queued), then queues instead of invoking
|
|
125
|
+
* inline when the constructed instance opts into queueing (the decision reads the instance, matching the
|
|
126
|
+
* Queue/Bus protocol's own isQueueable(), not just the class's static members).
|
|
127
|
+
*/
|
|
128
|
+
protected call(listener: Registration<unknown>, key: EventKey, args: unknown[], wildcard: boolean): Promise<unknown>;
|
|
129
|
+
/**
|
|
130
|
+
* Wraps the call as a CallQueuedListener job and dispatches it through BusDispatcher. Never runs inline; the
|
|
131
|
+
* already-constructed `instance` is used only to read its ShouldQueue options (queueOptionsOf), never to run
|
|
132
|
+
* handle()/method() — the worker builds its own instance from the registered class name.
|
|
133
|
+
*/
|
|
134
|
+
private queue;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
declare const QUEUE_OPTION_KEYS: readonly ["connection", "queue", "delay", "tries", "backoff", "timeout"];
|
|
138
|
+
type QueueOptionKey = (typeof QUEUE_OPTION_KEYS)[number];
|
|
139
|
+
/**
|
|
140
|
+
* Whether a listener opts into queueing. `implements ShouldQueue` leaves no runtime trace, so this is structural,
|
|
141
|
+
* like the Queue/Bus protocol's own `isQueueable(job)`: the marker, or an option, or a `uniqueId`/`retryUntil`
|
|
142
|
+
* method. Unlike a job (already an instance by the time Bus sees it), a listener is a *class* registered with
|
|
143
|
+
* `listen()`, so Events must build it first — `this.container.make(cls)` is cheap and side-effect-free for listener
|
|
144
|
+
* classes, which have DI-only constructors — and then applies the protocol rule to that instance: the marker
|
|
145
|
+
* (readable off the instance through the prototype chain), an **instance** option field with a defined value, or an
|
|
146
|
+
* instance `uniqueId`/`retryUntil` method — the same fields Mail's and Notifications' `isQueueableMailable`/
|
|
147
|
+
* equivalent read. A **static** field or method on the class counts too, as an extra on top of the protocol rule
|
|
148
|
+
* (not instead of it), so an existing `static queue = '...'` listener still works.
|
|
149
|
+
*/
|
|
150
|
+
declare function isQueueableListener(cls: Class<unknown>, instance: object): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Copies the instance's (falling back to the class's static) ShouldQueue options onto the wrapper job. Laravel lets
|
|
153
|
+
* these be methods (`backoff() { return [1, 5] }`) as well as plain fields — a method value is called (on the
|
|
154
|
+
* instance, or on the class for a static) before use, never copied as-is, since Bus's serializer rejects functions.
|
|
155
|
+
* Anything that isn't the expected type for its key (after resolving a method) is dropped rather than forwarded.
|
|
156
|
+
*/
|
|
157
|
+
declare function queueOptionsOf(cls: Class<unknown>, instance: object): Partial<Record<QueueOptionKey, unknown>>;
|
|
158
|
+
|
|
159
|
+
export { CallQueuedListener, Dispatcher, Event, type EventKey, type EventListenMap, EventServiceProvider, EventsNeedBusDispatcherError, EventsNeedClassRegistryError, InvalidListenerError, type ListenerTuple, discoverListeners, event, isListenerClass, isListenerTuple, isQueueableListener, queueOptionsOf };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
// CallQueuedListener.ts
|
|
2
|
+
import { ClassRegistry } from "@orieljs/contracts";
|
|
3
|
+
import { inject } from "@orieljs/container";
|
|
4
|
+
|
|
5
|
+
// errors.ts
|
|
6
|
+
var InvalidListenerError = class extends Error {
|
|
7
|
+
kind = "Server";
|
|
8
|
+
name = "InvalidListenerError";
|
|
9
|
+
constructor(event2) {
|
|
10
|
+
super(
|
|
11
|
+
`The listener registered for [${event2}] is not a function, a class with a handle() method, or a [Class, 'method'] tuple.`
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var EventsNeedBusDispatcherError = class extends Error {
|
|
16
|
+
kind = "Server";
|
|
17
|
+
name = "EventsNeedBusDispatcherError";
|
|
18
|
+
constructor(listenerName) {
|
|
19
|
+
super(`[${listenerName}] is a queued listener, but no BusDispatcher is bound. Register the BusServiceProvider.`);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var EventsNeedClassRegistryError = class extends Error {
|
|
23
|
+
kind = "Server";
|
|
24
|
+
name = "EventsNeedClassRegistryError";
|
|
25
|
+
constructor(listenerName) {
|
|
26
|
+
super(`[${listenerName}] is a queued listener, but no ClassRegistry is bound.`);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// CallQueuedListener.ts
|
|
31
|
+
var SHOULD_QUEUE = /* @__PURE__ */ Symbol.for("oriel:bus.shouldQueue");
|
|
32
|
+
var CallQueuedListener = class {
|
|
33
|
+
constructor(listenerClass, method, data) {
|
|
34
|
+
this.listenerClass = listenerClass;
|
|
35
|
+
this.method = method;
|
|
36
|
+
this.data = data;
|
|
37
|
+
}
|
|
38
|
+
listenerClass;
|
|
39
|
+
method;
|
|
40
|
+
data;
|
|
41
|
+
connection;
|
|
42
|
+
queue;
|
|
43
|
+
delay;
|
|
44
|
+
tries;
|
|
45
|
+
backoff;
|
|
46
|
+
timeout;
|
|
47
|
+
/** A fresh listener instance, resolved through the container (never called with constructor arguments — DI only). */
|
|
48
|
+
resolve() {
|
|
49
|
+
const registry = inject(ClassRegistry);
|
|
50
|
+
const cls = registry.resolve(this.listenerClass);
|
|
51
|
+
return inject(cls);
|
|
52
|
+
}
|
|
53
|
+
async handle() {
|
|
54
|
+
const instance = this.resolve();
|
|
55
|
+
const method = instance[this.method];
|
|
56
|
+
if (typeof method !== "function") throw new InvalidListenerError(this.listenerClass);
|
|
57
|
+
await method.apply(instance, this.data);
|
|
58
|
+
}
|
|
59
|
+
async failed(error) {
|
|
60
|
+
await this.resolve().failed?.(...this.data, error);
|
|
61
|
+
}
|
|
62
|
+
displayName() {
|
|
63
|
+
return this.listenerClass;
|
|
64
|
+
}
|
|
65
|
+
retryUntil() {
|
|
66
|
+
return this.resolve().retryUntil?.();
|
|
67
|
+
}
|
|
68
|
+
middleware() {
|
|
69
|
+
return this.resolve().middleware?.() ?? [];
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
CallQueuedListener.prototype[SHOULD_QUEUE] = true;
|
|
73
|
+
|
|
74
|
+
// discover.ts
|
|
75
|
+
import { existsSync, readdirSync, statSync } from "fs";
|
|
76
|
+
import { join } from "path";
|
|
77
|
+
import { pathToFileURL } from "url";
|
|
78
|
+
var EXTENSIONS = [".ts", ".js", ".mts", ".mjs"];
|
|
79
|
+
function files(directory) {
|
|
80
|
+
const found = [];
|
|
81
|
+
for (const entry of readdirSync(directory).sort()) {
|
|
82
|
+
const path = join(directory, entry);
|
|
83
|
+
if (statSync(path).isDirectory()) found.push(...files(path));
|
|
84
|
+
else if (EXTENSIONS.some((extension) => entry.endsWith(extension)) && !entry.endsWith(".d.ts")) found.push(path);
|
|
85
|
+
}
|
|
86
|
+
return found;
|
|
87
|
+
}
|
|
88
|
+
var isDiscoverableListener = (value) => typeof value === "function" && typeof value.prototype?.handle === "function" && "listensTo" in value;
|
|
89
|
+
var discoveredByDispatcher = /* @__PURE__ */ new WeakMap();
|
|
90
|
+
async function discoverListeners(directory, dispatcher, registry) {
|
|
91
|
+
if (!existsSync(directory)) return [];
|
|
92
|
+
let discovered = discoveredByDispatcher.get(dispatcher);
|
|
93
|
+
if (!discovered) {
|
|
94
|
+
discovered = /* @__PURE__ */ new WeakSet();
|
|
95
|
+
discoveredByDispatcher.set(dispatcher, discovered);
|
|
96
|
+
}
|
|
97
|
+
const names = [];
|
|
98
|
+
for (const file of files(directory)) {
|
|
99
|
+
const module = await import(pathToFileURL(file).href);
|
|
100
|
+
for (const exported of Object.values(module)) {
|
|
101
|
+
if (!isDiscoverableListener(exported)) continue;
|
|
102
|
+
names.push(registry.nameOf(exported) ?? registry.register(exported));
|
|
103
|
+
if (discovered.has(exported)) continue;
|
|
104
|
+
discovered.add(exported);
|
|
105
|
+
const events = Array.isArray(exported.listensTo) ? exported.listensTo : [exported.listensTo];
|
|
106
|
+
dispatcher.listen(events, exported);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return names;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// facade.ts
|
|
113
|
+
import { EventDispatcher as EventDispatcherToken } from "@orieljs/contracts";
|
|
114
|
+
import { inject as inject2 } from "@orieljs/container";
|
|
115
|
+
import { facade } from "@orieljs/support";
|
|
116
|
+
var Event = facade(EventDispatcherToken);
|
|
117
|
+
function event(eventValue, payload) {
|
|
118
|
+
return inject2(EventDispatcherToken).dispatch(eventValue, payload);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// EventServiceProvider.ts
|
|
122
|
+
import {
|
|
123
|
+
ClassRegistry as ClassRegistry3,
|
|
124
|
+
ConfigRepository,
|
|
125
|
+
ConsoleKernel,
|
|
126
|
+
EventDispatcher
|
|
127
|
+
} from "@orieljs/contracts";
|
|
128
|
+
import { ServiceProvider } from "@orieljs/support";
|
|
129
|
+
|
|
130
|
+
// Dispatcher.ts
|
|
131
|
+
import { BusDispatcher, ClassRegistry as ClassRegistry2 } from "@orieljs/contracts";
|
|
132
|
+
import { Str } from "@orieljs/support";
|
|
133
|
+
|
|
134
|
+
// listeners.ts
|
|
135
|
+
function isListenerTuple(value) {
|
|
136
|
+
return Array.isArray(value) && value.length === 2 && typeof value[0] === "function" && typeof value[1] === "string";
|
|
137
|
+
}
|
|
138
|
+
function isListenerClass(value) {
|
|
139
|
+
return typeof value === "function" && typeof value.prototype?.handle === "function";
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// queueable.ts
|
|
143
|
+
var SHOULD_QUEUE2 = /* @__PURE__ */ Symbol.for("oriel:bus.shouldQueue");
|
|
144
|
+
var QUEUE_OPTION_KEYS = ["connection", "queue", "delay", "tries", "backoff", "timeout"];
|
|
145
|
+
function isQueueableListener(cls, instance) {
|
|
146
|
+
const members = instance;
|
|
147
|
+
if (members[SHOULD_QUEUE2] === true) return true;
|
|
148
|
+
const statics = cls;
|
|
149
|
+
if (QUEUE_OPTION_KEYS.some((key) => members[key] !== void 0 || statics[key] !== void 0)) return true;
|
|
150
|
+
return typeof members.uniqueId === "function" || typeof members.retryUntil === "function" || typeof statics.uniqueId === "function" || typeof statics.retryUntil === "function";
|
|
151
|
+
}
|
|
152
|
+
var isString = (value) => typeof value === "string";
|
|
153
|
+
var isNumber = (value) => typeof value === "number";
|
|
154
|
+
var isNumberOrNumberArray = (value) => isNumber(value) || Array.isArray(value) && value.every(isNumber);
|
|
155
|
+
var VALIDATORS = {
|
|
156
|
+
connection: isString,
|
|
157
|
+
queue: isString,
|
|
158
|
+
delay: isNumber,
|
|
159
|
+
tries: isNumber,
|
|
160
|
+
timeout: isNumber,
|
|
161
|
+
backoff: isNumberOrNumberArray
|
|
162
|
+
};
|
|
163
|
+
function queueOptionsOf(cls, instance) {
|
|
164
|
+
const statics = cls;
|
|
165
|
+
const members = instance;
|
|
166
|
+
const options = {};
|
|
167
|
+
for (const key of QUEUE_OPTION_KEYS) {
|
|
168
|
+
let value;
|
|
169
|
+
let onInstance = true;
|
|
170
|
+
if (members[key] !== void 0) value = members[key];
|
|
171
|
+
else if (statics[key] !== void 0) {
|
|
172
|
+
value = statics[key];
|
|
173
|
+
onInstance = false;
|
|
174
|
+
} else continue;
|
|
175
|
+
if (typeof value === "function") value = onInstance ? value.call(instance) : value.call(cls);
|
|
176
|
+
if (VALIDATORS[key](value)) options[key] = value;
|
|
177
|
+
}
|
|
178
|
+
return options;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Dispatcher.ts
|
|
182
|
+
var nameOf = (key) => typeof key === "string" ? key : key.name;
|
|
183
|
+
var Dispatcher = class {
|
|
184
|
+
constructor(container) {
|
|
185
|
+
this.container = container;
|
|
186
|
+
}
|
|
187
|
+
container;
|
|
188
|
+
listeners = /* @__PURE__ */ new Map();
|
|
189
|
+
listen(events, listener) {
|
|
190
|
+
if (typeof listener !== "function" && !isListenerTuple(listener)) {
|
|
191
|
+
const label = Array.isArray(events) ? events.map((e) => nameOf(e)).join(", ") : nameOf(events);
|
|
192
|
+
throw new InvalidListenerError(label);
|
|
193
|
+
}
|
|
194
|
+
for (const event2 of Array.isArray(events) ? events : [events]) {
|
|
195
|
+
const list = this.listeners.get(event2) ?? [];
|
|
196
|
+
list.push(listener);
|
|
197
|
+
this.listeners.set(event2, list);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
hasListeners(event2) {
|
|
201
|
+
if ((this.listeners.get(event2)?.length ?? 0) > 0) return true;
|
|
202
|
+
return typeof event2 === "string" && this.wildcardPatternsFor(event2).some((pattern) => (this.listeners.get(pattern)?.length ?? 0) > 0);
|
|
203
|
+
}
|
|
204
|
+
forget(event2) {
|
|
205
|
+
this.listeners.delete(event2);
|
|
206
|
+
}
|
|
207
|
+
/** Introspection for the event:list command. Not part of the EventDispatcher contract. */
|
|
208
|
+
registeredEvents() {
|
|
209
|
+
const rows = [];
|
|
210
|
+
for (const [key, list] of this.listeners) rows.push({ event: nameOf(key), listeners: list.length });
|
|
211
|
+
return rows.sort((a, b) => a.event.localeCompare(b.event));
|
|
212
|
+
}
|
|
213
|
+
subscribe(subscriber) {
|
|
214
|
+
const instance = this.container.make(subscriber);
|
|
215
|
+
const result = instance.subscribe(this);
|
|
216
|
+
if (!result || typeof result !== "object") return;
|
|
217
|
+
for (const [event2, methods] of Object.entries(result)) {
|
|
218
|
+
for (const method of Array.isArray(methods) ? methods : [methods]) {
|
|
219
|
+
this.listen(event2, [subscriber, method]);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async dispatch(event2, payload = []) {
|
|
224
|
+
return await this.run(event2, payload, false);
|
|
225
|
+
}
|
|
226
|
+
/** Stops at the first listener whose response isn't undefined, and returns it. */
|
|
227
|
+
async until(event2, payload = []) {
|
|
228
|
+
return this.run(event2, payload, true);
|
|
229
|
+
}
|
|
230
|
+
async run(event2, payload, halt) {
|
|
231
|
+
const isString2 = typeof event2 === "string";
|
|
232
|
+
const key = isString2 ? event2 : event2.constructor;
|
|
233
|
+
const args = isString2 ? payload : [event2];
|
|
234
|
+
const responses = [];
|
|
235
|
+
for (const { listener, wildcard } of this.listenersFor(key)) {
|
|
236
|
+
const response = await this.call(listener, key, args, wildcard);
|
|
237
|
+
if (halt && response !== void 0) return response;
|
|
238
|
+
if (response === false) break;
|
|
239
|
+
responses.push(response);
|
|
240
|
+
}
|
|
241
|
+
return halt ? void 0 : responses;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Exact-key listeners first, in registration order, then every matching wildcard pattern's listeners. Both the
|
|
245
|
+
* exact-key list and the set of matching wildcard patterns (and their listeners) are snapshotted into plain
|
|
246
|
+
* arrays before the first listener runs, so a listener that registers another listener for this same event (or
|
|
247
|
+
* a new matching wildcard) while running does not also run in this dispatch — it only runs starting with the
|
|
248
|
+
* next one, like Laravel.
|
|
249
|
+
*/
|
|
250
|
+
*listenersFor(key) {
|
|
251
|
+
const exact = [...this.listeners.get(key) ?? []];
|
|
252
|
+
const wildcardLists = typeof key === "string" ? this.wildcardPatternsFor(key).map((pattern) => [...this.listeners.get(pattern) ?? []]) : [];
|
|
253
|
+
for (const listener of exact) yield { listener, wildcard: false };
|
|
254
|
+
for (const list of wildcardLists) {
|
|
255
|
+
for (const listener of list) yield { listener, wildcard: true };
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
wildcardPatternsFor(event2) {
|
|
259
|
+
const patterns = [];
|
|
260
|
+
for (const key of this.listeners.keys()) {
|
|
261
|
+
if (typeof key === "string" && key !== event2 && key.includes("*") && Str.is(key, event2)) patterns.push(key);
|
|
262
|
+
}
|
|
263
|
+
return patterns;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Instantiates class/tuple listeners through the container (listener classes have DI-only constructors, so this
|
|
267
|
+
* is cheap and side-effect-free even when the listener turns out to be queued), then queues instead of invoking
|
|
268
|
+
* inline when the constructed instance opts into queueing (the decision reads the instance, matching the
|
|
269
|
+
* Queue/Bus protocol's own isQueueable(), not just the class's static members).
|
|
270
|
+
*/
|
|
271
|
+
async call(listener, key, args, wildcard) {
|
|
272
|
+
const callArgs = wildcard ? [nameOf(key), args] : args;
|
|
273
|
+
if (isListenerTuple(listener)) {
|
|
274
|
+
const [cls, method] = listener;
|
|
275
|
+
const instance = this.container.make(cls);
|
|
276
|
+
if (isQueueableListener(cls, instance)) return this.queue(cls, instance, method, callArgs);
|
|
277
|
+
return instance[method](...callArgs);
|
|
278
|
+
}
|
|
279
|
+
if (isListenerClass(listener)) {
|
|
280
|
+
const instance = this.container.make(listener);
|
|
281
|
+
if (isQueueableListener(listener, instance)) return this.queue(listener, instance, "handle", callArgs);
|
|
282
|
+
return instance.handle(...callArgs);
|
|
283
|
+
}
|
|
284
|
+
return listener(...callArgs);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Wraps the call as a CallQueuedListener job and dispatches it through BusDispatcher. Never runs inline; the
|
|
288
|
+
* already-constructed `instance` is used only to read its ShouldQueue options (queueOptionsOf), never to run
|
|
289
|
+
* handle()/method() — the worker builds its own instance from the registered class name.
|
|
290
|
+
*/
|
|
291
|
+
async queue(cls, instance, method, data) {
|
|
292
|
+
const name = nameOf(cls);
|
|
293
|
+
if (!this.container.bound(BusDispatcher)) throw new EventsNeedBusDispatcherError(name);
|
|
294
|
+
if (!this.container.bound(ClassRegistry2)) throw new EventsNeedClassRegistryError(name);
|
|
295
|
+
const registry = this.container.make(ClassRegistry2);
|
|
296
|
+
const registeredName = registry.nameOf(cls) ?? registry.register(cls);
|
|
297
|
+
const job = new CallQueuedListener(registeredName, method, data);
|
|
298
|
+
Object.assign(job, queueOptionsOf(cls, instance));
|
|
299
|
+
await this.container.make(BusDispatcher).dispatch(job);
|
|
300
|
+
return void 0;
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// EventServiceProvider.ts
|
|
305
|
+
var EventServiceProvider = class extends ServiceProvider {
|
|
306
|
+
register() {
|
|
307
|
+
this.mergeConfigFrom({ discover: true, listen: [] }, "events");
|
|
308
|
+
this.app.singleton(EventDispatcher, (container) => new Dispatcher(container));
|
|
309
|
+
this.app.make(ClassRegistry3).register(CallQueuedListener, "Events.CallQueuedListener");
|
|
310
|
+
}
|
|
311
|
+
async boot() {
|
|
312
|
+
const dispatcher = this.app.make(EventDispatcher);
|
|
313
|
+
const registry = this.app.make(ClassRegistry3);
|
|
314
|
+
const config = this.app.make(ConfigRepository);
|
|
315
|
+
for (const [event2, listeners] of config.get("events.listen", [])) {
|
|
316
|
+
for (const listener of listeners) dispatcher.listen(event2, listener);
|
|
317
|
+
}
|
|
318
|
+
if (config.get("events.discover", true)) {
|
|
319
|
+
await discoverListeners(this.app.appPath("Listeners"), dispatcher, registry);
|
|
320
|
+
}
|
|
321
|
+
if (this.app.bound(ConsoleKernel)) {
|
|
322
|
+
const kernel = this.app.make(ConsoleKernel);
|
|
323
|
+
kernel.command("event:list", function() {
|
|
324
|
+
const rows = dispatcher.registeredEvents();
|
|
325
|
+
if (rows.length === 0) {
|
|
326
|
+
this.line("No events are registered.");
|
|
327
|
+
return 0;
|
|
328
|
+
}
|
|
329
|
+
for (const row of rows) this.line(` ${row.event} ${row.listeners} ${row.listeners === 1 ? "listener" : "listeners"}`);
|
|
330
|
+
return 0;
|
|
331
|
+
}).purpose("List the application's events and listeners");
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
export {
|
|
336
|
+
CallQueuedListener,
|
|
337
|
+
Dispatcher,
|
|
338
|
+
Event,
|
|
339
|
+
EventServiceProvider,
|
|
340
|
+
EventsNeedBusDispatcherError,
|
|
341
|
+
EventsNeedClassRegistryError,
|
|
342
|
+
InvalidListenerError,
|
|
343
|
+
discoverListeners,
|
|
344
|
+
event,
|
|
345
|
+
isListenerClass,
|
|
346
|
+
isListenerTuple,
|
|
347
|
+
isQueueableListener,
|
|
348
|
+
queueOptionsOf
|
|
349
|
+
};
|
|
350
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../CallQueuedListener.ts","../errors.ts","../discover.ts","../facade.ts","../EventServiceProvider.ts","../Dispatcher.ts","../listeners.ts","../queueable.ts"],"sourcesContent":["import type { Job } from '@orieljs/contracts'\nimport { ClassRegistry } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport { InvalidListenerError } from './errors'\n\nconst SHOULD_QUEUE = Symbol.for('oriel:bus.shouldQueue')\n\ntype ListenerMembers = Record<string, ((...args: unknown[]) => unknown) | undefined>\n\n/**\n * Wraps a queued listener call as a job (Laravel's CallQueuedListener). Always queueable: Dispatcher only ever\n * builds one after it already decided the wrapped listener wants queueing, so this wrapper's own queueability is\n * unconditional — set on its prototype below — unlike the structural, opt-in check `isQueueableListener()` runs on\n * the wrapped listener itself. Forwards `failed()`, `displayName()`, `retryUntil()` and `middleware()` to a fresh\n * instance of the wrapped listener (the Queue/Bus protocol), so a failing queued listener's own\n * `failed()` hook runs, `queue:failed`/`displayName()` shows the listener's own class name instead of\n * `CallQueuedListener`, and a listener's own `retryUntil()`/`middleware()` are honoured. `delay` (like `queue`,\n * `connection`, `tries`, `backoff`, `timeout`) is a plain field, copied by `Dispatcher.queue()` from\n * `queueOptionsOf()` — never a method — so it needs no forwarding here.\n */\nexport class CallQueuedListener implements Job {\n connection?: string\n queue?: string\n delay?: number\n tries?: number\n backoff?: number | number[]\n timeout?: number\n\n constructor(\n public readonly listenerClass: string,\n public readonly method: string,\n public readonly data: unknown[],\n ) {}\n\n /** A fresh listener instance, resolved through the container (never called with constructor arguments — DI only). */\n private resolve(): ListenerMembers {\n const registry = inject(ClassRegistry)\n const cls = registry.resolve(this.listenerClass)\n return inject(cls) as unknown as ListenerMembers\n }\n\n async handle(): Promise<void> {\n const instance = this.resolve()\n const method = instance[this.method]\n if (typeof method !== 'function') throw new InvalidListenerError(this.listenerClass)\n await method.apply(instance, this.data)\n }\n\n async failed(error: unknown): Promise<void> {\n await this.resolve().failed?.(...this.data, error)\n }\n\n displayName(): string {\n return this.listenerClass\n }\n\n retryUntil(): unknown {\n return this.resolve().retryUntil?.()\n }\n\n middleware(): unknown[] {\n return (this.resolve().middleware?.() as unknown[] | undefined) ?? []\n }\n}\n;(CallQueuedListener.prototype as unknown as Record<symbol, boolean>)[SHOULD_QUEUE] = true\n","import type { OrielError } from '@orieljs/contracts'\n\nexport class InvalidListenerError extends Error implements OrielError {\n readonly kind = 'Server' as const\n override readonly name = 'InvalidListenerError'\n constructor(event: string) {\n super(\n `The listener registered for [${event}] is not a function, a class with a handle() method, ` +\n `or a [Class, 'method'] tuple.`,\n )\n }\n}\n\nexport class EventsNeedBusDispatcherError extends Error implements OrielError {\n readonly kind = 'Server' as const\n override readonly name = 'EventsNeedBusDispatcherError'\n constructor(listenerName: string) {\n super(`[${listenerName}] is a queued listener, but no BusDispatcher is bound. Register the BusServiceProvider.`)\n }\n}\n\nexport class EventsNeedClassRegistryError extends Error implements OrielError {\n readonly kind = 'Server' as const\n override readonly name = 'EventsNeedClassRegistryError'\n constructor(listenerName: string) {\n super(`[${listenerName}] is a queued listener, but no ClassRegistry is bound.`)\n }\n}\n","import { existsSync, readdirSync, statSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport type { Class, ClassRegistry, EventDispatcher } from '@orieljs/contracts'\n\nconst EXTENSIONS = ['.ts', '.js', '.mts', '.mjs']\n\nfunction files(directory: string): string[] {\n const found: string[] = []\n for (const entry of readdirSync(directory).sort()) {\n const path = join(directory, entry)\n if (statSync(path).isDirectory()) found.push(...files(path))\n else if (EXTENSIONS.some((extension) => entry.endsWith(extension)) && !entry.endsWith('.d.ts')) found.push(path)\n }\n return found\n}\n\ntype DiscoverableListener = Class<{ handle(...args: unknown[]): unknown }> & {\n listensTo: Class<unknown> | string | Array<Class<unknown> | string>\n}\n\n/**\n * A discoverable listener class: has a handle() method (any listener class does) and a static `listensTo` field\n * naming the event(s) it handles. TS erases parameter types at runtime, so — unlike Laravel's reflection on\n * handle()'s parameter type — Oriel listeners declare what they listen to explicitly:\n * export class SendWelcomeEmail {\n * static listensTo = UserRegistered // a class, a string, or an array of either\n * async handle(event: UserRegistered) { ... }\n * }\n * Any other export (a helper function, a plain type) is silently skipped, not every export in a listener file is\n * necessarily a listener.\n */\nconst isDiscoverableListener = (value: unknown): value is DiscoverableListener =>\n typeof value === 'function' &&\n typeof (value.prototype as { handle?: unknown } | undefined)?.handle === 'function' &&\n 'listensTo' in value\n\n/** Classes already `listen()`ed by discovery itself, per dispatcher — so re-running discovery is a no-op. */\nconst discoveredByDispatcher = new WeakMap<EventDispatcher, WeakSet<Class<unknown>>>()\n\n/**\n * Imports every module under `directory` (recursively), registers each discoverable listener class into `registry`\n * and calls `dispatcher.listen()` for it. Returns the registered names. Safe to call more than once for the same\n * `dispatcher` (a worker process re-importing the same files re-registers each class in `ClassRegistry` — already\n * idempotent — but is not `listen()`ed again).\n */\nexport async function discoverListeners(directory: string, dispatcher: EventDispatcher, registry: ClassRegistry): Promise<string[]> {\n if (!existsSync(directory)) return []\n let discovered = discoveredByDispatcher.get(dispatcher)\n if (!discovered) {\n discovered = new WeakSet()\n discoveredByDispatcher.set(dispatcher, discovered)\n }\n const names: string[] = []\n for (const file of files(directory)) {\n const module = (await import(pathToFileURL(file).href)) as Record<string, unknown>\n for (const exported of Object.values(module)) {\n if (!isDiscoverableListener(exported)) continue\n names.push(registry.nameOf(exported) ?? registry.register(exported))\n if (discovered.has(exported)) continue\n discovered.add(exported)\n const events = Array.isArray(exported.listensTo) ? exported.listensTo : [exported.listensTo]\n dispatcher.listen(events as never, exported as never)\n }\n }\n return names\n}\n","import type { EventDispatcher } from '@orieljs/contracts'\nimport { EventDispatcher as EventDispatcherToken } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport { facade } from '@orieljs/support'\n\nexport const Event = facade<EventDispatcher>(EventDispatcherToken)\n\n/** Laravel's event() helper: dispatches through the current container's EventDispatcher. */\nexport function event(eventValue: object | string, payload?: unknown[]): Promise<unknown[]> {\n return inject(EventDispatcherToken).dispatch(eventValue, payload)\n}\n","import {\n ClassRegistry,\n ConfigRepository,\n ConsoleKernel,\n EventDispatcher,\n type Class,\n type CommandContext,\n type Listener,\n} from '@orieljs/contracts'\nimport { ServiceProvider } from '@orieljs/support'\nimport { CallQueuedListener } from './CallQueuedListener'\nimport { discoverListeners } from './discover'\nimport { Dispatcher } from './Dispatcher'\nimport type { ListenerTuple } from './listeners'\n\n/**\n * `config('events.listen')`'s shape. Laravel's EventServiceProvider::$listen is a PHP array keyed by FQCN string\n * constants; TypeScript object keys must be strings, so a real class reference can't be a plain-object key without\n * losing type safety. This is a list of [event, listeners] pairs instead, so either side can be a class reference:\n * [[UserRegistered, [SendWelcomeEmail]], ['order.shipped', [NotifyWarehouse]]]\n */\nexport type EventListenMap = Array<[Class<unknown> | string, Array<Listener<unknown> | ListenerTuple<unknown>>]>\n\nexport class EventServiceProvider extends ServiceProvider {\n override register(): void {\n this.mergeConfigFrom({ discover: true, listen: [] as EventListenMap }, 'events')\n this.app.singleton(EventDispatcher, (container) => new Dispatcher(container))\n // Registered here, not in boot() — a queued listener firing during an earlier provider's boot() must never\n // auto-register CallQueuedListener under the plain 'CallQueuedListener' name before this explicit, namespaced\n // registration runs.\n this.app.make(ClassRegistry).register(CallQueuedListener, 'Events.CallQueuedListener')\n }\n\n override async boot(): Promise<void> {\n const dispatcher = this.app.make(EventDispatcher) as Dispatcher\n const registry = this.app.make(ClassRegistry)\n\n const config = this.app.make(ConfigRepository)\n for (const [event, listeners] of config.get<EventListenMap>('events.listen', [])) {\n for (const listener of listeners) dispatcher.listen(event as never, listener as never)\n }\n\n if (config.get<boolean>('events.discover', true)) {\n await discoverListeners(this.app.appPath('Listeners'), dispatcher, registry)\n }\n\n if (this.app.bound(ConsoleKernel)) {\n const kernel = this.app.make(ConsoleKernel)\n kernel\n .command('event:list', function (this: CommandContext) {\n const rows = dispatcher.registeredEvents()\n if (rows.length === 0) {\n this.line('No events are registered.')\n return 0\n }\n for (const row of rows) this.line(` ${row.event} ${row.listeners} ${row.listeners === 1 ? 'listener' : 'listeners'}`)\n return 0\n })\n .purpose(\"List the application's events and listeners\")\n }\n }\n}\n","import type { Class, Container, EventDispatcher, ListenerClass } from '@orieljs/contracts'\nimport { BusDispatcher, ClassRegistry } from '@orieljs/contracts'\nimport { Str } from '@orieljs/support'\nimport { CallQueuedListener } from './CallQueuedListener'\nimport { EventsNeedBusDispatcherError, EventsNeedClassRegistryError, InvalidListenerError } from './errors'\nimport { isListenerClass, isListenerTuple, type ListenerTuple } from './listeners'\nimport { isQueueableListener, queueOptionsOf } from './queueable'\n\nexport type EventKey = Class<unknown> | string\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- a listener closure's parameter list is arbitrary\ntype Registration<E> = ((...args: any[]) => unknown) | ListenerClass<E> | ListenerTuple<E>\n\nconst nameOf = (key: EventKey): string => (typeof key === 'string' ? key : (key as unknown as { name: string }).name)\n\n/**\n * Laravel's Illuminate\\Events\\Dispatcher, on top of Oriel's Container. dispatch() and until() share run(), which\n * mirrors Dispatcher::dispatch($event, $payload, $halt): halt=true (until()) returns the first non-undefined\n * response and stops; either way, a literal `false` response stops the remaining listeners.\n */\nexport class Dispatcher implements EventDispatcher {\n private readonly listeners = new Map<EventKey, Array<Registration<unknown>>>()\n\n constructor(protected readonly container: Container) {}\n\n listen<E>(events: Class<E> | string | Array<Class<E> | string>, listener: Registration<E>): void {\n if (typeof listener !== 'function' && !isListenerTuple(listener)) {\n const label = Array.isArray(events) ? events.map((e) => nameOf(e as EventKey)).join(', ') : nameOf(events as EventKey)\n throw new InvalidListenerError(label)\n }\n for (const event of (Array.isArray(events) ? events : [events]) as EventKey[]) {\n const list = this.listeners.get(event) ?? []\n list.push(listener as Registration<unknown>)\n this.listeners.set(event, list)\n }\n }\n\n hasListeners(event: Class<unknown> | string): boolean {\n if ((this.listeners.get(event)?.length ?? 0) > 0) return true\n return typeof event === 'string' && this.wildcardPatternsFor(event).some((pattern) => (this.listeners.get(pattern)?.length ?? 0) > 0)\n }\n\n forget(event: Class<unknown> | string): void {\n this.listeners.delete(event)\n }\n\n /** Introspection for the event:list command. Not part of the EventDispatcher contract. */\n registeredEvents(): Array<{ event: string; listeners: number }> {\n const rows: Array<{ event: string; listeners: number }> = []\n for (const [key, list] of this.listeners) rows.push({ event: nameOf(key), listeners: list.length })\n return rows.sort((a, b) => a.event.localeCompare(b.event))\n }\n\n subscribe(subscriber: Class<{ subscribe(events: EventDispatcher): void }>): void {\n const instance = this.container.make(subscriber) as { subscribe: (events: EventDispatcher) => unknown }\n const result = instance.subscribe(this)\n if (!result || typeof result !== 'object') return\n for (const [event, methods] of Object.entries(result as Record<string, string | string[]>)) {\n for (const method of Array.isArray(methods) ? methods : [methods]) {\n this.listen(event, [subscriber, method] as ListenerTuple<unknown>)\n }\n }\n }\n\n async dispatch(event: object | string, payload: unknown[] = []): Promise<unknown[]> {\n return (await this.run(event, payload, false)) as unknown[]\n }\n\n /** Stops at the first listener whose response isn't undefined, and returns it. */\n async until(event: object | string, payload: unknown[] = []): Promise<unknown> {\n return this.run(event, payload, true)\n }\n\n private async run(event: object | string, payload: unknown[], halt: boolean): Promise<unknown> {\n const isString = typeof event === 'string'\n const key: EventKey = isString ? event : (event.constructor as Class<unknown>)\n const args: unknown[] = isString ? payload : [event]\n const responses: unknown[] = []\n for (const { listener, wildcard } of this.listenersFor(key)) {\n const response = await this.call(listener, key, args, wildcard)\n if (halt && response !== undefined) return response\n if (response === false) break\n responses.push(response)\n }\n return halt ? undefined : responses\n }\n\n /**\n * Exact-key listeners first, in registration order, then every matching wildcard pattern's listeners. Both the\n * exact-key list and the set of matching wildcard patterns (and their listeners) are snapshotted into plain\n * arrays before the first listener runs, so a listener that registers another listener for this same event (or\n * a new matching wildcard) while running does not also run in this dispatch — it only runs starting with the\n * next one, like Laravel.\n */\n protected *listenersFor(key: EventKey): Iterable<{ listener: Registration<unknown>; wildcard: boolean }> {\n const exact = [...(this.listeners.get(key) ?? [])]\n const wildcardLists = typeof key === 'string' ? this.wildcardPatternsFor(key).map((pattern) => [...(this.listeners.get(pattern) ?? [])]) : []\n for (const listener of exact) yield { listener, wildcard: false }\n for (const list of wildcardLists) {\n for (const listener of list) yield { listener, wildcard: true }\n }\n }\n\n private wildcardPatternsFor(event: string): string[] {\n const patterns: string[] = []\n for (const key of this.listeners.keys()) {\n if (typeof key === 'string' && key !== event && key.includes('*') && Str.is(key, event)) patterns.push(key)\n }\n return patterns\n }\n\n /**\n * Instantiates class/tuple listeners through the container (listener classes have DI-only constructors, so this\n * is cheap and side-effect-free even when the listener turns out to be queued), then queues instead of invoking\n * inline when the constructed instance opts into queueing (the decision reads the instance, matching the\n * Queue/Bus protocol's own isQueueable(), not just the class's static members).\n */\n protected async call(listener: Registration<unknown>, key: EventKey, args: unknown[], wildcard: boolean): Promise<unknown> {\n const callArgs = wildcard ? [nameOf(key), args] : args\n if (isListenerTuple(listener)) {\n const [cls, method] = listener\n const instance = this.container.make(cls) as Record<string, unknown>\n if (isQueueableListener(cls, instance)) return this.queue(cls, instance, method, callArgs)\n return (instance[method] as (...a: unknown[]) => unknown)(...callArgs)\n }\n if (isListenerClass(listener)) {\n const instance = this.container.make(listener) as Record<string, unknown> & { handle: (...a: unknown[]) => unknown }\n if (isQueueableListener(listener, instance)) return this.queue(listener, instance, 'handle', callArgs)\n return instance.handle(...callArgs)\n }\n return (listener as (...a: unknown[]) => unknown)(...callArgs)\n }\n\n /**\n * Wraps the call as a CallQueuedListener job and dispatches it through BusDispatcher. Never runs inline; the\n * already-constructed `instance` is used only to read its ShouldQueue options (queueOptionsOf), never to run\n * handle()/method() — the worker builds its own instance from the registered class name.\n */\n private async queue(cls: Class<unknown>, instance: object, method: string, data: unknown[]): Promise<undefined> {\n const name = nameOf(cls)\n if (!this.container.bound(BusDispatcher)) throw new EventsNeedBusDispatcherError(name)\n if (!this.container.bound(ClassRegistry)) throw new EventsNeedClassRegistryError(name)\n const registry = this.container.make(ClassRegistry)\n const registeredName = registry.nameOf(cls) ?? registry.register(cls)\n const job = new CallQueuedListener(registeredName, method, data)\n Object.assign(job, queueOptionsOf(cls, instance))\n await this.container.make(BusDispatcher).dispatch(job)\n return undefined\n }\n}\n","import type { Class } from '@orieljs/contracts'\n\n/** A [ListenerClass, methodName] pair, e.g. [Subscriber, 'onUserRegistered']. */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars -- E documents the event type the method handles\nexport type ListenerTuple<E> = [Class<object>, string]\n\nexport function isListenerTuple(value: unknown): value is ListenerTuple<unknown> {\n return Array.isArray(value) && value.length === 2 && typeof value[0] === 'function' && typeof value[1] === 'string'\n}\n\n/** A class with a handle() method on its prototype, as opposed to a plain closure listener. */\nexport function isListenerClass(value: unknown): value is Class<{ handle(...args: unknown[]): unknown }> {\n return typeof value === 'function' && typeof (value.prototype as { handle?: unknown } | undefined)?.handle === 'function'\n}\n","import type { Class } from '@orieljs/contracts'\n\n/** The same Symbol.for key Bus's real `Queueable` mixin sets on job prototypes (the Queue/Bus protocol). */\nconst SHOULD_QUEUE = Symbol.for('oriel:bus.shouldQueue')\n\nconst QUEUE_OPTION_KEYS = ['connection', 'queue', 'delay', 'tries', 'backoff', 'timeout'] as const\ntype QueueOptionKey = (typeof QUEUE_OPTION_KEYS)[number]\n\n/**\n * Whether a listener opts into queueing. `implements ShouldQueue` leaves no runtime trace, so this is structural,\n * like the Queue/Bus protocol's own `isQueueable(job)`: the marker, or an option, or a `uniqueId`/`retryUntil`\n * method. Unlike a job (already an instance by the time Bus sees it), a listener is a *class* registered with\n * `listen()`, so Events must build it first — `this.container.make(cls)` is cheap and side-effect-free for listener\n * classes, which have DI-only constructors — and then applies the protocol rule to that instance: the marker\n * (readable off the instance through the prototype chain), an **instance** option field with a defined value, or an\n * instance `uniqueId`/`retryUntil` method — the same fields Mail's and Notifications' `isQueueableMailable`/\n * equivalent read. A **static** field or method on the class counts too, as an extra on top of the protocol rule\n * (not instead of it), so an existing `static queue = '...'` listener still works.\n */\nexport function isQueueableListener(cls: Class<unknown>, instance: object): boolean {\n const members = instance as Record<PropertyKey, unknown>\n if (members[SHOULD_QUEUE] === true) return true\n const statics = cls as unknown as Record<string, unknown>\n if (QUEUE_OPTION_KEYS.some((key) => members[key] !== undefined || statics[key] !== undefined)) return true\n // Laravel doesn't support ShouldBeUnique on listeners: a `uniqueId`/`retryUntil` method only marks the listener as\n // queued here — it is never forwarded to the wrapper job (see queueOptionsOf and CallQueuedListener.retryUntil).\n return (\n typeof members.uniqueId === 'function' ||\n typeof members.retryUntil === 'function' ||\n typeof statics.uniqueId === 'function' ||\n typeof statics.retryUntil === 'function'\n )\n}\n\nconst isString = (value: unknown): value is string => typeof value === 'string'\nconst isNumber = (value: unknown): value is number => typeof value === 'number'\nconst isNumberOrNumberArray = (value: unknown): value is number | number[] =>\n isNumber(value) || (Array.isArray(value) && value.every(isNumber))\n\n/** Each option key's expected shape, so a method's return value (or a mistyped field) never reaches the job untyped. */\nconst VALIDATORS: Record<QueueOptionKey, (value: unknown) => boolean> = {\n connection: isString,\n queue: isString,\n delay: isNumber,\n tries: isNumber,\n timeout: isNumber,\n backoff: isNumberOrNumberArray,\n}\n\n/**\n * Copies the instance's (falling back to the class's static) ShouldQueue options onto the wrapper job. Laravel lets\n * these be methods (`backoff() { return [1, 5] }`) as well as plain fields — a method value is called (on the\n * instance, or on the class for a static) before use, never copied as-is, since Bus's serializer rejects functions.\n * Anything that isn't the expected type for its key (after resolving a method) is dropped rather than forwarded.\n */\nexport function queueOptionsOf(cls: Class<unknown>, instance: object): Partial<Record<QueueOptionKey, unknown>> {\n const statics = cls as unknown as Record<string, unknown>\n const members = instance as Record<string, unknown>\n const options: Partial<Record<QueueOptionKey, unknown>> = {}\n for (const key of QUEUE_OPTION_KEYS) {\n let value: unknown\n let onInstance = true\n if (members[key] !== undefined) value = members[key]\n else if (statics[key] !== undefined) {\n value = statics[key]\n onInstance = false\n } else continue\n if (typeof value === 'function') value = onInstance ? value.call(instance) : value.call(cls)\n if (VALIDATORS[key](value)) options[key] = value\n }\n return options\n}\n"],"mappings":";AACA,SAAS,qBAAqB;AAC9B,SAAS,cAAc;;;ACAhB,IAAM,uBAAN,cAAmC,MAA4B;AAAA,EAC3D,OAAO;AAAA,EACE,OAAO;AAAA,EACzB,YAAYA,QAAe;AACzB;AAAA,MACE,gCAAgCA,MAAK;AAAA,IAEvC;AAAA,EACF;AACF;AAEO,IAAM,+BAAN,cAA2C,MAA4B;AAAA,EACnE,OAAO;AAAA,EACE,OAAO;AAAA,EACzB,YAAY,cAAsB;AAChC,UAAM,IAAI,YAAY,yFAAyF;AAAA,EACjH;AACF;AAEO,IAAM,+BAAN,cAA2C,MAA4B;AAAA,EACnE,OAAO;AAAA,EACE,OAAO;AAAA,EACzB,YAAY,cAAsB;AAChC,UAAM,IAAI,YAAY,wDAAwD;AAAA,EAChF;AACF;;;ADtBA,IAAM,eAAe,uBAAO,IAAI,uBAAuB;AAehD,IAAM,qBAAN,MAAwC;AAAA,EAQ7C,YACkB,eACA,QACA,MAChB;AAHgB;AACA;AACA;AAAA,EACf;AAAA,EAHe;AAAA,EACA;AAAA,EACA;AAAA,EAVlB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EASQ,UAA2B;AACjC,UAAM,WAAW,OAAO,aAAa;AACrC,UAAM,MAAM,SAAS,QAAQ,KAAK,aAAa;AAC/C,WAAO,OAAO,GAAG;AAAA,EACnB;AAAA,EAEA,MAAM,SAAwB;AAC5B,UAAM,WAAW,KAAK,QAAQ;AAC9B,UAAM,SAAS,SAAS,KAAK,MAAM;AACnC,QAAI,OAAO,WAAW,WAAY,OAAM,IAAI,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AAK,WAAW,GAAG;AACrB,eAAK,KAAK,2BAA2B;AACrC,iBAAO;AAAA,QACT;AACA,mBAAW,OAAO,KAAM,MAAK,KAAK,KAAK,IAAI,KAAK,IAAI,IAAI,SAAS,IAAI,IAAI,cAAc,IAAI,aAAa,WAAW,EAAE;AACrH,eAAO;AAAA,MACT,CAAC,EACA,QAAQ,6CAA6C;AAAA,IAC1D;AAAA,EACF;AACF;","names":["event","inject","ClassRegistry","ClassRegistry","SHOULD_QUEUE","event","isString","ClassRegistry","ClassRegistry","event"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@orieljs/events",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "The Oriel Events component.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/orieljs/framework.git",
|
|
11
|
+
"directory": "src/Oriel/Events"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=22"
|
|
15
|
+
},
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"NOTICE"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@orieljs/contracts": "0.1.0-alpha.1",
|
|
33
|
+
"@orieljs/container": "0.1.0-alpha.1",
|
|
34
|
+
"@orieljs/support": "0.1.0-alpha.1"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup && node ../../../scripts/copy-license.mjs"
|
|
38
|
+
}
|
|
39
|
+
}
|