UNPKG

@scaffoldly/serverless-util

Version:
35 lines 1.67 kB
import { Model } from '@scaffoldly/dynamodb'; import Joi from 'joi'; import { AttributeValue, DynamoDBRecord, StreamRecord } from 'aws-lambda'; export interface TableIndex { hashKey: string; rangeKey?: string; name: string; type: 'local' | 'global'; } export declare class Table<T> { readonly model: Model<T>; private tableSuffix; readonly tableName: string; private serviceName; private stage; constructor(tableSuffix: string | undefined, serviceName: string | undefined, stage: string | undefined, schema: { [key: string]: Joi.AnySchema; }, hashKey: string, rangeKey?: string, indexes?: TableIndex[]); matches(fullTableName: string): boolean; } export declare const dynamoDBStreamEventExtractTableName: (eventSourceARN: string) => string | undefined; export declare const unmarshallDynamoDBImage: <T>(image?: { [key: string]: AttributeValue; } | undefined, options?: import("aws-sdk/clients/dynamodb").DocumentClient.ConverterOptions | undefined) => T; export declare type HandleFn = (record: StreamRecord) => boolean; export declare type StreamRecordHandlers<T, K = T> = { canHandle: HandleFn; onInsert?: (t: T) => Promise<T | K | null>; onModify?: (newT: T, oldT: T) => Promise<T | K | null>; onRemove?: (t: T) => Promise<T | K | null>; }; export declare const handleDynamoDBStreamRecord: <T, K = T>(record: DynamoDBRecord, handlers: StreamRecordHandlers<T, K>) => Promise<T | K | null>; declare const stringToId: <Version extends string, Namespace extends string>(value: string, version: Version, namespace: Namespace) => string; export { Model, stringToId }; //# sourceMappingURL=db.d.ts.map