@confect/core 10.0.0-next.20 → 10.0.0-next.22
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/CHANGELOG.md +162 -80
- package/dist/FunctionProvenance.d.ts +5 -6
- package/dist/FunctionProvenance.d.ts.map +1 -1
- package/dist/FunctionProvenance.js +3 -4
- package/dist/FunctionProvenance.js.map +1 -1
- package/dist/FunctionSpec.d.ts +3 -1
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +12 -6
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GroupSpec.d.ts +5 -1
- package/dist/GroupSpec.d.ts.map +1 -1
- package/dist/GroupSpec.js +31 -17
- package/dist/GroupSpec.js.map +1 -1
- package/dist/Identifier.d.ts +1 -1
- package/dist/Identifier.js +1 -1
- package/dist/Identifier.js.map +1 -1
- package/dist/Lazy.d.ts +4 -5
- package/dist/Lazy.d.ts.map +1 -1
- package/dist/Lazy.js +4 -5
- package/dist/Lazy.js.map +1 -1
- package/dist/MiddlewareAttachment.d.ts +171 -0
- package/dist/MiddlewareAttachment.d.ts.map +1 -0
- package/dist/MiddlewareAttachment.js +48 -0
- package/dist/MiddlewareAttachment.js.map +1 -0
- package/dist/MiddlewareSpec.d.ts +35 -23
- package/dist/MiddlewareSpec.d.ts.map +1 -1
- package/dist/MiddlewareSpec.js +1 -0
- package/dist/MiddlewareSpec.js.map +1 -1
- package/dist/PaginationOptions.d.ts +1 -1
- package/dist/PaginationOptions.js +1 -1
- package/dist/PaginationOptions.js.map +1 -1
- package/dist/Ref.d.ts +8 -7
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +11 -9
- package/dist/Ref.js.map +1 -1
- package/dist/Refs.js +1 -1
- package/dist/Refs.js.map +1 -1
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js +4 -2
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/Spec.d.ts +1 -1
- package/dist/Spec.js.map +1 -1
- package/dist/SystemFields.d.ts +3 -4
- package/dist/SystemFields.d.ts.map +1 -1
- package/dist/SystemFields.js +5 -6
- package/dist/SystemFields.js.map +1 -1
- package/dist/Table.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 +10 -10
- package/src/FunctionProvenance.ts +6 -8
- package/src/FunctionSpec.ts +21 -7
- package/src/GroupSpec.ts +74 -26
- package/src/Identifier.ts +1 -1
- package/src/Lazy.ts +4 -5
- package/src/MiddlewareAttachment.ts +106 -0
- package/src/MiddlewareSpec.ts +55 -21
- package/src/PaginationOptions.ts +1 -1
- package/src/Ref.ts +42 -37
- package/src/Refs.ts +1 -1
- package/src/SchemaToValidator.ts +56 -45
- package/src/Spec.ts +1 -1
- package/src/SystemFields.ts +9 -10
- package/src/Table.ts +2 -2
- package/src/index.ts +1 -0
package/dist/GroupSpec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupSpec.js","names":[],"sources":["../src/GroupSpec.ts"],"sourcesContent":["import * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\nimport { validateConfectFunctionIdentifier } from \"./Identifier\";\n\nexport const TypeId = \"~@confect/core/GroupSpec\";\nexport type TypeId = typeof TypeId;\n\nexport const isGroupSpec = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface GroupSpec<\n Runtime extends RuntimeAndFunctionType.Runtime,\n Name_ extends string,\n Functions_ extends FunctionSpec.AnyWithPropsWithRuntime<Runtime> = never,\n // Subgroups may be of any runtime, independent of this group's own runtime: a\n // group is only a namespace for its children, which are otherwise-independent\n // modules. Functions, by contrast, stay homogeneous (a Node group only accepts\n // Node actions) — `addFunction` keeps the `<Runtime>` bound below.\n Groups_ extends AnyWithProps = never,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n> {\n readonly [TypeId]: TypeId;\n readonly runtime: Runtime;\n readonly name: Name_;\n readonly functions: {\n [\n FunctionName in FunctionSpec.Name<\n FunctionSpec.AnyWithPropsWithRuntime<Runtime>\n >\n ]: FunctionSpec.WithName<Functions_, FunctionName>;\n };\n readonly groups: {\n [GroupName in Name<Groups_>]: WithName<Groups_, GroupName>;\n };\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpecs_>;\n readonly \"~Functions\": Functions_;\n readonly \"~Groups\": Groups_;\n\n addFunction<Function extends FunctionSpec.AnyWithPropsWithRuntime<Runtime>>(\n function_: Function &\n MiddlewareSpec.ValidateAddedFunction<Function, MiddlewareSpecs_>,\n ): GroupSpec<\n Runtime,\n Name_,\n Functions_ | Function,\n Groups_,\n MiddlewareSpecs_\n >;\n\n addGroup<Group extends AnyWithProps>(\n group: Group,\n ): GroupSpec<Runtime, Name_, Functions_, Groups_ | Group, MiddlewareSpecs_>;\n\n addGroupAt<const AtName extends string, Group extends AnyWithProps>(\n name: AtName,\n group: Group,\n ): GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_ | NamedAt<Group, AtName>,\n MiddlewareSpecs_\n >;\n\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n middlewareSpec: MiddlewareSpec_ &\n MiddlewareSpec.ValidateAttach<\n MiddlewareSpec_,\n Functions_,\n MiddlewareSpecs_\n >,\n ): GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_,\n MiddlewareSpecs_ | MiddlewareSpec_\n >;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends GroupSpec<\n RuntimeAndFunctionType.Runtime,\n string,\n FunctionSpec.AnyWithProps,\n AnyWithProps,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport interface AnyWithPropsWithRuntime<\n Runtime extends RuntimeAndFunctionType.Runtime,\n> extends GroupSpec<\n Runtime,\n string,\n FunctionSpec.AnyWithPropsWithRuntime<Runtime>,\n AnyWithPropsWithRuntime<Runtime>,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport type Name<Group extends AnyWithProps> = Group[\"name\"];\n\nexport type Functions<Group extends AnyWithProps> = Group[\"~Functions\"];\n\nexport type Groups<Group extends AnyWithProps> = Group[\"~Groups\"];\n\nexport type MiddlewareSpecs<Group extends AnyWithProps> =\n Group[\"middlewareSpecs\"][number];\n\nexport type GroupNames<Group extends AnyWithProps> = [Groups<Group>] extends [\n never,\n]\n ? never\n : Name<Groups<Group>>;\n\nexport type WithName<\n Group extends AnyWithProps,\n Name_ extends Name<Group>,\n> = Extract<Group, { readonly name: Name_ }>;\n\n/** Assigns a segment name to a leaf group created with {@link make} for typing and refs. */\nexport type NamedAt<Group extends Any, Name_ extends string> = Omit<\n Group,\n \"name\"\n> & {\n readonly name: Name_;\n};\n\nexport type AddGroups<\n Group extends AnyWithProps,\n ExtraGroups extends AnyWithProps,\n> =\n Group extends GroupSpec<\n infer Runtime,\n infer Name_,\n infer Functions_,\n infer Groups_,\n infer MiddlewareSpecs_\n >\n ? GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_ | ExtraGroups,\n MiddlewareSpecs_\n >\n : never;\n\nconst Proto = {\n [TypeId]: TypeId,\n\n addFunction<Function extends FunctionSpec.AnyWithProps>(\n this: Any,\n function_: Function,\n ) {\n const this_ = this as AnyWithProps;\n\n const overlapping = function_.middlewareSpecs.find(\n (functionMiddlewareSpec) =>\n this_.middlewareSpecs.some(\n (groupMiddlewareSpec) =>\n groupMiddlewareSpec.key === functionMiddlewareSpec.key,\n ),\n );\n if (overlapping !== undefined) {\n throw new Error(\n `Middleware \"${overlapping.key}\" is attached to both function \"${function_.name}\" and its group`,\n );\n }\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: Record.set(this_.functions, function_.name, function_),\n groups: this_.groups,\n middlewareSpecs: this_.middlewareSpecs,\n });\n },\n\n addGroup<Group extends Any>(this: Any, group: Group) {\n const this_ = this as AnyWithProps;\n const group_ = group as unknown as AnyWithProps;\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: this_.functions,\n groups: Record.set(this_.groups, group_.name, group_),\n middlewareSpecs: this_.middlewareSpecs,\n });\n },\n\n addGroupAt<Group extends Any>(this: Any, name: string, group: Group) {\n const this_ = this as AnyWithProps;\n const group_ = group as unknown as AnyWithProps;\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: this_.functions,\n groups: Record.set(this_.groups, name, withName(name, group_)),\n middlewareSpecs: this_.middlewareSpecs,\n });\n },\n\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n this: Any,\n middlewareSpec: MiddlewareSpec_,\n ) {\n const this_ = this as AnyWithProps;\n\n if (\n this_.middlewareSpecs.some(\n (existing) => existing.key === middlewareSpec.key,\n )\n ) {\n throw new Error(\n `Middleware \"${middlewareSpec.key}\" is already attached to this group`,\n );\n }\n\n for (const function_ of Object.values(this_.functions)) {\n if (\n function_.middlewareSpecs.some(\n (existing) => existing.key === middlewareSpec.key,\n )\n ) {\n throw new Error(\n `Middleware \"${middlewareSpec.key}\" is attached to both function \"${function_.name}\" and its group`,\n );\n }\n }\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: this_.functions,\n groups: this_.groups,\n middlewareSpecs: [...this_.middlewareSpecs, middlewareSpec],\n });\n },\n};\n\nconst makeProto = <\n Runtime extends RuntimeAndFunctionType.Runtime,\n Name_ extends string,\n Functions_ extends FunctionSpec.AnyWithPropsWithRuntime<Runtime>,\n Groups_ extends AnyWithPropsWithRuntime<Runtime>,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,\n>({\n runtime,\n name,\n functions,\n groups,\n middlewareSpecs,\n}: {\n runtime: Runtime;\n name: Name_;\n functions: Record.ReadonlyRecord<string, Functions_>;\n groups: Record.ReadonlyRecord<string, Groups_>;\n middlewareSpecs: ReadonlyArray<MiddlewareSpecs_>;\n}): GroupSpec<Runtime, Name_, Functions_, Groups_, MiddlewareSpecs_> =>\n Object.assign(Object.create(Proto), {\n runtime,\n name,\n functions,\n groups,\n middlewareSpecs,\n }) as GroupSpec<Runtime, Name_, Functions_, Groups_, MiddlewareSpecs_>;\n\nexport const make = (): GroupSpec<\"Convex\", \"\"> =>\n makeProto({\n runtime: \"Convex\",\n name: \"\",\n functions: Record.empty(),\n groups: Record.empty(),\n middlewareSpecs: [],\n });\n\nexport const makeAt = <const Name_ extends string>(\n name: Name_,\n): GroupSpec<\"Convex\", Name_> => {\n validateConfectFunctionIdentifier(name);\n\n return makeProto({\n runtime: \"Convex\",\n name,\n functions: Record.empty(),\n groups: Record.empty(),\n middlewareSpecs: [],\n });\n};\n\nexport const makeNode = (): GroupSpec<\"Node\", \"\"> =>\n makeProto({\n runtime: \"Node\",\n name: \"\",\n functions: Record.empty(),\n groups: Record.empty(),\n middlewareSpecs: [],\n });\n\nexport const makeNodeAt = <const Name_ extends string>(\n name: Name_,\n): GroupSpec<\"Node\", Name_> => {\n validateConfectFunctionIdentifier(name);\n\n return makeProto({\n runtime: \"Node\",\n name,\n functions: Record.empty(),\n groups: Record.empty(),\n middlewareSpecs: [],\n });\n};\n\nexport const withName = <const Name_ extends string>(\n name: Name_,\n group: Any,\n): AnyWithProps => {\n validateConfectFunctionIdentifier(name);\n const group_ = group as AnyWithProps;\n\n if (group_.name === name) {\n return group_;\n }\n\n return makeProto({\n runtime: group_.runtime,\n name,\n functions: group_.functions,\n groups: group_.groups,\n middlewareSpecs: group_.middlewareSpecs,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;AAOA,MAAa,SAAS;AAGtB,MAAa,eAAe,MAC1B,UAAU,YAAY,GAAG,MAAM;AA8IjC,MAAM,QAAQ;EACX,SAAS;CAEV,YAEE,WACA;EACA,MAAM,QAAQ;E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AM;GACd,iBAAiB,CAAC,GAAG,MAAM,iBAAiB,cAAc;EAC5D,CAAC;CACH;AACF;AAEA,MAAM,aAMJ,EACA,SACA,MACA,WACA,QACA,sBAQA,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG;CAClC;CACA;CACA;CACA;CACA;AACF,CAAC;AAEH,MAAa,aACX,UAAU;CACR,SAAS;CACT,MAAM;CACN,WAAW,OAAO,MAAM;CACxB,QAAQ,OAAO,MAAM;CACrB,iBAAiB,CAAC;AACpB,CAAC;AAEH,MAAa,UACX,SAC+B;CAC/B,kCAAkC,IAAI;CAEtC,OAAO,UAAU;EACf,SAAS;EACT;EACA,WAAW,OAAO,MAAM;EACxB,QAAQ,OAAO,MAAM;EACrB,iBAAiB,CAAC;CACpB,CAAC;AACH;AAEA,MAAa,iBACX,UAAU;CACR,SAAS;CACT,MAAM;CACN,WAAW,OAAO,MAAM;CACxB,QAAQ,OAAO,MAAM;CACrB,iBAAiB,CAAC;AACpB,CAAC;AAEH,MAAa,cACX,SAC6B;CAC7B,kCAAkC,IAAI;CAEtC,OAAO,UAAU;EACf,SAAS;EACT;EACA,WAAW,OAAO,MAAM;EACxB,QAAQ,OAAO,MAAM;EACrB,iBAAiB,CAAC;CACpB,CAAC;AACH;AAEA,MAAa,YACX,MACA,UACiB;CACjB,kCAAkC,IAAI;CACtC,MAAM,SAAS;CAEf,IAAI,OAAO,SAAS,MAClB,OAAO;CAGT,OAAO,UAAU;EACf,SAAS,OAAO;EAChB;EACA,WAAW,OAAO;EAClB,QAAQ,OAAO;EACf,iBAAiB,OAAO;CAC1B,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"GroupSpec.js","names":["MiddlewareAttachment.validateAll"],"sources":["../src/GroupSpec.ts"],"sourcesContent":["import * as MiddlewareAttachment from \"./MiddlewareAttachment\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport * as Result from \"effect/Result\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\nimport { validateConfectFunctionIdentifier } from \"./Identifier\";\n\nexport const TypeId = \"~@confect/core/GroupSpec\";\nexport type TypeId = typeof TypeId;\n\nexport const isGroupSpec = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface GroupSpec<\n Runtime extends RuntimeAndFunctionType.Runtime,\n Name_ extends string,\n Functions_ extends FunctionSpec.AnyWithPropsWithRuntime<Runtime> = never,\n // Subgroups may be of any runtime, independent of this group's own runtime: a\n // group is only a namespace for its children, which are otherwise-independent\n // modules. Functions, by contrast, stay homogeneous (a Node group only accepts\n // Node actions)—`addFunction` keeps the `<Runtime>` bound below.\n Groups_ extends AnyWithProps = never,\n MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec = never,\n> {\n readonly [TypeId]: TypeId;\n readonly runtime: Runtime;\n readonly name: Name_;\n readonly functions: {\n [\n FunctionName in FunctionSpec.Name<\n FunctionSpec.AnyWithPropsWithRuntime<Runtime>\n >\n ]: FunctionSpec.WithName<Functions_, FunctionName>;\n };\n readonly groups: {\n [GroupName in Name<Groups_>]: WithName<Groups_, GroupName>;\n };\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpecs_>;\n readonly middlewareAttachments: ReadonlyArray<\n MiddlewareAttachment.MiddlewareAttachment<MiddlewareSpecs_>\n >;\n readonly \"~Functions\": Functions_;\n readonly \"~Groups\": Groups_;\n\n addFunction<Function extends FunctionSpec.AnyWithPropsWithRuntime<Runtime>>(\n function_: Function &\n MiddlewareSpec.ValidateAddedFunction<Function, MiddlewareSpecs_>,\n ): GroupSpec<\n Runtime,\n Name_,\n Functions_ | Function,\n Groups_,\n MiddlewareSpecs_\n >;\n\n addGroup<Group extends AnyWithProps>(\n group: Group,\n ): GroupSpec<Runtime, Name_, Functions_, Groups_ | Group, MiddlewareSpecs_>;\n\n addGroupAt<const AtName extends string, Group extends AnyWithProps>(\n name: AtName,\n group: Group,\n ): GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_ | NamedAt<Group, AtName>,\n MiddlewareSpecs_\n >;\n\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n middlewareSpec: MiddlewareSpec_ &\n MiddlewareSpec.ValidateAttach<\n MiddlewareSpec_,\n Functions_,\n MiddlewareSpecs_\n >,\n ...options: MiddlewareAttachment.Args<NoInfer<MiddlewareSpec_>>\n ): GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_,\n MiddlewareSpecs_ | MiddlewareSpec_\n >;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends GroupSpec<\n RuntimeAndFunctionType.Runtime,\n string,\n FunctionSpec.AnyWithProps,\n AnyWithProps,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport interface AnyWithPropsWithRuntime<\n Runtime extends RuntimeAndFunctionType.Runtime,\n> extends GroupSpec<\n Runtime,\n string,\n FunctionSpec.AnyWithPropsWithRuntime<Runtime>,\n AnyWithPropsWithRuntime<Runtime>,\n MiddlewareSpec.AnyMiddlewareSpec\n> {}\n\nexport type Name<Group extends AnyWithProps> = Group[\"name\"];\n\nexport type Functions<Group extends AnyWithProps> = Group[\"~Functions\"];\n\nexport type Groups<Group extends AnyWithProps> = Group[\"~Groups\"];\n\nexport type MiddlewareSpecs<Group extends AnyWithProps> =\n Group[\"middlewareSpecs\"][number];\n\nexport type GroupNames<Group extends AnyWithProps> = [Groups<Group>] extends [\n never,\n]\n ? never\n : Name<Groups<Group>>;\n\nexport type WithName<\n Group extends AnyWithProps,\n Name_ extends Name<Group>,\n> = Extract<Group, { readonly name: Name_ }>;\n\n/** Assigns a segment name to a leaf group created with {@link make} for typing and refs. */\nexport type NamedAt<Group extends Any, Name_ extends string> = Omit<\n Group,\n \"name\"\n> & {\n readonly name: Name_;\n};\n\nexport type AddGroups<\n Group extends AnyWithProps,\n ExtraGroups extends AnyWithProps,\n> =\n Group extends GroupSpec<\n infer Runtime,\n infer Name_,\n infer Functions_,\n infer Groups_,\n infer MiddlewareSpecs_\n >\n ? GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_ | ExtraGroups,\n MiddlewareSpecs_\n >\n : never;\n\nconst Proto = {\n [TypeId]: TypeId,\n\n get middlewareSpecs() {\n return this.middlewareAttachments.map(({ spec }) => spec);\n },\n\n addFunction<Function extends FunctionSpec.AnyWithProps>(\n this: Any,\n function_: Function,\n ) {\n const this_ = this as AnyWithProps;\n\n const overlapping = function_.middlewareAttachments.find(\n ({ spec: functionMiddlewareSpec }) =>\n !(\"options\" in functionMiddlewareSpec) &&\n this_.middlewareAttachments.some(\n ({ spec: groupMiddlewareSpec }) =>\n groupMiddlewareSpec.key === functionMiddlewareSpec.key,\n ),\n );\n if (overlapping !== undefined) {\n throw new Error(\n `Middleware \"${overlapping.spec.key}\" is attached to both function \"${function_.name}\" and its group`,\n );\n }\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: Record.set(this_.functions, function_.name, function_),\n groups: this_.groups,\n middlewareAttachments: this_.middlewareAttachments,\n });\n },\n\n addGroup<Group extends Any>(this: Any, group: Group) {\n const this_ = this as AnyWithProps;\n const group_ = group as unknown as AnyWithProps;\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: this_.functions,\n groups: Record.set(this_.groups, group_.name, group_),\n middlewareAttachments: this_.middlewareAttachments,\n });\n },\n\n addGroupAt<Group extends Any>(this: Any, name: string, group: Group) {\n const this_ = this as AnyWithProps;\n const group_ = group as unknown as AnyWithProps;\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: this_.functions,\n groups: Record.set(this_.groups, name, withName(name, group_)),\n middlewareAttachments: this_.middlewareAttachments,\n });\n },\n\n middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(\n this: Any,\n middlewareSpec: MiddlewareSpec_,\n ...options: ReadonlyArray<unknown>\n ) {\n const this_ = this as AnyWithProps;\n\n if (\n !(\"options\" in middlewareSpec) &&\n this_.middlewareAttachments.some(\n ({ spec }) => spec.key === middlewareSpec.key,\n )\n ) {\n throw new Error(\n `Middleware \"${middlewareSpec.key}\" is already attached to this group`,\n );\n }\n\n for (const function_ of Object.values(this_.functions)) {\n if (\n !(\"options\" in middlewareSpec) &&\n function_.middlewareAttachments.some(\n ({ spec }) => spec.key === middlewareSpec.key,\n )\n ) {\n throw new Error(\n `Middleware \"${middlewareSpec.key}\" is attached to both function \"${function_.name}\" and its group`,\n );\n }\n }\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: this_.functions,\n groups: this_.groups,\n middlewareAttachments: [\n ...this_.middlewareAttachments,\n { spec: middlewareSpec, options: options[0] },\n ],\n });\n },\n} satisfies ThisType<AnyWithProps>;\n\nconst makeProto = <\n Runtime extends RuntimeAndFunctionType.Runtime,\n Name_ extends string,\n Functions_ extends FunctionSpec.AnyWithPropsWithRuntime<Runtime>,\n Groups_ extends AnyWithPropsWithRuntime<Runtime>,\n MiddlewareAttachments_ extends\n ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>,\n>({\n runtime,\n name,\n functions,\n groups,\n middlewareAttachments,\n}: {\n runtime: Runtime;\n name: Name_;\n functions: Record.ReadonlyRecord<string, Functions_>;\n groups: Record.ReadonlyRecord<string, Groups_>;\n middlewareAttachments: MiddlewareAttachments_;\n}): GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_,\n MiddlewareAttachments_[number][\"spec\"]\n> =>\n Object.assign(Object.create(Proto), {\n runtime,\n name,\n functions,\n groups,\n middlewareAttachments,\n }) as GroupSpec<\n Runtime,\n Name_,\n Functions_,\n Groups_,\n MiddlewareAttachments_[number][\"spec\"]\n >;\n\nexport const make = (): GroupSpec<\"Convex\", \"\"> =>\n makeProto({\n runtime: \"Convex\",\n name: \"\",\n functions: Record.empty(),\n groups: Record.empty(),\n middlewareAttachments: [],\n });\n\nexport const makeAt = <const Name_ extends string>(\n name: Name_,\n): GroupSpec<\"Convex\", Name_> => {\n validateConfectFunctionIdentifier(name);\n\n return makeProto({\n runtime: \"Convex\",\n name,\n functions: Record.empty(),\n groups: Record.empty(),\n middlewareAttachments: [],\n });\n};\n\nexport const makeNode = (): GroupSpec<\"Node\", \"\"> =>\n makeProto({\n runtime: \"Node\",\n name: \"\",\n functions: Record.empty(),\n groups: Record.empty(),\n middlewareAttachments: [],\n });\n\nexport const makeNodeAt = <const Name_ extends string>(\n name: Name_,\n): GroupSpec<\"Node\", Name_> => {\n validateConfectFunctionIdentifier(name);\n\n return makeProto({\n runtime: \"Node\",\n name,\n functions: Record.empty(),\n groups: Record.empty(),\n middlewareAttachments: [],\n });\n};\n\nexport const withName = <const Name_ extends string>(\n name: Name_,\n group: Any,\n): AnyWithProps => {\n validateConfectFunctionIdentifier(name);\n const group_ = group as AnyWithProps;\n\n if (group_.name === name) {\n return group_;\n }\n\n return makeProto({\n runtime: group_.runtime,\n name,\n functions: group_.functions,\n groups: group_.groups,\n middlewareAttachments: group_.middlewareAttachments,\n });\n};\n\nexport const validateMiddleware = (\n group: AnyWithProps,\n): Result.Result<void, MiddlewareAttachment.ValidationError> =>\n Result.gen(function* () {\n yield* MiddlewareAttachment.validateAll(\n group.middlewareAttachments,\n `group \"${group.name}\"`,\n );\n for (const function_ of Object.values(group.functions)) {\n yield* MiddlewareAttachment.validateAll(\n [...group.middlewareAttachments, ...function_.middlewareAttachments],\n `function \"${function_.name}\"`,\n );\n }\n for (const child of Object.values(group.groups))\n yield* validateMiddleware(child);\n });\n"],"mappings":";;;;;;;;;;;;;;;;;AASA,MAAa,SAAS;AAGtB,MAAa,eAAe,MAC1B,UAAU,YAAY,GAAG,MAAM;AAkJjC,MAAM,QAAQ;EACX,SAAS;CAEV,IAAI,kBAAkB;EACpB,OAAO,KAAK,sBAAsB,KAAK,EAAE,WAAW,IAAI;CAC1D;CAEA,YAEE,WACA;EACA,MAAM,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,MAAM,KAAK,EACvB;CACA,KAAK,MAAM,aAAa,OAAO,OAAO,MAAM,SAAS,GACnD,OAAOA,YACL,CAAC,GAAG,MAAM,uBAAuB,GAAG,UAAU,qBAAqB,GACnE,aAAa,UAAU,KAAK,EAC9B;CAEF,KAAK,MAAM,SAAS,OAAO,OAAO,MAAM,MAAM,GAC5C,OAAO,mBAAmB,KAAK;AACnC,CAAC"}
|
package/dist/Identifier.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const validateConfectFunctionIdentifier: (identifier: string) =>
|
|
|
4
4
|
* as a `confect/tables/<identifier>.ts` filename).
|
|
5
5
|
*
|
|
6
6
|
* Rules:
|
|
7
|
-
* - Must match `/^[A-Za-z][A-Za-z0-9_]
|
|
7
|
+
* - Must match `/^[A-Za-z][A-Za-z0-9_]*$/`—letter-leading, alphanumeric plus
|
|
8
8
|
* underscore. No `$` (not a valid Convex table name character); no leading
|
|
9
9
|
* `_` (Convex reserves `_<name>` for its system tables).
|
|
10
10
|
* - Must not be a reserved JavaScript identifier, so the name can also be used
|
package/dist/Identifier.js
CHANGED
|
@@ -74,7 +74,7 @@ const validateConfectFunctionIdentifier = (identifier) => {
|
|
|
74
74
|
* as a `confect/tables/<identifier>.ts` filename).
|
|
75
75
|
*
|
|
76
76
|
* Rules:
|
|
77
|
-
* - Must match `/^[A-Za-z][A-Za-z0-9_]
|
|
77
|
+
* - Must match `/^[A-Za-z][A-Za-z0-9_]*$/`—letter-leading, alphanumeric plus
|
|
78
78
|
* underscore. No `$` (not a valid Convex table name character); no leading
|
|
79
79
|
* `_` (Convex reserves `_<name>` for its system tables).
|
|
80
80
|
* - Must not be a reserved JavaScript identifier, so the name can also be used
|
package/dist/Identifier.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Identifier.js","names":[],"sources":["../src/Identifier.ts"],"sourcesContent":["const RESERVED_JS_IDENTIFIERS = new Set([\n // Reserved keywords\n \"break\",\n \"case\",\n \"catch\",\n \"class\",\n \"const\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"else\",\n \"export\",\n \"extends\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"import\",\n \"in\",\n \"instanceof\",\n \"new\",\n \"return\",\n \"super\",\n \"switch\",\n \"this\",\n \"throw\",\n \"try\",\n \"typeof\",\n \"var\",\n \"void\",\n \"while\",\n \"with\",\n \"yield\",\n // Future reserved keywords\n \"await\",\n \"enum\",\n \"implements\",\n \"interface\",\n \"let\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"static\",\n // Literal values that cannot be reassigned\n \"null\",\n \"true\",\n \"false\",\n // Global objects that shouldn't be shadowed\n \"undefined\",\n]);\n\nconst RESERVED_CONVEX_FILE_NAMES = new Set([\"schema\", \"http\", \"crons\"]);\n\nconst jsIdentifierRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\n\n// Stricter than `jsIdentifierRegex`: tables cannot start with `_` (Convex\n// reserves leading underscores for system tables) or `$` (Convex's table\n// naming grammar does not accept it). Letters/digits/underscore only,\n// letter-leading.\nconst tableNameRegex = /^[a-zA-Z][a-zA-Z0-9_]*$/;\n\nconst isReservedJsIdentifier = (identifier: string) =>\n RESERVED_JS_IDENTIFIERS.has(identifier);\n\nconst isReservedConvexFileName = (fileName: string) =>\n RESERVED_CONVEX_FILE_NAMES.has(fileName);\n\nconst matchesJsIdentifierPattern = (identifier: string) =>\n jsIdentifierRegex.test(identifier);\n\nconst matchesTableNamePattern = (identifier: string) =>\n tableNameRegex.test(identifier);\n\nexport const validateConfectFunctionIdentifier = (identifier: string) => {\n if (!matchesJsIdentifierPattern(identifier)) {\n throw new Error(\n `Expected a valid Confect function identifier, but received: \"${identifier}\". Valid identifiers must start with a letter, underscore, or dollar sign, and can only contain letters, numbers, underscores, or dollar signs.`,\n );\n }\n\n if (isReservedJsIdentifier(identifier)) {\n throw new Error(\n `Expected a valid Confect function identifier, but received: \"${identifier}\". \"${identifier}\" is a reserved JavaScript identifier.`,\n );\n }\n\n if (isReservedConvexFileName(identifier)) {\n throw new Error(\n `Expected a valid Confect function identifier, but received: \"${identifier}\". \"${identifier}\" is a reserved Convex file name.`,\n );\n }\n};\n\n/**\n * Validate that `identifier` is suitable as a Convex table name (and, equivalently,\n * as a `confect/tables/<identifier>.ts` filename).\n *\n * Rules:\n * - Must match `/^[A-Za-z][A-Za-z0-9_]
|
|
1
|
+
{"version":3,"file":"Identifier.js","names":[],"sources":["../src/Identifier.ts"],"sourcesContent":["const RESERVED_JS_IDENTIFIERS = new Set([\n // Reserved keywords\n \"break\",\n \"case\",\n \"catch\",\n \"class\",\n \"const\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"else\",\n \"export\",\n \"extends\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"import\",\n \"in\",\n \"instanceof\",\n \"new\",\n \"return\",\n \"super\",\n \"switch\",\n \"this\",\n \"throw\",\n \"try\",\n \"typeof\",\n \"var\",\n \"void\",\n \"while\",\n \"with\",\n \"yield\",\n // Future reserved keywords\n \"await\",\n \"enum\",\n \"implements\",\n \"interface\",\n \"let\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"static\",\n // Literal values that cannot be reassigned\n \"null\",\n \"true\",\n \"false\",\n // Global objects that shouldn't be shadowed\n \"undefined\",\n]);\n\nconst RESERVED_CONVEX_FILE_NAMES = new Set([\"schema\", \"http\", \"crons\"]);\n\nconst jsIdentifierRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\n\n// Stricter than `jsIdentifierRegex`: tables cannot start with `_` (Convex\n// reserves leading underscores for system tables) or `$` (Convex's table\n// naming grammar does not accept it). Letters/digits/underscore only,\n// letter-leading.\nconst tableNameRegex = /^[a-zA-Z][a-zA-Z0-9_]*$/;\n\nconst isReservedJsIdentifier = (identifier: string) =>\n RESERVED_JS_IDENTIFIERS.has(identifier);\n\nconst isReservedConvexFileName = (fileName: string) =>\n RESERVED_CONVEX_FILE_NAMES.has(fileName);\n\nconst matchesJsIdentifierPattern = (identifier: string) =>\n jsIdentifierRegex.test(identifier);\n\nconst matchesTableNamePattern = (identifier: string) =>\n tableNameRegex.test(identifier);\n\nexport const validateConfectFunctionIdentifier = (identifier: string) => {\n if (!matchesJsIdentifierPattern(identifier)) {\n throw new Error(\n `Expected a valid Confect function identifier, but received: \"${identifier}\". Valid identifiers must start with a letter, underscore, or dollar sign, and can only contain letters, numbers, underscores, or dollar signs.`,\n );\n }\n\n if (isReservedJsIdentifier(identifier)) {\n throw new Error(\n `Expected a valid Confect function identifier, but received: \"${identifier}\". \"${identifier}\" is a reserved JavaScript identifier.`,\n );\n }\n\n if (isReservedConvexFileName(identifier)) {\n throw new Error(\n `Expected a valid Confect function identifier, but received: \"${identifier}\". \"${identifier}\" is a reserved Convex file name.`,\n );\n }\n};\n\n/**\n * Validate that `identifier` is suitable as a Convex table name (and, equivalently,\n * as a `confect/tables/<identifier>.ts` filename).\n *\n * Rules:\n * - Must match `/^[A-Za-z][A-Za-z0-9_]*$/`—letter-leading, alphanumeric plus\n * underscore. No `$` (not a valid Convex table name character); no leading\n * `_` (Convex reserves `_<name>` for its system tables).\n * - Must not be a reserved JavaScript identifier, so the name can also be used\n * as a binding name in generated code without escaping.\n */\nexport const validateConfectTableIdentifier = (identifier: string) => {\n if (!matchesTableNamePattern(identifier)) {\n throw new Error(\n `Expected a valid Confect table identifier, but received: \"${identifier}\". Valid table identifiers must start with a letter and can only contain letters, numbers, and underscores. Leading underscores are reserved for Convex system tables.`,\n );\n }\n\n if (isReservedJsIdentifier(identifier)) {\n throw new Error(\n `Expected a valid Confect table identifier, but received: \"${identifier}\". \"${identifier}\" is a reserved JavaScript identifier.`,\n );\n }\n};\n"],"mappings":";;;;;;AAAA,MAAM,0CAA0B,IAAI,IAAI;CAEtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;AACF,CAAC;AAED,MAAM,6CAA6B,IAAI,IAAI;CAAC;CAAU;CAAQ;AAAO,CAAC;AAEtE,MAAM,oBAAoB;AAM1B,MAAM,iBAAiB;AAEvB,MAAM,0BAA0B,eAC9B,wBAAwB,IAAI,UAAU;AAExC,MAAM,4BAA4B,aAChC,2BAA2B,IAAI,QAAQ;AAEzC,MAAM,8BAA8B,eAClC,kBAAkB,KAAK,UAAU;AAEnC,MAAM,2BAA2B,eAC/B,eAAe,KAAK,UAAU;AAEhC,MAAa,qCAAqC,eAAuB;CACvE,IAAI,CAAC,2BAA2B,UAAU,GACxC,MAAM,IAAI,MACR,gEAAgE,WAAW,gJAC7E;CAGF,IAAI,uBAAuB,UAAU,GACnC,MAAM,IAAI,MACR,gEAAgE,WAAW,MAAM,WAAW,uCAC9F;CAGF,IAAI,yBAAyB,UAAU,GACrC,MAAM,IAAI,MACR,gEAAgE,WAAW,MAAM,WAAW,kCAC9F;AAEJ;;;;;;;;;;;;AAaA,MAAa,kCAAkC,eAAuB;CACpE,IAAI,CAAC,wBAAwB,UAAU,GACrC,MAAM,IAAI,MACR,6DAA6D,WAAW,uKAC1E;CAGF,IAAI,uBAAuB,UAAU,GACnC,MAAM,IAAI,MACR,6DAA6D,WAAW,MAAM,WAAW,uCAC3F;AAEJ"}
|
package/dist/Lazy.d.ts
CHANGED
|
@@ -2,20 +2,19 @@
|
|
|
2
2
|
* Install a lazy memoised property on `target`. The first access runs
|
|
3
3
|
* `compute()` and replaces the getter with a plain, non-writable data
|
|
4
4
|
* property whose value is the computed result. Subsequent accesses hit
|
|
5
|
-
* the V8 fast path for own data properties
|
|
6
|
-
* returned reference
|
|
5
|
+
* the V8 fast path for own data properties—no function call, identical
|
|
6
|
+
* returned reference—so first and second-and-subsequent accesses are
|
|
7
7
|
* observably indistinguishable.
|
|
8
8
|
*
|
|
9
9
|
* The replacement property is `enumerable: true` so the lazy property
|
|
10
|
-
* still participates in `Object.keys
|
|
10
|
+
* still participates in `Object.keys`/`JSON.stringify` after it
|
|
11
11
|
* materialises, matching the shape of a plain data property. The property
|
|
12
12
|
* is also `enumerable` before materialising, so presence checks
|
|
13
13
|
* (`"key" in target`, `Object.hasOwn(target, key)`) observe it without
|
|
14
14
|
* forcing the computation.
|
|
15
15
|
*
|
|
16
16
|
* This is the single shared implementation consumed across packages (e.g.
|
|
17
|
-
* `@confect/core`'s lazy `FunctionSpec` schemas and lazy `Table` `Fields`
|
|
18
|
-
* `Doc`), so there is no chance of the two drifting apart.
|
|
17
|
+
* `@confect/core`'s lazy `FunctionSpec` schemas and lazy `Table` `Fields`/`Doc`), so there is no chance of the two drifting apart.
|
|
19
18
|
*/
|
|
20
19
|
export declare const defineProperty: <T extends object, K extends PropertyKey>(target: T, key: K, compute: () => unknown) => void;
|
|
21
20
|
//# sourceMappingURL=Lazy.d.ts.map
|
package/dist/Lazy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lazy.d.ts","sourceRoot":"","sources":["../src/Lazy.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Lazy.d.ts","sourceRoot":"","sources":["../src/Lazy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,WAAW,UAC5D,CAAC,OACJ,CAAC,WACG,MAAM,OAAO,KACrB,IAeF,CAAC"}
|
package/dist/Lazy.js
CHANGED
|
@@ -5,20 +5,19 @@ var Lazy_exports = /* @__PURE__ */ __exportAll({ defineProperty: () => definePro
|
|
|
5
5
|
* Install a lazy memoised property on `target`. The first access runs
|
|
6
6
|
* `compute()` and replaces the getter with a plain, non-writable data
|
|
7
7
|
* property whose value is the computed result. Subsequent accesses hit
|
|
8
|
-
* the V8 fast path for own data properties
|
|
9
|
-
* returned reference
|
|
8
|
+
* the V8 fast path for own data properties—no function call, identical
|
|
9
|
+
* returned reference—so first and second-and-subsequent accesses are
|
|
10
10
|
* observably indistinguishable.
|
|
11
11
|
*
|
|
12
12
|
* The replacement property is `enumerable: true` so the lazy property
|
|
13
|
-
* still participates in `Object.keys
|
|
13
|
+
* still participates in `Object.keys`/`JSON.stringify` after it
|
|
14
14
|
* materialises, matching the shape of a plain data property. The property
|
|
15
15
|
* is also `enumerable` before materialising, so presence checks
|
|
16
16
|
* (`"key" in target`, `Object.hasOwn(target, key)`) observe it without
|
|
17
17
|
* forcing the computation.
|
|
18
18
|
*
|
|
19
19
|
* This is the single shared implementation consumed across packages (e.g.
|
|
20
|
-
* `@confect/core`'s lazy `FunctionSpec` schemas and lazy `Table` `Fields`
|
|
21
|
-
* `Doc`), so there is no chance of the two drifting apart.
|
|
20
|
+
* `@confect/core`'s lazy `FunctionSpec` schemas and lazy `Table` `Fields`/`Doc`), so there is no chance of the two drifting apart.
|
|
22
21
|
*/
|
|
23
22
|
const defineProperty = (target, key, compute) => {
|
|
24
23
|
Object.defineProperty(target, key, {
|
package/dist/Lazy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Lazy.js","names":[],"sources":["../src/Lazy.ts"],"sourcesContent":["/**\n * Install a lazy memoised property on `target`. The first access runs\n * `compute()` and replaces the getter with a plain, non-writable data\n * property whose value is the computed result. Subsequent accesses hit\n * the V8 fast path for own data properties
|
|
1
|
+
{"version":3,"file":"Lazy.js","names":[],"sources":["../src/Lazy.ts"],"sourcesContent":["/**\n * Install a lazy memoised property on `target`. The first access runs\n * `compute()` and replaces the getter with a plain, non-writable data\n * property whose value is the computed result. Subsequent accesses hit\n * the V8 fast path for own data properties—no function call, identical\n * returned reference—so first and second-and-subsequent accesses are\n * observably indistinguishable.\n *\n * The replacement property is `enumerable: true` so the lazy property\n * still participates in `Object.keys`/`JSON.stringify` after it\n * materialises, matching the shape of a plain data property. The property\n * is also `enumerable` before materialising, so presence checks\n * (`\"key\" in target`, `Object.hasOwn(target, key)`) observe it without\n * forcing the computation.\n *\n * This is the single shared implementation consumed across packages (e.g.\n * `@confect/core`'s lazy `FunctionSpec` schemas and lazy `Table` `Fields`/`Doc`), so there is no chance of the two drifting apart.\n */\nexport const defineProperty = <T extends object, K extends PropertyKey>(\n target: T,\n key: K,\n compute: () => unknown,\n): void => {\n Object.defineProperty(target, key, {\n configurable: true,\n enumerable: true,\n get(this: T) {\n const value = compute();\n Object.defineProperty(this, key, {\n value,\n writable: false,\n enumerable: true,\n configurable: false,\n });\n return value;\n },\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,kBACX,QACA,KACA,YACS;CACT,OAAO,eAAe,QAAQ,KAAK;EACjC,cAAc;EACd,YAAY;EACZ,MAAa;GACX,MAAM,QAAQ,QAAQ;GACtB,OAAO,eAAe,MAAM,KAAK;IAC/B;IACA,UAAU;IACV,YAAY;IACZ,cAAc;GAChB,CAAC;GACD,OAAO;EACT;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import * as Data from "effect/Data";
|
|
2
|
+
import * as Result from "effect/Result";
|
|
3
|
+
import type * as MiddlewareSpec from "./MiddlewareSpec";
|
|
4
|
+
export type MiddlewareAttachment<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec = MiddlewareSpec.AnyMiddlewareSpec> = MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec ? {
|
|
5
|
+
readonly spec: MiddlewareSpec_;
|
|
6
|
+
readonly options: [MiddlewareSpec_["~Options"]] extends [never] ? undefined : MiddlewareSpec.Options<MiddlewareSpec_>;
|
|
7
|
+
} : never;
|
|
8
|
+
export type Args<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec> = [
|
|
9
|
+
MiddlewareSpec_["~Options"]
|
|
10
|
+
] extends [never] ? [] : [options: MiddlewareSpec.Options<MiddlewareSpec_>];
|
|
11
|
+
export type ValidationError = Data.TaggedEnum<{
|
|
12
|
+
InvalidOptions: {
|
|
13
|
+
readonly middlewareKey: string;
|
|
14
|
+
readonly location: string;
|
|
15
|
+
readonly attachmentIndex: number;
|
|
16
|
+
};
|
|
17
|
+
ConflictingSpecs: {
|
|
18
|
+
readonly middlewareKey: string;
|
|
19
|
+
readonly location: string;
|
|
20
|
+
readonly attachmentIndex: number;
|
|
21
|
+
readonly previousIndex: number;
|
|
22
|
+
};
|
|
23
|
+
EquivalentOptions: {
|
|
24
|
+
readonly middlewareKey: string;
|
|
25
|
+
readonly location: string;
|
|
26
|
+
readonly attachmentIndex: number;
|
|
27
|
+
readonly previousIndex: number;
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
export declare const ValidationError: {
|
|
31
|
+
readonly $is: <Tag extends "ConflictingSpecs" | "EquivalentOptions" | "InvalidOptions">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
32
|
+
readonly _tag: "ConflictingSpecs";
|
|
33
|
+
readonly middlewareKey: string;
|
|
34
|
+
readonly location: string;
|
|
35
|
+
readonly attachmentIndex: number;
|
|
36
|
+
readonly previousIndex: number;
|
|
37
|
+
}, {
|
|
38
|
+
readonly _tag: Tag;
|
|
39
|
+
}> | Extract<{
|
|
40
|
+
readonly _tag: "EquivalentOptions";
|
|
41
|
+
readonly middlewareKey: string;
|
|
42
|
+
readonly location: string;
|
|
43
|
+
readonly attachmentIndex: number;
|
|
44
|
+
readonly previousIndex: number;
|
|
45
|
+
}, {
|
|
46
|
+
readonly _tag: Tag;
|
|
47
|
+
}> | Extract<{
|
|
48
|
+
readonly _tag: "InvalidOptions";
|
|
49
|
+
readonly middlewareKey: string;
|
|
50
|
+
readonly location: string;
|
|
51
|
+
readonly attachmentIndex: number;
|
|
52
|
+
}, {
|
|
53
|
+
readonly _tag: Tag;
|
|
54
|
+
}>;
|
|
55
|
+
readonly $match: {
|
|
56
|
+
<Cases extends { readonly [Tag in "ConflictingSpecs" | "EquivalentOptions" | "InvalidOptions"]: (args: Extract<{
|
|
57
|
+
readonly _tag: "ConflictingSpecs";
|
|
58
|
+
readonly middlewareKey: string;
|
|
59
|
+
readonly location: string;
|
|
60
|
+
readonly attachmentIndex: number;
|
|
61
|
+
readonly previousIndex: number;
|
|
62
|
+
} | {
|
|
63
|
+
readonly _tag: "EquivalentOptions";
|
|
64
|
+
readonly middlewareKey: string;
|
|
65
|
+
readonly location: string;
|
|
66
|
+
readonly attachmentIndex: number;
|
|
67
|
+
readonly previousIndex: number;
|
|
68
|
+
} | {
|
|
69
|
+
readonly _tag: "InvalidOptions";
|
|
70
|
+
readonly middlewareKey: string;
|
|
71
|
+
readonly location: string;
|
|
72
|
+
readonly attachmentIndex: number;
|
|
73
|
+
}, {
|
|
74
|
+
readonly _tag: Tag;
|
|
75
|
+
}>) => any; }>(cases: Cases): (value: {
|
|
76
|
+
readonly _tag: "ConflictingSpecs";
|
|
77
|
+
readonly middlewareKey: string;
|
|
78
|
+
readonly location: string;
|
|
79
|
+
readonly attachmentIndex: number;
|
|
80
|
+
readonly previousIndex: number;
|
|
81
|
+
} | {
|
|
82
|
+
readonly _tag: "EquivalentOptions";
|
|
83
|
+
readonly middlewareKey: string;
|
|
84
|
+
readonly location: string;
|
|
85
|
+
readonly attachmentIndex: number;
|
|
86
|
+
readonly previousIndex: number;
|
|
87
|
+
} | {
|
|
88
|
+
readonly _tag: "InvalidOptions";
|
|
89
|
+
readonly middlewareKey: string;
|
|
90
|
+
readonly location: string;
|
|
91
|
+
readonly attachmentIndex: number;
|
|
92
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["ConflictingSpecs" | "EquivalentOptions" | "InvalidOptions"]>>;
|
|
93
|
+
<Cases extends { readonly [Tag in "ConflictingSpecs" | "EquivalentOptions" | "InvalidOptions"]: (args: Extract<{
|
|
94
|
+
readonly _tag: "ConflictingSpecs";
|
|
95
|
+
readonly middlewareKey: string;
|
|
96
|
+
readonly location: string;
|
|
97
|
+
readonly attachmentIndex: number;
|
|
98
|
+
readonly previousIndex: number;
|
|
99
|
+
} | {
|
|
100
|
+
readonly _tag: "EquivalentOptions";
|
|
101
|
+
readonly middlewareKey: string;
|
|
102
|
+
readonly location: string;
|
|
103
|
+
readonly attachmentIndex: number;
|
|
104
|
+
readonly previousIndex: number;
|
|
105
|
+
} | {
|
|
106
|
+
readonly _tag: "InvalidOptions";
|
|
107
|
+
readonly middlewareKey: string;
|
|
108
|
+
readonly location: string;
|
|
109
|
+
readonly attachmentIndex: number;
|
|
110
|
+
}, {
|
|
111
|
+
readonly _tag: Tag;
|
|
112
|
+
}>) => any; }>(value: {
|
|
113
|
+
readonly _tag: "ConflictingSpecs";
|
|
114
|
+
readonly middlewareKey: string;
|
|
115
|
+
readonly location: string;
|
|
116
|
+
readonly attachmentIndex: number;
|
|
117
|
+
readonly previousIndex: number;
|
|
118
|
+
} | {
|
|
119
|
+
readonly _tag: "EquivalentOptions";
|
|
120
|
+
readonly middlewareKey: string;
|
|
121
|
+
readonly location: string;
|
|
122
|
+
readonly attachmentIndex: number;
|
|
123
|
+
readonly previousIndex: number;
|
|
124
|
+
} | {
|
|
125
|
+
readonly _tag: "InvalidOptions";
|
|
126
|
+
readonly middlewareKey: string;
|
|
127
|
+
readonly location: string;
|
|
128
|
+
readonly attachmentIndex: number;
|
|
129
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["ConflictingSpecs" | "EquivalentOptions" | "InvalidOptions"]>>;
|
|
130
|
+
};
|
|
131
|
+
readonly ConflictingSpecs: Data.TaggedEnum.ConstructorFrom<{
|
|
132
|
+
readonly _tag: "ConflictingSpecs";
|
|
133
|
+
readonly middlewareKey: string;
|
|
134
|
+
readonly location: string;
|
|
135
|
+
readonly attachmentIndex: number;
|
|
136
|
+
readonly previousIndex: number;
|
|
137
|
+
}, "_tag">;
|
|
138
|
+
readonly EquivalentOptions: Data.TaggedEnum.ConstructorFrom<{
|
|
139
|
+
readonly _tag: "EquivalentOptions";
|
|
140
|
+
readonly middlewareKey: string;
|
|
141
|
+
readonly location: string;
|
|
142
|
+
readonly attachmentIndex: number;
|
|
143
|
+
readonly previousIndex: number;
|
|
144
|
+
}, "_tag">;
|
|
145
|
+
readonly InvalidOptions: Data.TaggedEnum.ConstructorFrom<{
|
|
146
|
+
readonly _tag: "InvalidOptions";
|
|
147
|
+
readonly middlewareKey: string;
|
|
148
|
+
readonly location: string;
|
|
149
|
+
readonly attachmentIndex: number;
|
|
150
|
+
}, "_tag">;
|
|
151
|
+
};
|
|
152
|
+
export declare const formatValidationError: (value: {
|
|
153
|
+
readonly _tag: "ConflictingSpecs";
|
|
154
|
+
readonly middlewareKey: string;
|
|
155
|
+
readonly location: string;
|
|
156
|
+
readonly attachmentIndex: number;
|
|
157
|
+
readonly previousIndex: number;
|
|
158
|
+
} | {
|
|
159
|
+
readonly _tag: "EquivalentOptions";
|
|
160
|
+
readonly middlewareKey: string;
|
|
161
|
+
readonly location: string;
|
|
162
|
+
readonly attachmentIndex: number;
|
|
163
|
+
readonly previousIndex: number;
|
|
164
|
+
} | {
|
|
165
|
+
readonly _tag: "InvalidOptions";
|
|
166
|
+
readonly middlewareKey: string;
|
|
167
|
+
readonly location: string;
|
|
168
|
+
readonly attachmentIndex: number;
|
|
169
|
+
}) => string;
|
|
170
|
+
export declare const validateAll: (attachments: ReadonlyArray<MiddlewareAttachment>, location: string) => Result.Result<void, ValidationError>;
|
|
171
|
+
//# sourceMappingURL=MiddlewareAttachment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MiddlewareAttachment.d.ts","sourceRoot":"","sources":["../src/MiddlewareAttachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,cAAc,MAAM,kBAAkB,CAAC;AAExD,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,eAAe;;;gCAbA,MAAM;2BACX,MAAM;kCACC,MAAM;gCACR,MAAM;;;;;gCAGN,MAAM;2BACX,MAAM;kCACC,MAAM;gCACR,MAAM;;;;;gCAdN,MAAM;2BACX,MAAM;kCACC,MAAM;;;;;;;oCAGR,MAAM;+BACX,MAAM;sCACC,MAAM;oCACR,MAAM;;;oCAGN,MAAM;+BACX,MAAM;sCACC,MAAM;oCACR,MAAM;;;oCAdN,MAAM;+BACX,MAAM;sCACC,MAAM;;;;;;;;;;;;;;;;;;;;;;;oCAGR,MAAM;+BACX,MAAM;sCACC,MAAM;oCACR,MAAM;;;oCAGN,MAAM;+BACX,MAAM;sCACC,MAAM;oCACR,MAAM;;;oCAdN,MAAM;+BACX,MAAM;sCACC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;gCAGR,MAAM;2BACX,MAAM;kCACC,MAAM;gCACR,MAAM;;;;gCAGN,MAAM;2BACX,MAAM;kCACC,MAAM;gCACR,MAAM;;;;gCAdN,MAAM;2BACX,MAAM;kCACC,MAAM;;CAgB6B,CAAC;AAElE,eAAO,MAAM,qBAAqB;;4BAfN,MAAM;uBACX,MAAM;8BACC,MAAM;4BACR,MAAM;;;4BAGN,MAAM;uBACX,MAAM;8BACC,MAAM;4BACR,MAAM;;;4BAdN,MAAM;uBACX,MAAM;8BACC,MAAM;YA8BlC,CAAC;AAEH,eAAO,MAAM,WAAW,gBACT,aAAa,CAAC,oBAAoB,CAAC,YACtC,MAAM,KACf,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,CA2CrC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import * as Data from "effect/Data";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import * as Result from "effect/Result";
|
|
5
|
+
//#region src/MiddlewareAttachment.ts
|
|
6
|
+
var MiddlewareAttachment_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
ValidationError: () => ValidationError,
|
|
8
|
+
formatValidationError: () => formatValidationError,
|
|
9
|
+
validateAll: () => validateAll
|
|
10
|
+
});
|
|
11
|
+
const ValidationError = Data.taggedEnum();
|
|
12
|
+
const formatValidationError = ValidationError.$match({
|
|
13
|
+
InvalidOptions: ({ middlewareKey, location, attachmentIndex }) => `Middleware "${middlewareKey}" has invalid options at attachment ${attachmentIndex + 1} on ${location}`,
|
|
14
|
+
ConflictingSpecs: ({ middlewareKey, location }) => `Different middleware specs share key "${middlewareKey}" on ${location}`,
|
|
15
|
+
EquivalentOptions: ({ middlewareKey, location, attachmentIndex, previousIndex }) => `Middleware "${middlewareKey}" has equivalent options at attachments ${previousIndex + 1} and ${attachmentIndex + 1} on ${location}`
|
|
16
|
+
});
|
|
17
|
+
const validateAll = (attachments, location) => {
|
|
18
|
+
for (const [index, attachment] of attachments.entries()) {
|
|
19
|
+
const schema = attachment.spec.options;
|
|
20
|
+
if (schema !== void 0 && !Schema.is(schema)(attachment.options)) return Result.fail(ValidationError.InvalidOptions({
|
|
21
|
+
middlewareKey: attachment.spec.key,
|
|
22
|
+
location,
|
|
23
|
+
attachmentIndex: index
|
|
24
|
+
}));
|
|
25
|
+
const equivalent = schema === void 0 ? void 0 : Schema.toEquivalence(schema);
|
|
26
|
+
for (const [previousIndex, previous] of attachments.entries()) {
|
|
27
|
+
if (previousIndex === index) break;
|
|
28
|
+
if (previous.spec.key !== attachment.spec.key) continue;
|
|
29
|
+
if (previous.spec !== attachment.spec) return Result.fail(ValidationError.ConflictingSpecs({
|
|
30
|
+
middlewareKey: attachment.spec.key,
|
|
31
|
+
location,
|
|
32
|
+
attachmentIndex: index,
|
|
33
|
+
previousIndex
|
|
34
|
+
}));
|
|
35
|
+
if (equivalent === void 0 || equivalent(previous.options, attachment.options)) return Result.fail(ValidationError.EquivalentOptions({
|
|
36
|
+
middlewareKey: attachment.spec.key,
|
|
37
|
+
location,
|
|
38
|
+
attachmentIndex: index,
|
|
39
|
+
previousIndex
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return Result.void;
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { MiddlewareAttachment_exports, ValidationError, formatValidationError, validateAll };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=MiddlewareAttachment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MiddlewareAttachment.js","names":[],"sources":["../src/MiddlewareAttachment.ts"],"sourcesContent":["import * as Data from \"effect/Data\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec\";\n\nexport type MiddlewareAttachment<\n MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec =\n MiddlewareSpec.AnyMiddlewareSpec,\n> = MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec\n ? {\n readonly spec: MiddlewareSpec_;\n readonly options: [MiddlewareSpec_[\"~Options\"]] extends [never]\n ? undefined\n : MiddlewareSpec.Options<MiddlewareSpec_>;\n }\n : never;\n\nexport type Args<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec> = [\n MiddlewareSpec_[\"~Options\"],\n] extends [never]\n ? []\n : [options: MiddlewareSpec.Options<MiddlewareSpec_>];\n\nexport type ValidationError = Data.TaggedEnum<{\n InvalidOptions: {\n readonly middlewareKey: string;\n readonly location: string;\n readonly attachmentIndex: number;\n };\n ConflictingSpecs: {\n readonly middlewareKey: string;\n readonly location: string;\n readonly attachmentIndex: number;\n readonly previousIndex: number;\n };\n EquivalentOptions: {\n readonly middlewareKey: string;\n readonly location: string;\n readonly attachmentIndex: number;\n readonly previousIndex: number;\n };\n}>;\n\nexport const ValidationError = Data.taggedEnum<ValidationError>();\n\nexport const formatValidationError = ValidationError.$match({\n InvalidOptions: ({ middlewareKey, location, attachmentIndex }) =>\n `Middleware \"${middlewareKey}\" has invalid options at attachment ${attachmentIndex + 1} on ${location}`,\n ConflictingSpecs: ({ middlewareKey, location }) =>\n `Different middleware specs share key \"${middlewareKey}\" on ${location}`,\n EquivalentOptions: ({\n middlewareKey,\n location,\n attachmentIndex,\n previousIndex,\n }) =>\n `Middleware \"${middlewareKey}\" has equivalent options at attachments ${previousIndex + 1} and ${attachmentIndex + 1} on ${location}`,\n});\n\nexport const validateAll = (\n attachments: ReadonlyArray<MiddlewareAttachment>,\n location: string,\n): Result.Result<void, ValidationError> => {\n for (const [index, attachment] of attachments.entries()) {\n const schema = attachment.spec.options;\n if (schema !== undefined && !Schema.is(schema)(attachment.options)) {\n return Result.fail(\n ValidationError.InvalidOptions({\n middlewareKey: attachment.spec.key,\n location,\n attachmentIndex: index,\n }),\n );\n }\n const equivalent =\n schema === undefined ? undefined : Schema.toEquivalence(schema);\n for (const [previousIndex, previous] of attachments.entries()) {\n if (previousIndex === index) break;\n if (previous.spec.key !== attachment.spec.key) continue;\n if (previous.spec !== attachment.spec) {\n return Result.fail(\n ValidationError.ConflictingSpecs({\n middlewareKey: attachment.spec.key,\n location,\n attachmentIndex: index,\n previousIndex,\n }),\n );\n }\n if (\n equivalent === undefined ||\n equivalent(previous.options, attachment.options)\n ) {\n return Result.fail(\n ValidationError.EquivalentOptions({\n middlewareKey: attachment.spec.key,\n location,\n attachmentIndex: index,\n previousIndex,\n }),\n );\n }\n }\n }\n return Result.void;\n};\n"],"mappings":";;;;;;;;;;AA2CA,MAAa,kBAAkB,KAAK,WAA4B;AAEhE,MAAa,wBAAwB,gBAAgB,OAAO;CAC1D,iBAAiB,EAAE,eAAe,UAAU,sBAC1C,eAAe,cAAc,sCAAsC,kBAAkB,EAAE,MAAM;CAC/F,mBAAmB,EAAE,eAAe,eAClC,yCAAyC,cAAc,OAAO;CAChE,oBAAoB,EAClB,eACA,UACA,iBACA,oBAEA,eAAe,cAAc,0CAA0C,gBAAgB,EAAE,OAAO,kBAAkB,EAAE,MAAM;AAC9H,CAAC;AAED,MAAa,eACX,aACA,aACyC;CACzC,KAAK,MAAM,CAAC,OAAO,eAAe,YAAY,QAAQ,GAAG;EACvD,MAAM,SAAS,WAAW,KAAK;EAC/B,IAAI,WAAW,KAAA,KAAa,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,WAAW,OAAO,GAC/D,OAAO,OAAO,KACZ,gBAAgB,eAAe;GAC7B,eAAe,WAAW,KAAK;GAC/B;GACA,iBAAiB;EACnB,CAAC,CACH;EAEF,MAAM,aACJ,WAAW,KAAA,IAAY,KAAA,IAAY,OAAO,cAAc,MAAM;EAChE,KAAK,MAAM,CAAC,eAAe,aAAa,YAAY,QAAQ,GAAG;GAC7D,IAAI,kBAAkB,OAAO;GAC7B,IAAI,SAAS,KAAK,QAAQ,WAAW,KAAK,KAAK;GAC/C,IAAI,SAAS,SAAS,WAAW,MAC/B,OAAO,OAAO,KACZ,gBAAgB,iBAAiB;IAC/B,eAAe,WAAW,KAAK;IAC/B;IACA,iBAAiB;IACjB;GACF,CAAC,CACH;GAEF,IACE,eAAe,KAAA,KACf,WAAW,SAAS,SAAS,WAAW,OAAO,GAE/C,OAAO,OAAO,KACZ,gBAAgB,kBAAkB;IAChC,eAAe,WAAW,KAAK;IAC/B;IACA,iBAAiB;IACjB;GACF,CAAC,CACH;EAEJ;CACF;CACA,OAAO,OAAO;AAChB"}
|
package/dist/MiddlewareSpec.d.ts
CHANGED
|
@@ -31,26 +31,31 @@ export interface SuccessValue {
|
|
|
31
31
|
*
|
|
32
32
|
* Mirrors `RpcMiddleware.RpcMiddleware` in Effect.
|
|
33
33
|
*/
|
|
34
|
-
export interface MiddlewareImpl<Provides_, E, R> {
|
|
35
|
-
(effect: Effect.Effect<SuccessValue, E | unhandled, Provides_>,
|
|
34
|
+
export interface MiddlewareImpl<Provides_, E, R, Options_ = never> {
|
|
35
|
+
(effect: Effect.Effect<SuccessValue, E | unhandled, Provides_>, context: MiddlewareOptions<Options_>): Effect.Effect<SuccessValue, E | unhandled, R>;
|
|
36
36
|
}
|
|
37
|
-
export
|
|
38
|
-
readonly
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
export type MiddlewareOptions<Options_ = never> = {
|
|
38
|
+
readonly invocation: {
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly functionType: FunctionType;
|
|
41
|
+
readonly functionVisibility: FunctionVisibility;
|
|
42
|
+
readonly args: unknown;
|
|
43
|
+
};
|
|
44
|
+
} & ([Options_] extends [never] ? unknown : {
|
|
45
|
+
readonly options: Options_;
|
|
46
|
+
});
|
|
47
|
+
export interface AnyMiddlewareImpl {
|
|
48
|
+
(effect: Effect.Effect<SuccessValue, any, any>, context: MiddlewareOptions | MiddlewareOptions<unknown>): Effect.Effect<SuccessValue, any, any>;
|
|
44
49
|
}
|
|
45
50
|
/**
|
|
46
51
|
* The class shape produced by {@link MiddlewareSpec}. Only the static side is ever
|
|
47
|
-
* used
|
|
52
|
+
* used—the class is a value-level carrier for the middleware's key, its
|
|
48
53
|
* declared functionTypes, and its (lazily-evaluated) error schema, plus the
|
|
49
54
|
* type-level `Provides`/`Error` metadata. It is deliberately not a
|
|
50
55
|
* `Context.Tag`: implementations are registered through the group `Registry`
|
|
51
56
|
* (like `FunctionImpl`s), not resolved from a Layer context.
|
|
52
57
|
*/
|
|
53
|
-
export interface MiddlewareSpec<in out Self, Key_ extends string, Provides_, Requires_, ErrorSchema_ extends Schema.Codec<any, any>, FunctionTypes_ extends FunctionType> {
|
|
58
|
+
export interface MiddlewareSpec<in out Self, Key_ extends string, Provides_, Requires_, ErrorSchema_ extends Schema.Codec<any, any>, FunctionTypes_ extends FunctionType, OptionsSchema_ extends Schema.Schema<any> = never> {
|
|
54
59
|
new (_: never): {
|
|
55
60
|
readonly [TypeId]: TypeId;
|
|
56
61
|
readonly key: Key_;
|
|
@@ -59,22 +64,28 @@ export interface MiddlewareSpec<in out Self, Key_ extends string, Provides_, Req
|
|
|
59
64
|
readonly key: Key_;
|
|
60
65
|
readonly functionTypes: SupportedFunctionTypes;
|
|
61
66
|
readonly error?: ErrorSchema_;
|
|
67
|
+
readonly options?: OptionsSchema_;
|
|
62
68
|
readonly "~Provides": Provides_;
|
|
63
69
|
readonly "~Requires": Requires_;
|
|
64
70
|
readonly "~Error": ErrorSchema_;
|
|
65
71
|
readonly "~FunctionTypes": FunctionTypes_;
|
|
66
72
|
readonly "~Self": Self;
|
|
73
|
+
readonly "~Options": OptionsSchema_;
|
|
67
74
|
}
|
|
68
75
|
export interface AnyMiddlewareSpec {
|
|
69
76
|
readonly [TypeId]: TypeId;
|
|
70
77
|
readonly key: string;
|
|
71
78
|
readonly functionTypes: SupportedFunctionTypes;
|
|
72
79
|
readonly error?: Schema.Codec<any, any>;
|
|
80
|
+
readonly options?: Schema.Schema<any>;
|
|
73
81
|
readonly "~Provides": any;
|
|
74
82
|
readonly "~Requires": any;
|
|
75
83
|
readonly "~Error": any;
|
|
76
84
|
readonly "~FunctionTypes": FunctionType;
|
|
85
|
+
readonly "~Options": any;
|
|
77
86
|
}
|
|
87
|
+
export type Options<MiddlewareSpec_ extends AnyMiddlewareSpec> = MiddlewareSpec_["~Options"]["Type"];
|
|
88
|
+
export type WithoutOptions<MiddlewareSpec_ extends AnyMiddlewareSpec> = MiddlewareSpec_ extends AnyMiddlewareSpec ? [MiddlewareSpec_["~Options"]] extends [never] ? MiddlewareSpec_ : never : never;
|
|
78
89
|
export type Key<MiddlewareSpec_ extends AnyMiddlewareSpec> = MiddlewareSpec_["key"];
|
|
79
90
|
export type Provides<MiddlewareSpec_ extends AnyMiddlewareSpec> = MiddlewareSpec_ extends AnyMiddlewareSpec ? MiddlewareSpec_["~Provides"] : never;
|
|
80
91
|
/**
|
|
@@ -106,10 +117,11 @@ export type FunctionTypes<MiddlewareSpec_ extends AnyMiddlewareSpec> = Middlewar
|
|
|
106
117
|
export declare const MiddlewareSpec: <Self, Config extends {
|
|
107
118
|
provides?: any;
|
|
108
119
|
requires?: any;
|
|
109
|
-
} = {}>() => <const Key_ extends string, const FunctionTypesConfig_ extends SupportedFunctionTypes, ErrorSchema_ extends Schema.Codec<any, any> = never>(key: Key_, options: {
|
|
120
|
+
} = {}>() => <const Key_ extends string, const FunctionTypesConfig_ extends SupportedFunctionTypes, ErrorSchema_ extends Schema.Codec<any, any> = never, OptionsSchema_ extends Schema.Schema<any> = never>(key: Key_, options: {
|
|
110
121
|
readonly error?: () => ErrorSchema_;
|
|
122
|
+
readonly options?: () => OptionsSchema_;
|
|
111
123
|
readonly functionTypes: FunctionTypesConfig_ & ValidateFunctionTypesConfig<FunctionTypesConfig_>;
|
|
112
|
-
}) => MiddlewareSpec<Self, Key_, "provides" extends keyof Config ? Config["provides"] : never, "requires" extends keyof Config ? Config["requires"] : never, ErrorSchema_, FunctionTypesFromConfig<FunctionTypesConfig_
|
|
124
|
+
}) => MiddlewareSpec<Self, Key_, "provides" extends keyof Config ? Config["provides"] : never, "requires" extends keyof Config ? Config["requires"] : never, ErrorSchema_, FunctionTypesFromConfig<FunctionTypesConfig_>, OptionsSchema_>;
|
|
113
125
|
type FunctionTypesFromConfig<Config extends SupportedFunctionTypes> = {
|
|
114
126
|
[K in FunctionType]: Config[K] extends true ? K : never;
|
|
115
127
|
}[FunctionType];
|
|
@@ -120,7 +132,7 @@ export declare const errorSchemas: (middlewareSpecs: ReadonlyArray<AnyMiddleware
|
|
|
120
132
|
/**
|
|
121
133
|
* A branded, unconstructible type carrying a spec-authoring error message.
|
|
122
134
|
* Surfaced as (part of) a parameter type so the diagnostic names the exact
|
|
123
|
-
* problem at the `.middleware()
|
|
135
|
+
* problem at the `.middleware()`/`.addFunction()` call site.
|
|
124
136
|
*/
|
|
125
137
|
export interface AttachmentError<Message extends string> {
|
|
126
138
|
readonly "~@confect/core/MiddlewareSpec/AttachmentError": Message;
|
|
@@ -137,9 +149,9 @@ export type ValidateFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps, Mi
|
|
|
137
149
|
readonly functionProvenance: {
|
|
138
150
|
readonly _tag: "Convex";
|
|
139
151
|
};
|
|
140
|
-
} ? FunctionTypeOf<FunctionSpec_> extends FunctionTypes<MiddlewareSpec_> ? AttachmentError<`Convex-provenance function "${FunctionSpec_["name"]}" cannot be covered by middleware "${Key<MiddlewareSpec_>}"
|
|
152
|
+
} ? FunctionTypeOf<FunctionSpec_> extends FunctionTypes<MiddlewareSpec_> ? AttachmentError<`Convex-provenance function "${FunctionSpec_["name"]}" cannot be covered by middleware "${Key<MiddlewareSpec_>}"—attach middleware only to groups whose matching-type functions are all Confect-provenance`> : never : [
|
|
141
153
|
Extract<FunctionSpec.MiddlewareSpecs<FunctionSpec_>, {
|
|
142
|
-
readonly key: Key<MiddlewareSpec_
|
|
154
|
+
readonly key: Key<WithoutOptions<MiddlewareSpec_>>;
|
|
143
155
|
}>
|
|
144
156
|
] extends [never] ? FunctionTypeOf<FunctionSpec_> extends FunctionTypes<MiddlewareSpec_> ? never : AttachmentError<`Middleware "${Key<MiddlewareSpec_>}" does not declare function type "${FunctionTypeOf<FunctionSpec_>}", the type of function "${FunctionSpec_["name"]}"`> : AttachmentError<`Middleware "${Key<MiddlewareSpec_>}" is already attached to function "${FunctionSpec_["name"]}"`> : never : never;
|
|
145
157
|
/**
|
|
@@ -149,23 +161,23 @@ export type ValidateFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps, Mi
|
|
|
149
161
|
*/
|
|
150
162
|
export type ValidateAttach<MiddlewareSpec_ extends AnyMiddlewareSpec, Functions_ extends FunctionSpec.AnyWithProps, MiddlewareSpecs_ extends AnyMiddlewareSpec> = [
|
|
151
163
|
Extract<MiddlewareSpecs_, {
|
|
152
|
-
readonly key: Key<MiddlewareSpec_
|
|
164
|
+
readonly key: Key<WithoutOptions<MiddlewareSpec_>>;
|
|
153
165
|
}>
|
|
154
166
|
] extends [never] ? [Exclude<Requires<MiddlewareSpec_>, Provides<MiddlewareSpecs_>>] extends [
|
|
155
167
|
never
|
|
156
|
-
] ? ValidationResult<ValidateFunction<Functions_, MiddlewareSpec_>> : AttachmentError<`Middleware "${Key<MiddlewareSpec_>}" requires services that no middleware attached earlier to this group provides
|
|
168
|
+
] ? ValidationResult<ValidateFunction<Functions_, MiddlewareSpec_>> : AttachmentError<`Middleware "${Key<MiddlewareSpec_>}" requires services that no middleware attached earlier to this group provides—attach the providing middleware first`> : AttachmentError<`Middleware "${Key<MiddlewareSpec_>}" is already attached to this group`>;
|
|
157
169
|
export type ValidateAddedFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps, MiddlewareSpecs_ extends AnyMiddlewareSpec> = [MiddlewareSpecs_] extends [never] ? unknown : ValidationResult<ValidateFunction<FunctionSpec_, MiddlewareSpecs_> | GroupOverlap<FunctionSpec_, MiddlewareSpecs_>>;
|
|
158
170
|
type GroupOverlap<FunctionSpec_ extends FunctionSpec.AnyWithProps, MiddlewareSpecs_ extends AnyMiddlewareSpec> = FunctionSpec.MiddlewareSpecs<FunctionSpec_> extends infer FunctionMiddlewareSpec ? FunctionMiddlewareSpec extends AnyMiddlewareSpec ? [
|
|
159
171
|
Extract<MiddlewareSpecs_, {
|
|
160
|
-
readonly key: Key<FunctionMiddlewareSpec
|
|
172
|
+
readonly key: Key<WithoutOptions<FunctionMiddlewareSpec>>;
|
|
161
173
|
}>
|
|
162
174
|
] extends [never] ? never : AttachmentError<`Middleware "${Key<FunctionMiddlewareSpec>}" is attached to both function "${FunctionSpec_["name"]}" and its group`> : never : never;
|
|
163
175
|
/**
|
|
164
176
|
* The parameter-type validation applied to the group spec at
|
|
165
177
|
* `GroupImpl.make`: every function's attached middleware must have its
|
|
166
178
|
* `requires` services provided by some middleware covering that function
|
|
167
|
-
* (the group's or the function's own). Checked here
|
|
168
|
-
* assembled
|
|
179
|
+
* (the group's or the function's own). Checked here—with the group fully
|
|
180
|
+
* assembled—rather than at the spec builders, because a function-level
|
|
169
181
|
* middleware's `requires` may legitimately be satisfied by a group
|
|
170
182
|
* middleware the function spec never sees, and group attachment is
|
|
171
183
|
* declaratively order-independent with respect to `addFunction`.
|
|
@@ -175,9 +187,9 @@ export type ValidateImplRequires<Functions_ extends FunctionSpec.AnyWithProps, G
|
|
|
175
187
|
] extends [never] ? never : AttachmentError<`Function "${Functions_["name"]}" has middleware requiring services that no middleware covering it provides`> : never>;
|
|
176
188
|
export type ValidateFunctionAttach<MiddlewareSpec_ extends AnyMiddlewareSpec, RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType, FunctionProvenance_ extends FunctionProvenance.FunctionProvenance, MiddlewareSpecs_ extends AnyMiddlewareSpec> = FunctionProvenance_ extends {
|
|
177
189
|
readonly _tag: "Convex";
|
|
178
|
-
} ? AttachmentError<`Plain Convex functions cannot have middleware
|
|
190
|
+
} ? AttachmentError<`Plain Convex functions cannot have middleware—their raw handlers are passed through untouched`> : [
|
|
179
191
|
Extract<MiddlewareSpecs_, {
|
|
180
|
-
readonly key: Key<MiddlewareSpec_
|
|
192
|
+
readonly key: Key<WithoutOptions<MiddlewareSpec_>>;
|
|
181
193
|
}>
|
|
182
194
|
] extends [never] ? RuntimeAndFunctionType_["functionType"] extends FunctionTypes<MiddlewareSpec_> ? unknown : AttachmentError<`Middleware "${Key<MiddlewareSpec_>}" does not declare function type "${RuntimeAndFunctionType_["functionType"]}"`> : AttachmentError<`Middleware "${Key<MiddlewareSpec_>}" is already attached to this function`>;
|
|
183
195
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiddlewareSpec.d.ts","sourceRoot":"","sources":["../src/MiddlewareSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;AACh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C,KAAK,CAAC,GACf,KAAK,GACL,eAAe,CAAC,aAAa,UAAU,CAAC,MAAM,CAAC,6EAA6E,CAAC,GAC/H,KAAK,CACV,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAChC,eAAe,SAAS,iBAAiB,EACzC,uBAAuB,SAAS,sBAAsB,CAAC,sBAAsB,EAC7E,mBAAmB,SAAS,kBAAkB,CAAC,kBAAkB,EACjE,gBAAgB,SAAS,iBAAiB,IACxC,mBAAmB,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GACvD,eAAe,CAAC,+FAA+F,CAAC,GAChH;IACI,OAAO,CACL,gBAAgB,EAChB;QAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAA;KAAE,CACvD;CACF,SAAS,CAAC,KAAK,CAAC,GACjB,uBAAuB,CAAC,cAAc,CAAC,SAAS,aAAa,CAAC,eAAe,CAAC,GAC5E,OAAO,GACP,eAAe,CAAC,eAAe,GAAG,CAAC,eAAe,CAAC,qCAAqC,uBAAuB,CAAC,cAAc,CAAC,GAAG,CAAC,GACrI,eAAe,CAAC,eAAe,GAAG,CAAC,eAAe,CAAC,wCAAwC,CAAC,CAAC"}
|
package/dist/MiddlewareSpec.js
CHANGED
|
@@ -46,6 +46,7 @@ const MiddlewareSpec = () => (key, options) => {
|
|
|
46
46
|
action
|
|
47
47
|
};
|
|
48
48
|
if (options.error !== void 0) defineProperty(class_, "error", options.error);
|
|
49
|
+
if (options.options !== void 0) defineProperty(class_, "options", options.options);
|
|
49
50
|
return class_;
|
|
50
51
|
};
|
|
51
52
|
const errorSchemas = (middlewareSpecs) => middlewareSpecs.flatMap((middlewareSpec) => "error" in middlewareSpec && middlewareSpec.error !== void 0 ? [middlewareSpec.error] : []);
|