@ddd-qc/profiles-dvm 0.26.11 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bindings/profiles.proxy.d.ts +6 -4
- package/dist/bindings/profiles.proxy.js.map +1 -1
- package/dist/bindings/profiles.types.js.map +1 -1
- package/dist/bindings/profilesAlt.proxy.d.ts +7 -5
- package/dist/bindings/profilesAlt.proxy.js.map +1 -1
- package/dist/bindings/profilesAlt.types.js.map +1 -1
- package/dist/elements/edit-profile.js +1 -1
- package/dist/elements/edit-profile.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/profiles.zvm.js +3 -3
- package/dist/profiles.zvm.js.map +1 -1
- package/dist/profilesAlt.perspective.d.ts +18 -10
- package/dist/profilesAlt.perspective.js +54 -38
- package/dist/profilesAlt.perspective.js.map +1 -1
- package/dist/profilesAlt.zvm.d.ts +2 -1
- package/dist/profilesAlt.zvm.js +17 -17
- package/dist/profilesAlt.zvm.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Profile } from './profiles.types';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
3
|
/** hdk/record.ts */
|
|
4
4
|
Record as HcRecord } from '@holochain/client';
|
|
5
|
+
type AgentArray = Uint8Array;
|
|
5
6
|
/** User defined external dependencies */
|
|
6
7
|
import { ProfilesLinkType as LinkTypes } from "./profiles.integrity";
|
|
7
8
|
import { ZomeProxy } from '@ddd-qc/lit-happ';
|
|
@@ -16,7 +17,8 @@ export declare class ProfilesProxy extends ZomeProxy {
|
|
|
16
17
|
static readonly LINK_TYPES: LinkTypes[];
|
|
17
18
|
createProfile(profile: Profile): Promise<HcRecord>;
|
|
18
19
|
updateProfile(profile: Profile): Promise<HcRecord>;
|
|
19
|
-
searchAgents(nicknameFilter: string): Promise<
|
|
20
|
-
getAgentProfile(agentPubKey:
|
|
21
|
-
getAgentsWithProfile(): Promise<
|
|
20
|
+
searchAgents(nicknameFilter: string): Promise<AgentArray[]>;
|
|
21
|
+
getAgentProfile(agentPubKey: AgentArray): Promise<HcRecord | null>;
|
|
22
|
+
getAgentsWithProfile(): Promise<AgentArray[]>;
|
|
22
23
|
}
|
|
24
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.proxy.js","sourceRoot":"","sources":["../../src/bindings/profiles.proxy.ts"],"names":[],"mappings":"AAAA,0DAA0D;
|
|
1
|
+
{"version":3,"file":"profiles.proxy.js","sourceRoot":"","sources":["../../src/bindings/profiles.proxy.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAgK1D,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAExE;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAM1C,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,WAAuB;QAC3C,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;;AAvBe,+BAAiB,GAAG,UAAU,CAAC;AAC/B,sBAAQ,GAAG,qBAAqB,CAAC;AACjC,yBAAW,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC9C,wBAAU,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {EntryTypes, Signal, Profile, } from './profiles.types';\nimport {\nWebsocketConnectionOptions,\n/** types.ts */\n//HoloHash,\n//AgentPubKey,\n//DnaHash,\n//WasmHash,\n//EntryHash,\n//ActionHash,\n//AnyDhtHash,\n//ExternalHash,\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\n\n/// Simple Hashes\ntype AgentArray = Uint8Array;\ntype DnaArray = Uint8Array;\ntype WasmArray = Uint8Array;\ntype EntryArray = Uint8Array;\ntype ActionArray = Uint8Array;\ntype AnyDhtArray = Uint8Array;\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\n/** User defined external dependencies */\nimport {ProfilesLinkType as LinkTypes} from \"./profiles.integrity\"\n\nimport {ZomeProxy} from '@ddd-qc/lit-happ';\nimport {profilesFunctionNames} from './profiles.fn';\nimport {ProfilesUnitEnum, ProfilesLinkType} from './profiles.integrity';\n\n/**\n *\n */\nexport class ProfilesProxy extends ZomeProxy {\n static readonly DEFAULT_ZOME_NAME = \"profiles\";\n static readonly FN_NAMES = profilesFunctionNames;\n static readonly ENTRY_TYPES = Object.values(ProfilesUnitEnum);\n static readonly LINK_TYPES = Object.values(ProfilesLinkType);\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<AgentArray[]> {\n return this.call('search_agents', nicknameFilter);\n }\n\n async getAgentProfile(agentPubKey: AgentArray): Promise<HcRecord | null> {\n return this.call('get_agent_profile', agentPubKey);\n }\n\n async getAgentsWithProfile(): Promise<AgentArray[]> {\n return this.call('get_agents_with_profile', null);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.types.js","sourceRoot":"","sources":["../../src/bindings/profiles.types.ts"],"names":[],"mappings":"AAAA,0DAA0D;
|
|
1
|
+
{"version":3,"file":"profiles.types.js","sourceRoot":"","sources":["../../src/bindings/profiles.types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AA4M1D,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACzB,qCAAmB,CAAA;AACpB,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {\nWebsocketConnectionOptions,\n/** types.ts */\n//HoloHash,\n//AgentPubKey,\n//DnaHash,\n//WasmHash,\n//EntryHash,\n//ActionHash,\n//AnyDhtHash,\n//ExternalHash,\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\n\n/// Simple Hashes\ntype AgentArray = Uint8Array;\ntype DnaArray = Uint8Array;\ntype WasmArray = Uint8Array;\ntype EntryArray = Uint8Array;\ntype ActionArray = Uint8Array;\ntype AnyDhtArray = Uint8Array;\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\n/** User defined external dependencies */\nimport {ProfilesLinkType as LinkTypes} from \"./profiles.integrity\"\n\nexport type SignalVariantLinkCreated = {\n type: \"LinkCreated\"\n action: SignedActionHashed\n link_type: LinkTypes\n}\nexport type SignalVariantLinkDeleted = {\n type: \"LinkDeleted\"\n action: SignedActionHashed\n create_link_action: SignedActionHashed\n link_type: LinkTypes\n}\nexport type SignalVariantEntryCreated = {\n type: \"EntryCreated\"\n action: SignedActionHashed\n app_entry: EntryTypes\n}\nexport type SignalVariantEntryUpdated = {\n type: \"EntryUpdated\"\n action: SignedActionHashed\n app_entry: EntryTypes\n original_app_entry: EntryTypes\n}\nexport type SignalVariantEntryDeleted = {\n type: \"EntryDeleted\"\n action: SignedActionHashed\n original_app_entry: EntryTypes\n}\nexport type Signal =\n | SignalVariantLinkCreated\n | SignalVariantLinkDeleted\n | SignalVariantEntryCreated\n | SignalVariantEntryUpdated\n | SignalVariantEntryDeleted;\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: null}, content: Profile}\n\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Profile } from './profilesAlt.types';
|
|
2
|
-
|
|
2
|
+
type AgentArray = Uint8Array;
|
|
3
|
+
type ActionArray = Uint8Array;
|
|
3
4
|
import { ZomeProxy } from '@ddd-qc/lit-happ';
|
|
4
5
|
import { ProfilesAltUnitEnum, ProfilesAltLinkType } from './profilesAlt.integrity';
|
|
5
6
|
/**
|
|
@@ -10,9 +11,10 @@ export declare class ProfilesAltProxy extends ZomeProxy {
|
|
|
10
11
|
static readonly FN_NAMES: string[];
|
|
11
12
|
static readonly ENTRY_TYPES: ProfilesAltUnitEnum.Profile[];
|
|
12
13
|
static readonly LINK_TYPES: ProfilesAltLinkType[];
|
|
13
|
-
createProfile(pair: [Profile,
|
|
14
|
-
updateProfile(pair: [Profile,
|
|
15
|
-
searchAgents(nicknameFilter: string): Promise<
|
|
16
|
-
findProfile(agentPubKey:
|
|
14
|
+
createProfile(pair: [Profile, AgentArray]): Promise<ActionArray>;
|
|
15
|
+
updateProfile(pair: [Profile, AgentArray]): Promise<ActionArray>;
|
|
16
|
+
searchAgents(nicknameFilter: string): Promise<AgentArray[]>;
|
|
17
|
+
findProfile(agentPubKey: AgentArray): Promise<[ActionArray, Profile] | null>;
|
|
17
18
|
probeProfiles(): Promise<void>;
|
|
18
19
|
}
|
|
20
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.proxy.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.proxy.ts"],"names":[],"mappings":"AAAA,0DAA0D;
|
|
1
|
+
{"version":3,"file":"profilesAlt.proxy.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.proxy.ts"],"names":[],"mappings":"AAAA,0DAA0D;AA6J1D,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,wBAAwB,EAAC,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAC,mBAAmB,EAAE,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;AAEjF;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAM7C,KAAK,CAAC,aAAa,CAAC,IAA2B;QAC7C,OAAO,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAA2B;QAC7C,OAAO,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,cAAsB;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,WAAuB;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;;AAvBe,kCAAiB,GAAG,UAAU,CAAC;AAC/B,yBAAQ,GAAG,wBAAwB,CAAC;AACpC,4BAAW,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACjD,2BAAU,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {EntryTypes, Profile, } from './profilesAlt.types';\nimport {\nWebsocketConnectionOptions,\n/** types.ts */\n//HoloHash,\n//AgentPubKey,\n//DnaHash,\n//WasmHash,\n//EntryHash,\n//ActionHash,\n//AnyDhtHash,\n//ExternalHash,\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\n\n/// Simple Hashes\ntype AgentArray = Uint8Array;\ntype DnaArray = Uint8Array;\ntype WasmArray = Uint8Array;\ntype EntryArray = Uint8Array;\ntype ActionArray = Uint8Array;\ntype AnyDhtArray = Uint8Array;\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';\nimport {ProfilesAltUnitEnum, ProfilesAltLinkType} from './profilesAlt.integrity';\n\n/**\n *\n */\nexport class ProfilesAltProxy extends ZomeProxy {\n static readonly DEFAULT_ZOME_NAME = \"profiles\";\n static readonly FN_NAMES = profilesAltFunctionNames;\n static readonly ENTRY_TYPES = Object.values(ProfilesAltUnitEnum);\n static readonly LINK_TYPES = Object.values(ProfilesAltLinkType);\n \n async createProfile(pair: [Profile, AgentArray]): Promise<ActionArray> {\n return this.callBlocking('create_profile', pair);\n }\n\n async updateProfile(pair: [Profile, AgentArray]): Promise<ActionArray> {\n return this.callBlocking('update_profile', pair);\n }\n\n async searchAgents(nicknameFilter: string): Promise<AgentArray[]> {\n return this.call('search_agents', nicknameFilter);\n }\n\n async findProfile(agentPubKey: AgentArray): Promise<[ActionArray, Profile] | null> {\n return this.call('find_profile', agentPubKey);\n }\n\n async probeProfiles(): Promise<void> {\n return this.callBlocking('probe_profiles', null);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.types.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.types.ts"],"names":[],"mappings":"AAAA,0DAA0D;
|
|
1
|
+
{"version":3,"file":"profilesAlt.types.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAuK1D,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACzB,qCAAmB,CAAA;AACpB,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {\nWebsocketConnectionOptions,\n/** types.ts */\n//HoloHash,\n//AgentPubKey,\n//DnaHash,\n//WasmHash,\n//EntryHash,\n//ActionHash,\n//AnyDhtHash,\n//ExternalHash,\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\n\n/// Simple Hashes\ntype AgentArray = Uint8Array;\ntype DnaArray = Uint8Array;\ntype WasmArray = Uint8Array;\ntype EntryArray = Uint8Array;\ntype ActionArray = Uint8Array;\ntype AnyDhtArray = Uint8Array;\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\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: null}, content: Profile}\n\n"]}
|
|
@@ -75,7 +75,7 @@ let EditProfile = class EditProfile extends LitElement {
|
|
|
75
75
|
|
|
76
76
|
<div class="row" style="justify-content: center; margin-bottom: 8px; align-self: start;" >
|
|
77
77
|
<span style="font-size:18px;padding-right:10px;">${msg('Language')}:</span>
|
|
78
|
-
<sl-radio-group id="langRadioGroup" @click
|
|
78
|
+
<sl-radio-group id="langRadioGroup" @click=${this.handleLangChange} .value=${(_c = this.profile) === null || _c === void 0 ? void 0 : _c.fields['lang']}>
|
|
79
79
|
<sl-radio value="en">🇬🇧</sl-radio>
|
|
80
80
|
<sl-radio value="fr-fr">🇫🇷</sl-radio>
|
|
81
81
|
</sl-radio-group>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-profile.js","sourceRoot":"","sources":["../../src/elements/edit-profile.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,GAAG,EAAE,IAA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AC,AA7DQ,CA6DP;AAtJN;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CACE;AALlB,WAAW;IAFvB,SAAS,EAAE;IACX,aAAa,CAAC,uBAAuB,CAAC;GAC1B,WAAW,CA4JvB","sourcesContent":["import {css, html, LitElement} from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { localized, msg, str } from '@lit/localize';\nimport { onSubmit, sharedStyles } from '@holochain-open-dev/elements';\n\nimport '@holochain-open-dev/elements/dist/elements/select-avatar.js';\nimport {Profile} from \"../bindings/profilesAlt.types\";\n\n\n\n//import \"@shoelace-style/shoelace/dist/components/avatar/avatar.js\";\n//import \"@shoelace-style/shoelace/dist/components/button/button.js\";\n//import \"@shoelace-style/shoelace/dist/components/icon/icon.js\";\n//import \"@shoelace-style/shoelace/dist/components/input/input.js\";\n//import \"@shoelace-style/shoelace/dist/components/radio/radio.js\";\n//import \"@shoelace-style/shoelace/dist/components/radio-group/radio-group.js\";\n//import \"@shoelace-style/shoelace/dist/components/tooltip/tooltip.js\";\n\n\n\nconst MIN_NICKNAME_LENGTH = 2\n\n\n/**\n * @fires save-profile - Fired when the save profile button is clicked\n */\n@localized()\n@customElement('profiles-edit-profile')\nexport class EditProfile extends LitElement {\n\n\n /** The profile to be edited. */\n @property({ type: Object })\n profile: Profile | undefined;\n\n\n /** -- Methods -- */\n\n /**\n * Seperate Mailgun token from other fields as we don't want it to be saved in Profiles\n */\n async fireSaveProfile(formFields: Record<string, string>) {\n console.log(\"fireSaveProfile()\", formFields);\n const nickname = formFields['nickname'];\n delete formFields['nickname'];\n\n const fields = {}\n //fields['email'] = formFields['email'];\n fields['avatar'] = formFields['avatar']? formFields['avatar'] : \"\";\n fields['lang'] = formFields['option']? formFields['option'] : \"\";\n\n\n /** */\n this.dispatchEvent(\n new CustomEvent<Profile>('save-profile', {\n detail: {nickname, fields} as Profile,\n bubbles: true,\n composed: true,\n })\n );\n\n }\n\n\n /** */\n async handleLangChange(_e: any) {\n //console.log({langChangeEvent: e});\n const langRadioGroup = this.shadowRoot!.getElementById(\"langRadioGroup\") as any;\n console.log({langRadioGroup});\n const lang = langRadioGroup.value;\n console.log(\"handleLangChange: lang =\", lang);\n this.dispatchEvent(new CustomEvent('lang-selected', { detail: lang, bubbles: true, composed: true }));\n }\n\n\n /** */\n render() {\n console.log(\"<profiles-edit-profile>.render()\", this.profile);\n\n /** */\n return html`\n <form id=\"profile-form\" class=\"column\"\n ${onSubmit(fields => /*await*/ this.fireSaveProfile(fields))}>\n \n <div class=\"row\"\n style=\"justify-content: center; align-self: start; margin-bottom: 16px; width: 100%;\">\n <select-avatar\n style=\"cursor:pointer\"\n name=\"avatar\"\n .value=${this.profile?.fields['avatar'] || undefined}\n ></select-avatar>\n <label for=\"nickname\">Nickname:</label>\n <input\n type=\"text\"\n name=\"nickname\"\n .label=${msg('Nickname')}\n required\n minLength=${MIN_NICKNAME_LENGTH}\n .value=${this.profile?.nickname || ''}\n .helpText=${msg(str`Min. ${MIN_NICKNAME_LENGTH} characters`)}\n style=\"margin-left: 16px;\"\n >\n </div>\n \n <div class=\"row\" style=\"justify-content: center; margin-bottom: 8px; align-self: start;\" >\n <span style=\"font-size:18px;padding-right:10px;\">${msg('Language')}:</span>\n <sl-radio-group id=\"langRadioGroup\" @click=${this.handleLangChange} .value=${this.profile?.fields['lang']}>\n <sl-radio value=\"en\">🇬🇧</sl-radio>\n <sl-radio value=\"fr-fr\">🇫🇷</sl-radio>\n </sl-radio-group>\n </div>\n \n <div class=\"row\" style=\"margin-top: 8px;\">\n <button style=\"flex: 1;\" variant=\"primary\" type=\"submit\"\n >${msg('Save Profile')}\n </button>\n </div>\n </form>\n `;\n }\n\n\n static styles = [sharedStyles, css`\n\n sl-radio {\n font-size: larger;\n }\n .small-margin {\n margin-top: 6px;\n }\n .big-margin {\n margin-top: 23px;\n }\n\n .fill {\n flex: 1;\n height: 100%;\n }\n\n .title {\n font-size: 20px;\n }\n\n .center-content {\n align-items: center;\n justify-content: center;\n }\n\n .placeholder {\n color: rgba(0, 0, 0, 0.7);\n }\n\n .label {\n color: var(--mdc-text-field-label-ink-color, rgba(0, 0, 0, 0.6));\n font-family: var(\n --mdc-typography-caption-font-family,\n var(--mdc-typography-font-family, Roboto, sans-serif)\n );\n font-size: var(--mdc-typography-caption-font-size, 0.79rem);\n font-weight: var(--mdc-typography-caption-font-weight, 400);\n }\n\n .flex-scrollable-parent {\n position: relative;\n display: flex;\n flex: 1;\n }\n\n .flex-scrollable-container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n\n .flex-scrollable-x {\n max-width: 100%;\n overflow-x: auto;\n }\n .flex-scrollable-y {\n max-height: 100%;\n overflow-y: auto;\n }`];\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./profiles.zvm";
|
|
|
4
4
|
export * from "./bindings/profilesAlt.proxy";
|
|
5
5
|
export * from "./profilesAlt.perspective";
|
|
6
6
|
export * from "./profilesAlt.zvm";
|
|
7
|
+
export * from "./profilesAlt.dvm";
|
|
7
8
|
export * from "./elements/edit-profile";
|
|
8
9
|
export * from "./profiles.dvm";
|
|
9
10
|
export * from "./utils";
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./profiles.zvm";
|
|
|
4
4
|
export * from "./bindings/profilesAlt.proxy";
|
|
5
5
|
export * from "./profilesAlt.perspective";
|
|
6
6
|
export * from "./profilesAlt.zvm";
|
|
7
|
+
export * from "./profilesAlt.dvm";
|
|
7
8
|
export * from "./elements/edit-profile";
|
|
8
9
|
export * from "./profiles.dvm";
|
|
9
10
|
export * from "./utils";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gBAAgB,CAAA;AAE9B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,mBAAmB,CAAA;AAEjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA","sourcesContent":["export * from \"./bindings/profiles.types\"\nexport * from \"./bindings/profiles.proxy\"\nexport * from \"./profiles.zvm\"\n\nexport * from \"./bindings/profilesAlt.proxy\"\nexport * from \"./profilesAlt.perspective\"\nexport * from \"./profilesAlt.zvm\"\n\nexport * from \"./elements/edit-profile\"\nexport * from \"./profiles.dvm\"\nexport * from \"./utils\"\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gBAAgB,CAAA;AAE9B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AAEjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA","sourcesContent":["export * from \"./bindings/profiles.types\"\nexport * from \"./bindings/profiles.proxy\"\nexport * from \"./profiles.zvm\"\n\nexport * from \"./bindings/profilesAlt.proxy\"\nexport * from \"./profilesAlt.perspective\"\nexport * from \"./profilesAlt.zvm\"\nexport * from \"./profilesAlt.dvm\"\n\nexport * from \"./elements/edit-profile\"\nexport * from \"./profiles.dvm\"\nexport * from \"./utils\"\n"]}
|
package/dist/profiles.zvm.js
CHANGED
|
@@ -35,7 +35,7 @@ export class ProfilesZvm extends ZomeViewModel {
|
|
|
35
35
|
//profile_ahs: this._profile_ahs,
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
getMyProfile() { return this._profiles[this.cell.agentId.b64]; }
|
|
38
|
+
getMyProfile() { return this._profiles[this.cell.address.agentId.b64]; }
|
|
39
39
|
getProfile(agent) { return this._profiles[agent]; }
|
|
40
40
|
//getProfileHash(agent: AgentPubKeyB64): ActionHashB64 | undefined {return this._profile_ahs[agent]}
|
|
41
41
|
getAgents() { return Object.keys(this._profiles); }
|
|
@@ -108,12 +108,12 @@ export class ProfilesZvm extends ZomeViewModel {
|
|
|
108
108
|
/** */
|
|
109
109
|
async createMyProfile(profile) {
|
|
110
110
|
/*const record =*/ await this.zomeProxy.createProfile(profile);
|
|
111
|
-
this.storeProfile(this.cell.agentId.b64, profile);
|
|
111
|
+
this.storeProfile(this.cell.address.agentId.b64, profile);
|
|
112
112
|
}
|
|
113
113
|
/** */
|
|
114
114
|
async updateMyProfile(profile) {
|
|
115
115
|
/*const record =*/ await this.zomeProxy.updateProfile(profile);
|
|
116
|
-
this.storeProfile(this.cell.agentId.b64, profile);
|
|
116
|
+
this.storeProfile(this.cell.address.agentId.b64, profile);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
ProfilesZvm.ZOME_PROXY = ProfilesProxy;
|
package/dist/profiles.zvm.js.map
CHANGED
|
@@ -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,GAAoC,EAAE,CAAC;QACxD,mEAAmE;QAC3D,cAAS,GAAmC,EAAE,CAAC;IAuGzD,CAAC;IAxIC,IAAI,SAAS,KAAmB,OAAO,IAAI,CAAC,UAA2B,CAAC,CAAA,CAAC;IAGzE,KAAK;IACK,UAAU;QAClB,O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,CAAC,6BAA6B,EAAE,YAAY,CAAC,CAAC;QACzD,IAAI,CAAC,YAAY,EAAE;YACjB,OAAO;SACR;QACD,+EAA+E;QAC/E,4DAA4D;QAC5D,sFAAsF;QACtF,MAAM,OAAO,GAAY,MAAM,CAAE,YAAY,CAAC,KAAa,CAAC,OAAO,CAAC,KAAK,CAAY,CAAC;QACtF,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACtC,OAAO,OAAO,CAAC;IACjB,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,eAAe,CAAC,OAAgB;QACpC,kBAAkB,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,eAAe,CAAC,OAAgB;QACpC,kBAAkB,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;;AAvIe,sBAAU,GAAG,aAAa,AAAhB,CAAiB","sourcesContent":["import {ZomeViewModel} from \"@ddd-qc/lit-happ\";\nimport {Profile} 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, Profile>,\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, Profile> = {};\n //private _profile_ahs: Record<AgentPubKeyB64, ActionHashB64> = {};\n private _reversed: Record<string, AgentPubKeyB64> = {};\n\n\n getMyProfile(): Profile | undefined { return this._profiles[this.cell.address.agentId.b64] }\n\n getProfile(agent: AgentPubKeyB64): Profile | 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, Profile>;\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, Profile>> {\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: Profile = decode((maybeProfile.entry as any).Present.entry) as Profile;\n this.storeProfile(encodeHashToBase64(agentPubKey), profile);\n }\n this.notifySubscribers();\n return this._profiles;\n }\n\n\n /** */\n storeProfile(pubKeyB64: AgentPubKeyB64, profile: Profile) {\n this._profiles[pubKeyB64] = profile;\n this._reversed[profile.nickname] = pubKeyB64;\n this.notifySubscribers();\n }\n\n\n /** */\n async probeProfile(pubKeyB64: AgentPubKeyB64): Promise<Profile | 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: Profile = decode(profileEntry.record.entry.Present.entry) as Profile;\n const profile: Profile = decode((maybeProfile.entry as any).Present.entry) as Profile;\n console.log(\"probeProfile() profile\", profile);\n this.storeProfile(pubKeyB64, profile);\n return profile;\n }\n\n\n /** */\n async createMyProfile(profile: Profile): Promise<void> {\n /*const record =*/ await this.zomeProxy.createProfile(profile);\n this.storeProfile(this.cell.address.agentId.b64, profile);\n }\n\n\n /** */\n async updateMyProfile(profile: Profile): Promise<void> {\n /*const record =*/ await this.zomeProxy.updateProfile(profile);\n this.storeProfile(this.cell.address.agentId.b64, profile);\n }\n\n}\n"]}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { ActionId, ActionIdMap, AgentId, AgentIdMap } from "@ddd-qc/cell-proxy";
|
|
2
2
|
import { Profile } from "./bindings/profiles.types";
|
|
3
|
-
import { Timestamp } from "@holochain/client";
|
|
3
|
+
import { ActionHashB64, AgentPubKeyB64, Timestamp } from "@holochain/client";
|
|
4
4
|
/** */
|
|
5
|
-
export interface
|
|
6
|
-
|
|
7
|
-
profileByAgent: AgentIdMap<ActionId>;
|
|
5
|
+
export interface ProfilesAltSnapshot {
|
|
6
|
+
all: [AgentPubKeyB64, ActionHashB64, Profile, Timestamp][];
|
|
8
7
|
}
|
|
9
|
-
|
|
8
|
+
/** */
|
|
9
|
+
export declare class ProfilesAltPerspective {
|
|
10
10
|
profiles: ActionIdMap<[Profile, Timestamp]>;
|
|
11
11
|
profileByAgent: AgentIdMap<ActionId>;
|
|
12
|
-
/** Extra */
|
|
13
|
-
|
|
12
|
+
/** -- Extra -- */
|
|
13
|
+
agentByName: Record<string, AgentId>;
|
|
14
|
+
/** -- Methods -- */
|
|
15
|
+
equals(_other: ProfilesAltPerspective): boolean;
|
|
14
16
|
/** -- Getters -- */
|
|
15
17
|
get agents(): AgentId[];
|
|
16
18
|
get names(): string[];
|
|
@@ -22,6 +24,13 @@ export declare class ProfilesAltPerspective implements ProfilesAltPerspectiveCor
|
|
|
22
24
|
getProfileTs(agent: AgentId | string): Timestamp | undefined;
|
|
23
25
|
/** */
|
|
24
26
|
getAgent(nickname: string): AgentId | undefined;
|
|
27
|
+
/** -- Memento -- */
|
|
28
|
+
/** TODO: deep copy */
|
|
29
|
+
makeSnapshot(): ProfilesAltSnapshot;
|
|
30
|
+
}
|
|
31
|
+
/** */
|
|
32
|
+
export declare class ProfilesAltPerspectiveMutable extends ProfilesAltPerspective {
|
|
33
|
+
get readonly(): ProfilesAltPerspective;
|
|
25
34
|
/** -- Store -- */
|
|
26
35
|
/** */
|
|
27
36
|
storeProfile(profileAh: ActionId, profile: Profile, ts: Timestamp): void;
|
|
@@ -30,9 +39,8 @@ export declare class ProfilesAltPerspective implements ProfilesAltPerspectiveCor
|
|
|
30
39
|
/** */
|
|
31
40
|
unstoreAgentProfile(agentId: AgentId, profileAh: ActionId): void;
|
|
32
41
|
/** -- Memento -- */
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
restore(core: ProfilesAltPerspectiveCore): void;
|
|
42
|
+
/** */
|
|
43
|
+
restore(snapshot: ProfilesAltSnapshot): void;
|
|
36
44
|
/** -- Generate -- */
|
|
37
45
|
/** */
|
|
38
46
|
generateRandomProfile(nickname: string, ts?: Timestamp, fields?: Record<string, string>): Promise<void>;
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import { ActionId, ActionIdMap, AgentId, AgentIdMap } from "@ddd-qc/cell-proxy";
|
|
2
|
-
|
|
3
|
-
// /** Nickname -> AgentId */
|
|
4
|
-
// agentByName: Record<string, AgentId>,
|
|
5
|
-
// }
|
|
6
|
-
//
|
|
7
|
-
// export type ProfilesAltPerspectiveFull = ProfilesAltPerspectiveCore & ProfilesAltPerspectiveExtra;
|
|
1
|
+
import { ActionId, ActionIdMap, AgentId, AgentIdMap, assertAllDefined } from "@ddd-qc/cell-proxy";
|
|
2
|
+
/** */
|
|
8
3
|
export class ProfilesAltPerspective {
|
|
9
4
|
constructor() {
|
|
10
|
-
/*
|
|
5
|
+
/* ActionId -> Profile */
|
|
11
6
|
this.profiles = new ActionIdMap();
|
|
7
|
+
/* AgentId -> ActionId */
|
|
12
8
|
this.profileByAgent = new AgentIdMap();
|
|
13
|
-
/** Extra */
|
|
14
|
-
|
|
9
|
+
/** -- Extra -- */
|
|
10
|
+
/* Name -> AgentId */
|
|
11
|
+
this.agentByName = {};
|
|
12
|
+
}
|
|
13
|
+
/** -- Methods -- */
|
|
14
|
+
equals(_other) {
|
|
15
|
+
// TODO
|
|
16
|
+
return false;
|
|
15
17
|
}
|
|
16
|
-
// /* */
|
|
17
|
-
// diff(core: ProfilesAltPerspectiveCore): boolean {
|
|
18
|
-
// // TODO
|
|
19
|
-
// return true;
|
|
20
|
-
// }
|
|
21
18
|
/** -- Getters -- */
|
|
22
19
|
get agents() { return Array.from(this.profileByAgent.keys()); }
|
|
23
|
-
get names() { return Object.keys(this.
|
|
20
|
+
get names() { return Object.keys(this.agentByName); }
|
|
24
21
|
/** */
|
|
25
22
|
getProfileAgent(profileId) {
|
|
26
23
|
for (const [agentId, profId] of this.profileByAgent.entries()) {
|
|
@@ -33,7 +30,7 @@ export class ProfilesAltPerspective {
|
|
|
33
30
|
/** */
|
|
34
31
|
getProfile(agent) {
|
|
35
32
|
if (typeof agent == "string") {
|
|
36
|
-
agent = this.
|
|
33
|
+
agent = this.agentByName[agent];
|
|
37
34
|
if (!agent) {
|
|
38
35
|
return;
|
|
39
36
|
}
|
|
@@ -53,7 +50,7 @@ export class ProfilesAltPerspective {
|
|
|
53
50
|
/** */
|
|
54
51
|
getProfileTs(agent) {
|
|
55
52
|
if (typeof agent == "string") {
|
|
56
|
-
agent = this.
|
|
53
|
+
agent = this.agentByName[agent];
|
|
57
54
|
if (!agent) {
|
|
58
55
|
return;
|
|
59
56
|
}
|
|
@@ -63,58 +60,77 @@ export class ProfilesAltPerspective {
|
|
|
63
60
|
return undefined;
|
|
64
61
|
}
|
|
65
62
|
const pair = this.profiles.get(profileAh);
|
|
63
|
+
if (!pair) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
66
|
return pair[1];
|
|
67
67
|
}
|
|
68
68
|
/** */
|
|
69
69
|
getAgent(nickname) {
|
|
70
|
-
return this.
|
|
70
|
+
return this.agentByName[nickname];
|
|
71
|
+
}
|
|
72
|
+
/** -- Memento -- */
|
|
73
|
+
/** TODO: deep copy */
|
|
74
|
+
makeSnapshot() {
|
|
75
|
+
let all = [];
|
|
76
|
+
for (const [agentId, profileAh] of this.profileByAgent.entries()) {
|
|
77
|
+
const pair = this.profiles.get(profileAh);
|
|
78
|
+
if (pair) {
|
|
79
|
+
all.push([agentId, profileAh, pair[0], pair[1]]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** */
|
|
83
|
+
return { all };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** */
|
|
87
|
+
export class ProfilesAltPerspectiveMutable extends ProfilesAltPerspective {
|
|
88
|
+
get readonly() {
|
|
89
|
+
return this;
|
|
71
90
|
}
|
|
72
91
|
/** -- Store -- */
|
|
73
92
|
/** */
|
|
74
93
|
storeProfile(profileAh, profile, ts) {
|
|
75
|
-
|
|
94
|
+
console.debug("ProfilesAltZvm.storeProfile()", profileAh.short, profile.nickname);
|
|
95
|
+
assertAllDefined(profileAh, profile, ts);
|
|
76
96
|
this.profiles.set(profileAh, [profile, ts]);
|
|
77
97
|
const agentId = this.getProfileAgent(profileAh);
|
|
78
98
|
if (agentId) {
|
|
79
|
-
this.
|
|
99
|
+
this.agentByName[profile.nickname] = agentId;
|
|
80
100
|
}
|
|
81
101
|
}
|
|
82
102
|
/** */
|
|
83
103
|
storeAgentProfile(agentId, profileAh) {
|
|
84
|
-
|
|
104
|
+
console.debug("ProfilesAltZvm.storeAgentProfile()", agentId.short, profileAh.short);
|
|
105
|
+
assertAllDefined(agentId, profileAh);
|
|
85
106
|
this.profileByAgent.set(agentId, profileAh);
|
|
86
107
|
const pair = this.profiles.get(profileAh);
|
|
87
108
|
if (pair) {
|
|
88
|
-
this.
|
|
109
|
+
this.agentByName[pair[0].nickname] = agentId;
|
|
89
110
|
}
|
|
90
111
|
}
|
|
91
112
|
/** */
|
|
92
113
|
unstoreAgentProfile(agentId, profileAh) {
|
|
93
|
-
|
|
114
|
+
console.debug("ProfilesAltZvm.unstoreAgentProfile()", agentId.short, profileAh.short);
|
|
115
|
+
assertAllDefined(agentId, profileAh);
|
|
94
116
|
this.profileByAgent.delete(agentId);
|
|
95
117
|
const pair = this.profiles.get(profileAh);
|
|
96
118
|
if (pair) {
|
|
97
|
-
delete this.
|
|
119
|
+
delete this.agentByName[pair[0].nickname];
|
|
98
120
|
}
|
|
99
121
|
}
|
|
100
122
|
/** -- Memento -- */
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
profiles: this.profiles,
|
|
105
|
-
profileByAgent: this.profileByAgent,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
restore(core) {
|
|
123
|
+
/** */
|
|
124
|
+
restore(snapshot) {
|
|
109
125
|
/** Clear */
|
|
110
126
|
this.profiles.clear();
|
|
111
127
|
this.profileByAgent.clear();
|
|
112
|
-
this.
|
|
113
|
-
/** */
|
|
114
|
-
for (const [
|
|
128
|
+
this.agentByName = {};
|
|
129
|
+
/** Store */
|
|
130
|
+
for (const [agent, profileB64, profile, ts] of snapshot.all) {
|
|
131
|
+
const agentId = new AgentId(agent);
|
|
132
|
+
const profileAh = new ActionId(profileB64);
|
|
115
133
|
this.storeAgentProfile(agentId, profileAh);
|
|
116
|
-
}
|
|
117
|
-
for (const [profileAh, [profile, ts]] of core.profiles.entries()) {
|
|
118
134
|
this.storeProfile(profileAh, profile, ts);
|
|
119
135
|
}
|
|
120
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.perspective.js","sourceRoot":"","sources":["../src/profilesAlt.perspective.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"profilesAlt.perspective.js","sourceRoot":"","sources":["../src/profilesAlt.perspective.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAWhG,MAAM;AACN,MAAM,OAAO,sBAAsB;IAAnC;QACE,yBAAyB;QACzB,aAAQ,GAAsC,IAAI,WAAW,EAAE,CAAC;QAChE,yBAAyB;QACzB,mBAAc,GAAyB,IAAI,UAAU,EAAE,CAAC;QAExD,mBAAmB;QACnB,qBAAqB;QACrB,gBAAW,GAA4B,EAAE,CAAC;IAuF5C,CAA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IdMap, assertAllDefined} from \"@ddd-qc/cell-proxy\";\r\nimport {Profile} from \"./bindings/profiles.types\";\r\nimport {ActionHashB64, AgentPubKeyB64, Timestamp} from \"@holochain/client\";\r\n\r\n\r\n/** */\r\nexport interface ProfilesAltSnapshot {\r\n all: [AgentPubKeyB64, ActionHashB64, Profile, Timestamp][];\r\n}\r\n\r\n\r\n/** */\r\nexport class ProfilesAltPerspective {\r\n /* ActionId -> Profile */\r\n profiles: ActionIdMap<[Profile, Timestamp]> = new ActionIdMap();\r\n /* AgentId -> ActionId */\r\n profileByAgent: AgentIdMap<ActionId> = new AgentIdMap();\r\n\r\n /** -- Extra -- */\r\n /* Name -> AgentId */\r\n agentByName: Record<string, AgentId> = {};\r\n\r\n\r\n /** -- Methods -- */\r\n\r\n equals(_other: ProfilesAltPerspective) {\r\n // TODO\r\n return false;\r\n }\r\n\r\n /** -- Getters -- */\r\n\r\n get agents(): AgentId[] { return Array.from(this.profileByAgent.keys())}\r\n get names(): string[] { return Object.keys(this.agentByName)}\r\n\r\n /** */\r\n getProfileAgent(profileId: ActionId): AgentId | undefined {\r\n for (const [agentId, profId] of this.profileByAgent.entries()) {\r\n if (profileId.b64 == profId.b64) {\r\n return agentId;\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n\r\n /** */\r\n getProfile(agent: AgentId | string): Profile | undefined {\r\n if (typeof agent == \"string\") {\r\n agent = this.agentByName[agent];\r\n if (!agent) {\r\n return;\r\n }\r\n }\r\n const profileAh = this.profileByAgent.get(agent);\r\n //console.log(\"ProfilesAltZvm.getProfile()\", agent, profileAh);\r\n if (!profileAh) {\r\n return undefined;\r\n }\r\n const pair = this.profiles.get(profileAh);\r\n //console.log(\"ProfilesAltZvm.getProfile() pair\", pair);\r\n if (!pair) {\r\n return undefined;\r\n }\r\n return pair[0];\r\n }\r\n\r\n\r\n /** */\r\n getProfileTs(agent: AgentId | string): Timestamp | undefined {\r\n if (typeof agent == \"string\") {\r\n agent = this.agentByName[agent];\r\n if (!agent) {\r\n return;\r\n }\r\n }\r\n const profileAh = this.profileByAgent.get(agent);\r\n if (!profileAh) {\r\n return undefined;\r\n }\r\n const pair = this.profiles.get(profileAh);\r\n if (!pair) {\r\n return undefined;\r\n }\r\n return pair[1];\r\n }\r\n\r\n /** */\r\n getAgent(nickname: string): AgentId | undefined {\r\n return this.agentByName[nickname];\r\n }\r\n\r\n\r\n /** -- Memento -- */\r\n\r\n /** TODO: deep copy */\r\n makeSnapshot(): ProfilesAltSnapshot {\r\n let all = [];\r\n for (const [agentId, profileAh] of this.profileByAgent.entries()) {\r\n const pair = this.profiles.get(profileAh);\r\n if (pair) {\r\n all.push([agentId, profileAh, pair[0], pair[1]])\r\n }\r\n }\r\n /** */\r\n return {all}\r\n }\r\n}\r\n\r\n\r\n/** */\r\nexport class ProfilesAltPerspectiveMutable extends ProfilesAltPerspective {\r\n\r\n get readonly(): ProfilesAltPerspective {\r\n return this;\r\n }\r\n\r\n /** -- Store -- */\r\n\r\n /** */\r\n storeProfile(profileAh: ActionId, profile: Profile, ts: Timestamp) {\r\n console.debug(\"ProfilesAltZvm.storeProfile()\", profileAh.short, profile.nickname);\r\n assertAllDefined(profileAh, profile, ts);\r\n this.profiles.set(profileAh, [profile, ts]);\r\n const agentId = this.getProfileAgent(profileAh);\r\n if (agentId) {\r\n this.agentByName[profile.nickname] = agentId;\r\n }\r\n }\r\n\r\n /** */\r\n storeAgentProfile(agentId: AgentId, profileAh: ActionId) {\r\n console.debug(\"ProfilesAltZvm.storeAgentProfile()\", agentId.short, profileAh.short);\r\n assertAllDefined(agentId, profileAh);\r\n this.profileByAgent.set(agentId, profileAh);\r\n const pair = this.profiles.get(profileAh);\r\n if (pair) {\r\n this.agentByName[pair[0].nickname] = agentId;\r\n }\r\n }\r\n\r\n /** */\r\n unstoreAgentProfile(agentId: AgentId, profileAh: ActionId) {\r\n console.debug(\"ProfilesAltZvm.unstoreAgentProfile()\", agentId.short, profileAh.short);\r\n assertAllDefined(agentId, profileAh);\r\n this.profileByAgent.delete(agentId);\r\n const pair = this.profiles.get(profileAh);\r\n if (pair) {\r\n delete this.agentByName[pair[0].nickname];\r\n }\r\n }\r\n\r\n\r\n /** -- Memento -- */\r\n\r\n /** */\r\n restore(snapshot: ProfilesAltSnapshot) {\r\n /** Clear */\r\n this.profiles.clear();\r\n this.profileByAgent.clear();\r\n this.agentByName = {};\r\n /** Store */\r\n for (const [agent, profileB64, profile, ts] of snapshot.all) {\r\n const agentId = new AgentId(agent);\r\n const profileAh = new ActionId(profileB64);\r\n this.storeAgentProfile(agentId, profileAh);\r\n this.storeProfile(profileAh, profile, ts);\r\n }\r\n }\r\n\r\n\r\n /** -- Generate -- */\r\n\r\n /** */\r\n async generateRandomProfile(nickname: string, ts?: Timestamp, fields?: Record<string, string>) {\r\n const agentId = await AgentId.random();\r\n const profileAh = await ActionId.random();\r\n const profile: Profile = {nickname, fields};\r\n this.storeAgentProfile(agentId, profileAh);\r\n this.storeProfile(profileAh, profile, ts? ts : 0);\r\n }\r\n\r\n}\r\n"]}
|
|
@@ -7,6 +7,7 @@ import { ProfilesAltPerspective } from "./profilesAlt.perspective";
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
export declare class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
10
|
+
/** -- Concret -- */
|
|
10
11
|
static readonly ZOME_PROXY: typeof ProfilesAltProxy;
|
|
11
12
|
get zomeProxy(): ProfilesAltProxy;
|
|
12
13
|
protected hasChanged(): boolean;
|
|
@@ -14,8 +15,8 @@ export declare class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
14
15
|
initializePerspectiveOnline(): Promise<void>;
|
|
15
16
|
/** */
|
|
16
17
|
probeAllInner(): void;
|
|
17
|
-
/** -- Perspective -- */
|
|
18
18
|
get perspective(): ProfilesAltPerspective;
|
|
19
|
+
/** -- */
|
|
19
20
|
private _perspective;
|
|
20
21
|
/** -- Getters -- */
|
|
21
22
|
getMyProfile(): Profile | undefined;
|
package/dist/profilesAlt.zvm.js
CHANGED
|
@@ -3,20 +3,22 @@ import { decode } from "@msgpack/msgpack";
|
|
|
3
3
|
import { ProfilesAltProxy } from "./bindings/profilesAlt.proxy";
|
|
4
4
|
import { ProfilesLinkType } from "./bindings/profiles.integrity";
|
|
5
5
|
import { ProfilesAltUnitEnum } from "./bindings/profilesAlt.integrity";
|
|
6
|
-
import {
|
|
6
|
+
import { ProfilesAltPerspectiveMutable } from "./profilesAlt.perspective";
|
|
7
|
+
import { HoloHash } from "@holochain/client";
|
|
7
8
|
/**
|
|
8
9
|
*
|
|
9
10
|
*/
|
|
10
11
|
export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
11
12
|
constructor() {
|
|
13
|
+
/** -- Concret -- */
|
|
12
14
|
super(...arguments);
|
|
13
|
-
|
|
15
|
+
/** -- */
|
|
16
|
+
this._perspective = new ProfilesAltPerspectiveMutable();
|
|
14
17
|
}
|
|
15
18
|
get zomeProxy() { return this._zomeProxy; }
|
|
16
19
|
/* */
|
|
17
20
|
hasChanged() {
|
|
18
|
-
|
|
19
|
-
return true;
|
|
21
|
+
return !this.perspective.equals(this._previousPerspective);
|
|
20
22
|
}
|
|
21
23
|
/** */
|
|
22
24
|
async initializePerspectiveOnline() {
|
|
@@ -26,19 +28,17 @@ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
26
28
|
probeAllInner() {
|
|
27
29
|
this.probeAllProfiles();
|
|
28
30
|
}
|
|
29
|
-
/** -- Perspective -- */
|
|
30
31
|
/* */
|
|
31
32
|
get perspective() {
|
|
32
|
-
return this._perspective;
|
|
33
|
+
return this._perspective.readonly;
|
|
33
34
|
}
|
|
34
35
|
/** -- Getters -- */
|
|
35
36
|
getMyProfile() {
|
|
36
|
-
return this._perspective.getProfile(this.cell.agentId);
|
|
37
|
+
return this._perspective.getProfile(this.cell.address.agentId);
|
|
37
38
|
}
|
|
38
39
|
/** -- Signals -- */
|
|
39
40
|
/** */
|
|
40
41
|
async handleLinkPulse(pulse, _from) {
|
|
41
|
-
/** */
|
|
42
42
|
switch (pulse.link_type) {
|
|
43
43
|
case ProfilesLinkType.PrefixPath:
|
|
44
44
|
case ProfilesLinkType.PathToAgent:
|
|
@@ -83,7 +83,7 @@ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
83
83
|
}
|
|
84
84
|
/** */
|
|
85
85
|
async findProfile(agentId) {
|
|
86
|
-
const maybeProfilePair = await this.zomeProxy.findProfile(agentId.hash);
|
|
86
|
+
const maybeProfilePair = await this.zomeProxy.findProfile(new HoloHash(agentId.hash));
|
|
87
87
|
console.log("findProfile()", agentId, maybeProfilePair);
|
|
88
88
|
if (!maybeProfilePair) {
|
|
89
89
|
return;
|
|
@@ -92,30 +92,30 @@ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
92
92
|
}
|
|
93
93
|
/** */
|
|
94
94
|
async createMyProfile(profile) {
|
|
95
|
-
const _ah = await this.zomeProxy.createProfile([profile, this.cell.agentId.hash]);
|
|
95
|
+
const _ah = await this.zomeProxy.createProfile([profile, new HoloHash(this.cell.address.agentId.hash)]);
|
|
96
96
|
}
|
|
97
97
|
/** */
|
|
98
98
|
async updateMyProfile(profile) {
|
|
99
|
-
const _ah = await this.zomeProxy.updateProfile([profile, this.cell.agentId.hash]);
|
|
99
|
+
const _ah = await this.zomeProxy.updateProfile([profile, new HoloHash(this.cell.address.agentId.hash)]);
|
|
100
100
|
}
|
|
101
101
|
/** */
|
|
102
102
|
async createProfile(profile, agentId) {
|
|
103
|
-
const _ah = await this.zomeProxy.createProfile([profile, agentId.hash]);
|
|
103
|
+
const _ah = await this.zomeProxy.createProfile([profile, new HoloHash(agentId.hash)]);
|
|
104
104
|
}
|
|
105
105
|
/** */
|
|
106
106
|
async updateProfile(profile, agentId) {
|
|
107
|
-
const _ah = await this.zomeProxy.updateProfile([profile, agentId.hash]);
|
|
107
|
+
const _ah = await this.zomeProxy.updateProfile([profile, new HoloHash(agentId.hash)]);
|
|
108
108
|
}
|
|
109
109
|
/** -- Import / Export -- */
|
|
110
110
|
/** Dump perspective as JSON */
|
|
111
111
|
export() {
|
|
112
112
|
//console.log("exportPerspective()", perspMat);
|
|
113
|
-
const
|
|
114
|
-
return JSON.stringify(
|
|
113
|
+
const snapshot = this._perspective.makeSnapshot();
|
|
114
|
+
return JSON.stringify(snapshot, null, 2);
|
|
115
115
|
}
|
|
116
116
|
/** */
|
|
117
117
|
import(json, _canPublish) {
|
|
118
|
-
const
|
|
118
|
+
const snapshot = JSON.parse(json);
|
|
119
119
|
// if (canPublish) {
|
|
120
120
|
// for (const [profileAh, [profile, _ts]] of perspective.profiles.entries()) {
|
|
121
121
|
// await this.createProfile(profile, agentId);
|
|
@@ -123,7 +123,7 @@ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
123
123
|
// return;
|
|
124
124
|
// }
|
|
125
125
|
/** */
|
|
126
|
-
this._perspective.restore(
|
|
126
|
+
this._perspective.restore(snapshot);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
ProfilesAltZvm.ZOME_PROXY = ProfilesAltProxy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.zvm.js","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,OAAO,EACP,OAAO,EAEP,eAAe,EACf,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AACrE,OAAO,
|
|
1
|
+
{"version":3,"file":"profilesAlt.zvm.js","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ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QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxF,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,aAAa,CAAC,OAAgB,EAAE,OAAgB;QACpD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxF,CAAC;IAGD,4BAA4B;IAE5B,+BAA+B;IAC/B,MAAM;QACJ,+CAA+C;QAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC;IAGD,MAAM;IACN,MAAM,CAAC,IAAY,EAAE,WAAoB;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAwB,CAAC;QACzD,oBAAoB;QACpB,gFAAgF;QAChF,kDAAkD;QAClD,MAAM;QACN,YAAY;QACZ,IAAI;QACJ,MAAM;QACN,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IACrC,CAAC;;AAnJe,yBAAU,GAAG,gBAAgB,AAAnB,CAAoB","sourcesContent":["import {\n ActionId,\n AgentId,\n EntryId,\n LinkPulseMat,\n StateChangeType,\n ZomeViewModelWithSignals\n} from \"@ddd-qc/lit-happ\";\nimport {Profile} from \"./bindings/profiles.types\";\nimport {decode} from \"@msgpack/msgpack\";\nimport {ProfilesAltProxy} from \"./bindings/profilesAlt.proxy\";\nimport {EntryPulseMat} from \"@ddd-qc/lit-happ/dist/ZomeViewModelWithSignals\";\nimport {ProfilesLinkType} from \"./bindings/profiles.integrity\";\nimport {ProfilesAltUnitEnum} from \"./bindings/profilesAlt.integrity\";\nimport {\n ProfilesAltPerspective,\n ProfilesAltPerspectiveMutable,\n ProfilesAltSnapshot\n} from \"./profilesAlt.perspective\";\nimport {HoloHash} from \"@holochain/client\";\n\n\n/**\n *\n */\nexport class ProfilesAltZvm extends ZomeViewModelWithSignals {\n\n /** -- Concret -- */\n\n static readonly ZOME_PROXY = ProfilesAltProxy;\n get zomeProxy(): ProfilesAltProxy {return this._zomeProxy as ProfilesAltProxy;}\n\n\n /* */\n protected hasChanged(): boolean {\n return !this.perspective.equals(this._previousPerspective as ProfilesAltPerspective);\n }\n\n\n /** */\n async initializePerspectiveOnline(): Promise<void> {\n await this.probeAllProfiles();\n }\n\n\n /** */\n probeAllInner() {\n this.probeAllProfiles();\n }\n\n\n /* */\n get perspective(): ProfilesAltPerspective {\n return this._perspective.readonly;\n }\n\n\n /** -- */\n\n private _perspective: ProfilesAltPerspectiveMutable = new ProfilesAltPerspectiveMutable();\n\n\n /** -- Getters -- */\n\n getMyProfile(): Profile | undefined {\n return this._perspective.getProfile(this.cell.address.agentId);\n }\n\n\n\n /** -- Signals -- */\n\n /** */\n async handleLinkPulse(pulse: LinkPulseMat, _from: AgentId): Promise<void> {\n switch (pulse.link_type) {\n case ProfilesLinkType.PrefixPath:\n case ProfilesLinkType.PathToAgent: {\n const agentEh = new EntryId(pulse.target.b64);\n const agentId = AgentId.from(agentEh);\n if (pulse.state != StateChangeType.Delete) {\n await this.findProfile(agentId);\n }\n }\n break;\n case ProfilesLinkType.AgentToProfile: {\n const agentEh = new EntryId(pulse.base.b64); // Make sure its an EntryHash\n const agentId = AgentId.from(agentEh);\n const profileAh = ActionId.from(pulse.target);\n if (pulse.state == StateChangeType.Delete) {\n this._perspective.unstoreAgentProfile(agentId, profileAh)\n } else {\n this._perspective.storeAgentProfile(agentId, profileAh)\n }\n }\n break;\n }\n }\n\n\n /** */\n async handleEntryPulse(pulse: EntryPulseMat, _from: AgentId) {\n switch (pulse.entryType) {\n case ProfilesAltUnitEnum.Profile:\n const profile = decode(pulse.bytes) as Profile;\n if (pulse.state != StateChangeType.Delete) {\n this._perspective.storeProfile(pulse.ah, profile, pulse.ts);\n }\n break;\n }\n }\n\n\n /** -- Methods -- */\n\n /** */\n async probeAllProfiles()/*: Promise<Record<AgentPubKeyB64, ProfileMat>>*/ {\n await this.zomeProxy.probeProfiles();\n }\n\n\n /** */\n async findProfile(agentId: AgentId): Promise<Profile | undefined> {\n const maybeProfilePair = await this.zomeProxy.findProfile(new HoloHash(agentId.hash));\n console.log(\"findProfile()\", agentId, maybeProfilePair);\n if (!maybeProfilePair) {\n return;\n }\n return maybeProfilePair[1];\n }\n\n\n /** */\n async createMyProfile(profile: Profile): Promise<void> {\n const _ah = await this.zomeProxy.createProfile([profile, new HoloHash(this.cell.address.agentId.hash)]);\n }\n\n\n /** */\n async updateMyProfile(profile: Profile): Promise<void> {\n const _ah = await this.zomeProxy.updateProfile([profile, new HoloHash(this.cell.address.agentId.hash)]);\n }\n\n\n /** */\n async createProfile(profile: Profile, agentId: AgentId): Promise<void> {\n const _ah = await this.zomeProxy.createProfile([profile, new HoloHash(agentId.hash)]);\n }\n\n\n /** */\n async updateProfile(profile: Profile, agentId: AgentId): Promise<void> {\n const _ah = await this.zomeProxy.updateProfile([profile, new HoloHash(agentId.hash)]);\n }\n\n\n /** -- Import / Export -- */\n\n /** Dump perspective as JSON */\n export(): string {\n //console.log(\"exportPerspective()\", perspMat);\n const snapshot = this._perspective.makeSnapshot();\n return JSON.stringify(snapshot, null, 2);\n }\n\n\n /** */\n import(json: string, _canPublish: boolean) {\n const snapshot = JSON.parse(json) as ProfilesAltSnapshot;\n // if (canPublish) {\n // for (const [profileAh, [profile, _ts]] of perspective.profiles.entries()) {\n // await this.createProfile(profile, agentId);\n // }\n // return;\n // }\n /** */\n this._perspective.restore(snapshot)\n }\n}\n"]}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Profile as ProfileMat } from "./bindings/profiles.types";
|
|
2
1
|
import { TemplateResult } from "lit";
|
|
3
2
|
import { AgentId } from "@ddd-qc/cell-proxy";
|
|
3
|
+
import { Profile as ProfileMat } from "./bindings/profiles.types";
|
|
4
4
|
/** */
|
|
5
5
|
export declare function getInitials(nickname: string): string;
|
|
6
6
|
/** */
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAiB,MAAM,KAAK,CAAC;AAKzC,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,GAAY,EAAE,OAAoB;IAC3D,IAAI,CAAC,OAAO,EAAE;QACV,OAAO,CAAC,IAAI,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAC;QACnD,OAAO,GAAG,EAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAe,CAAC;KAC7D;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 {html, TemplateResult} from \"lit\";\nimport {AgentId} from \"@ddd-qc/cell-proxy\";\nimport {Profile as ProfileMat} from \"./bindings/profiles.types\";\n\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: AgentId, profile?: ProfileMat): [ProfileMat, TemplateResult<1>] {\n if (!profile) {\n console.warn(\"agent2avatar() No Profile arg\", key);\n profile = {nickname: \"unknown\", fields: {}} as ProfileMat;\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"]}
|