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
@@ -1,17 +1,17 @@
1
- export * from './acm';
2
- export * from './api';
3
- export * from './apigw';
4
- export * from './aws';
5
- export * from './cosmos';
6
- export * from './dynamo';
7
- export * from './enforceDynamoProvisionCap';
8
- export * from './google';
9
- export * from './retryOnError';
10
- export * from './s3';
11
- export * from './ses';
12
- export * from './sqs';
13
- export * from './ssm';
14
- export * from './ssmInfra';
15
- export * from './sts';
16
- export * from './validations';
17
- export * from './zod';
1
+ export * from "./acm";
2
+ export * from "./api";
3
+ export * from "./apigw";
4
+ export * from "./aws";
5
+ export * from "./cosmos";
6
+ export * from "./dynamo";
7
+ export * from "./enforceDynamoProvisionCap";
8
+ export * from "./google";
9
+ export * from "./retryOnError";
10
+ export * from "./s3";
11
+ export * from "./ses";
12
+ export * from "./sqs";
13
+ export * from "./ssm";
14
+ export * from "./ssmInfra";
15
+ export * from "./sts";
16
+ export * from "./validations";
17
+ export * from "./zod";
@@ -3,19 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sleep = exports.isRetryableApiError = exports.isOverloadedApiKeyError = exports.retryableErrorMessages = exports.overloadedMessages = void 0;
4
4
  exports.retryOnError = retryOnError;
5
5
  const log_1 = require("../../common/helpers/log");
6
- exports.overloadedMessages = [
7
- '429',
8
- 'current usage',
9
- 'current quota',
10
- 'overloaded',
11
- ];
6
+ exports.overloadedMessages = ["429", "current usage", "current quota", "overloaded"];
12
7
  exports.retryableErrorMessages = [
13
8
  ...exports.overloadedMessages,
14
- '500',
15
- '503',
16
- 'safety',
17
- 'invalid_type',
18
- 'expected',
9
+ "500",
10
+ "503",
11
+ "safety",
12
+ "invalid_type",
13
+ "expected",
19
14
  ];
20
15
  const errorContainsAnyMessage = (error, messages) => {
21
16
  const message = error.message.toLowerCase();
@@ -1,16 +1,16 @@
1
- import { S3Client } from '@aws-sdk/client-s3';
2
- import type { StreamingBlobPayloadOutputTypes } from '@smithy/types';
3
- import type { Buffer } from 'buffer';
4
- export type StorageProvider = 's3' | 'r2';
1
+ import type { Buffer } from "buffer";
2
+ import type { GetObjectCommandOutput } from "@aws-sdk/client-s3";
3
+ import { S3Client } from "@aws-sdk/client-s3";
4
+ export type StorageProvider = "s3" | "r2";
5
5
  export type StorageConfig = {
6
- provider: 's3';
6
+ provider: "s3";
7
7
  region?: string;
8
8
  endpoint?: string;
9
9
  accountId?: string;
10
10
  accessKeyId?: string;
11
11
  secretAccessKey?: string;
12
12
  } | {
13
- provider: 'r2';
13
+ provider: "r2";
14
14
  accountId: string;
15
15
  accessKeyId?: string;
16
16
  secretAccessKey?: string;
@@ -32,18 +32,18 @@ export declare const getS3Object: ({ fileurl: { Bucket, Key }, }: {
32
32
  export interface IS3Object {
33
33
  bucket: string;
34
34
  key: string;
35
- content: StreamingBlobPayloadOutputTypes;
35
+ content: NonNullable<GetObjectCommandOutput["Body"]>;
36
36
  }
37
37
  /** function generator to get s3 files */
38
- export declare function getS3Objects({ bucket, keys, }: {
38
+ export declare function getS3Objects({ bucket, keys }: {
39
39
  bucket: string;
40
40
  keys: string[];
41
41
  }): AsyncGenerator<{
42
42
  error: string;
43
43
  data?: undefined;
44
44
  } | {
45
- data: IS3Object;
46
45
  error?: undefined;
46
+ data: IS3Object;
47
47
  }, void, unknown>;
48
48
  export declare const putS3Object: ({ Body, Bucket, Key, ContentType, CacheControl, }: {
49
49
  ContentType?: string;
@@ -14,7 +14,7 @@ const object_1 = require("../../common/helpers/object");
14
14
  // Cache for memoization
15
15
  const clientCache = new Map();
16
16
  const getCacheKey = (config) => {
17
- if (config.provider === 'r2') {
17
+ if (config.provider === "r2") {
18
18
  return JSON.stringify({
19
19
  provider: config.provider,
20
20
  accountId: config.accountId,
@@ -34,10 +34,10 @@ const createStorageClient = (config) => {
34
34
  return cachedClient;
35
35
  }
36
36
  let client;
37
- if (config.provider === 'r2') {
37
+ if (config.provider === "r2") {
38
38
  const accountId = config.accountId || process.env.CLOUDFLARE_ACCOUNT_ID;
39
39
  if (!accountId) {
40
- throw new Error('Account ID is required for R2. Set CLOUDFLARE_ACCOUNT_ID env var or provide accountId in config');
40
+ throw new Error("Account ID is required for R2. Set CLOUDFLARE_ACCOUNT_ID env var or provide accountId in config");
41
41
  }
42
42
  client = new client_s3_1.S3Client({
43
43
  endpoint: `https://${accountId}.r2.cloudflarestorage.com`,
@@ -50,7 +50,7 @@ const createStorageClient = (config) => {
50
50
  },
51
51
  }
52
52
  : {}),
53
- region: config.region ?? 'auto',
53
+ region: config.region ?? "auto",
54
54
  });
55
55
  }
56
56
  else {
@@ -68,14 +68,14 @@ const setS3 = (config) => {
68
68
  };
69
69
  exports.setS3 = setS3;
70
70
  (0, exports.setS3)({
71
- provider: 's3',
72
- region: 'ap-southeast-2',
71
+ provider: "s3",
72
+ region: "ap-southeast-2",
73
73
  });
74
74
  const getS3Object = async ({ fileurl: { Bucket, Key }, }) => {
75
75
  try {
76
76
  const r = await s3.send(new client_s3_1.GetObjectCommand({ Bucket, Key }));
77
77
  if (!r.Body) {
78
- throw new Error('no body returned');
78
+ throw new Error("no body returned");
79
79
  }
80
80
  const data = {
81
81
  bucket: Bucket,
@@ -90,7 +90,7 @@ const getS3Object = async ({ fileurl: { Bucket, Key }, }) => {
90
90
  };
91
91
  exports.getS3Object = getS3Object;
92
92
  /** function generator to get s3 files */
93
- async function* getS3Objects({ bucket, keys, }) {
93
+ async function* getS3Objects({ bucket, keys }) {
94
94
  let toProcess = keys.map((Key) => ({
95
95
  Bucket: bucket,
96
96
  Key,
@@ -99,8 +99,9 @@ async function* getS3Objects({ bucket, keys, }) {
99
99
  const { part, rest } = (0, array_1.take)(toProcess, 1);
100
100
  toProcess = rest;
101
101
  const fileurl = part[0];
102
+ // oxlint-disable-next-line no-await-in-loop -- generator results must preserve input order
102
103
  const g = await (0, exports.getS3Object)({ fileurl });
103
- if ('error' in g) {
104
+ if ("error" in g) {
104
105
  yield { error: g.error };
105
106
  }
106
107
  else {
@@ -108,7 +109,7 @@ async function* getS3Objects({ bucket, keys, }) {
108
109
  }
109
110
  }
110
111
  }
111
- const putS3Object = async ({ Body, Bucket, Key, ContentType, CacheControl = 'public, max-age=300', }) => {
112
+ const putS3Object = async ({ Body, Bucket, Key, ContentType, CacheControl = "public, max-age=300", }) => {
112
113
  try {
113
114
  const r = await s3.send(new client_s3_1.PutObjectCommand({ Body, Bucket, Key, ContentType, CacheControl }));
114
115
  const code = r.$metadata.httpStatusCode;
@@ -141,12 +142,13 @@ const deleteFiles = async ({ Bucket, Keys, }) => {
141
142
  while (toDelete.length > 0) {
142
143
  const { part, rest } = (0, array_1.take)(toDelete, 900);
143
144
  toDelete = rest;
145
+ // oxlint-disable-next-line no-await-in-loop -- deletion batches are intentionally bounded
144
146
  const res = await s3.send(new client_s3_1.DeleteObjectsCommand({
145
147
  Bucket,
146
148
  Delete: { Objects: part },
147
149
  }));
148
150
  if (!res.Deleted?.length) {
149
- throw new Error('no deleted files');
151
+ throw new Error("no deleted files");
150
152
  }
151
153
  deleted += res.Deleted.length;
152
154
  (0, log_1.debug)(`deleted ${deleted} files`);
@@ -163,7 +165,7 @@ const copyFile = async ({ Bucket, fromKey, toKey, deleteSource = false, }) => {
163
165
  (0, log_1.debug)(`copying s3 file from ${Bucket}- ${fromKey} to ${toKey}`);
164
166
  await s3.send(new client_s3_1.CopyObjectCommand({
165
167
  //incl bucket
166
- CopySource: Bucket + '/' + fromKey,
168
+ CopySource: Bucket + "/" + fromKey,
167
169
  //dest
168
170
  Bucket,
169
171
  Key: toKey,
@@ -186,6 +188,7 @@ async function listFiles(bucketName, opt) {
186
188
  const ret = [];
187
189
  let response;
188
190
  do {
191
+ // oxlint-disable-next-line no-await-in-loop -- pagination depends on the prior continuation token
189
192
  response = await s3.send(new client_s3_1.ListObjectsV2Command({
190
193
  Bucket: bucketName,
191
194
  ContinuationToken: response?.NextContinuationToken,
@@ -198,7 +201,7 @@ async function listFiles(bucketName, opt) {
198
201
  return { data: (0, array_1.distinct)(ret.filter((r) => r)) };
199
202
  }
200
203
  catch (err) {
201
- (0, log_1.error)('Error', err);
204
+ (0, log_1.error)("Error", err);
202
205
  return { error: err.toString() };
203
206
  }
204
207
  }
@@ -222,8 +225,8 @@ async function getPresignedPostURL({ bucket, key, maxMb = 5, }) {
222
225
  Key: key,
223
226
  Expires: 600,
224
227
  Conditions: [
225
- ['content-length-range', 0, maxMb * 1049000], // content length restrictions: 0-5MB
226
- ['starts-with', '$Content-Type', 'image/'],
228
+ ["content-length-range", 0, maxMb * 1049000], // content length restrictions: 0-5MB
229
+ ["starts-with", "$Content-Type", "image/"],
227
230
  ],
228
231
  });
229
232
  const fields = (0, object_1.copy)(ps.fields);
@@ -253,7 +256,7 @@ async function getPresignedPutUrl({ bucket, key, contentType, contentLength, exp
253
256
  expiresIn,
254
257
  // Sign the Content-Length header so it's enforced
255
258
  ...(contentLength !== undefined && {
256
- signableHeaders: new Set(['content-length']),
259
+ signableHeaders: new Set(["content-length"]),
257
260
  }),
258
261
  });
259
262
  return { data: url };
@@ -1,4 +1,4 @@
1
- import { SESClient } from '@aws-sdk/client-ses';
1
+ import { SESClient } from "@aws-sdk/client-ses";
2
2
  export declare const setSes: (region: string) => SESClient;
3
3
  export declare let ses: SESClient;
4
4
  export interface ISendEmail {
@@ -9,16 +9,16 @@ const setSes = (region) => {
9
9
  return raw;
10
10
  };
11
11
  exports.setSes = setSes;
12
- exports.ses = (0, exports.setSes)('ap-southeast-2');
12
+ exports.ses = (0, exports.setSes)("ap-southeast-2");
13
13
  const sendEmail = async ({ to, message, subject, sourceArn, from, }) => {
14
14
  try {
15
- const sourceArnRegion = sourceArn.match(':ses:(.*?):')?.[1];
15
+ const sourceArnRegion = sourceArn.match(":ses:(.*?):")?.[1];
16
16
  if (sourceArn !== exports.ses.config.region && sourceArnRegion) {
17
- (0, log_1.warn)('ses arn not equal to config region changing to:' + sourceArnRegion);
17
+ (0, log_1.warn)("ses arn not equal to config region changing to:" + sourceArnRegion);
18
18
  (0, exports.setSes)(sourceArnRegion);
19
19
  }
20
- const ishtml = message.startsWith('<!DOCTYPE HTML') || message.startsWith('<html');
21
- (0, log_1.warn)('sending email. html=' + ishtml);
20
+ const ishtml = message.startsWith("<!DOCTYPE HTML") || message.startsWith("<html");
21
+ (0, log_1.warn)("sending email. html=" + ishtml);
22
22
  await exports.ses.send(new client_ses_1.SendEmailCommand({
23
23
  Destination: {
24
24
  CcAddresses: [],
@@ -29,18 +29,18 @@ const sendEmail = async ({ to, message, subject, sourceArn, from, }) => {
29
29
  ...(ishtml && {
30
30
  Html: {
31
31
  Data: message,
32
- Charset: 'UTF-8',
32
+ Charset: "UTF-8",
33
33
  },
34
34
  }),
35
35
  ...(!ishtml && {
36
36
  Text: {
37
37
  Data: message,
38
- Charset: 'UTF-8',
38
+ Charset: "UTF-8",
39
39
  },
40
40
  }),
41
41
  },
42
42
  Subject: {
43
- Charset: 'UTF-8',
43
+ Charset: "UTF-8",
44
44
  Data: subject,
45
45
  },
46
46
  },
@@ -51,7 +51,7 @@ const sendEmail = async ({ to, message, subject, sourceArn, from, }) => {
51
51
  return {};
52
52
  }
53
53
  catch (e) {
54
- (0, log_1.warn)('ses send error:' + JSON.stringify(e));
54
+ (0, log_1.warn)("ses send error:" + JSON.stringify(e));
55
55
  return { error: e.toString() };
56
56
  }
57
57
  };
@@ -1,4 +1,4 @@
1
- import { SQSClient } from '@aws-sdk/client-sqs';
1
+ import { SQSClient } from "@aws-sdk/client-sqs";
2
2
  export declare const setSqs: (region: string) => SQSClient;
3
3
  export declare const sqs: SQSClient;
4
4
  export declare const sendMessages: <T>(items: T[], queueUrl: string) => Promise<{
@@ -8,7 +8,7 @@ const setSqs = (region) => {
8
8
  return raw;
9
9
  };
10
10
  exports.setSqs = setSqs;
11
- exports.sqs = (0, exports.setSqs)('ap-southeast-2');
11
+ exports.sqs = (0, exports.setSqs)("ap-southeast-2");
12
12
  const sendMessages = async (items, queueUrl) => {
13
13
  const p = await exports.sqs.send(new client_sqs_1.SendMessageBatchCommand({
14
14
  QueueUrl: queueUrl,
@@ -1,4 +1,4 @@
1
- import type { Stack } from 'aws-cdk-lib';
1
+ import type { Stack } from "aws-cdk-lib";
2
2
  /**
3
3
  * save a value to ssm
4
4
  * @param param0
@@ -10,7 +10,7 @@ const base64_1 = require("../../common/helpers/string/base64");
10
10
  const saveToSsm = ({ stack, path, value, }) => {
11
11
  const name = (0, base64_1.toBase64)(path);
12
12
  new aws_cdk_lib_1.aws_ssm.StringParameter(stack, name, {
13
- allowedPattern: '.*',
13
+ allowedPattern: ".*",
14
14
  description: `${name} (cdk)`,
15
15
  parameterName: path,
16
16
  stringValue: value,
@@ -25,5 +25,5 @@ exports.loadSsmString = loadSsmString;
25
25
  const loadSsmStringSynth = ({ stack, path, }) => aws_cdk_lib_1.aws_ssm.StringParameter.valueFromLookup(stack, path);
26
26
  exports.loadSsmStringSynth = loadSsmStringSynth;
27
27
  /** load a csv from ssm */
28
- const loadSsmStringList = ({ stack, path, }) => aws_cdk_lib_1.Fn.split(',', (0, exports.loadSsmString)({ stack, path }));
28
+ const loadSsmStringList = ({ stack, path, }) => aws_cdk_lib_1.Fn.split(",", (0, exports.loadSsmString)({ stack, path }));
29
29
  exports.loadSsmStringList = loadSsmStringList;
@@ -1,9 +1,9 @@
1
- import type { Stack } from 'aws-cdk-lib';
2
- import { aws_iam as iam } from 'aws-cdk-lib';
3
- import type { IWebSocketApi, WebSocketStage } from 'aws-cdk-lib/aws-apigatewayv2';
4
- import { WebSocketApi } from 'aws-cdk-lib/aws-apigatewayv2';
5
- import type { IUser } from 'aws-cdk-lib/aws-iam';
6
- export declare const generateApigwRef: ({ stack, baseKey, }: {
1
+ import type { Stack } from "aws-cdk-lib";
2
+ import { aws_iam as iam } from "aws-cdk-lib";
3
+ import type { IWebSocketApi, WebSocketStage } from "aws-cdk-lib/aws-apigatewayv2";
4
+ import { WebSocketApi } from "aws-cdk-lib/aws-apigatewayv2";
5
+ import type { IUser } from "aws-cdk-lib/aws-iam";
6
+ export declare const generateApigwRef: ({ stack, baseKey }: {
7
7
  stack: Stack;
8
8
  baseKey: string;
9
9
  }) => {
@@ -6,7 +6,7 @@ exports.grantWebSocketManageConnectionsToRole = grantWebSocketManageConnectionsT
6
6
  const aws_cdk_lib_1 = require("aws-cdk-lib");
7
7
  const aws_apigatewayv2_1 = require("aws-cdk-lib/aws-apigatewayv2");
8
8
  const ssm_1 = require("../ssm");
9
- const generateApigwRef = ({ stack, baseKey, }) => {
9
+ const generateApigwRef = ({ stack, baseKey }) => {
10
10
  const webSocketId = (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/id` });
11
11
  const apiEndpoint = (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/endpoint` });
12
12
  const stageName = (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/stage` });
@@ -25,22 +25,18 @@ const generateApigwSSMParams = ({ stack, api, baseKey, stage, }) => {
25
25
  exports.generateApigwSSMParams = generateApigwSSMParams;
26
26
  function grantWebSocketManageConnectionsToUser(stack, apiGw, stage, user) {
27
27
  const statement = new aws_cdk_lib_1.aws_iam.PolicyStatement({
28
- actions: ['execute-api:ManageConnections'],
29
- resources: [
30
- `arn:aws:execute-api:${stack.region}:${stack.account}:${apiGw.apiId}/${stage}/*`,
31
- ],
28
+ actions: ["execute-api:ManageConnections"],
29
+ resources: [`arn:aws:execute-api:${stack.region}:${stack.account}:${apiGw.apiId}/${stage}/*`],
32
30
  });
33
- const policy = new aws_cdk_lib_1.aws_iam.ManagedPolicy(stack, 'WebSocketConnectionPolicy', {
31
+ const policy = new aws_cdk_lib_1.aws_iam.ManagedPolicy(stack, "WebSocketConnectionPolicy", {
34
32
  statements: [statement],
35
33
  });
36
34
  user.addManagedPolicy(policy);
37
35
  }
38
36
  function grantWebSocketManageConnectionsToRole(stack, apiGw, stage, ref) {
39
37
  const statement = new aws_cdk_lib_1.aws_iam.PolicyStatement({
40
- actions: ['execute-api:ManageConnections'],
41
- resources: [
42
- `arn:aws:execute-api:${stack.region}:${stack.account}:${apiGw.apiId}/${stage}/*`,
43
- ],
38
+ actions: ["execute-api:ManageConnections"],
39
+ resources: [`arn:aws:execute-api:${stack.region}:${stack.account}:${apiGw.apiId}/${stage}/*`],
44
40
  });
45
41
  ref.addToRolePolicy(statement);
46
42
  }
@@ -1,5 +1,5 @@
1
- import type { Stack } from 'aws-cdk-lib';
2
- import { aws_dynamodb as dynamodb } from 'aws-cdk-lib';
1
+ import type { Stack } from "aws-cdk-lib";
2
+ import { aws_dynamodb as dynamodb } from "aws-cdk-lib";
3
3
  export declare const generateTableRef: ({ stack, baseKey, hasStream, hasGSI, }: {
4
4
  hasStream: boolean;
5
5
  hasGSI: boolean;
@@ -31,7 +31,7 @@ const generateDynamoSSMParams = ({ stack, table, baseKey, gsi, }) => {
31
31
  (0, ssm_1.saveToSsm)({
32
32
  stack,
33
33
  path: `${baseKey}/gsi`,
34
- value: gsi.join(','),
34
+ value: gsi.join(","),
35
35
  });
36
36
  }
37
37
  };
@@ -1,4 +1,4 @@
1
- export * from './apigw';
2
- export * from './dynamo';
3
- export * from './s3';
4
- export * from './sqs';
1
+ export * from "./apigw";
2
+ export * from "./dynamo";
3
+ export * from "./s3";
4
+ export * from "./sqs";
@@ -1,11 +1,11 @@
1
- import type { Stack } from 'aws-cdk-lib';
2
- import { aws_s3 as s3 } from 'aws-cdk-lib';
1
+ import type { Stack } from "aws-cdk-lib";
2
+ import { aws_s3 as s3 } from "aws-cdk-lib";
3
3
  export declare const generateS3SSMParams: ({ stack, bucket, baseKey, }: {
4
4
  stack: Stack;
5
5
  bucket: s3.IBucket;
6
6
  baseKey: string;
7
7
  }) => void;
8
- export declare const generateBucketRef: ({ stack, baseKey, }: {
8
+ export declare const generateBucketRef: ({ stack, baseKey }: {
9
9
  stack: Stack;
10
10
  baseKey: string;
11
11
  }) => s3.IBucket;
@@ -8,7 +8,7 @@ const generateS3SSMParams = ({ stack, bucket, baseKey, }) => {
8
8
  (0, ssm_1.saveToSsm)({ stack, path: `${baseKey}/name`, value: bucket.bucketName });
9
9
  };
10
10
  exports.generateS3SSMParams = generateS3SSMParams;
11
- const generateBucketRef = ({ stack, baseKey, }) => {
11
+ const generateBucketRef = ({ stack, baseKey }) => {
12
12
  const bucketName = (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/name` });
13
13
  return aws_cdk_lib_1.aws_s3.Bucket.fromBucketAttributes(stack, baseKey, {
14
14
  bucketArn: (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/arn` }),
@@ -1,11 +1,11 @@
1
- import type { Stack } from 'aws-cdk-lib';
2
- import { aws_sqs as sqs } from 'aws-cdk-lib';
1
+ import type { Stack } from "aws-cdk-lib";
2
+ import { aws_sqs as sqs } from "aws-cdk-lib";
3
3
  export declare const generateSqsSSMParams: ({ stack, queue, baseKey, }: {
4
4
  stack: Stack;
5
5
  queue: sqs.IQueue;
6
6
  baseKey: string;
7
7
  }) => void;
8
- export declare const generateQueueRef: ({ stack, baseKey, }: {
8
+ export declare const generateQueueRef: ({ stack, baseKey }: {
9
9
  stack: Stack;
10
10
  baseKey: string;
11
11
  }) => sqs.IQueue;
@@ -9,7 +9,7 @@ const generateSqsSSMParams = ({ stack, queue, baseKey, }) => {
9
9
  (0, ssm_1.saveToSsm)({ stack, path: `${baseKey}/url`, value: queue.queueUrl });
10
10
  };
11
11
  exports.generateSqsSSMParams = generateSqsSSMParams;
12
- const generateQueueRef = ({ stack, baseKey, }) => {
12
+ const generateQueueRef = ({ stack, baseKey }) => {
13
13
  const queueArn = (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/arn` });
14
14
  return aws_cdk_lib_1.aws_sqs.Queue.fromQueueAttributes(stack, baseKey, {
15
15
  queueArn,
@@ -1,4 +1,4 @@
1
- import { STSClient } from '@aws-sdk/client-sts';
1
+ import { STSClient } from "@aws-sdk/client-sts";
2
2
  export declare const setSts: (region: string) => STSClient;
3
3
  export declare const sts: STSClient;
4
4
  /**
@@ -9,7 +9,7 @@ const setSts = (region) => {
9
9
  return raw;
10
10
  };
11
11
  exports.setSts = setSts;
12
- exports.sts = (0, exports.setSts)('ap-southeast-2');
12
+ exports.sts = (0, exports.setSts)("ap-southeast-2");
13
13
  /**
14
14
  * assume sts role
15
15
  * @returns {string} assumed accountId
@@ -19,16 +19,16 @@ async function assumeRole({ assumeRoleArn, region, }) {
19
19
  (0, log_1.info)(`assuming:${assumeRoleArn} in region:${region}`);
20
20
  const data = await exports.sts.send(new client_sts_1.AssumeRoleCommand({
21
21
  RoleArn: assumeRoleArn,
22
- RoleSessionName: 'stssession',
22
+ RoleSessionName: "stssession",
23
23
  }));
24
24
  if (!data.Credentials) {
25
- return { error: 'aws assume role error' };
25
+ return { error: "aws assume role error" };
26
26
  }
27
27
  if (!data.Credentials.AccessKeyId ||
28
28
  !data.Credentials.SecretAccessKey ||
29
29
  !data.Credentials.SessionToken ||
30
30
  !data.Credentials.Expiration) {
31
- return { error: 'missing cred values error' };
31
+ return { error: "missing cred values error" };
32
32
  }
33
33
  return {
34
34
  data: {
@@ -1,5 +1,5 @@
1
- import type { User } from '../../ui/helpers/jwt';
2
- import type { APIGatewayProxyResult } from '../types';
1
+ import type { User } from "../../ui/helpers/jwt";
2
+ import type { APIGatewayProxyResult } from "../types";
3
3
  export interface IGetAndValidateToken {
4
4
  /**
5
5
  * default ap-southeast-2
@@ -41,7 +41,7 @@ const jwtVerify = async ({ token, jwksUri, issuer, }) => {
41
41
  });
42
42
  }, {
43
43
  issuer,
44
- algorithms: ['RS256'],
44
+ algorithms: ["RS256"],
45
45
  }, (errorV, decoded) => {
46
46
  if (errorV) {
47
47
  reject(errorV);
@@ -52,21 +52,21 @@ const jwtVerify = async ({ token, jwksUri, issuer, }) => {
52
52
  });
53
53
  };
54
54
  /** extracts user details from oauth token */
55
- const getAndValidateToken = async ({ tokenRaw, jwksRegion = 'ap-southeast-2', COGNITO_USER_POOL_ID, }) => {
55
+ const getAndValidateToken = async ({ tokenRaw, jwksRegion = "ap-southeast-2", COGNITO_USER_POOL_ID, }) => {
56
56
  const jwksUri = `https://cognito-idp.${jwksRegion}.amazonaws.com/${COGNITO_USER_POOL_ID}/.well-known/jwks.json`;
57
57
  const issuer = `https://cognito-idp.${jwksRegion}.amazonaws.com/${COGNITO_USER_POOL_ID}`;
58
- let token = '';
58
+ let token = "";
59
59
  try {
60
60
  if (!tokenRaw) {
61
- const m = 'auth error: no auth headers';
61
+ const m = "auth error: no auth headers";
62
62
  (0, log_1.error)(m);
63
63
  return {
64
64
  error: (0, api_1.returnCode)(403, m),
65
65
  };
66
66
  }
67
- token = tokenRaw.substring(tokenRaw.indexOf(' ') + 1);
67
+ token = tokenRaw.substring(tokenRaw.indexOf(" ") + 1);
68
68
  if (!token) {
69
- const m = 'auth error: no token';
69
+ const m = "auth error: no token";
70
70
  (0, log_1.error)(m);
71
71
  return {
72
72
  error: (0, api_1.returnCode)(403, m),
@@ -78,7 +78,7 @@ const getAndValidateToken = async ({ tokenRaw, jwksRegion = 'ap-southeast-2', CO
78
78
  const decoded = (0, jsonwebtoken_1.decode)(token);
79
79
  (0, log_1.debug)(`decoded=${JSON.stringify(decoded, null, 2)}`);
80
80
  if (!decoded.email) {
81
- const m = 'auth error, no email';
81
+ const m = "auth error, no email";
82
82
  (0, log_1.error)(m);
83
83
  return {
84
84
  error: (0, api_1.returnCode)(403, m),
@@ -86,21 +86,21 @@ const getAndValidateToken = async ({ tokenRaw, jwksRegion = 'ap-southeast-2', CO
86
86
  }
87
87
  subject = decoded.sub;
88
88
  if (!subject) {
89
- const mess = 'user should have responded with subject (sub) field';
89
+ const mess = "user should have responded with subject (sub) field";
90
90
  (0, log_1.error)(mess);
91
91
  throw new Error(mess);
92
92
  }
93
93
  let { picture } = decoded;
94
- if (decoded.identities[0]?.providerName === 'Facebook') {
94
+ if (decoded.identities[0]?.providerName === "Facebook") {
95
95
  picture = JSON.parse(decoded.picture).data.url;
96
96
  }
97
97
  const userId = decoded.email.toLowerCase();
98
98
  const userProfile = {
99
- isAdmin: ['andreigec@hotmail.com', 'andreigec@gmail.com'].includes(userId),
99
+ isAdmin: ["andreigec@hotmail.com", "andreigec@gmail.com"].includes(userId),
100
100
  idJwt: decoded,
101
101
  userId,
102
- nickname: decoded.nickname || decoded['cognito:username'],
103
- fullname: decoded.name || decoded['cognito:username'],
102
+ nickname: decoded.nickname || decoded["cognito:username"],
103
+ fullname: decoded.name || decoded["cognito:username"],
104
104
  picture,
105
105
  updatedAt: parseInt(`${decoded.auth_time}000`, 10),
106
106
  };
@@ -109,14 +109,14 @@ const getAndValidateToken = async ({ tokenRaw, jwksRegion = 'ap-southeast-2', CO
109
109
  catch (e) {
110
110
  const ex = e;
111
111
  // expiry is too common to log
112
- if (ex.toString().indexOf('jwt expired') !== -1) {
112
+ if (ex.toString().indexOf("jwt expired") !== -1) {
113
113
  (0, log_1.info)(`jwt fail:${e}`);
114
114
  }
115
115
  throw e;
116
116
  }
117
117
  }
118
118
  catch (e) {
119
- const m = 'auth error:' + JSON.stringify(e, null, 2);
119
+ const m = "auth error:" + JSON.stringify(e, null, 2);
120
120
  (0, log_1.error)(m);
121
121
  return {
122
122
  error: (0, api_1.returnCode)(403, m),
@@ -1,4 +1,4 @@
1
- import type { z } from 'zod';
1
+ import type { z } from "zod";
2
2
  /**
3
3
  * Convert a Zod object schema to its code representation for use in LLM prompts.
4
4
  * Outputs actual Zod code like: z.object({ field: z.string().nullable().describe("...") })