@asaidimu/anansi 1.4.0 → 1.4.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/index.d.cts +111 -15
- package/index.d.ts +111 -15
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -5,21 +5,111 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
|
5
5
|
import LightningFS from '@isomorphic-git/lightning-fs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* hints.ts
|
|
9
9
|
*
|
|
10
|
-
* Defines
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
* Defines type hints for generating form input controls based on schema field definitions.
|
|
11
|
+
* Each hint type corresponds to a specific input control, providing metadata for code generation.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Hints for generating a file input control.
|
|
15
|
+
*/
|
|
16
|
+
type FileHint = {
|
|
17
|
+
type: "file";
|
|
18
|
+
label?: string;
|
|
19
|
+
embed?: boolean;
|
|
20
|
+
mimes?: string | string[];
|
|
21
|
+
size?: {
|
|
22
|
+
max?: number;
|
|
23
|
+
min?: number;
|
|
24
|
+
};
|
|
25
|
+
dimensions?: {
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Hints for generating a text-based input control.
|
|
32
|
+
*/
|
|
33
|
+
type TextHint = {
|
|
34
|
+
type: "text" | "email" | "tel" | "url" | "textarea";
|
|
35
|
+
label?: string;
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Hints for generating a secret input control (e.g., passwords, API keys).
|
|
22
40
|
*/
|
|
41
|
+
type SecretHint = {
|
|
42
|
+
type: "secret";
|
|
43
|
+
label?: string;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
password?: boolean;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Hints for generating a number-based input control.
|
|
49
|
+
*/
|
|
50
|
+
type NumberHint = {
|
|
51
|
+
type: "number" | "range";
|
|
52
|
+
label?: string;
|
|
53
|
+
step?: number;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Hints for generating a boolean input control.
|
|
57
|
+
*/
|
|
58
|
+
type BooleanHint = {
|
|
59
|
+
type: "checkbox" | "radio";
|
|
60
|
+
label?: string;
|
|
61
|
+
radioLabels?: {
|
|
62
|
+
true: string;
|
|
63
|
+
false: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Hints for generating an enum input control.
|
|
68
|
+
*/
|
|
69
|
+
type EnumHint = {
|
|
70
|
+
type: "select" | "radio";
|
|
71
|
+
label?: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Hints for generating an array input control.
|
|
75
|
+
*/
|
|
76
|
+
type ArrayHint = {
|
|
77
|
+
type: "list";
|
|
78
|
+
label?: string;
|
|
79
|
+
itemHint?: {
|
|
80
|
+
type: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Hints for generating a set input control.
|
|
85
|
+
*/
|
|
86
|
+
type SetHint = {
|
|
87
|
+
type: "tags";
|
|
88
|
+
label?: string;
|
|
89
|
+
itemHint?: {
|
|
90
|
+
type: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Hints for generating an object input control.
|
|
95
|
+
*/
|
|
96
|
+
type ObjectHint = {
|
|
97
|
+
type: "group";
|
|
98
|
+
label?: string;
|
|
99
|
+
collapsible?: boolean;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Hints for generating a dynamic input control.
|
|
103
|
+
*/
|
|
104
|
+
type DynamicHint = {
|
|
105
|
+
type: "text";
|
|
106
|
+
label?: string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Union type for all possible input hints.
|
|
110
|
+
*/
|
|
111
|
+
type InputHint = FileHint | TextHint | SecretHint | NumberHint | BooleanHint | EnumHint | ArrayHint | SetHint | ObjectHint | DynamicHint;
|
|
112
|
+
|
|
23
113
|
/**
|
|
24
114
|
* Logical operators for combining constraints or index conditions.
|
|
25
115
|
*/
|
|
@@ -27,7 +117,7 @@ type LogicalOperator = "and" | "or" | "not" | "nor" | "xor";
|
|
|
27
117
|
/**
|
|
28
118
|
* Basic field types supported by the schema system.
|
|
29
119
|
*/
|
|
30
|
-
type FieldType = "string" | "number" | "boolean" | "array" | "set" | "enum" | "object" | "dynamic";
|
|
120
|
+
type FieldType = "string" | "number" | "boolean" | "array" | "set" | "enum" | "object" | "record" | "dynamic";
|
|
31
121
|
/**
|
|
32
122
|
* Index types for optimizing different query patterns.
|
|
33
123
|
*/
|
|
@@ -54,6 +144,9 @@ type ConstraintsMap = Record<string, Predicate>;
|
|
|
54
144
|
* Names of supported predicates, derived from a PredicateMap.
|
|
55
145
|
*/
|
|
56
146
|
type PredicateName<T extends PredicateMap = any> = keyof T;
|
|
147
|
+
/**
|
|
148
|
+
* Parameters for predicates, tailored to each field type.
|
|
149
|
+
*/
|
|
57
150
|
/**
|
|
58
151
|
* Parameters for predicates, tailored to each field type.
|
|
59
152
|
*/
|
|
@@ -69,7 +162,7 @@ type PredicateParameters<T extends FieldType> = T extends "string" ? string | st
|
|
|
69
162
|
maxItems: number;
|
|
70
163
|
} : T extends "object" ? {
|
|
71
164
|
schema: Record<string, unknown>;
|
|
72
|
-
} : T extends "dynamic" ? any : never;
|
|
165
|
+
} : T extends "record" ? Record<string, unknown> : T extends "dynamic" ? any : never;
|
|
73
166
|
/** @deprecated Use PredicateParameters instead. */
|
|
74
167
|
type ConstraintParameters<T extends FieldType> = PredicateParameters<T>;
|
|
75
168
|
/**
|
|
@@ -120,6 +213,9 @@ interface FieldDefinition<T> {
|
|
|
120
213
|
};
|
|
121
214
|
description?: string;
|
|
122
215
|
unique?: boolean;
|
|
216
|
+
hint?: {
|
|
217
|
+
input: InputHint;
|
|
218
|
+
};
|
|
123
219
|
}
|
|
124
220
|
/**
|
|
125
221
|
* Condition for partial indexes, allowing conditional indexing based on field values.
|
package/index.d.ts
CHANGED
|
@@ -5,21 +5,111 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
|
5
5
|
import LightningFS from '@isomorphic-git/lightning-fs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* hints.ts
|
|
9
9
|
*
|
|
10
|
-
* Defines
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
* Defines type hints for generating form input controls based on schema field definitions.
|
|
11
|
+
* Each hint type corresponds to a specific input control, providing metadata for code generation.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Hints for generating a file input control.
|
|
15
|
+
*/
|
|
16
|
+
type FileHint = {
|
|
17
|
+
type: "file";
|
|
18
|
+
label?: string;
|
|
19
|
+
embed?: boolean;
|
|
20
|
+
mimes?: string | string[];
|
|
21
|
+
size?: {
|
|
22
|
+
max?: number;
|
|
23
|
+
min?: number;
|
|
24
|
+
};
|
|
25
|
+
dimensions?: {
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Hints for generating a text-based input control.
|
|
32
|
+
*/
|
|
33
|
+
type TextHint = {
|
|
34
|
+
type: "text" | "email" | "tel" | "url" | "textarea";
|
|
35
|
+
label?: string;
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Hints for generating a secret input control (e.g., passwords, API keys).
|
|
22
40
|
*/
|
|
41
|
+
type SecretHint = {
|
|
42
|
+
type: "secret";
|
|
43
|
+
label?: string;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
password?: boolean;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Hints for generating a number-based input control.
|
|
49
|
+
*/
|
|
50
|
+
type NumberHint = {
|
|
51
|
+
type: "number" | "range";
|
|
52
|
+
label?: string;
|
|
53
|
+
step?: number;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Hints for generating a boolean input control.
|
|
57
|
+
*/
|
|
58
|
+
type BooleanHint = {
|
|
59
|
+
type: "checkbox" | "radio";
|
|
60
|
+
label?: string;
|
|
61
|
+
radioLabels?: {
|
|
62
|
+
true: string;
|
|
63
|
+
false: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Hints for generating an enum input control.
|
|
68
|
+
*/
|
|
69
|
+
type EnumHint = {
|
|
70
|
+
type: "select" | "radio";
|
|
71
|
+
label?: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Hints for generating an array input control.
|
|
75
|
+
*/
|
|
76
|
+
type ArrayHint = {
|
|
77
|
+
type: "list";
|
|
78
|
+
label?: string;
|
|
79
|
+
itemHint?: {
|
|
80
|
+
type: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Hints for generating a set input control.
|
|
85
|
+
*/
|
|
86
|
+
type SetHint = {
|
|
87
|
+
type: "tags";
|
|
88
|
+
label?: string;
|
|
89
|
+
itemHint?: {
|
|
90
|
+
type: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Hints for generating an object input control.
|
|
95
|
+
*/
|
|
96
|
+
type ObjectHint = {
|
|
97
|
+
type: "group";
|
|
98
|
+
label?: string;
|
|
99
|
+
collapsible?: boolean;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Hints for generating a dynamic input control.
|
|
103
|
+
*/
|
|
104
|
+
type DynamicHint = {
|
|
105
|
+
type: "text";
|
|
106
|
+
label?: string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Union type for all possible input hints.
|
|
110
|
+
*/
|
|
111
|
+
type InputHint = FileHint | TextHint | SecretHint | NumberHint | BooleanHint | EnumHint | ArrayHint | SetHint | ObjectHint | DynamicHint;
|
|
112
|
+
|
|
23
113
|
/**
|
|
24
114
|
* Logical operators for combining constraints or index conditions.
|
|
25
115
|
*/
|
|
@@ -27,7 +117,7 @@ type LogicalOperator = "and" | "or" | "not" | "nor" | "xor";
|
|
|
27
117
|
/**
|
|
28
118
|
* Basic field types supported by the schema system.
|
|
29
119
|
*/
|
|
30
|
-
type FieldType = "string" | "number" | "boolean" | "array" | "set" | "enum" | "object" | "dynamic";
|
|
120
|
+
type FieldType = "string" | "number" | "boolean" | "array" | "set" | "enum" | "object" | "record" | "dynamic";
|
|
31
121
|
/**
|
|
32
122
|
* Index types for optimizing different query patterns.
|
|
33
123
|
*/
|
|
@@ -54,6 +144,9 @@ type ConstraintsMap = Record<string, Predicate>;
|
|
|
54
144
|
* Names of supported predicates, derived from a PredicateMap.
|
|
55
145
|
*/
|
|
56
146
|
type PredicateName<T extends PredicateMap = any> = keyof T;
|
|
147
|
+
/**
|
|
148
|
+
* Parameters for predicates, tailored to each field type.
|
|
149
|
+
*/
|
|
57
150
|
/**
|
|
58
151
|
* Parameters for predicates, tailored to each field type.
|
|
59
152
|
*/
|
|
@@ -69,7 +162,7 @@ type PredicateParameters<T extends FieldType> = T extends "string" ? string | st
|
|
|
69
162
|
maxItems: number;
|
|
70
163
|
} : T extends "object" ? {
|
|
71
164
|
schema: Record<string, unknown>;
|
|
72
|
-
} : T extends "dynamic" ? any : never;
|
|
165
|
+
} : T extends "record" ? Record<string, unknown> : T extends "dynamic" ? any : never;
|
|
73
166
|
/** @deprecated Use PredicateParameters instead. */
|
|
74
167
|
type ConstraintParameters<T extends FieldType> = PredicateParameters<T>;
|
|
75
168
|
/**
|
|
@@ -120,6 +213,9 @@ interface FieldDefinition<T> {
|
|
|
120
213
|
};
|
|
121
214
|
description?: string;
|
|
122
215
|
unique?: boolean;
|
|
216
|
+
hint?: {
|
|
217
|
+
input: InputHint;
|
|
218
|
+
};
|
|
123
219
|
}
|
|
124
220
|
/**
|
|
125
221
|
* Condition for partial indexes, allowing conditional indexing based on field values.
|