semantic-primitives 0.1.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/LICENSE +201 -0
- package/README.md +449 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25016 -0
- package/dist/llm/client.d.ts +82 -0
- package/dist/llm/client.d.ts.map +1 -0
- package/dist/llm/index.d.ts +11 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/providers/anthropic.d.ts +13 -0
- package/dist/llm/providers/anthropic.d.ts.map +1 -0
- package/dist/llm/providers/google.d.ts +13 -0
- package/dist/llm/providers/google.d.ts.map +1 -0
- package/dist/llm/providers/index.d.ts +7 -0
- package/dist/llm/providers/index.d.ts.map +1 -0
- package/dist/llm/providers/openai.d.ts +13 -0
- package/dist/llm/providers/openai.d.ts.map +1 -0
- package/dist/llm/types.d.ts +91 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/primitives/bigint/bigint.d.ts +197 -0
- package/dist/primitives/bigint/bigint.d.ts.map +1 -0
- package/dist/primitives/bigint/index.d.ts +7 -0
- package/dist/primitives/bigint/index.d.ts.map +1 -0
- package/dist/primitives/bigint/prompts.d.ts +37 -0
- package/dist/primitives/bigint/prompts.d.ts.map +1 -0
- package/dist/primitives/boolean/boolean.d.ts +194 -0
- package/dist/primitives/boolean/boolean.d.ts.map +1 -0
- package/dist/primitives/boolean/evals/from.evals.d.ts +7 -0
- package/dist/primitives/boolean/evals/from.evals.d.ts.map +1 -0
- package/dist/primitives/boolean/evals/index.d.ts +5 -0
- package/dist/primitives/boolean/evals/index.d.ts.map +1 -0
- package/dist/primitives/boolean/index.d.ts +6 -0
- package/dist/primitives/boolean/index.d.ts.map +1 -0
- package/dist/primitives/boolean/prompts.d.ts +29 -0
- package/dist/primitives/boolean/prompts.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +14 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/null/index.d.ts +6 -0
- package/dist/primitives/null/index.d.ts.map +1 -0
- package/dist/primitives/null/null.d.ts +181 -0
- package/dist/primitives/null/null.d.ts.map +1 -0
- package/dist/primitives/null/prompts.d.ts +39 -0
- package/dist/primitives/null/prompts.d.ts.map +1 -0
- package/dist/primitives/number/index.d.ts +6 -0
- package/dist/primitives/number/index.d.ts.map +1 -0
- package/dist/primitives/number/number.d.ts +154 -0
- package/dist/primitives/number/number.d.ts.map +1 -0
- package/dist/primitives/number/number.prompts.d.ts +53 -0
- package/dist/primitives/number/number.prompts.d.ts.map +1 -0
- package/dist/primitives/string/evals/classify.evals.d.ts +7 -0
- package/dist/primitives/string/evals/classify.evals.d.ts.map +1 -0
- package/dist/primitives/string/evals/index.d.ts +6 -0
- package/dist/primitives/string/evals/index.d.ts.map +1 -0
- package/dist/primitives/string/evals/semanticallyEquals.evals.d.ts +7 -0
- package/dist/primitives/string/evals/semanticallyEquals.evals.d.ts.map +1 -0
- package/dist/primitives/string/index.d.ts +206 -0
- package/dist/primitives/string/index.d.ts.map +1 -0
- package/dist/primitives/string/string.prompts.d.ts +45 -0
- package/dist/primitives/string/string.prompts.d.ts.map +1 -0
- package/dist/primitives/symbol/index.d.ts +6 -0
- package/dist/primitives/symbol/index.d.ts.map +1 -0
- package/dist/primitives/symbol/symbol.d.ts +176 -0
- package/dist/primitives/symbol/symbol.d.ts.map +1 -0
- package/dist/primitives/symbol/symbol.prompts.d.ts +53 -0
- package/dist/primitives/symbol/symbol.prompts.d.ts.map +1 -0
- package/dist/primitives/undefined/index.d.ts +5 -0
- package/dist/primitives/undefined/index.d.ts.map +1 -0
- package/dist/primitives/undefined/prompts.d.ts +40 -0
- package/dist/primitives/undefined/prompts.d.ts.map +1 -0
- package/dist/primitives/undefined/undefined.d.ts +216 -0
- package/dist/primitives/undefined/undefined.d.ts.map +1 -0
- package/dist/primitives/void/index.d.ts +5 -0
- package/dist/primitives/void/index.d.ts.map +1 -0
- package/dist/primitives/void/prompts.d.ts +37 -0
- package/dist/primitives/void/prompts.d.ts.map +1 -0
- package/dist/primitives/void/void.d.ts +172 -0
- package/dist/primitives/void/void.d.ts.map +1 -0
- package/dist/shared/base-classes.d.ts +331 -0
- package/dist/shared/base-classes.d.ts.map +1 -0
- package/dist/shared/eval-types.d.ts +82 -0
- package/dist/shared/eval-types.d.ts.map +1 -0
- package/dist/shared/index.d.ts +25 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/interfaces.d.ts +799 -0
- package/dist/shared/interfaces.d.ts.map +1 -0
- package/dist/shared/types.d.ts +335 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/types/array/array.d.ts +250 -0
- package/dist/types/array/array.d.ts.map +1 -0
- package/dist/types/array/index.d.ts +6 -0
- package/dist/types/array/index.d.ts.map +1 -0
- package/dist/types/array/prompts.d.ts +63 -0
- package/dist/types/array/prompts.d.ts.map +1 -0
- package/dist/types/blob-file/blob.d.ts +188 -0
- package/dist/types/blob-file/blob.d.ts.map +1 -0
- package/dist/types/blob-file/file.d.ts +144 -0
- package/dist/types/blob-file/file.d.ts.map +1 -0
- package/dist/types/blob-file/index.d.ts +8 -0
- package/dist/types/blob-file/index.d.ts.map +1 -0
- package/dist/types/blob-file/prompts.d.ts +101 -0
- package/dist/types/blob-file/prompts.d.ts.map +1 -0
- package/dist/types/bun/bun.d.ts +266 -0
- package/dist/types/bun/bun.d.ts.map +1 -0
- package/dist/types/bun/index.d.ts +7 -0
- package/dist/types/bun/index.d.ts.map +1 -0
- package/dist/types/bun/prompts.d.ts +93 -0
- package/dist/types/bun/prompts.d.ts.map +1 -0
- package/dist/types/callable/callable.d.ts +200 -0
- package/dist/types/callable/callable.d.ts.map +1 -0
- package/dist/types/callable/index.d.ts +6 -0
- package/dist/types/callable/index.d.ts.map +1 -0
- package/dist/types/callable/prompts.d.ts +45 -0
- package/dist/types/callable/prompts.d.ts.map +1 -0
- package/dist/types/constructable/constructable.d.ts +150 -0
- package/dist/types/constructable/constructable.d.ts.map +1 -0
- package/dist/types/constructable/index.d.ts +5 -0
- package/dist/types/constructable/index.d.ts.map +1 -0
- package/dist/types/constructable/prompts.d.ts +41 -0
- package/dist/types/constructable/prompts.d.ts.map +1 -0
- package/dist/types/date/date.d.ts +258 -0
- package/dist/types/date/date.d.ts.map +1 -0
- package/dist/types/date/index.d.ts +6 -0
- package/dist/types/date/index.d.ts.map +1 -0
- package/dist/types/date/prompts.d.ts +93 -0
- package/dist/types/date/prompts.d.ts.map +1 -0
- package/dist/types/error/error.d.ts +191 -0
- package/dist/types/error/error.d.ts.map +1 -0
- package/dist/types/error/index.d.ts +6 -0
- package/dist/types/error/index.d.ts.map +1 -0
- package/dist/types/error/prompts.d.ts +49 -0
- package/dist/types/error/prompts.d.ts.map +1 -0
- package/dist/types/event-emitter/event-emitter.d.ts +230 -0
- package/dist/types/event-emitter/event-emitter.d.ts.map +1 -0
- package/dist/types/event-emitter/index.d.ts +6 -0
- package/dist/types/event-emitter/index.d.ts.map +1 -0
- package/dist/types/event-emitter/prompts.d.ts +51 -0
- package/dist/types/event-emitter/prompts.d.ts.map +1 -0
- package/dist/types/fetch/headers.d.ts +126 -0
- package/dist/types/fetch/headers.d.ts.map +1 -0
- package/dist/types/fetch/index.d.ts +9 -0
- package/dist/types/fetch/index.d.ts.map +1 -0
- package/dist/types/fetch/prompts.d.ts +139 -0
- package/dist/types/fetch/prompts.d.ts.map +1 -0
- package/dist/types/fetch/request.d.ts +188 -0
- package/dist/types/fetch/request.d.ts.map +1 -0
- package/dist/types/fetch/response.d.ts +155 -0
- package/dist/types/fetch/response.d.ts.map +1 -0
- package/dist/types/form-data/form-data.d.ts +277 -0
- package/dist/types/form-data/form-data.d.ts.map +1 -0
- package/dist/types/form-data/index.d.ts +7 -0
- package/dist/types/form-data/index.d.ts.map +1 -0
- package/dist/types/form-data/prompts.d.ts +80 -0
- package/dist/types/form-data/prompts.d.ts.map +1 -0
- package/dist/types/index.d.ts +29 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/map/index.d.ts +6 -0
- package/dist/types/map/index.d.ts.map +1 -0
- package/dist/types/map/map.d.ts +204 -0
- package/dist/types/map/map.d.ts.map +1 -0
- package/dist/types/map/prompts.d.ts +56 -0
- package/dist/types/map/prompts.d.ts.map +1 -0
- package/dist/types/never/index.d.ts +5 -0
- package/dist/types/never/index.d.ts.map +1 -0
- package/dist/types/never/never.d.ts +220 -0
- package/dist/types/never/never.d.ts.map +1 -0
- package/dist/types/never/prompts.d.ts +50 -0
- package/dist/types/never/prompts.d.ts.map +1 -0
- package/dist/types/object/index.d.ts +6 -0
- package/dist/types/object/index.d.ts.map +1 -0
- package/dist/types/object/object.d.ts +162 -0
- package/dist/types/object/object.d.ts.map +1 -0
- package/dist/types/object/prompts.d.ts +55 -0
- package/dist/types/object/prompts.d.ts.map +1 -0
- package/dist/types/object-literal/index.d.ts +6 -0
- package/dist/types/object-literal/index.d.ts.map +1 -0
- package/dist/types/object-literal/object-literal.d.ts +223 -0
- package/dist/types/object-literal/object-literal.d.ts.map +1 -0
- package/dist/types/object-literal/prompts.d.ts +49 -0
- package/dist/types/object-literal/prompts.d.ts.map +1 -0
- package/dist/types/promise/index.d.ts +6 -0
- package/dist/types/promise/index.d.ts.map +1 -0
- package/dist/types/promise/promise.d.ts +240 -0
- package/dist/types/promise/promise.d.ts.map +1 -0
- package/dist/types/promise/prompts.d.ts +45 -0
- package/dist/types/promise/prompts.d.ts.map +1 -0
- package/dist/types/record/index.d.ts +5 -0
- package/dist/types/record/index.d.ts.map +1 -0
- package/dist/types/record/prompts.d.ts +45 -0
- package/dist/types/record/prompts.d.ts.map +1 -0
- package/dist/types/record/record.d.ts +179 -0
- package/dist/types/record/record.d.ts.map +1 -0
- package/dist/types/regexp/index.d.ts +7 -0
- package/dist/types/regexp/index.d.ts.map +1 -0
- package/dist/types/regexp/prompts.d.ts +56 -0
- package/dist/types/regexp/prompts.d.ts.map +1 -0
- package/dist/types/regexp/regexp.d.ts +160 -0
- package/dist/types/regexp/regexp.d.ts.map +1 -0
- package/dist/types/set/index.d.ts +6 -0
- package/dist/types/set/index.d.ts.map +1 -0
- package/dist/types/set/prompts.d.ts +60 -0
- package/dist/types/set/prompts.d.ts.map +1 -0
- package/dist/types/set/set.d.ts +261 -0
- package/dist/types/set/set.d.ts.map +1 -0
- package/dist/types/streams/index.d.ts +8 -0
- package/dist/types/streams/index.d.ts.map +1 -0
- package/dist/types/streams/prompts.d.ts +53 -0
- package/dist/types/streams/prompts.d.ts.map +1 -0
- package/dist/types/streams/readable-stream.d.ts +148 -0
- package/dist/types/streams/readable-stream.d.ts.map +1 -0
- package/dist/types/streams/transform-stream.d.ts +67 -0
- package/dist/types/streams/transform-stream.d.ts.map +1 -0
- package/dist/types/streams/writable-stream.d.ts +111 -0
- package/dist/types/streams/writable-stream.d.ts.map +1 -0
- package/dist/types/text-codec/index.d.ts +12 -0
- package/dist/types/text-codec/index.d.ts.map +1 -0
- package/dist/types/text-codec/prompts.d.ts +79 -0
- package/dist/types/text-codec/prompts.d.ts.map +1 -0
- package/dist/types/text-codec/text-codec.d.ts +305 -0
- package/dist/types/text-codec/text-codec.d.ts.map +1 -0
- package/dist/types/tuple/index.d.ts +6 -0
- package/dist/types/tuple/index.d.ts.map +1 -0
- package/dist/types/tuple/prompts.d.ts +41 -0
- package/dist/types/tuple/prompts.d.ts.map +1 -0
- package/dist/types/tuple/tuple.d.ts +221 -0
- package/dist/types/tuple/tuple.d.ts.map +1 -0
- package/dist/types/unknown/index.d.ts +5 -0
- package/dist/types/unknown/index.d.ts.map +1 -0
- package/dist/types/unknown/prompts.d.ts +45 -0
- package/dist/types/unknown/prompts.d.ts.map +1 -0
- package/dist/types/unknown/unknown.d.ts +220 -0
- package/dist/types/unknown/unknown.d.ts.map +1 -0
- package/dist/types/url/index.d.ts +7 -0
- package/dist/types/url/index.d.ts.map +1 -0
- package/dist/types/url/prompts.d.ts +93 -0
- package/dist/types/url/prompts.d.ts.map +1 -0
- package/dist/types/url/url.d.ts +270 -0
- package/dist/types/url/url.d.ts.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticFormData - LLM-enhanced FormData type with semantic understanding
|
|
3
|
+
*
|
|
4
|
+
* Extends the native FormData with semantic operations including:
|
|
5
|
+
* - Intelligent field validation and matching
|
|
6
|
+
* - Form purpose detection
|
|
7
|
+
* - Sensitive data detection
|
|
8
|
+
* - Missing field suggestions
|
|
9
|
+
* - File validation
|
|
10
|
+
*
|
|
11
|
+
* Implements shared interfaces:
|
|
12
|
+
* - Semantic<FormData> - Base semantic wrapper
|
|
13
|
+
* - Comparable<FormData> - Semantic equality comparison
|
|
14
|
+
* - Explainable - Human-readable explanations
|
|
15
|
+
*/
|
|
16
|
+
import type { LLMConfig, Message } from '../../llm/types.ts';
|
|
17
|
+
/** Type alias for FormData entry values (string or File) */
|
|
18
|
+
type FormDataEntryValue = string | File;
|
|
19
|
+
import type { SemanticEqualsResult } from '../../shared/types.ts';
|
|
20
|
+
import type { Semantic, Comparable, Explainable } from '../../shared/interfaces.ts';
|
|
21
|
+
/** Extended semantic equals result with field mappings */
|
|
22
|
+
export interface FormDataSemanticEqualsResult extends SemanticEqualsResult {
|
|
23
|
+
fieldMappings?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
/** Validation result with field-specific issues */
|
|
26
|
+
export interface FormDataValidateResult {
|
|
27
|
+
valid: boolean;
|
|
28
|
+
issues: {
|
|
29
|
+
field: string;
|
|
30
|
+
issue: string;
|
|
31
|
+
}[];
|
|
32
|
+
}
|
|
33
|
+
/** Result of semantic field access */
|
|
34
|
+
export interface FormDataSemanticGetResult {
|
|
35
|
+
value: FormDataEntryValue | null;
|
|
36
|
+
matchedField: string | undefined;
|
|
37
|
+
confidence: number;
|
|
38
|
+
}
|
|
39
|
+
/** Result of purpose inference */
|
|
40
|
+
export interface FormDataInferPurposeResult {
|
|
41
|
+
purpose: string;
|
|
42
|
+
requiredFields: string[];
|
|
43
|
+
confidence: number;
|
|
44
|
+
}
|
|
45
|
+
/** Result of sensitive data detection */
|
|
46
|
+
export interface FormDataDetectSensitiveResult {
|
|
47
|
+
hasSensitive: boolean;
|
|
48
|
+
fields: string[];
|
|
49
|
+
recommendation: string;
|
|
50
|
+
}
|
|
51
|
+
/** Suggestion for a missing field */
|
|
52
|
+
export interface FormDataMissingSuggestion {
|
|
53
|
+
field: string;
|
|
54
|
+
reason: string;
|
|
55
|
+
required: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** File validation rules */
|
|
58
|
+
export interface FileValidationRules {
|
|
59
|
+
maxSize?: string;
|
|
60
|
+
allowedTypes?: string[];
|
|
61
|
+
}
|
|
62
|
+
/** File validation result */
|
|
63
|
+
export interface FormDataFileValidateResult {
|
|
64
|
+
valid: boolean;
|
|
65
|
+
issues: {
|
|
66
|
+
field: string;
|
|
67
|
+
issue: string;
|
|
68
|
+
}[];
|
|
69
|
+
}
|
|
70
|
+
/** LLM client interface for dependency injection */
|
|
71
|
+
export interface FormDataLLMClientInterface {
|
|
72
|
+
chat(options: {
|
|
73
|
+
messages: Message[];
|
|
74
|
+
systemPrompt?: string;
|
|
75
|
+
} & LLMConfig): Promise<{
|
|
76
|
+
content: string;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* SemanticFormData class
|
|
81
|
+
* Wraps FormData with LLM-powered semantic operations
|
|
82
|
+
*
|
|
83
|
+
* Implements:
|
|
84
|
+
* - Semantic<FormData> - valueOf() returns the FormData value
|
|
85
|
+
* - Comparable<FormData> - semanticallyEquals() for comparison
|
|
86
|
+
* - Explainable - explain() for human-readable explanations
|
|
87
|
+
*/
|
|
88
|
+
export declare class SemanticFormData implements Semantic<FormData>, Comparable<FormData, FormDataSemanticEqualsResult>, Explainable {
|
|
89
|
+
private readonly _formData;
|
|
90
|
+
private readonly _context?;
|
|
91
|
+
private readonly _llmClient;
|
|
92
|
+
private readonly _llmConfig?;
|
|
93
|
+
/**
|
|
94
|
+
* Create a SemanticFormData instance
|
|
95
|
+
* @param formData - The FormData value to wrap
|
|
96
|
+
* @param context - Optional context about the form's purpose
|
|
97
|
+
* @param llmClient - Optional LLM client for dependency injection (useful for testing)
|
|
98
|
+
* @param llmConfig - Optional LLM configuration
|
|
99
|
+
*/
|
|
100
|
+
constructor(formData: FormData, context?: string, llmClient?: FormDataLLMClientInterface, llmConfig?: LLMConfig);
|
|
101
|
+
/**
|
|
102
|
+
* Create SemanticFormData from existing FormData or object.
|
|
103
|
+
*
|
|
104
|
+
* @param data - FormData or plain object
|
|
105
|
+
* @param context - Context about the form's purpose
|
|
106
|
+
* @param llmClient - Optional LLM client for dependency injection
|
|
107
|
+
* @param llmConfig - Optional LLM configuration
|
|
108
|
+
* @returns SemanticFormData instance
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* SemanticFormData.from({ name: "John", email: "john@example.com" })
|
|
112
|
+
* SemanticFormData.from(existingFormData, "user registration")
|
|
113
|
+
*/
|
|
114
|
+
static from(data: FormData | Record<string, unknown>, context?: string, llmClient?: FormDataLLMClientInterface, llmConfig?: LLMConfig): SemanticFormData;
|
|
115
|
+
/**
|
|
116
|
+
* Get a string representation of all form fields for LLM prompts
|
|
117
|
+
*/
|
|
118
|
+
private _getFieldsString;
|
|
119
|
+
/**
|
|
120
|
+
* Get file information for validation
|
|
121
|
+
*/
|
|
122
|
+
private _getFilesString;
|
|
123
|
+
/**
|
|
124
|
+
* Check if two FormData objects are semantically equivalent.
|
|
125
|
+
*
|
|
126
|
+
* @param other - FormData to compare
|
|
127
|
+
* @param _options - Optional comparison options (unused, for interface compatibility)
|
|
128
|
+
* @returns Equivalence result with field mappings
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* form1.semanticallyEquals(form2)
|
|
132
|
+
* // { equivalent: true, fieldMappings: { "firstName": "first_name" }, confidence: 0.95 }
|
|
133
|
+
*/
|
|
134
|
+
semanticallyEquals(other: FormData, _options?: Record<string, unknown>): Promise<FormDataSemanticEqualsResult>;
|
|
135
|
+
/**
|
|
136
|
+
* Validate form data against semantic rules.
|
|
137
|
+
*
|
|
138
|
+
* @param rules - Validation rules in natural language
|
|
139
|
+
* @returns Validation result with field-specific issues
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* form.validate([
|
|
143
|
+
* "email must be valid",
|
|
144
|
+
* "password must be strong",
|
|
145
|
+
* "file must be an image"
|
|
146
|
+
* ])
|
|
147
|
+
*/
|
|
148
|
+
validate(rules: string[]): Promise<FormDataValidateResult>;
|
|
149
|
+
/**
|
|
150
|
+
* Get a field using semantic matching.
|
|
151
|
+
*
|
|
152
|
+
* @param query - Field name or semantic description
|
|
153
|
+
* @returns Field value with match confidence
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* form.semanticGet("user's email address")
|
|
157
|
+
* // { value: "john@example.com", matchedField: "email", confidence: 0.95 }
|
|
158
|
+
*/
|
|
159
|
+
semanticGet(query: string): Promise<FormDataSemanticGetResult>;
|
|
160
|
+
/**
|
|
161
|
+
* Detect the purpose of this form.
|
|
162
|
+
*
|
|
163
|
+
* @returns Form purpose detection result
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* form.inferPurpose()
|
|
167
|
+
* // { purpose: "user-registration", requiredFields: ["email", "password"], confidence: 0.92 }
|
|
168
|
+
*/
|
|
169
|
+
inferPurpose(): Promise<FormDataInferPurposeResult>;
|
|
170
|
+
/**
|
|
171
|
+
* Check for sensitive data in the form.
|
|
172
|
+
*
|
|
173
|
+
* @returns Sensitivity analysis result
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* form.detectSensitive()
|
|
177
|
+
* // { hasSensitive: true, fields: ["password", "ssn"], recommendation: "Use HTTPS" }
|
|
178
|
+
*/
|
|
179
|
+
detectSensitive(): Promise<FormDataDetectSensitiveResult>;
|
|
180
|
+
/**
|
|
181
|
+
* Suggest missing fields based on form purpose.
|
|
182
|
+
*
|
|
183
|
+
* @returns Suggested fields with reasons
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* form.suggestMissingFields()
|
|
187
|
+
* // [{ field: "confirmPassword", reason: "Registration forms typically require password confirmation", required: true }]
|
|
188
|
+
*/
|
|
189
|
+
suggestMissingFields(): Promise<FormDataMissingSuggestion[]>;
|
|
190
|
+
/**
|
|
191
|
+
* Validate file fields in the form.
|
|
192
|
+
*
|
|
193
|
+
* @param rules - File validation rules
|
|
194
|
+
* @returns Validation result for file fields
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* form.validateFiles({
|
|
198
|
+
* maxSize: "5MB",
|
|
199
|
+
* allowedTypes: ["image/*", "application/pdf"]
|
|
200
|
+
* })
|
|
201
|
+
*/
|
|
202
|
+
validateFiles(rules: FileValidationRules): Promise<FormDataFileValidateResult>;
|
|
203
|
+
/**
|
|
204
|
+
* Explain the form contents.
|
|
205
|
+
*
|
|
206
|
+
* @param _context - Optional context (unused, for interface compatibility)
|
|
207
|
+
* @returns Human-readable explanation
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* form.explain()
|
|
211
|
+
* // "User registration form with name, email, password, and profile picture"
|
|
212
|
+
*/
|
|
213
|
+
explain(_context?: string): Promise<string>;
|
|
214
|
+
/**
|
|
215
|
+
* Convert to a plain object with semantic field names.
|
|
216
|
+
*
|
|
217
|
+
* @param targetConvention - Naming convention for keys (defaults to camelCase)
|
|
218
|
+
* @returns Plain object with converted field names
|
|
219
|
+
*/
|
|
220
|
+
toObject(targetConvention?: 'camelCase' | 'snake_case'): Promise<Record<string, unknown>>;
|
|
221
|
+
/**
|
|
222
|
+
* Get the raw FormData value
|
|
223
|
+
* @returns The underlying FormData
|
|
224
|
+
*/
|
|
225
|
+
valueOf(): FormData;
|
|
226
|
+
/**
|
|
227
|
+
* Get the context string
|
|
228
|
+
* @returns The context or undefined
|
|
229
|
+
*/
|
|
230
|
+
getContext(): string | undefined;
|
|
231
|
+
/**
|
|
232
|
+
* Append a value to the form data
|
|
233
|
+
*/
|
|
234
|
+
append(name: string, value: string | Blob, filename?: string): void;
|
|
235
|
+
/**
|
|
236
|
+
* Delete all values for a field
|
|
237
|
+
*/
|
|
238
|
+
delete(name: string): void;
|
|
239
|
+
/**
|
|
240
|
+
* Get the first value for a field
|
|
241
|
+
*/
|
|
242
|
+
get(name: string): FormDataEntryValue | null;
|
|
243
|
+
/**
|
|
244
|
+
* Get all values for a field
|
|
245
|
+
*/
|
|
246
|
+
getAll(name: string): FormDataEntryValue[];
|
|
247
|
+
/**
|
|
248
|
+
* Check if a field exists
|
|
249
|
+
*/
|
|
250
|
+
has(name: string): boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Set a value for a field (replaces existing)
|
|
253
|
+
*/
|
|
254
|
+
set(name: string, value: string | Blob, filename?: string): void;
|
|
255
|
+
/**
|
|
256
|
+
* Iterate over all entries
|
|
257
|
+
*/
|
|
258
|
+
entries(): IterableIterator<[string, FormDataEntryValue]>;
|
|
259
|
+
/**
|
|
260
|
+
* Iterate over all keys
|
|
261
|
+
*/
|
|
262
|
+
keys(): IterableIterator<string>;
|
|
263
|
+
/**
|
|
264
|
+
* Iterate over all values
|
|
265
|
+
*/
|
|
266
|
+
values(): IterableIterator<FormDataEntryValue>;
|
|
267
|
+
/**
|
|
268
|
+
* forEach iteration
|
|
269
|
+
*/
|
|
270
|
+
forEach(callback: (value: FormDataEntryValue, key: string, parent: FormData) => void): void;
|
|
271
|
+
/**
|
|
272
|
+
* Get all field names
|
|
273
|
+
*/
|
|
274
|
+
getFieldNames(): string[];
|
|
275
|
+
}
|
|
276
|
+
export {};
|
|
277
|
+
//# sourceMappingURL=form-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-data.d.ts","sourceRoot":"","sources":["../../../src/types/form-data/form-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE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M,GAAG,kBAAkB,EAAE;IAI1C;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAQhE;;OAEG;IACH,OAAO,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAIzD;;OAEG;IACH,IAAI,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAIhC;;OAEG;IACH,MAAM,IAAI,gBAAgB,CAAC,kBAAkB,CAAC;IAI9C;;OAEG;IACH,OAAO,CACL,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,KAAK,IAAI,GAC3E,IAAI;IAIP;;OAEG;IACH,aAAa,IAAI,MAAM,EAAE;CAS1B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticFormData Module
|
|
3
|
+
* LLM-enhanced FormData type with semantic understanding
|
|
4
|
+
*/
|
|
5
|
+
export { SemanticFormData, type FormDataSemanticEqualsResult, type FormDataValidateResult, type FormDataSemanticGetResult, type FormDataInferPurposeResult, type FormDataDetectSensitiveResult, type FormDataMissingSuggestion, type FileValidationRules, type FormDataFileValidateResult, type FormDataLLMClientInterface, } from './form-data.ts';
|
|
6
|
+
export type { SemanticEqualsResult } from '../../shared/types.ts';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/form-data/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,gBAAgB,EAChB,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EAClC,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,GAChC,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for SemanticFormData LLM operations
|
|
3
|
+
* These prompts are used for various semantic form data operations that require LLM understanding
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System prompt for semantic form data equality comparison
|
|
7
|
+
*/
|
|
8
|
+
export declare const SEMANTIC_EQUALS_SYSTEM = "You are a form data comparison assistant. Your task is to determine if two sets of form data are semantically equivalent.\n\nConsider these factors when comparing:\n- Field name variations (e.g., \"firstName\" vs \"first_name\" vs \"first-name\")\n- Similar field meanings (e.g., \"email\" vs \"emailAddress\" vs \"user_email\")\n- Value equivalence (same data, different formatting)\n- Missing fields that may have default values\n- Field ordering (typically irrelevant)\n\nAlways respond with valid JSON only.";
|
|
9
|
+
/**
|
|
10
|
+
* User prompt template for semantic form data equality
|
|
11
|
+
*/
|
|
12
|
+
export declare function semanticEqualsPrompt(fields1: string, fields2: string, context?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* System prompt for form validation
|
|
15
|
+
*/
|
|
16
|
+
export declare const VALIDATE_SYSTEM = "You are a form validation assistant. Your task is to validate form data against semantic rules described in natural language.\n\nConsider:\n- Field value formats (email, phone, date patterns)\n- Required field presence\n- Value constraints (length, range, allowed values)\n- Cross-field validations (password confirmation, date ranges)\n- Business logic rules\n\nAlways respond with valid JSON only.";
|
|
17
|
+
/**
|
|
18
|
+
* User prompt template for form validation
|
|
19
|
+
*/
|
|
20
|
+
export declare function validatePrompt(fields: string, rules: string[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* System prompt for semantic field access
|
|
23
|
+
*/
|
|
24
|
+
export declare const SEMANTIC_GET_SYSTEM = "You are a form field matching assistant. Your task is to find form fields that match a semantic query.\n\nConsider:\n- Field name variations and conventions\n- Common abbreviations (e.g., \"addr\" for \"address\", \"tel\" for \"telephone\")\n- Semantic meaning beyond exact name matching\n- Context clues from other fields\n\nAlways respond with valid JSON only.";
|
|
25
|
+
/**
|
|
26
|
+
* User prompt template for semantic field access
|
|
27
|
+
*/
|
|
28
|
+
export declare function semanticGetPrompt(fields: string, query: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* System prompt for inferring form purpose
|
|
31
|
+
*/
|
|
32
|
+
export declare const INFER_PURPOSE_SYSTEM = "You are a form analysis assistant. Your task is to determine the purpose of a form based on its fields.\n\nCommon form purposes include:\n- user-registration: Sign-up forms with email, password, name\n- login: Authentication with username/email and password\n- contact: Contact forms with message, email, name\n- checkout: Payment forms with address, card details\n- profile-update: Profile editing with personal information\n- search: Search forms with query fields\n- feedback: Forms collecting user opinions\n- newsletter-signup: Email subscription forms\n- booking: Reservation forms with dates, times\n- file-upload: Forms for uploading documents/media\n\nAlways respond with valid JSON only.";
|
|
33
|
+
/**
|
|
34
|
+
* User prompt template for purpose inference
|
|
35
|
+
*/
|
|
36
|
+
export declare function inferPurposePrompt(fields: string, context?: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* System prompt for detecting sensitive data
|
|
39
|
+
*/
|
|
40
|
+
export declare const DETECT_SENSITIVE_SYSTEM = "You are a data sensitivity analyst. Your task is to identify sensitive data in form fields.\n\nCategories of sensitive data:\n- Personally Identifiable Information (PII): name, email, phone, address\n- Financial: credit card, bank account, SSN\n- Authentication: password, PIN, security questions\n- Health: medical information, health conditions\n- Legal: government IDs, legal documents\n\nSecurity recommendations:\n- Use HTTPS for transmission\n- Encrypt at rest\n- Minimize data collection\n- Implement access controls\n\nAlways respond with valid JSON only.";
|
|
41
|
+
/**
|
|
42
|
+
* User prompt template for sensitive data detection
|
|
43
|
+
*/
|
|
44
|
+
export declare function detectSensitivePrompt(fields: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* System prompt for suggesting missing fields
|
|
47
|
+
*/
|
|
48
|
+
export declare const SUGGEST_MISSING_SYSTEM = "You are a form design assistant. Your task is to suggest missing fields based on the form's purpose and existing fields.\n\nConsider:\n- Common patterns for the form type\n- Required vs optional fields\n- User experience best practices\n- Data completeness requirements\n- Regulatory requirements (GDPR consent, terms acceptance)\n\nAlways respond with valid JSON only.";
|
|
49
|
+
/**
|
|
50
|
+
* User prompt template for missing field suggestions
|
|
51
|
+
*/
|
|
52
|
+
export declare function suggestMissingFieldsPrompt(fields: string, purpose?: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* System prompt for file validation
|
|
55
|
+
*/
|
|
56
|
+
export declare const VALIDATE_FILES_SYSTEM = "You are a file validation assistant. Your task is to validate file uploads in form data.\n\nConsider:\n- File size limits (parse human-readable sizes like \"5MB\", \"1GB\")\n- MIME type restrictions\n- File extension matching\n- Security concerns (executable files, scripts)\n\nAlways respond with valid JSON only.";
|
|
57
|
+
/**
|
|
58
|
+
* User prompt template for file validation
|
|
59
|
+
*/
|
|
60
|
+
export declare function validateFilesPrompt(files: string, rules: {
|
|
61
|
+
maxSize?: string;
|
|
62
|
+
allowedTypes?: string[];
|
|
63
|
+
}): string;
|
|
64
|
+
/**
|
|
65
|
+
* System prompt for form explanation
|
|
66
|
+
*/
|
|
67
|
+
export declare const EXPLAIN_SYSTEM = "You are a form description assistant. Your task is to explain what a form is for in human-readable terms.\n\nConsider:\n- The purpose of the form\n- What data it collects\n- Who might use it\n- Key fields and their purposes\n\nAlways respond with valid JSON only.";
|
|
68
|
+
/**
|
|
69
|
+
* User prompt template for form explanation
|
|
70
|
+
*/
|
|
71
|
+
export declare function explainPrompt(fields: string, context?: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* System prompt for converting field names
|
|
74
|
+
*/
|
|
75
|
+
export declare const TO_OBJECT_SYSTEM = "You are a naming convention assistant. Your task is to convert form field names to a target naming convention.\n\nNaming conventions:\n- camelCase: firstName, lastName, emailAddress\n- snake_case: first_name, last_name, email_address\n\nAlways respond with valid JSON only.";
|
|
76
|
+
/**
|
|
77
|
+
* User prompt template for field name conversion
|
|
78
|
+
*/
|
|
79
|
+
export declare function toObjectPrompt(fields: string, targetConvention: 'camelCase' | 'snake_case'): string;
|
|
80
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/types/form-data/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;GAEG;AACH,eAAO,MAAM,sBAAsB,ogBASE,CAAC;AAEtC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAcR;AAMD;;GAEG;AACH,eAAO,MAAM,eAAe,oZASS,CAAC;AAEtC;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CActE;AAMD;;GAEG;AACH,eAAO,MAAM,mBAAmB,+WAQK,CAAC;AAEtC;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAYvE;AAMD;;GAEG;AACH,eAAO,MAAM,oBAAoB,8rBAcI,CAAC;AAEtC;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAS3E;AAMD;;GAEG;AACH,eAAO,MAAM,uBAAuB,wjBAeC,CAAC;AAEtC;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQ5D;AAMD;;GAEG;AACH,eAAO,MAAM,sBAAsB,sXASE,CAAC;AAEtC;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAWR;AAMD;;GAEG;AACH,eAAO,MAAM,qBAAqB,+TAQG,CAAC;AAEtC;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GACnD,MAAM,CAWR;AAMD;;GAEG;AACH,eAAO,MAAM,cAAc,4QAQU,CAAC;AAEtC;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAStE;AAMD;;GAEG;AACH,eAAO,MAAM,gBAAgB,sRAMQ,CAAC;AAEtC;;GAEG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,WAAW,GAAG,YAAY,GAC3C,MAAM,CAQR"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic Types
|
|
3
|
+
* LLM-enhanced reference and structural types
|
|
4
|
+
*/
|
|
5
|
+
export { type SemanticEqualsResult, type DurationResult, type InferMeaningResult } from '../shared/types.ts';
|
|
6
|
+
export { SemanticDate, type ParseDateOptions, type DatePrecision, type DateSemanticEqualsOptions, type DateLLMClientInterface, } from './date/index.ts';
|
|
7
|
+
export { SemanticArray, type ArraySemanticEqualsOptions, type SemanticSearchOptions, type SummarizeOptions, type SemanticUniqueOptions, type ArrayValidateResult, type ArrayInferTypeResult, type ArrayDetectPatternResult, } from './array/index.ts';
|
|
8
|
+
export { SemanticError, type ErrorClassifyResult, type ResourceSuggestion, type ReportRecommendation, type SemanticEqualsResultWithReason, type RootCauseResult, type SuggestedFix, type RecoveryStrategy, type ErrorSeverityLevel, } from './error/index.ts';
|
|
9
|
+
export { SemanticPromise, type PromiseState, type PromiseStatus, type InferredOperation, type RetryOptions, type ValidationResult, type SemanticErrorAnalysis, } from './promise/index.ts';
|
|
10
|
+
export { SemanticRegExp, type FromOptions as RegExpFromOptions, type TestWithExplanationResult, type SimplifyResult, type ImprovementSuggestion, type RegExpTestCases, type ValidateResultWithWarnings, type RelatedSuggestion, type InferTypeResult, } from './regexp/index.ts';
|
|
11
|
+
export { SemanticURL, type URLSemanticEqualsResult, type URLClassifyResult, type URLValidateForResult, type ParsedQueryParam, type URLLLMClientInterface, } from './url/index.ts';
|
|
12
|
+
export { SemanticObject, type ObjectValidateResult, type SemanticMergeOptions as ObjectSemanticMergeOptions, type KeyConvention, type SemanticEqualsResultWithMappings, type SemanticGetResult as ObjectSemanticGetResult, type InferSchemaResult, type MissingSuggestion as ObjectMissingSuggestion, type InferTypeResult as ObjectInferTypeResult, type SensitiveResult, } from './object/index.ts';
|
|
13
|
+
export { SemanticMap, type SemanticMergeOptions as MapSemanticMergeOptions, type MapValidationRules, type FindKeyResult, type FindValueResult, type MapSemanticEqualsResult, type SemanticGetResult as MapSemanticGetResult, type ValidateResult, type MissingSuggestion as MapMissingSuggestion, type InferPurposeResult, } from './map/index.ts';
|
|
14
|
+
export { SemanticSet, type SemanticHasResult, type SemanticAddResult, type SetSemanticEqualsResult, type SetSummarizeOptions, type SetValidateResult, type InferThemeResult, } from './set/index.ts';
|
|
15
|
+
export { SemanticEventEmitter, type EventClassifyResult, type ValidateHandlersResult, type ValidateEventNameResult, type HandlerSuggestion, type AnalyzeFlowResult, type MonitorOptions, } from './event-emitter/index.ts';
|
|
16
|
+
export { SemanticRequest, SemanticResponse, SemanticHeaders, type RequestSemanticEqualsResult, type RequestFilter, type RequestIntentResult, type RequestSecurityResult, type RequestLLMClientInterface, type ResponseAnalysisResult, type ResponseContract, type ErrorInterpretationResult, type ResponseLLMClientInterface, type HeadersSemanticEqualsResult, type HeaderIssue, type HeadersValidateResult, type HeaderSuggestion, type HeadersLLMClientInterface, } from './fetch/index.ts';
|
|
17
|
+
export { SemanticTextEncoder, SemanticTextDecoder, SemanticTextCodec, type TextCodecLLMClientInterface, type EncodeWithAnalysisResult, type CanEncodeResult, type DetectEncodingResult, type DecodeWithAnalysisResult, type RepairMojibakeResult, type AreEquivalentResult, type TranscodeResult, type EncodingIssue, type ValidateEncodingResult, type SuggestEncodingResult, type ExplainErrorResult, } from './text-codec/index.ts';
|
|
18
|
+
export { SemanticFormData, type FormDataSemanticEqualsResult, type FormDataValidateResult, type FormDataSemanticGetResult, type FormDataInferPurposeResult, type FormDataDetectSensitiveResult, type FormDataMissingSuggestion, type FileValidationRules, type FormDataFileValidateResult, type FormDataLLMClientInterface, } from './form-data/index.ts';
|
|
19
|
+
export { SemanticBun, SemanticBunFileRef, analyzeServerConfig, suggestServerConfig, isCommandSafe, explainCommand, suggestSaferCommand, validateEnv, detectSensitiveEnv, getEnv, type FileTypeResult, type ServerConfigAnalysis, type CommandSafetyResult, type SaferCommandSuggestion, type EnvValidationResult, type SensitiveEnvResult, type BunLLMClientInterface, } from './bun/index.ts';
|
|
20
|
+
export { SemanticBlob, SemanticFile, type BlobSemanticEqualsResult, type ContentTypeResult, type AnalyzeResult, type ValidateForResult, type SafetyResult as BlobSafetyResult, type BlobLLMClientInterface, type FilenameValidationResult, type ExtensionValidationResult, type CategoryResult, type FilenameSuggestionResult, type FileLLMClientInterface, } from './blob-file/index.ts';
|
|
21
|
+
export { SemanticReadableStream, SemanticWritableStream, SemanticTransformStream, type DetectContentTypeResult, type StreamSemanticEqualsResult, type DetectPatternsResult, type InferSchemaResult as StreamInferSchemaResult, type StreamValidationItem, type WriteStats, } from './streams/index.ts';
|
|
22
|
+
export { SemanticNever, type UnreachabilityType, type ExhaustiveResult, type UnreachabilityResult, type DeadCodeResult, type ExhaustiveHandlerResult, type ValidateExhaustivenessResult, type ShouldReturnNeverResult, type IntersectionAnalysisResult, type NeverPattern, } from './never/index.ts';
|
|
23
|
+
export { SemanticUnknown, type BasicType, type UnknownInferTypeResult, type TypeSuggestion, type ValidateShapeResult, type GenerateTypeGuardResult, type MatchesResult, type NarrowToResult, } from './unknown/index.ts';
|
|
24
|
+
export { SemanticObjectLiteral, type ObjectLiteralValidateResult, type DetectDomainResult, type PropertySearchResult, type MissingPropertySuggestion, type KeyConvention as ObjectLiteralKeyConvention, type SemanticEqualsResultWithMappings as ObjectLiteralSemanticEqualsResult, type InferSchemaResult as ObjectLiteralInferSchemaResult, type SensitiveResult as ObjectLiteralSensitiveResult, } from './object-literal/index.ts';
|
|
25
|
+
export { SemanticCallable, type InferredSignature, type WrapperSuggestion, type CallableTestCase, type DetectedIssue, type SafetyResult as CallableSafetyResult, } from './callable/index.ts';
|
|
26
|
+
export { SemanticConstructable, type Constructor, type ConstructableSemanticEqualsResult, type InstanceShapeResult, type CreateValidatedResult, type DocFormat, } from './constructable/index.ts';
|
|
27
|
+
export { SemanticTuple, type PositionalMeaning, type InferPositionalMeaningResult, type ValidateRelationshipResult, type ToObjectResult, type GetByLabelResult, type StructureIssue, type ValidateStructureResult, type SemanticEqualsResultWithReason as TupleSemanticEqualsResult, type DetectPatternResult as TupleDetectPatternResult, } from './tuple/index.ts';
|
|
28
|
+
export { SemanticRecord, type RecordSemanticEqualsResult, type ValidateKeysResult, type ValidateValuesResult, type InvalidEntry, type RecordInferPurposeResult, type SemanticGetResult as RecordSemanticGetResult, type MissingSuggestion as RecordMissingSuggestion, } from './record/index.ts';
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG7G,OAAO,EACL,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,GAC5B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,aAAa,EACb,KAAK,0BAA0B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,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,IAAI,uBAAuB,EACjD,KAAK,iBAAiB,IAAI,uBAAuB,GAClD,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticMap module
|
|
3
|
+
* LLM-enhanced Map type with semantic understanding
|
|
4
|
+
*/
|
|
5
|
+
export { SemanticMap, type SemanticMergeOptions, type MapValidationRules, type FindKeyResult, type FindValueResult, type MapSemanticEqualsResult, type SemanticGetResult, type ValidateResult, type MissingSuggestion, type InferPurposeResult, } from './map.ts';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/map/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,WAAW,EACX,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticMap
|
|
3
|
+
* A Map type with LLM-powered semantic understanding
|
|
4
|
+
*
|
|
5
|
+
* Implements shared interfaces:
|
|
6
|
+
* - Semantic<Map<K, V>> - Base semantic wrapper
|
|
7
|
+
* - Comparable<SemanticMap<K, V>> - Semantic equality comparison
|
|
8
|
+
* - Validatable - Validation against semantic rules
|
|
9
|
+
* - Summarizable - Content summarization
|
|
10
|
+
* - SemanticAccessible - Semantic key lookup
|
|
11
|
+
* - SemanticGroupable - Semantic grouping
|
|
12
|
+
* - PurposeInferable - Purpose inference
|
|
13
|
+
*/
|
|
14
|
+
import type { LLMClient } from '../../llm/client.ts';
|
|
15
|
+
import type { SemanticGetResult, ValidateResult, MissingSuggestion, InferPurposeResult } from '../../shared/types.ts';
|
|
16
|
+
import type { Semantic, Comparable } from '../../shared/interfaces.ts';
|
|
17
|
+
export type { SemanticGetResult, ValidateResult, MissingSuggestion, InferPurposeResult, } from '../../shared/types.ts';
|
|
18
|
+
/** Options for semantic merge */
|
|
19
|
+
export interface SemanticMergeOptions {
|
|
20
|
+
conflictResolution?: 'prefer-this' | 'prefer-other' | 'combine';
|
|
21
|
+
}
|
|
22
|
+
/** Validation rules for map */
|
|
23
|
+
export interface MapValidationRules {
|
|
24
|
+
keys?: string;
|
|
25
|
+
values?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Result of finding keys */
|
|
28
|
+
export interface FindKeyResult<K> {
|
|
29
|
+
key: K;
|
|
30
|
+
relevance: number;
|
|
31
|
+
}
|
|
32
|
+
/** Result of finding values */
|
|
33
|
+
export interface FindValueResult<K, V> {
|
|
34
|
+
key: K;
|
|
35
|
+
value: V;
|
|
36
|
+
relevance: number;
|
|
37
|
+
}
|
|
38
|
+
/** Result of semantic equality comparison for maps */
|
|
39
|
+
export interface MapSemanticEqualsResult {
|
|
40
|
+
equivalent: boolean;
|
|
41
|
+
keyMappings?: [string, string][];
|
|
42
|
+
confidence: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* SemanticMap - Map with LLM-powered semantic understanding
|
|
46
|
+
*
|
|
47
|
+
* Unlike traditional maps that only support exact key matching,
|
|
48
|
+
* semantic maps can look up values using natural language queries,
|
|
49
|
+
* find semantically equivalent keys, and understand key-value relationships.
|
|
50
|
+
*
|
|
51
|
+
* @template K - The type of keys in the map
|
|
52
|
+
* @template V - The type of values in the map
|
|
53
|
+
*/
|
|
54
|
+
export declare class SemanticMap<K, V> implements Semantic<Map<K, V>>, Comparable<SemanticMap<K, V> | Map<K, V>, MapSemanticEqualsResult> {
|
|
55
|
+
private readonly internalMap;
|
|
56
|
+
private readonly client;
|
|
57
|
+
private constructor();
|
|
58
|
+
/**
|
|
59
|
+
* Create a SemanticMap from an existing Map or entries
|
|
60
|
+
*/
|
|
61
|
+
static from<K, V>(source: Map<K, V> | Iterable<readonly [K, V]>, client?: LLMClient): SemanticMap<K, V>;
|
|
62
|
+
/**
|
|
63
|
+
* Create an empty SemanticMap
|
|
64
|
+
*/
|
|
65
|
+
static empty<K, V>(client?: LLMClient): SemanticMap<K, V>;
|
|
66
|
+
/**
|
|
67
|
+
* Create a SemanticMap from key-value pairs
|
|
68
|
+
*/
|
|
69
|
+
static of<K, V>(...entries: (readonly [K, V])[]): SemanticMap<K, V>;
|
|
70
|
+
/**
|
|
71
|
+
* Get the underlying Map value
|
|
72
|
+
*/
|
|
73
|
+
valueOf(): Map<K, V>;
|
|
74
|
+
/**
|
|
75
|
+
* Get the size of the map
|
|
76
|
+
*/
|
|
77
|
+
get size(): number;
|
|
78
|
+
/**
|
|
79
|
+
* Get a value by exact key
|
|
80
|
+
*/
|
|
81
|
+
get(key: K): V | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Check if map has exact key
|
|
84
|
+
*/
|
|
85
|
+
has(key: K): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Set a key-value pair (returns new SemanticMap)
|
|
88
|
+
*/
|
|
89
|
+
set(key: K, value: V): SemanticMap<K, V>;
|
|
90
|
+
/**
|
|
91
|
+
* Delete a key (returns new SemanticMap)
|
|
92
|
+
*/
|
|
93
|
+
delete(key: K): SemanticMap<K, V>;
|
|
94
|
+
/**
|
|
95
|
+
* Get all keys
|
|
96
|
+
*/
|
|
97
|
+
keys(): IterableIterator<K>;
|
|
98
|
+
/**
|
|
99
|
+
* Get all values
|
|
100
|
+
*/
|
|
101
|
+
values(): IterableIterator<V>;
|
|
102
|
+
/**
|
|
103
|
+
* Get all entries
|
|
104
|
+
*/
|
|
105
|
+
entries(): IterableIterator<[K, V]>;
|
|
106
|
+
/**
|
|
107
|
+
* Get a value using semantic key matching.
|
|
108
|
+
* Finds the key that best matches the query, not just exact matches.
|
|
109
|
+
*
|
|
110
|
+
* @param query - Key or semantic query
|
|
111
|
+
* @param context - Optional context for matching
|
|
112
|
+
* @returns Value if found with match confidence
|
|
113
|
+
*/
|
|
114
|
+
semanticGet(query: string, context?: Record<string, unknown>): Promise<SemanticGetResult<K, V>>;
|
|
115
|
+
/**
|
|
116
|
+
* Check if the map contains a semantically matching key.
|
|
117
|
+
*
|
|
118
|
+
* @param query - Key or semantic query
|
|
119
|
+
* @returns Whether a matching key exists
|
|
120
|
+
*/
|
|
121
|
+
semanticHas(query: string): Promise<boolean>;
|
|
122
|
+
/**
|
|
123
|
+
* Check if two maps are semantically equivalent.
|
|
124
|
+
*
|
|
125
|
+
* @param other - Map to compare with
|
|
126
|
+
* @returns Equivalence result with key mappings
|
|
127
|
+
*/
|
|
128
|
+
semanticallyEquals(other: SemanticMap<K, V> | Map<K, V>): Promise<MapSemanticEqualsResult>;
|
|
129
|
+
/**
|
|
130
|
+
* Find all keys matching semantic criteria.
|
|
131
|
+
*
|
|
132
|
+
* @param criteria - Natural language criteria
|
|
133
|
+
* @returns Matching keys with relevance
|
|
134
|
+
*/
|
|
135
|
+
findKeys(criteria: string): Promise<FindKeyResult<K>[]>;
|
|
136
|
+
/**
|
|
137
|
+
* Find all values matching semantic criteria.
|
|
138
|
+
*
|
|
139
|
+
* @param criteria - Natural language criteria
|
|
140
|
+
* @returns Matching entries with relevance
|
|
141
|
+
*/
|
|
142
|
+
findValues(criteria: string): Promise<FindValueResult<K, V>[]>;
|
|
143
|
+
/**
|
|
144
|
+
* Merge another map with semantic key matching.
|
|
145
|
+
*
|
|
146
|
+
* @param other - Map to merge
|
|
147
|
+
* @param options - Merge options
|
|
148
|
+
* @returns Merged map
|
|
149
|
+
*/
|
|
150
|
+
semanticMerge(other: Map<K, V> | SemanticMap<K, V>, options?: SemanticMergeOptions): Promise<SemanticMap<K, V>>;
|
|
151
|
+
/**
|
|
152
|
+
* Validate all key-value pairs against semantic rules.
|
|
153
|
+
*
|
|
154
|
+
* @param rules - Validation rules for keys and/or values
|
|
155
|
+
* @returns Validation result
|
|
156
|
+
*/
|
|
157
|
+
validate(rules: MapValidationRules): Promise<ValidateResult>;
|
|
158
|
+
/**
|
|
159
|
+
* Suggest missing keys based on existing patterns.
|
|
160
|
+
*
|
|
161
|
+
* @returns Suggested keys with rationale
|
|
162
|
+
*/
|
|
163
|
+
suggestMissingKeys(): Promise<MissingSuggestion[]>;
|
|
164
|
+
/**
|
|
165
|
+
* Group entries by semantic criteria.
|
|
166
|
+
*
|
|
167
|
+
* @param criteria - Grouping criteria
|
|
168
|
+
* @returns Map of groups
|
|
169
|
+
*/
|
|
170
|
+
groupBy(criteria: string): Promise<Map<string, SemanticMap<K, V>>>;
|
|
171
|
+
/**
|
|
172
|
+
* Summarize the map contents.
|
|
173
|
+
*
|
|
174
|
+
* @returns Human-readable summary
|
|
175
|
+
*/
|
|
176
|
+
summarize(): Promise<string>;
|
|
177
|
+
/**
|
|
178
|
+
* Infer the semantic purpose of this map.
|
|
179
|
+
*
|
|
180
|
+
* @returns Inferred purpose
|
|
181
|
+
*/
|
|
182
|
+
inferPurpose(): Promise<InferPurposeResult>;
|
|
183
|
+
/**
|
|
184
|
+
* Execute a function for each entry
|
|
185
|
+
*/
|
|
186
|
+
forEach(callback: (value: V, key: K, map: Map<K, V>) => void): void;
|
|
187
|
+
/**
|
|
188
|
+
* Clear the map (returns new empty SemanticMap)
|
|
189
|
+
*/
|
|
190
|
+
clear(): SemanticMap<K, V>;
|
|
191
|
+
/**
|
|
192
|
+
* Iterator support
|
|
193
|
+
*/
|
|
194
|
+
[Symbol.iterator](): IterableIterator<[K, V]>;
|
|
195
|
+
/**
|
|
196
|
+
* Convert to string
|
|
197
|
+
*/
|
|
198
|
+
toString(): string;
|
|
199
|
+
/**
|
|
200
|
+
* Convert to JSON
|
|
201
|
+
*/
|
|
202
|
+
toJSON(): Record<string, V>;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@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