itube-specs 0.0.331 → 0.0.336

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,41 +1,40 @@
1
- import { EAsyncData } from '../runtime';
2
-
3
1
  export function useApiAction<T extends any[], R>(
4
- apiMethod: (...args: T) => Promise<R>,
5
- isGet: boolean = false,
6
- key?: string,
2
+ apiMethod: (...args: T) => Promise<R>,
3
+ isGet = false,
7
4
  ) {
8
- const loading = ref(false);
9
- const error = ref<Error | null>(null);
10
- const data = ref<R | null>(null);
5
+ const loading = ref(false)
6
+ const error = ref<Error | null>(null)
7
+ const data = ref<R | null>(null)
11
8
 
12
- const execute = async (...args: T) => {
13
- loading.value = true;
14
- error.value = null;
9
+ const execute = async (
10
+ args: T,
11
+ key?: string
12
+ ) => {
13
+ loading.value = true
14
+ error.value = null
15
15
 
16
- try {
17
- const result = await apiMethod(...args);
16
+ try {
17
+ const result = await apiMethod(...args)
18
18
 
19
- if (isGet) {
20
- data.value = result;
21
- if (key) {
22
- const state = useState<R | null>(`data-${key}`);
23
- state.value = result;
24
- }
25
- return result;
26
- }
19
+ if (isGet) {
20
+ data.value = result
27
21
 
28
- return;
29
- } catch (err: any) {
30
- error.value = createError({
31
- statusCode: 500,
32
- statusMessage: 'Error in API action',
33
- message: err instanceof Error ? err.message : 'Unknown error'
34
- });
35
- } finally {
36
- loading.value = false;
22
+ if (key) {
23
+ useState<R | null>(`data-${key}`).value = result
37
24
  }
38
- };
25
+ }
26
+
27
+ return result
28
+ } catch (err: any) {
29
+ error.value = createError({
30
+ statusCode: 500,
31
+ statusMessage: 'Error in API action',
32
+ message: err instanceof Error ? err.message : 'Unknown error'
33
+ })
34
+ } finally {
35
+ loading.value = false
36
+ }
37
+ }
39
38
 
40
- return { loading, error, data, execute };
39
+ return { loading, error, data, execute }
41
40
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.331",
4
+ "version": "0.0.336",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {
package/types/index.d.ts CHANGED
@@ -60,3 +60,4 @@ export * from './button-themes.d.ts';
60
60
  export * from './report-request.d.ts';
61
61
  export * from './burger-menu-item.d.ts';
62
62
  export * from './popular-tags-model.d.ts';
63
+ export * from './playlist-short.d.ts';
@@ -0,0 +1,6 @@
1
+ import { EPlaylistType } from '~/runtime';
2
+
3
+ export interface IPlaylistShort {
4
+ name: string
5
+ type: EPlaylistType
6
+ }