deployai 0.1.0-beta.19 → 0.1.0-beta.20

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.
Files changed (2) hide show
  1. package/dist/index.js +42 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -101,10 +101,10 @@ var ISSUES = [
101
101
  {
102
102
  code: "durable_objects",
103
103
  severity: "blocker",
104
- titleEn: "Uses Durable Objects, not supported yet",
105
- titleHe: "\u05D4\u05D0\u05EA\u05E8 \u05DE\u05E9\u05EA\u05DE\u05E9 \u05D1\u05BEDurable Objects, \u05E9\u05E2\u05D5\u05D3 \u05DC\u05D0 \u05E0\u05EA\u05DE\u05DB\u05D9\u05DD",
106
- agentLine: "{loc} declares Durable Objects{detail}.",
107
- fixForAgent: "Durable Objects do not run on customer sites yet. Keep the data in D1 (SQLite) and remove durable_objects from the wrangler config. For live updates use polling or server-sent events."
104
+ titleEn: "Uses a Durable Object from another Worker",
105
+ titleHe: "\u05D4\u05D0\u05EA\u05E8 \u05DE\u05E9\u05EA\u05DE\u05E9 \u05D1\u05BEDurable Object \u05E9\u05DC Worker \u05D0\u05D7\u05E8",
106
+ agentLine: "{loc} binds a Durable Object from another Worker (script_name) or without a class_name{detail}.",
107
+ fixForAgent: "A site here can use only the Durable Objects its own code exports. Export the class from this site's Worker, give the binding a name and a class_name, and remove script_name."
108
108
  },
109
109
  {
110
110
  code: "bundle_too_large",
@@ -740,7 +740,22 @@ function jsoncToJson(src) {
740
740
  function durableObjectsOf(v) {
741
741
  const list = v && typeof v === "object" ? v.bindings : null;
742
742
  if (!Array.isArray(list)) return [];
743
- return list.map((x) => x && typeof x === "object" && typeof x.name === "string" ? x.name : "");
743
+ const str2 = (x) => typeof x === "string" ? x : "";
744
+ return list.map((x) => {
745
+ const o = x && typeof x === "object" ? x : {};
746
+ return { name: str2(o.name), className: str2(o.class_name), script: str2(o.script_name) || null };
747
+ });
748
+ }
749
+ function tomlDurableObjects(value) {
750
+ const q = (t, k) => new RegExp(`\\b${k}\\s*=\\s*(?:"([^"]+)"|'([^']+)')`).exec(t);
751
+ return [...value.matchAll(/\{([^}]*)\}/g)].map((m) => {
752
+ const t = m[1];
753
+ const pick2 = (k) => {
754
+ const r = q(t, k);
755
+ return r ? r[1] ?? r[2] : "";
756
+ };
757
+ return { name: pick2("name"), className: pick2("class_name"), script: pick2("script_name") || null };
758
+ });
744
759
  }
745
760
  function bindingsOf(list) {
746
761
  if (!Array.isArray(list)) return [];
@@ -784,7 +799,7 @@ function parseWranglerToml(text) {
784
799
  section = `[[${arr[1]}]]`;
785
800
  if (arr[1] === "d1_databases") decl.d1.push({ binding: "" });
786
801
  if (arr[1] === "r2_buckets") decl.r2.push({ binding: "" });
787
- if (arr[1] === "durable_objects.bindings") decl.durableObjects.push("");
802
+ if (arr[1] === "durable_objects.bindings") decl.durableObjects.push({ name: "", className: "", script: null });
788
803
  continue;
789
804
  }
790
805
  const tbl = /^\[\s*([\w.]+)\s*\]$/.exec(line);
@@ -805,12 +820,17 @@ function parseWranglerToml(text) {
805
820
  for (const m of value.matchAll(/binding\s*=\s*(?:"([^"]+)"|'([^']+)')/g)) target.push({ binding: m[1] ?? m[2] });
806
821
  }
807
822
  if (key === "vars") for (const m of value.matchAll(/([\w-]+)\s*=/g)) decl.vars.push(m[1]);
808
- if (key === "durable_objects") for (const m of value.matchAll(/\bname\s*=\s*(?:"([^"]+)"|'([^']+)')/g)) decl.durableObjects.push(m[1] ?? m[2]);
823
+ if (key === "durable_objects") decl.durableObjects.push(...tomlDurableObjects(value));
809
824
  } else if (section === "durable_objects" && key === "bindings") {
810
- for (const m of value.matchAll(/\bname\s*=\s*(?:"([^"]+)"|'([^']+)')/g)) decl.durableObjects.push(m[1] ?? m[2]);
811
- } else if (section === "[[durable_objects.bindings]]" && key === "name") {
825
+ decl.durableObjects.push(...tomlDurableObjects(value));
826
+ } else if (section === "[[durable_objects.bindings]]" && (key === "name" || key === "class_name" || key === "script_name")) {
812
827
  const v = tomlString(value);
813
- if (v != null) decl.durableObjects[decl.durableObjects.length - 1] = v;
828
+ const last = decl.durableObjects[decl.durableObjects.length - 1];
829
+ if (v != null && last) {
830
+ if (key === "name") last.name = v;
831
+ else if (key === "class_name") last.className = v;
832
+ else last.script = v || null;
833
+ }
814
834
  } else if (section === "vars") {
815
835
  decl.vars.push(key);
816
836
  } else if (section === "assets" && key === "directory") {
@@ -959,15 +979,15 @@ var ISSUE_HELP = {
959
979
  },
960
980
  durable_objects: {
961
981
  he: {
962
- what: "\u05D4\u05D2\u05D3\u05E8\u05D5\u05EA \u05D4\u05D0\u05EA\u05E8 (wrangler) \u05DE\u05D1\u05E7\u05E9\u05D5\u05EA Durable Objects, \u05D0\u05D7\u05E1\u05D5\u05DF \u05DC\u05DE\u05E6\u05D1 \u05D7\u05D9 \u05DB\u05DE\u05D5 \u05E6\u05F3\u05D0\u05D8 \u05D0\u05D5 \u05DE\u05D5\u05E0\u05D9\u05DD.",
963
- why: "\u05D0\u05EA\u05E8\u05D9\u05DD \u05E9\u05DC \u05DC\u05E7\u05D5\u05D7\u05D5\u05EA \u05E2\u05D5\u05D3 \u05DC\u05D0 \u05D9\u05DB\u05D5\u05DC\u05D9\u05DD \u05DC\u05D4\u05E9\u05EA\u05DE\u05E9 \u05D1\u05D4\u05DD. \u05D4\u05D0\u05EA\u05E8 \u05D4\u05D9\u05D4 \u05E2\u05D5\u05DC\u05D4 \u05D5\u05E0\u05D5\u05E4\u05DC \u05D1\u05D1\u05E7\u05E9\u05D4 \u05D4\u05E8\u05D0\u05E9\u05D5\u05E0\u05D4 \u05E9\u05DE\u05D2\u05D9\u05E2\u05D4 \u05D0\u05DC\u05D9\u05D4\u05DD, \u05DC\u05DB\u05DF \u05D4\u05D5\u05D0 \u05DC\u05D0 \u05D9\u05E2\u05DC\u05D4.",
964
- fix: ["\u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD \u05E0\u05E9\u05DE\u05E8\u05D9\u05DD \u05D1\u05DE\u05E1\u05D3 \u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD \u05E9\u05DC \u05D4\u05D0\u05EA\u05E8.", "\u05DC\u05E2\u05D3\u05DB\u05D5\u05E0\u05D9\u05DD \u05D7\u05D9\u05D9\u05DD \u05D1\u05D5\u05D3\u05E7\u05D9\u05DD \u05DE\u05D7\u05D3\u05E9 \u05DB\u05DC \u05DB\u05DE\u05D4 \u05E9\u05E0\u05D9\u05D5\u05EA, \u05D0\u05D5 \u05DE\u05E9\u05EA\u05DE\u05E9\u05D9\u05DD \u05D1\u05D6\u05E8\u05DD \u05E2\u05D3\u05DB\u05D5\u05E0\u05D9\u05DD \u05DE\u05D4\u05E9\u05E8\u05EA."],
965
- prompt: "Durable Objects \u05DC\u05D0 \u05E8\u05E6\u05D9\u05DD \u05E2\u05D3\u05D9\u05D9\u05DF \u05D1\u05D0\u05EA\u05E8\u05D9\u05DD \u05E9\u05DC \u05DC\u05E7\u05D5\u05D7\u05D5\u05EA. \u05E9\u05DE\u05D5\u05E8 \u05D0\u05EA \u05D4\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD \u05D1\u05BED1 (SQLite) \u05D5\u05D4\u05E1\u05E8 \u05D0\u05EA durable_objects \u05DE\u05E7\u05D5\u05D1\u05E5 \u05D4\u05BEwrangler. \u05DC\u05E2\u05D3\u05DB\u05D5\u05E0\u05D9\u05DD \u05D7\u05D9\u05D9\u05DD \u05D4\u05E9\u05EA\u05DE\u05E9 \u05D1\u05BEpolling \u05D0\u05D5 \u05D1\u05BEserver-sent events."
982
+ what: "\u05D4\u05D2\u05D3\u05E8\u05D5\u05EA \u05D4\u05D0\u05EA\u05E8 (wrangler) \u05DE\u05D1\u05E7\u05E9\u05D5\u05EA Durable Object \u05E9\u05E0\u05DE\u05E6\u05D0 \u05D1\u05BEWorker \u05D0\u05D7\u05E8, \u05D0\u05D5 \u05D1\u05DC\u05D9 \u05E9\u05DD \u05DE\u05D7\u05DC\u05E7\u05D4.",
983
+ why: "\u05D0\u05EA\u05E8 \u05D0\u05E6\u05DC\u05E0\u05D5 \u05D9\u05DB\u05D5\u05DC \u05DC\u05D4\u05E9\u05EA\u05DE\u05E9 \u05E8\u05E7 \u05D1\u05BEDurable Objects \u05E9\u05D4\u05E7\u05D5\u05D3 \u05E9\u05DC\u05D5 \u05E2\u05E6\u05DE\u05D5 \u05DE\u05D9\u05D9\u05E6\u05D0. \u05D4\u05D0\u05EA\u05E8 \u05D4\u05D9\u05D4 \u05E2\u05D5\u05DC\u05D4 \u05D5\u05E0\u05D5\u05E4\u05DC \u05D1\u05D1\u05E7\u05E9\u05D4 \u05D4\u05E8\u05D0\u05E9\u05D5\u05E0\u05D4 \u05E9\u05DE\u05D2\u05D9\u05E2\u05D4 \u05DC\u05D0\u05D7\u05D3 \u05DB\u05D6\u05D4, \u05DC\u05DB\u05DF \u05D4\u05D5\u05D0 \u05DC\u05D0 \u05D9\u05E2\u05DC\u05D4.",
984
+ fix: ["\u05DE\u05D9\u05D9\u05E6\u05D0\u05D9\u05DD \u05D0\u05EA \u05D4\u05DE\u05D7\u05DC\u05E7\u05D4 \u05DE\u05D4\u05E7\u05D5\u05D3 \u05E9\u05DC \u05D4\u05D0\u05EA\u05E8 \u05E2\u05E6\u05DE\u05D5.", "\u05DC\u05DB\u05DC Durable Object \u05E0\u05D5\u05EA\u05E0\u05D9\u05DD name \u05D5\u05BEclass_name, \u05D5\u05DE\u05D5\u05D7\u05E7\u05D9\u05DD \u05D0\u05EA script_name."],
985
+ prompt: "\u05D0\u05EA\u05E8 \u05D0\u05E6\u05DC\u05E0\u05D5 \u05D9\u05DB\u05D5\u05DC \u05DC\u05D4\u05E9\u05EA\u05DE\u05E9 \u05E8\u05E7 \u05D1\u05BEDurable Objects \u05E9\u05D4\u05E7\u05D5\u05D3 \u05E9\u05DC\u05D5 \u05DE\u05D9\u05D9\u05E6\u05D0. \u05D9\u05D9\u05E6\u05D0 \u05D0\u05EA \u05D4\u05DE\u05D7\u05DC\u05E7\u05D4 \u05DE\u05D4\u05BEWorker \u05E9\u05DC \u05D4\u05D0\u05EA\u05E8, \u05EA\u05DF \u05DC\u05DB\u05DC binding \u05E9\u05DD \u05D5\u05BEclass_name, \u05D5\u05D4\u05E1\u05E8 \u05D0\u05EA script_name \u05DE\u05E7\u05D5\u05D1\u05E5 \u05D4\u05BEwrangler."
966
986
  },
967
987
  en: {
968
- what: "The site settings (wrangler) ask for Durable Objects, storage for live state such as a chat or counters.",
969
- why: "Customer sites cannot use them yet. The site would go live and then fail on the first request that reaches one, so it will not go live.",
970
- fix: ["Keep the data in the site database.", "For live updates, check again every few seconds, or use a stream of updates from the server."]
988
+ what: "The site settings (wrangler) ask for a Durable Object that lives in another Worker, or one without a class name.",
989
+ why: "A site here can use only the Durable Objects its own code exports. The site would go live and then fail on the first request that reaches such one, so it will not go live.",
990
+ fix: ["Export the class from the site's own code.", "Give each Durable Object a name and a class_name, and remove script_name."]
971
991
  }
972
992
  },
973
993
  websocket_server: {
@@ -22077,8 +22097,8 @@ var BUILD_WITH = [
22077
22097
  "Images: resize at build time or serve them as they are; no native image modules at runtime.",
22078
22098
  "Passwords: bcryptjs or Web Crypto, never native bcrypt.",
22079
22099
  "Server code runs per request: no long-running processes, background servers or child processes.",
22080
- // D-574: a customer site cannot use Durable Objects yet; it would deploy and fail on its first request that reaches one.
22081
- "No Durable Objects yet: keep state in D1, and use polling or server-sent events for live updates.",
22100
+ // D-611: Durable Objects run when the site's own code exports them; D1 stays the default, they cost more for plain data.
22101
+ "Data goes in D1 by default. Use a Durable Object only for live state that needs one place to coordinate (a chat room, a live counter, booking slots that must not double-book, presence): export the class from this site's Worker and bind it with a name and class_name in the wrangler config, never script_name. Never remove or rename a class once it is live: that would delete its data, so the upload is refused. A preview starts with empty objects.",
22082
22102
  // D-535: the agent knows our built-in email, so it never adds an email provider or asks the owner for keys to email them.
22083
22103
  "Email to the site owner (a form answer, a new order): the built-in email, with no email provider or keys. POST JSON { subject, text, replyTo } to `${DEPLOYAI_API}/api/site/notify` with the header Authorization: Bearer DEPLOYAI_KEY (both are environment variables every upload gets). It reaches only the owner. On a temporary site it works once the owner has a free account: keep building, and say so only when it is time to go live. Email to customers needs an HTTP email API (Resend, Postmark), never SMTP."
22084
22104
  ];
@@ -22913,7 +22933,7 @@ function messages(root) {
22913
22933
  }
22914
22934
 
22915
22935
  // src/version.ts
22916
- var CLI_VERSION = "0.1.0-beta.19";
22936
+ var CLI_VERSION = "0.1.0-beta.20";
22917
22937
 
22918
22938
  // src/api.ts
22919
22939
  function apiContext(apiFlag) {
@@ -23631,8 +23651,8 @@ function analyzeProject(root) {
23631
23651
  for (const name of ["wrangler.toml", "wrangler.json", "wrangler.jsonc"]) {
23632
23652
  if (!existsSync4(join4(root, name))) continue;
23633
23653
  const text = readFileSync4(join4(root, name), "utf8");
23634
- if (!parseWranglerConfig(name, text).durableObjects.length) break;
23635
- const at = text.search(/durable_objects/);
23654
+ if (!parseWranglerConfig(name, text).durableObjects.some((o) => o.script || !o.name || !o.className)) break;
23655
+ const at = text.search(/script_name/) >= 0 ? text.search(/script_name/) : text.search(/durable_objects/);
23636
23656
  add({ code: "durable_objects", severity: "blocker", file: name, line: at < 0 ? 1 : text.slice(0, at).split("\n").length, detail: "" });
23637
23657
  break;
23638
23658
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deployai",
3
- "version": "0.1.0-beta.19",
3
+ "version": "0.1.0-beta.20",
4
4
  "description": "Check a site built with an AI editor, see what has to change, and publish it to DeployAI. Hebrew first.",
5
5
  "keywords": [
6
6
  "deployai",