@@ -45,8 +45,8 @@ const mMyLifeTeams = [
45
45
{
46
46
active : true ,
47
47
allowCustom : true ,
48
- allowedTypes : [ 'artworks' , 'editor' , 'idea' , 'library' , ' marketing'] ,
49
- defaultTypes : [ 'artworks' , 'idea' , 'library' , ] ,
48
+ allowedTypes : [ 'artworks' , 'editor' , 'idea' , 'marketing' ] ,
49
+ defaultTypes : [ 'artworks' , 'idea' , ] ,
50
50
description : 'The Creative Team is dedicated to help you experience productive creativity sessions.' ,
51
51
id : '84aa50ca-fb64-43d8-b140-31d2373f3cd2' ,
52
52
name : 'creative' ,
@@ -65,8 +65,8 @@ const mMyLifeTeams = [
65
65
{
66
66
active : true ,
67
67
allowCustom : true ,
68
- allowedTypes : [ 'diary' , 'journaler' , 'library' , ' personal-biographer', ] ,
69
- defaultTypes : [ 'personal-biographer' , 'library' , ] ,
68
+ allowedTypes : [ 'diary' , 'journaler' , 'personal-biographer' , ] ,
69
+ defaultTypes : [ 'personal-biographer' , ] ,
70
70
description : 'The Memoir Team is dedicated to help you document your life stories, experiences, thoughts, and feelings.' ,
71
71
id : 'a261651e-51b3-44ec-a081-a8283b70369d' ,
72
72
name : 'memoir' ,
@@ -95,8 +95,8 @@ const mMyLifeTeams = [
95
95
{
96
96
active : false ,
97
97
allowCustom : true ,
98
- allowedTypes : [ 'library' , ' note', 'poem' , 'quote' , 'religion' , ] ,
99
- defaultTypes : [ 'library' , ' quote', 'religion' , ] ,
98
+ allowedTypes : [ 'note' , 'poem' , 'quote' , 'religion' , ] ,
99
+ defaultTypes : [ 'quote' , 'religion' , ] ,
100
100
description : 'The Spirituality Team is dedicated to help you creatively explore your spiritual side.' ,
101
101
id : 'bea7bb4a-a339-4026-ad1c-75f604dc3349' ,
102
102
name : 'sprituality' ,
@@ -105,8 +105,8 @@ const mMyLifeTeams = [
105
105
{
106
106
active : true ,
107
107
allowCustom : true ,
108
- allowedTypes : [ 'data-ownership' , 'investment' , 'library' , ' ubi', ] ,
109
- defaultTypes : [ 'library' , ' ubi'] ,
108
+ allowedTypes : [ 'data-ownership' , 'investment' , 'ubi' , ] ,
109
+ defaultTypes : [ 'ubi' ] ,
110
110
description : 'The Universal Basic Income (UBI) Team is dedicated to helping you tailor your MyLife revenue streams based upon consensual access to your personal MyLife data.' ,
111
111
id : '8a4d7340-ac62-40f1-8c77-f17c68797925' ,
112
112
name : 'ubi' ,
@@ -398,54 +398,6 @@ class BotFactory extends EventEmitter{
398
398
async help ( thread_id , bot_id , helpRequest , avatar ) {
399
399
return await mHelp ( thread_id , bot_id , helpRequest , this , avatar )
400
400
}
401
- /**
402
- * Gets, creates or updates Library in Cosmos.
403
- * @todo - institute bot for library mechanics.
404
- * @public
405
- * @param {Object } _library - The library object, including items to be added to/updated in member's library.
406
- * @returns {object } - The library.
407
- */
408
- async library ( _library ) {
409
- const updatedLibrary = await mLibrary ( this , _library )
410
- // test the type/form of Library
411
- switch ( updatedLibrary . type ) {
412
- case 'story' :
413
- if ( updatedLibrary . form === 'biographer' ) {
414
- // inflate and update library with stories
415
- const stories = ( await this . stories ( updatedLibrary . form ) )
416
- . filter ( story => ! this . globals . isValidGuid ( story ?. library_id ) )
417
- . map ( story => {
418
- const { mbr_name, newGuid } = this
419
- const { author= mbr_name , id= newGuid , title= mbr_name , } = story
420
- story = {
421
- ...story ,
422
- author,
423
- id,
424
- title,
425
- }
426
- return mInflateLibraryItem ( story , updatedLibrary . id , mbr_id )
427
- } )
428
- updatedLibrary . items = [
429
- ...updatedLibrary . items ,
430
- ...stories ,
431
- ]
432
- /* update stories (no await) */
433
- stories . forEach ( story => this . dataservices . patch (
434
- story . id ,
435
- { library_id : updatedLibrary . id } ,
436
- ) )
437
- /* update library (no await) */
438
- this . dataservices . patch (
439
- updatedLibrary . id ,
440
- { items : updatedLibrary . items } ,
441
- )
442
- }
443
- break
444
- default :
445
- break
446
- }
447
- return updatedLibrary
448
- }
449
401
/**
450
402
* Allows member to reset passphrase.
451
403
* @param {string } passphrase
@@ -468,7 +420,6 @@ class BotFactory extends EventEmitter{
468
420
}
469
421
/**
470
422
* Gets a collection of stories of a certain format.
471
- * @todo - currently disconnected from a library, but no decisive mechanic for incorporating library shell.
472
423
* @param {string } form - The form of the stories to retrieve.
473
424
* @returns {object[] } - The stories.
474
425
*/
@@ -770,21 +721,6 @@ class AgentFactory extends BotFactory {
770
721
isSession ( _session ) { // when unavailable from general schemas
771
722
return ( _session instanceof mSchemas . session )
772
723
}
773
- /**
774
- * Adds or updates a library with items outlined in request `library.items` array. Note: currently the override for `botFactory` function .library which returns a library item from the database.
775
- * @todo : finalize mechanic for overrides
776
- * @param {Object } _library - The library object, including items to be added to member's library.
777
- * @returns {Object } - The complete library object from Cosmos.
778
- */
779
- async library ( _library ) {
780
- /* hydrate library micro-bot */
781
- const { bot_id, mbr_id } = _library
782
- const _microBot = await this . libraryBot ( bot_id , mbr_id )
783
- return await _microBot . library ( _library )
784
- }
785
- async libraryBot ( id ) {
786
- return await this . bot ( id , 'library' )
787
- }
788
724
/**
789
725
* Saves a completed lived experience to MyLife.
790
726
* @param {Object } experience - The Lived Experience Object to save.
@@ -1530,118 +1466,6 @@ async function mHelp(thread_id, bot_id, helpRequest, factory, avatar){
1530
1466
const response = await mLLMServices . help ( thread_id , bot_id , helpRequest , factory , avatar )
1531
1467
return response
1532
1468
}
1533
- /**
1534
- * Inflates library item with required values and structure. Object structure expected from API, librayItemItem in JSON.
1535
- * root\inc\json-schemas\bots\library-bot.json
1536
- * @param {object } _item - Library item (API) object. { author: string, enjoymentLevel: number, format: string, insights: string, personalImpact: string, title: string, whenRead: string }
1537
- * @param {string } _library_id - Library id
1538
- * @param {string } _mbr_id - Member id
1539
- * @returns {object } - Library-item object. { assistantType: string, author_match: array, being: string, date: string, format: string, id: string, item: object, library_id: string, object_id: string, title_match: string
1540
- */
1541
- function mInflateLibraryItem ( _item , _library_id , _mbr_id ) {
1542
- const _id = _item . id ?? mNewGuid ( )
1543
- return {
1544
- assistantType : _item . assistantType ?? 'mylife-library' ,
1545
- author_match : ( _item . author ?? 'unknown-author' )
1546
- . trim ( )
1547
- . toLowerCase ( )
1548
- . split ( ' ' ) ,
1549
- being : 'library-item' ,
1550
- date : _item . date ?? new Date ( ) . toISOString ( ) ,
1551
- format : _item . format ?? _item . form ?? _item . type ?? 'book' ,
1552
- id : _id ,
1553
- item : { ..._item , id : _id } ,
1554
- library_id : _library_id ,
1555
- object_id : _library_id ,
1556
- title_match : ( _item . title ?? 'untitled' )
1557
- . trim ( )
1558
- . toLowerCase ( ) ,
1559
- }
1560
- }
1561
- /**
1562
- * Hydrates library and returns library object.
1563
- * @module
1564
- * @private
1565
- * @param {BotFactory } factory - BotFactory object
1566
- * @param {object } _library - Library object
1567
- * @returns {object } - Library object
1568
- */
1569
- async function mLibrary ( factory , _library ) {
1570
- // @todo : micro-avatar for representation of bot(s)
1571
- // @todo : Bot class with extension for things like handling libraries
1572
- // @todo : bot-extenders so that I can get this functionality into that object context
1573
- /* constants */
1574
- const { assistantType, form= 'collection' , id, items : _libraryItems = [ ] , mbr_id, type } = _library
1575
- const _avatar_id = factory . avatarId
1576
- // add/get correct library; default to core (object_id=avatar_id && type)
1577
- /* parse and cast _libraryItems */
1578
- let _libraryCosmos = await factory . dataservices . library ( id , _avatar_id , type , form )
1579
- // @dodo : currently only book/story library items are supported
1580
- if ( ! _libraryCosmos ) { // create when undefined
1581
- // @todo : microbot should have a method for these
1582
- const _library_id = factory . newGuid
1583
- _libraryCosmos = {
1584
- being : `library` ,
1585
- form : form ,
1586
- id : _library_id ,
1587
- items : _libraryItems . map ( _item => mInflateLibraryItem ( _item , _library_id , mbr_id ) ) ,
1588
- mbr_id : mbr_id ,
1589
- name : [ 'library' , type , form , _avatar_id ] . join ( '_' ) ,
1590
- object_id : _avatar_id ,
1591
- type : type ,
1592
- }
1593
- factory . dataservices . pushItem ( _libraryCosmos ) // push to Cosmos
1594
- } else {
1595
- // @todo : manage multiple libraries
1596
- const { id : _library_id , items : _storedLibraryItems } = _libraryCosmos
1597
- _libraryItems . forEach ( _item => {
1598
- _item = mInflateLibraryItem ( _item , _library_id , mbr_id )
1599
- const matchIndex = _storedLibraryItems . findIndex ( storedItem => { // Find the index of the item in the stored library items that matches the criteria
1600
- if ( storedItem . id === _item . id || storedItem . title_match === _item . title_match )
1601
- return true
1602
- const storedAuthorWords = storedItem . author_match
1603
- const incomingAuthorWords = _item . author_match
1604
- const authorMatches = ( ( ) => {
1605
- if ( storedAuthorWords . length === 1 || incomingAuthorWords . length === 1 ) { // If either author array has a length of 1, check for any matching word
1606
- return storedAuthorWords . some ( word => incomingAuthorWords . includes ( word ) )
1607
- } else { // If both have 2+ lengths, ensure at least 2 items match
1608
- const matches = storedAuthorWords . filter ( word => incomingAuthorWords . includes ( word ) )
1609
- return matches . length >= 2
1610
- }
1611
- } ) ( )
1612
- if ( authorMatches && matchIndex !== - 1 ) { // Mutate the author to the one with more details if needed
1613
- if ( incomingAuthorWords . length > storedAuthorWords . length ) {
1614
- _storedLibraryItems [ matchIndex ] . author_match = incomingAuthorWords // Update to more detailed author
1615
- }
1616
- }
1617
- return authorMatches
1618
- } )
1619
- if ( matchIndex !== - 1 ) { // If a match is found, update the entry
1620
- _storedLibraryItems [ matchIndex ] = {
1621
- ..._storedLibraryItems [ matchIndex ] , // Keep existing properties
1622
- ..._item , // Overwrite and add new properties from _item
1623
- id : _storedLibraryItems [ matchIndex ] . id
1624
- ?? factory . newGuid , // if for some reason object hasn't id
1625
- object_id : _library_id ,
1626
- type : _item . type
1627
- ?? 'book' ,
1628
- }
1629
- } else {
1630
- _storedLibraryItems . push ( { // If no match is found, add the item to the library
1631
- ..._item ,
1632
- id : _item . id ?? factory . newGuid , // Ensure each item has a unique ID
1633
- mbr_id : factory . mbr_id ,
1634
- object_id : _library_id ,
1635
- type : _item . type ?? 'book' ,
1636
- } )
1637
- }
1638
- } )
1639
- // save library to Cosmos @todo : microbot should have a method for this
1640
- _libraryCosmos . items = _storedLibraryItems
1641
- factory . dataservices . patch ( _library_id , { items : _libraryCosmos . items } )
1642
- }
1643
- return _libraryCosmos
1644
- }
1645
1469
/**
1646
1470
* Returns whether or not the factory is the MyLife server, as various functions are not available to the server and some _only_ to the server.
1647
1471
* @param {string } _mbr_id
0 commit comments