@plitzi/sdk-shared 0.38.23 → 0.39.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/CHANGELOG.md +162 -1
- package/dist/actions/functions.d.ts +22 -1
- package/dist/actions/functions.mjs +3 -3
- package/dist/actions/index.d.ts +1 -1
- package/dist/actions/index.mjs +7 -7
- package/dist/auth/failureChannel.mjs +1 -0
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.mjs +2 -2
- package/dist/auth/visitorRoles.d.ts +8 -0
- package/dist/auth/visitorRoles.mjs +5 -2
- package/dist/authoring/declare.d.ts +34 -1
- package/dist/authoring/elementCallbacks.d.ts +13 -0
- package/dist/authoring/elementCallbacks.mjs +11 -5
- package/dist/authoring/index.mjs +3 -3
- package/dist/authoring/paramSpec.d.ts +1 -0
- package/dist/dataSource/getBindingsDetails.d.ts +1 -1
- package/dist/dataSource/getBindingsDetails.mjs +1 -1
- package/dist/dataSource/globalSources.d.ts +1 -1
- package/dist/dataSource/index.d.ts +1 -2
- package/dist/dataSource/index.mjs +1 -1
- package/dist/dataSource/utility/arrayMap.mjs +1 -1
- package/dist/dataSource/utility/capitalize.mjs +1 -1
- package/dist/dataSource/utility/styleSelector.mjs +5 -3
- package/dist/dataSource/utility/styleVariant.mjs +17 -13
- package/dist/dataSource/variables/index.d.ts +2 -0
- package/dist/dataSource/variables/index.mjs +1 -0
- package/dist/dataSource/{resolveVariables.d.ts → variables/resolveVariables.d.ts} +1 -1
- package/dist/dataSource/{resolveVariables.mjs → variables/resolveVariables.mjs} +1 -1
- package/dist/devTools/chrome.d.ts +6 -0
- package/dist/devTools/chrome.mjs +2 -2
- package/dist/devTools/index.mjs +5 -5
- package/dist/devTools/sight/index.d.ts +1 -0
- package/dist/devTools/sight/index.mjs +1 -0
- package/dist/devTools/sight/sight.d.ts +28 -0
- package/dist/devTools/sight/sight.mjs +127 -0
- package/dist/devTools/utils/PlitziConsole.d.ts +14 -0
- package/dist/devTools/utils/PlitziConsole.mjs +20 -3
- package/dist/flags/flagsCookie.mjs +4 -4
- package/dist/flags/resolveFlags.d.ts +1 -1
- package/dist/helpers/index.mjs +19 -19
- package/dist/helpers/ruleEvaluator.d.ts +2 -0
- package/dist/helpers/ruleEvaluator.mjs +2 -2
- package/dist/helpers/scroll.d.ts +10 -0
- package/dist/helpers/scroll.mjs +2 -2
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +90 -88
- package/dist/helpers/twigWrapper/Evaluator/helpers.d.ts +6 -0
- package/dist/helpers/twigWrapper/Evaluator/helpers.mjs +11 -2
- package/dist/helpers/twigWrapper/filters/arrays.d.ts +2 -0
- package/dist/helpers/twigWrapper/filters/arrays.mjs +66 -0
- package/dist/helpers/twigWrapper/filters/catalog/index.d.ts +17 -0
- package/dist/helpers/twigWrapper/filters/catalog/index.mjs +351 -0
- package/dist/helpers/twigWrapper/filters/dateParts.d.ts +25 -0
- package/dist/helpers/twigWrapper/filters/dateParts.mjs +56 -0
- package/dist/helpers/twigWrapper/filters/dates.d.ts +2 -0
- package/dist/helpers/twigWrapper/filters/dates.mjs +97 -0
- package/dist/helpers/twigWrapper/filters/filters.d.ts +3 -13
- package/dist/helpers/twigWrapper/filters/filters.mjs +25 -483
- package/dist/helpers/twigWrapper/filters/hashing.d.ts +3 -0
- package/dist/helpers/twigWrapper/filters/hashing.mjs +101 -0
- package/dist/helpers/twigWrapper/filters/index.mjs +4 -1
- package/dist/helpers/twigWrapper/filters/misc.d.ts +5 -0
- package/dist/helpers/twigWrapper/filters/misc.mjs +52 -0
- package/dist/helpers/twigWrapper/filters/numbers.d.ts +2 -0
- package/dist/helpers/twigWrapper/filters/numbers.mjs +36 -0
- package/dist/helpers/twigWrapper/filters/objects.d.ts +3 -0
- package/dist/helpers/twigWrapper/filters/objects.mjs +61 -0
- package/dist/helpers/twigWrapper/filters/raw.d.ts +8 -0
- package/dist/helpers/twigWrapper/filters/raw.mjs +7 -0
- package/dist/helpers/twigWrapper/filters/strings.d.ts +7 -0
- package/dist/helpers/twigWrapper/filters/strings.mjs +79 -0
- package/dist/helpers/twigWrapper/filters/types.d.ts +5 -0
- package/dist/helpers/twigWrapper/filters/types.mjs +4 -0
- package/dist/helpers/twigWrapper/filters/values.d.ts +12 -0
- package/dist/helpers/twigWrapper/filters/values.mjs +17 -0
- package/dist/helpers/twigWrapper/inspectTemplate.d.ts +5 -0
- package/dist/helpers/twigWrapper/inspectTemplate.mjs +39 -20
- package/dist/helpers/utils.d.ts +4 -0
- package/dist/helpers/utils.mjs +3 -5
- package/dist/navigation/index.d.ts +2 -0
- package/dist/navigation/index.mjs +2 -1
- package/dist/navigation/sitemap.d.ts +16 -0
- package/dist/navigation/sitemap.mjs +25 -0
- package/dist/network/entitlements.d.ts +101 -0
- package/dist/network/entitlements.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceRunE2eTestsMutation.d.ts +31 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceRunE2eTestsMutation.mjs +13 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceSetTestsMutation.d.ts +5 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceSetTestsMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSettingsMutation.d.ts +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSettingsMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/index.d.ts +5 -0
- package/dist/network/graphql/builder/Mutations/index.mjs +150 -146
- package/dist/network/graphql/builder/Queries/Space/SpaceTestsQuery.d.ts +40 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceTestsQuery.mjs +24 -0
- package/dist/network/graphql/builder/Queries/index.d.ts +3 -0
- package/dist/network/graphql/builder/Queries/index.mjs +44 -42
- package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +3 -1
- package/dist/network/graphql/sdk/Queries/InitQuery.mjs +1 -1
- package/dist/network/index.d.ts +1 -0
- package/dist/network/index.mjs +9 -8
- package/dist/network/spaceEvents.d.ts +20 -1
- package/dist/network/spaceEvents.mjs +12 -0
- package/dist/project/index.mjs +8 -5
- package/dist/project/layout/check.d.ts +22 -0
- package/dist/project/layout/check.mjs +60 -0
- package/dist/project/{layout.d.ts → layout/codes.d.ts} +3 -66
- package/dist/project/layout/codes.mjs +108 -0
- package/dist/project/layout/contents.d.ts +10 -0
- package/dist/project/layout/contents.mjs +31 -0
- package/dist/project/layout/files.d.ts +31 -0
- package/dist/project/layout/files.mjs +49 -0
- package/dist/project/layout/folders.d.ts +4 -0
- package/dist/project/layout/folders.mjs +69 -0
- package/dist/project/layout/index.d.ts +16 -0
- package/dist/project/layout/index.mjs +5 -0
- package/dist/project/layout/plugins.d.ts +46 -0
- package/dist/project/layout/plugins.mjs +99 -0
- package/dist/project/layout/vendor.d.ts +15 -0
- package/dist/project/layout/vendor.mjs +34 -0
- package/dist/project/pages/index.d.ts +8 -0
- package/dist/project/pages/index.mjs +14 -0
- package/dist/project/paths/index.d.ts +52 -4
- package/dist/project/paths/index.mjs +2 -2
- package/dist/project/root.d.ts +6 -0
- package/dist/project/root.mjs +11 -10
- package/dist/realtime/client.mjs +104 -91
- package/dist/realtime/presence.d.ts +2 -2
- package/dist/realtime/presence.mjs +27 -21
- package/dist/runs/index.d.ts +73 -0
- package/dist/runs/index.mjs +6 -0
- package/dist/runs/report.d.ts +56 -0
- package/dist/runs/report.mjs +17 -0
- package/dist/schema/index.d.ts +6 -0
- package/dist/schema/index.mjs +18 -12
- package/dist/schema/motion.d.ts +25 -0
- package/dist/schema/motion.mjs +47 -19
- package/dist/schema/pageAccess.d.ts +6 -0
- package/dist/schema/pageAccess.mjs +8 -3
- package/dist/schema/pageHead.d.ts +64 -0
- package/dist/schema/pageHead.mjs +68 -0
- package/dist/schema/providerAnswer.d.ts +17 -0
- package/dist/schema/providerAnswer.mjs +4 -0
- package/dist/schema/providerWhen.d.ts +36 -0
- package/dist/schema/providerWhen.mjs +58 -0
- package/dist/schema/schemaSettings.d.ts +14 -0
- package/dist/schema/schemaSettings.mjs +4 -0
- package/dist/schema/serverElements.d.ts +20 -1
- package/dist/schema/serverElements.mjs +41 -28
- package/dist/schema/serverInput.d.ts +34 -0
- package/dist/schema/serverInput.mjs +60 -0
- package/dist/schema/serverQuery.d.ts +47 -0
- package/dist/schema/serverQuery.mjs +70 -0
- package/dist/server/index.mjs +5 -5
- package/dist/server/rsc/refreshRsc.d.ts +6 -2
- package/dist/server/rsc/refreshRsc.mjs +75 -59
- package/dist/server/rsc/useRscSync.mjs +22 -18
- package/dist/source/export.d.ts +1 -1
- package/dist/state/runtimeStatePersist.mjs +25 -17
- package/dist/store/renderSettings.d.ts +2 -0
- package/dist/store/renderSettings.mjs +13 -5
- package/dist/store/storeHooks.d.ts +45 -45
- package/dist/style/index.mjs +16 -16
- package/dist/style/styleConstants.d.ts +12 -2
- package/dist/style/styleConstants.mjs +20 -0
- package/dist/style/styleStates.d.ts +5 -0
- package/dist/style/styleStates.mjs +21 -5
- package/dist/types/ActionTypes.d.ts +26 -3
- package/dist/types/AuthTypes.d.ts +19 -1
- package/dist/types/CommonTypes.d.ts +3 -2
- package/dist/types/ElementTypes.d.ts +1 -1
- package/dist/types/InteractionTypes.d.ts +10 -1
- package/dist/types/JobTypes.d.ts +2 -1
- package/dist/types/OAuthTypes.d.ts +246 -0
- package/dist/types/OAuthTypes.mjs +0 -0
- package/dist/types/PluginTypes.d.ts +2 -0
- package/dist/types/PreviewTypes.d.ts +71 -0
- package/dist/types/PreviewTypes.mjs +0 -0
- package/dist/types/RealtimeTypes.d.ts +11 -0
- package/dist/types/SchemaTypes.d.ts +56 -0
- package/dist/types/ServerAdapterTypes.d.ts +345 -0
- package/dist/types/ServerAdapterTypes.mjs +0 -0
- package/dist/types/ServerConfigTypes.d.ts +527 -0
- package/dist/types/ServerConfigTypes.mjs +0 -0
- package/dist/types/ServerLogTypes.d.ts +119 -0
- package/dist/types/ServerLogTypes.mjs +0 -0
- package/dist/types/ServerTypes.d.ts +30 -1215
- package/dist/types/StoreTypes.d.ts +39 -1
- package/dist/types/TestTypes.d.ts +249 -0
- package/dist/types/TestTypes.mjs +0 -0
- package/dist/types/index.d.ts +6 -0
- package/eslint.config.mjs +3 -1
- package/package.json +2 -2
- package/setupTests.ts +4 -3
- package/dist/project/layout.mjs +0 -394
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { formatNumber as e, numberOf as t, toStr as n } from "./values.mjs";
|
|
2
|
+
//#region src/helpers/twigWrapper/filters/numbers.ts
|
|
3
|
+
var r = {
|
|
4
|
+
number_format: (e, t) => {
|
|
5
|
+
if (typeof e != "number") return e;
|
|
6
|
+
let r = Number(t[0]) || 0, i = t[1] == null ? "." : n(t[1]), a = t[2] == null ? "" : n(t[2]), o = e.toFixed(r);
|
|
7
|
+
if (a === "") return o.replace(".", i);
|
|
8
|
+
let s = o.split(".");
|
|
9
|
+
return s[0] = s[0].replace(/\B(?=(\d{3})+(?!\d))/g, a), s.join(i);
|
|
10
|
+
},
|
|
11
|
+
currency: (r, i) => {
|
|
12
|
+
let a = t(r);
|
|
13
|
+
if (a === void 0 || i.length === 0) return r;
|
|
14
|
+
let o = i[2], s = typeof o == "object" && !!o && "trimZeros" in o && o.trimZeros === !0 && Number.isInteger(a);
|
|
15
|
+
return e(a, i[1], {
|
|
16
|
+
style: "currency",
|
|
17
|
+
currency: n(i[0]),
|
|
18
|
+
...s ? {
|
|
19
|
+
minimumFractionDigits: 0,
|
|
20
|
+
maximumFractionDigits: 0
|
|
21
|
+
} : {}
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
percent: (n, r) => {
|
|
25
|
+
let i = t(n);
|
|
26
|
+
if (i === void 0) return n;
|
|
27
|
+
let a = Number(r[0]) || 0;
|
|
28
|
+
return e(i, r[1], {
|
|
29
|
+
style: "percent",
|
|
30
|
+
minimumFractionDigits: 0,
|
|
31
|
+
maximumFractionDigits: a
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { r as numberFilters };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { toStr as e } from "./values.mjs";
|
|
2
|
+
//#region src/helpers/twigWrapper/filters/objects.ts
|
|
3
|
+
var t = {
|
|
4
|
+
without: (t, n) => {
|
|
5
|
+
if (typeof t != "object" || !t || Array.isArray(t)) return t;
|
|
6
|
+
let r = n.map(e), i = {};
|
|
7
|
+
for (let [e, n] of Object.entries(t)) r.includes(e) || (i[e] = n);
|
|
8
|
+
return i;
|
|
9
|
+
},
|
|
10
|
+
only: (t, n) => {
|
|
11
|
+
if (typeof t != "object" || !t || Array.isArray(t)) return t;
|
|
12
|
+
let r = n.map(e), i = {};
|
|
13
|
+
for (let [e, n] of Object.entries(t)) r.includes(e) && (i[e] = n);
|
|
14
|
+
return i;
|
|
15
|
+
}
|
|
16
|
+
}, n = {
|
|
17
|
+
find: (t, n) => {
|
|
18
|
+
if (!Array.isArray(t) || n.length === 0) return;
|
|
19
|
+
let r = n[0];
|
|
20
|
+
if (typeof r == "function") return t.find((e, t) => r(e, t));
|
|
21
|
+
if (n.length < 2) return;
|
|
22
|
+
let i = e(r), a = n[1];
|
|
23
|
+
return t.find((e) => typeof e == "object" && e ? e[i] === a : e === a);
|
|
24
|
+
},
|
|
25
|
+
pluck: (t, n) => {
|
|
26
|
+
if (!Array.isArray(t) || n.length === 0) return t;
|
|
27
|
+
let r = e(n[0]);
|
|
28
|
+
return t.map((e) => typeof e == "object" && e ? e[r] : void 0);
|
|
29
|
+
},
|
|
30
|
+
unique: (e) => Array.isArray(e) ? [...new Set(e)] : e,
|
|
31
|
+
flatten: (e) => Array.isArray(e) ? e.flat() : e,
|
|
32
|
+
sum: (e) => Array.isArray(e) ? e.reduce((e, t) => e + (typeof t == "number" ? t : 0), 0) : e,
|
|
33
|
+
chunk: (e, t) => {
|
|
34
|
+
if (!Array.isArray(e) || t.length === 0) return e;
|
|
35
|
+
let n = Number(t[0]);
|
|
36
|
+
if (n <= 0) return e;
|
|
37
|
+
let r = [];
|
|
38
|
+
for (let t = 0; t < e.length; t += n) r.push(e.slice(t, t + n));
|
|
39
|
+
return r;
|
|
40
|
+
},
|
|
41
|
+
index_by: (t, n) => {
|
|
42
|
+
if (!Array.isArray(t) || n.length === 0) return t;
|
|
43
|
+
let r = e(n[0]), i = {};
|
|
44
|
+
for (let e of t) if (typeof e == "object" && e) {
|
|
45
|
+
let t = String(e[r] ?? "");
|
|
46
|
+
i[t] = e;
|
|
47
|
+
}
|
|
48
|
+
return i;
|
|
49
|
+
},
|
|
50
|
+
group_by: (t, n) => {
|
|
51
|
+
if (!Array.isArray(t) || n.length === 0) return t;
|
|
52
|
+
let r = e(n[0]), i = {};
|
|
53
|
+
for (let e of t) if (typeof e == "object" && e) {
|
|
54
|
+
let t = String(e[r] ?? "");
|
|
55
|
+
i[t] = i[t] ?? [], i[t].push(e);
|
|
56
|
+
}
|
|
57
|
+
return i;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
export { t as objectFilters, n as queryFilters };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type RawMarker = {
|
|
2
|
+
readonly __raw: unknown;
|
|
3
|
+
readonly __marker: typeof RAW_MARKER;
|
|
4
|
+
};
|
|
5
|
+
export declare const RAW_MARKER = "__PLITZI_RAW__";
|
|
6
|
+
export declare const isRawMarker: (value: unknown) => value is RawMarker;
|
|
7
|
+
export declare const wrapRaw: (value: unknown) => RawMarker;
|
|
8
|
+
export declare const unwrapRaw: (value: unknown) => unknown;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/helpers/twigWrapper/filters/raw.ts
|
|
2
|
+
var e = "__PLITZI_RAW__", t = (e) => typeof e == "object" && !!e && e.__marker === "__PLITZI_RAW__", n = (t) => ({
|
|
3
|
+
__raw: t,
|
|
4
|
+
__marker: e
|
|
5
|
+
}), r = (e) => t(e) ? e.__raw : e;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { e as RAW_MARKER, t as isRawMarker, r as unwrapRaw, n as wrapRaw };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TwigFilter } from './types';
|
|
2
|
+
export declare const identityFilters: Record<string, TwigFilter>;
|
|
3
|
+
export declare const serialisationFilters: Record<string, TwigFilter>;
|
|
4
|
+
export declare const defaultFilters: Record<string, TwigFilter>;
|
|
5
|
+
export declare const stringTransformFilters: Record<string, TwigFilter>;
|
|
6
|
+
export declare const stringOperationFilters: Record<string, TwigFilter>;
|
|
7
|
+
export declare const stringQueryFilters: Record<string, TwigFilter>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { isEmpty as e, toJson as t, toStr as n } from "./values.mjs";
|
|
2
|
+
import { wrapRaw as r } from "./raw.mjs";
|
|
3
|
+
//#region src/helpers/twigWrapper/filters/strings.ts
|
|
4
|
+
var i = { raw: (e) => r(e) }, a = {
|
|
5
|
+
to_json: (e) => t(e),
|
|
6
|
+
json_encode: (e) => t(e),
|
|
7
|
+
object_as_json: (e) => typeof e == "object" && e ? JSON.stringify(e) : e
|
|
8
|
+
}, o = { default: (t, n) => e(t) ? n[0] : t }, s = {
|
|
9
|
+
upper: (e) => typeof e == "string" ? e.toUpperCase() : e,
|
|
10
|
+
lower: (e) => typeof e == "string" ? e.toLowerCase() : e,
|
|
11
|
+
trim: (e) => typeof e == "string" ? e.trim() : e,
|
|
12
|
+
capitalize: (e) => typeof e == "string" && e.length > 0 ? e[0].toUpperCase() + e.slice(1).toLowerCase() : e,
|
|
13
|
+
title: (e) => typeof e == "string" ? e.replace(/\b\w/g, (e) => e.toUpperCase()) : e,
|
|
14
|
+
camelize: (e) => typeof e == "string" ? e.replace(/[-_]+(.)?/g, (e, t) => t ? t.toUpperCase() : "") : e,
|
|
15
|
+
kebab: (e) => typeof e == "string" ? e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase() : e,
|
|
16
|
+
snake: (e) => typeof e == "string" ? e.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase() : e,
|
|
17
|
+
ltrim: (e) => typeof e == "string" ? e.trimStart() : e,
|
|
18
|
+
rtrim: (e) => typeof e == "string" ? e.trimEnd() : e,
|
|
19
|
+
pad: (e, t) => {
|
|
20
|
+
if (typeof e != "string") return e;
|
|
21
|
+
let r = Number(t[0]) || 0, i = t.length > 1 ? n(t[1]) : " ";
|
|
22
|
+
if (i === "") return e;
|
|
23
|
+
let a = r - e.length;
|
|
24
|
+
if (a <= 0) return e;
|
|
25
|
+
let o = Math.ceil(a / i.length);
|
|
26
|
+
return i.repeat(o).slice(0, a) + e;
|
|
27
|
+
},
|
|
28
|
+
padRight: (e, t) => {
|
|
29
|
+
if (typeof e != "string") return e;
|
|
30
|
+
let r = Number(t[0]) || 0, i = t.length > 1 ? n(t[1]) : " ";
|
|
31
|
+
if (i === "") return e;
|
|
32
|
+
let a = r - e.length;
|
|
33
|
+
if (a <= 0) return e;
|
|
34
|
+
let o = Math.ceil(a / i.length);
|
|
35
|
+
return e + i.repeat(o).slice(0, a);
|
|
36
|
+
},
|
|
37
|
+
number: (e, t) => {
|
|
38
|
+
if (typeof e == "number") {
|
|
39
|
+
let n = Number(t[0]) || 0;
|
|
40
|
+
return e.toFixed(n);
|
|
41
|
+
}
|
|
42
|
+
if (typeof e != "string") return e;
|
|
43
|
+
let n = e.match(/-?\d+(?:\.\d+)?/);
|
|
44
|
+
return n ? Number(n[0]) : 0;
|
|
45
|
+
}
|
|
46
|
+
}, c = {
|
|
47
|
+
replace: (e, t) => {
|
|
48
|
+
if (typeof e != "string" || t.length === 0) return e;
|
|
49
|
+
let [r] = t;
|
|
50
|
+
if (typeof r == "object" && r && !Array.isArray(r)) {
|
|
51
|
+
let t = new Map(Object.entries(r).filter(([e]) => e !== ""));
|
|
52
|
+
if (t.size === 0) return e;
|
|
53
|
+
let i = [...t.keys()].sort((e, t) => t.length - e.length), a = new RegExp(i.map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), "g");
|
|
54
|
+
return e.replace(a, (e) => n(t.get(e)));
|
|
55
|
+
}
|
|
56
|
+
return e.split(n(r)).join(n(t[1]));
|
|
57
|
+
},
|
|
58
|
+
slice: (e, t) => {
|
|
59
|
+
if (t.length === 0) return e;
|
|
60
|
+
let n = Number(t[0]) || 0, r = t.length > 1 && Number.isFinite(Number(t[1])) ? n + Number(t[1]) : void 0;
|
|
61
|
+
return typeof e == "string" || Array.isArray(e) ? e.slice(n, r) : e;
|
|
62
|
+
},
|
|
63
|
+
split: (e, t) => typeof e == "string" && t.length > 0 ? e.split(n(t[0])) : e,
|
|
64
|
+
join: (e, t) => Array.isArray(e) ? e.join(t.length === 0 ? "" : n(t[0])) : e,
|
|
65
|
+
reverse: (e) => typeof e == "string" ? e.split("").reverse().join("") : Array.isArray(e) ? [...e].reverse() : e
|
|
66
|
+
}, l = {
|
|
67
|
+
length: (e) => typeof e == "string" || Array.isArray(e) ? e.length : typeof e == "number" ? n(e).length : typeof e == "object" && e ? Object.keys(e).length : 0,
|
|
68
|
+
first: (e) => typeof e == "string" ? e.length > 0 ? e[0] : "" : Array.isArray(e) ? e.length > 0 ? e[0] : void 0 : e,
|
|
69
|
+
last: (e) => typeof e == "string" ? e.length > 0 ? e[e.length - 1] : "" : Array.isArray(e) ? e.length > 0 ? e[e.length - 1] : void 0 : e,
|
|
70
|
+
contains: (e, t) => {
|
|
71
|
+
if (t.length === 0) return !1;
|
|
72
|
+
let r = t[0];
|
|
73
|
+
return typeof e == "string" ? e.includes(n(r)) : Array.isArray(e) ? e.includes(r) : !1;
|
|
74
|
+
},
|
|
75
|
+
startswith: (e, t) => typeof e == "string" && t.length > 0 && e.startsWith(n(t[0])),
|
|
76
|
+
endswith: (e, t) => typeof e == "string" && t.length > 0 && e.endsWith(n(t[0]))
|
|
77
|
+
};
|
|
78
|
+
//#endregion
|
|
79
|
+
export { o as defaultFilters, i as identityFilters, a as serialisationFilters, c as stringOperationFilters, l as stringQueryFilters, s as stringTransformFilters };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const isEmpty: (value: unknown) => boolean;
|
|
2
|
+
export declare const compareValues: (a: unknown, b: unknown) => number;
|
|
3
|
+
/** What JSON cannot hold — nothing, a function, a symbol — is Twig's `null`; a bigint is its digits. */
|
|
4
|
+
export declare const toJson: (value: unknown) => string;
|
|
5
|
+
export declare const toStr: (value: unknown) => string;
|
|
6
|
+
/** A number, or text that is one — a price read out of a JSON file is often a string. */
|
|
7
|
+
export declare const numberOf: (value: unknown) => number | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* A number as a locale writes it. A locale the runtime does not know falls back to `en`, and options it cannot honour —
|
|
10
|
+
* a currency code that is not one — leave the number as written: a template renders something rather than throw.
|
|
11
|
+
*/
|
|
12
|
+
export declare const formatNumber: (value: number, locale: unknown, options: Intl.NumberFormatOptions) => string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/helpers/twigWrapper/filters/values.ts
|
|
2
|
+
var e = (e) => e == null || e === "", t = (e, t) => e === t ? 0 : e == null ? -1 : t == null ? 1 : typeof e == "number" && typeof t == "number" ? e - t : String(e).localeCompare(String(t)), n = (e) => e === void 0 || typeof e == "function" || typeof e == "symbol" ? "null" : typeof e == "bigint" ? e.toString() : JSON.stringify(e), r = (e) => e == null ? "" : String(e), i = (e) => {
|
|
3
|
+
if (typeof e == "number") return Number.isFinite(e) ? e : void 0;
|
|
4
|
+
if (typeof e == "string" && e.trim() !== "") {
|
|
5
|
+
let t = Number(e);
|
|
6
|
+
return Number.isFinite(t) ? t : void 0;
|
|
7
|
+
}
|
|
8
|
+
}, a = (e, t, n) => {
|
|
9
|
+
for (let i of [t == null ? "en" : r(t), "en"]) try {
|
|
10
|
+
return new Intl.NumberFormat(i, n).format(e);
|
|
11
|
+
} catch {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
return String(e);
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { t as compareValues, a as formatNumber, e as isEmpty, i as numberOf, n as toJson, r as toStr };
|
|
@@ -11,6 +11,11 @@ export type TemplateInspection = {
|
|
|
11
11
|
* scope when it renders.
|
|
12
12
|
*/
|
|
13
13
|
freeNames: string[];
|
|
14
|
+
/**
|
|
15
|
+
* What reads as something other than it looks, though the interpreter reads it whole: `sort or 'listeners'` answers
|
|
16
|
+
* `true`, never "listeners" — `or` is a test, and a fallback value is `??`. A run's Explore links wrote `?sort=true`.
|
|
17
|
+
*/
|
|
18
|
+
notes: string[];
|
|
14
19
|
};
|
|
15
20
|
/**
|
|
16
21
|
* What a template would do that its author did not write — read at author time, with the parser the runtime uses.
|
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
import { filters as e } from "./filters/filters.mjs";
|
|
2
2
|
import { lex as t } from "./Lexer/Lexer.mjs";
|
|
3
3
|
import { parse as n } from "./Parser/Parser.mjs";
|
|
4
|
+
import { FUNCTION_DOCS as r } from "./filters/catalog/index.mjs";
|
|
4
5
|
//#region src/helpers/twigWrapper/inspectTemplate.ts
|
|
5
|
-
var
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
var i = (e) => e.replace(/_/g, "").toLowerCase(), a = (t) => Object.keys(e).find((e) => i(e) === i(t)), o = {
|
|
7
|
+
concat: "first|merge(second)",
|
|
8
|
+
push: "list|merge([item])",
|
|
9
|
+
includes: "item in list",
|
|
10
|
+
indexOf: "list|find(…)",
|
|
11
|
+
toUpperCase: "value|upper",
|
|
12
|
+
toLowerCase: "value|lower",
|
|
13
|
+
startsWith: "value|startswith(prefix)",
|
|
14
|
+
endsWith: "value|endswith(suffix)",
|
|
15
|
+
toFixed: "value|number(2)",
|
|
16
|
+
stringify: "value|to_json",
|
|
17
|
+
uniq: "list|unique",
|
|
18
|
+
groupBy: "list|group_by('field')"
|
|
19
|
+
}, s = new Set(Object.keys(r)), c = (e) => `value|round(0, '${e}')`, l = {
|
|
20
|
+
floor: c("floor"),
|
|
21
|
+
ceil: c("ceil"),
|
|
13
22
|
clamp: "min(max(value, low), high)"
|
|
14
|
-
},
|
|
15
|
-
let n = Object.hasOwn(e, t) ? `value|${t}` :
|
|
16
|
-
return `Unknown function "${t}()"${n ? ` — write \`${n}\`` : ""}: the functions are ${[...
|
|
17
|
-
},
|
|
23
|
+
}, u = (t) => {
|
|
24
|
+
let n = Object.hasOwn(e, t) ? `value|${t}` : l[t];
|
|
25
|
+
return `Unknown function "${t}()"${n ? ` — write \`${n}\`` : ""}: the functions are ${[...s].join(", ")}`;
|
|
26
|
+
}, d = "loop", f = (e) => e.type === "literal" && (typeof e.value == "string" || typeof e.value == "number"), p = class {
|
|
18
27
|
issues = [];
|
|
28
|
+
notes = [];
|
|
19
29
|
freeNames = /* @__PURE__ */ new Set();
|
|
20
30
|
nodes(e, t) {
|
|
21
31
|
let n = new Set(t);
|
|
@@ -36,7 +46,7 @@ var r = /* @__PURE__ */ new Set([
|
|
|
36
46
|
let e = /* @__PURE__ */ new Set([
|
|
37
47
|
...n,
|
|
38
48
|
t.valueVar,
|
|
39
|
-
|
|
49
|
+
d,
|
|
40
50
|
...t.keyVar ? [t.keyVar] : []
|
|
41
51
|
]);
|
|
42
52
|
this.nodes(t.body, e), n = /* @__PURE__ */ new Set([...n, ...this.setsIn(t.body)]), t.elseBody && this.nodes(t.elseBody, n);
|
|
@@ -56,7 +66,10 @@ var r = /* @__PURE__ */ new Set([
|
|
|
56
66
|
return e.flatMap((e) => e.type === "set" ? [e.name] : []);
|
|
57
67
|
}
|
|
58
68
|
filterNames(t) {
|
|
59
|
-
for (let n of t) n && !Object.hasOwn(e, n)
|
|
69
|
+
for (let n of t) if (n && !Object.hasOwn(e, n)) {
|
|
70
|
+
let e = o[n], t = e === void 0 ? a(n) : void 0;
|
|
71
|
+
this.issues.push(`Unknown filter "${n}"${e ? ` — write \`${e}\`` : t ? ` — did you mean \`${t}\`?` : ""}`);
|
|
72
|
+
}
|
|
60
73
|
}
|
|
61
74
|
expression(e, t) {
|
|
62
75
|
switch (e.type) {
|
|
@@ -77,7 +90,7 @@ var r = /* @__PURE__ */ new Set([
|
|
|
77
90
|
this.expression(e.object, t), this.expression(e.index, t);
|
|
78
91
|
return;
|
|
79
92
|
case "function":
|
|
80
|
-
|
|
93
|
+
s.has(e.name) || this.issues.push(u(e.name)), e.args.forEach((e) => this.expression(e, t));
|
|
81
94
|
return;
|
|
82
95
|
case "filter":
|
|
83
96
|
this.expression(e.subject, t), this.filterNames(e.filters.map((e) => e.name));
|
|
@@ -90,6 +103,10 @@ var r = /* @__PURE__ */ new Set([
|
|
|
90
103
|
this.expression(e.operand, t);
|
|
91
104
|
return;
|
|
92
105
|
case "binary":
|
|
106
|
+
if ((e.operator === "or" || e.operator === "and") && [e.left, e.right].some(f)) {
|
|
107
|
+
let t = [e.left, e.right].find(f);
|
|
108
|
+
this.notes.push(`\`${e.operator}\` with ${t?.type === "literal" ? JSON.stringify(t.value) : "a value"} answers true or false, never the value — a fallback value is \`??\`: \`x ?? ${t?.type === "literal" ? JSON.stringify(t.value) : "…"}\``);
|
|
109
|
+
}
|
|
93
110
|
this.expression(e.left, t), (e.operator !== "is" && e.operator !== "is not" || e.right.type !== "path") && this.expression(e.right, t);
|
|
94
111
|
return;
|
|
95
112
|
case "default":
|
|
@@ -101,17 +118,19 @@ var r = /* @__PURE__ */ new Set([
|
|
|
101
118
|
case "arrow": this.expression(e.body, /* @__PURE__ */ new Set([...t, ...e.params]));
|
|
102
119
|
}
|
|
103
120
|
}
|
|
104
|
-
},
|
|
121
|
+
}, m = (e) => {
|
|
105
122
|
let r = t(e);
|
|
106
123
|
if (r.error) return {
|
|
107
124
|
issues: [r.error],
|
|
108
|
-
freeNames: []
|
|
125
|
+
freeNames: [],
|
|
126
|
+
notes: []
|
|
109
127
|
};
|
|
110
|
-
let i = new
|
|
128
|
+
let i = new p(), { nodes: a, error: o } = n(r.tokens, !1, i.issues);
|
|
111
129
|
return o && i.issues.push(o), i.nodes(a, /* @__PURE__ */ new Set()), {
|
|
112
130
|
issues: [...new Set(i.issues)],
|
|
113
|
-
freeNames: [...i.freeNames]
|
|
131
|
+
freeNames: [...i.freeNames],
|
|
132
|
+
notes: [...new Set(i.notes)]
|
|
114
133
|
};
|
|
115
134
|
};
|
|
116
135
|
//#endregion
|
|
117
|
-
export {
|
|
136
|
+
export { m as inspectTemplate };
|
package/dist/helpers/utils.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ export declare const getPathsFromObject: (object?: {
|
|
|
8
8
|
export declare const makeId: (length: number, includeMayus?: boolean, includeNumbers?: boolean) => string;
|
|
9
9
|
export declare function getKeyDecoded(webKey: string, asWebId: true): number;
|
|
10
10
|
export declare function getKeyDecoded<T = unknown>(webKey: string, asWebId?: false): T;
|
|
11
|
+
/**
|
|
12
|
+
* A query string's parameters as the URL standard reads them: a value keeps every `=` after its first (`?next=/a?x=1`
|
|
13
|
+
* is `/a?x=1`), `+` is a space and each is decoded once; a name given twice or more is a list.
|
|
14
|
+
*/
|
|
11
15
|
export declare function ParamsFromURL(query?: string): {
|
|
12
16
|
[key: string]: string | string[];
|
|
13
17
|
};
|
package/dist/helpers/utils.mjs
CHANGED
|
@@ -36,11 +36,9 @@ function a(t, n) {
|
|
|
36
36
|
function o(e) {
|
|
37
37
|
!e && typeof window < "u" && (e = window.location.search);
|
|
38
38
|
let t = {};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let r = n[e].split("="), i = decodeURIComponent(r[0]), a = decodeURIComponent(r[1]);
|
|
43
|
-
t[i] === void 0 ? t[i] = decodeURIComponent(a) : typeof t[i] == "string" ? t[i] = [t[i], decodeURIComponent(a)] : t[i].push(decodeURIComponent(a));
|
|
39
|
+
for (let [n, r] of new URLSearchParams(e ?? "")) {
|
|
40
|
+
let e = Object.hasOwn(t, n) ? t[n] : void 0;
|
|
41
|
+
t[n] = e === void 0 ? r : typeof e == "string" ? [e, r] : [...e, r];
|
|
44
42
|
}
|
|
45
43
|
return t;
|
|
46
44
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { matchPath } from './matchPath';
|
|
2
|
+
export { SITEMAP_EXCLUSION_WORDS, sitemapExclusion, sitemapPaths } from './sitemap';
|
|
2
3
|
export { getPageFullPath, getPaths, isAbsoluteUrl, isPageAuthored, matchRoutePath, notFoundPageFor, getRouteParams, getSlugParams, navigationTarget, NOT_FOUND_SLUG } from './routes';
|
|
3
4
|
export type { PathMatch, PathPattern } from './matchPath';
|
|
4
5
|
export type { NavigationAccessLevel, NavigationAction, Path } from './routes';
|
|
6
|
+
export type { SitemapExclusion } from './sitemap';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { matchPath as e } from "./matchPath.mjs";
|
|
2
2
|
import { NOT_FOUND_SLUG as t, getPageFullPath as n, getPaths as r, getRouteParams as i, getSlugParams as a, isAbsoluteUrl as o, isPageAuthored as s, matchRoutePath as c, navigationTarget as l, notFoundPageFor as u } from "./routes.mjs";
|
|
3
|
-
|
|
3
|
+
import { SITEMAP_EXCLUSION_WORDS as d, sitemapExclusion as f, sitemapPaths as p } from "./sitemap.mjs";
|
|
4
|
+
export { t as NOT_FOUND_SLUG, d as SITEMAP_EXCLUSION_WORDS, n as getPageFullPath, r as getPaths, i as getRouteParams, a as getSlugParams, o as isAbsoluteUrl, s as isPageAuthored, e as matchPath, c as matchRoutePath, l as navigationTarget, u as notFoundPageFor, f as sitemapExclusion, p as sitemapPaths };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Element, Schema } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Why a page is not in the space's `/sitemap.xml` — each a reason a search engine has nothing to list: a page only a
|
|
4
|
+
* signed-in visitor or a role may open, an address made of parameters (one page per record, which no list of the space
|
|
5
|
+
* can name), the page of every address nobody answers, a page that says `noindex`, or one shown behind a feature flag.
|
|
6
|
+
*/
|
|
7
|
+
export type SitemapExclusion = 'signedIn' | 'restricted' | 'parameters' | 'notFound' | 'noindex' | 'flagged';
|
|
8
|
+
/** Each reason in the words a person reads it in — the builder's map of pages says them on each page left out. */
|
|
9
|
+
export declare const SITEMAP_EXCLUSION_WORDS: Record<SitemapExclusion, string>;
|
|
10
|
+
/** Why this page is left out of the sitemap, or nothing: a search engine may read it, and the sitemap lists it. */
|
|
11
|
+
export declare const sitemapExclusion: (page: Element) => SitemapExclusion | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Every address of the space a search engine may read, once each and sorted: its pages left in by
|
|
14
|
+
* {@link sitemapExclusion}, at the path a link to each resolves to (its folders' slugs before its own).
|
|
15
|
+
*/
|
|
16
|
+
export declare const sitemapPaths: (schema: Pick<Schema, "flat" | "pages" | "pageFolders">) => string[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { pageAccessOf as e } from "../schema/pageAccess.mjs";
|
|
2
|
+
import { getPageFullPath as t, getSlugParams as n } from "./routes.mjs";
|
|
3
|
+
//#region src/navigation/sitemap.ts
|
|
4
|
+
var r = {
|
|
5
|
+
signedIn: "Signed-in visitors only",
|
|
6
|
+
restricted: "Only for some roles",
|
|
7
|
+
parameters: "Its address takes parameters",
|
|
8
|
+
notFound: "The page of unknown addresses",
|
|
9
|
+
noindex: "Says noindex",
|
|
10
|
+
flagged: "Behind a feature flag"
|
|
11
|
+
}, i = (e) => typeof e == "string" ? e : "", a = (t) => {
|
|
12
|
+
let { attributes: r, definition: a } = t;
|
|
13
|
+
if (r.accessLevel === "authenticated") return "signedIn";
|
|
14
|
+
if (e(r)) return "restricted";
|
|
15
|
+
let o = i(r.slug);
|
|
16
|
+
return o === "*" || o.endsWith("/*") ? "notFound" : n(o).length > 0 || o.includes("*") ? "parameters" : r.seoEnabled === !0 && /\bnoindex\b/i.test(i(r.seoRobots)) ? "noindex" : a.flag ? "flagged" : void 0;
|
|
17
|
+
}, o = (e) => Object.fromEntries(e.pages.flatMap((t) => {
|
|
18
|
+
let n = e.flat[t];
|
|
19
|
+
return n ? [[t, n]] : [];
|
|
20
|
+
})), s = (e) => {
|
|
21
|
+
let n = o(e), r = e.pageFolders, i = Object.entries(n).filter(([, e]) => !a(e)).map(([e]) => t(n, r, e, !0));
|
|
22
|
+
return [...new Set(i)].sort((e, t) => e.localeCompare(t));
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { r as SITEMAP_EXCLUSION_WORDS, a as sitemapExclusion, s as sitemapPaths };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a space's plan includes, as a server tells the builder, the console and the CLI: each
|
|
3
|
+
* capability by name, included or not, and — when not — the plan that includes it and where to get it. The names are
|
|
4
|
+
* the deployment's; a surface locks the ones it knows and shows the rest as they are.
|
|
5
|
+
*
|
|
6
|
+
* A server that answers none — a self-hosted deployment, a development server — means everything is included, so no
|
|
7
|
+
* surface carries plan logic of its own: {@link isIncluded} answers "yes" for a contract that is absent.
|
|
8
|
+
*/
|
|
9
|
+
export type TCapability = {
|
|
10
|
+
included: boolean;
|
|
11
|
+
/** The capability in the words a refusal says it with: "A custom domain". */
|
|
12
|
+
label: string;
|
|
13
|
+
/** The cheapest plan that includes it, when this one does not: "Site". */
|
|
14
|
+
requires?: string;
|
|
15
|
+
/** Where to get it, when this plan does not include it. */
|
|
16
|
+
upgradeUrl?: string;
|
|
17
|
+
};
|
|
18
|
+
/** The cheapest plan above this one that allows more of a count, what it allows (`null`, no limit) and where to get it. */
|
|
19
|
+
export type TMoreOf = {
|
|
20
|
+
requires: string;
|
|
21
|
+
allows: number | null;
|
|
22
|
+
upgradeUrl: string;
|
|
23
|
+
};
|
|
24
|
+
export type TSpaceEntitlements = {
|
|
25
|
+
/** The plan as a person reads it: "Free", "App+". */
|
|
26
|
+
tierLabel: string;
|
|
27
|
+
/** Unpublished snapshots kept; a revision a domain serves is kept whatever its age. */
|
|
28
|
+
snapshotsKept: number;
|
|
29
|
+
/** Days of the space's analytics read back; 0 reads all the server keeps. */
|
|
30
|
+
analyticsDays: number;
|
|
31
|
+
/** Journeys (e2e tests) the space may keep; `null` has no limit. Played on the builder's canvas without one. */
|
|
32
|
+
journeysPerSpace: number | null;
|
|
33
|
+
/** Journeys played on the server a month (UTC), "Run on the server"; `null` has no limit. A publish's are not counted. */
|
|
34
|
+
serverRunsPerMonth: number | null;
|
|
35
|
+
/** The plan that keeps more journeys, when this one has a limit and one above keeps more. */
|
|
36
|
+
moreJourneys?: TMoreOf;
|
|
37
|
+
/** The plan that plays more journeys on the server, when this one has a limit and one above plays more. */
|
|
38
|
+
moreServerRuns?: TMoreOf;
|
|
39
|
+
capabilities: Record<string, TCapability>;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* What a workspace's plan includes: its seats and how many are taken, its ceilings, and each capability
|
|
43
|
+
* — teams, custom roles, SSO, the audit log — as {@link TCapability}. A count of 0 is not enforced.
|
|
44
|
+
*/
|
|
45
|
+
export type TWorkspaceEntitlements = {
|
|
46
|
+
/** The plan as a person reads it: "Free", "Team". */
|
|
47
|
+
planName: string;
|
|
48
|
+
/**
|
|
49
|
+
* The seats the plan includes (0: unlimited), those bought beyond them, and those taken — members and pending
|
|
50
|
+
* invitations. `purchasable`: the plan sells more.
|
|
51
|
+
*/
|
|
52
|
+
seats: {
|
|
53
|
+
included: number;
|
|
54
|
+
extra: number;
|
|
55
|
+
taken: number;
|
|
56
|
+
purchasable: boolean;
|
|
57
|
+
};
|
|
58
|
+
maxTeams: number;
|
|
59
|
+
/** Days of a space's change history kept; 0 keeps it for the life of the space. */
|
|
60
|
+
historyDays: number;
|
|
61
|
+
/** Days of a space's analytics read back on this plan alone; 0 reads all the server keeps. */
|
|
62
|
+
analyticsDays: number;
|
|
63
|
+
/** The hosted MCP's tool calls a day. */
|
|
64
|
+
mcpCallsPerDay: number;
|
|
65
|
+
capabilities: Record<string, TCapability>;
|
|
66
|
+
};
|
|
67
|
+
/** A plan refusal, as a REST route answers one (HTTP 402) and a GraphQL error carries it in `extensions`. */
|
|
68
|
+
export type TPlanRefusal = {
|
|
69
|
+
error: string;
|
|
70
|
+
code: 'plan-required';
|
|
71
|
+
capability: string;
|
|
72
|
+
requires: string;
|
|
73
|
+
upgradeUrl: string;
|
|
74
|
+
};
|
|
75
|
+
/** Whether the plan includes `capability` — everything does when the server answered no entitlements. */
|
|
76
|
+
export declare const isIncluded: (entitlements: TSpaceEntitlements | TWorkspaceEntitlements | undefined, capability: string) => boolean;
|
|
77
|
+
/** Whether an answer is a plan refusal — what the CLI and the builder print as its error and its link. */
|
|
78
|
+
export declare const isPlanRefusal: (value: unknown) => value is TPlanRefusal;
|
|
79
|
+
/**
|
|
80
|
+
* What the caller may do on a space: the role it holds there — the strongest of its grants — and the space
|
|
81
|
+
* permissions that role allows (`spaceView`, `spaceContent`, `spaceUpdate`, `spaceCode`, `spacePublish`, `spaceManage`,
|
|
82
|
+
* `spaceDelete`). The builder offers what these allow and nothing the server would refuse; the server's gates are what
|
|
83
|
+
* make it true.
|
|
84
|
+
*/
|
|
85
|
+
export type TSpaceAccess = {
|
|
86
|
+
/** What a grant names: `spaceDesigner`, `admin`, a workspace's own. */
|
|
87
|
+
role: string;
|
|
88
|
+
/** The role as a person reads it: "Can design". */
|
|
89
|
+
label: string;
|
|
90
|
+
permissions: string[];
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Whether the caller may do `permission` — everything, when the server answered no access: a self-hosted server or a
|
|
94
|
+
* development one with no roles of its own puts no lock on the builder.
|
|
95
|
+
*/
|
|
96
|
+
export declare const mayDo: (access: TSpaceAccess | undefined, permission: string) => boolean;
|
|
97
|
+
/**
|
|
98
|
+
* The share of an allowance past which it is nearly spent — what every surface warns at: the builder's meter, the
|
|
99
|
+
* dashboard's banner, and the line a site on the platform's shared domain shows its visitors. One number, so they agree.
|
|
100
|
+
*/
|
|
101
|
+
export declare const QUOTA_NEAR_RATIO = 0.8;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region src/network/entitlements.ts
|
|
2
|
+
var e = (e, t) => e?.capabilities[t]?.included ?? !0, t = (e) => typeof e == "object" && !!e && "code" in e && e.code === "plan-required" && "upgradeUrl" in e && typeof e.upgradeUrl == "string", n = (e, t) => e === void 0 || e.permissions.includes(t), r = .8;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { r as QUOTA_NEAR_RATIO, e as isIncluded, t as isPlanRefusal, n as mayDo };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TSpaceServerPlays } from '../../Queries/Space/SpaceTestsQuery';
|
|
2
|
+
/** One step of an e2e test as it went. */
|
|
3
|
+
export type TSpaceE2eStepResult = {
|
|
4
|
+
said: string;
|
|
5
|
+
ok: boolean;
|
|
6
|
+
read?: string;
|
|
7
|
+
notRun?: true;
|
|
8
|
+
ms: number;
|
|
9
|
+
/** The page once the step was played, as a picture (a data URL): the run replayed step by step. */
|
|
10
|
+
frame?: string;
|
|
11
|
+
};
|
|
12
|
+
/** One e2e test as it went on the draft: its steps, or why it could not start. */
|
|
13
|
+
export type TSpaceE2eResult = {
|
|
14
|
+
id: string;
|
|
15
|
+
title: string;
|
|
16
|
+
ok: boolean;
|
|
17
|
+
ms: number;
|
|
18
|
+
steps: TSpaceE2eStepResult[];
|
|
19
|
+
problem?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The e2e tests played on the draft — or why none was run on this server — and the month's plays once they were
|
|
23
|
+
* counted, said by a server that counts them.
|
|
24
|
+
*/
|
|
25
|
+
export type TSpaceRunE2eTestsMutation = {
|
|
26
|
+
results: TSpaceE2eResult[];
|
|
27
|
+
notRun: string | null;
|
|
28
|
+
serverPlays?: TSpaceServerPlays;
|
|
29
|
+
};
|
|
30
|
+
declare const SpaceRunE2eTestsMutation = "\n mutation SpaceRunE2eTestsMutation($ids: [String!]) {\n SpaceRunE2eTests(ids: $ids) {\n results\n notRun\n \n serverPlays {\n used\n limit\n resetsOn\n }\n\n }\n }\n";
|
|
31
|
+
export default SpaceRunE2eTestsMutation;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SPACE_SERVER_PLAYS_FIELDS as e } from "../../Queries/Space/SpaceTestsQuery.mjs";
|
|
2
|
+
//#region src/network/graphql/builder/Mutations/Space/SpaceRunE2eTestsMutation.ts
|
|
3
|
+
var t = `
|
|
4
|
+
mutation SpaceRunE2eTestsMutation($ids: [String!]) {
|
|
5
|
+
SpaceRunE2eTests(ids: $ids) {
|
|
6
|
+
results
|
|
7
|
+
notRun
|
|
8
|
+
${e}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TSpaceTests } from '../../Queries/Space/SpaceTestsQuery';
|
|
2
|
+
/** The space's tests saved whole; answers how they stand now, as `SpaceTests` does. */
|
|
3
|
+
export type TSpaceSetTestsMutation = TSpaceTests;
|
|
4
|
+
declare const SpaceSetTestsMutation = "\n mutation SpaceSetTestsMutation($environment: String!, $tests: JsonObject!) {\n SpaceSetTests(environment: $environment, tests: $tests) {\n \n tests\n problems\n unitPassed\n unitFailed\n unit {\n id\n title\n ok\n misses\n problem\n }\n e2eNotRun\n \n serverPlays {\n used\n limit\n resetsOn\n }\n\n\n }\n }\n";
|
|
5
|
+
export default SpaceSetTestsMutation;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SPACE_TESTS_FIELDS as e } from "../../Queries/Space/SpaceTestsQuery.mjs";
|
|
2
|
+
//#region src/network/graphql/builder/Mutations/Space/SpaceSetTestsMutation.ts
|
|
3
|
+
var t = `
|
|
4
|
+
mutation SpaceSetTestsMutation($environment: String!, $tests: JsonObject!) {
|
|
5
|
+
SpaceSetTests(environment: $environment, tests: $tests) {
|
|
6
|
+
${e}
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
`;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as default };
|