@plitzi/sdk-shared 0.38.5 → 0.38.7
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 +210 -0
- package/dist/dataSource/globalSources.d.ts +34 -1
- package/dist/dataSource/globalSources.mjs +22 -2
- package/dist/dataSource/hooks/index.d.ts +2 -1
- package/dist/dataSource/hooks/index.mjs +2 -1
- package/dist/dataSource/hooks/useResolvedVariables.d.ts +12 -0
- package/dist/dataSource/hooks/useResolvedVariables.mjs +28 -0
- package/dist/dataSource/index.mjs +2 -1
- package/dist/dataSource/resolveVariables.d.ts +2 -2
- package/dist/flags/useFlagResolution.mjs +6 -6
- package/dist/index.mjs +62 -58
- package/dist/network/spaceEvents.d.ts +30 -0
- package/dist/network/spaceEvents.mjs +150 -147
- package/dist/project/layout.d.ts +197 -0
- package/dist/project/layout.mjs +394 -0
- package/dist/project/paths.d.ts +84 -0
- package/dist/project/paths.mjs +4 -0
- package/dist/project/root.d.ts +24 -0
- package/dist/project/root.mjs +26 -0
- package/dist/queries/index.d.ts +12 -2
- package/dist/queries/index.mjs +27 -17
- package/dist/queries/serverQueries.d.ts +22 -0
- package/dist/queries/serverQueries.mjs +9 -0
- package/dist/queries/useServerQuery.d.ts +19 -0
- package/dist/queries/useServerQuery.mjs +21 -0
- package/dist/server/rsc/refreshRsc.d.ts +22 -10
- package/dist/server/rsc/refreshRsc.mjs +65 -53
- package/dist/server/rsc/useRscRefresh.d.ts +2 -1
- package/dist/server/rsc/useRscRefresh.mjs +1 -1
- package/dist/store/index.d.ts +45 -45
- package/dist/style/index.d.ts +3 -0
- package/dist/style/index.mjs +5 -2
- package/dist/style/keyframes.d.ts +39 -0
- package/dist/style/keyframes.mjs +41 -0
- package/dist/style/notifications.d.ts +34 -12
- package/dist/style/notifications.mjs +69 -32
- package/dist/style/styleConditions.d.ts +43 -0
- package/dist/style/styleConditions.mjs +29 -0
- package/dist/style/styleConstants.d.ts +3 -2
- package/dist/style/styleConstants.mjs +2 -0
- package/dist/style/stylePseudos.d.ts +40 -0
- package/dist/style/stylePseudos.mjs +109 -0
- package/dist/style/styleStates.d.ts +35 -8
- package/dist/style/styleStates.mjs +38 -15
- package/dist/style/styleTarget.d.ts +23 -0
- package/dist/style/styleTarget.mjs +35 -0
- package/dist/types/AuthTypes.d.ts +5 -0
- package/dist/types/CommonTypes.d.ts +12 -0
- package/dist/types/SchemaTypes.d.ts +2 -0
- package/dist/types/ServerTypes.d.ts +11 -4
- package/dist/types/StoreTypes.d.ts +5 -1
- package/dist/types/StyleTypes.d.ts +20 -2
- package/package.json +42 -2
|
@@ -2,163 +2,166 @@ import { isRecord as e } from "../helpers/isRecord.mjs";
|
|
|
2
2
|
import { isSchemaFlag as t } from "../flags/schemaFlag.mjs";
|
|
3
3
|
import { StyleVariableCategory as n } from "../types/StyleTypes.mjs";
|
|
4
4
|
import { DISPLAY_MODES as r } from "../style/displayModes.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { STYLE_PSEUDOS as i } from "../style/stylePseudos.mjs";
|
|
6
|
+
import { STYLE_STATES as a } from "../style/styleStates.mjs";
|
|
7
|
+
import { elementFromWire as o, schemaFromWire as s, schemaToWire as c } from "../schema/wire.mjs";
|
|
8
|
+
import { z as l } from "zod";
|
|
8
9
|
//#region src/network/spaceEvents.ts
|
|
9
|
-
var
|
|
10
|
+
var u = l.custom((t) => e(t) && typeof t.id == "string", { message: "expected an element with an id" }), d = l.array(u), f = l.custom((t) => e(t) && typeof t.id == "string" && e(t.flat), { message: "expected a component with an id and a flat" }), p = l.custom((t) => e(t) && Array.isArray(t.flat), { message: "expected a schema whose `flat` is a list of elements" }), m = l.custom((t) => e(t) && typeof t.id == "string", { message: "expected a page folder with an id" }), h = l.custom((t) => e(t) && typeof t.name == "string", { message: "expected a variable with a name" }), g = l.custom(t, { message: "expected a flag with a value and its rules" }), _ = l.custom(e, { message: "expected a style attributes object" }), v = l.custom((t) => e(t) && typeof t.family == "string" && typeof t.source == "string", { message: "expected a font with a family and a source" }), y = l.custom((t) => typeof t == "string" || typeof t == "number" || e(t), { message: "expected a style variable value" }), b = l.enum(r), x = l.custom((e) => typeof e == "string", { message: "expected a drop position" }), S = l.custom((e) => typeof e == "string", { message: "expected a style category" }), C = l.enum([
|
|
10
11
|
"class",
|
|
11
12
|
"element",
|
|
12
13
|
"id"
|
|
13
|
-
]),
|
|
14
|
-
componentType:
|
|
15
|
-
styleSelector:
|
|
16
|
-
styleState:
|
|
17
|
-
styleVariant:
|
|
18
|
-
styleAncestor:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
14
|
+
]), w = l.enum(a), T = l.enum(n), E = l.object({
|
|
15
|
+
componentType: l.string().optional(),
|
|
16
|
+
styleSelector: l.string().optional(),
|
|
17
|
+
styleState: w.optional(),
|
|
18
|
+
styleVariant: l.string().optional(),
|
|
19
|
+
styleAncestor: l.string().optional(),
|
|
20
|
+
stylePseudo: l.enum(i).optional(),
|
|
21
|
+
styleCondition: l.string().optional()
|
|
22
|
+
}), D = E.extend({ styleSelector: l.string() }), O = l.object({ variable: h }), k = l.object({
|
|
23
|
+
displayMode: b,
|
|
24
|
+
selector: l.string(),
|
|
25
|
+
category: T,
|
|
26
|
+
name: l.string(),
|
|
27
|
+
value: y
|
|
28
|
+
}), A = l.object({
|
|
29
|
+
displayMode: b,
|
|
30
|
+
selector: l.string(),
|
|
31
|
+
category: T,
|
|
32
|
+
name: l.string()
|
|
33
|
+
}), j = l.object({
|
|
34
|
+
category: T,
|
|
35
|
+
name: l.string(),
|
|
36
|
+
value: y
|
|
37
|
+
}), M = l.object({
|
|
38
|
+
type: l.string(),
|
|
39
|
+
resource: l.string(),
|
|
40
|
+
settings: l.custom(e, { message: "expected a plugin settings object" })
|
|
41
|
+
}), N = {
|
|
42
|
+
SPACE_UPDATED: l.object({ schema: p }),
|
|
43
|
+
STYLE_UPDATED: l.object({
|
|
44
|
+
platform: l.custom(e),
|
|
45
|
+
variables: l.custom(e),
|
|
46
|
+
cache: l.string()
|
|
47
|
+
}),
|
|
48
|
+
SPACE_ADD_PAGE: l.object({ page: u }),
|
|
49
|
+
SPACE_UPDATE_PAGE: l.object({ page: u }),
|
|
50
|
+
SPACE_SET_HOME_PAGE: l.object({ page: u }),
|
|
51
|
+
SPACE_REMOVE_PAGE: l.object({ pageId: l.string() }),
|
|
52
|
+
SPACE_ADD_PAGE_FOLDER: l.object({ pageFolder: m }),
|
|
53
|
+
SPACE_UPDATE_PAGE_FOLDER: l.object({ pageFolder: m }),
|
|
54
|
+
SPACE_REMOVE_PAGE_FOLDER: l.object({ pageFolderId: l.string() }),
|
|
55
|
+
SPACE_ADD_VARIABLE: O,
|
|
56
|
+
SPACE_UPDATE_VARIABLE: O,
|
|
57
|
+
SPACE_REMOVE_VARIABLE: l.object({ name: l.string() }),
|
|
58
|
+
SPACE_SET_FLAG: l.object({
|
|
59
|
+
name: l.string(),
|
|
60
|
+
flag: g
|
|
61
|
+
}),
|
|
62
|
+
SPACE_REMOVE_FLAG: l.object({ name: l.string() }),
|
|
63
|
+
SPACE_ADD_ELEMENT: l.object({
|
|
64
|
+
element: u,
|
|
65
|
+
dropPosition: x,
|
|
66
|
+
to: l.string(),
|
|
67
|
+
initialItems: d.optional(),
|
|
68
|
+
variables: l.array(h).optional()
|
|
69
|
+
}),
|
|
70
|
+
SPACE_UPDATE_ELEMENT: l.object({ element: u }),
|
|
71
|
+
SPACE_RENAME_ELEMENT: l.object({
|
|
72
|
+
elementId: l.string(),
|
|
73
|
+
id: l.string()
|
|
74
|
+
}),
|
|
75
|
+
SPACE_UPDATE_ELEMENTS: l.object({ elements: d }),
|
|
76
|
+
SPACE_REMOVE_ELEMENT: l.object({ elementId: l.string() }),
|
|
77
|
+
SPACE_MOVE_ELEMENT: l.object({
|
|
78
|
+
from: l.string(),
|
|
79
|
+
to: l.string(),
|
|
80
|
+
elementId: l.string(),
|
|
81
|
+
dropPosition: x
|
|
82
|
+
}),
|
|
83
|
+
SPACE_CLONE_ELEMENT: l.object({
|
|
84
|
+
to: l.string(),
|
|
85
|
+
element: u,
|
|
86
|
+
dropPosition: x,
|
|
87
|
+
initialItems: d
|
|
88
|
+
}),
|
|
89
|
+
SPACE_ADD_SNIPPET: l.object({
|
|
90
|
+
element: u,
|
|
91
|
+
style: l.custom(e),
|
|
92
|
+
to: l.string(),
|
|
93
|
+
dropPosition: x,
|
|
94
|
+
initialItems: d.optional(),
|
|
95
|
+
variables: l.array(h).optional()
|
|
96
|
+
}),
|
|
97
|
+
SPACE_ADD_PLUGIN: l.object({ plugin: M }),
|
|
98
|
+
SPACE_UPDATE_PLUGIN: l.object({ plugin: M }),
|
|
99
|
+
SPACE_REMOVE_PLUGIN: l.object({ pluginType: l.string() }),
|
|
100
|
+
SPACE_UPDATE_SETTINGS: l.object({
|
|
101
|
+
path: l.string(),
|
|
102
|
+
value: l.union([
|
|
103
|
+
l.string(),
|
|
104
|
+
l.number(),
|
|
105
|
+
l.boolean()
|
|
103
106
|
])
|
|
104
107
|
}),
|
|
105
|
-
STYLE_ADD_SELECTOR:
|
|
106
|
-
displayMode:
|
|
107
|
-
selector:
|
|
108
|
-
path:
|
|
109
|
-
type:
|
|
110
|
-
style:
|
|
111
|
-
params: T
|
|
112
|
-
}),
|
|
113
|
-
STYLE_UPDATE_SELECTOR: c.object({
|
|
114
|
-
displayMode: y,
|
|
115
|
-
selector: c.string(),
|
|
116
|
-
path: x.optional(),
|
|
117
|
-
style: g.optional(),
|
|
108
|
+
STYLE_ADD_SELECTOR: l.object({
|
|
109
|
+
displayMode: b,
|
|
110
|
+
selector: l.string(),
|
|
111
|
+
path: S.optional(),
|
|
112
|
+
type: C,
|
|
113
|
+
style: _.optional(),
|
|
118
114
|
params: E
|
|
119
115
|
}),
|
|
120
|
-
|
|
121
|
-
displayMode:
|
|
122
|
-
selector:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
116
|
+
STYLE_UPDATE_SELECTOR: l.object({
|
|
117
|
+
displayMode: b,
|
|
118
|
+
selector: l.string(),
|
|
119
|
+
path: S.optional(),
|
|
120
|
+
style: _.optional(),
|
|
121
|
+
params: D
|
|
122
|
+
}),
|
|
123
|
+
STYLE_REMOVE_SELECTOR: l.object({
|
|
124
|
+
displayMode: b,
|
|
125
|
+
selector: l.string()
|
|
126
|
+
}),
|
|
127
|
+
STYLE_REMOVE_SELECTORS: l.object({
|
|
128
|
+
displayMode: b,
|
|
129
|
+
selectors: l.array(l.string())
|
|
130
|
+
}),
|
|
131
|
+
STYLE_ADD_SELECTOR_VARIABLE: k,
|
|
132
|
+
STYLE_UPDATE_SELECTOR_VARIABLE: k,
|
|
133
|
+
STYLE_REMOVE_SELECTOR_VARIABLE: A,
|
|
134
|
+
STYLE_ADD_VARIABLE: j,
|
|
135
|
+
STYLE_UPDATE_VARIABLE: j,
|
|
136
|
+
STYLE_REMOVE_VARIABLE: l.object({
|
|
137
|
+
category: T,
|
|
138
|
+
name: l.string()
|
|
139
|
+
}),
|
|
140
|
+
STYLE_UPDATE_SETTINGS: l.object({
|
|
141
|
+
path: l.string(),
|
|
142
|
+
value: l.string()
|
|
143
|
+
}),
|
|
144
|
+
STYLE_ADD_FONT: l.object({ font: v }),
|
|
145
|
+
STYLE_UPDATE_FONT: l.object({
|
|
146
|
+
family: l.string(),
|
|
147
|
+
font: v
|
|
148
|
+
}),
|
|
149
|
+
STYLE_REMOVE_FONT: l.object({ family: l.string() }),
|
|
150
|
+
SPACE_ADD_COMPONENT: l.object({
|
|
151
|
+
component: f,
|
|
152
|
+
from: l.object({
|
|
153
|
+
elementId: l.string(),
|
|
154
|
+
instanceId: l.string()
|
|
152
155
|
}).optional()
|
|
153
156
|
}),
|
|
154
|
-
SPACE_UPDATE_COMPONENT:
|
|
155
|
-
componentId:
|
|
156
|
-
declaration:
|
|
157
|
+
SPACE_UPDATE_COMPONENT: l.object({
|
|
158
|
+
componentId: l.string(),
|
|
159
|
+
declaration: l.custom(e)
|
|
157
160
|
}),
|
|
158
|
-
SPACE_REMOVE_COMPONENT:
|
|
159
|
-
SPACE_DETACH_INSTANCE:
|
|
160
|
-
},
|
|
161
|
-
let n =
|
|
161
|
+
SPACE_REMOVE_COMPONENT: l.object({ componentId: l.string() }),
|
|
162
|
+
SPACE_DETACH_INSTANCE: l.object({ instanceId: l.string() })
|
|
163
|
+
}, P = Object.fromEntries(Object.keys(N).map((e) => [e, e])), F = (e, t) => {
|
|
164
|
+
let n = N[e];
|
|
162
165
|
if (!n) return {
|
|
163
166
|
ok: !1,
|
|
164
167
|
issues: [{
|
|
@@ -179,4 +182,4 @@ var l = c.custom((t) => e(t) && typeof t.id == "string", { message: "expected an
|
|
|
179
182
|
};
|
|
180
183
|
};
|
|
181
184
|
//#endregion
|
|
182
|
-
export {
|
|
185
|
+
export { P as SpaceEvents, P as default, o as elementFromWire, s as schemaFromWire, c as schemaToWire, N as spaceEventSchemas, F as validateSpaceEvent };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The project's layout held to what reads it: every folder the server builds, runs or serves from where the CLI puts
|
|
3
|
+
* it, each with the file it starts at. One check, said the same by the three that read the project — its server at
|
|
4
|
+
* boot (`serveProject`), its authoring (`projectAuthoring`: `npm run author` and the CLI's checks) and `plitzi doctor`,
|
|
5
|
+
* which makes the fixes that have one reading (`autofix`). Pure file system: what a file holds is never imported.
|
|
6
|
+
*
|
|
7
|
+
* An `error` is what keeps a part of the project from running — a plugin the server cannot build, code in a folder
|
|
8
|
+
* nothing reads, settings Node never loads — and stops the server and the authoring; a `warning` works, and should not
|
|
9
|
+
* stay.
|
|
10
|
+
*/
|
|
11
|
+
export type LayoutLevel = 'error' | 'warning';
|
|
12
|
+
/** Every finding of the layout check, by its code: how much it matters, and what it means in a line. */
|
|
13
|
+
export declare const PROJECT_LAYOUT_CODES: {
|
|
14
|
+
readonly 'plugin-entry-missing': {
|
|
15
|
+
readonly level: "error";
|
|
16
|
+
readonly means: "a folder of src/plugins/ with no index.ts (or index.tsx), which the server builds the plugin from";
|
|
17
|
+
};
|
|
18
|
+
readonly 'plugin-entry-ambiguous': {
|
|
19
|
+
readonly level: "error";
|
|
20
|
+
readonly means: "a folder of src/plugins/ with both index.ts and index.tsx: a plugin starts at one";
|
|
21
|
+
};
|
|
22
|
+
readonly 'entry-not-typescript': {
|
|
23
|
+
readonly level: "error";
|
|
24
|
+
readonly means: "an entry the server builds or runs written as JavaScript (index.js, .jsx, .mjs, .cjs): the project is TypeScript";
|
|
25
|
+
};
|
|
26
|
+
readonly 'plugin-name-invalid': {
|
|
27
|
+
readonly level: "error";
|
|
28
|
+
readonly means: "a folder of src/plugins/ whose name cannot be an element type: a letter, then letters and digits";
|
|
29
|
+
};
|
|
30
|
+
readonly 'plugin-type-taken': {
|
|
31
|
+
readonly level: "error";
|
|
32
|
+
readonly means: "two folders of src/plugins/ that are the same element type (StoryEditor and storyEditor)";
|
|
33
|
+
};
|
|
34
|
+
readonly 'plugin-shadowed': {
|
|
35
|
+
readonly level: "error";
|
|
36
|
+
readonly means: "a plugin both in src/plugins/ and, as it was built, in vendor/plugins/: the built one runs";
|
|
37
|
+
};
|
|
38
|
+
readonly 'plugin-functions-entry-missing': {
|
|
39
|
+
readonly level: "error";
|
|
40
|
+
readonly means: "a plugin’s functions/ with code and no index.ts, which its server half is built from";
|
|
41
|
+
};
|
|
42
|
+
readonly 'functions-entry-missing': {
|
|
43
|
+
readonly level: "error";
|
|
44
|
+
readonly means: "src/functions/ with code and no index.ts, which the project’s functions are built from";
|
|
45
|
+
};
|
|
46
|
+
readonly 'runtime-entry-missing': {
|
|
47
|
+
readonly level: "error";
|
|
48
|
+
readonly means: "src/runtime/ with code and no index.ts, which the space’s runtime starts at";
|
|
49
|
+
};
|
|
50
|
+
readonly 'space-entry-missing': {
|
|
51
|
+
readonly level: "error";
|
|
52
|
+
readonly means: "a space written in the project with no src/space/index.ts, which the server and npm run author import";
|
|
53
|
+
};
|
|
54
|
+
readonly 'space-default-export': {
|
|
55
|
+
readonly level: "error";
|
|
56
|
+
readonly means: "src/space/index.ts exporting the space by default, where it is imported by name: `space`";
|
|
57
|
+
};
|
|
58
|
+
readonly 'vendor-manifest-missing': {
|
|
59
|
+
readonly level: "error";
|
|
60
|
+
readonly means: "a built plugin (vendor/plugins/<type>/) with no plugin-manifest.json";
|
|
61
|
+
};
|
|
62
|
+
readonly 'vendor-manifest-invalid': {
|
|
63
|
+
readonly level: "error";
|
|
64
|
+
readonly means: "a built plugin’s plugin-manifest.json that is not a manifest";
|
|
65
|
+
};
|
|
66
|
+
readonly 'vendor-script-missing': {
|
|
67
|
+
readonly level: "error";
|
|
68
|
+
readonly means: "a built plugin’s manifest naming no script to run, or one that is not there";
|
|
69
|
+
};
|
|
70
|
+
readonly 'env-in-src': {
|
|
71
|
+
readonly level: "error";
|
|
72
|
+
readonly means: ".env inside src/: Node reads the project’s settings from the .env at its root";
|
|
73
|
+
};
|
|
74
|
+
readonly 'folder-misplaced': {
|
|
75
|
+
readonly level: "error";
|
|
76
|
+
readonly means: "code in a folder named like one the server reads (src/plugin/, plugins/ at the root): nothing reads it";
|
|
77
|
+
};
|
|
78
|
+
readonly 'folder-near-miss': {
|
|
79
|
+
readonly level: "warning";
|
|
80
|
+
readonly means: "a folder named like one the server reads (src/Data/, src/runtimes/), which nothing reads";
|
|
81
|
+
};
|
|
82
|
+
readonly 'plugin-declaration-missing': {
|
|
83
|
+
readonly level: "warning";
|
|
84
|
+
readonly means: "a plugin folder with no declaration.ts: the space’s use of the plugin is held to nothing";
|
|
85
|
+
};
|
|
86
|
+
readonly 'plugin-file-loose': {
|
|
87
|
+
readonly level: "warning";
|
|
88
|
+
readonly means: "a file directly in src/plugins/, where every plugin is a folder";
|
|
89
|
+
};
|
|
90
|
+
readonly 'data-not-json': {
|
|
91
|
+
readonly level: "warning";
|
|
92
|
+
readonly means: "a file of src/data/ that is not JSON, which no provider and no ctx.data reads";
|
|
93
|
+
};
|
|
94
|
+
readonly 'env-missing': {
|
|
95
|
+
readonly level: "warning";
|
|
96
|
+
readonly means: "no .env at the project’s root: none of its settings is set";
|
|
97
|
+
};
|
|
98
|
+
readonly 'env-example-missing': {
|
|
99
|
+
readonly level: "warning";
|
|
100
|
+
readonly means: "no .env.example: a clone does not know what .env must hold";
|
|
101
|
+
};
|
|
102
|
+
readonly 'public-data': {
|
|
103
|
+
readonly level: "warning";
|
|
104
|
+
readonly means: "JSON in public/data/ of a project with a server: served to anyone who asks";
|
|
105
|
+
};
|
|
106
|
+
readonly 'public-secret-file': {
|
|
107
|
+
readonly level: "warning";
|
|
108
|
+
readonly means: "a file in public/ named like a secret (.env, a key, a dump): served to anyone who asks";
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export type LayoutCode = keyof typeof PROJECT_LAYOUT_CODES;
|
|
112
|
+
/**
|
|
113
|
+
* The fix of a finding that has one reading, for `plitzi doctor --fix` to make. Paths are relative to the root, a
|
|
114
|
+
* folder's ending in `/`: a `move` of a folder takes everything under it, into a folder that may already be there.
|
|
115
|
+
*/
|
|
116
|
+
export type LayoutAutofix = {
|
|
117
|
+
action: 'move';
|
|
118
|
+
from: string;
|
|
119
|
+
to: string;
|
|
120
|
+
} | {
|
|
121
|
+
action: 'copy';
|
|
122
|
+
from: string;
|
|
123
|
+
to: string;
|
|
124
|
+
} | {
|
|
125
|
+
action: 'write';
|
|
126
|
+
file: string;
|
|
127
|
+
contents: string;
|
|
128
|
+
};
|
|
129
|
+
/** One thing out of place: where (`file`, relative to the root), what is wrong, and what to do — the command, if any. */
|
|
130
|
+
export interface LayoutFinding {
|
|
131
|
+
level: LayoutLevel;
|
|
132
|
+
code: LayoutCode;
|
|
133
|
+
file: string;
|
|
134
|
+
message: string;
|
|
135
|
+
fix: string;
|
|
136
|
+
autofix?: LayoutAutofix;
|
|
137
|
+
}
|
|
138
|
+
export interface ProjectLayoutOptions {
|
|
139
|
+
/** Whether the project runs a server of its own — told by its `@plitzi/sdk-server` dependency when left out. */
|
|
140
|
+
mode?: 'server' | 'client';
|
|
141
|
+
/** Where its space is: written in it (`src/space/`), or kept on Plitzi — told by its files when left out. */
|
|
142
|
+
space?: 'local' | 'cloud';
|
|
143
|
+
}
|
|
144
|
+
/** `src/plugins/StatCard` is the plugin `statCard`: what the server registers a folder as. */
|
|
145
|
+
export declare const pluginTypeOf: (folder: string) => string;
|
|
146
|
+
/**
|
|
147
|
+
* The file an element's folder is built from, wherever the folder is — its `index.ts`, or `index.tsx` — or nothing
|
|
148
|
+
* when it has neither, or both: what `plitzi pack plugin` builds a folder from, as the server does.
|
|
149
|
+
*/
|
|
150
|
+
export declare const elementEntry: (dir: string) => string | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* The file a folder of `src/plugins/` is built from (`elementEntry`) — or nothing when it is no plugin the server can
|
|
153
|
+
* build: a name that is no element type, no entry, or both. What the server registers, and what `checkPluginFolder`
|
|
154
|
+
* says why of.
|
|
155
|
+
*/
|
|
156
|
+
export declare const pluginEntry: (root: string, folder: string) => string | undefined;
|
|
157
|
+
/**
|
|
158
|
+
* One folder of `src/plugins/` as the server reads it: a name that is a type, the entry it is built from, its server
|
|
159
|
+
* half's entry, and its declaration. What the server says of a folder added while it runs, and what
|
|
160
|
+
* `checkProjectLayout` says of each.
|
|
161
|
+
*/
|
|
162
|
+
export declare const checkPluginFolder: (root: string, folder: string) => LayoutFinding[];
|
|
163
|
+
/** What a built plugin runs, by absolute path: its script, its style and its server half, as its manifest names them. */
|
|
164
|
+
export interface VendorPlugin {
|
|
165
|
+
script: string;
|
|
166
|
+
style?: string;
|
|
167
|
+
version: string;
|
|
168
|
+
functions?: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* A plugin of `vendor/plugins/` — one a project made from a space runs as it was built, beside the manifest `plitzi
|
|
172
|
+
* pack plugin` wrote when it was published — or what keeps it from running.
|
|
173
|
+
*/
|
|
174
|
+
export declare const readVendorPlugin: (root: string, type: string) => VendorPlugin | {
|
|
175
|
+
problem: LayoutFinding;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Everything out of place in the project at `root`, errors first: what its server, its authoring and `plitzi doctor`
|
|
179
|
+
* say of its layout. `PROJECT_LAYOUT_CODES` says what each code means.
|
|
180
|
+
*/
|
|
181
|
+
export declare const checkProjectLayout: (root: string, options?: ProjectLayoutOptions) => LayoutFinding[];
|
|
182
|
+
/** One finding as the terminal says it: what is wrong, then what to do. */
|
|
183
|
+
export declare const layoutFindingText: (layoutFinding: LayoutFinding) => string;
|
|
184
|
+
/**
|
|
185
|
+
* The errors of a project's layout, every one at once: what its server and its authoring refuse to start with.
|
|
186
|
+
* `findings` holds them as data, for a tool that says them its own way.
|
|
187
|
+
*/
|
|
188
|
+
export declare class ProjectLayoutError extends Error {
|
|
189
|
+
#private;
|
|
190
|
+
get findings(): readonly LayoutFinding[];
|
|
191
|
+
constructor(findings: readonly LayoutFinding[]);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The project's layout, refused with every error at once (`ProjectLayoutError`) — what its server and its authoring
|
|
195
|
+
* check before anything else — and its warnings answered, for the caller to say.
|
|
196
|
+
*/
|
|
197
|
+
export declare const assertProjectLayout: (root: string, options?: ProjectLayoutOptions) => LayoutFinding[];
|