dyno-table 1.3.0 → 1.4.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.
Files changed (66) hide show
  1. package/README.md +3 -6
  2. package/dist/{builder-types-C_PDZhnP.d.ts → builder-types-B_tCpn9F.d.ts} +2 -1
  3. package/dist/{builder-types-DtwbqMeF.d.cts → builder-types-DlaUSc-b.d.cts} +2 -1
  4. package/dist/builders/condition-check-builder.cjs +22 -0
  5. package/dist/builders/condition-check-builder.cjs.map +1 -1
  6. package/dist/builders/condition-check-builder.d.cts +2 -2
  7. package/dist/builders/condition-check-builder.d.ts +2 -2
  8. package/dist/builders/condition-check-builder.js +22 -0
  9. package/dist/builders/condition-check-builder.js.map +1 -1
  10. package/dist/builders/delete-builder.cjs +22 -0
  11. package/dist/builders/delete-builder.cjs.map +1 -1
  12. package/dist/builders/delete-builder.d.cts +2 -2
  13. package/dist/builders/delete-builder.d.ts +2 -2
  14. package/dist/builders/delete-builder.js +22 -0
  15. package/dist/builders/delete-builder.js.map +1 -1
  16. package/dist/builders/paginator.d.cts +1 -1
  17. package/dist/builders/paginator.d.ts +1 -1
  18. package/dist/builders/put-builder.cjs +30 -2
  19. package/dist/builders/put-builder.cjs.map +1 -1
  20. package/dist/builders/put-builder.d.cts +14 -7
  21. package/dist/builders/put-builder.d.ts +14 -7
  22. package/dist/builders/put-builder.js +30 -2
  23. package/dist/builders/put-builder.js.map +1 -1
  24. package/dist/builders/query-builder.cjs +6 -0
  25. package/dist/builders/query-builder.cjs.map +1 -1
  26. package/dist/builders/query-builder.d.cts +3 -3
  27. package/dist/builders/query-builder.d.ts +3 -3
  28. package/dist/builders/query-builder.js +6 -0
  29. package/dist/builders/query-builder.js.map +1 -1
  30. package/dist/builders/transaction-builder.cjs +16 -0
  31. package/dist/builders/transaction-builder.cjs.map +1 -1
  32. package/dist/builders/transaction-builder.d.cts +2 -2
  33. package/dist/builders/transaction-builder.d.ts +2 -2
  34. package/dist/builders/transaction-builder.js +16 -0
  35. package/dist/builders/transaction-builder.js.map +1 -1
  36. package/dist/builders/update-builder.cjs +22 -0
  37. package/dist/builders/update-builder.cjs.map +1 -1
  38. package/dist/builders/update-builder.d.cts +2 -2
  39. package/dist/builders/update-builder.d.ts +2 -2
  40. package/dist/builders/update-builder.js +22 -0
  41. package/dist/builders/update-builder.js.map +1 -1
  42. package/dist/conditions-BIpBkh4m.d.ts +729 -0
  43. package/dist/conditions-x6kGWMR7.d.cts +729 -0
  44. package/dist/conditions.cjs +6 -0
  45. package/dist/conditions.cjs.map +1 -1
  46. package/dist/conditions.d.cts +1 -1
  47. package/dist/conditions.d.ts +1 -1
  48. package/dist/conditions.js +6 -1
  49. package/dist/conditions.js.map +1 -1
  50. package/dist/entity.cjs.map +1 -1
  51. package/dist/entity.d.cts +4 -4
  52. package/dist/entity.d.ts +4 -4
  53. package/dist/entity.js.map +1 -1
  54. package/dist/{query-builder-D2FM9rsu.d.cts → query-builder-Dg9Loeco.d.cts} +2 -2
  55. package/dist/{query-builder-Csror9Iu.d.ts → query-builder-H9Dn0qaS.d.ts} +2 -2
  56. package/dist/{table-CM56NptV.d.cts → table-CmIQe-jD.d.cts} +30 -5
  57. package/dist/{table-B3fvMnkB.d.ts → table-TI4ULfra.d.ts} +30 -5
  58. package/dist/table.cjs +68 -8
  59. package/dist/table.cjs.map +1 -1
  60. package/dist/table.d.cts +4 -4
  61. package/dist/table.d.ts +4 -4
  62. package/dist/table.js +68 -8
  63. package/dist/table.js.map +1 -1
  64. package/package.json +1 -1
  65. package/dist/conditions--ld9a78i.d.ts +0 -331
  66. package/dist/conditions-ChhQWd6z.d.cts +0 -331
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/conditions.ts","../src/entity.ts"],"names":["primaryKey","key"],"mappings":";AA+FO,IAAM,yBACX,GAAA,CAAC,IACD,KAAA,CAAC,MAAc,KAA+B,MAAA;AAAA,EAC5C,IAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAA,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,MAAS,GAAA,MAAA;AACjB,QAAO,OAAA,OAAA;AAAA;AACT,KACF;AAAA,GACF;AACF;AAOO,SAAS,WAAc,GAAA;AAC5B,EAAO,OAAA;AAAA,IACL,KAAA,EAAO,CAAuB,MAAiC,MAAA;AAAA,MAC7D,YAAA,EAAc,CAAgC,IAAa,MAAA;AAAA,QACzD,OAAA,EAAS,CAAgC,IACtC,MAAA;AAAA,UACC,IAAM,EAAA,QAAA;AAAA,UACN,YAAc,EAAA,IAAA;AAAA,UACd,OAAS,EAAA,IAAA;AAAA,UACT,WAAA,EAAa,CAAC,IAAA,MAAa,EAAE,EAAA,EAAI,IAAK,CAAA,IAAI,CAAG,EAAA,EAAA,EAAI,IAAK,CAAA,IAAI,CAAE,EAAA;AAAA,SAC9D,CAAA;AAAA,QAEF,gBAAgB,OACb;AAAA,UACC,IAAM,EAAA,QAAA;AAAA,UACN,YAAc,EAAA,IAAA;AAAA,UACd,aAAa,CAAC,IAAA,MAAa,EAAE,EAAI,EAAA,IAAA,CAAK,IAAI,CAAE,EAAA;AAAA,SAC9C;AAAA,OACJ;AAAA,KACF;AAAA,GACF;AACF","file":"entity.js","sourcesContent":["import type { Path, PathType } from \"./builders/types\";\nimport type { DynamoItem } from \"./types\";\n\n/**\n * Supported comparison operators for DynamoDB conditions.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html AWS DynamoDB - Comparison Operator Reference}\n *\n * - eq: Equals (=)\n * - ne: Not equals (≠ / <>)\n * - lt: Less than (<)\n * - lte: Less than or equal to (≤)\n * - gt: Greater than (>)\n * - gte: Greater than or equal to (≥)\n * - between: Between two values (inclusive)\n * - beginsWith: Checks if string attribute begins with specified substring\n * - contains: Checks if string/set attribute contains specified value\n * - attributeExists: Checks if attribute exists\n * - attributeNotExists: Checks if attribute does not exist\n */\nexport type ComparisonOperator =\n | \"eq\"\n | \"ne\"\n | \"lt\"\n | \"lte\"\n | \"gt\"\n | \"gte\"\n | \"between\"\n | \"beginsWith\"\n | \"contains\"\n | \"attributeExists\"\n | \"attributeNotExists\";\n\n/**\n * Logical operators for combining multiple conditions.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - Logical Operator Reference}\n *\n * - and: Evaluates to true if all conditions are true\n * - or: Evaluates to true if any condition is true\n * - not: Negate the result of a condition\n */\nexport type LogicalOperator = \"and\" | \"or\" | \"not\";\n\n/**\n * Represents a DynamoDB condition expression.\n * Can be either a comparison condition or a logical combination of conditions.\n *\n * @example\n * // Simple comparison condition\n * const condition: Condition = {\n * type: \"eq\",\n * attr: \"status\",\n * value: \"ACTIVE\"\n * };\n *\n * @example\n * // Logical combination of conditions\n * const condition: Condition = {\n * type: \"and\",\n * conditions: [\n * { type: \"eq\", attr: \"status\", value: \"ACTIVE\" },\n * { type: \"gt\", attr: \"age\", value: 5 }\n * ]\n * };\n */\nexport interface Condition {\n /** The type of condition (comparison or logical operator) */\n type: ComparisonOperator | LogicalOperator;\n /** The attribute name for comparison conditions */\n attr?: string;\n /** The value to compare against for comparison conditions */\n value?: unknown;\n /** Array of conditions for logical operators (and/or) */\n conditions?: Condition[];\n /** Single condition for the 'not' operator */\n condition?: Condition;\n}\n\n/**\n * Parameters used to build DynamoDB expression strings.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html Expression Attribute Names}\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeValues.html Expression Attribute Values}\n */\nexport interface ExpressionParams {\n /** Map of attribute name placeholders to actual attribute names */\n expressionAttributeNames: Record<string, string>;\n /** Map of value placeholders to actual values */\n expressionAttributeValues: DynamoItem;\n /** Counter for generating unique value placeholders */\n valueCounter: { count: number };\n}\n\n/**\n * Creates a comparison condition builder function for the specified operator.\n * @internal\n */\nexport const createComparisonCondition =\n (type: ComparisonOperator) =>\n (attr: string, value: unknown): Condition => ({\n type,\n attr,\n value,\n });\n\n/**\n * Creates an equals (=) condition\n * @example\n * eq(\"status\", \"ACTIVE\") // status = \"ACTIVE\"\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const eq = createComparisonCondition(\"eq\");\n\n/**\n * Creates a not equals (≠) condition\n * @example\n * ne(\"status\", \"DELETED\") // status <> \"DELETED\"\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const ne = createComparisonCondition(\"ne\");\n\n/**\n * Creates a less than (<) condition\n * @example\n * lt(\"age\", 18) // age < 18\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const lt = createComparisonCondition(\"lt\");\n\n/**\n * Creates a less than or equal to (≤) condition\n * @example\n * lte(\"age\", 18) // age <= 18\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const lte = createComparisonCondition(\"lte\");\n\n/**\n * Creates a greater than (>) condition\n * @example\n * gt(\"price\", 100) // price > 100\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const gt = createComparisonCondition(\"gt\");\n\n/**\n * Creates a greater than or equal to (≥) condition\n * @example\n * gte(\"price\", 100) // price >= 100\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const gte = createComparisonCondition(\"gte\");\n\n/**\n * Creates a between condition that checks if a value is within a range (inclusive)\n * @example\n * between(\"age\", 18, 65) // age BETWEEN 18 AND 65\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - BETWEEN}\n */\nexport const between = (attr: string, lower: unknown, upper: unknown): Condition => ({\n type: \"between\",\n attr,\n value: [lower, upper],\n});\n\n/**\n * Creates a begins_with condition that checks if a string attribute starts with a substring\n * @example\n * beginsWith(\"email\", \"@example.com\") // begins_with(email, \"@example.com\")\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - begins_with}\n */\nexport const beginsWith = createComparisonCondition(\"beginsWith\");\n\n/**\n * Creates a contains condition that checks if a string contains a substring or if a set contains an element\n * @example\n * contains(\"tags\", \"important\") // contains(tags, \"important\")\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - contains}\n */\nexport const contains = createComparisonCondition(\"contains\");\n\n/**\n * Creates a condition that checks if an attribute exists\n * @example\n * attributeExists(\"email\") // attribute_exists(email)\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - attribute_exists}\n */\nexport const attributeExists = (attr: string): Condition => ({\n type: \"attributeExists\",\n attr,\n});\n\n/**\n * Creates a condition that checks if an attribute does not exist\n * @example\n * attributeNotExists(\"deletedAt\") // attribute_not_exists(deletedAt)\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - attribute_not_exists}\n */\nexport const attributeNotExists = (attr: string): Condition => ({\n type: \"attributeNotExists\",\n attr,\n});\n\n// --- Logical Operators ---\n\n/**\n * Combines multiple conditions with AND operator\n * @example\n * and(\n * eq(\"status\", \"ACTIVE\"),\n * gt(\"age\", 18)\n * ) // status = \"ACTIVE\" AND age > 18\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - AND}\n */\nexport const and = (...conditions: Condition[]): Condition => ({\n type: \"and\",\n conditions,\n});\n\n/**\n * Combines multiple conditions with OR operator\n * @example\n * or(\n * eq(\"status\", \"PENDING\"),\n * eq(\"status\", \"PROCESSING\")\n * ) // status = \"PENDING\" OR status = \"PROCESSING\"\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - OR}\n */\nexport const or = (...conditions: Condition[]): Condition => ({\n type: \"or\",\n conditions,\n});\n\n/**\n * Negates a condition\n * @example\n * not(eq(\"status\", \"DELETED\")) // NOT status = \"DELETED\"\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - NOT}\n */\nexport const not = (condition: Condition): Condition => ({\n type: \"not\",\n condition,\n});\n\n/**\n * Type-safe operators for building key conditions in DynamoDB queries.\n * Only includes operators that are valid for key conditions.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.KeyConditionExpressions AWS DynamoDB - Key Condition Expressions}\n *\n * @example\n * // Using with sort key conditions\n * table.query({\n * pk: \"USER#123\",\n * sk: op => op.beginsWith(\"ORDER#\")\n * })\n */\nexport type KeyConditionOperator = {\n /** Equals comparison for key attributes */\n eq: (value: unknown) => Condition;\n /** Less than comparison for key attributes */\n lt: (value: unknown) => Condition;\n /** Less than or equal comparison for key attributes */\n lte: (value: unknown) => Condition;\n /** Greater than comparison for key attributes */\n gt: (value: unknown) => Condition;\n /** Greater than or equal comparison for key attributes */\n gte: (value: unknown) => Condition;\n /** Between range comparison for key attributes */\n between: (lower: unknown, upper: unknown) => Condition;\n /** Begins with comparison for key attributes */\n beginsWith: (value: unknown) => Condition;\n /** Combines multiple key conditions with AND */\n and: (...conditions: Condition[]) => Condition;\n};\n\n/**\n * Type-safe operators for building conditions in DynamoDB operations.\n * Includes all available condition operators with proper type inference.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html AWS DynamoDB - Condition Expressions}\n *\n * @example\n * // Using with type-safe conditions\n * interface User {\n * status: string;\n * age: number;\n * email?: string;\n * }\n *\n * table.scan<User>()\n * .where(op => op.and(\n * op.eq(\"status\", \"ACTIVE\"),\n * op.gt(\"age\", 18),\n * op.attributeExists(\"email\")\n * ))\n *\n * @template T The type of the item being operated on\n */\nexport type ConditionOperator<T extends DynamoItem> = {\n eq: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n ne: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n lt: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n lte: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n gt: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n gte: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n between: <K extends Path<T>>(attr: K, lower: PathType<T, K>, upper: PathType<T, K>) => Condition;\n beginsWith: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n contains: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n attributeExists: <K extends Path<T>>(attr: K) => Condition;\n attributeNotExists: <K extends Path<T>>(attr: K) => Condition;\n and: (...conditions: Condition[]) => Condition;\n or: (...conditions: Condition[]) => Condition;\n not: (condition: Condition) => Condition;\n};\n\n/**\n * Primary key type for QUERY operations.\n * Allows building complex key conditions for the sort key.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html AWS DynamoDB - Query Operations}\n *\n * @example\n * // Query items with a specific partition key and sort key prefix\n * table.query({\n * pk: \"USER#123\",\n * sk: op => op.beginsWith(\"ORDER#2023\")\n * })\n *\n * @example\n * // Query items within a specific sort key range\n * table.query({\n * pk: \"USER#123\",\n * sk: op => op.between(\"ORDER#2023-01\", \"ORDER#2023-12\")\n * })\n */\nexport type PrimaryKey = {\n /** Partition key value */\n pk: string;\n /** Optional sort key condition builder */\n sk?: (op: KeyConditionOperator) => Condition;\n};\n\n/**\n * Primary key type for GET and DELETE operations.\n * Used when you need to specify exact key values without conditions.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html AWS DynamoDB - Working with Items}\n *\n * @example\n * // Get a specific item by its complete primary key\n * table.get({\n * pk: \"USER#123\",\n * sk: \"PROFILE#123\"\n * })\n *\n * @example\n * // Delete a specific item by its complete primary key\n * table.delete({\n * pk: \"USER#123\",\n * sk: \"ORDER#456\"\n * })\n */\nexport type PrimaryKeyWithoutExpression = {\n /** Partition key value */\n pk: string;\n /** Optional sort key value */\n sk?: string;\n};\n","import type { DeleteBuilder } from \"./builders/delete-builder\";\nimport type { GetBuilder } from \"./builders/get-builder\";\nimport type { PutBuilder } from \"./builders/put-builder\";\nimport type { ScanBuilder } from \"./builders/scan-builder\";\nimport type { UpdateBuilder } from \"./builders/update-builder\";\nimport type { StandardSchemaV1 } from \"./standard-schema\";\nimport type { Table } from \"./table\";\nimport type { DynamoItem, Index, TableConfig } from \"./types\";\nimport { eq, type PrimaryKey, type PrimaryKeyWithoutExpression } from \"./conditions\";\nimport type { QueryBuilder } from \"./builders/query-builder\";\nimport type { TransactionBuilder } from \"./builders/transaction-builder\";\n\n// Define the QueryFunction type with a generic return type\nexport type QueryFunction<T extends DynamoItem, I, R> = (input: I) => R;\n\n// Define a type for the query record that preserves the input type for each query function\nexport type QueryFunctionWithSchema<T extends DynamoItem, I, R> = QueryFunction<T, I, R> & {\n schema?: StandardSchemaV1<I>;\n};\n\nexport type QueryRecord<T extends DynamoItem> = {\n // biome-ignore lint/suspicious/noExplicitAny: This is for flexibility\n [K: string]: QueryFunctionWithSchema<T, any, ScanBuilder<T> | QueryBuilder<T, TableConfig> | GetBuilder<T>>;\n};\n\n// Define a type for entity with only scan, get and query methods\nexport type QueryEntity<T extends DynamoItem> = {\n scan: () => ScanBuilder<T>;\n get: (key: PrimaryKeyWithoutExpression) => GetBuilder<T>;\n query: (keyCondition: PrimaryKey) => QueryBuilder<T, TableConfig>;\n};\n\ninterface Settings {\n /**\n * Defaults to \"entityType\"\n */\n entityTypeAttributeName?: string;\n timestamps?: {\n createdAt?: {\n /**\n * ISO vs Unix trade-offs\n *\n * Both options support between, greater than and less than comparisons.\n *\n * ISO:\n * - Human readable, but requires more storage space\n * - Does not work with DynamoDBs TTL feature.\n *\n * UNIX:\n * - Less readable, but requires less storage space.\n * - Works with DynamoDBs TTL feature.\n */\n format: \"ISO\" | \"UNIX\";\n /**\n * Defaults to \"createdAt\"\n */\n attributeName?: string;\n };\n updatedAt?: {\n /**\n * ISO vs Unix trade-offs\n *\n * Both options support between, greater than and less than comparisons.\n *\n * ISO:\n * - Human readable, but requires more storage space\n * - Does not work with DynamoDBs TTL feature.\n *\n * UNIX:\n * - Less readable, but requires less storage space.\n * - Works with DynamoDBs TTL feature.\n */\n format: \"ISO\" | \"UNIX\";\n /**\n * Defaults to \"updatedAt\"\n */\n attributeName?: string;\n };\n };\n}\n\nexport interface EntityConfig<\n T extends DynamoItem,\n I extends DynamoItem = T,\n Q extends QueryRecord<T> = QueryRecord<T>,\n> {\n name: string;\n schema: StandardSchemaV1<T>;\n primaryKey: IndexDefinition<I>;\n indexes?: Record<string, Index>;\n queries: Q;\n settings?: Settings;\n}\n\nexport interface EntityRepository<\n /**\n * The Entity Type\n */\n T extends DynamoItem,\n /**\n * The Primary Index (Partition index) Type\n */\n I extends DynamoItem = T,\n /**\n * The Queries object\n */\n Q extends QueryRecord<T> = QueryRecord<T>,\n> {\n create: (data: T) => PutBuilder<T>;\n upsert: (data: T & I) => PutBuilder<T>;\n get: (key: I) => GetBuilder<T>;\n update: (key: I, data: Partial<T>) => UpdateBuilder<T>;\n delete: (key: I) => DeleteBuilder;\n query: Q;\n scan: () => ScanBuilder<T>;\n}\n\n/**\n * Creates an entity definition with type-safe operations\n *\n * @example\n * ```typescript\n * interface User {\n * id: string;\n * name: string;\n * }\n *\n * const UserEntity = defineEntity<User>({\n * name: \"User\",\n * schema: userSchema,\n * primaryKey: primaryKey,\n * });\n * ```\n */\nexport function defineEntity<T extends DynamoItem, I extends DynamoItem = T, Q extends QueryRecord<T> = QueryRecord<T>>(\n config: EntityConfig<T, I, Q>,\n) {\n const entityTypeAttributeName = config.settings?.entityTypeAttributeName ?? \"entityType\";\n\n /**\n * Generates an object containing timestamp attributes based on the given configuration settings.\n * The function determines the presence and format of \"createdAt\" and \"updatedAt\" timestamps dynamically.\n *\n * @param {Array<\"createdAt\" | \"updatedAt\">} [timestampTypes] - Optional array of timestamp types to generate. If not provided, all configured timestamps will be generated.\n * @returns {Record<string, string | number>} An object containing one or both of the \"createdAt\" and \"updatedAt\" timestamp attributes, depending on the configuration and requested types. Each timestamp can be formatted as either an ISO string or a UNIX timestamp.\n *\n * @throws Will not throw errors but depends on `config.settings?.timestamps` to be properly defined.\n * - If `createdAt` is configured, the function adds a timestamp using the attribute name specified in `config.settings.timestamps.createdAt.attributeName` or defaults to \"createdAt\".\n * - If `updatedAt` is configured, the function adds a timestamp using the attribute name specified in `config.settings.timestamps.updatedAt.attributeName` or defaults to \"updatedAt\".\n *\n * Configuration Details:\n * - `config.settings.timestamps.createdAt.format`: Determines the format of the \"createdAt\" timestamp. Accepts \"UNIX\" or defaults to ISO string.\n * - `config.settings.timestamps.updatedAt.format`: Determines the format of the \"updatedAt\" timestamp. Accepts \"UNIX\" or defaults to ISO string.\n *\n * The returned object keys and values depend on the provided configuration and requested timestamp types.\n */\n const generateTimestamps = (timestampTypes?: Array<\"createdAt\" | \"updatedAt\">): Record<string, string | number> => {\n if (!config.settings?.timestamps) return {};\n\n const timestamps: Record<string, string | number> = {};\n const now = new Date();\n const unixTime = Math.floor(Date.now() / 1000);\n\n const { createdAt, updatedAt } = config.settings.timestamps;\n\n // If no specific types are provided, generate all configured timestamps\n const typesToGenerate = timestampTypes || [\"createdAt\", \"updatedAt\"];\n\n if (createdAt && typesToGenerate.includes(\"createdAt\")) {\n const name = createdAt.attributeName ?? \"createdAt\";\n timestamps[name] = createdAt.format === \"UNIX\" ? unixTime : now.toISOString();\n }\n\n if (updatedAt && typesToGenerate.includes(\"updatedAt\")) {\n const name = updatedAt.attributeName ?? \"updatedAt\";\n timestamps[name] = updatedAt.format === \"UNIX\" ? unixTime : now.toISOString();\n }\n\n return timestamps;\n };\n\n return {\n name: config.name,\n createRepository: (table: Table): EntityRepository<T, I, Q> => {\n // Create a repository\n const repository = {\n create: (data: T) => {\n // Generate the primary key upfront for transaction compatibility\n // Note: We assume data is valid for key generation, validation happens during execution\n const primaryKey = config.primaryKey.generateKey(data as unknown as I);\n\n const indexes = Object.entries(config.indexes ?? {}).reduce(\n (acc, [indexName, index]) => {\n const key = (index as IndexDefinition<T>).generateKey(data);\n const gsiConfig = table.gsis[indexName];\n\n if (!gsiConfig) {\n throw new Error(`GSI configuration not found for index: ${indexName}`);\n }\n\n if (key.pk) {\n acc[gsiConfig.partitionKey] = key.pk;\n }\n if (key.sk && gsiConfig.sortKey) {\n acc[gsiConfig.sortKey] = key.sk;\n }\n return acc;\n },\n {} as Record<string, string>,\n );\n\n // Create the builder with all keys included upfront\n const builder = table.create<T>({\n ...data,\n [entityTypeAttributeName]: config.name,\n [table.partitionKey]: primaryKey.pk,\n ...(table.sortKey ? { [table.sortKey]: primaryKey.sk } : {}),\n ...indexes,\n ...generateTimestamps([\"createdAt\", \"updatedAt\"]),\n });\n\n // Core function that handles validation and item preparation (async version)\n const prepareValidatedItemAsync = async () => {\n const validationResult = await config.schema[\"~standard\"].validate(data);\n if (\"issues\" in validationResult && validationResult.issues) {\n throw new Error(`Validation failed: ${validationResult.issues.map((i) => i.message).join(\", \")}`);\n }\n\n const validatedItem = {\n ...validationResult.value,\n [entityTypeAttributeName]: config.name,\n [table.partitionKey]: primaryKey.pk,\n ...(table.sortKey ? { [table.sortKey]: primaryKey.sk } : {}),\n ...indexes,\n ...generateTimestamps([\"createdAt\", \"updatedAt\"]),\n };\n\n Object.assign(builder, { item: validatedItem });\n return validatedItem;\n };\n\n // Core function that handles validation and item preparation (sync version)\n const prepareValidatedItemSync = () => {\n const validationResult = config.schema[\"~standard\"].validate(data);\n\n // Handle Promise case - this shouldn't happen in withTransaction, but we need to handle it for type safety\n if (validationResult instanceof Promise) {\n throw new Error(\"Async validation is not supported in withTransaction. Use execute() instead.\");\n }\n\n if (\"issues\" in validationResult && validationResult.issues) {\n throw new Error(`Validation failed: ${validationResult.issues.map((i) => i.message).join(\", \")}`);\n }\n\n const validatedItem = {\n ...validationResult.value,\n [entityTypeAttributeName]: config.name,\n [table.partitionKey]: primaryKey.pk,\n ...(table.sortKey ? { [table.sortKey]: primaryKey.sk } : {}),\n ...indexes,\n ...generateTimestamps([\"createdAt\", \"updatedAt\"]),\n };\n\n Object.assign(builder, { item: validatedItem });\n return validatedItem;\n };\n\n // Wrap the builder's execute method\n const originalExecute = builder.execute;\n builder.execute = async () => {\n await prepareValidatedItemAsync();\n return await originalExecute.call(builder);\n };\n\n // Wrap the builder's withTransaction method\n const originalWithTransaction = builder.withTransaction;\n if (originalWithTransaction) {\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n const wrappedWithTransaction = (transaction: any) => {\n prepareValidatedItemSync();\n return originalWithTransaction.call(builder, transaction);\n };\n\n // Copy all properties from the original function to preserve mock functionality\n Object.setPrototypeOf(wrappedWithTransaction, originalWithTransaction);\n const propertyNames = Object.getOwnPropertyNames(originalWithTransaction);\n for (let i = 0; i < propertyNames.length; i++) {\n const prop = propertyNames[i] as string;\n if (prop !== \"length\" && prop !== \"name\" && prop !== \"prototype\") {\n try {\n // biome-ignore lint/suspicious/noExplicitAny: Make it work\n (wrappedWithTransaction as any)[prop] = (originalWithTransaction as any)[prop];\n } catch (e) {\n // Ignore errors for non-configurable properties\n }\n }\n }\n\n builder.withTransaction = wrappedWithTransaction;\n }\n\n return builder;\n },\n\n upsert: (data: T & I) => {\n const primaryKey = config.primaryKey.generateKey(data);\n\n // We need to handle the async operations when the consumer calls execute\n const builder = table.put<T>({\n [table.partitionKey]: primaryKey.pk,\n ...(table.sortKey ? { [table.sortKey]: primaryKey.sk } : {}),\n ...data,\n [entityTypeAttributeName]: config.name,\n ...generateTimestamps([\"createdAt\", \"updatedAt\"]),\n });\n\n // Core function that handles validation and item preparation (async version)\n const prepareValidatedItemAsync = async () => {\n const validationResult = await config.schema[\"~standard\"].validate(data);\n if (\"issues\" in validationResult && validationResult.issues) {\n throw new Error(`Validation failed: ${validationResult.issues.map((i) => i.message).join(\", \")}`);\n }\n\n const primaryKey = config.primaryKey.generateKey(validationResult.value as T & I);\n const validatedItem = {\n [table.partitionKey]: primaryKey.pk,\n ...(table.sortKey ? { [table.sortKey]: primaryKey.sk } : {}),\n ...validationResult.value,\n [entityTypeAttributeName]: config.name,\n ...generateTimestamps([\"createdAt\", \"updatedAt\"]),\n };\n\n Object.assign(builder, { item: validatedItem });\n return validatedItem;\n };\n\n // Core function that handles validation and item preparation (sync version)\n const prepareValidatedItemSync = () => {\n const validationResult = config.schema[\"~standard\"].validate(data);\n\n // Handle Promise case - this shouldn't happen in withTransaction but we need to handle it for type safety\n if (validationResult instanceof Promise) {\n throw new Error(\"Async validation is not supported in withTransaction. Use execute() instead.\");\n }\n\n if (\"issues\" in validationResult && validationResult.issues) {\n throw new Error(`Validation failed: ${validationResult.issues.map((i) => i.message).join(\", \")}`);\n }\n\n const primaryKey = config.primaryKey.generateKey(validationResult.value as T & I);\n const validatedItem = {\n [table.partitionKey]: primaryKey.pk,\n ...(table.sortKey ? { [table.sortKey]: primaryKey.sk } : {}),\n ...validationResult.value,\n [entityTypeAttributeName]: config.name,\n ...generateTimestamps([\"createdAt\", \"updatedAt\"]),\n };\n\n Object.assign(builder, { item: validatedItem });\n return validatedItem;\n };\n\n // Wrap the builder's execute method\n const originalExecute = builder.execute;\n builder.execute = async () => {\n await prepareValidatedItemAsync();\n const result = await originalExecute.call(builder);\n if (!result) {\n throw new Error(\"Failed to upsert item\");\n }\n return result;\n };\n\n // Wrap the builder's withTransaction method\n const originalWithTransaction = builder.withTransaction;\n if (originalWithTransaction) {\n const wrappedWithTransaction = (transaction: TransactionBuilder) => {\n prepareValidatedItemSync();\n return originalWithTransaction.call(builder, transaction);\n };\n\n // Copy all properties from the original function to preserve mock functionality\n Object.setPrototypeOf(wrappedWithTransaction, originalWithTransaction);\n const propertyNames = Object.getOwnPropertyNames(originalWithTransaction);\n for (let i = 0; i < propertyNames.length; i++) {\n const prop = propertyNames[i] as string;\n if (prop !== \"length\" && prop !== \"name\" && prop !== \"prototype\") {\n try {\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n (wrappedWithTransaction as any)[prop] = (originalWithTransaction as any)[prop];\n } catch (e) {\n // Ignore errors for non-configurable properties\n }\n }\n }\n\n builder.withTransaction = wrappedWithTransaction;\n }\n\n return builder;\n },\n\n get: <K extends I>(key: K) => table.get<T>(config.primaryKey.generateKey(key)),\n\n update: <K extends I>(key: K, data: Partial<T>) => {\n const primaryKeyObj = config.primaryKey.generateKey(key);\n const builder = table.update<T>(primaryKeyObj);\n builder.condition(eq(entityTypeAttributeName, config.name));\n\n // Use only updatedAt timestamp for updates\n const timestamps = generateTimestamps([\"updatedAt\"]);\n\n builder.set({ ...data, ...timestamps });\n return builder;\n },\n\n delete: <K extends I>(key: K) => {\n const builder = table.delete(config.primaryKey.generateKey(key));\n builder.condition(eq(entityTypeAttributeName, config.name));\n return builder;\n },\n\n query: Object.entries(config.queries || {}).reduce((acc, [key, inputCallback]) => {\n // @ts-expect-error - We need to cast the queryFn to a function that takes an unknown input\n acc[key] = (input: unknown) => {\n // Create a QueryEntity object with only the necessary methods\n const queryEntity: QueryEntity<T> = {\n scan: repository.scan,\n get: (key: PrimaryKeyWithoutExpression) => table.get<T>(key),\n query: (keyCondition: PrimaryKey) => {\n return table.query<T>(keyCondition);\n },\n };\n\n // Execute the query function to get the builder - This type is incorrect and needs to be fixed\n const queryBuilderCallback = inputCallback(input);\n\n // Run the inner handler which allows the user to apply their desired contraints\n // to the query builder of their choice\n // @ts-expect-error - We need to cast the queryBuilderCallback to a function that takes a QueryEntity\n const builder = queryBuilderCallback(queryEntity);\n\n // Add entity type filter if the builder has filter method\n if (builder && typeof builder === \"object\" && \"filter\" in builder && typeof builder.filter === \"function\") {\n builder.filter(eq(entityTypeAttributeName, config.name));\n }\n\n // Wrap the builder's execute method if it exists\n if (builder && typeof builder === \"object\" && \"execute\" in builder) {\n const originalExecute = builder.execute;\n builder.execute = async () => {\n // Validate the input before executing the query\n const queryFn = (\n config.queries as unknown as Record<string, QueryFunctionWithSchema<T, I, typeof builder>>\n )[key];\n\n if (queryFn && typeof queryFn === \"function\") {\n // Get the schema from the query function\n const schema = queryFn.schema;\n if (schema?.[\"~standard\"]?.validate && typeof schema[\"~standard\"].validate === \"function\") {\n const validationResult = schema[\"~standard\"].validate(input);\n if (\"issues\" in validationResult && validationResult.issues) {\n throw new Error(\n `Validation failed: ${validationResult.issues.map((issue) => issue.message).join(\", \")}`,\n );\n }\n }\n }\n\n // Execute the original builder\n const result = await originalExecute.call(builder);\n if (!result) {\n throw new Error(\"Failed to execute query\");\n }\n return result;\n };\n }\n\n return builder;\n };\n return acc;\n }, {} as Q),\n\n scan: () => {\n const builder = table.scan<T>();\n builder.filter(eq(entityTypeAttributeName, config.name));\n return builder;\n },\n };\n\n return repository;\n },\n };\n}\n\nexport function createQueries<T extends DynamoItem>() {\n return {\n input: <I>(schema: StandardSchemaV1<I>) => ({\n query: <\n Q extends QueryRecord<T> = QueryRecord<T>,\n R = ScanBuilder<T> | QueryBuilder<T, TableConfig> | GetBuilder<T>,\n >(\n handler: (params: { input: I; entity: QueryEntity<T> }) => R,\n ) => {\n const queryFn = (input: I) => (entity: QueryEntity<T>) => handler({ input, entity });\n queryFn.schema = schema;\n return queryFn as unknown as QueryFunctionWithSchema<T, I, R>;\n },\n }),\n };\n}\n\nexport interface IndexDefinition<T extends DynamoItem> extends Index {\n name: string;\n generateKey: (item: T) => { pk: string; sk?: string };\n}\n\nexport function createIndex() {\n return {\n input: <T extends DynamoItem>(schema: StandardSchemaV1<T>) => ({\n partitionKey: <P extends (item: T) => string>(pkFn: P) => ({\n sortKey: <S extends (item: T) => string>(skFn: S) =>\n ({\n name: \"custom\",\n partitionKey: \"pk\",\n sortKey: \"sk\",\n generateKey: (item: T) => ({ pk: pkFn(item), sk: skFn(item) }),\n }) as IndexDefinition<T>,\n\n withoutSortKey: () =>\n ({\n name: \"custom\",\n partitionKey: \"pk\",\n generateKey: (item: T) => ({ pk: pkFn(item) }),\n }) as IndexDefinition<T>,\n }),\n }),\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/conditions.ts","../src/entity.ts"],"names":["primaryKey","key"],"mappings":";AAiGO,IAAM,yBACX,GAAA,CAAC,IACD,KAAA,CAAC,MAAc,KAA+B,MAAA;AAAA,EAC5C,IAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAA,CAAA;AAQK,IAAM,EAAA,GAAK,0BAA0B,IAAI,CAAA;;;ACuBzC,SAAS,aACd,MACA,EAAA;AACA,EAAM,MAAA,uBAAA,GAA0B,MAAO,CAAA,QAAA,EAAU,uBAA2B,IAAA,YAAA;AAmB5E,EAAM,MAAA,kBAAA,GAAqB,CAAC,cAAuF,KAAA;AACjH,IAAA,IAAI,CAAC,MAAA,CAAO,QAAU,EAAA,UAAA,SAAmB,EAAC;AAE1C,IAAA,MAAM,aAA8C,EAAC;AACrD,IAAM,MAAA,GAAA,uBAAU,IAAK,EAAA;AACrB,IAAA,MAAM,WAAW,IAAK,CAAA,KAAA,CAAM,IAAK,CAAA,GAAA,KAAQ,GAAI,CAAA;AAE7C,IAAA,MAAM,EAAE,SAAA,EAAW,SAAU,EAAA,GAAI,OAAO,QAAS,CAAA,UAAA;AAGjD,IAAA,MAAM,eAAkB,GAAA,cAAA,IAAkB,CAAC,WAAA,EAAa,WAAW,CAAA;AAEnE,IAAA,IAAI,SAAa,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IAAA,CAAK,IAAI,CAAE,EAAA;AAAA,SAC9C;AAAA,OACJ;AAAA,KACF;AAAA,GACF;AACF","file":"entity.js","sourcesContent":["import type { Path, PathType } from \"./builders/types\";\nimport type { DynamoItem } from \"./types\";\n\n/**\n * Supported comparison operators for DynamoDB conditions.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html AWS DynamoDB - Comparison Operator Reference}\n *\n * - eq: Equals (=)\n * - ne: Not equals (≠ / <>)\n * - lt: Less than (<)\n * - lte: Less than or equal to (≤)\n * - gt: Greater than (>)\n * - gte: Greater than or equal to (≥)\n * - between: Between two values (inclusive)\n * - in: Checks if attribute value is in a list of values\n * - beginsWith: Checks if string attribute begins with specified substring\n * - contains: Checks if string/set attribute contains specified value\n * - attributeExists: Checks if attribute exists\n * - attributeNotExists: Checks if attribute does not exist\n */\nexport type ComparisonOperator =\n | \"eq\"\n | \"ne\"\n | \"lt\"\n | \"lte\"\n | \"gt\"\n | \"gte\"\n | \"between\"\n | \"in\"\n | \"beginsWith\"\n | \"contains\"\n | \"attributeExists\"\n | \"attributeNotExists\";\n\n/**\n * Logical operators for combining multiple conditions.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - Logical Operator Reference}\n *\n * - and: Evaluates to true if all conditions are true\n * - or: Evaluates to true if any condition is true\n * - not: Negate the result of a condition\n */\nexport type LogicalOperator = \"and\" | \"or\" | \"not\";\n\n/**\n * Represents a DynamoDB condition expression.\n * Can be either a comparison condition or a logical combination of conditions.\n *\n * @example\n * // Simple comparison condition\n * const condition: Condition = {\n * type: \"eq\",\n * attr: \"status\",\n * value: \"ACTIVE\"\n * };\n *\n * @example\n * // Logical combination of conditions\n * const condition: Condition = {\n * type: \"and\",\n * conditions: [\n * { type: \"eq\", attr: \"status\", value: \"ACTIVE\" },\n * { type: \"gt\", attr: \"age\", value: 5 }\n * ]\n * };\n */\nexport interface Condition {\n /** The type of condition (comparison or logical operator) */\n type: ComparisonOperator | LogicalOperator;\n /** The attribute name for comparison conditions */\n attr?: string;\n /** The value to compare against for comparison conditions */\n value?: unknown;\n /** Array of conditions for logical operators (and/or) */\n conditions?: Condition[];\n /** Single condition for the 'not' operator */\n condition?: Condition;\n}\n\n/**\n * Parameters used to build DynamoDB expression strings.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html Expression Attribute Names}\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeValues.html Expression Attribute Values}\n */\nexport interface ExpressionParams {\n /** Map of attribute name placeholders to actual attribute names */\n expressionAttributeNames: Record<string, string>;\n /** Map of value placeholders to actual values */\n expressionAttributeValues: DynamoItem;\n /** Counter for generating unique value placeholders */\n valueCounter: { count: number };\n}\n\n/**\n * Creates a comparison condition builder function for the specified operator.\n * @internal\n */\nexport const createComparisonCondition =\n (type: ComparisonOperator) =>\n (attr: string, value: unknown): Condition => ({\n type,\n attr,\n value,\n });\n\n/**\n * Creates an equals (=) condition\n * @example\n * eq(\"status\", \"ACTIVE\") // status = \"ACTIVE\"\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const eq = createComparisonCondition(\"eq\");\n\n/**\n * Creates a not equals (≠) condition\n * @example\n * ne(\"status\", \"DELETED\") // status <> \"DELETED\"\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const ne = createComparisonCondition(\"ne\");\n\n/**\n * Creates a less than (<) condition\n * @example\n * lt(\"age\", 18) // age < 18\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const lt = createComparisonCondition(\"lt\");\n\n/**\n * Creates a less than or equal to (≤) condition\n * @example\n * lte(\"age\", 18) // age <= 18\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const lte = createComparisonCondition(\"lte\");\n\n/**\n * Creates a greater than (>) condition\n * @example\n * gt(\"price\", 100) // price > 100\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const gt = createComparisonCondition(\"gt\");\n\n/**\n * Creates a greater than or equal to (≥) condition\n * @example\n * gte(\"price\", 100) // price >= 100\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html}\n */\nexport const gte = createComparisonCondition(\"gte\");\n\n/**\n * Creates a between condition that checks if a value is within a range (inclusive)\n * @example\n * between(\"age\", 18, 65) // age BETWEEN 18 AND 65\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - BETWEEN}\n */\nexport const between = (attr: string, lower: unknown, upper: unknown): Condition => ({\n type: \"between\",\n attr,\n value: [lower, upper],\n});\n\n/**\n * Creates an in condition that checks if a value is in a list of values\n * @example\n * inArray(\"status\", [\"ACTIVE\", \"PENDING\", \"PROCESSING\"]) // status IN (\"ACTIVE\", \"PENDING\", \"PROCESSING\")\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - IN}\n */\nexport const inArray = (attr: string, values: unknown[]): Condition => ({\n type: \"in\",\n attr,\n value: values,\n});\n\n/**\n * Creates a begins_with condition that checks if a string attribute starts with a substring\n * @example\n * beginsWith(\"email\", \"@example.com\") // begins_with(email, \"@example.com\")\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - begins_with}\n */\nexport const beginsWith = createComparisonCondition(\"beginsWith\");\n\n/**\n * Creates a contains condition that checks if a string contains a substring or if a set contains an element\n * @example\n * contains(\"tags\", \"important\") // contains(tags, \"important\")\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - contains}\n */\nexport const contains = createComparisonCondition(\"contains\");\n\n/**\n * Creates a condition that checks if an attribute exists\n * @example\n * attributeExists(\"email\") // attribute_exists(email)\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - attribute_exists}\n */\nexport const attributeExists = (attr: string): Condition => ({\n type: \"attributeExists\",\n attr,\n});\n\n/**\n * Creates a condition that checks if an attribute does not exist\n * @example\n * attributeNotExists(\"deletedAt\") // attribute_not_exists(deletedAt)\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - attribute_not_exists}\n */\nexport const attributeNotExists = (attr: string): Condition => ({\n type: \"attributeNotExists\",\n attr,\n});\n\n// --- Logical Operators ---\n\n/**\n * Combines multiple conditions with AND operator\n * @example\n * and(\n * eq(\"status\", \"ACTIVE\"),\n * gt(\"age\", 18)\n * ) // status = \"ACTIVE\" AND age > 18\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - AND}\n */\nexport const and = (...conditions: Condition[]): Condition => ({\n type: \"and\",\n conditions,\n});\n\n/**\n * Combines multiple conditions with OR operator\n * @example\n * or(\n * eq(\"status\", \"PENDING\"),\n * eq(\"status\", \"PROCESSING\")\n * ) // status = \"PENDING\" OR status = \"PROCESSING\"\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - OR}\n */\nexport const or = (...conditions: Condition[]): Condition => ({\n type: \"or\",\n conditions,\n});\n\n/**\n * Negates a condition\n * @example\n * not(eq(\"status\", \"DELETED\")) // NOT status = \"DELETED\"\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - NOT}\n */\nexport const not = (condition: Condition): Condition => ({\n type: \"not\",\n condition,\n});\n\n/**\n * Type-safe operators for building key conditions in DynamoDB queries.\n * Only includes operators that are valid for key conditions.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.KeyConditionExpressions AWS DynamoDB - Key Condition Expressions}\n *\n * @example\n * // Using with sort key conditions\n * table.query({\n * pk: \"USER#123\",\n * sk: op => op.beginsWith(\"ORDER#\")\n * })\n */\nexport type KeyConditionOperator = {\n /** Equals comparison for key attributes */\n eq: (value: unknown) => Condition;\n /** Less than comparison for key attributes */\n lt: (value: unknown) => Condition;\n /** Less than or equal comparison for key attributes */\n lte: (value: unknown) => Condition;\n /** Greater than comparison for key attributes */\n gt: (value: unknown) => Condition;\n /** Greater than or equal comparison for key attributes */\n gte: (value: unknown) => Condition;\n /** Between range comparison for key attributes */\n between: (lower: unknown, upper: unknown) => Condition;\n /** Begins with comparison for key attributes */\n beginsWith: (value: unknown) => Condition;\n /** Combines multiple key conditions with AND */\n and: (...conditions: Condition[]) => Condition;\n};\n\n/**\n * Type-safe operators for building conditions in DynamoDB operations.\n * Includes all available condition operators with proper type inference.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html AWS DynamoDB - Condition Expressions}\n *\n * @example\n * // Using with type-safe conditions\n * interface User {\n * status: string;\n * age: number;\n * email?: string;\n * }\n *\n * table.scan<User>()\n * .where(op => op.and(\n * op.eq(\"status\", \"ACTIVE\"),\n * op.gt(\"age\", 18),\n * op.attributeExists(\"email\")\n * ))\n *\n * @template T The type of the item being operated on\n */\nexport type ConditionOperator<T extends DynamoItem> = {\n /**\n * Creates an equals (=) condition for type-safe attribute comparison.\n * Tests if the specified attribute equals the provided value.\n *\n * @param attr - The attribute path to compare (with full type safety)\n * @param value - The value to compare against (must match attribute type)\n * @returns A condition that evaluates to true when attr equals value\n *\n * @example\n * ```typescript\n * interface User { status: string; age: number; }\n *\n * // String comparison\n * op.eq(\"status\", \"ACTIVE\") // status = \"ACTIVE\"\n *\n * // Numeric comparison\n * op.eq(\"age\", 25) // age = 25\n *\n * // Nested attribute\n * op.eq(\"profile.role\", \"admin\") // profile.role = \"admin\"\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - Comparison Operators}\n */\n eq: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n\n /**\n * Creates a not equals (≠ / <>) condition for type-safe attribute comparison.\n * Tests if the specified attribute does not equal the provided value.\n *\n * @param attr - The attribute path to compare (with full type safety)\n * @param value - The value to compare against (must match attribute type)\n * @returns A condition that evaluates to true when attr does not equal value\n *\n * @example\n * ```typescript\n * interface User { status: string; priority: number; }\n *\n * // String comparison\n * op.ne(\"status\", \"DELETED\") // status <> \"DELETED\"\n *\n * // Numeric comparison\n * op.ne(\"priority\", 0) // priority <> 0\n *\n * // Useful for filtering out specific values\n * op.ne(\"category\", \"ARCHIVED\") // category <> \"ARCHIVED\"\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - Comparison Operators}\n */\n ne: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n\n /**\n * Creates a less than (<) condition for type-safe attribute comparison.\n * Tests if the specified attribute is less than the provided value.\n * Works with numbers, strings (lexicographic), and dates.\n *\n * @param attr - The attribute path to compare (with full type safety)\n * @param value - The value to compare against (must match attribute type)\n * @returns A condition that evaluates to true when attr is less than value\n *\n * @example\n * ```typescript\n * interface Product { price: number; name: string; createdAt: string; }\n *\n * // Numeric comparison\n * op.lt(\"price\", 100) // price < 100\n *\n * // String comparison (lexicographic)\n * op.lt(\"name\", \"M\") // name < \"M\" (names starting with A-L)\n *\n * // Date comparison (ISO strings)\n * op.lt(\"createdAt\", \"2024-01-01\") // createdAt < \"2024-01-01\"\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - Comparison Operators}\n */\n lt: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n\n /**\n * Creates a less than or equal to (≤) condition for type-safe attribute comparison.\n * Tests if the specified attribute is less than or equal to the provided value.\n * Works with numbers, strings (lexicographic), and dates.\n *\n * @param attr - The attribute path to compare (with full type safety)\n * @param value - The value to compare against (must match attribute type)\n * @returns A condition that evaluates to true when attr is less than or equal to value\n *\n * @example\n * ```typescript\n * interface Order { total: number; priority: number; dueDate: string; }\n *\n * // Numeric comparison\n * op.lte(\"total\", 1000) // total <= 1000\n *\n * // Priority levels\n * op.lte(\"priority\", 3) // priority <= 3 (low to medium priority)\n *\n * // Date deadlines\n * op.lte(\"dueDate\", \"2024-12-31\") // dueDate <= \"2024-12-31\"\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - Comparison Operators}\n */\n lte: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n\n /**\n * Creates a greater than (>) condition for type-safe attribute comparison.\n * Tests if the specified attribute is greater than the provided value.\n * Works with numbers, strings (lexicographic), and dates.\n *\n * @param attr - The attribute path to compare (with full type safety)\n * @param value - The value to compare against (must match attribute type)\n * @returns A condition that evaluates to true when attr is greater than value\n *\n * @example\n * ```typescript\n * interface User { age: number; score: number; lastLogin: string; }\n *\n * // Age restrictions\n * op.gt(\"age\", 18) // age > 18 (adults only)\n *\n * // Performance thresholds\n * op.gt(\"score\", 85) // score > 85 (high performers)\n *\n * // Recent activity\n * op.gt(\"lastLogin\", \"2024-01-01\") // lastLogin > \"2024-01-01\"\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - Comparison Operators}\n */\n gt: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n\n /**\n * Creates a greater than or equal to (≥) condition for type-safe attribute comparison.\n * Tests if the specified attribute is greater than or equal to the provided value.\n * Works with numbers, strings (lexicographic), and dates.\n *\n * @param attr - The attribute path to compare (with full type safety)\n * @param value - The value to compare against (must match attribute type)\n * @returns A condition that evaluates to true when attr is greater than or equal to value\n *\n * @example\n * ```typescript\n * interface Product { rating: number; version: string; releaseDate: string; }\n *\n * // Minimum ratings\n * op.gte(\"rating\", 4.0) // rating >= 4.0 (highly rated)\n *\n * // Version requirements\n * op.gte(\"version\", \"2.0.0\") // version >= \"2.0.0\"\n *\n * // Release date filters\n * op.gte(\"releaseDate\", \"2024-01-01\") // releaseDate >= \"2024-01-01\"\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - Comparison Operators}\n */\n gte: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n\n /**\n * Creates a between condition for type-safe range comparison.\n * Tests if the specified attribute value falls within the inclusive range [lower, upper].\n * Works with numbers, strings (lexicographic), and dates.\n *\n * @param attr - The attribute path to compare (with full type safety)\n * @param lower - The lower bound of the range (inclusive, must match attribute type)\n * @param upper - The upper bound of the range (inclusive, must match attribute type)\n * @returns A condition that evaluates to true when lower ≤ attr ≤ upper\n *\n * @example\n * ```typescript\n * interface Event { price: number; date: string; priority: number; }\n *\n * // Price range\n * op.between(\"price\", 50, 200) // price BETWEEN 50 AND 200\n *\n * // Date range\n * op.between(\"date\", \"2024-01-01\", \"2024-12-31\") // date BETWEEN \"2024-01-01\" AND \"2024-12-31\"\n *\n * // Priority levels\n * op.between(\"priority\", 1, 5) // priority BETWEEN 1 AND 5\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - BETWEEN}\n */\n between: <K extends Path<T>>(attr: K, lower: PathType<T, K>, upper: PathType<T, K>) => Condition;\n\n /**\n * Creates an IN condition for type-safe list membership testing.\n * Tests if the specified attribute value matches any value in the provided list.\n * Supports up to 100 values in the list as per DynamoDB limitations.\n *\n * @param attr - The attribute path to compare (with full type safety)\n * @param values - Array of values to test against (must match attribute type, max 100 items)\n * @returns A condition that evaluates to true when attr matches any value in the list\n *\n * @example\n * ```typescript\n * interface User { status: string; role: string; priority: number; }\n *\n * // Status filtering\n * op.inArray(\"status\", [\"ACTIVE\", \"PENDING\", \"PROCESSING\"]) // status IN (\"ACTIVE\", \"PENDING\", \"PROCESSING\")\n *\n * // Role-based access\n * op.inArray(\"role\", [\"admin\", \"moderator\", \"editor\"]) // role IN (\"admin\", \"moderator\", \"editor\")\n *\n * // Priority levels\n * op.inArray(\"priority\", [1, 2, 3]) // priority IN (1, 2, 3)\n * ```\n *\n * @throws {Error} When values array is empty or contains more than 100 items\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Comparators AWS DynamoDB - IN}\n */\n inArray: <K extends Path<T>>(attr: K, values: PathType<T, K>[]) => Condition;\n\n /**\n * Creates a begins_with condition for type-safe string prefix testing.\n * Tests if the specified string attribute starts with the provided substring.\n * Only works with string attributes - will fail on other data types.\n *\n * @param attr - The string attribute path to test (with full type safety)\n * @param value - The prefix string to test for (must match attribute type)\n * @returns A condition that evaluates to true when attr starts with value\n *\n * @example\n * ```typescript\n * interface User { email: string; name: string; id: string; }\n *\n * // Email domain filtering\n * op.beginsWith(\"email\", \"admin@\") // begins_with(email, \"admin@\")\n *\n * // Name prefix search\n * op.beginsWith(\"name\", \"John\") // begins_with(name, \"John\")\n *\n * // ID pattern matching\n * op.beginsWith(\"id\", \"USER#\") // begins_with(id, \"USER#\")\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - begins_with}\n */\n beginsWith: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n\n /**\n * Creates a contains condition for type-safe substring or set membership testing.\n * For strings: tests if the attribute contains the specified substring.\n * For sets: tests if the set contains the specified element.\n *\n * @param attr - The attribute path to test (with full type safety)\n * @param value - The substring or element to search for (must match attribute type)\n * @returns A condition that evaluates to true when attr contains value\n *\n * @example\n * ```typescript\n * interface Post { content: string; tags: Set<string>; categories: string[]; }\n *\n * // Substring search in content\n * op.contains(\"content\", \"important\") // contains(content, \"important\")\n *\n * // Tag membership (for DynamoDB String Sets)\n * op.contains(\"tags\", \"featured\") // contains(tags, \"featured\")\n *\n * // Category search (for string arrays stored as lists)\n * op.contains(\"categories\", \"technology\") // contains(categories, \"technology\")\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - contains}\n */\n contains: <K extends Path<T>>(attr: K, value: PathType<T, K>) => Condition;\n\n /**\n * Creates an attribute_exists condition for type-safe attribute presence testing.\n * Tests if the specified attribute exists in the item, regardless of its value.\n * Useful for filtering items that have optional attributes populated.\n *\n * @param attr - The attribute path to test for existence (with full type safety)\n * @returns A condition that evaluates to true when the attribute exists\n *\n * @example\n * ```typescript\n * interface User { email: string; phone?: string; profile?: { avatar?: string; }; }\n *\n * // Check for optional fields\n * op.attributeExists(\"phone\") // attribute_exists(phone)\n *\n * // Check for nested optional attributes\n * op.attributeExists(\"profile.avatar\") // attribute_exists(profile.avatar)\n *\n * // Useful in combination with other conditions\n * op.and(\n * op.eq(\"status\", \"ACTIVE\"),\n * op.attributeExists(\"email\") // Only active users with email\n * )\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - attribute_exists}\n */\n attributeExists: <K extends Path<T>>(attr: K) => Condition;\n\n /**\n * Creates an attribute_not_exists condition for type-safe attribute absence testing.\n * Tests if the specified attribute does not exist in the item.\n * Useful for conditional writes to prevent overwriting existing data.\n *\n * @param attr - The attribute path to test for absence (with full type safety)\n * @returns A condition that evaluates to true when the attribute does not exist\n *\n * @example\n * ```typescript\n * interface User { id: string; email: string; deletedAt?: string; }\n *\n * // Ensure item hasn't been soft-deleted\n * op.attributeNotExists(\"deletedAt\") // attribute_not_exists(deletedAt)\n *\n * // Prevent duplicate creation\n * op.attributeNotExists(\"id\") // attribute_not_exists(id)\n *\n * // Conditional updates\n * op.and(\n * op.eq(\"status\", \"PENDING\"),\n * op.attributeNotExists(\"processedAt\") // Only unprocessed items\n * )\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions AWS DynamoDB - attribute_not_exists}\n */\n attributeNotExists: <K extends Path<T>>(attr: K) => Condition;\n\n /**\n * Combines multiple conditions with logical AND operator.\n * All provided conditions must evaluate to true for the AND condition to be true.\n * Supports any number of conditions as arguments.\n *\n * @param conditions - Variable number of conditions to combine with AND\n * @returns A condition that evaluates to true when all input conditions are true\n *\n * @example\n * ```typescript\n * interface User { status: string; age: number; role: string; verified: boolean; }\n *\n * // Multiple criteria\n * op.and(\n * op.eq(\"status\", \"ACTIVE\"),\n * op.gt(\"age\", 18),\n * op.eq(\"verified\", true)\n * ) // status = \"ACTIVE\" AND age > 18 AND verified = true\n *\n * // Complex business logic\n * op.and(\n * op.inArray(\"role\", [\"admin\", \"moderator\"]),\n * op.attributeExists(\"permissions\"),\n * op.ne(\"status\", \"SUSPENDED\")\n * )\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - AND}\n */\n and: (...conditions: Condition[]) => Condition;\n\n /**\n * Combines multiple conditions with logical OR operator.\n * At least one of the provided conditions must evaluate to true for the OR condition to be true.\n * Supports any number of conditions as arguments.\n *\n * @param conditions - Variable number of conditions to combine with OR\n * @returns A condition that evaluates to true when any input condition is true\n *\n * @example\n * ```typescript\n * interface Order { status: string; priority: string; urgent: boolean; }\n *\n * // Alternative statuses\n * op.or(\n * op.eq(\"status\", \"PENDING\"),\n * op.eq(\"status\", \"PROCESSING\"),\n * op.eq(\"status\", \"SHIPPED\")\n * ) // status = \"PENDING\" OR status = \"PROCESSING\" OR status = \"SHIPPED\"\n *\n * // High priority items\n * op.or(\n * op.eq(\"priority\", \"HIGH\"),\n * op.eq(\"urgent\", true)\n * )\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - OR}\n */\n or: (...conditions: Condition[]) => Condition;\n\n /**\n * Negates a condition with logical NOT operator.\n * Inverts the boolean result of the provided condition.\n *\n * @param condition - The condition to negate\n * @returns A condition that evaluates to true when the input condition is false\n *\n * @example\n * ```typescript\n * interface User { status: string; role: string; banned: boolean; }\n *\n * // Exclude specific status\n * op.not(op.eq(\"status\", \"DELETED\")) // NOT status = \"DELETED\"\n *\n * // Complex negation\n * op.not(\n * op.and(\n * op.eq(\"role\", \"guest\"),\n * op.eq(\"banned\", true)\n * )\n * ) // NOT (role = \"guest\" AND banned = true)\n *\n * // Exclude multiple values\n * op.not(op.inArray(\"status\", [\"DELETED\", \"ARCHIVED\"]))\n * ```\n *\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Logical AWS DynamoDB - NOT}\n */\n not: (condition: Condition) => Condition;\n};\n\n/**\n * Primary key type for QUERY operations.\n * Allows building complex key conditions for the sort key.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html AWS DynamoDB - Query Operations}\n *\n * @example\n * // Query items with a specific partition key and sort key prefix\n * table.query({\n * pk: \"USER#123\",\n * sk: op => op.beginsWith(\"ORDER#2023\")\n * })\n *\n * @example\n * // Query items within a specific sort key range\n * table.query({\n * pk: \"USER#123\",\n * sk: op => op.between(\"ORDER#2023-01\", \"ORDER#2023-12\")\n * })\n */\nexport type PrimaryKey = {\n /** Partition key value */\n pk: string;\n /** Optional sort key condition builder */\n sk?: (op: KeyConditionOperator) => Condition;\n};\n\n/**\n * Primary key type for GET and DELETE operations.\n * Used when you need to specify exact key values without conditions.\n * @see {@link https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html AWS DynamoDB - Working with Items}\n *\n * @example\n * // Get a specific item by its complete primary key\n * table.get({\n * pk: \"USER#123\",\n * sk: \"PROFILE#123\"\n * })\n *\n * @example\n * // Delete a specific item by its complete primary key\n * table.delete({\n * pk: \"USER#123\",\n * sk: \"ORDER#456\"\n * })\n */\nexport type PrimaryKeyWithoutExpression = {\n /** Partition key value */\n pk: string;\n /** Optional sort key value */\n sk?: string;\n};\n","import type { DeleteBuilder } from \"./builders/delete-builder\";\nimport type { GetBuilder } from \"./builders/get-builder\";\nimport type { PutBuilder } from \"./builders/put-builder\";\nimport type { ScanBuilder } from \"./builders/scan-builder\";\nimport type { UpdateBuilder } from \"./builders/update-builder\";\nimport type { StandardSchemaV1 } from \"./standard-schema\";\nimport type { Table } from \"./table\";\nimport type { DynamoItem, Index, TableConfig } from \"./types\";\nimport { eq, type PrimaryKey, type PrimaryKeyWithoutExpression } from \"./conditions\";\nimport type { QueryBuilder } from \"./builders/query-builder\";\nimport type { TransactionBuilder } from \"./builders/transaction-builder\";\n\n// Define the QueryFunction type with a generic return type\nexport type QueryFunction<T extends DynamoItem, I, R> = (input: I) => R;\n\n// Define a type for the query record that preserves the input type for each query function\nexport type QueryFunctionWithSchema<T extends DynamoItem, I, R> = QueryFunction<T, I, R> & {\n schema?: StandardSchemaV1<I>;\n};\n\nexport type QueryRecord<T extends DynamoItem> = {\n // biome-ignore lint/suspicious/noExplicitAny: This is for flexibility\n [K: string]: QueryFunctionWithSchema<T, any, ScanBuilder<T> | QueryBuilder<T, TableConfig> | GetBuilder<T>>;\n};\n\n// Define a type for entity with only scan, get and query methods\nexport type QueryEntity<T extends DynamoItem> = {\n scan: () => ScanBuilder<T>;\n get: (key: PrimaryKeyWithoutExpression) => GetBuilder<T>;\n query: (keyCondition: PrimaryKey) => QueryBuilder<T, TableConfig>;\n};\n\ninterface Settings {\n /**\n * Defaults to \"entityType\"\n */\n entityTypeAttributeName?: string;\n timestamps?: {\n createdAt?: {\n /**\n * ISO vs Unix trade-offs\n *\n * Both options support between, greater than and less than comparisons.\n *\n * ISO:\n * - Human readable, but requires more storage space\n * - Does not work with DynamoDBs TTL feature.\n *\n * UNIX:\n * - Less readable, but requires less storage space.\n * - Works with DynamoDBs TTL feature.\n */\n format: \"ISO\" | \"UNIX\";\n /**\n * Defaults to \"createdAt\"\n */\n attributeName?: string;\n };\n updatedAt?: {\n /**\n * ISO vs Unix trade-offs\n *\n * Both options support between, greater than and less than comparisons.\n *\n * ISO:\n * - Human readable, but requires more storage space\n * - Does not work with DynamoDBs TTL feature.\n *\n * UNIX:\n * - Less readable, but requires less storage space.\n * - Works with DynamoDBs TTL feature.\n */\n format: \"ISO\" | \"UNIX\";\n /**\n * Defaults to \"updatedAt\"\n */\n attributeName?: string;\n };\n };\n}\n\nexport interface EntityConfig<\n T extends DynamoItem,\n I extends DynamoItem = T,\n Q extends QueryRecord<T> = QueryRecord<T>,\n> {\n name: string;\n schema: StandardSchemaV1<T>;\n primaryKey: IndexDefinition<I>;\n indexes?: Record<string, Index>;\n queries: Q;\n settings?: Settings;\n}\n\nexport interface EntityRepository<\n /**\n * The Entity Type\n */\n T extends DynamoItem,\n /**\n * The Primary Index (Partition index) Type\n */\n I extends DynamoItem = T,\n /**\n * The Queries object\n */\n Q extends QueryRecord<T> = QueryRecord<T>,\n> {\n create: (data: T) => PutBuilder<T>;\n upsert: (data: T & I) => PutBuilder<T>;\n get: (key: I) => GetBuilder<T>;\n update: (key: I, data: Partial<T>) => UpdateBuilder<T>;\n delete: (key: I) => DeleteBuilder;\n query: Q;\n scan: () => ScanBuilder<T>;\n}\n\n/**\n * Creates an entity definition with type-safe operations\n *\n * @example\n * ```typescript\n * interface User {\n * id: string;\n * name: string;\n * }\n *\n * const UserEntity = defineEntity<User>({\n * name: \"User\",\n * schema: userSchema,\n * primaryKey: primaryKey,\n * });\n * ```\n */\nexport function defineEntity<T extends DynamoItem, I extends DynamoItem = T, Q extends QueryRecord<T> = QueryRecord<T>>(\n config: EntityConfig<T, I, Q>,\n) {\n const entityTypeAttributeName = config.settings?.entityTypeAttributeName ?? \"entityType\";\n\n /**\n * Generates an object containing timestamp attributes based on the given configuration settings.\n * The function determines the presence and format of \"createdAt\" and \"updatedAt\" timestamps dynamically.\n *\n * @param {Array<\"createdAt\" | \"updatedAt\">} [timestampTypes] - Optional array of timestamp types to generate. If not provided, all configured timestamps will be generated.\n * @returns {Record<string, string | number>} An object containing one or both of the \"createdAt\" and \"updatedAt\" timestamp attributes, depending on the configuration and requested types. Each timestamp can be formatted as either an ISO string or a UNIX timestamp.\n *\n * @throws Will not throw errors but depends on `config.settings?.timestamps` to be properly defined.\n * - If `createdAt` is configured, the function adds a timestamp using the attribute name specified in `config.settings.timestamps.createdAt.attributeName` or defaults to \"createdAt\".\n * - If `updatedAt` is configured, the function adds a timestamp using the attribute name specified in `config.settings.timestamps.updatedAt.attributeName` or defaults to \"updatedAt\".\n *\n * Configuration Details:\n * - `config.settings.timestamps.createdAt.format`: Determines the format of the \"createdAt\" timestamp. Accepts \"UNIX\" or defaults to ISO string.\n * - `config.settings.timestamps.updatedAt.format`: Determines the format of the \"updatedAt\" timestamp. Accepts \"UNIX\" or defaults to ISO string.\n *\n * The returned object keys and values depend on the provided configuration and requested timestamp types.\n */\n const generateTimestamps = (timestampTypes?: Array<\"createdAt\" | \"updatedAt\">): Record<string, string | number> => {\n if (!config.settings?.timestamps) return {};\n\n const timestamps: Record<string, string | number> = {};\n const now = new Date();\n const unixTime = Math.floor(Date.now() / 1000);\n\n const { createdAt, updatedAt } = config.settings.timestamps;\n\n // If no specific types are provided, generate all configured timestamps\n const typesToGenerate = timestampTypes || [\"createdAt\", \"updatedAt\"];\n\n if (createdAt && typesToGenerate.includes(\"createdAt\")) {\n const name = createdAt.attributeName ?? \"createdAt\";\n timestamps[name] = createdAt.format === \"UNIX\" ? unixTime : now.toISOString();\n }\n\n if (updatedAt && typesToGenerate.includes(\"updatedAt\")) {\n const name = updatedAt.attributeName ?? \"updatedAt\";\n timestamps[name] = updatedAt.format === \"UNIX\" ? unixTime : now.toISOString();\n }\n\n return timestamps;\n };\n\n return {\n name: config.name,\n createRepository: (table: Table): EntityRepository<T, I, Q> => {\n // Create a repository\n const repository = {\n create: (data: T) => {\n // Generate the primary key upfront for transaction compatibility\n // Note: We assume data is valid for key generation, validation happens during execution\n const primaryKey = config.primaryKey.generateKey(data as unknown as I);\n\n const indexes = Object.entries(config.indexes ?? {}).reduce(\n (acc, [indexName, index]) => {\n const key = (index as IndexDefinition<T>).generateKey(data);\n const gsiConfig = table.gsis[indexName];\n\n if (!gsiConfig) {\n throw new Error(`GSI configuration not found for index: ${indexName}`);\n }\n\n if (key.pk) {\n acc[gsiConfig.partitionKey] = key.pk;\n }\n if (key.sk && gsiConfig.sortKey) {\n acc[gsiConfig.sortKey] = key.sk;\n }\n return acc;\n },\n {} as Record<string, string>,\n );\n\n // Create the builder with all keys included upfront\n const builder = table.create<T>({\n ...data,\n [entityTypeAttributeName]: config.name,\n [table.partitionKey]: primaryKey.pk,\n ...(table.sortKey ? { [table.sortKey]: primaryKey.sk } : {}),\n ...indexes,\n ...generateTimestamps([\"createdAt\", \"updatedAt\"]),\n });\n\n // Core function that handles validation and item preparation (async version)\n const prepareValidatedItemAsync = async () => {\n const validationResult = await config.schema[\"~standard\"].validate(data);\n if (\"issues\" in validationResult && validationResult.issues) {\n throw new Error(`Validation failed: ${validationResult.issues.map((i) => i.message).join(\", \")}`);\n }\n\n const validatedItem = {\n ...validationResult.value,\n [entityTypeAttributeName]: config.name,\n [table.partitionKey]: primaryKey.pk,\n ...(table.sortKey ? { [table.sortKey]: primaryKey.sk } : {}),\n ...indexes,\n ...generateTimestamps([\"createdAt\", \"updatedAt\"]),\n };\n\n Object.assign(builder, { item: validatedItem });\n return validatedItem;\n };\n\n // Core function that handles validation and item preparation (sync version)\n const prepareValidatedItemSync = () => {\n const validationResult = config.schema[\"~standard\"].validate(data);\n\n // Handle Promise case - this shouldn't happen in withTransaction, but we need to handle it for type safety\n if (validationResult instanceof Promise) {\n throw new Error(\"Async validation is not supported in withTransaction. Use execute() instead.\");\n }\n\n if (\"issues\" in validationResult && validationResult.issues) {\n throw new Error(`Validation failed: ${validationResult.issues.map((i) => i.message).join(\", \")}`);\n }\n\n const validatedItem = {\n ...validationResult.value,\n [entityTypeAttributeName]: config.name,\n [table.partitionKey]: primaryKey.pk,\n ...(table.sortKey ? { [table.sortKey]: primaryKey.sk } : {}),\n ...indexes,\n ...generateTimestamps([\"createdAt\", \"updatedAt\"]),\n };\n\n Object.assign(builder, { item: validatedItem });\n return validatedItem;\n };\n\n // Wrap the builder's execute method\n const originalExecute = builder.execute;\n builder.execute = async () => {\n await prepareValidatedItemAsync();\n return await originalExecute.call(builder);\n };\n\n // Wrap the builder's withTransaction method\n const originalWithTransaction = builder.withTransaction;\n if (originalWithTransaction) {\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n const wrappedWithTransaction = (transaction: any) => {\n prepareValidatedItemSync();\n return originalWithTransaction.call(builder, transaction);\n };\n\n // Copy all properties from the original function to preserve mock functionality\n Object.setPrototypeOf(wrappedWithTransaction, originalWithTransaction);\n const propertyNames = Object.getOwnPropertyNames(originalWithTransaction);\n for (let i = 0; i < propertyNames.length; i++) {\n const prop = propertyNames[i] as string;\n if (prop !== \"length\" && prop !== \"name\" && prop !== \"prototype\") {\n try {\n // biome-ignore lint/suspicious/noExplicitAny: Make it work\n (wrappedWithTransaction as any)[prop] = (originalWithTransaction as any)[prop];\n } catch (e) {\n // Ignore errors for non-configurable properties\n }\n }\n }\n\n builder.withTransaction = wrappedWithTransaction;\n }\n\n return builder;\n },\n\n upsert: (data: T & I) => {\n const primaryKey = config.primaryKey.generateKey(data);\n\n // We need to handle the async operations when the consumer calls execute\n const builder = table.put<T>({\n [table.partitionKey]: primaryKey.pk,\n ...(table.sortKey ? { [table.sortKey]: primaryKey.sk } : {}),\n ...data,\n [entityTypeAttributeName]: config.name,\n ...generateTimestamps([\"createdAt\", \"updatedAt\"]),\n });\n\n // Core function that handles validation and item preparation (async version)\n const prepareValidatedItemAsync = async () => {\n const validationResult = await config.schema[\"~standard\"].validate(data);\n if (\"issues\" in validationResult && validationResult.issues) {\n throw new Error(`Validation failed: ${validationResult.issues.map((i) => i.message).join(\", \")}`);\n }\n\n const primaryKey = config.primaryKey.generateKey(validationResult.value as T & I);\n const validatedItem = {\n [table.partitionKey]: primaryKey.pk,\n ...(table.sortKey ? { [table.sortKey]: primaryKey.sk } : {}),\n ...validationResult.value,\n [entityTypeAttributeName]: config.name,\n ...generateTimestamps([\"createdAt\", \"updatedAt\"]),\n };\n\n Object.assign(builder, { item: validatedItem });\n return validatedItem;\n };\n\n // Core function that handles validation and item preparation (sync version)\n const prepareValidatedItemSync = () => {\n const validationResult = config.schema[\"~standard\"].validate(data);\n\n // Handle Promise case - this shouldn't happen in withTransaction but we need to handle it for type safety\n if (validationResult instanceof Promise) {\n throw new Error(\"Async validation is not supported in withTransaction. Use execute() instead.\");\n }\n\n if (\"issues\" in validationResult && validationResult.issues) {\n throw new Error(`Validation failed: ${validationResult.issues.map((i) => i.message).join(\", \")}`);\n }\n\n const primaryKey = config.primaryKey.generateKey(validationResult.value as T & I);\n const validatedItem = {\n [table.partitionKey]: primaryKey.pk,\n ...(table.sortKey ? { [table.sortKey]: primaryKey.sk } : {}),\n ...validationResult.value,\n [entityTypeAttributeName]: config.name,\n ...generateTimestamps([\"createdAt\", \"updatedAt\"]),\n };\n\n Object.assign(builder, { item: validatedItem });\n return validatedItem;\n };\n\n // Wrap the builder's execute method\n const originalExecute = builder.execute;\n builder.execute = async () => {\n await prepareValidatedItemAsync();\n const result = await originalExecute.call(builder);\n if (!result) {\n throw new Error(\"Failed to upsert item\");\n }\n return result;\n };\n\n // Wrap the builder's withTransaction method\n const originalWithTransaction = builder.withTransaction;\n if (originalWithTransaction) {\n const wrappedWithTransaction = (transaction: TransactionBuilder) => {\n prepareValidatedItemSync();\n return originalWithTransaction.call(builder, transaction);\n };\n\n // Copy all properties from the original function to preserve mock functionality\n Object.setPrototypeOf(wrappedWithTransaction, originalWithTransaction);\n const propertyNames = Object.getOwnPropertyNames(originalWithTransaction);\n for (let i = 0; i < propertyNames.length; i++) {\n const prop = propertyNames[i] as string;\n if (prop !== \"length\" && prop !== \"name\" && prop !== \"prototype\") {\n try {\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n (wrappedWithTransaction as any)[prop] = (originalWithTransaction as any)[prop];\n } catch (e) {\n // Ignore errors for non-configurable properties\n }\n }\n }\n\n builder.withTransaction = wrappedWithTransaction;\n }\n\n return builder;\n },\n\n get: <K extends I>(key: K) => table.get<T>(config.primaryKey.generateKey(key)),\n\n update: <K extends I>(key: K, data: Partial<T>) => {\n const primaryKeyObj = config.primaryKey.generateKey(key);\n const builder = table.update<T>(primaryKeyObj);\n builder.condition(eq(entityTypeAttributeName, config.name));\n\n // Use only updatedAt timestamp for updates\n const timestamps = generateTimestamps([\"updatedAt\"]);\n\n builder.set({ ...data, ...timestamps });\n return builder;\n },\n\n delete: <K extends I>(key: K) => {\n const builder = table.delete(config.primaryKey.generateKey(key));\n builder.condition(eq(entityTypeAttributeName, config.name));\n return builder;\n },\n\n query: Object.entries(config.queries || {}).reduce((acc, [key, inputCallback]) => {\n // @ts-expect-error - We need to cast the queryFn to a function that takes an unknown input\n acc[key] = (input: unknown) => {\n // Create a QueryEntity object with only the necessary methods\n const queryEntity: QueryEntity<T> = {\n scan: repository.scan,\n get: (key: PrimaryKeyWithoutExpression) => table.get<T>(key),\n query: (keyCondition: PrimaryKey) => {\n return table.query<T>(keyCondition);\n },\n };\n\n // Execute the query function to get the builder - This type is incorrect and needs to be fixed\n const queryBuilderCallback = inputCallback(input);\n\n // Run the inner handler which allows the user to apply their desired contraints\n // to the query builder of their choice\n // @ts-expect-error - We need to cast the queryBuilderCallback to a function that takes a QueryEntity\n const builder = queryBuilderCallback(queryEntity);\n\n // Add entity type filter if the builder has filter method\n if (builder && typeof builder === \"object\" && \"filter\" in builder && typeof builder.filter === \"function\") {\n builder.filter(eq(entityTypeAttributeName, config.name));\n }\n\n // Wrap the builder's execute method if it exists\n if (builder && typeof builder === \"object\" && \"execute\" in builder) {\n const originalExecute = builder.execute;\n builder.execute = async () => {\n // Validate the input before executing the query\n const queryFn = (\n config.queries as unknown as Record<string, QueryFunctionWithSchema<T, I, typeof builder>>\n )[key];\n\n if (queryFn && typeof queryFn === \"function\") {\n // Get the schema from the query function\n const schema = queryFn.schema;\n if (schema?.[\"~standard\"]?.validate && typeof schema[\"~standard\"].validate === \"function\") {\n const validationResult = schema[\"~standard\"].validate(input);\n if (\"issues\" in validationResult && validationResult.issues) {\n throw new Error(\n `Validation failed: ${validationResult.issues.map((issue) => issue.message).join(\", \")}`,\n );\n }\n }\n }\n\n // Execute the original builder\n const result = await originalExecute.call(builder);\n if (!result) {\n throw new Error(\"Failed to execute query\");\n }\n return result;\n };\n }\n\n return builder;\n };\n return acc;\n }, {} as Q),\n\n scan: () => {\n const builder = table.scan<T>();\n builder.filter(eq(entityTypeAttributeName, config.name));\n return builder;\n },\n };\n\n return repository;\n },\n };\n}\n\nexport function createQueries<T extends DynamoItem>() {\n return {\n input: <I>(schema: StandardSchemaV1<I>) => ({\n query: <\n Q extends QueryRecord<T> = QueryRecord<T>,\n R = ScanBuilder<T> | QueryBuilder<T, TableConfig> | GetBuilder<T>,\n >(\n handler: (params: { input: I; entity: QueryEntity<T> }) => R,\n ) => {\n const queryFn = (input: I) => (entity: QueryEntity<T>) => handler({ input, entity });\n queryFn.schema = schema;\n return queryFn as unknown as QueryFunctionWithSchema<T, I, R>;\n },\n }),\n };\n}\n\nexport interface IndexDefinition<T extends DynamoItem> extends Index {\n name: string;\n generateKey: (item: T) => { pk: string; sk?: string };\n}\n\nexport function createIndex() {\n return {\n input: <T extends DynamoItem>(schema: StandardSchemaV1<T>) => ({\n partitionKey: <P extends (item: T) => string>(pkFn: P) => ({\n sortKey: <S extends (item: T) => string>(skFn: S) =>\n ({\n name: \"custom\",\n partitionKey: \"pk\",\n sortKey: \"sk\",\n generateKey: (item: T) => ({ pk: pkFn(item), sk: skFn(item) }),\n }) as IndexDefinition<T>,\n\n withoutSortKey: () =>\n ({\n name: \"custom\",\n partitionKey: \"pk\",\n generateKey: (item: T) => ({ pk: pkFn(item) }),\n }) as IndexDefinition<T>,\n }),\n }),\n };\n}\n"]}
@@ -1,7 +1,7 @@
1
- import { C as Condition, b as ConditionOperator } from './conditions-ChhQWd6z.cjs';
1
+ import { C as Condition, b as ConditionOperator } from './conditions-x6kGWMR7.cjs';
2
2
  import { Paginator } from './builders/paginator.cjs';
3
3
  import { DynamoItem, TableConfig, GSINames } from './types.cjs';
4
- import { F as FilterBuilderInterface, Q as QueryBuilderInterface } from './builder-types-DtwbqMeF.cjs';
4
+ import { F as FilterBuilderInterface, Q as QueryBuilderInterface } from './builder-types-DlaUSc-b.cjs';
5
5
 
6
6
  /**
7
7
  * Configuration options for DynamoDB filter operations.
@@ -1,7 +1,7 @@
1
- import { C as Condition, b as ConditionOperator } from './conditions--ld9a78i.js';
1
+ import { C as Condition, b as ConditionOperator } from './conditions-BIpBkh4m.js';
2
2
  import { Paginator } from './builders/paginator.js';
3
3
  import { DynamoItem, TableConfig, GSINames } from './types.js';
4
- import { F as FilterBuilderInterface, Q as QueryBuilderInterface } from './builder-types-C_PDZhnP.js';
4
+ import { F as FilterBuilderInterface, Q as QueryBuilderInterface } from './builder-types-B_tCpn9F.js';
5
5
 
6
6
  /**
7
7
  * Configuration options for DynamoDB filter operations.
@@ -1,12 +1,12 @@
1
1
  import { DynamoItem, TableConfig, Index } from './types.cjs';
2
- import { P as PrimaryKeyWithoutExpression, a as PrimaryKey } from './conditions-ChhQWd6z.cjs';
3
- import { F as FilterBuilder, a as FilterOptions, Q as QueryBuilder } from './query-builder-D2FM9rsu.cjs';
2
+ import { P as PrimaryKeyWithoutExpression, a as PrimaryKey } from './conditions-x6kGWMR7.cjs';
3
+ import { F as FilterBuilder, a as FilterOptions, Q as QueryBuilder } from './query-builder-Dg9Loeco.cjs';
4
4
  import { PutBuilder } from './builders/put-builder.cjs';
5
5
  import { DeleteBuilder } from './builders/delete-builder.cjs';
6
6
  import { UpdateBuilder } from './builders/update-builder.cjs';
7
7
  import { TransactionBuilder, TransactionOptions } from './builders/transaction-builder.cjs';
8
8
  import { ConditionCheckBuilder } from './builders/condition-check-builder.cjs';
9
- import { S as ScanBuilderInterface } from './builder-types-DtwbqMeF.cjs';
9
+ import { S as ScanBuilderInterface } from './builder-types-DlaUSc-b.cjs';
10
10
 
11
11
  type BatchWriteOperation<T extends Record<string, unknown>> = {
12
12
  type: "put";
@@ -282,10 +282,35 @@ declare class Table<TConfig extends TableConfig = TableConfig> {
282
282
  constructor(config: TConfig);
283
283
  protected createKeyForPrimaryIndex(keyCondition: PrimaryKeyWithoutExpression): Record<string, unknown>;
284
284
  /**
285
- * Creates a new item in the table, it will fail if the item already exists
285
+ * Creates a new item in the table, it will fail if the item already exists.
286
+ *
287
+ * By default, this method returns the input values passed to the create operation
288
+ * upon successful creation.
289
+ *
290
+ * You can customise the return behaviour by chaining the `.returnValues()` method:
286
291
  *
287
292
  * @param item The item to create
288
- * @returns A PutBuilder instance for chaining conditions and executing the put operation
293
+ * @returns A PutBuilder instance for chaining additional conditions and executing the create operation
294
+ *
295
+ * @example
296
+ * ```ts
297
+ * // Create with default behavior (returns input values)
298
+ * const result = await table.create({
299
+ * id: 'user-123',
300
+ * name: 'John Doe',
301
+ * email: 'john@example.com'
302
+ * }).execute();
303
+ * console.log(result); // Returns the input object
304
+ *
305
+ * // Create with no return value for better performance
306
+ * await table.create(userData).returnValues('NONE').execute();
307
+ *
308
+ * // Create and get fresh data from dynamodb using a strongly consistent read
309
+ * const freshData = await table.create(userData).returnValues('CONSISTENT').execute();
310
+ *
311
+ * // Create and get previous values (if the item was overwritten)
312
+ * const oldData = await table.create(userData).returnValues('ALL_OLD').execute();
313
+ * ```
289
314
  */
290
315
  create<T extends DynamoItem>(item: T): PutBuilder<T>;
291
316
  get<T extends DynamoItem>(keyCondition: PrimaryKeyWithoutExpression): GetBuilder<T>;
@@ -1,12 +1,12 @@
1
1
  import { DynamoItem, TableConfig, Index } from './types.js';
2
- import { P as PrimaryKeyWithoutExpression, a as PrimaryKey } from './conditions--ld9a78i.js';
3
- import { F as FilterBuilder, a as FilterOptions, Q as QueryBuilder } from './query-builder-Csror9Iu.js';
2
+ import { P as PrimaryKeyWithoutExpression, a as PrimaryKey } from './conditions-BIpBkh4m.js';
3
+ import { F as FilterBuilder, a as FilterOptions, Q as QueryBuilder } from './query-builder-H9Dn0qaS.js';
4
4
  import { PutBuilder } from './builders/put-builder.js';
5
5
  import { DeleteBuilder } from './builders/delete-builder.js';
6
6
  import { UpdateBuilder } from './builders/update-builder.js';
7
7
  import { TransactionBuilder, TransactionOptions } from './builders/transaction-builder.js';
8
8
  import { ConditionCheckBuilder } from './builders/condition-check-builder.js';
9
- import { S as ScanBuilderInterface } from './builder-types-C_PDZhnP.js';
9
+ import { S as ScanBuilderInterface } from './builder-types-B_tCpn9F.js';
10
10
 
11
11
  type BatchWriteOperation<T extends Record<string, unknown>> = {
12
12
  type: "put";
@@ -282,10 +282,35 @@ declare class Table<TConfig extends TableConfig = TableConfig> {
282
282
  constructor(config: TConfig);
283
283
  protected createKeyForPrimaryIndex(keyCondition: PrimaryKeyWithoutExpression): Record<string, unknown>;
284
284
  /**
285
- * Creates a new item in the table, it will fail if the item already exists
285
+ * Creates a new item in the table, it will fail if the item already exists.
286
+ *
287
+ * By default, this method returns the input values passed to the create operation
288
+ * upon successful creation.
289
+ *
290
+ * You can customise the return behaviour by chaining the `.returnValues()` method:
286
291
  *
287
292
  * @param item The item to create
288
- * @returns A PutBuilder instance for chaining conditions and executing the put operation
293
+ * @returns A PutBuilder instance for chaining additional conditions and executing the create operation
294
+ *
295
+ * @example
296
+ * ```ts
297
+ * // Create with default behavior (returns input values)
298
+ * const result = await table.create({
299
+ * id: 'user-123',
300
+ * name: 'John Doe',
301
+ * email: 'john@example.com'
302
+ * }).execute();
303
+ * console.log(result); // Returns the input object
304
+ *
305
+ * // Create with no return value for better performance
306
+ * await table.create(userData).returnValues('NONE').execute();
307
+ *
308
+ * // Create and get fresh data from dynamodb using a strongly consistent read
309
+ * const freshData = await table.create(userData).returnValues('CONSISTENT').execute();
310
+ *
311
+ * // Create and get previous values (if the item was overwritten)
312
+ * const oldData = await table.create(userData).returnValues('ALL_OLD').execute();
313
+ * ```
289
314
  */
290
315
  create<T extends DynamoItem>(item: T): PutBuilder<T>;
291
316
  get<T extends DynamoItem>(keyCondition: PrimaryKeyWithoutExpression): GetBuilder<T>;
package/dist/table.cjs CHANGED
@@ -17,6 +17,11 @@ var between = (attr, lower, upper) => ({
17
17
  attr,
18
18
  value: [lower, upper]
19
19
  });
20
+ var inArray = (attr, values) => ({
21
+ type: "in",
22
+ attr,
23
+ value: values
24
+ });
20
25
  var beginsWith = createComparisonCondition("beginsWith");
21
26
  var contains = createComparisonCondition("contains");
22
27
  var attributeExists = (attr) => ({
@@ -86,6 +91,21 @@ var buildBetweenExpression = (condition, params) => {
86
91
  const upperName = generateValueName(params, condition.value[1]);
87
92
  return `${attrName} BETWEEN ${lowerName} AND ${upperName}`;
88
93
  };
94
+ var buildInExpression = (condition, params) => {
95
+ validateCondition(condition);
96
+ if (!condition.attr) {
97
+ throw new Error(`Attribute is required for ${condition.type} condition`);
98
+ }
99
+ if (!Array.isArray(condition.value) || condition.value.length === 0) {
100
+ throw new Error("In condition requires a non-empty array of values");
101
+ }
102
+ if (condition.value.length > 100) {
103
+ throw new Error("In condition supports a maximum of 100 values");
104
+ }
105
+ const attrName = generateAttributeName(params, condition.attr);
106
+ const valueNames = condition.value.map((value) => generateValueName(params, value));
107
+ return `${attrName} IN (${valueNames.join(", ")})`;
108
+ };
89
109
  var buildFunctionExpression = (functionName, condition, params) => {
90
110
  validateCondition(condition);
91
111
  if (!condition.attr) {
@@ -121,6 +141,7 @@ var buildExpression = (condition, params) => {
121
141
  gt: () => buildComparisonExpression(condition, ">", params),
122
142
  gte: () => buildComparisonExpression(condition, ">=", params),
123
143
  between: () => buildBetweenExpression(condition, params),
144
+ in: () => buildInExpression(condition, params),
124
145
  beginsWith: () => buildFunctionExpression("begins_with", condition, params),
125
146
  contains: () => buildFunctionExpression("contains", condition, params),
126
147
  attributeExists: () => buildAttributeFunction("attribute_exists", condition, params),
@@ -515,6 +536,7 @@ var FilterBuilder = class {
515
536
  gt,
516
537
  gte,
517
538
  between,
539
+ inArray,
518
540
  beginsWith,
519
541
  contains,
520
542
  attributeExists,
@@ -938,6 +960,7 @@ var PutBuilder = class {
938
960
  gt,
939
961
  gte,
940
962
  between,
963
+ inArray,
941
964
  beginsWith,
942
965
  contains,
943
966
  attributeExists,
@@ -958,7 +981,8 @@ var PutBuilder = class {
958
981
  * @options
959
982
  * - NONE: No return value
960
983
  * - ALL_OLD: Returns the item's previous state if it existed, no read capacity units are consumed
961
- * - CONSISTENT: (default) Performs a GET operation after the put to retrieve the item's new state
984
+ * - CONSISTENT: Performs a GET operation after the put to retrieve the item's new state
985
+ * - INPUT: Returns the input values that were passed to the operation
962
986
  *
963
987
  * @example
964
988
  * ```ts
@@ -977,9 +1001,14 @@ var PutBuilder = class {
977
1001
  * }
978
1002
  * });
979
1003
  * }
1004
+ *
1005
+ * // Return input values for create operations
1006
+ * const createResult = await builder
1007
+ * .returnValues('INPUT')
1008
+ * .execute();
980
1009
  * ```
981
1010
  *
982
- * @param returnValues - Use 'ALL_OLD' to return previous values if the item was overwritten, or 'NONE' (default).
1011
+ * @param returnValues - Use 'ALL_OLD' to return previous values, 'INPUT' to return input values, 'CONSISTENT' for fresh data, or 'NONE' (default).
983
1012
  * @returns The builder instance for method chaining
984
1013
  */
985
1014
  returnValues(returnValues) {
@@ -1150,6 +1179,7 @@ var DeleteBuilder = class {
1150
1179
  gt,
1151
1180
  gte,
1152
1181
  between,
1182
+ inArray,
1153
1183
  beginsWith,
1154
1184
  contains,
1155
1185
  attributeExists,
@@ -1454,6 +1484,7 @@ var UpdateBuilder = class {
1454
1484
  gt,
1455
1485
  gte,
1456
1486
  between,
1487
+ inArray,
1457
1488
  beginsWith,
1458
1489
  contains,
1459
1490
  attributeExists,
@@ -2498,6 +2529,7 @@ var ConditionCheckBuilder = class {
2498
2529
  gt,
2499
2530
  gte,
2500
2531
  between,
2532
+ inArray,
2501
2533
  beginsWith,
2502
2534
  contains,
2503
2535
  attributeExists,
@@ -2825,13 +2857,38 @@ var Table = class {
2825
2857
  return primaryCondition;
2826
2858
  }
2827
2859
  /**
2828
- * Creates a new item in the table, it will fail if the item already exists
2860
+ * Creates a new item in the table, it will fail if the item already exists.
2861
+ *
2862
+ * By default, this method returns the input values passed to the create operation
2863
+ * upon successful creation.
2864
+ *
2865
+ * You can customise the return behaviour by chaining the `.returnValues()` method:
2829
2866
  *
2830
2867
  * @param item The item to create
2831
- * @returns A PutBuilder instance for chaining conditions and executing the put operation
2868
+ * @returns A PutBuilder instance for chaining additional conditions and executing the create operation
2869
+ *
2870
+ * @example
2871
+ * ```ts
2872
+ * // Create with default behavior (returns input values)
2873
+ * const result = await table.create({
2874
+ * id: 'user-123',
2875
+ * name: 'John Doe',
2876
+ * email: 'john@example.com'
2877
+ * }).execute();
2878
+ * console.log(result); // Returns the input object
2879
+ *
2880
+ * // Create with no return value for better performance
2881
+ * await table.create(userData).returnValues('NONE').execute();
2882
+ *
2883
+ * // Create and get fresh data from dynamodb using a strongly consistent read
2884
+ * const freshData = await table.create(userData).returnValues('CONSISTENT').execute();
2885
+ *
2886
+ * // Create and get previous values (if the item was overwritten)
2887
+ * const oldData = await table.create(userData).returnValues('ALL_OLD').execute();
2888
+ * ```
2832
2889
  */
2833
2890
  create(item) {
2834
- return this.put(item).condition((op) => op.attributeNotExists(this.partitionKey));
2891
+ return this.put(item).condition((op) => op.attributeNotExists(this.partitionKey)).returnValues("INPUT");
2835
2892
  }
2836
2893
  get(keyCondition) {
2837
2894
  const executor = async (params) => {
@@ -2868,10 +2925,13 @@ var Table = class {
2868
2925
  ConditionExpression: params.conditionExpression,
2869
2926
  ExpressionAttributeNames: params.expressionAttributeNames,
2870
2927
  ExpressionAttributeValues: params.expressionAttributeValues,
2871
- // CONSISTENT is not a valid ReturnValue for DDB, so we set NONE as we are not interested in its
2872
- // response and will be reloading the item from the DB through a get instead
2873
- ReturnValues: params.returnValues === "CONSISTENT" ? "NONE" : params.returnValues
2928
+ // CONSISTENT and INPUT are not valid ReturnValues for DDB, so we set NONE as we are not interested in its
2929
+ // response and will be handling these cases separately
2930
+ ReturnValues: params.returnValues === "CONSISTENT" || params.returnValues === "INPUT" ? "NONE" : params.returnValues
2874
2931
  });
2932
+ if (params.returnValues === "INPUT") {
2933
+ return params.item;
2934
+ }
2875
2935
  if (params.returnValues === "CONSISTENT") {
2876
2936
  const getResult = await this.dynamoClient.get({
2877
2937
  TableName: params.tableName,