@rivetkit/engine-api-full 25.5.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/dist/browser/cjs/core.js +2297 -0
- package/dist/browser/cjs/index.js +3752 -0
- package/dist/browser/cjs/serialization.js +1744 -0
- package/dist/browser/esm/core.js +2271 -0
- package/dist/browser/esm/index.js +3726 -0
- package/dist/browser/esm/serialization.js +1717 -0
- package/dist/node/core.js +2310 -0
- package/dist/node/index.js +3765 -0
- package/dist/node/serialization.js +1782 -0
- package/package.json +59 -0
- package/types/Client.d.ts +241 -0
- package/types/api/client/index.d.ts +1 -0
- package/types/api/client/requests/ActorsCreateRequest.d.ts +22 -0
- package/types/api/client/requests/ActorsDeleteRequest.d.ts +10 -0
- package/types/api/client/requests/ActorsGetByIdRequest.d.ts +16 -0
- package/types/api/client/requests/ActorsGetOrCreateByIdRequest.d.ts +23 -0
- package/types/api/client/requests/ActorsGetOrCreateRequest.d.ts +23 -0
- package/types/api/client/requests/ActorsGetRequest.d.ts +10 -0
- package/types/api/client/requests/ActorsListNamesRequest.d.ts +14 -0
- package/types/api/client/requests/ActorsListRequest.d.ts +18 -0
- package/types/api/client/requests/index.d.ts +8 -0
- package/types/api/index.d.ts +3 -0
- package/types/api/resources/datacenters/client/Client.d.ts +34 -0
- package/types/api/resources/datacenters/client/index.d.ts +1 -0
- package/types/api/resources/datacenters/index.d.ts +1 -0
- package/types/api/resources/index.d.ts +5 -0
- package/types/api/resources/namespaces/client/Client.d.ts +54 -0
- package/types/api/resources/namespaces/client/index.d.ts +1 -0
- package/types/api/resources/namespaces/client/requests/NamespacesCreateRequest.d.ts +14 -0
- package/types/api/resources/namespaces/client/requests/NamespacesListRequest.d.ts +12 -0
- package/types/api/resources/namespaces/client/requests/index.d.ts +2 -0
- package/types/api/resources/namespaces/index.d.ts +1 -0
- package/types/api/resources/runners/client/Client.d.ts +61 -0
- package/types/api/resources/runners/client/index.d.ts +1 -0
- package/types/api/resources/runners/client/requests/RunnersGetRequest.d.ts +10 -0
- package/types/api/resources/runners/client/requests/RunnersListNamesRequest.d.ts +14 -0
- package/types/api/resources/runners/client/requests/RunnersListRequest.d.ts +16 -0
- package/types/api/resources/runners/client/requests/index.d.ts +3 -0
- package/types/api/resources/runners/index.d.ts +1 -0
- package/types/api/types/Actor.d.ts +19 -0
- package/types/api/types/ActorName.d.ts +6 -0
- package/types/api/types/ActorsCreateResponse.d.ts +7 -0
- package/types/api/types/ActorsDeleteResponse.d.ts +4 -0
- package/types/api/types/ActorsGetByIdResponse.d.ts +7 -0
- package/types/api/types/ActorsGetOrCreateByIdResponse.d.ts +8 -0
- package/types/api/types/ActorsGetOrCreateResponse.d.ts +8 -0
- package/types/api/types/ActorsGetResponse.d.ts +7 -0
- package/types/api/types/ActorsListNamesResponse.d.ts +8 -0
- package/types/api/types/ActorsListResponse.d.ts +8 -0
- package/types/api/types/CrashPolicy.d.ts +9 -0
- package/types/api/types/Datacenter.d.ts +8 -0
- package/types/api/types/DatacentersListResponse.d.ts +8 -0
- package/types/api/types/Namespace.d.ts +10 -0
- package/types/api/types/NamespacesCreateResponse.d.ts +7 -0
- package/types/api/types/NamespacesGetResponse.d.ts +7 -0
- package/types/api/types/NamespacesListResponse.d.ts +8 -0
- package/types/api/types/Pagination.d.ts +6 -0
- package/types/api/types/RivetId.d.ts +4 -0
- package/types/api/types/Runner.d.ts +24 -0
- package/types/api/types/RunnersGetResponse.d.ts +7 -0
- package/types/api/types/RunnersListNamesResponse.d.ts +8 -0
- package/types/api/types/RunnersListResponse.d.ts +8 -0
- package/types/api/types/StringHttpAddressHashableMap.d.ts +5 -0
- package/types/api/types/StringHttpAddressHashableMapValue.d.ts +7 -0
- package/types/api/types/StringTcpAddressHashableMap.d.ts +5 -0
- package/types/api/types/StringTcpAddressHashableMapValue.d.ts +7 -0
- package/types/api/types/StringUdpAddressHashableMap.d.ts +5 -0
- package/types/api/types/StringUdpAddressHashableMapValue.d.ts +7 -0
- package/types/api/types/index.d.ts +29 -0
- package/types/core/fetcher/APIResponse.d.ts +10 -0
- package/types/core/fetcher/Fetcher.d.ts +39 -0
- package/types/core/fetcher/Supplier.d.ts +4 -0
- package/types/core/fetcher/createRequestUrl.d.ts +1 -0
- package/types/core/fetcher/getFetchFn.d.ts +4 -0
- package/types/core/fetcher/getHeader.d.ts +1 -0
- package/types/core/fetcher/getRequestBody.d.ts +7 -0
- package/types/core/fetcher/getResponseBody.d.ts +1 -0
- package/types/core/fetcher/index.d.ts +5 -0
- package/types/core/fetcher/makeRequest.d.ts +1 -0
- package/types/core/fetcher/requestWithRetries.d.ts +1 -0
- package/types/core/fetcher/signals.d.ts +11 -0
- package/types/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
- package/types/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +21 -0
- package/types/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
- package/types/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
- package/types/core/index.d.ts +3 -0
- package/types/core/json.d.ts +15 -0
- package/types/core/runtime/index.d.ts +1 -0
- package/types/core/runtime/runtime.d.ts +9 -0
- package/types/core/schemas/Schema.d.ts +87 -0
- package/types/core/schemas/builders/bigint/bigint.d.ts +2 -0
- package/types/core/schemas/builders/bigint/index.d.ts +1 -0
- package/types/core/schemas/builders/date/date.d.ts +2 -0
- package/types/core/schemas/builders/date/index.d.ts +1 -0
- package/types/core/schemas/builders/enum/enum.d.ts +2 -0
- package/types/core/schemas/builders/enum/index.d.ts +1 -0
- package/types/core/schemas/builders/index.d.ts +14 -0
- package/types/core/schemas/builders/lazy/index.d.ts +3 -0
- package/types/core/schemas/builders/lazy/lazy.d.ts +5 -0
- package/types/core/schemas/builders/lazy/lazyObject.d.ts +3 -0
- package/types/core/schemas/builders/list/index.d.ts +1 -0
- package/types/core/schemas/builders/list/list.d.ts +2 -0
- package/types/core/schemas/builders/literals/booleanLiteral.d.ts +2 -0
- package/types/core/schemas/builders/literals/index.d.ts +2 -0
- package/types/core/schemas/builders/literals/stringLiteral.d.ts +2 -0
- package/types/core/schemas/builders/object/index.d.ts +6 -0
- package/types/core/schemas/builders/object/object.d.ts +3 -0
- package/types/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +6 -0
- package/types/core/schemas/builders/object/property.d.ts +8 -0
- package/types/core/schemas/builders/object/types.d.ts +31 -0
- package/types/core/schemas/builders/object-like/getObjectLikeUtils.d.ts +9 -0
- package/types/core/schemas/builders/object-like/index.d.ts +2 -0
- package/types/core/schemas/builders/object-like/types.d.ts +7 -0
- package/types/core/schemas/builders/primitives/any.d.ts +1 -0
- package/types/core/schemas/builders/primitives/boolean.d.ts +1 -0
- package/types/core/schemas/builders/primitives/index.d.ts +5 -0
- package/types/core/schemas/builders/primitives/number.d.ts +1 -0
- package/types/core/schemas/builders/primitives/string.d.ts +1 -0
- package/types/core/schemas/builders/primitives/unknown.d.ts +1 -0
- package/types/core/schemas/builders/record/index.d.ts +2 -0
- package/types/core/schemas/builders/record/record.d.ts +3 -0
- package/types/core/schemas/builders/record/types.d.ts +4 -0
- package/types/core/schemas/builders/schema-utils/JsonError.d.ts +5 -0
- package/types/core/schemas/builders/schema-utils/ParseError.d.ts +5 -0
- package/types/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +21 -0
- package/types/core/schemas/builders/schema-utils/index.d.ts +4 -0
- package/types/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts +2 -0
- package/types/core/schemas/builders/set/index.d.ts +1 -0
- package/types/core/schemas/builders/set/set.d.ts +2 -0
- package/types/core/schemas/builders/undiscriminated-union/index.d.ts +2 -0
- package/types/core/schemas/builders/undiscriminated-union/types.d.ts +4 -0
- package/types/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts +3 -0
- package/types/core/schemas/builders/union/discriminant.d.ts +5 -0
- package/types/core/schemas/builders/union/index.d.ts +4 -0
- package/types/core/schemas/builders/union/types.d.ts +13 -0
- package/types/core/schemas/builders/union/union.d.ts +4 -0
- package/types/core/schemas/index.d.ts +2 -0
- package/types/core/schemas/utils/MaybePromise.d.ts +1 -0
- package/types/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +7 -0
- package/types/core/schemas/utils/createIdentitySchemaCreator.d.ts +2 -0
- package/types/core/schemas/utils/entries.d.ts +1 -0
- package/types/core/schemas/utils/filterObject.d.ts +1 -0
- package/types/core/schemas/utils/getErrorMessageForIncorrectType.d.ts +1 -0
- package/types/core/schemas/utils/isPlainObject.d.ts +1 -0
- package/types/core/schemas/utils/keys.d.ts +1 -0
- package/types/core/schemas/utils/maybeSkipValidation.d.ts +2 -0
- package/types/core/schemas/utils/partition.d.ts +1 -0
- package/types/errors/RivetError.d.ts +12 -0
- package/types/errors/RivetTimeoutError.d.ts +6 -0
- package/types/errors/index.d.ts +2 -0
- package/types/index.d.ts +4 -0
- package/types/serialization/client/index.d.ts +1 -0
- package/types/serialization/client/requests/ActorsCreateRequest.d.ts +17 -0
- package/types/serialization/client/requests/ActorsGetOrCreateByIdRequest.d.ts +17 -0
- package/types/serialization/client/requests/ActorsGetOrCreateRequest.d.ts +17 -0
- package/types/serialization/client/requests/index.d.ts +3 -0
- package/types/serialization/index.d.ts +3 -0
- package/types/serialization/resources/index.d.ts +2 -0
- package/types/serialization/resources/namespaces/client/index.d.ts +1 -0
- package/types/serialization/resources/namespaces/client/requests/NamespacesCreateRequest.d.ts +13 -0
- package/types/serialization/resources/namespaces/client/requests/index.d.ts +1 -0
- package/types/serialization/resources/namespaces/index.d.ts +1 -0
- package/types/serialization/types/Actor.d.ts +26 -0
- package/types/serialization/types/ActorName.d.ts +12 -0
- package/types/serialization/types/ActorsCreateResponse.d.ts +13 -0
- package/types/serialization/types/ActorsDeleteResponse.d.ts +10 -0
- package/types/serialization/types/ActorsGetByIdResponse.d.ts +13 -0
- package/types/serialization/types/ActorsGetOrCreateByIdResponse.d.ts +14 -0
- package/types/serialization/types/ActorsGetOrCreateResponse.d.ts +14 -0
- package/types/serialization/types/ActorsGetResponse.d.ts +13 -0
- package/types/serialization/types/ActorsListNamesResponse.d.ts +15 -0
- package/types/serialization/types/ActorsListResponse.d.ts +15 -0
- package/types/serialization/types/CrashPolicy.d.ts +10 -0
- package/types/serialization/types/Datacenter.d.ts +14 -0
- package/types/serialization/types/DatacentersListResponse.d.ts +15 -0
- package/types/serialization/types/Namespace.d.ts +16 -0
- package/types/serialization/types/NamespacesCreateResponse.d.ts +13 -0
- package/types/serialization/types/NamespacesGetResponse.d.ts +13 -0
- package/types/serialization/types/NamespacesListResponse.d.ts +15 -0
- package/types/serialization/types/Pagination.d.ts +12 -0
- package/types/serialization/types/RivetId.d.ts +10 -0
- package/types/serialization/types/Runner.d.ts +33 -0
- package/types/serialization/types/RunnersGetResponse.d.ts +13 -0
- package/types/serialization/types/RunnersListNamesResponse.d.ts +14 -0
- package/types/serialization/types/RunnersListResponse.d.ts +15 -0
- package/types/serialization/types/StringHttpAddressHashableMap.d.ts +11 -0
- package/types/serialization/types/StringHttpAddressHashableMapValue.d.ts +13 -0
- package/types/serialization/types/StringTcpAddressHashableMap.d.ts +11 -0
- package/types/serialization/types/StringTcpAddressHashableMapValue.d.ts +13 -0
- package/types/serialization/types/StringUdpAddressHashableMap.d.ts +11 -0
- package/types/serialization/types/StringUdpAddressHashableMapValue.d.ts +13 -0
- package/types/serialization/types/index.d.ts +29 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { SchemaUtils } from "./builders";
|
|
2
|
+
export type Schema<Raw = unknown, Parsed = unknown> = BaseSchema<Raw, Parsed> & SchemaUtils<Raw, Parsed>;
|
|
3
|
+
export type inferRaw<S extends Schema> = S extends Schema<infer Raw, any> ? Raw : never;
|
|
4
|
+
export type inferParsed<S extends Schema> = S extends Schema<any, infer Parsed> ? Parsed : never;
|
|
5
|
+
export interface BaseSchema<Raw, Parsed> {
|
|
6
|
+
parse: (raw: unknown, opts?: SchemaOptions) => MaybeValid<Parsed>;
|
|
7
|
+
json: (parsed: unknown, opts?: SchemaOptions) => MaybeValid<Raw>;
|
|
8
|
+
getType: () => SchemaType | SchemaType;
|
|
9
|
+
}
|
|
10
|
+
export declare const SchemaType: {
|
|
11
|
+
readonly BIGINT: "bigint";
|
|
12
|
+
readonly DATE: "date";
|
|
13
|
+
readonly ENUM: "enum";
|
|
14
|
+
readonly LIST: "list";
|
|
15
|
+
readonly STRING_LITERAL: "stringLiteral";
|
|
16
|
+
readonly BOOLEAN_LITERAL: "booleanLiteral";
|
|
17
|
+
readonly OBJECT: "object";
|
|
18
|
+
readonly ANY: "any";
|
|
19
|
+
readonly BOOLEAN: "boolean";
|
|
20
|
+
readonly NUMBER: "number";
|
|
21
|
+
readonly STRING: "string";
|
|
22
|
+
readonly UNKNOWN: "unknown";
|
|
23
|
+
readonly RECORD: "record";
|
|
24
|
+
readonly SET: "set";
|
|
25
|
+
readonly UNION: "union";
|
|
26
|
+
readonly UNDISCRIMINATED_UNION: "undiscriminatedUnion";
|
|
27
|
+
readonly NULLABLE: "nullable";
|
|
28
|
+
readonly OPTIONAL: "optional";
|
|
29
|
+
readonly OPTIONAL_NULLABLE: "optionalNullable";
|
|
30
|
+
};
|
|
31
|
+
export type SchemaType = (typeof SchemaType)[keyof typeof SchemaType];
|
|
32
|
+
export type MaybeValid<T> = Valid<T> | Invalid;
|
|
33
|
+
export interface Valid<T> {
|
|
34
|
+
ok: true;
|
|
35
|
+
value: T;
|
|
36
|
+
}
|
|
37
|
+
export interface Invalid {
|
|
38
|
+
ok: false;
|
|
39
|
+
errors: ValidationError[];
|
|
40
|
+
}
|
|
41
|
+
export interface ValidationError {
|
|
42
|
+
path: string[];
|
|
43
|
+
message: string;
|
|
44
|
+
}
|
|
45
|
+
export interface SchemaOptions {
|
|
46
|
+
/**
|
|
47
|
+
* how to handle unrecognized keys in objects
|
|
48
|
+
*
|
|
49
|
+
* @default "fail"
|
|
50
|
+
*/
|
|
51
|
+
unrecognizedObjectKeys?: "fail" | "passthrough" | "strip";
|
|
52
|
+
/**
|
|
53
|
+
* whether to fail when an unrecognized discriminant value is
|
|
54
|
+
* encountered in a union
|
|
55
|
+
*
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
allowUnrecognizedUnionMembers?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* whether to fail when an unrecognized enum value is encountered
|
|
61
|
+
*
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
allowUnrecognizedEnumValues?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* whether to allow data that doesn't conform to the schema.
|
|
67
|
+
* invalid data is passed through without transformation.
|
|
68
|
+
*
|
|
69
|
+
* when this is enabled, .parse() and .json() will always
|
|
70
|
+
* return `ok: true`. `.parseOrThrow()` and `.jsonOrThrow()`
|
|
71
|
+
* will never fail.
|
|
72
|
+
*
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
skipValidation?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* each validation failure contains a "path" property, which is
|
|
78
|
+
* the breadcrumbs to the offending node in the JSON. you can supply
|
|
79
|
+
* a prefix that is prepended to all the errors' paths. this can be
|
|
80
|
+
* helpful for zurg's internal debug logging.
|
|
81
|
+
*/
|
|
82
|
+
breadcrumbsPrefix?: string[];
|
|
83
|
+
/**
|
|
84
|
+
* whether to send 'null' for optional properties explicitly set to 'undefined'.
|
|
85
|
+
*/
|
|
86
|
+
omitUndefined?: boolean;
|
|
87
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { bigint } from "./bigint";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { date } from "./date";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { enum_ } from "./enum";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./bigint";
|
|
2
|
+
export * from "./date";
|
|
3
|
+
export * from "./enum";
|
|
4
|
+
export * from "./lazy";
|
|
5
|
+
export * from "./list";
|
|
6
|
+
export * from "./literals";
|
|
7
|
+
export * from "./object";
|
|
8
|
+
export * from "./object-like";
|
|
9
|
+
export * from "./primitives";
|
|
10
|
+
export * from "./record";
|
|
11
|
+
export * from "./schema-utils";
|
|
12
|
+
export * from "./set";
|
|
13
|
+
export * from "./undiscriminated-union";
|
|
14
|
+
export * from "./union";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BaseSchema, Schema } from "../../Schema";
|
|
2
|
+
export type SchemaGetter<SchemaType extends Schema<any, any>> = () => SchemaType;
|
|
3
|
+
export declare function lazy<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): Schema<Raw, Parsed>;
|
|
4
|
+
export declare function constructLazyBaseSchema<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): BaseSchema<Raw, Parsed>;
|
|
5
|
+
export declare function getMemoizedSchema<SchemaType extends Schema<any, any>>(getter: SchemaGetter<SchemaType>): SchemaType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { list } from "./list";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { getObjectUtils, object } from "./object";
|
|
2
|
+
export { objectWithoutOptionalProperties } from "./objectWithoutOptionalProperties";
|
|
3
|
+
export type { inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas, inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas, } from "./objectWithoutOptionalProperties";
|
|
4
|
+
export { isProperty, property } from "./property";
|
|
5
|
+
export type { Property } from "./property";
|
|
6
|
+
export type { BaseObjectSchema, inferObjectSchemaFromPropertySchemas, inferParsedObject, inferParsedObjectFromPropertySchemas, inferParsedPropertySchema, inferRawKey, inferRawObject, inferRawObjectFromPropertySchemas, inferRawPropertySchema, ObjectSchema, ObjectUtils, PropertySchemas, } from "./types";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { BaseObjectSchema, ObjectUtils, PropertySchemas, inferObjectSchemaFromPropertySchemas } from "./types";
|
|
2
|
+
export declare function object<ParsedKeys extends string, T extends PropertySchemas<ParsedKeys>>(schemas: T): inferObjectSchemaFromPropertySchemas<T>;
|
|
3
|
+
export declare function getObjectUtils<Raw, Parsed>(schema: BaseObjectSchema<Raw, Parsed>): ObjectUtils<Raw, Parsed>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ObjectSchema, PropertySchemas, inferParsedPropertySchema, inferRawObjectFromPropertySchemas } from "./types";
|
|
2
|
+
export declare function objectWithoutOptionalProperties<ParsedKeys extends string, T extends PropertySchemas<ParsedKeys>>(schemas: T): inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas<T>;
|
|
3
|
+
export type inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas<T extends PropertySchemas<keyof T>> = ObjectSchema<inferRawObjectFromPropertySchemas<T>, inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas<T>>;
|
|
4
|
+
export type inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas<T extends PropertySchemas<keyof T>> = {
|
|
5
|
+
[K in keyof T]: inferParsedPropertySchema<T[K]>;
|
|
6
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Schema } from "../../Schema";
|
|
2
|
+
export declare function property<RawKey extends string, RawValue, ParsedValue>(rawKey: RawKey, valueSchema: Schema<RawValue, ParsedValue>): Property<RawKey, RawValue, ParsedValue>;
|
|
3
|
+
export interface Property<RawKey extends string, RawValue, ParsedValue> {
|
|
4
|
+
rawKey: RawKey;
|
|
5
|
+
valueSchema: Schema<RawValue, ParsedValue>;
|
|
6
|
+
isProperty: true;
|
|
7
|
+
}
|
|
8
|
+
export declare function isProperty<O extends Property<any, any, any>>(maybeProperty: unknown): maybeProperty is O;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BaseSchema, Schema, inferParsed, inferRaw } from "../../Schema";
|
|
2
|
+
import { addQuestionMarksToNullableProperties } from "../../utils/addQuestionMarksToNullableProperties";
|
|
3
|
+
import { ObjectLikeUtils } from "../object-like";
|
|
4
|
+
import { SchemaUtils } from "../schema-utils";
|
|
5
|
+
import { Property } from "./property";
|
|
6
|
+
export type ObjectSchema<Raw, Parsed> = BaseObjectSchema<Raw, Parsed> & ObjectLikeUtils<Raw, Parsed> & ObjectUtils<Raw, Parsed> & SchemaUtils<Raw, Parsed>;
|
|
7
|
+
export interface BaseObjectSchema<Raw, Parsed> extends BaseSchema<Raw, Parsed> {
|
|
8
|
+
_getRawProperties: () => (keyof Raw)[];
|
|
9
|
+
_getParsedProperties: () => (keyof Parsed)[];
|
|
10
|
+
}
|
|
11
|
+
export interface ObjectUtils<Raw, Parsed> {
|
|
12
|
+
extend: <RawExtension, ParsedExtension>(schemas: ObjectSchema<RawExtension, ParsedExtension>) => ObjectSchema<Raw & RawExtension, Parsed & ParsedExtension>;
|
|
13
|
+
passthrough: () => ObjectSchema<Raw & {
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}, Parsed & {
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
export type inferRawObject<O extends ObjectSchema<any, any>> = O extends ObjectSchema<infer Raw, any> ? Raw : never;
|
|
20
|
+
export type inferParsedObject<O extends ObjectSchema<any, any>> = O extends ObjectSchema<any, infer Parsed> ? Parsed : never;
|
|
21
|
+
export type inferObjectSchemaFromPropertySchemas<T extends PropertySchemas<keyof T>> = ObjectSchema<inferRawObjectFromPropertySchemas<T>, inferParsedObjectFromPropertySchemas<T>>;
|
|
22
|
+
export type inferRawObjectFromPropertySchemas<T extends PropertySchemas<keyof T>> = addQuestionMarksToNullableProperties<{
|
|
23
|
+
[ParsedKey in keyof T as inferRawKey<ParsedKey, T[ParsedKey]>]: inferRawPropertySchema<T[ParsedKey]>;
|
|
24
|
+
}>;
|
|
25
|
+
export type inferParsedObjectFromPropertySchemas<T extends PropertySchemas<keyof T>> = addQuestionMarksToNullableProperties<{
|
|
26
|
+
[K in keyof T]: inferParsedPropertySchema<T[K]>;
|
|
27
|
+
}>;
|
|
28
|
+
export type PropertySchemas<ParsedKeys extends string | number | symbol> = Record<ParsedKeys, Property<any, any, any> | Schema<any, any>>;
|
|
29
|
+
export type inferRawPropertySchema<P extends Property<any, any, any> | Schema<any, any>> = P extends Property<any, infer Raw, any> ? Raw : P extends Schema<any, any> ? inferRaw<P> : never;
|
|
30
|
+
export type inferParsedPropertySchema<P extends Property<any, any, any> | Schema<any, any>> = P extends Property<any, any, infer Parsed> ? Parsed : P extends Schema<any, any> ? inferParsed<P> : never;
|
|
31
|
+
export type inferRawKey<ParsedKey extends string | number | symbol, P extends Property<any, any, any> | Schema<any, any>> = P extends Property<infer Raw, any, any> ? Raw : ParsedKey;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseSchema } from "../../Schema";
|
|
2
|
+
import { ObjectLikeSchema, ObjectLikeUtils } from "./types";
|
|
3
|
+
export declare function getObjectLikeUtils<Raw, Parsed>(schema: BaseSchema<Raw, Parsed>): ObjectLikeUtils<Raw, Parsed>;
|
|
4
|
+
/**
|
|
5
|
+
* object-like utils are defined in one file to resolve issues with circular imports
|
|
6
|
+
*/
|
|
7
|
+
export declare function withParsedProperties<RawObjectShape, ParsedObjectShape, Properties>(objectLike: BaseSchema<RawObjectShape, ParsedObjectShape>, properties: {
|
|
8
|
+
[K in keyof Properties]: Properties[K] | ((parsed: ParsedObjectShape) => Properties[K]);
|
|
9
|
+
}): ObjectLikeSchema<RawObjectShape, ParsedObjectShape & Properties>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseSchema, Schema } from "../../Schema";
|
|
2
|
+
export type ObjectLikeSchema<Raw, Parsed> = Schema<Raw, Parsed> & BaseSchema<Raw, Parsed> & ObjectLikeUtils<Raw, Parsed>;
|
|
3
|
+
export interface ObjectLikeUtils<Raw, Parsed> {
|
|
4
|
+
withParsedProperties: <T extends Record<string, any>>(properties: {
|
|
5
|
+
[K in keyof T]: T[K] | ((parsed: Parsed) => T[K]);
|
|
6
|
+
}) => ObjectLikeSchema<Raw, Parsed & T>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const any: () => import("../../Schema").Schema<any, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const boolean: () => import("../../Schema").Schema<boolean, boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const number: () => import("../../Schema").Schema<number, number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const string: () => import("../../Schema").Schema<string, string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const unknown: () => import("../../Schema").Schema<unknown, unknown>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Schema } from "../../Schema";
|
|
2
|
+
import { RecordSchema } from "./types";
|
|
3
|
+
export declare function record<RawKey extends string | number, RawValue, ParsedValue, ParsedKey extends string | number>(keySchema: Schema<RawKey, ParsedKey>, valueSchema: Schema<RawValue, ParsedValue>): RecordSchema<RawKey, RawValue, ParsedKey, ParsedValue>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BaseSchema } from "../../Schema";
|
|
2
|
+
import { SchemaUtils } from "../schema-utils";
|
|
3
|
+
export type RecordSchema<RawKey extends string | number, RawValue, ParsedKey extends string | number, ParsedValue> = BaseRecordSchema<RawKey, RawValue, ParsedKey, ParsedValue> & SchemaUtils<Record<RawKey, RawValue>, Record<ParsedKey, ParsedValue>>;
|
|
4
|
+
export type BaseRecordSchema<RawKey extends string | number, RawValue, ParsedKey extends string | number, ParsedValue> = BaseSchema<Record<RawKey, RawValue>, Record<ParsedKey, ParsedValue>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseSchema, Schema, SchemaOptions } from "../../Schema";
|
|
2
|
+
export interface SchemaUtils<Raw, Parsed> {
|
|
3
|
+
nullable: () => Schema<Raw | null, Parsed | null>;
|
|
4
|
+
optional: () => Schema<Raw | null | undefined, Parsed | undefined>;
|
|
5
|
+
optionalNullable: () => Schema<Raw | null | undefined, Parsed | null | undefined>;
|
|
6
|
+
transform: <Transformed>(transformer: SchemaTransformer<Parsed, Transformed>) => Schema<Raw, Transformed>;
|
|
7
|
+
parseOrThrow: (raw: unknown, opts?: SchemaOptions) => Parsed;
|
|
8
|
+
jsonOrThrow: (raw: unknown, opts?: SchemaOptions) => Raw;
|
|
9
|
+
}
|
|
10
|
+
export interface SchemaTransformer<Parsed, Transformed> {
|
|
11
|
+
transform: (parsed: Parsed) => Transformed;
|
|
12
|
+
untransform: (transformed: any) => Parsed;
|
|
13
|
+
}
|
|
14
|
+
export declare function getSchemaUtils<Raw, Parsed>(schema: BaseSchema<Raw, Parsed>): SchemaUtils<Raw, Parsed>;
|
|
15
|
+
/**
|
|
16
|
+
* schema utils are defined in one file to resolve issues with circular imports
|
|
17
|
+
*/
|
|
18
|
+
export declare function nullable<Raw, Parsed>(schema: BaseSchema<Raw, Parsed>): Schema<Raw | null, Parsed | null>;
|
|
19
|
+
export declare function optional<Raw, Parsed>(schema: BaseSchema<Raw, Parsed>): Schema<Raw | null | undefined, Parsed | undefined>;
|
|
20
|
+
export declare function optionalNullable<Raw, Parsed>(schema: BaseSchema<Raw, Parsed>): Schema<Raw | null | undefined, Parsed | null | undefined>;
|
|
21
|
+
export declare function transform<Raw, Parsed, Transformed>(schema: BaseSchema<Raw, Parsed>, transformer: SchemaTransformer<Parsed, Transformed>): Schema<Raw, Transformed>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { set } from "./set";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Schema, inferParsed, inferRaw } from "../../Schema";
|
|
2
|
+
export type UndiscriminatedUnionSchema<Schemas extends [...Schema[]]> = Schema<inferRawUnidiscriminatedUnionSchema<Schemas>, inferParsedUnidiscriminatedUnionSchema<Schemas>>;
|
|
3
|
+
export type inferRawUnidiscriminatedUnionSchema<Schemas extends [...Schema[]]> = inferRaw<Schemas[number]>;
|
|
4
|
+
export type inferParsedUnidiscriminatedUnionSchema<Schemas extends [...Schema[]]> = inferParsed<Schemas[number]>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Schema } from "../../Schema";
|
|
2
|
+
import { inferParsedUnidiscriminatedUnionSchema, inferRawUnidiscriminatedUnionSchema } from "./types";
|
|
3
|
+
export declare function undiscriminatedUnion<Schemas extends [Schema<any, any>, ...Schema<any, any>[]]>(schemas: Schemas): Schema<inferRawUnidiscriminatedUnionSchema<Schemas>, inferParsedUnidiscriminatedUnionSchema<Schemas>>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function discriminant<RawDiscriminant extends string, ParsedDiscriminant extends string>(parsedDiscriminant: ParsedDiscriminant, rawDiscriminant: RawDiscriminant): Discriminant<RawDiscriminant, ParsedDiscriminant>;
|
|
2
|
+
export interface Discriminant<RawDiscriminant extends string, ParsedDiscriminant extends string> {
|
|
3
|
+
parsedDiscriminant: ParsedDiscriminant;
|
|
4
|
+
rawDiscriminant: RawDiscriminant;
|
|
5
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ObjectSchema, inferParsedObject, inferRawObject } from "../object";
|
|
2
|
+
import { Discriminant } from "./discriminant";
|
|
3
|
+
export type UnionSubtypes<DiscriminantValues extends string | number | symbol> = {
|
|
4
|
+
[K in DiscriminantValues]: ObjectSchema<any, any>;
|
|
5
|
+
};
|
|
6
|
+
export type inferRawUnion<D extends string | Discriminant<any, any>, U extends UnionSubtypes<keyof U>> = {
|
|
7
|
+
[K in keyof U]: Record<inferRawDiscriminant<D>, K> & inferRawObject<U[K]>;
|
|
8
|
+
}[keyof U];
|
|
9
|
+
export type inferParsedUnion<D extends string | Discriminant<any, any>, U extends UnionSubtypes<keyof U>> = {
|
|
10
|
+
[K in keyof U]: Record<inferParsedDiscriminant<D>, K> & inferParsedObject<U[K]>;
|
|
11
|
+
}[keyof U];
|
|
12
|
+
export type inferRawDiscriminant<D extends string | Discriminant<any, any>> = D extends string ? D : D extends Discriminant<infer Raw, any> ? Raw : never;
|
|
13
|
+
export type inferParsedDiscriminant<D extends string | Discriminant<any, any>> = D extends string ? D : D extends Discriminant<any, infer Parsed> ? Parsed : never;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ObjectLikeSchema } from "../object-like";
|
|
2
|
+
import { Discriminant } from "./discriminant";
|
|
3
|
+
import { UnionSubtypes, inferParsedUnion, inferRawUnion } from "./types";
|
|
4
|
+
export declare function union<D extends string | Discriminant<any, any>, U extends UnionSubtypes<any>>(discriminant: D, union: U): ObjectLikeSchema<inferRawUnion<D, U>, inferParsedUnion<D, U>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type addQuestionMarksToNullableProperties<T> = {
|
|
2
|
+
[K in OptionalKeys<T>]?: T[K];
|
|
3
|
+
} & Pick<T, RequiredKeys<T>>;
|
|
4
|
+
export type OptionalKeys<T> = {
|
|
5
|
+
[K in keyof T]-?: undefined extends T[K] ? K : never;
|
|
6
|
+
}[keyof T];
|
|
7
|
+
export type RequiredKeys<T> = Exclude<keyof T, OptionalKeys<T>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function entries<T extends object>(object: T): [keyof T, T[keyof T]][];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function filterObject<T extends object, K extends keyof T>(obj: T, keysToInclude: K[]): Pick<T, K>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getErrorMessageForIncorrectType(value: unknown, expectedType: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function keys<T extends object>(object: T): (keyof T)[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function partition<T>(items: readonly T[], predicate: (item: T) => boolean): [T[], T[]];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
export declare class RivetError extends Error {
|
|
5
|
+
readonly statusCode?: number;
|
|
6
|
+
readonly body?: unknown;
|
|
7
|
+
constructor({ message, statusCode, body }: {
|
|
8
|
+
message?: string;
|
|
9
|
+
statusCode?: number;
|
|
10
|
+
body?: unknown;
|
|
11
|
+
});
|
|
12
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as serializers from "../../index";
|
|
5
|
+
import * as Rivet from "../../../api/index";
|
|
6
|
+
import * as core from "../../../core";
|
|
7
|
+
import { CrashPolicy } from "../../types/CrashPolicy";
|
|
8
|
+
export declare const ActorsCreateRequest: core.serialization.Schema<serializers.ActorsCreateRequest.Raw, Omit<Rivet.ActorsCreateRequest, "namespace" | "datacenter">>;
|
|
9
|
+
export declare namespace ActorsCreateRequest {
|
|
10
|
+
interface Raw {
|
|
11
|
+
crash_policy: CrashPolicy.Raw;
|
|
12
|
+
input?: string | null;
|
|
13
|
+
key?: string | null;
|
|
14
|
+
name: string;
|
|
15
|
+
runner_name_selector: string;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as serializers from "../../index";
|
|
5
|
+
import * as Rivet from "../../../api/index";
|
|
6
|
+
import * as core from "../../../core";
|
|
7
|
+
import { CrashPolicy } from "../../types/CrashPolicy";
|
|
8
|
+
export declare const ActorsGetOrCreateByIdRequest: core.serialization.Schema<serializers.ActorsGetOrCreateByIdRequest.Raw, Omit<Rivet.ActorsGetOrCreateByIdRequest, "namespace" | "datacenter">>;
|
|
9
|
+
export declare namespace ActorsGetOrCreateByIdRequest {
|
|
10
|
+
interface Raw {
|
|
11
|
+
crash_policy: CrashPolicy.Raw;
|
|
12
|
+
input?: string | null;
|
|
13
|
+
key: string;
|
|
14
|
+
name: string;
|
|
15
|
+
runner_name_selector: string;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as serializers from "../../index";
|
|
5
|
+
import * as Rivet from "../../../api/index";
|
|
6
|
+
import * as core from "../../../core";
|
|
7
|
+
import { CrashPolicy } from "../../types/CrashPolicy";
|
|
8
|
+
export declare const ActorsGetOrCreateRequest: core.serialization.Schema<serializers.ActorsGetOrCreateRequest.Raw, Omit<Rivet.ActorsGetOrCreateRequest, "namespace" | "datacenter">>;
|
|
9
|
+
export declare namespace ActorsGetOrCreateRequest {
|
|
10
|
+
interface Raw {
|
|
11
|
+
crash_policy: CrashPolicy.Raw;
|
|
12
|
+
input?: string | null;
|
|
13
|
+
key: string;
|
|
14
|
+
name: string;
|
|
15
|
+
runner_name_selector: string;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as serializers from "../../../../index";
|
|
5
|
+
import * as Rivet from "../../../../../api/index";
|
|
6
|
+
import * as core from "../../../../../core";
|
|
7
|
+
export declare const NamespacesCreateRequest: core.serialization.Schema<serializers.NamespacesCreateRequest.Raw, Rivet.NamespacesCreateRequest>;
|
|
8
|
+
export declare namespace NamespacesCreateRequest {
|
|
9
|
+
interface Raw {
|
|
10
|
+
display_name: string;
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NamespacesCreateRequest } from "./NamespacesCreateRequest";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./client";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as serializers from "../index";
|
|
5
|
+
import * as Rivet from "../../api/index";
|
|
6
|
+
import * as core from "../../core";
|
|
7
|
+
import { RivetId } from "./RivetId";
|
|
8
|
+
import { CrashPolicy } from "./CrashPolicy";
|
|
9
|
+
export declare const Actor: core.serialization.ObjectSchema<serializers.Actor.Raw, Rivet.Actor>;
|
|
10
|
+
export declare namespace Actor {
|
|
11
|
+
interface Raw {
|
|
12
|
+
actor_id: RivetId.Raw;
|
|
13
|
+
connectable_ts?: number | null;
|
|
14
|
+
crash_policy: CrashPolicy.Raw;
|
|
15
|
+
create_ts: number;
|
|
16
|
+
datacenter: string;
|
|
17
|
+
destroy_ts?: number | null;
|
|
18
|
+
key?: string | null;
|
|
19
|
+
name: string;
|
|
20
|
+
namespace_id: RivetId.Raw;
|
|
21
|
+
pending_allocation_ts?: number | null;
|
|
22
|
+
runner_name_selector: string;
|
|
23
|
+
sleep_ts?: number | null;
|
|
24
|
+
start_ts?: number | null;
|
|
25
|
+
}
|
|
26
|
+
}
|