@syncmatters/script-api 1.0.9 → 1.0.10
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.
|
@@ -12,6 +12,7 @@ import { XlsxWriter, XlsxWriterOptions } from "./xlsx-writer/xlsx-writer.js";
|
|
|
12
12
|
import { emailCleanse } from "./www-utils/www-utils.js";
|
|
13
13
|
import { emailIsPublic } from "./www-utils/www-utils.js";
|
|
14
14
|
import { domainParse } from "./www-utils/www-utils.js";
|
|
15
|
+
import { xmlParse } from "./xml-utils/xml-utils.js";
|
|
15
16
|
import { nameParser } from "./name-parser/name-parser.js";
|
|
16
17
|
import { tempDir, tempFile } from "./file-utils/file-utils.js";
|
|
17
18
|
import { dateFormat, dateParse, dateTransform } from "./date-utils/date-utils.js";
|
|
@@ -87,9 +88,7 @@ export declare const utilities: {
|
|
|
87
88
|
};
|
|
88
89
|
xlsxReader: (options: XlsxReaderOptions) => XlsxReader;
|
|
89
90
|
xlsxWriter: (options: XlsxWriterOptions) => XlsxWriter;
|
|
90
|
-
xmlParse:
|
|
91
|
-
string: string;
|
|
92
|
-
}) => Promise<any>;
|
|
91
|
+
xmlParse: typeof xmlParse;
|
|
93
92
|
zip: {
|
|
94
93
|
compress: typeof zipCompress;
|
|
95
94
|
extract: typeof zipExtract;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { FileProvider } from "../file-provider/file-provider.js";
|
|
2
|
+
/** Where xmlParse reads XML from; exactly one of `fileProvider` or `string`. */
|
|
3
|
+
export interface XmlParseSource {
|
|
4
|
+
fileProvider?: FileProvider;
|
|
5
|
+
string?: string;
|
|
6
|
+
/** Decoding for fileProvider bytes (default `"utf8"`); ignored for string sources. */
|
|
7
|
+
encoding?: "utf8" | "utf16le" | "ucs2" | "latin1";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Options for xmlParse (module-internal; not re-exported from the package root).
|
|
11
|
+
* Prefer `source`; top-level `string` is deprecated.
|
|
12
|
+
* Set `emit` to stream matching elements; omit for a full-document Promise.
|
|
13
|
+
*/
|
|
14
|
+
export interface XmlParseOptions {
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use `source: { string }` instead.
|
|
17
|
+
*/
|
|
18
|
+
string?: string;
|
|
19
|
+
source?: XmlParseSource;
|
|
20
|
+
/**
|
|
21
|
+
* XPath subset expressions: `//Name`, `/A/B/C`, or `A/B` (local names; XML prefixes ignored).
|
|
22
|
+
* When set, xmlParse streams matching elements; omit for a full-document Promise.
|
|
23
|
+
*/
|
|
24
|
+
emit?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* One matched element from a streaming xmlParse({ source, emit }) call.
|
|
28
|
+
* Call sites normally infer this; kept here like CsvReader's row contract.
|
|
29
|
+
*/
|
|
30
|
+
export interface XmlParseChunk {
|
|
31
|
+
matched: string;
|
|
32
|
+
localName: string;
|
|
33
|
+
path: string[];
|
|
34
|
+
ancestors: Array<{
|
|
35
|
+
localName: string;
|
|
36
|
+
attributes: Record<string, string>;
|
|
37
|
+
}>;
|
|
38
|
+
value: any;
|
|
39
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Rebuild a well-formed XML fragment from sax events (saxpath-recorder style). */
|
|
2
|
+
export declare class XmlFragmentRecorder {
|
|
3
|
+
#private;
|
|
4
|
+
onOpenTag(name: string, attributes: Record<string, string>, isSelfClosing: boolean): void;
|
|
5
|
+
onText(text: string): void;
|
|
6
|
+
onCdata(text: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* @returns completed outer XML when the recorded root element closes; otherwise undefined
|
|
9
|
+
*/
|
|
10
|
+
onCloseTag(name: string): string | undefined;
|
|
11
|
+
}
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { XmlParseChunk, XmlParseOptions } from "./types.js";
|
|
2
|
+
export declare function xmlParse(options: XmlParseOptions & {
|
|
3
|
+
emit: string[];
|
|
4
|
+
}): AsyncIterable<XmlParseChunk>;
|
|
5
|
+
export declare function xmlParse(options: XmlParseOptions & {
|
|
6
|
+
emit?: undefined;
|
|
7
|
+
}): Promise<any>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Compiled emit expression — internal to xml-utils streaming. */
|
|
2
|
+
export type XmlEmitMatcher = {
|
|
3
|
+
kind: "descendant";
|
|
4
|
+
localName: string;
|
|
5
|
+
raw: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: "absolute";
|
|
8
|
+
steps: string[];
|
|
9
|
+
raw: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "suffix";
|
|
12
|
+
steps: string[];
|
|
13
|
+
raw: string;
|
|
14
|
+
};
|
|
15
|
+
/** Strip an XML prefix from a qname (`edm:EntityType` → `EntityType`). */
|
|
16
|
+
export declare function localNameOf(qname: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Compile one XPath-subset expression.
|
|
19
|
+
* Supported: `//Name`, `/A/B/C`, `A/B` (local names only; prefixes ignored).
|
|
20
|
+
*/
|
|
21
|
+
export declare function compileEmitExpression(raw: string): XmlEmitMatcher;
|
|
22
|
+
export declare function compileEmitExpressions(emit: string[]): XmlEmitMatcher[];
|
|
23
|
+
/** True if the current element stack (local names) matches the compiled expression. */
|
|
24
|
+
export declare function matchesEmit(matcher: XmlEmitMatcher, pathLocalNames: string[]): boolean;
|
|
25
|
+
/** Last path step local name for a matcher (the element that starts a potential match). */
|
|
26
|
+
export declare function matcherTargetLocalName(matcher: XmlEmitMatcher): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncmatters/script-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
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": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"author": "SyncMatters",
|
|
22
22
|
"homepage": "https://syncmatters.com",
|
|
23
|
-
"typesContentHash": "
|
|
23
|
+
"typesContentHash": "5251aaa77076a0901c2b3221a4be5f4d9a9d9aeb572ef3e59f4952b31e9fffdf",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@types/node": "*"
|
|
26
26
|
}
|