@jsfkit/types 1.1.0 → 1.3.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 +208 -21
  2. package/package.json +6 -6
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;
@@ -13,6 +26,42 @@ type Comment = {
13
26
  t: string;
14
27
  };
15
28
 
29
+ /**
30
+ * A cell coordinate in an uppercase A1-style reference format (e.g. `AG14`).
31
+ *
32
+ * The lower top-left bounds of the reference are A1-inclusive, and the upper bottom-right bound are
33
+ * `XFD1048576` inclusive.
34
+ *
35
+ * @pattern ^[A-Z]{1,3}[0-9]{1,7}$
36
+ */
37
+ type CellId = string;
38
+
39
+ /**
40
+ * A cell coordinate range in an uppercase A1-style reference format (e.g. `H6:J36`).
41
+ *
42
+ * The range consists of two {@link CellId | CellIds} separated by a colon (`:`) character.
43
+ *
44
+ * @pattern ^([A-Z]{1,3}[0-9]{1,7}):([A-Z]{1,3}[0-9]{1,7})$
45
+ */
46
+ type CellRange = string;
47
+
48
+ /**
49
+ * Data table configuration, present on the master cell of a data table range.
50
+ * Represents an Excel What-If Analysis data table.
51
+ */
52
+ type DataTable = {
53
+ /** Range of cells the data table manages (e.g., "D3:D5") */
54
+ ref: CellRange;
55
+ /** Primary input cell reference to substitute */
56
+ r1: CellId;
57
+ /** Secondary input cell reference, for 2D data tables */
58
+ r2?: CellId;
59
+ /** Whether one-dimensional data table is a row (true) or a column (false/absent) */
60
+ dtr?: boolean;
61
+ /** Whether this is a two-dimensional data table */
62
+ dt2D?: boolean;
63
+ };
64
+
16
65
  /**
17
66
  * A whole number without a fractional value.
18
67
  */
@@ -52,6 +101,8 @@ type Cell = {
52
101
  s?: integer;
53
102
  /**
54
103
  * Comments associated with the cell.
104
+ *
105
+ * @deprecated Use a worksheet's {@link Worksheet.notes | notes} and {@link Worksheet.comments | threaded comments} instead.
55
106
  */
56
107
  c?: Comment[];
57
108
  /**
@@ -60,27 +111,10 @@ type Cell = {
60
111
  * property).
61
112
  */
62
113
  t?: CellValueType;
114
+ /** Data table configuration. Present on the master cell of a data table range. */
115
+ dt?: DataTable;
63
116
  };
64
117
 
65
- /**
66
- * A cell coordinate in an uppercase A1-style reference format (e.g. `AG14`).
67
- *
68
- * The lower top-left bounds of the reference are A1-inclusive, and the upper bottom-right bound are
69
- * `XFD1048576` inclusive.
70
- *
71
- * @pattern ^[A-Z]{1,3}[0-9]{1,3}$
72
- */
73
- type CellId = string;
74
-
75
- /**
76
- * A cell coordinate range in an uppercase A1-style reference format (e.g. `H6:J36`).
77
- *
78
- * The range consists of two {@link CellId | CellIds} separated by a colon (`:`) character.
79
- *
80
- * @pattern ^([A-Z]{1,3}[0-9]{1,3}):([A-Z]{1,3}[0-9]{1,3})$
81
- */
82
- type CellRange = string;
83
-
84
118
  /**
85
119
  * A defined name (also called "named range") is a labelled reference to a cell, range, constant or
86
120
  * formula. Meaningful labels can make formula expressions more readable and more robust to
@@ -129,6 +163,11 @@ type ExternalWorksheet = {
129
163
  * inputs to formulas in other sheets.
130
164
  */
131
165
  cells: Record<CellId, Cell>;
166
+ /**
167
+ * Indicates that the sheet data could not be refreshed/fetched from the external workbook.
168
+ * In XLSX, this corresponds to the refreshError="1" attribute on sheetData.
169
+ */
170
+ refreshError?: boolean;
132
171
  };
133
172
 
134
173
  /**
@@ -146,6 +185,11 @@ type External = {
146
185
  sheets: ExternalWorksheet[];
147
186
  /** Relevant defined names from an external workbook. */
148
187
  names: DefinedName[];
188
+ /**
189
+ * Indicates that the path to the external workbook file is unknown or missing.
190
+ * In XLSX, this corresponds to the xlPathMissing relationship type.
191
+ */
192
+ pathMissing?: boolean;
149
193
  };
150
194
 
151
195
  /**
@@ -177,6 +221,21 @@ type GridSize = {
177
221
  s?: integer;
178
222
  };
179
223
 
224
+ /**
225
+ * An annotation associated with a cell.
226
+ *
227
+ * There is a maximum of one note per cell, and there is no way to reply to a note. For cell
228
+ * annotations with replies, see {@link ThreadedComment} and {@link Worksheet.comments}.
229
+ */
230
+ type Note = {
231
+ /** Cell to which the note is attached (e.g. A1, E24). */
232
+ ref: CellId;
233
+ /** Name of the person who originally made this note. */
234
+ author: string;
235
+ /** Body text of the note. */
236
+ text: string;
237
+ };
238
+
180
239
  /**
181
240
  * The style to use when drawing a cell border. If the worksheet's zoom factor is changed the width
182
241
  * of the border is expected to stay the same.
@@ -519,6 +578,125 @@ type Table = {
519
578
  style?: TableStyle;
520
579
  };
521
580
 
581
+ /**
582
+ * Base type for text runs that annotate ranges within threaded comment text.
583
+ *
584
+ * A text run identifies a contiguous range of characters in the comment text, specified by
585
+ * zero-indexed start and end positions. Text runs allow metadata to be attached to specific
586
+ * portions of text, enabling features such as hyperlinks, mentions, and formatting.
587
+ *
588
+ * ## How text runs work
589
+ *
590
+ * Each text run specifies a range within the comment text using `start` (inclusive) and `end`
591
+ * (exclusive) character positions. For example, in the text "Hello @foo", a mention text run
592
+ * for "@foo" would have `start: 6` and `end: 10`.
593
+ *
594
+ * Multiple text runs can exist within a single comment, allowing different types of annotations
595
+ * to coexist (a mention and a hyperlink in the same text, for example).
596
+ *
597
+ * @see {@link MentionTextRun} for mentions of people
598
+ * @see {@link HyperlinkTextRun} for hyperlinks
599
+ */
600
+ type TextRun = {
601
+ /** Starting character position of the run in the text (zero-indexed). */
602
+ start: integer;
603
+ /** Ending character position of the run in the text (zero-indexed, exclusive). */
604
+ end: integer;
605
+ };
606
+
607
+ /**
608
+ * A {@link TextRun | text run} representing a hyperlink within a threaded comment's text.
609
+ */
610
+ type HyperlinkTextRun = TextRun & {
611
+ /** Discriminator to identify this as a hyperlink text run. */
612
+ type: 'hyperlink';
613
+ /** The URL that the hyperlink points to. */
614
+ url: string;
615
+ };
616
+
617
+ /**
618
+ * A {@link TextRun | text run} representing a mention of a person within a threaded comment's text.
619
+ */
620
+ type MentionTextRun = TextRun & {
621
+ /** Discriminator to identify this as a mention text run. */
622
+ type: 'mention';
623
+ /**
624
+ * Unique identifier of the person being mentioned. Use this to find the person's details in a
625
+ * {@link Workbook.people | workbook's list of people}.
626
+ *
627
+ * Excel always uses a UUID in the format `{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`, but JSF makes
628
+ * no strict requirement.
629
+ */
630
+ personId: string;
631
+ };
632
+
633
+ /**
634
+ * An author of a threaded comment, or a person mentioned in a threaded comment.
635
+ */
636
+ type Person = {
637
+ /**
638
+ * A unique id for the person.
639
+ *
640
+ * Excel always uses a UUID in the format `{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`, but JSF makes
641
+ * no strict requirement.
642
+ */
643
+ id: string;
644
+ /** The person's name as it should be shown to other users. */
645
+ displayName: string;
646
+ /**
647
+ * Optional provider-issued user identifier that varies in format depending on the provider. See
648
+ * {@link Person.providerId} for details on possible values.
649
+ */
650
+ userId?: string;
651
+ /**
652
+ * Specifies where the person's information came from. Excel supports the following values:
653
+ *
654
+ * - `None`: no specific provider; {@link Person.userId} is expected to be the person's name.
655
+ * - `AD`: Active Directory; {@link Person.userId} will be Active Directory id.
656
+ * - `Windows Live`: Microsoft account; {@link Person.userId} will be a 64-bit signed decimal.
657
+ * - `PeoplePicker`: SharePoint People Picker; {@link Person.userId} will be an email address.
658
+ */
659
+ providerId?: string;
660
+ };
661
+
662
+ /**
663
+ * A threaded comment that is attached to an individual cell.
664
+ */
665
+ type ThreadedComment = {
666
+ /**
667
+ * Unique identifier for the comment.
668
+ *
669
+ * Excel always uses a UUID in the format `{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`, but JSF makes
670
+ * no strict requirement.
671
+ */
672
+ id: string;
673
+ /**
674
+ * Unique identifier of the parent comment, if this is a reply in a thread.
675
+ *
676
+ * Excel always uses a UUID in the format `{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`, but JSF makes
677
+ * no strict requirement.
678
+ */
679
+ parentId?: string;
680
+ /** A1-style reference to the cell this comment is attached to. */
681
+ ref: CellId;
682
+ /** Date and time the comment was written, as an ISO formatted string. */
683
+ datetime?: string;
684
+ /**
685
+ * Unique identifier of the person who authored this comment. Use this to find the person's
686
+ * details in a {@link Workbook.people | workbook's list of people}.
687
+ *
688
+ * Excel always uses a UUID in the format `{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}`, but JSF makes
689
+ * no strict requirement.
690
+ */
691
+ personId: string;
692
+ /** The comment text content. */
693
+ text: string;
694
+ /** Whether the comment has been marked as resolved. */
695
+ resolved?: boolean;
696
+ /** {@link TextRun | Text runs} that annotate ranges within the comment text. */
697
+ runs?: (MentionTextRun | HyperlinkTextRun)[];
698
+ };
699
+
522
700
  /**
523
701
  * Directions on how formulas should be recalculated in the workbook.
524
702
  */
@@ -638,6 +816,8 @@ type Worksheet = {
638
816
  name: string;
639
817
  /** The cells belonging to the worksheet that have some data attached. */
640
818
  cells: Record<CellId, Cell>;
819
+ comments?: ThreadedComment[];
820
+ notes?: Note[];
641
821
  /** Widths and styles of the columns in the worksheet. */
642
822
  columns?: GridSize[];
643
823
  /** Heights and styles of the rows in the worksheet. */
@@ -711,6 +891,13 @@ type Workbook = {
711
891
  formulas?: string[];
712
892
  /** The different display configurations saved for the workbook. */
713
893
  views?: WorkbookView[];
894
+ /**
895
+ * Individuals who have written a threaded comment in this workbook, or who have been mentioned in
896
+ * one.
897
+ *
898
+ * @see {@link ThreadedComment}
899
+ */
900
+ people?: Person[];
714
901
  };
715
902
 
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 };
903
+ export type { BorderStyle, CalcProps, Cell, CellId, CellRange, CellValueType, Color, Comment, DataTable, 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.3.0",
4
4
  "description": "TypeScript types for JSF: a JSON spreadsheet representation",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,13 +41,13 @@
41
41
  "release": "PACKAGE_VERSION=$(jq -r .version package.json) && echo \"About to tag and push v$PACKAGE_VERSION. Continue? (y/n)\" && read -r REPLY && [ \"$REPLY\" = \"y\" ] && git tag --annotate v$PACKAGE_VERSION --message=v$PACKAGE_VERSION && git push origin v$PACKAGE_VERSION"
42
42
  },
43
43
  "devDependencies": {
44
- "@borgar/eslint-config": "^4.0.0",
44
+ "@borgar/eslint-config": "^4.0.1",
45
45
  "@eslint/js": "^9.38.0",
46
46
  "eslint": "^9.38.0",
47
- "globals": "^16.4.0",
48
- "tsup": "^8.5.0",
49
- "typedoc": "^0.28.14",
47
+ "globals": "^17.3.0",
48
+ "tsup": "^8.5.1",
49
+ "typedoc": "^0.28.17",
50
50
  "typescript": "^5.9.3",
51
- "typescript-eslint": "^8.46.1"
51
+ "typescript-eslint": "^8.56.0"
52
52
  }
53
53
  }