@stigmer/react 0.0.89 → 0.0.91

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 (128) hide show
  1. package/identity-provider/CreateIdentityProviderForm.d.ts.map +1 -1
  2. package/identity-provider/CreateIdentityProviderForm.js +60 -2
  3. package/identity-provider/CreateIdentityProviderForm.js.map +1 -1
  4. package/identity-provider/IdentityProviderDetailPanel.d.ts.map +1 -1
  5. package/identity-provider/IdentityProviderDetailPanel.js +87 -4
  6. package/identity-provider/IdentityProviderDetailPanel.js.map +1 -1
  7. package/identity-provider/IdentityProviderListPanel.js +5 -3
  8. package/identity-provider/IdentityProviderListPanel.js.map +1 -1
  9. package/identity-provider/IdentityProviderWizard.d.ts.map +1 -1
  10. package/identity-provider/IdentityProviderWizard.js +59 -4
  11. package/identity-provider/IdentityProviderWizard.js.map +1 -1
  12. package/index.d.ts +2 -0
  13. package/index.d.ts.map +1 -1
  14. package/index.js +2 -0
  15. package/index.js.map +1 -1
  16. package/package.json +7 -7
  17. package/platform-client/CreatePlatformClientForm.d.ts +42 -0
  18. package/platform-client/CreatePlatformClientForm.d.ts.map +1 -0
  19. package/platform-client/CreatePlatformClientForm.js +148 -0
  20. package/platform-client/CreatePlatformClientForm.js.map +1 -0
  21. package/platform-client/PlatformClientDetailPanel.d.ts +51 -0
  22. package/platform-client/PlatformClientDetailPanel.d.ts.map +1 -0
  23. package/platform-client/PlatformClientDetailPanel.js +247 -0
  24. package/platform-client/PlatformClientDetailPanel.js.map +1 -0
  25. package/platform-client/PlatformClientListPanel.d.ts +41 -0
  26. package/platform-client/PlatformClientListPanel.d.ts.map +1 -0
  27. package/platform-client/PlatformClientListPanel.js +123 -0
  28. package/platform-client/PlatformClientListPanel.js.map +1 -0
  29. package/platform-client/PlatformClientSecretAlert.d.ts +39 -0
  30. package/platform-client/PlatformClientSecretAlert.d.ts.map +1 -0
  31. package/platform-client/PlatformClientSecretAlert.js +74 -0
  32. package/platform-client/PlatformClientSecretAlert.js.map +1 -0
  33. package/platform-client/index.d.ts +11 -0
  34. package/platform-client/index.d.ts.map +1 -0
  35. package/platform-client/index.js +11 -0
  36. package/platform-client/index.js.map +1 -0
  37. package/platform-client/useCreatePlatformClient.d.ts +42 -0
  38. package/platform-client/useCreatePlatformClient.d.ts.map +1 -0
  39. package/platform-client/useCreatePlatformClient.js +49 -0
  40. package/platform-client/useCreatePlatformClient.js.map +1 -0
  41. package/platform-client/useDeletePlatformClient.d.ts +31 -0
  42. package/platform-client/useDeletePlatformClient.d.ts.map +1 -0
  43. package/platform-client/useDeletePlatformClient.js +42 -0
  44. package/platform-client/useDeletePlatformClient.js.map +1 -0
  45. package/platform-client/usePlatformClient.d.ts +37 -0
  46. package/platform-client/usePlatformClient.d.ts.map +1 -0
  47. package/platform-client/usePlatformClient.js +62 -0
  48. package/platform-client/usePlatformClient.js.map +1 -0
  49. package/platform-client/usePlatformClientList.d.ts +42 -0
  50. package/platform-client/usePlatformClientList.d.ts.map +1 -0
  51. package/platform-client/usePlatformClientList.js +71 -0
  52. package/platform-client/usePlatformClientList.js.map +1 -0
  53. package/platform-client/useRotatePlatformClientSecret.d.ts +35 -0
  54. package/platform-client/useRotatePlatformClientSecret.d.ts.map +1 -0
  55. package/platform-client/useRotatePlatformClientSecret.js +43 -0
  56. package/platform-client/useRotatePlatformClientSecret.js.map +1 -0
  57. package/platform-client/useUpdatePlatformClient.d.ts +39 -0
  58. package/platform-client/useUpdatePlatformClient.d.ts.map +1 -0
  59. package/platform-client/useUpdatePlatformClient.js +50 -0
  60. package/platform-client/useUpdatePlatformClient.js.map +1 -0
  61. package/src/identity-provider/CreateIdentityProviderForm.tsx +220 -0
  62. package/src/identity-provider/IdentityProviderDetailPanel.tsx +288 -6
  63. package/src/identity-provider/IdentityProviderListPanel.tsx +9 -2
  64. package/src/identity-provider/IdentityProviderWizard.tsx +231 -25
  65. package/src/index.ts +26 -0
  66. package/src/platform-client/CreatePlatformClientForm.tsx +519 -0
  67. package/src/platform-client/PlatformClientDetailPanel.tsx +898 -0
  68. package/src/platform-client/PlatformClientListPanel.tsx +413 -0
  69. package/src/platform-client/PlatformClientSecretAlert.tsx +252 -0
  70. package/src/platform-client/index.ts +49 -0
  71. package/src/platform-client/useCreatePlatformClient.ts +77 -0
  72. package/src/platform-client/useDeletePlatformClient.ts +64 -0
  73. package/src/platform-client/usePlatformClient.ts +86 -0
  74. package/src/platform-client/usePlatformClientList.ts +96 -0
  75. package/src/platform-client/useRotatePlatformClientSecret.ts +68 -0
  76. package/src/platform-client/useUpdatePlatformClient.ts +70 -0
  77. package/src/test/index.ts +6 -0
  78. package/src/{demo → test}/samples.ts +1 -1
  79. package/styles.css +1 -1
  80. package/test/__tests__/samples.test.d.ts.map +1 -0
  81. package/{demo → test}/__tests__/samples.test.js.map +1 -1
  82. package/test/index.d.ts +2 -0
  83. package/test/index.d.ts.map +1 -0
  84. package/test/index.js +6 -0
  85. package/test/index.js.map +1 -0
  86. package/{demo → test}/samples.d.ts +1 -1
  87. package/{demo → test}/samples.d.ts.map +1 -1
  88. package/{demo → test}/samples.js +1 -1
  89. package/{demo → test}/samples.js.map +1 -1
  90. package/demo/__tests__/demo-client.test.d.ts +0 -2
  91. package/demo/__tests__/demo-client.test.d.ts.map +0 -1
  92. package/demo/__tests__/demo-client.test.js +0 -133
  93. package/demo/__tests__/demo-client.test.js.map +0 -1
  94. package/demo/__tests__/fixtures.test.d.ts +0 -2
  95. package/demo/__tests__/fixtures.test.d.ts.map +0 -1
  96. package/demo/__tests__/fixtures.test.js +0 -135
  97. package/demo/__tests__/fixtures.test.js.map +0 -1
  98. package/demo/__tests__/samples.test.d.ts.map +0 -1
  99. package/demo/client.d.ts +0 -29
  100. package/demo/client.d.ts.map +0 -1
  101. package/demo/client.js +0 -52
  102. package/demo/client.js.map +0 -1
  103. package/demo/fixtures.d.ts +0 -194
  104. package/demo/fixtures.d.ts.map +0 -1
  105. package/demo/fixtures.js +0 -267
  106. package/demo/fixtures.js.map +0 -1
  107. package/demo/index.d.ts +0 -6
  108. package/demo/index.d.ts.map +0 -1
  109. package/demo/index.js +0 -6
  110. package/demo/index.js.map +0 -1
  111. package/demo/transport.d.ts +0 -59
  112. package/demo/transport.d.ts.map +0 -1
  113. package/demo/transport.js +0 -75
  114. package/demo/transport.js.map +0 -1
  115. package/demo/types.d.ts +0 -62
  116. package/demo/types.d.ts.map +0 -1
  117. package/demo/types.js +0 -16
  118. package/demo/types.js.map +0 -1
  119. package/src/demo/__tests__/demo-client.test.tsx +0 -213
  120. package/src/demo/__tests__/fixtures.test.ts +0 -214
  121. package/src/demo/client.ts +0 -78
  122. package/src/demo/fixtures.ts +0 -409
  123. package/src/demo/index.ts +0 -12
  124. package/src/demo/transport.ts +0 -116
  125. package/src/demo/types.ts +0 -69
  126. /package/src/{demo → test}/__tests__/samples.test.ts +0 -0
  127. /package/{demo → test}/__tests__/samples.test.d.ts +0 -0
  128. /package/{demo → test}/__tests__/samples.test.js +0 -0
@@ -1,409 +0,0 @@
1
- import { AgentCommandController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/command_pb";
2
- import { AgentQueryController } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/query_pb";
3
- import { AgentExecutionCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/command_pb";
4
- import { AgentExecutionQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/query_pb";
5
- import { AgentInstanceCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/command_pb";
6
- import { AgentInstanceQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/query_pb";
7
- import { EnvironmentCommandController } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/command_pb";
8
- import { EnvironmentQueryController } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/query_pb";
9
- import { McpServerCommandController } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/command_pb";
10
- import { McpServerQueryController } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/query_pb";
11
- import { SessionCommandController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/command_pb";
12
- import { SessionQueryController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/query_pb";
13
- import { SkillCommandController } from "@stigmer/protos/ai/stigmer/agentic/skill/v1/command_pb";
14
- import { SkillQueryController } from "@stigmer/protos/ai/stigmer/agentic/skill/v1/query_pb";
15
- import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
16
- import { ApiKeyCommandController } from "@stigmer/protos/ai/stigmer/iam/apikey/v1/command_pb";
17
- import { ApiKeyQueryController } from "@stigmer/protos/ai/stigmer/iam/apikey/v1/query_pb";
18
- import { GitHubService } from "@stigmer/protos/ai/stigmer/platform/github/v1/service_pb";
19
- import { SearchService } from "@stigmer/protos/ai/stigmer/search/v1/query_pb";
20
- import { OrganizationCommandController } from "@stigmer/protos/ai/stigmer/tenancy/organization/v1/command_pb";
21
- import type {
22
- DemoScenario,
23
- FixtureEntry,
24
- StreamFixtureHandler,
25
- UnaryFixtureHandler,
26
- } from "./types";
27
- import { rpcKey } from "./types";
28
-
29
- /**
30
- * A fixture specification returned by fixture entry helpers.
31
- *
32
- * Pass one or more specs to {@link buildScenario} to construct a
33
- * {@link DemoScenario} ready for {@link createDemoClient}.
34
- *
35
- * The `searchResourceKind` field is set automatically by search-backed
36
- * helpers (`fixtures.agent.list`, `fixtures.skill.list`,
37
- * `fixtures.mcpServer.list`). Do not set it manually.
38
- */
39
- export interface FixtureSpec {
40
- readonly key: string;
41
- readonly entry: FixtureEntry;
42
- readonly searchResourceKind?: ApiResourceKind;
43
- }
44
-
45
- // ---------------------------------------------------------------------------
46
- // Internal helpers
47
- // ---------------------------------------------------------------------------
48
-
49
- function unarySpec(
50
- service: { readonly typeName: string },
51
- method: string,
52
- handler: UnaryFixtureHandler,
53
- ): FixtureSpec {
54
- return { key: rpcKey(service, method), entry: { unary: handler } };
55
- }
56
-
57
- function streamSpec(
58
- service: { readonly typeName: string },
59
- method: string,
60
- handler: StreamFixtureHandler,
61
- ): FixtureSpec {
62
- return { key: rpcKey(service, method), entry: { stream: handler } };
63
- }
64
-
65
- function searchListSpec(
66
- kind: ApiResourceKind,
67
- handler: UnaryFixtureHandler,
68
- ): FixtureSpec {
69
- return {
70
- key: rpcKey(SearchService, "search"),
71
- entry: { unary: handler },
72
- searchResourceKind: kind,
73
- };
74
- }
75
-
76
- // ---------------------------------------------------------------------------
77
- // Fixture entry helpers — organized by resource domain
78
- // ---------------------------------------------------------------------------
79
-
80
- /**
81
- * Fixture entry helpers mirroring the `Stigmer` SDK client shape.
82
- *
83
- * Each method wraps a user-provided handler into a {@link FixtureSpec}
84
- * that {@link buildScenario} assembles into a {@link DemoScenario}.
85
- *
86
- * Method names match the SDK client methods (e.g. `fixtures.session.get`
87
- * mirrors `client.session.get`). JSDoc on each method documents which
88
- * React hooks consume that RPC.
89
- *
90
- * @example
91
- * ```ts
92
- * import { fixtures, buildScenario, createDemoClient } from "@stigmer/react/demo";
93
- *
94
- * const scenario = buildScenario(
95
- * fixtures.session.get(() => mySession),
96
- * fixtures.agentExecution.listBySession(() => myExecutionList),
97
- * fixtures.agentExecution.subscribe(() => [snapshot1, snapshot2]),
98
- * );
99
- * const client = createDemoClient(scenario);
100
- * ```
101
- */
102
- export const fixtures = {
103
- // ---- Session ----
104
-
105
- session: {
106
- /** Hooks: `useSession`, `useSessionConversation` */
107
- get: (handler: UnaryFixtureHandler): FixtureSpec =>
108
- unarySpec(SessionQueryController, "get", handler),
109
-
110
- /** Hooks: `useSessionList` */
111
- list: (handler: UnaryFixtureHandler): FixtureSpec =>
112
- unarySpec(SessionQueryController, "list", handler),
113
-
114
- /** Hooks: `useCreateSession` */
115
- create: (handler: UnaryFixtureHandler): FixtureSpec =>
116
- unarySpec(SessionCommandController, "create", handler),
117
-
118
- /** Hooks: `useUpdateSession`, `useSessionConversation` */
119
- update: (handler: UnaryFixtureHandler): FixtureSpec =>
120
- unarySpec(SessionCommandController, "update", handler),
121
- },
122
-
123
- // ---- Agent Execution ----
124
-
125
- agentExecution: {
126
- /** Hooks: `useCreateAgentExecution` */
127
- create: (handler: UnaryFixtureHandler): FixtureSpec =>
128
- unarySpec(AgentExecutionCommandController, "create", handler),
129
-
130
- /** Hooks: `useSessionExecutions`, `useSessionConversation` */
131
- listBySession: (handler: UnaryFixtureHandler): FixtureSpec =>
132
- unarySpec(AgentExecutionQueryController, "listBySession", handler),
133
-
134
- /**
135
- * Hooks: `useExecutionStream`, `useSessionConversation`
136
- *
137
- * The handler returns an **array** of `AgentExecution` snapshots that
138
- * the transport yields as a server stream.
139
- */
140
- subscribe: (handler: StreamFixtureHandler): FixtureSpec =>
141
- streamSpec(AgentExecutionQueryController, "subscribe", handler),
142
-
143
- /** Hooks: `useSubmitApproval`, `useSessionConversation` */
144
- submitApproval: (handler: UnaryFixtureHandler): FixtureSpec =>
145
- unarySpec(AgentExecutionCommandController, "submitApproval", handler),
146
-
147
- /** Hooks: `useArtifactContent`, `useDetectSkillPackage` */
148
- getArtifactContent: (handler: UnaryFixtureHandler): FixtureSpec =>
149
- unarySpec(AgentExecutionQueryController, "getArtifactContent", handler),
150
-
151
- /** Hooks: `useAttachments` */
152
- uploadAttachment: (handler: UnaryFixtureHandler): FixtureSpec =>
153
- unarySpec(AgentExecutionCommandController, "uploadAttachment", handler),
154
- },
155
-
156
- // ---- Agent ----
157
-
158
- agent: {
159
- /** Hooks: `useAgentRefFromSession` */
160
- get: (handler: UnaryFixtureHandler): FixtureSpec =>
161
- unarySpec(AgentQueryController, "get", handler),
162
-
163
- /** Hooks: `useAgent`, `useCreateSession`, `useAgentSetup` */
164
- getByReference: (handler: UnaryFixtureHandler): FixtureSpec =>
165
- unarySpec(AgentQueryController, "getByReference", handler),
166
-
167
- /** Hooks: `useDefaultAgent` */
168
- getDefault: (handler: UnaryFixtureHandler): FixtureSpec =>
169
- unarySpec(AgentQueryController, "getDefault", handler),
170
-
171
- /**
172
- * Hooks: `useAgentList`, `useAgentSearch`, `useAgentCount`
173
- *
174
- * Routes through `SearchService` — use {@link buildScenario} to avoid
175
- * key collisions with `fixtures.skill.list` and `fixtures.mcpServer.list`.
176
- */
177
- list: (handler: UnaryFixtureHandler): FixtureSpec =>
178
- searchListSpec(ApiResourceKind.agent, handler),
179
-
180
- /** Hooks: `useApplyResource` */
181
- apply: (handler: UnaryFixtureHandler): FixtureSpec =>
182
- unarySpec(AgentCommandController, "apply", handler),
183
-
184
- /** Hooks: `useUpdateVisibility` (when kind is Agent) */
185
- updateVisibility: (handler: UnaryFixtureHandler): FixtureSpec =>
186
- unarySpec(AgentCommandController, "updateVisibility", handler),
187
- },
188
-
189
- // ---- Skill ----
190
-
191
- skill: {
192
- /** Hooks: `useSkill` */
193
- getByReference: (handler: UnaryFixtureHandler): FixtureSpec =>
194
- unarySpec(SkillQueryController, "getByReference", handler),
195
-
196
- /**
197
- * Hooks: `useSkillList`, `useSkillSearch`, `useSkillCount`
198
- *
199
- * Routes through `SearchService` — use {@link buildScenario} to avoid
200
- * key collisions with `fixtures.agent.list` and `fixtures.mcpServer.list`.
201
- */
202
- list: (handler: UnaryFixtureHandler): FixtureSpec =>
203
- searchListSpec(ApiResourceKind.skill, handler),
204
-
205
- /** Hooks: `useApplyResource` (when kind is Skill) */
206
- pushFromExecutionArtifact: (handler: UnaryFixtureHandler): FixtureSpec =>
207
- unarySpec(SkillCommandController, "pushFromExecutionArtifact", handler),
208
-
209
- /** Hooks: `useUpdateVisibility` (when kind is Skill) */
210
- updateVisibility: (handler: UnaryFixtureHandler): FixtureSpec =>
211
- unarySpec(SkillCommandController, "updateVisibility", handler),
212
- },
213
-
214
- // ---- MCP Server ----
215
-
216
- mcpServer: {
217
- /** Hooks: `useMcpServer`, `useMcpServerSetup` */
218
- getByReference: (handler: UnaryFixtureHandler): FixtureSpec =>
219
- unarySpec(McpServerQueryController, "getByReference", handler),
220
-
221
- /**
222
- * Hooks: `useMcpServerList`, `useMcpServerSearch`, `useMcpServerCount`
223
- *
224
- * Routes through `SearchService` — use {@link buildScenario} to avoid
225
- * key collisions with `fixtures.agent.list` and `fixtures.skill.list`.
226
- */
227
- list: (handler: UnaryFixtureHandler): FixtureSpec =>
228
- searchListSpec(ApiResourceKind.mcp_server, handler),
229
-
230
- /** Hooks: `useMcpServerConnect` */
231
- connect: (handler: UnaryFixtureHandler): FixtureSpec =>
232
- unarySpec(McpServerCommandController, "connect", handler),
233
-
234
- /** Hooks: `useApplyResource` (when kind is McpServer) */
235
- apply: (handler: UnaryFixtureHandler): FixtureSpec =>
236
- unarySpec(McpServerCommandController, "apply", handler),
237
-
238
- /** Hooks: `useUpdateVisibility` (when kind is McpServer) */
239
- updateVisibility: (handler: UnaryFixtureHandler): FixtureSpec =>
240
- unarySpec(McpServerCommandController, "updateVisibility", handler),
241
-
242
- /** Hooks: `useOAuthGrantStatus` */
243
- getOAuthGrantStatus: (handler: UnaryFixtureHandler): FixtureSpec =>
244
- unarySpec(McpServerQueryController, "getOAuthGrantStatus", handler),
245
-
246
- /** Hooks: `useOrgOAuthApp` */
247
- getOrgOAuthApp: (handler: UnaryFixtureHandler): FixtureSpec =>
248
- unarySpec(McpServerQueryController, "getOrgOAuthApp", handler),
249
- },
250
-
251
- // ---- Environment ----
252
-
253
- environment: {
254
- /** Components: `EnvironmentVariableEditor` */
255
- get: (handler: UnaryFixtureHandler): FixtureSpec =>
256
- unarySpec(EnvironmentQueryController, "get", handler),
257
-
258
- /** Hooks: `useEnvironment` */
259
- getByReference: (handler: UnaryFixtureHandler): FixtureSpec =>
260
- unarySpec(EnvironmentQueryController, "getByReference", handler),
261
-
262
- /** Hooks: `useEnvironmentList`, `usePersonalEnvironment` */
263
- list: (handler: UnaryFixtureHandler): FixtureSpec =>
264
- unarySpec(EnvironmentQueryController, "list", handler),
265
-
266
- /** Hooks: `useCreateEnvironment`, `usePersonalEnvironment` */
267
- create: (handler: UnaryFixtureHandler): FixtureSpec =>
268
- unarySpec(EnvironmentCommandController, "create", handler),
269
-
270
- /** Hooks: `useUpdateEnvironment` */
271
- update: (handler: UnaryFixtureHandler): FixtureSpec =>
272
- unarySpec(EnvironmentCommandController, "update", handler),
273
-
274
- /** Hooks: `useUpdateEnvironmentVariables`, `usePersonalEnvironment` */
275
- updateVariables: (handler: UnaryFixtureHandler): FixtureSpec =>
276
- unarySpec(EnvironmentCommandController, "updateVariables", handler),
277
-
278
- /** Hooks: `useRemoveEnvironmentVariables`, `usePersonalEnvironment` */
279
- removeVariables: (handler: UnaryFixtureHandler): FixtureSpec =>
280
- unarySpec(EnvironmentCommandController, "removeVariables", handler),
281
-
282
- /** Hooks: `useRevealSecretValue`, `useGitHubConnection` */
283
- getSecretValue: (handler: UnaryFixtureHandler): FixtureSpec =>
284
- unarySpec(EnvironmentQueryController, "getSecretValue", handler),
285
- },
286
-
287
- // ---- Agent Instance ----
288
-
289
- agentInstance: {
290
- /** Hooks: `useAgentRefFromSession` */
291
- get: (handler: UnaryFixtureHandler): FixtureSpec =>
292
- unarySpec(AgentInstanceQueryController, "get", handler),
293
-
294
- /** Hooks: `useAgentInstance` */
295
- getByReference: (handler: UnaryFixtureHandler): FixtureSpec =>
296
- unarySpec(AgentInstanceQueryController, "getByReference", handler),
297
-
298
- /** Hooks: `useAgentInstanceList`, `useAgentSetup` */
299
- list: (handler: UnaryFixtureHandler): FixtureSpec =>
300
- unarySpec(AgentInstanceQueryController, "list", handler),
301
-
302
- /** Hooks: `useCreateAgentInstance`, `usePersonalAgentInstance`, `useAgentSetup` */
303
- create: (handler: UnaryFixtureHandler): FixtureSpec =>
304
- unarySpec(AgentInstanceCommandController, "create", handler),
305
- },
306
-
307
- // ---- Organization ----
308
-
309
- organization: {
310
- /** Hooks: `useCreateOrganization` */
311
- create: (handler: UnaryFixtureHandler): FixtureSpec =>
312
- unarySpec(OrganizationCommandController, "create", handler),
313
- },
314
-
315
- // ---- API Key ----
316
-
317
- apiKey: {
318
- /** Hooks: `useApiKeyList` */
319
- findAll: (handler: UnaryFixtureHandler): FixtureSpec =>
320
- unarySpec(ApiKeyQueryController, "findAll", handler),
321
-
322
- /** Hooks: `useCreateApiKey` */
323
- create: (handler: UnaryFixtureHandler): FixtureSpec =>
324
- unarySpec(ApiKeyCommandController, "create", handler),
325
-
326
- /** Hooks: `useDeleteApiKey` */
327
- delete: (handler: UnaryFixtureHandler): FixtureSpec =>
328
- unarySpec(ApiKeyCommandController, "delete", handler),
329
- },
330
-
331
- // ---- GitHub ----
332
-
333
- github: {
334
- /** Hooks: `useGitHubConnection` */
335
- getOAuthAuthorizeUrl: (handler: UnaryFixtureHandler): FixtureSpec =>
336
- unarySpec(GitHubService, "getOAuthAuthorizeUrl", handler),
337
-
338
- /** Hooks: `useGitHubConnection` */
339
- exchangeOAuthCode: (handler: UnaryFixtureHandler): FixtureSpec =>
340
- unarySpec(GitHubService, "exchangeOAuthCode", handler),
341
- },
342
- } as const;
343
-
344
- // ---------------------------------------------------------------------------
345
- // Scenario builder
346
- // ---------------------------------------------------------------------------
347
-
348
- /**
349
- * Assemble {@link FixtureSpec} entries into a {@link DemoScenario}.
350
- *
351
- * This is the recommended way to construct scenarios because it correctly
352
- * merges search-backed list fixtures (`agent.list`, `skill.list`,
353
- * `mcpServer.list`) that share the same underlying `SearchService` RPC.
354
- * Using `new Map([...])` directly with these helpers would cause silent
355
- * key collisions where the last entry wins.
356
- *
357
- * @example
358
- * ```ts
359
- * import { fixtures, buildScenario, createDemoClient } from "@stigmer/react/demo";
360
- *
361
- * const scenario = buildScenario(
362
- * fixtures.session.get(() => mySession),
363
- * fixtures.agent.list(() => myAgentSearchResponse),
364
- * fixtures.skill.list(() => mySkillSearchResponse),
365
- * );
366
- * const client = createDemoClient(scenario);
367
- * ```
368
- */
369
- export function buildScenario(...specs: FixtureSpec[]): DemoScenario {
370
- const entries: [string, FixtureEntry][] = [];
371
- const searchHandlers = new Map<ApiResourceKind, UnaryFixtureHandler>();
372
-
373
- for (const spec of specs) {
374
- if (spec.searchResourceKind !== undefined) {
375
- if (spec.entry.unary) {
376
- searchHandlers.set(spec.searchResourceKind, spec.entry.unary);
377
- }
378
- } else {
379
- entries.push([spec.key, spec.entry]);
380
- }
381
- }
382
-
383
- if (searchHandlers.size > 0) {
384
- const searchKey = rpcKey(SearchService, "search");
385
- entries.push([
386
- searchKey,
387
- {
388
- unary: (request: unknown) => {
389
- const req = request as { kinds?: ApiResourceKind[] };
390
- const kind = req.kinds?.[0];
391
- if (kind !== undefined) {
392
- const handler = searchHandlers.get(kind);
393
- if (handler) return handler(request);
394
- }
395
- const registered = [...searchHandlers.keys()]
396
- .map((k) => ApiResourceKind[k])
397
- .join(", ");
398
- throw new Error(
399
- `No search fixture for resource kind ${kind !== undefined ? ApiResourceKind[kind] ?? kind : "(none)"}. ` +
400
- `Registered kinds: ${registered || "(none)"}. ` +
401
- `Add a fixture with fixtures.agent.list(), fixtures.skill.list(), or fixtures.mcpServer.list().`,
402
- );
403
- },
404
- },
405
- ]);
406
- }
407
-
408
- return { fixtures: new Map(entries) };
409
- }
package/src/demo/index.ts DELETED
@@ -1,12 +0,0 @@
1
- export { createDemoClient } from "./client";
2
- export { buildScenario, fixtures, type FixtureSpec } from "./fixtures";
3
- export { samples } from "./samples";
4
- export { DemoTransport } from "./transport";
5
- export {
6
- rpcKey,
7
- type DemoScenario,
8
- type FixtureEntry,
9
- type FixtureRegistry,
10
- type StreamFixtureHandler,
11
- type UnaryFixtureHandler,
12
- } from "./types";
@@ -1,116 +0,0 @@
1
- import type { FixtureRegistry } from "./types";
2
-
3
- /**
4
- * Minimal shape of a Connect-RPC method descriptor.
5
- *
6
- * Matches the relevant fields of `DescMethodUnary` and `DescMethodStreaming`
7
- * from `@bufbuild/protobuf` without importing the full generic types.
8
- * The transport only needs the service type name and method name to
9
- * look up fixture handlers.
10
- */
11
- interface RpcMethodDescriptor {
12
- readonly parent: { readonly typeName: string };
13
- readonly name: string;
14
- }
15
-
16
- function fixtureKey(method: RpcMethodDescriptor): string {
17
- return `${method.parent.typeName}/${method.name}`;
18
- }
19
-
20
- function shortServiceName(method: RpcMethodDescriptor): string {
21
- return method.parent.typeName.split(".").pop() ?? method.parent.typeName;
22
- }
23
-
24
- /**
25
- * A Connect-RPC `Transport` backed by in-memory fixture data.
26
- *
27
- * Implements the two-method `Transport` interface (`unary` and `stream`)
28
- * from `@connectrpc/connect`. When a generated client issues an RPC,
29
- * the transport looks up the matching fixture handler by
30
- * `"<service typeName>/<method name>"` and returns its result.
31
- *
32
- * Methods without registered fixtures throw a descriptive error
33
- * identifying the missing key and how to register it.
34
- *
35
- * This class is not typed as `implements Transport` because the interface
36
- * uses complex generics from `@bufbuild/protobuf` that would force a
37
- * runtime dependency on `@connectrpc/connect` in `@stigmer/react`.
38
- * The runtime shape is fully compatible — the client factory casts the
39
- * instance to `Transport` at the single point where it is passed to
40
- * generated client constructors.
41
- */
42
- export class DemoTransport {
43
- private readonly fixtures: FixtureRegistry;
44
-
45
- constructor(fixtures: FixtureRegistry) {
46
- this.fixtures = fixtures;
47
- }
48
-
49
- async unary(
50
- method: RpcMethodDescriptor,
51
- _signal: AbortSignal | undefined,
52
- _timeoutMs: number | undefined,
53
- _header: HeadersInit | undefined,
54
- input: unknown,
55
- ) {
56
- const key = fixtureKey(method);
57
- const entry = this.fixtures.get(key);
58
-
59
- if (!entry?.unary) {
60
- throw new Error(
61
- `No demo fixture for ${shortServiceName(method)}/${method.name}. ` +
62
- `Add a fixture with key "${key}" to your DemoScenario.`,
63
- );
64
- }
65
-
66
- return {
67
- stream: false as const,
68
- message: entry.unary(input),
69
- method,
70
- service: method.parent,
71
- header: new Headers(),
72
- trailer: new Headers(),
73
- };
74
- }
75
-
76
- async stream(
77
- method: RpcMethodDescriptor,
78
- _signal: AbortSignal | undefined,
79
- _timeoutMs: number | undefined,
80
- _header: HeadersInit | undefined,
81
- input: AsyncIterable<unknown>,
82
- ) {
83
- const key = fixtureKey(method);
84
- const entry = this.fixtures.get(key);
85
-
86
- if (!entry?.stream) {
87
- throw new Error(
88
- `No demo fixture for ${shortServiceName(method)}/${method.name}. ` +
89
- `Add a fixture with key "${key}" to your DemoScenario.`,
90
- );
91
- }
92
-
93
- // Server-streaming RPCs send a single request message wrapped in an
94
- // async iterable by createClient. Extract it for the fixture handler.
95
- let request: unknown;
96
- for await (const msg of input) {
97
- request = msg;
98
- break;
99
- }
100
-
101
- return {
102
- stream: true as const,
103
- message: toAsyncIterable(entry.stream(request)),
104
- method,
105
- service: method.parent,
106
- header: new Headers(),
107
- trailer: new Headers(),
108
- };
109
- }
110
- }
111
-
112
- async function* toAsyncIterable<T>(items: T[]): AsyncGenerator<T> {
113
- for (const item of items) {
114
- yield item;
115
- }
116
- }
package/src/demo/types.ts DELETED
@@ -1,69 +0,0 @@
1
- /**
2
- * Handler for a unary (request-response) RPC fixture.
3
- *
4
- * Receives the protobuf request message and returns the response message.
5
- * Build responses with `create()` from `@bufbuild/protobuf` to ensure
6
- * correct message shapes.
7
- */
8
- export type UnaryFixtureHandler = (request: unknown) => unknown;
9
-
10
- /**
11
- * Handler for a server-streaming RPC fixture.
12
- *
13
- * Receives the protobuf request message and returns an array of response
14
- * messages that the transport yields as an async stream.
15
- */
16
- export type StreamFixtureHandler = (request: unknown) => unknown[];
17
-
18
- /**
19
- * Fixture configuration for a single RPC method.
20
- *
21
- * Register `unary` for request-response RPCs, or `stream` for
22
- * server-streaming RPCs. The transport checks the appropriate handler
23
- * based on how the generated client invokes the method.
24
- */
25
- export interface FixtureEntry {
26
- readonly unary?: UnaryFixtureHandler;
27
- readonly stream?: StreamFixtureHandler;
28
- }
29
-
30
- /**
31
- * Map of fully-qualified RPC method keys to fixture handlers.
32
- *
33
- * Keys use the format `"<proto service typeName>/<method name>"`, e.g.:
34
- * ```
35
- * "ai.stigmer.agentic.session.v1.SessionQueryController/get"
36
- * ```
37
- *
38
- * Use {@link rpcKey} to construct keys from proto service descriptors.
39
- */
40
- export type FixtureRegistry = ReadonlyMap<string, FixtureEntry>;
41
-
42
- /**
43
- * A collection of RPC fixture handlers that powers a demo client.
44
- *
45
- * Pass to {@link createDemoClient} to obtain a `Stigmer`-compatible
46
- * client that resolves RPCs from in-memory data instead of a live backend.
47
- */
48
- export interface DemoScenario {
49
- readonly fixtures: FixtureRegistry;
50
- }
51
-
52
- /**
53
- * Construct a fixture registry key from a proto service descriptor
54
- * and method name.
55
- *
56
- * @example
57
- * ```ts
58
- * import { SessionQueryController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/query_pb";
59
- *
60
- * rpcKey(SessionQueryController, "get")
61
- * // → "ai.stigmer.agentic.session.v1.SessionQueryController/get"
62
- * ```
63
- */
64
- export function rpcKey(
65
- service: { readonly typeName: string },
66
- method: string,
67
- ): string {
68
- return `${service.typeName}/${method}`;
69
- }
File without changes
File without changes
File without changes