@luvio/adapter-test-library 0.146.0 → 0.146.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.
@@ -449,6 +449,19 @@ class MockDurableStore {
449
449
  }
450
450
  return returnSource;
451
451
  }
452
+ async getMetadata(entryIds, segment) {
453
+ const entries = await this.getEntries(entryIds, segment);
454
+ if (entries === undefined) {
455
+ return undefined;
456
+ }
457
+ return entryIds.reduce((accu, key) => {
458
+ const entry = entries[key];
459
+ if (entry !== undefined && entry.metadata !== undefined) {
460
+ accu[key] = { metadata: entry.metadata };
461
+ }
462
+ return accu;
463
+ }, {});
464
+ }
452
465
  async getAllEntries(segment) {
453
466
  // await any current write operations
454
467
  if (this.writePromises.size > 0) {
@@ -460,6 +473,9 @@ class MockDurableStore {
460
473
  setEntries(entries, segment) {
461
474
  return this.batchOperations([{ entries, segment, type: 'setEntries' }]);
462
475
  }
476
+ setMetadata(entries, segment) {
477
+ return this.batchOperations([{ entries, segment, type: 'setMetadata' }]);
478
+ }
463
479
  evictEntries(ids, segment) {
464
480
  return this.batchOperations([{ ids, segment, type: 'evictEntries' }]);
465
481
  }
@@ -511,6 +527,19 @@ class MockDurableStore {
511
527
  ids.forEach((id) => {
512
528
  delete entries[id];
513
529
  });
530
+ break;
531
+ case 'setMetadata':
532
+ ids = Object.keys(operation.entries);
533
+ if (entries !== undefined) {
534
+ ids.forEach((id) => {
535
+ const { metadata } = clone(operation.entries[id]);
536
+ const entry = rawEntries !== undefined
537
+ ? rawEntries[id]
538
+ : {};
539
+ entries[id] = { ...entry, metadata };
540
+ });
541
+ }
542
+ break;
514
543
  }
515
544
  await this.persistence.set(operation.segment, entries);
516
545
  return { ids, segment, type: operation.type };
@@ -1,4 +1,4 @@
1
- import type { DurableStore, DurableStoreEntries, OnDurableStoreChangedListener, DurableStoreOperation } from '@luvio/environments';
1
+ import type { DurableStore, DurableStoreEntries, OnDurableStoreChangedListener, DurableStoreOperation, DurableStoreMetadataEntries } from '@luvio/environments';
2
2
  import type { DurableStorePersistence } from './durableStorePersistence';
3
3
  export declare class MockDurableStore implements DurableStore {
4
4
  private writePromises;
@@ -6,8 +6,10 @@ export declare class MockDurableStore implements DurableStore {
6
6
  persistence: DurableStorePersistence;
7
7
  constructor(persistence?: DurableStorePersistence);
8
8
  getEntries<T>(entryIds: string[], segment: string): Promise<DurableStoreEntries<T> | undefined>;
9
+ getMetadata(entryIds: string[], segment: string): Promise<DurableStoreMetadataEntries | undefined>;
9
10
  getAllEntries<T>(segment: string): Promise<DurableStoreEntries<T> | undefined>;
10
11
  setEntries<T>(entries: DurableStoreEntries<T>, segment: string): Promise<void>;
12
+ setMetadata(entries: DurableStoreMetadataEntries, segment: string): Promise<void>;
11
13
  evictEntries(ids: string[], segment: string): Promise<void>;
12
14
  registerOnChangedListener(listener: OnDurableStoreChangedListener): () => Promise<void>;
13
15
  batchOperations<T>(operations: DurableStoreOperation<T>[]): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luvio/adapter-test-library",
3
- "version": "0.146.0",
3
+ "version": "0.146.2",
4
4
  "description": "Test library for luvio adapters",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,11 +25,11 @@
25
25
  "watch": "yarn build --watch"
26
26
  },
27
27
  "dependencies": {
28
- "sinon": "^14.0.0"
28
+ "sinon": "^15.2.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@luvio/engine": "^0.146.0",
32
- "@luvio/environments": "^0.146.0",
31
+ "@luvio/engine": "^0.146.2",
32
+ "@luvio/environments": "^0.146.2",
33
33
  "@types/sinon": "^7.5.2"
34
34
  },
35
35
  "volta": {