@confect/server 9.1.0 → 9.1.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@confect/server",
3
3
  "description": "Backend bindings to the Convex platform",
4
- "version": "9.1.0",
4
+ "version": "9.1.2",
5
5
  "author": "RJ Dellecese",
6
6
  "bugs": {
7
7
  "url": "https://github.com/rjdellecese/confect/issues"
@@ -68,7 +68,7 @@
68
68
  "@effect/platform-node": "^0.106.0",
69
69
  "convex": "^1.32.0",
70
70
  "effect": "^3.21.2",
71
- "@confect/core": "^9.1.0"
71
+ "@confect/core": "^9.1.2"
72
72
  },
73
73
  "peerDependenciesMeta": {
74
74
  "@effect/platform-node": {
@@ -123,7 +123,7 @@ export const make = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(
123
123
  const patch = (
124
124
  id: GenericId<TableName>,
125
125
  patchedValues: Partial<
126
- WithoutSystemFields<DocumentByName_<DataModel_, TableName>>
126
+ Document.WithoutSystemFields<DocumentByName_<DataModel_, TableName>>
127
127
  >,
128
128
  ) =>
129
129
  Effect.gen(function* () {
@@ -162,7 +162,9 @@ export const make = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(
162
162
 
163
163
  const replace = (
164
164
  id: GenericId<TableName>,
165
- value: WithoutSystemFields<DocumentByName_<DataModel_, TableName>>,
165
+ value: Document.WithoutSystemFields<
166
+ DocumentByName_<DataModel_, TableName>
167
+ >,
166
168
  ) =>
167
169
  Effect.gen(function* () {
168
170
  const updatedEncodedDoc = yield* Document.encode(
package/src/Document.ts CHANGED
@@ -15,7 +15,9 @@ export type Document<
15
15
  TableName extends DatabaseSchema.TableNames<Schema_>,
16
16
  > = DataModel.DocumentByName<DataModel.FromSchema<Schema_>, TableName>;
17
17
 
18
- export type WithoutSystemFields<Doc> = Omit<Doc, "_creationTime" | "_id">;
18
+ export type WithoutSystemFields<Doc> = Doc extends unknown
19
+ ? Omit<Doc, "_creationTime" | "_id">
20
+ : never;
19
21
 
20
22
  export type Any = any;
21
23
  export type AnyEncoded = ReadonlyRecord<string, ReadonlyValue>;
package/src/TableInfo.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import type {
2
- Expand,
3
2
  GenericDocument,
4
3
  GenericFieldPaths,
5
4
  GenericTableIndexes,
@@ -20,7 +19,7 @@ export type TypeId = typeof TypeId;
20
19
  export type TableInfo<Table_ extends Table.AnyWithProps> =
21
20
  Table_ extends Table.Table<
22
21
  infer TableName,
23
- infer _TableSchema,
22
+ infer TableSchema_,
24
23
  infer TableValidator,
25
24
  infer Indexes,
26
25
  infer SearchIndexes,
@@ -28,8 +27,14 @@ export type TableInfo<Table_ extends Table.AnyWithProps> =
28
27
  >
29
28
  ? {
30
29
  readonly [TypeId]: TypeId;
31
- readonly document: Table_["Doc"]["Type"];
32
- readonly encodedDocument: Table_["Doc"]["Encoded"];
30
+ readonly document: WithSystemFields<
31
+ TableName,
32
+ Schema.Schema.Type<TableSchema_>
33
+ >;
34
+ readonly encodedDocument: WithSystemFields<
35
+ TableName,
36
+ Schema.Schema.Encoded<TableSchema_>
37
+ >;
33
38
  readonly convexDocument: ExtractConvexDocument<
34
39
  TableName,
35
40
  TableValidator
@@ -72,6 +77,10 @@ export type TableSchema<TableInfo_ extends AnyWithProps> = Schema.Schema<
72
77
 
73
78
  export type Document<TableInfo_ extends AnyWithProps> = TableInfo_["document"];
74
79
 
80
+ type WithSystemFields<TableName extends string, Doc> = Doc extends unknown
81
+ ? IdField<TableName> & SystemFields & Doc
82
+ : never;
83
+
75
84
  // Vendored types from convex-js, partially modified.
76
85
  // See https://github.com/get-convex/convex-js/pull/14
77
86
 
@@ -83,8 +92,8 @@ type ExtractConvexDocument<
83
92
  TableName extends string,
84
93
  T extends GenericValidator,
85
94
  > =
86
- Expand<IdField<TableName> & SystemFields & T["type"]> extends GenericDocument
87
- ? Expand<IdField<TableName> & SystemFields & T["type"]>
95
+ WithSystemFields<TableName, T["type"]> extends GenericDocument
96
+ ? WithSystemFields<TableName, T["type"]>
88
97
  : never;
89
98
 
90
99
  // End of vendored types from convex-js, partially modified.