@syncmatters/script-api 1.0.8 → 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.
@@ -192,6 +192,8 @@ export interface QueryOptions {
192
192
  randomFilter?: boolean;
193
193
  /** filter for rows by row id (key) */
194
194
  idsFilter?: Array<string>;
195
+ /** path of the alternate key field that the idsFilter values refer to, if applicable */
196
+ idsFilterField?: Array<API.JsonValuePathPart>;
195
197
  /** filter for rows that relate to another object on this connection */
196
198
  relatedFilter?: QueryRelatedFilter;
197
199
  /** filter for rows that meet a specific matching rule */
@@ -239,6 +241,8 @@ export interface QueryOneOptions {
239
241
  relationshipFields?: Array<string>;
240
242
  /** filter for rows by row id (key) */
241
243
  idsFilter?: Array<string>;
244
+ /** path of the alternate key field that the idsFilter values refer to, if applicable */
245
+ idsFilterField?: Array<API.JsonValuePathPart>;
242
246
  /** filter for rows that relate to another object on this connection */
243
247
  relatedFilter?: QueryRelatedFilter;
244
248
  /** filter for rows that meet a specific matching rule */
@@ -264,7 +268,8 @@ export interface Row {
264
268
  data?: any;
265
269
  /** if filters requested files be included in the response, and the if row includes a file, the file will be here */
266
270
  file?: FileProvider | null | undefined;
267
- /** if filters requested rows filter by 'related', or 'matched' to source rows the relationship details will be here */
271
+ /** if filters requested rows filter by 'related', or 'matched' to source rows the relationship details will be here;
272
+ * for idsFilter queries with an idsFilterField, srcRowId holds the requested (alternate key) value this row matched */
268
273
  relationship?: {
269
274
  relationshipId?: string;
270
275
  srcObjectId?: string;
@@ -439,6 +444,8 @@ export interface ObjectField {
439
444
  isKey?: boolean;
440
445
  /** field holds an object containing the user defined row unique identifier required for add an update operations, and an indication of the operation type */
441
446
  isUserKey?: boolean;
447
+ /** field holds a unique value and the connector honors it as an idsFilterField key in queries */
448
+ isAlternateKey?: boolean;
442
449
  /** field, and any fields below, are custom (account specific) */
443
450
  isCustom?: boolean;
444
451
  /** can this field be referenced in match rules? */
package/lib/sync.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Row, QueryRelatedFilter, QueryMatchFilter, QueryCheckpointFilter, UpsertCleanOptions, UpsertCleanResponse, ObjectFieldConstraints, JsonValuePath, RowMatchRuleType, Logger, Connection } from "../index.js";
1
+ import { Row, QueryRelatedFilter, QueryMatchFilter, QueryCheckpointFilter, UpsertCleanOptions, UpsertCleanResponse, ObjectFieldConstraints, JsonValuePath, JsonValuePathPart, RowMatchRuleType, Logger, Connection } from "../index.js";
2
2
  export type GroupRunMode = "Standard" | "SelectedIds" | "Errors";
3
3
  export type SyncOptimalBatchSizeOperation = "noFilter" | "idsFilter" | "relatedFilter" | "matchFilter" | "checkpointFilter" | "randomFilter" | "rowFilter" | "upsert" | "delete";
4
4
  export type SyncOptimalBatchSizeBatchType = "atomic" | "concurrent" | "splitInsertUpdateAtomic";
@@ -163,6 +163,9 @@ export interface SyncEndpointField {
163
163
  /** indicates this field holds an object containing the user defined unique row identifier required
164
164
  * for add and update operations, with an indication of the operation type */
165
165
  isUserDefinedId?: boolean;
166
+ /** indicates this field holds a unique value the connector can resolve rows by as an alternate to
167
+ * the row id (e.g. in lookups) */
168
+ isAlternateId?: boolean;
166
169
  /** indicates this field is custom */
167
170
  isCustom?: boolean;
168
171
  }
@@ -198,6 +201,8 @@ export interface SyncQueryOptions {
198
201
  randomFilter?: boolean;
199
202
  /** filter for rows by row id (key) */
200
203
  idsFilter?: Array<string>;
204
+ /** path of the alternate key field that the idsFilter values refer to, if applicable */
205
+ idsFilterField?: Array<JsonValuePathPart>;
201
206
  /** filter for rows that relate to another objects rows on this endpoint */
202
207
  relatedFilter?: QueryRelatedFilter;
203
208
  /** filter for rows that meet a specific matching rule */
@@ -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: (options: {
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
- export declare function xmlParse(source: string): Promise<any>;
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.8",
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": "06c0e7d73e478f9b36cfd586c79b5d57c001924d7f7f1b7868771537b4176e27",
23
+ "typesContentHash": "5251aaa77076a0901c2b3221a4be5f4d9a9d9aeb572ef3e59f4952b31e9fffdf",
24
24
  "dependencies": {
25
25
  "@types/node": "*"
26
26
  }