@syncmatters/script-api 1.0.43 → 1.0.44
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/lib/connection.d.ts +106 -6
- package/package.json +2 -2
- package/sdk-test/sdk-test.d.ts +27 -2
package/lib/connection.d.ts
CHANGED
|
@@ -37,6 +37,20 @@ export interface Connection {
|
|
|
37
37
|
delete?: {
|
|
38
38
|
[id: string]: (rows: any[]) => Promise<void>;
|
|
39
39
|
};
|
|
40
|
+
upsertFields?: {
|
|
41
|
+
[id: string]: (options: {
|
|
42
|
+
rows: UpsertFieldRow[];
|
|
43
|
+
}) => Promise<{
|
|
44
|
+
rows: UpsertFieldResult[];
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
deleteFields?: {
|
|
48
|
+
[id: string]: (options: {
|
|
49
|
+
rows: DeleteFieldRow[];
|
|
50
|
+
}) => Promise<{
|
|
51
|
+
rows: DeleteFieldResult[];
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
40
54
|
/** Id's of all objects collected on this connection. */
|
|
41
55
|
objectIds: string[];
|
|
42
56
|
/** Connect to the source, validating credentials etc ... */
|
|
@@ -379,6 +393,7 @@ export interface ObjectMeta {
|
|
|
379
393
|
canQueryRandoms?: boolean;
|
|
380
394
|
canUpsertClean?: boolean;
|
|
381
395
|
canUpsertFieldOptions?: boolean;
|
|
396
|
+
canDeleteFields?: boolean;
|
|
382
397
|
canAddCustomRelationships?: boolean;
|
|
383
398
|
matchRules?: RowMatchRuleType[];
|
|
384
399
|
customIndexes?: ObjectIndex[];
|
|
@@ -389,12 +404,83 @@ export interface ObjectMeta {
|
|
|
389
404
|
default?: boolean;
|
|
390
405
|
/** set by meta() when a selected object can no longer be described (e.g. deleted); the platform keeps the cached copy */
|
|
391
406
|
unavailable?: ObjectUnavailableReason;
|
|
392
|
-
/**
|
|
393
|
-
* the kind of record this object holds, for field auto-mapping: a canonical entity ("company"), an
|
|
394
|
-
* entity with its sub-type ("company.vendor"), or "unknown" when no entity fits; absent lets the
|
|
395
|
-
* platform detect it from the object name
|
|
396
|
-
*/
|
|
407
|
+
/** the kind of record this object holds, for field auto-mapping */
|
|
397
408
|
semanticType?: ObjectSemanticType;
|
|
409
|
+
/** the form for creating/updating a field on this object */
|
|
410
|
+
upsertFieldsMeta?: UpsertFieldsMeta;
|
|
411
|
+
}
|
|
412
|
+
/** UpsertFieldOperation is what an upsertFields row does: create a field, or change the definition of one */
|
|
413
|
+
export type UpsertFieldOperation = "add" | "update";
|
|
414
|
+
/**
|
|
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.
|
|
418
|
+
*/
|
|
419
|
+
export interface UpsertFieldsMeta {
|
|
420
|
+
/** the operations the connector accepts (default ["add"]); a row whose operation is not listed is refused */
|
|
421
|
+
operations?: UpsertFieldOperation[];
|
|
422
|
+
/** the form's inputs, keyed by input id; the input id is also the key of the value in a {@link UpsertFieldRow} */
|
|
423
|
+
fields: Record<string, UpsertFieldInputMeta>;
|
|
424
|
+
/** prefilled rows offered to the user; `external_id` is the well-known one ("Id of the <other system> record") */
|
|
425
|
+
presets?: UpsertFieldPreset[];
|
|
426
|
+
}
|
|
427
|
+
/** UpsertFieldInputMeta is one input of a create-field form: a form input plus what the platform reads it for */
|
|
428
|
+
export interface UpsertFieldInputMeta extends FormInput {
|
|
429
|
+
/** the input's data type; required on a create-field form input (the platform drops a form with an untyped input) */
|
|
430
|
+
type: NonNullable<FormInput["type"]>;
|
|
431
|
+
/** holds the new field's key, chosen by the user; a row gives it as `{ operation: "add" | "update", value }` */
|
|
432
|
+
isUserKey?: boolean;
|
|
433
|
+
/** holds the field's key, assigned by the system; omitted on add (a row with it is an update) */
|
|
434
|
+
isKey?: boolean;
|
|
435
|
+
/** holds the field's display text */
|
|
436
|
+
isName?: boolean;
|
|
437
|
+
}
|
|
438
|
+
/** UpsertFieldPreset is a prefilled create-field row */
|
|
439
|
+
export interface UpsertFieldPreset {
|
|
440
|
+
id: string;
|
|
441
|
+
name?: string;
|
|
442
|
+
/** input values, keyed by input id */
|
|
443
|
+
values: Record<string, unknown>;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* UpsertFieldRow creates or changes one field. It is keyed by input id, as a data upsert row is keyed by field id:
|
|
447
|
+
* - with an `isUserKey` input, that input holds `{ operation: "add" | "update", value }`;
|
|
448
|
+
* - with an `isKey` input, a row that carries it is an update and a row without it is an add;
|
|
449
|
+
* - with neither, every row is an add.
|
|
450
|
+
* An `option_array` input holds the field's whole option list, as {@link UpsertFieldOption}s.
|
|
451
|
+
*/
|
|
452
|
+
export type UpsertFieldRow = Record<string, unknown>;
|
|
453
|
+
/** UpsertFieldOption is one value of an `option_array` input; an omitted `id` means the name */
|
|
454
|
+
export interface UpsertFieldOption {
|
|
455
|
+
id?: string;
|
|
456
|
+
name: string;
|
|
457
|
+
}
|
|
458
|
+
/** UpsertFieldResult is the outcome of one {@link UpsertFieldRow} */
|
|
459
|
+
export interface UpsertFieldResult {
|
|
460
|
+
/** the field's key, as the system has it */
|
|
461
|
+
id?: string;
|
|
462
|
+
/** where to map the field, when it is not the top-level field `id` (e.g. inside a custom-fields container) */
|
|
463
|
+
path?: string[];
|
|
464
|
+
/** set when the row failed; code "already_exists" when the field is already there */
|
|
465
|
+
error?: {
|
|
466
|
+
code?: string;
|
|
467
|
+
message: string;
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
/** DeleteFieldRow deletes one field of an object */
|
|
471
|
+
export interface DeleteFieldRow {
|
|
472
|
+
/** the field's id, as it appears in the object's metadata */
|
|
473
|
+
id: string;
|
|
474
|
+
}
|
|
475
|
+
/** DeleteFieldResult is the outcome of one {@link DeleteFieldRow} */
|
|
476
|
+
export interface DeleteFieldResult {
|
|
477
|
+
/** the id of the deleted field */
|
|
478
|
+
id?: string;
|
|
479
|
+
/** set when the row failed */
|
|
480
|
+
error?: {
|
|
481
|
+
code?: string;
|
|
482
|
+
message: string;
|
|
483
|
+
};
|
|
398
484
|
}
|
|
399
485
|
/**
|
|
400
486
|
* ObjectUnavailableReason describes why a selected object could not be returned in hte meta refresh response: "deleted" (gone
|
|
@@ -450,11 +536,13 @@ export interface FormInput {
|
|
|
450
536
|
displayIf?: "none" | "other_setting_has_value" | "other_setting_is_not_empty";
|
|
451
537
|
displayIfSetting?: string;
|
|
452
538
|
displayIfValues?: string[];
|
|
453
|
-
type?: "string" | "boolean" | "number" | "string_array" | "connection_uid_template" | "google_picker";
|
|
539
|
+
type?: "string" | "boolean" | "number" | "string_array" | "connection_uid_template" | "google_picker" | "option_array";
|
|
454
540
|
control?: "singlelinetext" | "textarea" | "checkbox" | "switch" | "integer" | "url" | "datepicker" | "datetimepicker" | "filepicker" | "drivefolder" | "drivefile" | "select" | "multiselect" | "button" | "timezone";
|
|
455
541
|
options?: FormInputOption[];
|
|
456
542
|
default?: unknown;
|
|
457
543
|
constraints?: ObjectFieldConstraints;
|
|
544
|
+
/** read only on an option_array input: true when the user may set option ids (default false: ids are refused) */
|
|
545
|
+
userOptionIds?: boolean;
|
|
458
546
|
}
|
|
459
547
|
/** FormInputOption holds a metadata option value */
|
|
460
548
|
export interface FormInputOption {
|
|
@@ -530,6 +618,18 @@ export interface ObjectField {
|
|
|
530
618
|
isUserKey?: boolean;
|
|
531
619
|
/** field holds a unique value and the connector honors it as an idsFilterField key in queries */
|
|
532
620
|
isAlternateKey?: boolean;
|
|
621
|
+
/** field holds the record's display text (e.g. a company's name); a display hint, not a key; at most one per object */
|
|
622
|
+
isName?: boolean;
|
|
623
|
+
/**
|
|
624
|
+
* set when the field's id differs per account: identifies the same field in any account (absent means the id is
|
|
625
|
+
* portable). Compared as an opaque string.
|
|
626
|
+
*/
|
|
627
|
+
portableId?: string;
|
|
628
|
+
/**
|
|
629
|
+
* set on custom fields: what kind of field it is, where `type` cannot say (absent means compare `type`). Compared
|
|
630
|
+
* as an opaque string.
|
|
631
|
+
*/
|
|
632
|
+
portableType?: string;
|
|
533
633
|
/** field holds the array element unique identifier, required for update operations */
|
|
534
634
|
isElementKey?: boolean;
|
|
535
635
|
/** field, and any fields below, are custom (account specific): created by the account, or a vendor
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncmatters/script-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.44",
|
|
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": "
|
|
31
|
+
"typesContentHash": "04475e4db60ca81efd87b1fa09a55709be88d008d8b1c1a18687fdefd7b84ee7",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@types/node": "*"
|
|
34
34
|
}
|
package/sdk-test/sdk-test.d.ts
CHANGED
|
@@ -245,6 +245,31 @@ export interface ObjectFeatures {
|
|
|
245
245
|
/** After a delete, it may take up to this long before the API reports the row as deleted */
|
|
246
246
|
afterDeleteMaxIndexWaitTimeMs?: number;
|
|
247
247
|
};
|
|
248
|
+
/**
|
|
249
|
+
* The object's create-field form (upsertFieldsMeta), as generated from cached metadata. The fieldMetadata feature
|
|
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.
|
|
252
|
+
*/
|
|
253
|
+
upsertFields?: {
|
|
254
|
+
/** ids of the form's inputs, sorted */
|
|
255
|
+
inputIds?: string[];
|
|
256
|
+
/** id of the input flagged isUserKey or isKey */
|
|
257
|
+
keyInputId?: string;
|
|
258
|
+
/** is the key input flagged isUserKey (chosen by the user) rather than isKey (assigned by the system)? */
|
|
259
|
+
expectUserKey?: boolean;
|
|
260
|
+
/** id of the input flagged isName */
|
|
261
|
+
nameInputId?: string;
|
|
262
|
+
/** ids of the form's presets, sorted */
|
|
263
|
+
presetIds?: string[];
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* 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.
|
|
268
|
+
*/
|
|
269
|
+
deleteFields?: {
|
|
270
|
+
/** does the object declare canDeleteFields? */
|
|
271
|
+
canDeleteFields?: boolean;
|
|
272
|
+
};
|
|
248
273
|
}
|
|
249
274
|
/** List of features that can be tested for an object. */
|
|
250
275
|
export type ObjectFeature = "all" | "list" | "idsFilter" | "fieldMetadata" | "checkpointFilter" | "relatedFilter" | "matchFilter" | "upsert" | "upsertClean" | "delete" | "rowFilter";
|
|
@@ -325,9 +350,9 @@ export interface ObjectTestResult {
|
|
|
325
350
|
};
|
|
326
351
|
}
|
|
327
352
|
export interface FieldMetadataIssue {
|
|
328
|
-
operation: "query" | "upsert" | "delete";
|
|
353
|
+
operation: "query" | "upsert" | "delete" | "upsertFields" | "deleteFields";
|
|
329
354
|
path?: string;
|
|
330
|
-
issue: "Missing canMatch" | "No test spec for key field" | "Key field from test spec not found on object" | "Key field not tagged with isKey" | "Key field not tagged with isUserKey" | "Key field user key structure incorrect {value: string, operation: string}" | "More than one query field tagged with isKey or isUserKey";
|
|
355
|
+
issue: "Missing canMatch" | "No test spec for key field" | "Key field from test spec not found on object" | "Key field not tagged with isKey" | "Key field not tagged with isUserKey" | "Key field user key structure incorrect {value: string, operation: string}" | "More than one query field tagged with isKey or isUserKey" | "More than one field tagged with isName" | "Create-field form would be dropped: invalid key or name inputs" | "Create-field form from test spec not found on object" | "Create-field form differs from test spec" | "Field deletion differs from test spec";
|
|
331
356
|
}
|
|
332
357
|
export interface MatchRuleTestResult {
|
|
333
358
|
rule: API.RowMatchRuleType;
|