@orieljs/framework 0.1.0-alpha.5 → 0.1.0-alpha.7
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/NOTICE +7 -0
- package/README.md +10 -1
- package/TRADEMARKS.md +33 -0
- package/dist/{chunk-WNJP46B7.js → chunk-4MWG3B7G.js} +1785 -626
- package/dist/chunk-4MWG3B7G.js.map +1 -0
- package/dist/chunk-7ZQZYDOC.js +3253 -0
- package/dist/chunk-7ZQZYDOC.js.map +1 -0
- package/dist/{chunk-BSQKOLSK.js → chunk-GVNLZZTN.js} +1 -1
- package/dist/chunk-GVNLZZTN.js.map +1 -0
- package/dist/{chunk-A5XRLEWM.js → chunk-VOYW3R5J.js} +4 -4
- package/dist/chunk-VOYW3R5J.js.map +1 -0
- package/dist/contracts.d.ts +535 -17
- package/dist/contracts.js +1 -1
- package/dist/index.d-WQpfdIbG.d.ts +630 -0
- package/dist/index.d.ts +2202 -5952
- package/dist/index.js +4900 -944
- package/dist/index.js.map +1 -1
- package/dist/{jsx-runtime-WKTl3EEw.d.ts → jsx-runtime-6um4Mwfb.d.ts} +97 -51
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.js +3 -3
- package/dist/{testing-BErengYY.d.ts → testing-CKwfWJGn.d.ts} +313 -994
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +19 -5
- package/docs/authentication.md +487 -0
- package/docs/authorization.md +435 -0
- package/docs/cache.md +647 -0
- package/docs/collections.md +2270 -0
- package/docs/configuration.md +334 -0
- package/docs/console.md +651 -0
- package/docs/container.md +430 -0
- package/docs/controllers.md +406 -0
- package/docs/csrf.md +126 -0
- package/docs/database-testing.md +144 -0
- package/docs/database.md +236 -0
- package/docs/deployment.md +276 -0
- package/docs/eloquent-collections.md +218 -0
- package/docs/eloquent-factories.md +255 -0
- package/docs/eloquent-mutators.md +254 -0
- package/docs/eloquent-observers.md +145 -0
- package/docs/eloquent-relationships.md +557 -0
- package/docs/eloquent.md +494 -0
- package/docs/encryption.md +104 -0
- package/docs/errors.md +318 -0
- package/docs/events.md +336 -0
- package/docs/facades.md +278 -0
- package/docs/hashing.md +118 -0
- package/docs/helpers.md +1281 -0
- package/docs/http-tests.md +386 -0
- package/docs/inertia.md +485 -0
- package/docs/installation.md +209 -0
- package/docs/lifecycle.md +234 -0
- package/docs/live-tests.md +226 -0
- package/docs/live.md +910 -0
- package/docs/logging.md +255 -0
- package/docs/mail.md +619 -0
- package/docs/middleware.md +384 -0
- package/docs/migrations.md +416 -0
- package/docs/mocking.md +264 -0
- package/docs/navigation.json +273 -0
- package/docs/notifications.md +225 -0
- package/docs/pagination.md +247 -0
- package/docs/passwords.md +207 -0
- package/docs/providers.md +187 -0
- package/docs/queries.md +600 -0
- package/docs/queues.md +330 -0
- package/docs/requests.md +533 -0
- package/docs/responses.md +444 -0
- package/docs/routing.md +738 -0
- package/docs/scheduling.md +277 -0
- package/docs/seeding.md +122 -0
- package/docs/session.md +409 -0
- package/docs/starter-kits.md +396 -0
- package/docs/storage.md +192 -0
- package/docs/structure.md +264 -0
- package/docs/testing.md +165 -0
- package/docs/time-travel.md +138 -0
- package/docs/validation.md +1792 -0
- package/docs/verification.md +152 -0
- package/docs/views.md +566 -0
- package/docs/vite.md +322 -0
- package/package.json +34 -32
- package/dist/chunk-A5XRLEWM.js.map +0 -1
- package/dist/chunk-BSQKOLSK.js.map +0 -1
- package/dist/chunk-PM5YTG57.js +0 -880
- package/dist/chunk-PM5YTG57.js.map +0 -1
- package/dist/chunk-WNJP46B7.js.map +0 -1
- package/dist/index.d-DOlTeG-8.d.ts +0 -99
|
@@ -1,611 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { S as ServiceProvider$
|
|
1
|
+
import { BusDispatcher, Job, PendingBatchOptions, Class, PendingChain, PendingBatch, Batch, EventDispatcher, Listener, MailManager, Mailable, Address, MailRecipient, Mailer, PendingMail, SentMessage, MailTransport, NotificationDispatcher, Notifiable, Notification, NotificationChannel, QueueManager, QueuePayload, Queue, QueueJob, FilesystemManager, Filesystem, PutOptions, UploadedFile, Application, Session, View, Authenticatable, Container, AuthFactory, InertiaPage, ServiceProvider, ServiceProviderClass, DatabaseManager, ModelInstance, Row, Encrypter, Token, ExceptionHandler, ViewFactory, RouteName, RouteArguments, Rules, InferValidatedType, MessageBag, LiveSnapshot, LiveEffects, OrielError, ErrorKind, Htmlable, LiveManager, HttpRequest, LiveUpdateRequest, LiveUpdateResponse, MiddlewareClass, Router } from './contracts.js';
|
|
2
|
+
import { S as ServiceProvider$1 } from './index.d-WQpfdIbG.js';
|
|
3
3
|
|
|
4
|
-
/** A
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/** Register an existing object as a shared instance. Returns it. On a scope it stays local to that scope. */
|
|
23
|
-
instance<T>(abstract: Abstract$1<T>, instance: T): T;
|
|
24
|
-
/** Resolve. Unbound classes are constructed with `new Class()`. Unbound tokens throw BindingResolutionError. */
|
|
25
|
-
make<T>(abstract: Abstract$1<T>): T;
|
|
26
|
-
bound(abstract: Abstract$1<unknown>): boolean;
|
|
27
|
-
resolved(abstract: Abstract$1<unknown>): boolean;
|
|
28
|
-
/** Decorate or replace an instance each time it's resolved (applied before resolving callbacks). Root only; throws on a scope. */
|
|
29
|
-
extend<T>(abstract: Abstract$1<T>, extender: (instance: T, container: Container$1) => T): void;
|
|
30
|
-
/** Called after each resolution of the abstract. Root only; throws on a scope. */
|
|
31
|
-
resolving<T>(abstract: Abstract$1<T>, callback: (instance: T, container: Container$1) => void): void;
|
|
32
|
-
forgetInstance(abstract: Abstract$1<unknown>): void;
|
|
33
|
-
/** A child container: shares bindings and singletons with its parent, and has its own scoped instances. Bindings can't be registered on it. */
|
|
34
|
-
createScope(): Container$1;
|
|
35
|
-
/** Run fn with this container as the "current" one for inject(), helpers and facades (AsyncLocalStorage). */
|
|
36
|
-
run<R>(fn: () => R): R;
|
|
37
|
-
}
|
|
38
|
-
declare const Container$1: Token$1<Container$1>;
|
|
39
|
-
|
|
40
|
-
/** The session of the current request (scoped). Loaded and saved by the StartSession middleware. */
|
|
41
|
-
interface Session$1 {
|
|
42
|
-
getId(): string;
|
|
43
|
-
start(): Promise<void>;
|
|
44
|
-
save(): Promise<void>;
|
|
45
|
-
all(): Record<string, unknown>;
|
|
46
|
-
has(key: string): boolean;
|
|
47
|
-
get<T = unknown>(key: string, defaultValue?: T): T;
|
|
48
|
-
put(key: string | Record<string, unknown>, value?: unknown): void;
|
|
49
|
-
push(key: string, value: unknown): void;
|
|
50
|
-
pull<T = unknown>(key: string, defaultValue?: T): T;
|
|
51
|
-
forget(...keys: string[]): void;
|
|
52
|
-
flush(): void;
|
|
53
|
-
flash(key: string, value: unknown): void;
|
|
54
|
-
now(key: string, value: unknown): void;
|
|
55
|
-
reflash(): void;
|
|
56
|
-
keep(...keys: string[]): void;
|
|
57
|
-
getOldInput<T = unknown>(key?: string, defaultValue?: T): T;
|
|
58
|
-
flashInput(input: Record<string, unknown>): void;
|
|
59
|
-
token(): string;
|
|
60
|
-
regenerateToken(): void;
|
|
61
|
-
regenerate(destroy?: boolean): Promise<void>;
|
|
62
|
-
invalidate(): Promise<void>;
|
|
63
|
-
previousUrl(): string | undefined;
|
|
64
|
-
setPreviousUrl(url: string): void;
|
|
65
|
-
}
|
|
66
|
-
declare const Session$1: Token$2<Session$1>;
|
|
67
|
-
interface UploadedFile$1 {
|
|
68
|
-
readonly clientName: string;
|
|
69
|
-
readonly mimeType: string;
|
|
70
|
-
readonly size: number;
|
|
71
|
-
extension(): string;
|
|
72
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
73
|
-
/** Stores on a Filesystem disk. Returns the stored path. */
|
|
74
|
-
store(directory: string, disk?: string): Promise<string>;
|
|
75
|
-
storeAs(directory: string, name: string, disk?: string): Promise<string>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
interface ServiceProvider$2 {
|
|
79
|
-
/** Bind things into the container. Synchronous. Don't resolve other services here. */
|
|
80
|
-
register?(): void;
|
|
81
|
-
/** Runs after every provider is registered. May be async (e.g. importing route files). */
|
|
82
|
-
boot?(): void | Promise<void>;
|
|
83
|
-
}
|
|
84
|
-
type ServiceProviderClass$1 = new (app: Application$1) => ServiceProvider$2;
|
|
85
|
-
interface Application$1 extends Container$1 {
|
|
86
|
-
readonly version: string;
|
|
87
|
-
basePath(path?: string): string;
|
|
88
|
-
appPath(path?: string): string;
|
|
89
|
-
bootstrapPath(path?: string): string;
|
|
90
|
-
configPath(path?: string): string;
|
|
91
|
-
databasePath(path?: string): string;
|
|
92
|
-
publicPath(path?: string): string;
|
|
93
|
-
resourcePath(path?: string): string;
|
|
94
|
-
storagePath(path?: string): string;
|
|
95
|
-
/** With no args returns the environment name. With args returns whether it matches any of them. */
|
|
96
|
-
environment(): string;
|
|
97
|
-
environment(...environments: string[]): boolean;
|
|
98
|
-
isProduction(): boolean;
|
|
99
|
-
isLocal(): boolean;
|
|
100
|
-
runningInConsole(): boolean;
|
|
101
|
-
/** Mark the app as running in the console (the CLI entry point calls this). Defaults to true. */
|
|
102
|
-
setRunningInConsole(value?: boolean): void;
|
|
103
|
-
runningUnitTests(): boolean;
|
|
104
|
-
/** Registers the provider. If the app is already booted, the provider is booted immediately. */
|
|
105
|
-
register(provider: ServiceProvider$2 | ServiceProviderClass$1): Promise<ServiceProvider$2>;
|
|
106
|
-
getProviders(): ServiceProvider$2[];
|
|
107
|
-
boot(): Promise<void>;
|
|
108
|
-
isBooted(): boolean;
|
|
109
|
-
booting(callback: (app: Application$1) => void | Promise<void>): void;
|
|
110
|
-
booted(callback: (app: Application$1) => void | Promise<void>): void;
|
|
111
|
-
/** Handle one HTTP request in a fresh request scope via the bound HttpKernel. */
|
|
112
|
-
handle(request: Request): Promise<Response>;
|
|
113
|
-
/** Register a callback that terminate() runs, in registration order. */
|
|
114
|
-
terminating(callback: () => void | Promise<void>): void;
|
|
115
|
-
terminate(): Promise<void>;
|
|
116
|
-
}
|
|
117
|
-
declare const Application$1: Token$2<Application$1>;
|
|
118
|
-
interface ExceptionHandler {
|
|
119
|
-
report(error: unknown): Promise<void>;
|
|
120
|
-
shouldReport(error: unknown): boolean;
|
|
121
|
-
/** `request` is the scoped HttpRequest (Contracts/Http) when available, else the raw Request. */
|
|
122
|
-
render(request: unknown, error: unknown): Promise<Response>;
|
|
123
|
-
}
|
|
124
|
-
declare const ExceptionHandler: Token$2<ExceptionHandler>;
|
|
125
|
-
|
|
126
|
-
interface Arrayable<T = unknown> {
|
|
127
|
-
toArray(): T;
|
|
128
|
-
}
|
|
129
|
-
interface Htmlable$1 {
|
|
130
|
-
toHtml(): string;
|
|
131
|
-
}
|
|
132
|
-
/** The minimal collection surface contracts rely on (implemented by @orieljs/collections). */
|
|
133
|
-
interface Enumerable<T> extends Iterable<T>, Arrayable<unknown[]> {
|
|
134
|
-
all(): T[];
|
|
135
|
-
count(): number;
|
|
136
|
-
isEmpty(): boolean;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
interface Encrypter {
|
|
140
|
-
/** JSON-serializes unless serialize=false (then value must be a string). AES-256-GCM, keyed by APP_KEY. */
|
|
141
|
-
encrypt(value: unknown, serialize?: boolean): string;
|
|
142
|
-
decrypt<T = unknown>(payload: string, unserialize?: boolean): T;
|
|
143
|
-
encryptString(value: string): string;
|
|
144
|
-
decryptString(payload: string): string;
|
|
145
|
-
getKey(): Uint8Array;
|
|
146
|
-
}
|
|
147
|
-
declare const Encrypter: Token$2<Encrypter>;
|
|
148
|
-
|
|
149
|
-
interface View extends Htmlable$1 {
|
|
150
|
-
readonly name: string;
|
|
151
|
-
with(key: string | Record<string, unknown>, value?: unknown): this;
|
|
152
|
-
render(): Promise<string>;
|
|
153
|
-
}
|
|
154
|
-
/** Resolves 'posts.index' → resources/views/posts/index.tsx and renders it to HTML on the server. */
|
|
155
|
-
interface ViewFactory {
|
|
156
|
-
make(name: string, data?: Record<string, unknown>): View;
|
|
157
|
-
exists(name: string): boolean;
|
|
158
|
-
share(key: string | Record<string, unknown>, value?: unknown): void;
|
|
159
|
-
composer(views: string | string[], composer: (view: View) => void | Promise<void>): void;
|
|
160
|
-
/** Renders TSX (an element, a string, an Htmlable, a View, promises of them) to HTML, like Blade::render(). */
|
|
161
|
-
renderToString(node: unknown): Promise<string>;
|
|
162
|
-
}
|
|
163
|
-
declare const ViewFactory: Token$2<ViewFactory>;
|
|
164
|
-
|
|
165
|
-
type Operator = '=' | '!=' | '<>' | '<' | '<=' | '>' | '>=' | 'like' | 'not like' | 'ilike' | 'in' | 'not in';
|
|
166
|
-
type Row = Record<string, unknown>;
|
|
167
|
-
/** The minimal query surface other components rely on (Queue, Cache, Session, Validation, Notifications). */
|
|
168
|
-
interface QueryBuilder<T = Row> {
|
|
169
|
-
select(...columns: string[]): this;
|
|
170
|
-
where(column: string, value: unknown): this;
|
|
171
|
-
where(column: string, operator: Operator, value: unknown): this;
|
|
172
|
-
where(conditions: Row): this;
|
|
173
|
-
orWhere(column: string, value: unknown): this;
|
|
174
|
-
orWhere(column: string, operator: Operator, value: unknown): this;
|
|
175
|
-
whereIn(column: string, values: readonly unknown[]): this;
|
|
176
|
-
whereNotIn(column: string, values: readonly unknown[]): this;
|
|
177
|
-
whereNull(column: string): this;
|
|
178
|
-
whereNotNull(column: string): this;
|
|
179
|
-
orderBy(column: string, direction?: 'asc' | 'desc'): this;
|
|
180
|
-
limit(count: number): this;
|
|
181
|
-
offset(count: number): this;
|
|
182
|
-
lockForUpdate(): this;
|
|
183
|
-
get(): Promise<Enumerable<T>>;
|
|
184
|
-
first(): Promise<T | undefined>;
|
|
185
|
-
find(id: unknown): Promise<T | undefined>;
|
|
186
|
-
value<V = unknown>(column: string): Promise<V | undefined>;
|
|
187
|
-
pluck<V = unknown>(column: string): Promise<Enumerable<V>>;
|
|
188
|
-
count(): Promise<number>;
|
|
189
|
-
exists(): Promise<boolean>;
|
|
190
|
-
insert(values: Row | Row[]): Promise<void>;
|
|
191
|
-
/**
|
|
192
|
-
* Inserts rows, skipping any that violate a unique key instead of failing (Laravel's insertOrIgnore). Returns the
|
|
193
|
-
* number of rows inserted. Nothing is thrown for a duplicate, so a caller's transaction stays usable on Postgres.
|
|
194
|
-
*/
|
|
195
|
-
insertOrIgnore(values: Row | Row[]): Promise<number>;
|
|
196
|
-
insertGetId(values: Row, keyName?: string): Promise<number | string>;
|
|
197
|
-
update(values: Row): Promise<number>;
|
|
198
|
-
upsert(values: Row | Row[], uniqueBy: string[], update?: string[]): Promise<number>;
|
|
199
|
-
increment(column: string, amount?: number, extra?: Row): Promise<number>;
|
|
200
|
-
decrement(column: string, amount?: number, extra?: Row): Promise<number>;
|
|
201
|
-
delete(): Promise<number>;
|
|
202
|
-
}
|
|
203
|
-
type DriverName = 'pgsql' | 'mysql' | 'sqlite';
|
|
204
|
-
interface DatabaseConnection {
|
|
205
|
-
getName(): string;
|
|
206
|
-
getDriverName(): DriverName;
|
|
207
|
-
table<T = Row>(table: string): QueryBuilder<T>;
|
|
208
|
-
select<T = Row>(sql: string, bindings?: readonly unknown[]): Promise<T[]>;
|
|
209
|
-
statement(sql: string, bindings?: readonly unknown[]): Promise<void>;
|
|
210
|
-
/** Nested calls use savepoints. Rolls back if fn throws. */
|
|
211
|
-
transaction<R>(fn: (connection: DatabaseConnection) => Promise<R>): Promise<R>;
|
|
212
|
-
/**
|
|
213
|
-
* Start a transaction that stays open, for every caller of this connection, until commit()/rollBack().
|
|
214
|
-
* Nested calls use savepoints. Meant for test isolation (RefreshDatabase); app code uses transaction(fn).
|
|
215
|
-
*/
|
|
216
|
-
beginTransaction(): Promise<void>;
|
|
217
|
-
commit(): Promise<void>;
|
|
218
|
-
/** Rolls back the innermost level opened by beginTransaction(). Does nothing when none is open. */
|
|
219
|
-
rollBack(): Promise<void>;
|
|
220
|
-
/** 0 outside a transaction. */
|
|
221
|
-
transactionLevel(): number;
|
|
222
|
-
}
|
|
223
|
-
interface DatabaseManager extends DatabaseConnection {
|
|
224
|
-
connection(name?: string): DatabaseConnection;
|
|
225
|
-
disconnect(name?: string): Promise<void>;
|
|
226
|
-
}
|
|
227
|
-
declare const DatabaseManager: Token$2<DatabaseManager>;
|
|
228
|
-
/** What non-Database components may rely on from a model instance. */
|
|
229
|
-
interface ModelInstance {
|
|
230
|
-
exists: boolean;
|
|
231
|
-
getKey(): unknown;
|
|
232
|
-
getKeyName(): string;
|
|
233
|
-
getTable(): string;
|
|
234
|
-
getRouteKey(): unknown;
|
|
235
|
-
getRouteKeyName(): string;
|
|
236
|
-
/** The value stored in a polymorphic `*_type` column for this model: its morph map alias, else its class name. */
|
|
237
|
-
getMorphClass(): string;
|
|
238
|
-
getAttribute<T = unknown>(key: string): T;
|
|
239
|
-
setAttribute(key: string, value: unknown): this;
|
|
240
|
-
fill(attributes: Row): this;
|
|
241
|
-
save(): Promise<boolean>;
|
|
242
|
-
delete(): Promise<boolean>;
|
|
243
|
-
refresh(): Promise<this>;
|
|
244
|
-
toArray(): Row;
|
|
245
|
-
toJSON(): Row;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
interface Authenticatable {
|
|
249
|
-
getAuthIdentifierName(): string;
|
|
250
|
-
getAuthIdentifier(): unknown;
|
|
251
|
-
getAuthPassword(): string;
|
|
252
|
-
getRememberToken(): string | undefined;
|
|
253
|
-
setRememberToken(value: string): void;
|
|
254
|
-
getRememberTokenName(): string;
|
|
255
|
-
}
|
|
256
|
-
type Credentials = Record<string, unknown>;
|
|
257
|
-
interface UserProvider {
|
|
258
|
-
retrieveById(id: unknown): Promise<Authenticatable | undefined>;
|
|
259
|
-
retrieveByToken(id: unknown, token: string): Promise<Authenticatable | undefined>;
|
|
260
|
-
updateRememberToken(user: Authenticatable, token: string): Promise<void>;
|
|
261
|
-
retrieveByCredentials(credentials: Credentials): Promise<Authenticatable | undefined>;
|
|
262
|
-
validateCredentials(user: Authenticatable, credentials: Credentials): Promise<boolean>;
|
|
263
|
-
}
|
|
264
|
-
interface Guard {
|
|
265
|
-
check(): Promise<boolean>;
|
|
266
|
-
guest(): Promise<boolean>;
|
|
267
|
-
user<T extends Authenticatable = Authenticatable>(): Promise<T | undefined>;
|
|
268
|
-
id(): Promise<unknown>;
|
|
269
|
-
validate(credentials: Credentials): Promise<boolean>;
|
|
270
|
-
hasUser(): boolean;
|
|
271
|
-
setUser(user: Authenticatable): void;
|
|
272
|
-
}
|
|
273
|
-
interface StatefulGuard extends Guard {
|
|
274
|
-
attempt(credentials: Credentials, remember?: boolean): Promise<boolean>;
|
|
275
|
-
once(credentials: Credentials): Promise<boolean>;
|
|
276
|
-
login(user: Authenticatable, remember?: boolean): Promise<void>;
|
|
277
|
-
loginUsingId(id: unknown, remember?: boolean): Promise<Authenticatable | false>;
|
|
278
|
-
logout(): Promise<void>;
|
|
279
|
-
}
|
|
280
|
-
interface AuthFactory {
|
|
281
|
-
guard(name?: string): StatefulGuard | Guard;
|
|
282
|
-
shouldUse(name: string): void;
|
|
283
|
-
extend(driver: string, factory: (name: string, config: Record<string, unknown>) => Guard): void;
|
|
284
|
-
provider(driver: string, factory: (config: Record<string, unknown>) => UserProvider): void;
|
|
285
|
-
}
|
|
286
|
-
declare const AuthFactory: Token$2<AuthFactory>;
|
|
287
|
-
|
|
288
|
-
/** Options a job class may declare as public fields. Their presence (or implementing ShouldQueue) makes things queueable. */
|
|
289
|
-
interface ShouldQueue {
|
|
290
|
-
/**
|
|
291
|
-
* Marks the class as queued at run time: `implements ShouldQueue` leaves no trace once compiled, so the interface
|
|
292
|
-
* asks for `readonly shouldQueue = true`. Jobs, listeners, mailables and notifications carrying it are queued.
|
|
293
|
-
*/
|
|
294
|
-
readonly shouldQueue: true;
|
|
295
|
-
connection?: string;
|
|
296
|
-
queue?: string;
|
|
297
|
-
/** Seconds. */
|
|
298
|
-
delay?: number;
|
|
299
|
-
tries?: number;
|
|
300
|
-
/** Seconds, or a per-attempt list. */
|
|
301
|
-
backoff?: number | number[];
|
|
302
|
-
/** Seconds. */
|
|
303
|
-
timeout?: number;
|
|
304
|
-
uniqueId?(): string;
|
|
305
|
-
}
|
|
306
|
-
/** A job: public fields are its serialized data; handle() runs on the worker (inject() works inside it). */
|
|
307
|
-
interface Job extends Partial<ShouldQueue> {
|
|
308
|
-
handle(): unknown | Promise<unknown>;
|
|
309
|
-
failed?(error: unknown): void | Promise<void>;
|
|
310
|
-
}
|
|
311
|
-
interface QueuePayload {
|
|
312
|
-
uuid: string;
|
|
313
|
-
/** ClassRegistry name. */
|
|
314
|
-
job: string;
|
|
315
|
-
displayName: string;
|
|
316
|
-
data: Record<string, unknown>;
|
|
317
|
-
attempts: number;
|
|
318
|
-
maxTries?: number;
|
|
319
|
-
backoff?: number[];
|
|
320
|
-
timeout?: number;
|
|
321
|
-
/** Unix ms. */
|
|
322
|
-
pushedAt: number;
|
|
323
|
-
batchId?: string;
|
|
324
|
-
chain?: QueuePayload[];
|
|
325
|
-
/** Unix ms after which the job fails instead of retrying. */
|
|
326
|
-
retryUntil?: number;
|
|
327
|
-
/** Mark the job failed (instead of releasing it) when it times out. */
|
|
328
|
-
failOnTimeout?: boolean;
|
|
329
|
-
}
|
|
330
|
-
interface QueueJob {
|
|
331
|
-
getJobId(): string;
|
|
332
|
-
getQueue(): string;
|
|
333
|
-
payload(): QueuePayload;
|
|
334
|
-
attempts(): number;
|
|
335
|
-
delete(): Promise<void>;
|
|
336
|
-
release(delaySeconds?: number): Promise<void>;
|
|
337
|
-
/** Marks as failed: stores it via FailedJobProvider and calls job.failed(). */
|
|
338
|
-
fail(error: unknown): Promise<void>;
|
|
339
|
-
isDeleted(): boolean;
|
|
340
|
-
isReleased(): boolean;
|
|
341
|
-
}
|
|
342
|
-
interface Queue {
|
|
343
|
-
push(job: Job, queue?: string): Promise<string>;
|
|
344
|
-
later(delaySeconds: number, job: Job, queue?: string): Promise<string>;
|
|
345
|
-
pushRaw(payload: QueuePayload, queue?: string, delaySeconds?: number): Promise<string>;
|
|
346
|
-
pop(queue?: string): Promise<QueueJob | undefined>;
|
|
347
|
-
size(queue?: string): Promise<number>;
|
|
348
|
-
clear(queue?: string): Promise<number>;
|
|
349
|
-
}
|
|
350
|
-
interface QueueManager extends Queue {
|
|
351
|
-
connection(name?: string): Queue;
|
|
352
|
-
extend(driver: string, factory: (config: Record<string, unknown>) => Queue): void;
|
|
353
|
-
}
|
|
354
|
-
declare const QueueManager: Token$2<QueueManager>;
|
|
355
|
-
|
|
356
|
-
interface Batch {
|
|
357
|
-
readonly id: string;
|
|
358
|
-
readonly name: string;
|
|
359
|
-
readonly totalJobs: number;
|
|
360
|
-
readonly pendingJobs: number;
|
|
361
|
-
readonly failedJobs: number;
|
|
362
|
-
progress(): number;
|
|
363
|
-
finished(): boolean;
|
|
364
|
-
cancelled(): boolean;
|
|
365
|
-
cancel(): Promise<void>;
|
|
366
|
-
}
|
|
367
|
-
interface PendingChain {
|
|
368
|
-
onConnection(connection: string): this;
|
|
369
|
-
onQueue(queue: string): this;
|
|
370
|
-
/** Runs as a job if any job in the chain fails. Callbacks are jobs, because closures can't be serialized. */
|
|
371
|
-
catch(job: Job): this;
|
|
372
|
-
dispatch(): Promise<void>;
|
|
373
|
-
}
|
|
374
|
-
interface PendingBatch {
|
|
375
|
-
name(name: string): this;
|
|
376
|
-
onConnection(connection: string): this;
|
|
377
|
-
onQueue(queue: string): this;
|
|
378
|
-
allowFailures(allow?: boolean): this;
|
|
379
|
-
then(job: Job): this;
|
|
380
|
-
catch(job: Job): this;
|
|
381
|
-
finally(job: Job): this;
|
|
382
|
-
dispatch(): Promise<Batch>;
|
|
383
|
-
}
|
|
384
|
-
interface BusDispatcher {
|
|
385
|
-
/** Queues it when the job is queueable (implements ShouldQueue / declares queue options), otherwise runs it now. */
|
|
386
|
-
dispatch(job: Job): Promise<unknown>;
|
|
387
|
-
dispatchSync(job: Job): Promise<unknown>;
|
|
388
|
-
/** Runs after the current response is sent (or the current job finishes). */
|
|
389
|
-
dispatchAfterResponse(job: Job): void;
|
|
390
|
-
chain(jobs: Job[]): PendingChain;
|
|
391
|
-
batch(jobs: Job[]): PendingBatch;
|
|
392
|
-
findBatch(id: string): Promise<Batch | undefined>;
|
|
393
|
-
}
|
|
394
|
-
declare const BusDispatcher: Token$2<BusDispatcher>;
|
|
395
|
-
/** What PendingBatch hands to the repository. Callbacks are jobs, because closures can't be serialized. */
|
|
396
|
-
interface PendingBatchOptions {
|
|
397
|
-
name: string;
|
|
398
|
-
then: Job[];
|
|
399
|
-
catch: Job[];
|
|
400
|
-
finally: Job[];
|
|
401
|
-
allowFailures: boolean;
|
|
402
|
-
connection?: string;
|
|
403
|
-
queue?: string;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
interface Address {
|
|
407
|
-
address: string;
|
|
408
|
-
name?: string;
|
|
409
|
-
}
|
|
410
|
-
/** A plain email string, an Address, or anything with email (+ optional name), such as a User model. */
|
|
411
|
-
type MailRecipient = string | Address | {
|
|
412
|
-
email: string;
|
|
413
|
-
name?: string;
|
|
414
|
-
};
|
|
415
|
-
interface Envelope {
|
|
416
|
-
from?: MailRecipient;
|
|
417
|
-
to?: MailRecipient[];
|
|
418
|
-
cc?: MailRecipient[];
|
|
419
|
-
bcc?: MailRecipient[];
|
|
420
|
-
replyTo?: MailRecipient[];
|
|
421
|
-
subject?: string;
|
|
422
|
-
tags?: string[];
|
|
423
|
-
metadata?: Record<string, string>;
|
|
424
|
-
}
|
|
425
|
-
interface Content {
|
|
426
|
-
/** A View name, rendered by ViewFactory (TSX). */
|
|
427
|
-
view?: string;
|
|
428
|
-
/** A plain-text view name. */
|
|
429
|
-
text?: string;
|
|
430
|
-
/** Raw HTML (used when no view is given). */
|
|
431
|
-
htmlString?: string;
|
|
432
|
-
/** Raw plain-text body (used when no text view is given). */
|
|
433
|
-
textString?: string;
|
|
434
|
-
with?: Record<string, unknown>;
|
|
435
|
-
}
|
|
436
|
-
interface Attachment {
|
|
437
|
-
name: string;
|
|
438
|
-
path?: string;
|
|
439
|
-
data?: Uint8Array | string;
|
|
440
|
-
mime?: string;
|
|
441
|
-
}
|
|
442
|
-
/** Laravel 10+ style mailable: envelope() + content() + attachments(). */
|
|
443
|
-
interface Mailable {
|
|
444
|
-
envelope(): Envelope | Promise<Envelope>;
|
|
445
|
-
content(): Content | Promise<Content>;
|
|
446
|
-
attachments?(): Attachment[] | Promise<Attachment[]>;
|
|
447
|
-
}
|
|
448
|
-
/** Fully rendered message handed to a transport. */
|
|
449
|
-
interface OutgoingMessage {
|
|
450
|
-
from: Address;
|
|
451
|
-
to: Address[];
|
|
452
|
-
cc: Address[];
|
|
453
|
-
bcc: Address[];
|
|
454
|
-
replyTo: Address[];
|
|
455
|
-
subject: string;
|
|
456
|
-
html?: string;
|
|
457
|
-
text?: string;
|
|
458
|
-
attachments: Attachment[];
|
|
459
|
-
headers: Record<string, string>;
|
|
460
|
-
}
|
|
461
|
-
interface SentMessage {
|
|
462
|
-
messageId: string;
|
|
463
|
-
message: OutgoingMessage;
|
|
464
|
-
}
|
|
465
|
-
interface MailTransport {
|
|
466
|
-
send(message: OutgoingMessage): Promise<SentMessage>;
|
|
467
|
-
}
|
|
468
|
-
interface PendingMail {
|
|
469
|
-
cc(recipients: MailRecipient | MailRecipient[]): this;
|
|
470
|
-
bcc(recipients: MailRecipient | MailRecipient[]): this;
|
|
471
|
-
send(mailable: Mailable): Promise<SentMessage | undefined>;
|
|
472
|
-
queue(mailable: Mailable): Promise<void>;
|
|
473
|
-
later(delaySeconds: number, mailable: Mailable): Promise<void>;
|
|
474
|
-
}
|
|
475
|
-
interface Mailer {
|
|
476
|
-
to(recipients: MailRecipient | MailRecipient[]): PendingMail;
|
|
477
|
-
/** Sends to the recipients given in the mailable's envelope. Queues it if the mailable is queueable. */
|
|
478
|
-
send(mailable: Mailable): Promise<SentMessage | undefined>;
|
|
479
|
-
queue(mailable: Mailable): Promise<void>;
|
|
480
|
-
}
|
|
481
|
-
interface MailManager extends Mailer {
|
|
482
|
-
mailer(name?: string): Mailer;
|
|
483
|
-
extend(transport: string, factory: (config: Record<string, unknown>) => MailTransport): void;
|
|
484
|
-
}
|
|
485
|
-
declare const MailManager: Token$2<MailManager>;
|
|
486
|
-
|
|
487
|
-
interface Notifiable {
|
|
488
|
-
/** e.g. 'mail' → email address, 'database' → the model itself. */
|
|
489
|
-
routeNotificationFor(channel: string, notification: Notification): unknown;
|
|
490
|
-
}
|
|
491
|
-
interface Notification {
|
|
492
|
-
/** Optional id; set by the dispatcher when missing. */
|
|
493
|
-
id?: string;
|
|
494
|
-
via(notifiable: Notifiable): string[];
|
|
495
|
-
/** Returns a Mailable (Contracts/Mail) or the Notifications MailMessage builder. */
|
|
496
|
-
toMail?(notifiable: Notifiable): unknown;
|
|
497
|
-
toDatabase?(notifiable: Notifiable): Record<string, unknown>;
|
|
498
|
-
toArray?(notifiable: Notifiable): Record<string, unknown>;
|
|
499
|
-
}
|
|
500
|
-
interface NotificationChannel {
|
|
501
|
-
send(notifiable: Notifiable, notification: Notification): Promise<void>;
|
|
502
|
-
}
|
|
503
|
-
interface NotificationDispatcher {
|
|
504
|
-
/** Queues it when the notification is queueable, otherwise sends immediately. */
|
|
505
|
-
send(notifiables: Notifiable | Notifiable[], notification: Notification): Promise<void>;
|
|
506
|
-
sendNow(notifiables: Notifiable | Notifiable[], notification: Notification, channels?: string[]): Promise<void>;
|
|
507
|
-
/** On-demand: Notification.route('mail', 'a@b.c').notify(n). */
|
|
508
|
-
route(channel: string, route: unknown): Notifiable & {
|
|
509
|
-
notify(notification: Notification): Promise<void>;
|
|
510
|
-
};
|
|
511
|
-
extend(channel: string, factory: () => NotificationChannel): void;
|
|
512
|
-
}
|
|
513
|
-
declare const NotificationDispatcher: Token$2<NotificationDispatcher>;
|
|
514
|
-
|
|
515
|
-
type ListenerClass<E> = Class$1<{
|
|
516
|
-
handle(event: E): unknown;
|
|
517
|
-
}>;
|
|
518
|
-
type Listener<E> = ((event: E) => unknown) | ListenerClass<E>;
|
|
519
|
-
interface EventDispatcher {
|
|
520
|
-
/** Class events (recommended) or string events like 'eloquent.created: Post'. */
|
|
521
|
-
listen<E>(events: Class$1<E> | string | Array<Class$1<E> | string>, listener: Listener<E>): void;
|
|
522
|
-
hasListeners(event: Class$1<unknown> | string): boolean;
|
|
523
|
-
/** Runs listeners in registration order. Listener classes that are queueable are queued. Returns results. */
|
|
524
|
-
dispatch(event: object | string, payload?: unknown[]): Promise<unknown[]>;
|
|
525
|
-
/** Stops at the first listener that returns something other than undefined. Returns that value. */
|
|
526
|
-
until(event: object | string, payload?: unknown[]): Promise<unknown>;
|
|
527
|
-
subscribe(subscriber: Class$1<{
|
|
528
|
-
subscribe(events: EventDispatcher): void;
|
|
529
|
-
}>): void;
|
|
530
|
-
forget(event: Class$1<unknown> | string): void;
|
|
531
|
-
}
|
|
532
|
-
declare const EventDispatcher: Token$2<EventDispatcher>;
|
|
533
|
-
|
|
534
|
-
interface PutOptions {
|
|
535
|
-
visibility?: 'public' | 'private';
|
|
536
|
-
mimeType?: string;
|
|
537
|
-
}
|
|
538
|
-
/** Paths are relative to the disk root. Throws on paths that escape it ('../'). */
|
|
539
|
-
interface Filesystem {
|
|
540
|
-
exists(path: string): Promise<boolean>;
|
|
541
|
-
missing(path: string): Promise<boolean>;
|
|
542
|
-
get(path: string): Promise<string>;
|
|
543
|
-
getBytes(path: string): Promise<Uint8Array>;
|
|
544
|
-
readStream(path: string): Promise<ReadableStream<Uint8Array>>;
|
|
545
|
-
put(path: string, contents: string | Uint8Array | ReadableStream<Uint8Array>, options?: PutOptions): Promise<boolean>;
|
|
546
|
-
/** Stores under a generated unique name. Returns the stored path. */
|
|
547
|
-
putFile(directory: string, file: UploadedFile$1, options?: PutOptions): Promise<string>;
|
|
548
|
-
putFileAs(directory: string, file: UploadedFile$1, name: string, options?: PutOptions): Promise<string>;
|
|
549
|
-
delete(paths: string | string[]): Promise<boolean>;
|
|
550
|
-
copy(from: string, to: string): Promise<boolean>;
|
|
551
|
-
move(from: string, to: string): Promise<boolean>;
|
|
552
|
-
size(path: string): Promise<number>;
|
|
553
|
-
lastModified(path: string): Promise<Date>;
|
|
554
|
-
mimeType(path: string): Promise<string | undefined>;
|
|
555
|
-
url(path: string): string;
|
|
556
|
-
temporaryUrl(path: string, expiresAt: Date): Promise<string>;
|
|
557
|
-
files(directory?: string, recursive?: boolean): Promise<string[]>;
|
|
558
|
-
directories(directory?: string, recursive?: boolean): Promise<string[]>;
|
|
559
|
-
makeDirectory(path: string): Promise<boolean>;
|
|
560
|
-
deleteDirectory(path: string): Promise<boolean>;
|
|
561
|
-
/** Absolute local path (local disks only). */
|
|
562
|
-
path(path: string): string;
|
|
563
|
-
}
|
|
564
|
-
interface FilesystemManager extends Filesystem {
|
|
565
|
-
disk(name?: string): Filesystem;
|
|
566
|
-
extend(driver: string, factory: (config: Record<string, unknown>) => Filesystem): void;
|
|
567
|
-
}
|
|
568
|
-
declare const FilesystemManager: Token$2<FilesystemManager>;
|
|
569
|
-
|
|
570
|
-
/** Infinite-scroll metadata for one prop (page.scrollProps[path]). */
|
|
571
|
-
interface InertiaScrollProp {
|
|
572
|
-
pageName: string;
|
|
573
|
-
previousPage: string | number | null;
|
|
574
|
-
nextPage: string | number | null;
|
|
575
|
-
currentPage: string | number | null;
|
|
576
|
-
reset: boolean;
|
|
577
|
-
}
|
|
578
|
-
/** A once prop the client keeps between visits (page.onceProps[key]). `expiresAt` is epoch milliseconds. */
|
|
579
|
-
interface InertiaOnceProp {
|
|
580
|
-
prop: string;
|
|
581
|
-
expiresAt: number | null;
|
|
582
|
-
}
|
|
4
|
+
/** A date the tests travel to: a Date, an ISO string or milliseconds since the epoch. */
|
|
5
|
+
type TravelDate = Date | string | number;
|
|
6
|
+
/**
|
|
7
|
+
* Laravel's travelTo(): the clock stands at `date` (new Date(), Date.now() and now() all read it) until travelBack().
|
|
8
|
+
* With a callback, it runs there and the clock travels back after it; its result is returned.
|
|
9
|
+
*/
|
|
10
|
+
declare function travelTo(date: TravelDate): void;
|
|
11
|
+
declare function travelTo<R>(date: TravelDate, callback: (date: Date) => R): R;
|
|
12
|
+
/** Laravel's travelBack(): the real clock again. Returns the real time. */
|
|
13
|
+
declare function travelBack(): Date;
|
|
14
|
+
/** Laravel's freezeTime(): holds the clock where it is now. Returns that time, or the callback's result. */
|
|
15
|
+
declare function freezeTime(): Date;
|
|
16
|
+
declare function freezeTime<R>(callback: (date: Date) => R): R;
|
|
17
|
+
/** Laravel's freezeSecond(): freezeTime() at the start of the current second. */
|
|
18
|
+
declare function freezeSecond(): Date;
|
|
19
|
+
declare function freezeSecond<R>(callback: (date: Date) => R): R;
|
|
20
|
+
/** Laravel's travel(5).minutes(): moves the clock on (a negative value moves it back) from where it stands. */
|
|
21
|
+
declare function travel(value: number): Wormhole;
|
|
583
22
|
/**
|
|
584
|
-
*
|
|
585
|
-
*
|
|
23
|
+
* Laravel's Wormhole: each unit moves the clock by `value` of it (months and years overflow as Carbon's do: 31 January
|
|
24
|
+
* plus a month is 3 March), in UTC. With a callback, it runs there, the clock travels back after it, and its result is
|
|
25
|
+
* returned. JavaScript dates hold milliseconds, so there are no microseconds.
|
|
586
26
|
*/
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
27
|
+
declare class Wormhole {
|
|
28
|
+
#private;
|
|
29
|
+
readonly value: number;
|
|
30
|
+
constructor(value: number);
|
|
31
|
+
millisecond(): void;
|
|
32
|
+
millisecond<R>(callback: () => R): R;
|
|
33
|
+
milliseconds(): void;
|
|
34
|
+
milliseconds<R>(callback: () => R): R;
|
|
35
|
+
second(): void;
|
|
36
|
+
second<R>(callback: () => R): R;
|
|
37
|
+
seconds(): void;
|
|
38
|
+
seconds<R>(callback: () => R): R;
|
|
39
|
+
minute(): void;
|
|
40
|
+
minute<R>(callback: () => R): R;
|
|
41
|
+
minutes(): void;
|
|
42
|
+
minutes<R>(callback: () => R): R;
|
|
43
|
+
hour(): void;
|
|
44
|
+
hour<R>(callback: () => R): R;
|
|
45
|
+
hours(): void;
|
|
46
|
+
hours<R>(callback: () => R): R;
|
|
47
|
+
day(): void;
|
|
48
|
+
day<R>(callback: () => R): R;
|
|
49
|
+
days(): void;
|
|
50
|
+
days<R>(callback: () => R): R;
|
|
51
|
+
week(): void;
|
|
52
|
+
week<R>(callback: () => R): R;
|
|
53
|
+
weeks(): void;
|
|
54
|
+
weeks<R>(callback: () => R): R;
|
|
55
|
+
month(): void;
|
|
56
|
+
month<R>(callback: () => R): R;
|
|
57
|
+
months(): void;
|
|
58
|
+
months<R>(callback: () => R): R;
|
|
59
|
+
year(): void;
|
|
60
|
+
year<R>(callback: () => R): R;
|
|
61
|
+
years(): void;
|
|
62
|
+
years<R>(callback: () => R): R;
|
|
63
|
+
/** Laravel's Wormhole::back(). */
|
|
64
|
+
static back(): Date;
|
|
609
65
|
}
|
|
610
66
|
|
|
611
67
|
/**
|
|
@@ -623,7 +79,7 @@ declare class PendingCommand implements PromiseLike<number> {
|
|
|
623
79
|
readonly parameters: Record<string, unknown>;
|
|
624
80
|
private readonly checks;
|
|
625
81
|
private result;
|
|
626
|
-
constructor(app: Application
|
|
82
|
+
constructor(app: Application, command: string, parameters?: Record<string, unknown>);
|
|
627
83
|
/** A line of output equals `line` exactly; with no argument, the command printed something. */
|
|
628
84
|
expectsOutput(line?: string): this;
|
|
629
85
|
/** No line equals `line`; with no argument, the command printed nothing at all. */
|
|
@@ -767,9 +223,9 @@ interface ResponseContext {
|
|
|
767
223
|
/** The raw request sent to the kernel (redirect URLs are resolved against it). */
|
|
768
224
|
request?: Request;
|
|
769
225
|
/** The application that handled it. */
|
|
770
|
-
app?: Application
|
|
226
|
+
app?: Application;
|
|
771
227
|
/** The request's session after the response. */
|
|
772
|
-
session?: Session
|
|
228
|
+
session?: Session;
|
|
773
229
|
/** Views made while handling the request, in order. */
|
|
774
230
|
views?: View[];
|
|
775
231
|
/** The last error the exception handler rendered. */
|
|
@@ -881,7 +337,7 @@ declare class TestResponse {
|
|
|
881
337
|
/** Validation errors for these keys (message fragments match with "contains"): JSON body or session. */
|
|
882
338
|
assertInvalid(errors: ExpectedErrors, errorBag?: string, responseKey?: string): this;
|
|
883
339
|
/** The request's session after the response (flashed data is still there). */
|
|
884
|
-
session(): Session
|
|
340
|
+
session(): Session;
|
|
885
341
|
/** A key (with an optional value or predicate), several keys, or a { key: value } record. */
|
|
886
342
|
assertSessionHas(key: string | string[] | Record<string, unknown>, value?: unknown): this;
|
|
887
343
|
assertSessionHasAll(bindings: Record<string, unknown>): this;
|
|
@@ -946,7 +402,7 @@ interface RequestOptions {
|
|
|
946
402
|
* requests, actingAs users and options, plus the dispatch itself.
|
|
947
403
|
*/
|
|
948
404
|
declare class HttpClient {
|
|
949
|
-
protected readonly app: Application
|
|
405
|
+
protected readonly app: Application;
|
|
950
406
|
readonly headers: Record<string, string>;
|
|
951
407
|
/** Cookies to encrypt on send (withCookie) and to send as-is (withUnencryptedCookie, or captured from responses). */
|
|
952
408
|
readonly cookies: Map<string, {
|
|
@@ -961,14 +417,19 @@ declare class HttpClient {
|
|
|
961
417
|
defaultGuard: string | undefined;
|
|
962
418
|
/** Session attributes carried from one request to the next (Laravel keeps one session store per test). */
|
|
963
419
|
session: Record<string, unknown> | undefined;
|
|
420
|
+
/**
|
|
421
|
+
* withSession() and flushSession() since the last started session: applied to the stored session (the one the
|
|
422
|
+
* session cookie points to) once the next request starts it, so they win over what it holds, as in Laravel.
|
|
423
|
+
*/
|
|
424
|
+
sessionChanges: Array<(session: Session) => void>;
|
|
964
425
|
/** from(url): the session's previous URL for the next request only (Laravel sets it once). */
|
|
965
426
|
previousUrl: string | undefined;
|
|
966
427
|
/** Requests whose actingAs users reached the guards (the AuthFactory they went through). */
|
|
967
428
|
private readonly actingAsApplied;
|
|
968
|
-
constructor(app: Application
|
|
429
|
+
constructor(app: Application);
|
|
969
430
|
request(method: string, uri: string, options?: RequestOptions): Promise<TestResponse>;
|
|
970
431
|
/** Runs `fn` in a scope prepared like a request's (carried session, actingAs users), e.g. for assertAuthenticated(). */
|
|
971
|
-
inScope<T>(fn: (scope: Container
|
|
432
|
+
inScope<T>(fn: (scope: Container) => T | Promise<T>): Promise<T>;
|
|
972
433
|
/**
|
|
973
434
|
* Runs `run` in a request scope like this client's requests have (a request for `method uri` bound, the carried
|
|
974
435
|
* session, actingAs users), then carries the session and the users on, as after a request. Live.test() runs its
|
|
@@ -978,16 +439,20 @@ declare class HttpClient {
|
|
|
978
439
|
/** Runs the request through the app's real HttpKernel, in a request scope this client owns. */
|
|
979
440
|
protected send(request: Request): Promise<TestResponse>;
|
|
980
441
|
/** Prepares the request scope: recorders, the carried session and actingAs users. */
|
|
981
|
-
protected beforeRequest(scope: Container
|
|
442
|
+
protected beforeRequest(scope: Container, context: ResponseContext): void;
|
|
982
443
|
/** Keeps the session for the next request, like Laravel's per-test session store, and the guards' users. */
|
|
983
|
-
protected afterRequest(_scope: Container
|
|
444
|
+
protected afterRequest(_scope: Container, context: ResponseContext): Promise<void>;
|
|
984
445
|
/**
|
|
985
446
|
* Laravel's actingAs() sets the user on the guard once, so a logout (or a login as someone else) in the
|
|
986
447
|
* request sticks. Reads each actingAs guard back and forgets or replaces its user to match.
|
|
987
448
|
*/
|
|
988
449
|
protected syncActingAs(auth: AuthFactory): Promise<void>;
|
|
450
|
+
/** Applies the pending withSession()/flushSession() changes once the session has loaded what it stored. */
|
|
451
|
+
protected applyOnStart(session: Session): void;
|
|
452
|
+
/** Applies the pending withSession()/flushSession() changes to the session, once. */
|
|
453
|
+
protected applyPending(session: Session): void;
|
|
989
454
|
/** The request's (scoped) Session, created now so the carried attributes are in place before StartSession. */
|
|
990
|
-
protected scopeSession(scope: Container
|
|
455
|
+
protected scopeSession(scope: Container): Session | undefined;
|
|
991
456
|
buildRequest(method: string, uri: string, options: RequestOptions): Request;
|
|
992
457
|
protected baseUrl(): string;
|
|
993
458
|
protected cookieHeader(): string;
|
|
@@ -1032,20 +497,20 @@ declare abstract class InteractsWithApplication {
|
|
|
1032
497
|
hooks?: TestHooks;
|
|
1033
498
|
}, options?: BootOptions): T;
|
|
1034
499
|
/** The current test's application. */
|
|
1035
|
-
get app(): Application
|
|
500
|
+
get app(): Application;
|
|
1036
501
|
/**
|
|
1037
502
|
* A fresh application for one test. tests/TestCase.ts overrides this to call bootstrap/app's factory.
|
|
1038
503
|
* The default builds one at basePath() with providers(), for package tests with no skeleton.
|
|
1039
504
|
*/
|
|
1040
|
-
createApplication(): Promise<Application
|
|
505
|
+
createApplication(): Promise<Application>;
|
|
1041
506
|
/** Used by the default createApplication(). */
|
|
1042
507
|
protected basePath(): string;
|
|
1043
508
|
/** Used by the default createApplication(). */
|
|
1044
|
-
protected providers(): Array<ServiceProvider
|
|
509
|
+
protected providers(): Array<ServiceProvider | ServiceProviderClass>;
|
|
1045
510
|
/** The variables applied (unless already set) before each application is created. */
|
|
1046
511
|
protected environment(): Record<string, string>;
|
|
1047
512
|
/** Adjust the fresh app before it boots, e.g. `app.make(ConfigRepository).set('mail.default', 'array')`. */
|
|
1048
|
-
protected defineEnvironment(_app: Application
|
|
513
|
+
protected defineEnvironment(_app: Application): void | Promise<void>;
|
|
1049
514
|
setUp(): Promise<void>;
|
|
1050
515
|
tearDown(): Promise<void>;
|
|
1051
516
|
/**
|
|
@@ -1082,9 +547,9 @@ declare abstract class MakesHttpRequests extends InteractsWithApplication {
|
|
|
1082
547
|
followingRedirects(): this;
|
|
1083
548
|
/** Sets the Referer and the session's previous URL, so redirect()->back() goes there. */
|
|
1084
549
|
from(url: string): this;
|
|
1085
|
-
/** Puts data in the session for the following requests (Laravel's withSession()). */
|
|
550
|
+
/** Puts data in the session for the following requests, over what the stored session holds (Laravel's withSession()). */
|
|
1086
551
|
withSession(data: Record<string, unknown>): this;
|
|
1087
|
-
/** Empties the session
|
|
552
|
+
/** Empties the session, the stored one included, so the next request starts with none (Laravel's flushSession()). */
|
|
1088
553
|
flushSession(): this;
|
|
1089
554
|
/** Every following request is authenticated as `user` on `guard` (which also becomes the default guard). */
|
|
1090
555
|
actingAs(user: Authenticatable, guard?: string): this;
|
|
@@ -1143,11 +608,28 @@ declare abstract class InteractsWithConsole extends InteractsWithDatabase {
|
|
|
1143
608
|
artisan(command: string, parameters?: Record<string, unknown>): PendingCommand;
|
|
1144
609
|
}
|
|
1145
610
|
|
|
611
|
+
/**
|
|
612
|
+
* Laravel's InteractsWithTime: `t.travelTo(date)`, `t.travel(5).minutes()`, `t.freezeTime()`, `t.travelBack()`.
|
|
613
|
+
* The functions of the same names do the same outside a test case. A test case's tearDown travels back, so each of its
|
|
614
|
+
* tests ends in the real time; with the plain functions, call `travelBack()` in your own `afterEach()` or pass a callback.
|
|
615
|
+
*/
|
|
616
|
+
declare abstract class InteractsWithTime extends InteractsWithConsole {
|
|
617
|
+
travelTo(date: TravelDate): void;
|
|
618
|
+
travelTo<R>(date: TravelDate, callback: (date: Date) => R): R;
|
|
619
|
+
travel(value: number): Wormhole;
|
|
620
|
+
travelBack(): Date;
|
|
621
|
+
freezeTime(): Date;
|
|
622
|
+
freezeTime<R>(callback: (date: Date) => R): R;
|
|
623
|
+
freezeSecond(): Date;
|
|
624
|
+
freezeSecond<R>(callback: (date: Date) => R): R;
|
|
625
|
+
tearDown(): Promise<void>;
|
|
626
|
+
}
|
|
627
|
+
|
|
1146
628
|
/**
|
|
1147
629
|
* Laravel's TestCase. Extend it in tests/TestCase.ts (override createApplication() and set `static hooks`),
|
|
1148
630
|
* then in each file: `const t = TestCase.boot()`, or `TestCase.boot({ uses: [RefreshDatabase] })`.
|
|
1149
631
|
*/
|
|
1150
|
-
declare abstract class TestCase extends
|
|
632
|
+
declare abstract class TestCase extends InteractsWithTime {
|
|
1151
633
|
}
|
|
1152
634
|
|
|
1153
635
|
/**
|
|
@@ -1188,9 +670,9 @@ declare const RefreshDatabaseState: {
|
|
|
1188
670
|
migrated: boolean;
|
|
1189
671
|
};
|
|
1190
672
|
/** Runs a console command through the ConsoleKernel contract; a non-zero exit fails the test with its output. */
|
|
1191
|
-
declare function runCommand(app: Application
|
|
673
|
+
declare function runCommand(app: Application, command: string, parameters?: Record<string, unknown>): Promise<void>;
|
|
1192
674
|
/** Laravel's usingInMemoryDatabase(): the default connection's database is ':memory:'. */
|
|
1193
|
-
declare function usingInMemoryDatabase(app: Application
|
|
675
|
+
declare function usingInMemoryDatabase(app: Application): boolean;
|
|
1194
676
|
/**
|
|
1195
677
|
* Laravel's RefreshDatabase.
|
|
1196
678
|
* - In-memory SQLite: every test's new application has an empty database, so it just runs `migrate`.
|
|
@@ -1204,11 +686,11 @@ declare const DatabaseMigrations: TestTrait;
|
|
|
1204
686
|
declare const DatabaseTransactions: TestTrait;
|
|
1205
687
|
|
|
1206
688
|
/** What an assertion targets: a class (exact constructor), or a name (a string event, a class name or a registry name). */
|
|
1207
|
-
type Target<T = unknown> = Class
|
|
689
|
+
type Target<T = unknown> = Class<T> | string;
|
|
1208
690
|
/** A count, or a filter over the recorded items. */
|
|
1209
691
|
type CountOrFilter<A extends unknown[]> = number | ((...args: A) => boolean);
|
|
1210
692
|
/** Swaps the fake in through the facade machinery (`facade(token).swap(fake)`: an instance on the current container). */
|
|
1211
|
-
declare function install<T extends object, F extends T>(token: Token
|
|
693
|
+
declare function install<T extends object, F extends T>(token: Token<T>, fake: F): F;
|
|
1212
694
|
declare function nameOf(target: Target | object): string;
|
|
1213
695
|
/** A recorded object (or string event) matches a target: same constructor, or the same (class) name. */
|
|
1214
696
|
declare function matches(item: unknown, target: Target): boolean;
|
|
@@ -1219,6 +701,8 @@ interface DispatchedEvent {
|
|
|
1219
701
|
payload: unknown[];
|
|
1220
702
|
}
|
|
1221
703
|
type EventFilter<E> = (event: E, payload: unknown[]) => boolean;
|
|
704
|
+
/** A listener as assertListening() expects it: a class, a [class, method] pair, a closure, or Function for any closure. */
|
|
705
|
+
type ExpectedListener = Listener<never> | readonly [Class<object>, string] | FunctionConstructor;
|
|
1222
706
|
/**
|
|
1223
707
|
* Laravel's Event::fake(): records dispatched events instead of running listeners. With a list, only those
|
|
1224
708
|
* events are faked and everything else reaches the original dispatcher (so model events keep working).
|
|
@@ -1235,25 +719,31 @@ declare class EventFake implements EventDispatcher {
|
|
|
1235
719
|
static fakeExcept(eventsToDispatch: Target | Target[]): EventFake;
|
|
1236
720
|
private static original;
|
|
1237
721
|
except(events: Target | Target[]): this;
|
|
1238
|
-
listen<E>(events: Class
|
|
1239
|
-
hasListeners(event: Class
|
|
722
|
+
listen<E>(events: Class<E> | string | Array<Class<E> | string>, listener: Listener<E>): void;
|
|
723
|
+
hasListeners(event: Class<unknown> | string): boolean;
|
|
1240
724
|
dispatch(event: object | string, payload?: unknown[]): Promise<unknown[]>;
|
|
1241
725
|
/** Faked events return undefined (never false), so halting model events such as `saving` still proceed. */
|
|
1242
726
|
until(event: object | string, payload?: unknown[]): Promise<unknown>;
|
|
1243
|
-
subscribe(subscriber: Class
|
|
727
|
+
subscribe(subscriber: Class<{
|
|
1244
728
|
subscribe(events: EventDispatcher): void;
|
|
1245
729
|
}>): void;
|
|
1246
|
-
forget(event: Class
|
|
730
|
+
forget(event: Class<unknown> | string): void;
|
|
1247
731
|
/** Dispatched at least once; a number asserts the exact count; a function filters (event, payload). */
|
|
1248
|
-
assertDispatched<E>(event: Class
|
|
1249
|
-
assertDispatchedTimes<E>(event: Class
|
|
1250
|
-
assertNotDispatched<E>(event: Class
|
|
732
|
+
assertDispatched<E>(event: Class<E> | string, callback?: CountOrFilter<[E, unknown[]]>): void;
|
|
733
|
+
assertDispatchedTimes<E>(event: Class<E> | string, times?: number): void;
|
|
734
|
+
assertNotDispatched<E>(event: Class<E> | string, callback?: EventFilter<E>): void;
|
|
1251
735
|
assertNothingDispatched(): void;
|
|
1252
|
-
/**
|
|
1253
|
-
|
|
736
|
+
/**
|
|
737
|
+
* Laravel's assertListening(event, listener): the original dispatcher has that listener for the event (a class, a
|
|
738
|
+
* [class, method] pair, the same closure, or Function for any closure; wildcard listeners count for a string event).
|
|
739
|
+
* With only the event, any listener will do.
|
|
740
|
+
*/
|
|
741
|
+
assertListening(event: Class<unknown> | string, listener?: ExpectedListener): void;
|
|
1254
742
|
/** The recorded events (objects, or names for string events) that match. */
|
|
1255
|
-
dispatched<E>(event: Class
|
|
1256
|
-
hasDispatched(event: Class
|
|
743
|
+
dispatched<E>(event: Class<E> | string, callback?: EventFilter<E>): E[];
|
|
744
|
+
hasDispatched(event: Class<unknown> | string): boolean;
|
|
745
|
+
/** The original dispatcher's listeners for the event, as registered, wildcard ones included for a string event. */
|
|
746
|
+
private listenersFor;
|
|
1257
747
|
private shouldFake;
|
|
1258
748
|
}
|
|
1259
749
|
|
|
@@ -1407,6 +897,8 @@ declare class MailFake implements MailManager {
|
|
|
1407
897
|
mailer(name?: string): Mailer;
|
|
1408
898
|
to(recipients: MailRecipient | MailRecipient[]): PendingMail;
|
|
1409
899
|
send(mailable: Mailable): Promise<SentMessage | undefined>;
|
|
900
|
+
/** Recorded as sent, never queued, like the real sendNow(). */
|
|
901
|
+
sendNow(mailable: Mailable): Promise<SentMessage | undefined>;
|
|
1410
902
|
queue(mailable: Mailable): Promise<void>;
|
|
1411
903
|
extend(_transport: string, _factory: (config: Record<string, unknown>) => MailTransport): void;
|
|
1412
904
|
/** Sent (not queued) at least once; a number asserts the count; a filter gets (mailable, record). */
|
|
@@ -1428,6 +920,7 @@ declare class MailFake implements MailManager {
|
|
|
1428
920
|
hasQueued(mailable: Target<Mailable>): boolean;
|
|
1429
921
|
private pending;
|
|
1430
922
|
private sendVia;
|
|
923
|
+
private sendNowVia;
|
|
1431
924
|
private queueVia;
|
|
1432
925
|
private record;
|
|
1433
926
|
private matching;
|
|
@@ -1476,7 +969,7 @@ declare class NotificationFake implements NotificationDispatcher {
|
|
|
1476
969
|
/** Sent this many times in total, to anyone. */
|
|
1477
970
|
assertSentTimes(notification: Target<Notification>, times: number): void;
|
|
1478
971
|
assertCount(expected: number): void;
|
|
1479
|
-
sent<N extends Notification>(notifiable: Notifiable, notification: Target<N> | Class
|
|
972
|
+
sent<N extends Notification>(notifiable: Notifiable, notification: Target<N> | Class<N>, callback?: Filter<N>): N[];
|
|
1480
973
|
hasSent(notifiable: Notifiable, notification: Target<Notification>): boolean;
|
|
1481
974
|
private record;
|
|
1482
975
|
}
|
|
@@ -1507,12 +1000,12 @@ declare class FakeDisk implements Filesystem {
|
|
|
1507
1000
|
getBytes(path: string): Promise<Uint8Array>;
|
|
1508
1001
|
readStream(path: string): Promise<ReadableStream<Uint8Array>>;
|
|
1509
1002
|
put(path: string, contents: string | Uint8Array | ReadableStream<Uint8Array>, options?: PutOptions): Promise<boolean>;
|
|
1510
|
-
putFile(directory: string, file: UploadedFile
|
|
1003
|
+
putFile(directory: string, file: UploadedFile, options?: PutOptions): Promise<string>;
|
|
1511
1004
|
/**
|
|
1512
1005
|
* The upload's own type, as the S3 disk sends it: its extension(), never the MIME type the client sent as such nor
|
|
1513
1006
|
* the stored name's type.
|
|
1514
1007
|
*/
|
|
1515
|
-
putFileAs(directory: string, file: UploadedFile
|
|
1008
|
+
putFileAs(directory: string, file: UploadedFile, name: string, options?: PutOptions): Promise<string>;
|
|
1516
1009
|
private write;
|
|
1517
1010
|
delete(paths: string | string[]): Promise<boolean>;
|
|
1518
1011
|
copy(from: string, to: string): Promise<boolean>;
|
|
@@ -1554,8 +1047,8 @@ declare class StorageFake implements FilesystemManager {
|
|
|
1554
1047
|
getBytes(path: string): Promise<Uint8Array<ArrayBufferLike>>;
|
|
1555
1048
|
readStream(path: string): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
|
|
1556
1049
|
put(path: string, contents: string | Uint8Array | ReadableStream<Uint8Array>, options?: PutOptions): Promise<boolean>;
|
|
1557
|
-
putFile(directory: string, file: UploadedFile
|
|
1558
|
-
putFileAs(directory: string, file: UploadedFile
|
|
1050
|
+
putFile(directory: string, file: UploadedFile, options?: PutOptions): Promise<string>;
|
|
1051
|
+
putFileAs(directory: string, file: UploadedFile, name: string, options?: PutOptions): Promise<string>;
|
|
1559
1052
|
delete(paths: string | string[]): Promise<boolean>;
|
|
1560
1053
|
copy(from: string, to: string): Promise<boolean>;
|
|
1561
1054
|
move(from: string, to: string): Promise<boolean>;
|
|
@@ -1587,346 +1080,6 @@ declare const FakeFile: {
|
|
|
1587
1080
|
image(name: string, width?: number, height?: number): File;
|
|
1588
1081
|
};
|
|
1589
1082
|
|
|
1590
|
-
/** A typed, runtime-unique key for container bindings. */
|
|
1591
|
-
interface Token<T> {
|
|
1592
|
-
readonly id: symbol;
|
|
1593
|
-
readonly description: string;
|
|
1594
|
-
/** Phantom field: only carries T at the type level. Never set at runtime. */
|
|
1595
|
-
readonly __type?: T;
|
|
1596
|
-
}
|
|
1597
|
-
type Class<T> = abstract new (...args: any[]) => T;
|
|
1598
|
-
type Abstract<T> = Token<T> | Class<T>;
|
|
1599
|
-
type Factory<T> = (container: Container) => T;
|
|
1600
|
-
type Concrete<T> = Factory<T> | (new () => T);
|
|
1601
|
-
interface Container {
|
|
1602
|
-
/** New instance on every make(). A class with no concrete binds to itself (constructed with no args). Root only; throws on a scope. */
|
|
1603
|
-
bind<T>(abstract: Abstract<T>, concrete?: Concrete<T>): void;
|
|
1604
|
-
/** One instance for the life of this container and its scopes. Root only; throws on a scope. */
|
|
1605
|
-
singleton<T>(abstract: Abstract<T>, concrete?: Concrete<T>): void;
|
|
1606
|
-
/** One instance per scope (e.g. per HTTP request or queue job). Root only; throws on a scope. */
|
|
1607
|
-
scoped<T>(abstract: Abstract<T>, concrete?: Concrete<T>): void;
|
|
1608
|
-
/** Register an existing object as a shared instance. Returns it. On a scope it stays local to that scope. */
|
|
1609
|
-
instance<T>(abstract: Abstract<T>, instance: T): T;
|
|
1610
|
-
/** Resolve. Unbound classes are constructed with `new Class()`. Unbound tokens throw BindingResolutionError. */
|
|
1611
|
-
make<T>(abstract: Abstract<T>): T;
|
|
1612
|
-
bound(abstract: Abstract<unknown>): boolean;
|
|
1613
|
-
resolved(abstract: Abstract<unknown>): boolean;
|
|
1614
|
-
/** Decorate or replace an instance each time it's resolved (applied before resolving callbacks). Root only; throws on a scope. */
|
|
1615
|
-
extend<T>(abstract: Abstract<T>, extender: (instance: T, container: Container) => T): void;
|
|
1616
|
-
/** Called after each resolution of the abstract. Root only; throws on a scope. */
|
|
1617
|
-
resolving<T>(abstract: Abstract<T>, callback: (instance: T, container: Container) => void): void;
|
|
1618
|
-
forgetInstance(abstract: Abstract<unknown>): void;
|
|
1619
|
-
/** A child container: shares bindings and singletons with its parent, and has its own scoped instances. Bindings can't be registered on it. */
|
|
1620
|
-
createScope(): Container;
|
|
1621
|
-
/** Run fn with this container as the "current" one for inject(), helpers and facades (AsyncLocalStorage). */
|
|
1622
|
-
run<R>(fn: () => R): R;
|
|
1623
|
-
}
|
|
1624
|
-
declare const Container: Token<Container>;
|
|
1625
|
-
|
|
1626
|
-
/** The session of the current request (scoped). Loaded and saved by the StartSession middleware. */
|
|
1627
|
-
interface Session {
|
|
1628
|
-
getId(): string;
|
|
1629
|
-
start(): Promise<void>;
|
|
1630
|
-
save(): Promise<void>;
|
|
1631
|
-
all(): Record<string, unknown>;
|
|
1632
|
-
has(key: string): boolean;
|
|
1633
|
-
get<T = unknown>(key: string, defaultValue?: T): T;
|
|
1634
|
-
put(key: string | Record<string, unknown>, value?: unknown): void;
|
|
1635
|
-
push(key: string, value: unknown): void;
|
|
1636
|
-
pull<T = unknown>(key: string, defaultValue?: T): T;
|
|
1637
|
-
forget(...keys: string[]): void;
|
|
1638
|
-
flush(): void;
|
|
1639
|
-
flash(key: string, value: unknown): void;
|
|
1640
|
-
now(key: string, value: unknown): void;
|
|
1641
|
-
reflash(): void;
|
|
1642
|
-
keep(...keys: string[]): void;
|
|
1643
|
-
getOldInput<T = unknown>(key?: string, defaultValue?: T): T;
|
|
1644
|
-
flashInput(input: Record<string, unknown>): void;
|
|
1645
|
-
token(): string;
|
|
1646
|
-
regenerateToken(): void;
|
|
1647
|
-
regenerate(destroy?: boolean): Promise<void>;
|
|
1648
|
-
invalidate(): Promise<void>;
|
|
1649
|
-
previousUrl(): string | undefined;
|
|
1650
|
-
setPreviousUrl(url: string): void;
|
|
1651
|
-
}
|
|
1652
|
-
declare const Session: Token$2<Session>;
|
|
1653
|
-
|
|
1654
|
-
/** A rule object (Laravel's ValidationRule). Call fail() to reject the value. */
|
|
1655
|
-
interface ValidationRule {
|
|
1656
|
-
validate(attribute: string, value: unknown, fail: (message: string) => void, data: Record<string, unknown>): void | Promise<void>;
|
|
1657
|
-
}
|
|
1658
|
-
/** 'required|string|max:255', or an array mixing strings and rule objects. Keys support dot + `*` wildcards. */
|
|
1659
|
-
type Rules = Record<string, string | ReadonlyArray<string | ValidationRule>>;
|
|
1660
|
-
interface MessageBag {
|
|
1661
|
-
has(key: string): boolean;
|
|
1662
|
-
first(key?: string): string | undefined;
|
|
1663
|
-
get(key: string): string[];
|
|
1664
|
-
all(): string[];
|
|
1665
|
-
isEmpty(): boolean;
|
|
1666
|
-
count(): number;
|
|
1667
|
-
toObject(): Record<string, string[]>;
|
|
1668
|
-
}
|
|
1669
|
-
interface UploadedFile {
|
|
1670
|
-
readonly clientName: string;
|
|
1671
|
-
readonly mimeType: string;
|
|
1672
|
-
readonly size: number;
|
|
1673
|
-
extension(): string;
|
|
1674
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
1675
|
-
/** Stores on a Filesystem disk. Returns the stored path. */
|
|
1676
|
-
store(directory: string, disk?: string): Promise<string>;
|
|
1677
|
-
storeAs(directory: string, name: string, disk?: string): Promise<string>;
|
|
1678
|
-
}
|
|
1679
|
-
/**
|
|
1680
|
-
* Oriel's request wrapper (one per request, scoped).
|
|
1681
|
-
* The Http kernel awaits `load()` before any middleware runs, so every input accessor below is synchronous.
|
|
1682
|
-
*/
|
|
1683
|
-
interface HttpRequest {
|
|
1684
|
-
readonly raw: Request;
|
|
1685
|
-
load(): Promise<this>;
|
|
1686
|
-
method(): string;
|
|
1687
|
-
isMethod(method: string): boolean;
|
|
1688
|
-
url(): string;
|
|
1689
|
-
fullUrl(): string;
|
|
1690
|
-
path(): string;
|
|
1691
|
-
is(...patterns: string[]): boolean;
|
|
1692
|
-
routeIs(...names: string[]): boolean;
|
|
1693
|
-
header(name: string): string | undefined;
|
|
1694
|
-
header(name: string, defaultValue: string): string;
|
|
1695
|
-
bearerToken(): string | undefined;
|
|
1696
|
-
ip(): string | undefined;
|
|
1697
|
-
/** The raw body as text (Laravel's getContent()); '' when there is none. */
|
|
1698
|
-
content(): string;
|
|
1699
|
-
expectsJson(): boolean;
|
|
1700
|
-
ajax(): boolean;
|
|
1701
|
-
query<T = unknown>(key?: string, defaultValue?: T): T;
|
|
1702
|
-
input<T = unknown>(key?: string, defaultValue?: T): T;
|
|
1703
|
-
all(): Record<string, unknown>;
|
|
1704
|
-
only(...keys: string[]): Record<string, unknown>;
|
|
1705
|
-
except(...keys: string[]): Record<string, unknown>;
|
|
1706
|
-
has(...keys: string[]): boolean;
|
|
1707
|
-
filled(key: string): boolean;
|
|
1708
|
-
boolean(key: string, defaultValue?: boolean): boolean;
|
|
1709
|
-
integer(key: string, defaultValue?: number): number;
|
|
1710
|
-
merge(values: Record<string, unknown>): this;
|
|
1711
|
-
file(key: string): UploadedFile | undefined;
|
|
1712
|
-
cookie(name: string): string | undefined;
|
|
1713
|
-
/** Replace the parsed request cookies (EncryptCookies calls this after decrypting). */
|
|
1714
|
-
setCookies(cookies: Record<string, string>): void;
|
|
1715
|
-
/** Route parameter (after model binding), or every parameter when called with no key. */
|
|
1716
|
-
route<T = unknown>(key?: string): T;
|
|
1717
|
-
session(): Session;
|
|
1718
|
-
/** The user resolved earlier by auth middleware. Undefined for guests. Use `await Auth.user()` to resolve lazily. */
|
|
1719
|
-
user<T = unknown>(guard?: string): T | undefined;
|
|
1720
|
-
setUserResolver(resolver: (guard?: string) => unknown): void;
|
|
1721
|
-
/** Validates this request's input via the ValidationFactory; throws a Validation OrielError (422) on failure. */
|
|
1722
|
-
validate<T = Record<string, unknown>>(rules: Rules, messages?: Record<string, string>, attributes?: Record<string, string>): Promise<T>;
|
|
1723
|
-
}
|
|
1724
|
-
declare const HttpRequest: Token$2<HttpRequest>;
|
|
1725
|
-
type Next = (request: HttpRequest) => Promise<Response>;
|
|
1726
|
-
interface Middleware {
|
|
1727
|
-
handle(request: HttpRequest, next: Next, ...parameters: string[]): Promise<Response>;
|
|
1728
|
-
terminate?(request: HttpRequest, response: Response): Promise<void>;
|
|
1729
|
-
}
|
|
1730
|
-
type MiddlewareClass = new (...args: any[]) => Middleware;
|
|
1731
|
-
|
|
1732
|
-
interface ServiceProvider$1 {
|
|
1733
|
-
/** Bind things into the container. Synchronous. Don't resolve other services here. */
|
|
1734
|
-
register?(): void;
|
|
1735
|
-
/** Runs after every provider is registered. May be async (e.g. importing route files). */
|
|
1736
|
-
boot?(): void | Promise<void>;
|
|
1737
|
-
}
|
|
1738
|
-
type ServiceProviderClass = new (app: Application) => ServiceProvider$1;
|
|
1739
|
-
interface Application extends Container {
|
|
1740
|
-
readonly version: string;
|
|
1741
|
-
basePath(path?: string): string;
|
|
1742
|
-
appPath(path?: string): string;
|
|
1743
|
-
bootstrapPath(path?: string): string;
|
|
1744
|
-
configPath(path?: string): string;
|
|
1745
|
-
databasePath(path?: string): string;
|
|
1746
|
-
publicPath(path?: string): string;
|
|
1747
|
-
resourcePath(path?: string): string;
|
|
1748
|
-
storagePath(path?: string): string;
|
|
1749
|
-
/** With no args returns the environment name. With args returns whether it matches any of them. */
|
|
1750
|
-
environment(): string;
|
|
1751
|
-
environment(...environments: string[]): boolean;
|
|
1752
|
-
isProduction(): boolean;
|
|
1753
|
-
isLocal(): boolean;
|
|
1754
|
-
runningInConsole(): boolean;
|
|
1755
|
-
/** Mark the app as running in the console (the CLI entry point calls this). Defaults to true. */
|
|
1756
|
-
setRunningInConsole(value?: boolean): void;
|
|
1757
|
-
runningUnitTests(): boolean;
|
|
1758
|
-
/** Registers the provider. If the app is already booted, the provider is booted immediately. */
|
|
1759
|
-
register(provider: ServiceProvider$1 | ServiceProviderClass): Promise<ServiceProvider$1>;
|
|
1760
|
-
getProviders(): ServiceProvider$1[];
|
|
1761
|
-
boot(): Promise<void>;
|
|
1762
|
-
isBooted(): boolean;
|
|
1763
|
-
booting(callback: (app: Application) => void | Promise<void>): void;
|
|
1764
|
-
booted(callback: (app: Application) => void | Promise<void>): void;
|
|
1765
|
-
/** Handle one HTTP request in a fresh request scope via the bound HttpKernel. */
|
|
1766
|
-
handle(request: Request): Promise<Response>;
|
|
1767
|
-
/** Register a callback that terminate() runs, in registration order. */
|
|
1768
|
-
terminating(callback: () => void | Promise<void>): void;
|
|
1769
|
-
terminate(): Promise<void>;
|
|
1770
|
-
}
|
|
1771
|
-
declare const Application: Token$2<Application>;
|
|
1772
|
-
interface Htmlable {
|
|
1773
|
-
toHtml(): string;
|
|
1774
|
-
}
|
|
1775
|
-
|
|
1776
|
-
/** Public method names of a controller (excludes non-function members). */
|
|
1777
|
-
type ActionMethods<C> = {
|
|
1778
|
-
[K in keyof C]: C[K] extends (...args: any[]) => unknown ? K : never;
|
|
1779
|
-
}[keyof C] & string;
|
|
1780
|
-
type ControllerAction<C> = readonly [Class<C>, ActionMethods<C>];
|
|
1781
|
-
type RouteClosure = (...args: any[]) => unknown;
|
|
1782
|
-
/** A class with __invoke(): Route.get('/counter', Counter) (single-action controllers, full-page Live components). */
|
|
1783
|
-
type InvokableClass = Class<{
|
|
1784
|
-
__invoke(...args: any[]): unknown;
|
|
1785
|
-
}>;
|
|
1786
|
-
type RouteAction = RouteClosure | ControllerAction<any> | InvokableClass;
|
|
1787
|
-
type MiddlewareReference = string | MiddlewareClass;
|
|
1788
|
-
interface Route {
|
|
1789
|
-
readonly methods: readonly string[];
|
|
1790
|
-
readonly uri: string;
|
|
1791
|
-
getName(): string | undefined;
|
|
1792
|
-
name(name: string): this;
|
|
1793
|
-
middleware(...middleware: Array<MiddlewareReference | readonly MiddlewareReference[]>): this;
|
|
1794
|
-
withoutMiddleware(...middleware: MiddlewareReference[]): this;
|
|
1795
|
-
where(parameter: string, pattern: string): this;
|
|
1796
|
-
where(patterns: Record<string, string>): this;
|
|
1797
|
-
}
|
|
1798
|
-
interface RouteRegistrar {
|
|
1799
|
-
prefix(prefix: string): RouteRegistrar;
|
|
1800
|
-
name(prefix: string): RouteRegistrar;
|
|
1801
|
-
middleware(...middleware: Array<MiddlewareReference | readonly MiddlewareReference[]>): RouteRegistrar;
|
|
1802
|
-
controller(controller: Class<unknown>): RouteRegistrar;
|
|
1803
|
-
group(routes: () => void | Promise<void>): Promise<void>;
|
|
1804
|
-
}
|
|
1805
|
-
interface ResourceOptions {
|
|
1806
|
-
only?: string[];
|
|
1807
|
-
except?: string[];
|
|
1808
|
-
parameters?: Record<string, string>;
|
|
1809
|
-
names?: Record<string, string>;
|
|
1810
|
-
}
|
|
1811
|
-
interface Router {
|
|
1812
|
-
get<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): Route;
|
|
1813
|
-
post<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): Route;
|
|
1814
|
-
put<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): Route;
|
|
1815
|
-
patch<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): Route;
|
|
1816
|
-
delete<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): Route;
|
|
1817
|
-
options<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): Route;
|
|
1818
|
-
any<C>(uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): Route;
|
|
1819
|
-
match<C>(methods: string[], uri: string, action: ControllerAction<C> | RouteClosure | InvokableClass | string): Route;
|
|
1820
|
-
redirect(from: string, to: string, status?: number): Route;
|
|
1821
|
-
view(uri: string, view: string, data?: Record<string, unknown>): Route;
|
|
1822
|
-
/** Route.inertia('/about', 'About', props): a GET route that renders an Inertia page (Laravel's Route::inertia). */
|
|
1823
|
-
inertia(uri: string, component: string, props?: Record<string, unknown>): Route;
|
|
1824
|
-
resource(name: string, controller: Class<unknown>, options?: ResourceOptions): void;
|
|
1825
|
-
apiResource(name: string, controller: Class<unknown>, options?: ResourceOptions): void;
|
|
1826
|
-
fallback(action: RouteAction): Route;
|
|
1827
|
-
prefix(prefix: string): RouteRegistrar;
|
|
1828
|
-
name(prefix: string): RouteRegistrar;
|
|
1829
|
-
middleware(...middleware: Array<MiddlewareReference | readonly MiddlewareReference[]>): RouteRegistrar;
|
|
1830
|
-
controller(controller: Class<unknown>): RouteRegistrar;
|
|
1831
|
-
/** Explicit model binding: Route.model('author', User). */
|
|
1832
|
-
model(parameter: string, model: Class<unknown>): void;
|
|
1833
|
-
/** Custom binding resolver. */
|
|
1834
|
-
bind(parameter: string, resolver: (value: string) => unknown | Promise<unknown>): void;
|
|
1835
|
-
pattern(parameter: string, pattern: string): void;
|
|
1836
|
-
/** Name a middleware class, e.g. aliasMiddleware('auth', Authenticate). */
|
|
1837
|
-
aliasMiddleware(name: string, middleware: MiddlewareClass): this;
|
|
1838
|
-
/** Define (or replace) a middleware group such as 'web' or 'api'. */
|
|
1839
|
-
middlewareGroup(name: string, middleware: MiddlewareReference[]): this;
|
|
1840
|
-
/** Append to a group unless it is already present. */
|
|
1841
|
-
pushMiddlewareToGroup(group: string, middleware: MiddlewareReference): this;
|
|
1842
|
-
getMiddlewareGroups(): Record<string, MiddlewareReference[]>;
|
|
1843
|
-
getRoutes(): readonly Route[];
|
|
1844
|
-
current(): Route | undefined;
|
|
1845
|
-
/** Match the request, bind parameters, run the route middleware and the action. Called by the Http kernel. */
|
|
1846
|
-
dispatch(request: HttpRequest): Promise<Response>;
|
|
1847
|
-
}
|
|
1848
|
-
declare const Router: Token$2<Router>;
|
|
1849
|
-
|
|
1850
|
-
type ErrorKind = 'Http' | 'Server' | 'ModelNotFound' | 'Validation' | 'Authentication' | 'Authorization' | 'TokenMismatch' | 'BindingResolution' | 'CircularDependency' | 'ContainerNotAvailable';
|
|
1851
|
-
/** Every error thrown by the framework implements this. The exception handler switches on `kind`. */
|
|
1852
|
-
interface OrielError extends Error {
|
|
1853
|
-
readonly kind: ErrorKind;
|
|
1854
|
-
/** HTTP status the error should render as, when relevant. */
|
|
1855
|
-
readonly status?: number;
|
|
1856
|
-
readonly headers?: Record<string, string>;
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
interface LiveSnapshot {
|
|
1860
|
-
data: Record<string, unknown>;
|
|
1861
|
-
memo: {
|
|
1862
|
-
id: string;
|
|
1863
|
-
/** ClassRegistry name of the component. */
|
|
1864
|
-
name: string;
|
|
1865
|
-
path: string;
|
|
1866
|
-
method: string;
|
|
1867
|
-
children: Record<string, [tag: string, id: string]>;
|
|
1868
|
-
errors: Record<string, string[]>;
|
|
1869
|
-
};
|
|
1870
|
-
/** HMAC-SHA256 of JSON(data + memo), keyed by APP_KEY. */
|
|
1871
|
-
checksum: string;
|
|
1872
|
-
}
|
|
1873
|
-
interface LiveEffects {
|
|
1874
|
-
html?: string;
|
|
1875
|
-
/** Browser events from this.dispatch(); `self` keeps one on this component, `to` sends it to one component name. */
|
|
1876
|
-
dispatches?: Array<{
|
|
1877
|
-
name: string;
|
|
1878
|
-
params: Record<string, unknown>;
|
|
1879
|
-
self?: true;
|
|
1880
|
-
to?: string;
|
|
1881
|
-
}>;
|
|
1882
|
-
/** Events this component listens to (@On, static listeners); sent with the first render. */
|
|
1883
|
-
listeners?: string[];
|
|
1884
|
-
redirect?: string;
|
|
1885
|
-
/** Follow `redirect` with o:navigate instead of a full page load. */
|
|
1886
|
-
redirectUsingNavigate?: true;
|
|
1887
|
-
returns?: unknown[];
|
|
1888
|
-
}
|
|
1889
|
-
interface LiveUpdateRequest {
|
|
1890
|
-
components: Array<{
|
|
1891
|
-
/** JSON-encoded LiveSnapshot. */
|
|
1892
|
-
snapshot: string;
|
|
1893
|
-
updates: Record<string, unknown>;
|
|
1894
|
-
calls: Array<{
|
|
1895
|
-
method: string;
|
|
1896
|
-
params: unknown[];
|
|
1897
|
-
}>;
|
|
1898
|
-
}>;
|
|
1899
|
-
}
|
|
1900
|
-
interface LiveUpdateResponse {
|
|
1901
|
-
components: Array<{
|
|
1902
|
-
snapshot: string;
|
|
1903
|
-
effects: LiveEffects;
|
|
1904
|
-
}>;
|
|
1905
|
-
}
|
|
1906
|
-
interface LiveManager {
|
|
1907
|
-
register(component: Class<unknown>, name?: string): void;
|
|
1908
|
-
/** Server-renders the first HTML (snapshot embedded). `key` identifies a child inside its parent (o:key). */
|
|
1909
|
-
mount(component: string | Class<unknown>, params?: Record<string, unknown>, key?: string): Promise<string>;
|
|
1910
|
-
/** Checks checksums and CSRF, then applies updates and calls, re-renders and returns new snapshots. */
|
|
1911
|
-
update(request: LiveUpdateRequest): Promise<LiveUpdateResponse>;
|
|
1912
|
-
/**
|
|
1913
|
-
* A full-page component (Route.get('/counter', Counter)): mounts `component` (a component instance) with the current route's parameters and
|
|
1914
|
-
* returns the response, its layout view or a redirect.
|
|
1915
|
-
*/
|
|
1916
|
-
page(component: object): Promise<unknown>;
|
|
1917
|
-
isLiveRequest(request: HttpRequest): boolean;
|
|
1918
|
-
}
|
|
1919
|
-
declare const LiveManager: Token$2<LiveManager>;
|
|
1920
|
-
|
|
1921
|
-
declare abstract class ServiceProvider implements ServiceProvider$3 {
|
|
1922
|
-
protected readonly app: Application$2;
|
|
1923
|
-
constructor(app: Application$2);
|
|
1924
|
-
register(): void;
|
|
1925
|
-
boot(): void | Promise<void>;
|
|
1926
|
-
/** Package defaults under `key`; values the app already set win (shallow merge, like Laravel). */
|
|
1927
|
-
protected mergeConfigFrom(defaults: Record<string, unknown>, key: string): void;
|
|
1928
|
-
}
|
|
1929
|
-
|
|
1930
1083
|
/** Marks Live component classes (Symbol.for, so two copies of the package agree). */
|
|
1931
1084
|
declare const COMPONENT: unique symbol;
|
|
1932
1085
|
/** A browser event queued by dispatch(). `to` is resolved to a component name when the effects are built. */
|
|
@@ -1938,8 +1091,11 @@ interface QueuedDispatch {
|
|
|
1938
1091
|
}
|
|
1939
1092
|
/** The validation errors of a component (Laravel's MessageBag), for render(): `this.errors.first('title')`. */
|
|
1940
1093
|
declare class ErrorBag implements MessageBag {
|
|
1094
|
+
#private;
|
|
1941
1095
|
private readonly messages;
|
|
1942
1096
|
constructor(messages: Record<string, string[]>);
|
|
1097
|
+
/** Adds to the component's errors, as addError() does. */
|
|
1098
|
+
add(key: string, message: string): void;
|
|
1943
1099
|
has(key: string): boolean;
|
|
1944
1100
|
first(key?: string): string | undefined;
|
|
1945
1101
|
get(key: string): string[];
|
|
@@ -1970,6 +1126,13 @@ declare abstract class Component {
|
|
|
1970
1126
|
static layout?: string;
|
|
1971
1127
|
/** The page title passed to the layout as `title`. */
|
|
1972
1128
|
static title?: string;
|
|
1129
|
+
/**
|
|
1130
|
+
* Livewire's #[Lazy]: every embed (and the full page) renders the placeholder first and mounts once the browser shows
|
|
1131
|
+
* it. `<Live component={…} lazy={false} />` mounts one at once. The placeholder is the component's
|
|
1132
|
+
* `placeholder(params)` method (TSX), else the `live.lazy_placeholder` view, else an empty `<div>`: give it the root
|
|
1133
|
+
* element the component renders.
|
|
1134
|
+
*/
|
|
1135
|
+
static lazy?: boolean;
|
|
1973
1136
|
/** Static fallbacks for runtimes without decorators: { event: 'method' }, locked names, computed getter names. */
|
|
1974
1137
|
static listeners?: Record<string, string>;
|
|
1975
1138
|
static locked?: string[];
|
|
@@ -1983,14 +1146,19 @@ declare abstract class Component {
|
|
|
1983
1146
|
redirect(url: string, options?: {
|
|
1984
1147
|
navigate?: boolean;
|
|
1985
1148
|
}): void;
|
|
1986
|
-
|
|
1149
|
+
/**
|
|
1150
|
+
* redirect() to a named route: `this.redirectRoute('posts.show', post, { navigate: true })`. Once `oriel
|
|
1151
|
+
* route:types` has run, the name and the route's parameters are checked, as route()'s are.
|
|
1152
|
+
*/
|
|
1153
|
+
redirectRoute<N extends RouteName>(name: N, ...args: RouteArguments<N, [options?: {
|
|
1987
1154
|
navigate?: boolean;
|
|
1988
|
-
}): void;
|
|
1155
|
+
}]>): void;
|
|
1989
1156
|
/**
|
|
1990
|
-
* Validates the public state. On success clears the error bag and returns the validated data
|
|
1991
|
-
*
|
|
1157
|
+
* Validates the public state. On success clears the error bag and returns the validated data, typed from the rules
|
|
1158
|
+
* (`await this.validate({ title: 'required|string' })` is `{ title: string }`); on failure fills the error bag and
|
|
1159
|
+
* throws (the rest of the action is skipped and the component re-renders with `errors`).
|
|
1992
1160
|
*/
|
|
1993
|
-
validate<
|
|
1161
|
+
validate<const R extends Rules>(rules: R, messages?: Record<string, string>, attributes?: Record<string, string>): Promise<InferValidatedType<R>>;
|
|
1994
1162
|
addError(key: string, message: string): void;
|
|
1995
1163
|
/** Clears every error, or only those of `keys`. */
|
|
1996
1164
|
resetErrorBag(...keys: string[]): void;
|
|
@@ -1999,6 +1167,13 @@ declare abstract class Component {
|
|
|
1999
1167
|
reset(...properties: string[]): void;
|
|
2000
1168
|
/** Keeps the current HTML: the response carries the new state but no `html` effect. */
|
|
2001
1169
|
skipRender(): void;
|
|
1170
|
+
/**
|
|
1171
|
+
* An action for an `o:` directive, typed against its method: `o:click={this.$action(this.delete, tag.id)}` writes
|
|
1172
|
+
* `delete(5)`, and a string where `delete` takes a number is a type error. The arguments are written as JSON, the
|
|
1173
|
+
* trailing `undefined` ones left out so the method's defaults apply. The method must be one of this component's
|
|
1174
|
+
* actions (a public method of its class, not a hook and not @Locked); anything else throws while rendering.
|
|
1175
|
+
*/
|
|
1176
|
+
$action<P extends unknown[]>(method: (...params: P) => unknown, ...params: NoInfer<P>): string;
|
|
2002
1177
|
/** A full-page component as a route action: Route.get('/counter', Counter). Route parameters go to mount(). */
|
|
2003
1178
|
__invoke(): Promise<unknown>;
|
|
2004
1179
|
}
|
|
@@ -2027,7 +1202,10 @@ declare class Testable<C extends Component = Component> {
|
|
|
2027
1202
|
private readonly manager;
|
|
2028
1203
|
private readonly scope;
|
|
2029
1204
|
private constructor();
|
|
2030
|
-
/**
|
|
1205
|
+
/**
|
|
1206
|
+
* Mounts `component` with `params`, as `<Live component={…} {...params} />` would. A lazy component mounts at once
|
|
1207
|
+
* (Livewire's withoutLazyLoading()); `{ lazy: true }` renders its placeholder, and `call('__lazyLoad', …)` loads it.
|
|
1208
|
+
*/
|
|
2031
1209
|
static create<C extends Component>(component: Class<C> | string, params?: Record<string, unknown>): Promise<Testable<C>>;
|
|
2032
1210
|
/** The component instance after the last request. */
|
|
2033
1211
|
instance(): C;
|
|
@@ -2037,7 +1215,14 @@ declare class Testable<C extends Component = Component> {
|
|
|
2037
1215
|
html(): string;
|
|
2038
1216
|
/** The effects of the last request. */
|
|
2039
1217
|
effects(): LiveEffects;
|
|
1218
|
+
/**
|
|
1219
|
+
* Sets public properties through an update. A file (a FakeFile) or an array of files is uploaded as `o:model` on a
|
|
1220
|
+
* file input does it: the upload rules, the temporary disk, then a TemporaryUploadedFile (or an array) in the
|
|
1221
|
+
* property, or the upload's errors on it (Livewire's).
|
|
1222
|
+
*/
|
|
2040
1223
|
set(path: string | Record<string, unknown>, value?: unknown): Promise<this>;
|
|
1224
|
+
/** Uploads `files` into the property `name` (an array when `multiple`), as the browser's upload calls do. */
|
|
1225
|
+
upload(name: string, files: readonly Blob[], multiple?: boolean): Promise<this>;
|
|
2041
1226
|
call(method: string, ...params: unknown[]): Promise<this>;
|
|
2042
1227
|
toggle(path: string): Promise<this>;
|
|
2043
1228
|
/** Dispatches an event to this component, as the browser does for its listeners. */
|
|
@@ -2050,6 +1235,9 @@ declare class Testable<C extends Component = Component> {
|
|
|
2050
1235
|
assertDontSee(...values: string[]): this;
|
|
2051
1236
|
/** Each value appears in the rendered HTML as written (not escaped). */
|
|
2052
1237
|
assertSeeHtml(...values: string[]): this;
|
|
1238
|
+
/** Each value, HTML-escaped, appears in the rendered text: the HTML with its tags stripped (Livewire's assertSeeText). */
|
|
1239
|
+
assertSeeText(...values: string[]): this;
|
|
1240
|
+
assertDontSeeText(...values: string[]): this;
|
|
2053
1241
|
assertDispatched(name: string, params?: Record<string, unknown>): this;
|
|
2054
1242
|
assertNotDispatched(name: string): this;
|
|
2055
1243
|
/** The error bag has errors for every key given (or any error at all with no keys). */
|
|
@@ -2067,6 +1255,11 @@ interface LiveProps {
|
|
|
2067
1255
|
component: Class<Component> | string;
|
|
2068
1256
|
/** Identifies a child inside its parent across re-renders (Livewire's :key / wire:key). */
|
|
2069
1257
|
'o:key'?: string | number;
|
|
1258
|
+
/**
|
|
1259
|
+
* Renders the placeholder and mounts the component once it scrolls into view (`'on-load'`: once the page starts);
|
|
1260
|
+
* `false` mounts a `static lazy` component at once.
|
|
1261
|
+
*/
|
|
1262
|
+
lazy?: boolean | 'on-load';
|
|
2070
1263
|
[param: string]: unknown;
|
|
2071
1264
|
}
|
|
2072
1265
|
/** Blade's @livewire('counter', ['count' => 3], key('c1')): the component's first render, as trusted HTML. */
|
|
@@ -2109,10 +1302,25 @@ declare class LiveComponentManager implements LiveManager {
|
|
|
2109
1302
|
isLiveRequest(request: HttpRequest): boolean;
|
|
2110
1303
|
/** The first render: HTML with o:id, o:snapshot and o:effects on the root element. */
|
|
2111
1304
|
mount(component: string | Class<unknown>, params?: Record<string, unknown>, key?: string): Promise<string>;
|
|
2112
|
-
|
|
1305
|
+
/**
|
|
1306
|
+
* Mounts a component: boot(), the params into its properties, mount(params), then its first render. A lazy one
|
|
1307
|
+
* (`lazy` in the params, or `static lazy`) renders its placeholder instead and mounts when the browser loads it.
|
|
1308
|
+
*/
|
|
1309
|
+
mountComponent(component: string | Class<unknown>, embedParams?: Record<string, unknown>, existing?: Component): Promise<ComponentResult>;
|
|
1310
|
+
/**
|
|
1311
|
+
* A lazy component's first render (Livewire's): its placeholder, with the state it has before mount() and the mount
|
|
1312
|
+
* params signed for the `__lazyLoad` call the browser makes when it shows it (`o:lazy`, or `o:lazy-on-load`).
|
|
1313
|
+
*/
|
|
1314
|
+
private mountPlaceholder;
|
|
2113
1315
|
/** Applies each component's updates and calls, re-renders it and returns its new snapshot and effects. */
|
|
2114
1316
|
update(request: LiveUpdateRequest): Promise<LiveUpdateResponse>;
|
|
2115
1317
|
updateComponent(snapshotJson: string, updates: Record<string, unknown>, calls: Call[]): Promise<ComponentResult>;
|
|
1318
|
+
/**
|
|
1319
|
+
* The mount params and placeholder tag of a `__lazyLoad` request, or undefined for any other update. The load comes
|
|
1320
|
+
* alone (no updates, no other call: the browser sends it in a request of its own) and its payload must be the one
|
|
1321
|
+
* signed for this component: anything else is refused as corrupt (a 403) before the component boots.
|
|
1322
|
+
*/
|
|
1323
|
+
private lazyLoad;
|
|
2116
1324
|
/**
|
|
2117
1325
|
* The route action of POST /oriel/live/update. Each component's update runs behind the persistent middleware of the
|
|
2118
1326
|
* route that rendered its page (Livewire's): `auth`, `verified`, `guest` and `can`, with the page route's parameters
|
|
@@ -2131,7 +1339,7 @@ declare class LiveComponentManager implements LiveManager {
|
|
|
2131
1339
|
/** Makes every computed getter (static `computed` too) cache its value for the rest of the request. */
|
|
2132
1340
|
private prepareComputed;
|
|
2133
1341
|
private applyUpdate;
|
|
2134
|
-
/** Runs one call from the browser: a magic action, an event, or a public method. Returns its return value. */
|
|
1342
|
+
/** Runs one call from the browser: a magic action, an event, an upload call, or a public method. Returns its return value. */
|
|
2135
1343
|
private call;
|
|
2136
1344
|
/**
|
|
2137
1345
|
* Renders the component (rendering/rendered hooks, nested children tracked) and checks for a single root. A
|
|
@@ -2151,10 +1359,11 @@ declare class LiveComponentManager implements LiveManager {
|
|
|
2151
1359
|
declare const UPDATE_URI = "/oriel/live/update";
|
|
2152
1360
|
/**
|
|
2153
1361
|
* Binds the LiveManager and the PaginationState that WithPagination components answer, merges the `live` config,
|
|
2154
|
-
* registers POST /oriel/live/update (named `live.update`, in the `web` group: sessions and CSRF apply), the
|
|
2155
|
-
* command, and the
|
|
1362
|
+
* registers POST /oriel/live/update (named `live.update`, in the `web` group: sessions and CSRF apply), the upload and
|
|
1363
|
+
* preview routes of WithFileUploads (`live.upload-file`, `live.preview-file`), the make:live command, and the
|
|
1364
|
+
* components under app/Live.
|
|
2156
1365
|
*/
|
|
2157
|
-
declare class LiveServiceProvider extends ServiceProvider {
|
|
1366
|
+
declare class LiveServiceProvider extends ServiceProvider$1 {
|
|
2158
1367
|
register(): void;
|
|
2159
1368
|
boot(): Promise<void>;
|
|
2160
1369
|
}
|
|
@@ -2202,6 +1411,108 @@ declare class InvalidLiveRequestError extends LiveError {
|
|
|
2202
1411
|
readonly kind: ErrorKind;
|
|
2203
1412
|
readonly status: number;
|
|
2204
1413
|
}
|
|
1414
|
+
/** An upload or preview URL whose signature is missing, wrong or expired (Livewire's 401). Nothing is read or stored. */
|
|
1415
|
+
declare class InvalidUploadSignatureError extends LiveError {
|
|
1416
|
+
readonly name: string;
|
|
1417
|
+
readonly kind: ErrorKind;
|
|
1418
|
+
readonly status: number;
|
|
1419
|
+
constructor();
|
|
1420
|
+
}
|
|
1421
|
+
/** A preview of a temporary upload that is no longer on the disk (cleaned up, or stored and deleted). */
|
|
1422
|
+
declare class TemporaryFileNotFoundError extends LiveError {
|
|
1423
|
+
readonly name: string;
|
|
1424
|
+
readonly kind: ErrorKind;
|
|
1425
|
+
readonly status: number;
|
|
1426
|
+
constructor(filename: string);
|
|
1427
|
+
}
|
|
1428
|
+
/** temporaryUrl() on an upload whose type has no preview (live.temporary_file_upload.preview_mimes). */
|
|
1429
|
+
declare class FileNotPreviewableError extends LiveError {
|
|
1430
|
+
readonly name: string;
|
|
1431
|
+
constructor(extension: string);
|
|
1432
|
+
}
|
|
1433
|
+
/** The errors an upload came back with (`_uploadErrored`): the component re-renders with them on the property. */
|
|
1434
|
+
declare class UploadValidationError extends LiveError {
|
|
1435
|
+
readonly errors: Record<string, string[]>;
|
|
1436
|
+
readonly name: string;
|
|
1437
|
+
readonly kind: ErrorKind;
|
|
1438
|
+
readonly status: number;
|
|
1439
|
+
readonly errorBag: string;
|
|
1440
|
+
constructor(errors: Record<string, string[]>);
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
/**
|
|
1444
|
+
* Livewire's `temporary_file_upload` settings, read from config `live.temporary_file_upload.*` (each one falls back on
|
|
1445
|
+
* its own): the disk (the default filesystem disk), the directory on it, the rules every upload must pass, the upload
|
|
1446
|
+
* route's middleware, the types a preview is served for, how long an upload URL lasts (minutes), and whether a finished
|
|
1447
|
+
* upload removes the temporary files older than a day.
|
|
1448
|
+
*/
|
|
1449
|
+
declare const TEMPORARY_UPLOAD_DEFAULTS: {
|
|
1450
|
+
disk: string | null;
|
|
1451
|
+
directory: string;
|
|
1452
|
+
rules: string | string[];
|
|
1453
|
+
middleware: string | string[];
|
|
1454
|
+
preview_mimes: string[];
|
|
1455
|
+
max_upload_time: number;
|
|
1456
|
+
cleanup: boolean;
|
|
1457
|
+
};
|
|
1458
|
+
/** What a temporary upload is: its stored name on the temporary disk and what the browser sent (signed with it). */
|
|
1459
|
+
interface TemporaryFileData {
|
|
1460
|
+
/** A random 40-character name with the extension its bytes showed: `live-tmp/<filename>` on the temporary disk. */
|
|
1461
|
+
filename: string;
|
|
1462
|
+
/** The name the browser gave the file. */
|
|
1463
|
+
name: string;
|
|
1464
|
+
size: number;
|
|
1465
|
+
/** The MIME type the browser claimed. */
|
|
1466
|
+
type: string;
|
|
1467
|
+
/** The extension of the upload's own type (its bytes, else a plain claimed extension), or ''. */
|
|
1468
|
+
extension: string;
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Livewire's TemporaryUploadedFile: a file the browser uploaded to the temporary directory before an action stores
|
|
1472
|
+
* it. A WithFileUploads component's property holds one (or an array of them) once `o:model` on a file input has
|
|
1473
|
+
* uploaded it: validate it like any upload (`'photo' => 'image|max:1024'`), preview it with `temporaryUrl()`, then
|
|
1474
|
+
* `store()` it. It travels in the component's snapshot as its data, signed with the rest.
|
|
1475
|
+
*/
|
|
1476
|
+
declare class TemporaryUploadedFile implements UploadedFile {
|
|
1477
|
+
#private;
|
|
1478
|
+
readonly filename: string;
|
|
1479
|
+
readonly clientName: string;
|
|
1480
|
+
readonly mimeType: string;
|
|
1481
|
+
readonly size: number;
|
|
1482
|
+
constructor(data: TemporaryFileData);
|
|
1483
|
+
/** What the snapshot carries. */
|
|
1484
|
+
toData(): TemporaryFileData;
|
|
1485
|
+
/** The file's path on the temporary disk. */
|
|
1486
|
+
get path(): string;
|
|
1487
|
+
/** The extension of the upload's own type, as FormUploadedFile's extension(): what putFile() names a stored copy by. */
|
|
1488
|
+
extension(): string;
|
|
1489
|
+
/** The extension of the name the browser gave the file, lower-cased ('' without one). */
|
|
1490
|
+
clientExtension(): string;
|
|
1491
|
+
/** A random 40-character name with extension(), as FormUploadedFile's. */
|
|
1492
|
+
hashName(): string;
|
|
1493
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
1494
|
+
text(): Promise<string>;
|
|
1495
|
+
/** The file's bytes from the temporary disk, opened on the first read. */
|
|
1496
|
+
stream(): ReadableStream<Uint8Array>;
|
|
1497
|
+
/** Stores a copy under a random name in `directory`, on `disk` (by default the temporary disk, as Livewire's). */
|
|
1498
|
+
store(directory: string, disk?: string): Promise<string>;
|
|
1499
|
+
storeAs(directory: string, name: string, disk?: string): Promise<string>;
|
|
1500
|
+
exists(): Promise<boolean>;
|
|
1501
|
+
/** Removes the temporary file (a stored copy stays). */
|
|
1502
|
+
delete(): Promise<boolean>;
|
|
1503
|
+
/** Whether temporaryUrl() serves this file: its type is in `live.temporary_file_upload.preview_mimes`. */
|
|
1504
|
+
isPreviewable(): boolean;
|
|
1505
|
+
/**
|
|
1506
|
+
* A signed link to the file for `<img src>` or `<video src>` before it is stored. It lasts until the end of the hour
|
|
1507
|
+
* at least 30 minutes away (Livewire's), so a re-render keeps the same link and the browser doesn't reload it.
|
|
1508
|
+
*/
|
|
1509
|
+
temporaryUrl(): string;
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
/** Where the browser POSTs a WithFileUploads component's files (Livewire's /livewire/upload-file), named live.upload-file. */
|
|
1513
|
+
declare const UPLOAD_URI = "/oriel/live/upload-file";
|
|
1514
|
+
/** Where temporaryUrl() links lead (Livewire's /livewire/preview-file/{filename}), named live.preview-file. */
|
|
1515
|
+
declare const PREVIEW_URI = "/oriel/live/preview-file";
|
|
2205
1516
|
|
|
2206
1517
|
/** The route middleware an update re-applies by default (config live.persistent_middleware), by alias. */
|
|
2207
1518
|
declare const PERSISTENT_MIDDLEWARE: string[];
|
|
@@ -2237,6 +1548,14 @@ interface Paginated {
|
|
|
2237
1548
|
*/
|
|
2238
1549
|
declare function WithPagination<TBase extends ComponentConstructor>(Base: TBase): TBase & (abstract new (...args: any[]) => Paginated);
|
|
2239
1550
|
|
|
1551
|
+
/**
|
|
1552
|
+
* Livewire's WithFileUploads: `class Profile extends WithFileUploads(Component)`. A file input with `o:model="photo"`
|
|
1553
|
+
* uploads the file to the temporary directory as soon as it is picked, then sets `photo` to a TemporaryUploadedFile
|
|
1554
|
+
* (`<input type="file" multiple>` sets an array), through `updatingPhoto()`/`updatedPhoto()` like any update. Validate
|
|
1555
|
+
* it with the file rules, preview it with `temporaryUrl()`, store it with `store()`.
|
|
1556
|
+
*/
|
|
1557
|
+
declare function WithFileUploads<TBase extends ComponentConstructor>(Base: TBase): TBase;
|
|
1558
|
+
|
|
2240
1559
|
/**
|
|
2241
1560
|
* What <Pagination> reads from a paginator. Structural, since Live can't import Database: paginate()'s
|
|
2242
1561
|
* LengthAwarePaginator (with lastPage(), so page buttons) and simplePaginate()'s Paginator (Previous and Next only).
|
|
@@ -2264,4 +1583,4 @@ interface PaginationProps {
|
|
|
2264
1583
|
*/
|
|
2265
1584
|
declare function Pagination({ paginator, class: className }: PaginationProps): Htmlable;
|
|
2266
1585
|
|
|
2267
|
-
export { type
|
|
1586
|
+
export { type DatabaseTestOptions as $, UploadValidationError as A, BusFake as B, Component as C, WithPagination as D, EventFake as E, FileNotPreviewableError as F, componentName as G, live as H, InvalidLiveRequestError as I, persistentMiddleware as J, AnonymousNotifiable as K, Live as L, MailFake as M, NotificationFake as N, On as O, PERSISTENT_MIDDLEWARE as P, QueueFake as Q, AssertableInertia as R, StorageFake as S, TEMPORARY_UPLOAD_DEFAULTS as T, UPDATE_URI as U, AssertableJson as V, WithFileUploads as W, type BatchRecord as X, type BootOptions as Y, type CountOrFilter as Z, DatabaseMigrations as _, type ComponentResult as a, DatabaseTransactions as a0, type DispatchedEvent as a1, type ExpectedErrors as a2, type ExpectedListener as a3, FakeDisk as a4, FakeFile as a5, HttpClient as a6, InteractsWithApplication as a7, InteractsWithConsole as a8, InteractsWithDatabase as a9, cookiePrefix as aA, decryptCookie as aB, encryptCookie as aC, flatten as aD, freezeSecond as aE, freezeTime as aF, guessMimeType as aG, inertiaPageOf as aH, install as aI, isExpired as aJ, matches as aK, nameOf as aL, recordingExceptionHandler as aM, recordingViewFactory as aN, responseCookies as aO, runCommand as aP, travel as aQ, travelBack as aR, travelTo as aS, usingInMemoryDatabase as aT, InteractsWithTime as aa, type JsonStructure as ab, MailRecord as ac, MakesHttpRequests as ad, PendingCommand as ae, type PushedJob as af, RefreshDatabase as ag, RefreshDatabaseState as ah, type RequestData as ai, type RequestOptions as aj, type ResponseContext as ak, type ResponseCookie as al, type SentNotification as am, TESTING_ENVIRONMENT as an, type TableOrModel as ao, type Target as ap, TestCase as aq, type TestHooks as ar, TestResponse as as, type TestTrait as at, type TravelDate as au, Wormhole as av, actingAsAuthFactory as aw, addresses as ax, applyEnvironment as ay, cookieHeader as az, Computed as b, CorruptComponentPayloadError as c, ErrorBag as d, InvalidUploadSignatureError as e, LiveComponentManager as f, LiveComponentNotFoundError as g, LiveError as h, type LiveProps as i, LiveServiceProvider as j, Locked as k, MethodNotCallableError as l, PREVIEW_URI as m, type Paginated as n, Pagination as o, type PaginationProps as p, type PaginationSource as q, PendingEvent as r, type PersistentMiddleware as s, PropertyNotUpdatableError as t, type TemporaryFileData as u, TemporaryFileNotFoundError as v, TemporaryUploadedFile as w, TestRequestScope as x, Testable as y, UPLOAD_URI as z };
|