@syncmatters/script-api 1.0.23 → 1.0.25
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 +1 -1
- package/lib/connection.d.ts +5 -12
- package/lib/context.d.ts +12 -0
- package/lib/utilities/csv-reader/csv-reader-csv-parse.d.ts +1 -1
- package/lib/utilities/csv-reader/types.d.ts +11 -4
- package/lib/utilities/http-client/types.d.ts +8 -1
- package/lib/utilities/utilities.d.ts +4 -0
- package/lib/utilities/www-utils/www-utils.d.ts +39 -0
- package/package.json +2 -2
package/api.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export * from "./lib/sync.js";
|
|
|
10
10
|
export * from "./lib/sync-group.js";
|
|
11
11
|
export * from "./lib/utilities/kv-store/types.js";
|
|
12
12
|
export * from "./lib/utilities/rate-limiter/rate-limiter.js";
|
|
13
|
-
export type { HttpClient, HttpClientOptions, HttpRequest, } from "./lib/utilities/http-client/types.js";
|
|
13
|
+
export type { HttpClient, HttpClientOptions, HttpFullResponse, HttpRequest, } from "./lib/utilities/http-client/types.js";
|
|
14
14
|
export type JsonValuesReader = InstanceType<typeof JVR>;
|
|
15
15
|
export type JsonValuesWriter = InstanceType<typeof JVW.JsonValuesWriter>;
|
|
16
16
|
export type WriteBehaviour = JVW.WriteBehaviour;
|
package/lib/connection.d.ts
CHANGED
|
@@ -141,7 +141,7 @@ export interface CacheQueryOneOptions {
|
|
|
141
141
|
name: string;
|
|
142
142
|
values: string[];
|
|
143
143
|
};
|
|
144
|
-
|
|
144
|
+
keys?: string[];
|
|
145
145
|
};
|
|
146
146
|
propertyFilter?: {
|
|
147
147
|
metaOnly?: boolean;
|
|
@@ -292,8 +292,6 @@ export interface Row {
|
|
|
292
292
|
srcObjectId?: string;
|
|
293
293
|
srcRowId: string;
|
|
294
294
|
};
|
|
295
|
-
/** if filters requested rows be returned from a 'checkpoint', the final row in the stream will return the next checkpoint here */
|
|
296
|
-
checkpoint?: string | undefined;
|
|
297
295
|
}
|
|
298
296
|
/** Iterator is returned in response to Query() operations */
|
|
299
297
|
export interface QueryIterator<T> extends AsyncIterableIterator<T> {
|
|
@@ -438,11 +436,11 @@ export interface ObjectSettingMeta {
|
|
|
438
436
|
advanced?: boolean;
|
|
439
437
|
readonly?: boolean;
|
|
440
438
|
mandatory?: boolean;
|
|
441
|
-
displayIf?:
|
|
439
|
+
displayIf?: "none" | "other_setting_has_value" | "other_setting_is_not_empty";
|
|
442
440
|
displayIfSetting?: string;
|
|
443
441
|
displayIfValues?: string[];
|
|
444
|
-
type?: string;
|
|
445
|
-
control?:
|
|
442
|
+
type?: "string" | "boolean" | "number" | "string_array" | "connection_uid_template" | "google_picker";
|
|
443
|
+
control?: "singlelinetext" | "textarea" | "checkbox" | "switch" | "integer" | "url" | "datepicker" | "datetimepicker" | "filepicker" | "drivefolder" | "drivefile" | "select" | "multiselect" | "button" | "timezone";
|
|
446
444
|
options?: ObjectSettingMetaOption[];
|
|
447
445
|
default?: unknown;
|
|
448
446
|
constraints?: ObjectFieldConstraints;
|
|
@@ -452,11 +450,6 @@ export interface ObjectSettingMetaOption {
|
|
|
452
450
|
id: string;
|
|
453
451
|
name?: string;
|
|
454
452
|
order?: string;
|
|
455
|
-
/**
|
|
456
|
-
* on an option of a prerequisite (or defines_version) connection setting: `false` makes a connection
|
|
457
|
-
* with this option selected single-phase - discover() is never called and its metadata is collected on
|
|
458
|
-
* first use, as for a connector without discovery. Absent inherits the connector's `discovery` flag.
|
|
459
|
-
*/
|
|
460
453
|
discovery?: boolean;
|
|
461
454
|
}
|
|
462
455
|
export interface ObjectRowFilter {
|
|
@@ -676,7 +669,7 @@ export interface ObjectRelationship {
|
|
|
676
669
|
data?: any;
|
|
677
670
|
}
|
|
678
671
|
/** IndexType holds a data index definition */
|
|
679
|
-
export type IndexType = "
|
|
672
|
+
export type IndexType = "jsonpath expression";
|
|
680
673
|
/** ObjectIndex specifies an index to be added to cached connector data. */
|
|
681
674
|
export interface ObjectIndex {
|
|
682
675
|
name: string;
|
package/lib/context.d.ts
CHANGED
|
@@ -20,6 +20,18 @@ export interface Context {
|
|
|
20
20
|
parameters: {
|
|
21
21
|
[name: string]: any;
|
|
22
22
|
};
|
|
23
|
+
/** set only when the run was triggered by an event */
|
|
24
|
+
event?: {
|
|
25
|
+
failedAttempts: number;
|
|
26
|
+
connectionId: string;
|
|
27
|
+
typeId: string;
|
|
28
|
+
timestamp: number;
|
|
29
|
+
object?: {
|
|
30
|
+
id: string;
|
|
31
|
+
key?: string;
|
|
32
|
+
};
|
|
33
|
+
data?: any;
|
|
34
|
+
};
|
|
23
35
|
connections: ContextMapFactories<ConnectionMap, Connection>;
|
|
24
36
|
syncGroups: ContextMapFactories<SyncGroupMap, SyncGroup>;
|
|
25
37
|
state: {
|
|
@@ -9,7 +9,7 @@ export declare class CsvReaderCsvParse implements CsvReader {
|
|
|
9
9
|
header(): Promise<string[]>;
|
|
10
10
|
jsDoc(): Promise<string>;
|
|
11
11
|
verifyHeader(required: string[]): Promise<void>;
|
|
12
|
-
rows(): AsyncIterableIterator<
|
|
12
|
+
rows(): AsyncIterableIterator<string[]>;
|
|
13
13
|
rowsWithProps(): AsyncIterableIterator<{
|
|
14
14
|
[name: string]: string;
|
|
15
15
|
}>;
|
|
@@ -26,14 +26,21 @@ export interface CsvReaderOptions {
|
|
|
26
26
|
escapeChar?: string;
|
|
27
27
|
/** number of lines to skip at the beginning of the file */
|
|
28
28
|
skipLines?: number;
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* parse engine to use (default: 'csv-parse'). 'fast-csv' was the default until csv-parse (not strict) was made to
|
|
31
|
+
* read as it does; it remains as a fallback while the switch beds in
|
|
32
|
+
*/
|
|
30
33
|
parseEngine?: "fast-csv" | "csv-parse";
|
|
34
|
+
/**
|
|
35
|
+
* csv-parse engine only: true rejects ragged rows, stray or misplaced quotes and whitespace-only lines, reporting
|
|
36
|
+
* the line number; false (default) tolerates them as the fast-csv engine does
|
|
37
|
+
*/
|
|
38
|
+
strict?: boolean;
|
|
31
39
|
}
|
|
32
40
|
/**
|
|
33
41
|
* CsvReader parses a csv and emits an async iterator for accessing the next row. The row is an array
|
|
34
|
-
* allowing access to the fields by index
|
|
42
|
+
* allowing access to the fields by index, rowsWithProps allows access by header name:
|
|
35
43
|
* for await (const row of reader.rows()) {
|
|
36
|
-
* var field1ByName = row["my col name"];
|
|
37
44
|
* var field1ByIndex = row[0];
|
|
38
45
|
* }
|
|
39
46
|
*/
|
|
@@ -41,7 +48,7 @@ export interface CsvReader {
|
|
|
41
48
|
header(): Promise<string[]>;
|
|
42
49
|
jsDoc(): Promise<string>;
|
|
43
50
|
verifyHeader(required: string[]): Promise<void>;
|
|
44
|
-
rows(): AsyncIterableIterator<
|
|
51
|
+
rows(): AsyncIterableIterator<string[]>;
|
|
45
52
|
rowsWithProps(): AsyncIterableIterator<{
|
|
46
53
|
[name: string]: string;
|
|
47
54
|
}>;
|
|
@@ -36,6 +36,14 @@ export interface HttpRequest {
|
|
|
36
36
|
fullResponse?: boolean;
|
|
37
37
|
fileResponse?: boolean;
|
|
38
38
|
}
|
|
39
|
+
/** HttpFullResponse is the execute() response when HttpRequest option fullResponse is true */
|
|
40
|
+
export interface HttpFullResponse {
|
|
41
|
+
body?: any;
|
|
42
|
+
headers: {
|
|
43
|
+
[name: string]: string;
|
|
44
|
+
};
|
|
45
|
+
statusCode: number;
|
|
46
|
+
}
|
|
39
47
|
/** HttpCanRetry is an optional interface allowing a connector to assess whether a retry is allowed */
|
|
40
48
|
export interface HttpCanRetry {
|
|
41
49
|
(err: HttpError, method: HttpMethod, url: string, httpCode: number, responseHeaders: {
|
|
@@ -55,7 +63,6 @@ export interface HttpClientOptions {
|
|
|
55
63
|
errMessageFormat?: "default" | "concise";
|
|
56
64
|
canRetry?: HttpCanRetry;
|
|
57
65
|
onError?: (err: HttpError, method: HttpMethod, url: string, httpCode: number, reqJson?: unknown) => void;
|
|
58
|
-
onSuccess?: (method: string, url: string, httpCode: number, reqJson?: unknown) => void;
|
|
59
66
|
}
|
|
60
67
|
export interface HttpClient {
|
|
61
68
|
execute: (request: HttpRequest) => Promise<any>;
|
|
@@ -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 { domainCleanse, domainCompare, domainIsShared } from "./www-utils/www-utils.js";
|
|
15
16
|
import { xmlParse } from "./xml-utils/xml-utils.js";
|
|
16
17
|
import { nameParser } from "./name-parser/name-parser.js";
|
|
17
18
|
import { tempDir, tempFile } from "./file-utils/file-utils.js";
|
|
@@ -47,6 +48,9 @@ export declare const utilities: {
|
|
|
47
48
|
emailCleanse: typeof emailCleanse;
|
|
48
49
|
emailIsPublic: typeof emailIsPublic;
|
|
49
50
|
domainParse: typeof domainParse;
|
|
51
|
+
domainCleanse: typeof domainCleanse;
|
|
52
|
+
domainCompare: typeof domainCompare;
|
|
53
|
+
domainIsShared: typeof domainIsShared;
|
|
50
54
|
fileProvider: typeof fileProvider;
|
|
51
55
|
gzip: {
|
|
52
56
|
compressB64: typeof gzipB64;
|
|
@@ -4,7 +4,46 @@ interface ParsedDomain {
|
|
|
4
4
|
tld: string;
|
|
5
5
|
tldListed: boolean;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Break a hostname or URL into its domain, subdomain and public suffix (tld). The parts of an
|
|
9
|
+
* internationalized name are returned in the form the value was written in: unicode for "münchen.de",
|
|
10
|
+
* punycode for "xn--mnchen-3ya.de".
|
|
11
|
+
*/
|
|
7
12
|
export declare function domainParse(hostname: string): ParsedDomain;
|
|
13
|
+
/** How far domainCleanse reduces a value: to the company's registered domain, or only to the host. */
|
|
14
|
+
export type DomainLevel = "company_domain" | "full_host";
|
|
15
|
+
/**
|
|
16
|
+
* Reduce a hostname or URL to a lowercased domain, dropping the scheme, port and path.
|
|
17
|
+
* - "company_domain" (the default) also drops every subdomain, leaving the registrable domain:
|
|
18
|
+
* "https://www.shop.Acme.co.uk/about" becomes "acme.co.uk".
|
|
19
|
+
* - "full_host" keeps the host and drops only a leading "www.": "shop.acme.co.uk".
|
|
20
|
+
*
|
|
21
|
+
* An internationalized name is returned in the form it was written in ("münchen.de" stays unicode,
|
|
22
|
+
* "xn--mnchen-3ya.de" stays punycode). Returns undefined when the value does not parse to a domain with a
|
|
23
|
+
* listed public suffix (e.g. "n/a", "john.smith").
|
|
24
|
+
*/
|
|
25
|
+
export declare function domainCleanse(value: string | undefined, level?: DomainLevel): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Compare a stored domain or website value with the domain a domain[ci] match rule is looking for.
|
|
28
|
+
* - "host": the stored value is at exactly that host ("https://www.acme.com/about" and "acme.com").
|
|
29
|
+
* - "company": the domain sought has no subdomain and the stored value is on a subdomain of it
|
|
30
|
+
* ("https://portal.acme.com/login" and "acme.com").
|
|
31
|
+
* - undefined: no match, including when the stored value is a page or subdomain on a shared host
|
|
32
|
+
* ("facebook.com/acme"), which never identifies a company.
|
|
33
|
+
*
|
|
34
|
+
* A connector that finds candidates by a contains search keeps the "host" candidates when there are any,
|
|
35
|
+
* and otherwise may keep the "company" ones. Case and the unicode or punycode form of an internationalized
|
|
36
|
+
* name are ignored.
|
|
37
|
+
*/
|
|
38
|
+
export declare function domainCompare(storedValue: string | undefined, matchDomain: string | undefined): "host" | "company" | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Whether a hostname or URL is a shared address rather than a company's own site, so it should not be used to
|
|
41
|
+
* identify a company: a page or subdomain on a shared host such as a social network, site builder, directory,
|
|
42
|
+
* URL shortener or public email provider ("facebook.com/acme", "sites.google.com/view/acme"). The shared
|
|
43
|
+
* host's own address ("facebook.com", "https://www.google.com/") is not shared: it belongs to that company.
|
|
44
|
+
* Pass the original value, not the result of domainCleanse.
|
|
45
|
+
*/
|
|
46
|
+
export declare function domainIsShared(value: string | undefined): boolean;
|
|
8
47
|
export declare function emailCleanse(email: string | undefined): string | undefined;
|
|
9
48
|
export declare function emailIsPublic(email: string | undefined): boolean;
|
|
10
49
|
export declare function tldCheck(tld: string | undefined): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncmatters/script-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
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": "
|
|
31
|
+
"typesContentHash": "a67babb6161481dc866ec520eb17814edf406e0be328319a66082e58751d90f3",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@types/node": "*"
|
|
34
34
|
}
|