From 3f89ec57bacc8af93282ec40fbb81ca571ee2203 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Fri, 8 Oct 2021 14:57:47 -0400 Subject: [PATCH] Simplify --- services/gunDB/contact-api/actions.js | 1 - services/gunDB/contact-api/jobs/onOrders.js | 1 - services/gunDB/rpc/index.js | 1 - utils/GunSmith/GunT.ts | 43 ------------ utils/GunSmith/Smith.ts | 76 +++++++++++++++++---- 5 files changed, 61 insertions(+), 61 deletions(-) diff --git a/services/gunDB/contact-api/actions.js b/services/gunDB/contact-api/actions.js index d3ed3750..edebb53f 100644 --- a/services/gunDB/contact-api/actions.js +++ b/services/gunDB/contact-api/actions.js @@ -5,7 +5,6 @@ const uuidv1 = require('uuid/v1') const logger = require('../../../config/log') const Common = require('shock-common') const { Constants, Schema } = Common -const Gun = require('gun') const { ErrorCode } = Constants diff --git a/services/gunDB/contact-api/jobs/onOrders.js b/services/gunDB/contact-api/jobs/onOrders.js index d2557f17..2bd8cebd 100644 --- a/services/gunDB/contact-api/jobs/onOrders.js +++ b/services/gunDB/contact-api/jobs/onOrders.js @@ -15,7 +15,6 @@ const SchemaManager = require('../../../schema') const LightningServices = require('../../../../utils/lightningServices') const Key = require('../key') const Utils = require('../utils') -const Gun = require('gun') const { selfContentToken, enrollContentTokens } = require('../../../seed') /// const TipForwarder = require('../../../tipsCallback') diff --git a/services/gunDB/rpc/index.js b/services/gunDB/rpc/index.js index 7bf64d41..5682a988 100644 --- a/services/gunDB/rpc/index.js +++ b/services/gunDB/rpc/index.js @@ -6,7 +6,6 @@ const { makePromise, Constants, Schema } = require('shock-common') const mapValues = require('lodash/mapValues') const Bluebird = require('bluebird') -const Gun = require('gun') const { pubToEpub } = require('../contact-api/utils') const { diff --git a/utils/GunSmith/GunT.ts b/utils/GunSmith/GunT.ts index b299dcb3..bd4102e8 100644 --- a/utils/GunSmith/GunT.ts +++ b/utils/GunSmith/GunT.ts @@ -58,38 +58,6 @@ namespace GunT { 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 - } - export interface CreateAck { pub: string | undefined err: string | undefined @@ -114,15 +82,4 @@ namespace GunT { export interface UserSoul extends Soul { 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 - } } diff --git a/utils/GunSmith/Smith.ts b/utils/GunSmith/Smith.ts index ed37a8c4..3ee8a655 100644 --- a/utils/GunSmith/Smith.ts +++ b/utils/GunSmith/Smith.ts @@ -3,17 +3,61 @@ */ /// 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 /** - * @override + * */ 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 + /** + * A promise version of set(). + * @throws + */ + pSet(data: GunT.ValidDataValue): Promise + /** + * + */ + put(data: GunT.ValidDataValue, cb?: GunT.Callback): void + /** + * */ set(data: GunT.ValidDataValue, cb?: GunT.Callback): GunSmithNode /** @@ -34,19 +78,21 @@ namespace Smith { * if needed. */ specialThen(): Promise - /** - * A promise version of put(). - * @throws - */ - pPut(data: GunT.ValidDataValue): Promise - /** - * A promise version of set(). - * @throws - */ - pSet(data: GunT.ValidDataValue): Promise + then(): Promise + user(): UserSmithNode + user(pub: string): GunSmithNode } - 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 { cb: GunT.Callback