@prisma/composer 0.34.0 → 0.35.0-dev.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.
Files changed (75) hide show
  1. package/dist/{app-config-BBPLNnZX-DzU21TVb.d.mts → app-config-B_gQYj3K-DpMi9a4K.d.mts} +61 -6
  2. package/dist/app-config-B_gQYj3K-DpMi9a4K.d.mts.map +1 -0
  3. package/dist/config-Bq3JlQ9_.d.mts +1 -0
  4. package/dist/config.d.mts +2 -2
  5. package/dist/control.d.mts +47 -19
  6. package/dist/control.d.mts.map +1 -1
  7. package/dist/control.mjs +3 -3
  8. package/dist/control.mjs.map +1 -1
  9. package/dist/deploy-Bq3JlQ9_.d.mts +1 -0
  10. package/dist/deploy.d.mts +3 -3
  11. package/dist/deploy.mjs +28 -1
  12. package/dist/deploy.mjs.map +1 -1
  13. package/dist/{deployment-summary-0-0eGWjc-ClB8FXcN.mjs → deployment-summary-CDHdLtnO-DrE7GsHq.mjs} +2 -2
  14. package/dist/{deployment-summary-0-0eGWjc-ClB8FXcN.mjs.map → deployment-summary-CDHdLtnO-DrE7GsHq.mjs.map} +1 -1
  15. package/dist/{deployment-summary-p88NV5m5-Ci2FsDKX.d.mts → deployment-summary-p88NV5m5-DTkPLzTp.d.mts} +3 -3
  16. package/dist/{deployment-summary-p88NV5m5-Ci2FsDKX.d.mts.map → deployment-summary-p88NV5m5-DTkPLzTp.d.mts.map} +1 -1
  17. package/dist/{dev-current-vAfxVcnD-DNeLJavU.mjs → dev-current-BB02pfSh-D-dYHs1q.mjs} +5 -5
  18. package/dist/{dev-current-vAfxVcnD-DNeLJavU.mjs.map → dev-current-BB02pfSh-D-dYHs1q.mjs.map} +1 -1
  19. package/dist/{dist-D5tj8ZhD.mjs → dist-Xd2Pp_-u.mjs} +2 -2
  20. package/dist/dist-Xd2Pp_-u.mjs.map +1 -0
  21. package/dist/{execute-deploy-destroy-CdjqjHzw-DNOFEr5H.mjs → execute-deploy-destroy-DwcoZIks-Cl-tWvo0.mjs} +15 -13
  22. package/dist/execute-deploy-destroy-DwcoZIks-Cl-tWvo0.mjs.map +1 -0
  23. package/dist/{execute-dev-C75Y_wIa-CBsKvWvl.mjs → execute-dev-BHRWoEnd-D-YNpuEN.mjs} +164 -35
  24. package/dist/execute-dev-BHRWoEnd-D-YNpuEN.mjs.map +1 -0
  25. package/dist/{execute-dev-current-C0y1X-EE-D6I5h2_B.mjs → execute-dev-current-D4RkOtPA-CDBtbQUq.mjs} +8 -6
  26. package/dist/execute-dev-current-D4RkOtPA-CDBtbQUq.mjs.map +1 -0
  27. package/dist/{execute-log-Cwa9F3BR-fhYWYzQk.mjs → execute-log-DxjUaSwN-nVFDjZqy.mjs} +4 -4
  28. package/dist/{execute-log-Cwa9F3BR-fhYWYzQk.mjs.map → execute-log-DxjUaSwN-nVFDjZqy.mjs.map} +1 -1
  29. package/dist/{graph-C4If3c5e-CVij_XGB.d.mts → graph-BmTgCiFm-qR5hnhOZ.d.mts} +8 -3
  30. package/dist/graph-BmTgCiFm-qR5hnhOZ.d.mts.map +1 -0
  31. package/dist/{graph-BPLLRt2I-m78iETnF.mjs → graph-D0ICjejE-CeQtHY5B.mjs} +23 -13
  32. package/dist/graph-D0ICjejE-CeQtHY5B.mjs.map +1 -0
  33. package/dist/http.d.mts +1 -1
  34. package/dist/http.mjs +2 -2
  35. package/dist/{index-vUfxWpWf.d.mts → index-B-9Dc0J7.d.mts} +2 -2
  36. package/dist/{index-vUfxWpWf.d.mts.map → index-B-9Dc0J7.d.mts.map} +1 -1
  37. package/dist/index.d.mts +3 -3
  38. package/dist/index.mjs +3 -3
  39. package/dist/local-target.d.mts +1 -1
  40. package/dist/{nextjs-DLyeRR7M-Btfuot-v.d.mts → nextjs-DLyeRR7M-kVartQq-.d.mts} +2 -2
  41. package/dist/{nextjs-DLyeRR7M-Btfuot-v.d.mts.map → nextjs-DLyeRR7M-kVartQq-.d.mts.map} +1 -1
  42. package/dist/nextjs-control.d.mts +11 -5
  43. package/dist/nextjs-control.d.mts.map +1 -1
  44. package/dist/nextjs-control.mjs +50 -2
  45. package/dist/nextjs-control.mjs.map +1 -1
  46. package/dist/nextjs.d.mts +1 -1
  47. package/dist/node-control.d.mts +10 -4
  48. package/dist/node-control.d.mts.map +1 -1
  49. package/dist/node-control.mjs +20 -3
  50. package/dist/node-control.mjs.map +1 -1
  51. package/dist/node.d.mts +10 -1
  52. package/dist/node.d.mts.map +1 -1
  53. package/dist/node.mjs +12 -8
  54. package/dist/node.mjs.map +1 -1
  55. package/dist/{pipeline-Dpesfd2j-CD3W79W6.mjs → pipeline-BmWt-Nhb-D9Eg14Sx.mjs} +100 -21
  56. package/dist/pipeline-BmWt-Nhb-D9Eg14Sx.mjs.map +1 -0
  57. package/dist/report.d.mts +3 -3
  58. package/dist/report.mjs +3 -2
  59. package/dist/report.mjs.map +1 -1
  60. package/dist/{run-alchemy-BqHpStQn-sYiodM6y.mjs → run-alchemy-Dl_MWw4g-BZaLckHp.mjs} +2 -2
  61. package/dist/{run-alchemy-BqHpStQn-sYiodM6y.mjs.map → run-alchemy-Dl_MWw4g-BZaLckHp.mjs.map} +1 -1
  62. package/dist/service-rpc.d.mts +1 -1
  63. package/dist/service-rpc.mjs +2 -2
  64. package/package.json +11 -11
  65. package/skills/prisma-composer-core-concepts/SKILL.md +88 -25
  66. package/dist/app-config-BBPLNnZX-DzU21TVb.d.mts.map +0 -1
  67. package/dist/config-CRHoX2Pq.d.mts +0 -1
  68. package/dist/deploy-CRHoX2Pq.d.mts +0 -1
  69. package/dist/dist-D5tj8ZhD.mjs.map +0 -1
  70. package/dist/execute-deploy-destroy-CdjqjHzw-DNOFEr5H.mjs.map +0 -1
  71. package/dist/execute-dev-C75Y_wIa-CBsKvWvl.mjs.map +0 -1
  72. package/dist/execute-dev-current-C0y1X-EE-D6I5h2_B.mjs.map +0 -1
  73. package/dist/graph-BPLLRt2I-m78iETnF.mjs.map +0 -1
  74. package/dist/graph-C4If3c5e-CVij_XGB.d.mts.map +0 -1
  75. package/dist/pipeline-Dpesfd2j-CD3W79W6.mjs.map +0 -1
@@ -1,14 +1,15 @@
1
1
  import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
2
2
  import { t as containerEnv } from "./container-transport-HcvNOGZL-twPi2TIv.mjs";
3
3
  import { t as DEV_DIR } from "./app-config-CGJHcFb--CIEFCG4V.mjs";
4
- import { c as notOk, l as ok, s as toStructured } from "./dev-current-vAfxVcnD-DNeLJavU.mjs";
4
+ import { c as notOk, l as ok, s as toStructured } from "./dev-current-BB02pfSh-D-dYHs1q.mjs";
5
5
  import { r as resolveLocalTargets } from "./local-target-BUZG9uLx.mjs";
6
- import { n as reproduceCommand, r as spawnAlchemy, t as alchemyInvocation } from "./run-alchemy-BqHpStQn-sYiodM6y.mjs";
7
- import { i as noComposerExportMessage, r as runPipeline } from "./pipeline-Dpesfd2j-CD3W79W6.mjs";
6
+ import { i as noComposerExportMessage, r as runPipeline } from "./pipeline-BmWt-Nhb-D9Eg14Sx.mjs";
7
+ import { n as reproduceCommand, r as spawnAlchemy, t as alchemyInvocation } from "./run-alchemy-Dl_MWw4g-BZaLckHp.mjs";
8
8
  import { t as withEmulatorRetry } from "./emulator-retry-CV8rl69G-BgUzkxc-.mjs";
9
9
  import * as fs$1 from "node:fs";
10
10
  import * as path$1 from "node:path";
11
11
  import { join, relative, resolve, sep } from "node:path";
12
+ import { fileURLToPath } from "node:url";
12
13
  import * as sysPath from "path";
13
14
  import { stat, unwatchFile, watch, watchFile } from "fs";
14
15
  import { Readable } from "node:stream";
@@ -17,7 +18,7 @@ import { type } from "os";
17
18
  import { EventEmitter } from "events";
18
19
  import { createHash } from "node:crypto";
19
20
  import { lstat as lstat$1, open, readdir as readdir$1, realpath as realpath$1, stat as stat$2 } from "fs/promises";
20
- //#region ../../0-framework/3-tooling/cli/dist/generate-dev-stack-DSBhURJV.mjs
21
+ //#region ../../0-framework/3-tooling/cli/dist/generate-dev-stack-CfneNj97.mjs
21
22
  /**
22
23
  * Local-dev spec § 6 `generate-dev-stack.ts`: like generate-stack.ts but at
23
24
  * `.prisma-composer/dev/alchemy.run.ts`, always Alchemy stage `dev`, using
@@ -49,6 +50,8 @@ function renderOptions(input) {
49
50
  lines.push(" bundles: {");
50
51
  for (const [id, bundle] of Object.entries(input.assembled.bundles)) lines.push(` ${quote(id)}: ${renderBundle(bundle)},`);
51
52
  lines.push(" },");
53
+ const unassembled = Object.keys(input.assembled.devServers);
54
+ if (unassembled.length > 0) lines.push(` unassembled: [${unassembled.map(quote).join(", ")}],`);
52
55
  lines.push(" providers: localTargetProviders(resolved, containers, devDir),");
53
56
  lines.push(" state: devState(),");
54
57
  return lines.join("\n");
@@ -1646,11 +1649,12 @@ var esm_default = {
1646
1649
  FSWatcher
1647
1650
  };
1648
1651
  //#endregion
1649
- //#region ../../0-framework/3-tooling/cli/dist/execute-dev-C75Y_wIa.mjs
1652
+ //#region ../../0-framework/3-tooling/cli/dist/execute-dev-BHRWoEnd.mjs
1650
1653
  /**
1651
1654
  * Local-dev spec § 6 `watch.ts`: watches each assembled bundle's declared
1652
- * `watch` paths (a directory watched recursively, a file watched through
1653
- * its parent — see `startWatch`), debounced 300 ms and coalesced across
1655
+ * `watch` paths and every authoring module (ADR-0056) — a directory watched
1656
+ * recursively, a file watched through its parent (see `startWatch`) —
1657
+ * debounced 300 ms and coalesced across
1654
1658
  * every service — one edit across several files/services still fires
1655
1659
  * exactly one rebuild.
1656
1660
  *
@@ -1687,6 +1691,29 @@ function watchTargetsFrom(bundles) {
1687
1691
  };
1688
1692
  }
1689
1693
  /**
1694
+ * One watch target per authoring module (ADR-0056): the entry file and the
1695
+ * file each service's `build.module` names, deduplicated. A topology edit
1696
+ * then reconverges even when every service runs a dev server and nothing
1697
+ * else is watched. A `build.module` that is not a `file:` URL names no file
1698
+ * and is skipped.
1699
+ */
1700
+ function authoringModuleTargets(entryPath, graph) {
1701
+ const targets = /* @__PURE__ */ new Map();
1702
+ const add = (address, file) => {
1703
+ const resolved = path$1.resolve(file);
1704
+ if (!targets.has(resolved)) targets.set(resolved, {
1705
+ address,
1706
+ paths: [resolved]
1707
+ });
1708
+ };
1709
+ add(graph.root.id, entryPath);
1710
+ for (const { id, node } of graph.nodes) {
1711
+ if (node.kind !== "service" || !node.build.module.startsWith("file:")) continue;
1712
+ add(id, fileURLToPath(node.build.module));
1713
+ }
1714
+ return [...targets.values()];
1715
+ }
1716
+ /**
1690
1717
  * Watches every target's paths via chokidar, debounced 300 ms and coalesced
1691
1718
  * across every service, invoking `onChange` once per burst.
1692
1719
  *
@@ -1767,8 +1794,49 @@ function startWatch(targets, onChange, onError) {
1767
1794
  function failureMessage(error) {
1768
1795
  return error instanceof Error ? error.message : String(error);
1769
1796
  }
1770
- async function mergedEndpoints(attachments) {
1771
- return (await Promise.all(attachments.map((a) => withEmulatorRetry(() => a.endpoints())))).flat();
1797
+ /**
1798
+ * How many lines of a dev server's log the session shows when it starts
1799
+ * following it. The emulator clears the log on every fresh start, so these
1800
+ * are the current process's own startup lines (the framework's banner, a
1801
+ * compile error), written while `prisma dev` waited for it to listen.
1802
+ */
1803
+ const DEV_SERVER_LOG_BACKLOG = 200;
1804
+ async function mergedEndpoints(attachments, devServers) {
1805
+ return (await Promise.all(attachments.map((a) => withEmulatorRetry(() => a.endpoints())))).flat().map((endpoint) => {
1806
+ const server = devServers[endpoint.address];
1807
+ return server === void 0 ? endpoint : {
1808
+ ...endpoint,
1809
+ devServer: server.display
1810
+ };
1811
+ });
1812
+ }
1813
+ /** Each service that runs a dev server, in graph order, with its node. */
1814
+ function devServerNodes(graph, devServers) {
1815
+ const found = [];
1816
+ for (const { id, node } of graph.nodes) {
1817
+ const server = devServers[id];
1818
+ if (server !== void 0 && node.kind === "service") found.push({
1819
+ address: id,
1820
+ node,
1821
+ server
1822
+ });
1823
+ }
1824
+ return found;
1825
+ }
1826
+ function devServerUnsupported(address, what, extension) {
1827
+ return new CliStructuredError("DEV.DEV_SERVER_UNSUPPORTED", `service "${address}" runs a dev server but ${what} — update ${extension}`, { meta: { address } });
1828
+ }
1829
+ /**
1830
+ * ADR-0056's two capability checks, before anything converges: the service's
1831
+ * descriptor must be able to lower it without an artifact (`reserve`), and its
1832
+ * target's local attachment must be able to run the command (`serve`).
1833
+ */
1834
+ function assertDevServersSupported(graph, devServers, config, attachments) {
1835
+ for (const { address, node } of devServerNodes(graph, devServers)) {
1836
+ const descriptor = config.extensions.find((e) => e.id === node.extension)?.nodes[node.type];
1837
+ if (descriptor?.kind === "service" && descriptor.reserve === void 0) throw devServerUnsupported(address, `its descriptor (${node.extension}/${node.type}) has no \`reserve\` step`, node.extension);
1838
+ if (attachments.get(node.extension)?.serve === void 0) throw devServerUnsupported(address, "its target's local attachment has no `serve`", node.extension);
1839
+ }
1772
1840
  }
1773
1841
  /** Runs the full dev pipeline; resolves to a running session or a structured failure. */
1774
1842
  /** The file's content hash; undefined when it cannot be read, which counts as a change. */
@@ -1786,8 +1854,17 @@ async function executeDev(input, deps, cwd) {
1786
1854
  let pipeline;
1787
1855
  let resolved;
1788
1856
  const containers = /* @__PURE__ */ new Map();
1857
+ const attachmentsById = /* @__PURE__ */ new Map();
1858
+ const emit = (event) => {
1859
+ try {
1860
+ onEvent?.(event);
1861
+ } catch {}
1862
+ };
1789
1863
  try {
1790
- const pipelineDeps = { runAssembler: deps.runAssembler };
1864
+ const pipelineDeps = {
1865
+ runAssembler: deps.runAssembler,
1866
+ devServers: true
1867
+ };
1791
1868
  pipeline = await runPipeline(input.entry, input.name, cwd, input.config, pipelineDeps);
1792
1869
  const { graph, name } = pipeline;
1793
1870
  const config = pipeline.configSource.value;
@@ -1835,6 +1912,22 @@ async function executeDev(input, deps, cwd) {
1835
1912
  throw toStructured("DEV.EMULATOR_FAILED", error);
1836
1913
  }
1837
1914
  }
1915
+ for (const [id, dev] of resolved) try {
1916
+ attachmentsById.set(id, await dev.attach({
1917
+ container: containers.get(id),
1918
+ devDir
1919
+ }));
1920
+ } catch (error) {
1921
+ throw toStructured("DEV.ATTACH_FAILED", error);
1922
+ }
1923
+ const { devServers } = pipeline.assembled;
1924
+ assertDevServersSupported(graph, devServers, config, attachmentsById);
1925
+ for (const { address, server } of devServerNodes(graph, devServers)) emit({
1926
+ kind: "dev-server",
1927
+ address,
1928
+ command: server.display,
1929
+ cwd: server.cwd
1930
+ });
1838
1931
  } catch (error) {
1839
1932
  if (CliStructuredError.is(error)) return notOk(error);
1840
1933
  throw error;
@@ -1880,13 +1973,33 @@ async function executeDev(input, deps, cwd) {
1880
1973
  };
1881
1974
  };
1882
1975
  const stopStartedServices = async () => {
1883
- for (const [id, dev] of resolved) try {
1884
- await (await dev.attach({
1885
- container: containers.get(id),
1886
- devDir
1887
- })).stopApp();
1976
+ for (const attachment of attachmentsById.values()) try {
1977
+ await attachment.stopApp();
1888
1978
  } catch {}
1889
1979
  };
1980
+ /**
1981
+ * ADR-0056's serve step: run every dev server on its service's instance,
1982
+ * in graph order. The emulator decides whether anything restarts; a
1983
+ * restart is reported through `onRestarted`.
1984
+ */
1985
+ const serveDevServers = async (graph, devServers, onRestarted) => {
1986
+ for (const { address, node, server } of devServerNodes(graph, devServers)) {
1987
+ const attachment = attachmentsById.get(node.extension);
1988
+ if (attachment?.serve === void 0) throw devServerUnsupported(address, "its target's local attachment has no `serve`", node.extension);
1989
+ const serve = attachment.serve.bind(attachment);
1990
+ let restarted;
1991
+ try {
1992
+ ({restarted} = await withEmulatorRetry(() => serve({
1993
+ address,
1994
+ node,
1995
+ server
1996
+ })));
1997
+ } catch (error) {
1998
+ throw toStructured("DEV.SERVICE_START_FAILED", error);
1999
+ }
2000
+ if (restarted) onRestarted?.(address, server);
2001
+ }
2002
+ };
1890
2003
  let first;
1891
2004
  try {
1892
2005
  first = await converge();
@@ -1909,24 +2022,12 @@ async function executeDev(input, deps, cwd) {
1909
2022
  }
1910
2023
  } }));
1911
2024
  }
1912
- const emit = (event) => {
1913
- try {
1914
- onEvent?.(event);
1915
- } catch {}
1916
- };
1917
- const attachments = [];
2025
+ const attachments = [...attachmentsById.values()];
1918
2026
  const started = [];
1919
2027
  let watch;
1920
2028
  let configWatch;
2029
+ const following = new AbortController();
1921
2030
  try {
1922
- for (const [id, dev] of resolved) try {
1923
- attachments.push(await dev.attach({
1924
- container: containers.get(id),
1925
- devDir
1926
- }));
1927
- } catch (error) {
1928
- throw toStructured("DEV.ATTACH_FAILED", error);
1929
- }
1930
2031
  for (const attachment of attachments) {
1931
2032
  started.push(attachment);
1932
2033
  try {
@@ -1935,9 +2036,10 @@ async function executeDev(input, deps, cwd) {
1935
2036
  throw toStructured("DEV.SERVICE_START_FAILED", error);
1936
2037
  }
1937
2038
  }
2039
+ await serveDevServers(pipeline.graph, pipeline.assembled.devServers);
1938
2040
  let endpoints;
1939
2041
  try {
1940
- endpoints = await mergedEndpoints(attachments);
2042
+ endpoints = await mergedEndpoints(attachments, pipeline.assembled.devServers);
1941
2043
  } catch (error) {
1942
2044
  throw toStructured("DEV.ATTACH_FAILED", error);
1943
2045
  }
@@ -1953,12 +2055,32 @@ async function executeDev(input, deps, cwd) {
1953
2055
  closed
1954
2056
  });
1955
2057
  }
1956
- const { targets, unwatchable } = watchTargetsFrom(pipeline.assembled.bundles);
1957
- for (const address of unwatchable) emit({
2058
+ for (const [id, attachment] of attachmentsById) {
2059
+ const addresses = devServerNodes(pipeline.graph, pipeline.assembled.devServers).filter(({ node }) => node.extension === id).map(({ address }) => address);
2060
+ if (addresses.length === 0) continue;
2061
+ (async () => {
2062
+ try {
2063
+ for await (const { service, line } of attachment.logs(following.signal, {
2064
+ tail: DEV_SERVER_LOG_BACKLOG,
2065
+ addresses
2066
+ })) emit({
2067
+ kind: "dev-server-output",
2068
+ address: service,
2069
+ line
2070
+ });
2071
+ } catch {}
2072
+ })();
2073
+ }
2074
+ const bundleWatch = watchTargetsFrom(pipeline.assembled.bundles);
2075
+ const targets = [...bundleWatch.targets, ...authoringModuleTargets(pipeline.entryModule.path, pipeline.graph)];
2076
+ for (const address of bundleWatch.unwatchable) emit({
1958
2077
  kind: "unwatchable",
1959
2078
  address
1960
2079
  });
1961
- const watchDeps = { runAssembler: deps.runAssembler };
2080
+ const watchDeps = {
2081
+ runAssembler: deps.runAssembler,
2082
+ devServers: true
2083
+ };
1962
2084
  const watchFiles = deps.watch ?? startWatch;
1963
2085
  const onWatchError = (error) => emit({
1964
2086
  kind: "watch-error",
@@ -2000,9 +2122,14 @@ async function executeDev(input, deps, cwd) {
2000
2122
  });
2001
2123
  return;
2002
2124
  }
2125
+ await serveDevServers(rePipeline.graph, rePipeline.assembled.devServers, (address, server) => emit({
2126
+ kind: "dev-server-restarted",
2127
+ address,
2128
+ command: server.display
2129
+ }));
2003
2130
  emit({
2004
2131
  kind: "ready",
2005
- endpoints: await mergedEndpoints(attachments)
2132
+ endpoints: await mergedEndpoints(attachments, rePipeline.assembled.devServers)
2006
2133
  });
2007
2134
  } catch (error) {
2008
2135
  emit({
@@ -2041,6 +2168,7 @@ async function executeDev(input, deps, cwd) {
2041
2168
  if (!stopping) {
2042
2169
  stopping = true;
2043
2170
  emit({ kind: "stopping" });
2171
+ following.abort();
2044
2172
  startedWatch.stop();
2045
2173
  startedConfigWatch.stop();
2046
2174
  (async () => {
@@ -2064,6 +2192,7 @@ async function executeDev(input, deps, cwd) {
2064
2192
  closed
2065
2193
  });
2066
2194
  } catch (error) {
2195
+ following.abort();
2067
2196
  watch?.stop();
2068
2197
  configWatch?.stop();
2069
2198
  await Promise.all(started.map((a) => a.stopApp().catch(() => void 0)));
@@ -2074,4 +2203,4 @@ async function executeDev(input, deps, cwd) {
2074
2203
  //#endregion
2075
2204
  export { executeDev };
2076
2205
 
2077
- //# sourceMappingURL=execute-dev-C75Y_wIa-CBsKvWvl.mjs.map
2206
+ //# sourceMappingURL=execute-dev-BHRWoEnd-D-YNpuEN.mjs.map