@gaganref/confect-core 10.3.1-fork.81 → 10.3.1-fork.83
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/CommitTs.d.ts +18 -0
- package/dist/CommitTs.d.ts.map +1 -0
- package/dist/CommitTs.js +20 -0
- package/dist/CommitTs.js.map +1 -0
- package/dist/ManifestSection.d.ts +14 -2
- package/dist/ManifestSection.d.ts.map +1 -1
- package/dist/ManifestSection.js.map +1 -1
- package/dist/SchemaToValidator.d.ts +9 -4
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js +2 -0
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
- package/src/CommitTs.ts +26 -0
- package/src/ManifestSection.ts +12 -2
- package/src/SchemaToValidator.ts +50 -17
- package/src/index.ts +1 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CommitTsPlaceholder } from "convex/values";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
4
|
+
/**
|
|
5
|
+
* A commit timestamp as Convex types it. A mutation writes the database
|
|
6
|
+
* writer's `vars.commitTs` placeholder, which resolves to an int64 when the
|
|
7
|
+
* mutation commits. Reading the field back inside that mutation still yields
|
|
8
|
+
* the placeholder, so a reader narrows with `typeof value === "bigint"` before
|
|
9
|
+
* using it as a number.
|
|
10
|
+
*/
|
|
11
|
+
export type CommitTs = bigint | CommitTsPlaceholder;
|
|
12
|
+
/**
|
|
13
|
+
* A field Convex stores as `v.commitTs()`. An index on it orders documents by
|
|
14
|
+
* commit order.
|
|
15
|
+
*/
|
|
16
|
+
export declare const CommitTs: Schema.Codec<CommitTs>;
|
|
17
|
+
export declare const isCommitTs: (ast: SchemaAST.AST) => boolean;
|
|
18
|
+
//# sourceMappingURL=CommitTs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommitTs.d.ts","sourceRoot":"","sources":["../src/CommitTs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAI9C;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,mBAAmB,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAGL,CAAC;AAExC,eAAO,MAAM,UAAU,QAAS,SAAS,CAAC,GAAG,KAAG,OACY,CAAC"}
|
package/dist/CommitTs.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
4
|
+
import { CommitTsPlaceholder } from "convex/values";
|
|
5
|
+
//#region src/CommitTs.ts
|
|
6
|
+
var CommitTs_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
CommitTs: () => CommitTs,
|
|
8
|
+
isCommitTs: () => isCommitTs
|
|
9
|
+
});
|
|
10
|
+
const ConvexCommitTs = "~@confect/core/ConvexCommitTs";
|
|
11
|
+
/**
|
|
12
|
+
* A field Convex stores as `v.commitTs()`. An index on it orders documents by
|
|
13
|
+
* commit order.
|
|
14
|
+
*/
|
|
15
|
+
const CommitTs = Schema.Union([Schema.BigInt, Schema.instanceOf(CommitTsPlaceholder)]).annotate({ [ConvexCommitTs]: true });
|
|
16
|
+
const isCommitTs = (ast) => SchemaAST.resolveAt(ConvexCommitTs)(ast) === true;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { CommitTs, CommitTs_exports, isCommitTs };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=CommitTs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommitTs.js","names":[],"sources":["../src/CommitTs.ts"],"sourcesContent":["import { CommitTsPlaceholder } from \"convex/values\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\n\nconst ConvexCommitTs = \"~@confect/core/ConvexCommitTs\";\n\n/**\n * A commit timestamp as Convex types it. A mutation writes the database\n * writer's `vars.commitTs` placeholder, which resolves to an int64 when the\n * mutation commits. Reading the field back inside that mutation still yields\n * the placeholder, so a reader narrows with `typeof value === \"bigint\"` before\n * using it as a number.\n */\nexport type CommitTs = bigint | CommitTsPlaceholder;\n\n/**\n * A field Convex stores as `v.commitTs()`. An index on it orders documents by\n * commit order.\n */\nexport const CommitTs: Schema.Codec<CommitTs> = Schema.Union([\n Schema.BigInt,\n Schema.instanceOf(CommitTsPlaceholder),\n]).annotate({ [ConvexCommitTs]: true });\n\nexport const isCommitTs = (ast: SchemaAST.AST): boolean =>\n SchemaAST.resolveAt<boolean>(ConvexCommitTs)(ast) === true;\n"],"mappings":";;;;;;;;;AAIA,MAAM,iBAAiB;;;;;AAevB,MAAa,WAAmC,OAAO,MAAM,CAC3D,OAAO,QACP,OAAO,WAAW,mBAAmB,CACvC,CAAC,CAAC,CAAC,SAAS,GAAG,iBAAiB,KAAK,CAAC;AAEtC,MAAa,cAAc,QACzB,UAAU,UAAmB,cAAc,CAAC,CAAC,GAAG,MAAM"}
|
|
@@ -4,11 +4,21 @@ export interface Data<Value = unknown> {
|
|
|
4
4
|
readonly format: number;
|
|
5
5
|
readonly functions: Readonly<Record<string, Value>>;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* The backend codegen generates: the app, or a component under the name its
|
|
9
|
+
* `defineComponent` gives it.
|
|
10
|
+
*/
|
|
11
|
+
export type Target = {
|
|
12
|
+
readonly kind: "app";
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "component";
|
|
15
|
+
readonly name: string;
|
|
16
|
+
};
|
|
7
17
|
/**
|
|
8
18
|
* What codegen hands a section's `render`: the exports of each `confect/` file
|
|
9
19
|
* it matched, every registered function with the spec file declaring it, each
|
|
10
|
-
* mounted component with the specifier of its definition,
|
|
11
|
-
*
|
|
20
|
+
* mounted component with the specifier of its definition, every file `match`
|
|
21
|
+
* was offered, the backend it generates and the absolute path of `confect/`.
|
|
12
22
|
*/
|
|
13
23
|
export interface GenerateInput {
|
|
14
24
|
readonly modules: ReadonlyArray<{
|
|
@@ -24,6 +34,8 @@ export interface GenerateInput {
|
|
|
24
34
|
readonly definition: string;
|
|
25
35
|
}>;
|
|
26
36
|
readonly files: ReadonlyArray<string>;
|
|
37
|
+
readonly target: Target;
|
|
38
|
+
readonly confectDirectory: string;
|
|
27
39
|
}
|
|
28
40
|
export interface Generate {
|
|
29
41
|
readonly file: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ManifestSection.d.ts","sourceRoot":"","sources":["../src/ManifestSection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,YAAY,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,KAAK,cAAc,MAAM,qBAAqB,CAAC;AAE3D,MAAM,WAAW,IAAI,CAAC,KAAK,GAAG,OAAO;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;CACrD;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;KACrD,CAAC,CAAC;IACH,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;QAChC,QAAQ,C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MAAM,CAAC;QACtB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,YAAY,CAAC;QACzC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;KACtE,GAAG,KAAK,CAAC;IACV,SAAS,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;IAChD,KAAK,CAAC,CACJ,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,OAAO,GAChB;QACD,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QACvC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KACvC,CAAC;IACF,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CAC9B;AAED,MAAM,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAExE,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ManifestSection.js","names":[],"sources":["../src/ManifestSection.ts"],"sourcesContent":["import type * as FunctionSpec from \"./FunctionSpec.js\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec.js\";\n\nexport interface Data<Value = unknown> {\n readonly format: number;\n readonly functions: Readonly<Record<string, Value>>;\n}\n\n/**\n * What codegen hands a section's `render`: the exports of each `confect/` file\n * it matched, every registered function with the spec file declaring it, each\n * mounted component with the specifier of its definition,
|
|
1
|
+
{"version":3,"file":"ManifestSection.js","names":[],"sources":["../src/ManifestSection.ts"],"sourcesContent":["import type * as FunctionSpec from \"./FunctionSpec.js\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec.js\";\n\nexport interface Data<Value = unknown> {\n readonly format: number;\n readonly functions: Readonly<Record<string, Value>>;\n}\n\n/**\n * The backend codegen generates: the app, or a component under the name its\n * `defineComponent` gives it.\n */\nexport type Target =\n | { readonly kind: \"app\" }\n | { readonly kind: \"component\"; readonly name: string };\n\n/**\n * What codegen hands a section's `render`: the exports of each `confect/` file\n * it matched, every registered function with the spec file declaring it, each\n * mounted component with the specifier of its definition, every file `match`\n * was offered, the backend it generates and the absolute path of `confect/`.\n */\nexport interface GenerateInput {\n readonly modules: ReadonlyArray<{\n readonly relativePath: string;\n readonly exports: Readonly<Record<string, unknown>>;\n }>;\n readonly functions: ReadonlyArray<{\n readonly path: string;\n readonly source: string;\n }>;\n readonly mounts: ReadonlyArray<{\n readonly name: string;\n readonly definition: string;\n }>;\n readonly files: ReadonlyArray<string>;\n readonly target: Target;\n readonly confectDirectory: string;\n}\n\nexport interface Generate {\n readonly file: string;\n match(relativePath: string): boolean;\n render(input: GenerateInput): {\n readonly contents: string;\n readonly errors: ReadonlyArray<string>;\n };\n}\n\n/**\n * What codegen hands a section's `summarize`: the `confect/` files its\n * `generate` matched, each function's description by path, and the spec file\n * declaring each function by path, relative to `confect/`.\n */\nexport interface SummarizeInput<Value = unknown> {\n readonly modules: GenerateInput[\"modules\"];\n readonly functions: Readonly<Record<string, Value>>;\n readonly sources: Readonly<Record<string, string>>;\n}\n\nexport interface ManifestSection<\n Value = unknown,\n Data_ extends { readonly format: number } = Data<Value>,\n> {\n readonly owner: string;\n readonly format: number;\n describe(input: {\n readonly path: string;\n readonly spec: FunctionSpec.AnyWithProps;\n readonly middleware: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;\n }): Value;\n summarize?(input: SummarizeInput<Value>): Data_;\n check?(\n next: Data_,\n previous: unknown,\n ): {\n readonly errors: ReadonlyArray<string>;\n readonly notes: ReadonlyArray<string>;\n };\n readonly generate?: Generate;\n}\n\nexport type Any = ManifestSection<unknown, { readonly format: number }>;\n\nexport interface Entry {\n readonly key: string;\n readonly section: Any;\n}\n"],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as IdScope from "./IdScope.js";
|
|
2
|
-
import type { GenericId as ConvexGenericId, PropertyValidators, Validator, VAny, VArray, VBoolean, VBytes, VFloat64, VId, VInt64, VLiteral, VNull, VObject, VRecord, VString, VUnion } from "convex/values";
|
|
2
|
+
import type { CommitTsPlaceholder, GenericId as ConvexGenericId, PropertyValidators, Validator, VAny, VArray, VBoolean, VBytes, VCommitTs, VFloat64, VId, VInt64, VLiteral, VNull, VObject, VRecord, VString, VUnion } from "convex/values";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
import * as SchemaAST from "effect/SchemaAST";
|
|
@@ -20,7 +20,7 @@ export declare const compileReturnsSchema: <ConfectValue, ConvexValue>(schema: S
|
|
|
20
20
|
*/
|
|
21
21
|
export type TableSchemaToTableValidator<TableSchema extends Schema.Codec<any, any>> = ValueToValidator<TableSchema["Encoded"]> extends infer Vd extends VObject<any, any, any, any> | VUnion<any, any, any, any> ? Vd : never;
|
|
22
22
|
export declare const compileTableSchema: <TableSchema extends Schema.Codec<any, any>>(schema: TableSchema, scope?: IdScope.IdScope) => TableSchemaToTableValidator<TableSchema>;
|
|
23
|
-
export type ReadonlyValue = string | number | bigint | boolean | ArrayBuffer | ReadonlyArrayValue | ReadonlyRecordValue | null;
|
|
23
|
+
export type ReadonlyValue = string | number | bigint | boolean | ArrayBuffer | CommitTsPlaceholder | ReadonlyArrayValue | ReadonlyRecordValue | null;
|
|
24
24
|
type ReadonlyArrayValue = readonly ReadonlyValue[];
|
|
25
25
|
export type ReadonlyRecordValue = {
|
|
26
26
|
readonly [key: string]: ReadonlyValue | undefined;
|
|
@@ -30,14 +30,19 @@ type MutableValue<T> = T extends ReadonlyArray<infer El> ? MutableValue<El>[] :
|
|
|
30
30
|
} : T;
|
|
31
31
|
export type ValueToValidator<Vl> = [Vl] extends [never] ? never : IsAny<Vl> extends true ? VAny : [Vl] extends [string | number | bigint | boolean | null | ArrayBuffer] ? ConvertValueToValidator<Vl> : IsRecursive<Vl> extends true ? VAny : [Vl] extends [ReadonlyValue] ? ConvertValueToValidator<Vl> : TypeError<"Provided value is not a valid Convex value", Vl>;
|
|
32
32
|
type OptionalValue<Vl, Optionality> = Optionality extends "optional" ? Vl | undefined : Vl;
|
|
33
|
-
type ConvertValueToValidator<Vl, Optionality extends "required" | "optional" = "required"> = [Vl] extends [never] ? never : IsAny<Vl> extends true ? VAny<any, Optionality> : [Vl] extends [null] ? VNull<OptionalValue<null, Optionality>, Optionality> : [Vl] extends [boolean] ? [boolean] extends [Vl] ? VBoolean<OptionalValue<boolean, Optionality>, Optionality> : VLiteral<OptionalValue<Vl, Optionality>, Optionality> : IsUnion<Vl> extends true ? UnionValueToValidator<Vl, Optionality> : [Vl] extends [number] ? [number] extends [Vl] ? VFloat64<OptionalValue<number, Optionality>, Optionality> : VLiteral<OptionalValue<Vl, Optionality>, Optionality> : [Vl] extends [bigint] ? [bigint] extends [Vl] ? VInt64<OptionalValue<bigint, Optionality>, Optionality> : VLiteral<OptionalValue<Vl, Optionality>, Optionality> : [Vl] extends [string] ? StringValueToValidator<Vl, Optionality> : [Vl] extends [ArrayBuffer] ? VBytes<OptionalValue<ArrayBuffer, Optionality>, Optionality> : IsRecursive<Vl> extends true ? VAny<any, Optionality> : Vl extends ReadonlyArray<infer El> ? VArray<OptionalValue<MutableValue<El[]>, Optionality>, ConvertValueToValidator<El>, Optionality> : Vl extends object ? ObjectValueToValidator<Vl, Optionality> : never;
|
|
33
|
+
type ConvertValueToValidator<Vl, Optionality extends "required" | "optional" = "required"> = [Vl] extends [never] ? never : IsAny<Vl> extends true ? VAny<any, Optionality> : [Vl] extends [null] ? VNull<OptionalValue<null, Optionality>, Optionality> : [Vl] extends [boolean] ? [boolean] extends [Vl] ? VBoolean<OptionalValue<boolean, Optionality>, Optionality> : VLiteral<OptionalValue<Vl, Optionality>, Optionality> : IsUnion<Vl> extends true ? IsCommitTs<Vl> extends true ? VCommitTs<OptionalValue<Vl, Optionality>, Optionality> : UnionValueToValidator<Vl, Optionality> : [Vl] extends [number] ? [number] extends [Vl] ? VFloat64<OptionalValue<number, Optionality>, Optionality> : VLiteral<OptionalValue<Vl, Optionality>, Optionality> : [Vl] extends [bigint] ? [bigint] extends [Vl] ? VInt64<OptionalValue<bigint, Optionality>, Optionality> : VLiteral<OptionalValue<Vl, Optionality>, Optionality> : [Vl] extends [string] ? StringValueToValidator<Vl, Optionality> : [Vl] extends [ArrayBuffer] ? VBytes<OptionalValue<ArrayBuffer, Optionality>, Optionality> : IsCommitTs<Vl> extends true ? VCommitTs<OptionalValue<Vl, Optionality>, Optionality> : IsRecursive<Vl> extends true ? VAny<any, Optionality> : Vl extends ReadonlyArray<infer El> ? VArray<OptionalValue<MutableValue<El[]>, Optionality>, ConvertValueToValidator<El>, Optionality> : Vl extends object ? ObjectValueToValidator<Vl, Optionality> : never;
|
|
34
|
+
type IsCommitTs<Vl> = [Vl] extends [bigint | CommitTsPlaceholder] ? [CommitTsPlaceholder] extends [Vl] ? true : false : false;
|
|
34
35
|
type StringValueToValidator<Vl, Optionality extends "required" | "optional"> = Vl extends ConvexGenericId<string> ? VId<OptionalValue<Vl, Optionality>, Optionality> : [string] extends [Vl] ? VString<OptionalValue<string, Optionality>, Optionality> : VLiteral<OptionalValue<Vl, Optionality>, Optionality>;
|
|
35
36
|
type ObjectValueToValidator<Vl, Optionality extends "required" | "optional"> = IsRecord<MutableValue<Vl>> extends true ? ValueToValidator<Vl[keyof Vl]> extends infer VdValue extends Validator<any, "required", any> ? VRecord<OptionalValue<MutableValue<Vl>, Optionality>, VString, VdValue, Optionality> : never : ObjectFieldsToValidators<Vl> extends infer VdFields extends Record<string, any> ? VObject<OptionalValue<MutableValue<Vl>, Optionality>, VdFields, Optionality> : never;
|
|
36
37
|
type ObjectFieldsToValidators<Vl> = {
|
|
37
38
|
-readonly [K in keyof Vl]-?: IsAny<Vl[K]> extends true ? IsOptional<Vl, K> extends true ? VAny<any, "optional"> : VAny : undefined extends Vl[K] ? OptionalValueToValidator<Vl[K]> : [Vl[K]] extends [ReadonlyValue] ? ConvertValueToValidator<Vl[K]> : never;
|
|
38
39
|
};
|
|
39
40
|
export type UndefinedOrValueToValidator<Vl extends ReadonlyValue | undefined> = undefined extends Vl ? OptionalValueToValidator<Vl> : [Vl] extends [ReadonlyValue] ? ValueToValidator<Vl> : never;
|
|
40
|
-
type UnionValueToValidator<Vl, Optionality extends "required" | "optional"> = IsRecursive<Vl> extends true ? VAny<any, Optionality> : VUnion<OptionalValue<MutableValue<Vl>, Optionality>, ValueTupleToValidatorTuple<UnionToTuple<Vl>>, Optionality>;
|
|
41
|
+
type UnionValueToValidator<Vl, Optionality extends "required" | "optional"> = IsRecursive<Vl> extends true ? VAny<any, Optionality> : [Extract<Vl, CommitTsPlaceholder>] extends [never] ? VUnion<OptionalValue<MutableValue<Vl>, Optionality>, ValueTupleToValidatorTuple<UnionToTuple<Vl>>, Optionality> : CommitTsUnionValueToValidator<Vl, Optionality>;
|
|
42
|
+
type CommitTsUnionValueToValidator<Vl, Optionality extends "required" | "optional"> = [
|
|
43
|
+
VCommitTs,
|
|
44
|
+
...ValueTupleToValidatorTuple<UnionToTuple<Exclude<Vl, bigint | CommitTsPlaceholder>>>
|
|
45
|
+
] extends infer VdMembers extends Validator<any, "required", any>[] ? VUnion<OptionalValue<MutableValue<Vl>, Optionality>, VdMembers, Optionality> : never;
|
|
41
46
|
type ValueTupleToValidatorTuple<VlTuple extends readonly unknown[], Acc extends Validator<any, "required", any>[] = []> = VlTuple extends [true, false, ...infer VlRest] | [false, true, ...infer VlRest] ? ValueTupleToValidatorTuple<VlRest, [...Acc, VBoolean]> : VlTuple extends [infer Vl, ...infer VlRest] ? ValueTupleToValidatorTuple<VlRest, [...Acc, ConvertValueToValidator<Vl>]> : Acc;
|
|
42
47
|
type OptionalValueToValidator<Vl> = [Vl] extends [
|
|
43
48
|
(infer Val extends ReadonlyValue) | undefined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaToValidator.d.ts","sourceRoot":"","sources":["../src/SchemaToValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,OAAO,KAAK,EACV,SAAS,IAAI,eAAe,EAC5B,kBAAkB,EAClB,SAAS,EACT,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,GAAG,EACH,MAAM,EACN,QAAQ,EACR,KAAK,EACL,OAAO,EACP,OAAO,EACP,OAAO,EACP,MAAM,EACP,MAAM,eAAe,CAAC;AAKvB,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAKxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"SchemaToValidator.d.ts","sourceRoot":"","sources":["../src/SchemaToValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,OAAO,KAAK,EACV,mBAAmB,EACnB,SAAS,IAAI,eAAe,EAC5B,kBAAkB,EAClB,SAAS,EACT,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,MAAM,EACN,SAAS,EACT,QAAQ,EACR,GAAG,EACH,MAAM,EACN,QAAQ,EACR,KAAK,EACL,OAAO,EACP,OAAO,EACP,OAAO,EACP,MAAM,EACP,MAAM,eAAe,CAAC;AAKvB,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAKxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAK9C,OAAO,KAAK,EACV,KAAK,EACL,UAAU,EACV,QAAQ,EACR,WAAW,EACX,OAAO,EACP,SAAS,EACT,YAAY,EACb,MAAM,YAAY,CAAC;AAIpB,eAAO,MAAM,iBAAiB,GAAI,YAAY,EAA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CAC5C,CAAC;IAEA,IAAa,OAAO,WAEnB;CAEF;;;;AAED,qBAAa,mCAAoC,SAAQ,wCAExD;IAEC,IAAa,OAAO,WAEnB;CAEF;;;;AAED,qBAAa,mDAAoD,SAAQ,wDAExE;IAEC,IAAa,OAAO,WAEnB;CAEF;;;;AAED,qBAAa,yCAA0C,SAAQ,8CAE9D;IAEC,IAAa,OAAO,WAEnB;CAEF"}
|
|
@@ -2,6 +2,7 @@ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
|
2
2
|
import { CallbackContract } from "./internal/annotations.js";
|
|
3
3
|
import { app } from "./IdScope.js";
|
|
4
4
|
import { scope, tableName } from "./GenericId.js";
|
|
5
|
+
import { isCommitTs } from "./CommitTs.js";
|
|
5
6
|
import * as Schema from "effect/Schema";
|
|
6
7
|
import * as Predicate from "effect/Predicate";
|
|
7
8
|
import * as Data from "effect/Data";
|
|
@@ -70,6 +71,7 @@ const compileAst = (ast, isOptionalPropertyOfTypeLiteral = false, scope$1 = app)
|
|
|
70
71
|
returns
|
|
71
72
|
});
|
|
72
73
|
});
|
|
74
|
+
if (isCommitTs(ast)) return Effect.succeed(v.commitTs());
|
|
73
75
|
return isRecursive(ast) ? Effect.succeed(v.any()) : pipe(ast, Match.value, Match.tag("Literal", ({ literal }) => pipe(literal, Match.value, Match.whenOr(Match.string, Match.number, Match.bigint, Match.boolean, (l) => v.literal(l)), Match.exhaustive, Effect.succeed)), Match.tag("Null", () => Effect.succeed(v.null())), Match.tag("Boolean", () => Effect.succeed(v.boolean())), Match.tag("String", (stringAst) => tableName(stringAst).pipe(Option.match({
|
|
74
76
|
onNone: () => Effect.succeed(v.string()),
|
|
75
77
|
onSome: (tableName) => Effect.succeed(scope(stringAst) === scope$1 ? v.id(tableName) : v.string())
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaToValidator.js","names":["IdScope.app","scope","GenericId.tableName","GenericId.scope"],"sources":["../src/SchemaToValidator.ts"],"sourcesContent":["import * as IdScope from \"./IdScope.js\";\nimport type * as Callback from \"./Callback.js\";\nimport { CallbackContract } from \"./internal/annotations.js\";\nimport type {\n GenericId as ConvexGenericId,\n PropertyValidators,\n Validator,\n VAny,\n VArray,\n VBoolean,\n VBytes,\n VFloat64,\n VId,\n VInt64,\n VLiteral,\n VNull,\n VObject,\n VRecord,\n VString,\n VUnion,\n} from \"convex/values\";\nimport { v } from \"convex/values\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Data from \"effect/Data\";\nimport * as Effect from \"effect/Effect\";\nimport * as Match from \"effect/Match\";\nimport * as Number from \"effect/Number\";\nimport * as Option from \"effect/Option\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\nimport * as String from \"effect/String\";\n\nimport * as GenericId from \"./GenericId.js\";\nimport type {\n IsAny,\n IsOptional,\n IsRecord,\n IsRecursive,\n IsUnion,\n TypeError,\n UnionToTuple,\n} from \"./Types.js\";\n\n// Args\n\nexport const compileArgsSchema = <ConfectValue, ConvexValue>(\n argsSchema: Schema.Codec<ConfectValue, ConvexValue>,\n scope: IdScope.IdScope = IdScope.app,\n reservedArgument?: string,\n functionName?: string,\n): PropertyValidators => {\n const ast = Schema.toEncoded(argsSchema).ast;\n\n const validators = Effect.runSync(compileArgsAst(ast, scope));\n if (reservedArgument === undefined) return validators;\n if (Object.hasOwn(validators, reservedArgument)) {\n throw new ReservedArgumentCollision({\n functionName,\n argument: reservedArgument,\n });\n }\n return { ...validators, [reservedArgument]: v.optional(v.any()) };\n};\n\nconst compileArgsAst = (ast: SchemaAST.AST, scope: IdScope.IdScope) =>\n pipe(\n ast,\n Match.value,\n Match.tag(\"Objects\", (objectsAst) =>\n Array.isReadonlyArrayEmpty(objectsAst.indexSignatures)\n ? handlePropertySignatures(objectsAst, scope)\n : Effect.fail(new IndexSignaturesAreNotSupportedError()),\n ),\n Match.orElse(() => Effect.fail(new TopLevelMustBeObjectError())),\n );\n\nexport class ReservedArgumentCollision extends Data.TaggedError(\n \"ReservedArgumentCollision\",\n)<{\n readonly functionName: string | undefined;\n readonly argument: string;\n}> {\n override get message() {\n return `${this.functionName} declares the argument \"${this.argument}\", which its profile reserves. Rename the argument.`;\n }\n}\n\n// Returns\n\nexport const compileReturnsSchema = <ConfectValue, ConvexValue>(\n schema: Schema.Codec<ConfectValue, ConvexValue>,\n scope: IdScope.IdScope = IdScope.app,\n): Validator<any, any, any> =>\n Effect.runSync(compileAst(Schema.toEncoded(schema).ast, false, scope));\n\n// Table\n\n/**\n * Convert a table `Schema` to a table `Validator`.\n */\nexport type TableSchemaToTableValidator<\n TableSchema extends Schema.Codec<any, any>,\n> =\n ValueToValidator<TableSchema[\"Encoded\"]> extends infer Vd extends\n | VObject<any, any, any, any>\n | VUnion<any, any, any, any>\n ? Vd\n : never;\n\nexport const compileTableSchema = <TableSchema extends Schema.Codec<any, any>>(\n schema: TableSchema,\n scope: IdScope.IdScope = IdScope.app,\n): TableSchemaToTableValidator<TableSchema> => {\n const ast = Schema.toEncoded(schema).ast;\n\n return pipe(\n ast,\n Match.value,\n Match.tag(\"Objects\", ({ indexSignatures }) =>\n Array.isReadonlyArrayEmpty(indexSignatures)\n ? // oxlint-disable-next-line effecttsgo/unsafe-effect-type-assertion -- The return type is derived from the input schema and cannot be recovered from the runtime AST.\n (compileAst(ast, false, scope) as Effect.Effect<any>)\n : Effect.fail(new IndexSignaturesAreNotSupportedError()),\n ),\n Match.tag(\"Union\", (unionAst) => compileAst(unionAst, false, scope)),\n Match.orElse(() => Effect.fail(new TopLevelMustBeObjectOrUnionError())),\n Effect.runSync,\n );\n};\n\n// Compiler\n\nexport type ReadonlyValue =\n | string\n | number\n | bigint\n | boolean\n | ArrayBuffer\n | ReadonlyArrayValue\n | ReadonlyRecordValue\n | null;\n\ntype ReadonlyArrayValue = readonly ReadonlyValue[];\n\nexport type ReadonlyRecordValue = {\n readonly [key: string]: ReadonlyValue | undefined;\n};\n\ntype MutableValue<T> =\n T extends ReadonlyArray<infer El>\n ? MutableValue<El>[]\n : T extends ReadonlyRecordValue\n ? { -readonly [K in keyof T]: MutableValue<Exclude<T[K], undefined>> }\n : T;\n\nexport type ValueToValidator<Vl> = [Vl] extends [never]\n ? never\n : IsAny<Vl> extends true\n ? VAny\n : [Vl] extends [string | number | bigint | boolean | null | ArrayBuffer]\n ? ConvertValueToValidator<Vl>\n : IsRecursive<Vl> extends true\n ? VAny\n : [Vl] extends [ReadonlyValue]\n ? ConvertValueToValidator<Vl>\n : TypeError<\"Provided value is not a valid Convex value\", Vl>;\n\ntype OptionalValue<Vl, Optionality> = Optionality extends \"optional\"\n ? Vl | undefined\n : Vl;\n\ntype ConvertValueToValidator<\n Vl,\n Optionality extends \"required\" | \"optional\" = \"required\",\n> = [Vl] extends [never]\n ? never\n : IsAny<Vl> extends true\n ? VAny<any, Optionality>\n : [Vl] extends [null]\n ? VNull<OptionalValue<null, Optionality>, Optionality>\n : [Vl] extends [boolean]\n ? [boolean] extends [Vl]\n ? VBoolean<OptionalValue<boolean, Optionality>, Optionality>\n : VLiteral<OptionalValue<Vl, Optionality>, Optionality>\n : IsUnion<Vl> extends true\n ? UnionValueToValidator<Vl, Optionality>\n : [Vl] extends [number]\n ? [number] extends [Vl]\n ? VFloat64<OptionalValue<number, Optionality>, Optionality>\n : VLiteral<OptionalValue<Vl, Optionality>, Optionality>\n : [Vl] extends [bigint]\n ? [bigint] extends [Vl]\n ? VInt64<OptionalValue<bigint, Optionality>, Optionality>\n : VLiteral<OptionalValue<Vl, Optionality>, Optionality>\n : [Vl] extends [string]\n ? StringValueToValidator<Vl, Optionality>\n : [Vl] extends [ArrayBuffer]\n ? VBytes<OptionalValue<ArrayBuffer, Optionality>, Optionality>\n : IsRecursive<Vl> extends true\n ? VAny<any, Optionality>\n : Vl extends ReadonlyArray<infer El>\n ? VArray<\n OptionalValue<MutableValue<El[]>, Optionality>,\n ConvertValueToValidator<El>,\n Optionality\n >\n : Vl extends object\n ? ObjectValueToValidator<Vl, Optionality>\n : never;\n\ntype StringValueToValidator<Vl, Optionality extends \"required\" | \"optional\"> =\n Vl extends ConvexGenericId<string>\n ? VId<OptionalValue<Vl, Optionality>, Optionality>\n : [string] extends [Vl]\n ? VString<OptionalValue<string, Optionality>, Optionality>\n : VLiteral<OptionalValue<Vl, Optionality>, Optionality>;\n\ntype ObjectValueToValidator<Vl, Optionality extends \"required\" | \"optional\"> =\n IsRecord<MutableValue<Vl>> extends true\n ? ValueToValidator<Vl[keyof Vl]> extends infer VdValue extends Validator<\n any,\n \"required\",\n any\n >\n ? VRecord<\n OptionalValue<MutableValue<Vl>, Optionality>,\n VString,\n VdValue,\n Optionality\n >\n : never\n : ObjectFieldsToValidators<Vl> extends infer VdFields extends Record<\n string,\n any\n >\n ? VObject<\n OptionalValue<MutableValue<Vl>, Optionality>,\n VdFields,\n Optionality\n >\n : never;\n\ntype ObjectFieldsToValidators<Vl> = {\n -readonly [K in keyof Vl]-?: IsAny<Vl[K]> extends true\n ? IsOptional<Vl, K> extends true\n ? VAny<any, \"optional\">\n : VAny\n : undefined extends Vl[K]\n ? OptionalValueToValidator<Vl[K]>\n : [Vl[K]] extends [ReadonlyValue]\n ? ConvertValueToValidator<Vl[K]>\n : never;\n};\n\nexport type UndefinedOrValueToValidator<Vl extends ReadonlyValue | undefined> =\n undefined extends Vl\n ? OptionalValueToValidator<Vl>\n : [Vl] extends [ReadonlyValue]\n ? ValueToValidator<Vl>\n : never;\n\ntype UnionValueToValidator<Vl, Optionality extends \"required\" | \"optional\"> =\n IsRecursive<Vl> extends true\n ? VAny<any, Optionality>\n : VUnion<\n OptionalValue<MutableValue<Vl>, Optionality>,\n ValueTupleToValidatorTuple<UnionToTuple<Vl>>,\n Optionality\n >;\n\ntype ValueTupleToValidatorTuple<\n VlTuple extends readonly unknown[],\n Acc extends Validator<any, \"required\", any>[] = [],\n> = VlTuple extends\n | [true, false, ...infer VlRest]\n | [false, true, ...infer VlRest]\n ? ValueTupleToValidatorTuple<VlRest, [...Acc, VBoolean]>\n : VlTuple extends [infer Vl, ...infer VlRest]\n ? ValueTupleToValidatorTuple<VlRest, [...Acc, ConvertValueToValidator<Vl>]>\n : Acc;\n\ntype OptionalValueToValidator<Vl> = [Vl] extends [\n (infer Val extends ReadonlyValue) | undefined,\n]\n ? ConvertValueToValidator<Val, \"optional\">\n : never;\n\nexport const compileSchema = <T, E>(\n schema: Schema.Codec<T, E>,\n): ValueToValidator<(typeof schema)[\"Encoded\"]> =>\n Effect.runSync(compileAst(schema.ast)) as any;\n\nexport const isRecursive = (ast: SchemaAST.AST): boolean =>\n pipe(\n ast,\n Match.value,\n Match.tag(\n \"Literal\",\n \"Null\",\n \"Boolean\",\n \"String\",\n \"Number\",\n \"BigInt\",\n \"Unknown\",\n \"Any\",\n \"Declaration\",\n \"UniqueSymbol\",\n \"Symbol\",\n \"Undefined\",\n \"Void\",\n \"Never\",\n \"Enum\",\n \"TemplateLiteral\",\n \"ObjectKeyword\",\n () => false,\n ),\n Match.tag(\"Union\", ({ types }) =>\n Array.some(types, (type) => isRecursive(type)),\n ),\n Match.tag(\"Objects\", ({ propertySignatures }) =>\n Array.some(propertySignatures, ({ type }) => isRecursive(type)),\n ),\n Match.tag(\n \"Arrays\",\n ({ elements, rest }) =>\n Array.some(elements, (element) => isRecursive(element)) ||\n Array.some(rest, (element) => isRecursive(element)),\n ),\n Match.tag(\"Suspend\", () => true),\n Match.exhaustive,\n );\n\nexport const compileAst = (\n ast: SchemaAST.AST,\n isOptionalPropertyOfTypeLiteral = false,\n scope: IdScope.IdScope = IdScope.app,\n): Effect.Effect<\n Validator<any, any, any>,\n | TopLevelMustBeObjectError\n | UnsupportedSchemaTypeError\n | UnsupportedPropertySignatureKeyTypeError\n | IndexSignaturesAreNotSupportedError\n | MixedIndexAndPropertySignaturesAreNotSupportedError\n | OptionalTupleElementsAreNotSupportedError\n | EmptyTupleIsNotSupportedError\n | EmptyUnionIsNotSupportedError\n> => {\n const contract = SchemaAST.resolveAt<Callback.Any>(CallbackContract)(ast);\n if (contract !== undefined) {\n return Effect.gen(function* () {\n const args = yield* compileArgsAst(\n Schema.toEncoded(contract.functionProvenance.args).ast,\n scope,\n );\n const returns = yield* compileAst(\n Schema.toEncoded(contract.functionProvenance.returns).ast,\n false,\n scope,\n );\n return v.function({ fnType: contract.functionType, args, returns });\n });\n }\n return isRecursive(ast)\n ? Effect.succeed(v.any())\n : pipe(\n ast,\n Match.value,\n Match.tag(\"Literal\", ({ literal }) =>\n pipe(\n literal,\n Match.value,\n Match.whenOr(\n Match.string,\n Match.number,\n Match.bigint,\n Match.boolean,\n (l) => v.literal(l),\n ),\n Match.exhaustive,\n Effect.succeed,\n ),\n ),\n Match.tag(\"Null\", () => Effect.succeed(v.null())),\n Match.tag(\"Boolean\", () => Effect.succeed(v.boolean())),\n Match.tag(\"String\", (stringAst) =>\n GenericId.tableName(stringAst).pipe(\n Option.match({\n onNone: () => Effect.succeed(v.string()),\n onSome: (tableName) =>\n Effect.succeed(\n GenericId.scope(stringAst) === scope\n ? v.id(tableName)\n : v.string(),\n ),\n }),\n ),\n ),\n Match.tag(\"Number\", () => Effect.succeed(v.float64())),\n Match.tag(\"BigInt\", () => Effect.succeed(v.int64())),\n Match.tag(\"Union\", (unionAst) =>\n handleUnion(unionAst, isOptionalPropertyOfTypeLiteral, scope),\n ),\n Match.tag(\"Objects\", (objectsAst) => handleObjects(objectsAst, scope)),\n Match.tag(\"Arrays\", (arraysAst) => handleArrays(arraysAst, scope)),\n Match.tag(\"Unknown\", \"Any\", () => Effect.succeed(v.any())),\n Match.tag(\"Declaration\", (declaration) =>\n Effect.mapBoth(\n // oxlint-disable-next-line effecttsgo/any-unknown-in-error-context -- Codec inputs are context-free, but Effect's SchemaAST.DeclarationRun erases their requirements to `any`.\n declaration.run(declaration.typeParameters)(\n new ArrayBuffer(0),\n declaration,\n {},\n ) as Effect.Effect<ArrayBuffer, unknown, never>,\n {\n onSuccess: () => v.bytes(),\n onFailure: () =>\n new UnsupportedSchemaTypeError({\n schemaType: declaration._tag,\n }),\n },\n ),\n ),\n Match.tag(\"Suspend\", () => Effect.succeed(v.any())),\n Match.tag(\n \"UniqueSymbol\",\n \"Symbol\",\n \"Undefined\",\n \"Void\",\n \"Never\",\n \"Enum\",\n \"TemplateLiteral\",\n \"ObjectKeyword\",\n () =>\n Effect.fail(\n new UnsupportedSchemaTypeError({\n schemaType: ast._tag,\n }),\n ),\n ),\n Match.exhaustive,\n );\n};\n\nconst handleUnion = (\n { types }: SchemaAST.Union,\n isOptionalPropertyOfTypeLiteral: boolean,\n scope: IdScope.IdScope,\n) => handleUnionTypes(types, isOptionalPropertyOfTypeLiteral, scope);\n\nconst handleUnionTypes = Effect.fnUntraced(function* (\n types: SchemaAST.Union[\"types\"],\n isOptionalPropertyOfTypeLiteral: boolean,\n scope: IdScope.IdScope,\n) {\n const members = isOptionalPropertyOfTypeLiteral\n ? Array.filter(types, Predicate.not(SchemaAST.isUndefined))\n : types;\n\n const [firstValidator, secondValidator, ...restValidators] =\n yield* Effect.all(\n Array.map(members, (type) => compileAst(type, false, scope)),\n );\n\n if (firstValidator === undefined) {\n return yield* new EmptyUnionIsNotSupportedError();\n } else if (secondValidator === undefined) {\n return firstValidator;\n } else {\n return v.union(firstValidator, secondValidator, ...restValidators);\n }\n});\n\nconst handleObjects = (objectsAst: SchemaAST.Objects, scope: IdScope.IdScope) =>\n pipe(\n objectsAst.indexSignatures,\n Array.head,\n Option.match({\n onNone: () =>\n Effect.map(handlePropertySignatures(objectsAst, scope), v.object),\n onSome: ({ parameter, type }) =>\n pipe(\n objectsAst.propertySignatures,\n Array.head,\n Option.match({\n onNone: () =>\n Effect.map(\n Effect.all({\n parameter_: compileAst(parameter, false, scope),\n type_: compileAst(type, false, scope),\n }),\n ({ parameter_, type_ }) => v.record(parameter_, type_),\n ),\n onSome: () =>\n Effect.fail(\n new MixedIndexAndPropertySignaturesAreNotSupportedError(),\n ),\n }),\n ),\n }),\n );\n\nconst handleArrays = (\n { elements, rest }: SchemaAST.Arrays,\n scope: IdScope.IdScope,\n) => handleArrayElements(elements, rest, scope);\n\nconst handleArrayElements = Effect.fnUntraced(function* (\n elements: SchemaAST.Arrays[\"elements\"],\n rest: SchemaAST.Arrays[\"rest\"],\n scope: IdScope.IdScope,\n) {\n const [f, s, ...r] = elements;\n\n const elementToValidator = (element: SchemaAST.AST) =>\n SchemaAST.isOptional(element)\n ? Effect.fail(new OptionalTupleElementsAreNotSupportedError())\n : compileAst(element, false, scope);\n\n const arrayItemsValidator = yield* f === undefined\n ? pipe(\n rest,\n Array.head,\n Option.match({\n onNone: () => Effect.fail(new EmptyTupleIsNotSupportedError()),\n onSome: (type) => compileAst(type, false, scope),\n }),\n )\n : s === undefined\n ? elementToValidator(f)\n : Effect.gen(function* () {\n const firstValidator = yield* elementToValidator(f);\n const secondValidator = yield* elementToValidator(s);\n const restValidators = yield* Effect.forEach(r, elementToValidator);\n\n return v.union(firstValidator, secondValidator, ...restValidators);\n });\n\n return v.array(arrayItemsValidator);\n});\n\nconst handlePropertySignatures = (\n objectsAst: SchemaAST.Objects,\n scope: IdScope.IdScope,\n) =>\n pipe(\n objectsAst.propertySignatures,\n Effect.forEach(({ type, name }) => {\n const isOptional = SchemaAST.isOptional(type);\n if (String.isString(name)) {\n // Somehow, somewhere, keys of type number are being coerced to strings…\n return Option.match(Number.parse(name), {\n onNone: () =>\n Effect.gen(function* () {\n const validator = yield* compileAst(type, isOptional, scope);\n\n return {\n propertyName: name,\n validator: isOptional ? v.optional(validator) : validator,\n };\n }),\n onSome: (number) =>\n Effect.fail(\n new UnsupportedPropertySignatureKeyTypeError({\n propertyKey: number,\n }),\n ),\n });\n } else {\n return Effect.fail(\n new UnsupportedPropertySignatureKeyTypeError({ propertyKey: name }),\n );\n }\n }),\n Effect.andThen((propertyNamesWithValidators) =>\n pipe(\n propertyNamesWithValidators,\n Array.reduce(\n {} as Record<string, Validator<any, any, any>>,\n (acc, { propertyName, validator }) => ({\n [propertyName]: validator,\n ...acc,\n }),\n ),\n Effect.succeed,\n ),\n ),\n );\n\n// Errors\n\nexport class TopLevelMustBeObjectError extends Data.TaggedError(\n \"TopLevelMustBeObjectError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Top level schema must be an object\";\n }\n /* v8 ignore stop */\n}\n\nexport class TopLevelMustBeObjectOrUnionError extends Data.TaggedError(\n \"TopLevelMustBeObjectOrUnionError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Top level schema must be an object or a union\";\n }\n /* v8 ignore stop */\n}\n\nexport class UnsupportedPropertySignatureKeyTypeError extends Data.TaggedError(\n \"UnsupportedPropertySignatureKeyTypeError\",\n)<{\n readonly propertyKey: number | symbol;\n}> {\n /* v8 ignore start */\n override get message() {\n return `Unsupported property signature '${this.propertyKey.toString()}'. Property is of type '${typeof this.propertyKey}' but only 'string' properties are supported.`;\n }\n /* v8 ignore stop */\n}\n\nexport class EmptyTupleIsNotSupportedError extends Data.TaggedError(\n \"EmptyTupleIsNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Tuple must have at least one element\";\n }\n /* v8 ignore stop */\n}\n\nexport class EmptyUnionIsNotSupportedError extends Data.TaggedError(\n \"EmptyUnionIsNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Union must have at least one member that compiles to a validator\";\n }\n /* v8 ignore stop */\n}\n\nexport class UnsupportedSchemaTypeError extends Data.TaggedError(\n \"UnsupportedSchemaTypeError\",\n)<{\n readonly schemaType: SchemaAST.AST[\"_tag\"];\n}> {\n /* v8 ignore start */\n override get message() {\n return `Unsupported schema type '${this.schemaType}'`;\n }\n /* v8 ignore stop */\n}\n\nexport class IndexSignaturesAreNotSupportedError extends Data.TaggedError(\n \"IndexSignaturesAreNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Index signatures are not supported\";\n }\n /* v8 ignore stop */\n}\n\nexport class MixedIndexAndPropertySignaturesAreNotSupportedError extends Data.TaggedError(\n \"MixedIndexAndPropertySignaturesAreNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Mixed index and property signatures are not supported\";\n }\n /* v8 ignore stop */\n}\n\nexport class OptionalTupleElementsAreNotSupportedError extends Data.TaggedError(\n \"OptionalTupleElementsAreNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Optional tuple elements are not supported\";\n }\n /* v8 ignore stop */\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,qBACX,YACA,QAAyBA,KACzB,kBACA,iBACuB;CACvB,MAAM,MAAM,OAAO,UAAU,UAAU,CAAC,CAAC;CAEzC,MAAM,aAAa,OAAO,QAAQ,eAAe,KAAK,KAAK,CAAC;CAC5D,IAAI,qBAAqB,KAAA,GAAW,OAAO;CAC3C,IAAI,OAAO,OAAO,YAAY,gBAAgB,GAC5C,MAAM,IAAI,0BAA0B;EAClC;EACA,UAAU;CACZ,CAAC;CAEH,OAAO;EAAE,GAAG;GAAa,mBAAmB,EAAE,SAAS,EAAE,IAAI,CAAC;CAAE;AAClE;AAEA,MAAM,kBAAkB,KAAoB,UAC1C,KACE,KACA,MAAM,OACN,MAAM,IAAI,YAAY,eACpB,MAAM,qBAAqB,WAAW,eAAe,IACjD,yBAAyB,YAAY,KAAK,IAC1C,OAAO,KAAK,IAAI,oCAAoC,CAAC,CAC3D,GACA,MAAM,aAAa,OAAO,KAAK,IAAI,0BAA0B,CAAC,CAAC,CACjE;AAEF,IAAa,4BAAb,cAA+C,KAAK,YAClD,2BACF,CAAC,CAGE;CACD,IAAa,UAAU;EACrB,OAAO,GAAG,KAAK,aAAa,0BAA0B,KAAK,SAAS;CACtE;AACF;AAIA,MAAa,wBACX,QACA,QAAyBA,QAEzB,OAAO,QAAQ,WAAW,OAAO,UAAU,MAAM,CAAC,CAAC,KAAK,OAAO,KAAK,CAAC;AAgBvE,MAAa,sBACX,QACA,QAAyBA,QACoB;CAC7C,M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ommitTs","GenericId.tableName","GenericId.scope"],"sources":["../src/SchemaToValidator.ts"],"sourcesContent":["import * as IdScope from \"./IdScope.js\";\nimport type * as Callback from \"./Callback.js\";\nimport { CallbackContract } from \"./internal/annotations.js\";\nimport type {\n CommitTsPlaceholder,\n GenericId as ConvexGenericId,\n PropertyValidators,\n Validator,\n VAny,\n VArray,\n VBoolean,\n VBytes,\n VCommitTs,\n VFloat64,\n VId,\n VInt64,\n VLiteral,\n VNull,\n VObject,\n VRecord,\n VString,\n VUnion,\n} from \"convex/values\";\nimport { v } from \"convex/values\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Data from \"effect/Data\";\nimport * as Effect from \"effect/Effect\";\nimport * as Match from \"effect/Match\";\nimport * as Number from \"effect/Number\";\nimport * as Option from \"effect/Option\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\nimport * as String from \"effect/String\";\n\nimport * as CommitTs from \"./CommitTs.js\";\nimport * as GenericId from \"./GenericId.js\";\nimport type {\n IsAny,\n IsOptional,\n IsRecord,\n IsRecursive,\n IsUnion,\n TypeError,\n UnionToTuple,\n} from \"./Types.js\";\n\n// Args\n\nexport const compileArgsSchema = <ConfectValue, ConvexValue>(\n argsSchema: Schema.Codec<ConfectValue, ConvexValue>,\n scope: IdScope.IdScope = IdScope.app,\n reservedArgument?: string,\n functionName?: string,\n): PropertyValidators => {\n const ast = Schema.toEncoded(argsSchema).ast;\n\n const validators = Effect.runSync(compileArgsAst(ast, scope));\n if (reservedArgument === undefined) return validators;\n if (Object.hasOwn(validators, reservedArgument)) {\n throw new ReservedArgumentCollision({\n functionName,\n argument: reservedArgument,\n });\n }\n return { ...validators, [reservedArgument]: v.optional(v.any()) };\n};\n\nconst compileArgsAst = (ast: SchemaAST.AST, scope: IdScope.IdScope) =>\n pipe(\n ast,\n Match.value,\n Match.tag(\"Objects\", (objectsAst) =>\n Array.isReadonlyArrayEmpty(objectsAst.indexSignatures)\n ? handlePropertySignatures(objectsAst, scope)\n : Effect.fail(new IndexSignaturesAreNotSupportedError()),\n ),\n Match.orElse(() => Effect.fail(new TopLevelMustBeObjectError())),\n );\n\nexport class ReservedArgumentCollision extends Data.TaggedError(\n \"ReservedArgumentCollision\",\n)<{\n readonly functionName: string | undefined;\n readonly argument: string;\n}> {\n override get message() {\n return `${this.functionName} declares the argument \"${this.argument}\", which its profile reserves. Rename the argument.`;\n }\n}\n\n// Returns\n\nexport const compileReturnsSchema = <ConfectValue, ConvexValue>(\n schema: Schema.Codec<ConfectValue, ConvexValue>,\n scope: IdScope.IdScope = IdScope.app,\n): Validator<any, any, any> =>\n Effect.runSync(compileAst(Schema.toEncoded(schema).ast, false, scope));\n\n// Table\n\n/**\n * Convert a table `Schema` to a table `Validator`.\n */\nexport type TableSchemaToTableValidator<\n TableSchema extends Schema.Codec<any, any>,\n> =\n ValueToValidator<TableSchema[\"Encoded\"]> extends infer Vd extends\n | VObject<any, any, any, any>\n | VUnion<any, any, any, any>\n ? Vd\n : never;\n\nexport const compileTableSchema = <TableSchema extends Schema.Codec<any, any>>(\n schema: TableSchema,\n scope: IdScope.IdScope = IdScope.app,\n): TableSchemaToTableValidator<TableSchema> => {\n const ast = Schema.toEncoded(schema).ast;\n\n return pipe(\n ast,\n Match.value,\n Match.tag(\"Objects\", ({ indexSignatures }) =>\n Array.isReadonlyArrayEmpty(indexSignatures)\n ? // oxlint-disable-next-line effecttsgo/unsafe-effect-type-assertion -- The return type is derived from the input schema and cannot be recovered from the runtime AST.\n (compileAst(ast, false, scope) as Effect.Effect<any>)\n : Effect.fail(new IndexSignaturesAreNotSupportedError()),\n ),\n Match.tag(\"Union\", (unionAst) => compileAst(unionAst, false, scope)),\n Match.orElse(() => Effect.fail(new TopLevelMustBeObjectOrUnionError())),\n Effect.runSync,\n );\n};\n\n// Compiler\n\nexport type ReadonlyValue =\n | string\n | number\n | bigint\n | boolean\n | ArrayBuffer\n | CommitTsPlaceholder\n | ReadonlyArrayValue\n | ReadonlyRecordValue\n | null;\n\ntype ReadonlyArrayValue = readonly ReadonlyValue[];\n\nexport type ReadonlyRecordValue = {\n readonly [key: string]: ReadonlyValue | undefined;\n};\n\ntype MutableValue<T> =\n T extends ReadonlyArray<infer El>\n ? MutableValue<El>[]\n : T extends ReadonlyRecordValue\n ? { -readonly [K in keyof T]: MutableValue<Exclude<T[K], undefined>> }\n : T;\n\nexport type ValueToValidator<Vl> = [Vl] extends [never]\n ? never\n : IsAny<Vl> extends true\n ? VAny\n : [Vl] extends [string | number | bigint | boolean | null | ArrayBuffer]\n ? ConvertValueToValidator<Vl>\n : IsRecursive<Vl> extends true\n ? VAny\n : [Vl] extends [ReadonlyValue]\n ? ConvertValueToValidator<Vl>\n : TypeError<\"Provided value is not a valid Convex value\", Vl>;\n\ntype OptionalValue<Vl, Optionality> = Optionality extends \"optional\"\n ? Vl | undefined\n : Vl;\n\ntype ConvertValueToValidator<\n Vl,\n Optionality extends \"required\" | \"optional\" = \"required\",\n> = [Vl] extends [never]\n ? never\n : IsAny<Vl> extends true\n ? VAny<any, Optionality>\n : [Vl] extends [null]\n ? VNull<OptionalValue<null, Optionality>, Optionality>\n : [Vl] extends [boolean]\n ? [boolean] extends [Vl]\n ? VBoolean<OptionalValue<boolean, Optionality>, Optionality>\n : VLiteral<OptionalValue<Vl, Optionality>, Optionality>\n : IsUnion<Vl> extends true\n ? IsCommitTs<Vl> extends true\n ? VCommitTs<OptionalValue<Vl, Optionality>, Optionality>\n : UnionValueToValidator<Vl, Optionality>\n : [Vl] extends [number]\n ? [number] extends [Vl]\n ? VFloat64<OptionalValue<number, Optionality>, Optionality>\n : VLiteral<OptionalValue<Vl, Optionality>, Optionality>\n : [Vl] extends [bigint]\n ? [bigint] extends [Vl]\n ? VInt64<OptionalValue<bigint, Optionality>, Optionality>\n : VLiteral<OptionalValue<Vl, Optionality>, Optionality>\n : [Vl] extends [string]\n ? StringValueToValidator<Vl, Optionality>\n : [Vl] extends [ArrayBuffer]\n ? VBytes<OptionalValue<ArrayBuffer, Optionality>, Optionality>\n : IsCommitTs<Vl> extends true\n ? VCommitTs<OptionalValue<Vl, Optionality>, Optionality>\n : IsRecursive<Vl> extends true\n ? VAny<any, Optionality>\n : Vl extends ReadonlyArray<infer El>\n ? VArray<\n OptionalValue<MutableValue<El[]>, Optionality>,\n ConvertValueToValidator<El>,\n Optionality\n >\n : Vl extends object\n ? ObjectValueToValidator<Vl, Optionality>\n : never;\n\ntype IsCommitTs<Vl> = [Vl] extends [bigint | CommitTsPlaceholder]\n ? [CommitTsPlaceholder] extends [Vl]\n ? true\n : false\n : false;\n\ntype StringValueToValidator<Vl, Optionality extends \"required\" | \"optional\"> =\n Vl extends ConvexGenericId<string>\n ? VId<OptionalValue<Vl, Optionality>, Optionality>\n : [string] extends [Vl]\n ? VString<OptionalValue<string, Optionality>, Optionality>\n : VLiteral<OptionalValue<Vl, Optionality>, Optionality>;\n\ntype ObjectValueToValidator<Vl, Optionality extends \"required\" | \"optional\"> =\n IsRecord<MutableValue<Vl>> extends true\n ? ValueToValidator<Vl[keyof Vl]> extends infer VdValue extends Validator<\n any,\n \"required\",\n any\n >\n ? VRecord<\n OptionalValue<MutableValue<Vl>, Optionality>,\n VString,\n VdValue,\n Optionality\n >\n : never\n : ObjectFieldsToValidators<Vl> extends infer VdFields extends Record<\n string,\n any\n >\n ? VObject<\n OptionalValue<MutableValue<Vl>, Optionality>,\n VdFields,\n Optionality\n >\n : never;\n\ntype ObjectFieldsToValidators<Vl> = {\n -readonly [K in keyof Vl]-?: IsAny<Vl[K]> extends true\n ? IsOptional<Vl, K> extends true\n ? VAny<any, \"optional\">\n : VAny\n : undefined extends Vl[K]\n ? OptionalValueToValidator<Vl[K]>\n : [Vl[K]] extends [ReadonlyValue]\n ? ConvertValueToValidator<Vl[K]>\n : never;\n};\n\nexport type UndefinedOrValueToValidator<Vl extends ReadonlyValue | undefined> =\n undefined extends Vl\n ? OptionalValueToValidator<Vl>\n : [Vl] extends [ReadonlyValue]\n ? ValueToValidator<Vl>\n : never;\n\ntype UnionValueToValidator<Vl, Optionality extends \"required\" | \"optional\"> =\n IsRecursive<Vl> extends true\n ? VAny<any, Optionality>\n : [Extract<Vl, CommitTsPlaceholder>] extends [never]\n ? VUnion<\n OptionalValue<MutableValue<Vl>, Optionality>,\n ValueTupleToValidatorTuple<UnionToTuple<Vl>>,\n Optionality\n >\n : CommitTsUnionValueToValidator<Vl, Optionality>;\n\n// A CommitTs is one validator at runtime, so its bigint and placeholder\n// branches collapse into a single member, as true and false do into VBoolean.\n// Only a union holding a placeholder comes here, because the infer that lets\n// the spread tuple satisfy VUnion's constraint makes other unions far costlier.\ntype CommitTsUnionValueToValidator<\n Vl,\n Optionality extends \"required\" | \"optional\",\n> = [\n VCommitTs,\n ...ValueTupleToValidatorTuple<\n UnionToTuple<Exclude<Vl, bigint | CommitTsPlaceholder>>\n >,\n] extends infer VdMembers extends Validator<any, \"required\", any>[]\n ? VUnion<OptionalValue<MutableValue<Vl>, Optionality>, VdMembers, Optionality>\n : never;\n\ntype ValueTupleToValidatorTuple<\n VlTuple extends readonly unknown[],\n Acc extends Validator<any, \"required\", any>[] = [],\n> = VlTuple extends\n | [true, false, ...infer VlRest]\n | [false, true, ...infer VlRest]\n ? ValueTupleToValidatorTuple<VlRest, [...Acc, VBoolean]>\n : VlTuple extends [infer Vl, ...infer VlRest]\n ? ValueTupleToValidatorTuple<VlRest, [...Acc, ConvertValueToValidator<Vl>]>\n : Acc;\n\ntype OptionalValueToValidator<Vl> = [Vl] extends [\n (infer Val extends ReadonlyValue) | undefined,\n]\n ? ConvertValueToValidator<Val, \"optional\">\n : never;\n\nexport const compileSchema = <T, E>(\n schema: Schema.Codec<T, E>,\n): ValueToValidator<(typeof schema)[\"Encoded\"]> =>\n Effect.runSync(compileAst(schema.ast)) as any;\n\nexport const isRecursive = (ast: SchemaAST.AST): boolean =>\n pipe(\n ast,\n Match.value,\n Match.tag(\n \"Literal\",\n \"Null\",\n \"Boolean\",\n \"String\",\n \"Number\",\n \"BigInt\",\n \"Unknown\",\n \"Any\",\n \"Declaration\",\n \"UniqueSymbol\",\n \"Symbol\",\n \"Undefined\",\n \"Void\",\n \"Never\",\n \"Enum\",\n \"TemplateLiteral\",\n \"ObjectKeyword\",\n () => false,\n ),\n Match.tag(\"Union\", ({ types }) =>\n Array.some(types, (type) => isRecursive(type)),\n ),\n Match.tag(\"Objects\", ({ propertySignatures }) =>\n Array.some(propertySignatures, ({ type }) => isRecursive(type)),\n ),\n Match.tag(\n \"Arrays\",\n ({ elements, rest }) =>\n Array.some(elements, (element) => isRecursive(element)) ||\n Array.some(rest, (element) => isRecursive(element)),\n ),\n Match.tag(\"Suspend\", () => true),\n Match.exhaustive,\n );\n\nexport const compileAst = (\n ast: SchemaAST.AST,\n isOptionalPropertyOfTypeLiteral = false,\n scope: IdScope.IdScope = IdScope.app,\n): Effect.Effect<\n Validator<any, any, any>,\n | TopLevelMustBeObjectError\n | UnsupportedSchemaTypeError\n | UnsupportedPropertySignatureKeyTypeError\n | IndexSignaturesAreNotSupportedError\n | MixedIndexAndPropertySignaturesAreNotSupportedError\n | OptionalTupleElementsAreNotSupportedError\n | EmptyTupleIsNotSupportedError\n | EmptyUnionIsNotSupportedError\n> => {\n const contract = SchemaAST.resolveAt<Callback.Any>(CallbackContract)(ast);\n if (contract !== undefined) {\n return Effect.gen(function* () {\n const args = yield* compileArgsAst(\n Schema.toEncoded(contract.functionProvenance.args).ast,\n scope,\n );\n const returns = yield* compileAst(\n Schema.toEncoded(contract.functionProvenance.returns).ast,\n false,\n scope,\n );\n return v.function({ fnType: contract.functionType, args, returns });\n });\n }\n if (CommitTs.isCommitTs(ast)) return Effect.succeed(v.commitTs());\n return isRecursive(ast)\n ? Effect.succeed(v.any())\n : pipe(\n ast,\n Match.value,\n Match.tag(\"Literal\", ({ literal }) =>\n pipe(\n literal,\n Match.value,\n Match.whenOr(\n Match.string,\n Match.number,\n Match.bigint,\n Match.boolean,\n (l) => v.literal(l),\n ),\n Match.exhaustive,\n Effect.succeed,\n ),\n ),\n Match.tag(\"Null\", () => Effect.succeed(v.null())),\n Match.tag(\"Boolean\", () => Effect.succeed(v.boolean())),\n Match.tag(\"String\", (stringAst) =>\n GenericId.tableName(stringAst).pipe(\n Option.match({\n onNone: () => Effect.succeed(v.string()),\n onSome: (tableName) =>\n Effect.succeed(\n GenericId.scope(stringAst) === scope\n ? v.id(tableName)\n : v.string(),\n ),\n }),\n ),\n ),\n Match.tag(\"Number\", () => Effect.succeed(v.float64())),\n Match.tag(\"BigInt\", () => Effect.succeed(v.int64())),\n Match.tag(\"Union\", (unionAst) =>\n handleUnion(unionAst, isOptionalPropertyOfTypeLiteral, scope),\n ),\n Match.tag(\"Objects\", (objectsAst) => handleObjects(objectsAst, scope)),\n Match.tag(\"Arrays\", (arraysAst) => handleArrays(arraysAst, scope)),\n Match.tag(\"Unknown\", \"Any\", () => Effect.succeed(v.any())),\n Match.tag(\"Declaration\", (declaration) =>\n Effect.mapBoth(\n // oxlint-disable-next-line effecttsgo/any-unknown-in-error-context -- Codec inputs are context-free, but Effect's SchemaAST.DeclarationRun erases their requirements to `any`.\n declaration.run(declaration.typeParameters)(\n new ArrayBuffer(0),\n declaration,\n {},\n ) as Effect.Effect<ArrayBuffer, unknown, never>,\n {\n onSuccess: () => v.bytes(),\n onFailure: () =>\n new UnsupportedSchemaTypeError({\n schemaType: declaration._tag,\n }),\n },\n ),\n ),\n Match.tag(\"Suspend\", () => Effect.succeed(v.any())),\n Match.tag(\n \"UniqueSymbol\",\n \"Symbol\",\n \"Undefined\",\n \"Void\",\n \"Never\",\n \"Enum\",\n \"TemplateLiteral\",\n \"ObjectKeyword\",\n () =>\n Effect.fail(\n new UnsupportedSchemaTypeError({\n schemaType: ast._tag,\n }),\n ),\n ),\n Match.exhaustive,\n );\n};\n\nconst handleUnion = (\n { types }: SchemaAST.Union,\n isOptionalPropertyOfTypeLiteral: boolean,\n scope: IdScope.IdScope,\n) => handleUnionTypes(types, isOptionalPropertyOfTypeLiteral, scope);\n\nconst handleUnionTypes = Effect.fnUntraced(function* (\n types: SchemaAST.Union[\"types\"],\n isOptionalPropertyOfTypeLiteral: boolean,\n scope: IdScope.IdScope,\n) {\n const members = isOptionalPropertyOfTypeLiteral\n ? Array.filter(types, Predicate.not(SchemaAST.isUndefined))\n : types;\n\n const [firstValidator, secondValidator, ...restValidators] =\n yield* Effect.all(\n Array.map(members, (type) => compileAst(type, false, scope)),\n );\n\n if (firstValidator === undefined) {\n return yield* new EmptyUnionIsNotSupportedError();\n } else if (secondValidator === undefined) {\n return firstValidator;\n } else {\n return v.union(firstValidator, secondValidator, ...restValidators);\n }\n});\n\nconst handleObjects = (objectsAst: SchemaAST.Objects, scope: IdScope.IdScope) =>\n pipe(\n objectsAst.indexSignatures,\n Array.head,\n Option.match({\n onNone: () =>\n Effect.map(handlePropertySignatures(objectsAst, scope), v.object),\n onSome: ({ parameter, type }) =>\n pipe(\n objectsAst.propertySignatures,\n Array.head,\n Option.match({\n onNone: () =>\n Effect.map(\n Effect.all({\n parameter_: compileAst(parameter, false, scope),\n type_: compileAst(type, false, scope),\n }),\n ({ parameter_, type_ }) => v.record(parameter_, type_),\n ),\n onSome: () =>\n Effect.fail(\n new MixedIndexAndPropertySignaturesAreNotSupportedError(),\n ),\n }),\n ),\n }),\n );\n\nconst handleArrays = (\n { elements, rest }: SchemaAST.Arrays,\n scope: IdScope.IdScope,\n) => handleArrayElements(elements, rest, scope);\n\nconst handleArrayElements = Effect.fnUntraced(function* (\n elements: SchemaAST.Arrays[\"elements\"],\n rest: SchemaAST.Arrays[\"rest\"],\n scope: IdScope.IdScope,\n) {\n const [f, s, ...r] = elements;\n\n const elementToValidator = (element: SchemaAST.AST) =>\n SchemaAST.isOptional(element)\n ? Effect.fail(new OptionalTupleElementsAreNotSupportedError())\n : compileAst(element, false, scope);\n\n const arrayItemsValidator = yield* f === undefined\n ? pipe(\n rest,\n Array.head,\n Option.match({\n onNone: () => Effect.fail(new EmptyTupleIsNotSupportedError()),\n onSome: (type) => compileAst(type, false, scope),\n }),\n )\n : s === undefined\n ? elementToValidator(f)\n : Effect.gen(function* () {\n const firstValidator = yield* elementToValidator(f);\n const secondValidator = yield* elementToValidator(s);\n const restValidators = yield* Effect.forEach(r, elementToValidator);\n\n return v.union(firstValidator, secondValidator, ...restValidators);\n });\n\n return v.array(arrayItemsValidator);\n});\n\nconst handlePropertySignatures = (\n objectsAst: SchemaAST.Objects,\n scope: IdScope.IdScope,\n) =>\n pipe(\n objectsAst.propertySignatures,\n Effect.forEach(({ type, name }) => {\n const isOptional = SchemaAST.isOptional(type);\n if (String.isString(name)) {\n // Somehow, somewhere, keys of type number are being coerced to strings…\n return Option.match(Number.parse(name), {\n onNone: () =>\n Effect.gen(function* () {\n const validator = yield* compileAst(type, isOptional, scope);\n\n return {\n propertyName: name,\n validator: isOptional ? v.optional(validator) : validator,\n };\n }),\n onSome: (number) =>\n Effect.fail(\n new UnsupportedPropertySignatureKeyTypeError({\n propertyKey: number,\n }),\n ),\n });\n } else {\n return Effect.fail(\n new UnsupportedPropertySignatureKeyTypeError({ propertyKey: name }),\n );\n }\n }),\n Effect.andThen((propertyNamesWithValidators) =>\n pipe(\n propertyNamesWithValidators,\n Array.reduce(\n {} as Record<string, Validator<any, any, any>>,\n (acc, { propertyName, validator }) => ({\n [propertyName]: validator,\n ...acc,\n }),\n ),\n Effect.succeed,\n ),\n ),\n );\n\n// Errors\n\nexport class TopLevelMustBeObjectError extends Data.TaggedError(\n \"TopLevelMustBeObjectError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Top level schema must be an object\";\n }\n /* v8 ignore stop */\n}\n\nexport class TopLevelMustBeObjectOrUnionError extends Data.TaggedError(\n \"TopLevelMustBeObjectOrUnionError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Top level schema must be an object or a union\";\n }\n /* v8 ignore stop */\n}\n\nexport class UnsupportedPropertySignatureKeyTypeError extends Data.TaggedError(\n \"UnsupportedPropertySignatureKeyTypeError\",\n)<{\n readonly propertyKey: number | symbol;\n}> {\n /* v8 ignore start */\n override get message() {\n return `Unsupported property signature '${this.propertyKey.toString()}'. Property is of type '${typeof this.propertyKey}' but only 'string' properties are supported.`;\n }\n /* v8 ignore stop */\n}\n\nexport class EmptyTupleIsNotSupportedError extends Data.TaggedError(\n \"EmptyTupleIsNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Tuple must have at least one element\";\n }\n /* v8 ignore stop */\n}\n\nexport class EmptyUnionIsNotSupportedError extends Data.TaggedError(\n \"EmptyUnionIsNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Union must have at least one member that compiles to a validator\";\n }\n /* v8 ignore stop */\n}\n\nexport class UnsupportedSchemaTypeError extends Data.TaggedError(\n \"UnsupportedSchemaTypeError\",\n)<{\n readonly schemaType: SchemaAST.AST[\"_tag\"];\n}> {\n /* v8 ignore start */\n override get message() {\n return `Unsupported schema type '${this.schemaType}'`;\n }\n /* v8 ignore stop */\n}\n\nexport class IndexSignaturesAreNotSupportedError extends Data.TaggedError(\n \"IndexSignaturesAreNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Index signatures are not supported\";\n }\n /* v8 ignore stop */\n}\n\nexport class MixedIndexAndPropertySignaturesAreNotSupportedError extends Data.TaggedError(\n \"MixedIndexAndPropertySignaturesAreNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Mixed index and property signatures are not supported\";\n }\n /* v8 ignore stop */\n}\n\nexport class OptionalTupleElementsAreNotSupportedError extends Data.TaggedError(\n \"OptionalTupleElementsAreNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Optional tuple elements are not supported\";\n }\n /* v8 ignore stop */\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAa,qBACX,YACA,QAAyBA,KACzB,kBACA,iBACuB;CACvB,MAAM,MA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,KAAK,YACzD,kCACF,CAAC,CAAC;;CAEA,IAAa,UAAU;EACrB,OAAO;CACT;AAEF;AAEA,IAAa,2CAAb,cAA8D,KAAK,YACjE,0CACF,CAAC,CAEE;;CAED,IAAa,UAAU;EACrB,OAAO,mCAAmC,KAAK,YAAY,SAAS,EAAE,0BAA0B,OAAO,KAAK,YAAY;CAC1H;AAEF;AAEA,IAAa,gCAAb,cAAmD,KAAK,YACtD,+BACF,CAAC,CAAC;;CAEA,IAAa,UAAU;EACrB,OAAO;CACT;AAEF;AAEA,IAAa,gCAAb,cAAmD,KAAK,YACtD,+BACF,CAAC,CAAC;;CAEA,IAAa,UAAU;EACrB,OAAO;CACT;AAEF;AAEA,IAAa,6BAAb,cAAgD,KAAK,YACnD,4BACF,CAAC,CAEE;;CAED,IAAa,UAAU;EACrB,OAAO,4BAA4B,KAAK,WAAW;CACrD;AAEF;AAEA,IAAa,sCAAb,cAAyD,KAAK,YAC5D,qCACF,CAAC,CAAC;;CAEA,IAAa,UAAU;EACrB,OAAO;CACT;AAEF;AAEA,IAAa,sDAAb,cAAyE,KAAK,YAC5E,qDACF,CAAC,CAAC;;CAEA,IAAa,UAAU;EACrB,OAAO;CACT;AAEF;AAEA,IAAa,4CAAb,cAA+D,KAAK,YAClE,2CACF,CAAC,CAAC;;CAEA,IAAa,UAAU;EACrB,OAAO;CACT;AAEF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * as ActionCall from "./ActionCall.js";
|
|
2
2
|
export * as Callback from "./Callback.js";
|
|
3
|
+
export * as CommitTs from "./CommitTs.js";
|
|
3
4
|
export * as FunctionProvenance from "./FunctionProvenance.js";
|
|
4
5
|
export * as FunctionSpec from "./FunctionSpec.js";
|
|
5
6
|
export * as GenericId from "./GenericId.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"m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AqB,CAAC;AACtD,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import { Component_exports } from "./Component.js";
|
|
|
18
18
|
import { Mount_exports } from "./Mount.js";
|
|
19
19
|
import { App_exports } from "./App.js";
|
|
20
20
|
import { Auth_exports } from "./Auth.js";
|
|
21
|
+
import { CommitTs_exports } from "./CommitTs.js";
|
|
21
22
|
import { Env_exports } from "./Env.js";
|
|
22
23
|
import { GroupPath_exports } from "./GroupPath.js";
|
|
23
24
|
import { Http_exports } from "./Http.js";
|
|
@@ -31,4 +32,4 @@ import { SystemFields_exports } from "./SystemFields.js";
|
|
|
31
32
|
import { Table_exports } from "./Table.js";
|
|
32
33
|
import { Types_exports } from "./Types.js";
|
|
33
34
|
import { UserIdentity_exports } from "./UserIdentity.js";
|
|
34
|
-
export { ActionCall_exports as ActionCall, App_exports as App, Auth_exports as Auth, Callback_exports as Callback, Component_exports as Component, Env_exports as Env, FunctionProvenance_exports as FunctionProvenance, FunctionSpec_exports as FunctionSpec, GenericId_exports as GenericId, GroupPath_exports as GroupPath, GroupSpec_exports as GroupSpec, Http_exports as Http, IdScope_exports as IdScope, Identifier_exports as Identifier, Lazy_exports as Lazy, Manifest_exports as Manifest, ManifestSection_exports as ManifestSection, MiddlewareAttachment_exports as MiddlewareAttachment, MiddlewareSpec_exports as MiddlewareSpec, Mount_exports as Mount, PaginationError_exports as PaginationError, PaginationOptions_exports as PaginationOptions, PaginationResult_exports as PaginationResult, Profile_exports as Profile, Ref_exports as Ref, Refs_exports as Refs, RuntimeAndFunctionType_exports as RuntimeAndFunctionType, SchemaToValidator_exports as SchemaToValidator, Spec_exports as Spec, SystemFields_exports as SystemFields, Table_exports as Table, Types_exports as Types, UserIdentity_exports as UserIdentity };
|
|
35
|
+
export { ActionCall_exports as ActionCall, App_exports as App, Auth_exports as Auth, Callback_exports as Callback, CommitTs_exports as CommitTs, Component_exports as Component, Env_exports as Env, FunctionProvenance_exports as FunctionProvenance, FunctionSpec_exports as FunctionSpec, GenericId_exports as GenericId, GroupPath_exports as GroupPath, GroupSpec_exports as GroupSpec, Http_exports as Http, IdScope_exports as IdScope, Identifier_exports as Identifier, Lazy_exports as Lazy, Manifest_exports as Manifest, ManifestSection_exports as ManifestSection, MiddlewareAttachment_exports as MiddlewareAttachment, MiddlewareSpec_exports as MiddlewareSpec, Mount_exports as Mount, PaginationError_exports as PaginationError, PaginationOptions_exports as PaginationOptions, PaginationResult_exports as PaginationResult, Profile_exports as Profile, Ref_exports as Ref, Refs_exports as Refs, RuntimeAndFunctionType_exports as RuntimeAndFunctionType, SchemaToValidator_exports as SchemaToValidator, Spec_exports as Spec, SystemFields_exports as SystemFields, Table_exports as Table, Types_exports as Types, UserIdentity_exports as UserIdentity };
|
package/package.json
CHANGED
package/src/CommitTs.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CommitTsPlaceholder } from "convex/values";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
4
|
+
|
|
5
|
+
const ConvexCommitTs = "~@confect/core/ConvexCommitTs";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A commit timestamp as Convex types it. A mutation writes the database
|
|
9
|
+
* writer's `vars.commitTs` placeholder, which resolves to an int64 when the
|
|
10
|
+
* mutation commits. Reading the field back inside that mutation still yields
|
|
11
|
+
* the placeholder, so a reader narrows with `typeof value === "bigint"` before
|
|
12
|
+
* using it as a number.
|
|
13
|
+
*/
|
|
14
|
+
export type CommitTs = bigint | CommitTsPlaceholder;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A field Convex stores as `v.commitTs()`. An index on it orders documents by
|
|
18
|
+
* commit order.
|
|
19
|
+
*/
|
|
20
|
+
export const CommitTs: Schema.Codec<CommitTs> = Schema.Union([
|
|
21
|
+
Schema.BigInt,
|
|
22
|
+
Schema.instanceOf(CommitTsPlaceholder),
|
|
23
|
+
]).annotate({ [ConvexCommitTs]: true });
|
|
24
|
+
|
|
25
|
+
export const isCommitTs = (ast: SchemaAST.AST): boolean =>
|
|
26
|
+
SchemaAST.resolveAt<boolean>(ConvexCommitTs)(ast) === true;
|
package/src/ManifestSection.ts
CHANGED
|
@@ -6,11 +6,19 @@ export interface Data<Value = unknown> {
|
|
|
6
6
|
readonly functions: Readonly<Record<string, Value>>;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* The backend codegen generates: the app, or a component under the name its
|
|
11
|
+
* `defineComponent` gives it.
|
|
12
|
+
*/
|
|
13
|
+
export type Target =
|
|
14
|
+
| { readonly kind: "app" }
|
|
15
|
+
| { readonly kind: "component"; readonly name: string };
|
|
16
|
+
|
|
9
17
|
/**
|
|
10
18
|
* What codegen hands a section's `render`: the exports of each `confect/` file
|
|
11
19
|
* it matched, every registered function with the spec file declaring it, each
|
|
12
|
-
* mounted component with the specifier of its definition,
|
|
13
|
-
*
|
|
20
|
+
* mounted component with the specifier of its definition, every file `match`
|
|
21
|
+
* was offered, the backend it generates and the absolute path of `confect/`.
|
|
14
22
|
*/
|
|
15
23
|
export interface GenerateInput {
|
|
16
24
|
readonly modules: ReadonlyArray<{
|
|
@@ -26,6 +34,8 @@ export interface GenerateInput {
|
|
|
26
34
|
readonly definition: string;
|
|
27
35
|
}>;
|
|
28
36
|
readonly files: ReadonlyArray<string>;
|
|
37
|
+
readonly target: Target;
|
|
38
|
+
readonly confectDirectory: string;
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
export interface Generate {
|
package/src/SchemaToValidator.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as IdScope from "./IdScope.js";
|
|
|
2
2
|
import type * as Callback from "./Callback.js";
|
|
3
3
|
import { CallbackContract } from "./internal/annotations.js";
|
|
4
4
|
import type {
|
|
5
|
+
CommitTsPlaceholder,
|
|
5
6
|
GenericId as ConvexGenericId,
|
|
6
7
|
PropertyValidators,
|
|
7
8
|
Validator,
|
|
@@ -9,6 +10,7 @@ import type {
|
|
|
9
10
|
VArray,
|
|
10
11
|
VBoolean,
|
|
11
12
|
VBytes,
|
|
13
|
+
VCommitTs,
|
|
12
14
|
VFloat64,
|
|
13
15
|
VId,
|
|
14
16
|
VInt64,
|
|
@@ -32,6 +34,7 @@ import * as Schema from "effect/Schema";
|
|
|
32
34
|
import * as SchemaAST from "effect/SchemaAST";
|
|
33
35
|
import * as String from "effect/String";
|
|
34
36
|
|
|
37
|
+
import * as CommitTs from "./CommitTs.js";
|
|
35
38
|
import * as GenericId from "./GenericId.js";
|
|
36
39
|
import type {
|
|
37
40
|
IsAny,
|
|
@@ -138,6 +141,7 @@ export type ReadonlyValue =
|
|
|
138
141
|
| bigint
|
|
139
142
|
| boolean
|
|
140
143
|
| ArrayBuffer
|
|
144
|
+
| CommitTsPlaceholder
|
|
141
145
|
| ReadonlyArrayValue
|
|
142
146
|
| ReadonlyRecordValue
|
|
143
147
|
| null;
|
|
@@ -185,7 +189,9 @@ type ConvertValueToValidator<
|
|
|
185
189
|
? VBoolean<OptionalValue<boolean, Optionality>, Optionality>
|
|
186
190
|
: VLiteral<OptionalValue<Vl, Optionality>, Optionality>
|
|
187
191
|
: IsUnion<Vl> extends true
|
|
188
|
-
?
|
|
192
|
+
? IsCommitTs<Vl> extends true
|
|
193
|
+
? VCommitTs<OptionalValue<Vl, Optionality>, Optionality>
|
|
194
|
+
: UnionValueToValidator<Vl, Optionality>
|
|
189
195
|
: [Vl] extends [number]
|
|
190
196
|
? [number] extends [Vl]
|
|
191
197
|
? VFloat64<OptionalValue<number, Optionality>, Optionality>
|
|
@@ -198,17 +204,25 @@ type ConvertValueToValidator<
|
|
|
198
204
|
? StringValueToValidator<Vl, Optionality>
|
|
199
205
|
: [Vl] extends [ArrayBuffer]
|
|
200
206
|
? VBytes<OptionalValue<ArrayBuffer, Optionality>, Optionality>
|
|
201
|
-
:
|
|
202
|
-
?
|
|
203
|
-
: Vl extends
|
|
204
|
-
?
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
:
|
|
207
|
+
: IsCommitTs<Vl> extends true
|
|
208
|
+
? VCommitTs<OptionalValue<Vl, Optionality>, Optionality>
|
|
209
|
+
: IsRecursive<Vl> extends true
|
|
210
|
+
? VAny<any, Optionality>
|
|
211
|
+
: Vl extends ReadonlyArray<infer El>
|
|
212
|
+
? VArray<
|
|
213
|
+
OptionalValue<MutableValue<El[]>, Optionality>,
|
|
214
|
+
ConvertValueToValidator<El>,
|
|
215
|
+
Optionality
|
|
216
|
+
>
|
|
217
|
+
: Vl extends object
|
|
218
|
+
? ObjectValueToValidator<Vl, Optionality>
|
|
219
|
+
: never;
|
|
220
|
+
|
|
221
|
+
type IsCommitTs<Vl> = [Vl] extends [bigint | CommitTsPlaceholder]
|
|
222
|
+
? [CommitTsPlaceholder] extends [Vl]
|
|
223
|
+
? true
|
|
224
|
+
: false
|
|
225
|
+
: false;
|
|
212
226
|
|
|
213
227
|
type StringValueToValidator<Vl, Optionality extends "required" | "optional"> =
|
|
214
228
|
Vl extends ConvexGenericId<string>
|
|
@@ -264,11 +278,29 @@ export type UndefinedOrValueToValidator<Vl extends ReadonlyValue | undefined> =
|
|
|
264
278
|
type UnionValueToValidator<Vl, Optionality extends "required" | "optional"> =
|
|
265
279
|
IsRecursive<Vl> extends true
|
|
266
280
|
? VAny<any, Optionality>
|
|
267
|
-
:
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
281
|
+
: [Extract<Vl, CommitTsPlaceholder>] extends [never]
|
|
282
|
+
? VUnion<
|
|
283
|
+
OptionalValue<MutableValue<Vl>, Optionality>,
|
|
284
|
+
ValueTupleToValidatorTuple<UnionToTuple<Vl>>,
|
|
285
|
+
Optionality
|
|
286
|
+
>
|
|
287
|
+
: CommitTsUnionValueToValidator<Vl, Optionality>;
|
|
288
|
+
|
|
289
|
+
// A CommitTs is one validator at runtime, so its bigint and placeholder
|
|
290
|
+
// branches collapse into a single member, as true and false do into VBoolean.
|
|
291
|
+
// Only a union holding a placeholder comes here, because the infer that lets
|
|
292
|
+
// the spread tuple satisfy VUnion's constraint makes other unions far costlier.
|
|
293
|
+
type CommitTsUnionValueToValidator<
|
|
294
|
+
Vl,
|
|
295
|
+
Optionality extends "required" | "optional",
|
|
296
|
+
> = [
|
|
297
|
+
VCommitTs,
|
|
298
|
+
...ValueTupleToValidatorTuple<
|
|
299
|
+
UnionToTuple<Exclude<Vl, bigint | CommitTsPlaceholder>>
|
|
300
|
+
>,
|
|
301
|
+
] extends infer VdMembers extends Validator<any, "required", any>[]
|
|
302
|
+
? VUnion<OptionalValue<MutableValue<Vl>, Optionality>, VdMembers, Optionality>
|
|
303
|
+
: never;
|
|
272
304
|
|
|
273
305
|
type ValueTupleToValidatorTuple<
|
|
274
306
|
VlTuple extends readonly unknown[],
|
|
@@ -362,6 +394,7 @@ export const compileAst = (
|
|
|
362
394
|
return v.function({ fnType: contract.functionType, args, returns });
|
|
363
395
|
});
|
|
364
396
|
}
|
|
397
|
+
if (CommitTs.isCommitTs(ast)) return Effect.succeed(v.commitTs());
|
|
365
398
|
return isRecursive(ast)
|
|
366
399
|
? Effect.succeed(v.any())
|
|
367
400
|
: pipe(
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * as ActionCall from "./ActionCall.js";
|
|
2
2
|
export * as Callback from "./Callback.js";
|
|
3
|
+
export * as CommitTs from "./CommitTs.js";
|
|
3
4
|
export * as FunctionProvenance from "./FunctionProvenance.js";
|
|
4
5
|
export * as FunctionSpec from "./FunctionSpec.js";
|
|
5
6
|
export * as GenericId from "./GenericId.js";
|