@akanjs/constant 0.0.39 → 0.0.40

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/constant",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -14,9 +14,5 @@
14
14
  "engines": {
15
15
  "node": ">=22"
16
16
  },
17
- "dependencies": {
18
- "dayjs": "^1.11.13",
19
- "pluralize": "^8.0.0",
20
- "reflect-metadata": "^0.2.2"
21
- }
17
+ "dependencies": {}
22
18
  }
@@ -0,0 +1,14 @@
1
+ import { N as NonFunctionalKeys, B as BaseObject } from '../types-DdO4B_Um.js';
2
+ import { T as Type } from '../types-b-U-yQib.js';
3
+ import 'dayjs';
4
+ import 'fs';
5
+ import 'stream';
6
+ import 'mongoose';
7
+
8
+ declare const as: <T>(modelRef: Type<T>) => Type<T>;
9
+ 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;
10
+ 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>;
11
+ 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>;
12
+ 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>;
13
+
14
+ export { as, from, mixModelOf, over, via };
package/src/baseGql.js ADDED
@@ -0,0 +1,275 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from2, except, desc) => {
11
+ if (from2 && typeof from2 === "object" || typeof from2 === "function") {
12
+ for (let key of __getOwnPropNames(from2))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var baseGql_exports = {};
20
+ __export(baseGql_exports, {
21
+ as: () => as,
22
+ from: () => from,
23
+ mixModelOf: () => mixModelOf,
24
+ over: () => over,
25
+ via: () => via
26
+ });
27
+ module.exports = __toCommonJS(baseGql_exports);
28
+ var import_reflect_metadata = require("reflect-metadata");
29
+ var import_base = require("@akanjs/base");
30
+ var import_common = require("@akanjs/common");
31
+ var import_filterMeta = require("./filterMeta");
32
+ var import_scalar = require("./scalar");
33
+ const defaultFieldMeta = {
34
+ fieldType: "property",
35
+ immutable: false,
36
+ select: true,
37
+ isClass: false,
38
+ isScalar: true,
39
+ nullable: false,
40
+ isArray: false,
41
+ arrDepth: 0,
42
+ optArrDepth: 0,
43
+ default: null,
44
+ isMap: false
45
+ };
46
+ const idFieldMeta = {
47
+ ...defaultFieldMeta,
48
+ key: "id",
49
+ name: "ID",
50
+ modelRef: import_base.ID
51
+ };
52
+ const createdAtFieldMeta = {
53
+ ...defaultFieldMeta,
54
+ key: "createdAt",
55
+ name: "Date",
56
+ modelRef: Date
57
+ };
58
+ const updatedAtFieldMeta = {
59
+ ...defaultFieldMeta,
60
+ key: "updatedAt",
61
+ name: "Date",
62
+ modelRef: Date
63
+ };
64
+ const removedAtFieldMeta = {
65
+ ...defaultFieldMeta,
66
+ key: "removedAt",
67
+ name: "Date",
68
+ modelRef: Date,
69
+ nullable: true,
70
+ default: null
71
+ };
72
+ const extendModel = /* @__PURE__ */ __name((modelRef) => {
73
+ let BaseModel = class BaseModel {
74
+ static {
75
+ __name(this, "BaseModel");
76
+ }
77
+ };
78
+ const metadataMap = (0, import_scalar.getFieldMetaMap)(modelRef);
79
+ (0, import_scalar.setFieldMetaMap)(BaseModel, metadataMap);
80
+ return BaseModel;
81
+ }, "extendModel");
82
+ const as = extendModel;
83
+ const baseModelOf = /* @__PURE__ */ __name((modelRef) => {
84
+ let BaseModel = class BaseModel {
85
+ static {
86
+ __name(this, "BaseModel");
87
+ }
88
+ __ModelType__ = "full";
89
+ };
90
+ const metadataMap = (0, import_scalar.getFieldMetaMap)(modelRef);
91
+ metadataMap.set("id", idFieldMeta);
92
+ metadataMap.set("createdAt", createdAtFieldMeta);
93
+ metadataMap.set("updatedAt", updatedAtFieldMeta);
94
+ metadataMap.set("removedAt", removedAtFieldMeta);
95
+ Reflect.defineMetadata("fields", metadataMap, BaseModel.prototype);
96
+ return BaseModel;
97
+ }, "baseModelOf");
98
+ const lightModelOf = /* @__PURE__ */ __name((objectRef, fields) => {
99
+ const map = /* @__PURE__ */ new Map();
100
+ const metadataMap = (0, import_scalar.getFieldMetaMap)(objectRef);
101
+ let BaseGql = class BaseGql {
102
+ static {
103
+ __name(this, "BaseGql");
104
+ }
105
+ __ModelType__ = "light";
106
+ };
107
+ [
108
+ "id",
109
+ ...fields,
110
+ "createdAt",
111
+ "updatedAt",
112
+ "removedAt"
113
+ ].forEach((key) => map.set(key, metadataMap.get(key)));
114
+ Reflect.defineMetadata("fields", map, BaseGql.prototype);
115
+ return BaseGql;
116
+ }, "lightModelOf");
117
+ const fullModelOf = /* @__PURE__ */ __name((modelRef, lightRef, overwriteRef, overwriteLightRef) => {
118
+ const modelFieldMetaMap = (0, import_scalar.getFieldMetaMap)(modelRef);
119
+ const lightFieldMetaMap = (0, import_scalar.getFieldMetaMap)(lightRef);
120
+ (0, import_common.applyMixins)(modelRef, [
121
+ lightRef
122
+ ]);
123
+ if (overwriteRef) {
124
+ (0, import_common.applyMixins)(overwriteRef, [
125
+ modelRef
126
+ ]);
127
+ (0, import_scalar.setFieldMetaMap)(overwriteRef, modelFieldMetaMap);
128
+ }
129
+ if (overwriteLightRef) {
130
+ (0, import_common.applyMixins)(overwriteLightRef, [
131
+ lightRef
132
+ ]);
133
+ (0, import_scalar.setFieldMetaMap)(overwriteLightRef, lightFieldMetaMap);
134
+ }
135
+ (0, import_scalar.setFieldMetaMap)(modelRef, new Map([
136
+ ...modelFieldMetaMap,
137
+ ...lightFieldMetaMap
138
+ ]));
139
+ return modelRef;
140
+ }, "fullModelOf");
141
+ const via = /* @__PURE__ */ __name((modelRef, fieldsOrLightModelRef, overwriteRef, overwriteLightRef) => {
142
+ if (!fieldsOrLightModelRef) return baseModelOf(modelRef);
143
+ else if (Array.isArray(fieldsOrLightModelRef)) return lightModelOf(modelRef, fieldsOrLightModelRef);
144
+ else return fullModelOf(modelRef, fieldsOrLightModelRef, overwriteRef, overwriteLightRef);
145
+ }, "via");
146
+ const addModelOf = /* @__PURE__ */ __name((modelRef, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => {
147
+ const modelMetadataMap = (0, import_scalar.getFieldMetaMap)(modelRef);
148
+ const metadataMap = new Map([
149
+ t1,
150
+ t2,
151
+ t3,
152
+ t4,
153
+ t5,
154
+ t6,
155
+ t7,
156
+ t8,
157
+ t9,
158
+ t10
159
+ ].filter((t) => !!t).reduce((acc, writeRef) => {
160
+ const writeMetadataMap = (0, import_scalar.getFieldMetaMap)(writeRef);
161
+ (0, import_common.applyMixins)(modelRef, [
162
+ writeRef
163
+ ]);
164
+ return new Map([
165
+ ...acc,
166
+ ...writeMetadataMap
167
+ ]);
168
+ }, modelMetadataMap));
169
+ (0, import_scalar.setFieldMetaMap)(modelRef, metadataMap);
170
+ return modelRef;
171
+ }, "addModelOf");
172
+ const addFilterOf = /* @__PURE__ */ __name((filterRef, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => {
173
+ const filterMeta = (0, import_filterMeta.getFilterMeta)(filterRef);
174
+ const filterQueryMap = (0, import_filterMeta.getFilterQueryMap)(filterRef);
175
+ const metadataMap = new Map([
176
+ t1,
177
+ t2,
178
+ t3,
179
+ t4,
180
+ t5,
181
+ t6,
182
+ t7,
183
+ t8,
184
+ t9,
185
+ t10
186
+ ].filter((t) => !!t).reduce((acc, writeRef) => {
187
+ const writeMetadataMap = (0, import_filterMeta.getFilterQueryMap)(writeRef);
188
+ (0, import_common.applyMixins)(filterRef, [
189
+ writeRef
190
+ ]);
191
+ writeMetadataMap.forEach((value, key) => {
192
+ const filterArgMetas = (0, import_filterMeta.getFilterArgMetas)(writeRef, key);
193
+ (0, import_filterMeta.setFilterArgMetasOnPrototype)(filterRef.prototype, key, filterArgMetas);
194
+ });
195
+ return new Map([
196
+ ...acc,
197
+ ...writeMetadataMap
198
+ ]);
199
+ }, filterQueryMap));
200
+ const filterSort = [
201
+ t1,
202
+ t2,
203
+ t3,
204
+ t4,
205
+ t5,
206
+ t6,
207
+ t7,
208
+ t8,
209
+ t9,
210
+ t10
211
+ ].filter((t) => !!t).map((t) => (0, import_filterMeta.getFilterSortMap)(t)).reduce((acc, sort) => {
212
+ Object.assign(acc, sort);
213
+ return acc;
214
+ }, filterMeta.sort);
215
+ (0, import_filterMeta.setFilterKeyMetaMapOnPrototype)(filterRef.prototype, metadataMap);
216
+ (0, import_filterMeta.setFilterMeta)(filterRef, {
217
+ ...filterMeta,
218
+ sort: filterSort
219
+ });
220
+ return filterRef;
221
+ }, "addFilterOf");
222
+ const from = /* @__PURE__ */ __name((modelRef, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => {
223
+ if ((0, import_scalar.isConstantModel)(modelRef)) return addModelOf(modelRef, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10);
224
+ else if ((0, import_filterMeta.isFilterModel)(modelRef)) return addFilterOf(modelRef, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10);
225
+ else throw new Error("Invalid modelRef");
226
+ }, "from");
227
+ const mixModelOf = /* @__PURE__ */ __name((t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20) => {
228
+ let Mix = class Mix {
229
+ static {
230
+ __name(this, "Mix");
231
+ }
232
+ };
233
+ const metadataMap = new Map([
234
+ t1,
235
+ t2,
236
+ t3,
237
+ t4,
238
+ t5,
239
+ t6,
240
+ t7,
241
+ t8,
242
+ t9,
243
+ t10,
244
+ t11,
245
+ t12,
246
+ t13,
247
+ t14,
248
+ t15,
249
+ t16,
250
+ t17,
251
+ t18,
252
+ t19,
253
+ t20
254
+ ].filter((t) => !!t).reduce((acc, modelRef) => {
255
+ const modelMetadataMap = (0, import_scalar.getFieldMetaMap)(modelRef);
256
+ (0, import_common.applyMixins)(Mix, [
257
+ modelRef
258
+ ]);
259
+ return [
260
+ ...acc,
261
+ ...modelMetadataMap
262
+ ];
263
+ }, []));
264
+ (0, import_scalar.setFieldMetaMap)(Mix, metadataMap);
265
+ return Mix;
266
+ }, "mixModelOf");
267
+ const over = mixModelOf;
268
+ // Annotate the CommonJS export names for ESM import in node:
269
+ 0 && (module.exports = {
270
+ as,
271
+ from,
272
+ mixModelOf,
273
+ over,
274
+ via
275
+ });
@@ -0,0 +1,39 @@
1
+ import { E as Enum } from '../base-D8mO_G-C.js';
2
+ import { T as Type } from '../types-b-U-yQib.js';
3
+
4
+ declare class InputModelStorage {
5
+ }
6
+ declare class LightModelStorage {
7
+ }
8
+ declare class FullModelStorage {
9
+ }
10
+ declare class ScalarModelStorage {
11
+ }
12
+ declare class FilterModelStorage {
13
+ }
14
+ declare const getFullModelRef: (refName: string) => Type;
15
+ declare const getInputModelRef: (refName: string) => Type;
16
+ declare const getScalarModelRef: (refName: string) => Type;
17
+ declare const getChildClassRefs: (target: Type) => Type[];
18
+ declare const getFieldEnumMetas: (modelRef: Type) => {
19
+ key: string;
20
+ enum: Enum<string | number>;
21
+ }[];
22
+ declare const hasTextField: (modelRef: Type) => boolean;
23
+ type ClassType = "light" | "full" | "input" | "scalar";
24
+ declare const Model: {
25
+ Light: (refName: string) => (target: Type) => void;
26
+ Object: (refName: string) => (target: Type) => void;
27
+ Full: (refName: string) => (target: Type) => void;
28
+ Input: (refName: string) => (target: Type) => void;
29
+ Scalar: (refName: string) => (target: Type) => void;
30
+ Summary: (refName: string) => (target: Type) => void;
31
+ Insight: (refName: string) => (target: Type) => void;
32
+ Filter: (refName: string) => (target: Type) => void;
33
+ };
34
+ declare const getLightModelRef: (modelRef: Type) => Type;
35
+ declare const getAllFullModelRefs: () => Type[];
36
+ declare const getAllScalarModelRefs: () => Type[];
37
+ declare const getAllFilterModelRefs: () => Type[];
38
+
39
+ export { type ClassType, FilterModelStorage, FullModelStorage, InputModelStorage, LightModelStorage, Model, ScalarModelStorage, getAllFilterModelRefs, getAllFullModelRefs, getAllScalarModelRefs, getChildClassRefs, getFieldEnumMetas, getFullModelRef, getInputModelRef, getLightModelRef, getScalarModelRef, hasTextField };
@@ -0,0 +1,187 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var classMeta_exports = {};
20
+ __export(classMeta_exports, {
21
+ FilterModelStorage: () => FilterModelStorage,
22
+ FullModelStorage: () => FullModelStorage,
23
+ InputModelStorage: () => InputModelStorage,
24
+ LightModelStorage: () => LightModelStorage,
25
+ Model: () => Model,
26
+ ScalarModelStorage: () => ScalarModelStorage,
27
+ getAllFilterModelRefs: () => getAllFilterModelRefs,
28
+ getAllFullModelRefs: () => getAllFullModelRefs,
29
+ getAllScalarModelRefs: () => getAllScalarModelRefs,
30
+ getChildClassRefs: () => getChildClassRefs,
31
+ getFieldEnumMetas: () => getFieldEnumMetas,
32
+ getFullModelRef: () => getFullModelRef,
33
+ getInputModelRef: () => getInputModelRef,
34
+ getLightModelRef: () => getLightModelRef,
35
+ getScalarModelRef: () => getScalarModelRef,
36
+ hasTextField: () => hasTextField
37
+ });
38
+ module.exports = __toCommonJS(classMeta_exports);
39
+ var import_reflect_metadata = require("reflect-metadata");
40
+ var import_common = require("@akanjs/common");
41
+ var import_filterMeta = require("./filterMeta");
42
+ var import_scalar = require("./scalar");
43
+ class InputModelStorage {
44
+ static {
45
+ __name(this, "InputModelStorage");
46
+ }
47
+ }
48
+ class LightModelStorage {
49
+ static {
50
+ __name(this, "LightModelStorage");
51
+ }
52
+ }
53
+ class FullModelStorage {
54
+ static {
55
+ __name(this, "FullModelStorage");
56
+ }
57
+ }
58
+ class ScalarModelStorage {
59
+ static {
60
+ __name(this, "ScalarModelStorage");
61
+ }
62
+ }
63
+ class FilterModelStorage {
64
+ static {
65
+ __name(this, "FilterModelStorage");
66
+ }
67
+ }
68
+ const getFullModelRef = /* @__PURE__ */ __name((refName) => {
69
+ const modelRef = Reflect.getMetadata((0, import_common.capitalize)(refName), FullModelStorage.prototype);
70
+ if (!modelRef) throw new Error(`FullModel not found - ${refName}`);
71
+ return modelRef;
72
+ }, "getFullModelRef");
73
+ const getInputModelRef = /* @__PURE__ */ __name((refName) => {
74
+ const modelRef = Reflect.getMetadata((0, import_common.capitalize)(refName), InputModelStorage.prototype);
75
+ if (!modelRef) throw new Error(`InputModel not found - ${refName}`);
76
+ return modelRef;
77
+ }, "getInputModelRef");
78
+ const getScalarModelRef = /* @__PURE__ */ __name((refName) => {
79
+ const modelRef = Reflect.getMetadata((0, import_common.capitalize)(refName), ScalarModelStorage.prototype);
80
+ if (!modelRef) throw new Error(`ScalarModel not found - ${refName}`);
81
+ return modelRef;
82
+ }, "getScalarModelRef");
83
+ const getChildClassRefs = /* @__PURE__ */ __name((target) => {
84
+ const metadatas = (0, import_scalar.getFieldMetas)(target);
85
+ const refMap = /* @__PURE__ */ new Map();
86
+ const childRefs = metadatas.filter((metadata) => metadata.isClass).reduce((acc, metadata) => {
87
+ return [
88
+ ...acc,
89
+ metadata.modelRef,
90
+ ...getChildClassRefs(metadata.modelRef)
91
+ ];
92
+ }, []);
93
+ childRefs.filter((modelRef, idx) => childRefs.findIndex((ref) => ref.prototype === modelRef.prototype) === idx).map((modelRef) => refMap.set((0, import_scalar.getClassMeta)(modelRef).refName, modelRef));
94
+ return [
95
+ ...refMap.values()
96
+ ];
97
+ }, "getChildClassRefs");
98
+ const getFieldEnumMetas = /* @__PURE__ */ __name((modelRef) => {
99
+ const fieldMetas = (0, import_scalar.getFieldMetas)(modelRef);
100
+ return fieldMetas.filter((fieldMeta) => !!fieldMeta.enum).map((fieldMeta) => ({
101
+ key: fieldMeta.key,
102
+ enum: fieldMeta.enum
103
+ }));
104
+ }, "getFieldEnumMetas");
105
+ const hasTextField = /* @__PURE__ */ __name((modelRef) => {
106
+ const fieldMetas = (0, import_scalar.getFieldMetas)(modelRef);
107
+ return fieldMetas.some((fieldMeta) => !!fieldMeta.text || fieldMeta.isScalar && fieldMeta.isClass && fieldMeta.select && hasTextField(fieldMeta.modelRef));
108
+ }, "hasTextField");
109
+ const applyClassMeta = /* @__PURE__ */ __name((type, modelType, storage) => {
110
+ return function(refName) {
111
+ return function(target) {
112
+ const modelRef = target;
113
+ const classMeta = {
114
+ refName,
115
+ type,
116
+ modelType,
117
+ modelRef,
118
+ hasTextField: hasTextField(modelRef)
119
+ };
120
+ Reflect.defineMetadata("class", classMeta, modelRef.prototype);
121
+ Reflect.defineMetadata(refName, modelRef, storage.prototype);
122
+ };
123
+ };
124
+ }, "applyClassMeta");
125
+ const applyFilterMeta = /* @__PURE__ */ __name((storage) => {
126
+ return function(refName) {
127
+ return function(target) {
128
+ const modelRef = target;
129
+ (0, import_filterMeta.setFilterMeta)(modelRef, {
130
+ refName,
131
+ sort: {}
132
+ });
133
+ Reflect.defineMetadata(refName, modelRef, storage.prototype);
134
+ };
135
+ };
136
+ }, "applyFilterMeta");
137
+ const Model = {
138
+ Light: applyClassMeta("light", "data", LightModelStorage),
139
+ Object: applyClassMeta("full", "ephemeral", FullModelStorage),
140
+ Full: applyClassMeta("full", "data", FullModelStorage),
141
+ Input: applyClassMeta("input", "data", InputModelStorage),
142
+ Scalar: applyClassMeta("scalar", "data", ScalarModelStorage),
143
+ Summary: applyClassMeta("scalar", "summary", ScalarModelStorage),
144
+ Insight: applyClassMeta("scalar", "insight", ScalarModelStorage),
145
+ Filter: applyFilterMeta(FilterModelStorage)
146
+ };
147
+ const getLightModelRef = /* @__PURE__ */ __name((modelRef) => {
148
+ const classMeta = (0, import_scalar.getClassMeta)(modelRef);
149
+ if (classMeta.type !== "full") return modelRef;
150
+ const lightModelRef = Reflect.getMetadata(`Light${classMeta.refName}`, LightModelStorage.prototype);
151
+ if (!lightModelRef) throw new Error(`LightModel not found - ${classMeta.refName}`);
152
+ return lightModelRef;
153
+ }, "getLightModelRef");
154
+ const getAllFullModelRefs = /* @__PURE__ */ __name(() => {
155
+ const modelNames = Reflect.getMetadataKeys(FullModelStorage.prototype);
156
+ const modelRefs = modelNames.map((modelName) => Reflect.getMetadata(modelName, FullModelStorage.prototype));
157
+ return modelRefs;
158
+ }, "getAllFullModelRefs");
159
+ const getAllScalarModelRefs = /* @__PURE__ */ __name(() => {
160
+ const modelNames = Reflect.getMetadataKeys(ScalarModelStorage.prototype);
161
+ const modelRefs = modelNames.map((modelName) => Reflect.getMetadata(modelName, ScalarModelStorage.prototype));
162
+ return modelRefs;
163
+ }, "getAllScalarModelRefs");
164
+ const getAllFilterModelRefs = /* @__PURE__ */ __name(() => {
165
+ const modelNames = Reflect.getMetadataKeys(FilterModelStorage.prototype);
166
+ const modelRefs = modelNames.map((modelName) => Reflect.getMetadata(modelName, FilterModelStorage.prototype));
167
+ return modelRefs;
168
+ }, "getAllFilterModelRefs");
169
+ // Annotate the CommonJS export names for ESM import in node:
170
+ 0 && (module.exports = {
171
+ FilterModelStorage,
172
+ FullModelStorage,
173
+ InputModelStorage,
174
+ LightModelStorage,
175
+ Model,
176
+ ScalarModelStorage,
177
+ getAllFilterModelRefs,
178
+ getAllFullModelRefs,
179
+ getAllScalarModelRefs,
180
+ getChildClassRefs,
181
+ getFieldEnumMetas,
182
+ getFullModelRef,
183
+ getInputModelRef,
184
+ getLightModelRef,
185
+ getScalarModelRef,
186
+ hasTextField
187
+ });
@@ -0,0 +1,20 @@
1
+ import { T as Type } from '../types-b-U-yQib.js';
2
+ import { F as FilterType } from '../types-DdO4B_Um.js';
3
+ import 'dayjs';
4
+ import 'fs';
5
+ import 'stream';
6
+ import 'mongoose';
7
+
8
+ declare const getCnstMeta: (refName: string) => ConstantModel<any, any, any, any, any, any>;
9
+ interface ConstantModel<T extends string, Input, Full, Light, Insight, Filter extends FilterType, Summary = any> {
10
+ refName: T;
11
+ Input: Type<Input>;
12
+ Full: Type<Full>;
13
+ Light: Type<Light>;
14
+ Insight: Type<Insight>;
15
+ Filter: Type<Filter>;
16
+ Summary?: Type<Summary>;
17
+ }
18
+ declare const cnstOf: <T extends string, Input, Full, Light, Insight, Filter extends FilterType, Summary>(refName: T, Input: Type<Input>, Full: Type<Full>, Light: Type<Light>, Insight: Type<Insight>, Filter: Type<Filter>, Summary?: Type<Summary>) => ConstantModel<T, Input, Full, Light, Insight, Filter, Summary>;
19
+
20
+ export { type ConstantModel, cnstOf, getCnstMeta };
@@ -0,0 +1,56 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var constantDecorator_exports = {};
20
+ __export(constantDecorator_exports, {
21
+ cnstOf: () => cnstOf,
22
+ getCnstMeta: () => getCnstMeta
23
+ });
24
+ module.exports = __toCommonJS(constantDecorator_exports);
25
+ var import_reflect_metadata = require("reflect-metadata");
26
+ let CnstStorage = class CnstStorage2 {
27
+ static {
28
+ __name(this, "CnstStorage");
29
+ }
30
+ };
31
+ const setCnstMeta = /* @__PURE__ */ __name((refName, cnst) => {
32
+ Reflect.defineMetadata(refName, cnst, CnstStorage.prototype);
33
+ }, "setCnstMeta");
34
+ const getCnstMeta = /* @__PURE__ */ __name((refName) => {
35
+ const cnst = Reflect.getMetadata(refName, CnstStorage.prototype);
36
+ if (!cnst) throw new Error(`No cnst meta for ${refName}`);
37
+ return cnst;
38
+ }, "getCnstMeta");
39
+ const cnstOf = /* @__PURE__ */ __name((refName, Input, Full, Light, Insight, Filter, Summary) => {
40
+ const cnst = {
41
+ refName,
42
+ Input,
43
+ Full,
44
+ Light,
45
+ Insight,
46
+ Filter,
47
+ Summary
48
+ };
49
+ setCnstMeta(refName, cnst);
50
+ return cnst;
51
+ }, "cnstOf");
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ cnstOf,
55
+ getCnstMeta
56
+ });
@@ -0,0 +1,17 @@
1
+ import { ReturnType, ConstantFieldProps } from './scalar.js';
2
+ import '../base-D8mO_G-C.js';
3
+ import '../types-DdO4B_Um.js';
4
+ import 'dayjs';
5
+ import 'fs';
6
+ import 'stream';
7
+ import '../types-b-U-yQib.js';
8
+ import 'mongoose';
9
+
10
+ declare const Field: {
11
+ Prop: (returns: ReturnType, fieldOption?: Omit<ConstantFieldProps, "fieldType" | "select"> | Omit<ConstantFieldProps, "nullable" | "fieldType" | "select">[]) => PropertyDecorator;
12
+ Hidden: (returns: ReturnType, fieldOption?: Omit<ConstantFieldProps, "fieldType" | "select"> | Omit<ConstantFieldProps, "nullable" | "fieldType" | "select">[]) => PropertyDecorator;
13
+ Secret: (returns: ReturnType, fieldOption?: Omit<ConstantFieldProps, "fieldType" | "select"> | Omit<ConstantFieldProps, "nullable" | "fieldType" | "select">[]) => PropertyDecorator;
14
+ Resolve: (returns: ReturnType, fieldOption?: Omit<ConstantFieldProps, "fieldType" | "select"> | Omit<ConstantFieldProps, "nullable" | "fieldType" | "select">[]) => PropertyDecorator;
15
+ };
16
+
17
+ export { Field };