@syncmatters/script-api 1.0.28 → 1.0.29

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/api.d.ts CHANGED
@@ -18,7 +18,7 @@ export type JsonValuesWriter = InstanceType<typeof JVW.JsonValuesWriter>;
18
18
  export type WriteBehaviour = JVW.WriteBehaviour;
19
19
  export type { CsvReaderOptions } from "./lib/utilities/csv-reader/index.js";
20
20
  export type { CsvWriterOptions } from "./lib/utilities/csv-writer/csv-writer.js";
21
- export type { XlsxReaderOptions } from "./lib/utilities/xlsx-reader/xlsx-reader.js";
21
+ export type { XlsxReaderOptions, XlsxToCsvsOptions, } from "./lib/utilities/xlsx-reader/xlsx-reader.js";
22
22
  export type { JsonValuePathPart, JsonValuePath, } from "./lib/utilities/json-utils/json-values-types.js";
23
23
  export type { FileProvider, FileProviderOptions, } from "./lib/utilities/file-provider/file-provider.js";
24
24
  export * from "./lib/logger.js";
@@ -29,7 +29,9 @@ export declare enum ErrorCode {
29
29
  UnexpectedRowId = "SCRIPT_UNEXPECTED_ROW_ID",
30
30
  KvStoreShadowMismatch = "SCRIPT_KV_STORE_SHADOW_MISMATCH",
31
31
  /** the token that started the run does not hold a scope the operation needs */
32
- MissingScope = "SCRIPT_MISSING_SCOPE"
32
+ MissingScope = "SCRIPT_MISSING_SCOPE",
33
+ /** the bundled excel2csv converter is unavailable or exited with an error */
34
+ XlsxConversionFailed = "SCRIPT_XLSX_CONVERSION_FAILED"
33
35
  }
34
36
  /**
35
37
  * ConnectorError extends error to expose a meaningful error code e.g.
@@ -8,7 +8,7 @@ import { HttpClient } from "./http-client/types.js";
8
8
  import { fileProvider } from "./file-provider/file-provider.js";
9
9
  import { CsvReaderOptions } from "./csv-reader/index.js";
10
10
  import { CsvWriter, CsvWriterOptions } from "./csv-writer/csv-writer.js";
11
- import { XlsxReader, XlsxReaderOptions } from "./xlsx-reader/xlsx-reader.js";
11
+ import { XlsxReader, XlsxReaderOptions, XlsxToCsvsOptions } from "./xlsx-reader/xlsx-reader.js";
12
12
  import { XlsxWriter, XlsxWriterOptions } from "./xlsx-writer/xlsx-writer.js";
13
13
  import { emailCleanse } from "./www-utils/www-utils.js";
14
14
  import { emailIsPublic } from "./www-utils/www-utils.js";
@@ -107,6 +107,9 @@ export declare const utilities: {
107
107
  get: typeof UpsertFlags.get;
108
108
  };
109
109
  xlsxReader: (options: XlsxReaderOptions) => XlsxReader;
110
+ xlsxToCsvs: (options: XlsxToCsvsOptions) => Promise<{
111
+ [sheet: string]: import("@syncmatters/script-api").FileProvider;
112
+ }>;
110
113
  xlsxWriter: (options: XlsxWriterOptions) => XlsxWriter;
111
114
  xmlParse: typeof xmlParse;
112
115
  zip: {
@@ -1,4 +1,14 @@
1
1
  import { FileProvider } from "../file-provider/file-provider.js";
2
+ export interface XlsxToCsvsOptions {
3
+ source: {
4
+ /** the workbook; it is copied to a temp file for the conversion and the copy is removed afterwards */
5
+ fileProvider?: FileProvider;
6
+ /** path of a workbook on disk; it is read in place */
7
+ path?: string;
8
+ };
9
+ /** names of the sheets to convert; every sheet when omitted */
10
+ sheets?: string[];
11
+ }
2
12
  export interface XlsxReaderOptions {
3
13
  source: {
4
14
  fileProvider?: FileProvider;
@@ -22,6 +32,15 @@ export interface XlsxReaderOptions {
22
32
  */
23
33
  export declare class XlsxReader {
24
34
  constructor(options: XlsxReaderOptions);
35
+ /**
36
+ * Converts the sheets of a workbook to CSV files with the excel2csv binary bundled in this package, one CSV
37
+ * per sheet, and returns a FileProvider per sheet keyed by sheet name. Each provider deletes its CSV when
38
+ * closed, so close every provider once done with it (utilities.closeFileProviders(result) closes them all).
39
+ * The key order is the converter's output order, not the workbook's sheet order.
40
+ */
41
+ static xlsxToCsvs(options: XlsxToCsvsOptions): Promise<{
42
+ [sheet: string]: FileProvider;
43
+ }>;
25
44
  sheets(): Promise<string[]>;
26
45
  header(sheet: string): Promise<string[]>;
27
46
  jsDoc(sheet: string): Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncmatters/script-api",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
4
4
  "description": "TypeScript type definitions for the SyncMatters script API (types only - scripts execute on the SyncMatters platform)",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -28,7 +28,7 @@
28
28
  "license": "MIT",
29
29
  "author": "SyncMatters",
30
30
  "homepage": "https://syncmatters.com",
31
- "typesContentHash": "65571529e07eb24c545c835d7fae7c6930797856ef2a0833242e6f5e0bb847ba",
31
+ "typesContentHash": "f4f0f8617559474b932871a5870e34bed9bf3b5cf1ec1b20066146ada8201f63",
32
32
  "dependencies": {
33
33
  "@types/node": "*"
34
34
  }