@ddd-qc/profiles-dvm 0.22.3 → 0.22.5
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.
|
@@ -30,7 +30,7 @@ export declare class ProfilesAltZvm extends ZomeViewModel {
|
|
|
30
30
|
/** Dump perspective as JSON */
|
|
31
31
|
exportPerspective(): string;
|
|
32
32
|
/** */
|
|
33
|
-
importPerspective(json: string, canPublish: boolean): void
|
|
33
|
+
importPerspective(json: string, canPublish: boolean): Promise<void>;
|
|
34
34
|
/** -- Methods -- */
|
|
35
35
|
findProfiles(names: string[]): AgentPubKeyB64[];
|
|
36
36
|
/** */
|
package/dist/profilesAlt.zvm.js
CHANGED
|
@@ -46,11 +46,11 @@ export class ProfilesAltZvm extends ZomeViewModel {
|
|
|
46
46
|
return JSON.stringify(this._profiles, null, 2);
|
|
47
47
|
}
|
|
48
48
|
/** */
|
|
49
|
-
importPerspective(json, canPublish) {
|
|
49
|
+
async importPerspective(json, canPublish) {
|
|
50
50
|
const profiles = JSON.parse(json);
|
|
51
51
|
if (canPublish) {
|
|
52
52
|
for (const [pubKey, profileMat] of Object.entries(profiles)) {
|
|
53
|
-
|
|
53
|
+
await this.createProfile(profileMat, pubKey);
|
|
54
54
|
}
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.zvm.js","sourceRoot":"","sources":["../src/profilesAlt.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,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAe9D;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,aAAa;IAAjD;;QAkCU,cAAS,GAAuC,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CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;;AA9Je,yBAAU,GAAG,gBAAgB,AAAnB,CAAoB","sourcesContent":["import {ZomeViewModel} from \"@ddd-qc/lit-happ\";\nimport {Profile as ProfileMat} from \"./bindings/profiles.types\";\nimport {AgentPubKeyB64, decodeHashFromBase64, encodeHashToBase64} from \"@holochain/client\";\nimport {decode} from \"@msgpack/msgpack\";\nimport {ProfilesAltProxy} from \"./bindings/profilesAlt.proxy\";\n\n\n/** */\nexport interface ProfilesAltPerspective {\n /* AgentPubKeyB64 -> Profile */\n profiles: Record<AgentPubKeyB64, ProfileMat>,\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 ProfilesAltZvm extends ZomeViewModel {\n\n static readonly ZOME_PROXY = ProfilesAltProxy;\n get zomeProxy(): ProfilesAltProxy {return this._zomeProxy as ProfilesAltProxy;}\n\n\n /* */\n protected hasChanged(): boolean {\n // TODO\n return true;\n }\n\n\n /** */\n async initializePerspectiveOnline(): Promise<void> {\n await this.probeAllProfiles();\n }\n\n /** */\n probeAllInner() {\n this.probeAllProfiles();\n }\n\n /** -- Perspective -- */\n\n /* */\n get perspective(): ProfilesAltPerspective {\n return {\n profiles: this._profiles,\n reversed: this._reversed,\n //profile_ahs: this._profile_ahs,\n };\n }\n\n private _profiles: Record<AgentPubKeyB64, ProfileMat> = {};\n //private _profile_ahs: Record<AgentPubKeyB64, ActionHashB64> = {};\n private _reversed: Record<string, AgentPubKeyB64> = {};\n\n\n getMyProfile(): ProfileMat | undefined { return this._profiles[this.cell.agentPubKey] }\n\n getProfile(agent: AgentPubKeyB64): ProfileMat | 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 async importPerspective(json: string, canPublish: boolean) {\n const profiles = JSON.parse(json) as Record<AgentPubKeyB64, ProfileMat>;\n\n if (canPublish) {\n for (const [pubKey, profileMat] of Object.entries(profiles)) {\n await this.createProfile(profileMat, pubKey);\n }\n return;\n }\n\n for (const [pubKey, profileMat] of Object.entries(profiles)) {\n this.storeProfile(pubKey, profileMat);\n }\n }\n\n\n /** -- Methods -- */\n\n /* */\n findProfiles(names: string[]): AgentPubKeyB64[] {\n let res = []\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(): Promise<Record<AgentPubKeyB64, ProfileMat>> {\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.getProfile(agentPubKey);\n if (!maybeProfile) {\n continue;\n }\n const profile: ProfileMat = decode((maybeProfile.entry as any).Present.entry) as ProfileMat;\n this.storeProfile(encodeHashToBase64(agentPubKey), profile);\n }\n this.notifySubscribers();\n return this._profiles;\n }\n\n\n /** */\n storeProfile(pubKeyB64: AgentPubKeyB64, profile: ProfileMat) {\n this._profiles[pubKeyB64] = profile;\n this._reversed[profile.nickname] = pubKeyB64;\n this.notifySubscribers();\n }\n\n\n /** */\n async probeProfile(pubKeyB64: AgentPubKeyB64): Promise<ProfileMat | undefined> {\n const maybeProfile = await this.zomeProxy.getProfile(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: ProfileMat = decode(profileEntry.record.entry.Present.entry) as ProfileMat;\n const profile: ProfileMat = decode((maybeProfile.entry as any).Present.entry) as ProfileMat;\n console.log(\"probeProfile() profile\", profile);\n this.storeProfile(pubKeyB64, profile);\n return profile;\n }\n\n\n /** */\n async createMyProfile(profile: ProfileMat): Promise<void> {\n /*const record =*/ await this.zomeProxy.createProfile([profile, decodeHashFromBase64(this.cell.agentPubKey)]);\n this.storeProfile(this.cell.agentPubKey, profile);\n }\n\n\n /** */\n async updateMyProfile(profile: ProfileMat): Promise<void> {\n /*const record =*/ await this.zomeProxy.updateProfile([profile, decodeHashFromBase64(this.cell.agentPubKey)]);\n this.storeProfile(this.cell.agentPubKey, profile);\n }\n\n\n /** */\n async createProfile(profile: ProfileMat, agent: AgentPubKeyB64): Promise<void> {\n /*const record =*/ await this.zomeProxy.createProfile([profile, decodeHashFromBase64(agent)]);\n this.storeProfile(agent, profile);\n }\n\n\n /** */\n async updateProfile(profile: ProfileMat, agent: AgentPubKeyB64): Promise<void> {\n /*const record =*/ await this.zomeProxy.updateProfile([profile, decodeHashFromBase64(agent)]);\n this.storeProfile(agent, profile);\n }\n\n}\n"]}
|