@memberjunction/integration-engine 6.1.4 → 6.2.0-edge.1
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/dist/ActionMetadataGenerator.d.ts +17 -17
- package/dist/ActionMetadataGenerator.js +70 -70
- package/dist/BaseIntegrationConnector.js +6 -6
- package/dist/BaseRESTIntegrationConnector.d.ts +28 -28
- package/dist/BaseRESTIntegrationConnector.js +97 -97
- package/dist/ConflictRecency.d.ts +4 -0
- package/dist/ConflictRecency.d.ts.map +1 -1
- package/dist/ConflictRecency.js +12 -4
- package/dist/ConflictRecency.js.map +1 -1
- package/dist/ConnectorFactory.d.ts +1 -1
- package/dist/ConnectorFactory.js +2 -2
- package/dist/ContentHash.d.ts +6 -0
- package/dist/ContentHash.d.ts.map +1 -1
- package/dist/ContentHash.js +17 -26
- package/dist/ContentHash.js.map +1 -1
- package/dist/CustomColumnPromotion.d.ts +12 -0
- package/dist/CustomColumnPromotion.d.ts.map +1 -1
- package/dist/CustomColumnPromotion.js +32 -8
- package/dist/CustomColumnPromotion.js.map +1 -1
- package/dist/CustomOverflow.d.ts +8 -0
- package/dist/CustomOverflow.d.ts.map +1 -1
- package/dist/CustomOverflow.js +20 -4
- package/dist/CustomOverflow.js.map +1 -1
- package/dist/EnrichSchemaConstraints.d.ts +1 -1
- package/dist/EnrichSchemaConstraints.js +2 -2
- package/dist/FieldMappingEngine.d.ts +3 -3
- package/dist/FieldMappingEngine.js +11 -11
- package/dist/HashDiff.d.ts +8 -0
- package/dist/HashDiff.d.ts.map +1 -1
- package/dist/HashDiff.js +22 -6
- package/dist/HashDiff.js.map +1 -1
- package/dist/IntegrationActionGenerator.d.ts +1 -1
- package/dist/IntegrationActionGenerator.js +2 -2
- package/dist/IntegrationConnectorCreationPipeline.d.ts +6 -6
- package/dist/IntegrationConnectorCreationPipeline.js +14 -14
- package/dist/IntegrationEngine.d.ts +38 -38
- package/dist/IntegrationEngine.js +132 -132
- package/dist/IntegrationSchemaSync.d.ts +47 -4
- package/dist/IntegrationSchemaSync.d.ts.map +1 -1
- package/dist/IntegrationSchemaSync.js +62 -30
- package/dist/IntegrationSchemaSync.js.map +1 -1
- package/dist/KeySerialization.d.ts +2 -0
- package/dist/KeySerialization.d.ts.map +1 -1
- package/dist/KeySerialization.js +5 -1
- package/dist/KeySerialization.js.map +1 -1
- package/dist/MatchEngine.d.ts +11 -11
- package/dist/MatchEngine.js +33 -33
- package/dist/RecordFlatten.d.ts +5 -1
- package/dist/RecordFlatten.d.ts.map +1 -1
- package/dist/RecordFlatten.js +11 -3
- package/dist/RecordFlatten.js.map +1 -1
- package/dist/RecordMapBatch.js +2 -2
- package/dist/StreamingDiscovery.d.ts +11 -0
- package/dist/StreamingDiscovery.d.ts.map +1 -1
- package/dist/StreamingDiscovery.js +22 -6
- package/dist/StreamingDiscovery.js.map +1 -1
- package/dist/SyncLogger.d.ts +15 -3
- package/dist/SyncLogger.d.ts.map +1 -1
- package/dist/SyncLogger.js +33 -9
- package/dist/SyncLogger.js.map +1 -1
- package/dist/WatermarkService.d.ts +2 -2
- package/dist/WatermarkService.js +4 -4
- package/dist/auth-helpers/BasicAuthHeaderBuilder.d.ts +6 -0
- package/dist/auth-helpers/BasicAuthHeaderBuilder.d.ts.map +1 -1
- package/dist/auth-helpers/BasicAuthHeaderBuilder.js +10 -2
- package/dist/auth-helpers/BasicAuthHeaderBuilder.js.map +1 -1
- package/dist/auth-helpers/OAuth1aSigner.d.ts +2 -0
- package/dist/auth-helpers/OAuth1aSigner.d.ts.map +1 -1
- package/dist/auth-helpers/OAuth1aSigner.js +10 -6
- package/dist/auth-helpers/OAuth1aSigner.js.map +1 -1
- package/dist/auth-helpers/OAuth2TokenManager.d.ts +2 -2
- package/dist/auth-helpers/OAuth2TokenManager.js +4 -4
- package/dist/auth-helpers/index.d.ts +2 -2
- package/dist/auth-helpers/index.d.ts.map +1 -1
- package/dist/auth-helpers/index.js +2 -2
- package/dist/auth-helpers/index.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/prefetchFilter.d.ts +4 -0
- package/dist/prefetchFilter.d.ts.map +1 -1
- package/dist/prefetchFilter.js +10 -2
- package/dist/prefetchFilter.js.map +1 -1
- package/package.json +7 -7
|
@@ -110,25 +110,25 @@ export declare class ActionMetadataGenerator {
|
|
|
110
110
|
* @returns SyncConfig (for .mj-sync.json) and ActionRecords (for .actions.json)
|
|
111
111
|
*/
|
|
112
112
|
Generate(config: ActionGeneratorConfig): GeneratedActionMetadata;
|
|
113
|
-
private
|
|
114
|
-
private
|
|
115
|
-
private
|
|
116
|
-
private
|
|
117
|
-
private
|
|
118
|
-
private
|
|
119
|
-
private
|
|
120
|
-
private
|
|
121
|
-
private
|
|
122
|
-
private
|
|
123
|
-
private
|
|
124
|
-
private
|
|
125
|
-
private
|
|
126
|
-
private
|
|
127
|
-
private
|
|
113
|
+
private generateActionsForObject;
|
|
114
|
+
private buildGetAction;
|
|
115
|
+
private buildCreateAction;
|
|
116
|
+
private buildUpsertAction;
|
|
117
|
+
private buildUpdateAction;
|
|
118
|
+
private buildDeleteAction;
|
|
119
|
+
private buildSearchAction;
|
|
120
|
+
private buildListAction;
|
|
121
|
+
private buildAction;
|
|
122
|
+
private buildSystemParam;
|
|
123
|
+
private fieldToInputParam;
|
|
124
|
+
private fieldToOutputParam;
|
|
125
|
+
private buildStandardResultCodes;
|
|
126
|
+
private buildSyncConfig;
|
|
127
|
+
private buildCategoryRecords;
|
|
128
128
|
/** Converts a field data type to an ActionParam ValueType */
|
|
129
|
-
private
|
|
129
|
+
private mapFieldTypeToValueType;
|
|
130
130
|
/** Converts a snake_case or lowercase name to a human-readable form */
|
|
131
|
-
private
|
|
131
|
+
private humanize;
|
|
132
132
|
}
|
|
133
133
|
export {};
|
|
134
134
|
//# sourceMappingURL=ActionMetadataGenerator.d.ts.map
|
|
@@ -21,136 +21,136 @@ export class ActionMetadataGenerator {
|
|
|
21
21
|
Generate(config) {
|
|
22
22
|
const actions = [];
|
|
23
23
|
for (const obj of config.Objects) {
|
|
24
|
-
actions.push(...this.
|
|
24
|
+
actions.push(...this.generateActionsForObject(config, obj));
|
|
25
25
|
}
|
|
26
26
|
return {
|
|
27
|
-
SyncConfig: this.
|
|
27
|
+
SyncConfig: this.buildSyncConfig(),
|
|
28
28
|
ActionRecords: actions,
|
|
29
|
-
CategoryRecords: this.
|
|
29
|
+
CategoryRecords: this.buildCategoryRecords(config),
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
// ─── Per-Object Generation ───────────────────────────────────────
|
|
33
|
-
|
|
33
|
+
generateActionsForObject(config, obj) {
|
|
34
34
|
const actions = [];
|
|
35
|
-
const displayName = obj.DisplayName || this.
|
|
35
|
+
const displayName = obj.DisplayName || this.humanize(obj.Name);
|
|
36
36
|
// Get — always generated
|
|
37
|
-
actions.push(this.
|
|
37
|
+
actions.push(this.buildGetAction(config, obj, displayName));
|
|
38
38
|
// Create/Update/Delete/Upsert — only if object supports write
|
|
39
39
|
if (obj.SupportsWrite) {
|
|
40
|
-
actions.push(this.
|
|
41
|
-
actions.push(this.
|
|
42
|
-
actions.push(this.
|
|
43
|
-
actions.push(this.
|
|
40
|
+
actions.push(this.buildCreateAction(config, obj, displayName));
|
|
41
|
+
actions.push(this.buildUpdateAction(config, obj, displayName));
|
|
42
|
+
actions.push(this.buildDeleteAction(config, obj, displayName));
|
|
43
|
+
actions.push(this.buildUpsertAction(config, obj, displayName));
|
|
44
44
|
}
|
|
45
45
|
// Search — if configured
|
|
46
46
|
if (config.IncludeSearch !== false) {
|
|
47
|
-
actions.push(this.
|
|
47
|
+
actions.push(this.buildSearchAction(config, obj, displayName));
|
|
48
48
|
}
|
|
49
49
|
// List — if configured
|
|
50
50
|
if (config.IncludeList !== false) {
|
|
51
|
-
actions.push(this.
|
|
51
|
+
actions.push(this.buildListAction(config, obj, displayName));
|
|
52
52
|
}
|
|
53
53
|
return actions;
|
|
54
54
|
}
|
|
55
55
|
// ─── Action Builders ─────────────────────────────────────────────
|
|
56
|
-
|
|
56
|
+
buildGetAction(config, obj, displayName) {
|
|
57
57
|
const params = [
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
60
|
-
this.
|
|
58
|
+
this.buildSystemParam('ExternalID', 'Both', true, `The unique ID of the ${displayName} record to retrieve`),
|
|
59
|
+
this.buildSystemParam('CompanyIntegrationID', 'Input', false, 'Optional: specific CompanyIntegration to use'),
|
|
60
|
+
this.buildSystemParam('Record', 'Output', false, `The retrieved ${displayName} record with all fields`),
|
|
61
61
|
];
|
|
62
62
|
// Add output params for each field so agents know what fields exist
|
|
63
63
|
for (const field of obj.Fields) {
|
|
64
|
-
params.push(this.
|
|
64
|
+
params.push(this.fieldToOutputParam(field));
|
|
65
65
|
}
|
|
66
|
-
return this.
|
|
66
|
+
return this.buildAction(config, obj, 'Get', displayName, `Retrieves a single ${displayName} record from ${config.IntegrationName} by its external ID`, params);
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
buildCreateAction(config, obj, displayName) {
|
|
69
69
|
const params = [
|
|
70
|
-
this.
|
|
70
|
+
this.buildSystemParam('CompanyIntegrationID', 'Input', false, 'Optional: specific CompanyIntegration to use'),
|
|
71
71
|
];
|
|
72
72
|
// Input params for writable fields
|
|
73
73
|
for (const field of obj.Fields) {
|
|
74
74
|
if (field.IsReadOnly || field.IsPrimaryKey)
|
|
75
75
|
continue;
|
|
76
|
-
params.push(this.
|
|
76
|
+
params.push(this.fieldToInputParam(field));
|
|
77
77
|
}
|
|
78
78
|
// Output
|
|
79
|
-
params.push(this.
|
|
80
|
-
return this.
|
|
79
|
+
params.push(this.buildSystemParam('ExternalID', 'Output', false, `The external ID of the newly created ${displayName} record`));
|
|
80
|
+
return this.buildAction(config, obj, 'Create', displayName, `Creates a new ${displayName} record in ${config.IntegrationName}`, params);
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
buildUpsertAction(config, obj, displayName) {
|
|
83
83
|
const idPropertyDesc = obj.UpsertKey
|
|
84
84
|
? `The unique field used to match an existing ${displayName} record (defaults to "${obj.UpsertKey}")`
|
|
85
85
|
: `The unique field used to match an existing ${displayName} record (connector default if omitted)`;
|
|
86
86
|
const params = [
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
87
|
+
this.buildSystemParam('CompanyIntegrationID', 'Input', false, 'Optional: specific CompanyIntegration to use'),
|
|
88
|
+
this.buildSystemParam('IDProperty', 'Input', false, idPropertyDesc),
|
|
89
89
|
];
|
|
90
90
|
// Input params for writable fields
|
|
91
91
|
for (const field of obj.Fields) {
|
|
92
92
|
if (field.IsReadOnly || field.IsPrimaryKey)
|
|
93
93
|
continue;
|
|
94
|
-
params.push(this.
|
|
94
|
+
params.push(this.fieldToInputParam(field, false)); // None required — upsert may match an existing record
|
|
95
95
|
}
|
|
96
96
|
// Output
|
|
97
|
-
params.push(this.
|
|
98
|
-
return this.
|
|
97
|
+
params.push(this.buildSystemParam('ExternalID', 'Output', false, `The external ID of the created or updated ${displayName} record`));
|
|
98
|
+
return this.buildAction(config, obj, 'Upsert', displayName, `Creates or updates a ${displayName} in ${config.IntegrationName} (idempotent upsert keyed on a natural ID)`, params);
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
buildUpdateAction(config, obj, displayName) {
|
|
101
101
|
const params = [
|
|
102
|
-
this.
|
|
103
|
-
this.
|
|
102
|
+
this.buildSystemParam('ExternalID', 'Both', true, `The external ID of the ${displayName} record to update`),
|
|
103
|
+
this.buildSystemParam('CompanyIntegrationID', 'Input', false, 'Optional: specific CompanyIntegration to use'),
|
|
104
104
|
];
|
|
105
105
|
// Input params for writable fields (none required — partial update)
|
|
106
106
|
for (const field of obj.Fields) {
|
|
107
107
|
if (field.IsReadOnly || field.IsPrimaryKey)
|
|
108
108
|
continue;
|
|
109
|
-
params.push(this.
|
|
109
|
+
params.push(this.fieldToInputParam(field, false)); // Not required for updates
|
|
110
110
|
}
|
|
111
|
-
return this.
|
|
111
|
+
return this.buildAction(config, obj, 'Update', displayName, `Updates an existing ${displayName} record in ${config.IntegrationName}. Only provided fields are changed.`, params);
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
buildDeleteAction(config, obj, displayName) {
|
|
114
114
|
const params = [
|
|
115
|
-
this.
|
|
116
|
-
this.
|
|
115
|
+
this.buildSystemParam('ExternalID', 'Input', true, `The external ID of the ${displayName} record to delete`),
|
|
116
|
+
this.buildSystemParam('CompanyIntegrationID', 'Input', false, 'Optional: specific CompanyIntegration to use'),
|
|
117
117
|
];
|
|
118
|
-
return this.
|
|
118
|
+
return this.buildAction(config, obj, 'Delete', displayName, `Deletes (archives) a ${displayName} record from ${config.IntegrationName}`, params);
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
buildSearchAction(config, obj, displayName) {
|
|
121
121
|
const params = [
|
|
122
|
-
this.
|
|
123
|
-
this.
|
|
124
|
-
this.
|
|
125
|
-
this.
|
|
122
|
+
this.buildSystemParam('CompanyIntegrationID', 'Input', false, 'Optional: specific CompanyIntegration to use'),
|
|
123
|
+
this.buildSystemParam('PageSize', 'Input', false, 'Maximum number of records to return (default: 100)'),
|
|
124
|
+
this.buildSystemParam('Page', 'Input', false, 'Page number for paginated results (1-based)'),
|
|
125
|
+
this.buildSystemParam('Sort', 'Input', false, 'Sort expression (connector-specific format)'),
|
|
126
126
|
];
|
|
127
127
|
// Input params for searchable fields (all non-PK fields as optional filters)
|
|
128
128
|
for (const field of obj.Fields) {
|
|
129
129
|
if (field.IsPrimaryKey)
|
|
130
130
|
continue;
|
|
131
|
-
params.push(this.
|
|
131
|
+
params.push(this.fieldToInputParam(field, false)); // All optional for search
|
|
132
132
|
}
|
|
133
133
|
// Outputs
|
|
134
|
-
params.push(this.
|
|
135
|
-
params.push(this.
|
|
136
|
-
params.push(this.
|
|
137
|
-
return this.
|
|
134
|
+
params.push(this.buildSystemParam('Records', 'Output', false, `Array of matching ${displayName} records`));
|
|
135
|
+
params.push(this.buildSystemParam('TotalCount', 'Output', false, 'Total number of matching records'));
|
|
136
|
+
params.push(this.buildSystemParam('HasMore', 'Output', false, 'Whether more pages of results exist'));
|
|
137
|
+
return this.buildAction(config, obj, 'Search', displayName, `Searches for ${displayName} records in ${config.IntegrationName} matching the given field filters`, params);
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
buildListAction(config, obj, displayName) {
|
|
140
140
|
const params = [
|
|
141
|
-
this.
|
|
142
|
-
this.
|
|
143
|
-
this.
|
|
144
|
-
this.
|
|
145
|
-
this.
|
|
146
|
-
this.
|
|
147
|
-
this.
|
|
148
|
-
this.
|
|
141
|
+
this.buildSystemParam('CompanyIntegrationID', 'Input', false, 'Optional: specific CompanyIntegration to use'),
|
|
142
|
+
this.buildSystemParam('PageSize', 'Input', false, 'Maximum number of records to return per page (default: 100)'),
|
|
143
|
+
this.buildSystemParam('Cursor', 'Input', false, 'Opaque cursor for fetching the next page (from previous ListResult)'),
|
|
144
|
+
this.buildSystemParam('Sort', 'Input', false, 'Sort expression (connector-specific format)'),
|
|
145
|
+
this.buildSystemParam('Records', 'Output', false, `Array of ${displayName} records in this page`),
|
|
146
|
+
this.buildSystemParam('HasMore', 'Output', false, 'Whether more pages of results exist'),
|
|
147
|
+
this.buildSystemParam('NextCursor', 'Output', false, 'Cursor to pass for the next page'),
|
|
148
|
+
this.buildSystemParam('TotalCount', 'Output', false, 'Total number of records, if known'),
|
|
149
149
|
];
|
|
150
|
-
return this.
|
|
150
|
+
return this.buildAction(config, obj, 'List', displayName, `Lists ${displayName} records from ${config.IntegrationName} with cursor-based pagination`, params);
|
|
151
151
|
}
|
|
152
152
|
// ─── Core Builders ───────────────────────────────────────────────
|
|
153
|
-
|
|
153
|
+
buildAction(config, obj, verb, displayName, description, params) {
|
|
154
154
|
const actionConfig = {
|
|
155
155
|
IntegrationName: config.IntegrationName,
|
|
156
156
|
ObjectName: obj.Name,
|
|
@@ -169,11 +169,11 @@ export class ActionMetadataGenerator {
|
|
|
169
169
|
},
|
|
170
170
|
relatedEntities: {
|
|
171
171
|
'MJ: Action Params': params,
|
|
172
|
-
'MJ: Action Result Codes': this.
|
|
172
|
+
'MJ: Action Result Codes': this.buildStandardResultCodes(verb),
|
|
173
173
|
},
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
|
-
|
|
176
|
+
buildSystemParam(name, type, isRequired, description) {
|
|
177
177
|
return {
|
|
178
178
|
fields: {
|
|
179
179
|
ActionID: '@parent:ID',
|
|
@@ -186,33 +186,33 @@ export class ActionMetadataGenerator {
|
|
|
186
186
|
},
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
|
-
|
|
189
|
+
fieldToInputParam(field, requiredOverride) {
|
|
190
190
|
return {
|
|
191
191
|
fields: {
|
|
192
192
|
ActionID: '@parent:ID',
|
|
193
193
|
Name: field.Name,
|
|
194
194
|
Type: 'Input',
|
|
195
|
-
ValueType: this.
|
|
195
|
+
ValueType: this.mapFieldTypeToValueType(field.Type),
|
|
196
196
|
IsArray: false,
|
|
197
197
|
IsRequired: requiredOverride ?? field.IsRequired,
|
|
198
198
|
Description: field.Description || `${field.DisplayName || field.Name} field`,
|
|
199
199
|
},
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
|
-
|
|
202
|
+
fieldToOutputParam(field) {
|
|
203
203
|
return {
|
|
204
204
|
fields: {
|
|
205
205
|
ActionID: '@parent:ID',
|
|
206
206
|
Name: field.Name,
|
|
207
207
|
Type: 'Output',
|
|
208
|
-
ValueType: this.
|
|
208
|
+
ValueType: this.mapFieldTypeToValueType(field.Type),
|
|
209
209
|
IsArray: false,
|
|
210
210
|
IsRequired: false,
|
|
211
211
|
Description: field.Description || `${field.DisplayName || field.Name} value from the retrieved record`,
|
|
212
212
|
},
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
|
-
|
|
215
|
+
buildStandardResultCodes(verb) {
|
|
216
216
|
const codes = [
|
|
217
217
|
{ fields: { ActionID: '@parent:ID', ResultCode: 'SUCCESS', IsSuccess: true, Description: `${verb} operation completed successfully` } },
|
|
218
218
|
{ fields: { ActionID: '@parent:ID', ResultCode: 'EXECUTOR_ERROR', IsSuccess: false, Description: 'Internal executor error' } },
|
|
@@ -227,7 +227,7 @@ export class ActionMetadataGenerator {
|
|
|
227
227
|
return codes;
|
|
228
228
|
}
|
|
229
229
|
// ─── .mj-sync.json ──────────────────────────────────────────────
|
|
230
|
-
|
|
230
|
+
buildSyncConfig() {
|
|
231
231
|
return {
|
|
232
232
|
entity: 'MJ: Actions',
|
|
233
233
|
filePattern: '**/.*.json',
|
|
@@ -266,7 +266,7 @@ export class ActionMetadataGenerator {
|
|
|
266
266
|
};
|
|
267
267
|
}
|
|
268
268
|
// ─── Category Generation ─────────────────────────────────────────
|
|
269
|
-
|
|
269
|
+
buildCategoryRecords(config) {
|
|
270
270
|
if (config.CreateCategory === false)
|
|
271
271
|
return [];
|
|
272
272
|
const fields = {
|
|
@@ -281,7 +281,7 @@ export class ActionMetadataGenerator {
|
|
|
281
281
|
}
|
|
282
282
|
// ─── Helpers ─────────────────────────────────────────────────────
|
|
283
283
|
/** Converts a field data type to an ActionParam ValueType */
|
|
284
|
-
|
|
284
|
+
mapFieldTypeToValueType(fieldType) {
|
|
285
285
|
switch (fieldType.toLowerCase()) {
|
|
286
286
|
case 'boolean':
|
|
287
287
|
case 'number':
|
|
@@ -301,7 +301,7 @@ export class ActionMetadataGenerator {
|
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
/** Converts a snake_case or lowercase name to a human-readable form */
|
|
304
|
-
|
|
304
|
+
humanize(name) {
|
|
305
305
|
return name
|
|
306
306
|
.replace(/_/g, ' ')
|
|
307
307
|
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClassifyError } from './types.js';
|
|
2
2
|
import { ExtractRetryAfterFromError } from './RetryAfter.js';
|
|
3
|
-
import {
|
|
3
|
+
import { DiscoverFromStream, PickKeyFromStats, PickPrimaryKeyFromStats, PK_STAT_MIN_ROWS_FOR_SIGNIFICANCE, } from './StreamingDiscovery.js';
|
|
4
4
|
import { AdaptiveConcurrencyController, RunAdaptive } from './AdaptiveConcurrency.js';
|
|
5
|
-
import {
|
|
5
|
+
import { FlattenRecord, HasNestedObject } from './RecordFlatten.js';
|
|
6
6
|
import { DiscoveryWatchdog } from './DiscoveryWatchdog.js';
|
|
7
7
|
/** Default timeout values for connector operations */
|
|
8
8
|
export const DEFAULT_OPERATION_TIMEOUTS = {
|
|
@@ -324,14 +324,14 @@ export class BaseIntegrationConnector {
|
|
|
324
324
|
// names discovered here match what sync produces. A flat record passes through unchanged.
|
|
325
325
|
async function* flattenRecords() {
|
|
326
326
|
for await (const r of records)
|
|
327
|
-
yield
|
|
327
|
+
yield HasNestedObject(r) ? FlattenRecord(r) : r;
|
|
328
328
|
}
|
|
329
|
-
const scan = await
|
|
329
|
+
const scan = await DiscoverFromStream(flattenRecords(), opts.Discovery);
|
|
330
330
|
// Provable-only identity in ONE pass: best contender per subset size (1,2,3…) → the SMALLEST
|
|
331
331
|
// size whose best contender is a provable key (single OR composite), decided by the Chao1
|
|
332
332
|
// domain-saturation test on the streamed sample. No fabricated keys; a genuinely-keyless object
|
|
333
333
|
// simply gets no PK and is honestly not added downstream.
|
|
334
|
-
const key =
|
|
334
|
+
const key = PickKeyFromStats(scan.Columns, scan.RowSamples, opts.Pk);
|
|
335
335
|
let pkFieldNames = key.Fields ?? [];
|
|
336
336
|
let pkReason = key.Reason;
|
|
337
337
|
if (pkFieldNames.length === 0) {
|
|
@@ -344,7 +344,7 @@ export class BaseIntegrationConnector {
|
|
|
344
344
|
// objects still get no PK (content-hash identity handles dedup).
|
|
345
345
|
// #A4 — tell the PK picker whether the scan saw the WHOLE stream; a time-budget-truncated scan
|
|
346
346
|
// must not yield a confident soft key from a partial prefix.
|
|
347
|
-
const soft =
|
|
347
|
+
const soft = PickPrimaryKeyFromStats(scan.Columns, { ...opts.Pk, ScanComplete: scan.StoppedReason !== 'time-budget' });
|
|
348
348
|
if (soft.Field) {
|
|
349
349
|
pkFieldNames = [soft.Field];
|
|
350
350
|
pkReason = `[soft-fallback] ${soft.Reason}`;
|
|
@@ -171,7 +171,7 @@ export declare abstract class BaseRESTIntegrationConnector extends BaseIntegrati
|
|
|
171
171
|
/**
|
|
172
172
|
* Fetches records from a flat endpoint (no template variable substitution).
|
|
173
173
|
*/
|
|
174
|
-
private
|
|
174
|
+
private fetchFlat;
|
|
175
175
|
/**
|
|
176
176
|
* Fetches records from a template-variable endpoint, generalized to MULTI-LEVEL
|
|
177
177
|
* (nested / chained) paths such as `/orgs/{OrgID}/depts/{DeptID}/employees`.
|
|
@@ -184,7 +184,7 @@ export declare abstract class BaseRESTIntegrationConnector extends BaseIntegrati
|
|
|
184
184
|
* This is the connector-side realization of the topological traversal the engine
|
|
185
185
|
* already uses for sync ORDER. A single-var path behaves exactly as before.
|
|
186
186
|
*/
|
|
187
|
-
private
|
|
187
|
+
private fetchWithTemplateVars;
|
|
188
188
|
/**
|
|
189
189
|
* Per-call cap on how many PARENTS a parent-iterated object processes before yielding a resumable
|
|
190
190
|
* batch (the engine loops on HasMore). Kept conservative so a single FetchChanges call fits the
|
|
@@ -238,7 +238,7 @@ export declare abstract class BaseRESTIntegrationConnector extends BaseIntegrati
|
|
|
238
238
|
* Record-constrained (unlike sync, which walks ALL rows via the DAG): a million-row ancestor is
|
|
239
239
|
* streamed and cut off early. Pure HTTP — no SQL, dialect-agnostic.
|
|
240
240
|
*/
|
|
241
|
-
private
|
|
241
|
+
private streamRecordsForDiscovery;
|
|
242
242
|
/**
|
|
243
243
|
* DISCOVERY-ONLY sampler for a MULTI-VAR child (2+ template vars in the APIPath).
|
|
244
244
|
*
|
|
@@ -259,22 +259,22 @@ export declare abstract class BaseRESTIntegrationConnector extends BaseIntegrati
|
|
|
259
259
|
* parent classification, because it is the same question — "how many rows before we admit this
|
|
260
260
|
* stream cannot answer".
|
|
261
261
|
*/
|
|
262
|
-
private
|
|
262
|
+
private streamMultiVarChildForDiscovery;
|
|
263
263
|
/**
|
|
264
264
|
* Resolves the parent's addressing-key FIELD NAME for discovery-time sampling, without presupposing
|
|
265
265
|
* it: (1) a declared PK in metadata; else (2) the value-statistic classifier over the fetched rows.
|
|
266
266
|
* Returns null when the parent is genuinely keyless (→ the caller adjourns). No conventional identity
|
|
267
267
|
* name is ever guessed — a name is never assumed for a field the data doesn't prove is the key.
|
|
268
268
|
*/
|
|
269
|
-
private
|
|
269
|
+
private resolveParentKeyField;
|
|
270
270
|
/** Reads the discovery knob precedence — per-connection Configuration (int) → operator env → default. */
|
|
271
|
-
private
|
|
271
|
+
private readDiscoveryConfig;
|
|
272
272
|
/** Stable total order over ID strings — numeric when ALL are integer-like, else lexical. */
|
|
273
|
-
private
|
|
273
|
+
private sortIdsStable;
|
|
274
274
|
/** Total-order comparator matching SortIdsStable, used for keyset resume (id > AfterKeyValue). */
|
|
275
|
-
private
|
|
275
|
+
private compareIds;
|
|
276
276
|
/** Runs `worker` over `items` with at most `concurrency` in flight. Rejects on the first worker error. */
|
|
277
|
-
private
|
|
277
|
+
private runBounded;
|
|
278
278
|
/**
|
|
279
279
|
* Recursive descent over the ordered template-var resolutions, one layer per level.
|
|
280
280
|
*
|
|
@@ -287,7 +287,7 @@ export declare abstract class BaseRESTIntegrationConnector extends BaseIntegrati
|
|
|
287
287
|
* (all vars substituted) it fetches with pagination and tags each record with the
|
|
288
288
|
* resolved parent FK values.
|
|
289
289
|
*/
|
|
290
|
-
private
|
|
290
|
+
private descendTemplateVars;
|
|
291
291
|
/**
|
|
292
292
|
* Resolves a SINGLE template variable to its parent object + FK field.
|
|
293
293
|
*
|
|
@@ -300,33 +300,33 @@ export declare abstract class BaseRESTIntegrationConnector extends BaseIntegrati
|
|
|
300
300
|
* Returns null when neither strategy matches.
|
|
301
301
|
*/
|
|
302
302
|
/** Reads a trimmed string value from an IntegrationObject's Configuration JSON (tolerant of absent/invalid). */
|
|
303
|
-
private
|
|
303
|
+
private readObjectConfigString;
|
|
304
304
|
/** Reads an OBJECT-valued key from an IntegrationObject's Configuration JSON as a string→string map
|
|
305
305
|
* with lowercased keys (tolerant of absent/invalid). Used for the per-var parent maps that let a
|
|
306
306
|
* MULTI-LEVEL template-var path resolve each variable to its own parent. */
|
|
307
|
-
private
|
|
308
|
-
private
|
|
307
|
+
private readObjectConfigStringMap;
|
|
308
|
+
private resolveParentForVar;
|
|
309
309
|
/**
|
|
310
310
|
* Finds the FK column on `innerObjectID` that points at `outerObjectID` — used to
|
|
311
311
|
* filter a child level by its parent in a nested path. Returns null when no FK links
|
|
312
312
|
* them, in which case that level loads unfiltered (independent vars / cartesian).
|
|
313
313
|
*/
|
|
314
|
-
private
|
|
314
|
+
private findFKColumnToParent;
|
|
315
315
|
/**
|
|
316
316
|
* Loads parent record IDs from the local MJ database.
|
|
317
317
|
* Uses IntegrationEngineBase cache for object/field metadata lookups,
|
|
318
318
|
* then queries the MJ entity via RunView for actual synced record IDs.
|
|
319
319
|
*/
|
|
320
|
-
private
|
|
320
|
+
private loadParentIDs;
|
|
321
321
|
/**
|
|
322
322
|
* Fetches records from a single URL with pagination support.
|
|
323
323
|
* Loops through pages until no more data or maxRecords is reached.
|
|
324
324
|
*/
|
|
325
|
-
private
|
|
325
|
+
private fetchWithPagination;
|
|
326
326
|
/**
|
|
327
327
|
* Fetches a single non-paginated page.
|
|
328
328
|
*/
|
|
329
|
-
private
|
|
329
|
+
private fetchSinglePage;
|
|
330
330
|
/**
|
|
331
331
|
* Iterates through paginated responses, accumulating records up to BatchSize per call.
|
|
332
332
|
* Stops mid-pagination when BatchSize is reached and returns HasMore=true + NextPage/NextOffset
|
|
@@ -334,11 +334,11 @@ export declare abstract class BaseRESTIntegrationConnector extends BaseIntegrati
|
|
|
334
334
|
* Cursor state is maintained internally within the batch, avoiding the need to
|
|
335
335
|
* externalize it through FetchBatchResult (which would break cursor-based connectors).
|
|
336
336
|
*/
|
|
337
|
-
private
|
|
337
|
+
private fetchPaginatedLoop;
|
|
338
338
|
/**
|
|
339
339
|
* Combines baseURL and apiPath into a full URL.
|
|
340
340
|
*/
|
|
341
|
-
private
|
|
341
|
+
private buildFullURL;
|
|
342
342
|
/**
|
|
343
343
|
* Appends pagination parameters to a URL based on the object's PaginationType.
|
|
344
344
|
* Override in subclasses to use vendor-specific parameter names.
|
|
@@ -358,16 +358,16 @@ export declare abstract class BaseRESTIntegrationConnector extends BaseIntegrati
|
|
|
358
358
|
* Extracts query parameter keys from a URL, returned as a Set of lowercase strings.
|
|
359
359
|
* Used to detect duplicates between pagination params and DefaultQueryParams.
|
|
360
360
|
*/
|
|
361
|
-
private
|
|
361
|
+
private extractURLParamKeys;
|
|
362
362
|
/**
|
|
363
363
|
* Detects template variables in an API path. Template variables use
|
|
364
364
|
* the format {VariableName} (e.g., "/profiles/{ProfileID}/events").
|
|
365
365
|
*/
|
|
366
|
-
private
|
|
366
|
+
private detectTemplateVars;
|
|
367
367
|
/**
|
|
368
368
|
* Substitutes a single template variable in a path.
|
|
369
369
|
*/
|
|
370
|
-
private
|
|
370
|
+
private substituteTemplateVars;
|
|
371
371
|
/**
|
|
372
372
|
* Gets an IntegrationObject from the engine's cache by integration ID and object name.
|
|
373
373
|
* Throws if not found.
|
|
@@ -395,29 +395,29 @@ export declare abstract class BaseRESTIntegrationConnector extends BaseIntegrati
|
|
|
395
395
|
* Converts a raw API record object to the ExternalRecord format.
|
|
396
396
|
* For composite primary keys, joins all PK values with '|' to form a unique ExternalID.
|
|
397
397
|
*/
|
|
398
|
-
private
|
|
398
|
+
private toExternalRecord;
|
|
399
399
|
/**
|
|
400
400
|
* Returns the primary key field names for a set of IntegrationObjectField records,
|
|
401
401
|
* sorted by Sequence. For composite PKs, returns all PK fields.
|
|
402
402
|
* Falls back to ["ID"] if no PK fields are explicitly marked.
|
|
403
403
|
*/
|
|
404
|
-
private
|
|
404
|
+
private findPrimaryKeyFieldNames;
|
|
405
405
|
/**
|
|
406
406
|
* Converts an IntegrationObjectFieldEntity to the ExternalFieldSchema format.
|
|
407
407
|
*/
|
|
408
|
-
private
|
|
408
|
+
private fieldEntityToSchema;
|
|
409
409
|
/**
|
|
410
410
|
* Builds a SourceObjectInfo from an IntegrationObject and its fields.
|
|
411
411
|
* Resolves FK relationships using the RelatedIntegrationObjectID.
|
|
412
412
|
*/
|
|
413
|
-
private
|
|
413
|
+
private buildSourceObjectInfo;
|
|
414
414
|
/**
|
|
415
415
|
* Builds SourceRelationshipInfo entries from FK fields.
|
|
416
416
|
*/
|
|
417
|
-
private
|
|
417
|
+
private buildRelationships;
|
|
418
418
|
/**
|
|
419
419
|
* Validates an HTTP response and throws a descriptive error on non-2xx status.
|
|
420
420
|
*/
|
|
421
|
-
private
|
|
421
|
+
private validateHTTPResponse;
|
|
422
422
|
}
|
|
423
423
|
//# sourceMappingURL=BaseRESTIntegrationConnector.d.ts.map
|