@syncmatters/script-api 1.0.0
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/LICENSE +21 -0
- package/README.md +37 -0
- package/api.d.ts +24 -0
- package/index.d.ts +3 -0
- package/index.js +1 -0
- package/lib/coded-error.d.ts +7 -0
- package/lib/connection.d.ts +597 -0
- package/lib/context.d.ts +58 -0
- package/lib/environment.d.ts +4 -0
- package/lib/logger.d.ts +20 -0
- package/lib/script-error.d.ts +38 -0
- package/lib/sync-group.d.ts +85 -0
- package/lib/sync.d.ts +392 -0
- package/lib/utilities/csv-reader/csv-reader-csv-parse.d.ts +16 -0
- package/lib/utilities/csv-reader/csv-reader-fast-csv.d.ts +15 -0
- package/lib/utilities/csv-reader/csv-reader.d.ts +2 -0
- package/lib/utilities/csv-reader/index.d.ts +2 -0
- package/lib/utilities/csv-reader/types.d.ts +48 -0
- package/lib/utilities/csv-writer/csv-writer.d.ts +21 -0
- package/lib/utilities/date-utils/date-utils.d.ts +37 -0
- package/lib/utilities/file-provider/file-provider-buffer.d.ts +11 -0
- package/lib/utilities/file-provider/file-provider-disk.d.ts +12 -0
- package/lib/utilities/file-provider/file-provider-string.d.ts +11 -0
- package/lib/utilities/file-provider/file-provider.d.ts +21 -0
- package/lib/utilities/file-utils/file-utils.d.ts +8 -0
- package/lib/utilities/html-utils/html-utils.d.ts +1 -0
- package/lib/utilities/http-client/fetch-http-client.d.ts +7 -0
- package/lib/utilities/http-client/fetch-http-error.d.ts +14 -0
- package/lib/utilities/http-client/types.d.ts +62 -0
- package/lib/utilities/json-utils/index.d.ts +6 -0
- package/lib/utilities/json-utils/json-changed-checker.d.ts +15 -0
- package/lib/utilities/json-utils/json-hash.d.ts +4 -0
- package/lib/utilities/json-utils/json-values-reader.d.ts +13 -0
- package/lib/utilities/json-utils/json-values-types.d.ts +41 -0
- package/lib/utilities/json-utils/json-values-writer.d.ts +28 -0
- package/lib/utilities/json-utils/lossless-numbers.d.ts +6 -0
- package/lib/utilities/json-utils/paths.d.ts +8 -0
- package/lib/utilities/kv-store/better-sqlite3/kv-collection-better-sqlite3.d.ts +18 -0
- package/lib/utilities/kv-store/better-sqlite3/kv-iterator-better-sqlite3.d.ts +26 -0
- package/lib/utilities/kv-store/better-sqlite3/kv-store-better-sqlite3.d.ts +11 -0
- package/lib/utilities/kv-store/index.d.ts +4 -0
- package/lib/utilities/kv-store/kv-store-benchmark-helpers.d.ts +14 -0
- package/lib/utilities/kv-store/shadow/kv-store-shadow.d.ts +29 -0
- package/lib/utilities/kv-store/sqlite3/database-sqlite3.d.ts +16 -0
- package/lib/utilities/kv-store/sqlite3/kv-collection-sqlite3.d.ts +18 -0
- package/lib/utilities/kv-store/sqlite3/kv-iterator-sqlite3.d.ts +21 -0
- package/lib/utilities/kv-store/sqlite3/kv-store-sqlite3.d.ts +11 -0
- package/lib/utilities/kv-store/sqlite3/statement-sqlite3.d.ts +13 -0
- package/lib/utilities/kv-store/types.d.ts +20 -0
- package/lib/utilities/name-parser/name-parser.d.ts +6 -0
- package/lib/utilities/rate-limiter/rate-limiter-concurrent.d.ts +24 -0
- package/lib/utilities/rate-limiter/rate-limiter-rolling.d.ts +18 -0
- package/lib/utilities/rate-limiter/rate-limiter.d.ts +15 -0
- package/lib/utilities/type-utils/type-utils.d.ts +11 -0
- package/lib/utilities/upsert-flags/upsert-flags.d.ts +10 -0
- package/lib/utilities/utilities.d.ts +105 -0
- package/lib/utilities/www-utils/www-utils.d.ts +14 -0
- package/lib/utilities/xlsx-reader/xlsx-reader.d.ts +32 -0
- package/lib/utilities/xlsx-writer/xlsx-writer.d.ts +23 -0
- package/lib/utilities/xml-utils/xml-utils.d.ts +1 -0
- package/lib/utilities/zip-utils/zip-utils.d.ts +29 -0
- package/package.json +23 -0
- package/sdk-test/sdk-test.d.ts +451 -0
- package/sdk-test.d.ts +3 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { RateLimiterRolling } from "./rate-limiter/rate-limiter-rolling.js";
|
|
2
|
+
import { RateLimiterConcurrent } from "./rate-limiter/rate-limiter-concurrent.js";
|
|
3
|
+
import { RateLimiterOptions } from "./rate-limiter/rate-limiter.js";
|
|
4
|
+
import { htmlToText } from "./html-utils/html-utils.js";
|
|
5
|
+
import { HttpClientOptions } from "./http-client/types.js";
|
|
6
|
+
import { HttpClient } from "./http-client/types.js";
|
|
7
|
+
import { fileProvider } from "./file-provider/file-provider.js";
|
|
8
|
+
import { CsvReaderOptions } from "./csv-reader/index.js";
|
|
9
|
+
import { CsvWriter, CsvWriterOptions } from "./csv-writer/csv-writer.js";
|
|
10
|
+
import { XlsxReader, XlsxReaderOptions } from "./xlsx-reader/xlsx-reader.js";
|
|
11
|
+
import { XlsxWriter, XlsxWriterOptions } from "./xlsx-writer/xlsx-writer.js";
|
|
12
|
+
import { emailCleanse } from "./www-utils/www-utils.js";
|
|
13
|
+
import { emailIsPublic } from "./www-utils/www-utils.js";
|
|
14
|
+
import { domainParse } from "./www-utils/www-utils.js";
|
|
15
|
+
import { nameParser } from "./name-parser/name-parser.js";
|
|
16
|
+
import { tempDir, tempFile } from "./file-utils/file-utils.js";
|
|
17
|
+
import { dateFormat, dateParse, dateTransform } from "./date-utils/date-utils.js";
|
|
18
|
+
import { gunzipB64, gzipB64, zipExtract, zipCompress } from "./zip-utils/zip-utils.js";
|
|
19
|
+
import * as TypeUtils from "./type-utils/type-utils.js";
|
|
20
|
+
import * as JsonUtils from "./json-utils/index.js";
|
|
21
|
+
import * as UpsertFlags from "./upsert-flags/upsert-flags.js";
|
|
22
|
+
import { KvStore } from "@syncmatters/script-api";
|
|
23
|
+
export declare const utilities: {
|
|
24
|
+
arrayOfStr: typeof arrayOfStrings;
|
|
25
|
+
arrayOfNum: typeof arrayOfNumbers;
|
|
26
|
+
clone: <T>(value: T) => T;
|
|
27
|
+
csvReader: (options: CsvReaderOptions) => import("./csv-reader/types.js").CsvReader;
|
|
28
|
+
csvWriter: (options: CsvWriterOptions) => CsvWriter;
|
|
29
|
+
dateFormat: typeof dateFormat;
|
|
30
|
+
dateParse: typeof dateParse;
|
|
31
|
+
dateTransform: typeof dateTransform;
|
|
32
|
+
emailCleanse: typeof emailCleanse;
|
|
33
|
+
emailIsPublic: typeof emailIsPublic;
|
|
34
|
+
domainParse: typeof domainParse;
|
|
35
|
+
fileProvider: typeof fileProvider;
|
|
36
|
+
gzip: {
|
|
37
|
+
compressB64: typeof gzipB64;
|
|
38
|
+
decompressB64: typeof gunzipB64;
|
|
39
|
+
};
|
|
40
|
+
htmlToText: typeof htmlToText;
|
|
41
|
+
httpClient: (options?: HttpClientOptions) => HttpClient;
|
|
42
|
+
json: {
|
|
43
|
+
stringsToLosslessNumbers: typeof JsonUtils.stringsToLosslessNumbers;
|
|
44
|
+
stringifyWithLosslessNumbers: typeof JsonUtils.stringifyWithLosslessNumbers;
|
|
45
|
+
parseWithLosslessNumbers: typeof JsonUtils.parseWithLosslessNumbers;
|
|
46
|
+
stringsFromLosslessNumbers: typeof JsonUtils.stringsFromLosslessNumbers;
|
|
47
|
+
valuesReader(options: {
|
|
48
|
+
paths: Array<JsonUtils.JsonValuePath>;
|
|
49
|
+
dontThrowOnInvalidParent?: boolean;
|
|
50
|
+
}): JsonUtils.JsonValuesReader;
|
|
51
|
+
valuesWriter(options: {
|
|
52
|
+
fields: Array<{
|
|
53
|
+
path: JsonUtils.JsonValuePath;
|
|
54
|
+
behaviour: JsonUtils.WriteBehaviour;
|
|
55
|
+
}>;
|
|
56
|
+
}): JsonUtils.JsonValuesWriter;
|
|
57
|
+
changesChecker: typeof JsonUtils.JsonChangedChecker;
|
|
58
|
+
stringToJsonValuePath: typeof JsonUtils.fieldPathToJsonValuePath;
|
|
59
|
+
stringsToJsonValuePaths: typeof JsonUtils.fieldsPathToJsonValuePaths;
|
|
60
|
+
fieldsToFieldPaths: typeof JsonUtils.fieldsToFieldPaths;
|
|
61
|
+
};
|
|
62
|
+
kvStore: () => KvStore;
|
|
63
|
+
nameParse: typeof nameParser;
|
|
64
|
+
rateLimiter: (options: RateLimiterOptions) => RateLimiterRolling | RateLimiterConcurrent;
|
|
65
|
+
setOfStr: typeof setOfStrings;
|
|
66
|
+
setOfNum: typeof setOfNumbers;
|
|
67
|
+
sleep: (ms: number) => Promise<void>;
|
|
68
|
+
tempDir: typeof tempDir;
|
|
69
|
+
tempFile: typeof tempFile;
|
|
70
|
+
tryGet: typeof tryGet;
|
|
71
|
+
types: {
|
|
72
|
+
isString: typeof TypeUtils.isString;
|
|
73
|
+
isNumber: typeof TypeUtils.isNumber;
|
|
74
|
+
isInteger: typeof TypeUtils.isInteger;
|
|
75
|
+
isBoolean: typeof TypeUtils.isBoolean;
|
|
76
|
+
isDate: typeof TypeUtils.isDate;
|
|
77
|
+
isBuffer: typeof TypeUtils.isBuffer;
|
|
78
|
+
isArray: typeof TypeUtils.isArray;
|
|
79
|
+
isFunction: typeof TypeUtils.isFunction;
|
|
80
|
+
isNull: typeof TypeUtils.isNull;
|
|
81
|
+
isUndefined: typeof TypeUtils.isUndefined;
|
|
82
|
+
isNullOrUndefined: typeof TypeUtils.isNullOrUndefined;
|
|
83
|
+
};
|
|
84
|
+
upsertFlags: {
|
|
85
|
+
set: typeof UpsertFlags.set;
|
|
86
|
+
get: typeof UpsertFlags.get;
|
|
87
|
+
};
|
|
88
|
+
xlsxReader: (options: XlsxReaderOptions) => XlsxReader;
|
|
89
|
+
xlsxWriter: (options: XlsxWriterOptions) => XlsxWriter;
|
|
90
|
+
xmlParse: (options: {
|
|
91
|
+
string: string;
|
|
92
|
+
}) => Promise<any>;
|
|
93
|
+
zip: {
|
|
94
|
+
compress: typeof zipCompress;
|
|
95
|
+
extract: typeof zipExtract;
|
|
96
|
+
};
|
|
97
|
+
zipExtract: typeof zipExtract;
|
|
98
|
+
};
|
|
99
|
+
declare function tryGet<T>(path: () => T | undefined): T | undefined;
|
|
100
|
+
declare function arrayOfStrings(): string[];
|
|
101
|
+
declare function arrayOfNumbers(): number[];
|
|
102
|
+
declare function setOfStrings(): Set<string>;
|
|
103
|
+
declare function setOfNumbers(): Set<number>;
|
|
104
|
+
export declare function reset(): Promise<void>;
|
|
105
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface ParsedDomain {
|
|
2
|
+
domain: string;
|
|
3
|
+
subdomain: string;
|
|
4
|
+
tld: string;
|
|
5
|
+
tldListed: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function domainParse(hostname: string): ParsedDomain;
|
|
8
|
+
export declare function emailCleanse(email: string | undefined): string | undefined;
|
|
9
|
+
export declare function emailIsPublic(email: string | undefined): boolean;
|
|
10
|
+
export declare function tldCheck(tld: string | undefined): boolean;
|
|
11
|
+
export declare function domainCheck(domain: string | undefined, options?: {
|
|
12
|
+
allowUnderscores?: boolean;
|
|
13
|
+
}): boolean;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FileProvider } from "../file-provider/file-provider.js";
|
|
2
|
+
export interface XlsxReaderOptions {
|
|
3
|
+
source: {
|
|
4
|
+
fileProvider?: FileProvider;
|
|
5
|
+
/** This is unlikely going to work. The string written will mangle the content b/o encoding in utf8 */
|
|
6
|
+
string?: string;
|
|
7
|
+
};
|
|
8
|
+
sheets: Array<{
|
|
9
|
+
name?: string;
|
|
10
|
+
noHeader?: boolean;
|
|
11
|
+
startRow?: number;
|
|
12
|
+
includeEmpty?: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* XlsxReader parses an xlsx and emits an async iterator for accessing the next row. The row is an array
|
|
17
|
+
* allowing access to the columns by index or, if the csv has a header, by header name:
|
|
18
|
+
* for await (const row of reader.rows()) {
|
|
19
|
+
* var field1ByName = row["my col name"];
|
|
20
|
+
* var field1ByIndex = row[0];
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
export declare class XlsxReader {
|
|
24
|
+
constructor(options: XlsxReaderOptions);
|
|
25
|
+
sheets(): Promise<string[]>;
|
|
26
|
+
header(sheet: string): Promise<string[]>;
|
|
27
|
+
jsDoc(sheet: string): Promise<string>;
|
|
28
|
+
verifyHeader(sheet: string, required: string[]): Promise<void>;
|
|
29
|
+
rows(sheet: string): AsyncIterableIterator<string[]>;
|
|
30
|
+
rowsWithProps<T>(sheet: string): AsyncIterableIterator<T>;
|
|
31
|
+
private _init;
|
|
32
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FileProvider } from "../file-provider/file-provider.js";
|
|
2
|
+
export interface XlsxWriterOptions {
|
|
3
|
+
target?: {
|
|
4
|
+
filePath?: string;
|
|
5
|
+
};
|
|
6
|
+
title?: string;
|
|
7
|
+
noHeader?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface XlsxCellFormat {
|
|
10
|
+
number?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* XlsxWriter writes rows of data to an XLSX file.
|
|
14
|
+
*/
|
|
15
|
+
export declare class XlsxWriter {
|
|
16
|
+
constructor(options: XlsxWriterOptions);
|
|
17
|
+
write(sheetName: string, row: {
|
|
18
|
+
[col: string]: any;
|
|
19
|
+
} | any[], formatter?: {
|
|
20
|
+
[col: string]: XlsxCellFormat;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
close(): Promise<FileProvider>;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function xmlParse(source: string): Promise<any>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FileProvider } from "../file-provider/file-provider.js";
|
|
2
|
+
import zlib from "zlib";
|
|
3
|
+
export declare function zipExtract(options: {
|
|
4
|
+
source: FileProvider;
|
|
5
|
+
targetDir?: string;
|
|
6
|
+
password?: string;
|
|
7
|
+
}): Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Compress a directory into a zip file
|
|
10
|
+
* @param options - The options to pass to the zipCompress function
|
|
11
|
+
* @returns The result as a FileProvider
|
|
12
|
+
*/
|
|
13
|
+
export declare function zipCompress(options: {
|
|
14
|
+
sourceDir: string;
|
|
15
|
+
}): Promise<FileProvider>;
|
|
16
|
+
/**
|
|
17
|
+
* Gzip the input and return the result as a base64 string
|
|
18
|
+
* @param input - The input to gzip
|
|
19
|
+
* @param options - The options to pass to the gzip function
|
|
20
|
+
* @returns The result as a base64 string
|
|
21
|
+
*/
|
|
22
|
+
export declare function gzipB64(input: unknown, options?: zlib.ZlibOptions): Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Gunzip the input and return the result as an JSON object
|
|
25
|
+
* @param input - The base64 encoded input to gunzip
|
|
26
|
+
* @param options - The options to pass to the gunzip function
|
|
27
|
+
* @returns The result as an JSON object
|
|
28
|
+
*/
|
|
29
|
+
export declare function gunzipB64(input: string, options?: zlib.ZlibOptions): Promise<unknown>;
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@syncmatters/script-api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript type definitions for the SyncMatters script API (types only - scripts execute on the SyncMatters platform)",
|
|
5
|
+
"types": "./index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"default": "./index.js"
|
|
10
|
+
},
|
|
11
|
+
"./sdk-test": {
|
|
12
|
+
"types": "./sdk-test.d.ts",
|
|
13
|
+
"default": "./index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "SyncMatters",
|
|
18
|
+
"homepage": "https://syncmatters.com",
|
|
19
|
+
"typesContentHash": "143c303baa596be30ce78a3af1e88dbcd485a63237e15a553bd0fe74ce495dc7",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@types/node": "*"
|
|
22
|
+
}
|
|
23
|
+
}
|