tjs-lang 0.6.19 → 0.6.26
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/CLAUDE.md +29 -24
- package/bin/dev.ts +9 -0
- package/demo/docs.json +49 -1
- package/demo/src/playground-shared.ts +8 -39
- package/demo/src/tjs-playground.ts +8 -0
- package/demo/src/tjs-runtime-iframe.ts +10 -0
- package/demo/src/ts-playground.ts +8 -0
- package/package.json +1 -1
- package/src/cli/commands/run.ts +4 -1
- package/src/cli/tjs.ts +1 -1
- package/src/lang/codegen.test.ts +26 -27
- package/src/lang/emitters/dts.test.ts +22 -0
- package/src/lang/emitters/dts.ts +5 -1
- package/src/lang/emitters/js-tests.ts +13 -19
- package/src/lang/emitters/js.ts +39 -7
- package/src/lang/parser-transforms.ts +18 -5
- package/src/lang/roundtrip.test.ts +1 -1
- package/src/lang/runtime.ts +88 -2
- package/src/lang/wasm.ts +1 -1
- package/dist/bin/benchmarks.d.ts +0 -9
- package/dist/bin/dev.d.ts +0 -1
- package/dist/bin/docs.d.ts +0 -1
- package/dist/bin/select-local-models.d.ts +0 -1
- package/dist/examples/modules/dist/main.d.ts +0 -34
- package/dist/examples/modules/dist/math.d.ts +0 -120
- package/dist/index.js +0 -426
- package/dist/index.js.map +0 -45
- package/dist/scripts/build-demo.d.ts +0 -2
- package/dist/scripts/build.d.ts +0 -11
- package/dist/scripts/seed-blog-rules.d.ts +0 -2
- package/dist/scripts/seed-stored-function.d.ts +0 -2
- package/dist/src/atoms/batteries.d.ts +0 -4
- package/dist/src/atoms/browser.d.ts +0 -4
- package/dist/src/atoms/index.d.ts +0 -4
- package/dist/src/batteries/audit.d.ts +0 -9
- package/dist/src/batteries/index.d.ts +0 -28
- package/dist/src/batteries/llm.d.ts +0 -18
- package/dist/src/batteries/models.d.ts +0 -19
- package/dist/src/batteries/store.d.ts +0 -13
- package/dist/src/builder.d.ts +0 -127
- package/dist/src/bun-plugin/tjs-plugin.d.ts +0 -12
- package/dist/src/cli/commands/check.d.ts +0 -4
- package/dist/src/cli/commands/convert.d.ts +0 -20
- package/dist/src/cli/commands/emit.d.ts +0 -34
- package/dist/src/cli/commands/run.d.ts +0 -6
- package/dist/src/cli/commands/test.d.ts +0 -21
- package/dist/src/cli/commands/types.d.ts +0 -4
- package/dist/src/cli/create-app.d.ts +0 -9
- package/dist/src/cli/playground.d.ts +0 -9
- package/dist/src/cli/tjs.d.ts +0 -15
- package/dist/src/cli/tjsx.d.ts +0 -16
- package/dist/src/index.d.ts +0 -11
- package/dist/src/inference.types.d.ts +0 -1
- package/dist/src/lang/core.d.ts +0 -56
- package/dist/src/lang/docs.d.ts +0 -69
- package/dist/src/lang/emitters/ast.d.ts +0 -24
- package/dist/src/lang/emitters/dts.d.ts +0 -48
- package/dist/src/lang/emitters/from-ts.d.ts +0 -94
- package/dist/src/lang/emitters/js-tests.d.ts +0 -70
- package/dist/src/lang/emitters/js-wasm.d.ts +0 -15
- package/dist/src/lang/emitters/js.d.ts +0 -175
- package/dist/src/lang/eval.d.ts +0 -63
- package/dist/src/lang/index.d.ts +0 -216
- package/dist/src/lang/inference.d.ts +0 -40
- package/dist/src/lang/linter.d.ts +0 -53
- package/dist/src/lang/metadata-cache.d.ts +0 -172
- package/dist/src/lang/parser-params.d.ts +0 -37
- package/dist/src/lang/parser-transforms.d.ts +0 -281
- package/dist/src/lang/parser-types.d.ts +0 -175
- package/dist/src/lang/parser.d.ts +0 -56
- package/dist/src/lang/runtime.d.ts +0 -454
- package/dist/src/lang/schema.d.ts +0 -35
- package/dist/src/lang/tests.d.ts +0 -94
- package/dist/src/lang/transpiler.d.ts +0 -25
- package/dist/src/lang/types.d.ts +0 -147
- package/dist/src/lang/wasm.d.ts +0 -83
- package/dist/src/rbac/index.d.ts +0 -85
- package/dist/src/rbac/rules.d.ts +0 -184
- package/dist/src/runtime.d.ts +0 -4
- package/dist/src/store/index.d.ts +0 -3
- package/dist/src/store/indexeddb.d.ts +0 -6
- package/dist/src/store/interface.d.ts +0 -90
- package/dist/src/store/memory.d.ts +0 -10
- package/dist/src/test-examples.d.ts +0 -41
- package/dist/src/test-utils.d.ts +0 -86
- package/dist/src/transpiler/index.d.ts +0 -6
- package/dist/src/transpiler/parser.d.ts +0 -4
- package/dist/src/transpiler/transformer.d.ts +0 -4
- package/dist/src/transpiler/type-system/inference.d.ts +0 -1
- package/dist/src/transpiler/types.d.ts +0 -4
- package/dist/src/types/LegalDate.d.ts +0 -241
- package/dist/src/types/Timestamp.d.ts +0 -233
- package/dist/src/types/Type.d.ts +0 -234
- package/dist/src/types/index.d.ts +0 -8
- package/dist/src/vm/atoms/batteries.d.ts +0 -6
- package/dist/src/vm/atoms/browser.d.ts +0 -18
- package/dist/src/vm/atoms/index.d.ts +0 -10
- package/dist/src/vm/index.d.ts +0 -12
- package/dist/src/vm/runtime.d.ts +0 -333
- package/dist/src/vm/vm.d.ts +0 -28
- package/dist/src/vm.d.ts +0 -4
- package/dist/test-preprocess.d.ts +0 -1
- package/dist/tjs-batteries.js +0 -4
- package/dist/tjs-batteries.js.map +0 -15
- package/dist/tjs-full.js +0 -426
- package/dist/tjs-full.js.map +0 -45
- package/dist/tjs-src/runtime.d.ts +0 -1
- package/dist/tjs-transpiler.js +0 -3
- package/dist/tjs-transpiler.js.map +0 -11
- package/dist/tjs-vm.js +0 -54
- package/dist/tjs-vm.js.map +0 -22
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Timestamp - Pure functions for ISO 8601 timestamp strings
|
|
3
|
-
*
|
|
4
|
-
* No Date warts:
|
|
5
|
-
* - Months are 1-based (January = 1)
|
|
6
|
-
* - All functions are pure (string in, string out)
|
|
7
|
-
* - No mutable objects
|
|
8
|
-
* - UTC by default, explicit timezone for display
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* ISO 8601 timestamp string type
|
|
12
|
-
* e.g., "2024-01-15T10:30:00.000Z"
|
|
13
|
-
*/
|
|
14
|
-
export type TimestampString = string;
|
|
15
|
-
/**
|
|
16
|
-
* Validate that a string is a valid ISO 8601 timestamp
|
|
17
|
-
*/
|
|
18
|
-
export declare function isValid(ts: string): ts is TimestampString;
|
|
19
|
-
/**
|
|
20
|
-
* Get the current timestamp as ISO string
|
|
21
|
-
*/
|
|
22
|
-
export declare function now(): TimestampString;
|
|
23
|
-
/**
|
|
24
|
-
* Create a timestamp from components
|
|
25
|
-
* IMPORTANT: month is 1-based (1 = January, 12 = December)
|
|
26
|
-
*/
|
|
27
|
-
export declare function from(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, ms?: number): TimestampString;
|
|
28
|
-
/**
|
|
29
|
-
* Parse a flexible date string into ISO timestamp
|
|
30
|
-
* Handles various formats and normalizes to UTC
|
|
31
|
-
*/
|
|
32
|
-
export declare function parse(input: string): TimestampString;
|
|
33
|
-
/**
|
|
34
|
-
* Try to parse a date string, returning null on failure
|
|
35
|
-
*/
|
|
36
|
-
export declare function tryParse(input: string): TimestampString | null;
|
|
37
|
-
/**
|
|
38
|
-
* Add milliseconds to a timestamp
|
|
39
|
-
*/
|
|
40
|
-
export declare function addMilliseconds(ts: TimestampString, ms: number): TimestampString;
|
|
41
|
-
/**
|
|
42
|
-
* Add seconds to a timestamp
|
|
43
|
-
*/
|
|
44
|
-
export declare function addSeconds(ts: TimestampString, seconds: number): TimestampString;
|
|
45
|
-
/**
|
|
46
|
-
* Add minutes to a timestamp
|
|
47
|
-
*/
|
|
48
|
-
export declare function addMinutes(ts: TimestampString, minutes: number): TimestampString;
|
|
49
|
-
/**
|
|
50
|
-
* Add hours to a timestamp
|
|
51
|
-
*/
|
|
52
|
-
export declare function addHours(ts: TimestampString, hours: number): TimestampString;
|
|
53
|
-
/**
|
|
54
|
-
* Add days to a timestamp
|
|
55
|
-
*/
|
|
56
|
-
export declare function addDays(ts: TimestampString, days: number): TimestampString;
|
|
57
|
-
/**
|
|
58
|
-
* Add weeks to a timestamp
|
|
59
|
-
*/
|
|
60
|
-
export declare function addWeeks(ts: TimestampString, weeks: number): TimestampString;
|
|
61
|
-
/**
|
|
62
|
-
* Add months to a timestamp
|
|
63
|
-
* Handles month overflow correctly (e.g., Jan 31 + 1 month = Feb 28/29)
|
|
64
|
-
*/
|
|
65
|
-
export declare function addMonths(ts: TimestampString, months: number): TimestampString;
|
|
66
|
-
/**
|
|
67
|
-
* Add years to a timestamp
|
|
68
|
-
* Handles leap years correctly (Feb 29 + 1 year = Feb 28)
|
|
69
|
-
*/
|
|
70
|
-
export declare function addYears(ts: TimestampString, years: number): TimestampString;
|
|
71
|
-
/**
|
|
72
|
-
* Get the difference between two timestamps in milliseconds
|
|
73
|
-
* Returns a - b (positive if a is after b)
|
|
74
|
-
*/
|
|
75
|
-
export declare function diff(a: TimestampString, b: TimestampString): number;
|
|
76
|
-
/**
|
|
77
|
-
* Get the difference in seconds
|
|
78
|
-
*/
|
|
79
|
-
export declare function diffSeconds(a: TimestampString, b: TimestampString): number;
|
|
80
|
-
/**
|
|
81
|
-
* Get the difference in minutes
|
|
82
|
-
*/
|
|
83
|
-
export declare function diffMinutes(a: TimestampString, b: TimestampString): number;
|
|
84
|
-
/**
|
|
85
|
-
* Get the difference in hours
|
|
86
|
-
*/
|
|
87
|
-
export declare function diffHours(a: TimestampString, b: TimestampString): number;
|
|
88
|
-
/**
|
|
89
|
-
* Get the difference in days
|
|
90
|
-
*/
|
|
91
|
-
export declare function diffDays(a: TimestampString, b: TimestampString): number;
|
|
92
|
-
/**
|
|
93
|
-
* Get the year component
|
|
94
|
-
*/
|
|
95
|
-
export declare function year(ts: TimestampString): number;
|
|
96
|
-
/**
|
|
97
|
-
* Get the month component (1-based: 1 = January, 12 = December)
|
|
98
|
-
*/
|
|
99
|
-
export declare function month(ts: TimestampString): number;
|
|
100
|
-
/**
|
|
101
|
-
* Get the day of month component (1-31)
|
|
102
|
-
*/
|
|
103
|
-
export declare function day(ts: TimestampString): number;
|
|
104
|
-
/**
|
|
105
|
-
* Get the hour component (0-23)
|
|
106
|
-
*/
|
|
107
|
-
export declare function hour(ts: TimestampString): number;
|
|
108
|
-
/**
|
|
109
|
-
* Get the minute component (0-59)
|
|
110
|
-
*/
|
|
111
|
-
export declare function minute(ts: TimestampString): number;
|
|
112
|
-
/**
|
|
113
|
-
* Get the second component (0-59)
|
|
114
|
-
*/
|
|
115
|
-
export declare function second(ts: TimestampString): number;
|
|
116
|
-
/**
|
|
117
|
-
* Get the millisecond component (0-999)
|
|
118
|
-
*/
|
|
119
|
-
export declare function millisecond(ts: TimestampString): number;
|
|
120
|
-
/**
|
|
121
|
-
* Get the day of week (1 = Monday, 7 = Sunday) - ISO 8601 convention
|
|
122
|
-
*/
|
|
123
|
-
export declare function dayOfWeek(ts: TimestampString): number;
|
|
124
|
-
/**
|
|
125
|
-
* Format a timestamp for local display
|
|
126
|
-
* Uses Intl.DateTimeFormat for timezone-aware formatting
|
|
127
|
-
*/
|
|
128
|
-
export declare function toLocal(ts: TimestampString, timezone?: string, options?: Intl.DateTimeFormatOptions): string;
|
|
129
|
-
/**
|
|
130
|
-
* Format as a readable date/time string
|
|
131
|
-
*/
|
|
132
|
-
export declare function format(ts: TimestampString, timezone?: string): string;
|
|
133
|
-
/**
|
|
134
|
-
* Format as date only (no time)
|
|
135
|
-
*/
|
|
136
|
-
export declare function formatDate(ts: TimestampString, timezone?: string): string;
|
|
137
|
-
/**
|
|
138
|
-
* Format as time only (no date)
|
|
139
|
-
*/
|
|
140
|
-
export declare function formatTime(ts: TimestampString, timezone?: string): string;
|
|
141
|
-
/**
|
|
142
|
-
* Extract just the date portion as YYYY-MM-DD (LegalDate format)
|
|
143
|
-
*/
|
|
144
|
-
export declare function toDate(ts: TimestampString): string;
|
|
145
|
-
/**
|
|
146
|
-
* Check if a is before b
|
|
147
|
-
*/
|
|
148
|
-
export declare function isBefore(a: TimestampString, b: TimestampString): boolean;
|
|
149
|
-
/**
|
|
150
|
-
* Check if a is after b
|
|
151
|
-
*/
|
|
152
|
-
export declare function isAfter(a: TimestampString, b: TimestampString): boolean;
|
|
153
|
-
/**
|
|
154
|
-
* Check if two timestamps are equal
|
|
155
|
-
*/
|
|
156
|
-
export declare function isEqual(a: TimestampString, b: TimestampString): boolean;
|
|
157
|
-
/**
|
|
158
|
-
* Get the earlier of two timestamps
|
|
159
|
-
*/
|
|
160
|
-
export declare function min(a: TimestampString, b: TimestampString): TimestampString;
|
|
161
|
-
/**
|
|
162
|
-
* Get the later of two timestamps
|
|
163
|
-
*/
|
|
164
|
-
export declare function max(a: TimestampString, b: TimestampString): TimestampString;
|
|
165
|
-
/**
|
|
166
|
-
* Get the start of the day (00:00:00.000 UTC)
|
|
167
|
-
*/
|
|
168
|
-
export declare function startOfDay(ts: TimestampString): TimestampString;
|
|
169
|
-
/**
|
|
170
|
-
* Get the end of the day (23:59:59.999 UTC)
|
|
171
|
-
*/
|
|
172
|
-
export declare function endOfDay(ts: TimestampString): TimestampString;
|
|
173
|
-
/**
|
|
174
|
-
* Get the start of the month
|
|
175
|
-
*/
|
|
176
|
-
export declare function startOfMonth(ts: TimestampString): TimestampString;
|
|
177
|
-
/**
|
|
178
|
-
* Get the end of the month
|
|
179
|
-
*/
|
|
180
|
-
export declare function endOfMonth(ts: TimestampString): TimestampString;
|
|
181
|
-
/**
|
|
182
|
-
* Get the start of the year
|
|
183
|
-
*/
|
|
184
|
-
export declare function startOfYear(ts: TimestampString): TimestampString;
|
|
185
|
-
/**
|
|
186
|
-
* Get the end of the year
|
|
187
|
-
*/
|
|
188
|
-
export declare function endOfYear(ts: TimestampString): TimestampString;
|
|
189
|
-
export declare const Timestamp: {
|
|
190
|
-
isValid: typeof isValid;
|
|
191
|
-
now: typeof now;
|
|
192
|
-
from: typeof from;
|
|
193
|
-
parse: typeof parse;
|
|
194
|
-
tryParse: typeof tryParse;
|
|
195
|
-
addMilliseconds: typeof addMilliseconds;
|
|
196
|
-
addSeconds: typeof addSeconds;
|
|
197
|
-
addMinutes: typeof addMinutes;
|
|
198
|
-
addHours: typeof addHours;
|
|
199
|
-
addDays: typeof addDays;
|
|
200
|
-
addWeeks: typeof addWeeks;
|
|
201
|
-
addMonths: typeof addMonths;
|
|
202
|
-
addYears: typeof addYears;
|
|
203
|
-
diff: typeof diff;
|
|
204
|
-
diffSeconds: typeof diffSeconds;
|
|
205
|
-
diffMinutes: typeof diffMinutes;
|
|
206
|
-
diffHours: typeof diffHours;
|
|
207
|
-
diffDays: typeof diffDays;
|
|
208
|
-
year: typeof year;
|
|
209
|
-
month: typeof month;
|
|
210
|
-
day: typeof day;
|
|
211
|
-
hour: typeof hour;
|
|
212
|
-
minute: typeof minute;
|
|
213
|
-
second: typeof second;
|
|
214
|
-
millisecond: typeof millisecond;
|
|
215
|
-
dayOfWeek: typeof dayOfWeek;
|
|
216
|
-
toLocal: typeof toLocal;
|
|
217
|
-
format: typeof format;
|
|
218
|
-
formatDate: typeof formatDate;
|
|
219
|
-
formatTime: typeof formatTime;
|
|
220
|
-
toDate: typeof toDate;
|
|
221
|
-
isBefore: typeof isBefore;
|
|
222
|
-
isAfter: typeof isAfter;
|
|
223
|
-
isEqual: typeof isEqual;
|
|
224
|
-
min: typeof min;
|
|
225
|
-
max: typeof max;
|
|
226
|
-
startOfDay: typeof startOfDay;
|
|
227
|
-
endOfDay: typeof endOfDay;
|
|
228
|
-
startOfMonth: typeof startOfMonth;
|
|
229
|
-
endOfMonth: typeof endOfMonth;
|
|
230
|
-
startOfYear: typeof startOfYear;
|
|
231
|
-
endOfYear: typeof endOfYear;
|
|
232
|
-
};
|
|
233
|
-
export default Timestamp;
|
package/dist/src/types/Type.d.ts
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type() - Runtime type definitions with descriptions and validation
|
|
3
|
-
*
|
|
4
|
-
* Forms:
|
|
5
|
-
* Type(description, predicate) - full form with custom validation
|
|
6
|
-
* Type(description, schema) - schema-based validation
|
|
7
|
-
* Type(schema) - schema only, self-documenting
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* const ZipCode = Type('5-digit US zip code', (s) => /^\d{5}$/.test(s))
|
|
11
|
-
* const Email = Type('valid email', s.string.email)
|
|
12
|
-
* const Age = Type(s.number.min(0).max(150))
|
|
13
|
-
*
|
|
14
|
-
* ZipCode.check('12345') // true
|
|
15
|
-
* ZipCode.check('abc') // false
|
|
16
|
-
* ZipCode.description // '5-digit US zip code'
|
|
17
|
-
*/
|
|
18
|
-
import { type Base } from 'tosijs-schema';
|
|
19
|
-
/** JSON Schema object type (simplified) */
|
|
20
|
-
type JSONSchema = {
|
|
21
|
-
type?: string;
|
|
22
|
-
properties?: Record<string, JSONSchema>;
|
|
23
|
-
items?: JSONSchema;
|
|
24
|
-
required?: string[];
|
|
25
|
-
[key: string]: unknown;
|
|
26
|
-
};
|
|
27
|
-
/** Schema can be a tosijs-schema builder or a raw JSON Schema object */
|
|
28
|
-
type Schema = Base<any> | JSONSchema;
|
|
29
|
-
/** A runtime type with description and validation */
|
|
30
|
-
export interface RuntimeType<T = unknown> {
|
|
31
|
-
/** Human-readable description of the type */
|
|
32
|
-
readonly description: string;
|
|
33
|
-
/** Check if a value matches this type */
|
|
34
|
-
check(value: unknown): value is T;
|
|
35
|
-
/** The underlying schema (if schema-based) */
|
|
36
|
-
readonly schema?: Schema;
|
|
37
|
-
/** The predicate function (if predicate-based) */
|
|
38
|
-
readonly predicate?: (value: unknown) => boolean;
|
|
39
|
-
/** Example value (for documentation and signature testing) */
|
|
40
|
-
readonly example?: T;
|
|
41
|
-
/** Multiple example values (from schema metadata, for autocomplete hints) */
|
|
42
|
-
readonly examples?: T[];
|
|
43
|
-
/** Default value (for instantiation) */
|
|
44
|
-
readonly default?: T;
|
|
45
|
-
/** Brand for type identification */
|
|
46
|
-
readonly __runtimeType: true;
|
|
47
|
-
}
|
|
48
|
-
/** Check if a value is a RuntimeType */
|
|
49
|
-
export declare function isRuntimeType(value: unknown): value is RuntimeType;
|
|
50
|
-
export declare function Type<T = unknown>(descriptionOrSchema: string | Schema, predicateOrSchemaOrExample?: ((value: unknown) => boolean) | Schema | T | undefined, exampleArg?: T, defaultArg?: T): RuntimeType<T>;
|
|
51
|
-
/** String type */
|
|
52
|
-
export declare const TString: RuntimeType<string>;
|
|
53
|
-
/** Number type */
|
|
54
|
-
export declare const TNumber: RuntimeType<number>;
|
|
55
|
-
/** Boolean type */
|
|
56
|
-
export declare const TBoolean: RuntimeType<boolean>;
|
|
57
|
-
/** Integer type */
|
|
58
|
-
export declare const TInteger: RuntimeType<number>;
|
|
59
|
-
/** Positive integer type */
|
|
60
|
-
export declare const TPositiveInt: RuntimeType<number>;
|
|
61
|
-
/** Non-empty string type */
|
|
62
|
-
export declare const TNonEmptyString: RuntimeType<string>;
|
|
63
|
-
/** Email type (basic validation) */
|
|
64
|
-
export declare const TEmail: RuntimeType<string>;
|
|
65
|
-
/**
|
|
66
|
-
* Check if a string is a valid URL (portable helper for predicates)
|
|
67
|
-
* This will become an AJS builtin
|
|
68
|
-
*/
|
|
69
|
-
export declare const isValidUrl: (v: string) => boolean;
|
|
70
|
-
/** URL type */
|
|
71
|
-
export declare const TUrl: RuntimeType<string>;
|
|
72
|
-
/** UUID type */
|
|
73
|
-
export declare const TUuid: RuntimeType<string>;
|
|
74
|
-
/**
|
|
75
|
-
* Check if a string is a valid ISO 8601 timestamp (portable helper for predicates)
|
|
76
|
-
* This will become an AJS builtin
|
|
77
|
-
*/
|
|
78
|
-
export declare const isValidTimestamp: (v: string) => boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Check if a string is a valid YYYY-MM-DD date (portable helper for predicates)
|
|
81
|
-
* This will become an AJS builtin
|
|
82
|
-
*/
|
|
83
|
-
export declare const isValidLegalDate: (v: string) => boolean;
|
|
84
|
-
/** ISO 8601 timestamp string (e.g., "2024-01-15T10:30:00Z") */
|
|
85
|
-
export declare const Timestamp: RuntimeType<string>;
|
|
86
|
-
/** Legal date string in YYYY-MM-DD format */
|
|
87
|
-
export declare const LegalDate: RuntimeType<string>;
|
|
88
|
-
/** Create a nullable version of a type */
|
|
89
|
-
export declare function Nullable<T>(type: RuntimeType<T>): RuntimeType<T | null>;
|
|
90
|
-
/** Create an optional version of a type (nullable + undefined) */
|
|
91
|
-
export declare function Optional<T>(type: RuntimeType<T>): RuntimeType<T | null | undefined>;
|
|
92
|
-
/**
|
|
93
|
-
* Create a union type
|
|
94
|
-
*
|
|
95
|
-
* Two forms:
|
|
96
|
-
* Union(...types: RuntimeType[]) - combine existing types
|
|
97
|
-
* Union(description, values) - create literal union from values
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* // From RuntimeTypes
|
|
101
|
-
* const StringOrNumber = Union(TString, TNumber)
|
|
102
|
-
*
|
|
103
|
-
* // From literal values (used by TJS syntax)
|
|
104
|
-
* const Direction = Union('cardinal direction', ['up', 'down', 'left', 'right'])
|
|
105
|
-
*/
|
|
106
|
-
export declare function Union<T extends unknown[]>(descriptionOrType: string | RuntimeType, valuesOrType?: T | RuntimeType, ...restTypes: RuntimeType[]): RuntimeType;
|
|
107
|
-
/** Create an array type */
|
|
108
|
-
export declare function TArray<T>(itemType: RuntimeType<T>): RuntimeType<T[]>;
|
|
109
|
-
/** Type parameter - can be a RuntimeType, schema, or example value */
|
|
110
|
-
export type TypeParam = RuntimeType | Base<any> | JSONSchema | unknown;
|
|
111
|
-
/** Generic type factory */
|
|
112
|
-
export interface GenericType<TParams extends string[] = string[]> {
|
|
113
|
-
/** Instantiate the generic with concrete type arguments */
|
|
114
|
-
(...typeArgs: TypeParam[]): RuntimeType;
|
|
115
|
-
/** The type parameter names */
|
|
116
|
-
readonly params: TParams;
|
|
117
|
-
/** Description template */
|
|
118
|
-
readonly description: string;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Create a generic (parameterized) type factory
|
|
122
|
-
*
|
|
123
|
-
* @param params Array of type parameter names, with optional defaults: ['T', ['U', defaultSchema]]
|
|
124
|
-
* @param predicate Function receiving (value, ...typeChecks) where typeChecks are validation functions
|
|
125
|
-
* @param description Human-readable description template (type params will be substituted)
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* // Pair<T, U>
|
|
129
|
-
* const Pair = Generic(
|
|
130
|
-
* ['T', 'U'],
|
|
131
|
-
* (x, checkT, checkU) =>
|
|
132
|
-
* Array.isArray(x) && x.length === 2 && checkT(x[0]) && checkU(x[1]),
|
|
133
|
-
* 'Pair<T, U>'
|
|
134
|
-
* )
|
|
135
|
-
*
|
|
136
|
-
* // Usage: Pair(TString, TNumber) creates a type for [string, number]
|
|
137
|
-
* // Or with examples: Pair('', 0)
|
|
138
|
-
*/
|
|
139
|
-
export declare function Generic<TParams extends string[]>(params: (string | [string, TypeParam])[], predicate: (value: unknown, ...typeChecks: Array<(v: unknown) => boolean>) => boolean, description: string): GenericType<TParams>;
|
|
140
|
-
/** Pair<T, U> - 2-element tuple */
|
|
141
|
-
export declare const TPair: GenericType<string[]>;
|
|
142
|
-
/** Record<V> - object with string keys and values of type V */
|
|
143
|
-
export declare const TRecord: GenericType<string[]>;
|
|
144
|
-
/** Enum type with bidirectional lookup */
|
|
145
|
-
export interface EnumType<T extends Record<string, string | number> = Record<string, string | number>> extends RuntimeType<T[keyof T]> {
|
|
146
|
-
/** The enum members as { Name: value } */
|
|
147
|
-
readonly members: T;
|
|
148
|
-
/** Reverse lookup: value -> name */
|
|
149
|
-
readonly names: Record<string | number, string>;
|
|
150
|
-
/** Get all valid values */
|
|
151
|
-
readonly values: Array<T[keyof T]>;
|
|
152
|
-
/** Get all member names */
|
|
153
|
-
readonly keys: Array<keyof T>;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Create an enum type with bidirectional lookup
|
|
157
|
-
*
|
|
158
|
-
* @param description Human-readable description
|
|
159
|
-
* @param members Object mapping names to values { Pending: 0, Active: 1 }
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* const Status = Enum('task status', { Pending: 0, Active: 1, Done: 2 })
|
|
163
|
-
* Status.check(0) // true
|
|
164
|
-
* Status.check('done') // false
|
|
165
|
-
* Status.members.Pending // 0
|
|
166
|
-
* Status.names[0] // 'Pending'
|
|
167
|
-
* Status.values // [0, 1, 2]
|
|
168
|
-
* Status.keys // ['Pending', 'Active', 'Done']
|
|
169
|
-
*
|
|
170
|
-
* const Color = Enum('CSS color', { Red: 'red', Green: 'green', Blue: 'blue' })
|
|
171
|
-
* Color.check('red') // true
|
|
172
|
-
* Color.members.Red // 'red'
|
|
173
|
-
*/
|
|
174
|
-
export declare function Enum<T extends Record<string, string | number>>(description: string, members: T): EnumType<T>;
|
|
175
|
-
/** Return contract levels in order of strictness */
|
|
176
|
-
export type ReturnContract = 'assertReturns' | 'returns' | 'checkedReturns';
|
|
177
|
-
/** Specification for a FunctionPredicate */
|
|
178
|
-
export interface FunctionPredicateSpec {
|
|
179
|
-
/** Parameter types as example values */
|
|
180
|
-
params?: Record<string, any>;
|
|
181
|
-
/** Return type as example value */
|
|
182
|
-
returns?: any;
|
|
183
|
-
/** Return contract level */
|
|
184
|
-
returnContract?: ReturnContract;
|
|
185
|
-
}
|
|
186
|
-
/** A runtime type that validates function signatures */
|
|
187
|
-
export interface FunctionPredicateType extends RuntimeType<Function> {
|
|
188
|
-
/** Parameter specification */
|
|
189
|
-
readonly params: Record<string, any>;
|
|
190
|
-
/** Return type specification */
|
|
191
|
-
readonly returns?: any;
|
|
192
|
-
/** Return contract level */
|
|
193
|
-
readonly returnContract: ReturnContract;
|
|
194
|
-
}
|
|
195
|
-
/** A generic FunctionPredicate factory — call with type args to get a FunctionPredicateType */
|
|
196
|
-
export interface GenericFunctionPredicateType {
|
|
197
|
-
(...typeArgs: TypeParam[]): FunctionPredicateType;
|
|
198
|
-
/** Type parameter names */
|
|
199
|
-
readonly typeParamNames: string[];
|
|
200
|
-
/** Description */
|
|
201
|
-
readonly description: string;
|
|
202
|
-
/** Marker for runtime type detection */
|
|
203
|
-
readonly __runtimeType: true;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Create a runtime type for function signatures.
|
|
207
|
-
*
|
|
208
|
-
* Forms:
|
|
209
|
-
* FunctionPredicate(name, spec) - from a specification object
|
|
210
|
-
* FunctionPredicate(name, fn) - from an existing typed function
|
|
211
|
-
*
|
|
212
|
-
* @example
|
|
213
|
-
* const Callback = FunctionPredicate('Callback', {
|
|
214
|
-
* params: { x: 0, y: 0 },
|
|
215
|
-
* returns: 0,
|
|
216
|
-
* })
|
|
217
|
-
* Callback.check((a, b) => a + b) // true (typeof === 'function')
|
|
218
|
-
* Callback.check(42) // false
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* function add(a: 0, b: 0) -> 0 { return a + b }
|
|
222
|
-
* const Adder = FunctionPredicate('Adder', add)
|
|
223
|
-
* // Extracts params/returns from add.__tjs
|
|
224
|
-
*
|
|
225
|
-
* @example
|
|
226
|
-
* // Generic form — returns a factory
|
|
227
|
-
* const Creator = FunctionPredicate('Creator', [['T', {}]], (T) => ({
|
|
228
|
-
* params: { contents: [null] },
|
|
229
|
-
* returns: T,
|
|
230
|
-
* }))
|
|
231
|
-
* const HtmlCreator = Creator({}) // FunctionPredicateType with returns: {}
|
|
232
|
-
*/
|
|
233
|
-
export declare function FunctionPredicate(name: string, specOrFn: FunctionPredicateSpec | Function | (string | [string, TypeParam])[], specBuilder?: (...typeArgs: any[]) => FunctionPredicateSpec): FunctionPredicateType | GenericFunctionPredicateType;
|
|
234
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TJS Type System
|
|
3
|
-
*
|
|
4
|
-
* Runtime types with descriptions and validation.
|
|
5
|
-
*/
|
|
6
|
-
export { Type, isRuntimeType, type RuntimeType, TString, TNumber, TBoolean, TInteger, TPositiveInt, TNonEmptyString, TEmail, TUrl, TUuid, Timestamp as TimestampType, LegalDate as LegalDateType, isValidUrl, isValidTimestamp, isValidLegalDate, Nullable, Optional, Union, TArray, Enum, type EnumType, Generic, TPair, TRecord, type GenericType, type TypeParam, FunctionPredicate, type FunctionPredicateType, type GenericFunctionPredicateType, type FunctionPredicateSpec, type ReturnContract, } from './Type';
|
|
7
|
-
export { Timestamp, type TimestampString } from './Timestamp';
|
|
8
|
-
export { LegalDate, type LegalDateString } from './LegalDate';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const storeVectorize: import("..").Atom<Record<string, any>, number[]>;
|
|
2
|
-
export declare const storeCreateCollection: import("..").Atom<Record<string, any>, void>;
|
|
3
|
-
export declare const storeVectorAdd: import("..").Atom<Record<string, any>, void>;
|
|
4
|
-
export declare const storeSearch: import("..").Atom<Record<string, any>, any[]>;
|
|
5
|
-
export declare const llmPredictBattery: import("..").Atom<Record<string, any>, any>;
|
|
6
|
-
export declare const llmVision: import("..").Atom<Record<string, any>, any>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface DomCapabilities {
|
|
2
|
-
querySelector(selector: string): Element | null;
|
|
3
|
-
querySelectorAll(selector: string): NodeListOf<Element>;
|
|
4
|
-
}
|
|
5
|
-
export interface StorageCapabilities {
|
|
6
|
-
getItem(key: string): string | null;
|
|
7
|
-
setItem(key: string, value: string): void;
|
|
8
|
-
}
|
|
9
|
-
export declare const createBrowserCapabilities: () => {
|
|
10
|
-
dom: {
|
|
11
|
-
querySelector: (s: string) => Element | null;
|
|
12
|
-
querySelectorAll: (s: string) => NodeListOf<Element>;
|
|
13
|
-
};
|
|
14
|
-
storage: {
|
|
15
|
-
getItem: (k: string) => string | null;
|
|
16
|
-
setItem: (k: string, v: string) => void;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { coreAtoms } from '../runtime';
|
|
2
|
-
export declare const batteryAtoms: {
|
|
3
|
-
storeCreateCollection: import("..").Atom<Record<string, any>, void>;
|
|
4
|
-
storeSearch: import("..").Atom<Record<string, any>, any[]>;
|
|
5
|
-
storeVectorAdd: import("..").Atom<Record<string, any>, void>;
|
|
6
|
-
storeVectorize: import("..").Atom<Record<string, any>, number[]>;
|
|
7
|
-
llmPredictBattery: import("..").Atom<Record<string, any>, any>;
|
|
8
|
-
llmVision: import("..").Atom<Record<string, any>, any>;
|
|
9
|
-
};
|
|
10
|
-
export { coreAtoms };
|
package/dist/src/vm/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TJS VM - Sandboxed execution runtime
|
|
3
|
-
*
|
|
4
|
-
* Lightweight (~33KB) VM for executing AJS AST with:
|
|
5
|
-
* - Fuel metering (gas limits)
|
|
6
|
-
* - Capability-based security
|
|
7
|
-
* - Monadic error handling
|
|
8
|
-
* - Timeout enforcement
|
|
9
|
-
*/
|
|
10
|
-
export * from './runtime';
|
|
11
|
-
export * from './vm';
|
|
12
|
-
export * from './atoms';
|