@ddd-qc/profiles-dvm 0.19.19 → 0.20.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 "profiles" */
3
+ export declare const profilesFunctionNames: FunctionName[];
4
+ /** Generate tuple array of function names with given zomeName */
5
+ export declare function generateProfilesZomeFunctionsArray(zomeName: ZomeName): [ZomeName, FunctionName][];
6
+ /** Tuple array of all zome function names with default zome name "profiles" */
7
+ export declare const profilesZomeFunctions: [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 "profiles" */
3
+ export const profilesFunctionNames = [
4
+ "entry_defs",
5
+ "get_zome_info",
6
+ "get_dna_info",
7
+ "create_profile",
8
+ "update_profile",
9
+ "search_agents",
10
+ "get_agent_profile",
11
+ "get_agents_with_profile",
12
+ ];
13
+ /** Generate tuple array of function names with given zomeName */
14
+ export function generateProfilesZomeFunctionsArray(zomeName) {
15
+ const fns = [];
16
+ for (const fn of profilesFunctionNames) {
17
+ fns.push([zomeName, fn]);
18
+ }
19
+ return fns;
20
+ }
21
+ /** Tuple array of all zome function names with default zome name "profiles" */
22
+ export const profilesZomeFunctions = generateProfilesZomeFunctionsArray("profiles");
23
+ //# sourceMappingURL=profiles.fn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiles.fn.js","sourceRoot":"","sources":["../../src/bindings/profiles.fn.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAK1D,qDAAqD;AACrD,MAAM,CAAC,MAAM,qBAAqB,GAAmB;IACpD,YAAY;IACZ,eAAe;IACf,cAAc;IACd,gBAAgB;IAChB,gBAAgB;IAChB,eAAe;IACf,mBAAmB;IACnB,yBAAyB;CACzB,CAAC;AAGF,iEAAiE;AACjE,MAAM,UAAU,kCAAkC,CAAC,QAAkB;IAClE,MAAM,GAAG,GAA+B,EAAE,CAAC;IAC3C,KAAK,MAAM,EAAE,IAAI,qBAAqB,EAAE;QACrC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;KAC3B;IACD,OAAO,GAAG,CAAC;AACd,CAAC;AAGD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,qBAAqB,GAA+B,kCAAkC,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 \"profiles\" */\nexport const profilesFunctionNames: 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\",\n\t\"get_agent_profile\",\n\t\"get_agents_with_profile\",\n];\n\n\n/** Generate tuple array of function names with given zomeName */\nexport function generateProfilesZomeFunctionsArray(zomeName: ZomeName): [ZomeName, FunctionName][] {\n const fns: [ZomeName, FunctionName][] = [];\n for (const fn of profilesFunctionNames) {\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 profilesZomeFunctions: [ZomeName, FunctionName][] = generateProfilesZomeFunctionsArray(\"profiles\");\n"]}
@@ -0,0 +1,17 @@
1
+ import { Profile } from './profiles.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 ProfilesProxy extends ZomeProxy {
10
+ static readonly DEFAULT_ZOME_NAME = "profiles";
11
+ static readonly FN_NAMES: string[];
12
+ createProfile(profile: Profile): Promise<HcRecord>;
13
+ updateProfile(profile: Profile): Promise<HcRecord>;
14
+ searchAgents(nicknameFilter: string): Promise<AgentPubKey[]>;
15
+ getAgentProfile(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 { profilesFunctionNames } from './profiles.fn';
4
+ /**
5
+ *
6
+ */
7
+ export class ProfilesProxy extends ZomeProxy {
8
+ async createProfile(profile) {
9
+ return this.call('create_profile', profile);
10
+ }
11
+ async updateProfile(profile) {
12
+ return this.call('update_profile', profile);
13
+ }
14
+ async searchAgents(nicknameFilter) {
15
+ return this.call('search_agents', nicknameFilter);
16
+ }
17
+ async getAgentProfile(agentPubKey) {
18
+ return this.call('get_agent_profile', agentPubKey);
19
+ }
20
+ async getAgentsWithProfile() {
21
+ return this.call('get_agents_with_profile', null);
22
+ }
23
+ }
24
+ ProfilesProxy.DEFAULT_ZOME_NAME = "profiles";
25
+ ProfilesProxy.FN_NAMES = profilesFunctionNames;
26
+ //# sourceMappingURL=profiles.proxy.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,54 @@
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
+ link_type: LinkTypes;
12
+ } | {
13
+ type: "EntryCreated";
14
+ action: SignedActionHashed;
15
+ app_entry: EntryTypes;
16
+ } | {
17
+ type: "EntryUpdated";
18
+ action: SignedActionHashed;
19
+ app_entry: EntryTypes;
20
+ original_app_entry: EntryTypes;
21
+ } | {
22
+ type: "EntryDeleted";
23
+ action: SignedActionHashed;
24
+ original_app_entry: EntryTypes;
25
+ };
26
+ /**
27
+ * Profile entry definition.
28
+ *
29
+ * The profile must include at a minimum the nickname of the agent
30
+ * in order to be able to search for agents by nickname.
31
+ */
32
+ export interface Profile {
33
+ nickname: string;
34
+ fields: Record<string, string>;
35
+ }
36
+ export declare enum EntryTypesType {
37
+ Profile = "Profile"
38
+ }
39
+ export type EntryTypes = {
40
+ type: "Profile";
41
+ content: Profile;
42
+ };
43
+ export type LinkTypes = {
44
+ PrefixPath: null;
45
+ } | {
46
+ PathToAgent: null;
47
+ } | {
48
+ AgentToProfile: null;
49
+ };
50
+ export declare enum LinkTypesType {
51
+ PrefixPath = "PrefixPath",
52
+ PathToAgent = "PathToAgent",
53
+ AgentToProfile = "AgentToProfile"
54
+ }
@@ -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=profiles.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiles.types.js","sourceRoot":"","sources":["../../src/bindings/profiles.types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AA4K1D,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 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"]}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- export * from "./profiles.zvm";
2
- export * from "./profiles.dvm";
3
- export * from "./profiles.proxy";
1
+ export * from "./bindings/profiles.types";
2
+ export * from "./bindings/profiles.proxy";
3
+ export * from "./profiles.zvm";
4
+ export * from "./profiles.dvm";
5
+ export * from "./utils";
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
- export * from "./profiles.zvm";
2
- export * from "./profiles.dvm";
3
- export * from "./profiles.proxy";
1
+ export * from "./bindings/profiles.types";
2
+ export * from "./bindings/profiles.proxy";
3
+ export * from "./profiles.zvm";
4
+ export * from "./profiles.dvm";
5
+ export * from "./utils";
4
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA","sourcesContent":["export * from \"./profiles.zvm\"\nexport * from \"./profiles.dvm\"\nexport * from \"./profiles.proxy\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AAEzC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA","sourcesContent":["export * from \"./bindings/profiles.types\"\nexport * from \"./bindings/profiles.proxy\"\n\nexport * from \"./profiles.zvm\"\nexport * from \"./profiles.dvm\"\nexport * from \"./utils\"\n"]}
@@ -1,20 +1,20 @@
1
- import { DnaViewModel } from "@ddd-qc/lit-happ";
2
- import { ProfilesZvm } from "./profiles.zvm";
3
- import { AppSignal, AppSignalCb } from "@holochain/client";
4
- /** */
5
- /**
6
- * ViewModel fo a DNA holding a Profiles zome
7
- */
8
- export declare class ProfilesDvm extends DnaViewModel {
9
- static readonly DEFAULT_BASE_ROLE_NAME = "profiles";
10
- static readonly ZVM_DEFS: (typeof ProfilesZvm)[];
11
- readonly signalHandler?: AppSignalCb;
12
- /** QoL Helpers */
13
- get profilesZvm(): ProfilesZvm;
14
- /** -- Perspective -- */
15
- protected hasChanged(): boolean;
16
- get perspective(): unknown;
17
- /** -- Signaling -- */
18
- /** */
19
- handleSignal(signal: AppSignal): void;
20
- }
1
+ import { DnaViewModel } from "@ddd-qc/lit-happ";
2
+ import { ProfilesZvm } from "./profiles.zvm";
3
+ import { AppSignal, AppSignalCb } from "@holochain/client";
4
+ /** */
5
+ /**
6
+ * ViewModel fo a DNA holding a Profiles zome
7
+ */
8
+ export declare class ProfilesDvm extends DnaViewModel {
9
+ static readonly DEFAULT_BASE_ROLE_NAME = "profiles";
10
+ static readonly ZVM_DEFS: (typeof ProfilesZvm)[];
11
+ readonly signalHandler?: AppSignalCb;
12
+ /** QoL Helpers */
13
+ get profilesZvm(): ProfilesZvm;
14
+ /** -- Perspective -- */
15
+ protected hasChanged(): boolean;
16
+ get perspective(): unknown;
17
+ /** -- Signaling -- */
18
+ /** */
19
+ handleSignal(signal: AppSignal): void;
20
+ }
@@ -1,37 +1,37 @@
1
- import { DnaViewModel } from "@ddd-qc/lit-happ";
2
- import { ProfilesZvm } from "./profiles.zvm";
3
- /** */
4
- // export interface ProfilesDnaPerspective {
5
- // agentPresences: Record<string, number>,
6
- // }
7
- /**
8
- * ViewModel fo a DNA holding a Profiles zome
9
- */
10
- export class ProfilesDvm extends DnaViewModel {
11
- constructor() {
12
- super(...arguments);
13
- this.signalHandler = this.handleSignal;
14
- }
15
- /** QoL Helpers */
16
- get profilesZvm() {
17
- return this.getZomeViewModel(ProfilesZvm.DEFAULT_ZOME_NAME);
18
- }
19
- /** -- Perspective -- */
20
- hasChanged() {
21
- return true;
22
- }
23
- get perspective() {
24
- return {};
25
- }
26
- /** -- Signaling -- */
27
- /** */
28
- handleSignal(signal) {
29
- console.log("Received Signal", signal);
30
- if (signal.zome_name !== ProfilesZvm.DEFAULT_ZOME_NAME) {
31
- return;
32
- }
33
- }
34
- }
35
- ProfilesDvm.DEFAULT_BASE_ROLE_NAME = "profiles";
36
- ProfilesDvm.ZVM_DEFS = [ProfilesZvm];
1
+ import { DnaViewModel } from "@ddd-qc/lit-happ";
2
+ import { ProfilesZvm } from "./profiles.zvm";
3
+ /** */
4
+ // export interface ProfilesDnaPerspective {
5
+ // agentPresences: Record<string, number>,
6
+ // }
7
+ /**
8
+ * ViewModel fo a DNA holding a Profiles zome
9
+ */
10
+ export class ProfilesDvm extends DnaViewModel {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.signalHandler = this.handleSignal;
14
+ }
15
+ /** QoL Helpers */
16
+ get profilesZvm() {
17
+ return this.getZomeViewModel(ProfilesZvm.DEFAULT_ZOME_NAME);
18
+ }
19
+ /** -- Perspective -- */
20
+ hasChanged() {
21
+ return true;
22
+ }
23
+ get perspective() {
24
+ return {};
25
+ }
26
+ /** -- Signaling -- */
27
+ /** */
28
+ handleSignal(signal) {
29
+ console.log("Received Signal", signal);
30
+ if (signal.zome_name !== ProfilesZvm.DEFAULT_ZOME_NAME) {
31
+ return;
32
+ }
33
+ }
34
+ }
35
+ ProfilesDvm.DEFAULT_BASE_ROLE_NAME = "profiles";
36
+ ProfilesDvm.ZVM_DEFS = [ProfilesZvm];
37
37
  //# sourceMappingURL=profiles.dvm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.dvm.js","sourceRoot":"","sources":["../src/profiles.dvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAC,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAK3C,MAAM;AACN,4CAA4C;AAC5C,4CAA4C;AAC5C,IAAI;AAGJ;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,YAAY;IAA7C;;QAIW,kBAAa,GAAiB,IAAI,CAAC,YAAY,CAAC;IA8B3D,CAAC;IA3BC,kBAAkB;IAClB,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,iBAAiB,CAAgB,CAAA;IAC5E,CAAC;IAED,wBAAwB;IAEd,UAAU;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,WAAW;QACb,OAAO,EAAE,CAAA;IACX,CAAC;IAGD,sBAAsB;IAEtB,MAAM;IACN,YAAY,CAAC,MAAiB;QAC5B,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACvC,IAAI,MAAM,CAAC,SAAS,KAAK,WAAW,CAAC,iBAAiB,EAAE;YACtD,OAAO;SACR;IACH,CAAC;;AA7Be,kCAAsB,GAAG,UAAU,CAAC;AACpC,oBAAQ,GAAG,CAAC,WAAW,CAAC,CAAA","sourcesContent":["import {delay, DnaViewModel} from \"@ddd-qc/lit-happ\";\nimport {ProfilesZvm} from \"./profiles.zvm\";\nimport {\n AppSignal, AppSignalCb,\n} from \"@holochain/client\";\n\n/** */\n// export interface ProfilesDnaPerspective {\n// agentPresences: Record<string, number>,\n// }\n\n\n/**\n * ViewModel fo a DNA holding a Profiles zome\n */\nexport class ProfilesDvm extends DnaViewModel {\n\n static readonly DEFAULT_BASE_ROLE_NAME = \"profiles\";\n static readonly ZVM_DEFS = [ProfilesZvm]\n readonly signalHandler?: AppSignalCb = this.handleSignal;\n\n\n /** QoL Helpers */\n get profilesZvm(): ProfilesZvm {\n return this.getZomeViewModel(ProfilesZvm.DEFAULT_ZOME_NAME) as ProfilesZvm\n }\n\n /** -- Perspective -- */\n\n protected hasChanged(): boolean {\n return true\n }\n\n get perspective(): unknown {\n return {}\n }\n\n\n /** -- Signaling -- */\n\n /** */\n handleSignal(signal: AppSignal) {\n console.log(\"Received Signal\", signal);\n if (signal.zome_name !== ProfilesZvm.DEFAULT_ZOME_NAME) {\n return;\n }\n }\n\n\n}\n"]}
1
+ {"version":3,"file":"profiles.dvm.js","sourceRoot":"","sources":["../src/profiles.dvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAC,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAK3C,MAAM;AACN,4CAA4C;AAC5C,4CAA4C;AAC5C,IAAI;AAGJ;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,YAAY;IAA7C;;QAIW,kBAAa,GAAiB,IAAI,CAAC,YAAY,CAAC;IA8B3D,CAAC;IA3BC,kBAAkB;IAClB,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,iBAAiB,CAAgB,CAAA;IAC5E,CAAC;IAED,wBAAwB;IAEd,UAAU;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,WAAW;QACb,OAAO,EAAE,CAAA;IACX,CAAC;IAGD,sBAAsB;IAEtB,MAAM;IACN,YAAY,CAAC,MAAiB;QAC5B,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACvC,IAAI,MAAM,CAAC,SAAS,KAAK,WAAW,CAAC,iBAAiB,EAAE;YACtD,OAAO;SACR;IACH,CAAC;;AA7Be,kCAAsB,GAAG,UAAU,AAAb,CAAc;AACpC,oBAAQ,GAAG,CAAC,WAAW,CAAC,AAAhB,CAAgB","sourcesContent":["import {delay, DnaViewModel} from \"@ddd-qc/lit-happ\";\nimport {ProfilesZvm} from \"./profiles.zvm\";\nimport {\n AppSignal, AppSignalCb,\n} from \"@holochain/client\";\n\n/** */\n// export interface ProfilesDnaPerspective {\n// agentPresences: Record<string, number>,\n// }\n\n\n/**\n * ViewModel fo a DNA holding a Profiles zome\n */\nexport class ProfilesDvm extends DnaViewModel {\n\n static readonly DEFAULT_BASE_ROLE_NAME = \"profiles\";\n static readonly ZVM_DEFS = [ProfilesZvm]\n readonly signalHandler?: AppSignalCb = this.handleSignal;\n\n\n /** QoL Helpers */\n get profilesZvm(): ProfilesZvm {\n return this.getZomeViewModel(ProfilesZvm.DEFAULT_ZOME_NAME) as ProfilesZvm\n }\n\n /** -- Perspective -- */\n\n protected hasChanged(): boolean {\n return true\n }\n\n get perspective(): unknown {\n return {}\n }\n\n\n /** -- Signaling -- */\n\n /** */\n handleSignal(signal: AppSignal) {\n console.log(\"Received Signal\", signal);\n if (signal.zome_name !== ProfilesZvm.DEFAULT_ZOME_NAME) {\n return;\n }\n }\n\n\n}\n"]}
@@ -1,39 +1,40 @@
1
- import { ZomeViewModel } from "@ddd-qc/lit-happ";
2
- import { ProfilesProxy, ProfileMat } from "./profiles.proxy";
3
- import { AgentPubKeyB64 } from "@holochain/client";
4
- /** */
5
- export interface ProfilesPerspective {
6
- profiles: Record<AgentPubKeyB64, ProfileMat>;
7
- /** Nickname -> AgentPubKeyB64 */
8
- reversed: Record<string, AgentPubKeyB64>;
9
- }
10
- /**
11
- *
12
- */
13
- export declare class ProfilesZvm extends ZomeViewModel {
14
- static readonly ZOME_PROXY: typeof ProfilesProxy;
15
- get zomeProxy(): ProfilesProxy;
16
- protected hasChanged(): boolean;
17
- /** */
18
- initializePerspectiveOnline(): Promise<void>;
19
- /** */
20
- probeAllInner(): void;
21
- /** -- Perspective -- */
22
- get perspective(): ProfilesPerspective;
23
- private _profiles;
24
- private _reversed;
25
- getMyProfile(): ProfileMat | undefined;
26
- getProfile(agent: AgentPubKeyB64): ProfileMat | undefined;
27
- getAgents(): AgentPubKeyB64[];
28
- getNames(): string[];
29
- /** -- Methods -- */
30
- findProfiles(names: string[]): AgentPubKeyB64[];
31
- /** */
32
- probeAllProfiles(): Promise<Record<AgentPubKeyB64, ProfileMat>>;
33
- /** */
34
- probeProfile(pubKeyB64: AgentPubKeyB64): Promise<ProfileMat | undefined>;
35
- /** */
36
- createMyProfile(profile: ProfileMat): Promise<void>;
37
- /** */
38
- updateMyProfile(profile: ProfileMat): Promise<void>;
39
- }
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 { ProfilesProxy } from "./bindings/profiles.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 ProfilesZvm extends ZomeViewModel {
15
+ static readonly ZOME_PROXY: typeof ProfilesProxy;
16
+ get zomeProxy(): ProfilesProxy;
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
+ /** -- Methods -- */
31
+ findProfiles(names: string[]): AgentPubKeyB64[];
32
+ /** */
33
+ probeAllProfiles(): Promise<Record<AgentPubKeyB64, ProfileMat>>;
34
+ /** */
35
+ probeProfile(pubKeyB64: AgentPubKeyB64): Promise<ProfileMat | undefined>;
36
+ /** */
37
+ createMyProfile(profile: ProfileMat): Promise<void>;
38
+ /** */
39
+ updateMyProfile(profile: ProfileMat): Promise<void>;
40
+ }
@@ -1,109 +1,110 @@
1
- import { ZomeViewModel } from "@ddd-qc/lit-happ";
2
- import { ProfilesProxy } from "./profiles.proxy";
3
- import { decodeHashFromBase64, encodeHashToBase64 } from "@holochain/client";
4
- /**
5
- *
6
- */
7
- export class ProfilesZvm extends ZomeViewModel {
8
- constructor() {
9
- super(...arguments);
10
- this._profiles = {};
11
- //private _profile_ahs: Record<AgentPubKeyB64, ActionHashB64> = {};
12
- this._reversed = {};
13
- }
14
- get zomeProxy() { return this._zomeProxy; }
15
- /* */
16
- hasChanged() {
17
- // TODO
18
- return true;
19
- }
20
- /** */
21
- async initializePerspectiveOnline() {
22
- await this.probeAllProfiles();
23
- }
24
- /** */
25
- probeAllInner() {
26
- this.probeAllProfiles();
27
- }
28
- /** -- Perspective -- */
29
- /* */
30
- get perspective() {
31
- return {
32
- profiles: this._profiles,
33
- reversed: this._reversed,
34
- //profile_ahs: this._profile_ahs,
35
- };
36
- }
37
- getMyProfile() { return this._profiles[this.cell.agentPubKey]; }
38
- getProfile(agent) { return this._profiles[agent]; }
39
- //getProfileHash(agent: AgentPubKeyB64): ActionHashB64 | undefined {return this._profile_ahs[agent]}
40
- getAgents() { return Object.keys(this._profiles); }
41
- getNames() { return Object.keys(this._reversed); }
42
- /** -- Methods -- */
43
- /* */
44
- findProfiles(names) {
45
- let res = [];
46
- for (const name of names) {
47
- if (this._reversed[name]) {
48
- res.push(this._reversed[name]);
49
- }
50
- }
51
- return res;
52
- }
53
- /** */
54
- async probeAllProfiles() {
55
- let allAgents;
56
- /** Attempt a retry on fail as this can create an entry and generate an error (path anchor) */
57
- try {
58
- allAgents = await this.zomeProxy.getAgentsWithProfile();
59
- }
60
- catch (e) {
61
- allAgents = await this.zomeProxy.getAgentsWithProfile();
62
- }
63
- for (const agentPubKey of allAgents) {
64
- const maybeProfile = await this.zomeProxy.getAgentProfile(agentPubKey);
65
- if (!maybeProfile) {
66
- continue;
67
- }
68
- //const maybeProfile: ThreadsProfile = decode((record.entry as any).Present.entry) as ThreadsProfile;
69
- const pubKeyB64 = encodeHashToBase64(agentPubKey);
70
- this._profiles[pubKeyB64] = maybeProfile;
71
- this._reversed[maybeProfile.nickname] = pubKeyB64;
72
- //this._profile_ahs[pubKeyB64] = encodeHashToBase64(record.signed_action.hashed.hash);
73
- }
74
- this.notifySubscribers();
75
- return this._profiles;
76
- }
77
- /** */
78
- async probeProfile(pubKeyB64) {
79
- const maybeProfile = await this.zomeProxy.getAgentProfile(decodeHashFromBase64(pubKeyB64));
80
- console.log("probeProfile()", maybeProfile);
81
- if (!maybeProfile) {
82
- return;
83
- }
84
- //const maybeProfile: ThreadsProfile = decode((record.entry as any).Present.entry) as ThreadsProfile;
85
- this._profiles[pubKeyB64] = maybeProfile;
86
- this._reversed[maybeProfile.nickname] = pubKeyB64;
87
- //this._profile_ahs[pubKeyB64] = encodeHashToBase64(record.signed_action.hashed.hash);
88
- this.notifySubscribers();
89
- return maybeProfile;
90
- }
91
- /** */
92
- async createMyProfile(profile) {
93
- /*const record =*/ await this.zomeProxy.createProfile(profile);
94
- this._profiles[this.cell.agentPubKey] = profile;
95
- this._reversed[profile.nickname] = this.cell.agentPubKey;
96
- //this._profile_ahs[this.cell.agentPubKey] = encodeHashToBase64(record.signed_action.hashed.hash);
97
- this.notifySubscribers();
98
- }
99
- /** */
100
- async updateMyProfile(profile) {
101
- /*const record =*/ await this.zomeProxy.updateProfile(profile);
102
- this._profiles[this.cell.agentPubKey] = profile;
103
- this._reversed[profile.nickname] = this.cell.agentPubKey;
104
- //this._profile_ahs[this.cell.agentPubKey] = encodeHashToBase64(record.signed_action.hashed.hash);
105
- this.notifySubscribers();
106
- }
107
- }
108
- ProfilesZvm.ZOME_PROXY = ProfilesProxy;
1
+ import { ZomeViewModel } from "@ddd-qc/lit-happ";
2
+ import { decodeHashFromBase64, encodeHashToBase64 } from "@holochain/client";
3
+ import { ProfilesProxy } from "./bindings/profiles.proxy";
4
+ import { decode } from "@msgpack/msgpack";
5
+ /**
6
+ *
7
+ */
8
+ export class ProfilesZvm 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
+ /** -- Methods -- */
44
+ /* */
45
+ findProfiles(names) {
46
+ let res = [];
47
+ for (const name of names) {
48
+ if (this._reversed[name]) {
49
+ res.push(this._reversed[name]);
50
+ }
51
+ }
52
+ return res;
53
+ }
54
+ /** */
55
+ async probeAllProfiles() {
56
+ let allAgents;
57
+ /** Attempt a retry on fail as this can create an entry (path anchor) and generate a 'head has moved' error */
58
+ try {
59
+ allAgents = await this.zomeProxy.getAgentsWithProfile();
60
+ }
61
+ catch (e) {
62
+ allAgents = await this.zomeProxy.getAgentsWithProfile();
63
+ }
64
+ for (const agentPubKey of allAgents) {
65
+ const maybeProfile = await this.zomeProxy.getAgentProfile(agentPubKey);
66
+ if (!maybeProfile) {
67
+ continue;
68
+ }
69
+ 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);
74
+ }
75
+ this.notifySubscribers();
76
+ return this._profiles;
77
+ }
78
+ /** */
79
+ async probeProfile(pubKeyB64) {
80
+ const maybeProfile = await this.zomeProxy.getAgentProfile(decodeHashFromBase64(pubKeyB64));
81
+ console.log("probeProfile()", maybeProfile);
82
+ if (!maybeProfile) {
83
+ return;
84
+ }
85
+ const profile = decode(maybeProfile.entry.Present.entry);
86
+ this._profiles[pubKeyB64] = profile;
87
+ this._reversed[profile.nickname] = pubKeyB64;
88
+ //this._profile_ahs[pubKeyB64] = encodeHashToBase64(record.signed_action.hashed.hash);
89
+ this.notifySubscribers();
90
+ return profile;
91
+ }
92
+ /** */
93
+ async createMyProfile(profile) {
94
+ /*const record =*/ await this.zomeProxy.createProfile(profile);
95
+ this._profiles[this.cell.agentPubKey] = profile;
96
+ this._reversed[profile.nickname] = this.cell.agentPubKey;
97
+ //this._profile_ahs[this.cell.agentPubKey] = encodeHashToBase64(record.signed_action.hashed.hash);
98
+ this.notifySubscribers();
99
+ }
100
+ /** */
101
+ async updateMyProfile(profile) {
102
+ /*const record =*/ await this.zomeProxy.updateProfile(profile);
103
+ this._profiles[this.cell.agentPubKey] = profile;
104
+ this._reversed[profile.nickname] = this.cell.agentPubKey;
105
+ //this._profile_ahs[this.cell.agentPubKey] = encodeHashToBase64(record.signed_action.hashed.hash);
106
+ this.notifySubscribers();
107
+ }
108
+ }
109
+ ProfilesZvm.ZOME_PROXY = ProfilesProxy;
109
110
  //# sourceMappingURL=profiles.zvm.js.map
@@ -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;AAC/C,OAAO,EAAC,aAAa,EAAa,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAiB,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAe3F;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,aAAa;IAA9C;;QAkCU,cAAS,GAAuC,EAAE,CAAC;QAC3D,mEAAmE;QAC3D,cAAS,GAAmC,EAAE,CAAC;IAuFzD,CAAC;IAxHC,IAAI,SAAS,KAAmB,OAA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,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;;AAvHe,sBAAU,GAAG,aAAa,CAAC","sourcesContent":["import {ZomeViewModel} from \"@ddd-qc/lit-happ\";\nimport {ProfilesProxy, ProfileMat} from \"./profiles.proxy\";\nimport {AgentPubKeyB64, decodeHashFromBase64, encodeHashToBase64} from \"@holochain/client\";\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 and generate an error (path anchor) */\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 maybeProfile: ThreadsProfile = decode((record.entry as any).Present.entry) as ThreadsProfile;\n const pubKeyB64 = encodeHashToBase64(agentPubKey);\n this._profiles[pubKeyB64] = maybeProfile;\n this._reversed[maybeProfile.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);\n if (!maybeProfile) {\n return;\n }\n //const maybeProfile: ThreadsProfile = decode((record.entry as any).Present.entry) as ThreadsProfile;\n this._profiles[pubKeyB64] = maybeProfile;\n this._reversed[maybeProfile.nickname] = pubKeyB64;\n //this._profile_ahs[pubKeyB64] = encodeHashToBase64(record.signed_action.hashed.hash);\n this.notifySubscribers();\n return maybeProfile;\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":["../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,m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AC;QACpC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;QAC7C,sFAAsF;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;;AAvHe,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);\n if (!maybeProfile) {\n return;\n }\n const profile: ProfileMat = decode((maybeProfile.entry as any).Present.entry) as ProfileMat;\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"]}
package/dist/utils.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { AgentPubKeyB64 } from "@holochain/client";
2
- import { ProfilesPerspective } from "./profiles.zvm";
3
- import { ProfileMat } from "./profiles.proxy";
4
- import { TemplateResult } from "lit";
5
- /** */
6
- export declare function getInitials(nickname: string): string;
7
- /** */
8
- export declare function agent2avatar(key: AgentPubKeyB64, profilesPerspective: ProfilesPerspective): [ProfileMat, TemplateResult<1>];
1
+ import { AgentPubKeyB64 } from "@holochain/client";
2
+ import { ProfilesPerspective } from "./profiles.zvm";
3
+ import { Profile as ProfileMat } from "./bindings/profiles.types";
4
+ import { TemplateResult } from "lit";
5
+ /** */
6
+ export declare function getInitials(nickname: string): string;
7
+ /** */
8
+ export declare function agent2avatar(key: AgentPubKeyB64, profilesPerspective: ProfilesPerspective): [ProfileMat, TemplateResult<1>];
package/dist/utils.js CHANGED
@@ -1,35 +1,35 @@
1
- import { html } from "lit";
2
- /** */
3
- export function getInitials(nickname) {
4
- const names = nickname.split(' ');
5
- let initials = names[0].substring(0, 1).toUpperCase();
6
- if (names.length > 1) {
7
- initials += names[names.length - 1].substring(0, 1).toUpperCase();
8
- }
9
- else {
10
- initials += names[0].substring(1, 2);
11
- }
12
- return initials;
13
- }
14
- /** */
15
- export function agent2avatar(key, profilesPerspective) {
16
- let profile = { nickname: "unknown", fields: {} };
17
- const maybeProfile = profilesPerspective.profiles[key];
18
- if (maybeProfile) {
19
- profile = maybeProfile;
20
- }
21
- else {
22
- console.log("Profile not found for agent", key, profilesPerspective.profiles);
23
- }
24
- const initials = getInitials(profile.nickname);
25
- const avatarUrl = profile.fields['avatar'];
26
- const avatar = avatarUrl ? html `
27
- <sl-avatar class="activityAvatar" style="box-shadow: 1px 1px 1px 1px rgba(130, 122, 122, 0.88)">
28
- <img src=${avatarUrl}>
29
- </sl-avatar>
30
- ` : html `
31
- <sl-avatar class="activityAvatar" shape="circle" initials=${initials} color-scheme="Accent2"></sl-avatar>
32
- `;
33
- return [profile, avatar];
34
- }
1
+ import { html } from "lit";
2
+ /** */
3
+ export function getInitials(nickname) {
4
+ const names = nickname.split(' ');
5
+ let initials = names[0].substring(0, 1).toUpperCase();
6
+ if (names.length > 1) {
7
+ initials += names[names.length - 1].substring(0, 1).toUpperCase();
8
+ }
9
+ else {
10
+ initials += names[0].substring(1, 2);
11
+ }
12
+ return initials;
13
+ }
14
+ /** */
15
+ export function agent2avatar(key, profilesPerspective) {
16
+ let profile = { nickname: "unknown", fields: {} };
17
+ const maybeProfile = profilesPerspective.profiles[key];
18
+ if (maybeProfile) {
19
+ profile = maybeProfile;
20
+ }
21
+ else {
22
+ console.log("Profile not found for agent", key, profilesPerspective.profiles);
23
+ }
24
+ const initials = getInitials(profile.nickname);
25
+ const avatarUrl = profile.fields['avatar'];
26
+ const avatar = avatarUrl ? html `
27
+ <sl-avatar class="activityAvatar" style="box-shadow: 1px 1px 1px 1px rgba(130, 122, 122, 0.88)">
28
+ <img src=${avatarUrl}>
29
+ </sl-avatar>
30
+ ` : html `
31
+ <sl-avatar class="activityAvatar" shape="circle" initials=${initials} color-scheme="Accent2"></sl-avatar>
32
+ `;
33
+ return [profile, avatar];
34
+ }
35
35
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,IAAI,EAAiB,MAAM,KAAK,CAAC;AAEzC,MAAM;AACN,MAAM,UAAU,WAAW,CAAC,QAAgB;IACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACtD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QAClB,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;KACrE;SAAM;QACH,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACxC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC;AAID,MAAM;AACN,MAAM,UAAU,YAAY,CAAC,GAAmB,EAAE,mBAAwC;IACtF,IAAI,OAAO,GAAG,EAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAe,CAAC;IAC9D,MAAM,YAAY,GAAG,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACvD,IAAI,YAAY,EAAE;QACd,OAAO,GAAG,YAAY,CAAC;KAC1B;SAAM;QACH,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,GAAG,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAA;KAChF;IACD,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC3C,MAAM,MAAM,GACR,SAAS,CAAA,CAAC,CAAC,IAAI,CAAA;;yBAEE,SAAS;;aAErB,CAAC,CAAC,CAAC,IAAI,CAAA;oEACgD,QAAQ;iBAC3D,CAAC;IACd,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import {AgentPubKeyB64} from \"@holochain/client\";\r\nimport {ProfilesPerspective} from \"./profiles.zvm\";\r\nimport {ProfileMat} from \"./profiles.proxy\";\r\nimport {html, TemplateResult} from \"lit\";\r\n\r\n/** */\r\nexport function getInitials(nickname: string): string {\r\n const names = nickname.split(' ');\r\n let initials = names[0].substring(0, 1).toUpperCase();\r\n if (names.length > 1) {\r\n initials += names[names.length - 1].substring(0, 1).toUpperCase();\r\n } else {\r\n initials += names[0].substring(1, 2);\r\n }\r\n return initials;\r\n}\r\n\r\n\r\n\r\n/** */\r\nexport function agent2avatar(key: AgentPubKeyB64, profilesPerspective: ProfilesPerspective): [ProfileMat, TemplateResult<1>] {\r\n let profile = {nickname: \"unknown\", fields: {}} as ProfileMat;\r\n const maybeProfile = profilesPerspective.profiles[key];\r\n if (maybeProfile) {\r\n profile = maybeProfile;\r\n } else {\r\n console.log(\"Profile not found for agent\", key, profilesPerspective.profiles)\r\n }\r\n const initials = getInitials(profile.nickname);\r\n const avatarUrl = profile.fields['avatar'];\r\n const avatar =\r\n avatarUrl? html`\r\n <sl-avatar class=\"activityAvatar\" style=\"box-shadow: 1px 1px 1px 1px rgba(130, 122, 122, 0.88)\">\r\n <img src=${avatarUrl}>\r\n </sl-avatar> \r\n ` : html`\r\n <sl-avatar class=\"activityAvatar\" shape=\"circle\" initials=${initials} color-scheme=\"Accent2\"></sl-avatar>\r\n `;\r\n return [profile, avatar];\r\n}\r\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,IAAI,EAAiB,MAAM,KAAK,CAAC;AAEzC,MAAM;AACN,MAAM,UAAU,WAAW,CAAC,QAAgB;IACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACtD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QAClB,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;KACrE;SAAM;QACH,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACxC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC;AAID,MAAM;AACN,MAAM,UAAU,YAAY,CAAC,GAAmB,EAAE,mBAAwC;IACtF,IAAI,OAAO,GAAG,EAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAe,CAAC;IAC9D,MAAM,YAAY,GAAG,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACvD,IAAI,YAAY,EAAE;QACd,OAAO,GAAG,YAAY,CAAC;KAC1B;SAAM;QACH,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,GAAG,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAA;KAChF;IACD,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC3C,MAAM,MAAM,GACR,SAAS,CAAA,CAAC,CAAC,IAAI,CAAA;;yBAEE,SAAS;;aAErB,CAAC,CAAC,CAAC,IAAI,CAAA;oEACgD,QAAQ;iBAC3D,CAAC;IACd,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import {AgentPubKeyB64} from \"@holochain/client\";\nimport {ProfilesPerspective} from \"./profiles.zvm\";\nimport {Profile as ProfileMat} from \"./bindings/profiles.types\";\nimport {html, TemplateResult} from \"lit\";\n\n/** */\nexport function getInitials(nickname: string): string {\n const names = nickname.split(' ');\n let initials = names[0].substring(0, 1).toUpperCase();\n if (names.length > 1) {\n initials += names[names.length - 1].substring(0, 1).toUpperCase();\n } else {\n initials += names[0].substring(1, 2);\n }\n return initials;\n}\n\n\n\n/** */\nexport function agent2avatar(key: AgentPubKeyB64, profilesPerspective: ProfilesPerspective): [ProfileMat, TemplateResult<1>] {\n let profile = {nickname: \"unknown\", fields: {}} as ProfileMat;\n const maybeProfile = profilesPerspective.profiles[key];\n if (maybeProfile) {\n profile = maybeProfile;\n } else {\n console.log(\"Profile not found for agent\", key, profilesPerspective.profiles)\n }\n const initials = getInitials(profile.nickname);\n const avatarUrl = profile.fields['avatar'];\n const avatar =\n avatarUrl? html`\n <sl-avatar class=\"activityAvatar\" style=\"box-shadow: 1px 1px 1px 1px rgba(130, 122, 122, 0.88)\">\n <img src=${avatarUrl}>\n </sl-avatar> \n ` : html`\n <sl-avatar class=\"activityAvatar\" shape=\"circle\" initials=${initials} color-scheme=\"Accent2\"></sl-avatar>\n `;\n return [profile, avatar];\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-qc/profiles-dvm",
3
- "version": "0.19.19",
3
+ "version": "0.20.0",
4
4
  "description": "DnaViewModel implementation for the Profiles zome.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -26,13 +26,14 @@
26
26
  "devDependencies": {
27
27
  "@types/node": "^20.8.9",
28
28
  "tslib": "^2.4.0",
29
- "typescript": "^4.9.0"
29
+ "typescript": "~5.2.0"
30
30
  },
31
31
  "dependencies": {
32
32
  "@ddd-qc/lit-happ": "file:../lit-happ",
33
+ "@holochain-open-dev/core-types": "0.7.0",
33
34
  "@holochain/client": "=0.16.2",
34
35
  "@msgpack/msgpack": "^2.7.2",
35
- "lit": "^2.6.0"
36
+ "lit": "3.0.2"
36
37
  },
37
38
  "engines": {
38
39
  "node": "^14.13.1 || >=16.0.0 || >=18.0.0"
@@ -1,18 +0,0 @@
1
- import { AgentPubKey } from '@holochain/client';
2
- import { ZomeProxy } from "@ddd-qc/lit-happ";
3
- export interface ProfileMat {
4
- nickname: string;
5
- fields: Record<string, string>;
6
- }
7
- /**
8
- *
9
- */
10
- export declare class ProfilesProxy extends ZomeProxy {
11
- static readonly DEFAULT_ZOME_NAME = "profiles";
12
- static readonly FN_NAMES: string[];
13
- createProfile(profile: ProfileMat): Promise<void>;
14
- updateProfile(profile: ProfileMat): Promise<void>;
15
- searchAgents(nickname_filter: string): Promise<AgentPubKey[]>;
16
- getAgentProfile(agentPubKey: AgentPubKey): Promise<ProfileMat | undefined>;
17
- getAgentsWithProfile(): Promise<AgentPubKey[]>;
18
- }
@@ -1,40 +0,0 @@
1
- import { ZomeProxy } from "@ddd-qc/lit-happ";
2
- import { decode } from "@msgpack/msgpack";
3
- /**
4
- *
5
- */
6
- export class ProfilesProxy extends ZomeProxy {
7
- async createProfile(profile) {
8
- return this.callBlocking('create_profile', profile);
9
- }
10
- async updateProfile(profile) {
11
- return this.callBlocking('update_profile', profile);
12
- }
13
- async searchAgents(nickname_filter) {
14
- return this.call('search_agents', { nickname_filter });
15
- }
16
- async getAgentProfile(agentPubKey) {
17
- var _a, _b;
18
- const record = await this.call('get_agent_profile', agentPubKey);
19
- console.log("getAgentProfile() record", record);
20
- if (!record) {
21
- return undefined;
22
- }
23
- const entry = (_b = (_a = record.entry) === null || _a === void 0 ? void 0 : _a.Present) === null || _b === void 0 ? void 0 : _b.entry;
24
- console.log("getAgentProfile() entry", entry);
25
- return decode(entry);
26
- }
27
- async getAgentsWithProfile() {
28
- return this.call('get_agents_with_profile', null);
29
- }
30
- }
31
- ProfilesProxy.DEFAULT_ZOME_NAME = "profiles";
32
- ProfilesProxy.FN_NAMES = [
33
- "entry_defs",
34
- 'create_profile',
35
- 'update_profile',
36
- "search_agents",
37
- "get_agent_profile",
38
- "get_agents_with_profile",
39
- ];
40
- //# sourceMappingURL=profiles.proxy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"profiles.proxy.js","sourceRoot":"","sources":["../src/profiles.proxy.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAU1C;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAY1C,KAAK,CAAC,aAAa,CAAC,OAAmB;QACrC,OAAO,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAmB;QACrC,OAAO,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,eAAuB;QACxC,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,EAAC,eAAe,EAAC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,WAAwB;;QAC5C,MAAM,MAAM,GAA0B,MAAM,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;QACxF,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,SAAS,CAAC;SAClB;QACD,MAAM,KAAK,GAAG,MAAA,MAAC,MAAM,CAAC,KAAa,0CAAE,OAAO,0CAAE,KAAK,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC,KAAK,CAAe,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;;AApCe,+BAAiB,GAAG,UAAU,CAAA;AAC9B,sBAAQ,GAAG;IACzB,YAAY;IACZ,gBAAgB;IAChB,gBAAgB;IAChB,eAAe;IACf,mBAAmB;IACnB,yBAAyB;CAC1B,CAAC","sourcesContent":["import { AgentPubKey, Record as HcRecord } from '@holochain/client';\nimport {ZomeProxy} from \"@ddd-qc/lit-happ\";\nimport { decode } from \"@msgpack/msgpack\";\n\n\nexport interface ProfileMat {\n nickname: string;\n fields: Record<string, string>;\n}\n\n\n\n/**\n *\n */\nexport class ProfilesProxy extends ZomeProxy {\n static readonly DEFAULT_ZOME_NAME = \"profiles\"\n static readonly FN_NAMES = [\n \"entry_defs\",\n 'create_profile',\n 'update_profile',\n \"search_agents\",\n \"get_agent_profile\",\n \"get_agents_with_profile\",\n ];\n\n\n async createProfile(profile: ProfileMat): Promise<void> {\n return this.callBlocking('create_profile', profile);\n }\n\n async updateProfile(profile: ProfileMat): Promise<void> {\n return this.callBlocking('update_profile', profile);\n }\n\n async searchAgents(nickname_filter: string): Promise<AgentPubKey[]> {\n return this.call('search_agents', {nickname_filter});\n }\n\n async getAgentProfile(agentPubKey: AgentPubKey): Promise<ProfileMat | undefined> {\n const record: HcRecord | undefined = await this.call('get_agent_profile', agentPubKey);\n console.log(\"getAgentProfile() record\", record);\n if (!record) {\n return undefined;\n }\n const entry = (record.entry as any)?.Present?.entry;\n console.log(\"getAgentProfile() entry\", entry);\n return decode(entry) as ProfileMat;\n }\n\n async getAgentsWithProfile(): Promise<AgentPubKey[]> {\n return this.call('get_agents_with_profile', null);\n }\n\n}\n"]}