@ddd-qc/profiles-dvm 0.20.7 → 0.21.0

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":"profiles.proxy.js","sourceRoot":"","sources":["../../src/bindings/profiles.proxy.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAsI1D,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAI1C,KAAK,CAAC,aAAa,CAAC,OAAgB;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAgB;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,cAAsB;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,WAAwB;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;;AArBe,+BAAiB,GAAG,UAAU,CAAA;AAC9B,sBAAQ,GAAG,qBAAqB,CAAA","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {EntryTypes, LinkTypes, Signal, Profile, } from './profiles.types';\nimport {\n/** types.ts */\nHoloHash,\nAgentPubKey,\nDnaHash,\nWasmHash,\nEntryHash,\nActionHash,\nAnyDhtHash,\nExternalHash,\nKitsuneAgent,\nKitsuneSpace,\nHoloHashB64,\nAgentPubKeyB64,\nDnaHashB64,\nWasmHashB64,\nEntryHashB64,\nActionHashB64,\nAnyDhtHashB64,\nInstalledAppId,\nSignature,\nCellId,\nDnaProperties,\nRoleName,\nInstalledCell,\nTimestamp,\nDuration,\nHoloHashed,\nNetworkInfo,\nFetchPoolInfo,\n/** hdk/action.ts */\nSignedActionHashed,\nActionHashed,\nActionType,\nAction,\nNewEntryAction,\nDna,\nAgentValidationPkg,\nInitZomesComplete,\nCreateLink,\nDeleteLink,\nOpenChain,\nCloseChain,\nUpdate,\nDelete,\nCreate,\n/** hdk/capabilities.ts */\nCapSecret,\nCapClaim,\nGrantedFunctionsType,\nGrantedFunctions,\nZomeCallCapGrant,\nCapAccess,\nCapGrant,\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 */\nDhtOpType,\nDhtOp,\ngetDhtOpType,\ngetDhtOpAction,\ngetDhtOpEntry,\ngetDhtOpSignature,\n/** hdk/entry.ts */\nEntryVisibility,\nAppEntryDef,\nEntryType,\nEntryContent,\nEntry,\n/** hdk/record.ts */\nRecord as HcRecord,\nRecordEntry as HcRecordEntry,\n/** api/admin/types.ts */\nInstalledAppInfoStatus,\nDeactivationReason,\nDisabledAppReason,\nStemCell,\nProvisionedCell,\nClonedCell,\nCellType,\nCellInfo,\nAppInfo,\nMembraneProof,\nFunctionName,\nZomeName,\nZomeDefinition,\nIntegrityZome,\nCoordinatorZome,\nDnaDefinition,\nResourceBytes,\nResourceMap,\nCellProvisioningStrategy,\nCellProvisioning,\nDnaVersionSpec,\nDnaVersionFlexible,\nAppRoleDnaManifest,\nAppRoleManifest,\nAppManifest,\nAppBundle,\nAppBundleSource,\nNetworkSeed,\nZomeLocation,\n } from '@holochain/client';\n\nimport {\n/** Common */\nDhtOpHashB64,\nDhtOpHash,\n/** DnaFile */\nDnaFile,\nDnaDef,\nZomes,\nWasmCode,\n/** entry-details */\nEntryDetails,\nRecordDetails,\nDetails,\nDetailsType,\nEntryDhtStatus,\n/** Validation */\nValidationStatus,\nValidationReceipt,\n } from '@holochain-open-dev/core-types';\n\nimport {ZomeProxy} from '@ddd-qc/lit-happ';\nimport {profilesFunctionNames} from './profiles.fn';\n\n/**\n *\n */\nexport class ProfilesProxy extends ZomeProxy {\n static readonly DEFAULT_ZOME_NAME = \"profiles\"\n static readonly FN_NAMES = profilesFunctionNames\n \n async createProfile(profile: Profile): Promise<HcRecord> {\n return this.call('create_profile', profile);\n }\n\n async updateProfile(profile: Profile): Promise<HcRecord> {\n return this.call('update_profile', profile);\n }\n\n async searchAgents(nicknameFilter: string): Promise<AgentPubKey[]> {\n return this.call('search_agents', nicknameFilter);\n }\n\n async getAgentProfile(agentPubKey: AgentPubKey): Promise<HcRecord | null> {\n return this.call('get_agent_profile', agentPubKey);\n }\n\n async getAgentsWithProfile(): Promise<AgentPubKey[]> {\n return this.call('get_agents_with_profile', null);\n }\n\n}\n"]}
1
+ {"version":3,"file":"profiles.proxy.js","sourceRoot":"","sources":["../../src/bindings/profiles.proxy.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAmJ1D,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAI1C,KAAK,CAAC,aAAa,CAAC,OAAgB;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAgB;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,cAAsB;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,WAAwB;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;;AArBe,+BAAiB,GAAG,UAAU,CAAA;AAC9B,sBAAQ,GAAG,qBAAqB,CAAA","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {EntryTypes, LinkTypes, Signal, Profile, } from './profiles.types';\nimport {\n/** types.ts */\nHoloHash,\nAgentPubKey,\nDnaHash,\nWasmHash,\nEntryHash,\nActionHash,\nAnyDhtHash,\nExternalHash,\nKitsuneAgent,\nKitsuneSpace,\nHoloHashB64,\nAgentPubKeyB64,\nDnaHashB64,\nWasmHashB64,\nEntryHashB64,\nActionHashB64,\nAnyDhtHashB64,\nInstalledAppId,\nSignature,\nCellId,\nDnaProperties,\nRoleName,\nInstalledCell,\nTimestamp,\nDuration,\nHoloHashed,\nNetworkInfo,\nFetchPoolInfo,\n/** hdk/action.ts */\nSignedActionHashed,\nRegisterAgentActivity,\nActionHashed,\nActionType,\nAction,\nNewEntryAction,\nDna,\nAgentValidationPkg,\nInitZomesComplete,\nCreateLink,\nDeleteLink,\nOpenChain,\nCloseChain,\nUpdate,\nDelete,\nCreate,\n/** hdk/capabilities.ts */\nCapSecret,\nCapClaim,\nGrantedFunctionsType,\nGrantedFunctions,\nZomeCallCapGrant,\nCapAccessType,\nCapAccess,\nCapGrant,\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 */\nDhtOpType,\nDhtOp,\ngetDhtOpType,\ngetDhtOpAction,\ngetDhtOpEntry,\ngetDhtOpSignature,\n/** hdk/entry.ts */\nEntryVisibility,\nAppEntryDef,\nEntryType,\nEntryContent,\nEntry,\n/** hdk/record.ts */\nRecord as HcRecord,\nRecordEntry as HcRecordEntry,\n/** hdk/link.ts */\nAnyLinkableHash,\nZomeIndex,\nLinkType,\nLinkTag,\nRateWeight,\nRateBucketId,\nRateUnits,\nLink,\n/** api/admin/types.ts */\nInstalledAppInfoStatus,\nDeactivationReason,\nDisabledAppReason,\nStemCell,\nProvisionedCell,\nClonedCell,\nCellType,\nCellInfo,\nAppInfo,\nMembraneProof,\nFunctionName,\nZomeName,\nZomeDefinition,\nIntegrityZome,\nCoordinatorZome,\nDnaDefinition,\nResourceBytes,\nResourceMap,\nCellProvisioningStrategy,\nCellProvisioning,\nDnaVersionSpec,\nDnaVersionFlexible,\nAppRoleDnaManifest,\nAppRoleManifest,\nAppManifest,\nAppBundle,\nAppBundleSource,\nNetworkSeed,\nZomeLocation,\n } from '@holochain/client';\n\nimport {\n/** Common */\nDhtOpHashB64,\n//DnaHashB64, (duplicate)\n//AnyDhtHashB64, (duplicate)\nDhtOpHash,\n/** DnaFile */\nDnaFile,\nDnaDef,\nZomes,\nWasmCode,\n/** entry-details */\nEntryDetails,\nRecordDetails,\nDetails,\nDetailsType,\nEntryDhtStatus,\n/** Validation */\nValidationStatus,\nValidationReceipt,\n } from '@holochain-open-dev/core-types';\n\nimport {ZomeProxy} from '@ddd-qc/lit-happ';\nimport {profilesFunctionNames} from './profiles.fn';\n\n/**\n *\n */\nexport class ProfilesProxy extends ZomeProxy {\n static readonly DEFAULT_ZOME_NAME = \"profiles\"\n static readonly FN_NAMES = profilesFunctionNames\n \n async createProfile(profile: Profile): Promise<HcRecord> {\n return this.call('create_profile', profile);\n }\n\n async updateProfile(profile: Profile): Promise<HcRecord> {\n return this.call('update_profile', profile);\n }\n\n async searchAgents(nicknameFilter: string): Promise<AgentPubKey[]> {\n return this.call('search_agents', nicknameFilter);\n }\n\n async getAgentProfile(agentPubKey: AgentPubKey): Promise<HcRecord | null> {\n return this.call('get_agent_profile', agentPubKey);\n }\n\n async getAgentsWithProfile(): Promise<AgentPubKey[]> {\n return this.call('get_agents_with_profile', null);\n }\n\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.types.js","sourceRoot":"","sources":["../../src/bindings/profiles.types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AA6K1D,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACzB,qCAAmB,CAAA;AACpB,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;AAOD,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACxB,0CAAyB,CAAA;IACzB,4CAA2B,CAAA;IAC3B,kDAAiC,CAAA;AAClC,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {\n/** types.ts */\nHoloHash,\nAgentPubKey,\nDnaHash,\nWasmHash,\nEntryHash,\nActionHash,\nAnyDhtHash,\nExternalHash,\nKitsuneAgent,\nKitsuneSpace,\nHoloHashB64,\nAgentPubKeyB64,\nDnaHashB64,\nWasmHashB64,\nEntryHashB64,\nActionHashB64,\nAnyDhtHashB64,\nInstalledAppId,\nSignature,\nCellId,\nDnaProperties,\nRoleName,\nInstalledCell,\nTimestamp,\nDuration,\nHoloHashed,\nNetworkInfo,\nFetchPoolInfo,\n/** hdk/action.ts */\nSignedActionHashed,\nActionHashed,\nActionType,\nAction,\nNewEntryAction,\nDna,\nAgentValidationPkg,\nInitZomesComplete,\nCreateLink,\nDeleteLink,\nOpenChain,\nCloseChain,\nUpdate,\nDelete,\nCreate,\n/** hdk/capabilities.ts */\nCapSecret,\nCapClaim,\nGrantedFunctionsType,\nGrantedFunctions,\nZomeCallCapGrant,\nCapAccess,\nCapGrant,\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 */\nDhtOpType,\nDhtOp,\ngetDhtOpType,\ngetDhtOpAction,\ngetDhtOpEntry,\ngetDhtOpSignature,\n/** hdk/entry.ts */\nEntryVisibility,\nAppEntryDef,\nEntryType,\nEntryContent,\nEntry,\n/** hdk/record.ts */\nRecord as HcRecord,\nRecordEntry as HcRecordEntry,\n/** api/admin/types.ts */\nInstalledAppInfoStatus,\nDeactivationReason,\nDisabledAppReason,\nStemCell,\nProvisionedCell,\nClonedCell,\nCellType,\nCellInfo,\nAppInfo,\nMembraneProof,\nFunctionName,\nZomeName,\nZomeDefinition,\nIntegrityZome,\nCoordinatorZome,\nDnaDefinition,\nResourceBytes,\nResourceMap,\nCellProvisioningStrategy,\nCellProvisioning,\nDnaVersionSpec,\nDnaVersionFlexible,\nAppRoleDnaManifest,\nAppRoleManifest,\nAppManifest,\nAppBundle,\nAppBundleSource,\nNetworkSeed,\nZomeLocation,\n } from '@holochain/client';\n\nimport {\n/** Common */\nDhtOpHashB64,\nDhtOpHash,\n/** DnaFile */\nDnaFile,\nDnaDef,\nZomes,\nWasmCode,\n/** entry-details */\nEntryDetails,\nRecordDetails,\nDetails,\nDetailsType,\nEntryDhtStatus,\n/** Validation */\nValidationStatus,\nValidationReceipt,\n } from '@holochain-open-dev/core-types';\n\nexport type Signal =\n | {\n type: \"LinkCreated\",\n action: SignedActionHashed\n link_type: LinkTypes\n }\n | {\n type: \"LinkDeleted\",\n action: SignedActionHashed\n create_link_action: SignedActionHashed\n link_type: LinkTypes\n }\n | {\n type: \"EntryCreated\",\n action: SignedActionHashed\n app_entry: EntryTypes\n }\n | {\n type: \"EntryUpdated\",\n action: SignedActionHashed\n app_entry: EntryTypes\n original_app_entry: EntryTypes\n }\n | {\n type: \"EntryDeleted\",\n action: SignedActionHashed\n original_app_entry: EntryTypes\n };\n\n/**\n * Profile entry definition.\n * \n * The profile must include at a minimum the nickname of the agent\n * in order to be able to search for agents by nickname.\n */\nexport interface Profile {\n nickname: string\n fields: Record<string, string>\n}\n\nexport enum EntryTypesType {\n\tProfile = 'Profile',\n}\nexport type EntryTypes = \n | {type: \"Profile\", content: Profile}\n\n\nexport type LinkTypes =\n | {PrefixPath: null} | {PathToAgent: null} | {AgentToProfile: null};\nexport enum LinkTypesType {\n\tPrefixPath = 'PrefixPath',\n\tPathToAgent = 'PathToAgent',\n\tAgentToProfile = 'AgentToProfile',\n}\n"]}
1
+ {"version":3,"file":"profiles.types.js","sourceRoot":"","sources":["../../src/bindings/profiles.types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AA0L1D,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACzB,qCAAmB,CAAA;AACpB,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;AAOD,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACxB,0CAAyB,CAAA;IACzB,4CAA2B,CAAA;IAC3B,kDAAiC,CAAA;AAClC,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {\n/** types.ts */\nHoloHash,\nAgentPubKey,\nDnaHash,\nWasmHash,\nEntryHash,\nActionHash,\nAnyDhtHash,\nExternalHash,\nKitsuneAgent,\nKitsuneSpace,\nHoloHashB64,\nAgentPubKeyB64,\nDnaHashB64,\nWasmHashB64,\nEntryHashB64,\nActionHashB64,\nAnyDhtHashB64,\nInstalledAppId,\nSignature,\nCellId,\nDnaProperties,\nRoleName,\nInstalledCell,\nTimestamp,\nDuration,\nHoloHashed,\nNetworkInfo,\nFetchPoolInfo,\n/** hdk/action.ts */\nSignedActionHashed,\nRegisterAgentActivity,\nActionHashed,\nActionType,\nAction,\nNewEntryAction,\nDna,\nAgentValidationPkg,\nInitZomesComplete,\nCreateLink,\nDeleteLink,\nOpenChain,\nCloseChain,\nUpdate,\nDelete,\nCreate,\n/** hdk/capabilities.ts */\nCapSecret,\nCapClaim,\nGrantedFunctionsType,\nGrantedFunctions,\nZomeCallCapGrant,\nCapAccessType,\nCapAccess,\nCapGrant,\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 */\nDhtOpType,\nDhtOp,\ngetDhtOpType,\ngetDhtOpAction,\ngetDhtOpEntry,\ngetDhtOpSignature,\n/** hdk/entry.ts */\nEntryVisibility,\nAppEntryDef,\nEntryType,\nEntryContent,\nEntry,\n/** hdk/record.ts */\nRecord as HcRecord,\nRecordEntry as HcRecordEntry,\n/** hdk/link.ts */\nAnyLinkableHash,\nZomeIndex,\nLinkType,\nLinkTag,\nRateWeight,\nRateBucketId,\nRateUnits,\nLink,\n/** api/admin/types.ts */\nInstalledAppInfoStatus,\nDeactivationReason,\nDisabledAppReason,\nStemCell,\nProvisionedCell,\nClonedCell,\nCellType,\nCellInfo,\nAppInfo,\nMembraneProof,\nFunctionName,\nZomeName,\nZomeDefinition,\nIntegrityZome,\nCoordinatorZome,\nDnaDefinition,\nResourceBytes,\nResourceMap,\nCellProvisioningStrategy,\nCellProvisioning,\nDnaVersionSpec,\nDnaVersionFlexible,\nAppRoleDnaManifest,\nAppRoleManifest,\nAppManifest,\nAppBundle,\nAppBundleSource,\nNetworkSeed,\nZomeLocation,\n } from '@holochain/client';\n\nimport {\n/** Common */\nDhtOpHashB64,\n//DnaHashB64, (duplicate)\n//AnyDhtHashB64, (duplicate)\nDhtOpHash,\n/** DnaFile */\nDnaFile,\nDnaDef,\nZomes,\nWasmCode,\n/** entry-details */\nEntryDetails,\nRecordDetails,\nDetails,\nDetailsType,\nEntryDhtStatus,\n/** Validation */\nValidationStatus,\nValidationReceipt,\n } from '@holochain-open-dev/core-types';\n\nexport type Signal =\n | {\n type: \"LinkCreated\",\n action: SignedActionHashed\n link_type: LinkTypes\n }\n | {\n type: \"LinkDeleted\",\n action: SignedActionHashed\n create_link_action: SignedActionHashed\n link_type: LinkTypes\n }\n | {\n type: \"EntryCreated\",\n action: SignedActionHashed\n app_entry: EntryTypes\n }\n | {\n type: \"EntryUpdated\",\n action: SignedActionHashed\n app_entry: EntryTypes\n original_app_entry: EntryTypes\n }\n | {\n type: \"EntryDeleted\",\n action: SignedActionHashed\n original_app_entry: EntryTypes\n };\n\n/**\n * Profile entry definition.\n * \n * The profile must include at a minimum the nickname of the agent\n * in order to be able to search for agents by nickname.\n */\nexport interface Profile {\n nickname: string\n fields: Record<string, string>\n}\n\nexport enum EntryTypesType {\n\tProfile = 'Profile',\n}\nexport type EntryTypes = \n | {type: \"Profile\", content: Profile}\n\n\nexport type LinkTypes =\n | {PrefixPath: null} | {PathToAgent: null} | {AgentToProfile: null};\nexport enum LinkTypesType {\n\tPrefixPath = 'PrefixPath',\n\tPathToAgent = 'PathToAgent',\n\tAgentToProfile = 'AgentToProfile',\n}\n"]}
@@ -27,11 +27,17 @@ export declare class ProfilesZvm extends ZomeViewModel {
27
27
  getProfile(agent: AgentPubKeyB64): ProfileMat | undefined;
28
28
  getAgents(): AgentPubKeyB64[];
29
29
  getNames(): string[];
30
+ /** Dump perspective as JSON */
31
+ exportPerspective(): string;
32
+ /** */
33
+ importPerspective(json: string, mapping?: Object): void;
30
34
  /** -- Methods -- */
31
35
  findProfiles(names: string[]): AgentPubKeyB64[];
32
36
  /** */
33
37
  probeAllProfiles(): Promise<Record<AgentPubKeyB64, ProfileMat>>;
34
38
  /** */
39
+ storeProfile(pubKeyB64: AgentPubKeyB64, profile: ProfileMat): void;
40
+ /** */
35
41
  probeProfile(pubKeyB64: AgentPubKeyB64): Promise<ProfileMat | undefined>;
36
42
  /** */
37
43
  createMyProfile(profile: ProfileMat): Promise<void>;
@@ -40,6 +40,18 @@ export class ProfilesZvm extends ZomeViewModel {
40
40
  //getProfileHash(agent: AgentPubKeyB64): ActionHashB64 | undefined {return this._profile_ahs[agent]}
41
41
  getAgents() { return Object.keys(this._profiles); }
42
42
  getNames() { return Object.keys(this._reversed); }
43
+ /** Dump perspective as JSON */
44
+ exportPerspective() {
45
+ //console.log("exportPerspective()", perspMat);
46
+ return JSON.stringify(this._profiles, null, 2);
47
+ }
48
+ /** */
49
+ importPerspective(json, mapping) {
50
+ const profiles = JSON.parse(json);
51
+ for (const [pubKey, profileMat] of Object.entries(profiles)) {
52
+ this.storeProfile(pubKey, profileMat);
53
+ }
54
+ }
43
55
  /** -- Methods -- */
44
56
  /* */
45
57
  findProfiles(names) {
@@ -67,15 +79,18 @@ export class ProfilesZvm extends ZomeViewModel {
67
79
  continue;
68
80
  }
69
81
  const profile = decode(maybeProfile.entry.Present.entry);
70
- const pubKeyB64 = encodeHashToBase64(agentPubKey);
71
- this._profiles[pubKeyB64] = profile;
72
- this._reversed[profile.nickname] = pubKeyB64;
73
- //this._profile_ahs[pubKeyB64] = encodeHashToBase64(record.signed_action.hashed.hash);
82
+ this.storeProfile(encodeHashToBase64(agentPubKey), profile);
74
83
  }
75
84
  this.notifySubscribers();
76
85
  return this._profiles;
77
86
  }
78
87
  /** */
88
+ storeProfile(pubKeyB64, profile) {
89
+ this._profiles[pubKeyB64] = profile;
90
+ this._reversed[profile.nickname] = pubKeyB64;
91
+ this.notifySubscribers();
92
+ }
93
+ /** */
79
94
  async probeProfile(pubKeyB64) {
80
95
  const maybeProfile = await this.zomeProxy.getAgentProfile(decodeHashFromBase64(pubKeyB64));
81
96
  console.log("probeProfile() maybeProfile", maybeProfile);
@@ -87,27 +102,18 @@ export class ProfilesZvm extends ZomeViewModel {
87
102
  //const profile: ProfileMat = decode(profileEntry.record.entry.Present.entry) as ProfileMat;
88
103
  const profile = decode(maybeProfile.entry.Present.entry);
89
104
  console.log("probeProfile() profile", profile);
90
- this._profiles[pubKeyB64] = profile;
91
- this._reversed[profile.nickname] = pubKeyB64;
92
- //this._profile_ahs[pubKeyB64] = encodeHashToBase64(record.signed_action.hashed.hash);
93
- this.notifySubscribers();
105
+ this.storeProfile(pubKeyB64, profile);
94
106
  return profile;
95
107
  }
96
108
  /** */
97
109
  async createMyProfile(profile) {
98
110
  /*const record =*/ await this.zomeProxy.createProfile(profile);
99
- this._profiles[this.cell.agentPubKey] = profile;
100
- this._reversed[profile.nickname] = this.cell.agentPubKey;
101
- //this._profile_ahs[this.cell.agentPubKey] = encodeHashToBase64(record.signed_action.hashed.hash);
102
- this.notifySubscribers();
111
+ this.storeProfile(this.cell.agentPubKey, profile);
103
112
  }
104
113
  /** */
105
114
  async updateMyProfile(profile) {
106
115
  /*const record =*/ await this.zomeProxy.updateProfile(profile);
107
- this._profiles[this.cell.agentPubKey] = profile;
108
- this._reversed[profile.nickname] = this.cell.agentPubKey;
109
- //this._profile_ahs[this.cell.agentPubKey] = encodeHashToBase64(record.signed_action.hashed.hash);
110
- this.notifySubscribers();
116
+ this.storeProfile(this.cell.agentPubKey, profile);
111
117
  }
112
118
  }
113
119
  ProfilesZvm.ZOME_PROXY = ProfilesProxy;
@@ -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;AAexC;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,aAAa;IAA9C;;QAkCU,cAAS,GAAuC,EAAE,CAAC;QAC3D,mEAAmE;QAC3D,cAAS,GAAmC,EAAE,CAAC;IA2FzD,CAAC;IA5HC,IAAI,SAAS,KAAmB,OAAO,IAAI,CAAC,UAA2B,CAAC,CAAA,CAAC;IAGzE,KAAK;IACK,UAAU;QAClB,OAAO;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IAG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AsF;QACtF,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC;IACjB,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,eAAe,CAAC,OAAmB;QACvC,kBAAkB,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC;QAChD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;QACzD,kGAAkG;QAClG,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IAED,MAAM;IACN,KAAK,CAAC,eAAe,CAAC,OAAmB;QACvC,kBAAkB,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC;QAChD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;QACzD,kGAAkG;QAClG,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;;AA3He,sBAAU,GAAG,aAAa,AAAhB,CAAiB","sourcesContent":["import {ZomeViewModel} from \"@ddd-qc/lit-happ\";\nimport {Profile as ProfileMat} from \"./bindings/profiles.types\";\nimport {AgentPubKeyB64, decodeHashFromBase64, encodeHashToBase64} from \"@holochain/client\";\nimport {ProfilesProxy} from \"./bindings/profiles.proxy\";\nimport {decode} from \"@msgpack/msgpack\";\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 ProfilesZvm extends ZomeViewModel {\n\n static readonly ZOME_PROXY = ProfilesProxy;\n get zomeProxy(): ProfilesProxy {return this._zomeProxy as ProfilesProxy;}\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 /** -- 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.getAgentProfile(agentPubKey);\n if (!maybeProfile) {\n continue;\n }\n const profile: ProfileMat = decode((maybeProfile.entry as any).Present.entry) as ProfileMat;\n const pubKeyB64 = encodeHashToBase64(agentPubKey);\n this._profiles[pubKeyB64] = profile;\n this._reversed[profile.nickname] = pubKeyB64;\n //this._profile_ahs[pubKeyB64] = encodeHashToBase64(record.signed_action.hashed.hash);\n }\n this.notifySubscribers();\n return this._profiles;\n }\n\n\n /** */\n async probeProfile(pubKeyB64: AgentPubKeyB64): Promise<ProfileMat | 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: 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._profiles[pubKeyB64] = profile;\n this._reversed[profile.nickname] = pubKeyB64;\n //this._profile_ahs[pubKeyB64] = encodeHashToBase64(record.signed_action.hashed.hash);\n this.notifySubscribers();\n return profile;\n }\n\n\n /** */\n async createMyProfile(profile: ProfileMat): Promise<void> {\n /*const record =*/ await this.zomeProxy.createProfile(profile);\n this._profiles[this.cell.agentPubKey] = profile;\n this._reversed[profile.nickname] = this.cell.agentPubKey;\n //this._profile_ahs[this.cell.agentPubKey] = encodeHashToBase64(record.signed_action.hashed.hash);\n this.notifySubscribers();\n }\n\n /** */\n async updateMyProfile(profile: ProfileMat): Promise<void> {\n /*const record =*/ await this.zomeProxy.updateProfile(profile);\n this._profiles[this.cell.agentPubKey] = profile;\n this._reversed[profile.nickname] = this.cell.agentPubKey;\n //this._profile_ahs[this.cell.agentPubKey] = encodeHashToBase64(record.signed_action.hashed.hash);\n this.notifySubscribers();\n }\n\n}\n"]}
1
+ {"version":3,"file":"profiles.zvm.js","sourceRoot":"","sources":["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,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,eAAe,CAAC,OAAmB;QACvC,kBAAkB,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;;AAvIe,sBAAU,GAAG,aAAa,AAAhB,CAAiB","sourcesContent":["import {ZomeViewModel} from \"@ddd-qc/lit-happ\";\nimport {Profile as ProfileMat} from \"./bindings/profiles.types\";\nimport {AgentPubKeyB64, decodeHashFromBase64, encodeHashToBase64} from \"@holochain/client\";\nimport {ProfilesProxy} from \"./bindings/profiles.proxy\";\nimport {decode} from \"@msgpack/msgpack\";\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 ProfilesZvm extends ZomeViewModel {\n\n static readonly ZOME_PROXY = ProfilesProxy;\n get zomeProxy(): ProfilesProxy {return this._zomeProxy as ProfilesProxy;}\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.getAgentProfile(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.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: 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);\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);\n this.storeProfile(this.cell.agentPubKey, 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.20.7",
3
+ "version": "0.21.0",
4
4
  "description": "DnaViewModel implementation for the Profiles zome.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "@ddd-qc/lit-happ": "file:../lit-happ",
33
33
  "@holochain-open-dev/core-types": "0.7.0",
34
- "@holochain/client": "=0.16.2",
34
+ "@holochain/client": "=0.16.7",
35
35
  "@msgpack/msgpack": "^2.7.2",
36
36
  "lit": "3.0.2"
37
37
  },