dyno-table 2.2.1 → 2.3.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 (102) hide show
  1. package/README.md +187 -1865
  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.cjs +67 -62
  17. package/dist/conditions.js +1 -48
  18. package/dist/entity.cjs +14 -625
  19. package/dist/entity.d.cts +2 -10
  20. package/dist/entity.d.ts +2 -10
  21. package/dist/entity.js +2 -626
  22. package/dist/index-2cbm07Bi.d.ts +2797 -0
  23. package/dist/index-DlN8G9hd.d.cts +2797 -0
  24. package/dist/index.cjs +111 -4460
  25. package/dist/index.d.cts +2 -10
  26. package/dist/index.d.ts +2 -10
  27. package/dist/index.js +5 -4442
  28. package/dist/standard-schema.cjs +0 -2
  29. package/dist/standard-schema.js +0 -2
  30. package/dist/table.cjs +7 -3796
  31. package/dist/table.d.cts +163 -12
  32. package/dist/table.d.ts +163 -12
  33. package/dist/table.js +3 -3799
  34. package/dist/types.cjs +0 -2
  35. package/dist/types.js +0 -2
  36. package/dist/utils.cjs +10 -30
  37. package/dist/utils.js +1 -31
  38. package/package.json +6 -66
  39. package/dist/batch-builder-BiQDIZ7p.d.cts +0 -398
  40. package/dist/batch-builder-CNsLS6sR.d.ts +0 -398
  41. package/dist/builder-types-BTVhQSHI.d.cts +0 -169
  42. package/dist/builder-types-CzuLR4Th.d.ts +0 -169
  43. package/dist/builders/condition-check-builder.cjs +0 -422
  44. package/dist/builders/condition-check-builder.cjs.map +0 -1
  45. package/dist/builders/condition-check-builder.d.cts +0 -153
  46. package/dist/builders/condition-check-builder.d.ts +0 -153
  47. package/dist/builders/condition-check-builder.js +0 -420
  48. package/dist/builders/condition-check-builder.js.map +0 -1
  49. package/dist/builders/delete-builder.cjs +0 -484
  50. package/dist/builders/delete-builder.cjs.map +0 -1
  51. package/dist/builders/delete-builder.d.cts +0 -211
  52. package/dist/builders/delete-builder.d.ts +0 -211
  53. package/dist/builders/delete-builder.js +0 -482
  54. package/dist/builders/delete-builder.js.map +0 -1
  55. package/dist/builders/paginator.cjs +0 -193
  56. package/dist/builders/paginator.cjs.map +0 -1
  57. package/dist/builders/paginator.d.cts +0 -155
  58. package/dist/builders/paginator.d.ts +0 -155
  59. package/dist/builders/paginator.js +0 -191
  60. package/dist/builders/paginator.js.map +0 -1
  61. package/dist/builders/put-builder.cjs +0 -554
  62. package/dist/builders/put-builder.cjs.map +0 -1
  63. package/dist/builders/put-builder.d.cts +0 -319
  64. package/dist/builders/put-builder.d.ts +0 -319
  65. package/dist/builders/put-builder.js +0 -552
  66. package/dist/builders/put-builder.js.map +0 -1
  67. package/dist/builders/query-builder.cjs +0 -757
  68. package/dist/builders/query-builder.cjs.map +0 -1
  69. package/dist/builders/query-builder.d.cts +0 -6
  70. package/dist/builders/query-builder.d.ts +0 -6
  71. package/dist/builders/query-builder.js +0 -755
  72. package/dist/builders/query-builder.js.map +0 -1
  73. package/dist/builders/transaction-builder.cjs +0 -906
  74. package/dist/builders/transaction-builder.cjs.map +0 -1
  75. package/dist/builders/transaction-builder.d.cts +0 -464
  76. package/dist/builders/transaction-builder.d.ts +0 -464
  77. package/dist/builders/transaction-builder.js +0 -904
  78. package/dist/builders/transaction-builder.js.map +0 -1
  79. package/dist/builders/update-builder.cjs +0 -668
  80. package/dist/builders/update-builder.cjs.map +0 -1
  81. package/dist/builders/update-builder.d.cts +0 -374
  82. package/dist/builders/update-builder.d.ts +0 -374
  83. package/dist/builders/update-builder.js +0 -666
  84. package/dist/builders/update-builder.js.map +0 -1
  85. package/dist/conditions.cjs.map +0 -1
  86. package/dist/conditions.js.map +0 -1
  87. package/dist/entity.cjs.map +0 -1
  88. package/dist/entity.js.map +0 -1
  89. package/dist/index.cjs.map +0 -1
  90. package/dist/index.js.map +0 -1
  91. package/dist/query-builder-D3URwK9k.d.cts +0 -477
  92. package/dist/query-builder-cfEkU0_w.d.ts +0 -477
  93. package/dist/standard-schema.cjs.map +0 -1
  94. package/dist/standard-schema.js.map +0 -1
  95. package/dist/table-ClST8nkR.d.cts +0 -276
  96. package/dist/table-vE3cGoDy.d.ts +0 -276
  97. package/dist/table.cjs.map +0 -1
  98. package/dist/table.js.map +0 -1
  99. package/dist/types.cjs.map +0 -1
  100. package/dist/types.js.map +0 -1
  101. package/dist/utils.cjs.map +0 -1
  102. package/dist/utils.js.map +0 -1
@@ -1,193 +0,0 @@
1
- 'use strict';
2
-
3
- // src/builders/paginator.ts
4
- var Paginator = class {
5
- queryBuilder;
6
- pageSize;
7
- currentPage = 0;
8
- lastEvaluatedKey;
9
- hasMorePages = true;
10
- totalItemsRetrieved = 0;
11
- overallLimit;
12
- constructor(queryBuilder, pageSize) {
13
- this.queryBuilder = queryBuilder;
14
- this.pageSize = pageSize;
15
- this.overallLimit = queryBuilder.getLimit();
16
- }
17
- /**
18
- * Gets the current page number (1-indexed).
19
- *
20
- * @example
21
- * ```ts
22
- * const paginator = new QueryBuilder(executor, eq('species', 'Tyrannosaurus'))
23
- * .paginate(5);
24
- *
25
- * await paginator.getNextPage();
26
- * console.log(`Reviewing T-Rex group ${paginator.getCurrentPage()}`);
27
- * ```
28
- *
29
- * @returns The current page number, starting from 1
30
- */
31
- getCurrentPage() {
32
- return this.currentPage;
33
- }
34
- /**
35
- * Checks if there are more pages of dinosaurs or habitats to process.
36
- *
37
- * This method takes into account both:
38
- * - DynamoDB's lastEvaluatedKey mechanism
39
- * - Any overall limit set on the query
40
- *
41
- * @example
42
- * ```ts
43
- * // Process all security incidents
44
- * const paginator = new QueryBuilder(executor, eq('type', 'SECURITY_BREACH'))
45
- * .sortDescending()
46
- * .paginate(10);
47
- *
48
- * while (paginator.hasNextPage()) {
49
- * const page = await paginator.getNextPage();
50
- * for (const incident of page.items) {
51
- * await processSecurityBreach(incident);
52
- * }
53
- * console.log(`Processed incidents page ${page.page}`);
54
- * }
55
- * ```
56
- *
57
- * @returns true if there are more pages available, false otherwise
58
- */
59
- hasNextPage() {
60
- if (this.overallLimit !== void 0 && this.totalItemsRetrieved >= this.overallLimit) {
61
- return false;
62
- }
63
- return this.hasMorePages;
64
- }
65
- /**
66
- * Retrieves the next page of dinosaurs or habitats from DynamoDB.
67
- *
68
- * This method handles:
69
- * - Automatic continuation between groups
70
- * - Respect for park capacity limits
71
- * - Group size adjustments for safety
72
- *
73
- * @example
74
- * ```ts
75
- * const paginator = new QueryBuilder(executor, eq('species', 'Velociraptor'))
76
- * .filter(op => op.eq('status', 'ACTIVE'))
77
- * .paginate(5);
78
- *
79
- * // Check first raptor group
80
- * const page1 = await paginator.getNextPage();
81
- * console.log(`Found ${page1.items.length} active raptors`);
82
- *
83
- * // Continue inspection if more groups exist
84
- * if (page1.hasNextPage) {
85
- * const page2 = await paginator.getNextPage();
86
- * console.log(`Inspecting raptor group ${page2.page}`);
87
- *
88
- * for (const raptor of page2.items) {
89
- * await performHealthCheck(raptor);
90
- * }
91
- * }
92
- * ```
93
- *
94
- * @returns A promise that resolves to a PaginationResult containing:
95
- * - items: The dinosaurs/habitats for this page
96
- * - hasNextPage: Whether more groups exist
97
- * - page: The current group number
98
- * - lastEvaluatedKey: DynamoDB's continuation token
99
- */
100
- async getNextPage() {
101
- if (!this.hasNextPage()) {
102
- return {
103
- items: [],
104
- hasNextPage: false,
105
- page: this.currentPage
106
- };
107
- }
108
- let effectivePageSize = this.pageSize;
109
- if (this.overallLimit !== void 0) {
110
- const remainingItems = this.overallLimit - this.totalItemsRetrieved;
111
- if (remainingItems <= 0) {
112
- return {
113
- items: [],
114
- hasNextPage: false,
115
- page: this.currentPage
116
- };
117
- }
118
- if (effectivePageSize !== void 0) {
119
- effectivePageSize = Math.min(effectivePageSize, remainingItems);
120
- } else {
121
- effectivePageSize = remainingItems;
122
- }
123
- }
124
- const query = this.queryBuilder.clone();
125
- if (effectivePageSize !== void 0) {
126
- query.limit(effectivePageSize);
127
- }
128
- if (this.lastEvaluatedKey) {
129
- query.startFrom(this.lastEvaluatedKey);
130
- }
131
- const generator = await query.execute();
132
- const items = [];
133
- let itemCount = 0;
134
- for await (const item of generator) {
135
- if (effectivePageSize !== void 0 && itemCount >= effectivePageSize) {
136
- break;
137
- }
138
- items.push(item);
139
- itemCount++;
140
- }
141
- const lastEvaluatedKey = generator.getLastEvaluatedKey();
142
- const result = { items, lastEvaluatedKey };
143
- this.currentPage += 1;
144
- this.lastEvaluatedKey = result.lastEvaluatedKey;
145
- this.totalItemsRetrieved += result.items.length;
146
- this.hasMorePages = !!result.lastEvaluatedKey && (this.overallLimit === void 0 || this.totalItemsRetrieved < this.overallLimit);
147
- return {
148
- items: result.items,
149
- lastEvaluatedKey: result.lastEvaluatedKey,
150
- hasNextPage: this.hasNextPage(),
151
- page: this.currentPage
152
- };
153
- }
154
- /**
155
- * Gets all remaining dinosaurs or habitats and combines them into a single array.
156
- *
157
- * @example
158
- * ```ts
159
- * // Get complete carnivore inventory
160
- * const paginator = new QueryBuilder(executor, eq('diet', 'CARNIVORE'))
161
- * .filter(op => op.eq('status', 'ACTIVE'))
162
- * .paginate(10);
163
- *
164
- * try {
165
- * const allCarnivores = await paginator.getAllPages();
166
- * console.log(`Park contains ${allCarnivores.length} active carnivores`);
167
- *
168
- * // Calculate total threat level
169
- * const totalThreat = allCarnivores.reduce(
170
- * (sum, dino) => sum + dino.stats.threatLevel,
171
- * 0
172
- * );
173
- * console.log(`Total threat level: ${totalThreat}`);
174
- * } catch (error) {
175
- * console.error('Failed to complete carnivore census:', error);
176
- * }
177
- * ```
178
- *
179
- * @returns A promise that resolves to an array containing all remaining items
180
- */
181
- async getAllPages() {
182
- const allItems = [];
183
- while (this.hasNextPage()) {
184
- const result = await this.getNextPage();
185
- allItems.push(...result.items);
186
- }
187
- return allItems;
188
- }
189
- };
190
-
191
- exports.Paginator = Paginator;
192
- //# sourceMappingURL=paginator.cjs.map
193
- //# sourceMappingURL=paginator.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/builders/paginator.ts"],"names":[],"mappings":";;;AAqCO,IAAM,YAAN,MAAiF;AAAA,EAC9E,YAAA;AAAA,EACS,QAAA;AAAA,EACT,WAAc,GAAA,CAAA;AAAA,EACd,gBAAA;AAAA,EACA,YAAe,GAAA,IAAA;AAAA,EACf,mBAAsB,GAAA,CAAA;AAAA,EACb,YAAA;AAAA,EAEjB,WAAA,CAAY,cAAiD,QAAmB,EAAA;AAC9E,IAAA,IAAA,CAAK,YAAe,GAAA,YAAA;AACpB,IAAA,IAAA,CAAK,QAAW,GAAA,QAAA;AAEhB,IAAK,IAAA,CAAA,YAAA,GAAe,aAAa,QAAS,EAAA;AAAA;AAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBO,cAAyB,GAAA;AAC9B,IAAA,OAAO,IAAK,CAAA,WAAA;AAAA;AACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BO,WAAuB,GAAA;AAE5B,IAAA,IAAI,KAAK,YAAiB,KAAA,MAAA,IAAa,IAAK,CAAA,mBAAA,IAAuB,KAAK,YAAc,EAAA;AACpF,MAAO,OAAA,KAAA;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AS,MAAM,IAAA,CAAK,WAAY,EAAA;AACtC,MAAS,QAAA,CAAA,IAAA,CAAK,GAAG,MAAA,CAAO,KAAK,CAAA;AAAA;AAG/B,IAAO,OAAA,QAAA;AAAA;AAEX","file":"paginator.cjs","sourcesContent":["import type { DynamoItem, TableConfig } from \"../types\";\nimport type { PaginationResult, QueryBuilderInterface } from \"./builder-types\";\n\n/**\n * A utility class for handling DynamoDB pagination.\n * Use this class when you need to:\n * - Browse large collections of dinosaurs\n * - Review extensive security logs\n * - Analyze habitat inspection history\n * - Process feeding schedules\n *\n * The paginator maintains internal state and automatically handles:\n * - Page boundaries\n * - Result set limits\n * - Continuation tokens\n *\n * @example\n * ```typescript\n * // List all velociraptors with pagination\n * const paginator = new QueryBuilder(executor, eq('species', 'Velociraptor'))\n * .filter(op => op.eq('status', 'ACTIVE'))\n * .paginate(10);\n *\n * // Process each page of dinosaurs\n * while (paginator.hasNextPage()) {\n * const page = await paginator.getNextPage();\n * console.log(`Processing page ${page.page} of velociraptors`);\n *\n * for (const raptor of page.items) {\n * console.log(`- ${raptor.id}: Health=${raptor.stats.health}`);\n * }\n * }\n * ```\n *\n * @typeParam T - The type of items being paginated\n * @typeParam TConfig - The table configuration type\n */\nexport class Paginator<T extends DynamoItem, TConfig extends TableConfig = TableConfig> {\n private queryBuilder: QueryBuilderInterface<T, TConfig>;\n private readonly pageSize?: number;\n private currentPage = 0;\n private lastEvaluatedKey?: DynamoItem;\n private hasMorePages = true;\n private totalItemsRetrieved = 0;\n private readonly overallLimit?: number;\n\n constructor(queryBuilder: QueryBuilderInterface<T, TConfig>, pageSize?: number) {\n this.queryBuilder = queryBuilder;\n this.pageSize = pageSize;\n // Store the overall limit from the query builder if it exists\n this.overallLimit = queryBuilder.getLimit();\n }\n\n /**\n * Gets the current page number (1-indexed).\n *\n * @example\n * ```ts\n * const paginator = new QueryBuilder(executor, eq('species', 'Tyrannosaurus'))\n * .paginate(5);\n *\n * await paginator.getNextPage();\n * console.log(`Reviewing T-Rex group ${paginator.getCurrentPage()}`);\n * ```\n *\n * @returns The current page number, starting from 1\n */\n public getCurrentPage(): number {\n return this.currentPage;\n }\n\n /**\n * Checks if there are more pages of dinosaurs or habitats to process.\n *\n * This method takes into account both:\n * - DynamoDB's lastEvaluatedKey mechanism\n * - Any overall limit set on the query\n *\n * @example\n * ```ts\n * // Process all security incidents\n * const paginator = new QueryBuilder(executor, eq('type', 'SECURITY_BREACH'))\n * .sortDescending()\n * .paginate(10);\n *\n * while (paginator.hasNextPage()) {\n * const page = await paginator.getNextPage();\n * for (const incident of page.items) {\n * await processSecurityBreach(incident);\n * }\n * console.log(`Processed incidents page ${page.page}`);\n * }\n * ```\n *\n * @returns true if there are more pages available, false otherwise\n */\n public hasNextPage(): boolean {\n // If we have an overall limit and we've already retrieved that many items, there are no more pages\n if (this.overallLimit !== undefined && this.totalItemsRetrieved >= this.overallLimit) {\n return false;\n }\n return this.hasMorePages;\n }\n\n /**\n * Retrieves the next page of dinosaurs or habitats from DynamoDB.\n *\n * This method handles:\n * - Automatic continuation between groups\n * - Respect for park capacity limits\n * - Group size adjustments for safety\n *\n * @example\n * ```ts\n * const paginator = new QueryBuilder(executor, eq('species', 'Velociraptor'))\n * .filter(op => op.eq('status', 'ACTIVE'))\n * .paginate(5);\n *\n * // Check first raptor group\n * const page1 = await paginator.getNextPage();\n * console.log(`Found ${page1.items.length} active raptors`);\n *\n * // Continue inspection if more groups exist\n * if (page1.hasNextPage) {\n * const page2 = await paginator.getNextPage();\n * console.log(`Inspecting raptor group ${page2.page}`);\n *\n * for (const raptor of page2.items) {\n * await performHealthCheck(raptor);\n * }\n * }\n * ```\n *\n * @returns A promise that resolves to a PaginationResult containing:\n * - items: The dinosaurs/habitats for this page\n * - hasNextPage: Whether more groups exist\n * - page: The current group number\n * - lastEvaluatedKey: DynamoDB's continuation token\n */\n public async getNextPage(): Promise<PaginationResult<T>> {\n if (!this.hasNextPage()) {\n return {\n items: [],\n hasNextPage: false,\n page: this.currentPage,\n };\n }\n\n // Calculate how many items to fetch for this page\n let effectivePageSize = this.pageSize;\n\n // If we have an overall limit, make sure we don't fetch more than what's left\n if (this.overallLimit !== undefined) {\n const remainingItems = this.overallLimit - this.totalItemsRetrieved;\n if (remainingItems <= 0) {\n return {\n items: [],\n hasNextPage: false,\n page: this.currentPage,\n };\n }\n if (effectivePageSize !== undefined) {\n effectivePageSize = Math.min(effectivePageSize, remainingItems);\n } else {\n effectivePageSize = remainingItems;\n }\n }\n\n // Clone the query builder to avoid modifying the original\n const query = this.queryBuilder.clone();\n\n // Only set limit if we have an effective page size (not automatic paging)\n if (effectivePageSize !== undefined) {\n query.limit(effectivePageSize);\n }\n\n // Apply the last evaluated key if we have one\n if (this.lastEvaluatedKey) {\n query.startFrom(this.lastEvaluatedKey);\n }\n\n // Execute the query and get the first page from the generator\n const generator = await query.execute();\n const items: T[] = [];\n\n // Take items up to the effective page size\n let itemCount = 0;\n for await (const item of generator) {\n if (effectivePageSize !== undefined && itemCount >= effectivePageSize) {\n break;\n }\n items.push(item);\n itemCount++;\n }\n\n // Get the last evaluated key from the generator\n const lastEvaluatedKey = generator.getLastEvaluatedKey();\n\n const result = { items, lastEvaluatedKey };\n\n // Update pagination state\n this.currentPage += 1;\n this.lastEvaluatedKey = result.lastEvaluatedKey;\n this.totalItemsRetrieved += result.items.length;\n\n // Determine if there are more pages\n // We have more pages if:\n // 1. DynamoDB returned a lastEvaluatedKey AND\n // 2. We haven't hit our overall limit (if one exists)\n this.hasMorePages =\n !!result.lastEvaluatedKey && (this.overallLimit === undefined || this.totalItemsRetrieved < this.overallLimit);\n\n return {\n items: result.items,\n lastEvaluatedKey: result.lastEvaluatedKey,\n hasNextPage: this.hasNextPage(),\n page: this.currentPage,\n };\n }\n\n /**\n * Gets all remaining dinosaurs or habitats and combines them into a single array.\n *\n * @example\n * ```ts\n * // Get complete carnivore inventory\n * const paginator = new QueryBuilder(executor, eq('diet', 'CARNIVORE'))\n * .filter(op => op.eq('status', 'ACTIVE'))\n * .paginate(10);\n *\n * try {\n * const allCarnivores = await paginator.getAllPages();\n * console.log(`Park contains ${allCarnivores.length} active carnivores`);\n *\n * // Calculate total threat level\n * const totalThreat = allCarnivores.reduce(\n * (sum, dino) => sum + dino.stats.threatLevel,\n * 0\n * );\n * console.log(`Total threat level: ${totalThreat}`);\n * } catch (error) {\n * console.error('Failed to complete carnivore census:', error);\n * }\n * ```\n *\n * @returns A promise that resolves to an array containing all remaining items\n */\n public async getAllPages(): Promise<T[]> {\n const allItems: T[] = [];\n\n while (this.hasNextPage()) {\n const result = await this.getNextPage();\n allItems.push(...result.items);\n }\n\n return allItems;\n }\n}\n"]}
@@ -1,155 +0,0 @@
1
- import { DynamoItem, TableConfig } from '../types.cjs';
2
- import { Q as QueryBuilderInterface, P as PaginationResult } from '../builder-types-BTVhQSHI.cjs';
3
- import '@aws-sdk/lib-dynamodb';
4
-
5
- /**
6
- * A utility class for handling DynamoDB pagination.
7
- * Use this class when you need to:
8
- * - Browse large collections of dinosaurs
9
- * - Review extensive security logs
10
- * - Analyze habitat inspection history
11
- * - Process feeding schedules
12
- *
13
- * The paginator maintains internal state and automatically handles:
14
- * - Page boundaries
15
- * - Result set limits
16
- * - Continuation tokens
17
- *
18
- * @example
19
- * ```typescript
20
- * // List all velociraptors with pagination
21
- * const paginator = new QueryBuilder(executor, eq('species', 'Velociraptor'))
22
- * .filter(op => op.eq('status', 'ACTIVE'))
23
- * .paginate(10);
24
- *
25
- * // Process each page of dinosaurs
26
- * while (paginator.hasNextPage()) {
27
- * const page = await paginator.getNextPage();
28
- * console.log(`Processing page ${page.page} of velociraptors`);
29
- *
30
- * for (const raptor of page.items) {
31
- * console.log(`- ${raptor.id}: Health=${raptor.stats.health}`);
32
- * }
33
- * }
34
- * ```
35
- *
36
- * @typeParam T - The type of items being paginated
37
- * @typeParam TConfig - The table configuration type
38
- */
39
- declare class Paginator<T extends DynamoItem, TConfig extends TableConfig = TableConfig> {
40
- private queryBuilder;
41
- private readonly pageSize?;
42
- private currentPage;
43
- private lastEvaluatedKey?;
44
- private hasMorePages;
45
- private totalItemsRetrieved;
46
- private readonly overallLimit?;
47
- constructor(queryBuilder: QueryBuilderInterface<T, TConfig>, pageSize?: number);
48
- /**
49
- * Gets the current page number (1-indexed).
50
- *
51
- * @example
52
- * ```ts
53
- * const paginator = new QueryBuilder(executor, eq('species', 'Tyrannosaurus'))
54
- * .paginate(5);
55
- *
56
- * await paginator.getNextPage();
57
- * console.log(`Reviewing T-Rex group ${paginator.getCurrentPage()}`);
58
- * ```
59
- *
60
- * @returns The current page number, starting from 1
61
- */
62
- getCurrentPage(): number;
63
- /**
64
- * Checks if there are more pages of dinosaurs or habitats to process.
65
- *
66
- * This method takes into account both:
67
- * - DynamoDB's lastEvaluatedKey mechanism
68
- * - Any overall limit set on the query
69
- *
70
- * @example
71
- * ```ts
72
- * // Process all security incidents
73
- * const paginator = new QueryBuilder(executor, eq('type', 'SECURITY_BREACH'))
74
- * .sortDescending()
75
- * .paginate(10);
76
- *
77
- * while (paginator.hasNextPage()) {
78
- * const page = await paginator.getNextPage();
79
- * for (const incident of page.items) {
80
- * await processSecurityBreach(incident);
81
- * }
82
- * console.log(`Processed incidents page ${page.page}`);
83
- * }
84
- * ```
85
- *
86
- * @returns true if there are more pages available, false otherwise
87
- */
88
- hasNextPage(): boolean;
89
- /**
90
- * Retrieves the next page of dinosaurs or habitats from DynamoDB.
91
- *
92
- * This method handles:
93
- * - Automatic continuation between groups
94
- * - Respect for park capacity limits
95
- * - Group size adjustments for safety
96
- *
97
- * @example
98
- * ```ts
99
- * const paginator = new QueryBuilder(executor, eq('species', 'Velociraptor'))
100
- * .filter(op => op.eq('status', 'ACTIVE'))
101
- * .paginate(5);
102
- *
103
- * // Check first raptor group
104
- * const page1 = await paginator.getNextPage();
105
- * console.log(`Found ${page1.items.length} active raptors`);
106
- *
107
- * // Continue inspection if more groups exist
108
- * if (page1.hasNextPage) {
109
- * const page2 = await paginator.getNextPage();
110
- * console.log(`Inspecting raptor group ${page2.page}`);
111
- *
112
- * for (const raptor of page2.items) {
113
- * await performHealthCheck(raptor);
114
- * }
115
- * }
116
- * ```
117
- *
118
- * @returns A promise that resolves to a PaginationResult containing:
119
- * - items: The dinosaurs/habitats for this page
120
- * - hasNextPage: Whether more groups exist
121
- * - page: The current group number
122
- * - lastEvaluatedKey: DynamoDB's continuation token
123
- */
124
- getNextPage(): Promise<PaginationResult<T>>;
125
- /**
126
- * Gets all remaining dinosaurs or habitats and combines them into a single array.
127
- *
128
- * @example
129
- * ```ts
130
- * // Get complete carnivore inventory
131
- * const paginator = new QueryBuilder(executor, eq('diet', 'CARNIVORE'))
132
- * .filter(op => op.eq('status', 'ACTIVE'))
133
- * .paginate(10);
134
- *
135
- * try {
136
- * const allCarnivores = await paginator.getAllPages();
137
- * console.log(`Park contains ${allCarnivores.length} active carnivores`);
138
- *
139
- * // Calculate total threat level
140
- * const totalThreat = allCarnivores.reduce(
141
- * (sum, dino) => sum + dino.stats.threatLevel,
142
- * 0
143
- * );
144
- * console.log(`Total threat level: ${totalThreat}`);
145
- * } catch (error) {
146
- * console.error('Failed to complete carnivore census:', error);
147
- * }
148
- * ```
149
- *
150
- * @returns A promise that resolves to an array containing all remaining items
151
- */
152
- getAllPages(): Promise<T[]>;
153
- }
154
-
155
- export { Paginator };
@@ -1,155 +0,0 @@
1
- import { DynamoItem, TableConfig } from '../types.js';
2
- import { Q as QueryBuilderInterface, P as PaginationResult } from '../builder-types-CzuLR4Th.js';
3
- import '@aws-sdk/lib-dynamodb';
4
-
5
- /**
6
- * A utility class for handling DynamoDB pagination.
7
- * Use this class when you need to:
8
- * - Browse large collections of dinosaurs
9
- * - Review extensive security logs
10
- * - Analyze habitat inspection history
11
- * - Process feeding schedules
12
- *
13
- * The paginator maintains internal state and automatically handles:
14
- * - Page boundaries
15
- * - Result set limits
16
- * - Continuation tokens
17
- *
18
- * @example
19
- * ```typescript
20
- * // List all velociraptors with pagination
21
- * const paginator = new QueryBuilder(executor, eq('species', 'Velociraptor'))
22
- * .filter(op => op.eq('status', 'ACTIVE'))
23
- * .paginate(10);
24
- *
25
- * // Process each page of dinosaurs
26
- * while (paginator.hasNextPage()) {
27
- * const page = await paginator.getNextPage();
28
- * console.log(`Processing page ${page.page} of velociraptors`);
29
- *
30
- * for (const raptor of page.items) {
31
- * console.log(`- ${raptor.id}: Health=${raptor.stats.health}`);
32
- * }
33
- * }
34
- * ```
35
- *
36
- * @typeParam T - The type of items being paginated
37
- * @typeParam TConfig - The table configuration type
38
- */
39
- declare class Paginator<T extends DynamoItem, TConfig extends TableConfig = TableConfig> {
40
- private queryBuilder;
41
- private readonly pageSize?;
42
- private currentPage;
43
- private lastEvaluatedKey?;
44
- private hasMorePages;
45
- private totalItemsRetrieved;
46
- private readonly overallLimit?;
47
- constructor(queryBuilder: QueryBuilderInterface<T, TConfig>, pageSize?: number);
48
- /**
49
- * Gets the current page number (1-indexed).
50
- *
51
- * @example
52
- * ```ts
53
- * const paginator = new QueryBuilder(executor, eq('species', 'Tyrannosaurus'))
54
- * .paginate(5);
55
- *
56
- * await paginator.getNextPage();
57
- * console.log(`Reviewing T-Rex group ${paginator.getCurrentPage()}`);
58
- * ```
59
- *
60
- * @returns The current page number, starting from 1
61
- */
62
- getCurrentPage(): number;
63
- /**
64
- * Checks if there are more pages of dinosaurs or habitats to process.
65
- *
66
- * This method takes into account both:
67
- * - DynamoDB's lastEvaluatedKey mechanism
68
- * - Any overall limit set on the query
69
- *
70
- * @example
71
- * ```ts
72
- * // Process all security incidents
73
- * const paginator = new QueryBuilder(executor, eq('type', 'SECURITY_BREACH'))
74
- * .sortDescending()
75
- * .paginate(10);
76
- *
77
- * while (paginator.hasNextPage()) {
78
- * const page = await paginator.getNextPage();
79
- * for (const incident of page.items) {
80
- * await processSecurityBreach(incident);
81
- * }
82
- * console.log(`Processed incidents page ${page.page}`);
83
- * }
84
- * ```
85
- *
86
- * @returns true if there are more pages available, false otherwise
87
- */
88
- hasNextPage(): boolean;
89
- /**
90
- * Retrieves the next page of dinosaurs or habitats from DynamoDB.
91
- *
92
- * This method handles:
93
- * - Automatic continuation between groups
94
- * - Respect for park capacity limits
95
- * - Group size adjustments for safety
96
- *
97
- * @example
98
- * ```ts
99
- * const paginator = new QueryBuilder(executor, eq('species', 'Velociraptor'))
100
- * .filter(op => op.eq('status', 'ACTIVE'))
101
- * .paginate(5);
102
- *
103
- * // Check first raptor group
104
- * const page1 = await paginator.getNextPage();
105
- * console.log(`Found ${page1.items.length} active raptors`);
106
- *
107
- * // Continue inspection if more groups exist
108
- * if (page1.hasNextPage) {
109
- * const page2 = await paginator.getNextPage();
110
- * console.log(`Inspecting raptor group ${page2.page}`);
111
- *
112
- * for (const raptor of page2.items) {
113
- * await performHealthCheck(raptor);
114
- * }
115
- * }
116
- * ```
117
- *
118
- * @returns A promise that resolves to a PaginationResult containing:
119
- * - items: The dinosaurs/habitats for this page
120
- * - hasNextPage: Whether more groups exist
121
- * - page: The current group number
122
- * - lastEvaluatedKey: DynamoDB's continuation token
123
- */
124
- getNextPage(): Promise<PaginationResult<T>>;
125
- /**
126
- * Gets all remaining dinosaurs or habitats and combines them into a single array.
127
- *
128
- * @example
129
- * ```ts
130
- * // Get complete carnivore inventory
131
- * const paginator = new QueryBuilder(executor, eq('diet', 'CARNIVORE'))
132
- * .filter(op => op.eq('status', 'ACTIVE'))
133
- * .paginate(10);
134
- *
135
- * try {
136
- * const allCarnivores = await paginator.getAllPages();
137
- * console.log(`Park contains ${allCarnivores.length} active carnivores`);
138
- *
139
- * // Calculate total threat level
140
- * const totalThreat = allCarnivores.reduce(
141
- * (sum, dino) => sum + dino.stats.threatLevel,
142
- * 0
143
- * );
144
- * console.log(`Total threat level: ${totalThreat}`);
145
- * } catch (error) {
146
- * console.error('Failed to complete carnivore census:', error);
147
- * }
148
- * ```
149
- *
150
- * @returns A promise that resolves to an array containing all remaining items
151
- */
152
- getAllPages(): Promise<T[]>;
153
- }
154
-
155
- export { Paginator };