carrick 0.3.153 → 0.3.154
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/dist/contract.d.ts +27 -3
- package/dist/contract.js +8 -0
- package/dist/contract.js.map +1 -1
- package/dist/render.js +20 -7
- package/dist/render.js.map +1 -1
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/scripts/install-scanned-deps.sh +25 -2
- package/sidecar/dist/src/capture/index.d.ts +1 -0
- package/sidecar/dist/src/capture/node-builder.d.ts +6 -0
- package/sidecar/dist/src/default-library.d.ts +39 -0
- package/sidecar/dist/src/default-library.js +132 -0
- package/sidecar/dist/src/definition-resolver.js +2 -0
- package/sidecar/dist/src/index.js +1 -1
- package/sidecar/dist/src/library-claims.d.ts +2 -0
- package/sidecar/dist/src/library-claims.js +176 -17
- package/sidecar/dist/src/position-rows.d.ts +40 -4
- package/sidecar/dist/src/position-rows.js +111 -3
- package/sidecar/dist/src/project-loader.d.ts +3 -3
- package/sidecar/dist/src/project-loader.js +5 -4
- package/sidecar/dist/src/type-inferrer.d.ts +14 -0
- package/sidecar/dist/src/type-inferrer.js +34 -5
- package/sidecar/dist/src/types.d.ts +9 -0
- package/sidecar/dist/src/validators.d.ts +6 -0
- package/sidecar/dist/src/validators.js +1 -0
|
@@ -2664,6 +2664,10 @@ export class TypeInferrer {
|
|
|
2664
2664
|
// machinery. A wrapper rule that DID unwrap the envelope, or a type the
|
|
2665
2665
|
// source itself states, is a contract and keeps its answer.
|
|
2666
2666
|
//
|
|
2667
|
+
// carrick#3741: a one-argument result envelope read only for its own
|
|
2668
|
+
// members (`res.success`, `res.error`) is decided the same way. The site
|
|
2669
|
+
// never reads the payload, and the envelope is not the wire body.
|
|
2670
|
+
//
|
|
2667
2671
|
// A single explicit call generic (`client.get<Order[]>(url)`) is the
|
|
2668
2672
|
// caller's own payload claim and states the contract as plainly as an
|
|
2669
2673
|
// `as` does — it is what the anchor below falls back to on a checkout
|
|
@@ -2675,7 +2679,8 @@ export class TypeInferrer {
|
|
|
2675
2679
|
// engine/type_compat_v2.rs). No anchor and no depth go with it, so the
|
|
2676
2680
|
// row also reads as blind rather than as a sighted answer.
|
|
2677
2681
|
if (use.projectionOnly &&
|
|
2678
|
-
this.projectionReadsGenericPayload(callExpr, use.projections)
|
|
2682
|
+
(this.projectionReadsGenericPayload(callExpr, use.projections) ||
|
|
2683
|
+
this.isOneArgumentEnvelope(callExpr)) &&
|
|
2679
2684
|
!unwrapResult.wasUnwrapped &&
|
|
2680
2685
|
!explicitType &&
|
|
2681
2686
|
!carrierPayload &&
|
|
@@ -3845,6 +3850,26 @@ export class TypeInferrer {
|
|
|
3845
3850
|
return parts.some((part) => argTexts.has(part.getText()));
|
|
3846
3851
|
});
|
|
3847
3852
|
}
|
|
3853
|
+
/**
|
|
3854
|
+
* True when the call answers a ONE-ARGUMENT result envelope: a union whose
|
|
3855
|
+
* branches say whether the call worked and one of which holds the single
|
|
3856
|
+
* type argument as a member (`{ success: true; data: T } | { success: false;
|
|
3857
|
+
* error: string }`), carrick#3741. carrick#1376 needs two arguments to tell
|
|
3858
|
+
* the success side from the failure side; with one there is nothing to tell
|
|
3859
|
+
* apart, and the envelope is the client's bookkeeping around `T`.
|
|
3860
|
+
*
|
|
3861
|
+
* A site that reads only such an envelope's own members (its status, its
|
|
3862
|
+
* error) reads no payload, so the envelope is not a response contract. A
|
|
3863
|
+
* union with no type argument (`{ ok: true } | { ok: false; reason: string }`)
|
|
3864
|
+
* is not an envelope here and keeps its declared answer (carrick#1375).
|
|
3865
|
+
*/
|
|
3866
|
+
isOneArgumentEnvelope(callExpr) {
|
|
3867
|
+
const shape = this.resultCarrierArguments(callExpr.getType(), callExpr, [], 1);
|
|
3868
|
+
if (!shape || shape.readOffCall)
|
|
3869
|
+
return false;
|
|
3870
|
+
const own = [...shape.carrier.getAliasTypeArguments(), ...shape.carrier.getTypeArguments()];
|
|
3871
|
+
return own.length === 1 && shape.carried.length === 1;
|
|
3872
|
+
}
|
|
3848
3873
|
/**
|
|
3849
3874
|
* The payload a RESULT CARRIER carries, or `undefined` when `type` is not
|
|
3850
3875
|
* one or its success side cannot be told from its failure side
|
|
@@ -4089,13 +4114,13 @@ export class TypeInferrer {
|
|
|
4089
4114
|
* promise-like around it is peeled, and the type arguments a branch of it
|
|
4090
4115
|
* holds as a member. `undefined` when `type` is not a carrier.
|
|
4091
4116
|
*/
|
|
4092
|
-
resultCarrierArguments(type, at, callArgs = []) {
|
|
4117
|
+
resultCarrierArguments(type, at, callArgs = [], minArguments = 2) {
|
|
4093
4118
|
// carrick#1841: a conditional deferred on a type parameter is a carrier
|
|
4094
4119
|
// where one of its branches is.
|
|
4095
4120
|
const deferredBranches = this.deferredConditionalBranches(type);
|
|
4096
4121
|
if (deferredBranches) {
|
|
4097
4122
|
for (const branch of deferredBranches) {
|
|
4098
|
-
const shape = this.resultCarrierArguments(branch, at, callArgs);
|
|
4123
|
+
const shape = this.resultCarrierArguments(branch, at, callArgs, minArguments);
|
|
4099
4124
|
if (shape)
|
|
4100
4125
|
return shape;
|
|
4101
4126
|
}
|
|
@@ -4114,7 +4139,7 @@ export class TypeInferrer {
|
|
|
4114
4139
|
// arguments its call was built from (`callResultArguments`).
|
|
4115
4140
|
const readOffCall = own.length === 0;
|
|
4116
4141
|
const args = readOffCall ? callArgs : own;
|
|
4117
|
-
if (args.length <
|
|
4142
|
+
if (args.length < minArguments) {
|
|
4118
4143
|
return undefined;
|
|
4119
4144
|
}
|
|
4120
4145
|
// carrick#1841: on a carrier read off the call, a member every branch
|
|
@@ -5656,8 +5681,12 @@ export class TypeInferrer {
|
|
|
5656
5681
|
}
|
|
5657
5682
|
/** The annotation `extractExplicitTypeFromAncestor` prints, as a node. */
|
|
5658
5683
|
explicitTypeNodeFromAncestor(node) {
|
|
5684
|
+
// The walk stops at the first function boundary: past it, the annotation
|
|
5685
|
+
// describes the object or value the function sits in, not this read.
|
|
5659
5686
|
const varDecl = node.getFirstAncestorByKind(SyntaxKind.VariableDeclaration);
|
|
5660
|
-
|
|
5687
|
+
const boundary = this.findContainingFunctionForNode(node);
|
|
5688
|
+
const crossesBoundary = !!varDecl && !!boundary && boundary.getStart() > varDecl.getStart();
|
|
5689
|
+
if (varDecl && !crossesBoundary) {
|
|
5661
5690
|
const typeNode = varDecl.getTypeNode();
|
|
5662
5691
|
if (typeNode) {
|
|
5663
5692
|
return typeNode;
|
|
@@ -858,6 +858,8 @@ export interface ListLibrarySurfaceRequest extends BaseRequest {
|
|
|
858
858
|
types?: boolean;
|
|
859
859
|
/** The most handler-parameter members the whole listing lists; default 500000 (carrick#3016). */
|
|
860
860
|
max_handler_members?: number;
|
|
861
|
+
/** Estimated member makers of values typed by another package past which they list only `export`; default 160000 (carrick#3745). */
|
|
862
|
+
foreign_maker_budget?: number;
|
|
861
863
|
/** List each signature's `result_candidates` (carrick#2817); default false (carrick#2966). */
|
|
862
864
|
result_candidates?: boolean;
|
|
863
865
|
}
|
|
@@ -1429,6 +1431,13 @@ export interface LibrarySurface {
|
|
|
1429
1431
|
* `truncated` does not count them, and it is outside `surface_sha256`.
|
|
1430
1432
|
*/
|
|
1431
1433
|
properties_left_out?: number;
|
|
1434
|
+
/**
|
|
1435
|
+
* Member makers (`instance:<member>`, `instance:new:<member>`) left out on
|
|
1436
|
+
* values typed by another package, because the request's estimate passed
|
|
1437
|
+
* `foreign_maker_budget` (carrick#3745); absent when none. `truncated` does
|
|
1438
|
+
* not count them, and it is outside `surface_sha256`.
|
|
1439
|
+
*/
|
|
1440
|
+
makers_left_out?: number;
|
|
1432
1441
|
/**
|
|
1433
1442
|
* With `types: true`: per export, per receiver the surface lists, the
|
|
1434
1443
|
* `types` receiver ids its built type and base types are declared by
|
|
@@ -3786,6 +3786,7 @@ export declare const ListLibrarySurfaceRequestSchema: z.ZodObject<{
|
|
|
3786
3786
|
types: z.ZodOptional<z.ZodBoolean>;
|
|
3787
3787
|
result_candidates: z.ZodOptional<z.ZodBoolean>;
|
|
3788
3788
|
max_handler_members: z.ZodOptional<z.ZodNumber>;
|
|
3789
|
+
foreign_maker_budget: z.ZodOptional<z.ZodNumber>;
|
|
3789
3790
|
}, "strip", z.ZodTypeAny, {
|
|
3790
3791
|
packages: string[];
|
|
3791
3792
|
request_id: string;
|
|
@@ -3797,6 +3798,7 @@ export declare const ListLibrarySurfaceRequestSchema: z.ZodObject<{
|
|
|
3797
3798
|
exports?: Record<string, string[]> | undefined;
|
|
3798
3799
|
max_entries?: number | undefined;
|
|
3799
3800
|
max_handler_members?: number | undefined;
|
|
3801
|
+
foreign_maker_budget?: number | undefined;
|
|
3800
3802
|
}, {
|
|
3801
3803
|
packages: string[];
|
|
3802
3804
|
request_id: string;
|
|
@@ -3808,6 +3810,7 @@ export declare const ListLibrarySurfaceRequestSchema: z.ZodObject<{
|
|
|
3808
3810
|
exports?: Record<string, string[]> | undefined;
|
|
3809
3811
|
max_entries?: number | undefined;
|
|
3810
3812
|
max_handler_members?: number | undefined;
|
|
3813
|
+
foreign_maker_budget?: number | undefined;
|
|
3811
3814
|
}>;
|
|
3812
3815
|
/**
|
|
3813
3816
|
* The main sidecar request schema - a discriminated union on the 'action' field
|
|
@@ -7199,6 +7202,7 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
7199
7202
|
types: z.ZodOptional<z.ZodBoolean>;
|
|
7200
7203
|
result_candidates: z.ZodOptional<z.ZodBoolean>;
|
|
7201
7204
|
max_handler_members: z.ZodOptional<z.ZodNumber>;
|
|
7205
|
+
foreign_maker_budget: z.ZodOptional<z.ZodNumber>;
|
|
7202
7206
|
}, "strip", z.ZodTypeAny, {
|
|
7203
7207
|
packages: string[];
|
|
7204
7208
|
request_id: string;
|
|
@@ -7210,6 +7214,7 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
7210
7214
|
exports?: Record<string, string[]> | undefined;
|
|
7211
7215
|
max_entries?: number | undefined;
|
|
7212
7216
|
max_handler_members?: number | undefined;
|
|
7217
|
+
foreign_maker_budget?: number | undefined;
|
|
7213
7218
|
}, {
|
|
7214
7219
|
packages: string[];
|
|
7215
7220
|
request_id: string;
|
|
@@ -7221,6 +7226,7 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
7221
7226
|
exports?: Record<string, string[]> | undefined;
|
|
7222
7227
|
max_entries?: number | undefined;
|
|
7223
7228
|
max_handler_members?: number | undefined;
|
|
7229
|
+
foreign_maker_budget?: number | undefined;
|
|
7224
7230
|
}>, z.ZodObject<{
|
|
7225
7231
|
request_id: z.ZodString;
|
|
7226
7232
|
} & {
|
|
@@ -683,6 +683,7 @@ export const ListLibrarySurfaceRequestSchema = BaseRequestSchema.extend({
|
|
|
683
683
|
types: z.boolean().optional(),
|
|
684
684
|
result_candidates: z.boolean().optional(),
|
|
685
685
|
max_handler_members: z.number().int().positive().optional(),
|
|
686
|
+
foreign_maker_budget: z.number().int().positive().optional(),
|
|
686
687
|
});
|
|
687
688
|
// ============================================================================
|
|
688
689
|
// Discriminated Union Schema
|