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

Dependency updates #652

Merged
merged 11 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
19 changes: 8 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
name: Test

on: push

on: [push, pull_request]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
node-version:
- lts/* # LTS version
- "17" # latest version
node:
- lts/*
- current
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v2
- name: Node ${{ matrix.node-version }}
uses: actions/setup-node@v2
- uses: actions/checkout@v3
- name: Node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

node-version: ${{ matrix.node }}
- run: npm run setup
- run: npm test
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# pico-engine

[![Node version](https://img.shields.io/node/v/pico-engine.svg)](https://nodejs.org/en/download/)
[![Build Status](https://github.com/Picolab/pico-engine/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/Picolab/pico-engine/actions/workflows/test.yml)

An implementation of the [pico-engine](http://www.windley.com/archives/2016/03/rebuilding_krl.shtml) hosted on node.js

Expand Down
2 changes: 1 addition & 1 deletion packages/krl-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"homepage": "https://github.com/Picolab/pico-engine#readme",
"devDependencies": {
"ava": "^4.0.0",
"ava": "^5.3.1",
"contra": "^1.9.4",
"diff-lines": "^1.1.0",
"standard": "^12.0.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/krl-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"homepage": "https://github.com/Picolab/pico-engine#readme",
"devDependencies": {
"ava": "^4.0.0",
"ava": "^5.3.1",
"krl-parser": "^1.3.0",
"standard": "^12.0.1"
},
Expand Down
17 changes: 7 additions & 10 deletions packages/krl-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"dist/src"
],
"scripts": {
"prepublish": "npm run build",
"prepare": "npm run build",
"start": "ava -w",
"test": "ava",
"test": "ava reset-cache && ava",
"build": "npm run build:ts -s && npm run build:spec -s",
"build:ts": "rm -rf dist && tsc",
"build:spec": "node specBuilder.js > spec.md"
Expand All @@ -31,27 +31,24 @@
},
"homepage": "https://github.com/Picolab/pico-engine#readme",
"devDependencies": {
"ava": "^2.4.0",
"ts-node": "^9.1.1",
"typescript": "^4.1.2"
"ava": "^5.3.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"dependencies": {
"excerpt-at-line-col": "^1.0.0",
"line-column": "^1.0.2"
},
"ava": {
"compileEnhancements": false,
"extensions": [
"ts"
],
"require": [
"ts-node/register"
],
"files": [
"test/**/*"
],
"helpers": [
"test/helpers/**/*"
"test/**/*",
"!test/helpers/**/*"
]
},
"gitHead": "26aee8aeb73a2450f9224f2d8d81f3a3d49b33f2"
Expand Down
17 changes: 8 additions & 9 deletions packages/krl-stdlib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dist"
],
"scripts": {
"prepublish": "npm run build",
"prepare": "npm run build",
"start": "ava -w",
"test": "ava",
"build": "rm -rf dist && tsc"
Expand All @@ -29,28 +29,27 @@
},
"homepage": "https://github.com/Picolab/pico-engine#readme",
"devDependencies": {
"@types/abstract-leveldown": "^5.0.1",
"@types/leveldown": "^4.0.0",
"@types/levelup": "^3.1.0",
"@types/lodash": "^4.14.123",
"@types/node": "^14.0.24",
"ava": "^1.4.1",
"@types/node": "^20.8.10",
"ava": "^5.3.1",
"ts-node": "^10.4.0",
"typescript": "^4.1.2"
"typescript": "^5.2.2"
},
"dependencies": {
"json-log": "^3.0.1",
"lodash": "^4.17.11",
"pico-framework": "^0.6.0",
"pico-framework": "^0.7.0",
"select-when": "^0.1.7"
},
"ava": {
"compileEnhancements": false,
"extensions": [
"ts"
],
"require": [
"ts-node/register"
],
"files": [
"test.ts"
]
},
"gitHead": "26aee8aeb73a2450f9224f2d8d81f3a3d49b33f2"
Expand Down
30 changes: 17 additions & 13 deletions packages/pico-engine-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,53 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"engines": {
"node": ">=8.0.0"
"node": ">=20.0.0"
},
"scripts": {
"prepublish": "npm run build",
"prepare": "npm run build",
"build": "rm -rf dist && tsc",
"test": "ava"
"test": "ava reset-cache && ava"
},
"dependencies": {
"abstract-level": "^1.0.3",
"bs58": "^4.0.1",
"cross-fetch": "^3.0.5",
"cross-fetch": "^4.0.0",
"cuid": "^2.1.8",
"didcomm-node": "^0.4.1",
"krl-compiler": "^1.3.0",
"krl-stdlib": "^1.3.0",
"libsodium-wrappers": "^0.7.8",
"lodash": "^4.17.11",
"memdown": "^5.1.0",
"moment-timezone": "^0.5.31",
"node-schedule": "^1.3.2",
"node-schedule": "^2.1.0",
"normalize-url": "^5.0.0",
"p-memoize": "^4.0.0",
"pico-framework": "^0.6.0",
"pico-framework": "^0.7.0",
"qs": "^6.9.4",
"random-words": "^1.1.1",
"strftime": "^0.10.0",
"tweetnacl": "^1.0.3"
},
"devDependencies": {
"@types/abstract-leveldown": "^5.0.1",
"@types/levelup": "^4.3.3",
"@types/lodash": "^4.14.123",
"@types/node": "^14.14.10",
"ava": "^1.4.1",
"@types/node": "^20.8.10",
"ava": "^5.3.1",
"charwise": "^3.0.1",
"level-json-coerce-null": "^1.0.1",
"memory-level": "^1.0.0",
"ts-node": "^10.4.0",
"typescript": "^4.1.2"
"typescript": "^5.2.2"
},
"ava": {
"compileEnhancements": false,
"extensions": [
"ts"
],
"require": [
"ts-node/register"
],
"files": [
"test/**/*",
"!test/helpers/**/*"
]
},
"gitHead": "26aee8aeb73a2450f9224f2d8d81f3a3d49b33f2"
Expand Down
2 changes: 1 addition & 1 deletion packages/pico-engine-core/src/PicoEngineCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class PicoEngineCore {
);

this.picoFramework = new PicoFramework({
leveldown: conf.leveldown,
db: conf.db,
genID: conf.genID,
useEventInputTime: conf.useEventInputTime,

Expand Down
4 changes: 2 additions & 2 deletions packages/pico-engine-core/src/PicoEngineCoreConfiguration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AbstractLevelDOWN } from "abstract-leveldown";
import { krl, KrlLogger, PicoLogEntry } from "krl-stdlib";
import { RulesetRegistryLoader } from "./RulesetRegistry";
import { PicoDb } from "pico-framework";

/**
* Configuration options that may be set by the user
Expand All @@ -9,7 +9,7 @@ export interface PicoEngineCoreConfiguration {
/**
* provide the persistence layer
*/
leveldown: AbstractLevelDOWN;
db: PicoDb;

/**
* How should rulesets be loaded in?
Expand Down
46 changes: 21 additions & 25 deletions packages/pico-engine-core/src/modules/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type ScheduledEvent = ScheduledEvent_at | ScheduledEvent_repeat;

type ScheduleJob = (
timespec: string,
handler: () => void
handler: () => void,
) => { handler: () => void; cancel: () => void };

type SetTimeout = (handler: () => void, time: number) => void;
Expand Down Expand Up @@ -56,7 +56,7 @@ export class Scheduler {
scheduleJob?: ScheduleJob,
setTimeout?: SetTimeout,
clearTimeout?: ClearTimeout,
now?: () => number
now?: () => number,
) {
this.scheduleJob = scheduleJob || nodeSchedule.scheduleJob;
this.setTimeout = setTimeout || longTimeout.setTimeout;
Expand Down Expand Up @@ -105,7 +105,7 @@ export class Scheduler {
// If it's in the past it will happen on the next tick
this.currTimeout = this.setTimeout(
() => this.onTime(),
next.time - this.now()
next.time - this.now(),
);
}

Expand Down Expand Up @@ -166,7 +166,7 @@ export function initScheduleModule(pf: PicoFramework) {

async function addToSchedule(
ctx: KrlCtx,
sEvent: ScheduledEvent
sEvent: ScheduledEvent,
): Promise<ScheduledEvent> {
const schedule = (await ctx.rsCtx.getEnt("_schedule")) || {};
schedule[sEvent.id] = sEvent;
Expand Down Expand Up @@ -199,7 +199,7 @@ export function initScheduleModule(pf: PicoFramework) {

if (posixTime === null || !krl.isNumber(posixTime)) {
throw new TypeError(
"schedule .. at expected a timestamp but got " + krl.typeOf(time)
"schedule .. at expected a timestamp but got " + krl.typeOf(time),
);
}

Expand All @@ -215,7 +215,7 @@ export function initScheduleModule(pf: PicoFramework) {
time: 0,
},
});
}
},
),

repeat: krl.Postlude(
Expand All @@ -233,7 +233,7 @@ export function initScheduleModule(pf: PicoFramework) {
time: 0,
},
});
}
},
),

list: krl.Function([], async function () {
Expand All @@ -249,7 +249,7 @@ export function initScheduleModule(pf: PicoFramework) {
remove: krl.Action(["id"], async function (id) {
await this.rsCtx.putEnt(
"_schedule",
_.omit(this.rsCtx.getEnt("_schedule") || {}, id)
_.omit(this.rsCtx.getEnt("_schedule") || {}, id),
);
scheduler.remove(id);
}),
Expand All @@ -266,24 +266,20 @@ export function initScheduleModule(pf: PicoFramework) {

return {
module,
start() {
return new Promise((resolve, reject) => {
const s = pf.db.createReadStream({
gte: ["entvar"],
lte: ["entvar", undefined], // charwise sorts with null at the bottom and undefined at the top
});
s.on("error", reject);
s.on("end", () => resolve(undefined));
s.on("data", (data) => {
if (data.key[3] === "_schedule") {
const rid = data.key[2];
const value: { [id: string]: ScheduledEvent } = data.value;
for (const sEvent of Object.values(value)) {
addScheduledEvent(rid, sEvent);
}
}
});
async start() {
const iter = pf.db.iterator({
gte: ["entvar"],
lte: ["entvar", undefined], // charwise sorts with null at the bottom and undefined at the top
});
for await (const [key, val] of iter) {
if (key[3] === "_schedule") {
const rid = key[2] + "";
const value: { [id: string]: ScheduledEvent } = val;
for (const sEvent of Object.values(value)) {
addScheduledEvent(rid, sEvent);
}
}
}
},
};
}
10 changes: 4 additions & 6 deletions packages/pico-engine-core/test/flush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { RulesetRegistryLoaderMem } from "../src/RulesetRegistryLoaderMem";
import { allowAllChannelConf } from "./helpers/allowAllChannelConf";
import { mkSignalBase } from "./helpers/mkSignalBase";
import { sleep } from "./helpers/sleep";

const memdown = require("memdown");
import { mkdb } from "./helpers/mkdb";

test("ruleset flush", async (t) => {
function mkKrlVersion(v: string): string {
Expand All @@ -29,7 +28,7 @@ test("ruleset flush", async (t) => {
};

const core = new PicoEngineCore({
leveldown: memdown(),
db: mkdb(),
rsRegLoader: RulesetRegistryLoaderMem(async (url) => krlUrls[url]),
log: makeKrlLogger((line: string) => null),
async getPicoLogs(picoId) {
Expand All @@ -38,9 +37,8 @@ test("ruleset flush", async (t) => {
});
await core.start();

const chann = await core.picoFramework.rootPico.newChannel(
allowAllChannelConf
);
const chann =
await core.picoFramework.rootPico.newChannel(allowAllChannelConf);
const eci = chann.id;
const mkSignal = mkSignalBase(core.picoFramework);
const signal = mkSignal(eci);
Expand Down
Loading