dyno-table 2.2.0 → 2.3.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 (106) hide show
  1. package/README.md +200 -1860
  2. package/dist/builders.cjs +55 -0
  3. package/dist/builders.d.cts +4 -0
  4. package/dist/builders.d.ts +4 -0
  5. package/dist/builders.js +2 -0
  6. package/dist/chunk-2EWNZOUK.js +618 -0
  7. package/dist/chunk-2WIBY7PZ.js +46 -0
  8. package/dist/chunk-7UJJ7JXM.cjs +63 -0
  9. package/dist/chunk-DTFJJASK.js +3200 -0
  10. package/dist/chunk-EODPMYPE.js +558 -0
  11. package/dist/chunk-KA3VPIPS.cjs +560 -0
  12. package/dist/chunk-NTA6GDPP.cjs +622 -0
  13. package/dist/chunk-PB7BBCZO.cjs +32 -0
  14. package/dist/chunk-QVRMYGC4.js +29 -0
  15. package/dist/chunk-XYL43FDX.cjs +3217 -0
  16. package/dist/{conditions-CC3NDfUU.d.cts → conditions-CcZL0sR2.d.cts} +1 -1
  17. package/dist/{conditions-DD0bvyHm.d.ts → conditions-D_w7vVYG.d.ts} +1 -1
  18. package/dist/conditions.cjs +67 -62
  19. package/dist/conditions.d.cts +1 -1
  20. package/dist/conditions.d.ts +1 -1
  21. package/dist/conditions.js +1 -48
  22. package/dist/entity.cjs +14 -625
  23. package/dist/entity.d.cts +5 -13
  24. package/dist/entity.d.ts +5 -13
  25. package/dist/entity.js +2 -626
  26. package/dist/index-2cbm07Bi.d.ts +2797 -0
  27. package/dist/index-DlN8G9hd.d.cts +2797 -0
  28. package/dist/index.cjs +111 -4446
  29. package/dist/index.d.cts +3 -11
  30. package/dist/index.d.ts +3 -11
  31. package/dist/index.js +5 -4428
  32. package/dist/standard-schema.cjs +0 -2
  33. package/dist/standard-schema.js +0 -2
  34. package/dist/table.cjs +7 -3782
  35. package/dist/table.d.cts +163 -12
  36. package/dist/table.d.ts +163 -12
  37. package/dist/table.js +3 -3785
  38. package/dist/types.cjs +0 -2
  39. package/dist/types.js +0 -2
  40. package/dist/utils.cjs +10 -30
  41. package/dist/utils.js +1 -31
  42. package/package.json +12 -67
  43. package/dist/batch-builder-BPoHyN_Q.d.cts +0 -398
  44. package/dist/batch-builder-Cdo49C2r.d.ts +0 -398
  45. package/dist/builder-types-BTVhQSHI.d.cts +0 -169
  46. package/dist/builder-types-CzuLR4Th.d.ts +0 -169
  47. package/dist/builders/condition-check-builder.cjs +0 -422
  48. package/dist/builders/condition-check-builder.cjs.map +0 -1
  49. package/dist/builders/condition-check-builder.d.cts +0 -153
  50. package/dist/builders/condition-check-builder.d.ts +0 -153
  51. package/dist/builders/condition-check-builder.js +0 -420
  52. package/dist/builders/condition-check-builder.js.map +0 -1
  53. package/dist/builders/delete-builder.cjs +0 -484
  54. package/dist/builders/delete-builder.cjs.map +0 -1
  55. package/dist/builders/delete-builder.d.cts +0 -211
  56. package/dist/builders/delete-builder.d.ts +0 -211
  57. package/dist/builders/delete-builder.js +0 -482
  58. package/dist/builders/delete-builder.js.map +0 -1
  59. package/dist/builders/paginator.cjs +0 -193
  60. package/dist/builders/paginator.cjs.map +0 -1
  61. package/dist/builders/paginator.d.cts +0 -155
  62. package/dist/builders/paginator.d.ts +0 -155
  63. package/dist/builders/paginator.js +0 -191
  64. package/dist/builders/paginator.js.map +0 -1
  65. package/dist/builders/put-builder.cjs +0 -554
  66. package/dist/builders/put-builder.cjs.map +0 -1
  67. package/dist/builders/put-builder.d.cts +0 -319
  68. package/dist/builders/put-builder.d.ts +0 -319
  69. package/dist/builders/put-builder.js +0 -552
  70. package/dist/builders/put-builder.js.map +0 -1
  71. package/dist/builders/query-builder.cjs +0 -743
  72. package/dist/builders/query-builder.cjs.map +0 -1
  73. package/dist/builders/query-builder.d.cts +0 -6
  74. package/dist/builders/query-builder.d.ts +0 -6
  75. package/dist/builders/query-builder.js +0 -741
  76. package/dist/builders/query-builder.js.map +0 -1
  77. package/dist/builders/transaction-builder.cjs +0 -906
  78. package/dist/builders/transaction-builder.cjs.map +0 -1
  79. package/dist/builders/transaction-builder.d.cts +0 -464
  80. package/dist/builders/transaction-builder.d.ts +0 -464
  81. package/dist/builders/transaction-builder.js +0 -904
  82. package/dist/builders/transaction-builder.js.map +0 -1
  83. package/dist/builders/update-builder.cjs +0 -668
  84. package/dist/builders/update-builder.cjs.map +0 -1
  85. package/dist/builders/update-builder.d.cts +0 -374
  86. package/dist/builders/update-builder.d.ts +0 -374
  87. package/dist/builders/update-builder.js +0 -666
  88. package/dist/builders/update-builder.js.map +0 -1
  89. package/dist/conditions.cjs.map +0 -1
  90. package/dist/conditions.js.map +0 -1
  91. package/dist/entity.cjs.map +0 -1
  92. package/dist/entity.js.map +0 -1
  93. package/dist/index.cjs.map +0 -1
  94. package/dist/index.js.map +0 -1
  95. package/dist/query-builder-CUWdavZw.d.ts +0 -477
  96. package/dist/query-builder-DoZzZz_c.d.cts +0 -477
  97. package/dist/standard-schema.cjs.map +0 -1
  98. package/dist/standard-schema.js.map +0 -1
  99. package/dist/table-CZBMkW2Z.d.ts +0 -276
  100. package/dist/table-f-3wsT7K.d.cts +0 -276
  101. package/dist/table.cjs.map +0 -1
  102. package/dist/table.js.map +0 -1
  103. package/dist/types.cjs.map +0 -1
  104. package/dist/types.js.map +0 -1
  105. package/dist/utils.cjs.map +0 -1
  106. package/dist/utils.js.map +0 -1
@@ -1,211 +0,0 @@
1
- import { r as PrimaryKeyWithoutExpression, C as Condition, q as ConditionOperator } from '../conditions-CC3NDfUU.cjs';
2
- import { TransactionBuilder } from './transaction-builder.cjs';
3
- import { B as BatchBuilder } from '../batch-builder-BPoHyN_Q.cjs';
4
- import { D as DeleteCommandParams } from '../builder-types-BTVhQSHI.cjs';
5
- import { DynamoItem } from '../types.cjs';
6
- import '@aws-sdk/lib-dynamodb';
7
-
8
- interface DeleteOptions {
9
- condition?: Condition;
10
- returnValues?: "ALL_OLD";
11
- }
12
- type DeleteExecutor = (params: DeleteCommandParams) => Promise<{
13
- item?: DynamoItem;
14
- }>;
15
- /**
16
- * Builder for creating DynamoDB delete operations.
17
- *
18
- * @example
19
- * ```typescript
20
- * // Simple delete
21
- * const result = await new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
22
- * .execute();
23
- *
24
- * // Conditional delete with old value retrieval
25
- * const result = await new DeleteBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
26
- * .condition(op =>
27
- * op.and([
28
- * op.eq('status', 'DECOMMISSIONED'),
29
- * op.eq('occupants', 0),
30
- * op.lt('securityIncidents', 1)
31
- * ])
32
- * )
33
- * .returnValues('ALL_OLD')
34
- * .execute();
35
- * ```
36
- */
37
- declare class DeleteBuilder {
38
- private options;
39
- private readonly executor;
40
- private readonly tableName;
41
- private readonly key;
42
- constructor(executor: DeleteExecutor, tableName: string, key: PrimaryKeyWithoutExpression);
43
- /**
44
- * Adds a condition that must be satisfied for the delete operation to succeed.
45
- *
46
- * @example
47
- * ```typescript
48
- * // Ensure dinosaur can be safely removed
49
- * builder.condition(op =>
50
- * op.and([
51
- * op.eq('status', 'SEDATED'),
52
- * op.eq('location', 'MEDICAL_BAY'),
53
- * op.attributeExists('lastCheckup')
54
- * ])
55
- * );
56
- *
57
- * // Verify habitat is empty
58
- * builder.condition(op =>
59
- * op.and([
60
- * op.eq('occupants', 0),
61
- * op.eq('maintenanceStatus', 'COMPLETE'),
62
- * op.not(op.attributeExists('activeAlerts'))
63
- * ])
64
- * );
65
- * ```
66
- *
67
- * @param condition - Either a Condition object or a callback function that builds the condition
68
- * @returns The builder instance for method chaining
69
- */
70
- condition<T extends DynamoItem>(condition: Condition | ((op: ConditionOperator<T>) => Condition)): DeleteBuilder;
71
- /**
72
- * Sets whether to return the item's attribute values before deletion.
73
- *
74
- * @example
75
- * ```ts
76
- * // Archive dinosaur data before removal
77
- * const result = await builder
78
- * .returnValues('ALL_OLD')
79
- * .execute();
80
- *
81
- * if (result.item) {
82
- * console.log('Removed dinosaur data:', {
83
- * species: result.item.species,
84
- * age: result.item.age,
85
- * lastLocation: result.item.location
86
- * });
87
- * }
88
- * ```
89
- *
90
- * @param returnValues - Use 'ALL_OLD' to return all attributes of the deleted item
91
- * @returns The builder instance for method chaining
92
- */
93
- returnValues(returnValues: "ALL_OLD"): DeleteBuilder;
94
- /**
95
- * Generate the DynamoDB command parameters
96
- */
97
- private toDynamoCommand;
98
- /**
99
- * Adds this delete operation to a transaction.
100
- *
101
- * @example
102
- * ```ts
103
- * const transaction = new TransactionBuilder();
104
- *
105
- * // Remove dinosaur from old habitat
106
- * new DeleteBuilder(executor, 'dinosaurs', { id: 'RAPTOR-001' })
107
- * .condition(op => op.eq('status', 'SEDATED'))
108
- * .withTransaction(transaction);
109
- *
110
- * // Update old habitat occupancy
111
- * new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
112
- * .add('occupants', -1)
113
- * .withTransaction(transaction);
114
- *
115
- * // Execute transfer atomically
116
- * await transaction.execute();
117
- * ```
118
- *
119
- * @param transaction - The transaction builder to add this operation to
120
- */
121
- withTransaction(transaction: TransactionBuilder): void;
122
- /**
123
- * Adds this delete operation to a batch with optional entity type information.
124
- *
125
- * @example Basic Usage
126
- * ```ts
127
- * const batch = table.batchBuilder();
128
- *
129
- * // Remove multiple dinosaurs in batch
130
- * dinosaurRepo.delete({ id: 'old-dino-1' }).withBatch(batch);
131
- * dinosaurRepo.delete({ id: 'old-dino-2' }).withBatch(batch);
132
- * dinosaurRepo.delete({ id: 'old-dino-3' }).withBatch(batch);
133
- *
134
- * // Execute all deletions efficiently
135
- * await batch.execute();
136
- * ```
137
- *
138
- * @example Typed Usage
139
- * ```ts
140
- * const batch = table.batchBuilder<{
141
- * User: UserEntity;
142
- * Order: OrderEntity;
143
- * }>();
144
- *
145
- * // Add operations with type information
146
- * userRepo.delete({ id: 'user-1' }).withBatch(batch, 'User');
147
- * orderRepo.delete({ id: 'order-1' }).withBatch(batch, 'Order');
148
- *
149
- * // Execute batch operations
150
- * await batch.execute();
151
- * ```
152
- *
153
- * @param batch - The batch builder to add this operation to
154
- * @param entityType - Optional entity type key for type tracking
155
- */
156
- withBatch<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>, K extends keyof TEntities = keyof TEntities>(batch: BatchBuilder<TEntities>, entityType?: K): void;
157
- /**
158
- * Executes the delete operation against DynamoDB.
159
- *
160
- * @example
161
- * ```ts
162
- * // Delete with condition and retrieve old values
163
- * const result = await new DeleteBuilder(executor, 'myTable', { id: '123' })
164
- * .condition(op => op.eq('status', 'INACTIVE'))
165
- * .returnValues('ALL_OLD')
166
- * .execute();
167
- *
168
- * if (result.item) {
169
- * console.log('Deleted item:', result.item);
170
- * }
171
- * ```
172
- *
173
- * @returns A promise that resolves to an object containing the deleted item's attributes (if returnValues is 'ALL_OLD')
174
- */
175
- execute(): Promise<{
176
- item?: DynamoItem;
177
- }>;
178
- /**
179
- * Gets a human-readable representation of the delete command
180
- * with all expression placeholders replaced by their actual values.
181
- *
182
- * @example
183
- * ```ts
184
- * const debugInfo = new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
185
- * .condition(op => op.and([
186
- * op.eq('status', 'SEDATED'),
187
- * op.eq('location', 'MEDICAL_BAY'),
188
- * op.gt('sedationLevel', 8)
189
- * op.eq('version', 1),
190
- * op.attributeExists('status')
191
- * ]))
192
- * .debug();
193
- *
194
- * console.log('Delete command:', debugInfo);
195
- * ```
196
- *
197
- * @returns A readable representation of the delete command with resolved expressions
198
- */
199
- debug(): {
200
- raw: DeleteCommandParams;
201
- readable: {
202
- conditionExpression?: string;
203
- updateExpression?: string;
204
- filterExpression?: string;
205
- keyConditionExpression?: string;
206
- projectionExpression?: string;
207
- };
208
- };
209
- }
210
-
211
- export { DeleteBuilder, type DeleteOptions };
@@ -1,211 +0,0 @@
1
- import { r as PrimaryKeyWithoutExpression, C as Condition, q as ConditionOperator } from '../conditions-DD0bvyHm.js';
2
- import { TransactionBuilder } from './transaction-builder.js';
3
- import { B as BatchBuilder } from '../batch-builder-Cdo49C2r.js';
4
- import { D as DeleteCommandParams } from '../builder-types-CzuLR4Th.js';
5
- import { DynamoItem } from '../types.js';
6
- import '@aws-sdk/lib-dynamodb';
7
-
8
- interface DeleteOptions {
9
- condition?: Condition;
10
- returnValues?: "ALL_OLD";
11
- }
12
- type DeleteExecutor = (params: DeleteCommandParams) => Promise<{
13
- item?: DynamoItem;
14
- }>;
15
- /**
16
- * Builder for creating DynamoDB delete operations.
17
- *
18
- * @example
19
- * ```typescript
20
- * // Simple delete
21
- * const result = await new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
22
- * .execute();
23
- *
24
- * // Conditional delete with old value retrieval
25
- * const result = await new DeleteBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
26
- * .condition(op =>
27
- * op.and([
28
- * op.eq('status', 'DECOMMISSIONED'),
29
- * op.eq('occupants', 0),
30
- * op.lt('securityIncidents', 1)
31
- * ])
32
- * )
33
- * .returnValues('ALL_OLD')
34
- * .execute();
35
- * ```
36
- */
37
- declare class DeleteBuilder {
38
- private options;
39
- private readonly executor;
40
- private readonly tableName;
41
- private readonly key;
42
- constructor(executor: DeleteExecutor, tableName: string, key: PrimaryKeyWithoutExpression);
43
- /**
44
- * Adds a condition that must be satisfied for the delete operation to succeed.
45
- *
46
- * @example
47
- * ```typescript
48
- * // Ensure dinosaur can be safely removed
49
- * builder.condition(op =>
50
- * op.and([
51
- * op.eq('status', 'SEDATED'),
52
- * op.eq('location', 'MEDICAL_BAY'),
53
- * op.attributeExists('lastCheckup')
54
- * ])
55
- * );
56
- *
57
- * // Verify habitat is empty
58
- * builder.condition(op =>
59
- * op.and([
60
- * op.eq('occupants', 0),
61
- * op.eq('maintenanceStatus', 'COMPLETE'),
62
- * op.not(op.attributeExists('activeAlerts'))
63
- * ])
64
- * );
65
- * ```
66
- *
67
- * @param condition - Either a Condition object or a callback function that builds the condition
68
- * @returns The builder instance for method chaining
69
- */
70
- condition<T extends DynamoItem>(condition: Condition | ((op: ConditionOperator<T>) => Condition)): DeleteBuilder;
71
- /**
72
- * Sets whether to return the item's attribute values before deletion.
73
- *
74
- * @example
75
- * ```ts
76
- * // Archive dinosaur data before removal
77
- * const result = await builder
78
- * .returnValues('ALL_OLD')
79
- * .execute();
80
- *
81
- * if (result.item) {
82
- * console.log('Removed dinosaur data:', {
83
- * species: result.item.species,
84
- * age: result.item.age,
85
- * lastLocation: result.item.location
86
- * });
87
- * }
88
- * ```
89
- *
90
- * @param returnValues - Use 'ALL_OLD' to return all attributes of the deleted item
91
- * @returns The builder instance for method chaining
92
- */
93
- returnValues(returnValues: "ALL_OLD"): DeleteBuilder;
94
- /**
95
- * Generate the DynamoDB command parameters
96
- */
97
- private toDynamoCommand;
98
- /**
99
- * Adds this delete operation to a transaction.
100
- *
101
- * @example
102
- * ```ts
103
- * const transaction = new TransactionBuilder();
104
- *
105
- * // Remove dinosaur from old habitat
106
- * new DeleteBuilder(executor, 'dinosaurs', { id: 'RAPTOR-001' })
107
- * .condition(op => op.eq('status', 'SEDATED'))
108
- * .withTransaction(transaction);
109
- *
110
- * // Update old habitat occupancy
111
- * new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
112
- * .add('occupants', -1)
113
- * .withTransaction(transaction);
114
- *
115
- * // Execute transfer atomically
116
- * await transaction.execute();
117
- * ```
118
- *
119
- * @param transaction - The transaction builder to add this operation to
120
- */
121
- withTransaction(transaction: TransactionBuilder): void;
122
- /**
123
- * Adds this delete operation to a batch with optional entity type information.
124
- *
125
- * @example Basic Usage
126
- * ```ts
127
- * const batch = table.batchBuilder();
128
- *
129
- * // Remove multiple dinosaurs in batch
130
- * dinosaurRepo.delete({ id: 'old-dino-1' }).withBatch(batch);
131
- * dinosaurRepo.delete({ id: 'old-dino-2' }).withBatch(batch);
132
- * dinosaurRepo.delete({ id: 'old-dino-3' }).withBatch(batch);
133
- *
134
- * // Execute all deletions efficiently
135
- * await batch.execute();
136
- * ```
137
- *
138
- * @example Typed Usage
139
- * ```ts
140
- * const batch = table.batchBuilder<{
141
- * User: UserEntity;
142
- * Order: OrderEntity;
143
- * }>();
144
- *
145
- * // Add operations with type information
146
- * userRepo.delete({ id: 'user-1' }).withBatch(batch, 'User');
147
- * orderRepo.delete({ id: 'order-1' }).withBatch(batch, 'Order');
148
- *
149
- * // Execute batch operations
150
- * await batch.execute();
151
- * ```
152
- *
153
- * @param batch - The batch builder to add this operation to
154
- * @param entityType - Optional entity type key for type tracking
155
- */
156
- withBatch<TEntities extends Record<string, DynamoItem> = Record<string, DynamoItem>, K extends keyof TEntities = keyof TEntities>(batch: BatchBuilder<TEntities>, entityType?: K): void;
157
- /**
158
- * Executes the delete operation against DynamoDB.
159
- *
160
- * @example
161
- * ```ts
162
- * // Delete with condition and retrieve old values
163
- * const result = await new DeleteBuilder(executor, 'myTable', { id: '123' })
164
- * .condition(op => op.eq('status', 'INACTIVE'))
165
- * .returnValues('ALL_OLD')
166
- * .execute();
167
- *
168
- * if (result.item) {
169
- * console.log('Deleted item:', result.item);
170
- * }
171
- * ```
172
- *
173
- * @returns A promise that resolves to an object containing the deleted item's attributes (if returnValues is 'ALL_OLD')
174
- */
175
- execute(): Promise<{
176
- item?: DynamoItem;
177
- }>;
178
- /**
179
- * Gets a human-readable representation of the delete command
180
- * with all expression placeholders replaced by their actual values.
181
- *
182
- * @example
183
- * ```ts
184
- * const debugInfo = new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
185
- * .condition(op => op.and([
186
- * op.eq('status', 'SEDATED'),
187
- * op.eq('location', 'MEDICAL_BAY'),
188
- * op.gt('sedationLevel', 8)
189
- * op.eq('version', 1),
190
- * op.attributeExists('status')
191
- * ]))
192
- * .debug();
193
- *
194
- * console.log('Delete command:', debugInfo);
195
- * ```
196
- *
197
- * @returns A readable representation of the delete command with resolved expressions
198
- */
199
- debug(): {
200
- raw: DeleteCommandParams;
201
- readable: {
202
- conditionExpression?: string;
203
- updateExpression?: string;
204
- filterExpression?: string;
205
- keyConditionExpression?: string;
206
- projectionExpression?: string;
207
- };
208
- };
209
- }
210
-
211
- export { DeleteBuilder, type DeleteOptions };