@syncmatters/script-api 1.0.46 → 1.0.47

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.46",
3
+ "version": "1.0.47",
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": "7daa6b9a71735cba7fac8b5a8bb29bde2b003fab23e29bee1b48bb244f552fb2",
31
+ "typesContentHash": "4f485525e7c4b00e1dd8f5a311a21818a14d533c9e8d0686a9e5c72866351c22",
32
32
  "dependencies": {
33
33
  "@types/node": "*"
34
34
  }
@@ -248,7 +248,8 @@ export interface ObjectFeatures {
248
248
  /**
249
249
  * The object's create-field form (upsertFieldsMeta), as generated from cached metadata. The fieldMetadata feature
250
250
  * checks the object's form against it, and flags a form the platform would drop (more than one key or name input,
251
- * or neither) and more than one field tagged isName. Fields are never created in the system under test.
251
+ * or neither) and more than one field tagged isName. Fields are created in the system under test only when `test`
252
+ * is set.
252
253
  */
253
254
  upsertFields?: {
254
255
  /** ids of the form's inputs, sorted */
@@ -261,10 +262,35 @@ export interface ObjectFeatures {
261
262
  nameInputId?: string;
262
263
  /** ids of the form's presets, sorted */
263
264
  presetIds?: string[];
265
+ /**
266
+ * Opt in to a live round trip, which changes the connected account's schema: the harness creates a field through
267
+ * Connection.upsertFields with `row`, checks the cached metadata has it, sends the same row again and expects a
268
+ * row error with code "already_exists", then deletes the field through Connection.deleteFields (when
269
+ * deleteFields.canDeleteFields is true) and checks it is gone. The results are the object's upsertFields and
270
+ * deleteFields features (ObjectTestResult.upsertFields / deleteFields). It runs when the run tests every feature,
271
+ * upsertFields or deleteFields; either value runs the whole round trip, since the delete needs the field the create
272
+ * made. Never generated: set it in the test module.
273
+ */
274
+ test?: {
275
+ /**
276
+ * The field to create, keyed by the form's input ids as an upsertFields row (a user key as
277
+ * `{ operation: "add", value }`, or as a plain string). The harness appends a per-run suffix to the key value
278
+ * and the name, within the inputs' regex and maxLen, so each run creates a new field. On a form whose key is
279
+ * assigned by the system the row must hold the name input and must not hold the key input.
280
+ */
281
+ row: API.UpsertFieldRow;
282
+ /**
283
+ * Create the field even though it cannot be deleted (deleteFields.canDeleteFields is not true, or the connection
284
+ * has no deleteFields for the object): each run leaves a field behind in the account, and the deleteFields
285
+ * feature reads Not tested naming it. Without this flag both features read Not tested and nothing is created.
286
+ */
287
+ leaveFieldBehind?: boolean;
288
+ };
264
289
  };
265
290
  /**
266
291
  * Field deletion, as generated from cached metadata. The fieldMetadata feature checks that the object's
267
- * canDeleteFields matches. Fields are never deleted in the system under test.
292
+ * canDeleteFields matches. Fields are deleted in the system under test only by the round trip that
293
+ * upsertFields.test opts in to, which deletes the field it created.
268
294
  */
269
295
  deleteFields?: {
270
296
  /** does the object declare canDeleteFields? */
@@ -272,7 +298,7 @@ export interface ObjectFeatures {
272
298
  };
273
299
  }
274
300
  /** List of features that can be tested for an object. */
275
- export type ObjectFeature = "all" | "list" | "idsFilter" | "fieldMetadata" | "checkpointFilter" | "relatedFilter" | "matchFilter" | "upsert" | "upsertClean" | "delete" | "rowFilter";
301
+ export type ObjectFeature = "all" | "list" | "idsFilter" | "fieldMetadata" | "checkpointFilter" | "relatedFilter" | "matchFilter" | "upsert" | "upsertClean" | "delete" | "rowFilter" | "upsertFields" | "deleteFields";
276
302
  export interface BeforeOptions {
277
303
  /** Connection that will be used to test the connector logic, as selected by the user. */
278
304
  connection: unknown;
@@ -339,11 +365,28 @@ export interface ObjectTestResult {
339
365
  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";
340
366
  rowFilterNotTestedReason?: string;
341
367
  rowFilterFatalError?: CaughtError;
368
+ /**
369
+ * The upsertFields round trip (ObjectFeatures.upsertFields.test): a test field is created, found in the cached
370
+ * metadata, and a repeated add of it is refused with "already_exists". The first step that fails decides the
371
+ * status; the "Repeated add" statuses name the repeated add. Absent when the spec does not opt in or the run does not
372
+ * select the feature. The error behind a failure is in upsertFieldsFatalError.
373
+ */
374
+ upsertFields?: "Passed" | "Not tested" | "Failed: upsertFields not available on the connection" | "Failed: Test row invalid" | "Failed: Fatal error during testing" | "Failed: Create returned an error" | "Failed: No id returned for the created field" | "Failed: Field not in cached metadata after create" | "Failed: Repeated add threw an error" | "Failed: Repeated add was not refused" | "Failed: Repeated add was not refused with already_exists";
375
+ upsertFieldsNotTestedReason?: string;
376
+ upsertFieldsFatalError?: CaughtError;
377
+ /**
378
+ * The delete half of the round trip: the fields the upsertFields test created are deleted and are gone from the
379
+ * cached metadata. Present exactly when upsertFields is. Not tested when no field was created, or when the object
380
+ * cannot delete fields and the spec set leaveFieldBehind (the reason names the field left behind).
381
+ */
382
+ deleteFields?: "Passed" | "Not tested" | "Failed: Fatal error during testing" | "Failed: Delete returned an error" | "Failed: Field still in cached metadata after delete";
383
+ deleteFieldsNotTestedReason?: string;
384
+ deleteFieldsFatalError?: CaughtError;
342
385
  /** Custom checks with this objectId, in declaration order. */
343
386
  customChecks?: CustomCheckResult[];
344
387
  /**
345
388
  * Diagnostic details keyed by feature (list, idsFilter, checkpointFilter, rowFilter, upsert, upsertClean, delete,
346
- * fieldMetadata) and check:<id>.
389
+ * fieldMetadata, upsertFields, deleteFields) and check:<id>.
347
390
  */
348
391
  details?: {
349
392
  [feature: string]: TestDetail[];