silgi 0.27.12 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/build.mjs CHANGED
@@ -23,6 +23,7 @@ import 'ufo';
23
23
  import 'defu';
24
24
  import 'hookable';
25
25
  import 'silgi';
26
+ import 'unadapter';
26
27
  import './_chunks/routeRules.mjs';
27
28
  import '@clack/prompts';
28
29
  import 'dotenv';
package/dist/cli/dev.mjs CHANGED
@@ -30,6 +30,7 @@ import 'pkg-types';
30
30
  import 'ufo';
31
31
  import 'defu';
32
32
  import 'hookable';
33
+ import 'unadapter';
33
34
  import '../_chunks/routeRules.mjs';
34
35
  import '@clack/prompts';
35
36
  import 'dotenv';
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.27.12";
4
+ const version = "0.28.0";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
package/dist/cli/init.mjs CHANGED
@@ -27,6 +27,7 @@ import 'ufo';
27
27
  import 'defu';
28
28
  import 'hookable';
29
29
  import 'silgi';
30
+ import 'unadapter';
30
31
  import '../_chunks/routeRules.mjs';
31
32
  import 'dotenv';
32
33
  import 'dev-jiti';
@@ -18,6 +18,7 @@ import 'unimport';
18
18
  import 'untyped';
19
19
  import 'hookable';
20
20
  import 'silgi';
21
+ import 'unadapter';
21
22
  import '../_chunks/routeRules.mjs';
22
23
  import 'ufo';
23
24
  import '@clack/prompts';
@@ -147,45 +147,62 @@ const command$1 = defineCommand({
147
147
  }
148
148
  ).flat();
149
149
  } else if (commandName === "functions") {
150
+ const functionGroups = Object.keys(cliJson).reduce((groups, cmdName) => {
151
+ const scripts2 = cliJson[cmdName];
152
+ if (!Object.values(scripts2).some((script) => script.type === "function")) {
153
+ return groups;
154
+ }
155
+ groups.push(cmdName);
156
+ return groups;
157
+ }, []);
158
+ if (functionGroups.length === 0) {
159
+ consola.warn("No function groups found in cli.json");
160
+ return;
161
+ }
162
+ const selectedGroup = await p.select({
163
+ message: "Select a project group",
164
+ options: functionGroups.map((group) => ({
165
+ label: group,
166
+ value: group
167
+ }))
168
+ });
169
+ if (!selectedGroup)
170
+ return;
150
171
  const availableFunctions = [];
151
- for (const cmd of Object.keys(cliJson)) {
152
- const scripts = cliJson[cmd];
153
- for (const scriptName of Object.keys(scripts)) {
154
- const script = scripts[scriptName];
155
- if (script && script.type === "function") {
156
- availableFunctions.push({
157
- command: cmd,
158
- script: scriptName,
159
- handler: script
160
- });
161
- }
172
+ const scripts = cliJson[selectedGroup];
173
+ for (const scriptName of Object.keys(scripts)) {
174
+ const script = scripts[scriptName];
175
+ if (script && script.type === "function") {
176
+ availableFunctions.push({
177
+ command: selectedGroup,
178
+ script: scriptName,
179
+ handler: script
180
+ });
162
181
  }
163
182
  }
164
183
  if (availableFunctions.length === 0) {
165
- consola.warn("No functions found in cli.json");
184
+ consola.warn(`No functions found in the ${selectedGroup} group`);
166
185
  return;
167
186
  }
168
187
  const selectedFunction = await p.select({
169
- message: "Select a function to run",
170
- options: availableFunctions.map((fn) => ({
171
- label: `${fn.command} \u2192 ${fn.script}`,
172
- value: `${fn.command}:${fn.script}`,
188
+ message: `Select a function from ${selectedGroup}`,
189
+ options: availableFunctions.map((fn, index) => ({
190
+ label: fn.script,
191
+ value: index.toString(),
173
192
  hint: fn.handler.description || void 0
174
193
  }))
175
194
  });
176
195
  if (!selectedFunction)
177
196
  return;
178
- const [selectedCmd, selectedScript] = selectedFunction.split(":");
179
- const selectedFunctionObj = availableFunctions.find(
180
- (fn) => fn.command === selectedCmd && fn.script === selectedScript
181
- );
197
+ const selectedIndex = Number.parseInt(selectedFunction, 10);
198
+ const selectedFunctionObj = availableFunctions[selectedIndex];
182
199
  if (!selectedFunctionObj || !selectedFunctionObj.handler) {
183
- consola.error(`Function ${selectedCmd}:${selectedScript} not found or invalid`);
200
+ consola.error("Selected function not found or invalid");
184
201
  return;
185
202
  }
186
203
  selectedCommands = [{
187
- command: selectedCmd,
188
- script: selectedScript,
204
+ command: selectedFunctionObj.command,
205
+ script: selectedFunctionObj.script,
189
206
  handler: selectedFunctionObj.handler
190
207
  }];
191
208
  } else {
@@ -13,6 +13,7 @@ import { generateTypes, resolveSchema } from 'untyped';
13
13
  import { s as silgiGenerateType, l as loadOptions } from './types.mjs';
14
14
  import { createHooks, createDebugger } from 'hookable';
15
15
  import { useSilgiCLI, replaceRuntimeValues, silgiCLICtx, autoImportTypes } from 'silgi';
16
+ import { createAdapter } from 'unadapter';
16
17
  import { c as createRouteRules } from '../_chunks/routeRules.mjs';
17
18
  import * as p from '@clack/prompts';
18
19
  import * as dotenv from 'dotenv';
@@ -2346,8 +2347,17 @@ async function createSilgiCLI(config = {}, opts = {}) {
2346
2347
  hook: hooks.hook,
2347
2348
  async updateConfig(_config) {
2348
2349
  },
2349
- routeRules: void 0
2350
+ routeRules: void 0,
2351
+ adapter: void 0
2350
2352
  };
2353
+ if (Object.keys(silgi.options.database).length) {
2354
+ for (const [key, value] of Object.entries(silgi.options.database)) {
2355
+ silgi.adapter[key] = createAdapter(
2356
+ value.tables,
2357
+ value.adapter
2358
+ );
2359
+ }
2360
+ }
2351
2361
  await prepareEnv(options);
2352
2362
  const routeRules = createRouteRules();
2353
2363
  routeRules.importRules(options.routeRules ?? {});
@@ -8,6 +8,7 @@ import { Ignore, Options } from 'ignore';
8
8
  import { TSConfig } from 'pkg-types';
9
9
  import { PresetName, PresetOptions, PresetNameInput } from 'silgi/presets';
10
10
  import { ResolvedServiceType as ResolvedServiceType$1, SilgiRuntimeShareds as SilgiRuntimeShareds$1, SilgiRuntimeOptions as SilgiRuntimeOptions$1, RouteRules as RouteRules$1, ModuleMeta as ModuleMeta$1, SilgiModule as SilgiModule$1, SilgiRouteRules as SilgiRouteRules$1, DotenvOptions as DotenvOptions$1, EnvOptions as EnvOptions$1, SilgiRuntimeConfig as SilgiRuntimeConfig$1, ServiceParseModule as ServiceParseModule$1, SilgiCLIHooks as SilgiCLIHooks$1, StorageMounts as StorageMounts$1, SilgiTemplate as SilgiTemplate$1, SilgiFrameworkInfo as SilgiFrameworkInfo$1 } from 'silgi/types';
11
+ import { Adapter, TablesSchema, InferModelTypes, AdapterOptions } from 'unadapter/types';
11
12
  import { UnimportPluginOptions } from 'unimport/unplugin';
12
13
  import { H3Event } from 'h3';
13
14
  import { NitroRuntimeConfig } from 'nitropack/types';
@@ -88,6 +89,7 @@ interface SilgiCLI {
88
89
  tags?: (keyof SilgiCommands)[];
89
90
  enabled?: boolean;
90
91
  }>>;
92
+ adapter: Record<string, Adapter<Record<string, any>, TablesSchema, InferModelTypes<TablesSchema>>>;
91
93
  }
92
94
  type SilgiCLIDynamicConfig = Pick<SilgiCLIConfig, 'routeRules'>;
93
95
  interface SilgiFrameworkInfo {
@@ -811,6 +813,10 @@ interface SilgiCLIOptions extends PresetOptions {
811
813
  }>>;
812
814
  installPackages: Record<'dependencies' | 'devDependencies', Record<string, string>>;
813
815
  apiFul: ApifulConfig;
816
+ database: Record<string, {
817
+ adapter: Adapter<any, TablesSchema, any>;
818
+ tables: (options: AdapterOptions) => TablesSchema;
819
+ } & AdapterOptions>;
814
820
  }
815
821
  /**
816
822
  * Silgi input config (silgi.config)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.27.12",
4
+ "version": "0.28.0",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {
@@ -81,9 +81,9 @@
81
81
  "destr": "^2.0.5",
82
82
  "dev-jiti": "^2.4.2",
83
83
  "dot-prop": "^9.0.0",
84
- "dotenv": "^16.4.7",
84
+ "dotenv": "^16.5.0",
85
85
  "escape-string-regexp": "^5.0.0",
86
- "exsolve": "^1.0.4",
86
+ "exsolve": "^1.0.5",
87
87
  "globby": "^14.1.0",
88
88
  "hookable": "^5.5.3",
89
89
  "ignore": "^7.0.3",
@@ -99,6 +99,7 @@
99
99
  "semver": "^7.7.1",
100
100
  "std-env": "^3.9.0",
101
101
  "ufo": "^1.6.1",
102
+ "unadapter": "^0.1.0",
102
103
  "unctx": "^2.4.1",
103
104
  "unimport": "^5.0.0",
104
105
  "unstorage": "^1.15.0",
@@ -108,19 +109,19 @@
108
109
  "@antfu/eslint-config": "^4.12.0",
109
110
  "@nuxt/kit": "^3.16.2",
110
111
  "@nuxt/schema": "^3.16.2",
111
- "@silgi/ecosystem": "^0.4.6",
112
- "@types/node": "^22.14.0",
112
+ "@silgi/ecosystem": "^0.4.10",
113
+ "@types/node": "^22.14.1",
113
114
  "@types/semver": "^7.7.0",
114
115
  "@vitest/coverage-v8": "3.0.5",
115
- "eslint": "^9.24.0",
116
+ "eslint": "^9.25.0",
116
117
  "h3": "^1.15.1",
117
- "nitropack": "^2.11.8",
118
+ "nitropack": "^2.11.9",
118
119
  "nuxt": "^3.16.2",
119
120
  "typescript": "^5.8.3",
120
121
  "unbuild": "^3.5.0",
121
122
  "vitest": "^3.1.1",
122
123
  "vue": "^3.5.13",
123
- "zod": "^3.24.2"
124
+ "zod": "^3.24.3"
124
125
  },
125
126
  "resolutions": {
126
127
  "silgi": "link:."