@ouispec/bindings 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +18 -2
- package/dist/binding.d.ts +46 -0
- package/dist/binding.d.ts.map +1 -0
- package/dist/binding.js +51 -0
- package/dist/binding.js.map +1 -0
- package/dist/controls.d.ts +69 -0
- package/dist/controls.d.ts.map +1 -0
- package/dist/controls.js +334 -0
- package/dist/controls.js.map +1 -0
- package/dist/effect.d.ts +54 -0
- package/dist/effect.d.ts.map +1 -0
- package/dist/effect.js +88 -0
- package/dist/effect.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive.d.ts +12 -0
- package/dist/interactive.d.ts.map +1 -0
- package/dist/interactive.js +21 -0
- package/dist/interactive.js.map +1 -0
- package/dist/jobs.d.ts +54 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +74 -0
- package/dist/jobs.js.map +1 -0
- package/dist/json-schema.d.ts +36 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +196 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/jsx.d.ts +19 -0
- package/dist/jsx.d.ts.map +1 -0
- package/dist/jsx.js +2 -0
- package/dist/jsx.js.map +1 -0
- package/dist/manifest.d.ts +35 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +77 -0
- package/dist/manifest.js.map +1 -0
- package/dist/oui.d.ts +112 -0
- package/dist/oui.d.ts.map +1 -0
- package/dist/oui.js +514 -0
- package/dist/oui.js.map +1 -0
- package/dist/package-declaration.d.ts +24 -0
- package/dist/package-declaration.d.ts.map +1 -0
- package/dist/package-declaration.js +24 -0
- package/dist/package-declaration.js.map +1 -0
- package/dist/react.d.ts +74 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +179 -0
- package/dist/react.js.map +1 -0
- package/dist/registry.d.ts +103 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +146 -0
- package/dist/registry.js.map +1 -0
- package/dist/room.d.ts +79 -0
- package/dist/room.d.ts.map +1 -0
- package/dist/room.js +111 -0
- package/dist/room.js.map +1 -0
- package/dist/tier2-react.d.ts +35 -0
- package/dist/tier2-react.d.ts.map +1 -0
- package/dist/tier2-react.js +186 -0
- package/dist/tier2-react.js.map +1 -0
- package/dist/tier2.d.ts +68 -0
- package/dist/tier2.d.ts.map +1 -0
- package/dist/tier2.js +129 -0
- package/dist/tier2.js.map +1 -0
- package/package.json +74 -3
package/dist/effect.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { effectAccess as ouiEffectAccess, OUI_EFFECT_ACCESS, OUI_EFFECT_KINDS, requiresApproval as ouiRequiresApproval, } from 'oui-spec/spec';
|
|
2
|
+
/**
|
|
3
|
+
* What using an action does (ADR-0226 §2.6): one vocabulary for a
|
|
4
|
+
* design-system control's binding, a room catalog's entry and a generated API
|
|
5
|
+
* tool, so a page control, a room action and an API call are told apart by
|
|
6
|
+
* what they change, never by where they are declared.
|
|
7
|
+
*
|
|
8
|
+
* | Effect | What it changes | ADR-0210 access |
|
|
9
|
+
* |---|---|---|
|
|
10
|
+
* | `view`, `selection`, `navigate`, `open` | What is shown | read |
|
|
11
|
+
* | `edit` | The document, one undo step | write |
|
|
12
|
+
* | `file` | Imports or exports a file | write |
|
|
13
|
+
* | `mutate` | Backend data, through an API operation | write |
|
|
14
|
+
* | `job` | Starts work that outlives the call, settled on its outcome | write |
|
|
15
|
+
* | `transaction` | An irreversible external act: an order, a payment, a send, a publish | write, approved |
|
|
16
|
+
*
|
|
17
|
+
* A `transaction`, and any `write` declared `destructive`, runs only on an
|
|
18
|
+
* approval the person gave, bound to the call (ADR-0228).
|
|
19
|
+
*/
|
|
20
|
+
/** How long an approval for an action lasts at most, in minutes (ADR-0228 §2.3). */
|
|
21
|
+
export const MAX_APPROVAL_MINUTES = 30;
|
|
22
|
+
const everyKindIsOUIs = true;
|
|
23
|
+
void everyKindIsOUIs;
|
|
24
|
+
const theSchemaListsOUIsKinds = true;
|
|
25
|
+
void theSchemaListsOUIsKinds;
|
|
26
|
+
/** Every effect, in the order of the table above. */
|
|
27
|
+
export const ACTION_EFFECT_KINDS = OUI_EFFECT_KINDS;
|
|
28
|
+
/** Whether an effect only changes what is shown, or changes something (ADR-0210 `effect`). */
|
|
29
|
+
export const EFFECT_ACCESS = OUI_EFFECT_ACCESS;
|
|
30
|
+
export function effectKind(effect) {
|
|
31
|
+
return typeof effect === 'string' ? effect : effect.kind;
|
|
32
|
+
}
|
|
33
|
+
/** `read` or `write`, as ADR-0210 names it. An action that declares no effect is a `write`: nothing says it only shows. */
|
|
34
|
+
export function effectAccess(effect) {
|
|
35
|
+
return ouiEffectAccess(effect === undefined ? undefined : effectKind(effect));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether running the action needs the person's approval of the exact call
|
|
39
|
+
* (ADR-0228 §2.1): a `transaction` always, and a `write` declared destructive.
|
|
40
|
+
* A host's policy may require it of more; it never waives these. OUI's rule.
|
|
41
|
+
*/
|
|
42
|
+
export function requiresApproval(effect, destructive) {
|
|
43
|
+
return ouiRequiresApproval(effect === undefined ? undefined : effectKind(effect), destructive);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Why a value is not a valid effect, or null. Checks the shape only: whether a
|
|
47
|
+
* route, container or operation it names exists is the generator's to check
|
|
48
|
+
* against the app.
|
|
49
|
+
*/
|
|
50
|
+
export function effectProblem(value) {
|
|
51
|
+
if (typeof value === 'string') {
|
|
52
|
+
return ['view', 'selection', 'edit', 'file'].includes(value)
|
|
53
|
+
? null
|
|
54
|
+
: `"${value}" is not an effect: ${ACTION_EFFECT_KINDS.join(', ')}`;
|
|
55
|
+
}
|
|
56
|
+
if (!value || typeof value !== 'object' || typeof value.kind !== 'string')
|
|
57
|
+
return `an effect is one of ${ACTION_EFFECT_KINDS.join(', ')}`;
|
|
58
|
+
const e = value;
|
|
59
|
+
const text = (key) => typeof e[key] === 'string' && e[key].trim() !== '';
|
|
60
|
+
const optionalText = (key) => e[key] === undefined || typeof e[key] === 'string';
|
|
61
|
+
const positive = (key) => e[key] === undefined || (typeof e[key] === 'number' && e[key] > 0);
|
|
62
|
+
switch (e.kind) {
|
|
63
|
+
case 'navigate':
|
|
64
|
+
return text('to') ? null : 'a navigate effect names the route it goes `to`';
|
|
65
|
+
case 'open':
|
|
66
|
+
return text('container') ? null : 'an open effect names the `container` it opens';
|
|
67
|
+
case 'mutate':
|
|
68
|
+
return text('operation') ? null : 'a mutate effect names its API `operation`';
|
|
69
|
+
case 'job':
|
|
70
|
+
return optionalText('estimatedDuration') && positive('timeoutMs')
|
|
71
|
+
? null
|
|
72
|
+
: 'a job effect’s `timeoutMs` is a positive number and its `estimatedDuration` a literal string';
|
|
73
|
+
case 'transaction': {
|
|
74
|
+
if (!optionalText('operation') || e.operation === '')
|
|
75
|
+
return 'a transaction’s `operation` is an operationId';
|
|
76
|
+
if (!optionalText('estimatedDuration') || !positive('timeoutMs'))
|
|
77
|
+
return 'a transaction’s `timeoutMs` is a positive number and its `estimatedDuration` a literal string';
|
|
78
|
+
const minutes = e.approvalMinutes;
|
|
79
|
+
if (minutes !== undefined &&
|
|
80
|
+
!(typeof minutes === 'number' && Number.isInteger(minutes) && minutes >= 1 && minutes <= MAX_APPROVAL_MINUTES))
|
|
81
|
+
return `a transaction’s \`approvalMinutes\` is a whole number from 1 to ${MAX_APPROVAL_MINUTES}`;
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
default:
|
|
85
|
+
return `"${String(e.kind)}" is not an effect: ${ACTION_EFFECT_KINDS.join(', ')}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=effect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effect.js","sourceRoot":"","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AAC,CAAC,2CAA2C,CAAC;QAChF,KAAK,KAAK;YACR,OAAO,YAAY,CAAC,mBAAmB,CAAC,IAAI,QAAQ,CAAC,WAAW,CAAC;gBAC/D,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,8FAA8F,CAAC;QACrG,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,SAAS,KAAK,EAAE;gBAAE,OAAO,+CAA+C,CAAC;YAC7G,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;gBAC9D,OAAO,+FAA+F,CAAC;YACzG,MAAM,OAAO,GAAG,CAAC,CAAC,eAAe,CAAC;YAClC,IACE,OAAO,KAAK,SAAS;gBACrB,CAAC,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,IAAI,oBAAoB,CAAC;gBAE9G,OAAO,mEAAmE,oBAAoB,EAAE,CAAC;YACnG,OAAO,IAAI,CAAC;QACd,CAAC;QACD;YACE,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,uBAAuB,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACrF,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ouispec/bindings — every UI capability declared once, in code
|
|
3
|
+
* (ADR-0220).
|
|
4
|
+
*
|
|
5
|
+
* - The binding a design-system control carries, and the input schema derived
|
|
6
|
+
* from its props.
|
|
7
|
+
* - The room catalog contract a room with its own editing model publishes.
|
|
8
|
+
* - The generated manifest and knowledge, and how the runtime reads them.
|
|
9
|
+
* - The registry of what is mounted right now.
|
|
10
|
+
*
|
|
11
|
+
* React hooks are in `@ouispec/bindings/react`; the adapter to OUI
|
|
12
|
+
* surfaces is in `@ouispec/bindings/oui`. This entry has no
|
|
13
|
+
* dependencies, so the build-time generator reads it in plain Node.
|
|
14
|
+
*/
|
|
15
|
+
export * from './json-schema.js';
|
|
16
|
+
export * from './effect.js';
|
|
17
|
+
export * from './room.js';
|
|
18
|
+
export * from './binding.js';
|
|
19
|
+
export * from './controls.js';
|
|
20
|
+
export * from './manifest.js';
|
|
21
|
+
export * from './registry.js';
|
|
22
|
+
export * from './interactive.js';
|
|
23
|
+
export * from './package-declaration.js';
|
|
24
|
+
export * from './tier2.js';
|
|
25
|
+
export type { OuiConfigFile, OuiPackageDeclaration, Tier2Control, Tier2Mapping, Tier2Part, ValueFrom } from '@ouispec/contract';
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAI3B,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ouispec/bindings — every UI capability declared once, in code
|
|
3
|
+
* (ADR-0220).
|
|
4
|
+
*
|
|
5
|
+
* - The binding a design-system control carries, and the input schema derived
|
|
6
|
+
* from its props.
|
|
7
|
+
* - The room catalog contract a room with its own editing model publishes.
|
|
8
|
+
* - The generated manifest and knowledge, and how the runtime reads them.
|
|
9
|
+
* - The registry of what is mounted right now.
|
|
10
|
+
*
|
|
11
|
+
* React hooks are in `@ouispec/bindings/react`; the adapter to OUI
|
|
12
|
+
* surfaces is in `@ouispec/bindings/oui`. This entry has no
|
|
13
|
+
* dependencies, so the build-time generator reads it in plain Node.
|
|
14
|
+
*/
|
|
15
|
+
export * from './json-schema.js';
|
|
16
|
+
export * from './effect.js';
|
|
17
|
+
export * from './room.js';
|
|
18
|
+
export * from './binding.js';
|
|
19
|
+
export * from './controls.js';
|
|
20
|
+
export * from './manifest.js';
|
|
21
|
+
export * from './registry.js';
|
|
22
|
+
export * from './interactive.js';
|
|
23
|
+
export * from './package-declaration.js';
|
|
24
|
+
export * from './tier2.js';
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What makes something a person can use, for the generator's reading of a
|
|
3
|
+
* page and the conformance kit's reading of a design system's exports: one
|
|
4
|
+
* definition, so the two never disagree on what must be bound.
|
|
5
|
+
*/
|
|
6
|
+
/** Elements someone can use by their nature. */
|
|
7
|
+
export declare const INTERACTIVE_TAGS: ReadonlySet<string>;
|
|
8
|
+
/** Handlers that make an element someone can use: a press, an edit, a key, a pointer. */
|
|
9
|
+
export declare const INTERACTIVE_HANDLERS: readonly string[];
|
|
10
|
+
/** A prop that takes a callback, by React's naming: `onValueChange`, `onDragEnd`. */
|
|
11
|
+
export declare const CALLBACK_PROP: RegExp;
|
|
12
|
+
//# sourceMappingURL=interactive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../src/interactive.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,gDAAgD;AAChD,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAsD,CAAC;AAExG,yFAAyF;AACzF,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EASjD,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,aAAa,QAAa,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What makes something a person can use, for the generator's reading of a
|
|
3
|
+
* page and the conformance kit's reading of a design system's exports: one
|
|
4
|
+
* definition, so the two never disagree on what must be bound.
|
|
5
|
+
*/
|
|
6
|
+
/** Elements someone can use by their nature. */
|
|
7
|
+
export const INTERACTIVE_TAGS = new Set(['button', 'input', 'select', 'textarea']);
|
|
8
|
+
/** Handlers that make an element someone can use: a press, an edit, a key, a pointer. */
|
|
9
|
+
export const INTERACTIVE_HANDLERS = [
|
|
10
|
+
'onClick',
|
|
11
|
+
'onChange',
|
|
12
|
+
'onInput',
|
|
13
|
+
'onSubmit',
|
|
14
|
+
'onDoubleClick',
|
|
15
|
+
'onPointerDown',
|
|
16
|
+
'onMouseDown',
|
|
17
|
+
'onKeyDown',
|
|
18
|
+
];
|
|
19
|
+
/** A prop that takes a callback, by React's naming: `onValueChange`, `onDragEnd`. */
|
|
20
|
+
export const CALLBACK_PROP = /^on[A-Z]/;
|
|
21
|
+
//# sourceMappingURL=interactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../src/interactive.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,gDAAgD;AAChD,MAAM,CAAC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;AAExG,yFAAyF;AACzF,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,SAAS;IACT,UAAU;IACV,SAAS;IACT,UAAU;IACV,eAAe;IACf,eAAe;IACf,aAAa;IACb,WAAW;CACZ,CAAC;AAEF,qFAAqF;AACrF,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC"}
|
package/dist/jobs.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's job tracker, built from the product's event declarations (W9,
|
|
3
|
+
* ADR-0227 §2.4): the `JobTracker` that `connectBindings({ jobs })` reads a
|
|
4
|
+
* `{ kind: 'job' }` action's outcome from.
|
|
5
|
+
*
|
|
6
|
+
* A job of the declared kind is followed in the room its completion declares
|
|
7
|
+
* for one job (`generation:{jobId}`), and ends on its declared completion,
|
|
8
|
+
* with the declared result fields, or its declared failure, with the declared
|
|
9
|
+
* reason. Work a declared kind cannot describe (work the tab does itself, a
|
|
10
|
+
* job made of several) plugs in as a `JobTrackerExtension`, which reads
|
|
11
|
+
* declared events only.
|
|
12
|
+
*
|
|
13
|
+
* It records outcomes only for jobs something asked it to track, so traffic
|
|
14
|
+
* for other jobs cannot grow it. It listens once per event name.
|
|
15
|
+
*/
|
|
16
|
+
import type { EventCatalog } from '@ouispec/agent-events';
|
|
17
|
+
import type { JobOutcome, JobTracker } from './oui.js';
|
|
18
|
+
/** What the tracker needs of a socket: rooms to join and events to hear. */
|
|
19
|
+
export interface JobEventSource {
|
|
20
|
+
subscribe(rooms: string[]): void;
|
|
21
|
+
unsubscribe(rooms: string[]): void;
|
|
22
|
+
on(event: string, handler: (data: unknown) => void): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Jobs the declared kind cannot describe, followed by the product's own code.
|
|
26
|
+
* The tracker hands it only the declared events it names, and answers for its
|
|
27
|
+
* jobs only while they are tracked.
|
|
28
|
+
*/
|
|
29
|
+
export interface JobTrackerExtension {
|
|
30
|
+
/** For errors. */
|
|
31
|
+
readonly name: string;
|
|
32
|
+
/** The declared events it reads; each must be declared. */
|
|
33
|
+
readonly events: readonly string[];
|
|
34
|
+
/** Whether this extension follows `jobId`. */
|
|
35
|
+
owns(jobId: string): boolean;
|
|
36
|
+
/** Start following `jobId`; the rooms to join (none for the tab's own work). */
|
|
37
|
+
track(jobId: string): readonly string[];
|
|
38
|
+
/** One of its events arrived. */
|
|
39
|
+
receive(event: string, payload: unknown): void;
|
|
40
|
+
/** The job's outcome once it has one. */
|
|
41
|
+
outcome(jobId: string): JobOutcome | null;
|
|
42
|
+
/** Stop following `jobId`; the rooms to leave. */
|
|
43
|
+
forget(jobId: string): readonly string[];
|
|
44
|
+
}
|
|
45
|
+
export interface DeclaredJobTrackerOptions {
|
|
46
|
+
/** The product's event declarations. */
|
|
47
|
+
events: EventCatalog;
|
|
48
|
+
source: JobEventSource;
|
|
49
|
+
/** The declared job kind a job id names, unless an extension owns it. */
|
|
50
|
+
kind: string;
|
|
51
|
+
extensions?: readonly JobTrackerExtension[];
|
|
52
|
+
}
|
|
53
|
+
export declare function createDeclaredJobTracker({ events, source, kind, extensions }: DeclaredJobTrackerOptions): JobTracker;
|
|
54
|
+
//# sourceMappingURL=jobs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../src/jobs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEvD,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACjC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACnC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;CAC3D;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,kBAAkB;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,8CAA8C;IAC9C,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,gFAAgF;IAChF,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IACxC,iCAAiC;IACjC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/C,yCAAyC;IACzC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;IAC1C,kDAAkD;IAClD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,yBAAyB;IACxC,wCAAwC;IACxC,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,cAAc,CAAC;IACvB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAC;CAC7C;AAED,wBAAgB,wBAAwB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAe,EAAE,EAAE,yBAAyB,GAAG,UAAU,CAsEzH"}
|
package/dist/jobs.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export function createDeclaredJobTracker({ events, source, kind, extensions = [] }) {
|
|
2
|
+
const declared = events.jobKind(kind);
|
|
3
|
+
if (!declared) {
|
|
4
|
+
const kinds = events.jobKinds().map((k) => k.kind);
|
|
5
|
+
throw new Error(`[oui-bindings] the job tracker follows jobs of kind '${kind}', which no declared event settles (declared: ${kinds.join(', ') || 'none'})`);
|
|
6
|
+
}
|
|
7
|
+
// Refuses, naming the kind, when no room is keyed by its id alone.
|
|
8
|
+
events.followRoom(kind, 'probe');
|
|
9
|
+
for (const extension of extensions) {
|
|
10
|
+
for (const event of extension.events)
|
|
11
|
+
events.require(event, `job tracker extension '${extension.name}'`);
|
|
12
|
+
}
|
|
13
|
+
const tracked = new Set();
|
|
14
|
+
const outcomes = new Map();
|
|
15
|
+
const owner = (jobId) => extensions.find((e) => e.owns(jobId));
|
|
16
|
+
const followRoom = (jobId) => {
|
|
17
|
+
try {
|
|
18
|
+
return [events.followRoom(kind, jobId)];
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// An id no room can hold cannot be followed; its action reports it unfinished.
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const settle = (event, payload) => {
|
|
26
|
+
const settlement = events.settlement(event, payload);
|
|
27
|
+
if (!settlement || !tracked.has(settlement.id))
|
|
28
|
+
return;
|
|
29
|
+
const outcome = events.outcome(settlement);
|
|
30
|
+
outcomes.set(settlement.id, outcome.status === 'complete'
|
|
31
|
+
? { status: 'complete', jobId: settlement.id, ...outcome.result }
|
|
32
|
+
: { status: 'failed', jobId: settlement.id, error: outcome.reason });
|
|
33
|
+
};
|
|
34
|
+
const readers = new Map();
|
|
35
|
+
const listen = (event, reader) => readers.set(event, [...(readers.get(event) ?? []), reader]);
|
|
36
|
+
listen(declared.completion.name, (payload) => settle(declared.completion.name, payload));
|
|
37
|
+
if (declared.failure)
|
|
38
|
+
listen(declared.failure.name, (payload) => settle(declared.failure.name, payload));
|
|
39
|
+
for (const extension of extensions) {
|
|
40
|
+
for (const event of extension.events)
|
|
41
|
+
listen(event, (payload) => extension.receive(event, payload));
|
|
42
|
+
}
|
|
43
|
+
for (const [event, eventReaders] of readers) {
|
|
44
|
+
source.on(event, (payload) => eventReaders.forEach((read) => read(payload)));
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
track(jobId) {
|
|
48
|
+
if (!jobId || tracked.has(jobId))
|
|
49
|
+
return;
|
|
50
|
+
tracked.add(jobId);
|
|
51
|
+
const extension = owner(jobId);
|
|
52
|
+
const rooms = extension ? [...extension.track(jobId)] : followRoom(jobId);
|
|
53
|
+
if (rooms.length > 0)
|
|
54
|
+
source.subscribe(rooms);
|
|
55
|
+
},
|
|
56
|
+
outcome(jobId) {
|
|
57
|
+
if (!tracked.has(jobId))
|
|
58
|
+
return null;
|
|
59
|
+
const extension = owner(jobId);
|
|
60
|
+
return extension ? extension.outcome(jobId) : (outcomes.get(jobId) ?? null);
|
|
61
|
+
},
|
|
62
|
+
forget(jobId) {
|
|
63
|
+
if (!tracked.delete(jobId))
|
|
64
|
+
return;
|
|
65
|
+
const extension = owner(jobId);
|
|
66
|
+
if (!extension)
|
|
67
|
+
outcomes.delete(jobId);
|
|
68
|
+
const rooms = extension ? [...extension.forget(jobId)] : followRoom(jobId);
|
|
69
|
+
if (rooms.length > 0)
|
|
70
|
+
source.unsubscribe(rooms);
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=jobs.js.map
|
package/dist/jobs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../src/jobs.ts"],"names":[],"mappings":"AAwDA,MAAM,UAAU,wBAAwB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,EAAE,EAA6B;IAC3G,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAA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KAAK,CAAC,CAAC;YACvC,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAC3E,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { JsonSchema, JsonSchemaType } from '@ouispec/contract';
|
|
2
|
+
/**
|
|
3
|
+
* The subset of JSON Schema (draft 2020-12) every capability declares its
|
|
4
|
+
* input and values in: the contract's (`json-schema.json`).
|
|
5
|
+
*/
|
|
6
|
+
export type { JsonSchema, JsonSchemaType };
|
|
7
|
+
/**
|
|
8
|
+
* Whether `live` asks for no more than `declared` does: the same type, a range
|
|
9
|
+
* inside the declared one, options drawn from the declared options, and the
|
|
10
|
+
* same properties. A live control may narrow what the build declared (the
|
|
11
|
+
* options loaded from the API today) but never widen it or change its type,
|
|
12
|
+
* because the build's declaration is what was reviewed.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isNarrowing(live: JsonSchema, declared: JsonSchema): boolean;
|
|
15
|
+
/** The keywords that combine schemas, which a tool's input may not have at its top level. */
|
|
16
|
+
export declare const TOOL_INPUT_COMBINERS: readonly ["oneOf", "anyOf", "allOf"];
|
|
17
|
+
/**
|
|
18
|
+
* Why `schema` cannot be a tool's input, or none. A tool's input is one JSON
|
|
19
|
+
* object schema: its type is `"object"` and only that, and it is not a union
|
|
20
|
+
* or an intersection of schemas. A model provider refuses the whole request
|
|
21
|
+
* when one tool's input is otherwise (Bedrock and the Anthropic API: "input_schema
|
|
22
|
+
* does not support oneOf, allOf, or anyOf at the top level"), so one such action
|
|
23
|
+
* takes down every turn its surface is offered in. Alternatives belong inside a
|
|
24
|
+
* property, and a value's own form is checked when the action runs.
|
|
25
|
+
*/
|
|
26
|
+
export declare function toolInputProblems(schema: unknown): string[];
|
|
27
|
+
/** Deterministic JSON: object keys sorted, so the same value always gives the same bytes. */
|
|
28
|
+
export declare function stableStringify(value: unknown, indent?: number): string;
|
|
29
|
+
/**
|
|
30
|
+
* Why `value` does not satisfy `schema`, or null. Covers what controls and
|
|
31
|
+
* room fields declare: type, enum, const, range, length, pattern, required
|
|
32
|
+
* properties, array items (and their uniqueness), dates, and `anyOf`/`oneOf`
|
|
33
|
+
* alternatives.
|
|
34
|
+
*/
|
|
35
|
+
export declare function validateValue(schema: JsonSchema, value: unknown, path?: string): string | null;
|
|
36
|
+
//# sourceMappingURL=json-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../src/json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEpE;;;GAGG;AACH,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;AAK3C;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,CA4B3E;AAED,6FAA6F;AAC7F,eAAO,MAAM,oBAAoB,sCAAuC,CAAC;AAEzE;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,CAmB3D;AAED,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,SAAI,GAAG,MAAM,CAElE;AAeD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,SAAU,GAAG,MAAM,GAAG,IAAI,CAoE/F"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
const typesOf = (schema) => schema.type === undefined ? [] : typeof schema.type === 'string' ? [schema.type] : schema.type;
|
|
2
|
+
/**
|
|
3
|
+
* Whether `live` asks for no more than `declared` does: the same type, a range
|
|
4
|
+
* inside the declared one, options drawn from the declared options, and the
|
|
5
|
+
* same properties. A live control may narrow what the build declared (the
|
|
6
|
+
* options loaded from the API today) but never widen it or change its type,
|
|
7
|
+
* because the build's declaration is what was reviewed.
|
|
8
|
+
*/
|
|
9
|
+
export function isNarrowing(live, declared) {
|
|
10
|
+
const liveTypes = typesOf(live);
|
|
11
|
+
const declaredTypes = typesOf(declared);
|
|
12
|
+
if (declaredTypes.length > 0 && !liveTypes.every(t => declaredTypes.includes(t)))
|
|
13
|
+
return false;
|
|
14
|
+
if (declaredTypes.length > 0 && liveTypes.length === 0)
|
|
15
|
+
return false;
|
|
16
|
+
if (declared.minimum !== undefined && (live.minimum === undefined || live.minimum < declared.minimum))
|
|
17
|
+
return false;
|
|
18
|
+
if (declared.maximum !== undefined && (live.maximum === undefined || live.maximum > declared.maximum))
|
|
19
|
+
return false;
|
|
20
|
+
if (declared.enum !== undefined) {
|
|
21
|
+
if (live.enum === undefined || !live.enum.every(v => declared.enum.includes(v)))
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (declared.const !== undefined && live.const !== declared.const)
|
|
25
|
+
return false;
|
|
26
|
+
if (declared.properties || live.properties) {
|
|
27
|
+
const declaredProps = declared.properties ?? {};
|
|
28
|
+
const liveProps = live.properties ?? {};
|
|
29
|
+
for (const key of Object.keys(liveProps)) {
|
|
30
|
+
if (!(key in declaredProps))
|
|
31
|
+
return false;
|
|
32
|
+
if (!isNarrowing(liveProps[key], declaredProps[key]))
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
for (const key of declared.required ?? []) {
|
|
36
|
+
if (!(key in liveProps))
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (declared.items && live.items && !isNarrowing(live.items, declared.items))
|
|
41
|
+
return false;
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
/** The keywords that combine schemas, which a tool's input may not have at its top level. */
|
|
45
|
+
export const TOOL_INPUT_COMBINERS = ['oneOf', 'anyOf', 'allOf'];
|
|
46
|
+
/**
|
|
47
|
+
* Why `schema` cannot be a tool's input, or none. A tool's input is one JSON
|
|
48
|
+
* object schema: its type is `"object"` and only that, and it is not a union
|
|
49
|
+
* or an intersection of schemas. A model provider refuses the whole request
|
|
50
|
+
* when one tool's input is otherwise (Bedrock and the Anthropic API: "input_schema
|
|
51
|
+
* does not support oneOf, allOf, or anyOf at the top level"), so one such action
|
|
52
|
+
* takes down every turn its surface is offered in. Alternatives belong inside a
|
|
53
|
+
* property, and a value's own form is checked when the action runs.
|
|
54
|
+
*/
|
|
55
|
+
export function toolInputProblems(schema) {
|
|
56
|
+
if (!schema || typeof schema !== 'object' || Array.isArray(schema))
|
|
57
|
+
return ['its input is not a JSON schema object'];
|
|
58
|
+
const record = schema;
|
|
59
|
+
const problems = [];
|
|
60
|
+
if (record.type !== 'object') {
|
|
61
|
+
problems.push(record.type === undefined
|
|
62
|
+
? 'its input has no type; a tool’s input must be "type": "object"'
|
|
63
|
+
: `its input's type is ${JSON.stringify(record.type)}; a tool’s input must be "type": "object"`);
|
|
64
|
+
}
|
|
65
|
+
for (const keyword of TOOL_INPUT_COMBINERS) {
|
|
66
|
+
if (keyword in record) {
|
|
67
|
+
problems.push(`its input has ${keyword} at the top level, which model providers refuse; put the alternatives inside a property and check them when it runs`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return problems;
|
|
71
|
+
}
|
|
72
|
+
/** Deterministic JSON: object keys sorted, so the same value always gives the same bytes. */
|
|
73
|
+
export function stableStringify(value, indent = 2) {
|
|
74
|
+
return JSON.stringify(sortKeys(value), null, indent);
|
|
75
|
+
}
|
|
76
|
+
function sortKeys(value) {
|
|
77
|
+
if (Array.isArray(value))
|
|
78
|
+
return value.map(sortKeys);
|
|
79
|
+
if (value && typeof value === 'object') {
|
|
80
|
+
const out = {};
|
|
81
|
+
for (const key of Object.keys(value).sort()) {
|
|
82
|
+
const v = value[key];
|
|
83
|
+
if (v !== undefined)
|
|
84
|
+
out[key] = sortKeys(v);
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Why `value` does not satisfy `schema`, or null. Covers what controls and
|
|
92
|
+
* room fields declare: type, enum, const, range, length, pattern, required
|
|
93
|
+
* properties, array items (and their uniqueness), dates, and `anyOf`/`oneOf`
|
|
94
|
+
* alternatives.
|
|
95
|
+
*/
|
|
96
|
+
export function validateValue(schema, value, path = 'value') {
|
|
97
|
+
const alternatives = schema.anyOf ?? schema.oneOf;
|
|
98
|
+
if (alternatives) {
|
|
99
|
+
const problems = alternatives.map(s => validateValue(s, value, path));
|
|
100
|
+
return problems.some(p => p === null)
|
|
101
|
+
? null
|
|
102
|
+
: `${path} matches none of the accepted forms (${problems.join('; ')})`;
|
|
103
|
+
}
|
|
104
|
+
const types = typesOf(schema);
|
|
105
|
+
if (types.length > 0 && !types.some(t => isType(t, value))) {
|
|
106
|
+
return `${path} must be ${types.join(' or ')}`;
|
|
107
|
+
}
|
|
108
|
+
if (schema.enum && !schema.enum.includes(value)) {
|
|
109
|
+
return `${path} must be one of ${schema.enum.map(v => JSON.stringify(v)).join(', ')}`;
|
|
110
|
+
}
|
|
111
|
+
if (schema.const !== undefined && value !== schema.const)
|
|
112
|
+
return `${path} must be ${JSON.stringify(schema.const)}`;
|
|
113
|
+
if (typeof value === 'number') {
|
|
114
|
+
if (schema.minimum !== undefined && value < schema.minimum)
|
|
115
|
+
return `${path} must be at least ${schema.minimum}`;
|
|
116
|
+
if (schema.maximum !== undefined && value > schema.maximum)
|
|
117
|
+
return `${path} must be at most ${schema.maximum}`;
|
|
118
|
+
}
|
|
119
|
+
if (typeof value === 'string') {
|
|
120
|
+
if (schema.minLength !== undefined && value.length < schema.minLength) {
|
|
121
|
+
return `${path} must be at least ${schema.minLength} characters`;
|
|
122
|
+
}
|
|
123
|
+
if (schema.maxLength !== undefined && value.length > schema.maxLength) {
|
|
124
|
+
return `${path} must be at most ${schema.maxLength} characters`;
|
|
125
|
+
}
|
|
126
|
+
if (schema.pattern !== undefined && !new RegExp(schema.pattern).test(value)) {
|
|
127
|
+
return `${path} must match ${schema.pattern}`;
|
|
128
|
+
}
|
|
129
|
+
if (schema.format === 'date' && !isCalendarDate(value))
|
|
130
|
+
return `${path} must be a date, YYYY-MM-DD`;
|
|
131
|
+
}
|
|
132
|
+
if (Array.isArray(value)) {
|
|
133
|
+
if (schema.minItems !== undefined && value.length < schema.minItems)
|
|
134
|
+
return `${path} needs at least ${schema.minItems} items`;
|
|
135
|
+
if (schema.maxItems !== undefined && value.length > schema.maxItems)
|
|
136
|
+
return `${path} takes at most ${schema.maxItems} items`;
|
|
137
|
+
if (schema.uniqueItems && new Set(value.map(v => JSON.stringify(v))).size !== value.length)
|
|
138
|
+
return `${path} lists an item twice`;
|
|
139
|
+
if (schema.items) {
|
|
140
|
+
for (const [i, item] of value.entries()) {
|
|
141
|
+
const problem = validateValue(schema.items, item, `${path}[${i}]`);
|
|
142
|
+
if (problem)
|
|
143
|
+
return problem;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
148
|
+
const record = value;
|
|
149
|
+
for (const key of schema.required ?? []) {
|
|
150
|
+
if (record[key] === undefined)
|
|
151
|
+
return `${path}.${key} is required`;
|
|
152
|
+
}
|
|
153
|
+
for (const [key, v] of Object.entries(record)) {
|
|
154
|
+
const prop = schema.properties?.[key];
|
|
155
|
+
if (prop) {
|
|
156
|
+
const problem = validateValue(prop, v, `${path}.${key}`);
|
|
157
|
+
if (problem)
|
|
158
|
+
return problem;
|
|
159
|
+
}
|
|
160
|
+
else if (schema.additionalProperties === false) {
|
|
161
|
+
return `${path} has no property "${key}"`;
|
|
162
|
+
}
|
|
163
|
+
else if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {
|
|
164
|
+
const problem = validateValue(schema.additionalProperties, v, `${path}.${key}`);
|
|
165
|
+
if (problem)
|
|
166
|
+
return problem;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
/** A real day written YYYY-MM-DD: 2026-02-30 is not one. */
|
|
173
|
+
function isCalendarDate(value) {
|
|
174
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
175
|
+
if (!m)
|
|
176
|
+
return false;
|
|
177
|
+
const date = new Date(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3])));
|
|
178
|
+
return date.toISOString().slice(0, 10) === value;
|
|
179
|
+
}
|
|
180
|
+
function isType(type, value) {
|
|
181
|
+
switch (type) {
|
|
182
|
+
case 'null':
|
|
183
|
+
return value === null;
|
|
184
|
+
case 'array':
|
|
185
|
+
return Array.isArray(value);
|
|
186
|
+
case 'object':
|
|
187
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
188
|
+
case 'integer':
|
|
189
|
+
return typeof value === 'number' && Number.isInteger(value);
|
|
190
|
+
case 'number':
|
|
191
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
192
|
+
default:
|
|
193
|
+
return typeof value === type;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=json-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../src/json-schema.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAG,CAAC,MAAkB,EAA6B,EAAE,CAChE,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAA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IAAI,EAAE,CAAC;QACb,KAAK,MAAM;YACT,OAAO,KAAK,KAAK,IAAI,CAAC;QACxB,KAAK,OAAO;YACV,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9B,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACvE,KAAK,SAAS;YACZ,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC9D,KAAK,QAAQ;YACX,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC7D;YACE,OAAO,OAAO,KAAK,KAAK,IAAI,CAAC;IACjC,CAAC;AACH,CAAC"}
|
package/dist/jsx.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agent` on JSX, for an app with tier 2 bound modules (ADR-0226 §2.3). A
|
|
3
|
+
* bound export keeps the third-party component's own type, generics and
|
|
4
|
+
* polymorphism included, so `agent` cannot be one of its props; every bound
|
|
5
|
+
* module imports this entry instead, the way a styling library adds `css`.
|
|
6
|
+
* Only apps with a bound module import it. The generator holds every `agent`
|
|
7
|
+
* to the control it is on.
|
|
8
|
+
*/
|
|
9
|
+
import type { AgentAttribute } from './tier2-react.js';
|
|
10
|
+
declare module 'react' {
|
|
11
|
+
namespace JSX {
|
|
12
|
+
interface IntrinsicAttributes {
|
|
13
|
+
/** The assistant's binding of a bound control (ADR-0226 §2.3). */
|
|
14
|
+
agent?: AgentAttribute;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=jsx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,QAAQ,OAAO,CAAC;IAGrB,UAAU,GAAG,CAAC;QACZ,UAAU,mBAAmB;YAC3B,kEAAkE;YAClE,KAAK,CAAC,EAAE,cAAc,CAAC;SACxB;KACF;CACF;AAED,OAAO,EAAE,CAAC"}
|
package/dist/jsx.js
ADDED
package/dist/jsx.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx.js","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":""}
|