@adonisjs/inertia 3.1.1 → 4.0.0-next.1
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/README.md +8 -5
- package/build/bin/test.d.ts +1 -0
- package/build/chunk-4EZ2J6OA.js +7 -0
- package/build/chunk-74S2VAL7.js +761 -0
- package/build/chunk-DISC5OYC.js +46 -0
- package/build/chunk-MLKGABMK.js +9 -0
- package/build/chunk-PDP56GPP.js +75 -0
- package/build/factories/inertia_factory.d.ts +137 -0
- package/build/factories/main.d.ts +1 -0
- package/build/factories/main.js +175 -0
- package/build/index.d.ts +7 -19
- package/build/index.js +21 -307
- package/build/providers/inertia_provider.d.ts +86 -13
- package/build/providers/inertia_provider.js +48 -18
- package/build/src/client/vite.d.ts +63 -0
- package/build/src/{plugins → client}/vite.js +9 -13
- package/build/src/debug.d.ts +22 -0
- package/build/src/define_config.d.ts +29 -0
- package/build/src/headers.d.ts +61 -0
- package/build/src/index_pages.d.ts +5 -0
- package/build/src/inertia.d.ts +253 -0
- package/build/src/inertia_manager.d.ts +46 -0
- package/build/src/inertia_middleware.d.ts +74 -87
- package/build/src/inertia_middleware.js +110 -3
- package/build/src/plugins/edge/plugin.d.ts +30 -6
- package/build/src/plugins/edge/plugin.js +13 -9
- package/build/src/plugins/edge/tags.d.ts +47 -0
- package/build/src/plugins/edge/utils.d.ts +26 -0
- package/build/src/plugins/japa/api_client.d.ts +136 -22
- package/build/src/plugins/japa/api_client.js +36 -48
- package/build/src/props.d.ts +269 -0
- package/build/src/server_renderer.d.ts +54 -0
- package/build/src/symbols.d.ts +25 -0
- package/build/src/types.d.ts +404 -4
- package/build/tests/helpers.d.ts +35 -0
- package/build/tests/index_pages.spec.d.ts +1 -0
- package/build/tests/inertia.spec.d.ts +1 -0
- package/build/tests/inertia_page.spec.d.ts +1 -0
- package/build/tests/middleware.spec.d.ts +1 -0
- package/build/tests/plugins/api_client.spec.d.ts +1 -0
- package/build/tests/plugins/edge.plugin.spec.d.ts +1 -0
- package/build/tests/provider.spec.d.ts +1 -0
- package/build/tests/types/shared_props.spec.d.ts +1 -0
- package/build/tests/types/to_component_props.spec.d.ts +1 -0
- package/build/tests/types/to_page_props.spec.d.ts +1 -0
- package/package.json +88 -71
- package/build/app.css.stub +0 -13
- package/build/chunk-W7TVEB4V.js +0 -412
- package/build/config.stub +0 -33
- package/build/react/app.tsx.stub +0 -38
- package/build/react/errors/not_found.tsx.stub +0 -14
- package/build/react/errors/server_error.tsx.stub +0 -14
- package/build/react/home.tsx.stub +0 -349
- package/build/react/root.edge.stub +0 -76
- package/build/react/ssr.tsx.stub +0 -17
- package/build/react/tsconfig.json.stub +0 -15
- package/build/solid/app.tsx.stub +0 -38
- package/build/solid/errors/not_found.tsx.stub +0 -14
- package/build/solid/errors/server_error.tsx.stub +0 -14
- package/build/solid/home.tsx.stub +0 -358
- package/build/solid/root.edge.stub +0 -73
- package/build/solid/ssr.tsx.stub +0 -19
- package/build/solid/tsconfig.json.stub +0 -16
- package/build/src/helpers.d.ts +0 -12
- package/build/src/helpers.js +0 -14
- package/build/src/plugins/vite.d.ts +0 -26
- package/build/svelte/app.ts.stub +0 -32
- package/build/svelte/errors/not_found.svelte.stub +0 -10
- package/build/svelte/errors/server_error.svelte.stub +0 -14
- package/build/svelte/home.svelte.stub +0 -339
- package/build/svelte/root.edge.stub +0 -75
- package/build/svelte/ssr.ts.stub +0 -19
- package/build/svelte/tsconfig.json.stub +0 -14
- package/build/types-DVqEHBD1.d.ts +0 -240
- package/build/vue/app.ts.stub +0 -41
- package/build/vue/errors/not_found.vue.stub +0 -10
- package/build/vue/errors/server_error.vue.stub +0 -14
- package/build/vue/home.vue.stub +0 -343
- package/build/vue/root.edge.stub +0 -75
- package/build/vue/ssr.ts.stub +0 -22
- package/build/vue/tsconfig.json.stub +0 -16
package/build/src/types.d.ts
CHANGED
|
@@ -1,4 +1,404 @@
|
|
|
1
|
-
import '@adonisjs/core/
|
|
2
|
-
import '@adonisjs/core/
|
|
3
|
-
import '@
|
|
4
|
-
|
|
1
|
+
import type { HttpContext } from '@adonisjs/core/http';
|
|
2
|
+
import { type ContainerResolver } from '@adonisjs/core/container';
|
|
3
|
+
import type { JSONDataTypes } from '@adonisjs/core/types/transformers';
|
|
4
|
+
import type { AsyncOrSync, DeepPartial, Prettify } from '@poppinss/utils/types';
|
|
5
|
+
import { type DEEP_MERGE, type ALWAYS_PROP, type OPTIONAL_PROP, type TO_BE_MERGED, type DEFERRED_PROP } from './symbols.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Representation of a resource item, collection and paginator that can be serialized
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type that the serializable object resolves to
|
|
10
|
+
*/
|
|
11
|
+
export type SerializableOf<T> = {
|
|
12
|
+
/**
|
|
13
|
+
* Serializes the object using the container resolver
|
|
14
|
+
*
|
|
15
|
+
* @param container - The container resolver instance
|
|
16
|
+
* @param depth - Current serialization depth
|
|
17
|
+
* @param maxDepth - Maximum allowed serialization depth
|
|
18
|
+
* @returns Promise that resolves to the serialized object
|
|
19
|
+
*/
|
|
20
|
+
serialize(container: ContainerResolver<any>, depth: number, maxDepth?: number): Promise<T>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Union type representing unpacked page prop values that can be either JSON data or serializable objects
|
|
24
|
+
*
|
|
25
|
+
* @template T - The JSON data type, defaults to JSONDataTypes
|
|
26
|
+
*/
|
|
27
|
+
export type UnPackedPageProps<T extends JSONDataTypes = JSONDataTypes> = T | SerializableOf<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Utility type that extracts the resolved type from a SerializableOf wrapper
|
|
30
|
+
* If the type is already unwrapped, returns it as-is
|
|
31
|
+
*
|
|
32
|
+
* @template T - The type to unwrap, potentially wrapped in SerializableOf
|
|
33
|
+
*/
|
|
34
|
+
export type UnpackProp<T> = T extends SerializableOf<infer A> ? A : T;
|
|
35
|
+
/**
|
|
36
|
+
* Information extracted from Inertia request headers
|
|
37
|
+
* Contains metadata about the current request type and filtering preferences
|
|
38
|
+
*/
|
|
39
|
+
export type RequestInfo = {
|
|
40
|
+
/** Asset version sent by the client for cache busting */
|
|
41
|
+
version?: string;
|
|
42
|
+
/** Whether this is an Inertia AJAX request */
|
|
43
|
+
isInertiaRequest: boolean;
|
|
44
|
+
/** Whether this is a partial data request */
|
|
45
|
+
isPartialRequest: boolean;
|
|
46
|
+
/** Component name for partial reloads */
|
|
47
|
+
partialComponent?: string;
|
|
48
|
+
/** Props to include in partial requests */
|
|
49
|
+
onlyProps?: string[];
|
|
50
|
+
/** Props to exclude in partial requests */
|
|
51
|
+
exceptProps?: string[];
|
|
52
|
+
/** Props to reset during merging */
|
|
53
|
+
resetProps?: string[];
|
|
54
|
+
/** Error bag identifier for validation errors */
|
|
55
|
+
errorBag?: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Represents a prop that is always included in responses and cannot be removed during cherry-picking
|
|
59
|
+
*
|
|
60
|
+
* @template T - The type of the prop value
|
|
61
|
+
*/
|
|
62
|
+
export type AlwaysProp<T extends UnPackedPageProps> = {
|
|
63
|
+
/** The actual value of the prop */
|
|
64
|
+
value: T;
|
|
65
|
+
/** Brand symbol to identify this as an always prop */
|
|
66
|
+
[ALWAYS_PROP]: true;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Represents a prop that is never included in standard visits but can be explicitly requested
|
|
70
|
+
* The prop value is computed lazily when requested
|
|
71
|
+
*
|
|
72
|
+
* @template T - The type of the computed prop value
|
|
73
|
+
*/
|
|
74
|
+
export type OptionalProp<T extends UnPackedPageProps> = {
|
|
75
|
+
/** Function that computes the prop value when requested */
|
|
76
|
+
compute: () => AsyncOrSync<T>;
|
|
77
|
+
/** Brand symbol to identify this as an optional prop */
|
|
78
|
+
[OPTIONAL_PROP]: true;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Represents a deferred prop that is never included in standard visits but must be shared with
|
|
82
|
+
* the client during standard visits. Can be explicitly requested and supports merging
|
|
83
|
+
*
|
|
84
|
+
* @template T - The type of the computed prop value
|
|
85
|
+
*/
|
|
86
|
+
export type DeferProp<T extends UnPackedPageProps> = {
|
|
87
|
+
group: string;
|
|
88
|
+
/** Function that computes the prop value when requested */
|
|
89
|
+
compute: () => AsyncOrSync<T>;
|
|
90
|
+
/** Creates a mergeable version of this deferred prop */
|
|
91
|
+
merge(): MergeableProp<DeferProp<T>>;
|
|
92
|
+
/** Brand symbol to identify this as a deferred prop */
|
|
93
|
+
[DEFERRED_PROP]: true;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Represents a prop that should be merged with existing props on the page rather than replaced
|
|
97
|
+
*
|
|
98
|
+
* @template T - The type of the prop value to be merged
|
|
99
|
+
*/
|
|
100
|
+
export type MergeableProp<T extends UnPackedPageProps | DeferProp<UnPackedPageProps>> = {
|
|
101
|
+
/** The prop value to be merged */
|
|
102
|
+
value: T;
|
|
103
|
+
/** Brand symbol to identify this prop for merging */
|
|
104
|
+
[TO_BE_MERGED]: true;
|
|
105
|
+
[DEEP_MERGE]: boolean;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Lazy props are never included during standard Inertia visits
|
|
109
|
+
* These props must be explicitly requested by the client
|
|
110
|
+
*
|
|
111
|
+
* @template T - The data type of the prop value
|
|
112
|
+
*/
|
|
113
|
+
type PagePropsLazyDataTypes<T extends JSONDataTypes> =
|
|
114
|
+
/**
|
|
115
|
+
* - Never included on standard visit
|
|
116
|
+
* - Must be shared with the client during standard visit
|
|
117
|
+
* - Can be explicitly requested for
|
|
118
|
+
* - Can be dropped during cherry-picking
|
|
119
|
+
*/
|
|
120
|
+
DeferProp<T | SerializableOf<T>>
|
|
121
|
+
/**
|
|
122
|
+
* - Never included on standard visit
|
|
123
|
+
* - Can be explicitly requested for
|
|
124
|
+
* - Can be dropped during cherry-picking
|
|
125
|
+
*/
|
|
126
|
+
| OptionalProp<T | SerializableOf<T>>;
|
|
127
|
+
/**
|
|
128
|
+
* Eager props are always included during standard Inertia visits, but
|
|
129
|
+
* can be removed via cherry-picking when only specific props are requested
|
|
130
|
+
*
|
|
131
|
+
* @template T - The data type of the prop value
|
|
132
|
+
*/
|
|
133
|
+
type PagePropsEagerDataTypes<T extends JSONDataTypes> =
|
|
134
|
+
/**
|
|
135
|
+
* - Always included on standard visit.
|
|
136
|
+
* - Can be dropped during cherry-picking
|
|
137
|
+
*/
|
|
138
|
+
T
|
|
139
|
+
/**
|
|
140
|
+
* - Always included on standard visit.
|
|
141
|
+
* - Can be dropped during cherry-picking
|
|
142
|
+
*/
|
|
143
|
+
| SerializableOf<T>
|
|
144
|
+
/**
|
|
145
|
+
* - Always included on standard visit.
|
|
146
|
+
* - Can be dropped during cherry-picking
|
|
147
|
+
*/
|
|
148
|
+
| (() => AsyncOrSync<T | SerializableOf<T>>)
|
|
149
|
+
/**
|
|
150
|
+
* - Always included on standard visit
|
|
151
|
+
* - Cannot be dropped during cherry-picking
|
|
152
|
+
*/
|
|
153
|
+
| AlwaysProp<T | SerializableOf<T>>;
|
|
154
|
+
/**
|
|
155
|
+
* Following is the list of acceptable Page props data types
|
|
156
|
+
* Combines both eager and lazy prop data types for comprehensive prop handling
|
|
157
|
+
*
|
|
158
|
+
* @template T - The data type extending JSONDataTypes, defaults to JSONDataTypes
|
|
159
|
+
*/
|
|
160
|
+
export type PagePropsDataTypes<T extends JSONDataTypes = JSONDataTypes> = PagePropsEagerDataTypes<T> | PagePropsLazyDataTypes<T>;
|
|
161
|
+
/**
|
|
162
|
+
* Record type representing all page props that can be passed to an Inertia page
|
|
163
|
+
* Maps prop names to their corresponding data types, including branded types for special behavior
|
|
164
|
+
*/
|
|
165
|
+
export type PageProps = Record<string, PagePropsDataTypes | MergeableProp<UnPackedPageProps | DeferProp<UnPackedPageProps>>>;
|
|
166
|
+
/**
|
|
167
|
+
* Record type representing component props as they appear on the frontend after serialization
|
|
168
|
+
* Maps prop names to JSON-serializable values that components can consume directly
|
|
169
|
+
*/
|
|
170
|
+
export type ComponentProps = Record<string, JSONDataTypes>;
|
|
171
|
+
/**
|
|
172
|
+
* Utility type to extract optional and deferred prop keys from a props object
|
|
173
|
+
* Identifies props that are not required and may not be present in the component
|
|
174
|
+
*
|
|
175
|
+
* @template Props - The page props object type to analyze
|
|
176
|
+
*/
|
|
177
|
+
export type GetOptionalProps<Props> = {
|
|
178
|
+
[K in keyof Props]: Props[K] extends OptionalProp<any> ? K : Props[K] extends DeferProp<any> ? K : [undefined] extends Props[K] ? K : Props[K] extends MergeableProp<infer A> ? A extends DeferProp<any> ? K : never : never;
|
|
179
|
+
}[keyof Props];
|
|
180
|
+
/**
|
|
181
|
+
* Utility type to extract required prop keys from a props object
|
|
182
|
+
* Identifies props that are always present and required by the component
|
|
183
|
+
*
|
|
184
|
+
* @template Props - The page props object type to analyze
|
|
185
|
+
*/
|
|
186
|
+
export type GetRequiredProps<Props> = {
|
|
187
|
+
[K in keyof Props]: Props[K] extends OptionalProp<any> ? never : Props[K] extends DeferProp<any> ? never : [undefined] extends Props[K] ? never : Props[K] extends MergeableProp<infer A> ? A extends DeferProp<any> ? never : K : K;
|
|
188
|
+
}[keyof Props];
|
|
189
|
+
/**
|
|
190
|
+
* Utility type to simplify value of a required prop by unwrapping branded types
|
|
191
|
+
* Extracts the actual value type from wrapped prop types like AlwaysProp, functions, etc.
|
|
192
|
+
*
|
|
193
|
+
* @template Value - The prop value type to unwrap
|
|
194
|
+
*/
|
|
195
|
+
export type GetRequiredPropValue<Value> = Value extends AlwaysProp<infer A> ? UnpackProp<A> : Value extends MergeableProp<infer B> ? UnpackProp<B> : Value extends () => AsyncOrSync<infer C> ? UnpackProp<C> : UnpackProp<Value>;
|
|
196
|
+
/**
|
|
197
|
+
* Utility type to simplify value of an optional prop by unwrapping branded types
|
|
198
|
+
* Extracts the actual value type from wrapped optional prop types like DeferProp, OptionalProp, etc.
|
|
199
|
+
*
|
|
200
|
+
* @template Value - The optional prop value type to unwrap
|
|
201
|
+
*/
|
|
202
|
+
export type GetOptionalPropValue<Value> = Value extends DeferProp<infer A> ? UnpackProp<A> : Value extends MergeableProp<infer B> ? B extends DeferProp<infer BA> ? UnpackProp<BA> : UnpackProp<B> : Value extends OptionalProp<infer C> ? UnpackProp<C> : Value extends () => AsyncOrSync<infer D> ? UnpackProp<D> : UnpackProp<Value>;
|
|
203
|
+
/**
|
|
204
|
+
* Converts the Page props to Component props that will be available to the frontend
|
|
205
|
+
* app after serialization. Maps server-side prop definitions to client-side prop types
|
|
206
|
+
*
|
|
207
|
+
* @template Props - The page props object with branded prop types
|
|
208
|
+
*/
|
|
209
|
+
export type ToComponentProps<Props extends PageProps> = Prettify<{
|
|
210
|
+
[K in GetRequiredProps<Props>]: GetRequiredPropValue<Props[K]>;
|
|
211
|
+
} & {
|
|
212
|
+
[K in GetOptionalProps<Props>]?: GetOptionalPropValue<Props[K]>;
|
|
213
|
+
}>;
|
|
214
|
+
/**
|
|
215
|
+
* Converts the Component props to Page props to allow computing the same values
|
|
216
|
+
* via branded types and lazy evaluated callbacks and promises
|
|
217
|
+
* Maps client-side prop types back to server-side prop definitions
|
|
218
|
+
*
|
|
219
|
+
* @template Props - The component props object with JSON data types
|
|
220
|
+
*/
|
|
221
|
+
export type AsPageProps<Props extends ComponentProps> = Prettify<{
|
|
222
|
+
[K in {
|
|
223
|
+
[O in keyof Props]: [undefined] extends [Props[O]] ? O : never;
|
|
224
|
+
}[keyof Props]]?: PagePropsDataTypes<Props[K]> | MergeableProp<UnPackedPageProps<Props[K]> | DeferProp<UnPackedPageProps<Props[K]>>>;
|
|
225
|
+
} & {
|
|
226
|
+
[K in {
|
|
227
|
+
[O in keyof Props]: [undefined] extends [Props[O]] ? never : O;
|
|
228
|
+
}[keyof Props]]: PagePropsEagerDataTypes<Props[K]> | MergeableProp<UnPackedPageProps<Props[K]>>;
|
|
229
|
+
}>;
|
|
230
|
+
/**
|
|
231
|
+
* Allowed values for the assets version used for cache busting
|
|
232
|
+
* Can be a string, number, or undefined for auto-detection
|
|
233
|
+
*/
|
|
234
|
+
export type AssetsVersion = string | number | undefined;
|
|
235
|
+
/**
|
|
236
|
+
* Resolved configuration returned by the `defineConfig` helper
|
|
237
|
+
* Contains all settings needed to configure Inertia.js integration
|
|
238
|
+
*/
|
|
239
|
+
export type InertiaConfig = {
|
|
240
|
+
/**
|
|
241
|
+
* Root Edge template to use for rendering the shell for the inertia
|
|
242
|
+
* application
|
|
243
|
+
*/
|
|
244
|
+
rootView: string | ((ctx: HttpContext) => string);
|
|
245
|
+
/**
|
|
246
|
+
* The entrypoint file to load in order to boot the frontend application.
|
|
247
|
+
*/
|
|
248
|
+
entrypoint: string;
|
|
249
|
+
/**
|
|
250
|
+
* A fixed asset version value to use. Otherwise, it will be read from the
|
|
251
|
+
* Vite manifest file.
|
|
252
|
+
*/
|
|
253
|
+
assetsVersion?: AssetsVersion;
|
|
254
|
+
/**
|
|
255
|
+
* History encryption settings. https://inertiajs.com/history-encryption
|
|
256
|
+
*/
|
|
257
|
+
encryptHistory: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Configuration settings for server-side rendering of the frontend
|
|
260
|
+
* app
|
|
261
|
+
*/
|
|
262
|
+
ssr: {
|
|
263
|
+
/**
|
|
264
|
+
* Enable/disable the SSR. Disabled by default
|
|
265
|
+
*/
|
|
266
|
+
enabled: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Cherry pick the pages you want to render server side
|
|
269
|
+
*/
|
|
270
|
+
pages?: string[] | ((ctx: HttpContext, page: string) => AsyncOrSync<boolean>);
|
|
271
|
+
/**
|
|
272
|
+
* The entrypoint file to load in order to boot the frontend application on
|
|
273
|
+
* the server
|
|
274
|
+
*/
|
|
275
|
+
entrypoint: string;
|
|
276
|
+
/**
|
|
277
|
+
* The SSR bundle output to load during production. This bundle is created
|
|
278
|
+
* using Vite
|
|
279
|
+
*/
|
|
280
|
+
bundle: string;
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* Input configuration type allowing partial configuration objects
|
|
285
|
+
* Used when defining configuration where all properties are optional and can be deeply partial
|
|
286
|
+
*/
|
|
287
|
+
export type InertiaConfigInput = DeepPartial<InertiaConfig>;
|
|
288
|
+
/**
|
|
289
|
+
* Represents a page object that is passed between server and client
|
|
290
|
+
*
|
|
291
|
+
* @template Props - The props type for the page component
|
|
292
|
+
*/
|
|
293
|
+
export type PageObject<Props extends PageProps = PageProps> = {
|
|
294
|
+
/**
|
|
295
|
+
* The name/path of the component to render
|
|
296
|
+
*/
|
|
297
|
+
component: string;
|
|
298
|
+
/**
|
|
299
|
+
* Version identifier sent to the client with every request. Inertia
|
|
300
|
+
* will trigger a full page refresh (in case of version mis-match)
|
|
301
|
+
*/
|
|
302
|
+
version: string | number;
|
|
303
|
+
/**
|
|
304
|
+
* Props data to pass to the component. These should be JSON values
|
|
305
|
+
*/
|
|
306
|
+
props: Props;
|
|
307
|
+
/**
|
|
308
|
+
* Current URL of the page
|
|
309
|
+
*/
|
|
310
|
+
url: string;
|
|
311
|
+
/**
|
|
312
|
+
* Grouped deferred props that can be loaded after the initial page
|
|
313
|
+
* load
|
|
314
|
+
*/
|
|
315
|
+
deferredProps?: {
|
|
316
|
+
[group: string]: string[];
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* An array with the keys of props that should be merged with the
|
|
320
|
+
* existing props on the page
|
|
321
|
+
*/
|
|
322
|
+
mergeProps?: string[];
|
|
323
|
+
/**
|
|
324
|
+
* An array with the keys of props that should be deeply merged with the
|
|
325
|
+
* existing props on the page
|
|
326
|
+
*/
|
|
327
|
+
deepMergeProps?: string[];
|
|
328
|
+
/**
|
|
329
|
+
* Encrypt history flag to be sent to the client with every request.
|
|
330
|
+
*/
|
|
331
|
+
encryptHistory?: boolean;
|
|
332
|
+
/**
|
|
333
|
+
* Optionally clear the browser history
|
|
334
|
+
*/
|
|
335
|
+
clearHistory?: boolean;
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* The shared props inferred from the user-land
|
|
339
|
+
* Should be augmented in the host application to define globally available props
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* declare module '@adonisjs/inertia/types' {
|
|
344
|
+
* interface SharedProps {
|
|
345
|
+
* user: { id: number; name: string } | null
|
|
346
|
+
* flash: { success?: string; error?: string }
|
|
347
|
+
* }
|
|
348
|
+
* }
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
export interface SharedProps {
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Discovered known pages with their props
|
|
355
|
+
* Should be augmented in the host application to define page-specific prop types
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```typescript
|
|
359
|
+
* declare module '@adonisjs/inertia/types' {
|
|
360
|
+
* interface InertiaPages {
|
|
361
|
+
* 'users/index': { users: User[] }
|
|
362
|
+
* 'users/show': { user: User }
|
|
363
|
+
* }
|
|
364
|
+
* }
|
|
365
|
+
* ```
|
|
366
|
+
*/
|
|
367
|
+
export interface InertiaPages {
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Function signature for the SSR render method that should be exported
|
|
371
|
+
* from the SSR entrypoint file to render Inertia pages on the server
|
|
372
|
+
*
|
|
373
|
+
* @param page - The page object containing component and props data
|
|
374
|
+
* @returns Promise resolving to an object with head tags and body HTML
|
|
375
|
+
*/
|
|
376
|
+
export type RenderInertiaSsrApp = (page: PageObject) => Promise<{
|
|
377
|
+
head: string[];
|
|
378
|
+
body: string;
|
|
379
|
+
}>;
|
|
380
|
+
/**
|
|
381
|
+
* Type helper to infer the return type of InertiaMiddleware.share method
|
|
382
|
+
* and augment the SharedProps interface automatically
|
|
383
|
+
*
|
|
384
|
+
* @template T - The middleware class type that extends BaseInertiaMiddleware
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* ```typescript
|
|
388
|
+
* class InertiaMiddleware extends BaseInertiaMiddleware {
|
|
389
|
+
* async share() {
|
|
390
|
+
* return {
|
|
391
|
+
* user: { id: 1, name: 'John' },
|
|
392
|
+
* flash: { success: 'Welcome!' }
|
|
393
|
+
* }
|
|
394
|
+
* }
|
|
395
|
+
* }
|
|
396
|
+
*
|
|
397
|
+
* // Automatically infer and augment SharedProps
|
|
398
|
+
* type InferredSharedProps = InferSharedProps<InertiaMiddleware>
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
export type InferSharedProps<T> = T extends {
|
|
402
|
+
share(...args: any[]): infer R;
|
|
403
|
+
} ? Awaited<R> extends PageProps ? ToComponentProps<Awaited<R>> : never : never;
|
|
404
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type InlineConfig } from 'vite';
|
|
2
|
+
import type { Test } from '@japa/runner/core';
|
|
3
|
+
import { type ProviderNode } from '@adonisjs/core/types/app';
|
|
4
|
+
import { type ApplicationService } from '@adonisjs/core/types';
|
|
5
|
+
import { Vite } from '@adonisjs/vite';
|
|
6
|
+
import { type IncomingMessage, type ServerResponse } from 'node:http';
|
|
7
|
+
export declare const BASE_URL: import("url").URL;
|
|
8
|
+
/**
|
|
9
|
+
* Create a http server that will be closed automatically
|
|
10
|
+
* when the test ends
|
|
11
|
+
*/
|
|
12
|
+
export declare const httpServer: {
|
|
13
|
+
create: (callback: (req: IncomingMessage, res: ServerResponse) => any) => import("http").Server<typeof IncomingMessage, typeof ServerResponse>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Mock the `view` macro on HttpContext to return a fake
|
|
17
|
+
*/
|
|
18
|
+
export declare function setupViewMacroMock(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Runs a japa test in isolation
|
|
21
|
+
*/
|
|
22
|
+
export declare function runJapaTest(app: ApplicationService, callback: Parameters<Test['run']>[0]): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Spin up a Vite server for the test
|
|
25
|
+
*/
|
|
26
|
+
export declare const setupVite: (options: InlineConfig) => Promise<Vite>;
|
|
27
|
+
/**
|
|
28
|
+
* Setup an AdonisJS app for testing
|
|
29
|
+
*/
|
|
30
|
+
export declare function setupApp(providers?: ProviderNode[]): Promise<{
|
|
31
|
+
ace: import("@adonisjs/core/ace").Kernel;
|
|
32
|
+
app: ApplicationService;
|
|
33
|
+
ignitor: import("@adonisjs/core").Ignitor;
|
|
34
|
+
}>;
|
|
35
|
+
export declare const setupFakeAdonisProject: () => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|