@syncmatters/script-api 1.0.15 → 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.
@@ -370,6 +383,48 @@ export interface ObjectMeta {
370
383
  systemIndexes?: ObjectIndex[];
371
384
  /** relationships that may be used to find rows of this object that relate to other objects */
372
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>;
373
428
  }
374
429
  /** ObjectSettingMeta holds metadata describing a setting */
375
430
  export interface ObjectSettingMeta {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncmatters/script-api",
3
- "version": "1.0.15",
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": "ad2f1f5cd5868f2362746920bfba5713dcf146857db7641a69ed90c72e101dff",
31
+ "typesContentHash": "ded988637cd580ceb7908990a4b80426f350619a0a067f24f49b9ccf3fc51967",
32
32
  "dependencies": {
33
33
  "@types/node": "*"
34
34
  }