@confect/core 9.0.0-next.0 → 9.0.0-next.10
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 +268 -4
- package/dist/FunctionProvenance.d.ts +101 -95
- package/dist/FunctionProvenance.d.ts.map +1 -1
- package/dist/FunctionProvenance.js +25 -6
- package/dist/FunctionProvenance.js.map +1 -1
- package/dist/FunctionSpec.d.ts +178 -218
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +2 -2
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GenericId.d.ts +7 -12
- package/dist/GenericId.d.ts.map +1 -1
- package/dist/GenericId.js +2 -1
- package/dist/GenericId.js.map +1 -1
- package/dist/GroupPath.d.ts +10 -16
- package/dist/GroupPath.d.ts.map +1 -1
- package/dist/GroupSpec.d.ts +38 -37
- package/dist/GroupSpec.d.ts.map +1 -1
- package/dist/GroupSpec.js +9 -3
- package/dist/GroupSpec.js.map +1 -1
- package/dist/Identifier.d.ts +14 -0
- package/dist/Identifier.d.ts.map +1 -0
- package/dist/{internal/utils.js → Identifier.js} +26 -3
- package/dist/Identifier.js.map +1 -0
- package/dist/Lazy.d.ts +22 -0
- package/dist/Lazy.d.ts.map +1 -0
- package/dist/Lazy.js +44 -0
- package/dist/Lazy.js.map +1 -0
- package/dist/PaginationResult.d.ts +11 -18
- package/dist/PaginationResult.d.ts.map +1 -1
- package/dist/PaginationResult.js +1 -1
- package/dist/PaginationResult.js.map +1 -1
- package/dist/Ref.d.ts +55 -51
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +17 -6
- package/dist/Ref.js.map +1 -1
- package/dist/Refs.d.ts +21 -21
- package/dist/Refs.d.ts.map +1 -1
- package/dist/Refs.js +5 -10
- package/dist/Refs.js.map +1 -1
- package/dist/Registry.d.ts +7 -11
- package/dist/Registry.d.ts.map +1 -1
- package/dist/Registry.js +2 -1
- package/dist/Registry.js.map +1 -1
- package/dist/RuntimeAndFunctionType.d.ts +36 -41
- package/dist/RuntimeAndFunctionType.d.ts.map +1 -1
- package/dist/Spec.d.ts +23 -32
- package/dist/Spec.d.ts.map +1 -1
- package/dist/Spec.js +9 -48
- package/dist/Spec.js.map +1 -1
- package/dist/SystemFields.d.ts +10 -16
- package/dist/SystemFields.d.ts.map +1 -1
- package/dist/SystemFields.js +1 -1
- package/dist/SystemFields.js.map +1 -1
- package/dist/Types.d.ts +27 -27
- package/dist/Types.d.ts.map +1 -1
- package/dist/UserIdentity.d.ts +56 -63
- package/dist/UserIdentity.d.ts.map +1 -1
- package/dist/UserIdentity.js +1 -1
- package/dist/UserIdentity.js.map +1 -1
- package/dist/index.d.ts +17 -15
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -1
- package/dist/tsconfig.src.tsbuildinfo +1 -0
- package/package.json +37 -46
- package/src/FunctionProvenance.ts +32 -10
- package/src/FunctionSpec.ts +5 -5
- package/src/GenericId.ts +3 -1
- package/src/GroupSpec.ts +16 -11
- package/src/{internal/utils.ts → Identifier.ts} +34 -0
- package/src/Lazy.ts +40 -0
- package/src/PaginationResult.ts +1 -1
- package/src/Ref.ts +23 -8
- package/src/Refs.ts +13 -44
- package/src/Registry.ts +2 -1
- package/src/Spec.ts +18 -81
- package/src/SystemFields.ts +1 -1
- package/src/UserIdentity.ts +1 -1
- package/src/index.ts +2 -0
- package/dist/internal/utils.d.ts +0 -5
- package/dist/internal/utils.d.ts.map +0 -1
- package/dist/internal/utils.js.map +0 -1
package/dist/GenericId.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericId.d.ts","
|
|
1
|
+
{"version":3,"file":"GenericId.d.ts","sourceRoot":"","sources":["../src/GenericId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAI9C,eAAO,MAAM,SAAS,GAAI,SAAS,SAAS,MAAM,EAChD,WAAW,SAAS,KACnB,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAGgB,CAAC;AAE5D,MAAM,MAAM,SAAS,CAAC,SAAS,SAAS,MAAM,IAAI,eAAe,CAAC,SAAS,CAAC,CAAC;AAE7E,eAAO,MAAM,SAAS,GAAI,SAAS,SAAS,MAAM,EAChD,KAAK,SAAS,CAAC,GAAG,KACjB,MAAM,CAAC,MAAM,CAAC,SAAS,CACyB,CAAC"}
|
package/dist/GenericId.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
3
4
|
|
|
4
5
|
//#region src/GenericId.ts
|
|
5
6
|
var GenericId_exports = /* @__PURE__ */ __exportAll({
|
package/dist/GenericId.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericId.js","names":[],"sources":["../src/GenericId.ts"],"sourcesContent":["import type { GenericId as ConvexGenericId } from \"convex/values\";\nimport {
|
|
1
|
+
{"version":3,"file":"GenericId.js","names":[],"sources":["../src/GenericId.ts"],"sourcesContent":["import type { GenericId as ConvexGenericId } from \"convex/values\";\nimport type { Option } from \"effect\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\n\nconst ConvexId = Symbol.for(\"ConvexId\");\n\nexport const GenericId = <TableName extends string>(\n tableName: TableName,\n): Schema.Schema<ConvexGenericId<TableName>> =>\n Schema.String.pipe(\n Schema.annotations({ [ConvexId]: tableName }),\n ) as unknown as Schema.Schema<ConvexGenericId<TableName>>;\n\nexport type GenericId<TableName extends string> = ConvexGenericId<TableName>;\n\nexport const tableName = <TableName extends string>(\n ast: SchemaAST.AST,\n): Option.Option<TableName> =>\n SchemaAST.getAnnotation<TableName>(ConvexId)(ast);\n"],"mappings":";;;;;;;;;AAKA,MAAM,WAAW,OAAO,IAAI,WAAW;AAEvC,MAAa,aACX,cAEA,OAAO,OAAO,KACZ,OAAO,YAAY,GAAG,WAAW,WAAW,CAAC,CAC9C;AAIH,MAAa,aACX,QAEA,UAAU,cAAyB,SAAS,CAAC,IAAI"}
|
package/dist/GroupPath.d.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
//#region src/GroupPath.d.ts
|
|
5
|
-
declare namespace GroupPath_d_exports {
|
|
6
|
-
export { All, GroupAt, SubGroupsAt };
|
|
7
|
-
}
|
|
1
|
+
import type { Record } from "effect";
|
|
2
|
+
import type * as GroupSpec from "./GroupSpec";
|
|
8
3
|
/**
|
|
9
4
|
* Recursively generates paths for a group and its nested groups.
|
|
10
5
|
*
|
|
11
6
|
* - For a group with no subgroups, returns just the group name.
|
|
12
7
|
* - For a group with subgroups, returns the group name plus all possible paths through its direct subgroups.
|
|
13
8
|
*/
|
|
14
|
-
type All<Group extends AnyWithProps, Depth extends 1[] = []> = Depth["length"] extends 15 ? string : Group extends any ? [Groups<Group>] extends [never] ? Name<Group> : Name<Group> | AllHelper<Group, Groups<Group>, Depth> : never;
|
|
15
|
-
type AllHelper<Parent extends AnyWithProps, Groups_ extends AnyWithProps, Depth extends 1[] = []> = Groups_ extends AnyWithProps ? `${Name<Parent>}.${All<Groups_, [...Depth, 1]>}` : never;
|
|
9
|
+
export type All<Group extends GroupSpec.AnyWithProps, Depth extends 1[] = []> = Depth["length"] extends 15 ? string : Group extends any ? [GroupSpec.Groups<Group>] extends [never] ? GroupSpec.Name<Group> : GroupSpec.Name<Group> | AllHelper<Group, GroupSpec.Groups<Group>, Depth> : never;
|
|
10
|
+
type AllHelper<Parent extends GroupSpec.AnyWithProps, Groups_ extends GroupSpec.AnyWithProps, Depth extends 1[] = []> = Groups_ extends GroupSpec.AnyWithProps ? `${GroupSpec.Name<Parent>}.${All<Groups_, [...Depth, 1]>}` : never;
|
|
16
11
|
/**
|
|
17
12
|
* Recursively extracts the group at the given dot-separated path.
|
|
18
13
|
* Path must match the format defined in `Path` above, e.g. "group" or "group.subgroup".
|
|
@@ -22,12 +17,11 @@ type AllHelper<Parent extends AnyWithProps, Groups_ extends AnyWithProps, Depth
|
|
|
22
17
|
* type G = WithPath<RootGroup, "group.subgroup">;
|
|
23
18
|
* ```
|
|
24
19
|
*/
|
|
25
|
-
type GroupAt<Group, Path extends string> = Group extends AnyWithProps ? Path extends `${infer Head}.${infer Tail}` ? Group extends {
|
|
26
|
-
|
|
20
|
+
export type GroupAt<Group, Path extends string> = Group extends GroupSpec.AnyWithProps ? Path extends `${infer Head}.${infer Tail}` ? Group extends {
|
|
21
|
+
readonly name: Head;
|
|
27
22
|
} ? Group extends {
|
|
28
|
-
|
|
29
|
-
} ? GroupAt<SubGroup, Tail> : never : never : WithName<Group, Path> : never;
|
|
30
|
-
type SubGroupsAt<Group extends AnyWithProps, GroupPath extends string> = Groups<GroupAt<Group, GroupPath>> extends infer SubGroups ? SubGroups extends AnyWithProps ? `${GroupPath}.${Name<SubGroups>}` : never : never;
|
|
31
|
-
|
|
32
|
-
export { All, GroupAt, GroupPath_d_exports, SubGroupsAt };
|
|
23
|
+
readonly groups: Record.ReadonlyRecord<string, infer SubGroup>;
|
|
24
|
+
} ? GroupAt<SubGroup, Tail> : never : never : GroupSpec.WithName<Group, Path> : never;
|
|
25
|
+
export type SubGroupsAt<Group extends GroupSpec.AnyWithProps, GroupPath extends string> = GroupSpec.Groups<GroupAt<Group, GroupPath>> extends infer SubGroups ? SubGroups extends GroupSpec.AnyWithProps ? `${GroupPath}.${GroupSpec.Name<SubGroups>}` : never : never;
|
|
26
|
+
export {};
|
|
33
27
|
//# sourceMappingURL=GroupPath.d.ts.map
|
package/dist/GroupPath.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupPath.d.ts","
|
|
1
|
+
{"version":3,"file":"GroupPath.d.ts","sourceRoot":"","sources":["../src/GroupPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,KAAK,SAAS,MAAM,aAAa,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,MAAM,GAAG,CACb,KAAK,SAAS,SAAS,CAAC,YAAY,EACpC,KAAK,SAAS,CAAC,EAAE,GAAG,EAAE,IACpB,KAAK,CAAC,QAAQ,CAAC,SAAS,EAAE,GAC1B,MAAM,GACN,KAAK,SAAS,GAAG,GACf,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GACvC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GACrB,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAC1E,KAAK,CAAC;AAEZ,KAAK,SAAS,CACZ,MAAM,SAAS,SAAS,CAAC,YAAY,EACrC,OAAO,SAAS,SAAS,CAAC,YAAY,EACtC,KAAK,SAAS,CAAC,EAAE,GAAG,EAAE,IACpB,OAAO,SAAS,SAAS,CAAC,YAAY,GACtC,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,GAC1D,KAAK,CAAC;AAEV;;;;;;;;GAQG;AACH,MAAM,MAAM,OAAO,CACjB,KAAK,EACL,IAAI,SAAS,MAAM,IACjB,KAAK,SAAS,SAAS,CAAC,YAAY,GACpC,IAAI,SAAS,GAAG,MAAM,IAAI,IAAI,MAAM,IAAI,EAAE,GACxC,KAAK,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GACnC,KAAK,SAAS;IACZ,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,CAAC;CAChE,GACC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,GACvB,KAAK,GACP,KAAK,GACP,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,GACjC,KAAK,CAAC;AAEV,MAAM,MAAM,WAAW,CACrB,KAAK,SAAS,SAAS,CAAC,YAAY,EACpC,SAAS,SAAS,MAAM,IAExB,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,SAAS,MAAM,SAAS,GAC/D,SAAS,SAAS,SAAS,CAAC,YAAY,GACtC,GAAG,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAC3C,KAAK,GACP,KAAK,CAAC"}
|
package/dist/GroupSpec.d.ts
CHANGED
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare
|
|
6
|
-
|
|
1
|
+
import type * as FunctionSpec from "./FunctionSpec";
|
|
2
|
+
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
3
|
+
export declare const TypeId = "@confect/core/GroupSpec";
|
|
4
|
+
export type TypeId = typeof TypeId;
|
|
5
|
+
export declare const isGroupSpec: (u: unknown) => u is AnyWithProps;
|
|
6
|
+
export interface GroupSpec<Runtime extends RuntimeAndFunctionType.Runtime, Name_ extends string, Functions_ extends FunctionSpec.AnyWithPropsWithRuntime<Runtime> = never, Groups_ extends AnyWithProps = never> {
|
|
7
|
+
readonly [TypeId]: TypeId;
|
|
8
|
+
readonly runtime: Runtime;
|
|
9
|
+
readonly name: Name_;
|
|
10
|
+
readonly functions: {
|
|
11
|
+
[FunctionName in FunctionSpec.Name<FunctionSpec.AnyWithPropsWithRuntime<Runtime>>]: FunctionSpec.WithName<Functions_, FunctionName>;
|
|
12
|
+
};
|
|
13
|
+
readonly groups: {
|
|
14
|
+
[GroupName in Name<Groups_>]: WithName<Groups_, GroupName>;
|
|
15
|
+
};
|
|
16
|
+
addFunction<Function extends FunctionSpec.AnyWithPropsWithRuntime<Runtime>>(function_: Function): GroupSpec<Runtime, Name_, Functions_ | Function, Groups_>;
|
|
17
|
+
addGroup<Group extends AnyWithProps>(group: Group): GroupSpec<Runtime, Name_, Functions_, Groups_ | Group>;
|
|
18
|
+
addGroupAt<const AtName extends string, Group extends AnyWithProps>(name: AtName, group: Group): GroupSpec<Runtime, Name_, Functions_, Groups_ | NamedAt<Group, AtName>>;
|
|
7
19
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
declare const isGroupSpec: (u: unknown) => u is AnyWithProps;
|
|
11
|
-
interface GroupSpec<Runtime$2 extends Runtime, Name_ extends string, Functions_ extends AnyWithPropsWithRuntime$1<Runtime$2> = never, Groups_ extends AnyWithPropsWithRuntime<Runtime$2> = never> {
|
|
12
|
-
readonly [TypeId]: TypeId;
|
|
13
|
-
readonly runtime: Runtime$2;
|
|
14
|
-
readonly name: Name_;
|
|
15
|
-
readonly functions: { [FunctionName in Name$1<AnyWithPropsWithRuntime$1<Runtime$2>>]: WithName$1<Functions_, FunctionName> };
|
|
16
|
-
readonly groups: { [GroupName in Name<Groups_>]: WithName<Groups_, GroupName> };
|
|
17
|
-
addFunction<Function extends AnyWithPropsWithRuntime$1<Runtime$2>>(function_: Function): GroupSpec<Runtime$2, Name_, Functions_ | Function, Groups_>;
|
|
18
|
-
addGroup<Group extends AnyWithPropsWithRuntime<Runtime$2>>(group: Group): GroupSpec<Runtime$2, Name_, Functions_, Groups_ | Group>;
|
|
19
|
-
addGroupAt<const AtName extends string, Group extends AnyWithPropsWithRuntime<Runtime$2>>(name: AtName, group: Group): GroupSpec<Runtime$2, Name_, Functions_, Groups_ | NamedAt<Group, AtName>>;
|
|
20
|
+
export interface Any {
|
|
21
|
+
readonly [TypeId]: TypeId;
|
|
20
22
|
}
|
|
21
|
-
interface
|
|
22
|
-
readonly [TypeId]: TypeId;
|
|
23
|
+
export interface AnyWithProps extends GroupSpec<RuntimeAndFunctionType.Runtime, string, FunctionSpec.AnyWithProps, AnyWithProps> {
|
|
23
24
|
}
|
|
24
|
-
interface
|
|
25
|
-
|
|
26
|
-
type Name<Group extends AnyWithProps> = Group["name"];
|
|
27
|
-
type Functions<Group extends AnyWithProps> = Group["functions"][keyof Group["functions"]];
|
|
28
|
-
type Groups<Group extends AnyWithProps> = Group["groups"][keyof Group["groups"]];
|
|
29
|
-
type GroupNames<Group extends AnyWithProps> = [Groups<Group>] extends [
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
export interface AnyWithPropsWithRuntime<Runtime extends RuntimeAndFunctionType.Runtime> extends GroupSpec<Runtime, string, FunctionSpec.AnyWithPropsWithRuntime<Runtime>, AnyWithPropsWithRuntime<Runtime>> {
|
|
26
|
+
}
|
|
27
|
+
export type Name<Group extends AnyWithProps> = Group["name"];
|
|
28
|
+
export type Functions<Group extends AnyWithProps> = Group["functions"][keyof Group["functions"]];
|
|
29
|
+
export type Groups<Group extends AnyWithProps> = Group["groups"][keyof Group["groups"]];
|
|
30
|
+
export type GroupNames<Group extends AnyWithProps> = [Groups<Group>] extends [
|
|
31
|
+
never
|
|
32
|
+
] ? never : Name<Groups<Group>>;
|
|
33
|
+
export type WithName<Group extends AnyWithProps, Name_ extends Name<Group>> = Extract<Group, {
|
|
34
|
+
readonly name: Name_;
|
|
32
35
|
}>;
|
|
33
36
|
/** Assigns a segment name to a leaf group created with {@link make} for typing and refs. */
|
|
34
|
-
type NamedAt<Group extends Any, Name_ extends string> = Omit<Group, "name"> & {
|
|
35
|
-
|
|
37
|
+
export type NamedAt<Group extends Any, Name_ extends string> = Omit<Group, "name"> & {
|
|
38
|
+
readonly name: Name_;
|
|
36
39
|
};
|
|
37
|
-
declare const make: () => GroupSpec<"Convex", "">;
|
|
38
|
-
declare const makeAt: <const Name_ extends string>(name: Name_) => GroupSpec<"Convex", Name_>;
|
|
39
|
-
declare const makeNode: () => GroupSpec<"Node", "">;
|
|
40
|
-
declare const makeNodeAt: <const Name_ extends string>(name: Name_) => GroupSpec<"Node", Name_>;
|
|
41
|
-
declare const withName: <const Name_ extends string>(name: Name_, group: Any) => AnyWithProps;
|
|
42
|
-
//#endregion
|
|
43
|
-
export { Any, AnyWithProps, AnyWithPropsWithRuntime, Functions, GroupNames, GroupSpec, GroupSpec_d_exports, Groups, Name, NamedAt, TypeId, WithName, isGroupSpec, make, makeAt, makeNode, makeNodeAt, withName };
|
|
40
|
+
export declare const make: () => GroupSpec<"Convex", "">;
|
|
41
|
+
export declare const makeAt: <const Name_ extends string>(name: Name_) => GroupSpec<"Convex", Name_>;
|
|
42
|
+
export declare const makeNode: () => GroupSpec<"Node", "">;
|
|
43
|
+
export declare const makeNodeAt: <const Name_ extends string>(name: Name_) => GroupSpec<"Node", Name_>;
|
|
44
|
+
export declare const withName: <const Name_ extends string>(name: Name_, group: Any) => AnyWithProps;
|
|
44
45
|
//# sourceMappingURL=GroupSpec.d.ts.map
|
package/dist/GroupSpec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupSpec.d.ts","
|
|
1
|
+
{"version":3,"file":"GroupSpec.d.ts","sourceRoot":"","sources":["../src/GroupSpec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,YAAY,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AAGxE,eAAO,MAAM,MAAM,4BAA4B,CAAC;AAChD,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAEnC,eAAO,MAAM,WAAW,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,YACZ,CAAC;AAEnC,MAAM,WAAW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,CAAC,IAAI,EAAE,KAAK,CAAC;CACtB,CAAC;AAmEF,eAAO,MAAM,IAAI,QAAO,SAAS,CAAC,QAAQ,EAAE,EAAE,CAM1C,CAAC;AAEL,eAAO,MAAM,MAAM,GAAI,KAAK,CAAC,KAAK,SAAS,MAAM,EAC/C,MAAM,KAAK,KACV,SAAS,CAAC,QAAQ,EAAE,KAAK,CAS3B,CAAC;AAEF,eAAO,MAAM,QAAQ,QAAO,SAAS,CAAC,MAAM,EAAE,EAAE,CAM5C,CAAC;AAEL,eAAO,MAAM,UAAU,GAAI,KAAK,CAAC,KAAK,SAAS,MAAM,EACnD,MAAM,KAAK,KACV,SAAS,CAAC,MAAM,EAAE,KAAK,CASzB,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,KAAK,CAAC,KAAK,SAAS,MAAM,EACjD,MAAM,KAAK,EACX,OAAO,GAAG,KACT,YAcF,CAAC"}
|
package/dist/GroupSpec.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { validateConfectFunctionIdentifier } from "./
|
|
3
|
-
import
|
|
2
|
+
import { validateConfectFunctionIdentifier } from "./Identifier.js";
|
|
3
|
+
import * as Predicate from "effect/Predicate";
|
|
4
|
+
import * as Record from "effect/Record";
|
|
4
5
|
|
|
5
6
|
//#region src/GroupSpec.ts
|
|
6
7
|
var GroupSpec_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -86,7 +87,12 @@ const withName = (name, group) => {
|
|
|
86
87
|
validateConfectFunctionIdentifier(name);
|
|
87
88
|
const group_ = group;
|
|
88
89
|
if (group_.name === name) return group_;
|
|
89
|
-
return
|
|
90
|
+
return makeProto({
|
|
91
|
+
runtime: group_.runtime,
|
|
92
|
+
name,
|
|
93
|
+
functions: group_.functions,
|
|
94
|
+
groups: group_.groups
|
|
95
|
+
});
|
|
90
96
|
};
|
|
91
97
|
|
|
92
98
|
//#endregion
|
package/dist/GroupSpec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupSpec.js","names":[],"sources":["../src/GroupSpec.ts"],"sourcesContent":["import
|
|
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 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> {\n readonly [TypeId]: TypeId;\n readonly runtime: Runtime;\n readonly name: Name_;\n readonly functions: {\n [FunctionName in FunctionSpec.Name<\n FunctionSpec.AnyWithPropsWithRuntime<Runtime>\n >]: FunctionSpec.WithName<Functions_, FunctionName>;\n };\n readonly groups: {\n [GroupName in Name<Groups_>]: WithName<Groups_, GroupName>;\n };\n\n addFunction<Function extends FunctionSpec.AnyWithPropsWithRuntime<Runtime>>(\n function_: Function,\n ): GroupSpec<Runtime, Name_, Functions_ | Function, Groups_>;\n\n addGroup<Group extends AnyWithProps>(\n group: Group,\n ): GroupSpec<Runtime, Name_, Functions_, Groups_ | Group>;\n\n addGroupAt<const AtName extends string, Group extends AnyWithProps>(\n name: AtName,\n group: Group,\n ): GroupSpec<Runtime, Name_, Functions_, Groups_ | NamedAt<Group, AtName>>;\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> {}\n\nexport interface AnyWithPropsWithRuntime<\n Runtime extends RuntimeAndFunctionType.Runtime,\n> extends GroupSpec<\n Runtime,\n string,\n FunctionSpec.AnyWithPropsWithRuntime<Runtime>,\n AnyWithPropsWithRuntime<Runtime>\n> {}\n\nexport type Name<Group extends AnyWithProps> = Group[\"name\"];\n\nexport type Functions<Group extends AnyWithProps> =\n Group[\"functions\"][keyof Group[\"functions\"]];\n\nexport type Groups<Group extends AnyWithProps> =\n Group[\"groups\"][keyof Group[\"groups\"]];\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\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 return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: Record.set(this_.functions, function_.name, function_),\n groups: this_.groups,\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 });\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 });\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>({\n runtime,\n name,\n functions,\n groups,\n}: {\n runtime: Runtime;\n name: Name_;\n functions: Record.ReadonlyRecord<string, Functions_>;\n groups: Record.ReadonlyRecord<string, Groups_>;\n}): GroupSpec<Runtime, Name_, Functions_, Groups_> =>\n Object.assign(Object.create(Proto), {\n runtime,\n name,\n functions,\n groups,\n });\n\nexport const make = (): GroupSpec<\"Convex\", \"\"> =>\n makeProto({\n runtime: \"Convex\",\n name: \"\",\n functions: Record.empty(),\n groups: Record.empty(),\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 });\n};\n\nexport const makeNode = (): GroupSpec<\"Node\", \"\"> =>\n makeProto({\n runtime: \"Node\",\n name: \"\",\n functions: Record.empty(),\n groups: Record.empty(),\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 });\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 });\n};\n"],"mappings":";;;;;;;;;;;;;;;AAMA,MAAa,SAAS;AAGtB,MAAa,eAAe,MAC1B,UAAU,YAAY,GAAG,OAAO;AAqFlC,MAAM,QAA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MACA,UACiB;AACjB,mCAAkC,KAAK;CACvC,MAAM,SAAS;AAEf,KAAI,OAAO,SAAS,KAClB,QAAO;AAGT,QAAO,UAAU;EACf,SAAS,OAAO;EAChB;EACA,WAAW,OAAO;EAClB,QAAQ,OAAO;EAChB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const validateConfectFunctionIdentifier: (identifier: string) => void;
|
|
2
|
+
/**
|
|
3
|
+
* Validate that `identifier` is suitable as a Convex table name (and, equivalently,
|
|
4
|
+
* as a `confect/tables/<identifier>.ts` filename).
|
|
5
|
+
*
|
|
6
|
+
* Rules:
|
|
7
|
+
* - Must match `/^[A-Za-z][A-Za-z0-9_]*$/` — letter-leading, alphanumeric plus
|
|
8
|
+
* underscore. No `$` (not a valid Convex table name character); no leading
|
|
9
|
+
* `_` (Convex reserves `_<name>` for its system tables).
|
|
10
|
+
* - Must not be a reserved JavaScript identifier, so the name can also be used
|
|
11
|
+
* as a binding name in generated code without escaping.
|
|
12
|
+
*/
|
|
13
|
+
export declare const validateConfectTableIdentifier: (identifier: string) => void;
|
|
14
|
+
//# sourceMappingURL=Identifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Identifier.d.ts","sourceRoot":"","sources":["../src/Identifier.ts"],"names":[],"mappings":"AA4EA,eAAO,MAAM,iCAAiC,GAAI,YAAY,MAAM,SAkBnE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,8BAA8B,GAAI,YAAY,MAAM,SAYhE,CAAC"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
|
|
3
|
+
//#region src/Identifier.ts
|
|
4
|
+
var Identifier_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
validateConfectFunctionIdentifier: () => validateConfectFunctionIdentifier,
|
|
6
|
+
validateConfectTableIdentifier: () => validateConfectTableIdentifier
|
|
7
|
+
});
|
|
2
8
|
const RESERVED_JS_IDENTIFIERS = new Set([
|
|
3
9
|
"break",
|
|
4
10
|
"case",
|
|
@@ -54,15 +60,32 @@ const RESERVED_CONVEX_FILE_NAMES = new Set([
|
|
|
54
60
|
"crons"
|
|
55
61
|
]);
|
|
56
62
|
const jsIdentifierRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
63
|
+
const tableNameRegex = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
57
64
|
const isReservedJsIdentifier = (identifier) => RESERVED_JS_IDENTIFIERS.has(identifier);
|
|
58
65
|
const isReservedConvexFileName = (fileName) => RESERVED_CONVEX_FILE_NAMES.has(fileName);
|
|
59
66
|
const matchesJsIdentifierPattern = (identifier) => jsIdentifierRegex.test(identifier);
|
|
67
|
+
const matchesTableNamePattern = (identifier) => tableNameRegex.test(identifier);
|
|
60
68
|
const validateConfectFunctionIdentifier = (identifier) => {
|
|
61
69
|
if (!matchesJsIdentifierPattern(identifier)) throw new Error(`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.`);
|
|
62
70
|
if (isReservedJsIdentifier(identifier)) throw new Error(`Expected a valid Confect function identifier, but received: "${identifier}". "${identifier}" is a reserved JavaScript identifier.`);
|
|
63
71
|
if (isReservedConvexFileName(identifier)) throw new Error(`Expected a valid Confect function identifier, but received: "${identifier}". "${identifier}" is a reserved Convex file name.`);
|
|
64
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Validate that `identifier` is suitable as a Convex table name (and, equivalently,
|
|
75
|
+
* as a `confect/tables/<identifier>.ts` filename).
|
|
76
|
+
*
|
|
77
|
+
* Rules:
|
|
78
|
+
* - Must match `/^[A-Za-z][A-Za-z0-9_]*$/` — letter-leading, alphanumeric plus
|
|
79
|
+
* underscore. No `$` (not a valid Convex table name character); no leading
|
|
80
|
+
* `_` (Convex reserves `_<name>` for its system tables).
|
|
81
|
+
* - Must not be a reserved JavaScript identifier, so the name can also be used
|
|
82
|
+
* as a binding name in generated code without escaping.
|
|
83
|
+
*/
|
|
84
|
+
const validateConfectTableIdentifier = (identifier) => {
|
|
85
|
+
if (!matchesTableNamePattern(identifier)) throw new Error(`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.`);
|
|
86
|
+
if (isReservedJsIdentifier(identifier)) throw new Error(`Expected a valid Confect table identifier, but received: "${identifier}". "${identifier}" is a reserved JavaScript identifier.`);
|
|
87
|
+
};
|
|
65
88
|
|
|
66
89
|
//#endregion
|
|
67
|
-
export { validateConfectFunctionIdentifier };
|
|
68
|
-
//# sourceMappingURL=
|
|
90
|
+
export { Identifier_exports, validateConfectFunctionIdentifier, validateConfectTableIdentifier };
|
|
91
|
+
//# sourceMappingURL=Identifier.js.map
|
|
@@ -0,0 +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_]*$/` — 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,0BAA0B,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;CACD,CAAC;AAEF,MAAM,6BAA6B,IAAI,IAAI;CAAC;CAAU;CAAQ;CAAQ,CAAC;AAEvE,MAAM,oBAAoB;AAM1B,MAAM,iBAAiB;AAEvB,MAAM,0BAA0B,eAC9B,wBAAwB,IAAI,WAAW;AAEzC,MAAM,4BAA4B,aAChC,2BAA2B,IAAI,SAAS;AAE1C,MAAM,8BAA8B,eAClC,kBAAkB,KAAK,WAAW;AAEpC,MAAM,2BAA2B,eAC/B,eAAe,KAAK,WAAW;AAEjC,MAAa,qCAAqC,eAAuB;AACvE,KAAI,CAAC,2BAA2B,WAAW,CACzC,OAAM,IAAI,MACR,gEAAgE,WAAW,iJAC5E;AAGH,KAAI,uBAAuB,WAAW,CACpC,OAAM,IAAI,MACR,gEAAgE,WAAW,MAAM,WAAW,wCAC7F;AAGH,KAAI,yBAAyB,WAAW,CACtC,OAAM,IAAI,MACR,gEAAgE,WAAW,MAAM,WAAW,mCAC7F;;;;;;;;;;;;;AAeL,MAAa,kCAAkC,eAAuB;AACpE,KAAI,CAAC,wBAAwB,WAAW,CACtC,OAAM,IAAI,MACR,6DAA6D,WAAW,wKACzE;AAGH,KAAI,uBAAuB,WAAW,CACpC,OAAM,IAAI,MACR,6DAA6D,WAAW,MAAM,WAAW,wCAC1F"}
|
package/dist/Lazy.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install a lazy memoised property on `target`. The first access runs
|
|
3
|
+
* `compute()` and replaces the getter with a plain, non-writable data
|
|
4
|
+
* property whose value is the computed result. Subsequent accesses hit
|
|
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
|
+
* observably indistinguishable.
|
|
8
|
+
*
|
|
9
|
+
* The replacement property is `enumerable: true` so the lazy property
|
|
10
|
+
* still participates in `Object.keys` / `JSON.stringify` after it
|
|
11
|
+
* materialises, matching the shape of a plain data property. The property
|
|
12
|
+
* is also `enumerable` before materialising, so presence checks
|
|
13
|
+
* (`"key" in target`, `Object.hasOwn(target, key)`) observe it without
|
|
14
|
+
* forcing the computation.
|
|
15
|
+
*
|
|
16
|
+
* This is the single shared implementation consumed across packages (e.g.
|
|
17
|
+
* `@confect/core`'s lazy `FunctionSpec` schemas and `@confect/server`'s lazy
|
|
18
|
+
* `Table` `Fields` / `Doc` / `tableDefinition`), so there is no chance of the
|
|
19
|
+
* two drifting apart.
|
|
20
|
+
*/
|
|
21
|
+
export declare const defineProperty: <T extends object, K extends PropertyKey>(target: T, key: K, compute: () => unknown) => void;
|
|
22
|
+
//# sourceMappingURL=Lazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Lazy.d.ts","sourceRoot":"","sources":["../src/Lazy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,WAAW,EACpE,QAAQ,CAAC,EACT,KAAK,CAAC,EACN,SAAS,MAAM,OAAO,KACrB,IAeF,CAAC"}
|
package/dist/Lazy.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
|
|
3
|
+
//#region src/Lazy.ts
|
|
4
|
+
var Lazy_exports = /* @__PURE__ */ __exportAll({ defineProperty: () => defineProperty });
|
|
5
|
+
/**
|
|
6
|
+
* Install a lazy memoised property on `target`. The first access runs
|
|
7
|
+
* `compute()` and replaces the getter with a plain, non-writable data
|
|
8
|
+
* property whose value is the computed result. Subsequent accesses hit
|
|
9
|
+
* the V8 fast path for own data properties — no function call, identical
|
|
10
|
+
* returned reference — so first and second-and-subsequent accesses are
|
|
11
|
+
* observably indistinguishable.
|
|
12
|
+
*
|
|
13
|
+
* The replacement property is `enumerable: true` so the lazy property
|
|
14
|
+
* still participates in `Object.keys` / `JSON.stringify` after it
|
|
15
|
+
* materialises, matching the shape of a plain data property. The property
|
|
16
|
+
* is also `enumerable` before materialising, so presence checks
|
|
17
|
+
* (`"key" in target`, `Object.hasOwn(target, key)`) observe it without
|
|
18
|
+
* forcing the computation.
|
|
19
|
+
*
|
|
20
|
+
* This is the single shared implementation consumed across packages (e.g.
|
|
21
|
+
* `@confect/core`'s lazy `FunctionSpec` schemas and `@confect/server`'s lazy
|
|
22
|
+
* `Table` `Fields` / `Doc` / `tableDefinition`), so there is no chance of the
|
|
23
|
+
* two drifting apart.
|
|
24
|
+
*/
|
|
25
|
+
const defineProperty = (target, key, compute) => {
|
|
26
|
+
Object.defineProperty(target, key, {
|
|
27
|
+
configurable: true,
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get() {
|
|
30
|
+
const value = compute();
|
|
31
|
+
Object.defineProperty(this, key, {
|
|
32
|
+
value,
|
|
33
|
+
writable: false,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: false
|
|
36
|
+
});
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { Lazy_exports, defineProperty };
|
|
44
|
+
//# sourceMappingURL=Lazy.js.map
|
package/dist/Lazy.js.map
ADDED
|
@@ -0,0 +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 — 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 `@confect/server`'s lazy\n * `Table` `Fields` / `Doc` / `tableDefinition`), so there is no chance of the\n * 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":";;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,kBACX,QACA,KACA,YACS;AACT,QAAO,eAAe,QAAQ,KAAK;EACjC,cAAc;EACd,YAAY;EACZ,MAAa;GACX,MAAM,QAAQ,SAAS;AACvB,UAAO,eAAe,MAAM,KAAK;IAC/B;IACA,UAAU;IACV,YAAY;IACZ,cAAc;IACf,CAAC;AACF,UAAO;;EAEV,CAAC"}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exact: true;
|
|
13
|
-
}>;
|
|
14
|
-
pageStatus: Schema.optionalWith<Schema.Union<[Schema.Literal<["SplitRecommended"]>, Schema.Literal<["SplitRequired"]>, typeof Schema.Null]>, {
|
|
15
|
-
exact: true;
|
|
16
|
-
}>;
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
export declare const PaginationResult: <Doc extends Schema.Schema.AnyNoContext>(Doc: Doc) => Schema.Struct<{
|
|
3
|
+
page: Schema.mutable<Schema.Array$<Doc>>;
|
|
4
|
+
isDone: typeof Schema.Boolean;
|
|
5
|
+
continueCursor: typeof Schema.String;
|
|
6
|
+
splitCursor: Schema.optionalWith<Schema.Union<[typeof Schema.String, typeof Schema.Null]>, {
|
|
7
|
+
exact: true;
|
|
8
|
+
}>;
|
|
9
|
+
pageStatus: Schema.optionalWith<Schema.Union<[Schema.Literal<["SplitRecommended"]>, Schema.Literal<["SplitRequired"]>, typeof Schema.Null]>, {
|
|
10
|
+
exact: true;
|
|
11
|
+
}>;
|
|
17
12
|
}>;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { PaginationResult, PaginationResult_d_exports };
|
|
20
13
|
//# sourceMappingURL=PaginationResult.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaginationResult.d.ts","
|
|
1
|
+
{"version":3,"file":"PaginationResult.d.ts","sourceRoot":"","sources":["../src/PaginationResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,eAAO,MAAM,gBAAgB,GAAI,GAAG,SAAS,MAAM,CAAC,MAAM,CAAC,YAAY,EACrE,KAAK,GAAG;;;;;;;;;;EAiBN,CAAC"}
|
package/dist/PaginationResult.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
3
|
|
|
4
4
|
//#region src/PaginationResult.ts
|
|
5
5
|
var PaginationResult_exports = /* @__PURE__ */ __exportAll({ PaginationResult: () => PaginationResult });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaginationResult.js","names":[],"sources":["../src/PaginationResult.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"PaginationResult.js","names":[],"sources":["../src/PaginationResult.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\n\nexport const PaginationResult = <Doc extends Schema.Schema.AnyNoContext>(\n Doc: Doc,\n) =>\n Schema.Struct({\n page: Schema.mutable(Schema.Array(Doc)),\n isDone: Schema.Boolean,\n continueCursor: Schema.String,\n splitCursor: Schema.optionalWith(Schema.Union(Schema.String, Schema.Null), {\n exact: true,\n }),\n pageStatus: Schema.optionalWith(\n Schema.Union(\n Schema.Literal(\"SplitRecommended\"),\n Schema.Literal(\"SplitRequired\"),\n Schema.Null,\n ),\n { exact: true },\n ),\n });\n"],"mappings":";;;;;AAEA,MAAa,oBACX,QAEA,OAAO,OAAO;CACZ,MAAM,OAAO,QAAQ,OAAO,MAAM,IAAI,CAAC;CACvC,QAAQ,OAAO;CACf,gBAAgB,OAAO;CACvB,aAAa,OAAO,aAAa,OAAO,MAAM,OAAO,QAAQ,OAAO,KAAK,EAAE,EACzE,OAAO,MACR,CAAC;CACF,YAAY,OAAO,aACjB,OAAO,MACL,OAAO,QAAQ,mBAAmB,EAClC,OAAO,QAAQ,gBAAgB,EAC/B,OAAO,KACR,EACD,EAAE,OAAO,MAAM,CAChB;CACF,CAAC"}
|