@valbuild/shared 0.63.1 → 0.64.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.
@@ -0,0 +1,49 @@
1
+ import { ModuleFilePath, PatchId, SerializedSchema } from "@valbuild/core";
2
+ import { result } from "@valbuild/core/fp";
3
+ import { Patch } from "@valbuild/core/patch";
4
+ import { ValClient } from "./ValClient.js";
5
+ export type ValCacheError = {
6
+ errorType: "patch-error";
7
+ errors: {
8
+ moduleFilePath: string;
9
+ patchId: PatchId;
10
+ skipped: boolean;
11
+ patchError: string;
12
+ }[];
13
+ } | {
14
+ errorType: "other";
15
+ message: string;
16
+ };
17
+ export declare class ValCache {
18
+ private readonly client;
19
+ private readonly drafts;
20
+ private readonly schema;
21
+ constructor(client: ValClient);
22
+ reloadPaths(paths: ModuleFilePath[]): Promise<void>;
23
+ reset(): Promise<result.Result<undefined, ValCacheError>>;
24
+ getModule(path: ModuleFilePath, refetch?: boolean): Promise<result.Err<{
25
+ message: string;
26
+ }> | result.Ok<{
27
+ source: any;
28
+ schema: SerializedSchema;
29
+ }>>;
30
+ deletePatches(patchIds: PatchId[]): Promise<result.Result<PatchId[], {
31
+ message: string;
32
+ }>>;
33
+ applyPatch(path: ModuleFilePath, patchIds: PatchId[], patch: Patch): Promise<result.Result<{
34
+ modules: Record<ModuleFilePath, {
35
+ patchIds: PatchId[];
36
+ }>;
37
+ newPatchId: PatchId;
38
+ }, ValCacheError>>;
39
+ private emitEvent;
40
+ initialize(): Promise<result.Result<ModuleFilePath[], {
41
+ message: string;
42
+ details: {
43
+ fetchError: {
44
+ message: string;
45
+ statusCode?: number;
46
+ };
47
+ };
48
+ }>>;
49
+ }
@@ -0,0 +1,3 @@
1
+ import { Api, ClientOf } from "./ApiRoutes.js";
2
+ export type ValClient = ClientOf<Api>;
3
+ export declare const createValClient: (host: string) => ValClient;
@@ -0,0 +1,3 @@
1
+ import { Api, UrlOf } from "./ApiRoutes.js";
2
+ export type ValUrls = UrlOf<typeof Api>;
3
+ export declare const urlOf: ValUrls;
@@ -1,4 +1,6 @@
1
1
  export * from "./richtext/conversion/index.js";
2
- export * from "./mimeType/index.js";
3
2
  export * from "./server/types.js";
4
- export * from "./ValStore.js";
3
+ export * from "./ValCache.js";
4
+ export * from "./ValClient.js";
5
+ export * from "./ValUrls.js";
6
+ export * from "./ApiRoutes.js";
@@ -1,4 +1,4 @@
1
- import { ApiPostValidationErrorResponse, ApiTreeResponse, Json } from "@valbuild/core";
1
+ import { Json } from "@valbuild/core";
2
2
  export declare const VAL_SESSION_COOKIE: "val_session";
3
3
  export declare const VAL_STATE_COOKIE: "val_state";
4
4
  export declare const VAL_ENABLE_COOKIE_NAME: "val_enable";
@@ -38,17 +38,14 @@ export type ValServerResult<Names extends ValCookiesNames, Body extends string |
38
38
  cookies?: ValServerResultCookies<Names>;
39
39
  body?: Body;
40
40
  } | ValServerError;
41
- export type ValServerJsonResult<Body extends Json | ApiPostValidationErrorResponse | ApiTreeResponse | never = never, Error extends Json | ApiPostValidationErrorResponse | never = never> = {
41
+ export type ValServerJsonResult<Body extends Json | never = never, Error extends Json | never = never> = {
42
42
  status: 200 | 201;
43
43
  json: Body;
44
- } | ValServerError | (Error extends Json | ApiPostValidationErrorResponse ? {
44
+ } | ValServerError | (Error extends Json ? {
45
45
  status: 400;
46
46
  json: Error;
47
47
  } : never);
48
- export type ValServerGenericResult = ValServerJsonResult<Json> | ValServerError | {
49
- status: 400;
50
- json: ApiPostValidationErrorResponse;
51
- } | ValServerRedirectResult<ValCookiesNames> | ValServerResult<ValCookiesNames, string | ReadableStream<Uint8Array>>;
48
+ export type ValServerGenericResult = ValServerJsonResult<Json> | ValServerError | ValServerRedirectResult<ValCookiesNames> | ValServerResult<ValCookiesNames, string | ReadableStream<Uint8Array>>;
52
49
  export type ValUIRequestHandler = (path: string, url: string) => Promise<ValServerGenericResult>;
53
50
  export type ValSession = {
54
51
  mode: "unauthorized";