@syncmatters/script-api 1.0.44 → 1.0.46

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.
@@ -413,8 +413,10 @@ export interface ObjectMeta {
413
413
  export type UpsertFieldOperation = "add" | "update";
414
414
  /**
415
415
  * UpsertFieldsMeta describes an object's create-field form. A form has at most one key input (flagged `isUserKey` or
416
- * `isKey`, never both), at most one name input (flagged `isName`), and at least one of the two; the platform drops
417
- * a form that breaks this rule.
416
+ * `isKey`, never both), at most one name input (flagged `isName`), and at least one of the two. An input's
417
+ * `generateFromSetting` and `generateFromMode` are set together, name another input of the form and a known mode. A
418
+ * copy preset's `values` is an object whose ids are all inputs of the form, and its `matchType`, when set, is a known
419
+ * type. The platform drops a form that breaks these rules.
418
420
  */
419
421
  export interface UpsertFieldsMeta {
420
422
  /** the operations the connector accepts (default ["add"]); a row whose operation is not listed is refused */
@@ -423,6 +425,12 @@ export interface UpsertFieldsMeta {
423
425
  fields: Record<string, UpsertFieldInputMeta>;
424
426
  /** prefilled rows offered to the user; `external_id` is the well-known one ("Id of the <other system> record") */
425
427
  presets?: UpsertFieldPreset[];
428
+ /**
429
+ * how a field copied from another field (a source field on the mapping screen) is prefilled: the first entry whose
430
+ * conditions all hold is used. List the `matchPortableType` entries first, then the entries for any source system;
431
+ * an entry with no condition, last, is the catch-all.
432
+ */
433
+ copyPresets?: UpsertFieldCopyPreset[];
426
434
  }
427
435
  /** UpsertFieldInputMeta is one input of a create-field form: a form input plus what the platform reads it for */
428
436
  export interface UpsertFieldInputMeta extends FormInput {
@@ -442,6 +450,28 @@ export interface UpsertFieldPreset {
442
450
  /** input values, keyed by input id */
443
451
  values: Record<string, unknown>;
444
452
  }
453
+ /**
454
+ * UpsertFieldCopyPreset is one rule of {@link UpsertFieldsMeta.copyPresets}: conditions on the copied field and the
455
+ * form values to start from. An absent condition is not tested; an entry with none matches every field.
456
+ */
457
+ export interface UpsertFieldCopyPreset {
458
+ /**
459
+ * the copied field's `portableType`. Holds only when the copied field comes from the same connector (or a child of
460
+ * the same parent): the string means nothing to another connector, and a field without `portableType` never matches.
461
+ */
462
+ matchPortableType?: string;
463
+ /**
464
+ * what the copied field holds, derived by the platform: a string with date/time constraints is "date" or "datetime"
465
+ * (`dateOnly` decides which), and an array is read by its element type with `matchMultiple`
466
+ */
467
+ matchType?: "string" | "number" | "boolean" | "date" | "datetime";
468
+ /** the copied field has option values (false: it has none) */
469
+ matchHasOptions?: boolean;
470
+ /** the copied field holds several values, an array (false: a single value) */
471
+ matchMultiple?: boolean;
472
+ /** input values, keyed by input id, as a preset's; every id must be an input of the form */
473
+ values: Record<string, unknown>;
474
+ }
445
475
  /**
446
476
  * UpsertFieldRow creates or changes one field. It is keyed by input id, as a data upsert row is keyed by field id:
447
477
  * - with an `isUserKey` input, that input holds `{ operation: "add" | "update", value }`;
@@ -536,6 +566,17 @@ export interface FormInput {
536
566
  displayIf?: "none" | "other_setting_has_value" | "other_setting_is_not_empty";
537
567
  displayIfSetting?: string;
538
568
  displayIfValues?: string[];
569
+ /**
570
+ * id of another input of the same form: the UI fills this input from that input's value while the
571
+ * user has not typed in this one. The input's own constraints still validate the result. Set
572
+ * together with generateFromMode.
573
+ */
574
+ generateFromSetting?: string;
575
+ /**
576
+ * how the value is derived from generateFromSetting's value: "snake_lower" lower-cases, strips
577
+ * accents and turns each run of other characters than letters and digits into one underscore
578
+ */
579
+ generateFromMode?: "snake_lower";
539
580
  type?: "string" | "boolean" | "number" | "string_array" | "connection_uid_template" | "google_picker" | "option_array";
540
581
  control?: "singlelinetext" | "textarea" | "checkbox" | "switch" | "integer" | "url" | "datepicker" | "datetimepicker" | "filepicker" | "drivefolder" | "drivefile" | "select" | "multiselect" | "button" | "timezone";
541
582
  options?: FormInputOption[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncmatters/script-api",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
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": "04475e4db60ca81efd87b1fa09a55709be88d008d8b1c1a18687fdefd7b84ee7",
31
+ "typesContentHash": "7daa6b9a71735cba7fac8b5a8bb29bde2b003fab23e29bee1b48bb244f552fb2",
32
32
  "dependencies": {
33
33
  "@types/node": "*"
34
34
  }