@composurecdk/lambda 0.9.5 → 0.10.1

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 (33) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +177 -0
  3. package/dist/commonjs/event-sources/dynamodb-event-source.d.ts +10 -4
  4. package/dist/commonjs/event-sources/dynamodb-event-source.d.ts.map +1 -1
  5. package/dist/commonjs/event-sources/dynamodb-event-source.js.map +1 -1
  6. package/dist/commonjs/function-builder.d.ts +79 -7
  7. package/dist/commonjs/function-builder.d.ts.map +1 -1
  8. package/dist/commonjs/function-builder.js +83 -4
  9. package/dist/commonjs/function-builder.js.map +1 -1
  10. package/dist/commonjs/index.d.ts +1 -0
  11. package/dist/commonjs/index.d.ts.map +1 -1
  12. package/dist/commonjs/index.js +4 -1
  13. package/dist/commonjs/index.js.map +1 -1
  14. package/dist/commonjs/invoke-on-deploy.d.ts +83 -0
  15. package/dist/commonjs/invoke-on-deploy.d.ts.map +1 -0
  16. package/dist/commonjs/invoke-on-deploy.js +155 -0
  17. package/dist/commonjs/invoke-on-deploy.js.map +1 -0
  18. package/dist/esm/event-sources/dynamodb-event-source.d.ts +10 -4
  19. package/dist/esm/event-sources/dynamodb-event-source.d.ts.map +1 -1
  20. package/dist/esm/event-sources/dynamodb-event-source.js.map +1 -1
  21. package/dist/esm/function-builder.d.ts +79 -7
  22. package/dist/esm/function-builder.d.ts.map +1 -1
  23. package/dist/esm/function-builder.js +84 -5
  24. package/dist/esm/function-builder.js.map +1 -1
  25. package/dist/esm/index.d.ts +1 -0
  26. package/dist/esm/index.d.ts.map +1 -1
  27. package/dist/esm/index.js +1 -0
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/esm/invoke-on-deploy.d.ts +83 -0
  30. package/dist/esm/invoke-on-deploy.d.ts.map +1 -0
  31. package/dist/esm/invoke-on-deploy.js +151 -0
  32. package/dist/esm/invoke-on-deploy.js.map +1 -0
  33. package/package.json +14 -12
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jason Duffett
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -49,6 +49,32 @@ const handler = createFunctionBuilder()
49
49
  .build(stack, "MyFunction");
50
50
  ```
51
51
 
52
+ ## Environment variables
53
+
54
+ Each **value** in `.environment(...)` is independently `Resolvable`, so a variable can carry a sibling's output while the rest stay literal:
55
+
56
+ ```ts
57
+ import { compose, ref } from "@composurecdk/core";
58
+ import { createRestApiBuilder, type RestApiBuilderResult } from "@composurecdk/apigateway";
59
+
60
+ compose(
61
+ {
62
+ api: createRestApiBuilder().restApiName("Orders"),
63
+ worker: createFunctionBuilder()
64
+ .runtime(Runtime.NODEJS_22_X)
65
+ .handler("index.handler")
66
+ .code(Code.fromAsset("lambda"))
67
+ .environment({
68
+ API_URL: ref("api", (r: RestApiBuilderResult) => r.api.url),
69
+ LOG_LEVEL: "info",
70
+ }),
71
+ },
72
+ { api: [], worker: ["api"] },
73
+ );
74
+ ```
75
+
76
+ Per value rather than over the whole record, because mixing the two is the common case: wrapping the record would push every literal through the same `ref`, and through [`combine`](../core/README.md) as soon as two siblings are involved.
77
+
52
78
  ## Environment variable encryption
53
79
 
54
80
  Lambda encrypts environment variables at rest with an AWS-managed key. `.environmentEncryption(...)` opts into a customer-managed one, and accepts a concrete key or a `Resolvable`, so a key built by [`@composurecdk/kms`](../kms/README.md) can be a component of the same system rather than a construct created before `compose`:
@@ -78,6 +104,8 @@ By default, `createFunctionBuilder` creates an explicit IAM execution role with
78
104
  - No `logs:CreateLogGroup` (the builder pre-creates the group).
79
105
  - No `AWSLambdaBasicExecutionRole` managed policy — that policy grants the same actions on `*`, allowing a compromised function to write to any log group in the account.
80
106
 
107
+ Supplying your own `logGroup` keeps that scoping: the ARN is read from wherever the `aws-cdk-lib` you have installed keeps it, so a log group in either the L2 or the reference form works. One that exposes no ARN at all fails the build by name rather than emitting an unscoped or malformed policy — reach for `.role()` or `.useCdkAutoRole()` if you need the builder to stay out of the role entirely.
108
+
81
109
  The role is exposed on the build result:
82
110
 
83
111
  ```ts
@@ -400,6 +428,155 @@ today (the queue often arrives as an unresolved `ref()`); they are tracked in
400
428
  `kinesisEventSource` is still deferred — see
401
429
  [#120](https://github.com/laazyj/composureCDK/issues/120).
402
430
 
431
+ ## Deploy-time invocation: `.invokeOnDeploy()`
432
+
433
+ Some work has to happen _as part of shipping the stack_, and its outcome has to
434
+ gate the deployment: registering the release with an external service, calling
435
+ the system you just deployed to prove it answers, seeding reference data through
436
+ a service API. `.invokeOnDeploy()` invokes the function once during deployment
437
+ and **fails the deployment if the function fails** — the stack rolls back and
438
+ the handler's error message lands in the CloudFormation events.
439
+
440
+ ```ts
441
+ import { compose, ref } from "@composurecdk/core";
442
+ import { createFunctionBuilder } from "@composurecdk/lambda";
443
+
444
+ compose(
445
+ {
446
+ register: createFunctionBuilder()
447
+ .runtime(Runtime.NODEJS_22_X)
448
+ .handler("index.handler")
449
+ .code(Code.fromAsset("register"))
450
+ .timeout(Duration.seconds(30))
451
+ .environment({ API_URL: "https://releases.example.com/v1/register" })
452
+ .invokeOnDeploy({ after: [ref("api", (r: RestApiBuilderResult) => r.api)] }),
453
+
454
+ api: createRestApiBuilder().restApiName("Orders"),
455
+ },
456
+ { api: [], register: ["api"] },
457
+ ).build(stack, "Release");
458
+ ```
459
+
460
+ ### What it is
461
+
462
+ If you already write CDK custom resources, the whole mental model is one
463
+ sentence: **it is CDK's
464
+ [`triggers.Trigger`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.triggers-readme.html),
465
+ with the synchronous invocation fixed and the wait and ordering derived from the
466
+ function.** Everything below is detail on those defaults.
467
+
468
+ Worth stating plainly, because the other two tools look right and are not.
469
+ `custom_resources.Provider` wants a handler of yours that speaks the
470
+ CloudFormation custom-resource protocol. `AwsCustomResource` runs one fixed SDK
471
+ call with no handler of yours — and reaching for `Lambda.invoke` there
472
+ [reports success when your handler fails](../custom-resources/README.md).
473
+ `Trigger` is the one that invokes a plain handler and fails the stack on an
474
+ error, and it is the least known of the three.
475
+
476
+ It is a domain action on the function builder
477
+ ([ADR-0016](../../docs/adr/0016-domain-action-custom-resource.md)): you declare
478
+ the intent, the builder owns the invocation semantics, the wait derivation, the
479
+ execution-role ordering and the IAM. The custom resource is exposed on the build
480
+ result as `deploymentTrigger`, so a sibling can be ordered against the call
481
+ itself (`deploymentTrigger.executeBefore(...)`).
482
+
483
+ Three things reach the template:
484
+
485
+ - **A `Custom::Trigger`**, carrying the handler ARN, the invocation type, the
486
+ wait, and `ExecuteOnHandlerChange`.
487
+ - **A trigger provider Lambda and its role** — one per stack, shared by every
488
+ `Trigger` in it, created by CDK rather than by this builder.
489
+ - **An `AWS::Lambda::Version` of your function.** `Trigger` addresses the handler
490
+ by its `currentVersion`, so calling `.invokeOnDeploy()` publishes a version —
491
+ unconditionally, including under `executeOnHandlerChange: false`. That is the
492
+ re-invocation mechanism rather than an accident: the version ARN changes when
493
+ the function's code or configuration does, and that property change is what
494
+ CloudFormation acts on.
495
+
496
+ ### The handler must throw
497
+
498
+ **A handler that returns an error rather than throwing does not fail the
499
+ deployment.** Lambda considers an invocation that returns successful no matter
500
+ what the payload says, so an HTTP-shaped `{ statusCode: 500 }` — or a caught
501
+ error folded into the response — deploys green:
502
+
503
+ ```ts
504
+ export const handler = async () => {
505
+ const response = await fetch(process.env.API_URL, { method: "POST" });
506
+ if (!response.ok) {
507
+ // Throw. Returning `{ statusCode: response.status }` here would deploy green.
508
+ throw new Error(`Registration failed: ${response.status} ${await response.text()}`);
509
+ }
510
+ };
511
+ ```
512
+
513
+ ### Ordering
514
+
515
+ The function's own execution role is always waited for, so the policies attached
516
+ _to it_ by `.grant()` and `.configureRole()` exist before the handler runs —
517
+ CloudFormation does not otherwise sequence those ahead of a custom resource, and
518
+ the handler would race them.
519
+
520
+ That covers the **identity** half of a grant, which is not always the whole
521
+ grant. `grantDecrypt` on a KMS key, or a cross-account bucket grant, also writes
522
+ a **resource** policy, and that half lives in the granting resource's own tree
523
+ where this ordering does not reach. If the handler needs it at deploy time, name
524
+ that resource in `after`.
525
+
526
+ Everything else the call depends on goes in `after` as well. It takes any
527
+ [`DependencySource`](../core/README.md#ordering-adddependencies) — the same
528
+ shapes as `dependsOn` in
529
+ [`@composurecdk/custom-resources`](../custom-resources/README.md).
530
+
531
+ One caveat on "always": a role supplied with `.role(Role.fromRoleArn(...))`
532
+ contributes no resources to the template, so there is nothing to sequence and
533
+ the wait is a no-op. Nothing is lost — an imported role's policies were never
534
+ this stack's to create — but do not read it as a guarantee that they are in
535
+ place.
536
+
537
+ ### Defaults
538
+
539
+ | Option | Default | Rationale |
540
+ | ------------------------ | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
541
+ | invocation type | `RequestResponse` (not settable) | The deployment waits for the result. An asynchronous invocation returns before the work happens, reporting success whatever the handler did — the opposite of the point. |
542
+ | `timeout` | function `timeout` + 30s | The deployment outlives the handler, so a handler that runs to its limit reports _its_ error ("Task timed out after …") instead of the deployment abandoning the call. Capped at 14m30s. |
543
+ | `executeOnHandlerChange` | `true` | Re-invokes when the handler's code or configuration changes; a no-op on unrelated stack updates. |
544
+
545
+ The derivation values are exported as `INVOKE_ON_DEPLOY_DEFAULTS`. With no
546
+ function `timeout` set (or a token one), the wait falls back to 2 minutes,
547
+ matching CDK's own `Trigger` default.
548
+
549
+ Whenever the wait ends up at or below the function's own timeout, a suppressible
550
+ warning fires under `INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID` — the deployment would
551
+ stop waiting while the handler is still running, so a slow call fails the stack
552
+ as an abandoned invocation rather than reporting the handler's error. That
553
+ covers an explicit `timeout` set too low, and also a function timeout at or
554
+ above the 14m30s cap, where the cap leaves no margin to add.
555
+
556
+ The cap is not Lambda's 15-minute ceiling but CDK's trigger provider: that
557
+ provider runs with a 15-minute Lambda timeout of its own and `Trigger` sets no
558
+ `ServiceTimeout` on the custom resource, so a provider that dies mid-wait posts
559
+ nothing back and CloudFormation is never told. The result is a **hung**
560
+ deployment, not a failed one. `.invokeOnDeploy()` therefore **throws** on an
561
+ explicit `timeout` above the cap rather than clamping it, and keeps 30s in hand
562
+ on the derived path so the provider outlives the call it is waiting on.
563
+
564
+ ### What it does not do
565
+
566
+ - **It does not invoke on every deployment.** With `executeOnHandlerChange: true`
567
+ the invocation re-runs when the handler changes; with `false` it runs only on
568
+ the stack's first deployment. CDK's `Trigger` offers no "always" mode.
569
+ - **It does not invoke on stack deletion.** For teardown-time work, use
570
+ [`@composurecdk/custom-resources`](../custom-resources/README.md), which has
571
+ create/update/**delete** semantics.
572
+ - **It creates no alarms.** The custom resource runs once per deployment, not
573
+ continuously; there is no steady-state signal to alarm on. Failures surface as
574
+ a failed deployment.
575
+ - **It is not a general SDK-call escape hatch.** A call that has no
576
+ CloudFormation resource but needs no handler of yours belongs in
577
+ `createAwsCustomResourceBuilder()` — that builder invokes an AWS API directly,
578
+ no Lambda of yours involved.
579
+
403
580
  ## Examples
404
581
 
405
582
  - [DualFunctionStack](../examples/src/dual-function-app.ts) — Two Lambda functions with recommended alarms, custom alarms, and SNS alarm actions
@@ -1,5 +1,5 @@
1
1
  import type { ITable } from "aws-cdk-lib/aws-dynamodb";
2
- import type { IEventSourceDlq, StartingPosition } from "aws-cdk-lib/aws-lambda";
2
+ import type { StartingPosition } from "aws-cdk-lib/aws-lambda";
3
3
  import { type DynamoEventSourceProps } from "aws-cdk-lib/aws-lambda-event-sources";
4
4
  import type { IQueue } from "aws-cdk-lib/aws-sqs";
5
5
  import { type Resolvable } from "@composurecdk/core";
@@ -30,11 +30,17 @@ export interface DynamoStreamEventSourceProps extends Omit<DynamoEventSourceProp
30
30
  /**
31
31
  * Destination for records that exhaust `retryAttempts` or exceed
32
32
  * `maxRecordAge`. Pass an {@link IQueue} (wrapped in {@link SqsDlq}
33
- * automatically), a concrete {@link IEventSourceDlq}, or a `ref()` to a
34
- * sibling that produces either.
33
+ * automatically), a concrete destination, or a `ref()` to a sibling that
34
+ * produces either.
35
+ *
36
+ * The destination arm is read from CDK's own prop rather than named as
37
+ * `IEventSourceDlq`, so it keeps tracking that type as CDK moves it
38
+ * (ADR-0018). The `IQueue` arm is the builder's own convenience and has no
39
+ * CDK prop to read from.
40
+ *
35
41
  * @see https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-errors
36
42
  */
37
- onFailure?: Resolvable<IQueue | IEventSourceDlq>;
43
+ onFailure?: Resolvable<IQueue | NonNullable<DynamoEventSourceProps["onFailure"]>>;
38
44
  }
39
45
  /**
40
46
  * Wraps a DynamoDB table's change stream as a Lambda {@link IEventSource},
@@ -1 +1 @@
1
- {"version":3,"file":"dynamodb-event-source.d.ts","sourceRoot":"","sources":["../../../src/event-sources/dynamodb-event-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAA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AAwB,MAAM,6BAA6B,CAAC;AAG9F;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,sKAAoC,CAAC;AAEnF;;;;;;;GAOG;AACH,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CACxD,sBAAsB,EACtB,WAAW,GAAG,kBAAkB,CACjC;IACC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC,MAAM,GAAG,WAAW,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CACnF;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,EACzB,KAAK,CAAC,EAAE,4BAA4B,GACnC,oBAAoB,CAwBtB"}
@@ -1 +1 @@
1
- {"version":3,"file":"dynamodb-event-source.js","sourceRoot":"","sources":["../../../src/event-sources/dynamodb-event-source.ts"],"names":[],"mappings":";;;AAoHA,8CA2BC;AA7ID,mFAI8C;AAE9C,6CAAqE;AACrE,2EAA8F;AAC9F,uFAAsF;AAEtF;;;;;;GAMG;AACU,QAAA,iCAAiC,GAAG,mEAAiC,CAAC;AA+BnF,sFAAsF;AACtF,SAAS,KAAK,CAAC,WAAqC;IAClD,6EAA6E;IAC7E,wDAAwD;IACxD,OAAO,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,iCAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;AAC3E,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,SAAgB,iBAAiB,CAC/B,KAAyB,EACzB,KAAoC;IAEpC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE,CA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E,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,SAAgB,iBAAiB,CAC/B,KAAyB,EACzB,KAAoC;IAEpC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE,CAAC;IAC3C,MAAM,MAAM,GAA8C;QACxD,GAAG,yCAAiC;QACpC,GAAG,IAAI;KACR,CAAC;IAEF,IAAI,MAAgC,CAAC;IACrC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,0EAA0E;QAC1E,MAAM,GAAG,IAAA,YAAK,EAAC,KAAK,CAAC;YACnB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,4CAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAClE,CAAC,CAAC,IAAI,4CAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;SAAM,CAAC;QACN,wEAAwE;QACxE,oEAAoE;QACpE,MAAM,GAAG,IAAA,cAAO,EACd,EAAE,KAAK,EAAE,SAAS,EAAE,EACpB,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,EAAE,CACnD,IAAI,4CAAiB,CAAC,aAAa,EAAE,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CACrF,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,gDAAoB,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC"}
@@ -2,6 +2,7 @@ import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
2
2
  import { type IGrantable, type IRole } from "aws-cdk-lib/aws-iam";
3
3
  import { Function as LambdaFunction, type FunctionProps, type IEventSource } from "aws-cdk-lib/aws-lambda";
4
4
  import type { LogGroup } from "aws-cdk-lib/aws-logs";
5
+ import type { Trigger } from "aws-cdk-lib/triggers";
5
6
  import { type IConstruct } from "constructs";
6
7
  import { COPY_STATE, type Grant, type Lifecycle, type Resolvable } from "@composurecdk/core";
7
8
  import { type ITaggedBuilder } from "@composurecdk/cloudformation";
@@ -9,28 +10,31 @@ import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
9
10
  import { type IRoleBuilder } from "@composurecdk/iam";
10
11
  import type { FunctionAlarmConfig } from "./alarm-config.js";
11
12
  import { type ComposureEventSource } from "./event-sources/composure-event-source.js";
13
+ import { type InvokeOnDeployOptions } from "./invoke-on-deploy.js";
12
14
  /**
13
15
  * Configuration properties for the Lambda function builder.
14
16
  *
15
17
  * Extends the CDK {@link FunctionProps} with builder-specific options. The
16
- * `role` and `environmentEncryption` props are widened to {@link Resolvable}
17
- * so a role or key built by a sibling component can be referenced via
18
- * `ref(...)` at configuration time.
18
+ * `role` and `environmentEncryption` are widened to {@link Resolvable}, and
19
+ * `environment` to a record of `Resolvable` values, so a role, key or value
20
+ * built by a sibling component can be referenced via `ref(...)` at
21
+ * configuration time. Each reads its inner type from CDK's own prop so they
22
+ * keep tracking it (ADR-0018).
19
23
  */
20
- export interface FunctionBuilderProps extends Omit<FunctionProps, "role" | "environmentEncryption"> {
24
+ export interface FunctionBuilderProps extends Omit<FunctionProps, "role" | "environmentEncryption" | "environment"> {
21
25
  /**
22
26
  * The IAM execution role to attach to the function. When set, the builder
23
27
  * skips creating its own role and the auto-created `LogsWriter` inline
24
28
  * policy is **not** added — the caller is fully responsible for the role's
25
29
  * permissions.
26
30
  *
27
- * Accepts a concrete {@link IRole} or a {@link Resolvable} for
28
- * cross-component wiring (e.g. `ref("sharedRole", r => r.role)`).
31
+ * Accepts a concrete role or a {@link Resolvable} for cross-component wiring
32
+ * (e.g. `ref("sharedRole", r => r.role)`).
29
33
  *
30
34
  * Mutually exclusive with {@link IFunctionBuilder.configureRole} and
31
35
  * {@link IFunctionBuilder.useCdkAutoRole}.
32
36
  */
33
- role?: Resolvable<IRole>;
37
+ role?: Resolvable<NonNullable<FunctionProps["role"]>>;
34
38
  /**
35
39
  * The customer-managed KMS key used to encrypt the function's environment
36
40
  * variables at rest.
@@ -51,6 +55,20 @@ export interface FunctionBuilderProps extends Omit<FunctionProps, "role" | "envi
51
55
  * @see https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-encryption
52
56
  */
53
57
  environmentEncryption?: Resolvable<NonNullable<FunctionProps["environmentEncryption"]>>;
58
+ /**
59
+ * Key-value pairs the function can read from `process.env` (e.g.
60
+ * `.environment({ API_URL: ref("api", (r) => r.api.url), LOG_LEVEL: "info" })`).
61
+ *
62
+ * Each **value** is independently {@link Resolvable}, rather than the record
63
+ * as a whole, because mixing a reference with literals is the common case:
64
+ * wrapping the record would push every literal through the same `ref`, and
65
+ * through {@link combine} as soon as two siblings are involved. Matches
66
+ * `validationZones` in `@composurecdk/acm`.
67
+ *
68
+ * The value type is read from CDK's own prop rather than written as `string`,
69
+ * so it tracks `aws-cdk-lib` (ADR-0018).
70
+ */
71
+ environment?: Record<string, Resolvable<NonNullable<FunctionProps["environment"]>[string]>>;
54
72
  /**
55
73
  * Configuration for AWS-recommended CloudWatch alarms.
56
74
  *
@@ -130,6 +148,18 @@ export interface FunctionBuilderResult {
130
148
  * Always present — `{}` when no event sources were added.
131
149
  */
132
150
  eventSources: Record<string, IEventSource>;
151
+ /**
152
+ * The custom resource that invokes the function during deployment, or
153
+ * `undefined` unless {@link IFunctionBuilder.invokeOnDeploy} was called.
154
+ *
155
+ * Exposed so a sibling can be ordered against the invocation — e.g.
156
+ * `deploymentTrigger.executeBefore(...)` to gate another resource on the
157
+ * call having succeeded.
158
+ *
159
+ * Optional, unlike the always-present `alarms` / `eventSources` beside it:
160
+ * there is no empty `Trigger` to stand in for the absence of one.
161
+ */
162
+ deploymentTrigger?: Trigger;
133
163
  }
134
164
  /**
135
165
  * A fluent builder for configuring and creating an AWS Lambda function.
@@ -238,6 +268,48 @@ declare class FunctionBuilder implements Lifecycle<FunctionBuilderResult> {
238
268
  * Mutually exclusive with {@link role} and {@link configureRole}.
239
269
  */
240
270
  useCdkAutoRole(): this;
271
+ /**
272
+ * Invoke this function once during deployment, and **fail the deployment if
273
+ * it fails** — a domain action for work that must happen as part of shipping
274
+ * the stack, such as registering the release with an external service,
275
+ * verifying the deployed system answers correctly, or seeding reference data
276
+ * through a service API (ADR-0016).
277
+ *
278
+ * The deployment waits for the handler's response. If the handler throws or
279
+ * times out, the stack fails and rolls back, and the handler's error message
280
+ * reaches the CloudFormation stack events.
281
+ *
282
+ * **The handler must throw to fail the deployment.** Returning an error
283
+ * object — an HTTP-shaped `{ statusCode: 500 }`, or a caught error swallowed
284
+ * into the response — is a *successful* invocation as far as Lambda is
285
+ * concerned, and the deployment goes green.
286
+ *
287
+ * Ordering is data: the function's own execution role is always waited for,
288
+ * and anything else the call needs is declared with
289
+ * {@link InvokeOnDeployOptions.after}.
290
+ *
291
+ * The deployment waits for this function's own `timeout` plus 30s, rather
292
+ * than the flat 2 minutes CDK's `Trigger` defaults to, so a handler that runs
293
+ * to its limit reports *its* error instead of the deployment abandoning the
294
+ * call first. The wait is capped at 14m30s — see
295
+ * {@link InvokeOnDeployOptions.timeout}, which throws above that rather than
296
+ * clamping.
297
+ *
298
+ * Calling this more than once replaces the previous options. The resulting
299
+ * custom resource is exposed on
300
+ * {@link FunctionBuilderResult.deploymentTrigger}.
301
+ *
302
+ * @example
303
+ * ```ts
304
+ * createFunctionBuilder()
305
+ * .runtime(Runtime.NODEJS_22_X)
306
+ * .handler("index.handler")
307
+ * .code(Code.fromAsset("register"))
308
+ * .timeout(Duration.seconds(30))
309
+ * .invokeOnDeploy({ after: [ref("api", (r: RestApiBuilderResult) => r.api)] });
310
+ * ```
311
+ */
312
+ invokeOnDeploy(options?: InvokeOnDeployOptions): this;
241
313
  /**
242
314
  * Grant this function's execution role access to a resource built by a
243
315
  * sibling component.
@@ -1 +1 @@
1
- {"version":3,"file":"function-buil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AAE,MAAM,EACX,SAAS,EAAE,CACT,KAAK,EAAE,sBAAsB,CAAC,cAAc,CAAC,KAC1C,sBAAsB,CAAC,cAAc,CAAC,GAC1C,IAAI;IAKP;;;;;;;;;;;;;;;;;;OAkBG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,oBAAoB,GAAG,YAAY,CAAC,GAAG,IAAI;IAU1F;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,OAAO,GAAG,IAAI;IAKtD;;;;;;;;;;;;OAYG;IACH,cAAc,IAAI,IAAI;IAKtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,IAAI;IAKzD;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,GAAG,IAAI;IAK3C,gCAAgC;IAChC,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAS3C,KAAK,CACH,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACnC,qBAAqB;CA4IzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,qBAAqB,IAAI,gBAAgB,CAExD"}
@@ -12,7 +12,33 @@ const function_alarms_js_1 = require("./function-alarms.js");
12
12
  const defaults_js_1 = require("./defaults.js");
13
13
  const composure_event_source_js_1 = require("./event-sources/composure-event-source.js");
14
14
  const event_source_relationship_guards_js_1 = require("./event-sources/event-source-relationship-guards.js");
15
+ const invoke_on_deploy_js_1 = require("./invoke-on-deploy.js");
15
16
  const LOGS_WRITER_POLICY_NAME = "LogsWriter";
17
+ /**
18
+ * The log group's ARN, wherever the installed `aws-cdk-lib` keeps it.
19
+ *
20
+ * `FunctionProps.logGroup` is `logs.ILogGroup` at this package's floor and
21
+ * `logs.ILogGroupRef` on current CDK, and the ARN sits somewhere different on
22
+ * each: `logGroupArn` on the L2 interface, `logGroupRef.logGroupArn` on the
23
+ * reference interface. Neither member compiles against both ends of the
24
+ * supported range, and narrowing the prop to the one we can read is what
25
+ * ADR-0018 forbids, so the value is read structurally instead.
26
+ *
27
+ * Reading it through a cast to `ILogGroup` instead produced
28
+ * `Resource: ["undefined:log-stream:*"]` for a log group that only exposes the
29
+ * reference form: a policy that grants the function nothing, and that
30
+ * CloudFormation rejects as a malformed ARN.
31
+ */
32
+ function logGroupArnOf(logGroup, id) {
33
+ const shape = logGroup;
34
+ const arn = shape.logGroupArn ?? shape.logGroupRef?.logGroupArn;
35
+ if (arn === undefined) {
36
+ throw new Error(`FunctionBuilder "${id}": the supplied logGroup exposes no ARN, so the default ` +
37
+ `execution role's ${LOGS_WRITER_POLICY_NAME} policy cannot be scoped to it. ` +
38
+ `Supply a log group that does, or bring your own role with .role() / .useCdkAutoRole().`);
39
+ }
40
+ return arn;
41
+ }
16
42
  class FunctionBuilder {
17
43
  props = {};
18
44
  #customAlarms = [];
@@ -20,6 +46,7 @@ class FunctionBuilder {
20
46
  #grants = new core_1.GrantQueue();
21
47
  #configureRole;
22
48
  #useCdkAutoRole = false;
49
+ #invokeOnDeploy;
23
50
  addAlarm(key, configure) {
24
51
  this.#customAlarms.push(configure(new cloudwatch_1.AlarmDefinitionBuilder(key)));
25
52
  return this;
@@ -83,6 +110,51 @@ class FunctionBuilder {
83
110
  this.#useCdkAutoRole = true;
84
111
  return this;
85
112
  }
113
+ /**
114
+ * Invoke this function once during deployment, and **fail the deployment if
115
+ * it fails** — a domain action for work that must happen as part of shipping
116
+ * the stack, such as registering the release with an external service,
117
+ * verifying the deployed system answers correctly, or seeding reference data
118
+ * through a service API (ADR-0016).
119
+ *
120
+ * The deployment waits for the handler's response. If the handler throws or
121
+ * times out, the stack fails and rolls back, and the handler's error message
122
+ * reaches the CloudFormation stack events.
123
+ *
124
+ * **The handler must throw to fail the deployment.** Returning an error
125
+ * object — an HTTP-shaped `{ statusCode: 500 }`, or a caught error swallowed
126
+ * into the response — is a *successful* invocation as far as Lambda is
127
+ * concerned, and the deployment goes green.
128
+ *
129
+ * Ordering is data: the function's own execution role is always waited for,
130
+ * and anything else the call needs is declared with
131
+ * {@link InvokeOnDeployOptions.after}.
132
+ *
133
+ * The deployment waits for this function's own `timeout` plus 30s, rather
134
+ * than the flat 2 minutes CDK's `Trigger` defaults to, so a handler that runs
135
+ * to its limit reports *its* error instead of the deployment abandoning the
136
+ * call first. The wait is capped at 14m30s — see
137
+ * {@link InvokeOnDeployOptions.timeout}, which throws above that rather than
138
+ * clamping.
139
+ *
140
+ * Calling this more than once replaces the previous options. The resulting
141
+ * custom resource is exposed on
142
+ * {@link FunctionBuilderResult.deploymentTrigger}.
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * createFunctionBuilder()
147
+ * .runtime(Runtime.NODEJS_22_X)
148
+ * .handler("index.handler")
149
+ * .code(Code.fromAsset("register"))
150
+ * .timeout(Duration.seconds(30))
151
+ * .invokeOnDeploy({ after: [ref("api", (r: RestApiBuilderResult) => r.api)] });
152
+ * ```
153
+ */
154
+ invokeOnDeploy(options = {}) {
155
+ this.#invokeOnDeploy = options;
156
+ return this;
157
+ }
86
158
  /**
87
159
  * Grant this function's execution role access to a resource built by a
88
160
  * sibling component.
@@ -113,9 +185,10 @@ class FunctionBuilder {
113
185
  this.#grants.copyInto(target.#grants);
114
186
  target.#configureRole = this.#configureRole;
115
187
  target.#useCdkAutoRole = this.#useCdkAutoRole;
188
+ target.#invokeOnDeploy = this.#invokeOnDeploy;
116
189
  }
117
190
  build(scope, id, context = {}) {
118
- const { role: roleResolvable, environmentEncryption, recommendedAlarms: alarmConfig, ...functionProps } = this.props;
191
+ const { role: roleResolvable, environmentEncryption, environment, recommendedAlarms: alarmConfig, ...functionProps } = this.props;
119
192
  const seamCount = (roleResolvable !== undefined ? 1 : 0) +
120
193
  (this.#configureRole !== undefined ? 1 : 0) +
121
194
  (this.#useCdkAutoRole ? 1 : 0);
@@ -133,7 +206,7 @@ class FunctionBuilder {
133
206
  role = (0, core_1.resolve)(roleResolvable, context);
134
207
  }
135
208
  else if (!this.#useCdkAutoRole) {
136
- role = this.#buildDefaultRole(scope, id, context, (logGroup ?? this.props.logGroup));
209
+ role = this.#buildDefaultRole(scope, id, context, logGroup ?? this.props.logGroup);
137
210
  }
138
211
  const mergedProps = {
139
212
  ...defaults_js_1.FUNCTION_DEFAULTS,
@@ -143,6 +216,7 @@ class FunctionBuilder {
143
216
  ...(environmentEncryption !== undefined
144
217
  ? { environmentEncryption: (0, core_1.resolve)(environmentEncryption, context) }
145
218
  : {}),
219
+ ...(environment !== undefined ? { environment: (0, core_1.resolve)((0, core_1.combine)(environment), context) } : {}),
146
220
  };
147
221
  const fn = new aws_lambda_1.Function(scope, id, mergedProps);
148
222
  this.#grants.applyTo(fn, context);
@@ -182,13 +256,18 @@ class FunctionBuilder {
182
256
  if (!resolvedRole) {
183
257
  throw new Error(`FunctionBuilder "${id}": Lambda function has no execution role.`);
184
258
  }
185
- return { function: fn, role: resolvedRole, logGroup, alarms, eventSources };
259
+ // Built last so the invocation is ordered after everything the builder
260
+ // attached to the function — grants included.
261
+ const deploymentTrigger = this.#invokeOnDeploy
262
+ ? (0, invoke_on_deploy_js_1.createDeploymentTrigger)(scope, id, fn, resolvedRole, this.#invokeOnDeploy, context)
263
+ : undefined;
264
+ return { function: fn, role: resolvedRole, logGroup, alarms, eventSources, deploymentTrigger };
186
265
  }
187
266
  #buildDefaultRole(scope, id, context, logGroup) {
188
267
  if (!logGroup) {
189
268
  throw new Error(`FunctionBuilder "${id}": cannot build the default execution role without a log group.`);
190
269
  }
191
- const logGroupArn = logGroup.logGroupArn;
270
+ const logGroupArn = logGroupArnOf(logGroup, id);
192
271
  const roleBuilder = (0, iam_1.createServiceRoleBuilder)("lambda.amazonaws.com").addInlinePolicyStatements(LOGS_WRITER_POLICY_NAME, [
193
272
  (0, iam_1.createStatementBuilder)()
194
273
  .allow()
@@ -1 +1 @@
1
- {"version":3,"file":"function-builder.js","sourceRoot":"","sources":["../../src/function-builder.ts"],"names":[],"mappings":";;AAsgBA,sDAEC;AAvgBD,iDAAiF;AACjF,uDAIgC;AAGhC,6CAO4B;AAC5B,iEAAkF;AAClF,yDAAkE;AAClE,2CAI2B;AAC3B,6CAA2D;AAE3D,6DAA4D;AAC5D,+CAAkD;AAClD,yFAKmD;AACnD,6GAAuG;AAEvG,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAqM7C,MAAM,eAAe;IACnB,KAAK,GAAkC,EAAE,CAAC;IACjC,aAAa,GAA6C,EAAE,CAAC;IAC7D,aAAa,GAAuB,EAAE,CAAC;IACvC,OAAO,GAAG,IAAI,iBAAU,EAAc,CAAC;IAChD,cAAc,CAAiC;IAC/C,eAAe,GAAG,KAAK,CAAC;IAExB,QAAQ,CACN,GAAW,EACX,SAE2C;QAE3C,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,mCAAsB,CAAiB,GAAG,CAAC,CAAC,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,cAAc,CAAC,GAAW,EAAE,MAAuD;QACjF,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CACb,kDAAkD,GAAG,6CAA6C,CACnG,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,EAAiC;QAC7C,IA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G,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ;YACxB,IAAI,IAAI,KAAK,2BAA2B,EAAE,CAAC;gBACzC,MAAM,OAAO,GAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE;oBACpD,IAAI,IAAI,KAAK,uBAAuB,EAAE,CAAC;wBACrC,MAAM,IAAI,KAAK,CACb,oBAAoB,UAAU,uCAAuC;4BACnE,IAAI,uBAAuB,6CAA6C;4BACxE,mEAAmE;4BACnE,2DAA2D,CAC9D,CAAC;oBACJ,CAAC;oBACD,OAAO,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;gBACpC,CAAC,CAAC;gBACF,OAAO,OAAO,CAAC;YACjB,CAAC;YACD,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAY,CAAC;QACxD,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1,6 +1,7 @@
1
1
  export { createFunctionBuilder, type FunctionBuilderProps, type FunctionBuilderResult, type IFunctionBuilder, } from "./function-builder.js";
2
2
  export { functionGrants } from "./grants.js";
3
3
  export { FUNCTION_DEFAULTS } from "./defaults.js";
4
+ export { INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID, INVOKE_ON_DEPLOY_DEFAULTS, type InvokeOnDeployOptions, } from "./invoke-on-deploy.js";
4
5
  export { type FunctionAlarmConfig, type PercentageAlarmConfig } from "./alarm-config.js";
5
6
  export { FUNCTION_ALARM_DEFAULTS } from "./alarm-defaults.js";
6
7
  export { type ComposureEventSource, type EventSourceKind, } from "./event-sources/composure-event-source.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,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MAAM,qDAAqD,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,iDAAiD,CAAC;AACpG,OAAO,EACL,iBAAiB,EACjB,iCAAiC,EACjC,KAAK,4BAA4B,GAClC,MAAM,0CAA0C,CAAC"}
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_DYNAMO_EVENT_SOURCE_PROPS = exports.dynamoEventSource = exports.DEFAULT_STREAM_EVENT_SOURCE_PROPS = exports.STREAM_DLQ_WARNING_ID = exports.SQS_VISIBILITY_TIMEOUT_WARNING_ID = exports.DEFAULT_SQS_EVENT_SOURCE_PROPS = exports.sqsEventSource = exports.FUNCTION_ALARM_DEFAULTS = exports.FUNCTION_DEFAULTS = exports.functionGrants = exports.createFunctionBuilder = void 0;
3
+ exports.DEFAULT_DYNAMO_EVENT_SOURCE_PROPS = exports.dynamoEventSource = exports.DEFAULT_STREAM_EVENT_SOURCE_PROPS = exports.STREAM_DLQ_WARNING_ID = exports.SQS_VISIBILITY_TIMEOUT_WARNING_ID = exports.DEFAULT_SQS_EVENT_SOURCE_PROPS = exports.sqsEventSource = exports.FUNCTION_ALARM_DEFAULTS = exports.INVOKE_ON_DEPLOY_DEFAULTS = exports.INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID = exports.FUNCTION_DEFAULTS = exports.functionGrants = exports.createFunctionBuilder = void 0;
4
4
  var function_builder_js_1 = require("./function-builder.js");
5
5
  Object.defineProperty(exports, "createFunctionBuilder", { enumerable: true, get: function () { return function_builder_js_1.createFunctionBuilder; } });
6
6
  var grants_js_1 = require("./grants.js");
7
7
  Object.defineProperty(exports, "functionGrants", { enumerable: true, get: function () { return grants_js_1.functionGrants; } });
8
8
  var defaults_js_1 = require("./defaults.js");
9
9
  Object.defineProperty(exports, "FUNCTION_DEFAULTS", { enumerable: true, get: function () { return defaults_js_1.FUNCTION_DEFAULTS; } });
10
+ var invoke_on_deploy_js_1 = require("./invoke-on-deploy.js");
11
+ Object.defineProperty(exports, "INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID", { enumerable: true, get: function () { return invoke_on_deploy_js_1.INVOKE_ON_DEPLOY_TIMEOUT_WARNING_ID; } });
12
+ Object.defineProperty(exports, "INVOKE_ON_DEPLOY_DEFAULTS", { enumerable: true, get: function () { return invoke_on_deploy_js_1.INVOKE_ON_DEPLOY_DEFAULTS; } });
10
13
  var alarm_defaults_js_1 = require("./alarm-defaults.js");
11
14
  Object.defineProperty(exports, "FUNCTION_ALARM_DEFAULTS", { enumerable: true, get: function () { return alarm_defaults_js_1.FUNCTION_ALARM_DEFAULTS; } });
12
15
  var sqs_event_source_js_1 = require("./event-sources/sqs-event-source.js");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAK+B;AAJ7B,4HAAA,qBAAqB,OAAA;AAKvB,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AACvB,6CAAkD;AAAzC,gHAAA,iBAAiB,OAAA;AAE1B,yDAA8D;AAArD,4HAAA,uBAAuB,OAAA;AAKhC,2EAG6C;AAF3C,qHAAA,cAAc,OAAA;AACd,qIAAA,8BAA8B,OAAA;AAEhC,2GAG6D;AAF3D,wJAAA,iCAAiC,OAAA;AACjC,4IAAA,qBAAqB,OAAA;AAEvB,mGAAoG;AAA3F,oJAAA,iCAAiC,OAAA;AAC1C,qFAIkD;AAHhD,6HAAA,iBAAiB,OAAA;AACjB,6IAAA,iCAAiC,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAK+B;AAJ7B,4HAAA,qBAAqB,OAAA;AAKvB,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AACvB,6CAAkD;AAAzC,gHAAA,iBAAiB,OAAA;AAC1B,6DAI+B;AAH7B,0IAAA,mCAAmC,OAAA;AACnC,gIAAA,yBAAyB,OAAA;AAI3B,yDAA8D;AAArD,4HAAA,uBAAuB,OAAA;AAKhC,2EAG6C;AAF3C,qHAAA,cAAc,OAAA;AACd,qIAAA,8BAA8B,OAAA;AAEhC,2GAG6D;AAF3D,wJAAA,iCAAiC,OAAA;AACjC,4IAAA,qBAAqB,OAAA;AAEvB,mGAAoG;AAA3F,oJAAA,iCAAiC,OAAA;AAC1C,qFAIkD;AAHhD,6HAAA,iBAAiB,OAAA;AACjB,6IAAA,iCAAiC,OAAA"}