@piedata/pieui 2.0.5 → 2.0.7

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 (46) hide show
  1. package/dist/cli.js +223 -97
  2. package/dist/code/commands/init.d.ts.map +1 -1
  3. package/dist/code/templates/index.d.ts +2 -1
  4. package/dist/code/templates/index.d.ts.map +1 -1
  5. package/dist/code/templates/nextConfig.d.ts +3 -0
  6. package/dist/code/templates/nextConfig.d.ts.map +1 -0
  7. package/dist/components/Common/CloudStorageCard/index.d.ts +3 -0
  8. package/dist/components/Common/CloudStorageCard/index.d.ts.map +1 -0
  9. package/dist/components/Common/CloudStorageCard/types/index.d.ts +13 -0
  10. package/dist/components/Common/CloudStorageCard/types/index.d.ts.map +1 -0
  11. package/dist/components/Common/CloudStorageCard/ui/CloudStorageCard.d.ts +4 -0
  12. package/dist/components/Common/CloudStorageCard/ui/CloudStorageCard.d.ts.map +1 -0
  13. package/dist/components/Common/DeviceStorageCard/index.d.ts +3 -0
  14. package/dist/components/Common/DeviceStorageCard/index.d.ts.map +1 -0
  15. package/dist/components/Common/DeviceStorageCard/types/index.d.ts +13 -0
  16. package/dist/components/Common/DeviceStorageCard/types/index.d.ts.map +1 -0
  17. package/dist/components/Common/DeviceStorageCard/ui/DeviceStorageCard.d.ts +4 -0
  18. package/dist/components/Common/DeviceStorageCard/ui/DeviceStorageCard.d.ts.map +1 -0
  19. package/dist/components/Common/SecureStorageCard/index.d.ts +3 -0
  20. package/dist/components/Common/SecureStorageCard/index.d.ts.map +1 -0
  21. package/dist/components/Common/SecureStorageCard/types/index.d.ts +13 -0
  22. package/dist/components/Common/SecureStorageCard/types/index.d.ts.map +1 -0
  23. package/dist/components/Common/SecureStorageCard/ui/SecureStorageCard.d.ts +4 -0
  24. package/dist/components/Common/SecureStorageCard/ui/SecureStorageCard.d.ts.map +1 -0
  25. package/dist/components/Common/SessionStorageCard/index.d.ts +3 -0
  26. package/dist/components/Common/SessionStorageCard/index.d.ts.map +1 -0
  27. package/dist/components/Common/SessionStorageCard/types/index.d.ts +13 -0
  28. package/dist/components/Common/SessionStorageCard/types/index.d.ts.map +1 -0
  29. package/dist/components/Common/SessionStorageCard/ui/SessionStorageCard.d.ts +4 -0
  30. package/dist/components/Common/SessionStorageCard/ui/SessionStorageCard.d.ts.map +1 -0
  31. package/dist/components/index.d.ts +4 -0
  32. package/dist/components/index.d.ts.map +1 -1
  33. package/dist/components/index.esm.js +1 -1
  34. package/dist/components/index.js +1 -1
  35. package/dist/index.d.ts +3 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.esm.js +2 -2
  38. package/dist/index.js +2 -2
  39. package/dist/pieui.components.json +144 -0
  40. package/dist/tests/mittAgentTools.test.d.ts +2 -0
  41. package/dist/tests/mittAgentTools.test.d.ts.map +1 -0
  42. package/dist/util/ajaxCommonUtils.d.ts +21 -2
  43. package/dist/util/ajaxCommonUtils.d.ts.map +1 -1
  44. package/dist/util/mittAgentTools.d.ts +89 -0
  45. package/dist/util/mittAgentTools.d.ts.map +1 -0
  46. package/package.json +1 -1
@@ -149,6 +149,150 @@
149
149
  "$schema": "http://json-schema.org/draft-07/schema#"
150
150
  }
151
151
  },
152
+ {
153
+ "card": "SessionStorageCard",
154
+ "data": {
155
+ "type": "object",
156
+ "properties": {
157
+ "name": {
158
+ "type": "string"
159
+ },
160
+ "key": {
161
+ "type": "string"
162
+ },
163
+ "value": {
164
+ "type": "string"
165
+ },
166
+ "useSocketioSupport": {
167
+ "type": "boolean"
168
+ },
169
+ "useCentrifugeSupport": {
170
+ "type": "boolean"
171
+ },
172
+ "useMittSupport": {
173
+ "type": "boolean"
174
+ },
175
+ "centrifugeChannel": {
176
+ "type": "string"
177
+ }
178
+ },
179
+ "additionalProperties": false,
180
+ "required": [
181
+ "key",
182
+ "name",
183
+ "value"
184
+ ],
185
+ "$schema": "http://json-schema.org/draft-07/schema#"
186
+ }
187
+ },
188
+ {
189
+ "card": "DeviceStorageCard",
190
+ "data": {
191
+ "type": "object",
192
+ "properties": {
193
+ "name": {
194
+ "type": "string"
195
+ },
196
+ "key": {
197
+ "type": "string"
198
+ },
199
+ "value": {
200
+ "type": "string"
201
+ },
202
+ "useSocketioSupport": {
203
+ "type": "boolean"
204
+ },
205
+ "useCentrifugeSupport": {
206
+ "type": "boolean"
207
+ },
208
+ "useMittSupport": {
209
+ "type": "boolean"
210
+ },
211
+ "centrifugeChannel": {
212
+ "type": "string"
213
+ }
214
+ },
215
+ "additionalProperties": false,
216
+ "required": [
217
+ "key",
218
+ "name",
219
+ "value"
220
+ ],
221
+ "$schema": "http://json-schema.org/draft-07/schema#"
222
+ }
223
+ },
224
+ {
225
+ "card": "CloudStorageCard",
226
+ "data": {
227
+ "type": "object",
228
+ "properties": {
229
+ "name": {
230
+ "type": "string"
231
+ },
232
+ "key": {
233
+ "type": "string"
234
+ },
235
+ "value": {
236
+ "type": "string"
237
+ },
238
+ "useSocketioSupport": {
239
+ "type": "boolean"
240
+ },
241
+ "useCentrifugeSupport": {
242
+ "type": "boolean"
243
+ },
244
+ "useMittSupport": {
245
+ "type": "boolean"
246
+ },
247
+ "centrifugeChannel": {
248
+ "type": "string"
249
+ }
250
+ },
251
+ "additionalProperties": false,
252
+ "required": [
253
+ "key",
254
+ "name",
255
+ "value"
256
+ ],
257
+ "$schema": "http://json-schema.org/draft-07/schema#"
258
+ }
259
+ },
260
+ {
261
+ "card": "SecureStorageCard",
262
+ "data": {
263
+ "type": "object",
264
+ "properties": {
265
+ "name": {
266
+ "type": "string"
267
+ },
268
+ "key": {
269
+ "type": "string"
270
+ },
271
+ "value": {
272
+ "type": "string"
273
+ },
274
+ "useSocketioSupport": {
275
+ "type": "boolean"
276
+ },
277
+ "useCentrifugeSupport": {
278
+ "type": "boolean"
279
+ },
280
+ "useMittSupport": {
281
+ "type": "boolean"
282
+ },
283
+ "centrifugeChannel": {
284
+ "type": "string"
285
+ }
286
+ },
287
+ "additionalProperties": false,
288
+ "required": [
289
+ "key",
290
+ "name",
291
+ "value"
292
+ ],
293
+ "$schema": "http://json-schema.org/draft-07/schema#"
294
+ }
295
+ },
152
296
  {
153
297
  "card": "AjaxGroupCard",
154
298
  "data": {
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mittAgentTools.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mittAgentTools.test.d.ts","sourceRoot":"","sources":["../../src/tests/mittAgentTools.test.ts"],"names":[],"mappings":""}
@@ -1,5 +1,16 @@
1
1
  import '../types';
2
2
  import { SetUiAjaxConfigurationType } from '../types';
3
+ /**
4
+ * Retry policy configuration for AJAX requests.
5
+ */
6
+ export type RetryPolicy = {
7
+ /** Maximum number of retry attempts (default: 0 — no retries). */
8
+ maxRetries?: number;
9
+ /** Base delay in ms between retries (default: 1000). Doubled on each attempt. */
10
+ baseDelay?: number;
11
+ /** HTTP status codes that should trigger a retry (default: [502, 503, 504]). Timeouts and network errors always retry regardless of this list. */
12
+ retryOn?: number[];
13
+ };
3
14
  /**
4
15
  * Options for {@link getAjaxSubmit}. Passed explicitly so that the helper can
5
16
  * stay a plain function — callers forward the values they already obtained
@@ -10,6 +21,10 @@ export type GetAjaxSubmitOptions = {
10
21
  apiServer?: string | null;
11
22
  /** When `true`, the helper will log registration and error details. */
12
23
  renderingLogEnabled?: boolean;
24
+ /** Request timeout in milliseconds. No timeout if omitted. */
25
+ timeout?: number;
26
+ /** Retry policy for failed requests. No retries if omitted. */
27
+ retryPolicy?: RetryPolicy;
13
28
  };
14
29
  /**
15
30
  * Builds an async "submit" function that issues an AJAX request to
@@ -38,7 +53,7 @@ export type GetAjaxSubmitOptions = {
38
53
  * @param options See {@link GetAjaxSubmitOptions}.
39
54
  * @returns An `async (extraKwargs?) => Promise<any>` submit function.
40
55
  */
41
- export declare const getAjaxSubmit: (setUiAjaxConfiguration?: SetUiAjaxConfigurationType, kwargs?: Record<string, any>, depsNames?: Array<string>, pathname?: string, options?: GetAjaxSubmitOptions) => (() => void) | ((extraKwargs?: Record<string, any>) => Promise<any>);
56
+ export declare const getAjaxSubmit: (setUiAjaxConfiguration?: SetUiAjaxConfigurationType, kwargs?: Record<string, any>, depsNames?: Array<string>, pathname?: string, options?: GetAjaxSubmitOptions) => (extraKwargs?: Record<string, any>) => Promise<any>;
42
57
  /**
43
58
  * React hook wrapper around {@link getAjaxSubmit}. Reads `apiServer` and
44
59
  * `enableRenderingLog` from {@link usePieConfig} and memoizes the submit
@@ -51,7 +66,11 @@ export declare const getAjaxSubmit: (setUiAjaxConfiguration?: SetUiAjaxConfigura
51
66
  * @param depsNames Names of DOM inputs whose current values should
52
67
  * be sent alongside the request.
53
68
  * @param pathname Path segment appended to `api/ajax_content`.
69
+ * @param options Optional `timeout` (ms) and `retryPolicy`.
54
70
  * @returns A memoized submit function; see {@link getAjaxSubmit}.
55
71
  */
56
- export declare const useAjaxSubmit: (setUiAjaxConfiguration?: SetUiAjaxConfigurationType, kwargs?: Record<string, any>, depsNames?: Array<string>, pathname?: string) => (() => void) | ((extraKwargs?: Record<string, any>) => Promise<any>);
72
+ export declare const useAjaxSubmit: (setUiAjaxConfiguration?: SetUiAjaxConfigurationType, kwargs?: Record<string, any>, depsNames?: Array<string>, pathname?: string, options?: {
73
+ timeout?: number;
74
+ retryPolicy?: RetryPolicy;
75
+ }) => (extraKwargs?: Record<string, any>) => Promise<any>;
57
76
  //# sourceMappingURL=ajaxCommonUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ajaxCommonUtils.d.ts","sourceRoot":"","sources":["../../src/util/ajaxCommonUtils.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,CAAA;AACjB,OAAO,EAAE,0BAA0B,EAAe,MAAM,UAAU,CAAA;AAKlE;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAC/B,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,uEAAuE;IACvE,mBAAmB,CAAC,EAAE,OAAO,C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AACH,eAAO,MAAM,aAAa,GACtB,yBAAyB,0BAA0B,EACnD,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAChC,YAAW,KAAK,CAAC,MAAM,CAAM,EAC7B,WAAW,MAAM,EACjB,UAAU,oBAAoB,MAahB,cAAa,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,iBA6LtD,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GACtB,yBAAyB,0BAA0B,EACnD,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAChC,YAAW,KAAK,CAAC,MAAM,CAAM,EAC7B,WAAW,MAAM,EACjB,UAAU;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,oBAnN9B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,iBA+OjD,CAAA"}
@@ -0,0 +1,89 @@
1
+ import { tool } from '@openai/agents';
2
+ import type { Emitter } from 'mitt';
3
+ import { type MittEvents } from './mitt';
4
+ /**
5
+ * Descriptor passed to the customization callbacks on
6
+ * {@link MittAgentToolsOptions}.
7
+ */
8
+ export type MittAgentToolDescriptor = {
9
+ /** Method key originally registered on the `PieCard.methods` map. */
10
+ methodName: string;
11
+ /** Value of `data.name` on the target `PieCard`. */
12
+ cardName: string;
13
+ /** Raw mitt event name (`pie{methodName}_{cardName}`). */
14
+ eventName: string;
15
+ };
16
+ /**
17
+ * Options accepted by {@link getMittAgentTools} and
18
+ * {@link usePieMittAgentTools}.
19
+ */
20
+ export type MittAgentToolsOptions = {
21
+ /**
22
+ * Optional predicate invoked for each discovered PieCard method. Return
23
+ * `false` to omit the event from the generated tool list. Defaults to
24
+ * accepting everything.
25
+ */
26
+ filter?: (descriptor: MittAgentToolDescriptor) => boolean;
27
+ /**
28
+ * Optional override for the tool description surfaced to the model.
29
+ * Defaults to a generic string mentioning the card and method.
30
+ */
31
+ describe?: (descriptor: MittAgentToolDescriptor) => string;
32
+ /**
33
+ * Optional override for the public tool name. Defaults to
34
+ * `{cardName}_{methodName}`. The returned value must be unique within the
35
+ * final tool set.
36
+ */
37
+ nameFor?: (descriptor: MittAgentToolDescriptor) => string;
38
+ };
39
+ /**
40
+ * Return type of {@link getMittAgentTools}. We intentionally keep this loose
41
+ * rather than importing the deeply-parameterized `FunctionTool` generic from
42
+ * `@openai/agents-core` — callers typically feed the result directly into
43
+ * `new Agent({ tools: [...] })` which accepts any tool-shaped value.
44
+ */
45
+ export type MittAgentTool = ReturnType<typeof tool>;
46
+ /**
47
+ * Scans a mitt emitter for all currently-registered PieCard methods (events
48
+ * matching `pie{methodName}_{cardName}`) and wraps each one as an
49
+ * `@openai/agents` function tool.
50
+ *
51
+ * Calling a returned tool re-emits the matching mitt event with the
52
+ * `payload` argument supplied by the model. Because mitt listeners run
53
+ * synchronously in-process, the tool executes entirely locally with no
54
+ * network hop.
55
+ *
56
+ * This takes a *snapshot* of the emitter at the moment it is called — cards
57
+ * that mount afterwards will not be represented until the function is called
58
+ * again. Prefer {@link usePieMittAgentTools} from inside React components so
59
+ * the snapshot refreshes whenever the surrounding tree re-renders.
60
+ *
61
+ * @param emitter The mitt emitter to scan. Defaults to the global PieUI
62
+ * singleton returned by {@link getEmitter}.
63
+ * @param options See {@link MittAgentToolsOptions}.
64
+ * @returns An array of `@openai/agents` function tools, one per discovered
65
+ * PieCard method.
66
+ */
67
+ export declare function getMittAgentTools(emitter?: Emitter<MittEvents>, options?: MittAgentToolsOptions): MittAgentTool[];
68
+ /**
69
+ * React hook wrapper around {@link getMittAgentTools}. Reads the emitter from
70
+ * {@link MittContext} — falling back to the global singleton returned by
71
+ * {@link getEmitter} when used outside of a PieRoot — and memoizes the
72
+ * resulting tool array by a sorted snapshot of registered event names so the
73
+ * returned reference is stable across renders that don't add or remove
74
+ * PieCard methods.
75
+ *
76
+ * Because mitt does not emit a "handler-added" notification, the hook only
77
+ * refreshes its snapshot when the calling component re-renders. If you need
78
+ * to react to cards mounting at arbitrary times, trigger a re-render from the
79
+ * consumer or call {@link getMittAgentTools} imperatively right before you
80
+ * build the `Agent`.
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * const tools = usePieMittAgentTools()
85
+ * const agent = useMemo(() => new Agent({ name: 'UI', tools }), [tools])
86
+ * ```
87
+ */
88
+ export declare function usePieMittAgentTools(options?: MittAgentToolsOptions): MittAgentTool[];
89
+ //# sourceMappingURL=mittAgentTools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mittAgentTools.d.ts","sourceRoot":"","sources":["../../src/util/mittAgentTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAErC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAoB,EAAc,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAA;AAWjE;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAClC,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAA;IAClB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAA;IAChB,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAChC;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,OAAO,CAAA;IACzD;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,MAAM,CAAA;IAC1D;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,MAAM,CAAA;CAC5D,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAA;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC7B,OAAO,GAAE,OAAO,CAAC,UAAU,CAAgB,EAC3C,OAAO,GAAE,qBAA0B,GACpC,aAAa,EAAE,CAqDjB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,GAAE,qBAA0B,GACpC,aAAa,EAAE,CAsBjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piedata/pieui",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "A React component library featuring PieCard component",
5
5
  "repository": {
6
6
  "type": "git",