@ja-platform/parser-schema 0.0.0-dev-20261019214152 → 0.0.0-dev-20261021195551
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/day/Day.d.ts +48 -4
- package/dist/@types/expressions/parseParameterValueProvider.d.ts +5 -0
- package/dist/@types/index.d.ts +6 -6
- package/dist/@types/schema/Schema.d.ts +6 -22
- package/dist/@types/schema/TypeFactory.d.ts +3 -4
- package/dist/@types/schema/fieldMetadata.d.ts +5 -0
- package/dist/@types/types/EnumOption.d.ts +0 -2
- package/dist/@types/types/Field.d.ts +24 -0
- package/dist/@types/types/Param.d.ts +4 -4
- package/dist/@types/types/SchemaModelType.d.ts +9 -25
- package/dist/@types/types/primitives/Date.d.ts +2 -1
- package/dist/day/Day.js +89 -97
- package/dist/day/Day.js.map +1 -1
- package/dist/expressions/parseParameterValueProvider.js +13 -0
- package/dist/expressions/parseParameterValueProvider.js.map +1 -0
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/schema/Schema.js +7 -69
- package/dist/schema/Schema.js.map +1 -1
- package/dist/schema/TypeFactory.js.map +1 -1
- package/dist/schema/fieldMetadata.js +35 -0
- package/dist/schema/fieldMetadata.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/EnumOption.js.map +1 -1
- package/dist/types/Field.js +28 -0
- package/dist/types/Field.js.map +1 -0
- package/dist/types/Param.js +2 -12
- package/dist/types/Param.js.map +1 -1
- package/dist/types/SchemaModelType.js +4 -28
- package/dist/types/SchemaModelType.js.map +1 -1
- package/dist/types/primitives/Date.js +8 -7
- package/dist/types/primitives/Date.js.map +1 -1
- package/package.json +5 -8
- package/dist/@types/Version.d.ts +0 -19
- package/dist/@types/day/DayConstructorInterface.d.ts +0 -50
- package/dist/@types/day/DayInterface.d.ts +0 -34
- package/dist/@types/day/index.d.ts +0 -2
- package/dist/@types/schema/SchemaParserErrors.d.ts +0 -10
- package/dist/@types/schema/reservedNames.d.ts +0 -7
- package/dist/@types/schema/schemaParser.d.ts +0 -43
- package/dist/@types/schema/schemaSerializer.d.ts +0 -11
- package/dist/@types/types/FunctionType.d.ts +0 -15
- package/dist/@types/types/Variable.d.ts +0 -32
- package/dist/Version.js +0 -76
- package/dist/Version.js.map +0 -1
- package/dist/day/DayConstructorInterface.js +0 -3
- package/dist/day/DayConstructorInterface.js.map +0 -1
- package/dist/day/DayInterface.js +0 -3
- package/dist/day/DayInterface.js.map +0 -1
- package/dist/day/index.js +0 -19
- package/dist/day/index.js.map +0 -1
- package/dist/schema/SchemaParserErrors.js +0 -26
- package/dist/schema/SchemaParserErrors.js.map +0 -1
- package/dist/schema/reservedNames.js +0 -101
- package/dist/schema/reservedNames.js.map +0 -1
- package/dist/schema/schemaParser.js +0 -1135
- package/dist/schema/schemaParser.js.map +0 -1
- package/dist/schema/schemaSerializer.js +0 -181
- package/dist/schema/schemaSerializer.js.map +0 -1
- package/dist/types/FunctionType.js +0 -30
- package/dist/types/FunctionType.js.map +0 -1
- package/dist/types/Variable.js +0 -49
- package/dist/types/Variable.js.map +0 -1
package/dist/@types/day/Day.d.ts
CHANGED
|
@@ -1,4 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export declare class Day {
|
|
2
|
+
private _time;
|
|
3
|
+
/**
|
|
4
|
+
* Today in the local timezone.
|
|
5
|
+
*/
|
|
6
|
+
constructor();
|
|
7
|
+
/**
|
|
8
|
+
* Construct from a local Date, another Day, a date string, or a UTC midnight timestamp.
|
|
9
|
+
* Date strings use their leading YYYY-MM-DD portion without timezone conversion.
|
|
10
|
+
*/
|
|
11
|
+
constructor(date: Date | Day | string | number);
|
|
12
|
+
/**
|
|
13
|
+
* Construct from a year, zero-based month and day of month.
|
|
14
|
+
*/
|
|
15
|
+
constructor(year: number, month: number, day: number);
|
|
16
|
+
static today(): Day;
|
|
17
|
+
static fromUTCDate(date: Date): Day;
|
|
18
|
+
/**
|
|
19
|
+
* Recognize Day objects, including instances from other copies of the package.
|
|
20
|
+
*/
|
|
21
|
+
static isDay(obj: unknown): obj is Day;
|
|
22
|
+
/**
|
|
23
|
+
* Return a copy of the date at midnight UTC.
|
|
24
|
+
*/
|
|
25
|
+
toDate(): Date;
|
|
26
|
+
toString(): string;
|
|
27
|
+
toJSON(): string;
|
|
28
|
+
toISOString(): string;
|
|
29
|
+
valueOf(): number;
|
|
30
|
+
/**
|
|
31
|
+
* Start of the day in the local timezone.
|
|
32
|
+
*/
|
|
33
|
+
startOfDay(): Date;
|
|
34
|
+
/**
|
|
35
|
+
* End of the day in the local timezone.
|
|
36
|
+
*/
|
|
37
|
+
endOfDay(): Date;
|
|
38
|
+
getYear(): number;
|
|
39
|
+
/**
|
|
40
|
+
* Zero-based month, from 0 (January) to 11 (December).
|
|
41
|
+
*/
|
|
42
|
+
getMonth(): number;
|
|
43
|
+
getDay(): number;
|
|
44
|
+
/**
|
|
45
|
+
* Day of the week, from 0 (Sunday) to 6 (Saturday).
|
|
46
|
+
*/
|
|
47
|
+
getDayOfWeek(): number;
|
|
48
|
+
}
|
package/dist/@types/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export * from './schema/Schema';
|
|
2
|
-
export * from './schema/schemaParser';
|
|
3
|
-
export * from './schema/schemaSerializer';
|
|
4
2
|
export * from './schema/TypeFactory';
|
|
5
3
|
export * from './types/EnumOption';
|
|
6
|
-
export * from './types/
|
|
4
|
+
export * from './types/Field';
|
|
7
5
|
export * from './types/Param';
|
|
8
|
-
export * from './types/FunctionType';
|
|
9
6
|
export * from './types/SchemaModelType';
|
|
10
7
|
export * from './types/Relationship';
|
|
11
8
|
export * from './types/primitives';
|
|
12
9
|
export { ArrayType } from '@ja-platform/parser-type-system';
|
|
13
10
|
export * from './types/QueryType';
|
|
14
11
|
export * from './expressions/SchemaObjectDisplayExpression';
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './day';
|
|
12
|
+
export * from './day/Day';
|
|
13
|
+
export * from './day/utils';
|
|
14
|
+
export * from './schema/ModelIndex';
|
|
15
|
+
export * from './schema/fieldMetadata';
|
|
16
|
+
export * from './expressions/parseParameterValueProvider';
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { Version } from '../Version';
|
|
2
|
-
import { FunctionType } from '../types/FunctionType';
|
|
3
1
|
import { Param } from '../types/Param';
|
|
4
|
-
import
|
|
5
|
-
import { Variable } from '../types/Variable';
|
|
2
|
+
import { Field } from '../types/Field';
|
|
6
3
|
import { Relationship } from '../types/Relationship';
|
|
7
4
|
import { SchemaModelType } from '../types/SchemaModelType';
|
|
8
5
|
import { Type } from '@ja-platform/parser-type-system';
|
|
9
|
-
import { ValidationError } from '@journeyapps/common-xml';
|
|
10
|
-
import { XMLError, XMLElement } from '@journeyapps/domparser/types';
|
|
11
6
|
import { PrimitiveTypeMap, PrimitiveTypeName } from '../types/primitives';
|
|
12
7
|
import { TypeFactory } from './TypeFactory';
|
|
13
8
|
export type InferGetType<T extends string | PrimitiveTypeName, MAP extends {
|
|
@@ -20,32 +15,21 @@ export declare class Schema {
|
|
|
20
15
|
objects: {
|
|
21
16
|
[index: string]: SchemaModelType;
|
|
22
17
|
};
|
|
23
|
-
errors: (ValidationError | XMLError)[];
|
|
24
|
-
sourceElement: XMLElement;
|
|
25
18
|
apiVersion?: any;
|
|
26
19
|
mobileUserType?: any;
|
|
20
|
+
/**
|
|
21
|
+
* Create an empty resolved schema, independently of its input format.
|
|
22
|
+
*/
|
|
27
23
|
constructor();
|
|
28
24
|
registerTypeFactory(factory: TypeFactory): void;
|
|
29
25
|
getFactory(name: string): TypeFactory<string>;
|
|
30
26
|
/** Helper function to assist in creating variables */
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
field<T extends Type = Type>(name?: string, type?: string): Field<T>;
|
|
28
|
+
field<T extends Type = Type>(name?: string, type?: T): Field<T>;
|
|
33
29
|
param<T extends Type = Type>(name?: string, type?: string): Param<T>;
|
|
34
30
|
param<T extends Type = Type>(name?: string, type?: T): Param<T>;
|
|
35
31
|
newObjectType(name?: string): SchemaModelType;
|
|
36
32
|
newRelationship(): Relationship;
|
|
37
|
-
functionType(): FunctionType;
|
|
38
33
|
getType<T extends string | PrimitiveTypeName>(typeName: T): InferGetType<T>;
|
|
39
34
|
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
35
|
}
|
|
50
|
-
export declare function parser2(schema: Schema): parser.SchemaParser;
|
|
51
|
-
export declare function parser3(schema: Schema): parser.SchemaParser;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { FunctionType } from '../types/FunctionType';
|
|
2
1
|
import { SchemaModelType } from '../types/SchemaModelType';
|
|
3
2
|
import { Param } from '../types/Param';
|
|
4
3
|
import { PrimitiveTypeInstance, PrimitiveTypeName } from '../types/primitives';
|
|
5
4
|
import { Relationship } from '../types/Relationship';
|
|
6
|
-
import {
|
|
5
|
+
import { Field } from '../types/Field';
|
|
7
6
|
import { Schema } from './Schema';
|
|
8
7
|
export interface TypeFactory<NAME extends string = string> {
|
|
9
8
|
name: NAME;
|
|
@@ -12,8 +11,8 @@ export interface TypeFactory<NAME extends string = string> {
|
|
|
12
11
|
export interface GenerateTypeEvent {
|
|
13
12
|
schema: Schema;
|
|
14
13
|
}
|
|
15
|
-
export type ObjectTypeInstance =
|
|
16
|
-
export type ObjectTypeName = typeof Param.TYPE | typeof
|
|
14
|
+
export type ObjectTypeInstance = Field<any> | Param | SchemaModelType | Relationship;
|
|
15
|
+
export type ObjectTypeName = typeof Param.TYPE | typeof Field.TYPE | typeof SchemaModelType.TYPE | typeof Relationship.TYPE;
|
|
17
16
|
export declare abstract class AbstractObjectTypeFactory<R extends ObjectTypeInstance = ObjectTypeInstance, E extends GenerateTypeEvent = GenerateTypeEvent> implements TypeFactory<ObjectTypeName> {
|
|
18
17
|
name: ObjectTypeName;
|
|
19
18
|
constructor(name: ObjectTypeName);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { XMLElement } from '@journeyapps/domparser/types';
|
|
2
1
|
export declare class EnumOption {
|
|
3
2
|
/** They key */
|
|
4
3
|
value: string | number | boolean;
|
|
5
4
|
label: string;
|
|
6
5
|
index: number;
|
|
7
|
-
sourceElement: XMLElement;
|
|
8
6
|
static isInstanceOf(value: any): value is EnumOption;
|
|
9
7
|
constructor(key: string | number | boolean, label: string, index?: number);
|
|
10
8
|
toJSON(): {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AbstractObjectTypeFactory, GenerateTypeEvent } from '../schema/TypeFactory';
|
|
2
|
+
import { Type } from '@ja-platform/parser-type-system';
|
|
3
|
+
/**
|
|
4
|
+
* A named, resolved field and its schema metadata.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Field<T extends Type = Type> {
|
|
7
|
+
static TYPE: string;
|
|
8
|
+
static isInstanceOf(obj: any): obj is Field;
|
|
9
|
+
name: string;
|
|
10
|
+
type: T | null;
|
|
11
|
+
label?: string;
|
|
12
|
+
relationship?: string;
|
|
13
|
+
isRelationshipId?: boolean;
|
|
14
|
+
isBelongsToId?: boolean;
|
|
15
|
+
constructor(name: string, type: T | null);
|
|
16
|
+
}
|
|
17
|
+
export interface GenerateFieldEvent<T extends Type> extends GenerateTypeEvent {
|
|
18
|
+
name: string;
|
|
19
|
+
type: T;
|
|
20
|
+
}
|
|
21
|
+
export declare class FieldFactory<T extends Type = Type> extends AbstractObjectTypeFactory<Field<T>, GenerateFieldEvent<T>> {
|
|
22
|
+
constructor();
|
|
23
|
+
generate<T extends Type = Type>(event: GenerateFieldEvent<T>): Field<T>;
|
|
24
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { FunctionExpression } from '@ja-platform/parser-expressions';
|
|
2
2
|
import { AbstractObjectTypeFactory } from '../schema/TypeFactory';
|
|
3
3
|
import { Type } from '@ja-platform/parser-type-system';
|
|
4
|
-
import {
|
|
5
|
-
export declare class Param<T extends Type = Type> extends
|
|
4
|
+
import { GenerateFieldEvent, Field } from './Field';
|
|
5
|
+
export declare class Param<T extends Type = Type> extends Field<T> {
|
|
6
6
|
static TYPE: string;
|
|
7
7
|
static isInstanceOf(obj: any): obj is Param;
|
|
8
|
+
sourceTypeName?: string;
|
|
8
9
|
required?: boolean;
|
|
9
10
|
provideValue?: FunctionExpression;
|
|
10
|
-
toJSON(): VariableJsonType;
|
|
11
11
|
}
|
|
12
|
-
export interface GenerateParamEvent<T extends Type> extends
|
|
12
|
+
export interface GenerateParamEvent<T extends Type> extends GenerateFieldEvent<T> {
|
|
13
13
|
required?: boolean;
|
|
14
14
|
provideValue?: FunctionExpression;
|
|
15
15
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { SchemaObjectDisplayExpression } from '../expressions/SchemaObjectDisplayExpression';
|
|
2
2
|
import { ObjectType, Type } from '@ja-platform/parser-type-system';
|
|
3
|
-
import {
|
|
3
|
+
import { Field } from './Field';
|
|
4
4
|
import { Relationship } from './Relationship';
|
|
5
5
|
import { Schema } from '../schema/Schema';
|
|
6
|
-
import { XMLElement } from '@journeyapps/domparser/types';
|
|
7
6
|
import { ModelIndex } from '../schema/ModelIndex';
|
|
8
7
|
import { TextType } from './primitives';
|
|
9
8
|
import { AbstractObjectTypeFactory, GenerateTypeEvent } from '../schema/TypeFactory';
|
|
@@ -17,10 +16,9 @@ export declare class SchemaModelType extends ObjectType {
|
|
|
17
16
|
static readonly TYPE = "object";
|
|
18
17
|
readonly isPrimitiveType = false;
|
|
19
18
|
readonly isObject = true;
|
|
20
|
-
attributes: Record<string,
|
|
19
|
+
attributes: Record<string, Field>;
|
|
21
20
|
static isInstanceOf(type: any): type is SchemaModelType;
|
|
22
21
|
displayFormat: SchemaObjectDisplayExpression | null;
|
|
23
|
-
displaySource?: XMLElement;
|
|
24
22
|
label: string;
|
|
25
23
|
belongsTo: {
|
|
26
24
|
[index: string]: Relationship;
|
|
@@ -29,15 +27,15 @@ export declare class SchemaModelType extends ObjectType {
|
|
|
29
27
|
[index: string]: Relationship;
|
|
30
28
|
};
|
|
31
29
|
belongsToVars: {
|
|
32
|
-
[index: string]:
|
|
30
|
+
[index: string]: Field;
|
|
33
31
|
};
|
|
34
32
|
belongsToIdVars: {
|
|
35
|
-
[index: string]:
|
|
33
|
+
[index: string]: Field;
|
|
36
34
|
};
|
|
37
35
|
hasManyVars: {
|
|
38
|
-
[index: string]:
|
|
36
|
+
[index: string]: Field;
|
|
39
37
|
};
|
|
40
|
-
idVar:
|
|
38
|
+
idVar: Field<TextType>;
|
|
41
39
|
/**
|
|
42
40
|
* App and Cloud indexes.
|
|
43
41
|
*/
|
|
@@ -46,32 +44,18 @@ export declare class SchemaModelType extends ObjectType {
|
|
|
46
44
|
* App indexes.
|
|
47
45
|
*/
|
|
48
46
|
indexes: ModelIndex[];
|
|
49
|
-
errors: any[];
|
|
50
47
|
webhooks: any[];
|
|
51
48
|
notifyUsers: NotificationConfig[];
|
|
52
|
-
sourceElement: XMLElement;
|
|
53
49
|
constructor(name?: string);
|
|
54
|
-
addAttribute(attribute:
|
|
50
|
+
addAttribute(attribute: Field): void;
|
|
55
51
|
setupVariables(schema: Schema): void;
|
|
56
52
|
/**
|
|
57
53
|
* Attribute or relationship variable.
|
|
58
54
|
*/
|
|
59
|
-
getAttribute(name: string):
|
|
55
|
+
getAttribute(name: string): Field | null;
|
|
60
56
|
getField(name: string): Type | null;
|
|
61
57
|
getAttributes(): {
|
|
62
|
-
[index: string]:
|
|
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;
|
|
58
|
+
[index: string]: Field;
|
|
75
59
|
};
|
|
76
60
|
addBelongsTo(options: {
|
|
77
61
|
schema: Schema;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Day } from '../../day/Day';
|
|
1
2
|
import { Type } from '@ja-platform/parser-type-system';
|
|
2
3
|
export declare class DateType extends Type {
|
|
3
4
|
static DEFAULT_FORMAT: string;
|
|
@@ -9,5 +10,5 @@ export declare class DateType extends Type {
|
|
|
9
10
|
toJSON(): any;
|
|
10
11
|
format(value: any, format?: string): string;
|
|
11
12
|
is(value: any): boolean;
|
|
12
|
-
parse(value: any): Date |
|
|
13
|
+
parse(value: any): Date | Day;
|
|
13
14
|
}
|
package/dist/day/Day.js
CHANGED
|
@@ -1,112 +1,104 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Day = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
class Day {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
if (args.length === 3) {
|
|
8
|
+
this._time = new Date(Date.UTC(args[0], args[1], args[2]));
|
|
9
|
+
}
|
|
10
|
+
else if (args.length === 1 && args[0] instanceof Date) {
|
|
11
|
+
this._time = (0, utils_1.dateFromTime)(args[0]);
|
|
12
|
+
}
|
|
13
|
+
else if (args.length === 1 && Day.isDay(args[0])) {
|
|
14
|
+
this._time = args[0].toDate();
|
|
15
|
+
}
|
|
16
|
+
else if (args.length === 1 && typeof args[0] === 'string') {
|
|
17
|
+
if (!/^\d\d\d\d-\d\d-\d\d/.test(args[0])) {
|
|
18
|
+
throw new Error('Invalid date format');
|
|
19
|
+
}
|
|
20
|
+
this._time = new Date(args[0].substring(0, 10) + 'T00:00Z');
|
|
21
|
+
}
|
|
22
|
+
else if (args.length === 1 && typeof args[0] === 'number') {
|
|
23
|
+
const date = new Date(args[0]);
|
|
24
|
+
if (!(0, utils_1.isPureDate)(date)) {
|
|
25
|
+
throw new Error('Invalid Day');
|
|
26
|
+
}
|
|
27
|
+
this._time = date;
|
|
28
|
+
}
|
|
29
|
+
else if (args.length === 0) {
|
|
30
|
+
this._time = (0, utils_1.dateFromTime)(new Date());
|
|
29
31
|
}
|
|
30
32
|
else {
|
|
31
|
-
throw new Error('Invalid
|
|
33
|
+
throw new Error('Invalid args for Day()');
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
static today() {
|
|
37
|
+
return new Day();
|
|
38
|
+
}
|
|
39
|
+
static fromUTCDate(date) {
|
|
40
|
+
return new Day(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Recognize Day objects, including instances from other copies of the package.
|
|
44
|
+
*/
|
|
45
|
+
static isDay(obj) {
|
|
46
|
+
return (obj instanceof Day ||
|
|
47
|
+
(obj !== null &&
|
|
48
|
+
typeof obj === 'object' &&
|
|
49
|
+
'startOfDay' in obj &&
|
|
50
|
+
typeof obj.startOfDay === 'function' &&
|
|
51
|
+
'endOfDay' in obj &&
|
|
52
|
+
typeof obj.endOfDay === 'function'));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Return a copy of the date at midnight UTC.
|
|
56
|
+
*/
|
|
57
|
+
toDate() {
|
|
58
|
+
return new Date(this._time.getTime());
|
|
59
|
+
}
|
|
60
|
+
toString() {
|
|
61
|
+
return this._time.toISOString().substring(0, 10);
|
|
62
|
+
}
|
|
63
|
+
toJSON() {
|
|
64
|
+
return this.toString();
|
|
65
|
+
}
|
|
66
|
+
toISOString() {
|
|
67
|
+
return this.toString();
|
|
68
|
+
}
|
|
69
|
+
valueOf() {
|
|
70
|
+
return this._time.getTime();
|
|
41
71
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Start of the day in the local timezone.
|
|
74
|
+
*/
|
|
75
|
+
startOfDay() {
|
|
76
|
+
return new Date(this.getYear(), this.getMonth(), this.getDay());
|
|
46
77
|
}
|
|
47
|
-
|
|
48
|
-
|
|
78
|
+
/**
|
|
79
|
+
* End of the day in the local timezone.
|
|
80
|
+
*/
|
|
81
|
+
endOfDay() {
|
|
82
|
+
return new Date(this.getYear(), this.getMonth(), this.getDay(), 23, 59, 59, 999);
|
|
49
83
|
}
|
|
50
|
-
|
|
51
|
-
|
|
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;
|
|
84
|
+
getYear() {
|
|
85
|
+
return this._time.getUTCFullYear();
|
|
60
86
|
}
|
|
61
|
-
|
|
62
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Zero-based month, from 0 (January) to 11 (December).
|
|
89
|
+
*/
|
|
90
|
+
getMonth() {
|
|
91
|
+
return this._time.getUTCMonth();
|
|
63
92
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// of duplicate imports.
|
|
67
|
-
return typeof obj.startOfDay == 'function' && typeof obj.endOfDay == 'function';
|
|
93
|
+
getDay() {
|
|
94
|
+
return this._time.getUTCDate();
|
|
68
95
|
}
|
|
69
|
-
|
|
70
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Day of the week, from 0 (Sunday) to 6 (Saturday).
|
|
98
|
+
*/
|
|
99
|
+
getDayOfWeek() {
|
|
100
|
+
return this._time.getUTCDay();
|
|
71
101
|
}
|
|
72
|
-
}
|
|
73
|
-
|
|
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
|
-
};
|
|
102
|
+
}
|
|
103
|
+
exports.Day = Day;
|
|
112
104
|
//# sourceMappingURL=Day.js.map
|
package/dist/day/Day.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Day.js","sourceRoot":"","sources":["../../src/day/Day.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Day.js","sourceRoot":"","sources":["../../src/day/Day.ts"],"names":[],"mappings":";;;AAAA,mCAAmD;AAEnD;IAgBE,YAAY,GAAG,IAAoE;QACjF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7D,CAAC;aAAM,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,CAAC;YACxD,IAAI,CAAC,KAAK,GAAG,IAAA,oBAAY,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC,CAAC;aAAM,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAChC,CAAC;aAAM,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC5D,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE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CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;IAChC,CAAC;CACF","sourcesContent":["import { dateFromTime, isPureDate } from './utils';\n\nexport class Day {\n private _time: Date;\n\n /**\n * Today in the local timezone.\n */\n constructor();\n /**\n * Construct from a local Date, another Day, a date string, or a UTC midnight timestamp.\n * Date strings use their leading YYYY-MM-DD portion without timezone conversion.\n */\n constructor(date: Date | Day | string | number);\n /**\n * Construct from a year, zero-based month and day of month.\n */\n constructor(year: number, month: number, day: number);\n constructor(...args: [] | [Date | Day | string | number] | [number, number, number]) {\n if (args.length === 3) {\n this._time = new Date(Date.UTC(args[0], args[1], args[2]));\n } else if (args.length === 1 && args[0] instanceof Date) {\n this._time = dateFromTime(args[0]);\n } else if (args.length === 1 && Day.isDay(args[0])) {\n this._time = args[0].toDate();\n } else if (args.length === 1 && typeof args[0] === 'string') {\n if (!/^\\d\\d\\d\\d-\\d\\d-\\d\\d/.test(args[0])) {\n throw new Error('Invalid date format');\n }\n this._time = new Date(args[0].substring(0, 10) + 'T00:00Z');\n } else if (args.length === 1 && typeof args[0] === 'number') {\n const date = new Date(args[0]);\n if (!isPureDate(date)) {\n throw new Error('Invalid Day');\n }\n this._time = date;\n } else if (args.length === 0) {\n this._time = dateFromTime(new Date());\n } else {\n throw new Error('Invalid args for Day()');\n }\n }\n\n static today(): Day {\n return new Day();\n }\n\n static fromUTCDate(date: Date): Day {\n return new Day(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());\n }\n\n /**\n * Recognize Day objects, including instances from other copies of the package.\n */\n static isDay(obj: unknown): obj is Day {\n return (\n obj instanceof Day ||\n (obj !== null &&\n typeof obj === 'object' &&\n 'startOfDay' in obj &&\n typeof obj.startOfDay === 'function' &&\n 'endOfDay' in obj &&\n typeof obj.endOfDay === 'function')\n );\n }\n\n /**\n * Return a copy of the date at midnight UTC.\n */\n toDate(): Date {\n return new Date(this._time.getTime());\n }\n\n toString(): string {\n return this._time.toISOString().substring(0, 10);\n }\n\n toJSON(): string {\n return this.toString();\n }\n\n toISOString(): string {\n return this.toString();\n }\n\n valueOf(): number {\n return this._time.getTime();\n }\n\n /**\n * Start of the day in the local timezone.\n */\n startOfDay(): Date {\n return new Date(this.getYear(), this.getMonth(), this.getDay());\n }\n\n /**\n * End of the day in the local timezone.\n */\n endOfDay(): Date {\n return new Date(this.getYear(), this.getMonth(), this.getDay(), 23, 59, 59, 999);\n }\n\n getYear(): number {\n return this._time.getUTCFullYear();\n }\n\n /**\n * Zero-based month, from 0 (January) to 11 (December).\n */\n getMonth(): number {\n return this._time.getUTCMonth();\n }\n\n getDay(): number {\n return this._time.getUTCDate();\n }\n\n /**\n * Day of the week, from 0 (Sunday) to 6 (Saturday).\n */\n getDayOfWeek(): number {\n return this._time.getUTCDay();\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseParameterValueProvider = parseParameterValueProvider;
|
|
4
|
+
const parser_expressions_1 = require("@ja-platform/parser-expressions");
|
|
5
|
+
/**
|
|
6
|
+
* Normalize serialized parameter providers once at the schema boundary.
|
|
7
|
+
*/
|
|
8
|
+
function parseParameterValueProvider(source) {
|
|
9
|
+
const code = source.trim().replace(/^\$:/, '');
|
|
10
|
+
const call = /^[\w$]+(?:\.[\w$]+)*$/.test(code) ? `${code}()` : code;
|
|
11
|
+
return parser_expressions_1.FunctionExpression.parse(`${parser_expressions_1.FUNCTION_PREFIX}${call}`);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=parseParameterValueProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseParameterValueProvider.js","sourceRoot":"","sources":["../../src/expressions/parseParameterValueProvider.ts"],"names":[],"mappings":";;;AAAA,wEAAsF;AAEtF;;GAEG;AACH,qCAA4C,MAAc;IACxD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACrE,OAAO,uCAAkB,CAAC,KAAK,CAAC,GAAG,oCAAe,GAAG,IAAI,EAAE,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["import { FunctionExpression, FUNCTION_PREFIX } from '@ja-platform/parser-expressions';\n\n/**\n * Normalize serialized parameter providers once at the schema boundary.\n */\nexport function parseParameterValueProvider(source: string): FunctionExpression {\n const code = source.trim().replace(/^\\$:/, '');\n const call = /^[\\w$]+(?:\\.[\\w$]+)*$/.test(code) ? `${code}()` : code;\n return FunctionExpression.parse(`${FUNCTION_PREFIX}${call}`);\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -16,13 +16,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.ArrayType = void 0;
|
|
18
18
|
__exportStar(require("./schema/Schema"), exports);
|
|
19
|
-
__exportStar(require("./schema/schemaParser"), exports);
|
|
20
|
-
__exportStar(require("./schema/schemaSerializer"), exports);
|
|
21
19
|
__exportStar(require("./schema/TypeFactory"), exports);
|
|
22
20
|
__exportStar(require("./types/EnumOption"), exports);
|
|
23
|
-
__exportStar(require("./types/
|
|
21
|
+
__exportStar(require("./types/Field"), exports);
|
|
24
22
|
__exportStar(require("./types/Param"), exports);
|
|
25
|
-
__exportStar(require("./types/FunctionType"), exports);
|
|
26
23
|
__exportStar(require("./types/SchemaModelType"), exports);
|
|
27
24
|
__exportStar(require("./types/Relationship"), exports);
|
|
28
25
|
__exportStar(require("./types/primitives"), exports);
|
|
@@ -30,6 +27,9 @@ var parser_type_system_1 = require("@ja-platform/parser-type-system");
|
|
|
30
27
|
Object.defineProperty(exports, "ArrayType", { enumerable: true, get: function () { return parser_type_system_1.ArrayType; } });
|
|
31
28
|
__exportStar(require("./types/QueryType"), exports);
|
|
32
29
|
__exportStar(require("./expressions/SchemaObjectDisplayExpression"), exports);
|
|
33
|
-
__exportStar(require("./
|
|
34
|
-
__exportStar(require("./day"), exports);
|
|
30
|
+
__exportStar(require("./day/Day"), exports);
|
|
31
|
+
__exportStar(require("./day/utils"), exports);
|
|
32
|
+
__exportStar(require("./schema/ModelIndex"), exports);
|
|
33
|
+
__exportStar(require("./schema/fieldMetadata"), exports);
|
|
34
|
+
__exportStar(require("./expressions/parseParameterValueProvider"), exports);
|
|
35
35
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAAgC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAAgC;AAEhC,uDAAqC;AAErC,qDAAmC;AACnC,gDAA8B;AAC9B,gDAA8B;AAC9B,0DAAwC;AACxC,uDAAqC;AAErC,qDAAmC;AAEnC,sEAA4D;AAAnD,+GAAA,SAAS,OAAA;AAClB,oDAAkC;AAElC,8EAA4D;AAE5D,4CAA0B;AAC1B,8CAA4B;AAE5B,sDAAoC;AACpC,yDAAuC;AACvC,4EAA0D","sourcesContent":["export * from './schema/Schema';\n\nexport * from './schema/TypeFactory';\n\nexport * from './types/EnumOption';\nexport * from './types/Field';\nexport * from './types/Param';\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 './day/Day';\nexport * from './day/utils';\n\nexport * from './schema/ModelIndex';\nexport * from './schema/fieldMetadata';\nexport * from './expressions/parseParameterValueProvider';\n"]}
|