@orieljs/framework 0.1.0-alpha.13 → 0.1.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OTCTQVDQ.js → chunk-7GPMFMS7.js} +349 -67
- package/dist/chunk-7GPMFMS7.js.map +1 -0
- package/dist/{chunk-CKH4KCYF.js → chunk-BKA5F3TH.js} +1 -1
- package/dist/{chunk-CKH4KCYF.js.map → chunk-BKA5F3TH.js.map} +1 -1
- package/dist/{chunk-6GMXKQ6O.js → chunk-FVI6X3VJ.js} +55 -2
- package/dist/chunk-FVI6X3VJ.js.map +1 -0
- package/dist/{chunk-ZRTWDJKD.js → chunk-GCMPAXIK.js} +98 -4
- package/dist/chunk-GCMPAXIK.js.map +1 -0
- package/dist/contracts.d.ts +4 -1
- package/dist/contracts.js +1 -1
- package/dist/{index.d-WQpfdIbG.d.ts → index.d-lffxurFs.d.ts} +10 -1
- package/dist/index.d.ts +233 -37
- package/dist/index.js +823 -307
- package/dist/index.js.map +1 -1
- package/dist/{jsx-runtime-6um4Mwfb.d.ts → jsx-runtime-Bc5KJzwb.d.ts} +1 -1
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.js +3 -3
- package/dist/{testing-B8NOiQC9.d.ts → testing-CVpo7aRl.d.ts} +41 -7
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +5 -3
- package/docs/authentication.md +40 -1
- package/docs/console.md +16 -5
- package/docs/database-testing.md +21 -0
- package/docs/database.md +17 -2
- package/docs/deployment.md +12 -3
- package/docs/eloquent-factories.md +3 -0
- package/docs/eloquent-observers.md +2 -0
- package/docs/eloquent-relationships.md +8 -0
- package/docs/eloquent.md +6 -0
- package/docs/encryption.md +2 -0
- package/docs/export.md +3 -3
- package/docs/inertia.md +2 -1
- package/docs/installation.md +4 -1
- package/docs/lifecycle.md +5 -4
- package/docs/live-tests.md +20 -0
- package/docs/live.md +2 -0
- package/docs/mail.md +4 -2
- package/docs/navigation.json +4 -0
- package/docs/pagination.md +10 -0
- package/docs/providers.md +1 -1
- package/docs/queues.md +6 -0
- package/docs/responses.md +2 -1
- package/docs/routing.md +33 -0
- package/docs/scheduling.md +2 -0
- package/docs/session.md +19 -2
- package/docs/starter-kits.md +4 -0
- package/docs/storage.md +21 -3
- package/docs/testing.md +9 -6
- package/docs/two-factor.md +14 -4
- package/docs/upgrade.md +73 -0
- package/docs/views.md +2 -0
- package/docs/vite.md +19 -1
- package/package.json +54 -38
- package/dist/chunk-6GMXKQ6O.js.map +0 -1
- package/dist/chunk-OTCTQVDQ.js.map +0 -1
- package/dist/chunk-ZRTWDJKD.js.map +0 -1
|
@@ -9,8 +9,9 @@ import {
|
|
|
9
9
|
currentContainer,
|
|
10
10
|
facade,
|
|
11
11
|
fileType_exports,
|
|
12
|
-
inject
|
|
13
|
-
|
|
12
|
+
inject,
|
|
13
|
+
isPublicAsset
|
|
14
|
+
} from "./chunk-FVI6X3VJ.js";
|
|
14
15
|
import {
|
|
15
16
|
Application,
|
|
16
17
|
AuthFactory,
|
|
@@ -47,7 +48,7 @@ import {
|
|
|
47
48
|
ValidationFactory,
|
|
48
49
|
ViewFactory,
|
|
49
50
|
token
|
|
50
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-BKA5F3TH.js";
|
|
51
52
|
|
|
52
53
|
// ../Config/dist/index.js
|
|
53
54
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -184,12 +185,14 @@ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } fr
|
|
|
184
185
|
var FIRST = "abcdefghijklmnopqrstuvwxyz";
|
|
185
186
|
var REST = `${FIRST}0123456789`;
|
|
186
187
|
var CLASS_ATTRIBUTE = /^(class|o:[^\s=]*-class[^\s=]*)$/i;
|
|
188
|
+
var ALPINE_EXPRESSION = /^(:|x-bind:)class$/i;
|
|
189
|
+
var ALPINE_CLASS_LIST = /^x-transition:(enter|leave)(-start|-end)?$/i;
|
|
187
190
|
var RAW_TEXT = /* @__PURE__ */ new Set(["script", "style", "textarea", "title", "xmp", "noembed", "noframes"]);
|
|
188
191
|
function rewriteHtml(html, map) {
|
|
189
192
|
if (Object.keys(map).length === 0) return html;
|
|
190
|
-
return replaceHtmlClasses(html, (token2) => map[decodeEntities(token2)] ?? token2);
|
|
193
|
+
return replaceHtmlClasses(html, (token2) => map[decodeEntities(token2)] ?? token2, { alpine: true });
|
|
191
194
|
}
|
|
192
|
-
function replaceHtmlClasses(html, replace) {
|
|
195
|
+
function replaceHtmlClasses(html, replace, options = {}) {
|
|
193
196
|
let out = "";
|
|
194
197
|
let last = 0;
|
|
195
198
|
let i = 0;
|
|
@@ -222,13 +225,21 @@ function replaceHtmlClasses(html, replace) {
|
|
|
222
225
|
const quote2 = html[j] === '"' || html[j] === "'" ? html[j] : "";
|
|
223
226
|
const valueStart = quote2 === "" ? j : j + 1;
|
|
224
227
|
const valueEnd = quote2 === "" ? unquotedEnd(html, valueStart) : indexOrEnd(html, quote2, valueStart);
|
|
225
|
-
if (CLASS_ATTRIBUTE.test(name)) {
|
|
228
|
+
if (CLASS_ATTRIBUTE.test(name) || options.alpine && ALPINE_CLASS_LIST.test(name)) {
|
|
226
229
|
const value = html.slice(valueStart, valueEnd);
|
|
227
230
|
const renamed = value.replace(/\S+/g, replace);
|
|
228
231
|
if (renamed !== value) {
|
|
229
232
|
out += html.slice(last, valueStart) + renamed;
|
|
230
233
|
last = valueEnd;
|
|
231
234
|
}
|
|
235
|
+
} else if (options.alpine && ALPINE_EXPRESSION.test(name)) {
|
|
236
|
+
const raw = html.slice(valueStart, valueEnd);
|
|
237
|
+
const decoded = decodeEntities(raw);
|
|
238
|
+
const renamed = rewriteClassExpression(decoded, replace);
|
|
239
|
+
if (renamed !== decoded) {
|
|
240
|
+
out += html.slice(last, valueStart) + (raw === decoded ? renamed : encodeAttribute(renamed));
|
|
241
|
+
last = valueEnd;
|
|
242
|
+
}
|
|
232
243
|
}
|
|
233
244
|
j = quote2 === "" ? valueEnd : valueEnd + 1;
|
|
234
245
|
}
|
|
@@ -242,6 +253,97 @@ function replaceHtmlClasses(html, replace) {
|
|
|
242
253
|
}
|
|
243
254
|
return out + html.slice(last);
|
|
244
255
|
}
|
|
256
|
+
var ATTRIBUTE_ESCAPES = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
257
|
+
var encodeAttribute = (value) => value.replace(/[&<>"']/g, (character) => ATTRIBUTE_ESCAPES[character]);
|
|
258
|
+
function rewriteClassExpression(expression, replace) {
|
|
259
|
+
let out = "";
|
|
260
|
+
let previous = "";
|
|
261
|
+
let i = 0;
|
|
262
|
+
while (i < expression.length) {
|
|
263
|
+
const character = expression[i];
|
|
264
|
+
if (character === "`") {
|
|
265
|
+
const end = templateEnd(expression, i);
|
|
266
|
+
out += `\`${rewriteTemplate(expression.slice(i + 1, end), replace)}${expression[end] ?? ""}`;
|
|
267
|
+
previous = character;
|
|
268
|
+
i = end + 1;
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (character === "'" || character === '"') {
|
|
272
|
+
let end = i + 1;
|
|
273
|
+
while (end < expression.length && expression[end] !== character) end += expression[end] === "\\" ? 2 : 1;
|
|
274
|
+
const body = expression.slice(i + 1, end);
|
|
275
|
+
const compared = /[=!]=$/.test(out.trimEnd()) || /^\s*[=!]=/.test(expression.slice(end + 1));
|
|
276
|
+
const untouched = compared || body.includes("\\");
|
|
277
|
+
out += character + (untouched ? body : body.replace(/\S+/g, replace)) + (expression[end] ?? "");
|
|
278
|
+
previous = character;
|
|
279
|
+
i = end + 1;
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (/[A-Za-z_$]/.test(character)) {
|
|
283
|
+
let end = i + 1;
|
|
284
|
+
while (end < expression.length && /[\w$-]/.test(expression[end]) && !(expression[end] === "-" && !/[\w$]/.test(expression[end + 1] ?? ""))) end++;
|
|
285
|
+
const word = expression.slice(i, end);
|
|
286
|
+
const isKey = (previous === "{" || previous === ",") && /^\s*:/.test(expression.slice(end));
|
|
287
|
+
const renamed = isKey ? replace(word) : word;
|
|
288
|
+
out += renamed === word || /^[A-Za-z_$][\w$]*$/.test(renamed) ? renamed : `'${renamed}'`;
|
|
289
|
+
previous = "word";
|
|
290
|
+
i = end;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (!/\s/.test(character)) previous = character;
|
|
294
|
+
out += character;
|
|
295
|
+
i++;
|
|
296
|
+
}
|
|
297
|
+
return out;
|
|
298
|
+
}
|
|
299
|
+
function templateEnd(code, start) {
|
|
300
|
+
let i = start + 1;
|
|
301
|
+
while (i < code.length && code[i] !== "`") {
|
|
302
|
+
if (code[i] === "\\") i += 2;
|
|
303
|
+
else if (code.startsWith("${", i)) i = substitutionEnd(code, i + 2) + 1;
|
|
304
|
+
else i++;
|
|
305
|
+
}
|
|
306
|
+
return i;
|
|
307
|
+
}
|
|
308
|
+
function substitutionEnd(code, start) {
|
|
309
|
+
let depth = 0;
|
|
310
|
+
let i = start;
|
|
311
|
+
while (i < code.length) {
|
|
312
|
+
const character = code[i];
|
|
313
|
+
if (character === "'" || character === '"') {
|
|
314
|
+
i++;
|
|
315
|
+
while (i < code.length && code[i] !== character) i += code[i] === "\\" ? 2 : 1;
|
|
316
|
+
} else if (character === "`") {
|
|
317
|
+
i = templateEnd(code, i);
|
|
318
|
+
} else if (character === "{") {
|
|
319
|
+
depth++;
|
|
320
|
+
} else if (character === "}") {
|
|
321
|
+
if (depth === 0) return i;
|
|
322
|
+
depth--;
|
|
323
|
+
}
|
|
324
|
+
i++;
|
|
325
|
+
}
|
|
326
|
+
return i;
|
|
327
|
+
}
|
|
328
|
+
function rewriteTemplate(body, replace) {
|
|
329
|
+
if (body.includes("\\")) return body;
|
|
330
|
+
let out = "";
|
|
331
|
+
let i = 0;
|
|
332
|
+
while (i < body.length) {
|
|
333
|
+
const open = body.indexOf("${", i);
|
|
334
|
+
const text = body.slice(i, open === -1 ? body.length : open);
|
|
335
|
+
out += text.replace(/\S+/g, (word, offset) => {
|
|
336
|
+
const gluedBefore = offset === 0 && i > 0;
|
|
337
|
+
const gluedAfter = offset + word.length === text.length && open !== -1;
|
|
338
|
+
return gluedBefore || gluedAfter ? word : replace(word);
|
|
339
|
+
});
|
|
340
|
+
if (open === -1) break;
|
|
341
|
+
const close = substitutionEnd(body, open + 2);
|
|
342
|
+
out += `\${${rewriteClassExpression(body.slice(open + 2, close), replace)}}`;
|
|
343
|
+
i = close + 1;
|
|
344
|
+
}
|
|
345
|
+
return out;
|
|
346
|
+
}
|
|
245
347
|
function attributeNameEnd(html, i) {
|
|
246
348
|
let j = i + 1;
|
|
247
349
|
while (j < html.length && !/[\s/>=]/.test(html[j])) j++;
|
|
@@ -700,7 +802,7 @@ var Application2 = class _Application extends Container2 {
|
|
|
700
802
|
this.singleton(ClassNames, () => new ClassNameMap(this));
|
|
701
803
|
}
|
|
702
804
|
base;
|
|
703
|
-
version = "0.1.0-alpha.
|
|
805
|
+
version = "0.1.0-alpha.15";
|
|
704
806
|
providers = [];
|
|
705
807
|
bootingCallbacks = [];
|
|
706
808
|
bootedCallbacks = [];
|
|
@@ -880,7 +982,7 @@ import { readFile } from "fs/promises";
|
|
|
880
982
|
import { fileURLToPath } from "url";
|
|
881
983
|
import { existsSync as existsSync4, lstatSync, readdirSync as readdirSync2, statSync as statSync3 } from "fs";
|
|
882
984
|
import { cp, mkdir, mkdtemp, rename, rm, writeFile } from "fs/promises";
|
|
883
|
-
import { basename as basename2, dirname, join as join5, resolve as resolve2 } from "path";
|
|
985
|
+
import { basename as basename2, dirname, join as join5, relative as relative2, resolve as resolve2 } from "path";
|
|
884
986
|
import { createReadStream as createReadStream2 } from "fs";
|
|
885
987
|
import { stat as stat2 } from "fs/promises";
|
|
886
988
|
import { Readable as Readable2 } from "stream";
|
|
@@ -2364,7 +2466,6 @@ function applyExceptionCallbacks(app, handler) {
|
|
|
2364
2466
|
const configurator = new ExceptionsConfiguration(handler);
|
|
2365
2467
|
for (const callback of app.make(ExceptionCallbacks)) callback(configurator);
|
|
2366
2468
|
}
|
|
2367
|
-
var HIDDEN_SEGMENT = /^\.|\.(ts|tsx|mts|cts)$|[. ]$/i;
|
|
2368
2469
|
async function servePublicFile(publicPath, request2) {
|
|
2369
2470
|
if (request2.method !== "GET" && request2.method !== "HEAD") return void 0;
|
|
2370
2471
|
let pathname;
|
|
@@ -2377,7 +2478,7 @@ async function servePublicFile(publicPath, request2) {
|
|
|
2377
2478
|
const root = resolve(publicPath);
|
|
2378
2479
|
const file = resolve(root, `.${pathname}`);
|
|
2379
2480
|
if (!file.startsWith(root + sep)) return void 0;
|
|
2380
|
-
if (relative(root, file)
|
|
2481
|
+
if (!isPublicAsset(relative(root, file))) return void 0;
|
|
2381
2482
|
const info = await stat2(file).catch(() => void 0);
|
|
2382
2483
|
if (info === void 0 || !info.isFile()) return void 0;
|
|
2383
2484
|
const type = mimeFromExtension(file);
|
|
@@ -2482,7 +2583,7 @@ async function exportSite(app, options) {
|
|
|
2482
2583
|
const staging = await mkdtemp(join5(dirname(output), `.${basename2(output)}-`));
|
|
2483
2584
|
try {
|
|
2484
2585
|
if (publicPath !== void 0 && existsSync4(publicPath)) {
|
|
2485
|
-
await cp(publicPath, staging, { recursive: true, filter: (source) => basename2(source) !== "hot" && !lstatSync(source).isSymbolicLink() });
|
|
2586
|
+
await cp(publicPath, staging, { recursive: true, filter: (source) => basename2(source) !== "hot" && !lstatSync(source).isSymbolicLink() && isPublicAsset(relative2(publicPath, source)) });
|
|
2486
2587
|
}
|
|
2487
2588
|
const excluded = (path) => options.exclude.some((pattern) => wildcard(pattern).test(path));
|
|
2488
2589
|
const isPublicFile = (path) => publicPath !== void 0 && path !== "/" && isFile(join5(publicPath, path));
|
|
@@ -2558,6 +2659,8 @@ async function serveBun(app, options) {
|
|
|
2558
2659
|
const server = bun.serve({
|
|
2559
2660
|
port: options.port,
|
|
2560
2661
|
hostname: options.hostname,
|
|
2662
|
+
// Bun closes a connection idle for 10 seconds by default, a slow page included; 255 is the most it allows.
|
|
2663
|
+
idleTimeout: 255,
|
|
2561
2664
|
async fetch(request2, current) {
|
|
2562
2665
|
setClientAddress(request2, current.requestIP(request2)?.address);
|
|
2563
2666
|
const response2 = await handleSafely(app, request2, options.publicPath);
|
|
@@ -3222,7 +3325,7 @@ import { createHmac, timingSafeEqual } from "crypto";
|
|
|
3222
3325
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
3223
3326
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
3224
3327
|
import { existsSync as existsSync5, readdirSync as readdirSync3 } from "fs";
|
|
3225
|
-
import { join as join6, relative as
|
|
3328
|
+
import { join as join6, relative as relative3, sep as sep2 } from "path";
|
|
3226
3329
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
3227
3330
|
import { AsyncLocalStorage } from "async_hooks";
|
|
3228
3331
|
import { existsSync as existsSync24 } from "fs";
|
|
@@ -3292,6 +3395,14 @@ var FileNotPreviewableError = class extends LiveError {
|
|
|
3292
3395
|
super(`File with extension "${extension}" is not previewable. See the live.temporary_file_upload.preview_mimes config.`);
|
|
3293
3396
|
}
|
|
3294
3397
|
};
|
|
3398
|
+
var UploadAlreadyStoredError = class extends LiveError {
|
|
3399
|
+
constructor(path) {
|
|
3400
|
+
super(`This upload was stored already, at ${path}. Reset the property after storing it.`);
|
|
3401
|
+
this.path = path;
|
|
3402
|
+
}
|
|
3403
|
+
path;
|
|
3404
|
+
name = "UploadAlreadyStoredError";
|
|
3405
|
+
};
|
|
3295
3406
|
var UploadValidationError = class extends LiveError {
|
|
3296
3407
|
constructor(errors) {
|
|
3297
3408
|
super("The upload failed.");
|
|
@@ -3411,6 +3522,8 @@ var TemporaryUploadedFile = class {
|
|
|
3411
3522
|
mimeType;
|
|
3412
3523
|
size;
|
|
3413
3524
|
#extension;
|
|
3525
|
+
/** Where store() put it, once it has. */
|
|
3526
|
+
#storedAt;
|
|
3414
3527
|
constructor(data) {
|
|
3415
3528
|
if (!isTemporaryFileData(data)) throw new LiveError("A temporary upload needs a stored name, a name, a size, a type and an extension.");
|
|
3416
3529
|
this.filename = data.filename;
|
|
@@ -3464,17 +3577,34 @@ var TemporaryUploadedFile = class {
|
|
|
3464
3577
|
}
|
|
3465
3578
|
});
|
|
3466
3579
|
}
|
|
3467
|
-
/**
|
|
3580
|
+
/**
|
|
3581
|
+
* Moves the file under a random name to `directory`, on `disk` (by default the temporary disk, as Livewire's), so no
|
|
3582
|
+
* temporary copy is left behind: on a public disk it could be fetched at its address. An upload stores once.
|
|
3583
|
+
*/
|
|
3468
3584
|
store(directory, disk) {
|
|
3469
|
-
return
|
|
3470
|
-
}
|
|
3471
|
-
|
|
3472
|
-
|
|
3585
|
+
return this.storeAs(directory, this.hashName(), disk);
|
|
3586
|
+
}
|
|
3587
|
+
/** store(), under the name you give it. */
|
|
3588
|
+
async storeAs(directory, name, disk) {
|
|
3589
|
+
if (this.#storedAt !== void 0) throw new UploadAlreadyStoredError(this.#storedAt);
|
|
3590
|
+
const target2 = container().make(FilesystemManager).disk(disk ?? uploadSetting("disk") ?? void 0);
|
|
3591
|
+
const temporary = temporaryDisk();
|
|
3592
|
+
let path;
|
|
3593
|
+
if (target2 === temporary) {
|
|
3594
|
+
const folder = directory.replace(/^\/+|\/+$/g, "");
|
|
3595
|
+
path = folder === "" ? name : `${folder}/${name}`;
|
|
3596
|
+
await target2.move(this.path, path);
|
|
3597
|
+
} else {
|
|
3598
|
+
path = await target2.putFileAs(directory, this, name);
|
|
3599
|
+
await temporary.delete(this.path);
|
|
3600
|
+
}
|
|
3601
|
+
this.#storedAt = path;
|
|
3602
|
+
return path;
|
|
3473
3603
|
}
|
|
3474
3604
|
exists() {
|
|
3475
3605
|
return temporaryDisk().exists(this.path);
|
|
3476
3606
|
}
|
|
3477
|
-
/** Removes the temporary file
|
|
3607
|
+
/** Removes the temporary file, if it hasn't been stored. */
|
|
3478
3608
|
delete() {
|
|
3479
3609
|
return temporaryDisk().delete(this.path);
|
|
3480
3610
|
}
|
|
@@ -3487,6 +3617,7 @@ var TemporaryUploadedFile = class {
|
|
|
3487
3617
|
* at least 30 minutes away (Livewire's), so a re-render keeps the same link and the browser doesn't reload it.
|
|
3488
3618
|
*/
|
|
3489
3619
|
temporaryUrl() {
|
|
3620
|
+
if (this.#storedAt !== void 0) throw new UploadAlreadyStoredError(this.#storedAt);
|
|
3490
3621
|
if (!this.isPreviewable()) throw new FileNotPreviewableError(this.#extension);
|
|
3491
3622
|
const expires = new Date((Math.floor((Date.now() + 30 * 6e4) / HOUR) + 1) * HOUR - 1e3);
|
|
3492
3623
|
return container().make(UrlGenerator).temporarySignedRoute("live.preview-file", expires, { filename: this.filename }, false);
|
|
@@ -4133,14 +4264,24 @@ function currentSession() {
|
|
|
4133
4264
|
return void 0;
|
|
4134
4265
|
}
|
|
4135
4266
|
}
|
|
4267
|
+
function queuedCookies() {
|
|
4268
|
+
const container2 = currentContainer();
|
|
4269
|
+
if (container2?.bound(CookieJar) !== true) return {};
|
|
4270
|
+
try {
|
|
4271
|
+
return Object.fromEntries(container2.make(CookieJar).queued().map((cookie) => [cookie.name, cookie.minutes < 0 ? null : cookie.value]));
|
|
4272
|
+
} catch {
|
|
4273
|
+
return {};
|
|
4274
|
+
}
|
|
4275
|
+
}
|
|
4136
4276
|
var Testable = class _Testable {
|
|
4137
|
-
constructor(manager, scope, result) {
|
|
4277
|
+
constructor(manager, scope, result, cookies) {
|
|
4138
4278
|
this.manager = manager;
|
|
4139
4279
|
this.scope = scope;
|
|
4140
4280
|
this.#snapshot = JSON.stringify(result.snapshot);
|
|
4141
4281
|
this.#html = result.html ?? "";
|
|
4142
4282
|
this.#effects = result.effects;
|
|
4143
4283
|
this.#instance = result.instance;
|
|
4284
|
+
this.#cookies = cookies;
|
|
4144
4285
|
}
|
|
4145
4286
|
manager;
|
|
4146
4287
|
scope;
|
|
@@ -4148,6 +4289,7 @@ var Testable = class _Testable {
|
|
|
4148
4289
|
#html;
|
|
4149
4290
|
#effects;
|
|
4150
4291
|
#instance;
|
|
4292
|
+
#cookies;
|
|
4151
4293
|
/**
|
|
4152
4294
|
* Mounts `component` with `params`, as `<Live component={…} {...params} />` would. A lazy component mounts at once
|
|
4153
4295
|
* (Livewire's withoutLazyLoading()); `{ lazy: true }` renders its placeholder, and `call('__lazyLoad', …)` loads it.
|
|
@@ -4155,7 +4297,11 @@ var Testable = class _Testable {
|
|
|
4155
4297
|
static async create(component, params = {}) {
|
|
4156
4298
|
const scope = requestScope2();
|
|
4157
4299
|
const manager = inject(LiveManager);
|
|
4158
|
-
|
|
4300
|
+
const { result, cookies } = await scope(async () => {
|
|
4301
|
+
const result2 = await manager.mountComponent(component, { lazy: false, ...params });
|
|
4302
|
+
return { result: result2, cookies: queuedCookies() };
|
|
4303
|
+
});
|
|
4304
|
+
return new _Testable(manager, scope, result, cookies);
|
|
4159
4305
|
}
|
|
4160
4306
|
/** The component instance after the last request. */
|
|
4161
4307
|
instance() {
|
|
@@ -4173,6 +4319,10 @@ var Testable = class _Testable {
|
|
|
4173
4319
|
effects() {
|
|
4174
4320
|
return this.#effects;
|
|
4175
4321
|
}
|
|
4322
|
+
/** The cookies the last request queued, by name; null for one it deleted. */
|
|
4323
|
+
cookies() {
|
|
4324
|
+
return { ...this.#cookies };
|
|
4325
|
+
}
|
|
4176
4326
|
/**
|
|
4177
4327
|
* Sets public properties through an update. A file (a FakeFile) or an array of files is uploaded as `o:model` on a
|
|
4178
4328
|
* file input does it: the upload rules, the temporary disk, then a TemporaryUploadedFile (or an array) in the
|
|
@@ -4205,12 +4355,13 @@ var Testable = class _Testable {
|
|
|
4205
4355
|
return this.#update({}, [{ method: "$refresh", params: [] }]);
|
|
4206
4356
|
}
|
|
4207
4357
|
async #update(updates, calls) {
|
|
4208
|
-
const result = await this.scope(async () => {
|
|
4358
|
+
const { result, cookies } = await this.scope(async () => {
|
|
4209
4359
|
const flashed = trackFlash(currentSession(), { saved: false });
|
|
4210
4360
|
const updated = await this.manager.updateComponent(this.#snapshot, updates, calls);
|
|
4211
4361
|
flashed(updated.effects.redirect !== void 0);
|
|
4212
|
-
return updated;
|
|
4362
|
+
return { result: updated, cookies: queuedCookies() };
|
|
4213
4363
|
});
|
|
4364
|
+
this.#cookies = cookies;
|
|
4214
4365
|
this.#snapshot = JSON.stringify(result.snapshot);
|
|
4215
4366
|
if (result.html !== void 0) this.#html = result.html;
|
|
4216
4367
|
this.#effects = result.effects;
|
|
@@ -4364,7 +4515,7 @@ async function discover(directory) {
|
|
|
4364
4515
|
/* @vite-ignore */
|
|
4365
4516
|
pathToFileURL2(join6(directory, file)).href
|
|
4366
4517
|
);
|
|
4367
|
-
found.push([componentName(
|
|
4518
|
+
found.push([componentName(relative3(directory, join6(directory, file))), module.default]);
|
|
4368
4519
|
}
|
|
4369
4520
|
return found;
|
|
4370
4521
|
}
|
|
@@ -4907,12 +5058,12 @@ var LiveComponentManager = class {
|
|
|
4907
5058
|
}
|
|
4908
5059
|
/** The absolute URL of the page a memo path belongs to, on the current request's origin ('/' + path without one). */
|
|
4909
5060
|
pageUrl(path) {
|
|
4910
|
-
const
|
|
5061
|
+
const relative32 = `/${path.replace(/^\/+/, "")}`;
|
|
4911
5062
|
const url2 = optional(this.container(), HttpRequest)?.url();
|
|
4912
5063
|
try {
|
|
4913
|
-
return url2 === void 0 ?
|
|
5064
|
+
return url2 === void 0 ? relative32 : new URL(relative32, url2).href;
|
|
4914
5065
|
} catch {
|
|
4915
|
-
return
|
|
5066
|
+
return relative32;
|
|
4916
5067
|
}
|
|
4917
5068
|
}
|
|
4918
5069
|
/** Dispatches, redirects: the effects every response carries. */
|
|
@@ -5046,11 +5197,12 @@ function urlWindow(current, last, onEachSide) {
|
|
|
5046
5197
|
if (current > last - size) return [...range(1, 2), "...", ...range(last - (size + (onEachSide - 1)), last)];
|
|
5047
5198
|
return [...range(1, 2), "...", ...range(current - onEachSide, current + onEachSide), "...", ...range(last - 1, last)];
|
|
5048
5199
|
}
|
|
5049
|
-
|
|
5200
|
+
var classAttribute = (classes) => classes === "" ? "" : ` class="${escapeAttribute2(classes)}"`;
|
|
5201
|
+
function button(label, action, classes, attributes = "") {
|
|
5050
5202
|
const live2 = action === void 0 ? " disabled" : ` o:click="${escapeAttribute2(action)}"`;
|
|
5051
|
-
return `<button type="button"
|
|
5203
|
+
return `<button type="button"${classAttribute(classes)}${attributes}${live2}>${escapeAttribute2(label)}</button>`;
|
|
5052
5204
|
}
|
|
5053
|
-
function Pagination({ paginator, class: className }) {
|
|
5205
|
+
function Pagination({ paginator, class: className, buttonClass = "btn btn-secondary", currentClass = "btn" }) {
|
|
5054
5206
|
if (typeof paginator.nextCursor === "function") {
|
|
5055
5207
|
throw new LiveError("<Pagination> needs paginate() or simplePaginate(): a cursor paginator has no page numbers.");
|
|
5056
5208
|
}
|
|
@@ -5058,26 +5210,28 @@ function Pagination({ paginator, class: className }) {
|
|
|
5058
5210
|
const onFirst = paginator.onFirstPage();
|
|
5059
5211
|
const hasMore = paginator.hasMorePages();
|
|
5060
5212
|
if (onFirst && !hasMore) return { toHtml: () => "" };
|
|
5061
|
-
const parts = [button("\xAB Previous", onFirst ? void 0 : "previousPage")];
|
|
5213
|
+
const parts = [button("\xAB Previous", onFirst ? void 0 : "previousPage", buttonClass)];
|
|
5062
5214
|
if (typeof paginator.lastPage === "function") {
|
|
5063
5215
|
const onEachSide = Number.isInteger(paginator.onEachSideCount) && paginator.onEachSideCount >= 0 ? paginator.onEachSideCount : 3;
|
|
5064
5216
|
for (const page of urlWindow(current, paginator.lastPage(), onEachSide)) {
|
|
5065
5217
|
if (page === "...") parts.push('<span aria-hidden="true">...</span>');
|
|
5066
|
-
else if (page === current) parts.push(`<button type="button"
|
|
5067
|
-
else parts.push(button(String(page), `gotoPage(${page})`, ` aria-label="Go to page ${page}"`));
|
|
5218
|
+
else if (page === current) parts.push(`<button type="button"${classAttribute(currentClass)} aria-current="page" disabled>${page}</button>`);
|
|
5219
|
+
else parts.push(button(String(page), `gotoPage(${page})`, buttonClass, ` aria-label="Go to page ${page}"`));
|
|
5068
5220
|
}
|
|
5069
5221
|
}
|
|
5070
|
-
parts.push(button("Next \xBB", hasMore ? "nextPage" : void 0));
|
|
5071
|
-
const
|
|
5072
|
-
const html = `<nav aria-label="Pagination"${classes}>${parts.join("")}</nav>`;
|
|
5222
|
+
parts.push(button("Next \xBB", hasMore ? "nextPage" : void 0, buttonClass));
|
|
5223
|
+
const html = `<nav aria-label="Pagination"${classAttribute(className ?? "")}>${parts.join("")}</nav>`;
|
|
5073
5224
|
return { toHtml: () => html };
|
|
5074
5225
|
}
|
|
5075
5226
|
|
|
5076
5227
|
// ../Testing/dist/index.js
|
|
5077
5228
|
import { AssertionError as AssertionError2 } from "assert";
|
|
5078
5229
|
import { isDeepStrictEqual as isDeepStrictEqual2 } from "util";
|
|
5079
|
-
import { existsSync as existsSync6 } from "fs";
|
|
5230
|
+
import { existsSync as existsSync6, readFileSync as readFileSync4 } from "fs";
|
|
5080
5231
|
import { join as join7 } from "path";
|
|
5232
|
+
import { parse as parse2 } from "dotenv";
|
|
5233
|
+
import { existsSync as existsSync25 } from "fs";
|
|
5234
|
+
import { join as join25 } from "path";
|
|
5081
5235
|
import { createHmac as createHmac2 } from "crypto";
|
|
5082
5236
|
import { randomUUID } from "crypto";
|
|
5083
5237
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -5286,6 +5440,7 @@ var PendingCommand = class {
|
|
|
5286
5440
|
app;
|
|
5287
5441
|
command;
|
|
5288
5442
|
parameters;
|
|
5443
|
+
answers = [];
|
|
5289
5444
|
checks = [];
|
|
5290
5445
|
result;
|
|
5291
5446
|
/** A line of output equals `line` exactly; with no argument, the command printed something. */
|
|
@@ -5338,6 +5493,11 @@ ${output}`, { actual: output, expected: text }));
|
|
|
5338
5493
|
assertFailed() {
|
|
5339
5494
|
return this.assertNotExitCode(0);
|
|
5340
5495
|
}
|
|
5496
|
+
/** Answers the command's questions (ask(), secret(), confirm(), choice()), in order. A question beyond them fails. */
|
|
5497
|
+
withAnswers(...answers) {
|
|
5498
|
+
this.answers.push(...answers);
|
|
5499
|
+
return this;
|
|
5500
|
+
}
|
|
5341
5501
|
/** Runs the command once and checks the expectations; resolves to the exit code. */
|
|
5342
5502
|
run() {
|
|
5343
5503
|
return this.result ??= this.execute();
|
|
@@ -5348,7 +5508,7 @@ ${output}`, { actual: output, expected: text }));
|
|
|
5348
5508
|
async execute() {
|
|
5349
5509
|
if (!this.app.bound(ConsoleKernel)) throw new Error(`Cannot run [${this.command}]: the Console component (ConsoleKernel) is not registered.`);
|
|
5350
5510
|
const kernel = this.app.make(ConsoleKernel);
|
|
5351
|
-
const exitCode = await kernel.call(this.command, this.parameters);
|
|
5511
|
+
const exitCode = await kernel.call(this.command, this.parameters, { answers: this.answers });
|
|
5352
5512
|
const output = kernel.output();
|
|
5353
5513
|
const lines = output.split("\n").map((line) => line.replace(/\r$/, ""));
|
|
5354
5514
|
for (const check of this.checks) check(output, lines, exitCode);
|
|
@@ -5407,6 +5567,96 @@ async function assertNotSoftDeleted(db, table, data = {}, connection, deletedAtC
|
|
|
5407
5567
|
const count = await constrain(t.connection.table(t.table), t.data).whereNull(t.column).count();
|
|
5408
5568
|
assert(count > 0, `Failed asserting that any existing row in the table [${t.table}] matches the attributes ${JSON.stringify(t.data, null, 2)}.`);
|
|
5409
5569
|
}
|
|
5570
|
+
var TESTING_ENVIRONMENT = Object.freeze({
|
|
5571
|
+
APP_ENV: "testing",
|
|
5572
|
+
BCRYPT_ROUNDS: "4",
|
|
5573
|
+
CACHE_STORE: "array",
|
|
5574
|
+
DB_CONNECTION: "sqlite",
|
|
5575
|
+
DB_DATABASE: ":memory:",
|
|
5576
|
+
DB_URL: "",
|
|
5577
|
+
MAIL_MAILER: "array",
|
|
5578
|
+
QUEUE_CONNECTION: "sync",
|
|
5579
|
+
SESSION_DRIVER: "array"
|
|
5580
|
+
});
|
|
5581
|
+
var DRIVERS = {
|
|
5582
|
+
"postgres:": { driver: "pgsql", port: "5432" },
|
|
5583
|
+
"postgresql:": { driver: "pgsql", port: "5432" },
|
|
5584
|
+
"mysql:": { driver: "mysql", port: "3306" },
|
|
5585
|
+
"mariadb:": { driver: "mysql", port: "3306" }
|
|
5586
|
+
};
|
|
5587
|
+
var DEFAULT_PORTS = { pgsql: "5432", mysql: "3306", mariadb: "3306" };
|
|
5588
|
+
var LOOPBACK = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
5589
|
+
var placeOf = (host, port, database) => `${LOOPBACK.has(host.toLowerCase()) ? "localhost" : host.toLowerCase()}:${port}/${database}`;
|
|
5590
|
+
function parseAddress(address) {
|
|
5591
|
+
let url2;
|
|
5592
|
+
try {
|
|
5593
|
+
url2 = new URL(address);
|
|
5594
|
+
} catch {
|
|
5595
|
+
return void 0;
|
|
5596
|
+
}
|
|
5597
|
+
const known = DRIVERS[url2.protocol];
|
|
5598
|
+
if (known === void 0) return void 0;
|
|
5599
|
+
const database = decodeURIComponent(url2.pathname.slice(1));
|
|
5600
|
+
const port = url2.port || known.port;
|
|
5601
|
+
return { driver: known.driver, database, place: placeOf(url2.hostname, port, database), shown: `${url2.hostname}:${port}/${database}` };
|
|
5602
|
+
}
|
|
5603
|
+
function dotEnv(cwd) {
|
|
5604
|
+
const file = join7(cwd, ".env");
|
|
5605
|
+
return existsSync6(file) ? parse2(readFileSync4(file, "utf8")) : {};
|
|
5606
|
+
}
|
|
5607
|
+
function serverDatabase(connection) {
|
|
5608
|
+
if (typeof connection.url === "string" && connection.url !== "") return parseAddress(connection.url);
|
|
5609
|
+
const driver = String(connection.driver ?? "");
|
|
5610
|
+
const port = DEFAULT_PORTS[driver];
|
|
5611
|
+
if (port === void 0) return void 0;
|
|
5612
|
+
const host = String(connection.host ?? "127.0.0.1");
|
|
5613
|
+
const at = String(connection.port ?? port);
|
|
5614
|
+
const database = String(connection.database ?? "oriel");
|
|
5615
|
+
return { driver, place: placeOf(host, at, database), shown: `${host}:${at}/${database}` };
|
|
5616
|
+
}
|
|
5617
|
+
function ownDatabases(env2, cwd) {
|
|
5618
|
+
const file = dotEnv(cwd);
|
|
5619
|
+
const setting = (key2) => env2[key2] !== void 0 && env2[key2] !== "" ? env2[key2] : file[key2] !== "" ? file[key2] : void 0;
|
|
5620
|
+
const places = [];
|
|
5621
|
+
for (const url2 of [env2.DB_URL, file.DB_URL]) {
|
|
5622
|
+
const place = url2 === void 0 || url2 === "" ? void 0 : parseAddress(url2)?.place;
|
|
5623
|
+
if (place !== void 0) places.push(place);
|
|
5624
|
+
}
|
|
5625
|
+
const port = DEFAULT_PORTS[setting("DB_CONNECTION") ?? ""];
|
|
5626
|
+
if (port !== void 0) places.push(placeOf(setting("DB_HOST") ?? "127.0.0.1", setting("DB_PORT") ?? port, setting("DB_DATABASE") ?? "oriel"));
|
|
5627
|
+
return places;
|
|
5628
|
+
}
|
|
5629
|
+
function testingConfig(env2 = process.env, log = (line) => console.log(line), cwd = process.cwd()) {
|
|
5630
|
+
const address = env2.TEST_DATABASE_URL;
|
|
5631
|
+
if (address === void 0 || address === "") {
|
|
5632
|
+
const ignored = env2.DB_CONNECTION !== void 0 && env2.DB_CONNECTION !== "" && env2.DB_CONNECTION !== "sqlite" || env2.DB_URL !== void 0 && env2.DB_URL !== "";
|
|
5633
|
+
log(`Tests run on SQLite, in memory.${ignored ? " DB_CONNECTION and DB_URL are ignored in tests: set TEST_DATABASE_URL to use another database." : ""}`);
|
|
5634
|
+
return { env: { ...TESTING_ENVIRONMENT }, fileParallelism: true };
|
|
5635
|
+
}
|
|
5636
|
+
const database = parseAddress(address);
|
|
5637
|
+
if (database === void 0) throw new Error("TEST_DATABASE_URL must be a postgres:// or mysql:// address.");
|
|
5638
|
+
if (database.database === "") throw new Error("TEST_DATABASE_URL must name a database.");
|
|
5639
|
+
if (ownDatabases(env2, cwd).includes(database.place)) {
|
|
5640
|
+
throw new Error("TEST_DATABASE_URL is the app's own database (DB_URL): the tests would wipe it.");
|
|
5641
|
+
}
|
|
5642
|
+
log(`Tests run on ${database.driver} at ${database.shown} (TEST_DATABASE_URL), one file at a time.`);
|
|
5643
|
+
return {
|
|
5644
|
+
env: { ...TESTING_ENVIRONMENT, DB_CONNECTION: database.driver, DB_URL: address, DB_DATABASE: database.database },
|
|
5645
|
+
fileParallelism: false
|
|
5646
|
+
};
|
|
5647
|
+
}
|
|
5648
|
+
function applyEnvironment(values, env2 = process.env) {
|
|
5649
|
+
for (const [key2, value] of Object.entries(values)) env2[key2] ??= value;
|
|
5650
|
+
}
|
|
5651
|
+
function clonePlain2(value) {
|
|
5652
|
+
if (Array.isArray(value)) return value.map((item) => clonePlain2(item));
|
|
5653
|
+
if (typeof value === "object" && value !== null) {
|
|
5654
|
+
const proto = Object.getPrototypeOf(value);
|
|
5655
|
+
if (proto !== Object.prototype && proto !== null) return value;
|
|
5656
|
+
return Object.fromEntries(Object.entries(value).map(([key2, item]) => [key2, clonePlain2(item)]));
|
|
5657
|
+
}
|
|
5658
|
+
return value;
|
|
5659
|
+
}
|
|
5410
5660
|
var RefreshDatabaseState = { migrated: false };
|
|
5411
5661
|
async function runCommand(app, command, parameters = {}) {
|
|
5412
5662
|
if (!app.bound(ConsoleKernel)) throw new Error(`Running [${command}] needs the Console component (ConsoleKernel is not bound).`);
|
|
@@ -5422,7 +5672,8 @@ function seedOptions(test) {
|
|
|
5422
5672
|
function usingInMemoryDatabase(app) {
|
|
5423
5673
|
const config = app.make(ConfigRepository);
|
|
5424
5674
|
const name = config.get("database.default");
|
|
5425
|
-
|
|
5675
|
+
if (name === void 0) return false;
|
|
5676
|
+
return config.get(`database.connections.${name}.driver`) === "sqlite" && config.get(`database.connections.${name}.database`) === ":memory:";
|
|
5426
5677
|
}
|
|
5427
5678
|
function connectionsOf(test) {
|
|
5428
5679
|
const db = test.app.make(DatabaseManager);
|
|
@@ -5444,9 +5695,19 @@ async function rollBackTo(connection, level) {
|
|
|
5444
5695
|
current = next;
|
|
5445
5696
|
}
|
|
5446
5697
|
}
|
|
5698
|
+
function refuseOwnDatabase(app, trait) {
|
|
5699
|
+
const config = app.make(ConfigRepository);
|
|
5700
|
+
const connection = config.get(`database.connections.${config.get("database.default")}`);
|
|
5701
|
+
const target2 = serverDatabase(connection ?? {});
|
|
5702
|
+
if (target2 === void 0 || !ownDatabases({}, app.basePath()).includes(target2.place)) return;
|
|
5703
|
+
throw new Error(
|
|
5704
|
+
`${trait} would empty the app's own database (${target2.driver} at ${target2.shown}, from .env). Give the tests a database of their own: set TEST_DATABASE_URL, and spread testingConfig() into vitest.config.ts.`
|
|
5705
|
+
);
|
|
5706
|
+
}
|
|
5447
5707
|
var RefreshDatabase = {
|
|
5448
5708
|
async setUp(test) {
|
|
5449
5709
|
if (usingInMemoryDatabase(test.app)) return runCommand(test.app, "migrate", seedOptions(test));
|
|
5710
|
+
refuseOwnDatabase(test.app, "RefreshDatabase");
|
|
5450
5711
|
if (!RefreshDatabaseState.migrated) {
|
|
5451
5712
|
if (test.migrateFreshUsing !== void 0) await test.migrateFreshUsing();
|
|
5452
5713
|
else await runCommand(test.app, "migrate:fresh", seedOptions(test));
|
|
@@ -5457,6 +5718,7 @@ var RefreshDatabase = {
|
|
|
5457
5718
|
};
|
|
5458
5719
|
var DatabaseMigrations = {
|
|
5459
5720
|
async setUp(test) {
|
|
5721
|
+
refuseOwnDatabase(test.app, "DatabaseMigrations");
|
|
5460
5722
|
await runCommand(test.app, "migrate:fresh", seedOptions(test));
|
|
5461
5723
|
test.beforeApplicationDestroyed(() => runCommand(test.app, "migrate:rollback"));
|
|
5462
5724
|
}
|
|
@@ -5466,28 +5728,6 @@ var DatabaseTransactions = {
|
|
|
5466
5728
|
await beginTransactions(test, connectionsOf(test));
|
|
5467
5729
|
}
|
|
5468
5730
|
};
|
|
5469
|
-
var TESTING_ENVIRONMENT = Object.freeze({
|
|
5470
|
-
APP_ENV: "testing",
|
|
5471
|
-
BCRYPT_ROUNDS: "4",
|
|
5472
|
-
CACHE_STORE: "array",
|
|
5473
|
-
DB_CONNECTION: "sqlite",
|
|
5474
|
-
DB_DATABASE: ":memory:",
|
|
5475
|
-
MAIL_MAILER: "array",
|
|
5476
|
-
QUEUE_CONNECTION: "sync",
|
|
5477
|
-
SESSION_DRIVER: "array"
|
|
5478
|
-
});
|
|
5479
|
-
function applyEnvironment(values, env2 = process.env) {
|
|
5480
|
-
for (const [key2, value] of Object.entries(values)) env2[key2] ??= value;
|
|
5481
|
-
}
|
|
5482
|
-
function clonePlain2(value) {
|
|
5483
|
-
if (Array.isArray(value)) return value.map((item) => clonePlain2(item));
|
|
5484
|
-
if (typeof value === "object" && value !== null) {
|
|
5485
|
-
const proto = Object.getPrototypeOf(value);
|
|
5486
|
-
if (proto !== Object.prototype && proto !== null) return value;
|
|
5487
|
-
return Object.fromEntries(Object.entries(value).map(([key2, item]) => [key2, clonePlain2(item)]));
|
|
5488
|
-
}
|
|
5489
|
-
return value;
|
|
5490
|
-
}
|
|
5491
5731
|
function typeOf(value) {
|
|
5492
5732
|
if (value === null) return ["null"];
|
|
5493
5733
|
if (Array.isArray(value)) return ["array"];
|
|
@@ -5781,7 +6021,7 @@ var AssertableInertia = class _AssertableInertia extends AssertableJson {
|
|
|
5781
6021
|
if (shouldExist === true || shouldExist === void 0 && config?.get("inertia.testing.ensure_pages_exist", true) !== false) {
|
|
5782
6022
|
const paths = config?.get("inertia.pages.paths", []) ?? [];
|
|
5783
6023
|
const extensions = config?.get("inertia.pages.extensions", []) ?? [];
|
|
5784
|
-
const exists = paths.some((path) => extensions.some((extension) =>
|
|
6024
|
+
const exists = paths.some((path) => extensions.some((extension) => existsSync25(join25(path, `${value}.${extension}`))));
|
|
5785
6025
|
if (!exists) fail2(`Inertia page component file [${value}] does not exist.`);
|
|
5786
6026
|
}
|
|
5787
6027
|
return this;
|
|
@@ -6617,16 +6857,39 @@ var HttpClient = class {
|
|
|
6617
6857
|
const result = await scope.run(async () => {
|
|
6618
6858
|
this.beforeRequest(scope, context);
|
|
6619
6859
|
if (context.session !== void 0) this.applyPending(context.session);
|
|
6620
|
-
|
|
6860
|
+
const incoming = new IncomingRequest(request2);
|
|
6861
|
+
incoming.setCookies(this.plainCookies());
|
|
6862
|
+
scope.instance(HttpRequest, incoming);
|
|
6621
6863
|
if (scope.bound(AuthFactory)) {
|
|
6622
6864
|
try {
|
|
6623
6865
|
await scope.make(AuthFactory).guard().check();
|
|
6624
6866
|
} catch {
|
|
6625
6867
|
}
|
|
6626
6868
|
}
|
|
6627
|
-
|
|
6869
|
+
const result2 = await run();
|
|
6870
|
+
if (scope.bound(CookieJar)) {
|
|
6871
|
+
for (const cookie of scope.make(CookieJar).queued()) {
|
|
6872
|
+
if (cookie.minutes < 0) this.cookies.delete(cookie.name);
|
|
6873
|
+
else this.cookies.set(cookie.name, { value: cookie.value, encrypt: true });
|
|
6874
|
+
}
|
|
6875
|
+
}
|
|
6876
|
+
if (scope.bound(AuthFactory)) {
|
|
6877
|
+
try {
|
|
6878
|
+
;
|
|
6879
|
+
scope.make(AuthFactory).guard().keepPasswordHash?.();
|
|
6880
|
+
} catch {
|
|
6881
|
+
}
|
|
6882
|
+
}
|
|
6883
|
+
return result2;
|
|
6628
6884
|
});
|
|
6629
6885
|
await scope.run(() => this.afterRequest(scope, context));
|
|
6886
|
+
if (context.session !== void 0) {
|
|
6887
|
+
const carried = clonePlain2(context.session.all());
|
|
6888
|
+
this.sessionChanges.splice(0, Infinity, (session) => {
|
|
6889
|
+
session.flush();
|
|
6890
|
+
session.put(clonePlain2(carried));
|
|
6891
|
+
});
|
|
6892
|
+
}
|
|
6630
6893
|
return result;
|
|
6631
6894
|
}
|
|
6632
6895
|
/** Runs the request through the app's real HttpKernel, in a request scope this client owns. */
|
|
@@ -6745,8 +7008,25 @@ var HttpClient = class {
|
|
|
6745
7008
|
const configured = this.app.bound(ConfigRepository) ? this.app.make(ConfigRepository).get("app.url") : void 0;
|
|
6746
7009
|
return typeof configured === "string" && configured !== "" ? configured : "http://localhost";
|
|
6747
7010
|
}
|
|
7011
|
+
/** The cookies as EncryptCookies would leave them, since no middleware runs for a Live test. */
|
|
7012
|
+
plainCookies() {
|
|
7013
|
+
const plain = {};
|
|
7014
|
+
for (const [name, { value, encrypt }] of this.cookies) {
|
|
7015
|
+
plain[name] = encrypt ? value : this.decrypted(name, value) ?? value;
|
|
7016
|
+
}
|
|
7017
|
+
return plain;
|
|
7018
|
+
}
|
|
7019
|
+
/** A cookie kept from a response is as it was sent: encrypted, unless the app excepts it. */
|
|
7020
|
+
decrypted(name, value) {
|
|
7021
|
+
try {
|
|
7022
|
+
return this.app.bound(Encrypter) ? decryptCookie(this.app.make(Encrypter), name, value) : void 0;
|
|
7023
|
+
} catch {
|
|
7024
|
+
return void 0;
|
|
7025
|
+
}
|
|
7026
|
+
}
|
|
6748
7027
|
cookieHeader() {
|
|
6749
|
-
const
|
|
7028
|
+
const needsKey = [...this.cookies.values()].some(({ encrypt }) => encrypt);
|
|
7029
|
+
const encrypter = needsKey && this.app.bound(Encrypter) ? this.app.make(Encrypter) : void 0;
|
|
6750
7030
|
const values = /* @__PURE__ */ new Map();
|
|
6751
7031
|
for (const [name, { value, encrypt }] of this.cookies) {
|
|
6752
7032
|
values.set(name, encrypt && encrypter !== void 0 ? encryptCookie(encrypter, name, value) : value);
|
|
@@ -8697,6 +8977,7 @@ export {
|
|
|
8697
8977
|
InvalidUploadSignatureError,
|
|
8698
8978
|
TemporaryFileNotFoundError,
|
|
8699
8979
|
FileNotPreviewableError,
|
|
8980
|
+
UploadAlreadyStoredError,
|
|
8700
8981
|
UploadValidationError,
|
|
8701
8982
|
On,
|
|
8702
8983
|
Locked,
|
|
@@ -8731,14 +9012,15 @@ export {
|
|
|
8731
9012
|
travel,
|
|
8732
9013
|
Wormhole,
|
|
8733
9014
|
PendingCommand,
|
|
9015
|
+
TESTING_ENVIRONMENT,
|
|
9016
|
+
testingConfig,
|
|
9017
|
+
applyEnvironment,
|
|
8734
9018
|
RefreshDatabaseState,
|
|
8735
9019
|
runCommand,
|
|
8736
9020
|
usingInMemoryDatabase,
|
|
8737
9021
|
RefreshDatabase,
|
|
8738
9022
|
DatabaseMigrations,
|
|
8739
9023
|
DatabaseTransactions,
|
|
8740
|
-
TESTING_ENVIRONMENT,
|
|
8741
|
-
applyEnvironment,
|
|
8742
9024
|
AssertableJson,
|
|
8743
9025
|
inertiaPageOf,
|
|
8744
9026
|
AssertableInertia,
|
|
@@ -8776,4 +9058,4 @@ export {
|
|
|
8776
9058
|
StorageFake,
|
|
8777
9059
|
FakeFile
|
|
8778
9060
|
};
|
|
8779
|
-
//# sourceMappingURL=chunk-
|
|
9061
|
+
//# sourceMappingURL=chunk-7GPMFMS7.js.map
|