@syncmatters/connector-sdk 1.0.40 → 1.0.42

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.
@@ -128,6 +128,7 @@ always stored, they were simply never written down here:
128
128
  | `group_id` | renders the setting inside a named group |
129
129
  | `mandatory: true` | the form blocks save until the setting has a value |
130
130
  | `display_if` / `display_if_setting` / `display_if_values` | conditional rendering (`displayIfHasValue` is the deprecated spelling, still accepted) |
131
+ | `generate_from_setting` / `generate_from_mode` | the UI fills this setting from another setting's value while the user has not typed in it; `generate_from_setting` is the other setting's id and `generate_from_mode` how the value is derived (`snake_lower`: lower-cased, accents stripped, each run of other characters than letters and digits one underscore). Set both or neither; the setting's own constraints still validate the result |
131
132
  | `prerequisite: true` | two-phase connectors only — see below |
132
133
  | `affects_meta: true` | `meta()` reads this setting (a scope, a checkpoint column, an API version), so changing its value marks the connection's cached metadata stale until the next full refresh. Independent of `discovery`; implied by `prerequisite`; no effect on a `metaRefreshDisabled` connector |
133
134
  | `connector_managed: true` | the value belongs to the connector, not the connection: the setting's `default` is evaluated on every read and never stored on a connection, and it wins over a value a connection stored before the flag was set (a hidden setting with a `default` is per-connection instead: snapshotted once at creation). Implies `readonly` (the server sets it on save); `hidden` is independent; `mandatory` means a default must exist to publish. Cannot be combined with `defines_version`, `prerequisite` or `staticonly` |
@@ -349,8 +349,9 @@ Declaring it on the wrong object doesn't fail here — it fails later, when
349
349
  An object may describe a form for creating a field on it in the connected system
350
350
  (`upsertFieldsMeta`). Users reach it from the mapping screen ("Create field"), and templates and
351
351
  installs use it to create the fields they map to. The form's presence on an object is the
352
- capability. An object may also allow its fields to be deleted (`canDeleteFields: true`); scripts and
353
- the connector test harness use that, the UI does not.
352
+ capability. An object may also allow its fields to be deleted (`canDeleteFields: true`); only
353
+ scripts call `deleteFields`: the UI does not, and the connector test harness checks only that
354
+ `canDeleteFields` matches the test spec.
354
355
 
355
356
  Scripts call them per object, like the data operations:
356
357
 
@@ -380,7 +381,8 @@ internal routine between the two methods.
380
381
  upsertFieldsMeta: {
381
382
  operations: ["add"], // what upsertFields() accepts; default ["add"]. Listing "update" is deliberate
382
383
  fields: { // form inputs, keyed by input id; a row uses the same ids
383
- name: { name: "Internal name", type: "string", isUserKey: true, mandatory: true, constraints: { regex: "^[a-z][a-z0-9_]*$" } },
384
+ name: { name: "Internal name", type: "string", isUserKey: true, mandatory: true, constraints: { regex: "^[a-z][a-z0-9_]*$" },
385
+ generateFromSetting: "label", generateFromMode: "snake_lower" },
384
386
  label: { name: "Label", type: "string", isName: true, mandatory: true },
385
387
  fieldType: { name: "Field type", type: "string", control: "select", mandatory: true,
386
388
  options: [{ id: "text", name: "Single-line text" }, { id: "select", name: "Dropdown select" }] },
@@ -405,16 +407,60 @@ upsertFieldsMeta: {
405
407
  - `isName`: holds the field's display text.
406
408
 
407
409
  A form has at most one key input (`isUserKey` or `isKey`, never both), at most one name input,
408
- and at least one of the two. The platform drops a form that breaks this rule, or has an input
409
- without a `type`, and logs why; the connector test harness flags it.
410
+ and at least one of the two. The platform drops a form that breaks this rule, has an input
411
+ without a `type`, or has an unusable `generateFromSetting` / `generateFromMode` or copy preset
412
+ (below), and logs why; the connector test harness flags it.
410
413
 
411
414
  - **`option_array`** holds a picklist's options as `[{ id?, name }]`, in option order. An omitted
412
415
  `id` means the name: apply that when you create the options. Set `userOptionIds: true` only where
413
416
  the system lets the creator choose option ids; without it a row that sends an `id` is refused.
414
417
  - **`displayIf`** hides inputs that do not apply (options for a text field). A hidden input is not
415
418
  sent, and a hidden mandatory input does not block.
419
+ - **`generateFromSetting` / `generateFromMode`** let the UI fill an input from another input while
420
+ the user has not typed in it, such as an internal name from the label. `generateFromSetting` is
421
+ the other input's id; `generateFromMode` is how the value is derived (`"snake_lower"`: lower-cased,
422
+ accents stripped, each run of other characters than letters and digits one underscore). The
423
+ input's own `constraints` still validate the result. Set both or neither, name another input of
424
+ the same form (not the input itself), and use a known mode; any form input (object or connection
425
+ setting) may carry them, and on a create-field form anything else drops the form.
416
426
  - **Presets** are prefilled rows. `external_id` is the well-known one: the UI offers it as "Id of
417
427
  the <other system> record".
428
+ - **Copy presets** (`copyPresets`) prefill a new field from the field being copied, such as when a
429
+ user creates several destination fields from source fields on the mapping screen. Each entry is
430
+ a set of conditions on the copied field plus the form `values` to start from:
431
+
432
+ ```js
433
+ upsertFieldsMeta: {
434
+ // ... operations, fields, presets as above
435
+ copyPresets: [
436
+ { matchPortableType: "picklist:multi", values: { fieldType: "multiselect" } },
437
+ { matchType: "boolean", values: { fieldType: "checkbox" } },
438
+ { matchType: "string", matchHasOptions: true, matchMultiple: true, values: { fieldType: "multiselect" } },
439
+ { matchType: "string", matchHasOptions: true, values: { fieldType: "select" } },
440
+ { matchType: "date", values: { fieldType: "date" } },
441
+ { matchType: "datetime", values: { fieldType: "datetime" } },
442
+ { matchType: "number", values: { fieldType: "number" } },
443
+ { values: { fieldType: "text" } }, // catch-all, last
444
+ ],
445
+ }
446
+ ```
447
+
448
+ - **First match wins**: the UI uses the first entry whose conditions all hold. An absent
449
+ condition is not tested, so an entry with none matches every field: put one last as the
450
+ catch-all.
451
+ - **`matchPortableType`** compares the copied field's `portableType`, and holds only when the
452
+ copied field comes from the same connector or a child of the same parent: the string means
453
+ nothing to another connector, and a field without `portableType` never matches. List these
454
+ entries first.
455
+ - **`matchType`** is derived by the platform from the copied field, since field meta has no date
456
+ type: `"string"`, `"number"`, `"boolean"`, or `"date"` / `"datetime"` for a string with
457
+ date/time constraints (`dateOnly` decides which). An array is read by its element type, with
458
+ `matchMultiple: true`.
459
+ - **`matchHasOptions`** / **`matchMultiple`**: the copied field has option values / holds an
460
+ array. `false` is a condition too (no options, a single value).
461
+ - Every id in `values` must be an input of the form, and `matchType` a known type, or the platform
462
+ drops the form.
463
+
418
464
  - **Advertise the form only where the connection may use it.** Set `upsertFieldsMeta` (and
419
465
  `canDeleteFields`) on an object only when your connector implements `upsertFields()` (and
420
466
  `deleteFields()`) and the connection's grant lets it change that object's fields, as you would hide
package/module.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * SDK specific elements that would be of no interest to users of the API.
4
4
  */
5
5
  export { EventScriptComplete, defaultRedactKeys } from "@syncmatters/script-api";
6
- export type { Cache, FileProvider, HttpRequest, HttpClientOptions, Redactor, RedactorOptions, KvCollection, KvIterator, Logger, EventContext, TestResult, Row, ObjectMeta, ObjectField, ObjectFieldOption, RateLimiterOptions, ScriptType, JsonValuePath, JsonValuePathPart, QueryMatchFilter, QueryCheckpointFilter, EventTypeMeta, ObjectIndex, ObjectMetaUpsert, ObjectRowFilter, ObjectRelationship, ObjectFieldConstraints, FormInput, FormInputOption, ObjectSettingMeta, UpsertFieldsMeta, UpsertFieldInputMeta, UpsertFieldOperation, UpsertFieldPreset, UpsertFieldRow, UpsertFieldOption, UpsertFieldResult, DeleteFieldRow, DeleteFieldResult, ObjectUnavailableReason, DiscoverResult, DiscoveredObject, MetaState, MetaStateObject, UpsertIssue, UpsertFieldOptionMeta, RowMatchRuleType, ObjectSemanticType, RowMatchData, RowMatchRuleOrder, SyncSession, SyncOptimalBatchSizeOperation, SyncOptimalBatchSizeBatchType, } from "@syncmatters/script-api";
6
+ export type { Cache, FileProvider, HttpRequest, HttpClientOptions, Redactor, RedactorOptions, KvCollection, KvIterator, Logger, EventContext, TestResult, Row, ObjectMeta, ObjectField, ObjectFieldOption, RateLimiterOptions, ScriptType, JsonValuePath, JsonValuePathPart, QueryMatchFilter, QueryCheckpointFilter, EventTypeMeta, ObjectIndex, ObjectMetaUpsert, ObjectRowFilter, ObjectRelationship, ObjectFieldConstraints, FormInput, FormInputOption, ObjectSettingMeta, UpsertFieldsMeta, UpsertFieldInputMeta, UpsertFieldOperation, UpsertFieldPreset, UpsertFieldCopyPreset, UpsertFieldRow, UpsertFieldOption, UpsertFieldResult, DeleteFieldRow, DeleteFieldResult, ObjectUnavailableReason, DiscoverResult, DiscoveredObject, MetaState, MetaStateObject, UpsertIssue, UpsertFieldOptionMeta, RowMatchRuleType, ObjectSemanticType, RowMatchData, RowMatchRuleOrder, SyncSession, SyncOptimalBatchSizeOperation, SyncOptimalBatchSizeBatchType, } from "@syncmatters/script-api";
7
7
  export * from "./lib/connector.js";
8
8
  export * from "./lib/connector-error.js";
9
9
  export { envSet } from "./lib/environment.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncmatters/connector-sdk",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "TypeScript type definitions for the SyncMatters connector SDK (types only - connectors execute on the SyncMatters platform)",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -12,9 +12,9 @@
12
12
  "license": "MIT",
13
13
  "author": "SyncMatters",
14
14
  "homepage": "https://syncmatters.com",
15
- "typesContentHash": "047a3bc412ec7fd9f3397234350f75efb2ce44768c7520f713801e35bac80cd3",
15
+ "typesContentHash": "0d29d38f3a11e36c7a03864f8034183d1a15c68fe66facf5b8404f0e829915ca",
16
16
  "dependencies": {
17
17
  "@types/node": "*",
18
- "@syncmatters/script-api": "^1.0.44"
18
+ "@syncmatters/script-api": "^1.0.46"
19
19
  }
20
20
  }