Skip to content

Commit

Permalink
Merge branch 'websocket-reconnect' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
lucksus committed May 24, 2024
2 parents da12c40 + 39ecc61 commit c13b105
Show file tree
Hide file tree
Showing 57 changed files with 1,914 additions and 535 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This project _loosely_ adheres to [Semantic Versioning](https://semver.org/spec/

### Changed
- Partially migrated the Runtime service to Rust. (DM language installation for agents is pending.) [PR#466](https://github.com/coasys/ad4m/pull/466)
- Improved performance of SDNA / SubjectClass functions by moving code from client into executor and saving a lot of client <-> executor roundtrips [PR#480](https://github.com/coasys/ad4m/pull/480)


## [0.9.0] - 23/03/2024
Expand Down
58 changes: 52 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ad4m-hooks/helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coasys/hooks-helpers",
"version": "0.9.1-prerelease",
"version": "0.10.0-prerelease",
"description": "",
"main": "./src/index.ts",
"module": "./src/index.ts",
Expand Down
42 changes: 15 additions & 27 deletions ad4m-hooks/helpers/src/factory/SubjectRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
}

async update(id: string, data: QueryPartialEntity<SubjectClass>) {
await this.ensureSubject();

const instance = await this.get(id);

if (!instance) {
Expand Down Expand Up @@ -102,8 +100,8 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
}

async get(id: string): Promise<SubjectClass | null> {
await this.ensureSubject();
if (id) {
await this.ensureSubject();
const subjectProxy = await this.perspective.getSubjectProxy(
id,
this.subject
Expand All @@ -118,7 +116,6 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
}

async getData(id: string): Promise<SubjectClass | string | null> {
await this.ensureSubject();
const entry = await this.get(id);
if (entry) {
// @ts-ignore
Expand All @@ -133,28 +130,21 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
new LinkQuery({ source: entry.baseExpression })
);

const getters = Object.entries(Object.getOwnPropertyDescriptors(entry))
.filter(([key, descriptor]) => typeof descriptor.get === "function")
.map(([key]) => key);

const promises = getters.map((getter) => entry[getter]);
return Promise.all(promises).then((values) => {
return getters.reduce((acc, getter, index) => {
let value = values[index];
if (this.tempSubject.prototype?.__properties[getter]?.transform) {
value =
this.tempSubject.prototype.__properties[getter].transform(value);
}
let data: any = await this.perspective.getSubjectData(this.subject, entry.baseExpression)

return {
...acc,
id: entry.baseExpression,
timestamp: links[0].timestamp,
author: links[0].author,
[getter]: value,
};
}, {});
});
for (const key in data) {
if (this.tempSubject.prototype?.__properties[key]?.transform) {
data[key] =
this.tempSubject.prototype.__properties[key].transform(data[key]);
}
}

return {
id: entry.baseExpression,
timestamp: links[0].timestamp,
author: links[0].author,
...data,
}
}

async getAll(source?: string, query?: QueryOptions): Promise<SubjectClass[]> {
Expand Down Expand Up @@ -232,8 +222,6 @@ export class SubjectRepository<SubjectClass extends { [x: string]: any }> {
source?: string,
query?: QueryOptions
): Promise<SubjectClass[]> {
await this.ensureSubject();

const subjects = await this.getAll(source, query);

const entries = await Promise.all(
Expand Down
2 changes: 1 addition & 1 deletion ad4m-hooks/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coasys/ad4m-react-hooks",
"version": "0.9.1-prerelease",
"version": "0.10.0-prerelease",
"description": "",
"main": "./src/index.ts",
"module": "./src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion ad4m-hooks/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coasys/ad4m-vue-hooks",
"version": "0.9.1-prerelease",
"version": "0.10.0-prerelease",
"description": "",
"main": "./src/index.ts",
"module": "./src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion bootstrap-languages/agent-language/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
"md5": "^2.3.0",
"postcss": "^8.2.1"
},
"version": "0.9.1-prerelease"
"version": "0.10.0-prerelease"
}
2 changes: 1 addition & 1 deletion bootstrap-languages/direct-message-language/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
"dependencies": {
"@types/node": "^18.0.0"
},
"version": "0.9.1-prerelease"
"version": "0.10.0-prerelease"
}
2 changes: 1 addition & 1 deletion bootstrap-languages/neighbourhood-language/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
},
"author": "[email protected]",
"license": "ISC",
"version": "0.9.1-prerelease"
"version": "0.10.0-prerelease"
}
2 changes: 1 addition & 1 deletion bootstrap-languages/p-diff-sync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
"devDependencies": {
"run-script-os": "^1.1.6"
},
"version": "0.9.1-prerelease"
"version": "0.10.0-prerelease"
}
2 changes: 1 addition & 1 deletion bootstrap-languages/perspective-language/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
"typescript": "^4.5.5",
"uint8arrays": "^3.0.0"
},
"version": "0.9.1-prerelease"
"version": "0.10.0-prerelease"
}
6 changes: 3 additions & 3 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ad4m"

version = "0.9.1-prerelease.0"
version = "0.10.0-prerelease.0"

edition = "2021"
authors = ["Nicolas Luck <[email protected]>"]
Expand All @@ -24,8 +24,8 @@ path = "src/ad4m_executor.rs"
[dependencies]


ad4m-client = { path = "../rust-client", version="0.9.1-prerelease"}
ad4m-executor = { path = "../rust-executor", version="0.9.1-prerelease" }
ad4m-client = { path = "../rust-client", version="0.10.0-prerelease"}
ad4m-executor = { path = "../rust-executor", version="0.10.0-prerelease" }
anyhow = "1.0.65"
clap = { version = "4.0.8", features = ["derive"] }
futures = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@
"esbuild-plugin-replace": "^1.4.0",
"lit": "^2.3.1"
},
"version": "0.9.1-prerelease"
"version": "0.10.0-prerelease"
}
13 changes: 10 additions & 3 deletions connect/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,16 @@ export default class Ad4mConnect {
},
closed: () => {
if (!this.requestedRestart) {
this.notifyConnectionChange(!this.token ? "not_connected" : "disconnected");
this.notifyAuthChange("unauthenticated");
this.requestedRestart = false;
setTimeout(async () => {
const client = await this.connect();
if (client) {
this.ad4mClient = client;
} else {
this.notifyConnectionChange(!this.token ? "not_connected" : "disconnected");
this.notifyAuthChange("unauthenticated");
this.requestedRestart = false;
}
}, 1000);
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@types/yargs": "*"
},
"patchedDependencies": {},
"version": "0.9.1-prerelease",
"version": "0.10.0-prerelease",
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/[email protected]"
Expand Down
Loading

0 comments on commit c13b105

Please sign in to comment.