@ddd-qc/profiles-dvm 0.33.2 → 0.33.4
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/profiles.zvm.d.ts +4 -2
- package/dist/profiles.zvm.d.ts.map +1 -1
- package/dist/profiles.zvm.js +8 -4
- package/dist/profiles.zvm.js.map +1 -1
- package/dist/profilesAlt.zvm.d.ts +2 -1
- package/dist/profilesAlt.zvm.d.ts.map +1 -1
- package/dist/profilesAlt.zvm.js +5 -2
- package/dist/profilesAlt.zvm.js.map +1 -1
- package/package.json +2 -2
package/dist/profiles.zvm.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ZomeViewModel } from "@ddd-qc/lit-happ";
|
|
|
2
2
|
import { Profile } from "./bindings/profiles.types";
|
|
3
3
|
import { AgentPubKeyB64 } from "@holochain/client";
|
|
4
4
|
import { ProfilesProxy } from "./bindings/profiles.proxy";
|
|
5
|
+
import { GetStrategy } from "@holochain-open-dev/core-types";
|
|
5
6
|
export type ProfilesPerspective = {
|
|
6
7
|
profiles: Record<AgentPubKeyB64, Profile>;
|
|
7
8
|
reversed: Record<string, AgentPubKeyB64>;
|
|
@@ -9,8 +10,9 @@ export type ProfilesPerspective = {
|
|
|
9
10
|
export declare class ProfilesZvm extends ZomeViewModel {
|
|
10
11
|
static readonly ZOME_PROXY: typeof ProfilesProxy;
|
|
11
12
|
get zomeProxy(): ProfilesProxy;
|
|
13
|
+
initializePerspectiveFromLocal(): Promise<void>;
|
|
12
14
|
initializePerspectiveFromNetwork(): Promise<void>;
|
|
13
|
-
probeAllInner(): void;
|
|
15
|
+
probeAllInner(strategy: GetStrategy): void;
|
|
14
16
|
get perspective(): ProfilesPerspective;
|
|
15
17
|
private _profiles;
|
|
16
18
|
private _reversed;
|
|
@@ -21,7 +23,7 @@ export declare class ProfilesZvm extends ZomeViewModel {
|
|
|
21
23
|
exportPerspective(): string;
|
|
22
24
|
importPerspective(json: string, _mapping?: Object): void;
|
|
23
25
|
findProfiles(names: string[]): AgentPubKeyB64[];
|
|
24
|
-
probeAllProfiles(): Promise<Record<AgentPubKeyB64, Profile>>;
|
|
26
|
+
probeAllProfiles(_strategy: GetStrategy): Promise<Record<AgentPubKeyB64, Profile>>;
|
|
25
27
|
storeProfile(pubKeyB64: AgentPubKeyB64, profile: Profile): void;
|
|
26
28
|
probeProfile(pubKeyB64: AgentPubKeyB64): Promise<Profile | undefined>;
|
|
27
29
|
createMyProfile(profile: Profile): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.zvm.d.ts","sourceRoot":"","sources":["../src/profiles.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAC,cAAc,EAA2C,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"profiles.zvm.d.ts","sourceRoot":"","sources":["../src/profiles.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAC,cAAc,EAA2C,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAI3D,MAAM,MAAM,mBAAmB,GAAG;IAEhC,QAAQ,EAAE,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAK1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC1C,CAAA;AAMD,qBAAa,WAAY,SAAQ,aAAa;IAE5C,gBAAyB,UAAU,uBAAiB;IACpD,IAAI,SAAS,IAAI,aAAa,CAA2C;IAI1D,8BAA8B,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/C,gCAAgC,IAAI,OAAO,CAAC,IAAI,CAAC;IAKvD,aAAa,CAAC,QAAQ,EAAE,WAAW;IAQ5C,IAAI,WAAW,IAAI,mBAAmB,CAOrC;IAED,OAAO,CAAC,SAAS,CAAuC;IAExD,OAAO,CAAC,SAAS,CAAsC;IAGvD,YAAY,IAAI,OAAO,GAAG,SAAS;IAEnC,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,SAAS;IAItD,SAAS,IAAI,cAAc,EAAE;IAE7B,QAAQ,IAAI,MAAM,EAAE;IAIpB,iBAAiB,IAAI,MAAM;IAO3B,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAUjD,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE;IAYzC,gBAAgB,CAAC,SAAS,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAsBxF,YAAY,CAAC,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO;IAQlD,YAAY,CAAC,SAAS,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAiBrE,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAOhD,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAKvD"}
|
package/dist/profiles.zvm.js
CHANGED
|
@@ -2,6 +2,7 @@ import { ZomeViewModel } from "@ddd-qc/lit-happ";
|
|
|
2
2
|
import { decodeHashFromBase64, encodeHashToBase64 } from "@holochain/client";
|
|
3
3
|
import { ProfilesProxy } from "./bindings/profiles.proxy";
|
|
4
4
|
import { decode } from "@msgpack/msgpack";
|
|
5
|
+
import { GetStrategy } from "@holochain-open-dev/core-types";
|
|
5
6
|
export class ProfilesZvm extends ZomeViewModel {
|
|
6
7
|
constructor() {
|
|
7
8
|
super(...arguments);
|
|
@@ -10,11 +11,14 @@ export class ProfilesZvm extends ZomeViewModel {
|
|
|
10
11
|
}
|
|
11
12
|
static { this.ZOME_PROXY = ProfilesProxy; }
|
|
12
13
|
get zomeProxy() { return this._zomeProxy; }
|
|
14
|
+
async initializePerspectiveFromLocal() {
|
|
15
|
+
await this.probeAllProfiles(GetStrategy.Local);
|
|
16
|
+
}
|
|
13
17
|
async initializePerspectiveFromNetwork() {
|
|
14
|
-
await this.probeAllProfiles();
|
|
18
|
+
await this.probeAllProfiles(GetStrategy.Network);
|
|
15
19
|
}
|
|
16
|
-
probeAllInner() {
|
|
17
|
-
this.probeAllProfiles()
|
|
20
|
+
probeAllInner(strategy) {
|
|
21
|
+
this.probeAllProfiles(strategy)
|
|
18
22
|
.then((res) => console.trace("probeAllProfiles() finished: ", res.length));
|
|
19
23
|
}
|
|
20
24
|
get perspective() {
|
|
@@ -46,7 +50,7 @@ export class ProfilesZvm extends ZomeViewModel {
|
|
|
46
50
|
}
|
|
47
51
|
return res;
|
|
48
52
|
}
|
|
49
|
-
async probeAllProfiles() {
|
|
53
|
+
async probeAllProfiles(_strategy) {
|
|
50
54
|
let allAgents;
|
|
51
55
|
try {
|
|
52
56
|
allAgents = await this.zomeProxy.getAgentsWithProfile();
|
package/dist/profiles.zvm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.zvm.js","sourceRoot":"","sources":["../src/profiles.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAiB,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"profiles.zvm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AM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAID,KAAK,CAAC,eAAe,CAAC,OAAgB;QACjB,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC","sourcesContent":["import {ZomeViewModel} from \"@ddd-qc/lit-happ\";\nimport {Profile} from \"./bindings/profiles.types\";\nimport {AgentPubKeyB64, decodeHashFromBase64, encodeHashToBase64} from \"@holochain/client\";\nimport {ProfilesProxy} from \"./bindings/profiles.proxy\";\nimport {decode} from \"@msgpack/msgpack\";\nimport {GetStrategy} from \"@holochain-open-dev/core-types\";\n\n\n/** */\nexport type ProfilesPerspective = {\n /* AgentPubKeyB64 -> Profile */\n profiles: Record<AgentPubKeyB64, Profile>,\n ///* AgentPubKeyB64 -> Profile hash */\n //profile_ahs: Record<AgentPubKeyB64, ActionHashB64>,\n\n /** Nickname -> AgentPubKeyB64 */\n reversed: Record<string, AgentPubKeyB64>,\n}\n\n\n/**\n *\n */\nexport class ProfilesZvm extends ZomeViewModel {\n\n static override readonly ZOME_PROXY = ProfilesProxy;\n get zomeProxy(): ProfilesProxy {return this._zomeProxy as ProfilesProxy;}\n\n\n /** */\n override async initializePerspectiveFromLocal(): Promise<void> {\n await this.probeAllProfiles(GetStrategy.Local);\n }\n\n /** */\n override async initializePerspectiveFromNetwork(): Promise<void> {\n await this.probeAllProfiles(GetStrategy.Network);\n }\n\n /** */\n override probeAllInner(strategy: GetStrategy) {\n this.probeAllProfiles(strategy)\n .then((res) => console.trace(\"probeAllProfiles() finished: \", res.length))\n }\n\n /** -- Perspective -- */\n\n /* */\n get perspective(): ProfilesPerspective {\n const pers: ProfilesPerspective = {\n profiles: this._profiles,\n reversed: this._reversed,\n //profile_ahs: this._profile_ahs,\n };\n return pers;\n }\n\n private _profiles: Record<AgentPubKeyB64, Profile> = {};\n //private _profile_ahs: Record<AgentPubKeyB64, ActionHashB64> = {};\n private _reversed: Record<string, AgentPubKeyB64> = {};\n\n\n getMyProfile(): Profile | undefined { return this._profiles[this.cell.address.agentId.b64] }\n\n getProfile(agent: AgentPubKeyB64): Profile | undefined {return this._profiles[agent]}\n\n //getProfileHash(agent: AgentPubKeyB64): ActionHashB64 | undefined {return this._profile_ahs[agent]}\n\n getAgents(): AgentPubKeyB64[] { return Object.keys(this._profiles)}\n\n getNames(): string[] { return Object.keys(this._reversed)}\n\n\n /** Dump perspective as JSON */\n exportPerspective(): string {\n //console.log(\"exportPerspective()\", perspMat);\n return JSON.stringify(this._profiles, null, 2);\n }\n\n\n /** */\n importPerspective(json: string, _mapping?: Object) {\n const profiles = JSON.parse(json) as Record<AgentPubKeyB64, Profile>;\n for (const [pubKey, profileMat] of Object.entries(profiles)) {\n this.storeProfile(pubKey, profileMat);\n }\n }\n\n /** -- Methods -- */\n\n /* */\n findProfiles(names: string[]): AgentPubKeyB64[] {\n let res: AgentPubKeyB64[] = []\n for (const name of names) {\n if (this._reversed[name]) {\n res.push(this._reversed[name]!)\n }\n }\n return res;\n }\n\n\n /** */\n async probeAllProfiles(_strategy: GetStrategy): Promise<Record<AgentPubKeyB64, Profile>> {\n let allAgents;\n /** Attempt a retry on fail as this can create an entry (path anchor) and generate a 'head has moved' error */\n try {\n allAgents = await this.zomeProxy.getAgentsWithProfile();\n } catch(e) {\n allAgents = await this.zomeProxy.getAgentsWithProfile();\n }\n for (const agentPubKey of allAgents) {\n const maybeProfile = await this.zomeProxy.getAgentProfile(agentPubKey);\n if (!maybeProfile) {\n continue;\n }\n const profile: Profile = decode((maybeProfile.entry as any).Present.entry) as Profile;\n this.storeProfile(encodeHashToBase64(agentPubKey), profile);\n }\n this.notifySubscribers();\n return this._profiles;\n }\n\n\n /** */\n storeProfile(pubKeyB64: AgentPubKeyB64, profile: Profile) {\n this._profiles[pubKeyB64] = profile;\n this._reversed[profile.nickname] = pubKeyB64;\n this.notifySubscribers();\n }\n\n\n /** */\n async probeProfile(pubKeyB64: AgentPubKeyB64): Promise<Profile | undefined> {\n const maybeProfile = await this.zomeProxy.getAgentProfile(decodeHashFromBase64(pubKeyB64));\n console.log(\"probeProfile() maybeProfile\", maybeProfile);\n if (!maybeProfile) {\n return;\n }\n // const profileEntry: any = decode((maybeProfile.entry as any).Present.entry);\n // console.log(\"probeProfile() profileEntry\", profileEntry);\n //const profile: Profile = decode(profileEntry.record.entry.Present.entry) as Profile;\n const profile: Profile = decode((maybeProfile.entry as any).Present.entry) as Profile;\n console.log(\"probeProfile() profile\", profile);\n this.storeProfile(pubKeyB64, profile);\n return profile;\n }\n\n\n /** */\n async createMyProfile(profile: Profile): Promise<void> {\n /*const record =*/ await this.zomeProxy.createProfile(profile);\n this.storeProfile(this.cell.address.agentId.b64, profile);\n }\n\n\n /** */\n async updateMyProfile(profile: Profile): Promise<void> {\n /*const record =*/ await this.zomeProxy.updateProfile(profile);\n this.storeProfile(this.cell.address.agentId.b64, profile);\n }\n\n}\n"]}
|
|
@@ -9,8 +9,9 @@ export declare class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
9
9
|
get zomeProxy(): ProfilesAltProxy;
|
|
10
10
|
comparable(): Object;
|
|
11
11
|
hasChanged(): boolean;
|
|
12
|
+
initializePerspectiveFromLocal(): Promise<void>;
|
|
12
13
|
initializePerspectiveFromNetwork(): Promise<void>;
|
|
13
|
-
probeAllInner(): void;
|
|
14
|
+
probeAllInner(strategy: GetStrategy): void;
|
|
14
15
|
get perspective(): ProfilesAltPerspective;
|
|
15
16
|
private _perspective;
|
|
16
17
|
getMyProfile(): Profile | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.zvm.d.ts","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,OAAO,EAGP,YAAY,EAEZ,wBAAwB,EAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,aAAa,EAAC,MAAM,gDAAgD,CAAC;AAG7E,OAAO,EAEH,sBAAsB,EAGzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAM3D,qBAAa,cAAe,SAAQ,wBAAwB;IAI1D,gBAAyB,UAAU,0BAAoB;IACvD,IAAI,SAAS,IAAI,gBAAgB,CAA8C;IAItE,UAAU,IAAI,MAAM;IASpB,UAAU,IAAI,OAAO;
|
|
1
|
+
{"version":3,"file":"profilesAlt.zvm.d.ts","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,OAAO,EAGP,YAAY,EAEZ,wBAAwB,EAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,aAAa,EAAC,MAAM,gDAAgD,CAAC;AAG7E,OAAO,EAEH,sBAAsB,EAGzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAM3D,qBAAa,cAAe,SAAQ,wBAAwB;IAI1D,gBAAyB,UAAU,0BAAoB;IACvD,IAAI,SAAS,IAAI,gBAAgB,CAA8C;IAItE,UAAU,IAAI,MAAM;IASpB,UAAU,IAAI,OAAO;IAYf,8BAA8B,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/C,gCAAgC,IAAI,OAAO,CAAC,IAAI,CAAC;IAMvD,aAAa,CAAC,QAAQ,EAAE,WAAW;IAM5C,IAAI,WAAW,IAAI,sBAAsB,CAExC;IAKD,OAAO,CAAC,YAAY,CAAsE;IAK1F,YAAY,IAAI,OAAO,GAAG,SAAS;IASpB,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BnE,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO;IAe9D,gBAAgB,CAAC,QAAQ,EAAE,WAAW;IAQtC,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAgB3D,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhD,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhD,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhE,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAQtE,MAAM,IAAI,MAAM;IAOhB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO;CAoBzC"}
|
package/dist/profilesAlt.zvm.js
CHANGED
|
@@ -34,11 +34,14 @@ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
34
34
|
}
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
|
+
async initializePerspectiveFromLocal() {
|
|
38
|
+
await this.probeAllProfiles(GetStrategy.Local);
|
|
39
|
+
}
|
|
37
40
|
async initializePerspectiveFromNetwork() {
|
|
38
41
|
await this.probeAllProfiles(GetStrategy.Network);
|
|
39
42
|
}
|
|
40
|
-
probeAllInner() {
|
|
41
|
-
this.probeAllProfiles(
|
|
43
|
+
probeAllInner(strategy) {
|
|
44
|
+
this.probeAllProfiles(strategy);
|
|
42
45
|
}
|
|
43
46
|
get perspective() {
|
|
44
47
|
return this._perspective.readonly;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.zvm.js","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,OAAO,EACP,OAAO,EACP,aAAa,EAEb,eAAe,EACf,wBAAwB,EAC3B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAGH,6BAA6B,EAEhC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAM3D,MAAM,OAAO,cAAe,SAAQ,wBAAwB;IAA5D;;QAkDU,iBAAY,GAAkC,IAAI,6BAA6B,EAAE,CAAC;IAqI5F,CAAC;aAnL0B,eAAU,GAAG,gBAAgB,AAAnB,CAAoB;IACvD,IAAI,SAAS,KAAsB,OAAO,IAAI,CAAC,UAA8B,CAAC,CAAA,CAAC;IAItE,UAAU;QACjB,MAAM,GAAG,GAA0B;YACjC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI;YACnD,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAChF,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC;IAGQ,UAAU;QACjB,MAAM,OAAO,GAAG,IAA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C,YAAY,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC;IAID,MAAM,CAAC,IAAY,EAAE,UAAmB;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,CAAwB,CAAC;QACxE,IAAI,UAAU,EAAE;YACd,KAAK,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,EAAE;gBAC9D,OAAO,CAAC,GAAG,CAAC,yCAAyC,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACxF,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBACpD,IAAI,KAAK,EAAE;oBACC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;iBAChD;qBAAM;oBACL,IAAI,KAAK,IAAI,OAAO,EAAE;wBACpB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;qBACtC;iBACF;aACF;YACD,OAAO;SACR;QAED,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpC,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC","sourcesContent":["import {\n ActionId,\n AgentId,\n EntryId,\n holoIdReviver,\n LinkPulseMat,\n StateChangeType,\n ZomeViewModelWithSignals\n} from \"@ddd-qc/lit-happ\";\nimport {Profile} from \"./bindings/profiles.types\";\nimport {decode} from \"@msgpack/msgpack\";\nimport {ProfilesAltProxy} from \"./bindings/profilesAlt.proxy\";\nimport {EntryPulseMat} from \"@ddd-qc/lit-happ/dist/ZomeViewModelWithSignals\";\nimport {ProfilesLinkType} from \"./bindings/profiles.integrity\";\nimport {ProfilesAltUnitEnum} from \"./bindings/profilesAlt.integrity\";\nimport {\n ProfilesAltComparable,\n ProfilesAltPerspective,\n ProfilesAltPerspectiveMutable,\n ProfilesAltSnapshot\n} from \"./profilesAlt.perspective\";\nimport {GetStrategy} from \"@holochain-open-dev/core-types\";\n\n\n/**\n *\n */\nexport class ProfilesAltZvm extends ZomeViewModelWithSignals {\n\n /** -- Concret -- */\n\n static override readonly ZOME_PROXY = ProfilesAltProxy;\n get zomeProxy(): ProfilesAltProxy {return this._zomeProxy as ProfilesAltProxy;}\n\n\n /** */\n override comparable(): Object {\n const res: ProfilesAltComparable = {\n profileCount: this._perspective.profileByAgent.size,\n profiles: Array.from(this.perspective.profiles.values()).map((pair) => pair[0]),\n };\n return res;\n }\n\n /* */\n override hasChanged(): boolean {\n const current = this.comparable() as ProfilesAltComparable;\n const prev = this._previousPerspective as ProfilesAltComparable;\n if (!prev) { return true }\n if (current.profileCount != prev.profileCount) return true;\n for (let i = 0; i < current.profileCount; i+= 1) {\n if (JSON.stringify(current.profiles[i]) != JSON.stringify(prev.profiles[i])) { return true }\n }\n return false;\n }\n\n\n /** */\n override async initializePerspectiveFromNetwork(): Promise<void> {\n await this.probeAllProfiles(GetStrategy.Network);\n }\n\n\n /** */\n override probeAllInner() {\n this.probeAllProfiles(GetStrategy.Network);\n }\n\n\n /* */\n get perspective(): ProfilesAltPerspective {\n return this._perspective.readonly;\n }\n\n\n /** -- */\n\n private _perspective: ProfilesAltPerspectiveMutable = new ProfilesAltPerspectiveMutable();\n\n\n /** -- Getters -- */\n\n getMyProfile(): Profile | undefined {\n return this._perspective.getProfile(this.cell.address.agentId);\n }\n\n\n\n /** -- Signals -- */\n\n /** */\n override async handleLinkPulse(pulse: LinkPulseMat, _from: AgentId): Promise<void> {\n switch (pulse.link_type) {\n case ProfilesLinkType.PrefixPath:\n case ProfilesLinkType.PathToAgent: {\n const agentEh = new EntryId(pulse.target.b64);\n const agentId = AgentId.from(agentEh);\n if (pulse.state != StateChangeType.Delete) {\n await this.findProfile(agentId);\n }\n }\n break;\n case ProfilesLinkType.AgentToProfile: {\n const agentEh = new EntryId(pulse.base.b64); // Make sure it's an EntryHash\n const agentId = AgentId.from(agentEh);\n const profileAh = ActionId.from(pulse.target);\n if (pulse.state == StateChangeType.Delete) {\n this._perspective.unstoreAgentProfile(agentId, profileAh)\n } else {\n this._perspective.storeAgentProfile(agentId, profileAh)\n }\n }\n break;\n }\n }\n\n\n /** */\n override async handleEntryPulse(pulse: EntryPulseMat, _from: AgentId) {\n switch (pulse.entryType) {\n case ProfilesAltUnitEnum.Profile:\n const profile = decode(pulse.bytes) as Profile;\n if (pulse.state != StateChangeType.Delete) {\n this._perspective.storeProfile(pulse.ah, profile, pulse.ts);\n }\n break;\n }\n }\n\n\n /** -- Methods -- */\n\n /** */\n async probeAllProfiles(strategy: GetStrategy)/*: Promise<Record<AgentPubKeyB64, ProfileMat>>*/ {\n try {\n await this.zomeProxy.probeProfiles(strategy);\n } catch(e) {}\n }\n\n\n /** */\n async findProfile(agentId: AgentId): Promise<Profile | undefined> {\n try {\n const maybeProfilePair = await this.zomeProxy.findProfile(agentId.hash);\n console.log(\"findProfile()\", agentId, maybeProfilePair);\n if (!maybeProfilePair) {\n return;\n }\n return maybeProfilePair[1];\n } catch(e) {\n return undefined;\n }\n return undefined;\n }\n\n\n /** */\n async createMyProfile(profile: Profile): Promise<void> {\n await this.zomeProxy.createProfile([profile, this.cell.address.agentId.hash]);\n }\n\n\n /** */\n async updateMyProfile(profile: Profile): Promise<void> {\n await this.zomeProxy.updateProfile([profile, this.cell.address.agentId.hash]);\n }\n\n\n /** */\n async createProfile(profile: Profile, agentId: AgentId): Promise<void> {\n await this.zomeProxy.createProfile([profile, agentId.hash]);\n }\n\n\n /** */\n async updateProfile(profile: Profile, agentId: AgentId): Promise<void> {\n await this.zomeProxy.updateProfile([profile, agentId.hash]);\n }\n\n\n /** -- Import / Export -- */\n\n /** Dump perspective as JSON */\n export(): string {\n const snapshot = this._perspective.makeSnapshot();\n return JSON.stringify(snapshot, null, 2);\n }\n\n\n /** */\n import(json: string, canPublish: boolean) {\n const snapshot = JSON.parse(json, holoIdReviver) as ProfilesAltSnapshot;\n if (canPublish) {\n for (const [agentId, _profileAh, profile, _ts] of snapshot.all) {\n console.log(\"ProfilesAltZvm.import() publish profile\", agentId.short, profile.nickname);\n const maybe = this._perspective.getProfile(agentId);\n if (maybe) {\n /*await*/ this.createProfile(profile, agentId);\n } else {\n if (maybe != profile) {\n this.updateProfile(profile, agentId);\n }\n }\n }\n return;\n }\n /** */\n this._perspective.restore(snapshot);\n this.notifySubscribers();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"profilesAlt.zvm.js","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,OAAO,EACP,OAAO,EACP,aAAa,EAEb,eAAe,EACf,wBAAwB,EAC3B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAGH,6BAA6B,EAEhC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAM3D,MAAM,OAAO,cAAe,SAAQ,wBAAwB;IAA5D;;QAsDU,iBAAY,GAAkC,IAAI,6BAA6B,EAAE,CAAC;IAqI5F,CAAC;aAvL0B,eAAU,GAAG,gBAAgB,AAAnB,CAAoB;IACvD,IAAI,SAAS,KAAsB,OAAO,IAAI,CAAC,UAA8B,CAAC,CAAA,CAAC;IAItE,UAAU;QACjB,MAAM,GAAG,GAA0B;YACjC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI;YACnD,QAAQ,EAAE,KAAK,CA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esContent":["import {\n ActionId,\n AgentId,\n EntryId,\n holoIdReviver,\n LinkPulseMat,\n StateChangeType,\n ZomeViewModelWithSignals\n} from \"@ddd-qc/lit-happ\";\nimport {Profile} from \"./bindings/profiles.types\";\nimport {decode} from \"@msgpack/msgpack\";\nimport {ProfilesAltProxy} from \"./bindings/profilesAlt.proxy\";\nimport {EntryPulseMat} from \"@ddd-qc/lit-happ/dist/ZomeViewModelWithSignals\";\nimport {ProfilesLinkType} from \"./bindings/profiles.integrity\";\nimport {ProfilesAltUnitEnum} from \"./bindings/profilesAlt.integrity\";\nimport {\n ProfilesAltComparable,\n ProfilesAltPerspective,\n ProfilesAltPerspectiveMutable,\n ProfilesAltSnapshot\n} from \"./profilesAlt.perspective\";\nimport {GetStrategy} from \"@holochain-open-dev/core-types\";\n\n\n/**\n *\n */\nexport class ProfilesAltZvm extends ZomeViewModelWithSignals {\n\n /** -- Concret -- */\n\n static override readonly ZOME_PROXY = ProfilesAltProxy;\n get zomeProxy(): ProfilesAltProxy {return this._zomeProxy as ProfilesAltProxy;}\n\n\n /** */\n override comparable(): Object {\n const res: ProfilesAltComparable = {\n profileCount: this._perspective.profileByAgent.size,\n profiles: Array.from(this.perspective.profiles.values()).map((pair) => pair[0]),\n };\n return res;\n }\n\n /* */\n override hasChanged(): boolean {\n const current = this.comparable() as ProfilesAltComparable;\n const prev = this._previousPerspective as ProfilesAltComparable;\n if (!prev) { return true }\n if (current.profileCount != prev.profileCount) return true;\n for (let i = 0; i < current.profileCount; i+= 1) {\n if (JSON.stringify(current.profiles[i]) != JSON.stringify(prev.profiles[i])) { return true }\n }\n return false;\n }\n\n /** */\n override async initializePerspectiveFromLocal(): Promise<void> {\n await this.probeAllProfiles(GetStrategy.Local);\n }\n\n /** */\n override async initializePerspectiveFromNetwork(): Promise<void> {\n await this.probeAllProfiles(GetStrategy.Network);\n }\n\n\n /** */\n override probeAllInner(strategy: GetStrategy) {\n this.probeAllProfiles(strategy);\n }\n\n\n /* */\n get perspective(): ProfilesAltPerspective {\n return this._perspective.readonly;\n }\n\n\n /** -- */\n\n private _perspective: ProfilesAltPerspectiveMutable = new ProfilesAltPerspectiveMutable();\n\n\n /** -- Getters -- */\n\n getMyProfile(): Profile | undefined {\n return this._perspective.getProfile(this.cell.address.agentId);\n }\n\n\n\n /** -- Signals -- */\n\n /** */\n override async handleLinkPulse(pulse: LinkPulseMat, _from: AgentId): Promise<void> {\n switch (pulse.link_type) {\n case ProfilesLinkType.PrefixPath:\n case ProfilesLinkType.PathToAgent: {\n const agentEh = new EntryId(pulse.target.b64);\n const agentId = AgentId.from(agentEh);\n if (pulse.state != StateChangeType.Delete) {\n await this.findProfile(agentId);\n }\n }\n break;\n case ProfilesLinkType.AgentToProfile: {\n const agentEh = new EntryId(pulse.base.b64); // Make sure it's an EntryHash\n const agentId = AgentId.from(agentEh);\n const profileAh = ActionId.from(pulse.target);\n if (pulse.state == StateChangeType.Delete) {\n this._perspective.unstoreAgentProfile(agentId, profileAh)\n } else {\n this._perspective.storeAgentProfile(agentId, profileAh)\n }\n }\n break;\n }\n }\n\n\n /** */\n override async handleEntryPulse(pulse: EntryPulseMat, _from: AgentId) {\n switch (pulse.entryType) {\n case ProfilesAltUnitEnum.Profile:\n const profile = decode(pulse.bytes) as Profile;\n if (pulse.state != StateChangeType.Delete) {\n this._perspective.storeProfile(pulse.ah, profile, pulse.ts);\n }\n break;\n }\n }\n\n\n /** -- Methods -- */\n\n /** */\n async probeAllProfiles(strategy: GetStrategy)/*: Promise<Record<AgentPubKeyB64, ProfileMat>>*/ {\n try {\n await this.zomeProxy.probeProfiles(strategy);\n } catch(e) {}\n }\n\n\n /** */\n async findProfile(agentId: AgentId): Promise<Profile | undefined> {\n try {\n const maybeProfilePair = await this.zomeProxy.findProfile(agentId.hash);\n console.log(\"findProfile()\", agentId, maybeProfilePair);\n if (!maybeProfilePair) {\n return;\n }\n return maybeProfilePair[1];\n } catch(e) {\n return undefined;\n }\n return undefined;\n }\n\n\n /** */\n async createMyProfile(profile: Profile): Promise<void> {\n await this.zomeProxy.createProfile([profile, this.cell.address.agentId.hash]);\n }\n\n\n /** */\n async updateMyProfile(profile: Profile): Promise<void> {\n await this.zomeProxy.updateProfile([profile, this.cell.address.agentId.hash]);\n }\n\n\n /** */\n async createProfile(profile: Profile, agentId: AgentId): Promise<void> {\n await this.zomeProxy.createProfile([profile, agentId.hash]);\n }\n\n\n /** */\n async updateProfile(profile: Profile, agentId: AgentId): Promise<void> {\n await this.zomeProxy.updateProfile([profile, agentId.hash]);\n }\n\n\n /** -- Import / Export -- */\n\n /** Dump perspective as JSON */\n export(): string {\n const snapshot = this._perspective.makeSnapshot();\n return JSON.stringify(snapshot, null, 2);\n }\n\n\n /** */\n import(json: string, canPublish: boolean) {\n const snapshot = JSON.parse(json, holoIdReviver) as ProfilesAltSnapshot;\n if (canPublish) {\n for (const [agentId, _profileAh, profile, _ts] of snapshot.all) {\n console.log(\"ProfilesAltZvm.import() publish profile\", agentId.short, profile.nickname);\n const maybe = this._perspective.getProfile(agentId);\n if (maybe) {\n /*await*/ this.createProfile(profile, agentId);\n } else {\n if (maybe != profile) {\n this.updateProfile(profile, agentId);\n }\n }\n }\n return;\n }\n /** */\n this._perspective.restore(snapshot);\n this.notifySubscribers();\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-qc/profiles-dvm",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.4",
|
|
4
4
|
"description": "DnaViewModel implementation for the Profiles zome.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"typescript": "~5.2.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@holochain/client": "^0.20.0",
|
|
33
34
|
"@ddd-qc/lit-happ": "file:../lit-happ",
|
|
34
35
|
"@holochain-open-dev/elements": "^0.600.0-dev.0",
|
|
35
|
-
"@holochain/client": "^0.20.0-dev.2",
|
|
36
36
|
"@msgpack/msgpack": "^3.1.1",
|
|
37
37
|
"lit": "3.0.2"
|
|
38
38
|
},
|