@djangocfg/api 2.1.331 → 2.1.332

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/dist/clients.d.ts CHANGED
@@ -1,12 +1,5 @@
1
1
  import { ConsolaInstance } from 'consola';
2
2
 
3
- interface StorageAdapter {
4
- getItem(key: string): string | null;
5
- setItem(key: string, value: string): void;
6
- removeItem(key: string): void;
7
- clear?(): void;
8
- }
9
-
10
3
  interface RequestLog {
11
4
  method: string;
12
5
  url: string;
@@ -57,8 +50,6 @@ declare class APILogger {
57
50
  }
58
51
 
59
52
  interface APIOptions$2 {
60
- /** Override storage backend (LocalStorage by default; Memory for SSR/tests). */
61
- storage?: StorageAdapter;
62
53
  /** Logger config (defaults to dev-only). */
63
54
  logger?: Partial<LoggerConfig>;
64
55
  /** Locale for `Accept-Language`. If omitted, auto-detected from cookie/navigator. */
@@ -69,22 +60,18 @@ interface APIOptions$2 {
69
60
  withCredentials?: boolean;
70
61
  }
71
62
  /**
72
- * Self-contained API wrapper for this group.
63
+ * Per-group ergonomic facade.
64
+ *
65
+ * Calling `setToken/setApiKey/setLocale/setBaseUrl` proxies to the
66
+ * global `auth` store — the change applies to **every** group's API
67
+ * instance because they share the same HTTP client and interceptor.
73
68
  *
74
- * Each group has its own client + interceptor + token store. The interceptor
75
- * automatically attaches:
76
- * - `Authorization: Bearer <jwt>` from storage
77
- * - `Accept-Language` from `opts.locale` or `NEXT_LOCALE` cookie
78
- * - `X-API-Key` from `opts.apiKey` or `NEXT_PUBLIC_API_KEY`
79
- * - `credentials: 'include'` for Django session/CSRF cookies (toggle via opts)
69
+ * Use the global `auth` object directly when you don't need a group
70
+ * facade: `import { auth } from '@your/api'; auth.setToken(jwt);`
80
71
  */
81
72
  declare class API$2 {
82
- private baseUrl;
83
- private storage;
84
- private locale;
85
- private apiKey;
86
73
  readonly logger: APILogger;
87
- constructor(baseUrl: string, opts?: APIOptions$2);
74
+ constructor(_baseUrl?: string, opts?: APIOptions$2);
88
75
  getBaseUrl(): string;
89
76
  setBaseUrl(url: string): void;
90
77
  getToken(): string | null;
@@ -100,8 +87,6 @@ declare class API$2 {
100
87
  }
101
88
 
102
89
  interface APIOptions$1 {
103
- /** Override storage backend (LocalStorage by default; Memory for SSR/tests). */
104
- storage?: StorageAdapter;
105
90
  /** Logger config (defaults to dev-only). */
106
91
  logger?: Partial<LoggerConfig>;
107
92
  /** Locale for `Accept-Language`. If omitted, auto-detected from cookie/navigator. */
@@ -112,22 +97,18 @@ interface APIOptions$1 {
112
97
  withCredentials?: boolean;
113
98
  }
114
99
  /**
115
- * Self-contained API wrapper for this group.
100
+ * Per-group ergonomic facade.
116
101
  *
117
- * Each group has its own client + interceptor + token store. The interceptor
118
- * automatically attaches:
119
- * - `Authorization: Bearer <jwt>` from storage
120
- * - `Accept-Language` from `opts.locale` or `NEXT_LOCALE` cookie
121
- * - `X-API-Key` from `opts.apiKey` or `NEXT_PUBLIC_API_KEY`
122
- * - `credentials: 'include'` for Django session/CSRF cookies (toggle via opts)
102
+ * Calling `setToken/setApiKey/setLocale/setBaseUrl` proxies to the
103
+ * global `auth` store — the change applies to **every** group's API
104
+ * instance because they share the same HTTP client and interceptor.
105
+ *
106
+ * Use the global `auth` object directly when you don't need a group
107
+ * facade: `import { auth } from '@your/api'; auth.setToken(jwt);`
123
108
  */
124
109
  declare class API$1 {
125
- private baseUrl;
126
- private storage;
127
- private locale;
128
- private apiKey;
129
110
  readonly logger: APILogger;
130
- constructor(baseUrl: string, opts?: APIOptions$1);
111
+ constructor(_baseUrl?: string, opts?: APIOptions$1);
131
112
  getBaseUrl(): string;
132
113
  setBaseUrl(url: string): void;
133
114
  getToken(): string | null;
@@ -143,8 +124,6 @@ declare class API$1 {
143
124
  }
144
125
 
145
126
  interface APIOptions {
146
- /** Override storage backend (LocalStorage by default; Memory for SSR/tests). */
147
- storage?: StorageAdapter;
148
127
  /** Logger config (defaults to dev-only). */
149
128
  logger?: Partial<LoggerConfig>;
150
129
  /** Locale for `Accept-Language`. If omitted, auto-detected from cookie/navigator. */
@@ -155,22 +134,18 @@ interface APIOptions {
155
134
  withCredentials?: boolean;
156
135
  }
157
136
  /**
158
- * Self-contained API wrapper for this group.
137
+ * Per-group ergonomic facade.
138
+ *
139
+ * Calling `setToken/setApiKey/setLocale/setBaseUrl` proxies to the
140
+ * global `auth` store — the change applies to **every** group's API
141
+ * instance because they share the same HTTP client and interceptor.
159
142
  *
160
- * Each group has its own client + interceptor + token store. The interceptor
161
- * automatically attaches:
162
- * - `Authorization: Bearer <jwt>` from storage
163
- * - `Accept-Language` from `opts.locale` or `NEXT_LOCALE` cookie
164
- * - `X-API-Key` from `opts.apiKey` or `NEXT_PUBLIC_API_KEY`
165
- * - `credentials: 'include'` for Django session/CSRF cookies (toggle via opts)
143
+ * Use the global `auth` object directly when you don't need a group
144
+ * facade: `import { auth } from '@your/api'; auth.setToken(jwt);`
166
145
  */
167
146
  declare class API {
168
- private baseUrl;
169
- private storage;
170
- private locale;
171
- private apiKey;
172
147
  readonly logger: APILogger;
173
- constructor(baseUrl: string, opts?: APIOptions);
148
+ constructor(_baseUrl?: string, opts?: APIOptions);
174
149
  getBaseUrl(): string;
175
150
  setBaseUrl(url: string): void;
176
151
  getToken(): string | null;