Skip to content
49,222 changes: 19,546 additions & 29,676 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@
"dependencies": {
"fs-extra": "^10.0.0",
"@holochain/client": "0.3.2",
"@perspect3vism/ad4m": "0.1.25",
"@perspect3vism/ad4m": "0.1.26",
"@peculiar/webcrypto": "^1.1.7",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@transmute/did-key-ed25519": "^0.2.1-unstable.29",
"@transmute/did-key-secp256k1": "^0.2.1-unstable.29",
"@transmute/did-key.js": "^0.2.1-unstable.29",
Expand Down
3 changes: 3 additions & 0 deletions scripts/get-builtin-test-langs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const languages = {
},
"direct-message-language": {
bundle: "https://github.com/perspect3vism/direct-message-language/releases/download/0.0.4/bundle.js"
},
"perspective-language": {
bundle: "https://github.com/perspect3vism/perspective-language/releases/download/0.0.1/bundle.js"
}
};

Expand Down
1 change: 1 addition & 0 deletions src/core/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export function getLanguageStoragePath(name: string) {
export interface BootstrapLanguages {
agents: string,
languages: string,
perspectives: string,
neighbourhoods: string,
}

Expand Down
15 changes: 13 additions & 2 deletions src/core/LanguageController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default class LanguageController {
#agentLanguage?: Language
#languageLanguage?: Language
#perspectiveLanguage?: Language
#neighbourhoodLanguage?: Language
pubSub


Expand Down Expand Up @@ -86,9 +87,12 @@ export default class LanguageController {
if(alias === 'lang') {
this.#languageLanguage = language
}
if(alias === 'neighbourhood') {
if(alias === 'perspective') {
this.#perspectiveLanguage = language
}
if(alias === 'neighbourhood') {
this.#neighbourhoodLanguage = language
}
}
})
}))
Expand Down Expand Up @@ -554,7 +558,7 @@ export default class LanguageController {
}

try {
return await this.#perspectiveLanguage!.expressionAdapter!.get(address)
return await this.#neighbourhoodLanguage!.expressionAdapter!.get(address)
} catch (e) {
throw Error(`Error inside perspective language expression get adapter: ${e}`)
}
Expand Down Expand Up @@ -593,6 +597,13 @@ export default class LanguageController {
return this.#perspectiveLanguage
}

getNeighbourhoodLanguage(): Language {
if(!this.#neighbourhoodLanguage) {
throw new Error("No Neighbourhood Language installed!")
}
return this.#neighbourhoodLanguage
}

async getConstructorIcon(lang: LanguageRef): Promise<string | undefined> {
let grabbedLang = await this.languageByRef(lang);

Expand Down
2 changes: 1 addition & 1 deletion src/core/PerspectivismCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export default class PerspectivismCore {
}

// Create neighbourhood
const neighbourhoodAddress = await (this.languageController.getPerspectiveLanguage().expressionAdapter!.putAdapter as PublicSharing).createPublic(neighbourhood)
const neighbourhoodAddress = await (this.languageController.getNeighbourhoodLanguage().expressionAdapter!.putAdapter as PublicSharing).createPublic(neighbourhood)
const neighbourhoodUrl = `neighbourhood://${neighbourhoodAddress}`

//Add shared perspective to original perpspective and then update controller
Expand Down
9 changes: 9 additions & 0 deletions src/core/graphQL-interface/GraphQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,15 @@ function createResolvers(core: PerspectivismCore) {
return perspective.updateLink(oldLink, newLink)
},
//@ts-ignore
perspectivePublishSnapshot: async (parent, args, context, info) => {
const { uuid } = args
const snapshot = await core.perspectivesController.perspectiveSnapshot(uuid)
const language = core.languageController.getPerspectiveLanguage()
const langref = { address: 'perspective' } as LanguageRef
const expref = await core.languageController.expressionCreate(langref, snapshot)
return exprRef2String(expref)
},
//@ts-ignore
runtimeOpenLink: (parent, args) => {
const { url } = args
console.log("openLinkExtern:", url)
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ export async function init(config: OuterConfig): Promise<PerspectivismCore> {
let builtInLangs = [
ad4mBootstrapLanguages.agents,
ad4mBootstrapLanguages.languages,
ad4mBootstrapLanguages.perspectives,
ad4mBootstrapLanguages.neighbourhoods
]

let languageAliases = {
'did': ad4mBootstrapLanguages.agents,
'lang': ad4mBootstrapLanguages.languages,
'perspective': ad4mBootstrapLanguages.perspectives,
'neighbourhood': ad4mBootstrapLanguages.neighbourhoods
}

Expand Down
2 changes: 2 additions & 0 deletions src/tests/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ describe("Integration tests", () => {
ad4mBootstrapLanguages: {
agents: "agent-expression-store",
languages: "languages",
perspectives: "perspective-language",
neighbourhoods: "neighbourhood-store",
},
ad4mBootstrapFixtures: {
Expand Down Expand Up @@ -179,6 +180,7 @@ describe("Integration tests", () => {
ad4mBootstrapLanguages: {
agents: "agent-expression-store",
languages: "languages",
perspectives: "perspective-language",
neighbourhoods: "neighbourhood-store",
},
ad4mBootstrapFixtures: {
Expand Down
29 changes: 29 additions & 0 deletions src/tests/perspective.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isReference } from "@apollo/client";
import { Ad4mClient, Link, LinkQuery, PerspectiveProxy, LinkExpression, ExpressionProof } from "@perspect3vism/ad4m";
import ExpressionClient from "@perspect3vism/ad4m/lib/src/expression/ExpressionClient";
import { TestContext } from './integration.test'
import sleep from "./sleep";

Expand Down Expand Up @@ -181,6 +182,34 @@ export default function perspectiveTests(testContext: TestContext) {
expect(linkRemoved.mock.calls[1][0]).toEqual(updatedLinkExpression)
})

it('publish snapshots', async () => {
//create new perspective, add links, create snapshot, get snapshot and check link length
const ad4mClient = testContext.ad4mClient!

const create = await ad4mClient!.perspective.add("test-snapshot");
expect(create.name).toEqual("test-snapshot");

// add a link to the perspective
let addLink = await ad4mClient!.perspective.addLink(create.uuid, new Link({source: "lang://test", target: "lang://test-target", predicate: "lang://predicate"}));
expect(addLink.data.target).toEqual("lang://test-target");
expect(addLink.data.source).toEqual("lang://test");

//turn perspective into snapshot
let snapshotUrl = await ad4mClient!.perspective.publishSnapshotByUUID(create.uuid)

let expression
// get the expression from the perspective language
if (typeof snapshotUrl === 'string') {
expression = await ad4mClient!.expression.get(snapshotUrl)
const perspectiveObject = JSON.parse(expression.data)
expect(perspectiveObject.links.length).toEqual(1)
}
else {
expression = null
expect(1).toEqual(2)
}
})

it('can run Prolog queries', async () => {
const ad4mClient: Ad4mClient = testContext.ad4mClient!
const p = await ad4mClient.perspective.add("Prolog test")
Expand Down
Loading