@orgloop/sdk 0.1.0 → 0.1.3
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 +76 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @orgloop/sdk
|
|
2
|
+
|
|
3
|
+
OrgLoop plugin development kit — interfaces, base classes, and test harnesses for building connectors, transforms, and loggers.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @orgloop/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Define a source connector
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import type { SourceConnector, PollResult, ConnectorRegistration } from '@orgloop/sdk';
|
|
17
|
+
|
|
18
|
+
const mySource: SourceConnector = {
|
|
19
|
+
async init(config) { /* set up API clients */ },
|
|
20
|
+
async poll(checkpoint): PollResult { /* fetch events since checkpoint */ },
|
|
21
|
+
async shutdown() { /* cleanup */ },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function register(): ConnectorRegistration {
|
|
25
|
+
return { id: 'my-source', source: mySource };
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Write tests with the test harness
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { MockSource, MockActor, createTestEvent, createTestContext } from '@orgloop/sdk';
|
|
33
|
+
|
|
34
|
+
const source = new MockSource([createTestEvent({ type: 'resource.changed' })]);
|
|
35
|
+
const actor = new MockActor();
|
|
36
|
+
const ctx = createTestContext();
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## API
|
|
40
|
+
|
|
41
|
+
### Types
|
|
42
|
+
|
|
43
|
+
Core event types, config interfaces, and plugin contracts:
|
|
44
|
+
|
|
45
|
+
- `OrgLoopEvent`, `OrgLoopEventType` -- event envelope and type union
|
|
46
|
+
- `SourceConnector`, `ActorConnector` -- connector interfaces
|
|
47
|
+
- `ConnectorRegistration`, `ConnectorSetup` -- plugin registration
|
|
48
|
+
- `Transform`, `TransformContext`, `TransformRegistration` -- transform plugin
|
|
49
|
+
- `Logger`, `LoggerRegistration` -- logger plugin
|
|
50
|
+
- `ProjectConfig`, `OrgLoopConfig` -- configuration types
|
|
51
|
+
- `ModuleManifest`, `ModuleParameter` -- module system types
|
|
52
|
+
|
|
53
|
+
### Helpers
|
|
54
|
+
|
|
55
|
+
- `generateEventId()` / `generateTraceId()` -- ID generation
|
|
56
|
+
- `buildEvent(options)` -- construct well-formed events
|
|
57
|
+
- `validateEvent(event)` -- runtime validation
|
|
58
|
+
- `parseDuration(str)` -- parse duration strings like `"30s"`, `"5m"`
|
|
59
|
+
- `expandTemplate(template, context)` -- module template expansion
|
|
60
|
+
|
|
61
|
+
### Test harness
|
|
62
|
+
|
|
63
|
+
- `MockSource` -- configurable source with canned events
|
|
64
|
+
- `MockActor` -- records delivered events
|
|
65
|
+
- `MockTransform` -- pass-through or custom transform
|
|
66
|
+
- `MockLogger` -- captures log entries
|
|
67
|
+
- `createTestEvent(overrides?)` -- factory for test events
|
|
68
|
+
- `createTestContext()` -- factory for test contexts
|
|
69
|
+
|
|
70
|
+
## Documentation
|
|
71
|
+
|
|
72
|
+
Full documentation at [orgloop.ai](https://orgloop.ai)
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
MIT
|