silgi 0.3.0 → 0.3.2
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/chunks/generate.mjs +15 -6
- package/dist/cli/config.d.mts +1 -1
- package/dist/cli/config.d.ts +1 -1
- package/dist/cli/index.mjs +2 -1
- package/dist/ecosystem/nuxt/module.mjs +10 -0
- package/dist/index.d.mts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.mjs +24 -1
- package/dist/shared/{silgi.DJkQv6rh.d.mts → silgi.Bv3UrLx7.d.mts} +1 -1
- package/dist/shared/{silgi.DJkQv6rh.d.ts → silgi.Bv3UrLx7.d.ts} +1 -1
- package/package.json +2 -1
package/dist/chunks/generate.mjs
CHANGED
|
@@ -575,21 +575,30 @@ async function generateRouterDTS(silgi) {
|
|
|
575
575
|
params: ${params}
|
|
576
576
|
}`;
|
|
577
577
|
}).join(",\n");
|
|
578
|
-
return ` '
|
|
578
|
+
return ` '/${path}': {
|
|
579
579
|
${methodEntries}
|
|
580
580
|
}`;
|
|
581
581
|
});
|
|
582
|
+
const nitro = [
|
|
583
|
+
"declare module 'nitropack/types' {",
|
|
584
|
+
" interface InternalApi extends RouterTypes {}",
|
|
585
|
+
"}"
|
|
586
|
+
];
|
|
582
587
|
const context = [
|
|
583
588
|
"import type { ExtractInputFromURI, ExtractOutputFromURI, ExtractRouterParamsFromURI } from 'silgi'",
|
|
584
589
|
"",
|
|
585
|
-
"export
|
|
590
|
+
"export interface RouterTypes {",
|
|
586
591
|
routerTypes.join(",\n"),
|
|
587
592
|
"}",
|
|
588
593
|
"",
|
|
589
594
|
"declare module 'silgi' {",
|
|
590
595
|
" interface SilgiRouterTypes extends RouterTypes {",
|
|
591
596
|
" }",
|
|
592
|
-
"}"
|
|
597
|
+
"}",
|
|
598
|
+
"",
|
|
599
|
+
silgi.options.environment === "h3" || silgi.options.environment === "nitrojs" ? nitro.join("\n") : "",
|
|
600
|
+
"",
|
|
601
|
+
"export {}"
|
|
593
602
|
].join("\n");
|
|
594
603
|
const outputPath = resolve(silgi.options.buildDir, "silgi-routes.d.ts");
|
|
595
604
|
await promises.writeFile(outputPath, context);
|
|
@@ -1213,9 +1222,9 @@ async function generate$1(mergeConfig) {
|
|
|
1213
1222
|
};
|
|
1214
1223
|
silgi._ignore = ignore(silgi.options.ignoreOptions);
|
|
1215
1224
|
silgi.hook("prepare:types", (opts) => {
|
|
1216
|
-
opts.references.push({ path: resolve(silgi.options.buildDir, "schema.d.ts") });
|
|
1217
|
-
opts.references.push({ path: resolve(silgi.options.buildDir, "h3.d.ts") });
|
|
1218
|
-
opts.references.push({ path: resolve(silgi.options.buildDir, "silgi-routes.d.ts") });
|
|
1225
|
+
opts.references.push({ path: resolve(silgi.options.buildDir, "./schema.d.ts") });
|
|
1226
|
+
opts.references.push({ path: resolve(silgi.options.buildDir, "./h3.d.ts") });
|
|
1227
|
+
opts.references.push({ path: resolve(silgi.options.buildDir, "./silgi-routes.d.ts") });
|
|
1219
1228
|
});
|
|
1220
1229
|
await generateUris(silgi);
|
|
1221
1230
|
await generateSilgiStorageBaseType(silgi);
|
package/dist/cli/config.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as unstorage from 'unstorage';
|
|
2
2
|
import * as net from 'net';
|
|
3
3
|
import * as consola from 'consola';
|
|
4
|
-
import { D as DeepPartial, S as SilgiOptions, a as SilgiModuleOptions } from '../shared/silgi.
|
|
4
|
+
import { D as DeepPartial, S as SilgiOptions, a as SilgiModuleOptions } from '../shared/silgi.Bv3UrLx7.mjs';
|
|
5
5
|
import 'hookable';
|
|
6
6
|
import 'ignore';
|
|
7
7
|
import '@standard-schema/spec';
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as unstorage from 'unstorage';
|
|
2
2
|
import * as net from 'net';
|
|
3
3
|
import * as consola from 'consola';
|
|
4
|
-
import { D as DeepPartial, S as SilgiOptions, a as SilgiModuleOptions } from '../shared/silgi.
|
|
4
|
+
import { D as DeepPartial, S as SilgiOptions, a as SilgiModuleOptions } from '../shared/silgi.Bv3UrLx7.js';
|
|
5
5
|
import 'hookable';
|
|
6
6
|
import 'ignore';
|
|
7
7
|
import '@standard-schema/spec';
|
package/dist/cli/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import consola from 'consola';
|
|
|
3
3
|
|
|
4
4
|
const name = "silgi";
|
|
5
5
|
const type = "module";
|
|
6
|
-
const version = "0.3.
|
|
6
|
+
const version = "0.3.2";
|
|
7
7
|
const packageManager = "pnpm@9.15.1";
|
|
8
8
|
const sideEffects = false;
|
|
9
9
|
const exports = {
|
|
@@ -99,6 +99,7 @@ const dependencies = {
|
|
|
99
99
|
klona: "^2.0.6",
|
|
100
100
|
mlly: "^1.7.4",
|
|
101
101
|
nitropack: "^2.10.4",
|
|
102
|
+
ofetch: "^1.4.1",
|
|
102
103
|
pathe: "^2.0.2",
|
|
103
104
|
"pkg-types": "^1.3.1",
|
|
104
105
|
scule: "^1.3.0",
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { defineNuxtModule } from '@nuxt/kit';
|
|
2
2
|
import { resolvePath } from 'mlly';
|
|
3
|
+
import { join } from 'pathe';
|
|
4
|
+
import { l as loadSilgiConfig } from '../../shared/silgi.2D3gmgW0.mjs';
|
|
5
|
+
import { r as relativeWithDot } from '../../shared/silgi.BNEdIEZH.mjs';
|
|
6
|
+
import 'c12';
|
|
7
|
+
import 'untyped';
|
|
8
|
+
import 'std-env';
|
|
3
9
|
|
|
4
10
|
const module = defineNuxtModule({
|
|
5
11
|
meta: {
|
|
@@ -11,9 +17,13 @@ const module = defineNuxtModule({
|
|
|
11
17
|
},
|
|
12
18
|
defaults: {},
|
|
13
19
|
async setup(options, nuxt) {
|
|
20
|
+
const silgi = await loadSilgiConfig({});
|
|
14
21
|
nuxt.options.build.transpile.push("silgi");
|
|
15
22
|
nuxt.options.nitro.modules ||= [];
|
|
16
23
|
nuxt.options.nitro.modules.push(await resolvePath("silgi/ecosystem/nitro"));
|
|
24
|
+
nuxt.hook("prepare:types", ({ references }) => {
|
|
25
|
+
references.push({ path: relativeWithDot(nuxt.options.buildDir, join(silgi.buildDir, "silgi.d.ts")) });
|
|
26
|
+
});
|
|
17
27
|
}
|
|
18
28
|
});
|
|
19
29
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { b as SilgiConfig, c as SilgiHelper, M as ModuleOptions,
|
|
2
|
-
export { F as Awaitable, G as CreateScope, D as DeepPartial, C as DefaultHooks, A as DefaultMethods, E as ExtendShared,
|
|
1
|
+
import { b as SilgiConfig, c as SilgiHelper, d as SilgiRouterTypes, M as ModuleOptions, e as ModuleDefinition, f as SilgiModule, B as BaseSchemaType, g as SilgiServiceInterface, h as DefaultNamespaces, i as Silgi, j as SilgiOperation, k as MergedSilgiSchema, l as ServiceType, m as SilgiSchema, R as RequiredServiceType, n as SilgiModuleShared } from './shared/silgi.Bv3UrLx7.mjs';
|
|
2
|
+
export { F as Awaitable, G as CreateScope, D as DeepPartial, C as DefaultHooks, A as DefaultMethods, E as ExtendShared, u as ExtractInputFromURI, v as ExtractOutputFromURI, w as ExtractRouterParamsFromURI, s as SilgiDefaultShared, o as SilgiEvent, z as SilgiHook, p as SilgiModuleMethods, a as SilgiModuleOptions, q as SilgiModules, r as SilgiNamespaces, S as SilgiOptions, x as SilgiStorageBase, t as SilgiURIs, U as URIsTypes, y as silgi } from './shared/silgi.Bv3UrLx7.mjs';
|
|
3
|
+
import { FetchOptions } from 'ofetch';
|
|
3
4
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
5
|
import * as unctx_index from 'unctx/index';
|
|
5
6
|
import 'consola';
|
|
@@ -54,6 +55,20 @@ declare class SilgiError extends Error {
|
|
|
54
55
|
static isSilgiError(error: unknown): error is SilgiError;
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
type RequestBodyOption<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route]> = SilgiRouterTypes[Route][Method] extends {
|
|
59
|
+
input: any;
|
|
60
|
+
} ? {
|
|
61
|
+
body: SilgiRouterTypes[Route][Method]['input'];
|
|
62
|
+
} : {
|
|
63
|
+
body?: never;
|
|
64
|
+
};
|
|
65
|
+
type DefaultMethod<Route extends keyof SilgiRouterTypes> = 'get' extends keyof SilgiRouterTypes[Route] ? 'get' : keyof SilgiRouterTypes[Route];
|
|
66
|
+
type OpenFetchOptions<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = DefaultMethod<Route>> = Partial<{
|
|
67
|
+
method: Method;
|
|
68
|
+
}> & RequestBodyOption<Route, Method> & Omit<FetchOptions, 'query' | 'body' | 'method'>;
|
|
69
|
+
type SilgiFetchClient = <Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = DefaultMethod<Route>>(url: Route, options?: OpenFetchOptions<Route, Method>) => Promise<SilgiRouterTypes[Route][Method]['output']>;
|
|
70
|
+
declare function createSilgiFetch(options: FetchOptions | ((options: FetchOptions) => FetchOptions), localFetch?: typeof globalThis.$fetch): SilgiFetchClient;
|
|
71
|
+
|
|
57
72
|
/**
|
|
58
73
|
* Define a Nuxt module, automatically merging defaults with user provided options, installing
|
|
59
74
|
* any hooks that are provided, and calling an optional setup function for full control.
|
|
@@ -151,4 +166,4 @@ declare function createSchema<T extends Partial<Record<keyof DefaultNamespaces,
|
|
|
151
166
|
};
|
|
152
167
|
};
|
|
153
168
|
|
|
154
|
-
export { DefaultNamespaces, type ExtendContext, MergedSilgiSchema, type Namespaces, ServiceType, Silgi, SilgiError, SilgiHelper, type SilgiModuleContext, SilgiModuleShared, SilgiSchema, createResolver, createSchema, createService, createShared, createSilgi, defineSilgiModule, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, relativeWithDot, silgiCtx, tryUseSilgi, useHook, useShared, useSilgi };
|
|
169
|
+
export { DefaultNamespaces, type ExtendContext, MergedSilgiSchema, type Namespaces, ServiceType, Silgi, SilgiError, SilgiHelper, type SilgiModuleContext, SilgiModuleShared, SilgiRouterTypes, SilgiSchema, createResolver, createSchema, createService, createShared, createSilgi, createSilgiFetch, defineSilgiModule, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, relativeWithDot, silgiCtx, tryUseSilgi, useHook, useShared, useSilgi };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { b as SilgiConfig, c as SilgiHelper, M as ModuleOptions,
|
|
2
|
-
export { F as Awaitable, G as CreateScope, D as DeepPartial, C as DefaultHooks, A as DefaultMethods, E as ExtendShared,
|
|
1
|
+
import { b as SilgiConfig, c as SilgiHelper, d as SilgiRouterTypes, M as ModuleOptions, e as ModuleDefinition, f as SilgiModule, B as BaseSchemaType, g as SilgiServiceInterface, h as DefaultNamespaces, i as Silgi, j as SilgiOperation, k as MergedSilgiSchema, l as ServiceType, m as SilgiSchema, R as RequiredServiceType, n as SilgiModuleShared } from './shared/silgi.Bv3UrLx7.js';
|
|
2
|
+
export { F as Awaitable, G as CreateScope, D as DeepPartial, C as DefaultHooks, A as DefaultMethods, E as ExtendShared, u as ExtractInputFromURI, v as ExtractOutputFromURI, w as ExtractRouterParamsFromURI, s as SilgiDefaultShared, o as SilgiEvent, z as SilgiHook, p as SilgiModuleMethods, a as SilgiModuleOptions, q as SilgiModules, r as SilgiNamespaces, S as SilgiOptions, x as SilgiStorageBase, t as SilgiURIs, U as URIsTypes, y as silgi } from './shared/silgi.Bv3UrLx7.js';
|
|
3
|
+
import { FetchOptions } from 'ofetch';
|
|
3
4
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
5
|
import * as unctx_index from 'unctx/index';
|
|
5
6
|
import 'consola';
|
|
@@ -54,6 +55,20 @@ declare class SilgiError extends Error {
|
|
|
54
55
|
static isSilgiError(error: unknown): error is SilgiError;
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
type RequestBodyOption<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route]> = SilgiRouterTypes[Route][Method] extends {
|
|
59
|
+
input: any;
|
|
60
|
+
} ? {
|
|
61
|
+
body: SilgiRouterTypes[Route][Method]['input'];
|
|
62
|
+
} : {
|
|
63
|
+
body?: never;
|
|
64
|
+
};
|
|
65
|
+
type DefaultMethod<Route extends keyof SilgiRouterTypes> = 'get' extends keyof SilgiRouterTypes[Route] ? 'get' : keyof SilgiRouterTypes[Route];
|
|
66
|
+
type OpenFetchOptions<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = DefaultMethod<Route>> = Partial<{
|
|
67
|
+
method: Method;
|
|
68
|
+
}> & RequestBodyOption<Route, Method> & Omit<FetchOptions, 'query' | 'body' | 'method'>;
|
|
69
|
+
type SilgiFetchClient = <Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = DefaultMethod<Route>>(url: Route, options?: OpenFetchOptions<Route, Method>) => Promise<SilgiRouterTypes[Route][Method]['output']>;
|
|
70
|
+
declare function createSilgiFetch(options: FetchOptions | ((options: FetchOptions) => FetchOptions), localFetch?: typeof globalThis.$fetch): SilgiFetchClient;
|
|
71
|
+
|
|
57
72
|
/**
|
|
58
73
|
* Define a Nuxt module, automatically merging defaults with user provided options, installing
|
|
59
74
|
* any hooks that are provided, and calling an optional setup function for full control.
|
|
@@ -151,4 +166,4 @@ declare function createSchema<T extends Partial<Record<keyof DefaultNamespaces,
|
|
|
151
166
|
};
|
|
152
167
|
};
|
|
153
168
|
|
|
154
|
-
export { DefaultNamespaces, type ExtendContext, MergedSilgiSchema, type Namespaces, ServiceType, Silgi, SilgiError, SilgiHelper, type SilgiModuleContext, SilgiModuleShared, SilgiSchema, createResolver, createSchema, createService, createShared, createSilgi, defineSilgiModule, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, relativeWithDot, silgiCtx, tryUseSilgi, useHook, useShared, useSilgi };
|
|
169
|
+
export { DefaultNamespaces, type ExtendContext, MergedSilgiSchema, type Namespaces, ServiceType, Silgi, SilgiError, SilgiHelper, type SilgiModuleContext, SilgiModuleShared, SilgiRouterTypes, SilgiSchema, createResolver, createSchema, createService, createShared, createSilgi, createSilgiFetch, defineSilgiModule, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, relativeWithDot, silgiCtx, tryUseSilgi, useHook, useShared, useSilgi };
|
package/dist/index.mjs
CHANGED
|
@@ -375,6 +375,29 @@ async function createSilgi(config) {
|
|
|
375
375
|
return silgi.options.helper;
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
+
function createSilgiFetch(options, localFetch) {
|
|
379
|
+
return (url, opts = {}) => {
|
|
380
|
+
opts = typeof options === "function" ? options(opts) : { ...options, ...opts };
|
|
381
|
+
if (!opts.method)
|
|
382
|
+
opts.method = "get";
|
|
383
|
+
const $fetch = getFetch(url, opts, localFetch);
|
|
384
|
+
return $fetch(fillPath(url, opts?.path), opts);
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
function getFetch(url, opts, localFetch) {
|
|
388
|
+
if (import.meta.server && localFetch) {
|
|
389
|
+
const isLocalFetch = url[0] === "/" && (!opts.baseURL || opts.baseURL[0] === "/");
|
|
390
|
+
if (isLocalFetch)
|
|
391
|
+
return localFetch;
|
|
392
|
+
}
|
|
393
|
+
return globalThis.$fetch;
|
|
394
|
+
}
|
|
395
|
+
function fillPath(path, params = {}) {
|
|
396
|
+
for (const [k, v] of Object.entries(params))
|
|
397
|
+
path = path.replace(`{${k}}`, encodeURIComponent(String(v)));
|
|
398
|
+
return path;
|
|
399
|
+
}
|
|
400
|
+
|
|
378
401
|
function defineSilgiModule(definition) {
|
|
379
402
|
if (definition) {
|
|
380
403
|
return _defineSilgiModule(definition);
|
|
@@ -469,4 +492,4 @@ function createSchema(silgiType) {
|
|
|
469
492
|
return silgiType;
|
|
470
493
|
}
|
|
471
494
|
|
|
472
|
-
export { SilgiError, SilgiHelper, createSchema, createService, createShared, createSilgi, defineSilgiModule, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, silgi, silgiCtx, tryUseSilgi, useSilgi };
|
|
495
|
+
export { SilgiError, SilgiHelper, createSchema, createService, createShared, createSilgi, createSilgiFetch, defineSilgiModule, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, silgi, silgiCtx, tryUseSilgi, useSilgi };
|
|
@@ -805,4 +805,4 @@ interface SilgiConfig extends Pick<Silgi, 'services' | 'shared' | 'uris' | 'sche
|
|
|
805
805
|
}
|
|
806
806
|
type SilgiFunction = typeof silgi;
|
|
807
807
|
|
|
808
|
-
export { type DefaultMethods as A, type BaseSchemaType as B, type DefaultHooks as C, type DeepPartial as D, type ExtendShared as E, type Awaitable as F, type CreateScope as G, type ModuleOptions as M, type RequiredServiceType as R, type SilgiOptions as S, type URIsTypes as U, type SilgiModuleOptions as a, type SilgiConfig as b, SilgiHelper as c, type
|
|
808
|
+
export { type DefaultMethods as A, type BaseSchemaType as B, type DefaultHooks as C, type DeepPartial as D, type ExtendShared as E, type Awaitable as F, type CreateScope as G, type ModuleOptions as M, type RequiredServiceType as R, type SilgiOptions as S, type URIsTypes as U, type SilgiModuleOptions as a, type SilgiConfig as b, SilgiHelper as c, type SilgiRouterTypes as d, type ModuleDefinition as e, type SilgiModule as f, type SilgiServiceInterface as g, type DefaultNamespaces as h, type Silgi as i, type SilgiOperation as j, type MergedSilgiSchema as k, type ServiceType as l, type SilgiSchema as m, type SilgiModuleShared as n, type SilgiEvent as o, type SilgiModuleMethods as p, type SilgiModules as q, type SilgiNamespaces as r, type SilgiDefaultShared as s, type SilgiURIs as t, type ExtractInputFromURI as u, type ExtractOutputFromURI as v, type ExtractRouterParamsFromURI as w, type SilgiStorageBase as x, silgi as y, type SilgiHook as z };
|
|
@@ -805,4 +805,4 @@ interface SilgiConfig extends Pick<Silgi, 'services' | 'shared' | 'uris' | 'sche
|
|
|
805
805
|
}
|
|
806
806
|
type SilgiFunction = typeof silgi;
|
|
807
807
|
|
|
808
|
-
export { type DefaultMethods as A, type BaseSchemaType as B, type DefaultHooks as C, type DeepPartial as D, type ExtendShared as E, type Awaitable as F, type CreateScope as G, type ModuleOptions as M, type RequiredServiceType as R, type SilgiOptions as S, type URIsTypes as U, type SilgiModuleOptions as a, type SilgiConfig as b, SilgiHelper as c, type
|
|
808
|
+
export { type DefaultMethods as A, type BaseSchemaType as B, type DefaultHooks as C, type DeepPartial as D, type ExtendShared as E, type Awaitable as F, type CreateScope as G, type ModuleOptions as M, type RequiredServiceType as R, type SilgiOptions as S, type URIsTypes as U, type SilgiModuleOptions as a, type SilgiConfig as b, SilgiHelper as c, type SilgiRouterTypes as d, type ModuleDefinition as e, type SilgiModule as f, type SilgiServiceInterface as g, type DefaultNamespaces as h, type Silgi as i, type SilgiOperation as j, type MergedSilgiSchema as k, type ServiceType as l, type SilgiSchema as m, type SilgiModuleShared as n, type SilgiEvent as o, type SilgiModuleMethods as p, type SilgiModules as q, type SilgiNamespaces as r, type SilgiDefaultShared as s, type SilgiURIs as t, type ExtractInputFromURI as u, type ExtractOutputFromURI as v, type ExtractRouterParamsFromURI as w, type SilgiStorageBase as x, silgi as y, type SilgiHook as z };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silgi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"klona": "^2.0.6",
|
|
83
83
|
"mlly": "^1.7.4",
|
|
84
84
|
"nitropack": "^2.10.4",
|
|
85
|
+
"ofetch": "^1.4.1",
|
|
85
86
|
"pathe": "^2.0.2",
|
|
86
87
|
"pkg-types": "^1.3.1",
|
|
87
88
|
"scule": "^1.3.0",
|