This commit is contained in:
Daniel Lugo 2021-10-08 14:57:47 -04:00
parent 62c833862b
commit 3f89ec57ba
5 changed files with 61 additions and 61 deletions

View file

@ -5,7 +5,6 @@ const uuidv1 = require('uuid/v1')
const logger = require('../../../config/log') const logger = require('../../../config/log')
const Common = require('shock-common') const Common = require('shock-common')
const { Constants, Schema } = Common const { Constants, Schema } = Common
const Gun = require('gun')
const { ErrorCode } = Constants const { ErrorCode } = Constants

View file

@ -15,7 +15,6 @@ const SchemaManager = require('../../../schema')
const LightningServices = require('../../../../utils/lightningServices') const LightningServices = require('../../../../utils/lightningServices')
const Key = require('../key') const Key = require('../key')
const Utils = require('../utils') const Utils = require('../utils')
const Gun = require('gun')
const { selfContentToken, enrollContentTokens } = require('../../../seed') const { selfContentToken, enrollContentTokens } = require('../../../seed')
/// <reference path="../../../utils/GunSmith/Smith.ts" /> /// <reference path="../../../utils/GunSmith/Smith.ts" />
const TipForwarder = require('../../../tipsCallback') const TipForwarder = require('../../../tipsCallback')

View file

@ -6,7 +6,6 @@
const { makePromise, Constants, Schema } = require('shock-common') const { makePromise, Constants, Schema } = require('shock-common')
const mapValues = require('lodash/mapValues') const mapValues = require('lodash/mapValues')
const Bluebird = require('bluebird') const Bluebird = require('bluebird')
const Gun = require('gun')
const { pubToEpub } = require('../contact-api/utils') const { pubToEpub } = require('../contact-api/utils')
const { const {

View file

@ -58,38 +58,6 @@ namespace GunT {
export type LoadListener = (data: LoadListenerData, key: string) => void export type LoadListener = (data: LoadListenerData, key: string) => void
export interface GUNNode {
_: Soul
/**
* Used only inside the subprocess.
*/
back(
path: 'opt'
): {
peers: Record<
string,
{
url: string
id: string
wire?: {
readyState: number
}
}
>
}
get(key: string): GUNNode
load(this: GUNNode, cb?: LoadListener): void
map(): GUNNode
off(): void
on(this: GUNNode, cb: Listener): void
once(this: GUNNode, cb?: Listener, opts?: { wait?: number }): void
user(): UserGUNNode
user(pub: string): GUNNode
put(data: ValidDataValue, cb?: Callback): void
set(data: ValidDataValue, cb?: Callback): GUNNode
then(): Promise<ListenerData>
}
export interface CreateAck { export interface CreateAck {
pub: string | undefined pub: string | undefined
err: string | undefined err: string | undefined
@ -114,15 +82,4 @@ namespace GunT {
export interface UserSoul extends Soul { export interface UserSoul extends Soul {
sea: UserPair sea: UserPair
} }
export interface UserGUNNode extends GUNNode {
_: UserSoul
auth(alias: string, pass: string, cb: AuthCB): void
is?: {
alias: string
pub: string
}
create(user: string, pass: string, cb: CreateCB): void
leave(): void
}
} }

View file

@ -3,17 +3,61 @@
*/ */
/// <reference path="GunT.ts" /> /// <reference path="GunT.ts" />
namespace Smith { namespace Smith {
export interface GunSmithNode extends GunT.GUNNode { export interface GunSmithNode {
_: GunT.Soul
/** /**
* @override * Used only inside the subprocess.
*/
back(
path: 'opt'
): {
peers: Record<
string,
{
url: string
id: string
wire?: {
readyState: number
}
}
>
}
/**
*
*/ */
get(key: string): GunSmithNode get(key: string): GunSmithNode
/** /**
* @override *
*/ */
map(): GunSmithNode map(): GunSmithNode
/** /**
* @override *
*/
off(): void
/**
*
*/
on(cb: GunT.Listener): void
/**
*
*/
once(cb?: GunT.Listener, opts?: { wait?: number }): void
/**
* A promise version of put().
* @throws
*/
pPut(data: GunT.ValidDataValue): Promise<void>
/**
* A promise version of set().
* @throws
*/
pSet(data: GunT.ValidDataValue): Promise<void>
/**
*
*/
put(data: GunT.ValidDataValue, cb?: GunT.Callback): void
/**
*
*/ */
set(data: GunT.ValidDataValue, cb?: GunT.Callback): GunSmithNode set(data: GunT.ValidDataValue, cb?: GunT.Callback): GunSmithNode
/** /**
@ -34,19 +78,21 @@ namespace Smith {
* if needed. * if needed.
*/ */
specialThen(): Promise<GunT.ListenerData> specialThen(): Promise<GunT.ListenerData>
/** then(): Promise<GunT.ListenerData>
* A promise version of put(). user(): UserSmithNode
* @throws user(pub: string): GunSmithNode
*/
pPut(data: GunT.ValidDataValue): Promise<void>
/**
* A promise version of set().
* @throws
*/
pSet(data: GunT.ValidDataValue): Promise<void>
} }
export type UserSmithNode = GunSmithNode & GunT.UserGUNNode export interface UserSmithNode extends GunSmithNode {
_: GunT.UserSoul
auth(alias: string, pass: string, cb: GunT.AuthCB): void
is?: {
alias: string
pub: string
}
create(user: string, pass: string, cb: GunT.CreateCB): void
leave(): void
}
export interface PendingPut { export interface PendingPut {
cb: GunT.Callback cb: GunT.Callback