@aws-blocks/core 0.2.0 → 0.4.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/README.md +13 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +32 -0
- package/dist/api.test.js +22 -0
- package/dist/bb-utils.d.ts +1 -0
- package/dist/bb-utils.d.ts.map +1 -1
- package/dist/bb-utils.js +3 -0
- package/dist/cdk/apigateway-account.d.ts +33 -0
- package/dist/cdk/apigateway-account.d.ts.map +1 -0
- package/dist/cdk/apigateway-account.js +60 -0
- package/dist/cdk/blocks-backend.d.ts +43 -9
- package/dist/cdk/blocks-backend.d.ts.map +1 -1
- package/dist/cdk/blocks-backend.js +69 -73
- package/dist/cdk/blocks-backend.test.js +78 -69
- package/dist/cdk/blocks-defaults.d.ts +92 -2
- package/dist/cdk/blocks-defaults.d.ts.map +1 -1
- package/dist/cdk/blocks-defaults.js +22 -2
- package/dist/cdk/blocks-defaults.test.js +21 -2
- package/dist/cdk/blocks-stack.test.js +94 -37
- package/dist/cdk/compute/compute-registry.d.ts +19 -0
- package/dist/cdk/compute/compute-registry.d.ts.map +1 -0
- package/dist/cdk/compute/compute-registry.js +38 -0
- package/dist/cdk/compute/compute.d.ts +2 -0
- package/dist/cdk/compute/compute.d.ts.map +1 -1
- package/dist/cdk/compute/compute.js +8 -0
- package/dist/cdk/compute/default-compute-factory.d.ts +34 -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/config-registry.d.ts +34 -4
- package/dist/cdk/config-registry.d.ts.map +1 -1
- package/dist/cdk/config-registry.js +83 -25
- package/dist/cdk/config-registry.test.d.ts +2 -0
- package/dist/cdk/config-registry.test.d.ts.map +1 -0
- package/dist/cdk/config-registry.test.js +115 -0
- package/dist/cdk/index.d.ts +76 -7
- package/dist/cdk/index.d.ts.map +1 -1
- package/dist/cdk/index.js +99 -9
- package/dist/cdk/internal.d.ts +1 -0
- package/dist/cdk/internal.d.ts.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/common/config.d.ts +34 -0
- package/dist/common/config.d.ts.map +1 -1
- package/dist/common/config.js +45 -3
- package/dist/common/config.test.js +19 -0
- package/dist/common/index.d.ts +8 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/errors.d.ts +16 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +20 -0
- 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 +97 -6
- package/dist/hosting.d.ts.map +1 -1
- package/dist/hosting.js +91 -23
- package/dist/hosting.test.js +182 -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.d.ts +17 -0
- package/dist/lambda-handler.d.ts.map +1 -1
- package/dist/lambda-handler.js +52 -3
- package/dist/lambda-handler.test.js +196 -1
- 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-empty-buckets.test.d.ts +2 -0
- package/dist/scripts/sandbox-empty-buckets.test.d.ts.map +1 -0
- package/dist/scripts/sandbox-empty-buckets.test.js +171 -0
- package/dist/scripts/sandbox.d.ts +106 -0
- package/dist/scripts/sandbox.d.ts.map +1 -1
- package/dist/scripts/sandbox.js +255 -40
- 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 +4 -1
- package/src/api.test.ts +25 -0
- package/src/api.ts +39 -0
- package/src/bb-utils.ts +3 -0
- package/src/cdk/apigateway-account.ts +66 -0
- package/src/cdk/blocks-backend.test.ts +291 -272
- package/src/cdk/blocks-backend.ts +88 -83
- package/src/cdk/blocks-defaults.test.ts +25 -2
- package/src/cdk/blocks-defaults.ts +94 -2
- package/src/cdk/blocks-stack.test.ts +186 -118
- package/src/cdk/compute/compute-registry.ts +45 -0
- package/src/cdk/compute/compute.ts +10 -0
- package/src/cdk/compute/default-compute-factory.ts +38 -0
- package/src/cdk/config-registry.test.ts +135 -0
- package/src/cdk/config-registry.ts +92 -34
- package/src/cdk/index.ts +129 -10
- package/src/cdk/internal.ts +1 -0
- package/src/client/index.ts +1 -1
- package/src/common/config.test.ts +21 -0
- package/src/common/config.ts +47 -3
- package/src/common/index.ts +8 -0
- package/src/errors.ts +21 -0
- package/src/hosting-secrets.test.ts +106 -0
- package/src/hosting-secrets.ts +106 -0
- package/src/hosting.test.ts +272 -63
- package/src/hosting.ts +200 -68
- package/src/index.cdk.ts +80 -38
- package/src/index.ts +35 -16
- package/src/lambda-handler.test.ts +215 -1
- package/src/lambda-handler.ts +54 -2
- 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-empty-buckets.test.ts +191 -0
- package/src/scripts/sandbox.ts +287 -39
- 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,35 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import assert from 'node:assert';
|
|
5
|
+
import { describe, it } from 'node:test';
|
|
6
|
+
import { runConfigCli } from './config.js';
|
|
7
|
+
import { runSecretCli } from './secret.js';
|
|
8
|
+
|
|
9
|
+
// argv parsing + validation only (no live SSM/Secrets Manager). The set/list/
|
|
10
|
+
// remove SDK calls are exercised end-to-end during deploy verification.
|
|
11
|
+
|
|
12
|
+
void describe('blocks secret / config CLI argv parsing', () => {
|
|
13
|
+
void it('rejects an unknown subcommand', async () => {
|
|
14
|
+
await assert.rejects(runSecretCli(['frobnicate']), /Unknown subcommand/);
|
|
15
|
+
await assert.rejects(runConfigCli(['frobnicate']), /Unknown subcommand/);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
void it('requires a key for set (label reflects the kind)', async () => {
|
|
19
|
+
await assert.rejects(runSecretCli(['set']), /Usage: blocks secret set/);
|
|
20
|
+
await assert.rejects(runConfigCli(['set']), /Usage: blocks config set/);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
void it('key-only set falls through to the hidden prompt (TTY error, not usage)', async () => {
|
|
24
|
+
await assert.rejects(runSecretCli(['set', 'ONLY_KEY']), /stdin is not a TTY/);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
void it('requires a key for remove', async () => {
|
|
28
|
+
await assert.rejects(runSecretCli(['remove']), /Usage: blocks secret remove/);
|
|
29
|
+
await assert.rejects(runConfigCli(['remove']), /Usage: blocks config remove/);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
void it('validates the key before any store call', async () => {
|
|
33
|
+
await assert.rejects(runSecretCli(['set', '1bad', 'value']), /Invalid key/);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `blocks secret` — manage a Blocks app's **secrets** (AWS Secrets Manager),
|
|
6
|
+
* pinned to the Blocks `/blocks/<stackId>/secrets` namespace (scoped to the app's
|
|
7
|
+
* stable `stackId` from `.blocks/config.json`, so two apps in one account never
|
|
8
|
+
* collide). Thin wrapper over the shared `@aws-blocks/hosting` CLI with the kind
|
|
9
|
+
* fixed to `secret`. The `config` counterpart is `./config.ts`.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { listValues, removeValue, runValueCli, setValue } from '@aws-blocks/hosting/scripts';
|
|
15
|
+
import { blocksSecretPrefix } from '../secret-naming.js';
|
|
16
|
+
|
|
17
|
+
/** Set (create or overwrite) a Blocks secret. */
|
|
18
|
+
export function setSecret(key: string, value: string, opts: { stage?: string } = {}): Promise<void> {
|
|
19
|
+
return setValue('secret', key, value, { prefix: blocksSecretPrefix(), ...opts });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** List Blocks secret keys (names only). */
|
|
23
|
+
export function listSecrets(opts: { stage?: string } = {}): Promise<string[]> {
|
|
24
|
+
return listValues('secret', { prefix: blocksSecretPrefix(), ...opts });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Remove a Blocks secret. */
|
|
28
|
+
export function removeSecret(key: string, opts: { stage?: string } = {}): Promise<boolean> {
|
|
29
|
+
return removeValue('secret', key, { prefix: blocksSecretPrefix(), ...opts });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** CLI dispatcher for `blocks secret <set|list|remove> …`. */
|
|
33
|
+
export function runSecretCli(argv: string[]): Promise<void> {
|
|
34
|
+
return runValueCli(argv, { kind: 'secret', prefix: blocksSecretPrefix(), label: 'blocks secret' });
|
|
35
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `blocks typegen` — generate the type-safe key augmentation for `getSecret` /
|
|
6
|
+
* `getConfig` in a Blocks app. Statically scans the app's `secret('...')` /
|
|
7
|
+
* `config('...')` calls (no execution, no AWS credentials) and writes a `.d.ts`
|
|
8
|
+
* that narrows the runtime getters to your declared keys (autocomplete + typo
|
|
9
|
+
* errors) with no call-site change.
|
|
10
|
+
*
|
|
11
|
+
* Thin pass-through to the `@aws-blocks/hosting` engine — the getters live on
|
|
12
|
+
* `@aws-blocks/hosting`, so the generated file augments that module by default;
|
|
13
|
+
* a Blocks app needs no extra configuration.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export { runTypegenCli } from '@aws-blocks/hosting/scripts';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import assert from 'node:assert';
|
|
5
|
+
import { describe, it } from 'node:test';
|
|
6
|
+
import { secretStoreLocator } from '@aws-blocks/hosting';
|
|
7
|
+
import {
|
|
8
|
+
BLOCKS_CONFIG_PARAMETER_PREFIX,
|
|
9
|
+
BLOCKS_SECRET_PARAMETER_PREFIX,
|
|
10
|
+
blocksConfigParameterName,
|
|
11
|
+
blocksConfigPrefix,
|
|
12
|
+
blocksSecretParameterName,
|
|
13
|
+
blocksSecretPrefix,
|
|
14
|
+
blocksStoreConfig,
|
|
15
|
+
} from './secret-naming.js';
|
|
16
|
+
|
|
17
|
+
// These run with no `.blocks/config.json` in cwd, so they exercise the UNSCOPED
|
|
18
|
+
// fallback. A real Blocks app has the file, so it gets the `stackId`-scoped path
|
|
19
|
+
// (covered by the explicit-stackId cases below).
|
|
20
|
+
void describe('Blocks value namespaces — fallback (no .blocks/config.json)', () => {
|
|
21
|
+
void it('falls back to the unscoped /blocks/secrets and /blocks/config bases', () => {
|
|
22
|
+
assert.strictEqual(BLOCKS_SECRET_PARAMETER_PREFIX, '/blocks/secrets');
|
|
23
|
+
assert.strictEqual(BLOCKS_CONFIG_PARAMETER_PREFIX, '/blocks/config');
|
|
24
|
+
// Secrets Manager names are slash-free at the root; SSM keeps the leading slash.
|
|
25
|
+
assert.strictEqual(blocksSecretParameterName('STRIPE_KEY'), 'blocks/secrets/STRIPE_KEY');
|
|
26
|
+
assert.strictEqual(blocksConfigParameterName('FEATURE_FLAGS'), '/blocks/config/FEATURE_FLAGS');
|
|
27
|
+
assert.deepStrictEqual(blocksStoreConfig(), {
|
|
28
|
+
secretStore: { prefix: '/blocks/secrets' },
|
|
29
|
+
configStore: { prefix: '/blocks/config' },
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
void it('matches the store locator the CLI/grant/runtime actually use (no divergent name)', () => {
|
|
34
|
+
assert.strictEqual(
|
|
35
|
+
blocksSecretParameterName('K'),
|
|
36
|
+
secretStoreLocator('K', { prefix: BLOCKS_SECRET_PARAMETER_PREFIX, store: 'secrets-manager' }),
|
|
37
|
+
);
|
|
38
|
+
assert.strictEqual(
|
|
39
|
+
blocksConfigParameterName('K'),
|
|
40
|
+
secretStoreLocator('K', { prefix: BLOCKS_CONFIG_PARAMETER_PREFIX, store: 'ssm' }),
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
void describe('Blocks value namespaces — stackId-scoped (B5)', () => {
|
|
46
|
+
void it('scopes the prefix by stackId so two apps in one account never collide', () => {
|
|
47
|
+
assert.strictEqual(blocksSecretPrefix('myapp'), '/blocks/myapp/secrets');
|
|
48
|
+
assert.strictEqual(blocksConfigPrefix('myapp'), '/blocks/myapp/config');
|
|
49
|
+
assert.deepStrictEqual(blocksStoreConfig('myapp'), {
|
|
50
|
+
secretStore: { prefix: '/blocks/myapp/secrets' },
|
|
51
|
+
configStore: { prefix: '/blocks/myapp/config' },
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
void it('scoped store names match secretStoreLocator (SM slash-free, SSM leading-slash)', () => {
|
|
56
|
+
assert.strictEqual(blocksSecretParameterName('STRIPE_KEY', 'myapp'), 'blocks/myapp/secrets/STRIPE_KEY');
|
|
57
|
+
assert.strictEqual(blocksConfigParameterName('FEATURE_FLAGS', 'myapp'), '/blocks/myapp/config/FEATURE_FLAGS');
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -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.4.0';
|