md-spreadsheet-parser 1.1.7 → 1.1.9

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.
package/dist/index.d.ts CHANGED
@@ -25,6 +25,11 @@ export declare class Table {
25
25
  endLine: number | undefined;
26
26
  constructor(data?: Partial<Table>);
27
27
  toDTO(): any;
28
+ /**
29
+ * Returns a JSON-compatible plain object representation.
30
+ * Mirrors Python's .json property.
31
+ */
32
+ get json(): any;
28
33
  toModels(schemaCls: any, conversionSchema?: any): any;
29
34
  toMarkdown(schema?: any): any;
30
35
  updateCell(rowIdx: any, colIdx: any, value: any): any;
@@ -40,6 +45,11 @@ export declare class Sheet {
40
45
  metadata: any | undefined;
41
46
  constructor(data?: Partial<Sheet>);
42
47
  toDTO(): any;
48
+ /**
49
+ * Returns a JSON-compatible plain object representation.
50
+ * Mirrors Python's .json property.
51
+ */
52
+ get json(): any;
43
53
  getTable(name: any): any;
44
54
  toMarkdown(schema?: any): any;
45
55
  }
@@ -48,6 +58,11 @@ export declare class Workbook {
48
58
  metadata: any | undefined;
49
59
  constructor(data?: Partial<Workbook>);
50
60
  toDTO(): any;
61
+ /**
62
+ * Returns a JSON-compatible plain object representation.
63
+ * Mirrors Python's .json property.
64
+ */
65
+ get json(): any;
51
66
  getSheet(name: any): any;
52
67
  toMarkdown(schema?: any): any;
53
68
  addSheet(name: any): any;
package/dist/index.js CHANGED
@@ -128,6 +128,22 @@ export class Table {
128
128
  dto.metadata = JSON.stringify(dto.metadata);
129
129
  return dto;
130
130
  }
131
+ /**
132
+ * Returns a JSON-compatible plain object representation.
133
+ * Mirrors Python's .json property.
134
+ */
135
+ get json() {
136
+ return {
137
+ name: this.name,
138
+ description: this.description,
139
+ headers: this.headers,
140
+ rows: this.rows,
141
+ metadata: this.metadata ?? {},
142
+ startLine: this.startLine,
143
+ endLine: this.endLine,
144
+ alignments: this.alignments,
145
+ };
146
+ }
131
147
  toModels(schemaCls, conversionSchema) {
132
148
  const dto = this.toDTO();
133
149
  const clientRes = clientSideToModels(this.headers, this.rows || [], schemaCls);
@@ -195,6 +211,17 @@ export class Sheet {
195
211
  dto.metadata = JSON.stringify(dto.metadata);
196
212
  return dto;
197
213
  }
214
+ /**
215
+ * Returns a JSON-compatible plain object representation.
216
+ * Mirrors Python's .json property.
217
+ */
218
+ get json() {
219
+ return {
220
+ name: this.name,
221
+ tables: (this.tables || []).map((t) => t.json ? t.json : t),
222
+ metadata: this.metadata ?? {},
223
+ };
224
+ }
198
225
  getTable(name) {
199
226
  const dto = this.toDTO();
200
227
  const res = _sheetGetTable(dto, name);
@@ -221,6 +248,16 @@ export class Workbook {
221
248
  dto.metadata = JSON.stringify(dto.metadata);
222
249
  return dto;
223
250
  }
251
+ /**
252
+ * Returns a JSON-compatible plain object representation.
253
+ * Mirrors Python's .json property.
254
+ */
255
+ get json() {
256
+ return {
257
+ sheets: (this.sheets || []).map((s) => s.json ? s.json : s),
258
+ metadata: this.metadata ?? {},
259
+ };
260
+ }
224
261
  getSheet(name) {
225
262
  const dto = this.toDTO();
226
263
  const res = _workbookGetSheet(dto, name);
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-spreadsheet-parser",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "A robust Markdown table parser and manipulator, powered by Python and WebAssembly.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
Binary file
package/src/index.ts CHANGED
@@ -163,6 +163,23 @@ export class Table {
163
163
  return dto;
164
164
  }
165
165
 
166
+ /**
167
+ * Returns a JSON-compatible plain object representation.
168
+ * Mirrors Python's .json property.
169
+ */
170
+ get json(): any {
171
+ return {
172
+ name: this.name,
173
+ description: this.description,
174
+ headers: this.headers,
175
+ rows: this.rows,
176
+ metadata: this.metadata ?? {},
177
+ startLine: this.startLine,
178
+ endLine: this.endLine,
179
+ alignments: this.alignments,
180
+ };
181
+ }
182
+
166
183
  toModels(schemaCls: any, conversionSchema?: any): any {
167
184
  const dto = this.toDTO();
168
185
  const clientRes = clientSideToModels(this.headers, this.rows || [], schemaCls);
@@ -242,6 +259,18 @@ export class Sheet {
242
259
  return dto;
243
260
  }
244
261
 
262
+ /**
263
+ * Returns a JSON-compatible plain object representation.
264
+ * Mirrors Python's .json property.
265
+ */
266
+ get json(): any {
267
+ return {
268
+ name: this.name,
269
+ tables: (this.tables || []).map((t: any) => t.json ? t.json : t),
270
+ metadata: this.metadata ?? {},
271
+ };
272
+ }
273
+
245
274
  getTable(name: any): any {
246
275
  const dto = this.toDTO();
247
276
  const res = _sheetGetTable(dto, name);
@@ -273,6 +302,17 @@ export class Workbook {
273
302
  return dto;
274
303
  }
275
304
 
305
+ /**
306
+ * Returns a JSON-compatible plain object representation.
307
+ * Mirrors Python's .json property.
308
+ */
309
+ get json(): any {
310
+ return {
311
+ sheets: (this.sheets || []).map((s: any) => s.json ? s.json : s),
312
+ metadata: this.metadata ?? {},
313
+ };
314
+ }
315
+
276
316
  getSheet(name: any): any {
277
317
  const dto = this.toDTO();
278
318
  const res = _workbookGetSheet(dto, name);