@kensio/yulin 1.20.14 → 1.20.16

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 (154) hide show
  1. package/README.md +13 -0
  2. package/{dist/config/oxlint/cffjs2.oxlintrc.json → cffjs2.oxlintrc.json} +1 -1
  3. package/dist/config/oxlint/cffjs2.oxlint.config.js +4 -3
  4. package/dist/sdk/module/sim-sdk-module-client-interceptor.d.ts +5 -0
  5. package/dist/sdk/module/sim-sdk-module-client-interceptor.js +14 -0
  6. package/dist/sdk/module/sim-sdk-static-client-factory.d.ts +26 -0
  7. package/dist/sdk/module/sim-sdk-static-client-factory.js +59 -0
  8. package/dist/sdk/send-patch.d.ts +8 -0
  9. package/dist/sdk/send-patch.js +11 -0
  10. package/dist/service/aws/caller/sim-aws-caller-resolver.d.ts +28 -6
  11. package/dist/service/aws/caller/sim-aws-caller-resolver.js +18 -11
  12. package/dist/service/aws/caller/sim-aws-caller.d.ts +9 -0
  13. package/dist/service/aws/caller/sim-aws-resolved-caller.d.ts +19 -0
  14. package/dist/service/aws/caller/sim-aws-resolved-caller.js +26 -0
  15. package/dist/service/aws/factory/sim-aws-account-region-service-builder.d.ts +6 -0
  16. package/dist/service/aws/factory/sim-aws-account-region-service-builder.js +3 -0
  17. package/dist/service/aws/factory/sim-aws-account-service-cache.d.ts +6 -0
  18. package/dist/service/aws/factory/sim-aws-account-service-cache.js +5 -0
  19. package/dist/service/aws/factory/sim-aws-service-factory.d.ts +5 -0
  20. package/dist/service/aws/factory/sim-aws-service-factory.js +6 -0
  21. package/dist/service/aws/sim-aws-properties.d.ts +15 -0
  22. package/dist/service/aws/sim-aws.js +2 -1
  23. package/dist/service/cloudformation/resource/resolve/property/sim-cfn-resource-property-resolver.d.ts +11 -4
  24. package/dist/service/cloudformation/resource/resolve/property/sim-cfn-resource-property-resolver.js +21 -8
  25. package/dist/service/cloudformation/resource/sim-cfn-resource.type.d.ts +9 -0
  26. package/dist/service/cloudformation/template/dynamic/make-sim-cfn-dynamic-references.d.ts +2 -0
  27. package/dist/service/cloudformation/template/dynamic/make-sim-cfn-dynamic-references.js +2 -2
  28. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-reference-resolvers.d.ts +10 -0
  29. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-reference-resolvers.js +4 -3
  30. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-reference-scan.d.ts +11 -0
  31. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-reference-scan.js +21 -0
  32. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-references.d.ts +24 -2
  33. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-references.js +50 -11
  34. package/dist/service/cloudformation/template/dynamic/sim-cfn-prefetched-dynamic-references.d.ts +42 -0
  35. package/dist/service/cloudformation/template/dynamic/sim-cfn-prefetched-dynamic-references.js +80 -0
  36. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-failures.d.ts +16 -0
  37. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-failures.js +19 -0
  38. package/dist/service/iam/authorize/context/sim-iam-auth-z-caller-context-builder.d.ts +30 -7
  39. package/dist/service/iam/authorize/context/sim-iam-auth-z-caller-context-builder.js +20 -11
  40. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.d.ts +2 -1
  41. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.js +5 -1
  42. package/dist/service/iam/authorize/match/sim-iam-policy-principal-matcher.d.ts +10 -0
  43. package/dist/service/iam/authorize/match/sim-iam-policy-principal-matcher.js +15 -3
  44. package/dist/service/iam/authorize/sim-iam-account-auth-z.d.ts +11 -4
  45. package/dist/service/iam/authorize/sim-iam-account-auth-z.js +5 -3
  46. package/dist/service/iam/authorize/sim-iam-authorizer.d.ts +2 -1
  47. package/dist/service/iam/authorize/sim-iam-authorizer.js +1 -0
  48. package/dist/service/iam/command/policy/create-policy/create-policy-input-resolver.js +4 -1
  49. package/dist/service/iam/command/policy/put-role-policy/put-role-policy.handler.js +5 -1
  50. package/dist/service/iam/command/policy/put-user-policy/put-user-policy.handler.js +5 -1
  51. package/dist/service/iam/policy/parse/sim-iam-document-parser.d.ts +4 -1
  52. package/dist/service/iam/policy/parse/sim-iam-document-parser.js +13 -15
  53. package/dist/service/iam/policy/sim-iam-statement-label.d.ts +28 -0
  54. package/dist/service/iam/policy/sim-iam-statement-label.js +17 -0
  55. package/dist/service/iam/policy/sim-iam-statement-strings.d.ts +11 -0
  56. package/dist/service/iam/policy/sim-iam-statement-strings.js +27 -0
  57. package/dist/service/iam/role/sim-iam-role-with-policy.factory.d.ts +9 -0
  58. package/dist/service/iam/role/sim-iam-role-with-policy.factory.js +4 -2
  59. package/dist/service/iam/sim-iam-account-parts.d.ts +8 -0
  60. package/dist/service/iam/sim-iam-account-parts.js +1 -0
  61. package/dist/service/iam/validate/sim-iam-policy-document-validator.d.ts +9 -2
  62. package/dist/service/iam/validate/sim-iam-policy-document-validator.js +37 -19
  63. package/dist/service/lambda/function/code/sim-lambda-vm-zip-function.factory.d.ts +7 -0
  64. package/dist/service/lambda/function/code/sim-lambda-vm-zip-function.factory.js +1 -0
  65. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-provided-sdk-module.d.ts +19 -0
  66. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-provided-sdk-module.js +78 -0
  67. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-sdk-packages-not-installed.error.d.ts +15 -0
  68. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-sdk-packages-not-installed.error.js +27 -0
  69. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-vm-sdk-module-provider.d.ts +9 -0
  70. package/dist/service/lambda/function/code/vm/sdk/sim-sdk-lambda-vm-module-provider.d.ts +10 -0
  71. package/dist/service/lambda/function/code/vm/sdk/sim-sdk-lambda-vm-module-provider.js +28 -34
  72. package/dist/service/lambda/function/code/vm/sim-lambda-host-modules.d.ts +15 -0
  73. package/dist/service/lambda/function/code/vm/sim-lambda-host-modules.js +31 -0
  74. package/dist/service/lambda/function/code/vm/sim-lambda-vm-module-resolver.d.ts +7 -0
  75. package/dist/service/lambda/function/code/vm/sim-lambda-vm-module-resolver.js +15 -0
  76. package/dist/service/lambda/function/code/vm/sim-lambda-vm-modules.js +5 -4
  77. package/dist/service/s3/command/put-bucket-policy/put-bucket-policy.handler.js +4 -1
  78. package/dist/service/scheduler/delivery/sim-scheduler-delivery-failures.d.ts +16 -0
  79. package/dist/service/scheduler/delivery/sim-scheduler-delivery-failures.js +19 -0
  80. package/dist/service/scheduler/index.d.ts +1 -1
  81. package/dist/service/scheduler/index.js +1 -1
  82. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-dynamic-reference-resolver.d.ts +13 -15
  83. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-dynamic-reference-resolver.js +22 -43
  84. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-reference-stand-in.d.ts +9 -0
  85. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-reference-stand-in.js +14 -0
  86. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-reference-value.d.ts +12 -0
  87. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-reference-value.js +29 -0
  88. package/dist/service/ssm/cfn/dynamic/sim-cfn-ssm-dynamic-reference-resolver.d.ts +22 -6
  89. package/dist/service/ssm/cfn/dynamic/sim-cfn-ssm-dynamic-reference-resolver.js +39 -24
  90. package/dist/service/ssm/cfn/dynamic/sim-cfn-ssm-secure-dynamic-reference-resolver.d.ts +10 -5
  91. package/dist/service/ssm/cfn/dynamic/sim-cfn-ssm-secure-dynamic-reference-resolver.js +10 -8
  92. package/dist/service/ssm/sim-ssm.d.ts +10 -2
  93. package/dist/service/ssm/sim-ssm.js +12 -4
  94. package/dist/service/sts/auth-z/assume-role-auth-z-coordinator.d.ts +9 -2
  95. package/dist/service/sts/auth-z/assume-role-auth-z-coordinator.js +2 -2
  96. package/dist/service/sts/auth-z/assume-role-source-account-auth-z.d.ts +10 -4
  97. package/dist/service/sts/auth-z/assume-role-source-account-auth-z.js +8 -7
  98. package/dist/service/sts/auth-z/assume-role-target-auth-z.d.ts +2 -2
  99. package/dist/service/sts/auth-z/assume-role-trust-policy-authorizer.d.ts +6 -2
  100. package/dist/service/sts/auth-z/assume-role-trust-policy-authorizer.js +14 -11
  101. package/dist/service/sts/command/assume-role/assume-role.handler.d.ts +5 -1
  102. package/dist/service/sts/command/assume-role/assume-role.handler.js +5 -2
  103. package/dist/service/sts/command/get-caller-identity/get-caller-identity.handler.d.ts +5 -1
  104. package/dist/service/sts/command/get-caller-identity/get-caller-identity.handler.js +4 -1
  105. package/dist/service/sts/service-role/sim-service-role.js +5 -1
  106. package/dist/service/sts/sim-sts.d.ts +9 -1
  107. package/dist/service/sts/sim-sts.js +4 -0
  108. package/docs/README.md +54 -0
  109. package/docs/ai-skill/README.md +69 -0
  110. package/docs/cli/README.md +284 -0
  111. package/docs/factories/README.md +140 -0
  112. package/docs/lint/README.md +176 -0
  113. package/docs/non-aws-dependencies/README.md +261 -0
  114. package/docs/sdk/README.md +272 -0
  115. package/docs/serve/README.md +1126 -0
  116. package/docs/services/acm/README.md +823 -0
  117. package/docs/services/apigateway/README.md +1919 -0
  118. package/docs/services/apigatewayv2/README.md +2678 -0
  119. package/docs/services/athena/README.md +1044 -0
  120. package/docs/services/bedrock/README.md +350 -0
  121. package/docs/services/cloudformation/README.md +3440 -0
  122. package/docs/services/cloudfront/README.md +2874 -0
  123. package/docs/services/cloudwatch/README.md +420 -0
  124. package/docs/services/cognito/README.md +4923 -0
  125. package/docs/services/dynamodb/README.md +3784 -0
  126. package/docs/services/ecr/README.md +302 -0
  127. package/docs/services/ecs/README.md +2010 -0
  128. package/docs/services/elbv2/README.md +1897 -0
  129. package/docs/services/eventbridge/README.md +1110 -0
  130. package/docs/services/firehose/README.md +805 -0
  131. package/docs/services/glue/README.md +501 -0
  132. package/docs/services/iam/README.md +1283 -0
  133. package/docs/services/kinesis/README.md +454 -0
  134. package/docs/services/kms/README.md +659 -0
  135. package/docs/services/lambda/README.md +3645 -0
  136. package/docs/services/logs/README.md +868 -0
  137. package/docs/services/organizations/README.md +574 -0
  138. package/docs/services/personalize/README.md +835 -0
  139. package/docs/services/rekognition/README.md +1070 -0
  140. package/docs/services/route53/README.md +1783 -0
  141. package/docs/services/s3/README.md +3024 -0
  142. package/docs/services/scheduler/README.md +806 -0
  143. package/docs/services/secretsmanager/README.md +667 -0
  144. package/docs/services/ses/README.md +1011 -0
  145. package/docs/services/sns/README.md +1904 -0
  146. package/docs/services/sqs/README.md +1185 -0
  147. package/docs/services/ssm/README.md +1072 -0
  148. package/docs/services/stepfunctions/README.md +1332 -0
  149. package/docs/services/sts/README.md +245 -0
  150. package/docs/services/wafv2/README.md +1378 -0
  151. package/docs/terraform/README.md +248 -0
  152. package/docs/time/README.md +284 -0
  153. package/llms.txt +59 -0
  154. package/package.json +9 -5
@@ -0,0 +1,78 @@
1
+ import { assertDefined } from "../../../../../../util/type-guard/defined.js";
2
+ import { SimLambdaVmModuleResolver } from "../sim-lambda-vm-module-resolver.js";
3
+ import { SimLambdaSdkPackagesNotInstalledError } from "./sim-lambda-sdk-packages-not-installed.error.js";
4
+ /**
5
+ * The archive entries worth reading specifiers out of.
6
+ */
7
+ const javaScriptFilePattern = /\.[cm]?js$/;
8
+ /**
9
+ * A quoted `@aws-sdk/*` specifier, however a file asks for it. A `require`
10
+ * call, a dynamic `import`, and a static import's `from` clause all match.
11
+ */
12
+ const awsSdkImportPattern = /(?:\b(?:require|import)\s*\(|\b(?:from|import)\b)\s*["'](@aws-sdk\/[^"']+)["']/g;
13
+ /**
14
+ * The module the runtime provides for a specifier the archive does not
15
+ * bundle, or undefined for a specifier the provider does not serve.
16
+ *
17
+ * A package the project has not installed is refused here naming every other
18
+ * AWS SDK package the function code imports and the project is missing too.
19
+ */
20
+ export function provideSdkModule(specifier, context) {
21
+ try {
22
+ return context.sdkModuleProvider.provideModule(specifier);
23
+ }
24
+ catch (error) {
25
+ throw everyMissingSdkPackage(error, context);
26
+ }
27
+ }
28
+ /**
29
+ * The refusal to raise for a package the project has not installed, naming
30
+ * every other AWS SDK package the function code imports and the project is
31
+ * missing too. Any other error stands as it is.
32
+ *
33
+ * The runtime provides a package when the code requires it, so on its own a
34
+ * refusal only ever names the one the code reached. A function importing two
35
+ * absent packages would then cost two runs and two installs, and the archive
36
+ * is the only place to read what a third-party function imports. So the
37
+ * archive is read here, once a package has already turned out to be missing,
38
+ * and one install covers the set. An archive that runs is never read.
39
+ */
40
+ function everyMissingSdkPackage(error, context) {
41
+ if (!(error instanceof SimLambdaSdkPackagesNotInstalledError)) {
42
+ return error;
43
+ }
44
+ const resolver = new SimLambdaVmModuleResolver(context.archive);
45
+ const candidates = archiveAwsSdkImports(context.archive).filter((specifier) => !error.specifiers.includes(specifier) &&
46
+ !resolver.bundlesPackage(specifier));
47
+ const missing = context.sdkModuleProvider.unresolvedModules?.(candidates) ?? [];
48
+ if (missing.length === 0) {
49
+ return error;
50
+ }
51
+ return new SimLambdaSdkPackagesNotInstalledError([...error.specifiers, ...missing], { cause: error.cause });
52
+ }
53
+ /**
54
+ * The AWS SDK packages a function code archive's own files import, in the
55
+ * order they appear.
56
+ *
57
+ * Bundled dependencies are left out. What a package under `node_modules/`
58
+ * imports is that package's own business, resolved from the bundle beside it,
59
+ * and reading a vendored tree to name one more install is a poor trade.
60
+ */
61
+ function archiveAwsSdkImports(archive) {
62
+ const specifiers = new Set();
63
+ for (const filePath of archive.filePaths()) {
64
+ if (!isFunctionCodeFile(filePath)) {
65
+ continue;
66
+ }
67
+ const source = archive.file(filePath).toString();
68
+ for (const match of source.matchAll(awsSdkImportPattern)) {
69
+ const specifier = match[1];
70
+ assertDefined(specifier, "Matched import has no specifier");
71
+ specifiers.add(specifier);
72
+ }
73
+ }
74
+ return specifiers.values().toArray();
75
+ }
76
+ function isFunctionCodeFile(filePath) {
77
+ return (javaScriptFilePattern.test(filePath) && !filePath.includes("node_modules/"));
78
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * AWS SDK packages the sim Lambda runtime was asked to provide and the
3
+ * consuming project has not installed.
4
+ *
5
+ * The real Lambda runtime provides these packages from the execution
6
+ * environment rather than from the deployment package, so the simulated
7
+ * runtime provides them from the host project. The fix is the same for every
8
+ * one of them, which is why they are named together: install them, or bundle
9
+ * them into the function code archive.
10
+ */
11
+ export declare class SimLambdaSdkPackagesNotInstalledError extends Error {
12
+ readonly specifiers: readonly string[];
13
+ readonly name = "SimLambdaSdkPackagesNotInstalledError";
14
+ constructor(specifiers: readonly string[], options?: ErrorOptions);
15
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * AWS SDK packages the sim Lambda runtime was asked to provide and the
3
+ * consuming project has not installed.
4
+ *
5
+ * The real Lambda runtime provides these packages from the execution
6
+ * environment rather than from the deployment package, so the simulated
7
+ * runtime provides them from the host project. The fix is the same for every
8
+ * one of them, which is why they are named together: install them, or bundle
9
+ * them into the function code archive.
10
+ */
11
+ export class SimLambdaSdkPackagesNotInstalledError extends Error {
12
+ specifiers;
13
+ name = "SimLambdaSdkPackagesNotInstalledError";
14
+ constructor(specifiers, options) {
15
+ super(notInstalledMessage(specifiers), options);
16
+ this.specifiers = specifiers;
17
+ }
18
+ }
19
+ function notInstalledMessage(specifiers) {
20
+ const [subject, object] = specifiers.length > 1
21
+ ? ["the packages are", "them"]
22
+ : ["the package is", "it"];
23
+ return (`Cannot provide ${specifiers.join(", ")} to sim Lambda function code: ` +
24
+ `${subject} not installed. Install ${object} in your project, as the ` +
25
+ `real Lambda runtime provides ${object}, or bundle ${object} into the ` +
26
+ "function code archive.");
27
+ }
@@ -16,6 +16,15 @@ export declare const awsSdkPackagePrefix = "@aws-sdk/";
16
16
  */
17
17
  export interface SimLambdaVmSdkModuleProvider {
18
18
  provideModule(specifier: string): unknown;
19
+ /**
20
+ * Which of the given specifiers this provider serves and cannot resolve.
21
+ *
22
+ * The module system asks once a package has turned out to be missing. The
23
+ * refusal then names every package the project has to install, where on
24
+ * its own it would name only the one the function code reached first. A
25
+ * provider that does not answer is asked for one specifier at a time.
26
+ */
27
+ unresolvedModules?(specifiers: readonly string[]): readonly string[];
19
28
  }
20
29
  /**
21
30
  * Module provider used when no simulated AWS environment is wired up, such
@@ -46,6 +46,16 @@ export declare class SimSdkLambdaVmModuleProvider implements SimLambdaVmSdkModul
46
46
  * undefined for other specifiers.
47
47
  */
48
48
  provideModule(specifier: string): unknown;
49
+ /**
50
+ * Which of the given specifiers this provider serves and the host cannot
51
+ * resolve.
52
+ *
53
+ * Resolution only. A package that resolves and then throws while it
54
+ * initializes is installed, and that error belongs to the function code
55
+ * requiring it rather than to a report of what is missing.
56
+ */
57
+ unresolvedModules(specifiers: readonly string[]): readonly string[];
58
+ private resolves;
49
59
  private hostModuleExports;
50
60
  }
51
61
  export {};
@@ -1,11 +1,10 @@
1
- import { createRequire } from "node:module";
2
- import path from "node:path";
3
1
  import { SimSdkModuleClientInterceptor } from "../../../../../../sdk/module/sim-sdk-module-client-interceptor.js";
4
2
  import { SimSdkCommandDispatcher } from "../../../../../../sdk/sim-sdk-command-dispatcher.js";
5
3
  import { SimLambdaAwsApiOutbound } from "../../../outbound/sim-lambda-aws-api-outbound.js";
6
4
  import { isSimLambdaHttpModuleSpecifier, makeSimLambdaHttpModule, simLambdaHttpModuleScheme, } from "../../../outbound/sim-lambda-http-module.js";
5
+ import { isModuleNotFoundError, requireHostModule, } from "../sim-lambda-host-modules.js";
6
+ import { SimLambdaSdkPackagesNotInstalledError } from "./sim-lambda-sdk-packages-not-installed.error.js";
7
7
  import { awsSdkPackagePrefix, } from "./sim-lambda-vm-sdk-module-provider.js";
8
- const hostRequire = createRequire(import.meta.url);
9
8
  /**
10
9
  * Provides host-installed AWS SDK v3 packages to sim Lambda vm function
11
10
  * code, with client classes intercepted into the owning simulated AWS
@@ -61,6 +60,29 @@ export class SimSdkLambdaVmModuleProvider {
61
60
  this.providedModules.set(specifier, module);
62
61
  return module;
63
62
  }
63
+ /**
64
+ * Which of the given specifiers this provider serves and the host cannot
65
+ * resolve.
66
+ *
67
+ * Resolution only. A package that resolves and then throws while it
68
+ * initializes is installed, and that error belongs to the function code
69
+ * requiring it rather than to a report of what is missing.
70
+ */
71
+ unresolvedModules(specifiers) {
72
+ return specifiers.filter((specifier) => specifier.startsWith(awsSdkPackagePrefix) && !this.resolves(specifier));
73
+ }
74
+ resolves(specifier) {
75
+ if (this.providedModules.has(specifier)) {
76
+ return true;
77
+ }
78
+ try {
79
+ this.requireModule(specifier);
80
+ return true;
81
+ }
82
+ catch (error) {
83
+ return !isModuleNotFoundError(error);
84
+ }
85
+ }
64
86
  hostModuleExports(specifier) {
65
87
  let moduleExports;
66
88
  try {
@@ -72,10 +94,9 @@ export class SimSdkLambdaVmModuleProvider {
72
94
  if (!isModuleNotFoundError(error)) {
73
95
  throw error;
74
96
  }
75
- throw new Error(`Cannot provide ${specifier} to sim Lambda function code: the ` +
76
- "package is not installed. Install it in your project, as the " +
77
- "real Lambda runtime provides it, or bundle it into the function " +
78
- "code archive.", { cause: error });
97
+ throw new SimLambdaSdkPackagesNotInstalledError([specifier], {
98
+ cause: error,
99
+ });
79
100
  }
80
101
  if (typeof moduleExports !== "object" || moduleExports === null) {
81
102
  throw new Error(`Cannot provide ${specifier} to sim Lambda function code: the host ` +
@@ -84,30 +105,3 @@ export class SimSdkLambdaVmModuleProvider {
84
105
  return moduleExports;
85
106
  }
86
107
  }
87
- /**
88
- * Require an AWS SDK package from the host.
89
- *
90
- * The packages are installed by the consuming project, as they are provided
91
- * by the real Lambda runtime rather than by this package. Requiring from
92
- * this module's context covers hoisted installs; the working-directory
93
- * fallback covers stricter package layouts.
94
- */
95
- function requireHostModule(specifier) {
96
- try {
97
- return hostRequire(specifier);
98
- }
99
- catch {
100
- /* v8 ignore next 4 -- only reachable in consumer package layouts where
101
- this package's own require context cannot see the SDK packages. */
102
- return createRequire(path.join(process.cwd(), "package.json"))(specifier);
103
- }
104
- }
105
- /**
106
- * Whether an error is a Node.js module resolution failure, as opposed to an
107
- * error thrown while a resolved module initializes.
108
- */
109
- function isModuleNotFoundError(error) {
110
- return (error instanceof Error &&
111
- "code" in error &&
112
- (error.code === "MODULE_NOT_FOUND" || error.code === "ERR_MODULE_NOT_FOUND"));
113
- }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Require from the host a module the real Lambda runtime provides without it
3
+ * being bundled: a Node.js built-in, or an AWS SDK package.
4
+ *
5
+ * The SDK packages are installed by the consuming project, as the real
6
+ * runtime provides them rather than this package. Requiring from this
7
+ * module's context covers hoisted installs; the working-directory fallback
8
+ * covers stricter package layouts.
9
+ */
10
+ export declare function requireHostModule(specifier: string): unknown;
11
+ /**
12
+ * Whether an error is a Node.js module resolution failure, as opposed to an
13
+ * error thrown while a resolved module initializes.
14
+ */
15
+ export declare function isModuleNotFoundError(error: unknown): boolean;
@@ -0,0 +1,31 @@
1
+ import { createRequire } from "node:module";
2
+ import path from "node:path";
3
+ const hostRequire = createRequire(import.meta.url);
4
+ /**
5
+ * Require from the host a module the real Lambda runtime provides without it
6
+ * being bundled: a Node.js built-in, or an AWS SDK package.
7
+ *
8
+ * The SDK packages are installed by the consuming project, as the real
9
+ * runtime provides them rather than this package. Requiring from this
10
+ * module's context covers hoisted installs; the working-directory fallback
11
+ * covers stricter package layouts.
12
+ */
13
+ export function requireHostModule(specifier) {
14
+ try {
15
+ return hostRequire(specifier);
16
+ }
17
+ catch {
18
+ /* v8 ignore next 4 -- only reachable in consumer package layouts where
19
+ this package's own require context cannot see the SDK packages. */
20
+ return createRequire(path.join(process.cwd(), "package.json"))(specifier);
21
+ }
22
+ }
23
+ /**
24
+ * Whether an error is a Node.js module resolution failure, as opposed to an
25
+ * error thrown while a resolved module initializes.
26
+ */
27
+ export function isModuleNotFoundError(error) {
28
+ return (error instanceof Error &&
29
+ "code" in error &&
30
+ (error.code === "MODULE_NOT_FOUND" || error.code === "ERR_MODULE_NOT_FOUND"));
31
+ }
@@ -14,6 +14,13 @@ export declare class SimLambdaVmModuleResolver {
14
14
  * Resolve a require specifier to an archive file path.
15
15
  */
16
16
  resolveFilePath(specifier: string, fromDirectory: string): string;
17
+ /**
18
+ * Whether the archive bundles a bare specifier itself.
19
+ *
20
+ * The archive takes precedence over anything the runtime provides, so a
21
+ * specifier it resolves is never asked of the module provider.
22
+ */
23
+ bundlesPackage(specifier: string): boolean;
17
24
  private resolveCandidates;
18
25
  /**
19
26
  * Resolve a bare specifier against node_modules bundled in the archive.
@@ -22,6 +22,21 @@ export class SimLambdaVmModuleResolver {
22
22
  }
23
23
  return this.resolvePackage(specifier);
24
24
  }
25
+ /**
26
+ * Whether the archive bundles a bare specifier itself.
27
+ *
28
+ * The archive takes precedence over anything the runtime provides, so a
29
+ * specifier it resolves is never asked of the module provider.
30
+ */
31
+ bundlesPackage(specifier) {
32
+ try {
33
+ this.resolvePackage(specifier);
34
+ return true;
35
+ }
36
+ catch {
37
+ return false;
38
+ }
39
+ }
25
40
  resolveCandidates(basePath, specifier) {
26
41
  const candidates = [
27
42
  basePath,
@@ -1,6 +1,8 @@
1
- import { createRequire, isBuiltin } from "node:module";
1
+ import { isBuiltin } from "node:module";
2
2
  import path from "node:path";
3
3
  import vm from "node:vm";
4
+ import { requireHostModule } from "./sim-lambda-host-modules.js";
5
+ import { provideSdkModule } from "./sdk/sim-lambda-provided-sdk-module.js";
4
6
  import { loadJsonModule } from "./sim-lambda-vm-json-module.js";
5
7
  import { SimLambdaVmModuleResolver } from "./sim-lambda-vm-module-resolver.js";
6
8
  import { userCodeSyntaxError } from "./sim-lambda-vm-syntax-error.js";
@@ -9,7 +11,6 @@ import { userCodeSyntaxError } from "./sim-lambda-vm-syntax-error.js";
9
11
  * bounded like real Lambda bounds its init phase.
10
12
  */
11
13
  const moduleEvaluationTimeoutMs = 5000;
12
- const hostRequire = createRequire(import.meta.url);
13
14
  /**
14
15
  * A CommonJS module system over a sim Lambda function code zip archive.
15
16
  *
@@ -35,7 +36,7 @@ export class SimLambdaVmModules {
35
36
  // those too. Anything it declines is the host built-in itself.
36
37
  if (isBuiltin(specifier)) {
37
38
  return (this.properties.sdkModuleProvider.provideModule(specifier) ??
38
- hostRequire(specifier));
39
+ requireHostModule(specifier));
39
40
  }
40
41
  let filePath;
41
42
  try {
@@ -59,7 +60,7 @@ export class SimLambdaVmModules {
59
60
  * original archive resolution error is reported.
60
61
  */
61
62
  provideModule(specifier, archiveError) {
62
- const provided = this.properties.sdkModuleProvider.provideModule(specifier);
63
+ const provided = provideSdkModule(specifier, this.properties);
63
64
  if (provided === undefined) {
64
65
  throw archiveError;
65
66
  }
@@ -28,7 +28,10 @@ export class PutBucketPolicyCommandHandler {
28
28
  async handle(command, options) {
29
29
  assertDefined(command.input.Bucket, "PutBucketPolicyCommand.input.Bucket");
30
30
  assertDefined(command.input.Policy, "PutBucketPolicyCommand.input.Policy");
31
- this.policyValidator.validateRequired(command.input.Policy);
31
+ this.policyValidator.validateRequired(command.input.Policy, {
32
+ attachedTo: "Bucket",
33
+ name: command.input.Bucket,
34
+ });
32
35
  const bucketName = command.input.Bucket;
33
36
  const bucket = requireSimS3Bucket(this.buckets, bucketName);
34
37
  await this.background.sequence();
@@ -6,6 +6,13 @@ interface SimSchedulerDeliveryFailureProperties {
6
6
  readonly at: Date;
7
7
  readonly error: unknown;
8
8
  }
9
+ /**
10
+ * A failed invocation as it serialises. Every property the failure holds, plus
11
+ * the message the getter reads off the error.
12
+ */
13
+ export interface SimSchedulerDeliveryFailureJson extends SimSchedulerDeliveryFailureProperties {
14
+ readonly message: string;
15
+ }
9
16
  /**
10
17
  * One invocation a schedule could not make.
11
18
  */
@@ -28,6 +35,15 @@ export declare class SimSchedulerDeliveryFailure {
28
35
  * What went wrong, as a message.
29
36
  */
30
37
  get message(): string;
38
+ /**
39
+ * The failure as JSON.stringify renders it, message included.
40
+ *
41
+ * Serialising a failure is the first thing to reach for when a schedule did
42
+ * not do what a test expected. The message is a getter on the prototype and
43
+ * would be left out. An Error keeps its own message on a non-enumerable
44
+ * property and prints as `{}`.
45
+ */
46
+ toJSON(): SimSchedulerDeliveryFailureJson;
31
47
  }
32
48
  /**
33
49
  * Every invocation one simulated Scheduler scope could not make.
@@ -32,6 +32,25 @@ export class SimSchedulerDeliveryFailure {
32
32
  }
33
33
  return String(this.error);
34
34
  }
35
+ /**
36
+ * The failure as JSON.stringify renders it, message included.
37
+ *
38
+ * Serialising a failure is the first thing to reach for when a schedule did
39
+ * not do what a test expected. The message is a getter on the prototype and
40
+ * would be left out. An Error keeps its own message on a non-enumerable
41
+ * property and prints as `{}`.
42
+ */
43
+ toJSON() {
44
+ return {
45
+ scheduleName: this.scheduleName,
46
+ scheduleArn: this.scheduleArn,
47
+ targetArn: this.targetArn,
48
+ roleArn: this.roleArn,
49
+ at: this.at,
50
+ message: this.message,
51
+ error: this.error,
52
+ };
53
+ }
35
54
  }
36
55
  /**
37
56
  * Every invocation one simulated Scheduler scope could not make.
@@ -10,6 +10,6 @@ export { schedulerScheduleDialect } from "./schedule/sim-scheduler-schedule-expr
10
10
  export { SimSchedulerTarget } from "./target/sim-scheduler-target.js";
11
11
  export { simSchedulerTargetServices, SimSchedulerTargetArn, type SimSchedulerTargetService, } from "./target/sim-scheduler-target-arn.js";
12
12
  export { simSchedulerServicePrincipal, type SimSchedulerDeliveryTargets, } from "./delivery/sim-scheduler-delivery.js";
13
- export { SimSchedulerDeliveryFailure } from "./delivery/sim-scheduler-delivery-failures.js";
13
+ export { SimSchedulerDeliveryFailure, type SimSchedulerDeliveryFailureJson, } from "./delivery/sim-scheduler-delivery-failures.js";
14
14
  export { SimSchedulerDeliveryNotPermitted, SimSchedulerTargetNotFound, } from "./error/sim-scheduler-delivery.error.js";
15
15
  export { SimSchedulerAccessDeniedException, SimSchedulerConflictException, SimSchedulerError, SimSchedulerResourceNotFoundException, SimSchedulerUnsimulatedInputException, SimSchedulerValidationException, } from "./error/sim-scheduler.error.js";
@@ -9,6 +9,6 @@ export { schedulerScheduleDialect } from "./schedule/sim-scheduler-schedule-expr
9
9
  export { SimSchedulerTarget } from "./target/sim-scheduler-target.js";
10
10
  export { simSchedulerTargetServices, SimSchedulerTargetArn, } from "./target/sim-scheduler-target-arn.js";
11
11
  export { simSchedulerServicePrincipal, } from "./delivery/sim-scheduler-delivery.js";
12
- export { SimSchedulerDeliveryFailure } from "./delivery/sim-scheduler-delivery-failures.js";
12
+ export { SimSchedulerDeliveryFailure, } from "./delivery/sim-scheduler-delivery-failures.js";
13
13
  export { SimSchedulerDeliveryNotPermitted, SimSchedulerTargetNotFound, } from "./error/sim-scheduler-delivery.error.js";
14
14
  export { SimSchedulerAccessDeniedException, SimSchedulerConflictException, SimSchedulerError, SimSchedulerResourceNotFoundException, SimSchedulerUnsimulatedInputException, SimSchedulerValidationException, } from "./error/sim-scheduler.error.js";
@@ -1,3 +1,4 @@
1
+ import type { SimAwsCaller } from "../../../aws/caller/sim-aws-caller.js";
1
2
  import type { SimAwsAccountRegionScope } from "../../../aws/sim-aws-account-region-scope.js";
2
3
  import type { SimCfnDynamicReference, SimCfnDynamicReferenceResolution, SimCfnDynamicReferenceResolver } from "../../../cloudformation/template/dynamic/sim-cfn-dynamic-reference.type.js";
3
4
  import type { SimSecretsManager } from "../../sim-secrets-manager.js";
@@ -6,16 +7,19 @@ interface SimCfnSecretsManagerDynamicReferenceResolverProperties {
6
7
  readonly secretsManager: SimSecretsManager;
7
8
  /** Secrets Manager for another Account and Region, which a full ARN names. */
8
9
  readonly secretsManagerIn: (scope: SimAwsAccountRegionScope) => SimSecretsManager;
10
+ /** The principal the deployment runs as, which the secret is read as. */
11
+ readonly caller?: SimAwsCaller | undefined;
9
12
  }
10
13
  /**
11
14
  * Answers `{{resolve:secretsmanager:...}}` references from simulated Secrets
12
15
  * Manager.
13
16
  *
14
- * The secret is read as the caller deploying the Stack would read it, at the
15
- * point the Resource holding the reference is created. Real CloudFormation
16
- * makes no dependency out of a dynamic reference, so a secret another Resource
17
- * of the same Stack creates is only there in time if the template says
18
- * `DependsOn`.
17
+ * The secret is read as the principal the deployment names, at the point the
18
+ * Resource holding the reference is created. A deployment naming none reads as
19
+ * the Account root, which is Secrets Manager's own default. Real
20
+ * CloudFormation makes no dependency out of a dynamic reference, so a secret
21
+ * another Resource of the same Stack creates is only there in time if the
22
+ * template says `DependsOn`.
19
23
  *
20
24
  * Reading goes through the ordinary GetSecretValue command, which decrypts the
21
25
  * version through simulated KMS, so the answer comes back as a promise. That
@@ -29,22 +33,16 @@ interface SimCfnSecretsManagerDynamicReferenceResolverProperties {
29
33
  export declare class SimCfnSecretsManagerDynamicReferenceResolver implements SimCfnDynamicReferenceResolver {
30
34
  private readonly secretsManager;
31
35
  private readonly secretsManagerIn;
36
+ private readonly callerOptions;
32
37
  constructor(properties: SimCfnSecretsManagerDynamicReferenceResolverProperties);
33
38
  /**
34
39
  * Resolve one reference to the secret value it names.
35
40
  */
36
41
  resolve(reference: SimCfnDynamicReference): Promise<SimCfnDynamicReferenceResolution>;
37
42
  /**
38
- * Read the version the reference selects, or the current one.
43
+ * The Secrets Manager a reference reads from: the Stack's own, or the one a
44
+ * full secret ARN names.
39
45
  */
40
- private read;
41
- /**
42
- * The value a reference Secrets Manager could not answer resolves to.
43
- *
44
- * The shape follows the `ssm` references beside it, and CDK before them,
45
- * which fills an unresolved context lookup with `dummy-value-for-<name>`. A
46
- * test reading one back sees where it came from.
47
- */
48
- private standIn;
46
+ private secretsManagerFor;
49
47
  }
50
48
  export {};
@@ -1,15 +1,18 @@
1
+ import { simCfnResourceCallerOptions, } from "../../../cloudformation/resource/caller/sim-cfn-resource-caller-options.js";
1
2
  import { SimSecretsManagerError } from "../../error/sim-secrets-manager.error.js";
2
- import { simCfnSecretsManagerJsonKeyValue } from "./sim-cfn-secrets-manager-json-key.js";
3
+ import { simCfnSecretsManagerReferenceStandIn } from "./sim-cfn-secrets-manager-reference-stand-in.js";
4
+ import { simCfnSecretsManagerReferenceValue } from "./sim-cfn-secrets-manager-reference-value.js";
3
5
  import { parseSimCfnSecretsManagerReference, SimCfnSecretsManagerReferenceProblem, } from "./sim-cfn-secrets-manager-reference-body.js";
4
6
  /**
5
7
  * Answers `{{resolve:secretsmanager:...}}` references from simulated Secrets
6
8
  * Manager.
7
9
  *
8
- * The secret is read as the caller deploying the Stack would read it, at the
9
- * point the Resource holding the reference is created. Real CloudFormation
10
- * makes no dependency out of a dynamic reference, so a secret another Resource
11
- * of the same Stack creates is only there in time if the template says
12
- * `DependsOn`.
10
+ * The secret is read as the principal the deployment names, at the point the
11
+ * Resource holding the reference is created. A deployment naming none reads as
12
+ * the Account root, which is Secrets Manager's own default. Real
13
+ * CloudFormation makes no dependency out of a dynamic reference, so a secret
14
+ * another Resource of the same Stack creates is only there in time if the
15
+ * template says `DependsOn`.
13
16
  *
14
17
  * Reading goes through the ordinary GetSecretValue command, which decrypts the
15
18
  * version through simulated KMS, so the answer comes back as a promise. That
@@ -23,9 +26,11 @@ import { parseSimCfnSecretsManagerReference, SimCfnSecretsManagerReferenceProble
23
26
  export class SimCfnSecretsManagerDynamicReferenceResolver {
24
27
  secretsManager;
25
28
  secretsManagerIn;
29
+ callerOptions;
26
30
  constructor(properties) {
27
31
  this.secretsManager = properties.secretsManager;
28
32
  this.secretsManagerIn = properties.secretsManagerIn;
33
+ this.callerOptions = simCfnResourceCallerOptions(properties.caller);
29
34
  }
30
35
  /**
31
36
  * Resolve one reference to the secret value it names.
@@ -35,54 +40,28 @@ export class SimCfnSecretsManagerDynamicReferenceResolver {
35
40
  try {
36
41
  const parsed = parseSimCfnSecretsManagerReference(reference.body);
37
42
  secretId = parsed.secretId;
38
- return { value: await this.read(parsed) };
43
+ return {
44
+ value: await simCfnSecretsManagerReferenceValue(this.secretsManagerFor(parsed.scope), parsed, this.callerOptions),
45
+ };
39
46
  }
40
47
  catch (error) {
41
48
  if (error instanceof SimCfnSecretsManagerReferenceProblem) {
42
- return this.standIn(reference, secretId, error.message);
49
+ return simCfnSecretsManagerReferenceStandIn(reference, secretId, error.message);
43
50
  }
44
51
  /* v8 ignore next 3 -- defensive: only Secrets Manager reaches here */
45
52
  if (!(error instanceof SimSecretsManagerError)) {
46
53
  throw error;
47
54
  }
48
- return this.standIn(reference, secretId, `and simulated Secrets Manager could not read it (${error.message})`);
55
+ return simCfnSecretsManagerReferenceStandIn(reference, secretId, `and simulated Secrets Manager could not read it (${error.message})`);
49
56
  }
50
57
  }
51
58
  /**
52
- * Read the version the reference selects, or the current one.
59
+ * The Secrets Manager a reference reads from: the Stack's own, or the one a
60
+ * full secret ARN names.
53
61
  */
54
- async read(reference) {
55
- const { secretId, scope, jsonKey, versionStage, versionId } = reference;
56
- const secretsManager = scope === undefined ? this.secretsManager : this.secretsManagerIn(scope);
57
- const read = await secretsManager.getSecretValue({
58
- input: {
59
- SecretId: secretId,
60
- VersionStage: versionStage,
61
- VersionId: versionId,
62
- },
63
- });
64
- const secretString = read.SecretString;
65
- if (secretString === undefined) {
66
- throw new SimCfnSecretsManagerReferenceProblem(`and '${secretId}' holds a binary value, which a dynamic reference ` +
67
- `cannot read`);
68
- }
69
- if (jsonKey === undefined) {
70
- return secretString;
71
- }
72
- return simCfnSecretsManagerJsonKeyValue(secretString, secretId, jsonKey);
73
- }
74
- /**
75
- * The value a reference Secrets Manager could not answer resolves to.
76
- *
77
- * The shape follows the `ssm` references beside it, and CDK before them,
78
- * which fills an unresolved context lookup with `dummy-value-for-<name>`. A
79
- * test reading one back sees where it came from.
80
- */
81
- standIn(reference, secretId, reason) {
82
- return {
83
- value: `dummy-value-for-${secretId}`,
84
- reason: `holds ${reference.text}, ${reason}, so the Resource is created ` +
85
- `with a stand-in value`,
86
- };
62
+ secretsManagerFor(scope) {
63
+ return scope === undefined
64
+ ? this.secretsManager
65
+ : this.secretsManagerIn(scope);
87
66
  }
88
67
  }
@@ -0,0 +1,9 @@
1
+ import type { SimCfnDynamicReference, SimCfnDynamicReferenceResolution } from "../../../cloudformation/template/dynamic/sim-cfn-dynamic-reference.type.js";
2
+ /**
3
+ * The value a reference Secrets Manager could not answer resolves to.
4
+ *
5
+ * The shape follows the `ssm` references beside it, and CDK before them, which
6
+ * fills an unresolved context lookup with `dummy-value-for-<name>`. A test
7
+ * reading one back sees where it came from.
8
+ */
9
+ export declare function simCfnSecretsManagerReferenceStandIn(reference: SimCfnDynamicReference, secretId: string, reason: string): SimCfnDynamicReferenceResolution;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The value a reference Secrets Manager could not answer resolves to.
3
+ *
4
+ * The shape follows the `ssm` references beside it, and CDK before them, which
5
+ * fills an unresolved context lookup with `dummy-value-for-<name>`. A test
6
+ * reading one back sees where it came from.
7
+ */
8
+ export function simCfnSecretsManagerReferenceStandIn(reference, secretId, reason) {
9
+ return {
10
+ value: `dummy-value-for-${secretId}`,
11
+ reason: `holds ${reference.text}, ${reason}, so the Resource is created ` +
12
+ `with a stand-in value`,
13
+ };
14
+ }