@mcpher/gas-fakes 2.5.2 → 2.5.4

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 (76) hide show
  1. package/README.md +17 -3
  2. package/package.json +1 -1
  3. package/pngs/srv.jpg +0 -0
  4. package/src/cli/app.js +1 -0
  5. package/src/cli/togas.js +23 -14
  6. package/src/index.js +1 -0
  7. package/src/services/advslides/fakeadvslides.js +11 -5
  8. package/src/services/base/app.js +9 -0
  9. package/src/services/base/fakebase.js +28 -0
  10. package/src/services/common/fakeadvresource.js +3 -2
  11. package/src/services/content/contentservice.js +3 -2
  12. package/src/services/enums/baseenums.js +47 -0
  13. package/src/services/enums/contentenums.js +1 -3
  14. package/src/services/enums/scriptenums.js +31 -4
  15. package/src/services/enums/slidesenums.js +3 -1
  16. package/src/services/enums/xmlenums.js +14 -0
  17. package/src/services/html/serverworker.js +1 -1
  18. package/src/services/scriptapp/app.js +14 -7
  19. package/src/services/scriptapp/fakeauthorizationinfo.js +4 -4
  20. package/src/services/slidesapp/app.js +5 -0
  21. package/src/services/slidesapp/fakeautofit.js +1 -1
  22. package/src/services/slidesapp/fakeborder.js +106 -0
  23. package/src/services/slidesapp/fakecolorscheme.js +1 -1
  24. package/src/services/slidesapp/fakefill.js +216 -0
  25. package/src/services/slidesapp/fakegroup.js +35 -0
  26. package/src/services/slidesapp/fakeimage.js +118 -0
  27. package/src/services/slidesapp/fakelayout.js +351 -0
  28. package/src/services/slidesapp/fakeline.js +2 -2
  29. package/src/services/slidesapp/fakelinefill.js +15 -16
  30. package/src/services/slidesapp/fakelink.js +20 -3
  31. package/src/services/slidesapp/fakelist.js +36 -0
  32. package/src/services/slidesapp/fakeliststyle.js +105 -0
  33. package/src/services/slidesapp/fakemaster.js +358 -0
  34. package/src/services/slidesapp/fakenotesmaster.js +125 -0
  35. package/src/services/slidesapp/fakenotespage.js +102 -2
  36. package/src/services/slidesapp/fakepagebackground.js +109 -1
  37. package/src/services/slidesapp/fakepageelement.js +157 -18
  38. package/src/services/slidesapp/fakepageelementrange.js +28 -0
  39. package/src/services/slidesapp/fakepagerange.js +28 -0
  40. package/src/services/slidesapp/fakeparagraphstyle.js +139 -0
  41. package/src/services/slidesapp/fakepicturefill.js +32 -0
  42. package/src/services/slidesapp/fakepresentation.js +126 -2
  43. package/src/services/slidesapp/fakeshape.js +9 -0
  44. package/src/services/slidesapp/fakeslide.js +216 -24
  45. package/src/services/slidesapp/fakesolidfill.js +45 -0
  46. package/src/services/slidesapp/fakespeakerspotlight.js +18 -0
  47. package/src/services/slidesapp/faketable.js +55 -9
  48. package/src/services/slidesapp/faketablecell.js +141 -12
  49. package/src/services/slidesapp/faketablecellrange.js +28 -0
  50. package/src/services/slidesapp/faketablecolumn.js +72 -0
  51. package/src/services/slidesapp/faketablerow.js +31 -0
  52. package/src/services/slidesapp/faketextrange.js +179 -135
  53. package/src/services/slidesapp/faketextstyle.js +158 -0
  54. package/src/services/slidesapp/fakevideo.js +35 -0
  55. package/src/services/slidesapp/fakewordart.js +22 -0
  56. package/src/services/slidesapp/pageelementfactory.js +24 -1
  57. package/src/services/spreadsheetapp/fakeembeddedchartbuilder.js +92 -12
  58. package/src/services/spreadsheetapp/fakespreadsheet.js +360 -62
  59. package/src/services/spreadsheetapp/fakespreadsheettheme.js +53 -0
  60. package/src/services/urlfetchapp/app.js +216 -175
  61. package/src/services/xmlservice/app.js +3 -78
  62. package/src/services/xmlservice/fakeattribute.js +15 -0
  63. package/src/services/xmlservice/fakecdata.js +40 -0
  64. package/src/services/xmlservice/fakecomment.js +34 -0
  65. package/src/services/xmlservice/fakecontent.js +51 -0
  66. package/src/services/xmlservice/fakedoctype.js +68 -0
  67. package/src/services/xmlservice/fakedocument.js +110 -13
  68. package/src/services/xmlservice/fakeelement.js +297 -82
  69. package/src/services/xmlservice/fakeentityref.js +54 -0
  70. package/src/services/xmlservice/fakeformat.js +67 -22
  71. package/src/services/xmlservice/fakeprocessinginstruction.js +44 -0
  72. package/src/services/xmlservice/faketext.js +39 -0
  73. package/src/services/xmlservice/fakexmlservice.js +118 -0
  74. package/src/support/sxfetch.js +60 -0
  75. package/tools/omlx.env.example +6 -0
  76. package/tools/omlx_mcp_server.cjs +157 -0
@@ -1,6 +1,7 @@
1
1
  import { Proxies } from '../../support/proxies.js';
2
2
  import { FakePageElement, PageElementRegistry } from './fakepageelement.js';
3
3
  import { newFakeTableRow } from './faketablerow.js';
4
+ import { newFakeTableColumn } from './faketablecolumn.js';
4
5
 
5
6
  export const newFakeTable = (...args) => {
6
7
  return Proxies.guard(new FakeTable(...args));
@@ -18,13 +19,41 @@ export class FakeTable extends FakePageElement {
18
19
  }
19
20
 
20
21
  /**
21
- * Gets the rows in the table.
22
- * @returns {FakeTableRow[]} The rows.
22
+ * Appends a new column to the right of the last column of the table.
23
+ * @returns {FakeTableColumn} The new appended column.
23
24
  */
24
- getRows() {
25
- return (this.__resource.table?.tableRows || []).map((_, index) =>
26
- newFakeTableRow(this, index)
27
- );
25
+ appendColumn() {
26
+ return this.insertColumn(this.getNumColumns());
27
+ }
28
+
29
+ /**
30
+ * Appends a new row below the last row of the table.
31
+ * @returns {FakeTableRow} The new appended row.
32
+ */
33
+ appendRow() {
34
+ return this.insertRow(this.getNumRows());
35
+ }
36
+
37
+ /**
38
+ * Gets a column by its index.
39
+ * @param {number} index The column index.
40
+ * @returns {FakeTableColumn} The column.
41
+ */
42
+ getColumn(index) {
43
+ if (index < 0 || index >= this.getNumColumns()) {
44
+ throw new Error(`Column index ${index} out of bounds`);
45
+ }
46
+ return newFakeTableColumn(this, index);
47
+ }
48
+
49
+ /**
50
+ * Gets a cell by its row and column index.
51
+ * @param {number} rowIndex The row index.
52
+ * @param {number} colIndex The column index.
53
+ * @returns {FakeTableCell} The cell.
54
+ */
55
+ getCell(rowIndex, colIndex) {
56
+ return this.getRow(rowIndex).getCell(colIndex);
28
57
  }
29
58
 
30
59
  /**
@@ -33,11 +62,10 @@ export class FakeTable extends FakePageElement {
33
62
  * @returns {FakeTableRow} The row.
34
63
  */
35
64
  getRow(index) {
36
- const rows = this.getRows();
37
- if (index < 0 || index >= rows.length) {
65
+ if (index < 0 || index >= this.getNumRows()) {
38
66
  throw new Error(`Row index ${index} out of bounds`);
39
67
  }
40
- return rows[index];
68
+ return newFakeTableRow(this, index);
41
69
  }
42
70
 
43
71
  /**
@@ -57,6 +85,24 @@ export class FakeTable extends FakePageElement {
57
85
  return rows.length > 0 ? (rows[0].tableCells || []).length : 0;
58
86
  }
59
87
 
88
+ /**
89
+ * Inserts a new column at the specified index of the table.
90
+ * @param {number} index The index.
91
+ * @returns {FakeTableColumn} The new column.
92
+ */
93
+ insertColumn(index) {
94
+ throw new Error('Table.insertColumn() not yet implemented');
95
+ }
96
+
97
+ /**
98
+ * Inserts a new row at the specified index of the table.
99
+ * @param {number} index The index.
100
+ * @returns {FakeTableRow} The new row.
101
+ */
102
+ insertRow(index) {
103
+ throw new Error('Table.insertRow() not yet implemented');
104
+ }
105
+
60
106
  toString() {
61
107
  return 'Table';
62
108
  }
@@ -1,5 +1,7 @@
1
1
  import { Proxies } from '../../support/proxies.js';
2
2
  import { newFakeTextRange } from './faketextrange.js';
3
+ import { newFakeFill } from './fakefill.js';
4
+ import { ContentAlignment, CellMergeState } from '../enums/slidesenums.js';
3
5
 
4
6
  export const newFakeTableCell = (...args) => {
5
7
  return Proxies.guard(new FakeTableCell(...args));
@@ -12,30 +14,157 @@ export class FakeTableCell {
12
14
  this.__colIndex = colIndex;
13
15
  }
14
16
 
17
+ /**
18
+ * Returns the unique ID for this object.
19
+ * @returns {string} The ID.
20
+ */
21
+ getObjectId() {
22
+ return this.__table.getObjectId();
23
+ }
24
+
15
25
  get __resource() {
16
26
  return this.__table.__resource.table?.tableRows?.[this.__rowIndex]?.tableCells?.[this.__colIndex];
17
27
  }
18
28
 
29
+ /**
30
+ * Returns the 0-based column index of the table cell.
31
+ * @returns {number} The column index.
32
+ */
33
+ getColumnIndex() {
34
+ return this.__colIndex;
35
+ }
36
+
37
+ /**
38
+ * Returns the column span of the table cell.
39
+ * @returns {number} The column span.
40
+ */
41
+ getColumnSpan() {
42
+ return this.__resource?.columnSpan || 1;
43
+ }
44
+
45
+ /**
46
+ * Returns the ContentAlignment of the text in the table cell.
47
+ * @returns {ContentAlignment} The content alignment.
48
+ */
49
+ getContentAlignment() {
50
+ const alignment = this.__resource?.tableCellProperties?.contentAlignment;
51
+ return ContentAlignment[alignment || 'TOP'];
52
+ }
53
+
54
+ /**
55
+ * Returns the fill of the table cell.
56
+ * @returns {FakeFill} The fill.
57
+ */
58
+ getFill() {
59
+ return newFakeFill(this);
60
+ }
61
+
62
+ /**
63
+ * Returns the head cell of this table cell.
64
+ * @returns {FakeTableCell | null} The head cell or null.
65
+ */
66
+ getHeadCell() {
67
+ // Basic implementation: if this is merged, find its head.
68
+ // For now, return null as we don't have full merge tracking.
69
+ return null;
70
+ }
71
+
72
+ /**
73
+ * Returns the merge state of the table cell.
74
+ * @returns {CellMergeState} The merge state.
75
+ */
76
+ getMergeState() {
77
+ const rowSpan = this.getRowSpan();
78
+ const colSpan = this.getColumnSpan();
79
+ if (rowSpan > 1 || colSpan > 1) {
80
+ return CellMergeState.HEAD;
81
+ }
82
+ // TODO: Detect MERGED state if we can find the head.
83
+ return CellMergeState.NORMAL;
84
+ }
85
+
86
+ /**
87
+ * Returns the table column containing the current cell.
88
+ * @returns {FakeTableColumn} The column.
89
+ */
90
+ getParentColumn() {
91
+ return this.__table.getColumn(this.__colIndex);
92
+ }
93
+
94
+ /**
95
+ * Returns the table row containing the current cell.
96
+ * @returns {FakeTableRow} The row.
97
+ */
98
+ getParentRow() {
99
+ return this.__table.getRow(this.__rowIndex);
100
+ }
101
+
102
+ /**
103
+ * Returns the table containing the current cell.
104
+ * @returns {FakeTable} The table.
105
+ */
106
+ getParentTable() {
107
+ return this.__table;
108
+ }
109
+
110
+ /**
111
+ * Returns the 0-based row index of the table cell.
112
+ * @returns {number} The row index.
113
+ */
114
+ getRowIndex() {
115
+ return this.__rowIndex;
116
+ }
117
+
118
+ /**
119
+ * Returns the row span of the table cell.
120
+ * @returns {number} The row span.
121
+ */
122
+ getRowSpan() {
123
+ return this.__resource?.rowSpan || 1;
124
+ }
125
+
126
+ /**
127
+ * Sets the ContentAlignment of the text in the table cell.
128
+ * @param {ContentAlignment} alignment The alignment.
129
+ * @returns {FakeTableCell} This cell.
130
+ */
131
+ setContentAlignment(alignment) {
132
+ const presentationId = this.__table.__presentation.getId();
133
+ Slides.Presentations.batchUpdate({ requests: [{
134
+ updateTableCellProperties: {
135
+ objectId: this.__table.getObjectId(),
136
+ tableCellProperties: {
137
+ contentAlignment: alignment.toString()
138
+ },
139
+ fields: 'contentAlignment',
140
+ tableRange: {
141
+ location: {
142
+ rowIndex: this.__rowIndex,
143
+ columnIndex: this.__colIndex
144
+ },
145
+ rowSpan: 1,
146
+ columnSpan: 1
147
+ }
148
+ }
149
+ }] }, presentationId);
150
+ return this;
151
+ }
152
+
19
153
  /**
20
154
  * Gets the text in the cell.
21
155
  * @returns {FakeTextRange} The text range.
22
156
  */
23
157
  getText() {
24
- // FakeTableCell in Slides API doesn't have a direct shape resource to pass to TextRange?
25
- // Actually, TableCell has text property in Slides API.
26
- // Wait, let's check Slides API TableCell resource.
27
- // It has `text` field of type `TextContent`.
28
- // FakeTextRange expects a `shape` with `__resource.shape.text`.
29
- // We might need to adapt FakeTextRange or mock a shape-like object.
30
-
31
- // Let's create a proxy for shape so FakeTextRange can work.
32
158
  const mockShape = {
33
159
  getObjectId: () => this.__table.getObjectId(),
34
- __resource: {
35
- shape: {
36
- text: this.__resource?.text || { textElements: [] }
37
- }
160
+ get __resource() {
161
+ return {
162
+ shape: {
163
+ text: this.__target.__resource?.text || { textElements: [] }
164
+ }
165
+ };
38
166
  },
167
+ __target: this,
39
168
  __cellLocation: {
40
169
  rowIndex: this.__rowIndex,
41
170
  columnIndex: this.__colIndex
@@ -0,0 +1,28 @@
1
+ import { Proxies } from '../../support/proxies.js';
2
+
3
+ /**
4
+ * create a new FakeTableCellRange instance
5
+ * @param {...any} args
6
+ * @returns {FakeTableCellRange}
7
+ */
8
+ export const newFakeTableCellRange = (...args) => {
9
+ return Proxies.guard(new FakeTableCellRange(...args));
10
+ };
11
+
12
+ export class FakeTableCellRange {
13
+ constructor(cells) {
14
+ this.__cells = cells;
15
+ }
16
+
17
+ /**
18
+ * Returns the list of TableCell instances.
19
+ * @returns {FakeTableCell[]} The cells.
20
+ */
21
+ getTableCells() {
22
+ return this.__cells;
23
+ }
24
+
25
+ toString() {
26
+ return 'TableCellRange';
27
+ }
28
+ }
@@ -0,0 +1,72 @@
1
+ import { Proxies } from '../../support/proxies.js';
2
+ import { newFakeTableCell } from './faketablecell.js';
3
+
4
+ /**
5
+ * create a new FakeTableColumn instance
6
+ * @param {...any} args
7
+ * @returns {FakeTableColumn}
8
+ */
9
+ export const newFakeTableColumn = (...args) => {
10
+ return Proxies.guard(new FakeTableColumn(...args));
11
+ };
12
+
13
+ export class FakeTableColumn {
14
+ constructor(table, colIndex) {
15
+ this.__table = table;
16
+ this.__colIndex = colIndex;
17
+ }
18
+
19
+ /**
20
+ * Gets a cell by its index.
21
+ * @param {number} index The row index.
22
+ * @returns {FakeTableCell} The cell.
23
+ */
24
+ getCell(index) {
25
+ return newFakeTableCell(this.__table, index, this.__colIndex);
26
+ }
27
+
28
+ /**
29
+ * Gets the 0-based index of the column.
30
+ * @returns {number} The index.
31
+ */
32
+ getIndex() {
33
+ return this.__colIndex;
34
+ }
35
+
36
+ /**
37
+ * Gets the number of cells in this column.
38
+ * @returns {number} The number of cells.
39
+ */
40
+ getNumCells() {
41
+ return this.__table.getNumRows();
42
+ }
43
+
44
+ /**
45
+ * Gets the table containing the current column.
46
+ * @returns {FakeTable} The parent table.
47
+ */
48
+ getParentTable() {
49
+ return this.__table;
50
+ }
51
+
52
+ /**
53
+ * Gets the width of the column in points.
54
+ * @returns {number} The width.
55
+ */
56
+ getWidth() {
57
+ const tableResource = this.__table.__resource.table;
58
+ const colProperties = tableResource?.tableColumns?.[this.__colIndex];
59
+ return this.__table.__normalize(colProperties?.columnWidth);
60
+ }
61
+
62
+ /**
63
+ * Removes the table column.
64
+ */
65
+ remove() {
66
+ throw new Error('TableColumn.remove() not yet implemented');
67
+ }
68
+
69
+ toString() {
70
+ return 'TableColumn';
71
+ }
72
+ }
@@ -38,6 +38,22 @@ export class FakeTableRow {
38
38
  return cells[index];
39
39
  }
40
40
 
41
+ /**
42
+ * Returns the 0-based index of the row.
43
+ * @returns {number} The index.
44
+ */
45
+ getIndex() {
46
+ return this.__rowIndex;
47
+ }
48
+
49
+ /**
50
+ * Returns the minimum height of the row in points.
51
+ * @returns {number} The minimum height.
52
+ */
53
+ getMinimumHeight() {
54
+ return this.__table.__normalize(this.__resource?.rowHeight);
55
+ }
56
+
41
57
  /**
42
58
  * Gets the number of cells in the row.
43
59
  * @returns {number} The number of cells.
@@ -46,6 +62,21 @@ export class FakeTableRow {
46
62
  return (this.__resource?.tableCells || []).length;
47
63
  }
48
64
 
65
+ /**
66
+ * Returns the table containing the current row.
67
+ * @returns {FakeTable} The parent table.
68
+ */
69
+ getParentTable() {
70
+ return this.__table;
71
+ }
72
+
73
+ /**
74
+ * Removes the table row.
75
+ */
76
+ remove() {
77
+ throw new Error('TableRow.remove() not yet implemented');
78
+ }
79
+
49
80
  toString() {
50
81
  return 'TableRow';
51
82
  }