@ddd-qc/profiles-dvm 0.34.1 → 0.34.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.
@@ -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;IAYf,8BAA8B,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/C,gCAAgC,IAAI,OAAO,CAAC,IAAI,CAAC;IAMvD,aAAa,CAAC,QAAQ,EAAE,WAAW;IAO5C,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;IAgB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ASpB,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;CAyBzC"}
@@ -127,15 +127,21 @@ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
127
127
  if (canPublish) {
128
128
  for (const [agentId, _profileAh, profile, _ts] of snapshot.all) {
129
129
  console.debug("ProfilesAltZvm.import() publish profile", agentId.short, profile.nickname);
130
- const maybe = this._perspective.getProfile(agentId);
131
- if (maybe) {
132
- this.createProfile(profile, agentId);
133
- }
134
- else {
135
- if (maybe != profile) {
136
- this.updateProfile(profile, agentId);
130
+ profile.fields["imported"] = "true";
131
+ try {
132
+ const maybe = this._perspective.getProfile(agentId);
133
+ if (maybe) {
134
+ this.createProfile(profile, agentId);
135
+ }
136
+ else {
137
+ if (maybe != profile) {
138
+ this.updateProfile(profile, agentId);
139
+ }
137
140
  }
138
141
  }
142
+ catch (e) {
143
+ console.error("ProfilesAltZvm.import()", e);
144
+ }
139
145
  }
140
146
  return;
141
147
  }
@@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M;QACJ,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,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,KAAK,CAAC,yCAAyC,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC1F,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 /** -- Concrete -- */\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 as [Profile, Number])[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 .then(() => console.debug(\"ProfilesAltZvm.probeAllProfiles() finished.\"))\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.debug(\"ProfilesAltZvm.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.debug(\"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;;QAuDU,iBAAY,GAAkC,IAAI,6BAA6B,EAAE,CAAC;IA0I5F,CAAC;aA7L0B,eAAU,GAAG,gBAAgB,AAAnB,CAA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I,KAAK,EAAE;wBACG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;qBAClD;yBAAM;wBACH,IAAI,KAAK,IAAI,OAAO,EAAE;4BAClB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;yBACxC;qBACJ;iBACJ;gBAAC,OAAO,CAAC,EAAE;oBACR,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC;iBAC/C;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 /** -- Concrete -- */\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 as [Profile, Number])[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 .then(() => console.debug(\"ProfilesAltZvm.probeAllProfiles() finished.\"))\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.debug(\"ProfilesAltZvm.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.debug(\"ProfilesAltZvm.import() publish profile\", agentId.short, profile.nickname);\n profile.fields[\"imported\"] = \"true\";\n try {\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 } catch (e) {\n console.error(\"ProfilesAltZvm.import()\", e);\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.34.1",
3
+ "version": "0.34.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.2",
33
+ "@holochain/client": "=0.20.4-rc.0",
34
34
  "@ddd-qc/lit-happ": "file:../lit-happ",
35
- "@holochain-open-dev/elements": "^0.600.0",
35
+ "@holochain-open-dev/elements": "^0.601.0",
36
36
  "@msgpack/msgpack": "^3.1.1",
37
37
  "lit": "3.0.2"
38
38
  },