@plitzi/sdk-shared 0.39.3 → 0.39.6
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 +18 -0
- package/dist/clients/index.d.ts +60 -0
- package/dist/clients/index.mjs +47 -0
- package/dist/conditions/types.d.ts +1 -1
- package/dist/credentials/index.d.ts +4 -0
- package/dist/credentials/index.mjs +3 -0
- package/dist/credentials/kinds.d.ts +54 -0
- package/dist/credentials/kinds.mjs +326 -0
- package/dist/credentials/problems.d.ts +14 -0
- package/dist/credentials/problems.mjs +43 -0
- 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/charClass.mjs +21 -16
- 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/hooks/index.d.ts +2 -1
- package/dist/hooks/index.mjs +3 -2
- package/dist/hooks/usePrePaint.d.ts +12 -0
- package/dist/hooks/usePrePaint.mjs +8 -0
- package/dist/navigation/index.d.ts +2 -1
- package/dist/navigation/index.mjs +4 -3
- package/dist/navigation/notFoundPages.d.ts +25 -0
- package/dist/navigation/notFoundPages.mjs +11 -0
- 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/network/graphql/builder/Mutations/Space/SpaceCancelDeployMutation.d.ts +7 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceCancelDeployMutation.mjs +3 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceCancelScheduledPublishMutation.d.ts +6 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceCancelScheduledPublishMutation.mjs +3 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceDeployMutation.d.ts +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceDeployMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceRedeployMutation.d.ts +5 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceRedeployMutation.mjs +3 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceRollbackMutation.d.ts +5 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceRollbackMutation.mjs +3 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceSchedulePublishMutation.d.ts +5 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceSchedulePublishMutation.mjs +3 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceSetTargetMutation.d.ts +10 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceSetTargetMutation.mjs +3 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceTargetAutomationMutation.d.ts +11 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceTargetAutomationMutation.mjs +3 -0
- package/dist/network/graphql/builder/Mutations/index.d.ts +14 -0
- package/dist/network/graphql/builder/Mutations/index.mjs +88 -74
- package/dist/network/graphql/builder/Queries/Space/SpaceDeployDetailQuery.d.ts +7 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceDeployDetailQuery.mjs +3 -0
- package/dist/network/graphql/builder/Queries/Space/SpacePublishCheckQuery.d.ts +7 -0
- package/dist/network/graphql/builder/Queries/Space/SpacePublishCheckQuery.mjs +3 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceReleasesQuery.d.ts +7 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceReleasesQuery.mjs +3 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceScheduledPublishesQuery.d.ts +7 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceScheduledPublishesQuery.mjs +3 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceSnapshotsQuery.d.ts +7 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceSnapshotsQuery.mjs +3 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceTargetsQuery.d.ts +7 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceTargetsQuery.mjs +3 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceVersionChangesQuery.d.ts +7 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceVersionChangesQuery.mjs +3 -0
- package/dist/network/graphql/builder/Queries/index.d.ts +14 -0
- package/dist/network/graphql/builder/Queries/index.mjs +38 -24
- 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.d.ts +6 -0
- package/dist/schema/pageAccess.mjs +23 -23
- 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 +10 -10
- package/dist/store/storeHooks.d.ts +45 -45
- 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/ServerTypes.d.ts +6 -0
- package/dist/types/SpaceTypes.d.ts +277 -6
- package/dist/types/StoreTypes.d.ts +11 -0
- package/eslint.config.mjs +123 -100
- package/package.json +9 -13
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/csrf/csrf.ts
|
|
2
|
+
var e = "x-csrf-token", t = "_csrf", n = "_csrf", r = "plitzi-csrf", i = [
|
|
3
|
+
"missing",
|
|
4
|
+
"malformed",
|
|
5
|
+
"expired",
|
|
6
|
+
"mismatch"
|
|
7
|
+
], a = /* @__PURE__ */ new Set([
|
|
8
|
+
"POST",
|
|
9
|
+
"PUT",
|
|
10
|
+
"PATCH",
|
|
11
|
+
"DELETE"
|
|
12
|
+
]), o = (e) => typeof e == "object" && !!e && typeof e.origin == "string" && typeof e.cookie == "string", s = (e) => {
|
|
13
|
+
if (typeof e != "object" || !e) return !1;
|
|
14
|
+
let { apis: t, path: n } = e;
|
|
15
|
+
return Array.isArray(t) && t.every(o) && typeof n == "string";
|
|
16
|
+
}, c = (e) => {
|
|
17
|
+
let t = (e ?? (typeof document > "u" ? void 0 : document))?.querySelector(`meta[name="${r}"]`)?.getAttribute("content");
|
|
18
|
+
if (t) try {
|
|
19
|
+
let e = JSON.parse(t);
|
|
20
|
+
return s(e) ? e : void 0;
|
|
21
|
+
} catch {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}, l = (e, t) => {
|
|
25
|
+
for (let n of e.split(";")) {
|
|
26
|
+
let e = n.indexOf("=");
|
|
27
|
+
if (e !== -1 && n.slice(0, e).trim() === t) return decodeURIComponent(n.slice(e + 1).trim());
|
|
28
|
+
}
|
|
29
|
+
}, u = (e, t) => {
|
|
30
|
+
try {
|
|
31
|
+
return new URL(e, t).origin;
|
|
32
|
+
} catch {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}, d = (e, t, n) => {
|
|
36
|
+
if (!e || n.credentials !== "include" || !a.has((n.method ?? "GET").toUpperCase())) return;
|
|
37
|
+
let r = u(t, typeof location > "u" ? void 0 : location.href);
|
|
38
|
+
return e.apis.find((e) => e.origin === r);
|
|
39
|
+
}, f = /* @__PURE__ */ new Map(), p = async (e, t, n) => {
|
|
40
|
+
let r = await e(`${n}${t.path}`, { credentials: "include" });
|
|
41
|
+
if (!r.ok) return;
|
|
42
|
+
let i = await r.json();
|
|
43
|
+
if (typeof i.token == "string") return f.set(n, i.token), i.token;
|
|
44
|
+
}, m = (e) => l(typeof document > "u" ? "" : document.cookie, e.cookie) ?? f.get(e.origin), h = (t, n) => {
|
|
45
|
+
let r = new Headers(t.headers);
|
|
46
|
+
return r.set(e, n), {
|
|
47
|
+
...t,
|
|
48
|
+
headers: r
|
|
49
|
+
};
|
|
50
|
+
}, g = async (e) => {
|
|
51
|
+
if (e.status !== 403) return !1;
|
|
52
|
+
let t = await e.clone().json().catch(() => void 0);
|
|
53
|
+
return i.includes(t?.reason);
|
|
54
|
+
}, _ = async (e, t = {}, n = globalThis.fetch) => {
|
|
55
|
+
let r = c(), i = d(r, e, t);
|
|
56
|
+
if (!r || !i) return n(e, t);
|
|
57
|
+
let a = m(i) ?? await p(n, r, i.origin), o = await n(e, a ? h(t, a) : t);
|
|
58
|
+
if (!await g(o)) return o;
|
|
59
|
+
let s = await p(n, r, i.origin);
|
|
60
|
+
return s ? n(e, h(t, s)) : o;
|
|
61
|
+
};
|
|
62
|
+
export { n as CSRF_COOKIE_SUFFIX, t as CSRF_FIELD_NAME, e as CSRF_HEADER_NAME, r as CSRF_HINT_META, i as CSRF_RENEWABLE, _ as csrfFetch, c as readCsrfHint };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CSRF_COOKIE_SUFFIX, CSRF_FIELD_NAME, CSRF_HEADER_NAME, CSRF_HINT_META, CSRF_RENEWABLE, csrfFetch, readCsrfHint } from "./csrf.mjs";
|
|
@@ -22,8 +22,9 @@ var e = (e, t) => Object.getOwnPropertyDescriptor(e, t)?.enumerable, t = (n, r,
|
|
|
22
22
|
return !0;
|
|
23
23
|
}
|
|
24
24
|
if (ArrayBuffer.isView(n) && ArrayBuffer.isView(r)) {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
let e = n, t = r;
|
|
26
|
+
if (s = e.length, s != t.length) return !1;
|
|
27
|
+
for (c = s; c-- !== 0;) if (e[c] !== t[c]) return !1;
|
|
27
28
|
return !0;
|
|
28
29
|
}
|
|
29
30
|
if (n.constructor === RegExp) return n.source === r.source && n.global === r.global && n.ignoreCase === r.ignoreCase && n.multiline === r.multiline && n.unicode === r.unicode && n.lastIndex === r.lastIndex && n.sticky === r.sticky;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Path } from './shared';
|
|
2
|
-
export declare
|
|
3
|
-
export declare const cloneObject: <T>(obj: T) => T;
|
|
2
|
+
export declare const cloneDeep: <T>(value: T) => T;
|
|
3
|
+
export declare const cloneObject: <T extends object>(obj: T) => T;
|
|
4
4
|
/**
|
|
5
5
|
* Clones only the necessary path (structural sharing).
|
|
6
6
|
* Useful for immutable operations like omit without cloning the entire object.
|
|
7
7
|
*/
|
|
8
|
-
export declare function cloneAtPath<T extends
|
|
8
|
+
export declare function cloneAtPath<T extends object>(obj: T, path: Path): T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toPath as e } from "./shared.mjs";
|
|
2
2
|
// src/helpers/lodash/cloneDeep.ts
|
|
3
|
-
|
|
3
|
+
var t = (e, n) => {
|
|
4
4
|
if (typeof e != "object" || !e) return e;
|
|
5
5
|
if (n.has(e)) return n.get(e);
|
|
6
6
|
if (e instanceof Date) return new Date(e.getTime());
|
|
@@ -13,41 +13,38 @@ function t(e, n = /* @__PURE__ */ new WeakMap()) {
|
|
|
13
13
|
let r = /* @__PURE__ */ new Set();
|
|
14
14
|
return n.set(e, r), e.forEach((e) => r.add(t(e, n))), r;
|
|
15
15
|
}
|
|
16
|
-
if (ArrayBuffer.isView(e)) {
|
|
17
|
-
if (e instanceof DataView) {
|
|
18
|
-
let r = new DataView(t(e.buffer, n), e.byteOffset, e.byteLength);
|
|
19
|
-
return n.set(e, r), r;
|
|
20
|
-
}
|
|
21
|
-
let r = e.constructor, i = new r(e.buffer.slice(0), e.byteOffset, e.length);
|
|
22
|
-
return n.set(e, i), i;
|
|
23
|
-
}
|
|
24
16
|
if (e instanceof ArrayBuffer) {
|
|
25
17
|
let t = e.slice(0);
|
|
26
18
|
return n.set(e, t), t;
|
|
27
19
|
}
|
|
20
|
+
if (e instanceof DataView) {
|
|
21
|
+
let r = t(e.buffer, n), i = r instanceof ArrayBuffer ? new DataView(r, e.byteOffset, e.byteLength) : e;
|
|
22
|
+
return n.set(e, i), i;
|
|
23
|
+
}
|
|
24
|
+
if (ArrayBuffer.isView(e)) {
|
|
25
|
+
let t = Reflect.get(e, "slice"), r = typeof t == "function" ? Reflect.apply(t, e, []) : e;
|
|
26
|
+
return n.set(e, r), r;
|
|
27
|
+
}
|
|
28
28
|
if (Array.isArray(e)) {
|
|
29
29
|
let r = [];
|
|
30
30
|
return n.set(e, r), e.forEach((e, i) => r[i] = t(e, n)), r;
|
|
31
31
|
}
|
|
32
|
-
let r = Object.getPrototypeOf(e)
|
|
33
|
-
n.set(e,
|
|
34
|
-
for (let
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
let t = i[e], r = o?.[t];
|
|
44
|
-
if (!r || typeof r != "object") {
|
|
45
|
-
s[t] = r;
|
|
32
|
+
let r = Object.create(Reflect.getPrototypeOf(e));
|
|
33
|
+
n.set(e, r);
|
|
34
|
+
for (let i of Object.keys(e)) Reflect.set(r, i, t(Reflect.get(e, i), n));
|
|
35
|
+
return r;
|
|
36
|
+
}, n = (e) => t(e, /* @__PURE__ */ new WeakMap()), r = (e) => Object.assign(Object.create(Reflect.getPrototypeOf(e)), e), i = (e) => Array.isArray(e) ? [...e] : r(e);
|
|
37
|
+
function a(t, n) {
|
|
38
|
+
let r = i(t), a = t, o = r;
|
|
39
|
+
for (let t of e(n)) {
|
|
40
|
+
let e = typeof a == "object" && a ? Reflect.get(a, t) : void 0;
|
|
41
|
+
if (!e || typeof e != "object") {
|
|
42
|
+
Reflect.set(o, t, e);
|
|
46
43
|
break;
|
|
47
44
|
}
|
|
48
|
-
let
|
|
49
|
-
|
|
45
|
+
let n = i(e);
|
|
46
|
+
Reflect.set(o, t, n), a = e, o = n;
|
|
50
47
|
}
|
|
51
|
-
return
|
|
48
|
+
return r;
|
|
52
49
|
}
|
|
53
|
-
export {
|
|
50
|
+
export { a as cloneAtPath, n as cloneDeep, r as cloneObject };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { Path } from './shared';
|
|
2
|
-
|
|
2
|
+
/** Whether every key of the path is there, own or inherited — a value that holds no keys holds none of them. */
|
|
3
|
+
export declare function has(obj: object | null | undefined, path: Path): boolean;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { toPath as e } from "./shared.mjs";
|
|
2
2
|
// src/helpers/lodash/has.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let
|
|
6
|
-
for (let
|
|
7
|
-
if (i
|
|
8
|
-
i = i
|
|
3
|
+
var t = (e) => typeof e == "object" && !!e || typeof e == "function";
|
|
4
|
+
function n(n, r) {
|
|
5
|
+
let i = n;
|
|
6
|
+
for (let n of e(r)) {
|
|
7
|
+
if (!t(i) || !(n in i)) return !1;
|
|
8
|
+
i = Reflect.get(i, n);
|
|
9
9
|
}
|
|
10
|
-
return
|
|
10
|
+
return t(n);
|
|
11
11
|
}
|
|
12
|
-
export {
|
|
12
|
+
export { n as has };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The lodash-like utilities sdk-shared reads paths and keys with — a copy of plitzi-ui's own, which keeps its for its 29
|
|
3
|
-
* files (
|
|
3
|
+
* files (docs/en/server-packages.md, D13): generic, with no Plitzi rule in them, so two copies are not two sources of truth for any rule,
|
|
4
4
|
* and a server reaches neither React nor a UI library to read a path.
|
|
5
5
|
*/
|
|
6
6
|
export * from './get';
|
|
@@ -13,7 +13,7 @@ function i(i, a) {
|
|
|
13
13
|
let l = i;
|
|
14
14
|
if (s.length) {
|
|
15
15
|
let e;
|
|
16
|
-
for (let n of s) Object.prototype.hasOwnProperty.call(l, n) && (e ??= t(l),
|
|
16
|
+
for (let n of s) Object.prototype.hasOwnProperty.call(l, n) && (e ??= t(l), Reflect.deleteProperty(e, n));
|
|
17
17
|
e && (l = e);
|
|
18
18
|
}
|
|
19
19
|
for (let t of c) {
|
|
@@ -26,7 +26,7 @@ function i(i, a) {
|
|
|
26
26
|
}
|
|
27
27
|
if (o && typeof o == "object") {
|
|
28
28
|
let e = i[i.length - 1];
|
|
29
|
-
Object.prototype.hasOwnProperty.call(o, e) &&
|
|
29
|
+
Object.prototype.hasOwnProperty.call(o, e) && Reflect.deleteProperty(o, e);
|
|
30
30
|
}
|
|
31
31
|
l = a;
|
|
32
32
|
}
|
|
@@ -34,25 +34,30 @@ var e = {
|
|
|
34
34
|
LowerN: 110,
|
|
35
35
|
LowerR: 114,
|
|
36
36
|
LowerT: 116
|
|
37
|
-
}, t = (t) => t >= 97 && t <= 122 || t >= 65 && t <= 90 || t === e.Underscore, n = (n) => t(n) || n >= e.Zero && n <= e.Nine, r = (t) => n(t) || t === e.Minus, i = (t) => t >= e.Zero && t <= e.Nine, a = (t) => t === e.Space || t === e.Tab || t === e.Newline || t === e.CarriageReturn, o =
|
|
37
|
+
}, t = (t) => t >= 97 && t <= 122 || t >= 65 && t <= 90 || t === e.Underscore, n = (n) => t(n) || n >= e.Zero && n <= e.Nine, r = (t) => n(t) || t === e.Minus, i = (t) => t >= e.Zero && t <= e.Nine, a = (t) => t === e.Space || t === e.Tab || t === e.Newline || t === e.CarriageReturn, o = /* @__PURE__ */ new Set([
|
|
38
|
+
"true",
|
|
39
|
+
"false",
|
|
40
|
+
"null",
|
|
41
|
+
"none"
|
|
42
|
+
]), s = (e) => {
|
|
38
43
|
let r = e.length;
|
|
39
|
-
if (r === 0 || !t(e.charCodeAt(0))) return !1;
|
|
44
|
+
if (r === 0 || !t(e.charCodeAt(0)) || o.has(e)) return !1;
|
|
40
45
|
for (let t = 1; t < r; t++) if (!n(e.charCodeAt(t))) return !1;
|
|
41
46
|
return !0;
|
|
42
|
-
},
|
|
47
|
+
}, c = (r) => {
|
|
43
48
|
let a = r.length;
|
|
44
|
-
if (a === 0 || !t(r.charCodeAt(0))) return !1;
|
|
45
|
-
let
|
|
46
|
-
for (let
|
|
47
|
-
let a = r.charCodeAt(
|
|
49
|
+
if (a === 0 || !t(r.charCodeAt(0)) || o.has(r)) return !1;
|
|
50
|
+
let s = !1, c = !1;
|
|
51
|
+
for (let o = 1; o < a; o++) {
|
|
52
|
+
let a = r.charCodeAt(o);
|
|
48
53
|
if (a === e.Dot) {
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
} else if (
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
} else if (
|
|
54
|
+
if (s) return !1;
|
|
55
|
+
s = !0, c = !1;
|
|
56
|
+
} else if (s) {
|
|
57
|
+
if (c = i(a), !c && !t(a)) return !1;
|
|
58
|
+
s = !1;
|
|
59
|
+
} else if (c ? !i(a) : !n(a)) return !1;
|
|
55
60
|
}
|
|
56
|
-
return !
|
|
57
|
-
},
|
|
58
|
-
export { e as Char, i as isDigit,
|
|
61
|
+
return !s;
|
|
62
|
+
}, l = (e) => s(e);
|
|
63
|
+
export { e as Char, i as isDigit, c as isDottedPath, n as isIdentPart, t as isIdentStart, r as isPathPart, s as isSimpleIdentifier, a as isSpace, l as isVariableName };
|
|
@@ -1,65 +1,66 @@
|
|
|
1
|
-
import { ARROW_PARAMS as e } from "./types.mjs";
|
|
2
|
-
import { compareValues as
|
|
1
|
+
import { ARROW_PARAMS as e, isCallback as t, isList as n } from "./types.mjs";
|
|
2
|
+
import { compareValues as r, toStr as i } from "./values.mjs";
|
|
3
|
+
import { isRecord as a } from "../../isRecord.mjs";
|
|
3
4
|
// src/helpers/twigWrapper/filters/arrays.ts
|
|
4
|
-
var
|
|
5
|
-
sort: (
|
|
6
|
-
if (!
|
|
7
|
-
let
|
|
8
|
-
if (
|
|
9
|
-
let
|
|
10
|
-
return (
|
|
5
|
+
var o = {
|
|
6
|
+
sort: (i, a) => {
|
|
7
|
+
if (!n(i)) return i;
|
|
8
|
+
let o = [...i], s = a[0];
|
|
9
|
+
if (t(s)) {
|
|
10
|
+
let t = s;
|
|
11
|
+
return (t[e] ?? 1) >= 2 ? o.sort((e, n) => Number(t(e, n))) : o.sort((e, n) => r(t(e), t(n)));
|
|
11
12
|
}
|
|
12
|
-
return
|
|
13
|
+
return o.sort(r);
|
|
13
14
|
},
|
|
14
15
|
batch: (e, t) => {
|
|
15
|
-
if (!
|
|
16
|
-
let
|
|
17
|
-
if (
|
|
18
|
-
let
|
|
19
|
-
for (let t = 0; t < e.length; t +=
|
|
20
|
-
return
|
|
16
|
+
if (!n(e) || t.length === 0) return e;
|
|
17
|
+
let r = Number(t[0]);
|
|
18
|
+
if (r <= 0) return e;
|
|
19
|
+
let i = [];
|
|
20
|
+
for (let t = 0; t < e.length; t += r) i.push(e.slice(t, t + r));
|
|
21
|
+
return i;
|
|
21
22
|
},
|
|
22
|
-
map: (e,
|
|
23
|
-
if (!
|
|
24
|
-
let
|
|
25
|
-
return
|
|
23
|
+
map: (e, r) => {
|
|
24
|
+
if (!n(e) || r.length === 0) return e;
|
|
25
|
+
let i = r[0];
|
|
26
|
+
return t(i) ? e.map((e, t) => i(e, t)) : e;
|
|
26
27
|
},
|
|
27
|
-
reduce: (e,
|
|
28
|
-
if (!
|
|
29
|
-
let
|
|
30
|
-
if (
|
|
31
|
-
let
|
|
32
|
-
for (let t =
|
|
33
|
-
return
|
|
28
|
+
reduce: (e, r) => {
|
|
29
|
+
if (!n(e) || r.length === 0) return e;
|
|
30
|
+
let i = r[0];
|
|
31
|
+
if (!t(i)) return e;
|
|
32
|
+
let a = r[1], o = +(a === void 0), s = a === void 0 ? e[0] : a;
|
|
33
|
+
for (let t = o; t < e.length; t++) s = i(s, e[t], t);
|
|
34
|
+
return s;
|
|
34
35
|
},
|
|
35
36
|
merge: (e, t) => {
|
|
36
37
|
if (t.length === 0) return e;
|
|
37
|
-
let
|
|
38
|
-
return
|
|
38
|
+
let r = t[0];
|
|
39
|
+
return n(e) && n(r) ? [...e, ...r] : typeof e == "object" && e && typeof r == "object" && r && !n(r) ? {
|
|
39
40
|
...e,
|
|
40
|
-
...
|
|
41
|
+
...r
|
|
41
42
|
} : e;
|
|
42
43
|
},
|
|
43
|
-
keys: (e) =>
|
|
44
|
-
values: (e) =>
|
|
45
|
-
filter: (e,
|
|
46
|
-
if (!
|
|
47
|
-
if (
|
|
48
|
-
let
|
|
49
|
-
if (
|
|
50
|
-
let
|
|
44
|
+
keys: (e) => a(e) ? Object.keys(e) : e,
|
|
45
|
+
values: (e) => a(e) ? Object.values(e) : e,
|
|
46
|
+
filter: (e, r) => {
|
|
47
|
+
if (!n(e)) return e;
|
|
48
|
+
if (r.length === 0) return e.filter(Boolean);
|
|
49
|
+
let a = r[0];
|
|
50
|
+
if (t(a)) return e.filter((e, t) => a(e, t));
|
|
51
|
+
let o = i(a);
|
|
51
52
|
return e.filter((e) => {
|
|
52
53
|
if (typeof e == "object" && e) {
|
|
53
|
-
let t = e[
|
|
54
|
+
let t = e[o];
|
|
54
55
|
return t != null && t !== !1 && t !== "";
|
|
55
56
|
}
|
|
56
57
|
return !!e;
|
|
57
58
|
});
|
|
58
59
|
},
|
|
59
60
|
column: (e, t) => {
|
|
60
|
-
if (!
|
|
61
|
-
let r =
|
|
61
|
+
if (!n(e) || t.length === 0) return e;
|
|
62
|
+
let r = i(t[0]);
|
|
62
63
|
return e.map((e) => typeof e == "object" && e ? e[r] : void 0);
|
|
63
64
|
}
|
|
64
65
|
};
|
|
65
|
-
export {
|
|
66
|
+
export { o as arrayTransformFilters };
|
|
@@ -5,9 +5,9 @@ import { numberFilters as o } from "./numbers.mjs";
|
|
|
5
5
|
import { objectFilters as s, queryFilters as c } from "./objects.mjs";
|
|
6
6
|
import { defaultFilters as l, identityFilters as u, serialisationFilters as d, stringOperationFilters as f, stringQueryFilters as p, stringTransformFilters as m } from "./strings.mjs";
|
|
7
7
|
import { RAW_MARKER as h, isRawMarker as g, unwrapRaw as _, wrapRaw as v } from "./raw.mjs";
|
|
8
|
-
import { ARROW_PARAMS as y } from "./types.mjs";
|
|
8
|
+
import { ARROW_PARAMS as y, isCallback as b, isList as x } from "./types.mjs";
|
|
9
9
|
// src/helpers/twigWrapper/filters/filters.ts
|
|
10
|
-
var
|
|
10
|
+
var S = {
|
|
11
11
|
...u,
|
|
12
12
|
...d,
|
|
13
13
|
...l,
|
|
@@ -24,4 +24,4 @@ var b = {
|
|
|
24
24
|
...s,
|
|
25
25
|
...c
|
|
26
26
|
};
|
|
27
|
-
export { y as ARROW_PARAMS, h as RAW_MARKER,
|
|
27
|
+
export { y as ARROW_PARAMS, h as RAW_MARKER, S as filters, b as isCallback, x as isList, g as isRawMarker, _ as unwrapRaw, v as wrapRaw };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ARROW_PARAMS as e } from "./types.mjs";
|
|
2
|
-
import { RAW_MARKER as
|
|
3
|
-
import { filters as
|
|
4
|
-
export { e as ARROW_PARAMS,
|
|
1
|
+
import { ARROW_PARAMS as e, isCallback as t, isList as n } from "./types.mjs";
|
|
2
|
+
import { RAW_MARKER as r, isRawMarker as i, unwrapRaw as a, wrapRaw as o } from "./raw.mjs";
|
|
3
|
+
import { filters as s } from "./filters.mjs";
|
|
4
|
+
export { e as ARROW_PARAMS, r as RAW_MARKER, s as filters, t as isCallback, n as isList, i as isRawMarker, a as unwrapRaw, o as wrapRaw };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { base64ToUtf8 as e, md5Hex as t, utf8ToBase64 as n } from "./hashing.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { isList as r } from "./types.mjs";
|
|
3
|
+
import { toStr as i } from "./values.mjs";
|
|
3
4
|
// src/helpers/twigWrapper/filters/misc.ts
|
|
4
|
-
var
|
|
5
|
-
url_encode: (e) => typeof e == "string" ? encodeURIComponent(e) : typeof e == "object" && e && !
|
|
5
|
+
var a = {
|
|
6
|
+
url_encode: (e) => typeof e == "string" ? encodeURIComponent(e) : typeof e == "object" && e && !r(e) ? new URLSearchParams(Object.fromEntries(Object.entries(e).map(([e, t]) => [e, i(t)]))).toString() : e,
|
|
6
7
|
nl2br: (e) => typeof e == "string" ? e.replace(/\n/g, "<br>") : e,
|
|
7
8
|
striptags: (e, t) => {
|
|
8
9
|
if (typeof e != "string") return e;
|
|
9
|
-
let n = t.length > 0 ?
|
|
10
|
+
let n = t.length > 0 ? i(t[0]).trim() : "";
|
|
10
11
|
if (n) {
|
|
11
12
|
let t = n.split(/(?:\s*>\s*<\s*|<\s*|>\s*)/).filter(Boolean).map((e) => e.replace(/[/>]/g, "").trim());
|
|
12
13
|
if (t.length > 0) {
|
|
@@ -19,33 +20,33 @@ var i = {
|
|
|
19
20
|
abs: (e) => typeof e == "number" ? Math.abs(e) : e,
|
|
20
21
|
round: (e, t) => {
|
|
21
22
|
if (typeof e != "number") return e;
|
|
22
|
-
let n = Number(t[0]) || 0,
|
|
23
|
-
return
|
|
23
|
+
let n = Number(t[0]) || 0, r = t[1] == null ? "common" : i(t[1]), a = 10 ** n;
|
|
24
|
+
return r === "ceil" ? Math.ceil(e * a) / a : r === "floor" ? Math.floor(e * a) / a : Math.round(e * a) / a;
|
|
24
25
|
},
|
|
25
26
|
format: (e, t) => {
|
|
26
27
|
if (typeof e != "string") return e;
|
|
27
28
|
let n = 0;
|
|
28
|
-
return e.replace(/%((?:[-+ 0]|'.)*)(\d*)(?:\.(\d+))?([sdf%])/g, (e,
|
|
29
|
+
return e.replace(/%((?:[-+ 0]|'.)*)(\d*)(?:\.(\d+))?([sdf%])/g, (e, r, a, o, s) => {
|
|
29
30
|
if (s === "%") return "%";
|
|
30
31
|
let c = t[n];
|
|
31
32
|
if (n++, c === void 0) return e;
|
|
32
|
-
let l =
|
|
33
|
+
let l = r.includes("+"), u;
|
|
33
34
|
if (s === "d") {
|
|
34
35
|
let e = Math.trunc(Number(c));
|
|
35
36
|
u = `${l && e >= 0 ? "+" : ""}${e}`;
|
|
36
37
|
} else if (s === "f") {
|
|
37
38
|
let e = Number(c);
|
|
38
39
|
u = `${l && e >= 0 ? "+" : ""}${o === void 0 ? String(e) : e.toFixed(Number(o))}`;
|
|
39
|
-
} else u =
|
|
40
|
+
} else u = i(c), u = o === void 0 ? u : u.slice(0, Number(o));
|
|
40
41
|
let d = Number(a || 0);
|
|
41
42
|
if (u.length >= d) return u;
|
|
42
|
-
let f = /'(.)/.exec(
|
|
43
|
-
return
|
|
43
|
+
let f = /'(.)/.exec(r), p = f ? f[1] : r.includes("0") ? "0" : " ";
|
|
44
|
+
return r.includes("-") ? u.padEnd(d, p === "0" ? " " : p) : p === "0" && s !== "s" && /^[+-]/.test(u) ? u[0] + u.slice(1).padStart(d - 1, "0") : u.padStart(d, p);
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
|
-
},
|
|
47
|
+
}, o = { spaceless: (e) => typeof e == "string" ? e.replace(/>\s+</g, "><").trim() : e }, s = { random: (e) => r(e) ? e.length > 0 ? e[Math.floor(Math.random() * e.length)] : void 0 : typeof e == "string" ? e.length > 0 ? e[Math.floor(Math.random() * e.length)] : "" : typeof e == "number" ? Math.floor(Math.random() * e) : e }, c = {
|
|
47
48
|
base64_encode: (e) => typeof e == "string" ? n(e) : e,
|
|
48
49
|
base64_decode: (t) => typeof t == "string" ? e(t) : t,
|
|
49
50
|
md5: (e) => typeof e == "string" ? t(e) : e
|
|
50
51
|
};
|
|
51
|
-
export {
|
|
52
|
+
export { c as encodingFilters, a as miscFilters, s as randomFilters, o as whitespaceFilters };
|
|
@@ -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 };
|