@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.
- 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 +15 -3
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FieldTransformEngine } from '@memberjunction/global';
|
|
2
|
-
import {
|
|
2
|
+
import { ComputeUnmappedFields } from './CustomOverflow.js';
|
|
3
3
|
import { StripExcludedFields } from './SyncDirectives.js';
|
|
4
|
-
import {
|
|
4
|
+
import { FlattenRecord, HasNestedObject } from './RecordFlatten.js';
|
|
5
5
|
/**
|
|
6
6
|
* Engine responsible for applying field-level mappings and transformations from external records to
|
|
7
7
|
* MJ entity fields.
|
|
@@ -33,12 +33,12 @@ export class FieldMappingEngine {
|
|
|
33
33
|
Apply(records, fieldMaps, entityName, excludedSourceNames) {
|
|
34
34
|
const activeMaps = fieldMaps.filter(fm => fm.Status === 'Active');
|
|
35
35
|
const excluded = excludedSourceNames ?? EMPTY_EXCLUSIONS;
|
|
36
|
-
return records.map(record => this.
|
|
36
|
+
return records.map(record => this.mapSingleRecord(record, activeMaps, entityName, excluded));
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Maps a single external record through all active field mappings.
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
mapSingleRecord(record, fieldMaps, entityName, excludedSourceNames) {
|
|
42
42
|
// Field-level exclusions strip BEFORE flatten and BEFORE mapping, so an excluded
|
|
43
43
|
// key reaches neither MappedFields, nor computeUnmappedFields (-> CustomOverflow),
|
|
44
44
|
// nor the content hash (whose basis is MappedFields). Deactivating a field map
|
|
@@ -56,14 +56,14 @@ export class FieldMappingEngine {
|
|
|
56
56
|
// per-occurrence / per-version key → duplicate rows. Discovery flattens identically, so
|
|
57
57
|
// the field maps reference the flattened scalar names. A record with no nested objects
|
|
58
58
|
// passes through unchanged — every flat-record connector is a no-op here.
|
|
59
|
-
const ext =
|
|
60
|
-
? { ...record, Fields:
|
|
59
|
+
const ext = HasNestedObject(record.Fields)
|
|
60
|
+
? { ...record, Fields: FlattenRecord(record.Fields) }
|
|
61
61
|
: record;
|
|
62
62
|
const mappedFields = {};
|
|
63
63
|
const mappedSourceNames = new Set();
|
|
64
64
|
for (const fieldMap of fieldMaps) {
|
|
65
65
|
mappedSourceNames.add(fieldMap.SourceFieldName);
|
|
66
|
-
const value = this.
|
|
66
|
+
const value = this.applyFieldMapping(ext, fieldMap);
|
|
67
67
|
if (value !== undefined) {
|
|
68
68
|
mappedFields[fieldMap.DestinationFieldName] = value;
|
|
69
69
|
}
|
|
@@ -72,7 +72,7 @@ export class FieldMappingEngine {
|
|
|
72
72
|
// the result is empty (and discarded by the writer) in the common all-mapped case,
|
|
73
73
|
// so this adds no measurable cost to a customs-free sync. The engine parks any extras
|
|
74
74
|
// in the __mj_integration_CustomOverflow system column — see {@link CustomOverflow}.
|
|
75
|
-
const unmappedFields =
|
|
75
|
+
const unmappedFields = ComputeUnmappedFields(ext.Fields, mappedSourceNames);
|
|
76
76
|
return {
|
|
77
77
|
ExternalRecord: ext,
|
|
78
78
|
MJEntityName: entityName,
|
|
@@ -85,16 +85,16 @@ export class FieldMappingEngine {
|
|
|
85
85
|
* Applies a single field mapping, including the full transform pipeline (delegated to the shared
|
|
86
86
|
* {@link FieldTransformEngine}). Returns undefined if the field should be skipped (OnError: Skip).
|
|
87
87
|
*/
|
|
88
|
-
|
|
88
|
+
applyFieldMapping(record, fieldMap) {
|
|
89
89
|
const value = record.Fields[fieldMap.SourceFieldName];
|
|
90
|
-
const pipeline = this.
|
|
90
|
+
const pipeline = this.parseTransformPipeline(fieldMap.TransformPipeline);
|
|
91
91
|
const result = this.transformEngine.ExecutePipeline(value, record.Fields, pipeline);
|
|
92
92
|
return result.Skipped ? undefined : result.Value;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Parses the JSON transform pipeline string into typed TransformStep objects.
|
|
96
96
|
*/
|
|
97
|
-
|
|
97
|
+
parseTransformPipeline(pipelineJson) {
|
|
98
98
|
if (!pipelineJson || pipelineJson.trim() === '')
|
|
99
99
|
return [];
|
|
100
100
|
try {
|
package/dist/HashDiff.d.ts
CHANGED
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
* id, first 4 bytes folded modulo `partitionCount`, gives an even, deterministic spread. Default 256
|
|
27
27
|
* buckets is a sane balance (few enough rollups to store, fine-grained enough to skip most work).
|
|
28
28
|
*/
|
|
29
|
+
export declare function PartitionKeyForIdentity(identity: string, partitionCount?: number): string;
|
|
30
|
+
/** @deprecated Use {@link PartitionKeyForIdentity}. */
|
|
29
31
|
export declare function partitionKeyForIdentity(identity: string, partitionCount?: number): string;
|
|
30
32
|
/** Outcome of comparing a local partition→rollup map against a remote one. */
|
|
31
33
|
export type PartitionDiff = {
|
|
@@ -43,6 +45,8 @@ export type PartitionDiff = {
|
|
|
43
45
|
* the array of records that fall in that partition. Records arrive in the order encountered — order
|
|
44
46
|
* is preserved within a bucket and never relied upon by the rollup (see `partitionRollupHash`).
|
|
45
47
|
*/
|
|
48
|
+
export declare function PartitionRecords<T>(records: readonly T[], getKey: (record: T) => string, getPartition: (record: T) => string): Map<string, T[]>;
|
|
49
|
+
/** @deprecated Use {@link PartitionRecords}. */
|
|
46
50
|
export declare function partitionRecords<T>(records: readonly T[], getKey: (record: T) => string, getPartition: (record: T) => string): Map<string, T[]>;
|
|
47
51
|
/**
|
|
48
52
|
* ORDER-INDEPENDENT rollup of a partition's records into a single hash. Each record's mapped fields
|
|
@@ -54,6 +58,8 @@ export declare function partitionRecords<T>(records: readonly T[], getKey: (reco
|
|
|
54
58
|
* An empty partition rolls up to the SHA-256 of the empty string, a stable sentinel distinct from any
|
|
55
59
|
* non-empty partition.
|
|
56
60
|
*/
|
|
61
|
+
export declare function PartitionRollupHash<T>(records: readonly T[], fieldsOf: (record: T) => Record<string, unknown>): string;
|
|
62
|
+
/** @deprecated Use {@link PartitionRollupHash}. */
|
|
57
63
|
export declare function partitionRollupHash<T>(records: readonly T[], fieldsOf: (record: T) => Record<string, unknown>): string;
|
|
58
64
|
/**
|
|
59
65
|
* Compares two partition→rollup maps and reports which partitions diverge. Only `changed`/`added`/
|
|
@@ -64,5 +70,7 @@ export declare function partitionRollupHash<T>(records: readonly T[], fieldsOf:
|
|
|
64
70
|
* - `added` — key in `local` only.
|
|
65
71
|
* - `removed` — key in `remote` only.
|
|
66
72
|
*/
|
|
73
|
+
export declare function DiffPartitions(local: ReadonlyMap<string, string>, remote: ReadonlyMap<string, string>): PartitionDiff;
|
|
74
|
+
/** @deprecated Use {@link DiffPartitions}. */
|
|
67
75
|
export declare function diffPartitions(local: ReadonlyMap<string, string>, remote: ReadonlyMap<string, string>): PartitionDiff;
|
|
68
76
|
//# sourceMappingURL=HashDiff.d.ts.map
|
package/dist/HashDiff.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HashDiff.d.ts","sourceRoot":"","sources":["../src/HashDiff.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,SAAM,GAAG,MAAM,CAGtF;AAED,8EAA8E;AAC9E,MAAM,MAAM,aAAa,GAAG;IACxB,wFAAwF;IACxF,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,gFAAgF;IAChF,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,qFAAqF;IACrF,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAC9B,OAAO,EAAE,SAAS,CAAC,EAAE,EACrB,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,EAC7B,YAAY,EAAE,CAAC,MA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AgD;AAChD,wBAAgB,gBAAgB,CAAC,CAAC,EAC9B,OAAO,EAAE,SAAS,CAAC,EAAE,EACrB,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,EAC7B,YAAY,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,GACpC,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAElB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACjC,OAAO,EAAE,SAAS,CAAC,EAAE,EACrB,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjD,MAAM,CAOR;AAED,mDAAmD;AACnD,wBAAgB,mBAAmB,CAAC,CAAC,EACjC,OAAO,EAAE,SAAS,CAAC,EAAE,EACrB,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjD,MAAM,CAER;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC1B,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,aAAa,CAoBf;AAED,8CAA8C;AAC9C,wBAAgB,cAAc,CAC1B,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,aAAa,CAEf"}
|
package/dist/HashDiff.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import {
|
|
2
|
+
import { ComputeContentHash } from './ContentHash.js';
|
|
3
3
|
/**
|
|
4
4
|
* Partitioned / Merkle-style hash-diff (§7 "hash-diff / full-table compare to find changed
|
|
5
5
|
* partitions cheaply when no incremental cursor exists").
|
|
@@ -28,10 +28,14 @@ import { computeContentHash } from './ContentHash.js';
|
|
|
28
28
|
* id, first 4 bytes folded modulo `partitionCount`, gives an even, deterministic spread. Default 256
|
|
29
29
|
* buckets is a sane balance (few enough rollups to store, fine-grained enough to skip most work).
|
|
30
30
|
*/
|
|
31
|
-
export function
|
|
31
|
+
export function PartitionKeyForIdentity(identity, partitionCount = 256) {
|
|
32
32
|
const hex = createHash('sha256').update(identity).digest('hex').slice(0, 8);
|
|
33
33
|
return String(parseInt(hex, 16) % Math.max(1, partitionCount));
|
|
34
34
|
}
|
|
35
|
+
/** @deprecated Use {@link PartitionKeyForIdentity}. */
|
|
36
|
+
export function partitionKeyForIdentity(identity, partitionCount = 256) {
|
|
37
|
+
return PartitionKeyForIdentity(identity, partitionCount);
|
|
38
|
+
}
|
|
35
39
|
/**
|
|
36
40
|
* Buckets records by a partition key. `getKey` is accepted to keep the call shape symmetric with
|
|
37
41
|
* the rest of the diff pipeline (callers thread a stable record identity through partition + rollup);
|
|
@@ -39,7 +43,7 @@ export function partitionKeyForIdentity(identity, partitionCount = 256) {
|
|
|
39
43
|
* the array of records that fall in that partition. Records arrive in the order encountered — order
|
|
40
44
|
* is preserved within a bucket and never relied upon by the rollup (see `partitionRollupHash`).
|
|
41
45
|
*/
|
|
42
|
-
export function
|
|
46
|
+
export function PartitionRecords(records, getKey, getPartition) {
|
|
43
47
|
// getKey is part of the documented signature (callers pass a record-identity accessor) but
|
|
44
48
|
// bucketing is driven purely by partition; reference it so the contract stays explicit.
|
|
45
49
|
void getKey;
|
|
@@ -56,6 +60,10 @@ export function partitionRecords(records, getKey, getPartition) {
|
|
|
56
60
|
}
|
|
57
61
|
return buckets;
|
|
58
62
|
}
|
|
63
|
+
/** @deprecated Use {@link PartitionRecords}. */
|
|
64
|
+
export function partitionRecords(records, getKey, getPartition) {
|
|
65
|
+
return PartitionRecords(records, getKey, getPartition);
|
|
66
|
+
}
|
|
59
67
|
/**
|
|
60
68
|
* ORDER-INDEPENDENT rollup of a partition's records into a single hash. Each record's mapped fields
|
|
61
69
|
* are content-hashed via `computeContentHash`, the per-record hashes are SORTED, then the sorted list
|
|
@@ -66,14 +74,18 @@ export function partitionRecords(records, getKey, getPartition) {
|
|
|
66
74
|
* An empty partition rolls up to the SHA-256 of the empty string, a stable sentinel distinct from any
|
|
67
75
|
* non-empty partition.
|
|
68
76
|
*/
|
|
69
|
-
export function
|
|
70
|
-
const recordHashes = records.map(record =>
|
|
77
|
+
export function PartitionRollupHash(records, fieldsOf) {
|
|
78
|
+
const recordHashes = records.map(record => ComputeContentHash(fieldsOf(record)));
|
|
71
79
|
recordHashes.sort();
|
|
72
80
|
// Length-prefix each hash so the concatenation is unambiguous and can't collide across different
|
|
73
81
|
// record counts. SHA-256 hex is fixed-width, but the prefix keeps the combine future-proof.
|
|
74
82
|
const combined = recordHashes.map(hash => `${hash.length}:${hash}`).join('');
|
|
75
83
|
return createHash('sha256').update(combined).digest('hex');
|
|
76
84
|
}
|
|
85
|
+
/** @deprecated Use {@link PartitionRollupHash}. */
|
|
86
|
+
export function partitionRollupHash(records, fieldsOf) {
|
|
87
|
+
return PartitionRollupHash(records, fieldsOf);
|
|
88
|
+
}
|
|
77
89
|
/**
|
|
78
90
|
* Compares two partition→rollup maps and reports which partitions diverge. Only `changed`/`added`/
|
|
79
91
|
* `removed` partitions need a deep re-sync; partitions whose rollup matches on both sides are proven
|
|
@@ -83,7 +95,7 @@ export function partitionRollupHash(records, fieldsOf) {
|
|
|
83
95
|
* - `added` — key in `local` only.
|
|
84
96
|
* - `removed` — key in `remote` only.
|
|
85
97
|
*/
|
|
86
|
-
export function
|
|
98
|
+
export function DiffPartitions(local, remote) {
|
|
87
99
|
const changed = [];
|
|
88
100
|
const added = [];
|
|
89
101
|
for (const [partition, localRollup] of local) {
|
|
@@ -105,4 +117,8 @@ export function diffPartitions(local, remote) {
|
|
|
105
117
|
removed.sort();
|
|
106
118
|
return { changed, added, removed };
|
|
107
119
|
}
|
|
120
|
+
/** @deprecated Use {@link DiffPartitions}. */
|
|
121
|
+
export function diffPartitions(local, remote) {
|
|
122
|
+
return DiffPartitions(local, remote);
|
|
123
|
+
}
|
|
108
124
|
//# sourceMappingURL=HashDiff.js.map
|
package/dist/HashDiff.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HashDiff.js","sourceRoot":"","sources":["../src/HashDiff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAgB,EAAE,cAAc,GAAG,GAAG;IAC1E,MAAM,GAAG,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5E,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC;AACnE,CAAC;AAYD;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC5B,OAAqB,EACrB,MAA6B,EAC7B,YAAmC;IAEnC,2FAA2F;IAC3F,wFAAwF;IACxF,KAAK,MAAM,CAAC;IACZ,MAAM,OAAO,GAAG,IAAI,GAAG,EAAe,CAAC;IACvC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACtC,IAAI,MAAM,EAAE,CAAC;YACT,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAA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AAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC1B,KAAkC,EAClC,MAAmC;IAEnC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,KAAK,EAAE,CAAC;QAC3C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1B,CAAC;aAAM,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,WAAW,EAAE,CAAC;YAC/C,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC;IACL,CAAC;IACD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QACpC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC;IACL,CAAC;IACD,OAAO,CAAC,IAAI,EAAE,CAAC;IACf,KAAK,CAAC,IAAI,EAAE,CAAC;IACb,OAAO,CAAC,IAAI,EAAE,CAAC;IACf,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACvC,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,cAAc,CAC1B,KAAkC,EAClC,MAAmC;IAEnC,OAAO,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -39,7 +39,7 @@ export interface GenerateIntegrationActionResult {
|
|
|
39
39
|
*/
|
|
40
40
|
export declare class IntegrationActionGenerator {
|
|
41
41
|
/** All verbs in canonical order, used by GenerateActionsForObject */
|
|
42
|
-
private static readonly
|
|
42
|
+
private static readonly allVerbs;
|
|
43
43
|
/**
|
|
44
44
|
* Generate + persist ONE strongly-typed action for (integration, object, verb).
|
|
45
45
|
* Idempotent on the deterministic Name "<Integration> - <Verb> <DisplayName>".
|
|
@@ -28,7 +28,7 @@ import { ActionMetadataGenerator, } from './ActionMetadataGenerator.js';
|
|
|
28
28
|
*/
|
|
29
29
|
export class IntegrationActionGenerator {
|
|
30
30
|
/** All verbs in canonical order, used by GenerateActionsForObject */
|
|
31
|
-
static { this.
|
|
31
|
+
static { this.allVerbs = [
|
|
32
32
|
'Get', 'Create', 'Update', 'Delete', 'Upsert', 'Search', 'List',
|
|
33
33
|
]; }
|
|
34
34
|
/**
|
|
@@ -76,7 +76,7 @@ export class IntegrationActionGenerator {
|
|
|
76
76
|
return provider ?? Metadata.Provider;
|
|
77
77
|
}
|
|
78
78
|
applicableVerbs(supportsWrite) {
|
|
79
|
-
return IntegrationActionGenerator.
|
|
79
|
+
return IntegrationActionGenerator.allVerbs.filter(v => {
|
|
80
80
|
if (v === 'Create' || v === 'Update' || v === 'Delete' || v === 'Upsert')
|
|
81
81
|
return supportsWrite;
|
|
82
82
|
return true; // Get, Search, List always
|
|
@@ -202,8 +202,8 @@ export declare class IntegrationConnectorCreationPipeline {
|
|
|
202
202
|
/** Drops recent-run entries older than the coalesce window so the map stays bounded. */
|
|
203
203
|
private static pruneRecentRuns;
|
|
204
204
|
private runInternal;
|
|
205
|
-
private
|
|
206
|
-
private
|
|
205
|
+
private stageConnectionTest;
|
|
206
|
+
private stageIntrospect;
|
|
207
207
|
/**
|
|
208
208
|
* Samples a DECLARED object over the read path and merges the result into it IN PLACE.
|
|
209
209
|
*
|
|
@@ -222,9 +222,9 @@ export declare class IntegrationConnectorCreationPipeline {
|
|
|
222
222
|
* catalog states no observed widths — but from the outside the two are indistinguishable, so
|
|
223
223
|
* without this an object quietly keeps a guessed width and drops every longer value at sync.
|
|
224
224
|
*/
|
|
225
|
-
private
|
|
226
|
-
private
|
|
227
|
-
private
|
|
228
|
-
private
|
|
225
|
+
private reportSampleFallback;
|
|
226
|
+
private sampleDeclaredObjectInPlace;
|
|
227
|
+
private stagePersist;
|
|
228
|
+
private stagePKClassify;
|
|
229
229
|
}
|
|
230
230
|
//# sourceMappingURL=IntegrationConnectorCreationPipeline.d.ts.map
|
|
@@ -263,10 +263,10 @@ export class IntegrationConnectorCreationPipeline {
|
|
|
263
263
|
clearTimeout(deadlineTimer); });
|
|
264
264
|
};
|
|
265
265
|
try {
|
|
266
|
-
await withDeadline('ConnectionTest', this.
|
|
267
|
-
const sourceSchema = await withDeadline('Introspect', this.
|
|
268
|
-
const persistResult = await withDeadline('Persist', this.
|
|
269
|
-
const { verdicts, unresolved } = await withDeadline('PKClassify', this.
|
|
266
|
+
await withDeadline('ConnectionTest', this.stageConnectionTest(emitter, opts));
|
|
267
|
+
const sourceSchema = await withDeadline('Introspect', this.stageIntrospect(emitter, opts));
|
|
268
|
+
const persistResult = await withDeadline('Persist', this.stagePersist(emitter, opts, sourceSchema));
|
|
269
|
+
const { verdicts, unresolved } = await withDeadline('PKClassify', this.stagePKClassify(emitter, opts));
|
|
270
270
|
emitter.stageComplete('Pipeline', {
|
|
271
271
|
processed: persistResult.ObjectsCreated + persistResult.ObjectsUpdated,
|
|
272
272
|
succeeded: verdicts.filter(v => v.Confident).length,
|
|
@@ -299,7 +299,7 @@ export class IntegrationConnectorCreationPipeline {
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
// ── Stage 1: connection ──────────────────────────────────────────────
|
|
302
|
-
async
|
|
302
|
+
async stageConnectionTest(emitter, opts) {
|
|
303
303
|
emitter.stageStart('ConnectionTest', 'Validating credentials before heavy work');
|
|
304
304
|
const startMs = Date.now();
|
|
305
305
|
const result = await opts.Connector.TestConnection(opts.CompanyIntegration, opts.ContextUser);
|
|
@@ -311,7 +311,7 @@ export class IntegrationConnectorCreationPipeline {
|
|
|
311
311
|
emitter.checkpoint('ConnectionTest', { completedAt: new Date().toISOString(), durationMs: Date.now() - startMs });
|
|
312
312
|
}
|
|
313
313
|
// ── Stage 2: introspect ──────────────────────────────────────────────
|
|
314
|
-
async
|
|
314
|
+
async stageIntrospect(emitter, opts) {
|
|
315
315
|
emitter.stageStart('Introspect', 'Discovering objects and fields via connector');
|
|
316
316
|
const startMs = Date.now();
|
|
317
317
|
// Sampling is now per OBJECT, so this stage's cost scales with the catalog — and on a large
|
|
@@ -422,7 +422,7 @@ export class IntegrationConnectorCreationPipeline {
|
|
|
422
422
|
// and a fully-declared one gets its true widths and undeclared columns.
|
|
423
423
|
const existing = schema.Objects.find(o => o.ExternalName.toLowerCase() === key);
|
|
424
424
|
if (existing) {
|
|
425
|
-
await this.
|
|
425
|
+
await this.sampleDeclaredObjectInPlace(existing, d.Name, opts, emitter);
|
|
426
426
|
sampledDeclared.add(key);
|
|
427
427
|
}
|
|
428
428
|
continue;
|
|
@@ -434,7 +434,7 @@ export class IntegrationConnectorCreationPipeline {
|
|
|
434
434
|
// SAVE-LESS — stream as much of the feed as the budget allows so the PK decision is
|
|
435
435
|
// made on a statistically-significant sample, not a single (possibly tiny) file. No
|
|
436
436
|
// DB write happens here; the real save is the later ApplyAll → StartSync.
|
|
437
|
-
fields = await opts.Connector.DiscoverFieldsViaFetch(opts.CompanyIntegration, d.Name, opts.ContextUser, { OnFallback: (err) => this.
|
|
437
|
+
fields = await opts.Connector.DiscoverFieldsViaFetch(opts.CompanyIntegration, d.Name, opts.ContextUser, { OnFallback: (err) => this.reportSampleFallback(d.Name, err, emitter) });
|
|
438
438
|
}
|
|
439
439
|
catch (err) {
|
|
440
440
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -492,7 +492,7 @@ export class IntegrationConnectorCreationPipeline {
|
|
|
492
492
|
// Record it here too: two declared entries that differ only by case resolve to the
|
|
493
493
|
// SAME object, and sampling it twice doubles the most expensive part of discovery.
|
|
494
494
|
sampledDeclared.add(key);
|
|
495
|
-
await this.
|
|
495
|
+
await this.sampleDeclaredObjectInPlace(existing, name, opts, emitter);
|
|
496
496
|
declaredOnlySampled++;
|
|
497
497
|
}
|
|
498
498
|
if (unsampledForTime > 0) {
|
|
@@ -547,15 +547,15 @@ export class IntegrationConnectorCreationPipeline {
|
|
|
547
547
|
* catalog states no observed widths — but from the outside the two are indistinguishable, so
|
|
548
548
|
* without this an object quietly keeps a guessed width and drops every longer value at sync.
|
|
549
549
|
*/
|
|
550
|
-
|
|
550
|
+
reportSampleFallback(objectName, err, emitter) {
|
|
551
551
|
const msg = err instanceof Error ? err.message : String(err);
|
|
552
552
|
emitter.stageError('Introspect', `Sampling fell back to the catalog description for "${objectName}" — real widths and ` +
|
|
553
553
|
`undeclared columns are unknown for this run: ${msg}`, { code: 'discover-fields-fallback' });
|
|
554
554
|
console.warn(`[IntrospectPipeline] sample fallback for "${objectName}": ${msg}`);
|
|
555
555
|
}
|
|
556
|
-
async
|
|
556
|
+
async sampleDeclaredObjectInPlace(existing, objectName, opts, emitter) {
|
|
557
557
|
try {
|
|
558
|
-
const dfields = await opts.Connector.DiscoverFieldsViaFetch(opts.CompanyIntegration, objectName, opts.ContextUser, { OnFallback: (err) => this.
|
|
558
|
+
const dfields = await opts.Connector.DiscoverFieldsViaFetch(opts.CompanyIntegration, objectName, opts.ContextUser, { OnFallback: (err) => this.reportSampleFallback(objectName, err, emitter) });
|
|
559
559
|
const sampled = dfields.map(f => ({
|
|
560
560
|
Name: f.Name, Label: f.Label, Description: f.Description, SourceType: f.DataType,
|
|
561
561
|
IsRequired: f.IsRequired, AllowsNull: f.AllowsNull, MaxLength: f.MaxLength ?? null,
|
|
@@ -605,7 +605,7 @@ export class IntegrationConnectorCreationPipeline {
|
|
|
605
605
|
console.error(`[IntrospectPipeline] DiscoverFieldsViaFetch failed for declared "${objectName}" — ${lost}: ${msg}`);
|
|
606
606
|
}
|
|
607
607
|
}
|
|
608
|
-
async
|
|
608
|
+
async stagePersist(emitter, opts, sourceSchema) {
|
|
609
609
|
emitter.stageStart('Persist', 'Upserting IntegrationObject/Field rows with overlay precedence');
|
|
610
610
|
const startMs = Date.now();
|
|
611
611
|
const persistResult = await IntegrationSchemaSync.PersistDiscoveredSchema({
|
|
@@ -652,7 +652,7 @@ export class IntegrationConnectorCreationPipeline {
|
|
|
652
652
|
return persistResult;
|
|
653
653
|
}
|
|
654
654
|
// ── Stage 4: PK classification ───────────────────────────────────────
|
|
655
|
-
async
|
|
655
|
+
async stagePKClassify(emitter, opts) {
|
|
656
656
|
emitter.stageStart('PKClassify', 'Soft PK classifier for objects still missing a PK');
|
|
657
657
|
const md = opts.Provider ?? Metadata.Provider;
|
|
658
658
|
const engine = IntegrationEngineBase.Instance;
|
|
@@ -158,7 +158,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
158
158
|
* therefore lands on the proven per-record path: a connection has to ASK for batched writes,
|
|
159
159
|
* and a malformed request is not an ask.
|
|
160
160
|
*/
|
|
161
|
-
private
|
|
161
|
+
private readWriteMode;
|
|
162
162
|
/** The current run's context, when called from inside a sync run. */
|
|
163
163
|
private get currentRunContext();
|
|
164
164
|
/**
|
|
@@ -205,7 +205,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
205
205
|
* for absent, unparseable or wrongly-typed configuration — every failure mode keeps the side
|
|
206
206
|
* effects ON. A connection has to ask, and a malformed request is not an ask.
|
|
207
207
|
*/
|
|
208
|
-
private
|
|
208
|
+
private readWriteSideEffects;
|
|
209
209
|
/**
|
|
210
210
|
* Save options for THIS run's machine writes: suppress the audit row + geocode lookup when
|
|
211
211
|
* the connection asked for it, undefined otherwise (identical to the pre-feature call).
|
|
@@ -379,7 +379,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
379
379
|
* atomic with several of these in flight: an async function runs synchronously up to its first
|
|
380
380
|
* await, and the pool always starts one from a synchronous call site.
|
|
381
381
|
*/
|
|
382
|
-
private
|
|
382
|
+
private resumeOneOrphanedRun;
|
|
383
383
|
/**
|
|
384
384
|
* Executes a full sync run for a company integration.
|
|
385
385
|
* If a sync is already running for the same integration, waits for it to finish
|
|
@@ -436,7 +436,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
436
436
|
/**
|
|
437
437
|
* Loads all configuration needed for a sync run.
|
|
438
438
|
*/
|
|
439
|
-
private
|
|
439
|
+
private loadRunConfiguration;
|
|
440
440
|
/**
|
|
441
441
|
* Periodic full-reconcile cadence (plan §C5: "periodic full reconcile for hard deletes"). When the
|
|
442
442
|
* caller did NOT explicitly request FullSync, an integration can opt into automatic periodic full
|
|
@@ -450,11 +450,11 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
450
450
|
/**
|
|
451
451
|
* Creates a new CompanyIntegrationRun record to track this sync.
|
|
452
452
|
*/
|
|
453
|
-
private
|
|
453
|
+
private createRunRecord;
|
|
454
454
|
/**
|
|
455
455
|
* Processes all entity maps, aggregating results with progress tracking.
|
|
456
456
|
*/
|
|
457
|
-
private
|
|
457
|
+
private executeEntityMaps;
|
|
458
458
|
/**
|
|
459
459
|
* Groups the run's entity maps into dependency layers (parents before children) using the
|
|
460
460
|
* IntegrationObject FK graph (RelatedIntegrationObjectID). Layer 0 = roots (no FK dependency on
|
|
@@ -602,13 +602,13 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
602
602
|
* - Push: detect MJ changes → map → push to external
|
|
603
603
|
* - Bidirectional: pull first, then push
|
|
604
604
|
*/
|
|
605
|
-
private
|
|
605
|
+
private processSingleEntityMap;
|
|
606
606
|
/** Loads the map fresh and writes its Configuration through Save(), like every other engine write. */
|
|
607
|
-
private
|
|
607
|
+
private saveEntityMapConfiguration;
|
|
608
608
|
/**
|
|
609
609
|
* Pull sync: fetch from external → map → match → validate → apply to MJ.
|
|
610
610
|
*/
|
|
611
|
-
private
|
|
611
|
+
private processPullSync;
|
|
612
612
|
/**
|
|
613
613
|
* Classifies a fetched batch against the `ctx.BatchSize` the engine asked for. Returns null when
|
|
614
614
|
* the batch is within contract, so the caller can treat "no verdict" as "nothing to warn about".
|
|
@@ -641,17 +641,17 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
641
641
|
* Filters out changes made by the integration engine itself to prevent echo loops.
|
|
642
642
|
* For each changed record, calls the connector's CreateRecord/UpdateRecord/DeleteRecord.
|
|
643
643
|
*/
|
|
644
|
-
private
|
|
644
|
+
private processPushSync;
|
|
645
645
|
/** Loads MJ records changed since the last push watermark, excluding integration-engine changes. */
|
|
646
|
-
private
|
|
646
|
+
private loadChangedMJRecords;
|
|
647
647
|
/**
|
|
648
648
|
* Loads ALL records from an MJ entity for full push sync.
|
|
649
649
|
* For each record, checks the record map to determine if it's a Create (no external ID)
|
|
650
650
|
* or Update (has external ID) in the external system.
|
|
651
651
|
*/
|
|
652
|
-
private
|
|
652
|
+
private loadAllMJRecords;
|
|
653
653
|
/** Pushes a single changed MJ record to the external system. */
|
|
654
|
-
private
|
|
654
|
+
private pushSingleRecord;
|
|
655
655
|
/**
|
|
656
656
|
* Surface a SKIPPED push (forbidden write / unsupported op) as a structured SyncWarning so a
|
|
657
657
|
* change that was NOT written to the external system is visible over GraphQL — not just a
|
|
@@ -687,22 +687,22 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
687
687
|
* but were NOT returned by the external system during this full pull.
|
|
688
688
|
* These records were deleted externally and should be removed from MJ.
|
|
689
689
|
*/
|
|
690
|
-
private
|
|
690
|
+
private deleteOrphanedRecords;
|
|
691
691
|
/**
|
|
692
692
|
* Removes one 'MJ: Company Integration Record Maps' row after delete-detection has handled
|
|
693
693
|
* its orphan (deleted, archived, or found already gone). A failure here is logged and
|
|
694
694
|
* swallowed: the orphan itself was handled, and the worst consequence of a surviving map
|
|
695
695
|
* row is one redundant re-detection on the next full sync.
|
|
696
696
|
*/
|
|
697
|
-
private
|
|
697
|
+
private deleteRecordMapRow;
|
|
698
698
|
/**
|
|
699
699
|
* Strips field-name prefixes from a RecordChange.RecordID to get the raw entity record ID.
|
|
700
700
|
* "hs_object_id|465950833372" → "465950833372"
|
|
701
701
|
* "contact_id|123||deal_id|456" → "123|456"
|
|
702
702
|
*/
|
|
703
|
-
private
|
|
703
|
+
private normalizeRecordChangeID;
|
|
704
704
|
/** Returns an empty SyncResult. */
|
|
705
|
-
private
|
|
705
|
+
private emptyResult;
|
|
706
706
|
/**
|
|
707
707
|
* Emits a progress update via the callback.
|
|
708
708
|
*/
|
|
@@ -710,7 +710,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
710
710
|
/**
|
|
711
711
|
* Loads active field maps for a given entity map.
|
|
712
712
|
*/
|
|
713
|
-
private
|
|
713
|
+
private loadFieldMaps;
|
|
714
714
|
/** Parses the entity map's Configuration JSON (best-effort) for engine-side feature toggles. */
|
|
715
715
|
private parseEntityMapConfig;
|
|
716
716
|
/** Opt-in partition (Merkle) reconcile flag from the entity map Configuration (GQL-managed). */
|
|
@@ -736,7 +736,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
736
736
|
/**
|
|
737
737
|
* Applies resolved records to MJ, handling each individually for error isolation.
|
|
738
738
|
*/
|
|
739
|
-
private
|
|
739
|
+
private applyRecords;
|
|
740
740
|
/**
|
|
741
741
|
* Flushes the queued record maps and reports any that failed, per external ID.
|
|
742
742
|
*
|
|
@@ -745,7 +745,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
745
745
|
* worth telling the operator about but is not a reason to mark the record — or the run —
|
|
746
746
|
* failed. Flushing itself never throws for the same reason.
|
|
747
747
|
*/
|
|
748
|
-
private
|
|
748
|
+
private flushRecordMaps;
|
|
749
749
|
/**
|
|
750
750
|
* Refreshes __mj_integration_LastReconciledAt = now for a set of records that the content-hash
|
|
751
751
|
* fast path skipped (present + confirmed-unchanged on the source). Issues ONE set-based UPDATE
|
|
@@ -754,7 +754,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
754
754
|
* mirroring PrefetchContentHashes. Keeps the column's "last confirmed present" semantics honest so
|
|
755
755
|
* future unseen-since-last-reconcile logic can't misclassify a still-present unchanged record.
|
|
756
756
|
*/
|
|
757
|
-
private
|
|
757
|
+
private touchLastReconciledAt;
|
|
758
758
|
/**
|
|
759
759
|
* Per-record fallback for a batch whose single transaction failed. Re-applies each
|
|
760
760
|
* record in its OWN transaction so a failure isolates to that record only — good
|
|
@@ -774,7 +774,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
774
774
|
/**
|
|
775
775
|
* Applies a single record change (Create, Update, Delete, or Skip).
|
|
776
776
|
*/
|
|
777
|
-
private
|
|
777
|
+
private applySingleRecord;
|
|
778
778
|
/**
|
|
779
779
|
* Upserts an MJ record BY PRIMARY KEY (and saves a record-map entry).
|
|
780
780
|
*
|
|
@@ -791,7 +791,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
791
791
|
*
|
|
792
792
|
* @returns true if an existing row was updated, false if a new row was inserted (so the caller counts correctly).
|
|
793
793
|
*/
|
|
794
|
-
private
|
|
794
|
+
private createRecord;
|
|
795
795
|
/**
|
|
796
796
|
* Builds the pipe-joined PK string for a record from its MAPPED fields (case-insensitively), or null
|
|
797
797
|
* when any PK field is absent/blank — i.e. the PK is not carried by the mapped data (server-assigned),
|
|
@@ -816,7 +816,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
816
816
|
* If the record cannot be loaded (e.g. it was deleted or never fully created),
|
|
817
817
|
* falls back to CreateRecord (upsert behavior).
|
|
818
818
|
*/
|
|
819
|
-
private
|
|
819
|
+
private updateRecord;
|
|
820
820
|
/**
|
|
821
821
|
* Batch-loads the stored `__mj_integration_ContentHash` for the Update records in a
|
|
822
822
|
* batch, keyed by matched MJ record ID. Returns undefined (→ no fast-path skip; the
|
|
@@ -826,7 +826,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
826
826
|
* - nothing in the batch is an Update with a matched ID, or
|
|
827
827
|
* - the read fails (best-effort — a logging/optimization read must never break a sync).
|
|
828
828
|
*/
|
|
829
|
-
private
|
|
829
|
+
private prefetchContentHashes;
|
|
830
830
|
/**
|
|
831
831
|
* Runs Validate() on an entity if the method exists.
|
|
832
832
|
* Throws a validation error with details if validation fails.
|
|
@@ -835,20 +835,20 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
835
835
|
/**
|
|
836
836
|
* Deletes (or soft-deletes) an MJ record based on the entity map's DeleteBehavior.
|
|
837
837
|
*/
|
|
838
|
-
private
|
|
838
|
+
private deleteRecord;
|
|
839
839
|
/**
|
|
840
840
|
* Builds a CompositeKey for a record lookup using the entity's PK field definitions.
|
|
841
841
|
* Supports both single-PK and composite-PK entities. For composite PKs the recordID
|
|
842
842
|
* is expected to be a '|'-delimited string of values in PK-field sequence order —
|
|
843
843
|
* the same format written by BaseRESTIntegrationConnector.ToExternalRecord.
|
|
844
844
|
*/
|
|
845
|
-
private
|
|
845
|
+
private buildEntityPrimaryKey;
|
|
846
846
|
/**
|
|
847
847
|
* The exact inverse of {@link BuildEntityPrimaryKey}: the '|'-joined value(s) of a data row's
|
|
848
848
|
* primary-key column(s), in PK-field order — the shape CompanyIntegrationRecordMap.EntityRecordID
|
|
849
849
|
* and a normalized RecordChange.RecordID carry. A single-column key is just its value.
|
|
850
850
|
*/
|
|
851
|
-
private
|
|
851
|
+
private composeEntityRecordID;
|
|
852
852
|
/**
|
|
853
853
|
* Reports ACTIVE field maps whose MJ column does not exist, once per entity map per run.
|
|
854
854
|
*
|
|
@@ -857,11 +857,11 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
857
857
|
* record while the run reports those records as written. Checking it here costs one metadata
|
|
858
858
|
* read and happens before the first fetch, so the warning arrives before the wasted work.
|
|
859
859
|
*/
|
|
860
|
-
private
|
|
860
|
+
private warnOnUnbindableFieldMaps;
|
|
861
861
|
/**
|
|
862
862
|
* Sets fields on a BaseEntity instance from a field value map.
|
|
863
863
|
*/
|
|
864
|
-
private
|
|
864
|
+
private setEntityFields;
|
|
865
865
|
/**
|
|
866
866
|
* §5/§10/§29 value-fit enforcement: a value that cannot fit its bounded destination column is NOT
|
|
867
867
|
* truncated/clamped (silent corruption) and does NOT widen the column (space is the priority) —
|
|
@@ -906,7 +906,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
906
906
|
* Sets standard integration columns (__mj_integration_*) on target entities.
|
|
907
907
|
* Silently skips if the entity doesn't have these columns (e.g., __mj targets).
|
|
908
908
|
*/
|
|
909
|
-
private
|
|
909
|
+
private setStandardIntegrationFields;
|
|
910
910
|
/**
|
|
911
911
|
* Reads EVERY record-map row for a (CompanyIntegration, Entity) pair, in pages.
|
|
912
912
|
*
|
|
@@ -935,7 +935,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
935
935
|
* truncation this helper exists to prevent, and the orphan sweep would archive live
|
|
936
936
|
* records on the strength of it. Keyset seeks on the last ID seen and cannot shift.
|
|
937
937
|
*/
|
|
938
|
-
private
|
|
938
|
+
private loadAllRecordMaps;
|
|
939
939
|
/**
|
|
940
940
|
* Records an external↔MJ mapping — batched when the apply pass supplied a writer, direct
|
|
941
941
|
* otherwise.
|
|
@@ -945,19 +945,19 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
945
945
|
* decides not to change. The `recordMaps` parameter is optional so that callers outside the
|
|
946
946
|
* batched apply pass (and every existing test) keep the original immediate-write behaviour.
|
|
947
947
|
*/
|
|
948
|
-
private
|
|
948
|
+
private queueRecordMap;
|
|
949
949
|
/**
|
|
950
950
|
* Creates or updates a CompanyIntegrationRecordMap entry to track the external↔MJ mapping.
|
|
951
951
|
*/
|
|
952
|
-
private
|
|
952
|
+
private saveRecordMap;
|
|
953
953
|
/**
|
|
954
954
|
* Creates a CompanyIntegrationRunDetail record for audit/reporting.
|
|
955
955
|
*/
|
|
956
|
-
private
|
|
956
|
+
private createRunDetail;
|
|
957
957
|
/**
|
|
958
958
|
* Merges an entity-map-level result into the aggregate result.
|
|
959
959
|
*/
|
|
960
|
-
private
|
|
960
|
+
private mergeResult;
|
|
961
961
|
/**
|
|
962
962
|
* Builds a per-entity-map result summary from the entity map and its sync result.
|
|
963
963
|
*/
|
|
@@ -965,7 +965,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
965
965
|
/**
|
|
966
966
|
* Finalizes a successful run with aggregate totals and emits a completion notification.
|
|
967
967
|
*/
|
|
968
|
-
private
|
|
968
|
+
private finalizeRun;
|
|
969
969
|
/**
|
|
970
970
|
* Retention: prune old CompanyIntegrationRun + RunDetail rows for THIS connection so the audit
|
|
971
971
|
* tables don't grow without bound (a row accumulates per sync forever otherwise — the unbounded-log
|
|
@@ -978,7 +978,7 @@ export declare class IntegrationEngine extends BaseSingleton<IntegrationEngine>
|
|
|
978
978
|
/**
|
|
979
979
|
* Marks a run as failed after an unrecoverable error and emits a failure notification.
|
|
980
980
|
*/
|
|
981
|
-
private
|
|
981
|
+
private failRun;
|
|
982
982
|
/**
|
|
983
983
|
* Builds a SyncNotification for a completed run (success or completed-with-errors).
|
|
984
984
|
*/
|