@telorun/sdk 0.2.3 → 0.2.4
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 +3 -3
- package/dist/context-provider.d.ts +17 -0
- package/dist/context-provider.js +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/resource-context.d.ts +10 -1
- package/dist/runtime-error.d.ts +1 -1
- package/package.json +1 -1
- package/src/context-provider.ts +25 -0
- package/src/index.ts +1 -0
- package/src/resource-context.ts +7 -1
- package/src/runtime-error.ts +2 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Telo SDK (Node.js)
|
|
2
2
|
|
|
3
|
-
The Node.js SDK provides the authoring surface for Telo modules. It defines the shared contracts (types and lifecycle interfaces) that modules use to plug into the
|
|
3
|
+
The Node.js SDK provides the authoring surface for Telo modules. It defines the shared contracts (types and lifecycle interfaces) that modules use to plug into the kernel, so module code stays consistent across implementations.
|
|
4
4
|
|
|
5
5
|
## What It Provides
|
|
6
6
|
|
|
@@ -14,10 +14,10 @@ Early prototype. APIs and contracts are still evolving. The API surface - includ
|
|
|
14
14
|
|
|
15
15
|
## When to Use It
|
|
16
16
|
|
|
17
|
-
Use the SDK when building or extending Telo modules. It is not the
|
|
17
|
+
Use the SDK when building or extending Telo modules. It is not the kernel itself; it is the contract layer that keeps module behavior consistent and predictable.
|
|
18
18
|
|
|
19
19
|
## Related Docs
|
|
20
20
|
|
|
21
|
-
-
|
|
21
|
+
- Kernel overview: `kernel/README.md`
|
|
22
22
|
- Built‑in modules: `modiles/`
|
|
23
23
|
- SDKs index: `sdk/README.md`
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional interface that a ResourceInstance can implement to expose
|
|
3
|
+
* stable, boot-time key/value pairs into the shared CEL context.
|
|
4
|
+
*
|
|
5
|
+
* Values are captured once after init() completes and cached for the
|
|
6
|
+
* lifetime of the initialization phase. Do not return request-specific
|
|
7
|
+
* or mutable data — this is AOT (Ahead-of-Time) static context only.
|
|
8
|
+
*/
|
|
9
|
+
export interface ContextProvider {
|
|
10
|
+
provideContext(): Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Duck-type guard: returns true when `instance` has a callable `provideContext` method.
|
|
14
|
+
* The kernel uses this to detect providers without coupling to any concrete class,
|
|
15
|
+
* keeping the Core 100% generic.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isContextProvider(instance: unknown): instance is ContextProvider;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Duck-type guard: returns true when `instance` has a callable `provideContext` method.
|
|
3
|
+
* The kernel uses this to detect providers without coupling to any concrete class,
|
|
4
|
+
* keeping the Core 100% generic.
|
|
5
|
+
*/
|
|
6
|
+
export function isContextProvider(instance) {
|
|
7
|
+
return (typeof instance === 'object' &&
|
|
8
|
+
instance !== null &&
|
|
9
|
+
'provideContext' in instance &&
|
|
10
|
+
typeof instance['provideContext'] === 'function');
|
|
11
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -15,9 +15,18 @@ export interface ResourceContext extends ControllerContext {
|
|
|
15
15
|
getResources(kind: string): RuntimeResource[];
|
|
16
16
|
getResourcesByName(kind: string, name: string): RuntimeResource | null;
|
|
17
17
|
registerManifest(resource: any): void;
|
|
18
|
+
resolveChildren(resource: any, resourceName?: string): {
|
|
19
|
+
kind: string;
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
18
22
|
validateSchema(value: any, schema: any): void;
|
|
19
23
|
createSchemaValidator(schema: any): DataValidator;
|
|
20
|
-
|
|
24
|
+
registerSchema(name: string, schema: object): void;
|
|
25
|
+
lookupSchema(name: string): object | undefined;
|
|
26
|
+
registerController(moduleName: string, kindName: string, controllerInstance: any): Promise<void>;
|
|
21
27
|
registerDefinition(definition: any): void;
|
|
28
|
+
registerCapability(name: string, schema?: Record<string, any>): void;
|
|
29
|
+
isCapabilityRegistered(name: string): boolean;
|
|
30
|
+
getCapabilitySchema(name: string): Record<string, any> | null | undefined;
|
|
22
31
|
teardownResource(kind: string, name: string): Promise<void>;
|
|
23
32
|
}
|
package/dist/runtime-error.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type RuntimeErrorCode = 'ERR_RESOURCE_NOT_FOUND' | 'ERR_CONTROLLER_NOT_FOUND' | 'ERR_CONTROLLER_INVALID' | 'ERR_RESOURCE_NOT_INVOKABLE' | 'ERR_DUPLICATE_RESOURCE' | 'ERR_EXECUTION_FAILED' | 'ERR_INVALID_VALUE';
|
|
1
|
+
export type RuntimeErrorCode = 'ERR_RESOURCE_NOT_FOUND' | 'ERR_CONTROLLER_NOT_FOUND' | 'ERR_CONTROLLER_INVALID' | 'ERR_RESOURCE_NOT_INVOKABLE' | 'ERR_DUPLICATE_RESOURCE' | 'ERR_EXECUTION_FAILED' | 'ERR_INVALID_VALUE' | 'ERR_VISIBILITY_DENIED';
|
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional interface that a ResourceInstance can implement to expose
|
|
3
|
+
* stable, boot-time key/value pairs into the shared CEL context.
|
|
4
|
+
*
|
|
5
|
+
* Values are captured once after init() completes and cached for the
|
|
6
|
+
* lifetime of the initialization phase. Do not return request-specific
|
|
7
|
+
* or mutable data — this is AOT (Ahead-of-Time) static context only.
|
|
8
|
+
*/
|
|
9
|
+
export interface ContextProvider {
|
|
10
|
+
provideContext(): Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Duck-type guard: returns true when `instance` has a callable `provideContext` method.
|
|
15
|
+
* The kernel uses this to detect providers without coupling to any concrete class,
|
|
16
|
+
* keeping the Core 100% generic.
|
|
17
|
+
*/
|
|
18
|
+
export function isContextProvider(instance: unknown): instance is ContextProvider {
|
|
19
|
+
return (
|
|
20
|
+
typeof instance === 'object' &&
|
|
21
|
+
instance !== null &&
|
|
22
|
+
'provideContext' in instance &&
|
|
23
|
+
typeof (instance as Record<string, unknown>)['provideContext'] === 'function'
|
|
24
|
+
);
|
|
25
|
+
}
|
package/src/index.ts
CHANGED
package/src/resource-context.ts
CHANGED
|
@@ -23,13 +23,19 @@ export interface ResourceContext extends ControllerContext {
|
|
|
23
23
|
getResources(kind: string): RuntimeResource[];
|
|
24
24
|
getResourcesByName(kind: string, name: string): RuntimeResource | null;
|
|
25
25
|
registerManifest(resource: any): void;
|
|
26
|
+
resolveChildren(resource: any, resourceName?: string): { kind: string; name: string };
|
|
26
27
|
validateSchema(value: any, schema: any): void;
|
|
27
28
|
createSchemaValidator(schema: any): DataValidator;
|
|
29
|
+
registerSchema(name: string, schema: object): void;
|
|
30
|
+
lookupSchema(name: string): object | undefined;
|
|
28
31
|
registerController(
|
|
29
32
|
moduleName: string,
|
|
30
|
-
|
|
33
|
+
kindName: string,
|
|
31
34
|
controllerInstance: any,
|
|
32
35
|
): Promise<void>;
|
|
33
36
|
registerDefinition(definition: any): void;
|
|
37
|
+
registerCapability(name: string, schema?: Record<string, any>): void;
|
|
38
|
+
isCapabilityRegistered(name: string): boolean;
|
|
39
|
+
getCapabilitySchema(name: string): Record<string, any> | null | undefined;
|
|
34
40
|
teardownResource(kind: string, name: string): Promise<void>;
|
|
35
41
|
}
|
package/src/runtime-error.ts
CHANGED