Skip to content

Commit

Permalink
feat: improve the exports
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Nov 9, 2023
1 parent 172e2fd commit dd980af
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 25 deletions.
28 changes: 24 additions & 4 deletions packages/homestar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"types": "./dist/src/index.d.ts",
"default": "./src/index.js"
},
"./types": {
"types": "./dist/src/types.d.ts"
},
"./workflow": {
"types": "./dist/src/workflow.d.ts",
"default": "./src/workflow.js"
Expand All @@ -23,28 +26,45 @@
"types": "./dist/src/channel/channel.d.ts",
"default": "./src/channel/channel.js"
},
"./channel/transports/ws": {
"types": "./dist/src/channel/transports/ws.d.ts",
"default": "./src/channel/transports/ws.js"
"./transports/*": {
"types": "./dist/src/channel/transports/*",
"default": "./src/channel/transports/*"
},
"./codecs/*": {
"types": "./dist/src/channel/codecs/*",
"default": "./src/channel/codecs/*"
}
},
"main": "src/index.js",
"types": "dist/src/index.d.ts",
"typesVersions": {
"*": {
".": [
"dist/src/index"
],
"workflow": [
"dist/src/workflow"
],
"channel": [
"dist/src/channel/channel"
],
"channel/transports/*": [
"transports/*": [
"dist/src/channel/transports/*"
],
"codecs/*": [
"dist/src/channel/codecs/*"
],
"types": [
"dist/src/types"
]
}
},
"files": [
"src",
"dist/src/channel/codecs/*.d.ts",
"dist/src/channel/codecs/*.d.ts.map",
"dist/src/channel/transports/*.d.ts",
"dist/src/channel/transports/*.d.ts.map",
"dist/src/channel/*.d.ts",
"dist/src/channel/*.d.ts.map",
"dist/src/*.d.ts",
Expand Down
6 changes: 1 addition & 5 deletions packages/homestar/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pnpm install @fission-codes/homestar

```js
import { Homestar } from '@fission-codes/homestar'
import { WebsocketTransport } from '@fission-codes/homestar/channel/transports/ws'
import { WebsocketTransport } from '@fission-codes/homestar/transports/ws.js'

// if you need isomorphic support
import { WebSocket } from 'unws'
Expand All @@ -41,11 +41,7 @@ Check <https://fission-codes.github.io/stack>

## TODO

- try base64 encoding the payload

```rust
/// Health endpoint.
pub(crate) const HEALTH_ENDPOINT: &str = "health";
/// Subscribe to network events.
#[cfg(feature = "websocket-notify")]
pub(crate) const SUBSCRIBE_NETWORK_EVENTS_ENDPOINT: &str = "subscribe_network_events";
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/homestar/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { decode } from '@ipld/dag-json'
import Emittery from 'emittery'
import { Channel } from './channel/channel.js'
import { Channel } from './channel/index.js'
import { JsonRpcCodec } from './channel/codecs/jsonrpc.js'
import * as Schemas from './schemas.js'

Expand Down
2 changes: 1 addition & 1 deletion packages/homestar/test/base.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert, suite } from 'playwright-test/taps'
import { WebSocket } from 'unws'
import pDefer from 'p-defer'
import { Channel } from '../src/channel/channel.js'
import { Channel } from '../src/channel/index.js'
import { JsonRpcCodec } from '../src/channel/codecs/jsonrpc.js'
import { WebsocketTransport } from '../src/channel/transports/ws.js'

Expand Down
64 changes: 63 additions & 1 deletion packages/homestar/test/homestar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,68 @@ test(
assert.equal(count, 2)
},
{
timeout: 120_000,
timeout: 30_000,
}
)

test(
'should run workflow with deps',
async function () {
/** @type {import('p-defer').DeferredPromise<number>} */
const prom = pDefer()
const hs = new Homestar({
transport: new WebsocketTransport(wsUrl, {
ws: WebSocket,
}),
})
let count = 0
const { dataUrl } = await getImgBlob()
const workflow = await Workflow.workflow({
name: 'test-template',
workflow: {
tasks: [
Workflow.cropBase64({
name: 'crop64',
resource: wasmCID,
args: {
data: dataUrl,
height: 10,
width: 10,
x: 1,
y: 1,
},
}),
Workflow.blur({
name: 'blur',
needs: 'crop64',
resource: wasmCID,
args: {
sigma: 0.1,
data: '{{needs.crop64.output}}',
},
}),
],
},
})

const { error, result } = await hs.runWorkflow(workflow, (data) => {
count++
if (count === 2) {
prom.resolve(2)
}
})

if (error) {
return assert.fail(error)
}

assert.ok(typeof result === 'string')

await prom.promise
assert.equal(count, 2)
},
{
timeout: 30_000,
skip: Client.mode === 'node',
}
)
36 changes: 23 additions & 13 deletions pnpm-lock.yaml

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

0 comments on commit dd980af

Please sign in to comment.