silgi 0.3.12 → 0.4.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.
Files changed (70) hide show
  1. package/README.md +1 -31
  2. package/cli.d.ts +1 -0
  3. package/config.d.ts +1 -0
  4. package/core.d.ts +1 -0
  5. package/dist/_chunks/index.mjs +233 -0
  6. package/dist/cli/compatibility.mjs +42 -0
  7. package/dist/cli/index.mjs +3 -178
  8. package/dist/cli/prepare.mjs +1346 -0
  9. package/dist/config/index.d.mts +5 -0
  10. package/dist/config/index.d.ts +5 -0
  11. package/dist/core/index.d.mts +136 -0
  12. package/dist/core/index.d.ts +136 -0
  13. package/dist/core/index.mjs +1444 -0
  14. package/dist/ecosystem/nitro/index.mjs +21 -10
  15. package/dist/ecosystem/nuxt/module.mjs +4 -6
  16. package/dist/kit/index.d.mts +90 -0
  17. package/dist/kit/index.d.ts +90 -0
  18. package/dist/kit/index.mjs +316 -0
  19. package/dist/meta/index.d.mts +3 -0
  20. package/dist/meta/index.d.ts +3 -0
  21. package/dist/meta/index.mjs +1 -0
  22. package/dist/presets/_all.gen.d.ts +2 -0
  23. package/dist/presets/_all.gen.mjs +8 -0
  24. package/dist/presets/_resolve.d.ts +8 -0
  25. package/dist/presets/_resolve.mjs +58 -0
  26. package/dist/presets/_types.gen.d.ts +5 -0
  27. package/dist/presets/_types.gen.mjs +1 -0
  28. package/dist/presets/h3/preset.d.ts +2 -0
  29. package/dist/presets/h3/preset.mjs +22 -0
  30. package/dist/presets/index.d.mts +1 -0
  31. package/dist/presets/index.d.ts +2 -0
  32. package/dist/presets/index.mjs +1 -0
  33. package/dist/presets/nitro/preset.d.ts +2 -0
  34. package/dist/presets/nitro/preset.mjs +26 -0
  35. package/dist/presets/npmpackage/preset.d.ts +2 -0
  36. package/dist/presets/npmpackage/preset.mjs +23 -0
  37. package/dist/runtime/index.d.ts +1 -0
  38. package/dist/runtime/index.mjs +1 -0
  39. package/dist/runtime/internal/debug.d.ts +2 -0
  40. package/dist/runtime/internal/debug.mjs +5 -0
  41. package/dist/runtime/internal/nitro.d.ts +2 -0
  42. package/dist/runtime/internal/nitro.mjs +45 -0
  43. package/dist/runtime/internal/plugin.d.ts +3 -0
  44. package/dist/runtime/internal/plugin.mjs +4 -0
  45. package/dist/shared/silgi.40ZJYm8F.d.mts +11 -0
  46. package/dist/shared/silgi.40ZJYm8F.d.ts +11 -0
  47. package/dist/shared/{silgi.ClpvycKI.d.mts → silgi.D8h2AAVk.d.ts} +451 -437
  48. package/dist/shared/{silgi.ClpvycKI.d.ts → silgi.DSHNePNA.d.mts} +451 -437
  49. package/dist/types/index.d.mts +42 -0
  50. package/dist/types/index.d.ts +42 -0
  51. package/dist/types/index.mjs +1 -0
  52. package/kit.d.ts +1 -0
  53. package/meta.d.ts +1 -0
  54. package/package.json +89 -39
  55. package/presets.d.ts +1 -0
  56. package/runtime-meta.d.ts +4 -0
  57. package/runtime-meta.mjs +32 -0
  58. package/runtime.d.ts +1 -0
  59. package/types.d.ts +1 -0
  60. package/bin/silgi.mjs +0 -3
  61. package/dist/chunks/generate.mjs +0 -1258
  62. package/dist/cli/config.d.mts +0 -1633
  63. package/dist/cli/config.d.ts +0 -1633
  64. package/dist/index.d.mts +0 -196
  65. package/dist/index.d.ts +0 -196
  66. package/dist/index.mjs +0 -499
  67. package/dist/shared/silgi.b9yhSIGd.mjs +0 -459
  68. package/dist/shared/silgi.mBwNj1W0.mjs +0 -386
  69. /package/dist/{chunks → cli}/init.mjs +0 -0
  70. /package/dist/{cli/config.mjs → config/index.mjs} +0 -0
@@ -0,0 +1,2 @@
1
+ declare const _default: readonly [any];
2
+ export default _default;
@@ -0,0 +1,22 @@
1
+ import { defineSilgiPreset } from "silgi/kit";
2
+ const h3 = defineSilgiPreset(
3
+ {
4
+ static: true,
5
+ output: {
6
+ dir: "{{ rootDir }}/.output",
7
+ publicDir: "{{ output.dir }}/public"
8
+ },
9
+ prerender: {
10
+ crawlLinks: true
11
+ },
12
+ commands: {
13
+ preview: "npx serve ./public"
14
+ }
15
+ },
16
+ {
17
+ name: "h3",
18
+ static: true,
19
+ url: import.meta.url
20
+ }
21
+ );
22
+ export default [h3];
@@ -0,0 +1 @@
1
+ export { resolvePreset } from "./_resolve";
@@ -0,0 +1,2 @@
1
+ export { resolvePreset } from './_resolve';
2
+ export type { PresetName, PresetNameInput, PresetOptions } from './_types.gen';
@@ -0,0 +1 @@
1
+ export { resolvePreset } from './_resolve.mjs'
@@ -0,0 +1,2 @@
1
+ declare const _default: readonly [any];
2
+ export default _default;
@@ -0,0 +1,26 @@
1
+ import { defineSilgiPreset } from "silgi/kit";
2
+ const nitro = defineSilgiPreset(
3
+ {
4
+ static: true,
5
+ output: {
6
+ dir: "{{ rootDir }}/.output",
7
+ publicDir: "{{ output.dir }}/public"
8
+ },
9
+ prerender: {
10
+ crawlLinks: true
11
+ },
12
+ typescript: {
13
+ generateTsConfig: false,
14
+ tsconfigPath: ".nitro/types/silgi.tsconfig.json"
15
+ },
16
+ commands: {
17
+ preview: "npx serve ./public"
18
+ }
19
+ },
20
+ {
21
+ name: "nitro",
22
+ static: true,
23
+ url: import.meta.url
24
+ }
25
+ );
26
+ export default [nitro];
@@ -0,0 +1,2 @@
1
+ declare const _default: readonly [any];
2
+ export default _default;
@@ -0,0 +1,23 @@
1
+ import { defineSilgiPreset } from "silgi/kit";
2
+ const npmPackage = defineSilgiPreset(
3
+ {
4
+ output: {
5
+ dir: "{{ rootDir }}/.output",
6
+ publicDir: "{{ output.dir }}/public"
7
+ },
8
+ serverDir: "{{ rootDir }}/src",
9
+ silgi: {
10
+ serverDir: "{{ serverDir }}/silgi"
11
+ },
12
+ modules: ["./src"],
13
+ commands: {
14
+ preview: "npx serve ./public"
15
+ }
16
+ },
17
+ {
18
+ name: "npm-package",
19
+ compatibilityDate: "2025-02-04",
20
+ url: import.meta.url
21
+ }
22
+ );
23
+ export default [npmPackage];
@@ -0,0 +1 @@
1
+ export { defineSilgiPlugin } from './internal/plugin';
@@ -0,0 +1 @@
1
+ export { defineSilgiPlugin } from "./internal/plugin.mjs";
@@ -0,0 +1,2 @@
1
+ declare const _default: SilgiAppPlugin;
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { createDebugger } from "hookable";
2
+ import { defineSilgiPlugin } from "./plugin.mjs";
3
+ export default defineSilgiPlugin((silgi) => {
4
+ createDebugger(silgi.hooks, { tag: "silgi-runtime" });
5
+ });
@@ -0,0 +1,2 @@
1
+ import type { Silgi } from 'silgi/types';
2
+ export default function addNitroApp(silgiCtx?: Silgi): Promise<void>;
@@ -0,0 +1,45 @@
1
+ import { createError, defineEventHandler, getQuery, readBody } from "h3";
2
+ import { silgi, SilgiError, useSilgi } from "silgi/core";
3
+ export default async function addNitroApp(silgiCtx = useSilgi()) {
4
+ const nitro = silgiCtx.framework;
5
+ nitro.router.use("/srn/**", defineEventHandler({
6
+ handler: async (event) => {
7
+ const ctx = useSilgi();
8
+ if (ctx.options.environment === "nitrojs" || ctx.options.environment === "h3") {
9
+ const silgiConnect = silgi(event);
10
+ const query = getQuery(event);
11
+ const body = await readBody(event).catch(() => {
12
+ });
13
+ let newPath = event.path;
14
+ if (event.path.includes("?")) {
15
+ newPath = `${event.path}&method=${event.method}`;
16
+ } else {
17
+ newPath = `${event.path}?method=${event.method}`;
18
+ }
19
+ try {
20
+ const data = await silgiConnect.execute(newPath, {
21
+ ...query,
22
+ ...body
23
+ });
24
+ if (data.success) {
25
+ return data.data;
26
+ }
27
+ } catch (error) {
28
+ if (error instanceof SilgiError && error.code.startsWith("URI_PARSE_ERROR")) {
29
+ throw createError({
30
+ statusCode: 400,
31
+ message: error.message
32
+ });
33
+ }
34
+ throw error;
35
+ }
36
+ return {
37
+ path: event.path,
38
+ method: event.method,
39
+ body,
40
+ query
41
+ };
42
+ }
43
+ }
44
+ }));
45
+ }
@@ -0,0 +1,3 @@
1
+ import type { SilgiAppPlugin } from 'silgi/types';
2
+ export declare function defineSilgiPlugin(def: SilgiAppPlugin): SilgiAppPlugin;
3
+ export declare const silgiPlugin: typeof defineSilgiPlugin;
@@ -0,0 +1,4 @@
1
+ export function defineSilgiPlugin(def) {
2
+ return def;
3
+ }
4
+ export const silgiPlugin = defineSilgiPlugin;
@@ -0,0 +1,11 @@
1
+ import { SilgiEvent, SilgiURIs, ExtractInputFromURI, MethodResponse, ExtractOutputFromURI, Silgi, StorageConfig } from 'silgi/types';
2
+ import { Storage, StorageValue } from 'unstorage';
3
+
4
+ declare function silgi(event?: SilgiEvent | Record<string, any>): {
5
+ execute: <TURI extends keyof SilgiURIs>(uriString: TURI, input: ExtractInputFromURI<TURI>) => Promise<MethodResponse<ExtractOutputFromURI<TURI>>>;
6
+ };
7
+
8
+ declare function createStorage(silgi: Silgi): Promise<Storage<StorageValue>>;
9
+ declare function useStorage<T extends StorageValue = StorageValue>(base?: StorageConfig<T>['base']): Storage<T>;
10
+
11
+ export { createStorage as c, silgi as s, useStorage as u };
@@ -0,0 +1,11 @@
1
+ import { SilgiEvent, SilgiURIs, ExtractInputFromURI, MethodResponse, ExtractOutputFromURI, Silgi, StorageConfig } from 'silgi/types';
2
+ import { Storage, StorageValue } from 'unstorage';
3
+
4
+ declare function silgi(event?: SilgiEvent | Record<string, any>): {
5
+ execute: <TURI extends keyof SilgiURIs>(uriString: TURI, input: ExtractInputFromURI<TURI>) => Promise<MethodResponse<ExtractOutputFromURI<TURI>>>;
6
+ };
7
+
8
+ declare function createStorage(silgi: Silgi): Promise<Storage<StorageValue>>;
9
+ declare function useStorage<T extends StorageValue = StorageValue>(base?: StorageConfig<T>['base']): Storage<T>;
10
+
11
+ export { createStorage as c, silgi as s, useStorage as u };