Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@perspect3vism/ad4m

Package Overview
Dependencies
Maintainers
2
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@perspect3vism/ad4m - npm Package Compare versions

Comparing version 0.1.26 to 0.1.27

lib/DID.d.ts

17

lib/Ad4mClient.test.js

@@ -22,2 +22,3 @@ "use strict";

const LanguageMeta_1 = require("./language/LanguageMeta");
const Language_1 = require("./language/Language");
jest.setTimeout(15000);

@@ -180,2 +181,18 @@ describe('Ad4mClient', () => {

});
it('interactions() smoke test', async () => {
const interactions = await ad4mClient.expression.interactions('Qmabcdf');
expect(interactions.length).toBe(1);
const i = interactions[0];
expect(i.label).toBe("Add a comment");
expect(i.name).toBe("add_comment");
expect(i.parameters.length).toBe(1);
const param = i.parameters[0];
expect(param.name).toBe('comment');
expect(param.type).toBe('string');
});
it('interact() smoke test', async () => {
const call = new Language_1.InteractionCall('add_comment', { content: 'test' });
const result = await ad4mClient.expression.interact('Qmabcdf', call);
expect(result.toString()).toBe("test result");
});
});

@@ -182,0 +199,0 @@ describe('.langauges', () => {

3

lib/expression/ExpressionClient.d.ts
import { ApolloClient } from "@apollo/client";
import { InteractionCall, InteractionMeta } from "../language/Language";
import { ExpressionRendered } from "./Expression";

@@ -10,2 +11,4 @@ export default class ExpressionClient {

create(content: any, languageAddress: string): Promise<string>;
interactions(url: string): Promise<InteractionMeta[]>;
interact(url: string, interactionCall: InteractionCall): Promise<string | null>;
}

@@ -84,4 +84,26 @@ "use strict";

}
async interactions(url) {
const { expressionInteractions } = (0, unwrapApolloResult_1.default)(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
query: (0, client_1.gql) `query expressionInteractions($url: String!) {
expressionInteractions(url: $url) {
label
name
parameters { name, type }
}
}`,
variables: { url }
}));
return expressionInteractions;
}
async interact(url, interactionCall) {
const { expressionInteract } = (0, unwrapApolloResult_1.default)(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").mutate({
mutation: (0, client_1.gql) `mutation expressionInteract($url: String!, $interactionCall: InteractionCall!){
expressionInteract(url: $url, interactionCall: $interactionCall)
}`,
variables: { url, interactionCall }
}));
return expressionInteract;
}
}
exports.default = ExpressionClient;
_ExpressionClient_apolloClient = new WeakMap();
import { ExpressionRendered } from "./Expression";
import { InteractionCall, InteractionMeta } from "../language/Language";
export default class ExpressionResolver {

@@ -7,2 +8,4 @@ expression(url: string): ExpressionRendered;

expressionCreate(content: string, languageAddress: string): string;
expressionInteractions(url: string): InteractionMeta[];
expressionInteract(url: string, interactionCall: InteractionCall): string | null;
}

@@ -18,2 +18,3 @@ "use strict";

const Expression_1 = require("./Expression");
const Language_1 = require("../language/Language");
const e = new Expression_1.ExpressionRendered();

@@ -49,2 +50,13 @@ e.author = 'did:ad4m:test';

}
expressionInteractions(url) {
const interaction = {
label: "Add a comment",
name: "add_comment",
parameters: [{ name: 'comment', type: 'string' }]
};
return [interaction];
}
expressionInteract(url, interactionCall) {
return "test result";
}
};

@@ -80,2 +92,17 @@ __decorate([

], ExpressionResolver.prototype, "expressionCreate", null);
__decorate([
(0, type_graphql_1.Query)(returns => [Language_1.InteractionMeta]),
__param(0, (0, type_graphql_1.Arg)('url')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Array)
], ExpressionResolver.prototype, "expressionInteractions", null);
__decorate([
(0, type_graphql_1.Mutation)(returns => String, { nullable: true }),
__param(0, (0, type_graphql_1.Arg)('url')),
__param(1, (0, type_graphql_1.Arg)('interactionCall')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, Language_1.InteractionCall]),
__metadata("design:returntype", String)
], ExpressionResolver.prototype, "expressionInteract", null);
ExpressionResolver = __decorate([

@@ -82,0 +109,0 @@ (0, type_graphql_1.Resolver)()

import { ApolloClient } from "@apollo/client";
import { InteractionCall, InteractionMeta } from "../language/Language";
import { ExpressionRendered } from "./Expression";

@@ -10,2 +11,4 @@ export default class ExpressionClient {

create(content: any, languageAddress: string): Promise<string>;
interactions(url: string): Promise<InteractionMeta[]>;
interact(url: string, interactionCall: InteractionCall): Promise<string | null>;
}

@@ -84,4 +84,26 @@ "use strict";

}
async interactions(url) {
const { expressionInteractions } = (0, unwrapApolloResult_1.default)(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").query({
query: (0, client_1.gql) `query expressionInteractions($url: String!) {
expressionInteractions(url: $url) {
label
name
parameters { name, type }
}
}`,
variables: { url }
}));
return expressionInteractions;
}
async interact(url, interactionCall) {
const { expressionInteract } = (0, unwrapApolloResult_1.default)(await __classPrivateFieldGet(this, _ExpressionClient_apolloClient, "f").mutate({
mutation: (0, client_1.gql) `mutation expressionInteract($url: String!, $interactionCall: InteractionCall!){
expressionInteract(url: $url, interactionCall: $interactionCall)
}`,
variables: { url, interactionCall }
}));
return expressionInteract;
}
}
exports.default = ExpressionClient;
_ExpressionClient_apolloClient = new WeakMap();
import { ExpressionRendered } from "./Expression";
import { InteractionCall, InteractionMeta } from "../language/Language";
export default class ExpressionResolver {

@@ -7,2 +8,4 @@ expression(url: string): ExpressionRendered;

expressionCreate(content: string, languageAddress: string): string;
expressionInteractions(url: string): InteractionMeta[];
expressionInteract(url: string, interactionCall: InteractionCall): string | null;
}

@@ -18,2 +18,3 @@ "use strict";

const Expression_1 = require("./Expression");
const Language_1 = require("../language/Language");
const e = new Expression_1.ExpressionRendered();

@@ -49,2 +50,13 @@ e.author = 'did:ad4m:test';

}
expressionInteractions(url) {
const interaction = {
label: "Add a comment",
name: "add_comment",
parameters: [{ name: 'comment', type: 'string' }]
};
return [interaction];
}
expressionInteract(url, interactionCall) {
return "test result";
}
};

@@ -80,2 +92,17 @@ __decorate([

], ExpressionResolver.prototype, "expressionCreate", null);
__decorate([
(0, type_graphql_1.Query)(returns => [Language_1.InteractionMeta]),
__param(0, (0, type_graphql_1.Arg)('url')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Array)
], ExpressionResolver.prototype, "expressionInteractions", null);
__decorate([
(0, type_graphql_1.Mutation)(returns => String, { nullable: true }),
__param(0, (0, type_graphql_1.Arg)('url')),
__param(1, (0, type_graphql_1.Arg)('interactionCall')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, Language_1.InteractionCall]),
__metadata("design:returntype", String)
], ExpressionResolver.prototype, "expressionInteract", null);
ExpressionResolver = __decorate([

@@ -82,0 +109,0 @@ (0, type_graphql_1.Resolver)()

@@ -67,11 +67,22 @@ import type { Address } from '../Address';

}
export declare class InteractionParameter {
name: string;
type: string;
}
export declare class InteractionMeta {
label: string;
name: string;
parameters: InteractionParameter[];
}
export interface Interaction {
readonly label: string;
readonly name: string;
readonly parameters: [string, string][];
execute(parameters: object): any;
readonly parameters: InteractionParameter[];
execute(parameters: object): Promise<string | null>;
}
export declare class InteractionCall {
name: string;
parameters: object;
parametersStringified: string;
get parameters(): object;
constructor(name: string, parameters: object);
}

@@ -78,0 +89,0 @@ export declare class OnlineAgent {

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TelepresenceRpcCall = exports.OnlineAgent = exports.InteractionCall = void 0;
class InteractionCall {
}
exports.TelepresenceRpcCall = exports.OnlineAgent = exports.InteractionCall = exports.InteractionMeta = exports.InteractionParameter = void 0;
const type_graphql_1 = require("type-graphql");
let InteractionParameter = class InteractionParameter {
};
__decorate([
(0, type_graphql_1.Field)(),
__metadata("design:type", String)
], InteractionParameter.prototype, "name", void 0);
__decorate([
(0, type_graphql_1.Field)(),
__metadata("design:type", String)
], InteractionParameter.prototype, "type", void 0);
InteractionParameter = __decorate([
(0, type_graphql_1.ObjectType)()
], InteractionParameter);
exports.InteractionParameter = InteractionParameter;
let InteractionMeta = class InteractionMeta {
};
__decorate([
(0, type_graphql_1.Field)(),
__metadata("design:type", String)
], InteractionMeta.prototype, "label", void 0);
__decorate([
(0, type_graphql_1.Field)(),
__metadata("design:type", String)
], InteractionMeta.prototype, "name", void 0);
__decorate([
(0, type_graphql_1.Field)(type => [InteractionParameter]),
__metadata("design:type", Array)
], InteractionMeta.prototype, "parameters", void 0);
InteractionMeta = __decorate([
(0, type_graphql_1.ObjectType)()
], InteractionMeta);
exports.InteractionMeta = InteractionMeta;
let InteractionCall = class InteractionCall {
constructor(name, parameters) {
this.name = name;
this.parametersStringified = JSON.stringify(parameters);
}
get parameters() {
return JSON.parse(this.parametersStringified);
}
};
__decorate([
(0, type_graphql_1.Field)(),
__metadata("design:type", String)
], InteractionCall.prototype, "name", void 0);
__decorate([
(0, type_graphql_1.Field)(),
__metadata("design:type", String)
], InteractionCall.prototype, "parametersStringified", void 0);
InteractionCall = __decorate([
(0, type_graphql_1.InputType)(),
__metadata("design:paramtypes", [String, Object])
], InteractionCall);
exports.InteractionCall = InteractionCall;

@@ -7,0 +68,0 @@ class OnlineAgent {

@@ -64,2 +64,18 @@

input InteractionCall {
name: String!
parametersStringified: String!
}
type InteractionMeta {
label: String!
name: String!
parameters: [InteractionParameter!]!
}
type InteractionParameter {
name: String!
type: String!
}
type LanguageHandle {

@@ -146,2 +162,3 @@ address: String!

expressionCreate(content: String!, languageAddress: String!): String!
expressionInteract(interactionCall: InteractionCall!, url: String!): String
languageApplyTemplateAndPublish(sourceLanguageHash: String!, templateData: String!): LanguageRef!

@@ -203,2 +220,3 @@ languagePublish(languageMeta: LanguageMetaInput!, languagePath: String!): LanguageMeta!

expression(url: String!): ExpressionRendered
expressionInteractions(url: String!): [InteractionMeta!]!
expressionMany(urls: [String!]!): [ExpressionRendered]!

@@ -205,0 +223,0 @@ expressionRaw(url: String!): String

@@ -64,2 +64,18 @@

input InteractionCall {
name: String!
parametersStringified: String!
}
type InteractionMeta {
label: String!
name: String!
parameters: [InteractionParameter!]!
}
type InteractionParameter {
name: String!
type: String!
}
type LanguageHandle {

@@ -146,2 +162,3 @@ address: String!

expressionCreate(content: String!, languageAddress: String!): String!
expressionInteract(interactionCall: InteractionCall!, url: String!): String
languageApplyTemplateAndPublish(sourceLanguageHash: String!, templateData: String!): LanguageRef!

@@ -203,2 +220,3 @@ languagePublish(languageMeta: LanguageMetaInput!, languagePath: String!): LanguageMeta!

expression(url: String!): ExpressionRendered
expressionInteractions(url: String!): [InteractionMeta!]!
expressionMany(urls: [String!]!): [ExpressionRendered]!

@@ -205,0 +223,0 @@ expressionRaw(url: String!): String

2

package.json
{
"name": "@perspect3vism/ad4m",
"version": "0.1.26",
"version": "0.1.27",
"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",

@@ -17,2 +17,3 @@ import { buildSchema } from "type-graphql"

import { LanguageMetaInput } from "./language/LanguageMeta";
import { InteractionCall } from "./language/Language";

@@ -207,2 +208,19 @@ jest.setTimeout(15000)

it('interactions() smoke test', async () => {
const interactions = await ad4mClient.expression.interactions('Qmabcdf')
expect(interactions.length).toBe(1)
const i = interactions[0]
expect(i.label).toBe("Add a comment")
expect(i.name).toBe("add_comment")
expect(i.parameters.length).toBe(1)
const param = i.parameters[0]
expect(param.name).toBe('comment')
expect(param.type).toBe('string')
})
it('interact() smoke test', async () => {
const call = new InteractionCall('add_comment', { content: 'test'})
const result = await ad4mClient.expression.interact('Qmabcdf', call)
expect(result.toString()).toBe("test result")
})
})

@@ -209,0 +227,0 @@

import { ApolloClient, gql } from "@apollo/client";
import { InteractionCall, InteractionMeta } from "../language/Language";
import unwrapApolloResult from "../unwrapApolloResult";

@@ -74,2 +75,26 @@ import { ExpressionRendered } from "./Expression";

}
async interactions(url: string): Promise<InteractionMeta[]> {
const { expressionInteractions } = unwrapApolloResult(await this.#apolloClient.query({
query: gql`query expressionInteractions($url: String!) {
expressionInteractions(url: $url) {
label
name
parameters { name, type }
}
}`,
variables: { url }
}))
return expressionInteractions
}
async interact(url: string, interactionCall: InteractionCall): Promise<string|null> {
const { expressionInteract } = unwrapApolloResult(await this.#apolloClient.mutate({
mutation: gql`mutation expressionInteract($url: String!, $interactionCall: InteractionCall!){
expressionInteract(url: $url, interactionCall: $interactionCall)
}`,
variables: { url, interactionCall }
}))
return expressionInteract
}
}
import { Arg, Mutation, Query, Resolver } from "type-graphql";
import { LanguageRef } from "../language/LanguageRef";
import { ExpressionProof, ExpressionRendered } from "./Expression";
import { InteractionCall, InteractionMeta } from "../language/Language"

@@ -45,2 +46,20 @@

}
@Query(returns => [InteractionMeta])
expressionInteractions(@Arg('url') url: string): InteractionMeta[] {
const interaction = {
label: "Add a comment",
name: "add_comment",
parameters: [{name: 'comment', type: 'string'}]
} as InteractionMeta
return [interaction]
}
@Mutation(returns => String, {nullable: true})
expressionInteract(
@Arg('url') url: string,
@Arg('interactionCall') interactionCall: InteractionCall
): string|null {
return "test result"
}
}

@@ -6,2 +6,3 @@ import type { Address } from '../Address'

import { Perspective, PerspectiveExpression } from '../perspectives/Perspective';
import { InputType, Field, ObjectType } from "type-graphql";

@@ -138,12 +139,44 @@ export interface Language {

@ObjectType()
export class InteractionParameter {
@Field()
name: string
@Field()
type: string
}
@ObjectType()
export class InteractionMeta {
@Field()
label: string;
@Field()
name: string;
@Field(type => [InteractionParameter])
parameters: InteractionParameter[]
}
export interface Interaction {
readonly label: string;
readonly name: string;
readonly parameters: [string, string][];
execute(parameters: object);
readonly parameters: InteractionParameter[];
execute(parameters: object): Promise<string|null>;
}
@InputType()
export class InteractionCall {
@Field()
name: string;
parameters: object;
@Field()
parametersStringified: string;
public get parameters(): object {
return JSON.parse(this.parametersStringified)
}
constructor(name: string, parameters: object) {
this.name = name
this.parametersStringified = JSON.stringify(parameters)
}
}

@@ -150,0 +183,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc