@plitzi/sdk-shared 0.39.2 → 0.39.4
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/CHANGELOG.md +11 -0
- package/dist/clients/index.d.ts +59 -0
- package/dist/clients/index.mjs +38 -0
- package/dist/conditions/types.d.ts +1 -1
- package/dist/csrf/csrf.d.ts +36 -0
- package/dist/csrf/csrf.mjs +62 -0
- package/dist/csrf/index.d.ts +2 -0
- package/dist/csrf/index.mjs +1 -0
- package/dist/helpers/deepEqual/deepEqual.mjs +3 -2
- package/dist/helpers/lodash/cloneDeep.d.ts +3 -3
- package/dist/helpers/lodash/cloneDeep.mjs +24 -27
- package/dist/helpers/lodash/has.d.ts +2 -1
- package/dist/helpers/lodash/has.mjs +8 -8
- package/dist/helpers/lodash/index.d.ts +1 -1
- package/dist/helpers/lodash/omit.mjs +2 -2
- package/dist/helpers/twigWrapper/filters/arrays.mjs +43 -42
- package/dist/helpers/twigWrapper/filters/filters.mjs +3 -3
- package/dist/helpers/twigWrapper/filters/index.mjs +4 -4
- package/dist/helpers/twigWrapper/filters/misc.mjs +14 -13
- package/dist/helpers/twigWrapper/filters/objects.mjs +50 -49
- package/dist/helpers/twigWrapper/filters/strings.mjs +41 -40
- package/dist/helpers/twigWrapper/filters/types.d.ts +4 -0
- package/dist/helpers/twigWrapper/filters/types.mjs +2 -2
- package/dist/navigation/index.d.ts +1 -1
- package/dist/navigation/index.mjs +3 -3
- package/dist/navigation/routes.d.ts +2 -0
- package/dist/navigation/routes.mjs +2 -1
- package/dist/navigation/sitemap.d.ts +8 -0
- package/dist/navigation/sitemap.mjs +7 -4
- package/dist/react/index.d.ts +1 -1
- package/dist/refusals/index.d.ts +112 -0
- package/dist/refusals/index.mjs +94 -0
- package/dist/schema/aiCrawlers.d.ts +25 -0
- package/dist/schema/aiCrawlers.mjs +34 -0
- package/dist/schema/documentParts.d.ts +45 -0
- package/dist/schema/documentParts.mjs +73 -0
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.mjs +21 -18
- package/dist/schema/pageAccess.mjs +1 -1
- package/dist/schema/plitziMark.d.ts +9 -0
- package/dist/schema/plitziMark.mjs +3 -0
- package/dist/schema/schemaSettings.d.ts +1 -1
- package/dist/schema/schemaSettings.mjs +1 -1
- package/dist/schema/serverElements.d.ts +5 -0
- package/dist/store/runtimeStatePersist.mjs +2 -2
- package/dist/store/storeHooks.d.ts +33 -33
- package/dist/style/runtimeStyle.d.ts +5 -2
- package/dist/style/runtimeStyle.mjs +1 -1
- package/dist/types/ActionTypes.d.ts +2 -0
- package/dist/types/AuthTypes.d.ts +5 -0
- package/dist/types/SchemaTypes.d.ts +31 -4
- package/dist/types/StoreTypes.d.ts +5 -0
- package/eslint.config.mjs +123 -100
- package/package.json +1 -1
|
@@ -1,60 +1,61 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isCallback as e, isList as t } from "./types.mjs";
|
|
2
|
+
import { toStr as n } from "./values.mjs";
|
|
2
3
|
// src/helpers/twigWrapper/filters/objects.ts
|
|
3
|
-
var
|
|
4
|
-
without: (
|
|
5
|
-
if (typeof
|
|
6
|
-
let
|
|
7
|
-
for (let [
|
|
8
|
-
return
|
|
4
|
+
var r = {
|
|
5
|
+
without: (e, r) => {
|
|
6
|
+
if (typeof e != "object" || !e || t(e)) return e;
|
|
7
|
+
let i = r.map(n), a = {};
|
|
8
|
+
for (let [t, n] of Object.entries(e)) i.includes(t) || (a[t] = n);
|
|
9
|
+
return a;
|
|
9
10
|
},
|
|
10
|
-
only: (
|
|
11
|
-
if (typeof
|
|
12
|
-
let
|
|
13
|
-
for (let [
|
|
14
|
-
return
|
|
11
|
+
only: (e, r) => {
|
|
12
|
+
if (typeof e != "object" || !e || t(e)) return e;
|
|
13
|
+
let i = r.map(n), a = {};
|
|
14
|
+
for (let [t, n] of Object.entries(e)) i.includes(t) && (a[t] = n);
|
|
15
|
+
return a;
|
|
15
16
|
}
|
|
16
|
-
},
|
|
17
|
-
find: (
|
|
18
|
-
if (!
|
|
19
|
-
let
|
|
20
|
-
if (
|
|
21
|
-
if (
|
|
22
|
-
let
|
|
23
|
-
return
|
|
17
|
+
}, i = {
|
|
18
|
+
find: (r, i) => {
|
|
19
|
+
if (!t(r) || i.length === 0) return;
|
|
20
|
+
let a = i[0];
|
|
21
|
+
if (e(a)) return r.find((e, t) => a(e, t));
|
|
22
|
+
if (i.length < 2) return;
|
|
23
|
+
let o = n(a), s = i[1];
|
|
24
|
+
return r.find((e) => typeof e == "object" && e ? e[o] === s : e === s);
|
|
24
25
|
},
|
|
25
|
-
pluck: (
|
|
26
|
-
if (!
|
|
27
|
-
let
|
|
28
|
-
return
|
|
26
|
+
pluck: (e, r) => {
|
|
27
|
+
if (!t(e) || r.length === 0) return e;
|
|
28
|
+
let i = n(r[0]);
|
|
29
|
+
return e.map((e) => typeof e == "object" && e ? e[i] : void 0);
|
|
29
30
|
},
|
|
30
|
-
unique: (e) =>
|
|
31
|
-
flatten: (e) =>
|
|
32
|
-
sum: (e) =>
|
|
33
|
-
chunk: (e,
|
|
34
|
-
if (!
|
|
35
|
-
let
|
|
36
|
-
if (
|
|
37
|
-
let
|
|
38
|
-
for (let t = 0; t < e.length; t +=
|
|
39
|
-
return
|
|
31
|
+
unique: (e) => t(e) ? [...new Set(e)] : e,
|
|
32
|
+
flatten: (e) => t(e) ? e.flat() : e,
|
|
33
|
+
sum: (e) => t(e) ? e.reduce((e, t) => e + (typeof t == "number" ? t : 0), 0) : e,
|
|
34
|
+
chunk: (e, n) => {
|
|
35
|
+
if (!t(e) || n.length === 0) return e;
|
|
36
|
+
let r = Number(n[0]);
|
|
37
|
+
if (r <= 0) return e;
|
|
38
|
+
let i = [];
|
|
39
|
+
for (let t = 0; t < e.length; t += r) i.push(e.slice(t, t + r));
|
|
40
|
+
return i;
|
|
40
41
|
},
|
|
41
|
-
index_by: (
|
|
42
|
-
if (!
|
|
43
|
-
let
|
|
44
|
-
for (let
|
|
45
|
-
let
|
|
46
|
-
|
|
42
|
+
index_by: (e, r) => {
|
|
43
|
+
if (!t(e) || r.length === 0) return e;
|
|
44
|
+
let i = n(r[0]), a = {};
|
|
45
|
+
for (let t of e) if (typeof t == "object" && t) {
|
|
46
|
+
let e = String(t[i] ?? "");
|
|
47
|
+
a[e] = t;
|
|
47
48
|
}
|
|
48
|
-
return
|
|
49
|
+
return a;
|
|
49
50
|
},
|
|
50
|
-
group_by: (
|
|
51
|
-
if (!
|
|
52
|
-
let
|
|
53
|
-
for (let
|
|
54
|
-
let
|
|
55
|
-
|
|
51
|
+
group_by: (e, r) => {
|
|
52
|
+
if (!t(e) || r.length === 0) return e;
|
|
53
|
+
let i = n(r[0]), a = {};
|
|
54
|
+
for (let t of e) if (typeof t == "object" && t) {
|
|
55
|
+
let e = String(t[i] ?? "");
|
|
56
|
+
a[e] = a[e] ?? [], a[e].push(t);
|
|
56
57
|
}
|
|
57
|
-
return
|
|
58
|
+
return a;
|
|
58
59
|
}
|
|
59
60
|
};
|
|
60
|
-
export {
|
|
61
|
+
export { r as objectFilters, i as queryFilters };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { wrapRaw as e } from "./raw.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { isList as t } from "./types.mjs";
|
|
3
|
+
import { isEmpty as n, toJson as r, toStr as i } from "./values.mjs";
|
|
3
4
|
// src/helpers/twigWrapper/filters/strings.ts
|
|
4
|
-
var
|
|
5
|
-
to_json: (e) =>
|
|
6
|
-
json_encode: (e) =>
|
|
5
|
+
var a = { raw: (t) => e(t) }, o = {
|
|
6
|
+
to_json: (e) => r(e),
|
|
7
|
+
json_encode: (e) => r(e),
|
|
7
8
|
object_as_json: (e) => typeof e == "object" && e ? JSON.stringify(e) : e
|
|
8
|
-
},
|
|
9
|
+
}, s = { default: (e, t) => n(e) ? t[0] : e }, c = {
|
|
9
10
|
upper: (e) => typeof e == "string" ? e.toUpperCase() : e,
|
|
10
11
|
lower: (e) => typeof e == "string" ? e.toLowerCase() : e,
|
|
11
12
|
trim: (e) => typeof e == "string" ? e.trim() : e,
|
|
@@ -18,21 +19,21 @@ var i = { raw: (t) => e(t) }, a = {
|
|
|
18
19
|
rtrim: (e) => typeof e == "string" ? e.trimEnd() : e,
|
|
19
20
|
pad: (e, t) => {
|
|
20
21
|
if (typeof e != "string") return e;
|
|
21
|
-
let n = Number(t[0]) || 0,
|
|
22
|
-
if (
|
|
22
|
+
let n = Number(t[0]) || 0, r = t.length > 1 ? i(t[1]) : " ";
|
|
23
|
+
if (r === "") return e;
|
|
23
24
|
let a = n - e.length;
|
|
24
25
|
if (a <= 0) return e;
|
|
25
|
-
let o = Math.ceil(a /
|
|
26
|
-
return
|
|
26
|
+
let o = Math.ceil(a / r.length);
|
|
27
|
+
return r.repeat(o).slice(0, a) + e;
|
|
27
28
|
},
|
|
28
29
|
padRight: (e, t) => {
|
|
29
30
|
if (typeof e != "string") return e;
|
|
30
|
-
let n = Number(t[0]) || 0,
|
|
31
|
-
if (
|
|
31
|
+
let n = Number(t[0]) || 0, r = t.length > 1 ? i(t[1]) : " ";
|
|
32
|
+
if (r === "") return e;
|
|
32
33
|
let a = n - e.length;
|
|
33
34
|
if (a <= 0) return e;
|
|
34
|
-
let o = Math.ceil(a /
|
|
35
|
-
return e +
|
|
35
|
+
let o = Math.ceil(a / r.length);
|
|
36
|
+
return e + r.repeat(o).slice(0, a);
|
|
36
37
|
},
|
|
37
38
|
number: (e, t) => {
|
|
38
39
|
if (typeof e == "number") {
|
|
@@ -43,36 +44,36 @@ var i = { raw: (t) => e(t) }, a = {
|
|
|
43
44
|
let n = e.match(/-?\d+(?:\.\d+)?/);
|
|
44
45
|
return n ? Number(n[0]) : 0;
|
|
45
46
|
}
|
|
46
|
-
},
|
|
47
|
-
replace: (e,
|
|
48
|
-
if (typeof e != "string" ||
|
|
49
|
-
let [
|
|
50
|
-
if (typeof
|
|
51
|
-
let t = new Map(Object.entries(
|
|
47
|
+
}, l = {
|
|
48
|
+
replace: (e, n) => {
|
|
49
|
+
if (typeof e != "string" || n.length === 0) return e;
|
|
50
|
+
let [r] = n;
|
|
51
|
+
if (typeof r == "object" && r && !t(r)) {
|
|
52
|
+
let t = new Map(Object.entries(r).filter(([e]) => e !== ""));
|
|
52
53
|
if (t.size === 0) return e;
|
|
53
|
-
let
|
|
54
|
-
return e.replace(a, (e) =>
|
|
54
|
+
let n = [...t.keys()].sort((e, t) => t.length - e.length), a = new RegExp(n.map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), "g");
|
|
55
|
+
return e.replace(a, (e) => i(t.get(e)));
|
|
55
56
|
}
|
|
56
|
-
return e.split(r
|
|
57
|
+
return e.split(i(r)).join(i(n[1]));
|
|
57
58
|
},
|
|
58
|
-
slice: (e,
|
|
59
|
-
if (
|
|
60
|
-
let
|
|
61
|
-
return typeof e == "string" ||
|
|
59
|
+
slice: (e, n) => {
|
|
60
|
+
if (n.length === 0) return e;
|
|
61
|
+
let r = Number(n[0]) || 0, i = n.length > 1 && Number.isFinite(Number(n[1])) ? r + Number(n[1]) : void 0;
|
|
62
|
+
return typeof e == "string" || t(e) ? e.slice(r, i) : e;
|
|
62
63
|
},
|
|
63
|
-
split: (e, t) => typeof e == "string" && t.length > 0 ? e.split(
|
|
64
|
-
join: (e,
|
|
65
|
-
reverse: (e) => typeof e == "string" ? e.split("").reverse().join("") :
|
|
66
|
-
},
|
|
67
|
-
length: (e) => typeof e == "string" ||
|
|
68
|
-
first: (e) => typeof e == "string" ? e.length > 0 ? e[0] : "" :
|
|
69
|
-
last: (e) => typeof e == "string" ? e.length > 0 ? e[e.length - 1] : "" :
|
|
70
|
-
contains: (e,
|
|
71
|
-
if (
|
|
72
|
-
let
|
|
73
|
-
return typeof e == "string" ? e.includes(r
|
|
64
|
+
split: (e, t) => typeof e == "string" && t.length > 0 ? e.split(i(t[0])) : e,
|
|
65
|
+
join: (e, n) => t(e) ? e.join(n.length === 0 ? "" : i(n[0])) : e,
|
|
66
|
+
reverse: (e) => typeof e == "string" ? e.split("").reverse().join("") : t(e) ? [...e].reverse() : e
|
|
67
|
+
}, u = {
|
|
68
|
+
length: (e) => typeof e == "string" || t(e) ? e.length : typeof e == "number" ? i(e).length : typeof e == "object" && e ? Object.keys(e).length : 0,
|
|
69
|
+
first: (e) => typeof e == "string" ? e.length > 0 ? e[0] : "" : t(e) ? e.length > 0 ? e[0] : void 0 : e,
|
|
70
|
+
last: (e) => typeof e == "string" ? e.length > 0 ? e[e.length - 1] : "" : t(e) ? e.length > 0 ? e[e.length - 1] : void 0 : e,
|
|
71
|
+
contains: (e, n) => {
|
|
72
|
+
if (n.length === 0) return !1;
|
|
73
|
+
let r = n[0];
|
|
74
|
+
return typeof e == "string" ? e.includes(i(r)) : t(e) ? e.includes(r) : !1;
|
|
74
75
|
},
|
|
75
|
-
startswith: (e, t) => typeof e == "string" && t.length > 0 && e.startsWith(
|
|
76
|
-
endswith: (e, t) => typeof e == "string" && t.length > 0 && e.endsWith(
|
|
76
|
+
startswith: (e, t) => typeof e == "string" && t.length > 0 && e.startsWith(i(t[0])),
|
|
77
|
+
endswith: (e, t) => typeof e == "string" && t.length > 0 && e.endsWith(i(t[0]))
|
|
77
78
|
};
|
|
78
|
-
export {
|
|
79
|
+
export { s as defaultFilters, a as identityFilters, o as serialisationFilters, l as stringOperationFilters, u as stringQueryFilters, c as stringTransformFilters };
|
|
@@ -3,3 +3,7 @@ export declare const ARROW_PARAMS: unique symbol;
|
|
|
3
3
|
export type ArrowCallback = ((...args: unknown[]) => unknown) & {
|
|
4
4
|
[ARROW_PARAMS]?: number;
|
|
5
5
|
};
|
|
6
|
+
/** A piped value that is a list, typed as one whose items are not known yet: `Array.isArray` alone says `any[]`. */
|
|
7
|
+
export declare const isList: (value: unknown) => value is unknown[];
|
|
8
|
+
/** An argument that is an arrow the Evaluator made: what a filter calls with the items. */
|
|
9
|
+
export declare const isCallback: (value: unknown) => value is ArrowCallback;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// src/helpers/twigWrapper/filters/types.ts
|
|
2
|
-
var e = Symbol("twigArrowParams");
|
|
3
|
-
export { e as ARROW_PARAMS };
|
|
2
|
+
var e = Symbol("twigArrowParams"), t = (e) => Array.isArray(e), n = (e) => typeof e == "function";
|
|
3
|
+
export { e as ARROW_PARAMS, n as isCallback, t as isList };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { matchPath } from './matchPath';
|
|
2
|
-
export { SITEMAP_EXCLUSION_WORDS, sitemapExclusion, sitemapPaths } from './sitemap';
|
|
2
|
+
export { SITEMAP_EXCLUSION_WORDS, sitemapExclusion, sitemapPages, sitemapPaths } from './sitemap';
|
|
3
3
|
export { getPageFullPath, getPaths, isAbsoluteUrl, isPageAuthored, matchRoutePath, notFoundPageFor, getRouteParams, getSlugParams, navigationTarget, NOT_FOUND_SLUG } from './routes';
|
|
4
4
|
export type { PathMatch, PathPattern } from './matchPath';
|
|
5
5
|
export type { NavigationAccessLevel, NavigationAction, Path } from './routes';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { matchPath as e } from "./matchPath.mjs";
|
|
2
|
-
import { SITEMAP_EXCLUSION_WORDS as t, sitemapExclusion as n,
|
|
3
|
-
import { NOT_FOUND_SLUG as
|
|
4
|
-
export {
|
|
2
|
+
import { SITEMAP_EXCLUSION_WORDS as t, sitemapExclusion as n, sitemapPages as r, sitemapPaths as i } from "./sitemap.mjs";
|
|
3
|
+
import { NOT_FOUND_SLUG as a, getPageFullPath as o, getPaths as s, getRouteParams as c, getSlugParams as l, isAbsoluteUrl as u, isPageAuthored as d, matchRoutePath as f, navigationTarget as p, notFoundPageFor as m } from "./routes.mjs";
|
|
4
|
+
export { a as NOT_FOUND_SLUG, t as SITEMAP_EXCLUSION_WORDS, o as getPageFullPath, s as getPaths, c as getRouteParams, l as getSlugParams, u as isAbsoluteUrl, d as isPageAuthored, e as matchPath, f as matchRoutePath, p as navigationTarget, m as notFoundPageFor, n as sitemapExclusion, r as sitemapPages, i as sitemapPaths };
|
|
@@ -47,6 +47,8 @@ declare const matchRoutePath: (paths: Path[], pathName: string, authenticated: b
|
|
|
47
47
|
};
|
|
48
48
|
pathMatch?: PathMatch;
|
|
49
49
|
pageId?: string;
|
|
50
|
+
/** The page that sends this visitor elsewhere, for a `redirect`: what its address was, before it redirected. */
|
|
51
|
+
redirectedFrom?: string;
|
|
50
52
|
};
|
|
51
53
|
/** The space's "not found" page for an address — its deepest folder's, or the space's — when it declares one. */
|
|
52
54
|
declare const notFoundPageFor: (paths: Path[], pathName: string) => string | undefined;
|
|
@@ -14,3 +14,11 @@ export declare const sitemapExclusion: (page: Element) => SitemapExclusion | und
|
|
|
14
14
|
* {@link sitemapExclusion}, at the path a link to each resolves to (its folders' slugs before its own).
|
|
15
15
|
*/
|
|
16
16
|
export declare const sitemapPaths: (schema: Pick<Schema, "flat" | "pages" | "pageFolders">) => string[];
|
|
17
|
+
/**
|
|
18
|
+
* The pages {@link sitemapPaths} lists, each with its id — what a reader that says more of a page than its address
|
|
19
|
+
* (`/llms.txt`: its title and description) reads. The first page at a path holds it, in the order the paths sort.
|
|
20
|
+
*/
|
|
21
|
+
export declare const sitemapPages: (schema: Pick<Schema, "flat" | "pages" | "pageFolders">) => {
|
|
22
|
+
pageId: string;
|
|
23
|
+
path: string;
|
|
24
|
+
}[];
|
|
@@ -17,8 +17,11 @@ var r = {
|
|
|
17
17
|
}, o = (e) => Object.fromEntries(e.pages.flatMap((t) => {
|
|
18
18
|
let n = e.flat[t];
|
|
19
19
|
return n ? [[t, n]] : [];
|
|
20
|
-
})), s = (t) => {
|
|
21
|
-
let n = o(t), r = t.pageFolders, i =
|
|
22
|
-
return
|
|
20
|
+
})), s = (e) => [...new Set(c(e).map((e) => e.path))], c = (t) => {
|
|
21
|
+
let n = o(t), r = t.pageFolders, i = /* @__PURE__ */ new Set();
|
|
22
|
+
return Object.entries(n).filter(([, e]) => !a(e)).map(([t]) => ({
|
|
23
|
+
pageId: t,
|
|
24
|
+
path: e(n, r, t, !0)
|
|
25
|
+
})).sort((e, t) => e.path.localeCompare(t.path)).filter((e) => !i.has(e.path) && (i.add(e.path), !0));
|
|
23
26
|
};
|
|
24
|
-
export { r as SITEMAP_EXCLUSION_WORDS, a as sitemapExclusion, s as sitemapPaths };
|
|
27
|
+
export { r as SITEMAP_EXCLUSION_WORDS, a as sitemapExclusion, c as sitemapPages, s as sitemapPaths };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What sdk-shared offers code that renders with React: a context that is one across every copy of the SDK a page loads
|
|
3
3
|
* (`sharedContext`), the facade a plugin's element is drawn through, and whether a space is drawn inside another. Apart
|
|
4
|
-
* from `/helpers`, which a server loads: nothing there reaches React (
|
|
4
|
+
* from `/helpers`, which a server loads: nothing there reaches React (docs/en/server-packages.md, D13).
|
|
5
5
|
*/
|
|
6
6
|
export * from './sharedContext';
|
|
7
7
|
export * from './generateFacade';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a command of the CLI or a tool of the MCP did not do what it was asked — one list for both, each code with what
|
|
3
|
+
* it means and what to do next. A refusal is raised with a code of this list (`fail` in the CLI, `fail` in the MCP's
|
|
4
|
+
* operations), so a new one cannot leave out its next step: the code carries it. `plitzi explain <code>` answers each,
|
|
5
|
+
* and `docs/en/refusals.md` is written from this table.
|
|
6
|
+
*
|
|
7
|
+
* A run's own refusals (a task claimed, a run stopping…) are the harness's, with exit codes of their own
|
|
8
|
+
* (`REFUSAL_EXIT_CODES` in the CLI); what a space's document is refused for is authoring's (`AUTHORING_CODES`).
|
|
9
|
+
*/
|
|
10
|
+
/** The surfaces a code is raised by: the CLI's commands, the MCP's tools. */
|
|
11
|
+
export type RefusalSurface = 'cli' | 'mcp';
|
|
12
|
+
export type RefusalEntry = {
|
|
13
|
+
/** What was wrong, in a line. */
|
|
14
|
+
means: string;
|
|
15
|
+
/** What to do next — a step, never a description. Printed with the refusal when its message names no other. */
|
|
16
|
+
next: string;
|
|
17
|
+
surfaces: readonly RefusalSurface[];
|
|
18
|
+
};
|
|
19
|
+
export declare const REFUSALS: {
|
|
20
|
+
'wrong-options': {
|
|
21
|
+
means: string;
|
|
22
|
+
next: string;
|
|
23
|
+
surfaces: ("mcp" | "cli")[];
|
|
24
|
+
};
|
|
25
|
+
'bad-value': {
|
|
26
|
+
means: string;
|
|
27
|
+
next: string;
|
|
28
|
+
surfaces: ("mcp" | "cli")[];
|
|
29
|
+
};
|
|
30
|
+
'not-a-project': {
|
|
31
|
+
means: string;
|
|
32
|
+
next: string;
|
|
33
|
+
surfaces: "cli"[];
|
|
34
|
+
};
|
|
35
|
+
'old-layout': {
|
|
36
|
+
means: string;
|
|
37
|
+
next: string;
|
|
38
|
+
surfaces: "cli"[];
|
|
39
|
+
};
|
|
40
|
+
missing: {
|
|
41
|
+
means: string;
|
|
42
|
+
next: string;
|
|
43
|
+
surfaces: ("mcp" | "cli")[];
|
|
44
|
+
};
|
|
45
|
+
exists: {
|
|
46
|
+
means: string;
|
|
47
|
+
next: string;
|
|
48
|
+
surfaces: ("mcp" | "cli")[];
|
|
49
|
+
};
|
|
50
|
+
unreadable: {
|
|
51
|
+
means: string;
|
|
52
|
+
next: string;
|
|
53
|
+
surfaces: "cli"[];
|
|
54
|
+
};
|
|
55
|
+
'does-not-build': {
|
|
56
|
+
means: string;
|
|
57
|
+
next: string;
|
|
58
|
+
surfaces: "cli"[];
|
|
59
|
+
};
|
|
60
|
+
'signed-out': {
|
|
61
|
+
means: string;
|
|
62
|
+
next: string;
|
|
63
|
+
surfaces: "cli"[];
|
|
64
|
+
};
|
|
65
|
+
'not-allowed': {
|
|
66
|
+
means: string;
|
|
67
|
+
next: string;
|
|
68
|
+
surfaces: ("mcp" | "cli")[];
|
|
69
|
+
};
|
|
70
|
+
'refused-by-platform': {
|
|
71
|
+
means: string;
|
|
72
|
+
next: string;
|
|
73
|
+
surfaces: "cli"[];
|
|
74
|
+
};
|
|
75
|
+
'changed-since': {
|
|
76
|
+
means: string;
|
|
77
|
+
next: string;
|
|
78
|
+
surfaces: ("mcp" | "cli")[];
|
|
79
|
+
};
|
|
80
|
+
unanswered: {
|
|
81
|
+
means: string;
|
|
82
|
+
next: string;
|
|
83
|
+
surfaces: ("mcp" | "cli")[];
|
|
84
|
+
};
|
|
85
|
+
'nobody-to-ask': {
|
|
86
|
+
means: string;
|
|
87
|
+
next: string;
|
|
88
|
+
surfaces: "cli"[];
|
|
89
|
+
};
|
|
90
|
+
'in-use': {
|
|
91
|
+
means: string;
|
|
92
|
+
next: string;
|
|
93
|
+
surfaces: ("mcp" | "cli")[];
|
|
94
|
+
};
|
|
95
|
+
outdated: {
|
|
96
|
+
means: string;
|
|
97
|
+
next: string;
|
|
98
|
+
surfaces: "cli"[];
|
|
99
|
+
};
|
|
100
|
+
repeated: {
|
|
101
|
+
means: string;
|
|
102
|
+
next: string;
|
|
103
|
+
surfaces: "mcp"[];
|
|
104
|
+
};
|
|
105
|
+
failed: {
|
|
106
|
+
means: string;
|
|
107
|
+
next: string;
|
|
108
|
+
surfaces: "cli"[];
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export type RefusalCode = keyof typeof REFUSALS;
|
|
112
|
+
export declare const isRefusalCode: (name: string) => name is RefusalCode;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// src/refusals/index.ts
|
|
2
|
+
var e = {
|
|
3
|
+
"wrong-options": {
|
|
4
|
+
means: "options given together that do not go together, or one given without the one it needs",
|
|
5
|
+
next: "change the options as the message says; the command’s --help lists what each takes",
|
|
6
|
+
surfaces: ["cli", "mcp"]
|
|
7
|
+
},
|
|
8
|
+
"bad-value": {
|
|
9
|
+
means: "a value an option, an argument or a field does not take: not an address, not one of a list, not JSON",
|
|
10
|
+
next: "write one of the values the message names, in the shape it shows",
|
|
11
|
+
surfaces: ["cli", "mcp"]
|
|
12
|
+
},
|
|
13
|
+
"not-a-project": {
|
|
14
|
+
means: "the command works on a project, and the folder it ran in is not one of the kind it needs",
|
|
15
|
+
next: "run it in the project’s folder: plitzi create makes one, and plitzi doctor says what a project lacks",
|
|
16
|
+
surfaces: ["cli"]
|
|
17
|
+
},
|
|
18
|
+
"old-layout": {
|
|
19
|
+
means: "the project is laid out as an older CLI left it, and this command would write it for another layout",
|
|
20
|
+
next: "run plitzi doctor --fix, which moves it with every import, then the command again",
|
|
21
|
+
surfaces: ["cli"]
|
|
22
|
+
},
|
|
23
|
+
missing: {
|
|
24
|
+
means: "what the call names is not there: a file, an element, a page, a task, a bucket",
|
|
25
|
+
next: "name one that is: the message lists them, or says where they are listed",
|
|
26
|
+
surfaces: ["cli", "mcp"]
|
|
27
|
+
},
|
|
28
|
+
exists: {
|
|
29
|
+
means: "the place it would write already holds something it would replace",
|
|
30
|
+
next: "choose another name or place; --force replaces it, where the command takes it and the person agrees",
|
|
31
|
+
surfaces: ["cli", "mcp"]
|
|
32
|
+
},
|
|
33
|
+
unreadable: {
|
|
34
|
+
means: "a file or an answer that could not be read as what the command takes",
|
|
35
|
+
next: "check the path, and that the file is what the message says it should be",
|
|
36
|
+
surfaces: ["cli"]
|
|
37
|
+
},
|
|
38
|
+
"does-not-build": {
|
|
39
|
+
means: "what was to be built, packed or installed did not build: its own words are in the message",
|
|
40
|
+
next: "fix what the build says, then run the command again",
|
|
41
|
+
surfaces: ["cli"]
|
|
42
|
+
},
|
|
43
|
+
"signed-out": {
|
|
44
|
+
means: "no session for the platform, or one it no longer takes",
|
|
45
|
+
next: "sign in with plitzi login, then run the command again",
|
|
46
|
+
surfaces: ["cli"]
|
|
47
|
+
},
|
|
48
|
+
"not-allowed": {
|
|
49
|
+
means: "what was asked is not this account’s, this plan’s or this surface’s to do",
|
|
50
|
+
next: "do it where the message says it is done, or ask a person whose role or plan allows it",
|
|
51
|
+
surfaces: ["cli", "mcp"]
|
|
52
|
+
},
|
|
53
|
+
"refused-by-platform": {
|
|
54
|
+
means: "the platform refused what was sent, in its own words",
|
|
55
|
+
next: "do what the platform’s words say; when they name no fix, plitzi doctor checks the connection and the project",
|
|
56
|
+
surfaces: ["cli"]
|
|
57
|
+
},
|
|
58
|
+
"changed-since": {
|
|
59
|
+
means: "what is there changed since this copy last had it, and sending would replace that change",
|
|
60
|
+
next: "pull first (plitzi space pull) — over the MCP, read it again — apply your change on what it brings, and send it again",
|
|
61
|
+
surfaces: ["cli", "mcp"]
|
|
62
|
+
},
|
|
63
|
+
unanswered: {
|
|
64
|
+
means: "nothing answered: a server not running, an address nothing serves, a browser that did not start",
|
|
65
|
+
next: "start what the message names (npm start, plitzi server) or install it (plitzi browser install); plitzi doctor checks the machine",
|
|
66
|
+
surfaces: ["cli", "mcp"]
|
|
67
|
+
},
|
|
68
|
+
"nobody-to-ask": {
|
|
69
|
+
means: "a choice that belongs to a person, and nobody is at the terminal to make it",
|
|
70
|
+
next: "ask the person each question the message lists, then run the command again with their answers",
|
|
71
|
+
surfaces: ["cli"]
|
|
72
|
+
},
|
|
73
|
+
"in-use": {
|
|
74
|
+
means: "what would be removed or changed is still used, or still running",
|
|
75
|
+
next: "stop or repoint what uses it first: the message names each",
|
|
76
|
+
surfaces: ["cli", "mcp"]
|
|
77
|
+
},
|
|
78
|
+
outdated: {
|
|
79
|
+
means: "this client is older than the oldest the platform takes",
|
|
80
|
+
next: "in a project, plitzi upgrade packages (the CLI is one of them); elsewhere, npx @plitzi/cli@latest — then run the command again",
|
|
81
|
+
surfaces: ["cli"]
|
|
82
|
+
},
|
|
83
|
+
repeated: {
|
|
84
|
+
means: "the same call was refused twice before and was not run again: the answer would not change",
|
|
85
|
+
next: "change what the errors named — plitzi_describe_operation gives an operation’s fields — or ask the person what they meant",
|
|
86
|
+
surfaces: ["mcp"]
|
|
87
|
+
},
|
|
88
|
+
failed: {
|
|
89
|
+
means: "what the command ran failed on its own: a task, a step, an install",
|
|
90
|
+
next: "read the failure the message carries, fix it in the project, and run the command again",
|
|
91
|
+
surfaces: ["cli"]
|
|
92
|
+
}
|
|
93
|
+
}, t = (t) => Object.hasOwn(e, t);
|
|
94
|
+
export { e as REFUSALS, t as isRefusalCode };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The AI crawlers a space's `/robots.txt` may keep out, by what they do — so whoever owns the space decides each on its
|
|
3
|
+
* own (`settings.blockAiCrawlers`). One switch for all of them kept assistants out of a product whose way in is an
|
|
4
|
+
* agent; now a site may refuse to train a model and still be read for a person who asked.
|
|
5
|
+
*
|
|
6
|
+
* - `training` — gathering pages to train models.
|
|
7
|
+
* - `assistants` — an assistant fetching a page because a person asked it to, now.
|
|
8
|
+
* - `search` — building the index an AI search answers from.
|
|
9
|
+
*
|
|
10
|
+
* Each by the user agent it reads `/robots.txt` as. A search engine's own crawler is none of them: Googlebot reads on,
|
|
11
|
+
* Google-Extended (the one that trains) does not.
|
|
12
|
+
*/
|
|
13
|
+
export declare const AI_CRAWLERS: {
|
|
14
|
+
readonly training: readonly ["GPTBot", "ClaudeBot", "anthropic-ai", "Google-Extended", "Applebot-Extended", "CCBot", "Bytespider", "Amazonbot", "meta-externalagent"];
|
|
15
|
+
readonly assistants: readonly ["ChatGPT-User", "Claude-User", "Perplexity-User", "MistralAI-User"];
|
|
16
|
+
readonly search: readonly ["OAI-SearchBot", "Claude-SearchBot", "PerplexityBot"];
|
|
17
|
+
};
|
|
18
|
+
/** The kinds, in the order a setting lists them: a tuple, so a schema validator can take it as its values. */
|
|
19
|
+
export declare const AI_CRAWLER_KINDS: readonly ["training", "assistants", "search"];
|
|
20
|
+
export type AiCrawlerKind = (typeof AI_CRAWLER_KINDS)[number];
|
|
21
|
+
/** What each kind is, in the words a setting shows its owner. */
|
|
22
|
+
export declare const AI_CRAWLER_KIND_LABEL: Record<AiCrawlerKind, string>;
|
|
23
|
+
export declare const isAiCrawlerKind: (value: unknown) => value is AiCrawlerKind;
|
|
24
|
+
/** The user agents a space keeps out, for the kinds it names — none when it names none, or names them wrong. */
|
|
25
|
+
export declare const blockedAiCrawlers: (kinds: unknown) => string[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/schema/aiCrawlers.ts
|
|
2
|
+
var e = {
|
|
3
|
+
training: [
|
|
4
|
+
"GPTBot",
|
|
5
|
+
"ClaudeBot",
|
|
6
|
+
"anthropic-ai",
|
|
7
|
+
"Google-Extended",
|
|
8
|
+
"Applebot-Extended",
|
|
9
|
+
"CCBot",
|
|
10
|
+
"Bytespider",
|
|
11
|
+
"Amazonbot",
|
|
12
|
+
"meta-externalagent"
|
|
13
|
+
],
|
|
14
|
+
assistants: [
|
|
15
|
+
"ChatGPT-User",
|
|
16
|
+
"Claude-User",
|
|
17
|
+
"Perplexity-User",
|
|
18
|
+
"MistralAI-User"
|
|
19
|
+
],
|
|
20
|
+
search: [
|
|
21
|
+
"OAI-SearchBot",
|
|
22
|
+
"Claude-SearchBot",
|
|
23
|
+
"PerplexityBot"
|
|
24
|
+
]
|
|
25
|
+
}, t = [
|
|
26
|
+
"training",
|
|
27
|
+
"assistants",
|
|
28
|
+
"search"
|
|
29
|
+
], n = {
|
|
30
|
+
training: "Crawlers that train AI models",
|
|
31
|
+
assistants: "Assistants fetching a page for a person",
|
|
32
|
+
search: "AI search indexes"
|
|
33
|
+
}, r = (t) => typeof t == "string" && t in e, i = (t) => Array.isArray(t) ? t.filter(r).flatMap((t) => [...e[t]]) : [];
|
|
34
|
+
export { e as AI_CRAWLERS, t as AI_CRAWLER_KINDS, n as AI_CRAWLER_KIND_LABEL, i as blockedAiCrawlers, r as isAiCrawlerKind };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Element, Schema } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* The space sent in parts: a shell — everything but the pages' and layouts' own elements — and a part
|
|
4
|
+
* per page and per layout, fetched as a page that needs it is opened. A visitor of one page downloads that page and its
|
|
5
|
+
* layouts, not the whole site.
|
|
6
|
+
*
|
|
7
|
+
* The shell keeps every root — each page and layout element itself, with its attributes and its `items` — so the space
|
|
8
|
+
* routes, lists its pages and resolves a page's layouts as the whole did; `schema.parts` names, for each root whose
|
|
9
|
+
* elements are elsewhere, the part that holds them. Only a page server sends it this way: the SDK alone, the builder
|
|
10
|
+
* and the MCP read the whole document, which has no `parts`.
|
|
11
|
+
*/
|
|
12
|
+
/** The elements of one root (a page or a layout) that the shell leaves out. */
|
|
13
|
+
export type DocumentPart = {
|
|
14
|
+
root: string;
|
|
15
|
+
flat: Record<string, Element>;
|
|
16
|
+
};
|
|
17
|
+
/** A schema split: its shell, and its parts by the name the shell gives them. */
|
|
18
|
+
export type SplitSchema = {
|
|
19
|
+
shell: Schema;
|
|
20
|
+
parts: ReadonlyMap<string, DocumentPart>;
|
|
21
|
+
};
|
|
22
|
+
/** A page's layouts, innermost first: what must be drawn around it. */
|
|
23
|
+
export declare const pageLayouts: (flat: Schema["flat"], pageId: string) => string[];
|
|
24
|
+
/**
|
|
25
|
+
* The schema as a shell and parts. A page `withheld` from this visitor (`withholdPages`) has no part; nor has a layout no
|
|
26
|
+
* page of theirs is drawn in — a console's shell, to a visitor of the website — which the shell names with `''`: only the
|
|
27
|
+
* server draws it, so a link to such a page loads it from there. `nameOf` names a part by its content.
|
|
28
|
+
*/
|
|
29
|
+
export declare const splitSchema: (schema: Schema, nameOf: (part: DocumentPart) => string, withheld?: readonly string[]) => SplitSchema;
|
|
30
|
+
/**
|
|
31
|
+
* The roots a page needs and the shell does not hold: the page's own part and its layouts', by root; the parts of the
|
|
32
|
+
* pages at its address; and, for a page withheld from this visitor, the page the space draws in its place
|
|
33
|
+
* (`settings.withheldPage`). A page at its address that is withheld from this visitor — a part named `''`, its layouts
|
|
34
|
+
* too — is not among them: the router changes to it only once the visitor changes, and a page kept from the visitor the
|
|
35
|
+
* document was sent for is loaded from the server then. Counted, a guest's every link to the home loaded the whole page
|
|
36
|
+
* from the server, for the signed-in home beside it.
|
|
37
|
+
*/
|
|
38
|
+
export declare const missingParts: (schema: Pick<Schema, "flat" | "parts" | "pages"> & Partial<Pick<Schema, "settings">>, pageId: string) => string[];
|
|
39
|
+
/**
|
|
40
|
+
* The schema with parts put in: their elements in `flat`, their roots off `parts` — a new object, so whatever is kept
|
|
41
|
+
* by the old one (a page's element types) is worked out again. `parts` goes once nothing is left out.
|
|
42
|
+
*/
|
|
43
|
+
export declare const withParts: (schema: Schema, added: readonly DocumentPart[]) => Schema;
|
|
44
|
+
/** The shell with a page's own part and its layouts' in it: the document a page server sends with that page. */
|
|
45
|
+
export declare const schemaForPage: (split: SplitSchema, pageId: string) => Schema;
|