Skip to content

Commit ee2144e

Browse files
Re-export standard schema instead of importing the package
1 parent f15077e commit ee2144e

File tree

5 files changed

+183
-14
lines changed

5 files changed

+183
-14
lines changed

packages/libs/restate-sdk-core/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,5 @@
4848
"prepublishOnly": "pnpm -w verify"
4949
},
5050
"dependencies": {},
51-
"devDependencies": {
52-
"@standard-schema/spec": "^1.1.0"
53-
}
51+
"devDependencies": {}
5452
}

packages/libs/restate-sdk-core/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ export type { Duration } from "./duration.js";
4040
export { durationToMillis, millisOrDurationToMillis } from "./duration.js";
4141

4242
export type { JournalValueCodec } from "./entry_codec.js";
43+
44+
export type { StandardTypedV1, StandardSchemaV1, StandardJSONSchemaV1 } from "./standard_schema.js";

packages/libs/restate-sdk-core/src/serde_api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import type {
1616
StandardJSONSchemaV1,
1717
StandardSchemaV1,
18-
} from "@standard-schema/spec";
18+
} from "./standard_schema.js";
1919

2020
export interface Serde<T> {
2121
contentType?: string;
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
/* eslint-disable @typescript-eslint/no-duplicate-type-constituents */
2+
/* eslint-disable @typescript-eslint/no-namespace */
3+
4+
/**
5+
* This file is copy pasted as is from https://standardschema.dev/
6+
*/
7+
8+
/** The Standard Typed interface. This is a base type extended by other specs. */
9+
export interface StandardTypedV1<Input = unknown, Output = Input> {
10+
/** The Standard properties. */
11+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
12+
}
13+
14+
export declare namespace StandardTypedV1 {
15+
/** The Standard Typed properties interface. */
16+
export interface Props<Input = unknown, Output = Input> {
17+
/** The version number of the standard. */
18+
readonly version: 1;
19+
/** The vendor name of the schema library. */
20+
readonly vendor: string;
21+
/** Inferred types associated with the schema. */
22+
readonly types?: Types<Input, Output> | undefined;
23+
}
24+
25+
/** The Standard Typed types interface. */
26+
export interface Types<Input = unknown, Output = Input> {
27+
/** The input type of the schema. */
28+
readonly input: Input;
29+
/** The output type of the schema. */
30+
readonly output: Output;
31+
}
32+
33+
/** Infers the input type of a Standard Typed. */
34+
export type InferInput<Schema extends StandardTypedV1> = NonNullable<
35+
Schema["~standard"]["types"]
36+
>["input"];
37+
38+
/** Infers the output type of a Standard Typed. */
39+
export type InferOutput<Schema extends StandardTypedV1> = NonNullable<
40+
Schema["~standard"]["types"]
41+
>["output"];
42+
}
43+
44+
/** The Standard Schema interface. */
45+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
46+
/** The Standard Schema properties. */
47+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
48+
}
49+
50+
export declare namespace StandardSchemaV1 {
51+
/** The Standard Schema properties interface. */
52+
export interface Props<
53+
Input = unknown,
54+
Output = Input,
55+
> extends StandardTypedV1.Props<Input, Output> {
56+
/** Validates unknown input values. */
57+
readonly validate: (
58+
value: unknown,
59+
options?: StandardSchemaV1.Options | undefined
60+
) => Result<Output> | Promise<Result<Output>>;
61+
}
62+
63+
/** The result interface of the validate function. */
64+
export type Result<Output> = SuccessResult<Output> | FailureResult;
65+
66+
/** The result interface if validation succeeds. */
67+
export interface SuccessResult<Output> {
68+
/** The typed output value. */
69+
readonly value: Output;
70+
/** A falsy value for `issues` indicates success. */
71+
readonly issues?: undefined;
72+
}
73+
74+
export interface Options {
75+
/** Explicit support for additional vendor-specific parameters, if needed. */
76+
readonly libraryOptions?: Record<string, unknown> | undefined;
77+
}
78+
79+
/** The result interface if validation fails. */
80+
export interface FailureResult {
81+
/** The issues of failed validation. */
82+
readonly issues: ReadonlyArray<Issue>;
83+
}
84+
85+
/** The issue interface of the failure output. */
86+
export interface Issue {
87+
/** The error message of the issue. */
88+
readonly message: string;
89+
/** The path of the issue, if any. */
90+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
91+
}
92+
93+
/** The path segment interface of the issue. */
94+
export interface PathSegment {
95+
/** The key representing a path segment. */
96+
readonly key: PropertyKey;
97+
}
98+
99+
/** The Standard types interface. */
100+
export interface Types<
101+
Input = unknown,
102+
Output = Input,
103+
> extends StandardTypedV1.Types<Input, Output> {}
104+
105+
/** Infers the input type of a Standard. */
106+
export type InferInput<Schema extends StandardTypedV1> =
107+
StandardTypedV1.InferInput<Schema>;
108+
109+
/** Infers the output type of a Standard. */
110+
export type InferOutput<Schema extends StandardTypedV1> =
111+
StandardTypedV1.InferOutput<Schema>;
112+
}
113+
114+
/** The Standard JSON Schema interface. */
115+
export interface StandardJSONSchemaV1<Input = unknown, Output = Input> {
116+
/** The Standard JSON Schema properties. */
117+
readonly "~standard": StandardJSONSchemaV1.Props<Input, Output>;
118+
}
119+
120+
export declare namespace StandardJSONSchemaV1 {
121+
/** The Standard JSON Schema properties interface. */
122+
export interface Props<
123+
Input = unknown,
124+
Output = Input,
125+
> extends StandardTypedV1.Props<Input, Output> {
126+
/** Methods for generating the input/output JSON Schema. */
127+
readonly jsonSchema: StandardJSONSchemaV1.Converter;
128+
}
129+
130+
/** The Standard JSON Schema converter interface. */
131+
export interface Converter {
132+
/** Converts the input type to JSON Schema. May throw if conversion is not supported. */
133+
readonly input: (
134+
options: StandardJSONSchemaV1.Options
135+
) => Record<string, unknown>;
136+
/** Converts the output type to JSON Schema. May throw if conversion is not supported. */
137+
readonly output: (
138+
options: StandardJSONSchemaV1.Options
139+
) => Record<string, unknown>;
140+
}
141+
142+
/**
143+
* The target version of the generated JSON Schema.
144+
*
145+
* It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.
146+
*
147+
* The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`.
148+
*/
149+
export type Target =
150+
| "draft-2020-12"
151+
| "draft-07"
152+
| "openapi-3.0"
153+
// Accepts any string: allows future targets while preserving autocomplete
154+
| ({} & string);
155+
156+
/** The options for the input/output methods. */
157+
export interface Options {
158+
/** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */
159+
readonly target: Target;
160+
161+
/** Explicit support for additional vendor-specific parameters, if needed. */
162+
readonly libraryOptions?: Record<string, unknown> | undefined;
163+
}
164+
165+
/** The Standard types interface. */
166+
export interface Types<
167+
Input = unknown,
168+
Output = Input,
169+
> extends StandardTypedV1.Types<Input, Output> {}
170+
171+
/** Infers the input type of a Standard. */
172+
export type InferInput<Schema extends StandardTypedV1> =
173+
StandardTypedV1.InferInput<Schema>;
174+
175+
/** Infers the output type of a Standard. */
176+
export type InferOutput<Schema extends StandardTypedV1> =
177+
StandardTypedV1.InferOutput<Schema>;
178+
}

pnpm-lock.yaml

Lines changed: 1 addition & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)