@ja-platform/parser-schema 0.0.0-dev-20261019214152
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/Version.d.ts +19 -0
- package/dist/@types/day/Day.d.ts +4 -0
- package/dist/@types/day/DayConstructorInterface.d.ts +50 -0
- package/dist/@types/day/DayInterface.d.ts +34 -0
- package/dist/@types/day/index.d.ts +2 -0
- package/dist/@types/day/utils.d.ts +4 -0
- package/dist/@types/expressions/SchemaObjectDisplayExpression.d.ts +17 -0
- package/dist/@types/index.d.ts +16 -0
- package/dist/@types/schema/ModelIndex.d.ts +19 -0
- package/dist/@types/schema/Schema.d.ts +51 -0
- package/dist/@types/schema/SchemaParserErrors.d.ts +10 -0
- package/dist/@types/schema/TypeFactory.d.ts +26 -0
- package/dist/@types/schema/reservedNames.d.ts +7 -0
- package/dist/@types/schema/schemaParser.d.ts +43 -0
- package/dist/@types/schema/schemaSerializer.d.ts +11 -0
- package/dist/@types/types/EnumOption.d.ts +15 -0
- package/dist/@types/types/FunctionType.d.ts +15 -0
- package/dist/@types/types/Param.d.ts +19 -0
- package/dist/@types/types/QueryType.d.ts +19 -0
- package/dist/@types/types/Relationship.d.ts +20 -0
- package/dist/@types/types/SchemaModelType.d.ts +89 -0
- package/dist/@types/types/Variable.d.ts +32 -0
- package/dist/@types/types/primitives/Boolean.d.ts +21 -0
- package/dist/@types/types/primitives/ChoiceType.d.ts +47 -0
- package/dist/@types/types/primitives/Date.d.ts +13 -0
- package/dist/@types/types/primitives/Datetime.d.ts +9 -0
- package/dist/@types/types/primitives/GeoTrack.d.ts +5 -0
- package/dist/@types/types/primitives/Location.d.ts +6 -0
- package/dist/@types/types/primitives/MultipleChoice.d.ts +5 -0
- package/dist/@types/types/primitives/MultipleChoiceInteger.d.ts +8 -0
- package/dist/@types/types/primitives/SingleChoice.d.ts +5 -0
- package/dist/@types/types/primitives/SingleChoiceInteger.d.ts +8 -0
- package/dist/@types/types/primitives/Text.d.ts +8 -0
- package/dist/@types/types/primitives/attachments/Attachment.d.ts +9 -0
- package/dist/@types/types/primitives/attachments/Photo.d.ts +6 -0
- package/dist/@types/types/primitives/attachments/Signature.d.ts +6 -0
- package/dist/@types/types/primitives/index.d.ts +67 -0
- package/dist/Version.js +76 -0
- package/dist/Version.js.map +1 -0
- package/dist/day/Day.js +112 -0
- package/dist/day/Day.js.map +1 -0
- package/dist/day/DayConstructorInterface.js +3 -0
- package/dist/day/DayConstructorInterface.js.map +1 -0
- package/dist/day/DayInterface.js +3 -0
- package/dist/day/DayInterface.js.map +1 -0
- package/dist/day/index.js +19 -0
- package/dist/day/index.js.map +1 -0
- package/dist/day/utils.js +43 -0
- package/dist/day/utils.js.map +1 -0
- package/dist/expressions/SchemaObjectDisplayExpression.js +40 -0
- package/dist/expressions/SchemaObjectDisplayExpression.js.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/schema/ModelIndex.js +14 -0
- package/dist/schema/ModelIndex.js.map +1 -0
- package/dist/schema/Schema.js +132 -0
- package/dist/schema/Schema.js.map +1 -0
- package/dist/schema/SchemaParserErrors.js +26 -0
- package/dist/schema/SchemaParserErrors.js.map +1 -0
- package/dist/schema/TypeFactory.js +21 -0
- package/dist/schema/TypeFactory.js.map +1 -0
- package/dist/schema/reservedNames.js +101 -0
- package/dist/schema/reservedNames.js.map +1 -0
- package/dist/schema/schemaParser.js +1135 -0
- package/dist/schema/schemaParser.js.map +1 -0
- package/dist/schema/schemaSerializer.js +181 -0
- package/dist/schema/schemaSerializer.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/EnumOption.js +22 -0
- package/dist/types/EnumOption.js.map +1 -0
- package/dist/types/FunctionType.js +30 -0
- package/dist/types/FunctionType.js.map +1 -0
- package/dist/types/Param.js +35 -0
- package/dist/types/Param.js.map +1 -0
- package/dist/types/QueryType.js +37 -0
- package/dist/types/QueryType.js.map +1 -0
- package/dist/types/Relationship.js +25 -0
- package/dist/types/Relationship.js.map +1 -0
- package/dist/types/SchemaModelType.js +147 -0
- package/dist/types/SchemaModelType.js.map +1 -0
- package/dist/types/Variable.js +49 -0
- package/dist/types/Variable.js.map +1 -0
- package/dist/types/primitives/Boolean.js +9 -0
- package/dist/types/primitives/Boolean.js.map +1 -0
- package/dist/types/primitives/ChoiceType.js +65 -0
- package/dist/types/primitives/ChoiceType.js.map +1 -0
- package/dist/types/primitives/Date.js +68 -0
- package/dist/types/primitives/Date.js.map +1 -0
- package/dist/types/primitives/Datetime.js +31 -0
- package/dist/types/primitives/Datetime.js.map +1 -0
- package/dist/types/primitives/GeoTrack.js +12 -0
- package/dist/types/primitives/GeoTrack.js.map +1 -0
- package/dist/types/primitives/Location.js +18 -0
- package/dist/types/primitives/Location.js.map +1 -0
- package/dist/types/primitives/MultipleChoice.js +12 -0
- package/dist/types/primitives/MultipleChoice.js.map +1 -0
- package/dist/types/primitives/MultipleChoiceInteger.js +34 -0
- package/dist/types/primitives/MultipleChoiceInteger.js.map +1 -0
- package/dist/types/primitives/SingleChoice.js +12 -0
- package/dist/types/primitives/SingleChoice.js.map +1 -0
- package/dist/types/primitives/SingleChoiceInteger.js +38 -0
- package/dist/types/primitives/SingleChoiceInteger.js.map +1 -0
- package/dist/types/primitives/Text.js +22 -0
- package/dist/types/primitives/Text.js.map +1 -0
- package/dist/types/primitives/attachments/Attachment.js +16 -0
- package/dist/types/primitives/attachments/Attachment.js.map +1 -0
- package/dist/types/primitives/attachments/Photo.js +16 -0
- package/dist/types/primitives/attachments/Photo.js.map +1 -0
- package/dist/types/primitives/attachments/Signature.js +16 -0
- package/dist/types/primitives/attachments/Signature.js.map +1 -0
- package/dist/types/primitives/index.js +85 -0
- package/dist/types/primitives/index.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version-related functions
|
|
3
|
+
*/
|
|
4
|
+
export declare class Version {
|
|
5
|
+
major: number;
|
|
6
|
+
minor: number;
|
|
7
|
+
hasPatch: boolean;
|
|
8
|
+
patch: number;
|
|
9
|
+
v3: boolean;
|
|
10
|
+
v3_1: boolean;
|
|
11
|
+
v2: boolean;
|
|
12
|
+
constructor(str: string);
|
|
13
|
+
toString(): string;
|
|
14
|
+
valueOf(): string;
|
|
15
|
+
compareTo(other: Version): -1 | 0 | 1;
|
|
16
|
+
supportsApi(api: string | Version): boolean;
|
|
17
|
+
gte(other: string | Version): boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const DEFAULT: Version;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Day } from './DayInterface';
|
|
2
|
+
export interface DayConstructor {
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param year number, e.g. 2001
|
|
6
|
+
* @param month 0-11
|
|
7
|
+
* @param day 1-31
|
|
8
|
+
*/
|
|
9
|
+
new (year: number, month: number, day: number): Day;
|
|
10
|
+
/**
|
|
11
|
+
* Construct from a Date(time) object, using the date in the local timezone.
|
|
12
|
+
*/
|
|
13
|
+
new (date: Date): Day;
|
|
14
|
+
/**
|
|
15
|
+
* Clone a Day object.
|
|
16
|
+
*/
|
|
17
|
+
new (date: Day): Day;
|
|
18
|
+
/**
|
|
19
|
+
* Parse a date string, for example:
|
|
20
|
+
*
|
|
21
|
+
* new Day("2014-02-15")
|
|
22
|
+
* new Day("2014-02-15T13:15")
|
|
23
|
+
* new Day("2014-02-15T13:15:11+02")
|
|
24
|
+
* new Day("2014-02-15T11:15:11Z")
|
|
25
|
+
*
|
|
26
|
+
* @param date - date string
|
|
27
|
+
*/
|
|
28
|
+
new (date: string): Day;
|
|
29
|
+
/**
|
|
30
|
+
* Construct from a timestamp number.
|
|
31
|
+
*
|
|
32
|
+
* Must be at exactly 00:00 in UTC.
|
|
33
|
+
*
|
|
34
|
+
* @param date - timestamp in ms
|
|
35
|
+
*/
|
|
36
|
+
new (date: number): Day;
|
|
37
|
+
/**
|
|
38
|
+
* Today in the current timezone.
|
|
39
|
+
*/
|
|
40
|
+
new (): Day;
|
|
41
|
+
/**
|
|
42
|
+
* Today in the current timezone.
|
|
43
|
+
*/
|
|
44
|
+
today(): Day;
|
|
45
|
+
fromUTCDate(date: Date): Day;
|
|
46
|
+
/**
|
|
47
|
+
* Return true if the argument is a Day object.
|
|
48
|
+
*/
|
|
49
|
+
isDay(obj: any): obj is Day;
|
|
50
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface Day {
|
|
2
|
+
/**
|
|
3
|
+
* Start of the Day (00:00) in UTC.
|
|
4
|
+
*/
|
|
5
|
+
toDate(): Date;
|
|
6
|
+
toString(): string;
|
|
7
|
+
toJSON(): string;
|
|
8
|
+
toISOString(): string;
|
|
9
|
+
valueOf(): number;
|
|
10
|
+
/**
|
|
11
|
+
* Start of the Day (00:00) in the local timezone.
|
|
12
|
+
*/
|
|
13
|
+
startOfDay(): Date;
|
|
14
|
+
/**
|
|
15
|
+
* End of the Day (23:59:59.999) in the local timezone.
|
|
16
|
+
*/
|
|
17
|
+
endOfDay(): Date;
|
|
18
|
+
/**
|
|
19
|
+
* @return a number representing the year, e.g. 2017
|
|
20
|
+
*/
|
|
21
|
+
getYear(): number;
|
|
22
|
+
/**
|
|
23
|
+
* @return a number from 0-11 representing the month. 0 is January, 11 is December
|
|
24
|
+
*/
|
|
25
|
+
getMonth(): number;
|
|
26
|
+
/**
|
|
27
|
+
* @return a number from 1-31 representing the day of month.
|
|
28
|
+
*/
|
|
29
|
+
getDay(): number;
|
|
30
|
+
/**
|
|
31
|
+
* @return a number from 0-6 representing the day of week. 0 is Sunday, 6 is Saturday.
|
|
32
|
+
*/
|
|
33
|
+
getDayOfWeek(): number;
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AbstractFormatExpression, AbstractFormatExpressionParser, ShorthandExpression } from '@ja-platform/parser-expressions';
|
|
2
|
+
import type { AbstractFormatExpressionOptions, ExpressionSource } from '@ja-platform/parser-expressions';
|
|
3
|
+
/**
|
|
4
|
+
* Schema object display text containing only references and formatted references.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SchemaObjectDisplayExpression extends AbstractFormatExpression<SchemaObjectDisplayExpression, ShorthandExpression> {
|
|
7
|
+
static readonly TYPE = "schema-object-display";
|
|
8
|
+
static parse(source: ExpressionSource, start?: number): SchemaObjectDisplayExpression;
|
|
9
|
+
constructor(options: AbstractFormatExpressionOptions<ShorthandExpression>);
|
|
10
|
+
isValid(): boolean;
|
|
11
|
+
protected getParser(): SchemaObjectDisplayExpressionParser;
|
|
12
|
+
}
|
|
13
|
+
export declare class SchemaObjectDisplayExpressionParser extends AbstractFormatExpressionParser<SchemaObjectDisplayExpression, ShorthandExpression> {
|
|
14
|
+
private readonly placeholders;
|
|
15
|
+
protected parsePlaceholder(source: ExpressionSource, start: number): ShorthandExpression<import("@ja-platform/parser-expressions").ShorthandExpressionOptions>;
|
|
16
|
+
protected createExpression(options: AbstractFormatExpressionOptions<ShorthandExpression>): SchemaObjectDisplayExpression;
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './schema/Schema';
|
|
2
|
+
export * from './schema/schemaParser';
|
|
3
|
+
export * from './schema/schemaSerializer';
|
|
4
|
+
export * from './schema/TypeFactory';
|
|
5
|
+
export * from './types/EnumOption';
|
|
6
|
+
export * from './types/Variable';
|
|
7
|
+
export * from './types/Param';
|
|
8
|
+
export * from './types/FunctionType';
|
|
9
|
+
export * from './types/SchemaModelType';
|
|
10
|
+
export * from './types/Relationship';
|
|
11
|
+
export * from './types/primitives';
|
|
12
|
+
export { ArrayType } from '@ja-platform/parser-type-system';
|
|
13
|
+
export * from './types/QueryType';
|
|
14
|
+
export * from './expressions/SchemaObjectDisplayExpression';
|
|
15
|
+
export * from './Version';
|
|
16
|
+
export * from './day';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare enum IndexDirection {
|
|
2
|
+
ASCENDING = 1,
|
|
3
|
+
DESCENDING = -1
|
|
4
|
+
}
|
|
5
|
+
export declare enum IndexDatabase {
|
|
6
|
+
CLOUD = "cloud",
|
|
7
|
+
APP = "app"
|
|
8
|
+
}
|
|
9
|
+
export interface ModelIndexKey {
|
|
10
|
+
field: string;
|
|
11
|
+
dir: IndexDirection;
|
|
12
|
+
}
|
|
13
|
+
export interface ModelIndex {
|
|
14
|
+
name: string;
|
|
15
|
+
/** @deprecated Use `keys` instead. */
|
|
16
|
+
on: string[];
|
|
17
|
+
keys: ModelIndexKey[];
|
|
18
|
+
databases: IndexDatabase[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Version } from '../Version';
|
|
2
|
+
import { FunctionType } from '../types/FunctionType';
|
|
3
|
+
import { Param } from '../types/Param';
|
|
4
|
+
import * as parser from './schemaParser';
|
|
5
|
+
import { Variable } from '../types/Variable';
|
|
6
|
+
import { Relationship } from '../types/Relationship';
|
|
7
|
+
import { SchemaModelType } from '../types/SchemaModelType';
|
|
8
|
+
import { Type } from '@ja-platform/parser-type-system';
|
|
9
|
+
import { ValidationError } from '@journeyapps/common-xml';
|
|
10
|
+
import { XMLError, XMLElement } from '@journeyapps/domparser/types';
|
|
11
|
+
import { PrimitiveTypeMap, PrimitiveTypeName } from '../types/primitives';
|
|
12
|
+
import { TypeFactory } from './TypeFactory';
|
|
13
|
+
export type InferGetType<T extends string | PrimitiveTypeName, MAP extends {
|
|
14
|
+
[key in PrimitiveTypeName]: new (...args: any[]) => Type;
|
|
15
|
+
} = PrimitiveTypeMap, Model extends SchemaModelType = SchemaModelType> = T extends PrimitiveTypeName ? InstanceType<MAP[T]> : Model;
|
|
16
|
+
export declare class Schema {
|
|
17
|
+
typeFactories: {
|
|
18
|
+
[key: string]: TypeFactory;
|
|
19
|
+
};
|
|
20
|
+
objects: {
|
|
21
|
+
[index: string]: SchemaModelType;
|
|
22
|
+
};
|
|
23
|
+
errors: (ValidationError | XMLError)[];
|
|
24
|
+
sourceElement: XMLElement;
|
|
25
|
+
apiVersion?: any;
|
|
26
|
+
mobileUserType?: any;
|
|
27
|
+
constructor();
|
|
28
|
+
registerTypeFactory(factory: TypeFactory): void;
|
|
29
|
+
getFactory(name: string): TypeFactory<string>;
|
|
30
|
+
/** Helper function to assist in creating variables */
|
|
31
|
+
variable<T extends Type = Type>(name?: string, type?: string): Variable<T>;
|
|
32
|
+
variable<T extends Type = Type>(name?: string, type?: T): Variable<T>;
|
|
33
|
+
param<T extends Type = Type>(name?: string, type?: string): Param<T>;
|
|
34
|
+
param<T extends Type = Type>(name?: string, type?: T): Param<T>;
|
|
35
|
+
newObjectType(name?: string): SchemaModelType;
|
|
36
|
+
newRelationship(): Relationship;
|
|
37
|
+
functionType(): FunctionType;
|
|
38
|
+
getType<T extends string | PrimitiveTypeName>(typeName: T): InferGetType<T>;
|
|
39
|
+
primitive<T extends string | PrimitiveTypeName>(name: T): InferGetType<T>;
|
|
40
|
+
loadXml(rawxml: string, options?: {
|
|
41
|
+
apiVersion?: Version;
|
|
42
|
+
recordSource?: boolean;
|
|
43
|
+
}): this;
|
|
44
|
+
toJSON(): {
|
|
45
|
+
objects: {
|
|
46
|
+
[index: string]: SchemaModelType;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export declare function parser2(schema: Schema): parser.SchemaParser;
|
|
51
|
+
export declare function parser3(schema: Schema): parser.SchemaParser;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ValidationError, XMLDiagnostic } from '@journeyapps/common-xml';
|
|
2
|
+
import { XMLError } from '@journeyapps/domparser/types';
|
|
3
|
+
export declare class SchemaParserErrors {
|
|
4
|
+
private errors;
|
|
5
|
+
constructor();
|
|
6
|
+
pushError({ element, message, type }: XMLDiagnostic): void;
|
|
7
|
+
pushErrors(newErrors: (ValidationError | XMLError)[]): void;
|
|
8
|
+
reset(): void;
|
|
9
|
+
getErrors(): (ValidationError | XMLError)[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FunctionType } from '../types/FunctionType';
|
|
2
|
+
import { SchemaModelType } from '../types/SchemaModelType';
|
|
3
|
+
import { Param } from '../types/Param';
|
|
4
|
+
import { PrimitiveTypeInstance, PrimitiveTypeName } from '../types/primitives';
|
|
5
|
+
import { Relationship } from '../types/Relationship';
|
|
6
|
+
import { Variable } from '../types/Variable';
|
|
7
|
+
import { Schema } from './Schema';
|
|
8
|
+
export interface TypeFactory<NAME extends string = string> {
|
|
9
|
+
name: NAME;
|
|
10
|
+
generate: <T>(event?: any) => any;
|
|
11
|
+
}
|
|
12
|
+
export interface GenerateTypeEvent {
|
|
13
|
+
schema: Schema;
|
|
14
|
+
}
|
|
15
|
+
export type ObjectTypeInstance = Variable<any> | Param | FunctionType | SchemaModelType | Relationship;
|
|
16
|
+
export type ObjectTypeName = typeof Param.TYPE | typeof Variable.TYPE | typeof FunctionType.TYPE | typeof SchemaModelType.TYPE | typeof Relationship.TYPE;
|
|
17
|
+
export declare abstract class AbstractObjectTypeFactory<R extends ObjectTypeInstance = ObjectTypeInstance, E extends GenerateTypeEvent = GenerateTypeEvent> implements TypeFactory<ObjectTypeName> {
|
|
18
|
+
name: ObjectTypeName;
|
|
19
|
+
constructor(name: ObjectTypeName);
|
|
20
|
+
abstract generate<T>(event: E): R;
|
|
21
|
+
}
|
|
22
|
+
export declare class PrimitiveTypeFactory<T extends PrimitiveTypeInstance, E extends GenerateTypeEvent = GenerateTypeEvent> implements TypeFactory<PrimitiveTypeName> {
|
|
23
|
+
name: PrimitiveTypeName;
|
|
24
|
+
constructor(name: PrimitiveTypeName);
|
|
25
|
+
generate(event: E): T;
|
|
26
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ErrorType } from '@journeyapps/common-xml';
|
|
2
|
+
export declare const RESERVED_WORDS: string[];
|
|
3
|
+
export declare const STRICT_RESERVED_WORDS: string[];
|
|
4
|
+
export declare const CONTEXTUAL_KEYWORDS: string[];
|
|
5
|
+
export declare const TYPE_BLACKLIST: Record<string, boolean>;
|
|
6
|
+
export declare function validateModelName(name: string): null | ErrorType;
|
|
7
|
+
export declare function validateFieldName(name: string): null | ErrorType;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ArrayType } from '@ja-platform/parser-type-system';
|
|
2
|
+
import { QueryType } from '../types/QueryType';
|
|
3
|
+
import { FunctionExpression } from '@ja-platform/parser-expressions';
|
|
4
|
+
import { Schema } from './Schema';
|
|
5
|
+
import { SchemaModelType } from '../types/SchemaModelType';
|
|
6
|
+
import { Type } from '@ja-platform/parser-type-system';
|
|
7
|
+
import { Variable } from '../types/Variable';
|
|
8
|
+
import { XMLElement } from '@journeyapps/domparser/types';
|
|
9
|
+
/**
|
|
10
|
+
* Normalize serialized parameter providers once at the schema boundary.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseParameterValueProvider(source: string): FunctionExpression;
|
|
13
|
+
export declare const ATTACHMENT_MEDIA_TYPES: string[];
|
|
14
|
+
export declare const TEXT_SUBTYPES: string[];
|
|
15
|
+
export interface ParseVersion {
|
|
16
|
+
v3?: boolean;
|
|
17
|
+
v3_1?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface SchemaParser {
|
|
20
|
+
parse: (rawxml: string) => void;
|
|
21
|
+
parseField: (element: XMLElement, isVariable?: boolean) => Variable;
|
|
22
|
+
validateVariableAttributes: (element: XMLElement, options?: {
|
|
23
|
+
validateType?: boolean;
|
|
24
|
+
}) => void;
|
|
25
|
+
parseObjectType: (element: XMLElement) => SchemaModelType;
|
|
26
|
+
parseBelongsTo: (object: SchemaModelType, element: XMLElement) => void;
|
|
27
|
+
parseDisplay: (object: SchemaModelType, element: XMLElement) => SchemaModelType;
|
|
28
|
+
reset: () => void;
|
|
29
|
+
getErrors: () => any[];
|
|
30
|
+
}
|
|
31
|
+
export declare function parser(schema: Schema, options?: {
|
|
32
|
+
version?: ParseVersion;
|
|
33
|
+
recordSource?: boolean;
|
|
34
|
+
}): SchemaParser;
|
|
35
|
+
/**
|
|
36
|
+
* Apply serialized field metadata to a variable whose type is already resolved.
|
|
37
|
+
*/
|
|
38
|
+
export declare function applyVariableMetadata(variable: Variable, attributeData: any): Variable<Type<any>>;
|
|
39
|
+
export declare function parseJsonVariable(schema: Schema, attributeName: string, attributeData: any): Variable<ArrayType> | Variable<QueryType> | Variable<Type<any>>;
|
|
40
|
+
export declare function parseJsonField(schema: Schema, attributeData: any): Variable<Type<any>>;
|
|
41
|
+
export declare function jsonParser(schema: Schema): {
|
|
42
|
+
parse: (data: any) => void;
|
|
43
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Schema } from './Schema';
|
|
2
|
+
import { OrderedIncrementalUpdater } from '@journeyapps/common-xml';
|
|
3
|
+
import { XMLDocument } from '@journeyapps/domparser/types';
|
|
4
|
+
import { Variable } from '../types/Variable';
|
|
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: Variable): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { XMLElement } from '@journeyapps/domparser/types';
|
|
2
|
+
export declare class EnumOption {
|
|
3
|
+
/** They key */
|
|
4
|
+
value: string | number | boolean;
|
|
5
|
+
label: string;
|
|
6
|
+
index: number;
|
|
7
|
+
sourceElement: XMLElement;
|
|
8
|
+
static isInstanceOf(value: any): value is EnumOption;
|
|
9
|
+
constructor(key: string | number | boolean, label: string, index?: number);
|
|
10
|
+
toJSON(): {
|
|
11
|
+
value: string | number | boolean;
|
|
12
|
+
label: string;
|
|
13
|
+
index: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AbstractObjectTypeFactory } from '../schema/TypeFactory';
|
|
2
|
+
import { Type } from '@ja-platform/parser-type-system';
|
|
3
|
+
import { Variable } from './Variable';
|
|
4
|
+
export declare class FunctionType extends Type {
|
|
5
|
+
static readonly TYPE = "function";
|
|
6
|
+
static readonly ARG_TAG = "arg";
|
|
7
|
+
static isInstanceOf(type: Type): type is FunctionType;
|
|
8
|
+
arguments: Variable[];
|
|
9
|
+
constructor();
|
|
10
|
+
addArgument(argument: Variable): void;
|
|
11
|
+
}
|
|
12
|
+
export declare class FunctionTypeFactory extends AbstractObjectTypeFactory<FunctionType> {
|
|
13
|
+
constructor();
|
|
14
|
+
generate(): FunctionType;
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FunctionExpression } from '@ja-platform/parser-expressions';
|
|
2
|
+
import { AbstractObjectTypeFactory } from '../schema/TypeFactory';
|
|
3
|
+
import { Type } from '@ja-platform/parser-type-system';
|
|
4
|
+
import { GenerateVariableEvent, Variable, VariableJsonType } from './Variable';
|
|
5
|
+
export declare class Param<T extends Type = Type> extends Variable<T> {
|
|
6
|
+
static TYPE: string;
|
|
7
|
+
static isInstanceOf(obj: any): obj is Param;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
provideValue?: FunctionExpression;
|
|
10
|
+
toJSON(): VariableJsonType;
|
|
11
|
+
}
|
|
12
|
+
export interface GenerateParamEvent<T extends Type> extends GenerateVariableEvent<T> {
|
|
13
|
+
required?: boolean;
|
|
14
|
+
provideValue?: FunctionExpression;
|
|
15
|
+
}
|
|
16
|
+
export declare class ParamFactory<T extends Type = Type> extends AbstractObjectTypeFactory<Param<T>, GenerateParamEvent<T>> {
|
|
17
|
+
constructor();
|
|
18
|
+
generate<T extends Type = Type>(event: GenerateParamEvent<T>): Param<T>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Type } from '@ja-platform/parser-type-system';
|
|
2
|
+
/**
|
|
3
|
+
* A query whose results share a value type.
|
|
4
|
+
*/
|
|
5
|
+
export declare class QueryType extends Type {
|
|
6
|
+
readonly itemType: Type;
|
|
7
|
+
readonly _typeName = "query";
|
|
8
|
+
readonly name = "query";
|
|
9
|
+
readonly isCollection = true;
|
|
10
|
+
constructor(itemType: Type);
|
|
11
|
+
static isInstanceOf(type: Type | null): type is QueryType;
|
|
12
|
+
is(value: any): boolean;
|
|
13
|
+
parse(value: unknown): unknown;
|
|
14
|
+
stringify(): string;
|
|
15
|
+
toJSON(): {
|
|
16
|
+
type: string;
|
|
17
|
+
object: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AbstractObjectTypeFactory } from '../schema/TypeFactory';
|
|
2
|
+
import { SchemaModelType } from './SchemaModelType';
|
|
3
|
+
export declare class Relationship {
|
|
4
|
+
static readonly TYPE = "relationship";
|
|
5
|
+
/** one-to-many, many-to-many, one-to-one */
|
|
6
|
+
type: string;
|
|
7
|
+
/** local object type (containing the belongs_to) */
|
|
8
|
+
objectType: SchemaModelType;
|
|
9
|
+
/** foreign object type (containing the has_many) */
|
|
10
|
+
foreignType: SchemaModelType;
|
|
11
|
+
/** The name used on the local object to identify the relationship (singular) */
|
|
12
|
+
name: string;
|
|
13
|
+
/** The name used on the foreign object to identify the relationship (plural) */
|
|
14
|
+
foreignName: string;
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
export declare class RelationshipTypeFactory extends AbstractObjectTypeFactory<Relationship> {
|
|
18
|
+
constructor();
|
|
19
|
+
generate(): Relationship;
|
|
20
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { SchemaObjectDisplayExpression } from '../expressions/SchemaObjectDisplayExpression';
|
|
2
|
+
import { ObjectType, Type } from '@ja-platform/parser-type-system';
|
|
3
|
+
import { Variable } from './Variable';
|
|
4
|
+
import { Relationship } from './Relationship';
|
|
5
|
+
import { Schema } from '../schema/Schema';
|
|
6
|
+
import { XMLElement } from '@journeyapps/domparser/types';
|
|
7
|
+
import { ModelIndex } from '../schema/ModelIndex';
|
|
8
|
+
import { TextType } from './primitives';
|
|
9
|
+
import { AbstractObjectTypeFactory, GenerateTypeEvent } from '../schema/TypeFactory';
|
|
10
|
+
export interface NotificationConfig {
|
|
11
|
+
message: SchemaObjectDisplayExpression;
|
|
12
|
+
recipient: string;
|
|
13
|
+
received: string;
|
|
14
|
+
badgeCount: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class SchemaModelType extends ObjectType {
|
|
17
|
+
static readonly TYPE = "object";
|
|
18
|
+
readonly isPrimitiveType = false;
|
|
19
|
+
readonly isObject = true;
|
|
20
|
+
attributes: Record<string, Variable>;
|
|
21
|
+
static isInstanceOf(type: any): type is SchemaModelType;
|
|
22
|
+
displayFormat: SchemaObjectDisplayExpression | null;
|
|
23
|
+
displaySource?: XMLElement;
|
|
24
|
+
label: string;
|
|
25
|
+
belongsTo: {
|
|
26
|
+
[index: string]: Relationship;
|
|
27
|
+
};
|
|
28
|
+
hasMany: {
|
|
29
|
+
[index: string]: Relationship;
|
|
30
|
+
};
|
|
31
|
+
belongsToVars: {
|
|
32
|
+
[index: string]: Variable;
|
|
33
|
+
};
|
|
34
|
+
belongsToIdVars: {
|
|
35
|
+
[index: string]: Variable;
|
|
36
|
+
};
|
|
37
|
+
hasManyVars: {
|
|
38
|
+
[index: string]: Variable;
|
|
39
|
+
};
|
|
40
|
+
idVar: Variable<TextType>;
|
|
41
|
+
/**
|
|
42
|
+
* App and Cloud indexes.
|
|
43
|
+
*/
|
|
44
|
+
allIndexes: ModelIndex[];
|
|
45
|
+
/**
|
|
46
|
+
* App indexes.
|
|
47
|
+
*/
|
|
48
|
+
indexes: ModelIndex[];
|
|
49
|
+
errors: any[];
|
|
50
|
+
webhooks: any[];
|
|
51
|
+
notifyUsers: NotificationConfig[];
|
|
52
|
+
sourceElement: XMLElement;
|
|
53
|
+
constructor(name?: string);
|
|
54
|
+
addAttribute(attribute: Variable): void;
|
|
55
|
+
setupVariables(schema: Schema): void;
|
|
56
|
+
/**
|
|
57
|
+
* Attribute or relationship variable.
|
|
58
|
+
*/
|
|
59
|
+
getAttribute(name: string): Variable | null;
|
|
60
|
+
getField(name: string): Type | null;
|
|
61
|
+
getAttributes(): {
|
|
62
|
+
[index: string]: Variable;
|
|
63
|
+
};
|
|
64
|
+
toJSON(): {
|
|
65
|
+
label: string;
|
|
66
|
+
attributes: Record<string, Variable<Type<any>>>;
|
|
67
|
+
belongsTo: {
|
|
68
|
+
[index: string]: {
|
|
69
|
+
type: string;
|
|
70
|
+
foreignName: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
hasMany: {};
|
|
74
|
+
display: string;
|
|
75
|
+
};
|
|
76
|
+
addBelongsTo(options: {
|
|
77
|
+
schema: Schema;
|
|
78
|
+
type?: string;
|
|
79
|
+
foreignName?: string;
|
|
80
|
+
name: string;
|
|
81
|
+
}): Relationship;
|
|
82
|
+
}
|
|
83
|
+
export interface GenerateSchemaModelTypeEvent extends GenerateTypeEvent {
|
|
84
|
+
name?: string;
|
|
85
|
+
}
|
|
86
|
+
export declare class SchemaModelTypeFactory extends AbstractObjectTypeFactory<SchemaModelType, GenerateSchemaModelTypeEvent> {
|
|
87
|
+
constructor();
|
|
88
|
+
generate(event: GenerateSchemaModelTypeEvent): SchemaModelType;
|
|
89
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AbstractObjectTypeFactory, GenerateTypeEvent } from '../schema/TypeFactory';
|
|
2
|
+
import { Type } from '@ja-platform/parser-type-system';
|
|
3
|
+
import { XMLElement } from '@journeyapps/domparser/types';
|
|
4
|
+
export interface VariableJsonType {
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
export declare class Variable<T extends Type = Type> {
|
|
11
|
+
static TYPE: string;
|
|
12
|
+
static isInstanceOf(obj: any): obj is Variable;
|
|
13
|
+
name: string;
|
|
14
|
+
type: T | null;
|
|
15
|
+
errors: any[];
|
|
16
|
+
label?: string;
|
|
17
|
+
relationship?: string;
|
|
18
|
+
isRelationshipId?: boolean;
|
|
19
|
+
isBelongsToId?: boolean;
|
|
20
|
+
sourceTypeName?: string;
|
|
21
|
+
sourceElement: XMLElement;
|
|
22
|
+
constructor(name: string, type: T | null);
|
|
23
|
+
toJSON(): VariableJsonType;
|
|
24
|
+
}
|
|
25
|
+
export interface GenerateVariableEvent<T extends Type> extends GenerateTypeEvent {
|
|
26
|
+
name: string;
|
|
27
|
+
type: T;
|
|
28
|
+
}
|
|
29
|
+
export declare class VariableFactory<T extends Type = Type> extends AbstractObjectTypeFactory<Variable<T>, GenerateVariableEvent<T>> {
|
|
30
|
+
constructor();
|
|
31
|
+
generate<T extends Type = Type>(event: GenerateVariableEvent<T>): Variable<T>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BooleanType as ValueBooleanType } from '@ja-platform/parser-type-system';
|
|
2
|
+
declare const BooleanType_base: {
|
|
3
|
+
new (...args: any[]): {
|
|
4
|
+
parse(value: unknown): any;
|
|
5
|
+
stringify(): string;
|
|
6
|
+
valueOf(): string;
|
|
7
|
+
options: Record<string, import("../EnumOption").EnumOption>;
|
|
8
|
+
multipleOptions: boolean;
|
|
9
|
+
hasOptions: boolean;
|
|
10
|
+
format(value: any): string;
|
|
11
|
+
addOption(value: any, label: string, index: number): import("../EnumOption").EnumOption;
|
|
12
|
+
values(obj: any): any[];
|
|
13
|
+
toJSON(): any;
|
|
14
|
+
name: string;
|
|
15
|
+
readonly _typeName: string;
|
|
16
|
+
is(_value: unknown): boolean;
|
|
17
|
+
};
|
|
18
|
+
} & typeof ValueBooleanType;
|
|
19
|
+
export declare class BooleanType extends BooleanType_base {
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { EnumOption } from '../EnumOption';
|
|
2
|
+
import { Type } from '@ja-platform/parser-type-system';
|
|
3
|
+
export interface ChoiceTypeConfig {
|
|
4
|
+
multiple: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Add schema option labels without replacing the underlying value type.
|
|
8
|
+
*/
|
|
9
|
+
export declare function withChoices<TBase extends new (...args: any[]) => Type>(Base: TBase): {
|
|
10
|
+
new (...args: any[]): {
|
|
11
|
+
parse(value: unknown): any;
|
|
12
|
+
stringify(): string;
|
|
13
|
+
valueOf(): string;
|
|
14
|
+
options: Record<string, EnumOption>;
|
|
15
|
+
multipleOptions: boolean;
|
|
16
|
+
hasOptions: boolean;
|
|
17
|
+
format(value: any): string;
|
|
18
|
+
addOption(value: any, label: string, index: number): EnumOption;
|
|
19
|
+
values(obj: any): any[];
|
|
20
|
+
toJSON(): any;
|
|
21
|
+
name: string;
|
|
22
|
+
readonly _typeName: string;
|
|
23
|
+
is(_value: unknown): boolean;
|
|
24
|
+
};
|
|
25
|
+
} & TBase;
|
|
26
|
+
declare const ChoiceType_base: {
|
|
27
|
+
new (...args: any[]): {
|
|
28
|
+
parse(value: unknown): any;
|
|
29
|
+
stringify(): string;
|
|
30
|
+
valueOf(): string;
|
|
31
|
+
options: Record<string, EnumOption>;
|
|
32
|
+
multipleOptions: boolean;
|
|
33
|
+
hasOptions: boolean;
|
|
34
|
+
format(value: any): string;
|
|
35
|
+
addOption(value: any, label: string, index: number): EnumOption;
|
|
36
|
+
values(obj: any): any[];
|
|
37
|
+
toJSON(): any;
|
|
38
|
+
name: string;
|
|
39
|
+
readonly _typeName: string;
|
|
40
|
+
is(_value: unknown): boolean;
|
|
41
|
+
};
|
|
42
|
+
} & typeof Type;
|
|
43
|
+
export declare abstract class ChoiceType extends ChoiceType_base {
|
|
44
|
+
static isInstanceOf(type: Type | null): type is ChoiceType;
|
|
45
|
+
constructor(name: string, config?: ChoiceTypeConfig);
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Type } from '@ja-platform/parser-type-system';
|
|
2
|
+
export declare class DateType extends Type {
|
|
3
|
+
static DEFAULT_FORMAT: string;
|
|
4
|
+
readonly _typeName = "date";
|
|
5
|
+
static readonly TYPE = "date";
|
|
6
|
+
static isInstanceOf(type: Type | null): type is DateType;
|
|
7
|
+
isDay?: boolean;
|
|
8
|
+
constructor();
|
|
9
|
+
toJSON(): any;
|
|
10
|
+
format(value: any, format?: string): string;
|
|
11
|
+
is(value: any): boolean;
|
|
12
|
+
parse(value: any): Date | import("../../day/DayInterface").Day;
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Type } from '@ja-platform/parser-type-system';
|
|
2
|
+
export declare class DatetimeType extends Type {
|
|
3
|
+
static DEFAULT_FORMAT: string;
|
|
4
|
+
static readonly TYPE = "datetime";
|
|
5
|
+
constructor();
|
|
6
|
+
format(value: any, format?: string): string;
|
|
7
|
+
is(value: any): boolean;
|
|
8
|
+
parse(value: any): any;
|
|
9
|
+
}
|