@supersoniks/concorde 4.9.7 → 4.9.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-infos.json +1 -1
- package/concorde-core.bundle.js +265 -265
- package/concorde-core.es.js +4600 -4385
- package/dist/concorde-core.bundle.js +265 -265
- package/dist/concorde-core.es.js +4600 -4385
- package/dist/js/core/components/functional/queue/queue.js +25 -153
- package/dist/js/core/components/functional/queue/queue.js.map +1 -1
- package/dist/js/core/components/ui/_css/scroll.js +2 -0
- package/dist/js/core/components/ui/_css/scroll.js.map +1 -1
- package/dist/js/core/decorators/api.js +92 -2
- package/dist/js/core/decorators/api.js.map +1 -1
- package/dist/js/core/utils/SafariScrollGuard.js +384 -0
- package/dist/js/core/utils/SafariScrollGuard.js.map +1 -0
- package/dist/js/decorators.js +4 -0
- package/dist/js/decorators.js.map +1 -1
- package/dist/js/utils.js +3 -0
- package/dist/js/utils.js.map +1 -1
- package/dist/types/core/components/functional/queue/queue.d.ts +8 -24
- package/dist/types/core/components/functional/queue/queue.d.ts.map +1 -1
- package/dist/types/core/components/ui/_css/scroll.d.ts.map +1 -1
- package/dist/types/core/decorators/api.d.ts +82 -60
- package/dist/types/core/decorators/api.d.ts.map +1 -1
- package/dist/types/core/utils/SafariScrollGuard.d.ts +36 -0
- package/dist/types/core/utils/SafariScrollGuard.d.ts.map +1 -0
- package/dist/types/decorators.d.ts +3 -1
- package/dist/types/decorators.d.ts.map +1 -1
- package/dist/types/utils.d.ts +1 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/docs/assets/index-BL6WVF7g.css +1 -0
- package/docs/assets/{index-hElUgV9_.js → index-DVn8AeyA.js} +572 -555
- package/docs/crawl/docs/_decorators/get.html +64 -81
- package/docs/crawl/docs/_decorators/patch.html +35 -23
- package/docs/crawl/docs/_decorators/post.html +72 -72
- package/docs/crawl/docs/_decorators/put.html +36 -21
- package/docs/crawl/docs/_getting-started/ai-agents.html +45 -6
- package/docs/crawl/hubs/decorators.html +141 -69
- package/docs/crawl/hubs/remote-data.html +141 -69
- package/docs/index.html +2 -2
- package/docs/llms-full.txt +203 -149
- package/docs/llms.txt +4 -4
- package/docs/src/core/components/functional/queue/queue.md +0 -0
- package/docs/src/core/components/ui/button/button.md +0 -0
- package/docs/src/docs/_decorators/get.md +55 -81
- package/docs/src/docs/_decorators/patch.md +36 -25
- package/docs/src/docs/_decorators/post.md +71 -62
- package/docs/src/docs/_decorators/put.md +37 -24
- package/docs/src/docs/_getting-started/ai-agents.md +24 -4
- package/docs/src/docs/search/docs-search.json +151 -1
- package/docs/src/tsconfig.json +3 -0
- package/package.json +6 -2
- package/src/core/components/functional/queue/queue.ts +33 -164
- package/src/core/components/ui/_css/scroll.ts +3 -0
- package/src/core/decorators/api.post.spec.ts +79 -1
- package/src/core/decorators/api.spec.ts +100 -1
- package/src/core/decorators/api.ts +252 -138
- package/src/core/utils/SafariScrollGuard.ts +429 -0
- package/src/decorators.ts +7 -0
- package/src/docs/_decorators/get.md +81 -80
- package/src/docs/_decorators/patch.md +36 -25
- package/src/docs/_decorators/post.md +99 -62
- package/src/docs/_decorators/put.md +37 -24
- package/src/docs/components/docs-demo-sources.ts +1 -6
- package/src/docs/example/decorators-demo-geo.ts +0 -21
- package/src/docs/example/decorators-demo-subscribe-publish-get-demos.ts +41 -132
- package/src/docs/search/docs-search.json +156 -241
- package/src/docs/tailwind/css/tailwind.css +0 -0
- package/src/tsconfig.json +3 -0
- package/src/tsconfig.tsbuildinfo +1 -1
- package/src/utils.ts +13 -0
- package/vite.config.mts +4 -0
- package/vitest.setup.ts +22 -0
- 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="
|
|
8
|
-
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/get, get, @get, decorator,
|
|
7
|
+
<meta name="description" content="@get loads data and stores the result in an ApiResult<T> | null property.">
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/get, get, @get, decorator, ApiResult | null, payload.result, payload.response, payload.request,
|
|
9
|
+
|
|
10
|
+
The first argument is always an
|
|
11
|
+
[, serviceURL, refetch(component),
|
|
12
|
+
|
|
13
|
+
## Options (, skipEmptyPlaceholder">
|
|
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,82 @@
|
|
|
15
20
|
</header>
|
|
16
21
|
<main>
|
|
17
22
|
<article>
|
|
18
|
-
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @get</strong>.
|
|
23
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @get</strong>. @get loads data and stores the result in an ApiResult<T> | null property. <span>Doc ID: <code>docs/_decorators/get</code>. Keywords: Concorde, supersoniks, docs/_decorators/get, get, @get, decorator, ApiResult | null, payload.result, payload.response, payload.request,
|
|
24
|
+
|
|
25
|
+
The first argument is always an
|
|
26
|
+
[, serviceURL, refetch(component),
|
|
27
|
+
|
|
28
|
+
## Options (, skipEmptyPlaceholder. 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>
|
|
21
|
-
<p>Pass an <a href="../_misc/endpoint.html#endpoint"><code>Endpoint<T></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 <code>ApiResult<T> | null</code> property.</p>
|
|
23
31
|
<ul>
|
|
24
|
-
<li><
|
|
25
|
-
<li><
|
|
32
|
+
<li><code>payload.result</code>: typed data;</li>
|
|
33
|
+
<li><code>payload.response</code>: the HTTP response;</li>
|
|
34
|
+
<li><code>payload.request</code>: the request that was sent.</li>
|
|
26
35
|
</ul>
|
|
27
|
-
<h2 id="
|
|
28
|
-
<
|
|
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>""</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 "@supersoniks/concorde/decorators";
|
|
54
|
-
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
|
|
55
|
-
import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
|
|
56
|
-
import { dp } from "@supersoniks/concorde/core/utils/PublisherProxy";
|
|
36
|
+
<h2 id="minimal-usage">Minimal usage</h2>
|
|
37
|
+
<pre><code class="language-typescript">const usersEndpoint = new Endpoint<User[]>("users");
|
|
57
38
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
39
|
+
@get(usersEndpoint)
|
|
40
|
+
@state()
|
|
41
|
+
payload: ApiResult<User[]> | null = null;
|
|
42
|
+
</code></pre>
|
|
43
|
+
<p>The first argument is always an
|
|
44
|
+
<a href="../_misc/endpoint.html#endpoint"><code>Endpoint<T></code></a>. API configuration is read
|
|
45
|
+
from the HTML scope (<code>serviceURL</code>, token, etc.), so the component is usually
|
|
46
|
+
placed below an element that provides this configuration.</p>
|
|
47
|
+
<h2 id="refetching-a-get">Refetching a GET</h2>
|
|
48
|
+
<h3 id="from-the-component">From the component</h3>
|
|
49
|
+
<p>Keep the decorator in a constant to access <code>refetch(component)</code>. Refetch only
|
|
50
|
+
targets the instance passed as the argument, even before it has received a
|
|
51
|
+
result.</p>
|
|
52
|
+
<pre><code class="language-typescript">const usersGet = get(new Endpoint<User[]>("users"));
|
|
64
53
|
|
|
65
|
-
@
|
|
66
|
-
triggerKey: geoCommunesRefreshKey,
|
|
67
|
-
})
|
|
54
|
+
@usersGet
|
|
68
55
|
@state()
|
|
69
|
-
payload: ApiResult<
|
|
56
|
+
payload: ApiResult<User[]> | null = null;
|
|
70
57
|
|
|
71
|
-
|
|
72
|
-
|
|
58
|
+
refresh() {
|
|
59
|
+
usersGet.refetch(this);
|
|
60
|
+
}
|
|
61
|
+
</code></pre>
|
|
62
|
+
<h2 id="options-getoptions">Options (<code>GetOptions</code>)</h2>
|
|
63
|
+
<p>Options are the second argument, or the third argument when an API
|
|
64
|
+
configuration key is provided.</p>
|
|
65
|
+
<ul>
|
|
66
|
+
<li><code>skipEmptyPlaceholder</code>: blocks the GET when <code>${prop}</code> is <code>""</code>.</li>
|
|
67
|
+
<li><code>refetchEveryMs</code>: automatically runs the GET again after this interval
|
|
68
|
+
(milliseconds). Omit the option, or use <code>0</code>, to disable polling.</li>
|
|
69
|
+
</ul>
|
|
70
|
+
<p>With a configuration key, use:</p>
|
|
71
|
+
<pre><code class="language-typescript">@get(usersEndpoint, apiConfigurationKey)
|
|
73
72
|
</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("X-Fetched-At")</code>).</p>
|
|
76
73
|
<h2 id="when-the-get-runs-again">When the GET runs again</h2>
|
|
77
74
|
<ul>
|
|
78
|
-
<li>
|
|
79
|
-
<li
|
|
80
|
-
<li
|
|
81
|
-
<li
|
|
75
|
+
<li>when the component connects and configuration is available;</li>
|
|
76
|
+
<li>when a property used in <code>${...}</code> changes;</li>
|
|
77
|
+
<li>when a configuration publisher changes;</li>
|
|
78
|
+
<li>after each response when <code>refetchEveryMs</code> is set.</li>
|
|
82
79
|
</ul>
|
|
80
|
+
<p>See <a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a> for
|
|
81
|
+
dynamic path details.</p>
|
|
83
82
|
<h2 id="import">Import</h2>
|
|
84
83
|
<pre><code class="language-typescript">import { get, type ApiResult } from "@supersoniks/concorde/decorators";
|
|
85
|
-
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
|
|
86
84
|
import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
|
|
85
|
+
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
|
|
87
86
|
</code></pre>
|
|
88
|
-
<h2 id="
|
|
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<User>("users/${userId}"))
|
|
91
|
-
@state()
|
|
92
|
-
payload: ApiResult<User> | 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>
|
|
87
|
+
<h2 id="demos">Demos</h2>
|
|
96
88
|
<pre><code><docs-demo-sources for="demo-api-get"></docs-demo-sources>
|
|
97
89
|
<demo-api-get></demo-api-get>
|
|
98
|
-
|
|
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><docs-demo-sources for="demo-api-get-configuration-key"></docs-demo-sources>
|
|
90
|
+
<docs-demo-sources for="demo-api-get-configuration-key"></docs-demo-sources>
|
|
101
91
|
<demo-api-get-configuration-key></demo-api-get-configuration-key>
|
|
102
|
-
<demo-api-get-refresh-remote></demo-api-get-refresh-remote>
|
|
103
|
-
</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="/docs-mock-api/geo/"</code>:</p>
|
|
105
|
-
<pre><code><div serviceURL="/docs-mock-api/geo/">
|
|
106
|
-
<docs-demo-sources for="demo-api-get-publish-subscribe"></docs-demo-sources>
|
|
107
|
-
<demo-api-get-publish-subscribe></demo-api-get-publish-subscribe>
|
|
108
|
-
</div>
|
|
109
92
|
</code></pre>
|
|
110
|
-
<p>
|
|
111
|
-
<
|
|
112
|
-
<
|
|
113
|
-
<
|
|
114
|
-
<
|
|
115
|
-
|
|
93
|
+
<p>See <a href="./post.html#post">@post</a>,
|
|
94
|
+
<a href="./put.html#put">@put</a>, and
|
|
95
|
+
<a href="./patch.html#patch">@patch</a> for write operations.</p>
|
|
96
|
+
<h2 id="advanced">Advanced</h2>
|
|
97
|
+
<p>External invalidation is currently available through <code>triggerKey</code>; it is kept
|
|
98
|
+
out of the main usage examples.</p>
|
|
116
99
|
|
|
117
100
|
</article>
|
|
118
101
|
</main>
|
|
@@ -4,8 +4,8 @@
|
|
|
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="
|
|
8
|
-
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/patch, patch, @patch, decorator,
|
|
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), autoPostOnBodyMutation: false, autoPostOnBodyMutation, skipIfBodyMissing, refetchEveryMs, skipEmptyPlaceholder">
|
|
9
9
|
<meta name="concorde-doc-id" content="docs/_decorators/patch">
|
|
10
10
|
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_decorators/patch.html">
|
|
11
11
|
</head>
|
|
@@ -15,34 +15,46 @@
|
|
|
15
15
|
</header>
|
|
16
16
|
<main>
|
|
17
17
|
<article>
|
|
18
|
-
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @patch</strong>.
|
|
18
|
+
<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), autoPostOnBodyMutation: false, autoPostOnBodyMutation, skipIfBodyMissing, refetchEveryMs, skipEmptyPlaceholder. 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
19
|
<h1 id="patch">@patch</h1>
|
|
20
|
-
<p
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
<h2 id="
|
|
25
|
-
<
|
|
20
|
+
<p><code>@patch</code> applies a partial update with the body from a publisher. It uses the
|
|
21
|
+
same model as <a href="./post.html#post">@post</a>:
|
|
22
|
+
<code>Endpoint<T></code>, <code>DataProviderKey<B></code>, <code>ApiResult<T></code>, options, and the
|
|
23
|
+
<code>send(component)</code> handle.</p>
|
|
24
|
+
<h2 id="minimal-usage">Minimal usage</h2>
|
|
25
|
+
<pre><code class="language-typescript">const bodyKey = new DataProviderKey<Partial<User>>("users.patch");
|
|
26
|
+
const patchUser = patch(new Endpoint<User>("users/42"), bodyKey);
|
|
27
|
+
|
|
28
|
+
@patchUser
|
|
29
|
+
@state()
|
|
30
|
+
payload: ApiResult<User> | null = null;
|
|
31
|
+
</code></pre>
|
|
32
|
+
<p>To run the operation again from the component:</p>
|
|
33
|
+
<pre><code class="language-typescript">savePatch() {
|
|
34
|
+
patchUser.send(this);
|
|
35
|
+
}
|
|
36
|
+
</code></pre>
|
|
37
|
+
<p>The PATCH is also sent automatically when the body mutates, unless
|
|
38
|
+
<code>autoPostOnBodyMutation: false</code> is set. The available options are described in
|
|
39
|
+
<a href="./post.html#post">@post</a>:</p>
|
|
40
|
+
<ul>
|
|
41
|
+
<li><code>autoPostOnBodyMutation</code></li>
|
|
42
|
+
<li><code>skipIfBodyMissing</code></li>
|
|
43
|
+
<li><code>refetchEveryMs</code></li>
|
|
44
|
+
<li><code>skipEmptyPlaceholder</code></li>
|
|
45
|
+
</ul>
|
|
46
|
+
<p>Pass explicit API configuration as the third argument:</p>
|
|
47
|
+
<pre><code class="language-typescript">@patch(endpoint, bodyKey, apiConfigurationKey)
|
|
48
|
+
</code></pre>
|
|
26
49
|
<h2 id="import">Import</h2>
|
|
27
50
|
<pre><code class="language-typescript">import { patch, type ApiResult } from "@supersoniks/concorde/decorators";
|
|
28
|
-
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
|
|
29
51
|
import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
|
|
30
|
-
|
|
31
|
-
<h2 id="example">Example</h2>
|
|
32
|
-
<pre><code class="language-typescript">const patchBodyKey = new DataProviderKey&lt;Partial&lt;Resource&gt;&gt;("resourcePatch");
|
|
33
|
-
|
|
34
|
-
@patch(
|
|
35
|
-
new Endpoint&lt;Resource, { resourceId: string }&gt;("resources/${resourceId}"),
|
|
36
|
-
patchBodyKey,
|
|
37
|
-
{ skipEmptyPlaceholder: true },
|
|
38
|
-
)
|
|
39
|
-
@state()
|
|
40
|
-
payload?: ApiResult&lt;Resource&gt; | null;
|
|
52
|
+
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
|
|
41
53
|
</code></pre>
|
|
42
54
|
<h2 id="see-also">See also</h2>
|
|
43
55
|
<ul>
|
|
44
|
-
<li><a href="./post.html#post">@post</a> —
|
|
45
|
-
<li><a href="./put.html#put">@put</a> — full replacement
|
|
56
|
+
<li><a href="./post.html#post">@post</a> — options and triggers</li>
|
|
57
|
+
<li><a href="./put.html#put">@put</a> — full replacement</li>
|
|
46
58
|
<li><a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a></li>
|
|
47
59
|
</ul>
|
|
48
60
|
|
|
@@ -4,8 +4,12 @@
|
|
|
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="
|
|
8
|
-
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/post, post, @post, decorator,
|
|
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 | null, Endpoint, DataProviderKey,
|
|
9
|
+
|
|
10
|
+
The current body is read from , send(component),
|
|
11
|
+
|
|
12
|
+
, PostOptions, autoPostOnBodyMutation, true">
|
|
9
13
|
<meta name="concorde-doc-id" content="docs/_decorators/post">
|
|
10
14
|
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_decorators/post.html">
|
|
11
15
|
</head>
|
|
@@ -15,86 +19,82 @@
|
|
|
15
19
|
</header>
|
|
16
20
|
<main>
|
|
17
21
|
<article>
|
|
18
|
-
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @post</strong>.
|
|
22
|
+
<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 | null, Endpoint, DataProviderKey,
|
|
23
|
+
|
|
24
|
+
The current body is read from , send(component),
|
|
25
|
+
|
|
26
|
+
, PostOptions, autoPostOnBodyMutation, true. 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
27
|
<h1 id="post">@post</h1>
|
|
20
|
-
<p
|
|
21
|
-
<
|
|
22
|
-
<h2 id="
|
|
23
|
-
<p>
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
</
|
|
31
|
-
</
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<
|
|
35
|
-
</
|
|
36
|
-
<
|
|
37
|
-
<
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
</
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<
|
|
50
|
-
<
|
|
51
|
-
</
|
|
52
|
-
</
|
|
53
|
-
<
|
|
28
|
+
<p><code>@post</code> sends the contents of a publisher and stores the response in an
|
|
29
|
+
<code>ApiResult<T> | null</code> property.</p>
|
|
30
|
+
<h2 id="minimal-usage">Minimal usage</h2>
|
|
31
|
+
<p>Pass an <code>Endpoint<T></code> and a <code>DataProviderKey<B></code> for the request body.</p>
|
|
32
|
+
<pre><code class="language-typescript">const userBodyKey = new DataProviderKey<CreateUser>("users.form");
|
|
33
|
+
const createUser = post(new Endpoint<User>("users"), userBodyKey);
|
|
34
|
+
|
|
35
|
+
@createUser
|
|
36
|
+
@state()
|
|
37
|
+
payload: ApiResult<User> | null = null;
|
|
38
|
+
</code></pre>
|
|
39
|
+
<p>The current body is read from <code>userBodyKey</code>. By default, the POST is sent when
|
|
40
|
+
the component connects and after each body mutation. Mutations in the same
|
|
41
|
+
frame are coalesced into one request.</p>
|
|
42
|
+
<p>API configuration is read from the HTML scope, as with
|
|
43
|
+
<a href="./get.html#get">@get</a>.</p>
|
|
44
|
+
<h2 id="sending-the-post-again">Sending the POST again</h2>
|
|
45
|
+
<h3 id="from-the-component">From the component</h3>
|
|
46
|
+
<p>Keep the decorator to access <code>send(component)</code>. The body is read again when the
|
|
47
|
+
operation runs.</p>
|
|
48
|
+
<pre><code class="language-typescript">saveAgain() {
|
|
49
|
+
createUser.send(this);
|
|
50
|
+
}
|
|
51
|
+
</code></pre>
|
|
52
|
+
<p><code>send()</code> is useful for “Save” or “Retry” buttons. It can repeat an operation
|
|
53
|
+
with side effects.</p>
|
|
54
|
+
<h2 id="options-postoptions">Options (<code>PostOptions</code>)</h2>
|
|
55
|
+
<p>Options are the third argument, or the fourth argument when a configuration key
|
|
56
|
+
is provided.</p>
|
|
57
|
+
<ul>
|
|
58
|
+
<li><code>autoPostOnBodyMutation</code>: send after a body mutation (default: <code>true</code>). Set
|
|
59
|
+
it to <code>false</code> to use <code>send()</code>.</li>
|
|
60
|
+
<li><code>skipIfBodyMissing</code>: skip when the body is <code>null</code> or <code>undefined</code> (default:
|
|
61
|
+
<code>true</code>).</li>
|
|
62
|
+
<li><code>refetchEveryMs</code>: repeat the POST at this interval. Use it only when
|
|
63
|
+
repeating the operation is intended.</li>
|
|
64
|
+
<li><code>skipEmptyPlaceholder</code>: block the request when a <code>${...}</code> placeholder is
|
|
65
|
+
<code>""</code>.</li>
|
|
66
|
+
</ul>
|
|
67
|
+
<p>With a configuration key:</p>
|
|
68
|
+
<pre><code class="language-typescript">@post(endpoint, userBodyKey, apiConfigurationKey)
|
|
69
|
+
</code></pre>
|
|
70
|
+
<p>See <a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a> for
|
|
71
|
+
dynamic path details.</p>
|
|
72
|
+
<h2 id="when-the-post-is-sent">When the POST is sent</h2>
|
|
54
73
|
<ul>
|
|
55
|
-
<li>
|
|
56
|
-
<li>
|
|
57
|
-
<li>
|
|
58
|
-
<li
|
|
59
|
-
<li
|
|
74
|
+
<li>when the component connects and the body and configuration are available;</li>
|
|
75
|
+
<li>after a body mutation, unless <code>autoPostOnBodyMutation: false</code>;</li>
|
|
76
|
+
<li>when a property used in <code>${...}</code> changes;</li>
|
|
77
|
+
<li>when a configuration publisher changes;</li>
|
|
78
|
+
<li>when <code>send()</code> is called;</li>
|
|
79
|
+
<li>after each response when <code>refetchEveryMs</code> is set.</li>
|
|
60
80
|
</ul>
|
|
61
81
|
<h2 id="import">Import</h2>
|
|
62
|
-
<pre><code class="language-typescript">import { post,
|
|
63
|
-
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
|
|
82
|
+
<pre><code class="language-typescript">import { post, type ApiResult } from "@supersoniks/concorde/decorators";
|
|
64
83
|
import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
|
|
84
|
+
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
|
|
65
85
|
</code></pre>
|
|
66
|
-
<h2 id="
|
|
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&lt;SyncRequest&gt;("syncRequest");
|
|
69
|
-
const syncTrigger = new DataProviderKey&lt;number&gt;("syncTrigger");
|
|
70
|
-
|
|
71
|
-
@post(
|
|
72
|
-
new Endpoint&lt;SyncResponse, { sessionId: string }&gt;("sessions/${sessionId}/sync"),
|
|
73
|
-
syncRequest,
|
|
74
|
-
{ triggerKey: syncTrigger },
|
|
75
|
-
)
|
|
76
|
-
@state()
|
|
77
|
-
payload?: ApiResult&lt;SyncResponse&gt; | null;
|
|
78
|
-
</code></pre>
|
|
79
|
-
<h2 id="live-demos">Live demos</h2>
|
|
86
|
+
<h2 id="demos">Demos</h2>
|
|
80
87
|
<pre><code><docs-demo-sources for="demo-api-post"></docs-demo-sources>
|
|
81
88
|
<demo-api-post></demo-api-post>
|
|
82
|
-
|
|
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><docs-demo-sources for="demo-api-post-dynamic"></docs-demo-sources>
|
|
89
|
+
<docs-demo-sources for="demo-api-post-dynamic"></docs-demo-sources>
|
|
85
90
|
<demo-api-post-dynamic></demo-api-post-dynamic>
|
|
86
91
|
</code></pre>
|
|
87
|
-
<p
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
</
|
|
91
|
-
<p>
|
|
92
|
-
|
|
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>
|
|
92
|
+
<p>See <a href="./put.html#put">@put</a> and
|
|
93
|
+
<a href="./patch.html#patch">@patch</a>: they use the same model with a
|
|
94
|
+
different HTTP method.</p>
|
|
95
|
+
<h2 id="advanced">Advanced</h2>
|
|
96
|
+
<p>External invalidation is currently available through <code>triggerKey</code>; it is kept
|
|
97
|
+
out of the main usage examples.</p>
|
|
98
98
|
|
|
99
99
|
</article>
|
|
100
100
|
</main>
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>@put — Concorde</title>
|
|
7
|
-
<meta name="description" content="
|
|
8
|
-
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/put, put, @put, decorator,
|
|
7
|
+
<meta name="description" content="@put replaces a resource with the body from a publisher. It uses exactly the">
|
|
8
|
+
<meta name="keywords" content="Concorde, supersoniks, docs/_decorators/put, put, @put, decorator, Endpoint, DataProviderKey, ApiResult, send(component), autoPostOnBodyMutation: false, autoPostOnBodyMutation, skipIfBodyMissing, refetchEveryMs, skipEmptyPlaceholder">
|
|
9
9
|
<meta name="concorde-doc-id" content="docs/_decorators/put">
|
|
10
10
|
<link rel="canonical" href="https://concorde.supersoniks.org/crawl/docs/_decorators/put.html">
|
|
11
11
|
</head>
|
|
@@ -15,32 +15,47 @@
|
|
|
15
15
|
</header>
|
|
16
16
|
<main>
|
|
17
17
|
<article>
|
|
18
|
-
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @put</strong>.
|
|
18
|
+
<p class="doc-lead" id="doc-summary"><strong>Concorde decorator — @put</strong>. @put replaces a resource with the body from a publisher. It uses exactly the <span>Doc ID: <code>docs/_decorators/put</code>. Keywords: Concorde, supersoniks, docs/_decorators/put, put, @put, decorator, Endpoint, DataProviderKey, ApiResult, send(component), autoPostOnBodyMutation: false, autoPostOnBodyMutation, skipIfBodyMissing, refetchEveryMs, skipEmptyPlaceholder. URL: <a href="https://concorde.supersoniks.org/crawl/docs/_decorators/put.html">https://concorde.supersoniks.org/crawl/docs/_decorators/put.html</a>.</span></p>
|
|
19
19
|
<h1 id="put">@put</h1>
|
|
20
|
-
<p
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
<h2 id="
|
|
25
|
-
<
|
|
20
|
+
<p><code>@put</code> replaces a resource with the body from a publisher. It uses exactly the
|
|
21
|
+
same model as <a href="./post.html#post">@post</a>:
|
|
22
|
+
<code>Endpoint<T></code>, <code>DataProviderKey<B></code>, <code>ApiResult<T></code>, options, and the
|
|
23
|
+
<code>send(component)</code> handle.</p>
|
|
24
|
+
<h2 id="minimal-usage">Minimal usage</h2>
|
|
25
|
+
<pre><code class="language-typescript">const bodyKey = new DataProviderKey<UpdateUser>("users.form");
|
|
26
|
+
const updateUser = put(new Endpoint<User>("users/42"), bodyKey);
|
|
27
|
+
|
|
28
|
+
@updateUser
|
|
29
|
+
@state()
|
|
30
|
+
payload: ApiResult<User> | null = null;
|
|
31
|
+
</code></pre>
|
|
32
|
+
<p>To run the operation again from the component:</p>
|
|
33
|
+
<pre><code class="language-typescript">update() {
|
|
34
|
+
updateUser.send(this);
|
|
35
|
+
}
|
|
36
|
+
</code></pre>
|
|
37
|
+
<p>The PUT is also sent automatically when the body mutates, unless
|
|
38
|
+
<code>autoPostOnBodyMutation: false</code> is set. See
|
|
39
|
+
<a href="./post.html#post">@post</a> for the option details:</p>
|
|
40
|
+
<ul>
|
|
41
|
+
<li><code>autoPostOnBodyMutation</code></li>
|
|
42
|
+
<li><code>skipIfBodyMissing</code></li>
|
|
43
|
+
<li><code>refetchEveryMs</code></li>
|
|
44
|
+
<li><code>skipEmptyPlaceholder</code></li>
|
|
45
|
+
</ul>
|
|
46
|
+
<p>Pass explicit API configuration as the third argument:</p>
|
|
47
|
+
<pre><code class="language-typescript">@put(endpoint, bodyKey, apiConfigurationKey)
|
|
48
|
+
</code></pre>
|
|
26
49
|
<h2 id="import">Import</h2>
|
|
27
50
|
<pre><code class="language-typescript">import { put, type ApiResult } from "@supersoniks/concorde/decorators";
|
|
28
|
-
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
|
|
29
51
|
import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
|
|
52
|
+
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
|
|
30
53
|
</code></pre>
|
|
31
|
-
<h2 id="example">Example</h2>
|
|
32
|
-
<pre><code class="language-typescript">const bodyKey = new DataProviderKey&lt;UpdatePayload&gt;("resourceBody");
|
|
33
|
-
|
|
34
|
-
@put(new Endpoint&lt;Resource, { resourceId: string }&gt;("resources/${resourceId}"), bodyKey)
|
|
35
|
-
@state()
|
|
36
|
-
payload?: ApiResult&lt;Resource&gt; | null;
|
|
37
|
-
</code></pre>
|
|
38
|
-
<p>Changing <code>resourceId</code> on the host re-runs the PUT when the path becomes ready — see <a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a>.</p>
|
|
39
54
|
<h2 id="see-also">See also</h2>
|
|
40
55
|
<ul>
|
|
41
|
-
<li><a href="./post.html#post">@post</a> —
|
|
42
|
-
<li><a href="./patch.html#patch">@patch</a> — partial update
|
|
43
|
-
<li><a href="../_misc/
|
|
56
|
+
<li><a href="./post.html#post">@post</a> — options and triggers</li>
|
|
57
|
+
<li><a href="./patch.html#patch">@patch</a> — partial update</li>
|
|
58
|
+
<li><a href="../_misc/dynamic-path.html#dynamic-path">Dynamic path placeholders</a></li>
|
|
44
59
|
</ul>
|
|
45
60
|
|
|
46
61
|
</article>
|