ag-common 0.0.894 → 0.0.896

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 (236) hide show
  1. package/LICENSE.md +2 -3
  2. package/README.md +2 -2
  3. package/dist/api/helpers/acm.d.ts +1 -1
  4. package/dist/api/helpers/acm.js +3 -3
  5. package/dist/api/helpers/api.d.ts +2 -2
  6. package/dist/api/helpers/api.js +26 -22
  7. package/dist/api/helpers/apigw.js +4 -4
  8. package/dist/api/helpers/aws.js +2 -2
  9. package/dist/api/helpers/cosmos/delete.d.ts +1 -1
  10. package/dist/api/helpers/cosmos/delete.js +15 -16
  11. package/dist/api/helpers/cosmos/get.d.ts +3 -3
  12. package/dist/api/helpers/cosmos/get.js +26 -32
  13. package/dist/api/helpers/cosmos/index.d.ts +3 -3
  14. package/dist/api/helpers/cosmos/index.js +1 -1
  15. package/dist/api/helpers/cosmos/utils.d.ts +1 -1
  16. package/dist/api/helpers/cosmos/utils.js +3 -7
  17. package/dist/api/helpers/cosmos/write.d.ts +1 -1
  18. package/dist/api/helpers/cosmos/write.js +11 -12
  19. package/dist/api/helpers/dynamo/delete.d.ts +1 -1
  20. package/dist/api/helpers/dynamo/delete.js +3 -3
  21. package/dist/api/helpers/dynamo/get.d.ts +2 -2
  22. package/dist/api/helpers/dynamo/get.js +20 -14
  23. package/dist/api/helpers/dynamo/index.d.ts +10 -38
  24. package/dist/api/helpers/dynamo/index.js +4 -4
  25. package/dist/api/helpers/dynamo/set.d.ts +1 -1
  26. package/dist/api/helpers/dynamo/set.js +10 -10
  27. package/dist/api/helpers/dynamo/types.d.ts +3 -3
  28. package/dist/api/helpers/dynamo/types.js +1 -1
  29. package/dist/api/helpers/enforceDynamoProvisionCap.d.ts +13 -1
  30. package/dist/api/helpers/enforceDynamoProvisionCap.js +3 -4
  31. package/dist/api/helpers/google/apikey.js +1 -1
  32. package/dist/api/helpers/google/gemini.d.ts +1 -1
  33. package/dist/api/helpers/google/gemini.js +43 -45
  34. package/dist/api/helpers/google/index.d.ts +2 -2
  35. package/dist/api/helpers/index.d.ts +17 -17
  36. package/dist/api/helpers/retryOnError.js +6 -11
  37. package/dist/api/helpers/s3.d.ts +9 -9
  38. package/dist/api/helpers/s3.js +19 -16
  39. package/dist/api/helpers/ses.d.ts +1 -1
  40. package/dist/api/helpers/ses.js +9 -9
  41. package/dist/api/helpers/sqs.d.ts +1 -1
  42. package/dist/api/helpers/sqs.js +1 -1
  43. package/dist/api/helpers/ssm.d.ts +1 -1
  44. package/dist/api/helpers/ssm.js +2 -2
  45. package/dist/api/helpers/ssmInfra/apigw.d.ts +6 -6
  46. package/dist/api/helpers/ssmInfra/apigw.js +6 -10
  47. package/dist/api/helpers/ssmInfra/dynamo.d.ts +2 -2
  48. package/dist/api/helpers/ssmInfra/dynamo.js +1 -1
  49. package/dist/api/helpers/ssmInfra/index.d.ts +4 -4
  50. package/dist/api/helpers/ssmInfra/s3.d.ts +3 -3
  51. package/dist/api/helpers/ssmInfra/s3.js +1 -1
  52. package/dist/api/helpers/ssmInfra/sqs.d.ts +3 -3
  53. package/dist/api/helpers/ssmInfra/sqs.js +1 -1
  54. package/dist/api/helpers/sts.d.ts +1 -1
  55. package/dist/api/helpers/sts.js +4 -4
  56. package/dist/api/helpers/validations.d.ts +2 -2
  57. package/dist/api/helpers/validations.js +14 -14
  58. package/dist/api/helpers/zod.d.ts +1 -1
  59. package/dist/api/helpers/zod.js +21 -27
  60. package/dist/api/index.d.ts +2 -2
  61. package/dist/api/types/aws.d.ts +0 -56
  62. package/dist/api/types/aws.js +0 -1
  63. package/dist/api/types/index.d.ts +1 -1
  64. package/dist/common/helpers/array.js +9 -10
  65. package/dist/common/helpers/async.js +2 -2
  66. package/dist/common/helpers/binary.d.ts +1 -1
  67. package/dist/common/helpers/binary.js +1 -1
  68. package/dist/common/helpers/csv.d.ts +4 -2
  69. package/dist/common/helpers/csv.js +8 -12
  70. package/dist/common/helpers/date.d.ts +2 -4
  71. package/dist/common/helpers/date.js +2 -2
  72. package/dist/common/helpers/email.js +2 -2
  73. package/dist/common/helpers/fetch.js +8 -8
  74. package/dist/common/helpers/generator.js +2 -2
  75. package/dist/common/helpers/groupBy.js +0 -2
  76. package/dist/common/helpers/hashCode.js +2 -6
  77. package/dist/common/helpers/headers.d.ts +20 -20
  78. package/dist/common/helpers/headers.js +38 -38
  79. package/dist/common/helpers/i18n.d.ts +2 -2
  80. package/dist/common/helpers/i18n.js +5 -6
  81. package/dist/common/helpers/index.d.ts +25 -25
  82. package/dist/common/helpers/log.d.ts +1 -1
  83. package/dist/common/helpers/log.js +30 -30
  84. package/dist/common/helpers/math.d.ts +2 -2
  85. package/dist/common/helpers/math.js +6 -6
  86. package/dist/common/helpers/memo.d.ts +1 -1
  87. package/dist/common/helpers/memo.js +1 -3
  88. package/dist/common/helpers/node-cache.d.ts +2 -2
  89. package/dist/common/helpers/node-cache.js +0 -1
  90. package/dist/common/helpers/object.d.ts +1 -1
  91. package/dist/common/helpers/object.js +16 -27
  92. package/dist/common/helpers/secondsInNearest.js +5 -5
  93. package/dist/common/helpers/stream.js +4 -6
  94. package/dist/common/helpers/string/base64.js +2 -2
  95. package/dist/common/helpers/string/chunk.js +1 -1
  96. package/dist/common/helpers/string/contains.js +1 -3
  97. package/dist/common/helpers/string/getExtendedStringSegment.js +1 -1
  98. package/dist/common/helpers/string/index.d.ts +11 -11
  99. package/dist/common/helpers/string/json.js +1 -1
  100. package/dist/common/helpers/string/redact.js +38 -39
  101. package/dist/common/helpers/string/trim.js +4 -4
  102. package/dist/common/helpers/string/truncate.js +1 -1
  103. package/dist/common/helpers/string/url.js +7 -8
  104. package/dist/common/helpers/withRetry.js +7 -7
  105. package/dist/common/helpers/xml.d.ts +7 -3
  106. package/dist/common/helpers/xml.js +33 -36
  107. package/dist/common/index.d.ts +2 -2
  108. package/dist/index.d.ts +3 -3
  109. package/dist/node/helpers/fetch.js +1 -2
  110. package/dist/node/helpers/fs.js +2 -2
  111. package/dist/node/helpers/index.d.ts +2 -2
  112. package/dist/node/index.d.ts +1 -1
  113. package/dist/ui/components/DarkMode/Base.d.ts +4 -4
  114. package/dist/ui/components/DarkMode/Base.js +26 -31
  115. package/dist/ui/components/DarkMode/index.d.ts +2 -2
  116. package/dist/ui/components/DarkMode/types.d.ts +5 -5
  117. package/dist/ui/components/HeadersRaw/index.d.ts +2 -2
  118. package/dist/ui/components/HeadersRaw/index.js +5 -5
  119. package/dist/ui/components/Markdown/index.d.ts +1 -1
  120. package/dist/ui/components/Markdown/index.js +10 -10
  121. package/dist/ui/components/index.d.ts +4 -4
  122. package/dist/ui/components/shadcn/accordion.d.ts +4 -4
  123. package/dist/ui/components/shadcn/accordion.js +6 -6
  124. package/dist/ui/components/shadcn/alert.d.ts +2 -2
  125. package/dist/ui/components/shadcn/alert.js +6 -6
  126. package/dist/ui/components/shadcn/avatar.d.ts +2 -2
  127. package/dist/ui/components/shadcn/avatar.js +4 -4
  128. package/dist/ui/components/shadcn/button.d.ts +4 -4
  129. package/dist/ui/components/shadcn/button.js +14 -14
  130. package/dist/ui/components/shadcn/card.d.ts +2 -2
  131. package/dist/ui/components/shadcn/card.js +6 -6
  132. package/dist/ui/components/shadcn/checkbox.d.ts +2 -2
  133. package/dist/ui/components/shadcn/checkbox.js +3 -3
  134. package/dist/ui/components/shadcn/dialog.d.ts +10 -10
  135. package/dist/ui/components/shadcn/dialog.js +9 -11
  136. package/dist/ui/components/shadcn/divider.d.ts +1 -1
  137. package/dist/ui/components/shadcn/divider.js +1 -1
  138. package/dist/ui/components/shadcn/dropdown-list.d.ts +1 -1
  139. package/dist/ui/components/shadcn/dropdown-list.js +5 -5
  140. package/dist/ui/components/shadcn/dropdown-menu.d.ts +6 -6
  141. package/dist/ui/components/shadcn/dropdown-menu.js +11 -11
  142. package/dist/ui/components/shadcn/index.d.ts +21 -21
  143. package/dist/ui/components/shadcn/input-selector.d.ts +1 -1
  144. package/dist/ui/components/shadcn/input-selector.js +10 -12
  145. package/dist/ui/components/shadcn/input.d.ts +1 -1
  146. package/dist/ui/components/shadcn/input.js +1 -1
  147. package/dist/ui/components/shadcn/label.d.ts +3 -3
  148. package/dist/ui/components/shadcn/label.js +2 -2
  149. package/dist/ui/components/shadcn/popover.d.ts +2 -2
  150. package/dist/ui/components/shadcn/popover.js +3 -3
  151. package/dist/ui/components/shadcn/radio-group.d.ts +2 -2
  152. package/dist/ui/components/shadcn/radio-group.js +2 -2
  153. package/dist/ui/components/shadcn/scroll-area.d.ts +2 -2
  154. package/dist/ui/components/shadcn/scroll-area.js +3 -5
  155. package/dist/ui/components/shadcn/select.d.ts +2 -2
  156. package/dist/ui/components/shadcn/select.js +12 -12
  157. package/dist/ui/components/shadcn/sheet.d.ts +12 -12
  158. package/dist/ui/components/shadcn/sheet.js +15 -15
  159. package/dist/ui/components/shadcn/switch.d.ts +2 -2
  160. package/dist/ui/components/shadcn/switch.js +3 -3
  161. package/dist/ui/components/shadcn/textarea.d.ts +1 -1
  162. package/dist/ui/components/shadcn/textarea.js +1 -1
  163. package/dist/ui/components/shadcn/toast.d.ts +2 -2
  164. package/dist/ui/components/shadcn/toast.js +25 -25
  165. package/dist/ui/helpers/cognito.d.ts +1 -1
  166. package/dist/ui/helpers/cookie/const.js +1 -1
  167. package/dist/ui/helpers/cookie/get.js +3 -4
  168. package/dist/ui/helpers/cookie/index.d.ts +5 -5
  169. package/dist/ui/helpers/cookie/raw.d.ts +1 -1
  170. package/dist/ui/helpers/cookie/raw.js +8 -9
  171. package/dist/ui/helpers/cookie/use.d.ts +1 -1
  172. package/dist/ui/helpers/cookie/use.js +4 -4
  173. package/dist/ui/helpers/date.js +8 -8
  174. package/dist/ui/helpers/debounce.js +1 -1
  175. package/dist/ui/helpers/dom.d.ts +1 -1
  176. package/dist/ui/helpers/dom.js +4 -14
  177. package/dist/ui/helpers/index.d.ts +26 -26
  178. package/dist/ui/helpers/jwt.d.ts +3 -3
  179. package/dist/ui/helpers/openDialog.d.ts +2 -2
  180. package/dist/ui/helpers/openDialog.js +8 -8
  181. package/dist/ui/helpers/plural.js +1 -1
  182. package/dist/ui/helpers/routes.d.ts +2 -2
  183. package/dist/ui/helpers/routes.js +14 -15
  184. package/dist/ui/helpers/serviceWorker.js +1 -1
  185. package/dist/ui/helpers/useContextMenu.d.ts +1 -1
  186. package/dist/ui/helpers/useContextMenu.js +9 -10
  187. package/dist/ui/helpers/useElementAttribute.js +3 -5
  188. package/dist/ui/helpers/useGranularHook.d.ts +1 -1
  189. package/dist/ui/helpers/useGranularHook.js +2 -3
  190. package/dist/ui/helpers/useInterval.d.ts +2 -2
  191. package/dist/ui/helpers/useInterval.js +2 -2
  192. package/dist/ui/helpers/useIsInViewport.d.ts +1 -1
  193. package/dist/ui/helpers/useIsInViewport.js +0 -1
  194. package/dist/ui/helpers/useLocalStorage.js +6 -6
  195. package/dist/ui/helpers/useLockBodyScroll.js +2 -2
  196. package/dist/ui/helpers/useOnClickOutside.d.ts +1 -1
  197. package/dist/ui/helpers/useOnClickOutside.js +3 -6
  198. package/dist/ui/helpers/useOnScroll.d.ts +1 -1
  199. package/dist/ui/helpers/useOnScroll.js +3 -4
  200. package/dist/ui/helpers/useOverloadPageSearch.js +8 -10
  201. package/dist/ui/helpers/useQueryString.js +7 -7
  202. package/dist/ui/helpers/useResize.js +5 -6
  203. package/dist/ui/helpers/useTimeout.js +1 -1
  204. package/dist/ui/helpers/useTooltip.d.ts +2 -2
  205. package/dist/ui/helpers/useTooltip.js +5 -7
  206. package/dist/ui/helpers/utils.d.ts +2 -2
  207. package/dist/ui/icons/Checkmark.d.ts +2 -2
  208. package/dist/ui/icons/Checkmark.js +1 -1
  209. package/dist/ui/icons/ChevronRight.d.ts +1 -1
  210. package/dist/ui/icons/Circle.d.ts +2 -2
  211. package/dist/ui/icons/Circle.js +1 -1
  212. package/dist/ui/icons/CircleDot.d.ts +2 -2
  213. package/dist/ui/icons/Cog.d.ts +2 -2
  214. package/dist/ui/icons/Computer.d.ts +2 -2
  215. package/dist/ui/icons/Door.d.ts +1 -1
  216. package/dist/ui/icons/Hamburger.d.ts +1 -1
  217. package/dist/ui/icons/HorizontalDots.d.ts +1 -1
  218. package/dist/ui/icons/House.d.ts +2 -2
  219. package/dist/ui/icons/Magnify.d.ts +2 -2
  220. package/dist/ui/icons/Magnify.js +1 -1
  221. package/dist/ui/icons/Moon.d.ts +2 -2
  222. package/dist/ui/icons/Pencil.d.ts +1 -1
  223. package/dist/ui/icons/Save.d.ts +1 -1
  224. package/dist/ui/icons/Sun.d.ts +1 -1
  225. package/dist/ui/icons/Sun.js +1 -1
  226. package/dist/ui/icons/Undo.d.ts +1 -1
  227. package/dist/ui/icons/UserOutline.d.ts +1 -1
  228. package/dist/ui/icons/Warning.d.ts +2 -2
  229. package/dist/ui/icons/Warning.js +1 -1
  230. package/dist/ui/icons/index.d.ts +32 -74
  231. package/dist/ui/index.d.ts +3 -3
  232. package/dist/ui/styles/colours.js +29 -29
  233. package/dist/ui/styles/common.d.ts +1 -1
  234. package/dist/ui/styles/common.js +10 -10
  235. package/dist/ui/styles/index.d.ts +3 -3
  236. package/package.json +65 -75
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.wipeTable = exports.batchDelete = void 0;
4
4
  const lib_dynamodb_1 = require("@aws-sdk/lib-dynamodb");
5
+ const _1 = require(".");
5
6
  const array_1 = require("../../../common/helpers/array");
6
7
  const async_1 = require("../../../common/helpers/async");
7
8
  const withRetry_1 = require("../../../common/helpers/withRetry");
8
- const _1 = require(".");
9
9
  const get_1 = require("./get");
10
10
  const batchDelete = async (params) => {
11
11
  try {
@@ -45,12 +45,12 @@ const wipeTable = async (tableName) => {
45
45
  const result = await (0, exports.batchDelete)({
46
46
  tableName,
47
47
  keys: pks,
48
- pkName: 'PK',
48
+ pkName: "PK",
49
49
  opt: {
50
50
  maxRetries: null, // Always retry on 429 since we want to ensure complete deletion
51
51
  },
52
52
  });
53
- if ('error' in result) {
53
+ if ("error" in result) {
54
54
  return result;
55
55
  }
56
56
  }
@@ -1,5 +1,5 @@
1
- import type { DynamoDBResult } from './types';
2
- import type { DynamoBatchQueryParams, DynamoQueryParams, ScanOptions } from './types';
1
+ import type { DynamoDBResult } from "./types";
2
+ import type { DynamoBatchQueryParams, DynamoQueryParams, ScanOptions } from "./types";
3
3
  export declare const getItemsDynamo: <T>(params: {
4
4
  tableName: string;
5
5
  items: {
@@ -4,14 +4,14 @@ exports.batchQueryDynamo = exports.scan = exports.queryDynamo = exports.getItemD
4
4
  exports.queryWithGenerator = queryWithGenerator;
5
5
  exports.scanWithGenerator = scanWithGenerator;
6
6
  const lib_dynamodb_1 = require("@aws-sdk/lib-dynamodb");
7
- const withRetry_1 = require("../../../common/helpers/withRetry");
8
7
  const _1 = require(".");
9
- const isError = (result) => 'error' in result;
8
+ const withRetry_1 = require("../../../common/helpers/withRetry");
9
+ const isError = (result) => "error" in result;
10
10
  /**
11
11
  * Helper function that builds the query parameters and executes the query
12
12
  */
13
13
  const executeQuery = async (params, exclusiveStartKey) => {
14
- let kce = `#${params.pkName.toLowerCase()} ${params.pkOperator ?? '='} :${params.pkName.toLowerCase()}`;
14
+ let kce = `#${params.pkName.toLowerCase()} ${params.pkOperator ?? "="} :${params.pkName.toLowerCase()}`;
15
15
  const ean = {
16
16
  [`#${params.pkName.toLowerCase()}`]: params.pkName,
17
17
  };
@@ -19,15 +19,15 @@ const executeQuery = async (params, exclusiveStartKey) => {
19
19
  [`:${params.pkName.toLowerCase()}`]: params.pkValue,
20
20
  };
21
21
  if (params.skName && params.skValue !== undefined) {
22
- const { skName, skValue, skOperator = '=' } = params;
23
- if (skOperator === 'BETWEEN' && Array.isArray(skValue)) {
22
+ const { skName, skValue, skOperator = "=" } = params;
23
+ if (skOperator === "BETWEEN" && Array.isArray(skValue)) {
24
24
  const [start, end] = skValue;
25
25
  kce += ` AND #${skName.toLowerCase()} BETWEEN :${skName}1 AND :${skName}2`;
26
26
  ean[`#${skName.toLowerCase()}`] = skName;
27
27
  eav[`:${skName}1`] = start;
28
28
  eav[`:${skName}2`] = end;
29
29
  }
30
- else if (skOperator === 'BEGINS_WITH') {
30
+ else if (skOperator === "BEGINS_WITH") {
31
31
  kce += ` AND begins_with(#${skName.toLowerCase()}, :${skName.toLowerCase()})`;
32
32
  ean[`#${skName.toLowerCase()}`] = skName;
33
33
  eav[`:${skName.toLowerCase()}`] = skValue;
@@ -63,7 +63,7 @@ const executeQuery = async (params, exclusiveStartKey) => {
63
63
  }),
64
64
  }),
65
65
  };
66
- return (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.QueryCommand(queryParams)), 'queryDynamo:' + JSON.stringify(params), {
66
+ return (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.QueryCommand(queryParams)), "queryDynamo:" + JSON.stringify(params), {
67
67
  maxRetries: params.maxRetries === undefined ? 3 : params.maxRetries,
68
68
  });
69
69
  };
@@ -95,11 +95,11 @@ const executeScan = async (tableName, options, exclusiveStartKey) => {
95
95
  ...(options?.requiredAttributeList && {
96
96
  ProjectionExpression: options.requiredAttributeList
97
97
  .map((_, index) => `#proj${index}`)
98
- .join(', '),
98
+ .join(", "),
99
99
  }),
100
100
  ExclusiveStartKey: exclusiveStartKey,
101
101
  };
102
- return (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.ScanCommand(scanParams)), `scan. already seen=${exclusiveStartKey ? 'some' : '0'} items`, {
102
+ return (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.ScanCommand(scanParams)), `scan. already seen=${exclusiveStartKey ? "some" : "0"} items`, {
103
103
  maxRetries: options?.maxRetries === undefined ? 3 : options.maxRetries,
104
104
  });
105
105
  };
@@ -120,7 +120,7 @@ const getItemsDynamo = async (params) => {
120
120
  },
121
121
  },
122
122
  };
123
- return (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.BatchGetCommand(batchGetParams)), 'getItemsDynamo:' + JSON.stringify(params));
123
+ return (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.BatchGetCommand(batchGetParams)), "getItemsDynamo:" + JSON.stringify(params));
124
124
  }));
125
125
  const allItems = [];
126
126
  responses.forEach((result) => {
@@ -151,6 +151,7 @@ const queryDynamo = async (params) => {
151
151
  let lastEvaluatedKey = params.exclusiveStartKey;
152
152
  const hasLimit = params.limit && params.limit > 0;
153
153
  do {
154
+ // oxlint-disable-next-line no-await-in-loop -- pagination depends on the prior page token
154
155
  const result = await executeQuery(params, lastEvaluatedKey);
155
156
  if (result.Items) {
156
157
  items.push(...result.Items);
@@ -180,6 +181,7 @@ const scan = async (tableName, options) => {
180
181
  const Items = [];
181
182
  let ExclusiveStartKey;
182
183
  do {
184
+ // oxlint-disable-next-line no-await-in-loop -- pagination depends on the prior page token
183
185
  const result = await executeScan(tableName, options, ExclusiveStartKey);
184
186
  if (result.Items) {
185
187
  Items.push(...result.Items);
@@ -257,11 +259,12 @@ const batchQueryDynamo = async (params) => {
257
259
  let totalProcessed = 0;
258
260
  // Process each chunk
259
261
  for (const chunk of chunks) {
262
+ // oxlint-disable-next-line no-await-in-loop -- chunks are intentionally processed in order
260
263
  const result = await executePartiQLQuery({
261
264
  ...params,
262
265
  pkValues: chunk,
263
266
  });
264
- if ('error' in result) {
267
+ if ("error" in result) {
265
268
  return result;
266
269
  }
267
270
  allItems.push(...result.data);
@@ -288,7 +291,7 @@ exports.batchQueryDynamo = batchQueryDynamo;
288
291
  const executePartiQLQuery = async (params) => {
289
292
  try {
290
293
  // Build the PartiQL WHERE clause for multiple partition keys
291
- const pkPlaceholders = params.pkValues.map(() => '?').join(', ');
294
+ const pkPlaceholders = params.pkValues.map(() => "?").join(", ");
292
295
  let whereClause = `"${params.pkName}" IN (${pkPlaceholders})`;
293
296
  // Build parameters array for PartiQL (positional parameters)
294
297
  const parameters = [...params.pkValues];
@@ -298,7 +301,7 @@ const executePartiQLQuery = async (params) => {
298
301
  let filterExpression = params.filter.filterExpression;
299
302
  if (params.filter.attrValues) {
300
303
  Object.entries(params.filter.attrValues).forEach(([key, value]) => {
301
- filterExpression = filterExpression.replace(new RegExp(key.replace(':', '\\:'), 'g'), '?');
304
+ filterExpression = filterExpression.replace(new RegExp(key.replace(":", "\\:"), "g"), "?");
302
305
  parameters.push(value);
303
306
  });
304
307
  }
@@ -319,7 +322,8 @@ const executePartiQLQuery = async (params) => {
319
322
  Limit: params.limit === -1 ? undefined : params.limit,
320
323
  NextToken: nextToken,
321
324
  };
322
- const result = await (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.ExecuteStatementCommand(executeParams)), 'batchQueryDynamo:' + JSON.stringify(params), {
325
+ // oxlint-disable-next-line no-await-in-loop -- pagination depends on the prior page token
326
+ const result = await (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.ExecuteStatementCommand(executeParams)), "batchQueryDynamo:" + JSON.stringify(params), {
323
327
  maxRetries: params.maxRetries === undefined ? 3 : params.maxRetries,
324
328
  });
325
329
  if (result.Items) {
@@ -350,6 +354,7 @@ async function* queryWithGenerator(params) {
350
354
  let lastEvaluatedKey = params.exclusiveStartKey;
351
355
  try {
352
356
  do {
357
+ // oxlint-disable-next-line no-await-in-loop -- pagination depends on the prior page token
353
358
  const result = await executeQuery(params, lastEvaluatedKey);
354
359
  if (result.Items) {
355
360
  items.push(...result.Items);
@@ -389,6 +394,7 @@ async function* scanWithGenerator(tableName, options) {
389
394
  let exclusiveStartKey;
390
395
  try {
391
396
  do {
397
+ // oxlint-disable-next-line no-await-in-loop -- pagination depends on the prior page token
392
398
  const result = await executeScan(tableName, options, exclusiveStartKey);
393
399
  if (result.Items) {
394
400
  items.push(...result.Items);
@@ -1,6 +1,8 @@
1
- import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
2
- import type { AwsCredentialIdentity } from '@smithy/types';
3
- import * as getOps from './get';
1
+ import { type DynamoDBClientConfig } from "@aws-sdk/client-dynamodb";
2
+ import { DynamoDBDocument } from "@aws-sdk/lib-dynamodb";
3
+ import * as deleteOps from "./delete";
4
+ import * as getOps from "./get";
5
+ import * as setOps from "./set";
4
6
  export declare let dynamoDb: DynamoDBDocument;
5
7
  /**
6
8
  * Sets up the DynamoDB client with the specified region and credentials.
@@ -8,38 +10,8 @@ export declare let dynamoDb: DynamoDBDocument;
8
10
  * @param credentials - Optional AWS credentials
9
11
  * @returns Configured DynamoDBDocument client
10
12
  */
11
- export declare const setDynamo: (region: string, credentials?: AwsCredentialIdentity) => DynamoDBDocument;
12
- export declare const getItemDynamo: <T>(params: {
13
- tableName: string;
14
- pkName: string;
15
- pkValue: string;
16
- }) => Promise<import("./types").DynamoDBResult<T>>, getItemsDynamo: <T>(params: {
17
- tableName: string;
18
- items: {
19
- pkName: string;
20
- pkValue: string;
21
- }[];
22
- }) => Promise<import("./types").DynamoDBResult<T[]>>, queryDynamo: <T>(params: import("./types").DynamoQueryParams) => Promise<import("./types").DynamoDBResult<T[]>>, batchQueryDynamo: <T>(params: import("./types").DynamoBatchQueryParams) => Promise<import("./types").DynamoDBResult<T[]>>, queryWithGenerator: typeof getOps.queryWithGenerator, scan: <T>(tableName: string, options?: import("./types").ScanOptions) => Promise<import("./types").DynamoDBResult<T[]>>, scanWithGenerator: typeof getOps.scanWithGenerator;
23
- export declare const putDynamo: <T extends Record<string, unknown>>(item: T, tableName: string, opt?: {
24
- pkName?: string;
25
- }) => Promise<import("./types").DynamoDBResult<void>>, batchWrite: <T extends Record<string, unknown>>(tableName: string, items: T[], opt?: {
26
- maxRetries?: number | null;
27
- batchSize?: number;
28
- }) => Promise<import("./types").DynamoDBResult<void>>, getDynamoUpdates: <T extends Record<string, unknown>>(item: T, options?: {
29
- excludeKeys?: string[];
30
- }) => {
31
- UpdateExpression: string;
32
- ExpressionAttributeNames: Record<string, string>;
33
- ExpressionAttributeValues: Record<string, unknown>;
34
- ReturnValues: "UPDATED_NEW";
35
- };
36
- export declare const batchDelete: (params: {
37
- tableName: string;
38
- keys: string[];
39
- pkName: string;
40
- opt?: {
41
- batchSize?: number;
42
- maxRetries?: number | null;
43
- };
44
- }) => Promise<import("./types").DynamoDBResult<void>>, wipeTable: (tableName: string) => Promise<import("./types").DynamoDBResult<void>>;
45
- export * from './types';
13
+ export declare const setDynamo: (region: string, credentials?: DynamoDBClientConfig["credentials"]) => DynamoDBDocument;
14
+ export declare const getItemDynamo: typeof getOps.getItemDynamo, getItemsDynamo: typeof getOps.getItemsDynamo, queryDynamo: typeof getOps.queryDynamo, batchQueryDynamo: typeof getOps.batchQueryDynamo, queryWithGenerator: typeof getOps.queryWithGenerator, scan: typeof getOps.scan, scanWithGenerator: typeof getOps.scanWithGenerator;
15
+ export declare const putDynamo: typeof setOps.putDynamo, batchWrite: typeof setOps.batchWrite, getDynamoUpdates: typeof setOps.getDynamoUpdates;
16
+ export declare const batchDelete: typeof deleteOps.batchDelete, wipeTable: typeof deleteOps.wipeTable;
17
+ export * from "./types";
@@ -57,10 +57,10 @@ const setDynamo = (region, credentials) => {
57
57
  };
58
58
  exports.setDynamo = setDynamo;
59
59
  // Initialize with default region
60
- exports.dynamoDb = (0, exports.setDynamo)('ap-southeast-2');
60
+ exports.dynamoDb = (0, exports.setDynamo)("ap-southeast-2");
61
61
  // Export all operations
62
- exports.getItemDynamo = getOps.getItemDynamo, exports.getItemsDynamo = getOps.getItemsDynamo, exports.queryDynamo = getOps.queryDynamo, exports.batchQueryDynamo = getOps.batchQueryDynamo, exports.queryWithGenerator = getOps.queryWithGenerator, exports.scan = getOps.scan, exports.scanWithGenerator = getOps.scanWithGenerator;
63
- exports.putDynamo = setOps.putDynamo, exports.batchWrite = setOps.batchWrite, exports.getDynamoUpdates = setOps.getDynamoUpdates;
64
- exports.batchDelete = deleteOps.batchDelete, exports.wipeTable = deleteOps.wipeTable;
62
+ ({ getItemDynamo: exports.getItemDynamo, getItemsDynamo: exports.getItemsDynamo, queryDynamo: exports.queryDynamo, batchQueryDynamo: exports.batchQueryDynamo, queryWithGenerator: exports.queryWithGenerator, scan: exports.scan, scanWithGenerator: exports.scanWithGenerator } = getOps);
63
+ ({ putDynamo: exports.putDynamo, batchWrite: exports.batchWrite, getDynamoUpdates: exports.getDynamoUpdates } = setOps);
64
+ ({ batchDelete: exports.batchDelete, wipeTable: exports.wipeTable } = deleteOps);
65
65
  // Export types
66
66
  __exportStar(require("./types"), exports);
@@ -1,4 +1,4 @@
1
- import type { DynamoDBResult } from './types';
1
+ import type { DynamoDBResult } from "./types";
2
2
  export declare const putDynamo: <T extends Record<string, unknown>>(item: T, tableName: string, opt?: {
3
3
  pkName?: string;
4
4
  }) => Promise<DynamoDBResult<void>>;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDynamoUpdates = exports.incrementDynamo = exports.batchWrite = exports.putDynamo = void 0;
4
4
  const lib_dynamodb_1 = require("@aws-sdk/lib-dynamodb");
5
+ const _1 = require(".");
5
6
  const array_1 = require("../../../common/helpers/array");
6
7
  const async_1 = require("../../../common/helpers/async");
7
8
  const withRetry_1 = require("../../../common/helpers/withRetry");
8
- const _1 = require(".");
9
9
  const putDynamo = async (item, tableName, opt) => {
10
10
  const putParams = {
11
11
  TableName: tableName,
@@ -15,7 +15,7 @@ const putDynamo = async (item, tableName, opt) => {
15
15
  }),
16
16
  };
17
17
  try {
18
- const res = await (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.PutCommand(putParams)), 'putDynamo');
18
+ const res = await (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.PutCommand(putParams)), "putDynamo");
19
19
  if (res.$metadata.httpStatusCode !== 200) {
20
20
  return { error: res.toString() };
21
21
  }
@@ -55,15 +55,15 @@ const incrementDynamo = async ({ tableName, pkName, pkValue, fieldName, incremen
55
55
  Key: { [pkName]: pkValue },
56
56
  UpdateExpression: `ADD #field :increment`,
57
57
  ExpressionAttributeNames: {
58
- '#field': fieldName,
58
+ "#field": fieldName,
59
59
  },
60
60
  ExpressionAttributeValues: {
61
- ':increment': incrementValue,
61
+ ":increment": incrementValue,
62
62
  },
63
- ReturnValues: 'UPDATED_NEW',
63
+ ReturnValues: "UPDATED_NEW",
64
64
  };
65
65
  try {
66
- const res = await (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.UpdateCommand(updateParams)), 'incrementDynamo');
66
+ const res = await (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.UpdateCommand(updateParams)), "incrementDynamo");
67
67
  if (res.$metadata.httpStatusCode !== 200) {
68
68
  return { error: res.toString() };
69
69
  }
@@ -77,20 +77,20 @@ const incrementDynamo = async ({ tableName, pkName, pkValue, fieldName, incremen
77
77
  };
78
78
  exports.incrementDynamo = incrementDynamo;
79
79
  const getDynamoUpdates = (item, options) => {
80
- const excludeKeys = (options?.excludeKeys ?? ['PK']).map((k) => k.toLowerCase());
80
+ const excludeKeys = (options?.excludeKeys ?? ["PK"]).map((k) => k.toLowerCase());
81
81
  const validEntries = Object.entries(item).filter(([key, value]) => !excludeKeys.includes(key.toLowerCase()) && value != null);
82
82
  const ExpressionAttributeNames = {};
83
83
  const ExpressionAttributeValues = {};
84
84
  const UpdateExpression = validEntries.reduce((expr, [key, value], index) => {
85
85
  ExpressionAttributeNames[`#${key}`] = key;
86
86
  ExpressionAttributeValues[`:${key}`] = value;
87
- return `${expr}${index > 0 ? ', ' : ''}#${key} = :${key}`;
88
- }, 'SET ');
87
+ return `${expr}${index > 0 ? ", " : ""}#${key} = :${key}`;
88
+ }, "SET ");
89
89
  return {
90
90
  UpdateExpression,
91
91
  ExpressionAttributeNames,
92
92
  ExpressionAttributeValues,
93
- ReturnValues: 'UPDATED_NEW',
93
+ ReturnValues: "UPDATED_NEW",
94
94
  };
95
95
  };
96
96
  exports.getDynamoUpdates = getDynamoUpdates;
@@ -1,4 +1,4 @@
1
- import type { Key } from '../../types';
1
+ import type { Key } from "../../types";
2
2
  export type DynamoDBError = {
3
3
  error: string;
4
4
  };
@@ -41,10 +41,10 @@ export interface DynamoQueryParams {
41
41
  tableName: string;
42
42
  pkName: string;
43
43
  pkValue: string | number;
44
- pkOperator?: '=' | '<' | '>' | '<=' | '>=';
44
+ pkOperator?: "=" | "<" | ">" | "<=" | ">=";
45
45
  skName?: string;
46
46
  skValue?: string | number | [string | number, string | number];
47
- skOperator?: '=' | '<' | '>' | '<=' | '>=' | 'BETWEEN' | 'BEGINS_WITH';
47
+ skOperator?: "=" | "<" | ">" | "<=" | ">=" | "BETWEEN" | "BEGINS_WITH";
48
48
  indexName?: string;
49
49
  /**
50
50
  * - number > 0: Limit the total number of items returned.
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isError = void 0;
4
- const isError = (result) => 'error' in result;
4
+ const isError = (result) => "error" in result;
5
5
  exports.isError = isError;
@@ -1,6 +1,17 @@
1
+ interface DynamoTableConstruct {
2
+ node: {
3
+ _children: {
4
+ Resource: {
5
+ node: {
6
+ scope: unknown;
7
+ };
8
+ };
9
+ };
10
+ };
11
+ }
1
12
  /** ensure that dynamo tables in stack dont exceed passed in provisioned limits */
2
13
  export declare const enforceDynamoProvisionCap: ({ tables, readsMax, writesMax, mustEqual, }: {
3
- tables: any[];
14
+ tables: DynamoTableConstruct[];
4
15
  /**
5
16
  * default 25
6
17
  */
@@ -14,3 +25,4 @@ export declare const enforceDynamoProvisionCap: ({ tables, readsMax, writesMax,
14
25
  */
15
26
  mustEqual?: boolean;
16
27
  }) => void;
28
+ export {};
@@ -7,16 +7,15 @@ const json_1 = require("../../common/helpers/string/json");
7
7
  const trim_1 = require("../../common/helpers/string/trim");
8
8
  const extractSum = ({ str, regex }) => (0, math_1.sumArray)(str
9
9
  .match(regex)
10
- ?.map((s2) => (0, trim_1.trim)(s2.substring(s2.indexOf(':') + 1), ':', ',', ' '))
10
+ ?.map((s2) => (0, trim_1.trim)(s2.substring(s2.indexOf(":") + 1), ":", ",", " "))
11
11
  .filter((r) => r && Number(r))
12
12
  .map((r) => Number(r)) ?? []);
13
13
  /** ensure that dynamo tables in stack dont exceed passed in provisioned limits */
14
14
  const enforceDynamoProvisionCap = ({ tables, readsMax = 25, writesMax = 25, mustEqual = false, }) => {
15
15
  if (tables.length === 0) {
16
- (0, log_1.warn)('error in dynamo FT enforce');
16
+ (0, log_1.warn)("error in dynamo FT enforce");
17
17
  return;
18
18
  }
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
19
  const t = tables[0];
21
20
  const s = (0, json_1.safeStringify)(t.node._children.Resource.node.scope);
22
21
  const reads = extractSum({ str: s, regex: /readCapacityUnits.*/gim });
@@ -24,7 +23,7 @@ const enforceDynamoProvisionCap = ({ tables, readsMax = 25, writesMax = 25, must
24
23
  (0, log_1.warn)(`dynamo table provisioned reads:${reads}/${readsMax}`);
25
24
  (0, log_1.warn)(`dynamo table provisioned writes:${writes}/${writesMax}`);
26
25
  if (reads > readsMax || writes > writesMax) {
27
- throw new Error('exceeded dynamo provision cap');
26
+ throw new Error("exceeded dynamo provision cap");
28
27
  }
29
28
  if (mustEqual && (reads !== readsMax || writes !== writesMax)) {
30
29
  throw new Error(`dynamo provision cap not met`);
@@ -19,7 +19,7 @@ const addToBlocklist = (apiKey, service) => {
19
19
  };
20
20
  // Get available API keys from environment (internal use only)
21
21
  const getApiKeys = () => {
22
- return (process.env.GOOGLE_API_KEY ?? '').split(',').filter(array_1.notEmpty);
22
+ return (process.env.GOOGLE_API_KEY ?? "").split(",").filter(array_1.notEmpty);
23
23
  };
24
24
  // Get available key+service combinations
25
25
  const getAvailableCombinations = (service) => {
@@ -1,4 +1,4 @@
1
- export type ModelPreference = 'quality' | 'fast' | undefined;
1
+ export type ModelPreference = "quality" | "fast" | undefined;
2
2
  export declare const geminiPromptImage: ({ prompt, urls, ident, prefer, }: {
3
3
  prompt: string;
4
4
  urls?: string[];
@@ -11,22 +11,22 @@ const retryOnError_1 = require("../retryOnError");
11
11
  const apikey_1 = require("./apikey");
12
12
  let genAIs;
13
13
  const geminiModelsCache = new node_cache_1.TypedNodeCache({ stdTTL: 86400 });
14
- const geminiModelsCacheKey = 'gemini-models-v1';
14
+ const geminiModelsCacheKey = "gemini-models-v1";
15
15
  const FALLBACK_GEMINI_MODELS = [
16
- 'gemini-3-flash-preview',
17
- 'gemini-3-pro-preview',
18
- 'gemini-2.5-pro',
19
- 'gemini-2.5-flash',
20
- 'gemini-2.5-flash-lite',
16
+ "gemini-3-flash-preview",
17
+ "gemini-3-pro-preview",
18
+ "gemini-2.5-pro",
19
+ "gemini-2.5-flash",
20
+ "gemini-2.5-flash-lite",
21
21
  ];
22
22
  // Helper to sort models based on preference
23
23
  const sortModelsByPreference = (models, prefer) => {
24
24
  const modelArray = [...models];
25
- if (prefer === 'quality') {
25
+ if (prefer === "quality") {
26
26
  // Sort pro models first
27
27
  return modelArray.sort((a, b) => {
28
- const aIsPro = a.includes('pro');
29
- const bIsPro = b.includes('pro');
28
+ const aIsPro = a.includes("pro");
29
+ const bIsPro = b.includes("pro");
30
30
  if (aIsPro && !bIsPro)
31
31
  return -1;
32
32
  if (!aIsPro && bIsPro)
@@ -34,11 +34,11 @@ const sortModelsByPreference = (models, prefer) => {
34
34
  return 0;
35
35
  });
36
36
  }
37
- else if (prefer === 'fast') {
37
+ else if (prefer === "fast") {
38
38
  // Sort flash models first
39
39
  return modelArray.sort((a, b) => {
40
- const aIsFlash = a.includes('flash');
41
- const bIsFlash = b.includes('flash');
40
+ const aIsFlash = a.includes("flash");
41
+ const bIsFlash = b.includes("flash");
42
42
  if (aIsFlash && !bIsFlash)
43
43
  return -1;
44
44
  if (!aIsFlash && bIsFlash)
@@ -49,16 +49,16 @@ const sortModelsByPreference = (models, prefer) => {
49
49
  // Default behavior - no sorting
50
50
  return modelArray;
51
51
  };
52
- const normalizeModelName = (name) => name.replace(/^models\//, '');
52
+ const normalizeModelName = (name) => name.replace(/^models\//, "");
53
53
  const getAvailableGeminiModels = async () => {
54
54
  const cachedModels = geminiModelsCache.get(geminiModelsCacheKey);
55
55
  if (cachedModels && cachedModels.length > 0) {
56
56
  return cachedModels;
57
57
  }
58
- const keyServiceCombinations = (0, apikey_1.getAvailableCombinations)('gemini');
58
+ const keyServiceCombinations = (0, apikey_1.getAvailableCombinations)("gemini");
59
59
  const key = keyServiceCombinations[0]?.key;
60
60
  if (!key) {
61
- (0, log_1.warn)('No GOOGLE_API_KEY available. Falling back to default Gemini models.');
61
+ (0, log_1.warn)("No GOOGLE_API_KEY available. Falling back to default Gemini models.");
62
62
  return [...FALLBACK_GEMINI_MODELS];
63
63
  }
64
64
  try {
@@ -69,12 +69,12 @@ const getAvailableGeminiModels = async () => {
69
69
  const payload = (await response.json());
70
70
  const discoveredModels = [
71
71
  ...new Set((payload.models ?? [])
72
- .filter((m) => (m.supportedGenerationMethods ?? []).includes('generateContent'))
73
- .map((m) => normalizeModelName(m.name ?? ''))
74
- .filter((name) => name.startsWith('gemini') && !name.includes('embedding'))),
72
+ .filter((m) => (m.supportedGenerationMethods ?? []).includes("generateContent"))
73
+ .map((m) => normalizeModelName(m.name ?? ""))
74
+ .filter((name) => name.startsWith("gemini") && !name.includes("embedding"))),
75
75
  ];
76
76
  if (discoveredModels.length === 0) {
77
- throw new Error('no gemini generateContent models discovered');
77
+ throw new Error("no gemini generateContent models discovered");
78
78
  }
79
79
  geminiModelsCache.set(geminiModelsCacheKey, discoveredModels);
80
80
  (0, log_1.info)(`loaded ${discoveredModels.length} Gemini models from API`);
@@ -87,9 +87,8 @@ const getAvailableGeminiModels = async () => {
87
87
  };
88
88
  // Helper to get available key+model combinations
89
89
  const getAvailableGeminiCombinations = async (prefer) => {
90
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
91
90
  if (!genAIs || genAIs.length === 0) {
92
- const keyServiceCombinations = (0, apikey_1.getAvailableCombinations)('gemini');
91
+ const keyServiceCombinations = (0, apikey_1.getAvailableCombinations)("gemini");
93
92
  const keys = keyServiceCombinations.map((combo) => combo.key);
94
93
  genAIs = keys.map((k) => [k, new genai_1.GoogleGenAI({ apiKey: k })]);
95
94
  }
@@ -112,9 +111,8 @@ const geminiPromptImage = async ({ prompt, urls, ident, prefer, }) => {
112
111
  if (urls && urls.length > 0) {
113
112
  images = await (0, async_1.asyncMap)(urls, (i) => (0, fetch_1.fetchToMemory)(i));
114
113
  }
115
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
116
114
  if (images.find((a) => !a)) {
117
- throw new Error('image not downloaded correctly');
115
+ throw new Error("image not downloaded correctly");
118
116
  }
119
117
  const r = await (0, exports.geminiPromptDirect)({
120
118
  prompt,
@@ -128,14 +126,14 @@ exports.geminiPromptImage = geminiPromptImage;
128
126
  const geminiPromptDirect = async ({ prompt, images = [], ident, prefer, groundedSearch = false, }) => {
129
127
  const parts = images.map((i) => ({
130
128
  inlineData: {
131
- data: Buffer.from(i.arraybuffer).toString('base64'),
129
+ data: Buffer.from(i.arraybuffer).toString("base64"),
132
130
  mimeType: i.type,
133
131
  },
134
132
  }));
135
- return (0, retryOnError_1.retryOnError)(`geminiPromptDirect:${ident ?? 'unknown'}`, async () => {
133
+ return (0, retryOnError_1.retryOnError)(`geminiPromptDirect:${ident ?? "unknown"}`, async () => {
136
134
  const combinations = await getAvailableGeminiCombinations(prefer);
137
135
  if (combinations.length === 0) {
138
- throw new Error('No available API key and model combinations');
136
+ throw new Error("No available API key and model combinations");
139
137
  }
140
138
  const [key, ai, selectedModel] = combinations[0];
141
139
  // Prepare the request configuration
@@ -148,22 +146,22 @@ const geminiPromptDirect = async ({ prompt, images = [], ident, prefer, grounded
148
146
  if (groundedSearch) {
149
147
  requestConfig.config.tools = [{ googleSearch: {} }];
150
148
  }
151
- (0, log_1.info)('gem query on:' + selectedModel, requestConfig);
149
+ (0, log_1.info)("gem query on:" + selectedModel, requestConfig);
152
150
  try {
153
151
  const response = await ai.models.generateContent(requestConfig);
154
- const rawtext = (response.text ?? '')
155
- .replace(/```(json)?/gi, '')
156
- .replace(/:[ ]+undefined/gim, ': null');
157
- (0, log_1.info)('gem response');
158
- (0, log_1.debug)('gem prompt:' + prompt, ident);
159
- (0, log_1.debug)('gem response:' + rawtext);
160
- (0, log_1.debug)('gem query usage:' + JSON.stringify(response.usageMetadata));
152
+ const rawtext = (response.text ?? "")
153
+ .replace(/```(json)?/gi, "")
154
+ .replace(/:[ ]+undefined/gim, ": null");
155
+ (0, log_1.info)("gem response");
156
+ (0, log_1.debug)("gem prompt:" + prompt, ident);
157
+ (0, log_1.debug)("gem response:" + rawtext);
158
+ (0, log_1.debug)("gem query usage:" + JSON.stringify(response.usageMetadata));
161
159
  return rawtext;
162
160
  }
163
161
  catch (e) {
164
162
  const mod = `gemini-${selectedModel}`;
165
163
  if ((0, retryOnError_1.isOverloadedApiKeyError)(e)) {
166
- (0, log_1.warn)('throughput exceeded for gemini:', mod);
164
+ (0, log_1.warn)("throughput exceeded for gemini:", mod);
167
165
  (0, apikey_1.blockKeyService)(key, mod);
168
166
  }
169
167
  throw e;
@@ -172,35 +170,35 @@ const geminiPromptDirect = async ({ prompt, images = [], ident, prefer, grounded
172
170
  };
173
171
  exports.geminiPromptDirect = geminiPromptDirect;
174
172
  const resolveGroundedUrl = async (url) => {
175
- if (!url.includes('vertexaisearch.cloud.google.com')) {
176
- (0, log_1.debug)('not a grounded url', url);
173
+ if (!url.includes("vertexaisearch.cloud.google.com")) {
174
+ (0, log_1.debug)("not a grounded url", url);
177
175
  return url;
178
176
  }
179
177
  try {
180
- (0, log_1.debug)('resolving grounded url', url);
178
+ (0, log_1.debug)("resolving grounded url", url);
181
179
  // Fetch the grounded URL with redirect following disabled
182
180
  const response = await fetch(url, {
183
- method: 'HEAD',
184
- redirect: 'manual',
181
+ method: "HEAD",
182
+ redirect: "manual",
185
183
  });
186
184
  // Check for redirect responses (301, 302, 307, 308)
187
185
  if (response.status >= 300 && response.status < 400) {
188
- const location = response.headers.get('location') || response.headers.get('Location');
186
+ const location = response.headers.get("location") || response.headers.get("Location");
189
187
  if (location) {
190
- (0, log_1.debug)('resolved grounded url to', location);
188
+ (0, log_1.debug)("resolved grounded url to", location);
191
189
  return location;
192
190
  }
193
191
  }
194
192
  // If no redirect, try a GET request to follow any JavaScript redirects
195
193
  const fullResponse = await fetch(url, {
196
- redirect: 'follow',
194
+ redirect: "follow",
197
195
  });
198
196
  const finalUrl = fullResponse.url;
199
- (0, log_1.debug)('resolved grounded url via GET to', finalUrl);
197
+ (0, log_1.debug)("resolved grounded url via GET to", finalUrl);
200
198
  return finalUrl;
201
199
  }
202
200
  catch (error) {
203
- (0, log_1.debug)('error resolving grounded url', error);
201
+ (0, log_1.debug)("error resolving grounded url", error);
204
202
  // Return original URL if resolution fails
205
203
  return url;
206
204
  }
@@ -1,2 +1,2 @@
1
- export * from './apikey';
2
- export * from './gemini';
1
+ export * from "./apikey";
2
+ export * from "./gemini";