@timeax/form-palette 0.0.8 → 0.0.10

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.
@@ -1,12 +1,12 @@
1
- import { AxiosResponse, AxiosRequestConfig } from 'axios';
2
1
  import { Page } from './../../../../node_modules/@inertiajs/core/types/types.d';
2
+ import { AxiosResponse, AxiosRequestConfig } from 'axios';
3
3
 
4
4
  /**
5
5
  * HTTP methods supported by the core adapter layer.
6
6
  *
7
7
  * This matches the legacy Method union from the old types.ts.
8
8
  */
9
- type Method$1 = 'post' | 'get' | 'delete' | 'put' | 'patch';
9
+ type Method = 'post' | 'get' | 'delete' | 'put' | 'patch';
10
10
  /**
11
11
  * Lifecycle callbacks used by adapters to report events back to the core.
12
12
  *
@@ -141,6 +141,73 @@ interface Adapters {
141
141
  */
142
142
  err: unknown;
143
143
  };
144
+ axios: {
145
+ /**
146
+ * What adapter.send() resolves with for Axios.
147
+ */
148
+ ok: AxiosResponse<unknown>;
149
+ /**
150
+ * What callbacks.onError receives for Axios.
151
+ *
152
+ * We pass the *payload* (e.g. response.data), not the raw AxiosError,
153
+ * so Form Palette's autoErr branch can see `.errors`.
154
+ */
155
+ err: unknown;
156
+ /**
157
+ * Extra public props exposed on CoreProps when adapter="axios".
158
+ *
159
+ * These are set on the Core shell and then used by createAxiosAdapter.
160
+ */
161
+ props: {
162
+ /**
163
+ * Request URL for this form.
164
+ * Required when using the axios adapter.
165
+ */
166
+ url: string;
167
+ /**
168
+ * HTTP method to use for this form.
169
+ * Optional: the adapter/Core can still default to "post".
170
+ */
171
+ method?: Method;
172
+ /**
173
+ * Base Axios request config merged into every request.
174
+ *
175
+ * Useful for baseURL, headers, withCredentials, params,
176
+ * timeout, etc. Per-call overrides still go through the
177
+ * `options` parameter of submit/send/run.
178
+ */
179
+ config?: AxiosRequestConfig<any>;
180
+ };
181
+ };
182
+ inertia: {
183
+ /**
184
+ * What adapter.send() resolves with for Inertia.
185
+ * This is the Page object passed to onSuccess.
186
+ */
187
+ ok: Page<any>;
188
+ /**
189
+ * What callbacks.onError receives for Inertia.
190
+ *
191
+ * We shape this as `{ errors: ErrorBag }` so Form Palette's
192
+ * autoErr branch can see `.errors`.
193
+ */
194
+ err: {
195
+ errors: Record<string, string | string[]>;
196
+ } | unknown;
197
+ /**
198
+ * Extra public props exposed on CoreProps when adapter="inertia".
199
+ */
200
+ props: {
201
+ /**
202
+ * Target URL / route for the Inertia visit.
203
+ */
204
+ url: string;
205
+ /**
206
+ * HTTP method to use for the visit.
207
+ */
208
+ method?: Method;
209
+ };
210
+ };
144
211
  }
145
212
  type AdapterProps<K extends AdapterKey> = Adapters[K] extends {
146
213
  props: infer P;
@@ -212,83 +279,8 @@ declare function getAdapter<K extends AdapterKey>(key: K): NamedAdapterFactory<K
212
279
  declare function hasAdapter(key: AdapterKey): boolean;
213
280
 
214
281
  declare const createAxiosAdapter: NamedAdapterFactory<"axios">;
215
- declare module "@/schema/adapter" {
216
- interface Adapters {
217
- axios: {
218
- /**
219
- * What adapter.send() resolves with for Axios.
220
- */
221
- ok: AxiosResponse<unknown>;
222
- /**
223
- * What callbacks.onError receives for Axios.
224
- *
225
- * We pass the *payload* (e.g. response.data), not the raw AxiosError,
226
- * so Form Palette's autoErr branch can see `.errors`.
227
- */
228
- err: unknown;
229
- /**
230
- * Extra public props exposed on CoreProps when adapter="axios".
231
- *
232
- * These are set on the Core shell and then used by createAxiosAdapter.
233
- */
234
- props: {
235
- /**
236
- * Request URL for this form.
237
- * Required when using the axios adapter.
238
- */
239
- url: string;
240
- /**
241
- * HTTP method to use for this form.
242
- * Optional: the adapter/Core can still default to "post".
243
- */
244
- method?: Method;
245
- /**
246
- * Base Axios request config merged into every request.
247
- *
248
- * Useful for baseURL, headers, withCredentials, params,
249
- * timeout, etc. Per-call overrides still go through the
250
- * `options` parameter of submit/send/run.
251
- */
252
- config?: AxiosRequestConfig<any>;
253
- };
254
- };
255
- }
256
- }
257
282
 
258
283
  declare const createInertiaAdapter: NamedAdapterFactory<"inertia">;
259
- declare module "@/schema/adapter" {
260
- interface Adapters {
261
- inertia: {
262
- /**
263
- * What adapter.send() resolves with for Inertia.
264
- * This is the Page object passed to onSuccess.
265
- */
266
- ok: Page<any>;
267
- /**
268
- * What callbacks.onError receives for Inertia.
269
- *
270
- * We shape this as `{ errors: ErrorBag }` so Form Palette's
271
- * autoErr branch can see `.errors`.
272
- */
273
- err: {
274
- errors: Record<string, string | string[]>;
275
- } | unknown;
276
- /**
277
- * Extra public props exposed on CoreProps when adapter="inertia".
278
- */
279
- props: {
280
- /**
281
- * Target URL / route for the Inertia visit.
282
- */
283
- url: string;
284
- /**
285
- * HTTP method to use for the visit.
286
- */
287
- method?: Method;
288
- };
289
- };
290
- }
291
- }
292
284
 
293
285
  /**
294
286
  * Register the Axios adapter under the "axios" key.
@@ -319,4 +311,4 @@ declare function registerInertiaAdapter(): Promise<void>;
319
311
  */
320
312
  declare function registerKnownAdapter(key: AdapterKey): Promise<void>;
321
313
 
322
- export { type AdapterCallbacks, type AdapterConfig, type AdapterError, type AdapterFactory, type AdapterKey, type AdapterOk, type AdapterProps, type AdapterResult, type AdapterSubmit, type Adapters, type Method$1 as Method, type NamedAdapterConfig, type NamedAdapterFactory, createAxiosAdapter, createInertiaAdapter, getAdapter, hasAdapter, localAdapter, registerAdapter, registerAxiosAdapter, registerInertiaAdapter, registerKnownAdapter };
314
+ export { type AdapterCallbacks, type AdapterConfig, type AdapterError, type AdapterFactory, type AdapterKey, type AdapterOk, type AdapterProps, type AdapterResult, type AdapterSubmit, type Adapters, type Method, type NamedAdapterConfig, type NamedAdapterFactory, createAxiosAdapter, createInertiaAdapter, getAdapter, hasAdapter, localAdapter, registerAdapter, registerAxiosAdapter, registerInertiaAdapter, registerKnownAdapter };
@@ -1,12 +1,12 @@
1
- import { AxiosResponse, AxiosRequestConfig } from 'axios';
2
1
  import { Page } from './../../../../node_modules/@inertiajs/core/types/types.d';
2
+ import { AxiosResponse, AxiosRequestConfig } from 'axios';
3
3
 
4
4
  /**
5
5
  * HTTP methods supported by the core adapter layer.
6
6
  *
7
7
  * This matches the legacy Method union from the old types.ts.
8
8
  */
9
- type Method$1 = 'post' | 'get' | 'delete' | 'put' | 'patch';
9
+ type Method = 'post' | 'get' | 'delete' | 'put' | 'patch';
10
10
  /**
11
11
  * Lifecycle callbacks used by adapters to report events back to the core.
12
12
  *
@@ -141,6 +141,73 @@ interface Adapters {
141
141
  */
142
142
  err: unknown;
143
143
  };
144
+ axios: {
145
+ /**
146
+ * What adapter.send() resolves with for Axios.
147
+ */
148
+ ok: AxiosResponse<unknown>;
149
+ /**
150
+ * What callbacks.onError receives for Axios.
151
+ *
152
+ * We pass the *payload* (e.g. response.data), not the raw AxiosError,
153
+ * so Form Palette's autoErr branch can see `.errors`.
154
+ */
155
+ err: unknown;
156
+ /**
157
+ * Extra public props exposed on CoreProps when adapter="axios".
158
+ *
159
+ * These are set on the Core shell and then used by createAxiosAdapter.
160
+ */
161
+ props: {
162
+ /**
163
+ * Request URL for this form.
164
+ * Required when using the axios adapter.
165
+ */
166
+ url: string;
167
+ /**
168
+ * HTTP method to use for this form.
169
+ * Optional: the adapter/Core can still default to "post".
170
+ */
171
+ method?: Method;
172
+ /**
173
+ * Base Axios request config merged into every request.
174
+ *
175
+ * Useful for baseURL, headers, withCredentials, params,
176
+ * timeout, etc. Per-call overrides still go through the
177
+ * `options` parameter of submit/send/run.
178
+ */
179
+ config?: AxiosRequestConfig<any>;
180
+ };
181
+ };
182
+ inertia: {
183
+ /**
184
+ * What adapter.send() resolves with for Inertia.
185
+ * This is the Page object passed to onSuccess.
186
+ */
187
+ ok: Page<any>;
188
+ /**
189
+ * What callbacks.onError receives for Inertia.
190
+ *
191
+ * We shape this as `{ errors: ErrorBag }` so Form Palette's
192
+ * autoErr branch can see `.errors`.
193
+ */
194
+ err: {
195
+ errors: Record<string, string | string[]>;
196
+ } | unknown;
197
+ /**
198
+ * Extra public props exposed on CoreProps when adapter="inertia".
199
+ */
200
+ props: {
201
+ /**
202
+ * Target URL / route for the Inertia visit.
203
+ */
204
+ url: string;
205
+ /**
206
+ * HTTP method to use for the visit.
207
+ */
208
+ method?: Method;
209
+ };
210
+ };
144
211
  }
145
212
  type AdapterProps<K extends AdapterKey> = Adapters[K] extends {
146
213
  props: infer P;
@@ -212,83 +279,8 @@ declare function getAdapter<K extends AdapterKey>(key: K): NamedAdapterFactory<K
212
279
  declare function hasAdapter(key: AdapterKey): boolean;
213
280
 
214
281
  declare const createAxiosAdapter: NamedAdapterFactory<"axios">;
215
- declare module "@/schema/adapter" {
216
- interface Adapters {
217
- axios: {
218
- /**
219
- * What adapter.send() resolves with for Axios.
220
- */
221
- ok: AxiosResponse<unknown>;
222
- /**
223
- * What callbacks.onError receives for Axios.
224
- *
225
- * We pass the *payload* (e.g. response.data), not the raw AxiosError,
226
- * so Form Palette's autoErr branch can see `.errors`.
227
- */
228
- err: unknown;
229
- /**
230
- * Extra public props exposed on CoreProps when adapter="axios".
231
- *
232
- * These are set on the Core shell and then used by createAxiosAdapter.
233
- */
234
- props: {
235
- /**
236
- * Request URL for this form.
237
- * Required when using the axios adapter.
238
- */
239
- url: string;
240
- /**
241
- * HTTP method to use for this form.
242
- * Optional: the adapter/Core can still default to "post".
243
- */
244
- method?: Method;
245
- /**
246
- * Base Axios request config merged into every request.
247
- *
248
- * Useful for baseURL, headers, withCredentials, params,
249
- * timeout, etc. Per-call overrides still go through the
250
- * `options` parameter of submit/send/run.
251
- */
252
- config?: AxiosRequestConfig<any>;
253
- };
254
- };
255
- }
256
- }
257
282
 
258
283
  declare const createInertiaAdapter: NamedAdapterFactory<"inertia">;
259
- declare module "@/schema/adapter" {
260
- interface Adapters {
261
- inertia: {
262
- /**
263
- * What adapter.send() resolves with for Inertia.
264
- * This is the Page object passed to onSuccess.
265
- */
266
- ok: Page<any>;
267
- /**
268
- * What callbacks.onError receives for Inertia.
269
- *
270
- * We shape this as `{ errors: ErrorBag }` so Form Palette's
271
- * autoErr branch can see `.errors`.
272
- */
273
- err: {
274
- errors: Record<string, string | string[]>;
275
- } | unknown;
276
- /**
277
- * Extra public props exposed on CoreProps when adapter="inertia".
278
- */
279
- props: {
280
- /**
281
- * Target URL / route for the Inertia visit.
282
- */
283
- url: string;
284
- /**
285
- * HTTP method to use for the visit.
286
- */
287
- method?: Method;
288
- };
289
- };
290
- }
291
- }
292
284
 
293
285
  /**
294
286
  * Register the Axios adapter under the "axios" key.
@@ -319,4 +311,4 @@ declare function registerInertiaAdapter(): Promise<void>;
319
311
  */
320
312
  declare function registerKnownAdapter(key: AdapterKey): Promise<void>;
321
313
 
322
- export { type AdapterCallbacks, type AdapterConfig, type AdapterError, type AdapterFactory, type AdapterKey, type AdapterOk, type AdapterProps, type AdapterResult, type AdapterSubmit, type Adapters, type Method$1 as Method, type NamedAdapterConfig, type NamedAdapterFactory, createAxiosAdapter, createInertiaAdapter, getAdapter, hasAdapter, localAdapter, registerAdapter, registerAxiosAdapter, registerInertiaAdapter, registerKnownAdapter };
314
+ export { type AdapterCallbacks, type AdapterConfig, type AdapterError, type AdapterFactory, type AdapterKey, type AdapterOk, type AdapterProps, type AdapterResult, type AdapterSubmit, type Adapters, type Method, type NamedAdapterConfig, type NamedAdapterFactory, createAxiosAdapter, createInertiaAdapter, getAdapter, hasAdapter, localAdapter, registerAdapter, registerAxiosAdapter, registerInertiaAdapter, registerKnownAdapter };