@plitzi/sdk-shared 0.37.9 → 0.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +601 -0
- package/dist/actions/index.d.ts +1 -1
- package/dist/actions/index.mjs +3 -3
- package/dist/actions/triggerParams.mjs +7 -6
- package/dist/actions/validateDocument.d.ts +3 -0
- package/dist/actions/validateDocument.mjs +89 -88
- package/dist/authoring/elementCallbacks.d.ts +65 -0
- package/dist/authoring/elementCallbacks.mjs +72 -8
- package/dist/authoring/index.mjs +3 -3
- package/dist/builder/contexts/BuilderContext.d.ts +18 -7
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.mjs +2 -2
- package/dist/connectors/validateManifest.d.ts +3 -0
- package/dist/connectors/validateManifest.mjs +77 -76
- package/dist/dataSource/computed.mjs +25 -29
- package/dist/dataSource/globalSources.d.ts +15 -0
- package/dist/dataSource/globalSources.mjs +13 -0
- package/dist/dataSource/index.d.ts +2 -0
- package/dist/dataSource/index.mjs +8 -7
- package/dist/devTools/utils/PlitziConsole.d.ts +9 -0
- package/dist/devTools/utils/PlitziConsole.mjs +27 -7
- package/dist/flags/flagsCookie.d.ts +26 -0
- package/dist/flags/flagsCookie.mjs +20 -0
- package/dist/flags/index.d.ts +3 -0
- package/dist/flags/index.mjs +4 -0
- package/dist/flags/resolveFlags.d.ts +60 -0
- package/dist/flags/resolveFlags.mjs +38 -0
- package/dist/flags/schemaFlag.d.ts +11 -0
- package/dist/flags/schemaFlag.mjs +9 -0
- package/dist/flags/useFlagResolution.d.ts +13 -0
- package/dist/flags/useFlagResolution.mjs +43 -0
- package/dist/helpers/eventTarget.d.ts +10 -0
- package/dist/helpers/eventTarget.mjs +4 -0
- package/dist/helpers/images.d.ts +18 -0
- package/dist/helpers/images.mjs +13 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.mjs +21 -18
- package/dist/helpers/interval.d.ts +18 -0
- package/dist/helpers/interval.mjs +7 -0
- package/dist/helpers/isRecord.d.ts +2 -0
- package/dist/helpers/isRecord.mjs +4 -0
- package/dist/helpers/scroll.d.ts +42 -0
- package/dist/helpers/scroll.mjs +30 -0
- package/dist/helpers/twigWrapper/TemplateCache/TemplateCache.mjs +1 -1
- package/dist/helpers/twigWrapper/filters/filters.mjs +38 -2
- package/dist/history/describe.mjs +3 -1
- package/dist/history/diff.d.ts +1 -1
- package/dist/history/diff.mjs +1 -0
- package/dist/history/types.d.ts +1 -1
- package/dist/hooks/index.mjs +5 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +90 -76
- package/dist/navigation/routes.mjs +6 -4
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddSnippetMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddSnippetMutation.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/Space/flags/SpacePublishFlagsMutation.d.ts +12 -0
- package/dist/network/graphql/builder/Mutations/Space/flags/SpacePublishFlagsMutation.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/Space/flags/SpaceRemoveFlagMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/flags/SpaceRemoveFlagMutation.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/Space/flags/SpaceSetFlagMutation.d.ts +3 -0
- package/dist/network/graphql/builder/Mutations/Space/flags/SpaceSetFlagMutation.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/index.d.ts +5 -1
- package/dist/network/graphql/builder/Mutations/index.mjs +122 -116
- package/dist/network/graphql/builder/Queries/InitQuery.d.ts +3 -1
- package/dist/network/graphql/builder/Queries/InitQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.d.ts +16 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/index.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/InitQuery.mjs +1 -1
- package/dist/network/index.mjs +8 -7
- package/dist/network/spaceEvents.d.ts +12 -6
- package/dist/network/spaceEvents.mjs +153 -154
- package/dist/realtime/client.mjs +123 -95
- package/dist/realtime/topics.mjs +18 -17
- package/dist/schema/anchor.d.ts +8 -0
- package/dist/schema/anchor.mjs +4 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.mjs +6 -4
- package/dist/schema/serverElements.d.ts +6 -2
- package/dist/schema/serverElements.mjs +17 -16
- package/dist/schema/snippet.d.ts +7 -0
- package/dist/schema/snippet.mjs +9 -0
- package/dist/schema/wire.d.ts +11 -0
- package/dist/schema/wire.mjs +27 -0
- package/dist/server/actions/useImagesSync.d.ts +9 -0
- package/dist/server/actions/useImagesSync.mjs +7 -0
- package/dist/server/rsc/refreshRsc.mjs +8 -8
- package/dist/source/snapshot.mjs +23 -22
- package/dist/state/paintedState.mjs +13 -12
- package/dist/state/runtimeStatePersist.mjs +50 -49
- package/dist/store/index.d.ts +45 -45
- package/dist/style/breakpoints.d.ts +11 -0
- package/dist/style/breakpoints.mjs +8 -0
- package/dist/style/displayModes.d.ts +5 -0
- package/dist/style/displayModes.mjs +8 -0
- package/dist/style/fontValidation.mjs +52 -51
- package/dist/style/fonts.d.ts +0 -12
- package/dist/style/fonts.mjs +11 -11
- package/dist/style/index.d.ts +4 -0
- package/dist/style/index.mjs +11 -7
- package/dist/style/layoutGrid.d.ts +30 -0
- package/dist/style/layoutGrid.mjs +33 -0
- package/dist/style/notifications.d.ts +52 -0
- package/dist/style/notifications.mjs +55 -0
- package/dist/style/snippetStyle.d.ts +23 -0
- package/dist/style/snippetStyle.mjs +32 -0
- package/dist/style/styleConstants.d.ts +7 -2
- package/dist/style/styleConstants.mjs +10 -0
- package/dist/style/styleStates.d.ts +11 -2
- package/dist/style/styleStates.mjs +12 -9
- package/dist/theme/ThemeProvider.mjs +20 -20
- package/dist/types/CommonTypes.d.ts +3 -0
- package/dist/types/DevToolsTypes.d.ts +29 -4
- package/dist/types/EventBridgeTypes.d.ts +2 -2
- package/dist/types/PluginTypes.d.ts +1 -1
- package/dist/types/ResourceTypes.d.ts +2 -2
- package/dist/types/SchemaTypes.d.ts +62 -3
- package/dist/types/ServerTypes.d.ts +47 -0
- package/dist/types/SnippetTypes.d.ts +28 -0
- package/dist/types/StoreTypes.d.ts +25 -0
- package/dist/types/StyleTypes.d.ts +2 -1
- package/dist/types/StyleTypes.mjs +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.mjs +2 -2
- package/dist/websockets/RTCodec.d.ts +1 -0
- package/dist/websockets/RTCodec.mjs +14 -12
- package/dist/websockets/index.mjs +2 -2
- package/package.json +115 -19
- package/tailwind.config.js +1 -6
- package/vite.config.ts +16 -4
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddTemplateMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddTemplateMutation.mjs +0 -4
- package/dist/types/TemplateTypes.d.ts +0 -20
- /package/dist/types/{TemplateTypes.mjs → SnippetTypes.mjs} +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { isRecord as e } from "../helpers/isRecord.mjs";
|
|
1
2
|
//#region src/actions/triggerParams.ts
|
|
2
|
-
var
|
|
3
|
+
var t = (e) => {
|
|
3
4
|
if (typeof e == "string" && e.trim() !== "") try {
|
|
4
5
|
return JSON.parse(e);
|
|
5
6
|
} catch {
|
|
6
7
|
return;
|
|
7
8
|
}
|
|
8
|
-
},
|
|
9
|
+
}, n = (e) => {
|
|
9
10
|
let { access: t } = e;
|
|
10
11
|
if (t === "public" || t === "session") return { mode: t };
|
|
11
12
|
if (t === "role") return {
|
|
@@ -13,8 +14,8 @@ var e = (e) => {
|
|
|
13
14
|
permissions: (e.permissions ?? "").split(",").map((e) => e.trim()).filter(Boolean)
|
|
14
15
|
};
|
|
15
16
|
}, r = (n) => {
|
|
16
|
-
let r =
|
|
17
|
-
return
|
|
17
|
+
let r = t(n.input);
|
|
18
|
+
return e(r) ? r : {};
|
|
18
19
|
}, i = (e) => {
|
|
19
20
|
let t = e.signatureCredential?.trim();
|
|
20
21
|
if (!t) return;
|
|
@@ -30,8 +31,8 @@ var e = (e) => {
|
|
|
30
31
|
};
|
|
31
32
|
}, a = (n) => {
|
|
32
33
|
if (n.signatureCredential?.trim()) return !1;
|
|
33
|
-
let r =
|
|
34
|
-
return
|
|
34
|
+
let r = t(n.verify);
|
|
35
|
+
return e(r) && typeof r.credential == "string" && r.credential.trim() !== "";
|
|
35
36
|
}, o = (e) => {
|
|
36
37
|
let t = Number.parseFloat(e.cacheSeconds ?? "");
|
|
37
38
|
return Number.isFinite(t) && t > 0 ? Math.round(t * 1e3) : 0;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ActionDocument } from '../types';
|
|
1
2
|
/**
|
|
2
3
|
* The one server-action validator.
|
|
3
4
|
*
|
|
@@ -21,3 +22,5 @@ export type ActionDocumentReport = {
|
|
|
21
22
|
warnings: ActionDocumentIssue[];
|
|
22
23
|
};
|
|
23
24
|
export declare const validateActionDocument: (document: unknown) => ActionDocumentReport;
|
|
25
|
+
/** Whether a value read from outside — a deployment's store, a request — is an action document a server can run. */
|
|
26
|
+
export declare const isActionDocument: (document: unknown) => document is ActionDocument;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { isKnownTimeZone as e, parseCron as t } from "./cron.mjs";
|
|
2
2
|
import { FAILURE_HANDLER_TASK as n } from "./failureHandler.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { isRecord as r } from "../helpers/isRecord.mjs";
|
|
4
|
+
import { triggerAccess as i, triggerHasStaleVerify as a, triggerVerify as o } from "./triggerParams.mjs";
|
|
4
5
|
//#region src/actions/validateDocument.ts
|
|
5
|
-
var
|
|
6
|
+
var s = [
|
|
6
7
|
"text",
|
|
7
8
|
"number",
|
|
8
9
|
"boolean",
|
|
9
10
|
"date",
|
|
10
11
|
"json",
|
|
11
12
|
"file"
|
|
12
|
-
],
|
|
13
|
+
], c = [
|
|
13
14
|
"public",
|
|
14
15
|
"session",
|
|
15
16
|
"role"
|
|
16
|
-
],
|
|
17
|
+
], l = [
|
|
17
18
|
"call",
|
|
18
19
|
"webhook",
|
|
19
20
|
"schedule",
|
|
20
21
|
"render",
|
|
21
22
|
"custom"
|
|
22
|
-
],
|
|
23
|
+
], u = ["sha256", "sha1"], d = /* @__PURE__ */ new Set([
|
|
23
24
|
"input",
|
|
24
25
|
"user",
|
|
25
26
|
"spaceId",
|
|
@@ -28,208 +29,208 @@ var o = [
|
|
|
28
29
|
"runId",
|
|
29
30
|
"now",
|
|
30
31
|
"failure"
|
|
31
|
-
]),
|
|
32
|
+
]), f = /^[a-z][a-zA-Z0-9]*\.[a-z][a-zA-Z0-9]*$/, p = (e) => typeof e == "string" && e.trim() !== "", m = (e) => {
|
|
32
33
|
try {
|
|
33
34
|
let t = JSON.parse(e);
|
|
34
|
-
return
|
|
35
|
+
return r(t) ? t : void 0;
|
|
35
36
|
} catch {
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
39
|
}, h = (e, t, n) => {
|
|
39
40
|
if (e !== void 0) {
|
|
40
|
-
if (!
|
|
41
|
+
if (!r(e)) {
|
|
41
42
|
n.push({
|
|
42
43
|
path: t,
|
|
43
44
|
message: "must be an object of field definitions"
|
|
44
45
|
});
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
47
|
-
Object.entries(e).forEach(([e,
|
|
48
|
-
if (!
|
|
48
|
+
Object.entries(e).forEach(([e, i]) => {
|
|
49
|
+
if (!r(i) || !p(i.type)) {
|
|
49
50
|
n.push({
|
|
50
51
|
path: `${t}.${e}`,
|
|
51
52
|
message: "must declare a type"
|
|
52
53
|
});
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
s.includes(i.type) || n.push({
|
|
56
57
|
path: `${t}.${e}.type`,
|
|
57
|
-
message: `unknown field type "${
|
|
58
|
-
hint: `one of ${
|
|
58
|
+
message: `unknown field type "${i.type}"`,
|
|
59
|
+
hint: `one of ${s.join(", ")}`
|
|
59
60
|
});
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
|
-
}, g = (n,
|
|
63
|
-
let g = `nodes.${n}`, _ =
|
|
64
|
-
if (!p(_) || !
|
|
65
|
-
|
|
63
|
+
}, g = (n, s, d, f) => {
|
|
64
|
+
let g = `nodes.${n}`, _ = s.action;
|
|
65
|
+
if (!p(_) || !l.includes(_)) {
|
|
66
|
+
d.push({
|
|
66
67
|
path: `${g}.action`,
|
|
67
68
|
message: `"${String(_)}" is not a way an action can be started`,
|
|
68
|
-
hint: `one of ${
|
|
69
|
+
hint: `one of ${l.join(", ")}`
|
|
69
70
|
});
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
72
|
-
let v =
|
|
73
|
+
let v = r(s.params) ? s.params : {};
|
|
73
74
|
if (p(v.input)) {
|
|
74
75
|
let e = m(v.input);
|
|
75
|
-
e === void 0 ?
|
|
76
|
+
e === void 0 ? d.push({
|
|
76
77
|
path: `${g}.params.input`,
|
|
77
78
|
message: "is not valid JSON"
|
|
78
|
-
}) : h(e, `${g}.params.input`,
|
|
79
|
+
}) : h(e, `${g}.params.input`, d);
|
|
79
80
|
}
|
|
80
81
|
if (_ !== "schedule") {
|
|
81
|
-
if (!p(v.access) || !
|
|
82
|
+
if (!p(v.access) || !c.includes(v.access)) d.push({
|
|
82
83
|
path: `${g}.params.access`,
|
|
83
84
|
message: "must say who may start a run this way",
|
|
84
|
-
hint: `one of ${
|
|
85
|
+
hint: `one of ${c.join(", ")}`
|
|
85
86
|
});
|
|
86
87
|
else if (v.access === "role") {
|
|
87
|
-
let e =
|
|
88
|
-
e?.mode === "role" && e.permissions.length === 0 &&
|
|
88
|
+
let e = i(v);
|
|
89
|
+
e?.mode === "role" && e.permissions.length === 0 && d.push({
|
|
89
90
|
path: `${g}.params.permissions`,
|
|
90
91
|
message: "role access must name at least one permission"
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
|
-
if (_ === "schedule" && (p(v.cron) ? t(v.cron) ||
|
|
95
|
+
if (_ === "schedule" && (p(v.cron) ? t(v.cron) || d.push({
|
|
95
96
|
path: `${g}.params.cron`,
|
|
96
97
|
message: `"${v.cron}" is not an expression this server can read, so it would never fire`,
|
|
97
98
|
hint: "five fields — minute hour day-of-month month day-of-week — with *, lists, ranges and steps"
|
|
98
|
-
}) :
|
|
99
|
+
}) : d.push({
|
|
99
100
|
path: `${g}.params.cron`,
|
|
100
101
|
message: "a scheduled trigger needs a cron expression"
|
|
101
|
-
}), p(v.timezone) && !e(v.timezone) &&
|
|
102
|
+
}), p(v.timezone) && !e(v.timezone) && d.push({
|
|
102
103
|
path: `${g}.params.timezone`,
|
|
103
104
|
message: `"${v.timezone}" is not a time zone this server knows, so the schedule would never fire`,
|
|
104
105
|
hint: "an IANA name like America/Santiago or Europe/Madrid — leave it empty for UTC"
|
|
105
106
|
})), p(v.cacheSeconds)) {
|
|
106
107
|
let e = Number.parseFloat(v.cacheSeconds);
|
|
107
|
-
!Number.isFinite(e) || e < 0 ?
|
|
108
|
+
!Number.isFinite(e) || e < 0 ? d.push({
|
|
108
109
|
path: `${g}.params.cacheSeconds`,
|
|
109
110
|
message: "must be a number of seconds, or left empty"
|
|
110
|
-
}) : _ !== "render" &&
|
|
111
|
+
}) : _ !== "render" && f.push({
|
|
111
112
|
path: `${g}.params.cacheSeconds`,
|
|
112
113
|
message: `a "${_}" trigger is never answered from a cache`,
|
|
113
114
|
hint: "reuse only applies to a render, where the same page is built for one visitor after another"
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
|
-
_ === "custom" && !p(v.name) &&
|
|
117
|
+
_ === "custom" && !p(v.name) && d.push({
|
|
117
118
|
path: `${g}.params.name`,
|
|
118
119
|
message: "a custom trigger needs a name to be mounted under"
|
|
119
|
-
}), _ === "webhook" && (
|
|
120
|
+
}), _ === "webhook" && (a(v) && d.push({
|
|
120
121
|
path: `${g}.params.signatureCredential`,
|
|
121
122
|
message: "this signature check is in a format nothing reads any more, so the webhook is unverified",
|
|
122
123
|
hint: "name the credential holding the signing secret in \"Signing secret\", and its header beside it"
|
|
123
|
-
}),
|
|
124
|
+
}), o(v) || f.push({
|
|
124
125
|
path: `${g}.params.signatureCredential`,
|
|
125
126
|
message: "this webhook accepts unsigned requests",
|
|
126
127
|
hint: "name the credential holding the signing secret, and only the sender you expect can start a run"
|
|
127
|
-
}), p(v.signatureAlgorithm) && !
|
|
128
|
+
}), p(v.signatureAlgorithm) && !u.includes(v.signatureAlgorithm) && f.push({
|
|
128
129
|
path: `${g}.params.signatureAlgorithm`,
|
|
129
130
|
message: `"${v.signatureAlgorithm}" is not an algorithm this server signs with, so sha256 is used`,
|
|
130
|
-
hint: `one of ${
|
|
131
|
-
}), p(v.signatureToleranceSeconds) && !p(v.signatureTimestampHeader) &&
|
|
131
|
+
hint: `one of ${u.join(", ")}`
|
|
132
|
+
}), p(v.signatureToleranceSeconds) && !p(v.signatureTimestampHeader) && f.push({
|
|
132
133
|
path: `${g}.params.signatureToleranceSeconds`,
|
|
133
134
|
message: "a tolerance with no timestamp header expires nothing",
|
|
134
135
|
hint: "name the header the sender puts the signing time in, or drop the tolerance"
|
|
135
|
-
})), _ === "call" && v.access === "public" &&
|
|
136
|
+
})), _ === "call" && v.access === "public" && f.push({
|
|
136
137
|
path: `${g}.params.access`,
|
|
137
138
|
message: "anyone can run this action, including signed-out visitors",
|
|
138
139
|
hint: "use session access unless the page needs it before anyone signs in"
|
|
139
140
|
});
|
|
140
|
-
}, _ = (e, t,
|
|
141
|
-
if (!
|
|
142
|
-
|
|
141
|
+
}, _ = (e, t, i, a) => {
|
|
142
|
+
if (!r(e)) {
|
|
143
|
+
i.push({
|
|
143
144
|
path: "nodes",
|
|
144
145
|
message: "must be an object of steps"
|
|
145
146
|
});
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
148
|
-
let
|
|
149
|
-
|
|
149
|
+
let o = Object.entries(e), s = o.filter(([, e]) => r(e) && e.type === "trigger");
|
|
150
|
+
s.length === 0 && i.push({
|
|
150
151
|
path: "nodes",
|
|
151
152
|
message: "this action has no way in",
|
|
152
153
|
hint: "add a trigger step — call, webhook, schedule, render or custom"
|
|
153
154
|
});
|
|
154
|
-
let
|
|
155
|
-
|
|
156
|
-
p(t.action) &&
|
|
157
|
-
}),
|
|
158
|
-
e.length > 1 &&
|
|
155
|
+
let c = /* @__PURE__ */ new Map();
|
|
156
|
+
s.forEach(([e, t]) => {
|
|
157
|
+
p(t.action) && c.set(t.action, [...c.get(t.action) ?? [], e]);
|
|
158
|
+
}), c.forEach((e, t) => {
|
|
159
|
+
e.length > 1 && i.push({
|
|
159
160
|
path: `nodes.${e[1]}`,
|
|
160
161
|
message: `this action has ${e.length} "${t}" triggers`,
|
|
161
162
|
hint: "one step per way in — a second flow starts from a different kind of trigger"
|
|
162
163
|
});
|
|
163
|
-
}),
|
|
164
|
-
let
|
|
165
|
-
if (!
|
|
166
|
-
|
|
167
|
-
path:
|
|
164
|
+
}), o.forEach(([t, n]) => {
|
|
165
|
+
let o = `nodes.${t}`;
|
|
166
|
+
if (!r(n)) {
|
|
167
|
+
i.push({
|
|
168
|
+
path: o,
|
|
168
169
|
message: "must be an object"
|
|
169
170
|
});
|
|
170
171
|
return;
|
|
171
172
|
}
|
|
172
173
|
if (n.type === "trigger") {
|
|
173
|
-
g(t, n,
|
|
174
|
+
g(t, n, i, a);
|
|
174
175
|
return;
|
|
175
176
|
}
|
|
176
177
|
if (n.type !== "task") {
|
|
177
|
-
|
|
178
|
-
path: `${
|
|
178
|
+
i.push({
|
|
179
|
+
path: `${o}.type`,
|
|
179
180
|
message: `"${String(n.type)}" steps run in the browser and cannot run on the server`,
|
|
180
181
|
hint: "a server action is made of task steps"
|
|
181
182
|
});
|
|
182
183
|
return;
|
|
183
184
|
}
|
|
184
|
-
if (!p(n.action) || !
|
|
185
|
-
|
|
186
|
-
path: `${
|
|
185
|
+
if (!p(n.action) || !f.test(n.action)) {
|
|
186
|
+
i.push({
|
|
187
|
+
path: `${o}.action`,
|
|
187
188
|
message: "must name a task as <namespace>.<action>",
|
|
188
189
|
hint: "for example flow.output or http.request"
|
|
189
190
|
});
|
|
190
191
|
return;
|
|
191
192
|
}
|
|
192
|
-
p(n.afterNode) && !Object.hasOwn(e, n.afterNode) &&
|
|
193
|
-
path: `${
|
|
193
|
+
p(n.afterNode) && !Object.hasOwn(e, n.afterNode) && i.push({
|
|
194
|
+
path: `${o}.afterNode`,
|
|
194
195
|
message: `points at "${n.afterNode}", which is not a step here`
|
|
195
196
|
});
|
|
196
|
-
}),
|
|
197
|
-
|
|
197
|
+
}), o.forEach(([e]) => {
|
|
198
|
+
d.has(e) && i.push({
|
|
198
199
|
path: `nodes.${e}`,
|
|
199
200
|
message: `"${e}" is what the run itself publishes in the flow scope, so a step may not take the name`,
|
|
200
201
|
hint: `rename the step — every later step reads {{ ${e} }} expecting the run's own value`
|
|
201
202
|
});
|
|
202
203
|
});
|
|
203
|
-
let
|
|
204
|
-
|
|
204
|
+
let l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), m = [];
|
|
205
|
+
s.forEach(([t]) => {
|
|
205
206
|
let n = /* @__PURE__ */ new Set(), r = [], i = t;
|
|
206
207
|
for (; i;) {
|
|
207
208
|
if (n.has(i)) {
|
|
208
|
-
|
|
209
|
+
u.add(i);
|
|
209
210
|
break;
|
|
210
211
|
}
|
|
211
|
-
n.add(i), r.push(i),
|
|
212
|
+
n.add(i), r.push(i), l.add(i);
|
|
212
213
|
let t = e[i];
|
|
213
214
|
i = p(t?.afterNode) ? t.afterNode : "";
|
|
214
215
|
}
|
|
215
216
|
m.push(r);
|
|
216
|
-
}),
|
|
217
|
-
|
|
217
|
+
}), u.forEach((e) => {
|
|
218
|
+
i.push({
|
|
218
219
|
path: `nodes.${e}`,
|
|
219
220
|
message: "this step is reached again by its own chain, so the flow never ends",
|
|
220
221
|
hint: "break the `afterNode` chain that comes back to it"
|
|
221
222
|
});
|
|
222
|
-
}),
|
|
223
|
-
|
|
223
|
+
}), o.forEach(([e]) => {
|
|
224
|
+
l.has(e) || a.push({
|
|
224
225
|
path: `nodes.${e}`,
|
|
225
226
|
message: "no trigger reaches this step, so it never runs",
|
|
226
227
|
hint: "chain it with `afterNode` from a trigger, or delete it"
|
|
227
228
|
});
|
|
228
229
|
});
|
|
229
|
-
let h = (t) => e[t]?.action, _ =
|
|
230
|
+
let h = (t) => e[t]?.action, _ = o.filter(([, e]) => r(e) && e.action === "flow.output");
|
|
230
231
|
for (let [t, n] of _) {
|
|
231
232
|
let r = p(n.afterNode) && h(n.afterNode) === "flow.onFailure";
|
|
232
|
-
p(n.afterNode) && Object.hasOwn(e, n.afterNode) && !r &&
|
|
233
|
+
p(n.afterNode) && Object.hasOwn(e, n.afterNode) && !r && a.push({
|
|
233
234
|
path: `nodes.${t}.afterNode`,
|
|
234
235
|
message: "the output step is not the last one, so the steps after it run for nothing",
|
|
235
236
|
hint: "move flow.output to the end of the flow"
|
|
@@ -241,37 +242,37 @@ var o = [
|
|
|
241
242
|
m.forEach((e) => {
|
|
242
243
|
let t = e.findIndex((e) => h(e) === n);
|
|
243
244
|
if (t === -1) return;
|
|
244
|
-
let
|
|
245
|
-
t === 1 && y(
|
|
246
|
-
path: `nodes.${
|
|
245
|
+
let r = e[t];
|
|
246
|
+
t === 1 && y(a, {
|
|
247
|
+
path: `nodes.${r}`,
|
|
247
248
|
message: "nothing runs before this step, so nothing can fail and the steps after it never run",
|
|
248
249
|
hint: "put On Failure after the steps whose work it undoes"
|
|
249
|
-
}), t === e.length - 1 && y(
|
|
250
|
-
path: `nodes.${
|
|
250
|
+
}), t === e.length - 1 && y(a, {
|
|
251
|
+
path: `nodes.${r}`,
|
|
251
252
|
message: "nothing follows this step, so a failed run undoes nothing",
|
|
252
253
|
hint: "add the steps that give back what the flow already did"
|
|
253
254
|
}), e.slice(t + 1).forEach((e) => {
|
|
254
|
-
h(e) === "flow.onFailure" && y(
|
|
255
|
+
h(e) === "flow.onFailure" && y(i, {
|
|
255
256
|
path: `nodes.${e}`,
|
|
256
257
|
message: "a flow has one place its undo begins, and this is a second one",
|
|
257
258
|
hint: "keep one On Failure step and put every undo step after it"
|
|
258
|
-
}), h(e) === "flow.output" && y(
|
|
259
|
+
}), h(e) === "flow.output" && y(i, {
|
|
259
260
|
path: `nodes.${e}`,
|
|
260
261
|
message: "an output step after On Failure answers a run that has already failed",
|
|
261
262
|
hint: "move flow.output before On Failure"
|
|
262
263
|
});
|
|
263
264
|
});
|
|
264
|
-
}), _.length === 0 &&
|
|
265
|
+
}), _.length === 0 && r(t) && Object.keys(t).length > 0 && a.push({
|
|
265
266
|
path: "nodes",
|
|
266
267
|
message: "this action is expected to answer values but no step names any",
|
|
267
268
|
hint: "add a flow.output step at the end naming what the caller should get"
|
|
268
269
|
});
|
|
269
270
|
}, v = /\{\{\s*credential\./, y = (e, t) => {
|
|
270
271
|
Object.entries(e).forEach(([e, n]) => {
|
|
271
|
-
if (!
|
|
272
|
-
let
|
|
273
|
-
Object.entries(n.params).forEach(([n,
|
|
274
|
-
typeof
|
|
272
|
+
if (!r(n) || !r(n.params)) return;
|
|
273
|
+
let i = p(n.params.credential) ? n.params.credential : "";
|
|
274
|
+
Object.entries(n.params).forEach(([n, r]) => {
|
|
275
|
+
typeof r == "string" && v.test(r) && i === "" && t.push({
|
|
275
276
|
path: `nodes.${e}.params.${n}`,
|
|
276
277
|
message: "this step reads a credential it did not ask for, so the token resolves to nothing",
|
|
277
278
|
hint: "set the step’s `credential` to the identifier it should use"
|
|
@@ -280,10 +281,10 @@ var o = [
|
|
|
280
281
|
});
|
|
281
282
|
}, b = (e) => {
|
|
282
283
|
let t = [], n = [];
|
|
283
|
-
return
|
|
284
|
+
return r(e) ? (p(e.name) || t.push({
|
|
284
285
|
path: "name",
|
|
285
286
|
message: "must have a name"
|
|
286
|
-
}), h(e.output, "output", t), _(e.nodes, e.output, t, n), y(
|
|
287
|
+
}), h(e.output, "output", t), _(e.nodes, e.output, t, n), y(r(e.nodes) ? e.nodes : {}, n), {
|
|
287
288
|
valid: t.length === 0,
|
|
288
289
|
errors: t,
|
|
289
290
|
warnings: n
|
|
@@ -295,6 +296,6 @@ var o = [
|
|
|
295
296
|
}],
|
|
296
297
|
warnings: n
|
|
297
298
|
};
|
|
298
|
-
};
|
|
299
|
+
}, x = (e) => b(e).valid;
|
|
299
300
|
//#endregion
|
|
300
|
-
export { b as validateActionDocument };
|
|
301
|
+
export { x as isActionDocument, b as validateActionDocument };
|
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
import { BuiltinActionSpec } from './builder';
|
|
2
|
+
import { BuiltinParam } from './paramSpec';
|
|
2
3
|
export type BuiltinElementCallback = BuiltinActionSpec;
|
|
4
|
+
/**
|
|
5
|
+
* Moving what an element shows, on the element whose box scrolls (`overflow: auto` on a row of cards, a panel) — or,
|
|
6
|
+
* with `scrollIntoView`, the page to an element. Arrows over a carousel that still swipes on a phone, a "back to the
|
|
7
|
+
* top", a jump to the answer a form just showed. Its node names the element that moves; nothing happens where there is
|
|
8
|
+
* no page to move (a server render).
|
|
9
|
+
*/
|
|
10
|
+
export declare const SCROLL_CALLBACKS: {
|
|
11
|
+
scrollBy: {
|
|
12
|
+
title: string;
|
|
13
|
+
type: "callback";
|
|
14
|
+
strictParams: true;
|
|
15
|
+
params: {
|
|
16
|
+
x: {
|
|
17
|
+
type: "text";
|
|
18
|
+
description: string;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
y: {
|
|
22
|
+
type: "text";
|
|
23
|
+
description: string;
|
|
24
|
+
default: string;
|
|
25
|
+
};
|
|
26
|
+
behavior: BuiltinParam;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
scrollTo: {
|
|
30
|
+
title: string;
|
|
31
|
+
type: "callback";
|
|
32
|
+
strictParams: true;
|
|
33
|
+
params: {
|
|
34
|
+
x: {
|
|
35
|
+
type: "text";
|
|
36
|
+
description: string;
|
|
37
|
+
default: string;
|
|
38
|
+
};
|
|
39
|
+
y: {
|
|
40
|
+
type: "text";
|
|
41
|
+
description: string;
|
|
42
|
+
default: string;
|
|
43
|
+
};
|
|
44
|
+
behavior: BuiltinParam;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
scrollIntoView: {
|
|
48
|
+
title: string;
|
|
49
|
+
type: "callback";
|
|
50
|
+
strictParams: true;
|
|
51
|
+
params: {
|
|
52
|
+
block: {
|
|
53
|
+
type: "select";
|
|
54
|
+
description: string;
|
|
55
|
+
default: string;
|
|
56
|
+
options: ("start" | "center" | "end" | "nearest")[];
|
|
57
|
+
};
|
|
58
|
+
inline: {
|
|
59
|
+
type: "select";
|
|
60
|
+
description: string;
|
|
61
|
+
default: string;
|
|
62
|
+
options: ("start" | "center" | "end" | "nearest")[];
|
|
63
|
+
};
|
|
64
|
+
behavior: BuiltinParam;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
3
68
|
export declare const BUILTIN_ELEMENT_CALLBACKS: Record<string, BuiltinElementCallback>;
|
|
4
69
|
/** The built-in element callback for an action, or undefined when the action is not a known built-in (an
|
|
5
70
|
* element-type-specific/plugin callback whose schema is not knowable here). */
|
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
import { reconcileParams as e } from "./paramSpec.mjs";
|
|
2
|
+
import { SCROLL_BEHAVIORS as t, SCROLL_POSITIONS as n } from "../helpers/scroll.mjs";
|
|
2
3
|
//#region src/authoring/elementCallbacks.ts
|
|
3
|
-
var
|
|
4
|
+
var r = {
|
|
5
|
+
type: "select",
|
|
6
|
+
description: "How it moves: \"smooth\" glides there, \"auto\" jumps.",
|
|
7
|
+
default: "smooth",
|
|
8
|
+
options: [...t]
|
|
9
|
+
}, i = {
|
|
10
|
+
scrollBy: {
|
|
11
|
+
title: "Scroll By",
|
|
12
|
+
type: "callback",
|
|
13
|
+
strictParams: !0,
|
|
14
|
+
params: {
|
|
15
|
+
x: {
|
|
16
|
+
type: "text",
|
|
17
|
+
description: "How far across: pixels (\"240\") or a share of what the box shows (\"80%\"); negative goes back.",
|
|
18
|
+
default: ""
|
|
19
|
+
},
|
|
20
|
+
y: {
|
|
21
|
+
type: "text",
|
|
22
|
+
description: "How far down, the same way; negative goes up.",
|
|
23
|
+
default: ""
|
|
24
|
+
},
|
|
25
|
+
behavior: r
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
scrollTo: {
|
|
29
|
+
title: "Scroll To",
|
|
30
|
+
type: "callback",
|
|
31
|
+
strictParams: !0,
|
|
32
|
+
params: {
|
|
33
|
+
x: {
|
|
34
|
+
type: "text",
|
|
35
|
+
description: "Where across: \"start\", \"end\", pixels from the start, or a share of the way (\"50%\"). Empty stays.",
|
|
36
|
+
default: ""
|
|
37
|
+
},
|
|
38
|
+
y: {
|
|
39
|
+
type: "text",
|
|
40
|
+
description: "Where down, the same way. Empty stays.",
|
|
41
|
+
default: ""
|
|
42
|
+
},
|
|
43
|
+
behavior: r
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
scrollIntoView: {
|
|
47
|
+
title: "Scroll Into View",
|
|
48
|
+
type: "callback",
|
|
49
|
+
strictParams: !0,
|
|
50
|
+
params: {
|
|
51
|
+
block: {
|
|
52
|
+
type: "select",
|
|
53
|
+
description: "Where the element lands, top to bottom.",
|
|
54
|
+
default: "start",
|
|
55
|
+
options: [...n]
|
|
56
|
+
},
|
|
57
|
+
inline: {
|
|
58
|
+
type: "select",
|
|
59
|
+
description: "Where it lands, side to side.",
|
|
60
|
+
default: "nearest",
|
|
61
|
+
options: [...n]
|
|
62
|
+
},
|
|
63
|
+
behavior: r
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}, a = {
|
|
4
67
|
setState: {
|
|
5
68
|
title: "Update Element (set attribute / state)",
|
|
6
69
|
type: "callback",
|
|
@@ -56,16 +119,17 @@ var t = {
|
|
|
56
119
|
label: "Revert changes after interaction"
|
|
57
120
|
}
|
|
58
121
|
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
122
|
+
},
|
|
123
|
+
...i
|
|
124
|
+
}, o = (e) => Object.hasOwn(a, e) ? a[e] : void 0, s = (t, n) => {
|
|
125
|
+
let r = o(t);
|
|
126
|
+
return r ? {
|
|
63
127
|
known: !0,
|
|
64
|
-
params: e(
|
|
128
|
+
params: e(n, r.params, r.strictParams)
|
|
65
129
|
} : {
|
|
66
130
|
known: !1,
|
|
67
|
-
params:
|
|
131
|
+
params: n
|
|
68
132
|
};
|
|
69
133
|
};
|
|
70
134
|
//#endregion
|
|
71
|
-
export {
|
|
135
|
+
export { a as BUILTIN_ELEMENT_CALLBACKS, i as SCROLL_CALLBACKS, s as applyElementCallback, o as getElementCallback };
|
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
2
|
import { elementDeclaration as r, valuesOf as i } from "./declare.mjs";
|
|
3
3
|
import { hiddenParams as a, invalidParams as o, missingRequiredParams as s, reconcileParams as c } from "./paramSpec.mjs";
|
|
4
|
-
import { BUILTIN_ELEMENT_CALLBACKS as l,
|
|
5
|
-
import { spaceCallbacks as
|
|
6
|
-
export { l as BUILTIN_ELEMENT_CALLBACKS, u as applyElementCallback, r as elementDeclaration,
|
|
4
|
+
import { BUILTIN_ELEMENT_CALLBACKS as l, SCROLL_CALLBACKS as u, applyElementCallback as d, getElementCallback as f } from "./elementCallbacks.mjs";
|
|
5
|
+
import { spaceCallbacks as p } from "./spaceCallbacks.mjs";
|
|
6
|
+
export { l as BUILTIN_ELEMENT_CALLBACKS, u as SCROLL_CALLBACKS, d as applyElementCallback, r as elementDeclaration, f as getElementCallback, a as hiddenParams, o as invalidParams, s as missingRequiredParams, c as reconcileParams, p as spaceCallbacks, e as toBuilderParams, t as toInteractionCallback, n as toInteractionCallbacks, i as valuesOf };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentPluginWithHOC, DropPosition, Element, EventBridgeEvent, PluginBuilder, Schema, Style } from '../../types';
|
|
2
2
|
import { Dispatch, SetStateAction } from 'react';
|
|
3
3
|
export type BuilderContextValue = {
|
|
4
|
-
mode: 'normal' | '
|
|
4
|
+
mode: 'normal' | 'snippet';
|
|
5
5
|
schemaName: string;
|
|
6
6
|
setMultiPagesMode: Dispatch<SetStateAction<boolean>>;
|
|
7
7
|
multiPagesMode: boolean;
|
|
@@ -18,27 +18,38 @@ export type BuilderContextValue = {
|
|
|
18
18
|
};
|
|
19
19
|
builderHandler: (event: EventBridgeEvent, ...data: unknown[]) => void;
|
|
20
20
|
updateElement: (elementId: string, attributeKey: string, attributeValue: unknown, category?: 'attributes' | 'definition') => void;
|
|
21
|
-
/**
|
|
22
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Saves an element and what it holds as a snippet file in a public bucket of one of the space's CDNs, and says
|
|
23
|
+
* whether it was saved — and why not, in words for whoever asked.
|
|
24
|
+
*/
|
|
25
|
+
elementAsSnippet: (target: {
|
|
23
26
|
cdnIdentifier: string;
|
|
24
27
|
bucketIdentifier: string;
|
|
25
|
-
},
|
|
28
|
+
}, details: {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
}, element: Element) => Promise<{
|
|
32
|
+
saved: true;
|
|
33
|
+
} | {
|
|
34
|
+
saved: false;
|
|
35
|
+
reason: string;
|
|
36
|
+
}>;
|
|
26
37
|
builderGetBaseElement: (otherBaseElementId?: string) => undefined | {
|
|
27
38
|
data: Element;
|
|
28
39
|
Plugin: ComponentPluginWithHOC | Record<string, ComponentPluginWithHOC>;
|
|
29
40
|
};
|
|
30
41
|
builderDropElement: {
|
|
31
|
-
(type: 'add##plitzi-
|
|
42
|
+
(type: 'add##plitzi-snippet', data: {
|
|
32
43
|
elements: Record<string, Element>;
|
|
33
44
|
baseElement?: Element;
|
|
34
45
|
style: Style;
|
|
35
46
|
variables: Schema['variables'];
|
|
36
47
|
}, dropPosition: DropPosition, toElementId: string, rootId?: string): boolean;
|
|
37
|
-
<T extends string>(type: `add##${Exclude<T, 'plitzi-
|
|
48
|
+
<T extends string>(type: `add##${Exclude<T, 'plitzi-snippet'>}`, data: {
|
|
38
49
|
id?: string;
|
|
39
50
|
element: Element;
|
|
40
51
|
}, dropPosition: DropPosition, toElementId: string, rootId?: string): boolean;
|
|
41
|
-
<T extends string>(type: `move##${Exclude<T, 'plitzi-
|
|
52
|
+
<T extends string>(type: `move##${Exclude<T, 'plitzi-snippet'>}`, data: {
|
|
42
53
|
id: string;
|
|
43
54
|
parentId: string;
|
|
44
55
|
element: Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { BODYLESS_METHODS, CONNECTOR_HTTP_METHODS, DEFAULT_READ_ENDPOINT, EMPTY_RESPONSE_METHODS, READ_ENDPOINT_NAMES, WRITE_ENDPOINT_NAMES } from './constants';
|
|
2
2
|
export { connectorTokens, getConnectorTokens } from './manifestTokens';
|
|
3
3
|
export { connectorPresets, emptyManifest } from './presets';
|
|
4
|
-
export { validateConnectorManifest } from './validateManifest';
|
|
4
|
+
export { isConnectorManifestDraft, validateConnectorManifest } from './validateManifest';
|
|
5
5
|
export type { ConnectorPreset } from './presets';
|
|
6
6
|
export type { ConnectorToken, ConnectorTokenScope } from './manifestTokens';
|
|
7
7
|
export type { ConnectorManifestIssue, ConnectorManifestReport } from './validateManifest';
|