@contractspec/example.integration-hub 1.57.0 → 1.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/connection/connection.enum.js +12 -0
- package/dist/browser/connection/connection.operation.js +101 -0
- package/dist/browser/connection/connection.presentation.js +99 -0
- package/dist/browser/connection/connection.schema.js +48 -0
- package/dist/browser/connection/index.js +104 -0
- package/dist/browser/docs/index.js +104 -0
- package/dist/browser/docs/integration-hub.docblock.js +104 -0
- package/dist/browser/events.js +211 -0
- package/dist/browser/example.js +42 -0
- package/dist/browser/handlers/index.js +246 -0
- package/dist/browser/handlers/integration.handlers.js +246 -0
- package/dist/browser/index.js +1595 -0
- package/dist/browser/integration/index.js +92 -0
- package/dist/browser/integration/integration.enum.js +12 -0
- package/dist/browser/integration/integration.operations.js +89 -0
- package/dist/browser/integration/integration.presentation.js +117 -0
- package/dist/browser/integration/integration.schema.js +42 -0
- package/dist/browser/integration-hub.capability.js +40 -0
- package/dist/browser/integration-hub.feature.js +114 -0
- package/dist/browser/seeders/index.js +60 -0
- package/dist/browser/sync/index.js +332 -0
- package/dist/browser/sync/sync.enum.js +26 -0
- package/dist/browser/sync/sync.operations.js +321 -0
- package/dist/browser/sync/sync.presentation.js +298 -0
- package/dist/browser/sync/sync.schema.js +154 -0
- package/dist/browser/sync-engine/index.js +186 -0
- package/dist/browser/tests/operations.test-spec.js +85 -0
- package/dist/browser/ui/IntegrationDashboard.js +369 -0
- package/dist/browser/ui/hooks/index.js +57 -0
- package/dist/browser/ui/hooks/useIntegrationData.js +54 -0
- package/dist/browser/ui/index.js +644 -0
- package/dist/browser/ui/renderers/index.js +273 -0
- package/dist/browser/ui/renderers/integration.markdown.js +273 -0
- package/dist/connection/connection.enum.d.ts +1 -6
- package/dist/connection/connection.enum.d.ts.map +1 -1
- package/dist/connection/connection.enum.js +11 -15
- package/dist/connection/connection.operation.d.ts +78 -84
- package/dist/connection/connection.operation.d.ts.map +1 -1
- package/dist/connection/connection.operation.js +99 -60
- package/dist/connection/connection.presentation.d.ts +2 -7
- package/dist/connection/connection.presentation.d.ts.map +1 -1
- package/dist/connection/connection.presentation.js +96 -56
- package/dist/connection/connection.schema.d.ts +54 -59
- package/dist/connection/connection.schema.d.ts.map +1 -1
- package/dist/connection/connection.schema.js +46 -73
- package/dist/connection/index.d.ts +7 -4
- package/dist/connection/index.d.ts.map +1 -0
- package/dist/connection/index.js +104 -4
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +105 -1
- package/dist/docs/integration-hub.docblock.d.ts +2 -1
- package/dist/docs/integration-hub.docblock.d.ts.map +1 -0
- package/dist/docs/integration-hub.docblock.js +45 -56
- package/dist/events.d.ts +137 -143
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +210 -287
- package/dist/example.d.ts +2 -6
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +41 -55
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +247 -3
- package/dist/handlers/integration.handlers.d.ts +114 -113
- package/dist/handlers/integration.handlers.d.ts.map +1 -1
- package/dist/handlers/integration.handlers.js +232 -267
- package/dist/index.d.ts +12 -19
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1596 -20
- package/dist/integration/index.d.ts +7 -4
- package/dist/integration/index.d.ts.map +1 -0
- package/dist/integration/index.js +92 -4
- package/dist/integration/integration.enum.d.ts +1 -6
- package/dist/integration/integration.enum.d.ts.map +1 -1
- package/dist/integration/integration.enum.js +11 -15
- package/dist/integration/integration.operations.d.ts +74 -80
- package/dist/integration/integration.operations.d.ts.map +1 -1
- package/dist/integration/integration.operations.js +87 -54
- package/dist/integration/integration.presentation.d.ts +3 -8
- package/dist/integration/integration.presentation.d.ts.map +1 -1
- package/dist/integration/integration.presentation.js +114 -73
- package/dist/integration/integration.schema.d.ts +54 -59
- package/dist/integration/integration.schema.d.ts.map +1 -1
- package/dist/integration/integration.schema.js +40 -73
- package/dist/integration-hub.capability.d.ts +3 -8
- package/dist/integration-hub.capability.d.ts.map +1 -1
- package/dist/integration-hub.capability.js +41 -38
- package/dist/integration-hub.feature.d.ts +1 -6
- package/dist/integration-hub.feature.d.ts.map +1 -1
- package/dist/integration-hub.feature.js +113 -242
- package/dist/node/connection/connection.enum.js +12 -0
- package/dist/node/connection/connection.operation.js +101 -0
- package/dist/node/connection/connection.presentation.js +99 -0
- package/dist/node/connection/connection.schema.js +48 -0
- package/dist/node/connection/index.js +104 -0
- package/dist/node/docs/index.js +104 -0
- package/dist/node/docs/integration-hub.docblock.js +104 -0
- package/dist/node/events.js +211 -0
- package/dist/node/example.js +42 -0
- package/dist/node/handlers/index.js +246 -0
- package/dist/node/handlers/integration.handlers.js +246 -0
- package/dist/node/index.js +1595 -0
- package/dist/node/integration/index.js +92 -0
- package/dist/node/integration/integration.enum.js +12 -0
- package/dist/node/integration/integration.operations.js +89 -0
- package/dist/node/integration/integration.presentation.js +117 -0
- package/dist/node/integration/integration.schema.js +42 -0
- package/dist/node/integration-hub.capability.js +40 -0
- package/dist/node/integration-hub.feature.js +114 -0
- package/dist/node/seeders/index.js +60 -0
- package/dist/node/sync/index.js +332 -0
- package/dist/node/sync/sync.enum.js +26 -0
- package/dist/node/sync/sync.operations.js +321 -0
- package/dist/node/sync/sync.presentation.js +298 -0
- package/dist/node/sync/sync.schema.js +154 -0
- package/dist/node/sync-engine/index.js +186 -0
- package/dist/node/tests/operations.test-spec.js +85 -0
- package/dist/node/ui/IntegrationDashboard.js +369 -0
- package/dist/node/ui/hooks/index.js +57 -0
- package/dist/node/ui/hooks/useIntegrationData.js +54 -0
- package/dist/node/ui/index.js +644 -0
- package/dist/node/ui/renderers/index.js +273 -0
- package/dist/node/ui/renderers/integration.markdown.js +273 -0
- package/dist/seeders/index.d.ts +4 -8
- package/dist/seeders/index.d.ts.map +1 -1
- package/dist/seeders/index.js +54 -52
- package/dist/sync/index.d.ts +7 -4
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +332 -4
- package/dist/sync/sync.enum.d.ts +3 -8
- package/dist/sync/sync.enum.d.ts.map +1 -1
- package/dist/sync/sync.enum.js +23 -31
- package/dist/sync/sync.operations.d.ts +413 -419
- package/dist/sync/sync.operations.d.ts.map +1 -1
- package/dist/sync/sync.operations.js +316 -197
- package/dist/sync/sync.presentation.d.ts +6 -11
- package/dist/sync/sync.presentation.d.ts.map +1 -1
- package/dist/sync/sync.presentation.js +291 -160
- package/dist/sync/sync.schema.d.ts +317 -322
- package/dist/sync/sync.schema.d.ts.map +1 -1
- package/dist/sync/sync.schema.js +146 -295
- package/dist/sync-engine/index.d.ts +88 -91
- package/dist/sync-engine/index.d.ts.map +1 -1
- package/dist/sync-engine/index.js +181 -142
- package/dist/tests/operations.test-spec.d.ts +3 -8
- package/dist/tests/operations.test-spec.d.ts.map +1 -1
- package/dist/tests/operations.test-spec.js +82 -90
- package/dist/ui/IntegrationDashboard.d.ts +1 -6
- package/dist/ui/IntegrationDashboard.d.ts.map +1 -1
- package/dist/ui/IntegrationDashboard.js +365 -261
- package/dist/ui/hooks/index.d.ts +2 -2
- package/dist/ui/hooks/index.d.ts.map +1 -0
- package/dist/ui/hooks/index.js +57 -4
- package/dist/ui/hooks/useIntegrationData.d.ts +16 -20
- package/dist/ui/hooks/useIntegrationData.d.ts.map +1 -1
- package/dist/ui/hooks/useIntegrationData.js +51 -55
- package/dist/ui/index.d.ts +7 -6
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +644 -5
- package/dist/ui/renderers/index.d.ts +2 -2
- package/dist/ui/renderers/index.d.ts.map +1 -0
- package/dist/ui/renderers/index.js +274 -3
- package/dist/ui/renderers/integration.markdown.d.ts +13 -14
- package/dist/ui/renderers/integration.markdown.d.ts.map +1 -1
- package/dist/ui/renderers/integration.markdown.js +268 -264
- package/package.json +360 -71
- package/dist/connection/connection.enum.js.map +0 -1
- package/dist/connection/connection.operation.js.map +0 -1
- package/dist/connection/connection.presentation.js.map +0 -1
- package/dist/connection/connection.schema.js.map +0 -1
- package/dist/docs/integration-hub.docblock.js.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/example.js.map +0 -1
- package/dist/handlers/integration.handlers.js.map +0 -1
- package/dist/integration/integration.enum.js.map +0 -1
- package/dist/integration/integration.operations.js.map +0 -1
- package/dist/integration/integration.presentation.js.map +0 -1
- package/dist/integration/integration.schema.js.map +0 -1
- package/dist/integration-hub.capability.js.map +0 -1
- package/dist/integration-hub.feature.js.map +0 -1
- package/dist/seeders/index.js.map +0 -1
- package/dist/sync/sync.enum.js.map +0 -1
- package/dist/sync/sync.operations.js.map +0 -1
- package/dist/sync/sync.presentation.js.map +0 -1
- package/dist/sync/sync.schema.js.map +0 -1
- package/dist/sync-engine/index.js.map +0 -1
- package/dist/tests/operations.test-spec.js.map +0 -1
- package/dist/ui/IntegrationDashboard.js.map +0 -1
- package/dist/ui/hooks/useIntegrationData.js.map +0 -1
- package/dist/ui/renderers/integration.markdown.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync-engine/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;IACzE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE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|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/sync-engine/index.ts
|
|
3
|
+
class BasicFieldTransformer {
|
|
4
|
+
transform(value, expression) {
|
|
5
|
+
try {
|
|
6
|
+
if (expression.startsWith("uppercase")) {
|
|
7
|
+
return typeof value === "string" ? value.toUpperCase() : value;
|
|
8
|
+
}
|
|
9
|
+
if (expression.startsWith("lowercase")) {
|
|
10
|
+
return typeof value === "string" ? value.toLowerCase() : value;
|
|
11
|
+
}
|
|
12
|
+
if (expression.startsWith("trim")) {
|
|
13
|
+
return typeof value === "string" ? value.trim() : value;
|
|
14
|
+
}
|
|
15
|
+
if (expression.startsWith("default:")) {
|
|
16
|
+
const defaultVal = expression.replace("default:", "");
|
|
17
|
+
return value ?? JSON.parse(defaultVal);
|
|
18
|
+
}
|
|
19
|
+
if (expression.startsWith("concat:")) {
|
|
20
|
+
const separator = expression.replace("concat:", "") || " ";
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
return value.join(separator);
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
if (expression.startsWith("split:")) {
|
|
27
|
+
const separator = expression.replace("split:", "") || ",";
|
|
28
|
+
if (typeof value === "string") {
|
|
29
|
+
return value.split(separator);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
if (expression.startsWith("number")) {
|
|
34
|
+
return Number(value);
|
|
35
|
+
}
|
|
36
|
+
if (expression.startsWith("boolean")) {
|
|
37
|
+
return Boolean(value);
|
|
38
|
+
}
|
|
39
|
+
if (expression.startsWith("string")) {
|
|
40
|
+
return String(value);
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
} catch {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class BasicSyncEngine {
|
|
50
|
+
transformer;
|
|
51
|
+
constructor(transformer) {
|
|
52
|
+
this.transformer = transformer ?? new BasicFieldTransformer;
|
|
53
|
+
}
|
|
54
|
+
async sync(_context) {
|
|
55
|
+
const result = {
|
|
56
|
+
success: true,
|
|
57
|
+
recordsProcessed: 0,
|
|
58
|
+
recordsCreated: 0,
|
|
59
|
+
recordsUpdated: 0,
|
|
60
|
+
recordsDeleted: 0,
|
|
61
|
+
recordsFailed: 0,
|
|
62
|
+
recordsSkipped: 0,
|
|
63
|
+
errors: []
|
|
64
|
+
};
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
transformRecord(sourceRecord, mappings, _context) {
|
|
68
|
+
const targetData = {};
|
|
69
|
+
for (const mapping of mappings) {
|
|
70
|
+
let value;
|
|
71
|
+
let sourceValue;
|
|
72
|
+
switch (mapping.mappingType) {
|
|
73
|
+
case "DIRECT":
|
|
74
|
+
value = this.getNestedValue(sourceRecord.data, mapping.sourceField);
|
|
75
|
+
break;
|
|
76
|
+
case "TRANSFORM":
|
|
77
|
+
sourceValue = this.getNestedValue(sourceRecord.data, mapping.sourceField);
|
|
78
|
+
value = mapping.transformExpression ? this.transformer.transform(sourceValue, mapping.transformExpression) : sourceValue;
|
|
79
|
+
break;
|
|
80
|
+
case "CONSTANT":
|
|
81
|
+
value = mapping.constantValue;
|
|
82
|
+
break;
|
|
83
|
+
case "LOOKUP":
|
|
84
|
+
value = this.getNestedValue(sourceRecord.data, mapping.sourceField);
|
|
85
|
+
break;
|
|
86
|
+
case "COMPUTED":
|
|
87
|
+
value = mapping.transformExpression ? this.evaluateComputed(sourceRecord.data, mapping.transformExpression) : null;
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
value = this.getNestedValue(sourceRecord.data, mapping.sourceField);
|
|
91
|
+
}
|
|
92
|
+
if (value === undefined || value === null) {
|
|
93
|
+
value = mapping.defaultValue;
|
|
94
|
+
}
|
|
95
|
+
this.setNestedValue(targetData, mapping.targetField, value);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
id: sourceRecord.id,
|
|
99
|
+
data: targetData
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
validateRecord(record, mappings) {
|
|
103
|
+
const errors = [];
|
|
104
|
+
for (const mapping of mappings) {
|
|
105
|
+
if (mapping.isRequired) {
|
|
106
|
+
const value = this.getNestedValue(record.data, mapping.targetField);
|
|
107
|
+
if (value === undefined || value === null) {
|
|
108
|
+
errors.push({
|
|
109
|
+
recordId: record.id,
|
|
110
|
+
field: mapping.targetField,
|
|
111
|
+
message: `Required field ${mapping.targetField} is missing`,
|
|
112
|
+
code: "REQUIRED_FIELD_MISSING"
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
valid: errors.length === 0,
|
|
119
|
+
errors
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
getNestedValue(obj, path) {
|
|
123
|
+
const parts = path.split(".");
|
|
124
|
+
let current = obj;
|
|
125
|
+
for (const part of parts) {
|
|
126
|
+
if (current === null || current === undefined) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
current = current[part];
|
|
130
|
+
}
|
|
131
|
+
return current;
|
|
132
|
+
}
|
|
133
|
+
setNestedValue(obj, path, value) {
|
|
134
|
+
const parts = path.split(".");
|
|
135
|
+
let current = obj;
|
|
136
|
+
for (let i = 0;i < parts.length - 1; i++) {
|
|
137
|
+
const part = parts[i];
|
|
138
|
+
if (part === undefined)
|
|
139
|
+
continue;
|
|
140
|
+
if (!(part in current)) {
|
|
141
|
+
current[part] = {};
|
|
142
|
+
}
|
|
143
|
+
current = current[part];
|
|
144
|
+
}
|
|
145
|
+
const lastPart = parts[parts.length - 1];
|
|
146
|
+
if (lastPart !== undefined) {
|
|
147
|
+
current[lastPart] = value;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
evaluateComputed(data, expression) {
|
|
151
|
+
try {
|
|
152
|
+
const result = expression.replace(/\$\{([^}]+)\}/g, (_, path) => {
|
|
153
|
+
const value = this.getNestedValue(data, path);
|
|
154
|
+
return String(value ?? "");
|
|
155
|
+
});
|
|
156
|
+
return result;
|
|
157
|
+
} catch {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
128
162
|
function createSyncEngine(transformer) {
|
|
129
|
-
|
|
163
|
+
return new BasicSyncEngine(transformer);
|
|
130
164
|
}
|
|
131
165
|
function computeChecksum(data) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
166
|
+
const str = JSON.stringify(data, Object.keys(data).sort());
|
|
167
|
+
let hash = 0;
|
|
168
|
+
for (let i = 0;i < str.length; i++) {
|
|
169
|
+
const char = str.charCodeAt(i);
|
|
170
|
+
hash = (hash << 5) - hash + char;
|
|
171
|
+
hash = hash & hash;
|
|
172
|
+
}
|
|
173
|
+
return hash.toString(16);
|
|
140
174
|
}
|
|
141
175
|
function hasChanges(sourceChecksum, targetChecksum) {
|
|
142
|
-
|
|
143
|
-
|
|
176
|
+
if (!sourceChecksum || !targetChecksum) {
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
return sourceChecksum !== targetChecksum;
|
|
144
180
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
181
|
+
export {
|
|
182
|
+
hasChanges,
|
|
183
|
+
createSyncEngine,
|
|
184
|
+
computeChecksum,
|
|
185
|
+
BasicSyncEngine,
|
|
186
|
+
BasicFieldTransformer
|
|
187
|
+
};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare const SyncConfigCreateTest: _contractspec_lib_contracts0.TestSpec;
|
|
5
|
-
declare const FieldMappingAddTest: _contractspec_lib_contracts0.TestSpec;
|
|
6
|
-
declare const SyncRunListTest: _contractspec_lib_contracts0.TestSpec;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { FieldMappingAddTest, SyncConfigCreateTest, SyncRunListTest };
|
|
1
|
+
export declare const SyncConfigCreateTest: import("@contractspec/lib.contracts").TestSpec;
|
|
2
|
+
export declare const FieldMappingAddTest: import("@contractspec/lib.contracts").TestSpec;
|
|
3
|
+
export declare const SyncRunListTest: import("@contractspec/lib.contracts").TestSpec;
|
|
9
4
|
//# sourceMappingURL=operations.test-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.test-spec.d.ts","
|
|
1
|
+
{"version":3,"file":"operations.test-spec.d.ts","sourceRoot":"","sources":["../../src/tests/operations.test-spec.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,gDAyB/B,CAAC;AAEH,eAAO,MAAM,mBAAmB,gDAyB9B,CAAC;AAEH,eAAO,MAAM,eAAe,gDAyB1B,CAAC"}
|
|
@@ -1,94 +1,86 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/tests/operations.test-spec.ts
|
|
1
3
|
import { defineTestSpec } from "@contractspec/lib.contracts";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, {
|
|
28
|
-
key: "error",
|
|
29
|
-
when: { operation: { key: "integration.syncConfig.create" } },
|
|
30
|
-
then: [{ type: "expectError" }]
|
|
31
|
-
}]
|
|
4
|
+
var SyncConfigCreateTest = defineTestSpec({
|
|
5
|
+
meta: {
|
|
6
|
+
key: "integration.syncConfig.create.test",
|
|
7
|
+
version: "1.0.0",
|
|
8
|
+
stability: "experimental",
|
|
9
|
+
owners: ["@example.integration-hub"],
|
|
10
|
+
description: "Test for creating sync config",
|
|
11
|
+
tags: ["test"]
|
|
12
|
+
},
|
|
13
|
+
target: {
|
|
14
|
+
type: "operation",
|
|
15
|
+
operation: { key: "integration.syncConfig.create", version: "1.0.0" }
|
|
16
|
+
},
|
|
17
|
+
scenarios: [
|
|
18
|
+
{
|
|
19
|
+
key: "success",
|
|
20
|
+
when: { operation: { key: "integration.syncConfig.create" } },
|
|
21
|
+
then: [{ type: "expectOutput", match: {} }]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
key: "error",
|
|
25
|
+
when: { operation: { key: "integration.syncConfig.create" } },
|
|
26
|
+
then: [{ type: "expectError" }]
|
|
27
|
+
}
|
|
28
|
+
]
|
|
32
29
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
when: { operation: { key: "integration.fieldMapping.add" } },
|
|
59
|
-
then: [{ type: "expectError" }]
|
|
60
|
-
}]
|
|
30
|
+
var FieldMappingAddTest = defineTestSpec({
|
|
31
|
+
meta: {
|
|
32
|
+
key: "integration.fieldMapping.add.test",
|
|
33
|
+
version: "1.0.0",
|
|
34
|
+
stability: "experimental",
|
|
35
|
+
owners: ["@example.integration-hub"],
|
|
36
|
+
description: "Test for adding field mapping",
|
|
37
|
+
tags: ["test"]
|
|
38
|
+
},
|
|
39
|
+
target: {
|
|
40
|
+
type: "operation",
|
|
41
|
+
operation: { key: "integration.fieldMapping.add", version: "1.0.0" }
|
|
42
|
+
},
|
|
43
|
+
scenarios: [
|
|
44
|
+
{
|
|
45
|
+
key: "success",
|
|
46
|
+
when: { operation: { key: "integration.fieldMapping.add" } },
|
|
47
|
+
then: [{ type: "expectOutput", match: {} }]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
key: "error",
|
|
51
|
+
when: { operation: { key: "integration.fieldMapping.add" } },
|
|
52
|
+
then: [{ type: "expectError" }]
|
|
53
|
+
}
|
|
54
|
+
]
|
|
61
55
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
when: { operation: { key: "integration.syncRun.list" } },
|
|
88
|
-
then: [{ type: "expectError" }]
|
|
89
|
-
}]
|
|
56
|
+
var SyncRunListTest = defineTestSpec({
|
|
57
|
+
meta: {
|
|
58
|
+
key: "integration.syncRun.list.test",
|
|
59
|
+
version: "1.0.0",
|
|
60
|
+
stability: "experimental",
|
|
61
|
+
owners: ["@example.integration-hub"],
|
|
62
|
+
description: "Test for listing sync runs",
|
|
63
|
+
tags: ["test"]
|
|
64
|
+
},
|
|
65
|
+
target: {
|
|
66
|
+
type: "operation",
|
|
67
|
+
operation: { key: "integration.syncRun.list", version: "1.0.0" }
|
|
68
|
+
},
|
|
69
|
+
scenarios: [
|
|
70
|
+
{
|
|
71
|
+
key: "success",
|
|
72
|
+
when: { operation: { key: "integration.syncRun.list" } },
|
|
73
|
+
then: [{ type: "expectOutput", match: {} }]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
key: "error",
|
|
77
|
+
when: { operation: { key: "integration.syncRun.list" } },
|
|
78
|
+
then: [{ type: "expectError" }]
|
|
79
|
+
}
|
|
80
|
+
]
|
|
90
81
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
82
|
+
export {
|
|
83
|
+
SyncRunListTest,
|
|
84
|
+
SyncConfigCreateTest,
|
|
85
|
+
FieldMappingAddTest
|
|
86
|
+
};
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//#region src/ui/IntegrationDashboard.d.ts
|
|
4
|
-
declare function IntegrationDashboard(): react_jsx_runtime0.JSX.Element;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { IntegrationDashboard };
|
|
1
|
+
export declare function IntegrationDashboard(): import("react/jsx-runtime").JSX.Element;
|
|
7
2
|
//# sourceMappingURL=IntegrationDashboard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntegrationDashboard.d.ts","
|
|
1
|
+
{"version":3,"file":"IntegrationDashboard.d.ts","sourceRoot":"","sources":["../../src/ui/IntegrationDashboard.tsx"],"names":[],"mappings":"AA4CA,wBAAgB,oBAAoB,4CAsOnC"}
|