@ddd-qc/cell-proxy 0.19.18 → 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.
@@ -1,15 +1,15 @@
1
- import { AppApi, AppInfoRequest, AppInfoResponse, CallZomeRequest, DisableCloneCellRequest, EnableCloneCellRequest, ClonedCell } from "@holochain/client";
2
- import { AppProxy } from "./AppProxy";
3
- /**
4
- *
5
- */
6
- export declare class ExternalAppProxy extends AppProxy implements AppApi {
7
- private _appApi;
8
- /** Ctor */
9
- constructor(_appApi: AppApi, defaultTimeout: number);
10
- /** -- AppApi (Passthrough to external AppApi) -- */
11
- enableCloneCell(request: EnableCloneCellRequest): Promise<ClonedCell>;
12
- disableCloneCell(request: DisableCloneCellRequest): Promise<void>;
13
- appInfo(args: AppInfoRequest): Promise<AppInfoResponse>;
14
- callZome(req: CallZomeRequest, timeout?: number): Promise<unknown>;
15
- }
1
+ import { AppApi, AppInfoRequest, AppInfoResponse, CallZomeRequest, DisableCloneCellRequest, EnableCloneCellRequest, ClonedCell } from "@holochain/client";
2
+ import { AppProxy } from "./AppProxy";
3
+ /**
4
+ *
5
+ */
6
+ export declare class ExternalAppProxy extends AppProxy implements AppApi {
7
+ private _appApi;
8
+ /** Ctor */
9
+ constructor(_appApi: AppApi, defaultTimeout: number);
10
+ /** -- AppApi (Passthrough to external AppApi) -- */
11
+ enableCloneCell(request: EnableCloneCellRequest): Promise<ClonedCell>;
12
+ disableCloneCell(request: DisableCloneCellRequest): Promise<void>;
13
+ appInfo(args: AppInfoRequest): Promise<AppInfoResponse>;
14
+ callZome(req: CallZomeRequest, timeout?: number): Promise<unknown>;
15
+ }
@@ -1,28 +1,28 @@
1
- import { AppProxy } from "./AppProxy";
2
- /**
3
- *
4
- */
5
- export class ExternalAppProxy extends AppProxy {
6
- /** Ctor */
7
- /*protected*/ constructor(_appApi, defaultTimeout) {
8
- super(defaultTimeout);
9
- this._appApi = _appApi;
10
- }
11
- /** -- AppApi (Passthrough to external AppApi) -- */
12
- async enableCloneCell(request) {
13
- //console.log("enableCloneCell() called:", request)
14
- return this._appApi.enableCloneCell(request);
15
- }
16
- async disableCloneCell(request) {
17
- //console.log("disableCloneCell() called:", request)
18
- return this._appApi.disableCloneCell(request);
19
- }
20
- async appInfo(args) {
21
- return this._appApi.appInfo(args);
22
- }
23
- async callZome(req, timeout) {
24
- timeout = timeout ? timeout : this.defaultTimeout;
25
- return this._appApi.callZome(req, timeout);
26
- }
27
- }
1
+ import { AppProxy } from "./AppProxy";
2
+ /**
3
+ *
4
+ */
5
+ export class ExternalAppProxy extends AppProxy {
6
+ /** Ctor */
7
+ /*protected*/ constructor(_appApi, defaultTimeout) {
8
+ super(defaultTimeout);
9
+ this._appApi = _appApi;
10
+ }
11
+ /** -- AppApi (Passthrough to external AppApi) -- */
12
+ async enableCloneCell(request) {
13
+ //console.log("enableCloneCell() called:", request)
14
+ return this._appApi.enableCloneCell(request);
15
+ }
16
+ async disableCloneCell(request) {
17
+ //console.log("disableCloneCell() called:", request)
18
+ return this._appApi.disableCloneCell(request);
19
+ }
20
+ async appInfo(args) {
21
+ return this._appApi.appInfo(args);
22
+ }
23
+ async callZome(req, timeout) {
24
+ timeout = timeout ? timeout : this.defaultTimeout;
25
+ return this._appApi.callZome(req, timeout);
26
+ }
27
+ }
28
28
  //# sourceMappingURL=ExternalAppProxy.js.map
@@ -1,38 +1,38 @@
1
- import { CapSecret, FunctionName, ZomeName } from "@holochain/client";
2
- import { ZomeSpecific } from "./mixins";
3
- import { CellProxy } from "./CellProxy";
4
- import { DnaInfo, ZomeInfo } from "./types";
5
- export type ZomeProxyConstructor = {
6
- new (cellProxy: CellProxy, zomeName?: ZomeName): ZomeProxy;
7
- } & typeof ZomeSpecific;
8
- declare const ZomeProxy_base: (abstract new (...args: any[]) => {
9
- _cell?: import("./cell").Cell;
10
- readonly cell: import("./cell").Cell;
11
- }) & ((abstract new (...args: any[]) => {
12
- zomeName: string;
13
- readonly defaultZomeName: string;
14
- readonly fnNames: [string, string][];
15
- }) & {
16
- readonly DEFAULT_ZOME_NAME: string;
17
- readonly FN_NAMES: string[];
18
- }) & typeof import("./mixins").Empty;
19
- /**
20
- * ABC for representing the zome function bindings of a Zome.
21
- * It holds the zomeName and reference to a CellProxy.
22
- */
23
- export declare abstract class ZomeProxy extends ZomeProxy_base {
24
- protected _cellProxy: CellProxy;
25
- /** Ctor */
26
- constructor(_cellProxy: CellProxy, zomeName?: ZomeName);
27
- /** Helper for calling a zome function on its zome */
28
- protected call(fnName: FunctionName, payload: any, maybeSecret?: CapSecret, timeout?: number): Promise<any>;
29
- /** Helper for calling a zome function on its zome */
30
- protected callBlocking(fnName: FunctionName, payload: any, maybeSecret?: CapSecret, timeout?: number): Promise<any>;
31
- /** */
32
- zomeInfo(): Promise<ZomeInfo>;
33
- /** */
34
- dnaInfo(): Promise<DnaInfo>;
35
- /** */
36
- callEntryDefs(zomeName: ZomeName): Promise<[string, boolean][]>;
37
- }
38
- export {};
1
+ import { CapSecret, FunctionName, ZomeName } from "@holochain/client";
2
+ import { ZomeSpecific } from "./mixins";
3
+ import { CellProxy } from "./CellProxy";
4
+ import { DnaInfo, ZomeInfo } from "./types";
5
+ export type ZomeProxyConstructor = {
6
+ new (cellProxy: CellProxy, zomeName?: ZomeName): ZomeProxy;
7
+ } & typeof ZomeSpecific;
8
+ declare const ZomeProxy_base: (abstract new (...args: any[]) => {
9
+ _cell?: import("./cell").Cell;
10
+ readonly cell: import("./cell").Cell;
11
+ }) & ((abstract new (...args: any[]) => {
12
+ zomeName: string;
13
+ readonly defaultZomeName: string;
14
+ readonly fnNames: [string, string][];
15
+ }) & {
16
+ readonly DEFAULT_ZOME_NAME: string;
17
+ readonly FN_NAMES: string[];
18
+ }) & typeof import("./mixins").Empty;
19
+ /**
20
+ * ABC for representing the zome function bindings of a Zome.
21
+ * It holds the zomeName and reference to a CellProxy.
22
+ */
23
+ export declare abstract class ZomeProxy extends ZomeProxy_base {
24
+ protected _cellProxy: CellProxy;
25
+ /** Ctor */
26
+ constructor(_cellProxy: CellProxy, zomeName?: ZomeName);
27
+ /** Helper for calling a zome function on its zome */
28
+ protected call(fnName: FunctionName, payload: any, maybeSecret?: CapSecret, timeout?: number): Promise<any>;
29
+ /** Helper for calling a zome function on its zome */
30
+ protected callBlocking(fnName: FunctionName, payload: any, maybeSecret?: CapSecret, timeout?: number): Promise<any>;
31
+ /** */
32
+ zomeInfo(): Promise<ZomeInfo>;
33
+ /** */
34
+ dnaInfo(): Promise<DnaInfo>;
35
+ /** */
36
+ callEntryDefs(zomeName: ZomeName): Promise<[string, boolean][]>;
37
+ }
38
+ export {};
package/dist/ZomeProxy.js CHANGED
@@ -1,64 +1,64 @@
1
- import { CellMixin, ZomeSpecific } from "./mixins";
2
- /**
3
- * ABC for representing the zome function bindings of a Zome.
4
- * It holds the zomeName and reference to a CellProxy.
5
- */
6
- export class ZomeProxy extends CellMixin(ZomeSpecific) {
7
- /** Ctor */
8
- constructor(_cellProxy, zomeName) {
9
- super();
10
- this._cellProxy = _cellProxy;
11
- if (zomeName) {
12
- this.zomeName = zomeName;
13
- }
14
- else {
15
- if (!this.defaultZomeName) {
16
- throw Error("zomeName not defined in ZomeProxy subclass " + this.constructor.name);
17
- }
18
- }
19
- this._cell = _cellProxy.cell;
20
- }
21
- // private _signingProps?: {
22
- // capSecret: CapSecret;
23
- // keyPair: nacl.SignKeyPair;
24
- // signingKey: AgentPubKey;
25
- // };
26
- // setSigningProps(signingProps: { capSecret: CapSecret; keyPair: nacl.SignKeyPair; signingKey: AgentPubKey}): void {
27
- // this._signingProps = signingProps;
28
- // }
29
- /** Helper for calling a zome function on its zome */
30
- async call(fnName, payload, maybeSecret, timeout) {
31
- //console.log("ZomeProxy.call", this.zomeName)
32
- if (!this.constructor.FN_NAMES.includes(fnName)) {
33
- return Promise.reject(`Function "${fnName}()" not part of zome "${this.zomeName}"`);
34
- }
35
- const cap_secret = maybeSecret
36
- ? maybeSecret
37
- // : this._signingProps
38
- // ? this._signingProps.capSecret
39
- : null;
40
- return this._cellProxy.callZome(this.zomeName, fnName, payload, cap_secret, timeout);
41
- }
42
- /** Helper for calling a zome function on its zome */
43
- async callBlocking(fnName, payload, maybeSecret, timeout) {
44
- //console.log("ZomeProxy.call", this.zomeName)
45
- if (!this.constructor.FN_NAMES.includes(fnName)) {
46
- return Promise.reject(`Function "${fnName}()" not part of zome "${this.zomeName}"`);
47
- }
48
- const cap_secret = maybeSecret ? maybeSecret : null;
49
- return this._cellProxy.callZomeBlocking(this.zomeName, fnName, payload, cap_secret, timeout);
50
- }
51
- /** */
52
- async zomeInfo() {
53
- return this._cellProxy.callZomeInfo(this.zomeName);
54
- }
55
- /** */
56
- async dnaInfo() {
57
- return this._cellProxy.callDnaInfo(this.zomeName);
58
- }
59
- /** */
60
- async callEntryDefs(zomeName) {
61
- return this._cellProxy.callEntryDefs(zomeName);
62
- }
63
- }
1
+ import { CellMixin, ZomeSpecific } from "./mixins";
2
+ /**
3
+ * ABC for representing the zome function bindings of a Zome.
4
+ * It holds the zomeName and reference to a CellProxy.
5
+ */
6
+ export class ZomeProxy extends CellMixin(ZomeSpecific) {
7
+ /** Ctor */
8
+ constructor(_cellProxy, zomeName) {
9
+ super();
10
+ this._cellProxy = _cellProxy;
11
+ if (zomeName) {
12
+ this.zomeName = zomeName;
13
+ }
14
+ else {
15
+ if (!this.defaultZomeName) {
16
+ throw Error("zomeName not defined in ZomeProxy subclass " + this.constructor.name);
17
+ }
18
+ }
19
+ this._cell = _cellProxy.cell;
20
+ }
21
+ // private _signingProps?: {
22
+ // capSecret: CapSecret;
23
+ // keyPair: nacl.SignKeyPair;
24
+ // signingKey: AgentPubKey;
25
+ // };
26
+ // setSigningProps(signingProps: { capSecret: CapSecret; keyPair: nacl.SignKeyPair; signingKey: AgentPubKey}): void {
27
+ // this._signingProps = signingProps;
28
+ // }
29
+ /** Helper for calling a zome function on its zome */
30
+ async call(fnName, payload, maybeSecret, timeout) {
31
+ //console.log("ZomeProxy.call", this.zomeName)
32
+ if (!this.constructor.FN_NAMES.includes(fnName)) {
33
+ return Promise.reject(`Function "${fnName}()" not part of zome "${this.zomeName}"`);
34
+ }
35
+ const cap_secret = maybeSecret
36
+ ? maybeSecret
37
+ // : this._signingProps
38
+ // ? this._signingProps.capSecret
39
+ : null;
40
+ return this._cellProxy.callZome(this.zomeName, fnName, payload, cap_secret, timeout);
41
+ }
42
+ /** Helper for calling a zome function on its zome */
43
+ async callBlocking(fnName, payload, maybeSecret, timeout) {
44
+ //console.log("ZomeProxy.call", this.zomeName)
45
+ if (!this.constructor.FN_NAMES.includes(fnName)) {
46
+ return Promise.reject(`Function "${fnName}()" not part of zome "${this.zomeName}"`);
47
+ }
48
+ const cap_secret = maybeSecret ? maybeSecret : null;
49
+ return this._cellProxy.callZomeBlocking(this.zomeName, fnName, payload, cap_secret, timeout);
50
+ }
51
+ /** */
52
+ async zomeInfo() {
53
+ return this._cellProxy.callZomeInfo(this.zomeName);
54
+ }
55
+ /** */
56
+ async dnaInfo() {
57
+ return this._cellProxy.callDnaInfo(this.zomeName);
58
+ }
59
+ /** */
60
+ async callEntryDefs(zomeName) {
61
+ return this._cellProxy.callEntryDefs(zomeName);
62
+ }
63
+ }
64
64
  //# sourceMappingURL=ZomeProxy.js.map
package/dist/cell.d.ts CHANGED
@@ -1,35 +1,35 @@
1
- import { AgentPubKeyB64, CellId, CellInfo, DnaHashB64, DnaModifiers, ProvisionedCell, StemCell, ClonedCell, InstalledAppId } from "@holochain/client";
2
- import { RoleName } from "@holochain/client/lib/types";
3
- import { HCL } from "./hcl";
4
- import { BaseRoleName } from "./types";
5
- export type AnyCell = ProvisionedCell | ClonedCell;
6
- /**
7
- * Common interface between Provisioned and Cloned cells
8
- */
9
- export declare class Cell {
10
- private readonly _cell;
11
- readonly appId: InstalledAppId;
12
- readonly baseRoleName: BaseRoleName;
13
- /** */
14
- static from(cellInfo: CellInfo, appId: InstalledAppId, baseRoleName: BaseRoleName): Cell;
15
- /** Ctor */
16
- constructor(_cell: AnyCell, appId: InstalledAppId, baseRoleName: BaseRoleName);
17
- /** -- Getters -- */
18
- get id(): CellId;
19
- get dnaHash(): DnaHashB64;
20
- get agentPubKey(): AgentPubKeyB64;
21
- get name(): string;
22
- get dnaModifiers(): DnaModifiers;
23
- /** ex: rNamedInteger.0 */
24
- get cloneId(): RoleName | undefined;
25
- /** -- Methods -- */
26
- hcl(): HCL;
27
- asCloned(): ClonedCell | null;
28
- asProvisioned(): ProvisionedCell | null;
29
- /** */
30
- print(): string;
31
- }
32
- /** ... */
33
- export declare function intoStem(cellInfo: CellInfo): StemCell | undefined;
34
- /** ... */
35
- export declare function asCell(cellInfo: CellInfo): AnyCell | undefined;
1
+ import { AgentPubKeyB64, CellId, CellInfo, DnaHashB64, DnaModifiers, ProvisionedCell, StemCell, ClonedCell, InstalledAppId } from "@holochain/client";
2
+ import { RoleName } from "@holochain/client/lib/types";
3
+ import { HCL } from "./hcl";
4
+ import { BaseRoleName } from "./types";
5
+ export type AnyCell = ProvisionedCell | ClonedCell;
6
+ /**
7
+ * Common interface between Provisioned and Cloned cells
8
+ */
9
+ export declare class Cell {
10
+ private readonly _cell;
11
+ readonly appId: InstalledAppId;
12
+ readonly baseRoleName: BaseRoleName;
13
+ /** */
14
+ static from(cellInfo: CellInfo, appId: InstalledAppId, baseRoleName: BaseRoleName): Cell;
15
+ /** Ctor */
16
+ constructor(_cell: AnyCell, appId: InstalledAppId, baseRoleName: BaseRoleName);
17
+ /** -- Getters -- */
18
+ get id(): CellId;
19
+ get dnaHash(): DnaHashB64;
20
+ get agentPubKey(): AgentPubKeyB64;
21
+ get name(): string;
22
+ get dnaModifiers(): DnaModifiers;
23
+ /** ex: rNamedInteger.0 */
24
+ get cloneId(): RoleName | undefined;
25
+ /** -- Methods -- */
26
+ hcl(): HCL;
27
+ asCloned(): ClonedCell | null;
28
+ asProvisioned(): ProvisionedCell | null;
29
+ /** */
30
+ print(): string;
31
+ }
32
+ /** ... */
33
+ export declare function intoStem(cellInfo: CellInfo): StemCell | undefined;
34
+ /** ... */
35
+ export declare function asCell(cellInfo: CellInfo): AnyCell | undefined;
package/dist/cell.js CHANGED
@@ -1,71 +1,71 @@
1
- import { CellType, encodeHashToBase64 } from "@holochain/client";
2
- import { HCL } from "./hcl";
3
- /**
4
- * Common interface between Provisioned and Cloned cells
5
- */
6
- export class Cell {
7
- /** */
8
- static from(cellInfo, appId, baseRoleName) {
9
- if (CellType.Stem in cellInfo) {
10
- const id = cellInfo.stem.name ? cellInfo.stem.name : encodeHashToBase64(cellInfo.stem.dna);
11
- throw Error("StemCell cannot be converted to Cell: " + id);
12
- }
13
- if (CellType.Cloned in cellInfo) {
14
- return new Cell(cellInfo.cloned, appId, baseRoleName);
15
- }
16
- return new Cell(cellInfo.provisioned, appId, baseRoleName);
17
- }
18
- /** Ctor */
19
- constructor(_cell, appId, baseRoleName) {
20
- this._cell = _cell;
21
- this.appId = appId;
22
- this.baseRoleName = baseRoleName;
23
- }
24
- /** -- Getters -- */
25
- get id() { return this._cell.cell_id; }
26
- get dnaHash() { return encodeHashToBase64(this.id[0]); }
27
- get agentPubKey() { return encodeHashToBase64(this.id[1]); }
28
- get name() { return this._cell.name; }
29
- get dnaModifiers() { return this._cell.dna_modifiers; }
30
- /** ex: rNamedInteger.0 */
31
- get cloneId() { return this._cell.clone_id; }
32
- /** -- Methods -- */
33
- hcl() { return new HCL(this.appId, this.baseRoleName, this.cloneId); }
34
- asCloned() {
35
- if (!this.cloneId) {
36
- return null;
37
- }
38
- return this._cell;
39
- }
40
- asProvisioned() {
41
- if (this.cloneId) {
42
- return null;
43
- }
44
- return this._cell;
45
- }
46
- /** */
47
- print() {
48
- return `Cell "${this.name}${this.cloneId ? "." + this.cloneId : ""}": ${this.dnaHash}`;
49
- }
50
- }
51
- /** ... */
52
- export function intoStem(cellInfo) {
53
- if (CellType.Stem in cellInfo) {
54
- return cellInfo.stem;
55
- }
56
- return undefined;
57
- }
58
- /** ... */
59
- export function asCell(cellInfo) {
60
- if (CellType.Stem in cellInfo) {
61
- return undefined;
62
- }
63
- if (CellType.Cloned in cellInfo) {
64
- return cellInfo.cloned;
65
- }
66
- if (CellType.Provisioned in cellInfo) {
67
- return cellInfo.provisioned;
68
- }
69
- return undefined;
70
- }
1
+ import { CellType, encodeHashToBase64 } from "@holochain/client";
2
+ import { HCL } from "./hcl";
3
+ /**
4
+ * Common interface between Provisioned and Cloned cells
5
+ */
6
+ export class Cell {
7
+ /** */
8
+ static from(cellInfo, appId, baseRoleName) {
9
+ if (CellType.Stem in cellInfo) {
10
+ const id = cellInfo.stem.name ? cellInfo.stem.name : encodeHashToBase64(cellInfo.stem.dna);
11
+ throw Error("StemCell cannot be converted to Cell: " + id);
12
+ }
13
+ if (CellType.Cloned in cellInfo) {
14
+ return new Cell(cellInfo.cloned, appId, baseRoleName);
15
+ }
16
+ return new Cell(cellInfo.provisioned, appId, baseRoleName);
17
+ }
18
+ /** Ctor */
19
+ constructor(_cell, appId, baseRoleName) {
20
+ this._cell = _cell;
21
+ this.appId = appId;
22
+ this.baseRoleName = baseRoleName;
23
+ }
24
+ /** -- Getters -- */
25
+ get id() { return this._cell.cell_id; }
26
+ get dnaHash() { return encodeHashToBase64(this.id[0]); }
27
+ get agentPubKey() { return encodeHashToBase64(this.id[1]); }
28
+ get name() { return this._cell.name; }
29
+ get dnaModifiers() { return this._cell.dna_modifiers; }
30
+ /** ex: rNamedInteger.0 */
31
+ get cloneId() { return this._cell.clone_id; }
32
+ /** -- Methods -- */
33
+ hcl() { return new HCL(this.appId, this.baseRoleName, this.cloneId); }
34
+ asCloned() {
35
+ if (!this.cloneId) {
36
+ return null;
37
+ }
38
+ return this._cell;
39
+ }
40
+ asProvisioned() {
41
+ if (this.cloneId) {
42
+ return null;
43
+ }
44
+ return this._cell;
45
+ }
46
+ /** */
47
+ print() {
48
+ return `Cell "${this.name}${this.cloneId ? "." + this.cloneId : ""}": ${this.dnaHash}`;
49
+ }
50
+ }
51
+ /** ... */
52
+ export function intoStem(cellInfo) {
53
+ if (CellType.Stem in cellInfo) {
54
+ return cellInfo.stem;
55
+ }
56
+ return undefined;
57
+ }
58
+ /** ... */
59
+ export function asCell(cellInfo) {
60
+ if (CellType.Stem in cellInfo) {
61
+ return undefined;
62
+ }
63
+ if (CellType.Cloned in cellInfo) {
64
+ return cellInfo.cloned;
65
+ }
66
+ if (CellType.Provisioned in cellInfo) {
67
+ return cellInfo.provisioned;
68
+ }
69
+ return undefined;
70
+ }
71
71
  //# sourceMappingURL=cell.js.map
package/dist/cell.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cell.js","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,QAAQ,EAGR,kBAAkB,EAEnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAO1B;;GAEG;AACH,MAAM,OAAO,IAAI;IAEf,MAAM;IACN,MAAM,CAAC,IAAI,CAAC,QAAkB,EAAE,KAAqB,EAAE,YAA0B;QAC/E,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,EAAE;YAC7B,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAA,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC1F,MAAM,KAAK,CAAC,wCAAwC,GAAG,EAAE,CAAC,CAAC;SAC5D;QACD,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,EAAE;YAC/B,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;SACvD;QACD,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IAC7D,CAAC;IAGD,WAAW;IACX,YAA6B,KAAc,EAAkB,K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O,CAAA,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACvF,CAAC;CACF;AAID,UAAU;AACV,MAAM,UAAU,QAAQ,CAAC,QAAkB;IACzC,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,EAAE;QAC7B,OAAO,QAAQ,CAAC,IAAI,CAAC;KACtB;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,UAAU;AACV,MAAM,UAAU,MAAM,CAAC,QAAkB;IACvC,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,EAAE;QAC7B,OAAO,SAAS,CAAC;KAClB;IACD,IAAI,QAAQ,CAAC,MAAM,IAAI,QAAQ,EAAE;QAC/B,OAAO,QAAQ,CAAC,MAAM,CAAC;KACxB;IACD,IAAI,QAAQ,CAAC,WAAW,IAAI,QAAQ,EAAE;QACpC,OAAO,QAAQ,CAAC,WAAW,CAAC;KAC7B;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {\r\n AgentPubKeyB64,\r\n CellId,\r\n CellInfo,\r\n CellType,\r\n DnaHashB64,\r\n DnaModifiers,\r\n encodeHashToBase64,\r\n ProvisionedCell, StemCell, ClonedCell, InstalledAppId\r\n} from \"@holochain/client\";\r\nimport {RoleName} from \"@holochain/client/lib/types\";\r\nimport {HCL} from \"./hcl\";\r\nimport {BaseRoleName} from \"./types\";\r\n\r\n\r\nexport type AnyCell = ProvisionedCell | ClonedCell;\r\n\r\n\r\n/**\r\n * Common interface between Provisioned and Cloned cells\r\n */\r\nexport class Cell {\r\n\r\n /** */\r\n static from(cellInfo: CellInfo, appId: InstalledAppId, baseRoleName: BaseRoleName): Cell {\r\n if (CellType.Stem in cellInfo) {\r\n const id = cellInfo.stem.name? cellInfo.stem.name : encodeHashToBase64(cellInfo.stem.dna);\r\n throw Error(\"StemCell cannot be converted to Cell: \" + id);\r\n }\r\n if (CellType.Cloned in cellInfo) {\r\n return new Cell(cellInfo.cloned, appId, baseRoleName);\r\n }\r\n return new Cell(cellInfo.provisioned, appId, baseRoleName);\r\n }\r\n\r\n\r\n /** Ctor */\r\n constructor(private readonly _cell: AnyCell, public readonly appId: InstalledAppId, public readonly baseRoleName: BaseRoleName) {}\r\n\r\n\r\n /** -- Getters -- */\r\n\r\n get id(): CellId { return (this._cell as any).cell_id }\r\n get dnaHash(): DnaHashB64 { return encodeHashToBase64(this.id[0]) }\r\n get agentPubKey(): AgentPubKeyB64 { return encodeHashToBase64(this.id[1]) }\r\n get name(): string {return (this._cell as any).name}\r\n get dnaModifiers(): DnaModifiers {return (this._cell as any).dna_modifiers}\r\n\r\n /** ex: rNamedInteger.0 */\r\n get cloneId(): RoleName | undefined { return (this._cell as any).clone_id }\r\n\r\n\r\n /** -- Methods -- */\r\n\r\n hcl(): HCL {return new HCL(this.appId, this.baseRoleName, this.cloneId)}\r\n\r\n asCloned(): ClonedCell | null {\r\n if (!this.cloneId) { return null}\r\n return this._cell as ClonedCell;\r\n }\r\n\r\n asProvisioned(): ProvisionedCell | null {\r\n if (this.cloneId) { return null}\r\n return this._cell as ProvisionedCell;\r\n }\r\n\r\n /** */\r\n print(): string {\r\n return `Cell \"${this.name}${this.cloneId? \".\" + this.cloneId: \"\"}\": ${this.dnaHash}`;\r\n }\r\n}\r\n\r\n\r\n\r\n/** ... */\r\nexport function intoStem(cellInfo: CellInfo): StemCell | undefined {\r\n if (CellType.Stem in cellInfo) {\r\n return cellInfo.stem;\r\n }\r\n return undefined\r\n}\r\n\r\n/** ... */\r\nexport function asCell(cellInfo: CellInfo): AnyCell | undefined {\r\n if (CellType.Stem in cellInfo) {\r\n return undefined;\r\n }\r\n if (CellType.Cloned in cellInfo) {\r\n return cellInfo.cloned;\r\n }\r\n if (CellType.Provisioned in cellInfo) {\r\n return cellInfo.provisioned;\r\n }\r\n return undefined;\r\n}\r\n"]}
1
+ {"version":3,"file":"cell.js","sourceRoot":"","sources":["../src/cell.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,QAAQ,E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,CAAC,MAAM,CAAC;KACxB;IACD,IAAI,QAAQ,CAAC,WAAW,IAAI,QAAQ,EAAE;QACpC,OAAO,QAAQ,CAAC,WAAW,CAAC;KAC7B;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {\n AgentPubKeyB64,\n CellId,\n CellInfo,\n CellType,\n DnaHashB64,\n DnaModifiers,\n encodeHashToBase64,\n ProvisionedCell, StemCell, ClonedCell, InstalledAppId\n} from \"@holochain/client\";\nimport {RoleName} from \"@holochain/client/lib/types\";\nimport {HCL} from \"./hcl\";\nimport {BaseRoleName} from \"./types\";\n\n\nexport type AnyCell = ProvisionedCell | ClonedCell;\n\n\n/**\n * Common interface between Provisioned and Cloned cells\n */\nexport class Cell {\n\n /** */\n static from(cellInfo: CellInfo, appId: InstalledAppId, baseRoleName: BaseRoleName): Cell {\n if (CellType.Stem in cellInfo) {\n const id = cellInfo.stem.name? cellInfo.stem.name : encodeHashToBase64(cellInfo.stem.dna);\n throw Error(\"StemCell cannot be converted to Cell: \" + id);\n }\n if (CellType.Cloned in cellInfo) {\n return new Cell(cellInfo.cloned, appId, baseRoleName);\n }\n return new Cell(cellInfo.provisioned, appId, baseRoleName);\n }\n\n\n /** Ctor */\n constructor(private readonly _cell: AnyCell, public readonly appId: InstalledAppId, public readonly baseRoleName: BaseRoleName) {}\n\n\n /** -- Getters -- */\n\n get id(): CellId { return (this._cell as any).cell_id }\n get dnaHash(): DnaHashB64 { return encodeHashToBase64(this.id[0]) }\n get agentPubKey(): AgentPubKeyB64 { return encodeHashToBase64(this.id[1]) }\n get name(): string {return (this._cell as any).name}\n get dnaModifiers(): DnaModifiers {return (this._cell as any).dna_modifiers}\n\n /** ex: rNamedInteger.0 */\n get cloneId(): RoleName | undefined { return (this._cell as any).clone_id }\n\n\n /** -- Methods -- */\n\n hcl(): HCL {return new HCL(this.appId, this.baseRoleName, this.cloneId)}\n\n asCloned(): ClonedCell | null {\n if (!this.cloneId) { return null}\n return this._cell as ClonedCell;\n }\n\n asProvisioned(): ProvisionedCell | null {\n if (this.cloneId) { return null}\n return this._cell as ProvisionedCell;\n }\n\n /** */\n print(): string {\n return `Cell \"${this.name}${this.cloneId? \".\" + this.cloneId: \"\"}\": ${this.dnaHash}`;\n }\n}\n\n\n\n/** ... */\nexport function intoStem(cellInfo: CellInfo): StemCell | undefined {\n if (CellType.Stem in cellInfo) {\n return cellInfo.stem;\n }\n return undefined\n}\n\n/** ... */\nexport function asCell(cellInfo: CellInfo): AnyCell | undefined {\n if (CellType.Stem in cellInfo) {\n return undefined;\n }\n if (CellType.Cloned in cellInfo) {\n return cellInfo.cloned;\n }\n if (CellType.Provisioned in cellInfo) {\n return cellInfo.provisioned;\n }\n return undefined;\n}\n"]}
package/dist/hcl.d.ts CHANGED
@@ -1,28 +1,28 @@
1
- import { InstalledAppId } from "@holochain/client";
2
- import { BaseRoleName, CloneId } from "./types";
3
- /** -- HCL: Holochain Cell Locator -- */
4
- export type HCLString = string;
5
- /**
6
- * `cell:/<appId>/<BaseRoleName>/<cloneId>`
7
- * Examples
8
- * `cell:/where/profiles`
9
- * `cell:/chatApp/channel/channel.2`
10
- */
11
- export declare class HCL {
12
- readonly appId: InstalledAppId;
13
- readonly baseRoleName: BaseRoleName;
14
- /** A Cell can have a cloneId if it's a cloneCell */
15
- readonly cloneId?: CloneId;
16
- /** Ctor */
17
- constructor(appId: InstalledAppId, role: BaseRoleName, cloneId?: CloneId);
18
- /** */
19
- get roleName(): string;
20
- /** */
21
- static parse(sHcl: HCLString): HCL;
22
- /** */
23
- toString(): HCLString;
24
- /** */
25
- isClone(): boolean;
26
- /** */
27
- match(hcl: HCL): boolean;
28
- }
1
+ import { InstalledAppId } from "@holochain/client";
2
+ import { BaseRoleName, CloneId } from "./types";
3
+ /** -- HCL: Holochain Cell Locator -- */
4
+ export type HCLString = string;
5
+ /**
6
+ * `cell:/<appId>/<BaseRoleName>/<cloneId>`
7
+ * Examples
8
+ * `cell:/where/profiles`
9
+ * `cell:/chatApp/channel/channel.2`
10
+ */
11
+ export declare class HCL {
12
+ readonly appId: InstalledAppId;
13
+ readonly baseRoleName: BaseRoleName;
14
+ /** A Cell can have a cloneId if it's a cloneCell */
15
+ readonly cloneId?: CloneId;
16
+ /** Ctor */
17
+ constructor(appId: InstalledAppId, role: BaseRoleName, cloneId?: CloneId);
18
+ /** */
19
+ get roleName(): string;
20
+ /** */
21
+ static parse(sHcl: HCLString): HCL;
22
+ /** */
23
+ toString(): HCLString;
24
+ /** */
25
+ isClone(): boolean;
26
+ /** */
27
+ match(hcl: HCL): boolean;
28
+ }