joist-orm 1.210.0 → 1.211.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/Aliases.d.ts +2 -1
- package/build/Aliases.d.ts.map +1 -1
- package/build/Aliases.js.map +1 -1
- package/build/EntityFilter.d.ts +2 -1
- package/build/EntityFilter.d.ts.map +1 -1
- package/build/EntityGraphQLFilter.d.ts +1 -1
- package/build/EntityGraphQLFilter.d.ts.map +1 -1
- package/build/EntityManager.d.ts +1 -53
- package/build/EntityManager.d.ts.map +1 -1
- package/build/EntityManager.js.map +1 -1
- package/build/changes.d.ts +2 -1
- package/build/changes.d.ts.map +1 -1
- package/build/changes.js.map +1 -1
- package/build/configure.d.ts.map +1 -1
- package/build/configure.js +2 -1
- package/build/configure.js.map +1 -1
- package/build/createOrUpdatePartial.d.ts +2 -1
- package/build/createOrUpdatePartial.d.ts.map +1 -1
- package/build/createOrUpdatePartial.js.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.d.ts +2 -1
- package/build/dataloaders/findOrCreateDataLoader.d.ts.map +1 -1
- package/build/dataloaders/findOrCreateDataLoader.js.map +1 -1
- package/build/index.d.ts +3 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/loadHints.d.ts +1 -1
- package/build/loadHints.d.ts.map +1 -1
- package/build/loadHints.js.map +1 -1
- package/build/newTestInstance.d.ts +2 -1
- package/build/newTestInstance.d.ts.map +1 -1
- package/build/newTestInstance.js.map +1 -1
- package/build/reactiveHints.d.ts +4 -9
- package/build/reactiveHints.d.ts.map +1 -1
- package/build/reactiveHints.js.map +1 -1
- package/build/rules.d.ts +2 -2
- package/build/rules.d.ts.map +1 -1
- package/build/rules.js.map +1 -1
- package/build/typeMap.d.ts +66 -0
- package/build/typeMap.d.ts.map +1 -0
- package/build/typeMap.js +3 -0
- package/build/typeMap.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Entity } from "./Entity";
|
|
2
|
+
import { EntityManager } from "./EntityManager";
|
|
3
|
+
/**
|
|
4
|
+
* Provides a container for entities to attach their application-specific types.
|
|
5
|
+
*
|
|
6
|
+
* Downstream applications inject their types into this map, so we can look them up
|
|
7
|
+
* via types like `OptsOf<Author>` or `FilterOf<Author>`, by including a `declare module`
|
|
8
|
+
* snippet in each entity's `...Codegen` file.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* declare module "joist-orm" {
|
|
12
|
+
* interface TypeMap {
|
|
13
|
+
* Author: { optsType: AuthorOpts; fieldsType: AuthorFields; filterType: AuthorFilter };
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Inspired by Tanstack Router, which uses a similar `declare module` approach.
|
|
19
|
+
*/
|
|
20
|
+
export interface TypeMap {
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns a key like `"Author"` or `"SmallPublisher"` for looking up types in the `TypeMap`.
|
|
24
|
+
*
|
|
25
|
+
* This is currently hard-coded to look for two levels of inheritance: we probe for the subtype
|
|
26
|
+
* key (1) first, and then fallback on the base type key (0) that all entities will have.
|
|
27
|
+
*/
|
|
28
|
+
type TypeMapKey<T> = T extends {
|
|
29
|
+
__type: {
|
|
30
|
+
1: infer K;
|
|
31
|
+
};
|
|
32
|
+
} ? K : T extends {
|
|
33
|
+
__type: {
|
|
34
|
+
0: infer K;
|
|
35
|
+
};
|
|
36
|
+
} ? K : never;
|
|
37
|
+
/** A helper type to look up `U` in the `TypeMap` for a given entity type `T`. */
|
|
38
|
+
export type TypeMapEntry<T, U extends string> = TypeMapKey<T> extends infer K ? (K extends keyof TypeMap ? TypeMap[K][U] : unknown) : unknown;
|
|
39
|
+
/** Return the `FooOpts` type for the given `Foo` entity. */
|
|
40
|
+
export type OptsOf<T> = TypeMapEntry<T, "optsType">;
|
|
41
|
+
/** Return the `FooFields` type for the given `Foo` entity. */
|
|
42
|
+
export type FieldsOf<T> = TypeMapEntry<T, "fieldsType">;
|
|
43
|
+
export type OptIdsOf<T> = TypeMapEntry<T, "optIdsType">;
|
|
44
|
+
/** Pulls the entity query type out of a given entity type T. */
|
|
45
|
+
export type FilterOf<T> = TypeMapEntry<T, "filterType">;
|
|
46
|
+
/** Pulls the entity GraphQL query type out of a given entity type T. */
|
|
47
|
+
export type GraphQLFilterOf<T> = TypeMapEntry<T, "gqlFilterType">;
|
|
48
|
+
/** Pulls the entity order type out of a given entity type T. */
|
|
49
|
+
export type OrderOf<T> = TypeMapEntry<T, "orderType">;
|
|
50
|
+
/**
|
|
51
|
+
* Returns the opts of the entity's `newEntity` factory method, as exists in the actual file.
|
|
52
|
+
*
|
|
53
|
+
* This is because `FactoryOpts` is a set of defaults, but the user can customize it if they want.
|
|
54
|
+
*/
|
|
55
|
+
export type ActualFactoryOpts<T> = TypeMapEntry<T, "factoryOptsType">;
|
|
56
|
+
/** Return the `Foo` type for a given `Foo` entity constructor. */
|
|
57
|
+
export type EntityOf<C> = C extends new (em: EntityManager, opts: any) => infer T ? T : never;
|
|
58
|
+
type RelationsKeysOf<T> = {
|
|
59
|
+
[K in keyof OptsOf<T>]: OptsOf<T>[K] extends Entity[] | undefined ? K : never;
|
|
60
|
+
}[keyof OptsOf<T>];
|
|
61
|
+
/** Return the Relation keys from `FooOpt` type, given a `Foo` entity */
|
|
62
|
+
export type RelationsOf<T extends Entity> = {
|
|
63
|
+
[K in RelationsKeysOf<T>]: NonNullable<OptsOf<T>[K]>;
|
|
64
|
+
};
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=typeMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeMap.d.ts","sourceRoot":"","sources":["../src/typeMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB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AY,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;AAEtE,kEAAkE;AAClE,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE9F,KAAK,eAAe,CAAC,CAAC,IAAI;KACvB,CAAC,IAAI,MAAM,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,CAAC,GAAG,KAAK;CAC9E,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAEnB,wEAAwE;AACxE,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI;KACzC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACrD,CAAC"}
|
package/build/typeMap.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeMap.js","sourceRoot":"","sources":["../src/typeMap.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "joist-orm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.211.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@types/object-hash": "^3.0.6",
|
|
23
23
|
"ansis": "^3.3.2",
|
|
24
24
|
"dataloader": "^2.2.2",
|
|
25
|
-
"joist-utils": "1.
|
|
25
|
+
"joist-utils": "1.211.0",
|
|
26
26
|
"knex": "^3.1.0",
|
|
27
27
|
"object-hash": "^3.0.0",
|
|
28
28
|
"pg": "^8.13.0",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"temporal-polyfill": "^0.2.5",
|
|
40
40
|
"ts-node-dev": "^2.0.0",
|
|
41
41
|
"tsconfig-paths": "^4.2.0",
|
|
42
|
-
"typescript": "5.
|
|
42
|
+
"typescript": "5.6.3"
|
|
43
43
|
}
|
|
44
44
|
}
|