@ignite-ember/extension-bridge 0.0.0-stage → 0.2.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.
Files changed (69) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +303 -2
  4. package/dist/bridge.d.ts +33 -0
  5. package/dist/bridge.d.ts.map +1 -0
  6. package/dist/bridge.js +92 -0
  7. package/dist/bridge.js.map +1 -0
  8. package/dist/channel.d.ts +26 -0
  9. package/dist/channel.d.ts.map +1 -0
  10. package/dist/channel.js +36 -0
  11. package/dist/channel.js.map +1 -0
  12. package/dist/contract.d.ts +110 -0
  13. package/dist/contract.d.ts.map +1 -0
  14. package/dist/contract.js +9 -0
  15. package/dist/contract.js.map +1 -0
  16. package/dist/correlator.d.ts +37 -0
  17. package/dist/correlator.d.ts.map +1 -0
  18. package/dist/correlator.js +67 -0
  19. package/dist/correlator.js.map +1 -0
  20. package/dist/guestBridge.d.ts +63 -0
  21. package/dist/guestBridge.d.ts.map +1 -0
  22. package/dist/guestBridge.js +156 -0
  23. package/dist/guestBridge.js.map +1 -0
  24. package/dist/hostModel.d.ts +155 -0
  25. package/dist/hostModel.d.ts.map +1 -0
  26. package/dist/hostModel.generated.d.ts +1870 -0
  27. package/dist/hostModel.generated.d.ts.map +1 -0
  28. package/dist/hostModel.generated.js +1241 -0
  29. package/dist/hostModel.generated.js.map +1 -0
  30. package/dist/hostModel.js +168 -0
  31. package/dist/hostModel.js.map +1 -0
  32. package/dist/index.d.ts +12 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +12 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/protocol.d.ts +338 -0
  37. package/dist/protocol.d.ts.map +1 -0
  38. package/dist/protocol.js +135 -0
  39. package/dist/protocol.js.map +1 -0
  40. package/dist/service.d.ts +143 -0
  41. package/dist/service.d.ts.map +1 -0
  42. package/dist/service.js +179 -0
  43. package/dist/service.js.map +1 -0
  44. package/dist/signals.d.ts +21 -0
  45. package/dist/signals.d.ts.map +1 -0
  46. package/dist/signals.js +52 -0
  47. package/dist/signals.js.map +1 -0
  48. package/dist/tokens.d.ts +95 -0
  49. package/dist/tokens.d.ts.map +1 -0
  50. package/dist/tokens.js +158 -0
  51. package/dist/tokens.js.map +1 -0
  52. package/dist/watchers.d.ts +12 -0
  53. package/dist/watchers.d.ts.map +1 -0
  54. package/dist/watchers.js +18 -0
  55. package/dist/watchers.js.map +1 -0
  56. package/package.json +53 -4
  57. package/src/bridge.ts +112 -0
  58. package/src/channel.ts +48 -0
  59. package/src/contract.ts +130 -0
  60. package/src/correlator.ts +81 -0
  61. package/src/guestBridge.ts +261 -0
  62. package/src/hostModel.generated.ts +2649 -0
  63. package/src/hostModel.ts +209 -0
  64. package/src/index.ts +11 -0
  65. package/src/protocol.ts +475 -0
  66. package/src/service.ts +253 -0
  67. package/src/signals.ts +65 -0
  68. package/src/tokens.ts +165 -0
  69. package/src/watchers.ts +18 -0
@@ -0,0 +1,155 @@
1
+ /**
2
+ * The pieces `bridge.host` is built from: objects, properties, signals,
3
+ * calls. `hostModel.generated.ts` is generated from igni's host schema
4
+ * and is made of these.
5
+ *
6
+ * await bridge.host.chat.processing.get(); // read a property
7
+ * await bridge.host.sessions.current.set(id); // write one
8
+ * await bridge.host.chat.post("Done."); // call a method
9
+ * bridge.on(bridge.host.chat.run_completed, (run) => { … });
10
+ *
11
+ * How a request reaches igni is the `HostLink`'s business — the bridge
12
+ * forwards it to the window this page is framed in, which forwards it to
13
+ * the host. Names are the schema's, snake_case, in both SDKs.
14
+ */
15
+ /** Any JSON value: the host's report of something not yet typed. */
16
+ export type JsonValue = unknown;
17
+ /** Why the host refused or failed — the same codes the Python SDK raises. */
18
+ export type HostErrorCode = "not_granted" | "not_found" | "invalid" | "read_only" | "stage_2" | "refused" | "unavailable" | "failed";
19
+ /** The host said no, or it went wrong there. `code` is for code; the message, for people. */
20
+ export declare class HostError extends Error {
21
+ /** Why it failed: one of the {@link HostErrorCode}s, or the host's own. */
22
+ readonly code: HostErrorCode | string;
23
+ /**
24
+ * The failure, as the host reported it.
25
+ *
26
+ * @param code — why it failed: one of the {@link HostErrorCode}s, or
27
+ * whatever the host said.
28
+ * @param message — a sentence for a person to read.
29
+ */
30
+ constructor(
31
+ /** Why it failed: one of the {@link HostErrorCode}s, or the host's own. */
32
+ code: HostErrorCode | string, message: string);
33
+ }
34
+ /** How requests reach the igni host. */
35
+ export interface HostLink {
36
+ /**
37
+ * Send one request to the host.
38
+ *
39
+ * @param op — what to do: read a property, write one, or call a method.
40
+ * @param path — where in the model, as `host.chat.processing`.
41
+ * @param options — the window or session it is about, the arguments
42
+ * of a call, and the value of a write.
43
+ * @returns — whatever the host answered with.
44
+ */
45
+ request(op: "get" | "set" | "call", path: string, options: {
46
+ /** The window to ask about, when it is not this page's own. */
47
+ window?: string | null;
48
+ /** The session to ask about, when it is not the one on screen. */
49
+ session?: string | null;
50
+ /** The arguments of a call, by name. */
51
+ params?: Record<string, unknown>;
52
+ /** The value of a write. */
53
+ value?: unknown;
54
+ }): Promise<unknown>;
55
+ }
56
+ /** One object of the host model: `host.chat`, `host.windows.ui(id)`, `host.sessions.chat(id)`. */
57
+ export declare class HostObject {
58
+ /** How requests reach the host. */
59
+ protected readonly link: HostLink;
60
+ /** Where in the model this object sits: `host.chat`. */
61
+ readonly path: string;
62
+ /** The window it belongs to, when it belongs to one. */
63
+ protected readonly window: string | null;
64
+ /** The session it belongs to, when it belongs to one. */
65
+ protected readonly session: string | null;
66
+ /**
67
+ * One object of the model, bound to a host.
68
+ *
69
+ * A page never builds one: `bridge.host` is already the right one,
70
+ * and a second would be a second conversation.
71
+ *
72
+ * @param link — how requests reach the host.
73
+ * @param path — where in the model this object sits.
74
+ * @param window — the window it belongs to, when it belongs to one.
75
+ * @param session — the session it belongs to, when it belongs to one.
76
+ */
77
+ constructor(
78
+ /** How requests reach the host. */
79
+ link: HostLink,
80
+ /** Where in the model this object sits: `host.chat`. */
81
+ path: string,
82
+ /** The window it belongs to, when it belongs to one. */
83
+ window?: string | null,
84
+ /** The session it belongs to, when it belongs to one. */
85
+ session?: string | null);
86
+ /** @internal */
87
+ memberPath(name: string): string;
88
+ /** @internal — for `Property`. */
89
+ hostLink(): HostLink;
90
+ /** @internal — for `Property`. */
91
+ windowId(): string | null;
92
+ /** @internal — for `Property`. */
93
+ sessionId(): string | null;
94
+ /**
95
+ * Call a method on the host.
96
+ *
97
+ * @param name — the method's name, as the schema spells it.
98
+ * @param params — its arguments, by name.
99
+ * @returns — whatever the host answered with.
100
+ */
101
+ protected call<T>(name: string, params: Record<string, unknown>): Promise<T>;
102
+ }
103
+ /** A value of a host object: `get()` reads it, `set()` writes it. */
104
+ export declare class Property<T> {
105
+ /** The object it belongs to. */
106
+ private readonly owner;
107
+ /** Its name, as the schema spells it. */
108
+ readonly name: string;
109
+ /** Whether it may be written. */
110
+ readonly writable: boolean;
111
+ /**
112
+ * One value of one host object.
113
+ *
114
+ * @param owner — the object it belongs to.
115
+ * @param name — its name, as the schema spells it.
116
+ * @param writable — whether it may be written.
117
+ */
118
+ constructor(
119
+ /** The object it belongs to. */
120
+ owner: HostObject,
121
+ /** Its name, as the schema spells it. */
122
+ name: string,
123
+ /** Whether it may be written. */
124
+ writable: boolean);
125
+ /** Where in the model this value sits: `host.chat.processing`. */
126
+ get path(): string;
127
+ /**
128
+ * Read it.
129
+ *
130
+ * @returns — the value the host holds right now.
131
+ */
132
+ get(): Promise<T>;
133
+ /** Write it, as the person's UI would. Refused where theirs would be. */
134
+ set(value: T): Promise<void>;
135
+ }
136
+ /**
137
+ * One signal of one host object; `T` is what it carries. `name` is its
138
+ * wire name — `chat.run_completed`, or for the four events that predate
139
+ * the model their topic strings (`session.switched`, …).
140
+ */
141
+ export declare class Signal<T> {
142
+ /** Its wire name, as the host sends it: `chat.run_completed`. */
143
+ readonly name: string;
144
+ /** Only for the type parameter; never set. */
145
+ readonly carries?: T;
146
+ /**
147
+ * One signal of one host object.
148
+ *
149
+ * @param name — its wire name, as the host sends it.
150
+ */
151
+ constructor(
152
+ /** Its wire name, as the host sends it: `chat.run_completed`. */
153
+ name: string);
154
+ }
155
+ //# sourceMappingURL=hostModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hostModel.d.ts","sourceRoot":"","sources":["../src/hostModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,oEAAoE;AACpE,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC;AAEhC,6EAA6E;AAC7E,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,WAAW,GACX,SAAS,GACT,WAAW,GACX,SAAS,GACT,SAAS,GACT,aAAa,GACb,QAAQ,CAAC;AAEb,6FAA6F;AAC7F,qBAAa,SAAU,SAAQ,KAAK;IAShC,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM;IATvC;;;;;;OAMG;;IAED,2EAA2E;IAClE,IAAI,EAAE,aAAa,GAAG,MAAM,EACrC,OAAO,EAAE,MAAM;CAKlB;AAED,wCAAwC;AACxC,MAAM,WAAW,QAAQ;IACvB;;;;;;;;OAQG;IACH,OAAO,CACL,EAAE,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,EAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QACP,+DAA+D;QAC/D,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,kEAAkE;QAClE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,wCAAwC;QACxC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjC,4BAA4B;QAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,GACA,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AAED,kGAAkG;AAClG,qBAAa,UAAU;IAanB,mCAAmC;IACnC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ;IACj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