@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/base-D8mO_G-C.d.ts +15 -0
- package/index.d.ts +13 -0
- package/index.js +20 -891
- package/package.json +2 -6
- package/src/baseGql.d.ts +14 -0
- package/src/baseGql.js +275 -0
- package/src/classMeta.d.ts +39 -0
- package/src/classMeta.js +187 -0
- package/src/constantDecorator.d.ts +20 -0
- package/src/constantDecorator.js +56 -0
- package/src/fieldMeta.d.ts +17 -0
- package/src/fieldMeta.js +104 -0
- package/src/filterMeta.d.ts +69 -0
- package/src/filterMeta.js +291 -0
- package/src/index.d.ts +13 -0
- package/src/index.js +33 -0
- package/src/scalar.d.ts +97 -0
- package/src/scalar.js +141 -0
- package/src/types.d.ts +6 -0
- package/src/types.js +34 -0
- package/types-DdO4B_Um.d.ts +126 -0
- package/types-b-U-yQib.d.ts +33 -0
package/src/fieldMeta.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
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 fieldMeta_exports = {};
|
|
20
|
+
__export(fieldMeta_exports, {
|
|
21
|
+
Field: () => Field
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(fieldMeta_exports);
|
|
24
|
+
var import_base = require("@akanjs/base");
|
|
25
|
+
var import_scalar = require("./scalar");
|
|
26
|
+
const applyFieldMeta = /* @__PURE__ */ __name((modelRef, arrDepth, option, optionArrDepth) => {
|
|
27
|
+
const isArray = arrDepth > 0;
|
|
28
|
+
const isClass = !(0, import_base.isGqlScalar)(modelRef);
|
|
29
|
+
const isMap = (0, import_base.isGqlMap)(modelRef);
|
|
30
|
+
const { refName, type } = isClass ? (0, import_scalar.getClassMeta)(modelRef) : {
|
|
31
|
+
refName: "",
|
|
32
|
+
type: "scalar"
|
|
33
|
+
};
|
|
34
|
+
const name = isClass ? refName : import_base.scalarNameMap.get(modelRef) ?? "Unknown";
|
|
35
|
+
if (isMap && !option.of) throw new Error("Map type must have 'of' option");
|
|
36
|
+
return (prototype, key) => {
|
|
37
|
+
const metadata = {
|
|
38
|
+
nullable: option.nullable ?? false,
|
|
39
|
+
ref: option.ref,
|
|
40
|
+
refPath: option.refPath,
|
|
41
|
+
refType: option.refType,
|
|
42
|
+
default: option.default ?? (isArray ? [] : null),
|
|
43
|
+
type: option.type,
|
|
44
|
+
fieldType: option.fieldType ?? "property",
|
|
45
|
+
immutable: option.immutable ?? false,
|
|
46
|
+
min: option.min,
|
|
47
|
+
max: option.max,
|
|
48
|
+
enum: option.enum,
|
|
49
|
+
select: option.select ?? true,
|
|
50
|
+
minlength: option.minlength,
|
|
51
|
+
maxlength: option.maxlength,
|
|
52
|
+
query: option.query,
|
|
53
|
+
accumulate: option.accumulate,
|
|
54
|
+
example: option.example,
|
|
55
|
+
validate: option.validate,
|
|
56
|
+
key,
|
|
57
|
+
name,
|
|
58
|
+
isClass,
|
|
59
|
+
isScalar: type === "scalar",
|
|
60
|
+
modelRef,
|
|
61
|
+
arrDepth,
|
|
62
|
+
isArray,
|
|
63
|
+
optArrDepth: optionArrDepth,
|
|
64
|
+
isMap,
|
|
65
|
+
of: option.of,
|
|
66
|
+
text: option.text
|
|
67
|
+
};
|
|
68
|
+
const metadataMap = (0, import_scalar.getFieldMetaMapOnPrototype)(prototype);
|
|
69
|
+
metadataMap.set(key, metadata);
|
|
70
|
+
(0, import_scalar.setFieldMetaMapOnPrototype)(prototype, metadataMap);
|
|
71
|
+
};
|
|
72
|
+
}, "applyFieldMeta");
|
|
73
|
+
const makeField = /* @__PURE__ */ __name((customOption) => (returns, fieldOption) => {
|
|
74
|
+
const [modelRef, arrDepth] = (0, import_base.getNonArrayModel)(returns());
|
|
75
|
+
if (!fieldOption) return applyFieldMeta(modelRef, arrDepth, {
|
|
76
|
+
...customOption
|
|
77
|
+
}, arrDepth);
|
|
78
|
+
const [opt, optArrDepth] = (0, import_base.getNonArrayModel)(fieldOption);
|
|
79
|
+
return applyFieldMeta(modelRef, arrDepth, {
|
|
80
|
+
...opt,
|
|
81
|
+
...customOption
|
|
82
|
+
}, optArrDepth);
|
|
83
|
+
}, "makeField");
|
|
84
|
+
const Field = {
|
|
85
|
+
Prop: makeField({
|
|
86
|
+
fieldType: "property"
|
|
87
|
+
}),
|
|
88
|
+
Hidden: makeField({
|
|
89
|
+
fieldType: "hidden",
|
|
90
|
+
nullable: true
|
|
91
|
+
}),
|
|
92
|
+
Secret: makeField({
|
|
93
|
+
fieldType: "hidden",
|
|
94
|
+
select: false,
|
|
95
|
+
nullable: true
|
|
96
|
+
}),
|
|
97
|
+
Resolve: makeField({
|
|
98
|
+
fieldType: "resolve"
|
|
99
|
+
})
|
|
100
|
+
};
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
Field
|
|
104
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { T as Type } from '../types-b-U-yQib.js';
|
|
2
|
+
import { ConstantFilterMeta, FilterKeyMeta, FilterArgMeta, FilterKeyProps, ReturnType, FilterArgProps } from './scalar.js';
|
|
3
|
+
import { S as SortType } from '../types-DdO4B_Um.js';
|
|
4
|
+
import { FilterQuery } from 'mongoose';
|
|
5
|
+
import '../base-D8mO_G-C.js';
|
|
6
|
+
import 'dayjs';
|
|
7
|
+
import 'fs';
|
|
8
|
+
import 'stream';
|
|
9
|
+
|
|
10
|
+
declare const isFilterModel: (filterRef: Type) => boolean;
|
|
11
|
+
declare const getFilterMeta: (filterRef: Type) => ConstantFilterMeta;
|
|
12
|
+
declare const setFilterMeta: (filterRef: Type, filterMeta: ConstantFilterMeta) => void;
|
|
13
|
+
declare const getFilterKeyMetaMapOnPrototype: (prototype: object) => Map<string, FilterKeyMeta>;
|
|
14
|
+
declare const setFilterKeyMetaMapOnPrototype: (prototype: object, metadataMap: Map<string, FilterKeyMeta>) => void;
|
|
15
|
+
declare const setFilterArgMetasOnPrototype: (prototype: object, key: string, filterArgMetas: FilterArgMeta[]) => void;
|
|
16
|
+
declare const getFilterArgMetas: (filterRef: Type, key: string) => FilterArgMeta[];
|
|
17
|
+
declare const getFilterQuery: (filterRef: Type, key: string) => (...args: any[]) => FilterQuery<any>;
|
|
18
|
+
declare const getFilterQueryMap: (filterRef: Type) => Map<string, FilterKeyMeta>;
|
|
19
|
+
declare const getFilterSort: (filterRef: Type, key: string) => {
|
|
20
|
+
[key: string]: number;
|
|
21
|
+
};
|
|
22
|
+
declare const getFilterSortMap: (filterRef: Type) => SortType;
|
|
23
|
+
declare const Filter: {
|
|
24
|
+
Mongo: (fieldOption?: Omit<FilterKeyProps, "type">) => (prototype: object, key: string, descriptor: PropertyDescriptor) => void;
|
|
25
|
+
Arg: (name: string, returns: ReturnType, argOption?: FilterArgProps | FilterArgProps[]) => (prototype: object, key: string, idx: number) => void;
|
|
26
|
+
};
|
|
27
|
+
type BaseFilterKey = "latest" | "oldest" | "any" | "byStatuses";
|
|
28
|
+
declare const sortOf: <Sort extends SortType>(modelRef: Type, sort: Sort) => Type<{
|
|
29
|
+
latest: {
|
|
30
|
+
createdAt: number;
|
|
31
|
+
};
|
|
32
|
+
oldest: {
|
|
33
|
+
createdAt: number;
|
|
34
|
+
};
|
|
35
|
+
any(): {
|
|
36
|
+
removedAt: {
|
|
37
|
+
$exists: boolean;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
byStatuses(statuses: string[] | null): {
|
|
41
|
+
status: {
|
|
42
|
+
$in: string[];
|
|
43
|
+
};
|
|
44
|
+
} | {
|
|
45
|
+
status?: undefined;
|
|
46
|
+
};
|
|
47
|
+
} & Sort>;
|
|
48
|
+
declare function BaseFilter<Sort extends SortType>(modelRef: Type, sort: Sort): Type<{
|
|
49
|
+
latest: {
|
|
50
|
+
createdAt: number;
|
|
51
|
+
};
|
|
52
|
+
oldest: {
|
|
53
|
+
createdAt: number;
|
|
54
|
+
};
|
|
55
|
+
any(): {
|
|
56
|
+
removedAt: {
|
|
57
|
+
$exists: boolean;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
byStatuses(statuses: string[] | null): {
|
|
61
|
+
status: {
|
|
62
|
+
$in: string[];
|
|
63
|
+
};
|
|
64
|
+
} | {
|
|
65
|
+
status?: undefined;
|
|
66
|
+
};
|
|
67
|
+
} & Sort>;
|
|
68
|
+
|
|
69
|
+
export { BaseFilter, type BaseFilterKey, Filter, getFilterArgMetas, getFilterKeyMetaMapOnPrototype, getFilterMeta, getFilterQuery, getFilterQueryMap, getFilterSort, getFilterSortMap, isFilterModel, setFilterArgMetasOnPrototype, setFilterKeyMetaMapOnPrototype, setFilterMeta, sortOf };
|
|
@@ -0,0 +1,291 @@
|
|
|
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 filterMeta_exports = {};
|
|
20
|
+
__export(filterMeta_exports, {
|
|
21
|
+
BaseFilter: () => BaseFilter,
|
|
22
|
+
Filter: () => Filter,
|
|
23
|
+
getFilterArgMetas: () => getFilterArgMetas,
|
|
24
|
+
getFilterKeyMetaMapOnPrototype: () => getFilterKeyMetaMapOnPrototype,
|
|
25
|
+
getFilterMeta: () => getFilterMeta,
|
|
26
|
+
getFilterQuery: () => getFilterQuery,
|
|
27
|
+
getFilterQueryMap: () => getFilterQueryMap,
|
|
28
|
+
getFilterSort: () => getFilterSort,
|
|
29
|
+
getFilterSortMap: () => getFilterSortMap,
|
|
30
|
+
isFilterModel: () => isFilterModel,
|
|
31
|
+
setFilterArgMetasOnPrototype: () => setFilterArgMetasOnPrototype,
|
|
32
|
+
setFilterKeyMetaMapOnPrototype: () => setFilterKeyMetaMapOnPrototype,
|
|
33
|
+
setFilterMeta: () => setFilterMeta,
|
|
34
|
+
sortOf: () => sortOf
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(filterMeta_exports);
|
|
37
|
+
var import_base = require("@akanjs/base");
|
|
38
|
+
var import_scalar = require("./scalar");
|
|
39
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
40
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
41
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
42
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
43
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
44
|
+
}
|
|
45
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
46
|
+
function _ts_metadata(k, v) {
|
|
47
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
48
|
+
}
|
|
49
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
50
|
+
function _ts_param(paramIndex, decorator) {
|
|
51
|
+
return function(target, key) {
|
|
52
|
+
decorator(target, key, paramIndex);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
__name(_ts_param, "_ts_param");
|
|
56
|
+
const isFilterModel = /* @__PURE__ */ __name((filterRef) => {
|
|
57
|
+
return Reflect.getMetadata("filter", filterRef.prototype) !== void 0;
|
|
58
|
+
}, "isFilterModel");
|
|
59
|
+
const getFilterMeta = /* @__PURE__ */ __name((filterRef) => {
|
|
60
|
+
const filterMeta = Reflect.getMetadata("filter", filterRef.prototype);
|
|
61
|
+
if (!filterMeta) throw new Error("filterMeta is not defined");
|
|
62
|
+
return filterMeta;
|
|
63
|
+
}, "getFilterMeta");
|
|
64
|
+
const setFilterMeta = /* @__PURE__ */ __name((filterRef, filterMeta) => {
|
|
65
|
+
const existingFilterMeta = Reflect.getMetadata("filter", filterRef.prototype);
|
|
66
|
+
if (existingFilterMeta) Object.assign(filterMeta.sort, existingFilterMeta.sort);
|
|
67
|
+
Reflect.defineMetadata("filter", filterMeta, filterRef.prototype);
|
|
68
|
+
}, "setFilterMeta");
|
|
69
|
+
const getFilterKeyMetaMapOnPrototype = /* @__PURE__ */ __name((prototype) => {
|
|
70
|
+
const metadataMap = Reflect.getMetadata("filterKey", prototype) ?? /* @__PURE__ */ new Map();
|
|
71
|
+
return new Map(metadataMap);
|
|
72
|
+
}, "getFilterKeyMetaMapOnPrototype");
|
|
73
|
+
const setFilterKeyMetaMapOnPrototype = /* @__PURE__ */ __name((prototype, metadataMap) => {
|
|
74
|
+
Reflect.defineMetadata("filterKey", new Map(metadataMap), prototype);
|
|
75
|
+
}, "setFilterKeyMetaMapOnPrototype");
|
|
76
|
+
const applyFilterKeyMeta = /* @__PURE__ */ __name((option) => {
|
|
77
|
+
return (prototype, key, descriptor) => {
|
|
78
|
+
const metadata = {
|
|
79
|
+
key,
|
|
80
|
+
...option,
|
|
81
|
+
descriptor
|
|
82
|
+
};
|
|
83
|
+
const metadataMap = getFilterKeyMetaMapOnPrototype(prototype);
|
|
84
|
+
metadataMap.set(key, metadata);
|
|
85
|
+
setFilterKeyMetaMapOnPrototype(prototype, metadataMap);
|
|
86
|
+
};
|
|
87
|
+
}, "applyFilterKeyMeta");
|
|
88
|
+
const makeFilter = /* @__PURE__ */ __name((customOption) => (fieldOption) => {
|
|
89
|
+
return applyFilterKeyMeta({
|
|
90
|
+
...customOption,
|
|
91
|
+
...fieldOption
|
|
92
|
+
});
|
|
93
|
+
}, "makeFilter");
|
|
94
|
+
const getFilterArgMetasOnPrototype = /* @__PURE__ */ __name((prototype, key) => {
|
|
95
|
+
const filterArgMetas = Reflect.getMetadata("filterArg", prototype, key) ?? [];
|
|
96
|
+
return filterArgMetas;
|
|
97
|
+
}, "getFilterArgMetasOnPrototype");
|
|
98
|
+
const setFilterArgMetasOnPrototype = /* @__PURE__ */ __name((prototype, key, filterArgMetas) => {
|
|
99
|
+
Reflect.defineMetadata("filterArg", filterArgMetas, prototype, key);
|
|
100
|
+
}, "setFilterArgMetasOnPrototype");
|
|
101
|
+
const getFilterArgMetas = /* @__PURE__ */ __name((filterRef, key) => {
|
|
102
|
+
const filterArgMetas = getFilterArgMetasOnPrototype(filterRef.prototype, key);
|
|
103
|
+
return filterArgMetas;
|
|
104
|
+
}, "getFilterArgMetas");
|
|
105
|
+
const applyFilterArgMeta = /* @__PURE__ */ __name((name, returns, argOption) => {
|
|
106
|
+
return (prototype, key, idx) => {
|
|
107
|
+
const [modelRef, arrDepth] = (0, import_base.getNonArrayModel)(returns());
|
|
108
|
+
const [opt, optArrDepth] = (0, import_base.getNonArrayModel)(argOption ?? {});
|
|
109
|
+
const filterArgMeta = {
|
|
110
|
+
name,
|
|
111
|
+
...opt,
|
|
112
|
+
modelRef,
|
|
113
|
+
arrDepth,
|
|
114
|
+
isArray: arrDepth > 0,
|
|
115
|
+
optArrDepth
|
|
116
|
+
};
|
|
117
|
+
const filterArgMetas = getFilterArgMetasOnPrototype(prototype, key);
|
|
118
|
+
filterArgMetas[idx] = filterArgMeta;
|
|
119
|
+
setFilterArgMetasOnPrototype(prototype, key, filterArgMetas);
|
|
120
|
+
};
|
|
121
|
+
}, "applyFilterArgMeta");
|
|
122
|
+
const getFilterQuery = /* @__PURE__ */ __name((filterRef, key) => {
|
|
123
|
+
const filterKeyMetaMap = getFilterKeyMetaMapOnPrototype(filterRef.prototype);
|
|
124
|
+
const filterKeyMeta = filterKeyMetaMap.get(key);
|
|
125
|
+
if (!filterKeyMeta?.descriptor.value) throw new Error(`filterKeyMeta is not defined for key: ${key}`);
|
|
126
|
+
return filterKeyMeta.descriptor.value;
|
|
127
|
+
}, "getFilterQuery");
|
|
128
|
+
const getFilterQueryMap = /* @__PURE__ */ __name((filterRef) => {
|
|
129
|
+
const filterKeyMetaMap = getFilterKeyMetaMapOnPrototype(filterRef.prototype);
|
|
130
|
+
return filterKeyMetaMap;
|
|
131
|
+
}, "getFilterQueryMap");
|
|
132
|
+
const getFilterSort = /* @__PURE__ */ __name((filterRef, key) => {
|
|
133
|
+
const filterMeta = getFilterMeta(filterRef);
|
|
134
|
+
const sort = filterMeta.sort[key];
|
|
135
|
+
return sort;
|
|
136
|
+
}, "getFilterSort");
|
|
137
|
+
const getFilterSortMap = /* @__PURE__ */ __name((filterRef) => {
|
|
138
|
+
const filterMeta = getFilterMeta(filterRef);
|
|
139
|
+
return filterMeta.sort;
|
|
140
|
+
}, "getFilterSortMap");
|
|
141
|
+
const Filter = {
|
|
142
|
+
Mongo: makeFilter({
|
|
143
|
+
type: "mongo"
|
|
144
|
+
}),
|
|
145
|
+
// Meili: makeFilter({ fieldType: "hidden", nullable: true }),
|
|
146
|
+
Arg: applyFilterArgMeta
|
|
147
|
+
};
|
|
148
|
+
const sortOf = /* @__PURE__ */ __name((modelRef, sort) => {
|
|
149
|
+
const fieldMetaMap = (0, import_scalar.getFieldMetaMap)(modelRef);
|
|
150
|
+
const statusFieldMeta = fieldMetaMap.get("status");
|
|
151
|
+
if (!statusFieldMeta) throw new Error(`No status field meta fount in ${modelRef.name}`);
|
|
152
|
+
let BaseFilter2 = class BaseFilter {
|
|
153
|
+
static {
|
|
154
|
+
__name(this, "BaseFilter");
|
|
155
|
+
}
|
|
156
|
+
latest = {
|
|
157
|
+
createdAt: -1
|
|
158
|
+
};
|
|
159
|
+
oldest = {
|
|
160
|
+
createdAt: 1
|
|
161
|
+
};
|
|
162
|
+
any() {
|
|
163
|
+
return {
|
|
164
|
+
removedAt: {
|
|
165
|
+
$exists: false
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
byStatuses(statuses) {
|
|
170
|
+
return statuses?.length ? {
|
|
171
|
+
status: {
|
|
172
|
+
$in: statuses
|
|
173
|
+
}
|
|
174
|
+
} : {};
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
_ts_decorate([
|
|
178
|
+
Filter.Mongo(),
|
|
179
|
+
_ts_metadata("design:type", Function),
|
|
180
|
+
_ts_metadata("design:paramtypes", []),
|
|
181
|
+
_ts_metadata("design:returntype", void 0)
|
|
182
|
+
], BaseFilter2.prototype, "any", null);
|
|
183
|
+
_ts_decorate([
|
|
184
|
+
Filter.Mongo(),
|
|
185
|
+
_ts_param(0, Filter.Arg("statuses", () => [
|
|
186
|
+
String
|
|
187
|
+
], {
|
|
188
|
+
nullable: true,
|
|
189
|
+
enum: statusFieldMeta?.enum
|
|
190
|
+
})),
|
|
191
|
+
_ts_metadata("design:type", Function),
|
|
192
|
+
_ts_metadata("design:paramtypes", [
|
|
193
|
+
Object
|
|
194
|
+
]),
|
|
195
|
+
_ts_metadata("design:returntype", void 0)
|
|
196
|
+
], BaseFilter2.prototype, "byStatuses", null);
|
|
197
|
+
Object.assign(BaseFilter2.prototype, sort);
|
|
198
|
+
setFilterMeta(BaseFilter2, {
|
|
199
|
+
refName: "BaseFilter",
|
|
200
|
+
sort: Object.assign({
|
|
201
|
+
latest: {
|
|
202
|
+
createdAt: -1
|
|
203
|
+
},
|
|
204
|
+
oldest: {
|
|
205
|
+
createdAt: 1
|
|
206
|
+
}
|
|
207
|
+
}, sort)
|
|
208
|
+
});
|
|
209
|
+
return BaseFilter2;
|
|
210
|
+
}, "sortOf");
|
|
211
|
+
function BaseFilter(modelRef, sort) {
|
|
212
|
+
const fieldMetaMap = (0, import_scalar.getFieldMetaMap)(modelRef);
|
|
213
|
+
const statusFieldMeta = fieldMetaMap.get("status");
|
|
214
|
+
if (!statusFieldMeta) throw new Error(`No status field meta fount in ${modelRef.name}`);
|
|
215
|
+
let BaseFilter2 = class BaseFilter {
|
|
216
|
+
static {
|
|
217
|
+
__name(this, "BaseFilter");
|
|
218
|
+
}
|
|
219
|
+
latest = {
|
|
220
|
+
createdAt: -1
|
|
221
|
+
};
|
|
222
|
+
oldest = {
|
|
223
|
+
createdAt: 1
|
|
224
|
+
};
|
|
225
|
+
any() {
|
|
226
|
+
return {
|
|
227
|
+
removedAt: {
|
|
228
|
+
$exists: false
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
byStatuses(statuses) {
|
|
233
|
+
return statuses?.length ? {
|
|
234
|
+
status: {
|
|
235
|
+
$in: statuses
|
|
236
|
+
}
|
|
237
|
+
} : {};
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
_ts_decorate([
|
|
241
|
+
Filter.Mongo(),
|
|
242
|
+
_ts_metadata("design:type", Function),
|
|
243
|
+
_ts_metadata("design:paramtypes", []),
|
|
244
|
+
_ts_metadata("design:returntype", void 0)
|
|
245
|
+
], BaseFilter2.prototype, "any", null);
|
|
246
|
+
_ts_decorate([
|
|
247
|
+
Filter.Mongo(),
|
|
248
|
+
_ts_param(0, Filter.Arg("statuses", () => [
|
|
249
|
+
String
|
|
250
|
+
], {
|
|
251
|
+
nullable: true,
|
|
252
|
+
enum: statusFieldMeta?.enum
|
|
253
|
+
})),
|
|
254
|
+
_ts_metadata("design:type", Function),
|
|
255
|
+
_ts_metadata("design:paramtypes", [
|
|
256
|
+
Object
|
|
257
|
+
]),
|
|
258
|
+
_ts_metadata("design:returntype", void 0)
|
|
259
|
+
], BaseFilter2.prototype, "byStatuses", null);
|
|
260
|
+
Object.assign(BaseFilter2.prototype, sort);
|
|
261
|
+
setFilterMeta(BaseFilter2, {
|
|
262
|
+
refName: "BaseFilter",
|
|
263
|
+
sort: Object.assign({
|
|
264
|
+
latest: {
|
|
265
|
+
createdAt: -1
|
|
266
|
+
},
|
|
267
|
+
oldest: {
|
|
268
|
+
createdAt: 1
|
|
269
|
+
}
|
|
270
|
+
}, sort)
|
|
271
|
+
});
|
|
272
|
+
return BaseFilter2;
|
|
273
|
+
}
|
|
274
|
+
__name(BaseFilter, "BaseFilter");
|
|
275
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
276
|
+
0 && (module.exports = {
|
|
277
|
+
BaseFilter,
|
|
278
|
+
Filter,
|
|
279
|
+
getFilterArgMetas,
|
|
280
|
+
getFilterKeyMetaMapOnPrototype,
|
|
281
|
+
getFilterMeta,
|
|
282
|
+
getFilterQuery,
|
|
283
|
+
getFilterQueryMap,
|
|
284
|
+
getFilterSort,
|
|
285
|
+
getFilterSortMap,
|
|
286
|
+
isFilterModel,
|
|
287
|
+
setFilterArgMetasOnPrototype,
|
|
288
|
+
setFilterKeyMetaMapOnPrototype,
|
|
289
|
+
setFilterMeta,
|
|
290
|
+
sortOf
|
|
291
|
+
});
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { i as DEFAULT_PAGE_SIZE, D as DocumentModel, F as FilterType, b as FindQueryOption, f as GetActionObject, G as GetPlainObject, e as GetStateObject, c as ListOption, L as ListQueryOption, N as NonFunctionalKeys, g as ProtoAppInfo, P as ProtoFile, h as ProtoPatch, a as SortOf, S as SortType, T as TextDoc, d as defaultListOption } from '../types-DdO4B_Um.js';
|
|
2
|
+
export { Field } from './fieldMeta.js';
|
|
3
|
+
export { ConstantClassMeta, ConstantFieldMeta, ConstantFieldProps, ConstantFilterMeta, FieldType, FilterArgMeta, FilterArgProps, FilterKeyMeta, FilterKeyProps, ReturnType, fieldTypes, getClassMeta, getFieldMetaMap, getFieldMetaMapOnPrototype, getFieldMetas, getGqlTypeStr, getQueryMap, getScalarExample, isConstantModel, scalarExampleMap, setFieldMetaMap, setFieldMetaMapOnPrototype } from './scalar.js';
|
|
4
|
+
export { ConstantModel, cnstOf, getCnstMeta } from './constantDecorator.js';
|
|
5
|
+
export { BaseFilter, BaseFilterKey, Filter, getFilterArgMetas, getFilterKeyMetaMapOnPrototype, getFilterMeta, getFilterQuery, getFilterQueryMap, getFilterSort, getFilterSortMap, isFilterModel, setFilterArgMetasOnPrototype, setFilterKeyMetaMapOnPrototype, setFilterMeta, sortOf } from './filterMeta.js';
|
|
6
|
+
export { as, from, mixModelOf, over, via } from './baseGql.js';
|
|
7
|
+
export { ClassType, FilterModelStorage, FullModelStorage, InputModelStorage, LightModelStorage, Model, ScalarModelStorage, getAllFilterModelRefs, getAllFullModelRefs, getAllScalarModelRefs, getChildClassRefs, getFieldEnumMetas, getFullModelRef, getInputModelRef, getLightModelRef, getScalarModelRef, hasTextField } from './classMeta.js';
|
|
8
|
+
export { FilterQuery as QueryOf } from 'mongoose';
|
|
9
|
+
import 'dayjs';
|
|
10
|
+
import 'fs';
|
|
11
|
+
import 'stream';
|
|
12
|
+
import '../types-b-U-yQib.js';
|
|
13
|
+
import '../base-D8mO_G-C.js';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var src_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(src_exports);
|
|
17
|
+
__reExport(src_exports, require("./types"), module.exports);
|
|
18
|
+
__reExport(src_exports, require("./fieldMeta"), module.exports);
|
|
19
|
+
__reExport(src_exports, require("./scalar"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./constantDecorator"), module.exports);
|
|
21
|
+
__reExport(src_exports, require("./filterMeta"), module.exports);
|
|
22
|
+
__reExport(src_exports, require("./baseGql"), module.exports);
|
|
23
|
+
__reExport(src_exports, require("./classMeta"), module.exports);
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
...require("./types"),
|
|
27
|
+
...require("./fieldMeta"),
|
|
28
|
+
...require("./scalar"),
|
|
29
|
+
...require("./constantDecorator"),
|
|
30
|
+
...require("./filterMeta"),
|
|
31
|
+
...require("./baseGql"),
|
|
32
|
+
...require("./classMeta")
|
|
33
|
+
});
|
package/src/scalar.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { E as Enum } from '../base-D8mO_G-C.js';
|
|
2
|
+
import { j as SingleFieldType, k as GqlScalar, I as Int, U as Upload, l as Float, m as ID, J as JSON, S as SortType } from '../types-DdO4B_Um.js';
|
|
3
|
+
import { T as Type } from '../types-b-U-yQib.js';
|
|
4
|
+
import { FilterQuery, AccumulatorOperator } from 'mongoose';
|
|
5
|
+
import { Dayjs } from 'dayjs';
|
|
6
|
+
import 'fs';
|
|
7
|
+
import 'stream';
|
|
8
|
+
|
|
9
|
+
declare const scalarExampleMap: Map<MapConstructor | typeof Int | typeof Upload | typeof Float | typeof ID | typeof JSON | StringConstructor | BooleanConstructor | DateConstructor, string | number | boolean | object>;
|
|
10
|
+
declare const getScalarExample: (ref: GqlScalar) => string | number | boolean | object | null;
|
|
11
|
+
declare const getGqlTypeStr: (ref: GqlScalar) => string;
|
|
12
|
+
interface ConstantClassMeta {
|
|
13
|
+
refName: string;
|
|
14
|
+
modelRef: any;
|
|
15
|
+
type: "input" | "full" | "light" | "scalar";
|
|
16
|
+
modelType: "data" | "ephemeral" | "summary" | "insight";
|
|
17
|
+
hasTextField: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface ConstantFilterMeta {
|
|
20
|
+
refName: string;
|
|
21
|
+
sort: SortType;
|
|
22
|
+
}
|
|
23
|
+
interface FilterKeyProps {
|
|
24
|
+
type?: "mongo" | "meili";
|
|
25
|
+
}
|
|
26
|
+
interface FilterKeyMeta extends FilterKeyProps {
|
|
27
|
+
key: string;
|
|
28
|
+
descriptor: PropertyDescriptor;
|
|
29
|
+
}
|
|
30
|
+
interface FilterArgProps {
|
|
31
|
+
nullable?: boolean;
|
|
32
|
+
ref?: string;
|
|
33
|
+
default?: string | number | boolean | object | null | (() => string | number | boolean | object | null);
|
|
34
|
+
renderOption?: (value: any) => string;
|
|
35
|
+
enum?: Enum<string | number>;
|
|
36
|
+
}
|
|
37
|
+
interface FilterArgMeta extends FilterArgProps {
|
|
38
|
+
name: string;
|
|
39
|
+
modelRef: Type;
|
|
40
|
+
arrDepth: number;
|
|
41
|
+
isArray: boolean;
|
|
42
|
+
optArrDepth: number;
|
|
43
|
+
}
|
|
44
|
+
declare const fieldTypes: readonly ["email", "password", "url"];
|
|
45
|
+
type FieldType = (typeof fieldTypes)[number];
|
|
46
|
+
type ReturnType<T extends SingleFieldType = SingleFieldType> = (of?: any) => T | [T] | [[T]] | Map<string, any>;
|
|
47
|
+
interface ConstantFieldProps {
|
|
48
|
+
nullable?: boolean;
|
|
49
|
+
ref?: string;
|
|
50
|
+
refPath?: string;
|
|
51
|
+
refType?: "child" | "parent" | "relation";
|
|
52
|
+
default?: string | number | boolean | object | null | Enum<string | number>;
|
|
53
|
+
type?: FieldType;
|
|
54
|
+
fieldType?: "property" | "hidden" | "resolve";
|
|
55
|
+
immutable?: boolean;
|
|
56
|
+
min?: number;
|
|
57
|
+
max?: number;
|
|
58
|
+
enum?: Enum<string | number>;
|
|
59
|
+
select?: boolean;
|
|
60
|
+
minlength?: number;
|
|
61
|
+
maxlength?: number;
|
|
62
|
+
query?: FilterQuery<any> | (() => FilterQuery<any>);
|
|
63
|
+
accumulate?: AccumulatorOperator;
|
|
64
|
+
example?: string | number | boolean | Dayjs | string[] | number[] | boolean[] | Dayjs[];
|
|
65
|
+
of?: GqlScalar;
|
|
66
|
+
validate?: (value: any, model: any) => boolean;
|
|
67
|
+
text?: "search" | "filter";
|
|
68
|
+
}
|
|
69
|
+
type ConstantFieldMeta = ConstantFieldProps & {
|
|
70
|
+
nullable: boolean;
|
|
71
|
+
default: any;
|
|
72
|
+
fieldType: "property" | "hidden" | "resolve";
|
|
73
|
+
immutable: boolean;
|
|
74
|
+
select: boolean;
|
|
75
|
+
} & {
|
|
76
|
+
key: string;
|
|
77
|
+
name: string;
|
|
78
|
+
isClass: boolean;
|
|
79
|
+
isScalar: boolean;
|
|
80
|
+
modelRef: Type;
|
|
81
|
+
arrDepth: number;
|
|
82
|
+
isArray: boolean;
|
|
83
|
+
optArrDepth: number;
|
|
84
|
+
isMap: boolean;
|
|
85
|
+
};
|
|
86
|
+
declare const getClassMeta: (modelRef: Type) => ConstantClassMeta;
|
|
87
|
+
declare const getFieldMetas: (modelRef: Type) => ConstantFieldMeta[];
|
|
88
|
+
declare const isConstantModel: (modelRef: Type) => boolean;
|
|
89
|
+
declare const getFieldMetaMap: (modelRef: Type) => Map<string, ConstantFieldMeta>;
|
|
90
|
+
declare const setFieldMetaMap: (modelRef: Type, metadataMap: Map<string, ConstantFieldMeta>) => void;
|
|
91
|
+
declare const getFieldMetaMapOnPrototype: (prototype: object) => Map<string, ConstantFieldMeta>;
|
|
92
|
+
declare const setFieldMetaMapOnPrototype: (prototype: object, metadataMap: Map<string, ConstantFieldMeta>) => void;
|
|
93
|
+
declare const getQueryMap: (modelRef: Type) => {
|
|
94
|
+
[key: string]: FilterQuery<any> | undefined | (() => FilterQuery<any>);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export { type ConstantClassMeta, type ConstantFieldMeta, type ConstantFieldProps, type ConstantFilterMeta, type FieldType, type FilterArgMeta, type FilterArgProps, type FilterKeyMeta, type FilterKeyProps, type ReturnType, fieldTypes, getClassMeta, getFieldMetaMap, getFieldMetaMapOnPrototype, getFieldMetas, getGqlTypeStr, getQueryMap, getScalarExample, isConstantModel, scalarExampleMap, setFieldMetaMap, setFieldMetaMapOnPrototype };
|