Skip to content

Commit

Permalink
CU-3nuxc9q - Refine unused codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-yu-2013 authored and stiartsly committed Oct 8, 2022
1 parent 0175556 commit 07e73a4
Show file tree
Hide file tree
Showing 37 changed files with 190 additions and 318 deletions.
12 changes: 6 additions & 6 deletions src/backup.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { AppContext } from "./connection/auth/appcontext";
import { PromotionService } from "./service/promotion/promotionservice";
import { ServiceEndpoint } from "./connection/serviceendpoint";
import {AppContext} from "./connection/auth/appcontext";
import {PromotionService} from "./service/promotion/promotionservice";
import {ServiceEndpoint} from "./connection/serviceendpoint";

export class Backup extends ServiceEndpoint {
private readonly promotionService: PromotionService;

public constructor(context: AppContext, providerAddress?: string) {
constructor(context: AppContext, providerAddress?: string) {
super(context, providerAddress);
this.promotionService = new PromotionService(this);
this.promotionService = new PromotionService(this);
}

public getPromotionService(): PromotionService {
getPromotionService(): PromotionService {
return this.promotionService;
}
}
23 changes: 16 additions & 7 deletions src/connection/auth/defaultappcontextprovider.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { Claims, DID, DIDBackend, DIDDocument, DIDStore, DIDURL, Issuer, JWTHeader, JWTParserBuilder, RootIdentity, VerifiableCredential, VerifiablePresentation } from "@elastosfoundation/did-js-sdk";
import { HiveException } from "../../exceptions";
import { AppContextProvider } from "./appcontextprovider";
import {
Claims,
DID,
DIDDocument,
DIDStore,
DIDURL,
Issuer,
JWTHeader,
JWTParserBuilder,
RootIdentity,
VerifiableCredential,
VerifiablePresentation
} from "@elastosfoundation/did-js-sdk";
import {HiveException} from "../../exceptions";
import {AppContextProvider} from "./appcontextprovider";
import dayjs from "dayjs";
import { Logger } from "../../utils/logger";
//import { ShorthandPropertyAssignment } from "typescript";

import {Logger} from "../../utils/logger";

export class AppContextParameters {
storePath: string;
Expand All @@ -19,7 +29,6 @@ export class AppContextParameters {
userStorePass: string;
}


export class DefaultAppContextProvider implements AppContextProvider {

private static LOG = new Logger("DefaultAppContextProvider");
Expand Down
8 changes: 0 additions & 8 deletions src/connection/httpmethod.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/connection/httpoptions.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/connection/httpresponseparser.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/connection/streamresponseparser.ts

This file was deleted.

12 changes: 1 addition & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

'use strict';

import { Vault } from "./vault";
Expand All @@ -9,10 +8,6 @@ import { NodeVersion } from "./service/about/nodeversion";
import { NodeInfo } from "./service/about/nodeinfo";
import { SHA256 } from "./utils/sha256";
import * as Utils from "./utils/utils";
import { HttpOptions, HttpHeaders } from "./connection/httpoptions";
import { HttpMethod } from "./connection/httpmethod";
import { HttpResponseParser } from "./connection/httpresponseparser";
import { StreamResponseParser } from "./connection/streamresponseparser";
import { ServiceEndpoint } from "./connection/serviceendpoint";
import { AccessToken } from "./connection/auth/accesstoken";
import { AppContext } from "./connection/auth/appcontext";
Expand Down Expand Up @@ -127,14 +122,10 @@ Logger.setDefaultLevel(Logger.DEBUG);

export type {
DataStorage,
HttpResponseParser,
StreamResponseParser,
AppContextProvider,
BridgeHandler,
CodeFetcher,
BackupContext,
HttpHeaders,
HttpOptions
BackupContext
}

export {
Expand All @@ -157,7 +148,6 @@ export {
VaultInfo,
File,
FileStorage,
HttpMethod,
ServiceEndpoint,
AccessToken,
NodeVersion,
Expand Down
3 changes: 0 additions & 3 deletions src/ipfsrunner.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as http from "http";
import * as https from "https";


export class IpfsRunner {

private readonly ipfsGatewayUrl: string;
private readonly https: any;

Expand All @@ -28,5 +26,4 @@ export class IpfsRunner {
})
});
}

}
12 changes: 6 additions & 6 deletions src/scriptrunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ export class ScriptRunner extends ServiceEndpoint{
* @param context null means to do anonymous access the script
* @param providerAddress must provide when context is null
*/
public constructor(context: AppContext, providerAddress?: string) {
constructor(context: AppContext, providerAddress?: string) {
super(context, providerAddress);
this.scriptService = new ScriptingService(this);
}

public async callScript<T>(name: string, params: any, targetDid: string, targetAppDid: string): Promise<T> {
async callScript<T>(name: string, params: any, targetDid: string, targetAppDid: string): Promise<T> {
return await this.scriptService.callScript(name, params, targetDid, targetAppDid);
}

public async callScriptUrl<T>(name: string, params: string, targetDid: string, targetAppDid: string): Promise<T> {
async callScriptUrl<T>(name: string, params: string, targetDid: string, targetAppDid: string): Promise<T> {
return await this.scriptService.callScriptUrl(name, params, targetDid, targetAppDid);
}

public async uploadFile(transactionId: string, data: Buffer | string): Promise<void> {
async uploadFile(transactionId: string, data: Buffer | string): Promise<void> {
return await this.scriptService.uploadFile(transactionId, data);
}

public async downloadFile(transactionId: string): Promise<Buffer> {
async downloadFile(transactionId: string): Promise<Buffer> {
return await this.scriptService.downloadFile(transactionId);
}

public async downloadFileByHiveUrl(hiveUrl: string): Promise<Buffer> {
async downloadFileByHiveUrl(hiveUrl: string): Promise<Buffer> {
return await this.scriptService.downloadFileByHiveUrl(hiveUrl);
}
}
6 changes: 3 additions & 3 deletions src/service/about/nodeversion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export class NodeVersion {
private major: number;
private minor: number;
private patch: number;
private readonly major: number;
private readonly minor: number;
private readonly patch: number;

constructor(major: number, minor: number, patch: number) {
this.major = major;
Expand Down
6 changes: 3 additions & 3 deletions src/service/backup/localresolver.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ServiceEndpoint } from "../../connection/serviceendpoint";
import { CodeFetcher } from "../../connection/auth/codefetcher";
import {VerifiableCredential} from "@elastosfoundation/did-js-sdk";
import {ServiceEndpoint} from "../../connection/serviceendpoint";
import {CodeFetcher} from "../../connection/auth/codefetcher";
import {BackupContext} from "./backupcontext";
import {NotImplementedException} from "../../exceptions";
import {VerifiableCredential} from "@elastosfoundation/did-js-sdk";
import {SHA256} from "../..";

export class LocalResolver implements CodeFetcher {
Expand Down
2 changes: 0 additions & 2 deletions src/service/backup/remoteresolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ export class RemoteResolver implements CodeFetcher {
throw new NotImplementedException();
}
}


3 changes: 1 addition & 2 deletions src/service/database/databaseencryption.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {InvalidParameterException, NotImplementedException} from "../../exceptions";
import {Cipher, JSONObject} from "@elastosfoundation/did-js-sdk";
import {InvalidParameterException, NotImplementedException} from "../../exceptions";
import {BasicEncryptionValue, EncryptionValue} from "../../utils/encryption/encryptionvalue";
import {Logger} from "../../utils/logger";

Expand Down Expand Up @@ -228,4 +228,3 @@ export class DatabaseEncryption {
return new EncryptionUpdate(this.cipher, this.nonce, json).encrypt();
}
}
//
1 change: 0 additions & 1 deletion src/service/database/sortitem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export class SortItem {
public static ASCENDING = 1;
public static DESCENDING = -1;
Expand Down
1 change: 0 additions & 1 deletion src/service/database/strength.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/service/database/updateoptions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export class UpdateOptions {
public upsert: boolean;
public bypass_document_validation: boolean;
Expand Down
7 changes: 0 additions & 7 deletions src/service/payment/versionresult.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/service/scripting/aggregatedcondition.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Condition } from "./condition";
import {Condition} from "./condition";

export abstract class AggregatedCondition extends Condition {
public static AND = "and";
public static OR = "or";

public constructor(name: string, type: string, conditions?: Condition[]) {
protected constructor(name: string, type: string, conditions?: Condition[]) {
super(name, type, conditions);
}

public setConditions(conditions: Condition[]): AggregatedCondition {
setConditions(conditions: Condition[]): AggregatedCondition {
super.setBody(conditions == null ? [] : conditions);
return this;
}

public appendCondition(condition: Condition): AggregatedCondition {
appendCondition(condition: Condition): AggregatedCondition {
if (!condition) {
return this;
}
Expand Down
8 changes: 4 additions & 4 deletions src/service/scripting/aggregatedexecutable.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Executable, ExecutableType } from "./executable";
import {Executable, ExecutableType} from "./executable";

/**
* Convenient class to store and serialize a sequence of executables.
*/
export class AggregatedExecutable extends Executable {

public constructor(name: string, executables?: Executable[]) {
constructor(name: string, executables?: Executable[]) {
super(name, ExecutableType.AGGREGATED, executables);
}

public appendExecutable(executable: Executable): AggregatedExecutable {
appendExecutable(executable: Executable): AggregatedExecutable {
if (!executable || !executable.getBody())
return this;

Expand All @@ -27,4 +27,4 @@ export class AggregatedExecutable extends Executable {
}
return this;
}
}
}
6 changes: 3 additions & 3 deletions src/service/scripting/andcondition.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AggregatedCondition } from "./aggregatedcondition";
import { Condition } from "./condition";
import {AggregatedCondition} from "./aggregatedcondition";
import {Condition} from "./condition";

/**
* Vault script condition that succeeds only if all the contained conditions are successful.
*/
export class AndCondition extends AggregatedCondition {
public constructor(name: string, conditions?: Condition[]) {
constructor(name: string, conditions?: Condition[]) {
super(name, AggregatedCondition.AND, conditions);
}
}
5 changes: 1 addition & 4 deletions src/service/scripting/context.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
export class Context {

//@SerializedName("target_did")
private target_did: string;
//@SerializedName("target_app_did")
private target_app_did: string;

public setTargetDid( targetDid: string): Context {
Expand All @@ -14,4 +11,4 @@ export class Context {
this.target_app_did = targetAppDid;
return this;
}
}
}
4 changes: 2 additions & 2 deletions src/service/scripting/countexecutable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Executable } from "./executable";
import { ExecutableDatabaseBody, ExecutableType } from "./executable";
import {Executable} from "./executable";
import {ExecutableDatabaseBody, ExecutableType} from "./executable";

export class CountExecutableBody extends ExecutableDatabaseBody {
private filter: any;
Expand Down
7 changes: 1 addition & 6 deletions src/service/scripting/deleteexecutable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Executable, ExecutableDatabaseBody, ExecutableType } from "./executable";
import {Executable, ExecutableDatabaseBody, ExecutableType} from "./executable";

export class DeleteExecutableBody extends ExecutableDatabaseBody {
private filter: any;
Expand All @@ -14,9 +14,4 @@ export class DeleteExecutable extends Executable {
super(name, ExecutableType.DELETE, null);
super.setBody(new DeleteExecutableBody(collectionName, filter));
}

// public DeleteExecutable( name: string, collectionName: string) {
// this(name, collectionName, null);
// }

}
2 changes: 1 addition & 1 deletion src/service/scripting/executable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Condition } from "./condition";
import {Condition} from "./condition";

export class ExecutableType {
public static AGGREGATED = "aggregated";
Expand Down
2 changes: 1 addition & 1 deletion src/service/scripting/filedownloadexecutable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Executable, ExecutableFileBody, ExecutableType } from "./executable";
import {Executable, ExecutableFileBody, ExecutableType} from "./executable";

export class FileDownloadExecutable extends Executable {
public constructor(name: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/service/scripting/filehashexecutable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Executable, ExecutableFileBody, ExecutableType } from "./executable";
import {Executable, ExecutableFileBody, ExecutableType} from "./executable";

export class FileHashExecutable extends Executable {
constructor( name: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/service/scripting/filepropertiesexecutable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Executable, ExecutableFileBody, ExecutableType } from "./executable";
import {Executable, ExecutableFileBody, ExecutableType} from "./executable";

export class FilePropertiesExecutable extends Executable {
public constructor(name: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/service/scripting/fileuploadexecutable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Executable, ExecutableFileBody, ExecutableType } from "./executable";
import {Executable, ExecutableFileBody, ExecutableType} from "./executable";

export class FileUploadExecutable extends Executable {
public constructor(name: string) {
Expand Down
Loading

0 comments on commit 07e73a4

Please sign in to comment.