@ddd-qc/profiles-dvm 0.34.6 → 0.34.7
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/bindings/profilesAlt.fn.d.ts.map +1 -1
- package/dist/bindings/profilesAlt.fn.js +3 -2
- package/dist/bindings/profilesAlt.fn.js.map +1 -1
- package/dist/bindings/profilesAlt.proxy.d.ts +3 -2
- package/dist/bindings/profilesAlt.proxy.d.ts.map +1 -1
- package/dist/bindings/profilesAlt.proxy.js +7 -4
- package/dist/bindings/profilesAlt.proxy.js.map +1 -1
- package/dist/profilesAlt.zvm.js +1 -1
- package/dist/profilesAlt.zvm.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.fn.d.ts","sourceRoot":"","sources":["../../src/bindings/profilesAlt.fn.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAIzD,eAAO,MAAM,wBAAwB,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"profilesAlt.fn.d.ts","sourceRoot":"","sources":["../../src/bindings/profilesAlt.fn.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAIzD,eAAO,MAAM,wBAAwB,EAAE,YAAY,EAYlD,CAAC;AAIF,wBAAgB,qCAAqC,CAAC,QAAQ,EAAE,QAAQ,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,CAMpG;AAID,eAAO,MAAM,wBAAwB,EAAE,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAsD,CAAC"}
|
|
@@ -4,8 +4,9 @@ export const profilesAltFunctionNames = [
|
|
|
4
4
|
"get_dna_info",
|
|
5
5
|
"create_profile",
|
|
6
6
|
"update_profile",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"search_agents_network",
|
|
8
|
+
"find_profile_network",
|
|
9
|
+
"find_profile_local",
|
|
9
10
|
"probe_profiles",
|
|
10
11
|
"cast_tip",
|
|
11
12
|
"synchronize_tip",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.fn.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.fn.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,wBAAwB,GAAmB;IACvD,YAAY;IACZ,eAAe;IACf,cAAc;IACd,gBAAgB;IAChB,gBAAgB;IAChB,
|
|
1
|
+
{"version":3,"file":"profilesAlt.fn.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.fn.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,wBAAwB,GAAmB;IACvD,YAAY;IACZ,eAAe;IACf,cAAc;IACd,gBAAgB;IAChB,gBAAgB;IAChB,uBAAuB;IACvB,sBAAsB;IACtB,oBAAoB;IACpB,gBAAgB;IAChB,UAAU;IACV,iBAAiB;CACjB,CAAC;AAIF,MAAM,UAAU,qCAAqC,CAAC,QAAkB;IACrE,MAAM,GAAG,GAA+B,EAAE,CAAC;IAC3C,KAAK,MAAM,EAAE,IAAI,wBAAwB,EAAE;QACxC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;KAC3B;IACD,OAAO,GAAG,CAAC;AACd,CAAC;AAID,MAAM,CAAC,MAAM,wBAAwB,GAA+B,qCAAqC,CAAC,UAAU,CAAC,CAAC","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {ZomeName, FunctionName} from '@holochain/client';\n\n\n/** Array of all zome function names in \"profilesAlt\" */\nexport const profilesAltFunctionNames: FunctionName[] = [\n\t\"entry_defs\", \n\t\"get_zome_info\", \n\t\"get_dna_info\",\n\t\"create_profile\",\n\t\"update_profile\",\n\t\"search_agents_network\",\n\t\"find_profile_network\",\n\t\"find_profile_local\",\n\t\"probe_profiles\",\n\t\"cast_tip\",\n\t\"synchronize_tip\",\n];\n\n\n/** Generate tuple array of function names with given zomeName */\nexport function generateProfilesAltZomeFunctionsArray(zomeName: ZomeName): [ZomeName, FunctionName][] {\n const fns: [ZomeName, FunctionName][] = [];\n for (const fn of profilesAltFunctionNames) {\n fns.push([zomeName, fn]);\n }\n return fns;\n}\n\n\n/** Tuple array of all zome function names with default zome name \"profiles\" */\nexport const profilesAltZomeFunctions: [ZomeName, FunctionName][] = generateProfilesAltZomeFunctionsArray(\"profiles\");\n"]}
|
|
@@ -12,8 +12,9 @@ export declare class ProfilesAltProxy extends ZomeProxy {
|
|
|
12
12
|
static readonly LINK_TYPES: ProfilesAltLinkType[];
|
|
13
13
|
createProfile(pair: [Profile, AgentArray]): Promise<ActionArray>;
|
|
14
14
|
updateProfile(pair: [Profile, AgentArray]): Promise<ActionArray>;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
searchAgentsNetwork(nicknameFilter: string): Promise<AgentArray[]>;
|
|
16
|
+
findProfileNetwork(agentPubKey: AgentArray): Promise<[ActionArray, Profile] | null>;
|
|
17
|
+
findProfileLocal(agentPubKey: AgentArray): Promise<[ActionArray, Profile] | null>;
|
|
17
18
|
probeProfiles(strategy: GetStrategy): Promise<void>;
|
|
18
19
|
}
|
|
19
20
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.proxy.d.ts","sourceRoot":"","sources":["../../src/bindings/profilesAlt.proxy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,OAAO,EAAG,MAAM,qBAAqB,CAAC;AA8C1D,KAAK,UAAU,GAAG,UAAU,CAAC;AAQ7B,KAAK,WAAW,GAAG,UAAU,CAAC;AAS9B,OAAO,EASkE,WAAW,EAOnF,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAC,mBAAmB,EAAC,MAAM,yB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,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAInF,gBAAgB,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAIjF,aAAa,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1D"}
|
|
@@ -13,11 +13,14 @@ export class ProfilesAltProxy extends ZomeProxy {
|
|
|
13
13
|
async updateProfile(pair) {
|
|
14
14
|
return this.callBlocking('update_profile', pair);
|
|
15
15
|
}
|
|
16
|
-
async
|
|
17
|
-
return this.call('
|
|
16
|
+
async searchAgentsNetwork(nicknameFilter) {
|
|
17
|
+
return this.call('search_agents_network', nicknameFilter);
|
|
18
18
|
}
|
|
19
|
-
async
|
|
20
|
-
return this.call('
|
|
19
|
+
async findProfileNetwork(agentPubKey) {
|
|
20
|
+
return this.call('find_profile_network', agentPubKey);
|
|
21
|
+
}
|
|
22
|
+
async findProfileLocal(agentPubKey) {
|
|
23
|
+
return this.call('find_profile_local', agentPubKey);
|
|
21
24
|
}
|
|
22
25
|
async probeProfiles(strategy) {
|
|
23
26
|
return this.callBlocking('probe_profiles', strategy);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.proxy.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.proxy.ts"],"names":[],"mappings":"AAoFA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,wBAAwB,EAAC,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;AAK5D,MAAM,OAAO,gBAAiB,SAAQ,SAAS;aACpB,sBAAiB,GAAG,UAAU,CAAC;aAC/B,aAAQ,GAAG,wBAAwB,CAAC;a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I,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,WAAuB;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,WAAW,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,WAAuB;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,QAAqB;QACvC,OAAO,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;IACvD,CAAC","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\n// @ts-ignore\nimport {EntryTypes, Profile, } from './profilesAlt.types';\n// @ts-ignore\nimport {\n/** api/common.ts */\n// @ts-ignore\nWebsocketConnectionOptions, WsClientOptions, HolochainError, CloneIdHelper,\n/** types.ts */\n// @ts-ignore\nKitsuneAgent, KitsuneSpace, HoloHashB64, AgentPubKeyB64, DnaHashB64, WasmHashB64, EntryHashB64, ActionHashB64, AnyDhtHashB64, InstalledAppId, Signature, CellId, DnaProperties, RoleName, InstalledCell, Timestamp, HoloHashed, FetchPoolInfo,\n/** hdk/action.ts */\n// @ts-ignore\nSignedAction, SignedActionHashed, RegisterAgentActivity, ActionHashed, ActionType, Action, NewEntryAction, Dna, AgentValidationPkg, InitZomesComplete, CreateLink, DeleteLink, OpenChain, CloseChain, Update, Delete, Create,\n/** hdk/capabilities.ts */\n// @ts-ignore\nCapSecret, CapClaim, GrantedFunctionsType, GrantedFunctions, ZomeCallCapGrant, CapAccess, CapGrant,\n///** hdk/countersigning.ts */\n//CounterSigningSessionData,\n//PreflightRequest,\n//CounterSigningSessionTimes,\n//ActionBase,\n//CounterSigningAgents,\n//PreflightBytes,\n//Role,\n//CountersigningAgentState,\n/** hdk/dht-ops.ts */\n// @ts-ignore\nChainOpType, DhtOp, WarrantOp, ChainOp, Warrant, ChainIntegrityWarrant, ValidationType, ActionHashAndSig,\n/** hdk/entry.ts */\n// @ts-ignore\nEntryVisibility, AppEntryDef, EntryType, EntryContent, Entry,\n/** hdk/record.ts */\n// @ts-ignore\nRecord as HcRecord, RecordEntry as HcRecordEntry,\n/** hdk/link.ts */\n//AnyLinkableHash,\n// @ts-ignore\nZomeIndex, LinkType, LinkTag, RateWeight, RateBucketId, RateUnits, Link,\n/** api/admin/types.ts */\n// @ts-ignore\n// YamlProperties\nZomes, WasmCode, CapGrantInfo, PeerMetaInfo, DisabledAppReason, AppStatus, StemCell, ProvisionedCell, ClonedCell, CellType, CellInfo, AppInfo, MembraneProof, MemproofMap, RoleSettingsMap, RoleSettings, DnaModifiersOpt, DnaModifiers, FunctionName, ZomeName, ZomeDefinition, IntegrityZome, CoordinatorZome, DnaDefinition, ResourceBytes, ResourceMap, CellProvisioningStrategy, CellProvisioning, DnaVersionSpec, DnaVersionFlexible, AppRoleDnaManifest, AppRoleManifest, AppManifest, AppBundle, AppBundleSource, NetworkSeed, AppStatusFilter, AppInterfaceInfo, AgentInfoSigned, ZomeLocation, DnaManifest,\n} from '@holochain/client';\n\n\n/// Simple Hashes\n// @ts-ignore\ntype AgentArray = Uint8Array;\n// @ts-ignore\ntype DnaArray = Uint8Array;\n// @ts-ignore\ntype WasmArray = Uint8Array;\n// @ts-ignore\ntype EntryArray = Uint8Array;\n// @ts-ignore\ntype ActionArray = Uint8Array;\n// @ts-ignore\ntype AnyDhtArray = Uint8Array;\n// @ts-ignore\ntype AnyLinkableArray = Uint8Array;\n// @ts-ignore\ntype ExternalArray = Uint8Array;\n\n// @ts-ignore\nimport {\n/** Common */\n// @ts-ignore\nDhtOpHashB64, DhtOpHash,\n/** DnaFile */\n// @ts-ignore\nDnaFile,\n/** entry */\n// @ts-ignore\nEntryDefLocation, EntryDefLocationType, AppEntryDefLocation, GetOptions, GetStrategy,\n/** entry-details */\n// @ts-ignore\nEntryDetails, RecordDetails, Details, DetailsType, EntryDhtStatus,\n/** Validation */\n// @ts-ignore\nValidationStatus, ValidationReceipt,\n} from '@holochain-open-dev/core-types';\n\nimport {ZomeProxy} from '@ddd-qc/lit-happ';\nimport {profilesAltFunctionNames} from './profilesAlt.fn';\nimport {ProfilesAltUnitEnum} from './profilesAlt.integrity';\nimport {ProfilesAltLinkType} from './profilesAlt.integrity';\n\n/**\n *\n */\nexport class ProfilesAltProxy extends ZomeProxy {\n static override readonly DEFAULT_ZOME_NAME = \"profiles\";\n static override readonly FN_NAMES = profilesAltFunctionNames;\n static override readonly ENTRY_TYPES = Object.values(ProfilesAltUnitEnum);\n static override readonly LINK_TYPES = Object.values(ProfilesAltLinkType);\n \n async createProfile(pair: [Profile, AgentArray]): Promise<ActionArray> {\n return this.callBlocking('create_profile', pair);\n }\n\n async updateProfile(pair: [Profile, AgentArray]): Promise<ActionArray> {\n return this.callBlocking('update_profile', pair);\n }\n\n async searchAgentsNetwork(nicknameFilter: string): Promise<AgentArray[]> {\n return this.call('search_agents_network', nicknameFilter);\n }\n\n async findProfileNetwork(agentPubKey: AgentArray): Promise<[ActionArray, Profile] | null> {\n return this.call('find_profile_network', agentPubKey);\n }\n\n async findProfileLocal(agentPubKey: AgentArray): Promise<[ActionArray, Profile] | null> {\n return this.call('find_profile_local', agentPubKey);\n }\n\n async probeProfiles(strategy: GetStrategy): Promise<void> {\n return this.callBlocking('probe_profiles', strategy);\n }\n}\n"]}
|
package/dist/profilesAlt.zvm.js
CHANGED
|
@@ -96,7 +96,7 @@ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
96
96
|
}
|
|
97
97
|
async findProfile(agentId) {
|
|
98
98
|
try {
|
|
99
|
-
const maybeProfilePair = await this.zomeProxy.
|
|
99
|
+
const maybeProfilePair = await this.zomeProxy.findProfileNetwork(agentId.hash);
|
|
100
100
|
console.debug("ProfilesAltZvm.findProfile()", agentId, maybeProfilePair);
|
|
101
101
|
if (!maybeProfilePair) {
|
|
102
102
|
return;
|
|
@@ -1 +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,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 const maybeProfile = this.perspective.profileByAgent.get(agentId);\n if (!maybeProfile && 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 const maybe = this._perspective.getProfile(agentId);\n if (!maybe) {\n this.createProfile(profile, agentId)\n .catch((e) => console.error(\"ProfilesAltZvm.import()\", e))\n } else {\n if (maybe != profile) {\n this.updateProfile(profile, agentId)\n .catch((e) => console.error(\"ProfilesAltZvm.import()\", e))\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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ntryId,\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 const maybeProfile = this.perspective.profileByAgent.get(agentId);\n if (!maybeProfile && 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.findProfileNetwork(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 const maybe = this._perspective.getProfile(agentId);\n if (!maybe) {\n this.createProfile(profile, agentId)\n .catch((e) => console.error(\"ProfilesAltZvm.import()\", e))\n } else {\n if (maybe != profile) {\n this.updateProfile(profile, agentId)\n .catch((e) => console.error(\"ProfilesAltZvm.import()\", e))\n }\n }\n }\n return;\n }\n /** */\n this._perspective.restore(snapshot);\n this.notifySubscribers();\n }\n}\n"]}
|