@akanjs/cli 3.2.0-rc.2 → 3.2.0-rc.21
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-faqv7t4g.js +11 -0
- package/{CodeTui-zyc7zaq6.js → CodeTui-vqck9tet.js} +822 -666
- package/README.ko.md +26 -1
- package/README.md +26 -1
- package/TunnelShare-bwe3ddv7.js +18 -0
- package/agent.command-p75jvgrd.js +56 -0
- package/akanCode.js +12 -12
- package/appExecutor-020cyesq.js +11 -0
- package/{application.command-vb278qnq.js → application.command-ta2knqxm.js} +72 -34
- package/{applicationBuildRunner-bqbyeg84.js → applicationBuildRunner-gkh82j2b.js} +18 -13
- package/buildBatch.proc.js +26 -11
- package/{cloud.command-ca777ee2.js → cloud.command-v3jhfvm5.js} +31 -28
- package/cloud.script-be9s1432.js +35 -0
- package/{code.command-j08txqcd.js → code.command-mh7dh1st.js} +14 -9
- package/{context.command-2fa6egp9.js → context.command-1ycfjkdd.js} +28 -23
- package/context.runner-333jkz86.js +34 -0
- package/{dependencyScanner-78sq8m4q.js → dependencyScanner-ge10gb52.js} +2 -2
- package/{devTui-w38ch13a.js → devTui-rf374y2w.js} +1 -1
- package/{fileSys-zpvt5gtf.js → fileSys-q22646yc.js} +1 -1
- package/{guideline.command-w6yqpdec.js → guideline.command-w1grfwh7.js} +9 -4
- package/guidelines/agentRule/agentRule.instruction.md +17 -5
- package/guidelines/akanApi/akanApi.instruction.md +5 -3
- package/guidelines/conventions/core.md +23 -5
- package/guidelines/conventions/rules/app.md +4 -1
- package/guidelines/conventions/rules/page.md +5 -0
- package/guidelines/errorCodes/errorCodes.instruction.md +158 -0
- package/guidelines/fieldRule/fieldRule.instruction.md +2 -1
- package/guidelines/mcpRule/mcpRule.instruction.md +86 -2
- package/guidelines/pageRule/pageRule.instruction.md +11 -1
- package/guidelines/runtimeRule/runtimeRule.instruction.md +7 -2
- package/guidelines/transportRule/transportRule.instruction.md +8 -1
- package/incrementalBuilder.proc.js +574 -410
- package/{index-c5ymqb05.js → index-013n6z7m.js} +12 -12
- package/{index-w15mg3km.js → index-0dm25wvf.js} +1 -1
- package/{index-8nbx607g.js → index-0hj82f9w.js} +136 -48
- package/{index-ebwkh7bt.js → index-1c0mjc2b.js} +25 -7
- package/{index-6h775rv3.js → index-1jk52ffq.js} +53 -12
- package/{index-hj6w4ka1.js → index-1p81ecbz.js} +1 -1
- package/{index-ygrdw6jw.js → index-1pjwsh2g.js} +65 -8
- package/{index-cbcwxp5v.js → index-22g3jq43.js} +9 -7
- package/{index-466z5931.js → index-2d9nm03s.js} +580 -364
- package/{index-0fj9ra3q.js → index-2k6mve6a.js} +18 -11
- package/{index-qd7xn2bk.js → index-2ny1e95c.js} +2 -2
- package/{index-j7p0jgaq.js → index-52w4jb87.js} +6 -6
- package/{index-e22zedc2.js → index-5h888r6j.js} +3 -3
- package/{index-7kmbqp0b.js → index-6pxmcaq8.js} +1 -1
- package/{index-xa0289eg.js → index-6zb17wcm.js} +16 -9
- package/{index-qgazn58x.js → index-7a07tdap.js} +50 -38
- package/{index-m5sg5spm.js → index-7ehdht84.js} +565 -187
- package/{index-y725zb1a.js → index-7v7tvgt7.js} +196 -168
- package/{index-pq5rjkch.js → index-88s746ns.js} +7 -2
- package/{index-r0a604h4.js → index-99kjwyma.js} +1 -1
- package/{index-2mrn1mrg.js → index-9f3reh2y.js} +1 -1
- package/{index-386canwe.js → index-9rv2zt48.js} +186 -121
- package/{index-wr9magsr.js → index-9zswcze5.js} +3 -3
- package/{index-xq97me1h.js → index-a41vv4cy.js} +811 -697
- package/{index-yf9wc28h.js → index-bejy9zyc.js} +1 -1
- package/{index-bdmgqzb5.js → index-bket1068.js} +58 -29
- package/{index-bns3wcpc.js → index-by2tvsq6.js} +1 -1
- package/{index-1cb9apzn.js → index-czf94w8c.js} +2 -2
- package/{index-65b6ms4c.js → index-d3178asw.js} +15 -11
- package/index-dss3ds74.js +127 -0
- package/{index-annxfpgz.js → index-eyfty8kk.js} +9 -9
- package/{index-ny2k80mv.js → index-ffa52fwf.js} +1 -1
- package/{index-8jpc5fqv.js → index-g7jgd4xs.js} +2 -2
- package/{index-abfbf01s.js → index-gwsesvqc.js} +2 -2
- package/{index-kcpk2d20.js → index-h1w4wqgd.js} +1474 -1139
- package/{index-j1hjb477.js → index-hp2c7xc2.js} +1 -1
- package/index-j4yvgfhr.js +70 -0
- package/{index-84c2pgak.js → index-jx2jcw1r.js} +89 -78
- package/{index-j6eeh5d7.js → index-knpm8sdm.js} +5 -5
- package/{index-2gees180.js → index-mpp4aas6.js} +62 -33
- package/index-na8r4a27.js +30 -0
- package/{index-0mqga3h9.js → index-nmxszh6x.js} +525 -440
- package/{index-35j83zkd.js → index-p5zh7pmc.js} +2 -2
- package/{index-20wvskt8.js → index-pt0agdck.js} +1 -1
- package/{index-htxck0pn.js → index-q444k260.js} +15 -10
- package/{index-wfmpxke3.js → index-qssq2d41.js} +2775 -3677
- package/{index-23860fej.js → index-rwgqba9p.js} +24 -9
- package/{index-v50xjbbe.js → index-t4d0ckde.js} +1 -1
- package/index-va90m8nd.js +25 -0
- package/index-vjbne22r.js +80 -0
- package/{index-djc5nxpy.js → index-w23tf30e.js} +6 -6
- package/{index-mvwvxgtd.js → index-wa01phm9.js} +289 -210
- package/{index-h7hehkw6.js → index-xczjdng6.js} +3 -1
- package/{index-vbhx60x5.js → index-xwe7y0gf.js} +2140 -2165
- package/index-ze48c0vd.js +788 -0
- package/{index-dk4g0x0d.js → index-zttyg7tg.js} +27 -16
- package/{index-ygdbn9jn.js → index-zyb0ebm4.js} +1 -1
- package/index.js +29 -24
- package/libExecutor-tq994592.js +10 -0
- package/{library.command-8d03a0pq.js → library.command-x219mhcx.js} +9 -4
- package/{localRegistry.command-vyv5k6t0.js → localRegistry.command-4p17wa9t.js} +30 -24
- package/{module.command-vy3kg965.js → module.command-tjthnvvr.js} +17 -8
- package/{package.command-qjh13rs9.js → package.command-c6df2hxx.js} +13 -8
- package/package.json +2 -2
- package/{page.command-t0nx1jat.js → page.command-gf06paq2.js} +9 -4
- package/{pipeline.command-2yjeas7m.js → pipeline.command-y07dgj9b.js} +14 -8
- package/pkgExecutor-stde3yc3.js +10 -0
- package/{primitive.command-8vm49279.js → primitive.command-0enfygxn.js} +13 -8
- package/{projectTypecheck-s9hhe5sa.js → projectTypecheck-mk8wefvd.js} +2 -1
- package/{prompter-qrwx1p17.js → prompter-qyggfhqd.js} +2 -2
- package/{quality.command-v76fev72.js → quality.command-dkbdztad.js} +23 -16
- package/{recipeScanner-4b69ybe0.js → recipeScanner-rrx69awy.js} +1 -1
- package/{repair.command-fp4m3w03.js → repair.command-g5vd95ax.js} +13 -8
- package/{routeSourceValidator-4h947v7c.js → routeSourceValidator-8n6j1vn7.js} +4 -2
- package/{scalar.command-hxe6try8.js → scalar.command-7909pg0d.js} +11 -6
- package/skills/akan-debug/SKILL.md +10 -3
- package/skills/akan-err/SKILL.md +7 -0
- package/skills/akan-mcp/SKILL.md +13 -2
- package/skills/akan-scaffold/SKILL.md +2 -2
- package/skills/akan-transport/SKILL.md +2 -0
- package/skills/akan-validate/SKILL.md +1 -0
- package/{subspace.command-q42n1844.js → subspace.command-at4jt1fb.js} +29 -23
- package/templates/biomeForm.ts +1 -1
- package/templates/env/_env.server.type.ts +1 -1
- package/templates/facetIndex/index.ts +2 -37
- package/templates/lib/sig.ts +0 -4
- package/templates/lib/useClient.ts +1 -1
- package/templates/workspaceRoot/AGENTS.md.template +2 -1
- package/{tunnel.command-22g11n0x.js → tunnel.command-91h92dwr.js} +17 -12
- package/{typeChecker-s640r6c0.js → typeChecker-bfrd1n9n.js} +1 -1
- package/typecheck.proc.js +6 -3
- package/{verify.command-rx43bha1.js → verify.command-pzky05ts.js} +26 -20
- package/{workflow.command-yg0d8mmq.js → workflow.command-mqqe4n12.js} +37 -19
- package/{workspace.command-fcfztvn5.js → workspace.command-y4rznvhx.js} +64 -53
- package/CodeAgent-6cpjtj25.js +0 -11
- package/TunnelShare-zkfkrw8w.js +0 -14
- package/agent.command-kf1g3nh4.js +0 -51
- package/cloud.script-agpxzq6j.js +0 -30
- package/context.runner-ftv8373t.js +0 -29
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
AppExecutor2
|
|
4
|
+
} from "./index-ze48c0vd.js";
|
|
5
|
+
import {
|
|
6
|
+
LibExecutor2
|
|
7
|
+
} from "./index-na8r4a27.js";
|
|
6
8
|
import {
|
|
7
9
|
createAst,
|
|
8
10
|
AkanIndex
|
|
9
|
-
} from "./index-
|
|
11
|
+
} from "./index-7ehdht84.js";
|
|
12
|
+
import {
|
|
13
|
+
sysNamePattern,
|
|
14
|
+
identifierPattern
|
|
15
|
+
} from "./index-va90m8nd.js";
|
|
10
16
|
import {
|
|
11
17
|
camelToKebabCase
|
|
12
|
-
} from "./index-
|
|
18
|
+
} from "./index-9rv2zt48.js";
|
|
13
19
|
|
|
14
20
|
// pkgs/@akanjs/devkit/workflow/artifacts.ts
|
|
15
21
|
import { capitalize as capitalize2 } from "akanjs/common";
|
|
@@ -180,11 +186,9 @@ var createWorkflowApplyReport = ({
|
|
|
180
186
|
nextActions = [],
|
|
181
187
|
plan
|
|
182
188
|
}) => {
|
|
183
|
-
const
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
action: inferNextActionCode(action, diagnostics)
|
|
187
|
-
}));
|
|
189
|
+
const status = workflowStatus(diagnostics);
|
|
190
|
+
const validationCommands = status === "failed" ? [] : recommendedValidationCommands ?? commands;
|
|
191
|
+
const nextActionsWithIntent = nextActions.map((action) => ({ ...action, action: inferNextActionCode(action, diagnostics) })).filter((action) => status !== "failed" || action.action !== "validate");
|
|
188
192
|
if (sourceChangeBlocked(diagnostics) && !nextActionsWithIntent.some((action) => action.action === "blocked")) {
|
|
189
193
|
nextActionsWithIntent.unshift({
|
|
190
194
|
command: `akan workflow explain ${workflow}`,
|
|
@@ -194,12 +198,12 @@ var createWorkflowApplyReport = ({
|
|
|
194
198
|
}
|
|
195
199
|
const orderedNextActions = uniqueBy(nextActionsWithIntent, (action) => action.command).sort((left, right) => nextActionPriority(left, diagnostics) - nextActionPriority(right, diagnostics));
|
|
196
200
|
const sourceFilesChanged = uniqueBy(changedFiles, (file) => `${file.action}:${file.path}:${file.reason}`);
|
|
197
|
-
const generatedFilesSynced = uniqueBy(generatedFiles, (file) => `${file.action}:${file.path}:${file.reason}`);
|
|
201
|
+
const generatedFilesSynced = status === "failed" ? [] : uniqueBy(generatedFiles, (file) => `${file.action}:${file.path}:${file.reason}`);
|
|
198
202
|
return {
|
|
199
203
|
schemaVersion: 1,
|
|
200
204
|
workflow,
|
|
201
205
|
mode,
|
|
202
|
-
status
|
|
206
|
+
status,
|
|
203
207
|
summary: {
|
|
204
208
|
sourceFilesChanged,
|
|
205
209
|
generatedFilesSynced
|
|
@@ -527,15 +531,12 @@ var createRepairReport = ({
|
|
|
527
531
|
});
|
|
528
532
|
// pkgs/@akanjs/devkit/workflow/executor.ts
|
|
529
533
|
import { capitalize as capitalize3 } from "akanjs/common";
|
|
530
|
-
import
|
|
534
|
+
import ts7 from "typescript";
|
|
531
535
|
|
|
532
|
-
// pkgs/@akanjs/devkit/workflow/
|
|
533
|
-
import
|
|
534
|
-
import path from "path";
|
|
535
|
-
import ts3 from "typescript";
|
|
536
|
+
// pkgs/@akanjs/devkit/workflow/constantSource.ts
|
|
537
|
+
import ts4 from "typescript";
|
|
536
538
|
|
|
537
|
-
// pkgs/@akanjs/devkit/workflow/
|
|
538
|
-
import { lowerlize as lowerlize2 } from "akanjs/common";
|
|
539
|
+
// pkgs/@akanjs/devkit/workflow/fieldOrder.ts
|
|
539
540
|
import ts2 from "typescript";
|
|
540
541
|
|
|
541
542
|
// pkgs/@akanjs/devkit/workflow/sourceAst.ts
|
|
@@ -549,130 +550,121 @@ var {
|
|
|
549
550
|
firstObjectReturnedByArrow,
|
|
550
551
|
heritageCall
|
|
551
552
|
} = createAst(ts);
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
var
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
abstract: `lib/${moduleName}/${moduleName}.abstract.md`,
|
|
565
|
-
constant: `lib/${moduleName}/${moduleName}.constant.ts`,
|
|
566
|
-
dictionary: `lib/${moduleName}/${moduleName}.dictionary.ts`,
|
|
567
|
-
document: `lib/${moduleName}/${moduleName}.document.ts`,
|
|
568
|
-
service: `lib/${moduleName}/${moduleName}.service.ts`,
|
|
569
|
-
signal: `lib/${moduleName}/${moduleName}.signal.ts`,
|
|
570
|
-
store: `lib/${moduleName}/${moduleName}.store.ts`,
|
|
571
|
-
template: `lib/${moduleName}/${componentName}.Template.tsx`,
|
|
572
|
-
unit: `lib/${moduleName}/${componentName}.Unit.tsx`,
|
|
573
|
-
util: `lib/${moduleName}/${componentName}.Util.tsx`,
|
|
574
|
-
view: `lib/${moduleName}/${componentName}.View.tsx`,
|
|
575
|
-
zone: `lib/${moduleName}/${componentName}.Zone.tsx`
|
|
553
|
+
var hasParseDiagnostics = (source) => (source.parseDiagnostics ?? []).length > 0;
|
|
554
|
+
var hasSourceParseErrors = (content, fileName = "source.ts") => hasParseDiagnostics(sourceFileFor(fileName, content));
|
|
555
|
+
var findClassDeclaration = (source, className) => {
|
|
556
|
+
let found = null;
|
|
557
|
+
const visit = (node) => {
|
|
558
|
+
if (found)
|
|
559
|
+
return;
|
|
560
|
+
if (ts.isClassDeclaration(node) && node.name?.text === className) {
|
|
561
|
+
found = node;
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
ts.forEachChild(node, visit);
|
|
576
565
|
};
|
|
566
|
+
ts.forEachChild(source, visit);
|
|
567
|
+
return found;
|
|
577
568
|
};
|
|
578
|
-
var
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
];
|
|
582
|
-
var nextActionsForTarget = (target) => [
|
|
583
|
-
{ command: `akan verify ${target}`, reason: "Refresh generated files and validate the target in one run." }
|
|
584
|
-
];
|
|
585
|
-
var createPrimitiveWriteReport = ({
|
|
586
|
-
command,
|
|
587
|
-
status,
|
|
588
|
-
changedFiles = [],
|
|
589
|
-
generatedFiles = [],
|
|
590
|
-
validationCommands = [],
|
|
591
|
-
diagnostics = [],
|
|
592
|
-
nextActions = []
|
|
593
|
-
}) => ({
|
|
594
|
-
schemaVersion: 1,
|
|
595
|
-
command,
|
|
596
|
-
status: status ?? (diagnostics.some((diagnostic) => diagnostic.severity === "error") ? "failed" : "passed"),
|
|
597
|
-
changedFiles,
|
|
598
|
-
generatedFiles,
|
|
599
|
-
validationCommands,
|
|
600
|
-
diagnostics,
|
|
601
|
-
nextActions
|
|
602
|
-
});
|
|
603
|
-
var createPassedPrimitiveReport = ({
|
|
604
|
-
command,
|
|
605
|
-
changedFiles,
|
|
606
|
-
generatedFiles,
|
|
607
|
-
target,
|
|
608
|
-
nextActions
|
|
609
|
-
}) => createPrimitiveWriteReport({
|
|
610
|
-
command,
|
|
611
|
-
changedFiles,
|
|
612
|
-
generatedFiles: generatedFiles ?? [],
|
|
613
|
-
validationCommands: validationCommandsForTarget(target),
|
|
614
|
-
diagnostics: [],
|
|
615
|
-
nextActions: nextActions ?? nextActionsForTarget(target)
|
|
616
|
-
});
|
|
617
|
-
var scalarChangedFiles = (sys, scalarName, files) => Object.values(files).map((file) => sourceFile(sys, `lib/__scalar/${scalarName}/${file.filename}`, "create", "Scalar source file was created."));
|
|
618
|
-
var titleize = (value) => value.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
|
|
619
|
-
var koLabels = {
|
|
620
|
-
amount: "\uAE08\uC561",
|
|
621
|
-
budget: "\uC608\uC0B0",
|
|
622
|
-
category: "\uCE74\uD14C\uACE0\uB9AC",
|
|
623
|
-
content: "\uB0B4\uC6A9",
|
|
624
|
-
count: "\uAC1C\uC218",
|
|
625
|
-
createdAt: "\uC0DD\uC131\uC77C",
|
|
626
|
-
date: "\uB0A0\uC9DC",
|
|
627
|
-
description: "\uC124\uBA85",
|
|
628
|
-
due: "\uB9C8\uAC10\uC77C",
|
|
629
|
-
dueAt: "\uB9C8\uAC10\uC77C",
|
|
630
|
-
email: "\uC774\uBA54\uC77C",
|
|
631
|
-
enabled: "\uD65C\uC131\uD654",
|
|
632
|
-
endAt: "\uC885\uB8CC\uC77C",
|
|
633
|
-
id: "ID",
|
|
634
|
-
name: "\uC774\uB984",
|
|
635
|
-
owner: "\uB2F4\uB2F9\uC790",
|
|
636
|
-
priority: "\uC6B0\uC120\uC21C\uC704",
|
|
637
|
-
project: "\uD504\uB85C\uC81D\uD2B8",
|
|
638
|
-
rating: "\uD3C9\uC810",
|
|
639
|
-
startAt: "\uC2DC\uC791\uC77C",
|
|
640
|
-
status: "\uC0C1\uD0DC",
|
|
641
|
-
title: "\uC81C\uBAA9",
|
|
642
|
-
updatedAt: "\uC218\uC815\uC77C"
|
|
569
|
+
var firstHeritageCall = (node) => {
|
|
570
|
+
const expression = (node.heritageClauses?.flatMap((clause) => [...clause.types]) ?? [])[0]?.expression;
|
|
571
|
+
return expression && ts.isCallExpression(expression) ? expression : null;
|
|
643
572
|
};
|
|
644
|
-
var
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
return koLabels[fieldName];
|
|
648
|
-
const words = splitFieldWords(fieldName);
|
|
649
|
-
const translated = words.map((word) => koLabels[word] ?? koLabels[lowerlize2(word)] ?? null);
|
|
650
|
-
return translated.every(Boolean) ? translated.join(" ") : null;
|
|
573
|
+
var factoryArrowOf = (call) => {
|
|
574
|
+
const arg = call.arguments.find((argument) => ts.isArrowFunction(argument) || ts.isFunctionExpression(argument));
|
|
575
|
+
return arg && (ts.isArrowFunction(arg) || ts.isFunctionExpression(arg)) ? arg : null;
|
|
651
576
|
};
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
577
|
+
|
|
578
|
+
// pkgs/@akanjs/devkit/workflow/sourceText.ts
|
|
579
|
+
var spliceText = (content, start, end, replacement) => `${content.slice(0, start)}${replacement}${content.slice(end)}`;
|
|
580
|
+
var lineStartAt = (content, position) => content.lastIndexOf(`
|
|
581
|
+
`, Math.max(0, position - 1)) + 1;
|
|
582
|
+
var lineEndAt = (content, position) => {
|
|
583
|
+
const end = content.indexOf(`
|
|
584
|
+
`, position);
|
|
585
|
+
return end < 0 ? content.length : end + 1;
|
|
655
586
|
};
|
|
656
|
-
var
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
587
|
+
var lineIndentAt = (content, position) => /^[ \t]*/.exec(content.slice(lineStartAt(content, position)))?.[0] ?? "";
|
|
588
|
+
|
|
589
|
+
// pkgs/@akanjs/devkit/workflow/fieldOrder.ts
|
|
590
|
+
var fieldOrderingPriority = [
|
|
591
|
+
"id",
|
|
592
|
+
"name",
|
|
593
|
+
"title",
|
|
594
|
+
"status",
|
|
595
|
+
"category",
|
|
596
|
+
"description",
|
|
597
|
+
"content",
|
|
598
|
+
"startAt",
|
|
599
|
+
"dueAt",
|
|
600
|
+
"endAt",
|
|
601
|
+
"createdAt",
|
|
602
|
+
"updatedAt"
|
|
603
|
+
];
|
|
604
|
+
var locatedObject = (source, objectLiteral) => ({
|
|
605
|
+
objectStart: objectLiteral.getStart(source),
|
|
606
|
+
objectEnd: objectLiteral.getEnd(),
|
|
607
|
+
fields: objectLiteral.properties.map((property) => {
|
|
608
|
+
const name = propertyName(property);
|
|
609
|
+
if (!name)
|
|
610
|
+
return null;
|
|
611
|
+
return {
|
|
612
|
+
name,
|
|
613
|
+
start: property.getStart(source),
|
|
614
|
+
fullStart: property.getFullStart(),
|
|
615
|
+
end: property.getEnd()
|
|
616
|
+
};
|
|
617
|
+
}).filter((field) => field !== null)
|
|
618
|
+
});
|
|
619
|
+
var priorityOf = (fieldName) => {
|
|
620
|
+
const priority = fieldOrderingPriority.indexOf(fieldName);
|
|
621
|
+
return priority < 0 ? null : priority;
|
|
662
622
|
};
|
|
663
|
-
var
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
623
|
+
var insertionIndexForFieldOrder = (fieldNames, newFieldName) => {
|
|
624
|
+
const newPriority = priorityOf(newFieldName);
|
|
625
|
+
if (newPriority !== null) {
|
|
626
|
+
const greaterPriorityIndex = fieldNames.findIndex((name) => {
|
|
627
|
+
const existingPriority = priorityOf(name);
|
|
628
|
+
return existingPriority !== null && existingPriority > newPriority;
|
|
629
|
+
});
|
|
630
|
+
if (greaterPriorityIndex >= 0)
|
|
631
|
+
return greaterPriorityIndex;
|
|
632
|
+
const lastPriorityIndex = fieldNames.reduce((lastIndex, name, index) => {
|
|
633
|
+
const existingPriority = priorityOf(name);
|
|
634
|
+
return existingPriority !== null ? index : lastIndex;
|
|
635
|
+
}, -1);
|
|
636
|
+
return lastPriorityIndex + 1;
|
|
637
|
+
}
|
|
638
|
+
const lastNonPriorityIndex = fieldNames.reduce((lastIndex, name, index) => priorityOf(name) === null ? index : lastIndex, -1);
|
|
639
|
+
return lastNonPriorityIndex >= 0 ? lastNonPriorityIndex + 1 : fieldNames.length;
|
|
640
|
+
};
|
|
641
|
+
var insertOrderedFieldLine = (content, locator, fieldName, line, options) => {
|
|
642
|
+
if (locator.fields.some((field) => field.name === fieldName))
|
|
643
|
+
return content;
|
|
644
|
+
const insertIndex = insertionIndexForFieldOrder(locator.fields.map((field) => field.name), fieldName);
|
|
645
|
+
const formattedLine = line.trim();
|
|
646
|
+
if (locator.fields.length === 0) {
|
|
647
|
+
return spliceText(content, locator.objectStart, locator.objectEnd, `{
|
|
648
|
+
${options.fieldIndent}${formattedLine}
|
|
649
|
+
${options.closingIndent}}`);
|
|
650
|
+
}
|
|
651
|
+
const beforeField = locator.fields[insertIndex];
|
|
652
|
+
if (beforeField) {
|
|
653
|
+
const leadingComments = ts2.getLeadingCommentRanges(content, beforeField.fullStart) ?? [];
|
|
654
|
+
const insertAt = lineStartAt(content, leadingComments[0]?.pos ?? beforeField.start);
|
|
655
|
+
const indent = lineIndentAt(content, beforeField.start) || options.fieldIndent;
|
|
656
|
+
return spliceText(content, insertAt, insertAt, `${indent}${formattedLine}
|
|
657
|
+
`);
|
|
658
|
+
}
|
|
659
|
+
const afterField = locator.fields[locator.fields.length - 1];
|
|
660
|
+
const insertAt = lineEndAt(content, afterField.end);
|
|
661
|
+
const indent = lineIndentAt(content, afterField.start) || options.fieldIndent;
|
|
662
|
+
return spliceText(content, insertAt, insertAt, `${indent}${formattedLine}
|
|
663
|
+
`);
|
|
675
664
|
};
|
|
665
|
+
|
|
666
|
+
// pkgs/@akanjs/devkit/workflow/sourceImports.ts
|
|
667
|
+
import ts3 from "typescript";
|
|
676
668
|
var importOrder = (a, b) => {
|
|
677
669
|
const [lowerA, lowerB] = [a.toLowerCase(), b.toLowerCase()];
|
|
678
670
|
if (lowerA !== lowerB)
|
|
@@ -694,7 +686,7 @@ var ensureImportDeclaration = (content, moduleSpecifier, clause) => {
|
|
|
694
686
|
if (content.includes(line))
|
|
695
687
|
return content;
|
|
696
688
|
const source = sourceFileFor("source.ts", content);
|
|
697
|
-
const imports = source.statements.filter((statement) =>
|
|
689
|
+
const imports = source.statements.filter((statement) => ts3.isImportDeclaration(statement)).flatMap((statement) => ts3.isStringLiteral(statement.moduleSpecifier) ? [{ specifier: statement.moduleSpecifier.text, start: statement.getStart(source), end: statement.getEnd() }] : []);
|
|
698
690
|
const isRelative = (specifier) => specifier.startsWith(".");
|
|
699
691
|
const peers = imports.filter((entry) => isRelative(entry.specifier) === isRelative(moduleSpecifier));
|
|
700
692
|
const before = peers.find((entry) => importOrder(entry.specifier, moduleSpecifier) > 0);
|
|
@@ -717,249 +709,67 @@ ${line}
|
|
|
717
709
|
`);
|
|
718
710
|
};
|
|
719
711
|
var ensureBaseImport = (content, name) => ensureNamedImport(content, "akanjs/base", name);
|
|
720
|
-
var
|
|
721
|
-
|
|
712
|
+
var findNamedImport = (source, moduleSpecifier, { valueOnly = false } = {}) => {
|
|
713
|
+
for (const statement of source.statements) {
|
|
714
|
+
if (!ts3.isImportDeclaration(statement) || !ts3.isStringLiteral(statement.moduleSpecifier))
|
|
715
|
+
continue;
|
|
716
|
+
if (statement.moduleSpecifier.text !== moduleSpecifier)
|
|
717
|
+
continue;
|
|
718
|
+
if (valueOnly && statement.importClause?.isTypeOnly)
|
|
719
|
+
continue;
|
|
720
|
+
const namedBindings = statement.importClause?.namedBindings;
|
|
721
|
+
if (!namedBindings || !ts3.isNamedImports(namedBindings))
|
|
722
|
+
continue;
|
|
723
|
+
return {
|
|
724
|
+
names: namedBindings.elements.map((element) => element.name.text),
|
|
725
|
+
elements: namedBindings.elements.map((element) => ({ name: element.name.text, text: element.getText(source) })),
|
|
726
|
+
namedBindingsStart: namedBindings.getStart(source),
|
|
727
|
+
namedBindingsEnd: namedBindings.getEnd()
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
return null;
|
|
731
|
+
};
|
|
732
|
+
var ensureEnumImport = (content) => {
|
|
733
|
+
if (content.includes("enumOf"))
|
|
722
734
|
return content;
|
|
723
|
-
|
|
735
|
+
const baseImport = /import \{ ([^{}]+) \} from "akanjs\/base";/.exec(content);
|
|
736
|
+
if (baseImport) {
|
|
737
|
+
const names = baseImport[1]?.split(",").map((name) => name.trim()) ?? [];
|
|
738
|
+
return content.replace(baseImport[0], `import { ${[...names, "enumOf"].sort().join(", ")} } from "akanjs/base";`);
|
|
739
|
+
}
|
|
740
|
+
return `import { enumOf } from "akanjs/base";
|
|
741
|
+
${content}`;
|
|
724
742
|
};
|
|
725
|
-
var
|
|
726
|
-
if (
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
if (typeof rawDefault !== "string")
|
|
734
|
-
return null;
|
|
735
|
-
const trimmed = rawDefault.trim();
|
|
736
|
-
if (!trimmed || !Number.isFinite(Number(trimmed)))
|
|
737
|
-
return null;
|
|
738
|
-
if (typeName === "Int" && !/^-?\d+$/.test(trimmed))
|
|
739
|
-
return null;
|
|
740
|
-
return trimmed;
|
|
741
|
-
};
|
|
742
|
-
var booleanDefault = (rawDefault) => {
|
|
743
|
-
if (typeof rawDefault === "boolean")
|
|
744
|
-
return String(rawDefault);
|
|
745
|
-
if (typeof rawDefault !== "string")
|
|
746
|
-
return null;
|
|
747
|
-
const lowered = rawDefault.trim().toLowerCase();
|
|
748
|
-
return lowered === "true" || lowered === "false" ? lowered : null;
|
|
749
|
-
};
|
|
750
|
-
var dateDefault = (rawDefault) => {
|
|
751
|
-
if (typeof rawDefault === "number" && Number.isFinite(rawDefault))
|
|
752
|
-
return `() => dayjs(${rawDefault})`;
|
|
753
|
-
if (typeof rawDefault !== "string")
|
|
754
|
-
return null;
|
|
755
|
-
const trimmed = rawDefault.trim();
|
|
756
|
-
if (!trimmed)
|
|
757
|
-
return null;
|
|
758
|
-
if (trimmed === "now")
|
|
759
|
-
return "() => dayjs()";
|
|
760
|
-
if (!Number.isNaN(Date.parse(trimmed)))
|
|
761
|
-
return `() => dayjs(${JSON.stringify(trimmed)})`;
|
|
762
|
-
return null;
|
|
763
|
-
};
|
|
764
|
-
var coerceFieldDefault = (typeName, defaultValue, options = {}) => {
|
|
765
|
-
const normalizedType = typeName.toLowerCase() === "enum" ? "enum" : normalizeFieldType(typeName);
|
|
766
|
-
if (defaultValue === undefined || defaultValue === null || defaultValue === "") {
|
|
767
|
-
return { expression: null, normalized: false, normalizedType };
|
|
768
|
-
}
|
|
769
|
-
if (normalizedType === "Int" || normalizedType === "Float") {
|
|
770
|
-
const expression = numericDefault(normalizedType, defaultValue);
|
|
771
|
-
if (expression !== null)
|
|
772
|
-
return { expression, normalized: typeof defaultValue === "string", normalizedType };
|
|
773
|
-
return {
|
|
774
|
-
expression: null,
|
|
775
|
-
normalized: false,
|
|
776
|
-
normalizedType,
|
|
777
|
-
diagnostic: {
|
|
778
|
-
severity: "error",
|
|
779
|
-
code: "primitive-default-value-invalid",
|
|
780
|
-
input: "default",
|
|
781
|
-
failureScope: "source-change",
|
|
782
|
-
message: `Default value for ${normalizedType} must be a numeric literal. Received: ${JSON.stringify(defaultValue)}.`
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
if (normalizedType === "Boolean") {
|
|
787
|
-
const expression = booleanDefault(defaultValue);
|
|
788
|
-
if (expression !== null)
|
|
789
|
-
return { expression, normalized: typeof defaultValue === "string", normalizedType };
|
|
790
|
-
return {
|
|
791
|
-
expression: null,
|
|
792
|
-
normalized: false,
|
|
793
|
-
normalizedType,
|
|
794
|
-
diagnostic: {
|
|
795
|
-
severity: "error",
|
|
796
|
-
code: "primitive-default-value-invalid",
|
|
797
|
-
input: "default",
|
|
798
|
-
failureScope: "source-change",
|
|
799
|
-
message: `Default value for Boolean must be true or false. Received: ${JSON.stringify(defaultValue)}.`
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
|
-
}
|
|
803
|
-
if (normalizedType === "Date") {
|
|
804
|
-
const expression = dateDefault(defaultValue);
|
|
805
|
-
if (expression !== null)
|
|
806
|
-
return { expression, normalized: true, normalizedType };
|
|
807
|
-
return {
|
|
808
|
-
expression: null,
|
|
809
|
-
normalized: false,
|
|
810
|
-
normalizedType,
|
|
811
|
-
diagnostic: {
|
|
812
|
-
severity: "error",
|
|
813
|
-
code: "primitive-default-value-invalid",
|
|
814
|
-
input: "default",
|
|
815
|
-
failureScope: "source-change",
|
|
816
|
-
message: `Default value for Date must be "now", a timestamp, or a parseable date string. Received: ${JSON.stringify(defaultValue)}.`
|
|
817
|
-
}
|
|
818
|
-
};
|
|
819
|
-
}
|
|
820
|
-
if (normalizedType === "enum") {
|
|
821
|
-
if (typeof defaultValue === "string" && options.enumValues?.includes(defaultValue)) {
|
|
822
|
-
return { expression: JSON.stringify(defaultValue), normalized: false, normalizedType };
|
|
823
|
-
}
|
|
824
|
-
return {
|
|
825
|
-
expression: null,
|
|
826
|
-
normalized: false,
|
|
827
|
-
normalizedType,
|
|
828
|
-
diagnostic: {
|
|
829
|
-
severity: "error",
|
|
830
|
-
code: "primitive-default-value-invalid",
|
|
831
|
-
input: "default",
|
|
832
|
-
failureScope: "source-change",
|
|
833
|
-
message: `Default value for enum must be one of: ${(options.enumValues ?? []).join(", ")}. Received: ${JSON.stringify(defaultValue)}.`
|
|
834
|
-
}
|
|
835
|
-
};
|
|
743
|
+
var ensureConstantTypeImport = (content, constantPath, typeName) => {
|
|
744
|
+
if (new RegExp(`import type \\{[^}]*\\b${typeName}\\b[^}]*\\} from "${constantPath}";`).test(content))
|
|
745
|
+
return content;
|
|
746
|
+
const importPattern = new RegExp(`import type \\{ ([^}]+) \\} from "${constantPath}";`);
|
|
747
|
+
const existingImport = content.match(importPattern);
|
|
748
|
+
if (existingImport !== null) {
|
|
749
|
+
const names = existingImport[1]?.split(",").map((name) => name.trim()) ?? [];
|
|
750
|
+
return content.replace(existingImport[0], `import type { ${[...names, typeName].sort().join(", ")} } from "${constantPath}";`);
|
|
836
751
|
}
|
|
837
|
-
return {
|
|
838
|
-
|
|
839
|
-
normalized: typeof defaultValue !== "string",
|
|
840
|
-
normalizedType
|
|
841
|
-
};
|
|
842
|
-
};
|
|
843
|
-
var fieldExpression = (typeName, defaultValue, options = {}) => {
|
|
844
|
-
const typeExpression = normalizeFieldType(typeName);
|
|
845
|
-
const defaultExpression = coerceFieldDefault(options.enumValues ? "enum" : typeExpression, defaultValue, options).expression;
|
|
846
|
-
const defaultOption = defaultExpression ? `, { default: ${defaultExpression} }` : "";
|
|
847
|
-
return `${options.builderName ?? "field"}(${typeExpression}${defaultOption})`;
|
|
848
|
-
};
|
|
849
|
-
var fieldOrderingPriority = [
|
|
850
|
-
"id",
|
|
851
|
-
"name",
|
|
852
|
-
"title",
|
|
853
|
-
"status",
|
|
854
|
-
"category",
|
|
855
|
-
"description",
|
|
856
|
-
"content",
|
|
857
|
-
"startAt",
|
|
858
|
-
"dueAt",
|
|
859
|
-
"endAt",
|
|
860
|
-
"createdAt",
|
|
861
|
-
"updatedAt"
|
|
862
|
-
];
|
|
863
|
-
var hasParseDiagnostics = (source) => (source.parseDiagnostics ?? []).length > 0;
|
|
864
|
-
var spliceText = (content, start, end, replacement) => `${content.slice(0, start)}${replacement}${content.slice(end)}`;
|
|
865
|
-
var lineStartAt = (content, position) => content.lastIndexOf(`
|
|
866
|
-
`, Math.max(0, position - 1)) + 1;
|
|
867
|
-
var lineEndAt = (content, position) => {
|
|
868
|
-
const end = content.indexOf(`
|
|
869
|
-
`, position);
|
|
870
|
-
return end < 0 ? content.length : end + 1;
|
|
752
|
+
return `import type { ${typeName} } from "${constantPath}";
|
|
753
|
+
${content}`;
|
|
871
754
|
};
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
objectStart: objectLiteral.getStart(source),
|
|
875
|
-
objectEnd: objectLiteral.getEnd(),
|
|
876
|
-
fields: objectLiteral.properties.map((property) => {
|
|
877
|
-
const name = propertyName(property);
|
|
878
|
-
if (!name)
|
|
879
|
-
return null;
|
|
880
|
-
return {
|
|
881
|
-
name,
|
|
882
|
-
start: property.getStart(source),
|
|
883
|
-
fullStart: property.getFullStart(),
|
|
884
|
-
end: property.getEnd()
|
|
885
|
-
};
|
|
886
|
-
}).filter((field) => field !== null)
|
|
887
|
-
});
|
|
755
|
+
|
|
756
|
+
// pkgs/@akanjs/devkit/workflow/constantSource.ts
|
|
888
757
|
var findConstantInputObject = (source, className) => {
|
|
889
758
|
let locator = null;
|
|
890
759
|
const visit = (node) => {
|
|
891
760
|
if (locator)
|
|
892
761
|
return;
|
|
893
|
-
if (!
|
|
894
|
-
|
|
762
|
+
if (!ts4.isClassDeclaration(node) || node.name?.text !== className) {
|
|
763
|
+
ts4.forEachChild(node, visit);
|
|
895
764
|
return;
|
|
896
765
|
}
|
|
897
766
|
const viaCall = heritageCall(node);
|
|
898
|
-
const callback = viaCall?.arguments.find((arg) =>
|
|
767
|
+
const callback = viaCall?.arguments.find((arg) => ts4.isArrowFunction(arg) || ts4.isFunctionExpression(arg));
|
|
899
768
|
const objectLiteral = callback ? firstObjectReturnedByArrow(callback) : null;
|
|
900
769
|
if (objectLiteral)
|
|
901
770
|
locator = locatedObject(source, objectLiteral);
|
|
902
771
|
};
|
|
903
|
-
|
|
904
|
-
return locator;
|
|
905
|
-
};
|
|
906
|
-
var chainMethodsForCall = (node) => {
|
|
907
|
-
if (ts2.isAsExpression(node) || ts2.isParenthesizedExpression(node))
|
|
908
|
-
return chainMethodsForCall(node.expression);
|
|
909
|
-
if (!ts2.isCallExpression(node))
|
|
910
|
-
return [];
|
|
911
|
-
if (ts2.isPropertyAccessExpression(node.expression)) {
|
|
912
|
-
return [...chainMethodsForCall(node.expression.expression), node.expression.name.text];
|
|
913
|
-
}
|
|
914
|
-
const name = expressionName(node.expression);
|
|
915
|
-
return name ? [name] : [];
|
|
916
|
-
};
|
|
917
|
-
var outermostFluentCall = (node) => {
|
|
918
|
-
let current = node;
|
|
919
|
-
while (ts2.isPropertyAccessExpression(current.parent) && current.parent.expression === current && ts2.isCallExpression(current.parent.parent) && current.parent.parent.expression === current.parent) {
|
|
920
|
-
current = current.parent.parent;
|
|
921
|
-
}
|
|
922
|
-
return current;
|
|
923
|
-
};
|
|
924
|
-
var protectedDictionaryChainOrder = ["model", "slice", "enum", "error", "translate"];
|
|
925
|
-
var dictionaryChainOrderValid = (chainMethods) => {
|
|
926
|
-
const protectedOrder = new Map(protectedDictionaryChainOrder.map((method, index) => [method, index]));
|
|
927
|
-
let lastOrder = -1;
|
|
928
|
-
for (const method of chainMethods) {
|
|
929
|
-
const order = protectedOrder.get(method);
|
|
930
|
-
if (order === undefined)
|
|
931
|
-
continue;
|
|
932
|
-
if (order < lastOrder)
|
|
933
|
-
return false;
|
|
934
|
-
lastOrder = order;
|
|
935
|
-
}
|
|
936
|
-
return true;
|
|
937
|
-
};
|
|
938
|
-
var findDictionaryModelObject = (source, moduleClassName) => findDictionaryStageObject(source, "model", moduleClassName);
|
|
939
|
-
var findDictionaryStageObject = (source, stage, typeName) => {
|
|
940
|
-
let locator = null;
|
|
941
|
-
const visit = (node) => {
|
|
942
|
-
if (locator)
|
|
943
|
-
return;
|
|
944
|
-
if (!ts2.isCallExpression(node) || callExpressionName(node) !== stage) {
|
|
945
|
-
ts2.forEachChild(node, visit);
|
|
946
|
-
return;
|
|
947
|
-
}
|
|
948
|
-
const typeArgument = node.typeArguments?.[0];
|
|
949
|
-
if (!typeArgument || typeArgument.getText(source) !== typeName) {
|
|
950
|
-
ts2.forEachChild(node, visit);
|
|
951
|
-
return;
|
|
952
|
-
}
|
|
953
|
-
const callback = node.arguments.find((arg) => ts2.isArrowFunction(arg) || ts2.isFunctionExpression(arg));
|
|
954
|
-
const objectLiteral = callback ? firstObjectReturnedByArrow(callback) : null;
|
|
955
|
-
if (objectLiteral) {
|
|
956
|
-
locator = {
|
|
957
|
-
...locatedObject(source, objectLiteral),
|
|
958
|
-
chainMethods: chainMethodsForCall(outermostFluentCall(node))
|
|
959
|
-
};
|
|
960
|
-
}
|
|
961
|
-
};
|
|
962
|
-
ts2.forEachChild(source, visit);
|
|
772
|
+
ts4.forEachChild(source, visit);
|
|
963
773
|
return locator;
|
|
964
774
|
};
|
|
965
775
|
var findLightProjectionArray = (source, moduleClassName) => {
|
|
@@ -967,118 +777,52 @@ var findLightProjectionArray = (source, moduleClassName) => {
|
|
|
967
777
|
const visit = (node) => {
|
|
968
778
|
if (locator)
|
|
969
779
|
return;
|
|
970
|
-
if (!
|
|
971
|
-
|
|
780
|
+
if (!ts4.isClassDeclaration(node) || node.name?.text !== `Light${moduleClassName}`) {
|
|
781
|
+
ts4.forEachChild(node, visit);
|
|
972
782
|
return;
|
|
973
783
|
}
|
|
974
784
|
const viaCall = heritageCall(node);
|
|
975
785
|
const projectionArg = viaCall?.arguments.find((arg) => {
|
|
976
|
-
const expression =
|
|
977
|
-
return
|
|
786
|
+
const expression = ts4.isAsExpression(arg) ? arg.expression : arg;
|
|
787
|
+
return ts4.isArrayLiteralExpression(expression);
|
|
978
788
|
});
|
|
979
|
-
const arrayLiteral = projectionArg ?
|
|
980
|
-
if (!projectionArg || !arrayLiteral || !
|
|
789
|
+
const arrayLiteral = projectionArg ? ts4.isAsExpression(projectionArg) ? projectionArg.expression : projectionArg : null;
|
|
790
|
+
if (!projectionArg || !arrayLiteral || !ts4.isArrayLiteralExpression(arrayLiteral))
|
|
981
791
|
return;
|
|
982
792
|
locator = {
|
|
983
793
|
projectionStart: projectionArg.getStart(source),
|
|
984
794
|
projectionEnd: projectionArg.getEnd(),
|
|
985
|
-
fields: arrayLiteral.elements.map((element) =>
|
|
795
|
+
fields: arrayLiteral.elements.map((element) => ts4.isStringLiteralLike(element) ? element.text : null).filter((field) => field !== null)
|
|
986
796
|
};
|
|
987
797
|
};
|
|
988
|
-
|
|
798
|
+
ts4.forEachChild(source, visit);
|
|
989
799
|
return locator;
|
|
990
800
|
};
|
|
991
|
-
var findNamedImport = (source, moduleSpecifier, { valueOnly = false } = {}) => {
|
|
992
|
-
for (const statement of source.statements) {
|
|
993
|
-
if (!ts2.isImportDeclaration(statement) || !ts2.isStringLiteral(statement.moduleSpecifier))
|
|
994
|
-
continue;
|
|
995
|
-
if (statement.moduleSpecifier.text !== moduleSpecifier)
|
|
996
|
-
continue;
|
|
997
|
-
if (valueOnly && statement.importClause?.isTypeOnly)
|
|
998
|
-
continue;
|
|
999
|
-
const namedBindings = statement.importClause?.namedBindings;
|
|
1000
|
-
if (!namedBindings || !ts2.isNamedImports(namedBindings))
|
|
1001
|
-
continue;
|
|
1002
|
-
return {
|
|
1003
|
-
names: namedBindings.elements.map((element) => element.name.text),
|
|
1004
|
-
elements: namedBindings.elements.map((element) => ({ name: element.name.text, text: element.getText(source) })),
|
|
1005
|
-
namedBindingsStart: namedBindings.getStart(source),
|
|
1006
|
-
namedBindingsEnd: namedBindings.getEnd()
|
|
1007
|
-
};
|
|
1008
|
-
}
|
|
1009
|
-
return null;
|
|
1010
|
-
};
|
|
1011
801
|
var fieldExpressionBuilder = (property) => {
|
|
1012
|
-
if (!
|
|
802
|
+
if (!ts4.isPropertyAssignment(property))
|
|
1013
803
|
return null;
|
|
1014
|
-
const initializer =
|
|
1015
|
-
if (!
|
|
804
|
+
const initializer = ts4.isAsExpression(property.initializer) ? property.initializer.expression : property.initializer;
|
|
805
|
+
if (!ts4.isCallExpression(initializer))
|
|
1016
806
|
return null;
|
|
1017
807
|
return expressionName(initializer.expression);
|
|
1018
808
|
};
|
|
1019
|
-
var priorityOf = (fieldName) => {
|
|
1020
|
-
const priority = fieldOrderingPriority.indexOf(fieldName);
|
|
1021
|
-
return priority < 0 ? null : priority;
|
|
1022
|
-
};
|
|
1023
|
-
var insertionIndexForFieldOrder = (fieldNames, newFieldName) => {
|
|
1024
|
-
const newPriority = priorityOf(newFieldName);
|
|
1025
|
-
if (newPriority !== null) {
|
|
1026
|
-
const greaterPriorityIndex = fieldNames.findIndex((name) => {
|
|
1027
|
-
const existingPriority = priorityOf(name);
|
|
1028
|
-
return existingPriority !== null && existingPriority > newPriority;
|
|
1029
|
-
});
|
|
1030
|
-
if (greaterPriorityIndex >= 0)
|
|
1031
|
-
return greaterPriorityIndex;
|
|
1032
|
-
const lastPriorityIndex = fieldNames.reduce((lastIndex, name, index) => {
|
|
1033
|
-
const existingPriority = priorityOf(name);
|
|
1034
|
-
return existingPriority !== null ? index : lastIndex;
|
|
1035
|
-
}, -1);
|
|
1036
|
-
return lastPriorityIndex + 1;
|
|
1037
|
-
}
|
|
1038
|
-
const lastNonPriorityIndex = fieldNames.reduce((lastIndex, name, index) => priorityOf(name) === null ? index : lastIndex, -1);
|
|
1039
|
-
return lastNonPriorityIndex >= 0 ? lastNonPriorityIndex + 1 : fieldNames.length;
|
|
1040
|
-
};
|
|
1041
|
-
var insertOrderedFieldLine = (content, locator, fieldName, line, options) => {
|
|
1042
|
-
if (locator.fields.some((field) => field.name === fieldName))
|
|
1043
|
-
return content;
|
|
1044
|
-
const insertIndex = insertionIndexForFieldOrder(locator.fields.map((field) => field.name), fieldName);
|
|
1045
|
-
const formattedLine = line.trim();
|
|
1046
|
-
if (locator.fields.length === 0) {
|
|
1047
|
-
return spliceText(content, locator.objectStart, locator.objectEnd, `{
|
|
1048
|
-
${options.fieldIndent}${formattedLine}
|
|
1049
|
-
${options.closingIndent}}`);
|
|
1050
|
-
}
|
|
1051
|
-
const beforeField = locator.fields[insertIndex];
|
|
1052
|
-
if (beforeField) {
|
|
1053
|
-
const leadingComments = ts2.getLeadingCommentRanges(content, beforeField.fullStart) ?? [];
|
|
1054
|
-
const insertAt = lineStartAt(content, leadingComments[0]?.pos ?? beforeField.start);
|
|
1055
|
-
const indent = lineIndentAt(content, beforeField.start) || options.fieldIndent;
|
|
1056
|
-
return spliceText(content, insertAt, insertAt, `${indent}${formattedLine}
|
|
1057
|
-
`);
|
|
1058
|
-
}
|
|
1059
|
-
const afterField = locator.fields[locator.fields.length - 1];
|
|
1060
|
-
const insertAt = lineEndAt(content, afterField.end);
|
|
1061
|
-
const indent = lineIndentAt(content, afterField.start) || options.fieldIndent;
|
|
1062
|
-
return spliceText(content, insertAt, insertAt, `${indent}${formattedLine}
|
|
1063
|
-
`);
|
|
1064
|
-
};
|
|
1065
809
|
var viaBuilderParameterName = (content, className) => {
|
|
1066
810
|
const source = sourceFileFor("constant.ts", content);
|
|
1067
811
|
let builderName = null;
|
|
1068
812
|
const visit = (node) => {
|
|
1069
813
|
if (builderName !== null)
|
|
1070
814
|
return;
|
|
1071
|
-
if (!
|
|
1072
|
-
|
|
815
|
+
if (!ts4.isClassDeclaration(node) || node.name?.text !== className) {
|
|
816
|
+
ts4.forEachChild(node, visit);
|
|
1073
817
|
return;
|
|
1074
818
|
}
|
|
1075
819
|
const viaCall = heritageCall(node);
|
|
1076
|
-
const callback = viaCall?.arguments.find((arg) =>
|
|
1077
|
-
if (callback && (
|
|
820
|
+
const callback = viaCall?.arguments.find((arg) => ts4.isArrowFunction(arg) || ts4.isFunctionExpression(arg));
|
|
821
|
+
if (callback && (ts4.isArrowFunction(callback) || ts4.isFunctionExpression(callback))) {
|
|
1078
822
|
builderName = nodeName(callback.parameters[0]?.name);
|
|
1079
823
|
}
|
|
1080
824
|
};
|
|
1081
|
-
|
|
825
|
+
ts4.forEachChild(source, visit);
|
|
1082
826
|
return builderName;
|
|
1083
827
|
};
|
|
1084
828
|
var inspectConstantStructure = (content, className, moduleClassName) => {
|
|
@@ -1089,12 +833,12 @@ var inspectConstantStructure = (content, className, moduleClassName) => {
|
|
|
1089
833
|
const fields = [];
|
|
1090
834
|
if (inputObject) {
|
|
1091
835
|
const visit = (node) => {
|
|
1092
|
-
if (!
|
|
1093
|
-
|
|
836
|
+
if (!ts4.isClassDeclaration(node) || node.name?.text !== className) {
|
|
837
|
+
ts4.forEachChild(node, visit);
|
|
1094
838
|
return;
|
|
1095
839
|
}
|
|
1096
840
|
const viaCall = heritageCall(node);
|
|
1097
|
-
const callback = viaCall?.arguments.find((arg) =>
|
|
841
|
+
const callback = viaCall?.arguments.find((arg) => ts4.isArrowFunction(arg) || ts4.isFunctionExpression(arg));
|
|
1098
842
|
const objectLiteral = callback ? firstObjectReturnedByArrow(callback) : null;
|
|
1099
843
|
if (!objectLiteral)
|
|
1100
844
|
return;
|
|
@@ -1105,7 +849,7 @@ var inspectConstantStructure = (content, className, moduleClassName) => {
|
|
|
1105
849
|
return { name, expressionBuilder: fieldExpressionBuilder(property) };
|
|
1106
850
|
}).filter((field) => field !== null));
|
|
1107
851
|
};
|
|
1108
|
-
|
|
852
|
+
ts4.forEachChild(source, visit);
|
|
1109
853
|
}
|
|
1110
854
|
return {
|
|
1111
855
|
parseValid: !hasParseDiagnostics(source),
|
|
@@ -1116,17 +860,6 @@ var inspectConstantStructure = (content, className, moduleClassName) => {
|
|
|
1116
860
|
baseImports: baseImport?.names ?? []
|
|
1117
861
|
};
|
|
1118
862
|
};
|
|
1119
|
-
var inspectDictionaryStructure = (content, moduleClassName) => {
|
|
1120
|
-
const source = sourceFileFor("dictionary.ts", content);
|
|
1121
|
-
const modelObject = findDictionaryModelObject(source, moduleClassName);
|
|
1122
|
-
return {
|
|
1123
|
-
parseValid: !hasParseDiagnostics(source),
|
|
1124
|
-
modelObjectFound: modelObject !== null,
|
|
1125
|
-
chainOrderValid: modelObject ? dictionaryChainOrderValid(modelObject.chainMethods) : false,
|
|
1126
|
-
chainMethods: modelObject?.chainMethods ?? [],
|
|
1127
|
-
fields: modelObject?.fields.map((field) => field.name) ?? []
|
|
1128
|
-
};
|
|
1129
|
-
};
|
|
1130
863
|
var insertIntoObject = (content, className, line) => {
|
|
1131
864
|
const fieldName = /^([A-Za-z_$][\w$]*)\s*:/.exec(line.trim())?.[1];
|
|
1132
865
|
if (!fieldName)
|
|
@@ -1151,42 +884,6 @@ ${nextFields.map((field) => ` ${JSON.stringify(field)},`).join(`
|
|
|
1151
884
|
] as const`;
|
|
1152
885
|
return spliceText(content, locator.projectionStart, locator.projectionEnd, nextArray);
|
|
1153
886
|
};
|
|
1154
|
-
var insertTemplateField = ({
|
|
1155
|
-
content,
|
|
1156
|
-
moduleName,
|
|
1157
|
-
moduleClassName,
|
|
1158
|
-
fieldName,
|
|
1159
|
-
component
|
|
1160
|
-
}) => {
|
|
1161
|
-
if (content.includes(`l("${moduleName}.${fieldName}")`) || content.includes(`.${fieldName}`))
|
|
1162
|
-
return content;
|
|
1163
|
-
const layoutEndIndex = content.indexOf(" </Layout.Template>");
|
|
1164
|
-
if (layoutEndIndex < 0)
|
|
1165
|
-
return null;
|
|
1166
|
-
const formName = `${moduleName}Form`;
|
|
1167
|
-
if (!content.includes(`const ${formName} = st.use.${moduleName}Form();`))
|
|
1168
|
-
return null;
|
|
1169
|
-
const fieldSetter = `st.do.set${moduleComponentName(fieldName)}On${moduleClassName}`;
|
|
1170
|
-
const fieldBlock = ` <${component}
|
|
1171
|
-
label={l("${moduleName}.${fieldName}")}
|
|
1172
|
-
desc={l("${moduleName}.${fieldName}.desc")}
|
|
1173
|
-
value={${formName}.${fieldName}}
|
|
1174
|
-
onChange={${fieldSetter}}
|
|
1175
|
-
/>
|
|
1176
|
-
`;
|
|
1177
|
-
return `${content.slice(0, layoutEndIndex)}${fieldBlock}${content.slice(layoutEndIndex)}`;
|
|
1178
|
-
};
|
|
1179
|
-
var ensureEnumImport = (content) => {
|
|
1180
|
-
if (content.includes("enumOf"))
|
|
1181
|
-
return content;
|
|
1182
|
-
const baseImport = /import \{ ([^{}]+) \} from "akanjs\/base";/.exec(content);
|
|
1183
|
-
if (baseImport) {
|
|
1184
|
-
const names = baseImport[1]?.split(",").map((name) => name.trim()) ?? [];
|
|
1185
|
-
return content.replace(baseImport[0], `import { ${[...names, "enumOf"].sort().join(", ")} } from "akanjs/base";`);
|
|
1186
|
-
}
|
|
1187
|
-
return `import { enumOf } from "akanjs/base";
|
|
1188
|
-
${content}`;
|
|
1189
|
-
};
|
|
1190
887
|
var insertEnumClass = (content, enumClassName, enumName, values) => {
|
|
1191
888
|
if (content.includes(`export class ${enumClassName} extends enumOf`))
|
|
1192
889
|
return content;
|
|
@@ -1202,6 +899,135 @@ ${values.map((value) => ` ${JSON.stringify(value)},`).join(`
|
|
|
1202
899
|
${enumClass}`;
|
|
1203
900
|
return `${content.slice(0, firstClassIndex)}${enumClass}${content.slice(firstClassIndex)}`;
|
|
1204
901
|
};
|
|
902
|
+
var hasConstantInputField = (content, className, fieldName) => {
|
|
903
|
+
const source = sourceFileFor("constant.ts", content);
|
|
904
|
+
if (hasParseDiagnostics(source))
|
|
905
|
+
return false;
|
|
906
|
+
return findConstantInputObject(source, className)?.fields.some((field) => field.name === fieldName) ?? false;
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
// pkgs/@akanjs/devkit/workflow/dictionarySource.ts
|
|
910
|
+
import ts5 from "typescript";
|
|
911
|
+
|
|
912
|
+
// pkgs/@akanjs/devkit/workflow/fieldLabel.ts
|
|
913
|
+
import { lowerlize as lowerlize2 } from "akanjs/common";
|
|
914
|
+
var titleize = (value) => value.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
|
|
915
|
+
var koLabels = {
|
|
916
|
+
amount: "\uAE08\uC561",
|
|
917
|
+
budget: "\uC608\uC0B0",
|
|
918
|
+
category: "\uCE74\uD14C\uACE0\uB9AC",
|
|
919
|
+
content: "\uB0B4\uC6A9",
|
|
920
|
+
count: "\uAC1C\uC218",
|
|
921
|
+
createdAt: "\uC0DD\uC131\uC77C",
|
|
922
|
+
date: "\uB0A0\uC9DC",
|
|
923
|
+
description: "\uC124\uBA85",
|
|
924
|
+
due: "\uB9C8\uAC10\uC77C",
|
|
925
|
+
dueAt: "\uB9C8\uAC10\uC77C",
|
|
926
|
+
email: "\uC774\uBA54\uC77C",
|
|
927
|
+
enabled: "\uD65C\uC131\uD654",
|
|
928
|
+
endAt: "\uC885\uB8CC\uC77C",
|
|
929
|
+
id: "ID",
|
|
930
|
+
name: "\uC774\uB984",
|
|
931
|
+
owner: "\uB2F4\uB2F9\uC790",
|
|
932
|
+
priority: "\uC6B0\uC120\uC21C\uC704",
|
|
933
|
+
project: "\uD504\uB85C\uC81D\uD2B8",
|
|
934
|
+
rating: "\uD3C9\uC810",
|
|
935
|
+
startAt: "\uC2DC\uC791\uC77C",
|
|
936
|
+
status: "\uC0C1\uD0DC",
|
|
937
|
+
title: "\uC81C\uBAA9",
|
|
938
|
+
updatedAt: "\uC218\uC815\uC77C"
|
|
939
|
+
};
|
|
940
|
+
var splitFieldWords = (fieldName) => fieldName.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").split(/\s+/).map((word) => word.trim()).filter(Boolean);
|
|
941
|
+
var koLabelForField = (fieldName) => {
|
|
942
|
+
if (koLabels[fieldName])
|
|
943
|
+
return koLabels[fieldName];
|
|
944
|
+
const words = splitFieldWords(fieldName);
|
|
945
|
+
const translated = words.map((word) => koLabels[word] ?? koLabels[lowerlize2(word)] ?? null);
|
|
946
|
+
return translated.every(Boolean) ? translated.join(" ") : null;
|
|
947
|
+
};
|
|
948
|
+
var bilingualLabelForField = (fieldName) => {
|
|
949
|
+
const en = titleize(fieldName);
|
|
950
|
+
return { en, ko: koLabelForField(fieldName) ?? en };
|
|
951
|
+
};
|
|
952
|
+
var bilingualDescriptionForField = (fieldName) => {
|
|
953
|
+
const label = bilingualLabelForField(fieldName);
|
|
954
|
+
return {
|
|
955
|
+
en: `Enter ${label.en.toLowerCase()}.`,
|
|
956
|
+
ko: `${label.ko} \uAC12\uC744 \uC785\uB825\uD569\uB2C8\uB2E4.`
|
|
957
|
+
};
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
// pkgs/@akanjs/devkit/workflow/dictionarySource.ts
|
|
961
|
+
var chainMethodsForCall = (node) => {
|
|
962
|
+
if (ts5.isAsExpression(node) || ts5.isParenthesizedExpression(node))
|
|
963
|
+
return chainMethodsForCall(node.expression);
|
|
964
|
+
if (!ts5.isCallExpression(node))
|
|
965
|
+
return [];
|
|
966
|
+
if (ts5.isPropertyAccessExpression(node.expression)) {
|
|
967
|
+
return [...chainMethodsForCall(node.expression.expression), node.expression.name.text];
|
|
968
|
+
}
|
|
969
|
+
const name = expressionName(node.expression);
|
|
970
|
+
return name ? [name] : [];
|
|
971
|
+
};
|
|
972
|
+
var outermostFluentCall = (node) => {
|
|
973
|
+
let current = node;
|
|
974
|
+
while (ts5.isPropertyAccessExpression(current.parent) && current.parent.expression === current && ts5.isCallExpression(current.parent.parent) && current.parent.parent.expression === current.parent) {
|
|
975
|
+
current = current.parent.parent;
|
|
976
|
+
}
|
|
977
|
+
return current;
|
|
978
|
+
};
|
|
979
|
+
var protectedDictionaryChainOrder = ["model", "slice", "enum", "error", "translate"];
|
|
980
|
+
var dictionaryChainOrderValid = (chainMethods) => {
|
|
981
|
+
const protectedOrder = new Map(protectedDictionaryChainOrder.map((method, index) => [method, index]));
|
|
982
|
+
let lastOrder = -1;
|
|
983
|
+
for (const method of chainMethods) {
|
|
984
|
+
const order = protectedOrder.get(method);
|
|
985
|
+
if (order === undefined)
|
|
986
|
+
continue;
|
|
987
|
+
if (order < lastOrder)
|
|
988
|
+
return false;
|
|
989
|
+
lastOrder = order;
|
|
990
|
+
}
|
|
991
|
+
return true;
|
|
992
|
+
};
|
|
993
|
+
var findDictionaryModelObject = (source, moduleClassName) => findDictionaryStageObject(source, "model", moduleClassName);
|
|
994
|
+
var findDictionaryStageObject = (source, stage, typeName) => {
|
|
995
|
+
let locator = null;
|
|
996
|
+
const visit = (node) => {
|
|
997
|
+
if (locator)
|
|
998
|
+
return;
|
|
999
|
+
if (!ts5.isCallExpression(node) || callExpressionName(node) !== stage) {
|
|
1000
|
+
ts5.forEachChild(node, visit);
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
const typeArgument = node.typeArguments?.[0];
|
|
1004
|
+
if (!typeArgument || typeArgument.getText(source) !== typeName) {
|
|
1005
|
+
ts5.forEachChild(node, visit);
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
const callback = node.arguments.find((arg) => ts5.isArrowFunction(arg) || ts5.isFunctionExpression(arg));
|
|
1009
|
+
const objectLiteral = callback ? firstObjectReturnedByArrow(callback) : null;
|
|
1010
|
+
if (objectLiteral) {
|
|
1011
|
+
locator = {
|
|
1012
|
+
...locatedObject(source, objectLiteral),
|
|
1013
|
+
chainMethods: chainMethodsForCall(outermostFluentCall(node))
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
ts5.forEachChild(source, visit);
|
|
1018
|
+
return locator;
|
|
1019
|
+
};
|
|
1020
|
+
var inspectDictionaryStructure = (content, moduleClassName) => {
|
|
1021
|
+
const source = sourceFileFor("dictionary.ts", content);
|
|
1022
|
+
const modelObject = findDictionaryModelObject(source, moduleClassName);
|
|
1023
|
+
return {
|
|
1024
|
+
parseValid: !hasParseDiagnostics(source),
|
|
1025
|
+
modelObjectFound: modelObject !== null,
|
|
1026
|
+
chainOrderValid: modelObject ? dictionaryChainOrderValid(modelObject.chainMethods) : false,
|
|
1027
|
+
chainMethods: modelObject?.chainMethods ?? [],
|
|
1028
|
+
fields: modelObject?.fields.map((field) => field.name) ?? []
|
|
1029
|
+
};
|
|
1030
|
+
};
|
|
1205
1031
|
var dictionaryModelFieldLine = (fieldName) => {
|
|
1206
1032
|
const label = bilingualLabelForField(fieldName);
|
|
1207
1033
|
const desc = bilingualDescriptionForField(fieldName);
|
|
@@ -1217,12 +1043,6 @@ var insertDictionaryModelField = (content, moduleClassName, fieldName) => {
|
|
|
1217
1043
|
closingIndent: " "
|
|
1218
1044
|
});
|
|
1219
1045
|
};
|
|
1220
|
-
var hasConstantInputField = (content, className, fieldName) => {
|
|
1221
|
-
const source = sourceFileFor("constant.ts", content);
|
|
1222
|
-
if (hasParseDiagnostics(source))
|
|
1223
|
-
return false;
|
|
1224
|
-
return findConstantInputObject(source, className)?.fields.some((field) => field.name === fieldName) ?? false;
|
|
1225
|
-
};
|
|
1226
1046
|
var hasDictionaryModelField = (content, moduleClassName, fieldName) => {
|
|
1227
1047
|
const source = sourceFileFor("dictionary.ts", content);
|
|
1228
1048
|
if (hasParseDiagnostics(source))
|
|
@@ -1240,28 +1060,16 @@ var insertDictionaryEndpointEntry = (content, moduleClassName, entryName, entryT
|
|
|
1240
1060
|
return null;
|
|
1241
1061
|
return insertOrderedFieldLine(content, locator, entryName, entryText, { fieldIndent: " ", closingIndent: " " });
|
|
1242
1062
|
};
|
|
1243
|
-
var ensureConstantTypeImport = (content, constantPath, typeName) => {
|
|
1244
|
-
if (new RegExp(`import type \\{[^}]*\\b${typeName}\\b[^}]*\\} from "${constantPath}";`).test(content))
|
|
1245
|
-
return content;
|
|
1246
|
-
const importPattern = new RegExp(`import type \\{ ([^}]+) \\} from "${constantPath}";`);
|
|
1247
|
-
const existingImport = content.match(importPattern);
|
|
1248
|
-
if (existingImport !== null) {
|
|
1249
|
-
const names = existingImport[1]?.split(",").map((name) => name.trim()) ?? [];
|
|
1250
|
-
return content.replace(existingImport[0], `import type { ${[...names, typeName].sort().join(", ")} } from "${constantPath}";`);
|
|
1251
|
-
}
|
|
1252
|
-
return `import type { ${typeName} } from "${constantPath}";
|
|
1253
|
-
${content}`;
|
|
1254
|
-
};
|
|
1255
1063
|
var dictionaryChainOf = (node) => {
|
|
1256
|
-
if (
|
|
1064
|
+
if (ts5.isCallExpression(node) && outermostFluentCall(node) === node && protectedDictionaryChainOrder.some((method) => chainMethodsForCall(node).includes(method)))
|
|
1257
1065
|
return node;
|
|
1258
|
-
return
|
|
1066
|
+
return ts5.forEachChild(node, dictionaryChainOf);
|
|
1259
1067
|
};
|
|
1260
1068
|
var chainMethodNames = (call) => {
|
|
1261
|
-
if (!
|
|
1069
|
+
if (!ts5.isCallExpression(call) || !ts5.isPropertyAccessExpression(call.expression))
|
|
1262
1070
|
return [];
|
|
1263
1071
|
const name = call.expression.name;
|
|
1264
|
-
return [...chainMethodNames(call.expression.expression), ...
|
|
1072
|
+
return [...chainMethodNames(call.expression.expression), ...ts5.isIdentifier(name) ? [name] : []];
|
|
1265
1073
|
};
|
|
1266
1074
|
var insertDictionaryEnum = (content, enumClassName, enumName, values) => {
|
|
1267
1075
|
if (content.includes(`.enum<${enumClassName}>("${enumName}"`))
|
|
@@ -1288,152 +1096,171 @@ ${enumBlock.trimEnd()}`);
|
|
|
1288
1096
|
return spliceText(content, dot, dot, `
|
|
1289
1097
|
${enumBlock}`);
|
|
1290
1098
|
};
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
var
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1099
|
+
|
|
1100
|
+
// pkgs/@akanjs/devkit/workflow/fieldExpression.ts
|
|
1101
|
+
var normalizeFieldType = (typeName) => {
|
|
1102
|
+
const normalizedTypes = {
|
|
1103
|
+
string: "String",
|
|
1104
|
+
boolean: "Boolean",
|
|
1105
|
+
date: "Date",
|
|
1106
|
+
int: "Int",
|
|
1107
|
+
integer: "Int",
|
|
1108
|
+
float: "Float",
|
|
1109
|
+
double: "Float",
|
|
1110
|
+
decimal: "Float"
|
|
1303
1111
|
};
|
|
1304
|
-
|
|
1305
|
-
return found;
|
|
1306
|
-
};
|
|
1307
|
-
var firstHeritageCall = (node) => {
|
|
1308
|
-
const expression = (node.heritageClauses?.flatMap((clause) => [...clause.types]) ?? [])[0]?.expression;
|
|
1309
|
-
return expression && ts2.isCallExpression(expression) ? expression : null;
|
|
1310
|
-
};
|
|
1311
|
-
var factoryArrowOf = (call) => {
|
|
1312
|
-
const arg = call.arguments.find((argument) => ts2.isArrowFunction(argument) || ts2.isFunctionExpression(argument));
|
|
1313
|
-
return arg && (ts2.isArrowFunction(arg) || ts2.isFunctionExpression(arg)) ? arg : null;
|
|
1314
|
-
};
|
|
1315
|
-
var hasClassMethod = (content, className, methodName) => {
|
|
1316
|
-
const node = findClassDeclaration(sourceFileFor("service.ts", content), className);
|
|
1317
|
-
return Boolean(node?.members.some((member) => ts2.isMethodDeclaration(member) && nodeName(member.name) === methodName));
|
|
1318
|
-
};
|
|
1319
|
-
var classMethodParameters = (content, className, methodName) => {
|
|
1320
|
-
const source = sourceFileFor("service.ts", content);
|
|
1321
|
-
const method = findClassDeclaration(source, className)?.members.find((member) => ts2.isMethodDeclaration(member) && nodeName(member.name) === methodName);
|
|
1322
|
-
return method?.parameters.map((parameter) => ({
|
|
1323
|
-
name: nodeName(parameter.name),
|
|
1324
|
-
optional: !!parameter.questionToken || !!parameter.initializer || !!parameter.dotDotDotToken
|
|
1325
|
-
})) ?? null;
|
|
1326
|
-
};
|
|
1327
|
-
var insertClassMethod = (content, className, methodBlock) => {
|
|
1328
|
-
const source = sourceFileFor("service.ts", content);
|
|
1329
|
-
const node = findClassDeclaration(source, className);
|
|
1330
|
-
if (!node)
|
|
1331
|
-
return null;
|
|
1332
|
-
const closeBrace = node.getEnd() - 1;
|
|
1333
|
-
if (content[closeBrace] !== "}")
|
|
1334
|
-
return null;
|
|
1335
|
-
const lead = content.slice(0, closeBrace).endsWith(`
|
|
1336
|
-
`) ? "" : `
|
|
1337
|
-
`;
|
|
1338
|
-
return spliceText(content, closeBrace, closeBrace, `${lead}${methodBlock}
|
|
1339
|
-
`);
|
|
1112
|
+
return normalizedTypes[typeName.toLowerCase()] ?? typeName;
|
|
1340
1113
|
};
|
|
1341
|
-
var
|
|
1342
|
-
if (
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1114
|
+
var numericDefault = (typeName, rawDefault) => {
|
|
1115
|
+
if (typeof rawDefault === "number") {
|
|
1116
|
+
if (!Number.isFinite(rawDefault))
|
|
1117
|
+
return null;
|
|
1118
|
+
if (typeName === "Int" && !Number.isInteger(rawDefault))
|
|
1119
|
+
return null;
|
|
1120
|
+
return String(rawDefault);
|
|
1347
1121
|
}
|
|
1348
|
-
|
|
1349
|
-
if (open < 0)
|
|
1350
|
-
return null;
|
|
1351
|
-
const close = content.indexOf(")", open);
|
|
1352
|
-
if (close < 0)
|
|
1353
|
-
return null;
|
|
1354
|
-
return { start: open + 1, end: close };
|
|
1355
|
-
};
|
|
1356
|
-
var factoryParamEdit = (content, source, arrow, plan) => {
|
|
1357
|
-
if (arrow.parameters.length > 1)
|
|
1358
|
-
return null;
|
|
1359
|
-
const region = arrowParamInnerRegion(content, source, arrow);
|
|
1360
|
-
if (!region)
|
|
1122
|
+
if (typeof rawDefault !== "string")
|
|
1361
1123
|
return null;
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
}
|
|
1365
|
-
const param = arrow.parameters[0];
|
|
1366
|
-
if (plan.mode === "positional")
|
|
1367
|
-
return nodeName(param.name) === plan.name ? "unchanged" : null;
|
|
1368
|
-
if (!ts2.isObjectBindingPattern(param.name))
|
|
1124
|
+
const trimmed = rawDefault.trim();
|
|
1125
|
+
if (!trimmed || !Number.isFinite(Number(trimmed)))
|
|
1369
1126
|
return null;
|
|
1370
|
-
|
|
1371
|
-
if (names.some((name) => name === null))
|
|
1127
|
+
if (typeName === "Int" && !/^-?\d+$/.test(trimmed))
|
|
1372
1128
|
return null;
|
|
1373
|
-
|
|
1374
|
-
return "unchanged";
|
|
1375
|
-
return {
|
|
1376
|
-
start: param.getStart(source),
|
|
1377
|
-
end: param.getEnd(),
|
|
1378
|
-
text: `{ ${[...names, plan.name].join(", ")} }`
|
|
1379
|
-
};
|
|
1380
|
-
};
|
|
1381
|
-
var factoryObjectOf = (source, className) => {
|
|
1382
|
-
const node = findClassDeclaration(source, className);
|
|
1383
|
-
const call = node ? firstHeritageCall(node) : null;
|
|
1384
|
-
const arrow = call ? factoryArrowOf(call) : null;
|
|
1385
|
-
const object = arrow ? firstObjectReturnedByArrow(arrow) : null;
|
|
1386
|
-
return arrow && object ? { arrow, object } : null;
|
|
1387
|
-
};
|
|
1388
|
-
var hasSignalFactoryEntry = (content, className, entryName) => {
|
|
1389
|
-
const located = factoryObjectOf(sourceFileFor("signal.ts", content), className);
|
|
1390
|
-
return Boolean(located?.object.properties.some((property) => propertyName(property) === entryName));
|
|
1129
|
+
return trimmed;
|
|
1391
1130
|
};
|
|
1392
|
-
var
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
if (
|
|
1131
|
+
var booleanDefault = (rawDefault) => {
|
|
1132
|
+
if (typeof rawDefault === "boolean")
|
|
1133
|
+
return String(rawDefault);
|
|
1134
|
+
if (typeof rawDefault !== "string")
|
|
1396
1135
|
return null;
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
if (
|
|
1136
|
+
const lowered = rawDefault.trim().toLowerCase();
|
|
1137
|
+
return lowered === "true" || lowered === "false" ? lowered : null;
|
|
1138
|
+
};
|
|
1139
|
+
var dateDefault = (rawDefault) => {
|
|
1140
|
+
if (typeof rawDefault === "number" && Number.isFinite(rawDefault))
|
|
1141
|
+
return `() => dayjs(${rawDefault})`;
|
|
1142
|
+
if (typeof rawDefault !== "string")
|
|
1402
1143
|
return null;
|
|
1403
|
-
const
|
|
1404
|
-
|
|
1405
|
-
closingIndent: ""
|
|
1406
|
-
});
|
|
1407
|
-
if (withEntry === content)
|
|
1144
|
+
const trimmed = rawDefault.trim();
|
|
1145
|
+
if (!trimmed)
|
|
1408
1146
|
return null;
|
|
1409
|
-
|
|
1147
|
+
if (trimmed === "now")
|
|
1148
|
+
return "() => dayjs()";
|
|
1149
|
+
if (!Number.isNaN(Date.parse(trimmed)))
|
|
1150
|
+
return `() => dayjs(${JSON.stringify(trimmed)})`;
|
|
1151
|
+
return null;
|
|
1410
1152
|
};
|
|
1411
|
-
var
|
|
1412
|
-
const
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
`)}
|
|
1153
|
+
var coerceFieldDefault = (typeName, defaultValue, options = {}) => {
|
|
1154
|
+
const normalizedType = typeName.toLowerCase() === "enum" ? "enum" : normalizeFieldType(typeName);
|
|
1155
|
+
if (defaultValue === undefined || defaultValue === null || defaultValue === "") {
|
|
1156
|
+
return { expression: null, normalized: false, normalizedType };
|
|
1157
|
+
}
|
|
1158
|
+
if (normalizedType === "Int" || normalizedType === "Float") {
|
|
1159
|
+
const expression = numericDefault(normalizedType, defaultValue);
|
|
1160
|
+
if (expression !== null)
|
|
1161
|
+
return { expression, normalized: typeof defaultValue === "string", normalizedType };
|
|
1162
|
+
return {
|
|
1163
|
+
expression: null,
|
|
1164
|
+
normalized: false,
|
|
1165
|
+
normalizedType,
|
|
1166
|
+
diagnostic: {
|
|
1167
|
+
severity: "error",
|
|
1168
|
+
code: "primitive-default-value-invalid",
|
|
1169
|
+
input: "default",
|
|
1170
|
+
failureScope: "source-change",
|
|
1171
|
+
message: `Default value for ${normalizedType} must be a numeric literal. Received: ${JSON.stringify(defaultValue)}.`
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
if (normalizedType === "Boolean") {
|
|
1176
|
+
const expression = booleanDefault(defaultValue);
|
|
1177
|
+
if (expression !== null)
|
|
1178
|
+
return { expression, normalized: typeof defaultValue === "string", normalizedType };
|
|
1179
|
+
return {
|
|
1180
|
+
expression: null,
|
|
1181
|
+
normalized: false,
|
|
1182
|
+
normalizedType,
|
|
1183
|
+
diagnostic: {
|
|
1184
|
+
severity: "error",
|
|
1185
|
+
code: "primitive-default-value-invalid",
|
|
1186
|
+
input: "default",
|
|
1187
|
+
failureScope: "source-change",
|
|
1188
|
+
message: `Default value for Boolean must be true or false. Received: ${JSON.stringify(defaultValue)}.`
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
if (normalizedType === "Date") {
|
|
1193
|
+
const expression = dateDefault(defaultValue);
|
|
1194
|
+
if (expression !== null)
|
|
1195
|
+
return { expression, normalized: true, normalizedType };
|
|
1196
|
+
return {
|
|
1197
|
+
expression: null,
|
|
1198
|
+
normalized: false,
|
|
1199
|
+
normalizedType,
|
|
1200
|
+
diagnostic: {
|
|
1201
|
+
severity: "error",
|
|
1202
|
+
code: "primitive-default-value-invalid",
|
|
1203
|
+
input: "default",
|
|
1204
|
+
failureScope: "source-change",
|
|
1205
|
+
message: `Default value for Date must be "now", a timestamp, or a parseable date string. Received: ${JSON.stringify(defaultValue)}.`
|
|
1206
|
+
}
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
if (normalizedType === "enum") {
|
|
1210
|
+
if (typeof defaultValue === "string" && options.enumValues?.includes(defaultValue)) {
|
|
1211
|
+
return { expression: JSON.stringify(defaultValue), normalized: false, normalizedType };
|
|
1212
|
+
}
|
|
1213
|
+
return {
|
|
1214
|
+
expression: null,
|
|
1215
|
+
normalized: false,
|
|
1216
|
+
normalizedType,
|
|
1217
|
+
diagnostic: {
|
|
1218
|
+
severity: "error",
|
|
1219
|
+
code: "primitive-default-value-invalid",
|
|
1220
|
+
input: "default",
|
|
1221
|
+
failureScope: "source-change",
|
|
1222
|
+
message: `Default value for enum must be one of: ${(options.enumValues ?? []).join(", ")}. Received: ${JSON.stringify(defaultValue)}.`
|
|
1223
|
+
}
|
|
1224
|
+
};
|
|
1430
1225
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1226
|
+
return {
|
|
1227
|
+
expression: JSON.stringify(String(defaultValue)),
|
|
1228
|
+
normalized: typeof defaultValue !== "string",
|
|
1229
|
+
normalizedType
|
|
1230
|
+
};
|
|
1231
|
+
};
|
|
1232
|
+
var fieldExpression = (typeName, defaultValue, options = {}) => {
|
|
1233
|
+
const typeExpression = normalizeFieldType(typeName);
|
|
1234
|
+
const defaultExpression = coerceFieldDefault(options.enumValues ? "enum" : typeExpression, defaultValue, options).expression;
|
|
1235
|
+
const defaultOption = defaultExpression ? `, { default: ${defaultExpression} }` : "";
|
|
1236
|
+
return `${options.builderName ?? "field"}(${typeExpression}${defaultOption})`;
|
|
1237
|
+
};
|
|
1238
|
+
var parseValues = (value) => value?.split(",").map((item) => item.trim()).filter(Boolean) ?? [];
|
|
1239
|
+
|
|
1240
|
+
// pkgs/@akanjs/devkit/workflow/moduleIndex.ts
|
|
1241
|
+
import { access } from "fs/promises";
|
|
1242
|
+
import path from "path";
|
|
1243
|
+
import ts6 from "typescript";
|
|
1244
|
+
|
|
1245
|
+
// pkgs/@akanjs/devkit/workflow/modulePaths.ts
|
|
1246
|
+
var getSysRoot = (sys) => `${sys.type}s/${sys.name}`;
|
|
1247
|
+
var moduleComponentName = (moduleName) => moduleName.replace(/[-_]+/g, " ").replace(/(?<=^|\s)[a-zA-Z0-9]/g, (char) => char.toUpperCase()).replace(/\s+/g, "");
|
|
1248
|
+
var moduleSourcePaths = (moduleName) => {
|
|
1249
|
+
const componentName = moduleComponentName(moduleName);
|
|
1250
|
+
return {
|
|
1251
|
+
abstract: `lib/${moduleName}/${moduleName}.abstract.md`,
|
|
1252
|
+
constant: `lib/${moduleName}/${moduleName}.constant.ts`,
|
|
1253
|
+
dictionary: `lib/${moduleName}/${moduleName}.dictionary.ts`,
|
|
1254
|
+
document: `lib/${moduleName}/${moduleName}.document.ts`,
|
|
1255
|
+
service: `lib/${moduleName}/${moduleName}.service.ts`,
|
|
1256
|
+
signal: `lib/${moduleName}/${moduleName}.signal.ts`,
|
|
1257
|
+
store: `lib/${moduleName}/${moduleName}.store.ts`,
|
|
1258
|
+
template: `lib/${moduleName}/${componentName}.Template.tsx`,
|
|
1259
|
+
unit: `lib/${moduleName}/${componentName}.Unit.tsx`,
|
|
1260
|
+
util: `lib/${moduleName}/${componentName}.Util.tsx`,
|
|
1261
|
+
view: `lib/${moduleName}/${componentName}.View.tsx`,
|
|
1262
|
+
zone: `lib/${moduleName}/${componentName}.Zone.tsx`
|
|
1263
|
+
};
|
|
1437
1264
|
};
|
|
1438
1265
|
|
|
1439
1266
|
// pkgs/@akanjs/devkit/workflow/moduleIndex.ts
|
|
@@ -1470,7 +1297,7 @@ var parseDiagnosticsFor = (source, filePath) => {
|
|
|
1470
1297
|
return parseDiagnostics.map((diagnostic) => ({
|
|
1471
1298
|
severity: "error",
|
|
1472
1299
|
code: "module-index-typescript-parse-error",
|
|
1473
|
-
message: `TypeScript parse diagnostic TS${diagnostic.code} in ${filePath}: ${
|
|
1300
|
+
message: `TypeScript parse diagnostic TS${diagnostic.code} in ${filePath}: ${ts6.flattenDiagnosticMessageText(diagnostic.messageText, `
|
|
1474
1301
|
`)}`,
|
|
1475
1302
|
context: { target: filePath, paths: [filePath] }
|
|
1476
1303
|
}));
|
|
@@ -1489,32 +1316,32 @@ var spanFor = (source, file, node) => {
|
|
|
1489
1316
|
};
|
|
1490
1317
|
};
|
|
1491
1318
|
var expressionSummary = (expression) => {
|
|
1492
|
-
if (
|
|
1319
|
+
if (ts6.isAsExpression(expression))
|
|
1493
1320
|
return expressionSummary(expression.expression);
|
|
1494
|
-
if (
|
|
1321
|
+
if (ts6.isIdentifier(expression) || ts6.isPropertyAccessExpression(expression))
|
|
1495
1322
|
return expressionName(expression) ?? "expression";
|
|
1496
|
-
if (
|
|
1323
|
+
if (ts6.isArrayLiteralExpression(expression))
|
|
1497
1324
|
return "array-literal";
|
|
1498
|
-
if (
|
|
1325
|
+
if (ts6.isObjectLiteralExpression(expression))
|
|
1499
1326
|
return "object-literal";
|
|
1500
|
-
if (
|
|
1327
|
+
if (ts6.isStringLiteralLike(expression))
|
|
1501
1328
|
return "string-literal";
|
|
1502
|
-
if (
|
|
1329
|
+
if (ts6.isNumericLiteral(expression))
|
|
1503
1330
|
return "numeric-literal";
|
|
1504
|
-
if (expression.kind ===
|
|
1331
|
+
if (expression.kind === ts6.SyntaxKind.TrueKeyword || expression.kind === ts6.SyntaxKind.FalseKeyword) {
|
|
1505
1332
|
return "boolean-literal";
|
|
1506
1333
|
}
|
|
1507
|
-
if (
|
|
1334
|
+
if (ts6.isCallExpression(expression)) {
|
|
1508
1335
|
const callee = expressionName(expression.expression);
|
|
1509
1336
|
return callee ? `${callee}(...)` : "call-expression";
|
|
1510
1337
|
}
|
|
1511
|
-
return
|
|
1338
|
+
return ts6.SyntaxKind[expression.kind] ?? "expression";
|
|
1512
1339
|
};
|
|
1513
1340
|
var typeSummaryForInitializer = (initializer) => {
|
|
1514
1341
|
if (!initializer)
|
|
1515
1342
|
return;
|
|
1516
|
-
const expression =
|
|
1517
|
-
if (!
|
|
1343
|
+
const expression = ts6.isAsExpression(initializer) ? initializer.expression : initializer;
|
|
1344
|
+
if (!ts6.isCallExpression(expression))
|
|
1518
1345
|
return expressionSummary(expression);
|
|
1519
1346
|
const callee = expressionName(expression.expression);
|
|
1520
1347
|
const firstArg = expression.arguments[0];
|
|
@@ -1525,7 +1352,7 @@ var fieldsFromObject = (source, file, objectLiteral, kind) => objectLiteral.prop
|
|
|
1525
1352
|
const name = propertyName(property);
|
|
1526
1353
|
if (!name)
|
|
1527
1354
|
return null;
|
|
1528
|
-
const initializer =
|
|
1355
|
+
const initializer = ts6.isPropertyAssignment(property) ? property.initializer : undefined;
|
|
1529
1356
|
return {
|
|
1530
1357
|
name,
|
|
1531
1358
|
kind,
|
|
@@ -1546,8 +1373,8 @@ var parseConstantIndex = (filePath, content, moduleClassName) => {
|
|
|
1546
1373
|
let fields = [];
|
|
1547
1374
|
let lightProjection;
|
|
1548
1375
|
const visit = (node) => {
|
|
1549
|
-
if (!
|
|
1550
|
-
|
|
1376
|
+
if (!ts6.isClassDeclaration(node) || !node.name) {
|
|
1377
|
+
ts6.forEachChild(node, visit);
|
|
1551
1378
|
return;
|
|
1552
1379
|
}
|
|
1553
1380
|
const className = node.name.text;
|
|
@@ -1557,8 +1384,8 @@ var parseConstantIndex = (filePath, content, moduleClassName) => {
|
|
|
1557
1384
|
if (!viaCall)
|
|
1558
1385
|
return;
|
|
1559
1386
|
inputViaFound = true;
|
|
1560
|
-
const callback = viaCall.arguments.find((arg) =>
|
|
1561
|
-
if (callback && (
|
|
1387
|
+
const callback = viaCall.arguments.find((arg) => ts6.isArrowFunction(arg) || ts6.isFunctionExpression(arg));
|
|
1388
|
+
if (callback && (ts6.isArrowFunction(callback) || ts6.isFunctionExpression(callback))) {
|
|
1562
1389
|
inputBuilderFound = true;
|
|
1563
1390
|
builderName = nodeName(callback.parameters[0]?.name) ?? null;
|
|
1564
1391
|
const objectLiteral = firstObjectReturnedByArrow(callback);
|
|
@@ -1572,15 +1399,15 @@ var parseConstantIndex = (filePath, content, moduleClassName) => {
|
|
|
1572
1399
|
return;
|
|
1573
1400
|
if (className === `Light${moduleClassName}`) {
|
|
1574
1401
|
const projectionArg = viaCall.arguments.find((arg) => {
|
|
1575
|
-
const expression =
|
|
1576
|
-
return
|
|
1402
|
+
const expression = ts6.isAsExpression(arg) ? arg.expression : arg;
|
|
1403
|
+
return ts6.isArrayLiteralExpression(expression);
|
|
1577
1404
|
});
|
|
1578
|
-
const arrayLiteral = projectionArg ?
|
|
1579
|
-
if (arrayLiteral &&
|
|
1405
|
+
const arrayLiteral = projectionArg ? ts6.isAsExpression(projectionArg) ? projectionArg.expression : projectionArg : null;
|
|
1406
|
+
if (arrayLiteral && ts6.isArrayLiteralExpression(arrayLiteral)) {
|
|
1580
1407
|
lightProjection = {
|
|
1581
1408
|
className,
|
|
1582
1409
|
sourceSpan: spanFor(source, filePath, arrayLiteral),
|
|
1583
|
-
fields: arrayLiteral.elements.map((element, order) =>
|
|
1410
|
+
fields: arrayLiteral.elements.map((element, order) => ts6.isStringLiteralLike(element) ? {
|
|
1584
1411
|
name: element.text,
|
|
1585
1412
|
kind: "lightProjection",
|
|
1586
1413
|
order,
|
|
@@ -1591,7 +1418,7 @@ var parseConstantIndex = (filePath, content, moduleClassName) => {
|
|
|
1591
1418
|
}
|
|
1592
1419
|
}
|
|
1593
1420
|
};
|
|
1594
|
-
|
|
1421
|
+
ts6.forEachChild(source, visit);
|
|
1595
1422
|
if (!inputClass) {
|
|
1596
1423
|
diagnostics.push({
|
|
1597
1424
|
severity: "error",
|
|
@@ -1639,22 +1466,22 @@ var parseDictionaryIndex = (filePath, content, moduleClassName) => {
|
|
|
1639
1466
|
let index;
|
|
1640
1467
|
let modelFound = false;
|
|
1641
1468
|
const visit = (node) => {
|
|
1642
|
-
if (modelFound || !
|
|
1643
|
-
|
|
1469
|
+
if (modelFound || !ts6.isCallExpression(node)) {
|
|
1470
|
+
ts6.forEachChild(node, visit);
|
|
1644
1471
|
return;
|
|
1645
1472
|
}
|
|
1646
1473
|
if (callExpressionName(node) !== "model") {
|
|
1647
|
-
|
|
1474
|
+
ts6.forEachChild(node, visit);
|
|
1648
1475
|
return;
|
|
1649
1476
|
}
|
|
1650
1477
|
const typeArgument = node.typeArguments?.[0];
|
|
1651
1478
|
if (!typeArgument || typeArgument.getText(source) !== moduleClassName) {
|
|
1652
|
-
|
|
1479
|
+
ts6.forEachChild(node, visit);
|
|
1653
1480
|
return;
|
|
1654
1481
|
}
|
|
1655
1482
|
modelFound = true;
|
|
1656
|
-
const callback = node.arguments.find((arg) =>
|
|
1657
|
-
if (!callback || !
|
|
1483
|
+
const callback = node.arguments.find((arg) => ts6.isArrowFunction(arg) || ts6.isFunctionExpression(arg));
|
|
1484
|
+
if (!callback || !ts6.isArrowFunction(callback) && !ts6.isFunctionExpression(callback)) {
|
|
1658
1485
|
diagnostics.push({
|
|
1659
1486
|
severity: "error",
|
|
1660
1487
|
code: "module-index-dictionary-builder-missing",
|
|
@@ -1680,7 +1507,7 @@ var parseDictionaryIndex = (filePath, content, moduleClassName) => {
|
|
|
1680
1507
|
sourceSpan: spanFor(source, filePath, node)
|
|
1681
1508
|
};
|
|
1682
1509
|
};
|
|
1683
|
-
|
|
1510
|
+
ts6.forEachChild(source, visit);
|
|
1684
1511
|
return { index, diagnostics, modelFound };
|
|
1685
1512
|
};
|
|
1686
1513
|
var expectedFilesFor = (module) => {
|
|
@@ -1853,9 +1680,9 @@ var postApplyDiagnostic = (code, message, target, severity = "error") => ({
|
|
|
1853
1680
|
});
|
|
1854
1681
|
var sourceKindForPath = (filePath) => {
|
|
1855
1682
|
if (filePath.endsWith(".tsx"))
|
|
1856
|
-
return
|
|
1683
|
+
return ts7.ScriptKind.TSX;
|
|
1857
1684
|
if (filePath.endsWith(".ts"))
|
|
1858
|
-
return
|
|
1685
|
+
return ts7.ScriptKind.TS;
|
|
1859
1686
|
return null;
|
|
1860
1687
|
};
|
|
1861
1688
|
var checkPathCasing = async (workspace, filePath) => {
|
|
@@ -1883,7 +1710,7 @@ var checkTypeScriptSyntax = async (workspace, filePath) => {
|
|
|
1883
1710
|
if (!scriptKind)
|
|
1884
1711
|
return null;
|
|
1885
1712
|
const content = await workspace.readFile(filePath);
|
|
1886
|
-
const source =
|
|
1713
|
+
const source = ts7.createSourceFile(filePath, content, ts7.ScriptTarget.Latest, true, scriptKind);
|
|
1887
1714
|
const diagnostic = (source.parseDiagnostics ?? [])[0];
|
|
1888
1715
|
if (!diagnostic)
|
|
1889
1716
|
return null;
|
|
@@ -1891,7 +1718,7 @@ var checkTypeScriptSyntax = async (workspace, filePath) => {
|
|
|
1891
1718
|
const location = position ? `:${position.line + 1}:${position.character + 1}` : "";
|
|
1892
1719
|
return {
|
|
1893
1720
|
code: "workflow-post-apply-syntax-error",
|
|
1894
|
-
message: `Generated source has a TypeScript syntax error at ${filePath}${location}: ${
|
|
1721
|
+
message: `Generated source has a TypeScript syntax error at ${filePath}${location}: ${ts7.flattenDiagnosticMessageText(diagnostic.messageText, " ")}`
|
|
1895
1722
|
};
|
|
1896
1723
|
};
|
|
1897
1724
|
var checkChangedFile = async (workspace, file) => {
|
|
@@ -2048,9 +1875,9 @@ var resolveWorkflowSys = async (workspace, target) => {
|
|
|
2048
1875
|
return null;
|
|
2049
1876
|
const [apps, libs] = await workspace.getSyss();
|
|
2050
1877
|
if (apps.includes(target))
|
|
2051
|
-
return
|
|
1878
|
+
return AppExecutor2.from(workspace, target);
|
|
2052
1879
|
if (libs.includes(target))
|
|
2053
|
-
return
|
|
1880
|
+
return LibExecutor2.from(workspace, target);
|
|
2054
1881
|
return null;
|
|
2055
1882
|
};
|
|
2056
1883
|
var targetMissing = (input = "app") => ({
|
|
@@ -2311,6 +2138,87 @@ class WorkflowExecutor {
|
|
|
2311
2138
|
return report();
|
|
2312
2139
|
}
|
|
2313
2140
|
}
|
|
2141
|
+
// pkgs/@akanjs/devkit/workflow/fieldType.ts
|
|
2142
|
+
import ts8 from "typescript";
|
|
2143
|
+
var builtInFieldTypes = new Set(["String", "Boolean", "Date", "Map"]);
|
|
2144
|
+
var baseFieldTypes = new Set(["Int", "Float", "ID", "Any", "Binary", "ImageResult"]);
|
|
2145
|
+
var fieldTypeReference = /^\[*([A-Za-z_$][\w$]*)((?:\.[A-Za-z_$][\w$]*)*)\]*$/;
|
|
2146
|
+
var ensureBaseTypeImport = (content, typeName) => {
|
|
2147
|
+
const [, name = "", member] = fieldTypeReference.exec(typeName) ?? [];
|
|
2148
|
+
if (member || !baseFieldTypes.has(name))
|
|
2149
|
+
return content;
|
|
2150
|
+
return ensureBaseImport(content, name);
|
|
2151
|
+
};
|
|
2152
|
+
var valueNamesOf = (content) => {
|
|
2153
|
+
const names = new Set;
|
|
2154
|
+
for (const statement of sourceFileFor("source.ts", content).statements) {
|
|
2155
|
+
if (ts8.isImportDeclaration(statement)) {
|
|
2156
|
+
const clause = statement.importClause;
|
|
2157
|
+
if (!clause || clause.isTypeOnly)
|
|
2158
|
+
continue;
|
|
2159
|
+
if (clause.name)
|
|
2160
|
+
names.add(clause.name.text);
|
|
2161
|
+
const bindings = clause.namedBindings;
|
|
2162
|
+
if (bindings && ts8.isNamespaceImport(bindings))
|
|
2163
|
+
names.add(bindings.name.text);
|
|
2164
|
+
else
|
|
2165
|
+
for (const element of bindings?.elements ?? [])
|
|
2166
|
+
if (!element.isTypeOnly)
|
|
2167
|
+
names.add(element.name.text);
|
|
2168
|
+
} else if (ts8.isVariableStatement(statement)) {
|
|
2169
|
+
for (const declaration of statement.declarationList.declarations)
|
|
2170
|
+
if (ts8.isIdentifier(declaration.name))
|
|
2171
|
+
names.add(declaration.name.text);
|
|
2172
|
+
} else if ((ts8.isClassDeclaration(statement) || ts8.isEnumDeclaration(statement) || ts8.isFunctionDeclaration(statement)) && statement.name)
|
|
2173
|
+
names.add(statement.name.text);
|
|
2174
|
+
}
|
|
2175
|
+
return names;
|
|
2176
|
+
};
|
|
2177
|
+
var fieldTypeSource = async (sys, module, typeName, constantContent) => {
|
|
2178
|
+
const reference = fieldTypeReference.exec(typeName);
|
|
2179
|
+
if (!reference)
|
|
2180
|
+
return {
|
|
2181
|
+
diagnostic: {
|
|
2182
|
+
severity: "error",
|
|
2183
|
+
code: "primitive-field-type-unknown",
|
|
2184
|
+
input: "type",
|
|
2185
|
+
message: `Field type "${typeName}" is not a type name field() takes. Name one type, such as Address, or a list of one, such as [Address], then plan this again.`
|
|
2186
|
+
}
|
|
2187
|
+
};
|
|
2188
|
+
const [, name = "", member] = reference;
|
|
2189
|
+
if (builtInFieldTypes.has(name) || baseFieldTypes.has(name) || valueNamesOf(constantContent).has(name))
|
|
2190
|
+
return {};
|
|
2191
|
+
const [scalars, models] = await Promise.all([sys.getScalarModules(), sys.getDatabaseModules()]);
|
|
2192
|
+
const scalar = member ? undefined : scalars.find((scalarName) => moduleComponentName(scalarName) === name);
|
|
2193
|
+
if (scalar)
|
|
2194
|
+
return { import: { name, from: `../__scalar/${scalar}/${scalar}.constant` } };
|
|
2195
|
+
const model = member ? undefined : models.find((modelName) => moduleComponentName(modelName) === name);
|
|
2196
|
+
if (model)
|
|
2197
|
+
return { import: { name, from: `../${model}/${model}.constant` } };
|
|
2198
|
+
const root = getSysRoot(sys);
|
|
2199
|
+
const constantPath = `${root}/${moduleSourcePaths(module).constant}`;
|
|
2200
|
+
const named = (kind, names) => names.length ? `Its ${kind} are ${names.map(moduleComponentName).join(", ")}.` : `It has no ${kind}.`;
|
|
2201
|
+
return {
|
|
2202
|
+
diagnostic: {
|
|
2203
|
+
severity: "error",
|
|
2204
|
+
code: "primitive-field-type-unknown",
|
|
2205
|
+
input: "type",
|
|
2206
|
+
message: [
|
|
2207
|
+
`Field type "${typeName}" names ${name}, which is not a built-in or akanjs/base type, not imported by ${constantPath}, and not a scalar or model in ${root}.`,
|
|
2208
|
+
named("scalars", scalars),
|
|
2209
|
+
named("models", models),
|
|
2210
|
+
`Create the scalar with the create-scalar workflow first, or import ${name} into ${constantPath}, then plan this again.`
|
|
2211
|
+
].join(" ")
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2214
|
+
};
|
|
2215
|
+
var withFieldTypeImport = async (sys, module, typeName, content, diagnostics) => {
|
|
2216
|
+
const withBaseImport = ensureBaseTypeImport(content, typeName);
|
|
2217
|
+
const source = await fieldTypeSource(sys, module, typeName, withBaseImport);
|
|
2218
|
+
if (source.diagnostic)
|
|
2219
|
+
diagnostics.push(source.diagnostic);
|
|
2220
|
+
return source.import ? ensureNamedImport(withBaseImport, source.import.from, source.import.name) : withBaseImport;
|
|
2221
|
+
};
|
|
2314
2222
|
// pkgs/@akanjs/devkit/workflow/guardCatalog.ts
|
|
2315
2223
|
class GuardCatalog {
|
|
2316
2224
|
static frameworkGuards = ["Public"];
|
|
@@ -2391,7 +2299,7 @@ class GuardCatalog {
|
|
|
2391
2299
|
// pkgs/@akanjs/devkit/workflow/keyRename.ts
|
|
2392
2300
|
import { readFile } from "fs/promises";
|
|
2393
2301
|
import path2 from "path";
|
|
2394
|
-
import
|
|
2302
|
+
import ts9 from "typescript";
|
|
2395
2303
|
var indexedPath = /^(apps|libs)\/(?!(?:.*\/)?(?:node_modules|dist|\.akan)\/).*\.tsx?$/;
|
|
2396
2304
|
var keyPattern = /^[a-z][A-Za-z0-9]*$/;
|
|
2397
2305
|
var slashed = (fileName) => fileName.replace(/\\/g, "/");
|
|
@@ -2420,7 +2328,7 @@ class KeyRename {
|
|
|
2420
2328
|
const sourceRelative = `${getSysRoot(sys)}/${family === "slice" ? paths.signal : paths.document}`;
|
|
2421
2329
|
const sourcePath = slashed(path2.join(root, sourceRelative));
|
|
2422
2330
|
const texts = new Map;
|
|
2423
|
-
const index = new AkanIndex({ ts:
|
|
2331
|
+
const index = new AkanIndex({ ts: ts9, root });
|
|
2424
2332
|
for (const relative of await workspace.getAllFiles("{apps,libs}/**/*.{ts,tsx}")) {
|
|
2425
2333
|
if (!indexedPath.test(slashed(relative)))
|
|
2426
2334
|
continue;
|
|
@@ -2641,6 +2549,138 @@ class MutationSource {
|
|
|
2641
2549
|
}
|
|
2642
2550
|
}
|
|
2643
2551
|
|
|
2552
|
+
// pkgs/@akanjs/devkit/workflow/serviceSource.ts
|
|
2553
|
+
import ts10 from "typescript";
|
|
2554
|
+
var hasClassMethod = (content, className, methodName) => {
|
|
2555
|
+
const node = findClassDeclaration(sourceFileFor("service.ts", content), className);
|
|
2556
|
+
return Boolean(node?.members.some((member) => ts10.isMethodDeclaration(member) && nodeName(member.name) === methodName));
|
|
2557
|
+
};
|
|
2558
|
+
var classMethodParameters = (content, className, methodName) => {
|
|
2559
|
+
const source = sourceFileFor("service.ts", content);
|
|
2560
|
+
const method = findClassDeclaration(source, className)?.members.find((member) => ts10.isMethodDeclaration(member) && nodeName(member.name) === methodName);
|
|
2561
|
+
return method?.parameters.map((parameter) => ({
|
|
2562
|
+
name: nodeName(parameter.name),
|
|
2563
|
+
optional: !!parameter.questionToken || !!parameter.initializer || !!parameter.dotDotDotToken
|
|
2564
|
+
})) ?? null;
|
|
2565
|
+
};
|
|
2566
|
+
var insertClassMethod = (content, className, methodBlock) => {
|
|
2567
|
+
const source = sourceFileFor("service.ts", content);
|
|
2568
|
+
const node = findClassDeclaration(source, className);
|
|
2569
|
+
if (!node)
|
|
2570
|
+
return null;
|
|
2571
|
+
const closeBrace = node.getEnd() - 1;
|
|
2572
|
+
if (content[closeBrace] !== "}")
|
|
2573
|
+
return null;
|
|
2574
|
+
const lead = content.slice(0, closeBrace).endsWith(`
|
|
2575
|
+
`) ? "" : `
|
|
2576
|
+
`;
|
|
2577
|
+
return spliceText(content, closeBrace, closeBrace, `${lead}${methodBlock}
|
|
2578
|
+
`);
|
|
2579
|
+
};
|
|
2580
|
+
|
|
2581
|
+
// pkgs/@akanjs/devkit/workflow/signalSource.ts
|
|
2582
|
+
import ts11 from "typescript";
|
|
2583
|
+
var arrowParamInnerRegion = (content, source, arrow) => {
|
|
2584
|
+
if (arrow.parameters.length > 0) {
|
|
2585
|
+
return {
|
|
2586
|
+
start: arrow.parameters[0].getStart(source),
|
|
2587
|
+
end: arrow.parameters[arrow.parameters.length - 1].getEnd()
|
|
2588
|
+
};
|
|
2589
|
+
}
|
|
2590
|
+
const open = content.indexOf("(", arrow.getStart(source));
|
|
2591
|
+
if (open < 0)
|
|
2592
|
+
return null;
|
|
2593
|
+
const close = content.indexOf(")", open);
|
|
2594
|
+
if (close < 0)
|
|
2595
|
+
return null;
|
|
2596
|
+
return { start: open + 1, end: close };
|
|
2597
|
+
};
|
|
2598
|
+
var factoryParamEdit = (content, source, arrow, plan) => {
|
|
2599
|
+
if (arrow.parameters.length > 1)
|
|
2600
|
+
return null;
|
|
2601
|
+
const region = arrowParamInnerRegion(content, source, arrow);
|
|
2602
|
+
if (!region)
|
|
2603
|
+
return null;
|
|
2604
|
+
if (arrow.parameters.length === 0) {
|
|
2605
|
+
return { ...region, text: plan.mode === "destructure" ? `{ ${plan.name} }` : plan.name };
|
|
2606
|
+
}
|
|
2607
|
+
const param = arrow.parameters[0];
|
|
2608
|
+
if (plan.mode === "positional")
|
|
2609
|
+
return nodeName(param.name) === plan.name ? "unchanged" : null;
|
|
2610
|
+
if (!ts11.isObjectBindingPattern(param.name))
|
|
2611
|
+
return null;
|
|
2612
|
+
const names = param.name.elements.map((element) => ts11.isIdentifier(element.name) ? element.name.text : null);
|
|
2613
|
+
if (names.some((name) => name === null))
|
|
2614
|
+
return null;
|
|
2615
|
+
if (names.includes(plan.name))
|
|
2616
|
+
return "unchanged";
|
|
2617
|
+
return {
|
|
2618
|
+
start: param.getStart(source),
|
|
2619
|
+
end: param.getEnd(),
|
|
2620
|
+
text: `{ ${[...names, plan.name].join(", ")} }`
|
|
2621
|
+
};
|
|
2622
|
+
};
|
|
2623
|
+
var factoryObjectOf = (source, className) => {
|
|
2624
|
+
const node = findClassDeclaration(source, className);
|
|
2625
|
+
const call = node ? firstHeritageCall(node) : null;
|
|
2626
|
+
const arrow = call ? factoryArrowOf(call) : null;
|
|
2627
|
+
const object = arrow ? firstObjectReturnedByArrow(arrow) : null;
|
|
2628
|
+
return arrow && object ? { arrow, object } : null;
|
|
2629
|
+
};
|
|
2630
|
+
var hasSignalFactoryEntry = (content, className, entryName) => {
|
|
2631
|
+
const located = factoryObjectOf(sourceFileFor("signal.ts", content), className);
|
|
2632
|
+
return Boolean(located?.object.properties.some((property) => propertyName(property) === entryName));
|
|
2633
|
+
};
|
|
2634
|
+
var insertSignalFactoryEntry = (content, className, entryName, entryLine, param) => {
|
|
2635
|
+
const source = sourceFileFor("signal.ts", content);
|
|
2636
|
+
const located = factoryObjectOf(source, className);
|
|
2637
|
+
if (!located)
|
|
2638
|
+
return null;
|
|
2639
|
+
const locator = locatedObject(source, located.object);
|
|
2640
|
+
if (locator.fields.some((field) => field.name === entryName))
|
|
2641
|
+
return content;
|
|
2642
|
+
const paramEdit = factoryParamEdit(content, source, located.arrow, param);
|
|
2643
|
+
if (paramEdit === null)
|
|
2644
|
+
return null;
|
|
2645
|
+
const withEntry = insertOrderedFieldLine(content, locator, entryName, entryLine, {
|
|
2646
|
+
fieldIndent: " ",
|
|
2647
|
+
closingIndent: ""
|
|
2648
|
+
});
|
|
2649
|
+
if (withEntry === content)
|
|
2650
|
+
return null;
|
|
2651
|
+
return paramEdit === "unchanged" ? withEntry : spliceText(withEntry, paramEdit.start, paramEdit.end, paramEdit.text);
|
|
2652
|
+
};
|
|
2653
|
+
|
|
2654
|
+
// pkgs/@akanjs/devkit/workflow/testSource.ts
|
|
2655
|
+
import ts12 from "typescript";
|
|
2656
|
+
var appendTopLevelTestCases = (content, describeTitle, render) => {
|
|
2657
|
+
const bunImport = findNamedImport(sourceFileFor("test.ts", content), "bun:test", { valueOnly: true });
|
|
2658
|
+
const itName = !bunImport?.names.includes("it") && bunImport?.names.includes("test") ? "test" : "it";
|
|
2659
|
+
const imported = ensureNamedImport(content, "bun:test", itName);
|
|
2660
|
+
const source = sourceFileFor("test.ts", imported);
|
|
2661
|
+
const body = source.statements.flatMap((statement) => {
|
|
2662
|
+
if (!ts12.isExpressionStatement(statement) || !ts12.isCallExpression(statement.expression))
|
|
2663
|
+
return [];
|
|
2664
|
+
if (expressionName(statement.expression.expression) !== "describe")
|
|
2665
|
+
return [];
|
|
2666
|
+
const callback = factoryArrowOf(statement.expression);
|
|
2667
|
+
return callback && ts12.isBlock(callback.body) ? [callback.body] : [];
|
|
2668
|
+
})[0];
|
|
2669
|
+
if (!body) {
|
|
2670
|
+
const block = [`describe(${JSON.stringify(describeTitle)}, () => {`, ...render(itName, " "), "});", ""];
|
|
2671
|
+
return `${ensureNamedImport(imported, "bun:test", "describe").trimEnd()}
|
|
2672
|
+
|
|
2673
|
+
${block.join(`
|
|
2674
|
+
`)}`;
|
|
2675
|
+
}
|
|
2676
|
+
const firstStatement = body.statements[0];
|
|
2677
|
+
const indent = firstStatement ? lineIndentAt(imported, firstStatement.getStart(source)) : `${lineIndentAt(imported, body.getStart(source))} `;
|
|
2678
|
+
const insertAt = lineStartAt(imported, body.getEnd() - 1);
|
|
2679
|
+
return spliceText(imported, insertAt, insertAt, `${render(itName, indent).join(`
|
|
2680
|
+
`)}
|
|
2681
|
+
`);
|
|
2682
|
+
};
|
|
2683
|
+
|
|
2644
2684
|
// pkgs/@akanjs/devkit/workflow/mutationScaffold.ts
|
|
2645
2685
|
class MutationScaffold {
|
|
2646
2686
|
static #documentMethods = new Set(["isModified", "refresh", "remove", "save", "set", "toJSON", "toObject"]);
|
|
@@ -3015,8 +3055,6 @@ class MutationScaffold {
|
|
|
3015
3055
|
// pkgs/@akanjs/devkit/workflow/plan.ts
|
|
3016
3056
|
import { capitalize as capitalize4 } from "akanjs/common";
|
|
3017
3057
|
var surfaceModes = new Set(["infer", "include", "skip"]);
|
|
3018
|
-
var sysNamePattern = /^[a-z0-9][a-zA-Z0-9_-]*$/;
|
|
3019
|
-
var identifierPattern = /^_{0,2}[a-zA-Z][a-zA-Z0-9_-]*$/;
|
|
3020
3058
|
var nameInputPatterns = {
|
|
3021
3059
|
app: sysNamePattern,
|
|
3022
3060
|
module: identifierPattern,
|
|
@@ -3028,8 +3066,6 @@ var nameInputPatterns = {
|
|
|
3028
3066
|
mutation: identifierPattern,
|
|
3029
3067
|
interaction: identifierPattern
|
|
3030
3068
|
};
|
|
3031
|
-
var isWorkflowSysName = (value) => typeof value === "string" && sysNamePattern.test(value);
|
|
3032
|
-
var isWorkflowModuleName = (value) => typeof value === "string" && identifierPattern.test(value);
|
|
3033
3069
|
var parseStringList = (value) => {
|
|
3034
3070
|
if (Array.isArray(value)) {
|
|
3035
3071
|
const values = value.filter((item) => typeof item === "string" && item.trim().length > 0);
|
|
@@ -3450,6 +3486,12 @@ var moduleNotDatabase = async (sys, spec, module) => {
|
|
|
3450
3486
|
].join(" ")
|
|
3451
3487
|
};
|
|
3452
3488
|
};
|
|
3489
|
+
var fieldTypeUnknown = async (sys, spec, module, type) => {
|
|
3490
|
+
if (spec.name !== "add-field" || !type || ["enum", "number", "numeric", "upload"].includes(type.toLowerCase()))
|
|
3491
|
+
return null;
|
|
3492
|
+
const constant = await sys.readFile(moduleSourcePaths(module).constant);
|
|
3493
|
+
return (await fieldTypeSource(sys, module, normalizeFieldType(type), constant)).diagnostic ?? null;
|
|
3494
|
+
};
|
|
3453
3495
|
var workflowTargetDiagnostics = async (workspace, spec, inputs) => {
|
|
3454
3496
|
const app = planString(inputs, "app");
|
|
3455
3497
|
if (!app)
|
|
@@ -3470,7 +3512,7 @@ var workflowTargetDiagnostics = async (workspace, spec, inputs) => {
|
|
|
3470
3512
|
const moduleSpec = spec.inputs.module;
|
|
3471
3513
|
if (!module || !moduleSpec?.mustExist)
|
|
3472
3514
|
return [];
|
|
3473
|
-
const refused = await moduleMissing(workspace, sys, module) ?? await moduleNotDatabase(sys, spec, module);
|
|
3515
|
+
const refused = await moduleMissing(workspace, sys, module) ?? await moduleNotDatabase(sys, spec, module) ?? await fieldTypeUnknown(sys, spec, module, planString(inputs, "type"));
|
|
3474
3516
|
return refused ? [refused] : [];
|
|
3475
3517
|
};
|
|
3476
3518
|
var inspectPlanTarget = async (workspace, spec, plan) => {
|
|
@@ -3839,4 +3881,76 @@ for (const candidate of toolingRolloutCandidates) {
|
|
|
3839
3881
|
if (isRestrictedCandidate(candidate))
|
|
3840
3882
|
restrictedCandidates.set(candidate.packageName, candidate);
|
|
3841
3883
|
}
|
|
3842
|
-
|
|
3884
|
+
// pkgs/@akanjs/devkit/workflow/primitiveReport.ts
|
|
3885
|
+
var sourceFile = (sys, path, action, reason) => ({
|
|
3886
|
+
path: `${getSysRoot(sys)}/${path}`,
|
|
3887
|
+
action,
|
|
3888
|
+
reason
|
|
3889
|
+
});
|
|
3890
|
+
var generatedFilesForSync = (sys, reason = "Generated files may change after sync.") => generatedFilePathsForTarget(getSysRoot(sys), reason);
|
|
3891
|
+
var validationCommandsForTarget = (target) => [
|
|
3892
|
+
{ command: `akan verify ${target}`, reason: "Sync, lint, typecheck and build the target in one run." }
|
|
3893
|
+
];
|
|
3894
|
+
var nextActionsForTarget = (target) => [
|
|
3895
|
+
{ command: `akan verify ${target}`, reason: "Refresh generated files and validate the target in one run." }
|
|
3896
|
+
];
|
|
3897
|
+
var createPrimitiveWriteReport = ({
|
|
3898
|
+
command,
|
|
3899
|
+
status,
|
|
3900
|
+
changedFiles = [],
|
|
3901
|
+
generatedFiles = [],
|
|
3902
|
+
validationCommands = [],
|
|
3903
|
+
diagnostics = [],
|
|
3904
|
+
nextActions = []
|
|
3905
|
+
}) => ({
|
|
3906
|
+
schemaVersion: 1,
|
|
3907
|
+
command,
|
|
3908
|
+
status: status ?? (diagnostics.some((diagnostic) => diagnostic.severity === "error") ? "failed" : "passed"),
|
|
3909
|
+
changedFiles,
|
|
3910
|
+
generatedFiles,
|
|
3911
|
+
validationCommands,
|
|
3912
|
+
diagnostics,
|
|
3913
|
+
nextActions
|
|
3914
|
+
});
|
|
3915
|
+
var createPassedPrimitiveReport = ({
|
|
3916
|
+
command,
|
|
3917
|
+
changedFiles,
|
|
3918
|
+
generatedFiles,
|
|
3919
|
+
target,
|
|
3920
|
+
nextActions
|
|
3921
|
+
}) => createPrimitiveWriteReport({
|
|
3922
|
+
command,
|
|
3923
|
+
changedFiles,
|
|
3924
|
+
generatedFiles: generatedFiles ?? [],
|
|
3925
|
+
validationCommands: validationCommandsForTarget(target),
|
|
3926
|
+
diagnostics: [],
|
|
3927
|
+
nextActions: nextActions ?? nextActionsForTarget(target)
|
|
3928
|
+
});
|
|
3929
|
+
var scalarChangedFiles = (sys, scalarName, files) => Object.values(files).map((file) => sourceFile(sys, `lib/__scalar/${scalarName}/${file.filename}`, "create", "Scalar source file was created."));
|
|
3930
|
+
// pkgs/@akanjs/devkit/workflow/templateSource.ts
|
|
3931
|
+
var insertTemplateField = ({
|
|
3932
|
+
content,
|
|
3933
|
+
moduleName,
|
|
3934
|
+
moduleClassName,
|
|
3935
|
+
fieldName,
|
|
3936
|
+
component
|
|
3937
|
+
}) => {
|
|
3938
|
+
if (content.includes(`l("${moduleName}.${fieldName}")`) || content.includes(`.${fieldName}`))
|
|
3939
|
+
return content;
|
|
3940
|
+
const layoutEndIndex = content.indexOf(" </Layout.Template>");
|
|
3941
|
+
if (layoutEndIndex < 0)
|
|
3942
|
+
return null;
|
|
3943
|
+
const formName = `${moduleName}Form`;
|
|
3944
|
+
if (!content.includes(`const ${formName} = st.use.${moduleName}Form();`))
|
|
3945
|
+
return null;
|
|
3946
|
+
const fieldSetter = `st.do.set${moduleComponentName(fieldName)}On${moduleClassName}`;
|
|
3947
|
+
const fieldBlock = ` <${component}
|
|
3948
|
+
label={l("${moduleName}.${fieldName}")}
|
|
3949
|
+
desc={l("${moduleName}.${fieldName}.desc")}
|
|
3950
|
+
value={${formName}.${fieldName}}
|
|
3951
|
+
onChange={${fieldSetter}}
|
|
3952
|
+
/>
|
|
3953
|
+
`;
|
|
3954
|
+
return `${content.slice(0, layoutEndIndex)}${fieldBlock}${content.slice(layoutEndIndex)}`;
|
|
3955
|
+
};
|
|
3956
|
+
export { InteractionScaffold, jsonText, workflowStatus, compactDiagnostics, workflowPlanApproval, createWorkflowApplyReport, workflowCommandsForPlan, workflowPathsForPlan, workflowRunArtifactPath, writeWorkflowRunArtifact, workflowSyncDir, generatedFilePathsForTarget, writeGeneratedSyncState, readWorkflowRunArtifact, createWorkflowBaselineSummary, createWorkflowValidationRunReport, createDryRunWorkflowApplyReport, createRepairReport, hasSourceParseErrors, ensureNamedImport, ensureBaseImport, ensureEnumImport, ensureConstantTypeImport, viaBuilderParameterName, insertIntoObject, insertLightProjectionField, insertEnumClass, hasConstantInputField, bilingualLabelForField, bilingualDescriptionForField, insertDictionaryModelField, hasDictionaryModelField, insertDictionaryEnum, normalizeFieldType, coerceFieldDefault, fieldExpression, parseValues, moduleComponentName, moduleSourcePaths, buildAkanModuleContextIndex, addFieldUiPolicyForType, createWorkflowStepRegistry, WorkflowExecutor, withFieldTypeImport, KeyRename, hasClassMethod, insertClassMethod, hasSignalFactoryEntry, insertSignalFactoryEntry, MutationScaffold, listWorkflowSpecs, getWorkflowSpec, compactWorkflowInputs, createWorkflowPlan, workflowTargetDiagnostics, inspectWorkflowPlan, renderWorkflowList, renderWorkflowExplain, renderWorkflowPlan, renderWorkflowApply, renderWorkflowValidation, renderRepairReport, renderWorkflowRunArtifact, renderPrimitiveReport, toolingRolloutGate, sourceFile, generatedFilesForSync, validationCommandsForTarget, nextActionsForTarget, createPrimitiveWriteReport, createPassedPrimitiveReport, scalarChangedFiles, insertTemplateField };
|