@supersoniks/concorde 4.9.93 → 4.9.94

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 (89) hide show
  1. package/build-infos.json +1 -1
  2. package/concorde-core.bundle.js +299 -292
  3. package/concorde-core.es.js +10104 -6071
  4. package/dist/concorde-core.bundle.js +299 -292
  5. package/dist/concorde-core.es.js +10104 -6071
  6. package/dist/docs-mock-api-sw.js +110 -0
  7. package/dist/docs-mock-api-sw.js.map +3 -3
  8. package/dist/js/core/components/functional/functional.js +1 -0
  9. package/dist/js/core/components/functional/functional.js.map +1 -1
  10. package/dist/js/core/components/functional/jsonata/jsonata.js +119 -0
  11. package/dist/js/core/components/functional/jsonata/jsonata.js.map +1 -0
  12. package/dist/js/core/components/ui/button/button.js +1 -1
  13. package/dist/js/core/components/ui/button/button.js.map +1 -1
  14. package/dist/js/core/decorators/Subscriber.js +1 -0
  15. package/dist/js/core/decorators/Subscriber.js.map +1 -1
  16. package/dist/js/core/decorators/subscriber/derive.js +60 -0
  17. package/dist/js/core/decorators/subscriber/derive.js.map +1 -0
  18. package/dist/js/core/utils/derive.js +246 -0
  19. package/dist/js/core/utils/derive.js.map +1 -0
  20. package/dist/js/core/utils/jsonataHelpers.js +69 -0
  21. package/dist/js/core/utils/jsonataHelpers.js.map +1 -0
  22. package/dist/js/core/utils/jsonataRuntime.js +75 -0
  23. package/dist/js/core/utils/jsonataRuntime.js.map +1 -0
  24. package/dist/js/utils.js +2 -0
  25. package/dist/js/utils.js.map +1 -1
  26. package/dist/types/core/components/functional/functional.d.ts +1 -0
  27. package/dist/types/core/components/functional/functional.d.ts.map +1 -1
  28. package/dist/types/core/components/functional/jsonata/jsonata.d.ts +29 -0
  29. package/dist/types/core/components/functional/jsonata/jsonata.d.ts.map +1 -0
  30. package/dist/types/core/components/ui/button/button.d.ts +1 -1
  31. package/dist/types/core/components/ui/button/button.d.ts.map +1 -1
  32. package/dist/types/core/components/ui/form/checkbox/checkbox.d.ts +3 -3
  33. package/dist/types/core/components/ui/form/input/input.d.ts +3 -3
  34. package/dist/types/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +3 -3
  35. package/dist/types/core/components/ui/form/textarea/textarea.d.ts +3 -3
  36. package/dist/types/core/decorators/Subscriber.d.ts +2 -0
  37. package/dist/types/core/decorators/Subscriber.d.ts.map +1 -1
  38. package/dist/types/core/decorators/subscriber/derive.d.ts +30 -0
  39. package/dist/types/core/decorators/subscriber/derive.d.ts.map +1 -0
  40. package/dist/types/core/utils/derive.d.ts +40 -0
  41. package/dist/types/core/utils/derive.d.ts.map +1 -0
  42. package/dist/types/core/utils/jsonataHelpers.d.ts +15 -0
  43. package/dist/types/core/utils/jsonataHelpers.d.ts.map +1 -0
  44. package/dist/types/core/utils/jsonataRuntime.d.ts +13 -0
  45. package/dist/types/core/utils/jsonataRuntime.d.ts.map +1 -0
  46. package/dist/types/mixins.d.ts +3 -3
  47. package/dist/types/utils.d.ts +2 -0
  48. package/dist/types/utils.d.ts.map +1 -1
  49. package/docs/assets/{index-DURr6O71.js → index-DpIkksht.js} +652 -479
  50. package/docs/crawl/docs/_decorators/get.html +27 -6
  51. package/docs/crawl/docs/_decorators/patch.html +6 -0
  52. package/docs/crawl/docs/_decorators/post.html +8 -0
  53. package/docs/crawl/docs/_decorators/put.html +6 -0
  54. package/docs/crawl/hubs/decorators.html +36 -31
  55. package/docs/crawl/hubs/remote-data.html +36 -31
  56. package/docs/index.html +1 -1
  57. package/docs/llms-full.txt +47 -3
  58. package/docs/src/docs/_decorators/get.md +31 -0
  59. package/docs/src/docs/_decorators/patch.md +9 -0
  60. package/docs/src/docs/_decorators/post.md +11 -0
  61. package/docs/src/docs/_decorators/put.md +9 -0
  62. package/docs/src/docs/search/docs-search.json +120 -5
  63. package/docs/src/tsconfig.json +268 -268
  64. package/package.json +28 -3
  65. package/public/docs-mock-api-sw.js +110 -0
  66. package/public/docs-mock-api-sw.js.map +3 -3
  67. package/src/core/components/functional/functional.ts +1 -0
  68. package/src/core/components/functional/jsonata/jsonata.md +56 -0
  69. package/src/core/components/functional/jsonata/jsonata.spec.ts +202 -0
  70. package/src/core/components/functional/jsonata/jsonata.ts +116 -0
  71. package/src/core/components/ui/button/button.ts +2 -2
  72. package/src/core/decorators/Subscriber.ts +2 -0
  73. package/src/core/decorators/subscriber/derive.ts +95 -0
  74. package/src/core/utils/derive.spec.ts +190 -0
  75. package/src/core/utils/derive.ts +357 -0
  76. package/src/core/utils/jsonataHelpers.ts +100 -0
  77. package/src/core/utils/jsonataRuntime.ts +88 -0
  78. package/src/docs/_core-concept/dataFlow.md +9 -0
  79. package/src/docs/_misc/docs-mock-api.md +3 -0
  80. package/src/docs/components/docs-demo-sources.ts +26 -0
  81. package/src/docs/docs.ts +1 -0
  82. package/src/docs/example/docs-jsonata-demos.ts +128 -0
  83. package/src/docs/mock-api/fixtures-jsonata.ts +131 -0
  84. package/src/docs/mock-api/router.ts +26 -0
  85. package/src/docs/navigation/navigation.ts +4 -0
  86. package/src/docs/search/docs-search.json +180 -0
  87. package/src/tsconfig.json +18 -0
  88. package/src/tsconfig.tsbuildinfo +1 -1
  89. package/src/utils.ts +13 -0
@@ -8,9 +8,7 @@
8
8
  <meta name="keywords" content="Concorde, supersoniks, docs/_decorators/get, get, @get, decorator, ApiResult, undefined, payload.result, payload.response, payload.request,
9
9
 
10
10
  The first argument is always an
11
- [, serviceURL, refetch(component),
12
-
13
- ">
11
+ [, serviceURL, refetch(component)">
14
12
  <meta name="concorde-doc-id" content="docs/_decorators/get">
15
13
  <link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_decorators/get.html">
16
14
  </head>
@@ -23,9 +21,7 @@ The first argument is always an
23
21
  <p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @get</strong>. @get loads data and stores the result in an optional ApiResult&lt;T&gt; property. <span>Doc ID: <code>docs/_decorators/get</code>. Keywords: Concorde, supersoniks, docs/_decorators/get, get, @get, decorator, ApiResult, undefined, payload.result, payload.response, payload.request,
24
22
 
25
23
  The first argument is always an
26
- [, serviceURL, refetch(component),
27
-
28
- . URL: <a href="https://concorde.supersoniks.org/crawl/docs/_decorators/get.html">https://concorde.supersoniks.org/crawl/docs/_decorators/get.html</a>.</span></p>
24
+ [, serviceURL, refetch(component). URL: <a href="https://concorde.supersoniks.org/crawl/docs/_decorators/get.html">https://concorde.supersoniks.org/crawl/docs/_decorators/get.html</a>.</span></p>
29
25
  <h1 id="get">@get</h1>
30
26
  <p><code>@get</code> loads data and stores the result in an optional <code>ApiResult&lt;T&gt;</code> property.
31
27
  The property is <code>undefined</code> until a result is available.</p>
@@ -41,6 +37,16 @@ The property is <code>undefined</code> until a result is available.</p>
41
37
  @state()
42
38
  payload?: ApiResult&lt;User[]&gt;;
43
39
  </code></pre>
40
+ <p>The same decorator adapts to a method. The method receives the complete
41
+ <code>ApiResult&lt;T&gt;</code> payload after each GET:</p>
42
+ <pre><code class="language-typescript">@get(usersEndpoint)
43
+ handleUsers(payload?: ApiResult&lt;User[]&gt;) {
44
+ if (!payload) return;
45
+
46
+ console.log(payload.response?.status);
47
+ console.log(payload.result);
48
+ }
49
+ </code></pre>
44
50
  <p>The first argument is always an
45
51
  <a href="../_misc/endpoint.html#endpoint"><code>Endpoint&lt;T&gt;</code></a>. API configuration is read
46
52
  from the HTML scope (<code>serviceURL</code>, token, etc.), so the component is usually
@@ -63,6 +69,19 @@ async refresh() {
63
69
  </code></pre>
64
70
  <p><code>refetch(component)</code> returns a <code>Promise&lt;ApiResult&lt;T&gt; | undefined&gt;</code> that resolves
65
71
  after the GET has completed.</p>
72
+ <p>The named handle can also decorate a method and be reused for refetching:</p>
73
+ <pre><code class="language-typescript">const usersGet = get(new Endpoint&lt;User[]&gt;(&quot;users&quot;));
74
+
75
+ @usersGet
76
+ handleUsers(payload?: ApiResult&lt;User[]&gt;) {
77
+ // ...
78
+ }
79
+
80
+ @refetch(usersGet)
81
+ reloadUsers() {
82
+ // The GET runs and handleUsers receives its payload.
83
+ }
84
+ </code></pre>
66
85
  <h3 id="from-a-method-decorator">From a method decorator</h3>
67
86
  <p>The refetch can decorate a local method. The default is <code>after</code>; if the
68
87
  method returns a Promise, the GET waits for its resolution. The decorated method
@@ -112,6 +131,8 @@ import { Endpoint } from &quot;@supersoniks/concorde/utils/endpoint&quot;;
112
131
  <h2 id="demos">Demos</h2>
113
132
  <pre><code>&lt;docs-demo-sources for=&quot;demo-api-get&quot;&gt;&lt;/docs-demo-sources&gt;
114
133
  &lt;demo-api-get&gt;&lt;/demo-api-get&gt;
134
+ &lt;docs-demo-sources for=&quot;demo-api-get-method&quot;&gt;&lt;/docs-demo-sources&gt;
135
+ &lt;demo-api-get-method&gt;&lt;/demo-api-get-method&gt;
115
136
  &lt;docs-demo-sources for=&quot;demo-api-get-configuration-key&quot;&gt;&lt;/docs-demo-sources&gt;
116
137
  &lt;demo-api-get-configuration-key&gt;&lt;/demo-api-get-configuration-key&gt;
117
138
  </code></pre>
@@ -33,6 +33,12 @@ const patchUser = patch(new Endpoint&lt;User&gt;(&quot;users/42&quot;), bodyKey)
33
33
  @state()
34
34
  payload?: ApiResult&lt;User&gt;;
35
35
  </code></pre>
36
+ <p>The same decorator adapts to a method:</p>
37
+ <pre><code class="language-typescript">@patch(new Endpoint&lt;User&gt;(&quot;users/42&quot;), bodyKey)
38
+ handlePatch(payload?: ApiResult&lt;User&gt;) {
39
+ if (payload?.response?.ok) console.log(payload.result);
40
+ }
41
+ </code></pre>
36
42
  <p>To run the operation again from the component:</p>
37
43
  <pre><code class="language-typescript">async savePatch() {
38
44
  await patchUser.send(this);
@@ -41,6 +41,12 @@ const createUser = post(new Endpoint&lt;User&gt;(&quot;users&quot;), userBodyKey
41
41
  @state()
42
42
  payload?: ApiResult&lt;User&gt;;
43
43
  </code></pre>
44
+ <p>The same decorator adapts to a method and receives the complete payload:</p>
45
+ <pre><code class="language-typescript">@post(new Endpoint&lt;User&gt;(&quot;users&quot;), userBodyKey)
46
+ handleCreate(payload?: ApiResult&lt;User&gt;) {
47
+ if (payload?.response?.ok) console.log(payload.result);
48
+ }
49
+ </code></pre>
44
50
  <p>The current body is read from <code>userBodyKey</code>. By default, the POST is sent when
45
51
  the component connects and after each body mutation. Mutations in the same
46
52
  frame are coalesced into one request.</p>
@@ -115,6 +121,8 @@ import { Endpoint } from &quot;@supersoniks/concorde/utils/endpoint&quot;;
115
121
  <h2 id="demos">Demos</h2>
116
122
  <pre><code>&lt;docs-demo-sources for=&quot;demo-api-post&quot;&gt;&lt;/docs-demo-sources&gt;
117
123
  &lt;demo-api-post&gt;&lt;/demo-api-post&gt;
124
+ &lt;docs-demo-sources for=&quot;demo-api-post-method&quot;&gt;&lt;/docs-demo-sources&gt;
125
+ &lt;demo-api-post-method&gt;&lt;/demo-api-post-method&gt;
118
126
  &lt;docs-demo-sources for=&quot;demo-api-post-dynamic&quot;&gt;&lt;/docs-demo-sources&gt;
119
127
  &lt;demo-api-post-dynamic&gt;&lt;/demo-api-post-dynamic&gt;
120
128
  </code></pre>
@@ -33,6 +33,12 @@ const updateUser = put(new Endpoint&lt;User&gt;(&quot;users/42&quot;), bodyKey);
33
33
  @state()
34
34
  payload?: ApiResult&lt;User&gt;;
35
35
  </code></pre>
36
+ <p>The same decorator adapts to a method:</p>
37
+ <pre><code class="language-typescript">@put(new Endpoint&lt;User&gt;(&quot;users/42&quot;), bodyKey)
38
+ handleUpdate(payload?: ApiResult&lt;User&gt;) {
39
+ if (payload?.response?.ok) console.log(payload.result);
40
+ }
41
+ </code></pre>
36
42
  <p>To run the operation again from the component:</p>
37
43
  <pre><code class="language-typescript">async update() {
38
44
  await updateUser.send(this);
@@ -167,6 +167,17 @@ const usersEndpoint = new Endpoint (&quot;users&quot;);
167
167
  @state()
168
168
  payload?: ApiResult ;
169
169
 
170
+ The same decorator adapts to a method. The method receives the complete
171
+ ApiResult payload after each GET:
172
+
173
+ @get(usersEndpoint)
174
+ handleUsers(payload?: ApiResult ) {
175
+ if (!payload) return;
176
+
177
+ console.log(payload.response?.status);
178
+ console.log(payload.result);
179
+ }
180
+
170
181
  The first argument is always an
171
182
  Endpoint . API configuration is read
172
183
  from the HTML scope (serviceURL, token, etc.), so the component is usually
@@ -188,16 +199,7 @@ payload?: ApiResult ;
188
199
 
189
200
  async refresh() {
190
201
  const payload = await usersGet.refetch(this);
191
- console.log(payload?.result);
192
- }
193
-
194
- refetch(component) returns a Promise | undefined&gt; that resolves
195
- after the GET has completed.
196
-
197
- From a method decorator
198
-
199
- The refetch can decorate a local method. The default is after; if the
200
- method returns a Promise, the GET waits for its resol</pre>
202
+ console.log(</pre>
201
203
  </section>
202
204
  <section id="docs-_decorators-handle" data-doc-id="docs/_decorators/handle">
203
205
  <h2><a href="../docs/_decorators/handle.html">@handle</a></h2>
@@ -294,6 +296,13 @@ const patchUser = patch(new Endpoint (&quot;users/42&quot;), bodyKey);
294
296
  @state()
295
297
  payload?: ApiResult ;
296
298
 
299
+ The same decorator adapts to a method:
300
+
301
+ @patch(new Endpoint (&quot;users/42&quot;), bodyKey)
302
+ handlePatch(payload?: ApiResult ) {
303
+ if (payload?.response?.ok) console.log(payload.result);
304
+ }
305
+
297
306
  To run the operation again from the component:
298
307
 
299
308
  async savePatch() {
@@ -320,13 +329,7 @@ Pass explicit API configuration as the third argument:
320
329
 
321
330
  Import
322
331
 
323
- import { patch, type ApiResult } from &quot;@supersoniks/concorde/decorators&quot;;
324
- import { DataProviderKey } from &quot;@supersoniks/concorde/dataProviderKey&quot;;
325
- import { Endpoint } from &quot;@supersoniks/concorde/utils/endpoint&quot;;
326
-
327
- See also
328
-
329
- - @post —</pre>
332
+ import { patch, type ApiResult } from &quot;@supersoniks/</pre>
330
333
  </section>
331
334
  <section id="docs-_decorators-post" data-doc-id="docs/_decorators/post">
332
335
  <h2><a href="../docs/_decorators/post.html">@post</a></h2>
@@ -349,6 +352,13 @@ const createUser = post(new Endpoint (&quot;users&quot;), userBodyKey);
349
352
  @state()
350
353
  payload?: ApiResult ;
351
354
 
355
+ The same decorator adapts to a method and receives the complete payload:
356
+
357
+ @post(new Endpoint (&quot;users&quot;), userBodyKey)
358
+ handleCreate(payload?: ApiResult ) {
359
+ if (payload?.response?.ok) console.log(payload.result);
360
+ }
361
+
352
362
  The current body is read from userBodyKey. By default, the POST is sent when
353
363
  the component connects and after each body mutation. Mutations in the same
354
364
  frame are coalesced into one request.
@@ -369,13 +379,7 @@ async saveAgain() {
369
379
  }
370
380
 
371
381
  send() returns a Promise | undefined&gt; that resolves after the
372
- operation completes. It is useful for “Save” or “Retry” buttons and can repeat
373
- an operation with side effects.
374
-
375
- From a method decorator
376
-
377
- The send action can decorate a local method. It runs after the method by
378
- default, waits for an eventu</pre>
382
+ operation completes. It</pre>
379
383
  </section>
380
384
  <section id="docs-_decorators-publish" data-doc-id="docs/_decorators/publish">
381
385
  <h2><a href="../docs/_decorators/publish.html">@publish</a></h2>
@@ -440,6 +444,13 @@ const updateUser = put(new Endpoint (&quot;users/42&quot;), bodyKey);
440
444
  @state()
441
445
  payload?: ApiResult ;
442
446
 
447
+ The same decorator adapts to a method:
448
+
449
+ @put(new Endpoint (&quot;users/42&quot;), bodyKey)
450
+ handleUpdate(payload?: ApiResult ) {
451
+ if (payload?.response?.ok) console.log(payload.result);
452
+ }
453
+
443
454
  To run the operation again from the component:
444
455
 
445
456
  async update() {
@@ -467,13 +478,7 @@ Pass explicit API configuration as the third argument:
467
478
  Import
468
479
 
469
480
  import { put, type ApiResult } from &quot;@supersoniks/concorde/decorators&quot;;
470
- import { DataProviderKey } from &quot;@supersoniks/concorde/dataProviderKey&quot;;
471
- import { Endpoint } from &quot;@supersoniks/concorde/utils/endpoint&quot;;
472
-
473
- See also
474
-
475
- - @post — options and triggers
476
- - @</pre>
481
+ impo</pre>
477
482
  </section>
478
483
  <section id="docs-_decorators-subscribe" data-doc-id="docs/_decorators/subscribe">
479
484
  <h2><a href="../docs/_decorators/subscribe.html">@subscribe</a></h2>
@@ -171,6 +171,17 @@ const usersEndpoint = new Endpoint (&quot;users&quot;);
171
171
  @state()
172
172
  payload?: ApiResult ;
173
173
 
174
+ The same decorator adapts to a method. The method receives the complete
175
+ ApiResult payload after each GET:
176
+
177
+ @get(usersEndpoint)
178
+ handleUsers(payload?: ApiResult ) {
179
+ if (!payload) return;
180
+
181
+ console.log(payload.response?.status);
182
+ console.log(payload.result);
183
+ }
184
+
174
185
  The first argument is always an
175
186
  Endpoint . API configuration is read
176
187
  from the HTML scope (serviceURL, token, etc.), so the component is usually
@@ -192,16 +203,7 @@ payload?: ApiResult ;
192
203
 
193
204
  async refresh() {
194
205
  const payload = await usersGet.refetch(this);
195
- console.log(payload?.result);
196
- }
197
-
198
- refetch(component) returns a Promise | undefined&gt; that resolves
199
- after the GET has completed.
200
-
201
- From a method decorator
202
-
203
- The refetch can decorate a local method. The default is after; if the
204
- method returns a Promise, the GET waits for its resol</pre>
206
+ console.log(</pre>
205
207
  </section>
206
208
  <section id="docs-_decorators-patch" data-doc-id="docs/_decorators/patch">
207
209
  <h2><a href="../docs/_decorators/patch.html">@patch</a></h2>
@@ -223,6 +225,13 @@ const patchUser = patch(new Endpoint (&quot;users/42&quot;), bodyKey);
223
225
  @state()
224
226
  payload?: ApiResult ;
225
227
 
228
+ The same decorator adapts to a method:
229
+
230
+ @patch(new Endpoint (&quot;users/42&quot;), bodyKey)
231
+ handlePatch(payload?: ApiResult ) {
232
+ if (payload?.response?.ok) console.log(payload.result);
233
+ }
234
+
226
235
  To run the operation again from the component:
227
236
 
228
237
  async savePatch() {
@@ -249,13 +258,7 @@ Pass explicit API configuration as the third argument:
249
258
 
250
259
  Import
251
260
 
252
- import { patch, type ApiResult } from &quot;@supersoniks/concorde/decorators&quot;;
253
- import { DataProviderKey } from &quot;@supersoniks/concorde/dataProviderKey&quot;;
254
- import { Endpoint } from &quot;@supersoniks/concorde/utils/endpoint&quot;;
255
-
256
- See also
257
-
258
- - @post —</pre>
261
+ import { patch, type ApiResult } from &quot;@supersoniks/</pre>
259
262
  </section>
260
263
  <section id="docs-_decorators-post" data-doc-id="docs/_decorators/post">
261
264
  <h2><a href="../docs/_decorators/post.html">@post</a></h2>
@@ -278,6 +281,13 @@ const createUser = post(new Endpoint (&quot;users&quot;), userBodyKey);
278
281
  @state()
279
282
  payload?: ApiResult ;
280
283
 
284
+ The same decorator adapts to a method and receives the complete payload:
285
+
286
+ @post(new Endpoint (&quot;users&quot;), userBodyKey)
287
+ handleCreate(payload?: ApiResult ) {
288
+ if (payload?.response?.ok) console.log(payload.result);
289
+ }
290
+
281
291
  The current body is read from userBodyKey. By default, the POST is sent when
282
292
  the component connects and after each body mutation. Mutations in the same
283
293
  frame are coalesced into one request.
@@ -298,13 +308,7 @@ async saveAgain() {
298
308
  }
299
309
 
300
310
  send() returns a Promise | undefined&gt; that resolves after the
301
- operation completes. It is useful for “Save” or “Retry” buttons and can repeat
302
- an operation with side effects.
303
-
304
- From a method decorator
305
-
306
- The send action can decorate a local method. It runs after the method by
307
- default, waits for an eventu</pre>
311
+ operation completes. It</pre>
308
312
  </section>
309
313
  <section id="docs-_decorators-put" data-doc-id="docs/_decorators/put">
310
314
  <h2><a href="../docs/_decorators/put.html">@put</a></h2>
@@ -326,6 +330,13 @@ const updateUser = put(new Endpoint (&quot;users/42&quot;), bodyKey);
326
330
  @state()
327
331
  payload?: ApiResult ;
328
332
 
333
+ The same decorator adapts to a method:
334
+
335
+ @put(new Endpoint (&quot;users/42&quot;), bodyKey)
336
+ handleUpdate(payload?: ApiResult ) {
337
+ if (payload?.response?.ok) console.log(payload.result);
338
+ }
339
+
329
340
  To run the operation again from the component:
330
341
 
331
342
  async update() {
@@ -353,13 +364,7 @@ Pass explicit API configuration as the third argument:
353
364
  Import
354
365
 
355
366
  import { put, type ApiResult } from &quot;@supersoniks/concorde/decorators&quot;;
356
- import { DataProviderKey } from &quot;@supersoniks/concorde/dataProviderKey&quot;;
357
- import { Endpoint } from &quot;@supersoniks/concorde/utils/endpoint&quot;;
358
-
359
- See also
360
-
361
- - @post — options and triggers
362
- - @</pre>
367
+ impo</pre>
363
368
  </section>
364
369
  <section id="docs-_misc-api-configuration" data-doc-id="docs/_misc/api-configuration">
365
370
  <h2><a href="../docs/_misc/api-configuration.html">API configuration</a></h2>
package/docs/index.html CHANGED
@@ -10,7 +10,7 @@
10
10
  <!-- <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
11
11
  -->
12
12
  <script src="https://cdn.jsdelivr.net/npm/marked@13.0.3"></script>
13
- <script type="module" crossorigin src="./assets/index-DURr6O71.js"></script>
13
+ <script type="module" crossorigin src="./assets/index-DpIkksht.js"></script>
14
14
  <link rel="stylesheet" crossorigin href="./assets/index-D2Q3JyQ6.css">
15
15
  </head>
16
16
  <body class="px-6 lg:px-20">
@@ -3137,9 +3137,7 @@ Shared data: Sharing data.
3137
3137
  - Keywords: Concorde, supersoniks, docs/_decorators/get, get, @get, decorator, ApiResult, undefined, payload.result, payload.response, payload.request,
3138
3138
 
3139
3139
  The first argument is always an
3140
- [, serviceURL, refetch(component),
3141
-
3142
-
3140
+ [, serviceURL, refetch(component)
3143
3141
 
3144
3142
  @get
3145
3143
 
@@ -3158,6 +3156,17 @@ const usersEndpoint = new Endpoint ("users");
3158
3156
  @state()
3159
3157
  payload?: ApiResult ;
3160
3158
 
3159
+ The same decorator adapts to a method. The method receives the complete
3160
+ ApiResult payload after each GET:
3161
+
3162
+ @get(usersEndpoint)
3163
+ handleUsers(payload?: ApiResult ) {
3164
+ if (!payload) return;
3165
+
3166
+ console.log(payload.response?.status);
3167
+ console.log(payload.result);
3168
+ }
3169
+
3161
3170
  The first argument is always an
3162
3171
  Endpoint . API configuration is read
3163
3172
  from the HTML scope (serviceURL, token, etc.), so the component is usually
@@ -3185,6 +3194,20 @@ async refresh() {
3185
3194
  refetch(component) returns a Promise | undefined> that resolves
3186
3195
  after the GET has completed.
3187
3196
 
3197
+ The named handle can also decorate a method and be reused for refetching:
3198
+
3199
+ const usersGet = get(new Endpoint ("users"));
3200
+
3201
+ @usersGet
3202
+ handleUsers(payload?: ApiResult ) {
3203
+ // ...
3204
+ }
3205
+
3206
+ @refetch(usersGet)
3207
+ reloadUsers() {
3208
+ // The GET runs and handleUsers receives its payload.
3209
+ }
3210
+
3188
3211
  From a method decorator
3189
3212
 
3190
3213
  The refetch can decorate a local method. The default is after; if the
@@ -3775,6 +3798,13 @@ const patchUser = patch(new Endpoint ("users/42"), bodyKey);
3775
3798
  @state()
3776
3799
  payload?: ApiResult ;
3777
3800
 
3801
+ The same decorator adapts to a method:
3802
+
3803
+ @patch(new Endpoint ("users/42"), bodyKey)
3804
+ handlePatch(payload?: ApiResult ) {
3805
+ if (payload?.response?.ok) console.log(payload.result);
3806
+ }
3807
+
3778
3808
  To run the operation again from the component:
3779
3809
 
3780
3810
  async savePatch() {
@@ -3842,6 +3872,13 @@ const createUser = post(new Endpoint ("users"), userBodyKey);
3842
3872
  @state()
3843
3873
  payload?: ApiResult ;
3844
3874
 
3875
+ The same decorator adapts to a method and receives the complete payload:
3876
+
3877
+ @post(new Endpoint ("users"), userBodyKey)
3878
+ handleCreate(payload?: ApiResult ) {
3879
+ if (payload?.response?.ok) console.log(payload.result);
3880
+ }
3881
+
3845
3882
  The current body is read from userBodyKey. By default, the POST is sent when
3846
3883
  the component connects and after each body mutation. Mutations in the same
3847
3884
  frame are coalesced into one request.
@@ -4011,6 +4048,13 @@ const updateUser = put(new Endpoint ("users/42"), bodyKey);
4011
4048
  @state()
4012
4049
  payload?: ApiResult ;
4013
4050
 
4051
+ The same decorator adapts to a method:
4052
+
4053
+ @put(new Endpoint ("users/42"), bodyKey)
4054
+ handleUpdate(payload?: ApiResult ) {
4055
+ if (payload?.response?.ok) console.log(payload.result);
4056
+ }
4057
+
4014
4058
  To run the operation again from the component:
4015
4059
 
4016
4060
  async update() {
@@ -17,6 +17,19 @@ const usersEndpoint = new Endpoint<User[]>("users");
17
17
  payload?: ApiResult<User[]>;
18
18
  ```
19
19
 
20
+ The same decorator adapts to a method. The method receives the complete
21
+ `ApiResult<T>` payload after each GET:
22
+
23
+ ```typescript
24
+ @get(usersEndpoint)
25
+ handleUsers(payload?: ApiResult<User[]>) {
26
+ if (!payload) return;
27
+
28
+ console.log(payload.response?.status);
29
+ console.log(payload.result);
30
+ }
31
+ ```
32
+
20
33
  The first argument is always an
21
34
  [`Endpoint<T>`](#docs/_misc/endpoint.md/endpoint). API configuration is read
22
35
  from the HTML scope (`serviceURL`, token, etc.), so the component is usually
@@ -46,6 +59,22 @@ async refresh() {
46
59
  `refetch(component)` returns a `Promise<ApiResult<T> | undefined>` that resolves
47
60
  after the GET has completed.
48
61
 
62
+ The named handle can also decorate a method and be reused for refetching:
63
+
64
+ ```typescript
65
+ const usersGet = get(new Endpoint<User[]>("users"));
66
+
67
+ @usersGet
68
+ handleUsers(payload?: ApiResult<User[]>) {
69
+ // ...
70
+ }
71
+
72
+ @refetch(usersGet)
73
+ reloadUsers() {
74
+ // The GET runs and handleUsers receives its payload.
75
+ }
76
+ ```
77
+
49
78
  ### From a method decorator
50
79
 
51
80
  The refetch can decorate a local method. The default is `after`; if the
@@ -116,6 +145,8 @@ import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
116
145
  <template>
117
146
  <docs-demo-sources for="demo-api-get"></docs-demo-sources>
118
147
  <demo-api-get></demo-api-get>
148
+ <docs-demo-sources for="demo-api-get-method"></docs-demo-sources>
149
+ <demo-api-get-method></demo-api-get-method>
119
150
  <docs-demo-sources for="demo-api-get-configuration-key"></docs-demo-sources>
120
151
  <demo-api-get-configuration-key></demo-api-get-configuration-key>
121
152
  </template>
@@ -16,6 +16,15 @@ const patchUser = patch(new Endpoint<User>("users/42"), bodyKey);
16
16
  payload?: ApiResult<User>;
17
17
  ```
18
18
 
19
+ The same decorator adapts to a method:
20
+
21
+ ```typescript
22
+ @patch(new Endpoint<User>("users/42"), bodyKey)
23
+ handlePatch(payload?: ApiResult<User>) {
24
+ if (payload?.response?.ok) console.log(payload.result);
25
+ }
26
+ ```
27
+
19
28
  To run the operation again from the component:
20
29
 
21
30
  ```typescript
@@ -17,6 +17,15 @@ const createUser = post(new Endpoint<User>("users"), userBodyKey);
17
17
  payload?: ApiResult<User>;
18
18
  ```
19
19
 
20
+ The same decorator adapts to a method and receives the complete payload:
21
+
22
+ ```typescript
23
+ @post(new Endpoint<User>("users"), userBodyKey)
24
+ handleCreate(payload?: ApiResult<User>) {
25
+ if (payload?.response?.ok) console.log(payload.result);
26
+ }
27
+ ```
28
+
20
29
  The current body is read from `userBodyKey`. By default, the POST is sent when
21
30
  the component connects and after each body mutation. Mutations in the same
22
31
  frame are coalesced into one request.
@@ -120,6 +129,8 @@ import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
120
129
  <template>
121
130
  <docs-demo-sources for="demo-api-post"></docs-demo-sources>
122
131
  <demo-api-post></demo-api-post>
132
+ <docs-demo-sources for="demo-api-post-method"></docs-demo-sources>
133
+ <demo-api-post-method></demo-api-post-method>
123
134
  <docs-demo-sources for="demo-api-post-dynamic"></docs-demo-sources>
124
135
  <demo-api-post-dynamic></demo-api-post-dynamic>
125
136
  </template>
@@ -16,6 +16,15 @@ const updateUser = put(new Endpoint<User>("users/42"), bodyKey);
16
16
  payload?: ApiResult<User>;
17
17
  ```
18
18
 
19
+ The same decorator adapts to a method:
20
+
21
+ ```typescript
22
+ @put(new Endpoint<User>("users/42"), bodyKey)
23
+ handleUpdate(payload?: ApiResult<User>) {
24
+ if (payload?.response?.ok) console.log(payload.result);
25
+ }
26
+ ```
27
+
19
28
  To run the operation again from the component:
20
29
 
21
30
  ```typescript