@akanjs/cli 3.2.0-rc.2 → 3.2.0-rc.4
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 +2 -1
- package/{CodeAgent-6cpjtj25.js → CodeAgent-4a2skdph.js} +3 -3
- package/{CodeTui-zyc7zaq6.js → CodeTui-enrzsnzc.js} +1 -1
- package/{TunnelShare-zkfkrw8w.js → TunnelShare-xs5rrpf1.js} +5 -5
- package/{agent.command-kf1g3nh4.js → agent.command-y22t9x1e.js} +12 -12
- package/akanCode.js +3 -3
- package/{application.command-vb278qnq.js → application.command-yhj5arwc.js} +10 -10
- package/{applicationBuildRunner-bqbyeg84.js → applicationBuildRunner-6w1fd61b.js} +5 -5
- package/buildBatch.proc.js +4 -4
- package/{cloud.command-ca777ee2.js → cloud.command-bqfh4cnx.js} +15 -15
- package/cloud.script-8jvfw1sh.js +30 -0
- package/{code.command-j08txqcd.js → code.command-y94hwxsn.js} +5 -5
- package/{context.command-2fa6egp9.js → context.command-xz65fhrn.js} +17 -17
- package/context.runner-dpt5wjb7.js +29 -0
- package/{devTui-w38ch13a.js → devTui-h77zrjv5.js} +1 -1
- package/{guideline.command-w6yqpdec.js → guideline.command-sn843nw6.js} +1 -1
- package/guidelines/conventions/rules/page.md +4 -0
- package/guidelines/pageRule/pageRule.instruction.md +5 -0
- package/guidelines/runtimeRule/runtimeRule.instruction.md +5 -1
- package/guidelines/transportRule/transportRule.instruction.md +5 -0
- package/incrementalBuilder.proc.js +5 -5
- package/{index-xq97me1h.js → index-02b8qvww.js} +7 -7
- package/{index-j1hjb477.js → index-2rcptfyp.js} +1 -1
- package/{index-ebwkh7bt.js → index-39jz41jb.js} +23 -5
- package/{index-84c2pgak.js → index-3rff2c48.js} +1 -0
- package/{index-dk4g0x0d.js → index-3wen6ddy.js} +1 -1
- package/{index-c5ymqb05.js → index-49y45vbj.js} +9 -9
- package/{index-cbcwxp5v.js → index-4mgabs8t.js} +7 -5
- package/{index-0fj9ra3q.js → index-50mg8bsm.js} +4 -4
- package/{index-20wvskt8.js → index-5hhe0rdd.js} +1 -1
- package/{index-kcpk2d20.js → index-5qq6qky3.js} +8 -8
- package/{index-vbhx60x5.js → index-5w8amdr7.js} +1 -1
- package/{index-bdmgqzb5.js → index-8vxdsqra.js} +35 -22
- package/{index-m5sg5spm.js → index-9p260r4e.js} +114 -24
- package/{index-8nbx607g.js → index-ah09graf.js} +56 -25
- package/{index-23860fej.js → index-b4qq3rq0.js} +23 -8
- package/{index-mvwvxgtd.js → index-b9q5aw30.js} +12 -12
- package/{index-1cb9apzn.js → index-cmg5ngqa.js} +1 -1
- package/{index-0mqga3h9.js → index-fqx74yxn.js} +11 -8
- package/{index-djc5nxpy.js → index-g43360sn.js} +2 -2
- package/{index-65b6ms4c.js → index-gsty3pkx.js} +6 -2
- package/{index-386canwe.js → index-hkq0q73d.js} +44 -25
- package/{index-htxck0pn.js → index-jgj6ajnk.js} +8 -3
- package/{index-466z5931.js → index-jqsj5wjb.js} +2 -2
- package/{index-xa0289eg.js → index-jrdp7c4h.js} +6 -1
- package/{index-wr9magsr.js → index-jxaq2evq.js} +1 -1
- package/{index-pq5rjkch.js → index-kgxhwgdk.js} +7 -2
- package/{index-6h775rv3.js → index-kjmrkc45.js} +4 -4
- package/{index-abfbf01s.js → index-kr8dvqnr.js} +1 -1
- package/{index-j7p0jgaq.js → index-qrp98bmp.js} +4 -4
- package/{index-qgazn58x.js → index-sjj3ywn5.js} +16 -9
- package/index-va90m8nd.js +25 -0
- package/{index-e22zedc2.js → index-vftjqv28.js} +2 -2
- package/{index-2gees180.js → index-w15hnxmb.js} +5 -5
- package/{index-annxfpgz.js → index-w88xghey.js} +6 -6
- package/{index-7kmbqp0b.js → index-z9b72teg.js} +1 -1
- package/index.js +22 -22
- package/{library.command-8d03a0pq.js → library.command-6eafevmj.js} +2 -2
- package/{localRegistry.command-vyv5k6t0.js → localRegistry.command-9tef2qsj.js} +14 -14
- package/{module.command-vy3kg965.js → module.command-pn1k7dfk.js} +10 -6
- package/{package.command-qjh13rs9.js → package.command-kbg9z7re.js} +4 -4
- package/package.json +2 -2
- package/{page.command-t0nx1jat.js → page.command-st0y2xg8.js} +2 -2
- package/{pipeline.command-2yjeas7m.js → pipeline.command-76m32y7z.js} +1 -1
- package/{primitive.command-8vm49279.js → primitive.command-ax6wg70s.js} +6 -6
- package/{quality.command-v76fev72.js → quality.command-0gzskga8.js} +3 -3
- package/{repair.command-fp4m3w03.js → repair.command-g5kc3x89.js} +5 -5
- package/{scalar.command-hxe6try8.js → scalar.command-ck8621dy.js} +4 -4
- package/skills/akan-debug/SKILL.md +6 -2
- package/skills/akan-transport/SKILL.md +2 -0
- package/{subspace.command-q42n1844.js → subspace.command-vh6dye0v.js} +6 -6
- package/{tunnel.command-22g11n0x.js → tunnel.command-4mezrypt.js} +6 -6
- package/{verify.command-rx43bha1.js → verify.command-f2n4bwp7.js} +9 -9
- package/{workflow.command-yg0d8mmq.js → workflow.command-bx9xwgs5.js} +10 -10
- package/{workspace.command-fcfztvn5.js → workspace.command-04qgwsst.js} +33 -29
- package/cloud.script-agpxzq6j.js +0 -30
- package/context.runner-ftv8373t.js +0 -29
|
@@ -576,6 +576,7 @@ var bundleDefine = (app, command, renderEnv) => {
|
|
|
576
576
|
return {
|
|
577
577
|
"process.env.NODE_ENV": JSON.stringify(nodeEnv),
|
|
578
578
|
"process.env.AKAN_PUBLIC_RENDER_ENV": JSON.stringify(renderEnv),
|
|
579
|
+
"process.env.AKAN_BUNDLE_COMMAND": JSON.stringify(command),
|
|
579
580
|
...Object.fromEntries(Object.entries(app.getPublicEnv()).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)]))
|
|
580
581
|
};
|
|
581
582
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import {
|
|
3
|
-
AkanContextAnalyzer
|
|
4
|
-
} from "./index-0mqga3h9.js";
|
|
5
2
|
import {
|
|
6
3
|
WorkspaceExecutor
|
|
7
4
|
} from "./index-wfmpxke3.js";
|
|
5
|
+
import {
|
|
6
|
+
AkanContextAnalyzer
|
|
7
|
+
} from "./index-fqx74yxn.js";
|
|
8
8
|
import {
|
|
9
9
|
jsonText,
|
|
10
10
|
workflowPlanApproval,
|
|
@@ -30,24 +30,24 @@ import {
|
|
|
30
30
|
renderWorkflowApply,
|
|
31
31
|
renderWorkflowValidation,
|
|
32
32
|
renderWorkflowRunArtifact
|
|
33
|
-
} from "./index-
|
|
33
|
+
} from "./index-02b8qvww.js";
|
|
34
34
|
import {
|
|
35
35
|
CommandContainer,
|
|
36
36
|
runner
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-hkq0q73d.js";
|
|
38
38
|
import {
|
|
39
39
|
ModuleScript
|
|
40
|
-
} from "./index-
|
|
40
|
+
} from "./index-jgj6ajnk.js";
|
|
41
41
|
import {
|
|
42
42
|
PrimitiveScript
|
|
43
|
-
} from "./index-
|
|
43
|
+
} from "./index-sjj3ywn5.js";
|
|
44
44
|
import {
|
|
45
45
|
spawnAkan,
|
|
46
46
|
isWorkspaceTarget
|
|
47
|
-
} from "./index-
|
|
47
|
+
} from "./index-4mgabs8t.js";
|
|
48
48
|
import {
|
|
49
49
|
ScalarScript
|
|
50
|
-
} from "./index-
|
|
50
|
+
} from "./index-kgxhwgdk.js";
|
|
51
51
|
import {
|
|
52
52
|
workflowSpecs
|
|
53
53
|
} from "./index-v50xjbbe.js";
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
AkanContextAnalyzer
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-fqx74yxn.js";
|
|
5
5
|
import {
|
|
6
6
|
writeWorkflowRunArtifact,
|
|
7
7
|
generatedFilePathsForTarget,
|
|
8
8
|
writeGeneratedSyncState,
|
|
9
9
|
createRepairReport,
|
|
10
|
-
isWorkflowSysName,
|
|
11
|
-
isWorkflowModuleName,
|
|
12
10
|
renderRepairReport
|
|
13
|
-
} from "./index-
|
|
11
|
+
} from "./index-02b8qvww.js";
|
|
14
12
|
import {
|
|
15
13
|
runner
|
|
16
|
-
} from "./index-
|
|
14
|
+
} from "./index-hkq0q73d.js";
|
|
15
|
+
import {
|
|
16
|
+
isWorkflowSysName,
|
|
17
|
+
isWorkflowModuleName
|
|
18
|
+
} from "./index-va90m8nd.js";
|
|
17
19
|
|
|
18
20
|
// pkgs/@akanjs/cli/repair/repair.runner.ts
|
|
19
21
|
var akanArgPattern = /^(?:--?[a-z][a-zA-Z0-9-]*|[A-Za-z0-9@_][A-Za-z0-9@._/:,=-]*)$/;
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
PreviewView2,
|
|
16
16
|
stripAnsi
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-b4qq3rq0.js";
|
|
18
18
|
import {
|
|
19
19
|
SubagentPool2,
|
|
20
20
|
McpSignIn,
|
|
21
21
|
AkanCodeCompaction2
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-kr8dvqnr.js";
|
|
23
23
|
import {
|
|
24
24
|
codeAgentIsLoopback,
|
|
25
25
|
codeAgentHostListed,
|
|
@@ -659,7 +659,7 @@ class AkanToolPack2 {
|
|
|
659
659
|
return { name: "akan-tools", factory: async (pi) => await this.#register(pi) };
|
|
660
660
|
}
|
|
661
661
|
async names() {
|
|
662
|
-
const { ContextRunner } = await import("./context.runner-
|
|
662
|
+
const { ContextRunner } = await import("./context.runner-dpt5wjb7.js");
|
|
663
663
|
return [
|
|
664
664
|
...new ContextRunner().listMcpTools(this.#options.mode).map((tool) => tool.name),
|
|
665
665
|
AkanToolPack2.verifyToolName
|
|
@@ -667,7 +667,7 @@ class AkanToolPack2 {
|
|
|
667
667
|
}
|
|
668
668
|
static verifyToolName = "akan_verify";
|
|
669
669
|
async#register(pi) {
|
|
670
|
-
const { ContextRunner } = await import("./context.runner-
|
|
670
|
+
const { ContextRunner } = await import("./context.runner-dpt5wjb7.js");
|
|
671
671
|
const runner = new ContextRunner;
|
|
672
672
|
const guidelineNames = await AkanToolPack2.#guidelineNames();
|
|
673
673
|
for (const tool of runner.listMcpTools(this.#options.mode, { guidelineNames })) {
|
|
@@ -51,16 +51,16 @@ import {
|
|
|
51
51
|
runner,
|
|
52
52
|
ExitCodeError,
|
|
53
53
|
assertPromptable
|
|
54
|
-
} from "./index-
|
|
54
|
+
} from "./index-hkq0q73d.js";
|
|
55
55
|
import {
|
|
56
56
|
UpdatePackFolder,
|
|
57
57
|
UpdateUploader,
|
|
58
58
|
NativePublicEnv,
|
|
59
59
|
NativeApp
|
|
60
|
-
} from "./index-
|
|
60
|
+
} from "./index-g43360sn.js";
|
|
61
61
|
import {
|
|
62
62
|
DesktopServerStage
|
|
63
|
-
} from "./index-
|
|
63
|
+
} from "./index-5hhe0rdd.js";
|
|
64
64
|
import {
|
|
65
65
|
resolveMobileTargets,
|
|
66
66
|
resolveAppId
|
|
@@ -569,7 +569,7 @@ class IncrementalBuilderHost {
|
|
|
569
569
|
this.#inFlight.clear();
|
|
570
570
|
this.logger.warn(`failing ${lost.length} unanswered builder request(s): ${reason}`);
|
|
571
571
|
for (const [id, type] of lost)
|
|
572
|
-
this.#onMessage({ type: `${type}-res`, id, ok: false, error: reason });
|
|
572
|
+
this.#onMessage({ type: `${type}-res`, id, ok: false, error: reason, kind: "unavailable" });
|
|
573
573
|
}
|
|
574
574
|
stop() {
|
|
575
575
|
this.#manualStop = true;
|
|
@@ -1608,11 +1608,11 @@ ${this.#backendStderrTail.join(`
|
|
|
1608
1608
|
}
|
|
1609
1609
|
#failBuilderRequest(message, error) {
|
|
1610
1610
|
if (message.type === "build-route")
|
|
1611
|
-
this.#sendToBackend({ type: "build-route-res", id: message.id, ok: false, error });
|
|
1611
|
+
this.#sendToBackend({ type: "build-route-res", id: message.id, ok: false, error, kind: "unavailable" });
|
|
1612
1612
|
else if (message.type === "build-csr")
|
|
1613
|
-
this.#sendToBackend({ type: "build-csr-res", id: message.id, ok: false, error });
|
|
1613
|
+
this.#sendToBackend({ type: "build-csr-res", id: message.id, ok: false, error, kind: "unavailable" });
|
|
1614
1614
|
else if (message.type === "build-graph")
|
|
1615
|
-
this.#sendToBackend({ type: "build-graph-res", id: message.id, ok: false, error });
|
|
1615
|
+
this.#sendToBackend({ type: "build-graph-res", id: message.id, ok: false, error, kind: "unavailable" });
|
|
1616
1616
|
else
|
|
1617
1617
|
return false;
|
|
1618
1618
|
return true;
|
|
@@ -2038,7 +2038,7 @@ var reportsNoTestFile = (exec) => {
|
|
|
2038
2038
|
};
|
|
2039
2039
|
|
|
2040
2040
|
// pkgs/@akanjs/cli/application/application.runner.ts
|
|
2041
|
-
var loadBuildRunner = async () => (await import("./applicationBuildRunner-
|
|
2041
|
+
var loadBuildRunner = async () => (await import("./applicationBuildRunner-6w1fd61b.js")).ApplicationBuildRunner;
|
|
2042
2042
|
var loadPrompts = async () => await import("@inquirer/prompts");
|
|
2043
2043
|
|
|
2044
2044
|
class ApplicationRunner extends runner("application") {
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ClientEntriesBundler,
|
|
10
10
|
VENDOR_SPECIFIERS,
|
|
11
11
|
RouteClientBuilder
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-5w8amdr7.js";
|
|
13
13
|
import {
|
|
14
14
|
SOURCE_EXTS,
|
|
15
15
|
FontOptimizer,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
CsrEntryFiles,
|
|
23
23
|
toClientReferencePath,
|
|
24
24
|
PagesBundleBuilder
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-3rff2c48.js";
|
|
26
26
|
import {
|
|
27
27
|
CssBlockParser
|
|
28
28
|
} from "./index-62md4dwy.js";
|
|
@@ -975,16 +975,7 @@ class SsrBaseArtifactBuilder {
|
|
|
975
975
|
const rscClientUrl = clientBundle.entryUrlsByAbsPath.get(rscClientEntry) ?? "";
|
|
976
976
|
const rscRuntimeSsrManifest = {
|
|
977
977
|
moduleLoading: null,
|
|
978
|
-
moduleMap:
|
|
979
|
-
const ssrOutput = ssrBundle.entryOutputAbsByAbsPath.get(rscSegmentOutletEntry);
|
|
980
|
-
if (!ssrOutput || key !== `${clientBundle.clientReferenceIdByAbsPath.get(rscSegmentOutletEntry)}#${row.name}`) {
|
|
981
|
-
return null;
|
|
982
|
-
}
|
|
983
|
-
return [
|
|
984
|
-
row.id,
|
|
985
|
-
{ [row.name]: { id: ssrOutput, chunks: [ssrOutput, ssrOutput], name: row.name, async: true } }
|
|
986
|
-
];
|
|
987
|
-
}).filter((entry) => Boolean(entry)))
|
|
978
|
+
moduleMap: SsrBaseArtifactBuilder.outletModuleMap(clientBundle.manifest, clientBundle.clientReferenceIdByAbsPath.get(rscSegmentOutletEntry), ssrBundle.entryOutputAbsByAbsPath.get(rscSegmentOutletEntry))
|
|
988
979
|
};
|
|
989
980
|
const vendorMap = Object.fromEntries(vendorEntries.map(({ specifier, absPath }) => [specifier, clientBundle.entryUrlsByAbsPath.get(absPath) ?? ""]));
|
|
990
981
|
this.#app.verbose(`[base-artifact] rscClientUrl=${rscClientUrl} vendors=${Object.keys(vendorMap).length}`);
|
|
@@ -1000,6 +991,20 @@ class SsrBaseArtifactBuilder {
|
|
|
1000
991
|
}
|
|
1001
992
|
};
|
|
1002
993
|
}
|
|
994
|
+
static outletModuleMap(manifest, outletReferenceId, ssrOutput) {
|
|
995
|
+
const moduleMap = {};
|
|
996
|
+
if (!ssrOutput || !outletReferenceId)
|
|
997
|
+
return moduleMap;
|
|
998
|
+
for (const [key, row] of Object.entries(manifest)) {
|
|
999
|
+
if (key !== `${outletReferenceId}#${row.name}`)
|
|
1000
|
+
continue;
|
|
1001
|
+
moduleMap[row.id] = {
|
|
1002
|
+
...moduleMap[row.id],
|
|
1003
|
+
[row.name]: { id: ssrOutput, chunks: [ssrOutput, ssrOutput], name: row.name, async: true }
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
return moduleMap;
|
|
1007
|
+
}
|
|
1003
1008
|
async#resolveAkanServerPath() {
|
|
1004
1009
|
const candidates = [];
|
|
1005
1010
|
try {
|
|
@@ -1070,28 +1075,36 @@ class VendorImportScanner {
|
|
|
1070
1075
|
for (const specifier of specifiers)
|
|
1071
1076
|
this.#names.set(specifier, new Set);
|
|
1072
1077
|
}
|
|
1073
|
-
static async exportsUsedIn(dir, specifiers) {
|
|
1078
|
+
static async exportsUsedIn(dir, specifiers, entryUrls) {
|
|
1074
1079
|
const scanner = new VendorImportScanner(specifiers);
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1080
|
+
const scanned = [];
|
|
1081
|
+
if (fs3.existsSync(dir))
|
|
1082
|
+
for await (const relative of new Bun.Glob("**/*.js").scan({ cwd: dir })) {
|
|
1083
|
+
scanner.scan(await Bun.file(path8.join(dir, relative)).text(), relative);
|
|
1084
|
+
scanned.push(`/${relative.split(path8.sep).join("/")}`);
|
|
1085
|
+
}
|
|
1086
|
+
const unread = [...new Set(entryUrls)].filter((url) => !scanned.some((relative) => url.endsWith(relative)));
|
|
1087
|
+
if (unread.length > 0) {
|
|
1088
|
+
const named = `${unread.slice(0, 3).join(", ")}${unread.length > 3 ? `, and ${unread.length - 3} more` : ""}`;
|
|
1089
|
+
throw new Error(`[VendorImportScanner] no file under ${dir} for the route client entries ${named}; narrowing the vendor entries without them would drop names those pages import`);
|
|
1090
|
+
}
|
|
1079
1091
|
return scanner.usedExports();
|
|
1080
1092
|
}
|
|
1081
1093
|
scan(source, fileName = "chunk.js") {
|
|
1082
1094
|
if (![...this.#specifiers].some((specifier) => source.includes(specifier)))
|
|
1083
1095
|
return this;
|
|
1084
|
-
const
|
|
1085
|
-
|
|
1096
|
+
const stack = [ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, false, ts.ScriptKind.JS)];
|
|
1097
|
+
for (let node = stack.pop();node; node = stack.pop()) {
|
|
1086
1098
|
if (ts.isImportDeclaration(node))
|
|
1087
1099
|
this.#readImport(node);
|
|
1088
1100
|
else if (ts.isExportDeclaration(node))
|
|
1089
1101
|
this.#readExport(node);
|
|
1090
1102
|
else if (ts.isCallExpression(node))
|
|
1091
1103
|
this.#readCall(node);
|
|
1092
|
-
ts.forEachChild(node,
|
|
1093
|
-
|
|
1094
|
-
|
|
1104
|
+
ts.forEachChild(node, (child) => {
|
|
1105
|
+
stack.push(child);
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1095
1108
|
return this;
|
|
1096
1109
|
}
|
|
1097
1110
|
usedExports() {
|
|
@@ -29,6 +29,9 @@ class AkanGraphDiff {
|
|
|
29
29
|
...head.edges.flatMap((edge) => !baseKeys.has(edgeKeyOf(edge)) ? [{ ...edge, change: "added" }] : marked.has(edge.from) || marked.has(edge.to) ? [edge] : []),
|
|
30
30
|
...base.edges.filter((edge) => !headKeys.has(edgeKeyOf(edge))).map((edge) => ({ ...edge, change: "removed" }))
|
|
31
31
|
];
|
|
32
|
+
const shown = new Set([...marked.keys(), ...edges.flatMap((edge) => [edge.from, edge.to])]);
|
|
33
|
+
const listed = new Set(edges.map(edgeKeyOf));
|
|
34
|
+
edges.push(...head.edges.filter((edge) => edge.kind === "binds" && shown.has(edge.from) && !listed.has(edgeKeyOf(edge))));
|
|
32
35
|
const context = edges.flatMap((edge) => [edge.from, edge.to]).filter((id) => !marked.has(id)).flatMap((id) => {
|
|
33
36
|
const node = headNodes.get(id) ?? baseNodes.get(id);
|
|
34
37
|
return node ? [node] : [];
|
|
@@ -486,7 +489,7 @@ var createFactReader = (ts, ast) => {
|
|
|
486
489
|
const [size, unit] = intervalUnits.find(([size]) => ms >= size && ms % size === 0) ?? [1, "ms"];
|
|
487
490
|
return `${ms / size}${unit}`;
|
|
488
491
|
};
|
|
489
|
-
const modesOf = (option) => {
|
|
492
|
+
const modesOf = (option, type) => {
|
|
490
493
|
const object = option && unwrap(option);
|
|
491
494
|
if (!object || !ts.isObjectLiteralExpression(object))
|
|
492
495
|
return [];
|
|
@@ -496,9 +499,9 @@ var createFactReader = (ts, ast) => {
|
|
|
496
499
|
if (name === "enabled")
|
|
497
500
|
return value.kind === ts.SyntaxKind.FalseKeyword ? ["disabled"] : [];
|
|
498
501
|
if (name === "once")
|
|
499
|
-
return value.kind === ts.SyntaxKind.TrueKeyword ? ["once"] : [];
|
|
502
|
+
return type === "initialize" && value.kind === ts.SyntaxKind.TrueKeyword ? ["once"] : [];
|
|
500
503
|
if (name === "lock")
|
|
501
|
-
return value.kind === ts.SyntaxKind.FalseKeyword ? ["unlocked"] : [];
|
|
504
|
+
return type === "interval" && value.kind === ts.SyntaxKind.FalseKeyword ? ["unlocked"] : [];
|
|
502
505
|
if (name !== "serverMode" && name !== "operationMode")
|
|
503
506
|
return [];
|
|
504
507
|
const values = ts.isArrayLiteralExpression(value) ? [...value.elements] : [value];
|
|
@@ -516,7 +519,8 @@ var createFactReader = (ts, ast) => {
|
|
|
516
519
|
const { root } = chainOf(property.initializer);
|
|
517
520
|
const type = root ? verbOf(root.expression) : null;
|
|
518
521
|
const [first, second] = root?.arguments ?? [];
|
|
519
|
-
const
|
|
522
|
+
const cron = type === "cron" && first ? unwrap(first) : null;
|
|
523
|
+
const schedule = cron ? ts.isStringLiteralLike(cron) ? cron.text : cron.getText(source) : type === "interval" || type === "timeout" ? durationOf(first, source) : null;
|
|
520
524
|
const option = type === "initialize" || type === "destroy" ? first : second;
|
|
521
525
|
return [
|
|
522
526
|
{
|
|
@@ -525,7 +529,7 @@ var createFactReader = (ts, ast) => {
|
|
|
525
529
|
extent: extentOf(source, property),
|
|
526
530
|
type,
|
|
527
531
|
schedule,
|
|
528
|
-
modes: modesOf(option)
|
|
532
|
+
modes: modesOf(option, type)
|
|
529
533
|
}
|
|
530
534
|
];
|
|
531
535
|
});
|
|
@@ -542,6 +546,19 @@ var createFactReader = (ts, ast) => {
|
|
|
542
546
|
return name && targetName ? [{ name, span: spanOf(source, property.name), target: targetName }] : [];
|
|
543
547
|
});
|
|
544
548
|
};
|
|
549
|
+
const adaptorBindingsIn = (source) => {
|
|
550
|
+
const bindings = [];
|
|
551
|
+
const visit = (node) => {
|
|
552
|
+
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && node.expression.name.text === "applyAdaptor") {
|
|
553
|
+
const [role, adaptor] = node.arguments.map(guardNameOf);
|
|
554
|
+
if (role && adaptor)
|
|
555
|
+
bindings.push({ role, adaptor, span: spanOf(source, node.expression.name) });
|
|
556
|
+
}
|
|
557
|
+
ts.forEachChild(node, visit);
|
|
558
|
+
};
|
|
559
|
+
visit(source);
|
|
560
|
+
return bindings;
|
|
561
|
+
};
|
|
545
562
|
const endpointKeysOf = (source, builder, made, model) => {
|
|
546
563
|
const verbOf = verbReaderOf(builder?.parameters[0]);
|
|
547
564
|
return (returnedObject(builder)?.properties ?? []).flatMap((property) => {
|
|
@@ -662,6 +679,7 @@ var createFactReader = (ts, ast) => {
|
|
|
662
679
|
endpoints: [],
|
|
663
680
|
internals: [],
|
|
664
681
|
adaptors: [],
|
|
682
|
+
adaptorBindings: source.text.includes("applyAdaptor") ? adaptorBindingsIn(source) : [],
|
|
665
683
|
stores: []
|
|
666
684
|
};
|
|
667
685
|
for (const statement of source.statements) {
|
|
@@ -686,7 +704,8 @@ var createFactReader = (ts, ast) => {
|
|
|
686
704
|
...name,
|
|
687
705
|
model: moduleRefOf(call.arguments[0], "db"),
|
|
688
706
|
methods: methodsOf(source, statement),
|
|
689
|
-
plugs: plugsOf(source, builder)
|
|
707
|
+
plugs: plugsOf(source, builder),
|
|
708
|
+
fields: objectKeys(source, returnedObject(builder)).map(({ name }) => name)
|
|
690
709
|
});
|
|
691
710
|
else if (callee === "slice") {
|
|
692
711
|
const model = moduleRefOf(call.arguments[0], "srv");
|
|
@@ -1358,6 +1377,7 @@ class GraphBuilder {
|
|
|
1358
1377
|
#resolver;
|
|
1359
1378
|
#adaptors = new Map;
|
|
1360
1379
|
#plugs = new Map;
|
|
1380
|
+
#serviceFields = new Set;
|
|
1361
1381
|
constructor(source) {
|
|
1362
1382
|
this.#source = source;
|
|
1363
1383
|
this.#routes = new RouteFactReader(source.ts, source.reader, source.parse);
|
|
@@ -1373,16 +1393,26 @@ class GraphBuilder {
|
|
|
1373
1393
|
...[...constantsByOwner].filter(([key]) => key !== owner && key?.startsWith("libs/")).flatMap(([, list]) => list)
|
|
1374
1394
|
];
|
|
1375
1395
|
const typed = [];
|
|
1396
|
+
const adaptorCounts = new Map;
|
|
1376
1397
|
for (const file of facts)
|
|
1377
1398
|
for (const fact of file.adaptors) {
|
|
1378
|
-
const
|
|
1379
|
-
|
|
1380
|
-
this.#adaptorNodeOf(declared);
|
|
1399
|
+
const key = this.#key("adaptor", file.owner, fact.name);
|
|
1400
|
+
adaptorCounts.set(key, (adaptorCounts.get(key) ?? 0) + 1);
|
|
1381
1401
|
}
|
|
1402
|
+
const declaredAdaptors = facts.flatMap((file) => file.adaptors.map((fact) => {
|
|
1403
|
+
const key = this.#key("adaptor", file.owner, fact.name);
|
|
1404
|
+
const id = (adaptorCounts.get(key) ?? 0) > 1 ? this.#key("adaptor", file.owner, `${this.#resolver.inOwner(file.fileName, file.owner)}#${fact.name}`) : key;
|
|
1405
|
+
const declared = { fact, owner: file.owner, fileName: file.fileName, id };
|
|
1406
|
+
this.#adaptors.set(fact.name, [...this.#adaptors.get(fact.name) ?? [], declared]);
|
|
1407
|
+
this.#adaptorNodeOf(declared);
|
|
1408
|
+
return { declared, file };
|
|
1409
|
+
}));
|
|
1410
|
+
for (const { declared, file } of declaredAdaptors)
|
|
1411
|
+
for (const plug of declared.fact.plugs)
|
|
1412
|
+
this.#addEdge(declared.id, this.#adaptorIdOf(plug.target, file), "plugs", plug.name, this.#location(plug.span));
|
|
1382
1413
|
for (const file of facts)
|
|
1383
|
-
for (const
|
|
1384
|
-
|
|
1385
|
-
this.#addEdge(this.#key("adaptor", file.owner, fact.name), this.#adaptorIdOf(plug.target, file), "plugs", plug.name, this.#location(plug.span));
|
|
1414
|
+
for (const binding of file.adaptorBindings)
|
|
1415
|
+
this.#addEdge(this.#adaptorIdOf(binding.role, file), this.#adaptorIdOf(binding.adaptor, file), "binds", file.owner, this.#location(binding.span));
|
|
1386
1416
|
for (const guard of this.#resolver.declare(facts))
|
|
1387
1417
|
this.#guardNodeOf(guard);
|
|
1388
1418
|
for (const file of facts) {
|
|
@@ -1415,10 +1445,18 @@ class GraphBuilder {
|
|
|
1415
1445
|
}
|
|
1416
1446
|
for (const method of service.methods)
|
|
1417
1447
|
this.#addMember("method", owner, refName, method, `${service.name}.${method.name}`, file.fileName);
|
|
1418
|
-
for (const plug of service.plugs)
|
|
1419
|
-
|
|
1448
|
+
for (const plug of service.plugs) {
|
|
1449
|
+
const key = `${refName}
|
|
1450
|
+
${plug.name}`;
|
|
1451
|
+
this.#plugs.set(key, [
|
|
1452
|
+
...this.#plugs.get(key) ?? [],
|
|
1453
|
+
{ owner, target: this.#adaptorIdOf(plug.target, file) }
|
|
1454
|
+
]);
|
|
1455
|
+
}
|
|
1456
|
+
for (const field of service.fields)
|
|
1457
|
+
this.#serviceFields.add(`${owner ?? ""}
|
|
1420
1458
|
${refName}
|
|
1421
|
-
${
|
|
1459
|
+
${field}`);
|
|
1422
1460
|
}
|
|
1423
1461
|
for (const filter of file.filters) {
|
|
1424
1462
|
if (!filter.name.endsWith("Filter"))
|
|
@@ -1677,18 +1715,70 @@ ${dir}`, node);
|
|
|
1677
1715
|
#adaptorIdOf(local, file) {
|
|
1678
1716
|
const [head, member] = local.split(".");
|
|
1679
1717
|
const imported = file.imports.find((item) => item.name === head);
|
|
1680
|
-
const from = imported ? this.#resolver.ownerOfSpecifier(file.fileName, imported.from) : undefined;
|
|
1681
1718
|
const name = member ?? (imported && imported.imported !== "default" && imported.imported !== "*" ? imported.imported : head);
|
|
1719
|
+
const path = imported ? this.#resolver.pathOfSpecifier(file.fileName, imported.from) : null;
|
|
1720
|
+
if (imported && path === null && !frameworkPattern.test(imported.from))
|
|
1721
|
+
return this.#packageAdaptorOf(name, imported.from);
|
|
1722
|
+
const from = imported ? this.#resolver.ownerOfSpecifier(file.fileName, imported.from) : undefined;
|
|
1682
1723
|
const declared = this.#adaptors.get(name) ?? [];
|
|
1683
|
-
const found = from === undefined ? declared
|
|
1724
|
+
const found = from === undefined ? this.#adaptorIn(declared, file.owner, path, file.fileName) ?? declared.find((adaptor) => this.#resolver.visible(adaptor.owner, file.owner)) : this.#adaptorIn(declared, from, path, file.fileName) ?? (from === frameworkOwner ? undefined : declared.find((adaptor) => this.#resolver.visible(adaptor.owner, from)));
|
|
1684
1725
|
if (found)
|
|
1685
|
-
return
|
|
1726
|
+
return found.id;
|
|
1727
|
+
const reexported = from && from !== frameworkOwner ? this.#packageShimOf(from, name, path) : null;
|
|
1728
|
+
if (reexported)
|
|
1729
|
+
return this.#packageAdaptorOf(reexported.name, reexported.from);
|
|
1686
1730
|
const owner = from === frameworkOwner ? null : imported ? from ?? null : file.owner;
|
|
1687
1731
|
const detail = from === frameworkOwner ? [frameworkOwner] : [];
|
|
1688
1732
|
return this.#addNode(this.#key("adaptor", owner, name), "adaptor", owner, null, name, null, detail).id;
|
|
1689
1733
|
}
|
|
1690
|
-
#
|
|
1691
|
-
const
|
|
1734
|
+
#adaptorIn(declared, owner, path, fileName) {
|
|
1735
|
+
const own = declared.filter((adaptor) => adaptor.owner === owner);
|
|
1736
|
+
if (own.length < 2)
|
|
1737
|
+
return own.at(0);
|
|
1738
|
+
const pathOf = (adaptor) => this.#source.relative(adaptor.fileName).replace(/\.tsx?$/, "");
|
|
1739
|
+
const named = path === null ? own.find((adaptor) => adaptor.fileName === fileName) : own.find((adaptor) => pathOf(adaptor) === path || pathOf(adaptor) === `${path}/index`) ?? own.find((adaptor) => pathOf(adaptor).startsWith(`${path}/`));
|
|
1740
|
+
return named ?? own.at(0);
|
|
1741
|
+
}
|
|
1742
|
+
#pluggedOf({ owner, module }, field) {
|
|
1743
|
+
const plugs = this.#plugs.get(`${module}
|
|
1744
|
+
${field}`) ?? [];
|
|
1745
|
+
const own = plugs.filter((plug) => plug.owner === owner);
|
|
1746
|
+
if (!own.length && this.#serviceFields.has(`${owner ?? ""}
|
|
1747
|
+
${module}
|
|
1748
|
+
${field}`))
|
|
1749
|
+
return [];
|
|
1750
|
+
const inherited = own.length ? own : plugs.filter((plug) => this.#resolver.visible(plug.owner, owner));
|
|
1751
|
+
return [...new Set(inherited.map(({ target }) => target))];
|
|
1752
|
+
}
|
|
1753
|
+
#packageAdaptorOf(name, specifier) {
|
|
1754
|
+
if (frameworkPattern.test(specifier))
|
|
1755
|
+
return this.#addNode(this.#key("adaptor", null, name), "adaptor", null, null, name, null, [frameworkOwner]).id;
|
|
1756
|
+
const pkg = specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/");
|
|
1757
|
+
return this.#addNode(this.#key("adaptor", pkg, name), "adaptor", null, null, name, null, [pkg]).id;
|
|
1758
|
+
}
|
|
1759
|
+
#packageShimOf(owner, name, near) {
|
|
1760
|
+
const reexport = this.#resolver.reexportOf(owner, name, near);
|
|
1761
|
+
const [shim] = reexport?.site.imports ?? [];
|
|
1762
|
+
if (reexport && shim && this.#resolver.pathOfSpecifier(reexport.site.fileName, shim.from) === null)
|
|
1763
|
+
return { name: reexport.local === "default" ? name : reexport.local, from: shim.from };
|
|
1764
|
+
if (reexport || !near)
|
|
1765
|
+
return null;
|
|
1766
|
+
const packages = new Set;
|
|
1767
|
+
for (const [fileName, words] of this.#resolver.filesIn(owner)) {
|
|
1768
|
+
const relative = this.#source.relative(fileName);
|
|
1769
|
+
const isNear = relative.startsWith(`${near}/`) || relative.replace(/\.tsx?$/, "") === near;
|
|
1770
|
+
if (!isNear || !words.includes(`
|
|
1771
|
+
export
|
|
1772
|
+
`))
|
|
1773
|
+
continue;
|
|
1774
|
+
for (const [, specifier = ""] of this.#source.readText(fileName)?.matchAll(starExportPattern) ?? [])
|
|
1775
|
+
if (this.#resolver.pathOfSpecifier(fileName, specifier) === null)
|
|
1776
|
+
packages.add(specifier);
|
|
1777
|
+
}
|
|
1778
|
+
const [only] = packages;
|
|
1779
|
+
return packages.size === 1 && only && !this.#resolver.declares(owner, name) ? { name, from: only } : null;
|
|
1780
|
+
}
|
|
1781
|
+
#adaptorNodeOf({ fact, owner, fileName, id }) {
|
|
1692
1782
|
const detail = fact.refName ? [fact.refName] : [];
|
|
1693
1783
|
const node = this.#addNode(id, "adaptor", owner, null, fact.name, fact.span, detail);
|
|
1694
1784
|
if (fact.doc && !node.doc)
|
|
@@ -1798,10 +1888,8 @@ st
|
|
|
1798
1888
|
visit(source);
|
|
1799
1889
|
}
|
|
1800
1890
|
#link(fileName, source, identifier, chain, context, owner) {
|
|
1801
|
-
const plugged = chain?.length === 2 && chain[0] === "this" && context.kind === "method" && this.#isServiceThis(identifier) ? this.#
|
|
1802
|
-
|
|
1803
|
-
${chain[1]}`) : undefined;
|
|
1804
|
-
const resolved = plugged ? [plugged] : this.#source.resolve(fileName, identifier).map((target) => this.#targetNodeOf(target)).filter((id) => id !== null);
|
|
1891
|
+
const plugged = chain?.length === 2 && chain[0] === "this" && context.kind === "method" && this.#isServiceThis(identifier) ? this.#pluggedOf(context, chain[1]) : [];
|
|
1892
|
+
const resolved = plugged.length ? plugged : this.#source.resolve(fileName, identifier).map((target) => this.#targetNodeOf(target)).filter((id) => id !== null);
|
|
1805
1893
|
const targets = resolved.length ? resolved : this.#plainTargetsOf(chain, identifier.text, context, owner);
|
|
1806
1894
|
if (!targets.length)
|
|
1807
1895
|
return;
|
|
@@ -2382,6 +2470,8 @@ canPass
|
|
|
2382
2470
|
adapt
|
|
2383
2471
|
`) || words.includes(`
|
|
2384
2472
|
dangerouslyAdapt
|
|
2473
|
+
`) || words.includes(`
|
|
2474
|
+
applyAdaptor
|
|
2385
2475
|
`);
|
|
2386
2476
|
}
|
|
2387
2477
|
static #sourceKeyOf({ family, sourceKey, label, detail, span }) {
|