Skip to content

Commit

Permalink
chore(deps): adds external context dep
Browse files Browse the repository at this point in the history
Signed-off-by: andrew <[email protected]>
  • Loading branch information
andrewxhill committed May 12, 2020
1 parent ba72c5f commit 64ffbf3
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 459 deletions.
425 changes: 154 additions & 271 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,22 @@
"dependencies": {
"@improbable-eng/grpc-web": "^0.12.0",
"@textile/buckets-grpc": "1.0.2",
"@textile/context": "^0.1.0",
"@textile/hub-grpc": "1.0.2",
"@textile/threads-client": "^0.3.0-rc.0",
"@textile/threads-id": "0.0.3",
"@textile/threads-client": "v0.3.0",
"@textile/threads-id": "0.0.4",
"@textile/users-grpc": "1.0.2",
"@types/google-protobuf": "^3.7.2",
"axios": "^0.19.2",
"cids": "^0.8.0",
"delay": "^4.3.0",
"fast-sha256": "^1.3.0",
"google-protobuf": "^3.10.0",
"isomorphic-ws": "^4.0.1",
"loglevel": "^1.6.8",
"queueable": "^4.1.4"
},
"devDependencies": {
"@textile/threads-core": "^0.1.5-rc.0",
"@textile/threads-core": "^0.1.6",
"@types/browser-or-node": "^1.2.0",
"@types/chai": "^4.2.5",
"@types/mocha": "^7.0.1",
Expand All @@ -87,6 +87,7 @@
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.1",
"isomorphic-ws": "^4.0.1",
"mocha": "^6.2.2",
"nyc": "^15.0.0",
"polendina": "^1.0.0",
Expand All @@ -102,6 +103,7 @@
"typescript": "^3.7.2",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0"
"webpack-dev-server": "^3.9.0",
"ws": "^7.3.0"
}
}
4 changes: 2 additions & 2 deletions src/buckets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ThreadID } from '@textile/threads-id'
import { expect } from 'chai'
import { Client } from '@textile/threads-client'
import { InitReply } from '@textile/buckets-grpc/buckets_pb'
import { Context } from './context'
import { Context } from '@textile/context'
import { Buckets } from './buckets'
import { signUp } from './utils'

Expand All @@ -28,7 +28,7 @@ describe('Buckets...', () => {
ctx = ctx.withSession(user.user?.session).withThreadName('buckets')
const id = ThreadID.fromRandom()
const db = new Client(ctx)
await db.newDB(id.toBytes())
await db.newDB(id)
ctx = ctx.withThread(id)
})

Expand Down
2 changes: 1 addition & 1 deletion src/buckets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { API, APIPushPath } from '@textile/buckets-grpc/buckets_pb_service'
import CID from 'cids'
import { Channel } from 'queueable'
import { grpc } from '@improbable-eng/grpc-web'
import { Context } from './context'
import { Context } from '@textile/context'
import { normaliseInput, File } from './normalize'

const logger = log.getLogger('buckets')
Expand Down
156 changes: 0 additions & 156 deletions src/context.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './buckets'
export * from './context'
export * from './users'
export { createAPISig } from './utils'
28 changes: 7 additions & 21 deletions src/users.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { SignupReply } from '@textile/hub-grpc/hub_pb'
import { expect } from 'chai'
import { Client } from '@textile/threads-client'
import { Libp2pCryptoIdentity } from '@textile/threads-core'
import { Context } from '@textile/context'
import { isBrowser } from 'browser-or-node'
import { Context } from './context'
import { Users } from './users'
import { signUp, createKey, createAPISig } from './utils'
import { Buckets } from './buckets'
Expand Down Expand Up @@ -74,10 +74,9 @@ describe('Users...', () => {
expect(err.code).to.equal(grpc.Code.NotFound)
}
// All good
ctx = ctx.withThreadName('foo')
const id = ThreadID.fromRandom()
const db = new Client(ctx)
await db.newDB(id.toBytes())
await db.newDB(id, ctx.withThreadName('foo'))
const res = await client.getThread('foo', ctx)
expect(res.name).to.equal('foo')
})
Expand Down Expand Up @@ -107,12 +106,8 @@ describe('Users...', () => {
expect(err.code).to.equal(grpc.Code.NotFound)
}
// All good
ctx = ctx.withThreadName('foo')
const id = ThreadID.fromRandom()
// Update existing db config directly as it doesn't yet directly support Context API on method calls
db.config = ctx
// @todo: In the near future, this should be `await db.newDB(id, ctx)`
await db.newDB(id.toBytes())
await db.newDB(id, ctx.withThreadName('foo'))
const res = await client.getThread('foo', ctx)
expect(res.name).to.equal('foo')
})
Expand Down Expand Up @@ -167,7 +162,7 @@ describe('Users...', () => {
// Got one
const id = ThreadID.fromRandom()
const db = new Client(ctx)
await db.newDB(id.toBytes())
await db.newDB(id)
res = await client.listThreads(ctx)
expect(res.listList).to.have.length(1)
})
Expand All @@ -192,12 +187,8 @@ describe('Users...', () => {
let res = await client.listThreads(ctx)
expect(res.listList).to.have.length(0)
// Got one
ctx = ctx.withThreadName('foo')
const id = ThreadID.fromRandom()
// Update existing db config directly as it doesn't yet directly support Context API on method calls
db.config = ctx
// @todo: In the near future, this should be `await db.newDB(id, ctx)`
await db.newDB(id.toBytes())
await db.newDB(id, ctx.withThreadName('foo'))
res = await client.listThreads(ctx)
expect(res.listList).to.have.length(1)
expect(res.listList[0].name).to.equal('foo')
Expand All @@ -221,11 +212,8 @@ describe('Users...', () => {
}).timeout(3000)
it('should then create a db for the bucket', async () => {
const db = new Client(ctx)
ctx = ctx.withThreadName('my-buckets')
const id = ThreadID.fromRandom()
db.config = ctx
await db.newDB(id.toBytes())
ctx = ctx.withThread(id)
await db.newDB(id, ctx.withThreadName('my-buckets'))
expect(ctx.toJSON()).to.have.ownProperty('x-textile-thread-name')
})
it('should then initialize a new bucket in the db and push to it', async function () {
Expand Down Expand Up @@ -270,11 +258,9 @@ describe('Users...', () => {
ctx = ctx.withToken(tok)
})
it('should then create a db for the bucket', async () => {
ctx = ctx.withThreadName('my-buckets')
const id = ThreadID.fromRandom()
const db = new Client(ctx)
await db.newDB(id.toBytes())
ctx = ctx.withThread(id)
await db.newDB(id, ctx.withThreadName('my-buckets'))
expect(ctx.toJSON()).to.have.ownProperty('x-textile-thread-name')
})
it('should then initialize a new bucket in the db and push to it', async function () {
Expand Down
2 changes: 1 addition & 1 deletion src/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import log from 'loglevel'
import * as pb from '@textile/users-grpc/users_pb'
import { APIClient } from '@textile/users-grpc/users_pb_service'
import { ServiceError } from '@textile/hub-grpc/hub_pb_service'
import { Context } from './context'
import { Context } from '@textile/context'
import { ThreadID } from '@textile/threads-id'

const logger = log.getLogger('users')
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HMAC } from 'fast-sha256'
import multibase from 'multibase'
import * as pb from '@textile/hub-grpc/hub_pb'
import { APIClient, ServiceError } from '@textile/hub-grpc/hub_pb_service'
import { Context } from './context'
import { Context } from '@textile/context'

export const createUsername = (size = 12) => {
return Array(size)
Expand Down

0 comments on commit 64ffbf3

Please sign in to comment.