@contractspec/example.integration-hub 3.7.5 → 3.7.7
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/README.md +70 -183
- package/dist/connection/index.d.ts +1 -1
- package/dist/events.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +596 -594
- package/dist/integration/index.d.ts +1 -1
- package/dist/node/events.js +1 -1
- package/dist/node/index.js +596 -594
- package/dist/node/ui/IntegrationDashboard.js +27 -27
- package/dist/node/ui/hooks/index.js +1 -1
- package/dist/node/ui/hooks/useIntegrationData.js +1 -1
- package/dist/node/ui/index.js +545 -544
- package/dist/sync/index.d.ts +3 -3
- package/dist/ui/IntegrationDashboard.js +27 -27
- package/dist/ui/hooks/index.d.ts +1 -1
- package/dist/ui/hooks/index.js +1 -1
- package/dist/ui/hooks/useIntegrationData.js +1 -1
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.js +545 -544
- package/dist/ui/renderers/index.d.ts +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -1,193 +1,80 @@
|
|
|
1
1
|
# @contractspec/example.integration-hub
|
|
2
2
|
|
|
3
|
-
Website: https://contractspec.io
|
|
3
|
+
Website: https://contractspec.io
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Integration Hub example with sync engine and field mappings for ContractSpec.**
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## What This Demonstrates
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
- **Feature Flag Integration**: Control integration availability
|
|
17
|
-
- **Full Audit Trail**: Track all sync operations
|
|
18
|
-
- **MCP-Ready Providers**: Supports provider configs that call remote MCP tools
|
|
19
|
-
- **Health Strategy Routing**: Supports `health.*` providers with official, aggregator, and gated unofficial fallback transports
|
|
9
|
+
- Connection management with typed schemas and enums.
|
|
10
|
+
- Integration lifecycle (create, configure, sync).
|
|
11
|
+
- Sync engine with field mapping and status tracking.
|
|
12
|
+
- MCP server example for tool integration.
|
|
13
|
+
- Capability and feature definition patterns.
|
|
14
|
+
- React UI with dashboard, hooks, and markdown renderers.
|
|
15
|
+
- Event definitions and operation test-specs.
|
|
20
16
|
|
|
21
|
-
##
|
|
17
|
+
## Running Locally
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- `
|
|
26
|
-
- `
|
|
27
|
-
- `SyncConfig` - Sync configuration for object pairs
|
|
28
|
-
- `FieldMapping` - Field-level mapping configuration
|
|
29
|
-
|
|
30
|
-
### Sync Execution
|
|
31
|
-
|
|
32
|
-
- `SyncRun` - A single sync execution
|
|
33
|
-
- `SyncLog` - Log entries for a sync run
|
|
34
|
-
- `SyncRecord` - Tracks synced records for deduplication
|
|
35
|
-
|
|
36
|
-
## Contracts
|
|
37
|
-
|
|
38
|
-
### Integration Management
|
|
39
|
-
|
|
40
|
-
- `integration.create` - Create a new integration
|
|
41
|
-
- `integration.connection.create` - Create a connection
|
|
42
|
-
|
|
43
|
-
### Sync Configuration
|
|
44
|
-
|
|
45
|
-
- `integration.syncConfig.create` - Create sync config
|
|
46
|
-
- `integration.fieldMapping.add` - Add field mapping
|
|
47
|
-
|
|
48
|
-
### Sync Execution
|
|
49
|
-
|
|
50
|
-
- `integration.sync.trigger` - Trigger manual sync
|
|
51
|
-
- `integration.syncRun.list` - List sync history
|
|
52
|
-
|
|
53
|
-
## Field Mapping Types
|
|
54
|
-
|
|
55
|
-
- **DIRECT**: Direct field copy
|
|
56
|
-
- **TRANSFORM**: Apply transformation expression
|
|
57
|
-
- **LOOKUP**: Lookup from another object
|
|
58
|
-
- **CONSTANT**: Fixed value
|
|
59
|
-
- **COMPUTED**: Computed from multiple fields
|
|
60
|
-
|
|
61
|
-
## Sync Engine
|
|
62
|
-
|
|
63
|
-
The sync engine handles:
|
|
64
|
-
|
|
65
|
-
1. **Change Detection**: Uses checksums to detect changes
|
|
66
|
-
2. **Transformation**: Applies field mappings
|
|
67
|
-
3. **Validation**: Validates required fields
|
|
68
|
-
4. **Deduplication**: Tracks synced records
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
import { createSyncEngine, BasicFieldTransformer } from '@contractspec/example.integration-hub/sync-engine';
|
|
72
|
-
|
|
73
|
-
const engine = createSyncEngine();
|
|
74
|
-
|
|
75
|
-
const result = engine.transformRecord(
|
|
76
|
-
{ id: '123', data: { FirstName: 'John', LastName: 'Doe' } },
|
|
77
|
-
[
|
|
78
|
-
{ sourceField: 'FirstName', targetField: 'first_name', mappingType: 'DIRECT' },
|
|
79
|
-
{ sourceField: 'LastName', targetField: 'last_name', mappingType: 'TRANSFORM', transformExpression: 'uppercase' },
|
|
80
|
-
],
|
|
81
|
-
context
|
|
82
|
-
);
|
|
83
|
-
// { id: '123', data: { first_name: 'John', last_name: 'DOE' } }
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## Transform Expressions
|
|
87
|
-
|
|
88
|
-
- `uppercase` - Convert to uppercase
|
|
89
|
-
- `lowercase` - Convert to lowercase
|
|
90
|
-
- `trim` - Trim whitespace
|
|
91
|
-
- `default:value` - Set default value
|
|
92
|
-
- `concat:separator` - Join array
|
|
93
|
-
- `split:separator` - Split string
|
|
94
|
-
- `number` - Convert to number
|
|
95
|
-
- `boolean` - Convert to boolean
|
|
96
|
-
- `string` - Convert to string
|
|
97
|
-
|
|
98
|
-
## Events
|
|
99
|
-
|
|
100
|
-
- `integration.created` - Integration created
|
|
101
|
-
- `integration.connection.created` - Connection created
|
|
102
|
-
- `integration.connection.statusChanged` - Connection status changed
|
|
103
|
-
- `integration.syncConfig.created` - Sync config created
|
|
104
|
-
- `integration.sync.started` - Sync started
|
|
105
|
-
- `integration.sync.completed` - Sync completed
|
|
106
|
-
- `integration.sync.failed` - Sync failed
|
|
107
|
-
- `integration.record.synced` - Record synced
|
|
19
|
+
From `packages/examples/integration-hub`:
|
|
20
|
+
- `bun run dev`
|
|
21
|
+
- `bun run build`
|
|
22
|
+
- `bun run typecheck`
|
|
108
23
|
|
|
109
24
|
## Usage
|
|
110
25
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
bun run --filter @contractspec/example.integration-hub run:mcp
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
Call a specific MCP tool:
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
export CONTRACTSPEC_INTEGRATION_HUB_MCP_MODE="call"
|
|
174
|
-
export CONTRACTSPEC_INTEGRATION_HUB_MCP_TOOL_NAME="read_file"
|
|
175
|
-
export CONTRACTSPEC_INTEGRATION_HUB_MCP_TOOL_ARGS_JSON='{"path":"README.md"}'
|
|
176
|
-
|
|
177
|
-
bun run --filter @contractspec/example.integration-hub run:mcp
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
Remote MCP transport is also supported via:
|
|
181
|
-
|
|
182
|
-
- `CONTRACTSPEC_INTEGRATION_HUB_MCP_TRANSPORT=http|sse`
|
|
183
|
-
- `CONTRACTSPEC_INTEGRATION_HUB_MCP_URL`
|
|
184
|
-
- `CONTRACTSPEC_INTEGRATION_HUB_MCP_HEADERS_JSON` (optional)
|
|
185
|
-
- `CONTRACTSPEC_INTEGRATION_HUB_MCP_ACCESS_TOKEN` or `..._ACCESS_TOKEN_ENV` (optional)
|
|
186
|
-
|
|
187
|
-
## Dependencies
|
|
188
|
-
|
|
189
|
-
- `@contractspec/lib.identity-rbac` - User identity and roles
|
|
190
|
-
- `@contractspec/lib.feature-flags` - Feature flag control
|
|
191
|
-
- `@contractspec/lib.files` - Import/export file handling
|
|
192
|
-
- `@contractspec/lib.jobs` - Background sync jobs
|
|
193
|
-
- `@contractspec/module.audit-trail` - Action auditing
|
|
26
|
+
Use `@contractspec/example.integration-hub` as a reference implementation, or import its exported surfaces into a workspace that composes ContractSpec examples and bundles.
|
|
27
|
+
|
|
28
|
+
## Architecture
|
|
29
|
+
|
|
30
|
+
- `src/connection` is part of the package's public or composition surface.
|
|
31
|
+
- `src/docs/` contains docblocks and documentation-facing exports.
|
|
32
|
+
- `src/events.ts` is package-level event definitions.
|
|
33
|
+
- `src/example.ts` is the runnable example entrypoint.
|
|
34
|
+
- `src/handlers/` contains handlers or demo adapters wired to contract surfaces.
|
|
35
|
+
- `src/index.ts` is the root public barrel and package entrypoint.
|
|
36
|
+
- `src/integration` is part of the package's public or composition surface.
|
|
37
|
+
|
|
38
|
+
## Public Entry Points
|
|
39
|
+
|
|
40
|
+
- Export `.` resolves through `./src/index.ts`.
|
|
41
|
+
- Export `./connection` resolves through `./src/connection/index.ts`.
|
|
42
|
+
- Export `./connection/connection.enum` resolves through `./src/connection/connection.enum.ts`.
|
|
43
|
+
- Export `./connection/connection.operation` resolves through `./src/connection/connection.operation.ts`.
|
|
44
|
+
- Export `./connection/connection.presentation` resolves through `./src/connection/connection.presentation.ts`.
|
|
45
|
+
- Export `./connection/connection.schema` resolves through `./src/connection/connection.schema.ts`.
|
|
46
|
+
- Export `./docs` resolves through `./src/docs/index.ts`.
|
|
47
|
+
- Export `./docs/integration-hub.docblock` resolves through `./src/docs/integration-hub.docblock.ts`.
|
|
48
|
+
- Export `./events` resolves through `./src/events.ts`.
|
|
49
|
+
- Export `./example` resolves through `./src/example.ts`.
|
|
50
|
+
- The package publishes 36 total export subpaths; keep docs aligned with `package.json`.
|
|
51
|
+
|
|
52
|
+
## Local Commands
|
|
53
|
+
|
|
54
|
+
- `bun run dev` — contractspec-bun-build dev
|
|
55
|
+
- `bun run build` — bun run prebuild && bun run build:bundle && bun run build:types
|
|
56
|
+
- `bun run lint` — bun lint:fix
|
|
57
|
+
- `bun run lint:check` — biome check .
|
|
58
|
+
- `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
|
|
59
|
+
- `bun run typecheck` — tsc --noEmit
|
|
60
|
+
- `bun run validate` — contractspec validate "src/**/*"
|
|
61
|
+
- `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
|
|
62
|
+
- `bun run publish:pkg:canary` — bun publish:pkg --tag canary
|
|
63
|
+
- `bun run clean` — rimraf dist .turbo
|
|
64
|
+
- `bun run build:bundle` — contractspec-bun-build transpile
|
|
65
|
+
- `bun run build:types` — contractspec-bun-build types
|
|
66
|
+
- `bun run run:mcp` — bun tsx src/run-mcp.ts
|
|
67
|
+
- `bun run prebuild` — contractspec-bun-build prebuild
|
|
68
|
+
|
|
69
|
+
## Recent Updates
|
|
70
|
+
|
|
71
|
+
- Replace eslint+prettier by biomejs to optimize speed.
|
|
72
|
+
- Vnext ai-native.
|
|
73
|
+
- Missing contract layers.
|
|
74
|
+
- Resolve lint, build, and type errors across nine packages.
|
|
75
|
+
- Add Composio universal fallback, fix provider-ranking types, and expand package exports.
|
|
76
|
+
- Add first-class transport, auth, versioning, and BYOK support across all integrations.
|
|
77
|
+
|
|
78
|
+
## Notes
|
|
79
|
+
|
|
80
|
+
- Works alongside `@contractspec/lib.ai-agent`, `@contractspec/lib.contracts-spec`, `@contractspec/lib.design-system`, `@contractspec/lib.example-shared-ui`, `@contractspec/lib.runtime-sandbox`, ...
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Connection domain - Connection management.
|
|
3
3
|
*/
|
|
4
4
|
export { ConnectionStatusEnum } from './connection.enum';
|
|
5
|
-
export { ConnectionModel, CreateConnectionInputModel, } from './connection.schema';
|
|
6
5
|
export { CreateConnectionContract } from './connection.operation';
|
|
6
|
+
export { ConnectionModel, CreateConnectionInputModel, } from './connection.schema';
|
package/dist/events.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/events.ts
|
|
3
3
|
import { defineEvent } from "@contractspec/lib.contracts-spec";
|
|
4
|
-
import {
|
|
4
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
5
5
|
var IntegrationCreatedPayload = defineSchemaModel({
|
|
6
6
|
name: "IntegrationCreatedPayload",
|
|
7
7
|
description: "Payload when an integration is created",
|
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Demonstrates a complete integration platform with connections and sync.
|
|
5
5
|
*/
|
|
6
|
-
export * from './integration';
|
|
7
6
|
export * from './connection';
|
|
8
|
-
export * from './sync';
|
|
9
7
|
export { createIntegrationHandlers, type IntegrationHandlers, } from './handlers/integration.handlers';
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './sync-engine';
|
|
8
|
+
export * from './integration';
|
|
12
9
|
export * from './mcp-example';
|
|
10
|
+
export * from './sync';
|
|
11
|
+
export * from './sync-engine';
|
|
12
|
+
export * from './ui';
|