@gravito/impulse-bridge 1.0.1 → 1.0.2
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.cjs +9 -3
- package/dist/index.d.cts +21 -6
- package/dist/index.d.ts +21 -6
- package/dist/index.js +9 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -26,13 +26,19 @@ __export(index_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
var ImpulseBridge = {
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Serializes a FormRequest class and shares its blueprint with the frontend.
|
|
30
|
+
*
|
|
31
|
+
* @param ctx - The Gravito request context.
|
|
32
|
+
* @param key - The unique identifier for this form blueprint on the frontend.
|
|
33
|
+
* @param RequestClass - The FormRequest class (not instance) to share.
|
|
30
34
|
*
|
|
31
35
|
* @example
|
|
36
|
+
* ```typescript
|
|
32
37
|
* async show(ctx: Context) {
|
|
33
|
-
* ImpulseBridge.share(ctx, '
|
|
34
|
-
* return ctx.inertia('
|
|
38
|
+
* ImpulseBridge.share(ctx, 'register', RegistrationRequest);
|
|
39
|
+
* return ctx.inertia('Auth/Register');
|
|
35
40
|
* }
|
|
41
|
+
* ```
|
|
36
42
|
*/
|
|
37
43
|
share(ctx, key, RequestClass) {
|
|
38
44
|
const request = new RequestClass();
|
package/dist/index.d.cts
CHANGED
|
@@ -2,24 +2,39 @@ import { GravitoContext } from '@gravito/core';
|
|
|
2
2
|
import { FormRequest } from '@gravito/impulse';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* ImpulseBridge facilitates the synchronization of backend validation rules
|
|
6
|
+
* and form blueprints with frontend frameworks (primarily via Inertia.js).
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
+
* It allows you to "share" a FormRequest structure so that frontend
|
|
9
|
+
* components can automatically perform client-side validation using the
|
|
10
|
+
* same rules defined on the server.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
8
13
|
*/
|
|
9
14
|
declare const ImpulseBridge: {
|
|
10
15
|
/**
|
|
11
|
-
*
|
|
16
|
+
* Serializes a FormRequest class and shares its blueprint with the frontend.
|
|
17
|
+
*
|
|
18
|
+
* @param ctx - The Gravito request context.
|
|
19
|
+
* @param key - The unique identifier for this form blueprint on the frontend.
|
|
20
|
+
* @param RequestClass - The FormRequest class (not instance) to share.
|
|
12
21
|
*
|
|
13
22
|
* @example
|
|
23
|
+
* ```typescript
|
|
14
24
|
* async show(ctx: Context) {
|
|
15
|
-
* ImpulseBridge.share(ctx, '
|
|
16
|
-
* return ctx.inertia('
|
|
25
|
+
* ImpulseBridge.share(ctx, 'register', RegistrationRequest);
|
|
26
|
+
* return ctx.inertia('Auth/Register');
|
|
17
27
|
* }
|
|
28
|
+
* ```
|
|
18
29
|
*/
|
|
19
30
|
share(ctx: GravitoContext, key: string, RequestClass: new () => FormRequest): void;
|
|
20
31
|
};
|
|
21
32
|
/**
|
|
22
|
-
*
|
|
33
|
+
* Middleware that automatically shares a set of FormRequest blueprints
|
|
34
|
+
* with every request matched by the router.
|
|
35
|
+
*
|
|
36
|
+
* @param blueprints - A map of key-to-FormRequestClass pairs.
|
|
37
|
+
* @public
|
|
23
38
|
*/
|
|
24
39
|
declare function impulseBridgeMiddleware(blueprints: Record<string, new () => FormRequest>): (ctx: GravitoContext, next: () => Promise<Response | undefined>) => Promise<Response | undefined>;
|
|
25
40
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,24 +2,39 @@ import { GravitoContext } from '@gravito/core';
|
|
|
2
2
|
import { FormRequest } from '@gravito/impulse';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* ImpulseBridge facilitates the synchronization of backend validation rules
|
|
6
|
+
* and form blueprints with frontend frameworks (primarily via Inertia.js).
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
+
* It allows you to "share" a FormRequest structure so that frontend
|
|
9
|
+
* components can automatically perform client-side validation using the
|
|
10
|
+
* same rules defined on the server.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
8
13
|
*/
|
|
9
14
|
declare const ImpulseBridge: {
|
|
10
15
|
/**
|
|
11
|
-
*
|
|
16
|
+
* Serializes a FormRequest class and shares its blueprint with the frontend.
|
|
17
|
+
*
|
|
18
|
+
* @param ctx - The Gravito request context.
|
|
19
|
+
* @param key - The unique identifier for this form blueprint on the frontend.
|
|
20
|
+
* @param RequestClass - The FormRequest class (not instance) to share.
|
|
12
21
|
*
|
|
13
22
|
* @example
|
|
23
|
+
* ```typescript
|
|
14
24
|
* async show(ctx: Context) {
|
|
15
|
-
* ImpulseBridge.share(ctx, '
|
|
16
|
-
* return ctx.inertia('
|
|
25
|
+
* ImpulseBridge.share(ctx, 'register', RegistrationRequest);
|
|
26
|
+
* return ctx.inertia('Auth/Register');
|
|
17
27
|
* }
|
|
28
|
+
* ```
|
|
18
29
|
*/
|
|
19
30
|
share(ctx: GravitoContext, key: string, RequestClass: new () => FormRequest): void;
|
|
20
31
|
};
|
|
21
32
|
/**
|
|
22
|
-
*
|
|
33
|
+
* Middleware that automatically shares a set of FormRequest blueprints
|
|
34
|
+
* with every request matched by the router.
|
|
35
|
+
*
|
|
36
|
+
* @param blueprints - A map of key-to-FormRequestClass pairs.
|
|
37
|
+
* @public
|
|
23
38
|
*/
|
|
24
39
|
declare function impulseBridgeMiddleware(blueprints: Record<string, new () => FormRequest>): (ctx: GravitoContext, next: () => Promise<Response | undefined>) => Promise<Response | undefined>;
|
|
25
40
|
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
var ImpulseBridge = {
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Serializes a FormRequest class and shares its blueprint with the frontend.
|
|
5
|
+
*
|
|
6
|
+
* @param ctx - The Gravito request context.
|
|
7
|
+
* @param key - The unique identifier for this form blueprint on the frontend.
|
|
8
|
+
* @param RequestClass - The FormRequest class (not instance) to share.
|
|
5
9
|
*
|
|
6
10
|
* @example
|
|
11
|
+
* ```typescript
|
|
7
12
|
* async show(ctx: Context) {
|
|
8
|
-
* ImpulseBridge.share(ctx, '
|
|
9
|
-
* return ctx.inertia('
|
|
13
|
+
* ImpulseBridge.share(ctx, 'register', RegistrationRequest);
|
|
14
|
+
* return ctx.inertia('Auth/Register');
|
|
10
15
|
* }
|
|
16
|
+
* ```
|
|
11
17
|
*/
|
|
12
18
|
share(ctx, key, RequestClass) {
|
|
13
19
|
const request = new RequestClass();
|