@kensio/yulin 1.10.5 → 1.11.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/dist/config/lint/cff-js2-lint.fixture.d.ts.map +1 -1
- package/dist/config/lint/cff-js2-lint.fixture.js +23 -0
- package/dist/config/lint/cff-js2-lint.fixture.js.map +1 -1
- package/dist/config/lint/cff-js2-restriction.d.ts +5 -5
- package/dist/config/lint/cff-js2-restriction.d.ts.map +1 -1
- package/dist/config/lint/cff-js2-restriction.js +11 -5
- package/dist/config/lint/cff-js2-restriction.js.map +1 -1
- package/dist/sdk/router/resolve-sim-sdk-command-router.d.ts.map +1 -1
- package/dist/sdk/router/resolve-sim-sdk-command-router.js +3 -0
- package/dist/sdk/router/resolve-sim-sdk-command-router.js.map +1 -1
- package/dist/service/aws/sim-aws-account-region-scope.d.ts +9 -0
- package/dist/service/aws/sim-aws-account-region-scope.d.ts.map +1 -1
- package/dist/service/aws/sim-aws-account-region-scope.js +10 -0
- package/dist/service/aws/sim-aws-account-region-scope.js.map +1 -1
- package/dist/service/aws/sim-aws-account.d.ts +5 -0
- package/dist/service/aws/sim-aws-account.d.ts.map +1 -1
- package/dist/service/aws/sim-aws-account.js +6 -0
- package/dist/service/aws/sim-aws-account.js.map +1 -1
- package/dist/service/aws/sim-aws-region.d.ts +5 -0
- package/dist/service/aws/sim-aws-region.d.ts.map +1 -1
- package/dist/service/aws/sim-aws-region.js +6 -0
- package/dist/service/aws/sim-aws-region.js.map +1 -1
- package/dist/service/aws/sim-aws-service-accessors.d.ts +5 -0
- package/dist/service/aws/sim-aws-service-accessors.d.ts.map +1 -1
- package/dist/service/aws/sim-aws-service-accessors.js +6 -0
- package/dist/service/aws/sim-aws-service-accessors.js.map +1 -1
- package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cfn-value-adapter.d.ts.map +1 -1
- package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cfn-value-adapter.js +8 -0
- package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cfn-value-adapter.js.map +1 -1
- package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-kvs-cfn.d.ts +28 -0
- package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-kvs-cfn.d.ts.map +1 -0
- package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-kvs-cfn.js +41 -0
- package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-kvs-cfn.js.map +1 -0
- package/dist/service/cloudfront/cff/function-code-input/cff-cloudfront-import.d.ts +21 -0
- package/dist/service/cloudfront/cff/function-code-input/cff-cloudfront-import.d.ts.map +1 -0
- package/dist/service/cloudfront/cff/function-code-input/cff-cloudfront-import.js +30 -0
- package/dist/service/cloudfront/cff/function-code-input/cff-cloudfront-import.js.map +1 -0
- package/dist/service/cloudfront/cff/function-code-input/cff-function-code-input.d.ts +3 -1
- package/dist/service/cloudfront/cff/function-code-input/cff-function-code-input.d.ts.map +1 -1
- package/dist/service/cloudfront/cff/function-code-input/cff-function-code-input.js +5 -17
- package/dist/service/cloudfront/cff/function-code-input/cff-function-code-input.js.map +1 -1
- package/dist/service/cloudfront/cff/function-code-input/cff-vm-source-handler.d.ts +13 -0
- package/dist/service/cloudfront/cff/function-code-input/cff-vm-source-handler.d.ts.map +1 -0
- package/dist/service/cloudfront/cff/function-code-input/cff-vm-source-handler.js +28 -0
- package/dist/service/cloudfront/cff/function-code-input/cff-vm-source-handler.js.map +1 -0
- package/dist/service/cloudfront/cff/kvs/cff-cloudfront-module.d.ts +28 -0
- package/dist/service/cloudfront/cff/kvs/cff-cloudfront-module.d.ts.map +1 -0
- package/dist/service/cloudfront/cff/kvs/cff-cloudfront-module.js +30 -0
- package/dist/service/cloudfront/cff/kvs/cff-cloudfront-module.js.map +1 -0
- package/dist/service/cloudfront/cff/kvs/cff-kvs-handle.d.ts +46 -0
- package/dist/service/cloudfront/cff/kvs/cff-kvs-handle.d.ts.map +1 -0
- package/dist/service/cloudfront/cff/kvs/cff-kvs-handle.js +60 -0
- package/dist/service/cloudfront/cff/kvs/cff-kvs-handle.js.map +1 -0
- package/dist/service/cloudfront/cff/kvs/sim-cff-cloudfront-global.d.ts +43 -0
- package/dist/service/cloudfront/cff/kvs/sim-cff-cloudfront-global.d.ts.map +1 -0
- package/dist/service/cloudfront/cff/kvs/sim-cff-cloudfront-global.js +66 -0
- package/dist/service/cloudfront/cff/kvs/sim-cff-cloudfront-global.js.map +1 -0
- package/dist/service/cloudfront/cff/kvs/sim-cff-key-value-store-users.d.ts +20 -0
- package/dist/service/cloudfront/cff/kvs/sim-cff-key-value-store-users.d.ts.map +1 -0
- package/dist/service/cloudfront/cff/kvs/sim-cff-key-value-store-users.js +25 -0
- package/dist/service/cloudfront/cff/kvs/sim-cff-key-value-store-users.js.map +1 -0
- package/dist/service/cloudfront/cff/sim-cloudfront-function.d.ts +23 -2
- package/dist/service/cloudfront/cff/sim-cloudfront-function.d.ts.map +1 -1
- package/dist/service/cloudfront/cff/sim-cloudfront-function.js +30 -4
- package/dist/service/cloudfront/cff/sim-cloudfront-function.js.map +1 -1
- package/dist/service/cloudfront/cfn/cff/sim-cfn-cff-function-config.d.ts +6 -0
- package/dist/service/cloudfront/cfn/cff/sim-cfn-cff-function-config.d.ts.map +1 -1
- package/dist/service/cloudfront/cfn/cff/sim-cfn-cff-function-config.js +43 -0
- package/dist/service/cloudfront/cfn/cff/sim-cfn-cff-function-config.js.map +1 -1
- package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-config.d.ts +38 -0
- package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-config.d.ts.map +1 -0
- package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-config.js +49 -0
- package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-config.js.map +1 -0
- package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-creator.d.ts +33 -0
- package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-creator.d.ts.map +1 -0
- package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-creator.js +54 -0
- package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-creator.js.map +1 -0
- package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.d.ts +1 -0
- package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.d.ts.map +1 -1
- package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.js +12 -0
- package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.js.map +1 -1
- package/dist/service/cloudfront/command/create-distribution/create-distribution.command.d.ts +6 -0
- package/dist/service/cloudfront/command/create-distribution/create-distribution.command.d.ts.map +1 -1
- package/dist/service/cloudfront/command/create-distribution/sim-cf-distro-config-normalizer.d.ts.map +1 -1
- package/dist/service/cloudfront/command/create-distribution/sim-cf-distro-config-normalizer.js +8 -6
- package/dist/service/cloudfront/command/create-distribution/sim-cf-distro-config-normalizer.js.map +1 -1
- package/dist/service/cloudfront/command/create-function/create-function-kvs-association.d.ts +24 -0
- package/dist/service/cloudfront/command/create-function/create-function-kvs-association.d.ts.map +1 -0
- package/dist/service/cloudfront/command/create-function/create-function-kvs-association.js +50 -0
- package/dist/service/cloudfront/command/create-function/create-function-kvs-association.js.map +1 -0
- package/dist/service/cloudfront/command/create-function/create-function.command.d.ts +6 -0
- package/dist/service/cloudfront/command/create-function/create-function.command.d.ts.map +1 -1
- package/dist/service/cloudfront/command/create-function/create-function.handler.d.ts +3 -0
- package/dist/service/cloudfront/command/create-function/create-function.handler.d.ts.map +1 -1
- package/dist/service/cloudfront/command/create-function/create-function.handler.js +11 -2
- package/dist/service/cloudfront/command/create-function/create-function.handler.js.map +1 -1
- package/dist/service/cloudfront/command/key-value-store/sim-cf-create-key-value-store.d.ts +24 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-create-key-value-store.d.ts.map +1 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-create-key-value-store.js +43 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-create-key-value-store.js.map +1 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-delete-key-value-store.d.ts +26 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-delete-key-value-store.d.ts.map +1 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-delete-key-value-store.js +40 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-delete-key-value-store.js.map +1 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-describe-key-value-store.d.ts +24 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-describe-key-value-store.d.ts.map +1 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-describe-key-value-store.js +32 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-describe-key-value-store.js.map +1 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-key-value-store-command.types.d.ts +109 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-key-value-store-command.types.d.ts.map +1 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-key-value-store-command.types.js +12 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-key-value-store-command.types.js.map +1 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-key-value-store-summary.d.ts +10 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-key-value-store-summary.d.ts.map +1 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-key-value-store-summary.js +17 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-key-value-store-summary.js.map +1 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-list-key-value-stores.d.ts +20 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-list-key-value-stores.d.ts.map +1 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-list-key-value-stores.js +34 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-list-key-value-stores.js.map +1 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-update-key-value-store.d.ts +24 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-update-key-value-store.d.ts.map +1 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-update-key-value-store.js +35 -0
- package/dist/service/cloudfront/command/key-value-store/sim-cf-update-key-value-store.js.map +1 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-cf-key-value-store-data-command.types.d.ts +116 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-cf-key-value-store-data-command.types.d.ts.map +1 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-cf-key-value-store-data-command.types.js +12 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-cf-key-value-store-data-command.types.js.map +1 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-kvs-batch.d.ts +22 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-kvs-batch.d.ts.map +1 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-kvs-batch.js +26 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-kvs-batch.js.map +1 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-kvs-key-reads.d.ts +37 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-kvs-key-reads.d.ts.map +1 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-kvs-key-reads.js +67 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-kvs-key-reads.js.map +1 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-kvs-key-writes.d.ts +43 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-kvs-key-writes.d.ts.map +1 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-kvs-key-writes.js +81 -0
- package/dist/service/cloudfront/command/key-value-store-data/sim-kvs-key-writes.js.map +1 -0
- package/dist/service/cloudfront/command/sim-cf-list-quantity.d.ts +20 -0
- package/dist/service/cloudfront/command/sim-cf-list-quantity.d.ts.map +1 -0
- package/dist/service/cloudfront/command/sim-cf-list-quantity.js +36 -0
- package/dist/service/cloudfront/command/sim-cf-list-quantity.js.map +1 -0
- package/dist/service/cloudfront/controller/cff/sim-cff-applicator.d.ts +2 -2
- package/dist/service/cloudfront/controller/cff/sim-cff-applicator.d.ts.map +1 -1
- package/dist/service/cloudfront/controller/cff/sim-cff-applicator.js +6 -6
- package/dist/service/cloudfront/controller/cff/sim-cff-applicator.js.map +1 -1
- package/dist/service/cloudfront/controller/sim-cloudfront-request-pipeline.js +2 -2
- package/dist/service/cloudfront/controller/sim-cloudfront-request-pipeline.js.map +1 -1
- package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-properties.d.ts.map +1 -1
- package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-properties.js +5 -3
- package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-properties.js.map +1 -1
- package/dist/service/cloudfront/error/sim-cf-key-value-store.error.d.ts +88 -0
- package/dist/service/cloudfront/error/sim-cf-key-value-store.error.d.ts.map +1 -0
- package/dist/service/cloudfront/error/sim-cf-key-value-store.error.js +104 -0
- package/dist/service/cloudfront/error/sim-cf-key-value-store.error.js.map +1 -0
- package/dist/service/cloudfront/error/sim-cloudfront.error.d.ts +10 -0
- package/dist/service/cloudfront/error/sim-cloudfront.error.d.ts.map +1 -1
- package/dist/service/cloudfront/error/sim-cloudfront.error.js +12 -0
- package/dist/service/cloudfront/error/sim-cloudfront.error.js.map +1 -1
- package/dist/service/cloudfront/globals.d.ts +12 -0
- package/dist/service/cloudfront/globals.d.ts.map +1 -1
- package/dist/service/cloudfront/globals.js.map +1 -1
- package/dist/service/cloudfront/index.d.ts +3 -0
- package/dist/service/cloudfront/index.d.ts.map +1 -1
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-access.d.ts +57 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-access.d.ts.map +1 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-access.js +72 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-access.js.map +1 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-commands.d.ts +51 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-commands.d.ts.map +1 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-commands.js +65 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-commands.js.map +1 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-keys.d.ts +72 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-keys.d.ts.map +1 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-keys.js +94 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-keys.js.map +1 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-registry.d.ts +59 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-registry.d.ts.map +1 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-registry.js +92 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-registry.js.map +1 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-users.d.ts +24 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-users.d.ts.map +1 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-users.js +7 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-users.js.map +1 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store.d.ts +141 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store.d.ts.map +1 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store.js +180 -0
- package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store.js.map +1 -0
- package/dist/service/cloudfront/sdk/sim-cf-key-value-store-sdk-command-router.d.ts +24 -0
- package/dist/service/cloudfront/sdk/sim-cf-key-value-store-sdk-command-router.d.ts.map +1 -0
- package/dist/service/cloudfront/sdk/sim-cf-key-value-store-sdk-command-router.js +54 -0
- package/dist/service/cloudfront/sdk/sim-cf-key-value-store-sdk-command-router.js.map +1 -0
- package/dist/service/cloudfront/sdk/sim-cloudfront-sdk-command-router.d.ts.map +1 -1
- package/dist/service/cloudfront/sdk/sim-cloudfront-sdk-command-router.js +30 -0
- package/dist/service/cloudfront/sdk/sim-cloudfront-sdk-command-router.js.map +1 -1
- package/dist/service/cloudfront/sim-cloudfront-commands.d.ts +10 -0
- package/dist/service/cloudfront/sim-cloudfront-commands.d.ts.map +1 -1
- package/dist/service/cloudfront/sim-cloudfront-commands.js +25 -0
- package/dist/service/cloudfront/sim-cloudfront-commands.js.map +1 -1
- package/dist/service/cloudfront/sim-cloudfront-key-value-store.d.ts +58 -0
- package/dist/service/cloudfront/sim-cloudfront-key-value-store.d.ts.map +1 -0
- package/dist/service/cloudfront/sim-cloudfront-key-value-store.js +68 -0
- package/dist/service/cloudfront/sim-cloudfront-key-value-store.js.map +1 -0
- package/dist/service/cloudfront/sim-cloudfront.d.ts +14 -1
- package/dist/service/cloudfront/sim-cloudfront.d.ts.map +1 -1
- package/dist/service/cloudfront/sim-cloudfront.js +15 -0
- package/dist/service/cloudfront/sim-cloudfront.js.map +1 -1
- package/dist/service/cloudfront/typings/cloudfront-functions.namespace.d.ts +9 -2
- package/dist/service/cloudfront/typings/cloudfront-functions.namespace.d.ts.map +1 -1
- package/package.json +2 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CloudFrontFunction } from "../../typings/cloudfront-functions.namespace.js";
|
|
2
2
|
import type { SimCreateFunctionCommand } from "../../command/create-function/create-function.command.js";
|
|
3
|
+
import type { CffCloudFrontModule } from "../kvs/cff-cloudfront-module.js";
|
|
3
4
|
type FunctionCodeInput = SimCreateFunctionCommand["input"]["FunctionCode"];
|
|
4
5
|
/**
|
|
5
6
|
* Convert a handler function reference into a Uint8Array for input in the
|
|
@@ -27,7 +28,8 @@ export declare class CffUint8ArrayStowaway extends Uint8Array {
|
|
|
27
28
|
*/
|
|
28
29
|
export declare class CffUint8ArrayFunctionCodeExtractor<H extends CloudFrontFunction.Handler = CloudFrontFunction.ViewerRequestHandler> {
|
|
29
30
|
private readonly functionCodeInput;
|
|
30
|
-
|
|
31
|
+
private readonly cloudFront?;
|
|
32
|
+
constructor(functionCodeInput: FunctionCodeInput, cloudFront?: CffCloudFrontModule | undefined);
|
|
31
33
|
/**
|
|
32
34
|
* Extract the handler function.
|
|
33
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cff-function-code-input.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/function-code-input/cff-function-code-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AAE1F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAC;
|
|
1
|
+
{"version":3,"file":"cff-function-code-input.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/function-code-input/cff-function-code-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AAE1F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAC;AACzG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,KAAK,iBAAiB,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC;AAE3E;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,kBAAkB,CAAC,OAAO,GAC1C,iBAAiB,CAInB;AAED;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,UAAU;;IAGnD;;OAEG;IACH,uBAAuB,CAAC,eAAe,EAAE,kBAAkB,CAAC,OAAO,GAAG,IAAI,CAGzE;IAED;;OAEG;IACH,IAAI,eAAe,IAAI,kBAAkB,CAAC,OAAO,CAEhD;CACF;AAED;;;GAGG;AACH,qBAAa,kCAAkC,CAC7C,CAAC,SAAS,kBAAkB,CAAC,OAAO,GAClC,kBAAkB,CAAC,oBAAoB;IAGvC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;IAF9B,YACmB,iBAAiB,EAAE,iBAAiB,EACpC,UAAU,CAAC,EAAE,mBAAmB,YAAA,EAC/C;IAEJ;;OAEG;IACH,sBAAsB,IAAI,CAAC,CAM1B;IAED,OAAO,CAAC,2BAA2B;CAKpC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defaultCffHandler } from "../sim-cloudfront-function.js";
|
|
2
|
-
import
|
|
2
|
+
import { cffHandlerFromSource } from "./cff-vm-source-handler.js";
|
|
3
3
|
/**
|
|
4
4
|
* Convert a handler function reference into a Uint8Array for input in the
|
|
5
5
|
* CloudFront CreateFunction Command input FunctionCode.
|
|
@@ -35,8 +35,10 @@ export class CffUint8ArrayStowaway extends Uint8Array {
|
|
|
35
35
|
*/
|
|
36
36
|
export class CffUint8ArrayFunctionCodeExtractor {
|
|
37
37
|
functionCodeInput;
|
|
38
|
-
|
|
38
|
+
cloudFront;
|
|
39
|
+
constructor(functionCodeInput, cloudFront) {
|
|
39
40
|
this.functionCodeInput = functionCodeInput;
|
|
41
|
+
this.cloudFront = cloudFront;
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
42
44
|
* Extract the handler function.
|
|
@@ -49,21 +51,7 @@ export class CffUint8ArrayFunctionCodeExtractor {
|
|
|
49
51
|
}
|
|
50
52
|
extractUint8ArraySourceCode() {
|
|
51
53
|
const source = Buffer.from(this.functionCodeInput ?? "").toString();
|
|
52
|
-
|
|
53
|
-
console,
|
|
54
|
-
});
|
|
55
|
-
const script = new vm.Script(`
|
|
56
|
-
${source}
|
|
57
|
-
handler;
|
|
58
|
-
`);
|
|
59
|
-
const handler = script.runInContext(context, {
|
|
60
|
-
timeout: 50, // Real CloudFront Functions have a short timeout.
|
|
61
|
-
breakOnSigint: true,
|
|
62
|
-
});
|
|
63
|
-
if (typeof handler !== "function") {
|
|
64
|
-
throw new TypeError("CloudFront Function code did not define a handler function");
|
|
65
|
-
}
|
|
66
|
-
return handler;
|
|
54
|
+
return cffHandlerFromSource(source, this.cloudFront);
|
|
67
55
|
}
|
|
68
56
|
}
|
|
69
57
|
//# sourceMappingURL=cff-function-code-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cff-function-code-input.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/function-code-input/cff-function-code-input.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"cff-function-code-input.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/function-code-input/cff-function-code-input.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAIlE;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,eAA2C;IAE3C,MAAM,QAAQ,GAAG,IAAI,qBAAqB,EAAE,CAAC;IAC7C,QAAQ,CAAC,uBAAuB,CAAC,eAAe,CAAC,CAAC;IAClD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,UAAU;IACnD,gBAAgB,GAA+B,iBAAiB,CAAC;IAEjE;;OAEG;IACH,uBAAuB,CAAC,eAA2C;QACjE,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,kCAAkC;IAK1B,iBAAiB;IACjB,UAAU;IAF7B,YACmB,iBAAoC,EACpC,UAAgC;iCADhC,iBAAiB;0BACjB,UAAU;IAC1B,CAAC;IAEJ;;OAEG;IACH,sBAAsB;QACpB,IAAI,IAAI,CAAC,iBAAiB,YAAY,qBAAqB,EAAE,CAAC;YAC5D,OAAO,IAAI,CAAC,iBAAiB,CAAC,eAAoB,CAAC;QACrD,CAAC;QAED,OAAO,IAAI,CAAC,2BAA2B,EAAE,CAAC;IAC5C,CAAC;IAEO,2BAA2B;QACjC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;QAEpE,OAAO,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAM,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CloudFrontFunction } from "../../typings/cloudfront-functions.namespace.js";
|
|
2
|
+
import { type CffCloudFrontModule } from "../kvs/cff-cloudfront-module.js";
|
|
3
|
+
/**
|
|
4
|
+
* Compile CloudFront Function source and hand back its handler.
|
|
5
|
+
*
|
|
6
|
+
* The source runs in a vm context of its own, which is the closest thing here
|
|
7
|
+
* to the isolate real CloudFront gives a Function. The context holds this
|
|
8
|
+
* Function's own `cf`, so two Functions running in one process each read the
|
|
9
|
+
* key value store they are associated with and nothing else. A Function with no
|
|
10
|
+
* association still gets a `cf`, one that refuses when asked to open a store.
|
|
11
|
+
*/
|
|
12
|
+
export declare function cffHandlerFromSource(source: string, cloudFront?: CffCloudFrontModule): CloudFrontFunction.Handler;
|
|
13
|
+
//# sourceMappingURL=cff-vm-source-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cff-vm-source-handler.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/function-code-input/cff-vm-source-handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AAC1F,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,iCAAiC,CAAC;AAGzC;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,mBAAoD,GAC/D,kBAAkB,CAAC,OAAO,CAmB5B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import vm from "node:vm";
|
|
2
|
+
import { cffCloudFrontModule, } from "../kvs/cff-cloudfront-module.js";
|
|
3
|
+
import { cffSourceWithoutCloudFrontImport } from "./cff-cloudfront-import.js";
|
|
4
|
+
/**
|
|
5
|
+
* Compile CloudFront Function source and hand back its handler.
|
|
6
|
+
*
|
|
7
|
+
* The source runs in a vm context of its own, which is the closest thing here
|
|
8
|
+
* to the isolate real CloudFront gives a Function. The context holds this
|
|
9
|
+
* Function's own `cf`, so two Functions running in one process each read the
|
|
10
|
+
* key value store they are associated with and nothing else. A Function with no
|
|
11
|
+
* association still gets a `cf`, one that refuses when asked to open a store.
|
|
12
|
+
*/
|
|
13
|
+
export function cffHandlerFromSource(source, cloudFront = cffCloudFrontModule(undefined)) {
|
|
14
|
+
const context = vm.createContext({ console, cf: cloudFront });
|
|
15
|
+
const script = new vm.Script(`
|
|
16
|
+
${cffSourceWithoutCloudFrontImport(source)}
|
|
17
|
+
handler;
|
|
18
|
+
`);
|
|
19
|
+
const handler = script.runInContext(context, {
|
|
20
|
+
timeout: 50, // Real CloudFront Functions have a short timeout.
|
|
21
|
+
breakOnSigint: true,
|
|
22
|
+
});
|
|
23
|
+
if (typeof handler !== "function") {
|
|
24
|
+
throw new TypeError("CloudFront Function code did not define a handler function");
|
|
25
|
+
}
|
|
26
|
+
return handler;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=cff-vm-source-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cff-vm-source-handler.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/function-code-input/cff-vm-source-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzB,OAAO,EAEL,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAE9E;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAc,EACd,UAAU,GAAwB,mBAAmB,CAAC,SAAS,CAAC;IAEhE,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC;MACzB,gCAAgC,CAAC,MAAM,CAAC;;KAEzC,CAAC,CAAC;IAEL,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE;QAC3C,OAAO,EAAE,EAAE,EAAE,kDAAkD;QAC/D,aAAa,EAAE,IAAI;KACpB,CAA+B,CAAC;IAEjC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QAClC,MAAM,IAAI,SAAS,CACjB,4DAA4D,CAC7D,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SimCloudFrontKeyValueStore } from "../../key-value-store/sim-cf-key-value-store.js";
|
|
2
|
+
import { CffKvsHandle } from "./cff-kvs-handle.js";
|
|
3
|
+
/**
|
|
4
|
+
* What a Function can reach a key value store through.
|
|
5
|
+
*
|
|
6
|
+
* The Function's own association is the only store it can open, so this is
|
|
7
|
+
* given the store the Function was created with, or nothing.
|
|
8
|
+
*/
|
|
9
|
+
export interface CffCloudFrontModule {
|
|
10
|
+
/**
|
|
11
|
+
* Open the key value store this Function is associated with.
|
|
12
|
+
*/
|
|
13
|
+
kvs(kvsId?: string): CffKvsHandle;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Build the `cloudfront` module a Function sees as `cf`.
|
|
17
|
+
*
|
|
18
|
+
* `cf.kvs()` opens the Function's associated store. An ID may be passed, and it
|
|
19
|
+
* has to be the associated store's: a Function can only reach the one it names
|
|
20
|
+
* in its own configuration, so an ID for any other store is refused rather than
|
|
21
|
+
* opened.
|
|
22
|
+
*
|
|
23
|
+
* A Function with no association has nothing to open, so `cf.kvs()` fails
|
|
24
|
+
* rather than handing back an empty store. An empty store would let a Function
|
|
25
|
+
* that forgot its association run to completion and quietly take every default.
|
|
26
|
+
*/
|
|
27
|
+
export declare function cffCloudFrontModule(store: SimCloudFrontKeyValueStore | undefined): CffCloudFrontModule;
|
|
28
|
+
//# sourceMappingURL=cff-cloudfront-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cff-cloudfront-module.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/kvs/cff-cloudfront-module.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AAClG,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;CACnC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,0BAA0B,GAAG,SAAS,GAC5C,mBAAmB,CAoBrB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SimCloudFrontCffKvsUnavailable } from "../../error/sim-cf-key-value-store.error.js";
|
|
2
|
+
import { CffKvsHandle } from "./cff-kvs-handle.js";
|
|
3
|
+
/**
|
|
4
|
+
* Build the `cloudfront` module a Function sees as `cf`.
|
|
5
|
+
*
|
|
6
|
+
* `cf.kvs()` opens the Function's associated store. An ID may be passed, and it
|
|
7
|
+
* has to be the associated store's: a Function can only reach the one it names
|
|
8
|
+
* in its own configuration, so an ID for any other store is refused rather than
|
|
9
|
+
* opened.
|
|
10
|
+
*
|
|
11
|
+
* A Function with no association has nothing to open, so `cf.kvs()` fails
|
|
12
|
+
* rather than handing back an empty store. An empty store would let a Function
|
|
13
|
+
* that forgot its association run to completion and quietly take every default.
|
|
14
|
+
*/
|
|
15
|
+
export function cffCloudFrontModule(store) {
|
|
16
|
+
return {
|
|
17
|
+
kvs: (kvsId) => {
|
|
18
|
+
if (store === undefined) {
|
|
19
|
+
throw new SimCloudFrontCffKvsUnavailable("This CloudFront Function is not associated with a key value store, " +
|
|
20
|
+
"so cf.kvs() has nothing to open");
|
|
21
|
+
}
|
|
22
|
+
if (kvsId !== undefined && kvsId !== store.id && kvsId !== store.arn) {
|
|
23
|
+
throw new SimCloudFrontCffKvsUnavailable(`This CloudFront Function is associated with key value store ` +
|
|
24
|
+
`${store.id}, so cf.kvs() cannot open ${kvsId}`);
|
|
25
|
+
}
|
|
26
|
+
return new CffKvsHandle(store);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=cff-cloudfront-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cff-cloudfront-module.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/kvs/cff-cloudfront-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAE7F,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAenD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAA6C;IAE7C,OAAO;QACL,GAAG,EAAE,CAAC,KAAc,EAAgB,EAAE;YACpC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,IAAI,8BAA8B,CACtC,qEAAqE;oBACnE,iCAAiC,CACpC,CAAC;YACJ,CAAC;YAED,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,CAAC,EAAE,IAAI,KAAK,KAAK,KAAK,CAAC,GAAG,EAAE,CAAC;gBACrE,MAAM,IAAI,8BAA8B,CACtC,8DAA8D;oBAC5D,GAAG,KAAK,CAAC,EAAE,6BAA6B,KAAK,EAAE,CAClD,CAAC;YACJ,CAAC;YAED,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { SimCloudFrontKeyValueStore } from "../../key-value-store/sim-cf-key-value-store.js";
|
|
2
|
+
/**
|
|
3
|
+
* What a Function may ask a value to be read back as.
|
|
4
|
+
*/
|
|
5
|
+
export type CffKvsValueFormat = "string" | "json" | "bytes";
|
|
6
|
+
/**
|
|
7
|
+
* What `kvs.meta()` answers with.
|
|
8
|
+
*/
|
|
9
|
+
export interface CffKvsMeta {
|
|
10
|
+
readonly creationDateTime: string;
|
|
11
|
+
readonly lastUpdatedDateTime: string;
|
|
12
|
+
readonly keyCount: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The handle a CloudFront Function gets back from `cf.kvs()`.
|
|
16
|
+
*
|
|
17
|
+
* Every method is a promise, as in the runtime, so a Function reading a store
|
|
18
|
+
* has to be async. It is read-only: a Function can never write to a store, and
|
|
19
|
+
* there is deliberately no method here that would let it.
|
|
20
|
+
*
|
|
21
|
+
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/kvs-with-functions-associate.html
|
|
22
|
+
*/
|
|
23
|
+
export declare class CffKvsHandle {
|
|
24
|
+
private readonly store;
|
|
25
|
+
constructor(store: SimCloudFrontKeyValueStore);
|
|
26
|
+
/**
|
|
27
|
+
* Read a key, in the format the Function asked for.
|
|
28
|
+
*
|
|
29
|
+
* The default is `string`. `json` parses the stored string, and `bytes`
|
|
30
|
+
* hands back its UTF-8 bytes. A key that is not stored rejects, as in the
|
|
31
|
+
* runtime, rather than resolving to undefined.
|
|
32
|
+
*/
|
|
33
|
+
get(key: string, options?: {
|
|
34
|
+
readonly format?: CffKvsValueFormat;
|
|
35
|
+
}): Promise<unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* Whether a key is in the store.
|
|
38
|
+
*/
|
|
39
|
+
exists(key: string): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* The store's metadata, as the runtime reports it.
|
|
42
|
+
*/
|
|
43
|
+
meta(): Promise<CffKvsMeta>;
|
|
44
|
+
private formatted;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=cff-kvs-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cff-kvs-handle.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/kvs/cff-kvs-handle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AAElG;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAlC,YAA6B,KAAK,EAAE,0BAA0B,EAAI;IAElE;;;;;;OAMG;IACG,GAAG,CACP,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAA;KAAE,GAChD,OAAO,CAAC,OAAO,CAAC,CASlB;IAED;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEpC;IAED;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC,CAM1B;IAED,OAAO,CAAC,SAAS;CAalB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The handle a CloudFront Function gets back from `cf.kvs()`.
|
|
3
|
+
*
|
|
4
|
+
* Every method is a promise, as in the runtime, so a Function reading a store
|
|
5
|
+
* has to be async. It is read-only: a Function can never write to a store, and
|
|
6
|
+
* there is deliberately no method here that would let it.
|
|
7
|
+
*
|
|
8
|
+
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/kvs-with-functions-associate.html
|
|
9
|
+
*/
|
|
10
|
+
export class CffKvsHandle {
|
|
11
|
+
store;
|
|
12
|
+
constructor(store) {
|
|
13
|
+
this.store = store;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Read a key, in the format the Function asked for.
|
|
17
|
+
*
|
|
18
|
+
* The default is `string`. `json` parses the stored string, and `bytes`
|
|
19
|
+
* hands back its UTF-8 bytes. A key that is not stored rejects, as in the
|
|
20
|
+
* runtime, rather than resolving to undefined.
|
|
21
|
+
*/
|
|
22
|
+
async get(key, options) {
|
|
23
|
+
// Async so that a missing key rejects the promise rather than throwing
|
|
24
|
+
// before the caller has one. A Function handling the miss with `.catch()`
|
|
25
|
+
// depends on that, and so does one that never awaits the read at all.
|
|
26
|
+
await Promise.resolve();
|
|
27
|
+
const value = this.store.keys.get(key);
|
|
28
|
+
return this.formatted(value, options?.format ?? "string");
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Whether a key is in the store.
|
|
32
|
+
*/
|
|
33
|
+
exists(key) {
|
|
34
|
+
return Promise.resolve(this.store.keys.has(key));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The store's metadata, as the runtime reports it.
|
|
38
|
+
*/
|
|
39
|
+
meta() {
|
|
40
|
+
return Promise.resolve({
|
|
41
|
+
creationDateTime: this.store.createdTime.toISOString(),
|
|
42
|
+
lastUpdatedDateTime: this.store.lastModifiedTime.toISOString(),
|
|
43
|
+
keyCount: this.store.keys.itemCount,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
formatted(value, format) {
|
|
47
|
+
switch (format) {
|
|
48
|
+
case "string": {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
case "json": {
|
|
52
|
+
return JSON.parse(value);
|
|
53
|
+
}
|
|
54
|
+
case "bytes": {
|
|
55
|
+
return Buffer.from(value, "utf8");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=cff-kvs-handle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cff-kvs-handle.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/kvs/cff-kvs-handle.ts"],"names":[],"mappings":"AAgBA;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAY;IACM,KAAK;IAAlC,YAA6B,KAAiC;qBAAjC,KAAK;IAA+B,CAAC;IAElE;;;;;;OAMG;IACH,KAAK,CAAC,GAAG,CACP,GAAW,EACX,OAAiD;QAEjD,uEAAuE;QACvE,0EAA0E;QAC1E,sEAAsE;QACtE,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QAExB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEvC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,GAAW;QAChB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE;YACtD,mBAAmB,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,WAAW,EAAE;YAC9D,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS;SACpC,CAAC,CAAC;IACL,CAAC;IAEO,SAAS,CAAC,KAAa,EAAE,MAAyB;QACxD,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,QAAQ,EAAE,CAAC;gBACd,OAAO,KAAK,CAAC;YACf,CAAC;YACD,KAAK,MAAM,EAAE,CAAC;gBACZ,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;YACD,KAAK,OAAO,EAAE,CAAC;gBACb,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { CffCloudFrontModule } from "./cff-cloudfront-module.js";
|
|
2
|
+
declare class SimCffCloudFrontGlobal {
|
|
3
|
+
private readonly storage;
|
|
4
|
+
private installed;
|
|
5
|
+
/**
|
|
6
|
+
* Run an invocation with the given module as its `cf`.
|
|
7
|
+
*/
|
|
8
|
+
run<T>(module: CffCloudFrontModule, run: () => Promise<T>): Promise<T>;
|
|
9
|
+
/**
|
|
10
|
+
* The module the invocation in progress is using, if there is one.
|
|
11
|
+
*
|
|
12
|
+
* An invocation that has finished holds nothing, even though asynchronous
|
|
13
|
+
* context still reaches its store. Work a Function starts and does not await
|
|
14
|
+
* outlives the invocation here, and in CloudFront it does not: the Function
|
|
15
|
+
* is done when it returns. Reading `cf` from that leaked work finds nothing
|
|
16
|
+
* rather than a store the Function is no longer entitled to.
|
|
17
|
+
*/
|
|
18
|
+
current(): CffCloudFrontModule | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Define `cf` as a global accessor backed by the invocation store.
|
|
21
|
+
*
|
|
22
|
+
* Installed once and never removed. Removing it would be unsafe while
|
|
23
|
+
* another invocation is in flight, and there is nothing to gain: an
|
|
24
|
+
* installed accessor with no invocation running reads as undefined, exactly
|
|
25
|
+
* as though it were not there.
|
|
26
|
+
*
|
|
27
|
+
* It stays configurable so that a second copy of this package in one process
|
|
28
|
+
* can install over the first. Locking it down would stop a Function
|
|
29
|
+
* reassigning `cf`, which is the Function sabotaging its own test rather than
|
|
30
|
+
* a boundary worth defending, at the cost of turning a duplicated dependency
|
|
31
|
+
* into a hard throw.
|
|
32
|
+
*/
|
|
33
|
+
private install;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The `cf` global, shared by every simulated CloudFront Function in a process.
|
|
37
|
+
*
|
|
38
|
+
* One accessor is installed for the process, and which module it resolves to
|
|
39
|
+
* is per-invocation, so a single global is all that is needed.
|
|
40
|
+
*/
|
|
41
|
+
export declare const simCffCloudFrontGlobal: SimCffCloudFrontGlobal;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=sim-cff-cloudfront-global.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sim-cff-cloudfront-global.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/kvs/sim-cff-cloudfront-global.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AA+BtE,cAAM,sBAAsB;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0C;IAClE,OAAO,CAAC,SAAS,CAAS;IAE1B;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAU3E;IAED;;;;;;;;OAQG;IACH,OAAO,IAAI,mBAAmB,GAAG,SAAS,CAQzC;IAED;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,OAAO;CAYhB;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,wBAA+B,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
class SimCffCloudFrontGlobal {
|
|
3
|
+
storage = new AsyncLocalStorage();
|
|
4
|
+
installed = false;
|
|
5
|
+
/**
|
|
6
|
+
* Run an invocation with the given module as its `cf`.
|
|
7
|
+
*/
|
|
8
|
+
async run(module, run) {
|
|
9
|
+
this.install();
|
|
10
|
+
const invocation = { module, active: true };
|
|
11
|
+
try {
|
|
12
|
+
return await this.storage.run(invocation, run);
|
|
13
|
+
}
|
|
14
|
+
finally {
|
|
15
|
+
invocation.active = false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The module the invocation in progress is using, if there is one.
|
|
20
|
+
*
|
|
21
|
+
* An invocation that has finished holds nothing, even though asynchronous
|
|
22
|
+
* context still reaches its store. Work a Function starts and does not await
|
|
23
|
+
* outlives the invocation here, and in CloudFront it does not: the Function
|
|
24
|
+
* is done when it returns. Reading `cf` from that leaked work finds nothing
|
|
25
|
+
* rather than a store the Function is no longer entitled to.
|
|
26
|
+
*/
|
|
27
|
+
current() {
|
|
28
|
+
const invocation = this.storage.getStore();
|
|
29
|
+
if (invocation?.active !== true) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return invocation.module;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Define `cf` as a global accessor backed by the invocation store.
|
|
36
|
+
*
|
|
37
|
+
* Installed once and never removed. Removing it would be unsafe while
|
|
38
|
+
* another invocation is in flight, and there is nothing to gain: an
|
|
39
|
+
* installed accessor with no invocation running reads as undefined, exactly
|
|
40
|
+
* as though it were not there.
|
|
41
|
+
*
|
|
42
|
+
* It stays configurable so that a second copy of this package in one process
|
|
43
|
+
* can install over the first. Locking it down would stop a Function
|
|
44
|
+
* reassigning `cf`, which is the Function sabotaging its own test rather than
|
|
45
|
+
* a boundary worth defending, at the cost of turning a duplicated dependency
|
|
46
|
+
* into a hard throw.
|
|
47
|
+
*/
|
|
48
|
+
install() {
|
|
49
|
+
if (this.installed) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
Object.defineProperty(globalThis, "cf", {
|
|
53
|
+
configurable: true,
|
|
54
|
+
get: () => this.current(),
|
|
55
|
+
});
|
|
56
|
+
this.installed = true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The `cf` global, shared by every simulated CloudFront Function in a process.
|
|
61
|
+
*
|
|
62
|
+
* One accessor is installed for the process, and which module it resolves to
|
|
63
|
+
* is per-invocation, so a single global is all that is needed.
|
|
64
|
+
*/
|
|
65
|
+
export const simCffCloudFrontGlobal = new SimCffCloudFrontGlobal();
|
|
66
|
+
//# sourceMappingURL=sim-cff-cloudfront-global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sim-cff-cloudfront-global.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/kvs/sim-cff-cloudfront-global.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAiCrD,MAAM,sBAAsB;IACT,OAAO,GAAG,IAAI,iBAAiB,EAAiB,CAAC;IAC1D,SAAS,GAAG,KAAK,CAAC;IAE1B;;OAEG;IACH,KAAK,CAAC,GAAG,CAAI,MAA2B,EAAE,GAAqB;QAC7D,IAAI,CAAC,OAAO,EAAE,CAAC;QAEf,MAAM,UAAU,GAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QAE3D,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QACjD,CAAC;gBAAS,CAAC;YACT,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC;QAC5B,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACH,OAAO;QACL,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QAE3C,IAAI,UAAU,EAAE,MAAM,KAAK,IAAI,EAAE,CAAC;YAChC,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,UAAU,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;;;;OAaG;IACK,OAAO;QACb,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,EAAE;YACtC,YAAY,EAAE,IAAI;YAClB,GAAG,EAAE,GAAoC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE;SAC3D,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SimCloudFrontFunctionMap } from "../../command/create-function/create-function.handler.js";
|
|
2
|
+
import type { SimCloudFrontKeyValueStoreId } from "../../key-value-store/sim-cf-key-value-store.js";
|
|
3
|
+
import type { SimCfKeyValueStoreUsers } from "../../key-value-store/sim-cf-key-value-store-users.js";
|
|
4
|
+
/**
|
|
5
|
+
* The CloudFront Functions holding a key value store open.
|
|
6
|
+
*
|
|
7
|
+
* CloudFront will not delete a store a Function is still associated with, and
|
|
8
|
+
* the Functions are the only thing here that can be, so this is what the delete
|
|
9
|
+
* command asks. It reads the Function map live rather than keeping its own
|
|
10
|
+
* index, so a Function deleted a moment ago stops holding its store open.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SimCffKeyValueStoreUsers implements SimCfKeyValueStoreUsers {
|
|
13
|
+
private readonly cloudFrontFunctions;
|
|
14
|
+
constructor(cloudFrontFunctions: SimCloudFrontFunctionMap);
|
|
15
|
+
/**
|
|
16
|
+
* The names of the Functions associated with a key value store.
|
|
17
|
+
*/
|
|
18
|
+
functionsUsing(storeId: SimCloudFrontKeyValueStoreId): readonly string[];
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=sim-cff-key-value-store-users.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sim-cff-key-value-store-users.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/kvs/sim-cff-key-value-store-users.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0DAA0D,CAAC;AACzG,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AACpG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uDAAuD,CAAC;AAErG;;;;;;;GAOG;AACH,qBAAa,wBAAyB,YAAW,uBAAuB;IAC1D,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IAAhD,YAA6B,mBAAmB,EAAE,wBAAwB,EAAI;IAE9E;;OAEG;IACH,cAAc,CAAC,OAAO,EAAE,4BAA4B,GAAG,SAAS,MAAM,EAAE,CAMvE;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CloudFront Functions holding a key value store open.
|
|
3
|
+
*
|
|
4
|
+
* CloudFront will not delete a store a Function is still associated with, and
|
|
5
|
+
* the Functions are the only thing here that can be, so this is what the delete
|
|
6
|
+
* command asks. It reads the Function map live rather than keeping its own
|
|
7
|
+
* index, so a Function deleted a moment ago stops holding its store open.
|
|
8
|
+
*/
|
|
9
|
+
export class SimCffKeyValueStoreUsers {
|
|
10
|
+
cloudFrontFunctions;
|
|
11
|
+
constructor(cloudFrontFunctions) {
|
|
12
|
+
this.cloudFrontFunctions = cloudFrontFunctions;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The names of the Functions associated with a key value store.
|
|
16
|
+
*/
|
|
17
|
+
functionsUsing(storeId) {
|
|
18
|
+
return this.cloudFrontFunctions
|
|
19
|
+
.values()
|
|
20
|
+
.filter((cff) => cff.keyValueStore?.id === storeId)
|
|
21
|
+
.map((cff) => cff.name)
|
|
22
|
+
.toArray();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=sim-cff-key-value-store-users.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sim-cff-key-value-store-users.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/kvs/sim-cff-key-value-store-users.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,OAAO,wBAAwB;IACN,mBAAmB;IAAhD,YAA6B,mBAA6C;mCAA7C,mBAAmB;IAA6B,CAAC;IAE9E;;OAEG;IACH,cAAc,CAAC,OAAqC;QAClD,OAAO,IAAI,CAAC,mBAAmB;aAC5B,MAAM,EAAE;aACR,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,KAAK,OAAO,CAAC;aAClD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAc,CAAC;aAChC,OAAO,EAAE,CAAC;IACf,CAAC;CACF"}
|
|
@@ -3,6 +3,7 @@ import { SimCffEventAdapter } from "./adapter/sim-cff-event-adapter.js";
|
|
|
3
3
|
import type { Brand } from "../../../util/brand.type.js";
|
|
4
4
|
import type { SimArn } from "../../aws/arn.js";
|
|
5
5
|
import { type SimAwsAccountId } from "../../aws/sim-aws-account.js";
|
|
6
|
+
import type { SimCloudFrontKeyValueStore } from "../key-value-store/sim-cf-key-value-store.js";
|
|
6
7
|
export type SimCloudFrontFunctionName = Brand<string, "SimCloudFrontFunctionName">;
|
|
7
8
|
export type CloudFrontFunctionStatus = "UNPUBLISHED" | "UNASSOCIATED" | "ASSOCIATED";
|
|
8
9
|
interface SimCloudFrontFunctionProperties {
|
|
@@ -11,6 +12,7 @@ interface SimCloudFrontFunctionProperties {
|
|
|
11
12
|
readonly accountId?: SimAwsAccountId;
|
|
12
13
|
handlerFunction?: CloudFrontFunction.Handler;
|
|
13
14
|
eventAdapter?: SimCffEventAdapter;
|
|
15
|
+
keyValueStore?: SimCloudFrontKeyValueStore | undefined;
|
|
14
16
|
}
|
|
15
17
|
export declare const defaultCffHandler: CloudFrontFunction.Handler;
|
|
16
18
|
/**
|
|
@@ -22,6 +24,7 @@ export declare class SimCloudFrontFunction {
|
|
|
22
24
|
readonly accountId: SimAwsAccountId;
|
|
23
25
|
private readonly handlerFunction;
|
|
24
26
|
private readonly eventAdapter;
|
|
27
|
+
private readonly associatedKeyValueStore;
|
|
25
28
|
constructor(properties: SimCloudFrontFunctionProperties);
|
|
26
29
|
/**
|
|
27
30
|
* Get the current status of this sim CloudFront Function.
|
|
@@ -35,14 +38,32 @@ export declare class SimCloudFrontFunction {
|
|
|
35
38
|
* Move this sim CloudFront Function to the PUBLISHED status.
|
|
36
39
|
*/
|
|
37
40
|
publish(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* The key value store this Function may read, if it is associated with one.
|
|
43
|
+
*/
|
|
44
|
+
get keyValueStore(): SimCloudFrontKeyValueStore | undefined;
|
|
38
45
|
/**
|
|
39
46
|
* Run the viewer-request CFF handler on a native Request.
|
|
47
|
+
*
|
|
48
|
+
* Awaited because a Function reading a key value store is async. One that
|
|
49
|
+
* reads nothing is synchronous and still works: awaiting a plain value is
|
|
50
|
+
* what makes both shapes the same here.
|
|
40
51
|
*/
|
|
41
|
-
handleViewerRequest(request: Request): Request | Response
|
|
52
|
+
handleViewerRequest(request: Request): Promise<Request | Response>;
|
|
42
53
|
/**
|
|
43
54
|
* Run the viewer-response CFF handler on a native Request and Response.
|
|
44
55
|
*/
|
|
45
|
-
handleViewerResponse(request: Request, response: Response): Response
|
|
56
|
+
handleViewerResponse(request: Request, response: Response): Promise<Response>;
|
|
57
|
+
/**
|
|
58
|
+
* Run the handler with this Function's own `cf` in scope.
|
|
59
|
+
*
|
|
60
|
+
* A Function given as source code already has `cf` in its vm sandbox, so this
|
|
61
|
+
* is what gives one given as a function reference the same thing: the module
|
|
62
|
+
* is held in asynchronous context for the length of the invocation, and the
|
|
63
|
+
* global `cf` resolves to it. Setting it for both is harmless and means the
|
|
64
|
+
* two kinds of Function reach a store the same way.
|
|
65
|
+
*/
|
|
66
|
+
private running;
|
|
46
67
|
}
|
|
47
68
|
export {};
|
|
48
69
|
//# sourceMappingURL=sim-cloudfront-function.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sim-cloudfront-function.d.ts","sourceRoot":"","sources":["../../../../src/service/cloudfront/cff/sim-cloudfront-function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"sim-cloudfront-function.d.ts","sourceRoot":"","sources":["../../../../src/service/cloudfront/cff/sim-cloudfront-function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAI/F,MAAM,MAAM,yBAAyB,GAAG,KAAK,CAC3C,MAAM,EACN,2BAA2B,CAC5B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAChC,aAAa,GACb,cAAc,GACd,YAAY,CAAC;AAEjB,UAAU,+BAA+B;IACvC,IAAI,EAAE,yBAAyB,GAAG,MAAM,CAAC;IACzC,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;IACrC,eAAe,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC;IAC7C,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,aAAa,CAAC,EAAE,0BAA0B,GAAG,SAAS,CAAC;CACxD;AAED,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,CAAC,OAOlD,CAAC;AAEF;;GAEG;AACH,qBAAa,qBAAqB;;IAChC,SAAgB,IAAI,EAAE,yBAAyB,CAAC;IAChD,SAAgB,SAAS,EAAE,eAAe,CAAC;IAG3C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA6B;IAC7D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqB;IAClD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAE1B;IAEd,YAAY,UAAU,EAAE,+BAA+B,EActD;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,wBAAwB,CAErC;IAED;;OAEG;IACH,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAGvB;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,0BAA0B,GAAG,SAAS,CAE1D;IAED;;;;;;OAMG;IACG,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC,CAUvE;IAED;;OAEG;IACG,oBAAoB,CACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,QAAQ,CAAC,CAUnB;IAED;;;;;;;;OAQG;YACW,OAAO;CAMtB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SimCffEventAdapter } from "./adapter/sim-cff-event-adapter.js";
|
|
2
2
|
import { makeSimAwsAccountId, } from "../../aws/sim-aws-account.js";
|
|
3
|
+
import { cffCloudFrontModule } from "./kvs/cff-cloudfront-module.js";
|
|
4
|
+
import { simCffCloudFrontGlobal } from "./kvs/sim-cff-cloudfront-global.js";
|
|
3
5
|
export const defaultCffHandler = (event) => {
|
|
4
6
|
if (event.context.eventType === "viewer-response") {
|
|
5
7
|
return event.response;
|
|
@@ -15,6 +17,7 @@ export class SimCloudFrontFunction {
|
|
|
15
17
|
#status;
|
|
16
18
|
handlerFunction;
|
|
17
19
|
eventAdapter;
|
|
20
|
+
associatedKeyValueStore;
|
|
18
21
|
constructor(properties) {
|
|
19
22
|
const { name, status = "UNPUBLISHED", accountId = makeSimAwsAccountId(), handlerFunction = defaultCffHandler, eventAdapter = new SimCffEventAdapter(), } = properties;
|
|
20
23
|
this.name = name;
|
|
@@ -22,6 +25,7 @@ export class SimCloudFrontFunction {
|
|
|
22
25
|
this.accountId = accountId;
|
|
23
26
|
this.handlerFunction = handlerFunction;
|
|
24
27
|
this.eventAdapter = eventAdapter;
|
|
28
|
+
this.associatedKeyValueStore = properties.keyValueStore;
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* Get the current status of this sim CloudFront Function.
|
|
@@ -42,25 +46,47 @@ export class SimCloudFrontFunction {
|
|
|
42
46
|
this.#status = "UNASSOCIATED";
|
|
43
47
|
return Promise.resolve();
|
|
44
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* The key value store this Function may read, if it is associated with one.
|
|
51
|
+
*/
|
|
52
|
+
get keyValueStore() {
|
|
53
|
+
return this.associatedKeyValueStore;
|
|
54
|
+
}
|
|
45
55
|
/**
|
|
46
56
|
* Run the viewer-request CFF handler on a native Request.
|
|
57
|
+
*
|
|
58
|
+
* Awaited because a Function reading a key value store is async. One that
|
|
59
|
+
* reads nothing is synchronous and still works: awaiting a plain value is
|
|
60
|
+
* what makes both shapes the same here.
|
|
47
61
|
*/
|
|
48
|
-
handleViewerRequest(request) {
|
|
62
|
+
async handleViewerRequest(request) {
|
|
49
63
|
const cffEvent = this.eventAdapter.toViewerRequestEvent(request);
|
|
50
64
|
const handlerFunction = this
|
|
51
65
|
.handlerFunction;
|
|
52
|
-
const cffResult = handlerFunction(cffEvent);
|
|
66
|
+
const cffResult = await this.running(async () => await handlerFunction(cffEvent));
|
|
53
67
|
return this.eventAdapter.fromViewerRequestResult(cffResult, request);
|
|
54
68
|
}
|
|
55
69
|
/**
|
|
56
70
|
* Run the viewer-response CFF handler on a native Request and Response.
|
|
57
71
|
*/
|
|
58
|
-
handleViewerResponse(request, response) {
|
|
72
|
+
async handleViewerResponse(request, response) {
|
|
59
73
|
const cffEvent = this.eventAdapter.toViewerResponseEvent(request, response);
|
|
60
74
|
const handlerFunction = this
|
|
61
75
|
.handlerFunction;
|
|
62
|
-
const cffResult = handlerFunction(cffEvent);
|
|
76
|
+
const cffResult = await this.running(async () => await handlerFunction(cffEvent));
|
|
63
77
|
return this.eventAdapter.fromViewerResponseResult(cffResult, response);
|
|
64
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Run the handler with this Function's own `cf` in scope.
|
|
81
|
+
*
|
|
82
|
+
* A Function given as source code already has `cf` in its vm sandbox, so this
|
|
83
|
+
* is what gives one given as a function reference the same thing: the module
|
|
84
|
+
* is held in asynchronous context for the length of the invocation, and the
|
|
85
|
+
* global `cf` resolves to it. Setting it for both is harmless and means the
|
|
86
|
+
* two kinds of Function reach a store the same way.
|
|
87
|
+
*/
|
|
88
|
+
async running(handler) {
|
|
89
|
+
return await simCffCloudFrontGlobal.run(cffCloudFrontModule(this.associatedKeyValueStore), handler);
|
|
90
|
+
}
|
|
65
91
|
}
|
|
66
92
|
//# sourceMappingURL=sim-cloudfront-function.js.map
|