@travetto/model-memory 5.0.7 → 5.0.9

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 +8 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-memory",
3
- "version": "5.0.7",
3
+ "version": "5.0.9",
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": "^5.0.7",
29
- "@travetto/di": "^5.0.7",
30
- "@travetto/model": "^5.0.7",
31
- "@travetto/schema": "^5.0.7"
28
+ "@travetto/config": "^5.0.8",
29
+ "@travetto/di": "^5.0.8",
30
+ "@travetto/model": "^5.0.9",
31
+ "@travetto/schema": "^5.0.8"
32
32
  },
33
33
  "peerDependencies": {
34
- "@travetto/cli": "^5.0.7",
35
- "@travetto/test": "^5.0.7"
34
+ "@travetto/cli": "^5.0.8",
35
+ "@travetto/test": "^5.0.8"
36
36
  },
37
37
  "peerDependenciesMeta": {
38
38
  "@travetto/cli": {
package/src/service.ts CHANGED
@@ -233,7 +233,7 @@ export class MemoryModelService implements ModelCrudSupport, ModelBlobSupport, M
233
233
 
234
234
  // Blob Support
235
235
  async upsertBlob(location: string, input: BinaryInput, meta?: BlobMeta, overwrite = true): Promise<void> {
236
- if (!overwrite && await this.describeBlob(location).then(() => true, () => false)) {
236
+ if (!overwrite && await this.getBlobMeta(location).then(() => true, () => false)) {
237
237
  return;
238
238
  }
239
239
 
@@ -251,11 +251,11 @@ export class MemoryModelService implements ModelCrudSupport, ModelBlobSupport, M
251
251
  if (final) {
252
252
  buffer = Buffer.from(buffer.subarray(final.start, final.end + 1));
253
253
  }
254
- const meta = await this.describeBlob(location);
254
+ const meta = await this.getBlobMeta(location);
255
255
  return BinaryUtil.readableBlob(() => Readable.from(buffer), { ...meta, range: final });
256
256
  }
257
257
 
258
- async describeBlob(location: string): Promise<BlobMeta> {
258
+ async getBlobMeta(location: string): Promise<BlobMeta> {
259
259
  const metaContent = this.#find(ModelBlobMetaNamespace, location, 'notfound');
260
260
  const meta: BlobMeta = JSON.parse(metaContent.get(location)!.toString('utf8'));
261
261
  return meta;
@@ -272,6 +272,11 @@ export class MemoryModelService implements ModelCrudSupport, ModelBlobSupport, M
272
272
  }
273
273
  }
274
274
 
275
+ async updateBlobMeta(location: string, meta: BlobMeta): Promise<void> {
276
+ const metaContent = this.#getStore(ModelBlobMetaNamespace);
277
+ metaContent.set(location, Buffer.from(JSON.stringify(meta), 'utf8'));
278
+ }
279
+
275
280
  // Expiry
276
281
  async deleteExpired<T extends ModelType>(cls: Class<T>): Promise<number> {
277
282
  return ModelExpiryUtil.naiveDeleteExpired(this, cls);