Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added statute "prover" extension loading via "extension subjects" #98

Merged
merged 1 commit into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions compliance/test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const { fork } = require('child_process');
const { createWriteStream } = require('fs');
const { join } = require('path');
const { dirname, join } = require('path');
const inspector = require('inspector');
const LOG = require('loglevel');

const COMPLIANCE_DIR = '../node_modules/@m-ld/m-ld-spec/compliance'.split('/');
const COMPLIANCE_PATH = join(__dirname, ...COMPLIANCE_DIR);
const COMPLIANCE_PATH = dirname(require.resolve('@m-ld/m-ld-spec/compliance/jasmine.json'));
const Jasmine = require(require.resolve('jasmine', { paths: [COMPLIANCE_PATH] }));
const jasmine = new Jasmine();

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"types": "dist/index.d.ts",
"exports": {
".": "./dist/index.js",
"./dist/orm": "./dist/orm/index.js",
"./dist/mqtt": "./dist/mqtt/index.js",
"./dist/socket.io": "./dist/socket.io/index.js",
"./dist/socket.io-server": "./dist/socket.io/server/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/ably/AblyRemotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class AblyRemotes extends PubsubRemotes {

constructor(
config: MeldAblyConfig,
extensions: MeldExtensions,
extensions: () => Promise<MeldExtensions>,
connect = ablyConnect
) {
super(config, extensions);
Expand Down
2 changes: 1 addition & 1 deletion src/ably/AblyWrtcRemotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class AblyWrtcRemotes extends AblyRemotes implements PeerSignaller {

constructor(
config: MeldAblyConfig & MeldWrtcConfig,
extensions: MeldExtensions,
extensions: () => Promise<MeldExtensions>,
connect = ablyConnect
) {
super(config, extensions, connect);
Expand Down
50 changes: 27 additions & 23 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { QueryableRdfSource } from './rdfjs-support';
import { Consumable, each, flow, Flowable } from 'rx-flowable';
import { Future, tapComplete } from './engine/util';
import { MeldMessageType } from './ns/m-ld';
import { MeldApp, MeldConfig } from './config';
import { MeldApp } from './config';

/**
* A convenience type for a struct with a `@insert` and `@delete` property, like
Expand Down Expand Up @@ -433,6 +433,32 @@ export interface MeldClone extends MeldStateMachine {
close(err?: any): Promise<unknown>;
}

/**
* Some component of type `T` that is loaded from domain state. The current
* value may change as the domain evolves; and may also be temporarily
* unavailable during an update.
* @internal
*/
export interface StateManaged<T> {
/**
* Get the current or next available value, ready for use (or a rejection,
* e.g. if the clone is shutting down).
*/
ready(): Promise<T>;
/**
* Initialises the extensions against the given clone state. This method could
* be used to read significant state into memory for the efficient
* implementation of an extension's function.
*/
readonly initialise?: StateProc;
/**
* Called to inform the extensions of an update to the state, _after_ it has
* been applied. If available, this procedure will be called for every state
* after that passed to {@link initialise}.
*/
readonly onUpdate?: UpdateProc<MeldPreUpdate>;
}

/**
* Extensions applied to a **m-ld** clone.
*
Expand All @@ -444,9 +470,6 @@ export interface MeldClone extends MeldStateMachine {
* to prevent outdated clones from acting incorrectly in ways that could cause
* data corruption or compromise security. Consult the extension's documentation
* for safe operation.
*
* @experimental
* @category Experimental
*/
export interface MeldExtensions {
/**
Expand All @@ -470,25 +493,6 @@ export interface MeldExtensions {
* @experimental
*/
readonly transportSecurity?: MeldTransportSecurity;
/**
* Initialises the extensions against the given clone state. This method could
* be used to read significant state into memory for the efficient
* implementation of an extension's function.
*/
readonly initialise?: StateProc;
/**
* Called to inform the extensions of an update to the state, _after_ it has
* been applied. If available, this procedure will be called for every state
* after that passed to {@link initialise}.
*/
readonly onUpdate?: UpdateProc<MeldPreUpdate>;
}

/**
* Required constructor form for **m-ld** extension classes
*/
export interface ConstructMeldExtensions {
new(config: MeldConfig, app: MeldApp): MeldExtensions;
}

/**
Expand Down
Loading