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

fix: update cli and fix linting errors #9

Merged
merged 2 commits into from
Aug 30, 2024
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
3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ node_modules
npm-debug.log
dist
docs
/coverage
.rete-cli
.sonar
6 changes: 6 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import tseslint from 'typescript-eslint';
import configs from 'rete-cli/configs/eslint.mjs';

export default tseslint.config(
...configs
)
3,675 changes: 2,049 additions & 1,626 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"devDependencies": {
"rete": "^2.0.1",
"rete-cli": "^1.0.2",
"rete-cli": "~2.0.1",
"typescript": "4.8.4"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/control-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
/**
* ControlFlowNodeSetup is a set of functions that define how to execute a node.
*/
export type ControlFlowNodeSetup<T extends ClassicScheme['Node'], I extends (keyof T['inputs'])[] = string[], O extends (keyof T['outputs'])[] = string[]> = {

Check warning on line 8 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

This line has a length of 158. Maximum allowed is 120

Check warning on line 8 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

This line has a length of 158. Maximum allowed is 120
/** Specifies the inputs which are part of the control flow */
inputs: () => I
/** Specifies the outputs which are part of the control flow */
outputs: () => O
/** Called when the node received control from the previous node */
execute(input: I[number], forward: (output: O[number]) => any): any

Check warning on line 14 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 14 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 14 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 14 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type
}

/**
Expand All @@ -19,7 +19,7 @@
* @priority 7
*/
export class ControlFlow<Schemes extends ClassicScheme> {
setups = new Map<NodeId, ControlFlowNodeSetup<any, any, any>>()

Check warning on line 22 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 22 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 22 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 22 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 22 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

Check warning on line 22 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unexpected any. Specify a different type

/**
* @param editor NodeEditor instance
Expand All @@ -31,7 +31,7 @@
* @param node Node instance
* @param setup Set of functions that define how to execute the node
*/
public add<T extends Schemes['Node']>(node: T, setup: ControlFlowNodeSetup<T, (keyof T['inputs'])[], (keyof T['outputs'])[]>) {

Check warning on line 34 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

This line has a length of 129. Maximum allowed is 120

Check warning on line 34 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

This line has a length of 129. Maximum allowed is 120
const affected = this.setups.get(node.id)

if (affected) {
Expand All @@ -57,11 +57,11 @@
const setup = this.setups.get(nodeId)

if (!setup) throw new Error('node is not initialized')
const inputKeys = setup.inputs()

Check warning on line 60 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unsafe assignment of an `any` value

Check warning on line 60 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

The type of 'inputKeys' is 'any'

Check warning on line 60 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unsafe assignment of an `any` value

Check warning on line 60 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

The type of 'inputKeys' is 'any'

if (input && !inputKeys.includes(input)) throw new Error('inputs don\'t have a key')

Check warning on line 62 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unsafe call of an `any` typed value

Check warning on line 62 in src/control-flow.ts

View workflow job for this annotation

GitHub Actions / ci / ci

Unsafe call of an `any` typed value

setup.execute(input, (output) => {
setup.execute(input, output => {
const outputKeys = setup.outputs()

if (!outputKeys.includes(output)) throw new Error('outputs don\'t have a key')
Expand Down
8 changes: 5 additions & 3 deletions src/dataflow-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class DataflowEngine<Schemes extends DataflowEngineScheme> extends Scope<
this.getDataflow().add(node, {
inputs: options.inputs,
outputs: options.outputs,
data: async (fetchInputs) => {
data: async fetchInputs => {
const cache = this.cache.get(node.id)

if (cache) return cache
Expand Down Expand Up @@ -91,14 +91,16 @@ export class DataflowEngine<Schemes extends DataflowEngineScheme> extends Scope<
if (nodeId) {
const setup = this.getDataflow().setups.get(nodeId)

if (!setup) throw 'setup'
if (!setup) throw new Error('setup')

const outputKeys = setup.outputs()

this.cache.delete(nodeId)
this.editor.getConnections()
.filter(c => c.source === nodeId && outputKeys.includes(c.sourceOutput))
.forEach(c => this.reset(c.target))
.forEach(c => {
this.reset(c.target)
})
} else {
this.cache.clear()
}
Expand Down
4 changes: 3 additions & 1 deletion src/dataflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ export class Dataflow<Schemes extends ClassicScheme> {
}))

for (const { c, sourceData } of consWithSourceData) {
const previous = inputs[c.targetInput] ? inputs[c.targetInput] : []
const previous = inputs[c.targetInput]
? inputs[c.targetInput]
: []

inputs[c.targetInput] = [...previous, sourceData[c.sourceOutput]]
}
Expand Down
4 changes: 3 additions & 1 deletion src/utils/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export class Cache<Key, T> {
const item = this.cache.get(key)

this.cache.delete(key)
this.onDelete && this.onDelete(item)
if (this.onDelete) {
this.onDelete(item)
}
}

clear() {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/cancellable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function createCancellblePromise(...sequence: S<any, any>[]): Cancellable<any> {
res()
})

const n = (sequence as S<any, any>[]).reduce((p, item) => {
const n = sequence.reduce((p, item) => {
const t = p.then(item as any).then(commit)

return t
Expand Down
4 changes: 1 addition & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"compilerOptions": {
"strict": true
},
"extends": "rete-cli/configs/tsconfig.json",
"include": ["src"]
}
Loading