@atscript/core 0.2.3 → 0.2.5
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/dist/index.cjs +399 -59
- package/dist/index.d.ts +86 -7
- package/dist/index.mjs +393 -59
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -367,7 +367,12 @@ interface TPrimitiveTypeObject {
|
|
|
367
367
|
propsPatterns: Record<string, TPrimitiveTypeDef>;
|
|
368
368
|
optional?: boolean;
|
|
369
369
|
}
|
|
370
|
-
|
|
370
|
+
/**
|
|
371
|
+
* A final (scalar) primitive type. `'any'`: any value, not checked (the `unknown` primitive —
|
|
372
|
+
* TypeScript `unknown`, JSON Schema `{}`); `'phantom'`: no value at all (not in the data type,
|
|
373
|
+
* validation or schema).
|
|
374
|
+
*/
|
|
375
|
+
type TPrimitiveTypeFinal = 'string' | 'number' | 'boolean' | 'void' | 'null' | 'phantom' | 'decimal' | 'any';
|
|
371
376
|
interface TPrimitiveTypeFinalOptional {
|
|
372
377
|
kind: 'final';
|
|
373
378
|
value: TPrimitiveTypeFinal;
|
|
@@ -461,7 +466,7 @@ declare class SemanticPrimitiveNode extends SemanticNode {
|
|
|
461
466
|
private readonly annotationTree?;
|
|
462
467
|
constructor(_id: string, config: TPrimitiveConfig, parentKey?: string, annotationTree?: TAnnotationsTree | undefined);
|
|
463
468
|
protected applyAnnotations(): void;
|
|
464
|
-
readonly type?: 'union' | 'intersection' | 'tuple' | 'array' | 'object' | 'string' | 'number' | 'boolean' | 'void' | 'null' | 'phantom' | 'decimal';
|
|
469
|
+
readonly type?: 'union' | 'intersection' | 'tuple' | 'array' | 'object' | 'string' | 'number' | 'boolean' | 'void' | 'null' | 'phantom' | 'decimal' | 'any';
|
|
465
470
|
get key(): string;
|
|
466
471
|
getAllTags(_processed?: Set<SemanticPrimitiveNode>): string[];
|
|
467
472
|
get id(): string;
|
|
@@ -502,6 +507,12 @@ declare const UNION_IN_RECURSIVE_MERGE = "union members are not supported in rec
|
|
|
502
507
|
declare const MERGE_TOO_COMPLEX = "merge too complex: split it with named types";
|
|
503
508
|
/** Why scalars (or an object and a scalar) merge to `never`. */
|
|
504
509
|
declare const NOTHING_IN_COMMON = "values with nothing in common";
|
|
510
|
+
/**
|
|
511
|
+
* Why a merge of `unknown` (any value) with an object, an array or `null` is refused: TypeScript
|
|
512
|
+
* reads `unknown & X` as `X`, a merge of values would be `never` (a compile error, not a
|
|
513
|
+
* validator rejecting what the `.d.ts` accepts).
|
|
514
|
+
*/
|
|
515
|
+
declare const OPAQUE_MERGE = "\"unknown\" cannot be merged with an object, an array or null";
|
|
505
516
|
/** A type written as an operand of its own merge (`type X = A & X`). */
|
|
506
517
|
declare const SELF_OPERAND = "a type cannot be an operand of its own merge; recurse through a field instead";
|
|
507
518
|
/** A db entity whose flattening reaches a web of mutually recursive merges. */
|
|
@@ -679,8 +690,11 @@ type TStructShape = {
|
|
|
679
690
|
k: 'uni';
|
|
680
691
|
n: number;
|
|
681
692
|
items: TStructShape[];
|
|
682
|
-
}
|
|
693
|
+
}
|
|
694
|
+
/** `any`: the `unknown` primitive (any value), or a union holding it */
|
|
695
|
+
| {
|
|
683
696
|
k: 'scalar';
|
|
697
|
+
any?: true;
|
|
684
698
|
} | {
|
|
685
699
|
k: 'never';
|
|
686
700
|
reason: string;
|
|
@@ -2307,7 +2321,16 @@ declare class AtscriptDoc {
|
|
|
2307
2321
|
* is `X & Z`; an alias `XN = X | null`: X, then XN's own).
|
|
2308
2322
|
*/
|
|
2309
2323
|
intersectionMemberRefs(group: SemanticGroup): SemanticRefNode[];
|
|
2310
|
-
|
|
2324
|
+
/**
|
|
2325
|
+
* Annotations `right` over `left`: right's win, `append` ones of both kept (left's after).
|
|
2326
|
+
*
|
|
2327
|
+
* `layered`: `right` is a node's and `left` what the node is layered over (the type it
|
|
2328
|
+
* references, an `as` copy's target) — right's `@annotate.reset 'x'` drop left's x, and the
|
|
2329
|
+
* resets of both stay, for the layers further below (see {@link stripResets}). Else they are
|
|
2330
|
+
* siblings (the members of a merge): a reset applies within its member's own layers only, and
|
|
2331
|
+
* is left out.
|
|
2332
|
+
*/
|
|
2333
|
+
mergeNodesAnnotations(left?: TAnnotationTokens[], right?: TAnnotationTokens[], layered?: boolean): TAnnotationTokens[];
|
|
2311
2334
|
}
|
|
2312
2335
|
/**
|
|
2313
2336
|
* {@link unwoundFields}, each declared field once: several positions of a type path may be one
|
|
@@ -2575,6 +2598,11 @@ interface TQueryScope {
|
|
|
2575
2598
|
*/
|
|
2576
2599
|
unqualifiedTarget: string | null;
|
|
2577
2600
|
}
|
|
2601
|
+
/**
|
|
2602
|
+
* The built-in annotation of `annotate` blocks that removes another annotation from the node
|
|
2603
|
+
* (`@annotate.reset 'expect.pattern'`): a directive, never written as metadata.
|
|
2604
|
+
*/
|
|
2605
|
+
declare const ANNOTATE_RESET = "annotate.reset";
|
|
2578
2606
|
/** Annotation argument types written in backticks, each parsed by its own grammar. */
|
|
2579
2607
|
type TBacktickArgKind = 'query' | 'expr' | 'order';
|
|
2580
2608
|
/** Whether an annotation argument type is written in backticks (`query`, `expr`, `order`). */
|
|
@@ -2602,8 +2630,12 @@ interface TAnnotationArgument {
|
|
|
2602
2630
|
* - `expr`: backtick arithmetic over field refs (`openCount * 10 + coalesce(overdue, 0)`):
|
|
2603
2631
|
* `+ - * /`, unary `-`, parentheses, numeric literals, `coalesce(a, b, …)`
|
|
2604
2632
|
* - `order`: backtick ordering (`raisedAt desc, id`): field refs with optional `asc` / `desc`
|
|
2633
|
+
* - `value`: a scalar literal — a string (`'active'`), a number (`0`, `-1.5`) or a boolean
|
|
2634
|
+
* (`true`). A number or boolean must fit the annotated field's type (a number for a number
|
|
2635
|
+
* field, …); a string is accepted for any field (read as text for a string field, else as
|
|
2636
|
+
* JSON by convention). The value is stored as written: a string, a number or a boolean.
|
|
2605
2637
|
*/
|
|
2606
|
-
type: 'string' | 'number' | 'boolean' | 'ref' | TBacktickArgKind;
|
|
2638
|
+
type: 'string' | 'number' | 'boolean' | 'ref' | 'value' | TBacktickArgKind;
|
|
2607
2639
|
description?: string;
|
|
2608
2640
|
values?: string[];
|
|
2609
2641
|
/**
|
|
@@ -2631,6 +2663,15 @@ interface TAnnotationArgument {
|
|
|
2631
2663
|
* return `false` to hide the candidate. All declarations are offered when absent.
|
|
2632
2664
|
*/
|
|
2633
2665
|
refFilter?: (decl: SemanticNode, doc: AtscriptDoc) => boolean;
|
|
2666
|
+
/**
|
|
2667
|
+
* The argument is user-facing text (a label, a description, an error message): i18n tooling
|
|
2668
|
+
* and translators read the annotations holding such text through {@link userTextAnnotations}
|
|
2669
|
+
* (build time) and `userTextOf` / `userTextKeys` of `@atscript/typescript/utils` (runtime).
|
|
2670
|
+
* `'expression'`: the argument is the source of a function the client evaluates (a computed
|
|
2671
|
+
* label, a custom validator returning its message); the texts it writes are the string literals
|
|
2672
|
+
* in that source, which a translator extracts and serves next to it. A `string` argument only.
|
|
2673
|
+
*/
|
|
2674
|
+
userText?: boolean | 'expression';
|
|
2634
2675
|
}
|
|
2635
2676
|
interface TAnnotationSpecConfig {
|
|
2636
2677
|
multiple?: boolean;
|
|
@@ -2648,6 +2689,11 @@ interface TAnnotationSpecConfig {
|
|
|
2648
2689
|
description?: string;
|
|
2649
2690
|
nodeType?: TNodeEntity[];
|
|
2650
2691
|
defType?: Array<SemanticPrimitiveNode['type']>;
|
|
2692
|
+
/**
|
|
2693
|
+
* With `defType`: a literal of an accepted type matches too (`'a'` for `string`, `1` for
|
|
2694
|
+
* `number`), alone or as a union member (`'a' | 'b' | null`).
|
|
2695
|
+
*/
|
|
2696
|
+
defTypeLiterals?: boolean;
|
|
2651
2697
|
argument?: TAnnotationArgument[] | TAnnotationArgument;
|
|
2652
2698
|
validate?: (mainToken: Token, args: Token[], doc: AtscriptDoc) => TMessages | undefined;
|
|
2653
2699
|
modify?: (mainToken: Token, args: Token[], doc: AtscriptDoc) => void;
|
|
@@ -2673,6 +2719,12 @@ declare class AnnotationSpec {
|
|
|
2673
2719
|
* by `getDiagMessages` (the `referred` loop) and is skipped here.
|
|
2674
2720
|
*/
|
|
2675
2721
|
validateDeferred(mainToken: Token, args: Token[], doc: AtscriptDoc): TMessages | undefined;
|
|
2722
|
+
/**
|
|
2723
|
+
* `value` arguments written as a number or a boolean must fit the annotated field's type: a
|
|
2724
|
+
* number literal a field that holds numbers, a boolean literal one that holds booleans (a
|
|
2725
|
+
* union: one of its members; `unknown`: any). A string is accepted for any field.
|
|
2726
|
+
*/
|
|
2727
|
+
private validateValueArgs;
|
|
2676
2728
|
/**
|
|
2677
2729
|
* Checks an already-resolved target node against this annotation's `defType`
|
|
2678
2730
|
* guard (e.g. `@expect.minLength` requires `string | array`). Returns a
|
|
@@ -2697,6 +2749,19 @@ declare function isAnnotationSpec(a?: TAnnotationsTree | AnnotationSpec): a is A
|
|
|
2697
2749
|
* reported under each.
|
|
2698
2750
|
*/
|
|
2699
2751
|
declare function forEachAnnotationSpec(tree: TAnnotationsTree, cb: (name: string, spec: AnnotationSpec) => void): void;
|
|
2752
|
+
/**
|
|
2753
|
+
* Where annotation `spec` holds user-facing text (arguments flagged `userText`): `true` — its
|
|
2754
|
+
* value itself (a spec with one argument, not a list: the value is the string; for a `multiple`
|
|
2755
|
+
* annotation, each value); `'expression'` — likewise, but the value is function source whose string
|
|
2756
|
+
* literals are the texts; a list — those fields of its value object (a spec with an argument
|
|
2757
|
+
* list), an expression field's name ending in `()`. `undefined`: no user-facing text.
|
|
2758
|
+
*/
|
|
2759
|
+
declare function userTextFields(spec: AnnotationSpec): true | 'expression' | string[] | undefined;
|
|
2760
|
+
/**
|
|
2761
|
+
* Every annotation of `tree` (core and plugins) holding user-facing text, by full name (see
|
|
2762
|
+
* {@link userTextFields}): what i18n tooling extracts and a translator translates.
|
|
2763
|
+
*/
|
|
2764
|
+
declare function userTextAnnotations(tree: TAnnotationsTree): Map<string, true | 'expression' | string[]>;
|
|
2700
2765
|
declare function resolveAnnotation(name: string, annotationsTree?: TAnnotationsTree): AnnotationSpec | undefined;
|
|
2701
2766
|
/**
|
|
2702
2767
|
* Resolved members of a union other than `null` / `undefined`, or `undefined`
|
|
@@ -2714,6 +2779,13 @@ declare function resolveAnnotation(name: string, annotationsTree?: TAnnotationsT
|
|
|
2714
2779
|
* ```
|
|
2715
2780
|
*/
|
|
2716
2781
|
declare function nonNullishMembers(def: SemanticNode | undefined, doc: AtscriptDoc): SemanticNode[] | undefined;
|
|
2782
|
+
/**
|
|
2783
|
+
* The scalar kinds the field (or type) annotation `mainToken` is written on holds (see
|
|
2784
|
+
* `valueKinds`): `string`, `number`, `boolean`, `decimal`, `unknown` (any value), or another
|
|
2785
|
+
* kind name (`object`, `array`, …). `undefined` when the field does not resolve. Code generators
|
|
2786
|
+
* use it for `value` arguments: a number literal on a `decimal` field is written as its string.
|
|
2787
|
+
*/
|
|
2788
|
+
declare function annotatedValueKinds(mainToken: Token, doc: AtscriptDoc): Set<string> | undefined;
|
|
2717
2789
|
|
|
2718
2790
|
/**
|
|
2719
2791
|
* Builds an {@link AnnotationSpec} `description` (shown in IDE hovers) that ends with an
|
|
@@ -2733,7 +2805,7 @@ declare function nonNullishMembers(def: SemanticNode | undefined, doc: AtscriptD
|
|
|
2733
2805
|
*/
|
|
2734
2806
|
declare function annotationExample(description: string, ...lines: string[]): string;
|
|
2735
2807
|
|
|
2736
|
-
declare function resolveAtscriptFromPath(
|
|
2808
|
+
declare function resolveAtscriptFromPath(written: string, id: string): string;
|
|
2737
2809
|
declare function fileUriToPath(id: string): string;
|
|
2738
2810
|
declare function getRelPath(fromUri: string, toUri: string): string;
|
|
2739
2811
|
|
|
@@ -2743,6 +2815,13 @@ declare function getRelPath(fromUri: string, toUri: string): string;
|
|
|
2743
2815
|
* NOT bare: './user', '../shared', '/absolute/path'
|
|
2744
2816
|
*/
|
|
2745
2817
|
declare function isBareSpecifier(specifier: string): boolean;
|
|
2818
|
+
/**
|
|
2819
|
+
* The import path of an `.as` import as atscript resolves it: without a trailing `.as` extension.
|
|
2820
|
+
* `.as` imports may name a file with or without its extension (`'./user'`, `'./user.as'`,
|
|
2821
|
+
* `'my-lib/models.as'`); both spellings resolve to the same module. A bare package name
|
|
2822
|
+
* (`'my-lib'`, no subpath) is kept as written.
|
|
2823
|
+
*/
|
|
2824
|
+
declare function withoutAsExtension(specifier: string): string;
|
|
2746
2825
|
/**
|
|
2747
2826
|
* Returns true if the document ID is a bare specifier placeholder.
|
|
2748
2827
|
*/
|
|
@@ -2962,5 +3041,5 @@ declare const BACKTICK_ARG_VOCABULARY: {
|
|
|
2962
3041
|
*/
|
|
2963
3042
|
declare function moduleId(doc: AtscriptDoc): string;
|
|
2964
3043
|
|
|
2965
|
-
export { $n, AnnotationSpec, AtscriptDoc, AtscriptRepo, BACKTICK_ARG_VOCABULARY, BuildRepo, DB_ENTITY_ANNOTATIONS, DEFAULT_FORMAT, FLATTEN_WEB, MERGE_CAP, MERGE_TOO_COMPLEX, NAV_PROP_ANNOTATIONS, NOTHING_IN_COMMON, PRODUCT_CAP, PluginManager, SELF_OPERAND, SELF_SPLIT, SemanticAnnotateNode, SemanticArrayNode, SemanticConstNode, SemanticExprBinaryNode, SemanticExprCallNode, SemanticExprNode, SemanticExprNumberNode, SemanticExprUnaryNode, SemanticGroup, SemanticImportNode, SemanticInterfaceNode, SemanticNode, SemanticOrderNode, SemanticPrimitiveNode, SemanticPropNode, SemanticQueryComparisonNode, SemanticQueryFieldRefNode, SemanticQueryLogicalNode, SemanticQueryNode, SemanticQueryValueListNode, SemanticQueryValueNode, SemanticRefNode, SemanticStructureNode, SemanticTupleNode, SemanticTypeNode, StructureModel, Token, UNION_IN_RECURSIVE_MERGE, analyzeQueryCursorContext, andExprs, annotationExample, baseSlot, blockDependencies, blockTargetDocuments, build, clearResolveBareCache, componentOf, components, createAtscriptPlugin, defPosition, defineConfig, distinctFields, documentsEpoch, entryParts, fieldRefTokens, fileUriToPath, flatDefinitions, forEachAnnotationSpec, getDeclaredValue, getFieldPathCompletionScope, getFieldsForType, getQueryCompletionScope, getQueryScope, getRelPath, getSiblingAnnotation, getValueCandidates, hasMutatingAnnotates, hasNavPropAnnotation, isAnnotate, isAnnotationSpec, isArray, isAsView, isBacktickArgType, isBareId, isBareSpecifier, isConst, isDbEntityNode, isGroup, isImport, isInterface, isNull, isPhantomNode, isPhantomPath, isPhantomPrimitive, isPrimitive, isProp, isQueryComparison, isQueryFieldRef, isQueryLogical, isRef, isStructure, isTuple, isType, loadConfig, loadTsConfig, moduleId, nonNullishMembers, parseBareSpecifier, pastViews, recordDocumentReads, resolveAnnotation, resolveAtscriptFromPath, resolveBareSpecifier, resolveConfigFile, resolveFieldRefAt, resolveFieldRefsAt, resolveQueryFieldRef, unshell, unwoundFields };
|
|
3044
|
+
export { $n, ANNOTATE_RESET, AnnotationSpec, AtscriptDoc, AtscriptRepo, BACKTICK_ARG_VOCABULARY, BuildRepo, DB_ENTITY_ANNOTATIONS, DEFAULT_FORMAT, FLATTEN_WEB, MERGE_CAP, MERGE_TOO_COMPLEX, NAV_PROP_ANNOTATIONS, NOTHING_IN_COMMON, OPAQUE_MERGE, PRODUCT_CAP, PluginManager, SELF_OPERAND, SELF_SPLIT, SemanticAnnotateNode, SemanticArrayNode, SemanticConstNode, SemanticExprBinaryNode, SemanticExprCallNode, SemanticExprNode, SemanticExprNumberNode, SemanticExprUnaryNode, SemanticGroup, SemanticImportNode, SemanticInterfaceNode, SemanticNode, SemanticOrderNode, SemanticPrimitiveNode, SemanticPropNode, SemanticQueryComparisonNode, SemanticQueryFieldRefNode, SemanticQueryLogicalNode, SemanticQueryNode, SemanticQueryValueListNode, SemanticQueryValueNode, SemanticRefNode, SemanticStructureNode, SemanticTupleNode, SemanticTypeNode, StructureModel, Token, UNION_IN_RECURSIVE_MERGE, analyzeQueryCursorContext, andExprs, annotatedValueKinds, annotationExample, baseSlot, blockDependencies, blockTargetDocuments, build, clearResolveBareCache, componentOf, components, createAtscriptPlugin, defPosition, defineConfig, distinctFields, documentsEpoch, entryParts, fieldRefTokens, fileUriToPath, flatDefinitions, forEachAnnotationSpec, getDeclaredValue, getFieldPathCompletionScope, getFieldsForType, getQueryCompletionScope, getQueryScope, getRelPath, getSiblingAnnotation, getValueCandidates, hasMutatingAnnotates, hasNavPropAnnotation, isAnnotate, isAnnotationSpec, isArray, isAsView, isBacktickArgType, isBareId, isBareSpecifier, isConst, isDbEntityNode, isGroup, isImport, isInterface, isNull, isPhantomNode, isPhantomPath, isPhantomPrimitive, isPrimitive, isProp, isQueryComparison, isQueryFieldRef, isQueryLogical, isRef, isStructure, isTuple, isType, loadConfig, loadTsConfig, moduleId, nonNullishMembers, parseBareSpecifier, pastViews, recordDocumentReads, resolveAnnotation, resolveAtscriptFromPath, resolveBareSpecifier, resolveConfigFile, resolveFieldRefAt, resolveFieldRefsAt, resolveQueryFieldRef, unshell, unwoundFields, userTextAnnotations, userTextFields, withoutAsExtension };
|
|
2966
3045
|
export type { SemanticExprItemNode, SemanticQueryExprNode, TAnnotationArgument, TAnnotationSpecConfig, TAnnotationTokens, TAnnotationsTree, TAtscriptConfig, TAtscriptConfigInput, TAtscriptConfigOutput, TAtscriptDocConfig, TAtscriptPlugin, TAtscriptRenderFormat, TAtscriptRenderOptions, TBacktickArgKind, TComponent, TDbConfig, TDbConfigDeclarative, TExprBinaryOperator, TFlatDefinition, TMergeRoot, TMessages, TNodeEntity, TOrderItem, TOutput, TOutputWithSource, TPluginManagers, TPluginOutput, TPrimitiveAnnotationArg, TPrimitiveAnnotationArgs, TPrimitiveAnnotationValue, TPrimitiveBaseConfig, TPrimitiveConfig, TPrimitiveTypeArray, TPrimitiveTypeComplex, TPrimitiveTypeDef, TPrimitiveTypeFinal, TPrimitiveTypeFinalOptional, TPrimitiveTypeObject, TQueryCursorContext, TQueryLogicalOperator, TQueryOperator, TQueryScope, TSemanticToken, TStructBlock, TStructDecl, TStructDef, TStructEntry, TStructError, TStructExpr, TStructLayer, TStructNever, TStructProp, TStructRank, TStructShape, TStructSlot, TUnwound, TUnwoundField, TValueCandidate };
|