@perspect3vism/ad4m
Advanced tools
Comparing version 0.1.20 to 0.1.21
@@ -283,2 +283,11 @@ "use strict"; | ||
}); | ||
it('queryProlog() smoke test', async () => { | ||
let result = await ad4mClient.perspective.queryProlog('000001', "link(X, 2)."); | ||
expect(result.length).toBe(1); | ||
expect(result[0].X).toBe(1); | ||
const proxy = await ad4mClient.perspective.byUUID('000001'); | ||
result = await proxy.infer("link(X, 2)."); | ||
expect(result.length).toBe(1); | ||
expect(result[0].X).toBe(1); | ||
}); | ||
it('add() smoke test', async () => { | ||
@@ -285,0 +294,0 @@ const p = await ad4mClient.perspective.add('p-name'); |
@@ -17,2 +17,3 @@ import { ApolloClient } from "@apollo/client"; | ||
queryLinks(uuid: string, query: LinkQuery): Promise<LinkExpression[]>; | ||
queryProlog(uuid: string, query: string): Promise<any>; | ||
add(name: string): Promise<PerspectiveProxy>; | ||
@@ -19,0 +20,0 @@ update(uuid: string, name: string): Promise<PerspectiveProxy>; |
@@ -140,2 +140,11 @@ "use strict"; | ||
} | ||
async queryProlog(uuid, query) { | ||
const { perspectiveQueryProlog } = (0, unwrapApolloResult_1.default)(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({ | ||
query: (0, client_1.gql) `query perspectiveQueryProlog($uuid: String!, $query: String!) { | ||
perspectiveQueryProlog(uuid: $uuid, query: $query) | ||
}`, | ||
variables: { uuid, query } | ||
})); | ||
return JSON.parse(perspectiveQueryProlog); | ||
} | ||
async add(name) { | ||
@@ -142,0 +151,0 @@ const { perspectiveAdd } = (0, unwrapApolloResult_1.default)(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({ |
@@ -15,2 +15,3 @@ import PerspectiveClient, { LinkCallback } from "./PerspectiveClient"; | ||
get(query: LinkQuery): Promise<LinkExpression[]>; | ||
infer(query: string): Promise<any>; | ||
add(link: Link): Promise<LinkExpression>; | ||
@@ -17,0 +18,0 @@ update(oldLink: LinkExpression, newLink: Link): Promise<LinkExpression>; |
@@ -39,2 +39,5 @@ "use strict"; | ||
} | ||
async infer(query) { | ||
return await __classPrivateFieldGet(this, _PerspectiveProxy_client, "f").queryProlog(__classPrivateFieldGet(this, _PerspectiveProxy_handle, "f").uuid, query); | ||
} | ||
async add(link) { | ||
@@ -41,0 +44,0 @@ return await __classPrivateFieldGet(this, _PerspectiveProxy_client, "f").addLink(__classPrivateFieldGet(this, _PerspectiveProxy_handle, "f").uuid, link); |
@@ -16,2 +16,3 @@ import { LinkExpression, LinkExpressionInput, LinkInput } from "../links/Links"; | ||
perspectiveQueryLinks(uuid: string, query: LinkQuery): LinkExpression[]; | ||
perspectiveQueryProlog(uuid: string, query: String): string; | ||
perspectiveAdd(name: string): PerspectiveHandle; | ||
@@ -18,0 +19,0 @@ perspectiveUpdate(uuid: string, name: string): PerspectiveHandle; |
@@ -60,2 +60,5 @@ "use strict"; | ||
} | ||
perspectiveQueryProlog(uuid, query) { | ||
return `[{"X": 1}]`; | ||
} | ||
perspectiveAdd(name) { | ||
@@ -134,2 +137,10 @@ return new PerspectiveHandle_1.PerspectiveHandle('00006', name); | ||
__decorate([ | ||
(0, type_graphql_1.Query)(returns => String), | ||
__param(0, (0, type_graphql_1.Arg)('uuid')), | ||
__param(1, (0, type_graphql_1.Arg)('query')), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [String, String]), | ||
__metadata("design:returntype", String) | ||
], PerspectiveResolver.prototype, "perspectiveQueryProlog", null); | ||
__decorate([ | ||
(0, type_graphql_1.Mutation)(returns => PerspectiveHandle_1.PerspectiveHandle), | ||
@@ -136,0 +147,0 @@ __param(0, (0, type_graphql_1.Arg)('name')), |
@@ -17,2 +17,3 @@ import { ApolloClient } from "@apollo/client"; | ||
queryLinks(uuid: string, query: LinkQuery): Promise<LinkExpression[]>; | ||
queryProlog(uuid: string, query: string): Promise<any>; | ||
add(name: string): Promise<PerspectiveProxy>; | ||
@@ -19,0 +20,0 @@ update(uuid: string, name: string): Promise<PerspectiveProxy>; |
@@ -140,2 +140,11 @@ "use strict"; | ||
} | ||
async queryProlog(uuid, query) { | ||
const { perspectiveQueryProlog } = (0, unwrapApolloResult_1.default)(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").query({ | ||
query: (0, client_1.gql) `query perspectiveQueryProlog($uuid: String!, $query: String!) { | ||
perspectiveQueryProlog(uuid: $uuid, query: $query) | ||
}`, | ||
variables: { uuid, query } | ||
})); | ||
return JSON.parse(perspectiveQueryProlog); | ||
} | ||
async add(name) { | ||
@@ -142,0 +151,0 @@ const { perspectiveAdd } = (0, unwrapApolloResult_1.default)(await __classPrivateFieldGet(this, _PerspectiveClient_apolloClient, "f").mutate({ |
@@ -15,2 +15,3 @@ import PerspectiveClient, { LinkCallback } from "./PerspectiveClient"; | ||
get(query: LinkQuery): Promise<LinkExpression[]>; | ||
infer(query: string): Promise<any>; | ||
add(link: Link): Promise<LinkExpression>; | ||
@@ -17,0 +18,0 @@ update(oldLink: LinkExpression, newLink: Link): Promise<LinkExpression>; |
@@ -39,2 +39,5 @@ "use strict"; | ||
} | ||
async infer(query) { | ||
return await __classPrivateFieldGet(this, _PerspectiveProxy_client, "f").queryProlog(__classPrivateFieldGet(this, _PerspectiveProxy_handle, "f").uuid, query); | ||
} | ||
async add(link) { | ||
@@ -41,0 +44,0 @@ return await __classPrivateFieldGet(this, _PerspectiveProxy_client, "f").addLink(__classPrivateFieldGet(this, _PerspectiveProxy_handle, "f").uuid, link); |
@@ -16,2 +16,3 @@ import { LinkExpression, LinkExpressionInput, LinkInput } from "../links/Links"; | ||
perspectiveQueryLinks(uuid: string, query: LinkQuery): LinkExpression[]; | ||
perspectiveQueryProlog(uuid: string, query: String): string; | ||
perspectiveAdd(name: string): PerspectiveHandle; | ||
@@ -18,0 +19,0 @@ perspectiveUpdate(uuid: string, name: string): PerspectiveHandle; |
@@ -60,2 +60,5 @@ "use strict"; | ||
} | ||
perspectiveQueryProlog(uuid, query) { | ||
return `[{"X": 1}]`; | ||
} | ||
perspectiveAdd(name) { | ||
@@ -134,2 +137,10 @@ return new PerspectiveHandle_1.PerspectiveHandle('00006', name); | ||
__decorate([ | ||
(0, type_graphql_1.Query)(returns => String), | ||
__param(0, (0, type_graphql_1.Arg)('uuid')), | ||
__param(1, (0, type_graphql_1.Arg)('query')), | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [String, String]), | ||
__metadata("design:returntype", String) | ||
], PerspectiveResolver.prototype, "perspectiveQueryProlog", null); | ||
__decorate([ | ||
(0, type_graphql_1.Mutation)(returns => PerspectiveHandle_1.PerspectiveHandle), | ||
@@ -136,0 +147,0 @@ __param(0, (0, type_graphql_1.Arg)('name')), |
@@ -209,2 +209,3 @@ | ||
perspectiveQueryLinks(query: LinkQuery!, uuid: String!): [LinkExpression!] | ||
perspectiveQueryProlog(query: String!, uuid: String!): String! | ||
perspectiveSnapshot(uuid: String!): Perspective | ||
@@ -211,0 +212,0 @@ perspectives: [PerspectiveHandle!]! |
@@ -209,2 +209,3 @@ | ||
perspectiveQueryLinks(query: LinkQuery!, uuid: String!): [LinkExpression!] | ||
perspectiveQueryProlog(query: String!, uuid: String!): String! | ||
perspectiveSnapshot(uuid: String!): Perspective | ||
@@ -211,0 +212,0 @@ perspectives: [PerspectiveHandle!]! |
{ | ||
"name": "@perspect3vism/ad4m", | ||
"version": "0.1.20", | ||
"version": "0.1.21", | ||
"description": "*The Agent-Centric Distributed Application Meta-ontology* or just: *Agent-Centric DApp Meta-ontology* * A new meta-ontology for interoperable, decentralized application design * A spanning-layer to enable seamless integration between Holochain DNAs, blockchains, linked-data structures/ontologies and centralized back-ends * The basis for turning distinct, monolithic and siloed apps into a global, open and interoperable sense-making network", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -15,2 +15,8 @@ # AD4M | ||
The easiest way to get that is to use ad4m-cli: | ||
```sh | ||
npm install -g @perspect3vism/ad4m-cli | ||
ad4m executor run & | ||
``` | ||
Then use `Ad4mClient` to connect to and work with the running ad4m-executor like this: | ||
@@ -77,3 +83,3 @@ ``` | ||
``` | ||
### Creating an Expressions | ||
### Creating an Expression | ||
@@ -98,11 +104,48 @@ ```js | ||
The back-bone of a Neighbourhood is a *LinkLanguage* - a Language that enables the sharing | ||
and thus synchronizing of links (see `LinksAdapter` in [Language.ts](src/language/Language.ts)). While there can and should be many different implementations | ||
with different trade-offs and features (like membranes etc.) the go-to implementation for now | ||
is *Social Context* from Junto: https://github.com/juntofoundation/Social-Context | ||
and thus synchronizing of links (see `LinksAdapter` in [Language.ts](src/language/Language.ts)). | ||
While there can and should be many different implementations | ||
with different trade-offs and features (like membranes etc.), | ||
there currently is one fully implemented and Holochain based LinkLanguage with the name *Social Context*. | ||
Let's assume we have downloaded the build files from their release directory, we can use it as | ||
a template to create a unique Language (with unique Holochain DNA in this case) like so: | ||
It is deployed on the current test network (Language Language v0.0.5) under the address: | ||
`QmZ1mkoY8nLvpxY3Mizx8UkUiwUzjxJxsqSTPPdH8sHxCQ`. | ||
#### Creating our unique LinkLanguage clone through templating | ||
But we should not just use this publicly known Language as the back-bone for our new Neighbourhood, | ||
since we need a unique clone. | ||
So what we want is to use this existing Language as a template and create a new copy with the same code | ||
but different UUID and/name in order to create a fresh space for our new Neighbourhood. | ||
What parameters can we adjust when using it as template? | ||
Let's have a look at the Language's meta information: | ||
```js | ||
const uniqueLinkLanguage = await ad4mClient.languages.cloneHolochainTemplate(path.join(__dirname, "../languages/social-context"), "social-context", "b98e53a8-5800-47b6-adb9-86d55a74871e"); | ||
const socialContextMeta = await ad4mClient.languages.meta("QmZ1mkoY8nLvpxY3Mizx8UkUiwUzjxJxsqSTPPdH8sHxCQ") | ||
console.log(socialContextMeta) | ||
``` | ||
Which should yield something like this: | ||
``` | ||
{ | ||
name: 'social-context', | ||
address: 'QmZ1mkoY8nLvpxY3Mizx8UkUiwUzjxJxsqSTPPdH8sHxCQ', | ||
description: 'Holochain based LinkLanguage. First full implementation of a LinkLanguage, for collaborative Neighbourhoods where every agent can add links. No membrane. Basic template for all custom Neighbourhoods in this first iteration of the Perspect3vism test network.', | ||
author: 'did:key:zQ3shkkuZLvqeFgHdgZgFMUx8VGkgVWsLA83w2oekhZxoCW2n', | ||
templated: false, | ||
templateSourceLanguageAddress: null, | ||
templateAppliedParams: null, | ||
possibleTemplateParams: [ 'uuid', 'name', 'description' ], | ||
sourceCodeLink: 'https://github.com/juntofoundation/Social-Context' | ||
} | ||
``` | ||
The field `possibleTemplateParams` tells us that we can set a `UUID` and override `name` and `description`. | ||
Let's leave description but change the name. | ||
The function `languages.applyTemplateAndPublish()` takes an object as JSON as second parameter like so: | ||
```js | ||
const uniqueLinkLanguage = await ad4mClient.languages.applyTemplateAndPublish("QmZ1mkoY8nLvpxY3Mizx8UkUiwUzjxJxsqSTPPdH8sHxCQ", JSON.stringify({"uuid": "84a329-77384c-1510fb", "name": "Social Context clone for demo Neighbourhood"})); | ||
``` | ||
And then use this new LinkLanguage in our Neighbourhood: | ||
@@ -125,5 +168,5 @@ ```js | ||
```js | ||
const perspectiveHandle = await ad4mClient.neighbourhood.joinFromUrl(neighbourhoodUrl) | ||
const links = await ad4mClient.perspective.queryLinks(perspectiveHandle.uuid, {}) | ||
links.forEach(link => { | ||
const joinedNeighbourhood = await ad4mClient.neighbourhood.joinFromUrl(neighbourhoodUrl) | ||
const links = await ad4mClient.perspective.queryLinks(joinedNeighbourhood.uuid, new LinkQuery({source: 'a'})) | ||
links.forEach(async link => { | ||
const address = link.data.target | ||
@@ -146,3 +189,3 @@ const expression = await ad4mClient.expression.get(address) | ||
## Wait, what?! | ||
The central claim of AD4M is that any single- but also specifically multi-user application can be bootstrapped out of a meta-ontology consisting of 3 quintessential entities: | ||
The central claim of AD4M is that any single- but also specifically multi-user application can be bootstrapped out of a meta-ontology consisting of 3 quintessential ontological units: | ||
* Agents | ||
@@ -158,3 +201,3 @@ * Languages | ||
### Agents... | ||
...represent humans with their devices, which is what the internet actually is. Technically **represented as Decentralized Identifier - DID**. | ||
...represent humans with their devices, which is what the internet actually is. Technically **represented as Decentralized Identifiers - DIDs**. | ||
@@ -167,3 +210,3 @@ | ||
### Perspectives... | ||
...belong to a specific agent. They represent context and association between expressions. They consist of a list of RDF/semantic web like triplets (subject-predicate-obejct) called `links` because all three items are just URLs pointing to expressions. Perspectives are like Solid's pods, but they are agent-centric. There is no such thing as a Perspective that does not belong to an agent. It is like the canvas on which an agent perceives and onto which they create anything. To the next layer above (either the very general UI built in Perspectivism - or any other special purpose UI), they are like a database scope. | ||
...belong to a specific agent. They represent context and association between expressions. They consist of a list of RDF/semantic web like triplets (subject-predicate-object) called `links` because all three items are just URLs pointing to expressions. Perspectives are like Solid's pods, but they are agent-centric. There is no such thing as a Perspective that does not belong to an agent. It is like the canvas on which an agent perceives and onto which they create anything. To the next layer above (either the very general UI built in Perspectivism - or any other special purpose UI), they are like a database scope. | ||
@@ -187,4 +230,4 @@ --- | ||
needed for the apps domain - and then creating expressions from those Languages and linking them inside Perspectives. | ||
needed for the app's domain - and then creating expressions from those Languages and linking them inside Perspectives. | ||
The latter means creating RDF/semantic web style triplets that associate expressions in order to represent app specific semantics - not too different to how Solid style linked-data would work. |
@@ -337,2 +337,13 @@ import { buildSchema } from "type-graphql" | ||
it('queryProlog() smoke test', async () => { | ||
let result = await ad4mClient.perspective.queryProlog('000001', "link(X, 2).") | ||
expect(result.length).toBe(1) | ||
expect(result[0].X).toBe(1) | ||
const proxy = await ad4mClient.perspective.byUUID('000001') | ||
result = await proxy.infer("link(X, 2).") | ||
expect(result.length).toBe(1) | ||
expect(result[0].X).toBe(1) | ||
}) | ||
it('add() smoke test', async () => { | ||
@@ -339,0 +350,0 @@ const p = await ad4mClient.perspective.add('p-name') |
@@ -138,2 +138,13 @@ import { ApolloClient, gql } from "@apollo/client"; | ||
async queryProlog(uuid: string, query: string): Promise<any> { | ||
const { perspectiveQueryProlog } = unwrapApolloResult(await this.#apolloClient.query({ | ||
query: gql`query perspectiveQueryProlog($uuid: String!, $query: String!) { | ||
perspectiveQueryProlog(uuid: $uuid, query: $query) | ||
}`, | ||
variables: { uuid, query } | ||
})) | ||
return JSON.parse(perspectiveQueryProlog) | ||
} | ||
async add(name: string): Promise<PerspectiveProxy> { | ||
@@ -140,0 +151,0 @@ const { perspectiveAdd } = unwrapApolloResult(await this.#apolloClient.mutate({ |
@@ -37,2 +37,6 @@ import PerspectiveClient, { LinkCallback } from "./PerspectiveClient"; | ||
async infer(query: string): Promise<any> { | ||
return await this.#client.queryProlog(this.#handle.uuid, query) | ||
} | ||
async add(link: Link): Promise<LinkExpression> { | ||
@@ -39,0 +43,0 @@ return await this.#client.addLink(this.#handle.uuid, link) |
@@ -57,2 +57,7 @@ import { Arg, Mutation, Query, Resolver, Subscription } from "type-graphql"; | ||
@Query(returns => String) | ||
perspectiveQueryProlog(@Arg('uuid') uuid: string, @Arg('query') query: String): string { | ||
return `[{"X": 1}]` | ||
} | ||
@Mutation(returns => PerspectiveHandle) | ||
@@ -59,0 +64,0 @@ perspectiveAdd(@Arg('name') name: string): PerspectiveHandle { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1179029
27349
226