effortless-aws 0.36.1 → 0.38.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 +27 -26
- package/dist/auth-YWMYFMBX.js +11 -0
- package/dist/bucket-client-FRWISKEB.js +9 -0
- package/dist/chunk-3NKYT4OX.js +268 -0
- package/dist/chunk-4UKWMWM5.js +113 -0
- package/dist/chunk-JFNBO4K3.js +243 -0
- package/dist/chunk-U56MLLWP.js +6 -0
- package/dist/chunk-UU3AKDJU.js +159 -0
- package/dist/chunk-VONNUUEN.js +16 -0
- package/dist/email-client-RMDQDOYI.js +34 -0
- package/dist/index.d.ts +106 -77
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/queue-client-WDAJYGQO.js +57 -0
- package/dist/runtime/wrap-api.js +14 -5
- package/dist/runtime/wrap-bucket.js +11 -4
- package/dist/runtime/wrap-cron.js +5 -2
- package/dist/runtime/wrap-mcp.js +5 -2
- package/dist/runtime/{wrap-fifo-queue.js → wrap-queue.js} +10 -7
- package/dist/runtime/wrap-table-stream.js +16 -9
- package/dist/runtime/wrap-worker.js +2 -1
- package/dist/ssm-client-2XDJC3HF.js +33 -0
- package/dist/table-client-BBLIC3EV.js +7 -0
- package/dist/worker-client-ZS25XCC2.js +69 -0
- package/package.json +1 -1
- package/dist/chunk-Q3ZDMZF3.js +0 -889
package/dist/index.d.ts
CHANGED
|
@@ -101,7 +101,7 @@ type LambdaConfig = {
|
|
|
101
101
|
};
|
|
102
102
|
/**
|
|
103
103
|
* Lambda configuration with additional IAM permissions.
|
|
104
|
-
* Used by handler types that support custom permissions (http, table,
|
|
104
|
+
* Used by handler types that support custom permissions (http, table, queue).
|
|
105
105
|
*/
|
|
106
106
|
type LambdaWithPermissions = LambdaConfig & {
|
|
107
107
|
/** Additional IAM permissions for the Lambda */
|
|
@@ -543,11 +543,11 @@ type MailerHandler = {
|
|
|
543
543
|
declare const defineMailer: () => (options: MailerConfig) => MailerHandler;
|
|
544
544
|
|
|
545
545
|
/**
|
|
546
|
-
* Parsed SQS
|
|
546
|
+
* Parsed SQS message passed to the handler callbacks.
|
|
547
547
|
*
|
|
548
548
|
* @typeParam T - Type of the decoded message body (from schema function)
|
|
549
549
|
*/
|
|
550
|
-
type
|
|
550
|
+
type QueueMessage<T = unknown> = {
|
|
551
551
|
/** Unique message identifier */
|
|
552
552
|
messageId: string;
|
|
553
553
|
/** Receipt handle for acknowledgement */
|
|
@@ -556,9 +556,9 @@ type FifoQueueMessage<T = unknown> = {
|
|
|
556
556
|
body: T;
|
|
557
557
|
/** Raw unparsed message body string */
|
|
558
558
|
rawBody: string;
|
|
559
|
-
/** Message group ID (FIFO ordering key) */
|
|
559
|
+
/** Message group ID (FIFO ordering key, empty string for standard queues) */
|
|
560
560
|
messageGroupId: string;
|
|
561
|
-
/** Message deduplication ID */
|
|
561
|
+
/** Message deduplication ID (FIFO only) */
|
|
562
562
|
messageDeduplicationId?: string;
|
|
563
563
|
/** SQS message attributes */
|
|
564
564
|
messageAttributes: Record<string, {
|
|
@@ -573,9 +573,18 @@ type FifoQueueMessage<T = unknown> = {
|
|
|
573
573
|
sentTimestamp?: string;
|
|
574
574
|
};
|
|
575
575
|
/**
|
|
576
|
-
*
|
|
576
|
+
* Event source mapping (poller) configuration — how Lambda consumes the queue.
|
|
577
|
+
*/
|
|
578
|
+
type QueuePollerConfig = {
|
|
579
|
+
/** Number of messages per Lambda invocation (1-10 for FIFO, default: 10) */
|
|
580
|
+
batchSize?: number;
|
|
581
|
+
/** Maximum time to gather messages before invoking (default: 0). Accepts `"5s"`, `"1m"`, etc. */
|
|
582
|
+
batchWindow?: Duration;
|
|
583
|
+
};
|
|
584
|
+
/**
|
|
585
|
+
* Configuration options for a queue handler.
|
|
577
586
|
*/
|
|
578
|
-
type
|
|
587
|
+
type QueueConfig = {
|
|
579
588
|
/** Lambda function settings (memory, timeout, permissions, etc.) */
|
|
580
589
|
lambda?: {
|
|
581
590
|
memory?: number;
|
|
@@ -583,20 +592,23 @@ type FifoQueueConfig = {
|
|
|
583
592
|
logLevel?: LogLevel;
|
|
584
593
|
permissions?: Permission[];
|
|
585
594
|
};
|
|
586
|
-
/**
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
595
|
+
/**
|
|
596
|
+
* Whether this is a FIFO queue (ordered, exactly-once).
|
|
597
|
+
* Currently only `true` is supported — standard queue support is planned.
|
|
598
|
+
*/
|
|
599
|
+
fifo?: boolean;
|
|
590
600
|
/** Visibility timeout (default: max of timeout or 30s). Accepts `"30s"`, `"5m"`, etc. */
|
|
591
601
|
visibilityTimeout?: Duration;
|
|
592
602
|
/** Message retention period (default: `"4d"`). Accepts `"1h"`, `"7d"`, etc. */
|
|
593
603
|
retentionPeriod?: Duration;
|
|
594
604
|
/** Delivery delay for all messages in the queue (default: 0). Accepts `"30s"`, `"5m"`, etc. */
|
|
595
605
|
delay?: Duration;
|
|
596
|
-
/** Enable content-based deduplication (default: true) */
|
|
606
|
+
/** Enable content-based deduplication for FIFO queues (default: true) */
|
|
597
607
|
contentBasedDeduplication?: boolean;
|
|
598
608
|
/** Max number of receives before a message is sent to the dead-letter queue (default: 3) */
|
|
599
609
|
maxReceiveCount?: number;
|
|
610
|
+
/** Event source mapping config — set via `.poller({...})` builder method. */
|
|
611
|
+
poller?: QueuePollerConfig;
|
|
600
612
|
};
|
|
601
613
|
/** Spread ctx into callback args (empty when no setup) */
|
|
602
614
|
type SpreadCtx$5<C> = [C] extends [undefined] ? {} : C & {};
|
|
@@ -612,26 +624,26 @@ type SetupArgs$5<D, P, HasFiles extends boolean> = ([D] extends [undefined] ? {}
|
|
|
612
624
|
* Per-message handler function.
|
|
613
625
|
* Called once per message in the batch. Failures are reported individually.
|
|
614
626
|
*/
|
|
615
|
-
type
|
|
616
|
-
message:
|
|
627
|
+
type QueueMessageFn<T = unknown, C = undefined> = (args: {
|
|
628
|
+
message: QueueMessage<T>;
|
|
617
629
|
} & SpreadCtx$5<C>) => Promise<void>;
|
|
618
630
|
/**
|
|
619
631
|
* Batch handler function.
|
|
620
632
|
* Called once with all messages in the batch.
|
|
621
633
|
* Return `{ failures: string[] }` (messageIds) for partial batch failure reporting.
|
|
622
634
|
*/
|
|
623
|
-
type
|
|
624
|
-
messages:
|
|
635
|
+
type QueueBatchFn<T = unknown, C = undefined> = (args: {
|
|
636
|
+
messages: QueueMessage<T>[];
|
|
625
637
|
} & SpreadCtx$5<C>) => Promise<void | {
|
|
626
638
|
failures: string[];
|
|
627
639
|
}>;
|
|
628
640
|
/**
|
|
629
|
-
* Internal handler object created by
|
|
641
|
+
* Internal handler object created by defineQueue.
|
|
630
642
|
* @internal
|
|
631
643
|
*/
|
|
632
|
-
type
|
|
633
|
-
readonly __brand: "effortless-
|
|
634
|
-
readonly __spec:
|
|
644
|
+
type QueueHandler$1<T = unknown, C = any> = {
|
|
645
|
+
readonly __brand: "effortless-queue";
|
|
646
|
+
readonly __spec: QueueConfig;
|
|
635
647
|
readonly schema?: (input: unknown) => T;
|
|
636
648
|
readonly onError?: (...args: any[]) => any;
|
|
637
649
|
readonly onCleanup?: (...args: any[]) => any;
|
|
@@ -642,64 +654,78 @@ type FifoQueueHandler$1<T = unknown, C = any> = {
|
|
|
642
654
|
readonly onMessage?: (...args: any[]) => any;
|
|
643
655
|
readonly onMessageBatch?: (...args: any[]) => any;
|
|
644
656
|
};
|
|
645
|
-
/** Options passed to `
|
|
646
|
-
type
|
|
647
|
-
/**
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
657
|
+
/** Options passed to `defineQueue()` — queue resource config */
|
|
658
|
+
type QueueOptions<T> = {
|
|
659
|
+
/**
|
|
660
|
+
* Whether this is a FIFO queue (ordered, exactly-once).
|
|
661
|
+
* Currently only `true` is supported — standard queue support is planned.
|
|
662
|
+
*/
|
|
663
|
+
fifo?: boolean;
|
|
651
664
|
/** Visibility timeout (default: max of timeout or 30s) */
|
|
652
665
|
visibilityTimeout?: Duration;
|
|
653
666
|
/** Message retention period (default: "4d") */
|
|
654
667
|
retentionPeriod?: Duration;
|
|
655
668
|
/** Delivery delay for all messages in the queue (default: 0) */
|
|
656
669
|
delay?: Duration;
|
|
657
|
-
/** Enable content-based deduplication (default: true) */
|
|
670
|
+
/** Enable content-based deduplication for FIFO queues (default: true) */
|
|
658
671
|
contentBasedDeduplication?: boolean;
|
|
659
672
|
/** Max number of receives before DLQ (default: 3) */
|
|
660
673
|
maxReceiveCount?: number;
|
|
661
674
|
/** Decode/validate function for the message body */
|
|
662
675
|
schema?: (input: unknown) => T;
|
|
663
676
|
};
|
|
664
|
-
interface
|
|
677
|
+
interface QueueBuilder<T = unknown, D = undefined, P = undefined, C = undefined, HasFiles extends boolean = false> {
|
|
665
678
|
/** Declare handler dependencies */
|
|
666
|
-
deps<D2 extends Record<string, AnyDepHandler>>(fn: () => D2):
|
|
679
|
+
deps<D2 extends Record<string, AnyDepHandler>>(fn: () => D2): QueueBuilder<T, D2, P, C, HasFiles>;
|
|
667
680
|
/** Declare SSM secrets */
|
|
668
|
-
config<P2 extends Record<string, AnySecretRef>>(fn: ConfigFactory<P2>):
|
|
681
|
+
config<P2 extends Record<string, AnySecretRef>>(fn: ConfigFactory<P2>): QueueBuilder<T, D, P2, C, HasFiles>;
|
|
669
682
|
/** Include static files in the Lambda bundle. Chainable — call multiple times. */
|
|
670
|
-
include(glob: string):
|
|
683
|
+
include(glob: string): QueueBuilder<T, D, P, C, true>;
|
|
671
684
|
/** Configure Lambda settings only (memory, timeout, permissions, etc.) */
|
|
672
|
-
setup(lambda: LambdaOptions):
|
|
685
|
+
setup(lambda: LambdaOptions): QueueBuilder<T, D, P, C, HasFiles>;
|
|
673
686
|
/** Initialize shared state on cold start. Receives deps, config, files. */
|
|
674
|
-
setup<C2>(fn: (args: SetupArgs$5<D, P, HasFiles>) => C2 | Promise<C2>):
|
|
687
|
+
setup<C2>(fn: (args: SetupArgs$5<D, P, HasFiles>) => C2 | Promise<C2>): QueueBuilder<T, D, P, C2, HasFiles>;
|
|
675
688
|
/** Initialize shared state on cold start + configure Lambda settings. */
|
|
676
|
-
setup<C2>(fn: (args: SetupArgs$5<D, P, HasFiles>) => C2 | Promise<C2>, lambda: LambdaOptions):
|
|
689
|
+
setup<C2>(fn: (args: SetupArgs$5<D, P, HasFiles>) => C2 | Promise<C2>, lambda: LambdaOptions): QueueBuilder<T, D, P, C2, HasFiles>;
|
|
690
|
+
/**
|
|
691
|
+
* Configure the event source mapping (poller) that delivers messages to the Lambda.
|
|
692
|
+
* Call before the terminal `.onMessage` / `.onMessageBatch`.
|
|
693
|
+
*/
|
|
694
|
+
poller(options: QueuePollerConfig): QueueBuilder<T, D, P, C, HasFiles>;
|
|
677
695
|
/** Handle errors thrown by message handlers */
|
|
678
696
|
onError(fn: (args: {
|
|
679
697
|
error: unknown;
|
|
680
|
-
} & SpreadCtx$5<C>) => void | Promise<void>):
|
|
698
|
+
} & SpreadCtx$5<C>) => void | Promise<void>): QueueBuilder<T, D, P, C, HasFiles>;
|
|
681
699
|
/** Cleanup callback — runs after each invocation, before Lambda freezes */
|
|
682
|
-
onCleanup(fn: (args: SpreadCtx$5<C>) => void | Promise<void>):
|
|
700
|
+
onCleanup(fn: (args: SpreadCtx$5<C>) => void | Promise<void>): QueueBuilder<T, D, P, C, HasFiles>;
|
|
683
701
|
/** Per-message handler (terminal — returns finalized handler) */
|
|
684
|
-
onMessage(fn:
|
|
702
|
+
onMessage(fn: QueueMessageFn<T, C>): QueueHandler$1<T, C>;
|
|
685
703
|
/** Batch handler (terminal — returns finalized handler) */
|
|
686
|
-
onMessageBatch(fn:
|
|
704
|
+
onMessageBatch(fn: QueueBatchFn<T, C>): QueueHandler$1<T, C>;
|
|
705
|
+
/** Finalize as a resource-only queue (no Lambda). Use when the SQS queue is consumed by an external system. */
|
|
706
|
+
build(): QueueHandler$1<T, C>;
|
|
687
707
|
}
|
|
688
708
|
/**
|
|
689
|
-
* Define
|
|
709
|
+
* Define an SQS queue with a Lambda message handler.
|
|
710
|
+
*
|
|
711
|
+
* Currently only FIFO queues are supported — pass `{ fifo: true }` explicitly
|
|
712
|
+
* (standard queue support is planned). Poller/batch settings live on the
|
|
713
|
+
* `.poller({...})` builder method; queue-level properties stay in the options
|
|
714
|
+
* object.
|
|
690
715
|
*
|
|
691
716
|
* @see {@link https://effortless-aws.website/use-cases/queue | Queue guide}
|
|
692
717
|
*
|
|
693
718
|
* @example
|
|
694
719
|
* ```typescript
|
|
695
|
-
* export const notifications =
|
|
720
|
+
* export const notifications = defineQueue<Notif>({ fifo: true })
|
|
721
|
+
* .poller({ batchSize: 5, batchWindow: "2s" })
|
|
696
722
|
* .onMessageBatch(async ({ messages }) => {
|
|
697
723
|
* await sendAll(messages.map(m => m.body));
|
|
698
724
|
* })
|
|
699
725
|
* ```
|
|
700
726
|
*/
|
|
701
|
-
declare function
|
|
702
|
-
declare function
|
|
727
|
+
declare function defineQueue<T = unknown>(): QueueBuilder<T>;
|
|
728
|
+
declare function defineQueue<T = unknown>(options: QueueOptions<T>): QueueBuilder<T>;
|
|
703
729
|
|
|
704
730
|
/** Fargate container size presets */
|
|
705
731
|
type FargateSize = "0.25vCPU-512mb" | "0.5vCPU-1gb" | "1vCPU-2gb" | "2vCPU-4gb" | "4vCPU-8gb";
|
|
@@ -978,14 +1004,32 @@ type WorkerClient<T = unknown> = {
|
|
|
978
1004
|
};
|
|
979
1005
|
|
|
980
1006
|
/** Dep value types supported by the deps declaration */
|
|
981
|
-
type AnyDepHandler = TableHandler$1<any, any> | BucketHandler$1<any, any> | MailerHandler |
|
|
1007
|
+
type AnyDepHandler = TableHandler$1<any, any> | BucketHandler$1<any, any> | MailerHandler | QueueHandler$1<any, any> | WorkerHandler$1<any, any>;
|
|
982
1008
|
/** Maps a deps declaration to resolved runtime client types */
|
|
983
1009
|
type ResolveDeps<D> = {
|
|
984
|
-
[K in keyof D]: D[K] extends TableHandler$1<infer T> ? TableClient<T> : D[K] extends BucketHandler$1<any, infer E> ? ({} extends E ? BucketClient : BucketClientWithEntities<E>) : D[K] extends MailerHandler ? EmailClient : D[K] extends
|
|
1010
|
+
[K in keyof D]: D[K] extends TableHandler$1<infer T> ? TableClient<T> : D[K] extends BucketHandler$1<any, infer E> ? ({} extends E ? BucketClient : BucketClientWithEntities<E>) : D[K] extends MailerHandler ? EmailClient : D[K] extends QueueHandler$1<infer T> ? QueueClient<T> : D[K] extends WorkerHandler$1<infer T> ? WorkerClient<T> : never;
|
|
985
1011
|
};
|
|
986
1012
|
|
|
987
1013
|
/** DynamoDB Streams view type - determines what data is captured in stream records */
|
|
988
1014
|
type StreamView = "NEW_AND_OLD_IMAGES" | "NEW_IMAGE" | "OLD_IMAGE" | "KEYS_ONLY";
|
|
1015
|
+
/**
|
|
1016
|
+
* Stream event source mapping configuration.
|
|
1017
|
+
* @internal
|
|
1018
|
+
*/
|
|
1019
|
+
type TableStreamConfig = {
|
|
1020
|
+
/** Stream view type - what data to include in stream records (default: "NEW_AND_OLD_IMAGES") */
|
|
1021
|
+
streamView?: StreamView;
|
|
1022
|
+
/** Number of records to process in each Lambda invocation (1-10000, default: 100) */
|
|
1023
|
+
batchSize?: number;
|
|
1024
|
+
/** Maximum time to gather records before invoking (default: `"2s"`). Accepts `"5s"`, `"1m"`, etc. */
|
|
1025
|
+
batchWindow?: Duration;
|
|
1026
|
+
/** Where to start reading the stream (default: "LATEST") */
|
|
1027
|
+
startingPosition?: "LATEST" | "TRIM_HORIZON";
|
|
1028
|
+
/** Number of records to process concurrently within a batch (default: 1 — sequential) */
|
|
1029
|
+
concurrency?: number;
|
|
1030
|
+
/** Max retry attempts for failed records before sending to DLQ (default: 1) */
|
|
1031
|
+
maxRetries?: number;
|
|
1032
|
+
};
|
|
989
1033
|
/**
|
|
990
1034
|
* Configuration options for defineTable (single-table design).
|
|
991
1035
|
*
|
|
@@ -1002,22 +1046,14 @@ type TableConfig = {
|
|
|
1002
1046
|
};
|
|
1003
1047
|
/** DynamoDB billing mode (default: "PAY_PER_REQUEST") */
|
|
1004
1048
|
billingMode?: "PAY_PER_REQUEST" | "PROVISIONED";
|
|
1005
|
-
/** Stream view type - what data to include in stream records (default: "NEW_AND_OLD_IMAGES") */
|
|
1006
|
-
streamView?: StreamView;
|
|
1007
|
-
/** Number of records to process in each Lambda invocation (1-10000, default: 100) */
|
|
1008
|
-
batchSize?: number;
|
|
1009
|
-
/** Maximum time to gather records before invoking (default: `"2s"`). Accepts `"5s"`, `"1m"`, etc. */
|
|
1010
|
-
batchWindow?: Duration;
|
|
1011
|
-
/** Where to start reading the stream (default: "LATEST") */
|
|
1012
|
-
startingPosition?: "LATEST" | "TRIM_HORIZON";
|
|
1013
|
-
/** Number of records to process concurrently within a batch (default: 1 — sequential) */
|
|
1014
|
-
concurrency?: number;
|
|
1015
1049
|
/**
|
|
1016
1050
|
* Name of the field in `data` that serves as the entity type discriminant.
|
|
1017
1051
|
* Effortless auto-copies `data[tagField]` to the top-level DynamoDB `tag` attribute on `put()`.
|
|
1018
1052
|
* Defaults to `"tag"`.
|
|
1019
1053
|
*/
|
|
1020
1054
|
tagField?: string;
|
|
1055
|
+
/** Stream event source mapping config — set via `.stream({...})` builder method. */
|
|
1056
|
+
stream?: TableStreamConfig;
|
|
1021
1057
|
};
|
|
1022
1058
|
/**
|
|
1023
1059
|
* DynamoDB stream record passed to onRecord callback.
|
|
@@ -1092,44 +1128,36 @@ type TableHandler$1<T = Record<string, unknown>, C = any> = {
|
|
|
1092
1128
|
readonly onRecord?: (...args: any[]) => any;
|
|
1093
1129
|
readonly onRecordBatch?: (...args: any[]) => any;
|
|
1094
1130
|
};
|
|
1095
|
-
/** Options passed to `defineTable()` — resource config only
|
|
1131
|
+
/** Options passed to `defineTable()` — resource config only. Stream options go in `.stream({...})`. */
|
|
1096
1132
|
type TableOptions<T> = {
|
|
1097
1133
|
/** DynamoDB billing mode (default: "PAY_PER_REQUEST") */
|
|
1098
1134
|
billingMode?: "PAY_PER_REQUEST" | "PROVISIONED";
|
|
1099
|
-
/** Stream view type (default: "NEW_AND_OLD_IMAGES") */
|
|
1100
|
-
streamView?: StreamView;
|
|
1101
|
-
/** Number of records to process in each Lambda invocation (1-10000, default: 100) */
|
|
1102
|
-
batchSize?: number;
|
|
1103
|
-
/** Maximum time to gather records before invoking (default: "2s") */
|
|
1104
|
-
batchWindow?: Duration;
|
|
1105
|
-
/** Where to start reading the stream (default: "LATEST") */
|
|
1106
|
-
startingPosition?: "LATEST" | "TRIM_HORIZON";
|
|
1107
|
-
/** Number of records to process concurrently within a batch (default: 1) */
|
|
1108
|
-
concurrency?: number;
|
|
1109
1135
|
/** Name of the field in `data` that serves as the entity type discriminant (default: "tag") */
|
|
1110
1136
|
tagField?: Extract<keyof T, string>;
|
|
1111
1137
|
/** Decode/validate function for the `data` portion of stream records */
|
|
1112
1138
|
schema?: (input: unknown) => T;
|
|
1113
1139
|
};
|
|
1114
|
-
interface TableBuilder<T = Record<string, unknown>, D = undefined, P = undefined, C = undefined, HasFiles extends boolean = false> {
|
|
1140
|
+
interface TableBuilder<T = Record<string, unknown>, D = undefined, P = undefined, C = undefined, HasFiles extends boolean = false, HasStream extends boolean = false> {
|
|
1115
1141
|
/** Declare handler dependencies (tables, queues, buckets, mailers) */
|
|
1116
|
-
deps<D2 extends Record<string, AnyDepHandler>>(fn: () => D2): TableBuilder<T, D2, P, C, HasFiles>;
|
|
1142
|
+
deps<D2 extends Record<string, AnyDepHandler>>(fn: () => D2): TableBuilder<T, D2, P, C, HasFiles, HasStream>;
|
|
1117
1143
|
/** Declare SSM secrets */
|
|
1118
|
-
config<P2 extends Record<string, AnySecretRef>>(fn: ConfigFactory<P2>): TableBuilder<T, D, P2, C, HasFiles>;
|
|
1144
|
+
config<P2 extends Record<string, AnySecretRef>>(fn: ConfigFactory<P2>): TableBuilder<T, D, P2, C, HasFiles, HasStream>;
|
|
1119
1145
|
/** Include static files in the Lambda bundle. Chainable — call multiple times. */
|
|
1120
|
-
include(glob: string): TableBuilder<T, D, P, C, true>;
|
|
1146
|
+
include(glob: string): TableBuilder<T, D, P, C, true, HasStream>;
|
|
1147
|
+
/** Configure the DynamoDB stream event source mapping (batch size, retries, concurrency, etc.). */
|
|
1148
|
+
stream: HasStream extends true ? never : (opts: TableStreamConfig) => TableBuilder<T, D, P, C, HasFiles, true>;
|
|
1121
1149
|
/** Configure Lambda settings only (memory, timeout, permissions, etc.) */
|
|
1122
|
-
setup(lambda: LambdaOptions): TableBuilder<T, D, P, C, HasFiles>;
|
|
1150
|
+
setup(lambda: LambdaOptions): TableBuilder<T, D, P, C, HasFiles, HasStream>;
|
|
1123
1151
|
/** Initialize shared state on cold start. Receives table (self-client), deps, config, files. */
|
|
1124
|
-
setup<C2>(fn: (args: SetupArgs$3<T, D, P, HasFiles>) => C2 | Promise<C2>): TableBuilder<T, D, P, C2, HasFiles>;
|
|
1152
|
+
setup<C2>(fn: (args: SetupArgs$3<T, D, P, HasFiles>) => C2 | Promise<C2>): TableBuilder<T, D, P, C2, HasFiles, HasStream>;
|
|
1125
1153
|
/** Initialize shared state on cold start + configure Lambda settings. */
|
|
1126
|
-
setup<C2>(fn: (args: SetupArgs$3<T, D, P, HasFiles>) => C2 | Promise<C2>, lambda: LambdaOptions): TableBuilder<T, D, P, C2, HasFiles>;
|
|
1154
|
+
setup<C2>(fn: (args: SetupArgs$3<T, D, P, HasFiles>) => C2 | Promise<C2>, lambda: LambdaOptions): TableBuilder<T, D, P, C2, HasFiles, HasStream>;
|
|
1127
1155
|
/** Handle errors thrown by onRecord/onRecordBatch */
|
|
1128
1156
|
onError(fn: (args: {
|
|
1129
1157
|
error: unknown;
|
|
1130
|
-
} & SpreadCtx$3<C>) => void | Promise<void>): TableBuilder<T, D, P, C, HasFiles>;
|
|
1158
|
+
} & SpreadCtx$3<C>) => void | Promise<void>): TableBuilder<T, D, P, C, HasFiles, HasStream>;
|
|
1131
1159
|
/** Cleanup callback — runs after each invocation, before Lambda freezes */
|
|
1132
|
-
onCleanup(fn: (args: SpreadCtx$3<C>) => void | Promise<void>): TableBuilder<T, D, P, C, HasFiles>;
|
|
1160
|
+
onCleanup(fn: (args: SpreadCtx$3<C>) => void | Promise<void>): TableBuilder<T, D, P, C, HasFiles, HasStream>;
|
|
1133
1161
|
/** Per-record stream handler (terminal — returns finalized handler) */
|
|
1134
1162
|
onRecord(fn: TableRecordFn<T, C>): TableHandler$1<T, C>;
|
|
1135
1163
|
/** Batch stream handler (terminal — returns finalized handler) */
|
|
@@ -1147,7 +1175,8 @@ interface TableBuilder<T = Record<string, unknown>, D = undefined, P = undefined
|
|
|
1147
1175
|
*
|
|
1148
1176
|
* @example
|
|
1149
1177
|
* ```typescript
|
|
1150
|
-
* export const orders = defineTable<OrderData>(
|
|
1178
|
+
* export const orders = defineTable<OrderData>()
|
|
1179
|
+
* .stream({ batchSize: 10, concurrency: 5, maxRetries: 3 })
|
|
1151
1180
|
* .setup(({ table }) => ({ table }))
|
|
1152
1181
|
* .onRecord(async ({ record, table }) => {
|
|
1153
1182
|
* if (record.eventName === "INSERT") {
|
|
@@ -1904,10 +1933,10 @@ type McpResourceMap = McpResourceMap$1;
|
|
|
1904
1933
|
type McpPromptDef = McpPromptDef$1;
|
|
1905
1934
|
|
|
1906
1935
|
type TableHandler<T = Record<string, unknown>> = TableHandler$1<T, any>;
|
|
1907
|
-
type
|
|
1936
|
+
type QueueHandler<T = unknown> = QueueHandler$1<T, any>;
|
|
1908
1937
|
type BucketHandler<Entities extends Record<string, any> = {}> = BucketHandler$1<any, Entities>;
|
|
1909
1938
|
type CronHandler = CronHandler$1<any>;
|
|
1910
1939
|
type WorkerHandler<T = any> = WorkerHandler$1<T, any>;
|
|
1911
1940
|
type McpHandler = McpHandler$1<any>;
|
|
1912
1941
|
|
|
1913
|
-
export { type ApiConfig, type ApiHandler, type ApiRoutes, type AppConfig, type AppHandler, type AuthHelpers, type AuthOptions, type BucketClient, type BucketClientWithEntities, type BucketConfig, type BucketEntityConfig, type BucketEvent, type BucketHandler, type CacheOptions, type CdnPolicyOptions, type ConfigHelpers, type ContentType, type CronConfig, type CronHandler, type DefineSecretFn, type Duration, type EffortlessConfig, type EmailClient, type
|
|
1942
|
+
export { type ApiConfig, type ApiHandler, type ApiRoutes, type AppConfig, type AppHandler, type AuthHelpers, type AuthOptions, type BucketClient, type BucketClientWithEntities, type BucketConfig, type BucketEntityConfig, type BucketEvent, type BucketHandler, type CacheOptions, type CdnPolicyOptions, type ConfigHelpers, type ContentType, type CronConfig, type CronHandler, type DefineSecretFn, type Duration, type EffortlessConfig, type EmailClient, type HttpMethod$1 as HttpMethod, type HttpRequest, type HttpResponse, type LogLevel, type MailerConfig, type MailerHandler, type McpConfig, type McpEntries, type McpHandler, type McpInputSchema, type McpPromptArgument, type McpPromptContent, type McpPromptDef, type McpPromptMessage, type McpPromptResult, type McpResourceContent, type McpResourceDef, type McpResourceMap, type McpResourceTemplateDef, type McpToolContent, type McpToolDef, type McpToolResult, type MiddlewareDeny, type MiddlewareHandler, type MiddlewareRedirect, type MiddlewareRequest, type MiddlewareResult, type ParamRef, type Permission, type PutInput, type PutOptions, type QueryByTagParams, type QueryParams, type QueueClient, type QueueConfig, type QueueHandler, type QueueMessage, type QueuePollerConfig, type ResponseStream, type SecretRef, type SendEmailOptions, type SendMessageInput, type SkCondition, type StaticFiles, type StaticSiteConfig, type StaticSiteHandler, type StaticSiteSeo, type StoreEntityClient, type StreamView, type TableClient, type TableConfig, type TableHandler, type TableItem, type TableKey, type TableRecord, type Timezone, type UpdateActions, type WorkerClient, type WorkerConfig, type WorkerHandler, type WorkerSendOptions, defineApi, defineApp, defineBucket, defineConfig, defineCron, defineMailer, defineMcp, defineQueue, defineSecret, defineStaticSite, defineTable, defineWorker, generateBase64, generateHex, generateUuid, param, secret, toSeconds };
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,10 @@ function defineTable(options) {
|
|
|
77
77
|
state.static = [...state.static ?? [], glob];
|
|
78
78
|
return builder;
|
|
79
79
|
},
|
|
80
|
+
stream(opts) {
|
|
81
|
+
state.spec = { ...state.spec, stream: { ...state.spec.stream, ...opts } };
|
|
82
|
+
return builder;
|
|
83
|
+
},
|
|
80
84
|
setup(fnOrLambda, maybeLambda) {
|
|
81
85
|
if (typeof fnOrLambda === "function") {
|
|
82
86
|
state.setup = fnOrLambda;
|
|
@@ -143,8 +147,8 @@ function defineStaticSite(options) {
|
|
|
143
147
|
return builder;
|
|
144
148
|
}
|
|
145
149
|
|
|
146
|
-
// src/handlers/define-
|
|
147
|
-
function
|
|
150
|
+
// src/handlers/define-queue.ts
|
|
151
|
+
function defineQueue(options) {
|
|
148
152
|
const {
|
|
149
153
|
schema,
|
|
150
154
|
...queueConfig
|
|
@@ -160,7 +164,7 @@ function defineFifoQueue(options) {
|
|
|
160
164
|
}
|
|
161
165
|
};
|
|
162
166
|
const finalize = () => ({
|
|
163
|
-
__brand: "effortless-
|
|
167
|
+
__brand: "effortless-queue",
|
|
164
168
|
__spec: state.spec,
|
|
165
169
|
...state.schema ? { schema: state.schema } : {},
|
|
166
170
|
...state.onError ? { onError: state.onError } : {},
|
|
@@ -194,6 +198,12 @@ function defineFifoQueue(options) {
|
|
|
194
198
|
}
|
|
195
199
|
return builder;
|
|
196
200
|
},
|
|
201
|
+
poller(options2) {
|
|
202
|
+
if (Object.keys(options2).length > 0) {
|
|
203
|
+
state.spec = { ...state.spec, poller: { ...state.spec.poller, ...options2 } };
|
|
204
|
+
}
|
|
205
|
+
return builder;
|
|
206
|
+
},
|
|
197
207
|
onMessage(fn) {
|
|
198
208
|
state.onMessage = fn;
|
|
199
209
|
return finalize();
|
|
@@ -209,6 +219,9 @@ function defineFifoQueue(options) {
|
|
|
209
219
|
onCleanup(fn) {
|
|
210
220
|
state.onCleanup = fn;
|
|
211
221
|
return builder;
|
|
222
|
+
},
|
|
223
|
+
build() {
|
|
224
|
+
return finalize();
|
|
212
225
|
}
|
|
213
226
|
};
|
|
214
227
|
return builder;
|
|
@@ -658,9 +671,9 @@ export {
|
|
|
658
671
|
defineBucket,
|
|
659
672
|
defineConfig,
|
|
660
673
|
defineCron,
|
|
661
|
-
defineFifoQueue,
|
|
662
674
|
defineMailer,
|
|
663
675
|
defineMcp,
|
|
676
|
+
defineQueue,
|
|
664
677
|
defineSecret,
|
|
665
678
|
defineStaticSite,
|
|
666
679
|
defineTable,
|