@ja-platform/parser-schema 0.0.0-stage → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/@types/day/Day.d.ts +48 -0
  2. package/dist/@types/day/utils.d.ts +4 -0
  3. package/dist/@types/expressions/SchemaObjectDisplayExpression.d.ts +17 -0
  4. package/dist/@types/expressions/parseParameterValueProvider.d.ts +5 -0
  5. package/dist/@types/index.d.ts +32 -0
  6. package/dist/@types/schema/ModelIndex.d.ts +19 -0
  7. package/dist/@types/schema/Schema.d.ts +33 -0
  8. package/dist/@types/schema/SchemaError.d.ts +4 -0
  9. package/dist/@types/schema/TypeFactory.d.ts +25 -0
  10. package/dist/@types/schema/fieldMetadata.d.ts +5 -0
  11. package/dist/@types/types/EnumOption.d.ts +13 -0
  12. package/dist/@types/types/Field.d.ts +23 -0
  13. package/dist/@types/types/Param.d.ts +19 -0
  14. package/dist/@types/types/QueryType.d.ts +20 -0
  15. package/dist/@types/types/Relationship.d.ts +24 -0
  16. package/dist/@types/types/SchemaModelType.d.ts +85 -0
  17. package/dist/@types/types/primitives/BooleanType.d.ts +21 -0
  18. package/dist/@types/types/primitives/ChoiceType.d.ts +50 -0
  19. package/dist/@types/types/primitives/DateType.d.ts +14 -0
  20. package/dist/@types/types/primitives/DatetimeType.d.ts +9 -0
  21. package/dist/@types/types/primitives/GeoTrackType.d.ts +5 -0
  22. package/dist/@types/types/primitives/LocationType.d.ts +6 -0
  23. package/dist/@types/types/primitives/MultipleChoiceIntegerType.d.ts +8 -0
  24. package/dist/@types/types/primitives/MultipleChoiceType.d.ts +5 -0
  25. package/dist/@types/types/primitives/PrimitiveTypes.d.ts +52 -0
  26. package/dist/@types/types/primitives/SingleChoiceIntegerType.d.ts +8 -0
  27. package/dist/@types/types/primitives/SingleChoiceType.d.ts +5 -0
  28. package/dist/@types/types/primitives/TextType.d.ts +8 -0
  29. package/dist/@types/types/primitives/attachments/AttachmentType.d.ts +9 -0
  30. package/dist/@types/types/primitives/attachments/PhotoType.d.ts +6 -0
  31. package/dist/@types/types/primitives/attachments/SignatureType.d.ts +6 -0
  32. package/dist/day/Day.js +104 -0
  33. package/dist/day/Day.js.map +1 -0
  34. package/dist/day/utils.js +43 -0
  35. package/dist/day/utils.js.map +1 -0
  36. package/dist/expressions/SchemaObjectDisplayExpression.js +40 -0
  37. package/dist/expressions/SchemaObjectDisplayExpression.js.map +1 -0
  38. package/dist/expressions/parseParameterValueProvider.js +13 -0
  39. package/dist/expressions/parseParameterValueProvider.js.map +1 -0
  40. package/dist/index.js +53 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/schema/ModelIndex.js +14 -0
  43. package/dist/schema/ModelIndex.js.map +1 -0
  44. package/dist/schema/Schema.js +70 -0
  45. package/dist/schema/Schema.js.map +1 -0
  46. package/dist/schema/SchemaError.js +12 -0
  47. package/dist/schema/SchemaError.js.map +1 -0
  48. package/dist/schema/TypeFactory.js +21 -0
  49. package/dist/schema/TypeFactory.js.map +1 -0
  50. package/dist/schema/fieldMetadata.js +35 -0
  51. package/dist/schema/fieldMetadata.js.map +1 -0
  52. package/dist/tsconfig.tsbuildinfo +1 -0
  53. package/dist/types/EnumOption.js +22 -0
  54. package/dist/types/EnumOption.js.map +1 -0
  55. package/dist/types/Field.js +25 -0
  56. package/dist/types/Field.js.map +1 -0
  57. package/dist/types/Param.js +25 -0
  58. package/dist/types/Param.js.map +1 -0
  59. package/dist/types/QueryType.js +38 -0
  60. package/dist/types/QueryType.js.map +1 -0
  61. package/dist/types/Relationship.js +31 -0
  62. package/dist/types/Relationship.js.map +1 -0
  63. package/dist/types/SchemaModelType.js +130 -0
  64. package/dist/types/SchemaModelType.js.map +1 -0
  65. package/dist/types/primitives/BooleanType.js +9 -0
  66. package/dist/types/primitives/BooleanType.js.map +1 -0
  67. package/dist/types/primitives/ChoiceType.js +86 -0
  68. package/dist/types/primitives/ChoiceType.js.map +1 -0
  69. package/dist/types/primitives/DateType.js +69 -0
  70. package/dist/types/primitives/DateType.js.map +1 -0
  71. package/dist/types/primitives/DatetimeType.js +31 -0
  72. package/dist/types/primitives/DatetimeType.js.map +1 -0
  73. package/dist/types/primitives/GeoTrackType.js +12 -0
  74. package/dist/types/primitives/GeoTrackType.js.map +1 -0
  75. package/dist/types/primitives/LocationType.js +18 -0
  76. package/dist/types/primitives/LocationType.js.map +1 -0
  77. package/dist/types/primitives/MultipleChoiceIntegerType.js +34 -0
  78. package/dist/types/primitives/MultipleChoiceIntegerType.js.map +1 -0
  79. package/dist/types/primitives/MultipleChoiceType.js +12 -0
  80. package/dist/types/primitives/MultipleChoiceType.js.map +1 -0
  81. package/dist/types/primitives/PrimitiveTypes.js +54 -0
  82. package/dist/types/primitives/PrimitiveTypes.js.map +1 -0
  83. package/dist/types/primitives/SingleChoiceIntegerType.js +38 -0
  84. package/dist/types/primitives/SingleChoiceIntegerType.js.map +1 -0
  85. package/dist/types/primitives/SingleChoiceType.js +12 -0
  86. package/dist/types/primitives/SingleChoiceType.js.map +1 -0
  87. package/dist/types/primitives/TextType.js +22 -0
  88. package/dist/types/primitives/TextType.js.map +1 -0
  89. package/dist/types/primitives/attachments/AttachmentType.js +16 -0
  90. package/dist/types/primitives/attachments/AttachmentType.js.map +1 -0
  91. package/dist/types/primitives/attachments/PhotoType.js +16 -0
  92. package/dist/types/primitives/attachments/PhotoType.js.map +1 -0
  93. package/dist/types/primitives/attachments/SignatureType.js +16 -0
  94. package/dist/types/primitives/attachments/SignatureType.js.map +1 -0
  95. package/package.json +35 -3
  96. package/README.md +0 -3
@@ -0,0 +1,48 @@
1
+ export declare class Day {
2
+ private _time;
3
+ static today(): Day;
4
+ static fromUTCDate(date: Date): Day;
5
+ /**
6
+ * Recognize Day objects, including instances from other copies of the package.
7
+ */
8
+ static isDay(obj: unknown): obj is Day;
9
+ /**
10
+ * Today in the local timezone.
11
+ */
12
+ constructor();
13
+ /**
14
+ * Construct from a local Date, another Day, a date string, or a UTC midnight timestamp.
15
+ * Date strings use their leading YYYY-MM-DD portion without timezone conversion.
16
+ */
17
+ constructor(date: Date | Day | string | number);
18
+ /**
19
+ * Construct from a year, zero-based month and day of month.
20
+ */
21
+ constructor(year: number, month: number, day: number);
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
+ }
@@ -0,0 +1,4 @@
1
+ export declare function dateFromTime(time: Date): Date;
2
+ export declare function pureDate(time: Date): Date;
3
+ export declare function isPureDate(date: Date): boolean;
4
+ export declare function parseDateTime(value: any): Date | null;
@@ -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,5 @@
1
+ import { FunctionExpression } from '@ja-platform/parser-expressions';
2
+ /**
3
+ * Normalize serialized parameter providers once at the schema boundary.
4
+ */
5
+ export declare function parseParameterValueProvider(source: string): FunctionExpression;
@@ -0,0 +1,32 @@
1
+ export * from './schema/Schema';
2
+ export * from './schema/SchemaError';
3
+ export * from './schema/TypeFactory';
4
+ export * from './types/EnumOption';
5
+ export * from './types/Field';
6
+ export * from './types/Param';
7
+ export * from './types/SchemaModelType';
8
+ export * from './types/Relationship';
9
+ export * from './types/primitives/PrimitiveTypes';
10
+ export * from './types/primitives/BooleanType';
11
+ export * from './types/primitives/DateType';
12
+ export * from './types/primitives/DatetimeType';
13
+ export { IntegerType, NumberType } from '@ja-platform/parser-type-system';
14
+ export * from './types/primitives/TextType';
15
+ export * from './types/primitives/LocationType';
16
+ export * from './types/primitives/GeoTrackType';
17
+ export * from './types/primitives/ChoiceType';
18
+ export * from './types/primitives/MultipleChoiceType';
19
+ export * from './types/primitives/MultipleChoiceIntegerType';
20
+ export * from './types/primitives/SingleChoiceType';
21
+ export * from './types/primitives/SingleChoiceIntegerType';
22
+ export * from './types/primitives/attachments/AttachmentType';
23
+ export * from './types/primitives/attachments/PhotoType';
24
+ export * from './types/primitives/attachments/SignatureType';
25
+ export { ArrayType } from '@ja-platform/parser-type-system';
26
+ export * from './types/QueryType';
27
+ export * from './expressions/SchemaObjectDisplayExpression';
28
+ export * from './day/Day';
29
+ export * from './day/utils';
30
+ export * from './schema/ModelIndex';
31
+ export * from './schema/fieldMetadata';
32
+ export * from './expressions/parseParameterValueProvider';
@@ -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,33 @@
1
+ import { Param } from '../types/Param';
2
+ import { Field } from '../types/Field';
3
+ import { Relationship } from '../types/Relationship';
4
+ import { SchemaModelType } from '../types/SchemaModelType';
5
+ import { Type } from '@ja-platform/parser-type-system';
6
+ import { PrimitiveTypeMap, PrimitiveTypeName } from '../types/primitives/PrimitiveTypes';
7
+ import { TypeFactory } from './TypeFactory';
8
+ export type InferGetType<T extends string | PrimitiveTypeName, MAP extends {
9
+ [key in PrimitiveTypeName]: new (...args: any[]) => Type;
10
+ } = PrimitiveTypeMap, Model extends SchemaModelType = SchemaModelType> = T extends PrimitiveTypeName ? InstanceType<MAP[T]> : Model;
11
+ export declare class Schema {
12
+ typeFactories: {
13
+ [key: string]: TypeFactory;
14
+ };
15
+ objects: {
16
+ [index: string]: SchemaModelType;
17
+ };
18
+ /**
19
+ * Create an empty resolved schema, independently of its input format.
20
+ */
21
+ constructor();
22
+ registerTypeFactory(factory: TypeFactory): void;
23
+ getFactory(name: string): TypeFactory<string>;
24
+ /** Helper function to assist in creating variables */
25
+ field<T extends Type = Type>(name?: string, type?: string): Field<T>;
26
+ field<T extends Type = Type>(name?: string, type?: T): Field<T>;
27
+ param<T extends Type = Type>(name?: string, type?: string): Param<T>;
28
+ param<T extends Type = Type>(name?: string, type?: T): Param<T>;
29
+ newObjectType(name?: string): SchemaModelType;
30
+ newRelationship(): Relationship;
31
+ getType<T extends string | PrimitiveTypeName>(typeName: T): InferGetType<T>;
32
+ primitive<T extends string | PrimitiveTypeName>(name: T): InferGetType<T>;
33
+ }
@@ -0,0 +1,4 @@
1
+ export declare class SchemaError extends Error {
2
+ readonly attribute: string;
3
+ constructor(message: string, attribute: string);
4
+ }
@@ -0,0 +1,25 @@
1
+ import { SchemaModelType } from '../types/SchemaModelType';
2
+ import { Param } from '../types/Param';
3
+ import { PrimitiveTypeInstance, PrimitiveTypeName } from '../types/primitives/PrimitiveTypes';
4
+ import { Relationship } from '../types/Relationship';
5
+ import { Field } from '../types/Field';
6
+ import { Schema } from './Schema';
7
+ export interface TypeFactory<NAME extends string = string> {
8
+ name: NAME;
9
+ generate: <T>(event?: any) => any;
10
+ }
11
+ export interface GenerateTypeEvent {
12
+ schema: Schema;
13
+ }
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;
16
+ export declare abstract class AbstractObjectTypeFactory<R extends ObjectTypeInstance = ObjectTypeInstance, E extends GenerateTypeEvent = GenerateTypeEvent> implements TypeFactory<ObjectTypeName> {
17
+ name: ObjectTypeName;
18
+ constructor(name: ObjectTypeName);
19
+ abstract generate<T>(event: E): R;
20
+ }
21
+ export declare class PrimitiveTypeFactory<T extends PrimitiveTypeInstance, E extends GenerateTypeEvent = GenerateTypeEvent> implements TypeFactory<PrimitiveTypeName> {
22
+ name: PrimitiveTypeName;
23
+ constructor(name: PrimitiveTypeName);
24
+ generate(event: E): T;
25
+ }
@@ -0,0 +1,5 @@
1
+ export declare const ATTACHMENT_MEDIA_TYPES: string[];
2
+ export declare const textSubtypeSpecs: {
3
+ [index: string]: string;
4
+ };
5
+ export declare const TEXT_SUBTYPES: string[];
@@ -0,0 +1,13 @@
1
+ export declare class EnumOption {
2
+ /** They key */
3
+ value: string | number | boolean;
4
+ label: string;
5
+ index: number;
6
+ static isInstanceOf(value: any): value is EnumOption;
7
+ constructor(key: string | number | boolean, label: string, index?: number);
8
+ toJSON(): {
9
+ value: string | number | boolean;
10
+ label: string;
11
+ index: number;
12
+ };
13
+ }
@@ -0,0 +1,23 @@
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
+ name: string;
9
+ type: T | null;
10
+ label?: string;
11
+ relationship?: string;
12
+ isRelationshipId?: boolean;
13
+ isBelongsToId?: boolean;
14
+ constructor(name: string, type: T | null);
15
+ }
16
+ export interface GenerateFieldEvent<T extends Type> extends GenerateTypeEvent {
17
+ name: string;
18
+ type: T;
19
+ }
20
+ export declare class FieldFactory<T extends Type = Type> extends AbstractObjectTypeFactory<Field<T>, GenerateFieldEvent<T>> {
21
+ constructor();
22
+ generate<T extends Type = Type>(event: GenerateFieldEvent<T>): Field<T>;
23
+ }
@@ -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 { GenerateFieldEvent, Field } from './Field';
5
+ export declare class Param<T extends Type = Type> extends Field<T> {
6
+ static TYPE: string;
7
+ static isInstanceOf(obj: any): obj is Param;
8
+ sourceTypeName?: string;
9
+ required?: boolean;
10
+ provideValue?: FunctionExpression;
11
+ }
12
+ export interface GenerateParamEvent<T extends Type> extends GenerateFieldEvent<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,20 @@
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
+ static readonly TYPE = "query";
8
+ readonly _typeName = "query";
9
+ readonly name = "query";
10
+ readonly isCollection = true;
11
+ static isInstanceOf(type: Type | null): type is QueryType;
12
+ constructor(itemType: Type);
13
+ is(value: any): boolean;
14
+ parse(value: unknown): unknown;
15
+ stringify(): string;
16
+ toJSON(): {
17
+ type: string;
18
+ object: string;
19
+ };
20
+ }
@@ -0,0 +1,24 @@
1
+ import { AbstractObjectTypeFactory } from '../schema/TypeFactory';
2
+ import { SchemaModelType } from './SchemaModelType';
3
+ export declare enum RelationshipType {
4
+ ONE_TO_MANY = "one-to-many",
5
+ MANY_TO_MANY = "many-to-many",
6
+ ONE_TO_ONE = "one-to-one"
7
+ }
8
+ export declare class Relationship {
9
+ static readonly TYPE = "relationship";
10
+ type: RelationshipType;
11
+ /** local object type (containing the belongs_to) */
12
+ objectType: SchemaModelType;
13
+ /** foreign object type (containing the has_many) */
14
+ foreignType: SchemaModelType;
15
+ /** The name used on the local object to identify the relationship (singular) */
16
+ name: string;
17
+ /** The name used on the foreign object to identify the relationship (plural) */
18
+ foreignName: string;
19
+ constructor();
20
+ }
21
+ export declare class RelationshipTypeFactory extends AbstractObjectTypeFactory<Relationship> {
22
+ constructor();
23
+ generate(): Relationship;
24
+ }
@@ -0,0 +1,85 @@
1
+ import { SchemaObjectDisplayExpression } from '../expressions/SchemaObjectDisplayExpression';
2
+ import { ObjectType, Type } from '@ja-platform/parser-type-system';
3
+ import { Field } from './Field';
4
+ import { Relationship } from './Relationship';
5
+ import { Schema } from '../schema/Schema';
6
+ import { ModelIndex } from '../schema/ModelIndex';
7
+ import { TextType } from './primitives/TextType';
8
+ import { AbstractObjectTypeFactory, GenerateTypeEvent } from '../schema/TypeFactory';
9
+ export interface NotificationConfig {
10
+ message: SchemaObjectDisplayExpression;
11
+ recipient: string;
12
+ received: string;
13
+ badgeCount: string;
14
+ }
15
+ export declare enum WebhookType {
16
+ READY = "ready",
17
+ UPDATE = "update"
18
+ }
19
+ export declare enum WebhookReceiver {
20
+ CLOUDCODE = "cloudcode"
21
+ }
22
+ export declare enum WebhookFieldState {
23
+ PRESENT = "present",
24
+ UPLOADED = "uploaded"
25
+ }
26
+ export interface WebhookFieldConfig {
27
+ name: string;
28
+ required: boolean;
29
+ embed: boolean;
30
+ state: WebhookFieldState;
31
+ }
32
+ export interface WebhookConfig {
33
+ name: string;
34
+ type: WebhookType;
35
+ receiver: WebhookReceiver | null;
36
+ action: string | null;
37
+ fields: WebhookFieldConfig[];
38
+ }
39
+ export declare class SchemaModelType extends ObjectType {
40
+ static readonly TYPE = "object";
41
+ static isInstanceOf(type: any): type is SchemaModelType;
42
+ attributes: Record<string, Field>;
43
+ displayFormat: SchemaObjectDisplayExpression | null;
44
+ label: string;
45
+ belongsTo: Record<string, Relationship>;
46
+ hasMany: Record<string, Relationship>;
47
+ belongsToVars: Record<string, Field>;
48
+ belongsToIdVars: Record<string, Field>;
49
+ hasManyVars: Record<string, Field>;
50
+ idVar: Field<TextType>;
51
+ /**
52
+ * App and Cloud indexes.
53
+ */
54
+ allIndexes: ModelIndex[];
55
+ /**
56
+ * App indexes.
57
+ */
58
+ indexes: ModelIndex[];
59
+ webhooks: WebhookConfig[];
60
+ notifyUsers: NotificationConfig[];
61
+ constructor(name?: string);
62
+ addAttribute(attribute: Field): void;
63
+ setupVariables(schema: Schema): void;
64
+ /**
65
+ * Attribute or relationship variable.
66
+ */
67
+ getAttribute(name: string): Field | null;
68
+ getField(name: string): Type | null;
69
+ getAttributes(): {
70
+ [index: string]: Field;
71
+ };
72
+ addBelongsTo(options: {
73
+ schema: Schema;
74
+ type?: string;
75
+ foreignName?: string;
76
+ name: string;
77
+ }): Relationship;
78
+ }
79
+ export interface GenerateSchemaModelTypeEvent extends GenerateTypeEvent {
80
+ name?: string;
81
+ }
82
+ export declare class SchemaModelTypeFactory extends AbstractObjectTypeFactory<SchemaModelType, GenerateSchemaModelTypeEvent> {
83
+ constructor();
84
+ generate(event: GenerateSchemaModelTypeEvent): SchemaModelType;
85
+ }
@@ -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,50 @@
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
+ is(value: unknown): boolean;
47
+ parse(value: unknown): unknown;
48
+ private hasOption;
49
+ }
50
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Day } from '../../day/Day';
2
+ import { Type } from '@ja-platform/parser-type-system';
3
+ export declare class DateType extends Type {
4
+ static DEFAULT_FORMAT: string;
5
+ readonly _typeName = "date";
6
+ static readonly TYPE = "date";
7
+ static isInstanceOf(type: Type | null): type is DateType;
8
+ isDay?: boolean;
9
+ constructor();
10
+ toJSON(): any;
11
+ format(value: any, format?: string): string;
12
+ is(value: any): boolean;
13
+ parse(value: any): Date | Day;
14
+ }
@@ -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
+ }
@@ -0,0 +1,5 @@
1
+ import { Type } from '@ja-platform/parser-type-system';
2
+ export declare class GeoTrackType extends Type {
3
+ static readonly TYPE = "track";
4
+ constructor();
5
+ }
@@ -0,0 +1,6 @@
1
+ import { ObjectType, Type } from '@ja-platform/parser-type-system';
2
+ export declare class LocationType extends ObjectType {
3
+ static readonly TYPE = "location";
4
+ constructor();
5
+ getField(name: string): Type | null;
6
+ }
@@ -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,5 @@
1
+ import { ChoiceType } from './ChoiceType';
2
+ export declare class MultipleChoiceType extends ChoiceType {
3
+ static readonly TYPE = "multiple-choice";
4
+ constructor();
5
+ }
@@ -0,0 +1,52 @@
1
+ import { AttachmentType } from './attachments/AttachmentType';
2
+ import { TextType } from './TextType';
3
+ import { BooleanType } from './BooleanType';
4
+ import { LocationType } from './LocationType';
5
+ import { GeoTrackType } from './GeoTrackType';
6
+ import { SingleChoiceType } from './SingleChoiceType';
7
+ import { SingleChoiceIntegerType } from './SingleChoiceIntegerType';
8
+ import { MultipleChoiceType } from './MultipleChoiceType';
9
+ import { MultipleChoiceIntegerType } from './MultipleChoiceIntegerType';
10
+ import { IntegerType, NumberType } from '@ja-platform/parser-type-system';
11
+ import { DateType } from './DateType';
12
+ import { DatetimeType } from './DatetimeType';
13
+ import { PhotoType } from './attachments/PhotoType';
14
+ import { SignatureType } from './attachments/SignatureType';
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]>;
@@ -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,5 @@
1
+ import { ChoiceType } from './ChoiceType';
2
+ export declare class SingleChoiceType extends ChoiceType {
3
+ static readonly TYPE = "single-choice";
4
+ constructor();
5
+ }
@@ -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,6 @@
1
+ import { AttachmentType } from './AttachmentType';
2
+ export declare class PhotoType extends AttachmentType {
3
+ static readonly SUB_TYPE = "photo";
4
+ constructor();
5
+ stringify(): string;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { AttachmentType } from './AttachmentType';
2
+ export declare class SignatureType extends AttachmentType {
3
+ static readonly SUB_TYPE = "signature";
4
+ constructor();
5
+ stringify(): string;
6
+ }