diff --git a/packages/interfaces/file-system/README.md b/packages/interfaces/file-system/README.md deleted file mode 100644 index f9c5057da0..0000000000 --- a/packages/interfaces/file-system/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# @polywrap/file-system-interface - -Interface for File System wrappers. diff --git a/packages/interfaces/file-system/deployment.json b/packages/interfaces/file-system/deployment.json deleted file mode 100644 index 1fbeb743d5..0000000000 --- a/packages/interfaces/file-system/deployment.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - { - "name": "ipfs_deploy", - "steps": [ - { - "name": "ipfs_deploy", - "id": "ipfs_deploy.ipfs_deploy", - "input": "wrap://fs/./build", - "result": "wrap://ipfs/QmZ6YX5S2YAscHWBqiEveGkZ4VxUuTDehMrf3ZzkQoLFwj" - } - ] - } -] \ No newline at end of file diff --git a/packages/interfaces/file-system/package.json b/packages/interfaces/file-system/package.json deleted file mode 100644 index b7fc2c6d83..0000000000 --- a/packages/interfaces/file-system/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "@polywrap/file-system-interface", - "description": "Polywrap Filesystem Interface", - "version": "0.10.0-pre.7", - "scripts": { - "build": "node ../../../dependencies/node_modules/polywrap/bin/polywrap build", - "lint": "eslint --color -c ../../../.eslintrc.js .", - "test:env:up": "npx polywrap infra up --modules=eth-ens-ipfs", - "test:env:down": "npx polywrap infra down --modules=eth-ens-ipfs", - "deploy": "npx polywrap deploy" - }, - "devDependencies": { - "polywrap": "0.10.0-pre.7" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/interfaces/file-system/polywrap.deploy.yaml b/packages/interfaces/file-system/polywrap.deploy.yaml deleted file mode 100644 index e36638b454..0000000000 --- a/packages/interfaces/file-system/polywrap.deploy.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.2.0 -jobs: - ipfs_deploy: - steps: - - name: ipfs_deploy - package: ipfs - uri: fs/./build - config: - gatewayUri: https://ipfs.wrappers.io diff --git a/packages/interfaces/file-system/polywrap.yaml b/packages/interfaces/file-system/polywrap.yaml deleted file mode 100644 index 2e15c1143b..0000000000 --- a/packages/interfaces/file-system/polywrap.yaml +++ /dev/null @@ -1,8 +0,0 @@ -format: 0.2.0 -project: - name: file-system-interface - type: interface -source: - schema: ./src/schema.graphql -extensions: - deploy: ./polywrap.deploy.yaml diff --git a/packages/js/client-config-builder/README.md b/packages/js/client-config-builder/README.md index 31aee395ba..716c4f2756 100644 --- a/packages/js/client-config-builder/README.md +++ b/packages/js/client-config-builder/README.md @@ -533,7 +533,7 @@ export const defaultPackages = { http: "wrap://plugin/http", httpResolver: "wrap://ens/http-resolver.polywrap.eth", logger: "wrap://plugin/logger", - fileSystem: "wrap://ens/fs.polywrap.eth", + fileSystem: "wrap://plugin/fs", fileSystemResolver: "wrap://ens/fs-resolver.polywrap.eth", ipfsResolver: "wrap://ens/ipfs-resolver.polywrap.eth", concurrent: "wrap://plugin/concurrent", @@ -544,6 +544,7 @@ export const defaultInterfaces = { concurrent: "wrap://ens/goerli/interface.concurrent.wrappers.eth", logger: "wrap://ens/wrappers.polywrap.eth:logger@1.0.0", http: "wrap://ens/wrappers.polywrap.eth:http@1.1.0", + fileSystem: "wrap://ens/wrappers.polywrap.eth:file-system@1.0.0", }; export const getDefaultConfig = (): ClientConfig => { @@ -588,6 +589,14 @@ export const getDefaultConfig = (): ClientConfig => { from: new Uri(defaultInterfaces.http), to: new Uri(defaultPackages.http), }, + { + from: new Uri("wrap://ens/fs.polywrap.eth"), + to: new Uri(defaultInterfaces.fileSystem), + }, + { + from: new Uri(defaultInterfaces.fileSystem), + to: new Uri(defaultPackages.fileSystem), + }, ], interfaces: [ { diff --git a/packages/js/client-config-builder/src/bundles/getDefaultConfig.ts b/packages/js/client-config-builder/src/bundles/getDefaultConfig.ts index 0d03d78d95..71772e201c 100644 --- a/packages/js/client-config-builder/src/bundles/getDefaultConfig.ts +++ b/packages/js/client-config-builder/src/bundles/getDefaultConfig.ts @@ -38,7 +38,7 @@ export const defaultPackages = { http: "wrap://plugin/http", httpResolver: "wrap://ens/http-resolver.polywrap.eth", logger: "wrap://plugin/logger", - fileSystem: "wrap://ens/fs.polywrap.eth", + fileSystem: "wrap://plugin/fs", fileSystemResolver: "wrap://ens/fs-resolver.polywrap.eth", ipfsResolver: "wrap://ens/ipfs-resolver.polywrap.eth", concurrent: "wrap://plugin/concurrent", @@ -49,6 +49,7 @@ export const defaultInterfaces = { concurrent: "wrap://ens/goerli/interface.concurrent.wrappers.eth", logger: "wrap://ens/wrappers.polywrap.eth:logger@1.0.0", http: "wrap://ens/wrappers.polywrap.eth:http@1.1.0", + fileSystem: "wrap://ens/wrappers.polywrap.eth:file-system@1.0.0", }; export const getDefaultConfig = (): ClientConfig => { @@ -93,6 +94,14 @@ export const getDefaultConfig = (): ClientConfig => { from: new Uri(defaultInterfaces.http), to: new Uri(defaultPackages.http), }, + { + from: new Uri("wrap://ens/fs.polywrap.eth"), + to: new Uri(defaultInterfaces.fileSystem), + }, + { + from: new Uri(defaultInterfaces.fileSystem), + to: new Uri(defaultPackages.fileSystem), + }, ], interfaces: [ { diff --git a/packages/js/client/src/__tests__/core/error-structure.spec.ts b/packages/js/client/src/__tests__/core/error-structure.spec.ts index 1dbf76bc3f..54ce4dc21c 100644 --- a/packages/js/client/src/__tests__/core/error-structure.spec.ts +++ b/packages/js/client/src/__tests__/core/error-structure.spec.ts @@ -3,6 +3,7 @@ import { Uri, PolywrapClient } from "../.."; import { buildWrapper } from "@polywrap/test-env-js"; import { WrapError, WrapErrorCode } from "@polywrap/core-js"; import { mockPluginRegistration } from "../helpers/mockPluginRegistration"; +import { defaultPackages } from "@polywrap/client-config-builder-js"; jest.setTimeout(660000); @@ -235,7 +236,7 @@ describe("Error structure", () => { describe("Plugin wrapper", () => { test("Invoke a plugin wrapper with malformed args", async () => { const result = await client.invoke({ - uri: "wrap://ens/fs.polywrap.eth", + uri: defaultPackages.fileSystem, method: "readFile", args: { pathh: "packages/js/client/src/__tests__/core/index.ts", @@ -248,7 +249,7 @@ describe("Error structure", () => { expect(result.error?.name).toEqual("WrapError"); expect(result.error?.code).toEqual(WrapErrorCode.WRAPPER_INVOKE_ABORTED); expect(result.error?.reason).toEqual("The \"path\" argument must be of type string or an instance of Buffer or URL. Received undefined"); - expect(result.error?.uri).toEqual("wrap://ens/fs.polywrap.eth"); + expect(result.error?.uri).toEqual(defaultPackages.fileSystem); expect(result.error?.method).toEqual("readFile"); expect(result.error?.args).toContain("{\n \"pathh\": \"packages/js/client/src/__tests__/core/index.ts\"\n}"); expect(result.error?.source).toEqual({ file: "node:internal/fs/promises", row: 450, col: 10 }); @@ -256,7 +257,7 @@ describe("Error structure", () => { test("Invoke a plugin wrapper with a method that doesn't exist", async () => { const result = await client.invoke({ - uri: "wrap://ens/fs.polywrap.eth", + uri: defaultPackages.fileSystem, method: "readFileNotFound", args: { path: __dirname + "/index.ts", @@ -269,7 +270,7 @@ describe("Error structure", () => { expect(result.error?.name).toEqual("WrapError"); expect(result.error?.code).toEqual(WrapErrorCode.WRAPPER_METHOD_NOT_FOUND); expect(result.error?.reason.startsWith("Plugin missing method ")).toBeTruthy(); - expect(result.error?.uri).toEqual("wrap://ens/fs.polywrap.eth"); + expect(result.error?.uri).toEqual(defaultPackages.fileSystem); expect(result.error?.method).toEqual("readFileNotFound"); }); @@ -293,7 +294,7 @@ describe("Error structure", () => { test("Invoke a plugin wrapper that throws unexpectedly", async () => { const result = await client.invoke({ - uri: "wrap://ens/fs.polywrap.eth", + uri: defaultPackages.fileSystem, method: "readFile", args: { path: "./this/path/does/not/exist.ts", @@ -306,7 +307,7 @@ describe("Error structure", () => { expect(result.error?.name).toEqual("WrapError"); expect(result.error?.code).toEqual(WrapErrorCode.WRAPPER_INVOKE_ABORTED); expect(result.error?.reason.startsWith("ENOENT: no such file or directory")).toBeTruthy(); - expect(result.error?.uri).toEqual("wrap://ens/fs.polywrap.eth"); + expect(result.error?.uri).toEqual(defaultPackages.fileSystem); expect(result.error?.method).toEqual("readFile"); expect(result.error?.args).toEqual("{\n \"path\": \"./this/path/does/not/exist.ts\"\n}"); }); diff --git a/packages/js/client/src/__tests__/helpers/getClientWithEnsAndIpfs.ts b/packages/js/client/src/__tests__/helpers/getClientWithEnsAndIpfs.ts index 4402b088fa..df23b7ed30 100644 --- a/packages/js/client/src/__tests__/helpers/getClientWithEnsAndIpfs.ts +++ b/packages/js/client/src/__tests__/helpers/getClientWithEnsAndIpfs.ts @@ -16,6 +16,7 @@ import { WrapperCache, } from "@polywrap/uri-resolvers-js"; import { ExtendableUriResolver } from "@polywrap/uri-resolver-extensions-js"; +import { defaultInterfaces } from "@polywrap/client-config-builder-js"; export const getClientWithEnsAndIpfs = () => { const connections: Connections = new Connections({ @@ -70,7 +71,7 @@ export const getClientWithEnsAndIpfs = () => { package: ipfsResolverPlugin({}), }, { - uri: "wrap://ens/fs.polywrap.eth", + uri: defaultInterfaces.fileSystem, package: fileSystemPlugin({}), }, { diff --git a/packages/js/plugins/ethereum/src/__tests__/helpers/getDefaultConfig.ts b/packages/js/plugins/ethereum/src/__tests__/helpers/getDefaultConfig.ts index ec0cbb1531..a9dabd91bd 100644 --- a/packages/js/plugins/ethereum/src/__tests__/helpers/getDefaultConfig.ts +++ b/packages/js/plugins/ethereum/src/__tests__/helpers/getDefaultConfig.ts @@ -5,7 +5,7 @@ import { ethereumPlugin, Connections } from "../.."; import { providers } from "@polywrap/test-env-js"; import { defaultIpfsProviders, - ClientConfig, + ClientConfig, defaultInterfaces, } from "@polywrap/client-config-builder-js"; export const getDefaultConfig = ( @@ -37,7 +37,7 @@ export const getDefaultConfig = ( package: fileSystemResolverPlugin({}), }, { - uri: "wrap://ens/fs.polywrap.eth", + uri: defaultInterfaces.fileSystem, package: fileSystemPlugin({}), }, ], diff --git a/packages/js/plugins/file-system/README.md b/packages/js/plugins/file-system/README.md deleted file mode 100644 index 7e976d76e9..0000000000 --- a/packages/js/plugins/file-system/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# @polywrap/fs-plugin-js - -Filesystem Plugin allows the Polywrap JS Client to interact with the local filesystem. - -## Usage - -``` typescript -import { PolywrapClient } from "@polywrap/client-js"; -import { filesystemPlugin } from "@polywrap/fs-plugin-js"; - -// query a local wrapper -export async function foo({ - - const filesystemPluginUri = "wrap://ens/fs.polywrap.eth"; - - // initialize the client with eth, ipfs, ens plugins - client = new PolywrapClient({ - plugins: [ - { - uri: filesystemPluginUri, - plugin: fileSystemPlugin({}), - }, - ], - }); - - const sampleFilePath = path.resolve(__dirname, "samples/sample.txt"); - - // and read from filesystem - const response = await client.invoke({ - filesystemPluginUri, - method: "readFile", - input: { - path: sampleFilePath, - }, - }); - - // or instantiate the plugin - const plugin = filesystemPlugin({}); - - // and read from filesystem - const response' = await plugin.readFile( - { path: sampleFilePath, }, - client - ); -}); -``` - -For more usage examples see `src/__tests__`. - -## API - - - readFile - - readFileAsString - - writeFile - - exists - - mkdir - - rm - - rmdir diff --git a/packages/js/plugins/file-system/jest.config.js b/packages/js/plugins/file-system/jest.config.js deleted file mode 100644 index cb254a6963..0000000000 --- a/packages/js/plugins/file-system/jest.config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - roots: ["/src"], - testMatch: ["**/?(*.)+(spec|test).+(ts|tsx|js)"], - transform: { - "^.+\\.(ts|tsx)$": "ts-jest", - }, - testEnvironment: "node", -}; diff --git a/packages/js/plugins/file-system/package.json b/packages/js/plugins/file-system/package.json deleted file mode 100644 index 455b6019e0..0000000000 --- a/packages/js/plugins/file-system/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "@polywrap/fs-plugin-js", - "description": "Polywrap File System Javascript Plugin", - "version": "0.10.0-pre.7", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/polywrap/monorepo.git" - }, - "main": "build/index.js", - "files": [ - "build" - ], - "scripts": { - "build": "rimraf ./build && yarn codegen && tsc --project tsconfig.build.json", - "codegen": "node ../../../../dependencies/node_modules/polywrap/bin/polywrap codegen", - "lint": "eslint --color -c ../../../../.eslintrc.js src/", - "test": "jest --passWithNoTests --runInBand --verbose", - "test:ci": "jest --passWithNoTests --runInBand --verbose", - "test:watch": "jest --watch --passWithNoTests --verbose" - }, - "dependencies": { - "@polywrap/core-js": "0.10.0-pre.7", - "@polywrap/plugin-js": "0.10.0-pre.7" - }, - "devDependencies": { - "@polywrap/client-js": "0.10.0-pre.7", - "@polywrap/uri-resolvers-js": "0.10.0-pre.7", - "@types/jest": "26.0.8", - "@types/prettier": "2.6.0", - "jest": "26.6.3", - "rimraf": "3.0.2", - "ts-jest": "26.5.4", - "ts-node": "8.10.2", - "typescript": "4.1.6" - }, - "gitHead": "7346adaf5adb7e6bbb70d9247583e995650d390a", - "publishConfig": { - "access": "public" - } -} diff --git a/packages/js/plugins/file-system/polywrap.yaml b/packages/js/plugins/file-system/polywrap.yaml deleted file mode 100644 index a076ae9435..0000000000 --- a/packages/js/plugins/file-system/polywrap.yaml +++ /dev/null @@ -1,10 +0,0 @@ -format: 0.2.0 -project: - type: plugin/typescript - name: FileSystem -source: - module: ./src/index.ts - schema: ./src/schema.graphql - import_abis: - - uri: "ens/fs.polywrap.eth" - abi: ../../../interfaces/file-system/build/wrap.info diff --git a/packages/js/plugins/file-system/src/__tests__/e2e.spec.ts b/packages/js/plugins/file-system/src/__tests__/e2e.spec.ts deleted file mode 100644 index f0df413665..0000000000 --- a/packages/js/plugins/file-system/src/__tests__/e2e.spec.ts +++ /dev/null @@ -1,231 +0,0 @@ -import { fileSystemPlugin } from "../index"; -import { PolywrapClient } from "@polywrap/client-js"; -import { UriResolver } from "@polywrap/uri-resolvers-js"; -import { FileSystem_Module, FileSystem_EncodingEnum } from "../wrap"; -import fs from "fs"; -import path from "path"; -import fileSystemEncodingToBufferEncoding from "../utils/fileSystemEncodingToBufferEncoding"; -import { WrapError } from "@polywrap/core-js"; - -jest.setTimeout(360000); - -describe("FileSystem plugin", () => { - const sampleFilePath = path.resolve(__dirname, "samples/sample.txt"); - const tempFilePath = path.resolve(__dirname, "samples/tempfile.dat"); - const tempDirPath = path.resolve(__dirname, "samples/tempdir"); - - let client: PolywrapClient; - const cleanUpTempFiles = async () => { - if (fs.existsSync(tempFilePath)) { - await fs.promises.rm(tempFilePath, { force: true }); - } - - if (fs.existsSync(tempDirPath)) { - await fs.promises.rm(tempDirPath, { force: true, recursive: true }); - } - }; - beforeAll(async () => { - await cleanUpTempFiles(); - - client = new PolywrapClient( - { - resolver: UriResolver.from({ - uri: "wrap://ens/fs.polywrap.eth", - package: fileSystemPlugin({}), - }), - }, - { noDefaults: true } - ); - }); - - afterEach(async () => { - await cleanUpTempFiles(); - }); - - it("can read a file", async () => { - const expectedContents = await fs.promises.readFile(sampleFilePath); - - const result = await FileSystem_Module.readFile( - { path: sampleFilePath }, - client - ); - - if (!result.ok) fail(result.error); - expect(result.value).toEqual(new Uint8Array(expectedContents)); - }); - - it("should fail reading a nonexistent file", async () => { - const nonExistentFilePath = path.resolve(__dirname, "nonexistent.txt"); - - let result = await FileSystem_Module.readFile( - { path: nonExistentFilePath }, - client - ); - - result = result as { ok: false; error: WrapError | undefined }; - expect(result.error).toBeTruthy(); - expect(result.ok).toBeFalsy(); - }); - - it("should read a UTF8-encoded file as a string", async () => { - let encoding = FileSystem_EncodingEnum.UTF8; - - const expectedContents = await fs.promises.readFile(sampleFilePath, { - encoding: fileSystemEncodingToBufferEncoding(encoding), - }); - - const result = await FileSystem_Module.readFileAsString( - { path: sampleFilePath, encoding: FileSystem_EncodingEnum.UTF8 }, - client - ); - - if (!result.ok) fail(result.error); - expect(result.value).toBe(expectedContents); - }); - - it("should read a file using supported encodings as a string", async () => { - let supportedEncodings = [ - FileSystem_EncodingEnum.ASCII, - FileSystem_EncodingEnum.UTF8, - FileSystem_EncodingEnum.UTF16LE, - FileSystem_EncodingEnum.UCS2, - FileSystem_EncodingEnum.BASE64, - FileSystem_EncodingEnum.BASE64URL, - FileSystem_EncodingEnum.LATIN1, - FileSystem_EncodingEnum.BINARY, - FileSystem_EncodingEnum.HEX, - ]; - - for (const encoding of supportedEncodings) { - const result = await FileSystem_Module.readFileAsString( - { path: sampleFilePath, encoding: encoding }, - client - ); - - if (!result.ok) fail(result.error); - - const expectedContents = await fs.promises.readFile(sampleFilePath, { - encoding: fileSystemEncodingToBufferEncoding(encoding), - }); - - expect(result.value).toBe(expectedContents); - } - }); - - it("should return whether a file exists or not", async () => { - const result_fileExists = await FileSystem_Module.exists( - { path: sampleFilePath }, - client - ); - - if (!result_fileExists.ok) fail(result_fileExists.error); - expect(result_fileExists.value).toBe(true); - - const nonExistentFilePath = path.resolve( - __dirname, - "samples/this-file-should-not-exist.txt" - ); - - const result_fileMissing = await FileSystem_Module.exists( - { path: nonExistentFilePath }, - client - ); - - if (!result_fileMissing.ok) fail(result_fileMissing.error); - expect(result_fileMissing.value).toBe(false); - }); - - it("should write byte data to a file", async () => { - const bytes = new Uint8Array([0, 1, 2, 3]); - - const result = await FileSystem_Module.writeFile( - { data: bytes, path: tempFilePath }, - client - ); - - const expectedFileContents = new Uint8Array( - await fs.promises.readFile(tempFilePath) - ); - - if (!result.ok) fail(result.error); - expect(result.value).toBe(true); - expect(expectedFileContents).toEqual(bytes); - }); - - it("should remove a file", async () => { - await fs.promises.writeFile(tempFilePath, "test file contents", { - encoding: "utf-8", - }); - - const result = await FileSystem_Module.rm({ path: tempFilePath }, client); - - if (!result.ok) fail(result.error); - expect(result.value).toBe(true); - - const fileExists = fs.existsSync(tempFilePath); - - expect(fileExists).toBe(false); - }); - - it("should remove a directory with files recursively", async () => { - const fileInDirPath = path.resolve(tempDirPath, "inner.txt"); - - await fs.promises.mkdir(tempDirPath); - - await fs.promises.writeFile(fileInDirPath, "test file contents", { - encoding: "utf-8", - }); - - const result = await FileSystem_Module.rm( - { path: tempDirPath, recursive: true }, - client - ); - - if (!result.ok) fail(result.error); - expect(result.value).toBe(true); - - const fileExists = fs.existsSync(fileInDirPath); - - expect(fileExists).toBe(false); - }); - - it("should create a directory", async () => { - const result = await FileSystem_Module.mkdir({ path: tempDirPath }, client); - - if (!result.ok) fail(result.error); - expect(result.value).toBe(true); - - let directoryExists = fs.existsSync(tempDirPath); - - expect(directoryExists).toBe(true); - }); - - it("should create a directory recursively", async () => { - const dirInDirPath = path.resolve(tempDirPath, "inner"); - - const result = await FileSystem_Module.mkdir( - { path: dirInDirPath, recursive: true }, - client - ); - - if (!result.ok) fail(result.error); - expect(result.value).toBe(true); - - let directoryExists = fs.existsSync(dirInDirPath); - - expect(directoryExists).toBe(true); - }); - - it("should remove a directory", async () => { - await fs.promises.mkdir(tempDirPath); - - const result = await FileSystem_Module.rmdir({ path: tempDirPath }, client); - - if (!result.ok) fail(result.error); - expect(result.value).toBe(true); - - const directoryExists = fs.existsSync(tempDirPath); - - expect(directoryExists).toBe(false); - }); -}); diff --git a/packages/js/plugins/file-system/src/__tests__/samples/sample.txt b/packages/js/plugins/file-system/src/__tests__/samples/sample.txt deleted file mode 100644 index 736581543d..0000000000 --- a/packages/js/plugins/file-system/src/__tests__/samples/sample.txt +++ /dev/null @@ -1 +0,0 @@ -this is a sample file \ No newline at end of file diff --git a/packages/js/plugins/file-system/src/index.ts b/packages/js/plugins/file-system/src/index.ts deleted file mode 100644 index 0f02710860..0000000000 --- a/packages/js/plugins/file-system/src/index.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { - CoreClient, - Module, - manifest, - Args_readFile, - Args_readFileAsString, - Args_exists, - Args_writeFile, - Args_mkdir, - Args_rm, - Args_rmdir, -} from "./wrap"; -import fileSystemEncodingToBufferEncoding from "./utils/fileSystemEncodingToBufferEncoding"; - -import fs from "fs"; -import { PluginFactory, PluginPackage } from "@polywrap/plugin-js"; - -type NoConfig = Record; - -export class FileSystemPlugin extends Module { - async readFile( - args: Args_readFile, - _client: CoreClient - ): Promise { - return fs.promises - .readFile(args.path) - .then((buffer) => new Uint8Array(buffer)); - } - - async readFileAsString( - args: Args_readFileAsString, - _client: CoreClient - ): Promise { - return fs.promises.readFile(args.path, { - encoding: fileSystemEncodingToBufferEncoding(args.encoding), - }); - } - - async exists(args: Args_exists, _client: CoreClient): Promise { - return fs.existsSync(args.path); - } - - async writeFile( - args: Args_writeFile, - _client: CoreClient - ): Promise { - await fs.promises.writeFile(args.path, Buffer.from(args.data)); - - return true; - } - - async mkdir(args: Args_mkdir, _client: CoreClient): Promise { - await fs.promises.mkdir(args.path, { - recursive: args.recursive ?? false, - }); - - return true; - } - - async rm(args: Args_rm, _client: CoreClient): Promise { - await fs.promises.rm(args.path, { - recursive: args.recursive ?? false, - force: args.force ?? false, - }); - - return true; - } - - async rmdir(args: Args_rmdir, _client: CoreClient): Promise { - await fs.promises.rmdir(args.path); - - return true; - } -} -export const fileSystemPlugin: PluginFactory = () => - new PluginPackage(new FileSystemPlugin({}), manifest); - -export const plugin = fileSystemPlugin; diff --git a/packages/js/plugins/file-system/src/schema.graphql b/packages/js/plugins/file-system/src/schema.graphql deleted file mode 100644 index c7d3ccfbf7..0000000000 --- a/packages/js/plugins/file-system/src/schema.graphql +++ /dev/null @@ -1,3 +0,0 @@ -#import { Module } into FileSystem from "ens/fs.polywrap.eth" - -type Module implements FileSystem_Module { } \ No newline at end of file diff --git a/packages/js/plugins/file-system/src/utils/fileSystemEncodingToBufferEncoding.ts b/packages/js/plugins/file-system/src/utils/fileSystemEncodingToBufferEncoding.ts deleted file mode 100644 index ea7871cbbd..0000000000 --- a/packages/js/plugins/file-system/src/utils/fileSystemEncodingToBufferEncoding.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { FileSystem_Encoding, FileSystem_EncodingEnum } from "../wrap"; - -const fileSystemEncodingToBufferEncoding = ( - encoding: FileSystem_Encoding | null | undefined -): BufferEncoding => { - switch (encoding) { - case FileSystem_EncodingEnum.ASCII: - case "ASCII": - return "ascii"; - - case FileSystem_EncodingEnum.BASE64: - case "BASE64": - return "base64"; - - case FileSystem_EncodingEnum.BASE64URL: - case "BASE64URL": - return "base64url"; - - case FileSystem_EncodingEnum.BINARY: - case "BINARY": - return "binary"; - - case FileSystem_EncodingEnum.HEX: - case "HEX": - return "hex"; - - case FileSystem_EncodingEnum.LATIN1: - case "LATIN1": - return "latin1"; - - case FileSystem_EncodingEnum.UCS2: - case "UCS2": - return "ucs2"; - - case FileSystem_EncodingEnum.UTF16LE: - case "UTF16LE": - return "utf16le"; - - case FileSystem_EncodingEnum.UTF8: - case "UTF8": - return "utf8"; - - default: - return "utf8"; - } -}; - -export default fileSystemEncodingToBufferEncoding; diff --git a/packages/js/plugins/file-system/tsconfig.build.json b/packages/js/plugins/file-system/tsconfig.build.json deleted file mode 100644 index 9708b5768a..0000000000 --- a/packages/js/plugins/file-system/tsconfig.build.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": [ - "./src/**/*.ts" - ], - "exclude": [ - "./src/**/__tests__" - ] -} \ No newline at end of file diff --git a/packages/js/plugins/file-system/tsconfig.json b/packages/js/plugins/file-system/tsconfig.json deleted file mode 100644 index 85d516ce30..0000000000 --- a/packages/js/plugins/file-system/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../../../tsconfig", - "compilerOptions": { - "outDir": "build" - }, - "include": [ - "./src/**/*.ts" - ], - "exclude": [] -} diff --git a/packages/js/plugins/uri-resolvers/file-system-resolver/README.md b/packages/js/plugins/uri-resolvers/file-system-resolver/README.md index 113067f67f..b997ce3774 100644 --- a/packages/js/plugins/uri-resolvers/file-system-resolver/README.md +++ b/packages/js/plugins/uri-resolvers/file-system-resolver/README.md @@ -33,7 +33,7 @@ export async function foo({ plugin: fileSystemResolverPlugin({}), }, { - uri: "wrap://ens/fs.polywrap.eth", + uri: "wrap://ens/wrappers.polywrap.eth:file-system@1.0.0", plugin: filesystemPlugin({}), } ], diff --git a/packages/js/plugins/uri-resolvers/file-system-resolver/package.json b/packages/js/plugins/uri-resolvers/file-system-resolver/package.json index 64673f5749..3aae8a7ff4 100644 --- a/packages/js/plugins/uri-resolvers/file-system-resolver/package.json +++ b/packages/js/plugins/uri-resolvers/file-system-resolver/package.json @@ -24,6 +24,7 @@ "@polywrap/plugin-js": "0.10.0-pre.7" }, "devDependencies": { + "@polywrap/client-config-builder-js": "0.10.0-pre.7", "@polywrap/client-js": "0.10.0-pre.7", "@polywrap/fs-plugin-js": "0.10.0-pre.7", "@types/jest": "26.0.8", diff --git a/packages/js/plugins/uri-resolvers/file-system-resolver/polywrap.yaml b/packages/js/plugins/uri-resolvers/file-system-resolver/polywrap.yaml index b8002a98c5..209f9e972e 100644 --- a/packages/js/plugins/uri-resolvers/file-system-resolver/polywrap.yaml +++ b/packages/js/plugins/uri-resolvers/file-system-resolver/polywrap.yaml @@ -8,5 +8,5 @@ source: import_abis: - uri: "ens/uri-resolver.core.polywrap.eth" abi: ../../../../interfaces/uri-resolver/build/wrap.info - - uri: "ens/fs.polywrap.eth" - abi: ../../../../interfaces/file-system/build/wrap.info \ No newline at end of file + - uri: "wrap://ens/wrappers.polywrap.eth:file-system@1.0.0" + abi: ./schema.interface.graphql \ No newline at end of file diff --git a/packages/interfaces/file-system/src/schema.graphql b/packages/js/plugins/uri-resolvers/file-system-resolver/schema.interface.graphql similarity index 100% rename from packages/interfaces/file-system/src/schema.graphql rename to packages/js/plugins/uri-resolvers/file-system-resolver/schema.interface.graphql diff --git a/packages/js/plugins/uri-resolvers/file-system-resolver/src/__tests__/e2e.spec.ts b/packages/js/plugins/uri-resolvers/file-system-resolver/src/__tests__/e2e.spec.ts index 1c886ab762..930aebe43b 100644 --- a/packages/js/plugins/uri-resolvers/file-system-resolver/src/__tests__/e2e.spec.ts +++ b/packages/js/plugins/uri-resolvers/file-system-resolver/src/__tests__/e2e.spec.ts @@ -10,7 +10,7 @@ jest.setTimeout(360000); const simpleWrapperPath = `${GetPathToTestWrappers()}/wasm-as/simple`; const simpleWrapperUri = new Uri(`fs/${simpleWrapperPath}/build`); -describe("Filesystem plugin", () => { +describe("Filesystem Resolver plugin", () => { let client: PolywrapClient; beforeAll(async () => { diff --git a/packages/js/plugins/uri-resolvers/file-system-resolver/src/__tests__/helpers/getClient.ts b/packages/js/plugins/uri-resolvers/file-system-resolver/src/__tests__/helpers/getClient.ts index 644f5bf156..75de093b8f 100644 --- a/packages/js/plugins/uri-resolvers/file-system-resolver/src/__tests__/helpers/getClient.ts +++ b/packages/js/plugins/uri-resolvers/file-system-resolver/src/__tests__/helpers/getClient.ts @@ -7,6 +7,7 @@ import { PolywrapClient } from "@polywrap/client-js"; import { ExtendableUriResolver } from "@polywrap/uri-resolver-extensions-js"; import { fileSystemPlugin } from "@polywrap/fs-plugin-js"; import { fileSystemResolverPlugin } from "../.."; +import { defaultInterfaces } from "@polywrap/client-config-builder-js"; export const getClient = () => { return new PolywrapClient( @@ -25,7 +26,7 @@ export const getClient = () => { package: fileSystemResolverPlugin({}), }, { - uri: "wrap://ens/fs.polywrap.eth", + uri: defaultInterfaces.fileSystem, package: fileSystemPlugin({}), }, new ExtendableUriResolver(), diff --git a/packages/js/plugins/uri-resolvers/file-system-resolver/src/schema.graphql b/packages/js/plugins/uri-resolvers/file-system-resolver/src/schema.graphql index 66c7c23dcc..6f9609895f 100644 --- a/packages/js/plugins/uri-resolvers/file-system-resolver/src/schema.graphql +++ b/packages/js/plugins/uri-resolvers/file-system-resolver/src/schema.graphql @@ -1,4 +1,4 @@ #import { Module, MaybeUriOrManifest } into UriResolver from "ens/uri-resolver.core.polywrap.eth" -#import { Module } into FileSystem from "ens/fs.polywrap.eth" +#import { Module } into FileSystem from "wrap://ens/wrappers.polywrap.eth:file-system@1.0.0" type Module implements UriResolver_Module { } diff --git a/packages/js/plugins/ws/src/__tests__/e2e/helpers/getClient.ts b/packages/js/plugins/ws/src/__tests__/e2e/helpers/getClient.ts index 72edf4600e..e118c8c7d5 100644 --- a/packages/js/plugins/ws/src/__tests__/e2e/helpers/getClient.ts +++ b/packages/js/plugins/ws/src/__tests__/e2e/helpers/getClient.ts @@ -10,6 +10,7 @@ import { fileSystemPlugin } from "@polywrap/fs-plugin-js"; import { fileSystemResolverPlugin } from "@polywrap/fs-resolver-plugin-js"; import { ExtendableUriResolver } from "@polywrap/uri-resolver-extensions-js"; import { wsPlugin } from "../../.."; +import { defaultInterfaces } from "@polywrap/client-config-builder-js"; export const getClient = (staticResolvers?: StaticResolverLike[]) => { return new PolywrapClient( @@ -33,7 +34,7 @@ export const getClient = (staticResolvers?: StaticResolverLike[]) => { package: fileSystemResolverPlugin({}), }, { - uri: "wrap://ens/fs.polywrap.eth", + uri: defaultInterfaces.fileSystem, package: fileSystemPlugin({}), }, ...(staticResolvers ?? []), diff --git a/yarn.lock b/yarn.lock index a953335bde..1002a3f692 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3391,6 +3391,14 @@ "@polywrap/core-js" "0.10.0-pre.6" "@polywrap/plugin-js" "0.10.0-pre.6" +"@polywrap/fs-plugin-js@0.10.0-pre.7": + version "0.10.0-pre.7" + resolved "https://registry.yarnpkg.com/@polywrap/fs-plugin-js/-/fs-plugin-js-0.10.0-pre.7.tgz#d066fac96869363de512978bb66204b589ffa9a1" + integrity sha512-zhNOrzaK+X95orrD9FgHRt6etUMq2kjzfZtbPGHcBxN3JR81rtO+7UsVfCdz1U2VoHXsKOZ6t59JhHVfvVRP/g== + dependencies: + "@polywrap/core-js" "0.10.0-pre.7" + "@polywrap/plugin-js" "0.10.0-pre.7" + "@polywrap/fs-resolver-plugin-js@0.10.0-pre.6": version "0.10.0-pre.6" resolved "https://registry.yarnpkg.com/@polywrap/fs-resolver-plugin-js/-/fs-resolver-plugin-js-0.10.0-pre.6.tgz#94b48d2eb87d940a2b1cf5822b3b6cc8ca7f606c"