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