@syncmatters/script-api 1.0.15 → 1.0.17
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/lib/connection.d.ts +57 -3
- package/package.json +2 -2
package/lib/connection.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export interface Connection {
|
|
|
17
17
|
events: {
|
|
18
18
|
[id: string]: () => Promise<EventTypeMeta>;
|
|
19
19
|
};
|
|
20
|
+
discovery?(): Promise<DiscoverResult | undefined>;
|
|
21
|
+
state(): Promise<MetaState>;
|
|
20
22
|
};
|
|
21
23
|
query: {
|
|
22
24
|
[id: string]: (options?: QueryOptions) => QueryIterator<Row>;
|
|
@@ -33,12 +35,22 @@ export interface Connection {
|
|
|
33
35
|
delete?: {
|
|
34
36
|
[id: string]: (rows: any[]) => Promise<void>;
|
|
35
37
|
};
|
|
36
|
-
/** Id's of all objects
|
|
38
|
+
/** Id's of all objects collected on this connection. */
|
|
37
39
|
objectIds: string[];
|
|
38
40
|
/** Connect to the source, validating credentials etc ... */
|
|
39
41
|
test(): Promise<TestResult>;
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
+
/**
|
|
43
|
+
* 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
|
|
44
|
+
* selection or any setting. Present only when the connector implements discover().
|
|
45
|
+
*/
|
|
46
|
+
discover?(): Promise<DiscoverResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the latest meta data (identity, object, field definitions, event types) from the connector.
|
|
49
|
+
* @param options.objectIds [optional] refresh only these objects.
|
|
50
|
+
*/
|
|
51
|
+
metaRefresh?(options?: {
|
|
52
|
+
objectIds?: string[];
|
|
53
|
+
}): Promise<void>;
|
|
42
54
|
/**
|
|
43
55
|
* Creates/updates the meta data model of a connection. This method is only applicable to connectors with
|
|
44
56
|
* data models that are managed by platform or user logic rather than through interrogation of the source application.
|
|
@@ -370,6 +382,48 @@ export interface ObjectMeta {
|
|
|
370
382
|
systemIndexes?: ObjectIndex[];
|
|
371
383
|
/** relationships that may be used to find rows of this object that relate to other objects */
|
|
372
384
|
relationships?: ObjectRelationship[];
|
|
385
|
+
/** should the object be selected for inclusion on a new connection? */
|
|
386
|
+
default?: boolean;
|
|
387
|
+
/** set by meta() when a selected object can no longer be described (e.g. deleted); the platform keeps the cached copy */
|
|
388
|
+
unavailable?: ObjectUnavailableReason;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* ObjectUnavailableReason describes why a selected object could not be returned in hte meta refresh response: "deleted" (gone
|
|
392
|
+
* from the system) or "unauthorized" (the API user may no longer read it).
|
|
393
|
+
*/
|
|
394
|
+
export type ObjectUnavailableReason = "deleted" | "unauthorized";
|
|
395
|
+
/** DiscoveredObject is a catalogue object returned by discover(): a subset of {@link ObjectMeta}, same ids and meanings. */
|
|
396
|
+
export type DiscoveredObject = Pick<ObjectMeta, "id" | "name" | "order" | "isCustom" | "data" | "default">;
|
|
397
|
+
/** DiscoverResult is returned by the connector's discover() and cached on the connection. */
|
|
398
|
+
export interface DiscoverResult {
|
|
399
|
+
/**
|
|
400
|
+
* Recommended per-setting default values, probed by the connector, only applied if the user has not set a value.
|
|
401
|
+
*/
|
|
402
|
+
settingsMeta?: Record<string, Partial<ObjectSettingMeta>>;
|
|
403
|
+
/** every object the connector could describe, without field detail */
|
|
404
|
+
objects: DiscoveredObject[];
|
|
405
|
+
/** connector-private; returned to the connector by MetaOptions.discovery() */
|
|
406
|
+
data?: unknown;
|
|
407
|
+
}
|
|
408
|
+
/** MetaStateObject holds the refresh state of one selected object. */
|
|
409
|
+
export interface MetaStateObject {
|
|
410
|
+
/** ISO time the object's metadata was last refreshed */
|
|
411
|
+
lastRefresh: string;
|
|
412
|
+
/** set when the last refresh reported the object as unavailable */
|
|
413
|
+
unavailable?: ObjectUnavailableReason;
|
|
414
|
+
}
|
|
415
|
+
/** MetaState holds metadata refresh and discovery times, recorded as connection state rather than configuration. */
|
|
416
|
+
export interface MetaState {
|
|
417
|
+
/** ISO time discover() last succeeded */
|
|
418
|
+
lastDiscovery?: string;
|
|
419
|
+
/** ISO time of the last successful meta() covering the all selected objects */
|
|
420
|
+
lastRefresh?: string;
|
|
421
|
+
/** an 'affectsMeta' or 'prerequisite' setting changed since lastRefresh */
|
|
422
|
+
metaStale?: boolean;
|
|
423
|
+
/** a prerequisite setting changed after lastDiscovery */
|
|
424
|
+
discoveryStale?: boolean;
|
|
425
|
+
/** refresh state per selected object */
|
|
426
|
+
objects: Record<string, MetaStateObject>;
|
|
373
427
|
}
|
|
374
428
|
/** ObjectSettingMeta holds metadata describing a setting */
|
|
375
429
|
export interface ObjectSettingMeta {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncmatters/script-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
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": "216ea92ae7a4c49117873ee8ec8f0fe5e77a62b371bc8ccc2a8f93833d9a9440",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@types/node": "*"
|
|
34
34
|
}
|