@ddd-qc/cell-proxy 0.19.19 → 0.20.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 +74 -74
- package/dist/AppProxy.js +297 -297
- package/dist/AppProxy.js.map +1 -1
- package/dist/CellProxy.d.ts +72 -72
- package/dist/CellProxy.js +208 -208
- package/dist/ConductorAppProxy.d.ts +31 -31
- package/dist/ConductorAppProxy.js +80 -80
- package/dist/ExternalAppProxy.d.ts +15 -15
- package/dist/ExternalAppProxy.js +27 -27
- package/dist/ZomeProxy.d.ts +38 -38
- package/dist/ZomeProxy.js +63 -63
- package/dist/cell.d.ts +35 -35
- package/dist/cell.js +70 -70
- package/dist/cell.js.map +1 -1
- package/dist/hcl.d.ts +28 -28
- package/dist/hcl.js +57 -57
- package/dist/index.d.ts +10 -10
- package/dist/index.js +10 -10
- package/dist/mixins.d.ts +38 -38
- package/dist/mixins.js +44 -44
- package/dist/types.d.ts +48 -48
- package/dist/types.js +33 -33
- package/dist/utils.d.ts +26 -26
- package/dist/utils.js +90 -90
- package/package.json +3 -2
- package/dist/CallQueue.d.ts +0 -14
- package/dist/CallQueue.js +0 -20
- package/dist/CallQueue.js.map +0 -1
package/dist/utils.js
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import { encodeHashToBase64 } from "@holochain/client";
|
|
2
|
-
import { CellType } from "@holochain/client";
|
|
3
|
-
import { intoStem } from "./cell";
|
|
4
|
-
/** */
|
|
5
|
-
export function areArraysEqual(first, second) {
|
|
6
|
-
return first.length === second.length && first.every((value, index) => value === second[index]);
|
|
7
|
-
}
|
|
8
|
-
/** */
|
|
9
|
-
export function areCellsEqual(cellA, cellB) {
|
|
10
|
-
return areArraysEqual(cellA[0], cellB[0]) && areArraysEqual(cellA[1], cellB[1]);
|
|
11
|
-
}
|
|
12
|
-
/** */
|
|
13
|
-
export const delay = (ms) => new Promise(r => setTimeout(r, ms));
|
|
14
|
-
/** convert Pascal case to snake case */
|
|
15
|
-
export const snake = str => str[0].toLowerCase() + str.slice(1, str.length).replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);
|
|
16
|
-
/** convert snake case to pascal case */
|
|
17
|
-
export const pascal = str => str[0].toUpperCase() + str.slice(1, str.length).replace(/_([a-z])/g, letter => `${letter[1].toUpperCase()}`);
|
|
18
|
-
/**
|
|
19
|
-
* Checks if obj is a Hash or list of hashes and tries to convert it a B64 or list of B64
|
|
20
|
-
*/
|
|
21
|
-
export function anyToB64(obj) {
|
|
22
|
-
/** Check if it's a hash */
|
|
23
|
-
if (obj instanceof Uint8Array) {
|
|
24
|
-
return encodeHashToBase64(obj);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
/** Check if it's an array of hashes */
|
|
28
|
-
if (Array.isArray(obj)) {
|
|
29
|
-
const isUint8Array = obj.length > 0 &&
|
|
30
|
-
obj.every((value) => {
|
|
31
|
-
return value instanceof Uint8Array;
|
|
32
|
-
});
|
|
33
|
-
if (isUint8Array) {
|
|
34
|
-
let result = [];
|
|
35
|
-
for (const cur of obj) {
|
|
36
|
-
result.push(encodeHashToBase64(cur));
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return obj;
|
|
43
|
-
}
|
|
44
|
-
/** -- Pretty print -- */
|
|
45
|
-
const zeroPad = (num, places) => String(num).padStart(places, '0');
|
|
46
|
-
export function prettyDuration(date) {
|
|
47
|
-
return date.getSeconds() + "." + zeroPad(date.getMilliseconds(), 3);
|
|
48
|
-
}
|
|
49
|
-
/** */
|
|
50
|
-
export function prettyDate(date) {
|
|
51
|
-
return ""
|
|
52
|
-
+ zeroPad(date.getHours(), 2)
|
|
53
|
-
+ ":" + zeroPad(date.getMinutes(), 2)
|
|
54
|
-
+ ":" + zeroPad(date.getSeconds(), 2)
|
|
55
|
-
+ "." + zeroPad(date.getMilliseconds(), 3);
|
|
56
|
-
}
|
|
57
|
-
/** */
|
|
58
|
-
export function printAppInfo(appInfo) {
|
|
59
|
-
let print = `Happ "${appInfo.installed_app_id}" info: (status: ${JSON.stringify(appInfo.status)})`;
|
|
60
|
-
for (const [roleName, cellInfos] of Object.entries(appInfo.cell_info)) {
|
|
61
|
-
for (const cellInfo of Object.values(cellInfos)) {
|
|
62
|
-
if (CellType.Stem in cellInfo) {
|
|
63
|
-
const stem = intoStem(cellInfo);
|
|
64
|
-
print += `\n - ${roleName}.${stem.name ? stem.name : "unnamed"}: ${encodeHashToBase64(stem.dna)} (stem)`;
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (CellType.Provisioned in cellInfo) {
|
|
68
|
-
const cell = cellInfo.provisioned;
|
|
69
|
-
print += `\n - ${roleName}: ${cell.name} | ${encodeHashToBase64(cell.cell_id[0])}`;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (CellType.Cloned in cellInfo) {
|
|
73
|
-
const cell = cellInfo.cloned;
|
|
74
|
-
print += `\n - ${roleName}.${cell.clone_id}: ${cell.name} | ${encodeHashToBase64(cell.cell_id[0])}`;
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return print;
|
|
80
|
-
}
|
|
81
|
-
/** */
|
|
82
|
-
export function printCellsForRole(baseRoleName, cells) {
|
|
83
|
-
let print = `CellsForRole "${baseRoleName}": (${encodeHashToBase64(cells.provisioned.cell_id[1])})\n`;
|
|
84
|
-
print += ` - Provisioned: ${cells.provisioned.name} | ${encodeHashToBase64(cells.provisioned.cell_id[0])}\n`;
|
|
85
|
-
print += ` - Clones : ${Object.values(cells.clones).length}\n`;
|
|
86
|
-
for (const [cloneId, clone] of Object.entries(cells.clones)) {
|
|
87
|
-
print += ` - (${clone.enabled ? "enabled" : "disabled"})${cloneId}: ${clone.name} | ${encodeHashToBase64(clone.cell_id[0])}\n`;
|
|
88
|
-
}
|
|
89
|
-
return print;
|
|
90
|
-
}
|
|
1
|
+
import { encodeHashToBase64 } from "@holochain/client";
|
|
2
|
+
import { CellType } from "@holochain/client";
|
|
3
|
+
import { intoStem } from "./cell";
|
|
4
|
+
/** */
|
|
5
|
+
export function areArraysEqual(first, second) {
|
|
6
|
+
return first.length === second.length && first.every((value, index) => value === second[index]);
|
|
7
|
+
}
|
|
8
|
+
/** */
|
|
9
|
+
export function areCellsEqual(cellA, cellB) {
|
|
10
|
+
return areArraysEqual(cellA[0], cellB[0]) && areArraysEqual(cellA[1], cellB[1]);
|
|
11
|
+
}
|
|
12
|
+
/** */
|
|
13
|
+
export const delay = (ms) => new Promise(r => setTimeout(r, ms));
|
|
14
|
+
/** convert Pascal case to snake case */
|
|
15
|
+
export const snake = str => str[0].toLowerCase() + str.slice(1, str.length).replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);
|
|
16
|
+
/** convert snake case to pascal case */
|
|
17
|
+
export const pascal = str => str[0].toUpperCase() + str.slice(1, str.length).replace(/_([a-z])/g, letter => `${letter[1].toUpperCase()}`);
|
|
18
|
+
/**
|
|
19
|
+
* Checks if obj is a Hash or list of hashes and tries to convert it a B64 or list of B64
|
|
20
|
+
*/
|
|
21
|
+
export function anyToB64(obj) {
|
|
22
|
+
/** Check if it's a hash */
|
|
23
|
+
if (obj instanceof Uint8Array) {
|
|
24
|
+
return encodeHashToBase64(obj);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
/** Check if it's an array of hashes */
|
|
28
|
+
if (Array.isArray(obj)) {
|
|
29
|
+
const isUint8Array = obj.length > 0 &&
|
|
30
|
+
obj.every((value) => {
|
|
31
|
+
return value instanceof Uint8Array;
|
|
32
|
+
});
|
|
33
|
+
if (isUint8Array) {
|
|
34
|
+
let result = [];
|
|
35
|
+
for (const cur of obj) {
|
|
36
|
+
result.push(encodeHashToBase64(cur));
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
/** -- Pretty print -- */
|
|
45
|
+
const zeroPad = (num, places) => String(num).padStart(places, '0');
|
|
46
|
+
export function prettyDuration(date) {
|
|
47
|
+
return date.getSeconds() + "." + zeroPad(date.getMilliseconds(), 3);
|
|
48
|
+
}
|
|
49
|
+
/** */
|
|
50
|
+
export function prettyDate(date) {
|
|
51
|
+
return ""
|
|
52
|
+
+ zeroPad(date.getHours(), 2)
|
|
53
|
+
+ ":" + zeroPad(date.getMinutes(), 2)
|
|
54
|
+
+ ":" + zeroPad(date.getSeconds(), 2)
|
|
55
|
+
+ "." + zeroPad(date.getMilliseconds(), 3);
|
|
56
|
+
}
|
|
57
|
+
/** */
|
|
58
|
+
export function printAppInfo(appInfo) {
|
|
59
|
+
let print = `Happ "${appInfo.installed_app_id}" info: (status: ${JSON.stringify(appInfo.status)})`;
|
|
60
|
+
for (const [roleName, cellInfos] of Object.entries(appInfo.cell_info)) {
|
|
61
|
+
for (const cellInfo of Object.values(cellInfos)) {
|
|
62
|
+
if (CellType.Stem in cellInfo) {
|
|
63
|
+
const stem = intoStem(cellInfo);
|
|
64
|
+
print += `\n - ${roleName}.${stem.name ? stem.name : "unnamed"}: ${encodeHashToBase64(stem.dna)} (stem)`;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (CellType.Provisioned in cellInfo) {
|
|
68
|
+
const cell = cellInfo.provisioned;
|
|
69
|
+
print += `\n - ${roleName}: ${cell.name} | ${encodeHashToBase64(cell.cell_id[0])}`;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (CellType.Cloned in cellInfo) {
|
|
73
|
+
const cell = cellInfo.cloned;
|
|
74
|
+
print += `\n - ${roleName}.${cell.clone_id}: ${cell.name} | ${encodeHashToBase64(cell.cell_id[0])}`;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return print;
|
|
80
|
+
}
|
|
81
|
+
/** */
|
|
82
|
+
export function printCellsForRole(baseRoleName, cells) {
|
|
83
|
+
let print = `CellsForRole "${baseRoleName}": (${encodeHashToBase64(cells.provisioned.cell_id[1])})\n`;
|
|
84
|
+
print += ` - Provisioned: ${cells.provisioned.name} | ${encodeHashToBase64(cells.provisioned.cell_id[0])}\n`;
|
|
85
|
+
print += ` - Clones : ${Object.values(cells.clones).length}\n`;
|
|
86
|
+
for (const [cloneId, clone] of Object.entries(cells.clones)) {
|
|
87
|
+
print += ` - (${clone.enabled ? "enabled" : "disabled"})${cloneId}: ${clone.name} | ${encodeHashToBase64(clone.cell_id[0])}\n`;
|
|
88
|
+
}
|
|
89
|
+
return print;
|
|
90
|
+
}
|
|
91
91
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-qc/cell-proxy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"description": "Proxy classes and helpers for managing a Holochain AppWebsocket",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
"homepage": "https://github.com/ddd-mtl/lit-happ#readme",
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"tslib": "^2.4.0",
|
|
27
|
-
"typescript": "
|
|
27
|
+
"typescript": "~5.2.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
+
"@holochain/client": "=0.16.2",
|
|
30
31
|
"async-mutex": "0.4.0"
|
|
31
32
|
}
|
|
32
33
|
}
|
package/dist/CallQueue.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** From https://dev.to/glebirovich/typescript-data-structures-stack-and-queue-hld#queue */
|
|
2
|
-
interface IQueue<T> {
|
|
3
|
-
enqueue(item: T): void;
|
|
4
|
-
dequeue(): T | undefined;
|
|
5
|
-
size(): number;
|
|
6
|
-
}
|
|
7
|
-
declare class Queue<T> implements IQueue<T> {
|
|
8
|
-
private capacity;
|
|
9
|
-
private storage;
|
|
10
|
-
constructor(capacity?: number);
|
|
11
|
-
enqueue(item: T): void;
|
|
12
|
-
dequeue(): T | undefined;
|
|
13
|
-
size(): number;
|
|
14
|
-
}
|
package/dist/CallQueue.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/** From https://dev.to/glebirovich/typescript-data-structures-stack-and-queue-hld#queue */
|
|
2
|
-
class Queue {
|
|
3
|
-
constructor(capacity = Infinity) {
|
|
4
|
-
this.capacity = capacity;
|
|
5
|
-
this.storage = [];
|
|
6
|
-
}
|
|
7
|
-
enqueue(item) {
|
|
8
|
-
if (this.size() === this.capacity) {
|
|
9
|
-
throw Error("Queue has reached max capacity, you cannot add more items");
|
|
10
|
-
}
|
|
11
|
-
this.storage.push(item);
|
|
12
|
-
}
|
|
13
|
-
dequeue() {
|
|
14
|
-
return this.storage.shift();
|
|
15
|
-
}
|
|
16
|
-
size() {
|
|
17
|
-
return this.storage.length;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=CallQueue.js.map
|
package/dist/CallQueue.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CallQueue.js","sourceRoot":"","sources":["../src/CallQueue.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAS3F,MAAM,KAAK;IAGT,YAAoB,WAAmB,QAAQ;QAA3B,aAAQ,GAAR,QAAQ,CAAmB;QAFvC,YAAO,GAAQ,EAAE,CAAC;IAEwB,CAAC;IAEnD,OAAO,CAAC,IAAO;QACb,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE;YACjC,MAAM,KAAK,CAAC,2DAA2D,CAAC,CAAC;SAC1E;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO;QACL,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IACD,IAAI;QACF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;CACF","sourcesContent":["/** From https://dev.to/glebirovich/typescript-data-structures-stack-and-queue-hld#queue */\r\n\r\n\r\ninterface IQueue<T> {\r\n enqueue(item: T): void;\r\n dequeue(): T | undefined;\r\n size(): number;\r\n}\r\n\r\nclass Queue<T> implements IQueue<T> {\r\n private storage: T[] = [];\r\n\r\n constructor(private capacity: number = Infinity) {}\r\n\r\n enqueue(item: T): void {\r\n if (this.size() === this.capacity) {\r\n throw Error(\"Queue has reached max capacity, you cannot add more items\");\r\n }\r\n this.storage.push(item);\r\n }\r\n dequeue(): T | undefined {\r\n return this.storage.shift();\r\n }\r\n size(): number {\r\n return this.storage.length;\r\n }\r\n}\r\n"]}
|