@webstudio-is/sdk 0.201.0 → 0.203.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +30 -19
- package/lib/types/expression.d.ts +3 -0
- package/lib/types/schema/deployment.d.ts +4 -4
- package/package.json +6 -6
package/lib/index.js
CHANGED
|
@@ -430,6 +430,7 @@ var Templates = z11.enum([
|
|
|
430
430
|
"vanilla",
|
|
431
431
|
"docker",
|
|
432
432
|
"vercel",
|
|
433
|
+
"netlify",
|
|
433
434
|
"netlify-functions",
|
|
434
435
|
"netlify-edge-functions",
|
|
435
436
|
"ssg",
|
|
@@ -967,7 +968,10 @@ var parseComponentName = (componentName) => {
|
|
|
967
968
|
};
|
|
968
969
|
|
|
969
970
|
// src/expression.ts
|
|
970
|
-
import {
|
|
971
|
+
import {
|
|
972
|
+
parse,
|
|
973
|
+
parseExpressionAt
|
|
974
|
+
} from "acorn";
|
|
971
975
|
import { simple } from "acorn-walk";
|
|
972
976
|
var lintExpression = ({
|
|
973
977
|
expression,
|
|
@@ -975,13 +979,13 @@ var lintExpression = ({
|
|
|
975
979
|
allowAssignment = false
|
|
976
980
|
}) => {
|
|
977
981
|
const diagnostics = [];
|
|
978
|
-
const
|
|
982
|
+
const addMessage = (message, severity = "error") => {
|
|
979
983
|
return (node) => {
|
|
980
984
|
diagnostics.push({
|
|
981
985
|
// tune error position after wrapping expression with parentheses
|
|
982
986
|
from: node.start - 1,
|
|
983
987
|
to: node.end - 1,
|
|
984
|
-
severity
|
|
988
|
+
severity,
|
|
985
989
|
message
|
|
986
990
|
});
|
|
987
991
|
};
|
|
@@ -996,7 +1000,7 @@ var lintExpression = ({
|
|
|
996
1000
|
return diagnostics;
|
|
997
1001
|
}
|
|
998
1002
|
try {
|
|
999
|
-
const root =
|
|
1003
|
+
const root = parse(`(${expression})`, {
|
|
1000
1004
|
ecmaVersion: "latest",
|
|
1001
1005
|
// support parsing import to forbid explicitly
|
|
1002
1006
|
sourceType: "module"
|
|
@@ -1004,7 +1008,10 @@ var lintExpression = ({
|
|
|
1004
1008
|
simple(root, {
|
|
1005
1009
|
Identifier(node) {
|
|
1006
1010
|
if (availableVariables.has(node.name) === false) {
|
|
1007
|
-
|
|
1011
|
+
addMessage(
|
|
1012
|
+
`"${node.name}" is not defined in the scope`,
|
|
1013
|
+
"warning"
|
|
1014
|
+
)(node);
|
|
1008
1015
|
}
|
|
1009
1016
|
},
|
|
1010
1017
|
Literal() {
|
|
@@ -1031,13 +1038,16 @@ var lintExpression = ({
|
|
|
1031
1038
|
},
|
|
1032
1039
|
AssignmentExpression(node) {
|
|
1033
1040
|
if (allowAssignment === false) {
|
|
1034
|
-
|
|
1041
|
+
addMessage("Assignment is supported only inside actions")(node);
|
|
1035
1042
|
return;
|
|
1036
1043
|
}
|
|
1037
1044
|
simple(node.left, {
|
|
1038
1045
|
Identifier(node2) {
|
|
1039
1046
|
if (availableVariables.has(node2.name) === false) {
|
|
1040
|
-
|
|
1047
|
+
addMessage(
|
|
1048
|
+
`"${node2.name}" is not defined in the scope`,
|
|
1049
|
+
"warning"
|
|
1050
|
+
)(node2);
|
|
1041
1051
|
}
|
|
1042
1052
|
}
|
|
1043
1053
|
});
|
|
@@ -1045,18 +1055,18 @@ var lintExpression = ({
|
|
|
1045
1055
|
// parser forbids to yield inside module
|
|
1046
1056
|
YieldExpression() {
|
|
1047
1057
|
},
|
|
1048
|
-
ThisExpression:
|
|
1049
|
-
FunctionExpression:
|
|
1050
|
-
UpdateExpression:
|
|
1051
|
-
CallExpression:
|
|
1052
|
-
NewExpression:
|
|
1053
|
-
SequenceExpression:
|
|
1054
|
-
ArrowFunctionExpression:
|
|
1055
|
-
TaggedTemplateExpression:
|
|
1056
|
-
ClassExpression:
|
|
1057
|
-
MetaProperty:
|
|
1058
|
-
AwaitExpression:
|
|
1059
|
-
ImportExpression:
|
|
1058
|
+
ThisExpression: addMessage(`"this" keyword is not supported`),
|
|
1059
|
+
FunctionExpression: addMessage("Functions are not supported"),
|
|
1060
|
+
UpdateExpression: addMessage("Increment and decrement are not supported"),
|
|
1061
|
+
CallExpression: addMessage("Functions are not supported"),
|
|
1062
|
+
NewExpression: addMessage("Classes are not supported"),
|
|
1063
|
+
SequenceExpression: addMessage(`Only single expression is supported`),
|
|
1064
|
+
ArrowFunctionExpression: addMessage("Functions are not supported"),
|
|
1065
|
+
TaggedTemplateExpression: addMessage("Tagged template is not supported"),
|
|
1066
|
+
ClassExpression: addMessage("Classes are not supported"),
|
|
1067
|
+
MetaProperty: addMessage("Imports are not supported"),
|
|
1068
|
+
AwaitExpression: addMessage(`"await" keyword is not supported`),
|
|
1069
|
+
ImportExpression: addMessage("Imports are not supported")
|
|
1060
1070
|
});
|
|
1061
1071
|
} catch (error) {
|
|
1062
1072
|
const castedError = error;
|
|
@@ -1241,6 +1251,7 @@ var generateExpression = ({
|
|
|
1241
1251
|
usedDataSources?.set(dep.id, dep);
|
|
1242
1252
|
return scope.getName(dep.id, dep.name);
|
|
1243
1253
|
}
|
|
1254
|
+
return "undefined";
|
|
1244
1255
|
}
|
|
1245
1256
|
});
|
|
1246
1257
|
};
|
|
@@ -52,4 +52,7 @@ export declare const generateExpression: ({ expression, dataSources, usedDataSou
|
|
|
52
52
|
usedDataSources: DataSources;
|
|
53
53
|
scope: Scope;
|
|
54
54
|
}) => string;
|
|
55
|
+
/**
|
|
56
|
+
* edge case utility for "statoc" expression without variables
|
|
57
|
+
*/
|
|
55
58
|
export declare const executeExpression: (expression: undefined | string) => any;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const Templates: z.ZodEnum<["vanilla", "docker", "vercel", "netlify-functions", "netlify-edge-functions", "ssg", "ssg-netlify", "ssg-vercel"]>;
|
|
2
|
+
export declare const Templates: z.ZodEnum<["vanilla", "docker", "vercel", "netlify", "netlify-functions", "netlify-edge-functions", "ssg", "ssg-netlify", "ssg-vercel"]>;
|
|
3
3
|
export type Templates = z.infer<typeof Templates>;
|
|
4
4
|
export declare const Deployment: z.ZodUnion<[z.ZodObject<{
|
|
5
5
|
destination: z.ZodLiteral<"static">;
|
|
6
6
|
name: z.ZodString;
|
|
7
7
|
assetsDomain: z.ZodString;
|
|
8
|
-
templates: z.ZodArray<z.ZodEnum<["vanilla", "docker", "vercel", "netlify-functions", "netlify-edge-functions", "ssg", "ssg-netlify", "ssg-vercel"]>, "many">;
|
|
8
|
+
templates: z.ZodArray<z.ZodEnum<["vanilla", "docker", "vercel", "netlify", "netlify-functions", "netlify-edge-functions", "ssg", "ssg-netlify", "ssg-vercel"]>, "many">;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
10
|
name: string;
|
|
11
11
|
destination: "static";
|
|
12
12
|
assetsDomain: string;
|
|
13
|
-
templates: ("vanilla" | "docker" | "vercel" | "netlify-functions" | "netlify-edge-functions" | "ssg" | "ssg-netlify" | "ssg-vercel")[];
|
|
13
|
+
templates: ("vanilla" | "docker" | "vercel" | "netlify" | "netlify-functions" | "netlify-edge-functions" | "ssg" | "ssg-netlify" | "ssg-vercel")[];
|
|
14
14
|
}, {
|
|
15
15
|
name: string;
|
|
16
16
|
destination: "static";
|
|
17
17
|
assetsDomain: string;
|
|
18
|
-
templates: ("vanilla" | "docker" | "vercel" | "netlify-functions" | "netlify-edge-functions" | "ssg" | "ssg-netlify" | "ssg-vercel")[];
|
|
18
|
+
templates: ("vanilla" | "docker" | "vercel" | "netlify" | "netlify-functions" | "netlify-edge-functions" | "ssg" | "ssg-netlify" | "ssg-vercel")[];
|
|
19
19
|
}>, z.ZodObject<{
|
|
20
20
|
destination: z.ZodOptional<z.ZodLiteral<"saas">>;
|
|
21
21
|
domains: z.ZodArray<z.ZodString, "many">;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.203.0",
|
|
4
4
|
"description": "Webstudio project data schema",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -39,16 +39,16 @@
|
|
|
39
39
|
"reserved-identifiers": "^1.0.0",
|
|
40
40
|
"type-fest": "^4.32.0",
|
|
41
41
|
"zod": "^3.22.4",
|
|
42
|
-
"@webstudio-is/
|
|
43
|
-
"@webstudio-is/
|
|
44
|
-
"@webstudio-is/
|
|
42
|
+
"@webstudio-is/css-engine": "0.203.0",
|
|
43
|
+
"@webstudio-is/icons": "0.203.0",
|
|
44
|
+
"@webstudio-is/fonts": "0.203.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"html-tags": "^4.0.0",
|
|
48
48
|
"vitest": "^3.0.2",
|
|
49
|
-
"@webstudio-is/
|
|
49
|
+
"@webstudio-is/template": "0.203.0",
|
|
50
50
|
"@webstudio-is/tsconfig": "1.0.7",
|
|
51
|
-
"@webstudio-is/
|
|
51
|
+
"@webstudio-is/css-data": "0.0.0"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"typecheck": "tsc",
|