cantian-mongodb 0.0.41 → 0.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +16 -0
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
2
|
+
export type MongoBsonType = 'date' | 'objectId' | 'string' | 'int' | 'long' | 'double' | 'bool';
|
|
3
|
+
export type MongoJSONSchema = JSONSchema & {
|
|
4
|
+
bsonType?: MongoBsonType | readonly MongoBsonType[];
|
|
5
|
+
};
|
|
6
|
+
type BsonTypeToTs<T> = T extends 'date' ? Date : T extends 'objectId' ? string : T extends 'string' ? string : T extends 'int' | 'long' | 'double' ? number : T extends 'bool' ? boolean : unknown;
|
|
7
|
+
type ExtractBson<T> = T extends readonly (infer U)[] ? BsonTypeToTs<U> : BsonTypeToTs<T>;
|
|
8
|
+
export type FromMongoSchema<S extends MongoJSONSchema> = S extends {
|
|
9
|
+
bsonType: infer B;
|
|
10
|
+
} ? ExtractBson<B> : S extends {
|
|
11
|
+
type: 'object';
|
|
12
|
+
properties: infer P;
|
|
13
|
+
} ? {
|
|
14
|
+
[K in keyof P]: P[K] extends MongoJSONSchema ? FromMongoSchema<P[K]> : never;
|
|
15
|
+
} : FromSchema<S>;
|
|
16
|
+
export {};
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":""}
|