@aws-blocks/core 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/cdk/blocks-backend.d.ts +35 -9
  2. package/dist/cdk/blocks-backend.d.ts.map +1 -1
  3. package/dist/cdk/blocks-backend.js +52 -69
  4. package/dist/cdk/blocks-backend.test.js +61 -69
  5. package/dist/cdk/blocks-defaults.d.ts +27 -1
  6. package/dist/cdk/blocks-defaults.d.ts.map +1 -1
  7. package/dist/cdk/blocks-defaults.js +5 -1
  8. package/dist/cdk/blocks-defaults.test.js +4 -2
  9. package/dist/cdk/blocks-stack.test.js +73 -37
  10. package/dist/cdk/compute/default-compute-factory.d.ts +33 -0
  11. package/dist/cdk/compute/default-compute-factory.d.ts.map +1 -0
  12. package/dist/cdk/compute/default-compute-factory.js +3 -0
  13. package/dist/cdk/index.d.ts +46 -5
  14. package/dist/cdk/index.d.ts.map +1 -1
  15. package/dist/cdk/index.js +57 -7
  16. package/dist/cdk/internal.d.ts +1 -0
  17. package/dist/cdk/internal.d.ts.map +1 -1
  18. package/dist/hosting-secrets.d.ts +48 -0
  19. package/dist/hosting-secrets.d.ts.map +1 -0
  20. package/dist/hosting-secrets.js +57 -0
  21. package/dist/hosting-secrets.test.d.ts +2 -0
  22. package/dist/hosting-secrets.test.d.ts.map +1 -0
  23. package/dist/hosting-secrets.test.js +81 -0
  24. package/dist/hosting.d.ts +88 -6
  25. package/dist/hosting.d.ts.map +1 -1
  26. package/dist/hosting.js +83 -24
  27. package/dist/hosting.test.js +158 -10
  28. package/dist/index.cdk.d.ts +13 -12
  29. package/dist/index.cdk.d.ts.map +1 -1
  30. package/dist/index.cdk.js +13 -9
  31. package/dist/index.d.ts +8 -7
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +9 -5
  34. package/dist/lambda-handler.test.js +66 -0
  35. package/dist/pipeline/index.d.ts +24 -2
  36. package/dist/pipeline/index.d.ts.map +1 -1
  37. package/dist/pipeline/index.js +41 -1
  38. package/dist/pipeline.test.d.ts +2 -0
  39. package/dist/pipeline.test.d.ts.map +1 -0
  40. package/dist/pipeline.test.js +47 -0
  41. package/dist/rpc.d.ts +21 -0
  42. package/dist/rpc.d.ts.map +1 -1
  43. package/dist/rpc.js +34 -0
  44. package/dist/rpc.test.js +38 -1
  45. package/dist/scripts/config.d.ts +15 -0
  46. package/dist/scripts/config.d.ts.map +1 -0
  47. package/dist/scripts/config.js +29 -0
  48. package/dist/scripts/deploy.d.ts.map +1 -1
  49. package/dist/scripts/deploy.js +4 -0
  50. package/dist/scripts/dev-server.d.ts +8 -0
  51. package/dist/scripts/dev-server.d.ts.map +1 -1
  52. package/dist/scripts/dev-server.js +31 -0
  53. package/dist/scripts/generate-client.d.ts.map +1 -1
  54. package/dist/scripts/generate-client.js +9 -4
  55. package/dist/scripts/generate-client.test.js +19 -4
  56. package/dist/scripts/index.d.ts +13 -10
  57. package/dist/scripts/index.d.ts.map +1 -1
  58. package/dist/scripts/index.js +11 -8
  59. package/dist/scripts/preflight-credentials.d.ts +30 -0
  60. package/dist/scripts/preflight-credentials.d.ts.map +1 -0
  61. package/dist/scripts/preflight-credentials.js +108 -0
  62. package/dist/scripts/preflight-credentials.test.d.ts +2 -0
  63. package/dist/scripts/preflight-credentials.test.d.ts.map +1 -0
  64. package/dist/scripts/preflight-credentials.test.js +77 -0
  65. package/dist/scripts/sandbox-args.test.d.ts +2 -0
  66. package/dist/scripts/sandbox-args.test.d.ts.map +1 -0
  67. package/dist/scripts/sandbox-args.test.js +77 -0
  68. package/dist/scripts/sandbox.d.ts +52 -0
  69. package/dist/scripts/sandbox.d.ts.map +1 -1
  70. package/dist/scripts/sandbox.js +92 -15
  71. package/dist/scripts/secret.d.ts +15 -0
  72. package/dist/scripts/secret.d.ts.map +1 -0
  73. package/dist/scripts/secret.js +29 -0
  74. package/dist/scripts/secret.test.d.ts +2 -0
  75. package/dist/scripts/secret.test.d.ts.map +1 -0
  76. package/dist/scripts/secret.test.js +28 -0
  77. package/dist/scripts/typegen.d.ts +15 -0
  78. package/dist/scripts/typegen.d.ts.map +1 -0
  79. package/dist/scripts/typegen.js +16 -0
  80. package/dist/secret-naming.d.ts +58 -0
  81. package/dist/secret-naming.d.ts.map +1 -0
  82. package/dist/secret-naming.js +67 -0
  83. package/dist/secret-naming.test.d.ts +2 -0
  84. package/dist/secret-naming.test.d.ts.map +1 -0
  85. package/dist/secret-naming.test.js +40 -0
  86. package/dist/version.d.ts +1 -1
  87. package/dist/version.js +1 -1
  88. package/package.json +2 -1
  89. package/src/cdk/blocks-backend.test.ts +267 -272
  90. package/src/cdk/blocks-backend.ts +71 -79
  91. package/src/cdk/blocks-defaults.test.ts +4 -2
  92. package/src/cdk/blocks-defaults.ts +27 -1
  93. package/src/cdk/blocks-stack.test.ts +161 -118
  94. package/src/cdk/compute/default-compute-factory.ts +37 -0
  95. package/src/cdk/index.ts +84 -8
  96. package/src/cdk/internal.ts +1 -0
  97. package/src/hosting-secrets.test.ts +106 -0
  98. package/src/hosting-secrets.ts +106 -0
  99. package/src/hosting.test.ts +244 -63
  100. package/src/hosting.ts +180 -68
  101. package/src/index.cdk.ts +77 -38
  102. package/src/index.ts +35 -16
  103. package/src/lambda-handler.test.ts +74 -0
  104. package/src/pipeline/index.ts +64 -11
  105. package/src/pipeline.test.ts +55 -0
  106. package/src/rpc.test.ts +44 -1
  107. package/src/rpc.ts +41 -0
  108. package/src/scripts/config.ts +35 -0
  109. package/src/scripts/deploy.ts +5 -0
  110. package/src/scripts/dev-server.ts +40 -0
  111. package/src/scripts/generate-client.test.ts +43 -8
  112. package/src/scripts/generate-client.ts +70 -65
  113. package/src/scripts/index.ts +20 -17
  114. package/src/scripts/preflight-credentials.test.ts +110 -0
  115. package/src/scripts/preflight-credentials.ts +131 -0
  116. package/src/scripts/sandbox-args.test.ts +92 -0
  117. package/src/scripts/sandbox.ts +102 -15
  118. package/src/scripts/secret.test.ts +35 -0
  119. package/src/scripts/secret.ts +35 -0
  120. package/src/scripts/typegen.ts +18 -0
  121. package/src/secret-naming.test.ts +59 -0
  122. package/src/secret-naming.ts +99 -0
  123. package/src/version.ts +1 -1
@@ -0,0 +1,99 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Blocks-owned namespaces for hosting values.
6
+ *
7
+ * The mechanism (markers, resolvers, path/env naming) lives in the
8
+ * framework-neutral `@aws-blocks/hosting` package, which defaults to neutral
9
+ * `/hosting/secrets` and `/hosting/config` prefixes so a non-Blocks consumer
10
+ * never inherits Blocks branding.
11
+ *
12
+ * This module is the ONE place Blocks pins its own namespaces. The prefixes are
13
+ * **scoped to the app's stable `stackId`** (from the committed `.blocks/config.json`)
14
+ * — `/blocks/<stackId>/secrets` (Secrets Manager) and `/blocks/<stackId>/config`
15
+ * (SSM Parameter Store) — so two Blocks apps in one account/region never collide.
16
+ *
17
+ * Both sides derive the scope from the SAME source: the out-of-band CLI
18
+ * (`npm run secret`/`config`) and the CDK synth both call {@link blocksStoreConfig},
19
+ * which reads `stackId` via {@link getStackId}. When `.blocks/config.json` is absent
20
+ * (e.g. a bare unit test) both sides fall back to the unscoped `/blocks/secrets` /
21
+ * `/blocks/config` identically — so the CLI write and the deploy read can never
22
+ * diverge, whether the id is present or not. `stackId` is stage-independent
23
+ * (prod and sandbox share it); use the opt-in `stage` segment for per-stage values.
24
+ *
25
+ * @module
26
+ */
27
+
28
+ import type { StoreConfig } from '@aws-blocks/hosting/constructs';
29
+ import { secretStoreLocator } from '@aws-blocks/hosting';
30
+ import { getStackId } from './scripts/stack-id.js';
31
+
32
+ /** Base Blocks prefix for `secret()` values (Secrets Manager); scoped by `stackId`. */
33
+ export const BLOCKS_SECRET_PARAMETER_PREFIX = '/blocks/secrets';
34
+
35
+ /** Base Blocks prefix for `config()` values (SSM Parameter Store); scoped by `stackId`. */
36
+ export const BLOCKS_CONFIG_PARAMETER_PREFIX = '/blocks/config';
37
+
38
+ /**
39
+ * Resolve the app's `stackId` (stable, stage-independent, from `.blocks/config.json`),
40
+ * or `undefined` when it can't be read. Never throws — a missing id means both the
41
+ * CLI and synth fall back to the unscoped base prefix, so they still agree.
42
+ */
43
+ function resolveStackId(explicit?: string): string | undefined {
44
+ if (explicit) return explicit;
45
+ try {
46
+ return getStackId();
47
+ } catch {
48
+ return undefined;
49
+ }
50
+ }
51
+
52
+ /** The Blocks `secret()` prefix, scoped to `stackId` when available. */
53
+ export function blocksSecretPrefix(stackId?: string): string {
54
+ const id = resolveStackId(stackId);
55
+ return id ? `/blocks/${id}/secrets` : BLOCKS_SECRET_PARAMETER_PREFIX;
56
+ }
57
+
58
+ /** The Blocks `config()` prefix, scoped to `stackId` when available. */
59
+ export function blocksConfigPrefix(stackId?: string): string {
60
+ const id = resolveStackId(stackId);
61
+ return id ? `/blocks/${id}/config` : BLOCKS_CONFIG_PARAMETER_PREFIX;
62
+ }
63
+
64
+ /**
65
+ * The **actual store name** of a Blocks `secret()` key in AWS Secrets Manager —
66
+ * routed through {@link secretStoreLocator} so it matches exactly what the CLI
67
+ * writes, the IAM grant scopes to, and the runtime resolver reads. Secrets Manager
68
+ * names are slash-free at the root, so this is `blocks/<stackId>/secrets/<KEY>`
69
+ * (no leading slash), NOT an SSM-style path. Pass `stackId` to compute it without
70
+ * reading `.blocks/config.json`.
71
+ *
72
+ * @example 'blocks/myapp/secrets/STRIPE_KEY'
73
+ */
74
+ export function blocksSecretParameterName(key: string, stackId?: string): string {
75
+ return secretStoreLocator(key, { prefix: blocksSecretPrefix(stackId), store: 'secrets-manager' });
76
+ }
77
+
78
+ /**
79
+ * The **actual store name** of a Blocks `config()` key in SSM Parameter Store —
80
+ * routed through {@link secretStoreLocator} for consistency with the CLI/grant/
81
+ * runtime path. SSM keeps the leading-slash path.
82
+ *
83
+ * @example '/blocks/myapp/config/FEATURE_FLAGS'
84
+ */
85
+ export function blocksConfigParameterName(key: string, stackId?: string): string {
86
+ return secretStoreLocator(key, { prefix: blocksConfigPrefix(stackId), store: 'ssm' });
87
+ }
88
+
89
+ /**
90
+ * The Blocks store config passed to the shared hosting engine — `stackId`-scoped
91
+ * prefixes (falling back to the unscoped base when `.blocks/config.json` is absent).
92
+ * Both the CLI and the CDK synth call this, so they resolve identical names.
93
+ */
94
+ export function blocksStoreConfig(stackId?: string): StoreConfig {
95
+ return {
96
+ secretStore: { prefix: blocksSecretPrefix(stackId) },
97
+ configStore: { prefix: blocksConfigPrefix(stackId) },
98
+ };
99
+ }
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Auto-generated by scripts/generate-version.mjs — do not edit manually
2
- export const CORE_VERSION = '0.2.0';
2
+ export const CORE_VERSION = '0.3.0';