@procedures/client 0.1.0 → 0.2.1

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 (334) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +5 -5
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/adapters/http/server/transport.d.ts.map +1 -1
  5. package/dist/adapters/http/server/transport.js +1 -0
  6. package/dist/adapters/http/server/transport.js.map +1 -1
  7. package/dist/browser.d.ts +6 -3
  8. package/dist/browser.d.ts.map +1 -1
  9. package/dist/browser.js +4 -1
  10. package/dist/browser.js.map +1 -1
  11. package/dist/client/client.d.ts +9 -1
  12. package/dist/client/client.d.ts.map +1 -1
  13. package/dist/client/client.js +27 -6
  14. package/dist/client/client.js.map +1 -1
  15. package/dist/client/types.d.ts +9 -0
  16. package/dist/client/types.d.ts.map +1 -1
  17. package/dist/client/types.js.map +1 -1
  18. package/dist/procedures/capability.d.ts +111 -0
  19. package/dist/procedures/capability.d.ts.map +1 -0
  20. package/dist/procedures/capability.js +269 -0
  21. package/dist/procedures/capability.js.map +1 -0
  22. package/dist/procedures/cli/discover.d.ts +3 -3
  23. package/dist/procedures/cli/discover.js +3 -3
  24. package/dist/procedures/cli/index.js +5 -3
  25. package/dist/procedures/cli/index.js.map +1 -1
  26. package/dist/procedures/cli/init.js +1 -1
  27. package/dist/procedures/collection/procedures.d.ts.map +1 -1
  28. package/dist/procedures/collection/procedures.js +12 -0
  29. package/dist/procedures/collection/procedures.js.map +1 -1
  30. package/dist/procedures/core/array.d.ts.map +1 -1
  31. package/dist/procedures/core/array.js +3 -1
  32. package/dist/procedures/core/array.js.map +1 -1
  33. package/dist/procedures/core/comparison.d.ts.map +1 -1
  34. package/dist/procedures/core/comparison.js +3 -1
  35. package/dist/procedures/core/comparison.js.map +1 -1
  36. package/dist/procedures/core/index.d.ts.map +1 -1
  37. package/dist/procedures/core/index.js +5 -2
  38. package/dist/procedures/core/index.js.map +1 -1
  39. package/dist/procedures/core/math.d.ts.map +1 -1
  40. package/dist/procedures/core/math.js +3 -1
  41. package/dist/procedures/core/math.js.map +1 -1
  42. package/dist/procedures/core/meta.d.ts.map +1 -1
  43. package/dist/procedures/core/meta.js +11 -6
  44. package/dist/procedures/core/meta.js.map +1 -1
  45. package/dist/procedures/core/object.d.ts.map +1 -1
  46. package/dist/procedures/core/object.js +3 -1
  47. package/dist/procedures/core/object.js.map +1 -1
  48. package/dist/procedures/core/string.d.ts.map +1 -1
  49. package/dist/procedures/core/string.js +3 -1
  50. package/dist/procedures/core/string.js.map +1 -1
  51. package/dist/procedures/core/type.d.ts.map +1 -1
  52. package/dist/procedures/core/type.js +3 -1
  53. package/dist/procedures/core/type.js.map +1 -1
  54. package/dist/procedures/define-procedure.d.ts.map +1 -1
  55. package/dist/procedures/define-procedure.js +5 -4
  56. package/dist/procedures/define-procedure.js.map +1 -1
  57. package/dist/procedures/effects.d.ts +15 -0
  58. package/dist/procedures/effects.d.ts.map +1 -0
  59. package/dist/procedures/effects.js +18 -0
  60. package/dist/procedures/effects.js.map +1 -0
  61. package/dist/procedures/index.d.ts +5 -2
  62. package/dist/procedures/index.d.ts.map +1 -1
  63. package/dist/procedures/index.js +8 -23
  64. package/dist/procedures/index.js.map +1 -1
  65. package/dist/procedures/interceptors.d.ts.map +1 -1
  66. package/dist/procedures/interceptors.js +2 -1
  67. package/dist/procedures/interceptors.js.map +1 -1
  68. package/dist/procedures/invoke.d.ts +36 -3
  69. package/dist/procedures/invoke.d.ts.map +1 -1
  70. package/dist/procedures/invoke.js +78 -12
  71. package/dist/procedures/invoke.js.map +1 -1
  72. package/dist/procedures/module.d.ts +13 -8
  73. package/dist/procedures/module.d.ts.map +1 -1
  74. package/dist/procedures/module.js +19 -9
  75. package/dist/procedures/module.js.map +1 -1
  76. package/dist/procedures/types.d.ts +100 -2
  77. package/dist/procedures/types.d.ts.map +1 -1
  78. package/dist/procedures/types.js.map +1 -1
  79. package/dist/register.d.ts +8 -0
  80. package/dist/register.d.ts.map +1 -0
  81. package/dist/register.js +9 -0
  82. package/dist/register.js.map +1 -0
  83. package/dist/server/host-policy.d.ts +24 -2
  84. package/dist/server/host-policy.d.ts.map +1 -1
  85. package/dist/server/host-policy.js +22 -0
  86. package/dist/server/host-policy.js.map +1 -1
  87. package/dist/server/procedure-server.d.ts +16 -2
  88. package/dist/server/procedure-server.d.ts.map +1 -1
  89. package/dist/server/procedure-server.js +26 -1
  90. package/dist/server/procedure-server.js.map +1 -1
  91. package/package.json +6 -4
  92. package/src/adapters/http/server/transport.ts +1 -0
  93. package/src/browser.ts +29 -0
  94. package/src/client/client.ts +33 -6
  95. package/src/client/types.ts +11 -0
  96. package/src/procedures/capability.ts +333 -0
  97. package/src/procedures/cli/discover.ts +3 -3
  98. package/src/procedures/cli/index.ts +5 -3
  99. package/src/procedures/cli/init.ts +1 -1
  100. package/src/procedures/collection/procedures.ts +12 -0
  101. package/src/procedures/core/array.ts +3 -1
  102. package/src/procedures/core/comparison.ts +3 -1
  103. package/src/procedures/core/index.ts +5 -2
  104. package/src/procedures/core/math.ts +3 -1
  105. package/src/procedures/core/meta.ts +11 -6
  106. package/src/procedures/core/object.ts +3 -1
  107. package/src/procedures/core/string.ts +3 -1
  108. package/src/procedures/core/type.ts +3 -1
  109. package/src/procedures/define-procedure.ts +5 -4
  110. package/src/procedures/effects.ts +24 -0
  111. package/src/procedures/index.ts +33 -22
  112. package/src/procedures/interceptors.ts +2 -1
  113. package/src/procedures/invoke.ts +112 -13
  114. package/src/procedures/module.ts +19 -9
  115. package/src/procedures/types.ts +113 -2
  116. package/src/register.ts +10 -0
  117. package/src/server/host-policy.ts +44 -2
  118. package/src/server/procedure-server.ts +44 -2
  119. package/dist/client/middleware/batching.d.ts +0 -102
  120. package/dist/client/middleware/batching.d.ts.map +0 -1
  121. package/dist/client/middleware/batching.js +0 -245
  122. package/dist/client/middleware/batching.js.map +0 -1
  123. package/dist/collections/async/async-queue.d.ts +0 -144
  124. package/dist/collections/async/async-queue.d.ts.map +0 -1
  125. package/dist/collections/async/async-queue.js +0 -347
  126. package/dist/collections/async/async-queue.js.map +0 -1
  127. package/dist/collections/async/channels.d.ts +0 -188
  128. package/dist/collections/async/channels.d.ts.map +0 -1
  129. package/dist/collections/async/channels.js +0 -312
  130. package/dist/collections/async/channels.js.map +0 -1
  131. package/dist/collections/behaviors/bounded.d.ts +0 -79
  132. package/dist/collections/behaviors/bounded.d.ts.map +0 -1
  133. package/dist/collections/behaviors/bounded.js +0 -384
  134. package/dist/collections/behaviors/bounded.js.map +0 -1
  135. package/dist/collections/behaviors/evented.d.ts +0 -154
  136. package/dist/collections/behaviors/evented.d.ts.map +0 -1
  137. package/dist/collections/behaviors/evented.js +0 -299
  138. package/dist/collections/behaviors/evented.js.map +0 -1
  139. package/dist/collections/behaviors/lru.d.ts +0 -84
  140. package/dist/collections/behaviors/lru.d.ts.map +0 -1
  141. package/dist/collections/behaviors/lru.js +0 -330
  142. package/dist/collections/behaviors/lru.js.map +0 -1
  143. package/dist/collections/behaviors/readonly.d.ts +0 -73
  144. package/dist/collections/behaviors/readonly.d.ts.map +0 -1
  145. package/dist/collections/behaviors/readonly.js +0 -158
  146. package/dist/collections/behaviors/readonly.js.map +0 -1
  147. package/dist/collections/behaviors/safe.d.ts +0 -163
  148. package/dist/collections/behaviors/safe.d.ts.map +0 -1
  149. package/dist/collections/behaviors/safe.js +0 -172
  150. package/dist/collections/behaviors/safe.js.map +0 -1
  151. package/dist/collections/behaviors/synchronized.d.ts +0 -88
  152. package/dist/collections/behaviors/synchronized.d.ts.map +0 -1
  153. package/dist/collections/behaviors/synchronized.js +0 -294
  154. package/dist/collections/behaviors/synchronized.js.map +0 -1
  155. package/dist/collections/behaviors/ttl.d.ts +0 -118
  156. package/dist/collections/behaviors/ttl.d.ts.map +0 -1
  157. package/dist/collections/behaviors/ttl.js +0 -338
  158. package/dist/collections/behaviors/ttl.js.map +0 -1
  159. package/dist/collections/core/effects.d.ts +0 -176
  160. package/dist/collections/core/effects.d.ts.map +0 -1
  161. package/dist/collections/core/effects.js +0 -180
  162. package/dist/collections/core/effects.js.map +0 -1
  163. package/dist/collections/core/events.d.ts +0 -192
  164. package/dist/collections/core/events.d.ts.map +0 -1
  165. package/dist/collections/core/events.js +0 -291
  166. package/dist/collections/core/events.js.map +0 -1
  167. package/dist/collections/core/middleware.d.ts +0 -231
  168. package/dist/collections/core/middleware.d.ts.map +0 -1
  169. package/dist/collections/core/middleware.js +0 -161
  170. package/dist/collections/core/middleware.js.map +0 -1
  171. package/dist/collections/core/policies.d.ts +0 -220
  172. package/dist/collections/core/policies.d.ts.map +0 -1
  173. package/dist/collections/core/policies.js +0 -48
  174. package/dist/collections/core/policies.js.map +0 -1
  175. package/dist/collections/core/traits.d.ts +0 -142
  176. package/dist/collections/core/traits.d.ts.map +0 -1
  177. package/dist/collections/core/traits.js +0 -8
  178. package/dist/collections/core/traits.js.map +0 -1
  179. package/dist/collections/examples.d.ts +0 -13
  180. package/dist/collections/examples.d.ts.map +0 -1
  181. package/dist/collections/examples.js +0 -302
  182. package/dist/collections/examples.js.map +0 -1
  183. package/dist/collections/fx/collectors.d.ts +0 -190
  184. package/dist/collections/fx/collectors.d.ts.map +0 -1
  185. package/dist/collections/fx/collectors.js +0 -369
  186. package/dist/collections/fx/collectors.js.map +0 -1
  187. package/dist/collections/fx/iter.d.ts +0 -166
  188. package/dist/collections/fx/iter.d.ts.map +0 -1
  189. package/dist/collections/fx/iter.js +0 -421
  190. package/dist/collections/fx/iter.js.map +0 -1
  191. package/dist/collections/impl/array-deque.d.ts +0 -107
  192. package/dist/collections/impl/array-deque.d.ts.map +0 -1
  193. package/dist/collections/impl/array-deque.js +0 -381
  194. package/dist/collections/impl/array-deque.js.map +0 -1
  195. package/dist/collections/impl/array-list.d.ts +0 -101
  196. package/dist/collections/impl/array-list.d.ts.map +0 -1
  197. package/dist/collections/impl/array-list.js +0 -387
  198. package/dist/collections/impl/array-list.js.map +0 -1
  199. package/dist/collections/impl/hash-map.d.ts +0 -141
  200. package/dist/collections/impl/hash-map.d.ts.map +0 -1
  201. package/dist/collections/impl/hash-map.js +0 -450
  202. package/dist/collections/impl/hash-map.js.map +0 -1
  203. package/dist/collections/impl/hash-set.d.ts +0 -125
  204. package/dist/collections/impl/hash-set.d.ts.map +0 -1
  205. package/dist/collections/impl/hash-set.js +0 -264
  206. package/dist/collections/impl/hash-set.js.map +0 -1
  207. package/dist/collections/impl/linked-hash-map.d.ts +0 -141
  208. package/dist/collections/impl/linked-hash-map.d.ts.map +0 -1
  209. package/dist/collections/impl/linked-hash-map.js +0 -472
  210. package/dist/collections/impl/linked-hash-map.js.map +0 -1
  211. package/dist/collections/impl/linked-list.d.ts +0 -109
  212. package/dist/collections/impl/linked-list.d.ts.map +0 -1
  213. package/dist/collections/impl/linked-list.js +0 -491
  214. package/dist/collections/impl/linked-list.js.map +0 -1
  215. package/dist/collections/impl/priority-queue.d.ts +0 -134
  216. package/dist/collections/impl/priority-queue.d.ts.map +0 -1
  217. package/dist/collections/impl/priority-queue.js +0 -336
  218. package/dist/collections/impl/priority-queue.js.map +0 -1
  219. package/dist/collections/impl/tree-map.d.ts +0 -146
  220. package/dist/collections/impl/tree-map.d.ts.map +0 -1
  221. package/dist/collections/impl/tree-map.js +0 -781
  222. package/dist/collections/impl/tree-map.js.map +0 -1
  223. package/dist/collections/impl/tree-set.d.ts +0 -112
  224. package/dist/collections/impl/tree-set.d.ts.map +0 -1
  225. package/dist/collections/impl/tree-set.js +0 -374
  226. package/dist/collections/impl/tree-set.js.map +0 -1
  227. package/dist/collections/index.d.ts +0 -105
  228. package/dist/collections/index.d.ts.map +0 -1
  229. package/dist/collections/index.js +0 -135
  230. package/dist/collections/index.js.map +0 -1
  231. package/dist/collections/interfaces/collection.d.ts +0 -119
  232. package/dist/collections/interfaces/collection.d.ts.map +0 -1
  233. package/dist/collections/interfaces/collection.js +0 -8
  234. package/dist/collections/interfaces/collection.js.map +0 -1
  235. package/dist/collections/interfaces/list.d.ts +0 -247
  236. package/dist/collections/interfaces/list.d.ts.map +0 -1
  237. package/dist/collections/interfaces/list.js +0 -8
  238. package/dist/collections/interfaces/list.js.map +0 -1
  239. package/dist/collections/interfaces/map.d.ts +0 -344
  240. package/dist/collections/interfaces/map.d.ts.map +0 -1
  241. package/dist/collections/interfaces/map.js +0 -8
  242. package/dist/collections/interfaces/map.js.map +0 -1
  243. package/dist/collections/interfaces/queue.d.ts +0 -304
  244. package/dist/collections/interfaces/queue.d.ts.map +0 -1
  245. package/dist/collections/interfaces/queue.js +0 -8
  246. package/dist/collections/interfaces/queue.js.map +0 -1
  247. package/dist/collections/interfaces/set.d.ts +0 -137
  248. package/dist/collections/interfaces/set.d.ts.map +0 -1
  249. package/dist/collections/interfaces/set.js +0 -8
  250. package/dist/collections/interfaces/set.js.map +0 -1
  251. package/dist/collections/storage/api.d.ts +0 -109
  252. package/dist/collections/storage/api.d.ts.map +0 -1
  253. package/dist/collections/storage/api.js +0 -182
  254. package/dist/collections/storage/api.js.map +0 -1
  255. package/dist/collections/storage/hybrid.d.ts +0 -164
  256. package/dist/collections/storage/hybrid.d.ts.map +0 -1
  257. package/dist/collections/storage/hybrid.js +0 -416
  258. package/dist/collections/storage/hybrid.js.map +0 -1
  259. package/dist/collections/storage/index.d.ts +0 -16
  260. package/dist/collections/storage/index.d.ts.map +0 -1
  261. package/dist/collections/storage/index.js +0 -13
  262. package/dist/collections/storage/index.js.map +0 -1
  263. package/dist/collections/storage/interface.d.ts +0 -141
  264. package/dist/collections/storage/interface.d.ts.map +0 -1
  265. package/dist/collections/storage/interface.js +0 -23
  266. package/dist/collections/storage/interface.js.map +0 -1
  267. package/dist/collections/storage/memory.d.ts +0 -68
  268. package/dist/collections/storage/memory.d.ts.map +0 -1
  269. package/dist/collections/storage/memory.js +0 -154
  270. package/dist/collections/storage/memory.js.map +0 -1
  271. package/dist/collections/utils/defaults.d.ts +0 -135
  272. package/dist/collections/utils/defaults.d.ts.map +0 -1
  273. package/dist/collections/utils/defaults.js +0 -322
  274. package/dist/collections/utils/defaults.js.map +0 -1
  275. package/dist/collections/utils/factories.d.ts +0 -144
  276. package/dist/collections/utils/factories.d.ts.map +0 -1
  277. package/dist/collections/utils/factories.js +0 -293
  278. package/dist/collections/utils/factories.js.map +0 -1
  279. package/dist/collections/utils/helpers.d.ts +0 -137
  280. package/dist/collections/utils/helpers.d.ts.map +0 -1
  281. package/dist/collections/utils/helpers.js +0 -221
  282. package/dist/collections/utils/helpers.js.map +0 -1
  283. package/dist/collections.d.ts +0 -12
  284. package/dist/collections.d.ts.map +0 -1
  285. package/dist/collections.js +0 -10
  286. package/dist/collections.js.map +0 -1
  287. package/dist/components/define.d.ts +0 -134
  288. package/dist/components/define.d.ts.map +0 -1
  289. package/dist/components/define.js +0 -486
  290. package/dist/components/define.js.map +0 -1
  291. package/dist/components/index.d.ts +0 -39
  292. package/dist/components/index.d.ts.map +0 -1
  293. package/dist/components/index.js +0 -38
  294. package/dist/components/index.js.map +0 -1
  295. package/dist/components/types.d.ts +0 -264
  296. package/dist/components/types.d.ts.map +0 -1
  297. package/dist/components/types.js +0 -46
  298. package/dist/components/types.js.map +0 -1
  299. package/dist/procedures/storage/adapter.d.ts +0 -148
  300. package/dist/procedures/storage/adapter.d.ts.map +0 -1
  301. package/dist/procedures/storage/adapter.js +0 -214
  302. package/dist/procedures/storage/adapter.js.map +0 -1
  303. package/dist/procedures/storage/api.d.ts +0 -125
  304. package/dist/procedures/storage/api.d.ts.map +0 -1
  305. package/dist/procedures/storage/api.js +0 -220
  306. package/dist/procedures/storage/api.js.map +0 -1
  307. package/dist/procedures/storage/factory.d.ts +0 -134
  308. package/dist/procedures/storage/factory.d.ts.map +0 -1
  309. package/dist/procedures/storage/factory.js +0 -166
  310. package/dist/procedures/storage/factory.js.map +0 -1
  311. package/dist/procedures/storage/hybrid.d.ts +0 -193
  312. package/dist/procedures/storage/hybrid.d.ts.map +0 -1
  313. package/dist/procedures/storage/hybrid.js +0 -519
  314. package/dist/procedures/storage/hybrid.js.map +0 -1
  315. package/dist/procedures/storage/index.d.ts +0 -17
  316. package/dist/procedures/storage/index.d.ts.map +0 -1
  317. package/dist/procedures/storage/index.js +0 -17
  318. package/dist/procedures/storage/index.js.map +0 -1
  319. package/dist/procedures/storage/procedures.d.ts +0 -39
  320. package/dist/procedures/storage/procedures.d.ts.map +0 -1
  321. package/dist/procedures/storage/procedures.js +0 -261
  322. package/dist/procedures/storage/procedures.js.map +0 -1
  323. package/dist/procedures/storage/serialization.d.ts +0 -123
  324. package/dist/procedures/storage/serialization.d.ts.map +0 -1
  325. package/dist/procedures/storage/serialization.js +0 -216
  326. package/dist/procedures/storage/serialization.js.map +0 -1
  327. package/dist/procedures/storage/synced-registry.d.ts +0 -246
  328. package/dist/procedures/storage/synced-registry.d.ts.map +0 -1
  329. package/dist/procedures/storage/synced-registry.js +0 -575
  330. package/dist/procedures/storage/synced-registry.js.map +0 -1
  331. package/dist/procedures/storage/types.d.ts +0 -130
  332. package/dist/procedures/storage/types.d.ts.map +0 -1
  333. package/dist/procedures/storage/types.js +0 -8
  334. package/dist/procedures/storage/types.js.map +0 -1
@@ -1,221 +0,0 @@
1
- /**
2
- * Common helper utilities for collections.
3
- *
4
- * Provides shared functionality to reduce code duplication across implementations.
5
- */
6
- // ============================================================================
7
- // Bounds checking utilities
8
- // ============================================================================
9
- /**
10
- * Checks if an index is within valid bounds [0, size).
11
- * Throws RangeError if out of bounds.
12
- *
13
- * @param index The index to check
14
- * @param size The size of the collection
15
- * @param collectionName Optional name for error message
16
- * @throws RangeError if index is out of bounds
17
- */
18
- export function checkBounds(index, size, collectionName = "Collection") {
19
- if (index < 0 || index >= size) {
20
- throw new RangeError(`${collectionName}: Index ${index} out of bounds [0, ${size})`);
21
- }
22
- }
23
- /**
24
- * Checks if an index is valid for insertion [0, size].
25
- * Allows index === size for append operations.
26
- *
27
- * @param index The index to check
28
- * @param size The size of the collection
29
- * @param collectionName Optional name for error message
30
- * @throws RangeError if index is out of bounds
31
- */
32
- export function checkInsertBounds(index, size, collectionName = "Collection") {
33
- if (index < 0 || index > size) {
34
- throw new RangeError(`${collectionName}: Index ${index} out of bounds [0, ${size}]`);
35
- }
36
- }
37
- /**
38
- * Checks if a range [start, end) is valid.
39
- *
40
- * @param start Start index (inclusive)
41
- * @param end End index (exclusive)
42
- * @param size The size of the collection
43
- * @param collectionName Optional name for error message
44
- * @throws RangeError if range is invalid
45
- */
46
- export function checkRangeBounds(start, end, size, collectionName = "Collection") {
47
- if (start < 0 || end > size || start > end) {
48
- throw new RangeError(`${collectionName}: Invalid range [${start}, ${end}) for size ${size}`);
49
- }
50
- }
51
- // ============================================================================
52
- // Equality and search utilities
53
- // ============================================================================
54
- /**
55
- * Finds the index of an element in an array using custom equality.
56
- *
57
- * @param array The array to search
58
- * @param element The element to find
59
- * @param eq Equality function
60
- * @returns Index of element, or -1 if not found
61
- */
62
- export function findIndex(array, element, eq) {
63
- for (let i = 0; i < array.length; i++) {
64
- if (eq(array[i], element)) {
65
- return i;
66
- }
67
- }
68
- return -1;
69
- }
70
- /**
71
- * Finds the last index of an element in an array using custom equality.
72
- *
73
- * @param array The array to search
74
- * @param element The element to find
75
- * @param eq Equality function
76
- * @returns Last index of element, or -1 if not found
77
- */
78
- export function findLastIndex(array, element, eq) {
79
- for (let i = array.length - 1; i >= 0; i--) {
80
- if (eq(array[i], element)) {
81
- return i;
82
- }
83
- }
84
- return -1;
85
- }
86
- /**
87
- * Checks if an array contains an element using custom equality.
88
- *
89
- * @param array The array to search
90
- * @param element The element to find
91
- * @param eq Equality function
92
- * @returns true if element is found
93
- */
94
- export function arrayContains(array, element, eq) {
95
- return findIndex(array, element, eq) !== -1;
96
- }
97
- /**
98
- * Removes the first occurrence of an element from an array.
99
- *
100
- * @param array The array to modify
101
- * @param element The element to remove
102
- * @param eq Equality function
103
- * @returns true if element was found and removed
104
- */
105
- export function arrayRemove(array, element, eq) {
106
- const index = findIndex(array, element, eq);
107
- if (index === -1)
108
- return false;
109
- array.splice(index, 1);
110
- return true;
111
- }
112
- /**
113
- * Removes all occurrences of an element from an array.
114
- *
115
- * @param array The array to modify
116
- * @param element The element to remove
117
- * @param eq Equality function
118
- * @returns Number of elements removed
119
- */
120
- export function arrayRemoveAll(array, element, eq) {
121
- let count = 0;
122
- for (let i = array.length - 1; i >= 0; i--) {
123
- if (eq(array[i], element)) {
124
- array.splice(i, 1);
125
- count++;
126
- }
127
- }
128
- return count;
129
- }
130
- // ============================================================================
131
- // Iterator utilities
132
- // ============================================================================
133
- /**
134
- * Creates a simple iterator for an array.
135
- *
136
- * @param array The array to iterate
137
- * @returns Iterator over the array
138
- */
139
- export function* arrayIterator(array) {
140
- yield* array;
141
- }
142
- /**
143
- * Creates a reversed iterator for an array.
144
- *
145
- * @param array The array to iterate
146
- * @returns Reversed iterator over the array
147
- */
148
- export function* reverseArrayIterator(array) {
149
- for (let i = array.length - 1; i >= 0; i--) {
150
- yield array[i];
151
- }
152
- }
153
- /**
154
- * Converts an iterable to an array.
155
- *
156
- * @param iterable The iterable to convert
157
- * @returns Array containing all elements
158
- */
159
- export function toArray(iterable) {
160
- return Array.from(iterable);
161
- }
162
- // ============================================================================
163
- // Validation utilities
164
- // ============================================================================
165
- /**
166
- * Ensures a value is not null or undefined.
167
- *
168
- * @param value The value to check
169
- * @param message Error message
170
- * @returns The non-null value
171
- * @throws Error if value is null or undefined
172
- */
173
- export function requireNonNull(value, message = "Value cannot be null or undefined") {
174
- if (value === null || value === undefined) {
175
- throw new Error(message);
176
- }
177
- return value;
178
- }
179
- /**
180
- * Ensures a collection is not empty.
181
- *
182
- * @param size Current size
183
- * @param collectionName Optional name for error message
184
- * @throws Error if collection is empty
185
- */
186
- export function requireNonEmpty(size, collectionName = "Collection") {
187
- if (size === 0) {
188
- throw new Error(`${collectionName} is empty`);
189
- }
190
- }
191
- // ============================================================================
192
- // Math utilities
193
- // ============================================================================
194
- /**
195
- * Clamps a value between min and max.
196
- *
197
- * @param value The value to clamp
198
- * @param min Minimum value
199
- * @param max Maximum value
200
- * @returns Clamped value
201
- */
202
- export function clamp(value, min, max) {
203
- return Math.max(min, Math.min(max, value));
204
- }
205
- /**
206
- * Calculates hash code for a string.
207
- * Uses Java's String.hashCode() algorithm.
208
- *
209
- * @param str The string to hash
210
- * @returns Hash code
211
- */
212
- export function stringHashCode(str) {
213
- let hash = 0;
214
- for (let i = 0; i < str.length; i++) {
215
- const char = str.charCodeAt(i);
216
- hash = ((hash << 5) - hash) + char;
217
- hash = hash & hash; // Convert to 32-bit integer
218
- }
219
- return hash;
220
- }
221
- //# sourceMappingURL=helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/collections/utils/helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,+EAA+E;AAC/E,4BAA4B;AAC5B,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,IAAY,EAAE,iBAAyB,YAAY;IAC5F,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAC/B,MAAM,IAAI,UAAU,CAAC,GAAG,cAAc,WAAW,KAAK,sBAAsB,IAAI,GAAG,CAAC,CAAC;IACvF,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa,EAAE,IAAY,EAAE,iBAAyB,YAAY;IAClG,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC;QAC9B,MAAM,IAAI,UAAU,CAAC,GAAG,cAAc,WAAW,KAAK,sBAAsB,IAAI,GAAG,CAAC,CAAC;IACvF,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAa,EACb,GAAW,EACX,IAAY,EACZ,iBAAyB,YAAY;IAErC,IAAI,KAAK,GAAG,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,KAAK,GAAG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mCAAmC;IAClH,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,iBAAyB,YAAY;IACjF,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,GAAG,cAAc,WAAW,CAAC,CAAC;IAChD,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;;;;;GAOG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IAC3D,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC/B,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;QACnC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,4BAA4B;IAClD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Collections entry point: "@mark1russell7/client/collections"
3
- *
4
- * Re-exports @mark1russell7/client-collections, plus the collection storage
5
- * backends that need a Client and therefore live in this package.
6
- */
7
- export * from "@mark1russell7/client-collections";
8
- export { ApiStorage } from "./procedures/storage/api.js";
9
- export type { ApiStorageOptions } from "./procedures/storage/api.js";
10
- export { HybridStorage } from "./procedures/storage/hybrid.js";
11
- export type { HybridStorageOptions, ConflictResolution, WriteStrategy } from "./procedures/storage/hybrid.js";
12
- //# sourceMappingURL=collections.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,mCAAmC,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Collections entry point: "@mark1russell7/client/collections"
3
- *
4
- * Re-exports @mark1russell7/client-collections, plus the collection storage
5
- * backends that need a Client and therefore live in this package.
6
- */
7
- export * from "@mark1russell7/client-collections";
8
- export { ApiStorage } from "./procedures/storage/api.js";
9
- export { HybridStorage } from "./procedures/storage/hybrid.js";
10
- //# sourceMappingURL=collections.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"collections.js","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,mCAAmC,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC"}
@@ -1,134 +0,0 @@
1
- /**
2
- * Component Definition Helpers
3
- *
4
- * Utilities for defining components as procedures.
5
- * Components are procedures with special handling for UI rendering.
6
- */
7
- import type { ZodLike } from "../client/validation/types.js";
8
- import type { Procedure, ProcedurePath } from "../procedures/types.js";
9
- import type { ComponentDefinition, ComponentContext, ComponentOutput, ComponentBundle, AnyComponentDefinition, Size } from "./types.js";
10
- /**
11
- * Standard component input structure.
12
- * Components receive data, size, and path for rendering.
13
- */
14
- export interface ComponentInput<TData = unknown> {
15
- /** Component data */
16
- data: TData;
17
- /** Available size for rendering */
18
- size: Size;
19
- /** Path in render tree */
20
- path: string;
21
- /** Depth in render tree */
22
- depth?: number;
23
- }
24
- /**
25
- * Default component input schema.
26
- * Validates the standard { data, size, path } structure.
27
- */
28
- export declare const componentInputSchema: ZodLike<ComponentInput>;
29
- /**
30
- * Component output schema.
31
- * Validates that output is a serializable ComponentOutput.
32
- */
33
- export declare const componentOutputSchema: ZodLike<ComponentOutput>;
34
- /**
35
- * Define a component and convert it to a procedure.
36
- *
37
- * Components are registered under ["components", namespace?, type].
38
- *
39
- * @param definition - Component definition
40
- * @returns The component definition (for chaining)
41
- *
42
- * @example
43
- * ```typescript
44
- * // Simple component
45
- * const userCard = defineComponent({
46
- * type: "user-card",
47
- * namespace: "ui",
48
- * input: userSchema,
49
- * factory: (ctx) => ({
50
- * type: "user-card",
51
- * props: { user: ctx.data },
52
- * }),
53
- * });
54
- *
55
- * // Streaming component
56
- * const liveDashboard = defineComponent({
57
- * type: "live-dashboard",
58
- * streaming: true,
59
- * factory: async function* (ctx) {
60
- * yield { type: "dashboard", props: { loading: true } };
61
- * for await (const data of ctx.bus.stream("updates")) {
62
- * yield { type: "dashboard", props: { data } };
63
- * }
64
- * },
65
- * });
66
- * ```
67
- */
68
- export declare function defineComponent<TData = unknown>(definition: ComponentDefinition<TData>): ComponentDefinition<TData>;
69
- /**
70
- * Convert a component definition to a procedure.
71
- *
72
- * @param definition - Component definition
73
- * @param path - Procedure path
74
- * @returns Procedure that wraps the component
75
- */
76
- export declare function componentToProcedure<TData>(definition: ComponentDefinition<TData>, path: ProcedurePath): Procedure<ComponentInput<TData>, ComponentOutput>;
77
- /**
78
- * Register a bundle of components.
79
- *
80
- * @param bundle - Component bundle
81
- * @returns The registered components
82
- *
83
- * @example
84
- * ```typescript
85
- * const registered = registerBundle({
86
- * namespace: "ui",
87
- * components: [buttonComponent, cardComponent],
88
- * });
89
- * ```
90
- */
91
- export declare function registerBundle(bundle: ComponentBundle): AnyComponentDefinition[];
92
- /**
93
- * Create a component bundle.
94
- *
95
- * @param namespace - Shared namespace
96
- * @param components - Component definitions
97
- * @param metadata - Optional bundle metadata
98
- * @returns ComponentBundle
99
- */
100
- export declare function createBundle(namespace: string, components: AnyComponentDefinition[], metadata?: ComponentBundle["metadata"]): ComponentBundle;
101
- /**
102
- * Define a simple component with minimal boilerplate.
103
- *
104
- * @param type - Component type
105
- * @param factory - Factory function
106
- * @returns ComponentDefinition
107
- *
108
- * @example
109
- * ```typescript
110
- * const badge = simpleComponent("badge", (ctx) => ({
111
- * type: "badge",
112
- * props: { label: ctx.data.label },
113
- * }));
114
- * ```
115
- */
116
- export declare function simpleComponent<TData = unknown>(type: string, factory: (ctx: ComponentContext<TData>) => ComponentOutput): ComponentDefinition<TData>;
117
- /**
118
- * Define a namespaced component with minimal boilerplate.
119
- *
120
- * @param namespace - Component namespace
121
- * @param type - Component type
122
- * @param factory - Factory function
123
- * @returns ComponentDefinition
124
- */
125
- export declare function namespacedComponent<TData = unknown>(namespace: string, type: string, factory: (ctx: ComponentContext<TData>) => ComponentOutput): ComponentDefinition<TData>;
126
- /**
127
- * Define a streaming component.
128
- *
129
- * @param type - Component type
130
- * @param factory - Generator factory function
131
- * @returns ComponentDefinition
132
- */
133
- export declare function streamingComponent<TData = unknown>(type: string, factory: (ctx: ComponentContext<TData>) => AsyncGenerator<ComponentOutput, void, unknown>): ComponentDefinition<TData>;
134
- //# sourceMappingURL=define.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/components/define.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAA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