@ethlete/query 0.1.0-next.9 → 1.0.0

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.
Files changed (40) hide show
  1. package/esm2020/lib/auth/auth-provider.types.mjs +1 -1
  2. package/esm2020/lib/auth/auth-provider.utils.mjs +1 -1
  3. package/esm2020/lib/auth/basic-auth-provider.mjs +4 -5
  4. package/esm2020/lib/auth/bearer-auth-provider.mjs +117 -60
  5. package/esm2020/lib/auth/custom-header-auth-provider.mjs +4 -5
  6. package/esm2020/lib/directives/infinity-query-trigger.directive.mjs +3 -3
  7. package/esm2020/lib/directives/infinity-query.directive.mjs +7 -9
  8. package/esm2020/lib/directives/query.directive.mjs +23 -19
  9. package/esm2020/lib/infinite-query/infinity-query.mjs +15 -11
  10. package/esm2020/lib/query/query.mjs +111 -86
  11. package/esm2020/lib/query/query.types.mjs +1 -1
  12. package/esm2020/lib/query/query.utils.mjs +51 -4
  13. package/esm2020/lib/query-client/query-client.mjs +25 -13
  14. package/esm2020/lib/query-client/query-client.types.mjs +1 -1
  15. package/esm2020/lib/query-form/query-form.mjs +7 -6
  16. package/esm2020/lib/request/request.mjs +168 -19
  17. package/esm2020/lib/request/request.types.mjs +1 -1
  18. package/esm2020/lib/request/request.util.mjs +66 -91
  19. package/fesm2015/ethlete-query.mjs +673 -398
  20. package/fesm2015/ethlete-query.mjs.map +1 -1
  21. package/fesm2020/ethlete-query.mjs +657 -389
  22. package/fesm2020/ethlete-query.mjs.map +1 -1
  23. package/lib/auth/auth-provider.types.d.ts +30 -22
  24. package/lib/auth/auth-provider.utils.d.ts +2 -1
  25. package/lib/auth/basic-auth-provider.d.ts +0 -2
  26. package/lib/auth/bearer-auth-provider.d.ts +14 -14
  27. package/lib/auth/custom-header-auth-provider.d.ts +0 -2
  28. package/lib/directives/infinity-query.directive.d.ts +1 -2
  29. package/lib/directives/query.directive.d.ts +6 -5
  30. package/lib/infinite-query/infinity-query.types.d.ts +4 -4
  31. package/lib/query/query.d.ts +6 -6
  32. package/lib/query/query.types.d.ts +78 -43
  33. package/lib/query/query.utils.d.ts +21 -5
  34. package/lib/query-client/query-client.d.ts +13 -11
  35. package/lib/query-client/query-client.types.d.ts +22 -10
  36. package/lib/query-form/query-form.types.d.ts +2 -2
  37. package/lib/request/request.d.ts +3 -9
  38. package/lib/request/request.types.d.ts +63 -15
  39. package/lib/request/request.util.d.ts +74 -7
  40. package/package.json +2 -5
@@ -1,18 +1,66 @@
1
- export declare type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT' | 'PURGE' | 'LINK' | 'UNLINK' | 'GQL_QUERY' | 'GQL_MUTATE' | 'CUSTOM';
1
+ import { HttpStatusCode } from './request.util';
2
+ export type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT' | 'PURGE' | 'LINK' | 'UNLINK' | 'GQL_QUERY' | 'GQL_MUTATE' | 'CUSTOM';
2
3
  export interface RequestError<Detail = unknown> {
3
- code: number;
4
- message: string;
4
+ url: string;
5
+ status: HttpStatusCode;
6
+ statusText: string;
5
7
  detail: Detail;
6
- raw: unknown;
7
- route: string;
8
- requestInit?: RequestInit;
9
8
  }
10
- export declare type ParamPrimitive = string | number | boolean | null | undefined;
11
- export declare type Params = Record<string | number | symbol, ParamPrimitive | ParamArray>;
12
- export declare type ParamArray = Array<ParamPrimitive>;
13
- export declare type UnfilteredParamPrimitive = string | number | boolean | null | undefined;
14
- export declare type QueryParams = Record<string | number | symbol, UnfilteredParamPrimitive | UnfilteredParamArray>;
15
- export declare type PathParams = Record<string, string | number>;
16
- export declare type UnfilteredParamArray = Array<UnfilteredParamPrimitive>;
17
- export declare type CacheAdapterFn = (headers: Headers) => number | null;
18
- export declare type RequestHeaders = Record<string, string>;
9
+ export type ParamPrimitive = string | number | boolean | null | undefined;
10
+ export type Params = Record<string | number | symbol, ParamPrimitive | ParamArray>;
11
+ export type ParamArray = Array<ParamPrimitive>;
12
+ export type UnfilteredParamPrimitive = string | number | boolean | null | undefined;
13
+ export type QueryParams = Record<string | number | symbol, UnfilteredParamPrimitive | UnfilteredParamArray>;
14
+ export type PathParams = Record<string, string | number>;
15
+ export type UnfilteredParamArray = Array<UnfilteredParamPrimitive>;
16
+ export type CacheAdapterFn = (headers: RequestHeaders) => number | null;
17
+ export type RequestHeaders = Record<string, string>;
18
+ export type RequestHeadersMethodMap = {
19
+ [M in Method]?: RequestHeaders;
20
+ };
21
+ export interface PartialXhrState {
22
+ headers: RequestHeaders;
23
+ status: number;
24
+ statusText: string;
25
+ url: string;
26
+ }
27
+ export interface RequestConfig {
28
+ method: Method;
29
+ urlWithParams: string;
30
+ body?: unknown;
31
+ reportProgress?: boolean;
32
+ withCredentials?: boolean;
33
+ responseType?: 'arraybuffer' | 'blob' | 'json' | 'text';
34
+ headers?: RequestHeaders;
35
+ cacheAdapter?: CacheAdapterFn;
36
+ }
37
+ export type RequestProgress = {
38
+ current: number;
39
+ percentage?: number;
40
+ total?: number;
41
+ };
42
+ export type RequestEvent<Response = unknown> = {
43
+ type: 'start';
44
+ headers: RequestHeaders;
45
+ } | {
46
+ type: 'download-progress';
47
+ headers: RequestHeaders;
48
+ progress: RequestProgress;
49
+ partialText?: string;
50
+ } | {
51
+ type: 'upload-progress';
52
+ headers: RequestHeaders;
53
+ progress: RequestProgress;
54
+ } | {
55
+ type: 'success';
56
+ headers: RequestHeaders;
57
+ response: Response;
58
+ expiresInTimestamp?: number;
59
+ } | {
60
+ type: 'failure';
61
+ headers: RequestHeaders;
62
+ error: RequestError;
63
+ } | {
64
+ type: 'cancel';
65
+ headers: RequestHeaders;
66
+ };
@@ -1,6 +1,5 @@
1
- import { Method, ParamArray, Params, QueryParams, RequestError, UnfilteredParamPrimitive } from './request.types';
2
- export declare const isRequestError: (error: unknown) => error is RequestError<unknown>;
3
- export declare const isAbortRequestError: (error: unknown) => error is RequestError<unknown>;
1
+ import { Method, ParamArray, Params, QueryParams, RequestError, RequestHeaders, UnfilteredParamPrimitive } from './request.types';
2
+ export declare const isRequestError: <T = unknown>(error: unknown) => error is RequestError<T>;
4
3
  export declare const buildRoute: (options: {
5
4
  base: string;
6
5
  route: string | ((args: Record<string, unknown>) => string) | null | undefined;
@@ -12,9 +11,77 @@ export declare const buildQueryArrayString: (key: string, array: ParamArray) =>
12
11
  export declare const isFetchResponse: (response: unknown) => response is Response;
13
12
  export declare const filterInvalidParams: (params: QueryParams) => Params;
14
13
  export declare const isParamValid: (primitive: UnfilteredParamPrimitive) => boolean;
15
- export declare const extractExpiresInSeconds: (headers: Headers) => number | null;
14
+ export declare const extractExpiresInSeconds: (headers: RequestHeaders) => number | null;
16
15
  export declare const buildTimestampFromSeconds: (seconds: number | null) => number | null;
17
- export declare const buildRequestError: <ErrorResponse = unknown>(error: unknown, route: string, requestInit?: RequestInit) => Promise<RequestError<null> | RequestError<ErrorResponse>>;
18
- export declare const buildBody: (body: unknown) => string | FormData | null;
16
+ export declare const serializeBody: (body: unknown) => ArrayBuffer | Blob | FormData | string | null;
19
17
  export declare const transformMethod: (method: Method) => "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "TRACE" | "CONNECT" | "PURGE" | "LINK" | "UNLINK" | "CUSTOM";
20
- export declare const guessContentType: (body: unknown) => "text/plain" | "multipart/form-data" | "application/json" | null;
18
+ export declare const detectContentTypeHeader: (body: unknown) => string | null;
19
+ export declare const hasHeader: (headers: RequestHeaders, header: string) => boolean;
20
+ export declare const forEachHeader: (headers: RequestHeaders, callback: (value: string, key: string) => void) => void;
21
+ export declare const parseAllXhrResponseHeaders: (xhr: XMLHttpRequest) => RequestHeaders;
22
+ export declare const getResponseUrl: (xhr: XMLHttpRequest) => string | null;
23
+ export declare const enum HttpStatusCode {
24
+ Continue = 100,
25
+ SwitchingProtocols = 101,
26
+ Processing = 102,
27
+ EarlyHints = 103,
28
+ Ok = 200,
29
+ Created = 201,
30
+ Accepted = 202,
31
+ NonAuthoritativeInformation = 203,
32
+ NoContent = 204,
33
+ ResetContent = 205,
34
+ PartialContent = 206,
35
+ MultiStatus = 207,
36
+ AlreadyReported = 208,
37
+ ImUsed = 226,
38
+ MultipleChoices = 300,
39
+ MovedPermanently = 301,
40
+ Found = 302,
41
+ SeeOther = 303,
42
+ NotModified = 304,
43
+ UseProxy = 305,
44
+ Unused = 306,
45
+ TemporaryRedirect = 307,
46
+ PermanentRedirect = 308,
47
+ BadRequest = 400,
48
+ Unauthorized = 401,
49
+ PaymentRequired = 402,
50
+ Forbidden = 403,
51
+ NotFound = 404,
52
+ MethodNotAllowed = 405,
53
+ NotAcceptable = 406,
54
+ ProxyAuthenticationRequired = 407,
55
+ RequestTimeout = 408,
56
+ Conflict = 409,
57
+ Gone = 410,
58
+ LengthRequired = 411,
59
+ PreconditionFailed = 412,
60
+ PayloadTooLarge = 413,
61
+ UriTooLong = 414,
62
+ UnsupportedMediaType = 415,
63
+ RangeNotSatisfiable = 416,
64
+ ExpectationFailed = 417,
65
+ ImATeapot = 418,
66
+ MisdirectedRequest = 421,
67
+ UnprocessableEntity = 422,
68
+ Locked = 423,
69
+ FailedDependency = 424,
70
+ TooEarly = 425,
71
+ UpgradeRequired = 426,
72
+ PreconditionRequired = 428,
73
+ TooManyRequests = 429,
74
+ RequestHeaderFieldsTooLarge = 431,
75
+ UnavailableForLegalReasons = 451,
76
+ InternalServerError = 500,
77
+ NotImplemented = 501,
78
+ BadGateway = 502,
79
+ ServiceUnavailable = 503,
80
+ GatewayTimeout = 504,
81
+ HttpVersionNotSupported = 505,
82
+ VariantAlsoNegotiates = 506,
83
+ InsufficientStorage = 507,
84
+ LoopDetected = 508,
85
+ NotExtended = 510,
86
+ NetworkAuthenticationRequired = 511
87
+ }
package/package.json CHANGED
@@ -1,16 +1,13 @@
1
1
  {
2
2
  "name": "@ethlete/query",
3
- "version": "0.1.0-next.9",
3
+ "version": "1.0.0",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0"
6
6
  },
7
7
  "peerDependencies": {
8
8
  "@angular/common": "^14.2.0 || ^15.0.0",
9
9
  "@angular/core": "^14.2.0 || ^15.0.0",
10
- "rxjs": "7.5.7",
11
- "@ethlete/core": "0.2.0-next.8",
12
- "@angular/forms": "15.0.1",
13
- "@angular/router": "15.0.1"
10
+ "@ethlete/core": "1.0.0"
14
11
  },
15
12
  "module": "fesm2015/ethlete-query.mjs",
16
13
  "es2020": "fesm2020/ethlete-query.mjs",