@syncmatters/connector-sdk 1.0.33 → 1.0.35

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.
@@ -260,8 +260,9 @@ publishing happens in the web UI as for any connector.
260
260
  Merge rules: a key present overrides the source, absent inherits, `null` clears; `settings` merge
261
261
  per setting id and, inside a setting, per attribute; arrays (`default_objects`, `scope_groups`,
262
262
  `categories`) replace whole. A setting's contract with the code (`type`, `control`, `options`,
263
- `template`, `secret`, `readonly`, `staticonly`, `connector_managed`, `mandatory`,
264
- `defines_version`, `prerequisite`, `affects_meta`) cannot be overridden, a child may only touch
263
+ `template`, `secret`, `readonly`, `staticonly`, `connector_managed`,
264
+ `defines_version`, `prerequisite`, `affects_meta`) cannot be overridden (`mandatory` can, either
265
+ way, except on a setting the source marks `connector_managed`), a child may only touch
265
266
  settings the source declares, and the source must be a published, non-deprecated connector that
266
267
  is not itself derived (one level only). A source sidecar may opt out with `"overrides": false`
267
268
  beside `connector_metadata`. A child never inherits a secret: the source's OAuth client id and
@@ -107,6 +107,7 @@ platform warns the user at deselect time, naming the syncs that would break.
107
107
  cardinality: "OneToOne", data: { idField: "companyId" } },
108
108
  ],
109
109
  isCustom: true, // object is account-specific (a custom object)
110
+ semanticType: "contact", // what kind of record a row is - set it on every object (below)
110
111
  data: { /* anything YOUR connector needs back later - options.meta.data */ },
111
112
  }
112
113
  ```
@@ -123,6 +124,77 @@ Set flags only for behaviour you implemented — but investigate the workaround
123
124
  before concluding a capability is impossible. "The API has no list-all endpoint" is not the
124
125
  same as "no list support". See [the query capability bar](#the-query-capability-bar).
125
126
 
127
+ ### `semanticType`: declare what kind of record each object holds
128
+
129
+ `semanticType` says what one row of the object **is**: a contact, a company, an invoice, a lookup
130
+ list. The platform uses it as the starting point for recognising the object's fields by meaning
131
+ (the same `Amount` field is a deal amount on an opportunity and an invoice total on an invoice),
132
+ and for working out which sync a reference field resolves through when auto-map proposes mappings.
133
+
134
+ **Declare it on every object. Do not rely on detection.** When `semanticType` is absent the
135
+ platform guesses from the object's id, then its name, with an exact-match lookup against a word
136
+ list you cannot see and that changes between releases. In a review of the first-party connectors
137
+ the guess was wrong or empty for about three objects in ten: a `Jobs` object that holds
138
+ recruiting requisitions is detected as a project, an `Email` related list as a contact, a
139
+ `CompanyCategories` lookup as nothing at all. A declaration always wins over the guess, costs one
140
+ line, and is checked: a value outside the `ObjectSemanticType` union fails the metadata refresh
141
+ with a connector error, so a typo is never stored.
142
+
143
+ How to choose the value:
144
+
145
+ - **By what a row is, not by what the vendor calls the object.** A property-management "Unit" is a
146
+ `location`; an accounting "Bill" is an `invoice`; a "Job" is a `project` in a PSA and a
147
+ `job_requisition` in a recruiting system.
148
+ - **The entity first, then the sub-type when the union has one.** The entities are `contact`,
149
+ `company`, `deal`, `quote`, `lead`, `user`, `activity`, `ticket`, `project`, `product`,
150
+ `line_item`, `order`, `invoice`, `payment`, `shipment`, `location`, `contract`, `campaign`,
151
+ `time_entry`, `expense`, `asset`, `document`, `journal_entry`, `reference`, `job_requisition` and
152
+ `application`. A sub-type narrows one of them: `company.vendor`, `order.purchase_order`,
153
+ `activity.email`, `location.unit`, `reference.tax_code`. Your editor completes the full list
154
+ from the union; the doc comment on each value gives its everyday name.
155
+ - **Lookup and code lists are `reference`**, with a sub-type where one fits (currencies, payment
156
+ terms, tax codes, categories, statuses, GL accounts). They are not `unknown`.
157
+ - **Two objects may share an entity.** Customers and vendors in separate objects are
158
+ `company.customer` and `company.vendor`; that is what the sub-type is for.
159
+
160
+ **When `"unknown"` is the right declaration.** `unknown` is a real answer, not a placeholder. Use
161
+ it when no entity describes a row:
162
+
163
+ - a join or association object (the rows only link two other records);
164
+ - an audit trail, change log or sync-status object;
165
+ - settings, configuration and report objects;
166
+ - a kind of record the list above does not model yet (an HR position, an insurance policy).
167
+
168
+ Declare it explicitly rather than leaving `semanticType` out: the declaration stops the platform
169
+ guessing from the name, and a guess of `company` for an `AccountAudit` object is worse than no
170
+ type.
171
+
172
+ What `unknown` means downstream, so you choose it knowingly:
173
+
174
+ - The object's fields are recognised from their own names and sample values only, without the
175
+ object as context. Generic fields (an email address, a created date) are still typed; fields
176
+ whose meaning depends on the object (`Amount`, `Status`, `Name`, the record's own id) mostly are
177
+ not, so **Auto-map fields** proposes less for syncs on that object and users map more by hand.
178
+ - A reference to this object from another object cannot be resolved through a sync of it by
179
+ entity, because it has none.
180
+ - Nothing breaks: the object syncs exactly as before, and every mapping can still be made by hand.
181
+ - A user can set a type for the object on their own connection (the **Type** line on the
182
+ connection's objects form), and that choice is never overwritten by the connector.
183
+
184
+ So do not reach for `unknown` because you are unsure. If an entity is a fair description of the
185
+ row, declare the entity; `unknown` is for objects where any entity would be wrong.
186
+
187
+ Changing your mind later:
188
+
189
+ - A new or changed declaration reaches each existing connection on its next metadata refresh.
190
+ - **Removing** a declaration does not clear it: the platform keeps the last declared value. To take
191
+ a type back, declare `"unknown"`.
192
+ - A value added to the union recently needs a platform release that carries it before a connector
193
+ can declare it; until then the refresh fails on the unrecognised value.
194
+
195
+ Check your work: after a metadata refresh, every object on the connection's objects form should
196
+ show its **Type** as "declared by connector". "Detected from the name" marks an object you missed.
197
+
126
198
  ## `ObjectField`
127
199
 
128
200
  ```js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncmatters/connector-sdk",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
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,7 +12,7 @@
12
12
  "license": "MIT",
13
13
  "author": "SyncMatters",
14
14
  "homepage": "https://syncmatters.com",
15
- "typesContentHash": "525bcc40b9d3b894b0e4501d4bf962b15091f5d6cbf907cf12f8f0f78c5eba2f",
15
+ "typesContentHash": "ca51dea3f49e69e304b4ee2d2d9e68d46e2bfb60243e5121077f83c1a6bb59df",
16
16
  "dependencies": {
17
17
  "@types/node": "*",
18
18
  "@syncmatters/script-api": "^1.0.37"