@skillstech/thunderlang 0.5.8 → 0.5.9
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/CHANGELOG.md +8 -0
- package/dist/core.cjs +22 -1
- package/dist/index.cjs +21 -1
- package/dist/learn.cjs +21 -1
- package/package.json +1 -1
- package/src/emit.mjs +1 -1
- package/src/model.mjs +1 -0
- package/src/steps.mjs +31 -0
- package/src/visual.d.mts +1 -1
- package/src/visual.mjs +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# 0.5.9
|
|
2
|
+
|
|
3
|
+
**Language: redirects say where the person goes.** A redirect reads "Sends the person to /login" (or "the Google
|
|
4
|
+
auth URL", "the dashboard page") instead of "Gives back the result of redirect", and has its own step kind,
|
|
5
|
+
`redirect` (mark ↪), in `THUNDER_VISUAL.does`. Fastify and Express `redirect`, `Response`/`NextResponse.redirect`,
|
|
6
|
+
Flask/Django/Next `redirect(...)`, `HttpResponseRedirect`, FastAPI `RedirectResponse`, Laravel `redirect()->route()`.
|
|
7
|
+
Found by OpenThunder on its own sign-in route.
|
|
8
|
+
|
|
1
9
|
# 0.5.8
|
|
2
10
|
|
|
3
11
|
**Language: Details is a fact sheet.** `readLevel(model, 'details', id)` now gives what you need to check before you
|
package/dist/core.cjs
CHANGED
|
@@ -2198,6 +2198,23 @@ function httpErrorOf(head) {
|
|
|
2198
2198
|
const msg = (expr.match(/\b(?:error|message|detail|msg)\s*[:=]\s*["'`]([^"'`]{1,80})["'`]/) || expr.match(/\.(?:send|json|end)\(\s*["'`]([^"'`]{1,80})["'`]/) || [])[1];
|
|
2199
2199
|
return { kind: "fail", says: `Fails with ${status} ${name}${msg ? `: "${msg}"` : ""}`, error: `${status} ${name}`, ...msg ? { message: msg } : {}, status };
|
|
2200
2200
|
}
|
|
2201
|
+
function redirectTarget(arg) {
|
|
2202
|
+
const a = String(arg || "").trim().replace(/^(?:url|to|location|redirect_to)\s*=\s*/, "");
|
|
2203
|
+
let m;
|
|
2204
|
+
if (m = a.match(/^(?:new\s+URL\(\s*)?["'`](\/[^"'`$?#]*|https?:\/\/[^"'`$/?#]+[^"'`$?#]*)/)) return m[1];
|
|
2205
|
+
if (m = a.match(/^`\$\{\s*([A-Za-z_][\w.]*)\s*\}/)) return `the ${words2(m[1].split(".").pop()).replace(/\burl\b/i, "URL")}`;
|
|
2206
|
+
if (m = a.match(/\b(?:url_for|reverse|route|url)\(\s*["']([\w.:-]+)["']/)) return `the ${words2(m[1].split(/[.:]/).pop())} page`;
|
|
2207
|
+
if (m = a.match(/^([A-Za-z_][\w.]*)$/)) return `the ${words2(m[1].split(".").pop()).replace(/\burl\b/i, "URL")}`;
|
|
2208
|
+
return "another page";
|
|
2209
|
+
}
|
|
2210
|
+
function redirectOf(head) {
|
|
2211
|
+
const isReturn = /^return\b/.test(head);
|
|
2212
|
+
const expr = head.replace(/^return\s+/, "").replace(/^await\s+/, "").replace(/;\s*$/, "").trim();
|
|
2213
|
+
let m = expr.match(/^(?:reply|res|response|resp|ctx|c)\s*\.\s*redirect\s*\(\s*(?:\d{3}\s*,\s*)?(.*)\)\s*$/) || expr.match(/^(?:Response|NextResponse)\s*\.\s*redirect\s*\(\s*(.*?)\s*(?:,\s*\d{3}\s*)?\)\s*$/) || expr.match(/^(?:HttpResponseRedirect|HttpResponsePermanentRedirect|RedirectResponse|redirect)\s*\(\s*(.*?)\s*(?:,\s*(?:\d{3}|status(?:_code)?\s*=\s*\d{3}|permanent\s*=\s*\w+)\s*)?\)\s*$/) || expr.match(/^redirect\(\s*\)\s*->\s*(route\(.*\))\s*$/);
|
|
2214
|
+
if (!m) return null;
|
|
2215
|
+
const to = redirectTarget(m[1]);
|
|
2216
|
+
return { kind: isReturn ? "return" : "call", says: `Sends the person to ${to}`, redirect: to };
|
|
2217
|
+
}
|
|
2201
2218
|
function classifyStatement(raw, { inner = 0 } = {}) {
|
|
2202
2219
|
const text = String(raw).trim();
|
|
2203
2220
|
const head = text.split("\n")[0].trim().replace(/\(\s*([\w$#.]+)\s+as\s+[^)]+\)/g, "$1").replace(/([\w$\])])!(?=[.(\[])/g, "$1").replace(/\?\.(?=[\w(\[])/g, ".").replace(/\.\(/g, "(").replace(/^\(\*+(self|this)\)\./, "$1.").replace(/\(\(\s*[A-Z][\w.<>\[\]?, ]*\s*\)\s*([\w$.]+)\s*\)/g, "$1").replace(/^(\w[\w.]*\s*=\s*)\(\s*[A-Z][\w.<>\[\]?]*\s*\)\s*/, "$1");
|
|
@@ -2224,6 +2241,8 @@ function classifyStatement(raw, { inner = 0 } = {}) {
|
|
|
2224
2241
|
}
|
|
2225
2242
|
const httpFail = httpErrorOf(head);
|
|
2226
2243
|
if (httpFail) return { ...httpFail, code };
|
|
2244
|
+
const redirect = redirectOf(head);
|
|
2245
|
+
if (redirect) return { ...redirect, code };
|
|
2227
2246
|
if (m = head.match(/^return\b\s*(.*)$/)) {
|
|
2228
2247
|
const expr = stripTail(m[1]);
|
|
2229
2248
|
if (!expr) return { kind: "return", says: "Stops here", code };
|
|
@@ -3486,7 +3505,7 @@ function notesSummary(ast) {
|
|
|
3486
3505
|
byLens
|
|
3487
3506
|
};
|
|
3488
3507
|
}
|
|
3489
|
-
var COMPILER_VERSION = "0.5.
|
|
3508
|
+
var COMPILER_VERSION = "0.5.9";
|
|
3490
3509
|
var PROOF_SCHEMA_VERSION = "0.1.0";
|
|
3491
3510
|
var SOURCE_PRODUCT = "skillstech-compiler";
|
|
3492
3511
|
function buildContractGraph(ast, generatedAt) {
|
|
@@ -7979,6 +7998,7 @@ var DOES = {
|
|
|
7979
7998
|
calculate: { label: "Works out", mark: "=", color: "fact" },
|
|
7980
7999
|
save: { label: "Saves", mark: "\u2913", color: "outcome" },
|
|
7981
8000
|
send: { label: "Tells someone", mark: "\u2709", color: "outcome" },
|
|
8001
|
+
redirect: { label: "Sends the person to", mark: "\u21AA", color: "outcome" },
|
|
7982
8002
|
ask: { label: "Asks another part", mark: "\u21C4", color: "outcome" },
|
|
7983
8003
|
repeat: { label: "For each", mark: "\u21BB", color: "structure" },
|
|
7984
8004
|
answer: { label: "Gives back", mark: "\u21E5", color: "outcome" },
|
|
@@ -8355,6 +8375,7 @@ function stepDoes(step) {
|
|
|
8355
8375
|
const s = step.says || "", c = step.callee || "";
|
|
8356
8376
|
if (step.restates || step.kind === "other") return "code";
|
|
8357
8377
|
if (step.kind === "fail") return "stop";
|
|
8378
|
+
if (step.redirect) return "redirect";
|
|
8358
8379
|
if (step.kind === "loop") return "repeat";
|
|
8359
8380
|
if (step.kind === "return") return "answer";
|
|
8360
8381
|
if (step.kind === "check") return "check";
|
package/dist/index.cjs
CHANGED
|
@@ -2423,7 +2423,7 @@ function notesSummary(ast) {
|
|
|
2423
2423
|
byLens
|
|
2424
2424
|
};
|
|
2425
2425
|
}
|
|
2426
|
-
var COMPILER_VERSION = "0.5.
|
|
2426
|
+
var COMPILER_VERSION = "0.5.9";
|
|
2427
2427
|
var PROOF_SCHEMA_VERSION = "0.1.0";
|
|
2428
2428
|
var SOURCE_PRODUCT = "skillstech-compiler";
|
|
2429
2429
|
function buildContractGraph(ast, generatedAt) {
|
|
@@ -9409,6 +9409,23 @@ function httpErrorOf(head) {
|
|
|
9409
9409
|
const msg = (expr.match(/\b(?:error|message|detail|msg)\s*[:=]\s*["'`]([^"'`]{1,80})["'`]/) || expr.match(/\.(?:send|json|end)\(\s*["'`]([^"'`]{1,80})["'`]/) || [])[1];
|
|
9410
9410
|
return { kind: "fail", says: `Fails with ${status} ${name}${msg ? `: "${msg}"` : ""}`, error: `${status} ${name}`, ...msg ? { message: msg } : {}, status };
|
|
9411
9411
|
}
|
|
9412
|
+
function redirectTarget(arg) {
|
|
9413
|
+
const a = String(arg || "").trim().replace(/^(?:url|to|location|redirect_to)\s*=\s*/, "");
|
|
9414
|
+
let m;
|
|
9415
|
+
if (m = a.match(/^(?:new\s+URL\(\s*)?["'`](\/[^"'`$?#]*|https?:\/\/[^"'`$/?#]+[^"'`$?#]*)/)) return m[1];
|
|
9416
|
+
if (m = a.match(/^`\$\{\s*([A-Za-z_][\w.]*)\s*\}/)) return `the ${words2(m[1].split(".").pop()).replace(/\burl\b/i, "URL")}`;
|
|
9417
|
+
if (m = a.match(/\b(?:url_for|reverse|route|url)\(\s*["']([\w.:-]+)["']/)) return `the ${words2(m[1].split(/[.:]/).pop())} page`;
|
|
9418
|
+
if (m = a.match(/^([A-Za-z_][\w.]*)$/)) return `the ${words2(m[1].split(".").pop()).replace(/\burl\b/i, "URL")}`;
|
|
9419
|
+
return "another page";
|
|
9420
|
+
}
|
|
9421
|
+
function redirectOf(head) {
|
|
9422
|
+
const isReturn = /^return\b/.test(head);
|
|
9423
|
+
const expr = head.replace(/^return\s+/, "").replace(/^await\s+/, "").replace(/;\s*$/, "").trim();
|
|
9424
|
+
let m = expr.match(/^(?:reply|res|response|resp|ctx|c)\s*\.\s*redirect\s*\(\s*(?:\d{3}\s*,\s*)?(.*)\)\s*$/) || expr.match(/^(?:Response|NextResponse)\s*\.\s*redirect\s*\(\s*(.*?)\s*(?:,\s*\d{3}\s*)?\)\s*$/) || expr.match(/^(?:HttpResponseRedirect|HttpResponsePermanentRedirect|RedirectResponse|redirect)\s*\(\s*(.*?)\s*(?:,\s*(?:\d{3}|status(?:_code)?\s*=\s*\d{3}|permanent\s*=\s*\w+)\s*)?\)\s*$/) || expr.match(/^redirect\(\s*\)\s*->\s*(route\(.*\))\s*$/);
|
|
9425
|
+
if (!m) return null;
|
|
9426
|
+
const to = redirectTarget(m[1]);
|
|
9427
|
+
return { kind: isReturn ? "return" : "call", says: `Sends the person to ${to}`, redirect: to };
|
|
9428
|
+
}
|
|
9412
9429
|
function classifyStatement(raw, { inner = 0 } = {}) {
|
|
9413
9430
|
const text = String(raw).trim();
|
|
9414
9431
|
const head = text.split("\n")[0].trim().replace(/\(\s*([\w$#.]+)\s+as\s+[^)]+\)/g, "$1").replace(/([\w$\])])!(?=[.(\[])/g, "$1").replace(/\?\.(?=[\w(\[])/g, ".").replace(/\.\(/g, "(").replace(/^\(\*+(self|this)\)\./, "$1.").replace(/\(\(\s*[A-Z][\w.<>\[\]?, ]*\s*\)\s*([\w$.]+)\s*\)/g, "$1").replace(/^(\w[\w.]*\s*=\s*)\(\s*[A-Z][\w.<>\[\]?]*\s*\)\s*/, "$1");
|
|
@@ -9435,6 +9452,8 @@ function classifyStatement(raw, { inner = 0 } = {}) {
|
|
|
9435
9452
|
}
|
|
9436
9453
|
const httpFail = httpErrorOf(head);
|
|
9437
9454
|
if (httpFail) return { ...httpFail, code };
|
|
9455
|
+
const redirect = redirectOf(head);
|
|
9456
|
+
if (redirect) return { ...redirect, code };
|
|
9438
9457
|
if (m = head.match(/^return\b\s*(.*)$/)) {
|
|
9439
9458
|
const expr = stripTail(m[1]);
|
|
9440
9459
|
if (!expr) return { kind: "return", says: "Stops here", code };
|
|
@@ -13629,6 +13648,7 @@ var DOES = {
|
|
|
13629
13648
|
calculate: { label: "Works out", mark: "=", color: "fact" },
|
|
13630
13649
|
save: { label: "Saves", mark: "\u2913", color: "outcome" },
|
|
13631
13650
|
send: { label: "Tells someone", mark: "\u2709", color: "outcome" },
|
|
13651
|
+
redirect: { label: "Sends the person to", mark: "\u21AA", color: "outcome" },
|
|
13632
13652
|
ask: { label: "Asks another part", mark: "\u21C4", color: "outcome" },
|
|
13633
13653
|
repeat: { label: "For each", mark: "\u21BB", color: "structure" },
|
|
13634
13654
|
answer: { label: "Gives back", mark: "\u21E5", color: "outcome" },
|
package/dist/learn.cjs
CHANGED
|
@@ -227,6 +227,23 @@ function httpErrorOf(head) {
|
|
|
227
227
|
const msg = (expr.match(/\b(?:error|message|detail|msg)\s*[:=]\s*["'`]([^"'`]{1,80})["'`]/) || expr.match(/\.(?:send|json|end)\(\s*["'`]([^"'`]{1,80})["'`]/) || [])[1];
|
|
228
228
|
return { kind: "fail", says: `Fails with ${status} ${name}${msg ? `: "${msg}"` : ""}`, error: `${status} ${name}`, ...msg ? { message: msg } : {}, status };
|
|
229
229
|
}
|
|
230
|
+
function redirectTarget(arg) {
|
|
231
|
+
const a = String(arg || "").trim().replace(/^(?:url|to|location|redirect_to)\s*=\s*/, "");
|
|
232
|
+
let m;
|
|
233
|
+
if (m = a.match(/^(?:new\s+URL\(\s*)?["'`](\/[^"'`$?#]*|https?:\/\/[^"'`$/?#]+[^"'`$?#]*)/)) return m[1];
|
|
234
|
+
if (m = a.match(/^`\$\{\s*([A-Za-z_][\w.]*)\s*\}/)) return `the ${words(m[1].split(".").pop()).replace(/\burl\b/i, "URL")}`;
|
|
235
|
+
if (m = a.match(/\b(?:url_for|reverse|route|url)\(\s*["']([\w.:-]+)["']/)) return `the ${words(m[1].split(/[.:]/).pop())} page`;
|
|
236
|
+
if (m = a.match(/^([A-Za-z_][\w.]*)$/)) return `the ${words(m[1].split(".").pop()).replace(/\burl\b/i, "URL")}`;
|
|
237
|
+
return "another page";
|
|
238
|
+
}
|
|
239
|
+
function redirectOf(head) {
|
|
240
|
+
const isReturn = /^return\b/.test(head);
|
|
241
|
+
const expr = head.replace(/^return\s+/, "").replace(/^await\s+/, "").replace(/;\s*$/, "").trim();
|
|
242
|
+
let m = expr.match(/^(?:reply|res|response|resp|ctx|c)\s*\.\s*redirect\s*\(\s*(?:\d{3}\s*,\s*)?(.*)\)\s*$/) || expr.match(/^(?:Response|NextResponse)\s*\.\s*redirect\s*\(\s*(.*?)\s*(?:,\s*\d{3}\s*)?\)\s*$/) || expr.match(/^(?:HttpResponseRedirect|HttpResponsePermanentRedirect|RedirectResponse|redirect)\s*\(\s*(.*?)\s*(?:,\s*(?:\d{3}|status(?:_code)?\s*=\s*\d{3}|permanent\s*=\s*\w+)\s*)?\)\s*$/) || expr.match(/^redirect\(\s*\)\s*->\s*(route\(.*\))\s*$/);
|
|
243
|
+
if (!m) return null;
|
|
244
|
+
const to = redirectTarget(m[1]);
|
|
245
|
+
return { kind: isReturn ? "return" : "call", says: `Sends the person to ${to}`, redirect: to };
|
|
246
|
+
}
|
|
230
247
|
function classifyStatement(raw, { inner = 0 } = {}) {
|
|
231
248
|
const text = String(raw).trim();
|
|
232
249
|
const head = text.split("\n")[0].trim().replace(/\(\s*([\w$#.]+)\s+as\s+[^)]+\)/g, "$1").replace(/([\w$\])])!(?=[.(\[])/g, "$1").replace(/\?\.(?=[\w(\[])/g, ".").replace(/\.\(/g, "(").replace(/^\(\*+(self|this)\)\./, "$1.").replace(/\(\(\s*[A-Z][\w.<>\[\]?, ]*\s*\)\s*([\w$.]+)\s*\)/g, "$1").replace(/^(\w[\w.]*\s*=\s*)\(\s*[A-Z][\w.<>\[\]?]*\s*\)\s*/, "$1");
|
|
@@ -253,6 +270,8 @@ function classifyStatement(raw, { inner = 0 } = {}) {
|
|
|
253
270
|
}
|
|
254
271
|
const httpFail = httpErrorOf(head);
|
|
255
272
|
if (httpFail) return { ...httpFail, code };
|
|
273
|
+
const redirect = redirectOf(head);
|
|
274
|
+
if (redirect) return { ...redirect, code };
|
|
256
275
|
if (m = head.match(/^return\b\s*(.*)$/)) {
|
|
257
276
|
const expr = stripTail(m[1]);
|
|
258
277
|
if (!expr) return { kind: "return", says: "Stops here", code };
|
|
@@ -1937,7 +1956,7 @@ var SEMANTIC_TYPES = Object.keys(SEMANTIC);
|
|
|
1937
1956
|
var PRIMITIVE_TYPES = Object.keys(PRIMITIVE);
|
|
1938
1957
|
|
|
1939
1958
|
// src/emit.mjs
|
|
1940
|
-
var COMPILER_VERSION = "0.5.
|
|
1959
|
+
var COMPILER_VERSION = "0.5.9";
|
|
1941
1960
|
|
|
1942
1961
|
// src/lift.mjs
|
|
1943
1962
|
var IR_SCHEMA_VERSION = "0.1.0";
|
|
@@ -5055,6 +5074,7 @@ function stepDoes(step) {
|
|
|
5055
5074
|
const s = step.says || "", c = step.callee || "";
|
|
5056
5075
|
if (step.restates || step.kind === "other") return "code";
|
|
5057
5076
|
if (step.kind === "fail") return "stop";
|
|
5077
|
+
if (step.redirect) return "redirect";
|
|
5058
5078
|
if (step.kind === "loop") return "repeat";
|
|
5059
5079
|
if (step.kind === "return") return "answer";
|
|
5060
5080
|
if (step.kind === "check") return "check";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skillstech/thunderlang",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"description": "Deterministic ThunderLang compiler, CLI, and Language Server. No AI required. Turns .thunder files into the canonical Intent Graph, docs, and a proof, and EXECUTES the intent: run decisions, simulate lifecycles, and check outcome contracts. Interops with DMN, BPMN, JSON Schema, and OpenAPI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.mjs",
|
package/src/emit.mjs
CHANGED
|
@@ -30,7 +30,7 @@ export function notesSummary(ast) {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export const COMPILER_VERSION = '0.5.
|
|
33
|
+
export const COMPILER_VERSION = '0.5.9';
|
|
34
34
|
export const PROOF_SCHEMA_VERSION = '0.1.0';
|
|
35
35
|
// Identifies which ecosystem product emitted this proof. Consumed by SkillsTech
|
|
36
36
|
// Certified to key cert proofs to the compiler. Stable slug per the coordination bus.
|
package/src/model.mjs
CHANGED
|
@@ -173,6 +173,7 @@ export function stepDoes(step) {
|
|
|
173
173
|
const s = step.says || '', c = step.callee || '';
|
|
174
174
|
if (step.restates || step.kind === 'other') return 'code';
|
|
175
175
|
if (step.kind === 'fail') return 'stop';
|
|
176
|
+
if (step.redirect) return 'redirect';
|
|
176
177
|
if (step.kind === 'loop') return 'repeat';
|
|
177
178
|
if (step.kind === 'return') return 'answer';
|
|
178
179
|
if (step.kind === 'check') return 'check';
|
package/src/steps.mjs
CHANGED
|
@@ -242,6 +242,34 @@ function httpErrorOf(head) {
|
|
|
242
242
|
return { kind: 'fail', says: `Fails with ${status} ${name}${msg ? `: "${msg}"` : ''}`, error: `${status} ${name}`, ...(msg ? { message: msg } : {}), status };
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
+
/** Where a redirect goes, in words: '/login' stays a path, `${GOOGLE_AUTH_URL}?…` -> "the Google auth URL", url_for('home') -> "the home page". */
|
|
246
|
+
function redirectTarget(arg) {
|
|
247
|
+
const a = String(arg || '').trim().replace(/^(?:url|to|location|redirect_to)\s*=\s*/, '');
|
|
248
|
+
let m;
|
|
249
|
+
if ((m = a.match(/^(?:new\s+URL\(\s*)?["'`](\/[^"'`$?#]*|https?:\/\/[^"'`$/?#]+[^"'`$?#]*)/))) return m[1];
|
|
250
|
+
if ((m = a.match(/^`\$\{\s*([A-Za-z_][\w.]*)\s*\}/))) return `the ${words(m[1].split('.').pop()).replace(/\burl\b/i, 'URL')}`;
|
|
251
|
+
if ((m = a.match(/\b(?:url_for|reverse|route|url)\(\s*["']([\w.:-]+)["']/))) return `the ${words(m[1].split(/[.:]/).pop())} page`;
|
|
252
|
+
if ((m = a.match(/^([A-Za-z_][\w.]*)$/))) return `the ${words(m[1].split('.').pop()).replace(/\burl\b/i, 'URL')}`;
|
|
253
|
+
return 'another page';
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* A redirect: Fastify/Express `reply.redirect(url)` / `res.redirect(302, url)`, `Response.redirect(url)`,
|
|
258
|
+
* `NextResponse.redirect(...)`, Flask/Django/Next `redirect(url)`, `HttpResponseRedirect(url)`,
|
|
259
|
+
* FastAPI `RedirectResponse(url)`, Laravel `redirect()->route('home')`. Gives a step that says where the person goes.
|
|
260
|
+
*/
|
|
261
|
+
function redirectOf(head) {
|
|
262
|
+
const isReturn = /^return\b/.test(head);
|
|
263
|
+
const expr = head.replace(/^return\s+/, '').replace(/^await\s+/, '').replace(/;\s*$/, '').trim();
|
|
264
|
+
let m = expr.match(/^(?:reply|res|response|resp|ctx|c)\s*\.\s*redirect\s*\(\s*(?:\d{3}\s*,\s*)?(.*)\)\s*$/)
|
|
265
|
+
|| expr.match(/^(?:Response|NextResponse)\s*\.\s*redirect\s*\(\s*(.*?)\s*(?:,\s*\d{3}\s*)?\)\s*$/)
|
|
266
|
+
|| expr.match(/^(?:HttpResponseRedirect|HttpResponsePermanentRedirect|RedirectResponse|redirect)\s*\(\s*(.*?)\s*(?:,\s*(?:\d{3}|status(?:_code)?\s*=\s*\d{3}|permanent\s*=\s*\w+)\s*)?\)\s*$/)
|
|
267
|
+
|| expr.match(/^redirect\(\s*\)\s*->\s*(route\(.*\))\s*$/);
|
|
268
|
+
if (!m) return null;
|
|
269
|
+
const to = redirectTarget(m[1]);
|
|
270
|
+
return { kind: isReturn ? 'return' : 'call', says: `Sends the person to ${to}`, redirect: to };
|
|
271
|
+
}
|
|
272
|
+
|
|
245
273
|
export function classifyStatement(raw, { inner = 0 } = {}) {
|
|
246
274
|
const text = String(raw).trim();
|
|
247
275
|
// TypeScript-only syntax that changes nothing for a reader: casts, non-null assertions, optional calls.
|
|
@@ -278,6 +306,9 @@ export function classifyStatement(raw, { inner = 0 } = {}) {
|
|
|
278
306
|
// An HTTP error response (4xx/5xx) is a Stop: the request is refused, with a status and a message.
|
|
279
307
|
const httpFail = httpErrorOf(head);
|
|
280
308
|
if (httpFail) return { ...httpFail, code };
|
|
309
|
+
// A redirect sends the person somewhere else: "Sends the person to the Google auth URL".
|
|
310
|
+
const redirect = redirectOf(head);
|
|
311
|
+
if (redirect) return { ...redirect, code };
|
|
281
312
|
// Returns (Go/Rust error returns read as failures)
|
|
282
313
|
if ((m = head.match(/^return\b\s*(.*)$/))) {
|
|
283
314
|
const expr = stripTail(m[1]);
|
package/src/visual.d.mts
CHANGED
|
@@ -29,7 +29,7 @@ export function visualForStep(step: ReadStep): { mark: string; label: string; co
|
|
|
29
29
|
export function thunderText(item: ReadItem): string;
|
|
30
30
|
export type SymbolId = 'app' | 'area' | 'file' | 'thing' | 'data' | 'record' | 'choices' | 'action' | 'rule' | 'steps' | 'setup' | 'stop' | 'not-read';
|
|
31
31
|
export const SYMBOLS: Record<SymbolId, { name: string; says: string; color: ColorRole; paths: string[]; circles?: [number, number, number][]; fill?: boolean; dashed?: boolean; beginner?: boolean; group?: string }>;
|
|
32
|
-
export type Does = 'start' | 'find' | 'keep-only' | 'check' | 'decide' | 'calculate' | 'save' | 'send' | 'ask' | 'repeat' | 'answer' | 'stop' | 'do' | 'code';
|
|
32
|
+
export type Does = 'start' | 'find' | 'keep-only' | 'check' | 'decide' | 'calculate' | 'save' | 'send' | 'redirect' | 'ask' | 'repeat' | 'answer' | 'stop' | 'do' | 'code';
|
|
33
33
|
export const DOES: Record<Does, { label: string; mark: string; color: ColorRole; dashed?: boolean; symbol?: SymbolId }>;
|
|
34
34
|
export const BEGINNER: SymbolId[];
|
|
35
35
|
/** The five reading levels, in order: how deep you read something. */
|
package/src/visual.mjs
CHANGED
|
@@ -250,6 +250,7 @@ export const DOES = {
|
|
|
250
250
|
calculate: { label: 'Works out', mark: '=', color: 'fact' },
|
|
251
251
|
save: { label: 'Saves', mark: '⤓', color: 'outcome' },
|
|
252
252
|
send: { label: 'Tells someone', mark: '✉', color: 'outcome' },
|
|
253
|
+
redirect: { label: 'Sends the person to', mark: '↪', color: 'outcome' },
|
|
253
254
|
ask: { label: 'Asks another part', mark: '⇄', color: 'outcome' },
|
|
254
255
|
repeat: { label: 'For each', mark: '↻', color: 'structure' },
|
|
255
256
|
answer: { label: 'Gives back', mark: '⇥', color: 'outcome' },
|