@valbuild/shared 0.136.1 → 0.136.3

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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # @valbuild/shared
2
2
 
3
+ ## 0.136.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#726](https://github.com/valbuild/val/pull/726) [`3b19534`](https://github.com/valbuild/val/commit/3b19534bb7aa16452a104906d9594083c3bc3e89) Thanks [@freekh](https://github.com/freekh)! - A Studio publish of a project with no repository now ships every edit that was saved, and keeps the site styled.
8
+
9
+ - A host that embeds the project's source can hand it to Val as `projectSource` (`initValServer(..., { http: { projectSource } })`). A publish then patches that text, not text fetched from the content service at a commit, which a project with no repository does not have. The build platform's wiring passes the build's own source, so `.val.ts` can be rendered for a project made on `/new`. Before, its first save produced no files, and the build that followed carried none of the save's edits.
10
+ - New route `GET /api/val/built-source`: the `.val.ts` text of every module changed since the running build, with every commit since it applied. The Studio builds from it, so an edit whose own publish failed, and a Finish publishing, are no longer left out of the next build.
11
+ - A Studio build that compiles no stylesheet (a browser cannot run Tailwind `@plugin`s) keeps the live site's. A Studio save never changes a stylesheet or a component, so the live CSS is still the right one.
12
+
13
+ ## 0.136.2
14
+
15
+ ### Patch Changes
16
+
17
+ - [#720](https://github.com/valbuild/val/pull/720) [`f76cd56`](https://github.com/valbuild/val/commit/f76cd56b9f1c1bcc0a608a7a4de24b1e776adccb) Thanks [@freekh](https://github.com/freekh)! - A managed project published from the Studio keeps its images, and a project created from a template can publish from the Studio at all.
18
+
19
+ - A publish from the Studio carries over every file under `public/` that the site already serves, so the favicon and images no longer disappear after the first Studio publish. When content published the live build, it already holds those files and nothing is uploaded again. When it didn't (a project cloned from a template), the Studio reads them from the site it runs on and builds with them.
20
+ - An image uploaded in the Studio is now part of the build that publishes it. For a managed project, `/save` returns the files the commit wrote (`binaryFiles`), the same way it already returns the `.val.ts` text.
21
+ - `/save` also returns the project's branch for a managed project, and the Studio's build uses it. A project cloned from a template was wired at no commit and no branch, so its first Studio publish went out branchless and the platform refused it.
22
+ - When neither content nor the platform can say which public files the live site serves, the Studio refuses to publish and says so, rather than publishing a site without them.
23
+
3
24
  ## 0.136.1
4
25
 
5
26
  ### Patch Changes
@@ -1022,6 +1022,51 @@ export declare const Api: {
1022
1022
  }, z.core.$strip>]>;
1023
1023
  };
1024
1024
  };
1025
+ /**
1026
+ * The `.val.ts` text of every module that changed since the RUNNING build,
1027
+ * with every commit since it applied, for a build made in the browser.
1028
+ *
1029
+ * A Studio build starts from the source stored with the live build. A commit
1030
+ * whose own publish failed -- or the first commit of a project that started
1031
+ * as a copy of a template -- is in content and in no stored source, so a build
1032
+ * that added only its own save's files shipped without it. Only this server
1033
+ * can render those commits back into text: content keeps a managed project's
1034
+ * content as Source, not as files.
1035
+ *
1036
+ * Committed patches only. A pending one is somebody's unpublished work, and
1037
+ * is not this build's to ship. 409 where there is nothing to answer with: a
1038
+ * project with a repository, or a build that did not embed its source.
1039
+ */
1040
+ "/built-source": {
1041
+ GET: {
1042
+ req: {
1043
+ cookies: {
1044
+ val_session: z.ZodOptional<z.ZodString>;
1045
+ };
1046
+ };
1047
+ res: z.ZodUnion<readonly [z.ZodObject<{
1048
+ status: z.ZodLiteral<401>;
1049
+ json: z.ZodObject<{
1050
+ message: z.ZodString;
1051
+ }, z.core.$strip>;
1052
+ }, z.core.$strip>, z.ZodObject<{
1053
+ status: z.ZodLiteral<409>;
1054
+ json: z.ZodObject<{
1055
+ message: z.ZodString;
1056
+ }, z.core.$strip>;
1057
+ }, z.core.$strip>, z.ZodObject<{
1058
+ status: z.ZodLiteral<500>;
1059
+ json: z.ZodObject<{
1060
+ message: z.ZodString;
1061
+ }, z.core.$strip>;
1062
+ }, z.core.$strip>, z.ZodObject<{
1063
+ status: z.ZodLiteral<200>;
1064
+ json: z.ZodObject<{
1065
+ files: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
1066
+ }, z.core.$strip>;
1067
+ }, z.core.$strip>]>;
1068
+ };
1069
+ };
1025
1070
  "/profiles": {
1026
1071
  GET: {
1027
1072
  req: {
@@ -1077,6 +1122,9 @@ export declare const Api: {
1077
1122
  json: z.ZodObject<{
1078
1123
  commitSha: z.ZodOptional<z.ZodString>;
1079
1124
  sourceFiles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>>;
1125
+ binaryFiles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1126
+ branch: z.ZodOptional<z.ZodString>;
1127
+ binaryFilesUnread: z.ZodOptional<z.ZodArray<z.ZodString>>;
1080
1128
  removed: z.ZodOptional<z.ZodArray<z.ZodObject<{
1081
1129
  patchId: z.ZodString & z.ZodType<import("@valbuild/core").PatchId, string, z.core.$ZodTypeInternals<import("@valbuild/core").PatchId, string>>;
1082
1130
  moduleFilePath: z.ZodString & z.ZodType<ModuleFilePath, string, z.core.$ZodTypeInternals<ModuleFilePath, string>>;
@@ -107,6 +107,12 @@ export type BuildTargetResponse = z.infer<typeof buildTargetResponse>;
107
107
  */
108
108
  declare const projectSourceResponse: z.ZodObject<{
109
109
  files: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>;
110
+ publicFiles: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
111
+ key: z.ZodString;
112
+ sha256: z.ZodString;
113
+ bytes: z.ZodNumber;
114
+ }, z.core.$strip>>>>;
115
+ publicPaths: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
110
116
  }, z.core.$strip>;
111
117
  export type ProjectSourceResponse = z.infer<typeof projectSourceResponse>;
112
118
  export declare const parseBuildTarget: (body: unknown) => BuildTargetResponse;
@@ -2506,6 +2506,43 @@ var Api = {
2506
2506
  })])
2507
2507
  }
2508
2508
  },
2509
+ /**
2510
+ * The `.val.ts` text of every module that changed since the RUNNING build,
2511
+ * with every commit since it applied, for a build made in the browser.
2512
+ *
2513
+ * A Studio build starts from the source stored with the live build. A commit
2514
+ * whose own publish failed -- or the first commit of a project that started
2515
+ * as a copy of a template -- is in content and in no stored source, so a build
2516
+ * that added only its own save's files shipped without it. Only this server
2517
+ * can render those commits back into text: content keeps a managed project's
2518
+ * content as Source, not as files.
2519
+ *
2520
+ * Committed patches only. A pending one is somebody's unpublished work, and
2521
+ * is not this build's to ship. 409 where there is nothing to answer with: a
2522
+ * project with a repository, or a build that did not embed its source.
2523
+ */
2524
+ "/built-source": {
2525
+ GET: {
2526
+ req: {
2527
+ cookies: {
2528
+ val_session: zod.z.string().optional()
2529
+ }
2530
+ },
2531
+ res: zod.z.union([unauthorizedResponse, zod.z.object({
2532
+ status: zod.z.literal(409),
2533
+ json: GenericError
2534
+ }), zod.z.object({
2535
+ status: zod.z.literal(500),
2536
+ json: GenericError
2537
+ }), zod.z.object({
2538
+ status: zod.z.literal(200),
2539
+ json: zod.z.object({
2540
+ /** By path, as `/save`'s `sourceFiles`. `null` is a deleted file. */
2541
+ files: zod.z.record(zod.z.string(), zod.z.string().nullable())
2542
+ })
2543
+ })])
2544
+ }
2545
+ },
2509
2546
  "/profiles": {
2510
2547
  GET: {
2511
2548
  req: {
@@ -2606,6 +2643,34 @@ var Api = {
2606
2643
  * repository, and from a server that predates it.
2607
2644
  */
2608
2645
  sourceFiles: zod.z.record(zod.z.string(), zod.z.string().nullable()).optional(),
2646
+ /**
2647
+ * The binary files this commit wrote -- an image uploaded in the
2648
+ * Studio -- base64, by path, for a MANAGED project.
2649
+ *
2650
+ * The same reason as `sourceFiles`: the in-tab build publishes the
2651
+ * site, and a file this commit added is in no earlier build. Local
2652
+ * files only; a remote one is served from its own URL and was never
2653
+ * part of a build. A deleted file is a `null` in `sourceFiles`, as
2654
+ * it always was.
2655
+ */
2656
+ binaryFiles: zod.z.record(zod.z.string(), zod.z.string()).optional(),
2657
+ /**
2658
+ * The branch this commit is on, for a MANAGED project -- the
2659
+ * content service's word for it.
2660
+ *
2661
+ * The in-tab build has to name the branch it was made at, and its
2662
+ * only other source is the `val.server.ts` the last build was
2663
+ * wired with: a project cloned from a template seed has one wired
2664
+ * at no commit, so without this its first publish is branchless
2665
+ * and the loader refuses it.
2666
+ */
2667
+ branch: zod.z.string().optional(),
2668
+ /**
2669
+ * Binary files this commit wrote whose bytes the server could not
2670
+ * read back before committing. Named so the Studio refuses to build
2671
+ * a site that would 404 them, rather than publishing it.
2672
+ */
2673
+ binaryFilesUnread: zod.z.array(zod.z.string()).optional(),
2609
2674
  /**
2610
2675
  * Unpublished changes the save threw away because they could not be
2611
2676
  * applied.
@@ -7231,7 +7296,37 @@ var buildTargetResponse = zod.z.object({
7231
7296
  * "there is nothing here yet".
7232
7297
  */
7233
7298
  var projectSourceResponse = zod.z.object({
7234
- files: zod.z.record(zod.z.string(), zod.z.string()).nullable()
7299
+ files: zod.z.record(zod.z.string(), zod.z.string()).nullable(),
7300
+ /**
7301
+ * The live build's `public/*` artifacts, by hash -- what a publisher with no
7302
+ * checkout carries into its build so the site keeps its favicon and images.
7303
+ *
7304
+ * The loader stores public files PER BUILD, so a build that names none
7305
+ * serves none. A publisher with a checkout has them on disk; the Studio has
7306
+ * this. Re-declaring one costs nothing: content holds the bytes for the
7307
+ * project already and asks for no upload.
7308
+ *
7309
+ * `null` when content cannot say -- the live build was not published through
7310
+ * it -- and absent from a content service that predates it. A publisher
7311
+ * must treat both as "unknown", never as "none": publishing on that guess
7312
+ * deletes every public file the site has.
7313
+ */
7314
+ publicFiles: zod.z.array(zod.z.object({
7315
+ key: zod.z.string(),
7316
+ sha256: zod.z.string(),
7317
+ bytes: zod.z.number()["int"]().nonnegative()
7318
+ })).nullable().optional(),
7319
+ /**
7320
+ * The URL paths the live build serves from `public/`, as the loader has
7321
+ * them -- without the bytes' hashes.
7322
+ *
7323
+ * The fallback for when `publicFiles` is `null`: a build content has no
7324
+ * record of, which is every project cloned from a template seed. A publisher
7325
+ * running on the site's own origin can fetch these and build with them;
7326
+ * after that publish content holds their hashes and `publicFiles` answers.
7327
+ * `null` when the loader serves no build or does not say.
7328
+ */
7329
+ publicPaths: zod.z.array(zod.z.string()).nullable().optional()
7235
7330
  });
7236
7331
  var parseBuildTarget = function parseBuildTarget(body) {
7237
7332
  return parse(buildTargetResponse, body, "GET /v1/build-target");
@@ -2506,6 +2506,43 @@ var Api = {
2506
2506
  })])
2507
2507
  }
2508
2508
  },
2509
+ /**
2510
+ * The `.val.ts` text of every module that changed since the RUNNING build,
2511
+ * with every commit since it applied, for a build made in the browser.
2512
+ *
2513
+ * A Studio build starts from the source stored with the live build. A commit
2514
+ * whose own publish failed -- or the first commit of a project that started
2515
+ * as a copy of a template -- is in content and in no stored source, so a build
2516
+ * that added only its own save's files shipped without it. Only this server
2517
+ * can render those commits back into text: content keeps a managed project's
2518
+ * content as Source, not as files.
2519
+ *
2520
+ * Committed patches only. A pending one is somebody's unpublished work, and
2521
+ * is not this build's to ship. 409 where there is nothing to answer with: a
2522
+ * project with a repository, or a build that did not embed its source.
2523
+ */
2524
+ "/built-source": {
2525
+ GET: {
2526
+ req: {
2527
+ cookies: {
2528
+ val_session: zod.z.string().optional()
2529
+ }
2530
+ },
2531
+ res: zod.z.union([unauthorizedResponse, zod.z.object({
2532
+ status: zod.z.literal(409),
2533
+ json: GenericError
2534
+ }), zod.z.object({
2535
+ status: zod.z.literal(500),
2536
+ json: GenericError
2537
+ }), zod.z.object({
2538
+ status: zod.z.literal(200),
2539
+ json: zod.z.object({
2540
+ /** By path, as `/save`'s `sourceFiles`. `null` is a deleted file. */
2541
+ files: zod.z.record(zod.z.string(), zod.z.string().nullable())
2542
+ })
2543
+ })])
2544
+ }
2545
+ },
2509
2546
  "/profiles": {
2510
2547
  GET: {
2511
2548
  req: {
@@ -2606,6 +2643,34 @@ var Api = {
2606
2643
  * repository, and from a server that predates it.
2607
2644
  */
2608
2645
  sourceFiles: zod.z.record(zod.z.string(), zod.z.string().nullable()).optional(),
2646
+ /**
2647
+ * The binary files this commit wrote -- an image uploaded in the
2648
+ * Studio -- base64, by path, for a MANAGED project.
2649
+ *
2650
+ * The same reason as `sourceFiles`: the in-tab build publishes the
2651
+ * site, and a file this commit added is in no earlier build. Local
2652
+ * files only; a remote one is served from its own URL and was never
2653
+ * part of a build. A deleted file is a `null` in `sourceFiles`, as
2654
+ * it always was.
2655
+ */
2656
+ binaryFiles: zod.z.record(zod.z.string(), zod.z.string()).optional(),
2657
+ /**
2658
+ * The branch this commit is on, for a MANAGED project -- the
2659
+ * content service's word for it.
2660
+ *
2661
+ * The in-tab build has to name the branch it was made at, and its
2662
+ * only other source is the `val.server.ts` the last build was
2663
+ * wired with: a project cloned from a template seed has one wired
2664
+ * at no commit, so without this its first publish is branchless
2665
+ * and the loader refuses it.
2666
+ */
2667
+ branch: zod.z.string().optional(),
2668
+ /**
2669
+ * Binary files this commit wrote whose bytes the server could not
2670
+ * read back before committing. Named so the Studio refuses to build
2671
+ * a site that would 404 them, rather than publishing it.
2672
+ */
2673
+ binaryFilesUnread: zod.z.array(zod.z.string()).optional(),
2609
2674
  /**
2610
2675
  * Unpublished changes the save threw away because they could not be
2611
2676
  * applied.
@@ -7231,7 +7296,37 @@ var buildTargetResponse = zod.z.object({
7231
7296
  * "there is nothing here yet".
7232
7297
  */
7233
7298
  var projectSourceResponse = zod.z.object({
7234
- files: zod.z.record(zod.z.string(), zod.z.string()).nullable()
7299
+ files: zod.z.record(zod.z.string(), zod.z.string()).nullable(),
7300
+ /**
7301
+ * The live build's `public/*` artifacts, by hash -- what a publisher with no
7302
+ * checkout carries into its build so the site keeps its favicon and images.
7303
+ *
7304
+ * The loader stores public files PER BUILD, so a build that names none
7305
+ * serves none. A publisher with a checkout has them on disk; the Studio has
7306
+ * this. Re-declaring one costs nothing: content holds the bytes for the
7307
+ * project already and asks for no upload.
7308
+ *
7309
+ * `null` when content cannot say -- the live build was not published through
7310
+ * it -- and absent from a content service that predates it. A publisher
7311
+ * must treat both as "unknown", never as "none": publishing on that guess
7312
+ * deletes every public file the site has.
7313
+ */
7314
+ publicFiles: zod.z.array(zod.z.object({
7315
+ key: zod.z.string(),
7316
+ sha256: zod.z.string(),
7317
+ bytes: zod.z.number()["int"]().nonnegative()
7318
+ })).nullable().optional(),
7319
+ /**
7320
+ * The URL paths the live build serves from `public/`, as the loader has
7321
+ * them -- without the bytes' hashes.
7322
+ *
7323
+ * The fallback for when `publicFiles` is `null`: a build content has no
7324
+ * record of, which is every project cloned from a template seed. A publisher
7325
+ * running on the site's own origin can fetch these and build with them;
7326
+ * after that publish content holds their hashes and `publicFiles` answers.
7327
+ * `null` when the loader serves no build or does not say.
7328
+ */
7329
+ publicPaths: zod.z.array(zod.z.string()).nullable().optional()
7235
7330
  });
7236
7331
  var parseBuildTarget = function parseBuildTarget(body) {
7237
7332
  return parse(buildTargetResponse, body, "GET /v1/build-target");
@@ -2499,6 +2499,43 @@ var Api = {
2499
2499
  })])
2500
2500
  }
2501
2501
  },
2502
+ /**
2503
+ * The `.val.ts` text of every module that changed since the RUNNING build,
2504
+ * with every commit since it applied, for a build made in the browser.
2505
+ *
2506
+ * A Studio build starts from the source stored with the live build. A commit
2507
+ * whose own publish failed -- or the first commit of a project that started
2508
+ * as a copy of a template -- is in content and in no stored source, so a build
2509
+ * that added only its own save's files shipped without it. Only this server
2510
+ * can render those commits back into text: content keeps a managed project's
2511
+ * content as Source, not as files.
2512
+ *
2513
+ * Committed patches only. A pending one is somebody's unpublished work, and
2514
+ * is not this build's to ship. 409 where there is nothing to answer with: a
2515
+ * project with a repository, or a build that did not embed its source.
2516
+ */
2517
+ "/built-source": {
2518
+ GET: {
2519
+ req: {
2520
+ cookies: {
2521
+ val_session: z.string().optional()
2522
+ }
2523
+ },
2524
+ res: z.union([unauthorizedResponse, z.object({
2525
+ status: z.literal(409),
2526
+ json: GenericError
2527
+ }), z.object({
2528
+ status: z.literal(500),
2529
+ json: GenericError
2530
+ }), z.object({
2531
+ status: z.literal(200),
2532
+ json: z.object({
2533
+ /** By path, as `/save`'s `sourceFiles`. `null` is a deleted file. */
2534
+ files: z.record(z.string(), z.string().nullable())
2535
+ })
2536
+ })])
2537
+ }
2538
+ },
2502
2539
  "/profiles": {
2503
2540
  GET: {
2504
2541
  req: {
@@ -2599,6 +2636,34 @@ var Api = {
2599
2636
  * repository, and from a server that predates it.
2600
2637
  */
2601
2638
  sourceFiles: z.record(z.string(), z.string().nullable()).optional(),
2639
+ /**
2640
+ * The binary files this commit wrote -- an image uploaded in the
2641
+ * Studio -- base64, by path, for a MANAGED project.
2642
+ *
2643
+ * The same reason as `sourceFiles`: the in-tab build publishes the
2644
+ * site, and a file this commit added is in no earlier build. Local
2645
+ * files only; a remote one is served from its own URL and was never
2646
+ * part of a build. A deleted file is a `null` in `sourceFiles`, as
2647
+ * it always was.
2648
+ */
2649
+ binaryFiles: z.record(z.string(), z.string()).optional(),
2650
+ /**
2651
+ * The branch this commit is on, for a MANAGED project -- the
2652
+ * content service's word for it.
2653
+ *
2654
+ * The in-tab build has to name the branch it was made at, and its
2655
+ * only other source is the `val.server.ts` the last build was
2656
+ * wired with: a project cloned from a template seed has one wired
2657
+ * at no commit, so without this its first publish is branchless
2658
+ * and the loader refuses it.
2659
+ */
2660
+ branch: z.string().optional(),
2661
+ /**
2662
+ * Binary files this commit wrote whose bytes the server could not
2663
+ * read back before committing. Named so the Studio refuses to build
2664
+ * a site that would 404 them, rather than publishing it.
2665
+ */
2666
+ binaryFilesUnread: z.array(z.string()).optional(),
2602
2667
  /**
2603
2668
  * Unpublished changes the save threw away because they could not be
2604
2669
  * applied.
@@ -7224,7 +7289,37 @@ var buildTargetResponse = z.object({
7224
7289
  * "there is nothing here yet".
7225
7290
  */
7226
7291
  var projectSourceResponse = z.object({
7227
- files: z.record(z.string(), z.string()).nullable()
7292
+ files: z.record(z.string(), z.string()).nullable(),
7293
+ /**
7294
+ * The live build's `public/*` artifacts, by hash -- what a publisher with no
7295
+ * checkout carries into its build so the site keeps its favicon and images.
7296
+ *
7297
+ * The loader stores public files PER BUILD, so a build that names none
7298
+ * serves none. A publisher with a checkout has them on disk; the Studio has
7299
+ * this. Re-declaring one costs nothing: content holds the bytes for the
7300
+ * project already and asks for no upload.
7301
+ *
7302
+ * `null` when content cannot say -- the live build was not published through
7303
+ * it -- and absent from a content service that predates it. A publisher
7304
+ * must treat both as "unknown", never as "none": publishing on that guess
7305
+ * deletes every public file the site has.
7306
+ */
7307
+ publicFiles: z.array(z.object({
7308
+ key: z.string(),
7309
+ sha256: z.string(),
7310
+ bytes: z.number()["int"]().nonnegative()
7311
+ })).nullable().optional(),
7312
+ /**
7313
+ * The URL paths the live build serves from `public/`, as the loader has
7314
+ * them -- without the bytes' hashes.
7315
+ *
7316
+ * The fallback for when `publicFiles` is `null`: a build content has no
7317
+ * record of, which is every project cloned from a template seed. A publisher
7318
+ * running on the site's own origin can fetch these and build with them;
7319
+ * after that publish content holds their hashes and `publicFiles` answers.
7320
+ * `null` when the loader serves no build or does not say.
7321
+ */
7322
+ publicPaths: z.array(z.string()).nullable().optional()
7228
7323
  });
7229
7324
  var parseBuildTarget = function parseBuildTarget(body) {
7230
7325
  return parse(buildTargetResponse, body, "GET /v1/build-target");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/shared",
3
- "version": "0.136.1",
3
+ "version": "0.136.3",
4
4
  "private": false,
5
5
  "description": "Val shared types and utilities",
6
6
  "repository": {