@ratiosolver/coco 0.0.2

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.
Files changed (39) hide show
  1. package/README.md +3 -0
  2. package/dist/coco/coco.d.ts +313 -0
  3. package/dist/coco/coco.js +557 -0
  4. package/dist/coco/coco.js.map +1 -0
  5. package/dist/coco/components/chart.d.ts +30 -0
  6. package/dist/coco/components/chart.js +231 -0
  7. package/dist/coco/components/chart.js.map +1 -0
  8. package/dist/coco/components/item.d.ts +23 -0
  9. package/dist/coco/components/item.js +85 -0
  10. package/dist/coco/components/item.js.map +1 -0
  11. package/dist/coco/components/item_chart.d.ts +15 -0
  12. package/dist/coco/components/item_chart.js +88 -0
  13. package/dist/coco/components/item_chart.js.map +1 -0
  14. package/dist/coco/components/item_properties.d.ts +11 -0
  15. package/dist/coco/components/item_properties.js +59 -0
  16. package/dist/coco/components/item_properties.js.map +1 -0
  17. package/dist/coco/components/item_publisher.d.ts +15 -0
  18. package/dist/coco/components/item_publisher.js +152 -0
  19. package/dist/coco/components/item_publisher.js.map +1 -0
  20. package/dist/coco/components/offcanvas.d.ts +6 -0
  21. package/dist/coco/components/offcanvas.js +42 -0
  22. package/dist/coco/components/offcanvas.js.map +1 -0
  23. package/dist/coco/components/publisher.d.ts +22 -0
  24. package/dist/coco/components/publisher.js +281 -0
  25. package/dist/coco/components/publisher.js.map +1 -0
  26. package/dist/coco/components/taxonomy.d.ts +27 -0
  27. package/dist/coco/components/taxonomy.js +185 -0
  28. package/dist/coco/components/taxonomy.js.map +1 -0
  29. package/dist/coco/components/type.d.ts +37 -0
  30. package/dist/coco/components/type.js +165 -0
  31. package/dist/coco/components/type.js.map +1 -0
  32. package/dist/coco/rules.d.ts +30 -0
  33. package/dist/coco/rules.js +36 -0
  34. package/dist/coco/rules.js.map +1 -0
  35. package/dist/index.d.ts +14 -0
  36. package/dist/index.js +30 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/tsconfig.tsbuildinfo +1 -0
  39. package/package.json +40 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # CoCo-lib
2
+
3
+ The deduCtiOn and abduCtiOn (CoCo) visualization library.
@@ -0,0 +1,313 @@
1
+ export declare namespace coco {
2
+ class CoCo implements CoCoListener {
3
+ private static instance;
4
+ private readonly property_types;
5
+ private readonly types;
6
+ private readonly items;
7
+ private readonly intents;
8
+ private readonly entities;
9
+ private readonly coco_listeners;
10
+ private constructor();
11
+ static get_instance(): CoCo;
12
+ add_property_type(pt: taxonomy.PropertyType<any>): void;
13
+ get_types(): MapIterator<taxonomy.Type>;
14
+ get_items(): MapIterator<taxonomy.Item>;
15
+ new_type(type: taxonomy.Type): void;
16
+ new_item(item: taxonomy.Item): void;
17
+ new_intent(intent: llm.Intent): void;
18
+ new_entity(entity: llm.Entity): void;
19
+ /**
20
+ * Loads data for a given taxonomy item within a specified date range.
21
+ *
22
+ * @param item - The taxonomy item for which data is to be loaded.
23
+ * @param from - The start date of the range (in milliseconds since the Unix epoch). Defaults to 14 days ago.
24
+ * @param to - The end date of the range (in milliseconds since the Unix epoch). Defaults to the current date and time.
25
+ *
26
+ * If the request is successful, the item's values are updated with the fetched data.
27
+ * If the request fails, an error message is displayed using the application's toast mechanism.
28
+ */
29
+ load_data(item: taxonomy.Item, from?: number, to?: number): void;
30
+ publish(item: taxonomy.Item, data: Record<string, unknown>): void;
31
+ fake_data(type: taxonomy.Type, pars?: string[] | undefined): Promise<Record<string, unknown>>;
32
+ update_coco(message: UpdateCoCoMessage | any): void;
33
+ private init;
34
+ private refine_type;
35
+ private make_item;
36
+ get_type(name: string): taxonomy.Type;
37
+ get_item(id: string): taxonomy.Item;
38
+ add_coco_listener(listener: CoCoListener): void;
39
+ remove_coco_listener(listener: CoCoListener): void;
40
+ }
41
+ interface CoCoListener {
42
+ new_type(type: taxonomy.Type): void;
43
+ new_item(item: taxonomy.Item): void;
44
+ new_intent(intent: llm.Intent): void;
45
+ new_entity(entity: llm.Entity): void;
46
+ }
47
+ namespace taxonomy {
48
+ abstract class PropertyType<P extends Property<unknown>> {
49
+ protected readonly cc: CoCo;
50
+ private readonly name;
51
+ constructor(cc: CoCo, name: string);
52
+ get_name(): string;
53
+ abstract make_property(property_message: PropertyMessage | any): P;
54
+ abstract to_string(val: unknown): string;
55
+ }
56
+ class BoolPropertyType extends PropertyType<BoolProperty> {
57
+ constructor(cc: CoCo);
58
+ make_property(property_message: PropertyMessage | any): BoolProperty;
59
+ to_string(val: boolean): string;
60
+ }
61
+ class IntPropertyType extends PropertyType<IntProperty> {
62
+ constructor(cc: CoCo);
63
+ make_property(property_message: PropertyMessage | any): IntProperty;
64
+ to_string(val: number): string;
65
+ }
66
+ class FloatPropertyType extends PropertyType<FloatProperty> {
67
+ constructor(cc: CoCo);
68
+ make_property(property_message: PropertyMessage | any): FloatProperty;
69
+ to_string(val: number): string;
70
+ }
71
+ class StringPropertyType extends PropertyType<StringProperty> {
72
+ constructor(cc: CoCo);
73
+ make_property(property_message: PropertyMessage | any): StringProperty;
74
+ to_string(val: string): string;
75
+ }
76
+ class SymbolPropertyType extends PropertyType<SymbolProperty> {
77
+ constructor(cc: CoCo);
78
+ make_property(property_message: PropertyMessage | any): SymbolProperty;
79
+ to_string(val: string | string[]): string;
80
+ }
81
+ class ItemPropertyType extends PropertyType<ItemProperty> {
82
+ constructor(cc: CoCo);
83
+ make_property(property_message: PropertyMessage | any): ItemProperty;
84
+ to_string(val: string | string[]): string;
85
+ }
86
+ class JSONPropertyType extends PropertyType<JSONProperty> {
87
+ constructor(cc: CoCo);
88
+ make_property(property_message: PropertyMessage | any): JSONProperty;
89
+ to_string(val: JSON): string;
90
+ }
91
+ class Property<V> {
92
+ protected readonly type: PropertyType<Property<V>>;
93
+ protected readonly default_value: V | undefined;
94
+ constructor(type: PropertyType<Property<V>>, default_value?: V);
95
+ get_type(): PropertyType<Property<V>>;
96
+ has_default_value(): boolean;
97
+ get_default_value(): V | undefined;
98
+ to_string(): string;
99
+ }
100
+ class BoolProperty extends Property<boolean> {
101
+ constructor(type: BoolPropertyType, default_value?: boolean);
102
+ to_string(): string;
103
+ }
104
+ class IntProperty extends Property<number> {
105
+ private readonly min?;
106
+ private readonly max?;
107
+ constructor(type: IntPropertyType, min?: number, max?: number, default_value?: number);
108
+ get_min(): number | undefined;
109
+ get_max(): number | undefined;
110
+ to_string(): string;
111
+ }
112
+ class FloatProperty extends Property<number> {
113
+ private readonly min?;
114
+ private readonly max?;
115
+ constructor(type: FloatPropertyType, min?: number, max?: number, default_value?: number);
116
+ get_min(): number | undefined;
117
+ get_max(): number | undefined;
118
+ to_string(): string;
119
+ }
120
+ class StringProperty extends Property<string> {
121
+ constructor(type: StringPropertyType, default_value?: string);
122
+ to_string(): string;
123
+ }
124
+ class SymbolProperty extends Property<string | string[]> {
125
+ private readonly multiple;
126
+ private readonly symbols?;
127
+ constructor(type: SymbolPropertyType, multiple: boolean, symbols?: string[], default_value?: string | string[]);
128
+ is_multiple(): boolean;
129
+ get_symbols(): string[] | undefined;
130
+ to_string(): string;
131
+ }
132
+ class ItemProperty extends Property<Item | Item[]> {
133
+ private readonly domain;
134
+ private readonly multiple;
135
+ constructor(type: ItemPropertyType, domain: Type, multiple: boolean, default_value?: Item | Item[]);
136
+ get_domain(): Type;
137
+ is_multiple(): boolean;
138
+ to_string(): string;
139
+ }
140
+ class JSONProperty extends Property<Record<string, any>> {
141
+ private readonly schema;
142
+ constructor(type: JSONPropertyType, schema: Record<string, any>, default_value?: Record<string, any>);
143
+ to_string(): string;
144
+ }
145
+ class Type {
146
+ private readonly name;
147
+ private parents?;
148
+ private data?;
149
+ private static_properties?;
150
+ private dynamic_properties?;
151
+ readonly _instances: Set<Item>;
152
+ private readonly listeners;
153
+ constructor(name: string, parents?: Type[], data?: Record<string, any>, static_properties?: Map<string, Property<unknown>>, dynamic_properties?: Map<string, Property<unknown>>);
154
+ get_name(): string;
155
+ get_parents(): Type[] | undefined;
156
+ get_data(): Record<string, any> | undefined;
157
+ get_static_properties(): Map<string, Property<unknown>> | undefined;
158
+ get_all_static_properties(): Map<string, Property<unknown>>;
159
+ get_dynamic_properties(): Map<string, Property<unknown>> | undefined;
160
+ get_all_dynamic_properties(): Map<string, Property<unknown>>;
161
+ get_instances(): Set<Item>;
162
+ _set_parents(ps?: Type[]): void;
163
+ _set_data(data?: Record<string, any>): void;
164
+ _set_static_properties(sp?: Map<string, Property<unknown>>): void;
165
+ _set_dynamic_properties(dp?: Map<string, Property<unknown>>): void;
166
+ to_string(): string;
167
+ add_type_listener(l: TypeListener): void;
168
+ remove_type_listener(l: TypeListener): void;
169
+ }
170
+ interface TypeListener {
171
+ parents_updated(type: Type): void;
172
+ data_updated(type: Type): void;
173
+ static_properties_updated(type: Type): void;
174
+ dynamic_properties_updated(type: Type): void;
175
+ }
176
+ type Datum = {
177
+ data: Record<string, unknown>;
178
+ timestamp: Date;
179
+ };
180
+ class Item {
181
+ private readonly id;
182
+ private readonly type;
183
+ private properties?;
184
+ private datum?;
185
+ private slots?;
186
+ private data;
187
+ private readonly listeners;
188
+ constructor(id: string, type: Type, properties?: Record<string, unknown>, value?: Datum, slots?: Record<string, unknown>);
189
+ get_id(): string;
190
+ get_type(): Type;
191
+ get_properties(): Record<string, unknown> | undefined;
192
+ get_datum(): Datum | undefined;
193
+ get_data(): Datum[];
194
+ get_slots(): Record<string, unknown> | undefined;
195
+ _set_properties(props?: Record<string, unknown>): void;
196
+ _set_data(data: Datum[]): void;
197
+ _set_datum(datum: Datum): void;
198
+ _set_slots(slots?: Record<string, unknown>): void;
199
+ add_item_listener(l: ItemListener): void;
200
+ remove_item_listener(l: ItemListener): void;
201
+ to_string(): string;
202
+ }
203
+ interface ItemListener {
204
+ properties_updated(item: Item): void;
205
+ values_updated(item: Item): void;
206
+ new_value(item: Item, v: Datum): void;
207
+ slots_updated(item: Item): void;
208
+ }
209
+ }
210
+ class User {
211
+ private readonly id;
212
+ private readonly personal_data;
213
+ constructor(id: string, personal_data: Record<string, unknown>);
214
+ get_id(): string;
215
+ get_personal_data(): Record<string, unknown>;
216
+ }
217
+ namespace llm {
218
+ class Intent {
219
+ private readonly name;
220
+ private readonly description;
221
+ constructor(name: string, description: string);
222
+ get_name(): string;
223
+ get_description(): string;
224
+ }
225
+ enum EntityType {
226
+ string = 0,
227
+ int = 1,
228
+ float = 2,
229
+ bool = 3,
230
+ symbol = 4
231
+ }
232
+ class Entity {
233
+ private readonly name;
234
+ private readonly type;
235
+ private readonly description;
236
+ constructor(name: string, type: EntityType, description: string);
237
+ get_name(): string;
238
+ get_type(): EntityType;
239
+ get_description(): string;
240
+ }
241
+ }
242
+ }
243
+ type UpdateCoCoMessage = {
244
+ msg_type: string;
245
+ } & (CoCoMessage | NewTypeMessage | NewItemMessage | NewDataMessage);
246
+ interface CoCoMessage {
247
+ types?: Record<string, TypeMessage>;
248
+ items?: Record<string, ItemMessage>;
249
+ intents?: Record<string, IntentMessage>;
250
+ entities?: Record<string, EntityMessage>;
251
+ }
252
+ interface NewTypeMessage extends TypeMessage {
253
+ name: string;
254
+ }
255
+ interface NewItemMessage extends ItemMessage {
256
+ id: string;
257
+ }
258
+ interface NewDataMessage extends ValueMessage {
259
+ id: string;
260
+ }
261
+ interface PropMessage<V> {
262
+ type: string;
263
+ default_value?: V;
264
+ }
265
+ interface BoolPropertyMessage extends PropMessage<boolean> {
266
+ }
267
+ interface IntPropertyMessage extends PropMessage<number> {
268
+ min?: number;
269
+ max?: number;
270
+ }
271
+ interface FloatPropertyMessage extends PropMessage<number> {
272
+ min?: number;
273
+ max?: number;
274
+ }
275
+ interface StringPropertyMessage extends PropMessage<string> {
276
+ }
277
+ interface SymbolPropertyMessage extends PropMessage<string | string[]> {
278
+ multiple: boolean;
279
+ values?: string[];
280
+ }
281
+ interface ItemPropertyMessage extends PropMessage<string | string[]> {
282
+ domain: string;
283
+ multiple: boolean;
284
+ }
285
+ interface JSONPropertyMessage extends PropMessage<Record<string, any>> {
286
+ schema: Record<string, any>;
287
+ }
288
+ type PropertyMessage = BoolPropertyMessage | IntPropertyMessage | FloatPropertyMessage | StringPropertyMessage | SymbolPropertyMessage | ItemPropertyMessage | JSONPropertyMessage;
289
+ interface TypeMessage {
290
+ parents?: string[];
291
+ data?: Record<string, any>;
292
+ static_properties?: Record<string, PropertyMessage>;
293
+ dynamic_properties?: Record<string, PropertyMessage>;
294
+ }
295
+ interface ValueMessage {
296
+ data: Record<string, unknown>;
297
+ timestamp: number;
298
+ }
299
+ interface ItemMessage {
300
+ type: string;
301
+ properties?: Record<string, unknown>;
302
+ value?: ValueMessage;
303
+ }
304
+ interface IntentMessage {
305
+ name: string;
306
+ description: string;
307
+ }
308
+ interface EntityMessage {
309
+ name: string;
310
+ type: string;
311
+ description: string;
312
+ }
313
+ export {};