@xy-planning-network/trees 0.6.2-rc-7 → 0.6.2-rc-8

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.2-rc-7",
3
+ "version": "0.6.2-rc-8",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "repository": "github:xy-planning-network/trees",
@@ -11,7 +11,7 @@ import Paginator from "../navigation/Paginator.vue"
11
11
  import BaseAPI from "../../api/base"
12
12
  import * as TableTypes from "@/composables/table"
13
13
  import { useAppFlasher } from "@/composables/useFlashes"
14
- import { TrailsResponsePaged } from "@/api/client"
14
+ import { TrailsRespPaged } from "@/api/client"
15
15
 
16
16
  const props = withDefaults(
17
17
  defineProps<{
@@ -96,7 +96,7 @@ const loadAndRender = (): void => {
96
96
  q: query.value,
97
97
  }
98
98
 
99
- BaseAPI.get<TrailsResponsePaged<unknown>>(
99
+ BaseAPI.get<TrailsRespPaged<unknown>>(
100
100
  props.tableData.url,
101
101
  { skipLoader: !props.loader },
102
102
  params
@@ -1,16 +1,8 @@
1
1
  import { AxiosRequestConfig } from "axios";
2
- import { HttpClient, HttpError, HttpPromise, RequestOptions } from "./client";
3
- export declare const httpRequest: <T = any>(config: AxiosRequestConfig, opts: RequestOptions) => HttpPromise<T>;
2
+ import { HttpClient, HttpError, HttpPromise, ReqOptions } from "./client";
3
+ export declare const httpRequest: <T = any>(config: AxiosRequestConfig, opts: ReqOptions) => HttpPromise<T>;
4
4
  declare const BaseAPI: HttpClient;
5
5
  export default BaseAPI;
6
- /**
7
- * A convenience method for checking if a variable in a failed request has an http status code.
8
- * This is most useful for checking for specific http status codes in error callbacks.
9
- * @param err unknown
10
- * @param codes number | number[]
11
- * @returns boolean
12
- */
13
- export declare const hasHttpErrStatus: (err: unknown, codes: number | number[]) => boolean;
14
6
  /**
15
7
  * A type guard for checking if a variable is in the shape of a HttpError
16
8
  * @param err unknown
@@ -1,13 +1,13 @@
1
1
  /**
2
- * RequestMethod
2
+ * ReqMethod
3
3
  * The HTTP request methods that our http client supports.
4
4
  */
5
- export declare type RequestMethod = "GET" | "get" | "PATCH" | "patch" | "PUT" | "put" | "POST" | "post" | "DELETE" | "delete";
5
+ export declare type ReqMethod = "DELETE" | "delete" | "GET" | "get" | "PATCH" | "patch" | "POST" | "post" | "PUT" | "put";
6
6
  /**
7
- * RequestOptions
7
+ * ReqOptions
8
8
  * The set of options available for any http client request.
9
9
  */
10
- export interface RequestOptions {
10
+ export interface ReqOptions {
11
11
  /**
12
12
  * Disable the full screen loading interface during the request when true.
13
13
  */
@@ -17,21 +17,21 @@ export interface RequestOptions {
17
17
  */
18
18
  withDelay?: number;
19
19
  }
20
- export declare const HTTP_ERROR = "HttpError";
21
- export declare const HTTP_CANCELLED_ERROR = "HttpCanceledError";
20
+ export declare const HTTP_ERR = "HttpError";
21
+ export declare const HTTP_ERR_CANCEL = "HttpErrorCanceled";
22
22
  /**
23
23
  * HttpError
24
24
  * An http client error when the request is rejected.
25
25
  */
26
26
  export declare class HttpError<T = unknown> extends Error {
27
- /**
28
- * The http response status code.
29
- */
30
- status: number;
31
27
  /**
32
28
  * The http response body.
33
29
  */
34
30
  response?: T;
31
+ /**
32
+ * The http response status code.
33
+ */
34
+ status: number;
35
35
  constructor(message?: string, status?: number, response?: T, name?: string);
36
36
  }
37
37
  /**
@@ -44,16 +44,16 @@ export interface HttpPromise<T = any> extends Promise<T> {
44
44
  * TrailsPromise
45
45
  * The successfully resolved interface of an http client request returned by @xy-planning-network/Trails.
46
46
  */
47
- export interface TrailsPromise<T = any> extends Promise<TrailsResponse<T>> {
47
+ export interface TrailsPromise<T = any> extends Promise<TrailsResp<T>> {
48
48
  }
49
49
  /**
50
50
  * TrailsPromisePaged
51
51
  * The successfully resolved interface of a paged http client request returned by @xy-planning-network/Trails.
52
52
  */
53
- export interface TrailsPromisePaged<T = any> extends Promise<TrailsResponsePaged<T>> {
53
+ export interface TrailsPromisePaged<T = any> extends Promise<TrailsRespPaged<T>> {
54
54
  }
55
55
  /**
56
- * TrailsResponse
56
+ * TrailsResp
57
57
  * A convenience interface to represent the shape of a Trails delivered API response.
58
58
  *
59
59
  * Example Usage:
@@ -62,18 +62,18 @@ export interface TrailsPromisePaged<T = any> extends Promise<TrailsResponsePaged
62
62
  * email: string
63
63
  * }
64
64
  *
65
- * BaseAPI.get<TrailsResponse<User>>(`/user/${id}`)
66
- * .then(result => {
65
+ * BaseAPI.get<TrailsResp<User>>(`/user/${id}`)
66
+ * .then((result) => {
67
67
  * const id = result.data.id
68
68
  * const email = result.data.email
69
- * const user = { ...result.data }
69
+ * const user = result.data
70
70
  * })
71
71
  */
72
- export interface TrailsResponse<T = any> {
72
+ export interface TrailsResp<T = any> {
73
73
  data: T;
74
74
  }
75
75
  /**
76
- * TrailsResponsePaged
76
+ * TrailsRespPaged
77
77
  * A convenience interface to represent the shape of a paginated Trails delivered API response.
78
78
  *
79
79
  * Example Usage:
@@ -82,17 +82,17 @@ export interface TrailsResponse<T = any> {
82
82
  * email: string
83
83
  * }
84
84
  *
85
- * BaseAPI.get<TrailsResponsePaged<User>>(`/users`)
86
- * .then(result => {
85
+ * BaseAPI.get<TrailsRespPaged<User>>(`/users`)
86
+ * .then((result) => {
87
87
  * const currentPage = result.data.page
88
- * const users = { ...result.data.items }
88
+ * const users = result.data.items
89
89
  *
90
- * result.data.items.forEach(u => {
90
+ * users.forEach((u) => {
91
91
  * console.log(u.id)
92
92
  * })
93
93
  * })
94
94
  */
95
- export interface TrailsResponsePaged<T = any> {
95
+ export interface TrailsRespPaged<T = any> {
96
96
  data: {
97
97
  items: T[];
98
98
  page: number;
@@ -107,49 +107,49 @@ export interface TrailsResponsePaged<T = any> {
107
107
  */
108
108
  export declare type QueryParams = Record<string, any>;
109
109
  /**
110
- * RequestPayload
110
+ * ReqPayload
111
111
  * Http POST and PUT payloads.
112
112
  */
113
- export declare type RequestPayload = Record<string, any> | FormData;
113
+ export declare type ReqPayload = Record<string, any> | FormData;
114
114
  /**
115
115
  * HttpClient
116
116
  * The http client interface the BaseAPI implements.
117
117
  */
118
118
  export interface HttpClient {
119
119
  /**
120
- * The method to make an http GET request.
120
+ * The method to make an http DELETE request.
121
121
  * @param path string
122
- * @param opts RequestOptions
123
- * @param params QueryParams
122
+ * @param opts ReqOptions
124
123
  * @returns HttpPromise<T>
125
124
  */
126
- get<T>(path: string, opts?: RequestOptions, params?: QueryParams): HttpPromise<T>;
125
+ delete<T>(path: string, opts?: ReqOptions): HttpPromise<T>;
127
126
  /**
128
- * The method to make an http DELETE request.
127
+ * The method to make an http GET request.
129
128
  * @param path string
130
- * @param opts RequestOptions
129
+ * @param opts ReqOptions
130
+ * @param params QueryParams
131
131
  * @returns HttpPromise<T>
132
132
  */
133
- delete<T>(path: string, opts?: RequestOptions): HttpPromise<T>;
133
+ get<T>(path: string, opts?: ReqOptions, params?: QueryParams): HttpPromise<T>;
134
134
  /**
135
135
  * The method to make an http PATCH request.
136
136
  * @param path string
137
- * @param data RequestPayload
138
- * @param opts RequestOptions
137
+ * @param data ReqPayload
138
+ * @param opts ReqOptions
139
139
  */
140
- patch<T>(path: string, data?: RequestPayload, opts?: RequestOptions): HttpPromise<T>;
140
+ patch<T>(path: string, data?: ReqPayload, opts?: ReqOptions): HttpPromise<T>;
141
141
  /**
142
142
  * The method to make an http POST request.
143
143
  * @param path string
144
- * @param data RequestPayload
145
- * @param opts RequestOptions
144
+ * @param data ReqPayload
145
+ * @param opts ReqOptions
146
146
  */
147
- post<T>(path: string, data?: RequestPayload, opts?: RequestOptions): HttpPromise<T>;
147
+ post<T>(path: string, data?: ReqPayload, opts?: ReqOptions): HttpPromise<T>;
148
148
  /**
149
149
  * The method to make an http PUT request.
150
150
  * @param path string
151
- * @param data RequestPayload
152
- * @param opts RequestOptions
151
+ * @param data ReqPayload
152
+ * @param opts ReqOptions
153
153
  */
154
- put<T>(path: string, data?: RequestPayload, opts?: RequestOptions): HttpPromise<T>;
154
+ put<T>(path: string, data?: ReqPayload, opts?: ReqOptions): HttpPromise<T>;
155
155
  }
@@ -1,11 +1,11 @@
1
1
  import { Ref, ShallowRef } from "vue";
2
- import type { HttpPromise, HttpError, RequestMethod, RequestOptions, RequestPayload } from "../api/client";
2
+ import type { HttpPromise, HttpError, ReqMethod, ReqOptions, ReqPayload } from "../api/client";
3
3
  /**
4
- * UseBaseAPIOptions extends Trees/RequestOptions
4
+ * UseBaseAPIOptions extends Trees/ReqOptions
5
5
  * these options are used only in the instantiation
6
6
  * of a new UseBaseAPI composable
7
7
  */
8
- export interface UseBaseAPIOptions extends RequestOptions {
8
+ export interface UseBaseAPIOptions extends ReqOptions {
9
9
  /**
10
10
  * Whether to immediately fire the execute function during instantiation
11
11
  */
@@ -50,17 +50,17 @@ export interface UseBaseAPI<T> {
50
50
  * Manually call the axios request
51
51
  * can be used multiple times
52
52
  */
53
- execute: (data?: RequestPayload, opts?: RequestOptions) => HttpPromise<T>;
53
+ execute: (data?: ReqPayload, opts?: ReqOptions) => HttpPromise<T>;
54
54
  }
55
55
  /**
56
56
  * useBaseAPI is a composable wrapper of BaseAPI
57
57
  * @param path {string} the api path or full url for the
58
- * @param method {RequestMethod} the initial request type
58
+ * @param method {ReqMethod} the initial request type
59
59
  * @param initOpts {UseBaseAPIOptions}
60
60
  * @param initConfig {AxiosRequestConfig}
61
61
  * @returns {UseBaseAPI<T>}
62
62
  */
63
- export default function useBaseAPI<T = any>(path: string, method?: RequestMethod, initOpts?: UseBaseAPIOptions): UseBaseAPI<T>;
63
+ export default function useBaseAPI<T = any>(path: string, method?: ReqMethod, initOpts?: UseBaseAPIOptions): UseBaseAPI<T>;
64
64
  /**
65
65
  * useBaseAPIGet is a convenience function for useBaseAPI
66
66
  * @param path {string} the api path or full url for the
package/types/entry.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Plugin } from "vue";
2
- import BaseAPI, { hasHttpErrStatus, isHttpCancel, isHttpError } from "./api/base";
3
- import type { HttpPromise, HttpError, QueryParams, RequestOptions, RequestPayload, TrailsPromise, TrailsPromisePaged, TrailsResponse, TrailsResponsePaged } from "./api/client";
2
+ import BaseAPI, { isHttpCancel, isHttpError } from "./api/base";
3
+ import type { HttpPromise, HttpError, QueryParams, ReqOptions, ReqPayload, TrailsPromise, TrailsPromisePaged, TrailsResp, TrailsRespPaged } from "./api/client";
4
4
  declare const install: Exclude<Plugin["install"], undefined>;
5
5
  export default install;
6
6
  export * from "./composables/index";
7
7
  export * from "./lib-components/index";
8
- export { BaseAPI, hasHttpErrStatus, isHttpCancel, isHttpError };
9
- export type { HttpPromise, HttpError, QueryParams, RequestOptions, RequestPayload, TrailsPromise, TrailsPromisePaged, TrailsResponse, TrailsResponsePaged, };
8
+ export { BaseAPI, isHttpCancel, isHttpError };
9
+ export type { HttpPromise, HttpError, QueryParams, ReqOptions, ReqPayload, TrailsPromise, TrailsPromisePaged, TrailsResp, TrailsRespPaged, };