@ddd-qc/profiles-dvm 0.24.1 → 0.26.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.integrity.d.ts +8 -0
- package/dist/bindings/profiles.integrity.js +12 -0
- package/dist/bindings/profiles.integrity.js.map +1 -0
- package/dist/bindings/profiles.proxy.d.ts +5 -0
- package/dist/bindings/profiles.proxy.js +3 -0
- package/dist/bindings/profiles.proxy.js.map +1 -1
- package/dist/bindings/profiles.types.d.ts +2 -12
- package/dist/bindings/profiles.types.js +0 -6
- package/dist/bindings/profiles.types.js.map +1 -1
- package/dist/bindings/profilesAlt.fn.js +3 -2
- package/dist/bindings/profilesAlt.fn.js.map +1 -1
- package/dist/bindings/profilesAlt.integrity.d.ts +8 -0
- package/dist/bindings/profilesAlt.integrity.js +12 -0
- package/dist/bindings/profilesAlt.integrity.js.map +1 -0
- package/dist/bindings/profilesAlt.proxy.d.ts +10 -8
- package/dist/bindings/profilesAlt.proxy.js +12 -6
- package/dist/bindings/profilesAlt.proxy.js.map +1 -1
- package/dist/bindings/profilesAlt.types.d.ts +112 -41
- package/dist/bindings/profilesAlt.types.js +24 -6
- package/dist/bindings/profilesAlt.types.js.map +1 -1
- package/dist/profiles.zvm.d.ts +9 -9
- package/dist/profiles.zvm.js +4 -4
- package/dist/profiles.zvm.js.map +1 -1
- package/dist/profilesAlt.zvm.d.ts +37 -25
- package/dist/profilesAlt.zvm.js +128 -85
- package/dist/profilesAlt.zvm.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* This file is generated by zits. Do not edit manually */
|
|
2
|
+
export var ProfilesUnitEnum;
|
|
3
|
+
(function (ProfilesUnitEnum) {
|
|
4
|
+
ProfilesUnitEnum["Profile"] = "Profile";
|
|
5
|
+
})(ProfilesUnitEnum || (ProfilesUnitEnum = {}));
|
|
6
|
+
export var ProfilesLinkType;
|
|
7
|
+
(function (ProfilesLinkType) {
|
|
8
|
+
ProfilesLinkType["PrefixPath"] = "PrefixPath";
|
|
9
|
+
ProfilesLinkType["PathToAgent"] = "PathToAgent";
|
|
10
|
+
ProfilesLinkType["AgentToProfile"] = "AgentToProfile";
|
|
11
|
+
})(ProfilesLinkType || (ProfilesLinkType = {}));
|
|
12
|
+
//# sourceMappingURL=profiles.integrity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.integrity.js","sourceRoot":"","sources":["../../src/bindings/profiles.integrity.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,MAAM,CAAN,IAAY,gBAEX;AAFD,WAAY,gBAAgB;IAC3B,uCAAmB,CAAA;AACpB,CAAC,EAFW,gBAAgB,KAAhB,gBAAgB,QAE3B;AAED,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC3B,6CAAyB,CAAA;IACzB,+CAA2B,CAAA;IAC3B,qDAAiC,CAAA;AAClC,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nexport enum ProfilesUnitEnum {\n\tProfile = 'Profile',\n}\n\nexport enum ProfilesLinkType {\n\tPrefixPath = 'PrefixPath',\n\tPathToAgent = 'PathToAgent',\n\tAgentToProfile = 'AgentToProfile',\n}\n"]}
|
|
@@ -2,13 +2,18 @@ import { Profile } from './profiles.types';
|
|
|
2
2
|
import { AgentPubKey,
|
|
3
3
|
/** hdk/record.ts */
|
|
4
4
|
Record as HcRecord } from '@holochain/client';
|
|
5
|
+
/** User defined external dependencies */
|
|
6
|
+
import { ProfilesLinkType as LinkTypes } from "./profiles.integrity";
|
|
5
7
|
import { ZomeProxy } from '@ddd-qc/lit-happ';
|
|
8
|
+
import { ProfilesUnitEnum } from './profiles.integrity';
|
|
6
9
|
/**
|
|
7
10
|
*
|
|
8
11
|
*/
|
|
9
12
|
export declare class ProfilesProxy extends ZomeProxy {
|
|
10
13
|
static readonly DEFAULT_ZOME_NAME = "profiles";
|
|
11
14
|
static readonly FN_NAMES: string[];
|
|
15
|
+
static readonly ENTRY_TYPES: ProfilesUnitEnum.Profile[];
|
|
16
|
+
static readonly LINK_TYPES: LinkTypes[];
|
|
12
17
|
createProfile(profile: Profile): Promise<HcRecord>;
|
|
13
18
|
updateProfile(profile: Profile): Promise<HcRecord>;
|
|
14
19
|
searchAgents(nicknameFilter: string): Promise<AgentPubKey[]>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* This file is generated by zits. Do not edit manually */
|
|
2
2
|
import { ZomeProxy } from '@ddd-qc/lit-happ';
|
|
3
3
|
import { profilesFunctionNames } from './profiles.fn';
|
|
4
|
+
import { ProfilesUnitEnum, ProfilesLinkType } from './profiles.integrity';
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
6
7
|
*/
|
|
@@ -23,4 +24,6 @@ export class ProfilesProxy extends ZomeProxy {
|
|
|
23
24
|
}
|
|
24
25
|
ProfilesProxy.DEFAULT_ZOME_NAME = "profiles";
|
|
25
26
|
ProfilesProxy.FN_NAMES = profilesFunctionNames;
|
|
27
|
+
ProfilesProxy.ENTRY_TYPES = Object.values(ProfilesUnitEnum);
|
|
28
|
+
ProfilesProxy.LINK_TYPES = Object.values(ProfilesLinkType);
|
|
26
29
|
//# sourceMappingURL=profiles.proxy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.proxy.js","sourceRoot":"","sources":["../../src/bindings/profiles.proxy.ts"],"names":[],"mappings":"AAAA,0DAA0D;
|
|
1
|
+
{"version":3,"file":"profiles.proxy.js","sourceRoot":"","sources":["../../src/bindings/profiles.proxy.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAuJ1D,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,EAAC,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAExE;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAM1C,KAAK,CAAC,aAAa,CAAC,OAAgB;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAgB;QAClC,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,cAAsB;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,WAAwB;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;;AAvBe,+BAAiB,GAAG,UAAU,CAAC;AAC/B,sBAAQ,GAAG,qBAAqB,CAAC;AACjC,yBAAW,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC9C,wBAAU,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {EntryTypes, Signal, Profile, } from './profiles.types';\nimport {\nWebsocketConnectionOptions,\n/** types.ts */\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/** User defined external dependencies */\nimport {ProfilesLinkType as LinkTypes} from \"./profiles.integrity\"\n\nimport {ZomeProxy} from '@ddd-qc/lit-happ';\nimport {profilesFunctionNames} from './profiles.fn';\nimport {ProfilesUnitEnum, ProfilesLinkType} from './profiles.integrity';\n\n/**\n *\n */\nexport class ProfilesProxy extends ZomeProxy {\n static readonly DEFAULT_ZOME_NAME = \"profiles\";\n static readonly FN_NAMES = profilesFunctionNames;\n static readonly ENTRY_TYPES = Object.values(ProfilesUnitEnum);\n static readonly LINK_TYPES = Object.values(ProfilesLinkType);\n \n async createProfile(profile: Profile): Promise<HcRecord> {\n return this.call('create_profile', profile);\n }\n\n async updateProfile(profile: Profile): Promise<HcRecord> {\n return this.call('update_profile', profile);\n }\n\n async searchAgents(nicknameFilter: string): Promise<AgentPubKey[]> {\n return this.call('search_agents', nicknameFilter);\n }\n\n async getAgentProfile(agentPubKey: AgentPubKey): Promise<HcRecord | null> {\n return this.call('get_agent_profile', agentPubKey);\n }\n\n async getAgentsWithProfile(): Promise<AgentPubKey[]> {\n return this.call('get_agents_with_profile', null);\n }\n}\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
/** hdk/action.ts */
|
|
3
3
|
SignedActionHashed } from '@holochain/client';
|
|
4
|
+
/** User defined external dependencies */
|
|
5
|
+
import { ProfilesLinkType as LinkTypes } from "./profiles.integrity";
|
|
4
6
|
export type SignalVariantLinkCreated = {
|
|
5
7
|
type: "LinkCreated";
|
|
6
8
|
action: SignedActionHashed;
|
|
@@ -48,15 +50,3 @@ export type EntryTypes = {
|
|
|
48
50
|
};
|
|
49
51
|
content: Profile;
|
|
50
52
|
};
|
|
51
|
-
export type LinkTypes = {
|
|
52
|
-
PrefixPath: null;
|
|
53
|
-
} | {
|
|
54
|
-
PathToAgent: null;
|
|
55
|
-
} | {
|
|
56
|
-
AgentToProfile: null;
|
|
57
|
-
};
|
|
58
|
-
export declare enum LinkTypesType {
|
|
59
|
-
PrefixPath = "PrefixPath",
|
|
60
|
-
PathToAgent = "PathToAgent",
|
|
61
|
-
AgentToProfile = "AgentToProfile"
|
|
62
|
-
}
|
|
@@ -3,10 +3,4 @@ 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 = {}));
|
|
12
6
|
//# 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;
|
|
1
|
+
{"version":3,"file":"profiles.types.js","sourceRoot":"","sources":["../../src/bindings/profiles.types.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAmM1D,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACzB,qCAAmB,CAAA;AACpB,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {\nWebsocketConnectionOptions,\n/** types.ts */\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/** User defined external dependencies */\nimport {ProfilesLinkType as LinkTypes} from \"./profiles.integrity\"\n\nexport type SignalVariantLinkCreated = {\n type: \"LinkCreated\"\n action: SignedActionHashed\n link_type: LinkTypes\n}\nexport type SignalVariantLinkDeleted = {\n type: \"LinkDeleted\"\n action: SignedActionHashed\n create_link_action: SignedActionHashed\n link_type: LinkTypes\n}\nexport type SignalVariantEntryCreated = {\n type: \"EntryCreated\"\n action: SignedActionHashed\n app_entry: EntryTypes\n}\nexport type SignalVariantEntryUpdated = {\n type: \"EntryUpdated\"\n action: SignedActionHashed\n app_entry: EntryTypes\n original_app_entry: EntryTypes\n}\nexport type SignalVariantEntryDeleted = {\n type: \"EntryDeleted\"\n action: SignedActionHashed\n original_app_entry: EntryTypes\n}\nexport type Signal =\n | SignalVariantLinkCreated\n | SignalVariantLinkDeleted\n | SignalVariantEntryCreated\n | SignalVariantEntryUpdated\n | SignalVariantEntryDeleted;\n\n/**\n * Profile entry definition.\n * \n * The profile must include at a minimum the nickname of the agent\n * in order to be able to search for agents by nickname.\n */\nexport interface Profile {\n nickname: string\n fields: Record<string, string>\n}\n\nexport enum EntryTypesType {\n\tProfile = 'Profile',\n}\nexport type EntryTypes = \n | {type: {Profile: null}, content: Profile}\n\n"]}
|
|
@@ -7,8 +7,9 @@ export const profilesAltFunctionNames = [
|
|
|
7
7
|
"create_profile",
|
|
8
8
|
"update_profile",
|
|
9
9
|
"search_agents",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
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;
|
|
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;IACd,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\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"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* This file is generated by zits. Do not edit manually */
|
|
2
|
+
export var ProfilesAltUnitEnum;
|
|
3
|
+
(function (ProfilesAltUnitEnum) {
|
|
4
|
+
ProfilesAltUnitEnum["Profile"] = "Profile";
|
|
5
|
+
})(ProfilesAltUnitEnum || (ProfilesAltUnitEnum = {}));
|
|
6
|
+
export var ProfilesAltLinkType;
|
|
7
|
+
(function (ProfilesAltLinkType) {
|
|
8
|
+
ProfilesAltLinkType["PrefixPath"] = "PrefixPath";
|
|
9
|
+
ProfilesAltLinkType["PathToAgent"] = "PathToAgent";
|
|
10
|
+
ProfilesAltLinkType["AgentToProfile"] = "AgentToProfile";
|
|
11
|
+
})(ProfilesAltLinkType || (ProfilesAltLinkType = {}));
|
|
12
|
+
//# sourceMappingURL=profilesAlt.integrity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profilesAlt.integrity.js","sourceRoot":"","sources":["../../src/bindings/profilesAlt.integrity.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,MAAM,CAAN,IAAY,mBAEX;AAFD,WAAY,mBAAmB;IAC9B,0CAAmB,CAAA;AACpB,CAAC,EAFW,mBAAmB,KAAnB,mBAAmB,QAE9B;AAED,MAAM,CAAN,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC9B,gDAAyB,CAAA;IACzB,kDAA2B,CAAA;IAC3B,wDAAiC,CAAA;AAClC,CAAC,EAJW,mBAAmB,KAAnB,mBAAmB,QAI9B","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nexport enum ProfilesAltUnitEnum {\n\tProfile = 'Profile',\n}\n\nexport enum ProfilesAltLinkType {\n\tPrefixPath = 'PrefixPath',\n\tPathToAgent = 'PathToAgent',\n\tAgentToProfile = 'AgentToProfile',\n}\n"]}
|
|
@@ -1,17 +1,19 @@
|
|
|
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';
|
|
4
|
+
import { ProfilesAltUnitEnum, ProfilesAltLinkType } from './profilesAlt.integrity';
|
|
6
5
|
/**
|
|
7
6
|
*
|
|
8
7
|
*/
|
|
9
8
|
export declare class ProfilesAltProxy extends ZomeProxy {
|
|
10
9
|
static readonly DEFAULT_ZOME_NAME = "profiles";
|
|
11
10
|
static readonly FN_NAMES: string[];
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
static readonly ENTRY_TYPES: ProfilesAltUnitEnum.Profile[];
|
|
12
|
+
static readonly LINK_TYPES: ProfilesAltLinkType[];
|
|
13
|
+
createProfile(pair: [Profile, AgentPubKey]): Promise<ActionHash>;
|
|
14
|
+
updateProfile(pair: [Profile, AgentPubKey]): Promise<ActionHash>;
|
|
14
15
|
searchAgents(nicknameFilter: string): Promise<AgentPubKey[]>;
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
findProfile(agentPubKey: AgentPubKey): Promise<[ActionHash, Profile] | null>;
|
|
17
|
+
probeProfiles(): Promise<void>;
|
|
18
|
+
castTip(input: CastTipInput): Promise<void>;
|
|
17
19
|
}
|
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
/* This file is generated by zits. Do not edit manually */
|
|
2
2
|
import { ZomeProxy } from '@ddd-qc/lit-happ';
|
|
3
3
|
import { profilesAltFunctionNames } from './profilesAlt.fn';
|
|
4
|
+
import { ProfilesAltUnitEnum, ProfilesAltLinkType } from './profilesAlt.integrity';
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
6
7
|
*/
|
|
7
8
|
export class ProfilesAltProxy extends ZomeProxy {
|
|
8
9
|
async createProfile(pair) {
|
|
9
|
-
return this.
|
|
10
|
+
return this.callBlocking('create_profile', pair);
|
|
10
11
|
}
|
|
11
12
|
async updateProfile(pair) {
|
|
12
|
-
return this.
|
|
13
|
+
return this.callBlocking('update_profile', pair);
|
|
13
14
|
}
|
|
14
15
|
async searchAgents(nicknameFilter) {
|
|
15
16
|
return this.call('search_agents', nicknameFilter);
|
|
16
17
|
}
|
|
17
|
-
async
|
|
18
|
-
return this.call('
|
|
18
|
+
async findProfile(agentPubKey) {
|
|
19
|
+
return this.call('find_profile', agentPubKey);
|
|
19
20
|
}
|
|
20
|
-
async
|
|
21
|
-
return this.
|
|
21
|
+
async probeProfiles() {
|
|
22
|
+
return this.callBlocking('probe_profiles', null);
|
|
23
|
+
}
|
|
24
|
+
async castTip(input) {
|
|
25
|
+
return this.call('cast_tip', input);
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
ProfilesAltProxy.DEFAULT_ZOME_NAME = "profiles";
|
|
25
29
|
ProfilesAltProxy.FN_NAMES = profilesAltFunctionNames;
|
|
30
|
+
ProfilesAltProxy.ENTRY_TYPES = Object.values(ProfilesAltUnitEnum);
|
|
31
|
+
ProfilesAltProxy.LINK_TYPES = Object.values(ProfilesAltLinkType);
|
|
26
32
|
//# sourceMappingURL=profilesAlt.proxy.js.map
|
|
@@ -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,OA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CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC","sourcesContent":["/* This file is generated by zits. Do not edit manually */\n\nimport {EntryTypes, 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';\nimport {ProfilesAltUnitEnum, ProfilesAltLinkType} from './profilesAlt.integrity';\n\n/**\n *\n */\nexport class ProfilesAltProxy extends ZomeProxy {\n static readonly DEFAULT_ZOME_NAME = \"profiles\";\n static readonly FN_NAMES = profilesAltFunctionNames;\n static readonly ENTRY_TYPES = Object.values(ProfilesAltUnitEnum);\n static readonly LINK_TYPES = Object.values(ProfilesAltLinkType);\n \n async createProfile(pair: [Profile, 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"]}
|
|
@@ -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,116 @@ export type EntryTypes = {
|
|
|
48
18
|
};
|
|
49
19
|
content: Profile;
|
|
50
20
|
};
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
21
|
+
export interface CastTipInput {
|
|
22
|
+
tip: TipProtocol;
|
|
23
|
+
peers: AgentPubKey[];
|
|
24
|
+
}
|
|
25
|
+
/** Bool: True if state change just happened (real-time) */
|
|
26
|
+
export declare enum StateChangeType {
|
|
27
|
+
Create = "Create",
|
|
28
|
+
Update = "Update",
|
|
29
|
+
Delete = "Delete"
|
|
30
|
+
}
|
|
31
|
+
export type StateChangeVariantCreate = {
|
|
32
|
+
Create: boolean;
|
|
33
|
+
};
|
|
34
|
+
export type StateChangeVariantUpdate = {
|
|
35
|
+
Update: boolean;
|
|
57
36
|
};
|
|
58
|
-
export
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
37
|
+
export type StateChangeVariantDelete = {
|
|
38
|
+
Delete: boolean;
|
|
39
|
+
};
|
|
40
|
+
export type StateChange = StateChangeVariantCreate | StateChangeVariantUpdate | StateChangeVariantDelete;
|
|
41
|
+
export interface LinkPulse {
|
|
42
|
+
link: Link;
|
|
43
|
+
state: StateChange;
|
|
44
|
+
}
|
|
45
|
+
export interface EntryPulse {
|
|
46
|
+
ah: ActionHash;
|
|
47
|
+
state: StateChange;
|
|
48
|
+
ts: Timestamp;
|
|
49
|
+
author: AgentPubKey;
|
|
50
|
+
eh: EntryHash;
|
|
51
|
+
def: AppEntryDef;
|
|
52
|
+
bytes: Uint8Array;
|
|
53
|
+
}
|
|
54
|
+
/** */
|
|
55
|
+
export interface ZomeSignal {
|
|
56
|
+
from: AgentPubKey;
|
|
57
|
+
pulses: ZomeSignalProtocol[];
|
|
62
58
|
}
|
|
59
|
+
/** */
|
|
60
|
+
export declare enum ZomeSignalProtocolType {
|
|
61
|
+
System = "System",
|
|
62
|
+
Entry = "Entry",
|
|
63
|
+
Link = "Link",
|
|
64
|
+
Tip = "Tip"
|
|
65
|
+
}
|
|
66
|
+
export type ZomeSignalProtocolVariantSystem = {
|
|
67
|
+
System: SystemSignalProtocol;
|
|
68
|
+
};
|
|
69
|
+
export type ZomeSignalProtocolVariantEntry = {
|
|
70
|
+
Entry: EntryPulse;
|
|
71
|
+
};
|
|
72
|
+
export type ZomeSignalProtocolVariantLink = {
|
|
73
|
+
Link: LinkPulse;
|
|
74
|
+
};
|
|
75
|
+
export type ZomeSignalProtocolVariantTip = {
|
|
76
|
+
Tip: TipProtocol;
|
|
77
|
+
};
|
|
78
|
+
export type ZomeSignalProtocol = ZomeSignalProtocolVariantSystem | ZomeSignalProtocolVariantEntry | ZomeSignalProtocolVariantLink | ZomeSignalProtocolVariantTip;
|
|
79
|
+
/** Protocol for notifying the ViewModel (UI) of system level events */
|
|
80
|
+
export type SystemSignalProtocolVariantPostCommitNewStart = {
|
|
81
|
+
type: "PostCommitNewStart";
|
|
82
|
+
app_entry_type: string;
|
|
83
|
+
};
|
|
84
|
+
export type SystemSignalProtocolVariantPostCommitNewEnd = {
|
|
85
|
+
type: "PostCommitNewEnd";
|
|
86
|
+
app_entry_type: string;
|
|
87
|
+
succeeded: boolean;
|
|
88
|
+
};
|
|
89
|
+
export type SystemSignalProtocolVariantPostCommitDeleteStart = {
|
|
90
|
+
type: "PostCommitDeleteStart";
|
|
91
|
+
app_entry_type: string;
|
|
92
|
+
};
|
|
93
|
+
export type SystemSignalProtocolVariantPostCommitDeleteEnd = {
|
|
94
|
+
type: "PostCommitDeleteEnd";
|
|
95
|
+
app_entry_type: string;
|
|
96
|
+
succeeded: boolean;
|
|
97
|
+
};
|
|
98
|
+
export type SystemSignalProtocolVariantSelfCallStart = {
|
|
99
|
+
type: "SelfCallStart";
|
|
100
|
+
zome_name: string;
|
|
101
|
+
fn_name: string;
|
|
102
|
+
};
|
|
103
|
+
export type SystemSignalProtocolVariantSelfCallEnd = {
|
|
104
|
+
type: "SelfCallEnd";
|
|
105
|
+
zome_name: string;
|
|
106
|
+
fn_name: string;
|
|
107
|
+
succeeded: boolean;
|
|
108
|
+
};
|
|
109
|
+
export type SystemSignalProtocol = SystemSignalProtocolVariantPostCommitNewStart | SystemSignalProtocolVariantPostCommitNewEnd | SystemSignalProtocolVariantPostCommitDeleteStart | SystemSignalProtocolVariantPostCommitDeleteEnd | SystemSignalProtocolVariantSelfCallStart | SystemSignalProtocolVariantSelfCallEnd;
|
|
110
|
+
/** Used by UI ONLY. That's why we use B64 here. */
|
|
111
|
+
export declare enum TipProtocolType {
|
|
112
|
+
Ping = "Ping",
|
|
113
|
+
Pong = "Pong",
|
|
114
|
+
Entry = "Entry",
|
|
115
|
+
Link = "Link",
|
|
116
|
+
App = "App"
|
|
117
|
+
}
|
|
118
|
+
export type TipProtocolVariantPing = {
|
|
119
|
+
Ping: AgentPubKey;
|
|
120
|
+
};
|
|
121
|
+
export type TipProtocolVariantPong = {
|
|
122
|
+
Pong: AgentPubKey;
|
|
123
|
+
};
|
|
124
|
+
export type TipProtocolVariantEntry = {
|
|
125
|
+
Entry: EntryPulse;
|
|
126
|
+
};
|
|
127
|
+
export type TipProtocolVariantLink = {
|
|
128
|
+
Link: LinkPulse;
|
|
129
|
+
};
|
|
130
|
+
export type TipProtocolVariantApp = {
|
|
131
|
+
App: Uint8Array;
|
|
132
|
+
};
|
|
133
|
+
export type TipProtocol = TipProtocolVariantPing | TipProtocolVariantPong | TipProtocolVariantEntry | TipProtocolVariantLink | TipProtocolVariantApp;
|
|
@@ -3,10 +3,28 @@ export var EntryTypesType;
|
|
|
3
3
|
(function (EntryTypesType) {
|
|
4
4
|
EntryTypesType["Profile"] = "Profile";
|
|
5
5
|
})(EntryTypesType || (EntryTypesType = {}));
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
/** Bool: True if state change just happened (real-time) */
|
|
7
|
+
export var StateChangeType;
|
|
8
|
+
(function (StateChangeType) {
|
|
9
|
+
StateChangeType["Create"] = "Create";
|
|
10
|
+
StateChangeType["Update"] = "Update";
|
|
11
|
+
StateChangeType["Delete"] = "Delete";
|
|
12
|
+
})(StateChangeType || (StateChangeType = {}));
|
|
13
|
+
/** */
|
|
14
|
+
export var ZomeSignalProtocolType;
|
|
15
|
+
(function (ZomeSignalProtocolType) {
|
|
16
|
+
ZomeSignalProtocolType["System"] = "System";
|
|
17
|
+
ZomeSignalProtocolType["Entry"] = "Entry";
|
|
18
|
+
ZomeSignalProtocolType["Link"] = "Link";
|
|
19
|
+
ZomeSignalProtocolType["Tip"] = "Tip";
|
|
20
|
+
})(ZomeSignalProtocolType || (ZomeSignalProtocolType = {}));
|
|
21
|
+
/** Used by UI ONLY. That's why we use B64 here. */
|
|
22
|
+
export var TipProtocolType;
|
|
23
|
+
(function (TipProtocolType) {
|
|
24
|
+
TipProtocolType["Ping"] = "Ping";
|
|
25
|
+
TipProtocolType["Pong"] = "Pong";
|
|
26
|
+
TipProtocolType["Entry"] = "Entry";
|
|
27
|
+
TipProtocolType["Link"] = "Link";
|
|
28
|
+
TipProtocolType["App"] = "App";
|
|
29
|
+
})(TipProtocolType || (TipProtocolType = {}));
|
|
12
30
|
//# 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;
|
|
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;AAUD,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 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"]}
|
package/dist/profiles.zvm.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ZomeViewModel } from "@ddd-qc/lit-happ";
|
|
2
|
-
import { Profile
|
|
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,
|
|
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():
|
|
27
|
-
getProfile(agent: AgentPubKeyB64):
|
|
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,
|
|
37
|
+
probeAllProfiles(): Promise<Record<AgentPubKeyB64, Profile>>;
|
|
38
38
|
/** */
|
|
39
|
-
storeProfile(pubKeyB64: AgentPubKeyB64, profile:
|
|
39
|
+
storeProfile(pubKeyB64: AgentPubKeyB64, profile: Profile): void;
|
|
40
40
|
/** */
|
|
41
|
-
probeProfile(pubKeyB64: AgentPubKeyB64): Promise<
|
|
41
|
+
probeProfile(pubKeyB64: AgentPubKeyB64): Promise<Profile | undefined>;
|
|
42
42
|
/** */
|
|
43
|
-
createMyProfile(profile:
|
|
43
|
+
createMyProfile(profile: Profile): Promise<void>;
|
|
44
44
|
/** */
|
|
45
|
-
updateMyProfile(profile:
|
|
45
|
+
updateMyProfile(profile: Profile): Promise<void>;
|
|
46
46
|
}
|
package/dist/profiles.zvm.js
CHANGED
|
@@ -35,7 +35,7 @@ export class ProfilesZvm extends ZomeViewModel {
|
|
|
35
35
|
//profile_ahs: this._profile_ahs,
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
getMyProfile() { return this._profiles[this.cell.
|
|
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:
|
|
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.
|
|
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.
|
|
116
|
+
this.storeProfile(this.cell.agentId.b64, profile);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
ProfilesZvm.ZOME_PROXY = ProfilesProxy;
|
package/dist/profiles.zvm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.zvm.js","sourceRoot":"","sources":["../src/profiles.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAiB,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAexC;;GAEG;AACH,MAAM,OAAO,WAAY,SA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C,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,eAAe,CAAC,OAAgB;QACpC,kBAAkB,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,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 {
|
|
2
|
-
import { Profile
|
|
3
|
-
import {
|
|
1
|
+
import { ActionId, ActionIdMap, AgentId, AgentIdMap, LinkPulseMat, 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 { EntryPulseMat } from "@ddd-qc/lit-happ/dist/ZomeViewModelWithSignals";
|
|
5
6
|
/** */
|
|
6
|
-
export interface
|
|
7
|
-
profiles:
|
|
8
|
-
|
|
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
|
|
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
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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: LinkPulseMat, from: AgentId): Promise<void>;
|
|
38
|
+
/** */
|
|
39
|
+
handleEntryPulse(pulse: EntryPulseMat, 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
|
-
/** --
|
|
38
|
-
findProfiles(names: string[]): AgentPubKeyB64[];
|
|
45
|
+
/** -- Store -- */
|
|
39
46
|
/** */
|
|
40
|
-
|
|
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
|
-
|
|
54
|
+
probeAllProfiles(): Promise<void>;
|
|
43
55
|
/** */
|
|
44
|
-
|
|
56
|
+
findProfile(agentId: AgentId): Promise<Profile | undefined>;
|
|
45
57
|
/** */
|
|
46
|
-
createMyProfile(profile:
|
|
58
|
+
createMyProfile(profile: Profile): Promise<void>;
|
|
47
59
|
/** */
|
|
48
|
-
updateMyProfile(profile:
|
|
60
|
+
updateMyProfile(profile: Profile): Promise<void>;
|
|
49
61
|
/** */
|
|
50
|
-
createProfile(profile:
|
|
62
|
+
createProfile(profile: Profile, agentId: AgentId): Promise<void>;
|
|
51
63
|
/** */
|
|
52
|
-
updateProfile(profile:
|
|
64
|
+
updateProfile(profile: Profile, agentId: AgentId): Promise<void>;
|
|
53
65
|
}
|
package/dist/profilesAlt.zvm.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { decodeHashFromBase64, encodeHashToBase64 } from "@holochain/client";
|
|
1
|
+
import { ActionIdMap, AgentIdMap, ZomeViewModelWithSignals } from "@ddd-qc/lit-happ";
|
|
3
2
|
import { decode } from "@msgpack/msgpack";
|
|
4
3
|
import { ProfilesAltProxy } from "./bindings/profilesAlt.proxy";
|
|
4
|
+
import { EntryTypesType, StateChangeType, } from "./bindings/profilesAlt.types";
|
|
5
|
+
import { ProfilesLinkType } from "./bindings/profiles.integrity";
|
|
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
|
|
16
|
+
export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
9
17
|
constructor() {
|
|
10
18
|
super(...arguments);
|
|
11
|
-
this.
|
|
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,155 @@ export class ProfilesAltZvm extends ZomeViewModel {
|
|
|
30
35
|
/** -- Perspective -- */
|
|
31
36
|
/* */
|
|
32
37
|
get perspective() {
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
+
/** */
|
|
76
|
+
switch (pulse.link_type) {
|
|
77
|
+
case ProfilesLinkType.PrefixPath:
|
|
78
|
+
case ProfilesLinkType.PathToAgent:
|
|
79
|
+
break;
|
|
80
|
+
case ProfilesLinkType.AgentToProfile:
|
|
81
|
+
if (pulse.state == StateChangeType.Delete) {
|
|
82
|
+
this.unstoreAgentProfile(pulse.base, pulse.target);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.storeAgentProfile(pulse.base, pulse.target);
|
|
86
|
+
}
|
|
87
|
+
// FIXME
|
|
88
|
+
// if (pulse.isNew && from.b64 == this.cell.agentId.b64) {
|
|
89
|
+
// await this.broadcastTip({Link: pulse});
|
|
90
|
+
// }
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** */
|
|
95
|
+
async handleEntryPulse(pulse, from) {
|
|
96
|
+
switch (pulse.entryType) {
|
|
97
|
+
case EntryTypesType.Profile:
|
|
98
|
+
const profile = decode(pulse.bytes);
|
|
99
|
+
if (pulse.state != StateChangeType.Delete) {
|
|
100
|
+
this.storeProfile(pulse.ah, profile, pulse.ts);
|
|
101
|
+
}
|
|
102
|
+
// FIXME
|
|
103
|
+
// if (isNew && from.b64 == this.cell.agentId.b64) {
|
|
104
|
+
// await this.broadcastTip({Entry: pulse});
|
|
105
|
+
// }
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** -- perspective -- */
|
|
46
110
|
/** Dump perspective as JSON */
|
|
47
111
|
exportPerspective() {
|
|
48
112
|
//console.log("exportPerspective()", perspMat);
|
|
49
|
-
|
|
50
|
-
|
|
113
|
+
const core = this._perspective; // FIXME: check if this actually works as expected
|
|
114
|
+
return JSON.stringify(core, null, 2);
|
|
51
115
|
}
|
|
52
116
|
/** */
|
|
53
117
|
async importPerspective(json, canPublish) {
|
|
54
|
-
const
|
|
118
|
+
const perspective = JSON.parse(json);
|
|
55
119
|
if (canPublish) {
|
|
56
|
-
for (const [
|
|
57
|
-
await this.createProfile(
|
|
120
|
+
for (const [agentId, [profile, _ts]] of perspective.profiles.entries()) {
|
|
121
|
+
await this.createProfile(profile, agentId);
|
|
58
122
|
}
|
|
59
123
|
return;
|
|
60
124
|
}
|
|
61
|
-
|
|
62
|
-
|
|
125
|
+
/** */
|
|
126
|
+
for (const [actionId, [profile, ts]] of perspective.profiles.entries()) {
|
|
127
|
+
this.storeProfile(actionId, profile, ts);
|
|
63
128
|
}
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
}
|
|
129
|
+
for (const [agentId, actionId] of perspective.profileByAgent.entries()) {
|
|
130
|
+
this.storeAgentProfile(agentId, actionId);
|
|
73
131
|
}
|
|
74
|
-
return res;
|
|
75
132
|
}
|
|
133
|
+
/** -- Store -- */
|
|
76
134
|
/** */
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
135
|
+
storeProfile(profileAh, profile, ts) {
|
|
136
|
+
this._perspective.profiles.set(profileAh, [profile, ts]);
|
|
137
|
+
const agentId = this.getProfileAgent(profileAh);
|
|
138
|
+
if (agentId) {
|
|
139
|
+
this._perspective.agentByName[profile.nickname] = agentId;
|
|
82
140
|
}
|
|
83
|
-
|
|
84
|
-
|
|
141
|
+
}
|
|
142
|
+
/** */
|
|
143
|
+
storeAgentProfile(agentId, profileAh) {
|
|
144
|
+
this._perspective.profileByAgent.set(agentId, profileAh);
|
|
145
|
+
const pair = this._perspective.profiles.get(profileAh);
|
|
146
|
+
if (pair) {
|
|
147
|
+
this._perspective.agentByName[pair[0].nickname] = agentId;
|
|
85
148
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this.storeProfile(encodeHashToBase64(agentPubKey), profile, timestamp);
|
|
149
|
+
}
|
|
150
|
+
/** */
|
|
151
|
+
unstoreAgentProfile(agentId, profileAh) {
|
|
152
|
+
this._perspective.profileByAgent.delete(agentId);
|
|
153
|
+
const pair = this._perspective.profiles.get(profileAh);
|
|
154
|
+
if (pair) {
|
|
155
|
+
delete this._perspective.agentByName[pair[0].nickname];
|
|
94
156
|
}
|
|
95
|
-
this.notifySubscribers();
|
|
96
|
-
return this._profiles;
|
|
97
157
|
}
|
|
158
|
+
/** -- Methods -- */
|
|
98
159
|
/** */
|
|
99
|
-
|
|
100
|
-
this.
|
|
101
|
-
this._profileDates[pubKeyB64] = ts;
|
|
102
|
-
this._reversed[profile.nickname] = pubKeyB64;
|
|
103
|
-
this.notifySubscribers();
|
|
160
|
+
async probeAllProfiles() {
|
|
161
|
+
await this.zomeProxy.probeProfiles();
|
|
104
162
|
}
|
|
105
163
|
/** */
|
|
106
|
-
async
|
|
107
|
-
const
|
|
108
|
-
console.log("probeProfile()
|
|
109
|
-
if (!
|
|
164
|
+
async findProfile(agentId) {
|
|
165
|
+
const maybeProfilePair = await this.zomeProxy.findProfile(agentId.hash);
|
|
166
|
+
console.log("probeProfile() maybeProfilePair", maybeProfilePair);
|
|
167
|
+
if (!maybeProfilePair) {
|
|
110
168
|
return;
|
|
111
169
|
}
|
|
112
|
-
|
|
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;
|
|
170
|
+
return maybeProfilePair[1];
|
|
120
171
|
}
|
|
121
172
|
/** */
|
|
122
173
|
async createMyProfile(profile) {
|
|
123
|
-
const
|
|
124
|
-
const timestamp = record.signed_action.hashed.content.timestamp;
|
|
125
|
-
this.storeProfile(this.cell.agentPubKey, profile, timestamp);
|
|
174
|
+
const _ah = await this.zomeProxy.createProfile([profile, this.cell.agentId.hash]);
|
|
126
175
|
}
|
|
127
176
|
/** */
|
|
128
177
|
async updateMyProfile(profile) {
|
|
129
|
-
const
|
|
130
|
-
const timestamp = record.signed_action.hashed.content.timestamp;
|
|
131
|
-
this.storeProfile(this.cell.agentPubKey, profile, timestamp);
|
|
178
|
+
const _ah = await this.zomeProxy.updateProfile([profile, this.cell.agentId.hash]);
|
|
132
179
|
}
|
|
133
180
|
/** */
|
|
134
|
-
async createProfile(profile,
|
|
135
|
-
const
|
|
136
|
-
const timestamp = record.signed_action.hashed.content.timestamp;
|
|
137
|
-
this.storeProfile(agent, profile, timestamp);
|
|
181
|
+
async createProfile(profile, agentId) {
|
|
182
|
+
const _ah = await this.zomeProxy.createProfile([profile, agentId.hash]);
|
|
138
183
|
}
|
|
139
184
|
/** */
|
|
140
|
-
async updateProfile(profile,
|
|
141
|
-
const
|
|
142
|
-
const timestamp = record.signed_action.hashed.content.timestamp;
|
|
143
|
-
this.storeProfile(agent, profile, timestamp);
|
|
185
|
+
async updateProfile(profile, agentId) {
|
|
186
|
+
const _ah = await this.zomeProxy.updateProfile([profile, agentId.hash]);
|
|
144
187
|
}
|
|
145
188
|
}
|
|
146
189
|
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,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,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,iCAAiC;SAClC,CAAC;IACJ,CAAC;IAQD,YAAY,KA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PubKeyB64, 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,EACK,WAAW,EAErB,UAAU,EAIV,wBAAwB,EACzB,MAAM,kBAAkB,CAAC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AAI,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;;AAnNe,yBAAU,GAAG,gBAAgB,AAAnB,CAAoB","sourcesContent":["import {\n ActionId, ActionIdMap,\n AgentId,\n AgentIdMap,\n EntryId,\n getVariantByIndex,\n intoLinkableId, LinkPulseMat,\n ZomeViewModelWithSignals\n} from \"@ddd-qc/lit-happ\";\nimport {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\";\nimport {EntryPulseMat} from \"@ddd-qc/lit-happ/dist/ZomeViewModelWithSignals\";\nimport {ProfilesLinkType} from \"./bindings/profiles.integrity\";\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: LinkPulseMat, from: AgentId): Promise<void> {\n /** */\n switch (pulse.link_type) {\n case ProfilesLinkType.PrefixPath:\n case ProfilesLinkType.PathToAgent:\n break;\n case ProfilesLinkType.AgentToProfile:\n if (pulse.state == StateChangeType.Delete) {\n this.unstoreAgentProfile(pulse.base, pulse.target)\n } else {\n this.storeAgentProfile(pulse.base, pulse.target)\n }\n // FIXME\n // if (pulse.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: EntryPulseMat, from: AgentId) {\n switch (pulse.entryType) {\n case EntryTypesType.Profile:\n const profile = decode(pulse.bytes) as Profile;\n if (pulse.state != StateChangeType.Delete) {\n this.storeProfile(pulse.ah, profile, pulse.ts);\n }\n // FIXME\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"]}
|