Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tall-laws-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lens-chain/storage-client": patch
---

**feat**: support for new `available` status
22 changes: 16 additions & 6 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": []
"includes": ["**"]
},
"formatter": {
"enabled": true,
"useEditorconfig": true
},
"organizeImports": {
"enabled": true
},
"assist": { "actions": { "source": { "organizeImports": "on" } } },
"linter": {
"enabled": true,
"rules": {
"recommended": true
"recommended": true,
"style": {
"noParameterAssign": "error",
"useAsConstAssertion": "error",
"useDefaultParameterLast": "error",
"useEnumInitializers": "error",
"useSelfClosingElements": "error",
"useSingleVarDeclarator": "error",
"noUnusedTemplateLiteral": "error",
"useNumberNamespace": "error",
"noInferrableTypes": "error",
"noUselessElse": "error"
}
}
},
"javascript": {
Expand Down
22 changes: 17 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@
"module": "dist/index.js",
"types": "dist/index.d.ts",
"sideEffects": false,
"files": ["dist"],
"keywords": ["lens", "grove", "chain", "storage", "node"],
"files": [
"dist"
],
"keywords": [
"lens",
"grove",
"chain",
"storage",
"node"
],
"exports": {
".": {
"import": "./dist/index.js",
Expand All @@ -17,8 +25,12 @@
},
"typesVersions": {
"*": {
"import": ["./dist/index.d.ts"],
"require": ["./dist/index.d.ts"]
"import": [
"./dist/index.d.ts"
],
"require": [
"./dist/index.d.ts"
]
}
},
"scripts": {
Expand All @@ -30,7 +42,7 @@
"test:browser": "vitest --project browser"
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@biomejs/biome": "^2.0.6",
"@changesets/cli": "^2.27.9",
"@types/node": "^22.9.0",
"@vitest/browser": "^3.2.3",
Expand Down
76 changes: 38 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 35 additions & 16 deletions src/StorageClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { privateKeyToAccount } from 'viem/accounts';
import { describe, expect, it } from 'vitest';

import { StorageClient } from './StorageClient';
import { immutable, lensAccountOnly, walletOnly } from './builders';
import { staging } from './environments';
import { StorageClient } from './StorageClient';
import { FileUploadResponse, type Resource } from './types';
import { never } from './utils';

Expand Down Expand Up @@ -73,7 +72,9 @@ describe(`Given an instance of the '${StorageClient.name}'`, () => {
const files = [file1, file2];

it('Then it should create the expected resources', async () => {
const result = await client.uploadFolder(files, { acl: immutable(37111) });
const result = await client.uploadFolder(files, {
acl: immutable(37111),
});

await assertFileExist(client.resolve(result.files[0]?.uri ?? never()));
});
Expand All @@ -88,14 +89,21 @@ describe(`Given an instance of the '${StorageClient.name}'`, () => {
const res = await fetch(url);
const json = await res.json();
expect(json).toMatchObject({
files: expect.arrayContaining([expect.any(String), expect.any(String), expect.any(String)]),
files: expect.arrayContaining([
expect.any(String),
expect.any(String),
expect.any(String),
]),
});
});

it('Then it should support using an arbitrary index file', async () => {
const index = new File(['[]'], 'index.json', { type: 'text/plain' });

const response = await client.uploadFolder(files, { index, acl: immutable(37111) });
const response = await client.uploadFolder(files, {
index,
acl: immutable(37111),
});

const url = client.resolve(response.folder.uri);
const res = await fetch(url);
Expand All @@ -104,7 +112,8 @@ describe(`Given an instance of the '${StorageClient.name}'`, () => {
});

it('Then it should support an index file factory', async () => {
const indexFactory = (resources: Resource[]) => resources.map((r) => r.uri);
const indexFactory = (resources: Resource[]) =>
resources.map((r) => r.uri);
const response = await client.uploadFolder(files, {
index: indexFactory,
acl: immutable(37111),
Expand All @@ -113,15 +122,20 @@ describe(`Given an instance of the '${StorageClient.name}'`, () => {
const url = client.resolve(response.folder.uri);
const res = await fetch(url);
const json = await res.json();
expect(json).toMatchObject(expect.arrayContaining([expect.stringContaining('lens://')]));
expect(json).toMatchObject(
expect.arrayContaining([expect.stringContaining('lens://')]),
);
});

it('Then it should allow to specify you own index file', async () => {
const content = [{ name: 'test.txt' }, { name: 'test2.txt' }];
const index = new File([JSON.stringify(content)], 'index.json', {
type: 'application/json',
});
const response = await client.uploadFolder(files, { index, acl: immutable(37111) });
const response = await client.uploadFolder(files, {
index,
acl: immutable(37111),
});

const url = client.resolve(response.folder.uri);
const res = await fetch(url);
Expand All @@ -139,9 +153,9 @@ describe(`Given an instance of the '${StorageClient.name}'`, () => {
const response = await client.uploadFile(file1, { acl });

await response.waitForPropagation();
await expect(client.editFile(response.uri, file2, signer, { acl })).resolves.toBeInstanceOf(
FileUploadResponse,
);
await expect(
client.editFile(response.uri, file2, signer, { acl }),
).resolves.toBeInstanceOf(FileUploadResponse);
},
);
});
Expand All @@ -155,7 +169,9 @@ describe(`Given an instance of the '${StorageClient.name}'`, () => {
const response = await client.uploadFile(file1, { acl });
await response.waitForPropagation();

await expect(client.delete(response.uri, signer)).resolves.toHaveProperty('success', true);
await expect(
client.delete(response.uri, signer),
).resolves.toHaveProperty('success', true);
},
);
});
Expand All @@ -169,9 +185,9 @@ describe(`Given an instance of the '${StorageClient.name}'`, () => {
const response = await client.uploadFile(file1, { acl });

await response.waitForPropagation();
await expect(client.editFile(response.uri, file2, signer, { acl })).resolves.toBeInstanceOf(
FileUploadResponse,
);
await expect(
client.editFile(response.uri, file2, signer, { acl }),
).resolves.toBeInstanceOf(FileUploadResponse);
},
);
});
Expand All @@ -182,7 +198,10 @@ describe(`Given an instance of the '${StorageClient.name}'`, () => {
const response = await client.uploadFile(file1, { acl });

await response.waitForPropagation();
await expect(client.delete(response.uri, signer)).resolves.toHaveProperty('success', true);
await expect(client.delete(response.uri, signer)).resolves.toHaveProperty(
'success',
true,
);
});
});
});
Loading