@holochain/client
Advanced tools
Comparing version 0.17.0-dev.12 to 0.17.0-rc.0
@@ -41,7 +41,3 @@ import { Action, DhtOp, Entry, ZomeCallCapGrant } from "../../hdk/index.js"; | ||
*/ | ||
export type DeactivationReason = { | ||
never_activated: null; | ||
} | { | ||
normal: null; | ||
} | { | ||
export type DeactivationReason = "never_activated" | "normal" | { | ||
quarantined: { | ||
@@ -60,7 +56,3 @@ error: string; | ||
*/ | ||
export type DisabledAppReason = { | ||
never_started: null; | ||
} | { | ||
user: null; | ||
} | { | ||
export type DisabledAppReason = "never_started" | "user" | { | ||
error: string; | ||
@@ -79,5 +71,3 @@ }; | ||
}; | ||
} | { | ||
running: null; | ||
}; | ||
} | "running"; | ||
/** | ||
@@ -456,7 +446,7 @@ * @public | ||
export declare enum AppStatusFilter { | ||
Enabled = "enabled", | ||
Disabled = "disabled", | ||
Running = "running", | ||
Stopped = "stopped", | ||
Paused = "paused" | ||
Enabled = "Enabled", | ||
Disabled = "Disabled", | ||
Running = "Running", | ||
Stopped = "Stopped", | ||
Paused = "Paused" | ||
} | ||
@@ -514,3 +504,3 @@ /** | ||
*/ | ||
export type AddAgentInfoResponse = any; | ||
export type AddAgentInfoResponse = unknown; | ||
/** | ||
@@ -517,0 +507,0 @@ * @public |
@@ -49,7 +49,7 @@ /** | ||
(function (AppStatusFilter) { | ||
AppStatusFilter["Enabled"] = "enabled"; | ||
AppStatusFilter["Disabled"] = "disabled"; | ||
AppStatusFilter["Running"] = "running"; | ||
AppStatusFilter["Stopped"] = "stopped"; | ||
AppStatusFilter["Paused"] = "paused"; | ||
AppStatusFilter["Enabled"] = "Enabled"; | ||
AppStatusFilter["Disabled"] = "Disabled"; | ||
AppStatusFilter["Running"] = "Running"; | ||
AppStatusFilter["Stopped"] = "Stopped"; | ||
AppStatusFilter["Paused"] = "Paused"; | ||
})(AppStatusFilter || (AppStatusFilter = {})); |
import { CapSecret, GrantedFunctions } from "../../hdk/index.js"; | ||
import type { AgentPubKey, CellId } from "../../types.js"; | ||
import { WsClient } from "../client.js"; | ||
import { WebsocketConnectionOptions, Requester, Transformer } from "../common.js"; | ||
import { Requester, Transformer, WebsocketConnectionOptions } from "../common.js"; | ||
import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpNetworkStatsRequest, DumpNetworkStatsResponse, DumpStateRequest, DumpStateResponse, EnableAppRequest, EnableAppResponse, GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse, GetDnaDefinitionRequest, GetDnaDefinitionResponse, GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse, InstallAppRequest, InstallAppResponse, IssueAppAuthenticationTokenRequest, IssueAppAuthenticationTokenResponse, ListAppInterfacesRequest, ListAppInterfacesResponse, ListAppsRequest, ListAppsResponse, ListCellIdsRequest, ListCellIdsResponse, ListDnasRequest, ListDnasResponse, RegisterDnaRequest, RegisterDnaResponse, StorageInfoRequest, StorageInfoResponse, UninstallAppRequest, UninstallAppResponse, UpdateCoordinatorsRequest, UpdateCoordinatorsResponse } from "./types.js"; | ||
@@ -6,0 +6,0 @@ /** |
import { getLauncherEnvironment } from "../../environments/launcher.js"; | ||
import { GrantedFunctionsType, } from "../../hdk/index.js"; | ||
import { WsClient } from "../client.js"; | ||
import { catchError, DEFAULT_TIMEOUT, promiseTimeout, requesterTransformer, HolochainError, } from "../common.js"; | ||
import { DEFAULT_TIMEOUT, HolochainError, catchError, promiseTimeout, requesterTransformer, } from "../common.js"; | ||
import { generateSigningKeyPair, randomCapSecret, setSigningCredentials, } from "../zome-call-signing.js"; | ||
import { AppStatusFilter, } from "./types.js"; | ||
/** | ||
@@ -105,3 +104,3 @@ * A class for interacting with a conductor's Admin API. | ||
*/ | ||
listApps = this._requester("list_apps", listAppsTransform); | ||
listApps = this._requester("list_apps"); | ||
/** | ||
@@ -167,16 +166,6 @@ * List all attached app interfaces. | ||
const [keyPair, signingKey] = await generateSigningKeyPair(); | ||
const capSecret = await this.grantSigningKey(cellId, functions || { [GrantedFunctionsType.All]: null }, signingKey); | ||
const capSecret = await this.grantSigningKey(cellId, functions || GrantedFunctionsType.All, signingKey); | ||
setSigningCredentials(cellId, { capSecret, keyPair, signingKey }); | ||
}; | ||
} | ||
const listAppsTransform = { | ||
input: (req) => { | ||
const args = {}; | ||
if (req.status_filter) { | ||
args.status_filter = getAppStatusInApiForm(req.status_filter); | ||
} | ||
return args; | ||
}, | ||
output: (res) => res, | ||
}; | ||
const dumpStateTransform = { | ||
@@ -188,25 +177,1 @@ input: (req) => req, | ||
}; | ||
function getAppStatusInApiForm(status_filter) { | ||
switch (status_filter) { | ||
case AppStatusFilter.Running: | ||
return { | ||
Running: null, | ||
}; | ||
case AppStatusFilter.Enabled: | ||
return { | ||
Enabled: null, | ||
}; | ||
case AppStatusFilter.Paused: | ||
return { | ||
Paused: null, | ||
}; | ||
case AppStatusFilter.Disabled: | ||
return { | ||
Disabled: null, | ||
}; | ||
case AppStatusFilter.Stopped: | ||
return { | ||
Stopped: null, | ||
}; | ||
} | ||
} |
@@ -24,5 +24,3 @@ /// <reference types="ws" /> | ||
export type Tagged<T> = { | ||
type: { | ||
[tag: string]: null; | ||
}; | ||
type: string; | ||
data: T; | ||
@@ -46,3 +44,3 @@ }; | ||
} | ||
export declare const catchError: (res: any) => Promise<any>; | ||
export declare const catchError: (response: any) => Promise<any>; | ||
export declare const promiseTimeout: (promise: Promise<unknown>, tag: string, ms: number) => Promise<unknown>; | ||
@@ -49,0 +47,0 @@ /** |
@@ -12,3 +12,3 @@ const ERROR_TYPE = "error"; | ||
const transformedInput = await transform.input(req); | ||
const input = { type: { [tag]: null }, data: transformedInput }; | ||
const input = { type: tag, data: transformedInput }; | ||
const response = await requester(input, timeout); | ||
@@ -35,10 +35,10 @@ return transform.output(response.data); | ||
// this determines the error format of all error responses | ||
export const catchError = (res) => { | ||
if (ERROR_TYPE in res.type) { | ||
const errorName = Object.keys(res.data.type)[0]; | ||
const error = new HolochainError(errorName, res.data.data); | ||
export const catchError = (response) => { | ||
if (response.type === ERROR_TYPE) { | ||
const errorName = response.data.type; | ||
const error = new HolochainError(errorName, response.data.data); | ||
return Promise.reject(error); | ||
} | ||
else { | ||
return Promise.resolve(res); | ||
return Promise.resolve(response); | ||
} | ||
@@ -45,0 +45,0 @@ }; |
@@ -13,2 +13,5 @@ import { AppAuthenticationToken, CallZomeRequest } from "../api/index.js"; | ||
} | ||
export interface HostZomeCallSigner { | ||
signZomeCall: (request: CallZomeRequest) => Promise<CallZomeRequestSigned>; | ||
} | ||
declare const __HC_LAUNCHER_ENV__ = "__HC_LAUNCHER_ENV__"; | ||
@@ -15,0 +18,0 @@ declare const __HC_ZOME_CALL_SIGNER__ = "__HC_ZOME_CALL_SIGNER__"; |
@@ -25,5 +25,3 @@ import { FunctionName, ZomeName } from "../api/admin/index.js"; | ||
*/ | ||
export type GrantedFunctions = { | ||
[GrantedFunctionsType.All]: null; | ||
} | { | ||
export type GrantedFunctions = GrantedFunctionsType.All | { | ||
[GrantedFunctionsType.Listed]: [ZomeName, FunctionName][]; | ||
@@ -50,5 +48,3 @@ }; | ||
*/ | ||
export type CapAccess = { | ||
[CapAccessType.Unrestricted]: null; | ||
} | { | ||
export type CapAccess = [CapAccessType.Unrestricted] | { | ||
[CapAccessType.Transferable]: { | ||
@@ -55,0 +51,0 @@ secret: CapSecret; |
@@ -7,7 +7,3 @@ import { CapClaim, ZomeCallCapGrant } from "./capabilities.js"; | ||
*/ | ||
export type EntryVisibility = { | ||
Public: null; | ||
} | { | ||
Private: null; | ||
}; | ||
export type EntryVisibility = "Public" | "Private"; | ||
/** | ||
@@ -14,0 +10,0 @@ * @public |
{ | ||
"name": "@holochain/client", | ||
"version": "0.17.0-dev.12", | ||
"version": "0.17.0-rc.0", | ||
"description": "A JavaScript client for the Holochain Conductor API", | ||
@@ -75,2 +75,2 @@ "author": "Holochain Foundation <info@holochain.org> (https://holochain.org)", | ||
} | ||
} | ||
} |
@@ -18,8 +18,6 @@ [![Project](https://img.shields.io/badge/Project-Holochain-blue.svg?style=flat-square)](http://holochain.org/) | ||
**JS client v0.12.x** is compatible with **Holochain v0.1.x**. | ||
**JS client v0.17.x** is compatible with **Holochain v0.3.x**. | ||
**JS client v0.16.x** is compatible with **Holochain v0.2.x**. | ||
**JS client v0.17.x** is compatible with **Holochain v0.3.x**. | ||
To install from NPM, run | ||
@@ -26,0 +24,0 @@ ```bash |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
125574
3482
172