From 336598f157cecc46b30cc7c80513dacf55a61259 Mon Sep 17 00:00:00 2001 From: mogulx_operates Date: Tue, 14 Mar 2023 09:06:28 -0500 Subject: [PATCH 1/6] refactor: add each user tag to the tags --- src/node/upload.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/node/upload.ts b/src/node/upload.ts index ecc2f78b..034ac037 100644 --- a/src/node/upload.ts +++ b/src/node/upload.ts @@ -72,12 +72,14 @@ export default class NodeUploader extends Uploader { indexFile, interactivePreflight, logFunction, + userTags, }: { batchSize: number; keepDeleted: boolean; indexFile?: string; interactivePreflight?: boolean; logFunction?: (log: string) => Promise; + userTags?: { name: string, value: string}[]; } = { batchSize: 10, keepDeleted: true }, ): Promise { path = resolve(path); @@ -215,6 +217,7 @@ export default class NodeUploader extends Uploader { { name: "Type", value: "manifest" }, { name: "Content-Type", value: "application/x.arweave-manifest+json" }, ]; + userTags?.forEach(t => tags.push(t)) const mres = await this.uploadData(createReadStream(jsonManifestPath), { tags }).catch((e) => { throw new Error(`Failed to upload manifest: ${e.message}`); }); From a206d2cfd05642e9211d3adda94dcbed5de9b683 Mon Sep 17 00:00:00 2001 From: mogulx_operates Date: Tue, 14 Mar 2023 09:10:18 -0500 Subject: [PATCH 2/6] fix: add tags to entry point also --- src/node/bundlr.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node/bundlr.ts b/src/node/bundlr.ts index e3d025c3..228a5c69 100644 --- a/src/node/bundlr.ts +++ b/src/node/bundlr.ts @@ -73,15 +73,17 @@ export default class NodeBundlr extends Bundlr { indexFile, interactivePreflight, logFunction, + userTags, }: { batchSize?: number; keepDeleted?: boolean; indexFile?: string; interactivePreflight?: boolean; logFunction?: (log: string) => Promise; + userTags?: { name: string, value: string }[] } = {}, ): Promise { - return this.uploader.uploadFolder(path, { indexFile, batchSize, interactivePreflight, keepDeleted, logFunction }); + return this.uploader.uploadFolder(path, { indexFile, batchSize, interactivePreflight, keepDeleted, logFunction, userTags }); } public static async init(opts: { url: string; From 8e2d555b6787b973af5ee970b9a28540c06bef51 Mon Sep 17 00:00:00 2001 From: mogulx_operates Date: Tue, 14 Mar 2023 10:06:33 -0500 Subject: [PATCH 3/6] fix: use manifestTags --- src/node/bundlr.ts | 6 +++--- src/node/upload.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/node/bundlr.ts b/src/node/bundlr.ts index 228a5c69..0b10ba9b 100644 --- a/src/node/bundlr.ts +++ b/src/node/bundlr.ts @@ -73,17 +73,17 @@ export default class NodeBundlr extends Bundlr { indexFile, interactivePreflight, logFunction, - userTags, + manifestTags, }: { batchSize?: number; keepDeleted?: boolean; indexFile?: string; interactivePreflight?: boolean; logFunction?: (log: string) => Promise; - userTags?: { name: string, value: string }[] + manifestTags?: { name: string, value: string }[] } = {}, ): Promise { - return this.uploader.uploadFolder(path, { indexFile, batchSize, interactivePreflight, keepDeleted, logFunction, userTags }); + return this.uploader.uploadFolder(path, { indexFile, batchSize, interactivePreflight, keepDeleted, logFunction, manifestTags }); } public static async init(opts: { url: string; diff --git a/src/node/upload.ts b/src/node/upload.ts index 034ac037..eed426de 100644 --- a/src/node/upload.ts +++ b/src/node/upload.ts @@ -72,14 +72,14 @@ export default class NodeUploader extends Uploader { indexFile, interactivePreflight, logFunction, - userTags, + manifestTags, }: { batchSize: number; keepDeleted: boolean; indexFile?: string; interactivePreflight?: boolean; logFunction?: (log: string) => Promise; - userTags?: { name: string, value: string}[]; + manifestTags?: { name: string, value: string}[]; } = { batchSize: 10, keepDeleted: true }, ): Promise { path = resolve(path); @@ -217,7 +217,7 @@ export default class NodeUploader extends Uploader { { name: "Type", value: "manifest" }, { name: "Content-Type", value: "application/x.arweave-manifest+json" }, ]; - userTags?.forEach(t => tags.push(t)) + manifestTags?.forEach(t => tags.push(t)) const mres = await this.uploadData(createReadStream(jsonManifestPath), { tags }).catch((e) => { throw new Error(`Failed to upload manifest: ${e.message}`); }); From 129b1d0563488ee6495bf610b09e6679046867da Mon Sep 17 00:00:00 2001 From: mogulx_operates Date: Tue, 14 Mar 2023 10:11:00 -0500 Subject: [PATCH 4/6] fix: spread tags --- src/node/upload.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/upload.ts b/src/node/upload.ts index eed426de..c66ff525 100644 --- a/src/node/upload.ts +++ b/src/node/upload.ts @@ -216,8 +216,8 @@ export default class NodeUploader extends Uploader { const tags = [ { name: "Type", value: "manifest" }, { name: "Content-Type", value: "application/x.arweave-manifest+json" }, + ...manifestTags || [] // Added the || [] because I was getting a type error ]; - manifestTags?.forEach(t => tags.push(t)) const mres = await this.uploadData(createReadStream(jsonManifestPath), { tags }).catch((e) => { throw new Error(`Failed to upload manifest: ${e.message}`); }); From 4f907ce736abe6b8d3ea91613a8f6982abe7abec Mon Sep 17 00:00:00 2001 From: mogulx_operates Date: Tue, 14 Mar 2023 10:47:57 -0500 Subject: [PATCH 5/6] style: use ?? --- src/node/upload.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/upload.ts b/src/node/upload.ts index c66ff525..9fd4247c 100644 --- a/src/node/upload.ts +++ b/src/node/upload.ts @@ -79,7 +79,7 @@ export default class NodeUploader extends Uploader { indexFile?: string; interactivePreflight?: boolean; logFunction?: (log: string) => Promise; - manifestTags?: { name: string, value: string}[]; + manifestTags?: { name: string; value: string }[]; } = { batchSize: 10, keepDeleted: true }, ): Promise { path = resolve(path); @@ -216,7 +216,7 @@ export default class NodeUploader extends Uploader { const tags = [ { name: "Type", value: "manifest" }, { name: "Content-Type", value: "application/x.arweave-manifest+json" }, - ...manifestTags || [] // Added the || [] because I was getting a type error + ...(manifestTags ?? []), ]; const mres = await this.uploadData(createReadStream(jsonManifestPath), { tags }).catch((e) => { throw new Error(`Failed to upload manifest: ${e.message}`); From 78105c4d0b8b59ce361bf7eda02059d532188def Mon Sep 17 00:00:00 2001 From: mogulx_operates Date: Tue, 14 Mar 2023 20:18:39 -0500 Subject: [PATCH 6/6] docs: add description of manifestTags prop to uploadFolder jsdocs --- src/node/bundlr.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node/bundlr.ts b/src/node/bundlr.ts index 0b10ba9b..a890c38e 100644 --- a/src/node/bundlr.ts +++ b/src/node/bundlr.ts @@ -63,6 +63,7 @@ export default class NodeBundlr extends Bundlr { * @param interactivePreflight - whether to interactively prompt the user for confirmation of upload (CLI ONLY) * @param keepDeleted - Whether to keep previously uploaded (but now deleted) files in the manifest * @param logFunction - for handling logging from the uploader for UX + * @param manifestTags - For allowing the caller to pass tags that will be added to the manifest transaction. * @returns */ public async uploadFolder( @@ -80,7 +81,7 @@ export default class NodeBundlr extends Bundlr { indexFile?: string; interactivePreflight?: boolean; logFunction?: (log: string) => Promise; - manifestTags?: { name: string, value: string }[] + manifestTags?: { name: string; value: string }[]; } = {}, ): Promise { return this.uploader.uploadFolder(path, { indexFile, batchSize, interactivePreflight, keepDeleted, logFunction, manifestTags });