@akanjs/cli 3.1.2-rc.1 → 3.1.2-rc.3
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/.build-stamp +1 -1
- package/{CodeAgent-dyc45f5w.js → CodeAgent-n2tkg59z.js} +2 -2
- package/{CodeTui-q55b2zrn.js → CodeTui-9wsdx7ap.js} +1 -1
- package/{TunnelShare-hdq9h1hr.js → TunnelShare-6d7z36sr.js} +1 -1
- package/{agent.command-20zaqe60.js → agent.command-tffz6wdn.js} +8 -8
- package/akanCode.js +2 -2
- package/{application.command-nd0fshsk.js → application.command-7bkxbrsp.js} +17 -2
- package/{cloud.command-8kbddsz9.js → cloud.command-a792bc10.js} +3 -3
- package/{cloud.script-hgvvajm3.js → cloud.script-t2n13gv6.js} +3 -3
- package/{code.command-625bg8s8.js → code.command-ma8dtzww.js} +4 -4
- package/commandManifest.json +1 -1
- package/{context.command-p6haqjay.js → context.command-80a1qhps.js} +12 -11
- package/{context.runner-rsnqnk9j.js → context.runner-wxqb3qcy.js} +11 -10
- package/incrementalBuilder.proc.js +22 -2
- package/{index-g841cap9.js → index-361ex3rb.js} +23 -2
- package/{index-raz588b3.js → index-9z3egsmg.js} +8 -7
- package/{index-fhw7yq2d.js → index-aayg4dqf.js} +4 -4
- package/{index-ewbmfarf.js → index-db2nqrad.js} +20 -2
- package/{index-7apsdr5g.js → index-eft5c2mp.js} +1 -1
- package/{index-t1t9wq9a.js → index-gbp1q1b5.js} +1 -1
- package/{index-jc2zbwra.js → index-hapx5myy.js} +1 -1
- package/index-j2dgmzbj.js +1259 -0
- package/{index-j7hwy56s.js → index-j9d3mjx1.js} +1 -1
- package/{index-qw6814m4.js → index-jb2sreps.js} +20 -5
- package/{index-fbewhg4g.js → index-k64mhwbw.js} +60 -1
- package/{index-hm0tn7qv.js → index-m02tdq8a.js} +102 -4
- package/{index-2mwjshz5.js → index-ppvqy5bc.js} +8 -5
- package/{index-tgqameyb.js → index-scck6h6d.js} +3 -3
- package/{index-cjmjvg4r.js → index-sjabnf7j.js} +2 -2
- package/{index-00a7j05x.js → index-sx91nf4z.js} +1 -1
- package/{index-2phm56a1.js → index-tns543wd.js} +2 -2
- package/index-vzpnr12w.js +65 -0
- package/{index-1qsd8ft1.js → index-wrmq92vk.js} +1 -1
- package/{index-a1vb3x7t.js → index-z7kbxdqg.js} +3 -3
- package/{index-t78230d7.js → index-zdpte1pj.js} +2 -1
- package/index.js +16 -16
- package/{localRegistry.command-g3f8k25t.js → localRegistry.command-343ksmn9.js} +2 -2
- package/{module.command-r4sa2khp.js → module.command-2hce9m6k.js} +3 -3
- package/package.json +2 -2
- package/{primitive.command-dfsv4mpe.js → primitive.command-7tdj12wn.js} +4 -4
- package/{quality.command-webzxee2.js → quality.command-29bgarh1.js} +3 -3
- package/{repair.command-3r3j1xre.js → repair.command-yng4rf5d.js} +4 -4
- package/{scalar.command-e8y47j6d.js → scalar.command-1nk4329t.js} +3 -3
- package/skills/akan-scaffold/SKILL.md +1 -0
- package/{subspace.command-a1sf9n5a.js → subspace.command-5cehmcdd.js} +1 -1
- package/{tunnel.command-dcb0wg93.js → tunnel.command-yrd4atqy.js} +1 -1
- package/{verify.command-yyepccbh.js → verify.command-kbq0fcg8.js} +5 -5
- package/{workflow.command-z5pg9ay0.js → workflow.command-274qfa8z.js} +13 -11
- package/{workspace.command-d7x5jttw.js → workspace.command-r6hgmawy.js} +18 -17
- package/index-2nxk8wgs.js +0 -266
|
@@ -7,13 +7,13 @@ import"./index-bns3wcpc.js";
|
|
|
7
7
|
import"./index-g500c5j9.js";
|
|
8
8
|
import {
|
|
9
9
|
renderPrimitiveReport
|
|
10
|
-
} from "./index-
|
|
11
|
-
import"./index-
|
|
10
|
+
} from "./index-m02tdq8a.js";
|
|
11
|
+
import"./index-j2dgmzbj.js";
|
|
12
12
|
import"./index-khk05tsf.js";
|
|
13
|
-
import"./index-
|
|
13
|
+
import"./index-gbp1q1b5.js";
|
|
14
14
|
import {
|
|
15
15
|
PrimitiveScript
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-361ex3rb.js";
|
|
17
17
|
|
|
18
18
|
// pkgs/@akanjs/cli/primitive/primitive.command.ts
|
|
19
19
|
import { Logger } from "akanjs/common";
|
|
@@ -15,12 +15,12 @@ import {
|
|
|
15
15
|
AkanQualityScanner,
|
|
16
16
|
formatQualityScanResult,
|
|
17
17
|
formatSsrScanResult
|
|
18
|
-
} from "./index-
|
|
19
|
-
import"./index-
|
|
18
|
+
} from "./index-sjabnf7j.js";
|
|
19
|
+
import"./index-j2dgmzbj.js";
|
|
20
20
|
import"./index-62md4dwy.js";
|
|
21
21
|
import"./index-hj6w4ka1.js";
|
|
22
22
|
import"./index-4am4dvmf.js";
|
|
23
|
-
import"./index-
|
|
23
|
+
import"./index-k64mhwbw.js";
|
|
24
24
|
|
|
25
25
|
// pkgs/@akanjs/cli/quality/quality.script.ts
|
|
26
26
|
import { Logger } from "akanjs/common";
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
import"./index-bns3wcpc.js";
|
|
8
8
|
import"./index-g500c5j9.js";
|
|
9
9
|
import"./index-hj6w4ka1.js";
|
|
10
|
-
import"./index-
|
|
11
|
-
import"./index-
|
|
12
|
-
import"./index-
|
|
10
|
+
import"./index-m02tdq8a.js";
|
|
11
|
+
import"./index-j2dgmzbj.js";
|
|
12
|
+
import"./index-j9d3mjx1.js";
|
|
13
13
|
import {
|
|
14
14
|
RepairRunner
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-tns543wd.js";
|
|
16
16
|
|
|
17
17
|
// pkgs/@akanjs/cli/repair/repair.script.ts
|
|
18
18
|
import { Logger } from "akanjs/common";
|
|
@@ -7,11 +7,11 @@ import"./index-bns3wcpc.js";
|
|
|
7
7
|
import"./index-g500c5j9.js";
|
|
8
8
|
import {
|
|
9
9
|
renderPrimitiveReport
|
|
10
|
-
} from "./index-
|
|
11
|
-
import"./index-
|
|
10
|
+
} from "./index-m02tdq8a.js";
|
|
11
|
+
import"./index-j2dgmzbj.js";
|
|
12
12
|
import {
|
|
13
13
|
ScalarScript
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-hapx5myy.js";
|
|
15
15
|
|
|
16
16
|
// pkgs/@akanjs/cli/scalar/scalar.command.ts
|
|
17
17
|
import { Logger, lowerlize } from "akanjs/common";
|
|
@@ -32,6 +32,7 @@ Then pick the workflow that matches the intent:
|
|
|
32
32
|
| a new field with a closed set of values | `add-enum-field` |
|
|
33
33
|
| a new state-changing action | `add-mutation` |
|
|
34
34
|
| a filtered list, tab, or reusable query | `add-slice` |
|
|
35
|
+
| a slice or query key renamed, with every name derived from it | `rename-key` |
|
|
35
36
|
| a View / Unit / Template / Zone / Util for an existing module | `create-ui` |
|
|
36
37
|
|
|
37
38
|
## The chain
|
|
@@ -818,7 +818,7 @@ class SubspaceRunner extends runner("subspace") {
|
|
|
818
818
|
if (!asked)
|
|
819
819
|
return { name: subspace.name, workspaceId, host, apps, libs: [], outcome: "cancelled", files: [] };
|
|
820
820
|
const { libs } = await subspace.slice();
|
|
821
|
-
const { CloudScript } = await import("./cloud.script-
|
|
821
|
+
const { CloudScript } = await import("./cloud.script-t2n13gv6.js");
|
|
822
822
|
const { files } = await CommandContainer.get(CloudScript).uploadEnv(workspace, {
|
|
823
823
|
host,
|
|
824
824
|
workspaceId,
|
|
@@ -11,7 +11,7 @@ import"./index-g500c5j9.js";
|
|
|
11
11
|
import {
|
|
12
12
|
ApplicationRunner,
|
|
13
13
|
VerifyScope
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-ppvqy5bc.js";
|
|
15
15
|
import"./index-p6x5b7hr.js";
|
|
16
16
|
import"./index-sp0qsr7a.js";
|
|
17
17
|
import"./index-0j1t1h2b.js";
|
|
@@ -21,15 +21,15 @@ import"./index-sveq36gh.js";
|
|
|
21
21
|
import"./index-62md4dwy.js";
|
|
22
22
|
import {
|
|
23
23
|
WorkspaceRunner
|
|
24
|
-
} from "./index-
|
|
25
|
-
import"./index-
|
|
24
|
+
} from "./index-sjabnf7j.js";
|
|
25
|
+
import"./index-j2dgmzbj.js";
|
|
26
26
|
import"./index-hj6w4ka1.js";
|
|
27
27
|
import"./index-4am4dvmf.js";
|
|
28
|
-
import"./index-
|
|
28
|
+
import"./index-k64mhwbw.js";
|
|
29
29
|
import {
|
|
30
30
|
VerifyPipeline,
|
|
31
31
|
VerifyReport
|
|
32
|
-
} from "./index-
|
|
32
|
+
} from "./index-eft5c2mp.js";
|
|
33
33
|
import"./index-defp4gmb.js";
|
|
34
34
|
|
|
35
35
|
// pkgs/@akanjs/cli/verify/verify.script.ts
|
|
@@ -7,18 +7,18 @@ import {
|
|
|
7
7
|
import"./index-bns3wcpc.js";
|
|
8
8
|
import"./index-g500c5j9.js";
|
|
9
9
|
import"./index-hj6w4ka1.js";
|
|
10
|
-
import"./index-
|
|
11
|
-
import"./index-
|
|
12
|
-
import"./index-
|
|
10
|
+
import"./index-m02tdq8a.js";
|
|
11
|
+
import"./index-j2dgmzbj.js";
|
|
12
|
+
import"./index-j9d3mjx1.js";
|
|
13
13
|
import"./index-khk05tsf.js";
|
|
14
|
-
import"./index-
|
|
15
|
-
import"./index-
|
|
16
|
-
import"./index-
|
|
17
|
-
import"./index-
|
|
18
|
-
import"./index-
|
|
14
|
+
import"./index-gbp1q1b5.js";
|
|
15
|
+
import"./index-361ex3rb.js";
|
|
16
|
+
import"./index-tns543wd.js";
|
|
17
|
+
import"./index-hapx5myy.js";
|
|
18
|
+
import"./index-k64mhwbw.js";
|
|
19
19
|
import {
|
|
20
20
|
WorkflowRunner
|
|
21
|
-
} from "./index-
|
|
21
|
+
} from "./index-9z3egsmg.js";
|
|
22
22
|
|
|
23
23
|
// pkgs/@akanjs/cli/workflow/workflow.script.ts
|
|
24
24
|
import { Logger } from "akanjs/common";
|
|
@@ -79,7 +79,7 @@ class WorkflowCommand extends command("workflow", [WorkflowScript], ({ public: t
|
|
|
79
79
|
flag: "p",
|
|
80
80
|
desc: "add the field to the Light<Model> projection used by lists and cards",
|
|
81
81
|
nullable: true
|
|
82
|
-
}).option("mutation", String, { flag: "n", desc: "mutation name", nullable: true }).option("slice", String, { flag: "i", desc: "slice name", nullable: true }).option("guard", String, { flag: "g", desc: "comma-separated guard class names", nullable: true }).option("with", String, {
|
|
82
|
+
}).option("mutation", String, { flag: "n", desc: "mutation name", nullable: true }).option("slice", String, { flag: "i", desc: "slice name", nullable: true }).option("query", String, { desc: "Filter query key for rename-key", nullable: true }).option("to", String, { flag: "x", desc: "new key name for rename-key", nullable: true }).option("guard", String, { flag: "g", desc: "comma-separated guard class names", nullable: true }).option("with", String, {
|
|
83
83
|
flag: "b",
|
|
84
84
|
desc: "comma-separated <serviceRef>.<method> writes committed with the mutation",
|
|
85
85
|
nullable: true
|
|
@@ -87,7 +87,7 @@ class WorkflowCommand extends command("workflow", [WorkflowScript], ({ public: t
|
|
|
87
87
|
flag: "e",
|
|
88
88
|
desc: "comma-separated <serviceRef>.<method> side effects run after the commit",
|
|
89
89
|
nullable: true
|
|
90
|
-
}).option("interaction", String, { flag: "k", desc: "interaction name", nullable: true }).exec(async function(action, workflow, workspace, format, out, dryRun, app, module, field, typeName, values, defaultValue, scalar, surface, surfaces, includeInLight, mutation, slice, guard, withCalls, after, interaction) {
|
|
90
|
+
}).option("interaction", String, { flag: "k", desc: "interaction name", nullable: true }).exec(async function(action, workflow, workspace, format, out, dryRun, app, module, field, typeName, values, defaultValue, scalar, surface, surfaces, includeInLight, mutation, slice, query, to, guard, withCalls, after, interaction) {
|
|
91
91
|
await this.workflowScript.workflow(action, workflow, {
|
|
92
92
|
app,
|
|
93
93
|
module,
|
|
@@ -101,6 +101,8 @@ class WorkflowCommand extends command("workflow", [WorkflowScript], ({ public: t
|
|
|
101
101
|
includeInLight: includeInLight === null ? null : String(includeInLight),
|
|
102
102
|
mutation,
|
|
103
103
|
slice,
|
|
104
|
+
query,
|
|
105
|
+
to,
|
|
104
106
|
guard,
|
|
105
107
|
with: withCalls,
|
|
106
108
|
after,
|
|
@@ -19,15 +19,15 @@ import"./index-62md4dwy.js";
|
|
|
19
19
|
import {
|
|
20
20
|
defaultMaxDiagnostics,
|
|
21
21
|
WorkspaceRunner
|
|
22
|
-
} from "./index-
|
|
23
|
-
import"./index-
|
|
22
|
+
} from "./index-sjabnf7j.js";
|
|
23
|
+
import"./index-j2dgmzbj.js";
|
|
24
24
|
import"./index-hj6w4ka1.js";
|
|
25
|
-
import"./index-
|
|
25
|
+
import"./index-k64mhwbw.js";
|
|
26
26
|
import"./index-35j83zkd.js";
|
|
27
27
|
import"./index-j6eeh5d7.js";
|
|
28
|
-
import"./index-
|
|
29
|
-
import"./index-
|
|
30
|
-
import"./index-
|
|
28
|
+
import"./index-m02tdq8a.js";
|
|
29
|
+
import"./index-j9d3mjx1.js";
|
|
30
|
+
import"./index-ppvqy5bc.js";
|
|
31
31
|
import"./index-p6x5b7hr.js";
|
|
32
32
|
import"./index-sp0qsr7a.js";
|
|
33
33
|
import"./index-0j1t1h2b.js";
|
|
@@ -36,13 +36,13 @@ import"./index-zbrwnmf1.js";
|
|
|
36
36
|
import"./index-sveq36gh.js";
|
|
37
37
|
import {
|
|
38
38
|
AgentScript
|
|
39
|
-
} from "./index-
|
|
39
|
+
} from "./index-aayg4dqf.js";
|
|
40
40
|
import {
|
|
41
41
|
LibraryScript
|
|
42
42
|
} from "./index-y4kcmbt2.js";
|
|
43
43
|
import {
|
|
44
44
|
ApplicationScript
|
|
45
|
-
} from "./index-
|
|
45
|
+
} from "./index-db2nqrad.js";
|
|
46
46
|
import"./index-tenw3mah.js";
|
|
47
47
|
import"./index-gr9thy79.js";
|
|
48
48
|
import"./index-qd7xn2bk.js";
|
|
@@ -52,18 +52,19 @@ import {
|
|
|
52
52
|
import"./index-1h2jc0x3.js";
|
|
53
53
|
import {
|
|
54
54
|
CloudScript2
|
|
55
|
-
} from "./index-
|
|
56
|
-
import"./index-
|
|
57
|
-
import"./index-
|
|
55
|
+
} from "./index-sx91nf4z.js";
|
|
56
|
+
import"./index-jb2sreps.js";
|
|
57
|
+
import"./index-vzpnr12w.js";
|
|
58
|
+
import"./index-tns543wd.js";
|
|
58
59
|
import"./index-khk05tsf.js";
|
|
59
|
-
import"./index-
|
|
60
|
-
import"./index-
|
|
61
|
-
import"./index-
|
|
62
|
-
import"./index-
|
|
60
|
+
import"./index-gbp1q1b5.js";
|
|
61
|
+
import"./index-361ex3rb.js";
|
|
62
|
+
import"./index-hapx5myy.js";
|
|
63
|
+
import"./index-9z3egsmg.js";
|
|
63
64
|
import {
|
|
64
65
|
ContextScript
|
|
65
|
-
} from "./index-
|
|
66
|
-
import"./index-
|
|
66
|
+
} from "./index-scck6h6d.js";
|
|
67
|
+
import"./index-eft5c2mp.js";
|
|
67
68
|
import"./index-defp4gmb.js";
|
|
68
69
|
import"./index-9bv479q5.js";
|
|
69
70
|
|
package/index-2nxk8wgs.js
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// pkgs/@akanjs/language/ast.ts
|
|
3
|
-
var createAst = (ts) => {
|
|
4
|
-
const sourceFileFor = (fileName, content, scriptKind = ts.ScriptKind.TS) => ts.createSourceFile(fileName, content, ts.ScriptTarget.Latest, true, scriptKind);
|
|
5
|
-
const nodeName = (node) => {
|
|
6
|
-
if (!node)
|
|
7
|
-
return null;
|
|
8
|
-
if (ts.isIdentifier(node) || ts.isStringLiteral(node) || ts.isNumericLiteral(node))
|
|
9
|
-
return node.text;
|
|
10
|
-
return null;
|
|
11
|
-
};
|
|
12
|
-
const propertyName = (node) => ts.isPropertyAssignment(node) || ts.isShorthandPropertyAssignment(node) || ts.isMethodDeclaration(node) ? nodeName(node.name) : null;
|
|
13
|
-
const expressionName = (expression) => {
|
|
14
|
-
if (ts.isIdentifier(expression))
|
|
15
|
-
return expression.text;
|
|
16
|
-
if (ts.isPropertyAccessExpression(expression))
|
|
17
|
-
return expression.name.text;
|
|
18
|
-
if (ts.isCallExpression(expression))
|
|
19
|
-
return expressionName(expression.expression);
|
|
20
|
-
if (ts.isAsExpression(expression))
|
|
21
|
-
return expressionName(expression.expression);
|
|
22
|
-
return null;
|
|
23
|
-
};
|
|
24
|
-
const callExpressionName = (node) => ts.isPropertyAccessExpression(node.expression) ? node.expression.name.text : expressionName(node.expression);
|
|
25
|
-
const firstObjectReturnedByArrow = (node) => {
|
|
26
|
-
if (!ts.isArrowFunction(node) && !ts.isFunctionExpression(node))
|
|
27
|
-
return null;
|
|
28
|
-
if (ts.isObjectLiteralExpression(node.body))
|
|
29
|
-
return node.body;
|
|
30
|
-
if (ts.isParenthesizedExpression(node.body) && ts.isObjectLiteralExpression(node.body.expression)) {
|
|
31
|
-
return node.body.expression;
|
|
32
|
-
}
|
|
33
|
-
if (!ts.isBlock(node.body))
|
|
34
|
-
return null;
|
|
35
|
-
for (const statement of node.body.statements) {
|
|
36
|
-
if (ts.isReturnStatement(statement) && statement.expression && ts.isObjectLiteralExpression(statement.expression)) {
|
|
37
|
-
return statement.expression;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
};
|
|
42
|
-
const heritageCallNamed = (node, names) => {
|
|
43
|
-
const heritage = node.heritageClauses?.flatMap((clause) => [...clause.types]) ?? [];
|
|
44
|
-
for (const { expression } of heritage) {
|
|
45
|
-
if (!ts.isCallExpression(expression))
|
|
46
|
-
continue;
|
|
47
|
-
const callee = expressionName(expression.expression);
|
|
48
|
-
if (callee && names.has(callee))
|
|
49
|
-
return { callee, call: expression };
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
};
|
|
53
|
-
const viaNames = new Set(["via"]);
|
|
54
|
-
const heritageCall = (node) => heritageCallNamed(node, viaNames)?.call ?? null;
|
|
55
|
-
return {
|
|
56
|
-
sourceFileFor,
|
|
57
|
-
nodeName,
|
|
58
|
-
propertyName,
|
|
59
|
-
expressionName,
|
|
60
|
-
callExpressionName,
|
|
61
|
-
firstObjectReturnedByArrow,
|
|
62
|
-
heritageCallNamed,
|
|
63
|
-
heritageCall
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// pkgs/@akanjs/language/moduleFacts.ts
|
|
68
|
-
var moduleCallees = new Set(["via", "from", "into", "serve", "slice", "endpoint", "store"]);
|
|
69
|
-
var argMethods = new Set(["param", "body", "search", "room", "msg"]);
|
|
70
|
-
var createFactReader = (ts, ast) => {
|
|
71
|
-
const spanOf = (source, node) => {
|
|
72
|
-
const start = node.getStart(source);
|
|
73
|
-
const end = node.getEnd();
|
|
74
|
-
const head = source.getLineAndCharacterOfPosition(start);
|
|
75
|
-
const tail = source.getLineAndCharacterOfPosition(end);
|
|
76
|
-
return {
|
|
77
|
-
fileName: source.fileName,
|
|
78
|
-
start,
|
|
79
|
-
end,
|
|
80
|
-
line: head.line,
|
|
81
|
-
character: head.character,
|
|
82
|
-
endLine: tail.line,
|
|
83
|
-
endCharacter: tail.character
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
const unwrap = (expression) => {
|
|
87
|
-
let current = expression;
|
|
88
|
-
while (ts.isParenthesizedExpression(current) || ts.isAsExpression(current) || ts.isSatisfiesExpression(current))
|
|
89
|
-
current = current.expression;
|
|
90
|
-
return current;
|
|
91
|
-
};
|
|
92
|
-
const moduleRefOf = (expression, holder) => {
|
|
93
|
-
let current = expression && unwrap(expression);
|
|
94
|
-
while (current && ts.isCallExpression(current) && ts.isPropertyAccessExpression(current.expression))
|
|
95
|
-
current = current.expression.expression;
|
|
96
|
-
if (current && ts.isStringLiteral(current))
|
|
97
|
-
return current.text;
|
|
98
|
-
if (!current || !ts.isPropertyAccessExpression(current))
|
|
99
|
-
return null;
|
|
100
|
-
return ts.isIdentifier(current.expression) && current.expression.text === holder ? current.name.text : null;
|
|
101
|
-
};
|
|
102
|
-
const returnedObject = (builder) => builder ? ast.firstObjectReturnedByArrow(builder) : null;
|
|
103
|
-
const builderOf = (call) => [...call.arguments].reverse().find((arg) => ts.isArrowFunction(arg) || ts.isFunctionExpression(arg));
|
|
104
|
-
const guardsIn = (object) => {
|
|
105
|
-
const guards = object?.properties.find((property) => ts.isPropertyAssignment(property) && ast.nodeName(property.name) === "guards")?.initializer;
|
|
106
|
-
if (!guards)
|
|
107
|
-
return [];
|
|
108
|
-
if (ts.isArrayLiteralExpression(guards))
|
|
109
|
-
return guards.elements.map((element) => ast.expressionName(element)).filter((name) => name !== null);
|
|
110
|
-
if (ts.isObjectLiteralExpression(guards))
|
|
111
|
-
return guards.properties.filter(ts.isPropertyAssignment).map((property) => `${ast.nodeName(property.name)} ${ast.expressionName(property.initializer) ?? "?"}`);
|
|
112
|
-
const single = ast.expressionName(guards);
|
|
113
|
-
return single ? [single] : [];
|
|
114
|
-
};
|
|
115
|
-
const optionObjectOf = (call) => call.arguments.find((arg) => ts.isObjectLiteralExpression(arg) && arg.properties.some((property) => ast.propertyName(property) === "guards"));
|
|
116
|
-
const chainOf = (initializer) => {
|
|
117
|
-
let root = unwrap(initializer);
|
|
118
|
-
const methods = [];
|
|
119
|
-
while (ts.isCallExpression(root) && ts.isPropertyAccessExpression(root.expression) && ts.isCallExpression(unwrap(root.expression.expression))) {
|
|
120
|
-
methods.push(root.expression.name.text);
|
|
121
|
-
root = unwrap(root.expression.expression);
|
|
122
|
-
}
|
|
123
|
-
return { root: ts.isCallExpression(root) ? root : null, methods };
|
|
124
|
-
};
|
|
125
|
-
const keyName = (property) => ts.isPropertyAssignment(property) || ts.isMethodDeclaration(property) || ts.isShorthandPropertyAssignment(property) ? property.name : null;
|
|
126
|
-
const objectKeys = (source, object) => (object?.properties ?? []).flatMap((property) => {
|
|
127
|
-
const name = ast.propertyName(property);
|
|
128
|
-
const node = keyName(property);
|
|
129
|
-
return name && node ? [{ name, span: spanOf(source, node) }] : [];
|
|
130
|
-
});
|
|
131
|
-
const sliceKeysOf = (source, builder) => (returnedObject(builder)?.properties ?? []).flatMap((property) => {
|
|
132
|
-
if (!ts.isPropertyAssignment(property))
|
|
133
|
-
return [];
|
|
134
|
-
const name = ast.nodeName(property.name);
|
|
135
|
-
if (!name)
|
|
136
|
-
return [];
|
|
137
|
-
const { root, methods } = chainOf(property.initializer);
|
|
138
|
-
return [
|
|
139
|
-
{
|
|
140
|
-
name,
|
|
141
|
-
span: spanOf(source, property.name),
|
|
142
|
-
guards: root ? guardsIn(optionObjectOf(root)) : [],
|
|
143
|
-
live: methods.includes("live"),
|
|
144
|
-
argCount: methods.filter((method) => argMethods.has(method)).length
|
|
145
|
-
}
|
|
146
|
-
];
|
|
147
|
-
});
|
|
148
|
-
const verbReaderOf = (parameter) => {
|
|
149
|
-
const verbs = new Map;
|
|
150
|
-
if (parameter && ts.isObjectBindingPattern(parameter.name))
|
|
151
|
-
for (const element of parameter.name.elements) {
|
|
152
|
-
const verb = element.propertyName ?? element.name;
|
|
153
|
-
if (ts.isIdentifier(verb) && ts.isIdentifier(element.name))
|
|
154
|
-
verbs.set(element.name.text, verb.text);
|
|
155
|
-
}
|
|
156
|
-
const holder = parameter && ts.isIdentifier(parameter.name) ? parameter.name.text : null;
|
|
157
|
-
return (callee) => {
|
|
158
|
-
if (callee && ts.isIdentifier(callee))
|
|
159
|
-
return verbs.get(callee.text) ?? null;
|
|
160
|
-
if (callee && ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === holder)
|
|
161
|
-
return callee.name.text;
|
|
162
|
-
return null;
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
const endpointKeysOf = (source, builder) => {
|
|
166
|
-
const verbOf = verbReaderOf(builder?.parameters[0]);
|
|
167
|
-
return (returnedObject(builder)?.properties ?? []).flatMap((property) => {
|
|
168
|
-
if (!ts.isPropertyAssignment(property))
|
|
169
|
-
return [];
|
|
170
|
-
const name = ast.nodeName(property.name);
|
|
171
|
-
if (!name)
|
|
172
|
-
return [];
|
|
173
|
-
const { root, methods } = chainOf(property.initializer);
|
|
174
|
-
return [
|
|
175
|
-
{
|
|
176
|
-
name,
|
|
177
|
-
span: spanOf(source, property.name),
|
|
178
|
-
verb: root ? verbOf(root.expression) : null,
|
|
179
|
-
guards: root ? guardsIn(optionObjectOf(root)) : [],
|
|
180
|
-
argCount: methods.filter((method) => argMethods.has(method)).length
|
|
181
|
-
}
|
|
182
|
-
];
|
|
183
|
-
});
|
|
184
|
-
};
|
|
185
|
-
const filterQueriesOf = (source, builder) => {
|
|
186
|
-
const query = returnedObject(builder)?.properties.find((property) => ts.isPropertyAssignment(property) && ast.nodeName(property.name) === "query")?.initializer;
|
|
187
|
-
return query && ts.isObjectLiteralExpression(query) ? objectKeys(source, query) : [];
|
|
188
|
-
};
|
|
189
|
-
const constantOf = (source, name, call) => {
|
|
190
|
-
const parents = call.arguments.map(unwrap).filter((arg) => ts.isIdentifier(arg) || ts.isPropertyAccessExpression(arg)).map((arg) => ast.expressionName(arg)).filter((parent) => parent !== null);
|
|
191
|
-
const fields = call.arguments.flatMap((arg) => objectKeys(source, ast.firstObjectReturnedByArrow(arg)));
|
|
192
|
-
return { ...name, parents, fields };
|
|
193
|
-
};
|
|
194
|
-
const lowerFirst = (text) => text.charAt(0).toLowerCase() + text.slice(1);
|
|
195
|
-
const read = (source, owner) => {
|
|
196
|
-
const facts = {
|
|
197
|
-
fileName: source.fileName,
|
|
198
|
-
owner,
|
|
199
|
-
constants: [],
|
|
200
|
-
filters: [],
|
|
201
|
-
models: [],
|
|
202
|
-
services: [],
|
|
203
|
-
slices: [],
|
|
204
|
-
endpoints: [],
|
|
205
|
-
stores: []
|
|
206
|
-
};
|
|
207
|
-
for (const statement of source.statements) {
|
|
208
|
-
if (!ts.isClassDeclaration(statement) || !statement.name)
|
|
209
|
-
continue;
|
|
210
|
-
const heritage = ast.heritageCallNamed(statement, moduleCallees);
|
|
211
|
-
if (!heritage)
|
|
212
|
-
continue;
|
|
213
|
-
const { callee, call } = heritage;
|
|
214
|
-
const name = { name: statement.name.text, span: spanOf(source, statement.name) };
|
|
215
|
-
const builder = builderOf(call);
|
|
216
|
-
if (callee === "via")
|
|
217
|
-
facts.constants.push(constantOf(source, name, call));
|
|
218
|
-
else if (callee === "from")
|
|
219
|
-
facts.filters.push({ ...name, queries: filterQueriesOf(source, builder) });
|
|
220
|
-
else if (callee === "into")
|
|
221
|
-
facts.models.push({ ...name, model: name.name.endsWith("Model") ? lowerFirst(name.name.slice(0, -5)) : null });
|
|
222
|
-
else if (callee === "serve")
|
|
223
|
-
facts.services.push({ ...name, model: moduleRefOf(call.arguments[0], "db") });
|
|
224
|
-
else if (callee === "slice")
|
|
225
|
-
facts.slices.push({
|
|
226
|
-
...name,
|
|
227
|
-
model: moduleRefOf(call.arguments[0], "srv"),
|
|
228
|
-
guards: guardsIn(call.arguments.find(ts.isObjectLiteralExpression)),
|
|
229
|
-
keys: sliceKeysOf(source, builder)
|
|
230
|
-
});
|
|
231
|
-
else if (callee === "endpoint")
|
|
232
|
-
facts.endpoints.push({
|
|
233
|
-
...name,
|
|
234
|
-
model: moduleRefOf(call.arguments[0], "srv"),
|
|
235
|
-
keys: endpointKeysOf(source, builder)
|
|
236
|
-
});
|
|
237
|
-
else if (callee === "store")
|
|
238
|
-
facts.stores.push({
|
|
239
|
-
...name,
|
|
240
|
-
model: moduleRefOf(call.arguments[0], "sig"),
|
|
241
|
-
stateKeys: objectKeys(source, returnedObject(builder))
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
return facts;
|
|
245
|
-
};
|
|
246
|
-
return { read, spanOf, moduleRefOf, chainOf, unwrap };
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
// pkgs/@akanjs/language/nameTable.ts
|
|
250
|
-
import {
|
|
251
|
-
databaseStateNames,
|
|
252
|
-
endpointNames,
|
|
253
|
-
formSetterNames,
|
|
254
|
-
modelNames,
|
|
255
|
-
moduleNames,
|
|
256
|
-
queryNames,
|
|
257
|
-
sliceNames,
|
|
258
|
-
stateSetterName
|
|
259
|
-
} from "akanjs/common/akanNames.ts";
|
|
260
|
-
|
|
261
|
-
// pkgs/@akanjs/language/akanIndex.ts
|
|
262
|
-
var stateReceivers = new Set(["use", "sel", "get", "do"]);
|
|
263
|
-
var lensFamilies = new Set(["slice", "query", "formSetter", "storeState", "endpoint"]);
|
|
264
|
-
var modellessFamilies = new Set(["query", "storeState", "endpoint"]);
|
|
265
|
-
var receiverGap = String.raw`(?:\s|\)|\/\*[\s\S]*?\*\/)*`;
|
|
266
|
-
export { createAst, createFactReader };
|