@luvio/environments 0.111.3 → 0.112.1
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/es/es2018/DurableStore.d.ts +7 -7
- package/dist/es/es2018/environments.js +24 -5
- package/dist/es/es2018/main.d.ts +1 -1
- package/dist/umd/es2018/DurableStore.d.ts +7 -7
- package/dist/umd/es2018/environments.js +24 -4
- package/dist/umd/es2018/main.d.ts +1 -1
- package/dist/umd/es5/DurableStore.d.ts +7 -7
- package/dist/umd/es5/environments.js +21 -4
- package/dist/umd/es5/main.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { StoreMetadata } from '@luvio/engine';
|
|
2
|
+
export declare const DURABLE_METADATA_VERSION = "0.111.0";
|
|
3
|
+
interface DurableStoreMetadata extends StoreMetadata {
|
|
4
|
+
metadataVersion: string;
|
|
5
|
+
}
|
|
1
6
|
/**
|
|
2
7
|
* Contains store entry data along with any metadata for that entry that needs
|
|
3
8
|
* to be persisted to durable storage
|
|
@@ -9,13 +14,7 @@
|
|
|
9
14
|
*/
|
|
10
15
|
export interface DurableStoreEntry<T = unknown> {
|
|
11
16
|
data: T;
|
|
12
|
-
metadata?:
|
|
13
|
-
ingestionTimestamp: number;
|
|
14
|
-
expirationTimestamp: number;
|
|
15
|
-
namespace: string;
|
|
16
|
-
version: string;
|
|
17
|
-
representationName: string;
|
|
18
|
-
};
|
|
17
|
+
metadata?: DurableStoreMetadata;
|
|
19
18
|
}
|
|
20
19
|
export declare function isDeprecatedDurableStoreEntry(durableRecord: unknown): boolean;
|
|
21
20
|
export interface DeprecatedDurableStoreEntry1<T = unknown> {
|
|
@@ -131,3 +130,4 @@ export interface DurableStore {
|
|
|
131
130
|
*/
|
|
132
131
|
registerOnChangedListener(listener: OnDurableStoreChangedListener): () => Promise<void>;
|
|
133
132
|
}
|
|
133
|
+
export {};
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { emitAdapterEvent, InMemoryStore, buildStaleWhileRevalidateImplementation, Reader } from '@luvio/engine';
|
|
2
2
|
|
|
3
|
+
// the last version the metadata shape was altered
|
|
4
|
+
const DURABLE_METADATA_VERSION = '0.111.0';
|
|
3
5
|
function isDeprecatedDurableStoreEntry(durableRecord) {
|
|
4
6
|
if (durableRecord.expiration !== undefined) {
|
|
5
7
|
return true;
|
|
6
8
|
}
|
|
9
|
+
const metadata = durableRecord.metadata;
|
|
10
|
+
if (metadata !== undefined) {
|
|
11
|
+
const { metadataVersion } = metadata;
|
|
12
|
+
// eventually we will want to assert that metadataVersion is defined
|
|
13
|
+
if (metadataVersion !== undefined && metadataVersion !== DURABLE_METADATA_VERSION) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
7
17
|
// Add more deprecated shape checks here
|
|
8
18
|
return false;
|
|
9
19
|
}
|
|
@@ -297,7 +307,10 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
|
|
|
297
307
|
data: copy(record),
|
|
298
308
|
};
|
|
299
309
|
if (metadata !== undefined) {
|
|
300
|
-
durableRecords[key].metadata =
|
|
310
|
+
durableRecords[key].metadata = {
|
|
311
|
+
...metadata,
|
|
312
|
+
metadataVersion: DURABLE_METADATA_VERSION,
|
|
313
|
+
};
|
|
301
314
|
}
|
|
302
315
|
}
|
|
303
316
|
const durableStoreOperations = [];
|
|
@@ -357,7 +370,7 @@ async function reviveTTLOverrides(ttlStore, environment) {
|
|
|
357
370
|
function buildIngestStagingStore(environment) {
|
|
358
371
|
const store = new InMemoryStore();
|
|
359
372
|
// need to make sure any TTL overrides are brought over from real L1
|
|
360
|
-
// because
|
|
373
|
+
// because publishStoreMetadata uses those overrides
|
|
361
374
|
store.ttlOverrides = environment.storeGetTTLOverrides();
|
|
362
375
|
store.defaultTTLOverride = environment.storeGetDefaultTTLOverride();
|
|
363
376
|
return store;
|
|
@@ -617,9 +630,15 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
617
630
|
};
|
|
618
631
|
const withContext = function (adapter, options) {
|
|
619
632
|
validateNotDisposed();
|
|
620
|
-
const { contextId, onContextLoaded } = options;
|
|
633
|
+
const { contextId, contextVersion, onContextLoaded } = options;
|
|
621
634
|
let context = undefined;
|
|
622
|
-
|
|
635
|
+
let contextKey = `${contextId}`;
|
|
636
|
+
// if a context version is supplied, key with the version encoded
|
|
637
|
+
if (contextVersion !== undefined) {
|
|
638
|
+
contextKey += `::${contextVersion}`;
|
|
639
|
+
}
|
|
640
|
+
contextKey += ADAPTER_CONTEXT_ID_SUFFIX;
|
|
641
|
+
const contextAsPromise = reviveOrCreateContext(contextKey, durableStore, durableStoreErrorHandler, contextStores, pendingContextStoreKeys, onContextLoaded);
|
|
623
642
|
return (config, requestContext) => {
|
|
624
643
|
if (context === undefined) {
|
|
625
644
|
return contextAsPromise.then((revivedContext) => {
|
|
@@ -844,4 +863,4 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
844
863
|
});
|
|
845
864
|
}
|
|
846
865
|
|
|
847
|
-
export { DefaultDurableSegment, isDurableEnvironmentEvent, makeDurable, publishDurableStoreEntries };
|
|
866
|
+
export { DURABLE_METADATA_VERSION, DefaultDurableSegment, isDurableEnvironmentEvent, makeDurable, publishDurableStoreEntries };
|
package/dist/es/es2018/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DurableStore, DurableStoreEntries, DurableStoreEntry, DurableStoreChange, OnDurableStoreChangedListener, DefaultDurableSegment, DurableStoreOperation, DurableStoreOperationType, } from './DurableStore';
|
|
1
|
+
export { DurableStore, DurableStoreEntries, DurableStoreEntry, DurableStoreChange, OnDurableStoreChangedListener, DefaultDurableSegment, DurableStoreOperation, DurableStoreOperationType, DURABLE_METADATA_VERSION, } from './DurableStore';
|
|
2
2
|
export { DurableTTLOverride, DefaultDurableTTLOverride } from './DurableTTLStore';
|
|
3
3
|
export { makeDurable, DurableEnvironment } from './makeDurable';
|
|
4
4
|
export { publishDurableStoreEntries } from './makeDurable/revive';
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { StoreMetadata } from '@luvio/engine';
|
|
2
|
+
export declare const DURABLE_METADATA_VERSION = "0.111.0";
|
|
3
|
+
interface DurableStoreMetadata extends StoreMetadata {
|
|
4
|
+
metadataVersion: string;
|
|
5
|
+
}
|
|
1
6
|
/**
|
|
2
7
|
* Contains store entry data along with any metadata for that entry that needs
|
|
3
8
|
* to be persisted to durable storage
|
|
@@ -9,13 +14,7 @@
|
|
|
9
14
|
*/
|
|
10
15
|
export interface DurableStoreEntry<T = unknown> {
|
|
11
16
|
data: T;
|
|
12
|
-
metadata?:
|
|
13
|
-
ingestionTimestamp: number;
|
|
14
|
-
expirationTimestamp: number;
|
|
15
|
-
namespace: string;
|
|
16
|
-
version: string;
|
|
17
|
-
representationName: string;
|
|
18
|
-
};
|
|
17
|
+
metadata?: DurableStoreMetadata;
|
|
19
18
|
}
|
|
20
19
|
export declare function isDeprecatedDurableStoreEntry(durableRecord: unknown): boolean;
|
|
21
20
|
export interface DeprecatedDurableStoreEntry1<T = unknown> {
|
|
@@ -131,3 +130,4 @@ export interface DurableStore {
|
|
|
131
130
|
*/
|
|
132
131
|
registerOnChangedListener(listener: OnDurableStoreChangedListener): () => Promise<void>;
|
|
133
132
|
}
|
|
133
|
+
export {};
|
|
@@ -4,10 +4,20 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.luvioEnvironments = {}, global.luvioEngine));
|
|
5
5
|
})(this, (function (exports, engine) { 'use strict';
|
|
6
6
|
|
|
7
|
+
// the last version the metadata shape was altered
|
|
8
|
+
const DURABLE_METADATA_VERSION = '0.111.0';
|
|
7
9
|
function isDeprecatedDurableStoreEntry(durableRecord) {
|
|
8
10
|
if (durableRecord.expiration !== undefined) {
|
|
9
11
|
return true;
|
|
10
12
|
}
|
|
13
|
+
const metadata = durableRecord.metadata;
|
|
14
|
+
if (metadata !== undefined) {
|
|
15
|
+
const { metadataVersion } = metadata;
|
|
16
|
+
// eventually we will want to assert that metadataVersion is defined
|
|
17
|
+
if (metadataVersion !== undefined && metadataVersion !== DURABLE_METADATA_VERSION) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
11
21
|
// Add more deprecated shape checks here
|
|
12
22
|
return false;
|
|
13
23
|
}
|
|
@@ -301,7 +311,10 @@
|
|
|
301
311
|
data: copy(record),
|
|
302
312
|
};
|
|
303
313
|
if (metadata !== undefined) {
|
|
304
|
-
durableRecords[key].metadata =
|
|
314
|
+
durableRecords[key].metadata = {
|
|
315
|
+
...metadata,
|
|
316
|
+
metadataVersion: DURABLE_METADATA_VERSION,
|
|
317
|
+
};
|
|
305
318
|
}
|
|
306
319
|
}
|
|
307
320
|
const durableStoreOperations = [];
|
|
@@ -361,7 +374,7 @@
|
|
|
361
374
|
function buildIngestStagingStore(environment) {
|
|
362
375
|
const store = new engine.InMemoryStore();
|
|
363
376
|
// need to make sure any TTL overrides are brought over from real L1
|
|
364
|
-
// because
|
|
377
|
+
// because publishStoreMetadata uses those overrides
|
|
365
378
|
store.ttlOverrides = environment.storeGetTTLOverrides();
|
|
366
379
|
store.defaultTTLOverride = environment.storeGetDefaultTTLOverride();
|
|
367
380
|
return store;
|
|
@@ -621,9 +634,15 @@
|
|
|
621
634
|
};
|
|
622
635
|
const withContext = function (adapter, options) {
|
|
623
636
|
validateNotDisposed();
|
|
624
|
-
const { contextId, onContextLoaded } = options;
|
|
637
|
+
const { contextId, contextVersion, onContextLoaded } = options;
|
|
625
638
|
let context = undefined;
|
|
626
|
-
|
|
639
|
+
let contextKey = `${contextId}`;
|
|
640
|
+
// if a context version is supplied, key with the version encoded
|
|
641
|
+
if (contextVersion !== undefined) {
|
|
642
|
+
contextKey += `::${contextVersion}`;
|
|
643
|
+
}
|
|
644
|
+
contextKey += ADAPTER_CONTEXT_ID_SUFFIX;
|
|
645
|
+
const contextAsPromise = reviveOrCreateContext(contextKey, durableStore, durableStoreErrorHandler, contextStores, pendingContextStoreKeys, onContextLoaded);
|
|
627
646
|
return (config, requestContext) => {
|
|
628
647
|
if (context === undefined) {
|
|
629
648
|
return contextAsPromise.then((revivedContext) => {
|
|
@@ -848,6 +867,7 @@
|
|
|
848
867
|
});
|
|
849
868
|
}
|
|
850
869
|
|
|
870
|
+
exports.DURABLE_METADATA_VERSION = DURABLE_METADATA_VERSION;
|
|
851
871
|
exports.DefaultDurableSegment = DefaultDurableSegment;
|
|
852
872
|
exports.isDurableEnvironmentEvent = isDurableEnvironmentEvent;
|
|
853
873
|
exports.makeDurable = makeDurable;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DurableStore, DurableStoreEntries, DurableStoreEntry, DurableStoreChange, OnDurableStoreChangedListener, DefaultDurableSegment, DurableStoreOperation, DurableStoreOperationType, } from './DurableStore';
|
|
1
|
+
export { DurableStore, DurableStoreEntries, DurableStoreEntry, DurableStoreChange, OnDurableStoreChangedListener, DefaultDurableSegment, DurableStoreOperation, DurableStoreOperationType, DURABLE_METADATA_VERSION, } from './DurableStore';
|
|
2
2
|
export { DurableTTLOverride, DefaultDurableTTLOverride } from './DurableTTLStore';
|
|
3
3
|
export { makeDurable, DurableEnvironment } from './makeDurable';
|
|
4
4
|
export { publishDurableStoreEntries } from './makeDurable/revive';
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { StoreMetadata } from '@luvio/engine';
|
|
2
|
+
export declare const DURABLE_METADATA_VERSION = "0.111.0";
|
|
3
|
+
interface DurableStoreMetadata extends StoreMetadata {
|
|
4
|
+
metadataVersion: string;
|
|
5
|
+
}
|
|
1
6
|
/**
|
|
2
7
|
* Contains store entry data along with any metadata for that entry that needs
|
|
3
8
|
* to be persisted to durable storage
|
|
@@ -9,13 +14,7 @@
|
|
|
9
14
|
*/
|
|
10
15
|
export interface DurableStoreEntry<T = unknown> {
|
|
11
16
|
data: T;
|
|
12
|
-
metadata?:
|
|
13
|
-
ingestionTimestamp: number;
|
|
14
|
-
expirationTimestamp: number;
|
|
15
|
-
namespace: string;
|
|
16
|
-
version: string;
|
|
17
|
-
representationName: string;
|
|
18
|
-
};
|
|
17
|
+
metadata?: DurableStoreMetadata;
|
|
19
18
|
}
|
|
20
19
|
export declare function isDeprecatedDurableStoreEntry(durableRecord: unknown): boolean;
|
|
21
20
|
export interface DeprecatedDurableStoreEntry1<T = unknown> {
|
|
@@ -131,3 +130,4 @@ export interface DurableStore {
|
|
|
131
130
|
*/
|
|
132
131
|
registerOnChangedListener(listener: OnDurableStoreChangedListener): () => Promise<void>;
|
|
133
132
|
}
|
|
133
|
+
export {};
|
|
@@ -4,10 +4,20 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.luvioEnvironments = {}, global.luvioEngine));
|
|
5
5
|
})(this, (function (exports, engine) { 'use strict';
|
|
6
6
|
|
|
7
|
+
// the last version the metadata shape was altered
|
|
8
|
+
var DURABLE_METADATA_VERSION = '0.111.0';
|
|
7
9
|
function isDeprecatedDurableStoreEntry(durableRecord) {
|
|
8
10
|
if (durableRecord.expiration !== undefined) {
|
|
9
11
|
return true;
|
|
10
12
|
}
|
|
13
|
+
var metadata = durableRecord.metadata;
|
|
14
|
+
if (metadata !== undefined) {
|
|
15
|
+
var metadataVersion = metadata.metadataVersion;
|
|
16
|
+
// eventually we will want to assert that metadataVersion is defined
|
|
17
|
+
if (metadataVersion !== undefined && metadataVersion !== DURABLE_METADATA_VERSION) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
11
21
|
// Add more deprecated shape checks here
|
|
12
22
|
return false;
|
|
13
23
|
}
|
|
@@ -382,7 +392,7 @@
|
|
|
382
392
|
data: copy(record),
|
|
383
393
|
};
|
|
384
394
|
if (metadata !== undefined) {
|
|
385
|
-
durableRecords[key].metadata =
|
|
395
|
+
durableRecords[key].metadata = __assign(__assign({}, metadata), { metadataVersion: DURABLE_METADATA_VERSION });
|
|
386
396
|
}
|
|
387
397
|
}
|
|
388
398
|
var durableStoreOperations = [];
|
|
@@ -452,7 +462,7 @@
|
|
|
452
462
|
function buildIngestStagingStore(environment) {
|
|
453
463
|
var store = new engine.InMemoryStore();
|
|
454
464
|
// need to make sure any TTL overrides are brought over from real L1
|
|
455
|
-
// because
|
|
465
|
+
// because publishStoreMetadata uses those overrides
|
|
456
466
|
store.ttlOverrides = environment.storeGetTTLOverrides();
|
|
457
467
|
store.defaultTTLOverride = environment.storeGetDefaultTTLOverride();
|
|
458
468
|
return store;
|
|
@@ -726,9 +736,15 @@
|
|
|
726
736
|
};
|
|
727
737
|
var withContext = function (adapter, options) {
|
|
728
738
|
validateNotDisposed();
|
|
729
|
-
var contextId = options.contextId, onContextLoaded = options.onContextLoaded;
|
|
739
|
+
var contextId = options.contextId, contextVersion = options.contextVersion, onContextLoaded = options.onContextLoaded;
|
|
730
740
|
var context = undefined;
|
|
731
|
-
var
|
|
741
|
+
var contextKey = "".concat(contextId);
|
|
742
|
+
// if a context version is supplied, key with the version encoded
|
|
743
|
+
if (contextVersion !== undefined) {
|
|
744
|
+
contextKey += "::".concat(contextVersion);
|
|
745
|
+
}
|
|
746
|
+
contextKey += ADAPTER_CONTEXT_ID_SUFFIX;
|
|
747
|
+
var contextAsPromise = reviveOrCreateContext(contextKey, durableStore, durableStoreErrorHandler, contextStores, pendingContextStoreKeys, onContextLoaded);
|
|
732
748
|
return function (config, requestContext) {
|
|
733
749
|
if (context === undefined) {
|
|
734
750
|
return contextAsPromise.then(function (revivedContext) {
|
|
@@ -991,6 +1007,7 @@
|
|
|
991
1007
|
});
|
|
992
1008
|
}
|
|
993
1009
|
|
|
1010
|
+
exports.DURABLE_METADATA_VERSION = DURABLE_METADATA_VERSION;
|
|
994
1011
|
exports.DefaultDurableSegment = DefaultDurableSegment;
|
|
995
1012
|
exports.isDurableEnvironmentEvent = isDurableEnvironmentEvent;
|
|
996
1013
|
exports.makeDurable = makeDurable;
|
package/dist/umd/es5/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DurableStore, DurableStoreEntries, DurableStoreEntry, DurableStoreChange, OnDurableStoreChangedListener, DefaultDurableSegment, DurableStoreOperation, DurableStoreOperationType, } from './DurableStore';
|
|
1
|
+
export { DurableStore, DurableStoreEntries, DurableStoreEntry, DurableStoreChange, OnDurableStoreChangedListener, DefaultDurableSegment, DurableStoreOperation, DurableStoreOperationType, DURABLE_METADATA_VERSION, } from './DurableStore';
|
|
2
2
|
export { DurableTTLOverride, DefaultDurableTTLOverride } from './DurableTTLStore';
|
|
3
3
|
export { makeDurable, DurableEnvironment } from './makeDurable';
|
|
4
4
|
export { publishDurableStoreEntries } from './makeDurable/revive';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luvio/environments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.112.1",
|
|
4
4
|
"description": "Luvio Environments",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"watch": "yarn build --watch"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@luvio/engine": "0.
|
|
26
|
+
"@luvio/engine": "0.112.1"
|
|
27
27
|
},
|
|
28
28
|
"bundlesize": [
|
|
29
29
|
{
|