carrick 0.3.156 → 0.3.158

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 (166) hide show
  1. package/dist/cli.d.ts +7 -0
  2. package/dist/cli.js +4 -0
  3. package/dist/cli.js.map +1 -1
  4. package/dist/contract.d.ts +8 -1
  5. package/dist/contract.js.map +1 -1
  6. package/dist/engine-ask.d.ts +21 -0
  7. package/dist/engine-ask.js +50 -0
  8. package/dist/engine-ask.js.map +1 -0
  9. package/dist/facts/diff.d.ts +14 -1
  10. package/dist/facts/diff.js +21 -8
  11. package/dist/facts/diff.js.map +1 -1
  12. package/dist/facts/enabled.d.ts +6 -0
  13. package/dist/facts/enabled.js +8 -0
  14. package/dist/facts/enabled.js.map +1 -1
  15. package/dist/facts/fetch.d.ts +7 -0
  16. package/dist/facts/fetch.js +24 -2
  17. package/dist/facts/fetch.js.map +1 -1
  18. package/dist/facts/lines.d.ts +22 -4
  19. package/dist/facts/lines.js +31 -9
  20. package/dist/facts/lines.js.map +1 -1
  21. package/dist/facts/peers.d.ts +13 -4
  22. package/dist/facts/peers.js +17 -15
  23. package/dist/facts/peers.js.map +1 -1
  24. package/dist/facts/rules/packages.js +3 -1
  25. package/dist/facts/rules/packages.js.map +1 -1
  26. package/dist/facts/rules/same-name.js +1 -1
  27. package/dist/facts/rules/same-name.js.map +1 -1
  28. package/dist/facts/store.d.ts +15 -0
  29. package/dist/facts/store.js +30 -0
  30. package/dist/facts/store.js.map +1 -1
  31. package/dist/held/backoff.d.ts +8 -0
  32. package/dist/held/backoff.js +43 -0
  33. package/dist/held/backoff.js.map +1 -0
  34. package/dist/held/build.d.ts +17 -0
  35. package/dist/held/build.js +62 -0
  36. package/dist/held/build.js.map +1 -0
  37. package/dist/held/client.d.ts +43 -0
  38. package/dist/held/client.js +200 -0
  39. package/dist/held/client.js.map +1 -0
  40. package/dist/held/daemon.d.ts +151 -0
  41. package/dist/held/daemon.js +399 -0
  42. package/dist/held/daemon.js.map +1 -0
  43. package/dist/held/early.d.ts +28 -0
  44. package/dist/held/early.js +115 -0
  45. package/dist/held/early.js.map +1 -0
  46. package/dist/held/engine.d.ts +50 -0
  47. package/dist/held/engine.js +166 -0
  48. package/dist/held/engine.js.map +1 -0
  49. package/dist/held/paths.d.ts +15 -0
  50. package/dist/held/paths.js +44 -0
  51. package/dist/held/paths.js.map +1 -0
  52. package/dist/held/place.d.ts +130 -0
  53. package/dist/held/place.js +236 -0
  54. package/dist/held/place.js.map +1 -0
  55. package/dist/held/registry.d.ts +22 -0
  56. package/dist/held/registry.js +72 -0
  57. package/dist/held/registry.js.map +1 -0
  58. package/dist/held/run.d.ts +2 -0
  59. package/dist/held/run.js +78 -0
  60. package/dist/held/run.js.map +1 -0
  61. package/dist/held/runtime.d.ts +22 -0
  62. package/dist/held/runtime.js +612 -0
  63. package/dist/held/runtime.js.map +1 -0
  64. package/dist/held/shadow.d.ts +33 -0
  65. package/dist/held/shadow.js +68 -0
  66. package/dist/held/shadow.js.map +1 -0
  67. package/dist/held/steps.d.ts +11 -0
  68. package/dist/held/steps.js +29 -0
  69. package/dist/held/steps.js.map +1 -0
  70. package/dist/hook/bash-targets.d.ts +7 -2
  71. package/dist/hook/bash-targets.js +82 -27
  72. package/dist/hook/bash-targets.js.map +1 -1
  73. package/dist/hook/confirm.d.ts +79 -0
  74. package/dist/hook/confirm.js +220 -0
  75. package/dist/hook/confirm.js.map +1 -0
  76. package/dist/hook/edit-flow.d.ts +14 -3
  77. package/dist/hook/edit-flow.js +113 -33
  78. package/dist/hook/edit-flow.js.map +1 -1
  79. package/dist/hook/generation.d.ts +19 -0
  80. package/dist/hook/generation.js +75 -0
  81. package/dist/hook/generation.js.map +1 -0
  82. package/dist/hook/late.d.ts +50 -9
  83. package/dist/hook/late.js +104 -24
  84. package/dist/hook/late.js.map +1 -1
  85. package/dist/hook/lock.d.ts +26 -0
  86. package/dist/hook/lock.js +122 -0
  87. package/dist/hook/lock.js.map +1 -0
  88. package/dist/hook/post-bash.js +17 -8
  89. package/dist/hook/post-bash.js.map +1 -1
  90. package/dist/hook/post-edit.js +2 -2
  91. package/dist/hook/post-edit.js.map +1 -1
  92. package/dist/hook/post-read.js +25 -3
  93. package/dist/hook/post-read.js.map +1 -1
  94. package/dist/hook/post-search.js +1 -1
  95. package/dist/hook/post-search.js.map +1 -1
  96. package/dist/hook/probe.js +1 -0
  97. package/dist/hook/probe.js.map +1 -1
  98. package/dist/hook/read-answer.d.ts +5 -0
  99. package/dist/hook/read-answer.js +8 -4
  100. package/dist/hook/read-answer.js.map +1 -1
  101. package/dist/hook/rechecks.d.ts +59 -2
  102. package/dist/hook/rechecks.js +129 -119
  103. package/dist/hook/rechecks.js.map +1 -1
  104. package/dist/hook/session-start.d.ts +1 -1
  105. package/dist/hook/session-start.js +19 -5
  106. package/dist/hook/session-start.js.map +1 -1
  107. package/dist/hook/similar.d.ts +1 -1
  108. package/dist/hook/similar.js +21 -8
  109. package/dist/hook/similar.js.map +1 -1
  110. package/dist/hook/stop-wait.js +35 -16
  111. package/dist/hook/stop-wait.js.map +1 -1
  112. package/dist/hook/timings.d.ts +30 -2
  113. package/dist/hook/timings.js +8 -2
  114. package/dist/hook/timings.js.map +1 -1
  115. package/dist/hook/user-prompt.js +2 -2
  116. package/dist/hook/user-prompt.js.map +1 -1
  117. package/dist/hosted-snapshot.d.ts +27 -0
  118. package/dist/hosted-snapshot.js +32 -0
  119. package/dist/hosted-snapshot.js.map +1 -1
  120. package/dist/init/hosted.js +2 -9
  121. package/dist/init/hosted.js.map +1 -1
  122. package/dist/lsp-frame.d.ts +20 -0
  123. package/dist/lsp-frame.js +47 -0
  124. package/dist/lsp-frame.js.map +1 -0
  125. package/dist/render.d.ts +15 -1
  126. package/dist/render.js +50 -4
  127. package/dist/render.js.map +1 -1
  128. package/dist/server.js +5 -29
  129. package/dist/server.js.map +1 -1
  130. package/package.json +6 -6
  131. package/plugin/.claude-plugin/plugin.json +1 -1
  132. package/sidecar/dist/src/capture/anchors.d.ts +8 -0
  133. package/sidecar/dist/src/capture/anchors.js +3 -2
  134. package/sidecar/dist/src/capture/api.d.ts +98 -1
  135. package/sidecar/dist/src/capture/check-classify.d.ts +7 -0
  136. package/sidecar/dist/src/capture/check-classify.js +24 -0
  137. package/sidecar/dist/src/capture/check-probe.d.ts +86 -11
  138. package/sidecar/dist/src/capture/check-probe.js +175 -22
  139. package/sidecar/dist/src/capture/check.js +13 -1
  140. package/sidecar/dist/src/capture/graphql-leaves.d.ts +46 -0
  141. package/sidecar/dist/src/capture/graphql-leaves.js +142 -0
  142. package/sidecar/dist/src/capture/index.d.ts +12 -3
  143. package/sidecar/dist/src/capture/index.js +11 -2
  144. package/sidecar/dist/src/capture/result-label.js +3 -1
  145. package/sidecar/dist/src/capture/type-reasons.json +78 -0
  146. package/sidecar/dist/src/definition-resolver.d.ts +6 -5
  147. package/sidecar/dist/src/definition-resolver.js +20 -15
  148. package/sidecar/dist/src/engine-stamp.json +1 -0
  149. package/sidecar/dist/src/held-shadow.d.ts +70 -0
  150. package/sidecar/dist/src/held-shadow.js +222 -0
  151. package/sidecar/dist/src/index.js +65 -2
  152. package/sidecar/dist/src/library-claims.d.ts +3 -1
  153. package/sidecar/dist/src/library-claims.js +105 -6
  154. package/sidecar/dist/src/retype.d.ts +47 -0
  155. package/sidecar/dist/src/retype.js +274 -18
  156. package/sidecar/dist/src/site-find.d.ts +27 -0
  157. package/sidecar/dist/src/site-find.js +109 -0
  158. package/sidecar/dist/src/type-home.d.ts +12 -0
  159. package/sidecar/dist/src/type-home.js +41 -1
  160. package/sidecar/dist/src/type-inferrer.d.ts +13 -3
  161. package/sidecar/dist/src/type-inferrer.js +44 -22
  162. package/sidecar/dist/src/type-structural-expander.d.ts +11 -11
  163. package/sidecar/dist/src/type-structural-expander.js +73 -4
  164. package/sidecar/dist/src/types.d.ts +91 -5
  165. package/sidecar/dist/src/validators.d.ts +621 -254
  166. package/sidecar/dist/src/validators.js +37 -0
@@ -33,7 +33,7 @@ import { callInto, calledFunction, narrowByArguments } from './argument-modes.js
33
33
  import { functionAtLine } from './function-line-index.js';
34
34
  import { attributedDeclaration, installedPackageOf } from './declaration-attribution.js';
35
35
  import { endLineOf, startLineOf } from './line-index.js';
36
- import { declaredTypeName, homeOfTypeDeclaration, isTypeSpaceDeclaration } from './type-home.js';
36
+ import { declaredTypeName, homeOfSchemaValue, homeOfTypeDeclaration, isTypeSpaceDeclaration } from './type-home.js';
37
37
  import { callsOf, descendantsOf, descendantsOnLine, descendantsOnLines, wrap, wrapCompilerNode, } from './node-index.js';
38
38
  import { elapsedMs, inferTiming, phaseClock, timedPhase } from './infer-timing.js';
39
39
  import { importedNameOf, packageNameOf } from './library-claims.js';
@@ -43,7 +43,7 @@ import { bindingToleratesAbsence, handlerToleratesAbsentBody } from './absent-bo
43
43
  import { replaceFileText } from './program-files.js';
44
44
  import { enclosingTypeParameterIn, instantiatedAtCall } from './type-parameters.js';
45
45
  import { endsWithPath, loopElementPick } from './loop-element.js';
46
- import { classifyStatusCodes, httpStatus, statesNoBody, statesNoShape, statusKeyCode, statusTableOf, successEntries, } from './capture/index.js';
46
+ import { classifyStatusCodes, httpStatus, statesNoBody, statesNoShape, statusKeyCode, statusTableOf, successEntries, TYPE_REASONS, } from './capture/index.js';
47
47
  import { addedDiagnostics, applyInsertions, fileDiagnostics, literalInsertions, mapBack, mapForward, normalise, pathOf, } from './unwidened.js';
48
48
  import { expandTypeStructural, jsonWireType, } from './type-structural-expander.js';
49
49
  /**
@@ -160,21 +160,14 @@ const STATUS_MEMBER_NAMES = ['status', 'statusCode'];
160
160
  /** An error or redirect send carries no body the route's contract describes. */
161
161
  const isDroppedResponseStatus = (status) => status === 'error' || status === 'redirect';
162
162
  /**
163
- * The reasons an `unknown` answer is a decision, not a failure to read: the
164
- * list `DECIDED_ABSTAIN_REASONS` in `src/engine/type_compat_v2.rs` holds
165
- * final. A stated reply never replaces one (carrick#2674).
163
+ * The reasons an `unknown` answer is a decision, not a failure to read, on the
164
+ * response path that reads this set: the words `capture/type-reasons.json`
165
+ * marks `always` (carrick#4231). A stated reply never replaces one
166
+ * (carrick#2674).
166
167
  */
167
- export const DECIDED_ABSTAIN_REASONS = new Set([
168
- 'no_success_payload',
169
- 'no_request_body',
170
- 'projected_value_only',
171
- 'serialised_body_unread',
172
- 'body_built_by_callee',
173
- 'result_member_missing',
174
- 'reshaped_by_callback',
175
- 'body_member_undecided',
176
- 'bound_by_callers',
177
- ]);
168
+ export const DECIDED_ABSTAIN_REASONS = new Set(Object.entries(TYPE_REASONS)
169
+ .filter(([, reason]) => reason.decided === 'always')
170
+ .map(([word]) => word));
178
171
  /** The provenance sentence for each reason a branch was not read. */
179
172
  const SERIALISED_BODY_UNREAD_DETAIL = {
180
173
  prebuilt: 'A return hands back a status and body built somewhere else, such as a variable or a field of another result, so the value in its body was not read.',
@@ -1073,15 +1066,19 @@ export class TypeInferrer {
1073
1066
  * published type came from, not a guess at the line.
1074
1067
  */
1075
1068
  locateCall(request) {
1076
- const filePath = path.isAbsolute(request.file_path)
1077
- ? request.file_path
1078
- : path.join(this.repoRoot, request.file_path);
1079
- const sourceFile = this.getSourceFile(filePath);
1069
+ const sourceFile = this.sourceFileOf(request.file_path);
1080
1070
  if (!sourceFile)
1081
1071
  return undefined;
1082
1072
  const call = this.resolveTargetCallExpression(sourceFile, request);
1083
1073
  return call ? { sourceFile, call } : undefined;
1084
1074
  }
1075
+ /**
1076
+ * The source file a locator's `file_path` names (absolute, or relative to
1077
+ * the repo root), added to the project when it is not loaded yet.
1078
+ */
1079
+ sourceFileOf(filePath) {
1080
+ return this.getSourceFile(path.isAbsolute(filePath) ? filePath : path.join(this.repoRoot, filePath));
1081
+ }
1085
1082
  /**
1086
1083
  * Get or add a source file to the project
1087
1084
  */
@@ -8447,7 +8444,10 @@ export class TypeInferrer {
8447
8444
  }
8448
8445
  this.log(`Route registration at ${request.file_path}:${request.line_number} declares its ` +
8449
8446
  'response schema; using the declared contract');
8450
- return this.withReads(this.createInferredType(request, declared.text, true, this.getNodeLocation(registration), undefined, undefined, undefined, undefined, undefined, undefined, declared.type), declared.reads ?? []);
8447
+ const inferred = this.createInferredType(request, declared.text, true, this.getNodeLocation(registration), undefined, undefined, undefined, undefined, undefined, undefined, declared.type);
8448
+ if (declared.home)
8449
+ inferred.type_home = declared.home;
8450
+ return this.withReads(inferred, declared.reads ?? []);
8451
8451
  }
8452
8452
  /**
8453
8453
  * The request contract of a route registration, in anchor order: the
@@ -9261,6 +9261,8 @@ export class TypeInferrer {
9261
9261
  });
9262
9262
  }
9263
9263
  const inferred = this.createInferredType(request, contract.text, true, location, undefined, undefined, undefined, undefined, undefined, undefined, contract.type);
9264
+ if (contract.home)
9265
+ inferred.type_home = contract.home;
9264
9266
  if (contract.provenance && contract.provenance.length > 0) {
9265
9267
  inferred.any_provenance = contract.provenance;
9266
9268
  }
@@ -9669,10 +9671,13 @@ export class TypeInferrer {
9669
9671
  return null;
9670
9672
  }
9671
9673
  const [first] = decided;
9674
+ // carrick#2148 H3: a home only where every deciding schema is the same one.
9675
+ const homes = new Set(decided.map(({ home }) => (home ? `${home.file_path}:${home.line}` : '')));
9672
9676
  return {
9673
9677
  text: first.text,
9674
9678
  type: first.typeNode?.getType(),
9675
9679
  provenance: first.provenance,
9680
+ ...(first.home && homes.size === 1 ? { home: first.home } : {}),
9676
9681
  at: first.at,
9677
9682
  how: first.how,
9678
9683
  typeNode: first.typeNode,
@@ -9687,7 +9692,14 @@ export class TypeInferrer {
9687
9692
  stateAtReceivingCall(call, index, reads, found, stateNode) {
9688
9693
  const contract = this.schemaHandedArgument(call, index);
9689
9694
  if (contract) {
9690
- found.push({ rank: 1, text: contract.text, provenance: contract.provenance, at: call, how: 'a schema it is handed to' });
9695
+ found.push({
9696
+ rank: 1,
9697
+ text: contract.text,
9698
+ provenance: contract.provenance,
9699
+ home: contract.home,
9700
+ at: call,
9701
+ how: 'a schema it is handed to',
9702
+ });
9691
9703
  return;
9692
9704
  }
9693
9705
  const passThrough = this.passThroughFunction(call, index);
@@ -10008,6 +10020,16 @@ export class TypeInferrer {
10008
10020
  * `unknown`.
10009
10021
  */
10010
10022
  schemaContract(value, direction) {
10023
+ const contract = this.schemaContractText(value, direction);
10024
+ if (!contract)
10025
+ return null;
10026
+ const home = homeOfSchemaValue(this.unwrapExpressionNode(value));
10027
+ return home ? { ...contract, home } : contract;
10028
+ }
10029
+ /**
10030
+ * `schemaContract`'s text and provenance, read off the schema's types.
10031
+ */
10032
+ schemaContractText(value, direction) {
10011
10033
  const node = this.unwrapExpressionNode(value);
10012
10034
  let schemaType;
10013
10035
  if (Node.isCallExpression(node)) {
@@ -30,6 +30,8 @@
30
30
  */
31
31
  import { type Node, type Type, ts } from 'ts-morph';
32
32
  import { type ExternalImports } from './origin.js';
33
+ import type { WireFormat } from './types.js';
34
+ import type { GraphqlRoot, GraphqlTypes } from './capture/index.js';
33
35
  /**
34
36
  * Bound on the structural-expansion recursion. Deep enough for every realistic
35
37
  * request/response shape; a backstop against pathological/recursive types the
@@ -63,17 +65,6 @@ export interface MemberOverrides {
63
65
  readonly applied: Set<string>;
64
66
  readonly at: Node;
65
67
  }
66
- /**
67
- * The representation a type is printed in.
68
- *
69
- * `'declared'` prints the type the source declares. `'json'` prints what a
70
- * JSON serialiser puts on the wire for a value of that type (carrick#1163):
71
- * `JSON.stringify` calls a value's `toJSON()` and serialises its RESULT, so a
72
- * `Date` travels as the string its `toJSON` returns, and so does any other
73
- * type that declares one. The mapping is read from the compiler's own
74
- * signature, never from a list of type names.
75
- */
76
- export type WireFormat = 'declared' | 'json';
77
68
  /**
78
69
  * The program the walked type belongs to, and the service root inside it.
79
70
  *
@@ -99,6 +90,15 @@ export interface ExpandOptions {
99
90
  readonly overrides?: MemberOverrides;
100
91
  /** Which representation to print; see `WireFormat`. */
101
92
  readonly wire?: WireFormat;
93
+ /**
94
+ * For `'graphql_scalars'`: the producer service's SDL types and the root
95
+ * field the response answers (carrick#4403). Without a leaf for the root
96
+ * the print is the JSON form.
97
+ */
98
+ readonly graphql?: {
99
+ types: GraphqlTypes;
100
+ root: GraphqlRoot;
101
+ };
102
102
  /**
103
103
  * Where in the recursion the walk starts. Production callers never set it —
104
104
  * depth is walk state — but the `MAX_EXPANSION_DEPTH` backstop is reachable
@@ -32,6 +32,7 @@ import { ts } from 'ts-morph';
32
32
  import { canonicalizeUnionsInText, foldBooleanLiterals, } from './type-text-canonicalizer.js';
33
33
  import { isExternalOrigin } from './origin.js';
34
34
  import { notePrintedType } from './printed-names.js';
35
+ import { graphqlDeclaresType, graphqlFieldLeaf, graphqlRootLeaf, graphqlScalarSent, withoutNonNull, } from './capture/index.js';
35
36
  /**
36
37
  * Bound on the structural-expansion recursion. Deep enough for every realistic
37
38
  * request/response shape; a backstop against pathological/recursive types the
@@ -72,8 +73,67 @@ function childCursor(cursor, segment) {
72
73
  * representation (`WireFormat`).
73
74
  */
74
75
  export function expandTypeStructural(type, origin, options = {}) {
75
- const { overrides, wire = 'declared', depth = 0 } = options;
76
- return expandAt(type, new Set(), depth, overrides ? { overrides, position: '' } : undefined, wire, origin);
76
+ const { overrides, wire = 'declared', depth = 0, graphql } = options;
77
+ return expandAt(type, new Set(), depth, overrides ? { overrides, position: '' } : undefined, wire === 'graphql_scalars'
78
+ ? graphqlWalkFrom(graphql)
79
+ : wire === 'unknown'
80
+ ? 'declared' // an unknown form prints as declared (carrick#4402)
81
+ : wire, origin);
82
+ }
83
+ /** The walk's start for a GraphQL producer response: its root leaf, or JSON. */
84
+ function graphqlWalkFrom(graphql) {
85
+ const leaf = graphql && graphqlRootLeaf(graphql.types, graphql.root);
86
+ return leaf ? { leaf, types: graphql.types } : 'json';
87
+ }
88
+ /**
89
+ * The walk below the member `name` of a value at `wire`: the field's own
90
+ * leaf under a GraphQL object type, JSON for a field the SDL does not name,
91
+ * and `wire` itself everywhere else.
92
+ */
93
+ function memberWalk(wire, name) {
94
+ if (typeof wire !== 'object')
95
+ return wire;
96
+ const leaf = withoutNonNull(wire.leaf);
97
+ if (!('type' in leaf))
98
+ return 'json';
99
+ const field = graphqlFieldLeaf(wire.types, leaf.type, name);
100
+ return field ? { leaf: field, types: wire.types } : 'json';
101
+ }
102
+ /**
103
+ * A value at a GraphQL leaf, printed as the server sends it (carrick#4403),
104
+ * mirroring the probe's `GqlLeafSent`: `null`, `undefined`, `any` and
105
+ * `unknown` stay; a union maps each member; a list maps its elements; a
106
+ * built-in scalar is the type it sends; any other scalar, an enum, a type
107
+ * reference the table does not hold, and a shape the leaf does not describe
108
+ * print in the JSON form. `undefined` means an object type over an object
109
+ * value: the caller walks its members.
110
+ */
111
+ function graphqlLeafText(type, seen, depth, cursor, wire, origin) {
112
+ const leaf = withoutNonNull(wire.leaf);
113
+ const here = { leaf, types: wire.types };
114
+ if (type.isNull() || type.isUndefined() || type.isAny() || type.isUnknown()) {
115
+ return namedText(type);
116
+ }
117
+ if (type.isUnion()) {
118
+ return canonicalMembers(type.getUnionTypes(), seen, depth, cursor, here, origin).join(' | ');
119
+ }
120
+ const json = () => expandAt(type, seen, depth, cursor, 'json', origin);
121
+ if ('list' in leaf) {
122
+ const element = type.isArray() ? type.getArrayElementType() : undefined;
123
+ if (!element)
124
+ return json();
125
+ const inner = expandAt(element, seen, depth + 1, childCursor(cursor, '<0>'), { leaf: leaf.list, types: wire.types }, origin);
126
+ return element.isUnion() || element.isIntersection() ? `(${inner})[]` : `${inner}[]`;
127
+ }
128
+ if ('scalar' in leaf)
129
+ return graphqlScalarSent(leaf.scalar) ?? json();
130
+ if (!('type' in leaf) || !graphqlDeclaresType(wire.types, leaf.type))
131
+ return json();
132
+ if (type.isArray() || isTuple(type))
133
+ return json();
134
+ if (type.getCallSignatures().length > 0)
135
+ return namedText(type);
136
+ return undefined;
77
137
  }
78
138
  /**
79
139
  * The type `JSON.stringify` serialises in place of a value of `type`: the
@@ -120,6 +180,11 @@ function expandAt(type, seen, depth, at, wire, origin) {
120
180
  if (!hasOverrideBelow(cursor))
121
181
  cursor = undefined;
122
182
  }
183
+ if (typeof wire === 'object') {
184
+ const text = graphqlLeafText(type, seen, depth, cursor, wire, origin);
185
+ if (text !== undefined)
186
+ return text;
187
+ }
123
188
  // Primitives & literals: nothing to inline.
124
189
  if (type.isString() ||
125
190
  type.isNumber() ||
@@ -247,7 +312,10 @@ function backstopText(type) {
247
312
  * case the joined output is the same whichever way round they go.
248
313
  */
249
314
  function canonicalMembers(members, seen, depth, cursor, wire, origin) {
250
- return orderMembers(members, (member) => expandAt(member, seen, depth + 1, cursor, wire, origin));
315
+ const texts = orderMembers(members, (member) => expandAt(member, seen, depth + 1, cursor, wire, origin));
316
+ // Under a GraphQL leaf several members can send one type (`bigint |
317
+ // string` under `String`): print it once (carrick#4403).
318
+ return typeof wire === 'object' ? [...new Set(texts)] : texts;
251
319
  }
252
320
  /**
253
321
  * The canonical order itself, over whatever text `render` gives each member.
@@ -268,7 +336,8 @@ function orderMembers(members, render) {
268
336
  return rendered.map((entry) => entry.text);
269
337
  }
270
338
  /** Render a single property as `name[?]: <expanded>`. */
271
- function expandProperty(prop, owner, seen, depth, at, wire, origin) {
339
+ function expandProperty(prop, owner, seen, depth, at, parentWire, origin) {
340
+ const wire = memberWalk(parentWire, prop.getName());
272
341
  const optional = (prop.getFlags() & ts.SymbolFlags.Optional) !== 0;
273
342
  const propDecl = prop.getDeclarations()[0];
274
343
  // Render the key from the declaration's name node so quoted/computed keys
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import type { ResponseModes } from './response-modes.js';
6
6
  import type { ResultLabel } from './capture/api.js';
7
+ import type { ShadowResult } from './held-shadow.js';
7
8
  /**
8
9
  * The kind of type inference to perform
9
10
  */
@@ -294,6 +295,28 @@ export interface ShutdownRequest extends BaseRequest {
294
295
  export interface ListProgramFilesRequest extends BaseRequest {
295
296
  action: 'list_program_files';
296
297
  }
298
+ /**
299
+ * Write the init'd service's program as a shadow tree a held-open TypeScript 7
300
+ * compiler reads (see held-shadow.ts). `out_dir` must lie outside the checkout.
301
+ */
302
+ export interface WriteShadowRequest extends BaseRequest {
303
+ action: 'write_shadow';
304
+ out_dir: string;
305
+ }
306
+ /**
307
+ * Find again, in a file's new text, the node the old text's span `[start, end)`
308
+ * named, with the capture's own exact-text finder (see site-find.ts). `file`
309
+ * only names the file (its extension picks JavaScript or TypeScript syntax);
310
+ * both texts are the caller's, so nothing is read from disk.
311
+ */
312
+ export interface FindSiteRequest extends BaseRequest {
313
+ action: 'find_site';
314
+ file: string;
315
+ oldText: string;
316
+ newText: string;
317
+ start: number;
318
+ end: number;
319
+ }
297
320
  /**
298
321
  * The import graph without statement texts. Every name and path is an index
299
322
  * into `strings`. Per file: its path, whether it is a script, its declared
@@ -438,13 +461,16 @@ export interface ResolveDefinitionsRequest extends BaseRequest {
438
461
  stub_dir: string;
439
462
  /** Surface type aliases to resolve, each with the payload it types. */
440
463
  aliases: DefinitionAlias[];
464
+ /** The service's SDL output types (carrick#4403), when it serves a schema. */
465
+ graphql_types?: import('./capture/api.js').GraphqlTypes;
441
466
  }
442
467
  /**
443
468
  * One surface alias to resolve, and the payload it types: which protocol,
444
469
  * which kind of payload, and which side of the operation the entry is on.
445
470
  * The resolver prints the alias's structural form in JSON wire form exactly
446
- * where the judge compares that form (`sentInJsonWireForm`,
447
- * carrick-cloud#3503): the sending side of an `http` payload. A derived alias
471
+ * where the judge compares that form (`wireFormFor`, carrick-cloud#3503,
472
+ * carrick#4275): the sending side of an `http` payload and a GraphQL producer
473
+ * response. A derived alias
448
474
  * (an unwidened reading, a response-mode case) carries its base entry's facts.
449
475
  */
450
476
  export interface DefinitionAlias {
@@ -458,6 +484,13 @@ export interface DefinitionAlias {
458
484
  * (carrick#4275), so it prints as declared until that is a known fact.
459
485
  */
460
486
  procedure: boolean;
487
+ /**
488
+ * The root field a GraphQL producer response answers (carrick#4403), from
489
+ * its manifest entry. With the request's `graphql_types`, the stored text
490
+ * prints each built-in scalar leaf in the type that scalar sends
491
+ * (`wireFormFor`).
492
+ */
493
+ graphql_root?: import('./capture/api.js').GraphqlRoot;
461
494
  }
462
495
  /**
463
496
  * One consumer call to retype with the producer's response type (carrick#1491).
@@ -486,6 +519,12 @@ export interface RetypeItem extends RetypeLocatorItem {
486
519
  producer_unwidened_type?: string;
487
520
  /** Judge the form JSON puts on the wire (an `http` response). */
488
521
  wire: boolean;
522
+ /**
523
+ * The key path of the procedure the call names (`orders.list`): the call's
524
+ * own type is the router's, so the retype judges the consumer's code
525
+ * against it (carrick#937).
526
+ */
527
+ procedure_path?: string;
489
528
  }
490
529
  /**
491
530
  * Ask, without a producer type, which consumer calls the retype abstains for
@@ -740,6 +779,14 @@ export type LibraryClaim = {
740
779
  kind: 'make';
741
780
  form: 'call' | 'new';
742
781
  member: string | null;
782
+ /**
783
+ * Amendment 12: one maker receiver id the export lists (`instance:new`).
784
+ * The member is read on that receiver's type, as an op's `of` is, and its
785
+ * declared return is the made object. Needs `form: 'call'`, a `member`
786
+ * and a `name` at an argument; `base`, `prefix`, `handler`, `runs`,
787
+ * `protocol` and `result` beside it are `claim_invalid`.
788
+ */
789
+ of?: string;
743
790
  /** An HTTP base URL, or a broker's address. */
744
791
  base?: ClaimSlot;
745
792
  /** A prefix every name the instance sends gets. */
@@ -904,6 +951,13 @@ export interface VerifyLibraryClaimsRequest extends BaseRequest {
904
951
  checks: LibraryCheck[];
905
952
  /** Checks not reached in time come back `unchecked` with reason `budget`; null or absent is the default. */
906
953
  budget_ms?: number | null;
954
+ /**
955
+ * Another service's tsconfig (absolute, or relative to the process's repo
956
+ * root): the checks are judged in a program built from its compiler options
957
+ * with only the probe file, released after the request. Absent: judged in
958
+ * this process's own program (carrick#4472).
959
+ */
960
+ tsconfig_path?: string;
907
961
  }
908
962
  /**
909
963
  * List each package's declared surface the way the verifier reads it
@@ -933,7 +987,7 @@ export interface ListLibrarySurfaceRequest extends BaseRequest {
933
987
  /**
934
988
  * Union type for all possible sidecar requests
935
989
  */
936
- export type SidecarRequest = RetypeCheckRequest | RetypePrescreenRequest | VerifyClientSemanticsRequest | VerifyLibraryClaimsRequest | ListLibrarySurfaceRequest | InitRequest | BundleRequest | CaptureV2Request | CheckV2Request | InferRequest | ResolveDefinitionsRequest | HealthRequest | ShutdownRequest | ListProgramFilesRequest | ReachGraphRequest | ReachRequest | AddProgramFilesRequest | PositionRowsRequest | ImplementationsRequest;
990
+ export type SidecarRequest = RetypeCheckRequest | RetypePrescreenRequest | VerifyClientSemanticsRequest | VerifyLibraryClaimsRequest | ListLibrarySurfaceRequest | InitRequest | BundleRequest | CaptureV2Request | CheckV2Request | InferRequest | ResolveDefinitionsRequest | HealthRequest | ShutdownRequest | ListProgramFilesRequest | WriteShadowRequest | FindSiteRequest | ReachGraphRequest | ReachRequest | AddProgramFilesRequest | PositionRowsRequest | ImplementationsRequest;
937
991
  /**
938
992
  * Request for a specific symbol to be bundled
939
993
  */
@@ -1190,6 +1244,25 @@ export interface ListProgramFilesResponse extends BaseResponse {
1190
1244
  files?: string[];
1191
1245
  errors?: string[];
1192
1246
  }
1247
+ /**
1248
+ * Response for write_shadow action: the fields of `ShadowResult`.
1249
+ */
1250
+ export interface WriteShadowResponse extends BaseResponse, Partial<ShadowResult> {
1251
+ errors?: string[];
1252
+ }
1253
+ /**
1254
+ * Response for find_site action: the node's new bounds (offsets into
1255
+ * `newText`, `start` excluding leading trivia), or the reason there are none.
1256
+ * `value_not_a_node`: no node of the new text fills the slot the old span sat in. `not_wrappable`:
1257
+ * the node is one a call cannot wrap in place (a spread, a shorthand
1258
+ * property's name).
1259
+ */
1260
+ export interface FindSiteResponse extends BaseResponse {
1261
+ start?: number;
1262
+ end?: number;
1263
+ reason?: 'value_not_a_node' | 'not_wrappable';
1264
+ errors?: string[];
1265
+ }
1193
1266
  /**
1194
1267
  * Response for reach_graph action
1195
1268
  */
@@ -1274,7 +1347,7 @@ export interface SemanticsResult {
1274
1347
  verdict: 'verified' | 'failed' | 'unchecked';
1275
1348
  /** Absent exactly when verified. */
1276
1349
  reason?: string;
1277
- /** Verified op verdicts only: the declarations its member resolves to on the receiver. */
1350
+ /** Verified op verdicts, and a verified `of`-make's (amendment 12): the declarations its member resolves to on the receiver. */
1278
1351
  declarations?: SemanticsDeclaration[];
1279
1352
  /**
1280
1353
  * Verified receive op verdicts only: the op verified but its `request`
@@ -1343,6 +1416,12 @@ export interface SurfaceSignature {
1343
1416
  * signature returns nothing.
1344
1417
  */
1345
1418
  result_candidates?: SurfaceResultCandidates;
1419
+ /**
1420
+ * On a `construct` entry only, and only when true: the class it constructs
1421
+ * is abstract, so `new` on it is a type error. Absent otherwise. Part of
1422
+ * the surface hash, so a package that declares one gets a new key.
1423
+ */
1424
+ abstract?: true;
1346
1425
  }
1347
1426
  /** What a signature's return offers as its result, by rule R (`result-candidates.ts`). */
1348
1427
  export interface SurfaceResultCandidates {
@@ -1546,7 +1625,7 @@ export interface ListLibrarySurfaceResponse extends BaseResponse {
1546
1625
  /**
1547
1626
  * Union type for all possible sidecar responses
1548
1627
  */
1549
- export type SidecarResponse = RetypeCheckResponse | RetypePrescreenResponse | VerifyClientSemanticsResponse | VerifyLibraryClaimsResponse | ListLibrarySurfaceResponse | InitResponse | BundleResponse | CaptureV2Response | CheckV2Response | InferResponse | ResolveDefinitionsResponse | HealthResponse | ShutdownResponse | ListProgramFilesResponse | ReachGraphResponse | ReachResponse | AddProgramFilesResponse | PositionRowsResponse | ImplementationsResponse | ErrorResponse;
1628
+ export type SidecarResponse = RetypeCheckResponse | RetypePrescreenResponse | VerifyClientSemanticsResponse | VerifyLibraryClaimsResponse | ListLibrarySurfaceResponse | InitResponse | BundleResponse | CaptureV2Response | CheckV2Response | InferResponse | ResolveDefinitionsResponse | HealthResponse | ShutdownResponse | ListProgramFilesResponse | WriteShadowResponse | FindSiteResponse | ReachGraphResponse | ReachResponse | AddProgramFilesResponse | PositionRowsResponse | ImplementationsResponse | ErrorResponse;
1550
1629
  /**
1551
1630
  * An entry in the type manifest
1552
1631
  */
@@ -1558,6 +1637,11 @@ export interface TypeHome {
1558
1637
  symbol: string;
1559
1638
  file_path: string;
1560
1639
  line: number;
1640
+ /**
1641
+ * carrick#2148 H3: `schema` where the home is the `const` of a schema value
1642
+ * the contract was read off, not a type declaration. Absent for a type.
1643
+ */
1644
+ kind?: 'schema';
1561
1645
  }
1562
1646
  export interface ManifestEntry {
1563
1647
  /** The alias or original name of the type */
@@ -1805,6 +1889,8 @@ export type TypeProvenance = import('./capture/api.js').TypeProvenance;
1805
1889
  /** carrick#1836: declared in the capture bundle, which reads it on a literal anchor. */
1806
1890
  export type PrintedName = import('./capture/api.js').PrintedName;
1807
1891
  export type TypeProvenanceReason = import('./capture/api.js').TypeProvenanceReason;
1892
+ /** carrick#4275: declared in the capture bundle, where `wireFormFor` answers it. */
1893
+ export type WireFormat = import('./capture/api.js').WireFormat;
1808
1894
  /**
1809
1895
  * Source location information for a type
1810
1896
  */