@luvio/environments 0.73.2 → 0.73.7

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.
@@ -1,4 +1,4 @@
1
- import { DurableStore } from './DurableStore';
1
+ import type { DurableStore } from './DurableStore';
2
2
  export declare const TTL_DURABLE_SEGMENT = "TTL_DURABLE_SEGMENT";
3
3
  export interface DefaultDurableTTLOverride extends DurableTTLOverride {
4
4
  namespace: 'TTL_DEFAULT_KEY';
@@ -548,12 +548,9 @@ function makeDurable(environment, { durableStore, instrumentation }) {
548
548
  };
549
549
  const storeBroadcast = function (_rebuildSnapshot, _snapshotDataAvailable) {
550
550
  validateNotDisposed();
551
- // for our environment we basically want a broadcast to be a "durable store broadcast",
552
- // so we flush staging store to L2, which will cause the onChanged handler to fire
553
- // which will revive records to the main L1 store and call the base storeBroadcast
554
- // don't await the DS write - DS implementation will take care of R/W
555
- // synchronization
556
- publishChangesToDurableStore();
551
+ // no-op here and wait for the L2 flush to happen in handleSuccessResponse,
552
+ // that flush will cause the onChanged handler to fire which will revive
553
+ // records to the main L1 store and call the base storeBroadcast
557
554
  };
558
555
  const publishChangesToDurableStore = function () {
559
556
  validateNotDisposed();
@@ -697,14 +694,34 @@ function makeDurable(environment, { durableStore, instrumentation }) {
697
694
  ingestStagingStore.records = existingRecords;
698
695
  }
699
696
  const snapshotFromMemoryIngest = ingestAndBroadcastFunc();
700
- if (snapshotFromMemoryIngest === undefined) {
701
- return undefined;
702
- }
703
- if (snapshotFromMemoryIngest.state !== 'Unfulfilled') {
697
+ // now that ingestion is done flush staging store values to L2
698
+ return publishChangesToDurableStore().then(() => {
699
+ if (snapshotFromMemoryIngest === undefined) {
700
+ return undefined;
701
+ }
702
+ if (snapshotFromMemoryIngest.state !== 'Unfulfilled') {
703
+ return snapshotFromMemoryIngest;
704
+ }
705
+ // if snapshot from staging store lookup is unfulfilled then do an L2 lookup
706
+ return reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, () => environment.storeLookup(snapshotFromMemoryIngest.select, environment.createSnapshot, snapshotFromMemoryIngest.refresh));
707
+ });
708
+ };
709
+ const handleErrorResponse = function (ingestAndBroadcastFunc) {
710
+ validateNotDisposed();
711
+ const snapshotFromMemoryIngest = ingestAndBroadcastFunc();
712
+ return publishChangesToDurableStore().then(() => {
704
713
  return snapshotFromMemoryIngest;
705
- }
706
- // if snapshot from staging store lookup is unfulfilled then do an L2 lookup
707
- return reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, () => environment.storeLookup(snapshotFromMemoryIngest.select, environment.createSnapshot, snapshotFromMemoryIngest.refresh));
714
+ });
715
+ };
716
+ const getNotifyChangeStoreEntries = function (keys) {
717
+ validateNotDisposed();
718
+ return durableStore.getEntries(keys, DefaultDurableSegment).then((durableRecords) => {
719
+ const entries = {};
720
+ publishDurableStoreEntries(durableRecords, (key, record) => {
721
+ entries[key] = record;
722
+ }, () => { });
723
+ return entries;
724
+ });
708
725
  };
709
726
  environment.defaultCachePolicy = buildStaleWhileRevalidateImplementation(Number.MAX_SAFE_INTEGER);
710
727
  return create(environment, {
@@ -729,6 +746,8 @@ function makeDurable(environment, { durableStore, instrumentation }) {
729
746
  getIngestStagingStoreRecords: { value: getIngestStagingStoreRecords },
730
747
  getIngestStagingStoreMetadata: { value: getIngestStagingStoreMetadata },
731
748
  handleSuccessResponse: { value: handleSuccessResponse },
749
+ handleErrorResponse: { value: handleErrorResponse },
750
+ getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
732
751
  });
733
752
  }
734
753
 
@@ -1,4 +1,4 @@
1
- import { Luvio } from '@luvio/engine';
1
+ import type { Luvio } from '@luvio/engine';
2
2
  export declare const DURABLE_STORE_ERROR = "durable-store-error";
3
3
  export declare type InstrumentationFunction = Luvio['instrument'];
4
4
  export declare type DurableStoreRejectionHandler = (e: any) => void;
@@ -1,4 +1,4 @@
1
- import { Store } from '@luvio/engine';
2
- import { DurableStore } from '../DurableStore';
3
- import { DurableStoreRejectionHandler } from './error';
1
+ import type { Store } from '@luvio/engine';
2
+ import type { DurableStore } from '../DurableStore';
3
+ import type { DurableStoreRejectionHandler } from './error';
4
4
  export declare function flushStoreValuesToDurableStore(store: Store, durableStore: DurableStore, durableStoreErrorHandler: DurableStoreRejectionHandler): Promise<void>;
@@ -1,6 +1,6 @@
1
- import { Environment, Snapshot, UnAvailableSnapshot, StoreMetadata } from '@luvio/engine';
2
- import { DurableStore, DurableStoreEntries } from '../DurableStore';
3
- import { DurableStoreRejectionHandler } from './error';
1
+ import type { Environment, Snapshot, UnAvailableSnapshot, StoreMetadata } from '@luvio/engine';
2
+ import type { DurableStore, DurableStoreEntries } from '../DurableStore';
3
+ import type { DurableStoreRejectionHandler } from './error';
4
4
  declare type ObjectAsSet = {
5
5
  [key: string]: true;
6
6
  };
@@ -1,2 +1,2 @@
1
- import { StoreRecordError } from '@luvio/engine';
1
+ import type { StoreRecordError } from '@luvio/engine';
2
2
  export declare function isStoreEntryError(storeRecord: unknown): storeRecord is StoreRecordError;
@@ -1,7 +1,8 @@
1
- import { CacheKeySet, Environment, RecordSource, Snapshot, Store } from '@luvio/engine';
2
- import { DurableStore } from './DurableStore';
3
- import { InstrumentationFunction } from './makeDurable/error';
4
- import { TTLOverridesMap } from './DurableTTLStore';
1
+ import type { CacheKeySet, Environment, RecordSource, Snapshot } from '@luvio/engine';
2
+ import { Store } from '@luvio/engine';
3
+ import type { DurableStore } from './DurableStore';
4
+ import type { InstrumentationFunction } from './makeDurable/error';
5
+ import type { TTLOverridesMap } from './DurableTTLStore';
5
6
  export interface DurableEnvironment extends Environment {
6
7
  /**
7
8
  * Disposes the environment and detaches the durable store listener
@@ -1,2 +1,2 @@
1
- import { Selector } from '@luvio/engine';
1
+ import type { Selector } from '@luvio/engine';
2
2
  export declare function readPaginationKeysFromSelector(select?: Selector<unknown>): string[];
@@ -1,4 +1,4 @@
1
- import { DurableStore } from './DurableStore';
1
+ import type { DurableStore } from './DurableStore';
2
2
  export declare const TTL_DURABLE_SEGMENT = "TTL_DURABLE_SEGMENT";
3
3
  export interface DefaultDurableTTLOverride extends DurableTTLOverride {
4
4
  namespace: 'TTL_DEFAULT_KEY';
@@ -552,12 +552,9 @@
552
552
  };
553
553
  const storeBroadcast = function (_rebuildSnapshot, _snapshotDataAvailable) {
554
554
  validateNotDisposed();
555
- // for our environment we basically want a broadcast to be a "durable store broadcast",
556
- // so we flush staging store to L2, which will cause the onChanged handler to fire
557
- // which will revive records to the main L1 store and call the base storeBroadcast
558
- // don't await the DS write - DS implementation will take care of R/W
559
- // synchronization
560
- publishChangesToDurableStore();
555
+ // no-op here and wait for the L2 flush to happen in handleSuccessResponse,
556
+ // that flush will cause the onChanged handler to fire which will revive
557
+ // records to the main L1 store and call the base storeBroadcast
561
558
  };
562
559
  const publishChangesToDurableStore = function () {
563
560
  validateNotDisposed();
@@ -701,14 +698,34 @@
701
698
  ingestStagingStore.records = existingRecords;
702
699
  }
703
700
  const snapshotFromMemoryIngest = ingestAndBroadcastFunc();
704
- if (snapshotFromMemoryIngest === undefined) {
705
- return undefined;
706
- }
707
- if (snapshotFromMemoryIngest.state !== 'Unfulfilled') {
701
+ // now that ingestion is done flush staging store values to L2
702
+ return publishChangesToDurableStore().then(() => {
703
+ if (snapshotFromMemoryIngest === undefined) {
704
+ return undefined;
705
+ }
706
+ if (snapshotFromMemoryIngest.state !== 'Unfulfilled') {
707
+ return snapshotFromMemoryIngest;
708
+ }
709
+ // if snapshot from staging store lookup is unfulfilled then do an L2 lookup
710
+ return reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, () => environment.storeLookup(snapshotFromMemoryIngest.select, environment.createSnapshot, snapshotFromMemoryIngest.refresh));
711
+ });
712
+ };
713
+ const handleErrorResponse = function (ingestAndBroadcastFunc) {
714
+ validateNotDisposed();
715
+ const snapshotFromMemoryIngest = ingestAndBroadcastFunc();
716
+ return publishChangesToDurableStore().then(() => {
708
717
  return snapshotFromMemoryIngest;
709
- }
710
- // if snapshot from staging store lookup is unfulfilled then do an L2 lookup
711
- return reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, () => environment.storeLookup(snapshotFromMemoryIngest.select, environment.createSnapshot, snapshotFromMemoryIngest.refresh));
718
+ });
719
+ };
720
+ const getNotifyChangeStoreEntries = function (keys) {
721
+ validateNotDisposed();
722
+ return durableStore.getEntries(keys, DefaultDurableSegment).then((durableRecords) => {
723
+ const entries = {};
724
+ publishDurableStoreEntries(durableRecords, (key, record) => {
725
+ entries[key] = record;
726
+ }, () => { });
727
+ return entries;
728
+ });
712
729
  };
713
730
  environment.defaultCachePolicy = engine.buildStaleWhileRevalidateImplementation(Number.MAX_SAFE_INTEGER);
714
731
  return create(environment, {
@@ -733,6 +750,8 @@
733
750
  getIngestStagingStoreRecords: { value: getIngestStagingStoreRecords },
734
751
  getIngestStagingStoreMetadata: { value: getIngestStagingStoreMetadata },
735
752
  handleSuccessResponse: { value: handleSuccessResponse },
753
+ handleErrorResponse: { value: handleErrorResponse },
754
+ getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
736
755
  });
737
756
  }
738
757
 
@@ -1,4 +1,4 @@
1
- import { Luvio } from '@luvio/engine';
1
+ import type { Luvio } from '@luvio/engine';
2
2
  export declare const DURABLE_STORE_ERROR = "durable-store-error";
3
3
  export declare type InstrumentationFunction = Luvio['instrument'];
4
4
  export declare type DurableStoreRejectionHandler = (e: any) => void;
@@ -1,4 +1,4 @@
1
- import { Store } from '@luvio/engine';
2
- import { DurableStore } from '../DurableStore';
3
- import { DurableStoreRejectionHandler } from './error';
1
+ import type { Store } from '@luvio/engine';
2
+ import type { DurableStore } from '../DurableStore';
3
+ import type { DurableStoreRejectionHandler } from './error';
4
4
  export declare function flushStoreValuesToDurableStore(store: Store, durableStore: DurableStore, durableStoreErrorHandler: DurableStoreRejectionHandler): Promise<void>;
@@ -1,6 +1,6 @@
1
- import { Environment, Snapshot, UnAvailableSnapshot, StoreMetadata } from '@luvio/engine';
2
- import { DurableStore, DurableStoreEntries } from '../DurableStore';
3
- import { DurableStoreRejectionHandler } from './error';
1
+ import type { Environment, Snapshot, UnAvailableSnapshot, StoreMetadata } from '@luvio/engine';
2
+ import type { DurableStore, DurableStoreEntries } from '../DurableStore';
3
+ import type { DurableStoreRejectionHandler } from './error';
4
4
  declare type ObjectAsSet = {
5
5
  [key: string]: true;
6
6
  };
@@ -1,2 +1,2 @@
1
- import { StoreRecordError } from '@luvio/engine';
1
+ import type { StoreRecordError } from '@luvio/engine';
2
2
  export declare function isStoreEntryError(storeRecord: unknown): storeRecord is StoreRecordError;
@@ -1,7 +1,8 @@
1
- import { CacheKeySet, Environment, RecordSource, Snapshot, Store } from '@luvio/engine';
2
- import { DurableStore } from './DurableStore';
3
- import { InstrumentationFunction } from './makeDurable/error';
4
- import { TTLOverridesMap } from './DurableTTLStore';
1
+ import type { CacheKeySet, Environment, RecordSource, Snapshot } from '@luvio/engine';
2
+ import { Store } from '@luvio/engine';
3
+ import type { DurableStore } from './DurableStore';
4
+ import type { InstrumentationFunction } from './makeDurable/error';
5
+ import type { TTLOverridesMap } from './DurableTTLStore';
5
6
  export interface DurableEnvironment extends Environment {
6
7
  /**
7
8
  * Disposes the environment and detaches the durable store listener
@@ -1,2 +1,2 @@
1
- import { Selector } from '@luvio/engine';
1
+ import type { Selector } from '@luvio/engine';
2
2
  export declare function readPaginationKeysFromSelector(select?: Selector<unknown>): string[];
@@ -1,4 +1,4 @@
1
- import { DurableStore } from './DurableStore';
1
+ import type { DurableStore } from './DurableStore';
2
2
  export declare const TTL_DURABLE_SEGMENT = "TTL_DURABLE_SEGMENT";
3
3
  export interface DefaultDurableTTLOverride extends DurableTTLOverride {
4
4
  namespace: 'TTL_DEFAULT_KEY';
@@ -590,12 +590,9 @@
590
590
  };
591
591
  var storeBroadcast = function (_rebuildSnapshot, _snapshotDataAvailable) {
592
592
  validateNotDisposed();
593
- // for our environment we basically want a broadcast to be a "durable store broadcast",
594
- // so we flush staging store to L2, which will cause the onChanged handler to fire
595
- // which will revive records to the main L1 store and call the base storeBroadcast
596
- // don't await the DS write - DS implementation will take care of R/W
597
- // synchronization
598
- publishChangesToDurableStore();
593
+ // no-op here and wait for the L2 flush to happen in handleSuccessResponse,
594
+ // that flush will cause the onChanged handler to fire which will revive
595
+ // records to the main L1 store and call the base storeBroadcast
599
596
  };
600
597
  var publishChangesToDurableStore = function () {
601
598
  validateNotDisposed();
@@ -738,15 +735,35 @@
738
735
  ingestStagingStore.records = existingRecords;
739
736
  }
740
737
  var snapshotFromMemoryIngest = ingestAndBroadcastFunc();
741
- if (snapshotFromMemoryIngest === undefined) {
742
- return undefined;
743
- }
744
- if (snapshotFromMemoryIngest.state !== 'Unfulfilled') {
738
+ // now that ingestion is done flush staging store values to L2
739
+ return publishChangesToDurableStore().then(function () {
740
+ if (snapshotFromMemoryIngest === undefined) {
741
+ return undefined;
742
+ }
743
+ if (snapshotFromMemoryIngest.state !== 'Unfulfilled') {
744
+ return snapshotFromMemoryIngest;
745
+ }
746
+ // if snapshot from staging store lookup is unfulfilled then do an L2 lookup
747
+ return reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, function () {
748
+ return environment.storeLookup(snapshotFromMemoryIngest.select, environment.createSnapshot, snapshotFromMemoryIngest.refresh);
749
+ });
750
+ });
751
+ };
752
+ var handleErrorResponse = function (ingestAndBroadcastFunc) {
753
+ validateNotDisposed();
754
+ var snapshotFromMemoryIngest = ingestAndBroadcastFunc();
755
+ return publishChangesToDurableStore().then(function () {
745
756
  return snapshotFromMemoryIngest;
746
- }
747
- // if snapshot from staging store lookup is unfulfilled then do an L2 lookup
748
- return reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, function () {
749
- return environment.storeLookup(snapshotFromMemoryIngest.select, environment.createSnapshot, snapshotFromMemoryIngest.refresh);
757
+ });
758
+ };
759
+ var getNotifyChangeStoreEntries = function (keys) {
760
+ validateNotDisposed();
761
+ return durableStore.getEntries(keys, DefaultDurableSegment).then(function (durableRecords) {
762
+ var entries = {};
763
+ publishDurableStoreEntries(durableRecords, function (key, record) {
764
+ entries[key] = record;
765
+ }, function () { });
766
+ return entries;
750
767
  });
751
768
  };
752
769
  environment.defaultCachePolicy = engine.buildStaleWhileRevalidateImplementation(Number.MAX_SAFE_INTEGER);
@@ -772,6 +789,8 @@
772
789
  getIngestStagingStoreRecords: { value: getIngestStagingStoreRecords },
773
790
  getIngestStagingStoreMetadata: { value: getIngestStagingStoreMetadata },
774
791
  handleSuccessResponse: { value: handleSuccessResponse },
792
+ handleErrorResponse: { value: handleErrorResponse },
793
+ getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
775
794
  });
776
795
  }
777
796
 
@@ -1,4 +1,4 @@
1
- import { Luvio } from '@luvio/engine';
1
+ import type { Luvio } from '@luvio/engine';
2
2
  export declare const DURABLE_STORE_ERROR = "durable-store-error";
3
3
  export declare type InstrumentationFunction = Luvio['instrument'];
4
4
  export declare type DurableStoreRejectionHandler = (e: any) => void;
@@ -1,4 +1,4 @@
1
- import { Store } from '@luvio/engine';
2
- import { DurableStore } from '../DurableStore';
3
- import { DurableStoreRejectionHandler } from './error';
1
+ import type { Store } from '@luvio/engine';
2
+ import type { DurableStore } from '../DurableStore';
3
+ import type { DurableStoreRejectionHandler } from './error';
4
4
  export declare function flushStoreValuesToDurableStore(store: Store, durableStore: DurableStore, durableStoreErrorHandler: DurableStoreRejectionHandler): Promise<void>;
@@ -1,6 +1,6 @@
1
- import { Environment, Snapshot, UnAvailableSnapshot, StoreMetadata } from '@luvio/engine';
2
- import { DurableStore, DurableStoreEntries } from '../DurableStore';
3
- import { DurableStoreRejectionHandler } from './error';
1
+ import type { Environment, Snapshot, UnAvailableSnapshot, StoreMetadata } from '@luvio/engine';
2
+ import type { DurableStore, DurableStoreEntries } from '../DurableStore';
3
+ import type { DurableStoreRejectionHandler } from './error';
4
4
  declare type ObjectAsSet = {
5
5
  [key: string]: true;
6
6
  };
@@ -1,2 +1,2 @@
1
- import { StoreRecordError } from '@luvio/engine';
1
+ import type { StoreRecordError } from '@luvio/engine';
2
2
  export declare function isStoreEntryError(storeRecord: unknown): storeRecord is StoreRecordError;
@@ -1,7 +1,8 @@
1
- import { CacheKeySet, Environment, RecordSource, Snapshot, Store } from '@luvio/engine';
2
- import { DurableStore } from './DurableStore';
3
- import { InstrumentationFunction } from './makeDurable/error';
4
- import { TTLOverridesMap } from './DurableTTLStore';
1
+ import type { CacheKeySet, Environment, RecordSource, Snapshot } from '@luvio/engine';
2
+ import { Store } from '@luvio/engine';
3
+ import type { DurableStore } from './DurableStore';
4
+ import type { InstrumentationFunction } from './makeDurable/error';
5
+ import type { TTLOverridesMap } from './DurableTTLStore';
5
6
  export interface DurableEnvironment extends Environment {
6
7
  /**
7
8
  * Disposes the environment and detaches the durable store listener
@@ -1,2 +1,2 @@
1
- import { Selector } from '@luvio/engine';
1
+ import type { Selector } from '@luvio/engine';
2
2
  export declare function readPaginationKeysFromSelector(select?: Selector<unknown>): string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luvio/environments",
3
- "version": "0.73.2",
3
+ "version": "0.73.7",
4
4
  "description": "Luvio Environments",
5
5
  "main": "dist/umd/es2018/environments.js",
6
6
  "module": "dist/es/es2018/environments.js",
@@ -11,7 +11,8 @@
11
11
  "build": "rollup --config rollup.config.js",
12
12
  "watch": "yarn build --watch",
13
13
  "test": "jest",
14
- "test:debug": "node --inspect-brk ../../../node_modules/jest/bin/jest.js --config ./jest.config.js --runInBand"
14
+ "test:debug": "node --inspect-brk ../../../node_modules/jest/bin/jest.js --config ./jest.config.js --runInBand",
15
+ "test:size": "bundlesize"
15
16
  },
16
17
  "nx": {
17
18
  "targets": {
@@ -26,6 +27,13 @@
26
27
  "dist/"
27
28
  ],
28
29
  "dependencies": {
29
- "@luvio/engine": "0.73.2"
30
- }
30
+ "@luvio/engine": "0.73.7"
31
+ },
32
+ "bundlesize": [
33
+ {
34
+ "path": "./dist/es/es2018/environments.js",
35
+ "maxSize": "9 kB",
36
+ "compression": "brotli"
37
+ }
38
+ ]
31
39
  }