@labdigital/commercetools-mock 2.45.1 → 2.47.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 (80) hide show
  1. package/dist/index.cjs +614 -250
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +788 -59
  4. package/dist/index.d.ts +788 -59
  5. package/dist/index.js +602 -238
  6. package/dist/index.js.map +1 -1
  7. package/package.json +41 -48
  8. package/src/ctMock.ts +11 -13
  9. package/src/index.test.ts +5 -5
  10. package/src/lib/predicateParser.test.ts +91 -60
  11. package/src/lib/predicateParser.ts +38 -42
  12. package/src/lib/productSearchFilter.test.ts +18 -0
  13. package/src/lib/productSearchFilter.ts +7 -0
  14. package/src/lib/projectionSearchFilter.test.ts +17 -17
  15. package/src/lib/projectionSearchFilter.ts +2 -3
  16. package/src/oauth/server.test.ts +1 -1
  17. package/src/oauth/server.ts +11 -11
  18. package/src/priceSelector.ts +1 -1
  19. package/src/product-projection-search.ts +18 -19
  20. package/src/product-search.ts +48 -8
  21. package/src/repositories/business-unit.ts +17 -16
  22. package/src/repositories/cart/actions.ts +32 -32
  23. package/src/repositories/cart/helpers.ts +1 -1
  24. package/src/repositories/cart/index.ts +25 -8
  25. package/src/repositories/cart-discount/actions.ts +1 -4
  26. package/src/repositories/category/actions.ts +2 -6
  27. package/src/repositories/custom-object.ts +20 -21
  28. package/src/repositories/customer/actions.ts +4 -4
  29. package/src/repositories/errors.ts +1 -1
  30. package/src/repositories/extension.ts +2 -1
  31. package/src/repositories/helpers.ts +27 -27
  32. package/src/repositories/index.ts +17 -17
  33. package/src/repositories/my-customer.ts +1 -1
  34. package/src/repositories/my-order.ts +2 -2
  35. package/src/repositories/order/index.ts +1 -1
  36. package/src/repositories/product/actions.ts +1 -1
  37. package/src/repositories/quote/actions.ts +83 -0
  38. package/src/repositories/quote/index.ts +54 -0
  39. package/src/repositories/quote-request/actions.ts +84 -0
  40. package/src/repositories/quote-request/index.test.ts +167 -0
  41. package/src/repositories/quote-request/index.ts +67 -0
  42. package/src/repositories/quote-staged/actions.ts +84 -0
  43. package/src/repositories/quote-staged/index.ts +47 -0
  44. package/src/repositories/review.ts +4 -4
  45. package/src/repositories/shipping-method/actions.ts +17 -17
  46. package/src/repositories/shipping-method/index.ts +6 -6
  47. package/src/repositories/shopping-list/actions.ts +1 -1
  48. package/src/repositories/shopping-list/index.ts +9 -1
  49. package/src/repositories/subscription.ts +2 -4
  50. package/src/server.ts +3 -2
  51. package/src/services/abstract.ts +7 -7
  52. package/src/services/as-associate-order.test.ts +1 -1
  53. package/src/services/cart-discount.test.ts +1 -1
  54. package/src/services/cart.test.ts +40 -15
  55. package/src/services/category.test.ts +1 -1
  56. package/src/services/customer.test.ts +16 -55
  57. package/src/services/customer.ts +1 -1
  58. package/src/services/index.ts +20 -14
  59. package/src/services/inventory-entry.test.ts +5 -5
  60. package/src/services/my-cart.test.ts +2 -2
  61. package/src/services/my-customer.test.ts +2 -2
  62. package/src/services/order.test.ts +8 -8
  63. package/src/services/product-projection.test.ts +5 -5
  64. package/src/services/product-projection.ts +12 -14
  65. package/src/services/product.test.ts +155 -71
  66. package/src/services/quote-request.test.ts +59 -0
  67. package/src/services/quote-request.ts +16 -0
  68. package/src/services/quote-staged.ts +16 -0
  69. package/src/services/quote.ts +16 -0
  70. package/src/services/standalone-price.test.ts +4 -4
  71. package/src/services/state.test.ts +1 -1
  72. package/src/services/store.test.ts +2 -2
  73. package/src/services/tax-category.test.ts +1 -1
  74. package/src/shipping.ts +3 -3
  75. package/src/storage/in-memory.ts +55 -63
  76. package/src/testing/customer.ts +40 -0
  77. package/src/types.ts +51 -31
  78. package/src/repositories/quote-request.ts +0 -17
  79. package/src/repositories/quote.ts +0 -14
  80. package/src/repositories/staged-quote.ts +0 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labdigital/commercetools-mock",
3
- "version": "2.45.1",
3
+ "version": "2.47.0",
4
4
  "license": "MIT",
5
5
  "author": "Michael van Tellingen",
6
6
  "type": "module",
@@ -19,54 +19,46 @@
19
19
  "src"
20
20
  ],
21
21
  "dependencies": {
22
- "basic-auth": "^2.0.1",
23
- "body-parser": "^1.20.2",
22
+ "@biomejs/biome": "^1.9.4",
23
+ "basic-auth": "2.0.1",
24
+ "body-parser": "1.20.2",
24
25
  "decimal.js": "10.4.3",
25
- "deep-equal": "^2.2.3",
26
- "express": "^4.21.1",
27
- "light-my-request": "^5.11.1",
28
- "lodash.isequal": "^4.5.0",
29
- "morgan": "^1.10.0",
30
- "msw": "^2.5.0",
31
- "uuid": "^9.0.1",
32
- "zod": "^3.22.4",
33
- "zod-validation-error": "^3.0.2"
26
+ "deep-equal": "2.2.3",
27
+ "express": "4.21.1",
28
+ "light-my-request": "5.11.1",
29
+ "lodash.isequal": "4.5.0",
30
+ "morgan": "1.10.0",
31
+ "msw": "2.5.0",
32
+ "uuid": "9.0.1",
33
+ "zod": "3.22.4",
34
+ "zod-validation-error": "3.0.2"
34
35
  },
35
36
  "devDependencies": {
36
- "@changesets/changelog-github": "^0.5.0",
37
- "@changesets/cli": "^2.27.1",
38
- "@commercetools/platform-sdk": "7.17.0",
39
- "@stylistic/eslint-plugin": "^1.6.2",
40
- "@types/basic-auth": "^1.1.8",
41
- "@types/body-parser": "^1.19.5",
42
- "@types/deep-equal": "^1.0.4",
43
- "@types/express": "^4.17.21",
44
- "@types/express-serve-static-core": "^4.17.43",
45
- "@types/lodash.isequal": "^4.5.8",
46
- "@types/morgan": "^1.9.9",
47
- "@types/node": "^20.16.14",
48
- "@types/qs": "^6.9.11",
49
- "@types/supertest": "^6.0.2",
50
- "@types/uuid": "^9.0.8",
51
- "@typescript-eslint/eslint-plugin": "^7.0.2",
52
- "@typescript-eslint/parser": "^7.0.2",
37
+ "@changesets/changelog-github": "0.5.0",
38
+ "@changesets/cli": "2.27.1",
39
+ "@commercetools/platform-sdk": "8.8.0",
40
+ "@types/basic-auth": "1.1.8",
41
+ "@types/body-parser": "1.19.5",
42
+ "@types/deep-equal": "1.0.4",
43
+ "@types/express": "4.17.21",
44
+ "@types/express-serve-static-core": "4.17.43",
45
+ "@types/lodash.isequal": "4.5.8",
46
+ "@types/morgan": "1.9.9",
47
+ "@types/node": "20.16.14",
48
+ "@types/qs": "6.9.11",
49
+ "@types/supertest": "6.0.2",
50
+ "@types/uuid": "9.0.8",
53
51
  "@vitest/coverage-v8": "3.0.2",
54
- "esbuild": "^0.20.1",
55
- "eslint": "^8.57.1",
56
- "eslint-plugin-sort-class-members": "^1.21.0",
57
- "eslint-plugin-unused-imports": "^3.1.0",
58
- "fishery": "^2.2.2",
59
- "got": "^14.2.0",
60
- "husky": "^9.0.11",
61
- "prettier": "^3.2.5",
62
- "prettier-plugin-organize-imports": "^3.2.4",
63
- "prettier-plugin-packagejson": "^2.5.3",
64
- "supertest": "^6.3.4",
65
- "timekeeper": "^2.3.1",
66
- "ts-node": "^10.9.2",
67
- "tslib": "^2.8.0",
68
- "tsup": "^8.0.2",
69
- "typescript": "^5.6.3",
52
+ "esbuild": "0.20.1",
53
+ "fishery": "2.2.2",
54
+ "got": "14.2.0",
55
+ "husky": "9.0.11",
56
+ "supertest": "6.3.4",
57
+ "timekeeper": "2.3.1",
58
+ "ts-node": "10.9.2",
59
+ "tslib": "2.8.0",
60
+ "tsup": "8.0.2",
61
+ "typescript": "5.8.3",
70
62
  "vitest": "3.0.2"
71
63
  },
72
64
  "engines": {
@@ -79,10 +71,11 @@
79
71
  "scripts": {
80
72
  "build": "tsup",
81
73
  "build:server": "esbuild src/server.ts --bundle --outfile=dist/server.js --platform=node",
82
- "check": "pnpm lint && tsc",
83
- "format": "eslint src --fix ; prettier --write .",
84
- "lint": "eslint src && prettier --check .",
74
+ "check": "biome check && tsc",
75
+ "format": "biome format --fix",
76
+ "lint": "biome check",
85
77
  "publish:ci": "pnpm build && pnpm changeset publish",
78
+ "publish:version": "pnpm changeset version && pnpm format",
86
79
  "start": "tsup src/server.ts --watch --onSuccess 'node dist/server'",
87
80
  "test": "vitest run",
88
81
  "test:ci": "vitest run --coverage"
package/src/ctMock.ts CHANGED
@@ -182,12 +182,11 @@ export class CommercetoolsMock {
182
182
  message: err.message,
183
183
  errors: [err.info],
184
184
  });
185
- } else {
186
- console.error(err);
187
- return resp.status(500).send({
188
- error: err.message,
189
- });
190
185
  }
186
+ console.error(err);
187
+ return resp.status(500).send({
188
+ error: err.message,
189
+ });
191
190
  });
192
191
 
193
192
  return app;
@@ -210,7 +209,7 @@ export class CommercetoolsMock {
210
209
  const headers = copyHeaders(request.headers);
211
210
 
212
211
  const res = await inject(app)
213
- .post(url.pathname + "?" + url.searchParams.toString())
212
+ .post(`${url.pathname}?${url.searchParams.toString()}`)
214
213
  .body(body)
215
214
  .headers(headers)
216
215
  .end();
@@ -225,7 +224,7 @@ export class CommercetoolsMock {
225
224
  const headers = copyHeaders(request.headers);
226
225
 
227
226
  const res = await inject(app)
228
- .get(url.pathname + "?" + url.searchParams.toString())
227
+ .get(`${url.pathname}?${url.searchParams.toString()}`)
229
228
  .body(body)
230
229
  .headers(headers)
231
230
  .end();
@@ -256,7 +255,7 @@ export class CommercetoolsMock {
256
255
  const headers = copyHeaders(request.headers);
257
256
 
258
257
  const res = await inject(app)
259
- .get(url.pathname + "?" + url.searchParams.toString())
258
+ .get(`${url.pathname}?${url.searchParams.toString()}`)
260
259
  .body(body)
261
260
  .headers(headers)
262
261
  .end();
@@ -271,7 +270,7 @@ export class CommercetoolsMock {
271
270
  const headers = copyHeaders(request.headers);
272
271
 
273
272
  const res = await inject(app)
274
- .post(url.pathname + "?" + url.searchParams.toString())
273
+ .post(`${url.pathname}?${url.searchParams.toString()}`)
275
274
  .body(body)
276
275
  .headers(headers)
277
276
  .end();
@@ -286,7 +285,7 @@ export class CommercetoolsMock {
286
285
  const headers = copyHeaders(request.headers);
287
286
 
288
287
  const res = await inject(app)
289
- .delete(url.pathname + "?" + url.searchParams.toString())
288
+ .delete(`${url.pathname}?${url.searchParams.toString()}`)
290
289
  .body(body)
291
290
  .headers(headers)
292
291
  .end();
@@ -307,10 +306,9 @@ export class CommercetoolsMock {
307
306
  if (_globalListeners.length > 0) {
308
307
  if (this._mswServer !== undefined) {
309
308
  throw new Error("Server already started");
310
- } else {
311
- process.emitWarning("Server wasn't stopped properly, clearing");
312
- _globalListeners.forEach((listener) => listener.close());
313
309
  }
310
+ process.emitWarning("Server wasn't stopped properly, clearing");
311
+ _globalListeners.forEach((listener) => listener.close());
314
312
  }
315
313
 
316
314
  const server = setupServer();
package/src/index.test.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type InvalidTokenError } from "@commercetools/platform-sdk";
1
+ import type { InvalidTokenError } from "@commercetools/platform-sdk";
2
2
  import got from "got";
3
3
  import { setupServer } from "msw/node";
4
4
  import { afterEach, beforeAll, expect, test } from "vitest";
@@ -23,12 +23,12 @@ test("node:fetch client", async () => {
23
23
  });
24
24
  ctMock.registerHandlers(mswServer);
25
25
 
26
- const authHeader = "Basic " + Buffer.from("foo:bar").toString("base64");
26
+ const authHeader = `Basic ${Buffer.from("foo:bar").toString("base64")}`;
27
27
  let response = await fetch("https://localhost:8080/oauth/token", {
28
28
  method: "POST",
29
29
  headers: {
30
30
  "Content-Type": "application/x-www-form-urlencoded",
31
- "Authorization": authHeader,
31
+ Authorization: authHeader,
32
32
  },
33
33
  body: new URLSearchParams({
34
34
  grant_type: "client_credentials",
@@ -109,7 +109,7 @@ test("Options.validateCredentials: true (error)", async () => {
109
109
  "https://api.europe-west1.gcp.commercetools.com/my-project/orders",
110
110
  {
111
111
  headers: {
112
- Authorization: `Bearer foobar`,
112
+ Authorization: "Bearer foobar",
113
113
  },
114
114
  responseType: "json",
115
115
  throwHttpErrors: false,
@@ -130,7 +130,7 @@ test("Options.validateCredentials: false", async () => {
130
130
  "https://api.europe-west1.gcp.commercetools.com/my-project/orders",
131
131
  {
132
132
  headers: {
133
- Authorization: `Bearer foobar`,
133
+ Authorization: "Bearer foobar",
134
134
  },
135
135
  responseType: "json",
136
136
  },
@@ -15,6 +15,10 @@ describe("Predicate filter", () => {
15
15
  objectProperty: {
16
16
  stringProperty: "foobar",
17
17
  booleanProperty: true,
18
+ "45c652f2-76e8-48fd-ab64-d11ad99d6631": {
19
+ stringProperty: "foobar",
20
+ uuidProperty: "3a57cc78-db08-4cd3-b778-d59b3326c435",
21
+ },
18
22
  },
19
23
  array: [
20
24
  {
@@ -91,60 +95,60 @@ describe("Predicate filter", () => {
91
95
  expect(match(`stringProperty="foobar"`)).toBeTruthy();
92
96
  expect(match(`stringProperty!="foobar"`)).toBeFalsy();
93
97
 
94
- expect(match(`stringProperty=:val`, { val: "foobar" })).toBeTruthy();
98
+ expect(match("stringProperty=:val", { val: "foobar" })).toBeTruthy();
95
99
  });
96
100
 
97
101
  test("booleanProperty = true", async () => {
98
- expect(match(`booleanProperty != true`)).toBeFalsy();
99
- expect(match(`booleanProperty = true`)).toBeTruthy();
102
+ expect(match("booleanProperty != true")).toBeFalsy();
103
+ expect(match("booleanProperty = true")).toBeTruthy();
100
104
 
101
- expect(match(`booleanProperty=:val`, { val: true })).toBeTruthy();
105
+ expect(match("booleanProperty=:val", { val: true })).toBeTruthy();
102
106
  });
103
107
 
104
108
  test('stringProperty matches ignore case "foobar"', async () => {
105
109
  expect(match(`stringProperty="FOObar"`)).toBeFalsy();
106
110
  expect(match(`stringProperty matches ignore case "FOObar"`)).toBeTruthy();
107
111
  expect(
108
- match(`stringProperty matches ignore case :val`, { val: "fooBar" }),
112
+ match("stringProperty matches ignore case :val", { val: "fooBar" }),
109
113
  ).toBeTruthy();
110
114
  });
111
115
 
112
116
  test("numberProperty = 1234", async () => {
113
- expect(match(`numberProperty=1234`)).toBeTruthy();
114
- expect(match(`numberProperty = 1234`)).toBeTruthy();
115
- expect(match(`numberProperty=1230`)).toBeFalsy();
116
- expect(match(`numberProperty = 1230`)).toBeFalsy();
117
+ expect(match("numberProperty=1234")).toBeTruthy();
118
+ expect(match("numberProperty = 1234")).toBeTruthy();
119
+ expect(match("numberProperty=1230")).toBeFalsy();
120
+ expect(match("numberProperty = 1230")).toBeFalsy();
117
121
 
118
- expect(match(`numberProperty=:val`, { val: 1234 })).toBeTruthy();
122
+ expect(match("numberProperty=:val", { val: 1234 })).toBeTruthy();
119
123
  });
120
124
 
121
125
  test("numberProperty > ...", async () => {
122
- expect(match(`numberProperty > 1233`)).toBeTruthy();
123
- expect(match(`numberProperty > 1234`)).toBeFalsy();
126
+ expect(match("numberProperty > 1233")).toBeTruthy();
127
+ expect(match("numberProperty > 1234")).toBeFalsy();
124
128
  });
125
129
 
126
130
  test("numberProperty >= ...", async () => {
127
- expect(match(`numberProperty >= 1234`)).toBeTruthy();
128
- expect(match(`numberProperty >= 1235`)).toBeFalsy();
131
+ expect(match("numberProperty >= 1234")).toBeTruthy();
132
+ expect(match("numberProperty >= 1235")).toBeFalsy();
129
133
  });
130
134
 
131
135
  test("numberProperty < ...", async () => {
132
- expect(match(`numberProperty < 1235`)).toBeTruthy();
133
- expect(match(`numberProperty < 1234`)).toBeFalsy();
136
+ expect(match("numberProperty < 1235")).toBeTruthy();
137
+ expect(match("numberProperty < 1234")).toBeFalsy();
134
138
  });
135
139
 
136
140
  test("numberProperty <= ...", async () => {
137
- expect(match(`numberProperty <= 1235`)).toBeTruthy();
138
- expect(match(`numberProperty <= 1234`)).toBeTruthy();
139
- expect(match(`numberProperty <= 1233`)).toBeFalsy();
141
+ expect(match("numberProperty <= 1235")).toBeTruthy();
142
+ expect(match("numberProperty <= 1234")).toBeTruthy();
143
+ expect(match("numberProperty <= 1233")).toBeFalsy();
140
144
  });
141
145
 
142
146
  test("numberPropery in (...)", async () => {
143
- expect(match(`numberProperty in (1233, 1234, 1235)`)).toBeTruthy();
147
+ expect(match("numberProperty in (1233, 1234, 1235)")).toBeTruthy();
144
148
  });
145
149
 
146
150
  test("numberPropery in (...) single value", async () => {
147
- expect(match(`numberProperty in (1234)`)).toBeTruthy();
151
+ expect(match("numberProperty in (1234)")).toBeTruthy();
148
152
  });
149
153
 
150
154
  test("arrayProperty contains all (...)", async () => {
@@ -155,17 +159,17 @@ describe("Predicate filter", () => {
155
159
  });
156
160
 
157
161
  test("arrayProperty is empty", async () => {
158
- expect(match(`arrayProperty is empty`)).toBeFalsy();
159
- expect(match(`arrayProperty is not empty`)).toBeTruthy();
160
- expect(match(`emptyArrayProperty is empty`)).toBeTruthy();
162
+ expect(match("arrayProperty is empty")).toBeFalsy();
163
+ expect(match("arrayProperty is not empty")).toBeTruthy();
164
+ expect(match("emptyArrayProperty is empty")).toBeTruthy();
161
165
  });
162
166
 
163
167
  test("property is defined", async () => {
164
- expect(match(`notDefined is defined`)).toBeFalsy();
165
- expect(match(`notDefined is not defined`)).toBeTruthy();
168
+ expect(match("notDefined is defined")).toBeFalsy();
169
+ expect(match("notDefined is not defined")).toBeTruthy();
166
170
 
167
- expect(match(`arrayProperty is defined`)).toBeTruthy();
168
- expect(match(`arrayProperty is not defined`)).toBeFalsy();
171
+ expect(match("arrayProperty is defined")).toBeTruthy();
172
+ expect(match("arrayProperty is not defined")).toBeFalsy();
169
173
  });
170
174
 
171
175
  test("arrayProperty contains any (...)", async () => {
@@ -182,14 +186,14 @@ describe("Predicate filter", () => {
182
186
  expect(match(`nested(array(stringProperty="foobar"))`)).toBeFalsy();
183
187
 
184
188
  // Different comparison operators
185
- expect(match(`nested(array(numberProperty>=2345))`)).toBeTruthy();
186
- expect(match(`nested(array(numberProperty>=2346))`)).toBeFalsy();
187
- expect(match(`nested(array(numberProperty>2344))`)).toBeTruthy();
188
- expect(match(`nested(array(numberProperty>2345))`)).toBeFalsy();
189
- expect(match(`nested(array(numberProperty<=1234))`)).toBeTruthy();
190
- expect(match(`nested(array(numberProperty<=1233))`)).toBeFalsy();
191
- expect(match(`nested(array(numberProperty<1235))`)).toBeTruthy();
192
- expect(match(`nested(array(numberProperty<1234))`)).toBeFalsy();
189
+ expect(match("nested(array(numberProperty>=2345))")).toBeTruthy();
190
+ expect(match("nested(array(numberProperty>=2346))")).toBeFalsy();
191
+ expect(match("nested(array(numberProperty>2344))")).toBeTruthy();
192
+ expect(match("nested(array(numberProperty>2345))")).toBeFalsy();
193
+ expect(match("nested(array(numberProperty<=1234))")).toBeTruthy();
194
+ expect(match("nested(array(numberProperty<=1233))")).toBeFalsy();
195
+ expect(match("nested(array(numberProperty<1235))")).toBeTruthy();
196
+ expect(match("nested(array(numberProperty<1234))")).toBeFalsy();
193
197
 
194
198
  // One level deeper
195
199
  expect(
@@ -242,57 +246,57 @@ describe("Predicate filter", () => {
242
246
  test("geolocation within circle (...)", async () => {
243
247
  expect(
244
248
  match(
245
- `geoLocation within circle(5.121310867198959, 52.09068804569714, 2500)`,
249
+ "geoLocation within circle(5.121310867198959, 52.09068804569714, 2500)",
246
250
  ),
247
251
  ).toBeTruthy();
248
252
  expect(
249
253
  match(
250
- `geoLocation within circle(5.121310867198959, 52.09068804569714, 2400)`,
254
+ "geoLocation within circle(5.121310867198959, 52.09068804569714, 2400)",
251
255
  ),
252
256
  ).toBeFalsy();
253
257
  });
254
258
 
255
259
  test("negate any other conditional expression", async () => {
256
- expect(match(`numberProperty = 1234`)).toBeTruthy();
257
- expect(match(`not (numberProperty = 1234)`)).toBeFalsy();
258
- expect(match(`not (numberProperty = 1235)`)).toBeTruthy();
259
- expect(match(`not (numberProperty = 1235)`)).toBeTruthy();
260
-
261
- expect(match(`nested(numberProperty=1234))`)).toBeTruthy();
262
- expect(match(`nested(not(numberProperty=1230)))`)).toBeTruthy();
263
- expect(match(`nested(not(numberProperty=1234)))`)).toBeFalsy();
260
+ expect(match("numberProperty = 1234")).toBeTruthy();
261
+ expect(match("not (numberProperty = 1234)")).toBeFalsy();
262
+ expect(match("not (numberProperty = 1235)")).toBeTruthy();
263
+ expect(match("not (numberProperty = 1235)")).toBeTruthy();
264
+
265
+ expect(match("nested(numberProperty=1234))")).toBeTruthy();
266
+ expect(match("nested(not(numberProperty=1230)))")).toBeTruthy();
267
+ expect(match("nested(not(numberProperty=1234)))")).toBeFalsy();
264
268
  });
265
269
 
266
270
  test("and clause (implicit)", async () => {
267
271
  expect(
268
- match([`stringProperty="foobar"`, `numberProperty=1234`]),
272
+ match([`stringProperty="foobar"`, "numberProperty=1234"]),
269
273
  ).toBeTruthy();
270
274
 
271
275
  expect(
272
- match([`stringProperty="foobar"`, `numberProperty=1111`]),
276
+ match([`stringProperty="foobar"`, "numberProperty=1111"]),
273
277
  ).toBeFalsy();
274
278
  });
275
279
 
276
280
  test("and clause (explicit)", async () => {
277
- expect(match(`numberProperty>1233 and numberProperty<1235`)).toBeTruthy();
278
- expect(match(`numberProperty>1233 and numberProperty<1234`)).toBeFalsy();
281
+ expect(match("numberProperty>1233 and numberProperty<1235")).toBeTruthy();
282
+ expect(match("numberProperty>1233 and numberProperty<1234")).toBeFalsy();
279
283
  });
280
284
 
281
285
  test("or clause", async () => {
282
286
  expect(
283
287
  match(
284
- `numberProperty=1231 or numberProperty>54312 or numberProperty=1234`,
288
+ "numberProperty=1231 or numberProperty>54312 or numberProperty=1234",
285
289
  ),
286
290
  ).toBeTruthy();
287
- expect(match(`numberProperty=1231 or numberProperty=1234`)).toBeTruthy();
288
- expect(match(`numberProperty=1231 or (numberProperty=1234)`)).toBeTruthy();
289
- expect(match(`numberProperty=1233 or numberProperty=1235`)).toBeFalsy();
291
+ expect(match("numberProperty=1231 or numberProperty=1234")).toBeTruthy();
292
+ expect(match("numberProperty=1231 or (numberProperty=1234)")).toBeTruthy();
293
+ expect(match("numberProperty=1233 or numberProperty=1235")).toBeFalsy();
290
294
  });
291
295
 
292
296
  test("or / and clause mixed", async () => {
293
297
  expect(
294
298
  match(
295
- `numberProperty=1234 and (numberProperty=1230 or (numberProperty=1234 or numberProperty=1235))`,
299
+ "numberProperty=1234 and (numberProperty=1230 or (numberProperty=1234 or numberProperty=1235))",
296
300
  ),
297
301
  ).toBeTruthy();
298
302
  });
@@ -304,10 +308,10 @@ describe("Predicate filter", () => {
304
308
 
305
309
  test("nested attribute access", async () => {
306
310
  expect(
307
- match(`nested(objectProperty(booleanProperty != true))`),
311
+ match("nested(objectProperty(booleanProperty != true))"),
308
312
  ).toBeFalsy();
309
313
  expect(
310
- match(`nested(objectProperty(booleanProperty != false))`),
314
+ match("nested(objectProperty(booleanProperty != false))"),
311
315
  ).toBeTruthy();
312
316
  });
313
317
 
@@ -325,11 +329,38 @@ describe("Predicate filter", () => {
325
329
  // })
326
330
 
327
331
  test("invalid predicate", async () => {
328
- expect(() => match(`stringProperty=nomatch`)).toThrow(PredicateError);
329
- expect(() => match(`stringProperty=nomatch`)).toThrow(
332
+ expect(() => match("stringProperty=nomatch")).toThrow(PredicateError);
333
+ expect(() => match("stringProperty=nomatch")).toThrow(
330
334
  "Invalid input 'n', expected input parameter or primitive value (line 1, column 16)",
331
335
  );
332
- expect(() => match(`stringProperty`)).toThrow(PredicateError);
336
+ expect(() => match("stringProperty")).toThrow(PredicateError);
337
+ });
338
+
339
+ test("uuid as field name", async () => {
340
+ expect(
341
+ match(
342
+ `nested(objectProperty(45c652f2-76e8-48fd-ab64-d11ad99d6631(stringProperty = "foobar")))`,
343
+ ),
344
+ ).toBeTruthy();
345
+
346
+ expect(
347
+ match(
348
+ `nested(objectProperty(3a57cc78-db08-4cd3-b778-d59b3326c435(stringProperty = "foobar")))`,
349
+ ),
350
+ ).toBeFalsy();
351
+ });
352
+
353
+ test("uuid as value", async () => {
354
+ expect(
355
+ match(
356
+ `nested(objectProperty(45c652f2-76e8-48fd-ab64-d11ad99d6631(uuidProperty = "3a57cc78-db08-4cd3-b778-d59b3326c435")))`,
357
+ ),
358
+ ).toBeTruthy();
359
+ expect(
360
+ match(
361
+ `nested(objectProperty(45c652f2-76e8-48fd-ab64-d11ad99d6631(uuidProperty = "45c652f2-76e8-48fd-ab64-d11ad99d6631")))`,
362
+ ),
363
+ ).toBeFalsy();
333
364
  });
334
365
  });
335
366