@moloodev/editor-store 0.5.0 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moloodev/editor-store",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/index.ts",
@@ -12,13 +12,13 @@
12
12
  "dependencies": {
13
13
  "@vercel/blob": "^2.8.0",
14
14
  "zod": "^4.5.4",
15
- "@moloodev/platform": "0.5.0"
15
+ "@moloodev/platform": "0.7.0"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@types/node": "^24.13.3",
19
19
  "tsx": "^4.23.13",
20
20
  "typescript": "^7.0.2",
21
- "@moloodev/typescript-config": "0.5.0"
21
+ "@moloodev/typescript-config": "0.7.0"
22
22
  },
23
23
  "publishConfig": {
24
24
  "access": "public"
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ export {
3
3
  cacheControl,
4
4
  encodePointer,
5
5
  isDnsId,
6
+ isRevisionScript,
6
7
  parsePointer,
7
8
  pointerFor,
8
9
  pointerPath,
package/src/pointer.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { EditorTrack } from "@moloodev/platform/editor-track";
1
2
  import { parseNetwork } from "@moloodev/platform/network";
2
3
  import { z } from "zod";
3
4
 
@@ -70,9 +71,10 @@ export function pointerFor(
70
71
  };
71
72
  }
72
73
 
73
- export function pointerPath(editorId: string): string {
74
+ /** `stable` is the editor's default pointer; other tracks add their name. */
75
+ export function pointerPath(editorId: string, track: EditorTrack): string {
74
76
  if (!isDnsId(editorId)) throw new Error("invalid id");
75
- return `pointers/${editorId}.json`;
77
+ return track === "stable" ? `pointers/${editorId}.json` : `pointers/${editorId}.${track}.json`;
76
78
  }
77
79
 
78
80
  export function encodePointer(pointer: Pointer): Uint8Array {
package/src/upload.ts CHANGED
@@ -51,7 +51,7 @@ type ScriptUploadToken = {
51
51
  validUntil: number;
52
52
  };
53
53
 
54
- // Shared private intake. Builtin publish and an external submission both
54
+ // Shared private intake. Immediate publication and reviewed submissions both
55
55
  // check the bytes at this pathname before they write a revision.
56
56
  export function uploadPath(id: string): string {
57
57
  if (!isDnsId(id)) throw new Error("invalid id");
package/src/write.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { EditorTrack } from "@moloodev/platform/editor-track";
1
2
  import { parseNetwork } from "@moloodev/platform/network";
2
3
  import {
3
4
  ARTIFACT_MAX_AGE,
@@ -18,6 +19,8 @@ export async function putRevision(
18
19
  readonly revisionId: string;
19
20
  readonly script: Uint8Array;
20
21
  readonly network: readonly string[];
22
+ /** Every track that should point at this revision. */
23
+ readonly tracks: readonly [EditorTrack, ...EditorTrack[]];
21
24
  },
22
25
  ): Promise<Pointer> {
23
26
  const pointer = pointerFor(
@@ -34,10 +37,12 @@ export async function putRevision(
34
37
  maxAge: ARTIFACT_MAX_AGE,
35
38
  immutable: true,
36
39
  });
37
- await writer.write(pointerPath(input.editorId), encodePointer(pointer), {
38
- contentType: POINTER_TYPE,
39
- maxAge: POINTER_MAX_AGE,
40
- immutable: false,
41
- });
40
+ for (const track of input.tracks) {
41
+ await writer.write(pointerPath(input.editorId, track), encodePointer(pointer), {
42
+ contentType: POINTER_TYPE,
43
+ maxAge: POINTER_MAX_AGE,
44
+ immutable: false,
45
+ });
46
+ }
42
47
  return pointer;
43
48
  }