@ja-platform/parser-schema-xml 0.0.0-stage → 1.0.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/dist/@types/SchemaNode.d.ts +13 -0
- package/dist/@types/XmlField.d.ts +10 -0
- package/dist/@types/XmlModel.d.ts +16 -0
- package/dist/@types/XmlParam.d.ts +7 -0
- package/dist/@types/XmlSchema.d.ts +20 -0
- package/dist/@types/attributes/SchemaDatabaseAttribute.d.ts +11 -0
- package/dist/@types/attributes/SchemaEnumAttribute.d.ts +6 -0
- package/dist/@types/attributes/SchemaFieldTypeAttribute.d.ts +9 -0
- package/dist/@types/attributes/SchemaIndexAttribute.d.ts +9 -0
- package/dist/@types/attributes/SchemaNameAttribute.d.ts +4 -0
- package/dist/@types/attributes/SchemaOptionKeyAttribute.d.ts +16 -0
- package/dist/@types/expressions/SchemaDatabasesExpression.d.ts +10 -0
- package/dist/@types/expressions/SchemaFieldTypeExpression.d.ts +14 -0
- package/dist/@types/expressions/SchemaIndexExpression.d.ts +14 -0
- package/dist/@types/index.d.ts +10 -0
- package/dist/@types/loadSchemaXml.d.ts +8 -0
- package/dist/@types/nodes/SchemaBelongsToNode.d.ts +9 -0
- package/dist/@types/nodes/SchemaDisplayNode.d.ts +8 -0
- package/dist/@types/nodes/SchemaFieldNode.d.ts +21 -0
- package/dist/@types/nodes/SchemaHasManyNode.d.ts +10 -0
- package/dist/@types/nodes/SchemaIndexNode.d.ts +12 -0
- package/dist/@types/nodes/SchemaModelNode.d.ts +26 -0
- package/dist/@types/nodes/SchemaNotificationNode.d.ts +12 -0
- package/dist/@types/nodes/SchemaOptionNode.d.ts +10 -0
- package/dist/@types/nodes/SchemaWebhookFieldNode.d.ts +12 -0
- package/dist/@types/nodes/SchemaWebhookNode.d.ts +14 -0
- package/dist/@types/parsed/ParsedSchemaFieldNode.d.ts +7 -0
- package/dist/@types/parsed/ParsedSchemaModelNode.d.ts +15 -0
- package/dist/@types/parsed/ParsedSchemaNode.d.ts +10 -0
- package/dist/@types/parsed/sourceElement.d.ts +4 -0
- package/dist/@types/schemaSerializer.d.ts +11 -0
- package/dist/@types/tokens/SchemaIndexKeyToken.d.ts +14 -0
- package/dist/SchemaNode.js +20 -0
- package/dist/SchemaNode.js.map +1 -0
- package/dist/XmlField.js +12 -0
- package/dist/XmlField.js.map +1 -0
- package/dist/XmlModel.js +8 -0
- package/dist/XmlModel.js.map +1 -0
- package/dist/XmlParam.js +12 -0
- package/dist/XmlParam.js.map +1 -0
- package/dist/XmlSchema.js +29 -0
- package/dist/XmlSchema.js.map +1 -0
- package/dist/attributes/SchemaDatabaseAttribute.js +12 -0
- package/dist/attributes/SchemaDatabaseAttribute.js.map +1 -0
- package/dist/attributes/SchemaEnumAttribute.js +27 -0
- package/dist/attributes/SchemaEnumAttribute.js.map +1 -0
- package/dist/attributes/SchemaFieldTypeAttribute.js +12 -0
- package/dist/attributes/SchemaFieldTypeAttribute.js.map +1 -0
- package/dist/attributes/SchemaIndexAttribute.js +12 -0
- package/dist/attributes/SchemaIndexAttribute.js.map +1 -0
- package/dist/attributes/SchemaNameAttribute.js +23 -0
- package/dist/attributes/SchemaNameAttribute.js.map +1 -0
- package/dist/attributes/SchemaOptionKeyAttribute.js +30 -0
- package/dist/attributes/SchemaOptionKeyAttribute.js.map +1 -0
- package/dist/expressions/SchemaDatabasesExpression.js +28 -0
- package/dist/expressions/SchemaDatabasesExpression.js.map +1 -0
- package/dist/expressions/SchemaFieldTypeExpression.js +50 -0
- package/dist/expressions/SchemaFieldTypeExpression.js.map +1 -0
- package/dist/expressions/SchemaIndexExpression.js +30 -0
- package/dist/expressions/SchemaIndexExpression.js.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/loadSchemaXml.js +46 -0
- package/dist/loadSchemaXml.js.map +1 -0
- package/dist/nodes/SchemaBelongsToNode.js +14 -0
- package/dist/nodes/SchemaBelongsToNode.js.map +1 -0
- package/dist/nodes/SchemaDisplayNode.js +17 -0
- package/dist/nodes/SchemaDisplayNode.js.map +1 -0
- package/dist/nodes/SchemaFieldNode.js +30 -0
- package/dist/nodes/SchemaFieldNode.js.map +1 -0
- package/dist/nodes/SchemaHasManyNode.js +15 -0
- package/dist/nodes/SchemaHasManyNode.js.map +1 -0
- package/dist/nodes/SchemaIndexNode.js +22 -0
- package/dist/nodes/SchemaIndexNode.js.map +1 -0
- package/dist/nodes/SchemaModelNode.js +34 -0
- package/dist/nodes/SchemaModelNode.js.map +1 -0
- package/dist/nodes/SchemaNotificationNode.js +21 -0
- package/dist/nodes/SchemaNotificationNode.js.map +1 -0
- package/dist/nodes/SchemaOptionNode.js +20 -0
- package/dist/nodes/SchemaOptionNode.js.map +1 -0
- package/dist/nodes/SchemaWebhookFieldNode.js +22 -0
- package/dist/nodes/SchemaWebhookFieldNode.js.map +1 -0
- package/dist/nodes/SchemaWebhookNode.js +20 -0
- package/dist/nodes/SchemaWebhookNode.js.map +1 -0
- package/dist/parsed/ParsedSchemaFieldNode.js +56 -0
- package/dist/parsed/ParsedSchemaFieldNode.js.map +1 -0
- package/dist/parsed/ParsedSchemaModelNode.js +113 -0
- package/dist/parsed/ParsedSchemaModelNode.js.map +1 -0
- package/dist/parsed/ParsedSchemaNode.js +29 -0
- package/dist/parsed/ParsedSchemaNode.js.map +1 -0
- package/dist/parsed/sourceElement.js +12 -0
- package/dist/parsed/sourceElement.js.map +1 -0
- package/dist/schemaSerializer.js +181 -0
- package/dist/schemaSerializer.js.map +1 -0
- package/dist/tokens/SchemaIndexKeyToken.js +39 -0
- package/dist/tokens/SchemaIndexKeyToken.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +41 -3
- package/README.md +0 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Node, NodeGenerics, ParsedNodeShape, ParsedArrayNode, ParseTreeOptions } from '@ja-platform/parser-core';
|
|
2
|
+
import { ParsedSchemaNode } from './parsed/ParsedSchemaNode';
|
|
3
|
+
import { ParsedSchemaModelNode } from './parsed/ParsedSchemaModelNode';
|
|
4
|
+
export interface SchemaShape extends ParsedNodeShape {
|
|
5
|
+
models: ParsedArrayNode<ParsedSchemaModelNode>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The schema XML grammar, producing a tree that can be converted to a schema.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SchemaNode extends Node<NodeGenerics<SchemaShape, ParsedSchemaNode>> {
|
|
11
|
+
constructor();
|
|
12
|
+
protected createParsedNode(options: ParseTreeOptions): ParsedSchemaNode;
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Field } from '@ja-platform/parser-schema';
|
|
2
|
+
import type { Type } from '@ja-platform/parser-type-system';
|
|
3
|
+
import type { XMLElement } from '@journeyapps/domparser/types';
|
|
4
|
+
import type { ParsedSchemaFieldNode } from './parsed/ParsedSchemaFieldNode';
|
|
5
|
+
export declare class XmlField<T extends Type = Type> extends Field<T> {
|
|
6
|
+
parsedNode?: ParsedSchemaFieldNode;
|
|
7
|
+
sourceElement?: XMLElement;
|
|
8
|
+
sourceTypeName?: string;
|
|
9
|
+
readonly optionSources: Map<string, XMLElement>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SchemaModelType } from '@ja-platform/parser-schema';
|
|
2
|
+
import type { WebhookConfig } from '@ja-platform/parser-schema';
|
|
3
|
+
import type { XMLElement } from '@journeyapps/domparser/types';
|
|
4
|
+
import type { ParsedSchemaModelNode } from './parsed/ParsedSchemaModelNode';
|
|
5
|
+
import type { XmlField } from './XmlField';
|
|
6
|
+
export declare class XmlModel extends SchemaModelType {
|
|
7
|
+
parsedNode?: ParsedSchemaModelNode;
|
|
8
|
+
sourceElement?: XMLElement;
|
|
9
|
+
displaySource?: XMLElement;
|
|
10
|
+
attributes: Record<string, XmlField>;
|
|
11
|
+
webhooks: (WebhookConfig & {
|
|
12
|
+
sourceElement?: XMLElement;
|
|
13
|
+
})[];
|
|
14
|
+
belongsToVars: Record<string, XmlField>;
|
|
15
|
+
hasManyVars: Record<string, XmlField>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Param } from '@ja-platform/parser-schema';
|
|
2
|
+
import type { Type } from '@ja-platform/parser-type-system';
|
|
3
|
+
import type { XMLElement } from '@journeyapps/domparser/types';
|
|
4
|
+
export declare class XmlParam<T extends Type = Type> extends Param<T> {
|
|
5
|
+
sourceElement?: XMLElement;
|
|
6
|
+
readonly optionSources: Map<string, XMLElement>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Schema } from '@ja-platform/parser-schema';
|
|
2
|
+
import type { Type } from '@ja-platform/parser-type-system';
|
|
3
|
+
import type { ParsedDiagnostic } from '@ja-platform/parser-core';
|
|
4
|
+
import type { XMLElement } from '@journeyapps/domparser/types';
|
|
5
|
+
import type { ParsedSchemaNode } from './parsed/ParsedSchemaNode';
|
|
6
|
+
import { XmlField } from './XmlField';
|
|
7
|
+
import { XmlParam } from './XmlParam';
|
|
8
|
+
import { XmlModel } from './XmlModel';
|
|
9
|
+
/**
|
|
10
|
+
* A resolved schema retaining its XML declarations for editing and diagnostics.
|
|
11
|
+
*/
|
|
12
|
+
export declare class XmlSchema extends Schema {
|
|
13
|
+
parsedNode?: ParsedSchemaNode;
|
|
14
|
+
sourceElement?: XMLElement;
|
|
15
|
+
errors: ParsedDiagnostic[];
|
|
16
|
+
objects: Record<string, XmlModel>;
|
|
17
|
+
field<T extends Type = Type>(name?: string, type?: T | string): XmlField<T>;
|
|
18
|
+
param<T extends Type = Type>(name?: string, type?: T | string): XmlParam<T>;
|
|
19
|
+
newObjectType(name?: string): XmlModel;
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Attribute, AttributeGenerics, AttributeOptions } from '@ja-platform/parser-core';
|
|
2
|
+
import { IndexDatabase } from '@ja-platform/parser-schema';
|
|
3
|
+
import { SchemaDatabasesExpression } from '../expressions/SchemaDatabasesExpression';
|
|
4
|
+
interface SchemaDatabaseAttributeGenerics extends AttributeGenerics {
|
|
5
|
+
Value: SchemaDatabasesExpression;
|
|
6
|
+
Options: AttributeOptions<IndexDatabase[]>;
|
|
7
|
+
}
|
|
8
|
+
export declare class SchemaDatabaseAttribute extends Attribute<SchemaDatabaseAttributeGenerics> {
|
|
9
|
+
constructor(options: SchemaDatabaseAttributeGenerics['Options']);
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Attribute, AttributeGenerics, AttributeOptions } from '@ja-platform/parser-core';
|
|
2
|
+
import { SchemaFieldTypeExpression } from '../expressions/SchemaFieldTypeExpression';
|
|
3
|
+
interface SchemaFieldTypeAttributeGenerics extends AttributeGenerics {
|
|
4
|
+
Value: SchemaFieldTypeExpression;
|
|
5
|
+
}
|
|
6
|
+
export declare class SchemaFieldTypeAttribute extends Attribute<SchemaFieldTypeAttributeGenerics> {
|
|
7
|
+
constructor(options: AttributeOptions);
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Attribute, AttributeGenerics, AttributeOptions } from '@ja-platform/parser-core';
|
|
2
|
+
import { SchemaIndexExpression } from '../expressions/SchemaIndexExpression';
|
|
3
|
+
interface SchemaIndexAttributeGenerics extends AttributeGenerics {
|
|
4
|
+
Value: SchemaIndexExpression;
|
|
5
|
+
}
|
|
6
|
+
export declare class SchemaIndexAttribute extends Attribute<SchemaIndexAttributeGenerics> {
|
|
7
|
+
constructor(options: AttributeOptions);
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Attribute, AttributeGenerics, AttributeParseEvent } from '@ja-platform/parser-core';
|
|
2
|
+
import { ConstantExpression } from '@ja-platform/parser-expressions';
|
|
3
|
+
export type SchemaOptionKey = string | number | boolean;
|
|
4
|
+
interface SchemaOptionKeyGenerics extends AttributeGenerics {
|
|
5
|
+
Value: ConstantExpression<SchemaOptionKey>;
|
|
6
|
+
NormalizedValue: SchemaOptionKey;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Choice keys use the enclosing field's declared literal type.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SchemaOptionKeyAttribute extends Attribute<SchemaOptionKeyGenerics> {
|
|
12
|
+
constructor();
|
|
13
|
+
protected getParsedValue(event: AttributeParseEvent): ConstantExpression<SchemaOptionKey>;
|
|
14
|
+
private keyType;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AbstractExpressionOptions, ListExpression, ListExpressionParser, IdentifierToken } from '@ja-platform/parser-expressions';
|
|
2
|
+
import { IndexDatabase } from '@ja-platform/parser-schema';
|
|
3
|
+
export declare class SchemaDatabasesExpression extends ListExpression<IdentifierToken> {
|
|
4
|
+
constructor(options: AbstractExpressionOptions);
|
|
5
|
+
isValid(): boolean;
|
|
6
|
+
get databases(): readonly IndexDatabase[];
|
|
7
|
+
}
|
|
8
|
+
export declare class SchemaDatabasesExpressionParser extends ListExpressionParser<SchemaDatabasesExpression> {
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AbstractExpression, AbstractExpressionOptions, ExpressionParser, ExpressionSource } from '@ja-platform/parser-expressions';
|
|
2
|
+
import { PrimitiveTypeMap } from '@ja-platform/parser-schema';
|
|
3
|
+
/**
|
|
4
|
+
* A primitive declaration, with an optional prefix introducing its subtype.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SchemaFieldTypeExpression extends AbstractExpression {
|
|
7
|
+
constructor(options: AbstractExpressionOptions);
|
|
8
|
+
get primitive(): keyof typeof PrimitiveTypeMap;
|
|
9
|
+
get subtype(): string | undefined;
|
|
10
|
+
isValid(): boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class SchemaFieldTypeExpressionParser extends ExpressionParser<SchemaFieldTypeExpression> {
|
|
13
|
+
tryParse(source: ExpressionSource, start?: number): SchemaFieldTypeExpression;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AbstractExpressionOptions, ListExpression, ListExpressionParser } from '@ja-platform/parser-expressions';
|
|
2
|
+
import { ModelIndexKey } from '@ja-platform/parser-schema';
|
|
3
|
+
import { SchemaIndexKeyToken } from '../tokens/SchemaIndexKeyToken';
|
|
4
|
+
/**
|
|
5
|
+
* Index field references and their sort directions, derived from the source tokens.
|
|
6
|
+
*/
|
|
7
|
+
export declare class SchemaIndexExpression extends ListExpression<SchemaIndexKeyToken> {
|
|
8
|
+
constructor(options: AbstractExpressionOptions);
|
|
9
|
+
isValid(): boolean;
|
|
10
|
+
get keys(): readonly ModelIndexKey[];
|
|
11
|
+
}
|
|
12
|
+
export declare class SchemaIndexExpressionParser extends ListExpressionParser<SchemaIndexExpression> {
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './schemaSerializer';
|
|
2
|
+
export * from './loadSchemaXml';
|
|
3
|
+
export * from './SchemaNode';
|
|
4
|
+
export * from './parsed/ParsedSchemaNode';
|
|
5
|
+
export * from './parsed/ParsedSchemaModelNode';
|
|
6
|
+
export * from './parsed/ParsedSchemaFieldNode';
|
|
7
|
+
export * from './XmlSchema';
|
|
8
|
+
export * from './XmlField';
|
|
9
|
+
export * from './XmlModel';
|
|
10
|
+
export * from './XmlParam';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { XmlSchema as Schema } from './XmlSchema';
|
|
2
|
+
export interface LoadSchemaXmlOptions {
|
|
3
|
+
source: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Parse schema XML using the node definitions and convert the resulting tree to a schema.
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadSchemaXml({ source }: LoadSchemaXmlOptions): Schema;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Node, NodeGenerics, ParsedNodeShape } from '@ja-platform/parser-core';
|
|
2
|
+
import { ConstantExpression } from '@ja-platform/parser-expressions';
|
|
3
|
+
export interface SchemaBelongsToShape extends ParsedNodeShape {
|
|
4
|
+
name?: ConstantExpression<string>;
|
|
5
|
+
model: ConstantExpression<string>;
|
|
6
|
+
}
|
|
7
|
+
export declare class SchemaBelongsToNode extends Node<NodeGenerics<SchemaBelongsToShape>> {
|
|
8
|
+
constructor();
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Node, NodeGenerics, ParsedNodeShape } from '@ja-platform/parser-core';
|
|
2
|
+
import { SchemaObjectDisplayExpression } from '@ja-platform/parser-schema';
|
|
3
|
+
export interface SchemaDisplayShape extends ParsedNodeShape {
|
|
4
|
+
format: SchemaObjectDisplayExpression;
|
|
5
|
+
}
|
|
6
|
+
export declare class SchemaDisplayNode extends Node<NodeGenerics<SchemaDisplayShape>> {
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Node, NodeGenerics, ParsedNodeShape, ParsedNode, ParsedArrayNode, ParseTreeOptions } from '@ja-platform/parser-core';
|
|
2
|
+
import { ConstantExpression } from '@ja-platform/parser-expressions';
|
|
3
|
+
import { SchemaFieldTypeExpression } from '../expressions/SchemaFieldTypeExpression';
|
|
4
|
+
import { SchemaOptionShape } from './SchemaOptionNode';
|
|
5
|
+
import { ParsedSchemaFieldNode } from '../parsed/ParsedSchemaFieldNode';
|
|
6
|
+
export interface SchemaFieldShape extends ParsedNodeShape {
|
|
7
|
+
name: ConstantExpression<string>;
|
|
8
|
+
label: ConstantExpression<string>;
|
|
9
|
+
type: SchemaFieldTypeExpression;
|
|
10
|
+
media?: ConstantExpression<string>;
|
|
11
|
+
autoDownload?: ConstantExpression<boolean>;
|
|
12
|
+
spec?: ConstantExpression<string>;
|
|
13
|
+
deprecatedSpec?: ConstantExpression<string>;
|
|
14
|
+
minValue?: ConstantExpression<string>;
|
|
15
|
+
maxValue?: ConstantExpression<string>;
|
|
16
|
+
options: ParsedArrayNode<ParsedNode<SchemaOptionShape>>;
|
|
17
|
+
}
|
|
18
|
+
export declare class SchemaFieldNode extends Node<NodeGenerics<SchemaFieldShape, ParsedSchemaFieldNode>> {
|
|
19
|
+
constructor();
|
|
20
|
+
protected createParsedNode(options: ParseTreeOptions): ParsedSchemaFieldNode;
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Node, NodeGenerics, ParsedNodeShape } from '@ja-platform/parser-core';
|
|
2
|
+
import { ConstantExpression } from '@ja-platform/parser-expressions';
|
|
3
|
+
export interface SchemaHasManyShape extends ParsedNodeShape {
|
|
4
|
+
name: ConstantExpression<string>;
|
|
5
|
+
model: ConstantExpression<string>;
|
|
6
|
+
inverseOf?: ConstantExpression<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare class SchemaHasManyNode extends Node<NodeGenerics<SchemaHasManyShape>> {
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Node, NodeGenerics, ParsedNodeShape } from '@ja-platform/parser-core';
|
|
2
|
+
import { ConstantExpression } from '@ja-platform/parser-expressions';
|
|
3
|
+
import { SchemaIndexExpression } from '../expressions/SchemaIndexExpression';
|
|
4
|
+
import { SchemaDatabasesExpression } from '../expressions/SchemaDatabasesExpression';
|
|
5
|
+
export interface SchemaIndexShape extends ParsedNodeShape {
|
|
6
|
+
name?: ConstantExpression<string>;
|
|
7
|
+
keys: SchemaIndexExpression;
|
|
8
|
+
databases?: SchemaDatabasesExpression;
|
|
9
|
+
}
|
|
10
|
+
export declare class SchemaIndexNode extends Node<NodeGenerics<SchemaIndexShape>> {
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Node, NodeGenerics, ParsedNodeShape, ParsedNode, ParsedArrayNode, ParseTreeOptions } from '@ja-platform/parser-core';
|
|
2
|
+
import { ConstantExpression } from '@ja-platform/parser-expressions';
|
|
3
|
+
import { ParsedSchemaFieldNode } from '../parsed/ParsedSchemaFieldNode';
|
|
4
|
+
import { ParsedSchemaModelNode } from '../parsed/ParsedSchemaModelNode';
|
|
5
|
+
import { SchemaBelongsToShape } from './SchemaBelongsToNode';
|
|
6
|
+
import { SchemaHasManyShape } from './SchemaHasManyNode';
|
|
7
|
+
import { SchemaIndexShape } from './SchemaIndexNode';
|
|
8
|
+
import { SchemaDisplayShape } from './SchemaDisplayNode';
|
|
9
|
+
import { SchemaNotificationShape } from './SchemaNotificationNode';
|
|
10
|
+
import { SchemaWebhookShape } from './SchemaWebhookNode';
|
|
11
|
+
export interface SchemaModelShape extends ParsedNodeShape {
|
|
12
|
+
name: ConstantExpression<string>;
|
|
13
|
+
label: ConstantExpression<string>;
|
|
14
|
+
classification?: ConstantExpression<string>;
|
|
15
|
+
fields: ParsedArrayNode<ParsedSchemaFieldNode>;
|
|
16
|
+
belongsTo: ParsedArrayNode<ParsedNode<SchemaBelongsToShape>>;
|
|
17
|
+
hasMany: ParsedArrayNode<ParsedNode<SchemaHasManyShape>>;
|
|
18
|
+
indexes: ParsedArrayNode<ParsedNode<SchemaIndexShape>>;
|
|
19
|
+
display?: ParsedNode<SchemaDisplayShape>;
|
|
20
|
+
notifications: ParsedArrayNode<ParsedNode<SchemaNotificationShape>>;
|
|
21
|
+
webhooks: ParsedArrayNode<ParsedNode<SchemaWebhookShape>>;
|
|
22
|
+
}
|
|
23
|
+
export declare class SchemaModelNode extends Node<NodeGenerics<SchemaModelShape, ParsedSchemaModelNode>> {
|
|
24
|
+
constructor();
|
|
25
|
+
protected createParsedNode(options: ParseTreeOptions): ParsedSchemaModelNode;
|
|
26
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Node, NodeGenerics, ParsedNodeShape } from '@ja-platform/parser-core';
|
|
2
|
+
import { ConstantExpression } from '@ja-platform/parser-expressions';
|
|
3
|
+
import { SchemaObjectDisplayExpression } from '@ja-platform/parser-schema';
|
|
4
|
+
export interface SchemaNotificationShape extends ParsedNodeShape {
|
|
5
|
+
message: SchemaObjectDisplayExpression;
|
|
6
|
+
received: ConstantExpression<string>;
|
|
7
|
+
recipient: ConstantExpression<string>;
|
|
8
|
+
badgeCount?: ConstantExpression<string>;
|
|
9
|
+
}
|
|
10
|
+
export declare class SchemaNotificationNode extends Node<NodeGenerics<SchemaNotificationShape>> {
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Node, NodeGenerics, ParsedNodeShape } from '@ja-platform/parser-core';
|
|
2
|
+
import { ConstantExpression } from '@ja-platform/parser-expressions';
|
|
3
|
+
import { SchemaOptionKey } from '../attributes/SchemaOptionKeyAttribute';
|
|
4
|
+
export interface SchemaOptionShape extends ParsedNodeShape {
|
|
5
|
+
key?: ConstantExpression<SchemaOptionKey>;
|
|
6
|
+
label: ConstantExpression<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare class SchemaOptionNode extends Node<NodeGenerics<SchemaOptionShape>> {
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Node, NodeGenerics, ParsedNodeShape } from '@ja-platform/parser-core';
|
|
2
|
+
import { ConstantExpression } from '@ja-platform/parser-expressions';
|
|
3
|
+
import { WebhookFieldState } from '@ja-platform/parser-schema';
|
|
4
|
+
export interface SchemaWebhookFieldShape extends ParsedNodeShape {
|
|
5
|
+
name: ConstantExpression<string>;
|
|
6
|
+
required?: ConstantExpression<boolean>;
|
|
7
|
+
embed?: ConstantExpression<boolean>;
|
|
8
|
+
state?: ConstantExpression<WebhookFieldState>;
|
|
9
|
+
}
|
|
10
|
+
export declare class SchemaWebhookFieldNode extends Node<NodeGenerics<SchemaWebhookFieldShape>> {
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Node, NodeGenerics, ParsedNodeShape, ParsedNode, ParsedArrayNode } from '@ja-platform/parser-core';
|
|
2
|
+
import { ConstantExpression } from '@ja-platform/parser-expressions';
|
|
3
|
+
import { WebhookReceiver, WebhookType } from '@ja-platform/parser-schema';
|
|
4
|
+
import { SchemaWebhookFieldShape } from './SchemaWebhookFieldNode';
|
|
5
|
+
export interface SchemaWebhookShape extends ParsedNodeShape {
|
|
6
|
+
name?: ConstantExpression<string>;
|
|
7
|
+
type: ConstantExpression<WebhookType>;
|
|
8
|
+
receiver?: ConstantExpression<WebhookReceiver>;
|
|
9
|
+
action?: ConstantExpression<string>;
|
|
10
|
+
fields: ParsedArrayNode<ParsedNode<SchemaWebhookFieldShape>>;
|
|
11
|
+
}
|
|
12
|
+
export declare class SchemaWebhookNode extends Node<NodeGenerics<SchemaWebhookShape>> {
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ParsedNode } from '@ja-platform/parser-core';
|
|
2
|
+
import { XmlSchema as Schema } from '../XmlSchema';
|
|
3
|
+
import { XmlField as Field } from '../XmlField';
|
|
4
|
+
import type { SchemaFieldShape } from '../nodes/SchemaFieldNode';
|
|
5
|
+
export declare class ParsedSchemaFieldNode extends ParsedNode<SchemaFieldShape> {
|
|
6
|
+
toField(schema: Schema): Field;
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ParsedNode } from '@ja-platform/parser-core';
|
|
2
|
+
import { XmlSchema as Schema } from '../XmlSchema';
|
|
3
|
+
import { XmlModel as SchemaModelType } from '../XmlModel';
|
|
4
|
+
import type { SchemaModelShape } from '../nodes/SchemaModelNode';
|
|
5
|
+
export declare class ParsedSchemaModelNode extends ParsedNode<SchemaModelShape> {
|
|
6
|
+
toModel(schema: Schema): SchemaModelType;
|
|
7
|
+
resolveBelongsTo({ schema, model }: {
|
|
8
|
+
schema: Schema;
|
|
9
|
+
model: SchemaModelType;
|
|
10
|
+
}): void;
|
|
11
|
+
resolveHasMany({ schema, model }: {
|
|
12
|
+
schema: Schema;
|
|
13
|
+
model: SchemaModelType;
|
|
14
|
+
}): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ParsedNode } from '@ja-platform/parser-core';
|
|
2
|
+
import { XmlSchema as Schema } from '../XmlSchema';
|
|
3
|
+
import type { SchemaShape } from '../SchemaNode';
|
|
4
|
+
export declare class ParsedSchemaNode extends ParsedNode<SchemaShape> {
|
|
5
|
+
/**
|
|
6
|
+
* Construct a fresh schema from the parsed declarations, then link its relationships.
|
|
7
|
+
* Validation remains an explicit, separate operation on the parsed tree.
|
|
8
|
+
*/
|
|
9
|
+
toSchema(): Schema;
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ParsedNode } from '@ja-platform/parser-core';
|
|
2
|
+
import type { XMLElement } from '@journeyapps/domparser/types';
|
|
3
|
+
/** Recover the original XML node for incremental schema serialization. */
|
|
4
|
+
export declare function sourceElement(node?: ParsedNode): XMLElement | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { XmlSchema as Schema } from './XmlSchema';
|
|
2
|
+
import { OrderedIncrementalUpdater } from '@journeyapps/common-xml';
|
|
3
|
+
import { XMLDocument } from '@journeyapps/domparser/types';
|
|
4
|
+
import { XmlField as Field } from './XmlField';
|
|
5
|
+
export declare function toDOM(schema: Schema): XMLDocument;
|
|
6
|
+
/**
|
|
7
|
+
* Update the options for single-choice, single-choice-integer and boolean fields.
|
|
8
|
+
*
|
|
9
|
+
* No-op for other fields.
|
|
10
|
+
*/
|
|
11
|
+
export declare function updateOptions(fieldDiff: OrderedIncrementalUpdater, attribute: Field): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AbstractToken } from '@ja-platform/parser-expressions';
|
|
2
|
+
import { IndexDirection } from '@ja-platform/parser-schema';
|
|
3
|
+
/**
|
|
4
|
+
* An index field reference with its optional sort direction.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SchemaIndexKeyToken extends AbstractToken {
|
|
7
|
+
readonly source: string;
|
|
8
|
+
constructor(source: string, start?: number);
|
|
9
|
+
get field(): string;
|
|
10
|
+
get direction(): IndexDirection;
|
|
11
|
+
isValid(): boolean;
|
|
12
|
+
raw(): string;
|
|
13
|
+
clone(): this;
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaNode = void 0;
|
|
4
|
+
const parser_core_1 = require("@ja-platform/parser-core");
|
|
5
|
+
const SchemaModelNode_1 = require("./nodes/SchemaModelNode");
|
|
6
|
+
const ParsedSchemaNode_1 = require("./parsed/ParsedSchemaNode");
|
|
7
|
+
/**
|
|
8
|
+
* The schema XML grammar, producing a tree that can be converted to a schema.
|
|
9
|
+
*/
|
|
10
|
+
class SchemaNode extends parser_core_1.Node {
|
|
11
|
+
constructor() {
|
|
12
|
+
super({ name: 'data-model' });
|
|
13
|
+
this.addNode(new SchemaModelNode_1.SchemaModelNode());
|
|
14
|
+
}
|
|
15
|
+
createParsedNode(options) {
|
|
16
|
+
return new ParsedSchemaNode_1.ParsedSchemaNode(Object.assign({ definition: this }, options));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.SchemaNode = SchemaNode;
|
|
20
|
+
//# sourceMappingURL=SchemaNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaNode.js","sourceRoot":"","sources":["../src/SchemaNode.ts"],"names":[],"mappings":";;;AAAA,0DAAkH;AAClH,6DAA0D;AAC1D,gEAA6D;AAO7D;;GAEG;AACH,gBAAwB,SAAQ,kBAAiD;IAC/E;QACE,KAAK,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;QAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,iCAAe,EAAE,CAAC,CAAC;IACtC,CAAC;IAES,gBAAgB,CAAC,OAAyB;QAClD,OAAO,IAAI,mCAAgB,iBAAG,UAAU,EAAE,IAAI,IAAK,OAAO,EAAG,CAAC;IAChE,CAAC;CACF","sourcesContent":["import { Node, NodeGenerics, ParsedNodeShape, ParsedArrayNode, ParseTreeOptions } from '@ja-platform/parser-core';\nimport { SchemaModelNode } from './nodes/SchemaModelNode';\nimport { ParsedSchemaNode } from './parsed/ParsedSchemaNode';\nimport { ParsedSchemaModelNode } from './parsed/ParsedSchemaModelNode';\n\nexport interface SchemaShape extends ParsedNodeShape {\n models: ParsedArrayNode<ParsedSchemaModelNode>;\n}\n\n/**\n * The schema XML grammar, producing a tree that can be converted to a schema.\n */\nexport class SchemaNode extends Node<NodeGenerics<SchemaShape, ParsedSchemaNode>> {\n constructor() {\n super({ name: 'data-model' });\n this.addNode(new SchemaModelNode());\n }\n\n protected createParsedNode(options: ParseTreeOptions): ParsedSchemaNode {\n return new ParsedSchemaNode({ definition: this, ...options });\n }\n}\n"]}
|
package/dist/XmlField.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XmlField = void 0;
|
|
4
|
+
const parser_schema_1 = require("@ja-platform/parser-schema");
|
|
5
|
+
class XmlField extends parser_schema_1.Field {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.optionSources = new Map();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.XmlField = XmlField;
|
|
12
|
+
//# sourceMappingURL=XmlField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XmlField.js","sourceRoot":"","sources":["../src/XmlField.ts"],"names":[],"mappings":";;;AAAA,8DAAmD;AAKnD,cAA6C,SAAQ,qBAAQ;IAA7D;;QAIW,kBAAa,GAAG,IAAI,GAAG,EAAsB,CAAC;IACzD,CAAC;CAAA","sourcesContent":["import { Field } from '@ja-platform/parser-schema';\nimport type { Type } from '@ja-platform/parser-type-system';\nimport type { XMLElement } from '@journeyapps/domparser/types';\nimport type { ParsedSchemaFieldNode } from './parsed/ParsedSchemaFieldNode';\n\nexport class XmlField<T extends Type = Type> extends Field<T> {\n parsedNode?: ParsedSchemaFieldNode;\n sourceElement?: XMLElement;\n sourceTypeName?: string;\n readonly optionSources = new Map<string, XMLElement>();\n}\n"]}
|
package/dist/XmlModel.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XmlModel = void 0;
|
|
4
|
+
const parser_schema_1 = require("@ja-platform/parser-schema");
|
|
5
|
+
class XmlModel extends parser_schema_1.SchemaModelType {
|
|
6
|
+
}
|
|
7
|
+
exports.XmlModel = XmlModel;
|
|
8
|
+
//# sourceMappingURL=XmlModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XmlModel.js","sourceRoot":"","sources":["../src/XmlModel.ts"],"names":[],"mappings":";;;AAAA,8DAA6D;AAM7D,cAAsB,SAAQ,+BAAe;CAQ5C","sourcesContent":["import { SchemaModelType } from '@ja-platform/parser-schema';\nimport type { WebhookConfig } from '@ja-platform/parser-schema';\nimport type { XMLElement } from '@journeyapps/domparser/types';\nimport type { ParsedSchemaModelNode } from './parsed/ParsedSchemaModelNode';\nimport type { XmlField } from './XmlField';\n\nexport class XmlModel extends SchemaModelType {\n parsedNode?: ParsedSchemaModelNode;\n sourceElement?: XMLElement;\n displaySource?: XMLElement;\n declare attributes: Record<string, XmlField>;\n declare webhooks: (WebhookConfig & { sourceElement?: XMLElement })[];\n declare belongsToVars: Record<string, XmlField>;\n declare hasManyVars: Record<string, XmlField>;\n}\n"]}
|
package/dist/XmlParam.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XmlParam = void 0;
|
|
4
|
+
const parser_schema_1 = require("@ja-platform/parser-schema");
|
|
5
|
+
class XmlParam extends parser_schema_1.Param {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.optionSources = new Map();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.XmlParam = XmlParam;
|
|
12
|
+
//# sourceMappingURL=XmlParam.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XmlParam.js","sourceRoot":"","sources":["../src/XmlParam.ts"],"names":[],"mappings":";;;AAAA,8DAAmD;AAInD,cAA6C,SAAQ,qBAAQ;IAA7D;;QAEW,kBAAa,GAAG,IAAI,GAAG,EAAsB,CAAC;IACzD,CAAC;CAAA","sourcesContent":["import { Param } from '@ja-platform/parser-schema';\nimport type { Type } from '@ja-platform/parser-type-system';\nimport type { XMLElement } from '@journeyapps/domparser/types';\n\nexport class XmlParam<T extends Type = Type> extends Param<T> {\n sourceElement?: XMLElement;\n readonly optionSources = new Map<string, XMLElement>();\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XmlSchema = void 0;
|
|
4
|
+
const parser_schema_1 = require("@ja-platform/parser-schema");
|
|
5
|
+
const XmlField_1 = require("./XmlField");
|
|
6
|
+
const XmlParam_1 = require("./XmlParam");
|
|
7
|
+
const XmlModel_1 = require("./XmlModel");
|
|
8
|
+
/**
|
|
9
|
+
* A resolved schema retaining its XML declarations for editing and diagnostics.
|
|
10
|
+
*/
|
|
11
|
+
class XmlSchema extends parser_schema_1.Schema {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.errors = [];
|
|
15
|
+
}
|
|
16
|
+
field(name, type) {
|
|
17
|
+
return new XmlField_1.XmlField(name, (typeof type === 'string' ? this.getType(type) : type));
|
|
18
|
+
}
|
|
19
|
+
param(name, type) {
|
|
20
|
+
return new XmlParam_1.XmlParam(name, (typeof type === 'string' ? this.getType(type) : type));
|
|
21
|
+
}
|
|
22
|
+
newObjectType(name) {
|
|
23
|
+
const model = new XmlModel_1.XmlModel(name);
|
|
24
|
+
model.setupVariables(this);
|
|
25
|
+
return model;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.XmlSchema = XmlSchema;
|
|
29
|
+
//# sourceMappingURL=XmlSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XmlSchema.js","sourceRoot":"","sources":["../src/XmlSchema.ts"],"names":[],"mappings":";;;AAAA,8DAAoD;AAKpD,yCAAsC;AACtC,yCAAsC;AACtC,yCAAsC;AAEtC;;GAEG;AACH,eAAuB,SAAQ,sBAAM;IAArC;;QAGE,WAAM,GAAuB,EAAE,CAAC;IAgBlC,CAAC;IAbC,KAAK,CAAwB,IAAa,EAAE,IAAiB;QAC3D,OAAO,IAAI,mBAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAM,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAwB,IAAa,EAAE,IAAiB;QAC3D,OAAO,IAAI,mBAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAM,CAAC,CAAC;IACzF,CAAC;IAED,aAAa,CAAC,IAAa;QACzB,MAAM,KAAK,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,CAAC;QACjC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["import { Schema } from '@ja-platform/parser-schema';\nimport type { Type } from '@ja-platform/parser-type-system';\nimport type { ParsedDiagnostic } from '@ja-platform/parser-core';\nimport type { XMLElement } from '@journeyapps/domparser/types';\nimport type { ParsedSchemaNode } from './parsed/ParsedSchemaNode';\nimport { XmlField } from './XmlField';\nimport { XmlParam } from './XmlParam';\nimport { XmlModel } from './XmlModel';\n\n/**\n * A resolved schema retaining its XML declarations for editing and diagnostics.\n */\nexport class XmlSchema extends Schema {\n parsedNode?: ParsedSchemaNode;\n sourceElement?: XMLElement;\n errors: ParsedDiagnostic[] = [];\n declare objects: Record<string, XmlModel>;\n\n field<T extends Type = Type>(name?: string, type?: T | string): XmlField<T> {\n return new XmlField(name, (typeof type === 'string' ? this.getType(type) : type) as T);\n }\n\n param<T extends Type = Type>(name?: string, type?: T | string): XmlParam<T> {\n return new XmlParam(name, (typeof type === 'string' ? this.getType(type) : type) as T);\n }\n\n newObjectType(name?: string): XmlModel {\n const model = new XmlModel(name);\n model.setupVariables(this);\n return model;\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaDatabaseAttribute = void 0;
|
|
4
|
+
const parser_core_1 = require("@ja-platform/parser-core");
|
|
5
|
+
const SchemaDatabasesExpression_1 = require("../expressions/SchemaDatabasesExpression");
|
|
6
|
+
class SchemaDatabaseAttribute extends parser_core_1.Attribute {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super('schema-databases', Object.assign(Object.assign({}, options), { syntax: new SchemaDatabasesExpression_1.SchemaDatabasesExpressionParser() }));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.SchemaDatabaseAttribute = SchemaDatabaseAttribute;
|
|
12
|
+
//# sourceMappingURL=SchemaDatabaseAttribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaDatabaseAttribute.js","sourceRoot":"","sources":["../../src/attributes/SchemaDatabaseAttribute.ts"],"names":[],"mappings":";;;AAAA,0DAA0F;AAE1F,wFAAsH;AAOtH,6BAAqC,SAAQ,uBAA0C;IACrF,YAAY,OAAmD;QAC7D,KAAK,CAAC,kBAAkB,kCAAO,OAAO,KAAE,MAAM,EAAE,IAAI,2DAA+B,EAAE,IAAG,CAAC;IAC3F,CAAC;CACF","sourcesContent":["import { Attribute, AttributeGenerics, AttributeOptions } from '@ja-platform/parser-core';\nimport { IndexDatabase } from '@ja-platform/parser-schema';\nimport { SchemaDatabasesExpression, SchemaDatabasesExpressionParser } from '../expressions/SchemaDatabasesExpression';\n\ninterface SchemaDatabaseAttributeGenerics extends AttributeGenerics {\n Value: SchemaDatabasesExpression;\n Options: AttributeOptions<IndexDatabase[]>;\n}\n\nexport class SchemaDatabaseAttribute extends Attribute<SchemaDatabaseAttributeGenerics> {\n constructor(options: SchemaDatabaseAttributeGenerics['Options']) {\n super('schema-databases', { ...options, syntax: new SchemaDatabasesExpressionParser() });\n }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaEnumAttribute = void 0;
|
|
4
|
+
const parser_core_1 = require("@ja-platform/parser-core");
|
|
5
|
+
const parser_type_system_1 = require("@ja-platform/parser-type-system");
|
|
6
|
+
/**
|
|
7
|
+
* Schema enums are literal strings, without evaluated syntax or engine size defaults.
|
|
8
|
+
*/
|
|
9
|
+
class SchemaEnumType extends parser_type_system_1.TextType {
|
|
10
|
+
constructor(values) {
|
|
11
|
+
super();
|
|
12
|
+
this.values = values;
|
|
13
|
+
}
|
|
14
|
+
parse(value) {
|
|
15
|
+
const text = super.parse(value);
|
|
16
|
+
if (!this.values.includes(text))
|
|
17
|
+
throw new SyntaxError(`Expected one of ${this.values.join(', ')}`);
|
|
18
|
+
return text;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
class SchemaEnumAttribute extends parser_core_1.ConstantTextAttribute {
|
|
22
|
+
constructor(options) {
|
|
23
|
+
super(Object.assign(Object.assign({}, options), { valueType: new SchemaEnumType(options.values) }));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.SchemaEnumAttribute = SchemaEnumAttribute;
|
|
27
|
+
//# sourceMappingURL=SchemaEnumAttribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaEnumAttribute.js","sourceRoot":"","sources":["../../src/attributes/SchemaEnumAttribute.ts"],"names":[],"mappings":";;;AAAA,0DAAmF;AACnF,wEAA2D;AAE3D;;GAEG;AACH,MAAM,cAAe,SAAQ,6BAAQ;IACnC,YAAqB,MAAyB;QAC5C,KAAK,EAAE,CAAC;sBADW,MAAM;IAE3B,CAAC;IAED,KAAK,CAAC,KAAc;QAClB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,WAAW,CAAC,mBAAmB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpG,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,yBAAiC,SAAQ,mCAAqB;IAC5D,YAAY,OAAyE;QACnF,KAAK,iCAAM,OAAO,KAAE,SAAS,EAAE,IAAI,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,IAAG,CAAC;IACvE,CAAC;CACF","sourcesContent":["import { ConstantTextAttribute, AttributeOptions } from '@ja-platform/parser-core';\nimport { TextType } from '@ja-platform/parser-type-system';\n\n/**\n * Schema enums are literal strings, without evaluated syntax or engine size defaults.\n */\nclass SchemaEnumType extends TextType {\n constructor(readonly values: readonly string[]) {\n super();\n }\n\n parse(value: unknown): string {\n const text = super.parse(value);\n if (!this.values.includes(text)) throw new SyntaxError(`Expected one of ${this.values.join(', ')}`);\n return text;\n }\n}\n\nexport class SchemaEnumAttribute extends ConstantTextAttribute {\n constructor(options: AttributeOptions<string, string> & { values: readonly string[] }) {\n super({ ...options, valueType: new SchemaEnumType(options.values) });\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaFieldTypeAttribute = void 0;
|
|
4
|
+
const parser_core_1 = require("@ja-platform/parser-core");
|
|
5
|
+
const SchemaFieldTypeExpression_1 = require("../expressions/SchemaFieldTypeExpression");
|
|
6
|
+
class SchemaFieldTypeAttribute extends parser_core_1.Attribute {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
super('schema-field-type', Object.assign(Object.assign({}, options), { syntax: new SchemaFieldTypeExpression_1.SchemaFieldTypeExpressionParser() }));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.SchemaFieldTypeAttribute = SchemaFieldTypeAttribute;
|
|
12
|
+
//# sourceMappingURL=SchemaFieldTypeAttribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaFieldTypeAttribute.js","sourceRoot":"","sources":["../../src/attributes/SchemaFieldTypeAttribute.ts"],"names":[],"mappings":";;;AAAA,0DAA0F;AAC1F,wFAAsH;AAMtH,8BAAsC,SAAQ,uBAA2C;IACvF,YAAY,OAAyB;QACnC,KAAK,CAAC,mBAAmB,kCAAO,OAAO,KAAE,MAAM,EAAE,IAAI,2DAA+B,EAAE,IAAG,CAAC;IAC5F,CAAC;CACF","sourcesContent":["import { Attribute, AttributeGenerics, AttributeOptions } from '@ja-platform/parser-core';\nimport { SchemaFieldTypeExpression, SchemaFieldTypeExpressionParser } from '../expressions/SchemaFieldTypeExpression';\n\ninterface SchemaFieldTypeAttributeGenerics extends AttributeGenerics {\n Value: SchemaFieldTypeExpression;\n}\n\nexport class SchemaFieldTypeAttribute extends Attribute<SchemaFieldTypeAttributeGenerics> {\n constructor(options: AttributeOptions) {\n super('schema-field-type', { ...options, syntax: new SchemaFieldTypeExpressionParser() });\n }\n}\n"]}
|