laravel-workers 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +295 -2
- package/bin/laravel-workers.mjs +141 -0
- package/build.mjs +2599 -0
- package/compiler/bin/controller.mjs +92 -0
- package/compiler/bin/transpile.mjs +65 -0
- package/compiler/runtime/rt-from-context.mjs +2399 -0
- package/compiler/src/classes.mjs +1232 -0
- package/compiler/src/controller.mjs +1029 -0
- package/compiler/src/dist-swap.mjs +76 -0
- package/compiler/src/mail-reach.mjs +104 -0
- package/compiler/src/policy.mjs +345 -0
- package/compiler/src/transpiler.mjs +3094 -0
- package/compiler/src/view-name.mjs +21 -0
- package/kernel/auth.mjs +1502 -0
- package/kernel/cache.mjs +405 -0
- package/kernel/collections.mjs +1615 -0
- package/kernel/cookies.mjs +474 -0
- package/kernel/csrf.mjs +698 -0
- package/kernel/db.mjs +703 -0
- package/kernel/digest.mjs +360 -0
- package/kernel/encrypter.mjs +106 -0
- package/kernel/form-request.mjs +106 -0
- package/kernel/hash.mjs +113 -0
- package/kernel/html-entities.mjs +268 -0
- package/kernel/http.mjs +1803 -0
- package/kernel/image.mjs +341 -0
- package/kernel/mail.mjs +269 -0
- package/kernel/mailable.mjs +172 -0
- package/kernel/model.mjs +1226 -0
- package/kernel/multipart.mjs +161 -0
- package/kernel/paginator.mjs +336 -0
- package/kernel/php-json.mjs +220 -0
- package/kernel/php-serialize.mjs +245 -0
- package/kernel/queue.mjs +96 -0
- package/kernel/ratelimit.mjs +855 -0
- package/kernel/redis.mjs +264 -0
- package/kernel/resources.mjs +857 -0
- package/kernel/response.mjs +17 -0
- package/kernel/router.mjs +276 -0
- package/kernel/scheduler.mjs +236 -0
- package/kernel/service-adapters.mjs +49 -0
- package/kernel/session.mjs +934 -0
- package/kernel/storage.mjs +265 -0
- package/kernel/str.mjs +445 -0
- package/kernel/tests/auth.test.mjs +1074 -0
- package/kernel/tests/budget.test.mjs +527 -0
- package/kernel/tests/cache.test.mjs +290 -0
- package/kernel/tests/collections.test.mjs +534 -0
- package/kernel/tests/cookies.test.mjs +302 -0
- package/kernel/tests/csrf.test.mjs +597 -0
- package/kernel/tests/db.test.mjs +1069 -0
- package/kernel/tests/encrypter.test.mjs +90 -0
- package/kernel/tests/fixtures/laravel-1337-cookies.json +120 -0
- package/kernel/tests/hash.test.mjs +149 -0
- package/kernel/tests/http.test.mjs +1182 -0
- package/kernel/tests/image.test.mjs +235 -0
- package/kernel/tests/login-flow.test.mjs +509 -0
- package/kernel/tests/model.test.mjs +324 -0
- package/kernel/tests/oracle-app.mjs +32 -0
- package/kernel/tests/paginator.test.mjs +132 -0
- package/kernel/tests/php-json.test.mjs +263 -0
- package/kernel/tests/php-serialize.test.mjs +210 -0
- package/kernel/tests/ports.test.mjs +47 -0
- package/kernel/tests/ratelimit.test.mjs +975 -0
- package/kernel/tests/readiness.test.mjs +155 -0
- package/kernel/tests/redis.test.mjs +175 -0
- package/kernel/tests/registry-json.test.mjs +28 -0
- package/kernel/tests/resources.test.mjs +275 -0
- package/kernel/tests/router.test.mjs +281 -0
- package/kernel/tests/routes-json.test.mjs +32 -0
- package/kernel/tests/services.test.mjs +474 -0
- package/kernel/tests/session.test.mjs +709 -0
- package/kernel/tests/sqlite-integration.test.mjs +390 -0
- package/kernel/tests/storage.test.mjs +133 -0
- package/kernel/tests/str.test.mjs +83 -0
- package/kernel/tests/upload.test.mjs +193 -0
- package/kernel/tests/validation-messages.test.mjs +117 -0
- package/kernel/tests/validation.test.mjs +340 -0
- package/kernel/tests/validator-hooks.test.mjs +343 -0
- package/kernel/tests/validator.test.mjs +805 -0
- package/kernel/tests/vendor-lite.test.mjs +39 -0
- package/kernel/validation-messages.data.mjs +168 -0
- package/kernel/validation-messages.mjs +249 -0
- package/kernel/validation.mjs +123 -0
- package/kernel/validator.mjs +1538 -0
- package/package.json +68 -5
- package/shadow/run.mjs +784 -0
- package/shadow/scenarios/fresh-app.mjs +60 -0
- package/shadow/scenarios/lw-constructs-app.mjs +669 -0
- package/src/ports/dbcheck.mjs +22 -0
- package/src/worker.mjs +200 -0
- package/tools/_root.php +135 -0
- package/tools/bench.mjs +129 -0
- package/tools/class-dump.php +87 -0
- package/tools/compile-view.php +263 -0
- package/tools/config-dump.php +192 -0
- package/tools/constants-dump.php +46 -0
- package/tools/construct-audit.mjs +326 -0
- package/tools/constructs.json +1510 -0
- package/tools/docs-check.mjs +149 -0
- package/tools/event-dump.php +320 -0
- package/tools/formrequest-dump.php +229 -0
- package/tools/gate.mjs +36 -0
- package/tools/http-oracle.php +200 -0
- package/tools/init.mjs +73 -0
- package/tools/integrations.json +69 -0
- package/tools/mailable-views.php +116 -0
- package/tools/make-cookie-fixture.mjs +87 -0
- package/tools/make-html-entities.mjs +106 -0
- package/tools/model-dump.php +198 -0
- package/tools/php-auth-oracle.php +701 -0
- package/tools/php-cache-oracle.php +166 -0
- package/tools/php-crypto-oracle.php +113 -0
- package/tools/php-csrf-oracle.php +271 -0
- package/tools/php-http-pipeline-oracle.php +358 -0
- package/tools/php-json-oracle.php +102 -0
- package/tools/php-login-flow-oracle.php +342 -0
- package/tools/php-provision.mjs +172 -0
- package/tools/php-ratelimit-oracle.php +508 -0
- package/tools/php-runtime.mjs +342 -0
- package/tools/php-serialize-oracle.php +114 -0
- package/tools/php-session-oracle.php +266 -0
- package/tools/php-shadow-oracle.php +588 -0
- package/tools/policy-dump.php +240 -0
- package/tools/ports.mjs +51 -0
- package/tools/prerender.php +68 -0
- package/tools/readiness.mjs +255 -0
- package/tools/registry-json.mjs +22 -0
- package/tools/routes-dump.php +27 -0
- package/tools/routes-json.mjs +48 -0
- package/tools/schedule-dump.php +82 -0
- package/tools/schema-dump.php +158 -0
- package/tools/validation-messages.php +54 -0
- package/tools/vendor-lite.mjs +299 -0
- package/tools/verify-s0.php +209 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// compiler/bin/controller.mjs — CLI for controller extraction/transpilation.
|
|
2
|
+
//
|
|
3
|
+
// Usage:
|
|
4
|
+
// node controller.mjs extract --file app/Http/Controllers/PostController.php --method show [--out meta.json]
|
|
5
|
+
// node controller.mjs emit --file app/Http/Controllers/PostController.php --method show --meta meta.json --out dist/src/controllers/posts-show.mjs
|
|
6
|
+
//
|
|
7
|
+
// extract prints {ok, fqcn, namespace, className, method, params, classes, views} on
|
|
8
|
+
// stdout (or writes it with --out). emit writes the handler module atomically on
|
|
9
|
+
// success. Both exit non-zero with a JSON error array [{code,message,line,column,hint}]
|
|
10
|
+
// on stderr when the controller/method is outside the supported subset.
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { extractController, emitController } from '../src/controller.mjs';
|
|
14
|
+
|
|
15
|
+
const USAGE =
|
|
16
|
+
'usage: controller.mjs extract|emit --file <controller.php> --method <name> [--meta <meta.json>] [--out <file>]';
|
|
17
|
+
|
|
18
|
+
function fail(errors) {
|
|
19
|
+
process.stderr.write(JSON.stringify(errors));
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function usageError(message) {
|
|
24
|
+
fail([{ code: 'LW004', message: message + ' — ' + USAGE, line: 0, column: 0, hint: '' }]);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const args = process.argv.slice(2);
|
|
28
|
+
let cmd = null;
|
|
29
|
+
let file = null;
|
|
30
|
+
let method = null;
|
|
31
|
+
let metaPath = null;
|
|
32
|
+
let outPath = null;
|
|
33
|
+
for (let i = 0; i < args.length; i++) {
|
|
34
|
+
const a = args[i];
|
|
35
|
+
if (a === 'extract' || a === 'emit') cmd = a;
|
|
36
|
+
else if (a === '--file') file = args[++i];
|
|
37
|
+
else if (a === '--method') method = args[++i];
|
|
38
|
+
else if (a === '--meta') metaPath = args[++i];
|
|
39
|
+
else if (a === '--out') outPath = args[++i];
|
|
40
|
+
else usageError('unexpected argument ' + JSON.stringify(a));
|
|
41
|
+
}
|
|
42
|
+
if (!cmd) usageError('missing command (extract|emit)');
|
|
43
|
+
if (!file) usageError('missing --file');
|
|
44
|
+
if (!method) usageError('missing --method');
|
|
45
|
+
|
|
46
|
+
const absFile = path.resolve(process.cwd(), file);
|
|
47
|
+
if (!fs.existsSync(absFile)) usageError('file not found: ' + absFile);
|
|
48
|
+
const source = fs.readFileSync(absFile, 'utf8');
|
|
49
|
+
|
|
50
|
+
if (cmd === 'extract') {
|
|
51
|
+
const info = extractController(source, method);
|
|
52
|
+
if (!info.ok) fail(info.errors);
|
|
53
|
+
const out = {
|
|
54
|
+
ok: true,
|
|
55
|
+
fqcn: info.fqcn,
|
|
56
|
+
namespace: info.namespace,
|
|
57
|
+
className: info.className,
|
|
58
|
+
method: info.method,
|
|
59
|
+
params: info.params,
|
|
60
|
+
classes: info.classes,
|
|
61
|
+
// The classes the body instantiates (`new OrderMail()`).
|
|
62
|
+
newClasses: info.newClasses,
|
|
63
|
+
constants: info.constants,
|
|
64
|
+
views: info.views,
|
|
65
|
+
// A paginator in the method + the kinds of the data the views receive.
|
|
66
|
+
usesPaginator: info.usesPaginator,
|
|
67
|
+
// A mail in the method: the build compiles the mailable's view.
|
|
68
|
+
usesMail: info.usesMail,
|
|
69
|
+
viewDataKinds: info.viewDataKinds,
|
|
70
|
+
};
|
|
71
|
+
const text = JSON.stringify(out);
|
|
72
|
+
if (outPath) fs.writeFileSync(path.resolve(process.cwd(), outPath), text);
|
|
73
|
+
else process.stdout.write(text);
|
|
74
|
+
} else {
|
|
75
|
+
if (!metaPath) usageError('emit requires --meta <file.json>');
|
|
76
|
+
if (!outPath) usageError('emit requires --out <file.mjs>');
|
|
77
|
+
const absMeta = path.resolve(process.cwd(), metaPath);
|
|
78
|
+
if (!fs.existsSync(absMeta)) usageError('meta file not found: ' + absMeta);
|
|
79
|
+
let meta;
|
|
80
|
+
try {
|
|
81
|
+
meta = JSON.parse(fs.readFileSync(absMeta, 'utf8'));
|
|
82
|
+
} catch (e) {
|
|
83
|
+
usageError('invalid meta JSON: ' + (e.message || String(e)));
|
|
84
|
+
}
|
|
85
|
+
const res = emitController(source, method, meta);
|
|
86
|
+
if (res.errors.length) fail(res.errors);
|
|
87
|
+
const absOut = path.resolve(process.cwd(), outPath);
|
|
88
|
+
fs.mkdirSync(path.dirname(absOut), { recursive: true });
|
|
89
|
+
const tmp = absOut + '.tmp-' + process.pid;
|
|
90
|
+
fs.writeFileSync(tmp, res.code);
|
|
91
|
+
fs.renameSync(tmp, absOut);
|
|
92
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// compiler/bin/transpile.mjs
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { transpile } from '../src/transpiler.mjs';
|
|
6
|
+
|
|
7
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
|
|
10
|
+
let input = null;
|
|
11
|
+
let jsonMode = false;
|
|
12
|
+
let templateMode = false;
|
|
13
|
+
let outPath = null;
|
|
14
|
+
|
|
15
|
+
for (let i = 0; i < args.length; i++) {
|
|
16
|
+
const a = args[i];
|
|
17
|
+
if (a === '--json') jsonMode = true;
|
|
18
|
+
else if (a === '--template') templateMode = true;
|
|
19
|
+
else if (a === '--out') { outPath = args[++i]; }
|
|
20
|
+
else if (!input) input = a;
|
|
21
|
+
else { console.error(JSON.stringify([{ code: 'LW004', message: 'unexpected arg ' + a, line: 0, column: 0, hint: '' }])); process.exit(1); }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!input) {
|
|
25
|
+
console.error(JSON.stringify([{ code: 'LW004', message: 'missing input file', line: 0, column: 0, hint: '' }]));
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const inputPath = path.resolve(process.cwd(), input);
|
|
30
|
+
let compiled;
|
|
31
|
+
let viewDataKinds = null;
|
|
32
|
+
try {
|
|
33
|
+
const raw = fs.readFileSync(inputPath, 'utf8');
|
|
34
|
+
if (jsonMode) {
|
|
35
|
+
const data = JSON.parse(raw);
|
|
36
|
+
compiled = data.compiled;
|
|
37
|
+
if (typeof compiled !== 'string') throw new Error('no .compiled string in JSON');
|
|
38
|
+
// The kinds of the view data (the build knows them: the pagination view
|
|
39
|
+
// receives a paginator).
|
|
40
|
+
if (data.viewDataKinds && typeof data.viewDataKinds === 'object') {
|
|
41
|
+
viewDataKinds = data.viewDataKinds;
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
compiled = raw;
|
|
45
|
+
}
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.error(JSON.stringify([{ code: 'LW004', message: 'cannot read input: ' + (e.message || e), line: 0, column: 0, hint: '' }]));
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const { code, errors } = transpile(compiled, { viewDataKinds });
|
|
52
|
+
|
|
53
|
+
if (errors && errors.length) {
|
|
54
|
+
console.error(JSON.stringify(errors));
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (outPath) {
|
|
59
|
+
const absOut = path.resolve(process.cwd(), outPath);
|
|
60
|
+
const tmp = absOut + '.tmp-' + process.pid;
|
|
61
|
+
fs.writeFileSync(tmp, code, 'utf8');
|
|
62
|
+
fs.renameSync(tmp, absOut);
|
|
63
|
+
} else {
|
|
64
|
+
process.stdout.write(code);
|
|
65
|
+
}
|