@bikky/replication 1.0.1
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/Constants/Errors.d.ts +27 -0
- package/Constants/Errors.js +75 -0
- package/Constants/Logging.d.ts +17 -0
- package/Constants/Logging.js +97 -0
- package/Constants/ReplicableRegistry.d.ts +37 -0
- package/Constants/ReplicableRegistry.js +234 -0
- package/Constants/SerialisationTypes.d.ts +82 -0
- package/Constants/SerialisationTypes.js +160 -0
- package/Constants/SourceMaps.d.ts +10 -0
- package/Constants/SourceMaps.js +12 -0
- package/Constants/TraversalStep.d.ts +5 -0
- package/Constants/TraversalStep.js +2 -0
- package/Constants/Versions.d.ts +15 -0
- package/Constants/Versions.js +63 -0
- package/Expressions/Compiler/BuiltinGrammar.d.ts +234 -0
- package/Expressions/Compiler/BuiltinGrammar.js +446 -0
- package/Expressions/Compiler/ExpressionGrammar.d.ts +89 -0
- package/Expressions/Compiler/ExpressionGrammar.js +70 -0
- package/Expressions/Compiler/Parser.d.ts +56 -0
- package/Expressions/Compiler/Parser.js +314 -0
- package/Expressions/Compiler/Tokenizer.d.ts +52 -0
- package/Expressions/Compiler/Tokenizer.js +222 -0
- package/Expressions/Compiler/__tests__/Replicable.Expressions.Parser.test.d.ts +1 -0
- package/Expressions/Compiler/__tests__/Replicable.Expressions.Parser.test.js +516 -0
- package/Expressions/Compiler/__tests__/Replicable.Expressions.Tokenizer.test.d.ts +1 -0
- package/Expressions/Compiler/__tests__/Replicable.Expressions.Tokenizer.test.js +68 -0
- package/Expressions/CreateEvaluator.d.ts +4 -0
- package/Expressions/CreateEvaluator.js +85 -0
- package/Expressions/EvaluatorChain.d.ts +19 -0
- package/Expressions/EvaluatorChain.js +137 -0
- package/Expressions/EvaluatorSteps.d.ts +19 -0
- package/Expressions/EvaluatorSteps.js +12 -0
- package/Expressions/EvaluatorString.d.ts +21 -0
- package/Expressions/EvaluatorString.js +26 -0
- package/Expressions/Expression.d.ts +36 -0
- package/Expressions/Expression.js +147 -0
- package/Expressions/Traverser.d.ts +28 -0
- package/Expressions/Traverser.js +348 -0
- package/Expressions/TypeRegistry/Accessors.d.ts +26 -0
- package/Expressions/TypeRegistry/Accessors.js +58 -0
- package/Expressions/TypeRegistry/ChainCollections.d.ts +51 -0
- package/Expressions/TypeRegistry/ChainCollections.js +134 -0
- package/Expressions/TypeRegistry/ChainTypes.d.ts +23 -0
- package/Expressions/TypeRegistry/ChainTypes.js +46 -0
- package/Expressions/TypeRegistry/CustomAPI.d.ts +36 -0
- package/Expressions/TypeRegistry/CustomAPI.js +181 -0
- package/Expressions/TypeRegistry/Primitive.d.ts +19 -0
- package/Expressions/TypeRegistry/Primitive.js +47 -0
- package/Expressions/TypeRegistry/Registry.d.ts +27 -0
- package/Expressions/TypeRegistry/Registry.js +270 -0
- package/Expressions/TypeRegistry/ReplAPI.d.ts +41 -0
- package/Expressions/TypeRegistry/ReplAPI.js +220 -0
- package/Expressions/TypeRegistry/Scope.d.ts +24 -0
- package/Expressions/TypeRegistry/Scope.js +44 -0
- package/Expressions/TypeRegistry/Types.d.ts +23 -0
- package/Expressions/TypeRegistry/Types.js +1 -0
- package/Expressions/TypeRegistry/__tests__/Replicable.Expressions.Accessors.test.d.ts +1 -0
- package/Expressions/TypeRegistry/__tests__/Replicable.Expressions.Accessors.test.js +31 -0
- package/Expressions/__tests__/ExpressionExamples.d.ts +28 -0
- package/Expressions/__tests__/ExpressionExamples.js +50 -0
- package/Expressions/__tests__/Replicable.Expressions.Expressions.test.d.ts +1 -0
- package/Expressions/__tests__/Replicable.Expressions.Expressions.test.js +166 -0
- package/IDPool.d.ts +18 -0
- package/IDPool.data.d.ts +17 -0
- package/IDPool.js +139 -0
- package/License.txt +1 -0
- package/Main.d.ts +13 -0
- package/Main.js +13 -0
- package/Networking.d.ts +60 -0
- package/Networking.js +626 -0
- package/Replicatable.d.ts +66 -0
- package/Replicatable.js +123 -0
- package/Tracking/Buffable.d.ts +68 -0
- package/Tracking/Buffable.js +194 -0
- package/Tracking/Class.d.ts +97 -0
- package/Tracking/Class.js +221 -0
- package/Tracking/Functions.d.ts +14 -0
- package/Tracking/Functions.js +27 -0
- package/Tracking/GlobalGroup.d.ts +5 -0
- package/Tracking/GlobalGroup.js +39 -0
- package/Tracking/Property.d.ts +95 -0
- package/Tracking/Property.js +125 -0
- package/Tracking/Types.d.ts +33 -0
- package/Tracking/Types.js +1 -0
- package/Tracking/__tests__/Replicable.Tracking.Decorator.test.d.ts +1 -0
- package/Tracking/__tests__/Replicable.Tracking.Decorator.test.js +151 -0
- package/Tracking/__tests__/Replicable.Tracking.Deserialisation.test.d.ts +1 -0
- package/Tracking/__tests__/Replicable.Tracking.Deserialisation.test.js +253 -0
- package/Tracking/__tests__/Replicable.Tracking.MixinSchemaGeneration.test.d.ts +1 -0
- package/Tracking/__tests__/Replicable.Tracking.MixinSchemaGeneration.test.js +135 -0
- package/Tracking/__tests__/Replicable.Tracking.Struct.test.d.ts +1 -0
- package/Tracking/__tests__/Replicable.Tracking.Struct.test.js +66 -0
- package/Tracking/__tests__/Replicable.Tracking.Type.test.d.ts +1 -0
- package/Tracking/__tests__/Replicable.Tracking.Type.test.js +67 -0
- package/Transformers/Configurer.d.ts +39 -0
- package/Transformers/Configurer.js +415 -0
- package/Transformers/Constructor.d.ts +12 -0
- package/Transformers/Constructor.js +44 -0
- package/Transformers/Definitions.d.ts +102 -0
- package/Transformers/Definitions.js +626 -0
- package/Transformers/Loader.d.ts +45 -0
- package/Transformers/Loader.js +350 -0
- package/Transformers/Progress.d.ts +32 -0
- package/Transformers/Progress.js +429 -0
- package/Transformers/Reference.d.ts +37 -0
- package/Transformers/Reference.js +212 -0
- package/Transformers/SchemaGenerator.d.ts +102 -0
- package/Transformers/SchemaGenerator.js +564 -0
- package/Transformers/Serialiser.d.ts +31 -0
- package/Transformers/Serialiser.js +366 -0
- package/Transformers/Utils.d.ts +33 -0
- package/Transformers/Utils.js +287 -0
- package/Transformers/__tests__/Examples.d.ts +168 -0
- package/Transformers/__tests__/Examples.js +263 -0
- package/Transformers/__tests__/Replicable.Transformers.Definitions.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.Definitions.test.js +457 -0
- package/Transformers/__tests__/Replicable.Transformers.Loader.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.Loader.test.js +339 -0
- package/Transformers/__tests__/Replicable.Transformers.Progress.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.Progress.test.js +256 -0
- package/Transformers/__tests__/Replicable.Transformers.Reference.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.Reference.test.js +167 -0
- package/Transformers/__tests__/Replicable.Transformers.SchemaGenerator.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.SchemaGenerator.test.js +400 -0
- package/Transformers/__tests__/Replicable.Transformers.SchemaGeneratorOutput.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.SchemaGeneratorOutput.test.js +441 -0
- package/Transformers/__tests__/Replicable.Transformers.Serialiser.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.Serialiser.test.js +320 -0
- package/Transformers/__tests__/Replicable.Transformers.Utils.test.d.ts +1 -0
- package/Transformers/__tests__/Replicable.Transformers.Utils.test.js +534 -0
- package/__tests__/Replicable.Expressions.test.d.ts +1 -0
- package/__tests__/Replicable.Expressions.test.js +166 -0
- package/__tests__/Replicable.IDPool.test.d.ts +1 -0
- package/__tests__/Replicable.IDPool.test.js +11 -0
- package/__tests__/Replicable.ReplicableRegistry.test.d.ts +1 -0
- package/__tests__/Replicable.ReplicableRegistry.test.js +154 -0
- package/__tests__/Replicable.Serialisation.test.d.ts +1 -0
- package/__tests__/Replicable.Serialisation.test.js +283 -0
- package/package.json +14 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BikPath } from "@bikky/path";
|
|
8
|
+
import { fn } from "@vitest/spy";
|
|
9
|
+
import { expect, test } from "vitest";
|
|
10
|
+
import { ReplicableRegistry } from "../../Constants/ReplicableRegistry";
|
|
11
|
+
import { Versions } from "../../Constants/Versions";
|
|
12
|
+
import { SchemaGenerator } from "../SchemaGenerator";
|
|
13
|
+
import { Struct, Type } from "../../Tracking/Class";
|
|
14
|
+
import { Property } from "../../Tracking/Property";
|
|
15
|
+
import { Progress } from "../Progress.js";
|
|
16
|
+
const localPath = BikPath.getCurrentFilepath().replace(/\.test(?:\.js|\.ts)/, ".test.data.d.ts").replace(/\\/g, "/");
|
|
17
|
+
function PickOutput(test, _class, style) {
|
|
18
|
+
let parts = test.split("export");
|
|
19
|
+
let match = _class.name +
|
|
20
|
+
(style === "serialised" ? "Serialised" :
|
|
21
|
+
style === "reference" ? "SerialisedReference" :
|
|
22
|
+
style === "creation" ? "Creation" :
|
|
23
|
+
"Definition");
|
|
24
|
+
match = (style === "reference" ? "type " : "interface ") + match;
|
|
25
|
+
for (let part of parts) {
|
|
26
|
+
if (part.includes("import") && part.includes("from")) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (part.includes(match)) {
|
|
30
|
+
return "export" + part;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return match + " not found in output";
|
|
34
|
+
}
|
|
35
|
+
test("@Struct with @Property initialisation.", async () => {
|
|
36
|
+
Progress.ClearCaches();
|
|
37
|
+
let TestClass = class TestClass {
|
|
38
|
+
};
|
|
39
|
+
__decorate([
|
|
40
|
+
Property(Versions.v1_0_0, String)
|
|
41
|
+
], TestClass.prototype, "prop", void 0);
|
|
42
|
+
TestClass = __decorate([
|
|
43
|
+
Struct(Versions.v1_0_0)
|
|
44
|
+
], TestClass);
|
|
45
|
+
Progress.FinishedAllLoading();
|
|
46
|
+
await ReplicableRegistry.Initialise();
|
|
47
|
+
let options = {
|
|
48
|
+
open: fn((file) => {
|
|
49
|
+
expect(file).toBe(localPath);
|
|
50
|
+
return true;
|
|
51
|
+
}),
|
|
52
|
+
write: fn((file, text) => {
|
|
53
|
+
let match = PickOutput(text, TestClass, "definition");
|
|
54
|
+
expect(match, `Output contains ${TestClass.name}Definition`).toContain(` ${TestClass.name}Definition `);
|
|
55
|
+
expect(match, "Output contains Prop").toContain("Prop");
|
|
56
|
+
expect(match, "Output contains Prop: string;").toContain("Prop: string | `@{${string}}`;");
|
|
57
|
+
expect(match).toContain(`
|
|
58
|
+
export interface ${TestClass.name}Definition {
|
|
59
|
+
\tClass: "${TestClass.name}";
|
|
60
|
+
\tProp: string | \`@{\${string}}\`;
|
|
61
|
+
}
|
|
62
|
+
`.trim());
|
|
63
|
+
return true;
|
|
64
|
+
})
|
|
65
|
+
};
|
|
66
|
+
SchemaGenerator.GenerateAllInterfaceTypes(Versions.v1_0_0, options);
|
|
67
|
+
expect(options.open).toBeCalledTimes(1);
|
|
68
|
+
expect(options.write).toBeCalledTimes(1);
|
|
69
|
+
});
|
|
70
|
+
test("@Struct with array @Property initialisation.", async () => {
|
|
71
|
+
Progress.ClearCaches();
|
|
72
|
+
let TestClass2 = class TestClass2 {
|
|
73
|
+
};
|
|
74
|
+
__decorate([
|
|
75
|
+
Property(Versions.v1_0_0, { type: String, array: true })
|
|
76
|
+
], TestClass2.prototype, "prop", void 0);
|
|
77
|
+
TestClass2 = __decorate([
|
|
78
|
+
Struct(Versions.v1_0_0)
|
|
79
|
+
], TestClass2);
|
|
80
|
+
Progress.FinishedAllLoading();
|
|
81
|
+
await ReplicableRegistry.Initialise();
|
|
82
|
+
let options = {
|
|
83
|
+
open: fn((file) => {
|
|
84
|
+
expect(file).toBe(localPath);
|
|
85
|
+
return true;
|
|
86
|
+
}),
|
|
87
|
+
write: fn((file, text) => {
|
|
88
|
+
let match = PickOutput(text, TestClass2, "definition");
|
|
89
|
+
expect(match, `Output contains ${TestClass2.name}Definition`).toContain(` ${TestClass2.name}Definition `);
|
|
90
|
+
expect(match, "Output contains Prop").toContain("Prop");
|
|
91
|
+
expect(match, "Output contains Prop: string[];").toContain("Prop: (string | `@{${string}}`)[] | `@{${string}}`;");
|
|
92
|
+
expect(match).toContain(`
|
|
93
|
+
export interface ${TestClass2.name}Definition {
|
|
94
|
+
\tClass: "${TestClass2.name}";
|
|
95
|
+
\tProp: (string | \`@{\${string}}\`)[] | \`@{\${string}}\`;
|
|
96
|
+
}
|
|
97
|
+
`.trim());
|
|
98
|
+
return true;
|
|
99
|
+
})
|
|
100
|
+
};
|
|
101
|
+
SchemaGenerator.GenerateAllInterfaceTypes(Versions.v1_0_0, options);
|
|
102
|
+
expect(options.open).toBeCalledTimes(1);
|
|
103
|
+
expect(options.write).toBeCalledTimes(1);
|
|
104
|
+
});
|
|
105
|
+
test("@Struct with readonly @Property initialisation.", async () => {
|
|
106
|
+
Progress.ClearCaches();
|
|
107
|
+
let TestClass3 = class TestClass3 {
|
|
108
|
+
};
|
|
109
|
+
__decorate([
|
|
110
|
+
Property(Versions.v1_0_0, String, { readonly: true })
|
|
111
|
+
], TestClass3.prototype, "prop", void 0);
|
|
112
|
+
TestClass3 = __decorate([
|
|
113
|
+
Struct(Versions.v1_0_0)
|
|
114
|
+
], TestClass3);
|
|
115
|
+
Progress.FinishedAllLoading();
|
|
116
|
+
await ReplicableRegistry.Initialise();
|
|
117
|
+
let options = {
|
|
118
|
+
open: fn((file) => {
|
|
119
|
+
expect(file).toBe(localPath);
|
|
120
|
+
return true;
|
|
121
|
+
}),
|
|
122
|
+
write: fn((file, text) => {
|
|
123
|
+
let match = PickOutput(text, TestClass3, "definition");
|
|
124
|
+
expect(match, `Output contains ${TestClass3.name}Definition`).toContain(` ${TestClass3.name}Definition `);
|
|
125
|
+
expect(match, "Output contains Prop").toContain("Prop");
|
|
126
|
+
expect(match, "Output contains Prop: string;").toContain("Prop: string | `@{${string}}`;");
|
|
127
|
+
expect(match).toContain(`
|
|
128
|
+
export interface ${TestClass3.name}Definition {
|
|
129
|
+
\tClass: "${TestClass3.name}";
|
|
130
|
+
\tProp: string | \`@{\${string}}\`;
|
|
131
|
+
} `.trim());
|
|
132
|
+
return true;
|
|
133
|
+
})
|
|
134
|
+
};
|
|
135
|
+
SchemaGenerator.GenerateAllInterfaceTypes(Versions.v1_0_0, options);
|
|
136
|
+
expect(options.open).toBeCalledTimes(1);
|
|
137
|
+
expect(options.write).toBeCalledTimes(1);
|
|
138
|
+
});
|
|
139
|
+
test("@Struct with readonly array @Property initialisation.", async () => {
|
|
140
|
+
Progress.ClearCaches();
|
|
141
|
+
let TestClass4 = class TestClass4 {
|
|
142
|
+
};
|
|
143
|
+
__decorate([
|
|
144
|
+
Property(Versions.v1_0_0, { type: String, array: true }, { readonly: true })
|
|
145
|
+
], TestClass4.prototype, "prop", void 0);
|
|
146
|
+
TestClass4 = __decorate([
|
|
147
|
+
Struct(Versions.v1_0_0)
|
|
148
|
+
], TestClass4);
|
|
149
|
+
Progress.FinishedAllLoading();
|
|
150
|
+
await ReplicableRegistry.Initialise();
|
|
151
|
+
let options = {
|
|
152
|
+
open: fn((file) => {
|
|
153
|
+
expect(file).toBe(localPath);
|
|
154
|
+
return true;
|
|
155
|
+
}),
|
|
156
|
+
write: fn((file, text) => {
|
|
157
|
+
let match = PickOutput(text, TestClass4, "definition");
|
|
158
|
+
expect(match, `Output contains ${TestClass4.name}Definition`).toContain(` ${TestClass4.name}Definition `);
|
|
159
|
+
expect(match, "Output contains Prop").toContain("Prop");
|
|
160
|
+
expect(match, "Output contains Prop: string[];").toContain("Prop: (string | `@{${string}}`)[] | `@{${string}}`;");
|
|
161
|
+
expect(match).toContain(`
|
|
162
|
+
export interface ${TestClass4.name}Definition {
|
|
163
|
+
\tClass: "${TestClass4.name}";
|
|
164
|
+
\tProp: (string | \`@{\${string}}\`)[] | \`@{\${string}}\`;
|
|
165
|
+
} `.trim());
|
|
166
|
+
return true;
|
|
167
|
+
})
|
|
168
|
+
};
|
|
169
|
+
SchemaGenerator.GenerateAllInterfaceTypes(Versions.v1_0_0, options);
|
|
170
|
+
expect(options.open).toBeCalledTimes(1);
|
|
171
|
+
expect(options.write).toBeCalledTimes(1);
|
|
172
|
+
});
|
|
173
|
+
test("@Struct with multiple @Property initialisation.", async () => {
|
|
174
|
+
Progress.ClearCaches();
|
|
175
|
+
let TestClass5 = class TestClass5 {
|
|
176
|
+
};
|
|
177
|
+
__decorate([
|
|
178
|
+
Property(Versions.v1_0_0, String)
|
|
179
|
+
], TestClass5.prototype, "prop", void 0);
|
|
180
|
+
__decorate([
|
|
181
|
+
Property(Versions.v1_0_0, Boolean)
|
|
182
|
+
], TestClass5.prototype, "flag", void 0);
|
|
183
|
+
TestClass5 = __decorate([
|
|
184
|
+
Struct(Versions.v1_0_0)
|
|
185
|
+
], TestClass5);
|
|
186
|
+
Progress.FinishedAllLoading();
|
|
187
|
+
await ReplicableRegistry.Initialise();
|
|
188
|
+
let options = {
|
|
189
|
+
open: fn((file) => {
|
|
190
|
+
expect(file).toBe(localPath);
|
|
191
|
+
return true;
|
|
192
|
+
}),
|
|
193
|
+
write: fn((file, text) => {
|
|
194
|
+
let match = PickOutput(text, TestClass5, "definition");
|
|
195
|
+
expect(match, `Output contains ${TestClass5.name}Definition`).toContain(` ${TestClass5.name}Definition `);
|
|
196
|
+
expect(match, "Output contains Prop").toContain("Prop");
|
|
197
|
+
expect(match, "Output contains Prop: string;").toContain("Prop: string | `@{${string}}`;");
|
|
198
|
+
expect(match, "Output contains Flag").toContain("Flag");
|
|
199
|
+
expect(match, "Output contains Flag: boolean;").toContain("Flag: boolean | `@{${string}}`;");
|
|
200
|
+
expect(match).toContain(`
|
|
201
|
+
export interface ${TestClass5.name}Definition {
|
|
202
|
+
\tClass: "${TestClass5.name}";
|
|
203
|
+
\tFlag: boolean | \`@{\${string}}\`;
|
|
204
|
+
\tProp: string | \`@{\${string}}\`;
|
|
205
|
+
} `.trim());
|
|
206
|
+
return true;
|
|
207
|
+
})
|
|
208
|
+
};
|
|
209
|
+
SchemaGenerator.GenerateAllInterfaceTypes(Versions.v1_0_0, options);
|
|
210
|
+
expect(options.open).toBeCalledTimes(1);
|
|
211
|
+
expect(options.write).toBeCalledTimes(1);
|
|
212
|
+
});
|
|
213
|
+
test("@Struct with map @Property initialisation.", async () => {
|
|
214
|
+
Progress.ClearCaches();
|
|
215
|
+
let TestClass6 = class TestClass6 {
|
|
216
|
+
};
|
|
217
|
+
__decorate([
|
|
218
|
+
Property(Versions.v1_0_0, { type: String, mapKey: String })
|
|
219
|
+
], TestClass6.prototype, "prop", void 0);
|
|
220
|
+
TestClass6 = __decorate([
|
|
221
|
+
Struct(Versions.v1_0_0)
|
|
222
|
+
], TestClass6);
|
|
223
|
+
Progress.FinishedAllLoading();
|
|
224
|
+
await ReplicableRegistry.Initialise();
|
|
225
|
+
let options = {
|
|
226
|
+
open: fn((file) => {
|
|
227
|
+
expect(file).toBe(localPath);
|
|
228
|
+
return true;
|
|
229
|
+
}),
|
|
230
|
+
write: fn((file, text) => {
|
|
231
|
+
let match = PickOutput(text, TestClass6, "definition");
|
|
232
|
+
expect(match, `Output contains ${TestClass6.name}Definition`).toContain(` ${TestClass6.name}Definition `);
|
|
233
|
+
expect(match, "Output contains Prop").toContain("Prop");
|
|
234
|
+
expect(match, "Output contains Prop: {[key: string]: (string | `@{${string}}`)} | `@{${string}}`;")
|
|
235
|
+
.toContain("Prop: {[key: string]: (string | `@{${string}}`)} | `@{${string}}`");
|
|
236
|
+
expect(match).toContain(`
|
|
237
|
+
export interface ${TestClass6.name}Definition {
|
|
238
|
+
\tClass: "${TestClass6.name}";
|
|
239
|
+
\tProp: {[key: string]: (string | \`@{\${string}}\`)} | \`@{\${string}}\`;
|
|
240
|
+
} `.trim());
|
|
241
|
+
return true;
|
|
242
|
+
})
|
|
243
|
+
};
|
|
244
|
+
SchemaGenerator.GenerateAllInterfaceTypes(Versions.v1_0_0, options);
|
|
245
|
+
expect(options.open).toBeCalledTimes(1);
|
|
246
|
+
expect(options.write).toBeCalledTimes(1);
|
|
247
|
+
});
|
|
248
|
+
test("@Struct with @Property with union type.", async () => {
|
|
249
|
+
Progress.ClearCaches();
|
|
250
|
+
let TestClass7 = class TestClass7 {
|
|
251
|
+
};
|
|
252
|
+
__decorate([
|
|
253
|
+
Property(Versions.v1_0_0, [String, Boolean])
|
|
254
|
+
], TestClass7.prototype, "prop", void 0);
|
|
255
|
+
TestClass7 = __decorate([
|
|
256
|
+
Struct(Versions.v1_0_0)
|
|
257
|
+
], TestClass7);
|
|
258
|
+
Progress.FinishedAllLoading();
|
|
259
|
+
await ReplicableRegistry.Initialise();
|
|
260
|
+
let options = {
|
|
261
|
+
open: fn((file) => {
|
|
262
|
+
expect(file).toBe(localPath);
|
|
263
|
+
return true;
|
|
264
|
+
}),
|
|
265
|
+
write: fn((file, text) => {
|
|
266
|
+
let match = PickOutput(text, TestClass7, "definition");
|
|
267
|
+
expect(match, `Output contains ${TestClass7.name}Definition`).toContain(` ${TestClass7.name}Definition `);
|
|
268
|
+
expect(match, "Output contains Prop").toContain("Prop");
|
|
269
|
+
expect(match, "Output contains Prop: boolean | string;").toContain("Prop: boolean | string | `@{${string}}`;");
|
|
270
|
+
expect(match).toContain(`
|
|
271
|
+
export interface ${TestClass7.name}Definition {
|
|
272
|
+
\tClass: "${TestClass7.name}";
|
|
273
|
+
\tProp: boolean | string | \`@{\${string}}\`;
|
|
274
|
+
}
|
|
275
|
+
`.trim());
|
|
276
|
+
return true;
|
|
277
|
+
})
|
|
278
|
+
};
|
|
279
|
+
SchemaGenerator.GenerateAllInterfaceTypes(Versions.v1_0_0, options);
|
|
280
|
+
expect(options.open).toBeCalledTimes(1);
|
|
281
|
+
expect(options.write).toBeCalledTimes(1);
|
|
282
|
+
});
|
|
283
|
+
test("@Struct with map @Property with union types.", async () => {
|
|
284
|
+
Progress.ClearCaches();
|
|
285
|
+
let TestClass8 = class TestClass8 {
|
|
286
|
+
};
|
|
287
|
+
__decorate([
|
|
288
|
+
Property(Versions.v1_0_0, { type: [String, Boolean], mapKey: String })
|
|
289
|
+
], TestClass8.prototype, "prop", void 0);
|
|
290
|
+
TestClass8 = __decorate([
|
|
291
|
+
Struct(Versions.v1_0_0)
|
|
292
|
+
], TestClass8);
|
|
293
|
+
Progress.FinishedAllLoading();
|
|
294
|
+
await ReplicableRegistry.Initialise();
|
|
295
|
+
let options = {
|
|
296
|
+
open: fn((file) => {
|
|
297
|
+
expect(file).toBe(localPath);
|
|
298
|
+
return true;
|
|
299
|
+
}),
|
|
300
|
+
write: fn((file, text) => {
|
|
301
|
+
let match = PickOutput(text, TestClass8, "definition");
|
|
302
|
+
expect(match, `Output contains ${TestClass8.name}Definition`).toContain(` ${TestClass8.name}Definition `);
|
|
303
|
+
expect(match, "Output contains Prop").toContain("Prop");
|
|
304
|
+
expect(match, "Output contains Prop: {[key: string]: (boolean | string | \`@{\${string}}\`)} | \`@{\${string}}\`;")
|
|
305
|
+
.toContain("Prop: {[key: string]: (boolean | string | \`@{\${string}}\`)} | \`@{\${string}}\`;");
|
|
306
|
+
expect(match).toContain(`
|
|
307
|
+
export interface ${TestClass8.name}Definition {
|
|
308
|
+
\tClass: "${TestClass8.name}";
|
|
309
|
+
\tProp: {[key: string]: (boolean | string | \`@{\${string}}\`)} | \`@{\${string}}\`;
|
|
310
|
+
} `.trim());
|
|
311
|
+
return true;
|
|
312
|
+
})
|
|
313
|
+
};
|
|
314
|
+
SchemaGenerator.GenerateAllInterfaceTypes(Versions.v1_0_0, options);
|
|
315
|
+
expect(options.open).toBeCalledTimes(1);
|
|
316
|
+
expect(options.write).toBeCalledTimes(1);
|
|
317
|
+
});
|
|
318
|
+
test("@Type with @Property initialisation.", async () => {
|
|
319
|
+
Progress.ClearCaches();
|
|
320
|
+
let TestClass9 = class TestClass9 {
|
|
321
|
+
static Reference() {
|
|
322
|
+
return [1];
|
|
323
|
+
}
|
|
324
|
+
static Dereference(obj) {
|
|
325
|
+
return 1;
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
__decorate([
|
|
329
|
+
Property(Versions.v1_0_0, String)
|
|
330
|
+
], TestClass9.prototype, "prop", void 0);
|
|
331
|
+
TestClass9 = __decorate([
|
|
332
|
+
Type(Versions.v1_0_0)
|
|
333
|
+
], TestClass9);
|
|
334
|
+
Progress.FinishedAllLoading();
|
|
335
|
+
await ReplicableRegistry.Initialise();
|
|
336
|
+
let options = {
|
|
337
|
+
open: fn((file) => {
|
|
338
|
+
expect(file).toBe(localPath);
|
|
339
|
+
return true;
|
|
340
|
+
}),
|
|
341
|
+
write: fn((file, text) => {
|
|
342
|
+
let def = PickOutput(text, TestClass9, "definition");
|
|
343
|
+
expect(def).toContain(`
|
|
344
|
+
export interface ${TestClass9.name}Definition {
|
|
345
|
+
\tClass: "${TestClass9.name}";
|
|
346
|
+
\tProp: string | \`@{\${string}}\`;
|
|
347
|
+
} `.trim());
|
|
348
|
+
let ser = PickOutput(text, TestClass9, "serialised");
|
|
349
|
+
expect(ser).toContain(`
|
|
350
|
+
export interface ${TestClass9.name}Serialised {
|
|
351
|
+
\tversion: string;
|
|
352
|
+
\tprop: [ "Primitive", string ] | [ "Expression", string ];
|
|
353
|
+
} `.trim());
|
|
354
|
+
let ref = PickOutput(text, TestClass9, "reference");
|
|
355
|
+
expect(ref).toContain(`
|
|
356
|
+
export type TestClass9SerialisedReference = [ string, ...(string | number)[] ];
|
|
357
|
+
`.trim());
|
|
358
|
+
return true;
|
|
359
|
+
})
|
|
360
|
+
};
|
|
361
|
+
SchemaGenerator.GenerateAllInterfaceTypes(Versions.v1_0_0, options);
|
|
362
|
+
expect(options.open).toHaveBeenCalledOnce();
|
|
363
|
+
expect(options.write).toHaveBeenCalledOnce();
|
|
364
|
+
});
|
|
365
|
+
test("@Type with reference to another @Type.", async () => {
|
|
366
|
+
Progress.ClearCaches();
|
|
367
|
+
let TestClass10 = class TestClass10 {
|
|
368
|
+
static Reference() {
|
|
369
|
+
return [1];
|
|
370
|
+
}
|
|
371
|
+
static Dereference(obj) {
|
|
372
|
+
return 1;
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
__decorate([
|
|
376
|
+
Property(Versions.v1_0_0, String)
|
|
377
|
+
], TestClass10.prototype, "prop", void 0);
|
|
378
|
+
TestClass10 = __decorate([
|
|
379
|
+
Type(Versions.v1_0_0)
|
|
380
|
+
], TestClass10);
|
|
381
|
+
let TestOtherClass10 = class TestOtherClass10 {
|
|
382
|
+
static Reference() {
|
|
383
|
+
return [1];
|
|
384
|
+
}
|
|
385
|
+
static Dereference(obj) {
|
|
386
|
+
return 1;
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
__decorate([
|
|
390
|
+
Property(Versions.v1_0_0, TestClass10)
|
|
391
|
+
], TestOtherClass10.prototype, "propTwo", void 0);
|
|
392
|
+
TestOtherClass10 = __decorate([
|
|
393
|
+
Type(Versions.v1_0_0)
|
|
394
|
+
], TestOtherClass10);
|
|
395
|
+
Progress.FinishedAllLoading();
|
|
396
|
+
await ReplicableRegistry.Initialise();
|
|
397
|
+
let options = {
|
|
398
|
+
open: fn((file) => {
|
|
399
|
+
expect(file).toBe(localPath);
|
|
400
|
+
return true;
|
|
401
|
+
}),
|
|
402
|
+
write: fn((file, text) => {
|
|
403
|
+
let def1 = PickOutput(text, TestClass10, "definition");
|
|
404
|
+
expect(def1, "TestClass Definition Generated Properly").toContain(`
|
|
405
|
+
export interface ${TestClass10.name}Definition {
|
|
406
|
+
\tClass: "${TestClass10.name}";
|
|
407
|
+
\tProp: string | \`@{\${string}}\`;
|
|
408
|
+
} `.trim());
|
|
409
|
+
let ser1 = PickOutput(text, TestClass10, "serialised");
|
|
410
|
+
expect(ser1, "TestClass Serialisation Generated Properly").toContain(`
|
|
411
|
+
export interface ${TestClass10.name}Serialised {
|
|
412
|
+
\tversion: string;
|
|
413
|
+
\tprop: [ "Primitive", string ] | [ "Expression", string ];
|
|
414
|
+
} `.trim());
|
|
415
|
+
let ref1 = PickOutput(text, TestClass10, "reference");
|
|
416
|
+
expect(ref1, "TestClass SerialisedReference Generated Properly").toContain(`
|
|
417
|
+
export type ${TestClass10.name}SerialisedReference = [ string, ...(string | number)[] ];
|
|
418
|
+
`.trim());
|
|
419
|
+
let def2 = PickOutput(text, TestOtherClass10, "definition");
|
|
420
|
+
expect(def2, "TestOtherClass Definition Generated Properly").toContain(`
|
|
421
|
+
export interface ${TestOtherClass10.name}Definition {
|
|
422
|
+
\tClass: "${TestOtherClass10.name}";
|
|
423
|
+
\tPropTwo: ${TestClass10.name}Definition | \`@{\${string}}\`;
|
|
424
|
+
} `.trim());
|
|
425
|
+
let ser2 = PickOutput(text, TestOtherClass10, "serialised");
|
|
426
|
+
expect(ser2, "TestOtherClass Serialised uses TestClassSerialisedReference").toContain(`
|
|
427
|
+
export interface ${TestOtherClass10.name}Serialised {
|
|
428
|
+
\tversion: string;
|
|
429
|
+
\tpropTwo: ${TestClass10.name}SerialisedReference | [ "Expression", string ];
|
|
430
|
+
} `.trim());
|
|
431
|
+
let ref2 = PickOutput(text, TestOtherClass10, "reference");
|
|
432
|
+
expect(ref2, "TestOtherClass SerialisedReference Generated Properly").toContain(`
|
|
433
|
+
export type ${TestOtherClass10.name}SerialisedReference = [ string, ...(string | number)[] ];
|
|
434
|
+
`.trim());
|
|
435
|
+
return true;
|
|
436
|
+
})
|
|
437
|
+
};
|
|
438
|
+
SchemaGenerator.GenerateAllInterfaceTypes(Versions.v1_0_0, options);
|
|
439
|
+
expect(options.open).toHaveBeenCalledOnce();
|
|
440
|
+
expect(options.write).toHaveBeenCalledOnce();
|
|
441
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../Loader.js";
|