@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,8 @@
|
|
|
1
|
+
import { ChoiceType } from './ChoiceType';
|
|
2
|
+
export declare class MultipleChoiceIntegerType extends ChoiceType {
|
|
3
|
+
static readonly TYPE = "multiple-choice-integer";
|
|
4
|
+
constructor();
|
|
5
|
+
setOptionLabels(labels: string[]): void;
|
|
6
|
+
is(value: any): boolean;
|
|
7
|
+
parse(value: any): any[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ChoiceType } from './ChoiceType';
|
|
2
|
+
export declare class SingleChoiceIntegerType extends ChoiceType {
|
|
3
|
+
static readonly TYPE = "single-choice-integer";
|
|
4
|
+
constructor();
|
|
5
|
+
setOptionLabels(labels: string[]): void;
|
|
6
|
+
is(value: any): boolean;
|
|
7
|
+
parse(value: any): number;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Type, TextType as ValueTextType } from '@ja-platform/parser-type-system';
|
|
2
|
+
export declare class TextType extends ValueTextType {
|
|
3
|
+
static readonly TYPE = "text";
|
|
4
|
+
static isInstanceOf(type: Type): type is TextType;
|
|
5
|
+
spec?: string;
|
|
6
|
+
subType?: string;
|
|
7
|
+
toJSON(): any;
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Type } from '@ja-platform/parser-type-system';
|
|
2
|
+
export declare class AttachmentType extends Type {
|
|
3
|
+
readonly _typeName = "attachment";
|
|
4
|
+
static readonly TYPE = "attachment";
|
|
5
|
+
static isInstanceOf(type: Type): type is AttachmentType;
|
|
6
|
+
media?: string;
|
|
7
|
+
autoDownload?: boolean;
|
|
8
|
+
constructor();
|
|
9
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { AttachmentType } from './attachments/Attachment';
|
|
2
|
+
import { TextType } from './Text';
|
|
3
|
+
import { BooleanType } from './Boolean';
|
|
4
|
+
import { LocationType } from './Location';
|
|
5
|
+
import { GeoTrackType } from './GeoTrack';
|
|
6
|
+
import { SingleChoiceType } from './SingleChoice';
|
|
7
|
+
import { SingleChoiceIntegerType } from './SingleChoiceInteger';
|
|
8
|
+
import { MultipleChoiceType } from './MultipleChoice';
|
|
9
|
+
import { MultipleChoiceIntegerType } from './MultipleChoiceInteger';
|
|
10
|
+
import { IntegerType, NumberType } from '@ja-platform/parser-type-system';
|
|
11
|
+
import { DateType } from './Date';
|
|
12
|
+
import { DatetimeType } from './Datetime';
|
|
13
|
+
import { PhotoType } from './attachments/Photo';
|
|
14
|
+
import { SignatureType } from './attachments/Signature';
|
|
15
|
+
export declare const PrimitiveType: {
|
|
16
|
+
readonly ATTACHMENT: "attachment";
|
|
17
|
+
readonly BOOLEAN: "boolean";
|
|
18
|
+
readonly DATE: "date";
|
|
19
|
+
readonly DATETIME: "datetime";
|
|
20
|
+
readonly GEO_TRACK: "track";
|
|
21
|
+
readonly INTEGER: "integer";
|
|
22
|
+
readonly LOCATION: "location";
|
|
23
|
+
readonly MULTIPLE_CHOICE_INTEGER: "multiple-choice-integer";
|
|
24
|
+
readonly MULTIPLE_CHOICE: "multiple-choice";
|
|
25
|
+
readonly NUMBER: "number";
|
|
26
|
+
readonly SINGLE_CHOICE_INTEGER: "single-choice-integer";
|
|
27
|
+
readonly SINGLE_CHOICE: "single-choice";
|
|
28
|
+
readonly TEXT: "text";
|
|
29
|
+
readonly PHOTO: "photo";
|
|
30
|
+
readonly SIGNATURE: "signature";
|
|
31
|
+
};
|
|
32
|
+
export type PrimitiveType = typeof PrimitiveType;
|
|
33
|
+
export declare const PrimitiveTypeMap: {
|
|
34
|
+
readonly attachment: typeof AttachmentType;
|
|
35
|
+
readonly boolean: typeof BooleanType;
|
|
36
|
+
readonly date: typeof DateType;
|
|
37
|
+
readonly datetime: typeof DatetimeType;
|
|
38
|
+
readonly track: typeof GeoTrackType;
|
|
39
|
+
readonly integer: typeof IntegerType;
|
|
40
|
+
readonly location: typeof LocationType;
|
|
41
|
+
readonly "multiple-choice-integer": typeof MultipleChoiceIntegerType;
|
|
42
|
+
readonly "multiple-choice": typeof MultipleChoiceType;
|
|
43
|
+
readonly number: typeof NumberType;
|
|
44
|
+
readonly "single-choice-integer": typeof SingleChoiceIntegerType;
|
|
45
|
+
readonly "single-choice": typeof SingleChoiceType;
|
|
46
|
+
readonly text: typeof TextType;
|
|
47
|
+
readonly signature: typeof SignatureType;
|
|
48
|
+
readonly photo: typeof PhotoType;
|
|
49
|
+
};
|
|
50
|
+
export type PrimitiveTypeMap = typeof PrimitiveTypeMap;
|
|
51
|
+
export type PrimitiveTypeName = keyof typeof PrimitiveTypeMap;
|
|
52
|
+
export type PrimitiveTypeInstance = InstanceType<PrimitiveTypeMap[PrimitiveTypeName]>;
|
|
53
|
+
export * from './Boolean';
|
|
54
|
+
export * from './Date';
|
|
55
|
+
export * from './Datetime';
|
|
56
|
+
export { IntegerType, NumberType } from '@ja-platform/parser-type-system';
|
|
57
|
+
export * from './Text';
|
|
58
|
+
export * from './Location';
|
|
59
|
+
export * from './GeoTrack';
|
|
60
|
+
export * from './ChoiceType';
|
|
61
|
+
export * from './MultipleChoice';
|
|
62
|
+
export * from './MultipleChoiceInteger';
|
|
63
|
+
export * from './SingleChoice';
|
|
64
|
+
export * from './SingleChoiceInteger';
|
|
65
|
+
export * from './attachments/Attachment';
|
|
66
|
+
export * from './attachments/Photo';
|
|
67
|
+
export * from './attachments/Signature';
|
package/dist/Version.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT = exports.Version = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Version-related functions
|
|
6
|
+
*/
|
|
7
|
+
class Version {
|
|
8
|
+
constructor(str) {
|
|
9
|
+
var components = str.split('.');
|
|
10
|
+
this.major = parseInt(components[0], 10);
|
|
11
|
+
this.minor = parseInt(components[1], 10);
|
|
12
|
+
this.hasPatch = components.length >= 3;
|
|
13
|
+
if (this.hasPatch) {
|
|
14
|
+
this.patch = parseInt(components[2], 10);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
this.patch = null;
|
|
18
|
+
}
|
|
19
|
+
this.v3 = this.major >= 3;
|
|
20
|
+
this.v3_1 = (this.v3 && this.minor >= 1) || this.major > 3;
|
|
21
|
+
this.v2 = this.major < 3;
|
|
22
|
+
}
|
|
23
|
+
toString() {
|
|
24
|
+
if (this.patch != null) {
|
|
25
|
+
return this.major + '.' + this.minor + '.' + this.patch;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return this.major + '.' + this.minor;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
valueOf() {
|
|
32
|
+
return this.toString();
|
|
33
|
+
}
|
|
34
|
+
// Returns -1 if < other, 0 if equal, 1 if > other.
|
|
35
|
+
compareTo(other) {
|
|
36
|
+
var thisPatch = this.patch == null ? -1 : this.patch;
|
|
37
|
+
var otherPatch = other.patch == null ? -1 : other.patch;
|
|
38
|
+
if (this.major < other.major) {
|
|
39
|
+
return -1;
|
|
40
|
+
}
|
|
41
|
+
else if (this.major > other.major) {
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
else if (this.minor < other.minor) {
|
|
45
|
+
return -1;
|
|
46
|
+
}
|
|
47
|
+
else if (this.minor > other.minor) {
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
else if (thisPatch < otherPatch) {
|
|
51
|
+
return -1;
|
|
52
|
+
}
|
|
53
|
+
else if (thisPatch > otherPatch) {
|
|
54
|
+
return 1;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
supportsApi(api) {
|
|
61
|
+
return api != null && this.gte(api) && ver(api).gte('2.0');
|
|
62
|
+
}
|
|
63
|
+
gte(other) {
|
|
64
|
+
const otherVersion = ver(other);
|
|
65
|
+
return this.compareTo(otherVersion) >= 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.Version = Version;
|
|
69
|
+
function ver(v) {
|
|
70
|
+
if (typeof v == 'string') {
|
|
71
|
+
v = new Version(v);
|
|
72
|
+
}
|
|
73
|
+
return v;
|
|
74
|
+
}
|
|
75
|
+
exports.DEFAULT = new Version('2.5');
|
|
76
|
+
//# sourceMappingURL=Version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Version.js","sourceRoot":"","sources":["../src/Version.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH;IASE,YAAY,GAAW;QACrB,IAAI,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,MAAM,IAAI,CAAC,CAAC;QACvC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACpB,CAAC;QAED,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QAC3D,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,QAAQ;QACN,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC;QAC1D,CAAC;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GAAG,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IAED,GAAG,CAAC,KAAuB;QACzB,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;CACF;;AAED,SAAS,GAAG,CAAC,CAAmB;IAC9B,IAAI,OAAO,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAEY,QAAA,OAAO,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC","sourcesContent":["/**\n * Version-related functions\n */\nexport class Version {\n major: number;\n minor: number;\n hasPatch: boolean;\n patch: number;\n v3: boolean;\n v3_1: boolean; // tslint:disable-line\n v2: boolean;\n\n constructor(str: string) {\n var components = str.split('.');\n this.major = parseInt(components[0], 10);\n this.minor = parseInt(components[1], 10);\n this.hasPatch = components.length >= 3;\n if (this.hasPatch) {\n this.patch = parseInt(components[2], 10);\n } else {\n this.patch = null;\n }\n\n this.v3 = this.major >= 3;\n this.v3_1 = (this.v3 && this.minor >= 1) || this.major > 3;\n this.v2 = this.major < 3;\n }\n\n toString() {\n if (this.patch != null) {\n return this.major + '.' + this.minor + '.' + this.patch;\n } else {\n return this.major + '.' + this.minor;\n }\n }\n\n valueOf() {\n return this.toString();\n }\n\n // Returns -1 if < other, 0 if equal, 1 if > other.\n compareTo(other: Version) {\n var thisPatch = this.patch == null ? -1 : this.patch;\n var otherPatch = other.patch == null ? -1 : other.patch;\n if (this.major < other.major) {\n return -1;\n } else if (this.major > other.major) {\n return 1;\n } else if (this.minor < other.minor) {\n return -1;\n } else if (this.minor > other.minor) {\n return 1;\n } else if (thisPatch < otherPatch) {\n return -1;\n } else if (thisPatch > otherPatch) {\n return 1;\n } else {\n return 0;\n }\n }\n\n supportsApi(api: string | Version) {\n return api != null && this.gte(api) && ver(api).gte('2.0');\n }\n\n gte(other: string | Version) {\n const otherVersion = ver(other);\n return this.compareTo(otherVersion) >= 0;\n }\n}\n\nfunction ver(v: string | Version) {\n if (typeof v == 'string') {\n v = new Version(v);\n }\n return v;\n}\n\nexport const DEFAULT = new Version('2.5');\n"]}
|
package/dist/day/Day.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Day = void 0;
|
|
4
|
+
exports.Day = function (...args) {
|
|
5
|
+
var date, dateString, t;
|
|
6
|
+
if (args.length == 3) {
|
|
7
|
+
// new Day(year, month, day);
|
|
8
|
+
// month is 0-11.
|
|
9
|
+
this._time = new Date(Date.UTC(args[0], args[1], args[2]));
|
|
10
|
+
}
|
|
11
|
+
else if (args.length == 1 && args[0] instanceof Date) {
|
|
12
|
+
// new Day(new Date());
|
|
13
|
+
// Assume local timezone
|
|
14
|
+
date = args[0];
|
|
15
|
+
this._time = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
16
|
+
}
|
|
17
|
+
else if (args.length == 1 && exports.Day.isDay(args[0])) {
|
|
18
|
+
// new Day(new Date());
|
|
19
|
+
this._time = args[0].toDate();
|
|
20
|
+
}
|
|
21
|
+
else if (args.length == 1 && typeof args[0] == 'string') {
|
|
22
|
+
// new Day("2014-02-15")
|
|
23
|
+
// new Day("2014-02-15T13:15")
|
|
24
|
+
// new Day("2014-02-15T13:15:11+02")
|
|
25
|
+
// new Day("2014-02-15T11:15:11Z")
|
|
26
|
+
dateString = args[0];
|
|
27
|
+
if (/^\d\d\d\d-\d\d-\d\d/.test(dateString)) {
|
|
28
|
+
this._time = new Date(dateString.substring(0, 10) + 'T00:00Z');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new Error('Invalid date format');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else if (args.length == 1 && typeof args[0] == 'number') {
|
|
35
|
+
// Assume UTC timestamp.
|
|
36
|
+
t = new Date(args[0]);
|
|
37
|
+
if (t.getUTCHours() !== 0 || t.getUTCMinutes() !== 0 || t.getUTCSeconds() !== 0 || t.getUTCMilliseconds() !== 0) {
|
|
38
|
+
throw new Error('Invalid Day');
|
|
39
|
+
}
|
|
40
|
+
this._time = t;
|
|
41
|
+
}
|
|
42
|
+
else if (args.length === 0) {
|
|
43
|
+
// Today in local timezone
|
|
44
|
+
date = new Date();
|
|
45
|
+
this._time = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw new Error('Invalid args for Day()');
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.Day.today = function () {
|
|
52
|
+
return new exports.Day();
|
|
53
|
+
};
|
|
54
|
+
exports.Day.fromUTCDate = function (date) {
|
|
55
|
+
return new exports.Day(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
56
|
+
};
|
|
57
|
+
exports.Day.isDay = function (obj) {
|
|
58
|
+
if (obj == null) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
else if (obj instanceof exports.Day) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
else if (typeof obj == 'object') {
|
|
65
|
+
// This covers other implementations of the Day class, e.g. in the case
|
|
66
|
+
// of duplicate imports.
|
|
67
|
+
return typeof obj.startOfDay == 'function' && typeof obj.endOfDay == 'function';
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
let DayPrototype = exports.Day.prototype;
|
|
74
|
+
DayPrototype.toDate = function () {
|
|
75
|
+
// Clone the date, to prevent modifications from affecting us.
|
|
76
|
+
return new Date(this._time.getTime());
|
|
77
|
+
};
|
|
78
|
+
DayPrototype.toString = function () {
|
|
79
|
+
return this._time.toISOString().substring(0, 10);
|
|
80
|
+
};
|
|
81
|
+
DayPrototype.toJSON = function () {
|
|
82
|
+
return this.toString();
|
|
83
|
+
};
|
|
84
|
+
DayPrototype.toISOString = function () {
|
|
85
|
+
return this.toString();
|
|
86
|
+
};
|
|
87
|
+
DayPrototype.valueOf = function () {
|
|
88
|
+
return this._time.getTime();
|
|
89
|
+
};
|
|
90
|
+
DayPrototype.startOfDay = function () {
|
|
91
|
+
var t = this._time;
|
|
92
|
+
var d = new Date(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate());
|
|
93
|
+
return d;
|
|
94
|
+
};
|
|
95
|
+
DayPrototype.endOfDay = function () {
|
|
96
|
+
var t = this._time;
|
|
97
|
+
var d = new Date(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate(), 23, 59, 59, 999);
|
|
98
|
+
return d;
|
|
99
|
+
};
|
|
100
|
+
DayPrototype.getYear = function () {
|
|
101
|
+
return this._time.getUTCFullYear();
|
|
102
|
+
};
|
|
103
|
+
DayPrototype.getMonth = function () {
|
|
104
|
+
return this._time.getUTCMonth();
|
|
105
|
+
};
|
|
106
|
+
DayPrototype.getDay = function () {
|
|
107
|
+
return this._time.getUTCDate();
|
|
108
|
+
};
|
|
109
|
+
DayPrototype.getDayOfWeek = function () {
|
|
110
|
+
return this._time.getUTCDay();
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=Day.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Day.js","sourceRoot":"","sources":["../../src/day/Day.ts"],"names":[],"mappings":";;;AAOa,QAAA,GAAG,GAAmB,UAAU,GAAG,IAAW;IACzD,IAAI,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IACxB,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACrB,6BAA6B;QAC7B,iBAAiB;QACjB,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,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F,YAAY,CAAC,QAAQ,GAAG;IACtB,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;IACnB,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;IACvF,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAEF,YAAY,CAAC,OAAO,GAAG;IACrB,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;AACrC,CAAC,CAAC;AAEF,YAAY,CAAC,QAAQ,GAAG;IACtB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;AAClC,CAAC,CAAC;AAEF,YAAY,CAAC,MAAM,GAAG;IACpB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;AACjC,CAAC,CAAC;AAEF,YAAY,CAAC,YAAY,GAAG;IAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;AAChC,CAAC,CAAC","sourcesContent":["import { DayConstructor } from './DayConstructorInterface';\nimport { Day as DayInterface } from './DayInterface';\n\n// Important: Day must be both a type (interface) and value (constructor).\n// This gives the equivalent of having `class Day`.\nexport type Day = DayInterface;\n\nexport const Day: DayConstructor = function (...args: any[]) {\n var date, dateString, t;\n if (args.length == 3) {\n // new Day(year, month, day);\n // month is 0-11.\n this._time = new Date(Date.UTC(args[0], args[1], args[2]));\n } else if (args.length == 1 && args[0] instanceof Date) {\n // new Day(new Date());\n // Assume local timezone\n date = args[0];\n this._time = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));\n } else if (args.length == 1 && Day.isDay(args[0])) {\n // new Day(new Date());\n this._time = args[0].toDate();\n } else if (args.length == 1 && typeof args[0] == 'string') {\n // new Day(\"2014-02-15\")\n // new Day(\"2014-02-15T13:15\")\n // new Day(\"2014-02-15T13:15:11+02\")\n // new Day(\"2014-02-15T11:15:11Z\")\n dateString = args[0];\n if (/^\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(dateString)) {\n this._time = new Date(dateString.substring(0, 10) + 'T00:00Z');\n } else {\n throw new Error('Invalid date format');\n }\n } else if (args.length == 1 && typeof args[0] == 'number') {\n // Assume UTC timestamp.\n t = new Date(args[0]);\n if (t.getUTCHours() !== 0 || t.getUTCMinutes() !== 0 || t.getUTCSeconds() !== 0 || t.getUTCMilliseconds() !== 0) {\n throw new Error('Invalid Day');\n }\n this._time = t;\n } else if (args.length === 0) {\n // Today in local timezone\n date = new Date();\n this._time = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));\n } else {\n throw new Error('Invalid args for Day()');\n }\n} as any;\n\nDay.today = function (): DayInterface {\n return new Day();\n};\n\nDay.fromUTCDate = function (date: Date): DayInterface {\n return new Day(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());\n};\n\nDay.isDay = function (obj: any): obj is DayInterface {\n if (obj == null) {\n return false;\n } else if (obj instanceof Day) {\n return true;\n } else if (typeof obj == 'object') {\n // This covers other implementations of the Day class, e.g. in the case\n // of duplicate imports.\n return typeof obj.startOfDay == 'function' && typeof obj.endOfDay == 'function';\n } else {\n return false;\n }\n};\n\nlet DayPrototype = Day.prototype as DayInterface;\n\nDayPrototype.toDate = function () {\n // Clone the date, to prevent modifications from affecting us.\n return new Date(this._time.getTime());\n};\n\nDayPrototype.toString = function () {\n return this._time.toISOString().substring(0, 10);\n};\n\nDayPrototype.toJSON = function () {\n return this.toString();\n};\n\nDayPrototype.toISOString = function () {\n return this.toString();\n};\n\nDayPrototype.valueOf = function () {\n return this._time.getTime();\n};\n\nDayPrototype.startOfDay = function () {\n var t = this._time;\n var d = new Date(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate());\n return d;\n};\n\nDayPrototype.endOfDay = function () {\n var t = this._time;\n var d = new Date(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate(), 23, 59, 59, 999);\n return d;\n};\n\nDayPrototype.getYear = function () {\n return this._time.getUTCFullYear();\n};\n\nDayPrototype.getMonth = function () {\n return this._time.getUTCMonth();\n};\n\nDayPrototype.getDay = function () {\n return this._time.getUTCDate();\n};\n\nDayPrototype.getDayOfWeek = function () {\n return this._time.getUTCDay();\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DayConstructorInterface.js","sourceRoot":"","sources":["../../src/day/DayConstructorInterface.ts"],"names":[],"mappings":"","sourcesContent":["import { Day } from './DayInterface';\n\nexport interface DayConstructor {\n /**\n *\n * @param year number, e.g. 2001\n * @param month 0-11\n * @param day 1-31\n */\n new (year: number, month: number, day: number): Day;\n\n /**\n * Construct from a Date(time) object, using the date in the local timezone.\n */\n new (date: Date): Day;\n\n /**\n * Clone a Day object.\n */\n new (date: Day): Day;\n\n /**\n * Parse a date string, for example:\n *\n * new Day(\"2014-02-15\")\n * new Day(\"2014-02-15T13:15\")\n * new Day(\"2014-02-15T13:15:11+02\")\n * new Day(\"2014-02-15T11:15:11Z\")\n *\n * @param date - date string\n */\n new (date: string): Day;\n\n /**\n * Construct from a timestamp number.\n *\n * Must be at exactly 00:00 in UTC.\n *\n * @param date - timestamp in ms\n */\n new (date: number): Day;\n\n /**\n * Today in the current timezone.\n */\n new (): Day;\n\n /**\n * Today in the current timezone.\n */\n today(): Day;\n fromUTCDate(date: Date): Day;\n\n /**\n * Return true if the argument is a Day object.\n */\n isDay(obj: any): obj is Day;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DayInterface.js","sourceRoot":"","sources":["../../src/day/DayInterface.ts"],"names":[],"mappings":"","sourcesContent":["export interface Day {\n /**\n * Start of the Day (00:00) in UTC.\n */\n toDate(): Date;\n\n toString(): string;\n\n toJSON(): string;\n\n toISOString(): string;\n\n valueOf(): number;\n\n /**\n * Start of the Day (00:00) in the local timezone.\n */\n startOfDay(): Date;\n\n /**\n * End of the Day (23:59:59.999) in the local timezone.\n */\n endOfDay(): Date;\n\n /**\n * @return a number representing the year, e.g. 2017\n */\n getYear(): number;\n\n /**\n * @return a number from 0-11 representing the month. 0 is January, 11 is December\n */\n getMonth(): number;\n\n /**\n * @return a number from 1-31 representing the day of month.\n */\n getDay(): number;\n\n /**\n * @return a number from 0-6 representing the day of week. 0 is Sunday, 6 is Saturday.\n */\n getDayOfWeek(): number;\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Day"), exports);
|
|
18
|
+
__exportStar(require("./utils"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/day/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,0CAAwB","sourcesContent":["export * from './Day';\nexport * from './utils';\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// # date module
|
|
3
|
+
// Date/time utility functions
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.dateFromTime = dateFromTime;
|
|
6
|
+
exports.pureDate = pureDate;
|
|
7
|
+
exports.isPureDate = isPureDate;
|
|
8
|
+
exports.parseDateTime = parseDateTime;
|
|
9
|
+
// Take a time in the local timezone, and the date portion as a pure UTC date.
|
|
10
|
+
function dateFromTime(time) {
|
|
11
|
+
return new Date(Date.UTC(time.getFullYear(), time.getMonth(), time.getDate()));
|
|
12
|
+
}
|
|
13
|
+
// If it is already a pure date, return it.
|
|
14
|
+
// Otherwise, make it a pure date.
|
|
15
|
+
function pureDate(time) {
|
|
16
|
+
if (isPureDate(time)) {
|
|
17
|
+
return time;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return dateFromTime(time);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function isPureDate(date) {
|
|
24
|
+
return (date.getUTCHours() === 0 &&
|
|
25
|
+
date.getUTCMinutes() === 0 &&
|
|
26
|
+
date.getUTCSeconds() === 0 &&
|
|
27
|
+
date.getUTCMilliseconds() === 0);
|
|
28
|
+
}
|
|
29
|
+
function parseDateTime(value) {
|
|
30
|
+
if (typeof value == 'string') {
|
|
31
|
+
const parsed = Date.parse(value);
|
|
32
|
+
if (isNaN(parsed)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return new Date(parsed);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/day/utils.ts"],"names":[],"mappings":";AAAA,gBAAgB;AAChB,8BAA8B;;;;;;AAE9B,8EAA8E;AAC9E,sBAA6B,IAAU;IACrC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AACjF,CAAC;AAED,2CAA2C;AAC3C,kCAAkC;AAClC,kBAAyB,IAAU;IACjC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,CAAC;QACN,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC;AAED,oBAA2B,IAAU;IACnC,OAAO,CACL,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC;QACxB,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC;QAC1B,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC;QAC1B,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAChC,CAAC;AACJ,CAAC;AAED,uBAA8B,KAAK;IACjC,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC;QACd,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["// # date module\n// Date/time utility functions\n\n// Take a time in the local timezone, and the date portion as a pure UTC date.\nexport function dateFromTime(time: Date) {\n return new Date(Date.UTC(time.getFullYear(), time.getMonth(), time.getDate()));\n}\n\n// If it is already a pure date, return it.\n// Otherwise, make it a pure date.\nexport function pureDate(time: Date) {\n if (isPureDate(time)) {\n return time;\n } else {\n return dateFromTime(time);\n }\n}\n\nexport function isPureDate(date: Date) {\n return (\n date.getUTCHours() === 0 &&\n date.getUTCMinutes() === 0 &&\n date.getUTCSeconds() === 0 &&\n date.getUTCMilliseconds() === 0\n );\n}\n\nexport function parseDateTime(value): Date | null {\n if (typeof value == 'string') {\n const parsed = Date.parse(value);\n if (isNaN(parsed)) {\n return null;\n } else {\n return new Date(parsed);\n }\n } else {\n return null;\n }\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaObjectDisplayExpressionParser = exports.SchemaObjectDisplayExpression = void 0;
|
|
4
|
+
const parser_expressions_1 = require("@ja-platform/parser-expressions");
|
|
5
|
+
/**
|
|
6
|
+
* Schema object display text containing only references and formatted references.
|
|
7
|
+
*/
|
|
8
|
+
class SchemaObjectDisplayExpression extends parser_expressions_1.AbstractFormatExpression {
|
|
9
|
+
static parse(source, start = 0) {
|
|
10
|
+
return new SchemaObjectDisplayExpressionParser().parse(source, start);
|
|
11
|
+
}
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super(SchemaObjectDisplayExpression.TYPE, options);
|
|
14
|
+
}
|
|
15
|
+
isValid() {
|
|
16
|
+
return super.isValid() && this.parameters.every((parameter) => parameter instanceof parser_expressions_1.ShorthandExpression);
|
|
17
|
+
}
|
|
18
|
+
getParser() {
|
|
19
|
+
return new SchemaObjectDisplayExpressionParser();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.SchemaObjectDisplayExpression = SchemaObjectDisplayExpression;
|
|
23
|
+
SchemaObjectDisplayExpression.TYPE = 'schema-object-display';
|
|
24
|
+
class SchemaObjectDisplayExpressionParser extends parser_expressions_1.AbstractFormatExpressionParser {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.placeholders = new parser_expressions_1.CombinedParser([
|
|
28
|
+
new parser_expressions_1.FormatShorthandExpressionParser(),
|
|
29
|
+
new parser_expressions_1.ShorthandExpressionParser()
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
parsePlaceholder(source, start) {
|
|
33
|
+
return this.placeholders.parse(source, start);
|
|
34
|
+
}
|
|
35
|
+
createExpression(options) {
|
|
36
|
+
return new SchemaObjectDisplayExpression(options);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.SchemaObjectDisplayExpressionParser = SchemaObjectDisplayExpressionParser;
|
|
40
|
+
//# sourceMappingURL=SchemaObjectDisplayExpression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaObjectDisplayExpression.js","sourceRoot":"","sources":["../../src/expressions/SchemaObjectDisplayExpression.ts"],"names":[],"mappings":";;;AAAA,wEAOyC;AAGzC;;GAEG;AACH,mCAA2C,SAAQ,6CAGlD;IAGC,MAAM,CAAC,KAAK,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC9C,OAAO,IAAI,mCAAmC,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACxE,CAAC;IAED,YAAY,OAA6D;QACvE,KAAK,CAAC,6BAA6B,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,OAAO;QACL,OAAO,KAAK,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,YAAY,wCAAmB,CAAC,CAAC;IAC3G,CAAC;IAES,SAAS;QACjB,OAAO,IAAI,mCAAmC,EAAE,CAAC;IACnD,CAAC;CACF;;AAjBiB,kCAAI,GAAG,uBAAuB,CAAC;AAmBjD,yCAAiD,SAAQ,mDAGxD;IAHD;;QAImB,iBAAY,GAAG,IAAI,mCAAc,CAAsB;YACtE,IAAI,oDAA+B,EAAE;YACrC,IAAI,8CAAyB,EAAE;SAChC,CAAC,CAAC;IASL,CAAC;IAPW,gBAAgB,CAAC,MAAwB,EAAE,KAAa;QAChE,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;IAES,gBAAgB,CAAC,OAA6D;QACtF,OAAO,IAAI,6BAA6B,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;CACF","sourcesContent":["import {\n AbstractFormatExpression,\n AbstractFormatExpressionParser,\n CombinedParser,\n FormatShorthandExpressionParser,\n ShorthandExpression,\n ShorthandExpressionParser\n} from '@ja-platform/parser-expressions';\nimport type { AbstractFormatExpressionOptions, ExpressionSource } from '@ja-platform/parser-expressions';\n\n/**\n * Schema object display text containing only references and formatted references.\n */\nexport class SchemaObjectDisplayExpression extends AbstractFormatExpression<\n SchemaObjectDisplayExpression,\n ShorthandExpression\n> {\n static readonly TYPE = 'schema-object-display';\n\n static parse(source: ExpressionSource, start = 0): SchemaObjectDisplayExpression {\n return new SchemaObjectDisplayExpressionParser().parse(source, start);\n }\n\n constructor(options: AbstractFormatExpressionOptions<ShorthandExpression>) {\n super(SchemaObjectDisplayExpression.TYPE, options);\n }\n\n isValid(): boolean {\n return super.isValid() && this.parameters.every((parameter) => parameter instanceof ShorthandExpression);\n }\n\n protected getParser(): SchemaObjectDisplayExpressionParser {\n return new SchemaObjectDisplayExpressionParser();\n }\n}\n\nexport class SchemaObjectDisplayExpressionParser extends AbstractFormatExpressionParser<\n SchemaObjectDisplayExpression,\n ShorthandExpression\n> {\n private readonly placeholders = new CombinedParser<ShorthandExpression>([\n new FormatShorthandExpressionParser(),\n new ShorthandExpressionParser()\n ]);\n\n protected parsePlaceholder(source: ExpressionSource, start: number) {\n return this.placeholders.parse(source, start);\n }\n\n protected createExpression(options: AbstractFormatExpressionOptions<ShorthandExpression>) {\n return new SchemaObjectDisplayExpression(options);\n }\n}\n"]}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ArrayType = void 0;
|
|
18
|
+
__exportStar(require("./schema/Schema"), exports);
|
|
19
|
+
__exportStar(require("./schema/schemaParser"), exports);
|
|
20
|
+
__exportStar(require("./schema/schemaSerializer"), exports);
|
|
21
|
+
__exportStar(require("./schema/TypeFactory"), exports);
|
|
22
|
+
__exportStar(require("./types/EnumOption"), exports);
|
|
23
|
+
__exportStar(require("./types/Variable"), exports);
|
|
24
|
+
__exportStar(require("./types/Param"), exports);
|
|
25
|
+
__exportStar(require("./types/FunctionType"), exports);
|
|
26
|
+
__exportStar(require("./types/SchemaModelType"), exports);
|
|
27
|
+
__exportStar(require("./types/Relationship"), exports);
|
|
28
|
+
__exportStar(require("./types/primitives"), exports);
|
|
29
|
+
var parser_type_system_1 = require("@ja-platform/parser-type-system");
|
|
30
|
+
Object.defineProperty(exports, "ArrayType", { enumerable: true, get: function () { return parser_type_system_1.ArrayType; } });
|
|
31
|
+
__exportStar(require("./types/QueryType"), exports);
|
|
32
|
+
__exportStar(require("./expressions/SchemaObjectDisplayExpression"), exports);
|
|
33
|
+
__exportStar(require("./Version"), exports);
|
|
34
|
+
__exportStar(require("./day"), exports);
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,wDAAsC;AACtC,4DAA0C;AAE1C,uDAAqC;AAErC,qDAAmC;AACnC,mDAAiC;AACjC,gDAA8B;AAC9B,uDAAqC;AACrC,0DAAwC;AACxC,uDAAqC;AAErC,qDAAmC;AAEnC,sEAA4D;AAAnD,+GAAA,SAAS,OAAA;AAClB,oDAAkC;AAElC,8EAA4D;AAE5D,4CAA0B;AAE1B,wCAAsB","sourcesContent":["export * from './schema/Schema';\nexport * from './schema/schemaParser';\nexport * from './schema/schemaSerializer';\n\nexport * from './schema/TypeFactory';\n\nexport * from './types/EnumOption';\nexport * from './types/Variable';\nexport * from './types/Param';\nexport * from './types/FunctionType';\nexport * from './types/SchemaModelType';\nexport * from './types/Relationship';\n\nexport * from './types/primitives';\n\nexport { ArrayType } from '@ja-platform/parser-type-system';\nexport * from './types/QueryType';\n\nexport * from './expressions/SchemaObjectDisplayExpression';\n\nexport * from './Version';\n\nexport * from './day';\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IndexDatabase = exports.IndexDirection = void 0;
|
|
4
|
+
var IndexDirection;
|
|
5
|
+
(function (IndexDirection) {
|
|
6
|
+
IndexDirection[IndexDirection["ASCENDING"] = 1] = "ASCENDING";
|
|
7
|
+
IndexDirection[IndexDirection["DESCENDING"] = -1] = "DESCENDING";
|
|
8
|
+
})(IndexDirection || (exports.IndexDirection = IndexDirection = {}));
|
|
9
|
+
var IndexDatabase;
|
|
10
|
+
(function (IndexDatabase) {
|
|
11
|
+
IndexDatabase["CLOUD"] = "cloud";
|
|
12
|
+
IndexDatabase["APP"] = "app";
|
|
13
|
+
})(IndexDatabase || (exports.IndexDatabase = IndexDatabase = {}));
|
|
14
|
+
//# sourceMappingURL=ModelIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelIndex.js","sourceRoot":"","sources":["../../src/schema/ModelIndex.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,6DAAa,CAAA;IACb,gEAAe,CAAA;AACjB,CAAC,EAHW,cAAc,aAAd,cAAc,GAAd,cAAc,QAGzB;AAED,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,gCAAe,CAAA;IACf,4BAAW,CAAA;AACb,CAAC,EAHW,aAAa,aAAb,aAAa,GAAb,aAAa,QAGxB","sourcesContent":["export enum IndexDirection {\n ASCENDING = 1,\n DESCENDING = -1\n}\n\nexport enum IndexDatabase {\n CLOUD = 'cloud',\n APP = 'app'\n}\n\nexport interface ModelIndexKey {\n field: string;\n dir: IndexDirection;\n}\n\nexport interface ModelIndex {\n name: string;\n /** @deprecated Use `keys` instead. */\n on: string[];\n keys: ModelIndexKey[];\n databases: IndexDatabase[];\n}\n"]}
|