silgi 0.20.29 → 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.29";
1
+ const version = "0.20.30";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -923,10 +923,6 @@ async function prepareServerFiles(silgi) {
923
923
  defu$1(scanned.modulesURIs, silgi.modulesURIs);
924
924
  }
925
925
  await silgi.callHook("prepare:scan.ts", scanned);
926
- scanned.services = [...new Set(scanned.services)];
927
- scanned.shareds = [...new Set(scanned.shareds)];
928
- scanned.schemas = [...new Set(scanned.schemas)];
929
- scanned.customImports = [...new Set(scanned.customImports)];
930
926
  if (importItems["#silgi/vfs"].import.length === 0) {
931
927
  delete importItems["#silgi/vfs"];
932
928
  }
@@ -1243,136 +1239,77 @@ async function scanFiles$1(silgi, watchFiles) {
1243
1239
  if (hasError("Parser", silgi)) {
1244
1240
  return;
1245
1241
  }
1242
+ const scanTS = [];
1243
+ const schemaTS = [];
1246
1244
  if (createServices.length > 0) {
1247
- for (const createService of createServices) {
1248
- const { exportName, path } = createService;
1245
+ scanTS.push(...createServices.map(({ exportName, path }) => {
1249
1246
  silgi.options.devServer.watch.push(path);
1250
1247
  const randomString = hash(basename(path) + exportName);
1251
1248
  const _name = `_v${randomString}`;
1252
- silgi.hook("prepare:scan.ts", (options) => {
1253
- options.services.push(_name);
1254
- });
1255
- silgi.hook("prepare:scan.ts", (options) => {
1256
- options.importItems[path] ??= {
1257
- import: [],
1258
- from: relativeWithDot(silgi.options.silgi.serverDir, path)
1259
- };
1260
- options.importItems[path].import.push({
1261
- name: `${exportName} as ${_name}`,
1262
- key: _name
1263
- });
1264
- });
1265
- }
1249
+ return { exportName, path, _name, type: "service" };
1250
+ }));
1266
1251
  }
1267
1252
  const createSchemas = exportVariables("createSchema", filePath);
1268
1253
  if (hasError("Parser", silgi)) {
1269
1254
  return;
1270
1255
  }
1271
1256
  if (createSchemas.length > 0) {
1272
- for (const createSchema of createSchemas) {
1273
- const { exportName, path } = createSchema;
1257
+ scanTS.push(...createSchemas.map(({ exportName, path }) => {
1274
1258
  silgi.options.devServer.watch.push(path);
1275
1259
  const randomString = hash(basename(path) + exportName);
1276
1260
  const _name = `_v${randomString}`;
1277
- silgi.hook("prepare:scan.ts", (options) => {
1278
- options.schemas.push(_name);
1279
- });
1280
- silgi.hook("prepare:scan.ts", (options) => {
1281
- options.importItems[path] ??= {
1282
- import: [],
1283
- from: relativeWithDot(silgi.options.silgi.serverDir, path)
1284
- };
1285
- options.importItems[path].import.push({
1286
- name: `${exportName} as ${_name}`,
1287
- key: _name
1288
- });
1289
- });
1290
- }
1261
+ return { exportName, path, _name, type: "schema" };
1262
+ }));
1291
1263
  }
1292
1264
  const createShareds = exportVariables("createShared", filePath);
1293
1265
  if (hasError("Parser", silgi)) {
1294
1266
  return;
1295
1267
  }
1296
1268
  if (createShareds.length > 0) {
1297
- for (const createShared of createShareds) {
1298
- const { exportName, path } = createShared;
1269
+ scanTS.push(...createShareds.map(({ exportName, path }) => {
1299
1270
  silgi.options.devServer.watch.push(path);
1300
1271
  const randomString = hash(basename(path) + exportName);
1301
1272
  const _name = `_v${randomString}`;
1302
- silgi.hook("prepare:scan.ts", (options) => {
1303
- options.shareds.push(_name);
1304
- });
1305
- silgi.hook("prepare:scan.ts", (options) => {
1306
- options.importItems[path] ??= {
1307
- import: [],
1308
- // Relative path kaldirmamiz gerekiyor bunlar hooklarin bittigi yerde karar verilmeli.
1309
- from: relativeWithDot(silgi.options.silgi.serverDir, path)
1310
- };
1311
- options.importItems[path].import.push({
1312
- name: `${exportName} as ${_name}`,
1313
- key: _name
1314
- });
1315
- });
1316
- }
1273
+ return { exportName, path, _name, type: "shared" };
1274
+ }));
1317
1275
  }
1318
1276
  const sharedsTypes = parseInterfaceDeclarations("ExtendShared", filePath);
1319
1277
  if (hasError("Parser", silgi)) {
1320
1278
  return;
1321
1279
  }
1322
1280
  if (sharedsTypes.length > 0) {
1323
- for (const sharedType of sharedsTypes) {
1324
- const { exportName, path } = sharedType;
1281
+ schemaTS.push(...sharedsTypes.map(({ exportName, path }) => {
1325
1282
  silgi.options.devServer.watch.push(path);
1326
1283
  const randomString = hash(basename(path) + exportName);
1327
1284
  const _name = `_v${randomString}`;
1328
- silgi.hook("prepare:schema.ts", (options) => {
1329
- options.shareds.push({
1330
- key: _name,
1331
- value: _name
1332
- });
1333
- });
1334
- silgi.hook("prepare:schema.ts", (options) => {
1335
- options.importItems[path] ??= {
1336
- import: [],
1337
- from: path
1338
- };
1339
- options.importItems[path].import.push({
1340
- name: `${exportName} as ${_name}`,
1341
- type: true,
1342
- key: _name
1343
- });
1344
- });
1345
- }
1285
+ return { exportName, path, _name, type: "shared" };
1286
+ }));
1346
1287
  }
1347
1288
  const contextTypes = parseInterfaceDeclarations("ExtendContext", filePath);
1348
1289
  if (hasError("Parser", silgi)) {
1349
1290
  return;
1350
1291
  }
1351
1292
  if (contextTypes.length > 0) {
1352
- for (const contextType of contextTypes) {
1353
- const { exportName, path } = contextType;
1293
+ schemaTS.push(...contextTypes.map(({ exportName, path }) => {
1354
1294
  silgi.options.devServer.watch.push(path);
1355
1295
  const randomString = hash(basename(path) + exportName);
1356
1296
  const _name = `_v${randomString}`;
1357
- silgi.hook("prepare:schema.ts", (options) => {
1358
- options.contexts.push({
1359
- key: _name,
1360
- value: _name
1361
- });
1362
- });
1363
- silgi.hook("prepare:schema.ts", (options) => {
1364
- options.importItems[path] ??= {
1365
- import: [],
1366
- from: path
1367
- };
1368
- options.importItems[path].import.push({
1369
- name: `${exportName} as ${_name}`,
1370
- type: true,
1371
- key: _name
1372
- });
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
1373
1310
  });
1374
1311
  }
1375
- }
1312
+ });
1376
1313
  }
1377
1314
  }
1378
1315
  }
@@ -1611,10 +1548,6 @@ async function createSilgiCLI(config = {}, opts = {}) {
1611
1548
  },
1612
1549
  routeRules: void 0
1613
1550
  };
1614
- silgi.hook("prepare:scan.ts", (options2) => {
1615
- options2.services = [];
1616
- options2.importItems = options2.importItems || {};
1617
- });
1618
1551
  const routeRules = createRouteRules();
1619
1552
  routeRules.importRules(options.routeRules ?? {});
1620
1553
  silgi.routeRules = routeRules;
@@ -1,4 +1,4 @@
1
- const version = "0.20.29";
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.29";
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.29",
4
+ "version": "0.20.30",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {