@travetto/model-memory 7.0.0-rc.2 → 7.0.0-rc.4

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 (2) hide show
  1. package/package.json +7 -7
  2. package/src/service.ts +5 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-memory",
3
- "version": "7.0.0-rc.2",
3
+ "version": "7.0.0-rc.4",
4
4
  "description": "Memory backing for the travetto model module.",
5
5
  "keywords": [
6
6
  "datastore",
@@ -25,14 +25,14 @@
25
25
  "directory": "module/model-memory"
26
26
  },
27
27
  "dependencies": {
28
- "@travetto/config": "^7.0.0-rc.2",
29
- "@travetto/di": "^7.0.0-rc.2",
30
- "@travetto/model": "^7.0.0-rc.2",
31
- "@travetto/schema": "^7.0.0-rc.2"
28
+ "@travetto/config": "^7.0.0-rc.4",
29
+ "@travetto/di": "^7.0.0-rc.4",
30
+ "@travetto/model": "^7.0.0-rc.4",
31
+ "@travetto/schema": "^7.0.0-rc.4"
32
32
  },
33
33
  "peerDependencies": {
34
- "@travetto/cli": "^7.0.0-rc.2",
35
- "@travetto/test": "^7.0.0-rc.2"
34
+ "@travetto/cli": "^7.0.0-rc.4",
35
+ "@travetto/test": "^7.0.0-rc.4"
36
36
  },
37
37
  "peerDependenciesMeta": {
38
38
  "@travetto/cli": {
package/src/service.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Readable } from 'node:stream';
2
2
  import { buffer as toBuffer } from 'node:stream/consumers';
3
3
 
4
- import { Class, TimeSpan, DeepPartial, castTo, BlobMeta, ByteRange, BinaryInput, BinaryUtil } from '@travetto/runtime';
4
+ import { Class, TimeSpan, DeepPartial, castTo, BlobMeta, ByteRange, BinaryInput, BinaryUtil, JSONUtil } from '@travetto/runtime';
5
5
  import { Injectable } from '@travetto/di';
6
6
  import { Config } from '@travetto/config';
7
7
  import {
@@ -17,7 +17,7 @@ type StoreType = Map<string, Buffer>;
17
17
 
18
18
  @Config('model.memory')
19
19
  export class MemoryModelConfig {
20
- autoCreate?: boolean = true;
20
+ modifyStorage?: boolean = true;
21
21
  namespace?: string;
22
22
  cullRate?: number | TimeSpan;
23
23
  }
@@ -146,7 +146,7 @@ export class MemoryModelService implements ModelCrudSupport, ModelBlobSupport, M
146
146
  }
147
147
 
148
148
  async postConstruct(): Promise<void> {
149
- await ModelStorageUtil.registerModelChangeListener(this);
149
+ await ModelStorageUtil.storageInitialization(this);
150
150
  ModelExpiryUtil.registerCull(this);
151
151
 
152
152
  for (const cls of ModelRegistryIndex.getClasses()) {
@@ -255,7 +255,7 @@ export class MemoryModelService implements ModelCrudSupport, ModelBlobSupport, M
255
255
 
256
256
  async getBlobMeta(location: string): Promise<BlobMeta> {
257
257
  const metaContent = this.#find(ModelBlobMetaNamespace, location, 'notfound');
258
- const meta: BlobMeta = JSON.parse(metaContent.get(location)!.toString('utf8'));
258
+ const meta: BlobMeta = JSONUtil.parseSafe(metaContent.get(location)!);
259
259
  return meta;
260
260
  }
261
261
 
@@ -301,7 +301,7 @@ export class MemoryModelService implements ModelCrudSupport, ModelBlobSupport, M
301
301
  this.#indices.unsorted.clear();
302
302
  }
303
303
 
304
- async createModel<T extends ModelType>(cls: Class<T>): Promise<void> {
304
+ async upsertModel<T extends ModelType>(cls: Class<T>): Promise<void> {
305
305
  for (const idx of ModelRegistryIndex.getConfig(cls).indices ?? []) {
306
306
  if (idx.type === 'sorted' || idx.type === 'unsorted') {
307
307
  this.#indices[idx.type].set(indexName(cls, idx), new Map());