@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/scalar.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
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 scalar_exports = {};
|
|
20
|
+
__export(scalar_exports, {
|
|
21
|
+
fieldTypes: () => fieldTypes,
|
|
22
|
+
getClassMeta: () => getClassMeta,
|
|
23
|
+
getFieldMetaMap: () => getFieldMetaMap,
|
|
24
|
+
getFieldMetaMapOnPrototype: () => getFieldMetaMapOnPrototype,
|
|
25
|
+
getFieldMetas: () => getFieldMetas,
|
|
26
|
+
getGqlTypeStr: () => getGqlTypeStr,
|
|
27
|
+
getQueryMap: () => getQueryMap,
|
|
28
|
+
getScalarExample: () => getScalarExample,
|
|
29
|
+
isConstantModel: () => isConstantModel,
|
|
30
|
+
scalarExampleMap: () => scalarExampleMap,
|
|
31
|
+
setFieldMetaMap: () => setFieldMetaMap,
|
|
32
|
+
setFieldMetaMapOnPrototype: () => setFieldMetaMapOnPrototype
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(scalar_exports);
|
|
35
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
36
|
+
var import_base = require("@akanjs/base");
|
|
37
|
+
const scalarExampleMap = /* @__PURE__ */ new Map([
|
|
38
|
+
[
|
|
39
|
+
import_base.ID,
|
|
40
|
+
"1234567890abcdef12345678"
|
|
41
|
+
],
|
|
42
|
+
[
|
|
43
|
+
import_base.Int,
|
|
44
|
+
0
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
import_base.Float,
|
|
48
|
+
0
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
String,
|
|
52
|
+
"String"
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
Boolean,
|
|
56
|
+
true
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
Date,
|
|
60
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
import_base.Upload,
|
|
64
|
+
"FileUpload"
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
import_base.JSON,
|
|
68
|
+
{}
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
Map,
|
|
72
|
+
{}
|
|
73
|
+
]
|
|
74
|
+
]);
|
|
75
|
+
const getScalarExample = /* @__PURE__ */ __name((ref) => scalarExampleMap.get(ref) ?? null, "getScalarExample");
|
|
76
|
+
const getGqlTypeStr = /* @__PURE__ */ __name((ref) => import_base.scalarNameMap.get(ref) ?? getClassMeta(ref).refName, "getGqlTypeStr");
|
|
77
|
+
const fieldTypes = [
|
|
78
|
+
"email",
|
|
79
|
+
"password",
|
|
80
|
+
"url"
|
|
81
|
+
];
|
|
82
|
+
const getClassMeta = /* @__PURE__ */ __name((modelRef) => {
|
|
83
|
+
const [target] = (0, import_base.getNonArrayModel)(modelRef);
|
|
84
|
+
const classMeta = Reflect.getMetadata("class", target.prototype);
|
|
85
|
+
if (!classMeta) throw new Error(`No ClassMeta for this target ${target.name}`);
|
|
86
|
+
return classMeta;
|
|
87
|
+
}, "getClassMeta");
|
|
88
|
+
const getFieldMetas = /* @__PURE__ */ __name((modelRef) => {
|
|
89
|
+
const [target] = (0, import_base.getNonArrayModel)(modelRef);
|
|
90
|
+
const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
|
|
91
|
+
const keySortMap = {
|
|
92
|
+
id: -1,
|
|
93
|
+
createdAt: 1,
|
|
94
|
+
updatedAt: 2,
|
|
95
|
+
removedAt: 3
|
|
96
|
+
};
|
|
97
|
+
return [
|
|
98
|
+
...metadataMap.values()
|
|
99
|
+
].sort((a, b) => (keySortMap[a.key] ?? 0) - (keySortMap[b.key] ?? 0));
|
|
100
|
+
}, "getFieldMetas");
|
|
101
|
+
const isConstantModel = /* @__PURE__ */ __name((modelRef) => {
|
|
102
|
+
return Reflect.getMetadata("class", modelRef.prototype) !== void 0;
|
|
103
|
+
}, "isConstantModel");
|
|
104
|
+
const getFieldMetaMap = /* @__PURE__ */ __name((modelRef) => {
|
|
105
|
+
const [target] = (0, import_base.getNonArrayModel)(modelRef);
|
|
106
|
+
const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
|
|
107
|
+
return new Map(metadataMap);
|
|
108
|
+
}, "getFieldMetaMap");
|
|
109
|
+
const setFieldMetaMap = /* @__PURE__ */ __name((modelRef, metadataMap) => {
|
|
110
|
+
const [target] = (0, import_base.getNonArrayModel)(modelRef);
|
|
111
|
+
Reflect.defineMetadata("fields", new Map(metadataMap), target.prototype);
|
|
112
|
+
}, "setFieldMetaMap");
|
|
113
|
+
const getFieldMetaMapOnPrototype = /* @__PURE__ */ __name((prototype) => {
|
|
114
|
+
const metadataMap = Reflect.getMetadata("fields", prototype) ?? /* @__PURE__ */ new Map();
|
|
115
|
+
return new Map(metadataMap);
|
|
116
|
+
}, "getFieldMetaMapOnPrototype");
|
|
117
|
+
const setFieldMetaMapOnPrototype = /* @__PURE__ */ __name((prototype, metadataMap) => {
|
|
118
|
+
Reflect.defineMetadata("fields", new Map(metadataMap), prototype);
|
|
119
|
+
}, "setFieldMetaMapOnPrototype");
|
|
120
|
+
const getQueryMap = /* @__PURE__ */ __name((modelRef) => {
|
|
121
|
+
const fieldMetas = getFieldMetas(modelRef);
|
|
122
|
+
return Object.fromEntries(fieldMetas.filter((fieldMeta) => !!fieldMeta.query).map((fieldMeta) => [
|
|
123
|
+
fieldMeta.key,
|
|
124
|
+
fieldMeta.query
|
|
125
|
+
]));
|
|
126
|
+
}, "getQueryMap");
|
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
+
0 && (module.exports = {
|
|
129
|
+
fieldTypes,
|
|
130
|
+
getClassMeta,
|
|
131
|
+
getFieldMetaMap,
|
|
132
|
+
getFieldMetaMapOnPrototype,
|
|
133
|
+
getFieldMetas,
|
|
134
|
+
getGqlTypeStr,
|
|
135
|
+
getQueryMap,
|
|
136
|
+
getScalarExample,
|
|
137
|
+
isConstantModel,
|
|
138
|
+
scalarExampleMap,
|
|
139
|
+
setFieldMetaMap,
|
|
140
|
+
setFieldMetaMapOnPrototype
|
|
141
|
+
});
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
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 { FilterQuery as QueryOf } from 'mongoose';
|
|
3
|
+
import 'dayjs';
|
|
4
|
+
import 'fs';
|
|
5
|
+
import 'stream';
|
|
6
|
+
import '../types-b-U-yQib.js';
|
package/src/types.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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 types_exports = {};
|
|
19
|
+
__export(types_exports, {
|
|
20
|
+
DEFAULT_PAGE_SIZE: () => DEFAULT_PAGE_SIZE,
|
|
21
|
+
defaultListOption: () => defaultListOption
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(types_exports);
|
|
24
|
+
const defaultListOption = {
|
|
25
|
+
limit: 20,
|
|
26
|
+
skip: 0,
|
|
27
|
+
sort: "latest"
|
|
28
|
+
};
|
|
29
|
+
const DEFAULT_PAGE_SIZE = 20;
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
DEFAULT_PAGE_SIZE,
|
|
33
|
+
defaultListOption
|
|
34
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
import { ReadStream } from 'fs';
|
|
3
|
+
import { Readable } from 'stream';
|
|
4
|
+
import { T as Type, G as GraphQLJSON, a as GraphQLUpload } from './types-b-U-yQib.js';
|
|
5
|
+
import { ProjectionType, HydratedDocument } from 'mongoose';
|
|
6
|
+
|
|
7
|
+
declare class BaseObject {
|
|
8
|
+
id: string;
|
|
9
|
+
createdAt: Dayjs;
|
|
10
|
+
updatedAt: Dayjs;
|
|
11
|
+
removedAt: Dayjs | null;
|
|
12
|
+
}
|
|
13
|
+
declare class Int {
|
|
14
|
+
__Scalar__: "int";
|
|
15
|
+
}
|
|
16
|
+
declare class Upload {
|
|
17
|
+
__Scalar__: "upload";
|
|
18
|
+
filename: string;
|
|
19
|
+
mimetype: string;
|
|
20
|
+
encoding: string;
|
|
21
|
+
createReadStream: () => ReadStream | Readable;
|
|
22
|
+
}
|
|
23
|
+
declare class Float {
|
|
24
|
+
__Scalar__: "float";
|
|
25
|
+
}
|
|
26
|
+
declare class ID {
|
|
27
|
+
__Scalar__: "id";
|
|
28
|
+
}
|
|
29
|
+
declare class JSON {
|
|
30
|
+
__Scalar__: "json";
|
|
31
|
+
}
|
|
32
|
+
type SingleFieldType = Int | Float | StringConstructor | BooleanConstructor | ID | DateConstructor | JSON | Type | GraphQLJSON | GraphQLUpload;
|
|
33
|
+
declare const gqlScalars: readonly [StringConstructor, BooleanConstructor, DateConstructor, typeof ID, typeof Int, typeof Float, typeof Upload, typeof JSON, MapConstructor];
|
|
34
|
+
type GqlScalar = (typeof gqlScalars)[number];
|
|
35
|
+
|
|
36
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
37
|
+
type OptionalKeys<T> = T extends {
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
} ? {
|
|
40
|
+
[K in keyof T]-?: null extends T[K] ? K : never;
|
|
41
|
+
}[keyof T] : never;
|
|
42
|
+
type ObjectToId<O, D = Dayjs> = O extends BaseObject ? string : O extends BaseObject[] ? string[] : O extends Dayjs ? D : O extends {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
} ? DocumentModel<O> : O;
|
|
45
|
+
interface SortType {
|
|
46
|
+
[key: string]: {
|
|
47
|
+
[key: string]: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
type SortOf<Filter> = keyof GetStateObject<Filter>;
|
|
51
|
+
type FilterType = Record<string, any>;
|
|
52
|
+
interface ListQueryOption<Sort, Obj> {
|
|
53
|
+
skip?: number | null;
|
|
54
|
+
limit?: number | null;
|
|
55
|
+
sort?: Sort | null;
|
|
56
|
+
sample?: number;
|
|
57
|
+
select?: ProjectionType<Obj>;
|
|
58
|
+
}
|
|
59
|
+
interface FindQueryOption<Sort, Obj> {
|
|
60
|
+
skip?: number | null;
|
|
61
|
+
sort?: Sort | null;
|
|
62
|
+
sample?: boolean;
|
|
63
|
+
select?: ProjectionType<Obj>;
|
|
64
|
+
}
|
|
65
|
+
type DocumentModel<T, D = Dayjs> = T extends (infer S)[] ? DocumentModel<S>[] : T extends string ? T : T extends number ? T : T extends boolean ? T : T extends Dayjs ? T : T extends Map<infer K, infer V> ? Map<K, DocumentModel<V, D>> : Optional<{
|
|
66
|
+
[K in keyof GetStateObject<T>]: T[K] extends infer S ? S extends null ? undefined : ObjectToId<T[K], D> : never;
|
|
67
|
+
}, OptionalKeys<GetStateObject<T>>>;
|
|
68
|
+
interface ListOption {
|
|
69
|
+
limit?: number;
|
|
70
|
+
skip?: number;
|
|
71
|
+
sort?: string;
|
|
72
|
+
}
|
|
73
|
+
declare const defaultListOption: ListOption;
|
|
74
|
+
type GetPlainObject<T, O extends string> = Omit<{
|
|
75
|
+
[K in keyof T as T[K] extends (...args: any) => any ? never : K extends keyof HydratedDocument<any> ? never : K]: T[K];
|
|
76
|
+
}, O>;
|
|
77
|
+
type GetStateObject<T> = Omit<{
|
|
78
|
+
[K in keyof T as T[K] extends (...args: any) => any ? never : K]: T[K];
|
|
79
|
+
}, "prototype">;
|
|
80
|
+
type GetActionObject<T> = Omit<{
|
|
81
|
+
[K in keyof T as T[K] extends (...args: any) => any ? K : never]: T[K];
|
|
82
|
+
}, "prototype">;
|
|
83
|
+
interface ProtoFile {
|
|
84
|
+
id: string;
|
|
85
|
+
filename: string;
|
|
86
|
+
abstractData: string | null;
|
|
87
|
+
imageSize: [number, number];
|
|
88
|
+
progress: number | null;
|
|
89
|
+
url: string;
|
|
90
|
+
size: number;
|
|
91
|
+
status: string;
|
|
92
|
+
createdAt: Dayjs;
|
|
93
|
+
updatedAt: Dayjs;
|
|
94
|
+
removedAt: Dayjs | null;
|
|
95
|
+
mimetype: string;
|
|
96
|
+
encoding: string;
|
|
97
|
+
origin: string | null;
|
|
98
|
+
lastModifiedAt: Dayjs;
|
|
99
|
+
}
|
|
100
|
+
interface ProtoAppInfo {
|
|
101
|
+
appId: string | null;
|
|
102
|
+
appName: string;
|
|
103
|
+
deviceId: string | null;
|
|
104
|
+
platform: "ios" | "android" | null;
|
|
105
|
+
major: number;
|
|
106
|
+
minor: number;
|
|
107
|
+
patch: number;
|
|
108
|
+
branch: string;
|
|
109
|
+
buildNum: string | null;
|
|
110
|
+
versionOs: string | null;
|
|
111
|
+
isEmulator: boolean | null;
|
|
112
|
+
}
|
|
113
|
+
interface ProtoPatch {
|
|
114
|
+
source: ProtoFile;
|
|
115
|
+
build: ProtoFile;
|
|
116
|
+
appBuild: ProtoFile | null;
|
|
117
|
+
status: "active" | "expired";
|
|
118
|
+
at: Dayjs;
|
|
119
|
+
}
|
|
120
|
+
declare const DEFAULT_PAGE_SIZE = 20;
|
|
121
|
+
interface TextDoc {
|
|
122
|
+
[key: string]: string | TextDoc;
|
|
123
|
+
}
|
|
124
|
+
type NonFunctionalKeys<T> = keyof T extends (...any: any[]) => any ? never : keyof T;
|
|
125
|
+
|
|
126
|
+
export { BaseObject as B, type DocumentModel as D, type FilterType as F, type GetPlainObject as G, Int as I, JSON as J, type ListQueryOption as L, type NonFunctionalKeys as N, type ProtoFile as P, type SortType as S, type TextDoc as T, Upload as U, type SortOf as a, type FindQueryOption as b, type ListOption as c, defaultListOption as d, type GetStateObject as e, type GetActionObject as f, type ProtoAppInfo as g, type ProtoPatch as h, DEFAULT_PAGE_SIZE as i, type SingleFieldType as j, type GqlScalar as k, Float as l, ID as m };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
type Type<T = any> = new (...args: any[]) => T;
|
|
2
|
+
interface GraphQLUpload {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
specifiedByUrl: string;
|
|
6
|
+
serialize: any;
|
|
7
|
+
parseValue: any;
|
|
8
|
+
parseLiteral: any;
|
|
9
|
+
extensions: any;
|
|
10
|
+
astNode: any;
|
|
11
|
+
extensionASTNodes: any;
|
|
12
|
+
toConfig(): any;
|
|
13
|
+
toString(): string;
|
|
14
|
+
toJSON(): string;
|
|
15
|
+
inspect(): string;
|
|
16
|
+
}
|
|
17
|
+
interface GraphQLJSON<TInternal = unknown, TExternal = TInternal> {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
specifiedByURL: string;
|
|
21
|
+
serialize: any;
|
|
22
|
+
parseValue: any;
|
|
23
|
+
parseLiteral: any;
|
|
24
|
+
extensions: any;
|
|
25
|
+
astNode: any;
|
|
26
|
+
extensionASTNodes: any;
|
|
27
|
+
get [Symbol.toStringTag](): string;
|
|
28
|
+
toConfig(): any;
|
|
29
|
+
toString(): string;
|
|
30
|
+
toJSON(): string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type { GraphQLJSON as G, Type as T, GraphQLUpload as a };
|