@squadbase/vite-server 0.0.8 → 0.0.10

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/cli/index.js CHANGED
@@ -14,7 +14,7 @@ var interactive_exports = {};
14
14
  __export(interactive_exports, {
15
15
  confirmRunAll: () => confirmRunAll,
16
16
  inputParameters: () => inputParameters,
17
- selectDataSource: () => selectDataSource
17
+ selectServerLogic: () => selectServerLogic
18
18
  });
19
19
  async function getPrompts() {
20
20
  try {
@@ -26,10 +26,10 @@ async function getPrompts() {
26
26
  );
27
27
  }
28
28
  }
29
- async function selectDataSource(slugs) {
29
+ async function selectServerLogic(slugs) {
30
30
  const { select, isCancel } = await getPrompts();
31
31
  const result = await select({
32
- message: "Select a data source to test:",
32
+ message: "Select a server logic to test:",
33
33
  options: slugs.map((s) => ({ value: s, label: s }))
34
34
  });
35
35
  if (isCancel(result)) return null;
@@ -68,7 +68,7 @@ async function inputParameters(params) {
68
68
  async function confirmRunAll() {
69
69
  const { confirm, isCancel } = await getPrompts();
70
70
  const result = await confirm({
71
- message: "Run all data sources?"
71
+ message: "Run all server logics?"
72
72
  });
73
73
  if (isCancel(result)) return false;
74
74
  return result;
@@ -280,7 +280,7 @@ import { readdir, readFile as readFile2, mkdir } from "fs/promises";
280
280
  import { watch as fsWatch2 } from "fs";
281
281
  import path2 from "path";
282
282
 
283
- // src/types/data-source.ts
283
+ // src/types/server-logic.ts
284
284
  import { z } from "zod";
285
285
  var parameterMetaSchema = z.object({
286
286
  name: z.string(),
@@ -289,21 +289,21 @@ var parameterMetaSchema = z.object({
289
289
  required: z.boolean().optional(),
290
290
  default: z.union([z.string(), z.number(), z.boolean()]).optional()
291
291
  });
292
- var dataSourceCacheConfigSchema = z.object({
292
+ var serverLogicCacheConfigSchema = z.object({
293
293
  ttl: z.number(),
294
294
  staleWhileRevalidate: z.boolean().optional()
295
295
  });
296
- var dataSourceSchemaObjectSchema = z.lazy(
296
+ var serverLogicSchemaObjectSchema = z.lazy(
297
297
  () => z.object({
298
298
  type: z.enum(["string", "number", "integer", "boolean", "object", "array", "null"]).optional(),
299
299
  format: z.string().optional(),
300
300
  description: z.string().optional(),
301
301
  nullable: z.boolean().optional(),
302
302
  enum: z.array(z.union([z.string(), z.number(), z.boolean(), z.null()])).optional(),
303
- items: dataSourceSchemaObjectSchema.optional(),
304
- properties: z.record(z.string(), dataSourceSchemaObjectSchema).optional(),
303
+ items: serverLogicSchemaObjectSchema.optional(),
304
+ properties: z.record(z.string(), serverLogicSchemaObjectSchema).optional(),
305
305
  required: z.array(z.string()).optional(),
306
- additionalProperties: z.union([z.boolean(), dataSourceSchemaObjectSchema]).optional(),
306
+ additionalProperties: z.union([z.boolean(), serverLogicSchemaObjectSchema]).optional(),
307
307
  minimum: z.number().optional(),
308
308
  maximum: z.number().optional(),
309
309
  minLength: z.number().optional(),
@@ -311,34 +311,34 @@ var dataSourceSchemaObjectSchema = z.lazy(
311
311
  pattern: z.string().optional()
312
312
  })
313
313
  );
314
- var dataSourceMediaTypeSchema = z.object({
315
- schema: dataSourceSchemaObjectSchema.optional(),
314
+ var serverLogicMediaTypeSchema = z.object({
315
+ schema: serverLogicSchemaObjectSchema.optional(),
316
316
  example: z.unknown().optional()
317
317
  });
318
- var dataSourceResponseSchema = z.object({
318
+ var serverLogicResponseSchema = z.object({
319
319
  description: z.string().optional(),
320
- content: z.record(z.string(), dataSourceMediaTypeSchema).optional()
320
+ content: z.record(z.string(), serverLogicMediaTypeSchema).optional()
321
321
  });
322
322
  var jsonBaseFields = {
323
323
  description: z.string(),
324
324
  parameters: z.array(parameterMetaSchema).optional(),
325
- response: dataSourceResponseSchema.optional(),
326
- cache: dataSourceCacheConfigSchema.optional()
325
+ response: serverLogicResponseSchema.optional(),
326
+ cache: serverLogicCacheConfigSchema.optional()
327
327
  };
328
- var jsonSqlDataSourceSchema = z.object({
328
+ var jsonSqlServerLogicSchema = z.object({
329
329
  ...jsonBaseFields,
330
330
  type: z.literal("sql").optional(),
331
331
  query: z.string(),
332
332
  connectionId: z.string()
333
333
  });
334
- var jsonTypeScriptDataSourceSchema = z.object({
334
+ var jsonTypeScriptServerLogicSchema = z.object({
335
335
  ...jsonBaseFields,
336
336
  type: z.literal("typescript"),
337
337
  handlerPath: z.string()
338
338
  });
339
- var anyJsonDataSourceSchema = z.union([
340
- jsonTypeScriptDataSourceSchema,
341
- jsonSqlDataSourceSchema
339
+ var anyJsonServerLogicSchema = z.union([
340
+ jsonTypeScriptServerLogicSchema,
341
+ jsonSqlServerLogicSchema
342
342
  ]);
343
343
 
344
344
  // src/registry.ts
@@ -357,7 +357,7 @@ function applyDefaults(parameterMeta, runtimeParams) {
357
357
  }
358
358
  return result;
359
359
  }
360
- var defaultDataSourceDir = path2.join(process.cwd(), "data-source");
360
+ var defaultServerLogicDir = path2.join(process.cwd(), "server-logic");
361
361
 
362
362
  // src/cli/runner.ts
363
363
  function createStubContext(params) {
@@ -388,7 +388,7 @@ function createStubContext(params) {
388
388
  };
389
389
  return stub;
390
390
  }
391
- async function runSqlDataSource(slug, def, params, limit) {
391
+ async function runSqlServerLogic(slug, def, params, limit) {
392
392
  const start = Date.now();
393
393
  try {
394
394
  const query = await getQuery(def.connectionId);
@@ -412,7 +412,7 @@ async function runSqlDataSource(slug, def, params, limit) {
412
412
  };
413
413
  }
414
414
  }
415
- async function runTypescriptDataSource(slug, handlerPath, params) {
415
+ async function runTypescriptServerLogic(slug, handlerPath, params) {
416
416
  const start = Date.now();
417
417
  try {
418
418
  const mod = await import(pathToFileURL(handlerPath).href);
@@ -446,19 +446,19 @@ async function runTypescriptDataSource(slug, handlerPath, params) {
446
446
  };
447
447
  }
448
448
  }
449
- async function runDataSource(slug, dirPath, params, limit) {
449
+ async function runServerLogic(slug, dirPath, params, limit) {
450
450
  const jsonPath = path3.join(dirPath, `${slug}.json`);
451
451
  let def;
452
452
  try {
453
453
  const raw = await readFile3(jsonPath, "utf-8");
454
- const parsed = anyJsonDataSourceSchema.safeParse(JSON.parse(raw));
454
+ const parsed = anyJsonServerLogicSchema.safeParse(JSON.parse(raw));
455
455
  if (!parsed.success) {
456
456
  return {
457
457
  slug,
458
458
  rows: [],
459
459
  rowCount: 0,
460
460
  durationMs: 0,
461
- error: new Error(`Invalid data source definition: ${parsed.error.message}`)
461
+ error: new Error(`Invalid server logic definition: ${parsed.error.message}`)
462
462
  };
463
463
  }
464
464
  def = parsed.data;
@@ -468,14 +468,14 @@ async function runDataSource(slug, dirPath, params, limit) {
468
468
  rows: [],
469
469
  rowCount: 0,
470
470
  durationMs: 0,
471
- error: new Error(`Data source not found: ${jsonPath}`)
471
+ error: new Error(`Server logic not found: ${jsonPath}`)
472
472
  };
473
473
  }
474
474
  if (def.type === "typescript") {
475
475
  const absolutePath = path3.resolve(dirPath, def.handlerPath);
476
- return runTypescriptDataSource(slug, absolutePath, params);
476
+ return runTypescriptServerLogic(slug, absolutePath, params);
477
477
  }
478
- return runSqlDataSource(slug, def, params, limit);
478
+ return runSqlServerLogic(slug, def, params, limit);
479
479
  }
480
480
  async function listSlugs(dirPath) {
481
481
  try {
@@ -487,7 +487,7 @@ async function listSlugs(dirPath) {
487
487
  }
488
488
  async function runAll(dirPath, params, limit) {
489
489
  const slugs = await listSlugs(dirPath);
490
- return Promise.all(slugs.map((slug) => runDataSource(slug, dirPath, params, limit)));
490
+ return Promise.all(slugs.map((slug) => runServerLogic(slug, dirPath, params, limit)));
491
491
  }
492
492
 
493
493
  // src/cli/display.ts
@@ -570,14 +570,14 @@ function displayError(error) {
570
570
 
571
571
  // src/cli/index.ts
572
572
  var HELP = `
573
- Usage: squadbase-ds-test [options]
573
+ Usage: squadbase-sl-test [options]
574
574
 
575
575
  Options:
576
- --slug <slug> Run a specific data source
577
- --all Run all data sources
576
+ --slug <slug> Run a specific server logic
577
+ --all Run all server logics
578
578
  --params k=v,... Comma-separated key=value parameters
579
579
  --env <path> Path to .env file (default: ../../.env)
580
- --dir <path> Data source directory (default: ./data-source)
580
+ --dir <path> Server logic directory (default: ./server-logic)
581
581
  --format table|json Output format (default: table)
582
582
  --limit <n> Max rows to display (default: 50)
583
583
  --debug Show SQL query and parameter values
@@ -609,7 +609,7 @@ async function main() {
609
609
  process.exit(0);
610
610
  }
611
611
  const cwd = process.cwd();
612
- const dirPath = values.dir ? path4.resolve(cwd, values.dir) : path4.join(cwd, "data-source");
612
+ const dirPath = values.dir ? path4.resolve(cwd, values.dir) : path4.join(cwd, "server-logic");
613
613
  const envPath = values.env ? path4.resolve(cwd, values.env) : path4.join(cwd, "../../.env");
614
614
  const limit = parseInt(values.limit ?? "50", 10);
615
615
  const format = values.format ?? "table";
@@ -625,7 +625,7 @@ async function main() {
625
625
  }
626
626
  }
627
627
  if (values.slug) {
628
- const result = await runDataSource(values.slug, dirPath, params, limit);
628
+ const result = await runServerLogic(values.slug, dirPath, params, limit);
629
629
  if (format === "json") {
630
630
  displayJson([result]);
631
631
  } else {
@@ -653,12 +653,12 @@ Total: ${results.length}, Failed: ${failed}`);
653
653
  } else {
654
654
  const slugs = await listSlugs(dirPath);
655
655
  if (slugs.length === 0) {
656
- displayError(new Error(`No data sources found in ${dirPath}`));
656
+ displayError(new Error(`No server logics found in ${dirPath}`));
657
657
  process.exit(1);
658
658
  }
659
659
  try {
660
- const { selectDataSource: selectDataSource2, inputParameters: inputParameters2 } = await Promise.resolve().then(() => (init_interactive(), interactive_exports));
661
- const slug = await selectDataSource2(slugs);
660
+ const { selectServerLogic: selectServerLogic2, inputParameters: inputParameters2 } = await Promise.resolve().then(() => (init_interactive(), interactive_exports));
661
+ const slug = await selectServerLogic2(slugs);
662
662
  if (!slug) {
663
663
  console.log("Cancelled.");
664
664
  process.exit(0);
@@ -667,13 +667,13 @@ Total: ${results.length}, Failed: ${failed}`);
667
667
  let paramMeta = [];
668
668
  try {
669
669
  const raw = await readFile4(jsonPath, "utf-8");
670
- const parsed = anyJsonDataSourceSchema.safeParse(JSON.parse(raw));
670
+ const parsed = anyJsonServerLogicSchema.safeParse(JSON.parse(raw));
671
671
  if (parsed.success) paramMeta = parsed.data.parameters ?? [];
672
672
  } catch {
673
673
  }
674
674
  const interactiveParams = await inputParameters2(paramMeta);
675
675
  const merged = { ...interactiveParams, ...params };
676
- const result = await runDataSource(slug, dirPath, merged, limit);
676
+ const result = await runServerLogic(slug, dirPath, merged, limit);
677
677
  displaySummary(result);
678
678
  if (values.debug) displayDebug(result);
679
679
  if (!result.error) displayTable(result.rows, limit);
package/dist/index.js CHANGED
@@ -451,7 +451,7 @@ function createDbtClient(entry, slug) {
451
451
  // src/connector-client/index.ts
452
452
  var { getQuery, loadConnections, reloadEnvFile, watchConnectionsFile } = createConnectorRegistry();
453
453
 
454
- // src/types/data-source.ts
454
+ // src/types/server-logic.ts
455
455
  import { z } from "zod";
456
456
  var parameterMetaSchema = z.object({
457
457
  name: z.string(),
@@ -460,21 +460,21 @@ var parameterMetaSchema = z.object({
460
460
  required: z.boolean().optional(),
461
461
  default: z.union([z.string(), z.number(), z.boolean()]).optional()
462
462
  });
463
- var dataSourceCacheConfigSchema = z.object({
463
+ var serverLogicCacheConfigSchema = z.object({
464
464
  ttl: z.number(),
465
465
  staleWhileRevalidate: z.boolean().optional()
466
466
  });
467
- var dataSourceSchemaObjectSchema = z.lazy(
467
+ var serverLogicSchemaObjectSchema = z.lazy(
468
468
  () => z.object({
469
469
  type: z.enum(["string", "number", "integer", "boolean", "object", "array", "null"]).optional(),
470
470
  format: z.string().optional(),
471
471
  description: z.string().optional(),
472
472
  nullable: z.boolean().optional(),
473
473
  enum: z.array(z.union([z.string(), z.number(), z.boolean(), z.null()])).optional(),
474
- items: dataSourceSchemaObjectSchema.optional(),
475
- properties: z.record(z.string(), dataSourceSchemaObjectSchema).optional(),
474
+ items: serverLogicSchemaObjectSchema.optional(),
475
+ properties: z.record(z.string(), serverLogicSchemaObjectSchema).optional(),
476
476
  required: z.array(z.string()).optional(),
477
- additionalProperties: z.union([z.boolean(), dataSourceSchemaObjectSchema]).optional(),
477
+ additionalProperties: z.union([z.boolean(), serverLogicSchemaObjectSchema]).optional(),
478
478
  minimum: z.number().optional(),
479
479
  maximum: z.number().optional(),
480
480
  minLength: z.number().optional(),
@@ -482,45 +482,45 @@ var dataSourceSchemaObjectSchema = z.lazy(
482
482
  pattern: z.string().optional()
483
483
  })
484
484
  );
485
- var dataSourceMediaTypeSchema = z.object({
486
- schema: dataSourceSchemaObjectSchema.optional(),
485
+ var serverLogicMediaTypeSchema = z.object({
486
+ schema: serverLogicSchemaObjectSchema.optional(),
487
487
  example: z.unknown().optional()
488
488
  });
489
- var dataSourceResponseSchema = z.object({
489
+ var serverLogicResponseSchema = z.object({
490
490
  description: z.string().optional(),
491
- content: z.record(z.string(), dataSourceMediaTypeSchema).optional()
491
+ content: z.record(z.string(), serverLogicMediaTypeSchema).optional()
492
492
  });
493
493
  var jsonBaseFields = {
494
494
  description: z.string(),
495
495
  parameters: z.array(parameterMetaSchema).optional(),
496
- response: dataSourceResponseSchema.optional(),
497
- cache: dataSourceCacheConfigSchema.optional()
496
+ response: serverLogicResponseSchema.optional(),
497
+ cache: serverLogicCacheConfigSchema.optional()
498
498
  };
499
- var jsonSqlDataSourceSchema = z.object({
499
+ var jsonSqlServerLogicSchema = z.object({
500
500
  ...jsonBaseFields,
501
501
  type: z.literal("sql").optional(),
502
502
  query: z.string(),
503
503
  connectionId: z.string()
504
504
  });
505
- var jsonTypeScriptDataSourceSchema = z.object({
505
+ var jsonTypeScriptServerLogicSchema = z.object({
506
506
  ...jsonBaseFields,
507
507
  type: z.literal("typescript"),
508
508
  handlerPath: z.string()
509
509
  });
510
- var anyJsonDataSourceSchema = z.union([
511
- jsonTypeScriptDataSourceSchema,
512
- jsonSqlDataSourceSchema
510
+ var anyJsonServerLogicSchema = z.union([
511
+ jsonTypeScriptServerLogicSchema,
512
+ jsonSqlServerLogicSchema
513
513
  ]);
514
514
 
515
515
  // src/registry.ts
516
- var dataSources = /* @__PURE__ */ new Map();
516
+ var serverLogics = /* @__PURE__ */ new Map();
517
517
  var currentDirPath = "";
518
518
  var viteServer = null;
519
519
  function validateHandlerPath(dirPath, handlerPath) {
520
520
  const absolute = path2.resolve(dirPath, handlerPath);
521
521
  const normalizedDir = path2.resolve(dirPath);
522
522
  if (!absolute.startsWith(normalizedDir + path2.sep)) {
523
- throw new Error(`Handler path escapes data-source directory: ${handlerPath}`);
523
+ throw new Error(`Handler path escapes server-logic directory: ${handlerPath}`);
524
524
  }
525
525
  if (!absolute.endsWith(".ts")) {
526
526
  throw new Error(`Handler must be a .ts file: ${handlerPath}`);
@@ -558,13 +558,13 @@ function applyDefaults(parameterMeta, runtimeParams) {
558
558
  }
559
559
  return result;
560
560
  }
561
- var defaultDataSourceDir = path2.join(process.cwd(), "data-source");
561
+ var defaultServerLogicDir = path2.join(process.cwd(), "server-logic");
562
562
  async function initialize() {
563
563
  console.log(
564
- `[registry] loading data sources from ${defaultDataSourceDir}...`
564
+ `[registry] loading server logics from ${defaultServerLogicDir}...`
565
565
  );
566
- dataSources.clear();
567
- const dirPath = process.env.DATA_SOURCE_DIR || defaultDataSourceDir;
566
+ serverLogics.clear();
567
+ const dirPath = process.env.SERVER_LOGIC_DIR || process.env.DATA_SOURCE_DIR || defaultServerLogicDir;
568
568
  currentDirPath = dirPath;
569
569
  await mkdir(dirPath, { recursive: true });
570
570
  const files = await readdir(dirPath);
@@ -573,7 +573,7 @@ async function initialize() {
573
573
  jsonFiles.map(async (file) => {
574
574
  const slug = file.replace(/\.json$/, "");
575
575
  const raw = await readFile2(`${dirPath}/${file}`, "utf-8");
576
- const parsed = anyJsonDataSourceSchema.safeParse(JSON.parse(raw));
576
+ const parsed = anyJsonServerLogicSchema.safeParse(JSON.parse(raw));
577
577
  if (!parsed.success) {
578
578
  console.warn(`[registry] Skipping ${file}: ${parsed.error.message}`);
579
579
  return;
@@ -581,7 +581,7 @@ async function initialize() {
581
581
  const def = parsed.data;
582
582
  if (def.type === "typescript") {
583
583
  const absoluteHandlerPath = validateHandlerPath(dirPath, def.handlerPath);
584
- const dataSourceDef = {
584
+ const serverLogicDef = {
585
585
  description: def.description,
586
586
  parameters: def.parameters ?? [],
587
587
  response: def.response,
@@ -592,11 +592,11 @@ async function initialize() {
592
592
  _isTypescript: true,
593
593
  _tsHandlerPath: absoluteHandlerPath
594
594
  };
595
- dataSources.set(slug, dataSourceDef);
595
+ serverLogics.set(slug, serverLogicDef);
596
596
  console.log(`[registry] registered (typescript): ${slug}`);
597
597
  } else {
598
598
  const sqlDef = def;
599
- const dataSourceDef = {
599
+ const serverLogicDef = {
600
600
  description: sqlDef.description,
601
601
  parameters: sqlDef.parameters ?? [],
602
602
  response: sqlDef.response,
@@ -613,7 +613,7 @@ async function initialize() {
613
613
  return result.rows;
614
614
  }
615
615
  };
616
- dataSources.set(slug, dataSourceDef);
616
+ serverLogics.set(slug, serverLogicDef);
617
617
  console.log(`[registry] registered: ${slug}`);
618
618
  }
619
619
  })
@@ -626,29 +626,29 @@ async function initialize() {
626
626
  );
627
627
  }
628
628
  });
629
- console.log(`[registry] ${dataSources.size} data source(s) ready`);
629
+ console.log(`[registry] ${serverLogics.size} server logic(s) ready`);
630
630
  }
631
631
  var reloadTimer = null;
632
632
  function startWatching() {
633
- const dirPath = process.env.DATA_SOURCE_DIR || defaultDataSourceDir;
633
+ const dirPath = process.env.SERVER_LOGIC_DIR || process.env.DATA_SOURCE_DIR || defaultServerLogicDir;
634
634
  try {
635
635
  fsWatch2(dirPath, { persistent: false }, (_event, filename) => {
636
636
  if (!filename?.endsWith(".json") && !filename?.endsWith(".ts")) return;
637
637
  if (reloadTimer) clearTimeout(reloadTimer);
638
638
  reloadTimer = setTimeout(async () => {
639
- console.log("[registry] data-source changed, reloading...");
639
+ console.log("[registry] server-logic changed, reloading...");
640
640
  await initialize();
641
641
  }, 300);
642
642
  });
643
- console.log("[registry] watching data-source directory");
643
+ console.log("[registry] watching server-logic directory");
644
644
  } catch {
645
645
  console.warn(
646
- "[registry] could not watch data-source directory (static load only)"
646
+ "[registry] could not watch server-logic directory (static load only)"
647
647
  );
648
648
  }
649
649
  }
650
- function getDataSource(slug) {
651
- return dataSources.get(slug);
650
+ function getServerLogic(slug) {
651
+ return serverLogics.get(slug);
652
652
  }
653
653
  function buildMeta(slug, def) {
654
654
  const base = {
@@ -673,17 +673,17 @@ function buildMeta(slug, def) {
673
673
  };
674
674
  }
675
675
  function getAllMeta() {
676
- return Array.from(dataSources.entries()).map(
676
+ return Array.from(serverLogics.entries()).map(
677
677
  ([slug, def]) => buildMeta(slug, def)
678
678
  );
679
679
  }
680
680
  function getMeta(slug) {
681
- const def = dataSources.get(slug);
681
+ const def = serverLogics.get(slug);
682
682
  if (!def) return void 0;
683
683
  return buildMeta(slug, def);
684
684
  }
685
685
 
686
- // src/routes/data-source.ts
686
+ // src/routes/server-logic.ts
687
687
  import { Hono } from "hono";
688
688
 
689
689
  // src/cache.ts
@@ -776,7 +776,7 @@ function buildCacheKey(slug, params) {
776
776
  return `${slug}:${JSON.stringify(sortedParams)}`;
777
777
  }
778
778
 
779
- // src/routes/data-source.ts
779
+ // src/routes/server-logic.ts
780
780
  var app = new Hono();
781
781
  function buildSqlResponse(c, result) {
782
782
  return c.json({ data: result });
@@ -786,9 +786,9 @@ function buildTypescriptResponse(result) {
786
786
  }
787
787
  app.get("/:slug", async (c) => {
788
788
  const slug = c.req.param("slug");
789
- const ds = getDataSource(slug);
789
+ const ds = getServerLogic(slug);
790
790
  if (!ds) {
791
- return c.json({ error: `Data source '${slug}' not found` }, 404);
791
+ return c.json({ error: `Server logic '${slug}' not found` }, 404);
792
792
  }
793
793
  try {
794
794
  if (ds._isTypescript && ds._tsHandlerPath) {
@@ -800,7 +800,7 @@ app.get("/:slug", async (c) => {
800
800
  return buildSqlResponse(c, result);
801
801
  }
802
802
  } catch (e) {
803
- console.error(`[data-source] ${slug} error:`, e);
803
+ console.error(`[server-logic] ${slug} error:`, e);
804
804
  return c.json(
805
805
  { error: e instanceof Error ? e.message : "Internal error" },
806
806
  500
@@ -809,9 +809,9 @@ app.get("/:slug", async (c) => {
809
809
  });
810
810
  app.post("/:slug", async (c) => {
811
811
  const slug = c.req.param("slug");
812
- const ds = getDataSource(slug);
812
+ const ds = getServerLogic(slug);
813
813
  if (!ds) {
814
- return c.json({ error: `Data source '${slug}' not found` }, 404);
814
+ return c.json({ error: `Server logic '${slug}' not found` }, 404);
815
815
  }
816
816
  try {
817
817
  const body = await c.req.json().catch(() => ({}));
@@ -877,16 +877,16 @@ app.post("/:slug", async (c) => {
877
877
  c.header("Cache-Control", `max-age=${ttl}`);
878
878
  return buildResponse(result);
879
879
  } catch (e) {
880
- console.error(`[data-source] ${slug} error:`, e);
880
+ console.error(`[server-logic] ${slug} error:`, e);
881
881
  return c.json(
882
882
  { error: e instanceof Error ? e.message : "Internal error" },
883
883
  500
884
884
  );
885
885
  }
886
886
  });
887
- var data_source_default = app;
887
+ var server_logic_default = app;
888
888
 
889
- // src/routes/data-source-meta.ts
889
+ // src/routes/server-logic-meta.ts
890
890
  import { Hono as Hono2 } from "hono";
891
891
  var app2 = new Hono2();
892
892
  app2.get("/", (c) => {
@@ -896,11 +896,11 @@ app2.get("/:slug", (c) => {
896
896
  const slug = c.req.param("slug");
897
897
  const meta = getMeta(slug);
898
898
  if (!meta) {
899
- return c.json({ error: `Data source '${slug}' not found` }, 404);
899
+ return c.json({ error: `Server logic '${slug}' not found` }, 404);
900
900
  }
901
901
  return c.json(meta);
902
902
  });
903
- var data_source_meta_default = app2;
903
+ var server_logic_meta_default = app2;
904
904
 
905
905
  // src/routes/cache.ts
906
906
  import { Hono as Hono3 } from "hono";
@@ -1060,8 +1060,8 @@ function connection(connectionId) {
1060
1060
  var apiApp = new Hono5();
1061
1061
  apiApp.use("/*", contextStorage());
1062
1062
  apiApp.use("/*", cors());
1063
- apiApp.route("/data-source", data_source_default);
1064
- apiApp.route("/data-source-meta", data_source_meta_default);
1063
+ apiApp.route("/server-logic", server_logic_default);
1064
+ apiApp.route("/server-logic-meta", server_logic_meta_default);
1065
1065
  apiApp.route("/cache", cache_default);
1066
1066
  apiApp.route("/", pages_default);
1067
1067
  reloadEnvFile(path4.join(process.cwd(), ".env"));
package/dist/main.js CHANGED
@@ -189,7 +189,7 @@ function resolveParams(entry, connectionId, plugin) {
189
189
  // src/connector-client/index.ts
190
190
  var { getQuery, loadConnections, reloadEnvFile, watchConnectionsFile } = createConnectorRegistry();
191
191
 
192
- // src/types/data-source.ts
192
+ // src/types/server-logic.ts
193
193
  import { z } from "zod";
194
194
  var parameterMetaSchema = z.object({
195
195
  name: z.string(),
@@ -198,21 +198,21 @@ var parameterMetaSchema = z.object({
198
198
  required: z.boolean().optional(),
199
199
  default: z.union([z.string(), z.number(), z.boolean()]).optional()
200
200
  });
201
- var dataSourceCacheConfigSchema = z.object({
201
+ var serverLogicCacheConfigSchema = z.object({
202
202
  ttl: z.number(),
203
203
  staleWhileRevalidate: z.boolean().optional()
204
204
  });
205
- var dataSourceSchemaObjectSchema = z.lazy(
205
+ var serverLogicSchemaObjectSchema = z.lazy(
206
206
  () => z.object({
207
207
  type: z.enum(["string", "number", "integer", "boolean", "object", "array", "null"]).optional(),
208
208
  format: z.string().optional(),
209
209
  description: z.string().optional(),
210
210
  nullable: z.boolean().optional(),
211
211
  enum: z.array(z.union([z.string(), z.number(), z.boolean(), z.null()])).optional(),
212
- items: dataSourceSchemaObjectSchema.optional(),
213
- properties: z.record(z.string(), dataSourceSchemaObjectSchema).optional(),
212
+ items: serverLogicSchemaObjectSchema.optional(),
213
+ properties: z.record(z.string(), serverLogicSchemaObjectSchema).optional(),
214
214
  required: z.array(z.string()).optional(),
215
- additionalProperties: z.union([z.boolean(), dataSourceSchemaObjectSchema]).optional(),
215
+ additionalProperties: z.union([z.boolean(), serverLogicSchemaObjectSchema]).optional(),
216
216
  minimum: z.number().optional(),
217
217
  maximum: z.number().optional(),
218
218
  minLength: z.number().optional(),
@@ -220,45 +220,45 @@ var dataSourceSchemaObjectSchema = z.lazy(
220
220
  pattern: z.string().optional()
221
221
  })
222
222
  );
223
- var dataSourceMediaTypeSchema = z.object({
224
- schema: dataSourceSchemaObjectSchema.optional(),
223
+ var serverLogicMediaTypeSchema = z.object({
224
+ schema: serverLogicSchemaObjectSchema.optional(),
225
225
  example: z.unknown().optional()
226
226
  });
227
- var dataSourceResponseSchema = z.object({
227
+ var serverLogicResponseSchema = z.object({
228
228
  description: z.string().optional(),
229
- content: z.record(z.string(), dataSourceMediaTypeSchema).optional()
229
+ content: z.record(z.string(), serverLogicMediaTypeSchema).optional()
230
230
  });
231
231
  var jsonBaseFields = {
232
232
  description: z.string(),
233
233
  parameters: z.array(parameterMetaSchema).optional(),
234
- response: dataSourceResponseSchema.optional(),
235
- cache: dataSourceCacheConfigSchema.optional()
234
+ response: serverLogicResponseSchema.optional(),
235
+ cache: serverLogicCacheConfigSchema.optional()
236
236
  };
237
- var jsonSqlDataSourceSchema = z.object({
237
+ var jsonSqlServerLogicSchema = z.object({
238
238
  ...jsonBaseFields,
239
239
  type: z.literal("sql").optional(),
240
240
  query: z.string(),
241
241
  connectionId: z.string()
242
242
  });
243
- var jsonTypeScriptDataSourceSchema = z.object({
243
+ var jsonTypeScriptServerLogicSchema = z.object({
244
244
  ...jsonBaseFields,
245
245
  type: z.literal("typescript"),
246
246
  handlerPath: z.string()
247
247
  });
248
- var anyJsonDataSourceSchema = z.union([
249
- jsonTypeScriptDataSourceSchema,
250
- jsonSqlDataSourceSchema
248
+ var anyJsonServerLogicSchema = z.union([
249
+ jsonTypeScriptServerLogicSchema,
250
+ jsonSqlServerLogicSchema
251
251
  ]);
252
252
 
253
253
  // src/registry.ts
254
- var dataSources = /* @__PURE__ */ new Map();
254
+ var serverLogics = /* @__PURE__ */ new Map();
255
255
  var currentDirPath = "";
256
256
  var viteServer = null;
257
257
  function validateHandlerPath(dirPath, handlerPath) {
258
258
  const absolute = path2.resolve(dirPath, handlerPath);
259
259
  const normalizedDir = path2.resolve(dirPath);
260
260
  if (!absolute.startsWith(normalizedDir + path2.sep)) {
261
- throw new Error(`Handler path escapes data-source directory: ${handlerPath}`);
261
+ throw new Error(`Handler path escapes server-logic directory: ${handlerPath}`);
262
262
  }
263
263
  if (!absolute.endsWith(".ts")) {
264
264
  throw new Error(`Handler must be a .ts file: ${handlerPath}`);
@@ -296,13 +296,13 @@ function applyDefaults(parameterMeta, runtimeParams) {
296
296
  }
297
297
  return result;
298
298
  }
299
- var defaultDataSourceDir = path2.join(process.cwd(), "data-source");
299
+ var defaultServerLogicDir = path2.join(process.cwd(), "server-logic");
300
300
  async function initialize() {
301
301
  console.log(
302
- `[registry] loading data sources from ${defaultDataSourceDir}...`
302
+ `[registry] loading server logics from ${defaultServerLogicDir}...`
303
303
  );
304
- dataSources.clear();
305
- const dirPath = process.env.DATA_SOURCE_DIR || defaultDataSourceDir;
304
+ serverLogics.clear();
305
+ const dirPath = process.env.SERVER_LOGIC_DIR || process.env.DATA_SOURCE_DIR || defaultServerLogicDir;
306
306
  currentDirPath = dirPath;
307
307
  await mkdir(dirPath, { recursive: true });
308
308
  const files = await readdir(dirPath);
@@ -311,7 +311,7 @@ async function initialize() {
311
311
  jsonFiles.map(async (file) => {
312
312
  const slug = file.replace(/\.json$/, "");
313
313
  const raw = await readFile2(`${dirPath}/${file}`, "utf-8");
314
- const parsed = anyJsonDataSourceSchema.safeParse(JSON.parse(raw));
314
+ const parsed = anyJsonServerLogicSchema.safeParse(JSON.parse(raw));
315
315
  if (!parsed.success) {
316
316
  console.warn(`[registry] Skipping ${file}: ${parsed.error.message}`);
317
317
  return;
@@ -319,7 +319,7 @@ async function initialize() {
319
319
  const def = parsed.data;
320
320
  if (def.type === "typescript") {
321
321
  const absoluteHandlerPath = validateHandlerPath(dirPath, def.handlerPath);
322
- const dataSourceDef = {
322
+ const serverLogicDef = {
323
323
  description: def.description,
324
324
  parameters: def.parameters ?? [],
325
325
  response: def.response,
@@ -330,11 +330,11 @@ async function initialize() {
330
330
  _isTypescript: true,
331
331
  _tsHandlerPath: absoluteHandlerPath
332
332
  };
333
- dataSources.set(slug, dataSourceDef);
333
+ serverLogics.set(slug, serverLogicDef);
334
334
  console.log(`[registry] registered (typescript): ${slug}`);
335
335
  } else {
336
336
  const sqlDef = def;
337
- const dataSourceDef = {
337
+ const serverLogicDef = {
338
338
  description: sqlDef.description,
339
339
  parameters: sqlDef.parameters ?? [],
340
340
  response: sqlDef.response,
@@ -351,7 +351,7 @@ async function initialize() {
351
351
  return result.rows;
352
352
  }
353
353
  };
354
- dataSources.set(slug, dataSourceDef);
354
+ serverLogics.set(slug, serverLogicDef);
355
355
  console.log(`[registry] registered: ${slug}`);
356
356
  }
357
357
  })
@@ -364,29 +364,29 @@ async function initialize() {
364
364
  );
365
365
  }
366
366
  });
367
- console.log(`[registry] ${dataSources.size} data source(s) ready`);
367
+ console.log(`[registry] ${serverLogics.size} server logic(s) ready`);
368
368
  }
369
369
  var reloadTimer = null;
370
370
  function startWatching() {
371
- const dirPath = process.env.DATA_SOURCE_DIR || defaultDataSourceDir;
371
+ const dirPath = process.env.SERVER_LOGIC_DIR || process.env.DATA_SOURCE_DIR || defaultServerLogicDir;
372
372
  try {
373
373
  fsWatch2(dirPath, { persistent: false }, (_event, filename) => {
374
374
  if (!filename?.endsWith(".json") && !filename?.endsWith(".ts")) return;
375
375
  if (reloadTimer) clearTimeout(reloadTimer);
376
376
  reloadTimer = setTimeout(async () => {
377
- console.log("[registry] data-source changed, reloading...");
377
+ console.log("[registry] server-logic changed, reloading...");
378
378
  await initialize();
379
379
  }, 300);
380
380
  });
381
- console.log("[registry] watching data-source directory");
381
+ console.log("[registry] watching server-logic directory");
382
382
  } catch {
383
383
  console.warn(
384
- "[registry] could not watch data-source directory (static load only)"
384
+ "[registry] could not watch server-logic directory (static load only)"
385
385
  );
386
386
  }
387
387
  }
388
- function getDataSource(slug) {
389
- return dataSources.get(slug);
388
+ function getServerLogic(slug) {
389
+ return serverLogics.get(slug);
390
390
  }
391
391
  function buildMeta(slug, def) {
392
392
  const base = {
@@ -411,17 +411,17 @@ function buildMeta(slug, def) {
411
411
  };
412
412
  }
413
413
  function getAllMeta() {
414
- return Array.from(dataSources.entries()).map(
414
+ return Array.from(serverLogics.entries()).map(
415
415
  ([slug, def]) => buildMeta(slug, def)
416
416
  );
417
417
  }
418
418
  function getMeta(slug) {
419
- const def = dataSources.get(slug);
419
+ const def = serverLogics.get(slug);
420
420
  if (!def) return void 0;
421
421
  return buildMeta(slug, def);
422
422
  }
423
423
 
424
- // src/routes/data-source.ts
424
+ // src/routes/server-logic.ts
425
425
  import { Hono } from "hono";
426
426
 
427
427
  // src/cache.ts
@@ -514,7 +514,7 @@ function buildCacheKey(slug, params) {
514
514
  return `${slug}:${JSON.stringify(sortedParams)}`;
515
515
  }
516
516
 
517
- // src/routes/data-source.ts
517
+ // src/routes/server-logic.ts
518
518
  var app = new Hono();
519
519
  function buildSqlResponse(c, result) {
520
520
  return c.json({ data: result });
@@ -524,9 +524,9 @@ function buildTypescriptResponse(result) {
524
524
  }
525
525
  app.get("/:slug", async (c) => {
526
526
  const slug = c.req.param("slug");
527
- const ds = getDataSource(slug);
527
+ const ds = getServerLogic(slug);
528
528
  if (!ds) {
529
- return c.json({ error: `Data source '${slug}' not found` }, 404);
529
+ return c.json({ error: `Server logic '${slug}' not found` }, 404);
530
530
  }
531
531
  try {
532
532
  if (ds._isTypescript && ds._tsHandlerPath) {
@@ -538,7 +538,7 @@ app.get("/:slug", async (c) => {
538
538
  return buildSqlResponse(c, result);
539
539
  }
540
540
  } catch (e) {
541
- console.error(`[data-source] ${slug} error:`, e);
541
+ console.error(`[server-logic] ${slug} error:`, e);
542
542
  return c.json(
543
543
  { error: e instanceof Error ? e.message : "Internal error" },
544
544
  500
@@ -547,9 +547,9 @@ app.get("/:slug", async (c) => {
547
547
  });
548
548
  app.post("/:slug", async (c) => {
549
549
  const slug = c.req.param("slug");
550
- const ds = getDataSource(slug);
550
+ const ds = getServerLogic(slug);
551
551
  if (!ds) {
552
- return c.json({ error: `Data source '${slug}' not found` }, 404);
552
+ return c.json({ error: `Server logic '${slug}' not found` }, 404);
553
553
  }
554
554
  try {
555
555
  const body = await c.req.json().catch(() => ({}));
@@ -615,16 +615,16 @@ app.post("/:slug", async (c) => {
615
615
  c.header("Cache-Control", `max-age=${ttl}`);
616
616
  return buildResponse(result);
617
617
  } catch (e) {
618
- console.error(`[data-source] ${slug} error:`, e);
618
+ console.error(`[server-logic] ${slug} error:`, e);
619
619
  return c.json(
620
620
  { error: e instanceof Error ? e.message : "Internal error" },
621
621
  500
622
622
  );
623
623
  }
624
624
  });
625
- var data_source_default = app;
625
+ var server_logic_default = app;
626
626
 
627
- // src/routes/data-source-meta.ts
627
+ // src/routes/server-logic-meta.ts
628
628
  import { Hono as Hono2 } from "hono";
629
629
  var app2 = new Hono2();
630
630
  app2.get("/", (c) => {
@@ -634,11 +634,11 @@ app2.get("/:slug", (c) => {
634
634
  const slug = c.req.param("slug");
635
635
  const meta = getMeta(slug);
636
636
  if (!meta) {
637
- return c.json({ error: `Data source '${slug}' not found` }, 404);
637
+ return c.json({ error: `Server logic '${slug}' not found` }, 404);
638
638
  }
639
639
  return c.json(meta);
640
640
  });
641
- var data_source_meta_default = app2;
641
+ var server_logic_meta_default = app2;
642
642
 
643
643
  // src/routes/cache.ts
644
644
  import { Hono as Hono3 } from "hono";
@@ -733,8 +733,8 @@ import { getCookie as getCookie2 } from "hono/cookie";
733
733
  var apiApp = new Hono5();
734
734
  apiApp.use("/*", contextStorage());
735
735
  apiApp.use("/*", cors());
736
- apiApp.route("/data-source", data_source_default);
737
- apiApp.route("/data-source-meta", data_source_meta_default);
736
+ apiApp.route("/server-logic", server_logic_default);
737
+ apiApp.route("/server-logic-meta", server_logic_meta_default);
738
738
  apiApp.route("/cache", cache_default);
739
739
  apiApp.route("/", pages_default);
740
740
  reloadEnvFile(path4.join(process.cwd(), ".env"));
@@ -12,42 +12,42 @@ declare const parameterMetaSchema: z.ZodObject<{
12
12
  default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
13
13
  }, z.core.$strip>;
14
14
  type ParameterMeta = z.infer<typeof parameterMetaSchema>;
15
- declare const dataSourceCacheConfigSchema: z.ZodObject<{
15
+ declare const serverLogicCacheConfigSchema: z.ZodObject<{
16
16
  ttl: z.ZodNumber;
17
17
  staleWhileRevalidate: z.ZodOptional<z.ZodBoolean>;
18
18
  }, z.core.$strip>;
19
- type DataSourceCacheConfig = z.infer<typeof dataSourceCacheConfigSchema>;
20
- declare const dataSourceSchemaObjectSchema: z.ZodType<DataSourceSchemaObject>;
21
- interface DataSourceSchemaObject {
19
+ type ServerLogicCacheConfig = z.infer<typeof serverLogicCacheConfigSchema>;
20
+ declare const serverLogicSchemaObjectSchema: z.ZodType<ServerLogicSchemaObject>;
21
+ interface ServerLogicSchemaObject {
22
22
  type?: "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
23
23
  format?: string;
24
24
  description?: string;
25
25
  nullable?: boolean;
26
26
  enum?: (string | number | boolean | null)[];
27
- items?: DataSourceSchemaObject;
28
- properties?: Record<string, DataSourceSchemaObject>;
27
+ items?: ServerLogicSchemaObject;
28
+ properties?: Record<string, ServerLogicSchemaObject>;
29
29
  required?: string[];
30
- additionalProperties?: boolean | DataSourceSchemaObject;
30
+ additionalProperties?: boolean | ServerLogicSchemaObject;
31
31
  minimum?: number;
32
32
  maximum?: number;
33
33
  minLength?: number;
34
34
  maxLength?: number;
35
35
  pattern?: string;
36
36
  }
37
- declare const dataSourceMediaTypeSchema: z.ZodObject<{
38
- schema: z.ZodOptional<z.ZodType<DataSourceSchemaObject, unknown, z.core.$ZodTypeInternals<DataSourceSchemaObject, unknown>>>;
37
+ declare const serverLogicMediaTypeSchema: z.ZodObject<{
38
+ schema: z.ZodOptional<z.ZodType<ServerLogicSchemaObject, unknown, z.core.$ZodTypeInternals<ServerLogicSchemaObject, unknown>>>;
39
39
  example: z.ZodOptional<z.ZodUnknown>;
40
40
  }, z.core.$strip>;
41
- type DataSourceMediaType = z.infer<typeof dataSourceMediaTypeSchema>;
42
- declare const dataSourceResponseSchema: z.ZodObject<{
41
+ type ServerLogicMediaType = z.infer<typeof serverLogicMediaTypeSchema>;
42
+ declare const serverLogicResponseSchema: z.ZodObject<{
43
43
  description: z.ZodOptional<z.ZodString>;
44
44
  content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
45
- schema: z.ZodOptional<z.ZodType<DataSourceSchemaObject, unknown, z.core.$ZodTypeInternals<DataSourceSchemaObject, unknown>>>;
45
+ schema: z.ZodOptional<z.ZodType<ServerLogicSchemaObject, unknown, z.core.$ZodTypeInternals<ServerLogicSchemaObject, unknown>>>;
46
46
  example: z.ZodOptional<z.ZodUnknown>;
47
47
  }, z.core.$strip>>>;
48
48
  }, z.core.$strip>;
49
- type DataSourceResponse = z.infer<typeof dataSourceResponseSchema>;
50
- declare const jsonSqlDataSourceSchema: z.ZodObject<{
49
+ type ServerLogicResponse = z.infer<typeof serverLogicResponseSchema>;
50
+ declare const jsonSqlServerLogicSchema: z.ZodObject<{
51
51
  type: z.ZodOptional<z.ZodLiteral<"sql">>;
52
52
  query: z.ZodString;
53
53
  connectionId: z.ZodString;
@@ -66,7 +66,7 @@ declare const jsonSqlDataSourceSchema: z.ZodObject<{
66
66
  response: z.ZodOptional<z.ZodObject<{
67
67
  description: z.ZodOptional<z.ZodString>;
68
68
  content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
69
- schema: z.ZodOptional<z.ZodType<DataSourceSchemaObject, unknown, z.core.$ZodTypeInternals<DataSourceSchemaObject, unknown>>>;
69
+ schema: z.ZodOptional<z.ZodType<ServerLogicSchemaObject, unknown, z.core.$ZodTypeInternals<ServerLogicSchemaObject, unknown>>>;
70
70
  example: z.ZodOptional<z.ZodUnknown>;
71
71
  }, z.core.$strip>>>;
72
72
  }, z.core.$strip>>;
@@ -75,8 +75,8 @@ declare const jsonSqlDataSourceSchema: z.ZodObject<{
75
75
  staleWhileRevalidate: z.ZodOptional<z.ZodBoolean>;
76
76
  }, z.core.$strip>>;
77
77
  }, z.core.$strip>;
78
- type JsonSqlDataSourceDefinition = z.infer<typeof jsonSqlDataSourceSchema>;
79
- declare const jsonTypeScriptDataSourceSchema: z.ZodObject<{
78
+ type JsonSqlServerLogicDefinition = z.infer<typeof jsonSqlServerLogicSchema>;
79
+ declare const jsonTypeScriptServerLogicSchema: z.ZodObject<{
80
80
  type: z.ZodLiteral<"typescript">;
81
81
  handlerPath: z.ZodString;
82
82
  description: z.ZodString;
@@ -94,7 +94,7 @@ declare const jsonTypeScriptDataSourceSchema: z.ZodObject<{
94
94
  response: z.ZodOptional<z.ZodObject<{
95
95
  description: z.ZodOptional<z.ZodString>;
96
96
  content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
97
- schema: z.ZodOptional<z.ZodType<DataSourceSchemaObject, unknown, z.core.$ZodTypeInternals<DataSourceSchemaObject, unknown>>>;
97
+ schema: z.ZodOptional<z.ZodType<ServerLogicSchemaObject, unknown, z.core.$ZodTypeInternals<ServerLogicSchemaObject, unknown>>>;
98
98
  example: z.ZodOptional<z.ZodUnknown>;
99
99
  }, z.core.$strip>>>;
100
100
  }, z.core.$strip>>;
@@ -103,8 +103,8 @@ declare const jsonTypeScriptDataSourceSchema: z.ZodObject<{
103
103
  staleWhileRevalidate: z.ZodOptional<z.ZodBoolean>;
104
104
  }, z.core.$strip>>;
105
105
  }, z.core.$strip>;
106
- type JsonTypeScriptDataSourceDefinition = z.infer<typeof jsonTypeScriptDataSourceSchema>;
107
- declare const anyJsonDataSourceSchema: z.ZodUnion<readonly [z.ZodObject<{
106
+ type JsonTypeScriptServerLogicDefinition = z.infer<typeof jsonTypeScriptServerLogicSchema>;
107
+ declare const anyJsonServerLogicSchema: z.ZodUnion<readonly [z.ZodObject<{
108
108
  type: z.ZodLiteral<"typescript">;
109
109
  handlerPath: z.ZodString;
110
110
  description: z.ZodString;
@@ -122,7 +122,7 @@ declare const anyJsonDataSourceSchema: z.ZodUnion<readonly [z.ZodObject<{
122
122
  response: z.ZodOptional<z.ZodObject<{
123
123
  description: z.ZodOptional<z.ZodString>;
124
124
  content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
125
- schema: z.ZodOptional<z.ZodType<DataSourceSchemaObject, unknown, z.core.$ZodTypeInternals<DataSourceSchemaObject, unknown>>>;
125
+ schema: z.ZodOptional<z.ZodType<ServerLogicSchemaObject, unknown, z.core.$ZodTypeInternals<ServerLogicSchemaObject, unknown>>>;
126
126
  example: z.ZodOptional<z.ZodUnknown>;
127
127
  }, z.core.$strip>>>;
128
128
  }, z.core.$strip>>;
@@ -149,7 +149,7 @@ declare const anyJsonDataSourceSchema: z.ZodUnion<readonly [z.ZodObject<{
149
149
  response: z.ZodOptional<z.ZodObject<{
150
150
  description: z.ZodOptional<z.ZodString>;
151
151
  content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
152
- schema: z.ZodOptional<z.ZodType<DataSourceSchemaObject, unknown, z.core.$ZodTypeInternals<DataSourceSchemaObject, unknown>>>;
152
+ schema: z.ZodOptional<z.ZodType<ServerLogicSchemaObject, unknown, z.core.$ZodTypeInternals<ServerLogicSchemaObject, unknown>>>;
153
153
  example: z.ZodOptional<z.ZodUnknown>;
154
154
  }, z.core.$strip>>>;
155
155
  }, z.core.$strip>>;
@@ -158,48 +158,48 @@ declare const anyJsonDataSourceSchema: z.ZodUnion<readonly [z.ZodObject<{
158
158
  staleWhileRevalidate: z.ZodOptional<z.ZodBoolean>;
159
159
  }, z.core.$strip>>;
160
160
  }, z.core.$strip>]>;
161
- type AnyJsonDataSourceDefinition = z.infer<typeof anyJsonDataSourceSchema>;
162
- interface BaseDataSourceDefinition {
161
+ type AnyJsonServerLogicDefinition = z.infer<typeof anyJsonServerLogicSchema>;
162
+ interface BaseServerLogicDefinition {
163
163
  description: string;
164
164
  parameters: ParameterMeta[];
165
- response?: DataSourceResponse;
166
- cacheConfig?: DataSourceCacheConfig;
165
+ response?: ServerLogicResponse;
166
+ cacheConfig?: ServerLogicCacheConfig;
167
167
  handler: (params: Record<string, unknown>) => Promise<unknown> | unknown;
168
168
  }
169
- interface SqlDataSourceDefinition extends BaseDataSourceDefinition {
169
+ interface SqlServerLogicDefinition extends BaseServerLogicDefinition {
170
170
  connectionId: string;
171
171
  _query: string;
172
172
  _isTypescript?: false;
173
173
  _tsHandlerPath?: undefined;
174
174
  }
175
- interface TypeScriptDataSourceDefinition extends BaseDataSourceDefinition {
175
+ interface TypeScriptServerLogicDefinition extends BaseServerLogicDefinition {
176
176
  _isTypescript: true;
177
177
  _tsHandlerPath: string;
178
178
  connectionId?: undefined;
179
179
  _query?: undefined;
180
180
  }
181
- type DataSourceDefinition = SqlDataSourceDefinition | TypeScriptDataSourceDefinition;
182
- interface BaseDataSourceMeta {
181
+ type ServerLogicDefinition = SqlServerLogicDefinition | TypeScriptServerLogicDefinition;
182
+ interface BaseServerLogicMeta {
183
183
  slug: string;
184
184
  description: string;
185
185
  parameters: ParameterMeta[];
186
- response?: DataSourceResponse;
187
- cache?: DataSourceCacheConfig;
186
+ response?: ServerLogicResponse;
187
+ cache?: ServerLogicCacheConfig;
188
188
  }
189
- interface SqlDataSourceMeta extends BaseDataSourceMeta {
189
+ interface SqlServerLogicMeta extends BaseServerLogicMeta {
190
190
  type: "sql";
191
191
  connectionId: string;
192
192
  query: string;
193
193
  handlerPath?: undefined;
194
194
  }
195
- interface TypeScriptDataSourceMeta extends BaseDataSourceMeta {
195
+ interface TypeScriptServerLogicMeta extends BaseServerLogicMeta {
196
196
  type: "typescript";
197
197
  handlerPath: string;
198
198
  connectionId?: undefined;
199
199
  query?: undefined;
200
200
  }
201
- type DataSourceMeta = SqlDataSourceMeta | TypeScriptDataSourceMeta;
202
- /** @deprecated Use JsonSqlDataSourceDefinition */
203
- type JsonDataSourceDefinition = JsonSqlDataSourceDefinition;
201
+ type ServerLogicMeta = SqlServerLogicMeta | TypeScriptServerLogicMeta;
202
+ /** @deprecated Use JsonSqlServerLogicDefinition */
203
+ type JsonServerLogicDefinition = JsonSqlServerLogicDefinition;
204
204
 
205
- export { type AnyJsonDataSourceDefinition, type DataSourceCacheConfig, type DataSourceDefinition, type DataSourceMediaType, type DataSourceMeta, type DataSourceResponse, type DataSourceSchemaObject, type JsonDataSourceDefinition, type JsonSqlDataSourceDefinition, type JsonTypeScriptDataSourceDefinition, type ParameterMeta, type SqlDataSourceDefinition, type SqlDataSourceMeta, type TypeScriptDataSourceDefinition, type TypeScriptDataSourceMeta, anyJsonDataSourceSchema, dataSourceCacheConfigSchema, dataSourceMediaTypeSchema, dataSourceResponseSchema, dataSourceSchemaObjectSchema, jsonSqlDataSourceSchema, jsonTypeScriptDataSourceSchema, parameterMetaSchema };
205
+ export { type AnyJsonServerLogicDefinition, type JsonServerLogicDefinition, type JsonSqlServerLogicDefinition, type JsonTypeScriptServerLogicDefinition, type ParameterMeta, type ServerLogicCacheConfig, type ServerLogicDefinition, type ServerLogicMediaType, type ServerLogicMeta, type ServerLogicResponse, type ServerLogicSchemaObject, type SqlServerLogicDefinition, type SqlServerLogicMeta, type TypeScriptServerLogicDefinition, type TypeScriptServerLogicMeta, anyJsonServerLogicSchema, jsonSqlServerLogicSchema, jsonTypeScriptServerLogicSchema, parameterMetaSchema, serverLogicCacheConfigSchema, serverLogicMediaTypeSchema, serverLogicResponseSchema, serverLogicSchemaObjectSchema };
@@ -1,4 +1,4 @@
1
- // src/types/data-source.ts
1
+ // src/types/server-logic.ts
2
2
  import { z } from "zod";
3
3
  var parameterMetaSchema = z.object({
4
4
  name: z.string(),
@@ -7,21 +7,21 @@ var parameterMetaSchema = z.object({
7
7
  required: z.boolean().optional(),
8
8
  default: z.union([z.string(), z.number(), z.boolean()]).optional()
9
9
  });
10
- var dataSourceCacheConfigSchema = z.object({
10
+ var serverLogicCacheConfigSchema = z.object({
11
11
  ttl: z.number(),
12
12
  staleWhileRevalidate: z.boolean().optional()
13
13
  });
14
- var dataSourceSchemaObjectSchema = z.lazy(
14
+ var serverLogicSchemaObjectSchema = z.lazy(
15
15
  () => z.object({
16
16
  type: z.enum(["string", "number", "integer", "boolean", "object", "array", "null"]).optional(),
17
17
  format: z.string().optional(),
18
18
  description: z.string().optional(),
19
19
  nullable: z.boolean().optional(),
20
20
  enum: z.array(z.union([z.string(), z.number(), z.boolean(), z.null()])).optional(),
21
- items: dataSourceSchemaObjectSchema.optional(),
22
- properties: z.record(z.string(), dataSourceSchemaObjectSchema).optional(),
21
+ items: serverLogicSchemaObjectSchema.optional(),
22
+ properties: z.record(z.string(), serverLogicSchemaObjectSchema).optional(),
23
23
  required: z.array(z.string()).optional(),
24
- additionalProperties: z.union([z.boolean(), dataSourceSchemaObjectSchema]).optional(),
24
+ additionalProperties: z.union([z.boolean(), serverLogicSchemaObjectSchema]).optional(),
25
25
  minimum: z.number().optional(),
26
26
  maximum: z.number().optional(),
27
27
  minLength: z.number().optional(),
@@ -29,42 +29,42 @@ var dataSourceSchemaObjectSchema = z.lazy(
29
29
  pattern: z.string().optional()
30
30
  })
31
31
  );
32
- var dataSourceMediaTypeSchema = z.object({
33
- schema: dataSourceSchemaObjectSchema.optional(),
32
+ var serverLogicMediaTypeSchema = z.object({
33
+ schema: serverLogicSchemaObjectSchema.optional(),
34
34
  example: z.unknown().optional()
35
35
  });
36
- var dataSourceResponseSchema = z.object({
36
+ var serverLogicResponseSchema = z.object({
37
37
  description: z.string().optional(),
38
- content: z.record(z.string(), dataSourceMediaTypeSchema).optional()
38
+ content: z.record(z.string(), serverLogicMediaTypeSchema).optional()
39
39
  });
40
40
  var jsonBaseFields = {
41
41
  description: z.string(),
42
42
  parameters: z.array(parameterMetaSchema).optional(),
43
- response: dataSourceResponseSchema.optional(),
44
- cache: dataSourceCacheConfigSchema.optional()
43
+ response: serverLogicResponseSchema.optional(),
44
+ cache: serverLogicCacheConfigSchema.optional()
45
45
  };
46
- var jsonSqlDataSourceSchema = z.object({
46
+ var jsonSqlServerLogicSchema = z.object({
47
47
  ...jsonBaseFields,
48
48
  type: z.literal("sql").optional(),
49
49
  query: z.string(),
50
50
  connectionId: z.string()
51
51
  });
52
- var jsonTypeScriptDataSourceSchema = z.object({
52
+ var jsonTypeScriptServerLogicSchema = z.object({
53
53
  ...jsonBaseFields,
54
54
  type: z.literal("typescript"),
55
55
  handlerPath: z.string()
56
56
  });
57
- var anyJsonDataSourceSchema = z.union([
58
- jsonTypeScriptDataSourceSchema,
59
- jsonSqlDataSourceSchema
57
+ var anyJsonServerLogicSchema = z.union([
58
+ jsonTypeScriptServerLogicSchema,
59
+ jsonSqlServerLogicSchema
60
60
  ]);
61
61
  export {
62
- anyJsonDataSourceSchema,
63
- dataSourceCacheConfigSchema,
64
- dataSourceMediaTypeSchema,
65
- dataSourceResponseSchema,
66
- dataSourceSchemaObjectSchema,
67
- jsonSqlDataSourceSchema,
68
- jsonTypeScriptDataSourceSchema,
69
- parameterMetaSchema
62
+ anyJsonServerLogicSchema,
63
+ jsonSqlServerLogicSchema,
64
+ jsonTypeScriptServerLogicSchema,
65
+ parameterMetaSchema,
66
+ serverLogicCacheConfigSchema,
67
+ serverLogicMediaTypeSchema,
68
+ serverLogicResponseSchema,
69
+ serverLogicSchemaObjectSchema
70
70
  };
@@ -190,7 +190,7 @@ function resolveParams(entry, connectionId, plugin) {
190
190
  // src/connector-client/index.ts
191
191
  var { getQuery, loadConnections, reloadEnvFile, watchConnectionsFile } = createConnectorRegistry();
192
192
 
193
- // src/types/data-source.ts
193
+ // src/types/server-logic.ts
194
194
  import { z } from "zod";
195
195
  var parameterMetaSchema = z.object({
196
196
  name: z.string(),
@@ -199,21 +199,21 @@ var parameterMetaSchema = z.object({
199
199
  required: z.boolean().optional(),
200
200
  default: z.union([z.string(), z.number(), z.boolean()]).optional()
201
201
  });
202
- var dataSourceCacheConfigSchema = z.object({
202
+ var serverLogicCacheConfigSchema = z.object({
203
203
  ttl: z.number(),
204
204
  staleWhileRevalidate: z.boolean().optional()
205
205
  });
206
- var dataSourceSchemaObjectSchema = z.lazy(
206
+ var serverLogicSchemaObjectSchema = z.lazy(
207
207
  () => z.object({
208
208
  type: z.enum(["string", "number", "integer", "boolean", "object", "array", "null"]).optional(),
209
209
  format: z.string().optional(),
210
210
  description: z.string().optional(),
211
211
  nullable: z.boolean().optional(),
212
212
  enum: z.array(z.union([z.string(), z.number(), z.boolean(), z.null()])).optional(),
213
- items: dataSourceSchemaObjectSchema.optional(),
214
- properties: z.record(z.string(), dataSourceSchemaObjectSchema).optional(),
213
+ items: serverLogicSchemaObjectSchema.optional(),
214
+ properties: z.record(z.string(), serverLogicSchemaObjectSchema).optional(),
215
215
  required: z.array(z.string()).optional(),
216
- additionalProperties: z.union([z.boolean(), dataSourceSchemaObjectSchema]).optional(),
216
+ additionalProperties: z.union([z.boolean(), serverLogicSchemaObjectSchema]).optional(),
217
217
  minimum: z.number().optional(),
218
218
  maximum: z.number().optional(),
219
219
  minLength: z.number().optional(),
@@ -221,34 +221,34 @@ var dataSourceSchemaObjectSchema = z.lazy(
221
221
  pattern: z.string().optional()
222
222
  })
223
223
  );
224
- var dataSourceMediaTypeSchema = z.object({
225
- schema: dataSourceSchemaObjectSchema.optional(),
224
+ var serverLogicMediaTypeSchema = z.object({
225
+ schema: serverLogicSchemaObjectSchema.optional(),
226
226
  example: z.unknown().optional()
227
227
  });
228
- var dataSourceResponseSchema = z.object({
228
+ var serverLogicResponseSchema = z.object({
229
229
  description: z.string().optional(),
230
- content: z.record(z.string(), dataSourceMediaTypeSchema).optional()
230
+ content: z.record(z.string(), serverLogicMediaTypeSchema).optional()
231
231
  });
232
232
  var jsonBaseFields = {
233
233
  description: z.string(),
234
234
  parameters: z.array(parameterMetaSchema).optional(),
235
- response: dataSourceResponseSchema.optional(),
236
- cache: dataSourceCacheConfigSchema.optional()
235
+ response: serverLogicResponseSchema.optional(),
236
+ cache: serverLogicCacheConfigSchema.optional()
237
237
  };
238
- var jsonSqlDataSourceSchema = z.object({
238
+ var jsonSqlServerLogicSchema = z.object({
239
239
  ...jsonBaseFields,
240
240
  type: z.literal("sql").optional(),
241
241
  query: z.string(),
242
242
  connectionId: z.string()
243
243
  });
244
- var jsonTypeScriptDataSourceSchema = z.object({
244
+ var jsonTypeScriptServerLogicSchema = z.object({
245
245
  ...jsonBaseFields,
246
246
  type: z.literal("typescript"),
247
247
  handlerPath: z.string()
248
248
  });
249
- var anyJsonDataSourceSchema = z.union([
250
- jsonTypeScriptDataSourceSchema,
251
- jsonSqlDataSourceSchema
249
+ var anyJsonServerLogicSchema = z.union([
250
+ jsonTypeScriptServerLogicSchema,
251
+ jsonSqlServerLogicSchema
252
252
  ]);
253
253
 
254
254
  // src/registry.ts
@@ -256,7 +256,7 @@ var viteServer = null;
256
256
  function setViteServer(server) {
257
257
  viteServer = server;
258
258
  }
259
- var defaultDataSourceDir = path2.join(process.cwd(), "data-source");
259
+ var defaultServerLogicDir = path2.join(process.cwd(), "server-logic");
260
260
 
261
261
  // src/vite-plugin.ts
262
262
  var DEFAULT_EXCLUDE = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squadbase/vite-server",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -12,8 +12,8 @@
12
12
  "types": "./dist/main.d.ts"
13
13
  },
14
14
  "./types": {
15
- "import": "./dist/types/data-source.js",
16
- "types": "./dist/types/data-source.d.ts"
15
+ "import": "./dist/types/server-logic.js",
16
+ "types": "./dist/types/server-logic.d.ts"
17
17
  },
18
18
  "./plugin": {
19
19
  "import": "./dist/vite-plugin.js",
@@ -35,7 +35,7 @@
35
35
  "access": "public"
36
36
  },
37
37
  "bin": {
38
- "squadbase-ds-test": "./dist/cli/index.js"
38
+ "squadbase-sl-test": "./dist/cli/index.js"
39
39
  },
40
40
  "scripts": {
41
41
  "cli": "tsx src/cli/index.ts",
@@ -45,7 +45,7 @@
45
45
  "build:cli": "tsup src/cli/index.ts --out-dir dist/cli --format esm --platform node --no-splitting --external pg --external snowflake-sdk --external @google-cloud/bigquery --external mysql2 --external @aws-sdk/client-athena --external @aws-sdk/client-redshift-data --external @databricks/sql --external @google-analytics/data --external @kintone/rest-api-client --external hono --external @clack/prompts"
46
46
  },
47
47
  "dependencies": {
48
- "@squadbase/connectors": "^0.0.14",
48
+ "@squadbase/connectors": "^0.0.16",
49
49
  "@aws-sdk/client-athena": "^3.750.0",
50
50
  "@aws-sdk/client-redshift-data": "^3.750.0",
51
51
  "@databricks/sql": "^1.8.0",