@kensio/yulin 1.11.0 → 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.
Files changed (114) hide show
  1. package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cfn-value-adapter.d.ts.map +1 -1
  2. package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cfn-value-adapter.js +8 -0
  3. package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cfn-value-adapter.js.map +1 -1
  4. package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-kvs-cfn.d.ts +28 -0
  5. package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-kvs-cfn.d.ts.map +1 -0
  6. package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-kvs-cfn.js +41 -0
  7. package/dist/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-kvs-cfn.js.map +1 -0
  8. package/dist/service/cloudfront/cff/function-code-input/cff-cloudfront-import.d.ts +21 -0
  9. package/dist/service/cloudfront/cff/function-code-input/cff-cloudfront-import.d.ts.map +1 -0
  10. package/dist/service/cloudfront/cff/function-code-input/cff-cloudfront-import.js +30 -0
  11. package/dist/service/cloudfront/cff/function-code-input/cff-cloudfront-import.js.map +1 -0
  12. package/dist/service/cloudfront/cff/function-code-input/cff-function-code-input.d.ts +3 -1
  13. package/dist/service/cloudfront/cff/function-code-input/cff-function-code-input.d.ts.map +1 -1
  14. package/dist/service/cloudfront/cff/function-code-input/cff-function-code-input.js +5 -17
  15. package/dist/service/cloudfront/cff/function-code-input/cff-function-code-input.js.map +1 -1
  16. package/dist/service/cloudfront/cff/function-code-input/cff-vm-source-handler.d.ts +13 -0
  17. package/dist/service/cloudfront/cff/function-code-input/cff-vm-source-handler.d.ts.map +1 -0
  18. package/dist/service/cloudfront/cff/function-code-input/cff-vm-source-handler.js +28 -0
  19. package/dist/service/cloudfront/cff/function-code-input/cff-vm-source-handler.js.map +1 -0
  20. package/dist/service/cloudfront/cff/kvs/cff-cloudfront-module.d.ts +28 -0
  21. package/dist/service/cloudfront/cff/kvs/cff-cloudfront-module.d.ts.map +1 -0
  22. package/dist/service/cloudfront/cff/kvs/cff-cloudfront-module.js +30 -0
  23. package/dist/service/cloudfront/cff/kvs/cff-cloudfront-module.js.map +1 -0
  24. package/dist/service/cloudfront/cff/kvs/cff-kvs-handle.d.ts +46 -0
  25. package/dist/service/cloudfront/cff/kvs/cff-kvs-handle.d.ts.map +1 -0
  26. package/dist/service/cloudfront/cff/kvs/cff-kvs-handle.js +60 -0
  27. package/dist/service/cloudfront/cff/kvs/cff-kvs-handle.js.map +1 -0
  28. package/dist/service/cloudfront/cff/kvs/sim-cff-cloudfront-global.d.ts +43 -0
  29. package/dist/service/cloudfront/cff/kvs/sim-cff-cloudfront-global.d.ts.map +1 -0
  30. package/dist/service/cloudfront/cff/kvs/sim-cff-cloudfront-global.js +66 -0
  31. package/dist/service/cloudfront/cff/kvs/sim-cff-cloudfront-global.js.map +1 -0
  32. package/dist/service/cloudfront/cff/kvs/sim-cff-key-value-store-users.d.ts +20 -0
  33. package/dist/service/cloudfront/cff/kvs/sim-cff-key-value-store-users.d.ts.map +1 -0
  34. package/dist/service/cloudfront/cff/kvs/sim-cff-key-value-store-users.js +25 -0
  35. package/dist/service/cloudfront/cff/kvs/sim-cff-key-value-store-users.js.map +1 -0
  36. package/dist/service/cloudfront/cff/sim-cloudfront-function.d.ts +23 -2
  37. package/dist/service/cloudfront/cff/sim-cloudfront-function.d.ts.map +1 -1
  38. package/dist/service/cloudfront/cff/sim-cloudfront-function.js +30 -4
  39. package/dist/service/cloudfront/cff/sim-cloudfront-function.js.map +1 -1
  40. package/dist/service/cloudfront/cfn/cff/sim-cfn-cff-function-config.d.ts +6 -0
  41. package/dist/service/cloudfront/cfn/cff/sim-cfn-cff-function-config.d.ts.map +1 -1
  42. package/dist/service/cloudfront/cfn/cff/sim-cfn-cff-function-config.js +43 -0
  43. package/dist/service/cloudfront/cfn/cff/sim-cfn-cff-function-config.js.map +1 -1
  44. package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-config.d.ts +38 -0
  45. package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-config.d.ts.map +1 -0
  46. package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-config.js +49 -0
  47. package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-config.js.map +1 -0
  48. package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-creator.d.ts +33 -0
  49. package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-creator.d.ts.map +1 -0
  50. package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-creator.js +54 -0
  51. package/dist/service/cloudfront/cfn/key-value-store/sim-cfn-cf-kvs-creator.js.map +1 -0
  52. package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.d.ts +1 -0
  53. package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.d.ts.map +1 -1
  54. package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.js +12 -0
  55. package/dist/service/cloudfront/cfn/sim-cfn-cloudfront-resource-factory.js.map +1 -1
  56. package/dist/service/cloudfront/command/create-distribution/create-distribution.command.d.ts +6 -0
  57. package/dist/service/cloudfront/command/create-distribution/create-distribution.command.d.ts.map +1 -1
  58. package/dist/service/cloudfront/command/create-distribution/sim-cf-distro-config-normalizer.d.ts.map +1 -1
  59. package/dist/service/cloudfront/command/create-distribution/sim-cf-distro-config-normalizer.js +8 -6
  60. package/dist/service/cloudfront/command/create-distribution/sim-cf-distro-config-normalizer.js.map +1 -1
  61. package/dist/service/cloudfront/command/create-function/create-function-kvs-association.d.ts +24 -0
  62. package/dist/service/cloudfront/command/create-function/create-function-kvs-association.d.ts.map +1 -0
  63. package/dist/service/cloudfront/command/create-function/create-function-kvs-association.js +50 -0
  64. package/dist/service/cloudfront/command/create-function/create-function-kvs-association.js.map +1 -0
  65. package/dist/service/cloudfront/command/create-function/create-function.command.d.ts +6 -0
  66. package/dist/service/cloudfront/command/create-function/create-function.command.d.ts.map +1 -1
  67. package/dist/service/cloudfront/command/create-function/create-function.handler.d.ts +3 -0
  68. package/dist/service/cloudfront/command/create-function/create-function.handler.d.ts.map +1 -1
  69. package/dist/service/cloudfront/command/create-function/create-function.handler.js +11 -2
  70. package/dist/service/cloudfront/command/create-function/create-function.handler.js.map +1 -1
  71. package/dist/service/cloudfront/command/key-value-store/sim-cf-delete-key-value-store.js +1 -1
  72. package/dist/service/cloudfront/command/key-value-store/sim-cf-delete-key-value-store.js.map +1 -1
  73. package/dist/service/cloudfront/command/sim-cf-list-quantity.d.ts +20 -0
  74. package/dist/service/cloudfront/command/sim-cf-list-quantity.d.ts.map +1 -0
  75. package/dist/service/cloudfront/command/sim-cf-list-quantity.js +36 -0
  76. package/dist/service/cloudfront/command/sim-cf-list-quantity.js.map +1 -0
  77. package/dist/service/cloudfront/controller/cff/sim-cff-applicator.d.ts +2 -2
  78. package/dist/service/cloudfront/controller/cff/sim-cff-applicator.d.ts.map +1 -1
  79. package/dist/service/cloudfront/controller/cff/sim-cff-applicator.js +6 -6
  80. package/dist/service/cloudfront/controller/cff/sim-cff-applicator.js.map +1 -1
  81. package/dist/service/cloudfront/controller/sim-cloudfront-request-pipeline.js +2 -2
  82. package/dist/service/cloudfront/controller/sim-cloudfront-request-pipeline.js.map +1 -1
  83. package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-properties.d.ts.map +1 -1
  84. package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-properties.js +5 -3
  85. package/dist/service/cloudfront/distribution/configurator/sim-cf-behavior-properties.js.map +1 -1
  86. package/dist/service/cloudfront/error/sim-cf-key-value-store.error.d.ts +88 -0
  87. package/dist/service/cloudfront/error/sim-cf-key-value-store.error.d.ts.map +1 -0
  88. package/dist/service/cloudfront/error/sim-cf-key-value-store.error.js +104 -0
  89. package/dist/service/cloudfront/error/sim-cf-key-value-store.error.js.map +1 -0
  90. package/dist/service/cloudfront/error/sim-cloudfront.error.d.ts +10 -63
  91. package/dist/service/cloudfront/error/sim-cloudfront.error.d.ts.map +1 -1
  92. package/dist/service/cloudfront/error/sim-cloudfront.error.js +11 -74
  93. package/dist/service/cloudfront/error/sim-cloudfront.error.js.map +1 -1
  94. package/dist/service/cloudfront/globals.d.ts +12 -0
  95. package/dist/service/cloudfront/globals.d.ts.map +1 -1
  96. package/dist/service/cloudfront/globals.js.map +1 -1
  97. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-keys.js +1 -1
  98. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-keys.js.map +1 -1
  99. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-registry.js +1 -1
  100. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-registry.js.map +1 -1
  101. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-users.d.ts +7 -5
  102. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-users.d.ts.map +1 -1
  103. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store-users.js.map +1 -1
  104. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store.js +1 -1
  105. package/dist/service/cloudfront/key-value-store/sim-cf-key-value-store.js.map +1 -1
  106. package/dist/service/cloudfront/sim-cloudfront-commands.d.ts.map +1 -1
  107. package/dist/service/cloudfront/sim-cloudfront-commands.js +7 -4
  108. package/dist/service/cloudfront/sim-cloudfront-commands.js.map +1 -1
  109. package/dist/service/cloudfront/sim-cloudfront.d.ts +1 -1
  110. package/dist/service/cloudfront/sim-cloudfront.d.ts.map +1 -1
  111. package/dist/service/cloudfront/sim-cloudfront.js.map +1 -1
  112. package/dist/service/cloudfront/typings/cloudfront-functions.namespace.d.ts +9 -2
  113. package/dist/service/cloudfront/typings/cloudfront-functions.namespace.d.ts.map +1 -1
  114. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"sim-cloudfront-cfn-value-adapter.d.ts","sourceRoot":"","sources":["../../../../../../src/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cfn-value-adapter.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,oCAAoC,EACpC,yBAAyB,EAC1B,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,oCAAoC,GAC/C,yBAAyB,CAoC3B"}
1
+ {"version":3,"file":"sim-cloudfront-cfn-value-adapter.d.ts","sourceRoot":"","sources":["../../../../../../src/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cfn-value-adapter.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,oCAAoC,EACpC,yBAAyB,EAC1B,MAAM,sCAAsC,CAAC;AAE9C;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,oCAAoC,GAC/C,yBAAyB,CA6C3B"}
@@ -6,6 +6,8 @@ import { SimCloudFrontResponseHeadersPolicy } from "../../../../cloudfront/respo
6
6
  import { SimCloudFrontResponseHeadersPolicyCfn } from "./sim-cloudfront-rh-policy-cfn.js";
7
7
  import { SimCloudFrontOriginAccessControl } from "../../../../cloudfront/origin-access-control/sim-cf-origin-access-control.js";
8
8
  import { SimCloudFrontOriginAccessControlCfn } from "./sim-cloudfront-oac-cfn.js";
9
+ import { SimCloudFrontKeyValueStore } from "../../../../cloudfront/key-value-store/sim-cf-key-value-store.js";
10
+ import { SimCloudFrontKeyValueStoreCfn } from "./sim-cloudfront-kvs-cfn.js";
9
11
  /**
10
12
  * The CloudFormation-facing value adapter for a simulated CloudFront Resource.
11
13
  */
@@ -32,6 +34,12 @@ export function cloudFrontValueAdapter(properties) {
32
34
  originAccessControl: properties.simResource,
33
35
  });
34
36
  }
37
+ if (properties.type === "AWS::CloudFront::KeyValueStore" &&
38
+ properties.simResource instanceof SimCloudFrontKeyValueStore) {
39
+ return new SimCloudFrontKeyValueStoreCfn({
40
+ keyValueStore: properties.simResource,
41
+ });
42
+ }
35
43
  return undefined;
36
44
  }
37
45
  //# sourceMappingURL=sim-cloudfront-cfn-value-adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sim-cloudfront-cfn-value-adapter.js","sourceRoot":"","sources":["../../../../../../src/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cfn-value-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oEAAoE,CAAC;AAC/G,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uDAAuD,CAAC;AAC9F,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,kCAAkC,EAAE,MAAM,kFAAkF,CAAC;AACtI,OAAO,EAAE,qCAAqC,EAAE,MAAM,mCAAmC,CAAC;AAC1F,OAAO,EAAE,gCAAgC,EAAE,MAAM,8EAA8E,CAAC;AAChI,OAAO,EAAE,mCAAmC,EAAE,MAAM,6BAA6B,CAAC;AAMlF;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAgD;IAEhD,IACE,UAAU,CAAC,IAAI,KAAK,+BAA+B;QACnD,UAAU,CAAC,WAAW,YAAY,yBAAyB,EAC3D,CAAC;QACD,OAAO,IAAI,4BAA4B,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,IACE,UAAU,CAAC,IAAI,KAAK,2BAA2B;QAC/C,UAAU,CAAC,WAAW,YAAY,qBAAqB,EACvD,CAAC;QACD,OAAO,IAAI,wBAAwB,CAAC;YAClC,kBAAkB,EAAE,UAAU,CAAC,WAAW;SAC3C,CAAC,CAAC;IACL,CAAC;IAED,IACE,UAAU,CAAC,IAAI,KAAK,wCAAwC;QAC5D,UAAU,CAAC,WAAW,YAAY,kCAAkC,EACpE,CAAC;QACD,OAAO,IAAI,qCAAqC,CAAC;YAC/C,MAAM,EAAE,UAAU,CAAC,WAAW;SAC/B,CAAC,CAAC;IACL,CAAC;IAED,IACE,UAAU,CAAC,IAAI,KAAK,sCAAsC;QAC1D,UAAU,CAAC,WAAW,YAAY,gCAAgC,EAClE,CAAC;QACD,OAAO,IAAI,mCAAmC,CAAC;YAC7C,mBAAmB,EAAE,UAAU,CAAC,WAAW;SAC5C,CAAC,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
1
+ {"version":3,"file":"sim-cloudfront-cfn-value-adapter.js","sourceRoot":"","sources":["../../../../../../src/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-cfn-value-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oEAAoE,CAAC;AAC/G,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uDAAuD,CAAC;AAC9F,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,kCAAkC,EAAE,MAAM,kFAAkF,CAAC;AACtI,OAAO,EAAE,qCAAqC,EAAE,MAAM,mCAAmC,CAAC;AAC1F,OAAO,EAAE,gCAAgC,EAAE,MAAM,8EAA8E,CAAC;AAChI,OAAO,EAAE,mCAAmC,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AAC9G,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAM5E;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAgD;IAEhD,IACE,UAAU,CAAC,IAAI,KAAK,+BAA+B;QACnD,UAAU,CAAC,WAAW,YAAY,yBAAyB,EAC3D,CAAC;QACD,OAAO,IAAI,4BAA4B,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,IACE,UAAU,CAAC,IAAI,KAAK,2BAA2B;QAC/C,UAAU,CAAC,WAAW,YAAY,qBAAqB,EACvD,CAAC;QACD,OAAO,IAAI,wBAAwB,CAAC;YAClC,kBAAkB,EAAE,UAAU,CAAC,WAAW;SAC3C,CAAC,CAAC;IACL,CAAC;IAED,IACE,UAAU,CAAC,IAAI,KAAK,wCAAwC;QAC5D,UAAU,CAAC,WAAW,YAAY,kCAAkC,EACpE,CAAC;QACD,OAAO,IAAI,qCAAqC,CAAC;YAC/C,MAAM,EAAE,UAAU,CAAC,WAAW;SAC/B,CAAC,CAAC;IACL,CAAC;IAED,IACE,UAAU,CAAC,IAAI,KAAK,sCAAsC;QAC1D,UAAU,CAAC,WAAW,YAAY,gCAAgC,EAClE,CAAC;QACD,OAAO,IAAI,mCAAmC,CAAC;YAC7C,mBAAmB,EAAE,UAAU,CAAC,WAAW;SAC5C,CAAC,CAAC;IACL,CAAC;IAED,IACE,UAAU,CAAC,IAAI,KAAK,gCAAgC;QACpD,UAAU,CAAC,WAAW,YAAY,0BAA0B,EAC5D,CAAC;QACD,OAAO,IAAI,6BAA6B,CAAC;YACvC,aAAa,EAAE,UAAU,CAAC,WAAW;SACtC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { SimCloudFrontKeyValueStore } from "../../../../cloudfront/key-value-store/sim-cf-key-value-store.js";
2
+ import type { SimCfnTemplateValue } from "../../../template/value/sim-cfn-template-value.js";
3
+ import type { SimCfnResourceValueAdapter } from "../sim-cfn-resource-value-adapter.js";
4
+ interface SimCloudFrontKeyValueStoreCfnProperties {
5
+ readonly keyValueStore: SimCloudFrontKeyValueStore;
6
+ }
7
+ /**
8
+ * CloudFormation-facing behavior for an AWS::CloudFront::KeyValueStore
9
+ * Resource.
10
+ */
11
+ export declare class SimCloudFrontKeyValueStoreCfn implements SimCfnResourceValueAdapter {
12
+ private readonly keyValueStore;
13
+ constructor(properties: SimCloudFrontKeyValueStoreCfnProperties);
14
+ /**
15
+ * CloudFormation Ref for AWS::CloudFront::KeyValueStore returns the ARN.
16
+ *
17
+ * That is the odd one out among the CloudFront resources here, which Ref to
18
+ * an ID, and it is what makes `Ref` usable straight from a Function's
19
+ * `KeyValueStoreARN`.
20
+ */
21
+ refValue(): SimCfnTemplateValue;
22
+ /**
23
+ * CloudFormation attributes for AWS::CloudFront::KeyValueStore.
24
+ */
25
+ attributeValue(attributeName: string): SimCfnTemplateValue;
26
+ }
27
+ export {};
28
+ //# sourceMappingURL=sim-cloudfront-kvs-cfn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sim-cloudfront-kvs-cfn.d.ts","sourceRoot":"","sources":["../../../../../../src/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-kvs-cfn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AACnH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAC7F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAEvF,UAAU,uCAAuC;IAC/C,QAAQ,CAAC,aAAa,EAAE,0BAA0B,CAAC;CACpD;AAED;;;GAGG;AACH,qBAAa,6BAA8B,YAAW,0BAA0B;IAC9E,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA6B;IAE3D,YAAY,UAAU,EAAE,uCAAuC,EAE9D;IAED;;;;;;OAMG;IACH,QAAQ,IAAI,mBAAmB,CAE9B;IAED;;OAEG;IACH,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,mBAAmB,CAgBzD;CACF"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * CloudFormation-facing behavior for an AWS::CloudFront::KeyValueStore
3
+ * Resource.
4
+ */
5
+ export class SimCloudFrontKeyValueStoreCfn {
6
+ keyValueStore;
7
+ constructor(properties) {
8
+ this.keyValueStore = properties.keyValueStore;
9
+ }
10
+ /**
11
+ * CloudFormation Ref for AWS::CloudFront::KeyValueStore returns the ARN.
12
+ *
13
+ * That is the odd one out among the CloudFront resources here, which Ref to
14
+ * an ID, and it is what makes `Ref` usable straight from a Function's
15
+ * `KeyValueStoreARN`.
16
+ */
17
+ refValue() {
18
+ return this.keyValueStore.arn;
19
+ }
20
+ /**
21
+ * CloudFormation attributes for AWS::CloudFront::KeyValueStore.
22
+ */
23
+ attributeValue(attributeName) {
24
+ switch (attributeName) {
25
+ case "Arn": {
26
+ return this.keyValueStore.arn;
27
+ }
28
+ case "Id": {
29
+ return this.keyValueStore.id;
30
+ }
31
+ case "Status": {
32
+ return this.keyValueStore.status;
33
+ }
34
+ default: {
35
+ /* v8 ignore next */
36
+ return `${this.keyValueStore.id}.${attributeName}`;
37
+ }
38
+ }
39
+ }
40
+ }
41
+ //# sourceMappingURL=sim-cloudfront-kvs-cfn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sim-cloudfront-kvs-cfn.js","sourceRoot":"","sources":["../../../../../../src/service/cloudformation/resource/cfn/cloudfront/sim-cloudfront-kvs-cfn.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,OAAO,6BAA6B;IACvB,aAAa,CAA6B;IAE3D,YAAY,UAAmD;QAC7D,IAAI,CAAC,aAAa,GAAG,UAAU,CAAC,aAAa,CAAC;IAChD,CAAC;IAED;;;;;;OAMG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,aAAqB;QAClC,QAAQ,aAAa,EAAE,CAAC;YACtB,KAAK,KAAK,EAAE,CAAC;gBACX,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;YAChC,CAAC;YACD,KAAK,IAAI,EAAE,CAAC;gBACV,OAAO,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;YAC/B,CAAC;YACD,KAAK,QAAQ,EAAE,CAAC;gBACd,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;YACnC,CAAC;YACD,SAAS,CAAC;gBACR,oBAAoB;gBACpB,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,IAAI,aAAa,EAAE,CAAC;YACrD,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Rewrite the `cloudfront` import out of CloudFront Function source.
3
+ *
4
+ * JS 2.0 has no module system to speak of, but it does let a Function reach the
5
+ * `cf` helpers with this one import. Source runs here in a `vm.Script`, which
6
+ * is not a module and treats any import statement as a syntax error, so the
7
+ * import is turned into a binding to the `cf` the sandbox already holds.
8
+ *
9
+ * The line is replaced rather than removed so that line numbers in a stack
10
+ * trace still line up with the source the caller wrote.
11
+ *
12
+ * The binding reads `globalThis.cf` rather than the bare `cf` the sandbox
13
+ * holds, because the usual binding name is `cf` and `const cf = cf` would be a
14
+ * reference to a name in its own initializer.
15
+ *
16
+ * Any other import is left alone: it is not something the runtime would run
17
+ * either, and leaving it in means the syntax error names the line the Function
18
+ * actually got wrong.
19
+ */
20
+ export declare function cffSourceWithoutCloudFrontImport(source: string): string;
21
+ //# sourceMappingURL=cff-cloudfront-import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cff-cloudfront-import.d.ts","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/function-code-input/cff-cloudfront-import.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKvE"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `import cf from "cloudfront"`, in the forms the runtime accepts it.
3
+ *
4
+ * The binding name is captured because a Function may call it something other
5
+ * than `cf`, and the quoting and the semicolon are both optional.
6
+ */
7
+ const cloudFrontImport = /^[\t ]*import[\t ]+(?<binding>[A-Za-z_$][\w$]*)[\t ]+from[\t ]+["']cloudfront["'][\t ]*;?[\t ]*$/gmu;
8
+ /**
9
+ * Rewrite the `cloudfront` import out of CloudFront Function source.
10
+ *
11
+ * JS 2.0 has no module system to speak of, but it does let a Function reach the
12
+ * `cf` helpers with this one import. Source runs here in a `vm.Script`, which
13
+ * is not a module and treats any import statement as a syntax error, so the
14
+ * import is turned into a binding to the `cf` the sandbox already holds.
15
+ *
16
+ * The line is replaced rather than removed so that line numbers in a stack
17
+ * trace still line up with the source the caller wrote.
18
+ *
19
+ * The binding reads `globalThis.cf` rather than the bare `cf` the sandbox
20
+ * holds, because the usual binding name is `cf` and `const cf = cf` would be a
21
+ * reference to a name in its own initializer.
22
+ *
23
+ * Any other import is left alone: it is not something the runtime would run
24
+ * either, and leaving it in means the syntax error names the line the Function
25
+ * actually got wrong.
26
+ */
27
+ export function cffSourceWithoutCloudFrontImport(source) {
28
+ return source.replaceAll(cloudFrontImport, (_match, binding) => `const ${binding} = globalThis.cf;`);
29
+ }
30
+ //# sourceMappingURL=cff-cloudfront-import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cff-cloudfront-import.js","sourceRoot":"","sources":["../../../../../src/service/cloudfront/cff/function-code-input/cff-cloudfront-import.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,gBAAgB,GACpB,qGAAqG,CAAC;AAExG;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gCAAgC,CAAC,MAAc;IAC7D,OAAO,MAAM,CAAC,UAAU,CACtB,gBAAgB,EAChB,CAAC,MAAM,EAAE,OAAe,EAAE,EAAE,CAAC,SAAS,OAAO,mBAAmB,CACjE,CAAC;AACJ,CAAC"}
@@ -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
- constructor(functionCodeInput: FunctionCodeInput);
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;AAGzG,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;IAE7B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAA9C,YAA6B,iBAAiB,EAAE,iBAAiB,EAAI;IAErE;;OAEG;IACH,sBAAsB,IAAI,CAAC,CAM1B;IAED,OAAO,CAAC,2BAA2B;CAsBpC"}
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 vm from "node:vm";
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
- constructor(functionCodeInput) {
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
- const context = vm.createContext({
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;AAElE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIzB;;;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;IAIhB,iBAAiB;IAA9C,YAA6B,iBAAoC;iCAApC,iBAAiB;IAAsB,CAAC;IAErE;;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;QACpE,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC;YAC/B,OAAO;SACR,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,EAAE,CAAC,MAAM,CAAC;MAC3B,MAAM;;KAEP,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE;YAC3C,OAAO,EAAE,EAAE,EAAE,kDAAkD;YAC/D,aAAa,EAAE,IAAI;SACpB,CAA+B,CAAC;QAEjC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;YAClC,MAAM,IAAI,SAAS,CACjB,4DAA4D,CAC7D,CAAC;QACJ,CAAC;QAED,OAAO,OAAY,CAAC;IACtB,CAAC;CACF"}
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"}