@punica/form-mcp 0.1.0 → 0.2.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/bundled/form/controller/index.d.ts +43 -53
- package/bundled/form/decorator/Readers.d.ts +2 -2
- package/bundled/form/decorator/Services.d.ts +2 -2
- package/bundled/form/decorator/Starters.d.ts +2 -2
- package/bundled/form/define/FormItem.d.ts +12 -6
- package/bundled/form/define/FormItemProperty.d.ts +5 -5
- package/bundled/form/define/FormProperty.d.ts +5 -4
- package/bundled/form/define/decorator.d.ts +16 -0
- package/bundled/form/define/index.d.ts +1 -0
- package/bundled/form/index.d.ts +1 -0
- package/bundled/form/metadata/index.d.ts +20 -0
- package/bundled/form/model/command/item.d.ts +11 -5
- package/bundled/form/model/command/service.d.ts +19 -10
- package/bundled/form/model/constants/index.d.ts +13 -2
- package/bundled/form/model/form/index.d.ts +8 -4
- package/bundled/form/model/index.d.ts +0 -1
- package/bundled/form/model/item/index.d.ts +27 -12
- package/bundled/form/model/reader/index.d.ts +5 -1
- package/bundled/form/model/service/index.d.ts +28 -10
- package/bundled/form/package.json +1 -1
- package/bundled/form/reader/index.d.ts +8 -16
- package/bundled/form/register/index.d.ts +26 -39
- package/bundled/form/utils/deepCopy.d.ts +1 -1
- package/bundled/form/utils/devtools.d.ts +11 -70
- package/bundled/form/utils/index.d.ts +1 -1
- package/bundled/form-service/clearError/index.d.ts +4 -14
- package/bundled/form-service/clearErrors/index.d.ts +4 -16
- package/bundled/form-service/getValues/index.d.ts +5 -13
- package/bundled/form-service/index.d.ts +21 -0
- package/bundled/form-service/package.json +1 -1
- package/bundled/form-service/reset/index.d.ts +4 -13
- package/bundled/form-service/resetItem/index.d.ts +4 -14
- package/bundled/form-service/setValue/index.d.ts +7 -16
- package/bundled/form-service/store/index.d.ts +11 -23
- package/bundled/form-service/trigger/index.d.ts +4 -13
- package/bundled/form-service/validate/index.d.ts +4 -18
- package/bundled/form-service/validateItem.d.ts +7 -0
- package/package.json +3 -3
- package/src/create.mjs +4 -4
- package/src/guide.md +81 -57
- package/src/knowledge.mjs +2 -2
- package/src/validate.mjs +61 -48
- package/bundled/form/model/util/GetItem.d.ts +0 -9
- package/bundled/form/model/util/WriteItems.d.ts +0 -8
- package/bundled/form/model/util/index.d.ts +0 -2
- package/bundled/form/reader/decorators/base/index.d.ts +0 -35
- package/bundled/form/reader/decorators/readers/FormItemsReader.d.ts +0 -17
- package/bundled/form/reader/decorators/readers/ItemDataReader.d.ts +0 -24
- package/bundled/form/reader/decorators/readers/ItemInitializerReader.d.ts +0 -16
- package/bundled/form/reader/decorators/readers/index.d.ts +0 -3
- package/bundled/form/reader/reader/Reader.d.ts +0 -13
- package/bundled/form/reader/reader/index.d.ts +0 -1
|
@@ -1,77 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Marker used by the DevTools extension to recognize bridge messages
|
|
4
|
-
*/
|
|
1
|
+
/** Marker the DevTools extension recognizes bridge messages by. */
|
|
5
2
|
export declare const DEVTOOLS_MESSAGE_SOURCE = "punica-form-devtools";
|
|
3
|
+
/** Version of the message format. */
|
|
4
|
+
export declare const DEVTOOLS_PROTOCOL_VERSION = 2;
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
declare class DevToolsBridge {
|
|
10
|
-
private static instance;
|
|
11
|
-
private enabled;
|
|
12
|
-
/**
|
|
13
|
-
* Get singleton instance
|
|
14
|
-
*/
|
|
15
|
-
static getInstance(): DevToolsBridge;
|
|
16
|
-
/**
|
|
17
|
-
* Enable DevTools bridge
|
|
18
|
-
*/
|
|
19
|
-
enable(): void;
|
|
20
|
-
/**
|
|
21
|
-
* Disable DevTools bridge
|
|
22
|
-
*/
|
|
23
|
-
disable(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Check if DevTools bridge is enabled
|
|
26
|
-
*/
|
|
27
|
-
isEnabled(): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Send message to DevTools extension
|
|
30
|
-
*/
|
|
31
|
-
private sendMessage;
|
|
32
|
-
/**
|
|
33
|
-
* Send initialization event
|
|
34
|
-
*/
|
|
35
|
-
sendInit<E, F extends FormItem<E>>(form: Form<E, F>): void;
|
|
36
|
-
/**
|
|
37
|
-
* Send entity data
|
|
38
|
-
*/
|
|
39
|
-
sendEntity<E>(entity: E): void;
|
|
40
|
-
/**
|
|
41
|
-
* Send form update event
|
|
42
|
-
*/
|
|
43
|
-
sendUpdate<E, F extends FormItem<E>>(form: Form<E, F>): void;
|
|
44
|
-
/**
|
|
45
|
-
* Send form reset event
|
|
46
|
-
*/
|
|
47
|
-
sendReset<E, F extends FormItem<E>>(form: Form<E, F>): void;
|
|
48
|
-
/**
|
|
49
|
-
* Send item update event
|
|
50
|
-
*/
|
|
51
|
-
sendUpdateItem<E, F extends FormItem<E>>(item: F | F[]): void;
|
|
52
|
-
/**
|
|
53
|
-
* Send register items event
|
|
54
|
-
*/
|
|
55
|
-
sendRegisterItems(itemKeys: string[]): void;
|
|
56
|
-
/**
|
|
57
|
-
* Send property value update event
|
|
58
|
-
*/
|
|
59
|
-
sendUpdatePropertyValue<E, F extends FormItem<E>>(property: keyof E, value: any, item: F): void;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get DevTools bridge instance
|
|
63
|
-
*/
|
|
64
|
-
export declare const getDevToolsBridge: () => DevToolsBridge;
|
|
65
|
-
/**
|
|
66
|
-
* Enable DevTools bridge
|
|
6
|
+
* Makes the forms of the page report to the Punica Form DevTools extension.
|
|
7
|
+
* Call it once, in development only.
|
|
67
8
|
*/
|
|
68
9
|
export declare const enableDevTools: () => void;
|
|
69
|
-
/**
|
|
70
|
-
* Disable DevTools bridge
|
|
71
|
-
*/
|
|
72
10
|
export declare const disableDevTools: () => void;
|
|
11
|
+
export declare const isDevToolsEnabled: () => boolean;
|
|
73
12
|
/**
|
|
74
|
-
*
|
|
13
|
+
* Sends a message to the DevTools extension, to the page's own origin only.
|
|
14
|
+
* @param formId - Identifies the form among the forms of the page
|
|
15
|
+
* @param type - `@@INIT`, `ENTITY` or the name of a form event
|
|
16
|
+
* @param formItemKey - The property the message is about
|
|
75
17
|
*/
|
|
76
|
-
export declare const
|
|
77
|
-
export {};
|
|
18
|
+
export declare const sendToDevTools: (formId: string, type: string, data: unknown, formItemKey?: string) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { DEVTOOLS_MESSAGE_SOURCE, DEVTOOLS_PROTOCOL_VERSION, disableDevTools, enableDevTools, isDevToolsEnabled } from './devtools';
|
|
2
2
|
export * from './deepCopy';
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import { CommandService, FormItem, IServiceControl, IServiceInitialize } from '@punica/form';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Clears the validation error of one item.
|
|
4
4
|
*/
|
|
5
|
-
export declare class ClearError<E, F extends FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl {
|
|
5
|
+
export declare class ClearError<E, F extends FormItem<E> = FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl {
|
|
6
6
|
#private;
|
|
7
|
-
/**
|
|
8
|
-
* Returns the name of the service.
|
|
9
|
-
* @returns {string} - Service name
|
|
10
|
-
*/
|
|
11
7
|
get name(): string;
|
|
8
|
+
initialize(command: CommandService<E, F>): void;
|
|
12
9
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param command - The command service to be used.
|
|
15
|
-
*/
|
|
16
|
-
initialize(command: CommandService<E, F>): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Clears errors on the specified form item.
|
|
19
|
-
* @param {keyof E} property - The name of the property to clear errors for.
|
|
20
|
-
* @returns {Promise<void>} - Resolves when the operation is complete.
|
|
10
|
+
* @throws When the form has no item for the property
|
|
21
11
|
*/
|
|
22
12
|
run(property: keyof E): Promise<void>;
|
|
23
13
|
}
|
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
import { CommandService, FormItem, IServiceControl, IServiceInitialize } from '@punica/form';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Clears the validation errors of every item.
|
|
4
4
|
*/
|
|
5
|
-
export declare class ClearErrors<E, F extends FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl
|
|
5
|
+
export declare class ClearErrors<E, F extends FormItem<E> = FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl {
|
|
6
6
|
#private;
|
|
7
|
-
/**
|
|
8
|
-
* Returns the name of the service.
|
|
9
|
-
* @returns {string} - Service name
|
|
10
|
-
*/
|
|
11
7
|
get name(): string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* @param command - The command service to be used.
|
|
15
|
-
*/
|
|
16
|
-
initialize(command: CommandService<E, F>): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Clears errors on form items.
|
|
19
|
-
* @returns {Promise<boolean>} - Resolves when the operation is complete.
|
|
20
|
-
*/
|
|
21
|
-
run(): Promise<boolean>;
|
|
8
|
+
initialize(command: CommandService<E, F>): void;
|
|
9
|
+
run(): Promise<void>;
|
|
22
10
|
}
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import { CommandService, FormItem, IServiceControl, IServiceInitialize } from '@punica/form';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Returns the entity with the values of the form.
|
|
4
4
|
*/
|
|
5
|
-
export declare class GetValues<E, F extends FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl
|
|
5
|
+
export declare class GetValues<E, F extends FormItem<E> = FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl {
|
|
6
6
|
#private;
|
|
7
|
-
/**
|
|
8
|
-
* Returns the name of the service.
|
|
9
|
-
* @returns {string} - Service name
|
|
10
|
-
*/
|
|
11
7
|
get name(): string;
|
|
8
|
+
initialize(command: CommandService<E, F>): void;
|
|
12
9
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
initialize(command: CommandService<E, F>): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Retrieves form values and returns them as an entity.
|
|
19
|
-
* @returns {Promise<E>} - Resolves with the entity containing form values.
|
|
10
|
+
* @returns A copy of the entity the form was created from, holding the
|
|
11
|
+
* current values. The entity itself is never changed.
|
|
20
12
|
*/
|
|
21
13
|
run(): Promise<E>;
|
|
22
14
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import type { FormItem } from '@punica/form';
|
|
2
|
+
import type { ClearError } from './clearError';
|
|
3
|
+
import type { ClearErrors } from './clearErrors';
|
|
4
|
+
import type { GetValues } from './getValues';
|
|
5
|
+
import type { Reset } from './reset';
|
|
6
|
+
import type { ResetItem } from './resetItem';
|
|
7
|
+
import type { SetValue } from './setValue';
|
|
8
|
+
import type { Trigger } from './trigger';
|
|
9
|
+
import type { Validate } from './validate';
|
|
1
10
|
export * from './clearError';
|
|
2
11
|
export * from './clearErrors';
|
|
3
12
|
export * from './getValues';
|
|
@@ -7,3 +16,15 @@ export * from './setValue';
|
|
|
7
16
|
export * from './store';
|
|
8
17
|
export * from './trigger';
|
|
9
18
|
export * from './validate';
|
|
19
|
+
declare module '@punica/form' {
|
|
20
|
+
interface ServiceRegistry<E, F extends FormItem<E>> {
|
|
21
|
+
clearError: ClearError<E, F>;
|
|
22
|
+
clearErrors: ClearErrors<E, F>;
|
|
23
|
+
getValues: GetValues<E, F>;
|
|
24
|
+
reset: Reset<E, F>;
|
|
25
|
+
resetItem: ResetItem<E, F>;
|
|
26
|
+
setValue: SetValue<E, F>;
|
|
27
|
+
trigger: Trigger<E, F>;
|
|
28
|
+
validate: Validate<E, F>;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"
|
|
1
|
+
{"version":"2.0.0"}
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import { CommandService, FormItem, IServiceControl, IServiceInitialize } from '@punica/form';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Resets the form to the state it was started with.
|
|
4
4
|
*/
|
|
5
|
-
export declare class Reset<E, F extends FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl {
|
|
5
|
+
export declare class Reset<E, F extends FormItem<E> = FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl {
|
|
6
6
|
#private;
|
|
7
|
-
/**
|
|
8
|
-
* Returns the name of the service.
|
|
9
|
-
* @returns {string} - Service name
|
|
10
|
-
*/
|
|
11
7
|
get name(): string;
|
|
8
|
+
initialize(command: CommandService<E, F>): void;
|
|
12
9
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param command - The command service to be used.
|
|
15
|
-
*/
|
|
16
|
-
initialize(command: CommandService<E, F>): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Resets the form to its initial state.
|
|
19
|
-
* @returns {Promise<void>} - Resolves when the operation is complete.
|
|
10
|
+
* Fires RESET after the form was updated.
|
|
20
11
|
*/
|
|
21
12
|
run(): Promise<void>;
|
|
22
13
|
}
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import { CommandService, FormItem, IServiceControl, IServiceInitialize } from '@punica/form';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Resets one item to the state it was started with.
|
|
4
4
|
*/
|
|
5
|
-
export declare class ResetItem<E, F extends FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl {
|
|
5
|
+
export declare class ResetItem<E, F extends FormItem<E> = FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl {
|
|
6
6
|
#private;
|
|
7
|
-
/**
|
|
8
|
-
* Returns the name of the service.
|
|
9
|
-
* @returns {string} - Service name
|
|
10
|
-
*/
|
|
11
7
|
get name(): string;
|
|
8
|
+
initialize(command: CommandService<E, F>): void;
|
|
12
9
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param command - The command service to be used.
|
|
15
|
-
*/
|
|
16
|
-
initialize(command: CommandService<E, F>): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Resets the value of the specified property.
|
|
19
|
-
* @param {keyof E} property - The name of the property to reset.
|
|
20
|
-
* @returns {Promise} - Resolves when the operation is complete, rejects on error.
|
|
10
|
+
* @throws When the form has no item for the property
|
|
21
11
|
*/
|
|
22
12
|
run(property: keyof E): Promise<void>;
|
|
23
13
|
}
|
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
import { CommandService, FormItem, IServiceInitialize } from '@punica/form';
|
|
1
|
+
import { CommandService, FormItem, IServiceControl, IServiceInitialize } from '@punica/form';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Sets the value of an item and runs its control function.
|
|
4
4
|
*/
|
|
5
|
-
export declare class SetValue<E, F extends FormItem<E>> implements IServiceInitialize<E, F
|
|
5
|
+
export declare class SetValue<E, F extends FormItem<E> = FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl {
|
|
6
6
|
#private;
|
|
7
|
-
/**
|
|
8
|
-
* Returns the name of the service.
|
|
9
|
-
* @returns {string} - Service name
|
|
10
|
-
*/
|
|
11
7
|
get name(): string;
|
|
8
|
+
initialize(command: CommandService<E, F>): void;
|
|
12
9
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
* @param value - Value to be set
|
|
16
|
-
*/
|
|
17
|
-
private setValue;
|
|
18
|
-
/**
|
|
19
|
-
* Initializes the service with a command.
|
|
20
|
-
* @param command - The command service to be used.
|
|
10
|
+
* Fires UPDATE_ITEM with the changed item and the items its control returned.
|
|
11
|
+
* @throws When the form has no item for the property
|
|
21
12
|
*/
|
|
22
|
-
|
|
13
|
+
run(property: keyof E, value: unknown): Promise<void>;
|
|
23
14
|
}
|
|
@@ -1,30 +1,18 @@
|
|
|
1
1
|
import { IServiceCommand } from '@punica/form';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* What `Store` adds to the command of the functions of form items:
|
|
4
|
+
* `validation: ({ readStoreItem }: CommandItem<E, F, StoreCommand>) => …`
|
|
5
|
+
*/
|
|
6
|
+
export type StoreCommand = {
|
|
7
|
+
readStoreItem: (key: string) => unknown;
|
|
8
|
+
writeStoreItem: (key: string, value: unknown) => void;
|
|
9
|
+
deleteStoreItem: (key: string) => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A key-value store the functions of the form items share.
|
|
4
13
|
*/
|
|
5
14
|
export declare class Store implements IServiceCommand {
|
|
6
15
|
#private;
|
|
7
|
-
/**
|
|
8
|
-
* Returns the name of the service.
|
|
9
|
-
* @returns {string} - Service name
|
|
10
|
-
*/
|
|
11
16
|
get name(): string;
|
|
12
|
-
|
|
13
|
-
* Adds custom features for command items.
|
|
14
|
-
* This method provides a set of custom functions that can be used by command items.
|
|
15
|
-
* These functions allow for reading, writing, and deleting data from the internal store.
|
|
16
|
-
* @returns {{
|
|
17
|
-
* readStoreItem: (key: string) => any,
|
|
18
|
-
* writeStoreItem: (key: string, value: any) => void,
|
|
19
|
-
* deleteStoreItem: (key: string) => void
|
|
20
|
-
* }} An object containing custom functions for command items:
|
|
21
|
-
* - `readStoreItem`: A function that takes a `key` (string) and returns the corresponding value from the store.
|
|
22
|
-
* - `writeStoreItem`: A function that takes a `key` (string) and `value` (any) to store in the internal store.
|
|
23
|
-
* - `deleteStoreItem`: A function that takes a `key` (string) and deletes the corresponding item from the store.
|
|
24
|
-
*/
|
|
25
|
-
addCustomFeaturesForCommandItem(): {
|
|
26
|
-
readStoreItem: (key: string) => any;
|
|
27
|
-
writeStoreItem: (key: string, value: any) => void;
|
|
28
|
-
deleteStoreItem: (key: string) => void;
|
|
29
|
-
};
|
|
17
|
+
addCustomFeaturesForCommandItem(): StoreCommand;
|
|
30
18
|
}
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import { CommandService, FormItem, IServiceControl, IServiceInitialize } from '@punica/form';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Validates one item of the form.
|
|
4
4
|
*/
|
|
5
|
-
export declare class Trigger<E, F extends FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl {
|
|
5
|
+
export declare class Trigger<E, F extends FormItem<E> = FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl {
|
|
6
6
|
#private;
|
|
7
|
-
/**
|
|
8
|
-
* Returns the name of the service.
|
|
9
|
-
* @returns {string} - Service name
|
|
10
|
-
*/
|
|
11
7
|
get name(): string;
|
|
8
|
+
initialize(command: CommandService<E, F>): void;
|
|
12
9
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param command - The command service to be used.
|
|
15
|
-
*/
|
|
16
|
-
initialize(command: CommandService<E, F>): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Called when the value of a form item is changed.
|
|
19
|
-
* @param property - Property of the changed item.
|
|
10
|
+
* @throws When the form has no item for the property
|
|
20
11
|
*/
|
|
21
12
|
run(property: keyof E): Promise<void>;
|
|
22
13
|
}
|
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
import { CommandService, FormItem, IServiceControl, IServiceInitialize } from '@punica/form';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Validates every item of the form.
|
|
4
4
|
*/
|
|
5
|
-
export declare class Validate<E, F extends FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl
|
|
5
|
+
export declare class Validate<E, F extends FormItem<E> = FormItem<E>> implements IServiceInitialize<E, F>, IServiceControl {
|
|
6
6
|
#private;
|
|
7
|
-
/**
|
|
8
|
-
* Validates a form item.
|
|
9
|
-
* @param {F} item - The form item to be validated.
|
|
10
|
-
*/
|
|
11
|
-
private validateFormItem;
|
|
12
|
-
/**
|
|
13
|
-
* Returns the name of the service.
|
|
14
|
-
* @returns {string} - Service name
|
|
15
|
-
*/
|
|
16
7
|
get name(): string;
|
|
8
|
+
initialize(command: CommandService<E, F>): void;
|
|
17
9
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param command - The command service to be used.
|
|
20
|
-
*/
|
|
21
|
-
initialize(command: CommandService<E, F>): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* Runs validation checks on all form items.
|
|
24
|
-
* @returns {Promise<boolean>} - Resolves to true if all validations pass, otherwise resolves to false.
|
|
10
|
+
* @returns Whether every validated item is valid
|
|
25
11
|
*/
|
|
26
12
|
run(): Promise<boolean>;
|
|
27
13
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CommandService, FormItem } from '@punica/form';
|
|
2
|
+
/**
|
|
3
|
+
* Runs the validation of an item.
|
|
4
|
+
* @returns The item with the result of the validation, or `undefined` when
|
|
5
|
+
* the item is not validated (no validation function, or hidden)
|
|
6
|
+
*/
|
|
7
|
+
export declare const validateItem: <E, F extends FormItem<E>>(command: CommandService<E, F>, item: F) => Promise<F | undefined>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@punica/form-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "MCP server for Punica Form: look up the exact API, read the rules and check code that uses it.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"zod": "^4.6.7"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@punica/form": "^
|
|
42
|
-
"@punica/form-service": "^
|
|
41
|
+
"@punica/form": "^2.0.0",
|
|
42
|
+
"@punica/form-service": "^2.0.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "node build.mjs",
|
package/src/create.mjs
CHANGED
|
@@ -21,7 +21,7 @@ export function createPunicaFormServer({ packages, guide }) {
|
|
|
21
21
|
.join(', ');
|
|
22
22
|
|
|
23
23
|
const server = new McpServer(
|
|
24
|
-
{ name: 'punica-form', version: '0.
|
|
24
|
+
{ name: 'punica-form', version: '0.2.0' },
|
|
25
25
|
{
|
|
26
26
|
instructions: `${versions}. Punica Form is a headless form engine and is rarely in training data: never write an import, a service name or a method from memory. Read get_guide first, look names up with search_api and get_api, and check the code with validate_code before handing it over.`
|
|
27
27
|
}
|
|
@@ -32,7 +32,7 @@ export function createPunicaFormServer({ packages, guide }) {
|
|
|
32
32
|
{
|
|
33
33
|
title: 'How to use Punica Form',
|
|
34
34
|
description:
|
|
35
|
-
'The rules of Punica Form: what the packages provide and what the application builds itself, the lifecycle, the services and how to call them, events, and a complete working example.',
|
|
35
|
+
'The rules of Punica Form: what the packages provide and what the application builds itself, the lifecycle, the immutable state, the services and how to call them, events, and a complete working example.',
|
|
36
36
|
inputSchema: {},
|
|
37
37
|
annotations: { readOnlyHint: true }
|
|
38
38
|
},
|
|
@@ -80,7 +80,7 @@ export function createPunicaFormServer({ packages, guide }) {
|
|
|
80
80
|
{
|
|
81
81
|
title: 'Check code that uses Punica Form',
|
|
82
82
|
description:
|
|
83
|
-
'Checks TypeScript or JavaScript that uses Punica Form: imports the packages do not export
|
|
83
|
+
'Checks TypeScript or JavaScript that uses Punica Form: imports the packages do not export and calls that do not exist, such as the 1.x API. Returns each problem with its line and a fix.',
|
|
84
84
|
inputSchema: { code: z.string().describe('The code to check') },
|
|
85
85
|
annotations: { readOnlyHint: true }
|
|
86
86
|
},
|
|
@@ -88,7 +88,7 @@ export function createPunicaFormServer({ packages, guide }) {
|
|
|
88
88
|
const findings = validate(code);
|
|
89
89
|
|
|
90
90
|
if (!findings.length) {
|
|
91
|
-
return text('No problems: every import exists and
|
|
91
|
+
return text('No problems: every import exists and no removed API is used.');
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
return text(
|