silgi 0.3.13 → 0.4.1
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/README.md +1 -31
- package/cli.d.ts +1 -0
- package/config.d.ts +1 -0
- package/core.d.ts +1 -0
- package/dist/_chunks/index.mjs +233 -0
- package/dist/cli/compatibility.mjs +42 -0
- package/dist/cli/index.mjs +3 -184
- package/dist/cli/prepare.mjs +1350 -0
- package/dist/config/index.d.mts +5 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/core/index.d.mts +136 -0
- package/dist/core/index.d.ts +136 -0
- package/dist/core/index.mjs +1444 -0
- package/dist/ecosystem/nitro/index.mjs +21 -29
- package/dist/ecosystem/nuxt/module.mjs +4 -25
- package/dist/kit/index.d.mts +90 -0
- package/dist/kit/index.d.ts +90 -0
- package/dist/kit/index.mjs +316 -0
- package/dist/meta/index.d.mts +3 -0
- package/dist/meta/index.d.ts +3 -0
- package/dist/meta/index.mjs +1 -0
- package/dist/presets/_all.gen.d.ts +2 -0
- package/dist/presets/_all.gen.mjs +10 -0
- package/dist/presets/_resolve.d.ts +8 -0
- package/dist/presets/_resolve.mjs +58 -0
- package/dist/presets/_types.gen.d.ts +5 -0
- package/dist/presets/_types.gen.mjs +1 -0
- package/dist/presets/h3/preset.d.ts +2 -0
- package/dist/presets/h3/preset.mjs +22 -0
- package/dist/presets/index.d.mts +1 -0
- package/dist/presets/index.d.ts +2 -0
- package/dist/presets/index.mjs +1 -0
- package/dist/presets/nitro/preset.d.ts +2 -0
- package/dist/presets/nitro/preset.mjs +26 -0
- package/dist/presets/npmpackage/preset.d.ts +2 -0
- package/dist/presets/npmpackage/preset.mjs +23 -0
- package/dist/presets/nuxt/preset.d.ts +2 -0
- package/dist/presets/nuxt/preset.mjs +26 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.mjs +1 -0
- package/dist/runtime/internal/debug.d.ts +2 -0
- package/dist/runtime/internal/debug.mjs +5 -0
- package/dist/runtime/internal/nitro.d.ts +2 -0
- package/dist/runtime/internal/nitro.mjs +45 -0
- package/dist/runtime/internal/plugin.d.ts +3 -0
- package/dist/runtime/internal/plugin.mjs +4 -0
- package/dist/shared/silgi.40ZJYm8F.d.mts +11 -0
- package/dist/shared/silgi.40ZJYm8F.d.ts +11 -0
- package/dist/shared/{silgi.ClpvycKI.d.ts → silgi.CzUPBllI.d.mts} +452 -438
- package/dist/shared/{silgi.ClpvycKI.d.mts → silgi.D_LzzCtJ.d.ts} +452 -438
- package/dist/types/index.d.mts +42 -0
- package/dist/types/index.d.ts +42 -0
- package/dist/types/index.mjs +1 -0
- package/kit.d.ts +1 -0
- package/meta.d.ts +1 -0
- package/package.json +89 -39
- package/presets.d.ts +1 -0
- package/runtime-meta.d.ts +4 -0
- package/runtime-meta.mjs +32 -0
- package/runtime.d.ts +1 -0
- package/types.d.ts +1 -0
- package/bin/silgi.mjs +0 -3
- package/dist/chunks/generate.mjs +0 -1257
- package/dist/cli/config.d.mts +0 -1633
- package/dist/cli/config.d.ts +0 -1633
- package/dist/index.d.mts +0 -198
- package/dist/index.d.ts +0 -198
- package/dist/index.mjs +0 -503
- package/dist/shared/silgi.D2yb1XAa.mjs +0 -842
- /package/dist/{chunks → cli}/init.mjs +0 -0
- /package/dist/{cli/config.mjs → config/index.mjs} +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatCompatibilityDate,
|
|
3
|
+
resolveCompatibilityDatesFromEnv
|
|
4
|
+
} from "compatx";
|
|
5
|
+
import { kebabCase } from "scule";
|
|
6
|
+
import { provider } from "std-env";
|
|
7
|
+
import allPresets from "./_all.gen.mjs";
|
|
8
|
+
const _stdProviderMap = {
|
|
9
|
+
aws_amplify: "aws",
|
|
10
|
+
azure_static: "azure",
|
|
11
|
+
cloudflare_pages: "cloudflare"
|
|
12
|
+
};
|
|
13
|
+
export async function resolvePreset(name, opts) {
|
|
14
|
+
const _name = kebabCase(name) || provider;
|
|
15
|
+
const _compatDates = opts.compatibilityDate ? resolveCompatibilityDatesFromEnv(opts.compatibilityDate) : false;
|
|
16
|
+
const matches = allPresets.filter((preset2) => {
|
|
17
|
+
const names = [preset2._meta.name, preset2._meta.stdName, ...preset2._meta.aliases || []].filter(Boolean);
|
|
18
|
+
if (!names.includes(_name)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (_compatDates) {
|
|
22
|
+
const _date = _compatDates[_stdProviderMap[preset2._meta.stdName]] || _compatDates[preset2._meta.stdName] || _compatDates[preset2._meta.name] || _compatDates.default;
|
|
23
|
+
if (_date && preset2._meta.compatibilityDate && new Date(preset2._meta.compatibilityDate) > new Date(_date)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}).sort((a, b) => {
|
|
29
|
+
const aDate = new Date(a._meta.compatibilityDate || 0);
|
|
30
|
+
const bDate = new Date(b._meta.compatibilityDate || 0);
|
|
31
|
+
return bDate > aDate ? 1 : -1;
|
|
32
|
+
});
|
|
33
|
+
const preset = matches.find(
|
|
34
|
+
(p) => (p._meta.static || false) === (opts?.static || false)
|
|
35
|
+
) || matches[0];
|
|
36
|
+
if (typeof preset === "function") {
|
|
37
|
+
return preset();
|
|
38
|
+
}
|
|
39
|
+
if (!name && !preset) {
|
|
40
|
+
return opts?.static ? resolvePreset("static", opts) : resolvePreset("node-server", opts);
|
|
41
|
+
}
|
|
42
|
+
if (name && !preset) {
|
|
43
|
+
const options = allPresets.filter((p) => p._meta.name === name || p._meta.stdName === name || p._meta.aliases?.includes(name)).sort((a, b) => (a._meta.compatibilityDate || 0) > (b._meta.compatibilityDate || 0) ? 1 : -1);
|
|
44
|
+
if (options.length > 0) {
|
|
45
|
+
let msg = `Preset "${name}" cannot be resolved with current compatibilityDate: ${formatCompatibilityDate(_compatDates || "")}.
|
|
46
|
+
|
|
47
|
+
`;
|
|
48
|
+
for (const option of options) {
|
|
49
|
+
msg += `
|
|
50
|
+
- ${option._meta.name} (requires compatibilityDate >= ${option._meta.compatibilityDate})`;
|
|
51
|
+
}
|
|
52
|
+
const err = new Error(msg);
|
|
53
|
+
Error.captureStackTrace?.(err, resolvePreset);
|
|
54
|
+
throw err;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return preset;
|
|
58
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface PresetOptions {
|
|
2
|
+
}
|
|
3
|
+
export declare const presetsWithConfig: readonly [];
|
|
4
|
+
export type PresetName = "h3" | "nitro" | "npm-package" | "nuxt";
|
|
5
|
+
export type PresetNameInput = "h3" | "nitro" | "npm-package" | "npmPackage" | "npm_package" | "nuxt" | (string & {});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const presetsWithConfig = [];
|
|
@@ -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 @@
|
|
|
1
|
+
export { resolvePreset } from './_resolve.mjs'
|
|
@@ -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,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,26 @@
|
|
|
1
|
+
import { defineSilgiPreset } from "silgi/kit";
|
|
2
|
+
const nuxt = 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: ".nuxt/silgi.tsconfig.json"
|
|
15
|
+
},
|
|
16
|
+
commands: {
|
|
17
|
+
preview: "npx serve ./public"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "nuxt",
|
|
22
|
+
static: true,
|
|
23
|
+
url: import.meta.url
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
export default [nuxt];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineSilgiPlugin } from './internal/plugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineSilgiPlugin } from "./internal/plugin.mjs";
|
|
@@ -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,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 };
|