@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.
- package/dist/cdk/blocks-backend.d.ts +35 -9
- package/dist/cdk/blocks-backend.d.ts.map +1 -1
- package/dist/cdk/blocks-backend.js +52 -69
- package/dist/cdk/blocks-backend.test.js +61 -69
- package/dist/cdk/blocks-defaults.d.ts +27 -1
- package/dist/cdk/blocks-defaults.d.ts.map +1 -1
- package/dist/cdk/blocks-defaults.js +5 -1
- package/dist/cdk/blocks-defaults.test.js +4 -2
- package/dist/cdk/blocks-stack.test.js +73 -37
- package/dist/cdk/compute/default-compute-factory.d.ts +33 -0
- package/dist/cdk/compute/default-compute-factory.d.ts.map +1 -0
- package/dist/cdk/compute/default-compute-factory.js +3 -0
- package/dist/cdk/index.d.ts +46 -5
- package/dist/cdk/index.d.ts.map +1 -1
- package/dist/cdk/index.js +57 -7
- package/dist/cdk/internal.d.ts +1 -0
- package/dist/cdk/internal.d.ts.map +1 -1
- package/dist/hosting-secrets.d.ts +48 -0
- package/dist/hosting-secrets.d.ts.map +1 -0
- package/dist/hosting-secrets.js +57 -0
- package/dist/hosting-secrets.test.d.ts +2 -0
- package/dist/hosting-secrets.test.d.ts.map +1 -0
- package/dist/hosting-secrets.test.js +81 -0
- package/dist/hosting.d.ts +88 -6
- package/dist/hosting.d.ts.map +1 -1
- package/dist/hosting.js +83 -24
- package/dist/hosting.test.js +158 -10
- package/dist/index.cdk.d.ts +13 -12
- package/dist/index.cdk.d.ts.map +1 -1
- package/dist/index.cdk.js +13 -9
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/lambda-handler.test.js +66 -0
- package/dist/pipeline/index.d.ts +24 -2
- package/dist/pipeline/index.d.ts.map +1 -1
- package/dist/pipeline/index.js +41 -1
- package/dist/pipeline.test.d.ts +2 -0
- package/dist/pipeline.test.d.ts.map +1 -0
- package/dist/pipeline.test.js +47 -0
- package/dist/rpc.d.ts +21 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +34 -0
- package/dist/rpc.test.js +38 -1
- package/dist/scripts/config.d.ts +15 -0
- package/dist/scripts/config.d.ts.map +1 -0
- package/dist/scripts/config.js +29 -0
- package/dist/scripts/deploy.d.ts.map +1 -1
- package/dist/scripts/deploy.js +4 -0
- package/dist/scripts/dev-server.d.ts +8 -0
- package/dist/scripts/dev-server.d.ts.map +1 -1
- package/dist/scripts/dev-server.js +31 -0
- package/dist/scripts/generate-client.d.ts.map +1 -1
- package/dist/scripts/generate-client.js +9 -4
- package/dist/scripts/generate-client.test.js +19 -4
- package/dist/scripts/index.d.ts +13 -10
- package/dist/scripts/index.d.ts.map +1 -1
- package/dist/scripts/index.js +11 -8
- package/dist/scripts/preflight-credentials.d.ts +30 -0
- package/dist/scripts/preflight-credentials.d.ts.map +1 -0
- package/dist/scripts/preflight-credentials.js +108 -0
- package/dist/scripts/preflight-credentials.test.d.ts +2 -0
- package/dist/scripts/preflight-credentials.test.d.ts.map +1 -0
- package/dist/scripts/preflight-credentials.test.js +77 -0
- package/dist/scripts/sandbox-args.test.d.ts +2 -0
- package/dist/scripts/sandbox-args.test.d.ts.map +1 -0
- package/dist/scripts/sandbox-args.test.js +77 -0
- package/dist/scripts/sandbox.d.ts +52 -0
- package/dist/scripts/sandbox.d.ts.map +1 -1
- package/dist/scripts/sandbox.js +92 -15
- package/dist/scripts/secret.d.ts +15 -0
- package/dist/scripts/secret.d.ts.map +1 -0
- package/dist/scripts/secret.js +29 -0
- package/dist/scripts/secret.test.d.ts +2 -0
- package/dist/scripts/secret.test.d.ts.map +1 -0
- package/dist/scripts/secret.test.js +28 -0
- package/dist/scripts/typegen.d.ts +15 -0
- package/dist/scripts/typegen.d.ts.map +1 -0
- package/dist/scripts/typegen.js +16 -0
- package/dist/secret-naming.d.ts +58 -0
- package/dist/secret-naming.d.ts.map +1 -0
- package/dist/secret-naming.js +67 -0
- package/dist/secret-naming.test.d.ts +2 -0
- package/dist/secret-naming.test.d.ts.map +1 -0
- package/dist/secret-naming.test.js +40 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -1
- package/src/cdk/blocks-backend.test.ts +267 -272
- package/src/cdk/blocks-backend.ts +71 -79
- package/src/cdk/blocks-defaults.test.ts +4 -2
- package/src/cdk/blocks-defaults.ts +27 -1
- package/src/cdk/blocks-stack.test.ts +161 -118
- package/src/cdk/compute/default-compute-factory.ts +37 -0
- package/src/cdk/index.ts +84 -8
- package/src/cdk/internal.ts +1 -0
- package/src/hosting-secrets.test.ts +106 -0
- package/src/hosting-secrets.ts +106 -0
- package/src/hosting.test.ts +244 -63
- package/src/hosting.ts +180 -68
- package/src/index.cdk.ts +77 -38
- package/src/index.ts +35 -16
- package/src/lambda-handler.test.ts +74 -0
- package/src/pipeline/index.ts +64 -11
- package/src/pipeline.test.ts +55 -0
- package/src/rpc.test.ts +44 -1
- package/src/rpc.ts +41 -0
- package/src/scripts/config.ts +35 -0
- package/src/scripts/deploy.ts +5 -0
- package/src/scripts/dev-server.ts +40 -0
- package/src/scripts/generate-client.test.ts +43 -8
- package/src/scripts/generate-client.ts +70 -65
- package/src/scripts/index.ts +20 -17
- package/src/scripts/preflight-credentials.test.ts +110 -0
- package/src/scripts/preflight-credentials.ts +131 -0
- package/src/scripts/sandbox-args.test.ts +92 -0
- package/src/scripts/sandbox.ts +102 -15
- package/src/scripts/secret.test.ts +35 -0
- package/src/scripts/secret.ts +35 -0
- package/src/scripts/typegen.ts +18 -0
- package/src/secret-naming.test.ts +59 -0
- package/src/secret-naming.ts +99 -0
- 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
|
+
export const CORE_VERSION = '0.3.0';
|