Skip to content

Commit 59d3ac3

Browse files
committed
feat: Add serialization support with pack/unpack and getById functions
This release adds new functionality for serializing and deserializing Deep structures: - Added getById function to find Deep instances by their ID - Added pack getter to serialize Selection into a portable format - Added unpack function to deserialize packed data back into Selection - Optimized unpack to use select({ or }) instead of manual selection building - Added comprehensive tests for serialization/deserialization flow - Fixed langchain tests temporary disable - Bump version to 7.0.0-alpha.2
1 parent 4bfe2a8 commit 59d3ac3

File tree

17 files changed

+9484
-6665
lines changed

17 files changed

+9484
-6665
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ next-env.d.ts
4848
typedoc
4949
wiki
5050
.obsidian
51+
.models

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ next-env.d.ts
5252
typedoc
5353
wiki
5454
.obsidian
55+
.models

README.md

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ Core Functionality:
7070
- [x] Uniform interface for all data types
7171
- [x] Reactive event system
7272
- [x] Complex querying with logical operators
73-
- [x] Chainable operations on collections
73+
- [ ] Event generation and applying
74+
- [ ] Export Selection to JSON and import as Selection
7475
- [ ] Transaction support
7576
- [ ] Distributed computation support
7677

@@ -293,13 +294,6 @@ In this example:
293294
- We can perform multiple traversals by chaining operations
294295
- Each traversal returns a Deep instance that can be further queried
295296

296-
### Uniform Data Handling
297-
298-
A key feature of Deep is its uniform approach to handling both single items and collections:
299-
- When working with a single item, it's treated as a collection of one element where the item serves as both key and value
300-
- The same methods work consistently across different data types (Symbol, Promise, Boolean, String, Number, BigInt, Set, Map, Array, Object, Function)
301-
- This uniformity allows for seamless transitions between single and multiple data operations
302-
303297
### Association in Deep
304298

305299
An association (link) consists of the following components:
@@ -308,6 +302,38 @@ An association (link) consists of the following components:
308302
- **to** - link target (Deep)
309303
- **value** - link value (can be any data type)
310304

305+
When creating associations in Deep, there are several important patterns to understand:
306+
307+
#### Creating Associations from Other Associations
308+
309+
When you create a new association using the `.new()` method from an existing association:
310+
1. The association you're calling `.new()` from becomes the type of the new association
311+
2. The optional argument passed to `.new()` becomes the value of the new association
312+
3. For primitive JavaScript values (strings, numbers, booleans), the value is automatically wrapped in a special container for deduplication
313+
314+
Example:
315+
```typescript
316+
const Type = deep.new();
317+
const instance1 = Type.new('value1'); // Creates new association with Type as type and wrapped 'value1' as value
318+
const instance2 = Type.new('value1'); // Reuses the same wrapped value due to deduplication
319+
console.log(instance1.value); // Deep with .value == 'value1'
320+
console.log(instance1.value === instance2.value); // true - same wrapped value reference
321+
console.log(instance1.call, 'value1'); // true - возвращает конечное значение
322+
```
323+
324+
This pattern enables:
325+
- Type-safe association creation
326+
- Automatic value deduplication
327+
- Memory optimization for primitive values
328+
- Consistent handling of values across the system
329+
330+
### Uniform Data Handling
331+
332+
A key feature of Deep is its uniform approach to handling both single items and collections:
333+
- When working with a single item, it's treated as a collection of one element where the item serves as both key and value
334+
- The same methods work consistently across different data types (Symbol, Promise, Boolean, String, Number, BigInt, Set, Map, Array, Object, Function)
335+
- This uniformity allows for seamless transitions between single and multiple data operations
336+
311337
### Association Capabilities
312338
- Creating new associations
313339
- Modifying properties (type, from, to, value)
@@ -316,12 +342,10 @@ An association (link) consists of the following components:
316342
- Searching links by various parameters
317343

318344
### Project Features
319-
- Support for various data types (Symbol, Promise, Boolean, String, Number, BigInt, Set, Map, Array, Object, Function)
320-
- Event system
321-
- Change observation
322-
- Support for both web and native platforms (iOS, Android, Electron)
323-
- Graph visualization
324-
- Modern UI
345+
- Support for various .value types (Symbol, Promise, Boolean, String, Number, BigInt, Set, Map, Array, Object, Function)
346+
- Event system `deep.on(event => {})`
347+
- Change observation `selection.on(event => {})`
348+
- Support for terminal (cli) web (NextJS) and native platforms (iOS, Android, Electron)
325349

326350
### Technical Characteristics
327351
- TypeScript as the main language

0 commit comments

Comments
 (0)