Add associative map constraints and range refinement
This commit is contained in:
@@ -28,7 +28,7 @@ await init();
|
||||
|
||||
const files = {
|
||||
'main.dcdl': 'let schema = import "./schema.dcdl"; in schema.Server',
|
||||
'schema.dcdl': 'Server = App.Server & { port = 8080; };',
|
||||
'schema.dcdl': 'Server = { port = 8080; } as App.Server;',
|
||||
};
|
||||
|
||||
const service = new DecodalLanguageService({
|
||||
@@ -64,6 +64,6 @@ console.log(JSON.parse(completion));
|
||||
|
||||
`globals`, `loadImport`, and `completeImport` are host-owned. The package does not assume a filesystem or virtual project model. Import callbacks are synchronous; preload or cache remote content before evaluation.
|
||||
|
||||
Plain strings, numbers, booleans, arrays, and objects are concrete host values. Use `{ $decodal: 'String' | 'Int' | 'Float' | 'Bool' }` for primitive schemas and `{ $decodal: 'Array', item: value }` for array schemas. Descriptors also accept `constraints` and `default`.
|
||||
Plain strings, numbers, booleans, arrays, and objects are concrete host values. Use `{ $decodal: 'String' | 'Int' | 'Float' | 'Bool' }` for primitive schemas, `{ $decodal: 'Array', item: value }` for array schemas, and `{ $decodal: 'Map', value: value }` for associative-array schemas. Descriptors also accept `constraints` and `default`.
|
||||
|
||||
Methods return JSON strings so callers can handle diagnostics and successful results without depending on Rust data structures.
|
||||
|
||||
+8
@@ -10,6 +10,7 @@ export type DecodalHostValue =
|
||||
| { [field: string]: DecodalHostValue }
|
||||
| DecodalPrimitiveDescriptor
|
||||
| DecodalArrayDescriptor
|
||||
| DecodalMapDescriptor
|
||||
| DecodalAbstractDescriptor;
|
||||
|
||||
export type DecodalPrimitiveType = 'String' | 'Int' | 'Float' | 'Bool';
|
||||
@@ -33,6 +34,13 @@ export interface DecodalArrayDescriptor {
|
||||
default?: DecodalHostValue;
|
||||
}
|
||||
|
||||
export interface DecodalMapDescriptor {
|
||||
$decodal: 'Map';
|
||||
value: DecodalHostValue;
|
||||
constraints?: DecodalConstraint[];
|
||||
default?: DecodalHostValue;
|
||||
}
|
||||
|
||||
export interface DecodalAbstractDescriptor {
|
||||
$decodal: 'Abstract';
|
||||
constraints?: DecodalConstraint[];
|
||||
|
||||
Binary file not shown.
@@ -13,6 +13,7 @@ export {
|
||||
export type {
|
||||
DecodalAbstractDescriptor,
|
||||
DecodalArrayDescriptor,
|
||||
DecodalMapDescriptor,
|
||||
DecodalConstraint,
|
||||
DecodalEnvironment,
|
||||
DecodalHostValue,
|
||||
|
||||
Reference in New Issue
Block a user