@syncmatters/script-api 1.0.0

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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/api.d.ts +24 -0
  4. package/index.d.ts +3 -0
  5. package/index.js +1 -0
  6. package/lib/coded-error.d.ts +7 -0
  7. package/lib/connection.d.ts +597 -0
  8. package/lib/context.d.ts +58 -0
  9. package/lib/environment.d.ts +4 -0
  10. package/lib/logger.d.ts +20 -0
  11. package/lib/script-error.d.ts +38 -0
  12. package/lib/sync-group.d.ts +85 -0
  13. package/lib/sync.d.ts +392 -0
  14. package/lib/utilities/csv-reader/csv-reader-csv-parse.d.ts +16 -0
  15. package/lib/utilities/csv-reader/csv-reader-fast-csv.d.ts +15 -0
  16. package/lib/utilities/csv-reader/csv-reader.d.ts +2 -0
  17. package/lib/utilities/csv-reader/index.d.ts +2 -0
  18. package/lib/utilities/csv-reader/types.d.ts +48 -0
  19. package/lib/utilities/csv-writer/csv-writer.d.ts +21 -0
  20. package/lib/utilities/date-utils/date-utils.d.ts +37 -0
  21. package/lib/utilities/file-provider/file-provider-buffer.d.ts +11 -0
  22. package/lib/utilities/file-provider/file-provider-disk.d.ts +12 -0
  23. package/lib/utilities/file-provider/file-provider-string.d.ts +11 -0
  24. package/lib/utilities/file-provider/file-provider.d.ts +21 -0
  25. package/lib/utilities/file-utils/file-utils.d.ts +8 -0
  26. package/lib/utilities/html-utils/html-utils.d.ts +1 -0
  27. package/lib/utilities/http-client/fetch-http-client.d.ts +7 -0
  28. package/lib/utilities/http-client/fetch-http-error.d.ts +14 -0
  29. package/lib/utilities/http-client/types.d.ts +62 -0
  30. package/lib/utilities/json-utils/index.d.ts +6 -0
  31. package/lib/utilities/json-utils/json-changed-checker.d.ts +15 -0
  32. package/lib/utilities/json-utils/json-hash.d.ts +4 -0
  33. package/lib/utilities/json-utils/json-values-reader.d.ts +13 -0
  34. package/lib/utilities/json-utils/json-values-types.d.ts +41 -0
  35. package/lib/utilities/json-utils/json-values-writer.d.ts +28 -0
  36. package/lib/utilities/json-utils/lossless-numbers.d.ts +6 -0
  37. package/lib/utilities/json-utils/paths.d.ts +8 -0
  38. package/lib/utilities/kv-store/better-sqlite3/kv-collection-better-sqlite3.d.ts +18 -0
  39. package/lib/utilities/kv-store/better-sqlite3/kv-iterator-better-sqlite3.d.ts +26 -0
  40. package/lib/utilities/kv-store/better-sqlite3/kv-store-better-sqlite3.d.ts +11 -0
  41. package/lib/utilities/kv-store/index.d.ts +4 -0
  42. package/lib/utilities/kv-store/kv-store-benchmark-helpers.d.ts +14 -0
  43. package/lib/utilities/kv-store/shadow/kv-store-shadow.d.ts +29 -0
  44. package/lib/utilities/kv-store/sqlite3/database-sqlite3.d.ts +16 -0
  45. package/lib/utilities/kv-store/sqlite3/kv-collection-sqlite3.d.ts +18 -0
  46. package/lib/utilities/kv-store/sqlite3/kv-iterator-sqlite3.d.ts +21 -0
  47. package/lib/utilities/kv-store/sqlite3/kv-store-sqlite3.d.ts +11 -0
  48. package/lib/utilities/kv-store/sqlite3/statement-sqlite3.d.ts +13 -0
  49. package/lib/utilities/kv-store/types.d.ts +20 -0
  50. package/lib/utilities/name-parser/name-parser.d.ts +6 -0
  51. package/lib/utilities/rate-limiter/rate-limiter-concurrent.d.ts +24 -0
  52. package/lib/utilities/rate-limiter/rate-limiter-rolling.d.ts +18 -0
  53. package/lib/utilities/rate-limiter/rate-limiter.d.ts +15 -0
  54. package/lib/utilities/type-utils/type-utils.d.ts +11 -0
  55. package/lib/utilities/upsert-flags/upsert-flags.d.ts +10 -0
  56. package/lib/utilities/utilities.d.ts +105 -0
  57. package/lib/utilities/www-utils/www-utils.d.ts +14 -0
  58. package/lib/utilities/xlsx-reader/xlsx-reader.d.ts +32 -0
  59. package/lib/utilities/xlsx-writer/xlsx-writer.d.ts +23 -0
  60. package/lib/utilities/xml-utils/xml-utils.d.ts +1 -0
  61. package/lib/utilities/zip-utils/zip-utils.d.ts +29 -0
  62. package/package.json +23 -0
  63. package/sdk-test/sdk-test.d.ts +451 -0
  64. package/sdk-test.d.ts +3 -0
@@ -0,0 +1,451 @@
1
+ import API from "../index.js";
2
+ /** This interface should be implemented in order for the test harness to run automated tests for the connector. */
3
+ export interface TestFeatureProvider {
4
+ /** Identity of the connection will be verified to ensure testing happens against the expected connection. */
5
+ expectedIdentity: string;
6
+ /** Setup function to run before starting tests. Can perform any required setup, such as creating test data. */
7
+ before(options: BeforeOptions): Promise<void>;
8
+ /** Ids of all objects that have tests specs defined. */
9
+ objectIds(): Promise<string[]>;
10
+ /** Return the expected features for an object. */
11
+ objectFeatures(objectId: string): Promise<ObjectFeatures>;
12
+ /**
13
+ * Prepare data that will be used to test the list feature. The test data may be created here, or retrieved from the system.
14
+ * Returning undefined indicates that the harness should just execute the list operation and verify that some data is
15
+ * returned.
16
+ */
17
+ listPrepare?(options: ListOptions): Promise<ListData | undefined>;
18
+ /** Delete test data created for use by this test. */
19
+ listCleanup?(options: ListCleanupOptions): Promise<void>;
20
+ /**
21
+ * Prepare data that will be used to test the idsFilter. The test data may be created here, or retrieved from the system.
22
+ * If the object supports list queries, this method need not be implemented. If undefined is returned a list query will be
23
+ * attempted to find some ids to test. If no data is retrieved feature will be marked as failed, with no test data.
24
+ */
25
+ idsFilterPrepare?(options: IdsFilterOptions): Promise<IdsFilterData | undefined>;
26
+ /** Delete test data created for use by this test. */
27
+ idsFilterCleanup?(options: IdsFilterCleanupOptions): Promise<void>;
28
+ /**
29
+ * Prepare data that can be used to test the checkpoint filter. The test data may be created here, or retrieved from the
30
+ * system. Returning undefined indicates that checkpoint filters cannot be tested.
31
+ */
32
+ checkpointFilterStep1Prepare?(options: CheckpointStep1Options): Promise<CheckpointStep1Data | undefined>;
33
+ /**
34
+ * Prepare data that can be used to test the checkpoint filter a second time. The test data may be created here, or retrieved
35
+ * from the system. Returning undefined indicates that checkpoint filters cannot be tested.
36
+ */
37
+ checkpointFilterStep2Prepare?(options: CheckpointStep2Options): Promise<CheckpointStep2Data | undefined>;
38
+ /** Delete test data created for use by a test. */
39
+ checkpointFilterCleanup?(options: CheckpointCleanupOptions): Promise<void>;
40
+ /**
41
+ * Prepare data that can be used to test a match operation; you may either create new test data, or search/find data
42
+ * that can be used to test the match rule. Returning undefined indicates that this match rule cannot be tested.
43
+ */
44
+ matchFilterPrepare?(options: MatchOptions): Promise<Array<MatchData> | undefined>;
45
+ /** Delete test data created for use by a test. */
46
+ matchFilterCleanup?(options: MatchCleanupOptions): Promise<void>;
47
+ /**
48
+ * Prepare data that can be used to test a query related operation; you may either create new test data, or search/find data
49
+ * that can be used to test the relationship query. Returning undefined indicates that this relationship cannot be tested.
50
+ */
51
+ relatedFilterPrepare?(options: RelationshipOptions): Promise<Array<RelationshipData> | undefined>;
52
+ /** Delete test data created for use by a test. */
53
+ relatedFilterCleanup?(options: RelationshipCleanupOptions): Promise<void>;
54
+ /**
55
+ * Prepare data that can be used to test a queries with 'rowFilters'; you may either create new test data, or search/find
56
+ * data that can be used to test the various row filters. Include one test of of test data for each row filter. Returning
57
+ * undefined indicates that row filters cannot be tested.
58
+ */
59
+ rowFiltersPrepare?(options: RowFiltersOptions): Promise<Array<RowFilterData> | undefined>;
60
+ /** Delete test data created for use by a test. */
61
+ rowFiltersCleanup?(options: RowFiltersCleanupOptions): Promise<void>;
62
+ /** Prepare data that can be used in 1) an 'insert' operation, 2) a follow-up 'update' operation. The test harness will copy
63
+ * the id from the insert response into the update request. Returning undefined indicates that the requested insert/update
64
+ * operation cannot be tested. The callet may request that:
65
+ * - a file field be included in the upsert request
66
+ * - examples be provided to simulate each possible upsertClean issue that may be returned by the connector for this object
67
+ */
68
+ upsertPrepare?(options: UpsertOptions): Promise<UpsertData | undefined>;
69
+ /** Delete test data created for use by a test. */
70
+ upsertCleanup?(options: UpsertCleanupOptions): Promise<void>;
71
+ /** Optional teardown function to run after all tests have completed. Can perform any required teardown, such as deleting test
72
+ * data. */
73
+ after?(): Promise<void>;
74
+ }
75
+ /** Specification of features that are supported by an object; much of this is auto generated however particular
76
+ * features may be further refined/specified by the test harness.
77
+ */
78
+ export interface ObjectFeatures {
79
+ /** If this object is exactly the same (i.e. 100% same code, same features) as another object on this connector, there is no
80
+ * need to test the object - just enter the id of the other object here.
81
+ */
82
+ sameAsObjectId?: string;
83
+ /** If this object cannot be tested, provide a reason here. For example "Object not available on test account". When a value
84
+ * is specified no object features will not be tested; the object status will be set to "Not tested".
85
+ */
86
+ cannotTestReason?: string;
87
+ query?: {
88
+ /** This option is as-per the object level sameAsObjectId, however applied at the whole of query operation */
89
+ sameAsObjectId?: string;
90
+ /** This option is as-per the object level cannotTestReason, however applied at the whole of query operation */
91
+ cannotTestReason?: string;
92
+ /** Does the object support list queries? (queries with no filters to return a all rows) */
93
+ list?: boolean;
94
+ /** This option is as-per the object level sameAsObjectId, however applied at the list query operation */
95
+ listSameAsObjectId?: string;
96
+ /** This option is as-per the object level cannotTestReason, however applied at the list query operation */
97
+ listCannotTestReason?: string;
98
+ /** Does the object allow rows to be collected by id? */
99
+ idsFilter?: boolean;
100
+ /** This option is as-per the object level sameAsObjectId, however applied at the idsFilter operation */
101
+ idsFilterSameAsObjectId?: string;
102
+ /** This option is as-per the object level cannotTestReason, however applied at the idsFilter operation */
103
+ idsFilterCannotTestReason?: string;
104
+ /** Does the object support checkpoint filtering? */
105
+ checkpointFilter?: boolean;
106
+ /** This option is as-per the object level sameAsObjectId, however applied at the checkpointFilter operation */
107
+ checkpointFilterSameAsObjectId?: string;
108
+ /** This option is as-per the object level cannotTestReason, however applied at the checkpointFilter operation */
109
+ checkpointFilterCannotTestReason?: string;
110
+ /** Expected match rules. Use sameAsObjectId or cannotTestReason to record reason not to test a match rule. */
111
+ matchRules?: {
112
+ rule: API.RowMatchRuleType;
113
+ sameAsObjectId?: string;
114
+ cannotTestReason?: string;
115
+ }[];
116
+ /** This option is as-per the object level sameAsObjectId, however applied to all match rule operations */
117
+ matchRulesSameAsObjectId?: string;
118
+ /** This option is as-per the object level cannotTestReason, however applied to all match rule operations */
119
+ matchRulesCannotTestReason?: string;
120
+ /** Which fields can be used for matching (typically means the API allows searching / filtering by the field) */
121
+ canMatchFields?: Array<API.JsonValuePath>;
122
+ /** Expected relationships to other objects. Use sameAsObjectId or cannotTestReason to record reason not to tested. */
123
+ relationshipsTo?: Array<{
124
+ id: string;
125
+ relObjectId: string;
126
+ sameAsObjectId?: string;
127
+ cannotTestReason?: string;
128
+ }>;
129
+ /** This option is as-per the object level sameAsObjectId, however applied to all relationship operations */
130
+ relationshipsToSameAsObjectId?: string;
131
+ /** This option is as-per the object level cannotTestReason, however applied to all relationship operations */
132
+ relationshipsToCannotTestReason?: string;
133
+ };
134
+ upsert?: {
135
+ /** This option is as-per the object level sameAsObjectId, however applied at the upsert operation */
136
+ sameAsObjectId?: string;
137
+ /** This option is as-per the object level cannotTestReason, however applied at the upsert operation */
138
+ cannotTestReason?: string;
139
+ /** Can rows be added/updated? */
140
+ canUpsert?: boolean;
141
+ key?: {
142
+ /** Path to the key in upsert fields */
143
+ path?: API.JsonValuePath;
144
+ /** Is this key user defined? (i.e. included on add and update)? */
145
+ expectUserKey?: boolean;
146
+ };
147
+ /** Is upsertClean supported? */
148
+ canUpsertClean?: boolean;
149
+ /** This option is as-per the object level sameAsObjectId, however applied at the upsertFieldOptions operation */
150
+ upsertCleanSameAsObjectId?: string;
151
+ /** This option is as-per the object level cannotTestReason, however applied at the upsertFieldOptions operation */
152
+ upsertCleanCannotTestReason?: string;
153
+ /** Can selected picklist option fields have new options auto-added and updated? */
154
+ canUpsertFieldOptions?: boolean;
155
+ /** Can custom relationships be added? */
156
+ canAddCustomRelationships?: boolean;
157
+ /** This option is as-per the object level sameAsObjectId, however applied at the upsertFieldOptions operation */
158
+ upsertFieldOptionsSameAsObjectId?: string;
159
+ /** This option is as-per the object level cannotTestReason, however applied at the upsertFieldOptions operation */
160
+ upsertFieldOptionsCannotTestReason?: string;
161
+ /** Identify expected field constraints */
162
+ constraints?: Array<{
163
+ fieldPath: API.JsonValuePath;
164
+ constraints: API.ObjectFieldConstraints;
165
+ }>;
166
+ };
167
+ delete?: {
168
+ /** This option is as-per the object level sameAsObjectId, however applied at the upsert operation */
169
+ sameAsObjectId?: string;
170
+ /** This option is as-per the object level cannotTestReason, however applied at the upsert operation */
171
+ cannotTestReason?: string;
172
+ /** Can rows be deleted? */
173
+ canDelete?: boolean;
174
+ key?: {
175
+ /** Path to the key in delete fields */
176
+ path?: API.JsonValuePath;
177
+ };
178
+ isDeleted?: {
179
+ /** Does the api still return the row, with this field set to valueWhenDeleted, even after deletion? */
180
+ path?: API.JsonValuePath;
181
+ valueWhenDeleted?: unknown;
182
+ };
183
+ /** After a delete, it may take up to this long before the API reports the row as deleted */
184
+ afterDeleteMaxIndexWaitTimeMs?: number;
185
+ };
186
+ }
187
+ /** List of features that can be tested for an object. */
188
+ export type ObjectFeature = "all" | "list" | "idsFilter" | "fieldMetadata" | "checkpointFilter" | "relatedFilter" | "matchFilter" | "upsert" | "upsertClean" | "delete" | "rowFilter";
189
+ export interface BeforeOptions {
190
+ /** Connection that will be used to test the connector logic, as selected by the user. */
191
+ connection: unknown;
192
+ /** Logger to use for logging. */
193
+ log: API.Logger;
194
+ }
195
+ /** Result of testing a connector. */
196
+ export interface ConnectorTestResult {
197
+ summaryStatus?: "Passed" | "Partial: Only selected objects/features tested" | "Partial: Not all features/objects can be tested" | "Failed: Connection selected for testing not found" | "Failed: Cannot create an instance of the test connection" | "Failed: Cannot instantiate the selected test code file" | "Failed: One or more tests failed";
198
+ fatalError?: CaughtError;
199
+ metaRefresh?: "Passed" | "Not supported" | "Not tested" | "Failed: Fatal error during testing" | "Failed: Connection identity does not match the test spec";
200
+ testConnection?: "Passed" | "Not tested" | "Failed: Fatal error during testing" | "Failed: Test connection response did not report success";
201
+ objectsStatus?: "Passed" | "Partial: Only selected objects tested" | "Partial: Only selected objects tested, not all features can be tested" | "Partial: Only selected object tests run" | "Partial: Only selected objects tested, only selected object tests run" | "Partial: Not all features/objects can be tested" | "Not tested" | "Failed: Fatal error during testing" | "Failed: One or more objects failed tests";
202
+ objects: ObjectTestResult[];
203
+ }
204
+ export interface ObjectTestResult {
205
+ objectId: string;
206
+ summaryStatus?: "Passed" | "Partial: Only selected object tests run" | "Partial: Not all features can be tested" | "Not tested" | "Failed: Object has no test spec" | "Failed: 'Same as object' not tested" | "Failed: Fatal error during testing" | "Failed: Object from test spec not present on connection" | "Failed: One or more tests failed";
207
+ fatalError?: CaughtError;
208
+ notTestedSameAsObjectId?: string;
209
+ notTestedReason?: string;
210
+ list?: "Passed" | "Passed: Limited test data, pagination not tested" | "Not tested" | "Not supported" | "Failed: 'Same as object' not tested" | "Failed: Object metadata supports list, test spec does not" | "Failed: Test spec supports list, object metadata does not" | "Failed: Fatal error during testing" | "Failed: No test data";
211
+ listNotTestedSameAsObjectId?: string;
212
+ listNotTestedReason?: string;
213
+ listFatalError?: CaughtError;
214
+ idsFilter?: "Passed" | "Not tested" | "Not supported" | "Failed: 'Same as object' not tested" | "Failed: Object metadata supports idsFilter, test spec does not" | "Failed: Test spec supports idsFilter, object metadata does not" | "Failed: Fatal error during testing" | "Failed: No test data" | "Failed: Returned unexpected row" | "Failed: Row not returned" | "Failed: More rows returned than expected";
215
+ idsFilterNotTestedSameAsObjectId?: string;
216
+ idsFilterNotTestedReason?: string;
217
+ idsFilterFatalError?: CaughtError;
218
+ checkpointFilter?: "Passed" | "Not tested" | "Not supported" | "Failed: 'Same as object' not tested" | "Failed: Object metadata supports checkpointFilter, test spec does not" | "Failed: Test spec supports checkpointFilter, object metadata does not" | "Failed: Fatal error during testing" | "Failed: No test data for step 1" | "Failed: No test data for step 2" | "Failed: Returned unexpected row for step 1" | "Failed: Returned unexpected row for step 2" | "Failed: Row not returned for step 1" | "Failed: Row not returned for step 2" | "Failed: Next checkpoint not returned";
219
+ checkpointFilterNotTestedSameAsObjectId?: string;
220
+ checkpointFilterNotTestedReason?: string;
221
+ checkpointFilterFatalError?: CaughtError;
222
+ relatedFilter?: "Passed" | "Not tested" | "Not supported" | "Failed: 'Same as object' not tested" | "Partial: Not all relationships can be tested" | "Failed: Object metadata supports relatedFilter, test spec does not" | "Failed: Test spec supports relatedFilter, object metadata does not" | "Failed: One or more filters have issues";
223
+ relatedFilterNotTestedSameAsObjectId?: string;
224
+ relatedFilterNotTestedReason?: string;
225
+ relatedFilterResults?: RelatedFilterTestResult[];
226
+ matchFilter?: "Passed" | "Not tested" | "Not supported" | "Failed: 'Same as object' not tested" | "Partial: Not all rules can be tested" | "Failed: Object metadata supports match rules, test spec does not" | "Failed: Test spec supports match rules, object metadata does not" | "Failed: One or more rules have issues";
227
+ matchFilterNotTestedSameAsObjectId?: string;
228
+ matchFilterNotTestedReason?: string;
229
+ matchFieldCount?: number;
230
+ matchFilterResults?: MatchRuleTestResult[];
231
+ upsert?: "Passed" | "Not tested" | "Not supported" | "Failed: 'Same as object' not tested" | "Failed: Feature has no test spec" | "Failed: Fatal error during testing" | "Failed: Test spec does not define key field" | "Failed: No test data for insert" | "Failed: No test data for update" | "Failed: No verifyField included with test data" | "Failed: query after insert did not return expected rows" | "Failed: No key path to test update" | "Failed: update returned unexpected row" | "Failed: verifyField value on the upsert row was blank" | "Failed: verifyField value on the queried row does not match the upsert value";
232
+ upsertNotTestedSameAsObjectId?: string;
233
+ upsertNotTestedReason?: string;
234
+ upsertFatalError?: CaughtError;
235
+ upsertClean?: "Passed" | "Not tested" | "Not supported" | "Failed: 'Same as object' not tested" | "Failed: constraints not defined" | "Failed: Feature has no test spec" | "Failed: ObjectFeatures says upsertClean is supported, however missing from object metadata" | "Failed: No test data for insert" | "Failed: No test data for simulating issues" | "Failed: Expected issue not reported by connector" | "Failed: Issue incorrectly reported as fatal by connector" | "Failed: Issue incorrectly reported as NOT fatal by connector" | "Failed: Fatal error during testing";
236
+ upsertCleanNotTestedSameAsObjectId?: string;
237
+ upsertCleanNotTestedReason?: string;
238
+ upsertCleanFatalError?: CaughtError;
239
+ fieldConstraintsCount?: number;
240
+ delete?: "Passed" | "Not tested" | "Not supported" | "Failed: 'Same as object' not tested" | "Failed: Feature has no test spec" | "Failed: Fatal error during testing" | "Failed: No test data for insert" | "Failed: insert did not return 2 rows" | "Failed: query after insert did not return expected rows" | "Failed: query after delete still returns row" | "Failed: No key path to test delete" | "Failed: delete returned unexpected row";
241
+ deleteNotTestedSameAsObjectId?: string;
242
+ deleteNotTestedReason?: string;
243
+ deleteFatalError?: CaughtError;
244
+ fieldMetadata?: "Passed" | "Not tested" | "Failed: One or more fields have metadata issues";
245
+ fieldMetadataIssues: FieldMetadataIssue[];
246
+ }
247
+ export interface FieldMetadataIssue {
248
+ operation: "query" | "upsert" | "delete";
249
+ path?: string;
250
+ 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}";
251
+ }
252
+ export interface MatchRuleTestResult {
253
+ rule: API.RowMatchRuleType;
254
+ status?: "Passed" | "Not tested" | "Failed: Rule has no test spec" | "Failed: Rule not present on object" | "Failed: Fatal error during testing" | "Failed: No test data" | "Failed: Expected match not returned" | "Failed: Wrong match returned" | "Failed: Test data invalid, no expected row ids";
255
+ notTestedSameAsObjectId?: string;
256
+ notTestedReason?: string;
257
+ errorRowId?: string;
258
+ fatalError?: CaughtError;
259
+ }
260
+ export interface RelatedFilterTestResult {
261
+ relationshipId: string;
262
+ status?: "Passed" | "Not tested" | "Failed: Relationship has no test spec" | "Failed: Relationship not present on object" | "Failed: Fatal error during testing" | "Failed: No test data" | "Failed: Did not find expected related row" | "Failed: Found unexpected row" | "Failed: Test data invalid, no expected row ids" | "Failed: Test data invalid, 'from' row not returned via idsFilter";
263
+ notTestedSameAsObjectId?: string;
264
+ notTestedReason?: string;
265
+ errorRowId?: string;
266
+ fatalError?: CaughtError;
267
+ }
268
+ /** Details from caught error that blocked test completion */
269
+ export interface CaughtError {
270
+ message?: string;
271
+ stack?: string;
272
+ }
273
+ /** Options passed when requesting data that will be used for an upsert test. */
274
+ export interface UpsertOptions {
275
+ meta: API.ObjectMeta;
276
+ withIssueSimulators?: boolean;
277
+ withUpsertFieldOptions?: API.JsonValuePath;
278
+ withFileField?: API.JsonValuePath;
279
+ }
280
+ /** Options passed when cleaning up after an upsert test. */
281
+ export interface UpsertCleanupOptions {
282
+ meta: API.ObjectMeta;
283
+ inserted: Array<API.Row>;
284
+ }
285
+ /** Data returned when requesting data that will be used for an upsert test. */
286
+ export interface UpsertData {
287
+ /** data to pass in the upsert call (ideally for an add operation) */
288
+ insert?: unknown;
289
+ /** a simple update that may be made to the added row (the test harness will copy over the key from the add response) */
290
+ update?: unknown;
291
+ /** if requested, include 'bad data' examples that will trigger upsertClean issues */
292
+ issueSimulators?: Array<UpsertIssueSimulator>;
293
+ /** fields to check to verify the insert/update was successful */
294
+ verifyFields?: Array<API.JsonValuePath>;
295
+ /** optionally specify other fields to include when querying the data back for validation */
296
+ fields?: Array<API.JsonValuePath>;
297
+ }
298
+ /** Expresses how to simulate an upsertClean issue, and defines the expected response. */
299
+ export interface UpsertIssueSimulator {
300
+ /** field(s) to apply to the insert to simulate the issue */
301
+ upsert: unknown;
302
+ /** expected upsert issue type */
303
+ type: API.UpsertIssueType;
304
+ /** is the issue expected to be fatal */
305
+ fatal?: boolean;
306
+ }
307
+ /** Options passed when requesting data that will be used for a match test. */
308
+ export interface MatchOptions {
309
+ meta: API.ObjectMeta;
310
+ rule: API.RowMatchRuleType;
311
+ }
312
+ /** Options passed when cleaning up after a match test. */
313
+ export interface MatchCleanupOptions {
314
+ meta: API.ObjectMeta;
315
+ testData: Array<MatchData>;
316
+ }
317
+ /** Data returned when requesting data that will be used for a match test. */
318
+ export interface MatchData {
319
+ /** data to pass into the match filter */
320
+ srcData: API.RowMatchData[];
321
+ /** path to the field on the dest row that holds the field to match with, if applicable to the rule */
322
+ destFieldPath?: API.JsonValuePath;
323
+ /** ids of dest rows expected back in response to the match query */
324
+ expectedMatchRowIds: string[];
325
+ /** optionally specify the fields to include in the match query */
326
+ fields?: Array<API.JsonValuePath>;
327
+ }
328
+ /** Options passed when requesting data that will be used for a relationship test. */
329
+ export interface RelationshipOptions {
330
+ fromObjectMeta: API.ObjectMeta;
331
+ fromRelationshipId: string;
332
+ toObjectMeta: API.ObjectMeta;
333
+ }
334
+ /** Options passed when cleaning up after a relationship test. */
335
+ export interface RelationshipCleanupOptions {
336
+ fromObjectMeta: API.ObjectMeta;
337
+ fromRelationshipId: string;
338
+ toObjectMeta: API.ObjectMeta;
339
+ testDatas: Array<RelationshipData>;
340
+ }
341
+ /** Data returned when requesting data that will be used for a relationship test. */
342
+ export interface RelationshipData {
343
+ /** id of the source row that will be passed as a filter when querying for rows from the 'other' object */
344
+ srcRowId: string;
345
+ /** id of rows from the 'other' object we can expect in response */
346
+ expectedRelatedRowIds: string[];
347
+ /** optionally specify the fields to include when collecting the 'from' row */
348
+ srcFields?: Array<API.JsonValuePath>;
349
+ /** optionally specify the fields from the 'other' row that should be returned in the response */
350
+ relatedFields?: Array<API.JsonValuePath>;
351
+ }
352
+ /** Options passed when requesting data that will be used for a checkpoint test. */
353
+ export interface CheckpointStep1Options {
354
+ meta: API.ObjectMeta;
355
+ }
356
+ /** Options passed when requesting data that will be used for a checkpoint test. */
357
+ export interface CheckpointStep2Options {
358
+ meta: API.ObjectMeta;
359
+ step1TestData: CheckpointStep1Data;
360
+ checkpointReceived: string;
361
+ }
362
+ /** Options passed when cleaning up after a checkpoint test. */
363
+ export interface CheckpointCleanupOptions {
364
+ meta: API.ObjectMeta;
365
+ step1TestData: CheckpointStep1Data;
366
+ step2TestData: CheckpointStep2Data;
367
+ }
368
+ /** Data returned when requesting data that will be used for a checkpoint test. */
369
+ export interface CheckpointStep1Data {
370
+ /** checkpoint to pass in the first checkpoint query */
371
+ nextCheckpoint?: string;
372
+ /** optional limit to pass in the first checkpoint query */
373
+ limit?: number;
374
+ /** id of rows we should receive back in response to the first checkpoint query */
375
+ expectedRowIds: string[];
376
+ /** optionally specify the fields to include in the checkpoint query */
377
+ fields?: Array<API.JsonValuePath>;
378
+ }
379
+ export interface CheckpointStep2Data {
380
+ /** id of rows we should receive back in response to the second checkpoint query */
381
+ expectedRowIds: string[];
382
+ /** optionally specify the fields to include in the checkpoint query */
383
+ fields?: Array<API.JsonValuePath>;
384
+ }
385
+ /** Options passed when requesting data that will be used for an list test. */
386
+ export interface ListOptions {
387
+ meta: API.ObjectMeta;
388
+ }
389
+ /** Options passed when cleaning up after an list test. */
390
+ export interface ListCleanupOptions {
391
+ meta: API.ObjectMeta;
392
+ testData: ListData;
393
+ }
394
+ /** Data returned when requesting data that will be used for an list test. */
395
+ export interface ListData {
396
+ /** number of rows included in each page of data returned via a list query, user to test pagination */
397
+ pageSize: number;
398
+ /** optionally specify the fields to include in the list query */
399
+ fields?: Array<API.JsonValuePath>;
400
+ /** if the test harness created test data, place the ids of the rows created here */
401
+ rowIds?: string[];
402
+ }
403
+ /** Options passed when requesting data that will be used for an idsFilter test. */
404
+ export interface IdsFilterOptions {
405
+ meta: API.ObjectMeta;
406
+ }
407
+ /** Options passed when cleaning up after an idsFilter test. */
408
+ export interface IdsFilterCleanupOptions {
409
+ meta: API.ObjectMeta;
410
+ testData: IdsFilterData;
411
+ }
412
+ /** Data returned when requesting data that will be used for an idsFilter test. */
413
+ export interface IdsFilterData {
414
+ id1: string;
415
+ id2: string;
416
+ /** optionally specify the fields to include in the idsFilter query */
417
+ fields?: Array<API.JsonValuePath>;
418
+ }
419
+ /** Options passed when requesting data that will be used for a rowFilters test. */
420
+ export interface RowFiltersOptions {
421
+ meta: API.ObjectMeta;
422
+ }
423
+ /** Options passed when cleaning up after an idsFilter test. */
424
+ export interface RowFiltersCleanupOptions {
425
+ meta: API.ObjectMeta;
426
+ testData: Array<RowFilterData>;
427
+ }
428
+ /** Data returned when requesting data that will be used for rowFilters tests. */
429
+ export interface RowFilterData {
430
+ /** filter to be passed in the query */
431
+ rowFilter: unknown;
432
+ /** id of rows we can expect in response */
433
+ expectedRowIds: string[];
434
+ /** optionally specify the fields to include in the rowFilter query */
435
+ fields?: Array<API.JsonValuePath>;
436
+ }
437
+ /**
438
+ * Find object field metadata by path.
439
+ * @param {API.ObjectField[]} fields
440
+ * @param {API.JsonValuePath} path - e.g. [{path: "id"}]
441
+ * @returns API.ObjectField|undefined
442
+ */
443
+ export declare function findObjectField(fields?: API.ObjectField[], path?: API.JsonValuePath): API.ObjectField | undefined;
444
+ /**
445
+ * Make a 6-character unique id for a test, e.g to use in naming test data. The unique id is guaranteed to be unique
446
+ * across this process. Uses a 3-letter random prefix + 3-character base36 counter. When counter overflows,
447
+ * generates a new unused 3-letter prefix. Whilst the uid will be unique for a given test run, it is possible that
448
+ * the uid will not be unique across test runs.
449
+ * @returns A unique id for a test.
450
+ */
451
+ export declare function makeUid(): string;
package/sdk-test.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import * as SDKTest from "./sdk-test/sdk-test.js";
2
+ export * from "./sdk-test/sdk-test.js";
3
+ export default SDKTest;