@plitzi/sdk-shared 0.37.1 → 0.37.3
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 +1288 -0
- package/dist/actions/access.d.ts +12 -0
- package/dist/actions/access.mjs +13 -0
- package/dist/actions/cron.d.ts +21 -12
- package/dist/actions/cron.mjs +48 -17
- package/dist/actions/functions.d.ts +27 -0
- package/dist/actions/functions.mjs +18 -0
- package/dist/actions/index.d.ts +5 -1
- package/dist/actions/index.mjs +9 -7
- package/dist/actions/triggers.d.ts +4 -0
- package/dist/actions/triggers.mjs +4 -1
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.mjs +2 -1
- package/dist/auth/visitorRoles.d.ts +27 -0
- package/dist/auth/visitorRoles.mjs +48 -0
- package/dist/authoring/builder.mjs +1 -0
- package/dist/authoring/declare.d.ts +74 -0
- package/dist/authoring/declare.mjs +2 -2
- package/dist/authoring/index.mjs +5 -5
- package/dist/authoring/paramSpec.d.ts +1 -1
- package/dist/authoring/paramSpec.mjs +1 -0
- package/dist/authoring/spaceCallbacks.mjs +2 -2
- package/dist/dataSource/computed.d.ts +21 -0
- package/dist/dataSource/computed.mjs +45 -0
- package/dist/dataSource/getBindingsDetails.mjs +35 -33
- package/dist/dataSource/index.d.ts +1 -0
- package/dist/dataSource/index.mjs +7 -6
- package/dist/dataSource/utility/checkboxParams.d.ts +11 -0
- package/dist/dataSource/utility/checkboxParams.mjs +12 -0
- package/dist/dataSource/utility/not.mjs +4 -7
- package/dist/dataSource/utility/stringToArray.mjs +1 -1
- package/dist/dataSource/utility/truthiness.d.ts +1 -0
- package/dist/dataSource/utility/truthiness.mjs +8 -0
- package/dist/dataSource/utility/twigTemplate.d.ts +2 -1
- package/dist/dataSource/utility/twigTemplate.mjs +29 -17
- package/dist/devTools/utils/PlitziConsole.mjs +22 -22
- package/dist/helpers/cookies.d.ts +10 -0
- package/dist/helpers/cookies.mjs +19 -0
- package/dist/helpers/fetchManifest.d.ts +9 -0
- package/dist/helpers/fetchManifest.mjs +3 -6
- package/dist/helpers/formatDate.d.ts +5 -3
- package/dist/helpers/formatDate.mjs +34 -36
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.mjs +18 -13
- package/dist/helpers/isDate.d.ts +7 -0
- package/dist/helpers/isDate.mjs +15 -0
- package/dist/helpers/keys.d.ts +42 -0
- package/dist/helpers/keys.mjs +91 -0
- package/dist/helpers/twigWrapper/AST.d.ts +2 -2
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.d.ts +12 -2
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +69 -31
- package/dist/helpers/twigWrapper/Evaluator/index.d.ts +1 -1
- package/dist/helpers/twigWrapper/Evaluator/index.mjs +2 -2
- package/dist/helpers/twigWrapper/Parser/ExpressionParser.d.ts +2 -2
- package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +147 -34
- package/dist/helpers/twigWrapper/Parser/Parser.d.ts +2 -1
- package/dist/helpers/twigWrapper/Parser/Parser.mjs +21 -20
- package/dist/helpers/twigWrapper/filters/filters.mjs +134 -111
- package/dist/helpers/twigWrapper/index.d.ts +6 -2
- package/dist/helpers/twigWrapper/index.mjs +7 -4
- package/dist/helpers/twigWrapper/inspectTemplate.d.ts +23 -0
- package/dist/helpers/twigWrapper/inspectTemplate.mjs +110 -0
- package/dist/helpers/twigWrapper/processTwig/helpers.d.ts +7 -0
- package/dist/helpers/twigWrapper/processTwig/helpers.mjs +2 -1
- package/dist/helpers/twigWrapper/processTwig/index.d.ts +2 -1
- package/dist/helpers/twigWrapper/processTwig/index.mjs +3 -2
- package/dist/helpers/twigWrapper/processTwig/processTwig.d.ts +28 -0
- package/dist/helpers/twigWrapper/processTwig/processTwig.mjs +73 -16
- package/dist/helpers/twigWrapper/processTwig/resolveStepParam.d.ts +17 -0
- package/dist/helpers/twigWrapper/processTwig/resolveStepParam.mjs +14 -0
- package/dist/helpers/twigWrapper/templateRoots.d.ts +11 -0
- package/dist/helpers/twigWrapper/templateRoots.mjs +4 -4
- package/dist/helpers/twigWrapper/tokens/hasTemplateSyntax.d.ts +9 -0
- package/dist/helpers/twigWrapper/tokens/hasTemplateSyntax.mjs +4 -0
- package/dist/history/describe.d.ts +29 -0
- package/dist/history/describe.mjs +93 -0
- package/dist/history/diff.d.ts +33 -0
- package/dist/history/diff.mjs +73 -0
- package/dist/history/index.d.ts +3 -0
- package/dist/history/index.mjs +3 -0
- package/dist/history/types.d.ts +48 -0
- package/dist/history/types.mjs +0 -0
- package/dist/hooks/usePlitziServiceContext.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +77 -65
- package/dist/navigation/index.d.ts +1 -1
- package/dist/navigation/index.mjs +2 -2
- package/dist/navigation/routes.d.ts +11 -1
- package/dist/navigation/routes.mjs +35 -30
- package/dist/network/graphql/builder/Mutations/Space/SpaceFixIssuesMutation.d.ts +14 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceFixIssuesMutation.mjs +16 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdatePluginMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdatePluginMutation.mjs +2 -2
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRunActionMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceRemoveFunctionsMutation.d.ts +3 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceRemoveFunctionsMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceSaveFunctionsMutation.d.ts +11 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceSaveFunctionsMutation.mjs +24 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceTryFunctionMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceTryFunctionMutation.mjs +15 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeVariableMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeVariableMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeSizeMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeSizeMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeVariableMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeVariableMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStartRuntimeMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStartRuntimeMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStopRuntimeMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStopRuntimeMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceAddVisitorMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceAddVisitorMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceRemoveVisitorMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceRemoveVisitorMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/index.d.ts +28 -0
- package/dist/network/graphql/builder/Mutations/index.mjs +108 -84
- package/dist/network/graphql/builder/Queries/Space/SpaceChangesQuery.d.ts +23 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceChangesQuery.mjs +49 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceFunctionsQuery.d.ts +6 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceFunctionsQuery.mjs +13 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.d.ts +17 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.mjs +22 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceRuntimeQuery.d.ts +6 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceRuntimeQuery.mjs +32 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceVisitorsQuery.d.ts +6 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceVisitorsQuery.mjs +16 -0
- package/dist/network/graphql/builder/Queries/index.d.ts +17 -3
- package/dist/network/graphql/builder/Queries/index.mjs +30 -22
- package/dist/network/graphql/sdk/Mutations/index.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/InitQuery.mjs +2 -91
- package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.mjs +2 -44
- package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.mjs +2 -55
- package/dist/network/graphql/sdk/Queries/index.d.ts +1 -5
- package/dist/network/index.mjs +7 -7
- package/dist/network/spaceEvents.d.ts +33 -3
- package/dist/network/spaceEvents.mjs +102 -89
- package/dist/realtime/client.d.ts +46 -0
- package/dist/realtime/client.mjs +192 -0
- package/dist/realtime/index.d.ts +6 -0
- package/dist/realtime/index.mjs +4 -0
- package/dist/realtime/presence.d.ts +38 -0
- package/dist/realtime/presence.mjs +70 -0
- package/dist/realtime/topics.d.ts +36 -0
- package/dist/realtime/topics.mjs +25 -0
- package/dist/schema/serverElements.d.ts +5 -0
- package/dist/schema/serverElements.mjs +15 -14
- package/dist/server/actions/useRealtimeSync.d.ts +9 -0
- package/dist/server/actions/useRealtimeSync.mjs +7 -0
- package/dist/state/index.d.ts +1 -0
- package/dist/state/index.mjs +3 -2
- package/dist/state/paintedState.d.ts +52 -0
- package/dist/state/paintedState.mjs +37 -0
- package/dist/state/runtimeStatePersist.d.ts +24 -0
- package/dist/state/runtimeStatePersist.mjs +113 -10
- package/dist/store/index.d.ts +45 -45
- package/dist/store/renderSettings.d.ts +6 -3
- package/dist/store/tracing/index.d.ts +1 -0
- package/dist/store/tracing/tracingCollector.d.ts +17 -1
- package/dist/store/tracing/tracingCollector.mjs +5 -0
- package/dist/style/index.d.ts +1 -0
- package/dist/style/index.mjs +3 -2
- package/dist/style/runtimeStyle.d.ts +29 -0
- package/dist/style/runtimeStyle.mjs +7 -0
- package/dist/style/styleConstants.d.ts +3 -2
- package/dist/style/styleConstants.mjs +2 -0
- package/dist/style/styleStates.d.ts +14 -1
- package/dist/style/styleStates.mjs +10 -7
- package/dist/theme/ThemeProvider.d.ts +1 -1
- package/dist/theme/ThemeProvider.mjs +35 -29
- package/dist/theme/themeCookie.mjs +11 -15
- package/dist/types/ActionTypes.d.ts +193 -0
- package/dist/types/AuthTypes.d.ts +11 -1
- package/dist/types/CommonTypes.d.ts +6 -0
- package/dist/types/FunctionTypes.d.ts +52 -0
- package/dist/types/FunctionTypes.mjs +0 -0
- package/dist/types/PluginTypes.d.ts +0 -1
- package/dist/types/RealtimeTypes.d.ts +94 -0
- package/dist/types/RealtimeTypes.mjs +0 -0
- package/dist/types/SchemaTypes.d.ts +54 -0
- package/dist/types/SchemaTypes.mjs +8 -0
- package/dist/types/ServerTypes.d.ts +310 -15
- package/dist/types/SpaceTypes.d.ts +53 -0
- package/dist/types/StateTypes.d.ts +6 -0
- package/dist/types/StoreTypes.d.ts +12 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.mjs +3 -2
- package/package.json +190 -21
- package/vite.config.ts +0 -12
- package/dist/network/graphql/builder/Queries/PluginsQuery.d.ts +0 -9
- package/dist/network/graphql/builder/Queries/PluginsQuery.mjs +0 -54
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ActionAccess } from '../types/ActionTypes';
|
|
2
|
+
/** Who is asking, as far as access is concerned: whether they are signed in, and what they may do. */
|
|
3
|
+
export type AccessCaller = {
|
|
4
|
+
permissions: readonly string[];
|
|
5
|
+
} | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Why a caller may not use something guarded by `access`, or `undefined` when they may.
|
|
8
|
+
*
|
|
9
|
+
* One reading of the access vocabulary for everything that speaks it — an action's trigger, a realtime channel — so
|
|
10
|
+
* `session` and `role` cannot come to mean two things in two places.
|
|
11
|
+
*/
|
|
12
|
+
export declare const accessRefusal: (access: ActionAccess | undefined, caller: AccessCaller) => "unauthenticated" | "forbidden" | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/actions/access.ts
|
|
2
|
+
var e = (e, t) => {
|
|
3
|
+
if (!e) return "forbidden";
|
|
4
|
+
if (e.mode !== "public") {
|
|
5
|
+
if (!t) return "unauthenticated";
|
|
6
|
+
if (e.mode === "role") {
|
|
7
|
+
let n = new Set(t.permissions);
|
|
8
|
+
return e.permissions.every((e) => n.has(e)) ? void 0 : "forbidden";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { e as accessRefusal };
|
package/dist/actions/cron.d.ts
CHANGED
|
@@ -10,25 +10,34 @@ type WallClock = {
|
|
|
10
10
|
month: number;
|
|
11
11
|
weekday: number;
|
|
12
12
|
};
|
|
13
|
+
export declare const zonedClock: (at: Date, timeZone: string) => WallClock | undefined;
|
|
14
|
+
export declare const cronMatches: (expression: string, at: Date, timeZone?: string) => boolean;
|
|
13
15
|
/**
|
|
14
|
-
* The
|
|
16
|
+
* The first minute at or after `from` that this expression fires on, or undefined when it never does.
|
|
17
|
+
*
|
|
18
|
+
* **This is what a schedule stores**, and why it is here rather than in a scheduler: a due time written into a row
|
|
19
|
+
* is a decision made once, by whoever wrote it, and every replica afterwards reads the same instant instead of each
|
|
20
|
+
* asking its own clock whether the moment has come. Nodes in different countries then disagree about what time it
|
|
21
|
+
* is — which they will — without ever disagreeing about which fires have happened.
|
|
15
22
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
23
|
+
* Inclusive of `from`, so a caller that wants the one strictly after an instant asks from the minute after it. The
|
|
24
|
+
* search steps by whole minutes, skipping a day at a time when the date cannot match and an hour at a time when the
|
|
25
|
+
* hour cannot — a yearly expression costs a few hundred comparisons rather than half a million.
|
|
19
26
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
27
|
+
* DST is the reason the skips are computed from the WALL clock and then re-read rather than added as fixed offsets:
|
|
28
|
+
* jumping "to midnight" lands an hour early on the night a zone falls back, which costs one more comparison, and an
|
|
29
|
+
* hour late on the night it springs forward — into minutes that did not exist locally, so there was nothing there
|
|
30
|
+
* to miss.
|
|
22
31
|
*/
|
|
23
|
-
export declare const
|
|
32
|
+
export declare const cronNextFire: (expression: string, from: Date, timeZone?: string) => Date | undefined;
|
|
24
33
|
/**
|
|
25
|
-
*
|
|
34
|
+
* How many times an expression would have fired in `(after, until]`.
|
|
26
35
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
36
|
+
* What an operator is owed after an outage: the run that is about to happen is one fire, and this is the number of
|
|
37
|
+
* others that went by while nothing was there to take them. Capped, because the answer's purpose is to be shown to
|
|
38
|
+
* somebody — a minutely schedule down for a week is "at least `limit`", not a number worth spending a second on.
|
|
30
39
|
*/
|
|
31
|
-
export declare const
|
|
40
|
+
export declare const cronFiresBetween: (expression: string, after: Date, until: Date, timeZone?: string, limit?: number) => number;
|
|
32
41
|
/** Whether `Intl` knows this zone. The validator asks so an author hears about a typo in the editor. */
|
|
33
42
|
export declare const isKnownTimeZone: (timeZone: string) => boolean;
|
|
34
43
|
export {};
|
package/dist/actions/cron.mjs
CHANGED
|
@@ -37,17 +37,23 @@ var e = [
|
|
|
37
37
|
day: e.getUTCDate(),
|
|
38
38
|
month: e.getUTCMonth() + 1,
|
|
39
39
|
weekday: e.getUTCDay()
|
|
40
|
-
}), a = (e
|
|
40
|
+
}), a = (e) => {
|
|
41
|
+
let t;
|
|
41
42
|
try {
|
|
42
|
-
|
|
43
|
-
timeZone:
|
|
43
|
+
t = new Intl.DateTimeFormat("en-US", {
|
|
44
|
+
timeZone: e,
|
|
44
45
|
hourCycle: "h23",
|
|
45
46
|
month: "numeric",
|
|
46
47
|
day: "numeric",
|
|
47
48
|
hour: "numeric",
|
|
48
49
|
minute: "numeric",
|
|
49
50
|
weekday: "short"
|
|
50
|
-
})
|
|
51
|
+
});
|
|
52
|
+
} catch {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
return (e) => {
|
|
56
|
+
let n = t.formatToParts(e), i = (e) => n.find((t) => t.type === e)?.value ?? "", a = r.indexOf(i("weekday")), o = {
|
|
51
57
|
minute: Number(i("minute")),
|
|
52
58
|
hour: Number(i("hour")),
|
|
53
59
|
day: Number(i("day")),
|
|
@@ -55,18 +61,43 @@ var e = [
|
|
|
55
61
|
weekday: a
|
|
56
62
|
};
|
|
57
63
|
return a >= 0 && Object.values(o).every(Number.isFinite) ? o : void 0;
|
|
58
|
-
}
|
|
59
|
-
|
|
64
|
+
};
|
|
65
|
+
}, o = (e, t) => a(t)?.(e), s = ([, , e, t, n], r) => {
|
|
66
|
+
if (!t.has(r.month)) return !1;
|
|
67
|
+
let i = e.size !== 31, a = n.size !== 7, o = e.has(r.day), s = n.has(r.weekday);
|
|
68
|
+
return i && a ? o || s : o && s;
|
|
69
|
+
}, c = (e, t) => {
|
|
70
|
+
let [n, r] = e;
|
|
71
|
+
return n.has(t.minute) && r.has(t.hour) && s(e, t);
|
|
72
|
+
}, l = (e) => e ? a(e) : i, u = (e, t, r) => {
|
|
73
|
+
let i = n(e), a = i ? l(r)?.(t) : void 0;
|
|
74
|
+
return i !== void 0 && a !== void 0 && c(i, a);
|
|
75
|
+
}, d = 6e4, f = 2108160 * d, p = (e, t, r) => {
|
|
76
|
+
let i = n(e), a = i ? l(r) : void 0;
|
|
77
|
+
if (!i || !a) return;
|
|
78
|
+
let o = Math.ceil(t.getTime() / d) * d, c = o + f, [u, p] = i;
|
|
79
|
+
for (let e = o; e <= c;) {
|
|
80
|
+
let t = new Date(e), n = a(t);
|
|
81
|
+
if (!n) return;
|
|
82
|
+
if (!s(i, n)) {
|
|
83
|
+
e += (1440 - n.hour * 60 - n.minute) * d;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (!p.has(n.hour)) {
|
|
87
|
+
e += (60 - n.minute) * d;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (u.has(n.minute)) return t;
|
|
91
|
+
e += d;
|
|
92
|
+
}
|
|
93
|
+
}, m = (e, t, n, r, i = 1e3) => {
|
|
94
|
+
let a = 0, o = new Date(t.getTime() + d);
|
|
95
|
+
for (; a < i;) {
|
|
96
|
+
let t = p(e, o, r);
|
|
97
|
+
if (!t || t > n) return a;
|
|
98
|
+
a += 1, o = new Date(t.getTime() + d);
|
|
60
99
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (!o) return !1;
|
|
64
|
-
let s = r ? a(t, r) : i(t);
|
|
65
|
-
if (!s) return !1;
|
|
66
|
-
let [c, l, u, d, f] = o;
|
|
67
|
-
if (!c.has(s.minute) || !l.has(s.hour) || !d.has(s.month)) return !1;
|
|
68
|
-
let p = u.size !== 31, m = f.size !== 7, h = u.has(s.day), g = f.has(s.weekday);
|
|
69
|
-
return p && m ? h || g : h && g;
|
|
70
|
-
}, s = (e) => a(/* @__PURE__ */ new Date(), e) !== void 0;
|
|
100
|
+
return a;
|
|
101
|
+
}, h = (e) => o(/* @__PURE__ */ new Date(), e) !== void 0;
|
|
71
102
|
//#endregion
|
|
72
|
-
export {
|
|
103
|
+
export { m as cronFiresBetween, u as cronMatches, p as cronNextFire, h as isKnownTimeZone, n as parseCron, o as zonedClock };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a space's functions answer HTTP: `GET /feed/:id` declared, `GET /api/feed/42` served. The path is
|
|
3
|
+
* the functions' and never a page's — the page server and the page linter both read it from here.
|
|
4
|
+
*/
|
|
5
|
+
export declare const FUNCTION_ROUTES_PREFIX = "/api";
|
|
6
|
+
/** Whether a page at `path` would sit where the space's functions answer. */
|
|
7
|
+
export declare const isFunctionRoutePath: (path: string) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether a path is one of a space's functions files: relative, inside `functions/`, a `.ts`, `.js`, `.mjs` or `.json`.
|
|
10
|
+
* The one rule for what a source is — the platform's build refuses anything else, and every reader of a working copy
|
|
11
|
+
* reads exactly this.
|
|
12
|
+
*/
|
|
13
|
+
export declare const isFunctionsSourcePath: (path: string) => boolean;
|
|
14
|
+
/** How a reader reaches a directory, whatever it runs on: Node's `fs`, a test's map. */
|
|
15
|
+
export type FunctionsSourceReader = {
|
|
16
|
+
list: (dir: string) => Promise<{
|
|
17
|
+
name: string;
|
|
18
|
+
directory: boolean;
|
|
19
|
+
}[]>;
|
|
20
|
+
read: (file: string) => Promise<string>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A space's functions as a directory holds them — every source file under `root`, by its path there (`lib/feed.ts`),
|
|
24
|
+
* `node_modules` and dotted folders skipped. What a project's working copy is read as, by the CLI and by a server
|
|
25
|
+
* loading its own; a directory that is not there reads as none.
|
|
26
|
+
*/
|
|
27
|
+
export declare const readFunctionsSource: (root: string, reader: FunctionsSourceReader) => Promise<Record<string, string>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/actions/functions.ts
|
|
2
|
+
var e = "/api", t = (e) => e === "/api" || e.startsWith("/api/"), n = (e) => /^[A-Za-z0-9_][A-Za-z0-9_./-]*\.(ts|js|mjs|json)$/.test(e) && !e.split("/").some((e) => e === ".." || e === "." || e === ""), r = async (e, t) => {
|
|
3
|
+
let r = {}, i = async (a) => {
|
|
4
|
+
let o;
|
|
5
|
+
try {
|
|
6
|
+
o = await t.list(a ? `${e}/${a}` : e);
|
|
7
|
+
} catch {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
for (let s of o) {
|
|
11
|
+
let o = a ? `${a}/${s.name}` : s.name;
|
|
12
|
+
s.directory ? s.name !== "node_modules" && !s.name.startsWith(".") && await i(o) : n(o) && (r[o] = await t.read(`${e}/${o}`));
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
return await i(""), r;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { e as FUNCTION_ROUTES_PREFIX, t as isFunctionRoutePath, n as isFunctionsSourcePath, r as readFunctionsSource };
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { accessRefusal } from './access';
|
|
2
|
+
export { cronFiresBetween, cronMatches, cronNextFire, isKnownTimeZone, parseCron, zonedClock } from './cron';
|
|
2
3
|
export { FAILURE_HANDLER_TASK } from './failureHandler';
|
|
4
|
+
export { FUNCTION_ROUTES_PREFIX, isFunctionRoutePath, isFunctionsSourcePath, readFunctionsSource } from './functions';
|
|
3
5
|
export { triggerAccess, triggerCacheMs, triggerHasStaleVerify, triggerInput, triggerVerify } from './triggerParams';
|
|
4
6
|
export { actionName, actionTriggers, isActionEnabled } from './triggers';
|
|
5
7
|
export { validateActionDocument } from './validateDocument';
|
|
6
8
|
export { isSingleEmailAddress, readSmtpCredential, SMTP_CREDENTIAL_KEYS } from './smtp';
|
|
9
|
+
export type { AccessCaller } from './access';
|
|
10
|
+
export type { FunctionsSourceReader } from './functions';
|
|
7
11
|
export type { CronExpression } from './cron';
|
|
8
12
|
export type { SmtpCredentialProblem, SmtpCredentialReading, SmtpSecurity, SmtpSettings } from './smtp';
|
|
9
13
|
export type { ActionDocumentIssue, ActionDocumentReport } from './validateDocument';
|
package/dist/actions/index.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { accessRefusal as e } from "./access.mjs";
|
|
2
|
+
import { cronFiresBetween as t, cronMatches as n, cronNextFire as r, isKnownTimeZone as i, parseCron as a, zonedClock as o } from "./cron.mjs";
|
|
3
|
+
import { FAILURE_HANDLER_TASK as s } from "./failureHandler.mjs";
|
|
4
|
+
import { FUNCTION_ROUTES_PREFIX as c, isFunctionRoutePath as l, isFunctionsSourcePath as u, readFunctionsSource as d } from "./functions.mjs";
|
|
5
|
+
import { triggerAccess as f, triggerCacheMs as p, triggerHasStaleVerify as m, triggerInput as h, triggerVerify as g } from "./triggerParams.mjs";
|
|
6
|
+
import { actionName as _, actionTriggers as v, isActionEnabled as y } from "./triggers.mjs";
|
|
7
|
+
import { validateActionDocument as b } from "./validateDocument.mjs";
|
|
8
|
+
import { SMTP_CREDENTIAL_KEYS as x, isSingleEmailAddress as S, readSmtpCredential as C } from "./smtp.mjs";
|
|
9
|
+
export { s as FAILURE_HANDLER_TASK, c as FUNCTION_ROUTES_PREFIX, x as SMTP_CREDENTIAL_KEYS, e as accessRefusal, _ as actionName, v as actionTriggers, t as cronFiresBetween, n as cronMatches, r as cronNextFire, y as isActionEnabled, l as isFunctionRoutePath, u as isFunctionsSourcePath, i as isKnownTimeZone, S as isSingleEmailAddress, a as parseCron, d as readFunctionsSource, C as readSmtpCredential, f as triggerAccess, p as triggerCacheMs, m as triggerHasStaleVerify, h as triggerInput, g as triggerVerify, b as validateActionDocument, o as zonedClock };
|
|
@@ -25,5 +25,9 @@ export declare const isActionEnabled: (document: ActionDocument) => boolean;
|
|
|
25
25
|
*
|
|
26
26
|
* Falls back to whatever the document already carries, so a document written before this — or by a caller that
|
|
27
27
|
* names it directly, like the authoring API — keeps the name it was given.
|
|
28
|
+
*
|
|
29
|
+
* A title that only repeats the trigger's kind is not a name: it is the default a node gets before anybody names
|
|
30
|
+
* it. Read as one, every page-rendered action in a workspace was called "render" and every clock "schedule" — a list
|
|
31
|
+
* of runs nobody could tell apart — while the document's own name sat unused beside it.
|
|
28
32
|
*/
|
|
29
33
|
export declare const actionName: (document: ActionDocument) => string;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
//#region src/actions/triggers.ts
|
|
2
|
-
var e = (e) => Object.values(e.nodes).filter((e) => e.type === "trigger"), t = (t) => e(t).some((e) => e.enabled), n = (t) => e(t).find((e) =>
|
|
2
|
+
var e = (e) => Object.values(e.nodes).filter((e) => e.type === "trigger"), t = (t) => e(t).some((e) => e.enabled), n = (t) => e(t).find((e) => {
|
|
3
|
+
let t = e.title.trim();
|
|
4
|
+
return t !== "" && t !== e.action;
|
|
5
|
+
})?.title.trim() ?? t.name;
|
|
3
6
|
//#endregion
|
|
4
7
|
export { n as actionName, e as actionTriggers, t as isActionEnabled };
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { createAuthFailureLink } from './authFailureLink';
|
|
2
2
|
export { authFailureFromResponse, onAuthFailure, reportAuthFailure, sameRegistrableDomain } from './failureChannel';
|
|
3
|
+
export { checkVisitorRoles, visitorAccess, VISITOR_NAME } from './visitorRoles';
|
|
3
4
|
export type { AuthFailureListener, AuthFailureSignal } from './failureChannel';
|
|
5
|
+
export type { VisitorRoles } from './visitorRoles';
|
package/dist/auth/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { authFailureFromResponse as e, onAuthFailure as t, reportAuthFailure as n, sameRegistrableDomain as r } from "./failureChannel.mjs";
|
|
2
2
|
import { createAuthFailureLink as i } from "./authFailureLink.mjs";
|
|
3
|
-
|
|
3
|
+
import { VISITOR_NAME as a, checkVisitorRoles as o, visitorAccess as s } from "./visitorRoles.mjs";
|
|
4
|
+
export { a as VISITOR_NAME, e as authFailureFromResponse, o as checkVisitorRoles, i as createAuthFailureLink, t as onAuthFailure, n as reportAuthFailure, r as sameRegistrableDomain, s as visitorAccess };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A space's visitor roles (`settings.visitorRoles`): each role a signed-in visitor may hold there, with the permissions
|
|
3
|
+
* it gives — what an action's `access: 'role'` and a page's `can()` are answered from.
|
|
4
|
+
*
|
|
5
|
+
* One reading of them for everyone who handles them: authoring refuses a space that writes them wrong, the builder's
|
|
6
|
+
* save refuses the same, and the server that resolves a visitor never reads a malformed map as a grant.
|
|
7
|
+
*/
|
|
8
|
+
export type VisitorRoles = Record<string, string[]>;
|
|
9
|
+
/** A role or a permission: a name a person reads in the builder and an action names in its access rule. */
|
|
10
|
+
export declare const VISITOR_NAME: RegExp;
|
|
11
|
+
/** The roles as declared, or what is wrong with them — said so it can be fixed from the message alone. */
|
|
12
|
+
export declare const checkVisitorRoles: (value: unknown) => {
|
|
13
|
+
ok: true;
|
|
14
|
+
roles: VisitorRoles;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
problem: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* What a visitor holding `held` may do in a space that declares `declared`: the roles the space still declares, and
|
|
21
|
+
* every permission they give. A role the space no longer declares gives nothing — a grant outlives an edit of the
|
|
22
|
+
* roles, and must not outlive what it meant. Malformed roles give nothing at all.
|
|
23
|
+
*/
|
|
24
|
+
export declare const visitorAccess: (declared: unknown, held: readonly string[]) => {
|
|
25
|
+
roles: string[];
|
|
26
|
+
permissions: string[];
|
|
27
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region src/auth/visitorRoles.ts
|
|
2
|
+
var e = /^[A-Za-z][\w-]{0,63}$/, t = "`visitorRoles: { author: [\"postPublish\"], editor: [\"postPublish\", \"postEdit\"] }`", n = (n) => {
|
|
3
|
+
if (typeof n != "object" || !n || Array.isArray(n)) return {
|
|
4
|
+
ok: !1,
|
|
5
|
+
problem: `\`settings.visitorRoles\` is ${JSON.stringify(n)}. Write each role with its permissions: ${t}.`
|
|
6
|
+
};
|
|
7
|
+
let r = {};
|
|
8
|
+
for (let [i, a] of Object.entries(n)) {
|
|
9
|
+
if (!e.test(i)) return {
|
|
10
|
+
ok: !1,
|
|
11
|
+
problem: `\`settings.visitorRoles\` has the role "${i}". A role is a name — a letter, then letters, digits, \`-\` or \`_\` — like "author".`
|
|
12
|
+
};
|
|
13
|
+
if (!Array.isArray(a) || a.length === 0) return {
|
|
14
|
+
ok: !1,
|
|
15
|
+
problem: `\`settings.visitorRoles.${i}\` is ${JSON.stringify(a)}. A role is the permissions it gives, as a list of names: ${t}.`
|
|
16
|
+
};
|
|
17
|
+
let n = /* @__PURE__ */ new Set();
|
|
18
|
+
for (let t of a) {
|
|
19
|
+
if (typeof t != "string" || !e.test(t)) return {
|
|
20
|
+
ok: !1,
|
|
21
|
+
problem: `\`settings.visitorRoles.${i}\` has ${JSON.stringify(t)}, which is not a permission name. Name it the way an action's \`access: 'role'\` asks for it, like "postPublish".`
|
|
22
|
+
};
|
|
23
|
+
if (n.has(t)) return {
|
|
24
|
+
ok: !1,
|
|
25
|
+
problem: `\`settings.visitorRoles.${i}\` names "${t}" twice.`
|
|
26
|
+
};
|
|
27
|
+
n.add(t);
|
|
28
|
+
}
|
|
29
|
+
r[i] = [...n];
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
ok: !0,
|
|
33
|
+
roles: r
|
|
34
|
+
};
|
|
35
|
+
}, r = (e, t) => {
|
|
36
|
+
let r = e === void 0 ? void 0 : n(e);
|
|
37
|
+
if (!r?.ok) return {
|
|
38
|
+
roles: [],
|
|
39
|
+
permissions: []
|
|
40
|
+
};
|
|
41
|
+
let i = [...new Set(t)].filter((e) => Object.hasOwn(r.roles, e));
|
|
42
|
+
return {
|
|
43
|
+
roles: i,
|
|
44
|
+
permissions: [...new Set(i.flatMap((e) => r.roles[e]))]
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { e as VISITOR_NAME, n as checkVisitorRoles, r as visitorAccess };
|
|
@@ -6,6 +6,7 @@ var e = {
|
|
|
6
6
|
boolean: "boolean",
|
|
7
7
|
number: "text",
|
|
8
8
|
scalar: "text",
|
|
9
|
+
json: "codemirror-json",
|
|
9
10
|
elementIds: "elements"
|
|
10
11
|
}, t = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[-_\s]+/).map((e) => `${e.charAt(0).toUpperCase()}${e.slice(1)}`).join(" "), n = (n, r) => ({
|
|
11
12
|
type: r.builderType ?? e[r.type],
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { InteractionCallback } from '../types/InteractionTypes';
|
|
2
|
+
import { PluginBuilder, PluginSchema } from '../types/PluginTypes';
|
|
3
|
+
import { ElementDefinition } from '../types/SchemaTypes';
|
|
1
4
|
/**
|
|
2
5
|
* How an element says what it can be authored with.
|
|
3
6
|
*
|
|
@@ -29,6 +32,35 @@ export interface ElementDeclarationData {
|
|
|
29
32
|
* reads it to resolve a binding that named the element alone.
|
|
30
33
|
*/
|
|
31
34
|
sourceType?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The triggers this type fires on top of the ones every element does (`onClick`, `onLoad`…), by action name.
|
|
37
|
+
*
|
|
38
|
+
* Declared here for the reason `sourceType` is: the component registers exactly these, and the authoring surface
|
|
39
|
+
* reads them to refuse a flow that starts on a trigger its element never fires — an `onSubmit` on the submit
|
|
40
|
+
* button rather than on the form is a flow that is written, saved and silently never runs.
|
|
41
|
+
*/
|
|
42
|
+
triggers?: Record<string, InteractionCallback>;
|
|
43
|
+
/**
|
|
44
|
+
* The callbacks this type runs on itself on top of the ones every element does (`setState`, `toggleState`) —
|
|
45
|
+
* their static half. The component adds what only a mounted element has: the function, a title naming its label,
|
|
46
|
+
* options drawn from its children. Read by the authoring surface to refuse a step aimed at an element that does not
|
|
47
|
+
* answer to it — an `openModal` sent to a plain container is a button that does nothing.
|
|
48
|
+
*/
|
|
49
|
+
callbacks?: Record<string, InteractionCallback>;
|
|
50
|
+
/**
|
|
51
|
+
* The type this one only works somewhere inside: it reads its state from that element's context, and anywhere
|
|
52
|
+
* else it throws on its first render. A dropdown's panel, a tab container's header and body.
|
|
53
|
+
*/
|
|
54
|
+
ancestorType?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The values an enumerated attribute takes — a heading's `subType`, a link's `mode` — by attribute name.
|
|
57
|
+
*
|
|
58
|
+
* A component's props say this in TypeScript, which is gone at run time; an author writing JavaScript, a document
|
|
59
|
+
* that arrived as JSON or a value that went through a cast reaches the element anyway, and `subType: 'h7'` renders an
|
|
60
|
+
* `<h7>`. Written with {@link valuesOf}, so the list cannot drift from the props it mirrors; read by the authoring
|
|
61
|
+
* surface to refuse a value outside it.
|
|
62
|
+
*/
|
|
63
|
+
attributeValues?: Record<string, readonly string[]>;
|
|
32
64
|
content?: {
|
|
33
65
|
attributes?: Record<string, unknown>;
|
|
34
66
|
definition?: {
|
|
@@ -36,6 +68,39 @@ export interface ElementDeclarationData {
|
|
|
36
68
|
};
|
|
37
69
|
};
|
|
38
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* A plugin's declaration: an element of somebody's own, declared the way the built-in ones declare themselves.
|
|
73
|
+
*
|
|
74
|
+
* On top of what {@link ElementDeclarationData} says of any element it carries the whole `content`, because for a
|
|
75
|
+
* plugin that is also what gets PUBLISHED — its build writes it into `plugin-manifest.json`, which the builder, the page
|
|
76
|
+
* server and the MCP server read before they load any code. Data only, so that build can read it without React.
|
|
77
|
+
*
|
|
78
|
+
* `A` is the attributes the element accepts: its component's props, minus what the runtime supplies.
|
|
79
|
+
* `const declaration = { … } satisfies PluginDeclaration<SeatPickerAttributes>` then refuses a default the component
|
|
80
|
+
* does not take.
|
|
81
|
+
*/
|
|
82
|
+
export interface PluginDeclaration<A extends object = Record<string, unknown>> extends Omit<ElementDeclarationData, 'content'> {
|
|
83
|
+
content: {
|
|
84
|
+
/** The element's starting attributes — its component's defaults, where the builder can show them. */
|
|
85
|
+
attributes: A;
|
|
86
|
+
definition: Omit<ElementDefinition, 'rootId' | 'parentId' | 'interactions' | 'runtime' | 'loadStrategy'> & {
|
|
87
|
+
/** What the element is for, in a sentence: the builder shows it, and an agent reads it to choose the element. */
|
|
88
|
+
description?: string;
|
|
89
|
+
};
|
|
90
|
+
builder: PluginBuilder;
|
|
91
|
+
/** How the builder's catalogue shows the element. Whether it is verified is the platform's to say, never its own. */
|
|
92
|
+
market: {
|
|
93
|
+
category: string;
|
|
94
|
+
owner: string;
|
|
95
|
+
license: string;
|
|
96
|
+
website: string;
|
|
97
|
+
backgroundColor: string;
|
|
98
|
+
icon: string;
|
|
99
|
+
};
|
|
100
|
+
defaultStyle: PluginSchema['defaultStyle'];
|
|
101
|
+
settings?: Record<string, string | number | boolean>;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
39
104
|
/**
|
|
40
105
|
* The attributes a declaration accepts, defaulting to "anything" for one that never said.
|
|
41
106
|
*
|
|
@@ -60,5 +125,14 @@ type AuthorableProps<Props, Injected extends keyof Props> = Omit<Props, 'ref' |
|
|
|
60
125
|
* "any value that is not null" everywhere else it could land.
|
|
61
126
|
*/
|
|
62
127
|
export type AuthorableAttributes<Props, Injected extends keyof Props = never> = keyof AuthorableProps<Props, Injected> extends never ? unknown : Partial<AuthorableProps<Props, Injected>>;
|
|
128
|
+
/**
|
|
129
|
+
* Every value of a string-literal union, as a list — and a compile error when the list leaves one out.
|
|
130
|
+
*
|
|
131
|
+
* `valuesOf<NonNullable<ButtonProps['subType']>>()(['button', 'submit', 'reset'])`. A value outside the union is
|
|
132
|
+
* refused by the parameter type; one the union has and the list does not makes the argument ask for `missing`.
|
|
133
|
+
*/
|
|
134
|
+
export declare const valuesOf: <T extends string>() => <const V extends readonly T[]>(values: V & ([Exclude<T, V[number]>] extends [never] ? unknown : {
|
|
135
|
+
readonly missing: Exclude<T, V[number]>;
|
|
136
|
+
})) => readonly string[];
|
|
63
137
|
export declare const elementDeclaration: <A>() => <const D extends ElementDeclarationData>(declaration: D) => D & ElementAttributesBrand<A>;
|
|
64
138
|
export {};
|
package/dist/authoring/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toBuilderParams as e, toInteractionCallback as t, toInteractionCallbacks as n } from "./builder.mjs";
|
|
2
|
-
import { elementDeclaration as r } from "./declare.mjs";
|
|
3
|
-
import { hiddenParams as
|
|
4
|
-
import { BUILTIN_ELEMENT_CALLBACKS as
|
|
5
|
-
import { spaceCallbacks as
|
|
6
|
-
export {
|
|
2
|
+
import { elementDeclaration as r, valuesOf as i } from "./declare.mjs";
|
|
3
|
+
import { hiddenParams as a, invalidParams as o, missingRequiredParams as s, reconcileParams as c } from "./paramSpec.mjs";
|
|
4
|
+
import { BUILTIN_ELEMENT_CALLBACKS as l, applyElementCallback as u, getElementCallback as d } from "./elementCallbacks.mjs";
|
|
5
|
+
import { spaceCallbacks as f } from "./spaceCallbacks.mjs";
|
|
6
|
+
export { l as BUILTIN_ELEMENT_CALLBACKS, u as applyElementCallback, r as elementDeclaration, d as getElementCallback, a as hiddenParams, o as invalidParams, s as missingRequiredParams, c as reconcileParams, f as spaceCallbacks, e as toBuilderParams, t as toInteractionCallback, n as toInteractionCallbacks, i as valuesOf };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InteractionParamType } from '../types';
|
|
2
|
-
export type BuiltinParamType = 'text' | 'textarea' | 'select' | 'boolean' | 'number' | 'scalar' | 'elementIds';
|
|
2
|
+
export type BuiltinParamType = 'text' | 'textarea' | 'select' | 'boolean' | 'number' | 'scalar' | 'json' | 'elementIds';
|
|
3
3
|
export interface BuiltinParam {
|
|
4
4
|
type: BuiltinParamType;
|
|
5
5
|
description: string;
|
|
@@ -14,6 +14,7 @@ var t = (e, t, n) => {
|
|
|
14
14
|
case "number": return typeof e == "number" || typeof e == "string" && r(e);
|
|
15
15
|
case "select": return typeof e == "string" && (!t.options || t.options.includes(e));
|
|
16
16
|
case "scalar": return typeof e == "string" || typeof e == "number" || typeof e == "boolean";
|
|
17
|
+
case "json": return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "object" && !!e;
|
|
17
18
|
case "text":
|
|
18
19
|
case "textarea": return typeof e == "string";
|
|
19
20
|
case "elementIds": return Array.isArray(e) && e.every((e) => typeof e == "string");
|
|
@@ -22,9 +22,9 @@ var e = { addNotification: {
|
|
|
22
22
|
"bottom-left"
|
|
23
23
|
]
|
|
24
24
|
},
|
|
25
|
-
|
|
25
|
+
appearance: {
|
|
26
26
|
type: "select",
|
|
27
|
-
description: "Visual style of the notification
|
|
27
|
+
description: "Visual style of the notification: success, danger, warning or info.",
|
|
28
28
|
default: "success",
|
|
29
29
|
options: [
|
|
30
30
|
"success",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The space's computed values, from its definitions and the global sources they read.
|
|
3
|
+
*
|
|
4
|
+
* In declaration order, each one seeing the values before it as `computed.<name>` — so `level` can be written over
|
|
5
|
+
* `xp` without repeating it. A value that reads one declared after it reads nothing; authoring refuses that.
|
|
6
|
+
*
|
|
7
|
+
* Given the `previous` evaluation, a value that comes out the same keeps the object it was, and so does the whole
|
|
8
|
+
* when none changed. They are all evaluated again whenever the state changes, and a list or a record evaluates to a new
|
|
9
|
+
* object every time: every element reading one — a star on each of a hundred and sixty library items reading the
|
|
10
|
+
* favourites — rendered again for the tool in hand changing, because what it read was no longer the same object.
|
|
11
|
+
*/
|
|
12
|
+
export declare const evaluateComputed: (definitions: Record<string, string>, globals: Record<string, unknown>, previous?: Record<string, unknown>) => Record<string, unknown>;
|
|
13
|
+
/**
|
|
14
|
+
* The sources as a flow step reads them: `state` as the store holds it this instant, and `computed` evaluated over it.
|
|
15
|
+
*
|
|
16
|
+
* `runtime.sources` carries both as the last render left them — they are copied there after React renders — so a step
|
|
17
|
+
* reading them right after an earlier step wrote the state could see the value from before the write, or not,
|
|
18
|
+
* depending on whether React had rendered in between. Read here, a step always sees every write made before it: the
|
|
19
|
+
* flow's own and anything else that happened while it waited.
|
|
20
|
+
*/
|
|
21
|
+
export declare const liveSources: (sources: Record<string, unknown>, state: unknown, definitions: unknown) => Record<string, unknown>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { processTwigValue as e } from "../helpers/twigWrapper/processTwig/processTwig.mjs";
|
|
2
|
+
import t from "@plitzi/plitzi-ui/utils/deepEqual";
|
|
3
|
+
//#region src/dataSource/computed.ts
|
|
4
|
+
var n = (n, r, i) => {
|
|
5
|
+
let a = {}, o = i !== void 0 && Object.keys(i).length === Object.keys(n).length;
|
|
6
|
+
for (let [s, c] of Object.entries(n)) {
|
|
7
|
+
let n = e(c, {
|
|
8
|
+
...r,
|
|
9
|
+
computed: { ...a }
|
|
10
|
+
}), l = i?.[s], u = i !== void 0 && Object.hasOwn(i, s) && (l === n || t(l, n));
|
|
11
|
+
a[s] = u ? l : n, o &&= u;
|
|
12
|
+
}
|
|
13
|
+
return o && i ? i : a;
|
|
14
|
+
}, r = (e) => typeof e == "object" && !!e, i = (e) => r(e) && Object.values(e).every((e) => typeof e == "string"), a = [
|
|
15
|
+
"variables",
|
|
16
|
+
"navigation",
|
|
17
|
+
"auth",
|
|
18
|
+
"host",
|
|
19
|
+
"theme"
|
|
20
|
+
], o = (e, t, n) => {
|
|
21
|
+
let a = r(t) ? t : {};
|
|
22
|
+
return i(n) ? {
|
|
23
|
+
...e,
|
|
24
|
+
state: a,
|
|
25
|
+
computed: c(n, e, a)
|
|
26
|
+
} : {
|
|
27
|
+
...e,
|
|
28
|
+
state: a
|
|
29
|
+
};
|
|
30
|
+
}, s, c = (e, t, r) => {
|
|
31
|
+
let i = a.map((e) => t[e]);
|
|
32
|
+
if (s?.definitions === e && s.state === r && s.globals.every((e, t) => e === i[t])) return s.computed;
|
|
33
|
+
let o = n(e, {
|
|
34
|
+
...Object.fromEntries(a.map((e, t) => [e, i[t]])),
|
|
35
|
+
state: r
|
|
36
|
+
}, s?.definitions === e ? s.computed : void 0);
|
|
37
|
+
return s = {
|
|
38
|
+
definitions: e,
|
|
39
|
+
state: r,
|
|
40
|
+
globals: i,
|
|
41
|
+
computed: o
|
|
42
|
+
}, o;
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { n as evaluateComputed, o as liveSources };
|