@supersoniks/concorde 4.9.9 → 4.9.92

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 (48) hide show
  1. package/build-infos.json +1 -1
  2. package/concorde-core.bundle.js +241 -241
  3. package/concorde-core.es.js +2931 -2851
  4. package/dist/concorde-core.bundle.js +241 -241
  5. package/dist/concorde-core.es.js +2931 -2851
  6. package/dist/js/core/decorators/api.js +146 -43
  7. package/dist/js/core/decorators/api.js.map +1 -1
  8. package/dist/js/decorators.js +4 -0
  9. package/dist/js/decorators.js.map +1 -1
  10. package/dist/types/core/decorators/api.d.ts +87 -60
  11. package/dist/types/core/decorators/api.d.ts.map +1 -1
  12. package/dist/types/decorators.d.ts +3 -1
  13. package/dist/types/decorators.d.ts.map +1 -1
  14. package/docs/assets/index-D2Q3JyQ6.css +1 -0
  15. package/docs/assets/{index-hElUgV9_.js → index-DURr6O71.js} +651 -736
  16. package/docs/crawl/docs/_decorators/get.html +89 -81
  17. package/docs/crawl/docs/_decorators/patch.html +43 -23
  18. package/docs/crawl/docs/_decorators/post.html +101 -72
  19. package/docs/crawl/docs/_decorators/put.html +44 -21
  20. package/docs/crawl/docs/_getting-started/ai-agents.html +45 -6
  21. package/docs/crawl/hubs/decorators.html +145 -70
  22. package/docs/crawl/hubs/remote-data.html +145 -70
  23. package/docs/index.html +2 -2
  24. package/docs/llms-full.txt +276 -147
  25. package/docs/llms.txt +4 -4
  26. package/docs/src/core/components/functional/queue/queue.md +0 -0
  27. package/docs/src/core/components/ui/button/button.md +0 -0
  28. package/docs/src/docs/_decorators/get.md +88 -80
  29. package/docs/src/docs/_decorators/patch.md +41 -25
  30. package/docs/src/docs/_decorators/post.md +104 -62
  31. package/docs/src/docs/_decorators/put.md +42 -24
  32. package/docs/src/docs/_getting-started/ai-agents.md +24 -4
  33. package/docs/src/docs/search/docs-search.json +182 -112
  34. package/docs/src/tsconfig.json +270 -267
  35. package/package.json +1 -1
  36. package/src/core/decorators/api.post.spec.ts +79 -1
  37. package/src/core/decorators/api.spec.ts +141 -1
  38. package/src/core/decorators/api.ts +330 -180
  39. package/src/decorators.ts +7 -0
  40. package/src/docs/_decorators/get.md +88 -80
  41. package/src/docs/_decorators/patch.md +41 -25
  42. package/src/docs/_decorators/post.md +104 -62
  43. package/src/docs/_decorators/put.md +42 -24
  44. package/src/docs/components/docs-demo-sources.ts +9 -14
  45. package/src/docs/example/decorators-demo-geo.ts +0 -21
  46. package/src/docs/example/decorators-demo-subscribe-publish-get-demos.ts +42 -133
  47. package/src/docs/search/docs-search.json +128 -133
  48. package/docs/assets/index-Bnp7gVaA.css +0 -1
@@ -4,8 +4,13 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>@get — Concorde</title>
7
- <meta name="description" content="Loads data through API.getDetailed. The decorated property is ApiResult&lt;T&gt; | null: request, response (or null for dataProvider(...) resolution without HTTP), and typed result.">
8
- <meta name="keywords" content="Concorde, supersoniks, docs/_decorators/get, get, @get, decorator, API.getDetailed, ApiResult | null, request, response, null, dataProvider(...), result, Endpoint, ApiResult">
7
+ <meta name="description" content="@get loads data and stores the result in an optional ApiResult&lt;T&gt; property.">
8
+ <meta name="keywords" content="Concorde, supersoniks, docs/_decorators/get, get, @get, decorator, ApiResult, undefined, payload.result, payload.response, payload.request,
9
+
10
+ The first argument is always an
11
+ [, serviceURL, refetch(component),
12
+
13
+ ">
9
14
  <meta name="concorde-doc-id" content="docs/_decorators/get">
10
15
  <link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_decorators/get.html">
11
16
  </head>
@@ -15,104 +20,107 @@
15
20
  </header>
16
21
  <main>
17
22
  <article>
18
- <p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @get</strong>. Loads data through API.getDetailed. The decorated property is ApiResult&lt;T&gt; | null: request, response (or null for dataProvider(...) resolution without HTTP), and typed result. <span>Doc ID: <code>docs/_decorators/get</code>. Keywords: Concorde, supersoniks, docs/_decorators/get, get, @get, decorator, API.getDetailed, ApiResult | null, request, response, null, dataProvider(...), result, Endpoint, ApiResult. URL: <a href="https://concorde.supersoniks.org/crawl/docs/_decorators/get.html">https://concorde.supersoniks.org/crawl/docs/_decorators/get.html</a>.</span></p>
23
+ <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
+
25
+ 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>
19
29
  <h1 id="get">@get</h1>
20
- <p>Loads data through <a href="../../core/utils/api.ts"><code>API.getDetailed</code></a>. The decorated property is <strong><code>ApiResult&lt;T&gt; | null</code></strong>: <code>request</code>, <code>response</code> (or <code>null</code> for <code>dataProvider(...)</code> resolution without HTTP), and typed <code>result</code>.</p>
21
- <p>Pass an <a href="../_misc/endpoint.html#endpoint"><code>Endpoint&lt;T&gt;</code></a> as the first argument. Import <code>get</code> and <code>ApiResult</code> from <code>@supersoniks/concorde/decorators</code>, and <code>Endpoint</code> from <code>@supersoniks/concorde/utils/endpoint</code>.</p>
22
- <h2 id="configuration">Configuration</h2>
30
+ <p><code>@get</code> loads data and stores the result in an optional <code>ApiResult&lt;T&gt;</code> property.
31
+ The property is <code>undefined</code> until a result is available.</p>
23
32
  <ul>
24
- <li><strong>Default:</strong> <code>HTML.getApiConfiguration(host)</code> (ancestor <code>serviceURL</code>, etc.).</li>
25
- <li><strong>Second argument:</strong> <code>DataProviderKey&lt;APIConfiguration&gt;</code> — config is read from the publisher at the resolved path; internal mutations trigger another GET. See <a href="../_misc/api-configuration.html#api-configuration">API configuration</a> for mock demos.</li>
33
+ <li><code>payload.result</code>: typed data;</li>
34
+ <li><code>payload.response</code>: the HTTP response;</li>
35
+ <li><code>payload.request</code>: the request that was sent.</li>
26
36
  </ul>
27
- <h2 id="dynamic-path">Dynamic path</h2>
28
- <p><code>${prop}</code> on the endpoint or config key is resolved on the host. While a placeholder is <code>null</code> or <code>undefined</code>, no GET runs. Optional <code>skipEmptyPlaceholder: true</code> also blocks <code>&quot;&quot;</code> (empty string only). Details: <a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a>.</p>
29
- <h2 id="options-getoptions">Options (<code>GetOptions</code>)</h2>
30
- <p>Pass as the <strong>second</strong> argument (scoped config) or <strong>third</strong> (with a configuration key). Same shape as send decorators where applicable:</p>
31
- <table>
32
- <thead>
33
- <tr>
34
- <th>Option</th>
35
- <th>Description</th>
36
- </tr>
37
- </thead>
38
- <tbody><tr>
39
- <td><code>skipEmptyPlaceholder</code></td>
40
- <td>Treat <code>&quot;&quot;</code> as not ready (see <a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path</a>).</td>
41
- </tr>
42
- <tr>
43
- <td><code>refetchEveryMs</code></td>
44
- <td>Automatic polling interval (ms). <code>0</code> or omitted = no polling.</td>
45
- </tr>
46
- <tr>
47
- <td><code>triggerKey</code></td>
48
- <td><code>DataProviderKey</code> — <code>PublisherManager.get(...).invalidate()</code> on that publisher re-runs the GET.</td>
49
- </tr>
50
- </tbody></table>
51
- <h3 id="manual-refetch-triggerkey">Manual refetch (<code>triggerKey</code>)</h3>
52
- <p>Same pattern as <a href="./post.html#post">@post</a>: a publisher acts as a <strong>signal</strong>, independent of the response payload.</p>
53
- <pre><code class="language-typescript">import { get, type ApiResult } from &quot;@supersoniks/concorde/decorators&quot;;
54
- import { Endpoint } from &quot;@supersoniks/concorde/utils/endpoint&quot;;
55
- import { DataProviderKey } from &quot;@supersoniks/concorde/dataProviderKey&quot;;
56
- import { dp } from &quot;@supersoniks/concorde/core/utils/PublisherProxy&quot;;
37
+ <h2 id="minimal-usage">Minimal usage</h2>
38
+ <pre><code class="language-typescript">const usersEndpoint = new Endpoint&lt;User[]&gt;(&quot;users&quot;);
57
39
 
58
- const geoCommunesEndpoint = new Endpoint&lt;GeoCommuneRow[]&gt;(
59
- &quot;communes?limit=5&amp;fields=nom,code&quot;,
60
- );
61
- const geoCommunesRefreshKey = new DataProviderKey&lt;void&gt;(
62
- &quot;docsDemoGeoCommunesRefresh&quot;,
63
- );
40
+ @get(usersEndpoint)
41
+ @state()
42
+ payload?: ApiResult&lt;User[]&gt;;
43
+ </code></pre>
44
+ <p>The first argument is always an
45
+ <a href="../_misc/endpoint.html#endpoint"><code>Endpoint&lt;T&gt;</code></a>. API configuration is read
46
+ from the HTML scope (<code>serviceURL</code>, token, etc.), so the component is usually
47
+ placed below an element that provides this configuration.</p>
48
+ <h2 id="refetching-a-get">Refetching a GET</h2>
49
+ <h3 id="from-the-component">From the component</h3>
50
+ <p>Keep the decorator in a constant to access <code>refetch(component)</code>. Refetch only
51
+ targets the instance passed as the argument, even before it has received a
52
+ result.</p>
53
+ <pre><code class="language-typescript">const usersGet = get(new Endpoint&lt;User[]&gt;(&quot;users&quot;));
64
54
 
65
- @get(geoCommunesEndpoint, apiConfigurationKey, {
66
- triggerKey: geoCommunesRefreshKey,
67
- })
55
+ @usersGet
68
56
  @state()
69
- payload: ApiResult&lt;GeoCommuneRow[]&gt; | null = null;
57
+ payload?: ApiResult&lt;User[]&gt;;
70
58
 
71
- // Same component or anywhere else:
72
- dp(geoCommunesRefreshKey).invalidate();
59
+ async refresh() {
60
+ const payload = await usersGet.refetch(this);
61
+ console.log(payload?.result);
62
+ }
63
+ </code></pre>
64
+ <p><code>refetch(component)</code> returns a <code>Promise&lt;ApiResult&lt;T&gt; | undefined&gt;</code> that resolves
65
+ after the GET has completed.</p>
66
+ <h3 id="from-a-method-decorator">From a method decorator</h3>
67
+ <p>The refetch can decorate a local method. The default is <code>after</code>; if the
68
+ method returns a Promise, the GET waits for its resolution. The decorated method
69
+ call also waits for the refetch to complete.</p>
70
+ <pre><code class="language-typescript">import { refetch } from &quot;@supersoniks/concorde/decorators&quot;;
71
+
72
+ @refetch(usersGet)
73
+ async reload() {
74
+ this.userId = &quot;42&quot;;
75
+ }
76
+ </code></pre>
77
+ <p>Use <code>{ when: &quot;before&quot; }</code> when the GET must complete before the method runs:</p>
78
+ <pre><code class="language-typescript">@refetch(usersGet, { when: &quot;before&quot; })
79
+ reloadBefore() {
80
+ // The refetch has completed before this method runs.
81
+ }
82
+ </code></pre>
83
+ <p>The method decorator adds an explicit trigger; changes to dynamic endpoint
84
+ properties and configuration publishers keep their existing automatic behavior.</p>
85
+ <h2 id="options-getoptions">Options (<code>GetOptions</code>)</h2>
86
+ <p>Options are the second argument, or the third argument when an API
87
+ configuration key is provided.</p>
88
+ <ul>
89
+ <li><code>skipEmptyPlaceholder</code>: blocks the GET when <code>${prop}</code> is <code>&quot;&quot;</code>.</li>
90
+ <li><code>refetchEveryMs</code>: automatically runs the GET again after this interval
91
+ (milliseconds). Omit the option, or use <code>0</code>, to disable polling.</li>
92
+ <li><code>triggerKey</code>: a publisher whose <code>invalidate()</code> runs the GET again.</li>
93
+ </ul>
94
+ <p>With a configuration key, use:</p>
95
+ <pre><code class="language-typescript">@get(usersEndpoint, apiConfigurationKey)
73
96
  </code></pre>
74
- <p>Prefer <code>triggerKey</code> over mutating the API configuration publisher when you only want to <strong>reload the same URL</strong> — no need to touch <code>serviceURL</code>, tokens, etc.</p>
75
- <p>The docs mock adds an <strong><code>X-Fetched-At</code></strong> response header on <code>/docs-mock-api/geo/communes</code> so live demos can show when the last fetch happened (<code>response.headers.get(&quot;X-Fetched-At&quot;)</code>).</p>
76
97
  <h2 id="when-the-get-runs-again">When the GET runs again</h2>
77
98
  <ul>
78
- <li>A referenced Lit property changes (endpoint path and/or config key contains <code>${...}</code>).</li>
79
- <li><code>set</code> on the active configuration publisher (<code>onInternalMutation</code>).</li>
80
- <li><code>triggerKey</code> publisher <code>invalidate()</code>.</li>
81
- <li><code>refetchEveryMs</code> polling (after each successful fetch).</li>
99
+ <li>when the component connects and configuration is available;</li>
100
+ <li>when a property used in <code>${...}</code> changes;</li>
101
+ <li>when a configuration publisher changes;</li>
102
+ <li>when the <code>triggerKey</code> publisher is invalidated;</li>
103
+ <li>after each response when <code>refetchEveryMs</code> is set.</li>
82
104
  </ul>
105
+ <p>See <a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a> for
106
+ dynamic path details.</p>
83
107
  <h2 id="import">Import</h2>
84
108
  <pre><code class="language-typescript">import { get, type ApiResult } from &quot;@supersoniks/concorde/decorators&quot;;
85
- import { Endpoint } from &quot;@supersoniks/concorde/utils/endpoint&quot;;
86
109
  import { DataProviderKey } from &quot;@supersoniks/concorde/dataProviderKey&quot;;
110
+ import { Endpoint } from &quot;@supersoniks/concorde/utils/endpoint&quot;;
87
111
  </code></pre>
88
- <h2 id="minimal-example">Minimal example</h2>
89
- <p>Same demo service as <a href="../../core/components/functional/queue/queue.demo.ts"><code>sonic-queue</code></a> (<code>/docs-mock-api/geo/</code>). Publisher setup lives in <code>decorators-demo-geo.ts</code> and <code>decorators-demo-subscribe-publish-get-demos.ts</code>.</p>
90
- <pre><code class="language-typescript">@get(new Endpoint&lt;User&gt;(&quot;users/${userId}&quot;))
91
- @state()
92
- payload: ApiResult&lt;User&gt; | null = null;
93
- </code></pre>
94
- <h2 id="live-demos">Live demos</h2>
95
- <p><code>@get</code> with <strong><code>triggerKey</code></strong> — refresh button + <code>X-Fetched-At</code> timestamp in the UI:</p>
112
+ <h2 id="demos">Demos</h2>
96
113
  <pre><code>&lt;docs-demo-sources for=&quot;demo-api-get&quot;&gt;&lt;/docs-demo-sources&gt;
97
114
  &lt;demo-api-get&gt;&lt;/demo-api-get&gt;
98
- </code></pre>
99
- <p>Dynamic config and endpoint path. Manual refetch is triggered <strong>from a separate component</strong> (same <code>triggerKey</code> publisher):</p>
100
- <pre><code>&lt;docs-demo-sources for=&quot;demo-api-get-configuration-key&quot;&gt;&lt;/docs-demo-sources&gt;
115
+ &lt;docs-demo-sources for=&quot;demo-api-get-configuration-key&quot;&gt;&lt;/docs-demo-sources&gt;
101
116
  &lt;demo-api-get-configuration-key&gt;&lt;/demo-api-get-configuration-key&gt;
102
- &lt;demo-api-get-refresh-remote&gt;&lt;/demo-api-get-refresh-remote&gt;
103
117
  </code></pre>
104
- <p>Scoped <code>@get</code> with <code>@publish</code> / <code>@subscribe</code> on the payload (see <a href="./publish.html#publish">@publish</a> and <a href="./subscribe.html#subscribe">@subscribe</a>) — wrap under an ancestor with <code>serviceURL=&quot;/docs-mock-api/geo/&quot;</code>:</p>
105
- <pre><code>&lt;div serviceURL=&quot;/docs-mock-api/geo/&quot;&gt;
106
- &lt;docs-demo-sources for=&quot;demo-api-get-publish-subscribe&quot;&gt;&lt;/docs-demo-sources&gt;
107
- &lt;demo-api-get-publish-subscribe&gt;&lt;/demo-api-get-publish-subscribe&gt;
108
- &lt;/div&gt;
109
- </code></pre>
110
- <p>Stale responses are ignored if the path or generation changed before the request finished.</p>
111
- <h2 id="see-also">See also</h2>
112
- <ul>
113
- <li><a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a></li>
114
- <li><a href="./post.html#post">@post</a> · <a href="./put.html#put">@put</a> · <a href="./patch.html#patch">@patch</a> — send decorators (same path rules)</li>
115
- </ul>
118
+ <p>See <a href="./post.html#post">@post</a>,
119
+ <a href="./put.html#put">@put</a>, and
120
+ <a href="./patch.html#patch">@patch</a> for write operations.</p>
121
+ <h2 id="advanced">Advanced</h2>
122
+ <p>External invalidation is currently available through <code>triggerKey</code>; it is kept
123
+ out of the main usage examples.</p>
116
124
 
117
125
  </article>
118
126
  </main>
@@ -4,8 +4,10 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>@patch — Concorde</title>
7
- <meta name="description" content="Sends data through API.patchDetailed. Same model as @post: decorated property is ApiResult&lt;T&gt; | null (request, response, result).">
8
- <meta name="keywords" content="Concorde, supersoniks, docs/_decorators/patch, patch, @patch, decorator, API.patchDetailed, ApiResult | null, request, response, result, Endpoint, DataProviderKey, ApiResult, @supersoniks/concorde/decorators">
7
+ <meta name="description" content="@patch applies a partial update with the body from a publisher. It uses the">
8
+ <meta name="keywords" content="Concorde, supersoniks, docs/_decorators/patch, patch, @patch, decorator, Endpoint, DataProviderKey, ApiResult, send(component),
9
+
10
+ , when: &quot;before&quot;, autoPostOnBodyMutation: false, autoPostOnBodyMutation, skipIfBodyMissing">
9
11
  <meta name="concorde-doc-id" content="docs/_decorators/patch">
10
12
  <link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_decorators/patch.html">
11
13
  </head>
@@ -15,34 +17,52 @@
15
17
  </header>
16
18
  <main>
17
19
  <article>
18
- <p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @patch</strong>. Sends data through API.patchDetailed. Same model as @post: decorated property is ApiResult&lt;T&gt; | null (request, response, result). <span>Doc ID: <code>docs/_decorators/patch</code>. Keywords: Concorde, supersoniks, docs/_decorators/patch, patch, @patch, decorator, API.patchDetailed, ApiResult | null, request, response, result, Endpoint, DataProviderKey, ApiResult, @supersoniks/concorde/decorators. URL: <a href="https://concorde.supersoniks.org/crawl/docs/_decorators/patch.html">https://concorde.supersoniks.org/crawl/docs/_decorators/patch.html</a>.</span></p>
20
+ <p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @patch</strong>. @patch applies a partial update with the body from a publisher. It uses the <span>Doc ID: <code>docs/_decorators/patch</code>. Keywords: Concorde, supersoniks, docs/_decorators/patch, patch, @patch, decorator, Endpoint, DataProviderKey, ApiResult, send(component),
21
+
22
+ , when: &quot;before&quot;, autoPostOnBodyMutation: false, autoPostOnBodyMutation, skipIfBodyMissing. URL: <a href="https://concorde.supersoniks.org/crawl/docs/_decorators/patch.html">https://concorde.supersoniks.org/crawl/docs/_decorators/patch.html</a>.</span></p>
19
23
  <h1 id="patch">@patch</h1>
20
- <p>Sends data through <a href="../../core/utils/api.ts"><code>API.patchDetailed</code></a>. Same model as <a href="./post.html#post">@post</a>: decorated property is <strong><code>ApiResult&lt;T&gt; | null</code></strong> (<code>request</code>, <code>response</code>, <code>result</code>).</p>
21
- <p>Pass an <a href="../_misc/endpoint.html#endpoint"><code>Endpoint&lt;T&gt;</code></a> and a <code>DataProviderKey</code> for the <strong>request body</strong>. Import <code>patch</code> and <code>ApiResult</code> from <code>@supersoniks/concorde/decorators</code>.</p>
22
- <h2 id="configuration">Configuration</h2>
23
- <p>Same as <a href="./post.html#post">@post</a> / <a href="./get.html#get">@get</a>: scoped <code>HTML.getApiConfiguration(host)</code> or <code>DataProviderKey&lt;APIConfiguration&gt;</code> as third argument.</p>
24
- <h2 id="options-patchoptions">Options (<code>PatchOptions</code>)</h2>
25
- <p>Same shape as <code>PostOptions</code> on <a href="./post.html#post">@post</a> (<code>ApiSendOptions</code>): <code>refetchEveryMs</code>, <code>skipIfBodyMissing</code>, <code>autoPostOnBodyMutation</code>, <code>triggerKey</code>, <code>skipEmptyPlaceholder</code>. See <a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a> for <code>${sessionId}</code> and empty-string behaviour.</p>
24
+ <p><code>@patch</code> applies a partial update with the body from a publisher. It uses the
25
+ same model as <a href="./post.html#post">@post</a>:
26
+ <code>Endpoint&lt;T&gt;</code>, <code>DataProviderKey&lt;B&gt;</code>, <code>ApiResult&lt;T&gt;</code>, options, and the
27
+ <code>send(component)</code> handle.</p>
28
+ <h2 id="minimal-usage">Minimal usage</h2>
29
+ <pre><code class="language-typescript">const bodyKey = new DataProviderKey&lt;Partial&lt;User&gt;&gt;(&quot;users.patch&quot;);
30
+ const patchUser = patch(new Endpoint&lt;User&gt;(&quot;users/42&quot;), bodyKey);
31
+
32
+ @patchUser
33
+ @state()
34
+ payload?: ApiResult&lt;User&gt;;
35
+ </code></pre>
36
+ <p>To run the operation again from the component:</p>
37
+ <pre><code class="language-typescript">async savePatch() {
38
+ await patchUser.send(this);
39
+ }
40
+ </code></pre>
41
+ <p><code>send(component)</code> returns a Promise resolved after the PATCH completes. See
42
+ <a href="./post.html#post">@post</a> for the method-decorator form and the
43
+ <code>when: &quot;before&quot;</code> option.</p>
44
+ <p>The PATCH is also sent automatically when the body mutates, unless
45
+ <code>autoPostOnBodyMutation: false</code> is set. The available options are described in
46
+ <a href="./post.html#post">@post</a>:</p>
47
+ <ul>
48
+ <li><code>autoPostOnBodyMutation</code></li>
49
+ <li><code>skipIfBodyMissing</code></li>
50
+ <li><code>refetchEveryMs</code></li>
51
+ <li><code>skipEmptyPlaceholder</code></li>
52
+ <li><code>triggerKey</code></li>
53
+ </ul>
54
+ <p>Pass explicit API configuration as the third argument:</p>
55
+ <pre><code class="language-typescript">@patch(endpoint, bodyKey, apiConfigurationKey)
56
+ </code></pre>
26
57
  <h2 id="import">Import</h2>
27
58
  <pre><code class="language-typescript">import { patch, type ApiResult } from &quot;@supersoniks/concorde/decorators&quot;;
28
- import { Endpoint } from &quot;@supersoniks/concorde/utils/endpoint&quot;;
29
59
  import { DataProviderKey } from &quot;@supersoniks/concorde/dataProviderKey&quot;;
30
- </code></pre>
31
- <h2 id="example">Example</h2>
32
- <pre><code class="language-typescript">const patchBodyKey = new DataProviderKey&amp;lt;Partial&amp;lt;Resource&amp;gt;&amp;gt;(&quot;resourcePatch&quot;);
33
-
34
- @patch(
35
- new Endpoint&amp;lt;Resource, { resourceId: string }&amp;gt;(&quot;resources/${resourceId}&quot;),
36
- patchBodyKey,
37
- { skipEmptyPlaceholder: true },
38
- )
39
- @state()
40
- payload?: ApiResult&amp;lt;Resource&amp;gt; | null;
60
+ import { Endpoint } from &quot;@supersoniks/concorde/utils/endpoint&quot;;
41
61
  </code></pre>
42
62
  <h2 id="see-also">See also</h2>
43
63
  <ul>
44
- <li><a href="./post.html#post">@post</a> — POST (live demos)</li>
45
- <li><a href="./put.html#put">@put</a> — full replacement (PUT)</li>
64
+ <li><a href="./post.html#post">@post</a> — options and triggers</li>
65
+ <li><a href="./put.html#put">@put</a> — full replacement</li>
46
66
  <li><a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a></li>
47
67
  </ul>
48
68
 
@@ -4,8 +4,14 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>@post — Concorde</title>
7
- <meta name="description" content="Sends data through API.postDetailed. The decorated property is ApiResult&lt;T&gt; | null: request, response, and typed result.">
8
- <meta name="keywords" content="Concorde, supersoniks, docs/_decorators/post, post, @post, decorator, API.postDetailed, ApiResult | null, request, response, result, Endpoint, DataProviderKey, ApiResult, @supersoniks/concorde/decorators">
7
+ <meta name="description" content="@post sends the contents of a publisher and stores the response in an">
8
+ <meta name="keywords" content="Concorde, supersoniks, docs/_decorators/post, post, @post, decorator, ApiResult, undefined, Endpoint, DataProviderKey,
9
+
10
+ The current body is read from , send(component),
11
+
12
+ , returns a ,
13
+
14
+ Use ">
9
15
  <meta name="concorde-doc-id" content="docs/_decorators/post">
10
16
  <link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_decorators/post.html">
11
17
  </head>
@@ -15,86 +21,109 @@
15
21
  </header>
16
22
  <main>
17
23
  <article>
18
- <p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @post</strong>. Sends data through API.postDetailed. The decorated property is ApiResult&lt;T&gt; | null: request, response, and typed result. <span>Doc ID: <code>docs/_decorators/post</code>. Keywords: Concorde, supersoniks, docs/_decorators/post, post, @post, decorator, API.postDetailed, ApiResult | null, request, response, result, Endpoint, DataProviderKey, ApiResult, @supersoniks/concorde/decorators. URL: <a href="https://concorde.supersoniks.org/crawl/docs/_decorators/post.html">https://concorde.supersoniks.org/crawl/docs/_decorators/post.html</a>.</span></p>
24
+ <p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @post</strong>. @post sends the contents of a publisher and stores the response in an <span>Doc ID: <code>docs/_decorators/post</code>. Keywords: Concorde, supersoniks, docs/_decorators/post, post, @post, decorator, ApiResult, undefined, Endpoint, DataProviderKey,
25
+
26
+ The current body is read from , send(component),
27
+
28
+ , returns a ,
29
+
30
+ Use . URL: <a href="https://concorde.supersoniks.org/crawl/docs/_decorators/post.html">https://concorde.supersoniks.org/crawl/docs/_decorators/post.html</a>.</span></p>
19
31
  <h1 id="post">@post</h1>
20
- <p>Sends data through <a href="../../core/utils/api.ts"><code>API.postDetailed</code></a>. The decorated property is <strong><code>ApiResult&lt;T&gt; | null</code></strong>: <code>request</code>, <code>response</code>, and typed <code>result</code>.</p>
21
- <p>Pass an <a href="../_misc/endpoint.html#endpoint"><code>Endpoint&lt;T&gt;</code></a> as the first argument and a <code>DataProviderKey</code> for the <strong>request body</strong> as the second. Import <code>post</code> and <code>ApiResult</code> from <code>@supersoniks/concorde/decorators</code>, and <code>Endpoint</code> from <code>@supersoniks/concorde/utils/endpoint</code>.</p>
22
- <h2 id="configuration">Configuration</h2>
23
- <p>Same as <a href="./get.html#get">@get</a>: scoped <code>HTML.getApiConfiguration(host)</code> by default, or <code>DataProviderKey&lt;APIConfiguration&gt;</code> as third argument. See <a href="../_misc/api-configuration.html#api-configuration">API configuration</a> for mock demos.</p>
24
- <h2 id="optional-postoptions-third-or-fourth-argument">Optional <code>PostOptions</code> (third or fourth argument)</h2>
25
- <table>
26
- <thead>
27
- <tr>
28
- <th>Option</th>
29
- <th>Description</th>
30
- </tr>
31
- </thead>
32
- <tbody><tr>
33
- <td><code>refetchEveryMs</code></td>
34
- <td>Re-post on an interval (ms).</td>
35
- </tr>
36
- <tr>
37
- <td><code>skipIfBodyMissing</code></td>
38
- <td>Skip when body publisher is <code>null</code>/<code>undefined</code> (default: <code>true</code>).</td>
39
- </tr>
40
- <tr>
41
- <td><code>autoPostOnBodyMutation</code></td>
42
- <td>Re-post when the body publisher mutates (default: <code>true</code>). <code>false</code> = manual via <code>triggerKey.invalidate()</code>.</td>
43
- </tr>
44
- <tr>
45
- <td><code>skipEmptyPlaceholder</code></td>
46
- <td>If <code>true</code>, a placeholder resolved to <code>&#39;&#39;</code> blocks the request (empty string only — not <code>0</code> or <code>false</code>). See <a href="../_misc/dynamic-path.html#dynamic-path">Dynamic paths</a>.</td>
47
- </tr>
48
- <tr>
49
- <td><code>triggerKey</code></td>
50
- <td><code>DataProviderKey</code> — <code>invalidate()</code> re-runs the POST with the current body.</td>
51
- </tr>
52
- </tbody></table>
53
- <h2 id="when-the-post-runs-again">When the POST runs again</h2>
32
+ <p><code>@post</code> sends the contents of a publisher and stores the response in an
33
+ optional <code>ApiResult&lt;T&gt;</code> property. The property is <code>undefined</code> until a result
34
+ is available.</p>
35
+ <h2 id="minimal-usage">Minimal usage</h2>
36
+ <p>Pass an <code>Endpoint&lt;T&gt;</code> and a <code>DataProviderKey&lt;B&gt;</code> for the request body.</p>
37
+ <pre><code class="language-typescript">const userBodyKey = new DataProviderKey&lt;CreateUser&gt;(&quot;users.form&quot;);
38
+ const createUser = post(new Endpoint&lt;User&gt;(&quot;users&quot;), userBodyKey);
39
+
40
+ @createUser
41
+ @state()
42
+ payload?: ApiResult&lt;User&gt;;
43
+ </code></pre>
44
+ <p>The current body is read from <code>userBodyKey</code>. By default, the POST is sent when
45
+ the component connects and after each body mutation. Mutations in the same
46
+ frame are coalesced into one request.</p>
47
+ <p>API configuration is read from the HTML scope, as with
48
+ <a href="./get.html#get">@get</a>.</p>
49
+ <h2 id="sending-the-post-again">Sending the POST again</h2>
50
+ <h3 id="from-the-component">From the component</h3>
51
+ <p>Keep the decorator to access <code>send(component)</code>. The body is read again when the
52
+ operation runs.</p>
53
+ <pre><code class="language-typescript">async saveAgain() {
54
+ const payload = await createUser.send(this);
55
+ console.log(payload?.result);
56
+ }
57
+ </code></pre>
58
+ <p><code>send()</code> returns a <code>Promise&lt;ApiResult&lt;T&gt; | undefined&gt;</code> that resolves after the
59
+ operation completes. It is useful for “Save” or “Retry” buttons and can repeat
60
+ an operation with side effects.</p>
61
+ <h3 id="from-a-method-decorator">From a method decorator</h3>
62
+ <p>The send action can decorate a local method. It runs after the method by
63
+ default, waits for an eventual Promise to resolve, and the decorated method
64
+ call waits for the send to complete:</p>
65
+ <pre><code class="language-typescript">import { send } from &quot;@supersoniks/concorde/decorators&quot;;
66
+
67
+ @send(createUser)
68
+ async save() {
69
+ // Prepare local state or validate the form.
70
+ }
71
+ </code></pre>
72
+ <p>Use <code>{ when: &quot;before&quot; }</code> when the send must complete before the method runs:</p>
73
+ <pre><code class="language-typescript">@send(createUser, { when: &quot;before&quot; })
74
+ saveBefore() {
75
+ // The POST has completed before this method runs.
76
+ }
77
+ </code></pre>
78
+ <p>The method decorator adds an explicit send. If the method also mutates the body
79
+ publisher, set <code>autoPostOnBodyMutation: false</code> when the decorated method must
80
+ be the only trigger.</p>
81
+ <h2 id="options-postoptions">Options (<code>PostOptions</code>)</h2>
82
+ <p>Options are the third argument, or the fourth argument when a configuration key
83
+ is provided.</p>
54
84
  <ul>
55
- <li>Body publisher <code>onInternalMutation</code> when <code>autoPostOnBodyMutation</code> is <code>true</code> (default). Plusieurs mutations synchrones dans la même frame sont regroupées en <strong>un seul POST</strong> via <code>requestAnimationFrame</code>.</li>
56
- <li>Endpoint path dependency changes (<code>${sessionId}</code> on the host).</li>
57
- <li>Configuration publisher mutation.</li>
58
- <li><code>triggerKey</code> publisher <code>invalidate()</code>.</li>
59
- <li><code>refetchEveryMs</code> timer (if set).</li>
85
+ <li><code>autoPostOnBodyMutation</code>: send after a body mutation (default: <code>true</code>). Set
86
+ it to <code>false</code> to use <code>send()</code>.</li>
87
+ <li><code>skipIfBodyMissing</code>: skip when the body is <code>null</code> or <code>undefined</code> (default:
88
+ <code>true</code>).</li>
89
+ <li><code>refetchEveryMs</code>: repeat the POST at this interval. Use it only when
90
+ repeating the operation is intended.</li>
91
+ <li><code>skipEmptyPlaceholder</code>: block the request when a <code>${...}</code> placeholder is
92
+ <code>&quot;&quot;</code>.</li>
93
+ <li><code>triggerKey</code>: a publisher whose <code>invalidate()</code> sends the POST again.</li>
94
+ </ul>
95
+ <p>With a configuration key:</p>
96
+ <pre><code class="language-typescript">@post(endpoint, userBodyKey, apiConfigurationKey)
97
+ </code></pre>
98
+ <p>See <a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a> for
99
+ dynamic path details.</p>
100
+ <h2 id="when-the-post-is-sent">When the POST is sent</h2>
101
+ <ul>
102
+ <li>when the component connects and the body and configuration are available;</li>
103
+ <li>after a body mutation, unless <code>autoPostOnBodyMutation: false</code>;</li>
104
+ <li>when a property used in <code>${...}</code> changes;</li>
105
+ <li>when a configuration publisher changes;</li>
106
+ <li>when the <code>triggerKey</code> publisher is invalidated;</li>
107
+ <li>when <code>send()</code> is called;</li>
108
+ <li>after each response when <code>refetchEveryMs</code> is set.</li>
60
109
  </ul>
61
110
  <h2 id="import">Import</h2>
62
- <pre><code class="language-typescript">import { post, publish, type ApiResult } from &quot;@supersoniks/concorde/decorators&quot;;
63
- import { Endpoint } from &quot;@supersoniks/concorde/utils/endpoint&quot;;
111
+ <pre><code class="language-typescript">import { post, type ApiResult } from &quot;@supersoniks/concorde/decorators&quot;;
64
112
  import { DataProviderKey } from &quot;@supersoniks/concorde/dataProviderKey&quot;;
113
+ import { Endpoint } from &quot;@supersoniks/concorde/utils/endpoint&quot;;
65
114
  </code></pre>
66
- <h2 id="minimal-example">Minimal example</h2>
67
- <p>Mock service: <code>POST /docs-mock-api/api/register</code> (same route as <a href="../../core/components/functional/submit/submit.html#submit"><code>sonic-submit</code></a> demos). Publisher setup lives in <code>decorators-demo-post.ts</code>.</p>
68
- <pre><code class="language-typescript">const syncRequest = new DataProviderKey&amp;lt;SyncRequest&amp;gt;(&quot;syncRequest&quot;);
69
- const syncTrigger = new DataProviderKey&amp;lt;number&amp;gt;(&quot;syncTrigger&quot;);
70
-
71
- @post(
72
- new Endpoint&amp;lt;SyncResponse, { sessionId: string }&amp;gt;(&quot;sessions/${sessionId}/sync&quot;),
73
- syncRequest,
74
- { triggerKey: syncTrigger },
75
- )
76
- @state()
77
- payload?: ApiResult&amp;lt;SyncResponse&amp;gt; | null;
78
- </code></pre>
79
- <h2 id="live-demos">Live demos</h2>
115
+ <h2 id="demos">Demos</h2>
80
116
  <pre><code>&lt;docs-demo-sources for=&quot;demo-api-post&quot;&gt;&lt;/docs-demo-sources&gt;
81
117
  &lt;demo-api-post&gt;&lt;/demo-api-post&gt;
82
- </code></pre>
83
- <p>Dynamic endpoint path — changing <code>sessionId</code> on the host re-runs the POST (<code>POST /docs-mock-api/api/sessions/{id}/sync</code>):</p>
84
- <pre><code>&lt;docs-demo-sources for=&quot;demo-api-post-dynamic&quot;&gt;&lt;/docs-demo-sources&gt;
118
+ &lt;docs-demo-sources for=&quot;demo-api-post-dynamic&quot;&gt;&lt;/docs-demo-sources&gt;
85
119
  &lt;demo-api-post-dynamic&gt;&lt;/demo-api-post-dynamic&gt;
86
120
  </code></pre>
87
- <p><code>@post</code> + <code>@publish</code> on the same property (see <a href="./publish.html#publish">@publish</a>):</p>
88
- <pre><code>&lt;docs-demo-sources for=&quot;demo-api-post-publish&quot;&gt;&lt;/docs-demo-sources&gt;
89
- &lt;demo-api-post-publish&gt;&lt;/demo-api-post-publish&gt;
90
- </code></pre>
91
- <p>Stale responses are ignored if the path or generation changed before the request finished.</p>
92
- <p><strong>Note:</strong> plusieurs composants <code>@post</code> sur la même page qui partagent le même <code>bodyKey</code> enverront chacun une requête à chaque mutation du body — utiliser une clé par composant (voir les deux démos live ci-dessus).</p>
93
- <p>Path placeholders (<code>${sessionId}</code>, …): <a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a>.</p>
94
- <h2 id="see-also">See also</h2>
95
- <ul>
96
- <li><a href="./put.html#put">@put</a> · <a href="./patch.html#patch">@patch</a> — same decorator model, <code>PUT</code> / <code>PATCH</code> via <code>putDetailed</code> / <code>patchDetailed</code></li>
97
- </ul>
121
+ <p>See <a href="./put.html#put">@put</a> and
122
+ <a href="./patch.html#patch">@patch</a>: they use the same model with a
123
+ different HTTP method.</p>
124
+ <h2 id="advanced">Advanced</h2>
125
+ <p>External invalidation is currently available through <code>triggerKey</code>; it is kept
126
+ out of the main usage examples.</p>
98
127
 
99
128
  </article>
100
129
  </main>