@syncmatters/connector-sdk 1.0.34 → 1.0.36

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.
@@ -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,84 @@ 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
+ - **A few sub-types are companions, not kinds of the record.** `deal.forecast` (the revenue forecast
160
+ of an opportunity) and `job_requisition.posting` (a job-board posting of a requisition) are
161
+ different records tied to the main one, each with its own id. Declare the companion on those
162
+ objects and keep the bare entity or a kind sub-type for the object that is the record itself.
163
+ A companion's fields are typed as the entity's, but the platform never picks a companion object
164
+ as the record for the entity (for example when it resolves a `deal` reference through another
165
+ sync). Which sub-types are companions is platform knowledge; you declare only the value.
166
+
167
+ **When `"unknown"` is the right declaration.** `unknown` is a real answer, not a placeholder. Use
168
+ it when no entity describes a row:
169
+
170
+ - a join or association object (the rows only link two other records);
171
+ - an audit trail, change log or sync-status object;
172
+ - settings, configuration and report objects;
173
+ - a kind of record the list above does not model yet (an HR position, an insurance policy).
174
+
175
+ Declare it explicitly rather than leaving `semanticType` out: the declaration stops the platform
176
+ guessing from the name, and a guess of `company` for an `AccountAudit` object is worse than no
177
+ type.
178
+
179
+ What `unknown` means downstream, so you choose it knowingly:
180
+
181
+ - The object's fields are recognised from their own names and sample values only, without the
182
+ object as context. Generic fields (an email address, a created date) are still typed; fields
183
+ whose meaning depends on the object (`Amount`, `Status`, `Name`, the record's own id) mostly are
184
+ not, so **Auto-map fields** proposes less for syncs on that object and users map more by hand.
185
+ - A reference to this object from another object cannot be resolved through a sync of it by
186
+ entity, because it has none.
187
+ - Nothing breaks: the object syncs exactly as before, and every mapping can still be made by hand.
188
+ - A user can set a type for the object on their own connection (the **Type** line on the
189
+ connection's objects form), and that choice is never overwritten by the connector.
190
+
191
+ So do not reach for `unknown` because you are unsure. If an entity is a fair description of the
192
+ row, declare the entity; `unknown` is for objects where any entity would be wrong.
193
+
194
+ Changing your mind later:
195
+
196
+ - A new or changed declaration reaches each existing connection on its next metadata refresh.
197
+ - **Removing** a declaration does not clear it: the platform keeps the last declared value. To take
198
+ a type back, declare `"unknown"`.
199
+ - A value added to the union recently needs a platform release that carries it before a connector
200
+ can declare it; until then the refresh fails on the unrecognised value.
201
+
202
+ Check your work: after a metadata refresh, every object on the connection's objects form should
203
+ show its **Type** as "declared by connector". "Detected from the name" marks an object you missed.
204
+
126
205
  ## `ObjectField`
127
206
 
128
207
  ```js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncmatters/connector-sdk",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
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": "17cd06537fafbbd520f5c69d01657aee664d22fdf18ab5541214b59336e2c73b",
15
+ "typesContentHash": "3d73ad11d72941a3c267c95a31a22061cb03cc2f66548112063e9907845af733",
16
16
  "dependencies": {
17
17
  "@types/node": "*",
18
- "@syncmatters/script-api": "^1.0.37"
18
+ "@syncmatters/script-api": "^1.0.38"
19
19
  }
20
20
  }