@aigne/core 0.4.206 → 0.4.207-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,43 @@
1
+ import { nanoid } from 'nanoid';
2
+ import { OrderedRecord } from './utils';
3
+ export function schemaToDataType(dataType) {
4
+ return OrderedRecord.fromArray(Object.entries(dataType).map(([name, schema]) => {
5
+ const base = {
6
+ ...schema,
7
+ id: nanoid(),
8
+ name,
9
+ };
10
+ switch (schema.type) {
11
+ case 'string':
12
+ return {
13
+ ...base,
14
+ type: 'string',
15
+ };
16
+ case 'number':
17
+ return {
18
+ ...base,
19
+ type: 'number',
20
+ };
21
+ case 'boolean':
22
+ return {
23
+ ...base,
24
+ type: 'boolean',
25
+ };
26
+ case 'object':
27
+ return {
28
+ ...base,
29
+ type: 'object',
30
+ properties: schemaToDataType(schema.properties),
31
+ };
32
+ case 'array':
33
+ return {
34
+ ...base,
35
+ type: 'array',
36
+ items: OrderedRecord.find(schemaToDataType({ items: schema.items }), (i) => i.name === 'items'),
37
+ };
38
+ default: {
39
+ throw new Error(`Unknown data type: ${schema.type}`);
40
+ }
41
+ }
42
+ }));
43
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import { camelCase, startCase } from 'lodash';
2
+ import { Runnable } from './runnable';
3
+ import { OrderedRecord } from './utils';
4
+ export class Memory extends Runnable {
5
+ constructor() {
6
+ super({
7
+ id: 'memory',
8
+ type: 'memory',
9
+ name: 'Memory',
10
+ inputs: OrderedRecord.fromArray([]),
11
+ outputs: OrderedRecord.fromArray([]),
12
+ });
13
+ }
14
+ }
15
+ export class MemoryRunner extends Runnable {
16
+ constructor(name) {
17
+ const id = `${camelCase(name)}_runner`;
18
+ super({
19
+ id,
20
+ type: id,
21
+ name: `${startCase(name)} Runner`,
22
+ description: `${startCase(name)} Runner`,
23
+ inputs: OrderedRecord.fromArray([]),
24
+ outputs: OrderedRecord.fromArray([]),
25
+ });
26
+ }
27
+ }