@lssm/example.integration-hub 0.0.0-canary-20251217054315 → 0.0.0-canary-20251217060804

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.
@@ -0,0 +1,355 @@
1
+ import * as _lssm_lib_schema209 from "@lssm/lib.schema";
2
+
3
+ //#region src/sync/sync.schema.d.ts
4
+ /**
5
+ * A field mapping configuration.
6
+ */
7
+ declare const FieldMappingModel: _lssm_lib_schema209.SchemaModel<{
8
+ id: {
9
+ type: _lssm_lib_schema209.FieldType<string, string>;
10
+ isOptional: false;
11
+ };
12
+ sourceField: {
13
+ type: _lssm_lib_schema209.FieldType<string, string>;
14
+ isOptional: false;
15
+ };
16
+ targetField: {
17
+ type: _lssm_lib_schema209.FieldType<string, string>;
18
+ isOptional: false;
19
+ };
20
+ mappingType: {
21
+ type: _lssm_lib_schema209.EnumType<[string, string, string, string, string]>;
22
+ isOptional: false;
23
+ };
24
+ transformExpression: {
25
+ type: _lssm_lib_schema209.FieldType<string, string>;
26
+ isOptional: true;
27
+ };
28
+ isRequired: {
29
+ type: _lssm_lib_schema209.FieldType<boolean, boolean>;
30
+ isOptional: false;
31
+ };
32
+ }>;
33
+ /**
34
+ * A sync configuration.
35
+ */
36
+ declare const SyncConfigModel: _lssm_lib_schema209.SchemaModel<{
37
+ id: {
38
+ type: _lssm_lib_schema209.FieldType<string, string>;
39
+ isOptional: false;
40
+ };
41
+ integrationId: {
42
+ type: _lssm_lib_schema209.FieldType<string, string>;
43
+ isOptional: false;
44
+ };
45
+ connectionId: {
46
+ type: _lssm_lib_schema209.FieldType<string, string>;
47
+ isOptional: false;
48
+ };
49
+ name: {
50
+ type: _lssm_lib_schema209.FieldType<string, string>;
51
+ isOptional: false;
52
+ };
53
+ direction: {
54
+ type: _lssm_lib_schema209.EnumType<[string, string, string]>;
55
+ isOptional: false;
56
+ };
57
+ sourceObject: {
58
+ type: _lssm_lib_schema209.FieldType<string, string>;
59
+ isOptional: false;
60
+ };
61
+ targetObject: {
62
+ type: _lssm_lib_schema209.FieldType<string, string>;
63
+ isOptional: false;
64
+ };
65
+ scheduleEnabled: {
66
+ type: _lssm_lib_schema209.FieldType<boolean, boolean>;
67
+ isOptional: false;
68
+ };
69
+ scheduleCron: {
70
+ type: _lssm_lib_schema209.FieldType<string, string>;
71
+ isOptional: true;
72
+ };
73
+ isActive: {
74
+ type: _lssm_lib_schema209.FieldType<boolean, boolean>;
75
+ isOptional: false;
76
+ };
77
+ lastSyncAt: {
78
+ type: _lssm_lib_schema209.FieldType<Date, string>;
79
+ isOptional: true;
80
+ };
81
+ fieldMappings: {
82
+ type: _lssm_lib_schema209.SchemaModel<{
83
+ id: {
84
+ type: _lssm_lib_schema209.FieldType<string, string>;
85
+ isOptional: false;
86
+ };
87
+ sourceField: {
88
+ type: _lssm_lib_schema209.FieldType<string, string>;
89
+ isOptional: false;
90
+ };
91
+ targetField: {
92
+ type: _lssm_lib_schema209.FieldType<string, string>;
93
+ isOptional: false;
94
+ };
95
+ mappingType: {
96
+ type: _lssm_lib_schema209.EnumType<[string, string, string, string, string]>;
97
+ isOptional: false;
98
+ };
99
+ transformExpression: {
100
+ type: _lssm_lib_schema209.FieldType<string, string>;
101
+ isOptional: true;
102
+ };
103
+ isRequired: {
104
+ type: _lssm_lib_schema209.FieldType<boolean, boolean>;
105
+ isOptional: false;
106
+ };
107
+ }>;
108
+ isArray: true;
109
+ isOptional: true;
110
+ };
111
+ }>;
112
+ /**
113
+ * A sync run.
114
+ */
115
+ declare const SyncRunModel: _lssm_lib_schema209.SchemaModel<{
116
+ id: {
117
+ type: _lssm_lib_schema209.FieldType<string, string>;
118
+ isOptional: false;
119
+ };
120
+ syncConfigId: {
121
+ type: _lssm_lib_schema209.FieldType<string, string>;
122
+ isOptional: false;
123
+ };
124
+ status: {
125
+ type: _lssm_lib_schema209.EnumType<[string, string, string, string, string]>;
126
+ isOptional: false;
127
+ };
128
+ direction: {
129
+ type: _lssm_lib_schema209.EnumType<[string, string, string]>;
130
+ isOptional: false;
131
+ };
132
+ trigger: {
133
+ type: _lssm_lib_schema209.FieldType<string, string>;
134
+ isOptional: false;
135
+ };
136
+ recordsProcessed: {
137
+ type: _lssm_lib_schema209.FieldType<number, number>;
138
+ isOptional: false;
139
+ };
140
+ recordsCreated: {
141
+ type: _lssm_lib_schema209.FieldType<number, number>;
142
+ isOptional: false;
143
+ };
144
+ recordsUpdated: {
145
+ type: _lssm_lib_schema209.FieldType<number, number>;
146
+ isOptional: false;
147
+ };
148
+ recordsFailed: {
149
+ type: _lssm_lib_schema209.FieldType<number, number>;
150
+ isOptional: false;
151
+ };
152
+ errorMessage: {
153
+ type: _lssm_lib_schema209.FieldType<string, string>;
154
+ isOptional: true;
155
+ };
156
+ startedAt: {
157
+ type: _lssm_lib_schema209.FieldType<Date, string>;
158
+ isOptional: true;
159
+ };
160
+ completedAt: {
161
+ type: _lssm_lib_schema209.FieldType<Date, string>;
162
+ isOptional: true;
163
+ };
164
+ createdAt: {
165
+ type: _lssm_lib_schema209.FieldType<Date, string>;
166
+ isOptional: false;
167
+ };
168
+ }>;
169
+ /**
170
+ * Input for creating a sync config.
171
+ */
172
+ declare const CreateSyncConfigInputModel: _lssm_lib_schema209.SchemaModel<{
173
+ integrationId: {
174
+ type: _lssm_lib_schema209.FieldType<string, string>;
175
+ isOptional: false;
176
+ };
177
+ connectionId: {
178
+ type: _lssm_lib_schema209.FieldType<string, string>;
179
+ isOptional: false;
180
+ };
181
+ name: {
182
+ type: _lssm_lib_schema209.FieldType<string, string>;
183
+ isOptional: false;
184
+ };
185
+ direction: {
186
+ type: _lssm_lib_schema209.EnumType<[string, string, string]>;
187
+ isOptional: false;
188
+ };
189
+ sourceObject: {
190
+ type: _lssm_lib_schema209.FieldType<string, string>;
191
+ isOptional: false;
192
+ };
193
+ targetObject: {
194
+ type: _lssm_lib_schema209.FieldType<string, string>;
195
+ isOptional: false;
196
+ };
197
+ scheduleEnabled: {
198
+ type: _lssm_lib_schema209.FieldType<boolean, boolean>;
199
+ isOptional: true;
200
+ };
201
+ scheduleCron: {
202
+ type: _lssm_lib_schema209.FieldType<string, string>;
203
+ isOptional: true;
204
+ };
205
+ }>;
206
+ /**
207
+ * Input for adding a field mapping.
208
+ */
209
+ declare const AddFieldMappingInputModel: _lssm_lib_schema209.SchemaModel<{
210
+ syncConfigId: {
211
+ type: _lssm_lib_schema209.FieldType<string, string>;
212
+ isOptional: false;
213
+ };
214
+ sourceField: {
215
+ type: _lssm_lib_schema209.FieldType<string, string>;
216
+ isOptional: false;
217
+ };
218
+ targetField: {
219
+ type: _lssm_lib_schema209.FieldType<string, string>;
220
+ isOptional: false;
221
+ };
222
+ mappingType: {
223
+ type: _lssm_lib_schema209.EnumType<[string, string, string, string, string]>;
224
+ isOptional: false;
225
+ };
226
+ transformExpression: {
227
+ type: _lssm_lib_schema209.FieldType<string, string>;
228
+ isOptional: true;
229
+ };
230
+ lookupConfig: {
231
+ type: _lssm_lib_schema209.FieldType<unknown, unknown>;
232
+ isOptional: true;
233
+ };
234
+ constantValue: {
235
+ type: _lssm_lib_schema209.FieldType<unknown, unknown>;
236
+ isOptional: true;
237
+ };
238
+ isRequired: {
239
+ type: _lssm_lib_schema209.FieldType<boolean, boolean>;
240
+ isOptional: true;
241
+ };
242
+ defaultValue: {
243
+ type: _lssm_lib_schema209.FieldType<unknown, unknown>;
244
+ isOptional: true;
245
+ };
246
+ }>;
247
+ /**
248
+ * Input for triggering a sync.
249
+ */
250
+ declare const TriggerSyncInputModel: _lssm_lib_schema209.SchemaModel<{
251
+ syncConfigId: {
252
+ type: _lssm_lib_schema209.FieldType<string, string>;
253
+ isOptional: false;
254
+ };
255
+ direction: {
256
+ type: _lssm_lib_schema209.EnumType<[string, string, string]>;
257
+ isOptional: true;
258
+ };
259
+ fullSync: {
260
+ type: _lssm_lib_schema209.FieldType<boolean, boolean>;
261
+ isOptional: true;
262
+ };
263
+ }>;
264
+ /**
265
+ * Input for listing sync runs.
266
+ */
267
+ declare const ListSyncRunsInputModel: _lssm_lib_schema209.SchemaModel<{
268
+ syncConfigId: {
269
+ type: _lssm_lib_schema209.FieldType<string, string>;
270
+ isOptional: false;
271
+ };
272
+ status: {
273
+ type: _lssm_lib_schema209.EnumType<[string, string, string, string, string]>;
274
+ isOptional: true;
275
+ };
276
+ limit: {
277
+ type: _lssm_lib_schema209.FieldType<number, number>;
278
+ isOptional: true;
279
+ defaultValue: number;
280
+ };
281
+ offset: {
282
+ type: _lssm_lib_schema209.FieldType<number, number>;
283
+ isOptional: true;
284
+ defaultValue: number;
285
+ };
286
+ }>;
287
+ /**
288
+ * Output for listing sync runs.
289
+ */
290
+ declare const ListSyncRunsOutputModel: _lssm_lib_schema209.SchemaModel<{
291
+ runs: {
292
+ type: _lssm_lib_schema209.SchemaModel<{
293
+ id: {
294
+ type: _lssm_lib_schema209.FieldType<string, string>;
295
+ isOptional: false;
296
+ };
297
+ syncConfigId: {
298
+ type: _lssm_lib_schema209.FieldType<string, string>;
299
+ isOptional: false;
300
+ };
301
+ status: {
302
+ type: _lssm_lib_schema209.EnumType<[string, string, string, string, string]>;
303
+ isOptional: false;
304
+ };
305
+ direction: {
306
+ type: _lssm_lib_schema209.EnumType<[string, string, string]>;
307
+ isOptional: false;
308
+ };
309
+ trigger: {
310
+ type: _lssm_lib_schema209.FieldType<string, string>;
311
+ isOptional: false;
312
+ };
313
+ recordsProcessed: {
314
+ type: _lssm_lib_schema209.FieldType<number, number>;
315
+ isOptional: false;
316
+ };
317
+ recordsCreated: {
318
+ type: _lssm_lib_schema209.FieldType<number, number>;
319
+ isOptional: false;
320
+ };
321
+ recordsUpdated: {
322
+ type: _lssm_lib_schema209.FieldType<number, number>;
323
+ isOptional: false;
324
+ };
325
+ recordsFailed: {
326
+ type: _lssm_lib_schema209.FieldType<number, number>;
327
+ isOptional: false;
328
+ };
329
+ errorMessage: {
330
+ type: _lssm_lib_schema209.FieldType<string, string>;
331
+ isOptional: true;
332
+ };
333
+ startedAt: {
334
+ type: _lssm_lib_schema209.FieldType<Date, string>;
335
+ isOptional: true;
336
+ };
337
+ completedAt: {
338
+ type: _lssm_lib_schema209.FieldType<Date, string>;
339
+ isOptional: true;
340
+ };
341
+ createdAt: {
342
+ type: _lssm_lib_schema209.FieldType<Date, string>;
343
+ isOptional: false;
344
+ };
345
+ }>;
346
+ isArray: true;
347
+ isOptional: false;
348
+ };
349
+ total: {
350
+ type: _lssm_lib_schema209.FieldType<number, number>;
351
+ isOptional: false;
352
+ };
353
+ }>;
354
+ //#endregion
355
+ export { AddFieldMappingInputModel, CreateSyncConfigInputModel, FieldMappingModel, ListSyncRunsInputModel, ListSyncRunsOutputModel, SyncConfigModel, SyncRunModel, TriggerSyncInputModel };
@@ -0,0 +1,108 @@
1
+ //#region src/sync-engine/index.d.ts
2
+ /**
3
+ * Sync Engine
4
+ *
5
+ * Core sync logic for the Integration Hub.
6
+ */
7
+ interface FieldMapping {
8
+ sourceField: string;
9
+ targetField: string;
10
+ mappingType: 'DIRECT' | 'TRANSFORM' | 'LOOKUP' | 'CONSTANT' | 'COMPUTED';
11
+ transformExpression?: string;
12
+ lookupConfig?: LookupConfig;
13
+ constantValue?: unknown;
14
+ isRequired: boolean;
15
+ defaultValue?: unknown;
16
+ }
17
+ interface LookupConfig {
18
+ sourceObject: string;
19
+ lookupField: string;
20
+ returnField: string;
21
+ }
22
+ interface SyncConfig {
23
+ id: string;
24
+ direction: 'INBOUND' | 'OUTBOUND' | 'BIDIRECTIONAL';
25
+ sourceObject: string;
26
+ targetObject: string;
27
+ fieldMappings: FieldMapping[];
28
+ createNew: boolean;
29
+ updateExisting: boolean;
30
+ deleteRemoved: boolean;
31
+ sourceFilter?: Record<string, unknown>;
32
+ }
33
+ interface SyncContext {
34
+ runId: string;
35
+ config: SyncConfig;
36
+ connection: {
37
+ id: string;
38
+ authType: string;
39
+ credentials?: Record<string, unknown>;
40
+ };
41
+ }
42
+ interface SyncResult {
43
+ success: boolean;
44
+ recordsProcessed: number;
45
+ recordsCreated: number;
46
+ recordsUpdated: number;
47
+ recordsDeleted: number;
48
+ recordsFailed: number;
49
+ recordsSkipped: number;
50
+ errors: SyncError[];
51
+ }
52
+ interface SyncError {
53
+ recordId?: string;
54
+ field?: string;
55
+ message: string;
56
+ code: string;
57
+ }
58
+ interface SourceRecord {
59
+ id: string;
60
+ data: Record<string, unknown>;
61
+ checksum?: string;
62
+ }
63
+ interface TargetRecord {
64
+ id: string;
65
+ data: Record<string, unknown>;
66
+ checksum?: string;
67
+ }
68
+ interface ISyncEngine {
69
+ /**
70
+ * Execute a sync operation.
71
+ */
72
+ sync(context: SyncContext): Promise<SyncResult>;
73
+ /**
74
+ * Transform a source record to target format.
75
+ */
76
+ transformRecord(sourceRecord: SourceRecord, mappings: FieldMapping[], context: SyncContext): TargetRecord;
77
+ /**
78
+ * Validate a transformed record.
79
+ */
80
+ validateRecord(record: TargetRecord, mappings: FieldMapping[]): {
81
+ valid: boolean;
82
+ errors: SyncError[];
83
+ };
84
+ }
85
+ interface IFieldTransformer {
86
+ transform(value: unknown, expression: string): unknown;
87
+ }
88
+ declare class BasicFieldTransformer implements IFieldTransformer {
89
+ transform(value: unknown, expression: string): unknown;
90
+ }
91
+ declare class BasicSyncEngine implements ISyncEngine {
92
+ private transformer;
93
+ constructor(transformer?: IFieldTransformer);
94
+ sync(context: SyncContext): Promise<SyncResult>;
95
+ transformRecord(sourceRecord: SourceRecord, mappings: FieldMapping[], _context: SyncContext): TargetRecord;
96
+ validateRecord(record: TargetRecord, mappings: FieldMapping[]): {
97
+ valid: boolean;
98
+ errors: SyncError[];
99
+ };
100
+ private getNestedValue;
101
+ private setNestedValue;
102
+ private evaluateComputed;
103
+ }
104
+ declare function createSyncEngine(transformer?: IFieldTransformer): ISyncEngine;
105
+ declare function computeChecksum(data: Record<string, unknown>): string;
106
+ declare function hasChanges(sourceChecksum: string | undefined, targetChecksum: string | undefined): boolean;
107
+ //#endregion
108
+ export { BasicFieldTransformer, BasicSyncEngine, FieldMapping, IFieldTransformer, ISyncEngine, LookupConfig, SourceRecord, SyncConfig, SyncContext, SyncError, SyncResult, TargetRecord, computeChecksum, createSyncEngine, hasChanges };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lssm/example.integration-hub",
3
- "version": "0.0.0-canary-20251217054315",
3
+ "version": "0.0.0-canary-20251217060804",
4
4
  "description": "Integration Hub example with sync engine and field mappings for ContractSpec",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -18,45 +18,45 @@
18
18
  "lint:check": "eslint src"
19
19
  },
20
20
  "dependencies": {
21
- "@lssm/lib.schema": "0.0.0-canary-20251217054315",
22
- "@lssm/lib.contracts": "0.0.0-canary-20251217054315",
23
- "@lssm/lib.bus": "0.0.0-canary-20251217054315",
24
- "@lssm/lib.identity-rbac": "0.0.0-canary-20251217054315",
25
- "@lssm/lib.files": "0.0.0-canary-20251217054315",
26
- "@lssm/lib.feature-flags": "0.0.0-canary-20251217054315",
27
- "@lssm/lib.jobs": "0.0.0-canary-20251217054315",
28
- "@lssm/module.audit-trail": "0.0.0-canary-20251217054315",
29
- "@lssm/module.notifications": "0.0.0-canary-20251217054315",
21
+ "@lssm/lib.schema": "0.0.0-canary-20251217060804",
22
+ "@lssm/lib.contracts": "0.0.0-canary-20251217060804",
23
+ "@lssm/lib.bus": "0.0.0-canary-20251217060804",
24
+ "@lssm/lib.identity-rbac": "0.0.0-canary-20251217060804",
25
+ "@lssm/lib.files": "0.0.0-canary-20251217060804",
26
+ "@lssm/lib.feature-flags": "0.0.0-canary-20251217060804",
27
+ "@lssm/lib.jobs": "0.0.0-canary-20251217060804",
28
+ "@lssm/module.audit-trail": "0.0.0-canary-20251217060804",
29
+ "@lssm/module.notifications": "0.0.0-canary-20251217060804",
30
30
  "zod": "^4.1.13"
31
31
  },
32
32
  "devDependencies": {
33
- "@lssm/tool.typescript": "0.0.0-canary-20251217054315",
34
- "@lssm/tool.tsdown": "0.0.0-canary-20251217054315",
33
+ "@lssm/tool.typescript": "0.0.0-canary-20251217060804",
34
+ "@lssm/tool.tsdown": "0.0.0-canary-20251217060804",
35
35
  "typescript": "^5.9.3"
36
36
  },
37
37
  "exports": {
38
- ".": "./src/index.ts",
39
- "./connection": "./src/connection/index.ts",
40
- "./connection/connection.contracts": "./src/connection/connection.contracts.ts",
41
- "./connection/connection.enum": "./src/connection/connection.enum.ts",
42
- "./connection/connection.presentation": "./src/connection/connection.presentation.ts",
43
- "./connection/connection.schema": "./src/connection/connection.schema.ts",
44
- "./docs": "./src/docs/index.ts",
45
- "./docs/integration-hub.docblock": "./src/docs/integration-hub.docblock.ts",
46
- "./events": "./src/events.ts",
47
- "./example": "./src/example.ts",
48
- "./integration": "./src/integration/index.ts",
49
- "./integration-hub.feature": "./src/integration-hub.feature.ts",
50
- "./integration/integration.contracts": "./src/integration/integration.contracts.ts",
51
- "./integration/integration.enum": "./src/integration/integration.enum.ts",
52
- "./integration/integration.presentation": "./src/integration/integration.presentation.ts",
53
- "./integration/integration.schema": "./src/integration/integration.schema.ts",
54
- "./sync": "./src/sync/index.ts",
55
- "./sync-engine": "./src/sync-engine/index.ts",
56
- "./sync/sync.contracts": "./src/sync/sync.contracts.ts",
57
- "./sync/sync.enum": "./src/sync/sync.enum.ts",
58
- "./sync/sync.presentation": "./src/sync/sync.presentation.ts",
59
- "./sync/sync.schema": "./src/sync/sync.schema.ts",
38
+ ".": "./dist/index.js",
39
+ "./connection": "./dist/connection/index.js",
40
+ "./connection/connection.contracts": "./dist/connection/connection.contracts.js",
41
+ "./connection/connection.enum": "./dist/connection/connection.enum.js",
42
+ "./connection/connection.presentation": "./dist/connection/connection.presentation.js",
43
+ "./connection/connection.schema": "./dist/connection/connection.schema.js",
44
+ "./docs": "./dist/docs/index.js",
45
+ "./docs/integration-hub.docblock": "./dist/docs/integration-hub.docblock.js",
46
+ "./events": "./dist/events.js",
47
+ "./example": "./dist/example.js",
48
+ "./integration": "./dist/integration/index.js",
49
+ "./integration-hub.feature": "./dist/integration-hub.feature.js",
50
+ "./integration/integration.contracts": "./dist/integration/integration.contracts.js",
51
+ "./integration/integration.enum": "./dist/integration/integration.enum.js",
52
+ "./integration/integration.presentation": "./dist/integration/integration.presentation.js",
53
+ "./integration/integration.schema": "./dist/integration/integration.schema.js",
54
+ "./sync": "./dist/sync/index.js",
55
+ "./sync-engine": "./dist/sync-engine/index.js",
56
+ "./sync/sync.contracts": "./dist/sync/sync.contracts.js",
57
+ "./sync/sync.enum": "./dist/sync/sync.enum.js",
58
+ "./sync/sync.presentation": "./dist/sync/sync.presentation.js",
59
+ "./sync/sync.schema": "./dist/sync/sync.schema.js",
60
60
  "./*": "./*"
61
61
  },
62
62
  "module": "./dist/index.js",