@memberjunction/integration-engine 6.2.0-edge.0 → 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.
Files changed (85) hide show
  1. package/dist/ActionMetadataGenerator.d.ts +17 -17
  2. package/dist/ActionMetadataGenerator.js +70 -70
  3. package/dist/BaseIntegrationConnector.js +6 -6
  4. package/dist/BaseRESTIntegrationConnector.d.ts +28 -28
  5. package/dist/BaseRESTIntegrationConnector.js +97 -97
  6. package/dist/ConflictRecency.d.ts +4 -0
  7. package/dist/ConflictRecency.d.ts.map +1 -1
  8. package/dist/ConflictRecency.js +12 -4
  9. package/dist/ConflictRecency.js.map +1 -1
  10. package/dist/ConnectorFactory.d.ts +1 -1
  11. package/dist/ConnectorFactory.js +2 -2
  12. package/dist/ContentHash.d.ts +6 -0
  13. package/dist/ContentHash.d.ts.map +1 -1
  14. package/dist/ContentHash.js +15 -3
  15. package/dist/ContentHash.js.map +1 -1
  16. package/dist/CustomColumnPromotion.d.ts +12 -0
  17. package/dist/CustomColumnPromotion.d.ts.map +1 -1
  18. package/dist/CustomColumnPromotion.js +32 -8
  19. package/dist/CustomColumnPromotion.js.map +1 -1
  20. package/dist/CustomOverflow.d.ts +8 -0
  21. package/dist/CustomOverflow.d.ts.map +1 -1
  22. package/dist/CustomOverflow.js +20 -4
  23. package/dist/CustomOverflow.js.map +1 -1
  24. package/dist/EnrichSchemaConstraints.d.ts +1 -1
  25. package/dist/EnrichSchemaConstraints.js +2 -2
  26. package/dist/FieldMappingEngine.d.ts +3 -3
  27. package/dist/FieldMappingEngine.js +11 -11
  28. package/dist/HashDiff.d.ts +8 -0
  29. package/dist/HashDiff.d.ts.map +1 -1
  30. package/dist/HashDiff.js +22 -6
  31. package/dist/HashDiff.js.map +1 -1
  32. package/dist/IntegrationActionGenerator.d.ts +1 -1
  33. package/dist/IntegrationActionGenerator.js +2 -2
  34. package/dist/IntegrationConnectorCreationPipeline.d.ts +6 -6
  35. package/dist/IntegrationConnectorCreationPipeline.js +14 -14
  36. package/dist/IntegrationEngine.d.ts +38 -38
  37. package/dist/IntegrationEngine.js +132 -132
  38. package/dist/IntegrationSchemaSync.d.ts +47 -4
  39. package/dist/IntegrationSchemaSync.d.ts.map +1 -1
  40. package/dist/IntegrationSchemaSync.js +62 -30
  41. package/dist/IntegrationSchemaSync.js.map +1 -1
  42. package/dist/KeySerialization.d.ts +2 -0
  43. package/dist/KeySerialization.d.ts.map +1 -1
  44. package/dist/KeySerialization.js +5 -1
  45. package/dist/KeySerialization.js.map +1 -1
  46. package/dist/MatchEngine.d.ts +11 -11
  47. package/dist/MatchEngine.js +33 -33
  48. package/dist/RecordFlatten.d.ts +5 -1
  49. package/dist/RecordFlatten.d.ts.map +1 -1
  50. package/dist/RecordFlatten.js +11 -3
  51. package/dist/RecordFlatten.js.map +1 -1
  52. package/dist/RecordMapBatch.js +2 -2
  53. package/dist/StreamingDiscovery.d.ts +11 -0
  54. package/dist/StreamingDiscovery.d.ts.map +1 -1
  55. package/dist/StreamingDiscovery.js +22 -6
  56. package/dist/StreamingDiscovery.js.map +1 -1
  57. package/dist/SyncLogger.d.ts +15 -3
  58. package/dist/SyncLogger.d.ts.map +1 -1
  59. package/dist/SyncLogger.js +33 -9
  60. package/dist/SyncLogger.js.map +1 -1
  61. package/dist/WatermarkService.d.ts +2 -2
  62. package/dist/WatermarkService.js +4 -4
  63. package/dist/auth-helpers/BasicAuthHeaderBuilder.d.ts +6 -0
  64. package/dist/auth-helpers/BasicAuthHeaderBuilder.d.ts.map +1 -1
  65. package/dist/auth-helpers/BasicAuthHeaderBuilder.js +10 -2
  66. package/dist/auth-helpers/BasicAuthHeaderBuilder.js.map +1 -1
  67. package/dist/auth-helpers/OAuth1aSigner.d.ts +2 -0
  68. package/dist/auth-helpers/OAuth1aSigner.d.ts.map +1 -1
  69. package/dist/auth-helpers/OAuth1aSigner.js +10 -6
  70. package/dist/auth-helpers/OAuth1aSigner.js.map +1 -1
  71. package/dist/auth-helpers/OAuth2TokenManager.d.ts +2 -2
  72. package/dist/auth-helpers/OAuth2TokenManager.js +4 -4
  73. package/dist/auth-helpers/index.d.ts +2 -2
  74. package/dist/auth-helpers/index.d.ts.map +1 -1
  75. package/dist/auth-helpers/index.js +2 -2
  76. package/dist/auth-helpers/index.js.map +1 -1
  77. package/dist/index.d.ts +8 -8
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +8 -8
  80. package/dist/index.js.map +1 -1
  81. package/dist/prefetchFilter.d.ts +4 -0
  82. package/dist/prefetchFilter.d.ts.map +1 -1
  83. package/dist/prefetchFilter.js +10 -2
  84. package/dist/prefetchFilter.js.map +1 -1
  85. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"KeySerialization.d.ts","sourceRoot":"","sources":["../src/KeySerialization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQxD"}
1
+ {"version":3,"file":"KeySerialization.d.ts","sourceRoot":"","sources":["../src/KeySerialization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAQxD;AAED,iDAAiD;AACjD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAExD"}
@@ -17,7 +17,7 @@
17
17
  * - plain object / array (anything `typeof === 'object'` that is not a `Date`) → `JSON.stringify`.
18
18
  * - everything else (string / number / boolean / Date / bigint / symbol) → `String(value)`.
19
19
  */
20
- export function serializeKeyValue(value) {
20
+ export function SerializeKeyValue(value) {
21
21
  if (value == null) {
22
22
  return '';
23
23
  }
@@ -26,4 +26,8 @@ export function serializeKeyValue(value) {
26
26
  }
27
27
  return String(value);
28
28
  }
29
+ /** @deprecated Use {@link SerializeKeyValue}. */
30
+ export function serializeKeyValue(value) {
31
+ return SerializeKeyValue(value);
32
+ }
29
33
  //# sourceMappingURL=KeySerialization.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KeySerialization.js","sourceRoot":"","sources":["../src/KeySerialization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC5C,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACd,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,YAAY,IAAI,CAAC,EAAE,CAAC;QACxD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC"}
1
+ {"version":3,"file":"KeySerialization.js","sourceRoot":"","sources":["../src/KeySerialization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC5C,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACd,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,YAAY,IAAI,CAAC,EAAE,CAAC;QACxD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC5C,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC"}
@@ -33,7 +33,7 @@ export declare class MatchEngine {
33
33
  * treat every record as unmapped and turn an incremental sync into a batch of duplicate
34
34
  * creates, so the two are kept distinct all the way down.
35
35
  */
36
- private PrefetchBatchLookups;
36
+ private prefetchBatchLookups;
37
37
  /**
38
38
  * The read that resolves an entire batch of external IDs against the record map, or null when
39
39
  * the batch carries no usable external ID (nothing to ask, so no query is issued).
@@ -70,15 +70,15 @@ export declare class MatchEngine {
70
70
  /**
71
71
  * Resolves a single record by checking for an existing MJ match.
72
72
  */
73
- private ResolveSingleRecord;
73
+ private resolveSingleRecord;
74
74
  /**
75
75
  * Handles records marked as deleted in the external system.
76
76
  */
77
- private ResolveDeletedRecord;
77
+ private resolveDeletedRecord;
78
78
  /**
79
79
  * Determines change type for a record that matches an existing MJ record.
80
80
  */
81
- private ResolveExistingRecord;
81
+ private resolveExistingRecord;
82
82
  /**
83
83
  * Attempts to find an existing MJ record by identity (PK) or, failing that, by the
84
84
  * configured key fields — then falls back to the CompanyIntegrationRecordMap.
@@ -94,12 +94,12 @@ export declare class MatchEngine {
94
94
  * see `LoadAllRecordMaps`) re-CREATED a row whose PK already existed. Integration shadow
95
95
  * tables are exactly this shape: a single soft PK holding the external ID.
96
96
  */
97
- private FindExistingRecord;
97
+ private findExistingRecord;
98
98
  /**
99
99
  * Answers the identity/key lookup from the batch prefetch when it can, and only issues the
100
100
  * per-record query when the prefetch neither found the record nor proved it absent.
101
101
  */
102
- private LookupByKeyFields;
102
+ private lookupByKeyFields;
103
103
  /**
104
104
  * Returns the entity's primary-key fields (soft PKs included — integration shadow tables
105
105
  * carry no physical key, so `PrimaryKeys` is populated from `additionalSchemaInfo` and is
@@ -128,7 +128,7 @@ export declare class MatchEngine {
128
128
  * The returned ID is always the PK values in `PrimaryKeys` order, '|'-joined — the same
129
129
  * format `ExternalID`/`EntityRecordID` use — so the caller can load the row directly.
130
130
  */
131
- private FindByKeyFields;
131
+ private findByKeyFields;
132
132
  /**
133
133
  * Builds the field/value criteria that identify a record, applying the item-3 identity rule:
134
134
  * a COMPLETE primary key matches on the PK alone; otherwise the configured key fields plus
@@ -137,7 +137,7 @@ export declare class MatchEngine {
137
137
  * Field/value pairs (rather than pre-rendered SQL) so the same criteria can be rendered as a
138
138
  * filter clause AND used as a local lookup key when a whole batch is resolved in one query.
139
139
  */
140
- private BuildMatchCriteria;
140
+ private buildMatchCriteria;
141
141
  /**
142
142
  * Quotes a value as a SQL string literal for a `RunView` `ExtraFilter`.
143
143
  *
@@ -161,7 +161,7 @@ export declare class MatchEngine {
161
161
  * identifiers break on a column named for a reserved word (e.g. a soft PK named
162
162
  * `open`/`order`); brackets would fix SQL Server but break Postgres, so double-quote.
163
163
  */
164
- private CriteriaToSQL;
164
+ private criteriaToSQL;
165
165
  /**
166
166
  * Order-independent local lookup key for a criteria set (and for a row read back for it).
167
167
  *
@@ -170,7 +170,7 @@ export declare class MatchEngine {
170
170
  * = `C` and field `A` = `B C` both render `A B C` — and since this key is what decides which
171
171
  * row answers which criteria, a collision attributes a row to the wrong record.
172
172
  */
173
- private CriteriaKey;
173
+ private criteriaKey;
174
174
  /**
175
175
  * Resolves the identity/key lookup for a WHOLE batch in one query per criteria shape,
176
176
  * instead of one query per record (tasks.md PR 2 item 5).
@@ -203,6 +203,6 @@ export declare class MatchEngine {
203
203
  /**
204
204
  * Checks the CompanyIntegrationRecordMap for a previous external↔MJ mapping.
205
205
  */
206
- private FindRecordMapEntry;
206
+ private findRecordMapEntry;
207
207
  }
208
208
  //# sourceMappingURL=MatchEngine.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { DatabaseProviderBase, Metadata, RunView } from '@memberjunction/core';
2
- import { serializeKeyValue } from './KeySerialization.js';
3
- import { quoteTextLiteral } from './prefetchFilter.js';
2
+ import { SerializeKeyValue } from './KeySerialization.js';
3
+ import { QuoteTextLiteral } from './prefetchFilter.js';
4
4
  /**
5
5
  * Folds an external ID the way a default SQL Server collation folds it for `=`
6
6
  * (`SQL_Latin1_General_CP1_CI_AS`: case-insensitive, trailing blanks ignored).
@@ -58,10 +58,10 @@ export class MatchEngine {
58
58
  // criteria-shape group. These are independent queries with no data dependency between
59
59
  // them, which is exactly what RunViews is for — issuing them separately (or as a
60
60
  // Promise.all of RunView calls) pays a round trip per leg for no reason.
61
- const { MapIndex: mapIndex, KeyIndex: keyIndex } = await this.PrefetchBatchLookups(records, entityMap, keyFields, contextUser);
61
+ const { MapIndex: mapIndex, KeyIndex: keyIndex } = await this.prefetchBatchLookups(records, entityMap, keyFields, contextUser);
62
62
  const results = [];
63
63
  for (const record of records) {
64
- const resolved = await this.ResolveSingleRecord(record, entityMap, keyFields, conflictResolution, contextUser, mapIndex, keyIndex);
64
+ const resolved = await this.resolveSingleRecord(record, entityMap, keyFields, conflictResolution, contextUser, mapIndex, keyIndex);
65
65
  results.push(resolved);
66
66
  }
67
67
  return results;
@@ -78,7 +78,7 @@ export class MatchEngine {
78
78
  * treat every record as unmapped and turn an incremental sync into a batch of duplicate
79
79
  * creates, so the two are kept distinct all the way down.
80
80
  */
81
- async PrefetchBatchLookups(records, entityMap, keyFields, contextUser) {
81
+ async prefetchBatchLookups(records, entityMap, keyFields, contextUser) {
82
82
  const mapParams = this.buildRecordMapViewParams(records, entityMap);
83
83
  const keyGroups = this.buildKeyMatchGroups(records, keyFields);
84
84
  const emptyMapIndex = { Exact: new Map(), Normalized: new Map(), Ambiguous: new Set() };
@@ -189,21 +189,21 @@ export class MatchEngine {
189
189
  /**
190
190
  * Resolves a single record by checking for an existing MJ match.
191
191
  */
192
- async ResolveSingleRecord(record, entityMap, keyFields, conflictResolution, contextUser, mapIndex, keyIndex) {
192
+ async resolveSingleRecord(record, entityMap, keyFields, conflictResolution, contextUser, mapIndex, keyIndex) {
193
193
  if (record.ExternalRecord.IsDeleted) {
194
- return this.ResolveDeletedRecord(record, entityMap, contextUser, mapIndex);
194
+ return this.resolveDeletedRecord(record, entityMap, contextUser, mapIndex);
195
195
  }
196
- const existingID = await this.FindExistingRecord(record, entityMap, keyFields, contextUser, mapIndex, keyIndex);
196
+ const existingID = await this.findExistingRecord(record, entityMap, keyFields, contextUser, mapIndex, keyIndex);
197
197
  if (existingID) {
198
- return this.ResolveExistingRecord(record, existingID, conflictResolution);
198
+ return this.resolveExistingRecord(record, existingID, conflictResolution);
199
199
  }
200
200
  return { ...record, ChangeType: 'Create' };
201
201
  }
202
202
  /**
203
203
  * Handles records marked as deleted in the external system.
204
204
  */
205
- async ResolveDeletedRecord(record, entityMap, contextUser, mapIndex) {
206
- const existingID = await this.FindRecordMapEntry(entityMap.CompanyIntegrationID, record.ExternalRecord.ExternalID, entityMap.EntityID, contextUser, mapIndex);
205
+ async resolveDeletedRecord(record, entityMap, contextUser, mapIndex) {
206
+ const existingID = await this.findRecordMapEntry(entityMap.CompanyIntegrationID, record.ExternalRecord.ExternalID, entityMap.EntityID, contextUser, mapIndex);
207
207
  if (existingID) {
208
208
  return { ...record, ChangeType: 'Delete', MatchedMJRecordID: existingID };
209
209
  }
@@ -212,7 +212,7 @@ export class MatchEngine {
212
212
  /**
213
213
  * Determines change type for a record that matches an existing MJ record.
214
214
  */
215
- ResolveExistingRecord(record, existingID, conflictResolution) {
215
+ resolveExistingRecord(record, existingID, conflictResolution) {
216
216
  if (conflictResolution === 'Manual') {
217
217
  return { ...record, ChangeType: 'Skip', MatchedMJRecordID: existingID };
218
218
  }
@@ -233,23 +233,23 @@ export class MatchEngine {
233
233
  * see `LoadAllRecordMaps`) re-CREATED a row whose PK already existed. Integration shadow
234
234
  * tables are exactly this shape: a single soft PK holding the external ID.
235
235
  */
236
- async FindExistingRecord(record, entityMap, keyFields, contextUser, mapIndex, keyIndex) {
236
+ async findExistingRecord(record, entityMap, keyFields, contextUser, mapIndex, keyIndex) {
237
237
  if (keyFields.length > 0 || this.hasCompleteMappedPrimaryKey(record)) {
238
- const idByKeys = await this.LookupByKeyFields(record, keyFields, contextUser, keyIndex);
238
+ const idByKeys = await this.lookupByKeyFields(record, keyFields, contextUser, keyIndex);
239
239
  if (idByKeys)
240
240
  return idByKeys;
241
241
  }
242
- return this.FindRecordMapEntry(entityMap.CompanyIntegrationID, record.ExternalRecord.ExternalID, entityMap.EntityID, contextUser, mapIndex);
242
+ return this.findRecordMapEntry(entityMap.CompanyIntegrationID, record.ExternalRecord.ExternalID, entityMap.EntityID, contextUser, mapIndex);
243
243
  }
244
244
  /**
245
245
  * Answers the identity/key lookup from the batch prefetch when it can, and only issues the
246
246
  * per-record query when the prefetch neither found the record nor proved it absent.
247
247
  */
248
- async LookupByKeyFields(record, keyFields, contextUser, keyIndex) {
248
+ async lookupByKeyFields(record, keyFields, contextUser, keyIndex) {
249
249
  if (keyIndex) {
250
- const criteria = this.BuildMatchCriteria(record, keyFields);
250
+ const criteria = this.buildMatchCriteria(record, keyFields);
251
251
  if (criteria) {
252
- const key = this.CriteriaKey(criteria.Fields, criteria.Values);
252
+ const key = this.criteriaKey(criteria.Fields, criteria.Values);
253
253
  const matched = keyIndex.Matched.get(key);
254
254
  if (matched)
255
255
  return matched;
@@ -257,7 +257,7 @@ export class MatchEngine {
257
257
  return null;
258
258
  }
259
259
  }
260
- return this.FindByKeyFields(record, keyFields, contextUser);
260
+ return this.findByKeyFields(record, keyFields, contextUser);
261
261
  }
262
262
  /**
263
263
  * Returns the entity's primary-key fields (soft PKs included — integration shadow tables
@@ -295,15 +295,15 @@ export class MatchEngine {
295
295
  * The returned ID is always the PK values in `PrimaryKeys` order, '|'-joined — the same
296
296
  * format `ExternalID`/`EntityRecordID` use — so the caller can load the row directly.
297
297
  */
298
- async FindByKeyFields(record, keyFields, contextUser) {
298
+ async findByKeyFields(record, keyFields, contextUser) {
299
299
  const pkFields = this.primaryKeyFieldsFor(record.MJEntityName);
300
- const match = this.BuildMatchCriteria(record, keyFields);
300
+ const match = this.buildMatchCriteria(record, keyFields);
301
301
  if (!match)
302
302
  return null;
303
303
  const rv = new RunView();
304
304
  const result = await rv.RunView({
305
305
  EntityName: record.MJEntityName,
306
- ExtraFilter: this.CriteriaToSQL(match),
306
+ ExtraFilter: this.criteriaToSQL(match),
307
307
  Fields: pkFields.map(f => f.Name),
308
308
  MaxRows: 1,
309
309
  ResultType: 'simple',
@@ -322,7 +322,7 @@ export class MatchEngine {
322
322
  * Field/value pairs (rather than pre-rendered SQL) so the same criteria can be rendered as a
323
323
  * filter clause AND used as a local lookup key when a whole batch is resolved in one query.
324
324
  */
325
- BuildMatchCriteria(record, keyFields) {
325
+ buildMatchCriteria(record, keyFields) {
326
326
  const pkFields = this.primaryKeyFieldsFor(record.MJEntityName);
327
327
  if (pkFields.length === 0)
328
328
  return null;
@@ -334,7 +334,7 @@ export class MatchEngine {
334
334
  if (value == null)
335
335
  continue;
336
336
  pk.Fields.push(pkField.Name);
337
- pk.Values.push(serializeKeyValue(value));
337
+ pk.Values.push(SerializeKeyValue(value));
338
338
  }
339
339
  // Complete PK → identity match, on the PK alone. Configured key fields are deliberately
340
340
  // NOT and-ed in here: a key field that disagrees with the PK would turn a correct
@@ -355,7 +355,7 @@ export class MatchEngine {
355
355
  const value = record.MappedFields[kf.DestinationFieldName];
356
356
  if (value == null)
357
357
  continue;
358
- add(kf.DestinationFieldName, serializeKeyValue(value));
358
+ add(kf.DestinationFieldName, SerializeKeyValue(value));
359
359
  }
360
360
  for (let i = 0; i < pk.Fields.length; i++)
361
361
  add(pk.Fields[i], pk.Values[i]);
@@ -378,7 +378,7 @@ export class MatchEngine {
378
378
  quoteLiteral(value) {
379
379
  const provider = this.ProviderToUse;
380
380
  return provider instanceof DatabaseProviderBase
381
- ? quoteTextLiteral(value, provider.Dialect)
381
+ ? QuoteTextLiteral(value, provider.Dialect)
382
382
  : `'${value.replace(/'/g, "''")}'`;
383
383
  }
384
384
  /**
@@ -389,7 +389,7 @@ export class MatchEngine {
389
389
  * identifiers break on a column named for a reserved word (e.g. a soft PK named
390
390
  * `open`/`order`); brackets would fix SQL Server but break Postgres, so double-quote.
391
391
  */
392
- CriteriaToSQL(criteria) {
392
+ criteriaToSQL(criteria) {
393
393
  return criteria.Fields
394
394
  .map((f, i) => `"${f}" = ${this.quoteLiteral(criteria.Values[i])}`)
395
395
  .join(' AND ');
@@ -402,7 +402,7 @@ export class MatchEngine {
402
402
  * = `C` and field `A` = `B C` both render `A B C` — and since this key is what decides which
403
403
  * row answers which criteria, a collision attributes a row to the wrong record.
404
404
  */
405
- CriteriaKey(fields, values) {
405
+ criteriaKey(fields, values) {
406
406
  return fields
407
407
  .map((f, i) => [f, values[i]])
408
408
  .sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))
@@ -437,7 +437,7 @@ export class MatchEngine {
437
437
  continue;
438
438
  if (keyFields.length === 0 && !this.hasCompleteMappedPrimaryKey(record))
439
439
  continue;
440
- const criteria = this.BuildMatchCriteria(record, keyFields);
440
+ const criteria = this.buildMatchCriteria(record, keyFields);
441
441
  if (!criteria)
442
442
  continue;
443
443
  // `\0`-delimited for the same reason CriteriaKey is: entity `AB` + field `C` and
@@ -457,7 +457,7 @@ export class MatchEngine {
457
457
  // Distinct clause sets only — a batch commonly repeats the same external record.
458
458
  const clauses = new Map();
459
459
  for (const c of group.Criteria)
460
- clauses.set(this.CriteriaKey(c.Fields, c.Values), c);
460
+ clauses.set(this.criteriaKey(c.Fields, c.Values), c);
461
461
  const lookupFields = group.Criteria[0].Fields;
462
462
  groups.push({
463
463
  PKFields: pkFields,
@@ -466,7 +466,7 @@ export class MatchEngine {
466
466
  Params: {
467
467
  EntityName: group.EntityName,
468
468
  ExtraFilter: Array.from(clauses.values())
469
- .map(c => `(${this.CriteriaToSQL(c)})`)
469
+ .map(c => `(${this.criteriaToSQL(c)})`)
470
470
  .join(' OR '),
471
471
  Fields: Array.from(new Set([...pkFields.map(f => f.Name), ...lookupFields])),
472
472
  IgnoreMaxRows: true, // a batch's matches can exceed the entity's default row cap
@@ -491,7 +491,7 @@ export class MatchEngine {
491
491
  return null;
492
492
  const rows = result.Results;
493
493
  for (const row of rows) {
494
- const rowKey = this.CriteriaKey(group.LookupFields, group.LookupFields.map(f => serializeKeyValue(row[f])));
494
+ const rowKey = this.criteriaKey(group.LookupFields, group.LookupFields.map(f => SerializeKeyValue(row[f])));
495
495
  if (index.Matched.has(rowKey))
496
496
  continue; // first row wins, as MaxRows:1 did
497
497
  index.Matched.set(rowKey, group.PKFields.map(f => row[f.Name] ?? '').join('|'));
@@ -507,7 +507,7 @@ export class MatchEngine {
507
507
  /**
508
508
  * Checks the CompanyIntegrationRecordMap for a previous external↔MJ mapping.
509
509
  */
510
- async FindRecordMapEntry(companyIntegrationID, externalID, entityID, contextUser, mapIndex) {
510
+ async findRecordMapEntry(companyIntegrationID, externalID, entityID, contextUser, mapIndex) {
511
511
  // The batch prefetch read every mapping for this batch's external IDs in one query, so
512
512
  // a hit here is the same answer the per-record query would give.
513
513
  //
@@ -34,16 +34,20 @@ export interface FlattenOptions {
34
34
  /** Maximum nesting depth to flatten; objects deeper than this are kept as leaf blobs. Default 4. */
35
35
  MaxDepth?: number;
36
36
  /** Invoked when a flattened key collides with an existing key (first value wins). For diagnostics. */
37
- onCollision?: (key: string) => void;
37
+ OnCollision?: (key: string) => void;
38
38
  }
39
39
  /**
40
40
  * Returns true if `raw` contains at least one nested plain-object value — i.e. flattening would
41
41
  * change it. Cheap top-level check; lets callers skip the allocation for the flat-record common case.
42
42
  */
43
+ export declare function HasNestedObject(raw: Record<string, unknown>): boolean;
44
+ /** @deprecated Use {@link HasNestedObject}. */
43
45
  export declare function hasNestedObject(raw: Record<string, unknown>): boolean;
44
46
  /**
45
47
  * Flatten a record's nested plain-objects into `parent<sep>child` scalar keys. Pure; returns a new
46
48
  * object. A record with no nested objects is returned shallow-copied + unchanged in shape.
47
49
  */
50
+ export declare function FlattenRecord(raw: Record<string, unknown>, opts?: FlattenOptions): Record<string, unknown>;
51
+ /** @deprecated Use {@link FlattenRecord}. */
48
52
  export declare function flattenRecord(raw: Record<string, unknown>, opts?: FlattenOptions): Record<string, unknown>;
49
53
  //# sourceMappingURL=RecordFlatten.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RecordFlatten.d.ts","sourceRoot":"","sources":["../src/RecordFlatten.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,cAAc;IAC3B,sEAAsE;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MAAM,EAAE,OAAO,CAAC,EAC5B,IAAI,GAAE,cAAmB,GAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB"}
@@ -11,24 +11,28 @@ function isPlainObject(value) {
11
11
  * Returns true if `raw` contains at least one nested plain-object value — i.e. flattening would
12
12
  * change it. Cheap top-level check; lets callers skip the allocation for the flat-record common case.
13
13
  */
14
- export function hasNestedObject(raw) {
14
+ export function HasNestedObject(raw) {
15
15
  for (const v of Object.values(raw)) {
16
16
  if (isPlainObject(v))
17
17
  return true;
18
18
  }
19
19
  return false;
20
20
  }
21
+ /** @deprecated Use {@link HasNestedObject}. */
22
+ export function hasNestedObject(raw) {
23
+ return HasNestedObject(raw);
24
+ }
21
25
  /**
22
26
  * Flatten a record's nested plain-objects into `parent<sep>child` scalar keys. Pure; returns a new
23
27
  * object. A record with no nested objects is returned shallow-copied + unchanged in shape.
24
28
  */
25
- export function flattenRecord(raw, opts = {}) {
29
+ export function FlattenRecord(raw, opts = {}) {
26
30
  const sep = opts.Separator ?? DEFAULT_SEPARATOR;
27
31
  const maxDepth = opts.MaxDepth ?? DEFAULT_MAX_DEPTH;
28
32
  const out = {};
29
33
  const put = (key, value) => {
30
34
  if (Object.prototype.hasOwnProperty.call(out, key)) {
31
- opts.onCollision?.(key);
35
+ opts.OnCollision?.(key);
32
36
  return; // first value wins
33
37
  }
34
38
  out[key] = value;
@@ -47,4 +51,8 @@ export function flattenRecord(raw, opts = {}) {
47
51
  recurse(raw, '', 0);
48
52
  return out;
49
53
  }
54
+ /** @deprecated Use {@link FlattenRecord}. */
55
+ export function flattenRecord(raw, opts = {}) {
56
+ return FlattenRecord(raw, opts);
57
+ }
50
58
  //# sourceMappingURL=RecordFlatten.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RecordFlatten.js","sourceRoot":"","sources":["../src/RecordFlatten.ts"],"names":[],"mappings":"AAuCA,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,iBAAiB,GAAG,CA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AAE,IAAI,CAAC,CAAC;AACpC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { DatabaseProviderBase, RunView } from '@memberjunction/core';
2
- import { quoteTextLiteral } from './prefetchFilter.js';
2
+ import { QuoteTextLiteral } from './prefetchFilter.js';
3
3
  /**
4
4
  * Batched writer for `MJ: Company Integration Record Maps`.
5
5
  *
@@ -188,7 +188,7 @@ export class RecordMapBatch {
188
188
  return null; // no dialect to quote with — the per-row path resolves each row itself
189
189
  // The external IDs are the only free-text values here (the other two are UUIDs), and they
190
190
  // are compared against an nvarchar column — see `quoteTextLiteral`.
191
- const inList = chunk.map(m => quoteTextLiteral(m.ExternalID, q)).join(',');
191
+ const inList = chunk.map(m => QuoteTextLiteral(m.ExternalID, q)).join(',');
192
192
  const rv = new RunView();
193
193
  const result = await rv.RunView({
194
194
  EntityName: 'MJ: Company Integration Record Maps',
@@ -73,6 +73,8 @@ export interface StreamDiscoveryResult {
73
73
  * until exhaustion or the time budget. Read-only; the caller supplies whatever read-only fetch
74
74
  * yields the records (no save, no ack happens here).
75
75
  */
76
+ export declare function DiscoverFromStream(records: AsyncIterable<Record<string, unknown>> | Iterable<Record<string, unknown>>, opts?: StreamDiscoveryOptions): Promise<StreamDiscoveryResult>;
77
+ /** @deprecated Use {@link DiscoverFromStream}. */
76
78
  export declare function discoverFromStream(records: AsyncIterable<Record<string, unknown>> | Iterable<Record<string, unknown>>, opts?: StreamDiscoveryOptions): Promise<StreamDiscoveryResult>;
77
79
  /** Options for the data-informed PK pick. */
78
80
  export interface PkPickOptions {
@@ -120,6 +122,8 @@ export declare const PK_STAT_MIN_ROWS_FOR_SIGNIFICANCE = 50;
120
122
  * all-distinct over a large N is not chance). Several candidates → naming breaks the tie if it can;
121
123
  * otherwise it's flagged ambiguous for the LLM tiebreaker. Zero candidates → no PK (no fabrication).
122
124
  */
125
+ export declare function PickPrimaryKeyFromStats(columns: DiscoveredColumnStat[], opts?: PkPickOptions): PkStatVerdict;
126
+ /** @deprecated Use {@link PickPrimaryKeyFromStats}. */
123
127
  export declare function pickPrimaryKeyFromStats(columns: DiscoveredColumnStat[], opts?: PkPickOptions): PkStatVerdict;
124
128
  /** The composite-key verdict — a provable multi-column identity, or null when none exists in the sample. */
125
129
  export interface CompositePkVerdict {
@@ -142,6 +146,8 @@ export interface CompositePkVerdict {
142
146
  * globally-minimal one — minimality is a nice-to-have the identity path doesn't need. A significance
143
147
  * gate (MinRowsForSignificance) keeps a small-sample "uniqueness" from being a fluke.
144
148
  */
149
+ export declare function PickCompositeKeyFromStats(columns: DiscoveredColumnStat[], rowSamples: Array<Record<string, string>>, opts?: PkPickOptions): CompositePkVerdict;
150
+ /** @deprecated Use {@link PickCompositeKeyFromStats}. */
145
151
  export declare function pickCompositeKeyFromStats(columns: DiscoveredColumnStat[], rowSamples: Array<Record<string, string>>, opts?: PkPickOptions): CompositePkVerdict;
146
152
  /** The unified key verdict — the chosen identity columns (1 = single PK, ≥2 = composite), or null. */
147
153
  export interface KeyVerdict {
@@ -155,6 +161,11 @@ export interface KeyVerdict {
155
161
  * ({@link subsetKeyness}) applied to the subset's combined tuple — no arbitrary distinct-ratio. If NO
156
162
  * size yields a provable key, returns null (the object is honestly keyless — never a fabricated key).
157
163
  */
164
+ export declare function PickKeyFromStats(columns: DiscoveredColumnStat[], rowSamples: Array<Record<string, string>>, opts?: PkPickOptions & {
165
+ MaxKeyColumns?: number;
166
+ MaxCandidates?: number;
167
+ }): KeyVerdict;
168
+ /** @deprecated Use {@link PickKeyFromStats}. */
158
169
  export declare function pickKeyFromStats(columns: DiscoveredColumnStat[], rowSamples: Array<Record<string, string>>, opts?: PkPickOptions & {
159
170
  MaxKeyColumns?: number;
160
171
  MaxCandidates?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"StreamingDiscovery.d.ts","sourceRoot":"","sources":["../src/StreamingDiscovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAA4B,KAAK,kBAAkB,EAAE,MAAM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AE,MAAM,CAAA;CAAO,GAC9E,UAAU,CAEZ"}
@@ -14,7 +14,7 @@
14
14
  *
15
15
  * Pure + clock-injectable, so it's deterministically testable. Reuses {@link inferColumnTypeFromSamples}.
16
16
  */
17
- import { inferColumnTypeFromStats } from './CustomColumnPromotion.js';
17
+ import { InferColumnTypeFromStats } from './CustomColumnPromotion.js';
18
18
  /** Positive integer from an env var, falling back when unset/invalid. */
19
19
  function envInt(name, fallback) {
20
20
  const v = parseInt(process.env[name] ?? '', 10);
@@ -32,7 +32,7 @@ const DEFAULT_COMPOSITE_SAMPLE_ROW_CAP = envInt('MJ_INTEGRATION_DISCOVERY_COMPOS
32
32
  * until exhaustion or the time budget. Read-only; the caller supplies whatever read-only fetch
33
33
  * yields the records (no save, no ack happens here).
34
34
  */
35
- export async function discoverFromStream(records, opts = {}) {
35
+ export async function DiscoverFromStream(records, opts = {}) {
36
36
  const timeBudgetMs = opts.TimeBudgetMs ?? DEFAULT_TIME_BUDGET_MS;
37
37
  const sampleCap = opts.SampleValueCap ?? DEFAULT_SAMPLE_VALUE_CAP;
38
38
  const distinctCap = opts.MaxDistinctTracked ?? DEFAULT_MAX_DISTINCT_TRACKED;
@@ -71,10 +71,14 @@ export async function discoverFromStream(records, opts = {}) {
71
71
  MaxObservedLength: e.maxLen,
72
72
  // Width from the TRUE observed max, not the capped sample — the rsuplan "largest string"
73
73
  // stat. A wide value in an unsampled row would otherwise silently under-size the column.
74
- Inferred: inferColumnTypeFromStats(e.samples, e.maxLen),
74
+ Inferred: InferColumnTypeFromStats(e.samples, e.maxLen),
75
75
  }));
76
76
  return { Columns: columns, RowsScanned: totalRows, StoppedReason: stoppedReason, RowSamples: rowSamples };
77
77
  }
78
+ /** @deprecated Use {@link DiscoverFromStream}. */
79
+ export async function discoverFromStream(records, opts = {}) {
80
+ return DiscoverFromStream(records, opts);
81
+ }
78
82
  /** Folds one record into the accumulator — O(columns), bounded memory. */
79
83
  function accumulateRecord(record, acc, sampleCap, distinctCap) {
80
84
  for (const [key, value] of Object.entries(record)) {
@@ -128,7 +132,7 @@ const SOFT_NEAR_UNIQUE_RATIO = 0.9;
128
132
  * all-distinct over a large N is not chance). Several candidates → naming breaks the tie if it can;
129
133
  * otherwise it's flagged ambiguous for the LLM tiebreaker. Zero candidates → no PK (no fabrication).
130
134
  */
131
- export function pickPrimaryKeyFromStats(columns, opts = {}) {
135
+ export function PickPrimaryKeyFromStats(columns, opts = {}) {
132
136
  const minRows = opts.MinRowsForSignificance ?? PK_STAT_MIN_ROWS_FOR_SIGNIFICANCE;
133
137
  const candidates = columns.filter(c => c.TotalRows >= minRows &&
134
138
  c.Occurrences === c.TotalRows && // non-null on EVERY row
@@ -172,6 +176,10 @@ export function pickPrimaryKeyFromStats(columns, opts = {}) {
172
176
  }
173
177
  return { Field: null, UniqueCandidates: names, AmbiguousForLLM: true, Reason: `${candidates.length} equally-named unique columns — ambiguous; defer to the evidence-fed LLM tiebreaker.` };
174
178
  }
179
+ /** @deprecated Use {@link PickPrimaryKeyFromStats}. */
180
+ export function pickPrimaryKeyFromStats(columns, opts = {}) {
181
+ return PickPrimaryKeyFromStats(columns, opts);
182
+ }
175
183
  /**
176
184
  * COMPOSITE PK pick from streamed evidence — for objects whose identity is a multi-column combination
177
185
  * (no single column is unique). Statistics-first + provable-only, same philosophy as the single-column
@@ -187,7 +195,7 @@ export function pickPrimaryKeyFromStats(columns, opts = {}) {
187
195
  * globally-minimal one — minimality is a nice-to-have the identity path doesn't need. A significance
188
196
  * gate (MinRowsForSignificance) keeps a small-sample "uniqueness" from being a fluke.
189
197
  */
190
- export function pickCompositeKeyFromStats(columns, rowSamples, opts = {}) {
198
+ export function PickCompositeKeyFromStats(columns, rowSamples, opts = {}) {
191
199
  const minRows = opts.MinRowsForSignificance ?? PK_STAT_MIN_ROWS_FOR_SIGNIFICANCE;
192
200
  const n = rowSamples.length;
193
201
  if (n < minRows) {
@@ -222,6 +230,10 @@ export function pickCompositeKeyFromStats(columns, rowSamples, opts = {}) {
222
230
  }
223
231
  return { Fields: null, Reason: `No combination of the ${candidates.length} non-null columns is unique over ${n} rows — genuinely keyless; use the content-hash identity floor.` };
224
232
  }
233
+ /** @deprecated Use {@link PickCompositeKeyFromStats}. */
234
+ export function pickCompositeKeyFromStats(columns, rowSamples, opts = {}) {
235
+ return PickCompositeKeyFromStats(columns, rowSamples, opts);
236
+ }
225
237
  /** All size-k combinations of `items` (k small; callers cap the candidate list). */
226
238
  function* combinations(items, k) {
227
239
  if (k <= 0) {
@@ -268,7 +280,7 @@ function subsetKeyness(rowSamples, cols, minRows) {
268
280
  * ({@link subsetKeyness}) applied to the subset's combined tuple — no arbitrary distinct-ratio. If NO
269
281
  * size yields a provable key, returns null (the object is honestly keyless — never a fabricated key).
270
282
  */
271
- export function pickKeyFromStats(columns, rowSamples, opts = {}) {
283
+ export function PickKeyFromStats(columns, rowSamples, opts = {}) {
272
284
  const minRows = opts.MinRowsForSignificance ?? PK_STAT_MIN_ROWS_FOR_SIGNIFICANCE;
273
285
  const maxK = opts.MaxKeyColumns ?? 3;
274
286
  const maxCandidates = opts.MaxCandidates ?? 15;
@@ -298,6 +310,10 @@ export function pickKeyFromStats(columns, rowSamples, opts = {}) {
298
310
  }
299
311
  return { Fields: null, Reason: `No provable key at sizes 1..${Math.min(maxK, candidates.length)} over ${rowSamples.length} rows — every best contender's domain saturated (Chao1 D̂ ≤ n).` };
300
312
  }
313
+ /** @deprecated Use {@link PickKeyFromStats}. */
314
+ export function pickKeyFromStats(columns, rowSamples, opts = {}) {
315
+ return PickKeyFromStats(columns, rowSamples, opts);
316
+ }
301
317
  /** Stable string key for a value so distinct-counting is correct across primitives + objects. */
302
318
  function stableValueKey(value) {
303
319
  if (typeof value === 'object') {