@ddd-qc/profiles-dvm 0.22.0 → 0.22.1

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/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export * from "./bindings/profiles.types";
2
2
  export * from "./bindings/profiles.proxy";
3
3
  export * from "./profiles.zvm";
4
+ export * from "./bindings/profilesAlt.proxy";
5
+ export * from "./profilesAlt.zvm";
4
6
  export * from "./profiles.dvm";
5
7
  export * from "./utils";
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  export * from "./bindings/profiles.types";
2
2
  export * from "./bindings/profiles.proxy";
3
3
  export * from "./profiles.zvm";
4
+ export * from "./bindings/profilesAlt.proxy";
5
+ export * from "./profilesAlt.zvm";
4
6
  export * from "./profiles.dvm";
5
7
  export * from "./utils";
6
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AAEzC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA","sourcesContent":["export * from \"./bindings/profiles.types\"\nexport * from \"./bindings/profiles.proxy\"\n\nexport * from \"./profiles.zvm\"\nexport * from \"./profiles.dvm\"\nexport * from \"./utils\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gBAAgB,CAAA;AAE9B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,mBAAmB,CAAA;AAEjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA","sourcesContent":["export * from \"./bindings/profiles.types\"\nexport * from \"./bindings/profiles.proxy\"\nexport * from \"./profiles.zvm\"\n\nexport * from \"./bindings/profilesAlt.proxy\"\nexport * from \"./profilesAlt.zvm\"\n\nexport * from \"./profiles.dvm\"\nexport * from \"./utils\"\n"]}
@@ -3,7 +3,7 @@ import { Profile as ProfileMat } from "./bindings/profiles.types";
3
3
  import { AgentPubKeyB64 } from "@holochain/client";
4
4
  import { ProfilesAltProxy } from "./bindings/profilesAlt.proxy";
5
5
  /** */
6
- export interface ProfilesPerspective {
6
+ export interface ProfilesAltPerspective {
7
7
  profiles: Record<AgentPubKeyB64, ProfileMat>;
8
8
  /** Nickname -> AgentPubKeyB64 */
9
9
  reversed: Record<string, AgentPubKeyB64>;
@@ -20,7 +20,7 @@ export declare class ProfilesAltZvm extends ZomeViewModel {
20
20
  /** */
21
21
  probeAllInner(): void;
22
22
  /** -- Perspective -- */
23
- get perspective(): ProfilesPerspective;
23
+ get perspective(): ProfilesAltPerspective;
24
24
  private _profiles;
25
25
  private _reversed;
26
26
  getMyProfile(): ProfileMat | undefined;
@@ -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,EAA8B,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AACxG,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,EAAE,CAAC;QAC3D,mEAAmE;QAC3D,cAAS,GAAmC,EAAE,CAAC;IAqHzD,CAAC;IAtJC,IAAI,SAAS,KAAsB,OAAO,IAAI,CAAC,UAA8B,CAAC,CAAA,CAAC;IAG/E,KAAK;IACK,UAAU;QAClB,OAAO;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IA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EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9F,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,aAAa,CAAC,OAAmB,EAAE,KAAqB;QAC5D,kBAAkB,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9F,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;;AArJe,yBAAU,GAAG,gBAAgB,AAAnB,CAAoB","sourcesContent":["import {ZomeViewModel} from \"@ddd-qc/lit-happ\";\nimport {Profile as ProfileMat} from \"./bindings/profiles.types\";\nimport {AgentPubKey, AgentPubKeyB64, decodeHashFromBase64, encodeHashToBase64} from \"@holochain/client\";\nimport {decode} from \"@msgpack/msgpack\";\nimport {ProfilesAltProxy} from \"./bindings/profilesAlt.proxy\";\n\n\n/** */\nexport interface ProfilesPerspective {\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(): ProfilesPerspective {\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 importPerspective(json: string, mapping?: Object) {\n const profiles = JSON.parse(json) as Record<AgentPubKeyB64, ProfileMat>;\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 = []\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"]}
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,MA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ACN,KAAK,CAAC,eAAe,CAAC,OAAmB;QACvC,kBAAkB,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAC9G,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,aAAa,CAAC,OAAmB,EAAE,KAAqB;QAC5D,kBAAkB,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9F,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,aAAa,CAAC,OAAmB,EAAE,KAAqB;QAC5D,kBAAkB,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9F,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;;AArJe,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 importPerspective(json: string, mapping?: Object) {\n const profiles = JSON.parse(json) as Record<AgentPubKeyB64, ProfileMat>;\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 = []\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-qc/profiles-dvm",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "description": "DnaViewModel implementation for the Profiles zome.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",