@jsfkit/types 1.1.0 → 1.2.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 (2) hide show
  1. package/dist/index.d.ts +170 -2
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,9 +1,22 @@
1
1
  /**
2
2
  * Defines the type of a value contained within a cell.
3
+ *
4
+ * | Value | Type | Notes |
5
+ * |-------|---------|--------------------------------------------------------------------------|
6
+ * | `b` | Boolean | |
7
+ * | `e` | Error | Formula error (cell value is the error code as a string) |
8
+ * | `n` | Number | Either integer or float |
9
+ * | `d` | Date | The {@link Cell.s | cell style} formats the integer cell value as a date |
10
+ * | `s` | Text | |
11
+ * | `z` | Empty | Cell is empty |
3
12
  */
4
13
  type CellValueType = 'b' | 'e' | 'n' | 'd' | 's' | 'z';
5
14
 
6
- /** A cell comment. */
15
+ /**
16
+ * A cell comment.
17
+ *
18
+ * @deprecated Use {@link Note | notes} and {@link ThreadedComment | threaded comments} instead.
19
+ */
7
20
  type Comment = {
8
21
  /** Author of the comment. */
9
22
  a: string;
@@ -52,6 +65,8 @@ type Cell = {
52
65
  s?: integer;
53
66
  /**
54
67
  * Comments associated with the cell.
68
+ *
69
+ * @deprecated Use a worksheet's {@link Worksheet.notes | notes} and {@link Worksheet.comments | threaded comments} instead.
55
70
  */
56
71
  c?: Comment[];
57
72
  /**
@@ -129,6 +144,11 @@ type ExternalWorksheet = {
129
144
  * inputs to formulas in other sheets.
130
145
  */
131
146
  cells: Record<CellId, Cell>;
147
+ /**
148
+ * Indicates that the sheet data could not be refreshed/fetched from the external workbook.
149
+ * In XLSX, this corresponds to the refreshError="1" attribute on sheetData.
150
+ */
151
+ refreshError?: boolean;
132
152
  };
133
153
 
134
154
  /**
@@ -146,6 +166,11 @@ type External = {
146
166
  sheets: ExternalWorksheet[];
147
167
  /** Relevant defined names from an external workbook. */
148
168
  names: DefinedName[];
169
+ /**
170
+ * Indicates that the path to the external workbook file is unknown or missing.
171
+ * In XLSX, this corresponds to the xlPathMissing relationship type.
172
+ */
173
+ pathMissing?: boolean;
149
174
  };
150
175
 
151
176
  /**
@@ -177,6 +202,21 @@ type GridSize = {
177
202
  s?: integer;
178
203
  };
179
204
 
205
+ /**
206
+ * An annotation associated with a cell.
207
+ *
208
+ * There is a maximum of one note per cell, and there is no way to reply to a note. For cell
209
+ * annotations with replies, see {@link ThreadedComment} and {@link Worksheet.comments}.
210
+ */
211
+ type Note = {
212
+ /** Cell to which the note is attached (e.g. A1, E24). */
213
+ ref: CellId;
214
+ /** Name of the person who originally made this note. */
215
+ author: string;
216
+ /** Body text of the note. */
217
+ text: string;
218
+ };
219
+
180
220
  /**
181
221
  * The style to use when drawing a cell border. If the worksheet's zoom factor is changed the width
182
222
  * of the border is expected to stay the same.
@@ -519,6 +559,125 @@ type Table = {
519
559
  style?: TableStyle;
520
560
  };
521
561
 
562
+ /**
563
+ * Base type for text runs that annotate ranges within threaded comment text.
564
+ *
565
+ * A text run identifies a contiguous range of characters in the comment text, specified by
566
+ * zero-indexed start and end positions. Text runs allow metadata to be attached to specific
567
+ * portions of text, enabling features such as hyperlinks, mentions, and formatting.
568
+ *
569
+ * ## How text runs work
570
+ *
571
+ * Each text run specifies a range within the comment text using `start` (inclusive) and `end`
572
+ * (exclusive) character positions. For example, in the text "Hello @foo", a mention text run
573
+ * for "@foo" would have `start: 6` and `end: 10`.
574
+ *
575
+ * Multiple text runs can exist within a single comment, allowing different types of annotations
576
+ * to coexist (a mention and a hyperlink in the same text, for example).
577
+ *
578
+ * @see {@link MentionTextRun} for mentions of people
579
+ * @see {@link HyperlinkTextRun} for hyperlinks
580
+ */
581
+ type TextRun = {
582
+ /** Starting character position of the run in the text (zero-indexed). */
583
+ start: integer;
584
+ /** Ending character position of the run in the text (zero-indexed, exclusive). */
585
+ end: integer;
586
+ };
587
+
588
+ /**
589
+ * A {@link TextRun | text run} representing a hyperlink within a threaded comment's text.
590
+ */
591
+ type HyperlinkTextRun = TextRun & {
592
+ /** Discriminator to identify this as a hyperlink text run. */
593
+ type: 'hyperlink';
594
+ /** The URL that the hyperlink points to. */
595
+ url: string;
596
+ };
597
+
598
+ /**
599
+ * A {@link TextRun | text run} representing a mention of a person within a threaded comment's text.
600
+ */
601
+ type MentionTextRun = TextRun & {
602
+ /** Discriminator to identify this as a mention text run. */
603
+ type: 'mention';
604
+ /**
605
+ * Unique identifier of the person being mentioned. Use this to find the person's details in a
606
+ * {@link Workbook.people | workbook's list of people}.
607
+ *
608
+ * Excel always uses a UUID in the format `{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`, but JSF makes
609
+ * no strict requirement.
610
+ */
611
+ personId: string;
612
+ };
613
+
614
+ /**
615
+ * An author of a threaded comment, or a person mentioned in a threaded comment.
616
+ */
617
+ type Person = {
618
+ /**
619
+ * A unique id for the person.
620
+ *
621
+ * Excel always uses a UUID in the format `{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`, but JSF makes
622
+ * no strict requirement.
623
+ */
624
+ id: string;
625
+ /** The person's name as it should be shown to other users. */
626
+ displayName: string;
627
+ /**
628
+ * Optional provider-issued user identifier that varies in format depending on the provider. See
629
+ * {@link Person.providerId} for details on possible values.
630
+ */
631
+ userId?: string;
632
+ /**
633
+ * Specifies where the person's information came from. Excel supports the following values:
634
+ *
635
+ * - `None`: no specific provider; {@link Person.userId} is expected to be the person's name.
636
+ * - `AD`: Active Directory; {@link Person.userId} will be Active Directory id.
637
+ * - `Windows Live`: Microsoft account; {@link Person.userId} will be a 64-bit signed decimal.
638
+ * - `PeoplePicker`: SharePoint People Picker; {@link Person.userId} will be an email address.
639
+ */
640
+ providerId?: string;
641
+ };
642
+
643
+ /**
644
+ * A threaded comment that is attached to an individual cell.
645
+ */
646
+ type ThreadedComment = {
647
+ /**
648
+ * Unique identifier for the comment.
649
+ *
650
+ * Excel always uses a UUID in the format `{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`, but JSF makes
651
+ * no strict requirement.
652
+ */
653
+ id: string;
654
+ /**
655
+ * Unique identifier of the parent comment, if this is a reply in a thread.
656
+ *
657
+ * Excel always uses a UUID in the format `{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`, but JSF makes
658
+ * no strict requirement.
659
+ */
660
+ parentId?: string;
661
+ /** A1-style reference to the cell this comment is attached to. */
662
+ ref: CellId;
663
+ /** Date and time the comment was written, as an ISO formatted string. */
664
+ datetime?: string;
665
+ /**
666
+ * Unique identifier of the person who authored this comment. Use this to find the person's
667
+ * details in a {@link Workbook.people | workbook's list of people}.
668
+ *
669
+ * Excel always uses a UUID in the format `{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`, but JSF makes
670
+ * no strict requirement.
671
+ */
672
+ personId: string;
673
+ /** The comment text content. */
674
+ text: string;
675
+ /** Whether the comment has been marked as resolved. */
676
+ resolved?: boolean;
677
+ /** {@link TextRun | Text runs} that annotate ranges within the comment text. */
678
+ runs?: (MentionTextRun | HyperlinkTextRun)[];
679
+ };
680
+
522
681
  /**
523
682
  * Directions on how formulas should be recalculated in the workbook.
524
683
  */
@@ -638,6 +797,8 @@ type Worksheet = {
638
797
  name: string;
639
798
  /** The cells belonging to the worksheet that have some data attached. */
640
799
  cells: Record<CellId, Cell>;
800
+ comments?: ThreadedComment[];
801
+ notes?: Note[];
641
802
  /** Widths and styles of the columns in the worksheet. */
642
803
  columns?: GridSize[];
643
804
  /** Heights and styles of the rows in the worksheet. */
@@ -711,6 +872,13 @@ type Workbook = {
711
872
  formulas?: string[];
712
873
  /** The different display configurations saved for the workbook. */
713
874
  views?: WorkbookView[];
875
+ /**
876
+ * Individuals who have written a threaded comment in this workbook, or who have been mentioned in
877
+ * one.
878
+ *
879
+ * @see {@link ThreadedComment}
880
+ */
881
+ people?: Person[];
714
882
  };
715
883
 
716
- export type { BorderStyle, CalcProps, Cell, CellId, CellRange, CellValueType, Color, Comment, DefinedName, External, ExternalWorksheet, GridSize, HAlign, PatternStyle, PixelValue, Style, Table, TableColumn, TableColumnDataType, TableStyle, TableStyleName, Underline, VAlign, Workbook, WorkbookView, Worksheet, WorksheetDefaults, WorksheetLayoutScales, WorksheetView };
884
+ export type { BorderStyle, CalcProps, Cell, CellId, CellRange, CellValueType, Color, Comment, DefinedName, External, ExternalWorksheet, GridSize, HAlign, HyperlinkTextRun, MentionTextRun, Note, PatternStyle, Person, PixelValue, Style, Table, TableColumn, TableColumnDataType, TableStyle, TableStyleName, TextRun, ThreadedComment, Underline, VAlign, Workbook, WorkbookView, Worksheet, WorksheetDefaults, WorksheetLayoutScales, WorksheetView };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsfkit/types",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "TypeScript types for JSF: a JSON spreadsheet representation",
5
5
  "license": "MIT",
6
6
  "type": "module",