@akanjs/server 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/dbDecorators-z3rJpvxp.d.ts +36 -0
- package/index.d.ts +23 -0
- package/index.js +20 -3780
- package/package.json +2 -44
- package/src/boot.d.ts +49 -0
- package/src/boot.js +258 -0
- package/src/controller.d.ts +9 -0
- package/src/controller.js +96 -0
- package/src/gql.d.ts +77 -0
- package/src/gql.js +172 -0
- package/src/index.d.ts +23 -0
- package/src/index.js +39 -0
- package/src/module.d.ts +95 -0
- package/src/module.js +347 -0
- package/src/processor.d.ts +11 -0
- package/src/processor.js +85 -0
- package/src/resolver.d.ts +9 -0
- package/src/resolver.js +161 -0
- package/src/schema.d.ts +12 -0
- package/src/schema.js +275 -0
- package/src/searchDaemon.d.ts +13 -0
- package/src/searchDaemon.js +282 -0
- package/src/types.d.ts +18 -0
- package/src/types.js +15 -0
- package/src/websocket.d.ts +20 -0
- package/src/websocket.js +192 -0
- package/types-CUkhtrLV.d.ts +53 -0
- package/types-H2HI4YUe.d.ts +3 -0
package/src/gql.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
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
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var gql_exports = {};
|
|
30
|
+
__export(gql_exports, {
|
|
31
|
+
DateScalar: () => DateScalar,
|
|
32
|
+
applyNestField: () => applyNestField,
|
|
33
|
+
generateGql: () => generateGql,
|
|
34
|
+
generateGqlInput: () => generateGqlInput
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(gql_exports);
|
|
37
|
+
var import_base = require("@akanjs/base");
|
|
38
|
+
var import_constant = require("@akanjs/constant");
|
|
39
|
+
var Nest = __toESM(require("@nestjs/graphql"));
|
|
40
|
+
var import_graphql = require("@nestjs/graphql");
|
|
41
|
+
var import_dayjs = require("dayjs");
|
|
42
|
+
var import_graphql2 = require("graphql");
|
|
43
|
+
var import_graphql_type_json = __toESM(require("graphql-type-json"));
|
|
44
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
45
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
46
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
47
|
+
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;
|
|
48
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
49
|
+
}
|
|
50
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
51
|
+
class DateScalar {
|
|
52
|
+
static {
|
|
53
|
+
__name(this, "DateScalar");
|
|
54
|
+
}
|
|
55
|
+
description = "Date custom scalar type";
|
|
56
|
+
parseValue(value) {
|
|
57
|
+
return (0, import_base.dayjs)(value);
|
|
58
|
+
}
|
|
59
|
+
serialize(value) {
|
|
60
|
+
if ((0, import_dayjs.isDayjs)(value)) return value.toDate();
|
|
61
|
+
else return new Date(value);
|
|
62
|
+
}
|
|
63
|
+
parseLiteral(ast) {
|
|
64
|
+
if (ast.kind === import_graphql2.Kind.INT) return (0, import_base.dayjs)(ast.value);
|
|
65
|
+
else if (ast.kind === import_graphql2.Kind.STRING) return (0, import_base.dayjs)(ast.value);
|
|
66
|
+
else return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
DateScalar = _ts_decorate([
|
|
70
|
+
Nest.Scalar("Date", () => Date)
|
|
71
|
+
], DateScalar);
|
|
72
|
+
let ObjectGqlStorage = class ObjectGqlStorage2 {
|
|
73
|
+
static {
|
|
74
|
+
__name(this, "ObjectGqlStorage");
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
let InputGqlStorage = class InputGqlStorage2 {
|
|
78
|
+
static {
|
|
79
|
+
__name(this, "InputGqlStorage");
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const getPredefinedInqutGql = /* @__PURE__ */ __name((refName) => {
|
|
83
|
+
const inputGql = Reflect.getMetadata(refName, InputGqlStorage.prototype);
|
|
84
|
+
return inputGql;
|
|
85
|
+
}, "getPredefinedInqutGql");
|
|
86
|
+
const setPredefinedInqutGql = /* @__PURE__ */ __name((refName, inputGql) => {
|
|
87
|
+
Reflect.defineMetadata(refName, inputGql, InputGqlStorage.prototype);
|
|
88
|
+
}, "setPredefinedInqutGql");
|
|
89
|
+
const getPredefinedObjectGql = /* @__PURE__ */ __name((refName) => {
|
|
90
|
+
const objectGql = Reflect.getMetadata(refName, ObjectGqlStorage.prototype);
|
|
91
|
+
return objectGql;
|
|
92
|
+
}, "getPredefinedObjectGql");
|
|
93
|
+
const setPredefinedObjectGql = /* @__PURE__ */ __name((refName, objectGql) => {
|
|
94
|
+
Reflect.defineMetadata(refName, objectGql, ObjectGqlStorage.prototype);
|
|
95
|
+
}, "setPredefinedObjectGql");
|
|
96
|
+
const gqlNestFieldMap = /* @__PURE__ */ new Map([
|
|
97
|
+
[
|
|
98
|
+
import_base.ID,
|
|
99
|
+
Nest.ID
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
import_base.Int,
|
|
103
|
+
Nest.Int
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
import_base.Float,
|
|
107
|
+
Nest.Float
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
import_base.JSON,
|
|
111
|
+
import_graphql_type_json.default
|
|
112
|
+
],
|
|
113
|
+
[
|
|
114
|
+
Map,
|
|
115
|
+
import_graphql_type_json.default
|
|
116
|
+
]
|
|
117
|
+
]);
|
|
118
|
+
const applyNestField = /* @__PURE__ */ __name((model, fieldMeta, type = "object") => {
|
|
119
|
+
if (fieldMeta.fieldType === "hidden" && type === "object") return;
|
|
120
|
+
const modelRef = fieldMeta.isClass ? type === "object" ? generateGql(fieldMeta.modelRef) : fieldMeta.isScalar ? generateGqlInput(fieldMeta.modelRef) : Nest.ID : gqlNestFieldMap.get(fieldMeta.modelRef) ?? fieldMeta.modelRef;
|
|
121
|
+
(0, import_graphql.Field)(() => (0, import_base.arraiedModel)(modelRef, fieldMeta.arrDepth), {
|
|
122
|
+
nullable: fieldMeta.nullable
|
|
123
|
+
})(model.prototype, fieldMeta.key);
|
|
124
|
+
}, "applyNestField");
|
|
125
|
+
const generateGqlInput = /* @__PURE__ */ __name((inputRef) => {
|
|
126
|
+
const classMeta = (0, import_constant.getClassMeta)(inputRef);
|
|
127
|
+
const predefinedInputGql = getPredefinedInqutGql(classMeta.refName);
|
|
128
|
+
if (predefinedInputGql) return predefinedInputGql;
|
|
129
|
+
const fieldMetas = (0, import_constant.getFieldMetas)(inputRef);
|
|
130
|
+
let InputGql = class InputGql {
|
|
131
|
+
static {
|
|
132
|
+
__name(this, "InputGql");
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const inputGql = classMeta.type === "scalar" ? InputGql : (0, import_constant.getInputModelRef)(classMeta.refName);
|
|
136
|
+
fieldMetas.forEach((fieldMeta) => {
|
|
137
|
+
applyNestField(inputGql, fieldMeta, "input");
|
|
138
|
+
});
|
|
139
|
+
(0, import_graphql.InputType)(classMeta.refName + (classMeta.type === "scalar" ? "Input" : ""))(inputGql);
|
|
140
|
+
setPredefinedInqutGql(classMeta.refName, inputGql);
|
|
141
|
+
return inputGql;
|
|
142
|
+
}, "generateGqlInput");
|
|
143
|
+
const generateGql = /* @__PURE__ */ __name((objectRef) => {
|
|
144
|
+
const classMeta = (0, import_constant.getClassMeta)(objectRef);
|
|
145
|
+
if (classMeta.type === "light") {
|
|
146
|
+
const fullModelRefName = classMeta.refName.slice(5);
|
|
147
|
+
const fullModelRef = (0, import_constant.getFullModelRef)(fullModelRefName);
|
|
148
|
+
return generateGql(fullModelRef);
|
|
149
|
+
}
|
|
150
|
+
const predefinedObjectGql = getPredefinedObjectGql(classMeta.refName);
|
|
151
|
+
if (predefinedObjectGql) return predefinedObjectGql;
|
|
152
|
+
const fieldMetas = (0, import_constant.getFieldMetas)(objectRef);
|
|
153
|
+
let ObjectGql = class ObjectGql {
|
|
154
|
+
static {
|
|
155
|
+
__name(this, "ObjectGql");
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const objectGql = classMeta.type === "scalar" ? ObjectGql : (0, import_constant.getFullModelRef)(classMeta.refName);
|
|
159
|
+
fieldMetas.forEach((fieldMeta) => {
|
|
160
|
+
applyNestField(objectGql, fieldMeta);
|
|
161
|
+
});
|
|
162
|
+
(0, import_graphql.ObjectType)(classMeta.refName)(objectGql);
|
|
163
|
+
setPredefinedObjectGql(classMeta.refName, objectGql);
|
|
164
|
+
return objectGql;
|
|
165
|
+
}, "generateGql");
|
|
166
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
167
|
+
0 && (module.exports = {
|
|
168
|
+
DateScalar,
|
|
169
|
+
applyNestField,
|
|
170
|
+
generateGql,
|
|
171
|
+
generateGqlInput
|
|
172
|
+
});
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { DateScalar, applyNestField, generateGql, generateGqlInput } from './gql.js';
|
|
2
|
+
export { resolverOf } from './resolver.js';
|
|
3
|
+
export { controllerOf } from './controller.js';
|
|
4
|
+
export { processorOf, queueOf } from './processor.js';
|
|
5
|
+
export { batchModuleOf, databaseModuleOf, scalarModuleOf, scalarModulesOf, serviceModuleOf, useGlobals } from './module.js';
|
|
6
|
+
export { FileStream, LocalFile } from './types.js';
|
|
7
|
+
export { Response, websocketOf, websocketServerOf } from './websocket.js';
|
|
8
|
+
export { BackendApp, createNestApp } from './boot.js';
|
|
9
|
+
export { SearchDaemonModule, makeTextFilter } from './searchDaemon.js';
|
|
10
|
+
export { addSchema, schemaOf } from './schema.js';
|
|
11
|
+
export { DynamicModule as Module } from '@nestjs/common';
|
|
12
|
+
import '../types-CUkhtrLV.js';
|
|
13
|
+
import 'dayjs';
|
|
14
|
+
import 'fs';
|
|
15
|
+
import 'stream';
|
|
16
|
+
import '../types-H2HI4YUe.js';
|
|
17
|
+
import 'mongoose';
|
|
18
|
+
import '../dbDecorators-z3rJpvxp.js';
|
|
19
|
+
import '@nestjs/graphql';
|
|
20
|
+
import 'graphql';
|
|
21
|
+
import 'bull';
|
|
22
|
+
import 'socket.io';
|
|
23
|
+
import 'tunnel-ssh';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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("./gql"), module.exports);
|
|
18
|
+
__reExport(src_exports, require("./resolver"), module.exports);
|
|
19
|
+
__reExport(src_exports, require("./controller"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./processor"), module.exports);
|
|
21
|
+
__reExport(src_exports, require("./module"), module.exports);
|
|
22
|
+
__reExport(src_exports, require("./types"), module.exports);
|
|
23
|
+
__reExport(src_exports, require("./websocket"), module.exports);
|
|
24
|
+
__reExport(src_exports, require("./boot"), module.exports);
|
|
25
|
+
__reExport(src_exports, require("./searchDaemon"), module.exports);
|
|
26
|
+
__reExport(src_exports, require("./schema"), module.exports);
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
...require("./gql"),
|
|
30
|
+
...require("./resolver"),
|
|
31
|
+
...require("./controller"),
|
|
32
|
+
...require("./processor"),
|
|
33
|
+
...require("./module"),
|
|
34
|
+
...require("./types"),
|
|
35
|
+
...require("./websocket"),
|
|
36
|
+
...require("./boot"),
|
|
37
|
+
...require("./searchDaemon"),
|
|
38
|
+
...require("./schema")
|
|
39
|
+
});
|
package/src/module.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { T as Type } from '../types-H2HI4YUe.js';
|
|
2
|
+
import { F as FilterType } from '../types-CUkhtrLV.js';
|
|
3
|
+
import { D as Database } from '../dbDecorators-z3rJpvxp.js';
|
|
4
|
+
import { DynamicModule } from '@nestjs/common';
|
|
5
|
+
import 'dayjs';
|
|
6
|
+
import 'fs';
|
|
7
|
+
import 'stream';
|
|
8
|
+
import 'mongoose';
|
|
9
|
+
|
|
10
|
+
interface ConstantModel<T extends string, Input, Full, Light, Insight, Filter extends FilterType, Summary = any> {
|
|
11
|
+
refName: T;
|
|
12
|
+
Input: Type<Input>;
|
|
13
|
+
Full: Type<Full>;
|
|
14
|
+
Light: Type<Light>;
|
|
15
|
+
Insight: Type<Insight>;
|
|
16
|
+
Filter: Type<Filter>;
|
|
17
|
+
Summary?: Type<Summary>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface DatabaseModuleCreateOptions {
|
|
21
|
+
constant: ConstantModel<string, any, any, any, any, any>;
|
|
22
|
+
database: Database<string, any, any, any, any, any, any, any, any>;
|
|
23
|
+
signal: Type;
|
|
24
|
+
service: Type;
|
|
25
|
+
uses?: {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
};
|
|
28
|
+
useAsyncs?: {
|
|
29
|
+
[key: string]: () => Promise<any>;
|
|
30
|
+
};
|
|
31
|
+
providers?: Type[];
|
|
32
|
+
extended?: boolean;
|
|
33
|
+
}
|
|
34
|
+
declare const databaseModuleOf: ({ constant, database, signal, service, uses, useAsyncs, providers, extended, }: DatabaseModuleCreateOptions, allSrvs: {
|
|
35
|
+
[key: string]: Type | undefined;
|
|
36
|
+
}) => DynamicModule | null;
|
|
37
|
+
interface ServiceModuleCreateOptions {
|
|
38
|
+
signal: Type;
|
|
39
|
+
service: Type;
|
|
40
|
+
uses?: {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
};
|
|
43
|
+
useAsyncs?: {
|
|
44
|
+
[key: string]: () => Promise<any>;
|
|
45
|
+
};
|
|
46
|
+
providers?: Type[];
|
|
47
|
+
}
|
|
48
|
+
declare const serviceModuleOf: ({ signal, service, uses, useAsyncs, providers }: ServiceModuleCreateOptions, allSrvs: {
|
|
49
|
+
[key: string]: Type | undefined;
|
|
50
|
+
}) => DynamicModule | null;
|
|
51
|
+
interface ScalarModuleCreateOptions {
|
|
52
|
+
signals: Type[];
|
|
53
|
+
uses?: {
|
|
54
|
+
[key: string]: any;
|
|
55
|
+
};
|
|
56
|
+
useAsyncs?: {
|
|
57
|
+
[key: string]: () => Promise<any>;
|
|
58
|
+
};
|
|
59
|
+
providers?: Type[];
|
|
60
|
+
enabled?: boolean;
|
|
61
|
+
}
|
|
62
|
+
declare const scalarModuleOf: ({ signals, uses, useAsyncs, providers, enabled }: ScalarModuleCreateOptions, allSrvs: {
|
|
63
|
+
[key: string]: Type | undefined;
|
|
64
|
+
}) => DynamicModule | null;
|
|
65
|
+
interface ScalarModulesCreateOptions {
|
|
66
|
+
constants: Type[];
|
|
67
|
+
}
|
|
68
|
+
declare const scalarModulesOf: ({ constants }: ScalarModulesCreateOptions, allSrvs: {
|
|
69
|
+
[key: string]: Type | undefined;
|
|
70
|
+
}) => DynamicModule | null;
|
|
71
|
+
interface BatchModuleCreateOptions {
|
|
72
|
+
service: Type;
|
|
73
|
+
uses?: {
|
|
74
|
+
[key: string]: any;
|
|
75
|
+
};
|
|
76
|
+
useAsyncs?: {
|
|
77
|
+
[key: string]: () => Promise<any>;
|
|
78
|
+
};
|
|
79
|
+
providers?: Type[];
|
|
80
|
+
}
|
|
81
|
+
declare const batchModuleOf: ({ service, uses, useAsyncs, providers, }: BatchModuleCreateOptions) => DynamicModule | null;
|
|
82
|
+
interface UseGlobalsCreateOptions {
|
|
83
|
+
uses?: {
|
|
84
|
+
[key: string]: any;
|
|
85
|
+
};
|
|
86
|
+
useAsyncs?: {
|
|
87
|
+
[key: string]: () => Promise<any>;
|
|
88
|
+
};
|
|
89
|
+
injects?: {
|
|
90
|
+
[key: string]: Type;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
declare const useGlobals: ({ uses, useAsyncs, injects }: UseGlobalsCreateOptions) => DynamicModule;
|
|
94
|
+
|
|
95
|
+
export { batchModuleOf, databaseModuleOf, scalarModuleOf, scalarModulesOf, serviceModuleOf, useGlobals };
|
package/src/module.js
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
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 module_exports = {};
|
|
20
|
+
__export(module_exports, {
|
|
21
|
+
batchModuleOf: () => batchModuleOf,
|
|
22
|
+
databaseModuleOf: () => databaseModuleOf,
|
|
23
|
+
scalarModuleOf: () => scalarModuleOf,
|
|
24
|
+
scalarModulesOf: () => scalarModulesOf,
|
|
25
|
+
serviceModuleOf: () => serviceModuleOf,
|
|
26
|
+
useGlobals: () => useGlobals
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(module_exports);
|
|
29
|
+
var import_common = require("@akanjs/common");
|
|
30
|
+
var import_constant = require("@akanjs/constant");
|
|
31
|
+
var import_document = require("@akanjs/document");
|
|
32
|
+
var import_service = require("@akanjs/service");
|
|
33
|
+
var import_signal = require("@akanjs/signal");
|
|
34
|
+
var import_bull = require("@nestjs/bull");
|
|
35
|
+
var import_common2 = require("@nestjs/common");
|
|
36
|
+
var import_mongoose = require("@nestjs/mongoose");
|
|
37
|
+
var import_controller = require("./controller");
|
|
38
|
+
var import_processor = require("./processor");
|
|
39
|
+
var import_resolver = require("./resolver");
|
|
40
|
+
var import_schema = require("./schema");
|
|
41
|
+
var import_websocket = require("./websocket");
|
|
42
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
43
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
44
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
45
|
+
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;
|
|
46
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
47
|
+
}
|
|
48
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
49
|
+
const hasWebsocket = /* @__PURE__ */ __name((signal) => (0, import_signal.getGqlMetas)(signal).some((gqlMeta) => [
|
|
50
|
+
"Message",
|
|
51
|
+
"Pubsub"
|
|
52
|
+
].includes(gqlMeta.type)), "hasWebsocket");
|
|
53
|
+
const hasProcessor = /* @__PURE__ */ __name((signal) => (0, import_signal.getGqlMetas)(signal).some((gqlMeta) => gqlMeta.type === "Process"), "hasProcessor");
|
|
54
|
+
const filterSrvs = /* @__PURE__ */ __name((srvs) => Object.fromEntries(Object.entries(srvs).filter(([_, srv]) => !!srv)), "filterSrvs");
|
|
55
|
+
const databaseModuleOf = /* @__PURE__ */ __name(({ constant, database, signal, service, uses = {}, useAsyncs = {}, providers = [], extended }, allSrvs) => {
|
|
56
|
+
if (!(0, import_service.isServiceEnabled)(service)) return null;
|
|
57
|
+
const [modelName, className] = [
|
|
58
|
+
(0, import_common.lowerlize)(constant.refName),
|
|
59
|
+
(0, import_common.capitalize)(constant.refName)
|
|
60
|
+
];
|
|
61
|
+
const mongoToken = (0, import_mongoose.getModelToken)(className);
|
|
62
|
+
let DatabaseModule = class DatabaseModule {
|
|
63
|
+
static {
|
|
64
|
+
__name(this, "DatabaseModule");
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
DatabaseModule = _ts_decorate([
|
|
68
|
+
(0, import_common2.Global)(),
|
|
69
|
+
(0, import_common2.Module)({
|
|
70
|
+
imports: [
|
|
71
|
+
import_mongoose.MongooseModule.forFeature([
|
|
72
|
+
{
|
|
73
|
+
name: className,
|
|
74
|
+
schema: extended ? (0, import_schema.addSchema)(database.Model, database.Doc, database.Input, database.Middleware) : (0, import_schema.schemaOf)(database.Model, database.Doc, database.Middleware)
|
|
75
|
+
}
|
|
76
|
+
]),
|
|
77
|
+
...hasProcessor(signal) ? [
|
|
78
|
+
import_bull.BullModule.registerQueue({
|
|
79
|
+
name: modelName,
|
|
80
|
+
defaultJobOptions: {
|
|
81
|
+
removeOnComplete: true,
|
|
82
|
+
removeOnFail: true
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
] : []
|
|
86
|
+
],
|
|
87
|
+
providers: [
|
|
88
|
+
(0, import_service.serviceOf)(service),
|
|
89
|
+
(0, import_resolver.resolverOf)(signal, filterSrvs(allSrvs)),
|
|
90
|
+
...hasProcessor(signal) ? [
|
|
91
|
+
(0, import_processor.processorOf)(signal, filterSrvs(allSrvs)),
|
|
92
|
+
{
|
|
93
|
+
provide: `${className}Queue`,
|
|
94
|
+
useFactory: /* @__PURE__ */ __name((queue) => queue, "useFactory"),
|
|
95
|
+
inject: [
|
|
96
|
+
(0, import_bull.getQueueToken)(modelName)
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
] : [],
|
|
100
|
+
...hasWebsocket(signal) ? [
|
|
101
|
+
(0, import_websocket.websocketOf)(signal, filterSrvs(allSrvs)),
|
|
102
|
+
{
|
|
103
|
+
provide: "Websocket",
|
|
104
|
+
useClass: (0, import_websocket.websocketServerOf)(signal)
|
|
105
|
+
}
|
|
106
|
+
] : [],
|
|
107
|
+
...Object.entries(uses).map(([key, useValue]) => ({
|
|
108
|
+
provide: (0, import_common.capitalize)(key),
|
|
109
|
+
useValue
|
|
110
|
+
})),
|
|
111
|
+
...Object.entries(useAsyncs).map(([key, useFactory]) => ({
|
|
112
|
+
provide: (0, import_common.capitalize)(key),
|
|
113
|
+
useFactory
|
|
114
|
+
})),
|
|
115
|
+
{
|
|
116
|
+
provide: `${modelName}Model`,
|
|
117
|
+
useFactory: /* @__PURE__ */ __name((model, redis, meili) => {
|
|
118
|
+
return (0, import_document.databaseModelOf)(database, model, redis, meili);
|
|
119
|
+
}, "useFactory"),
|
|
120
|
+
inject: [
|
|
121
|
+
mongoToken,
|
|
122
|
+
"REDIS_CLIENT",
|
|
123
|
+
"MEILI_CLIENT"
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
...providers
|
|
127
|
+
],
|
|
128
|
+
controllers: [
|
|
129
|
+
(0, import_controller.controllerOf)(signal, filterSrvs(allSrvs))
|
|
130
|
+
],
|
|
131
|
+
exports: [
|
|
132
|
+
service
|
|
133
|
+
]
|
|
134
|
+
})
|
|
135
|
+
], DatabaseModule);
|
|
136
|
+
return DatabaseModule;
|
|
137
|
+
}, "databaseModuleOf");
|
|
138
|
+
const serviceModuleOf = /* @__PURE__ */ __name(({ signal, service, uses = {}, useAsyncs = {}, providers = [] }, allSrvs) => {
|
|
139
|
+
if (!(0, import_service.isServiceEnabled)(service)) return null;
|
|
140
|
+
const sigMeta = (0, import_signal.getSigMeta)(signal);
|
|
141
|
+
const [modelName, className] = [
|
|
142
|
+
(0, import_common.lowerlize)(sigMeta.refName),
|
|
143
|
+
(0, import_common.capitalize)(sigMeta.refName)
|
|
144
|
+
];
|
|
145
|
+
let ServiceModule = class ServiceModule {
|
|
146
|
+
static {
|
|
147
|
+
__name(this, "ServiceModule");
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
ServiceModule = _ts_decorate([
|
|
151
|
+
(0, import_common2.Global)(),
|
|
152
|
+
(0, import_common2.Module)({
|
|
153
|
+
imports: [
|
|
154
|
+
...hasProcessor(signal) ? [
|
|
155
|
+
import_bull.BullModule.registerQueue({
|
|
156
|
+
name: modelName,
|
|
157
|
+
defaultJobOptions: {
|
|
158
|
+
removeOnComplete: true,
|
|
159
|
+
removeOnFail: true
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
] : []
|
|
163
|
+
],
|
|
164
|
+
providers: [
|
|
165
|
+
(0, import_service.serviceOf)(service),
|
|
166
|
+
(0, import_resolver.resolverOf)(signal, filterSrvs(allSrvs)),
|
|
167
|
+
...hasWebsocket(signal) ? [
|
|
168
|
+
(0, import_websocket.websocketOf)(signal, filterSrvs(allSrvs)),
|
|
169
|
+
{
|
|
170
|
+
provide: "Websocket",
|
|
171
|
+
useClass: (0, import_websocket.websocketServerOf)(signal)
|
|
172
|
+
}
|
|
173
|
+
] : [],
|
|
174
|
+
...hasProcessor(signal) ? [
|
|
175
|
+
(0, import_processor.processorOf)(signal, filterSrvs(allSrvs)),
|
|
176
|
+
{
|
|
177
|
+
provide: `${className}Queue`,
|
|
178
|
+
useFactory: /* @__PURE__ */ __name((queue) => queue, "useFactory"),
|
|
179
|
+
inject: [
|
|
180
|
+
(0, import_bull.getQueueToken)(modelName)
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
] : [],
|
|
184
|
+
...Object.entries(uses).map(([key, useValue]) => ({
|
|
185
|
+
provide: (0, import_common.capitalize)(key),
|
|
186
|
+
useValue
|
|
187
|
+
})),
|
|
188
|
+
...Object.entries(useAsyncs).map(([key, useFactory]) => ({
|
|
189
|
+
provide: (0, import_common.capitalize)(key),
|
|
190
|
+
useFactory
|
|
191
|
+
})),
|
|
192
|
+
...providers
|
|
193
|
+
],
|
|
194
|
+
controllers: [
|
|
195
|
+
(0, import_controller.controllerOf)(signal, filterSrvs(allSrvs))
|
|
196
|
+
],
|
|
197
|
+
exports: [
|
|
198
|
+
service
|
|
199
|
+
]
|
|
200
|
+
})
|
|
201
|
+
], ServiceModule);
|
|
202
|
+
return ServiceModule;
|
|
203
|
+
}, "serviceModuleOf");
|
|
204
|
+
const scalarModuleOf = /* @__PURE__ */ __name(({ signals, uses = {}, useAsyncs = {}, providers = [], enabled = true }, allSrvs) => {
|
|
205
|
+
if (!enabled) return null;
|
|
206
|
+
let ScalarModule = class ScalarModule {
|
|
207
|
+
static {
|
|
208
|
+
__name(this, "ScalarModule");
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
ScalarModule = _ts_decorate([
|
|
212
|
+
(0, import_common2.Global)(),
|
|
213
|
+
(0, import_common2.Module)({
|
|
214
|
+
imports: [],
|
|
215
|
+
providers: [
|
|
216
|
+
...signals.map((signal) => (0, import_resolver.resolverOf)(signal, filterSrvs(allSrvs))),
|
|
217
|
+
...signals.filter(hasWebsocket).map((signal) => [
|
|
218
|
+
(0, import_websocket.websocketOf)(signal, filterSrvs(allSrvs)),
|
|
219
|
+
{
|
|
220
|
+
provide: "Websocket",
|
|
221
|
+
useClass: (0, import_websocket.websocketServerOf)(signal)
|
|
222
|
+
}
|
|
223
|
+
]).flat(),
|
|
224
|
+
...Object.entries(uses).map(([key, useValue]) => ({
|
|
225
|
+
provide: (0, import_common.capitalize)(key),
|
|
226
|
+
useValue
|
|
227
|
+
})),
|
|
228
|
+
...Object.entries(useAsyncs).map(([key, useFactory]) => ({
|
|
229
|
+
provide: (0, import_common.capitalize)(key),
|
|
230
|
+
useFactory
|
|
231
|
+
})),
|
|
232
|
+
...providers
|
|
233
|
+
],
|
|
234
|
+
controllers: signals.map((signal) => (0, import_controller.controllerOf)(signal, filterSrvs(allSrvs)))
|
|
235
|
+
})
|
|
236
|
+
], ScalarModule);
|
|
237
|
+
return ScalarModule;
|
|
238
|
+
}, "scalarModuleOf");
|
|
239
|
+
const scalarModulesOf = /* @__PURE__ */ __name(({ constants }, allSrvs) => {
|
|
240
|
+
const signals = constants.filter((modelRef) => {
|
|
241
|
+
const childRefs = (0, import_constant.getChildClassRefs)(modelRef);
|
|
242
|
+
return childRefs.some((childRef) => {
|
|
243
|
+
const classMeta = (0, import_constant.getClassMeta)(childRef);
|
|
244
|
+
return [
|
|
245
|
+
"full",
|
|
246
|
+
"light"
|
|
247
|
+
].includes(classMeta.type);
|
|
248
|
+
});
|
|
249
|
+
}).map((modelRef) => {
|
|
250
|
+
let ScalarSignal = class ScalarSignal extends (0, import_signal.LogSignal)({}) {
|
|
251
|
+
static {
|
|
252
|
+
__name(this, "ScalarSignal");
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
ScalarSignal = _ts_decorate([
|
|
256
|
+
(0, import_signal.Signal)(() => modelRef)
|
|
257
|
+
], ScalarSignal);
|
|
258
|
+
return ScalarSignal;
|
|
259
|
+
});
|
|
260
|
+
let ScalarModule = class ScalarModule {
|
|
261
|
+
static {
|
|
262
|
+
__name(this, "ScalarModule");
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
ScalarModule = _ts_decorate([
|
|
266
|
+
(0, import_common2.Global)(),
|
|
267
|
+
(0, import_common2.Module)({
|
|
268
|
+
imports: [],
|
|
269
|
+
providers: [
|
|
270
|
+
...signals.map((signal) => (0, import_resolver.resolverOf)(signal, filterSrvs(allSrvs)))
|
|
271
|
+
]
|
|
272
|
+
})
|
|
273
|
+
], ScalarModule);
|
|
274
|
+
return ScalarModule;
|
|
275
|
+
}, "scalarModulesOf");
|
|
276
|
+
const batchModuleOf = /* @__PURE__ */ __name(({ service, uses = {}, useAsyncs = {}, providers = [] }) => {
|
|
277
|
+
if (!(0, import_service.isServiceEnabled)(service)) return null;
|
|
278
|
+
let BatchModule = class BatchModule {
|
|
279
|
+
static {
|
|
280
|
+
__name(this, "BatchModule");
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
BatchModule = _ts_decorate([
|
|
284
|
+
(0, import_common2.Global)(),
|
|
285
|
+
(0, import_common2.Module)({
|
|
286
|
+
imports: [],
|
|
287
|
+
providers: [
|
|
288
|
+
(0, import_service.serviceOf)(service),
|
|
289
|
+
...Object.entries(uses).map(([key, useValue]) => ({
|
|
290
|
+
provide: (0, import_common.capitalize)(key),
|
|
291
|
+
useValue
|
|
292
|
+
})),
|
|
293
|
+
...Object.entries(useAsyncs).map(([key, useFactory]) => ({
|
|
294
|
+
provide: (0, import_common.capitalize)(key),
|
|
295
|
+
useFactory
|
|
296
|
+
})),
|
|
297
|
+
...providers
|
|
298
|
+
],
|
|
299
|
+
exports: [
|
|
300
|
+
service
|
|
301
|
+
]
|
|
302
|
+
})
|
|
303
|
+
], BatchModule);
|
|
304
|
+
return BatchModule;
|
|
305
|
+
}, "batchModuleOf");
|
|
306
|
+
const useGlobals = /* @__PURE__ */ __name(({ uses, useAsyncs, injects }) => {
|
|
307
|
+
let GlobalsModule = class GlobalsModule {
|
|
308
|
+
static {
|
|
309
|
+
__name(this, "GlobalsModule");
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
GlobalsModule = _ts_decorate([
|
|
313
|
+
(0, import_common2.Global)(),
|
|
314
|
+
(0, import_common2.Module)({
|
|
315
|
+
imports: [],
|
|
316
|
+
providers: [
|
|
317
|
+
...Object.entries(uses ?? {}).map(([key, useValue]) => ({
|
|
318
|
+
provide: (0, import_common.capitalize)(key),
|
|
319
|
+
useValue
|
|
320
|
+
})),
|
|
321
|
+
...Object.entries(useAsyncs ?? {}).map(([key, useFactory]) => ({
|
|
322
|
+
provide: (0, import_common.capitalize)(key),
|
|
323
|
+
useFactory
|
|
324
|
+
})),
|
|
325
|
+
...Object.entries(injects ?? {}).map(([key, inject]) => ({
|
|
326
|
+
provide: (0, import_common.capitalize)(key),
|
|
327
|
+
useClass: inject
|
|
328
|
+
}))
|
|
329
|
+
],
|
|
330
|
+
exports: [
|
|
331
|
+
...Object.keys(uses ?? {}).map((key) => (0, import_common.capitalize)(key)),
|
|
332
|
+
...Object.keys(useAsyncs ?? {}).map((key) => (0, import_common.capitalize)(key)),
|
|
333
|
+
...Object.keys(injects ?? {}).map((key) => (0, import_common.capitalize)(key))
|
|
334
|
+
]
|
|
335
|
+
})
|
|
336
|
+
], GlobalsModule);
|
|
337
|
+
return GlobalsModule;
|
|
338
|
+
}, "useGlobals");
|
|
339
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
340
|
+
0 && (module.exports = {
|
|
341
|
+
batchModuleOf,
|
|
342
|
+
databaseModuleOf,
|
|
343
|
+
scalarModuleOf,
|
|
344
|
+
scalarModulesOf,
|
|
345
|
+
serviceModuleOf,
|
|
346
|
+
useGlobals
|
|
347
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { T as Type } from '../types-H2HI4YUe.js';
|
|
2
|
+
import { Queue } from 'bull';
|
|
3
|
+
|
|
4
|
+
declare const processorOf: (sigRef: Type, allSrvs: {
|
|
5
|
+
[key: string]: Type;
|
|
6
|
+
}) => {
|
|
7
|
+
new (): {};
|
|
8
|
+
};
|
|
9
|
+
declare const queueOf: (sigRef: Type, queue: Queue) => Queue<any>;
|
|
10
|
+
|
|
11
|
+
export { processorOf, queueOf };
|