@cedvict/http-guardian 0.0.1-next.5 → 0.0.1-next.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +21 -1
  3. package/README.md +76 -0
  4. package/dist/aliases.d.ts +35 -0
  5. package/dist/aliases.d.ts.map +1 -0
  6. package/dist/auth/authConfig.d.ts +91 -0
  7. package/dist/auth/authConfig.d.ts.map +1 -0
  8. package/dist/cache/inFlight.d.ts +10 -0
  9. package/dist/cache/inFlight.d.ts.map +1 -0
  10. package/dist/cache/key.d.ts +10 -0
  11. package/dist/cache/key.d.ts.map +1 -0
  12. package/dist/cache/memoryCache.d.ts +16 -0
  13. package/dist/cache/memoryCache.d.ts.map +1 -0
  14. package/dist/cache/types.d.ts +13 -0
  15. package/dist/cache/types.d.ts.map +1 -0
  16. package/dist/client/errors.d.ts +29 -0
  17. package/dist/client/errors.d.ts.map +1 -0
  18. package/dist/client/httpClient.d.ts +13 -0
  19. package/dist/client/httpClient.d.ts.map +1 -0
  20. package/dist/client/types.d.ts +84 -0
  21. package/dist/client/types.d.ts.map +1 -0
  22. package/dist/guards/cookieSafeRefreshGuard.d.ts +40 -0
  23. package/dist/guards/cookieSafeRefreshGuard.d.ts.map +1 -0
  24. package/dist/guards/instrumentGuard.d.ts +12 -0
  25. package/dist/guards/instrumentGuard.d.ts.map +1 -0
  26. package/dist/guards/retryGuard.d.ts +12 -0
  27. package/dist/guards/retryGuard.d.ts.map +1 -0
  28. package/dist/guards/types.d.ts +3 -0
  29. package/dist/guards/types.d.ts.map +1 -0
  30. package/dist/guards/unauthorizedGuard.d.ts +19 -0
  31. package/dist/guards/unauthorizedGuard.d.ts.map +1 -0
  32. package/dist/index.cjs +1413 -0
  33. package/dist/index.cjs.map +1 -0
  34. package/dist/index.d.ts +22 -270
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +736 -40
  37. package/dist/index.js.map +1 -1
  38. package/dist/internal/authGuard.d.ts +4 -0
  39. package/dist/internal/authGuard.d.ts.map +1 -0
  40. package/dist/internal/compose.d.ts +7 -0
  41. package/dist/internal/compose.d.ts.map +1 -0
  42. package/dist/internal/context.d.ts +31 -0
  43. package/dist/internal/context.d.ts.map +1 -0
  44. package/dist/internal/headersPolyfill.d.ts +25 -0
  45. package/dist/internal/headersPolyfill.d.ts.map +1 -0
  46. package/dist/internal/stableStringify.d.ts +2 -0
  47. package/dist/internal/stableStringify.d.ts.map +1 -0
  48. package/dist/internal/url.d.ts +3 -0
  49. package/dist/internal/url.d.ts.map +1 -0
  50. package/dist/notify/defaults.d.ts +9 -0
  51. package/dist/notify/defaults.d.ts.map +1 -0
  52. package/dist/notify/types.d.ts +33 -0
  53. package/dist/notify/types.d.ts.map +1 -0
  54. package/dist/parsing/presets.d.ts +15 -0
  55. package/dist/parsing/presets.d.ts.map +1 -0
  56. package/dist/parsing/schemaAdapter.d.ts +18 -0
  57. package/dist/parsing/schemaAdapter.d.ts.map +1 -0
  58. package/dist/parsing/shapeParser.d.ts +8 -0
  59. package/dist/parsing/shapeParser.d.ts.map +1 -0
  60. package/dist/plugins/types.d.ts +22 -0
  61. package/dist/plugins/types.d.ts.map +1 -0
  62. package/dist/presets/presetBuilder.d.ts +181 -0
  63. package/dist/presets/presetBuilder.d.ts.map +1 -0
  64. package/dist/publicTypes.d.ts +12 -0
  65. package/dist/publicTypes.d.ts.map +1 -0
  66. package/package.json +10 -5
@@ -0,0 +1,33 @@
1
+ import type { AppError } from "../client/errors.js";
2
+ export type NotifyEvent = {
3
+ type: "http-error";
4
+ level: "error" | "warning";
5
+ title: string;
6
+ message: string;
7
+ status: number;
8
+ errors?: AppError[];
9
+ url: string;
10
+ } | {
11
+ type: "network-error";
12
+ level: "error";
13
+ title: string;
14
+ message: string;
15
+ url: string;
16
+ } | {
17
+ type: "parse-error";
18
+ level: "error";
19
+ title: string;
20
+ message: string;
21
+ url: string;
22
+ };
23
+ /**
24
+ * Optional redaction hook.
25
+ *
26
+ * Use this if your notifier logs events and you want to strip secrets from `url`
27
+ * (e.g. query params), or to remove error details before sending to telemetry.
28
+ */
29
+ export type Notifier = {
30
+ notify: (event: NotifyEvent) => void;
31
+ redact?: (event: NotifyEvent) => NotifyEvent;
32
+ };
33
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/notify/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACpI;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACtF;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzF;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACrC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,WAAW,CAAC;CAC9C,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type ShapeParser } from "./shapeParser.js";
2
+ export declare function createApiParserRestClassic(opts?: {
3
+ successField?: string;
4
+ dataField?: string;
5
+ errorField?: string;
6
+ messageField?: string;
7
+ }): ShapeParser;
8
+ export declare function createApiParserLaravel(opts?: {
9
+ dataField?: string;
10
+ }): ShapeParser;
11
+ export declare function createApiParserNest(): ShapeParser;
12
+ export declare function createApiParserGraphQL(opts?: {
13
+ allowPartialData?: boolean;
14
+ }): ShapeParser;
15
+ //# sourceMappingURL=presets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/parsing/presets.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEvE,wBAAgB,0BAA0B,CAAC,IAAI,CAAC,EAAE;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,WAAW,CA4Bd;AAED,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,WAAW,CAOjF;AAmBD,wBAAgB,mBAAmB,IAAI,WAAW,CAMjD;AAaD,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,WAAW,CAyBzF"}
@@ -0,0 +1,18 @@
1
+ export type Schema<T> = {
2
+ parse: (input: unknown) => T;
3
+ };
4
+ export declare function schema<T>(impl: Schema<T>): Schema<T>;
5
+ /**
6
+ * Optional helper to wrap a zod-like schema without adding a dependency.
7
+ */
8
+ export declare function fromZod<T>(zodSchema: {
9
+ parse?: (i: unknown) => T;
10
+ safeParse?: (i: unknown) => {
11
+ success: true;
12
+ data: T;
13
+ } | {
14
+ success: false;
15
+ error: unknown;
16
+ };
17
+ }): Schema<T>;
18
+ //# sourceMappingURL=schemaAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaAdapter.d.ts","sourceRoot":"","sources":["../../src/parsing/schemaAdapter.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;IAAE,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,CAAA;CAAE,CAAC;AAEzD,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAEpD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE;IACpC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC;IAC1B,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,CAAC,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;CAC7F,GAAG,MAAM,CAAC,CAAC,CAAC,CAYZ"}
@@ -0,0 +1,8 @@
1
+ import type { AppError } from "../client/errors.js";
2
+ export type ShapeParser = {
3
+ isSuccess: (raw: unknown, status: number) => boolean;
4
+ getData: (raw: unknown) => unknown;
5
+ getErrors: (raw: unknown, status: number) => AppError[];
6
+ };
7
+ export declare function createShapeParser(p: ShapeParser): ShapeParser;
8
+ //# sourceMappingURL=shapeParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shapeParser.d.ts","sourceRoot":"","sources":["../../src/parsing/shapeParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IACrD,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;IACnC,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,QAAQ,EAAE,CAAC;CACzD,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,WAAW,GAAG,WAAW,CAE7D"}
@@ -0,0 +1,22 @@
1
+ import type { HttpClientOptions } from "../client/types.js";
2
+ /**
3
+ * Minimal, stable plugin interface.
4
+ *
5
+ * Goals:
6
+ * - keep createHttpClient fully configurable (raw options still work)
7
+ * - allow wrappers/presets to be composed without deep coupling
8
+ * - avoid hidden side-effects: plugins only mutate a draft options object
9
+ */
10
+ export type HttpPlugin = {
11
+ /**
12
+ * Stable identifier (useful for debugging / de-dupe).
13
+ */
14
+ name: string;
15
+ /**
16
+ * Apply changes to the draft options.
17
+ *
18
+ * Important: keep it synchronous to preserve deterministic config.
19
+ */
20
+ apply: (options: HttpClientOptions) => void;
21
+ };
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,KAAK,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC7C,CAAC"}
@@ -0,0 +1,181 @@
1
+ import type { HttpClientOptions } from "../client/types.js";
2
+ import type { ShapeParser } from "../parsing/shapeParser.js";
3
+ import type { AuthConfig } from "../auth/authConfig.js";
4
+ import { bearerAuth, cookieAuth, basicAuth, apiKeyAuth } from "../auth/authConfig.js";
5
+ import type { Guard } from "../guards/types.js";
6
+ import { type CookieSafeRefreshGuardOptions } from "../guards/cookieSafeRefreshGuard.js";
7
+ import { type UnauthorizedGuardOptions } from "../guards/unauthorizedGuard.js";
8
+ import { type MemoryCacheOptions } from "../cache/memoryCache.js";
9
+ import type { Notifier } from "../notify/types.js";
10
+ /**
11
+ * Option B: preset builder
12
+ * - defaults to a "classic REST envelope" parser
13
+ * - defaults to noAuth()
14
+ * - provides convenience methods for common auth modes & cookie refresh
15
+ *
16
+ * If you need full control, call createHttpClient directly.
17
+ */
18
+ export type PresetBuilder = ReturnType<typeof createPresetBuilder>;
19
+ export declare function createPresetBuilder(init?: {
20
+ baseUrl?: string;
21
+ parser?: ShapeParser;
22
+ auth?: AuthConfig;
23
+ fetch?: typeof globalThis.fetch;
24
+ notifier?: Notifier;
25
+ }): {
26
+ /** Set / override baseUrl */
27
+ baseUrl(baseUrl: string): /*elided*/ any;
28
+ /** Set / override parser */
29
+ parser(parser: ShapeParser): /*elided*/ any;
30
+ /** Set / override fetch */
31
+ fetch(fetchImpl: typeof globalThis.fetch): /*elided*/ any;
32
+ /** Set / override notifier */
33
+ notifier(notifier: Notifier): /*elided*/ any;
34
+ /** Add guard(s) (preserves order) */
35
+ guards(...guards: Guard[]): /*elided*/ any;
36
+ /** Enable in-memory cache */
37
+ memoryCache(opts?: MemoryCacheOptions): /*elided*/ any;
38
+ /** Low-level cache assignment */
39
+ cache(cache: HttpClientOptions["cache"]): /*elided*/ any;
40
+ /** Default headers / timeouts / notify policy */
41
+ defaults(defaults: HttpClientOptions["defaults"]): /*elided*/ any;
42
+ /** Redirect policy */
43
+ redirects(redirects: HttpClientOptions["redirects"]): /*elided*/ any;
44
+ /** Auth presets */
45
+ auth(auth: AuthConfig): /*elided*/ any;
46
+ bearer(getToken: Parameters<typeof bearerAuth>[0], opts?: Parameters<typeof bearerAuth>[1]): /*elided*/ any;
47
+ cookie(opts?: Parameters<typeof cookieAuth>[0]): /*elided*/ any;
48
+ basic(getCred: Parameters<typeof basicAuth>[0], opts?: Parameters<typeof basicAuth>[1]): /*elided*/ any;
49
+ apiKey(getKey: Parameters<typeof apiKeyAuth>[0], opts?: Parameters<typeof apiKeyAuth>[1]): /*elided*/ any;
50
+ none(): /*elided*/ any;
51
+ /**
52
+ * Cookie refresh guard preset (only meaningful for cookie auth).
53
+ * You can still add it manually via `.guards(...)`.
54
+ */
55
+ cookieRefresh(opts: CookieSafeRefreshGuardOptions): /*elided*/ any;
56
+ /** Unauthorized handler preset (redirect/logout). */
57
+ unauthorized(opts: UnauthorizedGuardOptions): /*elided*/ any;
58
+ /** Returns the final HttpClientOptions */
59
+ options(): HttpClientOptions;
60
+ /** Creates the http client */
61
+ create(): {
62
+ get: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
63
+ post: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
64
+ put: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
65
+ patch: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
66
+ delete: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
67
+ cache: {
68
+ invalidateByTag: (tag: string) => number;
69
+ clear: () => void | undefined;
70
+ };
71
+ };
72
+ };
73
+ /**
74
+ * Option A (aliases): minimal-instantiation helpers.
75
+ * They are thin wrappers around the preset builder.
76
+ */
77
+ export declare function createSimpleClient(opts: {
78
+ baseUrl: string;
79
+ /** Defaults to classic REST envelope parser */
80
+ parser?: ShapeParser;
81
+ /** Defaults to noAuth */
82
+ auth?: AuthConfig;
83
+ fetch?: typeof globalThis.fetch;
84
+ notifier?: Notifier;
85
+ }): {
86
+ get: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
87
+ post: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
88
+ put: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
89
+ patch: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
90
+ delete: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
91
+ cache: {
92
+ invalidateByTag: (tag: string) => number;
93
+ clear: () => void | undefined;
94
+ };
95
+ };
96
+ export declare function createBearerClient(opts: {
97
+ baseUrl: string;
98
+ getToken: () => string | null | Promise<string | null>;
99
+ parser?: ShapeParser;
100
+ fetch?: typeof globalThis.fetch;
101
+ notifier?: Notifier;
102
+ headerName?: string;
103
+ prefix?: string;
104
+ }): {
105
+ get: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
106
+ post: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
107
+ put: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
108
+ patch: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
109
+ delete: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
110
+ cache: {
111
+ invalidateByTag: (tag: string) => number;
112
+ clear: () => void | undefined;
113
+ };
114
+ };
115
+ export declare function createCookieClient(opts: {
116
+ baseUrl: string;
117
+ parser?: ShapeParser;
118
+ fetch?: typeof globalThis.fetch;
119
+ notifier?: Notifier;
120
+ credentials?: RequestCredentials;
121
+ csrf?: {
122
+ headerName: string;
123
+ getToken: () => string | null | Promise<string | null>;
124
+ };
125
+ refresh?: CookieSafeRefreshGuardOptions | null;
126
+ }): {
127
+ get: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
128
+ post: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
129
+ put: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
130
+ patch: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
131
+ delete: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
132
+ cache: {
133
+ invalidateByTag: (tag: string) => number;
134
+ clear: () => void | undefined;
135
+ };
136
+ };
137
+ export declare function createBasicClient(opts: {
138
+ baseUrl: string;
139
+ getCredentials: () => {
140
+ username: string;
141
+ password: string;
142
+ } | string | null | Promise<{
143
+ username: string;
144
+ password: string;
145
+ } | string | null>;
146
+ parser?: ShapeParser;
147
+ fetch?: typeof globalThis.fetch;
148
+ notifier?: Notifier;
149
+ headerName?: string;
150
+ prefix?: string;
151
+ }): {
152
+ get: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
153
+ post: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
154
+ put: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
155
+ patch: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
156
+ delete: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
157
+ cache: {
158
+ invalidateByTag: (tag: string) => number;
159
+ clear: () => void | undefined;
160
+ };
161
+ };
162
+ export declare function createApiKeyClient(opts: {
163
+ baseUrl: string;
164
+ getKey: () => string | null | Promise<string | null>;
165
+ parser?: ShapeParser;
166
+ fetch?: typeof globalThis.fetch;
167
+ notifier?: Notifier;
168
+ headerName?: string;
169
+ prefix?: string;
170
+ }): {
171
+ get: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
172
+ post: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
173
+ put: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
174
+ patch: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
175
+ delete: <T>(path: string, ro?: import("../publicTypes.js").RequestOptions<T>) => Promise<import("../publicTypes.js").ClientResult<T>>;
176
+ cache: {
177
+ invalidateByTag: (tag: string) => number;
178
+ clear: () => void | undefined;
179
+ };
180
+ };
181
+ //# sourceMappingURL=presetBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presetBuilder.d.ts","sourceRoot":"","sources":["../../src/presets/presetBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAU,SAAS,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC9F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAA0B,KAAK,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AACjH,OAAO,EAAqB,KAAK,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAClG,OAAO,EAAe,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,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AAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MACZ;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GACtC,MAAM,GACN,IAAI,GACJ,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC;IACpE,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;;;;;;;;;EAcA;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACrD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;;;;;;;;;EAcA"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Public types surface for consumers.
3
+ * Keep this stable to avoid breaking changes.
4
+ */
5
+ export type { HttpMethod, RequestOptions, ClientResult, HttpClientOptions } from "./client/types.js";
6
+ export type { AppError } from "./client/errors.js";
7
+ export type { AuthConfig, BearerAuthConfig, CookieAuthConfig, BasicAuthConfig, ApiKeyAuthConfig, NoneAuthConfig, } from "./auth/authConfig.js";
8
+ export type { Notifier, NotifyEvent } from "./notify/types.js";
9
+ export type { RequestContext } from "./internal/context.js";
10
+ export type { Guard } from "./guards/types.js";
11
+ export type { PresetBuilder } from "./presets/presetBuilder.js";
12
+ //# sourceMappingURL=publicTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicTypes.d.ts","sourceRoot":"","sources":["../src/publicTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrG,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,YAAY,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC"}
package/package.json CHANGED
@@ -1,25 +1,30 @@
1
1
  {
2
2
  "name": "@cedvict/http-guardian",
3
- "version": "0.0.1-next.5",
3
+ "version": "0.0.1-next.7",
4
4
  "description": "Configurable HTTP client for TypeScript: auth (bearer/cookie), guards, cache+dedupe, dynamic envelope parsing presets, notifications, redirect handling.",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
8
8
  "types": "./dist/index.d.ts",
9
+ "browser": "./dist/index.js",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.cjs",
9
12
  "default": "./dist/index.js"
10
13
  }
11
14
  },
12
- "main": "./dist/index.js",
15
+ "main": "./dist/index.cjs",
16
+ "module": "./dist/index.js",
13
17
  "types": "./dist/index.d.ts",
14
18
  "files": [
15
19
  "dist",
16
20
  "README.md",
17
21
  "LICENSE",
18
- "TESTING.md"
22
+ "TESTING.md",
23
+ "CHANGELOG.md"
19
24
  ],
20
25
  "sideEffects": false,
21
26
  "engines": {
22
- "node": ">=18"
27
+ "node": ">=22"
23
28
  },
24
29
  "keywords": [
25
30
  "http",
@@ -41,7 +46,7 @@
41
46
  "url": "git+https://github.com/cedvict/http-guardian.git"
42
47
  },
43
48
  "scripts": {
44
- "build": "tsup",
49
+ "build": "tsup && tsc -p tsconfig.dts.json",
45
50
  "dev": "tsup --watch",
46
51
  "test": "vitest run",
47
52
  "test:unit": "vitest run test/unit",