@brud/sdk 0.0.1 → 0.0.2
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/LICENSE +0 -0
- package/README.md +0 -0
- package/dist/core/contract.d.ts +1 -1
- package/dist/core/contract.js +1 -1
- package/dist/core/errors.d.ts +0 -0
- package/dist/core/errors.js +0 -0
- package/dist/core/names.d.ts +0 -0
- package/dist/core/names.js +0 -0
- package/dist/core/plain.d.ts +0 -0
- package/dist/core/plain.js +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/participant/byCapability.d.ts +0 -0
- package/dist/participant/byCapability.js +0 -0
- package/dist/participant/defineParticipant.d.ts +15 -1
- package/dist/participant/defineParticipant.js +10 -1
- package/dist/participant/index.d.ts +0 -0
- package/dist/participant/index.js +0 -0
- package/dist/testing/harness.d.ts +0 -0
- package/dist/testing/harness.js +0 -0
- package/dist/testing/index.d.ts +0 -0
- package/dist/testing/index.js +0 -0
- package/package.json +2 -2
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/dist/core/contract.d.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* contract version (plan decision S-4); until it does, the SDK records the
|
|
4
4
|
* kernel line it is built and tested against.
|
|
5
5
|
*/
|
|
6
|
-
export declare const SDK_VERSION = "0.0.
|
|
6
|
+
export declare const SDK_VERSION = "0.0.2";
|
|
7
7
|
/** Kernel package line (`major.minor`) this SDK is built and tested against. */
|
|
8
8
|
export declare const SDK_TARGET_KERNEL = "0.0";
|
package/dist/core/contract.js
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* contract version (plan decision S-4); until it does, the SDK records the
|
|
4
4
|
* kernel line it is built and tested against.
|
|
5
5
|
*/
|
|
6
|
-
export const SDK_VERSION = '0.0.
|
|
6
|
+
export const SDK_VERSION = '0.0.2';
|
|
7
7
|
/** Kernel package line (`major.minor`) this SDK is built and tested against. */
|
|
8
8
|
export const SDK_TARGET_KERNEL = '0.0';
|
package/dist/core/errors.d.ts
CHANGED
|
File without changes
|
package/dist/core/errors.js
CHANGED
|
File without changes
|
package/dist/core/names.d.ts
CHANGED
|
File without changes
|
package/dist/core/names.js
CHANGED
|
File without changes
|
package/dist/core/plain.d.ts
CHANGED
|
File without changes
|
package/dist/core/plain.js
CHANGED
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ExposedApiCaller, type ExposedApiResolveOptions, type KernelServiceModuleContext, type ServiceContext, type ServiceDescriptor, type ServiceTier } from '@brud/kernel';
|
|
1
|
+
import { type ExposedApiCaller, type ExposedApiRefusal, type ExposedApiResolveOptions, type EventDeclaration, type InterceptionDeclaration, type InterceptionPointDeclaration, type KernelServiceModuleContext, type KindDeclaration, type ServiceContext, type ServiceDescriptor, type ServiceTier } from '@brud/kernel';
|
|
2
2
|
/** Who may reach an exposure, by call origin (kernel scope semantics). */
|
|
3
3
|
export type ExposureScope = 'kernel' | 'runtime' | 'host' | 'any';
|
|
4
4
|
/** What a participant's code sees: its id, options, instance, and `resolve`. */
|
|
@@ -20,6 +20,12 @@ export interface ParticipantContext<TInstance extends object> {
|
|
|
20
20
|
* scope or policy refuses, and before the participant is running.
|
|
21
21
|
*/
|
|
22
22
|
resolve<T = unknown>(name: string, options?: ExposedApiResolveOptions): T | null;
|
|
23
|
+
/**
|
|
24
|
+
* Why the most recent `resolve` returned `null`, or `null` when it succeeded.
|
|
25
|
+
* Before the participant is running (for example in `create`) exposures are
|
|
26
|
+
* not attached yet, so this reports `no-call-context`.
|
|
27
|
+
*/
|
|
28
|
+
lastRefusal(): ExposedApiRefusal | null;
|
|
23
29
|
}
|
|
24
30
|
/**
|
|
25
31
|
* Builds the handle a caller receives (the exposure's Layer 2 projection).
|
|
@@ -48,6 +54,14 @@ export interface ParticipantDefinition<TInstance extends object> {
|
|
|
48
54
|
readonly requests?: readonly string[];
|
|
49
55
|
/** Exposures, keyed by exposure name. */
|
|
50
56
|
readonly exposes?: Readonly<Record<string, ExposureDefinition<TInstance>>>;
|
|
57
|
+
/** Events this participant declares it may emit. Validated by the kernel when the participant is admitted. */
|
|
58
|
+
readonly events?: readonly EventDeclaration[];
|
|
59
|
+
/** Exposures of other givers this participant intercepts. Implement `intercept` on the instance. */
|
|
60
|
+
readonly interceptions?: readonly InterceptionDeclaration[];
|
|
61
|
+
/** Interception points on this participant's own exposures, naming the interceptors it admits by token id. */
|
|
62
|
+
readonly interceptionPoints?: readonly InterceptionPointDeclaration[];
|
|
63
|
+
/** Syntax kinds this participant serves. Each names one of its own exposures, which dispatches the kind. */
|
|
64
|
+
readonly kinds?: readonly KindDeclaration[];
|
|
51
65
|
/** Builds the participant's instance. */
|
|
52
66
|
readonly create: (ctx: ParticipantContext<TInstance>) => TInstance;
|
|
53
67
|
/** Runs once the kernel is running (`resolve` is live). */
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { ExposedApiRegistryToken, createServiceToken, withExposureBindings, } from '@brud/kernel';
|
|
2
2
|
import { SdkError } from '../core/errors.js';
|
|
3
3
|
import { assertMajor, assertName, exposureKey } from '../core/names.js';
|
|
4
|
+
/** What `lastRefusal` reports before the registry is attached. */
|
|
5
|
+
const NOT_ATTACHED = Object.freeze({
|
|
6
|
+
code: 'no-call-context',
|
|
7
|
+
message: 'no kernel call context: exposures are not attached yet (for example during synchronous create)',
|
|
8
|
+
});
|
|
4
9
|
/**
|
|
5
10
|
* Defines a participant and returns its service module's `createService`.
|
|
6
11
|
*
|
|
@@ -33,7 +38,10 @@ export function defineParticipant(definition) {
|
|
|
33
38
|
scope: exposure.scope ?? 'runtime',
|
|
34
39
|
...(exposure.policy === undefined ? {} : { policy: exposure.policy }),
|
|
35
40
|
})),
|
|
36
|
-
events: [],
|
|
41
|
+
events: [...(definition.events ?? [])],
|
|
42
|
+
...(definition.interceptions === undefined ? {} : { interceptions: [...definition.interceptions] }),
|
|
43
|
+
...(definition.interceptionPoints === undefined ? {} : { interceptionPoints: [...definition.interceptionPoints] }),
|
|
44
|
+
...(definition.kinds === undefined ? {} : { kinds: [...definition.kinds] }),
|
|
37
45
|
});
|
|
38
46
|
const token = createServiceToken(id, definition.description ?? `Participant "${id}"`);
|
|
39
47
|
return (moduleContext) => ({
|
|
@@ -59,6 +67,7 @@ export function defineParticipant(definition) {
|
|
|
59
67
|
return registry !== undefined;
|
|
60
68
|
},
|
|
61
69
|
resolve: (name, options) => registry === undefined ? null : registry.resolve(name, options),
|
|
70
|
+
lastRefusal: () => registry === undefined ? NOT_ATTACHED : registry.lastRefusal(),
|
|
62
71
|
};
|
|
63
72
|
const created = definition.create(ctx);
|
|
64
73
|
if (created === null || typeof created !== 'object') {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/testing/harness.js
CHANGED
|
File without changes
|
package/dist/testing/index.d.ts
CHANGED
|
File without changes
|
package/dist/testing/index.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brud/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "The BrudOS SDK: define, compose, test and ship participants on the Brud kernel",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"test": "node --import tsx --test __tests__/*.test.ts"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@brud/kernel": "^0.0.
|
|
38
|
+
"@brud/kernel": "^0.0.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "22.x"
|