@ddd-qc/profiles-dvm 0.32.8 → 0.33.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.
- package/dist/bindings/profiles.proxy.d.ts.map +1 -1
- package/dist/bindings/profiles.proxy.js +2 -1
- 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 +2 -1
- package/dist/bindings/profilesAlt.proxy.d.ts.map +1 -1
- package/dist/bindings/profilesAlt.proxy.js +2 -1
- package/dist/bindings/profilesAlt.proxy.js.map +1 -1
- package/dist/bindings/profilesAlt.types.js.map +1 -1
- package/dist/profilesAlt.perspective.d.ts +5 -4
- package/dist/profilesAlt.perspective.d.ts.map +1 -1
- package/dist/profilesAlt.perspective.js +30 -21
- package/dist/profilesAlt.perspective.js.map +1 -1
- package/dist/profilesAlt.zvm.js +1 -1
- package/dist/profilesAlt.zvm.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.proxy.d.ts","sourceRoot":"","sources":["../../src/bindings/profiles.proxy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,OAAO,EAAgB,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EA8BP,MAAM,IAAI,QAAQ,EASjB,MAAM,mBAAmB,CAAC;AAK3B,KAAK,UAAU,GAAG,UAAU,CAAC;AAkC7B,OAAO,EAAC,gBAAgB,IAAI,SAAS,EAAC,MAAM,sBAAsB,CAAA;AAElE,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"profiles.proxy.d.ts","sourceRoot":"","sources":["../../src/bindings/profiles.proxy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,OAAO,EAAgB,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EA8BP,MAAM,IAAI,QAAQ,EASjB,MAAM,mBAAmB,CAAC;AAK3B,KAAK,UAAU,GAAG,UAAU,CAAC;AAkC7B,OAAO,EAAC,gBAAgB,IAAI,SAAS,EAAC,MAAM,sBAAsB,CAAA;AAElE,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAMtD,qBAAa,aAAc,SAAQ,SAAS;IAC1C,gBAAyB,iBAAiB,cAAc;IACxD,gBAAyB,QAAQ,WAAyB;IAC1D,gBAAyB,WAAW,6BAAmC;IACvE,gBAAyB,UAAU,cAAmC;IAEhE,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIlD,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIlD,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAI3D,YAAY,IAAI,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAIxC,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAI5D,oBAAoB,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAG/D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ZomeProxy } from '@ddd-qc/lit-happ';
|
|
2
2
|
import { profilesFunctionNames } from './profiles.fn';
|
|
3
|
-
import { ProfilesUnitEnum
|
|
3
|
+
import { ProfilesUnitEnum } from './profiles.integrity';
|
|
4
|
+
import { ProfilesLinkType } from './profiles.integrity';
|
|
4
5
|
export class ProfilesProxy extends ZomeProxy {
|
|
5
6
|
static { this.DEFAULT_ZOME_NAME = "profiles"; }
|
|
6
7
|
static { this.FN_NAMES = profilesFunctionNames; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.proxy.js","sourceRoot":"","sources":["../../src/bindings/profiles.proxy.ts"],"names":[],"mappings":"AAqFA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,EAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"profiles.proxy.js","sourceRoot":"","sources":["../../src/bindings/profiles.proxy.ts"],"names":[],"mappings":"AAqFA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAKtD,MAAM,OAAO,aAAc,SAAQ,SAAS;aACjB,sBAAiB,GAAG,UAAU,CAAC;aAC/B,aAAQ,GAAG,qBAAqB,CAAC;aACjC,gBAAW,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;aAC9C,eAAU,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAEtE,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,YAAY;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,KAAiB;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,KAAW;QACpC,OAAO,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\n// @ts-ignore\nimport {EntryTypes, Signal, Profile, ZomeFnInput, } from './profiles.types';\n// @ts-ignore\nimport {\n/** api/common.ts */\n// @ts-ignore\nWebsocketConnectionOptions, WsClientOptions, HolochainError, CloneIdHelper,\n/** types.ts */\n// @ts-ignore\nKitsuneAgent, KitsuneSpace, HoloHashB64, AgentPubKeyB64, DnaHashB64, WasmHashB64, EntryHashB64, ActionHashB64, AnyDhtHashB64, InstalledAppId, Signature, CellId, DnaProperties, RoleName, InstalledCell, Timestamp, HoloHashed, FetchPoolInfo,\n/** hdk/action.ts */\n// @ts-ignore\nSignedAction, SignedActionHashed, RegisterAgentActivity, ActionHashed, ActionType, Action, NewEntryAction, Dna, AgentValidationPkg, InitZomesComplete, CreateLink, DeleteLink, OpenChain, CloseChain, Update, Delete, Create,\n/** hdk/capabilities.ts */\n// @ts-ignore\nCapSecret, CapClaim, GrantedFunctionsType, GrantedFunctions, ZomeCallCapGrant, CapAccess, CapGrant,\n///** hdk/countersigning.ts */\n//CounterSigningSessionData,\n//PreflightRequest,\n//CounterSigningSessionTimes,\n//ActionBase,\n//CounterSigningAgents,\n//PreflightBytes,\n//Role,\n//CountersigningAgentState,\n/** hdk/dht-ops.ts */\n// @ts-ignore\nChainOpType, DhtOp, WarrantOp, ChainOp, Warrant, ChainIntegrityWarrant, ValidationType, ActionHashAndSig,\n/** hdk/entry.ts */\n// @ts-ignore\nEntryVisibility, AppEntryDef, EntryType, EntryContent, Entry,\n/** hdk/record.ts */\n// @ts-ignore\nRecord as HcRecord, RecordEntry as HcRecordEntry,\n/** hdk/link.ts */\n//AnyLinkableHash,\n// @ts-ignore\nZomeIndex, LinkType, LinkTag, RateWeight, RateBucketId, RateUnits, Link,\n/** api/admin/types.ts */\n// @ts-ignore\n// YamlProperties\nZomes, WasmCode, CapGrantInfo, PeerMetaInfo, DisabledAppReason, AppStatus, StemCell, ProvisionedCell, ClonedCell, CellType, CellInfo, AppInfo, MembraneProof, MemproofMap, RoleSettingsMap, RoleSettings, DnaModifiersOpt, DnaModifiers, FunctionName, ZomeName, ZomeDefinition, IntegrityZome, CoordinatorZome, DnaDefinition, ResourceBytes, ResourceMap, CellProvisioningStrategy, CellProvisioning, DnaVersionSpec, DnaVersionFlexible, AppRoleDnaManifest, AppRoleManifest, AppManifest, AppBundle, AppBundleSource, NetworkSeed, AppStatusFilter, AppInterfaceInfo, AgentInfoSigned, ZomeLocation, DnaManifest,\n} from '@holochain/client';\n\n\n/// Simple Hashes\n// @ts-ignore\ntype AgentArray = Uint8Array;\n// @ts-ignore\ntype DnaArray = Uint8Array;\n// @ts-ignore\ntype WasmArray = Uint8Array;\n// @ts-ignore\ntype EntryArray = Uint8Array;\n// @ts-ignore\ntype ActionArray = Uint8Array;\n// @ts-ignore\ntype AnyDhtArray = Uint8Array;\n// @ts-ignore\ntype AnyLinkableArray = Uint8Array;\n// @ts-ignore\ntype ExternalArray = Uint8Array;\n\n// @ts-ignore\nimport {\n/** Common */\n// @ts-ignore\nDhtOpHashB64, DhtOpHash,\n/** DnaFile */\n// @ts-ignore\nDnaFile, DnaDef,\n/** entry-details */\n// @ts-ignore\nEntryDetails, RecordDetails, Details, DetailsType, EntryDhtStatus,\n/** Validation */\n// @ts-ignore\nValidationStatus, ValidationReceipt,\n} from '@holochain-open-dev/core-types';\n\n/** User defined external dependencies */\n// @ts-ignore\nimport {ProfilesLinkType as LinkTypes} from \"./profiles.integrity\"\n\nimport {ZomeProxy} from '@ddd-qc/lit-happ';\nimport {profilesFunctionNames} from './profiles.fn';\nimport {ProfilesUnitEnum} from './profiles.integrity';\nimport {ProfilesLinkType} from './profiles.integrity';\n\n/**\n *\n */\nexport class ProfilesProxy extends ZomeProxy {\n static override readonly DEFAULT_ZOME_NAME = \"profiles\";\n static override readonly FN_NAMES = profilesFunctionNames;\n static override readonly ENTRY_TYPES = Object.values(ProfilesUnitEnum);\n static override 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 getMyProfile(): Promise<HcRecord | null> {\n return this.call('get_my_profile', null);\n }\n\n async getAgentProfile(input: AgentArray): Promise<HcRecord | null> {\n return this.call('get_agent_profile', input);\n }\n\n async getAgentsWithProfile(input: void): Promise<AgentArray[]> {\n return this.call('get_agents_with_profile', input);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.types.js","sourceRoot":"","sources":["../../src/bindings/profiles.types.ts"],"names":[],"mappings":"AAqIA,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\n// @ts-ignore\nimport {\n/** api/common.ts */\n// @ts-ignore\nWebsocketConnectionOptions, WsClientOptions, HolochainError, CloneIdHelper,\n/** types.ts */\n// @ts-ignore\nKitsuneAgent, KitsuneSpace, HoloHashB64, AgentPubKeyB64, DnaHashB64, WasmHashB64, EntryHashB64, ActionHashB64, AnyDhtHashB64, InstalledAppId, Signature, CellId, DnaProperties, RoleName, InstalledCell, Timestamp,
|
|
1
|
+
{"version":3,"file":"profiles.types.js","sourceRoot":"","sources":["../../src/bindings/profiles.types.ts"],"names":[],"mappings":"AAqIA,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\n// @ts-ignore\nimport {\n/** api/common.ts */\n// @ts-ignore\nWebsocketConnectionOptions, WsClientOptions, HolochainError, CloneIdHelper,\n/** types.ts */\n// @ts-ignore\nKitsuneAgent, KitsuneSpace, HoloHashB64, AgentPubKeyB64, DnaHashB64, WasmHashB64, EntryHashB64, ActionHashB64, AnyDhtHashB64, InstalledAppId, Signature, CellId, DnaProperties, RoleName, InstalledCell, Timestamp, HoloHashed, FetchPoolInfo,\n/** hdk/action.ts */\n// @ts-ignore\nSignedAction, SignedActionHashed, RegisterAgentActivity, ActionHashed, ActionType, Action, NewEntryAction, Dna, AgentValidationPkg, InitZomesComplete, CreateLink, DeleteLink, OpenChain, CloseChain, Update, Delete, Create,\n/** hdk/capabilities.ts */\n// @ts-ignore\nCapSecret, CapClaim, GrantedFunctionsType, GrantedFunctions, ZomeCallCapGrant, CapAccess, CapGrant,\n///** hdk/countersigning.ts */\n//CounterSigningSessionData,\n//PreflightRequest,\n//CounterSigningSessionTimes,\n//ActionBase,\n//CounterSigningAgents,\n//PreflightBytes,\n//Role,\n//CountersigningAgentState,\n/** hdk/dht-ops.ts */\n// @ts-ignore\nChainOpType, DhtOp, WarrantOp, ChainOp, Warrant, ChainIntegrityWarrant, ValidationType, ActionHashAndSig,\n/** hdk/entry.ts */\n// @ts-ignore\nEntryVisibility, AppEntryDef, EntryType, EntryContent, Entry,\n/** hdk/record.ts */\n// @ts-ignore\nRecord as HcRecord, RecordEntry as HcRecordEntry,\n/** hdk/link.ts */\n//AnyLinkableHash,\n// @ts-ignore\nZomeIndex, LinkType, LinkTag, RateWeight, RateBucketId, RateUnits, Link,\n/** api/admin/types.ts */\n// @ts-ignore\n// YamlProperties\nZomes, WasmCode, CapGrantInfo, PeerMetaInfo, DisabledAppReason, AppStatus, StemCell, ProvisionedCell, ClonedCell, CellType, CellInfo, AppInfo, MembraneProof, MemproofMap, RoleSettingsMap, RoleSettings, DnaModifiersOpt, DnaModifiers, FunctionName, ZomeName, ZomeDefinition, IntegrityZome, CoordinatorZome, DnaDefinition, ResourceBytes, ResourceMap, CellProvisioningStrategy, CellProvisioning, DnaVersionSpec, DnaVersionFlexible, AppRoleDnaManifest, AppRoleManifest, AppManifest, AppBundle, AppBundleSource, NetworkSeed, AppStatusFilter, AppInterfaceInfo, AgentInfoSigned, ZomeLocation, DnaManifest,\n} from '@holochain/client';\n\n\n/// Simple Hashes\n// @ts-ignore\ntype AgentArray = Uint8Array;\n// @ts-ignore\ntype DnaArray = Uint8Array;\n// @ts-ignore\ntype WasmArray = Uint8Array;\n// @ts-ignore\ntype EntryArray = Uint8Array;\n// @ts-ignore\ntype ActionArray = Uint8Array;\n// @ts-ignore\ntype AnyDhtArray = Uint8Array;\n// @ts-ignore\ntype AnyLinkableArray = Uint8Array;\n// @ts-ignore\ntype ExternalArray = Uint8Array;\n\n// @ts-ignore\nimport {\n/** Common */\n// @ts-ignore\nDhtOpHashB64, DhtOpHash,\n/** DnaFile */\n// @ts-ignore\nDnaFile, DnaDef,\n/** entry-details */\n// @ts-ignore\nEntryDetails, RecordDetails, Details, DetailsType, EntryDhtStatus,\n/** Validation */\n// @ts-ignore\nValidationStatus, ValidationReceipt,\n} from '@holochain-open-dev/core-types';\n\n/** User defined external dependencies */\n// @ts-ignore\nimport {ProfilesLinkType as LinkTypes} from \"./profiles.integrity\"\n\nexport interface ZomeFnInput<T> {\n input: T\n local?: boolean\n}\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"]}
|
|
@@ -2,7 +2,8 @@ import { Profile } from './profilesAlt.types';
|
|
|
2
2
|
type AgentArray = Uint8Array;
|
|
3
3
|
type ActionArray = Uint8Array;
|
|
4
4
|
import { ZomeProxy } from '@ddd-qc/lit-happ';
|
|
5
|
-
import { ProfilesAltUnitEnum
|
|
5
|
+
import { ProfilesAltUnitEnum } from './profilesAlt.integrity';
|
|
6
|
+
import { ProfilesAltLinkType } from './profilesAlt.integrity';
|
|
6
7
|
export declare class ProfilesAltProxy extends ZomeProxy {
|
|
7
8
|
static readonly DEFAULT_ZOME_NAME = "profiles";
|
|
8
9
|
static readonly FN_NAMES: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.proxy.d.ts","sourceRoot":"","sources":["../../src/bindings/profilesAlt.proxy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,OAAO,EAAG,MAAM,qBAAqB,CAAC;AA8C1D,KAAK,UAAU,GAAG,UAAU,CAAC;AAQ7B,KAAK,WAAW,GAAG,UAAU,CAAC;AAwB9B,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"profilesAlt.proxy.d.ts","sourceRoot":"","sources":["../../src/bindings/profilesAlt.proxy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,OAAO,EAAG,MAAM,qBAAqB,CAAC;AA8C1D,KAAK,UAAU,GAAG,UAAU,CAAC;AAQ7B,KAAK,WAAW,GAAG,UAAU,CAAC;AAwB9B,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;AAK5D,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,gBAAyB,iBAAiB,cAAc;IACxD,gBAAyB,QAAQ,WAA4B;IAC7D,gBAAyB,WAAW,gCAAsC;IAC1E,gBAAyB,UAAU,wBAAsC;IAEnE,aAAa,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAIhE,aAAa,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAIhE,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAI3D,WAAW,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAI5E,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;CAGrC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ZomeProxy } from '@ddd-qc/lit-happ';
|
|
2
2
|
import { profilesAltFunctionNames } from './profilesAlt.fn';
|
|
3
|
-
import { ProfilesAltUnitEnum
|
|
3
|
+
import { ProfilesAltUnitEnum } from './profilesAlt.integrity';
|
|
4
|
+
import { ProfilesAltLinkType } from './profilesAlt.integrity';
|
|
4
5
|
export class ProfilesAltProxy extends ZomeProxy {
|
|
5
6
|
static { this.DEFAULT_ZOME_NAME = "profiles"; }
|
|
6
7
|
static { this.FN_NAMES = profilesAltFunctionNames; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.proxy.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.proxy.ts"],"names":[],"mappings":"AAiFA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,wBAAwB,EAAC,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"profilesAlt.proxy.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.proxy.ts"],"names":[],"mappings":"AAiFA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,wBAAwB,EAAC,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;AAK5D,MAAM,OAAO,gBAAiB,SAAQ,SAAS;aACpB,sBAAiB,GAAG,UAAU,CAAC;aAC/B,aAAQ,GAAG,wBAAwB,CAAC;aACpC,gBAAW,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;aACjD,eAAU,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAEzE,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","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\n// @ts-ignore\nimport {EntryTypes, Profile, } from './profilesAlt.types';\n// @ts-ignore\nimport {\n/** api/common.ts */\n// @ts-ignore\nWebsocketConnectionOptions, WsClientOptions, HolochainError, CloneIdHelper,\n/** types.ts */\n// @ts-ignore\nKitsuneAgent, KitsuneSpace, HoloHashB64, AgentPubKeyB64, DnaHashB64, WasmHashB64, EntryHashB64, ActionHashB64, AnyDhtHashB64, InstalledAppId, Signature, CellId, DnaProperties, RoleName, InstalledCell, Timestamp, HoloHashed, FetchPoolInfo,\n/** hdk/action.ts */\n// @ts-ignore\nSignedAction, SignedActionHashed, RegisterAgentActivity, ActionHashed, ActionType, Action, NewEntryAction, Dna, AgentValidationPkg, InitZomesComplete, CreateLink, DeleteLink, OpenChain, CloseChain, Update, Delete, Create,\n/** hdk/capabilities.ts */\n// @ts-ignore\nCapSecret, CapClaim, GrantedFunctionsType, GrantedFunctions, ZomeCallCapGrant, CapAccess, CapGrant,\n///** hdk/countersigning.ts */\n//CounterSigningSessionData,\n//PreflightRequest,\n//CounterSigningSessionTimes,\n//ActionBase,\n//CounterSigningAgents,\n//PreflightBytes,\n//Role,\n//CountersigningAgentState,\n/** hdk/dht-ops.ts */\n// @ts-ignore\nChainOpType, DhtOp, WarrantOp, ChainOp, Warrant, ChainIntegrityWarrant, ValidationType, ActionHashAndSig,\n/** hdk/entry.ts */\n// @ts-ignore\nEntryVisibility, AppEntryDef, EntryType, EntryContent, Entry,\n/** hdk/record.ts */\n// @ts-ignore\nRecord as HcRecord, RecordEntry as HcRecordEntry,\n/** hdk/link.ts */\n//AnyLinkableHash,\n// @ts-ignore\nZomeIndex, LinkType, LinkTag, RateWeight, RateBucketId, RateUnits, Link,\n/** api/admin/types.ts */\n// @ts-ignore\n// YamlProperties\nZomes, WasmCode, CapGrantInfo, PeerMetaInfo, DisabledAppReason, AppStatus, StemCell, ProvisionedCell, ClonedCell, CellType, CellInfo, AppInfo, MembraneProof, MemproofMap, RoleSettingsMap, RoleSettings, DnaModifiersOpt, DnaModifiers, FunctionName, ZomeName, ZomeDefinition, IntegrityZome, CoordinatorZome, DnaDefinition, ResourceBytes, ResourceMap, CellProvisioningStrategy, CellProvisioning, DnaVersionSpec, DnaVersionFlexible, AppRoleDnaManifest, AppRoleManifest, AppManifest, AppBundle, AppBundleSource, NetworkSeed, AppStatusFilter, AppInterfaceInfo, AgentInfoSigned, ZomeLocation, DnaManifest,\n} from '@holochain/client';\n\n\n/// Simple Hashes\n// @ts-ignore\ntype AgentArray = Uint8Array;\n// @ts-ignore\ntype DnaArray = Uint8Array;\n// @ts-ignore\ntype WasmArray = Uint8Array;\n// @ts-ignore\ntype EntryArray = Uint8Array;\n// @ts-ignore\ntype ActionArray = Uint8Array;\n// @ts-ignore\ntype AnyDhtArray = Uint8Array;\n// @ts-ignore\ntype AnyLinkableArray = Uint8Array;\n// @ts-ignore\ntype ExternalArray = Uint8Array;\n\n// @ts-ignore\nimport {\n/** Common */\n// @ts-ignore\nDhtOpHashB64, DhtOpHash,\n/** DnaFile */\n// @ts-ignore\nDnaFile, DnaDef,\n/** entry-details */\n// @ts-ignore\nEntryDetails, RecordDetails, Details, DetailsType, EntryDhtStatus,\n/** Validation */\n// @ts-ignore\nValidationStatus, ValidationReceipt,\n} from '@holochain-open-dev/core-types';\n\nimport {ZomeProxy} from '@ddd-qc/lit-happ';\nimport {profilesAltFunctionNames} from './profilesAlt.fn';\nimport {ProfilesAltUnitEnum} from './profilesAlt.integrity';\nimport {ProfilesAltLinkType} from './profilesAlt.integrity';\n\n/**\n *\n */\nexport class ProfilesAltProxy extends ZomeProxy {\n static override readonly DEFAULT_ZOME_NAME = \"profiles\";\n static override readonly FN_NAMES = profilesAltFunctionNames;\n static override readonly ENTRY_TYPES = Object.values(ProfilesAltUnitEnum);\n static override readonly LINK_TYPES = Object.values(ProfilesAltLinkType);\n \n async createProfile(pair: [Profile, AgentArray]): Promise<ActionArray> {\n return this.callBlocking('create_profile', pair);\n }\n\n async updateProfile(pair: [Profile, AgentArray]): Promise<ActionArray> {\n return this.callBlocking('update_profile', pair);\n }\n\n async 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":"AA0FA,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\n// @ts-ignore\nimport {\n/** api/common.ts */\n// @ts-ignore\nWebsocketConnectionOptions, WsClientOptions, HolochainError, CloneIdHelper,\n/** types.ts */\n// @ts-ignore\nKitsuneAgent, KitsuneSpace, HoloHashB64, AgentPubKeyB64, DnaHashB64, WasmHashB64, EntryHashB64, ActionHashB64, AnyDhtHashB64, InstalledAppId, Signature, CellId, DnaProperties, RoleName, InstalledCell, Timestamp,
|
|
1
|
+
{"version":3,"file":"profilesAlt.types.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.types.ts"],"names":[],"mappings":"AA0FA,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\n// @ts-ignore\nimport {\n/** api/common.ts */\n// @ts-ignore\nWebsocketConnectionOptions, WsClientOptions, HolochainError, CloneIdHelper,\n/** types.ts */\n// @ts-ignore\nKitsuneAgent, KitsuneSpace, HoloHashB64, AgentPubKeyB64, DnaHashB64, WasmHashB64, EntryHashB64, ActionHashB64, AnyDhtHashB64, InstalledAppId, Signature, CellId, DnaProperties, RoleName, InstalledCell, Timestamp, HoloHashed, FetchPoolInfo,\n/** hdk/action.ts */\n// @ts-ignore\nSignedAction, SignedActionHashed, RegisterAgentActivity, ActionHashed, ActionType, Action, NewEntryAction, Dna, AgentValidationPkg, InitZomesComplete, CreateLink, DeleteLink, OpenChain, CloseChain, Update, Delete, Create,\n/** hdk/capabilities.ts */\n// @ts-ignore\nCapSecret, CapClaim, GrantedFunctionsType, GrantedFunctions, ZomeCallCapGrant, CapAccess, CapGrant,\n///** hdk/countersigning.ts */\n//CounterSigningSessionData,\n//PreflightRequest,\n//CounterSigningSessionTimes,\n//ActionBase,\n//CounterSigningAgents,\n//PreflightBytes,\n//Role,\n//CountersigningAgentState,\n/** hdk/dht-ops.ts */\n// @ts-ignore\nChainOpType, DhtOp, WarrantOp, ChainOp, Warrant, ChainIntegrityWarrant, ValidationType, ActionHashAndSig,\n/** hdk/entry.ts */\n// @ts-ignore\nEntryVisibility, AppEntryDef, EntryType, EntryContent, Entry,\n/** hdk/record.ts */\n// @ts-ignore\nRecord as HcRecord, RecordEntry as HcRecordEntry,\n/** hdk/link.ts */\n//AnyLinkableHash,\n// @ts-ignore\nZomeIndex, LinkType, LinkTag, RateWeight, RateBucketId, RateUnits, Link,\n/** api/admin/types.ts */\n// @ts-ignore\n// YamlProperties\nZomes, WasmCode, CapGrantInfo, PeerMetaInfo, DisabledAppReason, AppStatus, StemCell, ProvisionedCell, ClonedCell, CellType, CellInfo, AppInfo, MembraneProof, MemproofMap, RoleSettingsMap, RoleSettings, DnaModifiersOpt, DnaModifiers, FunctionName, ZomeName, ZomeDefinition, IntegrityZome, CoordinatorZome, DnaDefinition, ResourceBytes, ResourceMap, CellProvisioningStrategy, CellProvisioning, DnaVersionSpec, DnaVersionFlexible, AppRoleDnaManifest, AppRoleManifest, AppManifest, AppBundle, AppBundleSource, NetworkSeed, AppStatusFilter, AppInterfaceInfo, AgentInfoSigned, ZomeLocation, DnaManifest,\n} from '@holochain/client';\n\n\n/// Simple Hashes\n// @ts-ignore\ntype AgentArray = Uint8Array;\n// @ts-ignore\ntype DnaArray = Uint8Array;\n// @ts-ignore\ntype WasmArray = Uint8Array;\n// @ts-ignore\ntype EntryArray = Uint8Array;\n// @ts-ignore\ntype ActionArray = Uint8Array;\n// @ts-ignore\ntype AnyDhtArray = Uint8Array;\n// @ts-ignore\ntype AnyLinkableArray = Uint8Array;\n// @ts-ignore\ntype ExternalArray = Uint8Array;\n\n// @ts-ignore\nimport {\n/** Common */\n// @ts-ignore\nDhtOpHashB64, DhtOpHash,\n/** DnaFile */\n// @ts-ignore\nDnaFile, DnaDef,\n/** entry-details */\n// @ts-ignore\nEntryDetails, RecordDetails, Details, DetailsType, EntryDhtStatus,\n/** Validation */\n// @ts-ignore\nValidationStatus, ValidationReceipt,\n} from '@holochain-open-dev/core-types';\n\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"]}
|
|
@@ -11,13 +11,14 @@ export type ProfilesAltComparable = {
|
|
|
11
11
|
export declare class ProfilesAltPerspective {
|
|
12
12
|
profiles: ActionIdMap<[Profile, Timestamp]>;
|
|
13
13
|
profileByAgent: AgentIdMap<ActionId>;
|
|
14
|
-
agentByName: Record<string, AgentId
|
|
14
|
+
agentByName: Record<string, Set<AgentId>>;
|
|
15
15
|
get agents(): AgentId[];
|
|
16
16
|
get names(): string[];
|
|
17
17
|
getProfileAgent(profileId: ActionId): AgentId | undefined;
|
|
18
|
-
getProfile(agent: AgentId
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
getProfile(agent: AgentId): Profile | undefined;
|
|
19
|
+
getProfilesForName(nickname: string): Profile[];
|
|
20
|
+
getProfileTs(agent: AgentId): Timestamp | undefined;
|
|
21
|
+
getAgentsForName(nickname: string): Set<AgentId>;
|
|
21
22
|
makeSnapshot(): ProfilesAltSnapshot;
|
|
22
23
|
}
|
|
23
24
|
export declare class ProfilesAltPerspectiveMutable extends ProfilesAltPerspective {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.perspective.d.ts","sourceRoot":"","sources":["../src/profilesAlt.perspective.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAmB,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAI5C,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC;CAChD,CAAA;AAGD,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB,CAAA;AAGD,qBAAa,sBAAsB;IAEjC,QAAQ,EAAE,WAAW,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAqB;IAEhE,cAAc,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAoB;IAIxD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;
|
|
1
|
+
{"version":3,"file":"profilesAlt.perspective.d.ts","sourceRoot":"","sources":["../src/profilesAlt.perspective.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAmB,MAAM,oBAAoB,CAAC;AACh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Q;IAgBvD,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ;IAczD,OAAO,CAAC,QAAQ,EAAE,mBAAmB;IAgB/B,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAS9F"}
|
|
@@ -16,31 +16,26 @@ export class ProfilesAltPerspective {
|
|
|
16
16
|
return undefined;
|
|
17
17
|
}
|
|
18
18
|
getProfile(agent) {
|
|
19
|
-
if (typeof agent == "string") {
|
|
20
|
-
const maybe = this.agentByName[agent];
|
|
21
|
-
if (!maybe) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
agent = maybe;
|
|
25
|
-
}
|
|
26
19
|
const profileAh = this.profileByAgent.get(agent);
|
|
27
20
|
if (!profileAh) {
|
|
28
21
|
return undefined;
|
|
29
22
|
}
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
23
|
+
const maybe = this.profiles.get(profileAh);
|
|
24
|
+
if (!maybe) {
|
|
32
25
|
return undefined;
|
|
33
26
|
}
|
|
34
|
-
return
|
|
27
|
+
return maybe[0];
|
|
35
28
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
agent = maybe;
|
|
29
|
+
getProfilesForName(nickname) {
|
|
30
|
+
let profiles = new Set();
|
|
31
|
+
const maybe = this.agentByName[nickname];
|
|
32
|
+
if (!maybe) {
|
|
33
|
+
return [];
|
|
43
34
|
}
|
|
35
|
+
profiles = maybe;
|
|
36
|
+
return Object.values(profiles).map((profileAh) => this.profiles.get(profileAh)[0]);
|
|
37
|
+
}
|
|
38
|
+
getProfileTs(agent) {
|
|
44
39
|
const profileAh = this.profileByAgent.get(agent);
|
|
45
40
|
if (!profileAh) {
|
|
46
41
|
return undefined;
|
|
@@ -51,8 +46,12 @@ export class ProfilesAltPerspective {
|
|
|
51
46
|
}
|
|
52
47
|
return pair[1];
|
|
53
48
|
}
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
getAgentsForName(nickname) {
|
|
50
|
+
const maybe = this.agentByName[nickname];
|
|
51
|
+
if (!maybe) {
|
|
52
|
+
return new Set();
|
|
53
|
+
}
|
|
54
|
+
return maybe;
|
|
56
55
|
}
|
|
57
56
|
makeSnapshot() {
|
|
58
57
|
let all = [];
|
|
@@ -75,7 +74,12 @@ export class ProfilesAltPerspectiveMutable extends ProfilesAltPerspective {
|
|
|
75
74
|
this.profiles.set(profileAh, [profile, ts]);
|
|
76
75
|
const agentId = this.getProfileAgent(profileAh);
|
|
77
76
|
if (agentId) {
|
|
78
|
-
this.agentByName[profile.nickname]
|
|
77
|
+
let maybe = this.agentByName[profile.nickname];
|
|
78
|
+
if (!maybe) {
|
|
79
|
+
maybe = new Set();
|
|
80
|
+
}
|
|
81
|
+
maybe.add(agentId);
|
|
82
|
+
this.agentByName[profile.nickname] = maybe;
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
storeAgentProfile(agentId, profileAh) {
|
|
@@ -84,7 +88,12 @@ export class ProfilesAltPerspectiveMutable extends ProfilesAltPerspective {
|
|
|
84
88
|
this.profileByAgent.set(agentId, profileAh);
|
|
85
89
|
const pair = this.profiles.get(profileAh);
|
|
86
90
|
if (pair) {
|
|
87
|
-
this.agentByName[pair[0].nickname]
|
|
91
|
+
let maybe = this.agentByName[pair[0].nickname];
|
|
92
|
+
if (!maybe) {
|
|
93
|
+
maybe = new Set();
|
|
94
|
+
}
|
|
95
|
+
maybe.add(agentId);
|
|
96
|
+
this.agentByName[pair[0].nickname] = maybe;
|
|
88
97
|
}
|
|
89
98
|
}
|
|
90
99
|
unstoreAgentProfile(agentId, profileAh) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.perspective.js","sourceRoot":"","sources":["../src/profilesAlt.perspective.ts"],"names":[],"mappings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{Profile} from \"./bindings/profiles.types\";\r\nimport {Timestamp} from \"@holochain/client\";\r\n\r\n\r\n/** */\r\nexport type ProfilesAltSnapshot = {\r\n all: [AgentId, ActionId, Profile, Timestamp][];\r\n}\r\n\r\n\r\nexport type ProfilesAltComparable = {\r\n profileCount: number,\r\n profiles: Profile[],\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 /** -- 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 /** AgentId or Name */\r\n getProfile(agent: AgentId | string): Profile | undefined {\r\n if (typeof agent == \"string\") {\r\n const maybe = this.agentByName[agent];\r\n if (!maybe) {\r\n return;\r\n }\r\n agent = maybe;\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 const maybe = this.agentByName[agent];\r\n if (!maybe) {\r\n return;\r\n }\r\n agent = maybe;\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: [AgentId, ActionId, Profile, Timestamp][] = [];\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 [agentId, profileAh, profile, ts] of snapshot.all) {\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 if (fields) profile.fields = fields;\r\n this.storeAgentProfile(agentId, profileAh);\r\n this.storeProfile(profileAh, profile, ts? ts : 0);\r\n }\r\n\r\n}\r\n"]}
|
|
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;AAiBhG,MAAM,OAAO,sBAAsB;IAAnC;QAEE,aAAQ,GAAsC,IAAI,WAAW,EAAE,CAAC;QAEhE,mBAAc,GAAyB,IAAI,UAAU,EAAE,CAAC;QAIxD,gBAAW,GAAiC,EAAE,CAAC;IAoFjD,CAAC;IA/EC,IAAI,MAAM,KAAgB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAA,CAAA,CAAC;IACxE,IAAI,KAAK,KAAe,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA,CAAA,CAAC;IAG7D,eAAe,CAAC,SAAmB;QACjC,KAAK,MAAM,CAAC,OAA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\"@ddd-qc/cell-proxy\";\r\nimport {Profile} from \"./bindings/profiles.types\";\r\nimport {Timestamp} from \"@holochain/client\";\r\n\r\n\r\n/** */\r\nexport type ProfilesAltSnapshot = {\r\n all: [AgentId, ActionId, Profile, Timestamp][];\r\n}\r\n\r\n\r\nexport type ProfilesAltComparable = {\r\n profileCount: number,\r\n profiles: Profile[],\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, Set<AgentId>> = {};\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): Profile | undefined {\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 maybe = this.profiles.get(profileAh);\r\n if (!maybe) {\r\n return undefined;\r\n }\r\n return maybe[0];\r\n }\r\n\r\n\r\n /** AgentId or Name */\r\n getProfilesForName(nickname: string): Profile[] {\r\n let profiles = new Set();\r\n const maybe = this.agentByName[nickname];\r\n if (!maybe) {\r\n return [];\r\n }\r\n profiles = maybe;\r\n return Object.values(profiles).map((profileAh) => this.profiles.get(profileAh)![0]);\r\n }\r\n\r\n\r\n /** */\r\n getProfileTs(agent: AgentId): Timestamp | undefined {\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 /** */\r\n getAgentsForName(nickname: string): Set<AgentId> {\r\n const maybe = this.agentByName[nickname];\r\n if (!maybe) {\r\n return new Set();\r\n }\r\n return maybe;\r\n }\r\n\r\n\r\n /** -- Memento -- */\r\n\r\n /** TODO: deep copy */\r\n makeSnapshot(): ProfilesAltSnapshot {\r\n let all: [AgentId, ActionId, Profile, Timestamp][] = [];\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 let maybe = this.agentByName[profile.nickname];\r\n if (!maybe) {\r\n maybe = new Set<AgentId>();\r\n }\r\n maybe.add(agentId);\r\n this.agentByName[profile.nickname] = maybe;\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 let maybe = this.agentByName[pair[0].nickname];\r\n if (!maybe) {\r\n maybe = new Set<AgentId>();\r\n }\r\n maybe.add(agentId);\r\n this.agentByName[pair[0].nickname] = maybe;\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 [agentId, profileAh, profile, ts] of snapshot.all) {\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 if (fields) profile.fields = fields;\r\n this.storeAgentProfile(agentId, profileAh);\r\n this.storeProfile(profileAh, profile, ts? ts : 0);\r\n }\r\n\r\n}\r\n"]}
|
package/dist/profilesAlt.zvm.js
CHANGED
|
@@ -124,7 +124,7 @@ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
124
124
|
for (const [agentId, _profileAh, profile, _ts] of snapshot.all) {
|
|
125
125
|
console.log("ProfilesAltZvm.import() publish profile", agentId.short, profile.nickname);
|
|
126
126
|
const maybe = this._perspective.getProfile(agentId);
|
|
127
|
-
if (
|
|
127
|
+
if (maybe) {
|
|
128
128
|
this.createProfile(profile, agentId);
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.zvm.js","sourceRoot":"","sources":["../src/prof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,CAAC,IAAI,QAAQ,CAAC,GAAG,EAAE;gBAC9D,OAAO,CAAC,GAAG,CAAC,yCAAyC,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACxF,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBACpD,IAAI,CAAC,KAAK,EAAE;oBACA,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;iBAChD;qBAAM;oBACL,IAAI,KAAK,IAAI,OAAO,EAAE;wBACpB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;qBACtC;iBACF;aACF;YACD,OAAO;SACR;QAED,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpC,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC","sourcesContent":["import {\n ActionId,\n AgentId,\n EntryId, holoIdReviver,\n LinkPulseMat,\n StateChangeType,\n ZomeViewModelWithSignals\n} from \"@ddd-qc/lit-happ\";\nimport {Profile} from \"./bindings/profiles.types\";\nimport {decode} from \"@msgpack/msgpack\";\nimport {ProfilesAltProxy} from \"./bindings/profilesAlt.proxy\";\nimport {EntryPulseMat} from \"@ddd-qc/lit-happ/dist/ZomeViewModelWithSignals\";\nimport {ProfilesLinkType} from \"./bindings/profiles.integrity\";\nimport {ProfilesAltUnitEnum} from \"./bindings/profilesAlt.integrity\";\nimport {\n ProfilesAltComparable,\n ProfilesAltPerspective,\n ProfilesAltPerspectiveMutable,\n ProfilesAltSnapshot\n} from \"./profilesAlt.perspective\";\n\n\n/**\n *\n */\nexport class ProfilesAltZvm extends ZomeViewModelWithSignals {\n\n /** -- Concret -- */\n\n static override readonly ZOME_PROXY = ProfilesAltProxy;\n get zomeProxy(): ProfilesAltProxy {return this._zomeProxy as ProfilesAltProxy;}\n\n\n /** */\n override comparable(): Object {\n const res: ProfilesAltComparable = {\n profileCount: this._perspective.profileByAgent.size,\n profiles: Array.from(this.perspective.profiles.values()).map((pair) => pair[0]),\n };\n return res;\n }\n\n /* */\n override hasChanged(): boolean {\n const current = this.comparable() as ProfilesAltComparable;\n const prev = this._previousPerspective as ProfilesAltComparable;\n if (!prev) { return true }\n if (current.profileCount != prev.profileCount) return true;\n for (let i = 0; i < current.profileCount; i+= 1) {\n if (JSON.stringify(current.profiles[i]) != JSON.stringify(prev.profiles[i])) { return true }\n }\n return false;\n }\n\n\n /** */\n override async initializePerspectiveOnline(): Promise<void> {\n await this.probeAllProfiles();\n }\n\n\n /** */\n override 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 override async handleLinkPulse(pulse: LinkPulseMat, _from: AgentId): Promise<void> {\n switch (pulse.link_type) {\n case ProfilesLinkType.PrefixPath:\n case ProfilesLinkType.PathToAgent: {\n const agentEh = new EntryId(pulse.target.b64);\n const agentId = AgentId.from(agentEh);\n 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 it's an EntryHash\n const agentId = AgentId.from(agentEh);\n const profileAh = ActionId.from(pulse.target);\n if (pulse.state == StateChangeType.Delete) {\n this._perspective.unstoreAgentProfile(agentId, profileAh)\n } else {\n this._perspective.storeAgentProfile(agentId, profileAh)\n }\n }\n break;\n }\n }\n\n\n /** */\n override async handleEntryPulse(pulse: EntryPulseMat, _from: AgentId) {\n switch (pulse.entryType) {\n case ProfilesAltUnitEnum.Profile:\n const profile = decode(pulse.bytes) as Profile;\n if (pulse.state != StateChangeType.Delete) {\n this._perspective.storeProfile(pulse.ah, profile, pulse.ts);\n }\n break;\n }\n }\n\n\n /** -- Methods -- */\n\n /** */\n async probeAllProfiles()/*: Promise<Record<AgentPubKeyB64, ProfileMat>>*/ {\n try {\n await this.zomeProxy.probeProfiles();\n } catch(e) {}\n }\n\n\n /** */\n async findProfile(agentId: AgentId): Promise<Profile | undefined> {\n try {\n const maybeProfilePair = await this.zomeProxy.findProfile(agentId.hash);\n console.log(\"findProfile()\", agentId, maybeProfilePair);\n if (!maybeProfilePair) {\n return;\n }\n return maybeProfilePair[1];\n } catch(e) {\n return undefined;\n }\n return undefined;\n }\n\n\n /** */\n async createMyProfile(profile: Profile): Promise<void> {\n await this.zomeProxy.createProfile([profile, this.cell.address.agentId.hash]);\n }\n\n\n /** */\n async updateMyProfile(profile: Profile): Promise<void> {\n await this.zomeProxy.updateProfile([profile, this.cell.address.agentId.hash]);\n }\n\n\n /** */\n async createProfile(profile: Profile, agentId: AgentId): Promise<void> {\n await this.zomeProxy.createProfile([profile, agentId.hash]);\n }\n\n\n /** */\n async updateProfile(profile: Profile, agentId: AgentId): Promise<void> {\n await this.zomeProxy.updateProfile([profile, agentId.hash]);\n }\n\n\n /** -- Import / Export -- */\n\n /** Dump perspective as JSON */\n export(): string {\n const snapshot = this._perspective.makeSnapshot();\n return JSON.stringify(snapshot, null, 2);\n }\n\n\n /** */\n import(json: string, canPublish: boolean) {\n const snapshot = JSON.parse(json, holoIdReviver) as ProfilesAltSnapshot;\n if (canPublish) {\n for (const [agentId, _profileAh, profile, _ts] of snapshot.all) {\n console.log(\"ProfilesAltZvm.import() publish profile\", agentId.short, profile.nickname);\n const maybe = this._perspective.getProfile(agentId);\n if (!maybe) {\n /*await*/ this.createProfile(profile, agentId);\n } else {\n if (maybe != profile) {\n this.updateProfile(profile, agentId);\n }\n }\n }\n return;\n }\n /** */\n this._perspective.restore(snapshot);\n this.notifySubscribers();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"profilesA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E,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,EAAE;gBAC9D,OAAO,CAAC,GAAG,CAAC,yCAAyC,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACxF,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBACpD,IAAI,KAAK,EAAE;oBACC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;iBAChD;qBAAM;oBACL,IAAI,KAAK,IAAI,OAAO,EAAE;wBACpB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;qBACtC;iBACF;aACF;YACD,OAAO;SACR;QAED,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpC,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC","sourcesContent":["import {\n ActionId,\n AgentId,\n EntryId, holoIdReviver,\n LinkPulseMat,\n StateChangeType,\n ZomeViewModelWithSignals\n} from \"@ddd-qc/lit-happ\";\nimport {Profile} from \"./bindings/profiles.types\";\nimport {decode} from \"@msgpack/msgpack\";\nimport {ProfilesAltProxy} from \"./bindings/profilesAlt.proxy\";\nimport {EntryPulseMat} from \"@ddd-qc/lit-happ/dist/ZomeViewModelWithSignals\";\nimport {ProfilesLinkType} from \"./bindings/profiles.integrity\";\nimport {ProfilesAltUnitEnum} from \"./bindings/profilesAlt.integrity\";\nimport {\n ProfilesAltComparable,\n ProfilesAltPerspective,\n ProfilesAltPerspectiveMutable,\n ProfilesAltSnapshot\n} from \"./profilesAlt.perspective\";\n\n\n/**\n *\n */\nexport class ProfilesAltZvm extends ZomeViewModelWithSignals {\n\n /** -- Concret -- */\n\n static override readonly ZOME_PROXY = ProfilesAltProxy;\n get zomeProxy(): ProfilesAltProxy {return this._zomeProxy as ProfilesAltProxy;}\n\n\n /** */\n override comparable(): Object {\n const res: ProfilesAltComparable = {\n profileCount: this._perspective.profileByAgent.size,\n profiles: Array.from(this.perspective.profiles.values()).map((pair) => pair[0]),\n };\n return res;\n }\n\n /* */\n override hasChanged(): boolean {\n const current = this.comparable() as ProfilesAltComparable;\n const prev = this._previousPerspective as ProfilesAltComparable;\n if (!prev) { return true }\n if (current.profileCount != prev.profileCount) return true;\n for (let i = 0; i < current.profileCount; i+= 1) {\n if (JSON.stringify(current.profiles[i]) != JSON.stringify(prev.profiles[i])) { return true }\n }\n return false;\n }\n\n\n /** */\n override async initializePerspectiveOnline(): Promise<void> {\n await this.probeAllProfiles();\n }\n\n\n /** */\n override 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 override async handleLinkPulse(pulse: LinkPulseMat, _from: AgentId): Promise<void> {\n switch (pulse.link_type) {\n case ProfilesLinkType.PrefixPath:\n case ProfilesLinkType.PathToAgent: {\n const agentEh = new EntryId(pulse.target.b64);\n const agentId = AgentId.from(agentEh);\n 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 it's an EntryHash\n const agentId = AgentId.from(agentEh);\n const profileAh = ActionId.from(pulse.target);\n if (pulse.state == StateChangeType.Delete) {\n this._perspective.unstoreAgentProfile(agentId, profileAh)\n } else {\n this._perspective.storeAgentProfile(agentId, profileAh)\n }\n }\n break;\n }\n }\n\n\n /** */\n override async handleEntryPulse(pulse: EntryPulseMat, _from: AgentId) {\n switch (pulse.entryType) {\n case ProfilesAltUnitEnum.Profile:\n const profile = decode(pulse.bytes) as Profile;\n if (pulse.state != StateChangeType.Delete) {\n this._perspective.storeProfile(pulse.ah, profile, pulse.ts);\n }\n break;\n }\n }\n\n\n /** -- Methods -- */\n\n /** */\n async probeAllProfiles()/*: Promise<Record<AgentPubKeyB64, ProfileMat>>*/ {\n try {\n await this.zomeProxy.probeProfiles();\n } catch(e) {}\n }\n\n\n /** */\n async findProfile(agentId: AgentId): Promise<Profile | undefined> {\n try {\n const maybeProfilePair = await this.zomeProxy.findProfile(agentId.hash);\n console.log(\"findProfile()\", agentId, maybeProfilePair);\n if (!maybeProfilePair) {\n return;\n }\n return maybeProfilePair[1];\n } catch(e) {\n return undefined;\n }\n return undefined;\n }\n\n\n /** */\n async createMyProfile(profile: Profile): Promise<void> {\n await this.zomeProxy.createProfile([profile, this.cell.address.agentId.hash]);\n }\n\n\n /** */\n async updateMyProfile(profile: Profile): Promise<void> {\n await this.zomeProxy.updateProfile([profile, this.cell.address.agentId.hash]);\n }\n\n\n /** */\n async createProfile(profile: Profile, agentId: AgentId): Promise<void> {\n await this.zomeProxy.createProfile([profile, agentId.hash]);\n }\n\n\n /** */\n async updateProfile(profile: Profile, agentId: AgentId): Promise<void> {\n await this.zomeProxy.updateProfile([profile, agentId.hash]);\n }\n\n\n /** -- Import / Export -- */\n\n /** Dump perspective as JSON */\n export(): string {\n const snapshot = this._perspective.makeSnapshot();\n return JSON.stringify(snapshot, null, 2);\n }\n\n\n /** */\n import(json: string, canPublish: boolean) {\n const snapshot = JSON.parse(json, holoIdReviver) as ProfilesAltSnapshot;\n if (canPublish) {\n for (const [agentId, _profileAh, profile, _ts] of snapshot.all) {\n console.log(\"ProfilesAltZvm.import() publish profile\", agentId.short, profile.nickname);\n const maybe = this._perspective.getProfile(agentId);\n if (maybe) {\n /*await*/ this.createProfile(profile, agentId);\n } else {\n if (maybe != profile) {\n this.updateProfile(profile, agentId);\n }\n }\n }\n return;\n }\n /** */\n this._perspective.restore(snapshot);\n this.notifySubscribers();\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-qc/profiles-dvm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "DnaViewModel implementation for the Profiles zome.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@ddd-qc/lit-happ": "file:../lit-happ",
|
|
34
|
-
"@holochain-open-dev/elements": "
|
|
35
|
-
"@holochain/client": "^0.
|
|
34
|
+
"@holochain-open-dev/elements": "^0.600.0-dev.0",
|
|
35
|
+
"@holochain/client": "^0.20.0-dev.2",
|
|
36
36
|
"@msgpack/msgpack": "^3.1.1",
|
|
37
37
|
"lit": "3.0.2"
|
|
38
38
|
},
|