@legalplace/lplogic 2.3.5 → 2.3.6

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/dist/LpLogic.js CHANGED
@@ -159,30 +159,8 @@ var not = function (values, comparator, parents) {
159
159
  return reducedValues.length === filter.length;
160
160
  };
161
161
  json_logic_js_1.default.add_operation("not", not);
162
- var contains = function (values, comparator, parents) {
163
- var reducedValues = reduceValues(values, parents, function (value, parent) {
164
- if (Array.isArray(value)) {
165
- return (value.some(function (val) {
166
- return cleanString(val).includes(cleanString(comparator));
167
- }) && parent);
168
- }
169
- return (cleanString(value).includes(cleanString(comparator)) && parent);
170
- });
171
- var filter = reducedValues.filter(function (value) { return value === true; });
172
- return reducedValues.length === filter.length;
173
- };
174
- json_logic_js_1.default.add_operation("contains", contains);
175
- var doesNotContain = function (values, comparator, parents) {
176
- var reducedValues = reduceValues(values, parents, function (value, parent) {
177
- if (Array.isArray(value)) {
178
- return (value.every(function (val) { return !cleanString(val).includes(cleanString(comparator)); }) && parent);
179
- }
180
- return (!cleanString(value).includes(cleanString(comparator)) && parent);
181
- });
182
- var filter = reducedValues.filter(function (value) { return value === true; });
183
- return reducedValues.length === filter.length;
184
- };
185
- json_logic_js_1.default.add_operation("does-not-contain", doesNotContain);
162
+ json_logic_js_1.default.add_operation("contains", is);
163
+ json_logic_js_1.default.add_operation("does-not-contain", not);
186
164
  json_logic_js_1.default.add_operation("empty", function (values, comparator, parents) {
187
165
  var reducedValues = reduceValues(values, parents, function (value, parent) {
188
166
  var stringValue = typeof value === "number" ? value.toString() : value;
@@ -313,10 +291,10 @@ registerScopedComparisonOp("not", function (value, comparator, parent) {
313
291
  return cleanString(value) !== cleanString(comparator) && parent;
314
292
  });
315
293
  registerScopedComparisonOp("contains", function (value, comparator, parent) {
316
- return cleanString(value).includes(cleanString(comparator)) && parent;
294
+ return cleanString(value) === cleanString(comparator) && parent;
317
295
  });
318
296
  registerScopedComparisonOp("does-not-contain", function (value, comparator, parent) {
319
- return !cleanString(value).includes(cleanString(comparator)) && parent;
297
+ return cleanString(value) !== cleanString(comparator) && parent;
320
298
  });
321
299
  registerScopedComparisonOp("like", function (value, comparator, parent) {
322
300
  return new RegExp("( |^)".concat(cleanString(comparator), "( |$)"), "i").test(cleanString(value)) && parent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/lplogic",
3
- "version": "2.3.5",
3
+ "version": "2.3.6",
4
4
  "description": "LegalPlace LpLogic",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -308,17 +308,38 @@ test('Testing "<>" is inverse of accent/case-insensitive "="', async () => {
308
308
 
309
309
  test('Testing "contains" accent- and case-insensitive', async () => {
310
310
  expect(
311
- LpLogic({ contains: [{ var: "v.1" }, "la"] }, { v: { 1: ["lax"] } })
311
+ LpLogic({ contains: [{ var: "v.1" }, "la"] }, { v: { 1: [""] } })
312
312
  ).toBe(true)
313
313
  expect(
314
- LpLogic({ contains: [{ var: "v.1" }, "la"] }, { v: { 1: ["la ha"] } })
314
+ LpLogic({ contains: [{ var: "v.1" }, "la"] }, { v: { 1: ["La"] } })
315
315
  ).toBe(true)
316
+ })
317
+
318
+ /**
319
+ * Regression guard: `contains` is an alias of `is` (equality), never substring.
320
+ * These are the discriminating cases the suite previously lacked - "Hello"
321
+ * against "Hello" passes under both semantics, so it caught nothing when the
322
+ * operator silently became `.includes()`.
323
+ */
324
+ test('Testing "contains" is equality, not substring', async () => {
316
325
  expect(
317
- LpLogic({ contains: [{ var: "v.1" }, "la"] }, { v: { 1: [""] } })
318
- ).toBe(true)
326
+ LpLogic({ contains: [{ var: "v.1" }, "la"] }, { v: { 1: ["lax"] } })
327
+ ).toBe(false)
319
328
  expect(
320
- LpLogic({ contains: [{ var: "v.1" }, "la"] }, { v: { 1: ["La"] } })
329
+ LpLogic({ contains: [{ var: "v.1" }, "la"] }, { v: { 1: ["la ha"] } })
330
+ ).toBe(false)
331
+ expect(
332
+ LpLogic({ contains: [{ var: "v.1" }, "SARL"] }, { v: { 1: ["SARL"] } })
321
333
  ).toBe(true)
334
+ expect(
335
+ LpLogic(
336
+ { contains: [{ var: "v.1" }, "SARL"] },
337
+ { v: { 1: ["SARL unipersonnelle"] } }
338
+ )
339
+ ).toBe(false)
340
+ expect(
341
+ LpLogic({ contains: [{ var: "v.1" }, "SARL"] }, { v: { 1: ["EURL/SARL"] } })
342
+ ).toBe(false)
322
343
  })
323
344
 
324
345
  test('Testing "does-not-contain" is inverse of accent-insensitive contains', async () => {
@@ -336,6 +357,33 @@ test('Testing "does-not-contain" is inverse of accent-insensitive contains', asy
336
357
  ).toBe(true)
337
358
  })
338
359
 
360
+ test('Testing "does-not-contain" is inequality, not substring', async () => {
361
+ expect(
362
+ LpLogic({ "does-not-contain": [{ var: "v.1" }, "la"] }, { v: { 1: ["lax"] } })
363
+ ).toBe(true)
364
+ expect(
365
+ LpLogic(
366
+ { "does-not-contain": [{ var: "v.1" }, "SARL"] },
367
+ { v: { 1: ["SARL unipersonnelle"] } }
368
+ )
369
+ ).toBe(true)
370
+ })
371
+
372
+ test('Testing scoped "contains" variants share the equality predicate', async () => {
373
+ expect(
374
+ LpLogic({ "contains-any": [{ var: "v.1" }, "la"] }, { v: { 1: ["lax", "la"] } })
375
+ ).toBe(true)
376
+ expect(
377
+ LpLogic({ "contains-any": [{ var: "v.1" }, "la"] }, { v: { 1: ["lax", "lab"] } })
378
+ ).toBe(false)
379
+ expect(
380
+ LpLogic({ "contains-first": [{ var: "v.1" }, "la"] }, { v: { 1: ["la", "lax"] } })
381
+ ).toBe(true)
382
+ expect(
383
+ LpLogic({ "contains-first": [{ var: "v.1" }, "la"] }, { v: { 1: ["lax", "la"] } })
384
+ ).toBe(false)
385
+ })
386
+
339
387
  test('Testing "like" accent- and case-insensitive word match', async () => {
340
388
  expect(
341
389
  LpLogic({ like: [{ var: "v.1" }, "la"] }, { v: { 1: ["lax"] } })
package/.gitlab-automator DELETED
@@ -1,7 +0,0 @@
1
- GITLAB_PRIVATE_TOKEN=glpat-BOv5W1i6MoAAvHjzkmc5nW86MQp1OjkH.01.0w119catf
2
- GITLAB_BASE_URL=https://git.legalplace.eu
3
- GITLAB_API_PROJECT_ID=28
4
- GITLAB_USER_ID=9
5
- CURRENT_PROJECT_ID=39
6
- SLACK_USER_ID=U0B3SNBV3
7
- CLICKUP_PRIVATE_TOKEN=pk_32519579_K5W4L4KEVXY03A3D2WFA46D07HVGTL5L