Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/origin-dev' into kris/uri-type-i…
Browse files Browse the repository at this point in the history
…nference

# Conflicts:
#	yarn.lock
  • Loading branch information
krisbitney committed Oct 31, 2023
2 parents 16d6ec4 + 0878b14 commit 148364f
Show file tree
Hide file tree
Showing 57 changed files with 387 additions and 158 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/cd-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and Deploy Documentation

on:
push:
branches:
main

jobs:
deploy-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm

- name: Setup Node.js
uses: actions/setup-node@master
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: (yarn install --nonInteractive --frozen-lockfile --prefer-offline || yarn install --nonInteractive --frozen-lockfile --prefer-offline)

- name: Build
run: yarn build

- name: Generate reference
run: yarn build:reference

- name: Deploy documentation to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages-reference
folder: reference
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ polywrap.deployment.txt
**/__pycache__/
**/dist/
poetry.lock
examples/yarn.lock
examples/yarn.lock
reference
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ if (!result.ok) {
}
```
# Resources

- [Documentation](https://docs.polywrap.io/)
- [Javascript Client Reference Documentation](https://polywrap.github.io/javascript-client/)
- [Polywrap Documentation](https://docs.polywrap.io/)
- [Examples](./examples/)
- [Features supported](https://github.com/polywrap/client-readiness/tree/main/clients/js/src/features)

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"build:bundles": "lerna run build --scope @polywrap/*-config-bundle-js",
"build:client": "lerna run build --scope @polywrap/core-client-js --scope @polywrap/client-js --scope @polywrap/client-config-builder-js",
"build:docs": "lerna run build:docs",
"build:reference": "npx typedoc",
"lint": "lerna run lint",
"lint:fix": "lerna run lint -- --fix",
"lint:ci": "yarn lint",
Expand All @@ -44,7 +45,8 @@
"graphql": "15.5.0",
"lerna": "4.0.0",
"prettier": "2.2.1",
"rimraf": "3.0.2",
"ts-node": "10.9.1",
"rimraf": "3.0.2"
"typedoc": "^0.25.1"
}
}
}
2 changes: 1 addition & 1 deletion packages/asyncify/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig",
"extends": "../../tsconfig.base",
"compilerOptions": {
"lib": [
"es2020",
Expand Down
4 changes: 4 additions & 0 deletions packages/asyncify/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"entryPoints": ["./src/index.ts"],
"tsconfig": "./tsconfig.json"
}
2 changes: 1 addition & 1 deletion packages/client/src/__tests__/core/sanity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe("sanity", () => {
let config: CoreClientConfig = {
resolver: {
tryResolveUri: (_a: unknown, _b: unknown, _c: unknown) => {
return Promise.resolve(ResultErr());
return Promise.resolve(ResultErr(undefined));
},
},
interfaces: undefined,
Expand Down
28 changes: 14 additions & 14 deletions packages/client/src/__tests__/core/type-test-cases.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { memoryStoragePlugin, ErrResult } from "../helpers";
import { memoryStoragePlugin } from "../helpers";
import { PolywrapClient } from "../../PolywrapClient";

import BigNumber from "bignumber.js";
Expand Down Expand Up @@ -227,7 +227,7 @@ export const typeTestCases = (implementation: string) => {
},
});

method1a = method1a as ErrResult;
if (method1a.ok) throw Error("Expected error, but found `result.ok === true`");
expect(method1a.error).toBeTruthy();
expect(method1a.error?.message).toMatch(
/__wrap_abort: Invalid value for enum 'SanityEnum': 5/gm
Expand All @@ -253,7 +253,7 @@ export const typeTestCases = (implementation: string) => {
},
});

method1c = method1c as ErrResult;
if (method1c.ok) throw Error("Expected error, but found `result.ok === true`");
expect(method1c.error).toBeTruthy();
expect(method1c.error?.message).toMatch(
/__wrap_abort: Invalid key for enum 'SanityEnum': INVALID/gm
Expand All @@ -280,7 +280,7 @@ export const typeTestCases = (implementation: string) => {
arg: 10,
},
});
invalidBoolIntSent = invalidBoolIntSent as ErrResult;
if (invalidBoolIntSent.ok) throw Error("Expected error, but found `result.ok === true`");
expect(invalidBoolIntSent.error).toBeTruthy();
expect(invalidBoolIntSent.error?.message).toMatch(
/Property must be of type 'bool'. Found 'int'./
Expand All @@ -293,7 +293,7 @@ export const typeTestCases = (implementation: string) => {
arg: true,
},
});
invalidIntBoolSent = invalidIntBoolSent as ErrResult;
if (invalidIntBoolSent.ok) throw Error("Expected error, but found `result.ok === true`");
expect(invalidIntBoolSent.error).toBeTruthy();
expect(invalidIntBoolSent.error?.message).toMatch(
/Property must be of type 'int'. Found 'bool'./
Expand All @@ -306,7 +306,7 @@ export const typeTestCases = (implementation: string) => {
arg: [10],
},
});
invalidUIntArraySent = invalidUIntArraySent as ErrResult;
if (invalidUIntArraySent.ok) throw Error("Expected error, but found `result.ok === true`");
expect(invalidUIntArraySent.error).toBeTruthy();
expect(invalidUIntArraySent.error?.message).toMatch(
/Property must be of type 'uint'. Found 'array'./
Expand All @@ -320,7 +320,7 @@ export const typeTestCases = (implementation: string) => {
},
});

invalidBytesFloatSent = invalidBytesFloatSent as ErrResult;
if (invalidBytesFloatSent.ok) throw Error("Expected error, but found `result.ok === true`");
expect(invalidBytesFloatSent.error).toBeTruthy();
expect(invalidBytesFloatSent.error?.message).toMatch(
/Property must be of type 'bytes'. Found 'float64'./
Expand All @@ -336,7 +336,7 @@ export const typeTestCases = (implementation: string) => {
},
});

invalidArrayMapSent = invalidArrayMapSent as ErrResult;
if (invalidArrayMapSent.ok) throw Error("Expected error, but found `result.ok === true`");
expect(invalidArrayMapSent.error).toBeTruthy();
expect(invalidArrayMapSent.error?.message).toMatch(
/Property must be of type 'array'. Found 'map'./
Expand Down Expand Up @@ -447,7 +447,7 @@ export const typeTestCases = (implementation: string) => {
},
});

i8Underflow = i8Underflow as ErrResult;
if (i8Underflow.ok) throw Error("Expected error, but found `result.ok === true`");
expect(i8Underflow.error).toBeTruthy();
expect(i8Underflow.error?.message).toMatch(
/integer overflow: value = -129; bits = 8/
Expand All @@ -461,7 +461,7 @@ export const typeTestCases = (implementation: string) => {
second: 10,
},
});
u8Overflow = u8Overflow as ErrResult;
if (u8Overflow.ok) throw Error("Expected error, but found `result.ok === true`");
expect(u8Overflow.error).toBeTruthy();
expect(u8Overflow.error?.message).toMatch(
/unsigned integer overflow: value = 256; bits = 8/
Expand All @@ -475,7 +475,7 @@ export const typeTestCases = (implementation: string) => {
second: 10,
},
});
i16Underflow = i16Underflow as ErrResult;
if (i16Underflow.ok) throw Error("Expected error, but found `result.ok === true`");
expect(i16Underflow.error).toBeTruthy();
expect(i16Underflow.error?.message).toMatch(
/integer overflow: value = -32769; bits = 16/
Expand All @@ -489,7 +489,7 @@ export const typeTestCases = (implementation: string) => {
second: 10,
},
});
u16Overflow = u16Overflow as ErrResult;
if (u16Overflow.ok) throw Error("Expected error, but found `result.ok === true`");
expect(u16Overflow.error).toBeTruthy();
expect(u16Overflow.error?.message).toMatch(
/unsigned integer overflow: value = 65536; bits = 16/
Expand All @@ -503,7 +503,7 @@ export const typeTestCases = (implementation: string) => {
second: 10,
},
});
i32Underflow = i32Underflow as ErrResult;
if (i32Underflow.ok) throw Error("Expected error, but found `result.ok === true`");
expect(i32Underflow.error).toBeTruthy();
expect(i32Underflow.error?.message).toMatch(
/integer overflow: value = -2147483649; bits = 32/
Expand All @@ -517,7 +517,7 @@ export const typeTestCases = (implementation: string) => {
second: 10,
},
});
u32Overflow = u32Overflow as ErrResult;
if (u32Overflow.ok) throw Error("Expected error, but found `result.ok === true`");
expect(u32Overflow.error).toBeTruthy();
expect(u32Overflow.error?.message).toMatch(
/unsigned integer overflow: value = 4294967296; bits = 32/
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/__tests__/core/wasm-wrapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { WrapManifest } from "@polywrap/wrap-manifest-types-js";
import { PluginModule, PluginPackage } from "@polywrap/plugin-js";
import { UriResolver } from "@polywrap/uri-resolvers-js";
import { PolywrapClientConfigBuilder } from "@polywrap/client-config-builder-js";
import { mockPluginRegistration, ErrResult } from "../helpers";
import { mockPluginRegistration } from "../helpers";
import { ResultOk } from "@polywrap/result";

jest.setTimeout(200000);
Expand Down Expand Up @@ -175,7 +175,7 @@ describe("wasm-wrapper", () => {
}
);

pluginGetFileResult = pluginGetFileResult as ErrResult;
if (pluginGetFileResult.ok) throw Error("Expected error, but found `result.ok === true`");
expect(pluginGetFileResult.error?.message).toContain(
"client.getFile(...) is not implemented for Plugins."
);
Expand Down
2 changes: 0 additions & 2 deletions packages/client/src/__tests__/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export const mockPluginRegistration = (uri: string | Uri) => {
};
};

export type ErrResult<E = undefined> = { ok: false; error: E | undefined };

export const incompatiblePlugin = () => {
class IncompatiblePlugin extends PluginModule<Record<string, unknown>> {
async getData(_: {}): Promise<number> {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig",
"extends": "../../tsconfig.base",
"compilerOptions": {
"lib": [
"es2020",
Expand Down
4 changes: 4 additions & 0 deletions packages/client/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"entryPoints": ["./src/index.ts"],
"tsconfig": "./tsconfig.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MockUriResolver implements IUriResolver {
tryResolveUri(
_uri: Uri,
_client: CoreClient
): Promise<Result<UriPackageOrWrapper>> {
): Promise<Result<UriPackageOrWrapper, undefined>> {
throw new Error("Not implemented");
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/config-builder/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig",
"extends": "../../tsconfig.base",
"include": [
"./src/**/*.ts",
"./examples/**/*.ts"
Expand Down
4 changes: 4 additions & 0 deletions packages/config-builder/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"entryPoints": ["./src/index.ts"],
"tsconfig": "./tsconfig.json"
}
2 changes: 1 addition & 1 deletion packages/config-bundle/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig",
"extends": "../../tsconfig.base",
"compilerOptions": {
"outDir": "build"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/config-bundle/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"entryPoints": ["./src/index.ts"],
"tsconfig": "./tsconfig.json"
}
2 changes: 1 addition & 1 deletion packages/config-bundles/sys/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig",
"extends": "../../../tsconfig.base",
"compilerOptions": {
"outDir": "build"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/config-bundles/sys/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"entryPoints": ["./src/index.ts"],
"tsconfig": "./tsconfig.json"
}
2 changes: 1 addition & 1 deletion packages/config-bundles/web3/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig",
"extends": "../../../tsconfig.base",
"compilerOptions": {
"outDir": "build"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/config-bundles/web3/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"entryPoints": ["./src/index.ts"],
"tsconfig": "./tsconfig.json"
}
2 changes: 1 addition & 1 deletion packages/core-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig",
"extends": "../../tsconfig.base",
"compilerOptions": {
"lib": [
"es2020",
Expand Down
4 changes: 4 additions & 0 deletions packages/core-client/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"entryPoints": ["./src/index.ts"],
"tsconfig": "./tsconfig.json"
}
2 changes: 1 addition & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig",
"extends": "../../tsconfig.base",
"compilerOptions": {
"outDir": "build"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/core/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"entryPoints": ["./src/index.ts"],
"tsconfig": "./tsconfig.json"
}
2 changes: 1 addition & 1 deletion packages/manifests/wrap/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig",
"extends": "../../../tsconfig.base",
"compilerOptions": {
"outDir": "build"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/msgpack/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig",
"extends": "../../tsconfig.base",
"compilerOptions": {
"lib": [
"es2020",
Expand Down
4 changes: 4 additions & 0 deletions packages/msgpack/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"entryPoints": ["./src/index.ts"],
"tsconfig": "./tsconfig.json"
}
2 changes: 1 addition & 1 deletion packages/plugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig",
"extends": "../../tsconfig.base",
"compilerOptions": {
"outDir": "build"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"entryPoints": ["./src/index.ts"],
"tsconfig": "./tsconfig.json"
}
4 changes: 1 addition & 3 deletions packages/result/src/Result.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export type Result<T, E = undefined> =
| { ok: true; value: T }
| { ok: false; error: E | undefined };
export type Result<T, E> = { ok: true; value: T } | { ok: false; error: E };
Loading

0 comments on commit 148364f

Please sign in to comment.