@empiricalrun/r2-uploader 0.3.9 → 0.3.11

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @empiricalrun/r2-uploader
2
2
 
3
+ ## 0.3.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 8668785: feat: enabled params for video analysis tool
8
+
9
+ ## 0.3.10
10
+
11
+ ### Patch Changes
12
+
13
+ - 9f33a7a: chore: fetch r2 files with suffix, add created_at to summary
14
+
3
15
  ## 0.3.9
4
16
 
5
17
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,UAAU,GAAU,QAAQ,aAAa;;;;;;;;;;IA8CrD,CAAC"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,UAAU,GAAU,QAAQ,aAAa;;;;;;;;;;IAmDrD,CAAC"}
package/dist/fetch.js CHANGED
@@ -15,6 +15,7 @@ const fetchFiles = async (config) => {
15
15
  const params = {
16
16
  Bucket: config.bucket,
17
17
  Prefix: config.prefix,
18
+ MaxKeys: 20_000,
18
19
  };
19
20
  const cmd = new client_s3_1.ListObjectsV2Command(params);
20
21
  const data = await S3.send(cmd);
@@ -22,8 +23,11 @@ const fetchFiles = async (config) => {
22
23
  if (KeyCount === 0) {
23
24
  return [];
24
25
  }
26
+ const filteredContents = config.suffix
27
+ ? Contents?.filter((c) => c.Key.endsWith(config.suffix)) || []
28
+ : Contents || [];
25
29
  if (config.withSignedUrl) {
26
- return Promise.all((Contents || []).map(async (c) => {
30
+ return Promise.all(filteredContents.map(async (c) => {
27
31
  const key = c.Key;
28
32
  const getObjectCmd = new client_s3_1.GetObjectCommand({
29
33
  Bucket: config.bucket,
@@ -39,7 +43,7 @@ const fetchFiles = async (config) => {
39
43
  }));
40
44
  }
41
45
  else {
42
- return (Contents || []).map((c) => {
46
+ return filteredContents.map((c) => {
43
47
  return {
44
48
  key: c.Key,
45
49
  lastModified: c.LastModified,
package/dist/types.d.ts CHANGED
@@ -23,6 +23,7 @@ export interface R2UploadBufferConfig extends R2BaseConfig {
23
23
  export interface R2FetchConfig extends R2BaseConfig {
24
24
  prefix: string;
25
25
  withSignedUrl?: boolean;
26
+ suffix?: string;
26
27
  }
27
28
  export interface R2DeleteConfig extends R2BaseConfig {
28
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACpE;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClE;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;CAAG;AAEvD,MAAM,WAAW,OAAO;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACpE;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAClE;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;CAAG;AAEvD,MAAM,WAAW,OAAO;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../src/upload/buffer.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEzD,eAAO,MAAM,iBAAiB,GAAU,QAAQ,oBAAoB,qBA6FnE,CAAC"}
1
+ {"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../src/upload/buffer.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEzD,eAAO,MAAM,iBAAiB,GAAU,QAAQ,oBAAoB,qBAyGnE,CAAC"}
@@ -44,6 +44,7 @@ const uploadFileBuffers = async (config) => {
44
44
  name: "addETag",
45
45
  });
46
46
  try {
47
+ logger_1.logger.info(`upload:start ${file.fileName} -> ${config.bucket}/${config.destinationDir}`);
47
48
  await (0, async_retry_1.default)(async () => {
48
49
  try {
49
50
  const data = await S3.send(cmd);
@@ -70,16 +71,27 @@ const uploadFileBuffers = async (config) => {
70
71
  onRetry: (err, i) => {
71
72
  if (err) {
72
73
  const error = err;
73
- logger_1.logger.warn("Upload retry attempt:", i, ":", file.fileName);
74
- logger_1.logger.warn("Response status:", error.$response?.statusCode);
74
+ logger_1.logger.warn("upload:retry", i, file.fileName);
75
+ if (error.$response?.statusCode) {
76
+ logger_1.logger.warn("response status:", error.$response?.statusCode);
77
+ }
78
+ else {
79
+ logger_1.logger.warn("response status:", error);
80
+ }
75
81
  }
76
82
  },
77
83
  });
84
+ logger_1.logger.info(`upload:complete ${file.fileName}`);
78
85
  }
79
86
  catch (err) {
80
87
  const error = err;
81
88
  logger_1.logger.error(`R2 Error - ${file.fileName} \nError: ${error}`);
82
- logger_1.logger.error("Upload response", error.$response, "with status", error.$metadata.httpStatusCode);
89
+ if (error.$response?.statusCode && error.$metadata.httpStatusCode) {
90
+ logger_1.logger.error("Upload response", error.$response, "with status", error.$metadata.httpStatusCode);
91
+ }
92
+ else {
93
+ logger_1.logger.error("Upload response", error);
94
+ }
83
95
  }
84
96
  return;
85
97
  }));
@@ -0,0 +1,16 @@
1
+ import libraryConfig from "../eslint-config/library.mjs";
2
+ import tsParser from "@typescript-eslint/parser";
3
+
4
+ export default [
5
+ ...libraryConfig,
6
+ {
7
+ files: ["src/**/*.ts", "src/**/*.tsx"],
8
+ languageOptions: {
9
+ parser: tsParser,
10
+ parserOptions: {
11
+ project: "./tsconfig.lint.json",
12
+ tsconfigRootDir: import.meta.dirname,
13
+ },
14
+ },
15
+ },
16
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/r2-uploader",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"