@hot-updater/aws 0.36.6 → 1.0.0-rc.0

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/index.d.cts CHANGED
@@ -1,44 +1,19 @@
1
1
  import * as _$_hot_updater_plugin_core0 from "@hot-updater/plugin-core";
2
- import { RuntimeStoragePlugin, StoragePluginHooks, StorageResolveContext } from "@hot-updater/plugin-core";
2
+ import { StoragePlugin, StoragePluginWith } from "@hot-updater/plugin-core";
3
+ import { DynamoDBClientConfig } from "@aws-sdk/client-dynamodb";
3
4
  import { S3ClientConfig } from "@aws-sdk/client-s3";
4
5
 
5
- //#region src/s3Database.d.ts
6
- interface S3DatabaseConfig extends S3ClientConfig {
7
- bucketName: string;
8
- /**
9
- * Base path where database objects will be stored in the bucket.
10
- */
11
- basePath?: string;
12
- /**
13
- * CloudFront distribution ID used for cache invalidation.
14
- *
15
- * If omitted or an empty string, CloudFront invalidation is skipped.
16
- * This is useful for local development environments (e.g. Localstack)
17
- * where CloudFront is not available.
18
- */
19
- cloudfrontDistributionId?: string;
20
- /**
21
- * Wait for CloudFront invalidations to reach `Completed` before finishing.
22
- *
23
- * When enabled, invalidation failures and timeouts are surfaced to callers
24
- * instead of being logged and ignored.
25
- */
26
- shouldWaitForInvalidation?: boolean;
27
- apiBasePath?: string;
6
+ //#region src/dynamoDB.d.ts
7
+ declare const DYNAMODB_UPDATE_INDEX_NAME = "hot-updater-update-index";
8
+ interface DynamoDBConfig extends DynamoDBClientConfig {
9
+ readonly apiBasePath?: string;
10
+ readonly cloudfrontDistributionId?: string;
11
+ readonly shouldWaitForInvalidation?: boolean;
12
+ readonly tableName: string;
28
13
  }
29
- declare const s3Database: (config: S3DatabaseConfig, hooks?: _$_hot_updater_plugin_core0.DatabasePluginHooks) => () => _$_hot_updater_plugin_core0.DatabasePlugin<unknown>;
14
+ declare const dynamoDB: (config: DynamoDBConfig) => _$_hot_updater_plugin_core0.DatabasePlugin;
30
15
  //#endregion
31
- //#region src/s3Storage.d.ts
32
- interface S3StorageConfig extends S3ClientConfig {
33
- bucketName: string;
34
- /**
35
- * Base path where bundles will be stored in the bucket
36
- */
37
- basePath?: string;
38
- }
39
- declare const s3Storage: (config: S3StorageConfig, hooks?: _$_hot_updater_plugin_core0.StoragePluginHooks) => () => _$_hot_updater_plugin_core0.UniversalStoragePlugin<unknown>;
40
- //#endregion
41
- //#region src/withCloudFrontSignedUrl.d.ts
16
+ //#region src/cloudFrontDownloadUrl.d.ts
42
17
  interface CloudFrontPrivateKeyFromGetter {
43
18
  getPrivateKey: () => Promise<string>;
44
19
  ssmParameterName?: never;
@@ -49,18 +24,34 @@ interface CloudFrontPrivateKeyFromSsm {
49
24
  ssmParameterName: string;
50
25
  ssmRegion: string;
51
26
  }
52
- type PublicBaseUrlResolver<TContext = unknown> = (context?: StorageResolveContext<TContext>) => string | Promise<string>;
53
- type CloudFrontSignedUrlConfig = CloudFrontPrivateKeyFromGetter | CloudFrontPrivateKeyFromSsm;
54
- type WithCloudFrontSignedUrlOptions<TContext = unknown> = CloudFrontSignedUrlConfig & {
27
+ type CloudFrontDownloadUrlOptions = (CloudFrontPrivateKeyFromGetter | CloudFrontPrivateKeyFromSsm) & {
55
28
  keyPairId: string;
56
- publicBaseUrl: string | PublicBaseUrlResolver<TContext>;
29
+ publicBaseUrl: string;
57
30
  expiresSeconds?: number;
58
31
  };
59
- declare const withCloudFrontSignedUrl: <TContext = unknown, TStorage extends RuntimeStoragePlugin<TContext> = RuntimeStoragePlugin<TContext>>(storageFactory: () => TStorage, config: WithCloudFrontSignedUrlOptions<TContext>) => () => TStorage;
32
+ declare const cloudFrontDownloadUrl: (config: CloudFrontDownloadUrlOptions) => ({
33
+ storageUri
34
+ }: {
35
+ storageUri: string;
36
+ }) => Promise<{
37
+ url: string;
38
+ }>;
60
39
  //#endregion
61
- //#region src/s3LambdaEdgeStorage.d.ts
62
- type AwsLambdaEdgeStorageConfig = S3StorageConfig & WithCloudFrontSignedUrlOptions;
63
- declare const awsLambdaEdgeStorage: (config: AwsLambdaEdgeStorageConfig, hooks?: StoragePluginHooks) => () => _$_hot_updater_plugin_core0.UniversalStoragePlugin<unknown>;
64
- declare const s3LambdaEdgeStorage: (config: AwsLambdaEdgeStorageConfig, hooks?: StoragePluginHooks) => () => _$_hot_updater_plugin_core0.UniversalStoragePlugin<unknown>;
40
+ //#region src/s3Storage.d.ts
41
+ interface S3StorageConfig extends S3ClientConfig {
42
+ bucketName: string;
43
+ /** Base path where bundles will be stored in the bucket. */
44
+ basePath?: string;
45
+ downloadUrlSigningKey?: string;
46
+ getDownloadUrl?: StoragePlugin["getDownloadUrl"];
47
+ }
48
+ type S3StorageConfigWithDownloadUrl = S3StorageConfig & ({
49
+ downloadUrlSigningKey: string;
50
+ } | {
51
+ getDownloadUrl: NonNullable<StoragePlugin["getDownloadUrl"]>;
52
+ });
53
+ type S3StorageOperations = "put" | "get" | "exists" | "delete" | "listObjects" | "deleteObjects";
54
+ declare function s3Storage(config: S3StorageConfigWithDownloadUrl): StoragePluginWith<S3StorageOperations | "getDownloadUrl">;
55
+ declare function s3Storage(config: S3StorageConfig): StoragePluginWith<S3StorageOperations>;
65
56
  //#endregion
66
- export { AwsLambdaEdgeStorageConfig, CloudFrontSignedUrlConfig, PublicBaseUrlResolver, S3DatabaseConfig, S3StorageConfig, WithCloudFrontSignedUrlOptions, awsLambdaEdgeStorage, s3Database, s3LambdaEdgeStorage, s3Storage, withCloudFrontSignedUrl };
57
+ export { CloudFrontDownloadUrlOptions, DYNAMODB_UPDATE_INDEX_NAME, type DynamoDBConfig, S3StorageConfig, S3StorageConfigWithDownloadUrl, cloudFrontDownloadUrl, dynamoDB, s3Storage };
package/dist/index.d.mts CHANGED
@@ -1,44 +1,20 @@
1
- import { S3ClientConfig } from "@aws-sdk/client-s3";
1
+ import { DynamoDBClientConfig } from "@aws-sdk/client-dynamodb";
2
+ import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";
2
3
  import * as _$_hot_updater_plugin_core0 from "@hot-updater/plugin-core";
3
- import { RuntimeStoragePlugin, StoragePluginHooks, StorageResolveContext } from "@hot-updater/plugin-core";
4
+ import { StoragePlugin, StoragePluginWith } from "@hot-updater/plugin-core";
5
+ import { S3ClientConfig } from "@aws-sdk/client-s3";
4
6
 
5
- //#region src/s3Database.d.ts
6
- interface S3DatabaseConfig extends S3ClientConfig {
7
- bucketName: string;
8
- /**
9
- * Base path where database objects will be stored in the bucket.
10
- */
11
- basePath?: string;
12
- /**
13
- * CloudFront distribution ID used for cache invalidation.
14
- *
15
- * If omitted or an empty string, CloudFront invalidation is skipped.
16
- * This is useful for local development environments (e.g. Localstack)
17
- * where CloudFront is not available.
18
- */
19
- cloudfrontDistributionId?: string;
20
- /**
21
- * Wait for CloudFront invalidations to reach `Completed` before finishing.
22
- *
23
- * When enabled, invalidation failures and timeouts are surfaced to callers
24
- * instead of being logged and ignored.
25
- */
26
- shouldWaitForInvalidation?: boolean;
27
- apiBasePath?: string;
7
+ //#region src/dynamoDB.d.ts
8
+ declare const DYNAMODB_UPDATE_INDEX_NAME = "hot-updater-update-index";
9
+ interface DynamoDBConfig extends DynamoDBClientConfig {
10
+ readonly apiBasePath?: string;
11
+ readonly cloudfrontDistributionId?: string;
12
+ readonly shouldWaitForInvalidation?: boolean;
13
+ readonly tableName: string;
28
14
  }
29
- declare const s3Database: (config: S3DatabaseConfig, hooks?: _$_hot_updater_plugin_core0.DatabasePluginHooks) => () => _$_hot_updater_plugin_core0.DatabasePlugin<unknown>;
15
+ declare const dynamoDB: (config: DynamoDBConfig) => _$_hot_updater_plugin_core0.DatabasePlugin;
30
16
  //#endregion
31
- //#region src/s3Storage.d.ts
32
- interface S3StorageConfig extends S3ClientConfig {
33
- bucketName: string;
34
- /**
35
- * Base path where bundles will be stored in the bucket
36
- */
37
- basePath?: string;
38
- }
39
- declare const s3Storage: (config: S3StorageConfig, hooks?: _$_hot_updater_plugin_core0.StoragePluginHooks) => () => _$_hot_updater_plugin_core0.UniversalStoragePlugin<unknown>;
40
- //#endregion
41
- //#region src/withCloudFrontSignedUrl.d.ts
17
+ //#region src/cloudFrontDownloadUrl.d.ts
42
18
  interface CloudFrontPrivateKeyFromGetter {
43
19
  getPrivateKey: () => Promise<string>;
44
20
  ssmParameterName?: never;
@@ -49,18 +25,34 @@ interface CloudFrontPrivateKeyFromSsm {
49
25
  ssmParameterName: string;
50
26
  ssmRegion: string;
51
27
  }
52
- type PublicBaseUrlResolver<TContext = unknown> = (context?: StorageResolveContext<TContext>) => string | Promise<string>;
53
- type CloudFrontSignedUrlConfig = CloudFrontPrivateKeyFromGetter | CloudFrontPrivateKeyFromSsm;
54
- type WithCloudFrontSignedUrlOptions<TContext = unknown> = CloudFrontSignedUrlConfig & {
28
+ type CloudFrontDownloadUrlOptions = (CloudFrontPrivateKeyFromGetter | CloudFrontPrivateKeyFromSsm) & {
55
29
  keyPairId: string;
56
- publicBaseUrl: string | PublicBaseUrlResolver<TContext>;
30
+ publicBaseUrl: string;
57
31
  expiresSeconds?: number;
58
32
  };
59
- declare const withCloudFrontSignedUrl: <TContext = unknown, TStorage extends RuntimeStoragePlugin<TContext> = RuntimeStoragePlugin<TContext>>(storageFactory: () => TStorage, config: WithCloudFrontSignedUrlOptions<TContext>) => () => TStorage;
33
+ declare const cloudFrontDownloadUrl: (config: CloudFrontDownloadUrlOptions) => ({
34
+ storageUri
35
+ }: {
36
+ storageUri: string;
37
+ }) => Promise<{
38
+ url: string;
39
+ }>;
60
40
  //#endregion
61
- //#region src/s3LambdaEdgeStorage.d.ts
62
- type AwsLambdaEdgeStorageConfig = S3StorageConfig & WithCloudFrontSignedUrlOptions;
63
- declare const awsLambdaEdgeStorage: (config: AwsLambdaEdgeStorageConfig, hooks?: StoragePluginHooks) => () => _$_hot_updater_plugin_core0.UniversalStoragePlugin<unknown>;
64
- declare const s3LambdaEdgeStorage: (config: AwsLambdaEdgeStorageConfig, hooks?: StoragePluginHooks) => () => _$_hot_updater_plugin_core0.UniversalStoragePlugin<unknown>;
41
+ //#region src/s3Storage.d.ts
42
+ interface S3StorageConfig extends S3ClientConfig {
43
+ bucketName: string;
44
+ /** Base path where bundles will be stored in the bucket. */
45
+ basePath?: string;
46
+ downloadUrlSigningKey?: string;
47
+ getDownloadUrl?: StoragePlugin["getDownloadUrl"];
48
+ }
49
+ type S3StorageConfigWithDownloadUrl = S3StorageConfig & ({
50
+ downloadUrlSigningKey: string;
51
+ } | {
52
+ getDownloadUrl: NonNullable<StoragePlugin["getDownloadUrl"]>;
53
+ });
54
+ type S3StorageOperations = "put" | "get" | "exists" | "delete" | "listObjects" | "deleteObjects";
55
+ declare function s3Storage(config: S3StorageConfigWithDownloadUrl): StoragePluginWith<S3StorageOperations | "getDownloadUrl">;
56
+ declare function s3Storage(config: S3StorageConfig): StoragePluginWith<S3StorageOperations>;
65
57
  //#endregion
66
- export { AwsLambdaEdgeStorageConfig, CloudFrontSignedUrlConfig, PublicBaseUrlResolver, S3DatabaseConfig, S3StorageConfig, WithCloudFrontSignedUrlOptions, awsLambdaEdgeStorage, s3Database, s3LambdaEdgeStorage, s3Storage, withCloudFrontSignedUrl };
58
+ export { CloudFrontDownloadUrlOptions, DYNAMODB_UPDATE_INDEX_NAME, type DynamoDBConfig, S3StorageConfig, S3StorageConfigWithDownloadUrl, cloudFrontDownloadUrl, dynamoDB, s3Storage };