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,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticURL - LLM-enhanced URL type with semantic understanding
|
|
3
|
+
*
|
|
4
|
+
* Extends the native JavaScript URL with semantic operations including:
|
|
5
|
+
* - Intelligent URL parsing and normalization
|
|
6
|
+
* - Context-aware equality comparison
|
|
7
|
+
* - URL classification by type and purpose
|
|
8
|
+
* - Purpose-based validation
|
|
9
|
+
* - Safety assessment
|
|
10
|
+
* - Related URL suggestions
|
|
11
|
+
*
|
|
12
|
+
* Implements shared interfaces:
|
|
13
|
+
* - Semantic<URL> - Base semantic wrapper
|
|
14
|
+
* - Comparable<URL | string> - Semantic equality comparison
|
|
15
|
+
* - Classifiable - URL type classification
|
|
16
|
+
* - Explainable - Human-readable explanations
|
|
17
|
+
*/
|
|
18
|
+
import type { LLMConfig, Message } from '../../llm/types.ts';
|
|
19
|
+
import type { SemanticEqualsResult, ClassifyResult, SafetyResult, RelatedSuggestion } from '../../shared/types.ts';
|
|
20
|
+
import type { Semantic, Comparable, Classifiable, Explainable } from '../../shared/interfaces.ts';
|
|
21
|
+
export type { SemanticEqualsResult, ClassifyResult, SafetyResult, RelatedSuggestion, } from '../../shared/types.ts';
|
|
22
|
+
/** Extended semantic equals result with differences list */
|
|
23
|
+
export interface URLSemanticEqualsResult extends SemanticEqualsResult {
|
|
24
|
+
differences: string[];
|
|
25
|
+
}
|
|
26
|
+
/** Extended classify result for URLs */
|
|
27
|
+
export interface URLClassifyResult extends ClassifyResult {
|
|
28
|
+
type: string;
|
|
29
|
+
resource?: string;
|
|
30
|
+
action?: string;
|
|
31
|
+
}
|
|
32
|
+
/** Validation result for purpose-based validation */
|
|
33
|
+
export interface URLValidateForResult {
|
|
34
|
+
valid: boolean;
|
|
35
|
+
reason?: string;
|
|
36
|
+
warnings: string[];
|
|
37
|
+
}
|
|
38
|
+
/** Result of query parameter parsing */
|
|
39
|
+
export interface ParsedQueryParam {
|
|
40
|
+
value: string;
|
|
41
|
+
meaning: string;
|
|
42
|
+
}
|
|
43
|
+
/** LLM client interface for dependency injection */
|
|
44
|
+
export interface URLLLMClientInterface {
|
|
45
|
+
chat(options: {
|
|
46
|
+
messages: Message[];
|
|
47
|
+
systemPrompt?: string;
|
|
48
|
+
} & LLMConfig): Promise<{
|
|
49
|
+
content: string;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* SemanticURL class
|
|
54
|
+
* Wraps a URL value with LLM-powered semantic operations
|
|
55
|
+
*
|
|
56
|
+
* Implements:
|
|
57
|
+
* - Semantic<URL> - valueOf() returns the URL value
|
|
58
|
+
* - Comparable<URL | string> - semanticallyEquals() for comparison
|
|
59
|
+
* - Classifiable - classify() for URL type classification
|
|
60
|
+
* - Explainable - explain() for human-readable explanations
|
|
61
|
+
*
|
|
62
|
+
* Also provides (as async methods):
|
|
63
|
+
* - validateFor() for purpose-based validation
|
|
64
|
+
* - isSafe() for safety checks
|
|
65
|
+
* - suggestRelated() for related URL suggestions
|
|
66
|
+
*/
|
|
67
|
+
export declare class SemanticURL implements Semantic<URL>, Comparable<URL | string, URLSemanticEqualsResult>, Classifiable<URLClassifyResult>, Explainable {
|
|
68
|
+
private readonly _value;
|
|
69
|
+
private readonly _llmClient;
|
|
70
|
+
private readonly _llmConfig?;
|
|
71
|
+
/**
|
|
72
|
+
* Create a SemanticURL instance
|
|
73
|
+
* @param value - The URL value to wrap
|
|
74
|
+
* @param llmClient - Optional LLM client for dependency injection (useful for testing)
|
|
75
|
+
* @param llmConfig - Optional LLM configuration
|
|
76
|
+
*/
|
|
77
|
+
constructor(value: URL, llmClient?: URLLLMClientInterface, llmConfig?: LLMConfig);
|
|
78
|
+
/**
|
|
79
|
+
* Create a SemanticURL from a string, handling various formats.
|
|
80
|
+
*
|
|
81
|
+
* @param input - URL string, potentially incomplete or malformed
|
|
82
|
+
* @param base - Optional base URL
|
|
83
|
+
* @param llmClient - Optional LLM client for dependency injection
|
|
84
|
+
* @param llmConfig - Optional LLM configuration
|
|
85
|
+
* @returns SemanticURL instance
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* SemanticURL.from("example.com") // Adds https://
|
|
89
|
+
* SemanticURL.from("/path", "https://example.com")
|
|
90
|
+
*/
|
|
91
|
+
static from(input: string, base?: string, llmClient?: URLLLMClientInterface, llmConfig?: LLMConfig): SemanticURL;
|
|
92
|
+
/**
|
|
93
|
+
* Check if two URLs are semantically equivalent.
|
|
94
|
+
* Considers trailing slashes, default ports, www prefix, etc.
|
|
95
|
+
*
|
|
96
|
+
* @param other - URL to compare
|
|
97
|
+
* @returns Equivalence result with differences
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* url.semanticallyEquals("https://www.example.com/")
|
|
101
|
+
* // { equivalent: true, differences: ["www prefix", "trailing slash"], confidence: 0.95 }
|
|
102
|
+
*/
|
|
103
|
+
semanticallyEquals(other: string | URL, _options?: Record<string, unknown>): Promise<URLSemanticEqualsResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Classify the URL by type and purpose.
|
|
106
|
+
*
|
|
107
|
+
* @returns URL classification
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* url.classify()
|
|
111
|
+
* // { type: "api-endpoint", category: "rest-api", resource: "users", action: "list", confidence: 0.9 }
|
|
112
|
+
*/
|
|
113
|
+
classify(): Promise<URLClassifyResult>;
|
|
114
|
+
/**
|
|
115
|
+
* Validate the URL for a specific purpose.
|
|
116
|
+
*
|
|
117
|
+
* @param purpose - Intended purpose of the URL
|
|
118
|
+
* @returns Validation result
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* url.validateFor("public website")
|
|
122
|
+
* // { valid: true, warnings: ["Uses HTTP instead of HTTPS"] }
|
|
123
|
+
*/
|
|
124
|
+
validateFor(purpose: string): Promise<URLValidateForResult>;
|
|
125
|
+
/**
|
|
126
|
+
* Explain what this URL points to.
|
|
127
|
+
*
|
|
128
|
+
* @param _context - Optional context for explanation (unused, for interface compatibility)
|
|
129
|
+
* @returns Human-readable description
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* SemanticURL.from("https://api.github.com/users/octocat").explain()
|
|
133
|
+
* // "GitHub API endpoint to fetch the user profile for 'octocat'"
|
|
134
|
+
*/
|
|
135
|
+
explain(_context?: string): Promise<string>;
|
|
136
|
+
/**
|
|
137
|
+
* Extract semantic information from URL components.
|
|
138
|
+
*
|
|
139
|
+
* @returns Extracted information
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* url.extractInfo()
|
|
143
|
+
* // { service: "GitHub", resourceType: "user-profile", identifier: "octocat" }
|
|
144
|
+
*/
|
|
145
|
+
extractInfo(): Promise<Record<string, string | undefined>>;
|
|
146
|
+
/**
|
|
147
|
+
* Check if the URL is safe to visit/request.
|
|
148
|
+
*
|
|
149
|
+
* @param _context - Optional context (unused, for interface compatibility)
|
|
150
|
+
* @returns Safety assessment
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* url.isSafe()
|
|
154
|
+
* // { safe: false, reason: "Known phishing domain", severity: "high" }
|
|
155
|
+
*/
|
|
156
|
+
isSafe(_context?: string): Promise<SafetyResult>;
|
|
157
|
+
/**
|
|
158
|
+
* Suggest the canonical form of this URL.
|
|
159
|
+
*
|
|
160
|
+
* @returns Canonical URL
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* SemanticURL.from("HTTP://EXAMPLE.COM:80/path/").canonical()
|
|
164
|
+
* // SemanticURL for "https://example.com/path"
|
|
165
|
+
*/
|
|
166
|
+
canonical(): Promise<SemanticURL>;
|
|
167
|
+
/**
|
|
168
|
+
* Generate variations of this URL.
|
|
169
|
+
*
|
|
170
|
+
* @returns URL variations
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* url.variations()
|
|
174
|
+
* // ["https://example.com", "https://www.example.com", "http://example.com"]
|
|
175
|
+
*/
|
|
176
|
+
variations(): Promise<string[]>;
|
|
177
|
+
/**
|
|
178
|
+
* Parse query parameters with semantic understanding.
|
|
179
|
+
*
|
|
180
|
+
* @returns Parsed parameters with meanings
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* SemanticURL.from("https://api.example.com/search?q=test&limit=10").parseQuery()
|
|
184
|
+
* // { q: { value: "test", meaning: "search query" }, limit: { value: "10", meaning: "results limit" } }
|
|
185
|
+
*/
|
|
186
|
+
parseQuery(): Promise<Record<string, ParsedQueryParam>>;
|
|
187
|
+
/**
|
|
188
|
+
* Suggest related URLs based on patterns.
|
|
189
|
+
*
|
|
190
|
+
* @returns Related URLs
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* url.suggestRelated()
|
|
194
|
+
* // [{ url: "/users/octocat/repos", reason: "User's repositories" }]
|
|
195
|
+
*/
|
|
196
|
+
suggestRelated(): Promise<RelatedSuggestion[]>;
|
|
197
|
+
/**
|
|
198
|
+
* Check if URL matches a pattern description.
|
|
199
|
+
*
|
|
200
|
+
* @param pattern - Pattern description
|
|
201
|
+
* @returns Match result
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* url.matches("API endpoint")
|
|
205
|
+
* url.matches("image URL")
|
|
206
|
+
*/
|
|
207
|
+
matches(pattern: string): Promise<boolean>;
|
|
208
|
+
/**
|
|
209
|
+
* Get the raw URL value
|
|
210
|
+
* @returns The underlying URL
|
|
211
|
+
*/
|
|
212
|
+
valueOf(): URL;
|
|
213
|
+
/**
|
|
214
|
+
* Get the full URL string
|
|
215
|
+
*/
|
|
216
|
+
get href(): string;
|
|
217
|
+
/**
|
|
218
|
+
* Get the protocol (e.g., "https:")
|
|
219
|
+
*/
|
|
220
|
+
get protocol(): string;
|
|
221
|
+
/**
|
|
222
|
+
* Get the hostname
|
|
223
|
+
*/
|
|
224
|
+
get hostname(): string;
|
|
225
|
+
/**
|
|
226
|
+
* Get the host (hostname:port)
|
|
227
|
+
*/
|
|
228
|
+
get host(): string;
|
|
229
|
+
/**
|
|
230
|
+
* Get the port
|
|
231
|
+
*/
|
|
232
|
+
get port(): string;
|
|
233
|
+
/**
|
|
234
|
+
* Get the pathname
|
|
235
|
+
*/
|
|
236
|
+
get pathname(): string;
|
|
237
|
+
/**
|
|
238
|
+
* Get the search string (query string including ?)
|
|
239
|
+
*/
|
|
240
|
+
get search(): string;
|
|
241
|
+
/**
|
|
242
|
+
* Get the search params
|
|
243
|
+
*/
|
|
244
|
+
get searchParams(): URLSearchParams;
|
|
245
|
+
/**
|
|
246
|
+
* Get the hash (fragment including #)
|
|
247
|
+
*/
|
|
248
|
+
get hash(): string;
|
|
249
|
+
/**
|
|
250
|
+
* Get the origin
|
|
251
|
+
*/
|
|
252
|
+
get origin(): string;
|
|
253
|
+
/**
|
|
254
|
+
* Get the username
|
|
255
|
+
*/
|
|
256
|
+
get username(): string;
|
|
257
|
+
/**
|
|
258
|
+
* Get the password
|
|
259
|
+
*/
|
|
260
|
+
get password(): string;
|
|
261
|
+
/**
|
|
262
|
+
* Convert to string
|
|
263
|
+
*/
|
|
264
|
+
toString(): string;
|
|
265
|
+
/**
|
|
266
|
+
* Convert to JSON
|
|
267
|
+
*/
|
|
268
|
+
toJSON(): string;
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/types/url/url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,WAAW,EACZ,MAAM,4BAA4B,CAAC;AA2BpC,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I,GAAG;IAMd;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,eAAe,CAElC;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,MAAM,IAAI,MAAM;CAGjB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "semantic-primitives",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript library providing LLM-enhanced primitive types with built-in semantic understanding",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./llm": {
|
|
15
|
+
"types": "./dist/llm/index.d.ts",
|
|
16
|
+
"import": "./dist/llm/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./primitives": {
|
|
19
|
+
"types": "./dist/primitives/index.d.ts",
|
|
20
|
+
"import": "./dist/primitives/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "bun build ./src/index.ts --outdir ./dist --target node && bun run build:types",
|
|
28
|
+
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
29
|
+
"dev": "bun run --watch src/index.ts",
|
|
30
|
+
"test": "bun test",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"lint": "eslint src/",
|
|
33
|
+
"lint:fix": "eslint src/ --fix",
|
|
34
|
+
"check": "bun run typecheck && bun run lint",
|
|
35
|
+
"clean": "rm -rf dist",
|
|
36
|
+
"prepublishOnly": "bun run clean && bun run check && bun run test && bun run build",
|
|
37
|
+
"version:patch": "npm version patch",
|
|
38
|
+
"version:minor": "npm version minor",
|
|
39
|
+
"version:major": "npm version major"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/elicollinson/semantic-primitives.git"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/elicollinson/semantic-primitives#readme",
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/elicollinson/semantic-primitives/issues"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"llm",
|
|
51
|
+
"ai",
|
|
52
|
+
"semantic",
|
|
53
|
+
"primitives",
|
|
54
|
+
"typescript",
|
|
55
|
+
"openai",
|
|
56
|
+
"anthropic",
|
|
57
|
+
"google"
|
|
58
|
+
],
|
|
59
|
+
"author": "Eli Collinson",
|
|
60
|
+
"license": "Apache-2.0",
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@eslint/js": "^9.39.2",
|
|
63
|
+
"@types/bun": "latest",
|
|
64
|
+
"eslint": "^9.39.2",
|
|
65
|
+
"typescript": "^5",
|
|
66
|
+
"typescript-eslint": "^8.53.1"
|
|
67
|
+
},
|
|
68
|
+
"dependencies": {
|
|
69
|
+
"@anthropic-ai/sdk": "^0.71.2",
|
|
70
|
+
"@google/generative-ai": "^0.24.1",
|
|
71
|
+
"openai": "^6.16.0"
|
|
72
|
+
}
|
|
73
|
+
}
|