@coasys/ad4m 0.10.1-release-candidate-4-debug-strings-2 → 0.10.1-release-candidate-5
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/lib/index.cjs +94 -72
- package/lib/index.js +95 -73
- package/lib/src/language/Language.d.ts +0 -3
- package/lib/src/model/Ad4mModel.js +28 -1
- package/lib/src/neighbourhood/NeighbourhoodClient.js +0 -3
- package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +42 -0
- package/lib/src/perspectives/PerspectiveHandle.d.ts +6 -6
- package/lib/src/perspectives/PerspectiveHandle.js +6 -6
- package/lib/src/perspectives/PerspectiveProxy.d.ts +4 -0
- package/lib/src/perspectives/PerspectiveProxy.js +60 -3
- package/lib/src/runtime/RuntimeClient.d.ts +0 -1
- package/lib/src/runtime/RuntimeClient.js +0 -14
- package/lib/src/runtime/RuntimeResolver.d.ts +0 -7
- package/lib/src/runtime/RuntimeResolver.js +0 -38
- package/lib/src/schema.gql +0 -8
- package/lib/src/typeDefs.js +0 -8
- package/package.json +2 -2
- package/src/language/Language.ts +2 -6
- package/src/model/Ad4mModel.ts +28 -6
- package/src/neighbourhood/NeighbourhoodClient.ts +0 -3
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +57 -2
- package/src/perspectives/PerspectiveHandle.ts +6 -6
- package/src/perspectives/PerspectiveProxy.ts +73 -5
- package/src/runtime/RuntimeClient.ts +0 -15
- package/src/runtime/RuntimeResolver.ts +0 -26
package/lib/index.cjs
CHANGED
|
@@ -5304,10 +5304,63 @@ class PerspectiveProxy {
|
|
|
5304
5304
|
* This will return all SDNA code elements in an array.
|
|
5305
5305
|
*/
|
|
5306
5306
|
async getSdna() {
|
|
5307
|
-
|
|
5307
|
+
// First, find all the name literals that are linked from ad4m://self with SDNA predicates
|
|
5308
|
+
const sdnaPredicates = [
|
|
5309
|
+
"ad4m://has_subject_class",
|
|
5310
|
+
"ad4m://has_flow",
|
|
5311
|
+
"ad4m://has_custom_sdna"
|
|
5312
|
+
];
|
|
5313
|
+
const allSdnaCode = [];
|
|
5314
|
+
for (const predicate of sdnaPredicates) {
|
|
5315
|
+
// Find name literals linked from ad4m://self with this predicate
|
|
5316
|
+
const nameLinks = await this.get(new exports.LinkQuery({
|
|
5317
|
+
source: "ad4m://self",
|
|
5318
|
+
predicate: predicate
|
|
5319
|
+
}));
|
|
5320
|
+
// For each name literal found, get the actual SDNA code
|
|
5321
|
+
for (const nameLink of nameLinks) {
|
|
5322
|
+
const nameLiteral = nameLink.data.target;
|
|
5323
|
+
// Now find the SDNA code linked from this name with predicate "ad4m://sdna"
|
|
5324
|
+
const sdnaLinks = await this.get(new exports.LinkQuery({
|
|
5325
|
+
source: nameLiteral,
|
|
5326
|
+
predicate: "ad4m://sdna"
|
|
5327
|
+
}));
|
|
5328
|
+
// Extract the SDNA code from each link
|
|
5329
|
+
for (const sdnaLink of sdnaLinks) {
|
|
5330
|
+
const code = Literal.fromUrl(sdnaLink.data.target).get();
|
|
5331
|
+
if (typeof code === 'string') {
|
|
5332
|
+
allSdnaCode.push(code);
|
|
5333
|
+
}
|
|
5334
|
+
}
|
|
5335
|
+
}
|
|
5336
|
+
}
|
|
5337
|
+
return allSdnaCode;
|
|
5338
|
+
}
|
|
5339
|
+
/** Returns the Social DNA code for a specific class
|
|
5340
|
+
* This will return the SDNA code for the specified class, or null if not found.
|
|
5341
|
+
*/
|
|
5342
|
+
async getSdnaForClass(className) {
|
|
5343
|
+
// First, find the name literal for this class that is linked from ad4m://self
|
|
5344
|
+
const nameLiteral = Literal.from(className);
|
|
5345
|
+
const links = await this.get(new exports.LinkQuery({
|
|
5346
|
+
source: "ad4m://self",
|
|
5347
|
+
target: nameLiteral.toUrl(),
|
|
5348
|
+
predicate: "ad4m://has_subject_class"
|
|
5349
|
+
}));
|
|
5350
|
+
if (links.length === 0) {
|
|
5351
|
+
return null;
|
|
5352
|
+
}
|
|
5353
|
+
// Now find the SDNA code linked from this name with predicate "ad4m://sdna"
|
|
5354
|
+
const sdnaLinks = await this.get(new exports.LinkQuery({
|
|
5355
|
+
source: nameLiteral.toUrl(),
|
|
5308
5356
|
predicate: "ad4m://sdna"
|
|
5309
5357
|
}));
|
|
5310
|
-
|
|
5358
|
+
if (sdnaLinks.length === 0) {
|
|
5359
|
+
return null;
|
|
5360
|
+
}
|
|
5361
|
+
// Extract the SDNA code from the first link
|
|
5362
|
+
const code = Literal.fromUrl(sdnaLinks[0].data.target).get();
|
|
5363
|
+
return typeof code === 'string' ? code : null;
|
|
5311
5364
|
}
|
|
5312
5365
|
/** Adds the given Social DNA code to the perspective's SDNA code */
|
|
5313
5366
|
async addSdna(name, sdnaCode, sdnaType) {
|
|
@@ -5488,7 +5541,11 @@ class PerspectiveProxy {
|
|
|
5488
5541
|
}
|
|
5489
5542
|
// Collect all collections of the object in a list
|
|
5490
5543
|
if (Object.getPrototypeOf(obj).__collections) {
|
|
5491
|
-
Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c =>
|
|
5544
|
+
Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c => {
|
|
5545
|
+
if (!collections.includes(c)) {
|
|
5546
|
+
collections.push(c);
|
|
5547
|
+
}
|
|
5548
|
+
});
|
|
5492
5549
|
}
|
|
5493
5550
|
else {
|
|
5494
5551
|
collections.push(...Object.keys(obj).filter(key => Array.isArray(obj[key])).filter(key => key !== 'isSubjectInstance'));
|
|
@@ -7004,9 +7061,6 @@ class NeighbourhoodClient {
|
|
|
7004
7061
|
const index = handlersForPerspective.indexOf(handler);
|
|
7005
7062
|
if (index > -1) {
|
|
7006
7063
|
handlersForPerspective.splice(index, 1);
|
|
7007
|
-
if (!handlersForPerspective.length) {
|
|
7008
|
-
__classPrivateFieldGet$6(this, _NeighbourhoodClient_signalHandlers, "f").delete(perspectiveUUID);
|
|
7009
|
-
}
|
|
7010
7064
|
}
|
|
7011
7065
|
}
|
|
7012
7066
|
}
|
|
@@ -7196,20 +7250,6 @@ class RuntimeClient {
|
|
|
7196
7250
|
}));
|
|
7197
7251
|
return runtimeGetNetworkMetrics;
|
|
7198
7252
|
}
|
|
7199
|
-
async debugStrings(languageAddress) {
|
|
7200
|
-
const { runtimeDebugStrings } = unwrapApolloResult(await __classPrivateFieldGet$5(this, _RuntimeClient_apolloClient, "f").query({
|
|
7201
|
-
query: gql `query runtimeDebugStrings($languageAddress: String) {
|
|
7202
|
-
runtimeDebugStrings(languageAddress: $languageAddress) {
|
|
7203
|
-
languageAddress
|
|
7204
|
-
operation
|
|
7205
|
-
debugString
|
|
7206
|
-
timestamp
|
|
7207
|
-
}
|
|
7208
|
-
}`,
|
|
7209
|
-
variables: { languageAddress }
|
|
7210
|
-
}));
|
|
7211
|
-
return runtimeDebugStrings;
|
|
7212
|
-
}
|
|
7213
7253
|
async restartHolochain() {
|
|
7214
7254
|
const { runtimeRestartHolochain } = unwrapApolloResult(await __classPrivateFieldGet$5(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
7215
7255
|
mutation: gql `mutation runtimeRestartHolochain {
|
|
@@ -15461,12 +15501,12 @@ var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) {
|
|
|
15461
15501
|
};
|
|
15462
15502
|
exports.PerspectiveState = void 0;
|
|
15463
15503
|
(function (PerspectiveState) {
|
|
15464
|
-
PerspectiveState["Private"] = "
|
|
15465
|
-
PerspectiveState["NeighboudhoodCreationInitiated"] = "
|
|
15466
|
-
PerspectiveState["NeighbourhoodJoinInitiated"] = "
|
|
15467
|
-
PerspectiveState["LinkLanguageFailedToInstall"] = "
|
|
15468
|
-
PerspectiveState["LinkLanguageInstalledButNotSynced"] = "
|
|
15469
|
-
PerspectiveState["Synced"] = "
|
|
15504
|
+
PerspectiveState["Private"] = "PRIVATE";
|
|
15505
|
+
PerspectiveState["NeighboudhoodCreationInitiated"] = "NEIGHBOURHOOD_CREATION_INITIATED";
|
|
15506
|
+
PerspectiveState["NeighbourhoodJoinInitiated"] = "NEIGHBOURHOOD_JOIN_INITIATED";
|
|
15507
|
+
PerspectiveState["LinkLanguageFailedToInstall"] = "LINK_LANGUAGE_FAILED_TO_INSTALL";
|
|
15508
|
+
PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED";
|
|
15509
|
+
PerspectiveState["Synced"] = "SYNCED";
|
|
15470
15510
|
})(exports.PerspectiveState || (exports.PerspectiveState = {}));
|
|
15471
15511
|
// This type is used in the GraphQL interface to reference a mutable
|
|
15472
15512
|
// prespective that is implemented locally by the Ad4m runtime.
|
|
@@ -16383,13 +16423,6 @@ input CapabilityInput {
|
|
|
16383
16423
|
|
|
16384
16424
|
scalar DateTime
|
|
16385
16425
|
|
|
16386
|
-
type DebugStringEntry {
|
|
16387
|
-
debugString: String!
|
|
16388
|
-
languageAddress: String!
|
|
16389
|
-
operation: String!
|
|
16390
|
-
timestamp: String!
|
|
16391
|
-
}
|
|
16392
|
-
|
|
16393
16426
|
type EntanglementProof {
|
|
16394
16427
|
deviceKey: String!
|
|
16395
16428
|
deviceKeySignedByDid: String!
|
|
@@ -16766,7 +16799,6 @@ type Query {
|
|
|
16766
16799
|
perspectiveQueryProlog(query: String!, uuid: String!): String!
|
|
16767
16800
|
perspectiveSnapshot(uuid: String!): Perspective
|
|
16768
16801
|
perspectives: [PerspectiveHandle!]!
|
|
16769
|
-
runtimeDebugStrings(languageAddress: String): [DebugStringEntry!]!
|
|
16770
16802
|
runtimeFriendStatus(did: String!): PerspectiveExpression
|
|
16771
16803
|
runtimeFriends: [String!]!
|
|
16772
16804
|
runtimeGetNetworkMetrics: String!
|
|
@@ -17056,27 +17088,6 @@ __decorate([
|
|
|
17056
17088
|
exports.TriggeredNotification = __decorate([
|
|
17057
17089
|
ObjectType()
|
|
17058
17090
|
], exports.TriggeredNotification);
|
|
17059
|
-
exports.DebugStringEntry = class DebugStringEntry {
|
|
17060
|
-
};
|
|
17061
|
-
__decorate([
|
|
17062
|
-
Field(),
|
|
17063
|
-
__metadata("design:type", String)
|
|
17064
|
-
], exports.DebugStringEntry.prototype, "languageAddress", void 0);
|
|
17065
|
-
__decorate([
|
|
17066
|
-
Field(),
|
|
17067
|
-
__metadata("design:type", String)
|
|
17068
|
-
], exports.DebugStringEntry.prototype, "debugString", void 0);
|
|
17069
|
-
__decorate([
|
|
17070
|
-
Field(),
|
|
17071
|
-
__metadata("design:type", String)
|
|
17072
|
-
], exports.DebugStringEntry.prototype, "operation", void 0);
|
|
17073
|
-
__decorate([
|
|
17074
|
-
Field(),
|
|
17075
|
-
__metadata("design:type", String)
|
|
17076
|
-
], exports.DebugStringEntry.prototype, "timestamp", void 0);
|
|
17077
|
-
exports.DebugStringEntry = __decorate([
|
|
17078
|
-
ObjectType()
|
|
17079
|
-
], exports.DebugStringEntry);
|
|
17080
17091
|
exports.ImportStats = class ImportStats {
|
|
17081
17092
|
};
|
|
17082
17093
|
__decorate([
|
|
@@ -17183,15 +17194,6 @@ let RuntimeResolver = class RuntimeResolver {
|
|
|
17183
17194
|
runtimeKnownLinkLanguageTemplates() {
|
|
17184
17195
|
return ["Qm12345abcdef"];
|
|
17185
17196
|
}
|
|
17186
|
-
runtimeDebugStrings(languageAddress) {
|
|
17187
|
-
// Mock data for testing - in real implementation this would come from stored debug strings
|
|
17188
|
-
return [{
|
|
17189
|
-
languageAddress: "Qm123example",
|
|
17190
|
-
debugString: "Debug string content",
|
|
17191
|
-
operation: "merge",
|
|
17192
|
-
timestamp: new Date().toISOString()
|
|
17193
|
-
}];
|
|
17194
|
-
}
|
|
17195
17197
|
runtimeAddKnownLinkLanguageTemplates(addresses) {
|
|
17196
17198
|
return addresses;
|
|
17197
17199
|
}
|
|
@@ -17355,13 +17357,6 @@ __decorate([
|
|
|
17355
17357
|
__metadata("design:paramtypes", []),
|
|
17356
17358
|
__metadata("design:returntype", Array)
|
|
17357
17359
|
], RuntimeResolver.prototype, "runtimeKnownLinkLanguageTemplates", null);
|
|
17358
|
-
__decorate([
|
|
17359
|
-
Query(),
|
|
17360
|
-
__param(0, Arg()),
|
|
17361
|
-
__metadata("design:type", Function),
|
|
17362
|
-
__metadata("design:paramtypes", [String]),
|
|
17363
|
-
__metadata("design:returntype", Array)
|
|
17364
|
-
], RuntimeResolver.prototype, "runtimeDebugStrings", null);
|
|
17365
17360
|
__decorate([
|
|
17366
17361
|
Mutation(),
|
|
17367
17362
|
__param(0, Arg()),
|
|
@@ -17865,11 +17860,38 @@ class Ad4mModel {
|
|
|
17865
17860
|
// Map properties to object
|
|
17866
17861
|
const propsObject = Object.fromEntries(await Promise.all(values.map(async ([name, value, resolve]) => {
|
|
17867
17862
|
let finalValue = value;
|
|
17863
|
+
// Handle UTF-8 byte sequences from Prolog URL decoding
|
|
17864
|
+
if (!resolve && typeof value === 'string') {
|
|
17865
|
+
// Only attempt reconstruction if the string looks like a byte string (all code points <= 0xFF)
|
|
17866
|
+
// and contains at least one high byte (>= 0x80). This avoids mangling valid Unicode.
|
|
17867
|
+
const codePoints = Array.from(value, ch => ch.codePointAt(0));
|
|
17868
|
+
const looksByteString = codePoints.every(cp => cp <= 0xFF);
|
|
17869
|
+
const hasHighByte = codePoints.some(cp => cp >= 0x80);
|
|
17870
|
+
if (looksByteString && hasHighByte) {
|
|
17871
|
+
try {
|
|
17872
|
+
const bytes = Uint8Array.from(codePoints);
|
|
17873
|
+
const decoded = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
17874
|
+
if (decoded !== value)
|
|
17875
|
+
finalValue = decoded;
|
|
17876
|
+
}
|
|
17877
|
+
catch (error) {
|
|
17878
|
+
// If UTF-8 conversion fails, keep the original value
|
|
17879
|
+
console.warn(`UTF-8 byte reconstruction failed for property "${name}"`, { value, error });
|
|
17880
|
+
}
|
|
17881
|
+
}
|
|
17882
|
+
}
|
|
17868
17883
|
// Resolve the value if necessary
|
|
17869
17884
|
if (resolve) {
|
|
17870
17885
|
let resolvedExpression = await perspective.getExpression(value);
|
|
17871
17886
|
if (resolvedExpression) {
|
|
17872
|
-
|
|
17887
|
+
try {
|
|
17888
|
+
// Attempt to parse the data as JSON
|
|
17889
|
+
finalValue = JSON.parse(resolvedExpression.data);
|
|
17890
|
+
}
|
|
17891
|
+
catch (error) {
|
|
17892
|
+
// If parsing fails, keep the original data
|
|
17893
|
+
finalValue = resolvedExpression.data;
|
|
17894
|
+
}
|
|
17873
17895
|
}
|
|
17874
17896
|
}
|
|
17875
17897
|
// Apply transform function if it exists
|
package/lib/index.js
CHANGED
|
@@ -5300,10 +5300,63 @@ class PerspectiveProxy {
|
|
|
5300
5300
|
* This will return all SDNA code elements in an array.
|
|
5301
5301
|
*/
|
|
5302
5302
|
async getSdna() {
|
|
5303
|
-
|
|
5303
|
+
// First, find all the name literals that are linked from ad4m://self with SDNA predicates
|
|
5304
|
+
const sdnaPredicates = [
|
|
5305
|
+
"ad4m://has_subject_class",
|
|
5306
|
+
"ad4m://has_flow",
|
|
5307
|
+
"ad4m://has_custom_sdna"
|
|
5308
|
+
];
|
|
5309
|
+
const allSdnaCode = [];
|
|
5310
|
+
for (const predicate of sdnaPredicates) {
|
|
5311
|
+
// Find name literals linked from ad4m://self with this predicate
|
|
5312
|
+
const nameLinks = await this.get(new LinkQuery({
|
|
5313
|
+
source: "ad4m://self",
|
|
5314
|
+
predicate: predicate
|
|
5315
|
+
}));
|
|
5316
|
+
// For each name literal found, get the actual SDNA code
|
|
5317
|
+
for (const nameLink of nameLinks) {
|
|
5318
|
+
const nameLiteral = nameLink.data.target;
|
|
5319
|
+
// Now find the SDNA code linked from this name with predicate "ad4m://sdna"
|
|
5320
|
+
const sdnaLinks = await this.get(new LinkQuery({
|
|
5321
|
+
source: nameLiteral,
|
|
5322
|
+
predicate: "ad4m://sdna"
|
|
5323
|
+
}));
|
|
5324
|
+
// Extract the SDNA code from each link
|
|
5325
|
+
for (const sdnaLink of sdnaLinks) {
|
|
5326
|
+
const code = Literal.fromUrl(sdnaLink.data.target).get();
|
|
5327
|
+
if (typeof code === 'string') {
|
|
5328
|
+
allSdnaCode.push(code);
|
|
5329
|
+
}
|
|
5330
|
+
}
|
|
5331
|
+
}
|
|
5332
|
+
}
|
|
5333
|
+
return allSdnaCode;
|
|
5334
|
+
}
|
|
5335
|
+
/** Returns the Social DNA code for a specific class
|
|
5336
|
+
* This will return the SDNA code for the specified class, or null if not found.
|
|
5337
|
+
*/
|
|
5338
|
+
async getSdnaForClass(className) {
|
|
5339
|
+
// First, find the name literal for this class that is linked from ad4m://self
|
|
5340
|
+
const nameLiteral = Literal.from(className);
|
|
5341
|
+
const links = await this.get(new LinkQuery({
|
|
5342
|
+
source: "ad4m://self",
|
|
5343
|
+
target: nameLiteral.toUrl(),
|
|
5344
|
+
predicate: "ad4m://has_subject_class"
|
|
5345
|
+
}));
|
|
5346
|
+
if (links.length === 0) {
|
|
5347
|
+
return null;
|
|
5348
|
+
}
|
|
5349
|
+
// Now find the SDNA code linked from this name with predicate "ad4m://sdna"
|
|
5350
|
+
const sdnaLinks = await this.get(new LinkQuery({
|
|
5351
|
+
source: nameLiteral.toUrl(),
|
|
5304
5352
|
predicate: "ad4m://sdna"
|
|
5305
5353
|
}));
|
|
5306
|
-
|
|
5354
|
+
if (sdnaLinks.length === 0) {
|
|
5355
|
+
return null;
|
|
5356
|
+
}
|
|
5357
|
+
// Extract the SDNA code from the first link
|
|
5358
|
+
const code = Literal.fromUrl(sdnaLinks[0].data.target).get();
|
|
5359
|
+
return typeof code === 'string' ? code : null;
|
|
5307
5360
|
}
|
|
5308
5361
|
/** Adds the given Social DNA code to the perspective's SDNA code */
|
|
5309
5362
|
async addSdna(name, sdnaCode, sdnaType) {
|
|
@@ -5484,7 +5537,11 @@ class PerspectiveProxy {
|
|
|
5484
5537
|
}
|
|
5485
5538
|
// Collect all collections of the object in a list
|
|
5486
5539
|
if (Object.getPrototypeOf(obj).__collections) {
|
|
5487
|
-
Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c =>
|
|
5540
|
+
Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c => {
|
|
5541
|
+
if (!collections.includes(c)) {
|
|
5542
|
+
collections.push(c);
|
|
5543
|
+
}
|
|
5544
|
+
});
|
|
5488
5545
|
}
|
|
5489
5546
|
else {
|
|
5490
5547
|
collections.push(...Object.keys(obj).filter(key => Array.isArray(obj[key])).filter(key => key !== 'isSubjectInstance'));
|
|
@@ -7000,9 +7057,6 @@ class NeighbourhoodClient {
|
|
|
7000
7057
|
const index = handlersForPerspective.indexOf(handler);
|
|
7001
7058
|
if (index > -1) {
|
|
7002
7059
|
handlersForPerspective.splice(index, 1);
|
|
7003
|
-
if (!handlersForPerspective.length) {
|
|
7004
|
-
__classPrivateFieldGet$6(this, _NeighbourhoodClient_signalHandlers, "f").delete(perspectiveUUID);
|
|
7005
|
-
}
|
|
7006
7060
|
}
|
|
7007
7061
|
}
|
|
7008
7062
|
}
|
|
@@ -7192,20 +7246,6 @@ class RuntimeClient {
|
|
|
7192
7246
|
}));
|
|
7193
7247
|
return runtimeGetNetworkMetrics;
|
|
7194
7248
|
}
|
|
7195
|
-
async debugStrings(languageAddress) {
|
|
7196
|
-
const { runtimeDebugStrings } = unwrapApolloResult(await __classPrivateFieldGet$5(this, _RuntimeClient_apolloClient, "f").query({
|
|
7197
|
-
query: gql `query runtimeDebugStrings($languageAddress: String) {
|
|
7198
|
-
runtimeDebugStrings(languageAddress: $languageAddress) {
|
|
7199
|
-
languageAddress
|
|
7200
|
-
operation
|
|
7201
|
-
debugString
|
|
7202
|
-
timestamp
|
|
7203
|
-
}
|
|
7204
|
-
}`,
|
|
7205
|
-
variables: { languageAddress }
|
|
7206
|
-
}));
|
|
7207
|
-
return runtimeDebugStrings;
|
|
7208
|
-
}
|
|
7209
7249
|
async restartHolochain() {
|
|
7210
7250
|
const { runtimeRestartHolochain } = unwrapApolloResult(await __classPrivateFieldGet$5(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
7211
7251
|
mutation: gql `mutation runtimeRestartHolochain {
|
|
@@ -15457,12 +15497,12 @@ var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) {
|
|
|
15457
15497
|
};
|
|
15458
15498
|
var PerspectiveState;
|
|
15459
15499
|
(function (PerspectiveState) {
|
|
15460
|
-
PerspectiveState["Private"] = "
|
|
15461
|
-
PerspectiveState["NeighboudhoodCreationInitiated"] = "
|
|
15462
|
-
PerspectiveState["NeighbourhoodJoinInitiated"] = "
|
|
15463
|
-
PerspectiveState["LinkLanguageFailedToInstall"] = "
|
|
15464
|
-
PerspectiveState["LinkLanguageInstalledButNotSynced"] = "
|
|
15465
|
-
PerspectiveState["Synced"] = "
|
|
15500
|
+
PerspectiveState["Private"] = "PRIVATE";
|
|
15501
|
+
PerspectiveState["NeighboudhoodCreationInitiated"] = "NEIGHBOURHOOD_CREATION_INITIATED";
|
|
15502
|
+
PerspectiveState["NeighbourhoodJoinInitiated"] = "NEIGHBOURHOOD_JOIN_INITIATED";
|
|
15503
|
+
PerspectiveState["LinkLanguageFailedToInstall"] = "LINK_LANGUAGE_FAILED_TO_INSTALL";
|
|
15504
|
+
PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED";
|
|
15505
|
+
PerspectiveState["Synced"] = "SYNCED";
|
|
15466
15506
|
})(PerspectiveState || (PerspectiveState = {}));
|
|
15467
15507
|
// This type is used in the GraphQL interface to reference a mutable
|
|
15468
15508
|
// prespective that is implemented locally by the Ad4m runtime.
|
|
@@ -16379,13 +16419,6 @@ input CapabilityInput {
|
|
|
16379
16419
|
|
|
16380
16420
|
scalar DateTime
|
|
16381
16421
|
|
|
16382
|
-
type DebugStringEntry {
|
|
16383
|
-
debugString: String!
|
|
16384
|
-
languageAddress: String!
|
|
16385
|
-
operation: String!
|
|
16386
|
-
timestamp: String!
|
|
16387
|
-
}
|
|
16388
|
-
|
|
16389
16422
|
type EntanglementProof {
|
|
16390
16423
|
deviceKey: String!
|
|
16391
16424
|
deviceKeySignedByDid: String!
|
|
@@ -16762,7 +16795,6 @@ type Query {
|
|
|
16762
16795
|
perspectiveQueryProlog(query: String!, uuid: String!): String!
|
|
16763
16796
|
perspectiveSnapshot(uuid: String!): Perspective
|
|
16764
16797
|
perspectives: [PerspectiveHandle!]!
|
|
16765
|
-
runtimeDebugStrings(languageAddress: String): [DebugStringEntry!]!
|
|
16766
16798
|
runtimeFriendStatus(did: String!): PerspectiveExpression
|
|
16767
16799
|
runtimeFriends: [String!]!
|
|
16768
16800
|
runtimeGetNetworkMetrics: String!
|
|
@@ -17052,27 +17084,6 @@ __decorate([
|
|
|
17052
17084
|
TriggeredNotification = __decorate([
|
|
17053
17085
|
ObjectType()
|
|
17054
17086
|
], TriggeredNotification);
|
|
17055
|
-
let DebugStringEntry = class DebugStringEntry {
|
|
17056
|
-
};
|
|
17057
|
-
__decorate([
|
|
17058
|
-
Field(),
|
|
17059
|
-
__metadata("design:type", String)
|
|
17060
|
-
], DebugStringEntry.prototype, "languageAddress", void 0);
|
|
17061
|
-
__decorate([
|
|
17062
|
-
Field(),
|
|
17063
|
-
__metadata("design:type", String)
|
|
17064
|
-
], DebugStringEntry.prototype, "debugString", void 0);
|
|
17065
|
-
__decorate([
|
|
17066
|
-
Field(),
|
|
17067
|
-
__metadata("design:type", String)
|
|
17068
|
-
], DebugStringEntry.prototype, "operation", void 0);
|
|
17069
|
-
__decorate([
|
|
17070
|
-
Field(),
|
|
17071
|
-
__metadata("design:type", String)
|
|
17072
|
-
], DebugStringEntry.prototype, "timestamp", void 0);
|
|
17073
|
-
DebugStringEntry = __decorate([
|
|
17074
|
-
ObjectType()
|
|
17075
|
-
], DebugStringEntry);
|
|
17076
17087
|
let ImportStats = class ImportStats {
|
|
17077
17088
|
};
|
|
17078
17089
|
__decorate([
|
|
@@ -17179,15 +17190,6 @@ let RuntimeResolver = class RuntimeResolver {
|
|
|
17179
17190
|
runtimeKnownLinkLanguageTemplates() {
|
|
17180
17191
|
return ["Qm12345abcdef"];
|
|
17181
17192
|
}
|
|
17182
|
-
runtimeDebugStrings(languageAddress) {
|
|
17183
|
-
// Mock data for testing - in real implementation this would come from stored debug strings
|
|
17184
|
-
return [{
|
|
17185
|
-
languageAddress: "Qm123example",
|
|
17186
|
-
debugString: "Debug string content",
|
|
17187
|
-
operation: "merge",
|
|
17188
|
-
timestamp: new Date().toISOString()
|
|
17189
|
-
}];
|
|
17190
|
-
}
|
|
17191
17193
|
runtimeAddKnownLinkLanguageTemplates(addresses) {
|
|
17192
17194
|
return addresses;
|
|
17193
17195
|
}
|
|
@@ -17351,13 +17353,6 @@ __decorate([
|
|
|
17351
17353
|
__metadata("design:paramtypes", []),
|
|
17352
17354
|
__metadata("design:returntype", Array)
|
|
17353
17355
|
], RuntimeResolver.prototype, "runtimeKnownLinkLanguageTemplates", null);
|
|
17354
|
-
__decorate([
|
|
17355
|
-
Query(),
|
|
17356
|
-
__param(0, Arg()),
|
|
17357
|
-
__metadata("design:type", Function),
|
|
17358
|
-
__metadata("design:paramtypes", [String]),
|
|
17359
|
-
__metadata("design:returntype", Array)
|
|
17360
|
-
], RuntimeResolver.prototype, "runtimeDebugStrings", null);
|
|
17361
17356
|
__decorate([
|
|
17362
17357
|
Mutation(),
|
|
17363
17358
|
__param(0, Arg()),
|
|
@@ -17861,11 +17856,38 @@ class Ad4mModel {
|
|
|
17861
17856
|
// Map properties to object
|
|
17862
17857
|
const propsObject = Object.fromEntries(await Promise.all(values.map(async ([name, value, resolve]) => {
|
|
17863
17858
|
let finalValue = value;
|
|
17859
|
+
// Handle UTF-8 byte sequences from Prolog URL decoding
|
|
17860
|
+
if (!resolve && typeof value === 'string') {
|
|
17861
|
+
// Only attempt reconstruction if the string looks like a byte string (all code points <= 0xFF)
|
|
17862
|
+
// and contains at least one high byte (>= 0x80). This avoids mangling valid Unicode.
|
|
17863
|
+
const codePoints = Array.from(value, ch => ch.codePointAt(0));
|
|
17864
|
+
const looksByteString = codePoints.every(cp => cp <= 0xFF);
|
|
17865
|
+
const hasHighByte = codePoints.some(cp => cp >= 0x80);
|
|
17866
|
+
if (looksByteString && hasHighByte) {
|
|
17867
|
+
try {
|
|
17868
|
+
const bytes = Uint8Array.from(codePoints);
|
|
17869
|
+
const decoded = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
17870
|
+
if (decoded !== value)
|
|
17871
|
+
finalValue = decoded;
|
|
17872
|
+
}
|
|
17873
|
+
catch (error) {
|
|
17874
|
+
// If UTF-8 conversion fails, keep the original value
|
|
17875
|
+
console.warn(`UTF-8 byte reconstruction failed for property "${name}"`, { value, error });
|
|
17876
|
+
}
|
|
17877
|
+
}
|
|
17878
|
+
}
|
|
17864
17879
|
// Resolve the value if necessary
|
|
17865
17880
|
if (resolve) {
|
|
17866
17881
|
let resolvedExpression = await perspective.getExpression(value);
|
|
17867
17882
|
if (resolvedExpression) {
|
|
17868
|
-
|
|
17883
|
+
try {
|
|
17884
|
+
// Attempt to parse the data as JSON
|
|
17885
|
+
finalValue = JSON.parse(resolvedExpression.data);
|
|
17886
|
+
}
|
|
17887
|
+
catch (error) {
|
|
17888
|
+
// If parsing fails, keep the original data
|
|
17889
|
+
finalValue = resolvedExpression.data;
|
|
17890
|
+
}
|
|
17869
17891
|
}
|
|
17870
17892
|
}
|
|
17871
17893
|
// Apply transform function if it exists
|
|
@@ -18637,4 +18659,4 @@ class ModelQueryBuilder {
|
|
|
18637
18659
|
}
|
|
18638
18660
|
}
|
|
18639
18661
|
|
|
18640
|
-
export { AIClient, AIModelLoadingStatus, AIPromptExamples, AIPromptExamplesInput, AITask, AITaskInput, Ad4mClient, Ad4mModel, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, Capability, CapabilityInput, Collection,
|
|
18662
|
+
export { AIClient, AIModelLoadingStatus, AIPromptExamples, AIPromptExamplesInput, AITask, AITaskInput, Ad4mClient, Ad4mModel, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, Capability, CapabilityInput, Collection, Dna, EntanglementProof, EntanglementProofInput, ExceptionInfo, ExceptionType, Expression, ExpressionGeneric, ExpressionGenericInput, ExpressionProof, ExpressionProofInput, ExpressionRef, ExpressionRendered, Flag, Icon, ImportResult, ImportStats, InstanceQuery, InteractionCall, InteractionMeta, InteractionParameter, LanguageExpression, LanguageHandle, LanguageLanguageInput, LanguageMeta, LanguageMetaInput, LanguageMetaInternal, LanguageRef, Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations, LinkQuery, Literal, ModelOptions, ModelQueryBuilder, Neighbourhood, NeighbourhoodExpression, NeighbourhoodProxy, Notification, NotificationInput, OnlineAgent, Optional, Perspective, PerspectiveAction, PerspectiveDiff, PerspectiveDiffExpression, PerspectiveExpression, PerspectiveHandle, PerspectiveInput, PerspectiveProxy, PerspectiveState, PerspectiveUnsignedInput, Property, QuerySubscriptionProxy, ReadOnly, Resource, ResourceInput, RuntimeInfo, SMART_LITERAL_CONTENT_PREDICATE, SentMessage, SmartLiteral, Subject, TriggeredNotification, addLink, capSentence, exprRef2String, formatList, hasLink, isExpression, isLink, linkEqual, makeRandomPrologAtom, parseExprUrl, typeDefsString };
|
|
@@ -118,7 +118,6 @@ export interface GetAllAdapter {
|
|
|
118
118
|
}
|
|
119
119
|
export type PerspectiveDiffObserver = (diff: PerspectiveDiff) => void;
|
|
120
120
|
export type SyncStateChangeObserver = (state: PerspectiveState) => void;
|
|
121
|
-
export type DebugStringObserver = (debugString: string, operation: string) => void;
|
|
122
121
|
/** Interface for "Link Languages" that facilitate the synchronization
|
|
123
122
|
* between agents' local Perspectives inside a Neighbourhood.
|
|
124
123
|
* The assumption is that every version of the shared Perspective
|
|
@@ -149,8 +148,6 @@ export interface LinkSyncAdapter {
|
|
|
149
148
|
addCallback(callback: PerspectiveDiffObserver): any;
|
|
150
149
|
/** Add a sync state callback method */
|
|
151
150
|
addSyncStateChangeCallback(callback: SyncStateChangeObserver): any;
|
|
152
|
-
/** Add a debug string callback method for capturing internal debug information */
|
|
153
|
-
addDebugStringCallback?(callback: DebugStringObserver): any;
|
|
154
151
|
}
|
|
155
152
|
export type MessageCallback = (message: PerspectiveExpression) => void;
|
|
156
153
|
export type StatusCallback = (caller: DID) => Perspective;
|
|
@@ -314,11 +314,38 @@ export class Ad4mModel {
|
|
|
314
314
|
// Map properties to object
|
|
315
315
|
const propsObject = Object.fromEntries(await Promise.all(values.map(async ([name, value, resolve]) => {
|
|
316
316
|
let finalValue = value;
|
|
317
|
+
// Handle UTF-8 byte sequences from Prolog URL decoding
|
|
318
|
+
if (!resolve && typeof value === 'string') {
|
|
319
|
+
// Only attempt reconstruction if the string looks like a byte string (all code points <= 0xFF)
|
|
320
|
+
// and contains at least one high byte (>= 0x80). This avoids mangling valid Unicode.
|
|
321
|
+
const codePoints = Array.from(value, ch => ch.codePointAt(0));
|
|
322
|
+
const looksByteString = codePoints.every(cp => cp <= 0xFF);
|
|
323
|
+
const hasHighByte = codePoints.some(cp => cp >= 0x80);
|
|
324
|
+
if (looksByteString && hasHighByte) {
|
|
325
|
+
try {
|
|
326
|
+
const bytes = Uint8Array.from(codePoints);
|
|
327
|
+
const decoded = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
328
|
+
if (decoded !== value)
|
|
329
|
+
finalValue = decoded;
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
// If UTF-8 conversion fails, keep the original value
|
|
333
|
+
console.warn(`UTF-8 byte reconstruction failed for property "${name}"`, { value, error });
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
317
337
|
// Resolve the value if necessary
|
|
318
338
|
if (resolve) {
|
|
319
339
|
let resolvedExpression = await perspective.getExpression(value);
|
|
320
340
|
if (resolvedExpression) {
|
|
321
|
-
|
|
341
|
+
try {
|
|
342
|
+
// Attempt to parse the data as JSON
|
|
343
|
+
finalValue = JSON.parse(resolvedExpression.data);
|
|
344
|
+
}
|
|
345
|
+
catch (error) {
|
|
346
|
+
// If parsing fails, keep the original data
|
|
347
|
+
finalValue = resolvedExpression.data;
|
|
348
|
+
}
|
|
322
349
|
}
|
|
323
350
|
}
|
|
324
351
|
// Apply transform function if it exists
|
|
@@ -252,9 +252,6 @@ export class NeighbourhoodClient {
|
|
|
252
252
|
const index = handlersForPerspective.indexOf(handler);
|
|
253
253
|
if (index > -1) {
|
|
254
254
|
handlersForPerspective.splice(index, 1);
|
|
255
|
-
if (!handlersForPerspective.length) {
|
|
256
|
-
__classPrivateFieldGet(this, _NeighbourhoodClient_signalHandlers, "f").delete(perspectiveUUID);
|
|
257
|
-
}
|
|
258
255
|
}
|
|
259
256
|
}
|
|
260
257
|
}
|
|
@@ -28,4 +28,46 @@ describe("NeighbourhoodProxy", () => {
|
|
|
28
28
|
neighbourhoodClient.dispatchSignal(neighbourhoodURI, true);
|
|
29
29
|
expect(callbacks).toBe(2);
|
|
30
30
|
});
|
|
31
|
+
it("should not add multiple subscriptions when removing and adding another signal handler", async () => {
|
|
32
|
+
const neighbourhoodURI = "did://123";
|
|
33
|
+
const subscriptions = [];
|
|
34
|
+
const subscribe = (args) => {
|
|
35
|
+
subscriptions.push(args);
|
|
36
|
+
new Promise((resolve) => {
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
resolve({});
|
|
39
|
+
}, 10);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const mockApolloClient = {
|
|
43
|
+
subscribe: () => ({
|
|
44
|
+
subscribe,
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
const neighbourhoodClient = new NeighbourhoodClient(mockApolloClient);
|
|
48
|
+
const neighbourhoodProxy = new NeighbourhoodProxy(neighbourhoodClient, neighbourhoodURI);
|
|
49
|
+
let callbacks1 = 0;
|
|
50
|
+
let callbacks2 = 0;
|
|
51
|
+
const handler1 = () => {
|
|
52
|
+
callbacks1++;
|
|
53
|
+
};
|
|
54
|
+
const handler2 = () => {
|
|
55
|
+
callbacks2++;
|
|
56
|
+
};
|
|
57
|
+
// Add signal handler 1
|
|
58
|
+
await neighbourhoodProxy.addSignalHandler(handler1);
|
|
59
|
+
// Remove signal handler 2
|
|
60
|
+
neighbourhoodProxy.removeSignalHandler(handler1);
|
|
61
|
+
// Add signal handler 2
|
|
62
|
+
await neighbourhoodProxy.addSignalHandler(handler2);
|
|
63
|
+
// Check that only one subscription was added
|
|
64
|
+
expect(subscriptions.length).toBe(1);
|
|
65
|
+
// mock trigger signal event
|
|
66
|
+
for (const subscription of subscriptions) {
|
|
67
|
+
subscription.next({ data: { signal: { neighbourhoodSignal: true } } });
|
|
68
|
+
}
|
|
69
|
+
// Check that only our second callback was called
|
|
70
|
+
expect(callbacks1).toBe(0);
|
|
71
|
+
expect(callbacks2).toBe(1);
|
|
72
|
+
});
|
|
31
73
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
|
|
2
2
|
export declare enum PerspectiveState {
|
|
3
|
-
Private = "
|
|
4
|
-
NeighboudhoodCreationInitiated = "
|
|
5
|
-
NeighbourhoodJoinInitiated = "
|
|
6
|
-
LinkLanguageFailedToInstall = "
|
|
7
|
-
LinkLanguageInstalledButNotSynced = "
|
|
8
|
-
Synced = "
|
|
3
|
+
Private = "PRIVATE",
|
|
4
|
+
NeighboudhoodCreationInitiated = "NEIGHBOURHOOD_CREATION_INITIATED",
|
|
5
|
+
NeighbourhoodJoinInitiated = "NEIGHBOURHOOD_JOIN_INITIATED",
|
|
6
|
+
LinkLanguageFailedToInstall = "LINK_LANGUAGE_FAILED_TO_INSTALL",
|
|
7
|
+
LinkLanguageInstalledButNotSynced = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED",
|
|
8
|
+
Synced = "SYNCED"
|
|
9
9
|
}
|
|
10
10
|
export declare class PerspectiveHandle {
|
|
11
11
|
uuid: string;
|
|
@@ -11,12 +11,12 @@ import { Field, ObjectType } from "type-graphql";
|
|
|
11
11
|
import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
|
|
12
12
|
export var PerspectiveState;
|
|
13
13
|
(function (PerspectiveState) {
|
|
14
|
-
PerspectiveState["Private"] = "
|
|
15
|
-
PerspectiveState["NeighboudhoodCreationInitiated"] = "
|
|
16
|
-
PerspectiveState["NeighbourhoodJoinInitiated"] = "
|
|
17
|
-
PerspectiveState["LinkLanguageFailedToInstall"] = "
|
|
18
|
-
PerspectiveState["LinkLanguageInstalledButNotSynced"] = "
|
|
19
|
-
PerspectiveState["Synced"] = "
|
|
14
|
+
PerspectiveState["Private"] = "PRIVATE";
|
|
15
|
+
PerspectiveState["NeighboudhoodCreationInitiated"] = "NEIGHBOURHOOD_CREATION_INITIATED";
|
|
16
|
+
PerspectiveState["NeighbourhoodJoinInitiated"] = "NEIGHBOURHOOD_JOIN_INITIATED";
|
|
17
|
+
PerspectiveState["LinkLanguageFailedToInstall"] = "LINK_LANGUAGE_FAILED_TO_INSTALL";
|
|
18
|
+
PerspectiveState["LinkLanguageInstalledButNotSynced"] = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED";
|
|
19
|
+
PerspectiveState["Synced"] = "SYNCED";
|
|
20
20
|
})(PerspectiveState || (PerspectiveState = {}));
|
|
21
21
|
// This type is used in the GraphQL interface to reference a mutable
|
|
22
22
|
// prespective that is implemented locally by the Ad4m runtime.
|
|
@@ -482,6 +482,10 @@ export declare class PerspectiveProxy {
|
|
|
482
482
|
* This will return all SDNA code elements in an array.
|
|
483
483
|
*/
|
|
484
484
|
getSdna(): Promise<string[]>;
|
|
485
|
+
/** Returns the Social DNA code for a specific class
|
|
486
|
+
* This will return the SDNA code for the specified class, or null if not found.
|
|
487
|
+
*/
|
|
488
|
+
getSdnaForClass(className: string): Promise<string | null>;
|
|
485
489
|
/** Adds the given Social DNA code to the perspective's SDNA code */
|
|
486
490
|
addSdna(name: string, sdnaCode: string, sdnaType: "subject_class" | "flow" | "custom"): Promise<boolean>;
|
|
487
491
|
/** Returns all the Subject classes defined in this perspectives SDNA */
|
|
@@ -703,10 +703,63 @@ export class PerspectiveProxy {
|
|
|
703
703
|
* This will return all SDNA code elements in an array.
|
|
704
704
|
*/
|
|
705
705
|
async getSdna() {
|
|
706
|
-
|
|
706
|
+
// First, find all the name literals that are linked from ad4m://self with SDNA predicates
|
|
707
|
+
const sdnaPredicates = [
|
|
708
|
+
"ad4m://has_subject_class",
|
|
709
|
+
"ad4m://has_flow",
|
|
710
|
+
"ad4m://has_custom_sdna"
|
|
711
|
+
];
|
|
712
|
+
const allSdnaCode = [];
|
|
713
|
+
for (const predicate of sdnaPredicates) {
|
|
714
|
+
// Find name literals linked from ad4m://self with this predicate
|
|
715
|
+
const nameLinks = await this.get(new LinkQuery({
|
|
716
|
+
source: "ad4m://self",
|
|
717
|
+
predicate: predicate
|
|
718
|
+
}));
|
|
719
|
+
// For each name literal found, get the actual SDNA code
|
|
720
|
+
for (const nameLink of nameLinks) {
|
|
721
|
+
const nameLiteral = nameLink.data.target;
|
|
722
|
+
// Now find the SDNA code linked from this name with predicate "ad4m://sdna"
|
|
723
|
+
const sdnaLinks = await this.get(new LinkQuery({
|
|
724
|
+
source: nameLiteral,
|
|
725
|
+
predicate: "ad4m://sdna"
|
|
726
|
+
}));
|
|
727
|
+
// Extract the SDNA code from each link
|
|
728
|
+
for (const sdnaLink of sdnaLinks) {
|
|
729
|
+
const code = Literal.fromUrl(sdnaLink.data.target).get();
|
|
730
|
+
if (typeof code === 'string') {
|
|
731
|
+
allSdnaCode.push(code);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return allSdnaCode;
|
|
737
|
+
}
|
|
738
|
+
/** Returns the Social DNA code for a specific class
|
|
739
|
+
* This will return the SDNA code for the specified class, or null if not found.
|
|
740
|
+
*/
|
|
741
|
+
async getSdnaForClass(className) {
|
|
742
|
+
// First, find the name literal for this class that is linked from ad4m://self
|
|
743
|
+
const nameLiteral = Literal.from(className);
|
|
744
|
+
const links = await this.get(new LinkQuery({
|
|
745
|
+
source: "ad4m://self",
|
|
746
|
+
target: nameLiteral.toUrl(),
|
|
747
|
+
predicate: "ad4m://has_subject_class"
|
|
748
|
+
}));
|
|
749
|
+
if (links.length === 0) {
|
|
750
|
+
return null;
|
|
751
|
+
}
|
|
752
|
+
// Now find the SDNA code linked from this name with predicate "ad4m://sdna"
|
|
753
|
+
const sdnaLinks = await this.get(new LinkQuery({
|
|
754
|
+
source: nameLiteral.toUrl(),
|
|
707
755
|
predicate: "ad4m://sdna"
|
|
708
756
|
}));
|
|
709
|
-
|
|
757
|
+
if (sdnaLinks.length === 0) {
|
|
758
|
+
return null;
|
|
759
|
+
}
|
|
760
|
+
// Extract the SDNA code from the first link
|
|
761
|
+
const code = Literal.fromUrl(sdnaLinks[0].data.target).get();
|
|
762
|
+
return typeof code === 'string' ? code : null;
|
|
710
763
|
}
|
|
711
764
|
/** Adds the given Social DNA code to the perspective's SDNA code */
|
|
712
765
|
async addSdna(name, sdnaCode, sdnaType) {
|
|
@@ -887,7 +940,11 @@ export class PerspectiveProxy {
|
|
|
887
940
|
}
|
|
888
941
|
// Collect all collections of the object in a list
|
|
889
942
|
if (Object.getPrototypeOf(obj).__collections) {
|
|
890
|
-
Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c =>
|
|
943
|
+
Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c => {
|
|
944
|
+
if (!collections.includes(c)) {
|
|
945
|
+
collections.push(c);
|
|
946
|
+
}
|
|
947
|
+
});
|
|
891
948
|
}
|
|
892
949
|
else {
|
|
893
950
|
collections.push(...Object.keys(obj).filter(key => Array.isArray(obj[key])).filter(key => key !== 'isSubjectInstance'));
|
|
@@ -22,7 +22,6 @@ export declare class RuntimeClient {
|
|
|
22
22
|
friends(): Promise<string[]>;
|
|
23
23
|
hcAgentInfos(): Promise<string>;
|
|
24
24
|
getNetworkMetrics(): Promise<string>;
|
|
25
|
-
debugStrings(languageAddress?: string): Promise<any[]>;
|
|
26
25
|
restartHolochain(): Promise<boolean>;
|
|
27
26
|
hcAddAgentInfos(agentInfos: String): Promise<void>;
|
|
28
27
|
verifyStringSignedByDid(did: string, didSigningKeyId: string, data: string, signedData: string): Promise<boolean>;
|
|
@@ -183,20 +183,6 @@ export class RuntimeClient {
|
|
|
183
183
|
}));
|
|
184
184
|
return runtimeGetNetworkMetrics;
|
|
185
185
|
}
|
|
186
|
-
async debugStrings(languageAddress) {
|
|
187
|
-
const { runtimeDebugStrings } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").query({
|
|
188
|
-
query: gql `query runtimeDebugStrings($languageAddress: String) {
|
|
189
|
-
runtimeDebugStrings(languageAddress: $languageAddress) {
|
|
190
|
-
languageAddress
|
|
191
|
-
operation
|
|
192
|
-
debugString
|
|
193
|
-
timestamp
|
|
194
|
-
}
|
|
195
|
-
}`,
|
|
196
|
-
variables: { languageAddress }
|
|
197
|
-
}));
|
|
198
|
-
return runtimeDebugStrings;
|
|
199
|
-
}
|
|
200
186
|
async restartHolochain() {
|
|
201
187
|
const { runtimeRestartHolochain } = unwrapApolloResult(await __classPrivateFieldGet(this, _RuntimeClient_apolloClient, "f").mutate({
|
|
202
188
|
mutation: gql `mutation runtimeRestartHolochain {
|
|
@@ -42,12 +42,6 @@ export declare class TriggeredNotification {
|
|
|
42
42
|
perspectiveId: string;
|
|
43
43
|
triggerMatch: string;
|
|
44
44
|
}
|
|
45
|
-
export declare class DebugStringEntry {
|
|
46
|
-
languageAddress: string;
|
|
47
|
-
debugString: string;
|
|
48
|
-
operation: string;
|
|
49
|
-
timestamp: string;
|
|
50
|
-
}
|
|
51
45
|
export declare class ImportStats {
|
|
52
46
|
total: number;
|
|
53
47
|
imported: number;
|
|
@@ -82,7 +76,6 @@ export default class RuntimeResolver {
|
|
|
82
76
|
deleteTrustedAgents(agents: string[]): string[];
|
|
83
77
|
getTrustedAgents(): string[];
|
|
84
78
|
runtimeKnownLinkLanguageTemplates(): string[];
|
|
85
|
-
runtimeDebugStrings(languageAddress?: string): DebugStringEntry[];
|
|
86
79
|
runtimeAddKnownLinkLanguageTemplates(addresses: string[]): string[];
|
|
87
80
|
runtimeRemoveKnownLinkLanguageTemplates(addresses: string[]): string[];
|
|
88
81
|
runtimeFriends(): string[];
|
|
@@ -194,28 +194,6 @@ TriggeredNotification = __decorate([
|
|
|
194
194
|
ObjectType()
|
|
195
195
|
], TriggeredNotification);
|
|
196
196
|
export { TriggeredNotification };
|
|
197
|
-
let DebugStringEntry = class DebugStringEntry {
|
|
198
|
-
};
|
|
199
|
-
__decorate([
|
|
200
|
-
Field(),
|
|
201
|
-
__metadata("design:type", String)
|
|
202
|
-
], DebugStringEntry.prototype, "languageAddress", void 0);
|
|
203
|
-
__decorate([
|
|
204
|
-
Field(),
|
|
205
|
-
__metadata("design:type", String)
|
|
206
|
-
], DebugStringEntry.prototype, "debugString", void 0);
|
|
207
|
-
__decorate([
|
|
208
|
-
Field(),
|
|
209
|
-
__metadata("design:type", String)
|
|
210
|
-
], DebugStringEntry.prototype, "operation", void 0);
|
|
211
|
-
__decorate([
|
|
212
|
-
Field(),
|
|
213
|
-
__metadata("design:type", String)
|
|
214
|
-
], DebugStringEntry.prototype, "timestamp", void 0);
|
|
215
|
-
DebugStringEntry = __decorate([
|
|
216
|
-
ObjectType()
|
|
217
|
-
], DebugStringEntry);
|
|
218
|
-
export { DebugStringEntry };
|
|
219
197
|
let ImportStats = class ImportStats {
|
|
220
198
|
};
|
|
221
199
|
__decorate([
|
|
@@ -324,15 +302,6 @@ let RuntimeResolver = class RuntimeResolver {
|
|
|
324
302
|
runtimeKnownLinkLanguageTemplates() {
|
|
325
303
|
return ["Qm12345abcdef"];
|
|
326
304
|
}
|
|
327
|
-
runtimeDebugStrings(languageAddress) {
|
|
328
|
-
// Mock data for testing - in real implementation this would come from stored debug strings
|
|
329
|
-
return [{
|
|
330
|
-
languageAddress: "Qm123example",
|
|
331
|
-
debugString: "Debug string content",
|
|
332
|
-
operation: "merge",
|
|
333
|
-
timestamp: new Date().toISOString()
|
|
334
|
-
}];
|
|
335
|
-
}
|
|
336
305
|
runtimeAddKnownLinkLanguageTemplates(addresses) {
|
|
337
306
|
return addresses;
|
|
338
307
|
}
|
|
@@ -496,13 +465,6 @@ __decorate([
|
|
|
496
465
|
__metadata("design:paramtypes", []),
|
|
497
466
|
__metadata("design:returntype", Array)
|
|
498
467
|
], RuntimeResolver.prototype, "runtimeKnownLinkLanguageTemplates", null);
|
|
499
|
-
__decorate([
|
|
500
|
-
Query(returns => [DebugStringEntry]),
|
|
501
|
-
__param(0, Arg("languageAddress", type => String, { nullable: true })),
|
|
502
|
-
__metadata("design:type", Function),
|
|
503
|
-
__metadata("design:paramtypes", [String]),
|
|
504
|
-
__metadata("design:returntype", Array)
|
|
505
|
-
], RuntimeResolver.prototype, "runtimeDebugStrings", null);
|
|
506
468
|
__decorate([
|
|
507
469
|
Mutation(returns => [String]),
|
|
508
470
|
__param(0, Arg("addresses", type => [String])),
|
package/lib/src/schema.gql
CHANGED
|
@@ -96,13 +96,6 @@ input CapabilityInput {
|
|
|
96
96
|
# The javascript `Date` as string. Type represents date and time as the ISO Date string.
|
|
97
97
|
scalar DateTime
|
|
98
98
|
|
|
99
|
-
type DebugStringEntry {
|
|
100
|
-
debugString: String!
|
|
101
|
-
languageAddress: String!
|
|
102
|
-
operation: String!
|
|
103
|
-
timestamp: String!
|
|
104
|
-
}
|
|
105
|
-
|
|
106
99
|
type EntanglementProof {
|
|
107
100
|
deviceKey: String!
|
|
108
101
|
deviceKeySignedByDid: String!
|
|
@@ -479,7 +472,6 @@ type Query {
|
|
|
479
472
|
perspectiveQueryProlog(query: String!, uuid: String!): String!
|
|
480
473
|
perspectiveSnapshot(uuid: String!): Perspective
|
|
481
474
|
perspectives: [PerspectiveHandle!]!
|
|
482
|
-
runtimeDebugStrings(languageAddress: String): [DebugStringEntry!]!
|
|
483
475
|
runtimeFriendStatus(did: String!): PerspectiveExpression
|
|
484
476
|
runtimeFriends: [String!]!
|
|
485
477
|
runtimeGetNetworkMetrics: String!
|
package/lib/src/typeDefs.js
CHANGED
|
@@ -92,13 +92,6 @@ input CapabilityInput {
|
|
|
92
92
|
|
|
93
93
|
scalar DateTime
|
|
94
94
|
|
|
95
|
-
type DebugStringEntry {
|
|
96
|
-
debugString: String!
|
|
97
|
-
languageAddress: String!
|
|
98
|
-
operation: String!
|
|
99
|
-
timestamp: String!
|
|
100
|
-
}
|
|
101
|
-
|
|
102
95
|
type EntanglementProof {
|
|
103
96
|
deviceKey: String!
|
|
104
97
|
deviceKeySignedByDid: String!
|
|
@@ -475,7 +468,6 @@ type Query {
|
|
|
475
468
|
perspectiveQueryProlog(query: String!, uuid: String!): String!
|
|
476
469
|
perspectiveSnapshot(uuid: String!): Perspective
|
|
477
470
|
perspectives: [PerspectiveHandle!]!
|
|
478
|
-
runtimeDebugStrings(languageAddress: String): [DebugStringEntry!]!
|
|
479
471
|
runtimeFriendStatus(did: String!): PerspectiveExpression
|
|
480
472
|
runtimeFriends: [String!]!
|
|
481
473
|
runtimeGetNetworkMetrics: String!
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"types": "lib/src/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
|
-
|
|
8
|
+
"private": false,
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "patch-package && tsc && pnpm run buildSchema && pnpm run bundle",
|
|
11
11
|
"buildSchema": "node --es-module-specifier-resolution=node lib/src/buildSchema.js",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"graphql@15.7.2": "patches/graphql@15.7.2.patch"
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
|
-
"version": "0.10.1-release-candidate-
|
|
72
|
+
"version": "0.10.1-release-candidate-5"
|
|
73
73
|
}
|
package/src/language/Language.ts
CHANGED
|
@@ -148,9 +148,8 @@ export interface GetAllAdapter {
|
|
|
148
148
|
getAll(filter: any, count: number, page: number): Promise<Expression[] | null>;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
export type PerspectiveDiffObserver = (diff: PerspectiveDiff)
|
|
152
|
-
export type SyncStateChangeObserver = (state: PerspectiveState)
|
|
153
|
-
export type DebugStringObserver = (debugString: string, operation: string) => void;
|
|
151
|
+
export type PerspectiveDiffObserver = (diff: PerspectiveDiff)=>void;
|
|
152
|
+
export type SyncStateChangeObserver = (state: PerspectiveState)=>void;
|
|
154
153
|
|
|
155
154
|
/** Interface for "Link Languages" that facilitate the synchronization
|
|
156
155
|
* between agents' local Perspectives inside a Neighbourhood.
|
|
@@ -188,9 +187,6 @@ export interface LinkSyncAdapter {
|
|
|
188
187
|
|
|
189
188
|
/** Add a sync state callback method */
|
|
190
189
|
addSyncStateChangeCallback(callback: SyncStateChangeObserver);
|
|
191
|
-
|
|
192
|
-
/** Add a debug string callback method for capturing internal debug information */
|
|
193
|
-
addDebugStringCallback?(callback: DebugStringObserver);
|
|
194
190
|
}
|
|
195
191
|
|
|
196
192
|
export type MessageCallback = (message: PerspectiveExpression) => void;
|
package/src/model/Ad4mModel.ts
CHANGED
|
@@ -345,21 +345,43 @@ export class Ad4mModel {
|
|
|
345
345
|
return this.#perspective;
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
-
public static async assignValuesToInstance(
|
|
349
|
-
perspective: PerspectiveProxy,
|
|
350
|
-
instance: Ad4mModel,
|
|
351
|
-
values: ValueTuple[]
|
|
352
|
-
) {
|
|
348
|
+
public static async assignValuesToInstance(perspective: PerspectiveProxy, instance: Ad4mModel, values: ValueTuple[]) {
|
|
353
349
|
// Map properties to object
|
|
354
350
|
const propsObject = Object.fromEntries(
|
|
355
351
|
await Promise.all(
|
|
356
352
|
values.map(async ([name, value, resolve]) => {
|
|
357
353
|
let finalValue = value;
|
|
354
|
+
|
|
355
|
+
// Handle UTF-8 byte sequences from Prolog URL decoding
|
|
356
|
+
if (!resolve && typeof value === 'string') {
|
|
357
|
+
// Only attempt reconstruction if the string looks like a byte string (all code points <= 0xFF)
|
|
358
|
+
// and contains at least one high byte (>= 0x80). This avoids mangling valid Unicode.
|
|
359
|
+
const codePoints = Array.from(value, ch => ch.codePointAt(0)!);
|
|
360
|
+
const looksByteString = codePoints.every(cp => cp <= 0xFF);
|
|
361
|
+
const hasHighByte = codePoints.some(cp => cp >= 0x80);
|
|
362
|
+
if (looksByteString && hasHighByte) {
|
|
363
|
+
try {
|
|
364
|
+
const bytes = Uint8Array.from(codePoints);
|
|
365
|
+
const decoded = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
366
|
+
if (decoded !== value) finalValue = decoded;
|
|
367
|
+
} catch (error) {
|
|
368
|
+
// If UTF-8 conversion fails, keep the original value
|
|
369
|
+
console.warn(`UTF-8 byte reconstruction failed for property "${name}"`, { value, error });
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
358
374
|
// Resolve the value if necessary
|
|
359
375
|
if (resolve) {
|
|
360
376
|
let resolvedExpression = await perspective.getExpression(value);
|
|
361
377
|
if (resolvedExpression) {
|
|
362
|
-
|
|
378
|
+
try {
|
|
379
|
+
// Attempt to parse the data as JSON
|
|
380
|
+
finalValue = JSON.parse(resolvedExpression.data);
|
|
381
|
+
} catch (error) {
|
|
382
|
+
// If parsing fails, keep the original data
|
|
383
|
+
finalValue = resolvedExpression.data;
|
|
384
|
+
}
|
|
363
385
|
}
|
|
364
386
|
}
|
|
365
387
|
// Apply transform function if it exists
|
|
@@ -273,9 +273,6 @@ export class NeighbourhoodClient {
|
|
|
273
273
|
const index = handlersForPerspective.indexOf(handler)
|
|
274
274
|
if (index > -1) {
|
|
275
275
|
handlersForPerspective.splice(index, 1)
|
|
276
|
-
if (!handlersForPerspective.length) {
|
|
277
|
-
this.#signalHandlers.delete(perspectiveUUID)
|
|
278
|
-
}
|
|
279
276
|
}
|
|
280
277
|
}
|
|
281
278
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ApolloClient } from "@apollo/client";
|
|
2
|
-
import { LinkExpression } from "../links/Links";
|
|
3
1
|
import { NeighbourhoodClient } from "./NeighbourhoodClient";
|
|
4
2
|
import { NeighbourhoodProxy } from "./NeighbourhoodProxy";
|
|
5
3
|
|
|
@@ -42,4 +40,61 @@ describe("NeighbourhoodProxy", () => {
|
|
|
42
40
|
|
|
43
41
|
expect(callbacks).toBe(2);
|
|
44
42
|
});
|
|
43
|
+
|
|
44
|
+
it("should not add multiple subscriptions when removing and adding another signal handler", async () => {
|
|
45
|
+
const neighbourhoodURI = "did://123";
|
|
46
|
+
|
|
47
|
+
const subscriptions = [];
|
|
48
|
+
const subscribe = (args: { next: (result: any) => void }) => {
|
|
49
|
+
subscriptions.push(args);
|
|
50
|
+
new Promise((resolve) => {
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
resolve({});
|
|
53
|
+
}, 10);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const mockApolloClient = {
|
|
58
|
+
subscribe: () => ({
|
|
59
|
+
subscribe,
|
|
60
|
+
}),
|
|
61
|
+
} as any;
|
|
62
|
+
|
|
63
|
+
const neighbourhoodClient = new NeighbourhoodClient(mockApolloClient);
|
|
64
|
+
const neighbourhoodProxy = new NeighbourhoodProxy(
|
|
65
|
+
neighbourhoodClient,
|
|
66
|
+
neighbourhoodURI
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
let callbacks1 = 0;
|
|
70
|
+
let callbacks2 = 0;
|
|
71
|
+
|
|
72
|
+
const handler1 = () => {
|
|
73
|
+
callbacks1++;
|
|
74
|
+
};
|
|
75
|
+
const handler2 = () => {
|
|
76
|
+
callbacks2++;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Add signal handler 1
|
|
80
|
+
await neighbourhoodProxy.addSignalHandler(handler1);
|
|
81
|
+
|
|
82
|
+
// Remove signal handler 2
|
|
83
|
+
neighbourhoodProxy.removeSignalHandler(handler1);
|
|
84
|
+
|
|
85
|
+
// Add signal handler 2
|
|
86
|
+
await neighbourhoodProxy.addSignalHandler(handler2);
|
|
87
|
+
|
|
88
|
+
// Check that only one subscription was added
|
|
89
|
+
expect(subscriptions.length).toBe(1);
|
|
90
|
+
|
|
91
|
+
// mock trigger signal event
|
|
92
|
+
for (const subscription of subscriptions) {
|
|
93
|
+
subscription.next({ data: { signal: { neighbourhoodSignal: true } } });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Check that only our second callback was called
|
|
97
|
+
expect(callbacks1).toBe(0);
|
|
98
|
+
expect(callbacks2).toBe(1);
|
|
99
|
+
});
|
|
45
100
|
});
|
|
@@ -2,12 +2,12 @@ import { Field, ObjectType } from "type-graphql";
|
|
|
2
2
|
import { NeighbourhoodExpression } from "../neighbourhood/Neighbourhood";
|
|
3
3
|
|
|
4
4
|
export enum PerspectiveState {
|
|
5
|
-
Private = "
|
|
6
|
-
NeighboudhoodCreationInitiated = "
|
|
7
|
-
NeighbourhoodJoinInitiated = "
|
|
8
|
-
LinkLanguageFailedToInstall = "
|
|
9
|
-
LinkLanguageInstalledButNotSynced = "
|
|
10
|
-
Synced = "
|
|
5
|
+
Private = "PRIVATE",
|
|
6
|
+
NeighboudhoodCreationInitiated = "NEIGHBOURHOOD_CREATION_INITIATED",
|
|
7
|
+
NeighbourhoodJoinInitiated = "NEIGHBOURHOOD_JOIN_INITIATED",
|
|
8
|
+
LinkLanguageFailedToInstall = "LINK_LANGUAGE_FAILED_TO_INSTALL",
|
|
9
|
+
LinkLanguageInstalledButNotSynced = "LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED",
|
|
10
|
+
Synced = "SYNCED",
|
|
11
11
|
}
|
|
12
12
|
// This type is used in the GraphQL interface to reference a mutable
|
|
13
13
|
// prespective that is implemented locally by the Ad4m runtime.
|
|
@@ -782,11 +782,75 @@ export class PerspectiveProxy {
|
|
|
782
782
|
* This will return all SDNA code elements in an array.
|
|
783
783
|
*/
|
|
784
784
|
async getSdna(): Promise<string[]> {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
785
|
+
// First, find all the name literals that are linked from ad4m://self with SDNA predicates
|
|
786
|
+
const sdnaPredicates = [
|
|
787
|
+
"ad4m://has_subject_class",
|
|
788
|
+
"ad4m://has_flow",
|
|
789
|
+
"ad4m://has_custom_sdna"
|
|
790
|
+
];
|
|
791
|
+
|
|
792
|
+
const allSdnaCode: string[] = [];
|
|
793
|
+
|
|
794
|
+
for (const predicate of sdnaPredicates) {
|
|
795
|
+
// Find name literals linked from ad4m://self with this predicate
|
|
796
|
+
const nameLinks = await this.get(new LinkQuery({
|
|
797
|
+
source: "ad4m://self",
|
|
798
|
+
predicate: predicate
|
|
799
|
+
}));
|
|
800
|
+
|
|
801
|
+
// For each name literal found, get the actual SDNA code
|
|
802
|
+
for (const nameLink of nameLinks) {
|
|
803
|
+
const nameLiteral = nameLink.data.target;
|
|
804
|
+
|
|
805
|
+
// Now find the SDNA code linked from this name with predicate "ad4m://sdna"
|
|
806
|
+
const sdnaLinks = await this.get(new LinkQuery({
|
|
807
|
+
source: nameLiteral,
|
|
808
|
+
predicate: "ad4m://sdna"
|
|
809
|
+
}));
|
|
810
|
+
|
|
811
|
+
// Extract the SDNA code from each link
|
|
812
|
+
for (const sdnaLink of sdnaLinks) {
|
|
813
|
+
const code = Literal.fromUrl(sdnaLink.data.target).get();
|
|
814
|
+
if (typeof code === 'string') {
|
|
815
|
+
allSdnaCode.push(code);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
return allSdnaCode;
|
|
822
|
+
}
|
|
788
823
|
|
|
789
|
-
|
|
824
|
+
/** Returns the Social DNA code for a specific class
|
|
825
|
+
* This will return the SDNA code for the specified class, or null if not found.
|
|
826
|
+
*/
|
|
827
|
+
async getSdnaForClass(className: string): Promise<string | null> {
|
|
828
|
+
// First, find the name literal for this class that is linked from ad4m://self
|
|
829
|
+
const nameLiteral = Literal.from(className);
|
|
830
|
+
|
|
831
|
+
const links = await this.get(new LinkQuery({
|
|
832
|
+
source: "ad4m://self",
|
|
833
|
+
target: nameLiteral.toUrl(),
|
|
834
|
+
predicate: "ad4m://has_subject_class"
|
|
835
|
+
}));
|
|
836
|
+
|
|
837
|
+
if (links.length === 0) {
|
|
838
|
+
return null;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// Now find the SDNA code linked from this name with predicate "ad4m://sdna"
|
|
842
|
+
const sdnaLinks = await this.get(new LinkQuery({
|
|
843
|
+
source: nameLiteral.toUrl(),
|
|
844
|
+
predicate: "ad4m://sdna"
|
|
845
|
+
}));
|
|
846
|
+
|
|
847
|
+
if (sdnaLinks.length === 0) {
|
|
848
|
+
return null;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// Extract the SDNA code from the first link
|
|
852
|
+
const code = Literal.fromUrl(sdnaLinks[0].data.target).get();
|
|
853
|
+
return typeof code === 'string' ? code : null;
|
|
790
854
|
}
|
|
791
855
|
|
|
792
856
|
/** Adds the given Social DNA code to the perspective's SDNA code */
|
|
@@ -1002,7 +1066,11 @@ export class PerspectiveProxy {
|
|
|
1002
1066
|
|
|
1003
1067
|
// Collect all collections of the object in a list
|
|
1004
1068
|
if (Object.getPrototypeOf(obj).__collections) {
|
|
1005
|
-
Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c =>
|
|
1069
|
+
Object.keys(Object.getPrototypeOf(obj).__collections).filter(key => key !== 'isSubjectInstance').forEach(c => {
|
|
1070
|
+
if (!collections.includes(c)) {
|
|
1071
|
+
collections.push(c);
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1006
1074
|
} else {
|
|
1007
1075
|
collections.push(...Object.keys(obj).filter(key => Array.isArray(obj[key])).filter(key => key !== 'isSubjectInstance'))
|
|
1008
1076
|
}
|
|
@@ -201,21 +201,6 @@ export class RuntimeClient {
|
|
|
201
201
|
return runtimeGetNetworkMetrics
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
async debugStrings(languageAddress?: string): Promise<any[]> {
|
|
205
|
-
const { runtimeDebugStrings } = unwrapApolloResult(await this.#apolloClient.query({
|
|
206
|
-
query: gql`query runtimeDebugStrings($languageAddress: String) {
|
|
207
|
-
runtimeDebugStrings(languageAddress: $languageAddress) {
|
|
208
|
-
languageAddress
|
|
209
|
-
operation
|
|
210
|
-
debugString
|
|
211
|
-
timestamp
|
|
212
|
-
}
|
|
213
|
-
}`,
|
|
214
|
-
variables: { languageAddress }
|
|
215
|
-
}))
|
|
216
|
-
return runtimeDebugStrings
|
|
217
|
-
}
|
|
218
|
-
|
|
219
204
|
async restartHolochain(): Promise<boolean> {
|
|
220
205
|
const { runtimeRestartHolochain } = unwrapApolloResult(await this.#apolloClient.mutate({
|
|
221
206
|
mutation: gql`mutation runtimeRestartHolochain {
|
|
@@ -138,21 +138,6 @@ export class TriggeredNotification {
|
|
|
138
138
|
triggerMatch: string;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
@ObjectType()
|
|
142
|
-
export class DebugStringEntry {
|
|
143
|
-
@Field()
|
|
144
|
-
languageAddress: string;
|
|
145
|
-
|
|
146
|
-
@Field()
|
|
147
|
-
debugString: string;
|
|
148
|
-
|
|
149
|
-
@Field()
|
|
150
|
-
operation: string;
|
|
151
|
-
|
|
152
|
-
@Field()
|
|
153
|
-
timestamp: string;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
141
|
@ObjectType()
|
|
157
142
|
export class ImportStats {
|
|
158
143
|
@Field()
|
|
@@ -254,17 +239,6 @@ export default class RuntimeResolver {
|
|
|
254
239
|
return ["Qm12345abcdef"]
|
|
255
240
|
}
|
|
256
241
|
|
|
257
|
-
@Query(returns => [DebugStringEntry])
|
|
258
|
-
runtimeDebugStrings(@Arg("languageAddress", type => String, {nullable: true}) languageAddress?: string): DebugStringEntry[] {
|
|
259
|
-
// Mock data for testing - in real implementation this would come from stored debug strings
|
|
260
|
-
return [{
|
|
261
|
-
languageAddress: "Qm123example",
|
|
262
|
-
debugString: "Debug string content",
|
|
263
|
-
operation: "merge",
|
|
264
|
-
timestamp: new Date().toISOString()
|
|
265
|
-
}]
|
|
266
|
-
}
|
|
267
|
-
|
|
268
242
|
@Mutation(returns => [String])
|
|
269
243
|
runtimeAddKnownLinkLanguageTemplates(@Arg("addresses", type => [String]) addresses: string[]): string[] {
|
|
270
244
|
return addresses
|