@supersoniks/concorde 5.0.0 → 5.0.1
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 +0 -13
- package/build-infos.json +1 -1
- package/concorde-core.bundle.js +257 -273
- package/concorde-core.es.js +4127 -4039
- package/dist/concorde-core.bundle.js +257 -273
- package/dist/concorde-core.es.js +4127 -4039
- package/gitlab/job_tests.sh +25 -12
- package/index.html +1 -1
- package/package.json +3 -1
- package/scripts/post-build-docs.js +0 -0
- package/scripts/post-build.mjs +0 -0
- package/src/core/components/functional/fetch/fetch.md +0 -0
- package/src/core/components/functional/if/if.md +0 -0
- package/src/core/components/functional/list/list.demo.ts +0 -0
- package/src/core/components/functional/list/list.md +0 -0
- package/src/core/components/functional/list/list.ts +0 -0
- package/src/core/components/functional/router/router.md +0 -0
- package/src/core/components/functional/router/router.ts +0 -0
- package/src/core/components/functional/sdui/sdui.md +0 -0
- package/src/core/components/functional/states/states.md +0 -0
- package/src/core/components/functional/submit/submit.md +0 -0
- package/src/core/components/ui/_css/size.ts +0 -0
- package/src/core/components/ui/alert/alert.ts +0 -0
- package/src/core/components/ui/button/button.md +0 -0
- package/src/core/components/ui/captcha/altchaStyles.ts +0 -0
- package/src/core/components/ui/captcha/captcha.md +0 -0
- package/src/core/components/ui/card/card.md +0 -0
- package/src/core/components/ui/divider/divider.ts +0 -0
- package/src/core/components/ui/form/input/input.md +0 -0
- package/src/core/components/ui/form/radio/radio.md +0 -0
- package/src/core/components/ui/form/select/select.md +0 -0
- package/src/core/components/ui/form/switch/switch.md +0 -0
- package/src/core/components/ui/loader/loader.md +0 -0
- package/src/core/components/ui/menu/menu.md +0 -0
- package/src/core/components/ui/modal/modal-close.ts +0 -0
- package/src/core/components/ui/modal/modal.md +0 -0
- package/src/core/components/ui/pop/pop.md +103 -1
- package/src/core/components/ui/pop/pop.ts +70 -115
- package/src/core/components/ui/table/table-caption.ts +0 -0
- package/src/core/components/ui/table/table.md +0 -0
- package/src/core/components/ui/theme/theme.ts +1 -1
- package/src/core/components/ui/tooltip/tooltip.ts +178 -154
- package/src/core/utils/positioning.spec.ts +180 -0
- package/src/core/utils/positioning.ts +164 -0
- package/src/core/utils/route.ts +0 -0
- package/src/directives.ts +2 -3
- package/src/docs/_core-concept/subscriber.md +0 -0
- package/src/docs/_getting-started/concorde-outside.md +0 -0
- package/src/docs/_getting-started/my-first-subscriber.md +0 -0
- package/src/docs/_getting-started/pubsub.md +0 -0
- package/src/docs/_getting-started/start.md +0 -0
- package/src/docs/example/users.ts +0 -0
- package/src/docs/search/docs-search.json +90 -0
- package/src/docs/search/page.ts +0 -0
- package/src/docs/tailwind/css/tailwind.css +7 -6
- package/src/tsconfig.json +387 -381
- package/src/tsconfig.tsbuildinfo +1 -1
- package/vitest.setup.ts +49 -13
- package/.github/workflows/ci.yml +0 -21
- package/.github-export-ignore +0 -30
- package/CONTRIBUTING.md +0 -59
- package/DEV.md +0 -54
- package/LICENSE +0 -21
- package/OPEN_SOURCE_CHECKPOINT.md +0 -133
- package/concorde-3d.bundle.js +0 -3960
- package/concorde-3d.es.js +0 -33433
- package/concorde-hugging-face-infer.bundle.js +0 -32
- package/concorde-hugging-face-infer.es.js +0 -2952
- package/concorde-shader.bundle.js +0 -116
- package/concorde-shader.es.js +0 -8353
- package/concorde-webgpu.bundle.js +0 -307
- package/concorde-webgpu.es.js +0 -8627
- package/docs/altcha-widget.js +0 -2662
- package/docs/assets/index-BZiZXMU-.css +0 -1
- package/docs/assets/index-FmK4JaIM.js +0 -11992
- package/docs/crawl/core/components/functional/date/date.html +0 -190
- package/docs/crawl/core/components/functional/fetch/fetch.html +0 -109
- package/docs/crawl/core/components/functional/if/if.html +0 -27
- package/docs/crawl/core/components/functional/jsonata/jsonata.html +0 -79
- package/docs/crawl/core/components/functional/list/list.html +0 -70
- package/docs/crawl/core/components/functional/mix/mix.html +0 -45
- package/docs/crawl/core/components/functional/queue/queue.html +0 -96
- package/docs/crawl/core/components/functional/router/router.html +0 -106
- package/docs/crawl/core/components/functional/sdui/sdui.html +0 -269
- package/docs/crawl/core/components/functional/states/states.html +0 -66
- package/docs/crawl/core/components/functional/submit/submit.html +0 -160
- package/docs/crawl/core/components/functional/subscriber/subscriber.html +0 -67
- package/docs/crawl/core/components/functional/value/value.html +0 -51
- package/docs/crawl/core/components/ui/alert/alert.html +0 -110
- package/docs/crawl/core/components/ui/alert-messages/alert-messages.html +0 -23
- package/docs/crawl/core/components/ui/badge/badge.html +0 -119
- package/docs/crawl/core/components/ui/button/button.html +0 -149
- package/docs/crawl/core/components/ui/captcha/captcha.html +0 -30
- package/docs/crawl/core/components/ui/card/card.html +0 -99
- package/docs/crawl/core/components/ui/divider/divider.html +0 -58
- package/docs/crawl/core/components/ui/form/checkbox/checkbox.html +0 -73
- package/docs/crawl/core/components/ui/form/fieldset/fieldset.html +0 -135
- package/docs/crawl/core/components/ui/form/form-actions/form-actions.html +0 -79
- package/docs/crawl/core/components/ui/form/form-layout/form-layout.html +0 -62
- package/docs/crawl/core/components/ui/form/input/input.html +0 -109
- package/docs/crawl/core/components/ui/form/input-autocomplete/input-autocomplete.html +0 -106
- package/docs/crawl/core/components/ui/form/radio/radio.html +0 -56
- package/docs/crawl/core/components/ui/form/select/select.html +0 -73
- package/docs/crawl/core/components/ui/form/switch/switch.html +0 -56
- package/docs/crawl/core/components/ui/form/textarea/textarea.html +0 -59
- package/docs/crawl/core/components/ui/group/group.html +0 -82
- package/docs/crawl/core/components/ui/icon/icon.html +0 -133
- package/docs/crawl/core/components/ui/image/image.html +0 -110
- package/docs/crawl/core/components/ui/link/link.html +0 -42
- package/docs/crawl/core/components/ui/loader/loader.html +0 -50
- package/docs/crawl/core/components/ui/menu/menu.html +0 -322
- package/docs/crawl/core/components/ui/modal/modal.html +0 -117
- package/docs/crawl/core/components/ui/pop/pop.html +0 -102
- package/docs/crawl/core/components/ui/progress/progress.html +0 -58
- package/docs/crawl/core/components/ui/table/table.html +0 -413
- package/docs/crawl/core/components/ui/toast/toast.html +0 -122
- package/docs/crawl/core/components/ui/tooltip/tooltip.html +0 -79
- package/docs/crawl/docs/_core-concept/dataFlow.html +0 -177
- package/docs/crawl/docs/_core-concept/overview.html +0 -66
- package/docs/crawl/docs/_core-concept/subscriber.html +0 -75
- package/docs/crawl/docs/_decorators/ancestor-attribute.html +0 -116
- package/docs/crawl/docs/_decorators/auto-subscribe.html +0 -202
- package/docs/crawl/docs/_decorators/bind.html +0 -141
- package/docs/crawl/docs/_decorators/get.html +0 -149
- package/docs/crawl/docs/_decorators/handle.html +0 -165
- package/docs/crawl/docs/_decorators/on-assign.html +0 -355
- package/docs/crawl/docs/_decorators/patch.html +0 -78
- package/docs/crawl/docs/_decorators/post.html +0 -139
- package/docs/crawl/docs/_decorators/publish.html +0 -61
- package/docs/crawl/docs/_decorators/put.html +0 -78
- package/docs/crawl/docs/_decorators/subscribe.html +0 -109
- package/docs/crawl/docs/_decorators/wait-for-ancestors.html +0 -137
- package/docs/crawl/docs/_directives/sub.html +0 -93
- package/docs/crawl/docs/_getting-started/ai-agents.html +0 -173
- package/docs/crawl/docs/_getting-started/concorde-manual-install.html +0 -100
- package/docs/crawl/docs/_getting-started/concorde-outside.html +0 -58
- package/docs/crawl/docs/_getting-started/create-a-component.html +0 -111
- package/docs/crawl/docs/_getting-started/my-first-component.html +0 -189
- package/docs/crawl/docs/_getting-started/my-first-subscriber.html +0 -110
- package/docs/crawl/docs/_getting-started/pubsub.html +0 -62
- package/docs/crawl/docs/_getting-started/start.html +0 -76
- package/docs/crawl/docs/_getting-started/theming.html +0 -85
- package/docs/crawl/docs/_misc/api-configuration.html +0 -149
- package/docs/crawl/docs/_misc/dataProviderKey.html +0 -135
- package/docs/crawl/docs/_misc/docs-mock-api.html +0 -158
- package/docs/crawl/docs/_misc/dynamic-path.html +0 -180
- package/docs/crawl/docs/_misc/endpoint.html +0 -50
- package/docs/crawl/docs/_misc/formelement-subscriber-removal.html +0 -138
- package/docs/crawl/docs/_misc/html-integration.html +0 -48
- package/docs/crawl/hubs/decorators.html +0 -547
- package/docs/crawl/hubs/form-components.html +0 -357
- package/docs/crawl/hubs/remote-data.html +0 -452
- package/docs/crawl/index.html +0 -101
- package/docs/css/docs.css +0 -0
- package/docs/docs-mock-api-sw.js +0 -720
- package/docs/docs-mock-api-sw.js.map +0 -7
- package/docs/fonts/ClashGrotesk-Bold.eot +0 -0
- package/docs/fonts/ClashGrotesk-Bold.ttf +0 -0
- package/docs/fonts/ClashGrotesk-Bold.woff +0 -0
- package/docs/fonts/ClashGrotesk-Bold.woff2 +0 -0
- package/docs/fonts/ClashGrotesk-Extralight.eot +0 -0
- package/docs/fonts/ClashGrotesk-Extralight.ttf +0 -0
- package/docs/fonts/ClashGrotesk-Extralight.woff +0 -0
- package/docs/fonts/ClashGrotesk-Extralight.woff2 +0 -0
- package/docs/fonts/ClashGrotesk-Light.eot +0 -0
- package/docs/fonts/ClashGrotesk-Light.ttf +0 -0
- package/docs/fonts/ClashGrotesk-Light.woff +0 -0
- package/docs/fonts/ClashGrotesk-Light.woff2 +0 -0
- package/docs/fonts/ClashGrotesk-Medium.eot +0 -0
- package/docs/fonts/ClashGrotesk-Medium.ttf +0 -0
- package/docs/fonts/ClashGrotesk-Medium.woff +0 -0
- package/docs/fonts/ClashGrotesk-Medium.woff2 +0 -0
- package/docs/fonts/ClashGrotesk-Regular.eot +0 -0
- package/docs/fonts/ClashGrotesk-Regular.ttf +0 -0
- package/docs/fonts/ClashGrotesk-Regular.woff +0 -0
- package/docs/fonts/ClashGrotesk-Regular.woff2 +0 -0
- package/docs/fonts/ClashGrotesk-Semibold.eot +0 -0
- package/docs/fonts/ClashGrotesk-Semibold.ttf +0 -0
- package/docs/fonts/ClashGrotesk-Semibold.woff +0 -0
- package/docs/fonts/ClashGrotesk-Semibold.woff2 +0 -0
- package/docs/fonts/ClashGrotesk-Variable.eot +0 -0
- package/docs/fonts/ClashGrotesk-Variable.ttf +0 -0
- package/docs/fonts/ClashGrotesk-Variable.woff +0 -0
- package/docs/fonts/ClashGrotesk-Variable.woff2 +0 -0
- package/docs/img/concorde-icon.svg +0 -5
- package/docs/img/concorde-logo.svg +0 -1
- package/docs/img/concorde.png +0 -0
- package/docs/img/concorde_def.png +0 -0
- package/docs/img/concorde_seuil.png.webp +0 -0
- package/docs/img/concorde_seuil_invert.png +0 -0
- package/docs/img/paul_metrand.jpg +0 -0
- package/docs/img/paul_metrand_xs.jpg +0 -0
- package/docs/index.html +0 -93
- package/docs/llms-full.txt +0 -5787
- package/docs/llms.txt +0 -104
- package/docs/robots.txt +0 -16
- package/docs/sitemap.xml +0 -237
- package/docs/src/core/components/functional/date/date.md +0 -290
- package/docs/src/core/components/functional/fetch/fetch.md +0 -125
- package/docs/src/core/components/functional/if/if.md +0 -9
- package/docs/src/core/components/functional/jsonata/jsonata.md +0 -56
- package/docs/src/core/components/functional/list/list.md +0 -65
- package/docs/src/core/components/functional/mix/mix.md +0 -41
- package/docs/src/core/components/functional/queue/queue.md +0 -72
- package/docs/src/core/components/functional/router/router.md +0 -94
- package/docs/src/core/components/functional/sdui/default-library.json +0 -108
- package/docs/src/core/components/functional/sdui/example.json +0 -99
- package/docs/src/core/components/functional/sdui/sdui.md +0 -356
- package/docs/src/core/components/functional/states/states.md +0 -87
- package/docs/src/core/components/functional/submit/submit.md +0 -114
- package/docs/src/core/components/functional/subscriber/subscriber.md +0 -91
- package/docs/src/core/components/functional/value/value.md +0 -35
- package/docs/src/core/components/ui/alert/alert.md +0 -121
- package/docs/src/core/components/ui/alert-messages/alert-messages.md +0 -0
- package/docs/src/core/components/ui/badge/badge.md +0 -127
- package/docs/src/core/components/ui/button/button.md +0 -182
- package/docs/src/core/components/ui/captcha/captcha.md +0 -12
- package/docs/src/core/components/ui/card/card.md +0 -97
- package/docs/src/core/components/ui/divider/divider.md +0 -35
- package/docs/src/core/components/ui/form/checkbox/checkbox.md +0 -77
- package/docs/src/core/components/ui/form/fieldset/fieldset.md +0 -129
- package/docs/src/core/components/ui/form/form-actions/form-actions.md +0 -77
- package/docs/src/core/components/ui/form/form-layout/form-layout.md +0 -44
- package/docs/src/core/components/ui/form/input/input.md +0 -142
- package/docs/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +0 -133
- package/docs/src/core/components/ui/form/radio/radio.md +0 -57
- package/docs/src/core/components/ui/form/select/select.md +0 -71
- package/docs/src/core/components/ui/form/switch/switch.md +0 -57
- package/docs/src/core/components/ui/form/textarea/textarea.md +0 -65
- package/docs/src/core/components/ui/group/group.md +0 -75
- package/docs/src/core/components/ui/icon/icon.md +0 -125
- package/docs/src/core/components/ui/icon/icons.json +0 -1
- package/docs/src/core/components/ui/image/image.md +0 -107
- package/docs/src/core/components/ui/link/link.md +0 -43
- package/docs/src/core/components/ui/loader/loader.md +0 -55
- package/docs/src/core/components/ui/menu/menu.md +0 -329
- package/docs/src/core/components/ui/modal/modal.md +0 -119
- package/docs/src/core/components/ui/pop/pop.md +0 -96
- package/docs/src/core/components/ui/progress/progress.md +0 -63
- package/docs/src/core/components/ui/table/table.md +0 -455
- package/docs/src/core/components/ui/toast/toast.md +0 -166
- package/docs/src/core/components/ui/tooltip/tooltip.md +0 -82
- package/docs/src/docs/_core-concept/dataFlow.md +0 -88
- package/docs/src/docs/_core-concept/overview.md +0 -57
- package/docs/src/docs/_core-concept/subscriber.md +0 -75
- package/docs/src/docs/_decorators/ancestor-attribute.md +0 -127
- package/docs/src/docs/_decorators/auto-subscribe.md +0 -202
- package/docs/src/docs/_decorators/bind.md +0 -167
- package/docs/src/docs/_decorators/get.md +0 -162
- package/docs/src/docs/_decorators/handle.md +0 -175
- package/docs/src/docs/_decorators/on-assign.md +0 -390
- package/docs/src/docs/_decorators/patch.md +0 -70
- package/docs/src/docs/_decorators/post.md +0 -146
- package/docs/src/docs/_decorators/publish.md +0 -55
- package/docs/src/docs/_decorators/put.md +0 -70
- package/docs/src/docs/_decorators/subscribe.md +0 -100
- package/docs/src/docs/_decorators/wait-for-ancestors.md +0 -163
- package/docs/src/docs/_directives/sub.md +0 -91
- package/docs/src/docs/_getting-started/ai-agents.md +0 -76
- package/docs/src/docs/_getting-started/concorde-manual-install.md +0 -133
- package/docs/src/docs/_getting-started/concorde-outside.md +0 -33
- package/docs/src/docs/_getting-started/create-a-component.md +0 -139
- package/docs/src/docs/_getting-started/my-first-component.md +0 -236
- package/docs/src/docs/_getting-started/my-first-subscriber.md +0 -120
- package/docs/src/docs/_getting-started/pubsub.md +0 -37
- package/docs/src/docs/_getting-started/start.md +0 -47
- package/docs/src/docs/_getting-started/theming.md +0 -91
- package/docs/src/docs/_misc/api-configuration.md +0 -81
- package/docs/src/docs/_misc/dataProviderKey.md +0 -168
- package/docs/src/docs/_misc/docs-mock-api.md +0 -63
- package/docs/src/docs/_misc/dynamic-path.md +0 -71
- package/docs/src/docs/_misc/endpoint.md +0 -45
- package/docs/src/docs/_misc/formelement-subscriber-removal.md +0 -115
- package/docs/src/docs/_misc/html-integration.md +0 -15
- package/docs/src/docs/search/docs-search.json +0 -9512
- package/docs/src/tag-list.json +0 -1
- package/docs/src/tsconfig-model.json +0 -23
- package/docs/src/tsconfig.declarations.json +0 -22
- package/docs/src/tsconfig.emit.json +0 -23
- package/docs/src/tsconfig.json +0 -858
- package/docs/svg/regular/plane.svg +0 -1
- package/docs/svg/solid/plane.svg +0 -1
- package/gitlab/job_github_mirror.sh +0 -39
- package/scripts/github-export.mjs +0 -150
- package/src/css.d.ts +0 -19
- package/src/tsconfig.declarations.json +0 -22
- package/src/tsconfig.emit.json +0 -23
package/docs/docs-mock-api-sw.js
DELETED
|
@@ -1,720 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
(() => {
|
|
3
|
-
// src/docs/mock-api/urls.ts
|
|
4
|
-
var DOCS_MOCK_API_BASE = "/docs-mock-api";
|
|
5
|
-
var DOCS_MOCK_GEO_SERVICE = `${DOCS_MOCK_API_BASE}/geo/`;
|
|
6
|
-
var DOCS_MOCK_JOKES_SERVICE = `${DOCS_MOCK_API_BASE}/jokes`;
|
|
7
|
-
|
|
8
|
-
// src/docs/mock-api/api-config-mock.ts
|
|
9
|
-
var DOCS_MOCK_TOKEN_VALID = "docs-mock-valid-token";
|
|
10
|
-
var DOCS_MOCK_TOKEN_STALE = "docs-mock-stale-token";
|
|
11
|
-
var DOCS_MOCK_TOKEN_FRESH = "docs-mock-fresh-token";
|
|
12
|
-
var DOCS_MOCK_BASIC_USER = "demo";
|
|
13
|
-
var DOCS_MOCK_BASIC_PASSWORD = "secret";
|
|
14
|
-
var DOCS_MOCK_EVENTS_API_TOKEN = "docs-mock-events-token";
|
|
15
|
-
var WORDING_CATALOG = {
|
|
16
|
-
"api-config.greeting": { fr: "Bonjour", en: "Hello" },
|
|
17
|
-
"api-config.farewell": { fr: "Au revoir", en: "Goodbye" },
|
|
18
|
-
"api-config.hint": {
|
|
19
|
-
fr: "Libell\xE9s servis par le mock /wording/labels",
|
|
20
|
-
en: "Labels served by mock /wording/labels"
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
function json(body, init = {}) {
|
|
24
|
-
const headers = new Headers(init.headers);
|
|
25
|
-
headers.set("Content-Type", "application/json; charset=utf-8");
|
|
26
|
-
headers.set("Access-Control-Allow-Origin", "*");
|
|
27
|
-
headers.set("X-Docs-Mock-Api", "concorde-api-config");
|
|
28
|
-
return new Response(JSON.stringify(body), { ...init, headers });
|
|
29
|
-
}
|
|
30
|
-
function parseAuthorization(request) {
|
|
31
|
-
const header = request.headers.get("authorization");
|
|
32
|
-
if (!header) return { kind: "none" };
|
|
33
|
-
const basic = header.match(/^Basic\s+(.+)$/i);
|
|
34
|
-
if (basic) {
|
|
35
|
-
try {
|
|
36
|
-
const decoded = atob(basic[1]);
|
|
37
|
-
const sep = decoded.indexOf(":");
|
|
38
|
-
if (sep < 0) return { kind: "none" };
|
|
39
|
-
return {
|
|
40
|
-
kind: "basic",
|
|
41
|
-
user: decoded.slice(0, sep),
|
|
42
|
-
password: decoded.slice(sep + 1)
|
|
43
|
-
};
|
|
44
|
-
} catch {
|
|
45
|
-
return { kind: "none" };
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const bearer = header.match(/^Bearer\s+(.+)$/i);
|
|
49
|
-
if (bearer) return { kind: "bearer", token: bearer[1].trim() };
|
|
50
|
-
return { kind: "none" };
|
|
51
|
-
}
|
|
52
|
-
function isValidBasic(auth) {
|
|
53
|
-
return auth.kind === "basic" && auth.user === DOCS_MOCK_BASIC_USER && auth.password === DOCS_MOCK_BASIC_PASSWORD;
|
|
54
|
-
}
|
|
55
|
-
function wordingLabels(url) {
|
|
56
|
-
const lang = url.searchParams.get("lang") || "fr";
|
|
57
|
-
const labels = url.searchParams.getAll("labels[]").length ? url.searchParams.getAll("labels[]") : url.searchParams.getAll("labels");
|
|
58
|
-
const result = {};
|
|
59
|
-
for (const key of labels) {
|
|
60
|
-
const entry = WORDING_CATALOG[key];
|
|
61
|
-
result[key] = entry?.[lang] ?? entry?.en ?? `[missing:${key}]`;
|
|
62
|
-
}
|
|
63
|
-
return json({ lang, labels: result, ...result });
|
|
64
|
-
}
|
|
65
|
-
function handleApiConfigMockRequest(request, subPath, method) {
|
|
66
|
-
if (subPath === "/auth/token" && method === "GET") {
|
|
67
|
-
const auth = parseAuthorization(request);
|
|
68
|
-
if (isValidBasic(auth)) {
|
|
69
|
-
return json({
|
|
70
|
-
token: DOCS_MOCK_TOKEN_FRESH,
|
|
71
|
-
source: "basic",
|
|
72
|
-
serviceHost: new URL(request.url).searchParams.get("serviceHost")
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
if (auth.kind === "bearer" && auth.token === DOCS_MOCK_EVENTS_API_TOKEN) {
|
|
76
|
-
return json({
|
|
77
|
-
token: DOCS_MOCK_TOKEN_FRESH,
|
|
78
|
-
source: "eventsApiToken"
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return json({ error: "Unauthorized" }, { status: 401 });
|
|
82
|
-
}
|
|
83
|
-
if (subPath === "/api/config/protected" && method === "GET") {
|
|
84
|
-
const auth = parseAuthorization(request);
|
|
85
|
-
if (auth.kind === "bearer") {
|
|
86
|
-
if (auth.token === DOCS_MOCK_TOKEN_STALE) {
|
|
87
|
-
return json({ error: "Token expired", code: "token_stale" }, { status: 498 });
|
|
88
|
-
}
|
|
89
|
-
if (auth.token === DOCS_MOCK_TOKEN_VALID || auth.token === DOCS_MOCK_TOKEN_FRESH) {
|
|
90
|
-
return json({
|
|
91
|
-
ok: true,
|
|
92
|
-
message: "Protected resource",
|
|
93
|
-
tokenUsed: auth.token
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (isValidBasic(auth)) {
|
|
98
|
-
return json({
|
|
99
|
-
ok: true,
|
|
100
|
-
message: "Protected resource (basic)",
|
|
101
|
-
tokenUsed: null
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return json({ error: "Unauthorized" }, { status: 401 });
|
|
105
|
-
}
|
|
106
|
-
if ((subPath === "/wording/labels" || subPath.startsWith("/wording/labels")) && method === "GET") {
|
|
107
|
-
return wordingLabels(new URL(request.url));
|
|
108
|
-
}
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
var API_CONFIG_MOCK_PATHS = [
|
|
112
|
-
`${DOCS_MOCK_API_BASE}/auth/token`,
|
|
113
|
-
`${DOCS_MOCK_API_BASE}/api/config/protected`,
|
|
114
|
-
`${DOCS_MOCK_API_BASE}/wording/labels`
|
|
115
|
-
];
|
|
116
|
-
|
|
117
|
-
// src/docs/mock-api/fixtures.ts
|
|
118
|
-
var reqresAvatar = (seed) => `https://i.pravatar.cc/150?u=${encodeURIComponent(seed)}`;
|
|
119
|
-
var REQRES_EXTRA_NAMES = [
|
|
120
|
-
["Michael", "Lawson"],
|
|
121
|
-
["Tobias", "Funke"],
|
|
122
|
-
["Lindsay", "Funke"],
|
|
123
|
-
["Maeby", "Funke"],
|
|
124
|
-
["George", "Michael"],
|
|
125
|
-
["Annye", "Vang"],
|
|
126
|
-
["Rachel", "Howe"],
|
|
127
|
-
["Terry", "Medhurst"],
|
|
128
|
-
["Bette", "Haag"],
|
|
129
|
-
["Lester", "Solomon"],
|
|
130
|
-
["April", "Douglas"],
|
|
131
|
-
["Marian", "Roberts"],
|
|
132
|
-
["Kathryn", "Murphy"],
|
|
133
|
-
["Gloria", "Armstrong"],
|
|
134
|
-
["Adam", "Bradley"],
|
|
135
|
-
["Angela", "Hicks"],
|
|
136
|
-
["Rose", "Wheeler"],
|
|
137
|
-
["Sara", "Berry"],
|
|
138
|
-
["Glen", "Kuhn"],
|
|
139
|
-
["Roger", "Cox"]
|
|
140
|
-
];
|
|
141
|
-
function buildReqresUser(id, first_name, last_name) {
|
|
142
|
-
const slug = `${first_name}-${last_name}`.toLowerCase();
|
|
143
|
-
return {
|
|
144
|
-
id,
|
|
145
|
-
email: `${first_name.toLowerCase()}.${last_name.toLowerCase()}@example.com`,
|
|
146
|
-
first_name,
|
|
147
|
-
last_name,
|
|
148
|
-
avatar: reqresAvatar(slug)
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
var DOCS_REQRES_USERS = [
|
|
152
|
-
buildReqresUser(1, "George", "Bluth"),
|
|
153
|
-
buildReqresUser(2, "Janet", "Weaver"),
|
|
154
|
-
buildReqresUser(3, "Emma", "Wong"),
|
|
155
|
-
buildReqresUser(4, "Eve", "Holt"),
|
|
156
|
-
...REQRES_EXTRA_NAMES.map(
|
|
157
|
-
([first_name, last_name], index) => buildReqresUser(5 + index, first_name, last_name)
|
|
158
|
-
)
|
|
159
|
-
];
|
|
160
|
-
function filterDocsUsers(users, query) {
|
|
161
|
-
const q = query?.trim().toLowerCase();
|
|
162
|
-
if (!q) return users;
|
|
163
|
-
return users.filter((user) => {
|
|
164
|
-
const haystack = `${user.first_name} ${user.last_name} ${user.email}`.toLowerCase();
|
|
165
|
-
return haystack.includes(q);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
var DOCS_GEO_COMMUNES = [
|
|
169
|
-
{ nom: "Paris", code: "75056" },
|
|
170
|
-
{ nom: "Lyon", code: "69123" },
|
|
171
|
-
{ nom: "Marseille", code: "13055" },
|
|
172
|
-
{ nom: "Toulouse", code: "31555" },
|
|
173
|
-
{ nom: "Lille", code: "59350" },
|
|
174
|
-
{ nom: "Bordeaux", code: "33063" },
|
|
175
|
-
{ nom: "Nantes", code: "44109" },
|
|
176
|
-
{ nom: "Strasbourg", code: "67482" },
|
|
177
|
-
{ nom: "Montpellier", code: "34172" },
|
|
178
|
-
{ nom: "Rennes", code: "35238" }
|
|
179
|
-
];
|
|
180
|
-
var jokeFlags = (partial = {}) => ({
|
|
181
|
-
nsfw: false,
|
|
182
|
-
religious: false,
|
|
183
|
-
political: false,
|
|
184
|
-
racist: false,
|
|
185
|
-
sexist: false,
|
|
186
|
-
explicit: false,
|
|
187
|
-
...partial
|
|
188
|
-
});
|
|
189
|
-
var SAMPLE_JOKES = [
|
|
190
|
-
{
|
|
191
|
-
categories: ["Programming"],
|
|
192
|
-
createdAt: "2020-01-01 00:00:00",
|
|
193
|
-
id: 1,
|
|
194
|
-
lang: "en",
|
|
195
|
-
joke: "Why do programmers prefer dark mode? Because light attracts bugs.",
|
|
196
|
-
flags: jokeFlags(),
|
|
197
|
-
safe: true,
|
|
198
|
-
type: "single"
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
categories: ["Misc"],
|
|
202
|
-
createdAt: "2020-01-02 00:00:00",
|
|
203
|
-
id: 2,
|
|
204
|
-
lang: "en",
|
|
205
|
-
joke: "I told my computer I needed a break \u2014 it said: no problem, I'll go to sleep.",
|
|
206
|
-
flags: jokeFlags({ nsfw: true }),
|
|
207
|
-
safe: false,
|
|
208
|
-
type: "single"
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
categories: ["Pun"],
|
|
212
|
-
createdAt: "2020-01-03 00:00:00",
|
|
213
|
-
id: 3,
|
|
214
|
-
lang: "en",
|
|
215
|
-
joke: "Concorde docs run offline: even the API is a local joke.",
|
|
216
|
-
flags: jokeFlags(),
|
|
217
|
-
safe: true,
|
|
218
|
-
type: "single"
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
categories: ["Animals"],
|
|
222
|
-
createdAt: "2020-01-04 00:00:00",
|
|
223
|
-
id: 4,
|
|
224
|
-
lang: "en",
|
|
225
|
-
joke: "The dog ate my homework and my pull request.",
|
|
226
|
-
flags: jokeFlags({ political: true }),
|
|
227
|
-
safe: true,
|
|
228
|
-
type: "single"
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
categories: ["Animals", "Pun"],
|
|
232
|
-
createdAt: "2020-01-05 00:00:00",
|
|
233
|
-
id: 5,
|
|
234
|
-
lang: "fr",
|
|
235
|
-
joke: "Quel est le chien pr\xE9f\xE9r\xE9 des d\xE9veloppeurs ? Le labrador Retriever.",
|
|
236
|
-
flags: jokeFlags(),
|
|
237
|
-
safe: true,
|
|
238
|
-
type: "single"
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
categories: ["Animals"],
|
|
242
|
-
createdAt: "2020-01-06 00:00:00",
|
|
243
|
-
id: 6,
|
|
244
|
-
lang: "fr",
|
|
245
|
-
joke: "Un chat et un chien discutent de TypeScript : le chien dit \xAB woof \xBB, le chat compile.",
|
|
246
|
-
flags: jokeFlags({ racist: true }),
|
|
247
|
-
safe: false,
|
|
248
|
-
type: "single"
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
categories: ["Misc"],
|
|
252
|
-
createdAt: "2020-01-07 00:00:00",
|
|
253
|
-
id: 7,
|
|
254
|
-
lang: "fr",
|
|
255
|
-
joke: "Pourquoi les blagues offline sont-elles fiables ? Parce qu'elles passent par le Service Worker.",
|
|
256
|
-
flags: jokeFlags({ religious: true }),
|
|
257
|
-
safe: true,
|
|
258
|
-
type: "single"
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
categories: ["Programming"],
|
|
262
|
-
createdAt: "2020-01-08 00:00:00",
|
|
263
|
-
id: 8,
|
|
264
|
-
lang: "fr",
|
|
265
|
-
joke: "Mon compilateur et mon chien : tous deux ignorent mes commandes jusqu'au build.",
|
|
266
|
-
flags: jokeFlags({ sexist: true }),
|
|
267
|
-
safe: false,
|
|
268
|
-
type: "single"
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
categories: ["Misc"],
|
|
272
|
-
createdAt: "2020-01-09 00:00:00",
|
|
273
|
-
id: 9,
|
|
274
|
-
lang: "en",
|
|
275
|
-
joke: "A SQL query walks into a bar, walks up to two tables and asks: Can I join you?",
|
|
276
|
-
flags: jokeFlags({ explicit: true }),
|
|
277
|
-
safe: false,
|
|
278
|
-
type: "single"
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
categories: ["Pun"],
|
|
282
|
-
createdAt: "2020-01-10 00:00:00",
|
|
283
|
-
id: 10,
|
|
284
|
-
lang: "fr",
|
|
285
|
-
joke: "J'ai cherch\xE9 \xAB chien \xBB dans la doc : le mock API a r\xE9pondu.",
|
|
286
|
-
flags: jokeFlags(),
|
|
287
|
-
safe: true,
|
|
288
|
-
type: "single"
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
categories: ["Misc"],
|
|
292
|
-
createdAt: "2020-01-11 00:00:00",
|
|
293
|
-
id: 11,
|
|
294
|
-
lang: "en",
|
|
295
|
-
joke: "There are only two hard things in Computer Science: cache invalidation and naming things.",
|
|
296
|
-
flags: jokeFlags({ political: true, explicit: true }),
|
|
297
|
-
safe: false,
|
|
298
|
-
type: "single"
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
categories: ["Animals"],
|
|
302
|
-
createdAt: "2020-01-12 00:00:00",
|
|
303
|
-
id: 12,
|
|
304
|
-
lang: "fr",
|
|
305
|
-
joke: "Le golden retriever a r\xE9cup\xE9r\xE9 la donn\xE9e du publisher.",
|
|
306
|
-
flags: jokeFlags({ racist: true, sexist: true }),
|
|
307
|
-
safe: false,
|
|
308
|
-
type: "two-liner",
|
|
309
|
-
setup: "Pourquoi le chien aime Concorde ?",
|
|
310
|
-
delivery: "Parce qu'il sait fetch."
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
categories: ["Misc"],
|
|
314
|
-
createdAt: "2020-01-13 00:00:00",
|
|
315
|
-
id: 13,
|
|
316
|
-
lang: "en",
|
|
317
|
-
joke: "My code and my conscience: both have too many warnings.",
|
|
318
|
-
flags: jokeFlags(),
|
|
319
|
-
safe: true,
|
|
320
|
-
type: "single"
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
categories: ["Programming"],
|
|
324
|
-
createdAt: "2020-01-14 00:00:00",
|
|
325
|
-
id: 14,
|
|
326
|
-
lang: "en",
|
|
327
|
-
joke: "Git blame is just a mirror.",
|
|
328
|
-
flags: jokeFlags({ religious: true, political: true }),
|
|
329
|
-
safe: false,
|
|
330
|
-
type: "single"
|
|
331
|
-
}
|
|
332
|
-
];
|
|
333
|
-
function parseBlacklistFlags(url) {
|
|
334
|
-
const keys = /* @__PURE__ */ new Set();
|
|
335
|
-
const valid = [
|
|
336
|
-
"nsfw",
|
|
337
|
-
"religious",
|
|
338
|
-
"political",
|
|
339
|
-
"racist",
|
|
340
|
-
"sexist",
|
|
341
|
-
"explicit"
|
|
342
|
-
];
|
|
343
|
-
const add = (raw) => {
|
|
344
|
-
raw.split(",").map((s) => s.trim().toLowerCase()).forEach((part) => {
|
|
345
|
-
if (valid.includes(part)) keys.add(part);
|
|
346
|
-
});
|
|
347
|
-
};
|
|
348
|
-
url.searchParams.getAll("blacklistFlags").forEach(add);
|
|
349
|
-
const single = url.searchParams.get("blacklistFlags");
|
|
350
|
-
if (single) add(single);
|
|
351
|
-
return [...keys];
|
|
352
|
-
}
|
|
353
|
-
function applyJokeBlacklist(jokes, blacklist) {
|
|
354
|
-
if (!blacklist.length) return jokes;
|
|
355
|
-
return jokes.filter(
|
|
356
|
-
(j) => !blacklist.some((flag) => j.flags[flag] === true)
|
|
357
|
-
);
|
|
358
|
-
}
|
|
359
|
-
function filterDocsJokes(jokes, url) {
|
|
360
|
-
let pool = jokes;
|
|
361
|
-
const contains = url.searchParams.get("contains")?.trim().toLowerCase();
|
|
362
|
-
if (contains) {
|
|
363
|
-
pool = pool.filter((j) => {
|
|
364
|
-
const haystack = [j.joke, j.setup, j.delivery, ...j.categories].filter(Boolean).join(" ").toLowerCase();
|
|
365
|
-
return haystack.includes(contains);
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
const lang = url.searchParams.get("lang")?.trim().toLowerCase();
|
|
369
|
-
if (lang === "fr" || lang === "en") {
|
|
370
|
-
pool = pool.filter((j) => j.lang === lang);
|
|
371
|
-
}
|
|
372
|
-
pool = applyJokeBlacklist(pool, parseBlacklistFlags(url));
|
|
373
|
-
return pool;
|
|
374
|
-
}
|
|
375
|
-
function buildJokeApiResponse(url) {
|
|
376
|
-
const pool = filterDocsJokes(SAMPLE_JOKES, url);
|
|
377
|
-
const amount = Math.max(
|
|
378
|
-
1,
|
|
379
|
-
parseInt(url.searchParams.get("amount") || "10", 10)
|
|
380
|
-
);
|
|
381
|
-
const hasOffset = url.searchParams.has("offset");
|
|
382
|
-
const limit = Math.max(
|
|
383
|
-
1,
|
|
384
|
-
parseInt(
|
|
385
|
-
url.searchParams.get("limit") || url.searchParams.get("per_page") || String(amount),
|
|
386
|
-
10
|
|
387
|
-
)
|
|
388
|
-
);
|
|
389
|
-
const offset = Math.max(0, parseInt(url.searchParams.get("offset") || "0", 10));
|
|
390
|
-
const start = hasOffset ? offset : 0;
|
|
391
|
-
const count = hasOffset ? limit : amount;
|
|
392
|
-
const jokes = pool.slice(start, start + count).map((j, i) => ({
|
|
393
|
-
...j,
|
|
394
|
-
id: start + i + 1
|
|
395
|
-
}));
|
|
396
|
-
return { error: false, amount: jokes.length, jokes };
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
// src/docs/mock-api/fixtures-jsonata.ts
|
|
400
|
-
var avatar = (seed) => `https://i.pravatar.cc/150?u=${encodeURIComponent(seed)}`;
|
|
401
|
-
var DOCS_SPACE_CAT_MISSIONS = [
|
|
402
|
-
{
|
|
403
|
-
id: 1,
|
|
404
|
-
name: "Captain Whiskers",
|
|
405
|
-
planet: "Mars",
|
|
406
|
-
mission: "Laser hunt",
|
|
407
|
-
points: 40,
|
|
408
|
-
avatar: avatar("captain-whiskers")
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
id: 2,
|
|
412
|
-
name: "Captain Whiskers",
|
|
413
|
-
planet: "Mars",
|
|
414
|
-
mission: "Dust nap",
|
|
415
|
-
points: 25,
|
|
416
|
-
avatar: avatar("captain-whiskers")
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
id: 3,
|
|
420
|
-
name: "Nebula Paws",
|
|
421
|
-
planet: "Europa",
|
|
422
|
-
mission: "Ice fishing",
|
|
423
|
-
points: 55,
|
|
424
|
-
avatar: avatar("nebula-paws")
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
id: 4,
|
|
428
|
-
name: "Astro Mittens",
|
|
429
|
-
planet: "Titan",
|
|
430
|
-
mission: "Methane surf",
|
|
431
|
-
points: 33,
|
|
432
|
-
avatar: avatar("astro-mittens")
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
id: 5,
|
|
436
|
-
name: "Nebula Paws",
|
|
437
|
-
planet: "Europa",
|
|
438
|
-
mission: "Comet chase",
|
|
439
|
-
points: 20,
|
|
440
|
-
avatar: avatar("nebula-paws")
|
|
441
|
-
},
|
|
442
|
-
{
|
|
443
|
-
id: 6,
|
|
444
|
-
name: "Professor Meowington",
|
|
445
|
-
planet: "Venus",
|
|
446
|
-
mission: "Cloud tasting",
|
|
447
|
-
points: 48,
|
|
448
|
-
avatar: avatar("prof-meowington")
|
|
449
|
-
},
|
|
450
|
-
{
|
|
451
|
-
id: 7,
|
|
452
|
-
name: "Astro Mittens",
|
|
453
|
-
planet: "Titan",
|
|
454
|
-
mission: "Antenna polish",
|
|
455
|
-
points: 12,
|
|
456
|
-
avatar: avatar("astro-mittens")
|
|
457
|
-
},
|
|
458
|
-
{
|
|
459
|
-
id: 8,
|
|
460
|
-
name: "Zero-G Socks",
|
|
461
|
-
planet: "Moon",
|
|
462
|
-
mission: "Flag knitting",
|
|
463
|
-
points: 61,
|
|
464
|
-
avatar: avatar("zero-g-socks")
|
|
465
|
-
}
|
|
466
|
-
];
|
|
467
|
-
var DOCS_COFFEE_BAGS = [
|
|
468
|
-
{ id: 1, origin: "Ethiopia", roast: "light", kg: 12, farm: "Yirgacheffe Hills" },
|
|
469
|
-
{ id: 2, origin: "Ethiopia", roast: "medium", kg: 8, farm: "Sidamo Ridge" },
|
|
470
|
-
{ id: 3, origin: "Colombia", roast: "medium", kg: 15, farm: "Huila Valley" },
|
|
471
|
-
{ id: 4, origin: "Colombia", roast: "dark", kg: 6, farm: "Cauca Peak" },
|
|
472
|
-
{ id: 5, origin: "Brazil", roast: "dark", kg: 22, farm: "Minas Gerais" },
|
|
473
|
-
{ id: 6, origin: "Brazil", roast: "medium", kg: 10, farm: "Cerrado" },
|
|
474
|
-
{ id: 7, origin: "Guatemala", roast: "light", kg: 9, farm: "Antigua" },
|
|
475
|
-
{ id: 8, origin: "Guatemala", roast: "dark", kg: 5, farm: "Huehuetenango" },
|
|
476
|
-
{ id: 9, origin: "Ethiopia", roast: "light", kg: 4, farm: "Guji Forest" }
|
|
477
|
-
];
|
|
478
|
-
function filterCoffeeBags(bags, roast) {
|
|
479
|
-
const r = roast?.trim().toLowerCase();
|
|
480
|
-
if (!r || r === "all") return bags;
|
|
481
|
-
return bags.filter((b) => b.roast === r);
|
|
482
|
-
}
|
|
483
|
-
var DOCS_MARKET_ORDER_LINES = [
|
|
484
|
-
{ id: 1, name: "Heirloom tomatoes", qty: 4, unitPrice: 3.5, category: "veg" },
|
|
485
|
-
{ id: 2, name: "Sourdough loaf", qty: 2, unitPrice: 6, category: "bakery" },
|
|
486
|
-
{ id: 3, name: "Goat cheese", qty: 1, unitPrice: 8.5, category: "dairy" },
|
|
487
|
-
{ id: 4, name: "Honey jar", qty: 3, unitPrice: 5.2, category: "pantry" },
|
|
488
|
-
{ id: 5, name: "Sunflowers", qty: 5, unitPrice: 2, category: "flowers" },
|
|
489
|
-
{ id: 6, name: "Free-range eggs", qty: 2, unitPrice: 4.8, category: "dairy" }
|
|
490
|
-
];
|
|
491
|
-
|
|
492
|
-
// src/docs/mock-api/router.ts
|
|
493
|
-
var DOCS_MOCK_API_PREFIX = "/docs-mock-api";
|
|
494
|
-
function json2(body, init = {}) {
|
|
495
|
-
const { delayMs = 0, ...responseInit } = init;
|
|
496
|
-
const headers = new Headers(responseInit.headers);
|
|
497
|
-
headers.set("Content-Type", "application/json; charset=utf-8");
|
|
498
|
-
headers.set("Access-Control-Allow-Origin", "*");
|
|
499
|
-
headers.set("X-Docs-Mock-Api", "concorde");
|
|
500
|
-
const build = () => new Response(JSON.stringify(body), { ...responseInit, headers });
|
|
501
|
-
if (delayMs <= 0) return Promise.resolve(build());
|
|
502
|
-
return new Promise(
|
|
503
|
-
(resolve) => setTimeout(() => resolve(build()), delayMs)
|
|
504
|
-
);
|
|
505
|
-
}
|
|
506
|
-
function paginateUsers(url) {
|
|
507
|
-
const perPage = Math.max(
|
|
508
|
-
1,
|
|
509
|
-
parseInt(
|
|
510
|
-
url.searchParams.get("per_page") || url.searchParams.get("limit") || "6",
|
|
511
|
-
10
|
|
512
|
-
)
|
|
513
|
-
);
|
|
514
|
-
const pool = filterDocsUsers(DOCS_REQRES_USERS, url.searchParams.get("q"));
|
|
515
|
-
const total = pool.length;
|
|
516
|
-
let start;
|
|
517
|
-
let page;
|
|
518
|
-
if (url.searchParams.has("offset")) {
|
|
519
|
-
start = Math.max(0, parseInt(url.searchParams.get("offset") || "0", 10));
|
|
520
|
-
page = Math.floor(start / perPage) + 1;
|
|
521
|
-
} else {
|
|
522
|
-
page = Math.max(1, parseInt(url.searchParams.get("page") || "1", 10));
|
|
523
|
-
start = (page - 1) * perPage;
|
|
524
|
-
}
|
|
525
|
-
const data = pool.slice(start, start + perPage);
|
|
526
|
-
return {
|
|
527
|
-
page,
|
|
528
|
-
per_page: perPage,
|
|
529
|
-
total,
|
|
530
|
-
total_pages: Math.max(1, Math.ceil(total / perPage)),
|
|
531
|
-
data
|
|
532
|
-
};
|
|
533
|
-
}
|
|
534
|
-
async function parseRegisterFields(request) {
|
|
535
|
-
const contentType = (request.headers.get("content-type") || "").toLowerCase();
|
|
536
|
-
if (contentType.includes("multipart/form-data")) {
|
|
537
|
-
const fd = await request.formData();
|
|
538
|
-
return {
|
|
539
|
-
email: String(fd.get("email") ?? ""),
|
|
540
|
-
password: String(fd.get("password") ?? "")
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
if (contentType.includes("application/x-www-form-urlencoded")) {
|
|
544
|
-
const text2 = await request.text();
|
|
545
|
-
const params = new URLSearchParams(text2);
|
|
546
|
-
return {
|
|
547
|
-
email: params.get("email") ?? "",
|
|
548
|
-
password: params.get("password") ?? ""
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
const text = await request.text();
|
|
552
|
-
if (!text.trim()) return {};
|
|
553
|
-
try {
|
|
554
|
-
const parsed = JSON.parse(text);
|
|
555
|
-
return {
|
|
556
|
-
email: parsed.email != null ? String(parsed.email) : "",
|
|
557
|
-
password: parsed.password != null ? String(parsed.password) : ""
|
|
558
|
-
};
|
|
559
|
-
} catch {
|
|
560
|
-
const params = new URLSearchParams(text);
|
|
561
|
-
if (params.has("email") || params.has("password")) {
|
|
562
|
-
return {
|
|
563
|
-
email: params.get("email") ?? "",
|
|
564
|
-
password: params.get("password") ?? ""
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
return {};
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
function registerOkBody(fields, nested = false) {
|
|
571
|
-
const payload = {
|
|
572
|
-
id: 4,
|
|
573
|
-
token: "docs-mock-register-token",
|
|
574
|
-
email: fields.email
|
|
575
|
-
};
|
|
576
|
-
return nested ? { data: payload } : payload;
|
|
577
|
-
}
|
|
578
|
-
function geoCommunes(url) {
|
|
579
|
-
const limit = Math.max(
|
|
580
|
-
1,
|
|
581
|
-
parseInt(url.searchParams.get("limit") || "5", 10)
|
|
582
|
-
);
|
|
583
|
-
const offset = Math.max(0, parseInt(url.searchParams.get("offset") || "0", 10));
|
|
584
|
-
return DOCS_GEO_COMMUNES.slice(offset, offset + limit);
|
|
585
|
-
}
|
|
586
|
-
async function handleDocsMockApiRequest(request) {
|
|
587
|
-
const url = new URL(request.url);
|
|
588
|
-
if (!url.pathname.startsWith(DOCS_MOCK_API_PREFIX)) return null;
|
|
589
|
-
const subPath = url.pathname.slice(DOCS_MOCK_API_PREFIX.length) || "/";
|
|
590
|
-
const method = request.method.toUpperCase();
|
|
591
|
-
if (subPath === "/health") {
|
|
592
|
-
return json2({ ok: true, service: "concorde-docs-mock-api" });
|
|
593
|
-
}
|
|
594
|
-
const apiConfigResponse = handleApiConfigMockRequest(request, subPath, method);
|
|
595
|
-
if (apiConfigResponse) return apiConfigResponse;
|
|
596
|
-
if ((subPath === "/api/register" || subPath === "/api/register/nested") && method === "POST") {
|
|
597
|
-
const body = await parseRegisterFields(request);
|
|
598
|
-
if (!body.email?.trim() || !body.password?.trim()) {
|
|
599
|
-
return json2(
|
|
600
|
-
{
|
|
601
|
-
messages: [
|
|
602
|
-
{
|
|
603
|
-
content: "email and password are required",
|
|
604
|
-
status: "error"
|
|
605
|
-
}
|
|
606
|
-
]
|
|
607
|
-
},
|
|
608
|
-
{ status: 400 }
|
|
609
|
-
);
|
|
610
|
-
}
|
|
611
|
-
return json2(
|
|
612
|
-
registerOkBody(
|
|
613
|
-
{ email: body.email.trim(), password: body.password.trim() },
|
|
614
|
-
subPath === "/api/register/nested"
|
|
615
|
-
)
|
|
616
|
-
);
|
|
617
|
-
}
|
|
618
|
-
const sessionSyncMatch = subPath.match(/^\/api\/sessions\/([^/]+)\/sync$/);
|
|
619
|
-
if (sessionSyncMatch && method === "POST") {
|
|
620
|
-
const sessionId = decodeURIComponent(sessionSyncMatch[1]);
|
|
621
|
-
let body = {};
|
|
622
|
-
try {
|
|
623
|
-
const text = await request.text();
|
|
624
|
-
if (text.trim()) {
|
|
625
|
-
body = JSON.parse(text);
|
|
626
|
-
}
|
|
627
|
-
} catch {
|
|
628
|
-
body = {};
|
|
629
|
-
}
|
|
630
|
-
return json2({
|
|
631
|
-
ok: true,
|
|
632
|
-
sessionId,
|
|
633
|
-
serverTime: Date.now(),
|
|
634
|
-
echo: body
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
if (subPath === "/api/register/echo" && method === "GET") {
|
|
638
|
-
const email = url.searchParams.get("email") ?? "";
|
|
639
|
-
const password = url.searchParams.get("password") ?? "";
|
|
640
|
-
if (!email.trim() || !password.trim()) {
|
|
641
|
-
return json2(
|
|
642
|
-
{
|
|
643
|
-
messages: [
|
|
644
|
-
{
|
|
645
|
-
content: "email and password query params are required",
|
|
646
|
-
status: "error"
|
|
647
|
-
}
|
|
648
|
-
]
|
|
649
|
-
},
|
|
650
|
-
{ status: 400 }
|
|
651
|
-
);
|
|
652
|
-
}
|
|
653
|
-
return json2({
|
|
654
|
-
method: "GET",
|
|
655
|
-
query: { email, password },
|
|
656
|
-
email,
|
|
657
|
-
note: 'sonic-submit method="get" appends form fields to the endpoint URL'
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
if (method !== "GET") {
|
|
661
|
-
return json2({ error: "Method not allowed" }, { status: 405 });
|
|
662
|
-
}
|
|
663
|
-
const userMatch = subPath.match(/^\/api\/users\/(\d+)$/);
|
|
664
|
-
if (userMatch) {
|
|
665
|
-
const id = parseInt(userMatch[1], 10);
|
|
666
|
-
const user = DOCS_REQRES_USERS.find((u) => u.id === id) ?? DOCS_REQRES_USERS[0];
|
|
667
|
-
const body = { data: { ...user, id } };
|
|
668
|
-
return json2(body);
|
|
669
|
-
}
|
|
670
|
-
if (subPath === "/api/users") {
|
|
671
|
-
return json2(paginateUsers(url));
|
|
672
|
-
}
|
|
673
|
-
if (subPath === "/api/space-cats") {
|
|
674
|
-
return json2({
|
|
675
|
-
data: DOCS_SPACE_CAT_MISSIONS,
|
|
676
|
-
total: DOCS_SPACE_CAT_MISSIONS.length
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
if (subPath === "/api/coffee-bags") {
|
|
680
|
-
const roast = url.searchParams.get("roast");
|
|
681
|
-
const data = filterCoffeeBags(DOCS_COFFEE_BAGS, roast);
|
|
682
|
-
return json2({ data, total: data.length });
|
|
683
|
-
}
|
|
684
|
-
if (subPath === "/api/market-order") {
|
|
685
|
-
return json2({
|
|
686
|
-
data: DOCS_MARKET_ORDER_LINES,
|
|
687
|
-
total: DOCS_MARKET_ORDER_LINES.length
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
if (subPath === "/geo/communes" || subPath.startsWith("/geo/communes")) {
|
|
691
|
-
return json2(geoCommunes(url), {
|
|
692
|
-
headers: { "X-Fetched-At": (/* @__PURE__ */ new Date()).toISOString() }
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
const jokeMatch = subPath.match(/^\/jokes\/joke\/([^/]+)$/);
|
|
696
|
-
if (jokeMatch) {
|
|
697
|
-
return json2(buildJokeApiResponse(url));
|
|
698
|
-
}
|
|
699
|
-
return json2({ error: "Not found", path: subPath }, { status: 404 });
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
// src/docs/mock-api/service-worker.ts
|
|
703
|
-
self.addEventListener("install", (event) => {
|
|
704
|
-
event.waitUntil(self.skipWaiting());
|
|
705
|
-
});
|
|
706
|
-
self.addEventListener("activate", (event) => {
|
|
707
|
-
event.waitUntil(self.clients.claim());
|
|
708
|
-
});
|
|
709
|
-
self.addEventListener("fetch", (event) => {
|
|
710
|
-
const { request } = event;
|
|
711
|
-
event.respondWith(
|
|
712
|
-
(async () => {
|
|
713
|
-
const mocked = await handleDocsMockApiRequest(request);
|
|
714
|
-
if (mocked) return mocked;
|
|
715
|
-
return fetch(request);
|
|
716
|
-
})()
|
|
717
|
-
);
|
|
718
|
-
});
|
|
719
|
-
})();
|
|
720
|
-
//# sourceMappingURL=docs-mock-api-sw.js.map
|