@arrai-innovations/reactive-helpers 13.1.0 → 14.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 (51) hide show
  1. package/README.md +11 -1
  2. package/config/listCrud.js +4 -1
  3. package/config/objectCrud.js +10 -4
  4. package/docs/README.md +1 -1
  5. package/docs/config/listCrud.md +20 -2
  6. package/docs/config/objectCrud.md +51 -15
  7. package/docs/use/list.md +6 -0
  8. package/docs/use/listCalculated.md +58 -39
  9. package/docs/use/listFilter.md +57 -39
  10. package/docs/use/listInstance.md +29 -11
  11. package/docs/use/listRelated.md +47 -28
  12. package/docs/use/listSearch.md +40 -28
  13. package/docs/use/listSort.md +58 -39
  14. package/docs/use/listSubscription.md +8 -2
  15. package/docs/use/object.md +28 -14
  16. package/docs/use/objectCalculated.md +26 -13
  17. package/docs/use/objectInstance.md +49 -24
  18. package/docs/use/objectRelated.md +27 -14
  19. package/docs/use/objectSubscription.md +18 -9
  20. package/docs/use/paginatedListInstance.md +8 -2
  21. package/docs/use/search.md +8 -2
  22. package/docs/utils/{getFakeId.md → getFakePk.md} +7 -7
  23. package/index.js +1 -1
  24. package/package.json +1 -1
  25. package/tests/unit/use/listCalculated.spec.js +4 -4
  26. package/tests/unit/use/listFilter.spec.js +10 -9
  27. package/tests/unit/use/listInstance.spec.js +147 -23
  28. package/tests/unit/use/listRelated.spec.js +5 -5
  29. package/tests/unit/use/listSearch.spec.js +14 -12
  30. package/tests/unit/use/listSort.spec.js +8 -1
  31. package/tests/unit/use/listSubscription.spec.js +119 -10
  32. package/tests/unit/use/objectInstance.spec.js +575 -46
  33. package/tests/unit/use/objectSubscription.spec.js +152 -23
  34. package/tests/unit/use/search.spec.js +11 -11
  35. package/use/list.js +1 -0
  36. package/use/listCalculated.js +3 -2
  37. package/use/listFilter.js +9 -9
  38. package/use/listInstance.js +39 -28
  39. package/use/listKeys.js +4 -3
  40. package/use/listRelated.js +23 -22
  41. package/use/listSearch.js +37 -33
  42. package/use/listSort.js +1 -0
  43. package/use/listSubscription.js +25 -15
  44. package/use/object.js +8 -13
  45. package/use/objectCalculated.js +2 -1
  46. package/use/objectInstance.js +29 -14
  47. package/use/objectRelated.js +3 -2
  48. package/use/objectSubscription.js +31 -11
  49. package/use/paginatedListInstance.js +1 -1
  50. package/use/search.js +13 -4
  51. package/utils/{getFakeId.js → getFakePk.js} +4 -4
@@ -65,6 +65,23 @@ describe("use/listInstance.spec.js", function () {
65
65
  name: "nm,.",
66
66
  },
67
67
  ];
68
+ const crudListResolvedPageNonStandardPK = [
69
+ {
70
+ unique: 1,
71
+ __str__: "fdg",
72
+ name: "fdg",
73
+ },
74
+ {
75
+ unique: 2,
76
+ __str__: "ryt",
77
+ name: "ryt",
78
+ },
79
+ {
80
+ unique: 3,
81
+ __str__: "pui",
82
+ name: "pui",
83
+ },
84
+ ];
68
85
  const listObject = {
69
86
  id: null,
70
87
  __str__: "nvm",
@@ -72,6 +89,7 @@ describe("use/listInstance.spec.js", function () {
72
89
  };
73
90
  const crudListResolvedObjects1 = keyBy(crudListResolvedPage1, "id");
74
91
  const crudListResolvedObjects2 = keyBy(crudListResolvedPage2, "id");
92
+ const crudListResolvedObjectsNonStandardPK = keyBy(crudListResolvedPageNonStandardPK, "unique");
75
93
  describe("list", function () {
76
94
  it("success", async function () {
77
95
  const listArgs = reactive({
@@ -80,7 +98,7 @@ describe("use/listInstance.spec.js", function () {
80
98
  const retrieveArgs = reactive({
81
99
  fields,
82
100
  });
83
- const listInstance = useListInstance({ props: { listArgs, retrieveArgs } });
101
+ const listInstance = useListInstance({ props: { pkKey: "id", listArgs, retrieveArgs } });
84
102
  let crudListResolve;
85
103
  const crudListPromise = new Promise((resolve) => {
86
104
  crudListResolve = resolve;
@@ -132,6 +150,56 @@ describe("use/listInstance.spec.js", function () {
132
150
  expect({ ...listInstance.state.objects }).toEqual(crudListResolvedObjects2);
133
151
  expect(globalList).toHaveBeenCalledWith({
134
152
  crudArgs: { stream: "test_stream" },
153
+ pkKey: "id",
154
+ listArgs: { user: 1 },
155
+ retrieveArgs: { fields: fields },
156
+ pageCallback: passedPageCallback,
157
+ isCancelled: expect.any(Object), // ref
158
+ });
159
+ expect(globalList).toHaveBeenCalledTimes(1);
160
+ });
161
+ it("success with non-standard primary key", async function () {
162
+ const listArgs = reactive({
163
+ user: 1,
164
+ });
165
+ const retrieveArgs = reactive({
166
+ fields,
167
+ });
168
+ const listInstance = useListInstance({ props: { pkKey: "unique", listArgs, retrieveArgs } });
169
+ let crudListResolve;
170
+ const crudListPromise = new Promise((resolve) => {
171
+ crudListResolve = resolve;
172
+ });
173
+ let passedPageCallback;
174
+ globalList.mockImplementation(({ pageCallback }) => {
175
+ passedPageCallback = pageCallback;
176
+ return crudListPromise;
177
+ });
178
+
179
+ expectErrorToBeNull(listInstance.state.error);
180
+ expect(listInstance.state.errored).toBe(false);
181
+ expect(listInstance.state.loading).toBeUndefined();
182
+ expect({ ...listInstance.state.objects }).toEqual({});
183
+
184
+ listInstance.list();
185
+
186
+ expectErrorToBeNull(listInstance.state.error);
187
+ expect(listInstance.state.errored).toBe(false);
188
+ expect(listInstance.state.loading).toBe(true);
189
+ expect({ ...listInstance.state.objects }).toEqual({});
190
+
191
+ await nextTick();
192
+
193
+ // @ts-ignore - pageCallback is set in the mock, if not it will throw which is what we want
194
+ passedPageCallback(crudListResolvedPageNonStandardPK);
195
+
196
+ expectErrorToBeNull(listInstance.state.error);
197
+ expect(listInstance.state.errored).toBe(false);
198
+ expect(listInstance.state.loading).toBe(true);
199
+ expect({ ...listInstance.state.objects }).toEqual(crudListResolvedObjectsNonStandardPK);
200
+ expect(globalList).toHaveBeenCalledWith({
201
+ crudArgs: { stream: "test_stream" },
202
+ pkKey: "unique",
135
203
  listArgs: { user: 1 },
136
204
  retrieveArgs: { fields: fields },
137
205
  pageCallback: passedPageCallback,
@@ -146,7 +214,7 @@ describe("use/listInstance.spec.js", function () {
146
214
  const retrieveArgs = reactive({
147
215
  fields,
148
216
  });
149
- const listInstance = useListInstance({ props: { listArgs, retrieveArgs } });
217
+ const listInstance = useListInstance({ props: { pkKey: "id", listArgs, retrieveArgs } });
150
218
  expectErrorToBeNull(listInstance.state.error);
151
219
  expect(listInstance.state.errored).toBe(false);
152
220
  expect(listInstance.state.loading).toBeUndefined();
@@ -158,6 +226,7 @@ describe("use/listInstance.spec.js", function () {
158
226
 
159
227
  expect(globalList).toHaveBeenCalledWith({
160
228
  crudArgs: { stream: "test_stream" },
229
+ pkKey: "id",
161
230
  listArgs: { user: 1 },
162
231
  retrieveArgs: { fields: fields },
163
232
  pageCallback: expect.any(Function),
@@ -176,7 +245,7 @@ describe("use/listInstance.spec.js", function () {
176
245
  const retrieveArgs = reactive({
177
246
  fields,
178
247
  });
179
- const listInstance = useListInstance({ props: { listArgs, retrieveArgs } });
248
+ const listInstance = useListInstance({ props: { pkKey: "id", listArgs, retrieveArgs } });
180
249
  let crudListReject;
181
250
  const crudListPromise = new Promise((resolve, reject) => {
182
251
  crudListReject = reject;
@@ -214,6 +283,7 @@ describe("use/listInstance.spec.js", function () {
214
283
  expect({ ...listInstance.state.objects }).toEqual({});
215
284
  expect(globalList).toHaveBeenCalledWith({
216
285
  crudArgs: { stream: "test_stream" },
286
+ pkKey: "id",
217
287
  listArgs: { user: 1 },
218
288
  retrieveArgs: { fields: fields },
219
289
  pageCallback: passedPageCallback,
@@ -229,7 +299,7 @@ describe("use/listInstance.spec.js", function () {
229
299
  fields,
230
300
  });
231
301
  const listInstance = useListInstance({
232
- props: { listArgs, retrieveArgs, crudArgs: { stream: "custom_stream" } },
302
+ props: { pkKey: "id", listArgs, retrieveArgs, crudArgs: { stream: "custom_stream" } },
233
303
  });
234
304
  let crudListResolve;
235
305
  const crudListPromise = new Promise((resolve) => {
@@ -283,6 +353,7 @@ describe("use/listInstance.spec.js", function () {
283
353
  expect({ ...listInstance.state.objects }).toEqual(crudListResolvedObjects2);
284
354
  expect(globalList).toHaveBeenCalledWith({
285
355
  crudArgs: { stream: "custom_stream" },
356
+ pkKey: "id",
286
357
  listArgs: { user: 1 },
287
358
  retrieveArgs: { fields: fields },
288
359
  pageCallback: passedPageCallback,
@@ -301,6 +372,7 @@ describe("use/listInstance.spec.js", function () {
301
372
  props: {
302
373
  listArgs,
303
374
  retrieveArgs,
375
+ pkKey: "id",
304
376
  },
305
377
  });
306
378
  let crudListResolve;
@@ -333,6 +405,7 @@ describe("use/listInstance.spec.js", function () {
333
405
  expect(listInstance.state.objectsInOrder).toEqual(Object.values(crudListResolvedObjects2));
334
406
  expect(globalList).toHaveBeenCalledWith({
335
407
  crudArgs: { stream: "test_stream" },
408
+ pkKey: "id",
336
409
  listArgs: { user: 1 },
337
410
  retrieveArgs: { fields: fields },
338
411
  pageCallback: passedPageCallback,
@@ -354,7 +427,8 @@ describe("use/listInstance.spec.js", function () {
354
427
  const listInstanceA = useListInstance({
355
428
  props: {
356
429
  crudArgs: { stream: "test_streamA" },
357
- id: 1,
430
+ pk: 1,
431
+ pkKey: "id",
358
432
  retrieveArgs: {
359
433
  fields,
360
434
  },
@@ -363,7 +437,8 @@ describe("use/listInstance.spec.js", function () {
363
437
  const listInstanceB = useListInstance({
364
438
  props: {
365
439
  crudArgs: { stream: "test_streamB" },
366
- id: 2,
440
+ pk: 2,
441
+ pkKey: "id",
367
442
  retrieveArgs: {
368
443
  fields,
369
444
  },
@@ -373,7 +448,8 @@ describe("use/listInstance.spec.js", function () {
373
448
  A: {
374
449
  props: {
375
450
  crudArgs: { stream: "test_streamA" },
376
- id: 1,
451
+ pk: 1,
452
+ pkKey: "id",
377
453
  retrieveArgs: {
378
454
  fields,
379
455
  },
@@ -382,7 +458,8 @@ describe("use/listInstance.spec.js", function () {
382
458
  B: {
383
459
  props: {
384
460
  crudArgs: { stream: "test_streamB" },
385
- id: 2,
461
+ pk: 2,
462
+ pkKey: "id",
386
463
  retrieveArgs: {
387
464
  fields,
388
465
  },
@@ -394,15 +471,15 @@ describe("use/listInstance.spec.js", function () {
394
471
  });
395
472
  describe("addListObject", function () {
396
473
  it("errored", function () {
397
- const listInstance = useListInstance({ props: {} });
474
+ const listInstance = useListInstance({ props: { pkKey: "id" } });
398
475
  expect(() => listInstance.addListObject({ listObject })).toThrowError(ListInstanceError);
399
- listObject.id = listInstance.getFakeId();
476
+ listObject.id = listInstance.getFakePk();
400
477
  listInstance.addListObject(listObject);
401
478
  expect(() => listInstance.addListObject({ listObject })).toThrowError(ListInstanceError);
402
479
  });
403
480
  it("succeeded", async function () {
404
- const listInstance = useListInstance({ props: {} });
405
- const newId = listInstance.getFakeId();
481
+ const listInstance = useListInstance({ props: { pkKey: "id" } });
482
+ const newId = listInstance.getFakePk();
406
483
  listObject.id = newId;
407
484
  listInstance.addListObject(listObject);
408
485
  expect(listInstance.state.objects[newId]).toEqual(listObject);
@@ -424,7 +501,7 @@ describe("use/listInstance.spec.js", function () {
424
501
  });
425
502
  describe("updateListObject", function () {
426
503
  it("errors", function () {
427
- const listInstance = useListInstance({ props: {} });
504
+ const listInstance = useListInstance({ props: { pkKey: "id" } });
428
505
  expect(() => listInstance.updateListObject({ listObject })).toThrowError(ListInstanceError);
429
506
  listObject.id = -50002000;
430
507
  listInstance.addListObject(listObject);
@@ -432,7 +509,7 @@ describe("use/listInstance.spec.js", function () {
432
509
  });
433
510
  it("succeeds", async function () {
434
511
  const listInstance = useListInstance({
435
- props: {},
512
+ props: { pkKey: "id" },
436
513
  });
437
514
  let crudListResolve;
438
515
  const crudListPromise = new Promise((resolve) => {
@@ -455,7 +532,6 @@ describe("use/listInstance.spec.js", function () {
455
532
  obj: listInstance.state,
456
533
  prop: "running",
457
534
  });
458
-
459
535
  let updateObject = listInstance.state.objects["1"];
460
536
  updateObject.name = "updated";
461
537
  listInstance.updateListObject(updateObject);
@@ -470,12 +546,12 @@ describe("use/listInstance.spec.js", function () {
470
546
  });
471
547
  describe("deleteListObject", function () {
472
548
  it("errors", function () {
473
- const listInstance = useListInstance({ props: {} });
549
+ const listInstance = useListInstance({ props: { pkKey: "id" } });
474
550
  expect(() => listInstance.deleteListObject(-50002000)).toThrowError(ListInstanceError);
475
551
  });
476
552
  it("succeeds", async function () {
477
553
  const listInstance = useListInstance({
478
- props: {},
554
+ props: { pkKey: "id" },
479
555
  });
480
556
  let crudListResolve;
481
557
  const crudListPromise = new Promise((resolve) => {
@@ -523,7 +599,7 @@ describe("use/listInstance.spec.js", function () {
523
599
  const retrieveArgs = reactive({
524
600
  fields,
525
601
  });
526
- const listInstance = useListInstance({ props: { listArgs, retrieveArgs } });
602
+ const listInstance = useListInstance({ props: { pkKey: "id", listArgs, retrieveArgs } });
527
603
  let crudListResolve;
528
604
  const crudListPromise = new Promise((resolve) => {
529
605
  crudListResolve = resolve;
@@ -549,7 +625,53 @@ describe("use/listInstance.spec.js", function () {
549
625
  expect(listInstance.state.loading).toBe(true);
550
626
  expect(globalbulkDelete).toHaveBeenCalledWith({
551
627
  crudArgs: { stream: "test_stream" },
552
- ids: Object.keys(crudListResolvedObjects2).map(Number),
628
+ pkKey: "id",
629
+ pks: Object.keys(crudListResolvedObjects2).map(Number),
630
+ });
631
+
632
+ expect(globalbulkDelete).toHaveBeenCalledTimes(1);
633
+
634
+ // @ts-ignore - bulkDeleteResolve is set in a promise, since we await this will be set
635
+ crudListResolve();
636
+ await flushPromises();
637
+ await expect(bulkDeleteResolve).resolves.toBe(true);
638
+ expect({ ...listInstance.state.objects }).toEqual({});
639
+ });
640
+ it("succeeds with non-standard primary key", async function () {
641
+ const listArgs = reactive({
642
+ user: 1,
643
+ });
644
+ const retrieveArgs = reactive({
645
+ fields,
646
+ });
647
+ const listInstance = useListInstance({ props: { pkKey: "unique", listArgs, retrieveArgs } });
648
+ let crudListResolve;
649
+ const crudListPromise = new Promise((resolve) => {
650
+ crudListResolve = resolve;
651
+ });
652
+ let passedPageCallback;
653
+ globalList.mockImplementation(({ pageCallback }) => {
654
+ passedPageCallback = pageCallback;
655
+ return crudListPromise;
656
+ });
657
+ const liListResolve = listInstance.list();
658
+ await nextTick();
659
+ // @ts-ignore - pageCallback is set in the mock, if not it will throw which is what we want
660
+ passedPageCallback(crudListResolvedPageNonStandardPK);
661
+ // @ts-ignore - crudListResolve is set in a promise, since we await this will be set
662
+ crudListResolve();
663
+ await flushPromises();
664
+ await expect(liListResolve).resolves.toBe(true);
665
+
666
+ expect({ ...listInstance.state.objects }).toEqual(crudListResolvedObjectsNonStandardPK);
667
+ const bulkDeleteResolve = listInstance.bulkDelete();
668
+ expectErrorToBeNull(listInstance.state.error);
669
+ expect(listInstance.state.errored).toBe(false);
670
+ expect(listInstance.state.loading).toBe(true);
671
+ expect(globalbulkDelete).toHaveBeenCalledWith({
672
+ crudArgs: { stream: "test_stream" },
673
+ pkKey: "unique",
674
+ pks: Object.keys(crudListResolvedObjectsNonStandardPK).map(Number),
553
675
  });
554
676
 
555
677
  expect(globalbulkDelete).toHaveBeenCalledTimes(1);
@@ -561,10 +683,10 @@ describe("use/listInstance.spec.js", function () {
561
683
  expect({ ...listInstance.state.objects }).toEqual({});
562
684
  });
563
685
  });
564
- describe("getFakeId", function () {
686
+ describe("getFakePk", function () {
565
687
  it("returns fakeId", function () {
566
- const listInstance = useListInstance({ props: {} });
567
- const fakeId = listInstance.getFakeId();
688
+ const listInstance = useListInstance({ props: { pkKey: "id" } });
689
+ const fakeId = listInstance.getFakePk();
568
690
  expect(fakeId).toBeTruthy();
569
691
  });
570
692
  });
@@ -592,7 +714,9 @@ describe("use/listInstance.spec.js", function () {
592
714
  __str__: "yuio",
593
715
  name: "yiuo",
594
716
  };
595
- const listInstance = useListInstance({ props: { listArgs: { user: 1 }, retrieveArgs: { fields: fields } } });
717
+ const listInstance = useListInstance({
718
+ props: { pkKey: "id", listArgs: { user: 1 }, retrieveArgs: { fields: fields } },
719
+ });
596
720
  let crudListResolve;
597
721
  const crudListPromise = new Promise((resolve) => {
598
722
  crudListResolve = resolve;
@@ -13,8 +13,8 @@ describe("use/listRelated", () => {
13
13
  AwaitNot = watchesModule.AwaitNot;
14
14
  });
15
15
  it("should return a list of related items", async () => {
16
- const mainListInstance = useListInstance({ props: {} });
17
- const relatedListInstance = useListInstance({ props: {} });
16
+ const mainListInstance = useListInstance({ props: { pkKey: "id" } });
17
+ const relatedListInstance = useListInstance({ props: { pkKey: "id" } });
18
18
  mainListInstance.addListObject({
19
19
  id: "1",
20
20
  name: "main",
@@ -82,9 +82,9 @@ describe("use/listRelated", () => {
82
82
  });
83
83
  it('should allow related objects pkKey to be prefixed with "relatedItem." to reference previously related objects', async () => {
84
84
  //
85
- const mainListInstance = useListInstance({ props: {} });
86
- const intermediateListInstance = useListInstance({ props: {} });
87
- const relatedListInstance = useListInstance({ props: {} });
85
+ const mainListInstance = useListInstance({ props: { pkKey: "id" } });
86
+ const intermediateListInstance = useListInstance({ props: { pkKey: "id" } });
87
+ const relatedListInstance = useListInstance({ props: { pkKey: "id" } });
88
88
  mainListInstance.addListObject({
89
89
  id: "1",
90
90
  name: "main",
@@ -22,7 +22,7 @@ describe("use/listSearch", () => {
22
22
  it("should match by search term", async () => {
23
23
  const textSearchValue = ref("one");
24
24
  // const textSearchValue = ref("");
25
- const list = useListInstance({ props: {} });
25
+ const list = useListInstance({ props: { pkKey: "id" } });
26
26
  const search = useListSearch({
27
27
  parentState: list.state,
28
28
  props: reactive({
@@ -79,7 +79,7 @@ describe("use/listSearch", () => {
79
79
  });
80
80
  });
81
81
  it("no args: returns objects unsearched", async () => {
82
- const listInstance = useListInstance({ props: {} });
82
+ const listInstance = useListInstance({ props: { pkKey: "id" } });
83
83
  const listItems = [
84
84
  { id: 4, name: "four", has_things: true },
85
85
  { id: 2, name: "two", has_things: true },
@@ -103,7 +103,7 @@ describe("use/listSearch", () => {
103
103
  vi.resetAllMocks();
104
104
  const orderByRules = [{ key: "name", desc: true, localeCompare: false }];
105
105
  const sortThrottleWait = 0;
106
- const listInstance = useListInstance({ props: {} });
106
+ const listInstance = useListInstance({ props: { pkKey: "id" } });
107
107
  const listItems = [
108
108
  { id: 4, name: "four", has_things: true },
109
109
  { id: 2, name: "two", has_things: true },
@@ -140,6 +140,7 @@ describe("use/listSearch", () => {
140
140
  const listInstanceA = useListInstance({
141
141
  props: {
142
142
  crudArgs: { stream: "test_streamA" },
143
+ pkKey: "id",
143
144
  listArgs: { user: 1 },
144
145
  retrieveArgs: {
145
146
  fields,
@@ -149,6 +150,7 @@ describe("use/listSearch", () => {
149
150
  const listInstanceB = useListInstance({
150
151
  props: {
151
152
  crudArgs: { stream: "test_streamB" },
153
+ pkKey: "id",
152
154
  listArgs: { user: 2 },
153
155
  retrieveArgs: {
154
156
  fields,
@@ -242,8 +244,8 @@ describe("use/listSearch", () => {
242
244
  describe("useListSearch accepts relatedItem. and calculatedItem. rules", () => {
243
245
  it("in textSearchRules", async () => {
244
246
  const textSearchValue = ref("four");
245
- const list = useListInstance({ props: {} });
246
- const relatedList = useListInstance({ props: {} });
247
+ const list = useListInstance({ props: { pkKey: "id" } });
248
+ const relatedList = useListInstance({ props: { pkKey: "id" } });
247
249
  const related = useListRelated({
248
250
  parentState: list.state,
249
251
  relatedObjectsRules: {
@@ -296,7 +298,7 @@ describe("use/listSearch", () => {
296
298
  });
297
299
  describe("useListSearch updates index when", () => {
298
300
  it("parentState.objects is updated", async () => {
299
- const list = useListInstance({ props: {} });
301
+ const list = useListInstance({ props: { pkKey: "id" } });
300
302
  const textSearchValue = ref("");
301
303
  const search = useListSearch({
302
304
  parentState: list.state,
@@ -338,8 +340,8 @@ describe("use/listSearch", () => {
338
340
  });
339
341
  });
340
342
  it("parentState.relatedObjects is updated", async () => {
341
- const list = useListInstance({ props: {} });
342
- const relatedList = useListInstance({ props: {} });
343
+ const list = useListInstance({ props: { pkKey: "id" } });
344
+ const relatedList = useListInstance({ props: { pkKey: "id" } });
343
345
  const related = useListRelated({
344
346
  parentState: list.state,
345
347
  relatedObjectsRules: reactive({
@@ -382,7 +384,7 @@ describe("use/listSearch", () => {
382
384
  });
383
385
  });
384
386
  it("parentState.calculatedObjects is updated", async () => {
385
- const list = useListInstance({ props: {} });
387
+ const list = useListInstance({ props: { pkKey: "id" } });
386
388
  const calculated = useListCalculated({
387
389
  parentState: list.state,
388
390
  calculatedObjectsRules: reactive({
@@ -429,7 +431,7 @@ describe("use/listSearch", () => {
429
431
  });
430
432
  });
431
433
  it("textSearchRules is updated", async () => {
432
- const list = useListInstance({ props: {} });
434
+ const list = useListInstance({ props: { pkKey: "id" } });
433
435
  const textSearchValue = ref("");
434
436
  const searchProps = reactive({
435
437
  textSearchValue,
@@ -477,7 +479,7 @@ describe("use/listSearch", () => {
477
479
  });
478
480
  });
479
481
  it("does not pass through when showAllWhenEmpty is false", async () => {
480
- const list = useListInstance({ props: {} });
482
+ const list = useListInstance({ props: { pkKey: "id" } });
481
483
  const textSearchValue = ref("");
482
484
  const search = useListSearch({
483
485
  parentState: list.state,
@@ -508,7 +510,7 @@ describe("use/listSearch", () => {
508
510
  });
509
511
  it("should update when parentState is filtered in pass through mode.", async () => {
510
512
  const listInstance = useListInstance({
511
- props: {},
513
+ props: { pkKey: "id" },
512
514
  });
513
515
  const allowedFilter = ref((obj) => !obj.filtered);
514
516
  const listFilter = useListFilter({
@@ -58,6 +58,7 @@ describe("use/useListSort", () => {
58
58
  listInstance = useListInstance({
59
59
  props: {
60
60
  crudArgs: {},
61
+ pkKey: "id",
61
62
  retrieveArgs: {
62
63
  fields: ["id", "lexical_name", "organization", "relatedObjects"],
63
64
  },
@@ -169,6 +170,7 @@ describe("use/useListSort", () => {
169
170
  const listInstanceA = useListInstance({
170
171
  props: {
171
172
  crudArgs: { stream: "test_streamA" },
173
+ pkKey: "id",
172
174
  listArgs: { user: 1 },
173
175
  retrieveArgs: {
174
176
  fields,
@@ -179,6 +181,7 @@ describe("use/useListSort", () => {
179
181
  props: {
180
182
  crudArgs: { stream: "test_streamB" },
181
183
  listArgs: { user: 2 },
184
+ pkKey: "id",
182
185
  retrieveArgs: {
183
186
  fields,
184
187
  },
@@ -200,6 +203,7 @@ describe("use/useListSort", () => {
200
203
  retrieveArgs: {
201
204
  fields,
202
205
  },
206
+ pkKey: "id",
203
207
  },
204
208
  },
205
209
  B: {
@@ -209,6 +213,7 @@ describe("use/useListSort", () => {
209
213
  retrieveArgs: {
210
214
  fields,
211
215
  },
216
+ pkKey: "id",
212
217
  },
213
218
  },
214
219
  });
@@ -232,6 +237,7 @@ describe("use/useListSort", () => {
232
237
  props: reactive({
233
238
  crudArgs: { stream: "test_stream" },
234
239
  listArgs: { user: 1 },
240
+ pkKey: "id",
235
241
  retrieveArgs: {
236
242
  fields: ["id", "__str__", "name", "relatedItem", "calculatedItem"],
237
243
  },
@@ -241,6 +247,7 @@ describe("use/useListSort", () => {
241
247
  props: reactive({
242
248
  crudArgs: { stream: "test_related_stream" },
243
249
  listArgs: { user: 1 },
250
+ pkKey: "id",
244
251
  retrieveArgs: {
245
252
  fields: ["id", "__str__", "name"],
246
253
  },
@@ -350,7 +357,7 @@ describe("use/useListSort", () => {
350
357
  });
351
358
  it("pass through correctly when parentState changes their order", async () => {
352
359
  const listInstance = useListInstance({
353
- props: reactive({}),
360
+ props: reactive({ pkKey: "id" }),
354
361
  });
355
362
  const allowedFilter = ref((obj) => obj.name !== "two");
356
363
  const listFilter = useListFilter({