@bigfootai/bigfoot-types 2.6.13 → 2.7.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.
Files changed (5) hide show
  1. package/model.js +29 -23
  2. package/model.ts +43 -57
  3. package/package.json +4 -1
  4. package/utils.js +13 -0
  5. package/utils.ts +11 -0
package/model.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Table = exports.FieldVariation = exports.FieldType = exports.Template = exports.Thread = exports.ExternalTask = exports.Event = exports.EventStatus = exports.Conference = exports.Task = exports.Block = exports.Note = exports.Article = exports.Person = exports.Domain = exports.Tenant = exports.BusinessObject = exports.Tag = exports.Provider = exports.Primitive = exports.MutationType = exports.MarkType = exports.DocumentType = exports.RecurrenceRFC = exports.InviteStatus = exports.SharingApproach = exports.StepStatus = exports.TaskStatus = exports.SharingLevel = exports.ClientType = exports.TagType = exports.BlockType = exports.BusinessObjectType = void 0;
3
+ exports.Table = exports.FieldVariation = exports.FieldType = exports.Template = exports.Thread = exports.ExternalTask = exports.Event = exports.ResponseStatus = exports.EventStatus = exports.Conference = exports.Task = exports.Block = exports.Note = exports.Article = exports.Person = exports.Domain = exports.Tenant = exports.BusinessObject = exports.Tag = exports.Provider = exports.Primitive = exports.MutationType = exports.MarkType = exports.DocumentType = exports.RecurrenceRFC = exports.InviteStatus = exports.SharingApproach = exports.StepStatus = exports.TaskStatus = exports.SharingLevel = exports.ClientType = exports.TagType = exports.BlockType = exports.BusinessObjectType = void 0;
4
4
  const uuid_1 = require("uuid");
5
5
  /*
6
6
  These are the core primitives of our model. These represent the entities that show
@@ -15,8 +15,10 @@ var BusinessObjectType;
15
15
  BusinessObjectType["Document"] = "document";
16
16
  BusinessObjectType["Record"] = "record";
17
17
  BusinessObjectType["Conference"] = "conference";
18
- BusinessObjectType["Message"] = "message";
18
+ BusinessObjectType["Thread"] = "thread";
19
19
  BusinessObjectType["Website"] = "website";
20
+ BusinessObjectType["Template"] = "template";
21
+ BusinessObjectType["Table"] = "table";
20
22
  })(BusinessObjectType || (exports.BusinessObjectType = BusinessObjectType = {}));
21
23
  var BlockType;
22
24
  (function (BlockType) {
@@ -137,14 +139,13 @@ class Tag extends Primitive {
137
139
  }
138
140
  exports.Tag = Tag;
139
141
  class BusinessObject extends Primitive {
140
- constructor(provider, uri, externalId, businessObjectType, externalResponse, document) {
142
+ constructor(provider, uri, externalId, businessObjectType, externalResponse) {
141
143
  super();
142
144
  this.provider = provider;
143
145
  this.uri = uri;
144
146
  this.externalId = externalId;
145
147
  this.businessObjectType = businessObjectType;
146
148
  this.externalResponse = externalResponse;
147
- this.document = document;
148
149
  }
149
150
  }
150
151
  exports.BusinessObject = BusinessObject;
@@ -183,10 +184,9 @@ class Article extends Primitive {
183
184
  }
184
185
  exports.Article = Article;
185
186
  class Note extends Primitive {
186
- constructor(tenantIdCreated, document, editors, sharingTags, version) {
187
+ constructor(tenantIdCreated, editors, sharingTags, version) {
187
188
  super();
188
189
  this.tenantIdCreated = tenantIdCreated;
189
- this.document = document;
190
190
  this.editors = editors;
191
191
  this.sharingTags = sharingTags;
192
192
  this.version = version;
@@ -194,26 +194,25 @@ class Note extends Primitive {
194
194
  }
195
195
  exports.Note = Note;
196
196
  class Block extends Note {
197
- constructor(tenantIdCreated, document, editors, sharingTags, version, blockType, originNoteId) {
198
- super(tenantIdCreated, document, editors, sharingTags, version);
197
+ constructor(tenantIdCreated, editors, sharingTags, version, blockType, originNoteId) {
198
+ super(tenantIdCreated, editors, sharingTags, version);
199
199
  this.blockType = blockType;
200
200
  this.originNoteId = originNoteId;
201
201
  }
202
202
  }
203
203
  exports.Block = Block;
204
204
  class Task extends Block {
205
- constructor(tenantIdCreated, document, editors, sharingTags, version, originNoteId, dateDue) {
206
- super(tenantIdCreated, document, editors, sharingTags, version, BlockType.Task, originNoteId);
205
+ constructor(tenantIdCreated, editors, sharingTags, version, originNoteId, dateDue) {
206
+ super(tenantIdCreated, editors, sharingTags, version, BlockType.Task, originNoteId);
207
207
  this.status = TaskStatus.NotStarted;
208
208
  this.dateDue = dateDue;
209
209
  }
210
210
  }
211
211
  exports.Task = Task;
212
212
  class Conference extends BusinessObject {
213
- constructor(provider, uri, externalId, businessObjectType, externalResponse, document, entryPoints, transcription) {
214
- super(provider, uri, externalId, businessObjectType, externalResponse, document);
213
+ constructor(provider, uri, externalId, externalResponse, entryPoints) {
214
+ super(provider, uri, externalId, BusinessObjectType.Conference, externalResponse);
215
215
  this.entryPoints = entryPoints;
216
- this.transcription = transcription;
217
216
  }
218
217
  }
219
218
  exports.Conference = Conference;
@@ -225,9 +224,16 @@ var EventStatus;
225
224
  EventStatus["Tentative"] = "tentative";
226
225
  EventStatus["Cancelled"] = "cancelled";
227
226
  })(EventStatus || (exports.EventStatus = EventStatus = {}));
227
+ var ResponseStatus;
228
+ (function (ResponseStatus) {
229
+ ResponseStatus["NeedsAction"] = "needsAction";
230
+ ResponseStatus["Declined"] = "declined";
231
+ ResponseStatus["Tentative"] = "tentative";
232
+ ResponseStatus["Accepted"] = "accepted";
233
+ })(ResponseStatus || (exports.ResponseStatus = ResponseStatus = {}));
228
234
  class Event extends BusinessObject {
229
- constructor(provider, uri, externalId, businessObjectType, externalResponse, document, calendarId, status, location, startDate, organizedBy) {
230
- super(provider, uri, externalId, businessObjectType, externalResponse, document);
235
+ constructor(provider, uri, externalId, externalResponse, calendarId, status, location, startDate, organizedBy) {
236
+ super(provider, uri, externalId, BusinessObjectType.Event, externalResponse);
231
237
  this.calendarId = calendarId;
232
238
  this.status = status;
233
239
  this.location = location;
@@ -239,8 +245,8 @@ exports.Event = Event;
239
245
  //// EVENT END
240
246
  //// EXTERNAL TASK START
241
247
  class ExternalTask extends BusinessObject {
242
- constructor(provider, uri, externalId, businessObjectType, externalResponse, document, status, dateDue) {
243
- super(provider, uri, externalId, businessObjectType, externalResponse, document);
248
+ constructor(provider, uri, externalId, externalResponse, status, dateDue) {
249
+ super(provider, uri, externalId, BusinessObjectType.Task, externalResponse);
244
250
  this.status = status;
245
251
  this.dateDue = dateDue;
246
252
  }
@@ -249,14 +255,14 @@ exports.ExternalTask = ExternalTask;
249
255
  //// EXTERNAL TASK END
250
256
  //// MESSAGING START
251
257
  class Thread extends BusinessObject {
252
- constructor(provider, uri, externalId, businessObjectType, externalResponse, document) {
253
- super(provider, uri, externalId, businessObjectType, externalResponse, document);
258
+ constructor(provider, uri, externalId, externalResponse) {
259
+ super(provider, uri, externalId, BusinessObjectType.Thread, externalResponse);
254
260
  }
255
261
  }
256
262
  exports.Thread = Thread;
257
263
  class Template extends BusinessObject {
258
- constructor(provider, uri, externalId, businessObjectType, externalResponse, document, metadata) {
259
- super(provider, uri, externalId, businessObjectType, externalResponse, document);
264
+ constructor(provider, uri, externalId, externalResponse, metadata) {
265
+ super(provider, uri, externalId, BusinessObjectType.Template, externalResponse);
260
266
  this.metadata = metadata;
261
267
  }
262
268
  }
@@ -282,8 +288,8 @@ var FieldVariation;
282
288
  FieldVariation["Url"] = "url";
283
289
  })(FieldVariation || (exports.FieldVariation = FieldVariation = {}));
284
290
  class Table extends BusinessObject {
285
- constructor(provider, uri, externalId, businessObjectType, externalResponse, document, recordType, metadata, values) {
286
- super(provider, uri, externalId, businessObjectType, externalResponse, document);
291
+ constructor(provider, uri, externalId, externalResponse, recordType, metadata, values) {
292
+ super(provider, uri, externalId, BusinessObjectType.Table, externalResponse);
287
293
  this.recordType = recordType;
288
294
  this.metadata = metadata;
289
295
  this.values = values;
package/model.ts CHANGED
@@ -12,8 +12,10 @@ export enum BusinessObjectType {
12
12
  Document = 'document',
13
13
  Record = 'record',
14
14
  Conference = 'conference',
15
- Message = 'message',
15
+ Thread = 'thread',
16
16
  Website = 'website',
17
+ Template = 'template',
18
+ Table = 'table',
17
19
  }
18
20
 
19
21
  export enum BlockType {
@@ -226,6 +228,10 @@ export interface Changes {
226
228
  clientIds: string[];
227
229
  }
228
230
 
231
+ export interface PersonReference {
232
+ email: string;
233
+ }
234
+
229
235
  export class Primitive {
230
236
  _id: string;
231
237
  dateCreated: number;
@@ -287,16 +293,16 @@ export class BusinessObject extends Primitive {
287
293
  iconUrl?: string; // The url of an icon that represents the business object
288
294
  externalId: string; // An identifier that allows us to do entity resolution
289
295
  businessObjectType: BusinessObjectType;
290
- externalResponse: string; // The full response from the external system that created this object
291
- document: Document; // The business object formatted as a document for ML to ingest
296
+ externalResponse: any; // The full response from the external system that created this object
297
+ document?: Document; // The business object formatted as a document for ML to ingest
298
+ parentId?: string; // The business object that is the parent of this business object
292
299
 
293
300
  constructor(
294
301
  provider: string,
295
302
  uri: string,
296
303
  externalId: string,
297
304
  businessObjectType: BusinessObjectType,
298
- externalResponse: string,
299
- document: Document
305
+ externalResponse: any
300
306
  ) {
301
307
  super();
302
308
 
@@ -305,7 +311,6 @@ export class BusinessObject extends Primitive {
305
311
  this.externalId = externalId;
306
312
  this.businessObjectType = businessObjectType;
307
313
  this.externalResponse = externalResponse;
308
- this.document = document;
309
314
  }
310
315
  }
311
316
 
@@ -384,10 +389,10 @@ export class Article extends Primitive {
384
389
 
385
390
  export class Note extends Primitive {
386
391
  tenantIdCreated: string;
387
- document: string;
388
392
  editors: Editor[];
389
393
  sharingTags: SharingTag[];
390
394
  version: number;
395
+ document?: any;
391
396
  changes?: Changes;
392
397
  _sharedTags?: string[];
393
398
  reactions?: Reaction[];
@@ -395,7 +400,6 @@ export class Note extends Primitive {
395
400
 
396
401
  constructor(
397
402
  tenantIdCreated: string,
398
- document: string,
399
403
  editors: Editor[],
400
404
  sharingTags: SharingTag[],
401
405
  version: number
@@ -403,7 +407,6 @@ export class Note extends Primitive {
403
407
  super();
404
408
 
405
409
  this.tenantIdCreated = tenantIdCreated;
406
- this.document = document;
407
410
  this.editors = editors;
408
411
  this.sharingTags = sharingTags;
409
412
  this.version = version;
@@ -416,14 +419,13 @@ export class Block extends Note {
416
419
 
417
420
  constructor(
418
421
  tenantIdCreated: string,
419
- document: string,
420
422
  editors: Editor[],
421
423
  sharingTags: SharingTag[],
422
424
  version: number,
423
425
  blockType: BlockType,
424
426
  originNoteId: string
425
427
  ) {
426
- super(tenantIdCreated, document, editors, sharingTags, version);
428
+ super(tenantIdCreated, editors, sharingTags, version);
427
429
 
428
430
  this.blockType = blockType;
429
431
  this.originNoteId = originNoteId;
@@ -439,7 +441,6 @@ export class Task extends Block {
439
441
 
440
442
  constructor(
441
443
  tenantIdCreated: string,
442
- document: string,
443
444
  editors: Editor[],
444
445
  sharingTags: SharingTag[],
445
446
  version: number,
@@ -448,7 +449,6 @@ export class Task extends Block {
448
449
  ) {
449
450
  super(
450
451
  tenantIdCreated,
451
- document,
452
452
  editors,
453
453
  sharingTags,
454
454
  version,
@@ -495,29 +495,24 @@ export interface ConferenceEntrypoint {
495
495
 
496
496
  export class Conference extends BusinessObject {
497
497
  entryPoints: ConferenceEntrypoint[];
498
- transcription: Transcription;
498
+ transcription?: Transcription;
499
499
 
500
500
  constructor(
501
501
  provider: string,
502
502
  uri: string,
503
503
  externalId: string,
504
- businessObjectType: BusinessObjectType,
505
- externalResponse: string,
506
- document: Document,
507
- entryPoints: ConferenceEntrypoint[],
508
- transcription: Transcription
504
+ externalResponse: any,
505
+ entryPoints: ConferenceEntrypoint[]
509
506
  ) {
510
507
  super(
511
508
  provider,
512
509
  uri,
513
510
  externalId,
514
- businessObjectType,
515
- externalResponse,
516
- document
511
+ BusinessObjectType.Conference,
512
+ externalResponse
517
513
  );
518
514
 
519
515
  this.entryPoints = entryPoints;
520
- this.transcription = transcription;
521
516
  }
522
517
  }
523
518
  //// CONFERENCE END
@@ -529,9 +524,15 @@ export enum EventStatus {
529
524
  Cancelled = 'cancelled',
530
525
  }
531
526
 
532
- export interface PersonAcceptance {
533
- tagId: string;
534
- accepted: boolean;
527
+ export enum ResponseStatus {
528
+ NeedsAction = 'needsAction',
529
+ Declined = 'declined',
530
+ Tentative = 'tentative',
531
+ Accepted = 'accepted',
532
+ }
533
+
534
+ export interface PersonAcceptance extends PersonReference {
535
+ responseStatus: ResponseStatus;
535
536
  }
536
537
 
537
538
  export interface Calendar extends BusinessObject {
@@ -544,7 +545,7 @@ export class Event extends BusinessObject {
544
545
  calendarId: string;
545
546
  status: EventStatus;
546
547
  startDate: number;
547
- organizedBy: Person;
548
+ organizedBy: PersonReference;
548
549
  location?: string;
549
550
  originalStartDate?: number;
550
551
  recurrence?: RecurrenceRFC[];
@@ -559,9 +560,7 @@ export class Event extends BusinessObject {
559
560
  provider: string,
560
561
  uri: string,
561
562
  externalId: string,
562
- businessObjectType: BusinessObjectType,
563
- externalResponse: string,
564
- document: any,
563
+ externalResponse: any,
565
564
  calendarId: string,
566
565
  status: EventStatus,
567
566
  location: string,
@@ -572,9 +571,8 @@ export class Event extends BusinessObject {
572
571
  provider,
573
572
  uri,
574
573
  externalId,
575
- businessObjectType,
576
- externalResponse,
577
- document
574
+ BusinessObjectType.Event,
575
+ externalResponse
578
576
  );
579
577
 
580
578
  this.calendarId = calendarId;
@@ -598,9 +596,7 @@ export class ExternalTask extends BusinessObject {
598
596
  provider: string,
599
597
  uri: string,
600
598
  externalId: string,
601
- businessObjectType: BusinessObjectType,
602
- externalResponse: string,
603
- document: Document,
599
+ externalResponse: any,
604
600
  status: TaskStatus,
605
601
  dateDue: number
606
602
  ) {
@@ -608,9 +604,8 @@ export class ExternalTask extends BusinessObject {
608
604
  provider,
609
605
  uri,
610
606
  externalId,
611
- businessObjectType,
612
- externalResponse,
613
- document
607
+ BusinessObjectType.Task,
608
+ externalResponse
614
609
  );
615
610
 
616
611
  this.status = status;
@@ -625,17 +620,14 @@ export class Thread extends BusinessObject {
625
620
  provider: string,
626
621
  uri: string,
627
622
  externalId: string,
628
- businessObjectType: BusinessObjectType,
629
- externalResponse: string,
630
- document: Document
623
+ externalResponse: any
631
624
  ) {
632
625
  super(
633
626
  provider,
634
627
  uri,
635
628
  externalId,
636
- businessObjectType,
637
- externalResponse,
638
- document
629
+ BusinessObjectType.Thread,
630
+ externalResponse
639
631
  );
640
632
  }
641
633
  }
@@ -668,18 +660,15 @@ export class Template extends BusinessObject {
668
660
  provider: string,
669
661
  uri: string,
670
662
  externalId: string,
671
- businessObjectType: BusinessObjectType,
672
- externalResponse: string,
673
- document: Document,
663
+ externalResponse: any,
674
664
  metadata: DocumentMetadata
675
665
  ) {
676
666
  super(
677
667
  provider,
678
668
  uri,
679
669
  externalId,
680
- businessObjectType,
681
- externalResponse,
682
- document
670
+ BusinessObjectType.Template,
671
+ externalResponse
683
672
  );
684
673
 
685
674
  this.metadata = metadata;
@@ -748,9 +737,7 @@ export class Table extends BusinessObject {
748
737
  provider: string,
749
738
  uri: string,
750
739
  externalId: string,
751
- businessObjectType: BusinessObjectType,
752
- externalResponse: string,
753
- document: Document,
740
+ externalResponse: any,
754
741
  recordType: string,
755
742
  metadata: TableMetadata,
756
743
  values: FieldValue[]
@@ -759,9 +746,8 @@ export class Table extends BusinessObject {
759
746
  provider,
760
747
  uri,
761
748
  externalId,
762
- businessObjectType,
763
- externalResponse,
764
- document
749
+ BusinessObjectType.Table,
750
+ externalResponse
765
751
  );
766
752
 
767
753
  this.recordType = recordType;
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "author": "Bigfoot",
3
3
  "name": "@bigfootai/bigfoot-types",
4
- "version": "2.6.13",
4
+ "version": "2.7.0",
5
5
  "description": "The internal library for the types used in the Bigfoot platform",
6
6
  "main": "model.js",
7
7
  "license": "ISC",
8
8
  "repository": "Notify-AI/bigfoot-types",
9
9
  "dependencies": {
10
+ "parse5": "^7.1.2",
11
+ "prosemirror-model": "^1.19.4",
12
+ "prosemirror-schema-basic": "^1.2.2",
10
13
  "uuid": "^9.0.1"
11
14
  },
12
15
  "devDependencies": {
package/utils.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseHtmlToDocument = void 0;
4
+ const prosemirror_model_1 = require("prosemirror-model");
5
+ const prosemirror_schema_basic_1 = require("prosemirror-schema-basic");
6
+ const parse5_1 = require("parse5");
7
+ const parseHtmlToDocument = (html) => {
8
+ // Parse the html into a DOM
9
+ const document = (0, parse5_1.parse)(html);
10
+ // Only take the body of the document
11
+ return prosemirror_model_1.DOMParser.fromSchema(prosemirror_schema_basic_1.schema).parse(document.nodeName['body']);
12
+ };
13
+ exports.parseHtmlToDocument = parseHtmlToDocument;
package/utils.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { DOMParser } from 'prosemirror-model';
2
+ import { schema } from 'prosemirror-schema-basic';
3
+ import { parse } from 'parse5';
4
+
5
+ export const parseHtmlToDocument = (html: string): Record<string, any> => {
6
+ // Parse the html into a DOM
7
+ const document = parse(html);
8
+
9
+ // Only take the body of the document
10
+ return DOMParser.fromSchema(schema).parse(document.nodeName['body']);
11
+ };