silgi 0.20.28 → 0.20.30

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.
@@ -1,4 +1,4 @@
1
- const version = "0.20.28";
1
+ const version = "0.20.30";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -342,147 +342,125 @@ async function nuxtFramework(silgi, skip = false) {
342
342
  const frameworkSetup = [emptyFramework, h3Framework, nitroFramework, nuxtFramework];
343
343
 
344
344
  async function registerModuleExportScan(silgi) {
345
- for (const module of silgi.scanModules) {
346
- const moduleReExports = [];
347
- const moduleTypes = await promises.readFile(module.entryPath.replace(/\.mjs$/, "Types.d.ts"), "utf8").catch(() => "");
348
- const normalisedModuleTypes = moduleTypes.replace(/export\s*\{.*?\}/gs, (match) => match.replace(/\b(type|interface)\b/g, ""));
349
- for (const e of findTypeExports(normalisedModuleTypes)) {
350
- moduleReExports.push(e);
351
- }
352
- for (const e of findExports(normalisedModuleTypes)) {
353
- moduleReExports.push(e);
354
- }
355
- const hasTypeExport = (name) => moduleReExports.find((exp) => exp.names?.includes(name));
356
- const configKey = module.meta.configKey;
357
- const moduleName = module.meta.name || module.meta._packageName;
358
- silgi.hook("prepare:schema.ts", async (options) => {
345
+ silgi.hook("prepare:schema.ts", async (options) => {
346
+ for (const module of silgi.scanModules) {
347
+ const moduleReExports = [];
348
+ const moduleTypes = await promises.readFile(module.entryPath.replace(/\.mjs$/, "Types.d.ts"), "utf8").catch(() => "");
349
+ const normalisedModuleTypes = moduleTypes.replace(/export\s*\{.*?\}/gs, (match) => match.replace(/\b(type|interface)\b/g, ""));
350
+ for (const e of findTypeExports(normalisedModuleTypes)) {
351
+ moduleReExports.push(e);
352
+ }
353
+ for (const e of findExports(normalisedModuleTypes)) {
354
+ moduleReExports.push(e);
355
+ }
356
+ const hasTypeExport = (name) => moduleReExports.find((exp) => exp.names?.includes(name));
357
+ const configKey = module.meta.configKey;
358
+ const moduleName = module.meta.name || module.meta._packageName;
359
359
  options.importItems[configKey] = {
360
360
  import: [],
361
361
  from: module.meta._packageName ? moduleName : relativeWithDot(silgi.options.build.typesDir, module.entryPath)
362
362
  };
363
- });
364
- if (hasTypeExport("ModuleOptions")) {
365
- const importName = `_${hash(`${configKey}ModuleOptions`)}`;
366
- silgi.hook("prepare:schema.ts", async (options) => {
363
+ if (hasTypeExport("ModuleOptions")) {
364
+ const importName = `_${hash(`${configKey}ModuleOptions`)}`;
367
365
  options.importItems[configKey].import.push({
368
366
  name: `ModuleOptions as ${importName}`,
369
367
  type: true,
370
368
  key: importName
371
369
  });
372
370
  options.options.push({ key: configKey, value: importName });
373
- });
374
- }
375
- if (hasTypeExport("ModuleRuntimeOptions")) {
376
- const importName = `_${hash(`${configKey}ModuleRuntimeOptions`)}`;
377
- silgi.hook("prepare:schema.ts", async (options) => {
371
+ }
372
+ if (hasTypeExport("ModuleRuntimeOptions")) {
373
+ const importName = `_${hash(`${configKey}ModuleRuntimeOptions`)}`;
378
374
  options.importItems[configKey].import.push({
379
375
  name: `ModuleRuntimeOptions as ${importName}`,
380
376
  type: true,
381
377
  key: importName
382
378
  });
383
379
  options.runtimeOptions.push({ key: configKey, value: importName });
384
- });
385
- }
386
- if (hasTypeExport("ModuleRuntimeShareds")) {
387
- const importName = `_${hash(`${configKey}ModuleRuntimeShareds`)}`;
388
- silgi.hook("prepare:schema.ts", async (options) => {
380
+ }
381
+ if (hasTypeExport("ModuleRuntimeShareds")) {
382
+ const importName = `_${hash(`${configKey}ModuleRuntimeShareds`)}`;
389
383
  options.importItems[configKey].import.push({
390
384
  name: `ModuleRuntimeShareds as ${importName}`,
391
385
  type: true,
392
386
  key: importName
393
387
  });
394
388
  options.shareds.push({ key: configKey, value: importName });
395
- });
396
- }
397
- if (hasTypeExport("ModuleEvents")) {
398
- const importName = `_${hash(`${configKey}ModuleEvents`)}`;
399
- silgi.hook("prepare:schema.ts", async (options) => {
389
+ }
390
+ if (hasTypeExport("ModuleEvents")) {
391
+ const importName = `_${hash(`${configKey}ModuleEvents`)}`;
400
392
  options.importItems[configKey].import.push({
401
393
  name: `ModuleEvents as ${importName}`,
402
394
  type: true,
403
395
  key: importName
404
396
  });
405
397
  options.events.push({ key: configKey, value: importName });
406
- });
407
- }
408
- if (hasTypeExport("ModuleRuntimeContexts")) {
409
- const importName = `_${hash(`${configKey}ModuleRuntimeContexts`)}`;
410
- silgi.hook("prepare:schema.ts", async (options) => {
398
+ }
399
+ if (hasTypeExport("ModuleRuntimeContexts")) {
400
+ const importName = `_${hash(`${configKey}ModuleRuntimeContexts`)}`;
411
401
  options.importItems[configKey].import.push({
412
402
  name: `ModuleRuntimeContexts as ${importName}`,
413
403
  type: true,
414
404
  key: importName
415
405
  });
416
406
  options.contexts.push({ key: configKey, value: importName });
417
- });
418
- }
419
- if (hasTypeExport("ModuleHooks")) {
420
- const importName = `_${hash(`${configKey}ModuleHooks`)}`;
421
- silgi.hook("prepare:schema.ts", async (options) => {
407
+ }
408
+ if (hasTypeExport("ModuleHooks")) {
409
+ const importName = `_${hash(`${configKey}ModuleHooks`)}`;
422
410
  options.importItems[configKey].import.push({
423
411
  name: `ModuleHooks as ${importName}`,
424
412
  type: true,
425
413
  key: importName
426
414
  });
427
415
  options.hooks.push({ key: configKey, value: importName });
428
- });
429
- }
430
- if (hasTypeExport("ModuleRuntimeHooks")) {
431
- const importName = `_${hash(`${configKey}RuntimeHooks`)}`;
432
- silgi.hook("prepare:schema.ts", async (options) => {
416
+ }
417
+ if (hasTypeExport("ModuleRuntimeHooks")) {
418
+ const importName = `_${hash(`${configKey}RuntimeHooks`)}`;
433
419
  options.importItems[configKey].import.push({
434
420
  name: `ModuleRuntimeHooks as ${importName}`,
435
421
  type: true,
436
422
  key: importName
437
423
  });
438
424
  options.runtimeHooks.push({ key: configKey, value: importName });
439
- });
440
- }
441
- if (hasTypeExport("ModuleRuntimeActions")) {
442
- const importName = `_${hash(`${configKey}ModuleRuntimeActions`)}`;
443
- silgi.hook("prepare:schema.ts", async (options) => {
425
+ }
426
+ if (hasTypeExport("ModuleRuntimeActions")) {
427
+ const importName = `_${hash(`${configKey}ModuleRuntimeActions`)}`;
444
428
  options.importItems[configKey].import.push({
445
429
  name: `ModuleRuntimeActions as ${importName}`,
446
430
  type: true,
447
431
  key: importName
448
432
  });
449
433
  options.actions.push({ key: configKey, value: importName });
450
- });
451
- }
452
- if (hasTypeExport("ModuleRuntimeMethods")) {
453
- const importName = `_${hash(`${configKey}ModuleRuntimeMethods`)}`;
454
- silgi.hook("prepare:schema.ts", async (options) => {
434
+ }
435
+ if (hasTypeExport("ModuleRuntimeMethods")) {
436
+ const importName = `_${hash(`${configKey}ModuleRuntimeMethods`)}`;
455
437
  options.importItems[configKey].import.push({
456
438
  name: `ModuleRuntimeMethods as ${importName}`,
457
439
  type: true,
458
440
  key: importName
459
441
  });
460
442
  options.methods.push({ key: configKey, value: importName });
461
- });
462
- }
463
- if (hasTypeExport("ModuleRuntimeRouteRules")) {
464
- const importName = `_${hash(`${configKey}ModuleRuntimeRouteRules`)}`;
465
- silgi.hook("prepare:schema.ts", async (options) => {
443
+ }
444
+ if (hasTypeExport("ModuleRuntimeRouteRules")) {
445
+ const importName = `_${hash(`${configKey}ModuleRuntimeRouteRules`)}`;
466
446
  options.importItems[configKey].import.push({
467
447
  name: `ModuleRuntimeRouteRules as ${importName}`,
468
448
  type: true,
469
449
  key: importName
470
450
  });
471
451
  options.routeRules.push({ key: configKey, value: importName });
472
- });
473
- }
474
- if (hasTypeExport("ModuleRuntimeRouteRulesConfig")) {
475
- const importName = `_${hash(`${configKey}ModuleRuntimeRouteRulesConfig`)}`;
476
- silgi.hook("prepare:schema.ts", async (options) => {
452
+ }
453
+ if (hasTypeExport("ModuleRuntimeRouteRulesConfig")) {
454
+ const importName = `_${hash(`${configKey}ModuleRuntimeRouteRulesConfig`)}`;
477
455
  options.importItems[configKey].import.push({
478
456
  name: `ModuleRuntimeRouteRulesConfig as ${importName}`,
479
457
  type: true,
480
458
  key: importName
481
459
  });
482
460
  options.routeRulesConfig.push({ key: configKey, value: importName });
483
- });
461
+ }
484
462
  }
485
- }
463
+ });
486
464
  }
487
465
 
488
466
  async function loadSilgiModuleInstance(silgiModule) {
@@ -945,10 +923,6 @@ async function prepareServerFiles(silgi) {
945
923
  defu$1(scanned.modulesURIs, silgi.modulesURIs);
946
924
  }
947
925
  await silgi.callHook("prepare:scan.ts", scanned);
948
- scanned.services = [...new Set(scanned.services)];
949
- scanned.shareds = [...new Set(scanned.shareds)];
950
- scanned.schemas = [...new Set(scanned.schemas)];
951
- scanned.customImports = [...new Set(scanned.customImports)];
952
926
  if (importItems["#silgi/vfs"].import.length === 0) {
953
927
  delete importItems["#silgi/vfs"];
954
928
  }
@@ -1265,136 +1239,77 @@ async function scanFiles$1(silgi, watchFiles) {
1265
1239
  if (hasError("Parser", silgi)) {
1266
1240
  return;
1267
1241
  }
1242
+ const scanTS = [];
1243
+ const schemaTS = [];
1268
1244
  if (createServices.length > 0) {
1269
- for (const createService of createServices) {
1270
- const { exportName, path } = createService;
1245
+ scanTS.push(...createServices.map(({ exportName, path }) => {
1271
1246
  silgi.options.devServer.watch.push(path);
1272
1247
  const randomString = hash(basename(path) + exportName);
1273
1248
  const _name = `_v${randomString}`;
1274
- silgi.hook("prepare:scan.ts", (options) => {
1275
- options.services.push(_name);
1276
- });
1277
- silgi.hook("prepare:scan.ts", (options) => {
1278
- options.importItems[path] ??= {
1279
- import: [],
1280
- from: relativeWithDot(silgi.options.silgi.serverDir, path)
1281
- };
1282
- options.importItems[path].import.push({
1283
- name: `${exportName} as ${_name}`,
1284
- key: _name
1285
- });
1286
- });
1287
- }
1249
+ return { exportName, path, _name, type: "service" };
1250
+ }));
1288
1251
  }
1289
1252
  const createSchemas = exportVariables("createSchema", filePath);
1290
1253
  if (hasError("Parser", silgi)) {
1291
1254
  return;
1292
1255
  }
1293
1256
  if (createSchemas.length > 0) {
1294
- for (const createSchema of createSchemas) {
1295
- const { exportName, path } = createSchema;
1257
+ scanTS.push(...createSchemas.map(({ exportName, path }) => {
1296
1258
  silgi.options.devServer.watch.push(path);
1297
1259
  const randomString = hash(basename(path) + exportName);
1298
1260
  const _name = `_v${randomString}`;
1299
- silgi.hook("prepare:scan.ts", (options) => {
1300
- options.schemas.push(_name);
1301
- });
1302
- silgi.hook("prepare:scan.ts", (options) => {
1303
- options.importItems[path] ??= {
1304
- import: [],
1305
- from: relativeWithDot(silgi.options.silgi.serverDir, path)
1306
- };
1307
- options.importItems[path].import.push({
1308
- name: `${exportName} as ${_name}`,
1309
- key: _name
1310
- });
1311
- });
1312
- }
1261
+ return { exportName, path, _name, type: "schema" };
1262
+ }));
1313
1263
  }
1314
1264
  const createShareds = exportVariables("createShared", filePath);
1315
1265
  if (hasError("Parser", silgi)) {
1316
1266
  return;
1317
1267
  }
1318
1268
  if (createShareds.length > 0) {
1319
- for (const createShared of createShareds) {
1320
- const { exportName, path } = createShared;
1269
+ scanTS.push(...createShareds.map(({ exportName, path }) => {
1321
1270
  silgi.options.devServer.watch.push(path);
1322
1271
  const randomString = hash(basename(path) + exportName);
1323
1272
  const _name = `_v${randomString}`;
1324
- silgi.hook("prepare:scan.ts", (options) => {
1325
- options.shareds.push(_name);
1326
- });
1327
- silgi.hook("prepare:scan.ts", (options) => {
1328
- options.importItems[path] ??= {
1329
- import: [],
1330
- // Relative path kaldirmamiz gerekiyor bunlar hooklarin bittigi yerde karar verilmeli.
1331
- from: relativeWithDot(silgi.options.silgi.serverDir, path)
1332
- };
1333
- options.importItems[path].import.push({
1334
- name: `${exportName} as ${_name}`,
1335
- key: _name
1336
- });
1337
- });
1338
- }
1273
+ return { exportName, path, _name, type: "shared" };
1274
+ }));
1339
1275
  }
1340
1276
  const sharedsTypes = parseInterfaceDeclarations("ExtendShared", filePath);
1341
1277
  if (hasError("Parser", silgi)) {
1342
1278
  return;
1343
1279
  }
1344
1280
  if (sharedsTypes.length > 0) {
1345
- for (const sharedType of sharedsTypes) {
1346
- const { exportName, path } = sharedType;
1281
+ schemaTS.push(...sharedsTypes.map(({ exportName, path }) => {
1347
1282
  silgi.options.devServer.watch.push(path);
1348
1283
  const randomString = hash(basename(path) + exportName);
1349
1284
  const _name = `_v${randomString}`;
1350
- silgi.hook("prepare:schema.ts", (options) => {
1351
- options.shareds.push({
1352
- key: _name,
1353
- value: _name
1354
- });
1355
- });
1356
- silgi.hook("prepare:schema.ts", (options) => {
1357
- options.importItems[path] ??= {
1358
- import: [],
1359
- from: path
1360
- };
1361
- options.importItems[path].import.push({
1362
- name: `${exportName} as ${_name}`,
1363
- type: true,
1364
- key: _name
1365
- });
1366
- });
1367
- }
1285
+ return { exportName, path, _name, type: "shared" };
1286
+ }));
1368
1287
  }
1369
1288
  const contextTypes = parseInterfaceDeclarations("ExtendContext", filePath);
1370
1289
  if (hasError("Parser", silgi)) {
1371
1290
  return;
1372
1291
  }
1373
1292
  if (contextTypes.length > 0) {
1374
- for (const contextType of contextTypes) {
1375
- const { exportName, path } = contextType;
1293
+ schemaTS.push(...contextTypes.map(({ exportName, path }) => {
1376
1294
  silgi.options.devServer.watch.push(path);
1377
1295
  const randomString = hash(basename(path) + exportName);
1378
1296
  const _name = `_v${randomString}`;
1379
- silgi.hook("prepare:schema.ts", (options) => {
1380
- options.contexts.push({
1381
- key: _name,
1382
- value: _name
1383
- });
1384
- });
1385
- silgi.hook("prepare:schema.ts", (options) => {
1386
- options.importItems[path] ??= {
1387
- import: [],
1388
- from: path
1389
- };
1390
- options.importItems[path].import.push({
1391
- name: `${exportName} as ${_name}`,
1392
- type: true,
1393
- key: _name
1394
- });
1297
+ return { exportName, path, _name, type: "context" };
1298
+ }));
1299
+ }
1300
+ silgi.hook("prepare:scan.ts", (options) => {
1301
+ for (const { exportName, path, _name, type } of scanTS) {
1302
+ options.schemas.push(_name);
1303
+ options.importItems[path] ??= {
1304
+ import: [],
1305
+ from: relativeWithDot(silgi.options.silgi.serverDir, path)
1306
+ };
1307
+ options.importItems[path].import.push({
1308
+ name: `${exportName} as ${_name}`,
1309
+ key: _name
1395
1310
  });
1396
1311
  }
1397
- }
1312
+ });
1398
1313
  }
1399
1314
  }
1400
1315
  }
@@ -1,4 +1,4 @@
1
- const version = "0.20.28";
1
+ const version = "0.20.30";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -1,4 +1,4 @@
1
- const version = "0.20.28";
1
+ const version = "0.20.30";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.20.28",
4
+ "version": "0.20.30",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {