@aws-blocks/core 0.1.3 → 0.1.7
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/index.d.ts +1 -1
- package/dist/cdk/index.d.ts.map +1 -1
- package/dist/cdk/index.js +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/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +12 -0
- package/dist/errors.d.ts +28 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +27 -1
- package/dist/errors.test.d.ts +2 -0
- package/dist/errors.test.d.ts.map +1 -0
- package/dist/errors.test.js +47 -0
- package/dist/hosting.d.ts +22 -1
- package/dist/hosting.d.ts.map +1 -1
- package/dist/index.cdk.d.ts +1 -1
- package/dist/index.cdk.d.ts.map +1 -1
- package/dist/index.cdk.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/scripts/dev-server-config.test.d.ts +2 -0
- package/dist/scripts/dev-server-config.test.d.ts.map +1 -0
- package/dist/scripts/dev-server-config.test.js +37 -0
- package/dist/scripts/dev-server-supervisor.test.d.ts +2 -0
- package/dist/scripts/dev-server-supervisor.test.d.ts.map +1 -0
- package/dist/scripts/dev-server-supervisor.test.js +551 -0
- package/dist/scripts/dev-server.d.ts +92 -0
- package/dist/scripts/dev-server.d.ts.map +1 -1
- package/dist/scripts/dev-server.js +317 -34
- package/dist/scripts/index.d.ts +1 -0
- package/dist/scripts/index.d.ts.map +1 -1
- package/dist/scripts/index.js +1 -0
- package/dist/scripts/process-tree.d.ts +126 -0
- package/dist/scripts/process-tree.d.ts.map +1 -0
- package/dist/scripts/process-tree.js +198 -0
- package/dist/scripts/sandbox.d.ts.map +1 -1
- package/dist/scripts/sandbox.js +41 -3
- package/dist/scripts/stack-id.d.ts +12 -0
- package/dist/scripts/stack-id.d.ts.map +1 -0
- package/dist/scripts/stack-id.js +54 -0
- package/dist/scripts/stack-id.test.d.ts +2 -0
- package/dist/scripts/stack-id.test.d.ts.map +1 -0
- package/dist/scripts/stack-id.test.js +54 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/cdk/index.ts +1 -1
- package/src/client/index.ts +1 -1
- package/src/constants.ts +13 -0
- package/src/errors.test.ts +55 -0
- package/src/errors.ts +32 -1
- package/src/hosting.ts +22 -1
- package/src/index.cdk.ts +1 -1
- package/src/index.ts +1 -1
- package/src/scripts/dev-server-config.test.ts +43 -0
- package/src/scripts/dev-server-supervisor.test.ts +621 -0
- package/src/scripts/dev-server.ts +364 -33
- package/src/scripts/index.ts +1 -0
- package/src/scripts/process-tree.ts +245 -0
- package/src/scripts/sandbox.ts +40 -3
- package/src/scripts/stack-id.test.ts +63 -0
- package/src/scripts/stack-id.ts +61 -0
- package/src/version.ts +1 -1
package/dist/cdk/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { SandboxDisableDeletionProtection } from './mixins.js';
|
|
|
7
7
|
export { registerConfig, finalizeConfigRegistry } from './config-registry.js';
|
|
8
8
|
export { synthGuard } from './synth-guard.js';
|
|
9
9
|
export type { ScopeOptions } from '../index.js';
|
|
10
|
-
export { ApiError, isBlocksError } from '../errors.js';
|
|
10
|
+
export { ApiError, isBlocksError, hasAuthError, DEFAULT_API_ERROR_NAME } from '../errors.js';
|
|
11
11
|
export declare class BlocksStack extends cdk.Stack implements BaseBlocksStack {
|
|
12
12
|
readonly id: string;
|
|
13
13
|
readonly apiUrl: string;
|
package/dist/cdk/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cdk/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,C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+13,7 @@ export { DEFAULT_NODE_RUNTIME } from './node-version.js';
|
|
|
13
13
|
export { SandboxDisableDeletionProtection } from './mixins.js';
|
|
14
14
|
export { registerConfig, finalizeConfigRegistry } from './config-registry.js';
|
|
15
15
|
export { synthGuard } from './synth-guard.js';
|
|
16
|
-
export { ApiError, isBlocksError } from '../errors.js';
|
|
16
|
+
export { ApiError, isBlocksError, hasAuthError, DEFAULT_API_ERROR_NAME } from '../errors.js';
|
|
17
17
|
export class BlocksStack extends cdk.Stack {
|
|
18
18
|
id;
|
|
19
19
|
apiUrl;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -92,6 +92,6 @@ export interface ApiNamespaceClientOptions {
|
|
|
92
92
|
* ```
|
|
93
93
|
*/
|
|
94
94
|
export declare function ApiNamespaceClient<T extends Record<string, (...args: any[]) => any>>(name: string, options?: ApiNamespaceClientOptions): AsyncAPI<T>;
|
|
95
|
-
export { ApiError, isBlocksError } from '../errors.js';
|
|
95
|
+
export { ApiError, isBlocksError, hasAuthError, DEFAULT_API_ERROR_NAME } from '../errors.js';
|
|
96
96
|
export { Scope, type ScopeOptions } from '../common/index.js';
|
|
97
97
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC;AAChC,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,IAAI,GAAG,CAAC;AAiBhF,KAAK,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,IAAI;KAChE,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE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AAM,WAAW,yBAAyB;IACxC,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,EAClF,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,yBAAyB,GAClC,QAAQ,CAAC,CAAC,CAAC,CAyDb;AAED,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC7F,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/client/index.js
CHANGED
|
@@ -234,5 +234,5 @@ export function ApiNamespaceClient(name, options) {
|
|
|
234
234
|
}
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
|
-
export { ApiError, isBlocksError } from '../errors.js';
|
|
237
|
+
export { ApiError, isBlocksError, hasAuthError, DEFAULT_API_ERROR_NAME } from '../errors.js';
|
|
238
238
|
export { Scope } from '../common/index.js';
|
package/dist/constants.d.ts
CHANGED
|
@@ -24,4 +24,16 @@ export declare const BLOCKS_RPC_PREFIX = "/aws-blocks/api";
|
|
|
24
24
|
* prefix; CloudFront forwards the subtree and the Lambda dispatches by path.
|
|
25
25
|
*/
|
|
26
26
|
export declare const BLOCKS_AUTH_PREFIX = "/aws-blocks/auth";
|
|
27
|
+
/**
|
|
28
|
+
* Reserved path for the client runtime config (`config.json`).
|
|
29
|
+
*
|
|
30
|
+
* In production CloudFront serves `${BLOCKS_SANDBOX_PREFIX}/*` from S3 as
|
|
31
|
+
* static assets (see hosting.ts) so the browser client can resolve its API
|
|
32
|
+
* URL. The local dev server mirrors this by serving the config from the front
|
|
33
|
+
* door itself, instead of proxying the request to the framework dev server —
|
|
34
|
+
* which only serves its own static dir (Next.js `public/`, etc.) and would 404
|
|
35
|
+
* on a project-root file. Keeping this symmetric with production is what makes
|
|
36
|
+
* the browser client work the same in `dev`, `sandbox`, and deployed.
|
|
37
|
+
*/
|
|
38
|
+
export declare const BLOCKS_SANDBOX_PREFIX = "/.blocks-sandbox";
|
|
27
39
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,qBAAqB,CAAC;AAErD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,qBAAqB,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -26,3 +26,15 @@ export const BLOCKS_RPC_PREFIX = '/aws-blocks/api';
|
|
|
26
26
|
* prefix; CloudFront forwards the subtree and the Lambda dispatches by path.
|
|
27
27
|
*/
|
|
28
28
|
export const BLOCKS_AUTH_PREFIX = '/aws-blocks/auth';
|
|
29
|
+
/**
|
|
30
|
+
* Reserved path for the client runtime config (`config.json`).
|
|
31
|
+
*
|
|
32
|
+
* In production CloudFront serves `${BLOCKS_SANDBOX_PREFIX}/*` from S3 as
|
|
33
|
+
* static assets (see hosting.ts) so the browser client can resolve its API
|
|
34
|
+
* URL. The local dev server mirrors this by serving the config from the front
|
|
35
|
+
* door itself, instead of proxying the request to the framework dev server —
|
|
36
|
+
* which only serves its own static dir (Next.js `public/`, etc.) and would 404
|
|
37
|
+
* on a project-root file. Keeping this symmetric with production is what makes
|
|
38
|
+
* the browser client work the same in `dev`, `sandbox`, and deployed.
|
|
39
|
+
*/
|
|
40
|
+
export const BLOCKS_SANDBOX_PREFIX = '/.blocks-sandbox';
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `name` an `ApiError` falls back to when no structured error name is
|
|
3
|
+
* given. A name equal to this carries no BB-level meaning, so consumers
|
|
4
|
+
* branching on the structured identity should treat it as "no name".
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_API_ERROR_NAME = "ApiError";
|
|
1
7
|
/**
|
|
2
8
|
* Error subclass for errors that cross the wire between server and client.
|
|
3
9
|
*
|
|
@@ -64,4 +70,26 @@ export declare class ApiError extends Error {
|
|
|
64
70
|
export declare function isBlocksError<N extends string>(e: unknown, name: N): e is Error & {
|
|
65
71
|
name: N;
|
|
66
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Type guard for branching on a failed `AuthState` (the recommended
|
|
75
|
+
* `setAuthState` client path) by its structured `errorName`.
|
|
76
|
+
*
|
|
77
|
+
* The returned state is a plain object, not a thrown `Error`, so
|
|
78
|
+
* `isBlocksError` does not apply — use this on the value returned by
|
|
79
|
+
* `setAuthState`/`getAuthState`. Match on the BB error constant, never on
|
|
80
|
+
* the human-facing `error` string.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const next = await authApi.setAuthState({ action: 'signIn', username, password });
|
|
85
|
+
* if (hasAuthError(next, AuthBasicErrors.InvalidCredentials)) {
|
|
86
|
+
* // unknown user → fall back to sign-up
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function hasAuthError<T extends {
|
|
91
|
+
errorName?: string;
|
|
92
|
+
}, N extends string>(state: T | null | undefined, name: N): state is T & {
|
|
93
|
+
errorName: N;
|
|
94
|
+
};
|
|
67
95
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,QAAS,SAAQ,KAAK;IAClC,wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;gBAEhB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;CAM9G;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,GAAG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAE7F"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,aAAa,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,QAAS,SAAQ,KAAK;IAClC,wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;gBAEhB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;CAM9G;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,GAAG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAE7F;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,SAAS,MAAM,EAC9E,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,EAC3B,IAAI,EAAE,CAAC,GACL,KAAK,IAAI,CAAC,GAAG;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,CAE/B"}
|
package/dist/errors.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* The `name` an `ApiError` falls back to when no structured error name is
|
|
5
|
+
* given. A name equal to this carries no BB-level meaning, so consumers
|
|
6
|
+
* branching on the structured identity should treat it as "no name".
|
|
7
|
+
*/
|
|
8
|
+
export const DEFAULT_API_ERROR_NAME = 'ApiError';
|
|
3
9
|
/**
|
|
4
10
|
* Error subclass for errors that cross the wire between server and client.
|
|
5
11
|
*
|
|
@@ -44,7 +50,7 @@ export class ApiError extends Error {
|
|
|
44
50
|
retriable;
|
|
45
51
|
constructor(message, status, options) {
|
|
46
52
|
super(message, options?.cause ? { cause: options.cause } : undefined);
|
|
47
|
-
this.name = options?.name ??
|
|
53
|
+
this.name = options?.name ?? DEFAULT_API_ERROR_NAME;
|
|
48
54
|
this.status = status;
|
|
49
55
|
this.retriable = options?.retriable ?? false;
|
|
50
56
|
}
|
|
@@ -67,3 +73,23 @@ export class ApiError extends Error {
|
|
|
67
73
|
export function isBlocksError(e, name) {
|
|
68
74
|
return e instanceof Error && e.name === name;
|
|
69
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Type guard for branching on a failed `AuthState` (the recommended
|
|
78
|
+
* `setAuthState` client path) by its structured `errorName`.
|
|
79
|
+
*
|
|
80
|
+
* The returned state is a plain object, not a thrown `Error`, so
|
|
81
|
+
* `isBlocksError` does not apply — use this on the value returned by
|
|
82
|
+
* `setAuthState`/`getAuthState`. Match on the BB error constant, never on
|
|
83
|
+
* the human-facing `error` string.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const next = await authApi.setAuthState({ action: 'signIn', username, password });
|
|
88
|
+
* if (hasAuthError(next, AuthBasicErrors.InvalidCredentials)) {
|
|
89
|
+
* // unknown user → fall back to sign-up
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export function hasAuthError(state, name) {
|
|
94
|
+
return state?.errorName === name;
|
|
95
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.test.d.ts","sourceRoot":"","sources":["../src/errors.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { describe, it } from 'node:test';
|
|
4
|
+
import assert from 'node:assert';
|
|
5
|
+
import { ApiError, isBlocksError, hasAuthError } from './errors.js';
|
|
6
|
+
describe('isBlocksError', () => {
|
|
7
|
+
it('matches a thrown ApiError by name', () => {
|
|
8
|
+
const e = new ApiError('nope', 401, { name: 'InvalidCredentialsException' });
|
|
9
|
+
assert.ok(isBlocksError(e, 'InvalidCredentialsException'));
|
|
10
|
+
});
|
|
11
|
+
it('does not match a different name', () => {
|
|
12
|
+
const e = new ApiError('nope', 401, { name: 'InvalidCredentialsException' });
|
|
13
|
+
assert.ok(!isBlocksError(e, 'SomeOtherException'));
|
|
14
|
+
});
|
|
15
|
+
it('does not match a plain object (not an Error)', () => {
|
|
16
|
+
assert.ok(!isBlocksError({ name: 'InvalidCredentialsException' }, 'InvalidCredentialsException'));
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe('hasAuthError', () => {
|
|
20
|
+
it('matches a state carrying the given errorName', () => {
|
|
21
|
+
const state = { state: 'signedOut', errorName: 'InvalidCredentialsException' };
|
|
22
|
+
assert.ok(hasAuthError(state, 'InvalidCredentialsException'));
|
|
23
|
+
});
|
|
24
|
+
it('does not match a different errorName', () => {
|
|
25
|
+
const state = { errorName: 'InvalidCredentialsException' };
|
|
26
|
+
assert.ok(!hasAuthError(state, 'UserAlreadyExistsException'));
|
|
27
|
+
});
|
|
28
|
+
it('does not match a state with no errorName', () => {
|
|
29
|
+
const state = {};
|
|
30
|
+
assert.ok(!hasAuthError(state, 'InvalidCredentialsException'));
|
|
31
|
+
});
|
|
32
|
+
it('is safe on null / undefined', () => {
|
|
33
|
+
assert.ok(!hasAuthError(null, 'InvalidCredentialsException'));
|
|
34
|
+
assert.ok(!hasAuthError(undefined, 'InvalidCredentialsException'));
|
|
35
|
+
});
|
|
36
|
+
it('narrows the errorName to the matched literal', () => {
|
|
37
|
+
const state = { errorName: 'InvalidCredentialsException' };
|
|
38
|
+
if (hasAuthError(state, 'InvalidCredentialsException')) {
|
|
39
|
+
// Type-level: state.errorName is narrowed to the literal.
|
|
40
|
+
const name = state.errorName;
|
|
41
|
+
assert.strictEqual(name, 'InvalidCredentialsException');
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
assert.fail('expected match');
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
package/dist/hosting.d.ts
CHANGED
|
@@ -35,8 +35,29 @@ export type ComputeConfig = {
|
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
37
|
timeout?: cdk.Duration | number;
|
|
38
|
-
/** Reserved concurrent executions. Default: undefined (no reservation). */
|
|
38
|
+
/** Reserved concurrent executions for the SSR Lambda. Default: undefined (no reservation). */
|
|
39
39
|
reservedConcurrency?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Overrides for the image-optimization Lambda.
|
|
42
|
+
*
|
|
43
|
+
* `reservedConcurrency` defaults to undefined (no reservation). It is left
|
|
44
|
+
* unreserved so deploys succeed on fresh AWS accounts, whose default
|
|
45
|
+
* account-level unreserved-concurrency limit is 10 — reserving any
|
|
46
|
+
* concurrency there can drop the account below its required minimum and
|
|
47
|
+
* cause Lambda to reject the stack with a 400. Set this only if you have
|
|
48
|
+
* headroom and want to cap image-opt throughput.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* compute: {
|
|
53
|
+
* imageOptimization: { reservedConcurrency: 5 },
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
imageOptimization?: {
|
|
58
|
+
/** Reserved concurrent executions. Default: undefined (no reservation). */
|
|
59
|
+
reservedConcurrency?: number;
|
|
60
|
+
};
|
|
40
61
|
/** CloudWatch log retention for the SSR Lambda. Default: TWO_WEEKS. */
|
|
41
62
|
logRetention?: cdk.aws_logs.RetentionDays;
|
|
42
63
|
};
|
package/dist/hosting.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosting.d.ts","sourceRoot":"","sources":["../src/hosting.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AASnC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAC1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,8BAA8B,CAAC;A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{ BLOCKS_RPC_PREFIX, BLOCKS_AUTH_PREFIX } from './constants.js';
|
|
3
|
-
export { ApiError, isBlocksError } from './errors.js';
|
|
3
|
+
export { ApiError, isBlocksError, hasAuthError, DEFAULT_API_ERROR_NAME } from './errors.js';
|
|
4
4
|
export { EventSourceMapping } from './lambda-handler.js';
|
|
5
5
|
export { BlocksStackProps } from './common/index.js';
|
|
6
6
|
export { registerSdkIdentifiers, getSdkIdentifiers, getAllSdkIdentifiers, _resetSdkRegistry } from './common/sdk-registry.js';
|
package/dist/index.cdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cdk.d.ts","sourceRoot":"","sources":["../src/index.cdk.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.cdk.d.ts","sourceRoot":"","sources":["../src/index.cdk.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC9H,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxH,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,gCAAgC,EAAE,aAAa,EAAE,cAAc,EAAE,sBAAsB,EAAE,UAAU,EAAE,oBAAoB,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACxM,OAAO,EACL,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,QAAQ,EACR,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,UAAU,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,QAAQ,EACR,WAAW,EACX,wBAAwB,EACxB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.cdk.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
export { ApiNamespace } from './api.js';
|
|
4
4
|
export { BLOCKS_RPC_PREFIX, BLOCKS_AUTH_PREFIX } from './constants.js';
|
|
5
|
-
export { ApiError, isBlocksError } from './errors.js';
|
|
5
|
+
export { ApiError, isBlocksError, hasAuthError, DEFAULT_API_ERROR_NAME } from './errors.js';
|
|
6
6
|
export { EventSourceMapping } from './lambda-handler.js';
|
|
7
7
|
export { registerSdkIdentifiers, getSdkIdentifiers, getAllSdkIdentifiers, _resetSdkRegistry } from './common/sdk-registry.js';
|
|
8
8
|
export { getConfig, getConfigSync, preloadConfig, loadConfigToProcessEnv, _resetConfigCache } from './common/config.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ApiNamespace, type BlocksContext, type ApiHandler } from './api.js';
|
|
2
2
|
export { BLOCKS_RPC_PREFIX, BLOCKS_AUTH_PREFIX } from './constants.js';
|
|
3
|
-
export { ApiError, isBlocksError } from './errors.js';
|
|
3
|
+
export { ApiError, isBlocksError, hasAuthError, DEFAULT_API_ERROR_NAME } from './errors.js';
|
|
4
4
|
export { Scope, type ScopeOptions, type ScopeParent, type BuildingBlockMeta } from './common/index.js';
|
|
5
5
|
export { registerSdkIdentifiers, getSdkIdentifiers, getAllSdkIdentifiers, _resetSdkRegistry } from './common/sdk-registry.js';
|
|
6
6
|
export { getConfig, getConfigSync, preloadConfig, loadConfigToProcessEnv, _resetConfigCache } from './common/config.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC9H,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxH,OAAO,EACL,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,eAAe,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
export { ApiNamespace } from './api.js';
|
|
4
4
|
export { BLOCKS_RPC_PREFIX, BLOCKS_AUTH_PREFIX } from './constants.js';
|
|
5
|
-
export { ApiError, isBlocksError } from './errors.js';
|
|
5
|
+
export { ApiError, isBlocksError, hasAuthError, DEFAULT_API_ERROR_NAME } from './errors.js';
|
|
6
6
|
export { Scope } from './common/index.js';
|
|
7
7
|
export { registerSdkIdentifiers, getSdkIdentifiers, getAllSdkIdentifiers, _resetSdkRegistry } from './common/sdk-registry.js';
|
|
8
8
|
export { getConfig, getConfigSync, preloadConfig, loadConfigToProcessEnv, _resetConfigCache } from './common/config.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-server-config.test.d.ts","sourceRoot":"","sources":["../../src/scripts/dev-server-config.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { describe, it } from 'node:test';
|
|
4
|
+
import assert from 'node:assert';
|
|
5
|
+
import { buildBlocksConfig, isBlocksConfigRequest } from './dev-server.js';
|
|
6
|
+
describe('buildBlocksConfig — client runtime config', () => {
|
|
7
|
+
it('points the browser at the localhost front door RPC endpoint', () => {
|
|
8
|
+
assert.deepStrictEqual(buildBlocksConfig(3000, false), {
|
|
9
|
+
apiUrl: 'http://localhost:3000/aws-blocks/api',
|
|
10
|
+
environment: 'local',
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
it('honors a custom port', () => {
|
|
14
|
+
assert.strictEqual(buildBlocksConfig(4000, false).apiUrl, 'http://localhost:4000/aws-blocks/api');
|
|
15
|
+
});
|
|
16
|
+
it('marks the environment as sandbox but keeps the localhost front door', () => {
|
|
17
|
+
assert.deepStrictEqual(buildBlocksConfig(3000, true), {
|
|
18
|
+
apiUrl: 'http://localhost:3000/aws-blocks/api',
|
|
19
|
+
environment: 'sandbox',
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe('isBlocksConfigRequest — reserved runtime-config path', () => {
|
|
24
|
+
it('matches GET /.blocks-sandbox/config.json', () => {
|
|
25
|
+
assert.strictEqual(isBlocksConfigRequest('GET', '/.blocks-sandbox/config.json'), true);
|
|
26
|
+
});
|
|
27
|
+
it('ignores non-GET methods (only the static-style read is reserved)', () => {
|
|
28
|
+
assert.strictEqual(isBlocksConfigRequest('POST', '/.blocks-sandbox/config.json'), false);
|
|
29
|
+
assert.strictEqual(isBlocksConfigRequest('HEAD', '/.blocks-sandbox/config.json'), false);
|
|
30
|
+
});
|
|
31
|
+
it('does not match other paths (frontend/app routes pass through to the proxy)', () => {
|
|
32
|
+
assert.strictEqual(isBlocksConfigRequest('GET', '/'), false);
|
|
33
|
+
assert.strictEqual(isBlocksConfigRequest('GET', '/api/chat'), false);
|
|
34
|
+
assert.strictEqual(isBlocksConfigRequest('GET', '/.blocks-sandbox/other.json'), false);
|
|
35
|
+
assert.strictEqual(isBlocksConfigRequest('GET', '/aws-blocks/api'), false);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-server-supervisor.test.d.ts","sourceRoot":"","sources":["../../src/scripts/dev-server-supervisor.test.ts"],"names":[],"mappings":""}
|