runline 0.12.0 → 0.14.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.
@@ -1,4 +1,6 @@
1
- import { buildLocation, compact, extractDocumentId, hexToRgbF, location, runBatchUpdate, } from "./shared.js";
1
+ import * as t from "typebox";
2
+ import { buildLocation, compact, DocumentInput, extractDocumentId, HexColor, hexToRgbF, LOCATION_REQUIREMENT, LocationInput, location, PositivePoints, runBatchUpdate, SegmentInput, STRICT_OBJECT, TableLocationInput, } from "./shared.js";
3
+ const PositiveSpan = t.Integer({ minimum: 1 });
2
4
  function tableStartLocation(p) {
3
5
  return location(p.tableStartIndex, p.segmentId, p.tabId);
4
6
  }
@@ -16,15 +18,12 @@ export function registerTablesActions(rl) {
16
18
  rl.registerAction("document.insertTable", {
17
19
  access: "write",
18
20
  description: "Insert an empty table with the given dimensions.",
19
- inputSchema: {
20
- document: { type: "string", required: true },
21
- rows: { type: "number", required: true },
22
- columns: { type: "number", required: true },
23
- locationKind: { type: "string", required: false },
24
- index: { type: "number", required: false },
25
- segmentId: { type: "string", required: false },
26
- tabId: { type: "string", required: false },
27
- },
21
+ inputSchema: t.Object({
22
+ ...DocumentInput,
23
+ rows: PositiveSpan,
24
+ columns: PositiveSpan,
25
+ ...LocationInput,
26
+ }, { ...STRICT_OBJECT, anyOf: LOCATION_REQUIREMENT }),
28
27
  async execute(input, ctx) {
29
28
  const p = (input ?? {});
30
29
  const documentId = extractDocumentId(p.document);
@@ -41,23 +40,11 @@ export function registerTablesActions(rl) {
41
40
  rl.registerAction("document.insertTableRow", {
42
41
  access: "write",
43
42
  description: "Insert a table row above or below a cell in an existing table.",
44
- inputSchema: {
45
- document: { type: "string", required: true },
46
- tableStartIndex: {
47
- type: "number",
48
- required: true,
49
- description: "Document index where the table begins",
50
- },
51
- rowIndex: { type: "number", required: true },
52
- columnIndex: { type: "number", required: true },
53
- insertBelow: {
54
- type: "boolean",
55
- required: false,
56
- description: "default: false (insert above)",
57
- },
58
- segmentId: { type: "string", required: false },
59
- tabId: { type: "string", required: false },
60
- },
43
+ inputSchema: t.Object({
44
+ ...DocumentInput,
45
+ ...TableLocationInput,
46
+ insertBelow: t.Optional(t.Boolean()),
47
+ }, STRICT_OBJECT),
61
48
  async execute(input, ctx) {
62
49
  const p = (input ?? {});
63
50
  const documentId = extractDocumentId(p.document);
@@ -72,14 +59,7 @@ export function registerTablesActions(rl) {
72
59
  rl.registerAction("document.deleteTableRow", {
73
60
  access: "write",
74
61
  description: "Delete a specific row from a table.",
75
- inputSchema: {
76
- document: { type: "string", required: true },
77
- tableStartIndex: { type: "number", required: true },
78
- rowIndex: { type: "number", required: true },
79
- columnIndex: { type: "number", required: true },
80
- segmentId: { type: "string", required: false },
81
- tabId: { type: "string", required: false },
82
- },
62
+ inputSchema: t.Object({ ...DocumentInput, ...TableLocationInput }, STRICT_OBJECT),
83
63
  async execute(input, ctx) {
84
64
  const p = (input ?? {});
85
65
  const documentId = extractDocumentId(p.document);
@@ -93,19 +73,11 @@ export function registerTablesActions(rl) {
93
73
  rl.registerAction("document.insertTableColumn", {
94
74
  access: "write",
95
75
  description: "Insert a column left or right of a cell.",
96
- inputSchema: {
97
- document: { type: "string", required: true },
98
- tableStartIndex: { type: "number", required: true },
99
- rowIndex: { type: "number", required: true },
100
- columnIndex: { type: "number", required: true },
101
- insertRight: {
102
- type: "boolean",
103
- required: false,
104
- description: "default: false (insert left)",
105
- },
106
- segmentId: { type: "string", required: false },
107
- tabId: { type: "string", required: false },
108
- },
76
+ inputSchema: t.Object({
77
+ ...DocumentInput,
78
+ ...TableLocationInput,
79
+ insertRight: t.Optional(t.Boolean()),
80
+ }, STRICT_OBJECT),
109
81
  async execute(input, ctx) {
110
82
  const p = (input ?? {});
111
83
  const documentId = extractDocumentId(p.document);
@@ -120,14 +92,7 @@ export function registerTablesActions(rl) {
120
92
  rl.registerAction("document.deleteTableColumn", {
121
93
  access: "write",
122
94
  description: "Delete a specific column from a table.",
123
- inputSchema: {
124
- document: { type: "string", required: true },
125
- tableStartIndex: { type: "number", required: true },
126
- rowIndex: { type: "number", required: true },
127
- columnIndex: { type: "number", required: true },
128
- segmentId: { type: "string", required: false },
129
- tabId: { type: "string", required: false },
130
- },
95
+ inputSchema: t.Object({ ...DocumentInput, ...TableLocationInput }, STRICT_OBJECT),
131
96
  async execute(input, ctx) {
132
97
  const p = (input ?? {});
133
98
  const documentId = extractDocumentId(p.document);
@@ -141,30 +106,28 @@ export function registerTablesActions(rl) {
141
106
  rl.registerAction("document.updateTableCellStyle", {
142
107
  access: "write",
143
108
  description: "Apply table-cell styling (background color, borders, padding) to a contiguous span of cells. Pass either a single cell via `tableStartLocation+rowIndex+columnIndex`, or a range via `tableStartLocation+rowSpan+columnSpan`.",
144
- inputSchema: {
145
- document: { type: "string", required: true },
146
- tableStartIndex: {
147
- type: "number",
148
- required: true,
149
- description: "The startIndex of the table element.",
150
- },
151
- rowIndex: { type: "number", required: true },
152
- columnIndex: { type: "number", required: true },
153
- rowSpan: { type: "number", required: false, default: 1 },
154
- columnSpan: { type: "number", required: false, default: 1 },
155
- backgroundColorHex: { type: "string", required: false },
156
- paddingLeftPt: { type: "number", required: false },
157
- paddingRightPt: { type: "number", required: false },
158
- paddingTopPt: { type: "number", required: false },
159
- paddingBottomPt: { type: "number", required: false },
160
- contentAlignment: {
161
- type: "string",
162
- required: false,
163
- description: "TOP | MIDDLE | BOTTOM",
164
- },
165
- segmentId: { type: "string", required: false },
166
- tabId: { type: "string", required: false },
167
- },
109
+ inputSchema: t.Object({
110
+ ...DocumentInput,
111
+ ...TableLocationInput,
112
+ rowSpan: t.Optional(PositiveSpan),
113
+ columnSpan: t.Optional(PositiveSpan),
114
+ backgroundColorHex: t.Optional(HexColor),
115
+ paddingLeftPt: t.Optional(PositivePoints),
116
+ paddingRightPt: t.Optional(PositivePoints),
117
+ paddingTopPt: t.Optional(PositivePoints),
118
+ paddingBottomPt: t.Optional(PositivePoints),
119
+ contentAlignment: t.Optional(t.Union([t.Literal("TOP"), t.Literal("MIDDLE"), t.Literal("BOTTOM")])),
120
+ }, {
121
+ ...STRICT_OBJECT,
122
+ anyOf: [
123
+ { required: ["backgroundColorHex"] },
124
+ { required: ["paddingLeftPt"] },
125
+ { required: ["paddingRightPt"] },
126
+ { required: ["paddingTopPt"] },
127
+ { required: ["paddingBottomPt"] },
128
+ { required: ["contentAlignment"] },
129
+ ],
130
+ }),
168
131
  async execute(input, ctx) {
169
132
  const p = (input ?? {});
170
133
  const documentId = extractDocumentId(p.document);
@@ -222,16 +185,12 @@ export function registerTablesActions(rl) {
222
185
  rl.registerAction("document.mergeTableCells", {
223
186
  access: "write",
224
187
  description: "Merge a contiguous block of cells in a table.",
225
- inputSchema: {
226
- document: { type: "string", required: true },
227
- tableStartIndex: { type: "number", required: true },
228
- rowIndex: { type: "number", required: true },
229
- columnIndex: { type: "number", required: true },
230
- rowSpan: { type: "number", required: true },
231
- columnSpan: { type: "number", required: true },
232
- segmentId: { type: "string", required: false },
233
- tabId: { type: "string", required: false },
234
- },
188
+ inputSchema: t.Object({
189
+ ...DocumentInput,
190
+ ...TableLocationInput,
191
+ rowSpan: PositiveSpan,
192
+ columnSpan: PositiveSpan,
193
+ }, STRICT_OBJECT),
235
194
  async execute(input, ctx) {
236
195
  const p = (input ?? {});
237
196
  const documentId = extractDocumentId(p.document);
@@ -255,16 +214,12 @@ export function registerTablesActions(rl) {
255
214
  rl.registerAction("document.unmergeTableCells", {
256
215
  access: "write",
257
216
  description: "Unmerge a previously merged block of cells.",
258
- inputSchema: {
259
- document: { type: "string", required: true },
260
- tableStartIndex: { type: "number", required: true },
261
- rowIndex: { type: "number", required: true },
262
- columnIndex: { type: "number", required: true },
263
- rowSpan: { type: "number", required: true },
264
- columnSpan: { type: "number", required: true },
265
- segmentId: { type: "string", required: false },
266
- tabId: { type: "string", required: false },
267
- },
217
+ inputSchema: t.Object({
218
+ ...DocumentInput,
219
+ ...TableLocationInput,
220
+ rowSpan: PositiveSpan,
221
+ columnSpan: PositiveSpan,
222
+ }, STRICT_OBJECT),
268
223
  async execute(input, ctx) {
269
224
  const p = (input ?? {});
270
225
  const documentId = extractDocumentId(p.document);
@@ -288,32 +243,26 @@ export function registerTablesActions(rl) {
288
243
  rl.registerAction("document.updateTableColumnProperties", {
289
244
  access: "write",
290
245
  description: "Update table column properties such as width for selected columns or all columns.",
291
- inputSchema: {
292
- document: { type: "string", required: true },
293
- tableStartIndex: { type: "number", required: true },
294
- columnIndices: {
295
- type: "array",
296
- required: false,
297
- description: "Zero-based column indices. Omit to update all columns.",
298
- },
299
- widthPt: {
300
- type: "number",
301
- required: false,
302
- description: "Column width in points.",
303
- },
304
- widthType: {
305
- type: "string",
306
- required: false,
307
- description: "WIDTH_TYPE_UNSPECIFIED | EVENLY_DISTRIBUTED | FIXED_WIDTH. Defaults to FIXED_WIDTH when widthPt is provided.",
308
- },
309
- fields: {
310
- type: "string",
311
- required: false,
312
- description: "Field mask. Defaults to fields implied by supplied properties.",
313
- },
314
- segmentId: { type: "string", required: false },
315
- tabId: { type: "string", required: false },
316
- },
246
+ inputSchema: t.Object({
247
+ ...DocumentInput,
248
+ tableStartIndex: t.Integer({ minimum: 0 }),
249
+ columnIndices: t.Optional(t.Array(t.Integer({ minimum: 0 }), { minItems: 1 })),
250
+ widthPt: t.Optional(PositivePoints),
251
+ widthType: t.Optional(t.Union([
252
+ t.Literal("WIDTH_TYPE_UNSPECIFIED"),
253
+ t.Literal("EVENLY_DISTRIBUTED"),
254
+ t.Literal("FIXED_WIDTH"),
255
+ ])),
256
+ fields: t.Optional(t.String({ minLength: 1 })),
257
+ ...SegmentInput,
258
+ }, {
259
+ ...STRICT_OBJECT,
260
+ anyOf: [
261
+ { required: ["widthPt"] },
262
+ { required: ["widthType"] },
263
+ { required: ["fields"] },
264
+ ],
265
+ }),
317
266
  async execute(input, ctx) {
318
267
  const p = (input ?? {});
319
268
  const documentId = extractDocumentId(p.document);
@@ -344,23 +293,17 @@ export function registerTablesActions(rl) {
344
293
  rl.registerAction("document.updateTableRowStyle", {
345
294
  access: "write",
346
295
  description: "Update table row style such as minimum row height for selected rows or all rows.",
347
- inputSchema: {
348
- document: { type: "string", required: true },
349
- tableStartIndex: { type: "number", required: true },
350
- rowIndices: {
351
- type: "array",
352
- required: false,
353
- description: "Zero-based row indices. Omit to update all rows.",
354
- },
355
- minRowHeightPt: { type: "number", required: false },
356
- fields: {
357
- type: "string",
358
- required: false,
359
- description: "Field mask. Defaults to fields implied by supplied properties.",
360
- },
361
- segmentId: { type: "string", required: false },
362
- tabId: { type: "string", required: false },
363
- },
296
+ inputSchema: t.Object({
297
+ ...DocumentInput,
298
+ tableStartIndex: t.Integer({ minimum: 0 }),
299
+ rowIndices: t.Optional(t.Array(t.Integer({ minimum: 0 }), { minItems: 1 })),
300
+ minRowHeightPt: t.Optional(PositivePoints),
301
+ fields: t.Optional(t.String({ minLength: 1 })),
302
+ ...SegmentInput,
303
+ }, {
304
+ ...STRICT_OBJECT,
305
+ anyOf: [{ required: ["minRowHeightPt"] }, { required: ["fields"] }],
306
+ }),
364
307
  async execute(input, ctx) {
365
308
  const p = (input ?? {});
366
309
  const documentId = extractDocumentId(p.document);
@@ -386,17 +329,12 @@ export function registerTablesActions(rl) {
386
329
  rl.registerAction("document.pinTableHeaderRows", {
387
330
  access: "write",
388
331
  description: "Pin or unpin header rows in a table.",
389
- inputSchema: {
390
- document: { type: "string", required: true },
391
- tableStartIndex: { type: "number", required: true },
392
- pinnedHeaderRowsCount: {
393
- type: "number",
394
- required: true,
395
- description: "Use 0 to unpin all header rows.",
396
- },
397
- segmentId: { type: "string", required: false },
398
- tabId: { type: "string", required: false },
399
- },
332
+ inputSchema: t.Object({
333
+ ...DocumentInput,
334
+ tableStartIndex: t.Integer({ minimum: 0 }),
335
+ pinnedHeaderRowsCount: t.Integer({ minimum: 0 }),
336
+ ...SegmentInput,
337
+ }, STRICT_OBJECT),
400
338
  async execute(input, ctx) {
401
339
  const p = (input ?? {});
402
340
  const documentId = extractDocumentId(p.document);
@@ -1,4 +1,5 @@
1
- import { compact, extractDocumentId, runBatchUpdate } from "./shared.js";
1
+ import * as t from "typebox";
2
+ import { compact, DocumentInput, extractDocumentId, runBatchUpdate, STRICT_OBJECT, } from "./shared.js";
2
3
  function tabProperties(p) {
3
4
  return compact({
4
5
  tabId: p.tabId,
@@ -11,12 +12,12 @@ export function registerTabActions(rl) {
11
12
  rl.registerAction("document.addDocumentTab", {
12
13
  access: "write",
13
14
  description: "Add a Google Docs document tab, optionally at an index or under a parent tab.",
14
- inputSchema: {
15
- document: { type: "string", required: true },
16
- title: { type: "string", required: false },
17
- index: { type: "number", required: false },
18
- parentTabId: { type: "string", required: false },
19
- },
15
+ inputSchema: t.Object({
16
+ ...DocumentInput,
17
+ title: t.Optional(t.String({ minLength: 1 })),
18
+ index: t.Optional(t.Integer({ minimum: 0 })),
19
+ parentTabId: t.Optional(t.String({ minLength: 1 })),
20
+ }, STRICT_OBJECT),
20
21
  async execute(input, ctx) {
21
22
  const p = (input ?? {});
22
23
  const documentId = extractDocumentId(p.document);
@@ -28,10 +29,7 @@ export function registerTabActions(rl) {
28
29
  rl.registerAction("document.deleteTab", {
29
30
  access: "write",
30
31
  description: "Delete a Google Docs document tab by tab ID. Child tabs are deleted too.",
31
- inputSchema: {
32
- document: { type: "string", required: true },
33
- tabId: { type: "string", required: true },
34
- },
32
+ inputSchema: t.Object({ ...DocumentInput, tabId: t.String({ minLength: 1 }) }, STRICT_OBJECT),
35
33
  async execute(input, ctx) {
36
34
  const p = (input ?? {});
37
35
  const documentId = extractDocumentId(p.document);
@@ -43,18 +41,21 @@ export function registerTabActions(rl) {
43
41
  rl.registerAction("document.updateDocumentTabProperties", {
44
42
  access: "write",
45
43
  description: "Update Google Docs tab properties such as title, index, or parent tab.",
46
- inputSchema: {
47
- document: { type: "string", required: true },
48
- tabId: { type: "string", required: true },
49
- title: { type: "string", required: false },
50
- index: { type: "number", required: false },
51
- parentTabId: { type: "string", required: false },
52
- fields: {
53
- type: "string",
54
- required: false,
55
- description: "Field mask. Defaults to fields implied by supplied properties.",
56
- },
57
- },
44
+ inputSchema: t.Object({
45
+ ...DocumentInput,
46
+ tabId: t.String({ minLength: 1 }),
47
+ title: t.Optional(t.String({ minLength: 1 })),
48
+ index: t.Optional(t.Integer({ minimum: 0 })),
49
+ parentTabId: t.Optional(t.String({ minLength: 1 })),
50
+ fields: t.Optional(t.String({ minLength: 1 })),
51
+ }, {
52
+ ...STRICT_OBJECT,
53
+ anyOf: [
54
+ { required: ["title"] },
55
+ { required: ["index"] },
56
+ { required: ["parentTabId"] },
57
+ ],
58
+ }),
58
59
  async execute(input, ctx) {
59
60
  const p = (input ?? {});
60
61
  const documentId = extractDocumentId(p.document);