@almadar/std 1.0.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 +72 -0
- package/dist/behaviors/action-affinity.d.ts +88 -0
- package/dist/behaviors/action-affinity.js +290 -0
- package/dist/behaviors/action-affinity.js.map +1 -0
- package/dist/behaviors/async.d.ts +20 -0
- package/dist/behaviors/async.js +542 -0
- package/dist/behaviors/async.js.map +1 -0
- package/dist/behaviors/data-management.d.ts +40 -0
- package/dist/behaviors/data-management.js +495 -0
- package/dist/behaviors/data-management.js.map +1 -0
- package/dist/behaviors/feedback.d.ts +18 -0
- package/dist/behaviors/feedback.js +307 -0
- package/dist/behaviors/feedback.js.map +1 -0
- package/dist/behaviors/game-core.d.ts +40 -0
- package/dist/behaviors/game-core.js +443 -0
- package/dist/behaviors/game-core.js.map +1 -0
- package/dist/behaviors/game-entity.d.ts +39 -0
- package/dist/behaviors/game-entity.js +643 -0
- package/dist/behaviors/game-entity.js.map +1 -0
- package/dist/behaviors/game-ui.d.ts +29 -0
- package/dist/behaviors/game-ui.js +493 -0
- package/dist/behaviors/game-ui.js.map +1 -0
- package/dist/behaviors/index.d.ts +11 -0
- package/dist/behaviors/index.js +4539 -0
- package/dist/behaviors/index.js.map +1 -0
- package/dist/behaviors/registry.d.ts +103 -0
- package/dist/behaviors/registry.js +4166 -0
- package/dist/behaviors/registry.js.map +1 -0
- package/dist/behaviors/types.d.ts +179 -0
- package/dist/behaviors/types.js +111 -0
- package/dist/behaviors/types.js.map +1 -0
- package/dist/behaviors/ui-interaction.d.ts +36 -0
- package/dist/behaviors/ui-interaction.js +1104 -0
- package/dist/behaviors/ui-interaction.js.map +1 -0
- package/dist/index.d.ts +195 -0
- package/dist/index.js +8209 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/array.d.ts +28 -0
- package/dist/modules/array.js +556 -0
- package/dist/modules/array.js.map +1 -0
- package/dist/modules/async.d.ts +22 -0
- package/dist/modules/async.js +112 -0
- package/dist/modules/async.js.map +1 -0
- package/dist/modules/format.d.ts +21 -0
- package/dist/modules/format.js +129 -0
- package/dist/modules/format.js.map +1 -0
- package/dist/modules/index.d.ts +12 -0
- package/dist/modules/index.js +3131 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/math.d.ts +22 -0
- package/dist/modules/math.js +215 -0
- package/dist/modules/math.js.map +1 -0
- package/dist/modules/nn.d.ts +23 -0
- package/dist/modules/nn.js +189 -0
- package/dist/modules/nn.js.map +1 -0
- package/dist/modules/object.d.ts +22 -0
- package/dist/modules/object.js +257 -0
- package/dist/modules/object.js.map +1 -0
- package/dist/modules/str.d.ts +21 -0
- package/dist/modules/str.js +344 -0
- package/dist/modules/str.js.map +1 -0
- package/dist/modules/tensor.d.ts +23 -0
- package/dist/modules/tensor.js +427 -0
- package/dist/modules/tensor.js.map +1 -0
- package/dist/modules/time.d.ts +24 -0
- package/dist/modules/time.js +323 -0
- package/dist/modules/time.js.map +1 -0
- package/dist/modules/train.d.ts +23 -0
- package/dist/modules/train.js +308 -0
- package/dist/modules/train.js.map +1 -0
- package/dist/modules/validate.d.ts +23 -0
- package/dist/modules/validate.js +301 -0
- package/dist/modules/validate.js.map +1 -0
- package/dist/registry.d.ts +140 -0
- package/dist/registry.js +3240 -0
- package/dist/registry.js.map +1 -0
- package/dist/types-I95R8_FN.d.ts +91 -0
- package/package.json +59 -0
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
// behaviors/async.ts
|
|
2
|
+
var LOADING_BEHAVIOR = {
|
|
3
|
+
name: "std/Loading",
|
|
4
|
+
category: "async",
|
|
5
|
+
description: "Loading state management with success/error handling",
|
|
6
|
+
suggestedFor: [
|
|
7
|
+
"Async data loading",
|
|
8
|
+
"API calls",
|
|
9
|
+
"Resource fetching",
|
|
10
|
+
"Initial page load"
|
|
11
|
+
],
|
|
12
|
+
dataEntities: [
|
|
13
|
+
{
|
|
14
|
+
name: "LoadingState",
|
|
15
|
+
runtime: true,
|
|
16
|
+
singleton: true,
|
|
17
|
+
fields: [
|
|
18
|
+
{ name: "isLoading", type: "boolean", default: false },
|
|
19
|
+
{ name: "error", type: "object", default: null },
|
|
20
|
+
{ name: "data", type: "object", default: null },
|
|
21
|
+
{ name: "startTime", type: "number", default: null }
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
stateMachine: {
|
|
26
|
+
initial: "Idle",
|
|
27
|
+
states: [
|
|
28
|
+
{ name: "Idle", isInitial: true },
|
|
29
|
+
{ name: "Loading" },
|
|
30
|
+
{ name: "Success" },
|
|
31
|
+
{ name: "Error" }
|
|
32
|
+
],
|
|
33
|
+
events: [
|
|
34
|
+
{ key: "START" },
|
|
35
|
+
{ key: "SUCCESS" },
|
|
36
|
+
{ key: "ERROR" },
|
|
37
|
+
{ key: "RETRY" },
|
|
38
|
+
{ key: "RESET" }
|
|
39
|
+
],
|
|
40
|
+
transitions: [
|
|
41
|
+
{
|
|
42
|
+
from: "Idle",
|
|
43
|
+
to: "Loading",
|
|
44
|
+
event: "START",
|
|
45
|
+
effects: [
|
|
46
|
+
["set", "@entity.isLoading", true],
|
|
47
|
+
["set", "@entity.error", null],
|
|
48
|
+
["set", "@entity.startTime", ["time/now"]],
|
|
49
|
+
["render", "content", "loading-state", {}]
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
from: "Loading",
|
|
54
|
+
to: "Success",
|
|
55
|
+
event: "SUCCESS",
|
|
56
|
+
effects: [
|
|
57
|
+
["set", "@entity.isLoading", false],
|
|
58
|
+
["set", "@entity.data", "@payload.data"]
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
from: "Loading",
|
|
63
|
+
to: "Error",
|
|
64
|
+
event: "ERROR",
|
|
65
|
+
effects: [
|
|
66
|
+
["set", "@entity.isLoading", false],
|
|
67
|
+
["set", "@entity.error", "@payload.error"],
|
|
68
|
+
["render", "content", "error-state", {
|
|
69
|
+
error: "@entity.error",
|
|
70
|
+
onRetry: "RETRY"
|
|
71
|
+
}]
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
from: "Error",
|
|
76
|
+
to: "Loading",
|
|
77
|
+
event: "RETRY",
|
|
78
|
+
effects: [
|
|
79
|
+
["set", "@entity.isLoading", true],
|
|
80
|
+
["set", "@entity.error", null],
|
|
81
|
+
["set", "@entity.startTime", ["time/now"]],
|
|
82
|
+
["render", "content", "loading-state", {}]
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
from: ["Success", "Error"],
|
|
87
|
+
to: "Idle",
|
|
88
|
+
event: "RESET",
|
|
89
|
+
effects: [
|
|
90
|
+
["set", "@entity.isLoading", false],
|
|
91
|
+
["set", "@entity.error", null],
|
|
92
|
+
["set", "@entity.data", null]
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
configSchema: {
|
|
98
|
+
required: [],
|
|
99
|
+
optional: [
|
|
100
|
+
{ name: "showLoadingAfterMs", type: "number", description: "Delay before showing loading", default: 200 },
|
|
101
|
+
{ name: "minLoadingMs", type: "number", description: "Minimum loading display time", default: 500 }
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var FETCH_BEHAVIOR = {
|
|
106
|
+
name: "std/Fetch",
|
|
107
|
+
category: "async",
|
|
108
|
+
description: "Data fetching with caching and refresh capabilities",
|
|
109
|
+
suggestedFor: [
|
|
110
|
+
"API data fetching",
|
|
111
|
+
"Entity loading",
|
|
112
|
+
"Remote data",
|
|
113
|
+
"Cached queries"
|
|
114
|
+
],
|
|
115
|
+
dataEntities: [
|
|
116
|
+
{
|
|
117
|
+
name: "FetchState",
|
|
118
|
+
runtime: true,
|
|
119
|
+
singleton: true,
|
|
120
|
+
fields: [
|
|
121
|
+
{ name: "data", type: "object", default: null },
|
|
122
|
+
{ name: "error", type: "object", default: null },
|
|
123
|
+
{ name: "isFetching", type: "boolean", default: false },
|
|
124
|
+
{ name: "lastFetchedAt", type: "number", default: null }
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
stateMachine: {
|
|
129
|
+
initial: "Idle",
|
|
130
|
+
states: [
|
|
131
|
+
{ name: "Idle", isInitial: true },
|
|
132
|
+
{ name: "Fetching" },
|
|
133
|
+
{ name: "Stale" },
|
|
134
|
+
{ name: "Fresh" },
|
|
135
|
+
{ name: "Error" }
|
|
136
|
+
],
|
|
137
|
+
events: [
|
|
138
|
+
{ key: "FETCH" },
|
|
139
|
+
{ key: "FETCH_SUCCESS" },
|
|
140
|
+
{ key: "FETCH_ERROR" },
|
|
141
|
+
{ key: "REFRESH" },
|
|
142
|
+
{ key: "INVALIDATE" }
|
|
143
|
+
],
|
|
144
|
+
transitions: [
|
|
145
|
+
{
|
|
146
|
+
from: ["Idle", "Stale"],
|
|
147
|
+
to: "Fetching",
|
|
148
|
+
event: "FETCH",
|
|
149
|
+
effects: [
|
|
150
|
+
["set", "@entity.isFetching", true],
|
|
151
|
+
["set", "@entity.error", null]
|
|
152
|
+
]
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
from: "Fetching",
|
|
156
|
+
to: "Fresh",
|
|
157
|
+
event: "FETCH_SUCCESS",
|
|
158
|
+
effects: [
|
|
159
|
+
["set", "@entity.isFetching", false],
|
|
160
|
+
["set", "@entity.data", "@payload.data"],
|
|
161
|
+
["set", "@entity.lastFetchedAt", ["time/now"]]
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
from: "Fetching",
|
|
166
|
+
to: "Error",
|
|
167
|
+
event: "FETCH_ERROR",
|
|
168
|
+
effects: [
|
|
169
|
+
["set", "@entity.isFetching", false],
|
|
170
|
+
["set", "@entity.error", "@payload.error"]
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
from: "Fresh",
|
|
175
|
+
to: "Stale",
|
|
176
|
+
event: "INVALIDATE",
|
|
177
|
+
effects: [
|
|
178
|
+
["set", "@entity.lastFetchedAt", null]
|
|
179
|
+
]
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
from: ["Fresh", "Stale", "Error"],
|
|
183
|
+
to: "Fetching",
|
|
184
|
+
event: "REFRESH",
|
|
185
|
+
effects: [
|
|
186
|
+
["set", "@entity.isFetching", true],
|
|
187
|
+
["set", "@entity.error", null]
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
configSchema: {
|
|
193
|
+
required: [
|
|
194
|
+
{ name: "entity", type: "entity", description: "Entity type to fetch" }
|
|
195
|
+
],
|
|
196
|
+
optional: [
|
|
197
|
+
{ name: "staleTimeMs", type: "number", description: "Time until data is stale", default: 6e4 },
|
|
198
|
+
{ name: "cacheKey", type: "string", description: "Cache key for deduplication" }
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
var SUBMIT_BEHAVIOR = {
|
|
203
|
+
name: "std/Submit",
|
|
204
|
+
category: "async",
|
|
205
|
+
description: "Async submission with retry capabilities",
|
|
206
|
+
suggestedFor: [
|
|
207
|
+
"Form submission",
|
|
208
|
+
"Data saving",
|
|
209
|
+
"API mutations",
|
|
210
|
+
"Actions with confirmation"
|
|
211
|
+
],
|
|
212
|
+
dataEntities: [
|
|
213
|
+
{
|
|
214
|
+
name: "SubmitState",
|
|
215
|
+
runtime: true,
|
|
216
|
+
singleton: true,
|
|
217
|
+
fields: [
|
|
218
|
+
{ name: "isSubmitting", type: "boolean", default: false },
|
|
219
|
+
{ name: "error", type: "object", default: null },
|
|
220
|
+
{ name: "lastSubmittedData", type: "object", default: null }
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
],
|
|
224
|
+
stateMachine: {
|
|
225
|
+
initial: "Idle",
|
|
226
|
+
states: [
|
|
227
|
+
{ name: "Idle", isInitial: true },
|
|
228
|
+
{ name: "Submitting" },
|
|
229
|
+
{ name: "Success" },
|
|
230
|
+
{ name: "Error" }
|
|
231
|
+
],
|
|
232
|
+
events: [
|
|
233
|
+
{ key: "SUBMIT" },
|
|
234
|
+
{ key: "SUBMIT_SUCCESS" },
|
|
235
|
+
{ key: "SUBMIT_ERROR" },
|
|
236
|
+
{ key: "RETRY" },
|
|
237
|
+
{ key: "RESET" }
|
|
238
|
+
],
|
|
239
|
+
transitions: [
|
|
240
|
+
{
|
|
241
|
+
from: "Idle",
|
|
242
|
+
to: "Submitting",
|
|
243
|
+
event: "SUBMIT",
|
|
244
|
+
effects: [
|
|
245
|
+
["set", "@entity.isSubmitting", true],
|
|
246
|
+
["set", "@entity.error", null],
|
|
247
|
+
["set", "@entity.lastSubmittedData", "@payload.data"]
|
|
248
|
+
]
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
from: "Submitting",
|
|
252
|
+
to: "Success",
|
|
253
|
+
event: "SUBMIT_SUCCESS",
|
|
254
|
+
effects: [
|
|
255
|
+
["set", "@entity.isSubmitting", false],
|
|
256
|
+
["notify", { type: "success", message: "@config.successMessage" }],
|
|
257
|
+
["when", "@config.resetOnSuccess", ["emit", "RESET"]]
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
from: "Submitting",
|
|
262
|
+
to: "Error",
|
|
263
|
+
event: "SUBMIT_ERROR",
|
|
264
|
+
effects: [
|
|
265
|
+
["set", "@entity.isSubmitting", false],
|
|
266
|
+
["set", "@entity.error", "@payload.error"],
|
|
267
|
+
["notify", { type: "error", message: "@config.errorMessage" }]
|
|
268
|
+
]
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
from: "Error",
|
|
272
|
+
to: "Submitting",
|
|
273
|
+
event: "RETRY",
|
|
274
|
+
effects: [
|
|
275
|
+
["set", "@entity.isSubmitting", true],
|
|
276
|
+
["set", "@entity.error", null]
|
|
277
|
+
]
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
from: ["Success", "Error"],
|
|
281
|
+
to: "Idle",
|
|
282
|
+
event: "RESET",
|
|
283
|
+
effects: [
|
|
284
|
+
["set", "@entity.isSubmitting", false],
|
|
285
|
+
["set", "@entity.error", null],
|
|
286
|
+
["set", "@entity.lastSubmittedData", null]
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
},
|
|
291
|
+
configSchema: {
|
|
292
|
+
required: [],
|
|
293
|
+
optional: [
|
|
294
|
+
{ name: "successMessage", type: "string", description: "Success notification", default: "Saved successfully" },
|
|
295
|
+
{ name: "errorMessage", type: "string", description: "Error notification", default: "Failed to save" },
|
|
296
|
+
{ name: "resetOnSuccess", type: "boolean", description: "Reset to idle on success", default: false }
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
var RETRY_BEHAVIOR = {
|
|
301
|
+
name: "std/Retry",
|
|
302
|
+
category: "async",
|
|
303
|
+
description: "Automatic retry with exponential backoff",
|
|
304
|
+
suggestedFor: [
|
|
305
|
+
"Network requests",
|
|
306
|
+
"Unreliable operations",
|
|
307
|
+
"Transient failures",
|
|
308
|
+
"Recovery logic"
|
|
309
|
+
],
|
|
310
|
+
dataEntities: [
|
|
311
|
+
{
|
|
312
|
+
name: "RetryState",
|
|
313
|
+
runtime: true,
|
|
314
|
+
singleton: true,
|
|
315
|
+
fields: [
|
|
316
|
+
{ name: "attempt", type: "number", default: 0 },
|
|
317
|
+
{ name: "error", type: "object", default: null },
|
|
318
|
+
{ name: "nextRetryAt", type: "number", default: null }
|
|
319
|
+
]
|
|
320
|
+
}
|
|
321
|
+
],
|
|
322
|
+
stateMachine: {
|
|
323
|
+
initial: "Idle",
|
|
324
|
+
states: [
|
|
325
|
+
{ name: "Idle", isInitial: true },
|
|
326
|
+
{ name: "Attempting" },
|
|
327
|
+
{ name: "Waiting" },
|
|
328
|
+
{ name: "Success" },
|
|
329
|
+
{ name: "Failed" }
|
|
330
|
+
],
|
|
331
|
+
events: [
|
|
332
|
+
{ key: "START" },
|
|
333
|
+
{ key: "ATTEMPT_SUCCESS" },
|
|
334
|
+
{ key: "ATTEMPT_ERROR" },
|
|
335
|
+
{ key: "RETRY_TICK" },
|
|
336
|
+
{ key: "GIVE_UP" },
|
|
337
|
+
{ key: "RESET" }
|
|
338
|
+
],
|
|
339
|
+
transitions: [
|
|
340
|
+
{
|
|
341
|
+
from: "Idle",
|
|
342
|
+
to: "Attempting",
|
|
343
|
+
event: "START",
|
|
344
|
+
effects: [
|
|
345
|
+
["set", "@entity.attempt", 1],
|
|
346
|
+
["set", "@entity.error", null]
|
|
347
|
+
]
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
from: "Attempting",
|
|
351
|
+
to: "Success",
|
|
352
|
+
event: "ATTEMPT_SUCCESS",
|
|
353
|
+
effects: []
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
from: "Attempting",
|
|
357
|
+
to: "Waiting",
|
|
358
|
+
event: "ATTEMPT_ERROR",
|
|
359
|
+
guard: ["<", "@entity.attempt", "@config.maxAttempts"],
|
|
360
|
+
effects: [
|
|
361
|
+
["set", "@entity.error", "@payload.error"],
|
|
362
|
+
[
|
|
363
|
+
"let",
|
|
364
|
+
[["delay", [
|
|
365
|
+
"math/min",
|
|
366
|
+
["*", "@config.initialDelayMs", ["math/pow", "@config.backoffMultiplier", "@entity.attempt"]],
|
|
367
|
+
"@config.maxDelayMs"
|
|
368
|
+
]]],
|
|
369
|
+
["set", "@entity.nextRetryAt", ["+", ["time/now"], "@delay"]],
|
|
370
|
+
["async/delay", "@delay", ["emit", "RETRY_TICK"]]
|
|
371
|
+
]
|
|
372
|
+
]
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
from: "Attempting",
|
|
376
|
+
to: "Failed",
|
|
377
|
+
event: "ATTEMPT_ERROR",
|
|
378
|
+
guard: [">=", "@entity.attempt", "@config.maxAttempts"],
|
|
379
|
+
effects: [
|
|
380
|
+
["set", "@entity.error", "@payload.error"],
|
|
381
|
+
["notify", { type: "error", message: "All retry attempts failed" }]
|
|
382
|
+
]
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
from: "Waiting",
|
|
386
|
+
to: "Attempting",
|
|
387
|
+
event: "RETRY_TICK",
|
|
388
|
+
effects: [
|
|
389
|
+
["set", "@entity.attempt", ["+", "@entity.attempt", 1]]
|
|
390
|
+
]
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
from: "Waiting",
|
|
394
|
+
to: "Failed",
|
|
395
|
+
event: "GIVE_UP",
|
|
396
|
+
effects: [
|
|
397
|
+
["notify", { type: "warning", message: "Retry cancelled" }]
|
|
398
|
+
]
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
from: ["Success", "Failed"],
|
|
402
|
+
to: "Idle",
|
|
403
|
+
event: "RESET",
|
|
404
|
+
effects: [
|
|
405
|
+
["set", "@entity.attempt", 0],
|
|
406
|
+
["set", "@entity.error", null],
|
|
407
|
+
["set", "@entity.nextRetryAt", null]
|
|
408
|
+
]
|
|
409
|
+
}
|
|
410
|
+
]
|
|
411
|
+
},
|
|
412
|
+
configSchema: {
|
|
413
|
+
required: [],
|
|
414
|
+
optional: [
|
|
415
|
+
{ name: "maxAttempts", type: "number", description: "Maximum retry attempts", default: 3 },
|
|
416
|
+
{ name: "initialDelayMs", type: "number", description: "Initial retry delay", default: 1e3 },
|
|
417
|
+
{ name: "maxDelayMs", type: "number", description: "Maximum retry delay", default: 3e4 },
|
|
418
|
+
{ name: "backoffMultiplier", type: "number", description: "Backoff multiplier", default: 2 }
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
var POLL_BEHAVIOR = {
|
|
423
|
+
name: "std/Poll",
|
|
424
|
+
category: "async",
|
|
425
|
+
description: "Periodic polling with start/stop control",
|
|
426
|
+
suggestedFor: [
|
|
427
|
+
"Real-time updates",
|
|
428
|
+
"Status checking",
|
|
429
|
+
"Live data",
|
|
430
|
+
"Notification polling"
|
|
431
|
+
],
|
|
432
|
+
dataEntities: [
|
|
433
|
+
{
|
|
434
|
+
name: "PollState",
|
|
435
|
+
runtime: true,
|
|
436
|
+
singleton: true,
|
|
437
|
+
fields: [
|
|
438
|
+
{ name: "isPolling", type: "boolean", default: false },
|
|
439
|
+
{ name: "pollCount", type: "number", default: 0 },
|
|
440
|
+
{ name: "lastPollAt", type: "number", default: null },
|
|
441
|
+
{ name: "error", type: "object", default: null }
|
|
442
|
+
]
|
|
443
|
+
}
|
|
444
|
+
],
|
|
445
|
+
stateMachine: {
|
|
446
|
+
initial: "Stopped",
|
|
447
|
+
states: [
|
|
448
|
+
{ name: "Stopped", isInitial: true },
|
|
449
|
+
{ name: "Polling" },
|
|
450
|
+
{ name: "Paused" }
|
|
451
|
+
],
|
|
452
|
+
events: [
|
|
453
|
+
{ key: "START" },
|
|
454
|
+
{ key: "STOP" },
|
|
455
|
+
{ key: "PAUSE" },
|
|
456
|
+
{ key: "RESUME" },
|
|
457
|
+
{ key: "POLL_TICK" },
|
|
458
|
+
{ key: "POLL_SUCCESS" },
|
|
459
|
+
{ key: "POLL_ERROR" }
|
|
460
|
+
],
|
|
461
|
+
transitions: [
|
|
462
|
+
{
|
|
463
|
+
from: "Stopped",
|
|
464
|
+
to: "Polling",
|
|
465
|
+
event: "START",
|
|
466
|
+
effects: [
|
|
467
|
+
["set", "@entity.isPolling", true],
|
|
468
|
+
["set", "@entity.pollCount", 0],
|
|
469
|
+
["async/interval", "@config.intervalMs", ["emit", "POLL_TICK"]]
|
|
470
|
+
]
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
from: "Polling",
|
|
474
|
+
event: "POLL_TICK",
|
|
475
|
+
guard: ["or", ["=", "@config.maxPolls", null], ["<", "@entity.pollCount", "@config.maxPolls"]],
|
|
476
|
+
effects: [
|
|
477
|
+
["set", "@entity.lastPollAt", ["time/now"]]
|
|
478
|
+
]
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
from: "Polling",
|
|
482
|
+
event: "POLL_SUCCESS",
|
|
483
|
+
effects: [
|
|
484
|
+
["set", "@entity.pollCount", ["+", "@entity.pollCount", 1]],
|
|
485
|
+
["set", "@entity.error", null]
|
|
486
|
+
]
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
from: "Polling",
|
|
490
|
+
event: "POLL_ERROR",
|
|
491
|
+
effects: [
|
|
492
|
+
["set", "@entity.error", "@payload.error"],
|
|
493
|
+
["when", "@config.stopOnError", ["emit", "STOP"]]
|
|
494
|
+
]
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
from: "Polling",
|
|
498
|
+
to: "Paused",
|
|
499
|
+
event: "PAUSE",
|
|
500
|
+
effects: [
|
|
501
|
+
["set", "@entity.isPolling", false]
|
|
502
|
+
]
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
from: "Paused",
|
|
506
|
+
to: "Polling",
|
|
507
|
+
event: "RESUME",
|
|
508
|
+
effects: [
|
|
509
|
+
["set", "@entity.isPolling", true],
|
|
510
|
+
["async/interval", "@config.intervalMs", ["emit", "POLL_TICK"]]
|
|
511
|
+
]
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
from: ["Polling", "Paused"],
|
|
515
|
+
to: "Stopped",
|
|
516
|
+
event: "STOP",
|
|
517
|
+
effects: [
|
|
518
|
+
["set", "@entity.isPolling", false]
|
|
519
|
+
]
|
|
520
|
+
}
|
|
521
|
+
]
|
|
522
|
+
},
|
|
523
|
+
configSchema: {
|
|
524
|
+
required: [],
|
|
525
|
+
optional: [
|
|
526
|
+
{ name: "intervalMs", type: "number", description: "Poll interval in ms", default: 5e3 },
|
|
527
|
+
{ name: "stopOnError", type: "boolean", description: "Stop polling on error", default: false },
|
|
528
|
+
{ name: "maxPolls", type: "number", description: "Maximum poll count (null = infinite)", default: null }
|
|
529
|
+
]
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
var ASYNC_BEHAVIORS = [
|
|
533
|
+
LOADING_BEHAVIOR,
|
|
534
|
+
FETCH_BEHAVIOR,
|
|
535
|
+
SUBMIT_BEHAVIOR,
|
|
536
|
+
RETRY_BEHAVIOR,
|
|
537
|
+
POLL_BEHAVIOR
|
|
538
|
+
];
|
|
539
|
+
|
|
540
|
+
export { ASYNC_BEHAVIORS, FETCH_BEHAVIOR, LOADING_BEHAVIOR, POLL_BEHAVIOR, RETRY_BEHAVIOR, SUBMIT_BEHAVIOR };
|
|
541
|
+
//# sourceMappingURL=async.js.map
|
|
542
|
+
//# sourceMappingURL=async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../behaviors/async.ts"],"names":[],"mappings":";AAeO,IAAM,gBAAA,GAAqC;AAAA,EAChD,IAAA,EAAM,aAAA;AAAA,EACN,QAAA,EAAU,OAAA;AAAA,EACV,WAAA,EAAa,sDAAA;AAAA,EACb,YAAA,EAAc;AAAA,IACZ,oBAAA;AAAA,IACA,WAAA;AAAA,IACA,mBAAA;AAAA,IACA;AAAA,GACF;AAAA,EAEA,YAAA,EAAc;AAAA,IACZ;AAAA,MACE,IAAA,EAAM,cAAA;AAAA,MACN,OAAA,EAAS,IAAA;AAAA,MACT,SAAA,EAAW,IAAA;AAAA,MACX,MAAA,EAAQ;AAAA,QACN,EAAE,IAAA,EAAM,WAAA,EAAa,IAAA,EAAM,SAAA,EAAW,SAAS,KAAA,EAAM;AAAA,QACrD,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,QAAA,EAAU,SAAS,IAAA,EAAK;AAAA,QAC/C,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,QAAA,EAAU,SAAS,IAAA,EAAK;AAAA,QAC9C,EAAE,IAAA,EAAM,WAAA,EAAa,IAAA,EAAM,QAAA,EAAU,SAAS,IAAA;AAAK;AACrD;AACF,GACF;AAAA,EAEA,YAAA,EAAc;AAAA,IACZ,OAAA,EAAS,MAAA;AAAA,IACT,MAAA,EAAQ;AAAA,MACN,EAAE,IAAA,EAAM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F;AAAA,MACA;AAAA,QACE,IAAA,EAAM,QAAA;AAAA,QACN,EAAA,EAAI,SAAA;AAAA,QACJ,KAAA,EAAO,QAAA;AAAA,QACP,OAAA,EAAS;AAAA,UACP,CAAC,KAAA,EAAO,mBAAA,EAAqB,IAAI,CAAA;AAAA,UACjC,CAAC,gBAAA,EAAkB,oBAAA,EAAsB,CAAC,MAAA,EAAQ,WAAW,CAAC;AAAA;AAChE,OACF;AAAA,MACA;AAAA,QACE,IAAA,EAAM,CAAC,SAAA,EAAW,QAAQ,CAAA;AAAA,QAC1B,EAAA,EAAI,SAAA;AAAA,QACJ,KAAA,EAAO,MAAA;AAAA,QACP,OAAA,EAAS;AAAA,UACP,CAAC,KAAA,EAAO,mBAAA,EAAqB,KAAK;AAAA;AACpC;AACF;AACF,GACF;AAAA,EAEA,YAAA,EAAc;AAAA,IACZ,UAAU,EAAC;AAAA,IACX,QAAA,EAAU;AAAA,MACR,EAAE,MAAM,YAAA,EAAc,IAAA,EAAM,UAAU,WAAA,EAAa,qBAAA,EAAuB,SAAS,GAAA,EAAK;AAAA,MACxF,EAAE,MAAM,aAAA,EAAe,IAAA,EAAM,WAAW,WAAA,EAAa,uBAAA,EAAyB,SAAS,KAAA,EAAM;AAAA,MAC7F,EAAE,MAAM,UAAA,EAAY,IAAA,EAAM,UAAU,WAAA,EAAa,sCAAA,EAAwC,SAAS,IAAA;AAAK;AACzG;AAEJ;AAMO,IAAM,eAAA,GAAsC;AAAA,EACjD,gBAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF","file":"async.js","sourcesContent":["/**\n * Async Behaviors\n *\n * Standard behaviors for asynchronous operations like loading,\n * fetching, submission, retry, and polling.\n *\n * @packageDocumentation\n */\n\nimport type { StandardBehavior } from './types.js';\n\n// ============================================================================\n// std/Loading - Loading State Management\n// ============================================================================\n\nexport const LOADING_BEHAVIOR: StandardBehavior = {\n name: 'std/Loading',\n category: 'async',\n description: 'Loading state management with success/error handling',\n suggestedFor: [\n 'Async data loading',\n 'API calls',\n 'Resource fetching',\n 'Initial page load',\n ],\n\n dataEntities: [\n {\n name: 'LoadingState',\n runtime: true,\n singleton: true,\n fields: [\n { name: 'isLoading', type: 'boolean', default: false },\n { name: 'error', type: 'object', default: null },\n { name: 'data', type: 'object', default: null },\n { name: 'startTime', type: 'number', default: null },\n ],\n },\n ],\n\n stateMachine: {\n initial: 'Idle',\n states: [\n { name: 'Idle', isInitial: true },\n { name: 'Loading' },\n { name: 'Success' },\n { name: 'Error' },\n ],\n events: [\n { key: 'START' },\n { key: 'SUCCESS' },\n { key: 'ERROR' },\n { key: 'RETRY' },\n { key: 'RESET' },\n ],\n transitions: [\n {\n from: 'Idle',\n to: 'Loading',\n event: 'START',\n effects: [\n ['set', '@entity.isLoading', true],\n ['set', '@entity.error', null],\n ['set', '@entity.startTime', ['time/now']],\n ['render', 'content', 'loading-state', {}],\n ],\n },\n {\n from: 'Loading',\n to: 'Success',\n event: 'SUCCESS',\n effects: [\n ['set', '@entity.isLoading', false],\n ['set', '@entity.data', '@payload.data'],\n ],\n },\n {\n from: 'Loading',\n to: 'Error',\n event: 'ERROR',\n effects: [\n ['set', '@entity.isLoading', false],\n ['set', '@entity.error', '@payload.error'],\n ['render', 'content', 'error-state', {\n error: '@entity.error',\n onRetry: 'RETRY',\n }],\n ],\n },\n {\n from: 'Error',\n to: 'Loading',\n event: 'RETRY',\n effects: [\n ['set', '@entity.isLoading', true],\n ['set', '@entity.error', null],\n ['set', '@entity.startTime', ['time/now']],\n ['render', 'content', 'loading-state', {}],\n ],\n },\n {\n from: ['Success', 'Error'],\n to: 'Idle',\n event: 'RESET',\n effects: [\n ['set', '@entity.isLoading', false],\n ['set', '@entity.error', null],\n ['set', '@entity.data', null],\n ],\n },\n ],\n },\n\n configSchema: {\n required: [],\n optional: [\n { name: 'showLoadingAfterMs', type: 'number', description: 'Delay before showing loading', default: 200 },\n { name: 'minLoadingMs', type: 'number', description: 'Minimum loading display time', default: 500 },\n ],\n },\n};\n\n// ============================================================================\n// std/Fetch - Data Fetching\n// ============================================================================\n\nexport const FETCH_BEHAVIOR: StandardBehavior = {\n name: 'std/Fetch',\n category: 'async',\n description: 'Data fetching with caching and refresh capabilities',\n suggestedFor: [\n 'API data fetching',\n 'Entity loading',\n 'Remote data',\n 'Cached queries',\n ],\n\n dataEntities: [\n {\n name: 'FetchState',\n runtime: true,\n singleton: true,\n fields: [\n { name: 'data', type: 'object', default: null },\n { name: 'error', type: 'object', default: null },\n { name: 'isFetching', type: 'boolean', default: false },\n { name: 'lastFetchedAt', type: 'number', default: null },\n ],\n },\n ],\n\n stateMachine: {\n initial: 'Idle',\n states: [\n { name: 'Idle', isInitial: true },\n { name: 'Fetching' },\n { name: 'Stale' },\n { name: 'Fresh' },\n { name: 'Error' },\n ],\n events: [\n { key: 'FETCH' },\n { key: 'FETCH_SUCCESS' },\n { key: 'FETCH_ERROR' },\n { key: 'REFRESH' },\n { key: 'INVALIDATE' },\n ],\n transitions: [\n {\n from: ['Idle', 'Stale'],\n to: 'Fetching',\n event: 'FETCH',\n effects: [\n ['set', '@entity.isFetching', true],\n ['set', '@entity.error', null],\n ],\n },\n {\n from: 'Fetching',\n to: 'Fresh',\n event: 'FETCH_SUCCESS',\n effects: [\n ['set', '@entity.isFetching', false],\n ['set', '@entity.data', '@payload.data'],\n ['set', '@entity.lastFetchedAt', ['time/now']],\n ],\n },\n {\n from: 'Fetching',\n to: 'Error',\n event: 'FETCH_ERROR',\n effects: [\n ['set', '@entity.isFetching', false],\n ['set', '@entity.error', '@payload.error'],\n ],\n },\n {\n from: 'Fresh',\n to: 'Stale',\n event: 'INVALIDATE',\n effects: [\n ['set', '@entity.lastFetchedAt', null],\n ],\n },\n {\n from: ['Fresh', 'Stale', 'Error'],\n to: 'Fetching',\n event: 'REFRESH',\n effects: [\n ['set', '@entity.isFetching', true],\n ['set', '@entity.error', null],\n ],\n },\n ],\n },\n\n configSchema: {\n required: [\n { name: 'entity', type: 'entity', description: 'Entity type to fetch' },\n ],\n optional: [\n { name: 'staleTimeMs', type: 'number', description: 'Time until data is stale', default: 60000 },\n { name: 'cacheKey', type: 'string', description: 'Cache key for deduplication' },\n ],\n },\n};\n\n// ============================================================================\n// std/Submit - Form Submission\n// ============================================================================\n\nexport const SUBMIT_BEHAVIOR: StandardBehavior = {\n name: 'std/Submit',\n category: 'async',\n description: 'Async submission with retry capabilities',\n suggestedFor: [\n 'Form submission',\n 'Data saving',\n 'API mutations',\n 'Actions with confirmation',\n ],\n\n dataEntities: [\n {\n name: 'SubmitState',\n runtime: true,\n singleton: true,\n fields: [\n { name: 'isSubmitting', type: 'boolean', default: false },\n { name: 'error', type: 'object', default: null },\n { name: 'lastSubmittedData', type: 'object', default: null },\n ],\n },\n ],\n\n stateMachine: {\n initial: 'Idle',\n states: [\n { name: 'Idle', isInitial: true },\n { name: 'Submitting' },\n { name: 'Success' },\n { name: 'Error' },\n ],\n events: [\n { key: 'SUBMIT' },\n { key: 'SUBMIT_SUCCESS' },\n { key: 'SUBMIT_ERROR' },\n { key: 'RETRY' },\n { key: 'RESET' },\n ],\n transitions: [\n {\n from: 'Idle',\n to: 'Submitting',\n event: 'SUBMIT',\n effects: [\n ['set', '@entity.isSubmitting', true],\n ['set', '@entity.error', null],\n ['set', '@entity.lastSubmittedData', '@payload.data'],\n ],\n },\n {\n from: 'Submitting',\n to: 'Success',\n event: 'SUBMIT_SUCCESS',\n effects: [\n ['set', '@entity.isSubmitting', false],\n ['notify', { type: 'success', message: '@config.successMessage' }],\n ['when', '@config.resetOnSuccess', ['emit', 'RESET']],\n ],\n },\n {\n from: 'Submitting',\n to: 'Error',\n event: 'SUBMIT_ERROR',\n effects: [\n ['set', '@entity.isSubmitting', false],\n ['set', '@entity.error', '@payload.error'],\n ['notify', { type: 'error', message: '@config.errorMessage' }],\n ],\n },\n {\n from: 'Error',\n to: 'Submitting',\n event: 'RETRY',\n effects: [\n ['set', '@entity.isSubmitting', true],\n ['set', '@entity.error', null],\n ],\n },\n {\n from: ['Success', 'Error'],\n to: 'Idle',\n event: 'RESET',\n effects: [\n ['set', '@entity.isSubmitting', false],\n ['set', '@entity.error', null],\n ['set', '@entity.lastSubmittedData', null],\n ],\n },\n ],\n },\n\n configSchema: {\n required: [],\n optional: [\n { name: 'successMessage', type: 'string', description: 'Success notification', default: 'Saved successfully' },\n { name: 'errorMessage', type: 'string', description: 'Error notification', default: 'Failed to save' },\n { name: 'resetOnSuccess', type: 'boolean', description: 'Reset to idle on success', default: false },\n ],\n },\n};\n\n// ============================================================================\n// std/Retry - Automatic Retry\n// ============================================================================\n\nexport const RETRY_BEHAVIOR: StandardBehavior = {\n name: 'std/Retry',\n category: 'async',\n description: 'Automatic retry with exponential backoff',\n suggestedFor: [\n 'Network requests',\n 'Unreliable operations',\n 'Transient failures',\n 'Recovery logic',\n ],\n\n dataEntities: [\n {\n name: 'RetryState',\n runtime: true,\n singleton: true,\n fields: [\n { name: 'attempt', type: 'number', default: 0 },\n { name: 'error', type: 'object', default: null },\n { name: 'nextRetryAt', type: 'number', default: null },\n ],\n },\n ],\n\n stateMachine: {\n initial: 'Idle',\n states: [\n { name: 'Idle', isInitial: true },\n { name: 'Attempting' },\n { name: 'Waiting' },\n { name: 'Success' },\n { name: 'Failed' },\n ],\n events: [\n { key: 'START' },\n { key: 'ATTEMPT_SUCCESS' },\n { key: 'ATTEMPT_ERROR' },\n { key: 'RETRY_TICK' },\n { key: 'GIVE_UP' },\n { key: 'RESET' },\n ],\n transitions: [\n {\n from: 'Idle',\n to: 'Attempting',\n event: 'START',\n effects: [\n ['set', '@entity.attempt', 1],\n ['set', '@entity.error', null],\n ],\n },\n {\n from: 'Attempting',\n to: 'Success',\n event: 'ATTEMPT_SUCCESS',\n effects: [],\n },\n {\n from: 'Attempting',\n to: 'Waiting',\n event: 'ATTEMPT_ERROR',\n guard: ['<', '@entity.attempt', '@config.maxAttempts'],\n effects: [\n ['set', '@entity.error', '@payload.error'],\n ['let', [['delay', ['math/min',\n ['*', '@config.initialDelayMs', ['math/pow', '@config.backoffMultiplier', '@entity.attempt']],\n '@config.maxDelayMs']]],\n ['set', '@entity.nextRetryAt', ['+', ['time/now'], '@delay']],\n ['async/delay', '@delay', ['emit', 'RETRY_TICK']]],\n ],\n },\n {\n from: 'Attempting',\n to: 'Failed',\n event: 'ATTEMPT_ERROR',\n guard: ['>=', '@entity.attempt', '@config.maxAttempts'],\n effects: [\n ['set', '@entity.error', '@payload.error'],\n ['notify', { type: 'error', message: 'All retry attempts failed' }],\n ],\n },\n {\n from: 'Waiting',\n to: 'Attempting',\n event: 'RETRY_TICK',\n effects: [\n ['set', '@entity.attempt', ['+', '@entity.attempt', 1]],\n ],\n },\n {\n from: 'Waiting',\n to: 'Failed',\n event: 'GIVE_UP',\n effects: [\n ['notify', { type: 'warning', message: 'Retry cancelled' }],\n ],\n },\n {\n from: ['Success', 'Failed'],\n to: 'Idle',\n event: 'RESET',\n effects: [\n ['set', '@entity.attempt', 0],\n ['set', '@entity.error', null],\n ['set', '@entity.nextRetryAt', null],\n ],\n },\n ],\n },\n\n configSchema: {\n required: [],\n optional: [\n { name: 'maxAttempts', type: 'number', description: 'Maximum retry attempts', default: 3 },\n { name: 'initialDelayMs', type: 'number', description: 'Initial retry delay', default: 1000 },\n { name: 'maxDelayMs', type: 'number', description: 'Maximum retry delay', default: 30000 },\n { name: 'backoffMultiplier', type: 'number', description: 'Backoff multiplier', default: 2 },\n ],\n },\n};\n\n// ============================================================================\n// std/Poll - Periodic Polling\n// ============================================================================\n\nexport const POLL_BEHAVIOR: StandardBehavior = {\n name: 'std/Poll',\n category: 'async',\n description: 'Periodic polling with start/stop control',\n suggestedFor: [\n 'Real-time updates',\n 'Status checking',\n 'Live data',\n 'Notification polling',\n ],\n\n dataEntities: [\n {\n name: 'PollState',\n runtime: true,\n singleton: true,\n fields: [\n { name: 'isPolling', type: 'boolean', default: false },\n { name: 'pollCount', type: 'number', default: 0 },\n { name: 'lastPollAt', type: 'number', default: null },\n { name: 'error', type: 'object', default: null },\n ],\n },\n ],\n\n stateMachine: {\n initial: 'Stopped',\n states: [\n { name: 'Stopped', isInitial: true },\n { name: 'Polling' },\n { name: 'Paused' },\n ],\n events: [\n { key: 'START' },\n { key: 'STOP' },\n { key: 'PAUSE' },\n { key: 'RESUME' },\n { key: 'POLL_TICK' },\n { key: 'POLL_SUCCESS' },\n { key: 'POLL_ERROR' },\n ],\n transitions: [\n {\n from: 'Stopped',\n to: 'Polling',\n event: 'START',\n effects: [\n ['set', '@entity.isPolling', true],\n ['set', '@entity.pollCount', 0],\n ['async/interval', '@config.intervalMs', ['emit', 'POLL_TICK']],\n ],\n },\n {\n from: 'Polling',\n event: 'POLL_TICK',\n guard: ['or', ['=', '@config.maxPolls', null], ['<', '@entity.pollCount', '@config.maxPolls']],\n effects: [\n ['set', '@entity.lastPollAt', ['time/now']],\n ],\n },\n {\n from: 'Polling',\n event: 'POLL_SUCCESS',\n effects: [\n ['set', '@entity.pollCount', ['+', '@entity.pollCount', 1]],\n ['set', '@entity.error', null],\n ],\n },\n {\n from: 'Polling',\n event: 'POLL_ERROR',\n effects: [\n ['set', '@entity.error', '@payload.error'],\n ['when', '@config.stopOnError', ['emit', 'STOP']],\n ],\n },\n {\n from: 'Polling',\n to: 'Paused',\n event: 'PAUSE',\n effects: [\n ['set', '@entity.isPolling', false],\n ],\n },\n {\n from: 'Paused',\n to: 'Polling',\n event: 'RESUME',\n effects: [\n ['set', '@entity.isPolling', true],\n ['async/interval', '@config.intervalMs', ['emit', 'POLL_TICK']],\n ],\n },\n {\n from: ['Polling', 'Paused'],\n to: 'Stopped',\n event: 'STOP',\n effects: [\n ['set', '@entity.isPolling', false],\n ],\n },\n ],\n },\n\n configSchema: {\n required: [],\n optional: [\n { name: 'intervalMs', type: 'number', description: 'Poll interval in ms', default: 5000 },\n { name: 'stopOnError', type: 'boolean', description: 'Stop polling on error', default: false },\n { name: 'maxPolls', type: 'number', description: 'Maximum poll count (null = infinite)', default: null },\n ],\n },\n};\n\n// ============================================================================\n// Export All Async Behaviors\n// ============================================================================\n\nexport const ASYNC_BEHAVIORS: StandardBehavior[] = [\n LOADING_BEHAVIOR,\n FETCH_BEHAVIOR,\n SUBMIT_BEHAVIOR,\n RETRY_BEHAVIOR,\n POLL_BEHAVIOR,\n];\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { StandardBehavior } from './types.js';
|
|
2
|
+
import '@almadar/core/types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Data Management Behaviors
|
|
6
|
+
*
|
|
7
|
+
* Standard behaviors for data operations like pagination, selection,
|
|
8
|
+
* sorting, filtering, and search.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* std/Pagination - Page navigation behavior for large data sets.
|
|
15
|
+
*/
|
|
16
|
+
declare const PAGINATION_BEHAVIOR: StandardBehavior;
|
|
17
|
+
declare const SELECTION_BEHAVIOR: StandardBehavior;
|
|
18
|
+
declare const SORT_BEHAVIOR: StandardBehavior;
|
|
19
|
+
/**
|
|
20
|
+
* std/Filter - Query Singleton pattern for explicit filtering.
|
|
21
|
+
*
|
|
22
|
+
* This behavior uses a singleton entity to hold filter state, making filtering
|
|
23
|
+
* explicit in the schema rather than implicit in component behavior.
|
|
24
|
+
*
|
|
25
|
+
* The query singleton is referenced by patterns via the `query` prop:
|
|
26
|
+
* ```json
|
|
27
|
+
* { "type": "entity-table", "entity": "Task", "query": "@TaskQuery" }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare const FILTER_BEHAVIOR: StandardBehavior;
|
|
31
|
+
/**
|
|
32
|
+
* std/Search - Search with debounce.
|
|
33
|
+
*
|
|
34
|
+
* Uses a singleton to hold search state. Can be combined with std/Filter
|
|
35
|
+
* for full query singleton functionality, or used standalone.
|
|
36
|
+
*/
|
|
37
|
+
declare const SEARCH_BEHAVIOR: StandardBehavior;
|
|
38
|
+
declare const DATA_MANAGEMENT_BEHAVIORS: StandardBehavior[];
|
|
39
|
+
|
|
40
|
+
export { DATA_MANAGEMENT_BEHAVIORS, FILTER_BEHAVIOR, PAGINATION_BEHAVIOR, SEARCH_BEHAVIOR, SELECTION_BEHAVIOR, SORT_BEHAVIOR };
|