@ddd-qc/cell-proxy 0.25.0 → 0.25.1
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/dist/AppProxy.d.ts +4 -3
- package/dist/AppProxy.js +8 -6
- package/dist/AppProxy.js.map +1 -1
- package/dist/CellProxy.js +3 -3
- package/dist/CellProxy.js.map +1 -1
- package/dist/ConductorAppProxy.js +12 -8
- package/dist/ConductorAppProxy.js.map +1 -1
- package/dist/ExternalAppProxy.js.map +1 -1
- package/dist/ZomeProxy.d.ts +1 -1
- package/dist/ZomeProxy.js.map +1 -1
- package/dist/cell.d.ts +4 -3
- package/dist/cell.js +6 -5
- package/dist/cell.js.map +1 -1
- package/dist/datum-map.d.ts +35 -0
- package/dist/datum-map.js +77 -0
- package/dist/datum-map.js.map +1 -0
- package/dist/hash.d.ts +129 -0
- package/dist/hash.js +246 -0
- package/dist/hash.js.map +1 -0
- package/dist/holochain-id-map.d.ts +32 -0
- package/dist/holochain-id-map.js +74 -0
- package/dist/holochain-id-map.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/mixins.d.ts +4 -0
- package/dist/mixins.js.map +1 -1
- package/dist/pretty.d.ts +17 -0
- package/dist/pretty.js +57 -0
- package/dist/pretty.js.map +1 -0
- package/dist/types.d.ts +6 -38
- package/dist/types.js +11 -6
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +2 -20
- package/dist/utils.js +6 -80
- package/dist/utils.js.map +1 -1
- package/dist/zomeSignals.types.d.ts +114 -0
- package/dist/zomeSignals.types.js +26 -0
- package/dist/zomeSignals.types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ActionId, AgentId, DnaId, EntryId } from "./hash";
|
|
2
|
+
export class HolochainIdMap {
|
|
3
|
+
constructor(_ctor, initialEntries) {
|
|
4
|
+
this._ctor = _ctor;
|
|
5
|
+
this._map = new Map();
|
|
6
|
+
if (initialEntries) {
|
|
7
|
+
for (const [key, value] of initialEntries) {
|
|
8
|
+
this.set(key, value);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
has(key) {
|
|
13
|
+
return this._map.has(key.b64);
|
|
14
|
+
}
|
|
15
|
+
get(key) {
|
|
16
|
+
return this._map.get(key.b64);
|
|
17
|
+
}
|
|
18
|
+
set(key, value) {
|
|
19
|
+
this._map.set(key.b64, value);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
delete(key) {
|
|
23
|
+
return this._map.delete(key.b64);
|
|
24
|
+
}
|
|
25
|
+
values() {
|
|
26
|
+
return this._map.values();
|
|
27
|
+
}
|
|
28
|
+
keys() {
|
|
29
|
+
return Array.from(this._map.keys())
|
|
30
|
+
.map((h) => new this._ctor(h))[Symbol.iterator]();
|
|
31
|
+
}
|
|
32
|
+
entries() {
|
|
33
|
+
return Array.from(this._map.entries())
|
|
34
|
+
.map(([h, v]) => [new this._ctor(h), v])[Symbol.iterator]();
|
|
35
|
+
}
|
|
36
|
+
clear() {
|
|
37
|
+
return this._map.clear();
|
|
38
|
+
}
|
|
39
|
+
forEach(callbackfn, thisArg) {
|
|
40
|
+
return this._map.forEach((value, key) => {
|
|
41
|
+
callbackfn(value, new this._ctor(key), this);
|
|
42
|
+
}, thisArg);
|
|
43
|
+
}
|
|
44
|
+
get size() {
|
|
45
|
+
return this._map.size;
|
|
46
|
+
}
|
|
47
|
+
[Symbol.iterator]() {
|
|
48
|
+
return this.entries();
|
|
49
|
+
}
|
|
50
|
+
get [Symbol.toStringTag]() {
|
|
51
|
+
return this._map[Symbol.toStringTag];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export class ActionIdMap extends HolochainIdMap {
|
|
55
|
+
constructor(initialEntries) {
|
|
56
|
+
super(ActionId, initialEntries);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export class AgentIdMap extends HolochainIdMap {
|
|
60
|
+
constructor(initialEntries) {
|
|
61
|
+
super(AgentId, initialEntries);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export class DnaIdMap extends HolochainIdMap {
|
|
65
|
+
constructor(initialEntries) {
|
|
66
|
+
super(DnaId, initialEntries);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export class EntryIdMap extends HolochainIdMap {
|
|
70
|
+
constructor(initialEntries) {
|
|
71
|
+
super(EntryId, initialEntries);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=holochain-id-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"holochain-id-map.js","sourceRoot":"","sources":["../src/holochain-id-map.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAc,MAAM,QAAQ,CAAC;AAItE,MAAM,OAAO,cAAc;IAGzB,YAAoB,KAAsB,EAAE,cAA8B;QAAtD,UAAK,GAAL,KAAK,CAAiB;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,IAAI,cAAc,EAAE;YAClB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,cAAc,EAAE;gBACzC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aACtB;SACF;IACH,CAAC;IAED,GAAG,CAAC,GAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,GAAG,CAAC,GAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,GAAG,CAAC,GAAM,EAAE,KAAQ;QAClB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC9B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AE,CAAC;IACxB,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;CACF;AAID,MAAM,OAAO,WAAe,SAAQ,cAA2B;IAC7D,YAAY,cAAqC;QAC/C,KAAK,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAA;IACjC,CAAC;CACF;AAED,MAAM,OAAO,UAAc,SAAQ,cAA0B;IAC3D,YAAY,cAAoC;QAC9C,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;IAChC,CAAC;CACF;AAED,MAAM,OAAO,QAAY,SAAQ,cAAwB;IACvD,YAAY,cAAkC;QAC5C,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,CAAA;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,UAAc,SAAQ,cAA0B;IAC3D,YAAY,cAAoC;QAC9C,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;IAChC,CAAC;CACF","sourcesContent":["import {\n HoloHashB64,\n} from \"@holochain/client\";\nimport {ActionId, AgentId, DnaId, EntryId, HolochainId} from \"./hash\";\nimport {GConstructor} from \"./mixins\";\n\n\nexport class HolochainIdMap<K extends HolochainId, V> implements Map<K, V> {\n _map: Map<HoloHashB64, V>;\n\n constructor(private _ctor: GConstructor<K>, initialEntries?: Array<[K, V]>) {\n this._map = new Map();\n if (initialEntries) {\n for (const [key, value] of initialEntries) {\n this.set(key, value);\n }\n }\n }\n\n has(key: K) {\n return this._map.has(key.b64);\n }\n\n get(key: K): V {\n return this._map.get(key.b64);\n }\n\n set(key: K, value: V) {\n this._map.set(key.b64, value);\n return this;\n }\n\n delete(key: K) {\n return this._map.delete(key.b64);\n }\n\n values() {\n return this._map.values();\n }\n\n keys() {\n return Array.from(this._map.keys())\n .map((h) => new this._ctor(h))\n [Symbol.iterator]();\n }\n\n entries() {\n return Array.from(this._map.entries())\n .map(([h, v]) => [new this._ctor(h), v] as [K, V])\n [Symbol.iterator]();\n }\n\n clear() {\n return this._map.clear();\n }\n\n forEach(\n callbackfn: (value: V, key: K, map: Map<K, V>) => void,\n thisArg?: any\n ): void {\n return this._map.forEach((value, key) => {\n callbackfn(value, new this._ctor(key), this);\n }, thisArg);\n }\n\n get size() {\n return this._map.size;\n }\n\n [Symbol.iterator](): IterableIterator<[K, V]> {\n return this.entries();\n }\n\n get [Symbol.toStringTag](): string {\n return this._map[Symbol.toStringTag];\n }\n}\n\n\n\nexport class ActionIdMap<T> extends HolochainIdMap<ActionId, T> {\n constructor(initialEntries?: Array<[ActionId, T]>) {\n super(ActionId, initialEntries)\n }\n}\n\nexport class AgentIdMap<T> extends HolochainIdMap<AgentId, T> {\n constructor(initialEntries?: Array<[AgentId, T]>) {\n super(AgentId, initialEntries)\n }\n}\n\nexport class DnaIdMap<T> extends HolochainIdMap<DnaId, T> {\n constructor(initialEntries?: Array<[DnaId, T]>) {\n super(DnaId, initialEntries)\n }\n}\n\nexport class EntryIdMap<T> extends HolochainIdMap<EntryId, T> {\n constructor(initialEntries?: Array<[EntryId, T]>) {\n super(EntryId, initialEntries)\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,4 +8,8 @@ export * from "./types";
|
|
|
8
8
|
export * from "./hcl";
|
|
9
9
|
export * from "./mixins";
|
|
10
10
|
export * from "./cell";
|
|
11
|
+
export * from "./pretty";
|
|
12
|
+
export * from "./hash";
|
|
13
|
+
export * from "./holochain-id-map";
|
|
14
|
+
export * from "./zomeSignals.types";
|
|
11
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC","sourcesContent":["export * from \"./AppProxy\";\nexport * from \"./ConductorAppProxy\";\nexport * from \"./ExternalAppProxy\";\nexport * from \"./CellProxy\";\nexport * from \"./ZomeProxy\";\nexport * from \"./utils\";\nexport * from \"./types\";\nexport * from \"./hcl\";\nexport * from \"./mixins\";\nexport * from \"./cell\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC","sourcesContent":["export * from \"./AppProxy\";\nexport * from \"./ConductorAppProxy\";\nexport * from \"./ExternalAppProxy\";\nexport * from \"./CellProxy\";\nexport * from \"./ZomeProxy\";\nexport * from \"./utils\";\nexport * from \"./types\";\nexport * from \"./hcl\";\nexport * from \"./mixins\";\nexport * from \"./cell\";\nexport * from \"./pretty\";\nexport * from \"./hash\";\nexport * from \"./holochain-id-map\";\nexport * from \"./zomeSignals.types\";\n"]}
|
package/dist/mixins.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { FunctionName, ZomeName } from "@holochain/client";
|
|
2
2
|
import { Cell } from "./cell";
|
|
3
|
+
export type Constructor<T> = {
|
|
4
|
+
new (): T;
|
|
5
|
+
};
|
|
6
|
+
export type GConstructor<T = {}> = new (...args: any[]) => T;
|
|
3
7
|
export type AbstractConstructor<T = {}> = abstract new (...args: any[]) => T;
|
|
4
8
|
export declare class Empty {
|
|
5
9
|
constructor(...args: any[]);
|
package/dist/mixins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixins.js","sourceRoot":"","sources":["../src/mixins.ts"],"names":[],"mappings":"AAWA,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,+BAA+B,CAAC,CAAE,CAAC,OAAO,IAAI,CAAC,KAAM,CAAA,CAAC,CAAC;KAExG;IAED,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;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC","sourcesContent":["import {\n FunctionName,\n ZomeName\n} from \"@holochain/client\";\nimport {Cell} from \"./cell\";\n\
|
|
1
|
+
{"version":3,"file":"mixins.js","sourceRoot":"","sources":["../src/mixins.ts"],"names":[],"mappings":"AAWA,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,+BAA+B,CAAC,CAAE,CAAC,OAAO,IAAI,CAAC,KAAM,CAAA,CAAC,CAAC;KAExG;IAED,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;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC","sourcesContent":["import {\n FunctionName,\n ZomeName\n} from \"@holochain/client\";\nimport {Cell} from \"./cell\";\n\nexport type Constructor<T> = {new (): T};\nexport type GConstructor<T = {}> = new (...args: any[]) => T;\nexport type AbstractConstructor<T = {}> = abstract new (...args: any[]) => T\n\n\nexport class Empty {\n constructor(...args: any[]) {}\n}\n\n\n/** ------------------------------------------------------------------------------------------- **/\n\n/**\n * Mixin for Cell bound classes.\n * A Cell bound class must have a \"Provisioned\" or \"Cloned\" cell from @holochain/client\n */\nexport function CellMixin<TBase extends AbstractConstructor>(Base: TBase) {\n abstract class ACell extends Base {\n // constructor(...args: any[]){\n // super(args);\n // }\n _cell?: Cell;\n\n get cell(): Cell { if (!this._cell) throw Error(\"Cell field not set for object\") ; return this._cell! }\n\n }\n\n return ACell;\n}\n\n//export const CellSpecific = CellMixin(Empty);\n\n\n\n/** ------------------------------------------------------------------------------------------- **/\n\n/**\n * Mixin for Zome bound classes.\n * A Zome bound class must have a zome name and a list of zome functions\n */\nexport function ZomeMixin<TBase extends AbstractConstructor>(Base: TBase) {\n abstract class AZomeSpecific extends Base {\n\n static readonly DEFAULT_ZOME_NAME: ZomeName;\n zomeName: ZomeName;\n\n static readonly FN_NAMES: FunctionName[];\n\n constructor(...args: any[]){\n super(args);\n this.zomeName = (this.constructor as typeof AZomeSpecific).DEFAULT_ZOME_NAME\n }\n\n get defaultZomeName(): ZomeName {\n return (this.constructor as typeof AZomeSpecific).DEFAULT_ZOME_NAME;\n }\n\n /** Tuple array with zome name */\n get fnNames(): [ZomeName, FunctionName][] {\n const fnNames = (this.constructor as typeof AZomeSpecific).FN_NAMES;\n if (!fnNames) {\n throw Error(\"FN_NAMES not defined in ZomeProxy subclass \" + this.constructor.name);\n }\n return (fnNames as FunctionName[]).map((fnName) => {\n return [this.zomeName, fnName]\n })\n }\n }\n\n return AZomeSpecific;\n}\n\nexport const ZomeSpecific = ZomeMixin(Empty);\n"]}
|
package/dist/pretty.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SignalLog } from "./AppProxy";
|
|
2
|
+
import { AppInfo } from "@holochain/client";
|
|
3
|
+
import { BaseRoleName, CellsForRole } from "./types";
|
|
4
|
+
export declare function prettyDuration(date: Date): string;
|
|
5
|
+
/** */
|
|
6
|
+
export declare function prettyDate(date: Date): string;
|
|
7
|
+
export declare function prettySignalLogs(signalLogs: SignalLog[]): {
|
|
8
|
+
timestamp: string;
|
|
9
|
+
dnaHash: string;
|
|
10
|
+
zome: string;
|
|
11
|
+
type: string;
|
|
12
|
+
payload: import("./zomeSignals.types").ZomeSignal;
|
|
13
|
+
}[];
|
|
14
|
+
/** */
|
|
15
|
+
export declare function printAppInfo(appInfo: AppInfo): string;
|
|
16
|
+
/** */
|
|
17
|
+
export declare function printCellsForRole(baseRoleName: BaseRoleName, cells: CellsForRole): string;
|
package/dist/pretty.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CellType } from "@holochain/client";
|
|
2
|
+
import { str2CellId } from "./types";
|
|
3
|
+
import { intoStem } from "./cell";
|
|
4
|
+
import { enc64 } from "./hash";
|
|
5
|
+
const zeroPad = (num, places) => String(num).padStart(places, '0');
|
|
6
|
+
export function prettyDuration(date) {
|
|
7
|
+
return date.getSeconds() + "." + zeroPad(date.getMilliseconds(), 3);
|
|
8
|
+
}
|
|
9
|
+
/** */
|
|
10
|
+
export function prettyDate(date) {
|
|
11
|
+
return ""
|
|
12
|
+
+ zeroPad(date.getHours(), 2)
|
|
13
|
+
+ ":" + zeroPad(date.getMinutes(), 2)
|
|
14
|
+
+ ":" + zeroPad(date.getSeconds(), 2)
|
|
15
|
+
+ "." + zeroPad(date.getMilliseconds(), 3);
|
|
16
|
+
}
|
|
17
|
+
export function prettySignalLogs(signalLogs) {
|
|
18
|
+
return signalLogs.map((log) => {
|
|
19
|
+
const dnaHash = enc64(str2CellId(log.cellId)[0]).slice(-8);
|
|
20
|
+
return { timestamp: prettyDate(new Date(log.ts)), dnaHash, zome: log.zomeName, type: log.type, payload: log.zomeSignal };
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** */
|
|
24
|
+
export function printAppInfo(appInfo) {
|
|
25
|
+
let print = `Happ "${appInfo.installed_app_id}" info: (status: ${JSON.stringify(appInfo.status)})`;
|
|
26
|
+
for (const [roleName, cellInfos] of Object.entries(appInfo.cell_info)) {
|
|
27
|
+
for (const cellInfo of Object.values(cellInfos)) {
|
|
28
|
+
if (CellType.Stem in cellInfo) {
|
|
29
|
+
const stem = intoStem(cellInfo);
|
|
30
|
+
print += `\n - ${roleName}.${stem.name ? stem.name : "unnamed"}: ${enc64(stem.dna)} (stem)`;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (CellType.Provisioned in cellInfo) {
|
|
34
|
+
const cell = cellInfo.provisioned;
|
|
35
|
+
print += `\n - ${roleName}: ${cell.name} | ${enc64(cell.cell_id[0])}`;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (CellType.Cloned in cellInfo) {
|
|
39
|
+
const cell = cellInfo.cloned;
|
|
40
|
+
print += `\n - ${roleName}.${cell.clone_id}: ${cell.name} | ${enc64(cell.cell_id[0])}`;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return print;
|
|
46
|
+
}
|
|
47
|
+
/** */
|
|
48
|
+
export function printCellsForRole(baseRoleName, cells) {
|
|
49
|
+
let print = `CellsForRole "${baseRoleName}": (${enc64(cells.provisioned.cell_id[1])})\n`;
|
|
50
|
+
print += ` - Provisioned: ${cells.provisioned.name} | ${enc64(cells.provisioned.cell_id[0])}\n`;
|
|
51
|
+
print += ` - Clones : ${Object.values(cells.clones).length}\n`;
|
|
52
|
+
for (const [cloneId, clone] of Object.entries(cells.clones)) {
|
|
53
|
+
print += ` - (${clone.enabled ? "enabled" : "disabled"})${cloneId}: ${clone.name} | ${enc64(clone.cell_id[0])}\n`;
|
|
54
|
+
}
|
|
55
|
+
return print;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=pretty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pretty.js","sourceRoot":"","sources":["../src/pretty.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAA6B,UAAU,EAAC,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAC,KAAK,EAAC,MAAM,QAAQ,CAAC;AAG7B,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAElF,MAAM,UAAU,cAAc,CAAC,IAAU;IACvC,OAAO,IAAI,CAAC,UAAU,EAAE,GAAG,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,CAAA;AACrE,CAAC;AAED,MAAM;AACN,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO,EAAE;UACL,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;UAC3B,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;UACnC,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;UACnC,GAAG,GAAG,OAAO,CAAC,IA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,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KACrH;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["\r\nimport {SignalLog} from \"./AppProxy\";\r\nimport {AppInfo, CellType} from \"@holochain/client\";\r\nimport {BaseRoleName, CellsForRole, str2CellId} from \"./types\";\r\nimport {intoStem} from \"./cell\";\r\nimport {enc64} from \"./hash\";\r\n\r\n\r\nconst zeroPad = (num: number, places: number) => String(num).padStart(places, '0')\r\n\r\nexport function prettyDuration(date: Date): string {\r\n return date.getSeconds() + \".\" + zeroPad(date.getMilliseconds(), 3)\r\n}\r\n\r\n/** */\r\nexport function prettyDate(date: Date): string {\r\n return \"\"\r\n + zeroPad(date.getHours(), 2)\r\n + \":\" + zeroPad(date.getMinutes(), 2)\r\n + \":\" + zeroPad(date.getSeconds(), 2)\r\n + \".\" + zeroPad(date.getMilliseconds(), 3);\r\n}\r\n\r\n\r\nexport function prettySignalLogs(signalLogs: SignalLog[]) {\r\n return signalLogs.map((log) => {\r\n const dnaHash = enc64(str2CellId(log.cellId)[0]).slice(-8);\r\n return {timestamp: prettyDate(new Date(log.ts)), dnaHash, zome: log.zomeName, type: log.type, payload: log.zomeSignal};\r\n })\r\n}\r\n\r\n\r\n/** */\r\nexport function printAppInfo(appInfo: AppInfo): string {\r\n let print = `Happ \"${appInfo.installed_app_id}\" info: (status: ${JSON.stringify(appInfo.status)})`;\r\n for (const [roleName, cellInfos] of Object.entries(appInfo.cell_info)) {\r\n for (const cellInfo of Object.values(cellInfos)) {\r\n if (CellType.Stem in cellInfo) {\r\n const stem = intoStem(cellInfo)!;\r\n print += `\\n - ${roleName}.${stem.name? stem.name : \"unnamed\"}: ${enc64(stem.dna)} (stem)`;\r\n continue;\r\n }\r\n if (CellType.Provisioned in cellInfo) {\r\n const cell = cellInfo.provisioned;\r\n print += `\\n - ${roleName}: ${cell.name} | ${enc64(cell.cell_id[0])}`;\r\n continue;\r\n }\r\n if (CellType.Cloned in cellInfo) {\r\n const cell = cellInfo.cloned;\r\n print += `\\n - ${roleName}.${cell.clone_id}: ${cell.name} | ${enc64(cell.cell_id[0])}`;\r\n continue;\r\n }\r\n }\r\n }\r\n return print;\r\n}\r\n\r\n\r\n/** */\r\nexport function printCellsForRole(baseRoleName: BaseRoleName, cells: CellsForRole): string {\r\n let print = `CellsForRole \"${baseRoleName}\": (${enc64(cells.provisioned.cell_id[1])})\\n`;\r\n print += ` - Provisioned: ${cells.provisioned.name} | ${enc64(cells.provisioned.cell_id[0])}\\n`;\r\n print += ` - Clones : ${Object.values(cells.clones).length}\\n`;\r\n for (const [cloneId, clone] of Object.entries(cells.clones)) {\r\n print += ` - (${clone.enabled? \"enabled\" : \"disabled\"})${cloneId}: ${clone.name} | ${enc64(clone.cell_id[0])}\\n`;\r\n }\r\n return print;\r\n}\r\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CellId, RoleName, ClonedCell, ProvisionedCell, ZomeName, FunctionName } from "@holochain/client";
|
|
2
|
-
import { AgentPubKey, DnaHash } from "@holochain/client/lib/types";
|
|
3
2
|
import { Dictionary } from "./utils";
|
|
3
|
+
import { AgentId, DnaId } from "./hash";
|
|
4
|
+
import { SystemSignalProtocol } from "./zomeSignals.types";
|
|
4
5
|
/** Signal types */
|
|
5
6
|
export declare enum SignalType {
|
|
6
7
|
Unknown = "Unknown",
|
|
@@ -10,41 +11,6 @@ export declare enum SignalType {
|
|
|
10
11
|
export type SystemPulse = {
|
|
11
12
|
System: SystemSignalProtocol;
|
|
12
13
|
};
|
|
13
|
-
export interface LitHappSignal {
|
|
14
|
-
from: AgentPubKey;
|
|
15
|
-
pulses: unknown[];
|
|
16
|
-
}
|
|
17
|
-
/** Protocol for notifying the ViewModel (UI) of system level events */
|
|
18
|
-
export type SystemSignalProtocolVariantPostCommitNewStart = {
|
|
19
|
-
type: "PostCommitNewStart";
|
|
20
|
-
app_entry_type: string;
|
|
21
|
-
};
|
|
22
|
-
export type SystemSignalProtocolVariantPostCommitNewEnd = {
|
|
23
|
-
type: "PostCommitNewEnd";
|
|
24
|
-
app_entry_type: string;
|
|
25
|
-
succeeded: boolean;
|
|
26
|
-
};
|
|
27
|
-
export type SystemSignalProtocolVariantPostCommitDeleteStart = {
|
|
28
|
-
type: "PostCommitDeleteStart";
|
|
29
|
-
app_entry_type: string;
|
|
30
|
-
};
|
|
31
|
-
export type SystemSignalProtocolVariantPostCommitDeleteEnd = {
|
|
32
|
-
type: "PostCommitDeleteEnd";
|
|
33
|
-
app_entry_type: string;
|
|
34
|
-
succeeded: boolean;
|
|
35
|
-
};
|
|
36
|
-
export type SystemSignalProtocolVariantSelfCallStart = {
|
|
37
|
-
type: "SelfCallStart";
|
|
38
|
-
zome_name: string;
|
|
39
|
-
fn_name: string;
|
|
40
|
-
};
|
|
41
|
-
export type SystemSignalProtocolVariantSelfCallEnd = {
|
|
42
|
-
type: "SelfCallEnd";
|
|
43
|
-
zome_name: string;
|
|
44
|
-
fn_name: string;
|
|
45
|
-
succeeded: boolean;
|
|
46
|
-
};
|
|
47
|
-
export type SystemSignalProtocol = SystemSignalProtocolVariantPostCommitNewStart | SystemSignalProtocolVariantPostCommitNewEnd | SystemSignalProtocolVariantPostCommitDeleteStart | SystemSignalProtocolVariantPostCommitDeleteEnd | SystemSignalProtocolVariantSelfCallStart | SystemSignalProtocolVariantSelfCallEnd;
|
|
48
14
|
/** ---- */
|
|
49
15
|
export type BaseRoleName = string;
|
|
50
16
|
export type CloneIndex = number;
|
|
@@ -68,7 +34,7 @@ export type ZomeInfo = {
|
|
|
68
34
|
};
|
|
69
35
|
export type DnaInfo = {
|
|
70
36
|
name: string;
|
|
71
|
-
|
|
37
|
+
id: DnaId;
|
|
72
38
|
properties: Uint8Array;
|
|
73
39
|
zome_names: ZomeName[];
|
|
74
40
|
};
|
|
@@ -88,8 +54,10 @@ export type CloneId = RoleName;
|
|
|
88
54
|
export declare function createCloneName(baseRoleName: BaseRoleName, cloneIndex: CloneIndex): string;
|
|
89
55
|
/** */
|
|
90
56
|
export declare function destructureCloneId(cloneId: CloneId): [BaseRoleName, CloneIndex] | undefined;
|
|
57
|
+
/** */
|
|
58
|
+
export declare function decomposeCellId(cellId: CellId): [DnaId, AgentId];
|
|
91
59
|
/** -- CellIdStr -- */
|
|
92
60
|
export type CellIdStr = string;
|
|
93
|
-
export declare function CellIdStr(
|
|
61
|
+
export declare function CellIdStr(dna_or_cell_id: DnaId | CellId, key?: AgentId): CellIdStr;
|
|
94
62
|
/** */
|
|
95
63
|
export declare function str2CellId(str: CellIdStr): CellId;
|
package/dist/types.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AgentId, dec64, DnaId, enc64 } from "./hash";
|
|
2
|
+
//import {AgentPubKey} from "@holochain/client/lib/types";
|
|
2
3
|
/** Signal types */
|
|
3
4
|
export var SignalType;
|
|
4
5
|
(function (SignalType) {
|
|
@@ -26,15 +27,19 @@ export function destructureCloneId(cloneId) {
|
|
|
26
27
|
}
|
|
27
28
|
return [subs[0], Number(subs[1])];
|
|
28
29
|
}
|
|
30
|
+
/** */
|
|
31
|
+
export function decomposeCellId(cellId) {
|
|
32
|
+
return [new DnaId(cellId[0]), new AgentId(cellId[1])];
|
|
33
|
+
}
|
|
29
34
|
const CELL_ID_SEPARATOR = "||";
|
|
30
|
-
export function CellIdStr(
|
|
31
|
-
if (Array.isArray(
|
|
32
|
-
return "" +
|
|
35
|
+
export function CellIdStr(dna_or_cell_id, key) {
|
|
36
|
+
if (Array.isArray(dna_or_cell_id)) {
|
|
37
|
+
return "" + enc64(dna_or_cell_id[0]) + CELL_ID_SEPARATOR + enc64(dna_or_cell_id[1]);
|
|
33
38
|
}
|
|
34
39
|
if (!key) {
|
|
35
40
|
throw Error("CellIdStr() failed. AgentPubKey not provided");
|
|
36
41
|
}
|
|
37
|
-
return "" +
|
|
42
|
+
return "" + dna_or_cell_id.b64 + CELL_ID_SEPARATOR + key.b64;
|
|
38
43
|
}
|
|
39
44
|
/** */
|
|
40
45
|
export function str2CellId(str) {
|
|
@@ -42,6 +47,6 @@ export function str2CellId(str) {
|
|
|
42
47
|
if (subs.length != 2) {
|
|
43
48
|
throw Error("str2CellId() failed. Bad input string format");
|
|
44
49
|
}
|
|
45
|
-
return [
|
|
50
|
+
return [dec64(subs[0]), dec64(subs[1])];
|
|
46
51
|
}
|
|
47
52
|
//# 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":"AAKA,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,QAAQ,CAAC;AAEpD,0DAA0D;AAG1D,mBAAmB;AAEnB,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,iCAAmB,CAAA;IACnB,6BAAe,CAAA;IACf,2BAAa,CAAA;AACf,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AAgGD,MAAM;AACN,MAAM,UAAU,YAAY,CAAC,KAAmB;IAC9C,IAAI,GAAG,GAAa,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1F,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC;AACb,CAAC;AAKD,oDAAoD;AACpD,MAAM,UAAU,eAAe,CAAC,YAA0B,EAAE,UAAsB;IAChF,oDAAoD;IACpD,OAAO,EAAE,GAAG,YAAY,GAAG,GAAG,GAAG,UAAU,CAAC;AAC9C,CAAC;AAED,MAAM;AAC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CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACzC,CAAC","sourcesContent":["import {\n CellId,\n RoleName, ClonedCell, ProvisionedCell, ZomeName, FunctionName,\n} from \"@holochain/client\";\nimport {Dictionary} from \"./utils\";\nimport {AgentId, dec64, DnaId, enc64} from \"./hash\";\nimport {SystemSignalProtocol} from \"./zomeSignals.types\";\n//import {AgentPubKey} from \"@holochain/client/lib/types\";\n\n\n/** Signal types */\n\nexport enum SignalType {\n Unknown = \"Unknown\",\n Empty = \"Empty\",\n Zome = \"Zome\",\n}\n\nexport type SystemPulse = {System: SystemSignalProtocol}\n\n//\n// //export type SignalPayload = unknown | LitHappSignal;\n\n// export interface LitHappSignal {\n// from: AgentPubKey,\n// pulses: unknown[],\n// }\n//\n// /** Protocol for notifying the ViewModel (UI) of system level events */\n// export type SystemSignalProtocolVariantPostCommitNewStart = {\n// type: \"PostCommitNewStart\"\n// app_entry_type: string\n// }\n// export type SystemSignalProtocolVariantPostCommitNewEnd = {\n// type: \"PostCommitNewEnd\"\n// app_entry_type: string\n// succeeded: boolean\n// }\n// export type SystemSignalProtocolVariantPostCommitDeleteStart = {\n// type: \"PostCommitDeleteStart\"\n// app_entry_type: string\n// }\n// export type SystemSignalProtocolVariantPostCommitDeleteEnd = {\n// type: \"PostCommitDeleteEnd\"\n// app_entry_type: string\n// succeeded: boolean\n// }\n// export type SystemSignalProtocolVariantSelfCallStart = {\n// type: \"SelfCallStart\"\n// zome_name: string\n// fn_name: string\n// }\n// export type SystemSignalProtocolVariantSelfCallEnd = {\n// type: \"SelfCallEnd\"\n// zome_name: string\n// fn_name: string\n// succeeded: boolean\n// }\n// export type SystemSignalProtocol =\n// | SystemSignalProtocolVariantPostCommitNewStart\n// | SystemSignalProtocolVariantPostCommitNewEnd\n// | SystemSignalProtocolVariantPostCommitDeleteStart\n// | SystemSignalProtocolVariantPostCommitDeleteEnd\n// | SystemSignalProtocolVariantSelfCallStart\n// | SystemSignalProtocolVariantSelfCallEnd;\n//\n\n/** ---- */\n\nexport type BaseRoleName = string;\nexport type CloneIndex = number;\n\nexport type ZomeIndex = number;\n\nexport type EntryDef = any; // FIXME\nexport type EntryDefsCallbackResult = {Defs: EntryDef[]}\n\nexport type ScopedZomeTypes = [ZomeIndex, number[]][];\n\nexport type ScopedZomeTypesSet = {\n entries: ScopedZomeTypes, // EntryDefIndex\n links: ScopedZomeTypes, // LinkType\n};\n\nexport type ZomeInfo = {\n name: ZomeName,\n id: ZomeIndex,\n properties: Uint8Array,\n entry_defs: EntryDef[],\n extern_fns: FunctionName[],\n zome_types: ScopedZomeTypesSet,\n}\n\n\nexport type DnaInfo = {\n name: string,\n id: DnaId,\n properties: Uint8Array,\n zome_names: ZomeName[],\n}\n\n/** */\nexport type CellsForRole = {\n //baseRoleName: BaseRoleName,\n provisioned: ProvisionedCell,\n /** CloneId -> Cell */\n clones: Dictionary<ClonedCell>,\n}\n\n/** BaseRoleName -> RoleCells */\nexport type RoleCellsMap = Dictionary<CellsForRole>;\n\n/** */\nexport function flattenCells(cells: CellsForRole): CellId[] {\n let res: CellId[] = Object.entries(cells.clones).map(([cloneId, clone]) => clone.cell_id);\n res.push(cells.provisioned.cell_id);\n return res;\n}\n\n\n/** -- CloneId -- */\nexport type CloneId = RoleName;\n/** type for string \"<baseRoleName>.<cloneIndex>\" */\nexport function createCloneName(baseRoleName: BaseRoleName, cloneIndex: CloneIndex): string {\n //if (!cloneIndex) return baseRoleName as CloneName;\n return \"\" + baseRoleName + \".\" + cloneIndex;\n}\n\n/** */\nexport function destructureCloneId(cloneId: CloneId): [BaseRoleName, CloneIndex] | undefined {\n const subs = cloneId.split(\".\");\n if (subs.length != 2) {\n //throw Error(`Bad RoleInstance id format: \"${id}\"`);\n return undefined;\n }\n return [subs[0] as BaseRoleName, Number(subs[1]) as CloneIndex];\n}\n\n\n/** */\nexport function decomposeCellId(cellId: CellId): [DnaId, AgentId] {\n return [new DnaId(cellId[0]), new AgentId(cellId[1])]\n}\n\n\n/** -- CellIdStr -- */\n\nexport type CellIdStr = string;\n\nconst CELL_ID_SEPARATOR = \"||\"\n\nexport function CellIdStr(dna_or_cell_id: DnaId | CellId, key?: AgentId): CellIdStr {\n if (Array.isArray(dna_or_cell_id)) {\n return \"\" + enc64(dna_or_cell_id[0]) + CELL_ID_SEPARATOR + enc64(dna_or_cell_id[1]);\n }\n if (!key) {\n throw Error(\"CellIdStr() failed. AgentPubKey not provided\");\n }\n return \"\" + dna_or_cell_id.b64 + CELL_ID_SEPARATOR + key.b64;\n}\n\n/** */\nexport function str2CellId(str: CellIdStr): CellId {\n const subs = str.split(CELL_ID_SEPARATOR);\n if (subs.length != 2) {\n throw Error(\"str2CellId() failed. Bad input string format\");\n }\n return [dec64(subs[0]), dec64(subs[1])]\n}\n"]}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { CellId
|
|
2
|
-
import { BaseRoleName, CellsForRole } from "./types";
|
|
3
|
-
import { SignalLog } from "./AppProxy";
|
|
1
|
+
import { CellId } from "@holochain/client";
|
|
4
2
|
export declare type Dictionary<T> = {
|
|
5
3
|
[key: string]: T;
|
|
6
4
|
};
|
|
@@ -14,21 +12,5 @@ export declare const delay: (ms: number) => Promise<unknown>;
|
|
|
14
12
|
export declare const snake: (str: any) => any;
|
|
15
13
|
/** convert snake case to pascal case */
|
|
16
14
|
export declare const pascal: (str: any) => any;
|
|
17
|
-
/**
|
|
18
|
-
* Checks if obj is a Hash or list of hashes and tries to convert it a B64 or list of B64
|
|
19
|
-
*/
|
|
20
|
-
export declare function anyToB64(obj: any): any;
|
|
21
|
-
export declare function prettyDuration(date: Date): string;
|
|
22
15
|
/** */
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function prettySignalLogs(signalLogs: SignalLog[]): {
|
|
25
|
-
timestamp: string;
|
|
26
|
-
dnaHash: string;
|
|
27
|
-
zome: string;
|
|
28
|
-
type: string;
|
|
29
|
-
payload: import("./types").LitHappSignal;
|
|
30
|
-
}[];
|
|
31
|
-
/** */
|
|
32
|
-
export declare function printAppInfo(appInfo: AppInfo): string;
|
|
33
|
-
/** */
|
|
34
|
-
export declare function printCellsForRole(baseRoleName: BaseRoleName, cells: CellsForRole): string;
|
|
16
|
+
export declare function getVariantByIndex(enumType: any, index: number): string;
|
package/dist/utils.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { encodeHashToBase64 } from "@holochain/client";
|
|
2
|
-
import { CellType } from "@holochain/client";
|
|
3
|
-
import { intoStem } from "./cell";
|
|
4
|
-
import { str2CellId } from "./types";
|
|
5
1
|
/** */
|
|
6
2
|
export function areArraysEqual(first, second) {
|
|
7
3
|
return first.length === second.length && first.every((value, index) => value === second[index]);
|
|
@@ -16,83 +12,13 @@ export const delay = (ms) => new Promise(r => setTimeout(r, ms));
|
|
|
16
12
|
export const snake = str => str[0].toLowerCase() + str.slice(1, str.length).replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);
|
|
17
13
|
/** convert snake case to pascal case */
|
|
18
14
|
export const pascal = str => str[0].toUpperCase() + str.slice(1, str.length).replace(/_([a-z])/g, letter => `${letter[1].toUpperCase()}`);
|
|
19
|
-
/**
|
|
20
|
-
* Checks if obj is a Hash or list of hashes and tries to convert it a B64 or list of B64
|
|
21
|
-
*/
|
|
22
|
-
export function anyToB64(obj) {
|
|
23
|
-
/** Check if it's a hash */
|
|
24
|
-
if (obj instanceof Uint8Array) {
|
|
25
|
-
return encodeHashToBase64(obj);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
/** Check if it's an array of hashes */
|
|
29
|
-
if (Array.isArray(obj)) {
|
|
30
|
-
const isUint8Array = obj.length > 0 &&
|
|
31
|
-
obj.every((value) => {
|
|
32
|
-
return value instanceof Uint8Array;
|
|
33
|
-
});
|
|
34
|
-
if (isUint8Array) {
|
|
35
|
-
let result = [];
|
|
36
|
-
for (const cur of obj) {
|
|
37
|
-
result.push(encodeHashToBase64(cur));
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return obj;
|
|
44
|
-
}
|
|
45
|
-
/** -- Pretty print -- */
|
|
46
|
-
const zeroPad = (num, places) => String(num).padStart(places, '0');
|
|
47
|
-
export function prettyDuration(date) {
|
|
48
|
-
return date.getSeconds() + "." + zeroPad(date.getMilliseconds(), 3);
|
|
49
|
-
}
|
|
50
|
-
/** */
|
|
51
|
-
export function prettyDate(date) {
|
|
52
|
-
return ""
|
|
53
|
-
+ zeroPad(date.getHours(), 2)
|
|
54
|
-
+ ":" + zeroPad(date.getMinutes(), 2)
|
|
55
|
-
+ ":" + zeroPad(date.getSeconds(), 2)
|
|
56
|
-
+ "." + zeroPad(date.getMilliseconds(), 3);
|
|
57
|
-
}
|
|
58
|
-
export function prettySignalLogs(signalLogs) {
|
|
59
|
-
return signalLogs.map((log) => {
|
|
60
|
-
const dnaHash = encodeHashToBase64(str2CellId(log.cellId)[0]).slice(-8);
|
|
61
|
-
return { timestamp: prettyDate(new Date(log.ts)), dnaHash, zome: log.zomeName, type: log.type, payload: log.zomeSignal };
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/** */
|
|
65
|
-
export function printAppInfo(appInfo) {
|
|
66
|
-
let print = `Happ "${appInfo.installed_app_id}" info: (status: ${JSON.stringify(appInfo.status)})`;
|
|
67
|
-
for (const [roleName, cellInfos] of Object.entries(appInfo.cell_info)) {
|
|
68
|
-
for (const cellInfo of Object.values(cellInfos)) {
|
|
69
|
-
if (CellType.Stem in cellInfo) {
|
|
70
|
-
const stem = intoStem(cellInfo);
|
|
71
|
-
print += `\n - ${roleName}.${stem.name ? stem.name : "unnamed"}: ${encodeHashToBase64(stem.dna)} (stem)`;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (CellType.Provisioned in cellInfo) {
|
|
75
|
-
const cell = cellInfo.provisioned;
|
|
76
|
-
print += `\n - ${roleName}: ${cell.name} | ${encodeHashToBase64(cell.cell_id[0])}`;
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (CellType.Cloned in cellInfo) {
|
|
80
|
-
const cell = cellInfo.cloned;
|
|
81
|
-
print += `\n - ${roleName}.${cell.clone_id}: ${cell.name} | ${encodeHashToBase64(cell.cell_id[0])}`;
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return print;
|
|
87
|
-
}
|
|
88
15
|
/** */
|
|
89
|
-
export function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
print += ` - (${clone.enabled ? "enabled" : "disabled"})${cloneId}: ${clone.name} | ${encodeHashToBase64(clone.cell_id[0])}\n`;
|
|
16
|
+
export function getVariantByIndex(enumType, index) {
|
|
17
|
+
const keys = Object.keys(enumType);
|
|
18
|
+
if (index >= 0 && index < keys.length) {
|
|
19
|
+
const key = keys[index];
|
|
20
|
+
return enumType[key];
|
|
95
21
|
}
|
|
96
|
-
|
|
22
|
+
throw Error("Out of bounds index");
|
|
97
23
|
}
|
|
98
24
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAOA,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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,CAAC;KACtB;IACD,MAAM,KAAK,CAAC,qBAAqB,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import {CellId} from \"@holochain/client\";\n\n\nexport declare type Dictionary<T> = {\n [key: string]: T;\n};\n\n/** */\nexport function areArraysEqual(first: Uint8Array, second: Uint8Array) {\n return first.length === second.length && first.every((value, index) => value === second[index])\n}\n\n/** */\nexport function areCellsEqual(cellA: CellId, cellB: CellId) {\n return areArraysEqual(cellA[0], cellB[0]) && areArraysEqual(cellA[1], cellB[1])\n}\n\n/** */\nexport const delay = (ms: number) => new Promise(r => setTimeout(r, ms))\n\n/** convert Pascal case to snake case */\nexport const snake = str => str[0].toLowerCase() + str.slice(1, str.length).replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);\n\n/** convert snake case to pascal case */\nexport const pascal = str => str[0].toUpperCase() + str.slice(1, str.length).replace(/_([a-z])/g, letter => `${letter[1].toUpperCase()}`);\n\n\n/** */\nexport function getVariantByIndex(enumType: any, index: number): string {\n const keys = Object.keys(enumType);\n if (index >= 0 && index < keys.length) {\n const key = keys[index];\n return enumType[key];\n }\n throw Error(\"Out of bounds index\");\n}\n"]}
|