@travetto/model-file 5.0.0-rc.11 → 5.0.0-rc.13
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/package.json +7 -7
- package/src/service.ts +5 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-file",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.13",
|
|
4
4
|
"description": "File system backing for the travetto model module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datastore",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"directory": "module/model-file"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@travetto/config": "^5.0.0-rc.
|
|
29
|
-
"@travetto/di": "^5.0.0-rc.
|
|
30
|
-
"@travetto/model": "^5.0.0-rc.
|
|
31
|
-
"@travetto/schema": "^5.0.0-rc.
|
|
28
|
+
"@travetto/config": "^5.0.0-rc.13",
|
|
29
|
+
"@travetto/di": "^5.0.0-rc.12",
|
|
30
|
+
"@travetto/model": "^5.0.0-rc.13",
|
|
31
|
+
"@travetto/schema": "^5.0.0-rc.13"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@travetto/cli": "^5.0.0-rc.
|
|
35
|
-
"@travetto/test": "^5.0.0-rc.
|
|
34
|
+
"@travetto/cli": "^5.0.0-rc.13",
|
|
35
|
+
"@travetto/test": "^5.0.0-rc.12"
|
|
36
36
|
},
|
|
37
37
|
"peerDependenciesMeta": {
|
|
38
38
|
"@travetto/cli": {
|
package/src/service.ts
CHANGED
|
@@ -10,12 +10,12 @@ import { Config } from '@travetto/config';
|
|
|
10
10
|
import { Required } from '@travetto/schema';
|
|
11
11
|
import {
|
|
12
12
|
ModelCrudSupport, ModelExpirySupport, ModelStorageSupport, ModelType, ModelRegistry,
|
|
13
|
-
NotFoundError, OptionalId, ExistsError, ModelBlobSupport
|
|
13
|
+
NotFoundError, OptionalId, ExistsError, ModelBlobSupport
|
|
14
14
|
} from '@travetto/model';
|
|
15
15
|
|
|
16
16
|
import { ModelCrudUtil } from '@travetto/model/src/internal/service/crud';
|
|
17
17
|
import { ModelExpiryUtil } from '@travetto/model/src/internal/service/expiry';
|
|
18
|
-
import { MODEL_BLOB, ModelBlobNamespace } from '@travetto/model/src/internal/service/blob';
|
|
18
|
+
import { MODEL_BLOB, ModelBlobNamespace, ModelBlobUtil } from '@travetto/model/src/internal/service/blob';
|
|
19
19
|
|
|
20
20
|
type Suffix = '.bin' | '.meta' | '.json' | '.expires';
|
|
21
21
|
|
|
@@ -169,15 +169,11 @@ export class FileModelService implements ModelCrudSupport, ModelBlobSupport, Mod
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
// Blob
|
|
172
|
-
async
|
|
173
|
-
await this.describeBlob(location)
|
|
174
|
-
|
|
175
|
-
throw new ExistsError(ModelBlobNamespace, location);
|
|
172
|
+
async upsertBlob(location: string, input: BinaryInput, meta?: BlobMeta, overwrite = true): Promise<void> {
|
|
173
|
+
if (!overwrite && await this.describeBlob(location).then(() => true, () => false)) {
|
|
174
|
+
return;
|
|
176
175
|
}
|
|
177
|
-
return this.upsertBlob(location, input, meta);
|
|
178
|
-
}
|
|
179
176
|
|
|
180
|
-
async upsertBlob(location: string, input: BinaryInput, meta?: BlobMeta): Promise<void> {
|
|
181
177
|
const [stream, blobMeta] = await ModelBlobUtil.getInput(input, meta);
|
|
182
178
|
const file = await this.#resolveName(ModelBlobNamespace, BIN, location);
|
|
183
179
|
await Promise.all([
|