@garrix82/reactgenie-dsl 1.0.0 → 1.0.2
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/.env +10 -0
- package/.env.example +17 -0
- package/.github/workflows/publish.yml +20 -0
- package/README.md +5 -1
- package/package.json +1 -5
- package/dist/__test__/dsl-descriptor.test.d.ts +0 -1
- package/dist/__test__/dsl-descriptor.test.js +0 -27
- package/dist/__test__/dsl-descriptor.test.js.map +0 -1
- package/dist/__test__/example_descriptor.d.ts +0 -125
- package/dist/__test__/example_descriptor.js +0 -607
- package/dist/__test__/example_descriptor.js.map +0 -1
- package/dist/__test__/food_descriptor.state.json +0 -1
- package/dist/__test__/food_descriptor.test.d.ts +0 -74
- package/dist/__test__/food_descriptor.test.js +0 -205
- package/dist/__test__/food_descriptor.test.js.map +0 -1
- package/dist/__test__/nl-interpreter-provider-selection.test.d.ts +0 -1
- package/dist/__test__/nl-interpreter-provider-selection.test.js +0 -73
- package/dist/__test__/nl-interpreter-provider-selection.test.js.map +0 -1
- package/dist/__test__/nl-interpreter.test.d.ts +0 -1
- package/dist/__test__/nl-interpreter.test.js +0 -86
- package/dist/__test__/nl-interpreter.test.js.map +0 -1
- package/dist/decorators/__test__/decorators.test.d.ts +0 -1
- package/dist/decorators/__test__/decorators.test.js +0 -182
- package/dist/decorators/__test__/decorators.test.js.map +0 -1
- package/dist/decorators/__test__/inheritance-descriptor.test.d.ts +0 -1
- package/dist/decorators/__test__/inheritance-descriptor.test.js +0 -107
- package/dist/decorators/__test__/inheritance-descriptor.test.js.map +0 -1
- package/dist/dsl/__test__/dsl-interpreter.test.d.ts +0 -1
- package/dist/dsl/__test__/dsl-interpreter.test.js +0 -334
- package/dist/dsl/__test__/dsl-interpreter.test.js.map +0 -1
- package/dist/dsl/__test__/parser.gen.test.d.ts +0 -1
- package/dist/dsl/__test__/parser.gen.test.js +0 -283
- package/dist/dsl/__test__/parser.gen.test.js.map +0 -1
- package/dist/nl/__test__/context-aware-prompt.test.d.ts +0 -1
- package/dist/nl/__test__/context-aware-prompt.test.js +0 -247
- package/dist/nl/__test__/context-aware-prompt.test.js.map +0 -1
- package/dist/nl/__test__/context-selector.test.d.ts +0 -1
- package/dist/nl/__test__/context-selector.test.js +0 -20
- package/dist/nl/__test__/context-selector.test.js.map +0 -1
- package/dist/nl/__test__/nl-parser-groq-transport.test.d.ts +0 -1
- package/dist/nl/__test__/nl-parser-groq-transport.test.js +0 -87
- package/dist/nl/__test__/nl-parser-groq-transport.test.js.map +0 -1
- package/dist/nl/__test__/nl-parser-openai-parity.test.d.ts +0 -1
- package/dist/nl/__test__/nl-parser-openai-parity.test.js +0 -206
- package/dist/nl/__test__/nl-parser-openai-parity.test.js.map +0 -1
- package/dist/nl/__test__/nl-parser-openai-sampling.test.d.ts +0 -1
- package/dist/nl/__test__/nl-parser-openai-sampling.test.js +0 -44
- package/dist/nl/__test__/nl-parser-openai-sampling.test.js.map +0 -1
- package/dist/nl/__test__/nl-parser-openai-transport.test.d.ts +0 -1
- package/dist/nl/__test__/nl-parser-openai-transport.test.js +0 -55
- package/dist/nl/__test__/nl-parser-openai-transport.test.js.map +0 -1
- package/dist/nl/__test__/nl-parser-utils.test.d.ts +0 -1
- package/dist/nl/__test__/nl-parser-utils.test.js +0 -70
- package/dist/nl/__test__/nl-parser-utils.test.js.map +0 -1
- package/dist/nl/__test__/nl-parser.test.d.ts +0 -1
- package/dist/nl/__test__/nl-parser.test.js +0 -64
- package/dist/nl/__test__/nl-parser.test.js.map +0 -1
- package/dist/nl/__test__/parameter-tuning.test.d.ts +0 -1
- package/dist/nl/__test__/parameter-tuning.test.js +0 -95
- package/dist/nl/__test__/parameter-tuning.test.js.map +0 -1
- package/dist/nl/__test__/semantic-parsing-experiment.test.d.ts +0 -1
- package/dist/nl/__test__/semantic-parsing-experiment.test.js +0 -178
- package/dist/nl/__test__/semantic-parsing-experiment.test.js.map +0 -1
- package/dist/nl/llm-monitoring.test.d.ts +0 -5
- package/dist/nl/llm-monitoring.test.js +0 -101
- package/dist/nl/llm-monitoring.test.js.map +0 -1
- package/lib/__test__/dsl-descriptor.test.ts +0 -27
- package/lib/__test__/example_descriptor.ts +0 -762
- package/lib/__test__/food_descriptor.state.json +0 -1
- package/lib/__test__/food_descriptor.test.ts +0 -331
- package/lib/__test__/nl-interpreter-provider-selection.test.ts +0 -126
- package/lib/__test__/nl-interpreter.test.ts +0 -129
- package/lib/decorators/__test__/decorators.test.ts +0 -177
- package/lib/decorators/__test__/inheritance-descriptor.test.ts +0 -92
- package/lib/decorators/decorators.ts +0 -754
- package/lib/decorators/index.ts +0 -2
- package/lib/decorators/store.ts +0 -47
- package/lib/dsl/__test__/dsl-interpreter.test.ts +0 -453
- package/lib/dsl/__test__/parser.gen.test.ts +0 -296
- package/lib/dsl/dsl-interpreter.ts +0 -974
- package/lib/dsl/index.ts +0 -1
- package/lib/dsl/parser.gen.js +0 -1479
- package/lib/dsl/parser.pegjs +0 -130
- package/lib/dsl-descriptor.ts +0 -241
- package/lib/index.ts +0 -5
- package/lib/nl/__test__/context-aware-prompt.test.ts +0 -372
- package/lib/nl/__test__/context-selector.test.ts +0 -27
- package/lib/nl/__test__/nl-parser-groq-transport.test.ts +0 -139
- package/lib/nl/__test__/nl-parser-openai-parity.test.ts +0 -381
- package/lib/nl/__test__/nl-parser-openai-sampling.test.ts +0 -73
- package/lib/nl/__test__/nl-parser-openai-transport.test.ts +0 -79
- package/lib/nl/__test__/nl-parser-utils.test.ts +0 -98
- package/lib/nl/__test__/nl-parser.test.ts +0 -119
- package/lib/nl/__test__/parameter-tuning.test.ts +0 -137
- package/lib/nl/__test__/semantic-parsing-experiment.test.ts +0 -260
- package/lib/nl/context-selector.ts +0 -123
- package/lib/nl/index.ts +0 -19
- package/lib/nl/llm-monitoring.test.ts +0 -136
- package/lib/nl/llm-monitoring.ts +0 -339
- package/lib/nl/nl-parser-groq.ts +0 -510
- package/lib/nl/nl-parser-utils.ts +0 -310
- package/lib/nl/nl-parser.ts +0 -616
- package/lib/nl/prompt-gen.ts +0 -607
- package/lib/nl/prompt-res.ts +0 -207
- package/lib/nl-interpreter.ts +0 -262
|
@@ -1,182 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
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;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
-
};
|
|
34
|
-
var TodoList_1;
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
require("../decorators");
|
|
37
|
-
const assert = __importStar(require("assert"));
|
|
38
|
-
const dsl_descriptor_1 = require("../../dsl-descriptor");
|
|
39
|
-
const decorators_1 = require("../decorators");
|
|
40
|
-
const example_descriptor_1 = require("../../__test__/example_descriptor");
|
|
41
|
-
const store_1 = require("../store");
|
|
42
|
-
(0, decorators_1.initGenie)();
|
|
43
|
-
function essentialFuncDescriptor(original) {
|
|
44
|
-
return {
|
|
45
|
-
name: original.func_name,
|
|
46
|
-
params: original.parameters,
|
|
47
|
-
returnType: original.returnType,
|
|
48
|
-
isStatic: original.isStatic,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function essentialFieldDescriptor(original) {
|
|
52
|
-
return {
|
|
53
|
-
name: original.field,
|
|
54
|
-
type: original.fieldType,
|
|
55
|
-
isStatic: original.isStatic,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function sortDescriptor(a, b) {
|
|
59
|
-
return a.name.localeCompare(b.name);
|
|
60
|
-
}
|
|
61
|
-
function compareClassDescriptor(a, b) {
|
|
62
|
-
assert.equal(a.className, b.className);
|
|
63
|
-
assert.equal(a.classConstructor, b.classConstructor);
|
|
64
|
-
assert.equal(a.functions.size, b.functions.size);
|
|
65
|
-
assert.equal(a.fields.size, b.fields.size);
|
|
66
|
-
expect(Array.from(a.functions).map(essentialFuncDescriptor).sort(sortDescriptor)).toEqual(Array.from(b.functions).map(essentialFuncDescriptor).sort(sortDescriptor));
|
|
67
|
-
expect(Array.from(a.fields).map(essentialFieldDescriptor).sort(sortDescriptor)).toEqual(Array.from(b.fields).map(essentialFieldDescriptor).sort(sortDescriptor));
|
|
68
|
-
}
|
|
69
|
-
test("Restaurant Descriptor", async () => {
|
|
70
|
-
compareClassDescriptor(example_descriptor_1.Restaurant.ClassDescriptor, example_descriptor_1.Restaurant._ClassDescriptor);
|
|
71
|
-
example_descriptor_1.Restaurant.all();
|
|
72
|
-
const restaurant1 = example_descriptor_1.Restaurant.GetObject({ name: "McDonald's" });
|
|
73
|
-
const restaurant2 = example_descriptor_1.Restaurant.GetObject({ name: "McDonald's" });
|
|
74
|
-
restaurant2.rating = 5;
|
|
75
|
-
assert.equal(restaurant1.rating, 5);
|
|
76
|
-
restaurant2.rating = 3;
|
|
77
|
-
assert.equal(restaurant1.rating, 3);
|
|
78
|
-
});
|
|
79
|
-
test("Food Descriptor", async () => {
|
|
80
|
-
console.log("Food descriptor", example_descriptor_1.Food.ClassDescriptor);
|
|
81
|
-
console.log("Food descriptor", example_descriptor_1.Food._ClassDescriptor);
|
|
82
|
-
compareClassDescriptor(example_descriptor_1.Food.ClassDescriptor, example_descriptor_1.Food._ClassDescriptor);
|
|
83
|
-
example_descriptor_1.Restaurant.all();
|
|
84
|
-
example_descriptor_1.Food.all();
|
|
85
|
-
const foodItem1 = example_descriptor_1.Food.GetObject({ name: "Hamburger" });
|
|
86
|
-
const foodItem2 = example_descriptor_1.Food.GetObject({ name: "Hamburger" });
|
|
87
|
-
foodItem2.price = 6.99;
|
|
88
|
-
assert.equal(foodItem1.price, 6.99);
|
|
89
|
-
foodItem2.price = 5.99;
|
|
90
|
-
assert.equal(foodItem1.price, 5.99);
|
|
91
|
-
});
|
|
92
|
-
test("Order Descriptor", async () => {
|
|
93
|
-
compareClassDescriptor(example_descriptor_1.Order.ClassDescriptor, example_descriptor_1.Order._ClassDescriptor);
|
|
94
|
-
example_descriptor_1.Restaurant.all();
|
|
95
|
-
example_descriptor_1.Order.all();
|
|
96
|
-
const order1 = example_descriptor_1.Order.GetObject({ orderId: 1 });
|
|
97
|
-
const order2 = example_descriptor_1.Order.GetObject({ orderId: 1 });
|
|
98
|
-
order2.dateTime = example_descriptor_1.DateTime.CreateObject({
|
|
99
|
-
year: 2023,
|
|
100
|
-
month: 1,
|
|
101
|
-
day: 1,
|
|
102
|
-
hour: 13,
|
|
103
|
-
minute: 0,
|
|
104
|
-
});
|
|
105
|
-
assert.equal(order1.dateTime.toString(), new example_descriptor_1.DateTime({
|
|
106
|
-
year: 2023,
|
|
107
|
-
month: 1,
|
|
108
|
-
day: 1,
|
|
109
|
-
hour: 13,
|
|
110
|
-
minute: 0,
|
|
111
|
-
}).toString());
|
|
112
|
-
order2.dateTime = example_descriptor_1.DateTime.CreateObject({
|
|
113
|
-
year: 2023,
|
|
114
|
-
month: 1,
|
|
115
|
-
day: 2,
|
|
116
|
-
hour: 13,
|
|
117
|
-
minute: 0,
|
|
118
|
-
});
|
|
119
|
-
assert.equal(order1.dateTime.toString(), new example_descriptor_1.DateTime({
|
|
120
|
-
year: 2023,
|
|
121
|
-
month: 1,
|
|
122
|
-
day: 2,
|
|
123
|
-
hour: 13,
|
|
124
|
-
minute: 0,
|
|
125
|
-
}).toString());
|
|
126
|
-
});
|
|
127
|
-
let TodoListItem = class TodoListItem extends dsl_descriptor_1.HelperClass {
|
|
128
|
-
constructor({ name, done }) {
|
|
129
|
-
super({});
|
|
130
|
-
this.name = name;
|
|
131
|
-
this.done = done;
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
__decorate([
|
|
135
|
-
(0, decorators_1.GenieProperty)("Name of the item"),
|
|
136
|
-
__metadata("design:type", String)
|
|
137
|
-
], TodoListItem.prototype, "name", void 0);
|
|
138
|
-
__decorate([
|
|
139
|
-
(0, decorators_1.GenieProperty)("Whether the item is done"),
|
|
140
|
-
__metadata("design:type", Boolean)
|
|
141
|
-
], TodoListItem.prototype, "done", void 0);
|
|
142
|
-
TodoListItem = __decorate([
|
|
143
|
-
(0, decorators_1.GenieClass)("To-do list item"),
|
|
144
|
-
__metadata("design:paramtypes", [Object])
|
|
145
|
-
], TodoListItem);
|
|
146
|
-
let TodoList = TodoList_1 = class TodoList extends dsl_descriptor_1.DataClass {
|
|
147
|
-
constructor({ name, items }) {
|
|
148
|
-
super({});
|
|
149
|
-
this.name = name;
|
|
150
|
-
this.items = items;
|
|
151
|
-
}
|
|
152
|
-
static setup() {
|
|
153
|
-
TodoList_1.CreateObject({ name: "Groceries", items: [
|
|
154
|
-
TodoListItem.CreateObject({ name: "Milk", done: false }),
|
|
155
|
-
TodoListItem.CreateObject({ name: "Eggs", done: false }),
|
|
156
|
-
TodoListItem.CreateObject({ name: "Bread", done: false }),
|
|
157
|
-
] });
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
__decorate([
|
|
161
|
-
decorators_1.GenieKey,
|
|
162
|
-
(0, decorators_1.GenieProperty)("Name of the list"),
|
|
163
|
-
__metadata("design:type", String)
|
|
164
|
-
], TodoList.prototype, "name", void 0);
|
|
165
|
-
__decorate([
|
|
166
|
-
(0, decorators_1.GenieProperty)("Items in the list"),
|
|
167
|
-
__metadata("design:type", Array)
|
|
168
|
-
], TodoList.prototype, "items", void 0);
|
|
169
|
-
TodoList = TodoList_1 = __decorate([
|
|
170
|
-
(0, decorators_1.GenieClass)("To-do list"),
|
|
171
|
-
__metadata("design:paramtypes", [Object])
|
|
172
|
-
], TodoList);
|
|
173
|
-
test("Change TodoList", async () => {
|
|
174
|
-
(0, store_1.genieDispatch)(() => {
|
|
175
|
-
const groceriesList = TodoList.GetObject({ name: "Groceries" });
|
|
176
|
-
const item = groceriesList.items[0];
|
|
177
|
-
item.done = true;
|
|
178
|
-
const groceriesListItems = groceriesList.items;
|
|
179
|
-
groceriesListItems.push(TodoListItem.CreateObject({ name: "Butter", done: false }));
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
//# sourceMappingURL=decorators.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.test.js","sourceRoot":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ACpF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "..";
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var ParentHelper_1, ChildHelper_1;
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
require("..");
|
|
14
|
-
const __1 = require("..");
|
|
15
|
-
const dsl_descriptor_1 = require("../../dsl-descriptor");
|
|
16
|
-
let ParentHelper = ParentHelper_1 = class ParentHelper extends dsl_descriptor_1.HelperClass {
|
|
17
|
-
constructor({ parentField = "parent" } = {}) {
|
|
18
|
-
super({});
|
|
19
|
-
this.parentField = parentField;
|
|
20
|
-
}
|
|
21
|
-
parentInstance() {
|
|
22
|
-
return this;
|
|
23
|
-
}
|
|
24
|
-
static parentStatic() {
|
|
25
|
-
return ParentHelper_1.CreateObject({ parentField: "from-parent-static" });
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
__decorate([
|
|
29
|
-
(0, __1.GenieProperty)("Parent field"),
|
|
30
|
-
__metadata("design:type", String)
|
|
31
|
-
], ParentHelper.prototype, "parentField", void 0);
|
|
32
|
-
__decorate([
|
|
33
|
-
(0, __1.GenieFunction)("Parent instance method"),
|
|
34
|
-
__metadata("design:type", Function),
|
|
35
|
-
__metadata("design:paramtypes", []),
|
|
36
|
-
__metadata("design:returntype", ParentHelper)
|
|
37
|
-
], ParentHelper.prototype, "parentInstance", null);
|
|
38
|
-
__decorate([
|
|
39
|
-
(0, __1.GenieFunction)("Parent static method"),
|
|
40
|
-
__metadata("design:type", Function),
|
|
41
|
-
__metadata("design:paramtypes", []),
|
|
42
|
-
__metadata("design:returntype", ParentHelper)
|
|
43
|
-
], ParentHelper, "parentStatic", null);
|
|
44
|
-
ParentHelper = ParentHelper_1 = __decorate([
|
|
45
|
-
(0, __1.GenieClass)("Parent helper"),
|
|
46
|
-
__metadata("design:paramtypes", [Object])
|
|
47
|
-
], ParentHelper);
|
|
48
|
-
let ChildHelper = ChildHelper_1 = class ChildHelper extends ParentHelper {
|
|
49
|
-
constructor({ parentField = "parent", childField = "child", } = {}) {
|
|
50
|
-
super({ parentField });
|
|
51
|
-
this.childField = childField;
|
|
52
|
-
}
|
|
53
|
-
childInstance() {
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
static childStatic() {
|
|
57
|
-
return ChildHelper_1.CreateObject({
|
|
58
|
-
parentField: "from-child-static",
|
|
59
|
-
childField: "from-child-static",
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
__decorate([
|
|
64
|
-
(0, __1.GenieProperty)("Child field"),
|
|
65
|
-
__metadata("design:type", String)
|
|
66
|
-
], ChildHelper.prototype, "childField", void 0);
|
|
67
|
-
__decorate([
|
|
68
|
-
(0, __1.GenieFunction)("Child instance method"),
|
|
69
|
-
__metadata("design:type", Function),
|
|
70
|
-
__metadata("design:paramtypes", []),
|
|
71
|
-
__metadata("design:returntype", ChildHelper)
|
|
72
|
-
], ChildHelper.prototype, "childInstance", null);
|
|
73
|
-
__decorate([
|
|
74
|
-
(0, __1.GenieFunction)("Child static method"),
|
|
75
|
-
__metadata("design:type", Function),
|
|
76
|
-
__metadata("design:paramtypes", []),
|
|
77
|
-
__metadata("design:returntype", ChildHelper)
|
|
78
|
-
], ChildHelper, "childStatic", null);
|
|
79
|
-
ChildHelper = ChildHelper_1 = __decorate([
|
|
80
|
-
(0, __1.GenieClass)("Child helper"),
|
|
81
|
-
__metadata("design:paramtypes", [Object])
|
|
82
|
-
], ChildHelper);
|
|
83
|
-
describe("Genie descriptor inheritance isolation", () => {
|
|
84
|
-
test("creates an own ClassDescriptor for subclass and keeps parent descriptor clean", () => {
|
|
85
|
-
expect(Object.prototype.hasOwnProperty.call(ParentHelper, "ClassDescriptor")).toBe(true);
|
|
86
|
-
expect(Object.prototype.hasOwnProperty.call(ChildHelper, "ClassDescriptor")).toBe(true);
|
|
87
|
-
expect(ParentHelper.ClassDescriptor.className).toBe("ParentHelper");
|
|
88
|
-
expect(ChildHelper.ClassDescriptor.className).toBe("ChildHelper");
|
|
89
|
-
const parentFunctions = Array.from(ParentHelper.ClassDescriptor.functions).map((func) => func.func_name);
|
|
90
|
-
expect(parentFunctions).toContain("parentInstance");
|
|
91
|
-
expect(parentFunctions).toContain("parentStatic");
|
|
92
|
-
expect(parentFunctions).not.toContain("childInstance");
|
|
93
|
-
expect(parentFunctions).not.toContain("childStatic");
|
|
94
|
-
const childFunctions = Array.from(ChildHelper.ClassDescriptor.functions).map((func) => func.func_name);
|
|
95
|
-
expect(childFunctions).toContain("parentInstance");
|
|
96
|
-
expect(childFunctions).toContain("parentStatic");
|
|
97
|
-
expect(childFunctions).toContain("childInstance");
|
|
98
|
-
expect(childFunctions).toContain("childStatic");
|
|
99
|
-
const parentFields = Array.from(ParentHelper.ClassDescriptor.fields).map((field) => field.field);
|
|
100
|
-
expect(parentFields).toContain("parentField");
|
|
101
|
-
expect(parentFields).not.toContain("childField");
|
|
102
|
-
const childFields = Array.from(ChildHelper.ClassDescriptor.fields).map((field) => field.field);
|
|
103
|
-
expect(childFields).toContain("parentField");
|
|
104
|
-
expect(childFields).toContain("childField");
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
//# sourceMappingURL=inheritance-descriptor.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inheritance-descriptor.test.js","sourceRoot":"","sources":["../../../lib/decorators/__test__/inheritance-descriptor.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,cAAY;AACZ,0BAA8D;AAC9D,yDAAmD;AAEnD,IACM,YAAY,oBADlB,MACM,YAAa,SAAQ,4BAAW;IAIpC,YAAY,EAAE,WAAW,GAAG,QAAQ,KAA+B,EAAE;QACnE,KAAK,CAAC,EAAE,CAAC,CAAC;QACV,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAGD,cAAc;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAGM,AAAP,MAAM,CAAC,YAAY;QACjB,OAAO,cAAY,CAAC,YAAY,CAAC,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF,CAAA;AAhBC;IADC,IAAA,iBAAa,EAAC,cAAc,CAAC;;iDACV;AAQpB;IADC,IAAA,iBAAa,EAAC,wBAAwB,CAAC;;;oCACtB,YAAY;kDAE7B;AAGM;IADN,IAAA,iBAAa,EAAC,sBAAsB,CAAC;;;oCACf,YAAY;sCAElC;AAjBG,YAAY;IADjB,IAAA,cAAU,EAAC,eAAe,CAAC;;GACtB,YAAY,CAkBjB;AAED,IACM,WAAW,mBADjB,MACM,WAAY,SAAQ,YAAY;IAIpC,YAAY,EACV,WAAW,GAAG,QAAQ,EACtB,UAAU,GAAG,OAAO,MAIlB,EAAE;QACJ,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAGD,aAAa;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAGM,AAAP,MAAM,CAAC,WAAW;QAChB,OAAO,aAAW,CAAC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 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const dsl_interpreter_1 = require("../dsl-interpreter");
|
|
4
|
-
const example_descriptor_1 = require("../../__test__/example_descriptor");
|
|
5
|
-
const decorators_1 = require("../../decorators");
|
|
6
|
-
(0, decorators_1.initGenie)();
|
|
7
|
-
test("Basic function call", async () => {
|
|
8
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
9
|
-
const funcCallResult = await interpreter.interpret("Restaurant.current().book(dateTime: DateTime(year: 2020, month: 1, day: 1, hour: 12, minute: 0))");
|
|
10
|
-
expect(example_descriptor_1.recentBooking).toEqual("McDonald's is booking for 2020-1-1 12:0");
|
|
11
|
-
expect(funcCallResult).toEqual({
|
|
12
|
-
objectType: "void",
|
|
13
|
-
type: "object",
|
|
14
|
-
value: undefined
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
test("Indexing", async () => {
|
|
18
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
19
|
-
const funcCallResult = await interpreter.interpret("Restaurant.all()[1].name");
|
|
20
|
-
expect(funcCallResult).toEqual({
|
|
21
|
-
objectType: "string",
|
|
22
|
-
type: "object",
|
|
23
|
-
value: "KFC"
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
test("Array", async () => {
|
|
27
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
28
|
-
const funcCallResult = await interpreter.interpret("[Restaurant.all()[1].name, Restaurant.current().name]");
|
|
29
|
-
expect(funcCallResult).toEqual({
|
|
30
|
-
type: "array",
|
|
31
|
-
value: [
|
|
32
|
-
{
|
|
33
|
-
objectType: "string",
|
|
34
|
-
type: "object",
|
|
35
|
-
value: "KFC"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
objectType: "string",
|
|
39
|
-
type: "object",
|
|
40
|
-
value: "McDonald's"
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
test("Array matching", async () => {
|
|
46
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
47
|
-
const funcCallResult = await interpreter.interpret("Restaurant.current().menu.matching(field: .name, value: \"hamburger\")[0].name");
|
|
48
|
-
expect(funcCallResult).toEqual({
|
|
49
|
-
objectType: "string",
|
|
50
|
-
type: "object",
|
|
51
|
-
value: "Hamburger"
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
test("Array matching rejects quoted field parameter with a helpful error", async () => {
|
|
55
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
56
|
-
await expect(interpreter.interpret("Restaurant.all().matching(field: \"name\", value: \"Taste\")")).rejects.toThrow('Invalid DSL: matching(field: ...) requires a dotted accessor such as .name, but received string.');
|
|
57
|
-
});
|
|
58
|
-
test("Array matching does not crash on string field vs numeric value", async () => {
|
|
59
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
60
|
-
const funcCallResult = await interpreter.interpret("Order.all().matching(field: .dateTime.dayOfWeek, value: DateTime.today().month)");
|
|
61
|
-
expect(funcCallResult).toEqual({
|
|
62
|
-
type: "array",
|
|
63
|
-
value: []
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
test("Array contains does not crash on string field vs numeric value", async () => {
|
|
67
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
68
|
-
const funcCallResult = await interpreter.interpret("Order.all().contains(field: .dateTime.dayOfWeek, value: DateTime.today().month)");
|
|
69
|
-
expect(funcCallResult).toEqual({
|
|
70
|
-
type: "array",
|
|
71
|
-
value: []
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
test("Array between does not crash when comparator is unavailable", async () => {
|
|
75
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
76
|
-
const funcCallResult = await interpreter.interpret("Order.all().between(field: .restaurant, from: 1, to: 2)");
|
|
77
|
-
expect(funcCallResult).toEqual({
|
|
78
|
-
type: "array",
|
|
79
|
-
value: []
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
test("Array between", async () => {
|
|
83
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
84
|
-
const funcCallResult = await interpreter.interpret("Order.all().between(field: .dateTime, from: DateTime.today().addDateOffset(day: -7), to: DateTime.today())[0].restaurant.name");
|
|
85
|
-
expect(funcCallResult).toEqual({
|
|
86
|
-
objectType: "string",
|
|
87
|
-
type: "object",
|
|
88
|
-
value: "McDonald's"
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
test("Array between one side", async () => {
|
|
92
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
93
|
-
const funcCallResult = await interpreter.interpret("Order.all().between(field: .dateTime, from: DateTime.today().addDateOffset(day: -7))[-1].restaurant.name");
|
|
94
|
-
expect(funcCallResult).toEqual({
|
|
95
|
-
objectType: "string",
|
|
96
|
-
type: "object",
|
|
97
|
-
value: "McDonald's"
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
test("Array between one side deep accessor", async () => {
|
|
101
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
102
|
-
const funcCallResult = await interpreter.interpret("Order.all().between(field: .dateTime.day, from: 2, to: 3)[-1].dateTime.day");
|
|
103
|
-
expect(funcCallResult).toEqual({
|
|
104
|
-
"objectType": "int",
|
|
105
|
-
"type": "object",
|
|
106
|
-
"value": 3
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
test("Array equals", async () => {
|
|
110
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
111
|
-
const funcCallResult = await interpreter.interpret("Restaurant.all().equals(field: .priceGrade, value: 1)[0].name");
|
|
112
|
-
expect(funcCallResult).toEqual({
|
|
113
|
-
objectType: "string",
|
|
114
|
-
type: "object",
|
|
115
|
-
value: "KFC"
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
test("Array sort", async () => {
|
|
119
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
120
|
-
const funcCallResult = await interpreter.interpret("Restaurant.all().sort(field: .priceGrade, ascending: false)[0].name");
|
|
121
|
-
expect(funcCallResult).toEqual({
|
|
122
|
-
objectType: "string",
|
|
123
|
-
type: "object",
|
|
124
|
-
value: "Taste"
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
test("Array in array", async () => {
|
|
128
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
129
|
-
const funcCallResult = await interpreter.interpret("Restaurant.all().menu.matching(field:.name, value:\"Hamburger\")[0][0].name");
|
|
130
|
-
expect(funcCallResult).toEqual({
|
|
131
|
-
objectType: "string",
|
|
132
|
-
type: "object",
|
|
133
|
-
value: "Hamburger"
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
test("length", async () => {
|
|
137
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
138
|
-
const funcCallResult = await interpreter.interpret("Restaurant.all()[0].menu.matching(field:.name, value:\"Hamburger\").length()");
|
|
139
|
-
expect(funcCallResult).toEqual({
|
|
140
|
-
"objectType": "int",
|
|
141
|
-
"type": "object",
|
|
142
|
-
"value": 1
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
test("find burger name", async () => {
|
|
146
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
147
|
-
const funcCallResult = await interpreter.interpret("Restaurant.current().menu.matching(field: .name, value: \"hamburger\")[0].name");
|
|
148
|
-
expect(funcCallResult).toEqual({
|
|
149
|
-
objectType: "string",
|
|
150
|
-
type: "object",
|
|
151
|
-
value: "Hamburger"
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
test("find burger price", async () => {
|
|
155
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
156
|
-
const funcCallResult = await interpreter.interpret("Restaurant.current().menu.matching(field: .name, value: \"hamburger\")[0].price");
|
|
157
|
-
expect(funcCallResult).toEqual({
|
|
158
|
-
objectType: "float",
|
|
159
|
-
type: "object",
|
|
160
|
-
value: 5
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
test("best restaurant", async () => {
|
|
164
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
165
|
-
const funcCallResult = await interpreter.interpret("Restaurant.all().matching(field: .address, value: \"palo alto\").sort(field: .rating, ascending: false)[0]");
|
|
166
|
-
expect(await interpreter.describe(funcCallResult)).toEqual({
|
|
167
|
-
type: "object",
|
|
168
|
-
value: {
|
|
169
|
-
address: "123 Main St, Palo Alto, USA",
|
|
170
|
-
cuisine: "Chinese",
|
|
171
|
-
name: "Taste",
|
|
172
|
-
priceGrade: 3,
|
|
173
|
-
rating: 5
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
test("find cheap chinese restaurant", async () => {
|
|
178
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
179
|
-
const funcCallResult = await interpreter.interpret("Restaurant.all().matching(field: .cuisine, value: \"chinese\").sort(field: .priceGrade, ascending: true)[0]");
|
|
180
|
-
expect(await interpreter.describe(funcCallResult)).toEqual({
|
|
181
|
-
type: "object",
|
|
182
|
-
value: {
|
|
183
|
-
address: "123 Main St, Palo Alto, USA",
|
|
184
|
-
cuisine: "Chinese",
|
|
185
|
-
name: "Steam",
|
|
186
|
-
priceGrade: 2,
|
|
187
|
-
rating: 4
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
test("add hamburger to the order", async () => {
|
|
192
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
193
|
-
const funcCallResult = await interpreter.interpret("Order.current().addFoods(foods: [Restaurant.current().menu.matching(field: .name, value: \"hamburger\")[0]])");
|
|
194
|
-
expect(await interpreter.describe(funcCallResult)).toEqual({
|
|
195
|
-
type: "object",
|
|
196
|
-
value: "undefined"
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
test("add hamburger to the order (steps)", async () => {
|
|
200
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
201
|
-
const funcCallResult = await interpreter.interpretSteps("Restaurant.all().equals(field: .priceGrade, value: 1)[0].name");
|
|
202
|
-
const describeSteps = (await interpreter.describeSteps(funcCallResult[funcCallResult.length - 1].steps)).reverse();
|
|
203
|
-
expect((describeSteps[1])).toEqual({
|
|
204
|
-
type: "object",
|
|
205
|
-
value: {
|
|
206
|
-
address: "123 Main St, Palo Alto, USA",
|
|
207
|
-
cuisine: "Fast Food",
|
|
208
|
-
name: "KFC",
|
|
209
|
-
priceGrade: 1,
|
|
210
|
-
rating: 3
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
test("DateTime object comparison", async () => {
|
|
215
|
-
example_descriptor_1.Restaurant.all();
|
|
216
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
217
|
-
const funcCallResult = await interpreter.interpret("Order.all().between(field: .dateTime, from: DateTime(year: 2020, month: 2, day: 1, hour: 0, minute: 0), to: DateTime(year: 2020, month: 2, day: 1, hour: 23, minute: 59))[0].restaurant.name");
|
|
218
|
-
expect(funcCallResult).toEqual({
|
|
219
|
-
objectType: "string",
|
|
220
|
-
type: "object",
|
|
221
|
-
value: "McDonald's"
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
test("Order containing burger", async () => {
|
|
225
|
-
example_descriptor_1.Restaurant.all();
|
|
226
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
227
|
-
const funcCallResult = await interpreter.interpret("Order.all().contains(field: .foods, value: Restaurant.current().menu.matching(field: .name, value: \"hamburger\")[0])[0].restaurant.name");
|
|
228
|
-
expect(funcCallResult).toEqual({
|
|
229
|
-
objectType: "string",
|
|
230
|
-
type: "object",
|
|
231
|
-
value: "McDonald's"
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
test("Order array distribution field", async () => {
|
|
235
|
-
example_descriptor_1.Restaurant.all();
|
|
236
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
237
|
-
const funcCallResult = await interpreter.interpret("Order.all().dateTime[0].dayOfWeek");
|
|
238
|
-
expect(funcCallResult).toEqual({
|
|
239
|
-
"objectType": "string",
|
|
240
|
-
"type": "object",
|
|
241
|
-
"value": "Wednesday"
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
test("Order array distribution function", async () => {
|
|
245
|
-
example_descriptor_1.Restaurant.all();
|
|
246
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
247
|
-
const funcCallResult = await interpreter.interpret("Order.all().placeOrder()");
|
|
248
|
-
expect(funcCallResult["objectType"]).toEqual("void");
|
|
249
|
-
});
|
|
250
|
-
test("Multiple actions", async () => {
|
|
251
|
-
example_descriptor_1.Restaurant.all();
|
|
252
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
253
|
-
const funcCallResult = await interpreter.interpret("Order.all().placeOrder(); Order.all().dateTime[0].dayOfWeek");
|
|
254
|
-
expect(funcCallResult["objectType"]).toEqual("string");
|
|
255
|
-
});
|
|
256
|
-
test("Single actions with semicolon", async () => {
|
|
257
|
-
example_descriptor_1.Restaurant.all();
|
|
258
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors);
|
|
259
|
-
const funcCallResult = await interpreter.interpret("Order.all().dateTime[0].dayOfWeek;");
|
|
260
|
-
expect(funcCallResult["objectType"]).toEqual("string");
|
|
261
|
-
});
|
|
262
|
-
test("[dry run] Order containing burger", async () => {
|
|
263
|
-
example_descriptor_1.Restaurant.all();
|
|
264
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors, true);
|
|
265
|
-
const funcCallResult = await interpreter.interpret("Order.all().contains(field: .foods, value: Restaurant.current().menu.matching(field: .name, value: \"hamburger\")[0])[0].restaurant.name");
|
|
266
|
-
expect(funcCallResult).toEqual({
|
|
267
|
-
objectType: "string",
|
|
268
|
-
type: "object",
|
|
269
|
-
value: null
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
test("[dry run][error] Restaurant noise level", async () => {
|
|
273
|
-
example_descriptor_1.Restaurant.all();
|
|
274
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors, true);
|
|
275
|
-
try {
|
|
276
|
-
await interpreter.interpret("Restaurant.All().matching(field: .noiseLevel, value: \"quiet\")");
|
|
277
|
-
}
|
|
278
|
-
catch (e) {
|
|
279
|
-
expect(e.message).toEqual("Field Restaurant.noiseLevel is missing");
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
test("[dry run][error] Restaurant noise level 2", async () => {
|
|
283
|
-
example_descriptor_1.Restaurant.all();
|
|
284
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors, true);
|
|
285
|
-
try {
|
|
286
|
-
await interpreter.interpret("Restaurant.All()[0].noiseLevel");
|
|
287
|
-
}
|
|
288
|
-
catch (e) {
|
|
289
|
-
expect(e.message).toEqual("Field Restaurant.noiseLevel is missing");
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
test("[dry run][error] Restaurant notify when near", async () => {
|
|
293
|
-
example_descriptor_1.Restaurant.all();
|
|
294
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors, true);
|
|
295
|
-
try {
|
|
296
|
-
await interpreter.interpret("Order.current().notifyWhenNearLocation()");
|
|
297
|
-
}
|
|
298
|
-
catch (e) {
|
|
299
|
-
expect(e.message).toEqual("Function Order.notifyWhenNearLocation is missing");
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
test("[dry run][error] Login", async () => {
|
|
303
|
-
example_descriptor_1.Restaurant.all();
|
|
304
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors, true);
|
|
305
|
-
try {
|
|
306
|
-
await interpreter.interpret("User.login()");
|
|
307
|
-
}
|
|
308
|
-
catch (e) {
|
|
309
|
-
expect(e.message).toEqual("Class User is missing");
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
test("[dry run][error] String", async () => {
|
|
313
|
-
example_descriptor_1.Restaurant.all();
|
|
314
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors, true);
|
|
315
|
-
try {
|
|
316
|
-
await interpreter.interpret("Restaurant.All().matching(field: .location, value: \"near me\")");
|
|
317
|
-
}
|
|
318
|
-
catch (e) {
|
|
319
|
-
console.log(e);
|
|
320
|
-
expect(e.message).toEqual("Field Restaurant.location is missing");
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
test("GetObject", async () => {
|
|
324
|
-
example_descriptor_1.Restaurant.all();
|
|
325
|
-
const interpreter = new dsl_interpreter_1.DslInterpreter(example_descriptor_1.allDescriptors, true);
|
|
326
|
-
try {
|
|
327
|
-
await interpreter.interpret("Restaurant.GetObject(id:0)");
|
|
328
|
-
}
|
|
329
|
-
catch (e) {
|
|
330
|
-
console.log(e);
|
|
331
|
-
expect(e.message).toEqual("Function Restaurant.GetObject is missing");
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
//# sourceMappingURL=dsl-interpreter.test.js.map
|