@warkypublic/svelix 0.1.6 → 0.1.7

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,7 +1,7 @@
1
- import type { FormerAPICallType } from './types';
1
+ import type { FormerAPICallType } from "./types";
2
2
  interface ResolveSpecRequest {
3
3
  data?: Record<string, any>;
4
- operation: 'create' | 'delete' | 'read' | 'update';
4
+ operation: "create" | "delete" | "read" | "update";
5
5
  options?: {
6
6
  columns?: string[];
7
7
  computedColumns?: any[];
@@ -1,33 +1,33 @@
1
1
  function FormerResolveSpecAPI(options) {
2
2
  return async (mode, request, value, key) => {
3
- const baseUrl = options.url.replace(/\/$/, '');
3
+ const baseUrl = options.url.replace(/\/$/, "");
4
4
  let url = `${baseUrl}`;
5
- if (request !== 'insert' && key) {
5
+ if (request !== "insert" && key) {
6
6
  url = `${url}/${key}`;
7
7
  }
8
8
  const resolveSpecRequest = {
9
- operation: mode === 'read'
10
- ? 'read'
11
- : request === 'delete'
12
- ? 'delete'
13
- : request === 'update'
14
- ? 'update'
15
- : 'create',
9
+ operation: mode === "read"
10
+ ? "read"
11
+ : request === "delete"
12
+ ? "delete"
13
+ : request === "update"
14
+ ? "update"
15
+ : "create",
16
16
  };
17
- if (mode === 'mutate') {
17
+ if (mode === "mutate") {
18
18
  resolveSpecRequest.data = value;
19
19
  }
20
20
  const fetchOptions = {
21
- cache: 'no-cache',
21
+ cache: "no-cache",
22
22
  signal: options.signal,
23
23
  ...options.fetchOptions,
24
24
  body: JSON.stringify(resolveSpecRequest),
25
25
  headers: {
26
26
  Authorization: `Bearer ${options.authToken}`,
27
- 'Content-Type': 'application/json',
27
+ "Content-Type": "application/json",
28
28
  ...options.fetchOptions?.headers,
29
29
  },
30
- method: 'POST',
30
+ method: "POST",
31
31
  };
32
32
  const response = await fetch(url, fetchOptions);
33
33
  if (!response.ok) {
@@ -38,7 +38,7 @@ function FormerResolveSpecAPI(options) {
38
38
  throw new Error(`API request failed with status ${response.status}`);
39
39
  }
40
40
  const data = await response.json();
41
- return data;
41
+ return (data?.data ?? data);
42
42
  };
43
43
  }
44
44
  export { FormerResolveSpecAPI };
@@ -1,4 +1,4 @@
1
- import type { FormerAPICallType } from './types';
1
+ import type { FormerAPICallType } from "./types";
2
2
  declare function FormerRestHeadSpecAPI(options: {
3
3
  authToken: string;
4
4
  fetchOptions?: Partial<RequestInit>;
@@ -1,26 +1,28 @@
1
1
  function FormerRestHeadSpecAPI(options) {
2
2
  return async (mode, request, value, key) => {
3
- const baseUrl = options.url ?? '';
3
+ const baseUrl = options.url ?? "";
4
4
  let url = baseUrl;
5
5
  const fetchOptions = {
6
- cache: 'no-cache',
6
+ cache: "no-cache",
7
7
  signal: options.signal,
8
8
  ...options.fetchOptions,
9
- body: mode === 'mutate' && request !== 'delete' ? JSON.stringify(value) : undefined,
9
+ body: mode === "mutate" && request !== "delete"
10
+ ? JSON.stringify(value)
11
+ : undefined,
10
12
  headers: {
11
13
  Authorization: `Bearer ${options.authToken}`,
12
- 'Content-Type': 'application/json',
14
+ "Content-Type": "application/json",
13
15
  ...options.fetchOptions?.headers,
14
16
  },
15
- method: mode === 'read'
16
- ? 'GET'
17
- : request === 'delete'
18
- ? 'DELETE'
19
- : request === 'update'
20
- ? 'PUT'
21
- : 'POST',
17
+ method: mode === "read"
18
+ ? "GET"
19
+ : request === "delete"
20
+ ? "DELETE"
21
+ : request === "update"
22
+ ? "PUT"
23
+ : "POST",
22
24
  };
23
- if (request !== 'insert') {
25
+ if (request !== "insert") {
24
26
  url = `${baseUrl}/${key}`;
25
27
  }
26
28
  const response = await fetch(url, fetchOptions);
@@ -32,7 +34,7 @@ function FormerRestHeadSpecAPI(options) {
32
34
  throw new Error(`API request failed with status ${response.status}`);
33
35
  }
34
36
  const data = await response.json();
35
- return data;
37
+ return (data?.data ?? data);
36
38
  };
37
39
  }
38
40
  export { FormerRestHeadSpecAPI };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warkypublic/svelix",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Svelte 5 component library with Skeleton UI and Tailwind CSS",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {