@syncmatters/script-api 1.0.20 → 1.0.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncmatters/script-api",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
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": "6f0e7724c2cff15e666109cc05b76419887b64ffa0310e9ec23fe2b585a323e5",
31
+ "typesContentHash": "3dcf1af8c79b37f9fe75992f52dbbdc70d0f22515d9f65b1123ceb7e4f31de20",
32
32
  "dependencies": {
33
33
  "@types/node": "*"
34
34
  }
@@ -54,7 +54,8 @@ export interface TestFeatureProvider {
54
54
  /**
55
55
  * Prepare data that can be used to test a queries with 'rowFilters'; you may either create new test data, or search/find
56
56
  * data that can be used to test the various row filters. Include one test of of test data for each row filter. Returning
57
- * undefined indicates that row filters cannot be tested.
57
+ * undefined indicates that row filters cannot be tested (the rowFilter feature then reads Not tested, which does not
58
+ * make the object Partial: row filters have no ObjectFeatures flag to opt in with).
58
59
  */
59
60
  rowFiltersPrepare?(options: RowFiltersOptions): Promise<Array<RowFilterData> | undefined>;
60
61
  /** Delete test data created for use by a test. */
@@ -68,10 +69,52 @@ export interface TestFeatureProvider {
68
69
  upsertPrepare?(options: UpsertOptions): Promise<UpsertData | undefined>;
69
70
  /** Delete test data created for use by a test. */
70
71
  upsertCleanup?(options: UpsertCleanupOptions): Promise<void>;
72
+ /**
73
+ * Named checks that are not shaped like an object feature (a free statement, connection churn, a connection-level
74
+ * timeout). They run after the feature tests, in declaration order, each with its own status, duration and details.
75
+ * An escape hatch: a check that recurs across connectors belongs in the harness as a feature.
76
+ */
77
+ customChecks?(): Promise<CustomCheck[]>;
71
78
  /** Optional teardown function to run after all tests have completed. Can perform any required teardown, such as deleting test
72
79
  * data. */
73
80
  after?(): Promise<void>;
74
81
  }
82
+ /** One named check run by the harness after the feature tests (TestFeatureProvider.customChecks()). */
83
+ export interface CustomCheck {
84
+ /** stable id: keys the check's result and details (details["check:<id>"]) and is what --check names */
85
+ id: string;
86
+ /** display name for results */
87
+ name: string;
88
+ /**
89
+ * The object the check exercises. Gated like a feature: when the object is not on the connection (not selected on a
90
+ * two-phase connection, or not returned by meta()) the check reads Not tested with the reason, and its result is
91
+ * reported under that object. A check without one is connection-level and always runs.
92
+ */
93
+ objectId?: string;
94
+ /** default 60 000; capped at the run's remaining budget when the run has one */
95
+ timeoutMs?: number;
96
+ /** throw to fail; ctx.record(message, data) adds details. A check past its timeout fails and the suite carries on. */
97
+ run(ctx: CustomCheckContext): Promise<void>;
98
+ }
99
+ /** What a custom check runs with. */
100
+ export interface CustomCheckContext {
101
+ /** the connection under test, as before() receives it */
102
+ connection: unknown;
103
+ /** metadata of the check's object, when it has one */
104
+ meta?: API.ObjectMeta;
105
+ log: API.Logger;
106
+ /** record a detail on the check's result (logged too), under the same size caps as every feature's details */
107
+ record(message: string, data?: unknown): void;
108
+ }
109
+ /** Result of one custom check. Its details are in the owning result's details under "check:<id>". */
110
+ export interface CustomCheckResult {
111
+ id: string;
112
+ name: string;
113
+ status: "Passed" | "Not tested" | `Failed: ${string}`;
114
+ notTestedReason?: string;
115
+ durationMs: number;
116
+ fatalError?: CaughtError;
117
+ }
75
118
  /** Specification of features that are supported by an object; much of this is auto generated however particular
76
119
  * features may be further refined/specified by the test harness.
77
120
  */
@@ -219,10 +262,12 @@ export interface ConnectorTestResult {
219
262
  testConnection?: "Passed" | "Not tested" | "Failed: Fatal error during testing" | "Failed: Test connection response did not report success";
220
263
  objectsStatus?: "Passed" | "Partial: Only selected objects tested" | "Partial: Only selected objects tested, not all features can be tested" | "Partial: Only selected object tests run" | "Partial: Only selected objects tested, only selected object tests run" | "Partial: Not all features/objects can be tested" | "Not tested" | "Failed: Fatal error during testing" | "Failed: One or more objects failed tests";
221
264
  objects: ObjectTestResult[];
222
- /** Diagnostic details for connection-level stages, keyed by stage (testConnection, metaRefresh). */
265
+ /** Diagnostic details for connection-level stages, keyed by stage (testConnection, metaRefresh) and check:<id>. */
223
266
  details?: {
224
267
  [stage: string]: TestDetail[];
225
268
  };
269
+ /** Connection-level custom checks (no objectId), in declaration order. */
270
+ customChecks?: CustomCheckResult[];
226
271
  }
227
272
  export interface ObjectTestResult {
228
273
  objectId: string;
@@ -266,7 +311,15 @@ export interface ObjectTestResult {
266
311
  deleteFatalError?: CaughtError;
267
312
  fieldMetadata?: "Passed" | "Not tested" | "Failed: One or more fields have metadata issues";
268
313
  fieldMetadataIssues: FieldMetadataIssue[];
269
- /** Diagnostic details keyed by feature (list, idsFilter, checkpointFilter, upsert, upsertClean, delete, fieldMetadata). */
314
+ rowFilter?: "Passed" | "Not tested" | "Not supported" | "Failed: Fatal error during testing" | "Failed: Test data invalid, no expected row ids" | "Failed: Row not returned" | "Failed: Returned unexpected row" | "Failed: Expected values did not match" | "Failed: Expected error did not occur";
315
+ rowFilterNotTestedReason?: string;
316
+ rowFilterFatalError?: CaughtError;
317
+ /** Custom checks with this objectId, in declaration order. */
318
+ customChecks?: CustomCheckResult[];
319
+ /**
320
+ * Diagnostic details keyed by feature (list, idsFilter, checkpointFilter, rowFilter, upsert, upsertClean, delete,
321
+ * fieldMetadata) and check:<id>.
322
+ */
270
323
  details?: {
271
324
  [feature: string]: TestDetail[];
272
325
  };
@@ -503,7 +556,10 @@ export interface RowFilterData {
503
556
  expectedRowIds: string[];
504
557
  /** optionally specify the fields to include in the rowFilter query */
505
558
  fields?: Array<API.JsonValuePath>;
506
- /** declared for uniformity with the other features; the harness does not run row filters yet, so it is not evaluated */
559
+ /**
560
+ * The row-filter query must fail (error; e.g. a timeout forced with requestTimeoutOverride), or the rows it returns
561
+ * must hold these values (rows). With error set, expectedRowIds may be empty.
562
+ */
507
563
  expect?: Expect;
508
564
  }
509
565
  /**