@webstudio-is/sdk 0.0.0-4f7bf18 → 0.0.0-5844e28

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 CHANGED
@@ -88,7 +88,10 @@ var HomePage = z2.object({
88
88
  ...commonPageFields,
89
89
  path: HomePagePath
90
90
  });
91
- var PagePath = z2.string().refine((path) => path !== "", "Can't be empty").refine((path) => path !== "/", "Can't be just a /").refine((path) => path === "" || path.startsWith("/"), "Must start with a /").refine((path) => path.endsWith("/") === false, "Can't end with a /").refine((path) => path.includes("//") === false, "Can't contain repeating /").refine(
91
+ var PagePath = z2.string().refine((path) => path !== "", "Can't be empty").refine((path) => path !== "/", "Can't be just a /").refine(
92
+ (path) => path === "" || path.startsWith("/"),
93
+ "Must start with a / or a full URL e.g. https://website.org"
94
+ ).refine((path) => path.endsWith("/") === false, "Can't end with a /").refine((path) => path.includes("//") === false, "Can't contain repeating /").refine(
92
95
  (path) => /^[-_a-z0-9*:?\\/.]*$/.test(path),
93
96
  "Only a-z, 0-9, -, _, /, :, ?, . and * are allowed"
94
97
  ).refine(
@@ -428,9 +431,10 @@ var Styles = z10.map(z10.string(), StyleDecl);
428
431
  import { z as z11 } from "zod";
429
432
  var Templates = z11.enum([
430
433
  "vanilla",
434
+ "docker",
431
435
  "vercel",
432
- "netlify-functions",
433
- "netlify-edge-functions",
436
+ "vercel-legacy",
437
+ "netlify",
434
438
  "ssg",
435
439
  "ssg-netlify",
436
440
  "ssg-vercel"
@@ -966,7 +970,10 @@ var parseComponentName = (componentName) => {
966
970
  };
967
971
 
968
972
  // src/expression.ts
969
- import { parseExpressionAt } from "acorn";
973
+ import {
974
+ parse,
975
+ parseExpressionAt
976
+ } from "acorn";
970
977
  import { simple } from "acorn-walk";
971
978
  var lintExpression = ({
972
979
  expression,
@@ -974,13 +981,13 @@ var lintExpression = ({
974
981
  allowAssignment = false
975
982
  }) => {
976
983
  const diagnostics = [];
977
- const addError = (message) => {
984
+ const addMessage = (message, severity = "error") => {
978
985
  return (node) => {
979
986
  diagnostics.push({
980
987
  // tune error position after wrapping expression with parentheses
981
988
  from: node.start - 1,
982
989
  to: node.end - 1,
983
- severity: "error",
990
+ severity,
984
991
  message
985
992
  });
986
993
  };
@@ -995,7 +1002,7 @@ var lintExpression = ({
995
1002
  return diagnostics;
996
1003
  }
997
1004
  try {
998
- const root = parseExpressionAt(`(${expression})`, 0, {
1005
+ const root = parse(`(${expression})`, {
999
1006
  ecmaVersion: "latest",
1000
1007
  // support parsing import to forbid explicitly
1001
1008
  sourceType: "module"
@@ -1003,7 +1010,10 @@ var lintExpression = ({
1003
1010
  simple(root, {
1004
1011
  Identifier(node) {
1005
1012
  if (availableVariables.has(node.name) === false) {
1006
- addError(`"${node.name}" is not defined in the scope`)(node);
1013
+ addMessage(
1014
+ `"${node.name}" is not defined in the scope`,
1015
+ "warning"
1016
+ )(node);
1007
1017
  }
1008
1018
  },
1009
1019
  Literal() {
@@ -1030,13 +1040,16 @@ var lintExpression = ({
1030
1040
  },
1031
1041
  AssignmentExpression(node) {
1032
1042
  if (allowAssignment === false) {
1033
- addError("Assignment is supported only inside actions")(node);
1043
+ addMessage("Assignment is supported only inside actions")(node);
1034
1044
  return;
1035
1045
  }
1036
1046
  simple(node.left, {
1037
1047
  Identifier(node2) {
1038
1048
  if (availableVariables.has(node2.name) === false) {
1039
- addError(`"${node2.name}" is not defined in the scope`)(node2);
1049
+ addMessage(
1050
+ `"${node2.name}" is not defined in the scope`,
1051
+ "warning"
1052
+ )(node2);
1040
1053
  }
1041
1054
  }
1042
1055
  });
@@ -1044,18 +1057,18 @@ var lintExpression = ({
1044
1057
  // parser forbids to yield inside module
1045
1058
  YieldExpression() {
1046
1059
  },
1047
- ThisExpression: addError(`"this" keyword is not supported`),
1048
- FunctionExpression: addError("Functions are not supported"),
1049
- UpdateExpression: addError("Increment and decrement are not supported"),
1050
- CallExpression: addError("Functions are not supported"),
1051
- NewExpression: addError("Classes are not supported"),
1052
- SequenceExpression: addError(`Only single expression is supported`),
1053
- ArrowFunctionExpression: addError("Functions are not supported"),
1054
- TaggedTemplateExpression: addError("Tagged template is not supported"),
1055
- ClassExpression: addError("Classes are not supported"),
1056
- MetaProperty: addError("Imports are not supported"),
1057
- AwaitExpression: addError(`"await" keyword is not supported`),
1058
- ImportExpression: addError("Imports are not supported")
1060
+ ThisExpression: addMessage(`"this" keyword is not supported`),
1061
+ FunctionExpression: addMessage("Functions are not supported"),
1062
+ UpdateExpression: addMessage("Increment and decrement are not supported"),
1063
+ CallExpression: addMessage("Functions are not supported"),
1064
+ NewExpression: addMessage("Classes are not supported"),
1065
+ SequenceExpression: addMessage(`Only single expression is supported`),
1066
+ ArrowFunctionExpression: addMessage("Functions are not supported"),
1067
+ TaggedTemplateExpression: addMessage("Tagged template is not supported"),
1068
+ ClassExpression: addMessage("Classes are not supported"),
1069
+ MetaProperty: addMessage("Imports are not supported"),
1070
+ AwaitExpression: addMessage(`"await" keyword is not supported`),
1071
+ ImportExpression: addMessage("Imports are not supported")
1059
1072
  });
1060
1073
  } catch (error) {
1061
1074
  const castedError = error;
@@ -1240,6 +1253,7 @@ var generateExpression = ({
1240
1253
  usedDataSources?.set(dep.id, dep);
1241
1254
  return scope.getName(dep.id, dep.name);
1242
1255
  }
1256
+ return "undefined";
1243
1257
  }
1244
1258
  });
1245
1259
  };
@@ -1736,10 +1750,12 @@ export {
1736
1750
  corePropsMetas,
1737
1751
  createScope,
1738
1752
  decodeDataSourceVariable,
1753
+ decodeDataSourceVariable as decodeDataVariableId,
1739
1754
  defaultStates,
1740
1755
  descendantComponent,
1741
1756
  documentTypes,
1742
1757
  encodeDataSourceVariable,
1758
+ encodeDataSourceVariable as encodeDataVariableId,
1743
1759
  executeExpression,
1744
1760
  findPageByIdOrPath,
1745
1761
  findParentFolderByChildId,
@@ -43,11 +43,16 @@ export declare const parseObjectExpression: (expression: string) => Map<string,
43
43
  */
44
44
  export declare const generateObjectExpression: (map: Map<string, string>) => string;
45
45
  export declare const encodeDataSourceVariable: (id: string) => string;
46
+ export { encodeDataSourceVariable as encodeDataVariableId };
46
47
  export declare const decodeDataSourceVariable: (name: string) => string | undefined;
48
+ export { decodeDataSourceVariable as decodeDataVariableId };
47
49
  export declare const generateExpression: ({ expression, dataSources, usedDataSources, scope, }: {
48
50
  expression: string;
49
51
  dataSources: DataSources;
50
52
  usedDataSources: DataSources;
51
53
  scope: Scope;
52
54
  }) => string;
55
+ /**
56
+ * edge case utility for "statoc" expression without variables
57
+ */
53
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", "vercel", "netlify-functions", "netlify-edge-functions", "ssg", "ssg-netlify", "ssg-vercel"]>;
2
+ export declare const Templates: z.ZodEnum<["vanilla", "docker", "vercel", "vercel-legacy", "netlify", "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", "vercel", "netlify-functions", "netlify-edge-functions", "ssg", "ssg-netlify", "ssg-vercel"]>, "many">;
8
+ templates: z.ZodArray<z.ZodEnum<["vanilla", "docker", "vercel", "vercel-legacy", "netlify", "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" | "vercel" | "netlify-functions" | "netlify-edge-functions" | "ssg" | "ssg-netlify" | "ssg-vercel")[];
13
+ templates: ("vanilla" | "docker" | "vercel" | "vercel-legacy" | "netlify" | "ssg" | "ssg-netlify" | "ssg-vercel")[];
14
14
  }, {
15
15
  name: string;
16
16
  destination: "static";
17
17
  assetsDomain: string;
18
- templates: ("vanilla" | "vercel" | "netlify-functions" | "netlify-edge-functions" | "ssg" | "ssg-netlify" | "ssg-vercel")[];
18
+ templates: ("vanilla" | "docker" | "vercel" | "vercel-legacy" | "netlify" | "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.0.0-4f7bf18",
3
+ "version": "0.0.0-5844e28",
4
4
  "description": "Webstudio project data schema",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -39,15 +39,15 @@
39
39
  "reserved-identifiers": "^1.0.0",
40
40
  "type-fest": "^4.32.0",
41
41
  "zod": "^3.22.4",
42
- "@webstudio-is/css-engine": "0.0.0-4f7bf18",
43
- "@webstudio-is/icons": "0.0.0-4f7bf18",
44
- "@webstudio-is/fonts": "0.0.0-4f7bf18"
42
+ "@webstudio-is/css-engine": "0.0.0-5844e28",
43
+ "@webstudio-is/fonts": "0.0.0-5844e28",
44
+ "@webstudio-is/icons": "0.0.0-5844e28"
45
45
  },
46
46
  "devDependencies": {
47
47
  "html-tags": "^4.0.0",
48
- "vitest": "^3.0.2",
48
+ "vitest": "^3.0.4",
49
+ "@webstudio-is/template": "0.0.0-5844e28",
49
50
  "@webstudio-is/css-data": "0.0.0",
50
- "@webstudio-is/template": "0.0.0-4f7bf18",
51
51
  "@webstudio-is/tsconfig": "1.0.7"
52
52
  },
53
53
  "scripts": {