dyno-table 0.2.0-0 → 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/README.md +182 -577
  2. package/dist/{table.cjs → index.cjs} +175 -87
  3. package/dist/index.d.cts +2971 -0
  4. package/dist/index.d.ts +2971 -0
  5. package/dist/{table.js → index.js} +127 -86
  6. package/package.json +10 -77
  7. package/dist/builder-types-C_PDZhnP.d.ts +0 -118
  8. package/dist/builder-types-DtwbqMeF.d.cts +0 -118
  9. package/dist/builders/condition-check-builder.cjs +0 -394
  10. package/dist/builders/condition-check-builder.cjs.map +0 -1
  11. package/dist/builders/condition-check-builder.d.cts +0 -157
  12. package/dist/builders/condition-check-builder.d.ts +0 -157
  13. package/dist/builders/condition-check-builder.js +0 -392
  14. package/dist/builders/condition-check-builder.js.map +0 -1
  15. package/dist/builders/delete-builder.cjs +0 -405
  16. package/dist/builders/delete-builder.cjs.map +0 -1
  17. package/dist/builders/delete-builder.d.cts +0 -166
  18. package/dist/builders/delete-builder.d.ts +0 -166
  19. package/dist/builders/delete-builder.js +0 -403
  20. package/dist/builders/delete-builder.js.map +0 -1
  21. package/dist/builders/paginator.cjs +0 -199
  22. package/dist/builders/paginator.cjs.map +0 -1
  23. package/dist/builders/paginator.d.cts +0 -179
  24. package/dist/builders/paginator.d.ts +0 -179
  25. package/dist/builders/paginator.js +0 -197
  26. package/dist/builders/paginator.js.map +0 -1
  27. package/dist/builders/put-builder.cjs +0 -476
  28. package/dist/builders/put-builder.cjs.map +0 -1
  29. package/dist/builders/put-builder.d.cts +0 -274
  30. package/dist/builders/put-builder.d.ts +0 -274
  31. package/dist/builders/put-builder.js +0 -474
  32. package/dist/builders/put-builder.js.map +0 -1
  33. package/dist/builders/query-builder.cjs +0 -674
  34. package/dist/builders/query-builder.cjs.map +0 -1
  35. package/dist/builders/query-builder.d.cts +0 -6
  36. package/dist/builders/query-builder.d.ts +0 -6
  37. package/dist/builders/query-builder.js +0 -672
  38. package/dist/builders/query-builder.js.map +0 -1
  39. package/dist/builders/transaction-builder.cjs +0 -894
  40. package/dist/builders/transaction-builder.cjs.map +0 -1
  41. package/dist/builders/transaction-builder.d.cts +0 -511
  42. package/dist/builders/transaction-builder.d.ts +0 -511
  43. package/dist/builders/transaction-builder.js +0 -892
  44. package/dist/builders/transaction-builder.js.map +0 -1
  45. package/dist/builders/update-builder.cjs +0 -627
  46. package/dist/builders/update-builder.cjs.map +0 -1
  47. package/dist/builders/update-builder.d.cts +0 -365
  48. package/dist/builders/update-builder.d.ts +0 -365
  49. package/dist/builders/update-builder.js +0 -625
  50. package/dist/builders/update-builder.js.map +0 -1
  51. package/dist/conditions--ld9a78i.d.ts +0 -331
  52. package/dist/conditions-ChhQWd6z.d.cts +0 -331
  53. package/dist/conditions.cjs +0 -59
  54. package/dist/conditions.cjs.map +0 -1
  55. package/dist/conditions.d.cts +0 -3
  56. package/dist/conditions.d.ts +0 -3
  57. package/dist/conditions.js +0 -43
  58. package/dist/conditions.js.map +0 -1
  59. package/dist/entity.cjs +0 -228
  60. package/dist/entity.cjs.map +0 -1
  61. package/dist/entity.d.cts +0 -149
  62. package/dist/entity.d.ts +0 -149
  63. package/dist/entity.js +0 -224
  64. package/dist/entity.js.map +0 -1
  65. package/dist/query-builder-Csror9Iu.d.ts +0 -507
  66. package/dist/query-builder-D2FM9rsu.d.cts +0 -507
  67. package/dist/standard-schema.cjs +0 -4
  68. package/dist/standard-schema.cjs.map +0 -1
  69. package/dist/standard-schema.d.cts +0 -57
  70. package/dist/standard-schema.d.ts +0 -57
  71. package/dist/standard-schema.js +0 -3
  72. package/dist/standard-schema.js.map +0 -1
  73. package/dist/table-BEhBPy2G.d.cts +0 -364
  74. package/dist/table-BW3cmUqr.d.ts +0 -364
  75. package/dist/table.cjs.map +0 -1
  76. package/dist/table.d.cts +0 -12
  77. package/dist/table.d.ts +0 -12
  78. package/dist/table.js.map +0 -1
  79. package/dist/types.cjs +0 -4
  80. package/dist/types.cjs.map +0 -1
  81. package/dist/types.d.cts +0 -22
  82. package/dist/types.d.ts +0 -22
  83. package/dist/types.js +0 -3
  84. package/dist/types.js.map +0 -1
  85. package/dist/utils/partition-key-template.cjs +0 -19
  86. package/dist/utils/partition-key-template.cjs.map +0 -1
  87. package/dist/utils/partition-key-template.d.cts +0 -32
  88. package/dist/utils/partition-key-template.d.ts +0 -32
  89. package/dist/utils/partition-key-template.js +0 -17
  90. package/dist/utils/partition-key-template.js.map +0 -1
  91. package/dist/utils/sort-key-template.cjs +0 -19
  92. package/dist/utils/sort-key-template.cjs.map +0 -1
  93. package/dist/utils/sort-key-template.d.cts +0 -35
  94. package/dist/utils/sort-key-template.d.ts +0 -35
  95. package/dist/utils/sort-key-template.js +0 -17
  96. package/dist/utils/sort-key-template.js.map +0 -1
@@ -1,166 +0,0 @@
1
- import { C as Condition, P as PrimaryKeyWithoutExpression, b as ConditionOperator } from '../conditions-ChhQWd6z.cjs';
2
- import { TransactionBuilder } from './transaction-builder.cjs';
3
- import { D as DeleteCommandParams } from '../builder-types-DtwbqMeF.cjs';
4
- import { DynamoItem } from '../types.cjs';
5
- import '@aws-sdk/lib-dynamodb';
6
-
7
- interface DeleteOptions {
8
- condition?: Condition;
9
- returnValues?: "ALL_OLD";
10
- }
11
- type DeleteExecutor = (params: DeleteCommandParams) => Promise<{
12
- item?: DynamoItem;
13
- }>;
14
- /**
15
- * Builder for creating DynamoDB delete operations.
16
- *
17
- * @example
18
- * ```typescript
19
- * // Simple delete
20
- * const result = await new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
21
- * .execute();
22
- *
23
- * // Conditional delete with old value retrieval
24
- * const result = await new DeleteBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
25
- * .condition(op =>
26
- * op.and([
27
- * op.eq('status', 'DECOMMISSIONED'),
28
- * op.eq('occupants', 0),
29
- * op.lt('securityIncidents', 1)
30
- * ])
31
- * )
32
- * .returnValues('ALL_OLD')
33
- * .execute();
34
- * ```
35
- */
36
- declare class DeleteBuilder {
37
- private options;
38
- private readonly executor;
39
- private readonly tableName;
40
- private readonly key;
41
- constructor(executor: DeleteExecutor, tableName: string, key: PrimaryKeyWithoutExpression);
42
- /**
43
- * Adds a condition that must be satisfied for the delete operation to succeed.
44
- *
45
- * @example
46
- * ```typescript
47
- * // Ensure dinosaur can be safely removed
48
- * builder.condition(op =>
49
- * op.and([
50
- * op.eq('status', 'SEDATED'),
51
- * op.eq('location', 'MEDICAL_BAY'),
52
- * op.attributeExists('lastCheckup')
53
- * ])
54
- * );
55
- *
56
- * // Verify habitat is empty
57
- * builder.condition(op =>
58
- * op.and([
59
- * op.eq('occupants', 0),
60
- * op.eq('maintenanceStatus', 'COMPLETE'),
61
- * op.not(op.attributeExists('activeAlerts'))
62
- * ])
63
- * );
64
- * ```
65
- *
66
- * @param condition - Either a Condition object or a callback function that builds the condition
67
- * @returns The builder instance for method chaining
68
- */
69
- condition<T extends DynamoItem>(condition: Condition | ((op: ConditionOperator<T>) => Condition)): DeleteBuilder;
70
- /**
71
- * Sets whether to return the item's attribute values before deletion.
72
- *
73
- * @example
74
- * ```ts
75
- * // Archive dinosaur data before removal
76
- * const result = await builder
77
- * .returnValues('ALL_OLD')
78
- * .execute();
79
- *
80
- * if (result.item) {
81
- * console.log('Removed dinosaur data:', {
82
- * species: result.item.species,
83
- * age: result.item.age,
84
- * lastLocation: result.item.location
85
- * });
86
- * }
87
- * ```
88
- *
89
- * @param returnValues - Use 'ALL_OLD' to return all attributes of the deleted item
90
- * @returns The builder instance for method chaining
91
- */
92
- returnValues(returnValues: "ALL_OLD"): DeleteBuilder;
93
- /**
94
- * Generate the DynamoDB command parameters
95
- */
96
- private toDynamoCommand;
97
- /**
98
- * Adds this delete operation to a transaction.
99
- *
100
- * @example
101
- * ```ts
102
- * const transaction = new TransactionBuilder();
103
- *
104
- * // Remove dinosaur from old habitat
105
- * new DeleteBuilder(executor, 'dinosaurs', { id: 'RAPTOR-001' })
106
- * .condition(op => op.eq('status', 'SEDATED'))
107
- * .withTransaction(transaction);
108
- *
109
- * // Update old habitat occupancy
110
- * new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
111
- * .add('occupants', -1)
112
- * .withTransaction(transaction);
113
- *
114
- * // Execute transfer atomically
115
- * await transaction.execute();
116
- * ```
117
- *
118
- * @param transaction - The transaction builder to add this operation to
119
- */
120
- withTransaction(transaction: TransactionBuilder): void;
121
- /**
122
- * Executes the delete operation against DynamoDB.
123
- *
124
- * @example
125
- * ```ts
126
- * // Delete with condition and retrieve old values
127
- * const result = await new DeleteBuilder(executor, 'myTable', { id: '123' })
128
- * .condition(op => op.eq('status', 'INACTIVE'))
129
- * .returnValues('ALL_OLD')
130
- * .execute();
131
- *
132
- * if (result.item) {
133
- * console.log('Deleted item:', result.item);
134
- * }
135
- * ```
136
- *
137
- * @returns A promise that resolves to an object containing the deleted item's attributes (if returnValues is 'ALL_OLD')
138
- */
139
- execute(): Promise<{
140
- item?: DynamoItem;
141
- }>;
142
- /**
143
- * Gets a human-readable representation of the delete command
144
- * with all expression placeholders replaced by their actual values.
145
- *
146
- * @example
147
- * ```ts
148
- * const debugInfo = new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
149
- * .condition(op => op.and([
150
- * op.eq('status', 'SEDATED'),
151
- * op.eq('location', 'MEDICAL_BAY'),
152
- * op.gt('sedationLevel', 8)
153
- * op.eq('version', 1),
154
- * op.attributeExists('status')
155
- * ]))
156
- * .debug();
157
- *
158
- * console.log('Delete command:', debugInfo);
159
- * ```
160
- *
161
- * @returns A readable representation of the delete command with resolved expressions
162
- */
163
- debug(): DynamoItem;
164
- }
165
-
166
- export { DeleteBuilder, type DeleteOptions };
@@ -1,166 +0,0 @@
1
- import { C as Condition, P as PrimaryKeyWithoutExpression, b as ConditionOperator } from '../conditions--ld9a78i.js';
2
- import { TransactionBuilder } from './transaction-builder.js';
3
- import { D as DeleteCommandParams } from '../builder-types-C_PDZhnP.js';
4
- import { DynamoItem } from '../types.js';
5
- import '@aws-sdk/lib-dynamodb';
6
-
7
- interface DeleteOptions {
8
- condition?: Condition;
9
- returnValues?: "ALL_OLD";
10
- }
11
- type DeleteExecutor = (params: DeleteCommandParams) => Promise<{
12
- item?: DynamoItem;
13
- }>;
14
- /**
15
- * Builder for creating DynamoDB delete operations.
16
- *
17
- * @example
18
- * ```typescript
19
- * // Simple delete
20
- * const result = await new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
21
- * .execute();
22
- *
23
- * // Conditional delete with old value retrieval
24
- * const result = await new DeleteBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
25
- * .condition(op =>
26
- * op.and([
27
- * op.eq('status', 'DECOMMISSIONED'),
28
- * op.eq('occupants', 0),
29
- * op.lt('securityIncidents', 1)
30
- * ])
31
- * )
32
- * .returnValues('ALL_OLD')
33
- * .execute();
34
- * ```
35
- */
36
- declare class DeleteBuilder {
37
- private options;
38
- private readonly executor;
39
- private readonly tableName;
40
- private readonly key;
41
- constructor(executor: DeleteExecutor, tableName: string, key: PrimaryKeyWithoutExpression);
42
- /**
43
- * Adds a condition that must be satisfied for the delete operation to succeed.
44
- *
45
- * @example
46
- * ```typescript
47
- * // Ensure dinosaur can be safely removed
48
- * builder.condition(op =>
49
- * op.and([
50
- * op.eq('status', 'SEDATED'),
51
- * op.eq('location', 'MEDICAL_BAY'),
52
- * op.attributeExists('lastCheckup')
53
- * ])
54
- * );
55
- *
56
- * // Verify habitat is empty
57
- * builder.condition(op =>
58
- * op.and([
59
- * op.eq('occupants', 0),
60
- * op.eq('maintenanceStatus', 'COMPLETE'),
61
- * op.not(op.attributeExists('activeAlerts'))
62
- * ])
63
- * );
64
- * ```
65
- *
66
- * @param condition - Either a Condition object or a callback function that builds the condition
67
- * @returns The builder instance for method chaining
68
- */
69
- condition<T extends DynamoItem>(condition: Condition | ((op: ConditionOperator<T>) => Condition)): DeleteBuilder;
70
- /**
71
- * Sets whether to return the item's attribute values before deletion.
72
- *
73
- * @example
74
- * ```ts
75
- * // Archive dinosaur data before removal
76
- * const result = await builder
77
- * .returnValues('ALL_OLD')
78
- * .execute();
79
- *
80
- * if (result.item) {
81
- * console.log('Removed dinosaur data:', {
82
- * species: result.item.species,
83
- * age: result.item.age,
84
- * lastLocation: result.item.location
85
- * });
86
- * }
87
- * ```
88
- *
89
- * @param returnValues - Use 'ALL_OLD' to return all attributes of the deleted item
90
- * @returns The builder instance for method chaining
91
- */
92
- returnValues(returnValues: "ALL_OLD"): DeleteBuilder;
93
- /**
94
- * Generate the DynamoDB command parameters
95
- */
96
- private toDynamoCommand;
97
- /**
98
- * Adds this delete operation to a transaction.
99
- *
100
- * @example
101
- * ```ts
102
- * const transaction = new TransactionBuilder();
103
- *
104
- * // Remove dinosaur from old habitat
105
- * new DeleteBuilder(executor, 'dinosaurs', { id: 'RAPTOR-001' })
106
- * .condition(op => op.eq('status', 'SEDATED'))
107
- * .withTransaction(transaction);
108
- *
109
- * // Update old habitat occupancy
110
- * new UpdateBuilder(executor, 'habitats', { id: 'PADDOCK-A' })
111
- * .add('occupants', -1)
112
- * .withTransaction(transaction);
113
- *
114
- * // Execute transfer atomically
115
- * await transaction.execute();
116
- * ```
117
- *
118
- * @param transaction - The transaction builder to add this operation to
119
- */
120
- withTransaction(transaction: TransactionBuilder): void;
121
- /**
122
- * Executes the delete operation against DynamoDB.
123
- *
124
- * @example
125
- * ```ts
126
- * // Delete with condition and retrieve old values
127
- * const result = await new DeleteBuilder(executor, 'myTable', { id: '123' })
128
- * .condition(op => op.eq('status', 'INACTIVE'))
129
- * .returnValues('ALL_OLD')
130
- * .execute();
131
- *
132
- * if (result.item) {
133
- * console.log('Deleted item:', result.item);
134
- * }
135
- * ```
136
- *
137
- * @returns A promise that resolves to an object containing the deleted item's attributes (if returnValues is 'ALL_OLD')
138
- */
139
- execute(): Promise<{
140
- item?: DynamoItem;
141
- }>;
142
- /**
143
- * Gets a human-readable representation of the delete command
144
- * with all expression placeholders replaced by their actual values.
145
- *
146
- * @example
147
- * ```ts
148
- * const debugInfo = new DeleteBuilder(executor, 'dinosaurs', { id: 'TREX-001' })
149
- * .condition(op => op.and([
150
- * op.eq('status', 'SEDATED'),
151
- * op.eq('location', 'MEDICAL_BAY'),
152
- * op.gt('sedationLevel', 8)
153
- * op.eq('version', 1),
154
- * op.attributeExists('status')
155
- * ]))
156
- * .debug();
157
- *
158
- * console.log('Delete command:', debugInfo);
159
- * ```
160
- *
161
- * @returns A readable representation of the delete command with resolved expressions
162
- */
163
- debug(): DynamoItem;
164
- }
165
-
166
- export { DeleteBuilder, type DeleteOptions };