@ddd-qc/cell-proxy 0.9.7 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/CellProxy.d.ts +58 -57
- package/dist/CellProxy.js +165 -154
- package/dist/CellProxy.js.map +1 -1
- package/dist/ConductorAppProxy.d.ts +74 -71
- package/dist/ConductorAppProxy.js +338 -296
- package/dist/ConductorAppProxy.js.map +1 -1
- package/dist/ZomeProxy.d.ts +34 -27
- package/dist/ZomeProxy.js +56 -38
- package/dist/ZomeProxy.js.map +1 -1
- package/dist/hcl.d.ts +26 -30
- package/dist/hcl.js +56 -90
- package/dist/hcl.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -7
- package/dist/mixins.d.ts +40 -42
- package/dist/mixins.js +50 -36
- package/dist/mixins.js.map +1 -1
- package/dist/types.d.ts +30 -32
- package/dist/types.js +31 -32
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +37 -30
- package/dist/utils.js +108 -80
- package/dist/utils.js.map +1 -1
- package/package.json +7 -9
package/dist/mixins.js
CHANGED
|
@@ -1,37 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
1
|
+
import { encodeHashToBase64 } from "@holochain/client";
|
|
2
|
+
export class Empty {
|
|
3
|
+
constructor(...args) { }
|
|
4
|
+
}
|
|
5
|
+
/** ------------------------------------------------------------------------------------------- **/
|
|
6
|
+
/**
|
|
7
|
+
* Mixin for Cell bound classes.
|
|
8
|
+
* A Cell bound class must have a "Cell" from @/holochain/client
|
|
9
|
+
*/
|
|
10
|
+
export function CellMixin(Base) {
|
|
11
|
+
class ACell extends Base {
|
|
12
|
+
get cell() { if (!this._cell)
|
|
13
|
+
throw Error("Cell not set for object"); return this._cell; }
|
|
14
|
+
get cellId() { return this._cell.cell_id; }
|
|
15
|
+
get dnaHash() { return encodeHashToBase64(this._cell.cell_id[0]); }
|
|
16
|
+
get agentPubKey() { return encodeHashToBase64(this._cell.cell_id[1]); }
|
|
17
|
+
}
|
|
18
|
+
;
|
|
19
|
+
return ACell;
|
|
20
|
+
}
|
|
21
|
+
//export const CellSpecific = CellMixin(Empty);
|
|
22
|
+
/** ------------------------------------------------------------------------------------------- **/
|
|
23
|
+
/**
|
|
24
|
+
* Mixin for Zome bound classes.
|
|
25
|
+
* A Zome bound class must have a zome name and a list of zome functions
|
|
26
|
+
*/
|
|
27
|
+
export function ZomeMixin(Base) {
|
|
28
|
+
class AZomeSpecific extends Base {
|
|
29
|
+
constructor(...args) {
|
|
30
|
+
super(args);
|
|
31
|
+
this.zomeName = this.constructor.DEFAULT_ZOME_NAME;
|
|
32
|
+
}
|
|
33
|
+
get defaultZomeName() {
|
|
34
|
+
return this.constructor.DEFAULT_ZOME_NAME;
|
|
35
|
+
}
|
|
36
|
+
/** Tuple array with zome name */
|
|
37
|
+
get fnNames() {
|
|
38
|
+
const fnNames = this.constructor.FN_NAMES;
|
|
39
|
+
if (!fnNames) {
|
|
40
|
+
throw Error("FN_NAMES not defined in ZomeProxy subclass " + this.constructor.name);
|
|
41
|
+
}
|
|
42
|
+
return fnNames.map((fnName) => {
|
|
43
|
+
return [this.zomeName, fnName];
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
;
|
|
48
|
+
return AZomeSpecific;
|
|
49
|
+
}
|
|
50
|
+
export const ZomeSpecific = ZomeMixin(Empty);
|
|
37
51
|
//# sourceMappingURL=mixins.js.map
|
package/dist/mixins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixins.js","sourceRoot":"","sources":["../src/mixins.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mixins.js","sourceRoot":"","sources":["../src/mixins.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,kBAAkB,EAGnB,MAAM,mBAAmB,CAAC;AAO3B,MAAM,OAAO,KAAK;IAChB,YAAY,GAAG,IAAW,IAAG,CAAC;CAC/B;AAGD,mGAAmG;AAEnG;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAoC,IAAW;IACtE,MAAe,KAAM,SAAQ,IAAI;QAM/B,IAAI,IAAI,KAAW,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,MAAM,KAAK,CAAC,yBAAyB,CAAC,CAAE,CAAC,OAAO,IAAI,CAAC,KAAM,CAAA,CAAC,CAAC;QACjG,IAAI,MAAM,KAAa,OAAO,IAAI,CAAC,KAAM,CAAC,OAAO,CAAA,CAAC,CAAC;QACnD,IAAI,OAAO,KAAiB,OAAO,kBAAkB,CAAC,IAAI,CAAC,KAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC;QAC/E,IAAI,WAAW,KAAqB,OAAO,kBAAkB,CAAC,IAAI,CAAC,KAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC;KACxF;IAAA,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,+CAA+C;AAI/C,mGAAmG;AAEnG;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAoC,IAAW;IACtE,MAAe,aAAc,SAAQ,IAAI;QAOvC,YAAY,GAAG,IAAW;YACxB,KAAK,CAAC,IAAI,CAAC,CAAC;YACZ,IAAI,CAAC,QAAQ,GAAI,IAAI,CAAC,WAAoC,CAAC,iBAAiB,CAAA;QAC9E,CAAC;QAED,IAAI,eAAe;YACjB,OAAQ,IAAI,CAAC,WAAoC,CAAC,iBAAiB,CAAC;QACtE,CAAC;QAED,iCAAiC;QACjC,IAAI,OAAO;YACT,MAAM,OAAO,GAAI,IAAI,CAAC,WAAoC,CAAC,QAAQ,CAAC;YACpE,IAAI,CAAC,OAAO,EAAE;gBACZ,MAAM,KAAK,CAAC,6CAA6C,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;aACpF;YACD,OAAQ,OAA0B,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;gBAChD,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;YAChC,CAAC,CAAC,CAAA;QACJ,CAAC;KACF;IAAA,CAAC;IACF,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,32 +1,30 @@
|
|
|
1
|
-
import { CellId,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
export interface
|
|
8
|
-
get
|
|
9
|
-
get
|
|
10
|
-
get
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export declare function
|
|
31
|
-
/** */
|
|
32
|
-
export declare function str2CellId(str: CellIdStr): CellId;
|
|
1
|
+
import { CellId, AgentPubKeyB64, DnaHashB64, Cell } from "@holochain/client";
|
|
2
|
+
import { AgentPubKey, DnaHash } from "@holochain/client/lib/types";
|
|
3
|
+
import { Dictionary } from "./utils";
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export interface ICell {
|
|
8
|
+
get cell(): Cell;
|
|
9
|
+
get dnaHash(): DnaHashB64;
|
|
10
|
+
get agentPubKey(): AgentPubKeyB64;
|
|
11
|
+
}
|
|
12
|
+
export type BaseRoleName = string;
|
|
13
|
+
export type CloneIndex = number;
|
|
14
|
+
export type CellsForRole = {
|
|
15
|
+
provisioned: Cell;
|
|
16
|
+
/** CloneName -> Cell */
|
|
17
|
+
clones: Dictionary<Cell>;
|
|
18
|
+
};
|
|
19
|
+
/** BaseRoleName -> RoleCells */
|
|
20
|
+
export type RoleCellsMap = Dictionary<CellsForRole>;
|
|
21
|
+
/** -- RoleInstanceId -- */
|
|
22
|
+
/** type for string "<baseRoleName>.<cloneIndex>" */
|
|
23
|
+
export type CloneName = string;
|
|
24
|
+
export declare function createCloneName(baseRoleName: BaseRoleName, cloneIndex: CloneIndex): CloneName;
|
|
25
|
+
export declare function destructureCloneName(id: CloneName): [BaseRoleName, CloneIndex] | undefined;
|
|
26
|
+
/** -- CellIdStr -- */
|
|
27
|
+
export type CellIdStr = string;
|
|
28
|
+
export declare function CellIdStr(hash_or_id: DnaHash | CellId, key?: AgentPubKey): CellIdStr;
|
|
29
|
+
/** */
|
|
30
|
+
export declare function str2CellId(str: CellIdStr): CellId;
|
package/dist/types.js
CHANGED
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export function
|
|
3
|
-
if (!cloneIndex)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
1
|
+
import { decodeHashFromBase64, encodeHashToBase64 } from "@holochain/client";
|
|
2
|
+
export function createCloneName(baseRoleName, cloneIndex) {
|
|
3
|
+
//if (!cloneIndex) return baseRoleName as CloneName;
|
|
4
|
+
return "" + baseRoleName + "." + cloneIndex;
|
|
5
|
+
}
|
|
6
|
+
export function destructureCloneName(id) {
|
|
7
|
+
const subs = id.split(".");
|
|
8
|
+
if (subs.length != 2) {
|
|
9
|
+
//throw Error(`Bad RoleInstance id format: "${id}"`);
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
return [subs[0], Number(subs[1])];
|
|
13
|
+
}
|
|
14
|
+
const CELL_ID_SEPARATOR = "||";
|
|
15
|
+
export function CellIdStr(hash_or_id, key) {
|
|
16
|
+
if (Array.isArray(hash_or_id)) {
|
|
17
|
+
return "" + encodeHashToBase64(hash_or_id[0]) + CELL_ID_SEPARATOR + encodeHashToBase64(hash_or_id[1]);
|
|
18
|
+
}
|
|
19
|
+
if (!key) {
|
|
20
|
+
throw Error("CellIdStr() failed. AgentPubKey not provided");
|
|
21
|
+
}
|
|
22
|
+
return "" + encodeHashToBase64(hash_or_id) + CELL_ID_SEPARATOR + encodeHashToBase64(key);
|
|
23
|
+
}
|
|
24
|
+
/** */
|
|
25
|
+
export function str2CellId(str) {
|
|
26
|
+
const subs = str.split(CELL_ID_SEPARATOR);
|
|
27
|
+
if (subs.length != 2) {
|
|
28
|
+
throw Error("str2CellId() failed. Bad input string format");
|
|
29
|
+
}
|
|
30
|
+
return [decodeHashFromBase64(subs[0]), decodeHashFromBase64(subs[1])];
|
|
31
|
+
}
|
|
33
32
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EACpB,kBAAkB,EAInB,MAAM,mBAAmB,CAAC;AAuC3B,MAAM,UAAU,eAAe,CAAC,YAA0B,EAAE,UAAsB;IAChF,oDAAoD;IACpD,OAAO,EAAE,GAAG,YAAY,GAAG,GAAG,GAAG,UAAU,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,EAAa;IAChD,MAAM,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE;QACpB,qDAAqD;QACrD,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAe,CAAC,CAAC;AAClE,CAAC;AASD,MAAM,iBAAiB,GAAG,IAAI,CAAA;AAE9B,MAAM,UAAU,SAAS,CAAC,UAA4B,EAAE,GAAiB;IACvE,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC7B,OAAO,EAAE,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,iBAAiB,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;KACvG;IACD,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,KAAK,CAAC,8CAA8C,CAAC,CAAC;KAC7D;IACD,OAAO,EAAE,GAAG,kBAAkB,CAAC,UAAU,CAAC,GAAG,iBAAiB,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAC3F,CAAC;AAED,MAAM;AACN,MAAM,UAAU,UAAU,CAAC,GAAc;IACvC,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC1C,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE;QACpB,MAAM,KAAK,CAAC,8CAA8C,CAAC,CAAC;KAC7D;IACD,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACvE,CAAC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,30 +1,37 @@
|
|
|
1
|
-
import { CellId,
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export declare function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
export declare
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import { CellId, AppInfo, CellInfo, Cell } from "@holochain/client";
|
|
2
|
+
import { StemCell } from "@holochain/client/lib/api/admin/types";
|
|
3
|
+
export declare type Dictionary<T> = {
|
|
4
|
+
[key: string]: T;
|
|
5
|
+
};
|
|
6
|
+
/** */
|
|
7
|
+
export declare function areArraysEqual(first: Uint8Array, second: Uint8Array): boolean;
|
|
8
|
+
/** */
|
|
9
|
+
export declare function areCellsEqual(cellA: CellId, cellB: CellId): boolean;
|
|
10
|
+
/** */
|
|
11
|
+
export declare const delay: (ms: number) => Promise<unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Checks if obj is a Hash or list of hashes and tries to convert it a B64 or list of B64
|
|
14
|
+
*/
|
|
15
|
+
export declare function anyToB64(obj: any): any;
|
|
16
|
+
export declare function prettyDuration(date: Date): string;
|
|
17
|
+
/** */
|
|
18
|
+
export declare function prettyDate(date: Date): string;
|
|
19
|
+
/** ... */
|
|
20
|
+
export declare function intoStem(cellInfo: CellInfo): StemCell | undefined;
|
|
21
|
+
/** ... */
|
|
22
|
+
export declare function intoCell(cellInfo: CellInfo): Cell | undefined;
|
|
23
|
+
/** */
|
|
24
|
+
export declare function printAppInfo(appInfo: AppInfo): string;
|
|
25
|
+
/** */
|
|
26
|
+
export declare function printCell(cell: Cell): string;
|
|
27
|
+
/** -- Experimental -- */
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
export declare class Queue<T> {
|
|
32
|
+
private _store;
|
|
33
|
+
get length(): number;
|
|
34
|
+
push(val: T): void;
|
|
35
|
+
pop(): T | undefined;
|
|
36
|
+
isEmpty(): boolean;
|
|
37
|
+
}
|
package/dist/utils.js
CHANGED
|
@@ -1,81 +1,109 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
/** */
|
|
4
|
-
export function areArraysEqual(first, second) {
|
|
5
|
-
return first.length === second.length && first.every((value, index) => value === second[index]);
|
|
6
|
-
}
|
|
7
|
-
/** */
|
|
8
|
-
export function areCellsEqual(cellA, cellB) {
|
|
9
|
-
return areArraysEqual(cellA[0], cellB[0]) && areArraysEqual(cellA[1], cellB[1]);
|
|
10
|
-
}
|
|
11
|
-
/** */
|
|
12
|
-
export const delay = (ms) => new Promise(r => setTimeout(r, ms));
|
|
13
|
-
/**
|
|
14
|
-
* Checks if obj is a Hash or list of hashes and tries to convert it a B64 or list of B64
|
|
15
|
-
*/
|
|
16
|
-
export function anyToB64(obj) {
|
|
17
|
-
/** Check if it's a hash */
|
|
18
|
-
if (obj instanceof Uint8Array) {
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
/** Check if
|
|
23
|
-
if (Array.isArray(obj)) {
|
|
24
|
-
const isUint8Array = obj.length > 0 &&
|
|
25
|
-
obj.every((value) => {
|
|
26
|
-
return value instanceof Uint8Array;
|
|
27
|
-
});
|
|
28
|
-
if (isUint8Array) {
|
|
29
|
-
let result = [];
|
|
30
|
-
for (const cur of obj) {
|
|
31
|
-
result.push(
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return obj;
|
|
38
|
-
}
|
|
39
|
-
/** -- Pretty print -- */
|
|
40
|
-
const zeroPad = (num, places) => String(num).padStart(places, '0');
|
|
41
|
-
export function prettyDuration(date) {
|
|
42
|
-
return date.getSeconds() + "." + zeroPad(date.getMilliseconds(), 3);
|
|
43
|
-
}
|
|
44
|
-
/** */
|
|
45
|
-
export function prettyDate(date) {
|
|
46
|
-
return ""
|
|
47
|
-
+ zeroPad(date.getHours(), 2)
|
|
48
|
-
+ ":" + zeroPad(date.getMinutes(), 2)
|
|
49
|
-
+ ":" + zeroPad(date.getSeconds(), 2)
|
|
50
|
-
+ "." + zeroPad(date.getMilliseconds(), 3);
|
|
51
|
-
}
|
|
52
|
-
/** */
|
|
53
|
-
export function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
1
|
+
import { encodeHashToBase64 } from "@holochain/client";
|
|
2
|
+
import { CellType } from "@holochain/client";
|
|
3
|
+
/** */
|
|
4
|
+
export function areArraysEqual(first, second) {
|
|
5
|
+
return first.length === second.length && first.every((value, index) => value === second[index]);
|
|
6
|
+
}
|
|
7
|
+
/** */
|
|
8
|
+
export function areCellsEqual(cellA, cellB) {
|
|
9
|
+
return areArraysEqual(cellA[0], cellB[0]) && areArraysEqual(cellA[1], cellB[1]);
|
|
10
|
+
}
|
|
11
|
+
/** */
|
|
12
|
+
export const delay = (ms) => new Promise(r => setTimeout(r, ms));
|
|
13
|
+
/**
|
|
14
|
+
* Checks if obj is a Hash or list of hashes and tries to convert it a B64 or list of B64
|
|
15
|
+
*/
|
|
16
|
+
export function anyToB64(obj) {
|
|
17
|
+
/** Check if it's a hash */
|
|
18
|
+
if (obj instanceof Uint8Array) {
|
|
19
|
+
return encodeHashToBase64(obj);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
/** Check if it's an array of hashes */
|
|
23
|
+
if (Array.isArray(obj)) {
|
|
24
|
+
const isUint8Array = obj.length > 0 &&
|
|
25
|
+
obj.every((value) => {
|
|
26
|
+
return value instanceof Uint8Array;
|
|
27
|
+
});
|
|
28
|
+
if (isUint8Array) {
|
|
29
|
+
let result = [];
|
|
30
|
+
for (const cur of obj) {
|
|
31
|
+
result.push(encodeHashToBase64(cur));
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return obj;
|
|
38
|
+
}
|
|
39
|
+
/** -- Pretty print -- */
|
|
40
|
+
const zeroPad = (num, places) => String(num).padStart(places, '0');
|
|
41
|
+
export function prettyDuration(date) {
|
|
42
|
+
return date.getSeconds() + "." + zeroPad(date.getMilliseconds(), 3);
|
|
43
|
+
}
|
|
44
|
+
/** */
|
|
45
|
+
export function prettyDate(date) {
|
|
46
|
+
return ""
|
|
47
|
+
+ zeroPad(date.getHours(), 2)
|
|
48
|
+
+ ":" + zeroPad(date.getMinutes(), 2)
|
|
49
|
+
+ ":" + zeroPad(date.getSeconds(), 2)
|
|
50
|
+
+ "." + zeroPad(date.getMilliseconds(), 3);
|
|
51
|
+
}
|
|
52
|
+
/** ... */
|
|
53
|
+
export function intoStem(cellInfo) {
|
|
54
|
+
if (CellType.Stem in cellInfo) {
|
|
55
|
+
return cellInfo.Stem;
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
/** ... */
|
|
60
|
+
export function intoCell(cellInfo) {
|
|
61
|
+
if (CellType.Stem in cellInfo) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
if (CellType.Cloned in cellInfo) {
|
|
65
|
+
return cellInfo.Cloned;
|
|
66
|
+
}
|
|
67
|
+
if (CellType.Provisioned in cellInfo) {
|
|
68
|
+
return cellInfo.Provisioned;
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
/** */
|
|
73
|
+
export function printAppInfo(appInfo) {
|
|
74
|
+
let print = `Happ "${appInfo.installed_app_id}" info: (status: ${JSON.stringify(appInfo.status)})`;
|
|
75
|
+
for (const [roleName, cellInfos] of Object.entries(appInfo.cell_info)) {
|
|
76
|
+
for (const cellInfo of Object.values(cellInfos)) {
|
|
77
|
+
if (CellType.Stem in cellInfo) {
|
|
78
|
+
const stem = intoStem(cellInfo);
|
|
79
|
+
print += `\n - ${roleName}.${stem.name ? stem.name : "unnamed"} : ${encodeHashToBase64(stem.dna)} (stem)`;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const cell = intoCell(cellInfo);
|
|
83
|
+
print += `\n - ${roleName}.${cell.name}${cell.name ? "." + cell.name : ""} : ${encodeHashToBase64(cell.cell_id[0])}`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return print;
|
|
87
|
+
}
|
|
88
|
+
/** */
|
|
89
|
+
export function printCell(cell) {
|
|
90
|
+
return `Cell "${cell.name}${cell.clone_id ? "." + cell.clone_id : ""}": ${encodeHashToBase64(cell.cell_id[0])}`;
|
|
91
|
+
}
|
|
92
|
+
/** -- Experimental -- */
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
export class Queue {
|
|
97
|
+
constructor() {
|
|
98
|
+
this._store = [];
|
|
99
|
+
}
|
|
100
|
+
get length() { return this._store.length; }
|
|
101
|
+
push(val) {
|
|
102
|
+
this._store.push(val);
|
|
103
|
+
}
|
|
104
|
+
pop() {
|
|
105
|
+
return this._store.shift();
|
|
106
|
+
}
|
|
107
|
+
isEmpty() { return this._store.length == 0; }
|
|
108
|
+
}
|
|
81
109
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAEtF,OAAO,EAAC,QAAQ,EAAe,MAAM,mBAAmB,CAAC;AAQzD,MAAM;AACN,MAAM,UAAU,cAAc,CAAC,KAAiB,EAAE,MAAkB;IAClE,OAAO,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;AACjG,CAAC;AAED,MAAM;AACN,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,KAAa;IACxD,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AACjF,CAAC;AAED,OAAO;AACP,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;AAGxE;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAQ;IAC/B,2BAA2B;IAC3B,IAAI,GAAG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C,QAAQ,CAAE,CAAC;YACjC,KAAK,IAAI,QAAQ,QAAQ,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA,CAAC,CAAC,GAAG,GAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACnH;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAGD,MAAM;AACN,MAAM,UAAU,SAAS,CAAC,IAAU;IAClC,OAAO,SAAS,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAA,CAAC,CAAC,GAAG,GAAE,IAAI,CAAC,QAAQ,CAAA,CAAC,CAAC,EAAE,MAAM,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/G,CAAC;AAGD,yBAAyB;AAEzB;;GAEG;AACH,MAAM,OAAO,KAAK;IAAlB;QACU,WAAM,GAAQ,EAAE,CAAC;IAY3B,CAAC;IAVC,IAAI,MAAM,KAAY,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA,CAAA,CAAC;IAEhD,IAAI,CAAC,GAAM;QACT,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IACD,GAAG;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,KAAc,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAA,CAAA,CAAC;CACrD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-qc/cell-proxy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Proxy classes and helpers for managing a Holochain AppWebsocket",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -14,21 +14,19 @@
|
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/ddd-mtl/
|
|
17
|
+
"url": "git+https://github.com/ddd-mtl/lit-happ.git"
|
|
18
18
|
},
|
|
19
19
|
"author": "",
|
|
20
20
|
"license": "CAL-1.0",
|
|
21
21
|
"bugs": {
|
|
22
|
-
"url": "https://github.com/ddd-mtl/
|
|
22
|
+
"url": "https://github.com/ddd-mtl/lit-happ/issues"
|
|
23
23
|
},
|
|
24
|
-
"homepage": "https://github.com/ddd-mtl/
|
|
24
|
+
"homepage": "https://github.com/ddd-mtl/lit-happ#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@holochain
|
|
27
|
-
"@holochain-open-dev/utils": "0.4.0",
|
|
28
|
-
"@holochain/client": "^0.9.3"
|
|
26
|
+
"@holochain/client": "^0.11.8"
|
|
29
27
|
},
|
|
30
28
|
"devDependencies": {
|
|
31
|
-
"tslib": "^2.
|
|
32
|
-
"typescript": "^4.
|
|
29
|
+
"tslib": "^2.4.0",
|
|
30
|
+
"typescript": "^4.9.0"
|
|
33
31
|
}
|
|
34
32
|
}
|