@ddd-qc/profiles-dvm 0.21.0 → 0.22.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.
@@ -0,0 +1,7 @@
1
+ import { ZomeName, FunctionName } from '@holochain/client';
2
+ /** Array of all zome function names in "profilesAlt" */
3
+ export declare const profilesAltFunctionNames: FunctionName[];
4
+ /** Generate tuple array of function names with given zomeName */
5
+ export declare function generateProfilesAltZomeFunctionsArray(zomeName: ZomeName): [ZomeName, FunctionName][];
6
+ /** Tuple array of all zome function names with default zome name "profilesAlt" */
7
+ export declare const profilesAltZomeFunctions: [ZomeName, FunctionName][];
@@ -0,0 +1,23 @@
1
+ /* This file is generated by zits. Do not edit manually */
2
+ /** Array of all zome function names in "profilesAlt" */
3
+ export const profilesAltFunctionNames = [
4
+ "entry_defs",
5
+ "get_zome_info",
6
+ "get_dna_info",
7
+ "create_profile",
8
+ "update_profile",
9
+ "search_agents",
10
+ "get_profile",
11
+ "get_agents_with_profile",
12
+ ];
13
+ /** Generate tuple array of function names with given zomeName */
14
+ export function generateProfilesAltZomeFunctionsArray(zomeName) {
15
+ const fns = [];
16
+ for (const fn of profilesAltFunctionNames) {
17
+ fns.push([zomeName, fn]);
18
+ }
19
+ return fns;
20
+ }
21
+ /** Tuple array of all zome function names with default zome name "profilesAlt" */
22
+ export const profilesAltZomeFunctions = generateProfilesAltZomeFunctionsArray("profilesAlt");
23
+ //# sourceMappingURL=profilesAlt.fn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profilesAlt.fn.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.fn.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAK1D,wDAAwD;AACxD,MAAM,CAAC,MAAM,wBAAwB,GAAmB;IACvD,YAAY;IACZ,eAAe;IACf,cAAc;IAEd,gBAAgB;IAChB,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,yBAAyB;CAAE,CAAC;AAG7B,iEAAiE;AACjE,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;AAGD,kFAAkF;AAClF,MAAM,CAAC,MAAM,wBAAwB,GAA+B,qCAAqC,CAAC,aAAa,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\n\t\"create_profile\",\n\t\"update_profile\",\n\t\"search_agents\",\n\t\"get_profile\",\n\t\"get_agents_with_profile\",];\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 \"profilesAlt\" */\nexport const profilesAltZomeFunctions: [ZomeName, FunctionName][] = generateProfilesAltZomeFunctionsArray(\"profilesAlt\");\n"]}
@@ -0,0 +1,17 @@
1
+ import { Profile } from './profilesAlt.types';
2
+ import { AgentPubKey,
3
+ /** hdk/record.ts */
4
+ Record as HcRecord } from '@holochain/client';
5
+ import { ZomeProxy } from '@ddd-qc/lit-happ';
6
+ /**
7
+ *
8
+ */
9
+ export declare class ProfilesAltProxy extends ZomeProxy {
10
+ static readonly DEFAULT_ZOME_NAME = "profilesAlt";
11
+ static readonly FN_NAMES: string[];
12
+ createProfile(pair: [Profile, AgentPubKey]): Promise<HcRecord>;
13
+ updateProfile(pair: [Profile, AgentPubKey]): Promise<HcRecord>;
14
+ searchAgents(nicknameFilter: string): Promise<AgentPubKey[]>;
15
+ getProfile(agentPubKey: AgentPubKey): Promise<HcRecord | null>;
16
+ getAgentsWithProfile(): Promise<AgentPubKey[]>;
17
+ }
@@ -0,0 +1,26 @@
1
+ /* This file is generated by zits. Do not edit manually */
2
+ import { ZomeProxy } from '@ddd-qc/lit-happ';
3
+ import { profilesAltFunctionNames } from './profilesAlt.fn';
4
+ /**
5
+ *
6
+ */
7
+ export class ProfilesAltProxy extends ZomeProxy {
8
+ async createProfile(pair) {
9
+ return this.call('create_profile', pair);
10
+ }
11
+ async updateProfile(pair) {
12
+ return this.call('update_profile', pair);
13
+ }
14
+ async searchAgents(nicknameFilter) {
15
+ return this.call('search_agents', nicknameFilter);
16
+ }
17
+ async getProfile(agentPubKey) {
18
+ return this.call('get_profile', agentPubKey);
19
+ }
20
+ async getAgentsWithProfile() {
21
+ return this.call('get_agents_with_profile', null);
22
+ }
23
+ }
24
+ ProfilesAltProxy.DEFAULT_ZOME_NAME = "profilesAlt";
25
+ ProfilesAltProxy.FN_NAMES = profilesAltFunctionNames;
26
+ //# sourceMappingURL=profilesAlt.proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profilesAlt.proxy.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.proxy.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAmJ1D,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,wBAAwB,EAAC,MAAM,kBAAkB,CAAC;AAE1D;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAK7C,KAAK,CAAC,aAAa,CAAC,IAA4B;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAA4B;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,cAAsB;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,WAAwB;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;;AAtBe,kCAAiB,GAAG,aAAa,CAAA;AACjC,yBAAQ,GAAG,wBAAwB,CAAA","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {EntryTypes, LinkTypes, Signal, Profile, } from './profilesAlt.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 {profilesAltFunctionNames} from './profilesAlt.fn';\n\n/**\n *\n */\nexport class ProfilesAltProxy extends ZomeProxy {\n static readonly DEFAULT_ZOME_NAME = \"profilesAlt\"\n static readonly FN_NAMES = profilesAltFunctionNames\n \n\n async createProfile(pair: [Profile, AgentPubKey]): Promise<HcRecord> {\n return this.call('create_profile', pair);\n }\n\n async updateProfile(pair: [Profile, AgentPubKey]): Promise<HcRecord> {\n return this.call('update_profile', pair);\n }\n\n async searchAgents(nicknameFilter: string): Promise<AgentPubKey[]> {\n return this.call('search_agents', nicknameFilter);\n }\n\n async getProfile(agentPubKey: AgentPubKey): Promise<HcRecord | null> {\n return this.call('get_profile', agentPubKey);\n }\n\n async getAgentsWithProfile(): Promise<AgentPubKey[]> {\n return this.call('get_agents_with_profile', null);\n }\n}\n"]}
@@ -0,0 +1,55 @@
1
+ import {
2
+ /** hdk/action.ts */
3
+ SignedActionHashed } from '@holochain/client';
4
+ export type Signal = {
5
+ type: "LinkCreated";
6
+ action: SignedActionHashed;
7
+ link_type: LinkTypes;
8
+ } | {
9
+ type: "LinkDeleted";
10
+ action: SignedActionHashed;
11
+ create_link_action: SignedActionHashed;
12
+ link_type: LinkTypes;
13
+ } | {
14
+ type: "EntryCreated";
15
+ action: SignedActionHashed;
16
+ app_entry: EntryTypes;
17
+ } | {
18
+ type: "EntryUpdated";
19
+ action: SignedActionHashed;
20
+ app_entry: EntryTypes;
21
+ original_app_entry: EntryTypes;
22
+ } | {
23
+ type: "EntryDeleted";
24
+ action: SignedActionHashed;
25
+ original_app_entry: EntryTypes;
26
+ };
27
+ /**
28
+ * Profile entry definition.
29
+ *
30
+ * The profile must include at a minimum the nickname of the agent
31
+ * in order to be able to search for agents by nickname.
32
+ */
33
+ export interface Profile {
34
+ nickname: string;
35
+ fields: Record<string, string>;
36
+ }
37
+ export declare enum EntryTypesType {
38
+ Profile = "Profile"
39
+ }
40
+ export type EntryTypes = {
41
+ type: "Profile";
42
+ content: Profile;
43
+ };
44
+ export type LinkTypes = {
45
+ PrefixPath: null;
46
+ } | {
47
+ PathToAgent: null;
48
+ } | {
49
+ AgentToProfile: null;
50
+ };
51
+ export declare enum LinkTypesType {
52
+ PrefixPath = "PrefixPath",
53
+ PathToAgent = "PathToAgent",
54
+ AgentToProfile = "AgentToProfile"
55
+ }
@@ -0,0 +1,12 @@
1
+ /* This file is generated by zits. Do not edit manually */
2
+ export var EntryTypesType;
3
+ (function (EntryTypesType) {
4
+ EntryTypesType["Profile"] = "Profile";
5
+ })(EntryTypesType || (EntryTypesType = {}));
6
+ export var LinkTypesType;
7
+ (function (LinkTypesType) {
8
+ LinkTypesType["PrefixPath"] = "PrefixPath";
9
+ LinkTypesType["PathToAgent"] = "PathToAgent";
10
+ LinkTypesType["AgentToProfile"] = "AgentToProfile";
11
+ })(LinkTypesType || (LinkTypesType = {}));
12
+ //# sourceMappingURL=profilesAlt.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profilesAlt.types.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.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"]}
@@ -0,0 +1,50 @@
1
+ import { ZomeViewModel } from "@ddd-qc/lit-happ";
2
+ import { Profile as ProfileMat } from "./bindings/profiles.types";
3
+ import { AgentPubKeyB64 } from "@holochain/client";
4
+ import { ProfilesAltProxy } from "./bindings/profilesAlt.proxy";
5
+ /** */
6
+ export interface ProfilesPerspective {
7
+ profiles: Record<AgentPubKeyB64, ProfileMat>;
8
+ /** Nickname -> AgentPubKeyB64 */
9
+ reversed: Record<string, AgentPubKeyB64>;
10
+ }
11
+ /**
12
+ *
13
+ */
14
+ export declare class ProfilesAltZvm extends ZomeViewModel {
15
+ static readonly ZOME_PROXY: typeof ProfilesAltProxy;
16
+ get zomeProxy(): ProfilesAltProxy;
17
+ protected hasChanged(): boolean;
18
+ /** */
19
+ initializePerspectiveOnline(): Promise<void>;
20
+ /** */
21
+ probeAllInner(): void;
22
+ /** -- Perspective -- */
23
+ get perspective(): ProfilesPerspective;
24
+ private _profiles;
25
+ private _reversed;
26
+ getMyProfile(): ProfileMat | undefined;
27
+ getProfile(agent: AgentPubKeyB64): ProfileMat | undefined;
28
+ getAgents(): AgentPubKeyB64[];
29
+ getNames(): string[];
30
+ /** Dump perspective as JSON */
31
+ exportPerspective(): string;
32
+ /** */
33
+ importPerspective(json: string, mapping?: Object): void;
34
+ /** -- Methods -- */
35
+ findProfiles(names: string[]): AgentPubKeyB64[];
36
+ /** */
37
+ probeAllProfiles(): Promise<Record<AgentPubKeyB64, ProfileMat>>;
38
+ /** */
39
+ storeProfile(pubKeyB64: AgentPubKeyB64, profile: ProfileMat): void;
40
+ /** */
41
+ probeProfile(pubKeyB64: AgentPubKeyB64): Promise<ProfileMat | undefined>;
42
+ /** */
43
+ createMyProfile(profile: ProfileMat): Promise<void>;
44
+ /** */
45
+ updateMyProfile(profile: ProfileMat): Promise<void>;
46
+ /** */
47
+ createProfile(profile: ProfileMat, agent: AgentPubKeyB64): Promise<void>;
48
+ /** */
49
+ updateProfile(profile: ProfileMat, agent: AgentPubKeyB64): Promise<void>;
50
+ }
@@ -0,0 +1,130 @@
1
+ import { ZomeViewModel } from "@ddd-qc/lit-happ";
2
+ import { decodeHashFromBase64, encodeHashToBase64 } from "@holochain/client";
3
+ import { decode } from "@msgpack/msgpack";
4
+ import { ProfilesAltProxy } from "./bindings/profilesAlt.proxy";
5
+ /**
6
+ *
7
+ */
8
+ export class ProfilesAltZvm extends ZomeViewModel {
9
+ constructor() {
10
+ super(...arguments);
11
+ this._profiles = {};
12
+ //private _profile_ahs: Record<AgentPubKeyB64, ActionHashB64> = {};
13
+ this._reversed = {};
14
+ }
15
+ get zomeProxy() { return this._zomeProxy; }
16
+ /* */
17
+ hasChanged() {
18
+ // TODO
19
+ return true;
20
+ }
21
+ /** */
22
+ async initializePerspectiveOnline() {
23
+ await this.probeAllProfiles();
24
+ }
25
+ /** */
26
+ probeAllInner() {
27
+ this.probeAllProfiles();
28
+ }
29
+ /** -- Perspective -- */
30
+ /* */
31
+ get perspective() {
32
+ return {
33
+ profiles: this._profiles,
34
+ reversed: this._reversed,
35
+ //profile_ahs: this._profile_ahs,
36
+ };
37
+ }
38
+ getMyProfile() { return this._profiles[this.cell.agentPubKey]; }
39
+ getProfile(agent) { return this._profiles[agent]; }
40
+ //getProfileHash(agent: AgentPubKeyB64): ActionHashB64 | undefined {return this._profile_ahs[agent]}
41
+ getAgents() { return Object.keys(this._profiles); }
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
+ }
55
+ /** -- Methods -- */
56
+ /* */
57
+ findProfiles(names) {
58
+ let res = [];
59
+ for (const name of names) {
60
+ if (this._reversed[name]) {
61
+ res.push(this._reversed[name]);
62
+ }
63
+ }
64
+ return res;
65
+ }
66
+ /** */
67
+ async probeAllProfiles() {
68
+ let allAgents;
69
+ /** Attempt a retry on fail as this can create an entry (path anchor) and generate a 'head has moved' error */
70
+ try {
71
+ allAgents = await this.zomeProxy.getAgentsWithProfile();
72
+ }
73
+ catch (e) {
74
+ allAgents = await this.zomeProxy.getAgentsWithProfile();
75
+ }
76
+ for (const agentPubKey of allAgents) {
77
+ const maybeProfile = await this.zomeProxy.getProfile(agentPubKey);
78
+ if (!maybeProfile) {
79
+ continue;
80
+ }
81
+ const profile = decode(maybeProfile.entry.Present.entry);
82
+ this.storeProfile(encodeHashToBase64(agentPubKey), profile);
83
+ }
84
+ this.notifySubscribers();
85
+ return this._profiles;
86
+ }
87
+ /** */
88
+ storeProfile(pubKeyB64, profile) {
89
+ this._profiles[pubKeyB64] = profile;
90
+ this._reversed[profile.nickname] = pubKeyB64;
91
+ this.notifySubscribers();
92
+ }
93
+ /** */
94
+ async probeProfile(pubKeyB64) {
95
+ const maybeProfile = await this.zomeProxy.getProfile(decodeHashFromBase64(pubKeyB64));
96
+ console.log("probeProfile() maybeProfile", maybeProfile);
97
+ if (!maybeProfile) {
98
+ return;
99
+ }
100
+ // const profileEntry: any = decode((maybeProfile.entry as any).Present.entry);
101
+ // console.log("probeProfile() profileEntry", profileEntry);
102
+ //const profile: ProfileMat = decode(profileEntry.record.entry.Present.entry) as ProfileMat;
103
+ const profile = decode(maybeProfile.entry.Present.entry);
104
+ console.log("probeProfile() profile", profile);
105
+ this.storeProfile(pubKeyB64, profile);
106
+ return profile;
107
+ }
108
+ /** */
109
+ async createMyProfile(profile) {
110
+ /*const record =*/ await this.zomeProxy.createProfile([profile, decodeHashFromBase64(this.cell.agentPubKey)]);
111
+ this.storeProfile(this.cell.agentPubKey, profile);
112
+ }
113
+ /** */
114
+ async updateMyProfile(profile) {
115
+ /*const record =*/ await this.zomeProxy.updateProfile([profile, decodeHashFromBase64(this.cell.agentPubKey)]);
116
+ this.storeProfile(this.cell.agentPubKey, profile);
117
+ }
118
+ /** */
119
+ async createProfile(profile, agent) {
120
+ /*const record =*/ await this.zomeProxy.createProfile([profile, decodeHashFromBase64(agent)]);
121
+ this.storeProfile(agent, profile);
122
+ }
123
+ /** */
124
+ async updateProfile(profile, agent) {
125
+ /*const record =*/ await this.zomeProxy.updateProfile([profile, decodeHashFromBase64(agent)]);
126
+ this.storeProfile(agent, profile);
127
+ }
128
+ }
129
+ ProfilesAltZvm.ZOME_PROXY = ProfilesAltProxy;
130
+ //# sourceMappingURL=profilesAlt.zvm.js.map
@@ -0,0 +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,EAA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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 {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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-qc/profiles-dvm",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "DnaViewModel implementation for the Profiles zome.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",