@composurecdk/core 0.3.5 → 0.3.6
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/construct-id.d.ts +45 -0
- package/dist/construct-id.d.ts.map +1 -0
- package/dist/construct-id.js +54 -0
- package/dist/construct-id.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for producing safe CDK construct IDs from arbitrary strings.
|
|
3
|
+
*
|
|
4
|
+
* The `constructs` library uses `/` as the path separator between construct
|
|
5
|
+
* IDs. When user-supplied strings (DNS names, ARNs, filesystem paths) are
|
|
6
|
+
* passed through to a construct ID, any embedded `/` silently gets rewritten
|
|
7
|
+
* to `--`, which produces unreadable CloudFormation logical IDs. Control
|
|
8
|
+
* characters are likewise unsafe.
|
|
9
|
+
*
|
|
10
|
+
* These helpers consolidate that sanitization in one place so every builder
|
|
11
|
+
* in the monorepo applies the same constraints.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Return a construct-ID-safe copy of `raw` by replacing unsafe characters
|
|
15
|
+
* (`/` and control characters) with a single `-`.
|
|
16
|
+
*
|
|
17
|
+
* Does not touch other characters — CDK construct IDs are otherwise
|
|
18
|
+
* permissive, and collapsing further (e.g., to PascalCase) would destroy
|
|
19
|
+
* information a reader expects to see in the synthesised tree.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* sanitizeConstructId("a/b") // "a-b"
|
|
24
|
+
* sanitizeConstructId("_sip._tcp") // "_sip._tcp" (unchanged)
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function sanitizeConstructId(raw: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Join the supplied parts into a single construct ID. Falsy parts are
|
|
30
|
+
* dropped; each remaining part is passed through {@link sanitizeConstructId}
|
|
31
|
+
* and the results are joined with `-`.
|
|
32
|
+
*
|
|
33
|
+
* Intended for composing IDs from a mix of static prefixes and user-supplied
|
|
34
|
+
* fragments — the sanitization step means callers don't have to reason about
|
|
35
|
+
* what characters their inputs might contain.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* constructId("records", "a", "api") // "records-a-api"
|
|
40
|
+
* constructId("zone", undefined, "www") // "zone-www"
|
|
41
|
+
* constructId("records", "a/b") // "records-a-b"
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function constructId(...parts: readonly (string | undefined | null | false)[]): string;
|
|
45
|
+
//# sourceMappingURL=construct-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"construct-id.d.ts","sourceRoot":"","sources":["../src/construct-id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,GAAG,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,KAAK,CAAC,EAAE,GAAG,MAAM,CAK5F"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for producing safe CDK construct IDs from arbitrary strings.
|
|
3
|
+
*
|
|
4
|
+
* The `constructs` library uses `/` as the path separator between construct
|
|
5
|
+
* IDs. When user-supplied strings (DNS names, ARNs, filesystem paths) are
|
|
6
|
+
* passed through to a construct ID, any embedded `/` silently gets rewritten
|
|
7
|
+
* to `--`, which produces unreadable CloudFormation logical IDs. Control
|
|
8
|
+
* characters are likewise unsafe.
|
|
9
|
+
*
|
|
10
|
+
* These helpers consolidate that sanitization in one place so every builder
|
|
11
|
+
* in the monorepo applies the same constraints.
|
|
12
|
+
*/
|
|
13
|
+
// eslint-disable-next-line no-control-regex
|
|
14
|
+
const UNSAFE = /[/\x00-\x1f\x7f]/g;
|
|
15
|
+
/**
|
|
16
|
+
* Return a construct-ID-safe copy of `raw` by replacing unsafe characters
|
|
17
|
+
* (`/` and control characters) with a single `-`.
|
|
18
|
+
*
|
|
19
|
+
* Does not touch other characters — CDK construct IDs are otherwise
|
|
20
|
+
* permissive, and collapsing further (e.g., to PascalCase) would destroy
|
|
21
|
+
* information a reader expects to see in the synthesised tree.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* sanitizeConstructId("a/b") // "a-b"
|
|
26
|
+
* sanitizeConstructId("_sip._tcp") // "_sip._tcp" (unchanged)
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function sanitizeConstructId(raw) {
|
|
30
|
+
return raw.replace(UNSAFE, "-");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Join the supplied parts into a single construct ID. Falsy parts are
|
|
34
|
+
* dropped; each remaining part is passed through {@link sanitizeConstructId}
|
|
35
|
+
* and the results are joined with `-`.
|
|
36
|
+
*
|
|
37
|
+
* Intended for composing IDs from a mix of static prefixes and user-supplied
|
|
38
|
+
* fragments — the sanitization step means callers don't have to reason about
|
|
39
|
+
* what characters their inputs might contain.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* constructId("records", "a", "api") // "records-a-api"
|
|
44
|
+
* constructId("zone", undefined, "www") // "zone-www"
|
|
45
|
+
* constructId("records", "a/b") // "records-a-b"
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export function constructId(...parts) {
|
|
49
|
+
return parts
|
|
50
|
+
.filter((p) => typeof p === "string" && p.length > 0)
|
|
51
|
+
.map(sanitizeConstructId)
|
|
52
|
+
.join("-");
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=construct-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"construct-id.js","sourceRoot":"","sources":["../src/construct-id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,4CAA4C;AAC5C,MAAM,MAAM,GAAG,mBAAmB,CAAC;AAEnC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,WAAW,CAAC,GAAG,KAAqD;IAClF,OAAO,KAAK;SACT,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;SACjE,GAAG,CAAC,mBAAmB,CAAC;SACxB,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Builder, type IBuilder } from "./builder.js";
|
|
2
|
+
export { constructId, sanitizeConstructId } from "./construct-id.js";
|
|
2
3
|
export { compose, type ComposedSystem, type ConfiguredSystem, type AfterBuildHook, } from "./compose.js";
|
|
3
4
|
export { CyclicDependencyError } from "./cyclic-dependency-error.js";
|
|
4
5
|
export { type Lifecycle } from "./lifecycle.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EACL,OAAO,EACP,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,cAAc,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,WAAW,EACX,aAAa,GACd,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EACL,OAAO,EACP,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,cAAc,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,WAAW,EACX,aAAa,GACd,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Builder } from "./builder.js";
|
|
2
|
+
export { constructId, sanitizeConstructId } from "./construct-id.js";
|
|
2
3
|
export { compose, } from "./compose.js";
|
|
3
4
|
export { CyclicDependencyError } from "./cyclic-dependency-error.js";
|
|
4
5
|
export { Ref, ref, resolve, isRef } from "./ref.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,cAAc,CAAC;AACtD,OAAO,EACL,OAAO,GAIR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAmB,MAAM,UAAU,CAAC;AACrE,OAAO,EAGL,WAAW,EACX,aAAa,GACd,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EACL,OAAO,GAIR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAmB,MAAM,UAAU,CAAC;AACrE,OAAO,EAGL,WAAW,EACX,aAAa,GACd,MAAM,qBAAqB,CAAC"}
|