silgi 0.4.10 → 0.4.12

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.
@@ -1,6 +1,6 @@
1
1
  const name = "silgi";
2
2
  const type = "module";
3
- const version = "0.4.10";
3
+ const version = "0.4.12";
4
4
  const packageManager = "pnpm@9.15.1";
5
5
  const sideEffects = false;
6
6
  const exports = {
@@ -250,11 +250,12 @@ async function generateRouterDTS(silgi) {
250
250
  silgi.hook("close", async () => {
251
251
  const { object } = await data();
252
252
  const uris = object.uris;
253
+ const subPath = "srn";
253
254
  const groupedPaths = /* @__PURE__ */ new Map();
254
255
  Object.entries(uris || {}).forEach(([key, params]) => {
255
256
  const [service, resource, method, action] = key.split("/");
256
- const basePath = params ? `${service}/${resource}/${action}/${params}` : `${service}/${resource}/${action}`;
257
- const fullPath = `${service}/${resource}/${action}`;
257
+ const basePath = params ? `${subPath}/${service}/${resource}/${action}/${params}` : `${subPath}/${service}/${resource}/${action}`;
258
+ const fullPath = `${subPath}/${service}/${resource}/${action}`;
258
259
  if (!groupedPaths.has(basePath)) {
259
260
  groupedPaths.set(basePath, /* @__PURE__ */ new Map());
260
261
  }
@@ -272,7 +273,7 @@ async function generateRouterDTS(silgi) {
272
273
  ].join("\n");
273
274
  const groupedRoutes = Object.entries(uris || {}).reduce((acc, [key, _params]) => {
274
275
  const [service, resource, method, action] = key.split("/");
275
- const routePath = `${service}/${resource}/${action}`;
276
+ const routePath = `${subPath}/${service}/${resource}/${action}`;
276
277
  if (!acc[routePath]) {
277
278
  acc[routePath] = {};
278
279
  }
@@ -14,7 +14,7 @@ declare function silgiGenerateType(silgi: SilgiCLI): Promise<{
14
14
 
15
15
  declare function createSilgi(config: SilgiConfig): Promise<Silgi>;
16
16
 
17
- type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer _}` ? `/${S1}/${S2}/${S3}` : T;
17
+ type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer S4}/${infer _}` ? `/${S1}/${S2}/${S3}/${S4}` : T;
18
18
  type AllPaths = SilgiRouterTypes extends {
19
19
  keys: infer U;
20
20
  } ? keyof U extends never ? string : keyof U : string;
@@ -37,7 +37,7 @@ type RouterParams<R extends ValidRoute> = ExtractPathParams<R>;
37
37
  type SilgiFetchOptions<R extends ValidRoute, M extends Method<R>> = {
38
38
  method: M;
39
39
  } & RequestBodyOption<R, M> & (RouterParams<R> extends object ? {
40
- params: RouterParams<R>;
40
+ params?: RouterParams<R>;
41
41
  } : {
42
42
  params?: never;
43
43
  }) & Omit<FetchOptions, 'query' | 'body' | 'method'>;
@@ -14,7 +14,7 @@ declare function silgiGenerateType(silgi: SilgiCLI): Promise<{
14
14
 
15
15
  declare function createSilgi(config: SilgiConfig): Promise<Silgi>;
16
16
 
17
- type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer _}` ? `/${S1}/${S2}/${S3}` : T;
17
+ type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer S4}/${infer _}` ? `/${S1}/${S2}/${S3}/${S4}` : T;
18
18
  type AllPaths = SilgiRouterTypes extends {
19
19
  keys: infer U;
20
20
  } ? keyof U extends never ? string : keyof U : string;
@@ -37,7 +37,7 @@ type RouterParams<R extends ValidRoute> = ExtractPathParams<R>;
37
37
  type SilgiFetchOptions<R extends ValidRoute, M extends Method<R>> = {
38
38
  method: M;
39
39
  } & RequestBodyOption<R, M> & (RouterParams<R> extends object ? {
40
- params: RouterParams<R>;
40
+ params?: RouterParams<R>;
41
41
  } : {
42
42
  params?: never;
43
43
  }) & Omit<FetchOptions, 'query' | 'body' | 'method'>;
@@ -1143,8 +1143,13 @@ function getFetch(url, opts, localFetch) {
1143
1143
  return globalThis.$fetch;
1144
1144
  }
1145
1145
  function fillPath(path, params) {
1146
- if (!params)
1146
+ if (!params) {
1147
+ if (path.includes(":"))
1148
+ throw new Error("Parametreler dogru kullanmal\u0131s\u0131n\u0131z");
1147
1149
  return path;
1150
+ }
1151
+ if (!path.includes(":"))
1152
+ throw new Error("Path parametler : ile belirtilmelidir");
1148
1153
  let result = path;
1149
1154
  for (const [key, value] of Object.entries(params)) {
1150
1155
  result = result.replace(`:${key}`, value);
@@ -20,7 +20,7 @@ const module = defineNuxtModule({
20
20
  nuxt.options.nitro.modules ||= [];
21
21
  nuxt.options.nitro.modules.push(await resolvePath("silgi/ecosystem/nitro"));
22
22
  nuxt.hook("prepare:types", ({ references }) => {
23
- references.push({ path: relativeWithDot(nuxt.options.buildDir, join(silgi.build.dir, "silgi.d.ts")) });
23
+ references.push({ path: relativeWithDot(nuxt.options.buildDir, join(silgi.build.typesDir, "silgi.d.ts")) });
24
24
  });
25
25
  nuxt.options.imports.presets.push({
26
26
  from: "silgi/types",
@@ -1,3 +1,3 @@
1
- const version = "0.4.10";
1
+ const version = "0.4.12";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "0.4.10";
1
+ const version = "0.4.12";
2
2
 
3
3
  export { version };
@@ -1,7 +1,7 @@
1
1
  import type { FetchError } from 'ofetch';
2
2
  import type { SilgiRouterTypes } from 'silgi/types';
3
- import { type AsyncData } from 'nuxt/app';
4
- type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer _}` ? `/${S1}/${S2}/${S3}` : T;
3
+ import { type AsyncData, type UseFetchOptions } from 'nuxt/app';
4
+ type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer S4}/${infer _}` ? `/${S1}/${S2}/${S3}/${S4}` : T;
5
5
  type AllPaths = SilgiRouterTypes extends {
6
6
  keys: infer U;
7
7
  } ? keyof U extends never ? string : keyof U : string;
@@ -10,9 +10,9 @@ type ExtractPathParams<T extends string> = T extends `${infer _Start}:${infer Pa
10
10
  } & ExtractPathParams<Rest> : T extends `${infer _Start}:${infer Param}` ? {
11
11
  [K in Param]: string;
12
12
  } : unknown;
13
- export declare function useSilgiFetch<P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]>(path: P, options?: {
13
+ export declare function useSilgiFetch<T, P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]>(path: P, options?: {
14
14
  method?: M;
15
15
  params?: ExtractPathParams<P>;
16
16
  body?: SilgiRouterTypes[BasePath][M]['input'];
17
- }): AsyncData<SilgiRouterTypes[BasePath][M]["output"], FetchError | null>;
17
+ } & Omit<UseFetchOptions<T>, 'method' | 'body' | 'params'>): AsyncData<SilgiRouterTypes[BasePath][M]["output"], FetchError | null>;
18
18
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.4.10",
4
+ "version": "0.4.12",
5
5
  "sideEffects": false,
6
6
  "exports": {
7
7
  "./cli": {