@confect/server 9.0.0-next.9 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +154 -4
  2. package/dist/ActionCtx.d.ts +3 -10
  3. package/dist/ActionCtx.d.ts.map +1 -1
  4. package/dist/ActionRunner.d.ts +7 -14
  5. package/dist/ActionRunner.d.ts.map +1 -1
  6. package/dist/Auth.d.ts +15 -23
  7. package/dist/Auth.d.ts.map +1 -1
  8. package/dist/BlobNotFoundError.d.ts +5 -11
  9. package/dist/BlobNotFoundError.d.ts.map +1 -1
  10. package/dist/ConvexConfigProvider.d.ts +1 -8
  11. package/dist/ConvexConfigProvider.d.ts.map +1 -1
  12. package/dist/CronJob.d.ts +12 -19
  13. package/dist/CronJob.d.ts.map +1 -1
  14. package/dist/CronJobs.d.ts +11 -18
  15. package/dist/CronJobs.d.ts.map +1 -1
  16. package/dist/DataModel.d.ts +24 -29
  17. package/dist/DataModel.d.ts.map +1 -1
  18. package/dist/DatabaseReader.d.ts +4313 -4328
  19. package/dist/DatabaseReader.d.ts.map +1 -1
  20. package/dist/DatabaseSchema.d.ts +19 -24
  21. package/dist/DatabaseSchema.d.ts.map +1 -1
  22. package/dist/DatabaseWriter.d.ts +36 -42
  23. package/dist/DatabaseWriter.d.ts.map +1 -1
  24. package/dist/Document.d.ts +26 -36
  25. package/dist/Document.d.ts.map +1 -1
  26. package/dist/FunctionImpl.d.ts +11 -20
  27. package/dist/FunctionImpl.d.ts.map +1 -1
  28. package/dist/GroupImpl.d.ts +29 -35
  29. package/dist/GroupImpl.d.ts.map +1 -1
  30. package/dist/Handler.d.ts +34 -40
  31. package/dist/Handler.d.ts.map +1 -1
  32. package/dist/HttpApi.d.ts +19 -25
  33. package/dist/HttpApi.d.ts.map +1 -1
  34. package/dist/HttpApi.js +4 -4
  35. package/dist/HttpApi.js.map +1 -1
  36. package/dist/MutationCtx.d.ts +3 -10
  37. package/dist/MutationCtx.d.ts.map +1 -1
  38. package/dist/MutationRunner.d.ts +7 -14
  39. package/dist/MutationRunner.d.ts.map +1 -1
  40. package/dist/OrderedQuery.d.ts +15 -22
  41. package/dist/OrderedQuery.d.ts.map +1 -1
  42. package/dist/QueryCtx.d.ts +3 -10
  43. package/dist/QueryCtx.d.ts.map +1 -1
  44. package/dist/QueryInitializer.d.ts +32 -38
  45. package/dist/QueryInitializer.d.ts.map +1 -1
  46. package/dist/QueryRunner.d.ts +7 -14
  47. package/dist/QueryRunner.d.ts.map +1 -1
  48. package/dist/RegisteredConvexFunction.d.ts +1099 -1121
  49. package/dist/RegisteredConvexFunction.d.ts.map +1 -1
  50. package/dist/RegisteredConvexFunction.js +4 -4
  51. package/dist/RegisteredConvexFunction.js.map +1 -1
  52. package/dist/RegisteredFunction.d.ts +46 -64
  53. package/dist/RegisteredFunction.d.ts.map +1 -1
  54. package/dist/RegisteredFunction.js +4 -4
  55. package/dist/RegisteredFunction.js.map +1 -1
  56. package/dist/RegisteredFunctions.d.ts +20 -22
  57. package/dist/RegisteredFunctions.d.ts.map +1 -1
  58. package/dist/RegisteredNodeFunction.d.ts +4 -14
  59. package/dist/RegisteredNodeFunction.d.ts.map +1 -1
  60. package/dist/RegistryItem.d.ts +17 -27
  61. package/dist/RegistryItem.d.ts.map +1 -1
  62. package/dist/Scheduler.d.ts +14 -22
  63. package/dist/Scheduler.d.ts.map +1 -1
  64. package/dist/SchemaToValidator.d.ts +68 -64
  65. package/dist/SchemaToValidator.d.ts.map +1 -1
  66. package/dist/SchemaToValidator.js +2 -2
  67. package/dist/SchemaToValidator.js.map +1 -1
  68. package/dist/StorageActionWriter.d.ts +20 -28
  69. package/dist/StorageActionWriter.d.ts.map +1 -1
  70. package/dist/StorageReader.d.ts +13 -21
  71. package/dist/StorageReader.d.ts.map +1 -1
  72. package/dist/StorageWriter.d.ts +15 -23
  73. package/dist/StorageWriter.d.ts.map +1 -1
  74. package/dist/Table.d.ts +202 -203
  75. package/dist/Table.d.ts.map +1 -1
  76. package/dist/Table.js +2 -2
  77. package/dist/Table.js.map +1 -1
  78. package/dist/TableInfo.d.ts +35 -41
  79. package/dist/TableInfo.d.ts.map +1 -1
  80. package/dist/VectorSearch.d.ts +28 -35
  81. package/dist/VectorSearch.d.ts.map +1 -1
  82. package/dist/index.d.ts +35 -35
  83. package/dist/index.d.ts.map +1 -0
  84. package/dist/internal/utils.d.ts +10 -13
  85. package/dist/internal/utils.d.ts.map +1 -1
  86. package/dist/node.d.ts +2 -2
  87. package/dist/node.d.ts.map +1 -0
  88. package/dist/tsconfig.src.tsbuildinfo +1 -0
  89. package/package.json +4 -12
@@ -1,28 +1,20 @@
1
- import * as Context from "effect/Context";
2
- import { Scheduler as Scheduler$1 } from "convex/server";
3
- import * as Layer from "effect/Layer";
4
- import * as Effect from "effect/Effect";
5
1
  import { Ref } from "@confect/core";
6
- import * as Duration from "effect/Duration";
7
- import * as convex_values0 from "convex/values";
2
+ import type { Scheduler as ConvexScheduler } from "convex/server";
3
+ import * as Context from "effect/Context";
8
4
  import * as DateTime from "effect/DateTime";
9
-
10
- //#region src/Scheduler.d.ts
11
- declare namespace Scheduler_d_exports {
12
- export { Scheduler, layer };
13
- }
14
- declare const Scheduler: Context.Tag<{
15
- runAfter: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(delay: Duration.Duration, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
16
- runAt: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(dateTime: DateTime.DateTime, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
5
+ import * as Duration from "effect/Duration";
6
+ import * as Effect from "effect/Effect";
7
+ import * as Layer from "effect/Layer";
8
+ export declare const Scheduler: Context.Tag<{
9
+ runAfter: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(delay: Duration.Duration, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
10
+ runAt: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(dateTime: DateTime.DateTime, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
17
11
  }, {
18
- runAfter: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(delay: Duration.Duration, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
19
- runAt: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(dateTime: DateTime.DateTime, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
12
+ runAfter: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(delay: Duration.Duration, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
13
+ runAt: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(dateTime: DateTime.DateTime, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
20
14
  }>;
21
- type Scheduler = typeof Scheduler.Identifier;
22
- declare const layer: (scheduler: Scheduler$1) => Layer.Layer<{
23
- runAfter: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(delay: Duration.Duration, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
24
- runAt: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(dateTime: DateTime.DateTime, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
15
+ export type Scheduler = typeof Scheduler.Identifier;
16
+ export declare const layer: (scheduler: ConvexScheduler) => Layer.Layer<{
17
+ runAfter: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(delay: Duration.Duration, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
18
+ runAt: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(dateTime: DateTime.DateTime, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
25
19
  }, never, never>;
26
- //#endregion
27
- export { Scheduler, Scheduler_d_exports, layer };
28
20
  //# sourceMappingURL=Scheduler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Scheduler.d.ts","names":[],"sources":["../src/Scheduler.ts"],"mappings":";;;;;;;;;;;;;cA2Ca,SAAA,EAAS,OAAA,CAAA,GAAA;0BAlCI,GAAA,CAAI,WAAA,GAAc,GAAA,CAAI,SAAA,EAAS,KAAA,EAC9C,QAAA,CAAS,QAAA,EAAQ,GAAA,EACnB,IAAA,KAAI,IAAA,EACA,GAAA,CAAI,YAAA,CAAa,IAAA,MAAK,MAAA,CAAA,MAAA,CAAN,cAAA,CAAM,SAAA;uBAaZ,GAAA,CAAI,WAAA,GAAc,GAAA,CAAI,SAAA,EAAS,QAAA,EACxC,QAAA,CAAS,QAAA,EAAQ,GAAA,EACtB,IAAA,KAAI,IAAA,EACA,GAAA,CAAI,YAAA,CAAa,IAAA,MAAK,MAAA,CAAA,MAAA,CAAN,cAAA,CAAM,SAAA;AAAA;0BAnBT,GAAA,CAAI,WAAA,GAAc,GAAA,CAAI,SAAA,EAAS,KAAA,EAC9C,QAAA,CAAS,QAAA,EAAQ,GAAA,EACnB,IAAA,KAAI,IAAA,EACA,GAAA,CAAI,YAAA,CAAa,IAAA,MAAK,MAAA,CAAA,MAAA,CAAN,cAAA,CAAM,SAAA;uBAaZ,GAAA,CAAI,WAAA,GAAc,GAAA,CAAI,SAAA,EAAS,QAAA,EACxC,QAAA,CAAS,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,CAAC,IAAI,CAAC;YAazB,IAAI,SAAS,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,SAAS,YACxC,QAAQ,CAAC,QAAQ,OACtB,IAAI,WACA,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;;eAnBtB,IAAI,SAAS,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,SAAS,SAC9C,QAAQ,CAAC,QAAQ,OACnB,IAAI,WACA,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;YAazB,IAAI,SAAS,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,SAAS,YACxC,QAAQ,CAAC,QAAQ,OACtB,IAAI,WACA,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;EAiBlC,CAAC;AACF,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,UAAU,CAAC;AAEpD,eAAO,MAAM,KAAK,GAAI,WAAW,eAAe;eAvCnC,IAAI,SAAS,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,SAAS,SAC9C,QAAQ,CAAC,QAAQ,OACnB,IAAI,WACA,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;YAazB,IAAI,SAAS,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,SAAS,YACxC,QAAQ,CAAC,QAAQ,OACtB,IAAI,WACA,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;gBAqBQ,CAAC"}
@@ -1,92 +1,96 @@
1
+ import type { PropertyValidators, Validator, VAny, VArray, VBoolean, VBytes, VFloat64, VId, VInt64, VLiteral, VNull, VObject, VOptional, VRecord, VString, VUnion } from "convex/values";
2
+ import * as Cause from "effect/Cause";
1
3
  import * as Effect from "effect/Effect";
2
4
  import * as Schema from "effect/Schema";
3
- import { PropertyValidators, VAny, VArray, VBoolean, VBytes, VFloat64, VId, VInt64, VLiteral, VNull, VObject, VOptional, VRecord, VString, VUnion, Validator } from "convex/values";
4
- import * as Cause from "effect/Cause";
5
5
  import * as SchemaAST from "effect/SchemaAST";
6
- import * as GenericId$1 from "@confect/core/GenericId";
7
- import * as effect_Types0 from "effect/Types";
8
- import { IsAny, IsOptional, IsRecord, IsRecursive, IsUnion, TypeError, UnionToTuple } from "@confect/core/Types";
9
-
10
- //#region src/SchemaToValidator.d.ts
11
- declare namespace SchemaToValidator_d_exports {
12
- export { EmptyTupleIsNotSupportedError, IndexSignaturesAreNotSupportedError, MixedIndexAndPropertySignaturesAreNotSupportedError, OptionalTupleElementsAreNotSupportedError, ReadonlyRecordValue, ReadonlyValue, TableSchemaToTableValidator, TopLevelMustBeObjectError, TopLevelMustBeObjectOrUnionError, UndefinedOrValueToValidator, UnsupportedPropertySignatureKeyTypeError, UnsupportedSchemaTypeError, ValueToValidator, compileArgsSchema, compileAst, compileReturnsSchema, compileSchema, compileTableSchema, isRecursive };
13
- }
14
- declare const compileArgsSchema: <ConfectValue, ConvexValue>(argsSchema: Schema.Schema<ConfectValue, ConvexValue>) => PropertyValidators;
15
- declare const compileReturnsSchema: <ConfectValue, ConvexValue>(schema: Schema.Schema<ConfectValue, ConvexValue>) => Validator<any, any, any>;
6
+ import * as GenericId from "@confect/core/GenericId";
7
+ import type { IsAny, IsOptional, IsRecord, IsRecursive, IsUnion, TypeError, UnionToTuple } from "@confect/core/Types";
8
+ export declare const compileArgsSchema: <ConfectValue, ConvexValue>(argsSchema: Schema.Schema<ConfectValue, ConvexValue>) => PropertyValidators;
9
+ export declare const compileReturnsSchema: <ConfectValue, ConvexValue>(schema: Schema.Schema<ConfectValue, ConvexValue>) => Validator<any, any, any>;
16
10
  /**
17
11
  * Convert a table `Schema` to a table `Validator`.
18
12
  */
19
- type TableSchemaToTableValidator<TableSchema extends Schema.Schema.AnyNoContext> = ValueToValidator<TableSchema["Encoded"]> extends infer Vd extends VObject<any, any, any, any> | VUnion<any, any, any, any> ? Vd : never;
20
- declare const compileTableSchema: <TableSchema extends Schema.Schema.AnyNoContext>(schema: TableSchema) => TableSchemaToTableValidator<TableSchema>;
21
- type ReadonlyValue = string | number | bigint | boolean | ArrayBuffer | ReadonlyArrayValue | ReadonlyRecordValue | null;
13
+ export type TableSchemaToTableValidator<TableSchema extends Schema.Schema.AnyNoContext> = ValueToValidator<TableSchema["Encoded"]> extends infer Vd extends VObject<any, any, any, any> | VUnion<any, any, any, any> ? Vd : never;
14
+ export declare const compileTableSchema: <TableSchema extends Schema.Schema.AnyNoContext>(schema: TableSchema) => TableSchemaToTableValidator<TableSchema>;
15
+ export type ReadonlyValue = string | number | bigint | boolean | ArrayBuffer | ReadonlyArrayValue | ReadonlyRecordValue | null;
22
16
  type ReadonlyArrayValue = readonly ReadonlyValue[];
23
- type ReadonlyRecordValue = {
24
- readonly [key: string]: ReadonlyValue | undefined;
17
+ export type ReadonlyRecordValue = {
18
+ readonly [key: string]: ReadonlyValue | undefined;
25
19
  };
26
- type MutableValue<T> = T extends ReadonlyArray<infer El> ? MutableValue<El>[] : T extends ReadonlyRecordValue ? { -readonly [K in keyof T]: MutableValue<T[K]> } : T;
27
- type ValueToValidator<Vl> = [Vl] extends [never] ? never : IsAny<Vl> extends true ? VAny : [Vl] extends [null] ? VNull : [Vl] extends [boolean] ? [boolean] extends [Vl] ? VBoolean : VLiteral<Vl> : IsUnion<Vl> extends true ? IsRecursive<Vl> extends true ? VAny : [Vl] extends [ReadonlyValue] ? UnionValueToValidator<Vl> : TypeError<"Provided value is not a valid Convex value", Vl> : [Vl] extends [number] ? [number] extends [Vl] ? VFloat64 : VLiteral<Vl> : [Vl] extends [bigint] ? [bigint] extends [Vl] ? VInt64 : VLiteral<Vl> : [Vl] extends [string] ? Vl extends {
28
- __tableName: infer TableName extends string;
29
- } ? VId<GenericId$1.GenericId<TableName>> : [string] extends [Vl] ? VString : VLiteral<Vl> : [Vl] extends [ArrayBuffer] ? VBytes : IsRecursive<Vl> extends true ? VAny : [Vl] extends [ReadonlyValue] ? Vl extends ReadonlyArray<ReadonlyValue> ? ArrayValueToValidator<Vl> : Vl extends ReadonlyRecordValue ? RecordValueToValidator<Vl> : TypeError<"Unexpected value", Vl> : TypeError<"Provided value is not a valid Convex value", Vl>;
20
+ type MutableValue<T> = T extends ReadonlyArray<infer El> ? MutableValue<El>[] : T extends ReadonlyRecordValue ? {
21
+ -readonly [K in keyof T]: MutableValue<T[K]>;
22
+ } : T;
23
+ export type ValueToValidator<Vl> = [Vl] extends [never] ? never : IsAny<Vl> extends true ? VAny : [Vl] extends [null] ? VNull : [Vl] extends [boolean] ? [boolean] extends [Vl] ? VBoolean : VLiteral<Vl> : IsUnion<Vl> extends true ? IsRecursive<Vl> extends true ? VAny : [Vl] extends [ReadonlyValue] ? UnionValueToValidator<Vl> : TypeError<"Provided value is not a valid Convex value", Vl> : [Vl] extends [number] ? [number] extends [Vl] ? VFloat64 : VLiteral<Vl> : [Vl] extends [bigint] ? [bigint] extends [Vl] ? VInt64 : VLiteral<Vl> : [Vl] extends [string] ? Vl extends {
24
+ __tableName: infer TableName extends string;
25
+ } ? VId<GenericId.GenericId<TableName>> : [string] extends [Vl] ? VString : VLiteral<Vl> : [Vl] extends [ArrayBuffer] ? VBytes : IsRecursive<Vl> extends true ? VAny : [Vl] extends [ReadonlyValue] ? Vl extends ReadonlyArray<ReadonlyValue> ? ArrayValueToValidator<Vl> : Vl extends ReadonlyRecordValue ? RecordValueToValidator<Vl> : TypeError<"Unexpected value", Vl> : TypeError<"Provided value is not a valid Convex value", Vl>;
30
26
  type ArrayValueToValidator<Vl extends ReadonlyArray<ReadonlyValue>> = Vl extends ReadonlyArray<infer El extends ReadonlyValue> ? ValueToValidator<El> extends infer Vd extends Validator<any, any, any> ? VArray<MutableValue<El[]>, Vd> : never : never;
31
- type RecordValueToValidator<Vl> = Vl extends ReadonlyRecordValue ? { -readonly [K in keyof Vl]-?: IsAny<Vl[K]> extends true ? IsOptional<Vl, K> extends true ? VOptional<VAny> : VAny : UndefinedOrValueToValidator<Vl[K]> } extends infer VdRecord extends Record<string, any> ? { -readonly [K in keyof Vl]: undefined extends Vl[K] ? MutableValue<Exclude<Vl[K], undefined>> : MutableValue<Vl[K]> } extends infer VlRecord extends Record<string, any> ? IsRecord<VlRecord> extends true ? VRecord<VlRecord, VString, VdRecord[keyof VdRecord]> : VObject<VlRecord, VdRecord> : never : never : never;
32
- type UndefinedOrValueToValidator<Vl extends ReadonlyValue | undefined> = undefined extends Vl ? [Vl] extends [(infer Val extends ReadonlyValue) | undefined] ? ValueToValidator<Val> extends infer Vd extends Validator<any, "required", any> ? VOptional<Vd> : never : never : [Vl] extends [ReadonlyValue] ? ValueToValidator<Vl> : never;
33
- type UnionValueToValidator<Vl extends ReadonlyValue> = [Vl] extends [ReadonlyValue] ? IsUnion<Vl> extends true ? UnionToTuple<Vl> extends infer VlTuple extends ReadonlyArray<ReadonlyValue> ? ValueTupleToValidatorTuple<VlTuple> extends infer VdTuple extends Validator<any, "required", any>[] ? VUnion<MutableValue<Vl>, VdTuple> : TypeError<"Failed to convert value tuple to validator tuple"> : TypeError<"Failed to convert union to tuple"> : TypeError<"Expected a union of values, but got a single value instead"> : TypeError<"Provided value is not a valid Convex value">;
34
- type ValueTupleToValidatorTuple<VlTuple extends ReadonlyArray<ReadonlyValue>> = VlTuple extends [true, false, ...infer VlRest extends ReadonlyArray<ReadonlyValue>] | [false, true, ...infer VlRest extends ReadonlyArray<ReadonlyValue>] ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends Validator<any, any, any>[] ? [VBoolean<boolean>, ...VdRest] : never : VlTuple extends [infer Vl extends ReadonlyValue, ...infer VlRest extends ReadonlyArray<ReadonlyValue>] ? ValueToValidator<Vl> extends infer Vd extends Validator<any, any, any> ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends Validator<any, "required", any>[] ? [Vd, ...VdRest] : never : never : [];
35
- declare const compileSchema: <T, E>(schema: Schema.Schema<T, E>) => ValueToValidator<(typeof schema)["Encoded"]>;
36
- declare const isRecursive: (ast: SchemaAST.AST) => boolean;
37
- declare const compileAst: (ast: SchemaAST.AST, isOptionalPropertyOfTypeLiteral?: boolean) => Effect.Effect<Validator<any, any, any>, UnsupportedSchemaTypeError | UnsupportedPropertySignatureKeyTypeError | IndexSignaturesAreNotSupportedError | MixedIndexAndPropertySignaturesAreNotSupportedError | OptionalTupleElementsAreNotSupportedError | EmptyTupleIsNotSupportedError>;
38
- declare const TopLevelMustBeObjectError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
39
- readonly _tag: "TopLevelMustBeObjectError";
27
+ type RecordValueToValidator<Vl> = Vl extends ReadonlyRecordValue ? {
28
+ -readonly [K in keyof Vl]-?: IsAny<Vl[K]> extends true ? IsOptional<Vl, K> extends true ? VOptional<VAny> : VAny : UndefinedOrValueToValidator<Vl[K]>;
29
+ } extends infer VdRecord extends Record<string, any> ? {
30
+ -readonly [K in keyof Vl]: undefined extends Vl[K] ? MutableValue<Exclude<Vl[K], undefined>> : MutableValue<Vl[K]>;
31
+ } extends infer VlRecord extends Record<string, any> ? IsRecord<VlRecord> extends true ? VRecord<VlRecord, VString, VdRecord[keyof VdRecord]> : VObject<VlRecord, VdRecord> : never : never : never;
32
+ export type UndefinedOrValueToValidator<Vl extends ReadonlyValue | undefined> = undefined extends Vl ? [Vl] extends [(infer Val extends ReadonlyValue) | undefined] ? ValueToValidator<Val> extends infer Vd extends Validator<any, "required", any> ? VOptional<Vd> : never : never : [Vl] extends [ReadonlyValue] ? ValueToValidator<Vl> : never;
33
+ type UnionValueToValidator<Vl extends ReadonlyValue> = [Vl] extends [
34
+ ReadonlyValue
35
+ ] ? IsUnion<Vl> extends true ? UnionToTuple<Vl> extends infer VlTuple extends ReadonlyArray<ReadonlyValue> ? ValueTupleToValidatorTuple<VlTuple> extends infer VdTuple extends Validator<any, "required", any>[] ? VUnion<MutableValue<Vl>, VdTuple> : TypeError<"Failed to convert value tuple to validator tuple"> : TypeError<"Failed to convert union to tuple"> : TypeError<"Expected a union of values, but got a single value instead"> : TypeError<"Provided value is not a valid Convex value">;
36
+ type ValueTupleToValidatorTuple<VlTuple extends ReadonlyArray<ReadonlyValue>> = VlTuple extends [true, false, ...infer VlRest extends ReadonlyArray<ReadonlyValue>] | [false, true, ...infer VlRest extends ReadonlyArray<ReadonlyValue>] ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends Validator<any, any, any>[] ? [VBoolean<boolean>, ...VdRest] : never : VlTuple extends [
37
+ infer Vl extends ReadonlyValue,
38
+ ...infer VlRest extends ReadonlyArray<ReadonlyValue>
39
+ ] ? ValueToValidator<Vl> extends infer Vd extends Validator<any, any, any> ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends Validator<any, "required", any>[] ? [Vd, ...VdRest] : never : never : [];
40
+ export declare const compileSchema: <T, E>(schema: Schema.Schema<T, E>) => ValueToValidator<(typeof schema)["Encoded"]>;
41
+ export declare const isRecursive: (ast: SchemaAST.AST) => boolean;
42
+ export declare const compileAst: (ast: SchemaAST.AST, isOptionalPropertyOfTypeLiteral?: boolean) => Effect.Effect<Validator<any, any, any>, UnsupportedSchemaTypeError | UnsupportedPropertySignatureKeyTypeError | IndexSignaturesAreNotSupportedError | MixedIndexAndPropertySignaturesAreNotSupportedError | OptionalTupleElementsAreNotSupportedError | EmptyTupleIsNotSupportedError>;
43
+ declare const TopLevelMustBeObjectError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
44
+ readonly _tag: "TopLevelMustBeObjectError";
40
45
  } & Readonly<A>;
41
- declare class TopLevelMustBeObjectError extends TopLevelMustBeObjectError_base {
42
- get message(): string;
46
+ export declare class TopLevelMustBeObjectError extends TopLevelMustBeObjectError_base {
47
+ get message(): string;
43
48
  }
44
- declare const TopLevelMustBeObjectOrUnionError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
45
- readonly _tag: "TopLevelMustBeObjectOrUnionError";
49
+ declare const TopLevelMustBeObjectOrUnionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
50
+ readonly _tag: "TopLevelMustBeObjectOrUnionError";
46
51
  } & Readonly<A>;
47
- declare class TopLevelMustBeObjectOrUnionError extends TopLevelMustBeObjectOrUnionError_base {
48
- get message(): string;
52
+ export declare class TopLevelMustBeObjectOrUnionError extends TopLevelMustBeObjectOrUnionError_base {
53
+ get message(): string;
49
54
  }
50
- declare const UnsupportedPropertySignatureKeyTypeError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
51
- readonly _tag: "UnsupportedPropertySignatureKeyTypeError";
55
+ declare const UnsupportedPropertySignatureKeyTypeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
56
+ readonly _tag: "UnsupportedPropertySignatureKeyTypeError";
52
57
  } & Readonly<A>;
53
- declare class UnsupportedPropertySignatureKeyTypeError extends UnsupportedPropertySignatureKeyTypeError_base<{
54
- readonly propertyKey: number | symbol;
58
+ export declare class UnsupportedPropertySignatureKeyTypeError extends UnsupportedPropertySignatureKeyTypeError_base<{
59
+ readonly propertyKey: number | symbol;
55
60
  }> {
56
- get message(): string;
61
+ get message(): string;
57
62
  }
58
- declare const EmptyTupleIsNotSupportedError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
59
- readonly _tag: "EmptyTupleIsNotSupportedError";
63
+ declare const EmptyTupleIsNotSupportedError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
64
+ readonly _tag: "EmptyTupleIsNotSupportedError";
60
65
  } & Readonly<A>;
61
- declare class EmptyTupleIsNotSupportedError extends EmptyTupleIsNotSupportedError_base {
62
- get message(): string;
66
+ export declare class EmptyTupleIsNotSupportedError extends EmptyTupleIsNotSupportedError_base {
67
+ get message(): string;
63
68
  }
64
- declare const UnsupportedSchemaTypeError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
65
- readonly _tag: "UnsupportedSchemaTypeError";
69
+ declare const UnsupportedSchemaTypeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
70
+ readonly _tag: "UnsupportedSchemaTypeError";
66
71
  } & Readonly<A>;
67
- declare class UnsupportedSchemaTypeError extends UnsupportedSchemaTypeError_base<{
68
- readonly schemaType: SchemaAST.AST["_tag"];
72
+ export declare class UnsupportedSchemaTypeError extends UnsupportedSchemaTypeError_base<{
73
+ readonly schemaType: SchemaAST.AST["_tag"];
69
74
  }> {
70
- get message(): string;
75
+ get message(): string;
71
76
  }
72
- declare const IndexSignaturesAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
73
- readonly _tag: "IndexSignaturesAreNotSupportedError";
77
+ declare const IndexSignaturesAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
78
+ readonly _tag: "IndexSignaturesAreNotSupportedError";
74
79
  } & Readonly<A>;
75
- declare class IndexSignaturesAreNotSupportedError extends IndexSignaturesAreNotSupportedError_base {
76
- get message(): string;
80
+ export declare class IndexSignaturesAreNotSupportedError extends IndexSignaturesAreNotSupportedError_base {
81
+ get message(): string;
77
82
  }
78
- declare const MixedIndexAndPropertySignaturesAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
79
- readonly _tag: "MixedIndexAndPropertySignaturesAreNotSupportedError";
83
+ declare const MixedIndexAndPropertySignaturesAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
84
+ readonly _tag: "MixedIndexAndPropertySignaturesAreNotSupportedError";
80
85
  } & Readonly<A>;
81
- declare class MixedIndexAndPropertySignaturesAreNotSupportedError extends MixedIndexAndPropertySignaturesAreNotSupportedError_base {
82
- get message(): string;
86
+ export declare class MixedIndexAndPropertySignaturesAreNotSupportedError extends MixedIndexAndPropertySignaturesAreNotSupportedError_base {
87
+ get message(): string;
83
88
  }
84
- declare const OptionalTupleElementsAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => Cause.YieldableError & {
85
- readonly _tag: "OptionalTupleElementsAreNotSupportedError";
89
+ declare const OptionalTupleElementsAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
90
+ readonly _tag: "OptionalTupleElementsAreNotSupportedError";
86
91
  } & Readonly<A>;
87
- declare class OptionalTupleElementsAreNotSupportedError extends OptionalTupleElementsAreNotSupportedError_base {
88
- get message(): string;
92
+ export declare class OptionalTupleElementsAreNotSupportedError extends OptionalTupleElementsAreNotSupportedError_base {
93
+ get message(): string;
89
94
  }
90
- //#endregion
91
- export { EmptyTupleIsNotSupportedError, IndexSignaturesAreNotSupportedError, MixedIndexAndPropertySignaturesAreNotSupportedError, OptionalTupleElementsAreNotSupportedError, ReadonlyRecordValue, ReadonlyValue, SchemaToValidator_d_exports, TableSchemaToTableValidator, TopLevelMustBeObjectError, TopLevelMustBeObjectOrUnionError, UndefinedOrValueToValidator, UnsupportedPropertySignatureKeyTypeError, UnsupportedSchemaTypeError, ValueToValidator, compileArgsSchema, compileAst, compileReturnsSchema, compileSchema, compileTableSchema, isRecursive };
95
+ export {};
92
96
  //# sourceMappingURL=SchemaToValidator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaToValidator.d.ts","names":[],"sources":["../src/SchemaToValidator.ts"],"mappings":";;;;;;;;;;;;;cA+Ca,iBAAA,8BACX,UAAA,EAAY,MAAA,CAAO,MAAA,CAAO,YAAA,EAAc,WAAA,MACvC,kBAAA;AAAA,cAkBU,oBAAA,8BACX,MAAA,EAAQ,MAAA,CAAO,MAAA,CAAO,YAAA,EAAc,WAAA,MACnC,SAAA;;;;KAQS,2BAAA,qBACU,MAAA,CAAO,MAAA,CAAO,YAAA,IAElC,gBAAA,CAAiB,WAAA,sCACb,OAAA,uBACA,MAAA,uBACA,EAAA;AAAA,cAGO,kBAAA,uBACS,MAAA,CAAO,MAAA,CAAO,YAAA,EAElC,MAAA,EAAQ,WAAA,KACP,2BAAA,CAA4B,WAAA;AAAA,KAmBnB,aAAA,wCAKR,WAAA,GACA,kBAAA,GACA,mBAAA;AAAA,KAGC,kBAAA,YAA8B,aAAA;AAAA,KAEvB,mBAAA;EAAA,UACA,GAAA,WAAc,aAAA;AAAA;AAAA,KAGrB,YAAA,MACH,CAAA,SAAU,aAAA,aACN,YAAA,CAAa,EAAA,MACb,CAAA,SAAU,mBAAA,2BACgB,CAAA,GAAI,YAAA,CAAa,CAAA,CAAE,CAAA,OAC3C,CAAA;AAAA,KAEI,gBAAA,QAAwB,EAAA,4BAEhC,KAAA,CAAM,EAAA,iBACJ,IAAA,IACC,EAAA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,EAAE,SAAS,CAAC,CACD,CAAC;AAE9C,eAAO,MAAM,WAAW,GAAI,KAAK,SAAS,CAAC,GAAG,KAAG,OAwC9C,CAAC;AAEJ,eAAO,MAAM,UAAU,GACrB,KAAK,SAAS,CAAC,GAAG,EAClB,yCAAuC,KACtC,MAAM,CAAC,MAAM,CACd,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EACtB,0BAA0B,GAC1B,wCAAwC,GACxC,mCAAmC,GACnC,mDAAmD,GACnD,yCAAyC,GACzC,6BAA6B,CA8E1B,CAAC;;;;AA4JR,qBAAa,yBAA0B,SAAQ,8BAE9C;IAEC,IAAa,OAAO,WAEnB;CAEF;;;;AAED,qBAAa,gCAAiC,SAAQ,qCAErD;IAEC,IAAa,OAAO,WAEnB;CAEF;;;;AAED,qBAAa,wCAAyC,SAAQ,8CAE5D;IACA,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;CACvC,CAAC;IAEA,IAAa,OAAO,WAEnB;CAEF;;;;AAED,qBAAa,6BAA8B,SAAQ,kCAElD;IAEC,IAAa,OAAO,WAEnB;CAEF;;;;AAED,qBAAa,0BAA2B,SAAQ,gCAE9C;IACA,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;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"}
@@ -13,7 +13,7 @@ import * as Exit from "effect/Exit";
13
13
  import * as Number from "effect/Number";
14
14
  import * as SchemaAST from "effect/SchemaAST";
15
15
  import * as String from "effect/String";
16
- import * as GenericId$1 from "@confect/core/GenericId";
16
+ import * as GenericId from "@confect/core/GenericId";
17
17
 
18
18
  //#region src/SchemaToValidator.ts
19
19
  var SchemaToValidator_exports = /* @__PURE__ */ __exportAll({
@@ -43,7 +43,7 @@ const compileTableSchema = (schema) => {
43
43
  };
44
44
  const compileSchema = (schema) => runSyncThrow(compileAst(schema.ast));
45
45
  const isRecursive = (ast) => pipe(ast, Match.value, Match.tag("Literal", "BooleanKeyword", "StringKeyword", "NumberKeyword", "BigIntKeyword", "UnknownKeyword", "AnyKeyword", "Declaration", "UniqueSymbol", "SymbolKeyword", "UndefinedKeyword", "VoidKeyword", "NeverKeyword", "Enums", "TemplateLiteral", "ObjectKeyword", "Transformation", () => false), Match.tag("Union", ({ types }) => Array.some(types, (type) => isRecursive(type))), Match.tag("TypeLiteral", ({ propertySignatures }) => Array.some(propertySignatures, ({ type }) => isRecursive(type))), Match.tag("TupleType", ({ elements: optionalElements, rest: elements }) => Array.some(optionalElements, (optionalElement) => isRecursive(optionalElement.type)) || Array.some(elements, (element) => isRecursive(element.type))), Match.tag("Refinement", ({ from }) => isRecursive(from)), Match.tag("Suspend", () => true), Match.exhaustive);
46
- const compileAst = (ast, isOptionalPropertyOfTypeLiteral = false) => 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.when(Match.null, () => v.null()), Match.exhaustive, Effect.succeed)), Match.tag("BooleanKeyword", () => Effect.succeed(v.boolean())), Match.tag("StringKeyword", (stringAst) => GenericId$1.tableName(stringAst).pipe(Option.match({
46
+ const compileAst = (ast, isOptionalPropertyOfTypeLiteral = false) => 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.when(Match.null, () => v.null()), Match.exhaustive, Effect.succeed)), Match.tag("BooleanKeyword", () => Effect.succeed(v.boolean())), Match.tag("StringKeyword", (stringAst) => GenericId.tableName(stringAst).pipe(Option.match({
47
47
  onNone: () => Effect.succeed(v.string()),
48
48
  onSome: (tableName) => Effect.succeed(v.id(tableName))
49
49
  }))), Match.tag("NumberKeyword", () => Effect.succeed(v.float64())), Match.tag("BigIntKeyword", () => Effect.succeed(v.int64())), Match.tag("Union", (unionAst) => handleUnion(unionAst, isOptionalPropertyOfTypeLiteral)), Match.tag("TypeLiteral", (typeLiteralAst) => handleTypeLiteral(typeLiteralAst)), Match.tag("TupleType", (tupleTypeAst) => handleTupleType(tupleTypeAst)), Match.tag("UnknownKeyword", "AnyKeyword", () => Effect.succeed(v.any())), Match.tag("Declaration", (declaration) => Effect.mapBoth(declaration.decodeUnknown(...declaration.typeParameters)(/* @__PURE__ */ new ArrayBuffer(0), {}, declaration), {
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaToValidator.js","names":["GenericId"],"sources":["../src/SchemaToValidator.ts"],"sourcesContent":["import type {\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 VOptional,\n VRecord,\n VString,\n VUnion,\n} from \"convex/values\";\nimport { v } from \"convex/values\";\nimport { pipe } from \"effect/Function\";\nimport type { ParseResult } from \"effect\";\nimport * as Array from \"effect/Array\";\nimport * as Cause from \"effect/Cause\";\nimport * as Data from \"effect/Data\";\nimport * as Effect from \"effect/Effect\";\nimport * as Exit from \"effect/Exit\";\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 \"@confect/core/GenericId\";\nimport type {\n IsAny,\n IsOptional,\n IsRecord,\n IsRecursive,\n IsUnion,\n TypeError,\n UnionToTuple,\n} from \"@confect/core/Types\";\n\n// Args\n\nexport const compileArgsSchema = <ConfectValue, ConvexValue>(\n argsSchema: Schema.Schema<ConfectValue, ConvexValue>,\n): PropertyValidators => {\n const ast = Schema.encodedSchema(argsSchema).ast;\n\n return pipe(\n ast,\n Match.value,\n Match.tag(\"TypeLiteral\", (typeLiteralAst) =>\n Array.isEmptyReadonlyArray(typeLiteralAst.indexSignatures)\n ? handlePropertySignatures(typeLiteralAst)\n : Effect.fail(new IndexSignaturesAreNotSupportedError()),\n ),\n Match.orElse(() => Effect.fail(new TopLevelMustBeObjectError())),\n runSyncThrow,\n );\n};\n\n// Returns\n\nexport const compileReturnsSchema = <ConfectValue, ConvexValue>(\n schema: Schema.Schema<ConfectValue, ConvexValue>,\n): Validator<any, any, any> =>\n runSyncThrow(compileAst(Schema.encodedSchema(schema).ast));\n\n// Table\n\n/**\n * Convert a table `Schema` to a table `Validator`.\n */\nexport type TableSchemaToTableValidator<\n TableSchema extends Schema.Schema.AnyNoContext,\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 = <\n TableSchema extends Schema.Schema.AnyNoContext,\n>(\n schema: TableSchema,\n): TableSchemaToTableValidator<TableSchema> => {\n const ast = Schema.encodedSchema(schema).ast;\n\n return pipe(\n ast,\n Match.value,\n Match.tag(\"TypeLiteral\", ({ indexSignatures }) =>\n Array.isEmptyReadonlyArray(indexSignatures)\n ? (compileAst(ast) as Effect.Effect<any>)\n : Effect.fail(new IndexSignaturesAreNotSupportedError()),\n ),\n Match.tag(\"Union\", (unionAst) => compileAst(unionAst)),\n Match.orElse(() => Effect.fail(new TopLevelMustBeObjectOrUnionError())),\n runSyncThrow,\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<T[K]> }\n : T;\n\nexport type ValueToValidator<Vl> = [Vl] extends [never]\n ? never\n : IsAny<Vl> extends true\n ? VAny\n : [Vl] extends [null]\n ? VNull\n : [Vl] extends [boolean]\n ? [boolean] extends [Vl]\n ? VBoolean\n : VLiteral<Vl>\n : IsUnion<Vl> extends true\n ? IsRecursive<Vl> extends true\n ? VAny\n : [Vl] extends [ReadonlyValue]\n ? UnionValueToValidator<Vl>\n : TypeError<\"Provided value is not a valid Convex value\", Vl>\n : [Vl] extends [number]\n ? [number] extends [Vl]\n ? VFloat64\n : VLiteral<Vl>\n : [Vl] extends [bigint]\n ? [bigint] extends [Vl]\n ? VInt64\n : VLiteral<Vl>\n : [Vl] extends [string]\n ? Vl extends {\n __tableName: infer TableName extends string;\n }\n ? VId<GenericId.GenericId<TableName>>\n : [string] extends [Vl]\n ? VString\n : VLiteral<Vl>\n : [Vl] extends [ArrayBuffer]\n ? VBytes\n : IsRecursive<Vl> extends true\n ? VAny\n : [Vl] extends [ReadonlyValue]\n ? Vl extends ReadonlyArray<ReadonlyValue>\n ? ArrayValueToValidator<Vl>\n : Vl extends ReadonlyRecordValue\n ? RecordValueToValidator<Vl>\n : TypeError<\"Unexpected value\", Vl>\n : TypeError<\n \"Provided value is not a valid Convex value\",\n Vl\n >;\n\ntype ArrayValueToValidator<Vl extends ReadonlyArray<ReadonlyValue>> =\n Vl extends ReadonlyArray<infer El extends ReadonlyValue>\n ? ValueToValidator<El> extends infer Vd extends Validator<any, any, any>\n ? VArray<MutableValue<El[]>, Vd>\n : never\n : never;\n\ntype RecordValueToValidator<Vl> = Vl extends ReadonlyRecordValue\n ? {\n -readonly [K in keyof Vl]-?: IsAny<Vl[K]> extends true\n ? IsOptional<Vl, K> extends true\n ? VOptional<VAny>\n : VAny\n : UndefinedOrValueToValidator<Vl[K]>;\n } extends infer VdRecord extends Record<string, any>\n ? {\n -readonly [K in keyof Vl]: undefined extends Vl[K]\n ? MutableValue<Exclude<Vl[K], undefined>>\n : MutableValue<Vl[K]>;\n } extends infer VlRecord extends Record<string, any>\n ? IsRecord<VlRecord> extends true\n ? VRecord<VlRecord, VString, VdRecord[keyof VdRecord]>\n : VObject<VlRecord, VdRecord>\n : never\n : never\n : never;\n\nexport type UndefinedOrValueToValidator<Vl extends ReadonlyValue | undefined> =\n undefined extends Vl\n ? [Vl] extends [(infer Val extends ReadonlyValue) | undefined]\n ? ValueToValidator<Val> extends infer Vd extends Validator<\n any,\n \"required\",\n any\n >\n ? VOptional<Vd>\n : never\n : never\n : [Vl] extends [ReadonlyValue]\n ? ValueToValidator<Vl>\n : never;\n\ntype UnionValueToValidator<Vl extends ReadonlyValue> = [Vl] extends [\n ReadonlyValue,\n]\n ? IsUnion<Vl> extends true\n ? UnionToTuple<Vl> extends infer VlTuple extends\n ReadonlyArray<ReadonlyValue>\n ? ValueTupleToValidatorTuple<VlTuple> extends infer VdTuple extends\n Validator<any, \"required\", any>[]\n ? VUnion<MutableValue<Vl>, VdTuple>\n : TypeError<\"Failed to convert value tuple to validator tuple\">\n : TypeError<\"Failed to convert union to tuple\">\n : TypeError<\"Expected a union of values, but got a single value instead\">\n : TypeError<\"Provided value is not a valid Convex value\">;\n\ntype ValueTupleToValidatorTuple<VlTuple extends ReadonlyArray<ReadonlyValue>> =\n VlTuple extends\n | [true, false, ...infer VlRest extends ReadonlyArray<ReadonlyValue>]\n | [false, true, ...infer VlRest extends ReadonlyArray<ReadonlyValue>]\n ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends Validator<\n any,\n any,\n any\n >[]\n ? [VBoolean<boolean>, ...VdRest]\n : never\n : VlTuple extends [\n infer Vl extends ReadonlyValue,\n ...infer VlRest extends ReadonlyArray<ReadonlyValue>,\n ]\n ? ValueToValidator<Vl> extends infer Vd extends Validator<any, any, any>\n ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends\n Validator<any, \"required\", any>[]\n ? [Vd, ...VdRest]\n : never\n : never\n : [];\n\nexport const compileSchema = <T, E>(\n schema: Schema.Schema<T, E>,\n): ValueToValidator<(typeof schema)[\"Encoded\"]> =>\n runSyncThrow(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 \"BooleanKeyword\",\n \"StringKeyword\",\n \"NumberKeyword\",\n \"BigIntKeyword\",\n \"UnknownKeyword\",\n \"AnyKeyword\",\n \"Declaration\",\n \"UniqueSymbol\",\n \"SymbolKeyword\",\n \"UndefinedKeyword\",\n \"VoidKeyword\",\n \"NeverKeyword\",\n \"Enums\",\n \"TemplateLiteral\",\n \"ObjectKeyword\",\n \"Transformation\",\n () => false,\n ),\n Match.tag(\"Union\", ({ types }) =>\n Array.some(types, (type) => isRecursive(type)),\n ),\n Match.tag(\"TypeLiteral\", ({ propertySignatures }) =>\n Array.some(propertySignatures, ({ type }) => isRecursive(type)),\n ),\n Match.tag(\n \"TupleType\",\n ({ elements: optionalElements, rest: elements }) =>\n Array.some(optionalElements, (optionalElement) =>\n isRecursive(optionalElement.type),\n ) || Array.some(elements, (element) => isRecursive(element.type)),\n ),\n Match.tag(\"Refinement\", ({ from }) => isRecursive(from)),\n Match.tag(\"Suspend\", () => true),\n Match.exhaustive,\n );\n\nexport const compileAst = (\n ast: SchemaAST.AST,\n isOptionalPropertyOfTypeLiteral = false,\n): Effect.Effect<\n Validator<any, any, any>,\n | UnsupportedSchemaTypeError\n | UnsupportedPropertySignatureKeyTypeError\n | IndexSignaturesAreNotSupportedError\n | MixedIndexAndPropertySignaturesAreNotSupportedError\n | OptionalTupleElementsAreNotSupportedError\n | EmptyTupleIsNotSupportedError\n> =>\n 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.when(Match.null, () => v.null()),\n Match.exhaustive,\n Effect.succeed,\n ),\n ),\n Match.tag(\"BooleanKeyword\", () => Effect.succeed(v.boolean())),\n Match.tag(\"StringKeyword\", (stringAst) =>\n GenericId.tableName(stringAst).pipe(\n Option.match({\n onNone: () => Effect.succeed(v.string()),\n onSome: (tableName) => Effect.succeed(v.id(tableName)),\n }),\n ),\n ),\n Match.tag(\"NumberKeyword\", () => Effect.succeed(v.float64())),\n Match.tag(\"BigIntKeyword\", () => Effect.succeed(v.int64())),\n Match.tag(\"Union\", (unionAst) =>\n handleUnion(unionAst, isOptionalPropertyOfTypeLiteral),\n ),\n Match.tag(\"TypeLiteral\", (typeLiteralAst) =>\n handleTypeLiteral(typeLiteralAst),\n ),\n Match.tag(\"TupleType\", (tupleTypeAst) => handleTupleType(tupleTypeAst)),\n Match.tag(\"UnknownKeyword\", \"AnyKeyword\", () =>\n Effect.succeed(v.any()),\n ),\n Match.tag(\"Declaration\", (declaration) =>\n Effect.mapBoth(\n declaration.decodeUnknown(...declaration.typeParameters)(\n new ArrayBuffer(0),\n {},\n declaration,\n ) as Effect.Effect<ArrayBuffer, ParseResult.ParseIssue>,\n {\n onSuccess: () => v.bytes(),\n onFailure: () =>\n new UnsupportedSchemaTypeError({\n schemaType: declaration._tag,\n }),\n },\n ),\n ),\n Match.tag(\"Refinement\", ({ from }) => compileAst(from)),\n Match.tag(\"Suspend\", () => Effect.succeed(v.any())),\n Match.tag(\n \"UniqueSymbol\",\n \"SymbolKeyword\",\n \"UndefinedKeyword\",\n \"VoidKeyword\",\n \"NeverKeyword\",\n \"Enums\",\n \"TemplateLiteral\",\n \"ObjectKeyword\",\n \"Transformation\",\n () =>\n new UnsupportedSchemaTypeError({\n schemaType: ast._tag,\n }),\n ),\n Match.exhaustive,\n );\n\nconst handleUnion = (\n { types: [first, second, ...rest] }: SchemaAST.Union,\n isOptionalPropertyOfTypeLiteral: boolean,\n) =>\n Effect.gen(function* () {\n const validatorEffects = isOptionalPropertyOfTypeLiteral\n ? Array.filterMap([first, second, ...rest], (type) =>\n Predicate.not(SchemaAST.isUndefinedKeyword)(type)\n ? Option.some(compileAst(type))\n : Option.none(),\n )\n : Array.map([first, second, ...rest], (type) => compileAst(type));\n\n const [firstValidator, secondValidator, ...restValidators] =\n yield* Effect.all(validatorEffects);\n\n /* v8 ignore start */\n if (firstValidator === undefined) {\n return yield* Effect.dieMessage(\n \"First validator of union is undefined; this should be impossible.\",\n );\n /* v8 ignore stop */\n } else if (secondValidator === undefined) {\n return firstValidator;\n } else {\n return v.union(firstValidator, secondValidator, ...restValidators);\n }\n });\n\nconst handleTypeLiteral = (typeLiteralAst: SchemaAST.TypeLiteral) =>\n pipe(\n typeLiteralAst.indexSignatures,\n Array.head,\n Option.match({\n onNone: () =>\n Effect.map(handlePropertySignatures(typeLiteralAst), v.object),\n onSome: ({ parameter, type }) =>\n pipe(\n typeLiteralAst.propertySignatures,\n Array.head,\n Option.match({\n onNone: () =>\n Effect.map(\n Effect.all({\n parameter_: compileAst(parameter),\n type_: compileAst(type),\n }),\n ({ parameter_, type_ }) => v.record(parameter_, type_),\n ),\n onSome: () =>\n Effect.fail(\n new MixedIndexAndPropertySignaturesAreNotSupportedError(),\n ),\n }),\n ),\n }),\n );\n\nconst handleTupleType = ({ elements, rest }: SchemaAST.TupleType) =>\n Effect.gen(function* () {\n const restValidator = pipe(\n rest,\n Array.head,\n Option.map(({ type }) => compileAst(type)),\n Effect.flatten,\n );\n\n const [f, s, ...r] = elements;\n\n const elementToValidator = ({ type, isOptional }: SchemaAST.OptionalType) =>\n Effect.if(isOptional, {\n onTrue: () =>\n Effect.fail(new OptionalTupleElementsAreNotSupportedError()),\n onFalse: () => compileAst(type),\n });\n\n const arrayItemsValidator = yield* f === undefined\n ? pipe(\n restValidator,\n Effect.catchTag(\"NoSuchElementException\", () =>\n Effect.fail(new EmptyTupleIsNotSupportedError()),\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 = (typeLiteralAst: SchemaAST.TypeLiteral) =>\n pipe(\n typeLiteralAst.propertySignatures,\n Effect.forEach(({ type, name, isOptional }) => {\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);\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\nconst runSyncThrow = <A, E>(effect: Effect.Effect<A, E>) =>\n pipe(\n effect,\n Effect.runSyncExit,\n Exit.match({\n onSuccess: (validator) => validator,\n onFailure: (cause) => {\n throw Cause.squash(cause);\n },\n }),\n );\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 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,eACuB;CACvB,MAAM,MAAM,OAAO,cAAc,WAAW,CAAC;AAE7C,QAAO,KACL,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AS,gCACd,KACE,6BACA,MAAM,OACJ,EAAE,GACD,KAAK,EAAE,cAAc,iBAAiB;EACpC,eAAe;CAChB,GAAG;CACJ,EACF,EACD,OAAO,QACR,CACF,CACF;AAIH,MAAM,gBAAsB,WAC1B,KACE,QACA,OAAO,aACP,KAAK,MAAM;CACT,YAAY,cAAc;CAC1B,YAAY,UAAU;AACpB,QAAM,MAAM,OAAO,MAAM;;CAE5B,CAAC,CACH;AAEH,IAAa,4BAAb,cAA+C,KAAK,YAClD,4BACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,mCAAb,cAAsD,KAAK,YACzD,mCACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,2CAAb,cAA8D,KAAK,YACjE,2CACD,CAEE;;CAED,IAAa,UAAU;AACrB,SAAO,mCAAmC,KAAK,YAAY,UAAU,CAAC,0BAA0B,OAAO,KAAK,YAAY;;;AAK5H,IAAa,gCAAb,cAAmD,KAAK,YACtD,gCACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,6BAAb,cAAgD,KAAK,YACnD,6BACD,CAEE;;CAED,IAAa,UAAU;AACrB,SAAO,4BAA4B,KAAK,WAAW;;;AAKvD,IAAa,sCAAb,cAAyD,KAAK,YAC5D,sCACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,sDAAb,cAAyE,KAAK,YAC5E,sDACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,4CAAb,cAA+D,KAAK,YAClE,4CACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO"}
1
+ {"version":3,"file":"SchemaToValidator.js","names":[],"sources":["../src/SchemaToValidator.ts"],"sourcesContent":["import type {\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 VOptional,\n VRecord,\n VString,\n VUnion,\n} from \"convex/values\";\nimport { v } from \"convex/values\";\nimport { pipe } from \"effect/Function\";\nimport type { ParseResult } from \"effect\";\nimport * as Array from \"effect/Array\";\nimport * as Cause from \"effect/Cause\";\nimport * as Data from \"effect/Data\";\nimport * as Effect from \"effect/Effect\";\nimport * as Exit from \"effect/Exit\";\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 \"@confect/core/GenericId\";\nimport type {\n IsAny,\n IsOptional,\n IsRecord,\n IsRecursive,\n IsUnion,\n TypeError,\n UnionToTuple,\n} from \"@confect/core/Types\";\n\n// Args\n\nexport const compileArgsSchema = <ConfectValue, ConvexValue>(\n argsSchema: Schema.Schema<ConfectValue, ConvexValue>,\n): PropertyValidators => {\n const ast = Schema.encodedSchema(argsSchema).ast;\n\n return pipe(\n ast,\n Match.value,\n Match.tag(\"TypeLiteral\", (typeLiteralAst) =>\n Array.isEmptyReadonlyArray(typeLiteralAst.indexSignatures)\n ? handlePropertySignatures(typeLiteralAst)\n : Effect.fail(new IndexSignaturesAreNotSupportedError()),\n ),\n Match.orElse(() => Effect.fail(new TopLevelMustBeObjectError())),\n runSyncThrow,\n );\n};\n\n// Returns\n\nexport const compileReturnsSchema = <ConfectValue, ConvexValue>(\n schema: Schema.Schema<ConfectValue, ConvexValue>,\n): Validator<any, any, any> =>\n runSyncThrow(compileAst(Schema.encodedSchema(schema).ast));\n\n// Table\n\n/**\n * Convert a table `Schema` to a table `Validator`.\n */\nexport type TableSchemaToTableValidator<\n TableSchema extends Schema.Schema.AnyNoContext,\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 = <\n TableSchema extends Schema.Schema.AnyNoContext,\n>(\n schema: TableSchema,\n): TableSchemaToTableValidator<TableSchema> => {\n const ast = Schema.encodedSchema(schema).ast;\n\n return pipe(\n ast,\n Match.value,\n Match.tag(\"TypeLiteral\", ({ indexSignatures }) =>\n Array.isEmptyReadonlyArray(indexSignatures)\n ? (compileAst(ast) as Effect.Effect<any>)\n : Effect.fail(new IndexSignaturesAreNotSupportedError()),\n ),\n Match.tag(\"Union\", (unionAst) => compileAst(unionAst)),\n Match.orElse(() => Effect.fail(new TopLevelMustBeObjectOrUnionError())),\n runSyncThrow,\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<T[K]> }\n : T;\n\nexport type ValueToValidator<Vl> = [Vl] extends [never]\n ? never\n : IsAny<Vl> extends true\n ? VAny\n : [Vl] extends [null]\n ? VNull\n : [Vl] extends [boolean]\n ? [boolean] extends [Vl]\n ? VBoolean\n : VLiteral<Vl>\n : IsUnion<Vl> extends true\n ? IsRecursive<Vl> extends true\n ? VAny\n : [Vl] extends [ReadonlyValue]\n ? UnionValueToValidator<Vl>\n : TypeError<\"Provided value is not a valid Convex value\", Vl>\n : [Vl] extends [number]\n ? [number] extends [Vl]\n ? VFloat64\n : VLiteral<Vl>\n : [Vl] extends [bigint]\n ? [bigint] extends [Vl]\n ? VInt64\n : VLiteral<Vl>\n : [Vl] extends [string]\n ? Vl extends {\n __tableName: infer TableName extends string;\n }\n ? VId<GenericId.GenericId<TableName>>\n : [string] extends [Vl]\n ? VString\n : VLiteral<Vl>\n : [Vl] extends [ArrayBuffer]\n ? VBytes\n : IsRecursive<Vl> extends true\n ? VAny\n : [Vl] extends [ReadonlyValue]\n ? Vl extends ReadonlyArray<ReadonlyValue>\n ? ArrayValueToValidator<Vl>\n : Vl extends ReadonlyRecordValue\n ? RecordValueToValidator<Vl>\n : TypeError<\"Unexpected value\", Vl>\n : TypeError<\n \"Provided value is not a valid Convex value\",\n Vl\n >;\n\ntype ArrayValueToValidator<Vl extends ReadonlyArray<ReadonlyValue>> =\n Vl extends ReadonlyArray<infer El extends ReadonlyValue>\n ? ValueToValidator<El> extends infer Vd extends Validator<any, any, any>\n ? VArray<MutableValue<El[]>, Vd>\n : never\n : never;\n\ntype RecordValueToValidator<Vl> = Vl extends ReadonlyRecordValue\n ? {\n -readonly [K in keyof Vl]-?: IsAny<Vl[K]> extends true\n ? IsOptional<Vl, K> extends true\n ? VOptional<VAny>\n : VAny\n : UndefinedOrValueToValidator<Vl[K]>;\n } extends infer VdRecord extends Record<string, any>\n ? {\n -readonly [K in keyof Vl]: undefined extends Vl[K]\n ? MutableValue<Exclude<Vl[K], undefined>>\n : MutableValue<Vl[K]>;\n } extends infer VlRecord extends Record<string, any>\n ? IsRecord<VlRecord> extends true\n ? VRecord<VlRecord, VString, VdRecord[keyof VdRecord]>\n : VObject<VlRecord, VdRecord>\n : never\n : never\n : never;\n\nexport type UndefinedOrValueToValidator<Vl extends ReadonlyValue | undefined> =\n undefined extends Vl\n ? [Vl] extends [(infer Val extends ReadonlyValue) | undefined]\n ? ValueToValidator<Val> extends infer Vd extends Validator<\n any,\n \"required\",\n any\n >\n ? VOptional<Vd>\n : never\n : never\n : [Vl] extends [ReadonlyValue]\n ? ValueToValidator<Vl>\n : never;\n\ntype UnionValueToValidator<Vl extends ReadonlyValue> = [Vl] extends [\n ReadonlyValue,\n]\n ? IsUnion<Vl> extends true\n ? UnionToTuple<Vl> extends infer VlTuple extends\n ReadonlyArray<ReadonlyValue>\n ? ValueTupleToValidatorTuple<VlTuple> extends infer VdTuple extends\n Validator<any, \"required\", any>[]\n ? VUnion<MutableValue<Vl>, VdTuple>\n : TypeError<\"Failed to convert value tuple to validator tuple\">\n : TypeError<\"Failed to convert union to tuple\">\n : TypeError<\"Expected a union of values, but got a single value instead\">\n : TypeError<\"Provided value is not a valid Convex value\">;\n\ntype ValueTupleToValidatorTuple<VlTuple extends ReadonlyArray<ReadonlyValue>> =\n VlTuple extends\n | [true, false, ...infer VlRest extends ReadonlyArray<ReadonlyValue>]\n | [false, true, ...infer VlRest extends ReadonlyArray<ReadonlyValue>]\n ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends Validator<\n any,\n any,\n any\n >[]\n ? [VBoolean<boolean>, ...VdRest]\n : never\n : VlTuple extends [\n infer Vl extends ReadonlyValue,\n ...infer VlRest extends ReadonlyArray<ReadonlyValue>,\n ]\n ? ValueToValidator<Vl> extends infer Vd extends Validator<any, any, any>\n ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends\n Validator<any, \"required\", any>[]\n ? [Vd, ...VdRest]\n : never\n : never\n : [];\n\nexport const compileSchema = <T, E>(\n schema: Schema.Schema<T, E>,\n): ValueToValidator<(typeof schema)[\"Encoded\"]> =>\n runSyncThrow(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 \"BooleanKeyword\",\n \"StringKeyword\",\n \"NumberKeyword\",\n \"BigIntKeyword\",\n \"UnknownKeyword\",\n \"AnyKeyword\",\n \"Declaration\",\n \"UniqueSymbol\",\n \"SymbolKeyword\",\n \"UndefinedKeyword\",\n \"VoidKeyword\",\n \"NeverKeyword\",\n \"Enums\",\n \"TemplateLiteral\",\n \"ObjectKeyword\",\n \"Transformation\",\n () => false,\n ),\n Match.tag(\"Union\", ({ types }) =>\n Array.some(types, (type) => isRecursive(type)),\n ),\n Match.tag(\"TypeLiteral\", ({ propertySignatures }) =>\n Array.some(propertySignatures, ({ type }) => isRecursive(type)),\n ),\n Match.tag(\n \"TupleType\",\n ({ elements: optionalElements, rest: elements }) =>\n Array.some(optionalElements, (optionalElement) =>\n isRecursive(optionalElement.type),\n ) || Array.some(elements, (element) => isRecursive(element.type)),\n ),\n Match.tag(\"Refinement\", ({ from }) => isRecursive(from)),\n Match.tag(\"Suspend\", () => true),\n Match.exhaustive,\n );\n\nexport const compileAst = (\n ast: SchemaAST.AST,\n isOptionalPropertyOfTypeLiteral = false,\n): Effect.Effect<\n Validator<any, any, any>,\n | UnsupportedSchemaTypeError\n | UnsupportedPropertySignatureKeyTypeError\n | IndexSignaturesAreNotSupportedError\n | MixedIndexAndPropertySignaturesAreNotSupportedError\n | OptionalTupleElementsAreNotSupportedError\n | EmptyTupleIsNotSupportedError\n> =>\n 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.when(Match.null, () => v.null()),\n Match.exhaustive,\n Effect.succeed,\n ),\n ),\n Match.tag(\"BooleanKeyword\", () => Effect.succeed(v.boolean())),\n Match.tag(\"StringKeyword\", (stringAst) =>\n GenericId.tableName(stringAst).pipe(\n Option.match({\n onNone: () => Effect.succeed(v.string()),\n onSome: (tableName) => Effect.succeed(v.id(tableName)),\n }),\n ),\n ),\n Match.tag(\"NumberKeyword\", () => Effect.succeed(v.float64())),\n Match.tag(\"BigIntKeyword\", () => Effect.succeed(v.int64())),\n Match.tag(\"Union\", (unionAst) =>\n handleUnion(unionAst, isOptionalPropertyOfTypeLiteral),\n ),\n Match.tag(\"TypeLiteral\", (typeLiteralAst) =>\n handleTypeLiteral(typeLiteralAst),\n ),\n Match.tag(\"TupleType\", (tupleTypeAst) => handleTupleType(tupleTypeAst)),\n Match.tag(\"UnknownKeyword\", \"AnyKeyword\", () =>\n Effect.succeed(v.any()),\n ),\n Match.tag(\"Declaration\", (declaration) =>\n Effect.mapBoth(\n declaration.decodeUnknown(...declaration.typeParameters)(\n new ArrayBuffer(0),\n {},\n declaration,\n ) as Effect.Effect<ArrayBuffer, ParseResult.ParseIssue>,\n {\n onSuccess: () => v.bytes(),\n onFailure: () =>\n new UnsupportedSchemaTypeError({\n schemaType: declaration._tag,\n }),\n },\n ),\n ),\n Match.tag(\"Refinement\", ({ from }) => compileAst(from)),\n Match.tag(\"Suspend\", () => Effect.succeed(v.any())),\n Match.tag(\n \"UniqueSymbol\",\n \"SymbolKeyword\",\n \"UndefinedKeyword\",\n \"VoidKeyword\",\n \"NeverKeyword\",\n \"Enums\",\n \"TemplateLiteral\",\n \"ObjectKeyword\",\n \"Transformation\",\n () =>\n new UnsupportedSchemaTypeError({\n schemaType: ast._tag,\n }),\n ),\n Match.exhaustive,\n );\n\nconst handleUnion = (\n { types: [first, second, ...rest] }: SchemaAST.Union,\n isOptionalPropertyOfTypeLiteral: boolean,\n) =>\n Effect.gen(function* () {\n const validatorEffects = isOptionalPropertyOfTypeLiteral\n ? Array.filterMap([first, second, ...rest], (type) =>\n Predicate.not(SchemaAST.isUndefinedKeyword)(type)\n ? Option.some(compileAst(type))\n : Option.none(),\n )\n : Array.map([first, second, ...rest], (type) => compileAst(type));\n\n const [firstValidator, secondValidator, ...restValidators] =\n yield* Effect.all(validatorEffects);\n\n /* v8 ignore start */\n if (firstValidator === undefined) {\n return yield* Effect.dieMessage(\n \"First validator of union is undefined; this should be impossible.\",\n );\n /* v8 ignore stop */\n } else if (secondValidator === undefined) {\n return firstValidator;\n } else {\n return v.union(firstValidator, secondValidator, ...restValidators);\n }\n });\n\nconst handleTypeLiteral = (typeLiteralAst: SchemaAST.TypeLiteral) =>\n pipe(\n typeLiteralAst.indexSignatures,\n Array.head,\n Option.match({\n onNone: () =>\n Effect.map(handlePropertySignatures(typeLiteralAst), v.object),\n onSome: ({ parameter, type }) =>\n pipe(\n typeLiteralAst.propertySignatures,\n Array.head,\n Option.match({\n onNone: () =>\n Effect.map(\n Effect.all({\n parameter_: compileAst(parameter),\n type_: compileAst(type),\n }),\n ({ parameter_, type_ }) => v.record(parameter_, type_),\n ),\n onSome: () =>\n Effect.fail(\n new MixedIndexAndPropertySignaturesAreNotSupportedError(),\n ),\n }),\n ),\n }),\n );\n\nconst handleTupleType = ({ elements, rest }: SchemaAST.TupleType) =>\n Effect.gen(function* () {\n const restValidator = pipe(\n rest,\n Array.head,\n Option.map(({ type }) => compileAst(type)),\n Effect.flatten,\n );\n\n const [f, s, ...r] = elements;\n\n const elementToValidator = ({ type, isOptional }: SchemaAST.OptionalType) =>\n Effect.if(isOptional, {\n onTrue: () =>\n Effect.fail(new OptionalTupleElementsAreNotSupportedError()),\n onFalse: () => compileAst(type),\n });\n\n const arrayItemsValidator = yield* f === undefined\n ? pipe(\n restValidator,\n Effect.catchTag(\"NoSuchElementException\", () =>\n Effect.fail(new EmptyTupleIsNotSupportedError()),\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 = (typeLiteralAst: SchemaAST.TypeLiteral) =>\n pipe(\n typeLiteralAst.propertySignatures,\n Effect.forEach(({ type, name, isOptional }) => {\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);\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\nconst runSyncThrow = <A, E>(effect: Effect.Effect<A, E>) =>\n pipe(\n effect,\n Effect.runSyncExit,\n Exit.match({\n onSuccess: (validator) => validator,\n onFailure: (cause) => {\n throw Cause.squash(cause);\n },\n }),\n );\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 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,eACuB;CACvB,MAAM,MAAM,OAAO,cAAc,WAAW,CAAC;AAE7C,QAAO,KACL,KACA,MAAM,OACN,MAAM,IAAI,gBAAgB,mBACxB,MAAM,qBAAqB,eAAe,gBAAgB,GACtD,yBAAyB,eAAe,GACxC,OAAO,KAAK,IAAI,qCAAqC,CAAC,CAC3D,EACD,MAAM,aAAa,OAAO,KAAK,IAAI,2BAA2B,CAAC,CAAC,EAChE,aACD;;AAKH,MAAa,wBACX,WAEA,aAAa,WAAW,OAAO,cAAc,OAAO,CAAC,IAAI,CAAC;AAgB5D,MAAa,sBAGX,WAC6C;CAC7C,MAAM,MAAM,OAAO,cAAc,OAAO,CAAC;AAEzC,QAAO,KACL,KACA,MAAM,OACN,MAAM,IAAI,gBAAgB,EAAE,sBAC1B,MAAM,qBAAqB,gBAAgB,GACtC,WAAW,IAAI,GAChB,OAAO,KAAK,IAAI,qCAAqC,CAAC,CAC3D,EACD,MAAM,IAAI,UAAU,aAAa,WAAW,SAAS,CAAC,EACtD,MAAM,aAAa,OAAO,KAAK,IAAI,kCAAkC,CAAC,CAAC,EACvE,aACD;;AA0JH,MAAa,iBACX,WAEA,aAAa,WAAW,OAAO,IAAI,CAAC;AAEtC,MAAa,eAAe,QAC1B,KACE,KACA,MAAM,OACN,MAAM,IACJ,WACA,kBACA,iBACA,iB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A4B,KAAK,WAAW;;;AAKvD,IAAa,sCAAb,cAAyD,KAAK,YAC5D,sCACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,sDAAb,cAAyE,KAAK,YAC5E,sDACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,4CAAb,cAA+D,KAAK,YAClE,4CACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO"}
@@ -1,36 +1,28 @@
1
- import { BlobNotFoundError } from "./BlobNotFoundError.js";
2
- import * as effect_Context0 from "effect/Context";
3
- import { StorageActionWriter as StorageActionWriter$1 } from "convex/server";
4
- import * as Layer from "effect/Layer";
1
+ import type { StorageActionWriter as ConvexStorageActionWriter } from "convex/server";
2
+ import type { GenericId } from "convex/values";
5
3
  import * as Effect from "effect/Effect";
6
- import { GenericId } from "convex/values";
7
- import * as effect_Cause0 from "effect/Cause";
8
-
9
- //#region src/StorageActionWriter.d.ts
10
- declare namespace StorageActionWriter_d_exports {
11
- export { StorageActionWriter };
12
- }
13
- declare const StorageActionWriter_base: effect_Context0.TagClass<StorageActionWriter, "@confect/server/StorageActionWriter", {
14
- get: (storageId: GenericId<"_storage">) => Effect.Effect<Blob, BlobNotFoundError, never>;
15
- store: (blob: Blob, options?: {
16
- sha256?: string;
17
- }) => Effect.Effect<GenericId<"_storage">, never, never>;
4
+ import * as Layer from "effect/Layer";
5
+ import { BlobNotFoundError } from "./BlobNotFoundError";
6
+ declare const StorageActionWriter_base: import("effect/Context").TagClass<StorageActionWriter, "@confect/server/StorageActionWriter", {
7
+ get: (storageId: GenericId<"_storage">) => Effect.Effect<Blob, BlobNotFoundError, never>;
8
+ store: (blob: Blob, options?: {
9
+ sha256?: string;
10
+ }) => Effect.Effect<GenericId<"_storage">, never, never>;
18
11
  }> & Effect.Tag.Proxy<StorageActionWriter, {
19
- get: (storageId: GenericId<"_storage">) => Effect.Effect<Blob, BlobNotFoundError, never>;
20
- store: (blob: Blob, options?: {
21
- sha256?: string;
22
- }) => Effect.Effect<GenericId<"_storage">, never, never>;
23
- }> & {
24
- use: <X>(body: (_: {
25
12
  get: (storageId: GenericId<"_storage">) => Effect.Effect<Blob, BlobNotFoundError, never>;
26
13
  store: (blob: Blob, options?: {
27
- sha256?: string;
14
+ sha256?: string;
28
15
  }) => Effect.Effect<GenericId<"_storage">, never, never>;
29
- }) => X) => [X] extends [Effect.Effect<infer A, infer E, infer R>] ? Effect.Effect<A, E, R | StorageActionWriter> : [X] extends [PromiseLike<infer A_1>] ? Effect.Effect<A_1, effect_Cause0.UnknownException, StorageActionWriter> : Effect.Effect<X, never, StorageActionWriter>;
16
+ }> & {
17
+ use: <X>(body: (_: {
18
+ get: (storageId: GenericId<"_storage">) => Effect.Effect<Blob, BlobNotFoundError, never>;
19
+ store: (blob: Blob, options?: {
20
+ sha256?: string;
21
+ }) => Effect.Effect<GenericId<"_storage">, never, never>;
22
+ }) => X) => [X] extends [Effect.Effect<infer A, infer E, infer R>] ? Effect.Effect<A, E, R | StorageActionWriter> : [X] extends [PromiseLike<infer A_1>] ? Effect.Effect<A_1, import("effect/Cause").UnknownException, StorageActionWriter> : Effect.Effect<X, never, StorageActionWriter>;
30
23
  };
31
- declare class StorageActionWriter extends StorageActionWriter_base {
32
- static readonly layer: (storageActionWriter: StorageActionWriter$1) => Layer.Layer<StorageActionWriter, never, never>;
24
+ export declare class StorageActionWriter extends StorageActionWriter_base {
25
+ static readonly layer: (storageActionWriter: ConvexStorageActionWriter) => Layer.Layer<StorageActionWriter, never, never>;
33
26
  }
34
- //#endregion
35
- export { StorageActionWriter, StorageActionWriter_d_exports };
27
+ export {};
36
28
  //# sourceMappingURL=StorageActionWriter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StorageActionWriter.d.ts","names":[],"sources":["../src/StorageActionWriter.ts"],"mappings":";;;;;;;;;;;;cAMwD,wBAAA,EAeL,eAAA,CAAA,QAAA;mBAZhC,SAAA,iBAAqB,MAAA,CAAA,MAAA,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AM,CAAC,QAAQ,CAAC,KAAK,GAAI,qBAAqB,yBAAyB,oDACtB;CAClD"}
@@ -1,27 +1,19 @@
1
- import { BlobNotFoundError } from "./BlobNotFoundError.js";
2
- import * as effect_Context0 from "effect/Context";
3
- import { StorageReader as StorageReader$1 } from "convex/server";
4
- import * as Layer from "effect/Layer";
1
+ import type { StorageReader as ConvexStorageReader } from "convex/server";
2
+ import type { GenericId } from "convex/values";
5
3
  import * as Effect from "effect/Effect";
6
- import { GenericId } from "convex/values";
7
- import * as effect_Cause0 from "effect/Cause";
8
-
9
- //#region src/StorageReader.d.ts
10
- declare namespace StorageReader_d_exports {
11
- export { StorageReader };
12
- }
13
- declare const StorageReader_base: effect_Context0.TagClass<StorageReader, "@confect/server/StorageReader", {
14
- getUrl: (storageId: GenericId<"_storage">) => Effect.Effect<URL, BlobNotFoundError, never>;
4
+ import * as Layer from "effect/Layer";
5
+ import { BlobNotFoundError } from "./BlobNotFoundError";
6
+ declare const StorageReader_base: import("effect/Context").TagClass<StorageReader, "@confect/server/StorageReader", {
7
+ getUrl: (storageId: GenericId<"_storage">) => Effect.Effect<URL, BlobNotFoundError, never>;
15
8
  }> & Effect.Tag.Proxy<StorageReader, {
16
- getUrl: (storageId: GenericId<"_storage">) => Effect.Effect<URL, BlobNotFoundError, never>;
17
- }> & {
18
- use: <X>(body: (_: {
19
9
  getUrl: (storageId: GenericId<"_storage">) => Effect.Effect<URL, BlobNotFoundError, never>;
20
- }) => X) => [X] extends [Effect.Effect<infer A, infer E, infer R>] ? Effect.Effect<A, E, R | StorageReader> : [X] extends [PromiseLike<infer A_1>] ? Effect.Effect<A_1, effect_Cause0.UnknownException, StorageReader> : Effect.Effect<X, never, StorageReader>;
10
+ }> & {
11
+ use: <X>(body: (_: {
12
+ getUrl: (storageId: GenericId<"_storage">) => Effect.Effect<URL, BlobNotFoundError, never>;
13
+ }) => X) => [X] extends [Effect.Effect<infer A, infer E, infer R>] ? Effect.Effect<A, E, R | StorageReader> : [X] extends [PromiseLike<infer A_1>] ? Effect.Effect<A_1, import("effect/Cause").UnknownException, StorageReader> : Effect.Effect<X, never, StorageReader>;
21
14
  };
22
- declare class StorageReader extends StorageReader_base {
23
- static readonly layer: (storageReader: StorageReader$1) => Layer.Layer<StorageReader, never, never>;
15
+ export declare class StorageReader extends StorageReader_base {
16
+ static readonly layer: (storageReader: ConvexStorageReader) => Layer.Layer<StorageReader, never, never>;
24
17
  }
25
- //#endregion
26
- export { StorageReader, StorageReader_d_exports };
18
+ export {};
27
19
  //# sourceMappingURL=StorageReader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StorageReader.d.ts","names":[],"sources":["../src/StorageReader.ts"],"mappings":";;;;;;;;;;;;cAOwD,kBAAA,EAGb,eAAA,CAAA,QAAA;sBAArB,SAAA,iBAAqB,MAAA,CAAA,MAAA,CAAA,GAAA,EAAA,iBAAA;AAAA;sBAArB,SAAA,iBAAqB,MAAA,CAAA,MAAA,CAAA,GAAA,EAAA,iBAAA;AAAA;;wBAArB,SAAA,iBAAqB,MAAA,CAAA,MAAA,CAAA,GAAA,EAAA,iBAAA;EAAA;;cAc9B,aAAA,SAAsB,kBAAA;EAAA,gBAIjB,KAAA,GAAS,aAAA,EAAe,eAAA,KAAmB,KAAA,CAAA,KAAA,CAAA,aAAA;AAAA"}
1
+ {"version":3,"file":"StorageReader.d.ts","sourceRoot":"","sources":["../src/StorageReader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;;wBAGlC,SAAS,CAAC,UAAU,CAAC;;wBAArB,SAAS,CAAC,UAAU,CAAC;;;4BAArB,SAAS,CAAC,UAAU,CAAC;;;AAc3C,qBAAa,aAAc,SAAQ,kBAGhC;IACD,MAAM,CAAC,QAAQ,CAAC,KAAK,GAAI,eAAe,mBAAmB,8CAChB;CAC5C"}