@gravito/ion 3.1.0 → 4.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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,140 @@
1
1
  import { GravitoContext, GravitoVariables, GravitoOrbit, PlanetCore } from '@gravito/core';
2
2
 
3
+ /**
4
+ * @fileoverview Type definitions for Inertia v2 protocol features.
5
+ *
6
+ * This module provides type definitions for advanced Inertia features:
7
+ * - Deferred Props: Delay loading of specific props to initial render
8
+ * - Merge Props: Replace, prepend, or deep-merge props during partial reloads
9
+ * - History Encryption: Control browser history handling
10
+ * - Error Bags: Organize form validation errors by category
11
+ *
12
+ * @module @gravito/ion/types
13
+ */
14
+ /**
15
+ * Marks a prop for deferred loading.
16
+ *
17
+ * Deferred props are not executed during the initial page render, but are listed
18
+ * in the `deferredProps` field of the Inertia page object. The client fetches them
19
+ * separately after the initial render is complete.
20
+ *
21
+ * @template T - Type of the deferred value (inferred from factory return type).
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * inertia.render('Dashboard', {
26
+ * user: { id: 1, name: 'Carl' },
27
+ * // Heavy computation deferred to later
28
+ * slowStats: InertiaService.defer(() => calculateStats()),
29
+ * // Grouped deferred props
30
+ * notifications: InertiaService.defer(
31
+ * () => fetchNotifications(),
32
+ * 'notifications-group'
33
+ * )
34
+ * });
35
+ * ```
36
+ */
37
+ interface DeferredPropDefinition<T = unknown> {
38
+ readonly _type: 'deferred';
39
+ readonly factory: () => T | Promise<T>;
40
+ readonly group?: string;
41
+ }
42
+ /**
43
+ * Marks a prop for merging rather than replacement.
44
+ *
45
+ * Used during partial reloads (X-Inertia-Partial-Data) to control how props
46
+ * are combined with existing data on the client:
47
+ * - `merge`: Shallow merge at top level
48
+ * - `prepend`: Add items to the beginning of an array
49
+ * - `deepMerge`: Recursive merge for nested objects
50
+ *
51
+ * @template T - Type of the prop value.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * inertia.render('Products/List', {
56
+ * // Deep merge filters with existing data
57
+ * filters: InertiaService.deepMerge({ status: 'active', price: 100 }),
58
+ * // Prepend new items to the beginning of the list
59
+ * items: InertiaService.prepend([newProduct]),
60
+ * // Shallow merge config with existing data
61
+ * config: InertiaService.merge({ sortBy: 'name' })
62
+ * });
63
+ * ```
64
+ */
65
+ interface MergedPropDefinition<T = unknown> {
66
+ readonly _type: 'merge' | 'prepend' | 'deepMerge';
67
+ readonly value: T;
68
+ readonly matchOn?: string | string[];
69
+ }
70
+ /**
71
+ * Configuration for error bags in form validation.
72
+ *
73
+ * Organizes form validation errors into named categories, allowing multiple
74
+ * validation failure scenarios to coexist (e.g., 'default' and 'import-csv').
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * inertia.withErrors({
79
+ * email: 'Email is required',
80
+ * password: 'Must be at least 8 characters'
81
+ * }, 'login'); // Bag name: 'login'
82
+ *
83
+ * inertia.withErrors({
84
+ * line_1: 'Invalid CSV at row 1',
85
+ * line_2: 'Invalid CSV at row 2'
86
+ * }, 'import'); // Bag name: 'import'
87
+ * ```
88
+ */
89
+ interface ErrorBagDefinition {
90
+ readonly bag: string;
91
+ readonly errors: Record<string, string | string[]>;
92
+ }
93
+ /**
94
+ * Inertia page object structure for the initial render response.
95
+ *
96
+ * This is the JSON structure sent to the frontend containing component metadata
97
+ * and all resolved props. Extended with Inertia v2 features.
98
+ *
99
+ * @template P - Shape of the props object.
100
+ */
101
+ interface InertiaPageObject<P extends Record<string, unknown> = Record<string, unknown>> {
102
+ /** Frontend component name (e.g., 'Pages/Dashboard') */
103
+ component: string;
104
+ /** Resolved and merged props for the component */
105
+ props: P;
106
+ /** Current URL without query string */
107
+ url: string;
108
+ /** Asset version (cache-busting identifier) */
109
+ version?: string;
110
+ /** Deferred prop groups and their factories (Inertia v2) */
111
+ deferredProps?: Record<string, string[]>;
112
+ /** Keys marked for merge/prepend/deepMerge (Inertia v2) */
113
+ mergeProps?: {
114
+ keys: string[];
115
+ mode: 'merge' | 'prepend' | 'deepMerge';
116
+ }[];
117
+ /** Whether to encrypt browser history (Inertia v2) */
118
+ encryptHistory?: boolean;
119
+ /** Whether to clear browser history (Inertia v2) */
120
+ clearHistory?: boolean;
121
+ /** Error bags organized by category (Inertia v2) */
122
+ errorBags?: Record<string, Record<string, string | string[]>>;
123
+ }
124
+ /**
125
+ * Inertia response metadata for partial reloads.
126
+ *
127
+ * Controls how the frontend should process the props update:
128
+ * - Handles reset scenarios (X-Inertia-Reset header)
129
+ * - Tracks which keys should be reset to undefined
130
+ */
131
+ interface PartialReloadMetadata {
132
+ /** Keys to reset to undefined before merging new props */
133
+ resetKeys?: string[];
134
+ /** Merge strategy for the reload response */
135
+ mergeStrategy?: 'replace' | 'merge' | 'deepMerge';
136
+ }
137
+
3
138
  /**
4
139
  * @fileoverview Inertia.js Service for Gravito.
5
140
  *
@@ -115,8 +250,49 @@ declare class InertiaService {
115
250
  private context;
116
251
  private config;
117
252
  private sharedProps;
253
+ private errorBags;
254
+ private encryptHistoryFlag;
255
+ private clearHistoryFlag;
118
256
  private readonly logLevel;
119
257
  private readonly onRenderCallback?;
258
+ /**
259
+ * Creates a deferred prop that will be loaded after the initial render.
260
+ *
261
+ * @param factory - Function that resolves to the prop value.
262
+ * @param group - Optional group name for organizing deferred props.
263
+ * @returns A deferred prop definition.
264
+ *
265
+ * @example
266
+ * ```typescript
267
+ * props: {
268
+ * user: { id: 1 },
269
+ * stats: InertiaService.defer(() => fetchStats())
270
+ * }
271
+ * ```
272
+ */
273
+ static defer<T = unknown>(factory: () => T | Promise<T>, group?: string): DeferredPropDefinition<T>;
274
+ /**
275
+ * Marks a prop to be merged (shallow) with existing data during partial reloads.
276
+ *
277
+ * @param value - The prop value to merge.
278
+ * @param matchOn - Optional key(s) to match on when merging arrays.
279
+ * @returns A merge prop definition.
280
+ */
281
+ static merge<T = unknown>(value: T, matchOn?: string | string[]): MergedPropDefinition<T>;
282
+ /**
283
+ * Marks a prop to prepend to an array during partial reloads.
284
+ *
285
+ * @param value - The prop value to prepend.
286
+ * @returns A prepend prop definition.
287
+ */
288
+ static prepend<T = unknown>(value: T): MergedPropDefinition<T>;
289
+ /**
290
+ * Marks a prop to be deep-merged with existing data during partial reloads.
291
+ *
292
+ * @param value - The prop value to deep merge.
293
+ * @returns A deep merge prop definition.
294
+ */
295
+ static deepMerge<T = unknown>(value: T): MergedPropDefinition<T>;
120
296
  /**
121
297
  * Initializes a new instance of the Inertia service.
122
298
  *
@@ -230,6 +406,77 @@ declare class InertiaService {
230
406
  * ```
231
407
  */
232
408
  getSharedProps(): Record<string, unknown>;
409
+ /**
410
+ * Instructs the Inertia client to navigate to a different URL.
411
+ *
412
+ * For Inertia AJAX requests, this returns a 409 Conflict with the `X-Inertia-Location` header.
413
+ * For regular page loads, this returns a 302 Found redirect.
414
+ *
415
+ * This is useful for server-side redirects triggered by authentication or authorization checks.
416
+ *
417
+ * @param url - The URL to redirect to.
418
+ * @returns A redirect response.
419
+ *
420
+ * @example
421
+ * ```typescript
422
+ * if (!ctx.get('user')) {
423
+ * return inertia.location('/login');
424
+ * }
425
+ * ```
426
+ */
427
+ location(url: string): Response;
428
+ /**
429
+ * Controls whether the Inertia client should encrypt browser history.
430
+ *
431
+ * When enabled, history is not written to the browser's History API,
432
+ * preventing users from using the browser back button to return to previous pages.
433
+ *
434
+ * @param encrypt - Whether to encrypt history (defaults to true).
435
+ * @returns The service instance for method chaining.
436
+ *
437
+ * @example
438
+ * ```typescript
439
+ * return await inertia.encryptHistory(true).render('SecurePage');
440
+ * ```
441
+ */
442
+ encryptHistory(encrypt?: boolean): this;
443
+ /**
444
+ * Clears the browser history after the page load.
445
+ *
446
+ * Useful for sensitive operations or multi-step wizards where you don't want
447
+ * users navigating back to previous states.
448
+ *
449
+ * @returns The service instance for method chaining.
450
+ *
451
+ * @example
452
+ * ```typescript
453
+ * return await inertia.clearHistory().render('SuccessPage');
454
+ * ```
455
+ */
456
+ clearHistory(): this;
457
+ /**
458
+ * Registers form validation errors organized into named bags.
459
+ *
460
+ * Error bags allow multiple validation failure scenarios to coexist.
461
+ * For example, you might have 'default' errors and 'import' errors from different forms.
462
+ *
463
+ * @param errors - Validation errors, with field names as keys and error messages as values.
464
+ * @param bag - The error bag name (defaults to 'default').
465
+ * @returns The service instance for method chaining.
466
+ *
467
+ * @example
468
+ * ```typescript
469
+ * inertia.withErrors({
470
+ * email: 'Email is required',
471
+ * password: 'Must be 8+ characters'
472
+ * }, 'login');
473
+ *
474
+ * inertia.withErrors({
475
+ * line_1: 'Invalid CSV format'
476
+ * }, 'import');
477
+ * ```
478
+ */
479
+ withErrors(errors: Record<string, string | string[]>, bag?: string): this;
233
480
  }
234
481
 
235
482
  /**
@@ -347,6 +594,34 @@ interface InertiaHelper {
347
594
  * Thrown if the rendering lifecycle encounters a fatal error.
348
595
  */
349
596
  render<T extends Record<string, unknown> = Record<string, unknown>>(component: string, props?: T, rootVars?: Record<string, unknown>, status?: number): Promise<Response>;
597
+ /**
598
+ * Instructs the client to navigate to a different URL.
599
+ *
600
+ * @param url - The URL to navigate to.
601
+ * @returns A redirect response.
602
+ */
603
+ location(url: string): Response;
604
+ /**
605
+ * Encrypts the browser history to prevent navigation via back button.
606
+ *
607
+ * @param encrypt - Whether to enable history encryption (defaults to true).
608
+ * @returns The helper for method chaining.
609
+ */
610
+ encryptHistory(encrypt?: boolean): InertiaHelper;
611
+ /**
612
+ * Clears the browser history after page load.
613
+ *
614
+ * @returns The helper for method chaining.
615
+ */
616
+ clearHistory(): InertiaHelper;
617
+ /**
618
+ * Registers form validation errors organized by bag name.
619
+ *
620
+ * @param errors - Error map with field names as keys.
621
+ * @param bag - The error bag name (defaults to 'default').
622
+ * @returns The helper for method chaining.
623
+ */
624
+ withErrors(errors: Record<string, string | string[]>, bag?: string): InertiaHelper;
350
625
  /**
351
626
  * Direct access to the low-level `InertiaService` instance.
352
627
  *
@@ -394,6 +669,19 @@ interface OrbitIonOptions {
394
669
  body: string;
395
670
  }>;
396
671
  };
672
+ /**
673
+ * CSRF protection configuration.
674
+ *
675
+ * Automatically sets the XSRF-TOKEN cookie for CSRF protection.
676
+ *
677
+ * @defaultValue { enabled: true, cookieName: 'XSRF-TOKEN' }
678
+ */
679
+ csrf?: {
680
+ /** Whether CSRF protection is enabled. */
681
+ enabled?: boolean;
682
+ /** Name of the CSRF token cookie (commonly read by Axios). */
683
+ cookieName?: string;
684
+ };
397
685
  }
398
686
  /**
399
687
  * OrbitIon provides official Inertia.js integration for Gravito.
@@ -445,4 +733,4 @@ declare class OrbitIon implements GravitoOrbit {
445
733
  install(core: PlanetCore): void;
446
734
  }
447
735
 
448
- export { type InertiaConfig, InertiaConfigError, InertiaDataError, InertiaError, type InertiaHelper, InertiaService, InertiaTemplateError, OrbitIon, type OrbitIonOptions, type RenderMetrics, OrbitIon as default };
736
+ export { type DeferredPropDefinition, type ErrorBagDefinition, type InertiaConfig, InertiaConfigError, InertiaDataError, InertiaError, type InertiaHelper, type InertiaPageObject, InertiaService, InertiaTemplateError, type MergedPropDefinition, OrbitIon, type OrbitIonOptions, type PartialReloadMetadata, type RenderMetrics, OrbitIon as default };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,140 @@
1
1
  import { GravitoContext, GravitoVariables, GravitoOrbit, PlanetCore } from '@gravito/core';
2
2
 
3
+ /**
4
+ * @fileoverview Type definitions for Inertia v2 protocol features.
5
+ *
6
+ * This module provides type definitions for advanced Inertia features:
7
+ * - Deferred Props: Delay loading of specific props to initial render
8
+ * - Merge Props: Replace, prepend, or deep-merge props during partial reloads
9
+ * - History Encryption: Control browser history handling
10
+ * - Error Bags: Organize form validation errors by category
11
+ *
12
+ * @module @gravito/ion/types
13
+ */
14
+ /**
15
+ * Marks a prop for deferred loading.
16
+ *
17
+ * Deferred props are not executed during the initial page render, but are listed
18
+ * in the `deferredProps` field of the Inertia page object. The client fetches them
19
+ * separately after the initial render is complete.
20
+ *
21
+ * @template T - Type of the deferred value (inferred from factory return type).
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * inertia.render('Dashboard', {
26
+ * user: { id: 1, name: 'Carl' },
27
+ * // Heavy computation deferred to later
28
+ * slowStats: InertiaService.defer(() => calculateStats()),
29
+ * // Grouped deferred props
30
+ * notifications: InertiaService.defer(
31
+ * () => fetchNotifications(),
32
+ * 'notifications-group'
33
+ * )
34
+ * });
35
+ * ```
36
+ */
37
+ interface DeferredPropDefinition<T = unknown> {
38
+ readonly _type: 'deferred';
39
+ readonly factory: () => T | Promise<T>;
40
+ readonly group?: string;
41
+ }
42
+ /**
43
+ * Marks a prop for merging rather than replacement.
44
+ *
45
+ * Used during partial reloads (X-Inertia-Partial-Data) to control how props
46
+ * are combined with existing data on the client:
47
+ * - `merge`: Shallow merge at top level
48
+ * - `prepend`: Add items to the beginning of an array
49
+ * - `deepMerge`: Recursive merge for nested objects
50
+ *
51
+ * @template T - Type of the prop value.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * inertia.render('Products/List', {
56
+ * // Deep merge filters with existing data
57
+ * filters: InertiaService.deepMerge({ status: 'active', price: 100 }),
58
+ * // Prepend new items to the beginning of the list
59
+ * items: InertiaService.prepend([newProduct]),
60
+ * // Shallow merge config with existing data
61
+ * config: InertiaService.merge({ sortBy: 'name' })
62
+ * });
63
+ * ```
64
+ */
65
+ interface MergedPropDefinition<T = unknown> {
66
+ readonly _type: 'merge' | 'prepend' | 'deepMerge';
67
+ readonly value: T;
68
+ readonly matchOn?: string | string[];
69
+ }
70
+ /**
71
+ * Configuration for error bags in form validation.
72
+ *
73
+ * Organizes form validation errors into named categories, allowing multiple
74
+ * validation failure scenarios to coexist (e.g., 'default' and 'import-csv').
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * inertia.withErrors({
79
+ * email: 'Email is required',
80
+ * password: 'Must be at least 8 characters'
81
+ * }, 'login'); // Bag name: 'login'
82
+ *
83
+ * inertia.withErrors({
84
+ * line_1: 'Invalid CSV at row 1',
85
+ * line_2: 'Invalid CSV at row 2'
86
+ * }, 'import'); // Bag name: 'import'
87
+ * ```
88
+ */
89
+ interface ErrorBagDefinition {
90
+ readonly bag: string;
91
+ readonly errors: Record<string, string | string[]>;
92
+ }
93
+ /**
94
+ * Inertia page object structure for the initial render response.
95
+ *
96
+ * This is the JSON structure sent to the frontend containing component metadata
97
+ * and all resolved props. Extended with Inertia v2 features.
98
+ *
99
+ * @template P - Shape of the props object.
100
+ */
101
+ interface InertiaPageObject<P extends Record<string, unknown> = Record<string, unknown>> {
102
+ /** Frontend component name (e.g., 'Pages/Dashboard') */
103
+ component: string;
104
+ /** Resolved and merged props for the component */
105
+ props: P;
106
+ /** Current URL without query string */
107
+ url: string;
108
+ /** Asset version (cache-busting identifier) */
109
+ version?: string;
110
+ /** Deferred prop groups and their factories (Inertia v2) */
111
+ deferredProps?: Record<string, string[]>;
112
+ /** Keys marked for merge/prepend/deepMerge (Inertia v2) */
113
+ mergeProps?: {
114
+ keys: string[];
115
+ mode: 'merge' | 'prepend' | 'deepMerge';
116
+ }[];
117
+ /** Whether to encrypt browser history (Inertia v2) */
118
+ encryptHistory?: boolean;
119
+ /** Whether to clear browser history (Inertia v2) */
120
+ clearHistory?: boolean;
121
+ /** Error bags organized by category (Inertia v2) */
122
+ errorBags?: Record<string, Record<string, string | string[]>>;
123
+ }
124
+ /**
125
+ * Inertia response metadata for partial reloads.
126
+ *
127
+ * Controls how the frontend should process the props update:
128
+ * - Handles reset scenarios (X-Inertia-Reset header)
129
+ * - Tracks which keys should be reset to undefined
130
+ */
131
+ interface PartialReloadMetadata {
132
+ /** Keys to reset to undefined before merging new props */
133
+ resetKeys?: string[];
134
+ /** Merge strategy for the reload response */
135
+ mergeStrategy?: 'replace' | 'merge' | 'deepMerge';
136
+ }
137
+
3
138
  /**
4
139
  * @fileoverview Inertia.js Service for Gravito.
5
140
  *
@@ -115,8 +250,49 @@ declare class InertiaService {
115
250
  private context;
116
251
  private config;
117
252
  private sharedProps;
253
+ private errorBags;
254
+ private encryptHistoryFlag;
255
+ private clearHistoryFlag;
118
256
  private readonly logLevel;
119
257
  private readonly onRenderCallback?;
258
+ /**
259
+ * Creates a deferred prop that will be loaded after the initial render.
260
+ *
261
+ * @param factory - Function that resolves to the prop value.
262
+ * @param group - Optional group name for organizing deferred props.
263
+ * @returns A deferred prop definition.
264
+ *
265
+ * @example
266
+ * ```typescript
267
+ * props: {
268
+ * user: { id: 1 },
269
+ * stats: InertiaService.defer(() => fetchStats())
270
+ * }
271
+ * ```
272
+ */
273
+ static defer<T = unknown>(factory: () => T | Promise<T>, group?: string): DeferredPropDefinition<T>;
274
+ /**
275
+ * Marks a prop to be merged (shallow) with existing data during partial reloads.
276
+ *
277
+ * @param value - The prop value to merge.
278
+ * @param matchOn - Optional key(s) to match on when merging arrays.
279
+ * @returns A merge prop definition.
280
+ */
281
+ static merge<T = unknown>(value: T, matchOn?: string | string[]): MergedPropDefinition<T>;
282
+ /**
283
+ * Marks a prop to prepend to an array during partial reloads.
284
+ *
285
+ * @param value - The prop value to prepend.
286
+ * @returns A prepend prop definition.
287
+ */
288
+ static prepend<T = unknown>(value: T): MergedPropDefinition<T>;
289
+ /**
290
+ * Marks a prop to be deep-merged with existing data during partial reloads.
291
+ *
292
+ * @param value - The prop value to deep merge.
293
+ * @returns A deep merge prop definition.
294
+ */
295
+ static deepMerge<T = unknown>(value: T): MergedPropDefinition<T>;
120
296
  /**
121
297
  * Initializes a new instance of the Inertia service.
122
298
  *
@@ -230,6 +406,77 @@ declare class InertiaService {
230
406
  * ```
231
407
  */
232
408
  getSharedProps(): Record<string, unknown>;
409
+ /**
410
+ * Instructs the Inertia client to navigate to a different URL.
411
+ *
412
+ * For Inertia AJAX requests, this returns a 409 Conflict with the `X-Inertia-Location` header.
413
+ * For regular page loads, this returns a 302 Found redirect.
414
+ *
415
+ * This is useful for server-side redirects triggered by authentication or authorization checks.
416
+ *
417
+ * @param url - The URL to redirect to.
418
+ * @returns A redirect response.
419
+ *
420
+ * @example
421
+ * ```typescript
422
+ * if (!ctx.get('user')) {
423
+ * return inertia.location('/login');
424
+ * }
425
+ * ```
426
+ */
427
+ location(url: string): Response;
428
+ /**
429
+ * Controls whether the Inertia client should encrypt browser history.
430
+ *
431
+ * When enabled, history is not written to the browser's History API,
432
+ * preventing users from using the browser back button to return to previous pages.
433
+ *
434
+ * @param encrypt - Whether to encrypt history (defaults to true).
435
+ * @returns The service instance for method chaining.
436
+ *
437
+ * @example
438
+ * ```typescript
439
+ * return await inertia.encryptHistory(true).render('SecurePage');
440
+ * ```
441
+ */
442
+ encryptHistory(encrypt?: boolean): this;
443
+ /**
444
+ * Clears the browser history after the page load.
445
+ *
446
+ * Useful for sensitive operations or multi-step wizards where you don't want
447
+ * users navigating back to previous states.
448
+ *
449
+ * @returns The service instance for method chaining.
450
+ *
451
+ * @example
452
+ * ```typescript
453
+ * return await inertia.clearHistory().render('SuccessPage');
454
+ * ```
455
+ */
456
+ clearHistory(): this;
457
+ /**
458
+ * Registers form validation errors organized into named bags.
459
+ *
460
+ * Error bags allow multiple validation failure scenarios to coexist.
461
+ * For example, you might have 'default' errors and 'import' errors from different forms.
462
+ *
463
+ * @param errors - Validation errors, with field names as keys and error messages as values.
464
+ * @param bag - The error bag name (defaults to 'default').
465
+ * @returns The service instance for method chaining.
466
+ *
467
+ * @example
468
+ * ```typescript
469
+ * inertia.withErrors({
470
+ * email: 'Email is required',
471
+ * password: 'Must be 8+ characters'
472
+ * }, 'login');
473
+ *
474
+ * inertia.withErrors({
475
+ * line_1: 'Invalid CSV format'
476
+ * }, 'import');
477
+ * ```
478
+ */
479
+ withErrors(errors: Record<string, string | string[]>, bag?: string): this;
233
480
  }
234
481
 
235
482
  /**
@@ -347,6 +594,34 @@ interface InertiaHelper {
347
594
  * Thrown if the rendering lifecycle encounters a fatal error.
348
595
  */
349
596
  render<T extends Record<string, unknown> = Record<string, unknown>>(component: string, props?: T, rootVars?: Record<string, unknown>, status?: number): Promise<Response>;
597
+ /**
598
+ * Instructs the client to navigate to a different URL.
599
+ *
600
+ * @param url - The URL to navigate to.
601
+ * @returns A redirect response.
602
+ */
603
+ location(url: string): Response;
604
+ /**
605
+ * Encrypts the browser history to prevent navigation via back button.
606
+ *
607
+ * @param encrypt - Whether to enable history encryption (defaults to true).
608
+ * @returns The helper for method chaining.
609
+ */
610
+ encryptHistory(encrypt?: boolean): InertiaHelper;
611
+ /**
612
+ * Clears the browser history after page load.
613
+ *
614
+ * @returns The helper for method chaining.
615
+ */
616
+ clearHistory(): InertiaHelper;
617
+ /**
618
+ * Registers form validation errors organized by bag name.
619
+ *
620
+ * @param errors - Error map with field names as keys.
621
+ * @param bag - The error bag name (defaults to 'default').
622
+ * @returns The helper for method chaining.
623
+ */
624
+ withErrors(errors: Record<string, string | string[]>, bag?: string): InertiaHelper;
350
625
  /**
351
626
  * Direct access to the low-level `InertiaService` instance.
352
627
  *
@@ -394,6 +669,19 @@ interface OrbitIonOptions {
394
669
  body: string;
395
670
  }>;
396
671
  };
672
+ /**
673
+ * CSRF protection configuration.
674
+ *
675
+ * Automatically sets the XSRF-TOKEN cookie for CSRF protection.
676
+ *
677
+ * @defaultValue { enabled: true, cookieName: 'XSRF-TOKEN' }
678
+ */
679
+ csrf?: {
680
+ /** Whether CSRF protection is enabled. */
681
+ enabled?: boolean;
682
+ /** Name of the CSRF token cookie (commonly read by Axios). */
683
+ cookieName?: string;
684
+ };
397
685
  }
398
686
  /**
399
687
  * OrbitIon provides official Inertia.js integration for Gravito.
@@ -445,4 +733,4 @@ declare class OrbitIon implements GravitoOrbit {
445
733
  install(core: PlanetCore): void;
446
734
  }
447
735
 
448
- export { type InertiaConfig, InertiaConfigError, InertiaDataError, InertiaError, type InertiaHelper, InertiaService, InertiaTemplateError, OrbitIon, type OrbitIonOptions, type RenderMetrics, OrbitIon as default };
736
+ export { type DeferredPropDefinition, type ErrorBagDefinition, type InertiaConfig, InertiaConfigError, InertiaDataError, InertiaError, type InertiaHelper, type InertiaPageObject, InertiaService, InertiaTemplateError, type MergedPropDefinition, OrbitIon, type OrbitIonOptions, type PartialReloadMetadata, type RenderMetrics, OrbitIon as default };