@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.
Files changed (105) hide show
  1. package/.env +10 -0
  2. package/.env.example +17 -0
  3. package/.github/workflows/publish.yml +20 -0
  4. package/README.md +5 -1
  5. package/package.json +1 -5
  6. package/dist/__test__/dsl-descriptor.test.d.ts +0 -1
  7. package/dist/__test__/dsl-descriptor.test.js +0 -27
  8. package/dist/__test__/dsl-descriptor.test.js.map +0 -1
  9. package/dist/__test__/example_descriptor.d.ts +0 -125
  10. package/dist/__test__/example_descriptor.js +0 -607
  11. package/dist/__test__/example_descriptor.js.map +0 -1
  12. package/dist/__test__/food_descriptor.state.json +0 -1
  13. package/dist/__test__/food_descriptor.test.d.ts +0 -74
  14. package/dist/__test__/food_descriptor.test.js +0 -205
  15. package/dist/__test__/food_descriptor.test.js.map +0 -1
  16. package/dist/__test__/nl-interpreter-provider-selection.test.d.ts +0 -1
  17. package/dist/__test__/nl-interpreter-provider-selection.test.js +0 -73
  18. package/dist/__test__/nl-interpreter-provider-selection.test.js.map +0 -1
  19. package/dist/__test__/nl-interpreter.test.d.ts +0 -1
  20. package/dist/__test__/nl-interpreter.test.js +0 -86
  21. package/dist/__test__/nl-interpreter.test.js.map +0 -1
  22. package/dist/decorators/__test__/decorators.test.d.ts +0 -1
  23. package/dist/decorators/__test__/decorators.test.js +0 -182
  24. package/dist/decorators/__test__/decorators.test.js.map +0 -1
  25. package/dist/decorators/__test__/inheritance-descriptor.test.d.ts +0 -1
  26. package/dist/decorators/__test__/inheritance-descriptor.test.js +0 -107
  27. package/dist/decorators/__test__/inheritance-descriptor.test.js.map +0 -1
  28. package/dist/dsl/__test__/dsl-interpreter.test.d.ts +0 -1
  29. package/dist/dsl/__test__/dsl-interpreter.test.js +0 -334
  30. package/dist/dsl/__test__/dsl-interpreter.test.js.map +0 -1
  31. package/dist/dsl/__test__/parser.gen.test.d.ts +0 -1
  32. package/dist/dsl/__test__/parser.gen.test.js +0 -283
  33. package/dist/dsl/__test__/parser.gen.test.js.map +0 -1
  34. package/dist/nl/__test__/context-aware-prompt.test.d.ts +0 -1
  35. package/dist/nl/__test__/context-aware-prompt.test.js +0 -247
  36. package/dist/nl/__test__/context-aware-prompt.test.js.map +0 -1
  37. package/dist/nl/__test__/context-selector.test.d.ts +0 -1
  38. package/dist/nl/__test__/context-selector.test.js +0 -20
  39. package/dist/nl/__test__/context-selector.test.js.map +0 -1
  40. package/dist/nl/__test__/nl-parser-groq-transport.test.d.ts +0 -1
  41. package/dist/nl/__test__/nl-parser-groq-transport.test.js +0 -87
  42. package/dist/nl/__test__/nl-parser-groq-transport.test.js.map +0 -1
  43. package/dist/nl/__test__/nl-parser-openai-parity.test.d.ts +0 -1
  44. package/dist/nl/__test__/nl-parser-openai-parity.test.js +0 -206
  45. package/dist/nl/__test__/nl-parser-openai-parity.test.js.map +0 -1
  46. package/dist/nl/__test__/nl-parser-openai-sampling.test.d.ts +0 -1
  47. package/dist/nl/__test__/nl-parser-openai-sampling.test.js +0 -44
  48. package/dist/nl/__test__/nl-parser-openai-sampling.test.js.map +0 -1
  49. package/dist/nl/__test__/nl-parser-openai-transport.test.d.ts +0 -1
  50. package/dist/nl/__test__/nl-parser-openai-transport.test.js +0 -55
  51. package/dist/nl/__test__/nl-parser-openai-transport.test.js.map +0 -1
  52. package/dist/nl/__test__/nl-parser-utils.test.d.ts +0 -1
  53. package/dist/nl/__test__/nl-parser-utils.test.js +0 -70
  54. package/dist/nl/__test__/nl-parser-utils.test.js.map +0 -1
  55. package/dist/nl/__test__/nl-parser.test.d.ts +0 -1
  56. package/dist/nl/__test__/nl-parser.test.js +0 -64
  57. package/dist/nl/__test__/nl-parser.test.js.map +0 -1
  58. package/dist/nl/__test__/parameter-tuning.test.d.ts +0 -1
  59. package/dist/nl/__test__/parameter-tuning.test.js +0 -95
  60. package/dist/nl/__test__/parameter-tuning.test.js.map +0 -1
  61. package/dist/nl/__test__/semantic-parsing-experiment.test.d.ts +0 -1
  62. package/dist/nl/__test__/semantic-parsing-experiment.test.js +0 -178
  63. package/dist/nl/__test__/semantic-parsing-experiment.test.js.map +0 -1
  64. package/dist/nl/llm-monitoring.test.d.ts +0 -5
  65. package/dist/nl/llm-monitoring.test.js +0 -101
  66. package/dist/nl/llm-monitoring.test.js.map +0 -1
  67. package/lib/__test__/dsl-descriptor.test.ts +0 -27
  68. package/lib/__test__/example_descriptor.ts +0 -762
  69. package/lib/__test__/food_descriptor.state.json +0 -1
  70. package/lib/__test__/food_descriptor.test.ts +0 -331
  71. package/lib/__test__/nl-interpreter-provider-selection.test.ts +0 -126
  72. package/lib/__test__/nl-interpreter.test.ts +0 -129
  73. package/lib/decorators/__test__/decorators.test.ts +0 -177
  74. package/lib/decorators/__test__/inheritance-descriptor.test.ts +0 -92
  75. package/lib/decorators/decorators.ts +0 -754
  76. package/lib/decorators/index.ts +0 -2
  77. package/lib/decorators/store.ts +0 -47
  78. package/lib/dsl/__test__/dsl-interpreter.test.ts +0 -453
  79. package/lib/dsl/__test__/parser.gen.test.ts +0 -296
  80. package/lib/dsl/dsl-interpreter.ts +0 -974
  81. package/lib/dsl/index.ts +0 -1
  82. package/lib/dsl/parser.gen.js +0 -1479
  83. package/lib/dsl/parser.pegjs +0 -130
  84. package/lib/dsl-descriptor.ts +0 -241
  85. package/lib/index.ts +0 -5
  86. package/lib/nl/__test__/context-aware-prompt.test.ts +0 -372
  87. package/lib/nl/__test__/context-selector.test.ts +0 -27
  88. package/lib/nl/__test__/nl-parser-groq-transport.test.ts +0 -139
  89. package/lib/nl/__test__/nl-parser-openai-parity.test.ts +0 -381
  90. package/lib/nl/__test__/nl-parser-openai-sampling.test.ts +0 -73
  91. package/lib/nl/__test__/nl-parser-openai-transport.test.ts +0 -79
  92. package/lib/nl/__test__/nl-parser-utils.test.ts +0 -98
  93. package/lib/nl/__test__/nl-parser.test.ts +0 -119
  94. package/lib/nl/__test__/parameter-tuning.test.ts +0 -137
  95. package/lib/nl/__test__/semantic-parsing-experiment.test.ts +0 -260
  96. package/lib/nl/context-selector.ts +0 -123
  97. package/lib/nl/index.ts +0 -19
  98. package/lib/nl/llm-monitoring.test.ts +0 -136
  99. package/lib/nl/llm-monitoring.ts +0 -339
  100. package/lib/nl/nl-parser-groq.ts +0 -510
  101. package/lib/nl/nl-parser-utils.ts +0 -310
  102. package/lib/nl/nl-parser.ts +0 -616
  103. package/lib/nl/prompt-gen.ts +0 -607
  104. package/lib/nl/prompt-res.ts +0 -207
  105. package/lib/nl-interpreter.ts +0 -262
@@ -1,2 +0,0 @@
1
- export * from "./decorators";
2
- export * from "./store";
@@ -1,47 +0,0 @@
1
- import { Store } from "redux";
2
-
3
- let genieActionFunc: () => any = null;
4
- let genieActionReturnVal: any = null;
5
-
6
- export let sharedStore: Store = null;
7
- export let sharedState: {} = null;
8
-
9
- export let objects: {} = {};
10
-
11
- export let originalClasses: {} = {};
12
-
13
- export function setSharedStore(store: Store) {
14
- sharedStore = store;
15
- }
16
-
17
- export function setSharedState(state: {}) {
18
- sharedState = state;
19
- }
20
-
21
- export function storeReducer(
22
- state: {} = {"CLASS": {}, "OBJECT": {}},
23
- action: { type: string; payload: any }
24
- ) {
25
- if (action.type === "genieAction") {
26
- sharedState = {
27
- ...state,
28
- };
29
- genieActionReturnVal = genieActionFunc();
30
- return {
31
- ...sharedState,
32
- };
33
- }
34
- return state;
35
- }
36
-
37
- export function genieDispatch(func: () => any) {
38
- if (genieActionFunc != null) {
39
- // already in a genieDispatch
40
- return func();
41
- } else {
42
- genieActionFunc = func;
43
- sharedStore.dispatch({ type: "genieAction", payload: {} });
44
- genieActionFunc = null;
45
- return genieActionReturnVal;
46
- }
47
- }
@@ -1,453 +0,0 @@
1
- import { DslInterpreter } from "../dsl-interpreter";
2
- import { allDescriptors, recentBooking, Restaurant } from "../../__test__/example_descriptor";
3
- import { initGenie } from "../../decorators";
4
-
5
- initGenie();
6
-
7
- test("Basic function call", async () => {
8
- const interpreter = new DslInterpreter(allDescriptors);
9
- const funcCallResult = await interpreter.interpret(
10
- "Restaurant.current().book(dateTime: DateTime(year: 2020, month: 1, day: 1, hour: 12, minute: 0))"
11
- );
12
- expect(recentBooking).toEqual("McDonald's is booking for 2020-1-1 12:0");
13
- expect(funcCallResult).toEqual({
14
- objectType: "void",
15
- type: "object",
16
- value: undefined
17
- });
18
- });
19
-
20
- test("Indexing", async () => {
21
- const interpreter = new DslInterpreter(allDescriptors);
22
- const funcCallResult = await interpreter.interpret("Restaurant.all()[1].name");
23
- expect(funcCallResult).toEqual({
24
- objectType: "string",
25
- type: "object",
26
- value: "KFC"
27
- });
28
- });
29
-
30
- test("Array", async () => {
31
- const interpreter = new DslInterpreter(allDescriptors);
32
- const funcCallResult = await interpreter.interpret(
33
- "[Restaurant.all()[1].name, Restaurant.current().name]"
34
- );
35
- expect(funcCallResult).toEqual({
36
- type: "array",
37
- value: [
38
- {
39
- objectType: "string",
40
- type: "object",
41
- value: "KFC"
42
- },
43
- {
44
- objectType: "string",
45
- type: "object",
46
- value: "McDonald's"
47
- }
48
- ]
49
- });
50
- });
51
-
52
- test("Array matching", async () => {
53
- const interpreter = new DslInterpreter(allDescriptors);
54
- const funcCallResult = await interpreter.interpret(
55
- "Restaurant.current().menu.matching(field: .name, value: \"hamburger\")[0].name"
56
- );
57
- expect(funcCallResult).toEqual({
58
- objectType: "string",
59
- type: "object",
60
- value: "Hamburger"
61
- });
62
- });
63
-
64
- test("Array matching rejects quoted field parameter with a helpful error", async () => {
65
- const interpreter = new DslInterpreter(allDescriptors);
66
- await expect(
67
- interpreter.interpret(
68
- "Restaurant.all().matching(field: \"name\", value: \"Taste\")"
69
- )
70
- ).rejects.toThrow(
71
- 'Invalid DSL: matching(field: ...) requires a dotted accessor such as .name, but received string.'
72
- );
73
- });
74
-
75
- test("Array matching does not crash on string field vs numeric value", async () => {
76
- const interpreter = new DslInterpreter(allDescriptors);
77
- const funcCallResult = await interpreter.interpret(
78
- "Order.all().matching(field: .dateTime.dayOfWeek, value: DateTime.today().month)"
79
- );
80
- expect(funcCallResult).toEqual({
81
- type: "array",
82
- value: []
83
- });
84
- });
85
-
86
- test("Array contains does not crash on string field vs numeric value", async () => {
87
- const interpreter = new DslInterpreter(allDescriptors);
88
- const funcCallResult = await interpreter.interpret(
89
- "Order.all().contains(field: .dateTime.dayOfWeek, value: DateTime.today().month)"
90
- );
91
- expect(funcCallResult).toEqual({
92
- type: "array",
93
- value: []
94
- });
95
- });
96
-
97
- test("Array between does not crash when comparator is unavailable", async () => {
98
- const interpreter = new DslInterpreter(allDescriptors);
99
- const funcCallResult = await interpreter.interpret(
100
- "Order.all().between(field: .restaurant, from: 1, to: 2)"
101
- );
102
- expect(funcCallResult).toEqual({
103
- type: "array",
104
- value: []
105
- });
106
- });
107
-
108
- test("Array between", async () => {
109
- const interpreter = new DslInterpreter(allDescriptors);
110
- const funcCallResult = await interpreter.interpret(
111
- "Order.all().between(field: .dateTime, from: DateTime.today().addDateOffset(day: -7), to: DateTime.today())[0].restaurant.name"
112
- );
113
- expect(funcCallResult).toEqual({
114
- objectType: "string",
115
- type: "object",
116
- value: "McDonald's"
117
- });
118
- });
119
-
120
- test("Array between one side", async () => {
121
- const interpreter = new DslInterpreter(allDescriptors);
122
- const funcCallResult = await interpreter.interpret(
123
- "Order.all().between(field: .dateTime, from: DateTime.today().addDateOffset(day: -7))[-1].restaurant.name"
124
- );
125
- expect(funcCallResult).toEqual({
126
- objectType: "string",
127
- type: "object",
128
- value: "McDonald's"
129
- });
130
- });
131
-
132
- test("Array between one side deep accessor", async () => {
133
- const interpreter = new DslInterpreter(allDescriptors);
134
- const funcCallResult = await interpreter.interpret(
135
- "Order.all().between(field: .dateTime.day, from: 2, to: 3)[-1].dateTime.day"
136
- );
137
- expect(funcCallResult).toEqual({
138
- "objectType": "int",
139
- "type": "object",
140
- "value": 3
141
- });
142
- });
143
-
144
- test("Array equals", async () => {
145
- const interpreter = new DslInterpreter(allDescriptors);
146
- const funcCallResult = await interpreter.interpret(
147
- "Restaurant.all().equals(field: .priceGrade, value: 1)[0].name"
148
- );
149
- expect(funcCallResult).toEqual({
150
- objectType: "string",
151
- type: "object",
152
- value: "KFC"
153
- });
154
- });
155
-
156
- test("Array sort", async () => {
157
- const interpreter = new DslInterpreter(allDescriptors);
158
- const funcCallResult = await interpreter.interpret(
159
- "Restaurant.all().sort(field: .priceGrade, ascending: false)[0].name"
160
- );
161
- expect(funcCallResult).toEqual({
162
- objectType: "string",
163
- type: "object",
164
- value: "Taste"
165
- });
166
- });
167
-
168
- test("Array in array", async () => {
169
- const interpreter = new DslInterpreter(allDescriptors);
170
- const funcCallResult = await interpreter.interpret(
171
- "Restaurant.all().menu.matching(field:.name, value:\"Hamburger\")[0][0].name"
172
- );
173
- expect(funcCallResult).toEqual({
174
- objectType: "string",
175
- type: "object",
176
- value: "Hamburger"
177
- });
178
- });
179
-
180
- test("length", async () => {
181
- const interpreter = new DslInterpreter(allDescriptors);
182
- const funcCallResult = await interpreter.interpret(
183
- "Restaurant.all()[0].menu.matching(field:.name, value:\"Hamburger\").length()"
184
- );
185
- expect(funcCallResult).toEqual({
186
- "objectType": "int",
187
- "type": "object",
188
- "value": 1
189
- });
190
- });
191
-
192
- // test("index in Array.Array", async () => {
193
- // const interpreter = new DslInterpreter(allDescriptors);
194
- // const funcCallResult = await interpreter.interpret(
195
- // "Restaurant.all().menu.matching(field:.name, value:\"Hamburger\")[0]"
196
- // );
197
- // expect(funcCallResult).toEqual({
198
- // objectType: "string",
199
- // type: "object",
200
- // value: "Taste",
201
- // });
202
- // });
203
-
204
- test("find burger name", async () => {
205
- const interpreter = new DslInterpreter(allDescriptors);
206
- const funcCallResult = await interpreter.interpret(
207
- "Restaurant.current().menu.matching(field: .name, value: \"hamburger\")[0].name"
208
- );
209
- expect(funcCallResult).toEqual({
210
- objectType: "string",
211
- type: "object",
212
- value: "Hamburger"
213
- });
214
- });
215
-
216
- test("find burger price", async () => {
217
- const interpreter = new DslInterpreter(allDescriptors);
218
- const funcCallResult = await interpreter.interpret(
219
- "Restaurant.current().menu.matching(field: .name, value: \"hamburger\")[0].price"
220
- );
221
- expect(funcCallResult).toEqual({
222
- objectType: "float",
223
- type: "object",
224
- value: 5
225
- });
226
- });
227
-
228
- test("best restaurant", async () => {
229
- const interpreter = new DslInterpreter(allDescriptors);
230
- const funcCallResult = await interpreter.interpret(
231
- "Restaurant.all().matching(field: .address, value: \"palo alto\").sort(field: .rating, ascending: false)[0]"
232
- );
233
- expect(await interpreter.describe(funcCallResult)).toEqual({
234
- type: "object",
235
- value: {
236
- address: "123 Main St, Palo Alto, USA",
237
- cuisine: "Chinese",
238
- name: "Taste",
239
- priceGrade: 3,
240
- rating: 5
241
- }
242
- });
243
- });
244
-
245
- test("find cheap chinese restaurant", async () => {
246
- const interpreter = new DslInterpreter(allDescriptors);
247
- const funcCallResult = await interpreter.interpret(
248
- "Restaurant.all().matching(field: .cuisine, value: \"chinese\").sort(field: .priceGrade, ascending: true)[0]"
249
- );
250
- expect(await interpreter.describe(funcCallResult)).toEqual({
251
- type: "object",
252
- value: {
253
- address: "123 Main St, Palo Alto, USA",
254
- cuisine: "Chinese",
255
- name: "Steam",
256
- priceGrade: 2,
257
- rating: 4
258
- }
259
- });
260
- });
261
-
262
- test("add hamburger to the order", async () => {
263
- const interpreter = new DslInterpreter(allDescriptors);
264
- const funcCallResult = await interpreter.interpret(
265
- "Order.current().addFoods(foods: [Restaurant.current().menu.matching(field: .name, value: \"hamburger\")[0]])"
266
- );
267
- expect(await interpreter.describe(funcCallResult)).toEqual({
268
- type: "object",
269
- value: "undefined"
270
- });
271
- });
272
-
273
- test("add hamburger to the order (steps)", async () => {
274
- const interpreter = new DslInterpreter(allDescriptors);
275
- const funcCallResult: any[] = await interpreter.interpretSteps(
276
- "Restaurant.all().equals(field: .priceGrade, value: 1)[0].name"
277
- );
278
- const describeSteps =(await interpreter.describeSteps(
279
- funcCallResult[funcCallResult.length - 1].steps
280
- )).reverse()
281
- expect((describeSteps[1])).toEqual({
282
- type: "object",
283
- value: {
284
- address: "123 Main St, Palo Alto, USA",
285
- cuisine: "Fast Food",
286
- name: "KFC",
287
- priceGrade: 1,
288
- rating: 3
289
- }
290
- });
291
- });
292
-
293
- test("DateTime object comparison", async () => {
294
- Restaurant.all();
295
- const interpreter = new DslInterpreter(allDescriptors);
296
- // order yestersday
297
- const funcCallResult = await interpreter.interpret(
298
- "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"
299
- );
300
- expect(funcCallResult).toEqual({
301
- objectType: "string",
302
- type: "object",
303
- value: "McDonald's"
304
- });
305
- });
306
-
307
- test("Order containing burger", async () => {
308
- Restaurant.all();
309
- const interpreter = new DslInterpreter(allDescriptors);
310
- // const funcCallResult = await interpreter.interpret(
311
- // 'Order.all().containing(field: .foods, value: Restaurant.current().menu.matching(field: .name, value: "hamburger")[0])[0].restaurant.name'
312
- // )
313
- const funcCallResult = await interpreter.interpret(
314
- "Order.all().contains(field: .foods, value: Restaurant.current().menu.matching(field: .name, value: \"hamburger\")[0])[0].restaurant.name"
315
- );
316
- expect(funcCallResult).toEqual({
317
- objectType: "string",
318
- type: "object",
319
- value: "McDonald's"
320
- });
321
- });
322
-
323
- test("Order array distribution field", async () => {
324
- Restaurant.all();
325
- const interpreter = new DslInterpreter(allDescriptors);
326
- const funcCallResult = await interpreter.interpret(
327
- "Order.all().dateTime[0].dayOfWeek"
328
- );
329
- expect(funcCallResult).toEqual({
330
- "objectType": "string",
331
- "type": "object",
332
- "value": "Wednesday"
333
- });
334
- });
335
-
336
- test("Order array distribution function", async () => {
337
- Restaurant.all();
338
- const interpreter = new DslInterpreter(allDescriptors);
339
- const funcCallResult = await interpreter.interpret(
340
- "Order.all().placeOrder()"
341
- );
342
- expect(funcCallResult["objectType"]).toEqual("void");
343
- });
344
-
345
- test("Multiple actions", async () => {
346
- Restaurant.all();
347
- const interpreter = new DslInterpreter(allDescriptors);
348
- const funcCallResult = await interpreter.interpret(
349
- "Order.all().placeOrder(); Order.all().dateTime[0].dayOfWeek"
350
- );
351
- expect(funcCallResult["objectType"]).toEqual("string");
352
- });
353
-
354
- test("Single actions with semicolon", async () => {
355
- Restaurant.all();
356
- const interpreter = new DslInterpreter(allDescriptors);
357
- const funcCallResult = await interpreter.interpret(
358
- "Order.all().dateTime[0].dayOfWeek;"
359
- );
360
- expect(funcCallResult["objectType"]).toEqual("string");
361
- });
362
-
363
-
364
- test("[dry run] Order containing burger", async () => {
365
- Restaurant.all();
366
- const interpreter = new DslInterpreter(allDescriptors, true);
367
- const funcCallResult = await interpreter.interpret(
368
- "Order.all().contains(field: .foods, value: Restaurant.current().menu.matching(field: .name, value: \"hamburger\")[0])[0].restaurant.name"
369
- );
370
- expect(funcCallResult).toEqual({
371
- objectType: "string",
372
- type: "object",
373
- value: null
374
- });
375
- });
376
-
377
- test("[dry run][error] Restaurant noise level", async () => {
378
- Restaurant.all();
379
- const interpreter = new DslInterpreter(allDescriptors, true);
380
- try {
381
- await interpreter.interpret(
382
- "Restaurant.All().matching(field: .noiseLevel, value: \"quiet\")"
383
- );
384
- } catch (e) {
385
- expect(e.message).toEqual("Field Restaurant.noiseLevel is missing");
386
- }
387
- });
388
-
389
- test("[dry run][error] Restaurant noise level 2", async () => {
390
- Restaurant.all();
391
- const interpreter = new DslInterpreter(allDescriptors, true);
392
- try {
393
- await interpreter.interpret(
394
- "Restaurant.All()[0].noiseLevel"
395
- );
396
- } catch (e) {
397
- expect(e.message).toEqual("Field Restaurant.noiseLevel is missing");
398
- }
399
- });
400
-
401
- test("[dry run][error] Restaurant notify when near", async () => {
402
- Restaurant.all();
403
- const interpreter = new DslInterpreter(allDescriptors, true);
404
- try {
405
- await interpreter.interpret(
406
- "Order.current().notifyWhenNearLocation()"
407
- );
408
- } catch (e) {
409
- expect(e.message).toEqual("Function Order.notifyWhenNearLocation is missing");
410
- }
411
- });
412
-
413
- test("[dry run][error] Login", async () => {
414
- Restaurant.all();
415
- const interpreter = new DslInterpreter(allDescriptors, true);
416
- try {
417
- await interpreter.interpret(
418
- "User.login()"
419
- );
420
- } catch (e) {
421
- expect(e.message).toEqual("Class User is missing");
422
- }
423
- });
424
-
425
-
426
- test("[dry run][error] String", async () => {
427
- Restaurant.all();
428
- const interpreter = new DslInterpreter(allDescriptors, true);
429
- try {
430
- await interpreter.interpret(
431
- "Restaurant.All().matching(field: .location, value: \"near me\")"
432
- );
433
- } catch (e) {
434
- console.log(e);
435
- expect(e.message).toEqual("Field Restaurant.location is missing");
436
- }
437
- });
438
-
439
- test("GetObject", async () => {
440
- Restaurant.all();
441
- const interpreter = new DslInterpreter(allDescriptors, true);
442
- try {
443
- await interpreter.interpret(
444
- "Restaurant.GetObject(id:0)"
445
- );
446
- } catch (e) {
447
- console.log(e);
448
- expect(e.message).toEqual("Function Restaurant.GetObject is missing");
449
- }
450
- });
451
-
452
-
453
-