@ddd-qc/cell-proxy 0.26.9 → 0.27.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/dist/types.js.map CHANGED
@@ -1 +1 @@
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;AAIpD,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;AAwDD,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;AAMD,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;AACN,MAAM,UAAU,kBAAkB,CAAC,OAAgB;IACjD,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,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;AAGD,MAAM;AACN,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACvD,CAAC;AAOD,MAAM,iBAAiB,GAAG,IAAI,CAAA;AAE9B,MAAM,UAAU,SAAS,CAAC,cAA8B,EAAE,GAAa;IACrE,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;QACjC,OAAO,EAAE,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;KACrF;IACD,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,KAAK,CAAC,8CAA8C,CAAC,CAAC;KAC7D;IACD,OAAO,EAAE,GAAG,cAAc,CAAC,GAAG,GAAG,iBAAiB,GAAG,GAAG,CAAC,GAAG,CAAC;AAC/D,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,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,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\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/** ---- */\n\nexport type BaseRoleName = string;\nexport type CloneIndex = number;\n\nexport type ZomeIndex = number;\n\nexport type EntryDef = {\n id: { App: string } | { CapClaim: null } | { CapGrant: null },\n visibility: \"Public\" | \"Private\",\n requiredValidations: number,\n cacheAtAgentActivity: boolean,\n}\n\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 -- */\n\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"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAE0D,QAAQ,GACxE,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,QAAQ,CAAC;AAMtC,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;AAwDD,MAAM;AACN,MAAM,UAAU,YAAY,CAAC,KAAmB;IAC9C,IAAI,GAAG,GAAkB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,C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AO,IAAI,WAAW,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM;QACJ,OAAO,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IACzE,CAAC;IAED,iGAAiG;IACjG,QAAQ,KAAY,MAAM,KAAK,CAAC,8CAA8C,CAAC,CAAA,CAAA,CAAC;IAGhF,IAAI,GAAG;QACL,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;IACpE,CAAC;IAED,MAAM;IACN,MAAM,CAAC,KAAkB;QACvB,OAAO,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import {\n CellId,\n RoleName, ClonedCell, ProvisionedCell, ZomeName, FunctionName, HoloHash,\n} from \"@holochain/client\";\nimport {Dictionary} from \"./utils\";\nimport {AgentId, DnaId} from \"./hash\";\nimport {SystemSignalProtocol} from \"./zomeSignals.types\";\n\n\nexport type AnyCell = ProvisionedCell | ClonedCell;\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/** ---- */\n\nexport type BaseRoleName = string;\nexport type CloneIndex = number;\n\nexport type ZomeIndex = number;\n\nexport type EntryDef = {\n id: { App: string } | { CapClaim: null } | { CapGrant: null },\n visibility: \"Public\" | \"Private\",\n requiredValidations: number,\n cacheAtAgentActivity: boolean,\n}\n\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): CellAddress[] {\n let res: CellAddress[] = Object.entries(cells.clones).map(([cloneId, clone]) => CellAddress.from(clone.cell_id));\n res.push(CellAddress.from(cells.provisioned.cell_id));\n return res;\n}\n\n\n/** -- CloneId -- */\n\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/** -- CellAddress -- */\n\nexport type CellIdStr = string;\n\nconst CELL_ID_SEPARATOR = \"||\"\n\n\nexport class CellAddress {\n constructor(public readonly dnaId: DnaId, public readonly agentId: AgentId) {}\n\n static from(id_or_str: CellId | CellIdStr): CellAddress {\n if (typeof id_or_str == 'string') {\n const subs = id_or_str.split(CELL_ID_SEPARATOR);\n if (subs.length != 2) {\n throw Error(\"CellAddress.from() failed. Bad input string format\");\n }\n return new CellAddress(new DnaId(subs[0]), new AgentId(subs[1]));\n }\n return new CellAddress(new DnaId(id_or_str[0]), new AgentId(id_or_str[1]));\n }\n\n intoId(): CellId {\n return [new HoloHash(this.dnaId.hash), new HoloHash(this.agentId.hash)]\n }\n\n // Don't autoconvert to string as this can lead to confusions. Have convert to string be explicit\n toString(): string {throw Error(\"Implicit conversion of HolochainId to string\")}\n\n\n get str(): CellIdStr {\n return \"\" + this.dnaId.b64 + CELL_ID_SEPARATOR + this.agentId.b64;\n }\n\n /** */\n equals(other: CellAddress): boolean {\n return this.str == other.str;\n }\n}\n\n\n"]}
package/dist/utils.d.ts CHANGED
@@ -1,18 +1,19 @@
1
- import { CellId } from "@holochain/client";
2
1
  export declare type Dictionary<T> = {
3
2
  [key: string]: T;
4
3
  };
5
4
  /** */
6
- export declare function areArraysEqual(first: Uint8Array, second: Uint8Array): boolean;
5
+ export declare function assertIsDefined<T>(value: T | undefined): asserts value is T;
6
+ /** */
7
+ export declare function assertAllDefined(...args: any[]): void;
7
8
  /** */
8
- export declare function areCellsEqual(cellA: CellId, cellB: CellId): boolean;
9
+ export declare function areArraysEqual(first: Uint8Array, second: Uint8Array): boolean;
9
10
  /** */
10
11
  export declare const delay: (ms: number) => Promise<unknown>;
11
12
  /** convert Pascal case to snake case */
12
13
  export declare const snake: (str: any) => any;
13
14
  /** convert snake case to pascal case */
14
15
  export declare const pascal: (str: any) => any;
15
- /** */
16
- export declare function getVariantByIndex(enumType: Object, index: number): string;
17
- /** */
18
- export declare function getIndexByVariant(enumType: Object, variant: string): number;
16
+ /** enumType = enum or Object.values(enum) */
17
+ export declare function getVariantByIndex(enumType: Object | string[], index: number): string;
18
+ /** enumType = enum or Object.values(enum) */
19
+ export declare function getIndexByVariant(enumType: Object | string[], value: string): number;
package/dist/utils.js CHANGED
@@ -1,10 +1,20 @@
1
1
  /** */
2
- export function areArraysEqual(first, second) {
3
- return first.length === second.length && first.every((value, index) => value === second[index]);
2
+ export function assertIsDefined(value) {
3
+ if (value === undefined) {
4
+ throw new Error('Value is undefined');
5
+ }
4
6
  }
5
7
  /** */
6
- export function areCellsEqual(cellA, cellB) {
7
- return areArraysEqual(cellA[0], cellB[0]) && areArraysEqual(cellA[1], cellB[1]);
8
+ export function assertAllDefined(...args) {
9
+ for (const arg of args) {
10
+ if (arg === undefined) {
11
+ throw new Error('One or more arguments are undefined');
12
+ }
13
+ }
14
+ }
15
+ /** */
16
+ export function areArraysEqual(first, second) {
17
+ return first.length === second.length && first.every((value, index) => value === second[index]);
8
18
  }
9
19
  /** */
10
20
  export const delay = (ms) => new Promise(r => setTimeout(r, ms));
@@ -12,20 +22,27 @@ export const delay = (ms) => new Promise(r => setTimeout(r, ms));
12
22
  export const snake = str => str[0].toLowerCase() + str.slice(1, str.length).replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);
13
23
  /** convert snake case to pascal case */
14
24
  export const pascal = str => str[0].toUpperCase() + str.slice(1, str.length).replace(/_([a-z])/g, letter => `${letter[1].toUpperCase()}`);
15
- /** */
25
+ /** enumType = enum or Object.values(enum) */
16
26
  export function getVariantByIndex(enumType, index) {
17
- const keys = Object.keys(enumType);
27
+ let keys = enumType;
28
+ if (!Array.isArray(enumType)) {
29
+ keys = Object.keys(enumType);
30
+ }
18
31
  if (index >= 0 && index < keys.length) {
19
32
  const key = keys[index];
20
33
  return enumType[key];
21
34
  }
22
35
  throw Error("Out of bounds index");
23
36
  }
24
- /** */
25
- export function getIndexByVariant(enumType, variant) {
26
- for (const [i, cur] of Object.entries(enumType)) {
27
- if (cur == variant) {
28
- return Number(i);
37
+ /** enumType = enum or Object.values(enum) */
38
+ export function getIndexByVariant(enumType, value) {
39
+ let variants = enumType;
40
+ if (!Array.isArray(enumType)) {
41
+ variants = Object.keys(enumType).filter(key => isNaN(Number(key))); // Filter out numeric keys if present
42
+ }
43
+ for (let i = 0; i < variants.length; i++) {
44
+ if (variants[i] === value) {
45
+ return i;
29
46
  }
30
47
  }
31
48
  throw Error("Unknown variant");
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
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;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;AAExE,wCAAwC;AACxC,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAEpI,wCAAwC;AACxC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAG1I,MAAM;AACN,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,KAAa;IAC/D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;KACtB;IACD,MAAM,KAAK,CAAC,qBAAqB,CAAC,CAAC;AACrC,CAAC;AAGD,MAAM;AACN,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,OAAe;IACjE,KAAK,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC/C,IAAI,GAAG,IAAI,OAAO,EAAE;YAClB,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;SAClB;KACF;IACD,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACjC,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: Object, 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\n\n/** */\nexport function getIndexByVariant(enumType: Object, variant: string): number {\n for (const [i, cur] of Object.entries(enumType)) {\n if (cur == variant) {\n return Number(i);\n }\n }\n throw Error(\"Unknown variant\");\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAOA,MAAM;AACN,MAAM,UAAU,eAAe,CAAI,KAAoB;IACrD,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACvC;AACH,CAAC;AAGD,MAAM;AACN,MAAM,UAAU,gBAAgB,CAAC,GAAG,IAAW;IAC7C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;SACxD;KACF;AACH,CAAC;AAGD,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;AAGD,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;AAExE,wCAAwC;AACxC,MAAM,C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IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,qCAAqC;KAC1G;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACxC,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE;YACzB,OAAO,CAAC,CAAC;SACV;KACF;IACD,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACjC,CAAC","sourcesContent":["\n\nexport declare type Dictionary<T> = {\n [key: string]: T;\n};\n\n\n/** */\nexport function assertIsDefined<T>(value: T | undefined): asserts value is T {\n if (value === undefined) {\n throw new Error('Value is undefined');\n }\n}\n\n\n/** */\nexport function assertAllDefined(...args: any[]): void {\n for (const arg of args) {\n if (arg === undefined) {\n throw new Error('One or more arguments are undefined');\n }\n }\n}\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\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/** enumType = enum or Object.values(enum) */\nexport function getVariantByIndex(enumType: Object | string[], index: number): string {\n let keys = enumType as string[];\n if (!Array.isArray(enumType)) {\n keys = Object.keys(enumType);\n }\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\n\n/** enumType = enum or Object.values(enum) */\nexport function getIndexByVariant(enumType: Object | string[], value: string): number {\n let variants = enumType as string[];\n if (!Array.isArray(enumType)) {\n variants = Object.keys(enumType).filter(key => isNaN(Number(key))); // Filter out numeric keys if present\n }\n for (let i = 0; i < variants.length; i++) {\n if (variants[i] === value) {\n return i;\n }\n }\n throw Error(\"Unknown variant\");\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-qc/cell-proxy",
3
- "version": "0.26.9",
3
+ "version": "0.27.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",
@@ -29,6 +29,9 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@holochain/client": "^0.18.0-dev.4",
32
+ "@bitgo/blake2b": "^3.2.4",
33
+ "js-base64": "^3.7.5",
34
+ "@msgpack/msgpack": "^2.7.2",
32
35
  "async-mutex": "0.4.0"
33
36
  }
34
37
  }