@supersoniks/concorde 4.6.0 → 4.7.0
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/.gitlab-ci.yml +23 -0
- package/README.md +106 -55
- package/ai/AGENTS.md +52 -0
- package/ai/README.md +30 -0
- package/ai/cursor/rules/concorde-menu.mdc +15 -0
- package/ai/cursor/rules/concorde-scope.mdc +14 -0
- package/ai/cursor/rules/concorde-theme.mdc +13 -0
- package/ai/cursor/rules/concorde.mdc +49 -0
- package/ai/jetbrains/rules/concorde.md +39 -0
- package/ai/skills/concorde/SKILL.md +220 -0
- package/ai/skills/concorde-get-set-dp/SKILL.md +194 -0
- package/ai/skills/concorde-imports/SKILL.md +78 -0
- package/ai/skills/concorde-menu/SKILL.md +74 -0
- package/ai/skills/concorde-scope/SKILL.md +70 -0
- package/ai/skills/concorde-theme/SKILL.md +46 -0
- package/build-infos.json +1 -1
- package/concorde-core.bundle.js +127 -127
- package/concorde-core.es.js +1435 -1364
- package/dist/altcha-widget.js +2662 -0
- package/dist/concorde-core.bundle.js +127 -127
- package/dist/concorde-core.es.js +1435 -1364
- package/dist/docs-mock-api-sw.js +589 -0
- package/dist/docs-mock-api-sw.js.map +7 -0
- package/docs/altcha-widget.js +2662 -0
- package/docs/assets/index-D9pxaQYK.js +7508 -0
- package/docs/assets/index-t0-i22oI.css +1 -0
- package/docs/docs-mock-api-sw.js +589 -0
- package/docs/docs-mock-api-sw.js.map +7 -0
- package/docs/index.html +2 -2
- package/docs/src/core/components/functional/fetch/fetch.md +13 -11
- package/docs/src/core/components/functional/if/if.md +4 -11
- package/docs/src/core/components/functional/list/list.md +60 -194
- package/docs/src/core/components/functional/queue/queue.md +70 -85
- package/docs/src/core/components/functional/router/router.md +62 -97
- package/docs/src/core/components/functional/states/states.md +2 -2
- package/docs/src/core/components/functional/submit/submit.md +86 -55
- package/docs/src/core/components/ui/captcha/captcha.md +2 -2
- package/docs/src/core/components/ui/card/card.md +1 -1
- package/docs/src/core/components/ui/form/checkbox/checkbox.md +5 -32
- package/docs/src/core/components/ui/form/input/input.md +5 -30
- package/docs/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +6 -4
- package/docs/src/core/components/ui/form/radio/radio.md +5 -32
- package/docs/src/core/components/ui/form/select/select.md +5 -31
- package/docs/src/core/components/ui/form/switch/switch.md +5 -32
- package/docs/src/core/components/ui/loader/loader.md +1 -13
- package/docs/src/core/components/ui/table/table.md +3 -3
- package/docs/src/docs/_core-concept/dataFlow.md +73 -0
- package/docs/src/docs/_core-concept/subscriber.md +9 -10
- package/docs/src/docs/_decorators/ancestor-attribute.md +4 -3
- package/docs/src/docs/_decorators/auto-subscribe.md +19 -16
- package/docs/src/docs/_decorators/bind.md +20 -17
- package/docs/src/docs/_decorators/get.md +7 -4
- package/docs/src/docs/_decorators/handle.md +171 -0
- package/docs/src/docs/_decorators/on-assign.md +99 -73
- package/docs/src/docs/_decorators/publish.md +2 -1
- package/docs/src/docs/_decorators/subscribe.md +70 -9
- package/docs/src/docs/_decorators/wait-for-ancestors.md +13 -10
- package/docs/src/docs/_directives/sub.md +91 -0
- package/docs/src/docs/_getting-started/ai-agents.md +56 -0
- package/docs/src/docs/_getting-started/concorde-manual-install.md +133 -0
- package/docs/src/docs/_getting-started/concorde-outside.md +13 -123
- package/docs/src/docs/_getting-started/create-a-component.md +2 -0
- package/docs/src/docs/_getting-started/my-first-component.md +236 -0
- package/docs/src/docs/_getting-started/my-first-subscriber.md +29 -83
- package/docs/src/docs/_getting-started/pubsub.md +21 -134
- package/docs/src/docs/_getting-started/start.md +26 -18
- package/docs/src/docs/_misc/api-configuration.md +79 -0
- package/docs/src/docs/_misc/dataProviderKey.md +38 -5
- package/docs/src/docs/_misc/docs-mock-api.md +60 -0
- package/docs/src/docs/_misc/endpoint.md +2 -1
- package/docs/src/docs/_misc/html-integration.md +13 -0
- package/docs/src/docs/search/docs-search.json +4163 -873
- package/docs/src/tsconfig.json +380 -317
- package/gitlab/job_tests.sh +55 -0
- package/package.json +34 -3
- package/public/altcha-widget.js +2662 -0
- package/public/docs-mock-api-sw.js +589 -0
- package/public/docs-mock-api-sw.js.map +7 -0
- package/scripts/ai-init.mjs +167 -0
- package/scripts/docs-mock-api-vite-plugin.ts +116 -0
- package/scripts/docs-open-in-editor-plugin.ts +130 -0
- package/scripts/pre-publish.mjs +2 -1
- package/src/core/components/functional/example/example.ts +1 -1
- package/src/core/components/functional/fetch/fetch.md +13 -11
- package/src/core/components/functional/if/if.md +4 -11
- package/src/core/components/functional/list/list.demo.ts +4 -4
- package/src/core/components/functional/list/list.md +60 -194
- package/src/core/components/functional/list/list.ts +8 -7
- package/src/core/components/functional/queue/queue.demo.ts +1 -1
- package/src/core/components/functional/queue/queue.md +70 -85
- package/src/core/components/functional/queue/queue.ts +4 -4
- package/src/core/components/functional/router/router.md +62 -97
- package/src/core/components/functional/router/router.ts +1 -1
- package/src/core/components/functional/states/states.md +2 -2
- package/src/core/components/functional/submit/submit.md +86 -55
- package/src/core/components/functional/submit/submit.ts +10 -3
- package/src/core/components/ui/captcha/captcha.md +2 -2
- package/src/core/components/ui/card/card.md +1 -1
- package/src/core/components/ui/form/checkbox/checkbox.md +5 -32
- package/src/core/components/ui/form/input/input.md +5 -30
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +6 -4
- package/src/core/components/ui/form/radio/radio.md +5 -32
- package/src/core/components/ui/form/select/select.md +5 -31
- package/src/core/components/ui/form/switch/switch.md +5 -32
- package/src/core/components/ui/loader/loader.md +1 -13
- package/src/core/components/ui/table/table.md +3 -3
- package/src/core/directives/DataProvider.sub.spec.ts +96 -0
- package/src/core/directives/DataProvider.ts +109 -40
- package/src/core/utils/PublisherProxy.ts +33 -18
- package/src/core/utils/dataProviderKey.ts +23 -0
- package/src/core/utils/publisherPathKey.spec.ts +58 -0
- package/src/docs/_core-concept/dataFlow.md +73 -0
- package/src/docs/_core-concept/subscriber.md +9 -10
- package/src/docs/_decorators/ancestor-attribute.md +4 -3
- package/src/docs/_decorators/auto-subscribe.md +19 -16
- package/src/docs/_decorators/bind.md +19 -16
- package/src/docs/_decorators/get.md +7 -4
- package/src/docs/_decorators/handle.md +15 -13
- package/src/docs/_decorators/on-assign.md +53 -53
- package/src/docs/_decorators/publish.md +2 -1
- package/src/docs/_decorators/subscribe.md +70 -9
- package/src/docs/_decorators/wait-for-ancestors.md +13 -10
- package/src/docs/_directives/sub.md +91 -0
- package/src/docs/_getting-started/ai-agents.md +56 -0
- package/src/docs/_getting-started/concorde-manual-install.md +133 -0
- package/src/docs/_getting-started/concorde-outside.md +13 -123
- package/src/docs/_getting-started/create-a-component.md +2 -0
- package/src/docs/_getting-started/my-first-component.md +236 -0
- package/src/docs/_getting-started/my-first-subscriber.md +29 -83
- package/src/docs/_getting-started/pubsub.md +21 -134
- package/src/docs/_getting-started/start.md +26 -18
- package/src/docs/_misc/api-configuration.md +79 -0
- package/src/docs/_misc/dataProviderKey.md +34 -1
- package/src/docs/_misc/docs-mock-api.md +60 -0
- package/src/docs/_misc/endpoint.md +2 -1
- package/src/docs/_misc/html-integration.md +13 -0
- package/src/docs/code.ts +58 -12
- package/src/docs/components/docs-demo-sources.ts +397 -0
- package/src/docs/components/docs-lit-demo-raw.ts +28 -0
- package/src/docs/components/docs-lit-demo.ts +166 -0
- package/src/docs/components/docs-source-link.ts +72 -0
- package/src/docs/docs-location.ts +54 -0
- package/src/docs/docs.ts +12 -0
- package/src/docs/example/decorators-demo-bind-demos.ts +41 -46
- package/src/docs/example/decorators-demo-geo.ts +16 -11
- package/src/docs/example/decorators-demo-init.ts +2 -228
- package/src/docs/example/decorators-demo-subscribe-publish-get-demos.ts +54 -14
- package/src/docs/example/decorators-demo.ts +71 -70
- package/src/docs/example/docs-api-config-demos.ts +234 -0
- package/src/docs/example/docs-joke-demos.ts +297 -0
- package/src/docs/example/docs-list-demos.ts +179 -0
- package/src/docs/example/docs-provider-keys.ts +315 -0
- package/src/docs/example/docs-queue-demos.ts +114 -0
- package/src/docs/example/docs-router-demos.ts +89 -0
- package/src/docs/example/docs-submit-demos.ts +455 -0
- package/src/docs/example/docs-toggle-demos.ts +73 -0
- package/src/docs/example/docs-user-two-scopes.ts +37 -0
- package/src/docs/example/docs-users-list.ts +71 -0
- package/src/docs/example/users.ts +41 -24
- package/src/docs/mock-api/api-config-mock.ts +152 -0
- package/src/docs/mock-api/fixtures.ts +377 -0
- package/src/docs/mock-api/register.ts +25 -0
- package/src/docs/mock-api/router.ts +234 -0
- package/src/docs/mock-api/service-worker.ts +23 -0
- package/src/docs/mock-api/urls.ts +11 -0
- package/src/docs/navigation/navigation.ts +39 -7
- package/src/docs/search/docs-search.json +4021 -936
- package/src/docs/search/markdown-renderer.ts +7 -3
- package/src/docs/search/page.ts +11 -14
- package/src/docs/search/sonic-code-markdown.spec.ts +29 -0
- package/src/docs/search/sonic-code-markdown.ts +28 -0
- package/src/docs.ts +4 -0
- package/src/tsconfig.json +87 -0
- package/src/tsconfig.tsbuildinfo +1 -1
- package/vite.config.mts +8 -0
- package/docs/assets/index-CaysOMFz.js +0 -5046
- package/docs/assets/index-D8mGoXzF.css +0 -1
- package/docs/src/docs/_misc/templates-demo.md +0 -19
- package/src/docs/_misc/templates-demo.md +0 -19
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
# My first subscriber component
|
|
1
|
+
# Legacy: My first subscriber component
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
> **New projects:** use [My first component](#docs/_getting-started/my-first-component.md/my-first-component) (`@ancestorAttribute`, `@subscribe` + `DataProviderKey`, `.items` on lists) and [Data flow](#docs/_core-concept/dataFlow.md/dataFlow). This page documents the **Subscriber mixin** used by older apps and core components.
|
|
4
|
+
|
|
5
|
+
Learn how to build a component with the **Subscriber** mixin, styled with Tailwind, filled from a DataProvider via automatic property mapping.
|
|
5
6
|
|
|
6
7
|
## Create a classic lit component
|
|
7
8
|
|
|
@@ -9,30 +10,24 @@ which could be used as a regular component or could be filled from a dataprovide
|
|
|
9
10
|
<template>
|
|
10
11
|
import { html, LitElement, nothing } from "lit";
|
|
11
12
|
import { customElement, property } from "lit/decorators.js";
|
|
12
|
-
// name component
|
|
13
13
|
@customElement("docs-user")
|
|
14
14
|
export class user extends LitElement {
|
|
15
|
-
// set a few props
|
|
16
15
|
@property({ type: String }) first_name = "";
|
|
17
16
|
@property({ type: String }) last_name = "";
|
|
18
17
|
@property({ type: String }) avatar = "";
|
|
19
18
|
@property({ type: String }) email = "";
|
|
20
|
-
// output
|
|
21
19
|
render() {
|
|
22
20
|
return html`
|
|
23
|
-
|
|
24
|
-
${this.first_name} ${this.last_name}
|
|
21
|
+
<img src="${this.avatar}" /> <br>
|
|
22
|
+
${this.first_name} ${this.last_name} <br>
|
|
25
23
|
${this.email}`;
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
</template>
|
|
29
27
|
</sonic-code>
|
|
30
28
|
|
|
31
|
-
|
|
32
29
|
### Style with tailwind and ui components
|
|
33
30
|
|
|
34
|
-
First export tailwind, in a tailwind.ts file, stylesheet to add it in our component when needed.
|
|
35
|
-
|
|
36
31
|
<sonic-code language="javascript">
|
|
37
32
|
<template>
|
|
38
33
|
import { css, unsafeCSS } from "lit";
|
|
@@ -43,132 +38,83 @@ First export tailwind, in a tailwind.ts file, stylesheet to add it in our compon
|
|
|
43
38
|
|
|
44
39
|
<sonic-code language="javascript">
|
|
45
40
|
<template>
|
|
46
|
-
import { html, LitElement
|
|
41
|
+
import { html, LitElement } from "lit";
|
|
47
42
|
import { customElement, property } from "lit/decorators.js";
|
|
48
|
-
// add tailwind and needed components
|
|
49
43
|
import { tailwind } from "../tailwind";
|
|
50
44
|
import '@supersoniks/concode/ui/image'
|
|
51
45
|
import '@supersoniks/concode/ui/button'
|
|
52
46
|
import '@supersoniks/concode/ui/icon'
|
|
53
|
-
//
|
|
54
47
|
@customElement("docs-user")
|
|
55
48
|
export class user extends LitElement {
|
|
56
|
-
// add tailwind stylesheed
|
|
57
49
|
static styles = [tailwind];
|
|
58
50
|
@property({ type: String }) first_name = "";
|
|
59
51
|
@property({ type: String }) last_name = "";
|
|
60
52
|
@property({ type: String }) avatar = "";
|
|
61
53
|
@property({ type: String }) email = "";
|
|
62
|
-
// use utility class in your markup
|
|
63
54
|
render() {
|
|
64
|
-
return html
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
rounded="md"
|
|
70
|
-
ratio="1/1"
|
|
71
|
-
class="w-16 block"
|
|
72
|
-
></sonic-image>
|
|
73
|
-
<div>
|
|
74
|
-
<div>
|
|
75
|
-
${this.first_name} <span class="font-bold">${this.last_name}</span>
|
|
76
|
-
</div>
|
|
77
|
-
<div class="text-sm text-neutral-400">${this.email}</div>
|
|
78
|
-
</div>
|
|
79
|
-
<div class="ml-auto relative">
|
|
80
|
-
<sonic-button
|
|
81
|
-
href="mailto:${this.email}"
|
|
82
|
-
size="sm"
|
|
83
|
-
variant="outline"
|
|
84
|
-
shape="circle"
|
|
85
|
-
class="relative"
|
|
86
|
-
icon
|
|
87
|
-
>
|
|
88
|
-
<sonic-icon library="iconoir" name="chat-bubble"></sonic-icon>
|
|
89
|
-
</sonic-button>
|
|
90
|
-
</div>
|
|
91
|
-
</div>`;
|
|
55
|
+
return html`<div class="flex items-center gap-3 p-2">
|
|
56
|
+
<sonic-image src=${this.avatar} rounded="md" ratio="1/1" class="w-16"></sonic-image>
|
|
57
|
+
<div>${this.first_name} <span class="font-bold">${this.last_name}</span></div>
|
|
58
|
+
<div class="text-sm text-neutral-400">${this.email}</div>
|
|
59
|
+
</div>`;
|
|
92
60
|
}
|
|
93
61
|
}
|
|
94
62
|
</template>
|
|
95
63
|
</sonic-code>
|
|
96
64
|
|
|
97
|
-
### Basic usage
|
|
98
|
-
|
|
99
|
-
Reactive properties can be filled by its attributes as a simple lit component.
|
|
100
|
-
|
|
101
|
-
<sonic-code>
|
|
102
|
-
<template>
|
|
103
|
-
<docs-user
|
|
104
|
-
first_name="Paul"
|
|
105
|
-
last_name="Metrand"
|
|
106
|
-
avatar="/img/paul_metrand_xs.jpg"
|
|
107
|
-
email="paulmetrand@concorde.fr"
|
|
108
|
-
></docs-user>
|
|
109
|
-
</template>
|
|
110
|
-
</sonic-code>
|
|
111
|
-
|
|
112
65
|
## Add Subscriber mixin
|
|
113
66
|
|
|
114
|
-
Import Subscriber mixin, and add it around LitElement.
|
|
115
67
|
<sonic-code language="javascript">
|
|
116
68
|
<template>
|
|
117
|
-
import { html, LitElement, nothing } from "lit";
|
|
118
|
-
import { customElement, property } from "lit/decorators.js";
|
|
119
|
-
import { tailwind } from "../tailwind";
|
|
120
69
|
import Subscriber from "@supersoniks/concorde/core/mixins/Subscriber";
|
|
121
70
|
@customElement("docs-user")
|
|
122
71
|
export class user extends Subscriber(LitElement) {
|
|
123
|
-
|
|
72
|
+
// properties auto-filled from DataProvider when names match
|
|
124
73
|
}
|
|
125
74
|
</template>
|
|
126
75
|
</sonic-code>
|
|
127
76
|
|
|
128
|
-
|
|
77
|
+
See [Legacy: Subscriber mixin](#docs/_core-concept/subscriber.md/subscriber).
|
|
78
|
+
|
|
79
|
+
## Autofill from a dataProvider
|
|
129
80
|
|
|
130
|
-
Without a dataProvider attribute, a subscriber set its own dataprovider from first ancestor found, and then reactive properties automatically filled and update from it.
|
|
131
|
-
A fetcher is a simple component which set its fetch result to props of its dataprovider.
|
|
132
81
|
<sonic-code >
|
|
133
82
|
<template>
|
|
83
|
+
<docs-demo-sources for="list-users-fetch"></docs-demo-sources>
|
|
84
|
+
<div serviceURL="/docs-mock-api">
|
|
134
85
|
<sonic-fetch
|
|
135
|
-
serviceURL="
|
|
86
|
+
serviceURL="/docs-mock-api"
|
|
136
87
|
dataProvider="api/users/3"
|
|
137
88
|
key="data">
|
|
138
89
|
<docs-user></docs-user>
|
|
139
90
|
</sonic-fetch>
|
|
91
|
+
</div>
|
|
140
92
|
</template>
|
|
141
93
|
</sonic-code>
|
|
142
94
|
|
|
143
|
-
A subscriber can subscribe data from anywhere in the DOM, with its dataprovider set as a provider id.
|
|
144
95
|
<sonic-code >
|
|
145
96
|
<template>
|
|
146
97
|
<sonic-fetch
|
|
147
|
-
serviceURL="
|
|
98
|
+
serviceURL="/docs-mock-api"
|
|
148
99
|
dataProvider="api/users/2"
|
|
149
100
|
key="data"></sonic-fetch>
|
|
150
101
|
<docs-user dataProvider="api/users/2" ></docs-user>
|
|
151
|
-
<docs-user dataProvider="api/users/2" ></docs-user>
|
|
152
|
-
<docs-user dataProvider="api/users/2" ></docs-user>
|
|
153
102
|
</template>
|
|
154
103
|
</sonic-code>
|
|
155
104
|
|
|
156
|
-
|
|
157
105
|
<sonic-code >
|
|
158
106
|
<template>
|
|
159
|
-
|
|
160
107
|
<div class="grid grid-cols-1 gap-4">
|
|
161
108
|
<form formDataProvider="userPreview" class="grid grid-cols-4 gap-3" >
|
|
162
|
-
<sonic-input label="First name" type="text" name="first_name"
|
|
163
|
-
<sonic-input label="Last name" type="text" name="last_name"
|
|
164
|
-
<sonic-input class="col-span-2"
|
|
165
|
-
<sonic-input type="
|
|
109
|
+
<sonic-input label="First name" type="text" name="first_name" value="Paul" size="sm"></sonic-input>
|
|
110
|
+
<sonic-input label="Last name" type="text" name="last_name" value="Metrand" size="sm"></sonic-input>
|
|
111
|
+
<sonic-input class="col-span-2" label="email" type="text" name="email" value="paul@example.com" size="sm"></sonic-input>
|
|
112
|
+
<sonic-input label="Image url" type="text" name="avatar" value="https://i.pravatar.cc/150?u=paul" size="sm"></sonic-input>
|
|
166
113
|
</form>
|
|
167
114
|
<sonic-divider align="left">Preview before submit</sonic-divider>
|
|
168
|
-
<
|
|
169
|
-
<
|
|
170
|
-
|
|
171
|
-
</sonic-button>
|
|
115
|
+
<div dataProvider="userPreview">
|
|
116
|
+
<docs-user></docs-user>
|
|
117
|
+
</div>
|
|
172
118
|
</div>
|
|
173
119
|
</template>
|
|
174
|
-
</sonic-code>
|
|
120
|
+
</sonic-code>
|
|
@@ -1,150 +1,37 @@
|
|
|
1
|
-
# Sharing data
|
|
1
|
+
# Legacy: Sharing data
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **New apps:** [Data flow](#docs/_core-concept/dataFlow.md/dataFlow) (`get` / `set` / `DataProviderKey`, decorators). This page documents the historical **Publisher** proxy API (`PublisherManager`, `publisher.set`, `onAssign`, …).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Thats why we use **publish/subscribe** paradigm to addresse this issue.
|
|
5
|
+
This section describes how data is shared between graphical and non-graphical components.
|
|
8
6
|
|
|
7
|
+
Graphical components should not reference each other directly — they stay decoupled via a **publish/subscribe** store.
|
|
9
8
|
|
|
10
9
|
## The Publisher
|
|
11
10
|
|
|
12
11
|
### Principle
|
|
13
12
|
|
|
14
|
-
* The **publisher** is a [JavaScript proxy](https://developer.mozilla.org/
|
|
15
|
-
Example
|
|
16
|
-
|
|
17
|
-
* if a property of the **publisher** (dot syntax / array access), it returns another **publisher**.
|
|
18
|
-
Using the previous example `myPublisher.foo.hello` is also a publisher containing `["world"]`
|
|
13
|
+
* The **publisher** is a [JavaScript proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) that holds data.<br>
|
|
14
|
+
Example: `{foo:{hello:["world"]}, bar:"baz"}`
|
|
19
15
|
|
|
20
|
-
*
|
|
21
|
-
The value that can then be provided later.
|
|
16
|
+
* Accessing a property (`myPublisher.foo.hello`) returns another **publisher** for that segment.
|
|
22
17
|
|
|
23
|
-
*
|
|
18
|
+
* Missing properties create a publisher with internal data `null`, filled later.
|
|
24
19
|
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
* The publisher publishes modifications to any of its **Subscribers**.
|
|
20
|
+
* **Subscribers** listen via `onAssign`, `onInternalMutation`, template filling on the **Subscriber mixin**, etc.
|
|
28
21
|
|
|
22
|
+
* Updates use `publisher.set(...)` or nested assignment; changes propagate to subscribers.
|
|
29
23
|
|
|
30
|
-
❇️
|
|
24
|
+
❇️ Order of creation vs subscription theoretically does not matter.
|
|
31
25
|
|
|
32
26
|
### Methods
|
|
33
27
|
|
|
34
|
-
* **set
|
|
35
|
-
<sonic-code language="javascript">
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
</template>
|
|
39
|
-
|
|
40
|
-
* **
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
</template>
|
|
45
|
-
</sonic-code>
|
|
46
|
-
* **onAssign/offAssign:** Subscribe/unsubscribe to value assignments (via `set`) of the publisher.
|
|
47
|
-
<sonic-code language="javascript">
|
|
48
|
-
<template>
|
|
49
|
-
publisher.a.b.onAssign(console.log);
|
|
50
|
-
//indirect
|
|
51
|
-
publisher.a = {b:"dramatic change"}; //log: "dramatic change"
|
|
52
|
-
//via set
|
|
53
|
-
publisher.a.b.set(["Hello"]) //log: ["Hello"]
|
|
54
|
-
</template>
|
|
55
|
-
</sonic-code>
|
|
56
|
-
* **onInternalMutation/offInternalMutation:** Listen to any internal mutation regardless of its depth level.
|
|
57
|
-
<sonic-code language="javascript">
|
|
58
|
-
<template>
|
|
59
|
-
function save(){
|
|
60
|
-
console.log("Something has changed, let's save");
|
|
61
|
-
}
|
|
62
|
-
publisher.onInternalMutation(save);
|
|
63
|
-
publisher.a.b[0] = "e";
|
|
64
|
-
</template>
|
|
65
|
-
</sonic-code>
|
|
66
|
-
* **startTemplateFilling/stopTemplateFilling:** Fill an object model, a principle used with the Subscriber mixin on which most Concorde components rely.
|
|
67
|
-
<sonic-code language="javascript">
|
|
68
|
-
<template>
|
|
69
|
-
const fillableTemplate = { title: "A title to be replaced"};
|
|
70
|
-
publisher.startTemplateFilling(fillableTemplate);
|
|
71
|
-
state.title = "Good morning";
|
|
72
|
-
publisher.stopTemplateFilling(fillableTemplate);
|
|
73
|
-
state.title = "Oops";
|
|
74
|
-
console.log(fillableTemplate);
|
|
75
|
-
</template>
|
|
76
|
-
</sonic-code>
|
|
77
|
-
* **invalidate:** Flag the data as invalid. Used by sonic-fetch and sonic-list to trigger data reloading.
|
|
78
|
-
<sonic-code language="javascript">
|
|
79
|
-
<template>
|
|
80
|
-
publisher.invalidate();
|
|
81
|
-
</template>
|
|
82
|
-
</sonic-code>
|
|
83
|
-
* **onInvalidate/offInvalidate:** Subscribe/unsubscribe to data invalidation of the publisher. Used by sonic-fetch and sonic-list to trigger data reloading.
|
|
84
|
-
<sonic-code language="javascript">
|
|
85
|
-
<template>
|
|
86
|
-
function reloadData(){
|
|
87
|
-
console.log("Reload data to inject it again into the publisher");
|
|
88
|
-
}
|
|
89
|
-
publisher.onInvalidate(reloadData);
|
|
90
|
-
</template>
|
|
91
|
-
</sonic-code>
|
|
92
|
-
|
|
93
|
-
## DataProvider
|
|
94
|
-
|
|
95
|
-
Denotes the identifier of a publisher as referenced in the PublisherManager (see below).
|
|
96
|
-
Uses the dataProvider attribut in html tags to scop the content with some data.
|
|
97
|
-
see [Subscribers](#docs/_core-concept/subscriber.md/subscriber).
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
## PublisherManager
|
|
101
|
-
|
|
102
|
-
The **PublisherManager** is a utility class to get publishers
|
|
103
|
-
|
|
104
|
-
It plays a central role in the components, especially through the "subscriber" mixin.<br>
|
|
105
|
-
Automatic data communication between components in concorde uses this principle in conjunction with Lit's reactive properties. <br>
|
|
106
|
-
Refer to the documentation for [Subscriber](#docs/_core-concept/subscriber.md/subscriber).
|
|
107
|
-
|
|
108
|
-
<sonic-code language="javascript">
|
|
109
|
-
<template>
|
|
110
|
-
import { PublisherManager } from "publisherproxy";
|
|
111
|
-
let dataProvider = "cart";
|
|
112
|
-
let publisher = PublisherManager.get(dataProvider);
|
|
113
|
-
|
|
114
|
-
</template>
|
|
115
|
-
</sonic-code>
|
|
116
|
-
|
|
117
|
-
It is declared on the `window` object to allow usage in a web page, so the equivalent one-liner would be:
|
|
118
|
-
|
|
119
|
-
<sonic-code language="javascript">
|
|
120
|
-
<template>
|
|
121
|
-
let dataProvider = "cart";
|
|
122
|
-
let publisher = SonicPublisherManager.get(dataProvider);
|
|
123
|
-
|
|
124
|
-
</template>
|
|
125
|
-
</sonic-code>
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
## Basic Example
|
|
129
|
-
|
|
130
|
-
This example can be tested in a console when Concorde is loaded on the page (for example, in a ticketing system).
|
|
131
|
-
In a component, you will need to perform an `import` as explained earlier.
|
|
132
|
-
|
|
133
|
-
<sonic-code language="javascript">
|
|
134
|
-
<template>
|
|
135
|
-
// Anywhere, anytime
|
|
136
|
-
SonicPublisherManager.get("mySubject").title.onAssign(console.log)
|
|
137
|
-
|
|
138
|
-
</template>
|
|
139
|
-
</sonic-code>
|
|
140
|
-
|
|
141
|
-
<sonic-code language="javascript">
|
|
142
|
-
<template>
|
|
143
|
-
// Anywhere, anytime
|
|
144
|
-
let publisher = SonicPublisherManager.get("mySubject");
|
|
145
|
-
// ...
|
|
146
|
-
publisher.set({title: "A title"});
|
|
147
|
-
publisher.title.set("A second title");
|
|
148
|
-
|
|
149
|
-
</template>
|
|
150
|
-
</sonic-code>
|
|
28
|
+
* **set** — replace internal value
|
|
29
|
+
<sonic-code language="javascript"><template>publisher.set({foo:{hello:["world"]}, bar:"baz"});</template></sonic-code>
|
|
30
|
+
|
|
31
|
+
* **get** — read internal value
|
|
32
|
+
<sonic-code language="javascript"><template>publisher.get()</template></sonic-code>
|
|
33
|
+
|
|
34
|
+
* **onAssign / offAssign** — react to `set`
|
|
35
|
+
<sonic-code language="javascript"><template>publisher.a.b.onAssign(console.log);</template></sonic-code>
|
|
36
|
+
|
|
37
|
+
Modern equivalent: `get` / `set` / `@handle` — see [Data flow](#docs/_core-concept/dataFlow.md/dataFlow).
|
|
@@ -1,39 +1,47 @@
|
|
|
1
1
|
# Introduction
|
|
2
2
|
|
|
3
|
-
## What is Concorde
|
|
3
|
+
## What is Concorde?
|
|
4
4
|
|
|
5
|
-
Based on **[lit.dev](https://lit.dev)**, Concorde is a collection of
|
|
6
|
-
|
|
5
|
+
Based on **[lit.dev](https://lit.dev)**, Concorde is a collection of web components for shared apps and websites.
|
|
6
|
+
Build UIs without tying components to a specific host stack, while keeping visual consistency through a small set of CSS variables.
|
|
7
7
|
|
|
8
8
|
## Why and use case
|
|
9
9
|
|
|
10
|
-
In 2022, Supersoniks
|
|
11
|
-
|
|
12
|
-
Webcomponents appeared to be a the perfect solution to guarantee that compatibility with all past, present and futures environment, and lit seemed to be the best choice to build them.
|
|
10
|
+
In 2022, Supersoniks needed a new ticketing stack for nearly 100 sites — mobile apps, modern sites, and legacy PHP without bundlers.
|
|
11
|
+
One composable web-component library replaced many one-off apps. Lit was chosen for broad runtime compatibility.
|
|
13
12
|
|
|
14
13
|
### Stack
|
|
15
14
|
|
|
16
15
|
* Lit
|
|
17
|
-
*
|
|
16
|
+
* TypeScript
|
|
18
17
|
* Vite
|
|
19
|
-
* Tailwind, not in the core
|
|
18
|
+
* Tailwind (starter kit, not required in the core package)
|
|
20
19
|
|
|
21
|
-
###
|
|
20
|
+
### Functional features
|
|
22
21
|
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* Simple router, state component, ...
|
|
28
|
-
* And all ui component, with status variants to build an app with a consistent design
|
|
22
|
+
* **DataProvider** store (decorators, `get` / `set`)
|
|
23
|
+
* Forms (`formDataProvider`)
|
|
24
|
+
* Lists, queues, lazy loading
|
|
25
|
+
* Router, states, UI kit with status variants
|
|
29
26
|
|
|
27
|
+
## Learn Concorde
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
| Step | Page |
|
|
30
|
+
|------|------|
|
|
31
|
+
| 1 | [My first component](#docs/_getting-started/my-first-component.md/my-first-component) — Lit card, `@ancestorAttribute`, `@bind`, mock API |
|
|
32
|
+
| 2 | [Data flow](#docs/_core-concept/dataFlow.md/dataFlow) — Core concepts: decorators and APIs |
|
|
33
|
+
| 3 | [Local API demos](#docs/_misc/docs-mock-api.md/docs-mock-api) — offline `serviceURL` for this site (Misc) |
|
|
34
|
+
| 4 | [create-concorde-ts-starter](https://www.npmjs.com/package/@supersoniks/create-concorde-ts-starter) — **recommended** project kit (Vite, Tailwind, `yarn ai:sync`) |
|
|
35
|
+
| 5 | [AI agents (skills)](#docs/_getting-started/ai-agents.md/ai-agents) — `AGENTS.md`, Cursor / JetBrains rules |
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
Legacy (Subscriber mixin, Publisher API): **Legacy** section at the bottom of the sidebar.
|
|
38
|
+
|
|
39
|
+
## Start a new project
|
|
34
40
|
|
|
35
41
|
<sonic-code language="bash">
|
|
36
42
|
<template>
|
|
37
|
-
|
|
43
|
+
npx @supersoniks/create-concorde-ts-starter "project_name"
|
|
38
44
|
</template>
|
|
39
45
|
</sonic-code>
|
|
46
|
+
|
|
47
|
+
The starter runs **`yarn ai:sync`** for you. Details: [AI agents (skills)](#docs/_getting-started/ai-agents.md/ai-agents). Manual Vite setup: [Legacy: Manual installation](#docs/_getting-started/concorde-manual-install.md/concorde-manual-install).
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# API configuration
|
|
2
|
+
|
|
3
|
+
`APIConfiguration` is the object built by [`HTML.getApiConfiguration`](../../core/utils/HTML.ts) from **ancestor attributes** on the DOM (or from a typed publisher — see [@get configuration key](#docs/_decorators/get.md/get)). It is passed to [`API`](../../core/utils/api.ts) by fetchers, **sonic-submit**, the **`wording()`** directive, and **`@get`**.
|
|
4
|
+
|
|
5
|
+
> **Mock service:** same [Local API demos](#docs/_misc/docs-mock-api.md/docs-mock-api) Service Worker / Vite middleware. Routes used on this page are listed in the [API config routes](#api-config-routes) section below.
|
|
6
|
+
|
|
7
|
+
## Attribute map
|
|
8
|
+
|
|
9
|
+
| Attribute (ancestor) | `APIConfiguration` field | Role |
|
|
10
|
+
|---------------------|---------------------------|------|
|
|
11
|
+
| `serviceURL` | `serviceURL` | Base URL (e.g. `/docs-mock-api`) |
|
|
12
|
+
| `token` | `token` | Static Bearer sent on REST calls |
|
|
13
|
+
| `userName` / `password` | `userName` / `password` | Basic auth for **tokenProvider** fetch only |
|
|
14
|
+
| `eventsApiToken` | `authToken` | Bearer for **tokenProvider** when no Basic |
|
|
15
|
+
| `tokenProvider` | `tokenProvider` | Path to GET a new token (`{ token }` JSON) |
|
|
16
|
+
| `wordingProvider` | — (read by `wording()`) | Base path + query for label batch GET |
|
|
17
|
+
| `wordingVersionProvider` | — | Publisher id; bump version → reload wordings |
|
|
18
|
+
| `credentials` | `credentials` | `fetch` credentials mode |
|
|
19
|
+
| `addHTTPResponse` | `addHTTPResponse` | Attach `_sonic_http_response_` on result |
|
|
20
|
+
| `cache` | `cache` | `fetch` cache mode |
|
|
21
|
+
| `blockUntilDone` | `blockUntilDone` | Serialize calls per `serviceURL` |
|
|
22
|
+
| `keepAlive` | `keepAlive` | `fetch` keepalive |
|
|
23
|
+
|
|
24
|
+
**Lit / TypeScript:** store the same shape in a publisher and pass `DataProviderKey<APIConfiguration>` as the second argument of `@get` (see [DataProviderKey](#docs/_misc/dataProviderKey.md/dataProviderKey)).
|
|
25
|
+
|
|
26
|
+
## Bearer token (static)
|
|
27
|
+
|
|
28
|
+
Publisher `docsApiConfBearerKey` (`set(docsApiConfBearerKey, { token: "docs-mock-valid-token", … })`) — mock returns the protected payload.
|
|
29
|
+
|
|
30
|
+
<docs-lit-demo for="docs-api-config-bearer-demo"></docs-lit-demo>
|
|
31
|
+
|
|
32
|
+
## tokenProvider + Basic auth
|
|
33
|
+
|
|
34
|
+
No static `token`: `API.auth()` calls `GET /docs-mock-api/auth/token` with Basic **demo** / **secret**, stores `token`, then calls the protected route.
|
|
35
|
+
|
|
36
|
+
<docs-lit-demo for="docs-api-config-token-provider-demo"></docs-lit-demo>
|
|
37
|
+
|
|
38
|
+
## HTTP 498 — stale token refresh
|
|
39
|
+
|
|
40
|
+
Initial `token="docs-mock-stale-token"` → mock responds **498** → Concorde invalidates the token, runs `auth()` again (same `tokenProvider` + Basic), retries with `docs-mock-fresh-token`.
|
|
41
|
+
|
|
42
|
+
<docs-lit-demo for="docs-api-config-stale-token-demo"></docs-lit-demo>
|
|
43
|
+
|
|
44
|
+
## eventsApiToken
|
|
45
|
+
|
|
46
|
+
Attribute **`eventsApiToken`** on an ancestor maps to **`authToken`** in config (used as Bearer when calling `tokenProvider`, instead of Basic).
|
|
47
|
+
|
|
48
|
+
<docs-lit-demo for="docs-api-config-events-token-demo"></docs-lit-demo>
|
|
49
|
+
|
|
50
|
+
## Wording API
|
|
51
|
+
|
|
52
|
+
`wordingProvider="wording/labels?lang=fr"` + `wording('api-config.greeting')` in Lit. Mock returns label map from `labels[]` query params.
|
|
53
|
+
|
|
54
|
+
<docs-lit-demo for="docs-api-config-wording-demo"></docs-lit-demo>
|
|
55
|
+
|
|
56
|
+
## Scoped attributes (HTML / sonic-scope)
|
|
57
|
+
|
|
58
|
+
Attributes on **`sonic-scope`** (or any ancestor) are visible to descendants via `getAncestorAttributeValue`.
|
|
59
|
+
|
|
60
|
+
<docs-lit-demo for="docs-api-config-scoped-attrs-demo"></docs-lit-demo>
|
|
61
|
+
|
|
62
|
+
## API config routes
|
|
63
|
+
|
|
64
|
+
| Route | Demo |
|
|
65
|
+
|-------|------|
|
|
66
|
+
| `GET /docs-mock-api/auth/token` | tokenProvider, eventsApiToken |
|
|
67
|
+
| `GET /docs-mock-api/api/config/protected` | Bearer / Basic / 498 |
|
|
68
|
+
| `GET /docs-mock-api/wording/labels?labels[]=…&lang=fr` | `wording()` |
|
|
69
|
+
|
|
70
|
+
Mock tokens (doc only): `docs-mock-valid-token`, `docs-mock-stale-token` (498), `docs-mock-fresh-token` (after refresh). Basic: **demo** / **secret**. Events token: `docs-mock-events-token`.
|
|
71
|
+
|
|
72
|
+
Implementation: `src/docs/mock-api/api-config-mock.ts` (bundled in the Service Worker with `router.ts`).
|
|
73
|
+
|
|
74
|
+
## See also
|
|
75
|
+
|
|
76
|
+
- [@get](#docs/_decorators/get.md/get) — `APIConfiguration` + `Endpoint`
|
|
77
|
+
- [Endpoint](#docs/_misc/endpoint.md/endpoint) — typed path
|
|
78
|
+
- [Local API demos](#docs/_misc/docs-mock-api.md/docs-mock-api) — offline `serviceURL`
|
|
79
|
+
- [Fetch](#core/components/functional/fetch/fetch.md/fetch) — attribute table (legacy sonic-fetch)
|
|
@@ -2,12 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
The `DataProviderKey<T>` utility provides type-safe navigation through composite data structures. Each property or index access extends the path, and the final key can be retrieved via `toString()` or the `path` property.
|
|
4
4
|
|
|
5
|
-
For a **single HTTP path string** (no dot-syntax), see [Endpoint](#docs/_misc/endpoint.md/endpoint).
|
|
5
|
+
For a **single HTTP path string** (no dot-syntax), see [Endpoint](#docs/_misc/endpoint.md/endpoint). For **`DataProviderKey<APIConfiguration>`**, see [API configuration](#docs/_misc/api-configuration.md/api-configuration).
|
|
6
6
|
|
|
7
7
|
## Principle
|
|
8
8
|
|
|
9
9
|
`DataProviderKey` uses a Proxy to intercept property access and build a cumulative path string. TypeScript infers the nested type at each level, so `myKey.items[0]` is correctly typed as `DataProviderKey<Item>` when `items` is `Item[]`.
|
|
10
10
|
|
|
11
|
+
In Lit demos, bind HTML attributes from a key’s **`.path`** (single source of truth), and use **`get` / `set` / `dp`** instead of `PublisherManager.get("…")`:
|
|
12
|
+
|
|
13
|
+
<sonic-code language="typescript">
|
|
14
|
+
<template>
|
|
15
|
+
import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
|
|
16
|
+
import { get, set } from "@supersoniks/concorde/utils";
|
|
17
|
+
|
|
18
|
+
export const myFormKey = new DataProviderKey<{ email: string }>("myForm");
|
|
19
|
+
set(myFormKey, { email: "a@b.c" });
|
|
20
|
+
|
|
21
|
+
// template: formDataProvider=${myFormKey.path}
|
|
22
|
+
</template>
|
|
23
|
+
</sonic-code>
|
|
24
|
+
|
|
11
25
|
## Usage
|
|
12
26
|
|
|
13
27
|
### Import
|
|
@@ -77,6 +91,25 @@ user: User | null = null;
|
|
|
77
91
|
</template>
|
|
78
92
|
</sonic-code>
|
|
79
93
|
|
|
94
|
+
Dynamic keys are **not** supported by `get`, `set`, or `dp` — those APIs take a snapshot at call time with no component context. For dynamic paths use decorators (`@subscribe`, `@publish`, `@handle`) or **`sub(key)`** in Lit templates (resolves `${…}` from the host component). See [sub()](#docs/_directives/sub.md/sub).
|
|
95
|
+
|
|
96
|
+
### get / set / dp with static keys
|
|
97
|
+
|
|
98
|
+
For programmatic access, pass a `DataProviderKey` or a static path string. Dynamic placeholders are rejected:
|
|
99
|
+
|
|
100
|
+
<sonic-code language="typescript">
|
|
101
|
+
<template>
|
|
102
|
+
import { dp, get, set } from "@supersoniks/concorde/utils";
|
|
103
|
+
import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
|
|
104
|
+
//
|
|
105
|
+
const counterKey = new DataProviderKey<{ count: number }>("myCounter");
|
|
106
|
+
//
|
|
107
|
+
set(counterKey, { count: 0 });
|
|
108
|
+
dp(counterKey.count).set(1);
|
|
109
|
+
get(counterKey); // snapshot: { count: 1 }
|
|
110
|
+
</template>
|
|
111
|
+
</sonic-code>
|
|
112
|
+
|
|
80
113
|
## Path retrieval
|
|
81
114
|
|
|
82
115
|
The final path is built by concatenating each accessed property with a dot:
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Local API demos (offline)
|
|
2
|
+
|
|
3
|
+
The Concorde doc site does not call fragile third-party APIs during `yarn dev`. A **Service Worker** and the Vite dev middleware serve **`/docs-mock-api/*`** on the same origin.
|
|
4
|
+
|
|
5
|
+
## How it works
|
|
6
|
+
|
|
7
|
+
1. On load, `registerDocsMockApiServiceWorker()` registers `/docs-mock-api-sw.js`.
|
|
8
|
+
2. Requests to `/docs-mock-api/...` are handled by the SW (production build) or Vite middleware (dev).
|
|
9
|
+
3. Live examples use `serviceURL="/docs-mock-api"` and relative paths.
|
|
10
|
+
|
|
11
|
+
TypeScript constants: `src/docs/mock-api/urls.ts` (`DOCS_MOCK_REQRES_SERVICE`, `DOCS_MOCK_GEO_SERVICE`, …).
|
|
12
|
+
|
|
13
|
+
## Routes
|
|
14
|
+
|
|
15
|
+
| Path | Used in |
|
|
16
|
+
|------|---------|
|
|
17
|
+
| `/docs-mock-api/api/users` | `sonic-list`, `sonic-fetch`, `sonic-queue` (users) |
|
|
18
|
+
| `/docs-mock-api/api/users/:id` | Single user, `docs-user` |
|
|
19
|
+
| `POST /docs-mock-api/api/register` | **sonic-submit** — JSON, `multipart/form-data` (`sendAsFormData`), or `application/x-www-form-urlencoded` (native `<form>`); response includes parsed `email` + `token` |
|
|
20
|
+
| `POST /docs-mock-api/api/register/nested` | Wrapped body `{ data: { id, token } }` for `submit-result-key` demo |
|
|
21
|
+
| `GET /docs-mock-api/api/register/echo` | Echoes query string (`method="get"` on submit) |
|
|
22
|
+
| `GET /docs-mock-api/auth/token` | [API configuration](#docs/_misc/api-configuration.md/api-configuration) — tokenProvider (Basic or `eventsApiToken`) |
|
|
23
|
+
| `GET /docs-mock-api/api/config/protected` | Bearer / Basic; `docs-mock-stale-token` → **498** |
|
|
24
|
+
| `GET /docs-mock-api/wording/labels` | Wording batch (`labels[]`, `lang`) |
|
|
25
|
+
| `/docs-mock-api/geo/communes` | Geo list, `@get` demos |
|
|
26
|
+
| `/docs-mock-api/jokes/joke/:category` | JokeAPI-shaped list (`key="jokes"` on queue/list) |
|
|
27
|
+
|
|
28
|
+
### Filtres `GET /jokes/joke/…`
|
|
29
|
+
|
|
30
|
+
| Query | Meaning |
|
|
31
|
+
|-------|---------|
|
|
32
|
+
| `amount` | Max jokes per request when not using `offset` |
|
|
33
|
+
| `offset` + `limit` / `per_page` | Pagination for **sonic-queue** lazy load |
|
|
34
|
+
| `contains` | Substring on joke text, setup/delivery, categories (**input** demo, `name="contains"`) |
|
|
35
|
+
| `lang` | `fr` or `en` — filters the local dataset (**select** demo, `name="lang"`) |
|
|
36
|
+
| `blacklistFlags` | Comma-separated flags to **exclude** (`nsfw`, `religious`, `political`, `racist`, `sexist`, `explicit`) — checkbox/radio/switch « Remove following jokes » demos; each joke has matching `flags` in fixtures |
|
|
37
|
+
|
|
38
|
+
### Pagination `GET /api/users`
|
|
39
|
+
|
|
40
|
+
| Query | Meaning |
|
|
41
|
+
|-------|---------|
|
|
42
|
+
| `offset` + `per_page` | Index-based slice on the filtered set — **sonic-queue** (`offset=$offset&per_page=$limit`) |
|
|
43
|
+
| `page` + `per_page` | 1-based page — static fetch examples (`?page=2`) |
|
|
44
|
+
| `limit` | Alias of `per_page` |
|
|
45
|
+
| `q` | Search on first name, last name, email (optional; **sonic-queue** + `dataFilterProvider`, field `name="q"`) |
|
|
46
|
+
|
|
47
|
+
**ALTCHA** (`sonic-captcha`) is **not** mocked — it still uses the Supersoniks service.
|
|
48
|
+
|
|
49
|
+
In TypeScript demos, import from `src/docs/mock-api/urls.ts` (e.g. `DOCS_MOCK_REQRES_SERVICE` on `serviceURL`).
|
|
50
|
+
|
|
51
|
+
## Source files
|
|
52
|
+
|
|
53
|
+
- `src/docs/mock-api/` — router, fixtures, service worker, `urls.ts`
|
|
54
|
+
- `scripts/docs-mock-api-vite-plugin.ts` — SW build + middleware
|
|
55
|
+
- `public/docs-mock-api-sw.js` — generated on `yarn dev` / `yarn build-docs`
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
yarn dev # mock API on by default
|
|
59
|
+
yarn build-docs # includes SW bundle
|
|
60
|
+
```
|
|
@@ -18,7 +18,7 @@ import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
|
|
|
18
18
|
<template>
|
|
19
19
|
const users = new Endpoint<User[]>("users?limit=10");
|
|
20
20
|
users.path; // "users?limit=10"
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
const one = new Endpoint<User, { userId: string }>("users/${userId}");
|
|
23
23
|
// `userId` on the host class is observed when used with @get
|
|
24
24
|
</template>
|
|
@@ -38,5 +38,6 @@ const one = new Endpoint<User, { userId: string }>("users/${userId}");
|
|
|
38
38
|
|
|
39
39
|
## See also
|
|
40
40
|
|
|
41
|
+
- [API configuration](#docs/_misc/api-configuration.md/api-configuration) — `serviceURL`, token, wording (mock demos)
|
|
41
42
|
- [@get](#docs/_decorators/get.md/get) — decorator that uses `Endpoint<T>`
|
|
42
43
|
- [DataProviderKey](#docs/_misc/dataProviderKey.md/dataProviderKey) — typed publisher paths (dot notation)
|