@syncmatters/script-api 1.0.23 → 1.0.24

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
@@ -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;
@@ -141,7 +141,7 @@ export interface CacheQueryOneOptions {
141
141
  name: string;
142
142
  values: string[];
143
143
  };
144
- key?: string;
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?: string;
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?: string;
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 = "unknown" | "jsonpath expression";
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<any>;
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
- /** parse engine to use (default: 'fast-csv') */
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 or, if the csv has a header, by header name:
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<any>;
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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncmatters/script-api",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
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": "a7752b94739b0e0e5ab5d1a50afa574d6ca86c42013470349f048ab296bc4103",
31
+ "typesContentHash": "f3ff131064f3d7de6653d9bb2a7766b1ea8e918cd38aacbf0f73e6b37dfe13f8",
32
32
  "dependencies": {
33
33
  "@types/node": "*"
34
34
  }