Skip to content

Commit c3a4e27

Browse files
ymc9claude
andauthored
fix(deps): upgrade langium to 4.2 to drop vulnerable lodash-es (#2704) (#2709)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 666f841 commit c3a4e27

21 files changed

Lines changed: 1387 additions & 1167 deletions

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@
6262
],
6363
"overrides": {
6464
"cookie@<0.7.0": ">=0.7.0",
65-
"lodash-es@>=4.0.0 <=4.17.22": ">=4.17.23",
66-
"lodash@>=4.0.0 <=4.17.22": ">=4.17.23",
65+
"lodash@>=4.0.0 <=4.17.23": ">=4.18.0",
6766
"@better-auth/core": "1.4.19"
6867
}
6968
},

packages/auth-adapters/better-auth/src/schema-generator.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function addDefaultNow(df: DataField) {
132132
} as any;
133133
const nowExpr: InvocationExpr = {
134134
$type: 'InvocationExpr',
135-
function: { $refText: 'now' },
135+
function: { $refText: 'now', ref: undefined },
136136
args: [],
137137
$container: nowArg,
138138
};
@@ -221,6 +221,7 @@ function initializeZmodel(config: AdapterConfig) {
221221
$type: 'InvocationExpr',
222222
function: {
223223
$refText: 'env',
224+
ref: undefined,
224225
},
225226
args: [],
226227
$container: urlField,
@@ -391,6 +392,7 @@ function addOrUpdateModel(
391392
$type: 'DataFieldType',
392393
reference: {
393394
$refText: upperCaseFirst(referencedCustomModelName),
395+
ref: undefined,
394396
},
395397
array: (field.type as string).endsWith('[]'),
396398
optional: !field.required,
@@ -408,6 +410,7 @@ function addOrUpdateModel(
408410
$type: 'DataFieldAttribute',
409411
decl: {
410412
$refText: '@relation',
413+
ref: undefined,
411414
},
412415
args: [],
413416
$container: relationField,
@@ -430,6 +433,7 @@ function addOrUpdateModel(
430433
$container: fieldsExpr,
431434
target: {
432435
$refText: fieldName,
436+
ref: undefined,
433437
},
434438
};
435439
fieldsExpr.items.push(fkRefExpr);
@@ -452,6 +456,7 @@ function addOrUpdateModel(
452456
$container: referencesExpr,
453457
target: {
454458
$refText: field.references.field,
459+
ref: undefined,
455460
},
456461
};
457462
referencesExpr.items.push(pkRefExpr);
@@ -465,7 +470,7 @@ function addOrUpdateModel(
465470
} as any;
466471
const onDeleteValueExpr: ReferenceExpr = {
467472
$type: 'ReferenceExpr',
468-
target: { $refText: action },
473+
target: { $refText: action, ref: undefined },
469474
args: [],
470475
$container: onDeleteArg,
471476
};
@@ -495,6 +500,7 @@ function addOrUpdateModel(
495500
$type: 'DataFieldType',
496501
reference: {
497502
$refText: relatedModel,
503+
ref: undefined,
498504
},
499505
array: true,
500506
optional: false,
@@ -512,7 +518,7 @@ function addOrUpdateModel(
512518
function addModelAttribute(dataModel: DataModel, name: string, args: Omit<AttributeArg, '$container'>[] = []) {
513519
const attr: DataModelAttribute = {
514520
$type: 'DataModelAttribute',
515-
decl: { $refText: name },
521+
decl: { $refText: name, ref: undefined },
516522
$container: dataModel,
517523
args: [],
518524
};
@@ -527,7 +533,7 @@ function addModelAttribute(dataModel: DataModel, name: string, args: Omit<Attrib
527533
function addFieldAttribute(dataField: DataField, name: string, args: Omit<AttributeArg, '$container'>[] = []) {
528534
const attr: DataFieldAttribute = {
529535
$type: 'DataFieldAttribute',
530-
decl: { $refText: name },
536+
decl: { $refText: name, ref: undefined },
531537
$container: dataField,
532538
args: [],
533539
};

packages/cli/src/actions/check.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function checkPluginResolution(schemaFile: string, model: Model) {
3030
const provider = getPluginProvider(plugin);
3131
if (!provider.startsWith('@core/')) {
3232
const pluginSourcePath =
33-
plugin.$cstNode?.parent?.element.$document?.uri?.fsPath ?? schemaFile;
33+
plugin.$cstNode?.container?.astNode.$document?.uri?.fsPath ?? schemaFile;
3434
await loadPluginModule(provider, path.dirname(pluginSourcePath));
3535
}
3636
}

packages/cli/src/actions/db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ async function runPull(options: PullOptions) {
267267
});
268268
// Add/update models and their fields
269269
newModel.declarations
270-
.filter((d) => [DataModel, Enum].includes(d.$type))
270+
.filter((d) => d.$type === DataModel.$type || d.$type === Enum.$type)
271271
.forEach((_declaration) => {
272272
const newDataModel = _declaration as DataModel | Enum;
273273
const declarations = services.shared.workspace.IndexManager.allElements(newDataModel.$type, docsSet).toArray();

packages/cli/src/actions/generate.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ export async function run(options: Options) {
6363
(
6464
model.declarations.filter(
6565
(v) =>
66-
v.$cstNode?.parent?.element.$type === 'Model' &&
67-
!!v.$cstNode.parent.element.$document?.uri?.fsPath,
66+
v.$cstNode?.container?.astNode.$type === 'Model' &&
67+
!!v.$cstNode.container.astNode.$document?.uri?.fsPath,
6868
) as AbstractDeclaration[]
69-
).map((v) => v.$cstNode!.parent!.element.$document!.uri!.fsPath),
69+
).map((v) => v.$cstNode!.container!.astNode.$document!.uri!.fsPath),
7070
);
7171

7272
const watchedPaths = getRootModelWatchPaths(model);
@@ -189,7 +189,7 @@ async function runPlugins(schemaFile: string, model: Model, outputPath: string,
189189
// resolve relative plugin paths against the schema file where the plugin is declared,
190190
// not the entry schema file
191191
const pluginSourcePath =
192-
plugin.$cstNode?.parent?.element.$document?.uri?.fsPath ?? schemaFile;
192+
plugin.$cstNode?.container?.astNode.$document?.uri?.fsPath ?? schemaFile;
193193
cliPlugin = await loadPluginModule(provider, path.dirname(pluginSourcePath));
194194
}
195195

packages/language/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"vscode-languageserver": "^9.0.1"
8282
},
8383
"devDependencies": {
84+
"@types/node": "catalog:",
8485
"@types/pluralize": "^0.0.33",
8586
"@types/tmp": "catalog:",
8687
"@zenstackhq/eslint-config": "workspace:*",

packages/language/src/document.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ function validationAfterImportMerge(model: Model) {
251251
export async function formatDocument(content: string) {
252252
const services = createZModelServices().ZModelLanguage;
253253
const langiumDocuments = services.shared.workspace.LangiumDocuments;
254-
const document = langiumDocuments.createDocument(URI.parse('memory://schema.zmodel'), content);
254+
const document = langiumDocuments.createDocument(URI.parse('memory:///schema.zmodel'), content);
255255
const formatter = services.lsp.Formatter as ZModelFormatter;
256256
const identifier = { uri: document.uri.toString() };
257257
const options = formatter.getFormatOptions() ?? {

packages/language/src/factory/attribute.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class DataFieldAttributeFactory extends AstFactory<DataFieldAttribute> {
1818
args: AttributeArgFactory[] = [];
1919
decl?: Reference<Attribute>;
2020
constructor() {
21-
super({ type: DataFieldAttribute, node: { args: [] } });
21+
super({ type: DataFieldAttribute.$type, node: { args: [] } });
2222
}
2323
setDecl(decl: Attribute) {
2424
if (!decl) {
@@ -50,7 +50,7 @@ export class DataModelAttributeFactory extends AstFactory<DataModelAttribute> {
5050
args: AttributeArgFactory[] = [];
5151
decl?: Reference<Attribute>;
5252
constructor() {
53-
super({ type: DataModelAttribute, node: { args: [] } });
53+
super({ type: DataModelAttribute.$type, node: { args: [] } });
5454
}
5555
setDecl(decl: Attribute) {
5656
if (!decl) {
@@ -83,7 +83,7 @@ export class AttributeArgFactory extends AstFactory<AttributeArg> {
8383
value?: AstFactory<Expression>;
8484

8585
constructor() {
86-
super({ type: AttributeArg });
86+
super({ type: AttributeArg.$type });
8787
}
8888

8989
setName(name: RegularID) {
@@ -108,7 +108,7 @@ export class InternalAttributeFactory extends AstFactory<InternalAttribute> {
108108
args: AttributeArgFactory[] = [];
109109

110110
constructor() {
111-
super({ type: InternalAttribute, node: { args: [] } });
111+
super({ type: InternalAttribute.$type, node: { args: [] } });
112112
}
113113

114114
setDecl(decl: Attribute) {
@@ -144,7 +144,7 @@ export class AttributeParamFactory extends AstFactory<AttributeParam> {
144144

145145
constructor() {
146146
super({
147-
type: AttributeParam,
147+
type: AttributeParam.$type,
148148
node: {
149149
comments: [],
150150
attributes: [],
@@ -199,7 +199,7 @@ export class AttributeParamTypeFactory extends AstFactory<AttributeParamType> {
199199
reference?: Reference<TypeDeclaration>;
200200
type?: AttributeParamType['type'];
201201
constructor() {
202-
super({ type: AttributeParamType });
202+
super({ type: AttributeParamType.$type });
203203
}
204204
setArray(array: boolean) {
205205
this.array = array;
@@ -244,7 +244,7 @@ export class AttributeFactory extends AstFactory<Attribute> {
244244
params: AttributeParamFactory[] = [];
245245

246246
constructor() {
247-
super({ type: Attribute, node: { comments: [], attributes: [], params: [] } });
247+
super({ type: Attribute.$type, node: { comments: [], attributes: [], params: [] } });
248248
}
249249

250250
setName(name: string) {

packages/language/src/factory/declaration.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class DataModelFactory extends AstFactory<DataModel> {
6969

7070
constructor() {
7171
super({
72-
type: DataModel,
72+
type: DataModel.$type,
7373
node: {
7474
attributes: [],
7575
comments: [],
@@ -151,7 +151,7 @@ export class DataFieldFactory extends AstFactory<DataField> {
151151
type?: DataFieldTypeFactory;
152152

153153
constructor() {
154-
super({ type: DataField, node: { attributes: [], comments: [] } });
154+
super({ type: DataField.$type, node: { attributes: [], comments: [] } });
155155
}
156156

157157
addAttribute(
@@ -204,7 +204,7 @@ export class DataFieldTypeFactory extends AstFactory<DataFieldType> {
204204
unsupported?: UnsupportedFieldTypeFactory;
205205

206206
constructor() {
207-
super({ type: DataFieldType });
207+
super({ type: DataFieldType.$type });
208208
}
209209

210210
setArray(array: boolean) {
@@ -254,7 +254,7 @@ export class DataFieldTypeFactory extends AstFactory<DataFieldType> {
254254
export class UnsupportedFieldTypeFactory extends AstFactory<UnsupportedFieldType> {
255255
value?: AstFactory<LiteralExpr>;
256256
constructor() {
257-
super({ type: UnsupportedFieldType });
257+
super({ type: UnsupportedFieldType.$type });
258258
}
259259
setValue(builder: (value: ExpressionBuilder<LiteralExpr>) => AstFactory<LiteralExpr>) {
260260
this.value = builder(ExpressionBuilder());
@@ -269,7 +269,7 @@ export class ModelFactory extends AstFactory<Model> {
269269
declarations: AstFactory<AbstractDeclaration>[] = [];
270270
imports: ModelImportFactory[] = [];
271271
constructor() {
272-
super({ type: Model, node: { declarations: [], imports: [] } });
272+
super({ type: Model.$type, node: { declarations: [], imports: [] } });
273273
}
274274
addImport(builder: (b: ModelImportFactory) => ModelImportFactory) {
275275
this.imports.push(builder(new ModelImportFactory()).setContainer(this.node));
@@ -291,7 +291,7 @@ export class ModelImportFactory extends AstFactory<ModelImport> {
291291
path?: string | undefined;
292292

293293
constructor() {
294-
super({ type: ModelImport });
294+
super({ type: ModelImport.$type });
295295
}
296296

297297
setPath(path: string) {
@@ -310,7 +310,7 @@ export class EnumFactory extends AstFactory<Enum> {
310310
attributes: DataModelAttributeFactory[] = [];
311311

312312
constructor() {
313-
super({ type: Enum, node: { comments: [], fields: [], attributes: [] } });
313+
super({ type: Enum.$type, node: { comments: [], fields: [], attributes: [] } });
314314
}
315315

316316
addField(builder: (b: EnumFieldFactory) => EnumFieldFactory) {
@@ -344,7 +344,7 @@ export class EnumFieldFactory extends AstFactory<EnumField> {
344344
attributes: DataFieldAttributeFactory[] = [];
345345

346346
constructor() {
347-
super({ type: EnumField, node: { comments: [], attributes: [] } });
347+
super({ type: EnumField.$type, node: { comments: [], attributes: [] } });
348348
}
349349

350350
setName(name: RegularIDWithTypeNames) {

packages/language/src/factory/expression.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class UnaryExprFactory extends AstFactory<UnaryExpr> {
7979
operand?: AstFactory<Expression>;
8080

8181
constructor() {
82-
super({ type: UnaryExpr, node: { operator: '!' } });
82+
super({ type: UnaryExpr.$type, node: { operator: '!' } });
8383
}
8484

8585
setOperand(builder: (a: ExpressionBuilder) => AstFactory<Expression>) {
@@ -96,7 +96,7 @@ export class ReferenceExprFactory extends AstFactory<ReferenceExpr> {
9696
args: ReferenceArgFactory[] = [];
9797

9898
constructor() {
99-
super({ type: ReferenceExpr, node: { args: [] } });
99+
super({ type: ReferenceExpr.$type, node: { args: [] } });
100100
}
101101

102102
setTarget(target: ReferenceTarget) {
@@ -128,7 +128,7 @@ export class ReferenceArgFactory extends AstFactory<ReferenceArg> {
128128
value?: AstFactory<Expression>;
129129

130130
constructor() {
131-
super({ type: ReferenceArg });
131+
super({ type: ReferenceArg.$type });
132132
}
133133

134134
setName(name: string) {
@@ -153,7 +153,7 @@ export class MemberAccessExprFactory extends AstFactory<MemberAccessExpr> {
153153
operand?: AstFactory<Expression>;
154154

155155
constructor() {
156-
super({ type: MemberAccessExpr });
156+
super({ type: MemberAccessExpr.$type });
157157
}
158158

159159
setMember(target: Reference<MemberAccessTarget>) {
@@ -177,7 +177,7 @@ export class ObjectExprFactory extends AstFactory<ObjectExpr> {
177177
fields: FieldInitializerFactory[] = [];
178178

179179
constructor() {
180-
super({ type: ObjectExpr, node: { fields: [] } });
180+
super({ type: ObjectExpr.$type, node: { fields: [] } });
181181
}
182182

183183
addField(builder: (b: FieldInitializerFactory) => FieldInitializerFactory) {
@@ -194,7 +194,7 @@ export class FieldInitializerFactory extends AstFactory<FieldInitializer> {
194194
value?: AstFactory<Expression>;
195195

196196
constructor() {
197-
super({ type: FieldInitializer });
197+
super({ type: FieldInitializer.$type });
198198
}
199199

200200
setName(name: RegularID) {
@@ -219,7 +219,7 @@ export class InvocationExprFactory extends AstFactory<InvocationExpr> {
219219
function?: Reference<FunctionDecl>;
220220

221221
constructor() {
222-
super({ type: InvocationExpr, node: { args: [] } });
222+
super({ type: InvocationExpr.$type, node: { args: [] } });
223223
}
224224

225225
addArg(builder: (arg: ArgumentFactory) => ArgumentFactory) {
@@ -246,7 +246,7 @@ export class ArgumentFactory extends AstFactory<Argument> {
246246
value?: AstFactory<Expression>;
247247

248248
constructor() {
249-
super({ type: Argument });
249+
super({ type: Argument.$type });
250250
}
251251

252252
setValue(builder: (a: ExpressionBuilder) => AstFactory<Expression>) {
@@ -262,7 +262,7 @@ export class ArrayExprFactory extends AstFactory<ArrayExpr> {
262262
items: AstFactory<Expression>[] = [];
263263

264264
constructor() {
265-
super({ type: ArrayExpr, node: { items: [] } });
265+
super({ type: ArrayExpr.$type, node: { items: [] } });
266266
}
267267

268268
addItem(builder: (a: ExpressionBuilder) => AstFactory<Expression>) {
@@ -281,7 +281,7 @@ export class BinaryExprFactory extends AstFactory<BinaryExpr> {
281281
// TODO: add support for CollectionPredicateBinding
282282

283283
constructor() {
284-
super({ type: BinaryExpr });
284+
super({ type: BinaryExpr.$type });
285285
}
286286

287287
setOperator(operator: BinaryExpr['operator']) {

0 commit comments

Comments
 (0)