From 59837ece13c374ef5ab26d9420110426a6b9110e Mon Sep 17 00:00:00 2001 From: Arnaud Date: Fri, 30 May 2025 15:37:59 +0200 Subject: [PATCH] chore: fix typo (#19) * Fix typo * Fix rebase --- README.md | 12 ++++++------ examples/upload-browser/index.js | 6 +++--- examples/upload-node/index.js | 6 +++--- src/data/browser-upload.ts | 6 +++--- src/data/data.spec.ts | 18 +++++++++--------- src/data/data.ts | 8 ++++---- src/data/node-upload.ts | 6 +++--- src/data/types.ts | 6 +++--- src/marketplace/marketplace.test.ts | 4 ++-- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 6cceb3b..e286fa3 100644 --- a/README.md +++ b/README.md @@ -313,7 +313,7 @@ Upload a file in a streaming manner #### Browser -- stategy [BrowserUploadStategy](./src/data/browser-upload.ts#L5) +- strategy [BrowserUploadStrategy](./src/data/browser-upload.ts#L5) - returns [UploadResponse](./src/data/types.ts#L17) Example: @@ -327,9 +327,9 @@ const onProgress = (loaded, total) => { const metadata = { filename: "foo.xt", mimetype: "text/plain" }; -const stategy = new BrowserUploadStategy(file, onProgress, metadata); +const strategy = new BrowserUploadStrategy(file, onProgress, metadata); -const uploadResponse = data.upload(stategy); +const uploadResponse = data.upload(strategy); const res = await uploadResponse.result; @@ -343,14 +343,14 @@ console.info("CID is", res.data); #### Node -- stategy [NodeUploadStategy](./src/data/node-upload.ts#L9) +- strategy [NodeUploadStrategy](./src/data/node-upload.ts#L9) - returns [UploadResponse](./src/data/types.ts#L17) Example: ```js -const stategy = new NodeUploadStategy("Hello World !"); -const uploadResponse = data.upload(stategy); +const strategy = new NodeUploadStrategy("Hello World !"); +const uploadResponse = data.upload(strategy); const res = await uploadResponse.result; diff --git a/examples/upload-browser/index.js b/examples/upload-browser/index.js index 13563e0..3649b46 100644 --- a/examples/upload-browser/index.js +++ b/examples/upload-browser/index.js @@ -1,5 +1,5 @@ import { Codex } from "@codex-storage/sdk-js"; -import { BrowserUploadStategy } from "@codex-storage/sdk-js/browser"; +import { BrowserUploadStrategy } from "@codex-storage/sdk-js/browser"; async function main() { const codex = new Codex(process.env.CODEX_NODE_URL); @@ -19,9 +19,9 @@ async function main() { mimetype: "text/plain", }; - const stategy = new BrowserUploadStategy(file, onProgress, metadata); + const strategy = new BrowserUploadStrategy(file, onProgress, metadata); - const uploadResponse = data.upload(stategy); + const uploadResponse = data.upload(strategy); const res = await uploadResponse.result; diff --git a/examples/upload-node/index.js b/examples/upload-node/index.js index a674da5..624af5d 100644 --- a/examples/upload-node/index.js +++ b/examples/upload-node/index.js @@ -1,5 +1,5 @@ const { Codex } = require("@codex-storage/sdk-js"); -const { NodeUploadStategy } = require("@codex-storage/sdk-js/node"); +const { NodeUploadStrategy } = require("@codex-storage/sdk-js/node"); async function main() { const codex = new Codex( @@ -7,8 +7,8 @@ async function main() { ); const data = codex.data; - const stategy = new NodeUploadStategy("Hello World !"); - const uploadResponse = data.upload(stategy); + const strategy = new NodeUploadStrategy("Hello World !"); + const uploadResponse = data.upload(strategy); const res = await uploadResponse.result; diff --git a/src/data/browser-upload.ts b/src/data/browser-upload.ts index 9470441..607b856 100644 --- a/src/data/browser-upload.ts +++ b/src/data/browser-upload.ts @@ -1,8 +1,8 @@ import { CodexError } from "../errors/errors"; import type { SafeValue } from "../values/values"; -import type { UploadStategy, UploadStategyOptions } from "./types"; +import type { UploadStrategy, UploadStrategyOptions } from "./types"; -export class BrowserUploadStategy implements UploadStategy { +export class BrowserUploadStrategy implements UploadStrategy { private readonly file: Document | XMLHttpRequestBodyInit; private readonly onProgress: | ((loaded: number, total: number) => void) @@ -24,7 +24,7 @@ export class BrowserUploadStategy implements UploadStategy { upload( url: string, - { auth }: UploadStategyOptions + { auth }: UploadStrategyOptions ): Promise> { const xhr = new XMLHttpRequest(); this.xhr = xhr; diff --git a/src/data/data.spec.ts b/src/data/data.spec.ts index 5e29fd2..3261b95 100644 --- a/src/data/data.spec.ts +++ b/src/data/data.spec.ts @@ -1,6 +1,6 @@ import { assert, describe, it } from "vitest"; import { CodexData } from "./data"; -import { NodeUploadStategy } from "./node-upload"; +import { NodeUploadStrategy } from "./node-upload"; import crypto from "crypto"; describe("data", () => { @@ -14,7 +14,7 @@ describe("data", () => { it("uploads a file a download it locally", async () => { const content = crypto.randomBytes(16).toString("hex"); - const strategy = new NodeUploadStategy(content); + const strategy = new NodeUploadStrategy(content); const res = data.upload(strategy); const cid = await res.result; assert.ok(cid.error == false); @@ -41,7 +41,7 @@ describe("data", () => { it("saves the metadata uploads provided during the upload", async () => { const content = crypto.randomBytes(16).toString("hex"); - const strategy = new NodeUploadStategy(content, { + const strategy = new NodeUploadStrategy(content, { filename: "hello.txt", mimetype: "text/plain", }); @@ -63,7 +63,7 @@ describe("data", () => { it("fails when providing wrong metadata", async () => { const content = crypto.randomBytes(16).toString("hex"); - const strategy = new NodeUploadStategy(content, { + const strategy = new NodeUploadStrategy(content, { filename: "hello.txt", mimetype: "plain/text", }); @@ -79,7 +79,7 @@ describe("data", () => { it("delete a file a locally", async () => { const content = "b".repeat(131072); - const strategy = new NodeUploadStategy(content); + const strategy = new NodeUploadStrategy(content); const res = data.upload(strategy); const cid = await res.result; assert.ok(cid.error == false); @@ -99,7 +99,7 @@ describe("data", () => { it("doesn't do anything when trying to delete a non existing cid", async () => { const content = crypto.randomBytes(16).toString("hex"); - const strategy = new NodeUploadStategy(content); + const strategy = new NodeUploadStrategy(content); const res = spData.upload(strategy); const cid = await res.result; assert.ok(cid.error == false); @@ -124,7 +124,7 @@ describe("data", () => { const usedBytes = space.data.quotaUsedBytes; - const strategy = new NodeUploadStategy(content); + const strategy = new NodeUploadStrategy(content); const res = data.upload(strategy); const cid = await res.result; assert.ok(cid.error == false); @@ -139,7 +139,7 @@ describe("data", () => { it("stream downloads a file on the network", async () => { const content = crypto.randomBytes(16).toString("hex"); - const strategy = new NodeUploadStategy(content); + const strategy = new NodeUploadStrategy(content); const res = spData.upload(strategy); const cid = await res.result; assert.ok(cid.error == false); @@ -153,7 +153,7 @@ describe("data", () => { it("downloads a file on the network", async () => { const content = crypto.randomBytes(16).toString("hex"); - const strategy = new NodeUploadStategy(content); + const strategy = new NodeUploadStrategy(content); const res = spData.upload(strategy); const cid = await res.result; assert.ok(cid.error == false); diff --git a/src/data/data.ts b/src/data/data.ts index 755cb45..c214531 100644 --- a/src/data/data.ts +++ b/src/data/data.ts @@ -7,7 +7,7 @@ import { import type { SafeValue } from "../values/values"; import type { CodexDataResponse, - UploadStategy, + UploadStrategy, UploadResponse, CodexSpaceResponse, CodexNodeSpace, @@ -70,13 +70,13 @@ export class CodexData { * XMLHttpRequest is used instead of fetch for this case, to obtain progress information. * A callback onProgress can be passed to receive upload progress data information. */ - upload(stategy: UploadStategy): UploadResponse { + upload(strategy: UploadStrategy): UploadResponse { const url = this.url + Api.config.prefix + "/data"; return { - result: stategy.upload(url, { auth: this.auth }), + result: strategy.upload(url, { auth: this.auth }), abort: () => { - stategy.abort(); + strategy.abort(); }, }; } diff --git a/src/data/node-upload.ts b/src/data/node-upload.ts index 7c262e3..01c8ad4 100644 --- a/src/data/node-upload.ts +++ b/src/data/node-upload.ts @@ -3,10 +3,10 @@ import { CodexError } from "../errors/errors"; import type { SafeValue } from "../values/values"; import Undici from "undici"; import { type FormData } from "undici"; -import type { UploadStategy, UploadStategyOptions } from "./types"; +import type { UploadStrategy, UploadStrategyOptions } from "./types"; import { FetchAuthBuilder } from "../fetch-safe/fetch-safe"; -export class NodeUploadStategy implements UploadStategy { +export class NodeUploadStrategy implements UploadStrategy { private readonly body: | string | Buffer @@ -29,7 +29,7 @@ export class NodeUploadStategy implements UploadStategy { async upload( url: string, - { auth }: UploadStategyOptions + { auth }: UploadStrategyOptions ): Promise> { const headers: Record = FetchAuthBuilder.build(auth); diff --git a/src/data/types.ts b/src/data/types.ts index 27548f6..4c718b9 100644 --- a/src/data/types.ts +++ b/src/data/types.ts @@ -29,14 +29,14 @@ export type CodexFetchManifestResponse = export type CodexManifest = CodexFetchManifestResponse; -export type UploadStategyOptions = { +export type UploadStrategyOptions = { auth?: FetchAuth; }; -export interface UploadStategy { +export interface UploadStrategy { upload( url: string, - options?: UploadStategyOptions + options?: UploadStrategyOptions ): Promise>; abort(): void; } diff --git a/src/marketplace/marketplace.test.ts b/src/marketplace/marketplace.test.ts index 47f3ee0..dcb4433 100644 --- a/src/marketplace/marketplace.test.ts +++ b/src/marketplace/marketplace.test.ts @@ -1,7 +1,7 @@ import { assert, describe, it } from "vitest"; import { CodexMarketplace } from "./marketplace"; import { CodexData } from "../data/data"; -import { NodeUploadStategy } from "../data/node-upload"; +import { NodeUploadStrategy } from "../data/node-upload"; import type { CodexAvailabilityPatchInput, CodexCreateAvailabilityInput, @@ -154,7 +154,7 @@ describe("marketplace", async () => { async function uploadContent(sizeInBytes: number) { const content = "a".repeat(sizeInBytes); - const strategy = new NodeUploadStategy(content); + const strategy = new NodeUploadStrategy(content); const res = data.upload(strategy); const cid = await res.result; assert.ok(cid.error == false);