@ddd-qc/cell-proxy 0.19.19 → 0.20.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/hcl.js CHANGED
@@ -1,58 +1,58 @@
1
- /**
2
- * `cell:/<appId>/<BaseRoleName>/<cloneId>`
3
- * Examples
4
- * `cell:/where/profiles`
5
- * `cell:/chatApp/channel/channel.2`
6
- */
7
- export class HCL {
8
- /** Ctor */
9
- constructor(appId, role, cloneId) {
10
- this.appId = appId;
11
- this.baseRoleName = role;
12
- this.cloneId = cloneId;
13
- }
14
- /** */
15
- get roleName() { return this.isClone() ? this.cloneId : this.baseRoleName; }
16
- ;
17
- /** */
18
- static parse(sHcl) {
19
- const subs = sHcl.split('/');
20
- //console.log({subs});
21
- if (subs[0] !== "cell:")
22
- throw Error("HCL.parse() Bad string format: " + sHcl);
23
- if (subs.length < 2)
24
- throw Error("HCL.parse() Bad string format. Too few components: " + sHcl);
25
- if (subs.length > 4)
26
- throw Error("HCL.parse() Bad string format. Too many components: " + sHcl);
27
- if (subs.length == 4) {
28
- return new HCL(subs[1], subs[2], subs[3]);
29
- }
30
- return new HCL(subs[1], subs[2]);
31
- }
32
- /** */
33
- toString() {
34
- let hcl = "cell:/" + this.appId + "/" + this.baseRoleName;
35
- //const maybeCloneName = this.cloneId;
36
- if (this.isClone()) {
37
- hcl += "/" + this.cloneId;
38
- }
39
- return hcl;
40
- }
41
- /** */
42
- isClone() { return this.cloneId !== undefined; }
43
- /** */
44
- match(hcl) {
45
- if (this.appId != hcl.appId)
46
- return false;
47
- if (this.baseRoleName != hcl.baseRoleName)
48
- return false;
49
- if (hcl.isClone()) {
50
- if (!this.isClone())
51
- return false;
52
- if (hcl.cloneId != this.cloneId)
53
- return false;
54
- }
55
- return true;
56
- }
57
- }
1
+ /**
2
+ * `cell:/<appId>/<BaseRoleName>/<cloneId>`
3
+ * Examples
4
+ * `cell:/where/profiles`
5
+ * `cell:/chatApp/channel/channel.2`
6
+ */
7
+ export class HCL {
8
+ /** Ctor */
9
+ constructor(appId, role, cloneId) {
10
+ this.appId = appId;
11
+ this.baseRoleName = role;
12
+ this.cloneId = cloneId;
13
+ }
14
+ /** */
15
+ get roleName() { return this.isClone() ? this.cloneId : this.baseRoleName; }
16
+ ;
17
+ /** */
18
+ static parse(sHcl) {
19
+ const subs = sHcl.split('/');
20
+ //console.log({subs});
21
+ if (subs[0] !== "cell:")
22
+ throw Error("HCL.parse() Bad string format: " + sHcl);
23
+ if (subs.length < 2)
24
+ throw Error("HCL.parse() Bad string format. Too few components: " + sHcl);
25
+ if (subs.length > 4)
26
+ throw Error("HCL.parse() Bad string format. Too many components: " + sHcl);
27
+ if (subs.length == 4) {
28
+ return new HCL(subs[1], subs[2], subs[3]);
29
+ }
30
+ return new HCL(subs[1], subs[2]);
31
+ }
32
+ /** */
33
+ toString() {
34
+ let hcl = "cell:/" + this.appId + "/" + this.baseRoleName;
35
+ //const maybeCloneName = this.cloneId;
36
+ if (this.isClone()) {
37
+ hcl += "/" + this.cloneId;
38
+ }
39
+ return hcl;
40
+ }
41
+ /** */
42
+ isClone() { return this.cloneId !== undefined; }
43
+ /** */
44
+ match(hcl) {
45
+ if (this.appId != hcl.appId)
46
+ return false;
47
+ if (this.baseRoleName != hcl.baseRoleName)
48
+ return false;
49
+ if (hcl.isClone()) {
50
+ if (!this.isClone())
51
+ return false;
52
+ if (hcl.cloneId != this.cloneId)
53
+ return false;
54
+ }
55
+ return true;
56
+ }
57
+ }
58
58
  //# sourceMappingURL=hcl.js.map
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export * from "./AppProxy";
2
- export * from "./ConductorAppProxy";
3
- export * from "./ExternalAppProxy";
4
- export * from "./CellProxy";
5
- export * from "./ZomeProxy";
6
- export * from "./utils";
7
- export * from "./types";
8
- export * from "./hcl";
9
- export * from "./mixins";
10
- export * from "./cell";
1
+ export * from "./AppProxy";
2
+ export * from "./ConductorAppProxy";
3
+ export * from "./ExternalAppProxy";
4
+ export * from "./CellProxy";
5
+ export * from "./ZomeProxy";
6
+ export * from "./utils";
7
+ export * from "./types";
8
+ export * from "./hcl";
9
+ export * from "./mixins";
10
+ export * from "./cell";
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- export * from "./AppProxy";
2
- export * from "./ConductorAppProxy";
3
- export * from "./ExternalAppProxy";
4
- export * from "./CellProxy";
5
- export * from "./ZomeProxy";
6
- export * from "./utils";
7
- export * from "./types";
8
- export * from "./hcl";
9
- export * from "./mixins";
10
- export * from "./cell";
1
+ export * from "./AppProxy";
2
+ export * from "./ConductorAppProxy";
3
+ export * from "./ExternalAppProxy";
4
+ export * from "./CellProxy";
5
+ export * from "./ZomeProxy";
6
+ export * from "./utils";
7
+ export * from "./types";
8
+ export * from "./hcl";
9
+ export * from "./mixins";
10
+ export * from "./cell";
11
11
  //# sourceMappingURL=index.js.map
package/dist/mixins.d.ts CHANGED
@@ -1,38 +1,38 @@
1
- import { FunctionName, ZomeName } from "@holochain/client";
2
- import { Cell } from "./cell";
3
- export type AbstractConstructor<T = {}> = abstract new (...args: any[]) => T;
4
- export declare class Empty {
5
- constructor(...args: any[]);
6
- }
7
- /** ------------------------------------------------------------------------------------------- **/
8
- /**
9
- * Mixin for Cell bound classes.
10
- * A Cell bound class must have a "Provisioned" or "Cloned" cell from @holochain/client
11
- */
12
- export declare function CellMixin<TBase extends AbstractConstructor>(Base: TBase): (abstract new (...args: any[]) => {
13
- _cell?: Cell;
14
- readonly cell: Cell;
15
- }) & TBase;
16
- /** ------------------------------------------------------------------------------------------- **/
17
- /**
18
- * Mixin for Zome bound classes.
19
- * A Zome bound class must have a zome name and a list of zome functions
20
- */
21
- export declare function ZomeMixin<TBase extends AbstractConstructor>(Base: TBase): ((abstract new (...args: any[]) => {
22
- zomeName: ZomeName;
23
- readonly defaultZomeName: string;
24
- /** Tuple array with zome name */
25
- readonly fnNames: [string, string][];
26
- }) & {
27
- readonly DEFAULT_ZOME_NAME: ZomeName;
28
- readonly FN_NAMES: FunctionName[];
29
- }) & TBase;
30
- export declare const ZomeSpecific: ((abstract new (...args: any[]) => {
31
- zomeName: ZomeName;
32
- readonly defaultZomeName: string;
33
- /** Tuple array with zome name */
34
- readonly fnNames: [string, string][];
35
- }) & {
36
- readonly DEFAULT_ZOME_NAME: ZomeName;
37
- readonly FN_NAMES: FunctionName[];
38
- }) & typeof Empty;
1
+ import { FunctionName, ZomeName } from "@holochain/client";
2
+ import { Cell } from "./cell";
3
+ export type AbstractConstructor<T = {}> = abstract new (...args: any[]) => T;
4
+ export declare class Empty {
5
+ constructor(...args: any[]);
6
+ }
7
+ /** ------------------------------------------------------------------------------------------- **/
8
+ /**
9
+ * Mixin for Cell bound classes.
10
+ * A Cell bound class must have a "Provisioned" or "Cloned" cell from @holochain/client
11
+ */
12
+ export declare function CellMixin<TBase extends AbstractConstructor>(Base: TBase): (abstract new (...args: any[]) => {
13
+ _cell?: Cell;
14
+ readonly cell: Cell;
15
+ }) & TBase;
16
+ /** ------------------------------------------------------------------------------------------- **/
17
+ /**
18
+ * Mixin for Zome bound classes.
19
+ * A Zome bound class must have a zome name and a list of zome functions
20
+ */
21
+ export declare function ZomeMixin<TBase extends AbstractConstructor>(Base: TBase): ((abstract new (...args: any[]) => {
22
+ zomeName: ZomeName;
23
+ readonly defaultZomeName: string;
24
+ /** Tuple array with zome name */
25
+ readonly fnNames: [string, string][];
26
+ }) & {
27
+ readonly DEFAULT_ZOME_NAME: ZomeName;
28
+ readonly FN_NAMES: FunctionName[];
29
+ }) & TBase;
30
+ export declare const ZomeSpecific: ((abstract new (...args: any[]) => {
31
+ zomeName: ZomeName;
32
+ readonly defaultZomeName: string;
33
+ /** Tuple array with zome name */
34
+ readonly fnNames: [string, string][];
35
+ }) & {
36
+ readonly DEFAULT_ZOME_NAME: ZomeName;
37
+ readonly FN_NAMES: FunctionName[];
38
+ }) & typeof Empty;
package/dist/mixins.js CHANGED
@@ -1,45 +1,45 @@
1
- export class Empty {
2
- constructor(...args) { }
3
- }
4
- /** ------------------------------------------------------------------------------------------- **/
5
- /**
6
- * Mixin for Cell bound classes.
7
- * A Cell bound class must have a "Provisioned" or "Cloned" cell from @holochain/client
8
- */
9
- export function CellMixin(Base) {
10
- class ACell extends Base {
11
- get cell() { if (!this._cell)
12
- throw Error("Cell field not set for object"); return this._cell; }
13
- }
14
- return ACell;
15
- }
16
- //export const CellSpecific = CellMixin(Empty);
17
- /** ------------------------------------------------------------------------------------------- **/
18
- /**
19
- * Mixin for Zome bound classes.
20
- * A Zome bound class must have a zome name and a list of zome functions
21
- */
22
- export function ZomeMixin(Base) {
23
- class AZomeSpecific extends Base {
24
- constructor(...args) {
25
- super(args);
26
- this.zomeName = this.constructor.DEFAULT_ZOME_NAME;
27
- }
28
- get defaultZomeName() {
29
- return this.constructor.DEFAULT_ZOME_NAME;
30
- }
31
- /** Tuple array with zome name */
32
- get fnNames() {
33
- const fnNames = this.constructor.FN_NAMES;
34
- if (!fnNames) {
35
- throw Error("FN_NAMES not defined in ZomeProxy subclass " + this.constructor.name);
36
- }
37
- return fnNames.map((fnName) => {
38
- return [this.zomeName, fnName];
39
- });
40
- }
41
- }
42
- return AZomeSpecific;
43
- }
44
- export const ZomeSpecific = ZomeMixin(Empty);
1
+ export class Empty {
2
+ constructor(...args) { }
3
+ }
4
+ /** ------------------------------------------------------------------------------------------- **/
5
+ /**
6
+ * Mixin for Cell bound classes.
7
+ * A Cell bound class must have a "Provisioned" or "Cloned" cell from @holochain/client
8
+ */
9
+ export function CellMixin(Base) {
10
+ class ACell extends Base {
11
+ get cell() { if (!this._cell)
12
+ throw Error("Cell field not set for object"); return this._cell; }
13
+ }
14
+ return ACell;
15
+ }
16
+ //export const CellSpecific = CellMixin(Empty);
17
+ /** ------------------------------------------------------------------------------------------- **/
18
+ /**
19
+ * Mixin for Zome bound classes.
20
+ * A Zome bound class must have a zome name and a list of zome functions
21
+ */
22
+ export function ZomeMixin(Base) {
23
+ class AZomeSpecific extends Base {
24
+ constructor(...args) {
25
+ super(args);
26
+ this.zomeName = this.constructor.DEFAULT_ZOME_NAME;
27
+ }
28
+ get defaultZomeName() {
29
+ return this.constructor.DEFAULT_ZOME_NAME;
30
+ }
31
+ /** Tuple array with zome name */
32
+ get fnNames() {
33
+ const fnNames = this.constructor.FN_NAMES;
34
+ if (!fnNames) {
35
+ throw Error("FN_NAMES not defined in ZomeProxy subclass " + this.constructor.name);
36
+ }
37
+ return fnNames.map((fnName) => {
38
+ return [this.zomeName, fnName];
39
+ });
40
+ }
41
+ }
42
+ return AZomeSpecific;
43
+ }
44
+ export const ZomeSpecific = ZomeMixin(Empty);
45
45
  //# sourceMappingURL=mixins.js.map
package/dist/types.d.ts CHANGED
@@ -1,48 +1,48 @@
1
- import { CellId, RoleName, ClonedCell, ProvisionedCell, ZomeName, FunctionName } from "@holochain/client";
2
- import { AgentPubKey, DnaHash } from "@holochain/client/lib/types";
3
- import { Dictionary } from "./utils";
4
- export type BaseRoleName = string;
5
- export type CloneIndex = number;
6
- export type ZomeIndex = number;
7
- export type EntryDef = any;
8
- export type EntryDefsCallbackResult = {
9
- Defs: EntryDef[];
10
- };
11
- export type ScopedZomeTypes = [ZomeIndex, number[]][];
12
- export type ScopedZomeTypesSet = {
13
- entries: ScopedZomeTypes;
14
- links: ScopedZomeTypes;
15
- };
16
- export type ZomeInfo = {
17
- name: ZomeName;
18
- id: ZomeIndex;
19
- properties: Uint8Array;
20
- entry_defs: EntryDef[];
21
- extern_fns: FunctionName[];
22
- zome_types: ScopedZomeTypesSet;
23
- };
24
- export type DnaInfo = {
25
- name: string;
26
- hash: DnaHash;
27
- properties: Uint8Array;
28
- zome_names: ZomeName[];
29
- };
30
- /** */
31
- export type CellsForRole = {
32
- provisioned: ProvisionedCell;
33
- /** CloneId -> Cell */
34
- clones: Dictionary<ClonedCell>;
35
- };
36
- /** BaseRoleName -> RoleCells */
37
- export type RoleCellsMap = Dictionary<CellsForRole>;
38
- /** -- CloneId -- */
39
- export type CloneId = RoleName;
40
- /** type for string "<baseRoleName>.<cloneIndex>" */
41
- export declare function createCloneName(baseRoleName: BaseRoleName, cloneIndex: CloneIndex): string;
42
- /** */
43
- export declare function destructureCloneId(cloneId: CloneId): [BaseRoleName, CloneIndex] | undefined;
44
- /** -- CellIdStr -- */
45
- export type CellIdStr = string;
46
- export declare function CellIdStr(hash_or_id: DnaHash | CellId, key?: AgentPubKey): CellIdStr;
47
- /** */
48
- export declare function str2CellId(str: CellIdStr): CellId;
1
+ import { CellId, RoleName, ClonedCell, ProvisionedCell, ZomeName, FunctionName } from "@holochain/client";
2
+ import { AgentPubKey, DnaHash } from "@holochain/client/lib/types";
3
+ import { Dictionary } from "./utils";
4
+ export type BaseRoleName = string;
5
+ export type CloneIndex = number;
6
+ export type ZomeIndex = number;
7
+ export type EntryDef = any;
8
+ export type EntryDefsCallbackResult = {
9
+ Defs: EntryDef[];
10
+ };
11
+ export type ScopedZomeTypes = [ZomeIndex, number[]][];
12
+ export type ScopedZomeTypesSet = {
13
+ entries: ScopedZomeTypes;
14
+ links: ScopedZomeTypes;
15
+ };
16
+ export type ZomeInfo = {
17
+ name: ZomeName;
18
+ id: ZomeIndex;
19
+ properties: Uint8Array;
20
+ entry_defs: EntryDef[];
21
+ extern_fns: FunctionName[];
22
+ zome_types: ScopedZomeTypesSet;
23
+ };
24
+ export type DnaInfo = {
25
+ name: string;
26
+ hash: DnaHash;
27
+ properties: Uint8Array;
28
+ zome_names: ZomeName[];
29
+ };
30
+ /** */
31
+ export type CellsForRole = {
32
+ provisioned: ProvisionedCell;
33
+ /** CloneId -> Cell */
34
+ clones: Dictionary<ClonedCell>;
35
+ };
36
+ /** BaseRoleName -> RoleCells */
37
+ export type RoleCellsMap = Dictionary<CellsForRole>;
38
+ /** -- CloneId -- */
39
+ export type CloneId = RoleName;
40
+ /** type for string "<baseRoleName>.<cloneIndex>" */
41
+ export declare function createCloneName(baseRoleName: BaseRoleName, cloneIndex: CloneIndex): string;
42
+ /** */
43
+ export declare function destructureCloneId(cloneId: CloneId): [BaseRoleName, CloneIndex] | undefined;
44
+ /** -- CellIdStr -- */
45
+ export type CellIdStr = string;
46
+ export declare function CellIdStr(hash_or_id: DnaHash | CellId, key?: AgentPubKey): CellIdStr;
47
+ /** */
48
+ export declare function str2CellId(str: CellIdStr): CellId;
package/dist/types.js CHANGED
@@ -1,34 +1,34 @@
1
- import { decodeHashFromBase64, encodeHashToBase64, } from "@holochain/client";
2
- /** type for string "<baseRoleName>.<cloneIndex>" */
3
- export function createCloneName(baseRoleName, cloneIndex) {
4
- //if (!cloneIndex) return baseRoleName as CloneName;
5
- return "" + baseRoleName + "." + cloneIndex;
6
- }
7
- /** */
8
- export function destructureCloneId(cloneId) {
9
- const subs = cloneId.split(".");
10
- if (subs.length != 2) {
11
- //throw Error(`Bad RoleInstance id format: "${id}"`);
12
- return undefined;
13
- }
14
- return [subs[0], Number(subs[1])];
15
- }
16
- const CELL_ID_SEPARATOR = "||";
17
- export function CellIdStr(hash_or_id, key) {
18
- if (Array.isArray(hash_or_id)) {
19
- return "" + encodeHashToBase64(hash_or_id[0]) + CELL_ID_SEPARATOR + encodeHashToBase64(hash_or_id[1]);
20
- }
21
- if (!key) {
22
- throw Error("CellIdStr() failed. AgentPubKey not provided");
23
- }
24
- return "" + encodeHashToBase64(hash_or_id) + CELL_ID_SEPARATOR + encodeHashToBase64(key);
25
- }
26
- /** */
27
- export function str2CellId(str) {
28
- const subs = str.split(CELL_ID_SEPARATOR);
29
- if (subs.length != 2) {
30
- throw Error("str2CellId() failed. Bad input string format");
31
- }
32
- return [decodeHashFromBase64(subs[0]), decodeHashFromBase64(subs[1])];
33
- }
1
+ import { decodeHashFromBase64, encodeHashToBase64, } from "@holochain/client";
2
+ /** type for string "<baseRoleName>.<cloneIndex>" */
3
+ export function createCloneName(baseRoleName, cloneIndex) {
4
+ //if (!cloneIndex) return baseRoleName as CloneName;
5
+ return "" + baseRoleName + "." + cloneIndex;
6
+ }
7
+ /** */
8
+ export function destructureCloneId(cloneId) {
9
+ const subs = cloneId.split(".");
10
+ if (subs.length != 2) {
11
+ //throw Error(`Bad RoleInstance id format: "${id}"`);
12
+ return undefined;
13
+ }
14
+ return [subs[0], Number(subs[1])];
15
+ }
16
+ const CELL_ID_SEPARATOR = "||";
17
+ export function CellIdStr(hash_or_id, key) {
18
+ if (Array.isArray(hash_or_id)) {
19
+ return "" + encodeHashToBase64(hash_or_id[0]) + CELL_ID_SEPARATOR + encodeHashToBase64(hash_or_id[1]);
20
+ }
21
+ if (!key) {
22
+ throw Error("CellIdStr() failed. AgentPubKey not provided");
23
+ }
24
+ return "" + encodeHashToBase64(hash_or_id) + CELL_ID_SEPARATOR + encodeHashToBase64(key);
25
+ }
26
+ /** */
27
+ export function str2CellId(str) {
28
+ const subs = str.split(CELL_ID_SEPARATOR);
29
+ if (subs.length != 2) {
30
+ throw Error("str2CellId() failed. Bad input string format");
31
+ }
32
+ return [decodeHashFromBase64(subs[0]), decodeHashFromBase64(subs[1])];
33
+ }
34
34
  //# sourceMappingURL=types.js.map
package/dist/utils.d.ts CHANGED
@@ -1,26 +1,26 @@
1
- import { CellId, AppInfo } from "@holochain/client";
2
- import { BaseRoleName, CellsForRole } from "./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
- /** convert Pascal case to snake case */
13
- export declare const snake: (str: any) => any;
14
- /** convert snake case to pascal case */
15
- export declare const pascal: (str: any) => any;
16
- /**
17
- * Checks if obj is a Hash or list of hashes and tries to convert it a B64 or list of B64
18
- */
19
- export declare function anyToB64(obj: any): any;
20
- export declare function prettyDuration(date: Date): string;
21
- /** */
22
- export declare function prettyDate(date: Date): string;
23
- /** */
24
- export declare function printAppInfo(appInfo: AppInfo): string;
25
- /** */
26
- export declare function printCellsForRole(baseRoleName: BaseRoleName, cells: CellsForRole): string;
1
+ import { CellId, AppInfo } from "@holochain/client";
2
+ import { BaseRoleName, CellsForRole } from "./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
+ /** convert Pascal case to snake case */
13
+ export declare const snake: (str: any) => any;
14
+ /** convert snake case to pascal case */
15
+ export declare const pascal: (str: any) => any;
16
+ /**
17
+ * Checks if obj is a Hash or list of hashes and tries to convert it a B64 or list of B64
18
+ */
19
+ export declare function anyToB64(obj: any): any;
20
+ export declare function prettyDuration(date: Date): string;
21
+ /** */
22
+ export declare function prettyDate(date: Date): string;
23
+ /** */
24
+ export declare function printAppInfo(appInfo: AppInfo): string;
25
+ /** */
26
+ export declare function printCellsForRole(baseRoleName: BaseRoleName, cells: CellsForRole): string;