@xy-planning-network/trees 0.6.0 → 0.7.0-rc-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xy-planning-network/trees",
3
- "version": "0.6.0",
3
+ "version": "0.7.0-rc-1",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "repository": "github:xy-planning-network/trees",
@@ -1,5 +1,4 @@
1
1
  <script setup lang="ts">
2
- import { AxiosResponse } from "axios"
3
2
  import {
4
3
  ComponentPublicInstance,
5
4
  computed,
@@ -97,7 +96,7 @@ const loadAndRender = (): void => {
97
96
  }
98
97
 
99
98
  BaseAPI.get(props.tableData.url, { skipLoader: !props.loader }, params).then(
100
- (success: AxiosResponse) => {
99
+ (success) => {
101
100
  pagination.value = {
102
101
  page: success.data.page,
103
102
  perPage: success.data.perPage,
@@ -1,10 +1,22 @@
1
+ import { Pagination } from "../composables/nav";
1
2
  import { AxiosRequestConfig } from "axios";
2
- export declare type RequestMethod = "GET" | "get" | "PUT" | "put" | "POST" | "post" | "DELETE" | "delete";
3
- export interface RequestOptions {
3
+ export interface Paginated<T> extends Pagination {
4
+ items: T[];
5
+ }
6
+ export interface TreesResponse<T = any> {
7
+ /**
8
+ * response data as T
9
+ */
10
+ data: T;
4
11
  /**
5
- * returns the nested data key inside the AxiosResponse data when true
12
+ * http status code
6
13
  */
7
- dataIntercept?: boolean;
14
+ status: number;
15
+ }
16
+ export interface TreesPromise<T = any> extends Promise<TreesResponse<T>> {
17
+ }
18
+ export declare type RequestMethod = "GET" | "get" | "PUT" | "put" | "POST" | "post" | "DELETE" | "delete";
19
+ export interface RequestOptions {
8
20
  /**
9
21
  * disables the full screen loading interface during the request when true
10
22
  */
@@ -15,10 +27,10 @@ export interface RequestOptions {
15
27
  withDelay?: number;
16
28
  }
17
29
  declare const BaseAPI: {
18
- makeRequest<T = any>(config: AxiosRequestConfig, opts: RequestOptions): Promise<T>;
19
- get<T_1 = any>(path: string, opts: RequestOptions, params?: Record<string, unknown> | undefined): Promise<T_1>;
20
- delete<T_2 = any>(path: string, opts: RequestOptions): Promise<T_2>;
21
- post<T_3 = any>(path: string, data: Record<string, unknown> | FormData, opts: RequestOptions): Promise<T_3>;
22
- put<T_4 = any>(path: string, data: Record<string, unknown> | FormData, opts: RequestOptions): Promise<T_4>;
30
+ makeRequest<T = any>(config: AxiosRequestConfig, opts: RequestOptions): TreesPromise<T>;
31
+ get<T_1 = any>(path: string, opts: RequestOptions, params?: Record<string, unknown> | undefined): TreesPromise<T_1>;
32
+ delete<T_2 = any>(path: string, opts: RequestOptions): TreesPromise<T_2>;
33
+ post<T_3 = any>(path: string, data: Record<string, unknown> | FormData, opts: RequestOptions): TreesPromise<T_3>;
34
+ put<T_4 = any>(path: string, data: Record<string, unknown> | FormData, opts: RequestOptions): TreesPromise<T_4>;
23
35
  };
24
36
  export default BaseAPI;
@@ -0,0 +1 @@
1
+ export declare function getBaseUrl(): string;
@@ -1,5 +1,6 @@
1
1
  import { AxiosError } from "axios";
2
2
  import { Ref, ShallowRef } from "vue";
3
+ import { TreesPromise } from "../api/base";
3
4
  import type { RequestMethod, RequestOptions } from "../api/base";
4
5
  /**
5
6
  * UseBaseAPIOptions extends Trees/RequestOptions
@@ -19,13 +20,17 @@ export interface UseBaseAPIOptions extends RequestOptions {
19
20
  */
20
21
  export interface UseBaseAPI<T> {
21
22
  /**
22
- * Axios response data
23
+ * Promise response data
23
24
  */
24
25
  result: Ref<T | undefined>;
25
26
  /**
26
- * Any errors that may have occurred
27
+ * Promise response http status code
27
28
  */
28
- error: ShallowRef<Error | AxiosError<T> | undefined>;
29
+ status: Ref<number | undefined>;
30
+ /**
31
+ * Any errors or rejections that may have occurred
32
+ */
33
+ error: ShallowRef<AxiosError | Error | undefined>;
29
34
  /**
30
35
  * Indicates if the request has finished
31
36
  */
@@ -51,7 +56,7 @@ export interface UseBaseAPI<T> {
51
56
  * Manually call the axios request
52
57
  * can be used multiple times
53
58
  */
54
- execute: (data?: Record<string, unknown> | FormData, opts?: RequestOptions) => Promise<T>;
59
+ execute: (data?: Record<string, unknown> | FormData, opts?: RequestOptions) => TreesPromise<T>;
55
60
  }
56
61
  /**
57
62
  * useBaseAPI is a composable wrapper of BaseAPI
@@ -63,13 +68,14 @@ export interface UseBaseAPI<T> {
63
68
  */
64
69
  export default function useBaseAPI<T = any>(path: string, method?: RequestMethod, initOpts?: UseBaseAPIOptions): {
65
70
  result: Ref<T | undefined>;
66
- error: ShallowRef<Error | AxiosError<T, any> | undefined>;
71
+ status: Ref<number | undefined>;
72
+ error: ShallowRef<AxiosError<unknown, any> | Error | undefined>;
67
73
  isFinished: Ref<boolean>;
68
74
  isLoading: Ref<boolean>;
69
75
  isAborted: Ref<boolean>;
70
76
  hasFetched: Ref<boolean>;
71
77
  abort: () => void;
72
- execute: (data?: Record<string, unknown> | FormData, opts?: RequestOptions) => Promise<T>;
78
+ execute: (data?: Record<string, unknown> | FormData, opts?: RequestOptions) => TreesPromise<T>;
73
79
  };
74
80
  /**
75
81
  * useBaseAPIGet is a convenience function for useBaseAPI
@@ -0,0 +1,19 @@
1
+ import { VNode } from "vue";
2
+ import { Options, Placement } from "@popperjs/core";
3
+ export declare type PopperPosition = Placement;
4
+ export declare const offsetModifier: (skidding: number, distance: number) => {
5
+ options: {
6
+ offset: () => number[];
7
+ };
8
+ name: "offset";
9
+ enabled: boolean;
10
+ phase: import("@popperjs/core").ModifierPhases;
11
+ requires?: string[] | undefined;
12
+ requiresIfExists?: string[] | undefined;
13
+ fn: (arg0: import("@popperjs/core").ModifierArguments<import("@popperjs/core/lib/modifiers/offset").Options>) => void | import("@popperjs/core").State;
14
+ effect?: ((arg0: import("@popperjs/core").ModifierArguments<import("@popperjs/core/lib/modifiers/offset").Options>) => void | (() => void)) | undefined;
15
+ data?: import("@popperjs/core").Obj | undefined;
16
+ };
17
+ export declare function usePopper(opts: Partial<Options>): import("vue").Ref<VNode<import("vue").RendererNode, import("vue").RendererElement, {
18
+ [key: string]: any;
19
+ }> | HTMLElement | undefined>[];
package/types/entry.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Plugin } from "vue";
2
2
  import BaseAPI from "./api/base";
3
- import type { RequestOptions } from "./api/base";
3
+ import type { Paginated, RequestOptions, TreesPromise, TreesResponse } from "./api/base";
4
+ import type { Pagination } from "./composables/nav";
4
5
  declare const install: Exclude<Plugin["install"], undefined>;
5
6
  export default install;
6
7
  export * from "./composables/index";
7
8
  export * from "./lib-components/index";
8
9
  export { BaseAPI };
9
- export type { RequestOptions };
10
+ export type { Paginated, Pagination, RequestOptions, TreesPromise, TreesResponse, };
@@ -0,0 +1,12 @@
1
+ export interface Pagination {
2
+ page: number;
3
+ perPage: number;
4
+ totalItems: number;
5
+ totalPages: number;
6
+ }
7
+ export interface PaginationItems<T = any> {
8
+ items: T[];
9
+ }
10
+ export interface PaginationData<T = any> {
11
+ data: Pagination & PaginationItems<T>;
12
+ }