@akanjs/constant 0.0.28 → 0.0.29
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 +1 -1
- package/src/baseGql.d.ts +6 -11
- package/src/baseGql.js +73 -59
- package/src/filterMeta.d.ts +21 -0
- package/src/filterMeta.js +38 -2
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -19
- package/src/scalar.d.ts +1 -0
- package/src/scalar.js +5 -0
- package/src/types.d.ts +1 -0
- package/src/base_temp.d.ts +0 -3
- package/src/base_temp.js +0 -45
package/package.json
CHANGED
package/src/baseGql.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import { BaseObject, Type } from "@akanjs/base";
|
|
3
|
-
|
|
4
|
-
export declare
|
|
5
|
-
export declare
|
|
6
|
-
export declare
|
|
7
|
-
export declare
|
|
8
|
-
|
|
9
|
-
export declare function Light<T, F extends NonFunctionalKeys<Omit<T, "id" | "createdAt" | "updatedAt" | "removedAt">>>(objectRef: Type<T>, fields: readonly F[]): Type<{
|
|
10
|
-
[K in F]: T[K];
|
|
11
|
-
} & BaseObject>;
|
|
12
|
-
export declare function Full<A, B = undefined>(modelRef: Type<A>, lightRef: Type<B>, overwriteRef?: Type, overwriteLightRef?: Type): Type<Omit<A, keyof B> & B>;
|
|
13
|
-
export {};
|
|
3
|
+
import type { NonFunctionalKeys } from "./types";
|
|
4
|
+
export declare const as: <T>(modelRef: Type<T>) => Type<T>;
|
|
5
|
+
export declare const via: <T, LightOrFields extends readonly NonFunctionalKeys<Omit<T, "id" | "createdAt" | "updatedAt" | "removedAt">>[] | Type | undefined = undefined>(modelRef: Type<T>, fieldsOrLightModelRef?: LightOrFields, overwriteRef?: Type, overwriteLightRef?: Type) => LightOrFields extends undefined ? Type<T & BaseObject> : LightOrFields extends Type<infer Light> ? Type<T & Light & BaseObject> : LightOrFields extends readonly NonFunctionalKeys<Omit<T, "id" | "createdAt" | "updatedAt" | "removedAt">>[] ? Type<{ [K in LightOrFields[number]]: T[K]; } & BaseObject> : never;
|
|
6
|
+
export declare const from: <A, T1, T2 = unknown, T3 = unknown, T4 = unknown, T5 = unknown, T6 = unknown, T7 = unknown, T8 = unknown, T9 = unknown, T10 = unknown>(modelRef: Type<A>, t1: Type<T1>, t2?: Type<T2>, t3?: Type<T3>, t4?: Type<T4>, t5?: Type<T5>, t6?: Type<T6>, t7?: Type<T7>, t8?: Type<T8>, t9?: Type<T9>, t10?: Type<T10>) => Type<A & T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9 & T10>;
|
|
7
|
+
export declare const mixModelOf: <T1 = unknown, T2 = unknown, T3 = unknown, T4 = unknown, T5 = unknown, T6 = unknown, T7 = unknown, T8 = unknown, T9 = unknown, T10 = unknown, T11 = unknown, T12 = unknown, T13 = unknown, T14 = unknown, T15 = unknown, T16 = unknown, T17 = unknown, T18 = unknown, T19 = unknown, T20 = unknown>(t1: Type<T1>, t2?: Type<T2>, t3?: Type<T3>, t4?: Type<T4>, t5?: Type<T5>, t6?: Type<T6>, t7?: Type<T7>, t8?: Type<T8>, t9?: Type<T9>, t10?: Type<T10>, t11?: Type<T11>, t12?: Type<T12>, t13?: Type<T13>, t14?: Type<T14>, t15?: Type<T15>, t16?: Type<T16>, t17?: Type<T17>, t18?: Type<T18>, t19?: Type<T19>, t20?: Type<T20>) => Type<T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9 & T10 & T11 & T12 & T13 & T14 & T15 & T16 & T17 & T18 & T19 & T20>;
|
|
8
|
+
export declare const over: <T1 = unknown, T2 = unknown, T3 = unknown, T4 = unknown, T5 = unknown, T6 = unknown, T7 = unknown, T8 = unknown, T9 = unknown, T10 = unknown, T11 = unknown, T12 = unknown, T13 = unknown, T14 = unknown, T15 = unknown, T16 = unknown, T17 = unknown, T18 = unknown, T19 = unknown, T20 = unknown>(t1: Type<T1>, t2?: Type<T2>, t3?: Type<T3>, t4?: Type<T4>, t5?: Type<T5>, t6?: Type<T6>, t7?: Type<T7>, t8?: Type<T8>, t9?: Type<T9>, t10?: Type<T10>, t11?: Type<T11>, t12?: Type<T12>, t13?: Type<T13>, t14?: Type<T14>, t15?: Type<T15>, t16?: Type<T16>, t17?: Type<T17>, t18?: Type<T18>, t19?: Type<T19>, t20?: Type<T20>) => Type<T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9 & T10 & T11 & T12 & T13 & T14 & T15 & T16 & T17 & T18 & T19 & T20>;
|
package/src/baseGql.js
CHANGED
|
@@ -6,24 +6,22 @@ var __export = (target, all) => {
|
|
|
6
6
|
for (var name in all)
|
|
7
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
8
|
};
|
|
9
|
-
var __copyProps = (to,
|
|
10
|
-
if (
|
|
11
|
-
for (let key of __getOwnPropNames(
|
|
9
|
+
var __copyProps = (to, from2, except, desc) => {
|
|
10
|
+
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from2))
|
|
12
12
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () =>
|
|
13
|
+
__defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
|
|
14
14
|
}
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var baseGql_exports = {};
|
|
19
19
|
__export(baseGql_exports, {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Light: () => Light,
|
|
26
|
-
MixModels: () => MixModels
|
|
20
|
+
as: () => as,
|
|
21
|
+
from: () => from,
|
|
22
|
+
mixModelOf: () => mixModelOf,
|
|
23
|
+
over: () => over,
|
|
24
|
+
via: () => via
|
|
27
25
|
});
|
|
28
26
|
module.exports = __toCommonJS(baseGql_exports);
|
|
29
27
|
var import_reflect_metadata = require("reflect-metadata");
|
|
@@ -55,15 +53,16 @@ const removedAtFieldMeta = {
|
|
|
55
53
|
nullable: true,
|
|
56
54
|
default: null
|
|
57
55
|
};
|
|
58
|
-
|
|
59
|
-
class
|
|
56
|
+
const extendModel = (modelRef) => {
|
|
57
|
+
class BaseModel {
|
|
60
58
|
}
|
|
61
59
|
const metadataMap = (0, import_scalar.getFieldMetaMap)(modelRef);
|
|
62
|
-
(0, import_scalar.setFieldMetaMap)(
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
(0, import_scalar.setFieldMetaMap)(BaseModel, metadataMap);
|
|
61
|
+
return BaseModel;
|
|
62
|
+
};
|
|
63
|
+
const as = extendModel;
|
|
64
|
+
const baseModelOf = (modelRef) => {
|
|
65
|
+
class BaseModel {
|
|
67
66
|
__ModelType__ = "full";
|
|
68
67
|
}
|
|
69
68
|
const metadataMap = (0, import_scalar.getFieldMetaMap)(modelRef);
|
|
@@ -71,10 +70,43 @@ function BaseModel(modelRef) {
|
|
|
71
70
|
metadataMap.set("createdAt", createdAtFieldMeta);
|
|
72
71
|
metadataMap.set("updatedAt", updatedAtFieldMeta);
|
|
73
72
|
metadataMap.set("removedAt", removedAtFieldMeta);
|
|
74
|
-
Reflect.defineMetadata("fields", metadataMap,
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
|
|
73
|
+
Reflect.defineMetadata("fields", metadataMap, BaseModel.prototype);
|
|
74
|
+
return BaseModel;
|
|
75
|
+
};
|
|
76
|
+
const lightModelOf = (objectRef, fields) => {
|
|
77
|
+
const map = /* @__PURE__ */ new Map();
|
|
78
|
+
const metadataMap = (0, import_scalar.getFieldMetaMap)(objectRef);
|
|
79
|
+
class BaseGql {
|
|
80
|
+
__ModelType__ = "light";
|
|
81
|
+
}
|
|
82
|
+
["id", ...fields, "createdAt", "updatedAt", "removedAt"].forEach((key) => map.set(key, metadataMap.get(key)));
|
|
83
|
+
Reflect.defineMetadata("fields", map, BaseGql.prototype);
|
|
84
|
+
return BaseGql;
|
|
85
|
+
};
|
|
86
|
+
const fullModelOf = (modelRef, lightRef, overwriteRef, overwriteLightRef) => {
|
|
87
|
+
const modelFieldMetaMap = (0, import_scalar.getFieldMetaMap)(modelRef);
|
|
88
|
+
const lightFieldMetaMap = (0, import_scalar.getFieldMetaMap)(lightRef);
|
|
89
|
+
(0, import_common.applyMixins)(modelRef, [lightRef]);
|
|
90
|
+
if (overwriteRef) {
|
|
91
|
+
(0, import_common.applyMixins)(overwriteRef, [modelRef]);
|
|
92
|
+
(0, import_scalar.setFieldMetaMap)(overwriteRef, modelFieldMetaMap);
|
|
93
|
+
}
|
|
94
|
+
if (overwriteLightRef) {
|
|
95
|
+
(0, import_common.applyMixins)(overwriteLightRef, [lightRef]);
|
|
96
|
+
(0, import_scalar.setFieldMetaMap)(overwriteLightRef, lightFieldMetaMap);
|
|
97
|
+
}
|
|
98
|
+
(0, import_scalar.setFieldMetaMap)(modelRef, new Map([...modelFieldMetaMap, ...lightFieldMetaMap]));
|
|
99
|
+
return modelRef;
|
|
100
|
+
};
|
|
101
|
+
const via = (modelRef, fieldsOrLightModelRef, overwriteRef, overwriteLightRef) => {
|
|
102
|
+
if (!fieldsOrLightModelRef)
|
|
103
|
+
return baseModelOf(modelRef);
|
|
104
|
+
else if (Array.isArray(fieldsOrLightModelRef))
|
|
105
|
+
return lightModelOf(modelRef, fieldsOrLightModelRef);
|
|
106
|
+
else
|
|
107
|
+
return fullModelOf(modelRef, fieldsOrLightModelRef, overwriteRef, overwriteLightRef);
|
|
108
|
+
};
|
|
109
|
+
const addModelOf = (modelRef, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => {
|
|
78
110
|
const modelMetadataMap = (0, import_scalar.getFieldMetaMap)(modelRef);
|
|
79
111
|
const metadataMap = new Map(
|
|
80
112
|
[t1, t2, t3, t4, t5, t6, t7, t8, t9, t10].filter((t) => !!t).reduce((acc, writeRef) => {
|
|
@@ -85,8 +117,8 @@ function AddModel(modelRef, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) {
|
|
|
85
117
|
);
|
|
86
118
|
(0, import_scalar.setFieldMetaMap)(modelRef, metadataMap);
|
|
87
119
|
return modelRef;
|
|
88
|
-
}
|
|
89
|
-
|
|
120
|
+
};
|
|
121
|
+
const addFilterOf = (filterRef, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => {
|
|
90
122
|
const filterMeta = (0, import_filterMeta.getFilterMeta)(filterRef);
|
|
91
123
|
const filterQueryMap = (0, import_filterMeta.getFilterQueryMap)(filterRef);
|
|
92
124
|
const metadataMap = new Map(
|
|
@@ -107,8 +139,16 @@ function AddFilter(filterRef, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) {
|
|
|
107
139
|
(0, import_filterMeta.setFilterKeyMetaMapOnPrototype)(filterRef.prototype, metadataMap);
|
|
108
140
|
(0, import_filterMeta.setFilterMeta)(filterRef, { ...filterMeta, sort: filterSort });
|
|
109
141
|
return filterRef;
|
|
110
|
-
}
|
|
111
|
-
|
|
142
|
+
};
|
|
143
|
+
const from = (modelRef, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => {
|
|
144
|
+
if ((0, import_scalar.isConstantModel)(modelRef))
|
|
145
|
+
return addModelOf(modelRef, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10);
|
|
146
|
+
else if ((0, import_filterMeta.isFilterModel)(modelRef))
|
|
147
|
+
return addFilterOf(modelRef, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10);
|
|
148
|
+
else
|
|
149
|
+
throw new Error("Invalid modelRef");
|
|
150
|
+
};
|
|
151
|
+
const mixModelOf = (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20) => {
|
|
112
152
|
class Mix {
|
|
113
153
|
}
|
|
114
154
|
const metadataMap = new Map(
|
|
@@ -120,39 +160,13 @@ function MixModels(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14,
|
|
|
120
160
|
);
|
|
121
161
|
(0, import_scalar.setFieldMetaMap)(Mix, metadataMap);
|
|
122
162
|
return Mix;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const map = /* @__PURE__ */ new Map();
|
|
126
|
-
const metadataMap = (0, import_scalar.getFieldMetaMap)(objectRef);
|
|
127
|
-
class BaseGql {
|
|
128
|
-
__ModelType__ = "light";
|
|
129
|
-
}
|
|
130
|
-
["id", ...fields, "createdAt", "updatedAt", "removedAt"].forEach((key) => map.set(key, metadataMap.get(key)));
|
|
131
|
-
Reflect.defineMetadata("fields", map, BaseGql.prototype);
|
|
132
|
-
return BaseGql;
|
|
133
|
-
}
|
|
134
|
-
function Full(modelRef, lightRef, overwriteRef, overwriteLightRef) {
|
|
135
|
-
const modelFieldMetaMap = (0, import_scalar.getFieldMetaMap)(modelRef);
|
|
136
|
-
const lightFieldMetaMap = (0, import_scalar.getFieldMetaMap)(lightRef);
|
|
137
|
-
(0, import_common.applyMixins)(modelRef, [lightRef]);
|
|
138
|
-
if (overwriteRef) {
|
|
139
|
-
(0, import_common.applyMixins)(overwriteRef, [modelRef]);
|
|
140
|
-
(0, import_scalar.setFieldMetaMap)(overwriteRef, modelFieldMetaMap);
|
|
141
|
-
}
|
|
142
|
-
if (overwriteLightRef) {
|
|
143
|
-
(0, import_common.applyMixins)(overwriteLightRef, [lightRef]);
|
|
144
|
-
(0, import_scalar.setFieldMetaMap)(overwriteLightRef, lightFieldMetaMap);
|
|
145
|
-
}
|
|
146
|
-
(0, import_scalar.setFieldMetaMap)(modelRef, new Map([...modelFieldMetaMap, ...lightFieldMetaMap]));
|
|
147
|
-
return modelRef;
|
|
148
|
-
}
|
|
163
|
+
};
|
|
164
|
+
const over = mixModelOf;
|
|
149
165
|
// Annotate the CommonJS export names for ESM import in node:
|
|
150
166
|
0 && (module.exports = {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
Light,
|
|
157
|
-
MixModels
|
|
167
|
+
as,
|
|
168
|
+
from,
|
|
169
|
+
mixModelOf,
|
|
170
|
+
over,
|
|
171
|
+
via
|
|
158
172
|
});
|
package/src/filterMeta.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Type } from "@akanjs/base";
|
|
2
2
|
import { type ConstantFilterMeta, type FilterArgMeta, type FilterArgProps, type FilterKeyMeta, type FilterKeyProps, type ReturnType } from "./scalar";
|
|
3
3
|
import type { QueryOf, SortType } from "./types";
|
|
4
|
+
export declare const isFilterModel: (filterRef: Type) => boolean;
|
|
4
5
|
export declare const getFilterMeta: (filterRef: Type) => ConstantFilterMeta;
|
|
5
6
|
export declare const setFilterMeta: (filterRef: Type, filterMeta: ConstantFilterMeta) => void;
|
|
6
7
|
export declare const getFilterKeyMetaMapOnPrototype: (prototype: object) => Map<string, FilterKeyMeta>;
|
|
@@ -18,6 +19,26 @@ export declare const Filter: {
|
|
|
18
19
|
Arg: (name: string, returns: ReturnType, argOption?: FilterArgProps | FilterArgProps[]) => (prototype: object, key: string, idx: number) => void;
|
|
19
20
|
};
|
|
20
21
|
export type BaseFilterKey = "latest" | "oldest" | "any" | "byStatuses";
|
|
22
|
+
export declare const sortOf: <Sort extends SortType>(modelRef: Type, sort: Sort) => Type<{
|
|
23
|
+
latest: {
|
|
24
|
+
createdAt: number;
|
|
25
|
+
};
|
|
26
|
+
oldest: {
|
|
27
|
+
createdAt: number;
|
|
28
|
+
};
|
|
29
|
+
any(): {
|
|
30
|
+
removedAt: {
|
|
31
|
+
$exists: boolean;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
byStatuses(statuses: string[] | null): {
|
|
35
|
+
status: {
|
|
36
|
+
$in: string[];
|
|
37
|
+
};
|
|
38
|
+
} | {
|
|
39
|
+
status?: undefined;
|
|
40
|
+
};
|
|
41
|
+
} & Sort>;
|
|
21
42
|
export declare function BaseFilter<Sort extends SortType>(modelRef: Type, sort: Sort): Type<{
|
|
22
43
|
latest: {
|
|
23
44
|
createdAt: number;
|
package/src/filterMeta.js
CHANGED
|
@@ -36,13 +36,18 @@ __export(filterMeta_exports, {
|
|
|
36
36
|
getFilterQueryMap: () => getFilterQueryMap,
|
|
37
37
|
getFilterSort: () => getFilterSort,
|
|
38
38
|
getFilterSortMap: () => getFilterSortMap,
|
|
39
|
+
isFilterModel: () => isFilterModel,
|
|
39
40
|
setFilterArgMetasOnPrototype: () => setFilterArgMetasOnPrototype,
|
|
40
41
|
setFilterKeyMetaMapOnPrototype: () => setFilterKeyMetaMapOnPrototype,
|
|
41
|
-
setFilterMeta: () => setFilterMeta
|
|
42
|
+
setFilterMeta: () => setFilterMeta,
|
|
43
|
+
sortOf: () => sortOf
|
|
42
44
|
});
|
|
43
45
|
module.exports = __toCommonJS(filterMeta_exports);
|
|
44
46
|
var import_base = require("@akanjs/base");
|
|
45
47
|
var import_scalar = require("./scalar");
|
|
48
|
+
const isFilterModel = (filterRef) => {
|
|
49
|
+
return Reflect.getMetadata("filter", filterRef.prototype) !== void 0;
|
|
50
|
+
};
|
|
46
51
|
const getFilterMeta = (filterRef) => {
|
|
47
52
|
const filterMeta = Reflect.getMetadata("filter", filterRef.prototype);
|
|
48
53
|
if (!filterMeta)
|
|
@@ -119,6 +124,35 @@ const Filter = {
|
|
|
119
124
|
// Meili: makeFilter({ fieldType: "hidden", nullable: true }),
|
|
120
125
|
Arg: applyFilterArgMeta
|
|
121
126
|
};
|
|
127
|
+
const sortOf = (modelRef, sort) => {
|
|
128
|
+
const fieldMetaMap = (0, import_scalar.getFieldMetaMap)(modelRef);
|
|
129
|
+
const statusFieldMeta = fieldMetaMap.get("status");
|
|
130
|
+
if (!statusFieldMeta)
|
|
131
|
+
throw new Error(`No status field meta fount in ${modelRef.name}`);
|
|
132
|
+
class BaseFilter2 {
|
|
133
|
+
latest = { createdAt: -1 };
|
|
134
|
+
oldest = { createdAt: 1 };
|
|
135
|
+
any() {
|
|
136
|
+
return { removedAt: { $exists: false } };
|
|
137
|
+
}
|
|
138
|
+
byStatuses(statuses) {
|
|
139
|
+
return statuses?.length ? { status: { $in: statuses } } : {};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
__decorateClass([
|
|
143
|
+
Filter.Mongo()
|
|
144
|
+
], BaseFilter2.prototype, "any", 1);
|
|
145
|
+
__decorateClass([
|
|
146
|
+
Filter.Mongo(),
|
|
147
|
+
__decorateParam(0, Filter.Arg("statuses", () => [String], { nullable: true, enum: statusFieldMeta?.enum }))
|
|
148
|
+
], BaseFilter2.prototype, "byStatuses", 1);
|
|
149
|
+
Object.assign(BaseFilter2.prototype, sort);
|
|
150
|
+
setFilterMeta(BaseFilter2, {
|
|
151
|
+
refName: "BaseFilter",
|
|
152
|
+
sort: Object.assign({ latest: { createdAt: -1 }, oldest: { createdAt: 1 } }, sort)
|
|
153
|
+
});
|
|
154
|
+
return BaseFilter2;
|
|
155
|
+
};
|
|
122
156
|
function BaseFilter(modelRef, sort) {
|
|
123
157
|
const fieldMetaMap = (0, import_scalar.getFieldMetaMap)(modelRef);
|
|
124
158
|
const statusFieldMeta = fieldMetaMap.get("status");
|
|
@@ -159,7 +193,9 @@ function BaseFilter(modelRef, sort) {
|
|
|
159
193
|
getFilterQueryMap,
|
|
160
194
|
getFilterSort,
|
|
161
195
|
getFilterSortMap,
|
|
196
|
+
isFilterModel,
|
|
162
197
|
setFilterArgMetasOnPrototype,
|
|
163
198
|
setFilterKeyMetaMapOnPrototype,
|
|
164
|
-
setFilterMeta
|
|
199
|
+
setFilterMeta,
|
|
200
|
+
sortOf
|
|
165
201
|
});
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
5
|
var __copyProps = (to, from, except, desc) => {
|
|
12
6
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
7
|
for (let key of __getOwnPropNames(from))
|
|
@@ -17,21 +11,9 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
11
|
return to;
|
|
18
12
|
};
|
|
19
13
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
15
|
var src_exports = {};
|
|
30
|
-
__export(src_exports, {
|
|
31
|
-
base: () => base
|
|
32
|
-
});
|
|
33
16
|
module.exports = __toCommonJS(src_exports);
|
|
34
|
-
var base = __toESM(require("./base_temp"));
|
|
35
17
|
__reExport(src_exports, require("./types"), module.exports);
|
|
36
18
|
__reExport(src_exports, require("./fieldMeta"), module.exports);
|
|
37
19
|
__reExport(src_exports, require("./scalar"), module.exports);
|
|
@@ -41,7 +23,6 @@ __reExport(src_exports, require("./baseGql"), module.exports);
|
|
|
41
23
|
__reExport(src_exports, require("./classMeta"), module.exports);
|
|
42
24
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
25
|
0 && (module.exports = {
|
|
44
|
-
base,
|
|
45
26
|
...require("./types"),
|
|
46
27
|
...require("./fieldMeta"),
|
|
47
28
|
...require("./scalar"),
|
package/src/scalar.d.ts
CHANGED
|
@@ -81,6 +81,7 @@ export type ConstantFieldMeta = ConstantFieldProps & {
|
|
|
81
81
|
};
|
|
82
82
|
export declare const getClassMeta: (modelRef: Type) => ConstantClassMeta;
|
|
83
83
|
export declare const getFieldMetas: (modelRef: Type) => ConstantFieldMeta[];
|
|
84
|
+
export declare const isConstantModel: (modelRef: Type) => boolean;
|
|
84
85
|
export declare const getFieldMetaMap: (modelRef: Type) => Map<string, ConstantFieldMeta>;
|
|
85
86
|
export declare const setFieldMetaMap: (modelRef: Type, metadataMap: Map<string, ConstantFieldMeta>) => void;
|
|
86
87
|
export declare const getFieldMetaMapOnPrototype: (prototype: object) => Map<string, ConstantFieldMeta>;
|
package/src/scalar.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(scalar_exports, {
|
|
|
25
25
|
getGqlTypeStr: () => getGqlTypeStr,
|
|
26
26
|
getQueryMap: () => getQueryMap,
|
|
27
27
|
getScalarExample: () => getScalarExample,
|
|
28
|
+
isConstantModel: () => isConstantModel,
|
|
28
29
|
scalarExampleMap: () => scalarExampleMap,
|
|
29
30
|
setFieldMetaMap: () => setFieldMetaMap,
|
|
30
31
|
setFieldMetaMapOnPrototype: () => setFieldMetaMapOnPrototype
|
|
@@ -59,6 +60,9 @@ const getFieldMetas = (modelRef) => {
|
|
|
59
60
|
const keySortMap = { id: -1, createdAt: 1, updatedAt: 2, removedAt: 3 };
|
|
60
61
|
return [...metadataMap.values()].sort((a, b) => (keySortMap[a.key] ?? 0) - (keySortMap[b.key] ?? 0));
|
|
61
62
|
};
|
|
63
|
+
const isConstantModel = (modelRef) => {
|
|
64
|
+
return Reflect.getMetadata("class", modelRef.prototype) !== void 0;
|
|
65
|
+
};
|
|
62
66
|
const getFieldMetaMap = (modelRef) => {
|
|
63
67
|
const [target] = (0, import_base.getNonArrayModel)(modelRef);
|
|
64
68
|
const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
|
|
@@ -91,6 +95,7 @@ const getQueryMap = (modelRef) => {
|
|
|
91
95
|
getGqlTypeStr,
|
|
92
96
|
getQueryMap,
|
|
93
97
|
getScalarExample,
|
|
98
|
+
isConstantModel,
|
|
94
99
|
scalarExampleMap,
|
|
95
100
|
setFieldMetaMap,
|
|
96
101
|
setFieldMetaMapOnPrototype
|
package/src/types.d.ts
CHANGED
package/src/base_temp.d.ts
DELETED
package/src/base_temp.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var base_temp_exports = {};
|
|
19
|
-
__export(base_temp_exports, {
|
|
20
|
-
AddFilter: () => import_baseGql.AddFilter,
|
|
21
|
-
AddModel: () => import_baseGql.AddModel,
|
|
22
|
-
ExtendModel: () => import_baseGql.ExtendModel,
|
|
23
|
-
Filter: () => import_filterMeta.BaseFilter,
|
|
24
|
-
Full: () => import_baseGql.Full,
|
|
25
|
-
Light: () => import_baseGql.Light,
|
|
26
|
-
MixModels: () => import_baseGql.MixModels,
|
|
27
|
-
Model: () => import_baseGql.BaseModel,
|
|
28
|
-
enum: () => import_base.enumOf
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(base_temp_exports);
|
|
31
|
-
var import_baseGql = require("./baseGql");
|
|
32
|
-
var import_filterMeta = require("./filterMeta");
|
|
33
|
-
var import_base = require("@akanjs/base");
|
|
34
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
AddFilter,
|
|
37
|
-
AddModel,
|
|
38
|
-
ExtendModel,
|
|
39
|
-
Filter,
|
|
40
|
-
Full,
|
|
41
|
-
Light,
|
|
42
|
-
MixModels,
|
|
43
|
-
Model,
|
|
44
|
-
enum: null
|
|
45
|
-
});
|