Skip to content

Commit

Permalink
fix: LANGUAGES→LANGUAGE_CONTROLLER:
Browse files Browse the repository at this point in the history
	+ fix: typescript types
	see coasys#493
  • Loading branch information
btakita committed Jun 12, 2024
1 parent 4517e38 commit 396d31b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 39 deletions.
37 changes: 21 additions & 16 deletions executor/src/core/Ad4mCore.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import type { Address, PublicSharing, PerspectiveHandle, Perspective, LanguageLanguageInput, LanguageExpression, LanguageMetaInput, AgentExpression, Language, NeighbourhoodExpression } from '@coasys/ad4m'
import { parseExprUrl, LanguageRef, Neighbourhood, PerspectiveState } from '@coasys/ad4m'

import * as Config from './Config'
import * as Db from './db'
import type { Ad4mDb } from './db'
import HolochainService, { HolochainConfiguration } from './storage-services/Holochain/HolochainService';
import type {
AgentExpression,
Language,
LanguageExpression,
LanguageLanguageInput,
LanguageMetaInput,
PublicSharing
} from '@coasys/ad4m'
import { LanguageRef } from '@coasys/ad4m'
import { AgentInfoResponse } from '@holochain/client'
import fs from 'node:fs'
import { v4 as uuidv4 } from 'uuid'
import AgentService from './agent/AgentService'
import LanguageController from './LanguageController'
import * as DIDs from './agent/DIDs'
import type { DIDResolver } from './agent/DIDs'
import * as PubSubDefinitions from './graphQL-interface/SubscriptionDefinitions'
import fs from 'node:fs'
import { AgentInfoResponse } from '@holochain/client'
import { v4 as uuidv4 } from 'uuid';
import * as DIDs from './agent/DIDs'
import * as Config from './Config'
import { MainConfig } from './Config'
import { getPubSub, sleep } from "./utils";

import type { Ad4mDb } from './db'
import * as Db from './db'
import * as PubSubDefinitions from './graphQL-interface/SubscriptionDefinitions'
import LanguageController from './LanguageController'
import HolochainService, { HolochainConfiguration } from './storage-services/Holochain/HolochainService'
import { getPubSub } from './utils'
export interface InitServicesParams {
agentService: AgentService,
}
Expand Down Expand Up @@ -285,4 +290,4 @@ export default class Ad4mCore {

export function create(config: Config.CoreConfig): Ad4mCore {
return new Ad4mCore(config)
}
}
26 changes: 3 additions & 23 deletions executor/src/languages_extension.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
export interface LinkExpression {
author: string;
timestamp: string;
data: Triple;
proof: ExpressionProof;
}
import type { LinkExpression, PerspectiveDiff, PerspectiveExpression, PerspectiveState } from '@coasys/ad4m';

export interface Triple {
source?: string;
Expand All @@ -16,31 +11,16 @@ export interface ExpressionProof {
signature: string;
}

export interface PerspectiveDiff {
additions: LinkExpression[];
removals: LinkExpression[];
}

export interface PerspectiveExpression {
author: string;
timestamp: string;
data: Perspective;
proof: ExpressionProof;
}

export interface Perspective {
links: LinkExpression[];
}

// PerspectiveState is an enum in Rust, which can be represented as a union type in TypeScript
export type PerspectiveState = 'PRIVATE' | 'NEIGHBOURHOOD_JOIN_INITIATED' | 'LINK_LANGUAGE_FAILED_TO_INSTALL' | 'LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED' | 'SYNCED';

declare global {
interface RustLanguages {
perspectiveDiffReceived: (diff: PerspectiveDiff, languageAddress: string) => void;
syncStateChanged: (state: PerspectiveState, languageAddress: string) => void;
telepresenceSignalReceived: (signal: PerspectiveExpression, languageAddress: string) => void;
}

const LANGUAGES: RustLanguages;
}
const LANGUAGE_CONTROLLER: RustLanguages;
}

0 comments on commit 396d31b

Please sign in to comment.