@akanjs/devkit 3.2.0-rc.17 → 3.2.0-rc.19

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +74 -5
  2. package/DEV_RUNTIME_KNOBS.md +4 -3
  3. package/akanApp/akanApp.host.test.ts +18 -2
  4. package/akanApp/akanApp.host.wiring.test.ts +723 -0
  5. package/akanApp/devIdleSuspend.test.ts +107 -20
  6. package/akanApp/devIdleSuspend.ts +31 -14
  7. package/akanApp/devIdleSuspend.watcher.test.ts +77 -0
  8. package/apiReport/apiReport.test.ts +29 -0
  9. package/apiReport/apiReportDiff.ts +35 -1
  10. package/app/applicationBuildReporter.ts +2 -49
  11. package/app/routeSourceValidator.test.ts +17 -0
  12. package/app/routeSourceValidator.ts +5 -1
  13. package/artifact/implicitRootLayout.test.ts +67 -3
  14. package/artifact/implicitRootLayout.ts +9 -4
  15. package/artifact/implicitRootLayoutRender.test.tsx +297 -0
  16. package/codeAgent/agent/akanSystemPrompt.ts +1 -1
  17. package/codeAgent/skills/akan-scaffold/SKILL.md +1 -1
  18. package/commandDecorators/command.ts +2 -1
  19. package/commandDecorators/commandBuilder.ts +1 -1
  20. package/commandDecorators/commandDecorators.test.ts +28 -4
  21. package/context/akanContext.ts +20 -527
  22. package/context/akanContextInspection.ts +296 -0
  23. package/context/akanMcpContract.ts +13 -253
  24. package/context/doctor/agentGuideCheck.ts +81 -0
  25. package/context/doctor/configLeftoverCheck.ts +35 -0
  26. package/context/doctor/doctorFindings.ts +70 -0
  27. package/context/doctor/generatedFreshness.ts +56 -0
  28. package/context/doctor/moduleShapeCheck.ts +88 -0
  29. package/context/doctor/recipeDuplicateCheck.ts +39 -0
  30. package/context/doctor/recipeIndexCheck.ts +87 -0
  31. package/context/doctor/rootShapeCheck.ts +55 -0
  32. package/context/doctor/workflowScope.ts +97 -0
  33. package/context/safeRead.ts +9 -0
  34. package/devkitUtils.test.ts +34 -0
  35. package/executors/executors.test.ts +28 -4
  36. package/executors/workspaceExecutor.ts +1 -2
  37. package/frontendBuild/devGeneratedIndexSync.ts +5 -36
  38. package/frontendBuild/hmrWatcher.stop.test.ts +36 -0
  39. package/frontendBuild/hmrWatcher.ts +2 -0
  40. package/frontendBuild/optionalPeers.test.ts +35 -7
  41. package/incrementalBuilder/buildBatch.proc.ts +13 -3
  42. package/incrementalBuilder/buildBatchProtocol.ts +2 -0
  43. package/incrementalBuilder/buildBatchRunner.test.ts +61 -0
  44. package/incrementalBuilder/buildBatchRunner.ts +6 -3
  45. package/incrementalBuilder/builderBoot.ts +106 -0
  46. package/incrementalBuilder/builderBuildStatus.ts +23 -0
  47. package/incrementalBuilder/builderChannel.ts +11 -0
  48. package/incrementalBuilder/builderLanes.ts +157 -0
  49. package/incrementalBuilder/builderWatch.ts +213 -0
  50. package/incrementalBuilder/csrRegistry.ts +234 -0
  51. package/incrementalBuilder/incrementalBuilder.proc.test.ts +92 -1
  52. package/incrementalBuilder/incrementalBuilder.proc.ts +80 -822
  53. package/incrementalBuilder/ssrRegistry.ts +278 -0
  54. package/integration/devStability.integration.test.ts +62 -56
  55. package/package.json +3 -3
  56. package/test/testHelpers.ts +36 -0
  57. package/util/errorReport.ts +66 -0
  58. package/workflow/constantSource.ts +187 -0
  59. package/workflow/dictionarySource.ts +184 -0
  60. package/workflow/executor.ts +5 -8
  61. package/workflow/fieldExpression.ts +153 -0
  62. package/workflow/fieldLabel.ts +61 -0
  63. package/workflow/fieldOrder.ts +117 -0
  64. package/workflow/fieldType.ts +2 -1
  65. package/workflow/keyRename.ts +1 -1
  66. package/workflow/moduleIndex.ts +1 -1
  67. package/workflow/modulePaths.ts +27 -0
  68. package/workflow/mutationScaffold.ts +7 -15
  69. package/workflow/mutationSource.ts +2 -1
  70. package/workflow/plan.ts +2 -1
  71. package/workflow/primitiveReport.ts +78 -0
  72. package/workflow/serviceSource.ts +33 -0
  73. package/workflow/signalSource.ts +96 -0
  74. package/workflow/source.ts +50 -1100
  75. package/workflow/sourceAst.ts +30 -0
  76. package/workflow/sourceImports.ts +105 -0
  77. package/workflow/sourceText.ts +13 -0
  78. package/workflow/templateSource.ts +30 -0
  79. package/workflow/testSource.ts +31 -0
  80. package/workflow/types.ts +1 -1
  81. package/workflow/uiPolicy.ts +1 -1
  82. package/workspace/workspaceLayout.ts +3 -1
@@ -0,0 +1,117 @@
1
+ import ts from "typescript";
2
+ import { propertyName } from "./sourceAst";
3
+ import { lineEndAt, lineIndentAt, lineStartAt, spliceText } from "./sourceText";
4
+
5
+ export const fieldOrderingPriority = [
6
+ "id",
7
+ "name",
8
+ "title",
9
+ "status",
10
+ "category",
11
+ "description",
12
+ "content",
13
+ "startAt",
14
+ "dueAt",
15
+ "endAt",
16
+ "createdAt",
17
+ "updatedAt",
18
+ ] as const;
19
+
20
+ type FieldOrderingName = string;
21
+
22
+ interface LocatedField {
23
+ name: FieldOrderingName;
24
+ start: number;
25
+ fullStart: number;
26
+ end: number;
27
+ }
28
+
29
+ export interface ObjectInsertionLocator {
30
+ objectStart: number;
31
+ objectEnd: number;
32
+ fields: LocatedField[];
33
+ }
34
+
35
+ export const locatedObject = (
36
+ source: ts.SourceFile,
37
+ objectLiteral: ts.ObjectLiteralExpression,
38
+ ): ObjectInsertionLocator => ({
39
+ objectStart: objectLiteral.getStart(source),
40
+ objectEnd: objectLiteral.getEnd(),
41
+ fields: objectLiteral.properties
42
+ .map((property): LocatedField | null => {
43
+ const name = propertyName(property);
44
+ if (!name) return null;
45
+ return {
46
+ name,
47
+ start: property.getStart(source),
48
+ fullStart: property.getFullStart(),
49
+ end: property.getEnd(),
50
+ };
51
+ })
52
+ .filter((field): field is LocatedField => field !== null),
53
+ });
54
+
55
+ const priorityOf = (fieldName: string) => {
56
+ const priority = (fieldOrderingPriority as readonly string[]).indexOf(fieldName);
57
+ return priority < 0 ? null : priority;
58
+ };
59
+
60
+ export const insertionIndexForFieldOrder = (fieldNames: readonly string[], newFieldName: string) => {
61
+ const newPriority = priorityOf(newFieldName);
62
+ if (newPriority !== null) {
63
+ const greaterPriorityIndex = fieldNames.findIndex((name) => {
64
+ const existingPriority = priorityOf(name);
65
+ return existingPriority !== null && existingPriority > newPriority;
66
+ });
67
+ if (greaterPriorityIndex >= 0) return greaterPriorityIndex;
68
+
69
+ const lastPriorityIndex = fieldNames.reduce((lastIndex, name, index) => {
70
+ const existingPriority = priorityOf(name);
71
+ return existingPriority !== null ? index : lastIndex;
72
+ }, -1);
73
+ return lastPriorityIndex + 1;
74
+ }
75
+
76
+ const lastNonPriorityIndex = fieldNames.reduce(
77
+ (lastIndex, name, index) => (priorityOf(name) === null ? index : lastIndex),
78
+ -1,
79
+ );
80
+ return lastNonPriorityIndex >= 0 ? lastNonPriorityIndex + 1 : fieldNames.length;
81
+ };
82
+
83
+ export const insertOrderedFieldLine = (
84
+ content: string,
85
+ locator: ObjectInsertionLocator,
86
+ fieldName: string,
87
+ line: string,
88
+ options: { fieldIndent: string; closingIndent: string },
89
+ ) => {
90
+ if (locator.fields.some((field) => field.name === fieldName)) return content;
91
+ const insertIndex = insertionIndexForFieldOrder(
92
+ locator.fields.map((field) => field.name),
93
+ fieldName,
94
+ );
95
+ const formattedLine = line.trim();
96
+ if (locator.fields.length === 0) {
97
+ return spliceText(
98
+ content,
99
+ locator.objectStart,
100
+ locator.objectEnd,
101
+ `{\n${options.fieldIndent}${formattedLine}\n${options.closingIndent}}`,
102
+ );
103
+ }
104
+
105
+ const beforeField = locator.fields[insertIndex];
106
+ if (beforeField) {
107
+ const leadingComments = ts.getLeadingCommentRanges(content, beforeField.fullStart) ?? [];
108
+ const insertAt = lineStartAt(content, leadingComments[0]?.pos ?? beforeField.start);
109
+ const indent = lineIndentAt(content, beforeField.start) || options.fieldIndent;
110
+ return spliceText(content, insertAt, insertAt, `${indent}${formattedLine}\n`);
111
+ }
112
+
113
+ const afterField = locator.fields[locator.fields.length - 1];
114
+ const insertAt = lineEndAt(content, afterField.end);
115
+ const indent = lineIndentAt(content, afterField.start) || options.fieldIndent;
116
+ return spliceText(content, insertAt, insertAt, `${indent}${formattedLine}\n`);
117
+ };
@@ -1,7 +1,8 @@
1
1
  import ts from "typescript";
2
2
  import type { Sys } from "../commandDecorators";
3
- import { ensureBaseImport, ensureNamedImport, getSysRoot, moduleComponentName, moduleSourcePaths } from "./source";
3
+ import { getSysRoot, moduleComponentName, moduleSourcePaths } from "./modulePaths";
4
4
  import { sourceFileFor } from "./sourceAst";
5
+ import { ensureBaseImport, ensureNamedImport } from "./sourceImports";
5
6
  import type { WorkflowDiagnostic } from "./types";
6
7
 
7
8
  const builtInFieldTypes = new Set(["String", "Boolean", "Date", "Map"]);
@@ -4,7 +4,7 @@ import { AkanIndex, type AkanRenameEdit } from "@akanjs/language";
4
4
  import ts from "typescript";
5
5
  import type { Workspace } from "../commandDecorators";
6
6
  import { resolveWorkflowSys } from "./executor";
7
- import { getSysRoot, moduleSourcePaths } from "./source";
7
+ import { getSysRoot, moduleSourcePaths } from "./modulePaths";
8
8
  import type { RenameKeyInput, ScaffoldFile, WorkflowDiagnostic } from "./types";
9
9
 
10
10
  const indexedPath = /^(apps|libs)\/(?!(?:.*\/)?(?:node_modules|dist|\.akan)\/).*\.tsx?$/;
@@ -3,7 +3,7 @@ import path from "node:path";
3
3
  import ts from "typescript";
4
4
  import type { Workspace } from "../commandDecorators";
5
5
  import type { AkanModuleContext } from "../context/akanContext";
6
- import { moduleComponentName, moduleSourcePaths } from "./source";
6
+ import { moduleComponentName, moduleSourcePaths } from "./modulePaths";
7
7
  import {
8
8
  callExpressionName,
9
9
  expressionName,
@@ -0,0 +1,27 @@
1
+ import type { Sys } from "../commandDecorators";
2
+
3
+ export const getSysRoot = (sys: Sys) => `${sys.type}s/${sys.name}`;
4
+
5
+ export const moduleComponentName = (moduleName: string) =>
6
+ moduleName
7
+ .replace(/[-_]+/g, " ")
8
+ .replace(/(?<=^|\s)[a-zA-Z0-9]/g, (char) => char.toUpperCase())
9
+ .replace(/\s+/g, "");
10
+
11
+ export const moduleSourcePaths = (moduleName: string) => {
12
+ const componentName = moduleComponentName(moduleName);
13
+ return {
14
+ abstract: `lib/${moduleName}/${moduleName}.abstract.md`,
15
+ constant: `lib/${moduleName}/${moduleName}.constant.ts`,
16
+ dictionary: `lib/${moduleName}/${moduleName}.dictionary.ts`,
17
+ document: `lib/${moduleName}/${moduleName}.document.ts`,
18
+ service: `lib/${moduleName}/${moduleName}.service.ts`,
19
+ signal: `lib/${moduleName}/${moduleName}.signal.ts`,
20
+ store: `lib/${moduleName}/${moduleName}.store.ts`,
21
+ template: `lib/${moduleName}/${componentName}.Template.tsx`,
22
+ unit: `lib/${moduleName}/${componentName}.Unit.tsx`,
23
+ util: `lib/${moduleName}/${componentName}.Util.tsx`,
24
+ view: `lib/${moduleName}/${componentName}.View.tsx`,
25
+ zone: `lib/${moduleName}/${componentName}.Zone.tsx`,
26
+ };
27
+ };
@@ -1,22 +1,14 @@
1
1
  import { lowerlize, modelNames } from "akanjs/common";
2
2
  import type { Sys } from "../commandDecorators";
3
+ import { hasDictionaryEndpointEntry, insertDictionaryEndpointEntry } from "./dictionarySource";
3
4
  import { GuardCatalog } from "./guardCatalog";
5
+ import { moduleComponentName, moduleSourcePaths } from "./modulePaths";
4
6
  import { type MutationActingUser, type MutationCall, MutationSource } from "./mutationSource";
5
- import {
6
- appendTopLevelTestCases,
7
- classMethodParameters,
8
- ensureImportDeclaration,
9
- ensureNamedImport,
10
- hasClassMethod,
11
- hasDictionaryEndpointEntry,
12
- hasSignalFactoryEntry,
13
- hasSourceParseErrors,
14
- insertClassMethod,
15
- insertDictionaryEndpointEntry,
16
- insertSignalFactoryEntry,
17
- moduleComponentName,
18
- moduleSourcePaths,
19
- } from "./source";
7
+ import { classMethodParameters, hasClassMethod, insertClassMethod } from "./serviceSource";
8
+ import { hasSignalFactoryEntry, insertSignalFactoryEntry } from "./signalSource";
9
+ import { hasSourceParseErrors } from "./sourceAst";
10
+ import { ensureImportDeclaration, ensureNamedImport } from "./sourceImports";
11
+ import { appendTopLevelTestCases } from "./testSource";
20
12
  import type { ScaffoldFile, WorkflowDiagnostic, WorkflowRecommendation } from "./types";
21
13
 
22
14
  export interface MutationScaffoldInput {
@@ -1,5 +1,6 @@
1
1
  import { lowerlize } from "akanjs/common";
2
- import { bilingualLabelForField, moduleComponentName, titleize } from "./source";
2
+ import { bilingualLabelForField, titleize } from "./fieldLabel";
3
+ import { moduleComponentName } from "./modulePaths";
3
4
 
4
5
  export interface MutationCall {
5
6
  ref: string;
package/workflow/plan.ts CHANGED
@@ -2,12 +2,13 @@ import { capitalize } from "akanjs/common";
2
2
  import type { Sys, Workspace } from "../commandDecorators";
3
3
  import { withoutApplyHints, workflowPlanApproval } from "./artifacts";
4
4
  import { resolveWorkflowSys } from "./executor";
5
+ import { coerceFieldDefault, normalizeFieldType } from "./fieldExpression";
5
6
  import { fieldTypeSource } from "./fieldType";
6
7
  import { InteractionScaffold } from "./interactionScaffold";
7
8
  import { KeyRename } from "./keyRename";
9
+ import { getSysRoot, moduleSourcePaths } from "./modulePaths";
8
10
  import { MutationScaffold } from "./mutationScaffold";
9
11
  import { identifierPattern, sysNamePattern } from "./plainName";
10
- import { coerceFieldDefault, getSysRoot, moduleSourcePaths, normalizeFieldType } from "./source";
11
12
  import type {
12
13
  WorkflowDiagnostic,
13
14
  WorkflowInputSpec,
@@ -0,0 +1,78 @@
1
+ import type { Sys } from "../commandDecorators";
2
+ import { generatedFilePathsForTarget } from "./artifacts";
3
+ import { getSysRoot } from "./modulePaths";
4
+ import type {
5
+ PrimitiveChangedFile,
6
+ PrimitiveFileMap,
7
+ PrimitiveGeneratedFile,
8
+ PrimitiveNextAction,
9
+ PrimitiveValidationCommand,
10
+ PrimitiveWriteReport,
11
+ } from "./types";
12
+
13
+ export const sourceFile = (sys: Sys, path: string, action: PrimitiveChangedFile["action"], reason: string) => ({
14
+ path: `${getSysRoot(sys)}/${path}`,
15
+ action,
16
+ reason,
17
+ });
18
+
19
+ export const generatedFilesForSync = (sys: Sys, reason = "Generated files may change after sync.") =>
20
+ generatedFilePathsForTarget(getSysRoot(sys), reason);
21
+
22
+ export const validationCommandsForTarget = (target: string) =>
23
+ [
24
+ { command: `akan verify ${target}`, reason: "Sync, lint, typecheck and build the target in one run." },
25
+ ] satisfies PrimitiveValidationCommand[];
26
+
27
+ export const nextActionsForTarget = (target: string) =>
28
+ [
29
+ { command: `akan verify ${target}`, reason: "Refresh generated files and validate the target in one run." },
30
+ ] satisfies PrimitiveNextAction[];
31
+
32
+ export const createPrimitiveWriteReport = ({
33
+ command,
34
+ status,
35
+ changedFiles = [],
36
+ generatedFiles = [],
37
+ validationCommands = [],
38
+ diagnostics = [],
39
+ nextActions = [],
40
+ }: Omit<PrimitiveWriteReport, "schemaVersion" | "status"> & {
41
+ status?: PrimitiveWriteReport["status"];
42
+ }): PrimitiveWriteReport => ({
43
+ schemaVersion: 1,
44
+ command,
45
+ status: status ?? (diagnostics.some((diagnostic) => diagnostic.severity === "error") ? "failed" : "passed"),
46
+ changedFiles,
47
+ generatedFiles,
48
+ validationCommands,
49
+ diagnostics,
50
+ nextActions,
51
+ });
52
+
53
+ export const createPassedPrimitiveReport = ({
54
+ command,
55
+ changedFiles,
56
+ generatedFiles,
57
+ target,
58
+ nextActions,
59
+ }: {
60
+ command: string;
61
+ changedFiles: PrimitiveChangedFile[];
62
+ generatedFiles?: PrimitiveGeneratedFile[];
63
+ target: string;
64
+ nextActions?: PrimitiveNextAction[];
65
+ }) =>
66
+ createPrimitiveWriteReport({
67
+ command,
68
+ changedFiles,
69
+ generatedFiles: generatedFiles ?? [],
70
+ validationCommands: validationCommandsForTarget(target),
71
+ diagnostics: [],
72
+ nextActions: nextActions ?? nextActionsForTarget(target),
73
+ });
74
+
75
+ export const scalarChangedFiles = (sys: Sys, scalarName: string, files: PrimitiveFileMap) =>
76
+ Object.values(files).map((file) =>
77
+ sourceFile(sys, `lib/__scalar/${scalarName}/${file.filename}`, "create", "Scalar source file was created."),
78
+ );
@@ -0,0 +1,33 @@
1
+ import ts from "typescript";
2
+ import { findClassDeclaration, nodeName, sourceFileFor } from "./sourceAst";
3
+ import { spliceText } from "./sourceText";
4
+
5
+ export const hasClassMethod = (content: string, className: string, methodName: string) => {
6
+ const node = findClassDeclaration(sourceFileFor("service.ts", content), className);
7
+ return Boolean(
8
+ node?.members.some((member) => ts.isMethodDeclaration(member) && nodeName(member.name) === methodName),
9
+ );
10
+ };
11
+
12
+ export const classMethodParameters = (content: string, className: string, methodName: string) => {
13
+ const source = sourceFileFor("service.ts", content);
14
+ const method = findClassDeclaration(source, className)?.members.find(
15
+ (member): member is ts.MethodDeclaration => ts.isMethodDeclaration(member) && nodeName(member.name) === methodName,
16
+ );
17
+ return (
18
+ method?.parameters.map((parameter) => ({
19
+ name: nodeName(parameter.name),
20
+ optional: !!parameter.questionToken || !!parameter.initializer || !!parameter.dotDotDotToken,
21
+ })) ?? null
22
+ );
23
+ };
24
+
25
+ export const insertClassMethod = (content: string, className: string, methodBlock: string): string | null => {
26
+ const source = sourceFileFor("service.ts", content);
27
+ const node = findClassDeclaration(source, className);
28
+ if (!node) return null;
29
+ const closeBrace = node.getEnd() - 1;
30
+ if (content[closeBrace] !== "}") return null;
31
+ const lead = content.slice(0, closeBrace).endsWith("\n") ? "" : "\n";
32
+ return spliceText(content, closeBrace, closeBrace, `${lead}${methodBlock}\n`);
33
+ };
@@ -0,0 +1,96 @@
1
+ import ts from "typescript";
2
+ import { insertOrderedFieldLine, locatedObject } from "./fieldOrder";
3
+ import {
4
+ factoryArrowOf,
5
+ findClassDeclaration,
6
+ firstHeritageCall,
7
+ firstObjectReturnedByArrow,
8
+ nodeName,
9
+ propertyName,
10
+ sourceFileFor,
11
+ } from "./sourceAst";
12
+ import { spliceText } from "./sourceText";
13
+
14
+ export interface FactoryParamPlan {
15
+ mode: "destructure" | "positional";
16
+ name: string;
17
+ }
18
+
19
+ const arrowParamInnerRegion = (
20
+ content: string,
21
+ source: ts.SourceFile,
22
+ arrow: ts.ArrowFunction | ts.FunctionExpression,
23
+ ) => {
24
+ if (arrow.parameters.length > 0) {
25
+ return {
26
+ start: arrow.parameters[0].getStart(source),
27
+ end: arrow.parameters[arrow.parameters.length - 1].getEnd(),
28
+ };
29
+ }
30
+ const open = content.indexOf("(", arrow.getStart(source));
31
+ if (open < 0) return null;
32
+ const close = content.indexOf(")", open);
33
+ if (close < 0) return null;
34
+ return { start: open + 1, end: close };
35
+ };
36
+
37
+ const factoryParamEdit = (
38
+ content: string,
39
+ source: ts.SourceFile,
40
+ arrow: ts.ArrowFunction | ts.FunctionExpression,
41
+ plan: FactoryParamPlan,
42
+ ): { start: number; end: number; text: string } | "unchanged" | null => {
43
+ if (arrow.parameters.length > 1) return null;
44
+ const region = arrowParamInnerRegion(content, source, arrow);
45
+ if (!region) return null;
46
+ if (arrow.parameters.length === 0) {
47
+ return { ...region, text: plan.mode === "destructure" ? `{ ${plan.name} }` : plan.name };
48
+ }
49
+ const param = arrow.parameters[0];
50
+ if (plan.mode === "positional") return nodeName(param.name) === plan.name ? "unchanged" : null;
51
+ if (!ts.isObjectBindingPattern(param.name)) return null;
52
+ const names = param.name.elements.map((element) => (ts.isIdentifier(element.name) ? element.name.text : null));
53
+ if (names.some((name) => name === null)) return null;
54
+ if (names.includes(plan.name)) return "unchanged";
55
+ return {
56
+ start: param.getStart(source),
57
+ end: param.getEnd(),
58
+ text: `{ ${[...(names as string[]), plan.name].join(", ")} }`,
59
+ };
60
+ };
61
+
62
+ const factoryObjectOf = (source: ts.SourceFile, className: string) => {
63
+ const node = findClassDeclaration(source, className);
64
+ const call = node ? firstHeritageCall(node) : null;
65
+ const arrow = call ? factoryArrowOf(call) : null;
66
+ const object = arrow ? firstObjectReturnedByArrow(arrow) : null;
67
+ return arrow && object ? { arrow, object } : null;
68
+ };
69
+
70
+ export const hasSignalFactoryEntry = (content: string, className: string, entryName: string) => {
71
+ const located = factoryObjectOf(sourceFileFor("signal.ts", content), className);
72
+ return Boolean(located?.object.properties.some((property) => propertyName(property) === entryName));
73
+ };
74
+
75
+ export const insertSignalFactoryEntry = (
76
+ content: string,
77
+ className: string,
78
+ entryName: string,
79
+ entryLine: string,
80
+ param: FactoryParamPlan,
81
+ ): string | null => {
82
+ const source = sourceFileFor("signal.ts", content);
83
+ const located = factoryObjectOf(source, className);
84
+ if (!located) return null;
85
+ const locator = locatedObject(source, located.object);
86
+ if (locator.fields.some((field) => field.name === entryName)) return content;
87
+ // Apply the param edit last: it sits before the object, so applying it first would shift the object's offsets.
88
+ const paramEdit = factoryParamEdit(content, source, located.arrow, param);
89
+ if (paramEdit === null) return null;
90
+ const withEntry = insertOrderedFieldLine(content, locator, entryName, entryLine, {
91
+ fieldIndent: " ",
92
+ closingIndent: "",
93
+ });
94
+ if (withEntry === content) return null;
95
+ return paramEdit === "unchanged" ? withEntry : spliceText(withEntry, paramEdit.start, paramEdit.end, paramEdit.text);
96
+ };