@travetto/model-s3 6.0.1 → 7.0.0-rc.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/README.md CHANGED
@@ -55,7 +55,6 @@ export class S3ModelConfig {
55
55
  @EnvVar('AWS_PROFILE')
56
56
  profile?: string;
57
57
 
58
- @Field(Object)
59
58
  @Required(false)
60
59
  config: s3.S3ClientConfig; // Additional s3 config
61
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-s3",
3
- "version": "6.0.1",
3
+ "version": "7.0.0-rc.1",
4
4
  "description": "S3 backing for the travetto model module.",
5
5
  "keywords": [
6
6
  "s3",
@@ -25,12 +25,12 @@
25
25
  "directory": "module/model-s3"
26
26
  },
27
27
  "dependencies": {
28
- "@aws-sdk/client-s3": "^3.901.0",
29
- "@aws-sdk/credential-provider-ini": "^3.901.0",
30
- "@aws-sdk/s3-request-presigner": "^3.901.0",
31
- "@travetto/cli": "^6.0.1",
32
- "@travetto/config": "^6.0.1",
33
- "@travetto/model": "^6.0.1"
28
+ "@aws-sdk/client-s3": "^3.940.0",
29
+ "@aws-sdk/credential-provider-ini": "^3.940.0",
30
+ "@aws-sdk/s3-request-presigner": "^3.940.0",
31
+ "@travetto/cli": "^7.0.0-rc.1",
32
+ "@travetto/config": "^7.0.0-rc.1",
33
+ "@travetto/model": "^7.0.0-rc.1"
34
34
  },
35
35
  "travetto": {
36
36
  "displayName": "S3 Model Support"
package/src/config.ts CHANGED
@@ -2,7 +2,7 @@ import { fromIni } from '@aws-sdk/credential-provider-ini';
2
2
  import type s3 from '@aws-sdk/client-s3';
3
3
 
4
4
  import { Config, EnvVar } from '@travetto/config';
5
- import { Field, Required } from '@travetto/schema';
5
+ import { Required } from '@travetto/schema';
6
6
  import { Runtime } from '@travetto/runtime';
7
7
 
8
8
  /**
@@ -22,7 +22,6 @@ export class S3ModelConfig {
22
22
  @EnvVar('AWS_PROFILE')
23
23
  profile?: string;
24
24
 
25
- @Field(Object)
26
25
  @Required(false)
27
26
  config: s3.S3ClientConfig; // Additional s3 config
28
27
 
package/src/service.ts CHANGED
@@ -8,9 +8,8 @@ import { NodeHttpHandler } from '@smithy/node-http-handler';
8
8
  import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
9
9
 
10
10
  import {
11
- ModelCrudSupport, ModelStorageSupport, ModelType, ModelRegistry, ExistsError, NotFoundError, OptionalId,
11
+ ModelCrudSupport, ModelStorageSupport, ModelType, ModelRegistryIndex, ExistsError, NotFoundError, OptionalId,
12
12
  ModelBlobSupport, ModelExpirySupport, ModelBlobUtil, ModelCrudUtil, ModelExpiryUtil, ModelStorageUtil,
13
-
14
13
  } from '@travetto/model';
15
14
  import { Injectable } from '@travetto/di';
16
15
  import { Class, AppError, castTo, asFull, BlobMeta, ByteRange, BinaryInput, BinaryUtil, TimeSpan, TimeUtil } from '@travetto/runtime';
@@ -65,7 +64,7 @@ export class S3ModelService implements ModelCrudSupport, ModelBlobSupport, Model
65
64
  }
66
65
 
67
66
  #resolveKey(cls: Class | string, id?: string): string {
68
- let key = typeof cls === 'string' ? cls : ModelRegistry.getStore(cls);
67
+ let key = typeof cls === 'string' ? cls : ModelRegistryIndex.getStoreName(cls);
69
68
  if (id) {
70
69
  key = `${key}:${id}`;
71
70
  }
@@ -85,7 +84,7 @@ export class S3ModelService implements ModelCrudSupport, ModelBlobSupport, Model
85
84
 
86
85
 
87
86
  #getExpiryConfig<T extends ModelType>(cls: Class<T>, item: T): { Expires?: Date } {
88
- if (ModelRegistry.get(cls).expiresAt) {
87
+ if (ModelRegistryIndex.getConfig(cls).expiresAt) {
89
88
  const { expiresAt } = ModelExpiryUtil.getExpiryState(cls, item);
90
89
  if (expiresAt) {
91
90
  return { Expires: expiresAt };
@@ -197,8 +196,8 @@ export class S3ModelService implements ModelCrudSupport, ModelBlobSupport, Model
197
196
  async head<T extends ModelType>(cls: Class<T>, id: string): Promise<boolean> {
198
197
  try {
199
198
  const result = await this.client.headObject(this.#q(cls, id));
200
- const { expiresAt } = ModelRegistry.get(cls);
201
- if (expiresAt && result.Expires && result.Expires.getTime() < Date.now()) {
199
+ const { expiresAt } = ModelRegistryIndex.getConfig(cls);
200
+ if (expiresAt && result.ExpiresString && Date.parse(result.ExpiresString) < Date.now()) {
202
201
  return false;
203
202
  }
204
203
  return true;
@@ -219,7 +218,7 @@ export class S3ModelService implements ModelCrudSupport, ModelBlobSupport, Model
219
218
  const body = await toText(castTo(result.Body));
220
219
  const output = await ModelCrudUtil.load(cls, body);
221
220
  if (output) {
222
- const { expiresAt } = ModelRegistry.get(cls);
221
+ const { expiresAt } = ModelRegistryIndex.getConfig(cls);
223
222
  if (expiresAt) {
224
223
  const expiry = ModelExpiryUtil.getExpiryState(cls, output);
225
224
  if (!expiry.expired) {
@@ -1,6 +1,6 @@
1
1
  import type { ServiceDescriptor } from '@travetto/cli';
2
2
 
3
- const version = '4.8.0';
3
+ const version = '4.10.0';
4
4
 
5
5
  export const service: ServiceDescriptor = {
6
6
  name: 's3',