@effect/language-service 0.73.0 → 0.74.0
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/README.md +10 -0
- package/cli.js +221 -34
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +220 -33
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +279 -51
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +220 -33
- package/transform.js.map +1 -1
package/README.md
CHANGED
|
@@ -303,6 +303,16 @@ Effect.succeed(1); // This will not be reported as a floating Effect
|
|
|
303
303
|
Effect.succeed(1); // This will be reported as a floating effect
|
|
304
304
|
```
|
|
305
305
|
|
|
306
|
+
You can also use `*` as a wildcard to apply a severity to all diagnostics at once:
|
|
307
|
+
|
|
308
|
+
```ts
|
|
309
|
+
// @effect-diagnostics *:off
|
|
310
|
+
Effect.succeed(1); // No diagnostics will be reported from this point on
|
|
311
|
+
|
|
312
|
+
// @effect-diagnostics effect/floatingEffect:error
|
|
313
|
+
Effect.succeed(1); // This will be reported as a floating effect (rule-specific overrides wildcard)
|
|
314
|
+
```
|
|
315
|
+
|
|
306
316
|
or you can set the severity for the entire project in the global plugin configuration
|
|
307
317
|
|
|
308
318
|
```jsonc
|
package/cli.js
CHANGED
|
@@ -30214,7 +30214,7 @@ var runMain3 = runMain2;
|
|
|
30214
30214
|
// package.json
|
|
30215
30215
|
var package_default = {
|
|
30216
30216
|
name: "@effect/language-service",
|
|
30217
|
-
version: "0.
|
|
30217
|
+
version: "0.74.0",
|
|
30218
30218
|
publishConfig: {
|
|
30219
30219
|
access: "public",
|
|
30220
30220
|
directory: "dist"
|
|
@@ -32166,7 +32166,7 @@ var createDiagnosticExecutor = fn2("LSP.createCommentDirectivesProcessor")(
|
|
|
32166
32166
|
const lineOverrides = {};
|
|
32167
32167
|
const sectionOverrides = {};
|
|
32168
32168
|
const skippedRules = [];
|
|
32169
|
-
const regex = /@effect-diagnostics(-next-line)?((?:\s[a-zA-Z0-9/]
|
|
32169
|
+
const regex = /@effect-diagnostics(-next-line)?((?:\s(?:[a-zA-Z0-9/]+|\*):(?:off|warning|error|message|suggestion|skip-file))+)?/gm;
|
|
32170
32170
|
let match18;
|
|
32171
32171
|
while ((match18 = regex.exec(sourceFile.text)) !== null) {
|
|
32172
32172
|
const nextLineCaptureGroup = match18[1];
|
|
@@ -32215,8 +32215,10 @@ var createDiagnosticExecutor = fn2("LSP.createCommentDirectivesProcessor")(
|
|
|
32215
32215
|
const codeFixes = [];
|
|
32216
32216
|
const ruleNameLowered = rule.name.toLowerCase();
|
|
32217
32217
|
const defaultLevel = pluginOptions.diagnosticSeverity[ruleNameLowered] || rule.severity;
|
|
32218
|
-
if (skippedRules.indexOf(ruleNameLowered) > -1
|
|
32219
|
-
|
|
32218
|
+
if (skippedRules.indexOf(ruleNameLowered) > -1 || skippedRules.indexOf("*") > -1) {
|
|
32219
|
+
return { diagnostics: diagnostics3, codeFixes };
|
|
32220
|
+
}
|
|
32221
|
+
if (defaultLevel === "off" && (lineOverrides[ruleNameLowered] || sectionOverrides[ruleNameLowered] || lineOverrides["*"] || sectionOverrides["*"] || []).length === 0) {
|
|
32220
32222
|
return { diagnostics: diagnostics3, codeFixes };
|
|
32221
32223
|
}
|
|
32222
32224
|
const fixByDisableNextLine = (node) => ({
|
|
@@ -32265,14 +32267,22 @@ var createDiagnosticExecutor = fn2("LSP.createCommentDirectivesProcessor")(
|
|
|
32265
32267
|
const unusedLineOverrides = new Set(lineOverrides[ruleNameLowered] || []);
|
|
32266
32268
|
for (const emitted of applicableDiagnostics.slice(0)) {
|
|
32267
32269
|
let newLevel = defaultLevel;
|
|
32268
|
-
const
|
|
32270
|
+
const specificLineOverride = (lineOverrides[ruleNameLowered] || []).find(
|
|
32271
|
+
(_) => _.pos < emitted.range.pos && _.end >= emitted.range.end
|
|
32272
|
+
);
|
|
32273
|
+
const wildcardLineOverride = (lineOverrides["*"] || []).find(
|
|
32269
32274
|
(_) => _.pos < emitted.range.pos && _.end >= emitted.range.end
|
|
32270
32275
|
);
|
|
32276
|
+
const lineOverride = specificLineOverride && wildcardLineOverride ? specificLineOverride.pos >= wildcardLineOverride.pos ? specificLineOverride : wildcardLineOverride : specificLineOverride || wildcardLineOverride;
|
|
32271
32277
|
if (lineOverride) {
|
|
32272
32278
|
newLevel = lineOverride.level;
|
|
32273
32279
|
unusedLineOverrides.delete(lineOverride);
|
|
32274
32280
|
} else {
|
|
32275
|
-
const
|
|
32281
|
+
const specificSectionOverride = (sectionOverrides[ruleNameLowered] || []).find(
|
|
32282
|
+
(_) => _.pos < emitted.range.pos
|
|
32283
|
+
);
|
|
32284
|
+
const wildcardSectionOverride = (sectionOverrides["*"] || []).find((_) => _.pos < emitted.range.pos);
|
|
32285
|
+
const sectionOverride = specificSectionOverride && wildcardSectionOverride ? specificSectionOverride.pos >= wildcardSectionOverride.pos ? specificSectionOverride : wildcardSectionOverride : specificSectionOverride || wildcardSectionOverride;
|
|
32276
32286
|
if (sectionOverride) newLevel = sectionOverride.level;
|
|
32277
32287
|
}
|
|
32278
32288
|
if (!(newLevel in levelToDiagnosticCategory)) continue;
|
|
@@ -33593,6 +33603,28 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
33593
33603
|
`TypeParser.isNodeReferenceToEffectParseResultModuleApi(${memberName})`,
|
|
33594
33604
|
(node) => node
|
|
33595
33605
|
);
|
|
33606
|
+
const isEffectSchemaParserSourceFile = cachedBy(
|
|
33607
|
+
fn2("TypeParser.isEffectSchemaParserSourceFile")(function* (sourceFile) {
|
|
33608
|
+
const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
|
|
33609
|
+
if (!moduleSymbol) return yield* typeParserIssue("Node has no symbol", void 0, sourceFile);
|
|
33610
|
+
const parseIssueSymbol = typeChecker.tryGetMemberInModuleExports("Parser", moduleSymbol);
|
|
33611
|
+
if (!parseIssueSymbol) return yield* typeParserIssue("ParseIssue type not found", void 0, sourceFile);
|
|
33612
|
+
const decodeSyncSymbol = typeChecker.tryGetMemberInModuleExports("decodeEffect", moduleSymbol);
|
|
33613
|
+
if (!decodeSyncSymbol) return yield* typeParserIssue("decodeSync not found", void 0, sourceFile);
|
|
33614
|
+
const encodeSyncSymbol = typeChecker.tryGetMemberInModuleExports("encodeEffect", moduleSymbol);
|
|
33615
|
+
if (!encodeSyncSymbol) return yield* typeParserIssue("encodeSync not found", void 0, sourceFile);
|
|
33616
|
+
return sourceFile;
|
|
33617
|
+
}),
|
|
33618
|
+
"TypeParser.isEffectSchemaParserSourceFile",
|
|
33619
|
+
(sourceFile) => sourceFile
|
|
33620
|
+
);
|
|
33621
|
+
const isNodeReferenceToEffectSchemaParserModuleApi = (memberName) => cachedBy(
|
|
33622
|
+
fn2("TypeParser.isNodeReferenceToEffectSchemaParserModuleApi")(function* (node) {
|
|
33623
|
+
return yield* isNodeReferenceToExportOfPackageModule(node, "effect", isEffectSchemaParserSourceFile, memberName);
|
|
33624
|
+
}),
|
|
33625
|
+
`TypeParser.isNodeReferenceToEffectSchemaParserModuleApi(${memberName})`,
|
|
33626
|
+
(node) => node
|
|
33627
|
+
);
|
|
33596
33628
|
const contextTagVarianceStruct = (type2, atLocation) => map34(
|
|
33597
33629
|
all9(
|
|
33598
33630
|
varianceStructInvariantType(type2, atLocation, "_Identifier"),
|
|
@@ -33600,6 +33632,31 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
33600
33632
|
),
|
|
33601
33633
|
([Identifier, Service]) => ({ Identifier, Service })
|
|
33602
33634
|
);
|
|
33635
|
+
const serviceVarianceStruct = (type2, atLocation) => map34(
|
|
33636
|
+
all9(
|
|
33637
|
+
varianceStructInvariantType(type2, atLocation, "_Identifier"),
|
|
33638
|
+
varianceStructInvariantType(type2, atLocation, "_Service")
|
|
33639
|
+
),
|
|
33640
|
+
([Identifier, Service]) => ({ Identifier, Service })
|
|
33641
|
+
);
|
|
33642
|
+
const serviceType = cachedBy(
|
|
33643
|
+
fn2("TypeParser.serviceType")(function* (type2, atLocation) {
|
|
33644
|
+
yield* pipeableType(type2, atLocation);
|
|
33645
|
+
const propertiesSymbols = typeChecker.getPropertiesOfType(type2).filter(
|
|
33646
|
+
(_) => _.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration
|
|
33647
|
+
);
|
|
33648
|
+
if (propertiesSymbols.length === 0) {
|
|
33649
|
+
return yield* typeParserIssue("Type has no tag variance struct", type2, atLocation);
|
|
33650
|
+
}
|
|
33651
|
+
propertiesSymbols.sort((a, b) => ts.symbolName(b).indexOf("TypeId") - ts.symbolName(a).indexOf("TypeId"));
|
|
33652
|
+
return yield* firstSuccessOf2(propertiesSymbols.map((propertySymbol) => {
|
|
33653
|
+
const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
|
|
33654
|
+
return serviceVarianceStruct(propertyType, atLocation);
|
|
33655
|
+
}));
|
|
33656
|
+
}),
|
|
33657
|
+
"TypeParser.serviceType",
|
|
33658
|
+
(type2) => type2
|
|
33659
|
+
);
|
|
33603
33660
|
const contextTag = cachedBy(
|
|
33604
33661
|
fn2("TypeParser.contextTag")(function* (type2, atLocation) {
|
|
33605
33662
|
yield* pipeableType(type2, atLocation);
|
|
@@ -33681,14 +33738,22 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
33681
33738
|
);
|
|
33682
33739
|
const scopeType = cachedBy(
|
|
33683
33740
|
fn2("TypeParser.scopeType")(function* (type2, atLocation) {
|
|
33684
|
-
|
|
33685
|
-
|
|
33686
|
-
|
|
33687
|
-
|
|
33688
|
-
|
|
33689
|
-
return type2;
|
|
33741
|
+
if (supportedEffect() === "v4") {
|
|
33742
|
+
const typeIdSymbol = typeChecker.getPropertyOfType(type2, "~effect/Scope");
|
|
33743
|
+
if (typeIdSymbol) {
|
|
33744
|
+
return type2;
|
|
33745
|
+
}
|
|
33746
|
+
return yield* typeParserIssue("Type is not an effect", type2, atLocation);
|
|
33747
|
+
} else {
|
|
33748
|
+
yield* pipeableType(type2, atLocation);
|
|
33749
|
+
const propertiesSymbols = typeChecker.getPropertiesOfType(type2).filter(
|
|
33750
|
+
(_) => _.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration
|
|
33751
|
+
);
|
|
33752
|
+
if (propertiesSymbols.some((s) => ts.symbolName(s).indexOf("ScopeTypeId") !== -1)) {
|
|
33753
|
+
return type2;
|
|
33754
|
+
}
|
|
33755
|
+
return yield* typeParserIssue("Type has no scope type id", type2, atLocation);
|
|
33690
33756
|
}
|
|
33691
|
-
return yield* typeParserIssue("Type has no scope type id", type2, atLocation);
|
|
33692
33757
|
}),
|
|
33693
33758
|
"TypeParser.scopeType",
|
|
33694
33759
|
(type2) => type2
|
|
@@ -34170,6 +34235,55 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
34170
34235
|
"TypeParser.extendsEffectService",
|
|
34171
34236
|
(atLocation) => atLocation
|
|
34172
34237
|
);
|
|
34238
|
+
const extendsServiceMapService = cachedBy(
|
|
34239
|
+
fn2("TypeParser.extendsServiceMapService")(function* (atLocation) {
|
|
34240
|
+
if (!atLocation.name) {
|
|
34241
|
+
return yield* typeParserIssue("Class has no name", void 0, atLocation);
|
|
34242
|
+
}
|
|
34243
|
+
const heritageClauses = atLocation.heritageClauses;
|
|
34244
|
+
if (!heritageClauses) {
|
|
34245
|
+
return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
|
|
34246
|
+
}
|
|
34247
|
+
for (const heritageClause of heritageClauses) {
|
|
34248
|
+
for (const typeX of heritageClause.types) {
|
|
34249
|
+
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
34250
|
+
const wholeCall = typeX.expression;
|
|
34251
|
+
if (ts.isCallExpression(wholeCall)) {
|
|
34252
|
+
const serviceMapServiceCall = wholeCall.expression;
|
|
34253
|
+
if (ts.isCallExpression(serviceMapServiceCall) && serviceMapServiceCall.typeArguments && serviceMapServiceCall.typeArguments.length > 0) {
|
|
34254
|
+
const serviceMapServiceIdentifier = serviceMapServiceCall.expression;
|
|
34255
|
+
const selfTypeNode = serviceMapServiceCall.typeArguments[0];
|
|
34256
|
+
const isServiceMapService = yield* pipe(
|
|
34257
|
+
isNodeReferenceToServiceMapModuleApi("Service")(serviceMapServiceIdentifier),
|
|
34258
|
+
orUndefined2
|
|
34259
|
+
);
|
|
34260
|
+
if (isServiceMapService) {
|
|
34261
|
+
const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
|
|
34262
|
+
if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
|
|
34263
|
+
const type2 = typeChecker.getTypeOfSymbol(classSym);
|
|
34264
|
+
const parsedServiceType = yield* pipe(
|
|
34265
|
+
serviceType(type2, atLocation),
|
|
34266
|
+
orUndefined2
|
|
34267
|
+
);
|
|
34268
|
+
if (parsedServiceType) {
|
|
34269
|
+
return {
|
|
34270
|
+
...parsedServiceType,
|
|
34271
|
+
className: atLocation.name,
|
|
34272
|
+
selfTypeNode,
|
|
34273
|
+
keyStringLiteral: wholeCall.arguments.length > 0 && ts.isStringLiteral(wholeCall.arguments[0]) ? wholeCall.arguments[0] : void 0
|
|
34274
|
+
};
|
|
34275
|
+
}
|
|
34276
|
+
}
|
|
34277
|
+
}
|
|
34278
|
+
}
|
|
34279
|
+
}
|
|
34280
|
+
}
|
|
34281
|
+
}
|
|
34282
|
+
return yield* typeParserIssue("Class does not extend ServiceMap.Service", void 0, atLocation);
|
|
34283
|
+
}),
|
|
34284
|
+
"TypeParser.extendsServiceMapService",
|
|
34285
|
+
(atLocation) => atLocation
|
|
34286
|
+
);
|
|
34173
34287
|
const isEffectSqlModelTypeSourceFile = cachedBy(
|
|
34174
34288
|
fn2("TypeParser.isEffectSqlModelTypeSourceFile")(function* (sourceFile) {
|
|
34175
34289
|
const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
|
|
@@ -34262,6 +34376,24 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
34262
34376
|
`TypeParser.isNodeReferenceToEffectLayerModuleApi(${memberName})`,
|
|
34263
34377
|
(node) => node
|
|
34264
34378
|
);
|
|
34379
|
+
const isServiceMapTypeSourceFile = cachedBy(
|
|
34380
|
+
fn2("TypeParser.isServiceMapTypeSourceFile")(function* (sourceFile) {
|
|
34381
|
+
const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
|
|
34382
|
+
if (!moduleSymbol) return yield* typeParserIssue("Node has no symbol", void 0, sourceFile);
|
|
34383
|
+
const serviceMapSymbol = typeChecker.tryGetMemberInModuleExports("ServiceMap", moduleSymbol);
|
|
34384
|
+
if (!serviceMapSymbol) return yield* typeParserIssue("ServiceMap not found", void 0, sourceFile);
|
|
34385
|
+
return sourceFile;
|
|
34386
|
+
}),
|
|
34387
|
+
"TypeParser.isServiceMapTypeSourceFile",
|
|
34388
|
+
(sourceFile) => sourceFile
|
|
34389
|
+
);
|
|
34390
|
+
const isNodeReferenceToServiceMapModuleApi = (memberName) => cachedBy(
|
|
34391
|
+
fn2("TypeParser.isNodeReferenceToServiceMapModuleApi")(function* (node) {
|
|
34392
|
+
return yield* isNodeReferenceToExportOfPackageModule(node, "effect", isServiceMapTypeSourceFile, memberName);
|
|
34393
|
+
}),
|
|
34394
|
+
`TypeParser.isNodeReferenceToServiceMapModuleApi(${memberName})`,
|
|
34395
|
+
(node) => node
|
|
34396
|
+
);
|
|
34265
34397
|
const lazyExpression = cachedBy(
|
|
34266
34398
|
function(node) {
|
|
34267
34399
|
if (!ts.isArrowFunction(node) && !ts.isFunctionExpression(node)) {
|
|
@@ -34592,6 +34724,9 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
34592
34724
|
isNodeReferenceToEffectContextModuleApi,
|
|
34593
34725
|
isNodeReferenceToEffectSqlModelModuleApi,
|
|
34594
34726
|
isNodeReferenceToEffectLayerModuleApi,
|
|
34727
|
+
isNodeReferenceToEffectSchemaParserModuleApi,
|
|
34728
|
+
isServiceMapTypeSourceFile,
|
|
34729
|
+
isNodeReferenceToServiceMapModuleApi,
|
|
34595
34730
|
effectType,
|
|
34596
34731
|
strictEffectType,
|
|
34597
34732
|
layerType,
|
|
@@ -34607,6 +34742,7 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
34607
34742
|
unnecessaryEffectGen: unnecessaryEffectGen2,
|
|
34608
34743
|
effectSchemaType,
|
|
34609
34744
|
contextTag,
|
|
34745
|
+
serviceType,
|
|
34610
34746
|
pipeableType,
|
|
34611
34747
|
pipeCall,
|
|
34612
34748
|
singleArgCall,
|
|
@@ -34614,6 +34750,7 @@ function make64(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
34614
34750
|
promiseLike,
|
|
34615
34751
|
extendsEffectTag,
|
|
34616
34752
|
extendsEffectService,
|
|
34753
|
+
extendsServiceMapService,
|
|
34617
34754
|
extendsContextTag,
|
|
34618
34755
|
extendsSchemaClass,
|
|
34619
34756
|
extendsSchemaTaggedClass,
|
|
@@ -34834,6 +34971,7 @@ var parse5 = fn2("writeTagClassAccessors.parse")(function* (node) {
|
|
|
34834
34971
|
const typeChecker = yield* service2(TypeCheckerApi);
|
|
34835
34972
|
const typeParser = yield* service2(TypeParser);
|
|
34836
34973
|
const typeCheckerUtils = yield* service2(TypeCheckerUtils);
|
|
34974
|
+
if (typeParser.supportedEffect() === "v4") return yield* fail18("not applicable to Effect v4");
|
|
34837
34975
|
if (!ts.isClassDeclaration(node)) return yield* fail18("not a class declaration");
|
|
34838
34976
|
const { Service, accessors: accessors2, className, kind } = yield* pipe(
|
|
34839
34977
|
map34(typeParser.extendsEffectService(node), (_) => ({ kind: "effectService", ..._ })),
|
|
@@ -35076,16 +35214,16 @@ var pushHoistedVariableStatement = fn2("StructuralSchemaGen.pushHoistedVariableS
|
|
|
35076
35214
|
);
|
|
35077
35215
|
}
|
|
35078
35216
|
);
|
|
35079
|
-
var createProcessingContext = (maxDepth = 200) => ({
|
|
35217
|
+
var createProcessingContext = (supportedEffect, maxDepth = 200) => ({
|
|
35080
35218
|
depth: 0,
|
|
35081
35219
|
maxDepth,
|
|
35082
|
-
hoistName: void 0
|
|
35220
|
+
hoistName: void 0,
|
|
35221
|
+
supportedEffect
|
|
35083
35222
|
});
|
|
35084
35223
|
var processType = fn2(
|
|
35085
35224
|
"StructuralSchemaGen.processType"
|
|
35086
35225
|
)(
|
|
35087
|
-
function* (type2,
|
|
35088
|
-
const processingContext = context7 || createProcessingContext();
|
|
35226
|
+
function* (type2, processingContext) {
|
|
35089
35227
|
const { hoistedSchemas, nameToType, ts, typeChecker, usedGlobalIdentifiers } = yield* service2(
|
|
35090
35228
|
StructuralSchemaGenContext
|
|
35091
35229
|
);
|
|
@@ -35220,7 +35358,7 @@ var processUnionType = fn2(
|
|
|
35220
35358
|
const allLiterals = types.every(
|
|
35221
35359
|
(t) => t.flags & ts.TypeFlags.StringLiteral || t.flags & ts.TypeFlags.NumberLiteral || t.flags & ts.TypeFlags.BooleanLiteral
|
|
35222
35360
|
);
|
|
35223
|
-
if (allLiterals) {
|
|
35361
|
+
if (allLiterals && context7.supportedEffect !== "v4") {
|
|
35224
35362
|
const literals = yield* all9(
|
|
35225
35363
|
...types.map((t) => processType(t, context7))
|
|
35226
35364
|
);
|
|
@@ -35230,7 +35368,13 @@ var processUnionType = fn2(
|
|
|
35230
35368
|
}
|
|
35231
35369
|
return expr;
|
|
35232
35370
|
}).filter((arg) => arg !== void 0);
|
|
35233
|
-
return [
|
|
35371
|
+
return [
|
|
35372
|
+
createApiCall(
|
|
35373
|
+
"Literal",
|
|
35374
|
+
literalValues
|
|
35375
|
+
),
|
|
35376
|
+
false
|
|
35377
|
+
];
|
|
35234
35378
|
}
|
|
35235
35379
|
const members = yield* all9(
|
|
35236
35380
|
...types.map((t) => processType(t, context7))
|
|
@@ -35238,7 +35382,13 @@ var processUnionType = fn2(
|
|
|
35238
35382
|
if (members.length === 1) {
|
|
35239
35383
|
return [members[0], false];
|
|
35240
35384
|
}
|
|
35241
|
-
return [
|
|
35385
|
+
return [
|
|
35386
|
+
createApiCall(
|
|
35387
|
+
"Union",
|
|
35388
|
+
context7.supportedEffect === "v4" ? [ts.factory.createArrayLiteralExpression(members)] : members
|
|
35389
|
+
),
|
|
35390
|
+
false
|
|
35391
|
+
];
|
|
35242
35392
|
}
|
|
35243
35393
|
);
|
|
35244
35394
|
var processIntersectionType = fn2(
|
|
@@ -35284,12 +35434,18 @@ var processTupleType = fn2(
|
|
|
35284
35434
|
"StructuralSchemaGen.processTupleType"
|
|
35285
35435
|
)(
|
|
35286
35436
|
function* (type2, context7) {
|
|
35287
|
-
const { createApiCall, typeChecker } = yield* service2(StructuralSchemaGenContext);
|
|
35437
|
+
const { createApiCall, ts, typeChecker } = yield* service2(StructuralSchemaGenContext);
|
|
35288
35438
|
const typeArgs = typeChecker.getTypeArguments(type2);
|
|
35289
35439
|
const elementSchemas = yield* all9(
|
|
35290
35440
|
...typeArgs.map((t) => processType(t, context7))
|
|
35291
35441
|
);
|
|
35292
|
-
return [
|
|
35442
|
+
return [
|
|
35443
|
+
createApiCall(
|
|
35444
|
+
"Tuple",
|
|
35445
|
+
context7.supportedEffect === "v4" ? [ts.factory.createArrayLiteralExpression(elementSchemas)] : elementSchemas
|
|
35446
|
+
),
|
|
35447
|
+
false
|
|
35448
|
+
];
|
|
35293
35449
|
}
|
|
35294
35450
|
);
|
|
35295
35451
|
var processObjectType = fn2(
|
|
@@ -35306,7 +35462,6 @@ var processObjectType = fn2(
|
|
|
35306
35462
|
} = yield* service2(
|
|
35307
35463
|
StructuralSchemaGenContext
|
|
35308
35464
|
);
|
|
35309
|
-
let hasRecords = false;
|
|
35310
35465
|
const properties = typeChecker.getPropertiesOfType(type2);
|
|
35311
35466
|
const propertyAssignments = [];
|
|
35312
35467
|
for (const property of properties) {
|
|
@@ -35346,20 +35501,28 @@ var processObjectType = fn2(
|
|
|
35346
35501
|
const args3 = [
|
|
35347
35502
|
ts.factory.createObjectLiteralExpression(propertyAssignments, propertyAssignments.length > 0)
|
|
35348
35503
|
];
|
|
35504
|
+
const records = [];
|
|
35349
35505
|
for (const indexInfo of indexInfos) {
|
|
35350
|
-
hasRecords = true;
|
|
35351
35506
|
const keyType = indexInfo.keyType;
|
|
35352
35507
|
const valueType = indexInfo.type;
|
|
35353
35508
|
const keySchema = yield* processType(keyType, context7);
|
|
35354
35509
|
const valueSchema = yield* processType(valueType, context7);
|
|
35355
|
-
|
|
35356
|
-
|
|
35357
|
-
|
|
35358
|
-
|
|
35359
|
-
|
|
35360
|
-
|
|
35510
|
+
records.push({ key: keySchema, value: valueSchema });
|
|
35511
|
+
}
|
|
35512
|
+
if (context7.supportedEffect === "v4") {
|
|
35513
|
+
if (records.length > 0) {
|
|
35514
|
+
return [
|
|
35515
|
+
createApiCall("StructWithRest", [
|
|
35516
|
+
createApiCall("Struct", args3),
|
|
35517
|
+
ts.factory.createArrayLiteralExpression(
|
|
35518
|
+
records.map(({ key, value: value5 }) => createApiCall("Record", [key, value5]))
|
|
35519
|
+
)
|
|
35520
|
+
]),
|
|
35521
|
+
propertyAssignments.length === 0
|
|
35522
|
+
];
|
|
35523
|
+
}
|
|
35361
35524
|
}
|
|
35362
|
-
if (
|
|
35525
|
+
if (records.length === 0 && context7.hoistName) {
|
|
35363
35526
|
const ctx = yield* service2(StructuralSchemaGenContext);
|
|
35364
35527
|
yield* pushHoistedStatement(
|
|
35365
35528
|
ctx,
|
|
@@ -35394,6 +35557,14 @@ var processObjectType = fn2(
|
|
|
35394
35557
|
);
|
|
35395
35558
|
return [ctx.hoistedSchemas.get(type2)(), true];
|
|
35396
35559
|
}
|
|
35560
|
+
for (const { key, value: value5 } of records) {
|
|
35561
|
+
args3.push(
|
|
35562
|
+
ts.factory.createObjectLiteralExpression([
|
|
35563
|
+
ts.factory.createPropertyAssignment("key", key),
|
|
35564
|
+
ts.factory.createPropertyAssignment("value", value5)
|
|
35565
|
+
])
|
|
35566
|
+
);
|
|
35567
|
+
}
|
|
35397
35568
|
return [createApiCall("Struct", args3), propertyAssignments.length === 0];
|
|
35398
35569
|
}
|
|
35399
35570
|
);
|
|
@@ -35479,7 +35650,7 @@ var process2 = fn2("StructuralSchemaGen.process")(
|
|
|
35479
35650
|
all9(
|
|
35480
35651
|
...fromIterable(ctx.nameToType.entries()).map(
|
|
35481
35652
|
([name, type2]) => pipe(
|
|
35482
|
-
processType(type2),
|
|
35653
|
+
processType(type2, createProcessingContext(typeParser.supportedEffect())),
|
|
35483
35654
|
orElse15(
|
|
35484
35655
|
(error4) => succeed17(ts.addSyntheticLeadingComment(
|
|
35485
35656
|
ts.factory.createIdentifier(""),
|
|
@@ -36279,6 +36450,7 @@ var deterministicKeys = createDiagnostic({
|
|
|
36279
36450
|
typeParser.extendsEffectService(node),
|
|
36280
36451
|
orElse15(() => typeParser.extendsContextTag(node)),
|
|
36281
36452
|
orElse15(() => typeParser.extendsEffectTag(node)),
|
|
36453
|
+
orElse15(() => typeParser.extendsServiceMapService(node)),
|
|
36282
36454
|
map34(({ className, keyStringLiteral }) => ({ keyStringLiteral, className, target: "service" }))
|
|
36283
36455
|
),
|
|
36284
36456
|
orElse15(
|
|
@@ -37674,6 +37846,9 @@ More info and examples at https://effect.website/docs/requirements-management/la
|
|
|
37674
37846
|
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && ts.idText(node.expression.name) === "GenericTag") {
|
|
37675
37847
|
const nodeType = typeCheckerUtils.getTypeAtLocation(node);
|
|
37676
37848
|
if (nodeType) typesToCheck.push([nodeType, node]);
|
|
37849
|
+
} else if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && ts.idText(node.expression.name) === "Service") {
|
|
37850
|
+
const nodeType = typeCheckerUtils.getTypeAtLocation(node);
|
|
37851
|
+
if (nodeType) typesToCheck.push([nodeType, node]);
|
|
37677
37852
|
} else if (ts.isClassDeclaration(node) && node.name && node.heritageClauses) {
|
|
37678
37853
|
const classSym = typeChecker.getSymbolAtLocation(node.name);
|
|
37679
37854
|
if (classSym) {
|
|
@@ -37687,6 +37862,7 @@ More info and examples at https://effect.website/docs/requirements-management/la
|
|
|
37687
37862
|
for (const [type2, reportAt] of typesToCheck) {
|
|
37688
37863
|
yield* pipe(
|
|
37689
37864
|
typeParser.contextTag(type2, node),
|
|
37865
|
+
orElse15(() => typeParser.serviceType(type2, node)),
|
|
37690
37866
|
flatMap18(
|
|
37691
37867
|
({ Service }) => pipe(
|
|
37692
37868
|
parseLeakedRequirements(Service, node),
|
|
@@ -38461,6 +38637,7 @@ var nonObjectEffectServiceType = createDiagnostic({
|
|
|
38461
38637
|
const typeChecker = yield* service2(TypeCheckerApi);
|
|
38462
38638
|
const typeCheckerUtils = yield* service2(TypeCheckerUtils);
|
|
38463
38639
|
const typeParser = yield* service2(TypeParser);
|
|
38640
|
+
if (typeParser.supportedEffect() === "v4") return;
|
|
38464
38641
|
function isPrimitiveType(type2) {
|
|
38465
38642
|
return typeCheckerUtils.unrollUnionMembers(type2).some(
|
|
38466
38643
|
(type3) => !!(type3.flags & ts.TypeFlags.String || type3.flags & ts.TypeFlags.Number || type3.flags & ts.TypeFlags.Boolean || type3.flags & ts.TypeFlags.StringLiteral || type3.flags & ts.TypeFlags.NumberLiteral || type3.flags & ts.TypeFlags.BooleanLiteral || type3.flags & ts.TypeFlags.Undefined || type3.flags & ts.TypeFlags.Null)
|
|
@@ -38939,6 +39116,7 @@ var runEffectInsideEffect = createDiagnostic({
|
|
|
38939
39116
|
const ts = yield* service2(TypeScriptApi);
|
|
38940
39117
|
const typeParser = yield* service2(TypeParser);
|
|
38941
39118
|
const tsUtils = yield* service2(TypeScriptUtils);
|
|
39119
|
+
if (typeParser.supportedEffect() === "v4") return;
|
|
38942
39120
|
const parseEffectMethod = (node, methodName) => pipe(
|
|
38943
39121
|
typeParser.isNodeReferenceToEffectModuleApi(methodName)(node),
|
|
38944
39122
|
map34(() => ({ node, methodName }))
|
|
@@ -39133,12 +39311,18 @@ var schemaStructWithTag = createDiagnostic({
|
|
|
39133
39311
|
});
|
|
39134
39312
|
|
|
39135
39313
|
// src/diagnostics/schemaSyncInEffect.ts
|
|
39136
|
-
var
|
|
39314
|
+
var syncToEffectMethodV3 = {
|
|
39137
39315
|
decodeSync: "decode",
|
|
39138
39316
|
decodeUnknownSync: "decodeUnknown",
|
|
39139
39317
|
encodeSync: "encode",
|
|
39140
39318
|
encodeUnknownSync: "encodeUnknown"
|
|
39141
39319
|
};
|
|
39320
|
+
var syncToEffectMethodV4 = {
|
|
39321
|
+
decodeSync: "decodeEffect",
|
|
39322
|
+
decodeUnknownSync: "decodeUnknownEffect",
|
|
39323
|
+
encodeSync: "encodeEffect",
|
|
39324
|
+
encodeUnknownSync: "encodeUnknownEffect"
|
|
39325
|
+
};
|
|
39142
39326
|
var schemaSyncInEffect = createDiagnostic({
|
|
39143
39327
|
name: "schemaSyncInEffect",
|
|
39144
39328
|
code: 43,
|
|
@@ -39147,8 +39331,10 @@ var schemaSyncInEffect = createDiagnostic({
|
|
|
39147
39331
|
apply: fn2("schemaSyncInEffect.apply")(function* (sourceFile, report) {
|
|
39148
39332
|
const ts = yield* service2(TypeScriptApi);
|
|
39149
39333
|
const typeParser = yield* service2(TypeParser);
|
|
39334
|
+
const syncToEffectMethod = typeParser.supportedEffect() === "v3" ? syncToEffectMethodV3 : syncToEffectMethodV4;
|
|
39150
39335
|
const parseSchemaSyncMethod = (node, methodName) => pipe(
|
|
39151
39336
|
typeParser.isNodeReferenceToEffectParseResultModuleApi(methodName)(node),
|
|
39337
|
+
orElse15(() => typeParser.isNodeReferenceToEffectSchemaParserModuleApi(methodName)(node)),
|
|
39152
39338
|
map34(() => ({ node, methodName }))
|
|
39153
39339
|
);
|
|
39154
39340
|
const nodeToVisit = [];
|
|
@@ -39178,7 +39364,7 @@ var schemaSyncInEffect = createDiagnostic({
|
|
|
39178
39364
|
const effectMethodName = syncToEffectMethod[isSchemaSyncCall.value.methodName];
|
|
39179
39365
|
report({
|
|
39180
39366
|
location: node.expression,
|
|
39181
|
-
messageText: `Using ${nodeText} inside an Effect generator is not recommended. Use Schema.${effectMethodName} instead to get properly typed
|
|
39367
|
+
messageText: `Using ${nodeText} inside an Effect generator is not recommended. Use Schema.${effectMethodName} instead to get properly typed error channel.`,
|
|
39182
39368
|
fixes: []
|
|
39183
39369
|
});
|
|
39184
39370
|
}
|
|
@@ -39194,6 +39380,7 @@ var schemaUnionOfLiterals = createDiagnostic({
|
|
|
39194
39380
|
apply: fn2("schemaUnionOfLiterals.apply")(function* (sourceFile, report) {
|
|
39195
39381
|
const ts = yield* service2(TypeScriptApi);
|
|
39196
39382
|
const typeParser = yield* service2(TypeParser);
|
|
39383
|
+
if (typeParser.supportedEffect() === "v4") return;
|
|
39197
39384
|
const nodeToVisit = [];
|
|
39198
39385
|
const appendNodeToVisit = (node) => {
|
|
39199
39386
|
nodeToVisit.push(node);
|