@ddd-qc/profiles-dvm 0.24.1 → 0.25.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.
@@ -48,14 +48,7 @@ export type EntryTypes = {
48
48
  };
49
49
  content: Profile;
50
50
  };
51
- export type LinkTypes = {
52
- PrefixPath: null;
53
- } | {
54
- PathToAgent: null;
55
- } | {
56
- AgentToProfile: null;
57
- };
58
- export declare enum LinkTypesType {
51
+ export declare enum LinkTypes {
59
52
  PrefixPath = "PrefixPath",
60
53
  PathToAgent = "PathToAgent",
61
54
  AgentToProfile = "AgentToProfile"
@@ -3,10 +3,10 @@ export var EntryTypesType;
3
3
  (function (EntryTypesType) {
4
4
  EntryTypesType["Profile"] = "Profile";
5
5
  })(EntryTypesType || (EntryTypesType = {}));
6
- export var LinkTypesType;
7
- (function (LinkTypesType) {
8
- LinkTypesType["PrefixPath"] = "PrefixPath";
9
- LinkTypesType["PathToAgent"] = "PathToAgent";
10
- LinkTypesType["AgentToProfile"] = "AgentToProfile";
11
- })(LinkTypesType || (LinkTypesType = {}));
6
+ export var LinkTypes;
7
+ (function (LinkTypes) {
8
+ LinkTypes["PrefixPath"] = "PrefixPath";
9
+ LinkTypes["PathToAgent"] = "PathToAgent";
10
+ LinkTypes["AgentToProfile"] = "AgentToProfile";
11
+ })(LinkTypes || (LinkTypes = {}));
12
12
  //# sourceMappingURL=profiles.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.types.js","sourceRoot":"","sources":["../../src/bindings/profiles.types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAgM1D,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACzB,qCAAmB,CAAA;AACpB,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;AAOD,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACxB,0CAAyB,CAAA;IACzB,4CAA2B,CAAA;IAC3B,kDAAiC,CAAA;AAClC,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {\nWebsocketConnectionOptions,\n/** types.ts */\nHoloHash,\nAgentPubKey,\nDnaHash,\nWasmHash,\nEntryHash,\nActionHash,\nAnyDhtHash,\nExternalHash,\nKitsuneAgent,\nKitsuneSpace,\nHoloHashB64,\nAgentPubKeyB64,\nDnaHashB64,\nWasmHashB64,\nEntryHashB64,\nActionHashB64,\nAnyDhtHashB64,\nInstalledAppId,\nSignature,\nCellId,\nDnaProperties,\nRoleName,\nInstalledCell,\nTimestamp,\nDuration,\nHoloHashed,\nNetworkInfo,\nFetchPoolInfo,\n/** hdk/action.ts */\nSignedActionHashed,\nRegisterAgentActivity,\nActionHashed,\nActionType,\nAction,\nNewEntryAction,\nDna,\nAgentValidationPkg,\nInitZomesComplete,\nCreateLink,\nDeleteLink,\nOpenChain,\nCloseChain,\nUpdate,\nDelete,\nCreate,\n/** hdk/capabilities.ts */\nCapSecret,\nCapClaim,\nGrantedFunctionsType,\nGrantedFunctions,\nZomeCallCapGrant,\nCapAccessType,\nCapAccess,\nCapGrant,\n///** hdk/countersigning.ts */\n//CounterSigningSessionData,\n//PreflightRequest,\n//CounterSigningSessionTimes,\n//ActionBase,\n//CounterSigningAgents,\n//PreflightBytes,\n//Role,\n//CountersigningAgentState,\n/** hdk/dht-ops.ts */\nDhtOpType,\nDhtOp,\ngetDhtOpType,\ngetDhtOpAction,\ngetDhtOpEntry,\ngetDhtOpSignature,\n/** hdk/entry.ts */\nEntryVisibility,\nAppEntryDef,\nEntryType,\nEntryContent,\nEntry,\n/** hdk/record.ts */\nRecord as HcRecord,\nRecordEntry as HcRecordEntry,\n/** hdk/link.ts */\nAnyLinkableHash,\nZomeIndex,\nLinkType,\nLinkTag,\nRateWeight,\nRateBucketId,\nRateUnits,\nLink,\n/** api/admin/types.ts */\nInstalledAppInfoStatus,\nDeactivationReason,\nDisabledAppReason,\nStemCell,\nProvisionedCell,\nClonedCell,\nCellType,\nCellInfo,\nAppInfo,\nMembraneProof,\nFunctionName,\nZomeName,\nZomeDefinition,\nIntegrityZome,\nCoordinatorZome,\nDnaDefinition,\nResourceBytes,\nResourceMap,\nCellProvisioningStrategy,\nCellProvisioning,\nDnaVersionSpec,\nDnaVersionFlexible,\nAppRoleDnaManifest,\nAppRoleManifest,\nAppManifest,\nAppBundle,\nAppBundleSource,\nNetworkSeed,\nZomeLocation,\n } from '@holochain/client';\n\nimport {\n/** Common */\nDhtOpHashB64,\n//DnaHashB64, (duplicate)\n//AnyDhtHashB64, (duplicate)\nDhtOpHash,\n/** DnaFile */\nDnaFile,\nDnaDef,\nZomes,\nWasmCode,\n/** entry-details */\nEntryDetails,\nRecordDetails,\nDetails,\nDetailsType,\nEntryDhtStatus,\n/** Validation */\nValidationStatus,\nValidationReceipt,\n } from '@holochain-open-dev/core-types';\n\nexport type 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\nexport type LinkTypes =\n | {PrefixPath: null} | {PathToAgent: null} | {AgentToProfile: null};\nexport enum LinkTypesType {\n\tPrefixPath = 'PrefixPath',\n\tPathToAgent = 'PathToAgent',\n\tAgentToProfile = 'AgentToProfile',\n}\n"]}
1
+ {"version":3,"file":"profiles.types.js","sourceRoot":"","sources":["../../src/bindings/profiles.types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAgM1D,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACzB,qCAAmB,CAAA;AACpB,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;AAKD,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACpB,sCAAyB,CAAA;IACzB,wCAA2B,CAAA;IAC3B,8CAAiC,CAAA;AAClC,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {\nWebsocketConnectionOptions,\n/** types.ts */\nHoloHash,\nAgentPubKey,\nDnaHash,\nWasmHash,\nEntryHash,\nActionHash,\nAnyDhtHash,\nExternalHash,\nKitsuneAgent,\nKitsuneSpace,\nHoloHashB64,\nAgentPubKeyB64,\nDnaHashB64,\nWasmHashB64,\nEntryHashB64,\nActionHashB64,\nAnyDhtHashB64,\nInstalledAppId,\nSignature,\nCellId,\nDnaProperties,\nRoleName,\nInstalledCell,\nTimestamp,\nDuration,\nHoloHashed,\nNetworkInfo,\nFetchPoolInfo,\n/** hdk/action.ts */\nSignedActionHashed,\nRegisterAgentActivity,\nActionHashed,\nActionType,\nAction,\nNewEntryAction,\nDna,\nAgentValidationPkg,\nInitZomesComplete,\nCreateLink,\nDeleteLink,\nOpenChain,\nCloseChain,\nUpdate,\nDelete,\nCreate,\n/** hdk/capabilities.ts */\nCapSecret,\nCapClaim,\nGrantedFunctionsType,\nGrantedFunctions,\nZomeCallCapGrant,\nCapAccessType,\nCapAccess,\nCapGrant,\n///** hdk/countersigning.ts */\n//CounterSigningSessionData,\n//PreflightRequest,\n//CounterSigningSessionTimes,\n//ActionBase,\n//CounterSigningAgents,\n//PreflightBytes,\n//Role,\n//CountersigningAgentState,\n/** hdk/dht-ops.ts */\nDhtOpType,\nDhtOp,\ngetDhtOpType,\ngetDhtOpAction,\ngetDhtOpEntry,\ngetDhtOpSignature,\n/** hdk/entry.ts */\nEntryVisibility,\nAppEntryDef,\nEntryType,\nEntryContent,\nEntry,\n/** hdk/record.ts */\nRecord as HcRecord,\nRecordEntry as HcRecordEntry,\n/** hdk/link.ts */\nAnyLinkableHash,\nZomeIndex,\nLinkType,\nLinkTag,\nRateWeight,\nRateBucketId,\nRateUnits,\nLink,\n/** api/admin/types.ts */\nInstalledAppInfoStatus,\nDeactivationReason,\nDisabledAppReason,\nStemCell,\nProvisionedCell,\nClonedCell,\nCellType,\nCellInfo,\nAppInfo,\nMembraneProof,\nFunctionName,\nZomeName,\nZomeDefinition,\nIntegrityZome,\nCoordinatorZome,\nDnaDefinition,\nResourceBytes,\nResourceMap,\nCellProvisioningStrategy,\nCellProvisioning,\nDnaVersionSpec,\nDnaVersionFlexible,\nAppRoleDnaManifest,\nAppRoleManifest,\nAppManifest,\nAppBundle,\nAppBundleSource,\nNetworkSeed,\nZomeLocation,\n } from '@holochain/client';\n\nimport {\n/** Common */\nDhtOpHashB64,\n//DnaHashB64, (duplicate)\n//AnyDhtHashB64, (duplicate)\nDhtOpHash,\n/** DnaFile */\nDnaFile,\nDnaDef,\nZomes,\nWasmCode,\n/** entry-details */\nEntryDetails,\nRecordDetails,\nDetails,\nDetailsType,\nEntryDhtStatus,\n/** Validation */\nValidationStatus,\nValidationReceipt,\n } from '@holochain-open-dev/core-types';\n\nexport type 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\nexport enum LinkTypes {\n\tPrefixPath = 'PrefixPath',\n\tPathToAgent = 'PathToAgent',\n\tAgentToProfile = 'AgentToProfile',\n}\n"]}
@@ -7,8 +7,9 @@ export const profilesAltFunctionNames = [
7
7
  "create_profile",
8
8
  "update_profile",
9
9
  "search_agents",
10
- "get_profile",
11
- "get_agents_with_profile",
10
+ "find_profile",
11
+ "probe_profiles",
12
+ "cast_tip",
12
13
  ];
13
14
  /** Generate tuple array of function names with given zomeName */
14
15
  export function generateProfilesAltZomeFunctionsArray(zomeName) {
@@ -1 +1 @@
1
- {"version":3,"file":"profilesAlt.fn.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.fn.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAK1D,wDAAwD;AACxD,MAAM,CAAC,MAAM,wBAAwB,GAAmB;IACvD,YAAY;IACZ,eAAe;IACf,cAAc;IAEd,gBAAgB;IAChB,gBAAgB;IAChB,eAAe;IACf,aAAa;IACb,yBAAyB;CAAE,CAAC;AAG7B,iEAAiE;AACjE,MAAM,UAAU,qCAAqC,CAAC,QAAkB;IACrE,MAAM,GAAG,GAA+B,EAAE,CAAC;IAC3C,KAAK,MAAM,EAAE,IAAI,wBAAwB,EAAE;QACxC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;KAC3B;IACD,OAAO,GAAG,CAAC;AACd,CAAC;AAGD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,wBAAwB,GAA+B,qCAAqC,CAAC,UAAU,CAAC,CAAC","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {ZomeName, FunctionName} from '@holochain/client';\n\n\n/** Array of all zome function names in \"profilesAlt\" */\nexport const profilesAltFunctionNames: FunctionName[] = [\n\t\"entry_defs\", \n\t\"get_zome_info\", \n\t\"get_dna_info\",\n\n\t\"create_profile\",\n\t\"update_profile\",\n\t\"search_agents\",\n\t\"get_profile\",\n\t\"get_agents_with_profile\",];\n\n\n/** Generate tuple array of function names with given zomeName */\nexport function generateProfilesAltZomeFunctionsArray(zomeName: ZomeName): [ZomeName, FunctionName][] {\n const fns: [ZomeName, FunctionName][] = [];\n for (const fn of profilesAltFunctionNames) {\n fns.push([zomeName, fn]);\n }\n return fns;\n}\n\n\n/** Tuple array of all zome function names with default zome name \"profiles\" */\nexport const profilesAltZomeFunctions: [ZomeName, FunctionName][] = generateProfilesAltZomeFunctionsArray(\"profiles\");\n"]}
1
+ {"version":3,"file":"profilesAlt.fn.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.fn.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAK1D,wDAAwD;AACxD,MAAM,CAAC,MAAM,wBAAwB,GAAmB;IACvD,YAAY;IACZ,eAAe;IACf,cAAc;IAGd,gBAAgB;IAChB,gBAAgB;IAChB,eAAe;IACf,cAAc;IACd,gBAAgB;IAChB,UAAU;CACV,CAAC;AAGF,iEAAiE;AACjE,MAAM,UAAU,qCAAqC,CAAC,QAAkB;IACrE,MAAM,GAAG,GAA+B,EAAE,CAAC;IAC3C,KAAK,MAAM,EAAE,IAAI,wBAAwB,EAAE;QACxC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;KAC3B;IACD,OAAO,GAAG,CAAC;AACd,CAAC;AAGD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,wBAAwB,GAA+B,qCAAqC,CAAC,UAAU,CAAC,CAAC","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {ZomeName, FunctionName} from '@holochain/client';\n\n\n/** Array of all zome function names in \"profilesAlt\" */\nexport const profilesAltFunctionNames: FunctionName[] = [\n\t\"entry_defs\", \n\t\"get_zome_info\", \n\t\"get_dna_info\",\n\n\n\t\"create_profile\",\n\t\"update_profile\",\n\t\"search_agents\",\n\t\"find_profile\",\n\t\"probe_profiles\",\n\t\"cast_tip\",\n];\n\n\n/** Generate tuple array of function names with given zomeName */\nexport function generateProfilesAltZomeFunctionsArray(zomeName: ZomeName): [ZomeName, FunctionName][] {\n const fns: [ZomeName, FunctionName][] = [];\n for (const fn of profilesAltFunctionNames) {\n fns.push([zomeName, fn]);\n }\n return fns;\n}\n\n\n/** Tuple array of all zome function names with default zome name \"profiles\" */\nexport const profilesAltZomeFunctions: [ZomeName, FunctionName][] = generateProfilesAltZomeFunctionsArray(\"profiles\");\n"]}
@@ -1,7 +1,5 @@
1
- import { Profile } from './profilesAlt.types';
2
- import { AgentPubKey,
3
- /** hdk/record.ts */
4
- Record as HcRecord } from '@holochain/client';
1
+ import { CastTipInput, Profile } from './profilesAlt.types';
2
+ import { AgentPubKey, ActionHash } from '@holochain/client';
5
3
  import { ZomeProxy } from '@ddd-qc/lit-happ';
6
4
  /**
7
5
  *
@@ -9,9 +7,10 @@ import { ZomeProxy } from '@ddd-qc/lit-happ';
9
7
  export declare class ProfilesAltProxy extends ZomeProxy {
10
8
  static readonly DEFAULT_ZOME_NAME = "profiles";
11
9
  static readonly FN_NAMES: string[];
12
- createProfile(pair: [Profile, AgentPubKey]): Promise<HcRecord>;
13
- updateProfile(pair: [Profile, AgentPubKey]): Promise<HcRecord>;
10
+ createProfile(pair: [Profile, AgentPubKey]): Promise<ActionHash>;
11
+ updateProfile(pair: [Profile, AgentPubKey]): Promise<ActionHash>;
14
12
  searchAgents(nicknameFilter: string): Promise<AgentPubKey[]>;
15
- getProfile(agentPubKey: AgentPubKey): Promise<HcRecord | null>;
16
- getAgentsWithProfile(): Promise<AgentPubKey[]>;
13
+ findProfile(agentPubKey: AgentPubKey): Promise<[ActionHash, Profile] | null>;
14
+ probeProfiles(): Promise<void>;
15
+ castTip(input: CastTipInput): Promise<void>;
17
16
  }
@@ -6,19 +6,22 @@ import { profilesAltFunctionNames } from './profilesAlt.fn';
6
6
  */
7
7
  export class ProfilesAltProxy extends ZomeProxy {
8
8
  async createProfile(pair) {
9
- return this.call('create_profile', pair);
9
+ return this.callBlocking('create_profile', pair);
10
10
  }
11
11
  async updateProfile(pair) {
12
- return this.call('update_profile', pair);
12
+ return this.callBlocking('update_profile', pair);
13
13
  }
14
14
  async searchAgents(nicknameFilter) {
15
15
  return this.call('search_agents', nicknameFilter);
16
16
  }
17
- async getProfile(agentPubKey) {
18
- return this.call('get_profile', agentPubKey);
17
+ async findProfile(agentPubKey) {
18
+ return this.call('find_profile', agentPubKey);
19
19
  }
20
- async getAgentsWithProfile() {
21
- return this.call('get_agents_with_profile', null);
20
+ async probeProfiles() {
21
+ return this.callBlocking('probe_profiles', null);
22
+ }
23
+ async castTip(input) {
24
+ return this.call('cast_tip', input);
22
25
  }
23
26
  }
24
27
  ProfilesAltProxy.DEFAULT_ZOME_NAME = "profiles";
@@ -1 +1 @@
1
- {"version":3,"file":"profilesAlt.proxy.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.proxy.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAoJ1D,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,wBAAwB,EAAC,MAAM,kBAAkB,CAAC;AAE1D;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAK7C,KAAK,CAAC,aAAa,CAAC,IAA4B;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAA4B;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,cAAsB;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,WAAwB;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;;AAtBe,kCAAiB,GAAG,UAAU,CAAA;AAC9B,yBAAQ,GAAG,wBAAwB,CAAA","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {EntryTypes, LinkTypes, Signal, Profile, } from './profilesAlt.types';\nimport {\nWebsocketConnectionOptions,\n/** types.ts */\nHoloHash,\nAgentPubKey,\nDnaHash,\nWasmHash,\nEntryHash,\nActionHash,\nAnyDhtHash,\nExternalHash,\nKitsuneAgent,\nKitsuneSpace,\nHoloHashB64,\nAgentPubKeyB64,\nDnaHashB64,\nWasmHashB64,\nEntryHashB64,\nActionHashB64,\nAnyDhtHashB64,\nInstalledAppId,\nSignature,\nCellId,\nDnaProperties,\nRoleName,\nInstalledCell,\nTimestamp,\nDuration,\nHoloHashed,\nNetworkInfo,\nFetchPoolInfo,\n/** hdk/action.ts */\nSignedActionHashed,\nRegisterAgentActivity,\nActionHashed,\nActionType,\nAction,\nNewEntryAction,\nDna,\nAgentValidationPkg,\nInitZomesComplete,\nCreateLink,\nDeleteLink,\nOpenChain,\nCloseChain,\nUpdate,\nDelete,\nCreate,\n/** hdk/capabilities.ts */\nCapSecret,\nCapClaim,\nGrantedFunctionsType,\nGrantedFunctions,\nZomeCallCapGrant,\nCapAccessType,\nCapAccess,\nCapGrant,\n///** hdk/countersigning.ts */\n//CounterSigningSessionData,\n//PreflightRequest,\n//CounterSigningSessionTimes,\n//ActionBase,\n//CounterSigningAgents,\n//PreflightBytes,\n//Role,\n//CountersigningAgentState,\n/** hdk/dht-ops.ts */\nDhtOpType,\nDhtOp,\ngetDhtOpType,\ngetDhtOpAction,\ngetDhtOpEntry,\ngetDhtOpSignature,\n/** hdk/entry.ts */\nEntryVisibility,\nAppEntryDef,\nEntryType,\nEntryContent,\nEntry,\n/** hdk/record.ts */\nRecord as HcRecord,\nRecordEntry as HcRecordEntry,\n/** hdk/link.ts */\nAnyLinkableHash,\nZomeIndex,\nLinkType,\nLinkTag,\nRateWeight,\nRateBucketId,\nRateUnits,\nLink,\n/** api/admin/types.ts */\nInstalledAppInfoStatus,\nDeactivationReason,\nDisabledAppReason,\nStemCell,\nProvisionedCell,\nClonedCell,\nCellType,\nCellInfo,\nAppInfo,\nMembraneProof,\nFunctionName,\nZomeName,\nZomeDefinition,\nIntegrityZome,\nCoordinatorZome,\nDnaDefinition,\nResourceBytes,\nResourceMap,\nCellProvisioningStrategy,\nCellProvisioning,\nDnaVersionSpec,\nDnaVersionFlexible,\nAppRoleDnaManifest,\nAppRoleManifest,\nAppManifest,\nAppBundle,\nAppBundleSource,\nNetworkSeed,\nZomeLocation,\n } from '@holochain/client';\n\nimport {\n/** Common */\nDhtOpHashB64,\n//DnaHashB64, (duplicate)\n//AnyDhtHashB64, (duplicate)\nDhtOpHash,\n/** DnaFile */\nDnaFile,\nDnaDef,\nZomes,\nWasmCode,\n/** entry-details */\nEntryDetails,\nRecordDetails,\nDetails,\nDetailsType,\nEntryDhtStatus,\n/** Validation */\nValidationStatus,\nValidationReceipt,\n } from '@holochain-open-dev/core-types';\n\nimport {ZomeProxy} from '@ddd-qc/lit-happ';\nimport {profilesAltFunctionNames} from './profilesAlt.fn';\n\n/**\n *\n */\nexport class ProfilesAltProxy extends ZomeProxy {\n static readonly DEFAULT_ZOME_NAME = \"profiles\"\n static readonly FN_NAMES = profilesAltFunctionNames\n \n\n async createProfile(pair: [Profile, AgentPubKey]): Promise<HcRecord> {\n return this.call('create_profile', pair);\n }\n\n async updateProfile(pair: [Profile, AgentPubKey]): Promise<HcRecord> {\n return this.call('update_profile', pair);\n }\n\n async searchAgents(nicknameFilter: string): Promise<AgentPubKey[]> {\n return this.call('search_agents', nicknameFilter);\n }\n\n async getProfile(agentPubKey: AgentPubKey): Promise<HcRecord | null> {\n return this.call('get_profile', agentPubKey);\n }\n\n async getAgentsWithProfile(): Promise<AgentPubKey[]> {\n return this.call('get_agents_with_profile', null);\n }\n}\n"]}
1
+ {"version":3,"file":"profilesAlt.proxy.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.proxy.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAoJ1D,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,wBAAwB,EAAC,MAAM,kBAAkB,CAAC;AAE1D;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAM7C,KAAK,CAAC,aAAa,CAAC,IAA4B;QAC9C,OAAO,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAA4B;QAC9C,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,WAAwB;QACxC,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;IAED,KAAK,CAAC,OAAO,CAAC,KAAmB;QAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;;AA3Be,kCAAiB,GAAG,UAAU,CAAA;AAC9B,yBAAQ,GAAG,wBAAwB,CAAA","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {EntryTypes, LinkTypes, StateChange, SystemSignalProtocol, TipProtocol, ZomeSignalProtocol, CastTipInput, EntryPulse, LinkPulse, Profile, ZomeSignal, } from './profilesAlt.types';\nimport {\nWebsocketConnectionOptions,\n/** types.ts */\nHoloHash,\nAgentPubKey,\nDnaHash,\nWasmHash,\nEntryHash,\nActionHash,\nAnyDhtHash,\nExternalHash,\nKitsuneAgent,\nKitsuneSpace,\nHoloHashB64,\nAgentPubKeyB64,\nDnaHashB64,\nWasmHashB64,\nEntryHashB64,\nActionHashB64,\nAnyDhtHashB64,\nInstalledAppId,\nSignature,\nCellId,\nDnaProperties,\nRoleName,\nInstalledCell,\nTimestamp,\nDuration,\nHoloHashed,\nNetworkInfo,\nFetchPoolInfo,\n/** hdk/action.ts */\nSignedActionHashed,\nRegisterAgentActivity,\nActionHashed,\nActionType,\nAction,\nNewEntryAction,\nDna,\nAgentValidationPkg,\nInitZomesComplete,\nCreateLink,\nDeleteLink,\nOpenChain,\nCloseChain,\nUpdate,\nDelete,\nCreate,\n/** hdk/capabilities.ts */\nCapSecret,\nCapClaim,\nGrantedFunctionsType,\nGrantedFunctions,\nZomeCallCapGrant,\nCapAccessType,\nCapAccess,\nCapGrant,\n///** hdk/countersigning.ts */\n//CounterSigningSessionData,\n//PreflightRequest,\n//CounterSigningSessionTimes,\n//ActionBase,\n//CounterSigningAgents,\n//PreflightBytes,\n//Role,\n//CountersigningAgentState,\n/** hdk/dht-ops.ts */\nDhtOpType,\nDhtOp,\ngetDhtOpType,\ngetDhtOpAction,\ngetDhtOpEntry,\ngetDhtOpSignature,\n/** hdk/entry.ts */\nEntryVisibility,\nAppEntryDef,\nEntryType,\nEntryContent,\nEntry,\n/** hdk/record.ts */\nRecord as HcRecord,\nRecordEntry as HcRecordEntry,\n/** hdk/link.ts */\nAnyLinkableHash,\nZomeIndex,\nLinkType,\nLinkTag,\nRateWeight,\nRateBucketId,\nRateUnits,\nLink,\n/** api/admin/types.ts */\nInstalledAppInfoStatus,\nDeactivationReason,\nDisabledAppReason,\nStemCell,\nProvisionedCell,\nClonedCell,\nCellType,\nCellInfo,\nAppInfo,\nMembraneProof,\nFunctionName,\nZomeName,\nZomeDefinition,\nIntegrityZome,\nCoordinatorZome,\nDnaDefinition,\nResourceBytes,\nResourceMap,\nCellProvisioningStrategy,\nCellProvisioning,\nDnaVersionSpec,\nDnaVersionFlexible,\nAppRoleDnaManifest,\nAppRoleManifest,\nAppManifest,\nAppBundle,\nAppBundleSource,\nNetworkSeed,\nZomeLocation,\n } from '@holochain/client';\n\nimport {\n/** Common */\nDhtOpHashB64,\n//DnaHashB64, (duplicate)\n//AnyDhtHashB64, (duplicate)\nDhtOpHash,\n/** DnaFile */\nDnaFile,\nDnaDef,\nZomes,\nWasmCode,\n/** entry-details */\nEntryDetails,\nRecordDetails,\nDetails,\nDetailsType,\nEntryDhtStatus,\n/** Validation */\nValidationStatus,\nValidationReceipt,\n } from '@holochain-open-dev/core-types';\n\nimport {ZomeProxy} from '@ddd-qc/lit-happ';\nimport {profilesAltFunctionNames} from './profilesAlt.fn';\n\n/**\n *\n */\nexport class ProfilesAltProxy extends ZomeProxy {\n static readonly DEFAULT_ZOME_NAME = \"profiles\"\n static readonly FN_NAMES = profilesAltFunctionNames\n \n\n\n async createProfile(pair: [Profile, AgentPubKey]): Promise<ActionHash> {\n return this.callBlocking('create_profile', pair);\n }\n\n async updateProfile(pair: [Profile, AgentPubKey]): Promise<ActionHash> {\n return this.callBlocking('update_profile', pair);\n }\n\n async searchAgents(nicknameFilter: string): Promise<AgentPubKey[]> {\n return this.call('search_agents', nicknameFilter);\n }\n\n async findProfile(agentPubKey: AgentPubKey): Promise<[ActionHash, 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 async castTip(input: CastTipInput): Promise<void> {\n return this.call('cast_tip', input);\n }\n\n}\n"]}
@@ -1,34 +1,4 @@
1
- import {
2
- /** hdk/action.ts */
3
- SignedActionHashed } from '@holochain/client';
4
- export type SignalVariantLinkCreated = {
5
- type: "LinkCreated";
6
- action: SignedActionHashed;
7
- link_type: LinkTypes;
8
- };
9
- export type SignalVariantLinkDeleted = {
10
- type: "LinkDeleted";
11
- action: SignedActionHashed;
12
- create_link_action: SignedActionHashed;
13
- link_type: LinkTypes;
14
- };
15
- export type SignalVariantEntryCreated = {
16
- type: "EntryCreated";
17
- action: SignedActionHashed;
18
- app_entry: EntryTypes;
19
- };
20
- export type SignalVariantEntryUpdated = {
21
- type: "EntryUpdated";
22
- action: SignedActionHashed;
23
- app_entry: EntryTypes;
24
- original_app_entry: EntryTypes;
25
- };
26
- export type SignalVariantEntryDeleted = {
27
- type: "EntryDeleted";
28
- action: SignedActionHashed;
29
- original_app_entry: EntryTypes;
30
- };
31
- export type Signal = SignalVariantLinkCreated | SignalVariantLinkDeleted | SignalVariantEntryCreated | SignalVariantEntryUpdated | SignalVariantEntryDeleted;
1
+ import { AgentPubKey, EntryHash, ActionHash, Timestamp, AppEntryDef, Link } from '@holochain/client';
32
2
  /**
33
3
  * Profile entry definition.
34
4
  *
@@ -48,15 +18,121 @@ export type EntryTypes = {
48
18
  };
49
19
  content: Profile;
50
20
  };
51
- export type LinkTypes = {
52
- PrefixPath: null;
53
- } | {
54
- PathToAgent: null;
55
- } | {
56
- AgentToProfile: null;
57
- };
58
- export declare enum LinkTypesType {
21
+ export declare enum LinkTypes {
59
22
  PrefixPath = "PrefixPath",
60
23
  PathToAgent = "PathToAgent",
61
24
  AgentToProfile = "AgentToProfile"
62
25
  }
26
+ export interface CastTipInput {
27
+ tip: TipProtocol;
28
+ peers: AgentPubKey[];
29
+ }
30
+ /** Bool: True if state change just happened (real-time) */
31
+ export declare enum StateChangeType {
32
+ Create = "Create",
33
+ Update = "Update",
34
+ Delete = "Delete"
35
+ }
36
+ export type StateChangeVariantCreate = {
37
+ Create: boolean;
38
+ };
39
+ export type StateChangeVariantUpdate = {
40
+ Update: boolean;
41
+ };
42
+ export type StateChangeVariantDelete = {
43
+ Delete: boolean;
44
+ };
45
+ export type StateChange = StateChangeVariantCreate | StateChangeVariantUpdate | StateChangeVariantDelete;
46
+ export interface LinkPulse {
47
+ link: Link;
48
+ state: StateChange;
49
+ }
50
+ export interface EntryPulse {
51
+ ah: ActionHash;
52
+ state: StateChange;
53
+ ts: Timestamp;
54
+ author: AgentPubKey;
55
+ eh: EntryHash;
56
+ def: AppEntryDef;
57
+ bytes: Uint8Array;
58
+ }
59
+ /** */
60
+ export interface ZomeSignal {
61
+ from: AgentPubKey;
62
+ pulses: ZomeSignalProtocol[];
63
+ }
64
+ /** */
65
+ export declare enum ZomeSignalProtocolType {
66
+ System = "System",
67
+ Entry = "Entry",
68
+ Link = "Link",
69
+ Tip = "Tip"
70
+ }
71
+ export type ZomeSignalProtocolVariantSystem = {
72
+ System: SystemSignalProtocol;
73
+ };
74
+ export type ZomeSignalProtocolVariantEntry = {
75
+ Entry: EntryPulse;
76
+ };
77
+ export type ZomeSignalProtocolVariantLink = {
78
+ Link: LinkPulse;
79
+ };
80
+ export type ZomeSignalProtocolVariantTip = {
81
+ Tip: TipProtocol;
82
+ };
83
+ export type ZomeSignalProtocol = ZomeSignalProtocolVariantSystem | ZomeSignalProtocolVariantEntry | ZomeSignalProtocolVariantLink | ZomeSignalProtocolVariantTip;
84
+ /** Protocol for notifying the ViewModel (UI) of system level events */
85
+ export type SystemSignalProtocolVariantPostCommitNewStart = {
86
+ type: "PostCommitNewStart";
87
+ app_entry_type: string;
88
+ };
89
+ export type SystemSignalProtocolVariantPostCommitNewEnd = {
90
+ type: "PostCommitNewEnd";
91
+ app_entry_type: string;
92
+ succeeded: boolean;
93
+ };
94
+ export type SystemSignalProtocolVariantPostCommitDeleteStart = {
95
+ type: "PostCommitDeleteStart";
96
+ app_entry_type: string;
97
+ };
98
+ export type SystemSignalProtocolVariantPostCommitDeleteEnd = {
99
+ type: "PostCommitDeleteEnd";
100
+ app_entry_type: string;
101
+ succeeded: boolean;
102
+ };
103
+ export type SystemSignalProtocolVariantSelfCallStart = {
104
+ type: "SelfCallStart";
105
+ zome_name: string;
106
+ fn_name: string;
107
+ };
108
+ export type SystemSignalProtocolVariantSelfCallEnd = {
109
+ type: "SelfCallEnd";
110
+ zome_name: string;
111
+ fn_name: string;
112
+ succeeded: boolean;
113
+ };
114
+ export type SystemSignalProtocol = SystemSignalProtocolVariantPostCommitNewStart | SystemSignalProtocolVariantPostCommitNewEnd | SystemSignalProtocolVariantPostCommitDeleteStart | SystemSignalProtocolVariantPostCommitDeleteEnd | SystemSignalProtocolVariantSelfCallStart | SystemSignalProtocolVariantSelfCallEnd;
115
+ /** Used by UI ONLY. That's why we use B64 here. */
116
+ export declare enum TipProtocolType {
117
+ Ping = "Ping",
118
+ Pong = "Pong",
119
+ Entry = "Entry",
120
+ Link = "Link",
121
+ App = "App"
122
+ }
123
+ export type TipProtocolVariantPing = {
124
+ Ping: AgentPubKey;
125
+ };
126
+ export type TipProtocolVariantPong = {
127
+ Pong: AgentPubKey;
128
+ };
129
+ export type TipProtocolVariantEntry = {
130
+ Entry: EntryPulse;
131
+ };
132
+ export type TipProtocolVariantLink = {
133
+ Link: LinkPulse;
134
+ };
135
+ export type TipProtocolVariantApp = {
136
+ App: Uint8Array;
137
+ };
138
+ export type TipProtocol = TipProtocolVariantPing | TipProtocolVariantPong | TipProtocolVariantEntry | TipProtocolVariantLink | TipProtocolVariantApp;
@@ -3,10 +3,34 @@ export var EntryTypesType;
3
3
  (function (EntryTypesType) {
4
4
  EntryTypesType["Profile"] = "Profile";
5
5
  })(EntryTypesType || (EntryTypesType = {}));
6
- export var LinkTypesType;
7
- (function (LinkTypesType) {
8
- LinkTypesType["PrefixPath"] = "PrefixPath";
9
- LinkTypesType["PathToAgent"] = "PathToAgent";
10
- LinkTypesType["AgentToProfile"] = "AgentToProfile";
11
- })(LinkTypesType || (LinkTypesType = {}));
6
+ export var LinkTypes;
7
+ (function (LinkTypes) {
8
+ LinkTypes["PrefixPath"] = "PrefixPath";
9
+ LinkTypes["PathToAgent"] = "PathToAgent";
10
+ LinkTypes["AgentToProfile"] = "AgentToProfile";
11
+ })(LinkTypes || (LinkTypes = {}));
12
+ /** Bool: True if state change just happened (real-time) */
13
+ export var StateChangeType;
14
+ (function (StateChangeType) {
15
+ StateChangeType["Create"] = "Create";
16
+ StateChangeType["Update"] = "Update";
17
+ StateChangeType["Delete"] = "Delete";
18
+ })(StateChangeType || (StateChangeType = {}));
19
+ /** */
20
+ export var ZomeSignalProtocolType;
21
+ (function (ZomeSignalProtocolType) {
22
+ ZomeSignalProtocolType["System"] = "System";
23
+ ZomeSignalProtocolType["Entry"] = "Entry";
24
+ ZomeSignalProtocolType["Link"] = "Link";
25
+ ZomeSignalProtocolType["Tip"] = "Tip";
26
+ })(ZomeSignalProtocolType || (ZomeSignalProtocolType = {}));
27
+ /** Used by UI ONLY. That's why we use B64 here. */
28
+ export var TipProtocolType;
29
+ (function (TipProtocolType) {
30
+ TipProtocolType["Ping"] = "Ping";
31
+ TipProtocolType["Pong"] = "Pong";
32
+ TipProtocolType["Entry"] = "Entry";
33
+ TipProtocolType["Link"] = "Link";
34
+ TipProtocolType["App"] = "App";
35
+ })(TipProtocolType || (TipProtocolType = {}));
12
36
  //# sourceMappingURL=profilesAlt.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"profilesAlt.types.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAgM1D,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACzB,qCAAmB,CAAA;AACpB,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;AAOD,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACxB,0CAAyB,CAAA;IACzB,4CAA2B,CAAA;IAC3B,kDAAiC,CAAA;AAClC,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {\nWebsocketConnectionOptions,\n/** types.ts */\nHoloHash,\nAgentPubKey,\nDnaHash,\nWasmHash,\nEntryHash,\nActionHash,\nAnyDhtHash,\nExternalHash,\nKitsuneAgent,\nKitsuneSpace,\nHoloHashB64,\nAgentPubKeyB64,\nDnaHashB64,\nWasmHashB64,\nEntryHashB64,\nActionHashB64,\nAnyDhtHashB64,\nInstalledAppId,\nSignature,\nCellId,\nDnaProperties,\nRoleName,\nInstalledCell,\nTimestamp,\nDuration,\nHoloHashed,\nNetworkInfo,\nFetchPoolInfo,\n/** hdk/action.ts */\nSignedActionHashed,\nRegisterAgentActivity,\nActionHashed,\nActionType,\nAction,\nNewEntryAction,\nDna,\nAgentValidationPkg,\nInitZomesComplete,\nCreateLink,\nDeleteLink,\nOpenChain,\nCloseChain,\nUpdate,\nDelete,\nCreate,\n/** hdk/capabilities.ts */\nCapSecret,\nCapClaim,\nGrantedFunctionsType,\nGrantedFunctions,\nZomeCallCapGrant,\nCapAccessType,\nCapAccess,\nCapGrant,\n///** hdk/countersigning.ts */\n//CounterSigningSessionData,\n//PreflightRequest,\n//CounterSigningSessionTimes,\n//ActionBase,\n//CounterSigningAgents,\n//PreflightBytes,\n//Role,\n//CountersigningAgentState,\n/** hdk/dht-ops.ts */\nDhtOpType,\nDhtOp,\ngetDhtOpType,\ngetDhtOpAction,\ngetDhtOpEntry,\ngetDhtOpSignature,\n/** hdk/entry.ts */\nEntryVisibility,\nAppEntryDef,\nEntryType,\nEntryContent,\nEntry,\n/** hdk/record.ts */\nRecord as HcRecord,\nRecordEntry as HcRecordEntry,\n/** hdk/link.ts */\nAnyLinkableHash,\nZomeIndex,\nLinkType,\nLinkTag,\nRateWeight,\nRateBucketId,\nRateUnits,\nLink,\n/** api/admin/types.ts */\nInstalledAppInfoStatus,\nDeactivationReason,\nDisabledAppReason,\nStemCell,\nProvisionedCell,\nClonedCell,\nCellType,\nCellInfo,\nAppInfo,\nMembraneProof,\nFunctionName,\nZomeName,\nZomeDefinition,\nIntegrityZome,\nCoordinatorZome,\nDnaDefinition,\nResourceBytes,\nResourceMap,\nCellProvisioningStrategy,\nCellProvisioning,\nDnaVersionSpec,\nDnaVersionFlexible,\nAppRoleDnaManifest,\nAppRoleManifest,\nAppManifest,\nAppBundle,\nAppBundleSource,\nNetworkSeed,\nZomeLocation,\n } from '@holochain/client';\n\nimport {\n/** Common */\nDhtOpHashB64,\n//DnaHashB64, (duplicate)\n//AnyDhtHashB64, (duplicate)\nDhtOpHash,\n/** DnaFile */\nDnaFile,\nDnaDef,\nZomes,\nWasmCode,\n/** entry-details */\nEntryDetails,\nRecordDetails,\nDetails,\nDetailsType,\nEntryDhtStatus,\n/** Validation */\nValidationStatus,\nValidationReceipt,\n } from '@holochain-open-dev/core-types';\n\nexport type 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\nexport type LinkTypes =\n | {PrefixPath: null} | {PathToAgent: null} | {AgentToProfile: null};\nexport enum LinkTypesType {\n\tPrefixPath = 'PrefixPath',\n\tPathToAgent = 'PathToAgent',\n\tAgentToProfile = 'AgentToProfile',\n}\n"]}
1
+ {"version":3,"file":"profilesAlt.types.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AA8J1D,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACzB,qCAAmB,CAAA;AACpB,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB;AAKD,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACpB,sCAAyB,CAAA;IACzB,wCAA2B,CAAA;IAC3B,8CAAiC,CAAA;AAClC,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB;AAOD,2DAA2D;AAC3D,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IAC1B,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;AAClB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AA4BD,OAAO;AACP,MAAM,CAAN,IAAY,sBAKX;AALD,WAAY,sBAAsB;IACjC,2CAAiB,CAAA;IACjB,yCAAe,CAAA;IACf,uCAAa,CAAA;IACb,qCAAW,CAAA;AACZ,CAAC,EALW,sBAAsB,KAAtB,sBAAsB,QAKjC;AA8CD,mDAAmD;AACnD,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IAC1B,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,kCAAe,CAAA;IACf,gCAAa,CAAA;IACb,8BAAW,CAAA;AACZ,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {\nWebsocketConnectionOptions,\n/** types.ts */\nHoloHash,\nAgentPubKey,\nDnaHash,\nWasmHash,\nEntryHash,\nActionHash,\nAnyDhtHash,\nExternalHash,\nKitsuneAgent,\nKitsuneSpace,\nHoloHashB64,\nAgentPubKeyB64,\nDnaHashB64,\nWasmHashB64,\nEntryHashB64,\nActionHashB64,\nAnyDhtHashB64,\nInstalledAppId,\nSignature,\nCellId,\nDnaProperties,\nRoleName,\nInstalledCell,\nTimestamp,\nDuration,\nHoloHashed,\nNetworkInfo,\nFetchPoolInfo,\n/** hdk/action.ts */\nSignedActionHashed,\nRegisterAgentActivity,\nActionHashed,\nActionType,\nAction,\nNewEntryAction,\nDna,\nAgentValidationPkg,\nInitZomesComplete,\nCreateLink,\nDeleteLink,\nOpenChain,\nCloseChain,\nUpdate,\nDelete,\nCreate,\n/** hdk/capabilities.ts */\nCapSecret,\nCapClaim,\nGrantedFunctionsType,\nGrantedFunctions,\nZomeCallCapGrant,\nCapAccessType,\nCapAccess,\nCapGrant,\n///** hdk/countersigning.ts */\n//CounterSigningSessionData,\n//PreflightRequest,\n//CounterSigningSessionTimes,\n//ActionBase,\n//CounterSigningAgents,\n//PreflightBytes,\n//Role,\n//CountersigningAgentState,\n/** hdk/dht-ops.ts */\nDhtOpType,\nDhtOp,\ngetDhtOpType,\ngetDhtOpAction,\ngetDhtOpEntry,\ngetDhtOpSignature,\n/** hdk/entry.ts */\nEntryVisibility,\nAppEntryDef,\nEntryType,\nEntryContent,\nEntry,\n/** hdk/record.ts */\nRecord as HcRecord,\nRecordEntry as HcRecordEntry,\n/** hdk/link.ts */\nAnyLinkableHash,\nZomeIndex,\nLinkType,\nLinkTag,\nRateWeight,\nRateBucketId,\nRateUnits,\nLink,\n/** api/admin/types.ts */\nInstalledAppInfoStatus,\nDeactivationReason,\nDisabledAppReason,\nStemCell,\nProvisionedCell,\nClonedCell,\nCellType,\nCellInfo,\nAppInfo,\nMembraneProof,\nFunctionName,\nZomeName,\nZomeDefinition,\nIntegrityZome,\nCoordinatorZome,\nDnaDefinition,\nResourceBytes,\nResourceMap,\nCellProvisioningStrategy,\nCellProvisioning,\nDnaVersionSpec,\nDnaVersionFlexible,\nAppRoleDnaManifest,\nAppRoleManifest,\nAppManifest,\nAppBundle,\nAppBundleSource,\nNetworkSeed,\nZomeLocation,\n } from '@holochain/client';\n\nimport {\n/** Common */\nDhtOpHashB64,\n//DnaHashB64, (duplicate)\n//AnyDhtHashB64, (duplicate)\nDhtOpHash,\n/** DnaFile */\nDnaFile,\nDnaDef,\nZomes,\nWasmCode,\n/** entry-details */\nEntryDetails,\nRecordDetails,\nDetails,\nDetailsType,\nEntryDhtStatus,\n/** Validation */\nValidationStatus,\nValidationReceipt,\n } from '@holochain-open-dev/core-types';\n\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\nexport enum LinkTypes {\n\tPrefixPath = 'PrefixPath',\n\tPathToAgent = 'PathToAgent',\n\tAgentToProfile = 'AgentToProfile',\n}\n\nexport interface CastTipInput {\n tip: TipProtocol\n peers: AgentPubKey[]\n}\n\n/** Bool: True if state change just happened (real-time) */\nexport enum StateChangeType {\n\tCreate = 'Create',\n\tUpdate = 'Update',\n\tDelete = 'Delete',\n}\nexport type StateChangeVariantCreate = {Create: boolean}\nexport type StateChangeVariantUpdate = {Update: boolean}\nexport type StateChangeVariantDelete = {Delete: boolean}\nexport type StateChange = \n | StateChangeVariantCreate | StateChangeVariantUpdate | StateChangeVariantDelete;\n\nexport interface LinkPulse {\n link: Link\n state: StateChange\n}\n\nexport interface EntryPulse {\n ah: ActionHash\n state: StateChange\n ts: Timestamp\n author: AgentPubKey\n eh: EntryHash\n def: AppEntryDef\n bytes: Uint8Array\n}\n\n/** */\nexport interface ZomeSignal {\n from: AgentPubKey\n pulses: ZomeSignalProtocol[]\n}\n\n/** */\nexport enum ZomeSignalProtocolType {\n\tSystem = 'System',\n\tEntry = 'Entry',\n\tLink = 'Link',\n\tTip = 'Tip',\n}\nexport type ZomeSignalProtocolVariantSystem = {System: SystemSignalProtocol}\nexport type ZomeSignalProtocolVariantEntry = {Entry: EntryPulse}\nexport type ZomeSignalProtocolVariantLink = {Link: LinkPulse}\nexport type ZomeSignalProtocolVariantTip = {Tip: TipProtocol}\nexport type ZomeSignalProtocol = \n | ZomeSignalProtocolVariantSystem | ZomeSignalProtocolVariantEntry | ZomeSignalProtocolVariantLink | ZomeSignalProtocolVariantTip;\n\n/** Protocol for notifying the ViewModel (UI) of system level events */\nexport type SystemSignalProtocolVariantPostCommitNewStart = {\n type: \"PostCommitNewStart\"\n app_entry_type: string\n}\nexport type SystemSignalProtocolVariantPostCommitNewEnd = {\n type: \"PostCommitNewEnd\"\n app_entry_type: string\n succeeded: boolean\n}\nexport type SystemSignalProtocolVariantPostCommitDeleteStart = {\n type: \"PostCommitDeleteStart\"\n app_entry_type: string\n}\nexport type SystemSignalProtocolVariantPostCommitDeleteEnd = {\n type: \"PostCommitDeleteEnd\"\n app_entry_type: string\n succeeded: boolean\n}\nexport type SystemSignalProtocolVariantSelfCallStart = {\n type: \"SelfCallStart\"\n zome_name: string\n fn_name: string\n}\nexport type SystemSignalProtocolVariantSelfCallEnd = {\n type: \"SelfCallEnd\"\n zome_name: string\n fn_name: string\n succeeded: boolean\n}\nexport type SystemSignalProtocol =\n | SystemSignalProtocolVariantPostCommitNewStart\n | SystemSignalProtocolVariantPostCommitNewEnd\n | SystemSignalProtocolVariantPostCommitDeleteStart\n | SystemSignalProtocolVariantPostCommitDeleteEnd\n | SystemSignalProtocolVariantSelfCallStart\n | SystemSignalProtocolVariantSelfCallEnd;\n\n/** Used by UI ONLY. That's why we use B64 here. */\nexport enum TipProtocolType {\n\tPing = 'Ping',\n\tPong = 'Pong',\n\tEntry = 'Entry',\n\tLink = 'Link',\n\tApp = 'App',\n}\nexport type TipProtocolVariantPing = {Ping: AgentPubKey}\nexport type TipProtocolVariantPong = {Pong: AgentPubKey}\nexport type TipProtocolVariantEntry = {Entry: EntryPulse}\nexport type TipProtocolVariantLink = {Link: LinkPulse}\nexport type TipProtocolVariantApp = {App: Uint8Array}\nexport type TipProtocol = \n | TipProtocolVariantPing | TipProtocolVariantPong | TipProtocolVariantEntry | TipProtocolVariantLink | TipProtocolVariantApp;\n"]}
@@ -1,10 +1,10 @@
1
1
  import { ZomeViewModel } from "@ddd-qc/lit-happ";
2
- import { Profile as ProfileMat } from "./bindings/profiles.types";
2
+ import { Profile } from "./bindings/profiles.types";
3
3
  import { AgentPubKeyB64 } from "@holochain/client";
4
4
  import { ProfilesProxy } from "./bindings/profiles.proxy";
5
5
  /** */
6
6
  export interface ProfilesPerspective {
7
- profiles: Record<AgentPubKeyB64, ProfileMat>;
7
+ profiles: Record<AgentPubKeyB64, Profile>;
8
8
  /** Nickname -> AgentPubKeyB64 */
9
9
  reversed: Record<string, AgentPubKeyB64>;
10
10
  }
@@ -23,8 +23,8 @@ export declare class ProfilesZvm extends ZomeViewModel {
23
23
  get perspective(): ProfilesPerspective;
24
24
  private _profiles;
25
25
  private _reversed;
26
- getMyProfile(): ProfileMat | undefined;
27
- getProfile(agent: AgentPubKeyB64): ProfileMat | undefined;
26
+ getMyProfile(): Profile | undefined;
27
+ getProfile(agent: AgentPubKeyB64): Profile | undefined;
28
28
  getAgents(): AgentPubKeyB64[];
29
29
  getNames(): string[];
30
30
  /** Dump perspective as JSON */
@@ -34,13 +34,13 @@ export declare class ProfilesZvm extends ZomeViewModel {
34
34
  /** -- Methods -- */
35
35
  findProfiles(names: string[]): AgentPubKeyB64[];
36
36
  /** */
37
- probeAllProfiles(): Promise<Record<AgentPubKeyB64, ProfileMat>>;
37
+ probeAllProfiles(): Promise<Record<AgentPubKeyB64, Profile>>;
38
38
  /** */
39
- storeProfile(pubKeyB64: AgentPubKeyB64, profile: ProfileMat): void;
39
+ storeProfile(pubKeyB64: AgentPubKeyB64, profile: Profile): void;
40
40
  /** */
41
- probeProfile(pubKeyB64: AgentPubKeyB64): Promise<ProfileMat | undefined>;
41
+ probeProfile(pubKeyB64: AgentPubKeyB64): Promise<Profile | undefined>;
42
42
  /** */
43
- createMyProfile(profile: ProfileMat): Promise<void>;
43
+ createMyProfile(profile: Profile): Promise<void>;
44
44
  /** */
45
- updateMyProfile(profile: ProfileMat): Promise<void>;
45
+ updateMyProfile(profile: Profile): Promise<void>;
46
46
  }
@@ -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.agentPubKey]; }
38
+ getMyProfile() { return this._profiles[this.cell.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); }
@@ -99,7 +99,7 @@ export class ProfilesZvm extends ZomeViewModel {
99
99
  }
100
100
  // const profileEntry: any = decode((maybeProfile.entry as any).Present.entry);
101
101
  // console.log("probeProfile() profileEntry", profileEntry);
102
- //const profile: ProfileMat = decode(profileEntry.record.entry.Present.entry) as ProfileMat;
102
+ //const profile: Profile = decode(profileEntry.record.entry.Present.entry) as Profile;
103
103
  const profile = decode(maybeProfile.entry.Present.entry);
104
104
  console.log("probeProfile() profile", profile);
105
105
  this.storeProfile(pubKeyB64, profile);
@@ -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.agentPubKey, profile);
111
+ this.storeProfile(this.cell.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.agentPubKey, profile);
116
+ this.storeProfile(this.cell.agentId.b64, profile);
117
117
  }
118
118
  }
119
119
  ProfilesZvm.ZOME_PROXY = ProfilesProxy;
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.zvm.js","sourceRoot":"","sources":["../src/profiles.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAiB,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAexC;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,aAAa;IAA9C;;QAkCU,cAAS,GAAuC,EAAE,CAAC;QAC3D,mEAAmE;QAC3D,cAAS,GAAmC,EAAE,CAAC;IAuGzD,CAAC;IAxIC,IAAI,SAAS,KAAmB,OAAO,IAAI,CAAC,UAA2B,CAAC,CAAA,CAAC;IAGzE,KAAK;IACK,UAAU;QAClB,OAAO;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,2BAA2B;QAC/B,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAChC,CAAC;IAED,MAAM;IACN,aAAa;QACX,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAED,wBAAwB;IAExB,KAAK;IACL,IAAI,WAAW;QACb,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,iCAAiC;SAClC,CAAC;IACJ,CAA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KAAK,CAAe,CAAC;QAC5F,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,OAAmB;QACvC,kBAAkB,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,eAAe,CAAC,OAAmB;QACvC,kBAAkB,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;;AAvIe,sBAAU,GAAG,aAAa,AAAhB,CAAiB","sourcesContent":["import {ZomeViewModel} from \"@ddd-qc/lit-happ\";\nimport {Profile as ProfileMat} from \"./bindings/profiles.types\";\nimport {AgentPubKeyB64, decodeHashFromBase64, encodeHashToBase64} from \"@holochain/client\";\nimport {ProfilesProxy} from \"./bindings/profiles.proxy\";\nimport {decode} from \"@msgpack/msgpack\";\n\n\n/** */\nexport interface ProfilesPerspective {\n /* AgentPubKeyB64 -> Profile */\n profiles: Record<AgentPubKeyB64, ProfileMat>,\n ///* AgentPubKeyB64 -> Profile hash */\n //profile_ahs: Record<AgentPubKeyB64, ActionHashB64>,\n\n /** Nickname -> AgentPubKeyB64 */\n reversed: Record<string, AgentPubKeyB64>,\n}\n\n\n/**\n *\n */\nexport class ProfilesZvm extends ZomeViewModel {\n\n static readonly ZOME_PROXY = ProfilesProxy;\n get zomeProxy(): ProfilesProxy {return this._zomeProxy as ProfilesProxy;}\n\n\n /* */\n protected hasChanged(): boolean {\n // TODO\n return true;\n }\n\n\n /** */\n async initializePerspectiveOnline(): Promise<void> {\n await this.probeAllProfiles();\n }\n\n /** */\n probeAllInner() {\n this.probeAllProfiles();\n }\n\n /** -- Perspective -- */\n\n /* */\n get perspective(): ProfilesPerspective {\n return {\n profiles: this._profiles,\n reversed: this._reversed,\n //profile_ahs: this._profile_ahs,\n };\n }\n\n private _profiles: Record<AgentPubKeyB64, ProfileMat> = {};\n //private _profile_ahs: Record<AgentPubKeyB64, ActionHashB64> = {};\n private _reversed: Record<string, AgentPubKeyB64> = {};\n\n\n getMyProfile(): ProfileMat | undefined { return this._profiles[this.cell.agentPubKey] }\n\n getProfile(agent: AgentPubKeyB64): ProfileMat | undefined {return this._profiles[agent]}\n\n //getProfileHash(agent: AgentPubKeyB64): ActionHashB64 | undefined {return this._profile_ahs[agent]}\n\n getAgents(): AgentPubKeyB64[] { return Object.keys(this._profiles)}\n\n getNames(): string[] { return Object.keys(this._reversed)}\n\n\n /** Dump perspective as JSON */\n exportPerspective(): string {\n //console.log(\"exportPerspective()\", perspMat);\n return JSON.stringify(this._profiles, null, 2);\n }\n\n\n /** */\n importPerspective(json: string, mapping?: Object) {\n const profiles = JSON.parse(json) as Record<AgentPubKeyB64, ProfileMat>;\n for (const [pubKey, profileMat] of Object.entries(profiles)) {\n this.storeProfile(pubKey, profileMat);\n }\n }\n\n /** -- Methods -- */\n\n /* */\n findProfiles(names: string[]): AgentPubKeyB64[] {\n let res = []\n for (const name of names) {\n if (this._reversed[name]) {\n res.push(this._reversed[name])\n }\n }\n return res;\n }\n\n\n /** */\n async probeAllProfiles(): Promise<Record<AgentPubKeyB64, ProfileMat>> {\n let allAgents;\n /** Attempt a retry on fail as this can create an entry (path anchor) and generate a 'head has moved' error */\n try {\n allAgents = await this.zomeProxy.getAgentsWithProfile();\n } catch(e) {\n allAgents = await this.zomeProxy.getAgentsWithProfile();\n }\n for (const agentPubKey of allAgents) {\n const maybeProfile = await this.zomeProxy.getAgentProfile(agentPubKey);\n if (!maybeProfile) {\n continue;\n }\n const profile: ProfileMat = decode((maybeProfile.entry as any).Present.entry) as ProfileMat;\n this.storeProfile(encodeHashToBase64(agentPubKey), profile);\n }\n this.notifySubscribers();\n return this._profiles;\n }\n\n\n /** */\n storeProfile(pubKeyB64: AgentPubKeyB64, profile: ProfileMat) {\n this._profiles[pubKeyB64] = profile;\n this._reversed[profile.nickname] = pubKeyB64;\n this.notifySubscribers();\n }\n\n\n /** */\n async probeProfile(pubKeyB64: AgentPubKeyB64): Promise<ProfileMat | undefined> {\n const maybeProfile = await this.zomeProxy.getAgentProfile(decodeHashFromBase64(pubKeyB64));\n console.log(\"probeProfile() maybeProfile\", maybeProfile);\n if (!maybeProfile) {\n return;\n }\n // const profileEntry: any = decode((maybeProfile.entry as any).Present.entry);\n // console.log(\"probeProfile() profileEntry\", profileEntry);\n //const profile: ProfileMat = decode(profileEntry.record.entry.Present.entry) as ProfileMat;\n const profile: ProfileMat = decode((maybeProfile.entry as any).Present.entry) as ProfileMat;\n console.log(\"probeProfile() profile\", profile);\n this.storeProfile(pubKeyB64, profile);\n return profile;\n }\n\n\n /** */\n async createMyProfile(profile: ProfileMat): Promise<void> {\n /*const record =*/ await this.zomeProxy.createProfile(profile);\n this.storeProfile(this.cell.agentPubKey, profile);\n }\n\n\n /** */\n async updateMyProfile(profile: ProfileMat): Promise<void> {\n /*const record =*/ await this.zomeProxy.updateProfile(profile);\n this.storeProfile(this.cell.agentPubKey, profile);\n }\n\n}\n"]}
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,kBA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AI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACpD,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.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.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.agentId.b64, profile);\n }\n\n}\n"]}
@@ -1,18 +1,22 @@
1
- import { ZomeViewModel } from "@ddd-qc/lit-happ";
2
- import { Profile as ProfileMat } from "./bindings/profiles.types";
3
- import { AgentPubKeyB64, Timestamp } from "@holochain/client";
1
+ import { ActionId, ActionIdMap, AgentId, AgentIdMap, ZomeViewModelWithSignals } from "@ddd-qc/lit-happ";
2
+ import { Profile } from "./bindings/profiles.types";
3
+ import { Timestamp } from "@holochain/client";
4
4
  import { ProfilesAltProxy } from "./bindings/profilesAlt.proxy";
5
+ import { EntryPulse, LinkPulse } from "./bindings/profilesAlt.types";
5
6
  /** */
6
- export interface ProfilesAltPerspective {
7
- profiles: Record<AgentPubKeyB64, ProfileMat>;
8
- profileDates: Record<AgentPubKeyB64, Timestamp>;
9
- /** Nickname -> AgentPubKeyB64 */
10
- reversed: Record<string, AgentPubKeyB64>;
7
+ export interface ProfilesAltPerspectiveCore {
8
+ profiles: ActionIdMap<[Profile, Timestamp]>;
9
+ profileByAgent: AgentIdMap<ActionId>;
11
10
  }
11
+ export interface ProfilesAltPerspectiveLive {
12
+ /** Nickname -> AgentId */
13
+ agentByName: Record<string, AgentId>;
14
+ }
15
+ export type ProfilesAltPerspective = ProfilesAltPerspectiveCore & ProfilesAltPerspectiveLive;
12
16
  /**
13
17
  *
14
18
  */
15
- export declare class ProfilesAltZvm extends ZomeViewModel {
19
+ export declare class ProfilesAltZvm extends ZomeViewModelWithSignals {
16
20
  static readonly ZOME_PROXY: typeof ProfilesAltProxy;
17
21
  get zomeProxy(): ProfilesAltProxy;
18
22
  protected hasChanged(): boolean;
@@ -22,32 +26,40 @@ export declare class ProfilesAltZvm extends ZomeViewModel {
22
26
  probeAllInner(): void;
23
27
  /** -- Perspective -- */
24
28
  get perspective(): ProfilesAltPerspective;
25
- private _profiles;
26
- private _profileDates;
27
- private _reversed;
28
- getMyProfile(): ProfileMat | undefined;
29
- getProfile(agent: AgentPubKeyB64): ProfileMat | undefined;
30
- getProfileDate(agent: AgentPubKeyB64): Timestamp | undefined;
31
- getAgents(): AgentPubKeyB64[];
29
+ private _perspective;
30
+ getMyProfile(): Profile | undefined;
31
+ getProfileAgent(profileId: ActionId): AgentId | undefined;
32
+ getProfile(agent: AgentId): Profile | undefined;
33
+ getProfileTs(agent: AgentId): Timestamp | undefined;
34
+ getAgents(): AgentId[];
32
35
  getNames(): string[];
36
+ /** */
37
+ handleLinkPulse(pulse: LinkPulse, from: AgentId): Promise<void>;
38
+ /** */
39
+ handleEntryPulse(pulse: EntryPulse, from: AgentId): Promise<void>;
40
+ /** -- perspective -- */
33
41
  /** Dump perspective as JSON */
34
42
  exportPerspective(): string;
35
43
  /** */
36
44
  importPerspective(json: string, canPublish: boolean): Promise<void>;
37
- /** -- Methods -- */
38
- findProfiles(names: string[]): AgentPubKeyB64[];
45
+ /** -- Store -- */
39
46
  /** */
40
- probeAllProfiles(): Promise<Record<AgentPubKeyB64, ProfileMat>>;
47
+ storeProfile(profileAh: ActionId, profile: Profile, ts: Timestamp): void;
48
+ /** */
49
+ storeAgentProfile(agentId: AgentId, profileAh: ActionId): void;
50
+ /** */
51
+ unstoreAgentProfile(agentId: AgentId, profileAh: ActionId): void;
52
+ /** -- Methods -- */
41
53
  /** */
42
- storeProfile(pubKeyB64: AgentPubKeyB64, profile: ProfileMat, ts: Timestamp): void;
54
+ probeAllProfiles(): Promise<void>;
43
55
  /** */
44
- probeProfile(pubKeyB64: AgentPubKeyB64): Promise<ProfileMat | undefined>;
56
+ findProfile(agentId: AgentId): Promise<Profile | undefined>;
45
57
  /** */
46
- createMyProfile(profile: ProfileMat): Promise<void>;
58
+ createMyProfile(profile: Profile): Promise<void>;
47
59
  /** */
48
- updateMyProfile(profile: ProfileMat): Promise<void>;
60
+ updateMyProfile(profile: Profile): Promise<void>;
49
61
  /** */
50
- createProfile(profile: ProfileMat, agent: AgentPubKeyB64): Promise<void>;
62
+ createProfile(profile: Profile, agentId: AgentId): Promise<void>;
51
63
  /** */
52
- updateProfile(profile: ProfileMat, agent: AgentPubKeyB64): Promise<void>;
64
+ updateProfile(profile: Profile, agentId: AgentId): Promise<void>;
53
65
  }
@@ -1,17 +1,22 @@
1
- import { ZomeViewModel } from "@ddd-qc/lit-happ";
2
- import { decodeHashFromBase64, encodeHashToBase64 } from "@holochain/client";
1
+ import { ActionId, ActionIdMap, AgentId, AgentIdMap, EntryId, getVariantByIndex, intoLinkableId, ZomeViewModelWithSignals } from "@ddd-qc/lit-happ";
2
+ import { LinkTypes } from "./bindings/profiles.types";
3
3
  import { decode } from "@msgpack/msgpack";
4
4
  import { ProfilesAltProxy } from "./bindings/profilesAlt.proxy";
5
+ import { EntryTypesType, StateChangeType, } from "./bindings/profilesAlt.types";
6
+ function createProfilesAltPerspective() {
7
+ return {
8
+ profiles: new ActionIdMap(),
9
+ profileByAgent: new AgentIdMap(),
10
+ agentByName: {},
11
+ };
12
+ }
5
13
  /**
6
14
  *
7
15
  */
8
- export class ProfilesAltZvm extends ZomeViewModel {
16
+ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
9
17
  constructor() {
10
18
  super(...arguments);
11
- this._profiles = {};
12
- this._profileDates = {};
13
- //private _profile_ahs: Record<AgentPubKeyB64, ActionHashB64> = {};
14
- this._reversed = {};
19
+ this._perspective = createProfilesAltPerspective();
15
20
  }
16
21
  get zomeProxy() { return this._zomeProxy; }
17
22
  /* */
@@ -30,117 +35,166 @@ export class ProfilesAltZvm extends ZomeViewModel {
30
35
  /** -- Perspective -- */
31
36
  /* */
32
37
  get perspective() {
33
- return {
34
- profiles: this._profiles,
35
- profileDates: this._profileDates,
36
- reversed: this._reversed,
37
- //profile_ahs: this._profile_ahs,
38
- };
39
- }
40
- getMyProfile() { return this._profiles[this.cell.agentPubKey]; }
41
- getProfile(agent) { return this._profiles[agent]; }
42
- getProfileDate(agent) { return this._profileDates[agent]; }
43
- //getProfileHash(agent: AgentPubKeyB64): ActionHashB64 | undefined {return this._profile_ahs[agent]}
44
- getAgents() { return Object.keys(this._profiles); }
45
- getNames() { return Object.keys(this._reversed); }
38
+ return this._perspective;
39
+ }
40
+ getMyProfile() {
41
+ const pair = this._perspective.profiles.get(this.cell.agentId);
42
+ if (!pair) {
43
+ return undefined;
44
+ }
45
+ return pair[0];
46
+ }
47
+ getProfileAgent(profileId) {
48
+ for (const [agentId, profId] of this._perspective.profileByAgent.entries()) {
49
+ if (profileId.b64 == profId.b64) {
50
+ return agentId;
51
+ }
52
+ }
53
+ return undefined;
54
+ }
55
+ getProfile(agent) {
56
+ const profileAh = this._perspective.profileByAgent.get(agent);
57
+ if (!profileAh) {
58
+ return undefined;
59
+ }
60
+ const pair = this._perspective.profiles.get(profileAh);
61
+ return pair[0];
62
+ }
63
+ getProfileTs(agent) {
64
+ const profileAh = this._perspective.profileByAgent.get(agent);
65
+ if (!profileAh) {
66
+ return undefined;
67
+ }
68
+ const pair = this._perspective.profiles.get(profileAh);
69
+ return pair[1];
70
+ }
71
+ getAgents() { return Array.from(this._perspective.profileByAgent.keys()); }
72
+ getNames() { return Object.keys(this._perspective.agentByName); }
73
+ /** */
74
+ async handleLinkPulse(pulse, from) {
75
+ const link = pulse.link;
76
+ const linkAh = new ActionId(link.create_link_hash);
77
+ const author = new AgentId(link.author);
78
+ const base = intoLinkableId(link.base);
79
+ const target = intoLinkableId(link.target);
80
+ const state = Object.keys(pulse.state)[0];
81
+ const isNew = pulse.state[state];
82
+ /** */
83
+ switch (getVariantByIndex(LinkTypes, link.link_type)) {
84
+ case LinkTypes.PrefixPath:
85
+ case LinkTypes.PathToAgent:
86
+ break;
87
+ case LinkTypes.AgentToProfile:
88
+ if (state == StateChangeType.Delete) {
89
+ this.unstoreAgentProfile(base, target);
90
+ }
91
+ else {
92
+ this.storeAgentProfile(base, target);
93
+ }
94
+ if (isNew && from.b64 == this.cell.agentId.b64) {
95
+ await this.broadcastTip({ Link: pulse });
96
+ }
97
+ break;
98
+ }
99
+ }
100
+ /** */
101
+ async handleEntryPulse(pulse, from) {
102
+ const entryType = getVariantByIndex(EntryTypesType, pulse.def.entry_index);
103
+ const author = new AgentId(pulse.author);
104
+ const ah = new ActionId(pulse.ah);
105
+ const eh = new EntryId(pulse.eh);
106
+ const state = Object.keys(pulse.state)[0];
107
+ const isNew = pulse.state[state];
108
+ switch (entryType) {
109
+ case EntryTypesType.Profile:
110
+ const profile = decode(pulse.bytes);
111
+ if (state != StateChangeType.Delete) {
112
+ this.storeProfile(ah, profile, pulse.ts);
113
+ }
114
+ if (isNew && from.b64 == this.cell.agentId.b64) {
115
+ await this.broadcastTip({ Entry: pulse });
116
+ }
117
+ break;
118
+ }
119
+ }
120
+ /** -- perspective -- */
46
121
  /** Dump perspective as JSON */
47
122
  exportPerspective() {
48
123
  //console.log("exportPerspective()", perspMat);
49
- return JSON.stringify(this._profiles, null, 2);
50
- //return JSON.stringify(this.perspective, null, 2);
124
+ const core = this._perspective; // FIXME: check if this actually works as expected
125
+ return JSON.stringify(core, null, 2);
51
126
  }
52
127
  /** */
53
128
  async importPerspective(json, canPublish) {
54
- const profiles = JSON.parse(json);
129
+ const perspective = JSON.parse(json);
55
130
  if (canPublish) {
56
- for (const [pubKey, profileMat] of Object.entries(profiles)) {
57
- await this.createProfile(profileMat, pubKey);
131
+ for (const [agentId, [profile, _ts]] of perspective.profiles.entries()) {
132
+ await this.createProfile(profile, agentId);
58
133
  }
59
134
  return;
60
135
  }
61
- for (const [pubKey, profileMat] of Object.entries(profiles)) {
62
- this.storeProfile(pubKey, profileMat, Date.now());
136
+ /** */
137
+ for (const [actionId, [profile, ts]] of perspective.profiles.entries()) {
138
+ this.storeProfile(actionId, profile, ts);
63
139
  }
64
- }
65
- /** -- Methods -- */
66
- /* */
67
- findProfiles(names) {
68
- let res = [];
69
- for (const name of names) {
70
- if (this._reversed[name]) {
71
- res.push(this._reversed[name]);
72
- }
140
+ for (const [agentId, actionId] of perspective.profileByAgent.entries()) {
141
+ this.storeAgentProfile(agentId, actionId);
73
142
  }
74
- return res;
75
143
  }
144
+ /** -- Store -- */
76
145
  /** */
77
- async probeAllProfiles() {
78
- let allAgents;
79
- /** Attempt a retry on fail as this can create an entry (path anchor) and generate a 'head has moved' error */
80
- try {
81
- allAgents = await this.zomeProxy.getAgentsWithProfile();
146
+ storeProfile(profileAh, profile, ts) {
147
+ this._perspective.profiles.set(profileAh, [profile, ts]);
148
+ const agentId = this.getProfileAgent(profileAh);
149
+ if (agentId) {
150
+ this._perspective.agentByName[profile.nickname] = agentId;
82
151
  }
83
- catch (e) {
84
- allAgents = await this.zomeProxy.getAgentsWithProfile();
152
+ }
153
+ /** */
154
+ storeAgentProfile(agentId, profileAh) {
155
+ this._perspective.profileByAgent.set(agentId, profileAh);
156
+ const pair = this._perspective.profiles.get(profileAh);
157
+ if (pair) {
158
+ this._perspective.agentByName[pair[0].nickname] = agentId;
85
159
  }
86
- for (const agentPubKey of allAgents) {
87
- const maybeProfileRecord = await this.zomeProxy.getProfile(agentPubKey);
88
- if (!maybeProfileRecord) {
89
- continue;
90
- }
91
- const timestamp = maybeProfileRecord.signed_action.hashed.content.timestamp;
92
- const profile = decode(maybeProfileRecord.entry.Present.entry);
93
- this.storeProfile(encodeHashToBase64(agentPubKey), profile, timestamp);
160
+ }
161
+ /** */
162
+ unstoreAgentProfile(agentId, profileAh) {
163
+ this._perspective.profileByAgent.delete(agentId);
164
+ const pair = this._perspective.profiles.get(profileAh);
165
+ if (pair) {
166
+ delete this._perspective.agentByName[pair[0].nickname];
94
167
  }
95
- this.notifySubscribers();
96
- return this._profiles;
97
168
  }
169
+ /** -- Methods -- */
98
170
  /** */
99
- storeProfile(pubKeyB64, profile, ts) {
100
- this._profiles[pubKeyB64] = profile;
101
- this._profileDates[pubKeyB64] = ts;
102
- this._reversed[profile.nickname] = pubKeyB64;
103
- this.notifySubscribers();
171
+ async probeAllProfiles() {
172
+ await this.zomeProxy.probeProfiles();
104
173
  }
105
174
  /** */
106
- async probeProfile(pubKeyB64) {
107
- const maybeProfileRecord = await this.zomeProxy.getProfile(decodeHashFromBase64(pubKeyB64));
108
- console.log("probeProfile() maybeProfile", maybeProfileRecord);
109
- if (!maybeProfileRecord) {
175
+ async findProfile(agentId) {
176
+ const maybeProfilePair = await this.zomeProxy.findProfile(agentId.hash);
177
+ console.log("probeProfile() maybeProfilePair", maybeProfilePair);
178
+ if (!maybeProfilePair) {
110
179
  return;
111
180
  }
112
- // const profileEntry: any = decode((maybeProfile.entry as any).Present.entry);
113
- // console.log("probeProfile() profileEntry", profileEntry);
114
- //const profile: ProfileMat = decode(profileEntry.record.entry.Present.entry) as ProfileMat;
115
- const timestamp = maybeProfileRecord.signed_action.hashed.content.timestamp;
116
- const profile = decode(maybeProfileRecord.entry.Present.entry);
117
- console.log("probeProfile() profile", profile);
118
- this.storeProfile(pubKeyB64, profile, timestamp);
119
- return profile;
181
+ return maybeProfilePair[1];
120
182
  }
121
183
  /** */
122
184
  async createMyProfile(profile) {
123
- const record = await this.zomeProxy.createProfile([profile, decodeHashFromBase64(this.cell.agentPubKey)]);
124
- const timestamp = record.signed_action.hashed.content.timestamp;
125
- this.storeProfile(this.cell.agentPubKey, profile, timestamp);
185
+ const _ah = await this.zomeProxy.createProfile([profile, this.cell.agentId.hash]);
126
186
  }
127
187
  /** */
128
188
  async updateMyProfile(profile) {
129
- const record = await this.zomeProxy.updateProfile([profile, decodeHashFromBase64(this.cell.agentPubKey)]);
130
- const timestamp = record.signed_action.hashed.content.timestamp;
131
- this.storeProfile(this.cell.agentPubKey, profile, timestamp);
189
+ const _ah = await this.zomeProxy.updateProfile([profile, this.cell.agentId.hash]);
132
190
  }
133
191
  /** */
134
- async createProfile(profile, agent) {
135
- const record = await this.zomeProxy.createProfile([profile, decodeHashFromBase64(agent)]);
136
- const timestamp = record.signed_action.hashed.content.timestamp;
137
- this.storeProfile(agent, profile, timestamp);
192
+ async createProfile(profile, agentId) {
193
+ const _ah = await this.zomeProxy.createProfile([profile, agentId.hash]);
138
194
  }
139
195
  /** */
140
- async updateProfile(profile, agent) {
141
- const record = await this.zomeProxy.updateProfile([profile, decodeHashFromBase64(agent)]);
142
- const timestamp = record.signed_action.hashed.content.timestamp;
143
- this.storeProfile(agent, profile, timestamp);
196
+ async updateProfile(profile, agentId) {
197
+ const _ah = await this.zomeProxy.updateProfile([profile, agentId.hash]);
144
198
  }
145
199
  }
146
200
  ProfilesAltZvm.ZOME_PROXY = ProfilesAltProxy;
@@ -1 +1 @@
1
- {"version":3,"file":"profilesAlt.zvm.js","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAiB,oBAAoB,EAAE,kBAAkB,EAAY,MAAM,mBAAmB,CAAC;AACtG,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAgB9D;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,aAAa;IAAjD;;QAmCU,cAAS,GAAuC,EAAE,CAAC;QACnD,kBAAa,GAAsC,EAAE,CAAC;QAC9D,mEAAmE;QAC3D,cAAS,GAAmC,EAAE,CAAC;IAuIzD,CAAC;IA1KC,IAAI,SAAS,KAAsB,OAAO,IAAI,CAAC,UAA8B,CAAC,CAAA,CAAC;IAG/E,KAAK;IACK,UAAU;QAClB,OAAO;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,2BAA2B;QAC/B,MAAM,IAAI,CAAC,gBAAgB,EAAE,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AC1F,MAAM,SAAS,GAAG,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;QAChE,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAC/C,CAAC;;AAzKe,yBAAU,GAAG,gBAAgB,AAAnB,CAAoB","sourcesContent":["import {ZomeViewModel} from \"@ddd-qc/lit-happ\";\nimport {Profile as ProfileMat} from \"./bindings/profiles.types\";\nimport {AgentPubKeyB64, decodeHashFromBase64, encodeHashToBase64, Timestamp} from \"@holochain/client\";\nimport {decode} from \"@msgpack/msgpack\";\nimport {ProfilesAltProxy} from \"./bindings/profilesAlt.proxy\";\n\n\n/** */\nexport interface ProfilesAltPerspective {\n /* AgentPubKeyB64 -> Profile */\n profiles: Record<AgentPubKeyB64, ProfileMat>,\n profileDates: Record<AgentPubKeyB64, Timestamp>,\n ///* AgentPubKeyB64 -> Profile hash */\n //profile_ahs: Record<AgentPubKeyB64, ActionHashB64>,\n\n /** Nickname -> AgentPubKeyB64 */\n reversed: Record<string, AgentPubKeyB64>,\n}\n\n\n/**\n *\n */\nexport class ProfilesAltZvm extends ZomeViewModel {\n\n static readonly ZOME_PROXY = ProfilesAltProxy;\n get zomeProxy(): ProfilesAltProxy {return this._zomeProxy as ProfilesAltProxy;}\n\n\n /* */\n protected hasChanged(): boolean {\n // TODO\n return true;\n }\n\n\n /** */\n async initializePerspectiveOnline(): Promise<void> {\n await this.probeAllProfiles();\n }\n\n /** */\n probeAllInner() {\n this.probeAllProfiles();\n }\n\n /** -- Perspective -- */\n\n /* */\n get perspective(): ProfilesAltPerspective {\n return {\n profiles: this._profiles,\n profileDates: this._profileDates,\n reversed: this._reversed,\n //profile_ahs: this._profile_ahs,\n };\n }\n\n private _profiles: Record<AgentPubKeyB64, ProfileMat> = {};\n private _profileDates: Record<AgentPubKeyB64, Timestamp> = {};\n //private _profile_ahs: Record<AgentPubKeyB64, ActionHashB64> = {};\n private _reversed: Record<string, AgentPubKeyB64> = {};\n\n\n getMyProfile(): ProfileMat | undefined { return this._profiles[this.cell.agentPubKey] }\n\n getProfile(agent: AgentPubKeyB64): ProfileMat | undefined {return this._profiles[agent]}\n\n getProfileDate(agent: AgentPubKeyB64): Timestamp | undefined {return this._profileDates[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 //return JSON.stringify(this.perspective, null, 2);\n }\n\n\n /** */\n async importPerspective(json: string, canPublish: boolean) {\n const profiles = JSON.parse(json) as ProfilesAltPerspective;\n if (canPublish) {\n for (const [pubKey, profileMat] of Object.entries(profiles)) {\n await this.createProfile(profileMat, pubKey);\n }\n return;\n }\n\n for (const [pubKey, profileMat] of Object.entries(profiles)) {\n this.storeProfile(pubKey, profileMat, Date.now());\n }\n }\n\n\n /** -- Methods -- */\n\n /* */\n findProfiles(names: string[]): AgentPubKeyB64[] {\n let res = []\n for (const name of names) {\n if (this._reversed[name]) {\n res.push(this._reversed[name])\n }\n }\n return res;\n }\n\n\n /** */\n async probeAllProfiles(): Promise<Record<AgentPubKeyB64, ProfileMat>> {\n let allAgents;\n /** Attempt a retry on fail as this can create an entry (path anchor) and generate a 'head has moved' error */\n try {\n allAgents = await this.zomeProxy.getAgentsWithProfile();\n } catch(e) {\n allAgents = await this.zomeProxy.getAgentsWithProfile();\n }\n for (const agentPubKey of allAgents) {\n const maybeProfileRecord = await this.zomeProxy.getProfile(agentPubKey);\n if (!maybeProfileRecord) {\n continue;\n }\n const timestamp = maybeProfileRecord.signed_action.hashed.content.timestamp;\n const profile: ProfileMat = decode((maybeProfileRecord.entry as any).Present.entry) as ProfileMat;\n this.storeProfile(encodeHashToBase64(agentPubKey), profile, timestamp);\n }\n this.notifySubscribers();\n return this._profiles;\n }\n\n\n /** */\n storeProfile(pubKeyB64: AgentPubKeyB64, profile: ProfileMat, ts: Timestamp) {\n this._profiles[pubKeyB64] = profile;\n this._profileDates[pubKeyB64] = ts;\n this._reversed[profile.nickname] = pubKeyB64;\n this.notifySubscribers();\n }\n\n\n /** */\n async probeProfile(pubKeyB64: AgentPubKeyB64): Promise<ProfileMat | undefined> {\n const maybeProfileRecord = await this.zomeProxy.getProfile(decodeHashFromBase64(pubKeyB64));\n console.log(\"probeProfile() maybeProfile\", maybeProfileRecord);\n if (!maybeProfileRecord) {\n return;\n }\n // const profileEntry: any = decode((maybeProfile.entry as any).Present.entry);\n // console.log(\"probeProfile() profileEntry\", profileEntry);\n //const profile: ProfileMat = decode(profileEntry.record.entry.Present.entry) as ProfileMat;\n const timestamp = maybeProfileRecord.signed_action.hashed.content.timestamp;\n const profile: ProfileMat = decode((maybeProfileRecord.entry as any).Present.entry) as ProfileMat;\n console.log(\"probeProfile() profile\", profile);\n this.storeProfile(pubKeyB64, profile, timestamp);\n return profile;\n }\n\n\n /** */\n async createMyProfile(profile: ProfileMat): Promise<void> {\n const record = await this.zomeProxy.createProfile([profile, decodeHashFromBase64(this.cell.agentPubKey)]);\n const timestamp = record.signed_action.hashed.content.timestamp;\n this.storeProfile(this.cell.agentPubKey, profile, timestamp);\n }\n\n\n /** */\n async updateMyProfile(profile: ProfileMat): Promise<void> {\n const record = await this.zomeProxy.updateProfile([profile, decodeHashFromBase64(this.cell.agentPubKey)]);\n const timestamp = record.signed_action.hashed.content.timestamp;\n this.storeProfile(this.cell.agentPubKey, profile, timestamp);\n }\n\n\n /** */\n async createProfile(profile: ProfileMat, agent: AgentPubKeyB64): Promise<void> {\n const record = await this.zomeProxy.createProfile([profile, decodeHashFromBase64(agent)]);\n const timestamp = record.signed_action.hashed.content.timestamp;\n this.storeProfile(agent, profile, timestamp);\n }\n\n\n /** */\n async updateProfile(profile: ProfileMat, agent: AgentPubKeyB64): Promise<void> {\n const record = await this.zomeProxy.updateProfile([profile, decodeHashFromBase64(agent)]);\n const timestamp = record.signed_action.hashed.content.timestamp;\n this.storeProfile(agent, profile, timestamp);\n }\n\n}\n"]}
1
+ {"version":3,"file":"profilesAlt.zvm.js","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAAE,WAAW,EACrB,OAAO,EACP,UAAU,EACV,OAAO,EACP,iBAAiB,EACjB,cAAc,EACd,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,SAAS,EAAU,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAEL,cAAc,EACH,eAAe,GAC3B,MAAM,8BAA8B,CAAC;AAmBtC,SAAS,4BAA4B;IACnC,OAAO;QACL,QAAQ,EAAE,IAAI,WAAW,EAAE;QAC3B,cAAc,EAAE,IAAI,UAAU,EAAE;QAChC,WAAW,EAAE,EAAE;KAChB,CAAA;AACH,CAAC;AAGD;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,wBAAwB;IAA5D;;QA8BU,iBAAY,GAA2B,4BAA4B,EAAE,CAAC;IAoMhF,CAAC;IA/NC,IAAI,SAAS,KAAsB,OAAO,IAAI,CAAC,UAA8B,CAAC,CAAA,CAAC;IAG/E,KAAK;IACK,UAAU;QAClB,OAAO;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,2BAA2B;QAC/B,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAChC,CAAC;IAED,MAAM;IACN,aAAa;QACX,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAED,wBAAwB;IAExB,KAAK;IACL,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAA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AC,aAAa,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACpF,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,eAAe,CAAC,OAAgB;QACpC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACpF,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,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1E,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,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1E,CAAC;;AA9Ne,yBAAU,GAAG,gBAAgB,AAAnB,CAAoB","sourcesContent":["import {\n ActionId, ActionIdMap,\n AgentId,\n AgentIdMap,\n EntryId,\n getVariantByIndex,\n intoLinkableId,\n ZomeViewModelWithSignals\n} from \"@ddd-qc/lit-happ\";\nimport {LinkTypes, Profile} from \"./bindings/profiles.types\";\nimport {Timestamp} from \"@holochain/client\";\nimport {decode} from \"@msgpack/msgpack\";\nimport {ProfilesAltProxy} from \"./bindings/profilesAlt.proxy\";\nimport {\n EntryPulse,\n EntryTypesType,\n LinkPulse, StateChangeType,\n} from \"./bindings/profilesAlt.types\";\n\n\n/** */\nexport interface ProfilesAltPerspectiveCore {\n /* ActionId -> Profile */\n profiles: ActionIdMap<[Profile, Timestamp]>,\n /* AgentId -> ActionId */\n profileByAgent: AgentIdMap<ActionId>,\n}\n\nexport interface ProfilesAltPerspectiveLive {\n /** Nickname -> AgentId */\n agentByName: Record<string, AgentId>,\n}\n\nexport type ProfilesAltPerspective = ProfilesAltPerspectiveCore & ProfilesAltPerspectiveLive;\n\n\nfunction createProfilesAltPerspective(): ProfilesAltPerspective {\n return {\n profiles: new ActionIdMap(),\n profileByAgent: new AgentIdMap(),\n agentByName: {},\n }\n}\n\n\n/**\n *\n */\nexport class ProfilesAltZvm extends ZomeViewModelWithSignals {\n\n static readonly ZOME_PROXY = ProfilesAltProxy;\n get zomeProxy(): ProfilesAltProxy {return this._zomeProxy as ProfilesAltProxy;}\n\n\n /* */\n protected hasChanged(): boolean {\n // TODO\n return true;\n }\n\n\n /** */\n async initializePerspectiveOnline(): Promise<void> {\n await this.probeAllProfiles();\n }\n\n /** */\n probeAllInner() {\n this.probeAllProfiles();\n }\n\n /** -- Perspective -- */\n\n /* */\n get perspective(): ProfilesAltPerspective {\n return this._perspective;\n }\n\n private _perspective: ProfilesAltPerspective = createProfilesAltPerspective();\n\n getMyProfile(): Profile | undefined {\n const pair = this._perspective.profiles.get(this.cell.agentId)\n if (!pair) {\n return undefined;\n }\n return pair[0];\n }\n\n getProfileAgent(profileId: ActionId): AgentId | undefined {\n for (const [agentId, profId] of this._perspective.profileByAgent.entries()) {\n if (profileId.b64 == profId.b64) {\n return agentId;\n }\n }\n return undefined;\n }\n\n getProfile(agent: AgentId): Profile | undefined {\n const profileAh = this._perspective.profileByAgent.get(agent);\n if (!profileAh) {\n return undefined;\n }\n const pair = this._perspective.profiles.get(profileAh);\n return pair[0];\n\n }\n\n getProfileTs(agent: AgentId): Timestamp | undefined {\n const profileAh = this._perspective.profileByAgent.get(agent);\n if (!profileAh) {\n return undefined;\n }\n const pair = this._perspective.profiles.get(profileAh);\n return pair[1];\n }\n\n getAgents(): AgentId[] { return Array.from(this._perspective.profileByAgent.keys())}\n\n getNames(): string[] { return Object.keys(this._perspective.agentByName)}\n\n\n\n /** */\n async handleLinkPulse(pulse: LinkPulse, from: AgentId): Promise<void> {\n const link = pulse.link;\n const linkAh = new ActionId(link.create_link_hash);\n const author = new AgentId(link.author);\n const base = intoLinkableId((link as any).base);\n const target = intoLinkableId(link.target);\n const state = Object.keys(pulse.state)[0];\n const isNew = (pulse.state as any)[state];\n /** */\n switch (getVariantByIndex(LinkTypes, link.link_type)) {\n case LinkTypes.PrefixPath:\n case LinkTypes.PathToAgent:\n break;\n case LinkTypes.AgentToProfile:\n if (state == StateChangeType.Delete) {\n this.unstoreAgentProfile(base, target)\n } else {\n this.storeAgentProfile(base, target)\n }\n if (isNew && from.b64 == this.cell.agentId.b64) {\n await this.broadcastTip({Link: pulse});\n }\n break;\n }\n }\n\n\n /** */\n async handleEntryPulse(pulse: EntryPulse, from: AgentId) {\n const entryType = getVariantByIndex(EntryTypesType, pulse.def.entry_index);\n const author = new AgentId(pulse.author);\n const ah = new ActionId(pulse.ah);\n const eh = new EntryId(pulse.eh);\n const state = Object.keys(pulse.state)[0];\n const isNew = (pulse.state as any)[state];\n switch (entryType) {\n case EntryTypesType.Profile:\n const profile = decode(pulse.bytes) as Profile;\n if (state != StateChangeType.Delete) {\n this.storeProfile(ah, profile, pulse.ts);\n }\n if (isNew && from.b64 == this.cell.agentId.b64) {\n await this.broadcastTip({Entry: pulse});\n }\n break;\n }\n }\n\n\n /** -- perspective -- */\n\n /** Dump perspective as JSON */\n exportPerspective(): string {\n //console.log(\"exportPerspective()\", perspMat);\n const core = this._perspective as ProfilesAltPerspectiveCore; // FIXME: check if this actually works as expected\n return JSON.stringify(core, null, 2);\n }\n\n\n /** */\n async importPerspective(json: string, canPublish: boolean) {\n const perspective = JSON.parse(json) as ProfilesAltPerspectiveCore;\n if (canPublish) {\n for (const [agentId, [profile, _ts]] of perspective.profiles.entries()) {\n await this.createProfile(profile, agentId);\n }\n return;\n }\n /** */\n for (const [actionId, [profile, ts]] of perspective.profiles.entries()) {\n this.storeProfile(actionId, profile, ts);\n }\n for (const [agentId, actionId] of perspective.profileByAgent.entries()) {\n this.storeAgentProfile(agentId, actionId);\n }\n }\n\n\n /** -- Store -- */\n\n\n /** */\n storeProfile(profileAh: ActionId, profile: Profile, ts: Timestamp) {\n this._perspective.profiles.set(profileAh, [profile, ts]);\n const agentId = this.getProfileAgent(profileAh);\n if (agentId) {\n this._perspective.agentByName[profile.nickname] = agentId;\n }\n }\n\n /** */\n storeAgentProfile(agentId: AgentId, profileAh: ActionId) {\n this._perspective.profileByAgent.set(agentId, profileAh);\n const pair = this._perspective.profiles.get(profileAh);\n if (pair) {\n this._perspective.agentByName[pair[0].nickname] = agentId;\n }\n }\n\n /** */\n unstoreAgentProfile(agentId: AgentId, profileAh: ActionId) {\n this._perspective.profileByAgent.delete(agentId);\n const pair = this._perspective.profiles.get(profileAh);\n if (pair) {\n delete this._perspective.agentByName[pair[0].nickname];\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(agentId.hash);\n console.log(\"probeProfile() maybeProfilePair\", 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, this.cell.agentId.hash]);\n }\n\n\n /** */\n async updateMyProfile(profile: Profile): Promise<void> {\n const _ah = await this.zomeProxy.updateProfile([profile, this.cell.agentId.hash]);\n }\n\n\n /** */\n async createProfile(profile: Profile, agentId: AgentId): Promise<void> {\n const _ah = await this.zomeProxy.createProfile([profile, agentId.hash]);\n }\n\n\n /** */\n async updateProfile(profile: Profile, agentId: AgentId): Promise<void> {\n const _ah = await this.zomeProxy.updateProfile([profile, agentId.hash]);\n }\n\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-qc/profiles-dvm",
3
- "version": "0.24.1",
3
+ "version": "0.25.0",
4
4
  "description": "DnaViewModel implementation for the Profiles zome.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",