@syncmatters/script-api 1.0.14 → 1.0.16

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.
@@ -17,6 +17,9 @@ export interface Connection {
17
17
  events: {
18
18
  [id: string]: () => Promise<EventTypeMeta>;
19
19
  };
20
+ discovery?(): Promise<DiscoverResult | undefined>;
21
+ /** Metadata refresh and discovery times recorded as connection state (`{ objects: {} }` when none recorded). */
22
+ readonly state: MetaState;
20
23
  };
21
24
  query: {
22
25
  [id: string]: (options?: QueryOptions) => QueryIterator<Row>;
@@ -33,12 +36,22 @@ export interface Connection {
33
36
  delete?: {
34
37
  [id: string]: (rows: any[]) => Promise<void>;
35
38
  };
36
- /** Id's of all objects found on this connection. */
39
+ /** Id's of all objects collected on this connection. */
37
40
  objectIds: string[];
38
41
  /** Connect to the source, validating credentials etc ... */
39
42
  test(): Promise<TestResult>;
40
- /** Retrieves the latest meta data (identity, object, field definitions, event types) from the connector. */
41
- metaRefresh?(): Promise<void>;
43
+ /**
44
+ * Collects the catalogue of objects present in the system, without field detail, can also return setting defaults and caches the result. Does not change the
45
+ * selection or any setting. Present only when the connector implements discover().
46
+ */
47
+ discover?(): Promise<DiscoverResult>;
48
+ /**
49
+ * Retrieves the latest meta data (identity, object, field definitions, event types) from the connector.
50
+ * @param options.objectIds [optional] refresh only these objects.
51
+ */
52
+ metaRefresh?(options?: {
53
+ objectIds?: string[];
54
+ }): Promise<void>;
42
55
  /**
43
56
  * Creates/updates the meta data model of a connection. This method is only applicable to connectors with
44
57
  * data models that are managed by platform or user logic rather than through interrogation of the source application.
@@ -205,7 +218,7 @@ export interface QueryOptions {
205
218
  /** @deprecated (use standard fields filter) system specific property filters; allowed values are defined in meta.queryFilter.propertyFilter */
206
219
  propertyFilter?: any;
207
220
  }
208
- export type RowMatchRuleType = "id" /** match by source row id (key) */ | "name[ci]" /** match by destination row name (case senstive) */ | "email[ci]" /** match by destination row email (case insenstive) */ | "domain[ci]" /** match by destination domain (case insenstive) */ | "first_and_last_name[ci]" /** match by destination first and last name (case insenstive) */ | "field_value_equals[ci]"; /** match by value in user selected field (case insenstive) */
221
+ export type RowMatchRuleType = "id" /** match by source row id (key) */ | "name[ci]" /** match by destination row name (case insensitive) */ | "email[ci]" /** match by destination row email (case insensitive) */ | "domain[ci]" /** match by destination domain (case insensitive) */ | "first_and_last_name[ci]" /** match by destination first and last name (case insensitive) */ | "field_value_equals[ci]" /** match by value in user selected field (case insensitive) */ | "field_values_equal[ci]"; /** match by 1-5 user selected source/destination field pairs, all must be equal (case insensitive) */
209
222
  export type RowMatchRuleOrder = "oldest" | "newest" | "alphabetical";
210
223
  /** source row data used by the destination connector when matching a source row to a destination row */
211
224
  export interface RowMatchData {
@@ -227,6 +240,11 @@ export interface RowMatchData {
227
240
  lastname?: string;
228
241
  /** custom value to match */
229
242
  custom?: string | number;
243
+ /**
244
+ * field_values_equal[ci]: values to match, index-aligned with QueryMatchFilter.destFieldPaths. A blank ("") value
245
+ * means the destination field must be empty/absent - filter for "empty", never drop the filter.
246
+ */
247
+ customs?: Array<string | number>;
230
248
  };
231
249
  }
232
250
  /** unique ids (property names) used in the row match data passed to the destination when a match is saught */
@@ -300,6 +318,11 @@ export interface QueryMatchFilter {
300
318
  selectOrder?: RowMatchRuleOrder;
301
319
  /** if the rule references a field in the destination row the path to the destination field will be specified here (e.g. match value in a specific field) */
302
320
  destFieldPath?: Array<API.JsonValuePathPart>;
321
+ /**
322
+ * field_values_equal[ci]: paths to the destination fields to compare, index-aligned with RowMatchData.match.customs;
323
+ * a destination row matches when every pair is equal
324
+ */
325
+ destFieldPaths?: Array<Array<API.JsonValuePathPart>>;
303
326
  /** data to match */
304
327
  srcData: Array<RowMatchData>;
305
328
  /**
@@ -360,6 +383,48 @@ export interface ObjectMeta {
360
383
  systemIndexes?: ObjectIndex[];
361
384
  /** relationships that may be used to find rows of this object that relate to other objects */
362
385
  relationships?: ObjectRelationship[];
386
+ /** should the object be selected for inclusion on a new connection? */
387
+ default?: boolean;
388
+ /** set by meta() when a selected object can no longer be described (e.g. deleted); the platform keeps the cached copy */
389
+ unavailable?: ObjectUnavailableReason;
390
+ }
391
+ /**
392
+ * ObjectUnavailableReason describes why a selected object could not be returned in hte meta refresh response: "deleted" (gone
393
+ * from the system) or "unauthorized" (the API user may no longer read it).
394
+ */
395
+ export type ObjectUnavailableReason = "deleted" | "unauthorized";
396
+ /** DiscoveredObject is a catalogue object returned by discover(): a subset of {@link ObjectMeta}, same ids and meanings. */
397
+ export type DiscoveredObject = Pick<ObjectMeta, "id" | "name" | "order" | "isCustom" | "data" | "default">;
398
+ /** DiscoverResult is returned by the connector's discover() and cached on the connection. */
399
+ export interface DiscoverResult {
400
+ /**
401
+ * Recommended per-setting default values, probed by the connector, only applied if the user has not set a value.
402
+ */
403
+ settingsMeta?: Record<string, Partial<ObjectSettingMeta>>;
404
+ /** every object the connector could describe, without field detail */
405
+ objects: DiscoveredObject[];
406
+ /** connector-private; echoed back as MetaOptions.discovery.data */
407
+ data?: unknown;
408
+ }
409
+ /** MetaStateObject holds the refresh state of one selected object. */
410
+ export interface MetaStateObject {
411
+ /** ISO time the object's metadata was last refreshed */
412
+ lastRefresh: string;
413
+ /** set when the last refresh reported the object as unavailable */
414
+ unavailable?: ObjectUnavailableReason;
415
+ }
416
+ /** MetaState holds metadata refresh and discovery times, recorded as connection state rather than configuration. */
417
+ export interface MetaState {
418
+ /** ISO time discover() last succeeded */
419
+ lastDiscovery?: string;
420
+ /** ISO time of the last successful meta() covering the all selected objects */
421
+ lastRefresh?: string;
422
+ /** an 'affectsMeta' or 'prerequisite' setting changed since lastRefresh */
423
+ metaStale?: boolean;
424
+ /** a prerequisite setting changed after lastDiscovery */
425
+ discoveryStale?: boolean;
426
+ /** refresh state per selected object */
427
+ objects: Record<string, MetaStateObject>;
363
428
  }
364
429
  /** ObjectSettingMeta holds metadata describing a setting */
365
430
  export interface ObjectSettingMeta {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncmatters/script-api",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
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": "1908da7a9d689fba3b76a80a652493ef9028ab6cebb2e1c08db9f2cc3cb9ffa5",
31
+ "typesContentHash": "ded988637cd580ceb7908990a4b80426f350619a0a067f24f49b9ccf3fc51967",
32
32
  "dependencies": {
33
33
  "@types/node": "*"
34
34
  }
@@ -354,6 +354,8 @@ export interface MatchData {
354
354
  srcData: API.RowMatchData[];
355
355
  /** path to the field on the dest row that holds the field to match with, if applicable to the rule */
356
356
  destFieldPath?: API.JsonValuePath;
357
+ /** field_values_equal[ci]: paths to the dest row fields to match with, index-aligned with srcData[].match.customs */
358
+ destFieldPaths?: API.JsonValuePath[];
357
359
  /** ids of dest rows expected back in response to the match query */
358
360
  expectedMatchRowIds: string[];
359
361
  /** optionally specify the fields to include in the match query */