@c-rex/core 0.1.0 → 0.1.2
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/dist/api/cookies.d.mts +10 -0
- package/dist/api/cookies.d.ts +10 -0
- package/dist/api/cookies.js +38 -0
- package/dist/api/cookies.js.map +1 -0
- package/dist/api/cookies.mjs +13 -0
- package/dist/api/cookies.mjs.map +1 -0
- package/dist/api/rpc.d.mts +9 -0
- package/dist/api/rpc.d.ts +9 -0
- package/dist/api/rpc.js +212 -0
- package/dist/api/rpc.js.map +1 -0
- package/dist/api/rpc.mjs +175 -0
- package/dist/api/rpc.mjs.map +1 -0
- package/dist/index.js +38 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -40
- package/dist/index.mjs.map +1 -1
- package/dist/logger.js +21 -68
- package/dist/logger.js.map +1 -1
- package/dist/logger.mjs +21 -68
- package/dist/logger.mjs.map +1 -1
- package/package.json +16 -6
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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
|
+
|
|
20
|
+
// src/api/cookies.ts
|
|
21
|
+
var cookies_exports = {};
|
|
22
|
+
__export(cookies_exports, {
|
|
23
|
+
GET: () => GET
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(cookies_exports);
|
|
26
|
+
var import_server = require("next/server");
|
|
27
|
+
var import_next_cookies = require("@c-rex/utils/next-cookies");
|
|
28
|
+
var GET = async (req) => {
|
|
29
|
+
const key = req.nextUrl.searchParams.get("key");
|
|
30
|
+
if (!key) return import_server.NextResponse.json({ error: "Missing key" }, { status: 400 });
|
|
31
|
+
const value = (0, import_next_cookies.getCookieFromBack)(key);
|
|
32
|
+
return import_server.NextResponse.json({ key, value: value ?? null });
|
|
33
|
+
};
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
GET
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=cookies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/api/cookies.ts"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\nimport { getCookieFromBack } from \"@c-rex/utils/next-cookies\";\n\nexport const GET = async (req: NextRequest) => {\n const key = req.nextUrl.searchParams.get('key');\n if (!key) return NextResponse.json({ error: 'Missing key' }, { status: 400 });\n\n const value = getCookieFromBack(key);\n\n return NextResponse.json({ key, value: value ?? null });\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA0C;AAC1C,0BAAkC;AAE3B,IAAM,MAAM,OAAO,QAAqB;AAC3C,QAAM,MAAM,IAAI,QAAQ,aAAa,IAAI,KAAK;AAC9C,MAAI,CAAC,IAAK,QAAO,2BAAa,KAAK,EAAE,OAAO,cAAc,GAAG,EAAE,QAAQ,IAAI,CAAC;AAE5E,QAAM,YAAQ,uCAAkB,GAAG;AAEnC,SAAO,2BAAa,KAAK,EAAE,KAAK,OAAO,SAAS,KAAK,CAAC;AAC1D;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/api/cookies.ts
|
|
2
|
+
import { NextResponse } from "next/server";
|
|
3
|
+
import { getCookieFromBack } from "@c-rex/utils/next-cookies";
|
|
4
|
+
var GET = async (req) => {
|
|
5
|
+
const key = req.nextUrl.searchParams.get("key");
|
|
6
|
+
if (!key) return NextResponse.json({ error: "Missing key" }, { status: 400 });
|
|
7
|
+
const value = getCookieFromBack(key);
|
|
8
|
+
return NextResponse.json({ key, value: value ?? null });
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
GET
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=cookies.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/api/cookies.ts"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\nimport { getCookieFromBack } from \"@c-rex/utils/next-cookies\";\n\nexport const GET = async (req: NextRequest) => {\n const key = req.nextUrl.searchParams.get('key');\n if (!key) return NextResponse.json({ error: 'Missing key' }, { status: 400 });\n\n const value = getCookieFromBack(key);\n\n return NextResponse.json({ key, value: value ?? null });\n}"],"mappings":";AAAA,SAAsB,oBAAoB;AAC1C,SAAS,yBAAyB;AAE3B,IAAM,MAAM,OAAO,QAAqB;AAC3C,QAAM,MAAM,IAAI,QAAQ,aAAa,IAAI,KAAK;AAC9C,MAAI,CAAC,IAAK,QAAO,aAAa,KAAK,EAAE,OAAO,cAAc,GAAG,EAAE,QAAQ,IAAI,CAAC;AAE5E,QAAM,QAAQ,kBAAkB,GAAG;AAEnC,SAAO,aAAa,KAAK,EAAE,KAAK,OAAO,SAAS,KAAK,CAAC;AAC1D;","names":[]}
|
package/dist/api/rpc.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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
|
+
|
|
30
|
+
// src/api/rpc.ts
|
|
31
|
+
var rpc_exports = {};
|
|
32
|
+
__export(rpc_exports, {
|
|
33
|
+
POST: () => POST
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(rpc_exports);
|
|
36
|
+
|
|
37
|
+
// ../constants/src/index.ts
|
|
38
|
+
var ALL = "*";
|
|
39
|
+
var LOG_LEVELS = {
|
|
40
|
+
critical: 2,
|
|
41
|
+
error: 3,
|
|
42
|
+
warning: 4,
|
|
43
|
+
info: 6,
|
|
44
|
+
debug: 7
|
|
45
|
+
};
|
|
46
|
+
var DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1e3;
|
|
47
|
+
|
|
48
|
+
// src/sdk.ts
|
|
49
|
+
var import_next_cookies = require("@c-rex/utils/next-cookies");
|
|
50
|
+
var CrexSDK = class {
|
|
51
|
+
userAuthConfig;
|
|
52
|
+
customerConfig;
|
|
53
|
+
async getConfig() {
|
|
54
|
+
if (!this.customerConfig) {
|
|
55
|
+
this.customerConfig = await (0, import_next_cookies.getConfigs)();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async getUserAuthConfig() {
|
|
59
|
+
if (this.userAuthConfig) {
|
|
60
|
+
return this.userAuthConfig;
|
|
61
|
+
}
|
|
62
|
+
await this.getConfig();
|
|
63
|
+
const user = this.customerConfig.OIDC.user;
|
|
64
|
+
if (user.enabled) {
|
|
65
|
+
this.userAuthConfig = {
|
|
66
|
+
providers: [
|
|
67
|
+
{
|
|
68
|
+
id: "crex",
|
|
69
|
+
name: "CREX",
|
|
70
|
+
type: "oauth",
|
|
71
|
+
clientId: user.id,
|
|
72
|
+
wellKnown: user.issuer,
|
|
73
|
+
clientSecret: user.secret,
|
|
74
|
+
authorization: { params: { scope: user.scope } },
|
|
75
|
+
profile(profile) {
|
|
76
|
+
return {
|
|
77
|
+
id: profile.id || "fake Id",
|
|
78
|
+
name: profile.name || "Fake Name",
|
|
79
|
+
email: profile.email || "fake Email",
|
|
80
|
+
image: profile.image || "fake Image"
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
;
|
|
88
|
+
return this.userAuthConfig;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// src/logger.ts
|
|
93
|
+
var import_winston = __toESM(require("winston"));
|
|
94
|
+
|
|
95
|
+
// src/transports/matomo.ts
|
|
96
|
+
var import_winston_transport = __toESM(require("winston-transport"));
|
|
97
|
+
var MatomoTransport = class extends import_winston_transport.default {
|
|
98
|
+
matomoTransport;
|
|
99
|
+
configs;
|
|
100
|
+
constructor(configs) {
|
|
101
|
+
super({
|
|
102
|
+
level: configs.logs.console.minimumLevel,
|
|
103
|
+
silent: configs.logs.console.silent
|
|
104
|
+
});
|
|
105
|
+
this.matomoTransport = new import_winston_transport.default();
|
|
106
|
+
this.configs = configs;
|
|
107
|
+
}
|
|
108
|
+
log(info, callback) {
|
|
109
|
+
const matomoCategory = this.configs.logs.matomo.categoriesLevel;
|
|
110
|
+
if (matomoCategory.includes(info.category) || matomoCategory.includes(ALL)) {
|
|
111
|
+
this.matomoTransport.log(info, callback);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// src/transports/graylog.ts
|
|
117
|
+
var import_winston_transport2 = __toESM(require("winston-transport"));
|
|
118
|
+
var import_winston_graylog2 = __toESM(require("winston-graylog2"));
|
|
119
|
+
var GraylogTransport = class extends import_winston_transport2.default {
|
|
120
|
+
graylogTransport;
|
|
121
|
+
configs;
|
|
122
|
+
constructor(configs) {
|
|
123
|
+
super({
|
|
124
|
+
level: configs.logs.graylog.minimumLevel,
|
|
125
|
+
silent: configs.logs.graylog.silent
|
|
126
|
+
});
|
|
127
|
+
this.configs = configs;
|
|
128
|
+
this.graylogTransport = new import_winston_graylog2.default({
|
|
129
|
+
name: "Periotto-TEST",
|
|
130
|
+
silent: false,
|
|
131
|
+
handleExceptions: false,
|
|
132
|
+
graylog: {
|
|
133
|
+
servers: [{ host: "localhost", port: 12201 }]
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
log(info, callback) {
|
|
138
|
+
const graylogCategory = this.configs.logs.graylog.categoriesLevel;
|
|
139
|
+
if (graylogCategory.includes(info.category) || graylogCategory.includes(ALL)) {
|
|
140
|
+
this.graylogTransport.log(info, callback);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// src/logger.ts
|
|
146
|
+
var import_next_cookies2 = require("@c-rex/utils/next-cookies");
|
|
147
|
+
var CrexLogger = class {
|
|
148
|
+
customerConfig;
|
|
149
|
+
logger;
|
|
150
|
+
async initLogger() {
|
|
151
|
+
if (!this.customerConfig) {
|
|
152
|
+
this.customerConfig = await (0, import_next_cookies2.getConfigs)();
|
|
153
|
+
}
|
|
154
|
+
if (!this.logger) {
|
|
155
|
+
this.logger = this.createLogger();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
async log({ level, message, category }) {
|
|
159
|
+
await this.initLogger();
|
|
160
|
+
this.logger.log(level, message, category);
|
|
161
|
+
}
|
|
162
|
+
createLogger() {
|
|
163
|
+
return import_winston.default.createLogger({
|
|
164
|
+
levels: LOG_LEVELS,
|
|
165
|
+
transports: [
|
|
166
|
+
new import_winston.default.transports.Console({
|
|
167
|
+
level: this.customerConfig.logs.console.minimumLevel,
|
|
168
|
+
silent: this.customerConfig.logs.console.silent
|
|
169
|
+
}),
|
|
170
|
+
new MatomoTransport(this.customerConfig),
|
|
171
|
+
new GraylogTransport(this.customerConfig)
|
|
172
|
+
]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// src/api/rpc.ts
|
|
178
|
+
var import_services = require("@c-rex/services");
|
|
179
|
+
var import_server = require("next/server");
|
|
180
|
+
var serviceRegistry = {
|
|
181
|
+
InformationUnitsService: import_services.InformationUnitsService,
|
|
182
|
+
DocumentTypesService: import_services.DocumentTypesService,
|
|
183
|
+
DirectoryNodesService: import_services.DirectoryNodesService,
|
|
184
|
+
RenditionsService: import_services.RenditionsService,
|
|
185
|
+
CrexLogger,
|
|
186
|
+
CrexSDK
|
|
187
|
+
};
|
|
188
|
+
var POST = async (req) => {
|
|
189
|
+
try {
|
|
190
|
+
const { method, params } = await req.json();
|
|
191
|
+
const [serviceName, methodName] = method.split(".");
|
|
192
|
+
const ServiceClass = serviceRegistry[serviceName];
|
|
193
|
+
if (!ServiceClass) {
|
|
194
|
+
return import_server.NextResponse.json({ error: `Service '${serviceName}' not found` }, { status: 404 });
|
|
195
|
+
}
|
|
196
|
+
const serviceInstance = new ServiceClass();
|
|
197
|
+
const handler = serviceInstance[methodName];
|
|
198
|
+
if (typeof handler !== "function") {
|
|
199
|
+
return import_server.NextResponse.json({ error: `Method '${methodName}' not found on '${serviceName}'` }, { status: 404 });
|
|
200
|
+
}
|
|
201
|
+
const result = await handler.call(serviceInstance, params);
|
|
202
|
+
return import_server.NextResponse.json({ data: result });
|
|
203
|
+
} catch (err) {
|
|
204
|
+
console.error(err);
|
|
205
|
+
return import_server.NextResponse.json({ error: String(err) }, { status: 500 });
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
209
|
+
0 && (module.exports = {
|
|
210
|
+
POST
|
|
211
|
+
});
|
|
212
|
+
//# sourceMappingURL=rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/api/rpc.ts","../../../constants/src/index.ts","../../src/sdk.ts","../../src/logger.ts","../../src/transports/matomo.ts","../../src/transports/graylog.ts"],"sourcesContent":["import { CrexSDK } from '../';\nimport { CrexLogger } from '../logger';\nimport { DirectoryNodesService, DocumentTypesService, InformationUnitsService, RenditionsService } from '@c-rex/services';\nimport { NextRequest, NextResponse } from 'next/server';\n\nconst serviceRegistry = {\n InformationUnitsService,\n DocumentTypesService,\n DirectoryNodesService,\n RenditionsService,\n CrexLogger,\n CrexSDK,\n};\n\ntype RpcPayload = {\n method: string;\n params: any;\n};\n\nexport const POST = async (req: NextRequest) => {\n try {\n const { method, params }: RpcPayload = await req.json();\n const [serviceName, methodName] = method.split('.');\n const ServiceClass = serviceRegistry[serviceName as keyof typeof serviceRegistry];\n\n if (!ServiceClass) {\n return NextResponse.json({ error: `Service '${serviceName}' not found` }, { status: 404 });\n }\n\n const serviceInstance = new ServiceClass();\n const handler = (serviceInstance as any)[methodName as any];\n\n if (typeof handler !== 'function') {\n return NextResponse.json({ error: `Method '${methodName}' not found on '${serviceName}'` }, { status: 404 });\n }\n\n const result = await handler.call(serviceInstance, params);\n return NextResponse.json({ data: result });\n } catch (err) {\n console.error(err);\n return NextResponse.json({ error: String(err) }, { status: 500 });\n }\n}\n","export const ALL = \"*\"\n\nexport const LOG_CATEGORIES = [\n \"NoLicense\",\n \"Scenario\",\n \"Favorites\",\n \"Subscription\",\n \"Share\",\n \"Document\",\n \"Search\",\n \"History\",\n \"Notification\",\n \"UserProfile\",\n] as const;\n\nexport const LOG_LEVELS = {\n critical: 2,\n error: 3,\n warning: 4,\n info: 6,\n debug: 7,\n} as const;\n\nexport const RESULT_VIEW_STYLES = [\n \"cards\",\n \"table\",\n] as const;\n\nexport const API = {\n MAX_RETRY: 3,\n API_TIMEOUT: 10000,\n API_HEADERS: {\n \"content-Type\": \"application/json\",\n },\n};\n\nexport const SDK_CONFIG_KEY = \"crex-sdk-config\";\n\nexport const CONTENT_LANG_KEY = \"CONTENT_LANG_KEY\";\n\nexport const AVAILABLE_CONTENT_LANG_KEY = \"AVAILABLE_CONTENT_LANG_KEY\";\n\nexport const UI_LANG_KEY = \"UI_LANG_KEY\";\n\nexport const FLAGS_BY_LANG = {\n \"en\": \"US\",\n \"de\": \"DE\",\n};\n\nexport const DEFAULT_LANG = \"en-US\";\n\nexport const EN_LANG = \"en\";\n\nexport const UI_LANG_OPTIONS = [\"en-us\", \"de-de\"];\n\nexport const RESULT_TYPES = {\n TOPIC: \"TOPIC\",\n DOCUMENT: \"DOCUMENT\",\n PACKAGE: \"PACKAGE\",\n} as const;\n\nexport const FILES_EXTENSIONS = {\n PDF: \"application/pdf\",\n HTML: \"text/html\",\n} as const;\n\nexport const DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1000; // 7 days in milliseconds\n\nexport const ICONS_BY_FILE_EXTENSION = {\n \"application/pdf\": \"FaFilePdf\",\n} as const;\n\nexport const DEFAULT_ICON = \"file\";","import { ConfigInterface } from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\nexport class CrexSDK {\n public userAuthConfig!: any;\n public customerConfig!: ConfigInterface;\n\n private async getConfig() {\n if (!this.customerConfig) {\n this.customerConfig = await getConfigs()\n }\n }\n\n public async getUserAuthConfig() {\n if (this.userAuthConfig) {\n return this.userAuthConfig;\n }\n\n await this.getConfig();\n\n const user = this.customerConfig.OIDC.user;\n if (user.enabled) {\n this.userAuthConfig = {\n providers: [\n {\n id: \"crex\",\n name: \"CREX\",\n type: \"oauth\",\n clientId: user.id,\n wellKnown: user.issuer,\n clientSecret: user.secret,\n authorization: { params: { scope: user.scope } },\n profile(profile: any) {\n return {\n id: profile.id || \"fake Id\",\n name: profile.name || \"Fake Name\",\n email: profile.email || \"fake Email\",\n image: profile.image || \"fake Image\",\n }\n },\n },\n ]\n }\n };\n\n return this.userAuthConfig;\n }\n}","import winston from \"winston\";\nimport { MatomoTransport } from \"./transports/matomo\";\nimport { GraylogTransport } from \"./transports/graylog\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { LOG_LEVELS } from \"@c-rex/constants\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\nexport class CrexLogger {\n private customerConfig!: ConfigInterface;\n public logger!: winston.Logger;\n\n private async initLogger() {\n if (!this.customerConfig) {\n this.customerConfig = await getConfigs();\n }\n\n if (!this.logger) {\n this.logger = this.createLogger();\n }\n }\n\n public async log({ level, message, category }: {\n level: LogLevelType,\n message: string,\n category?: LogCategoriesType\n }) {\n await this.initLogger();\n this.logger.log(level, message, category);\n }\n\n private createLogger() {\n return winston.createLogger({\n levels: LOG_LEVELS,\n transports: [\n new winston.transports.Console({\n level: this.customerConfig.logs.console.minimumLevel,\n silent: this.customerConfig.logs.console.silent,\n }),\n new MatomoTransport(this.customerConfig),\n new GraylogTransport(this.customerConfig),\n ],\n });\n }\n}","import Transport from \"winston-transport\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\nexport class MatomoTransport extends Transport {\n public matomoTransport: any;\n private configs: ConfigInterface;\n\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.console.minimumLevel,\n silent: configs.logs.console.silent,\n });\n\n this.matomoTransport = new Transport();\n this.configs = configs;\n }\n\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const matomoCategory = this.configs.logs.matomo.categoriesLevel\n\n if (matomoCategory.includes(info.category) || matomoCategory.includes(ALL)) {\n\n this.matomoTransport.log(info, callback);\n }\n }\n}\n","import Transport from \"winston-transport\";\nimport Graylog2Transport from \"winston-graylog2\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\nexport class GraylogTransport extends Transport {\n public graylogTransport: any;\n public configs: ConfigInterface\n\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.graylog.minimumLevel,\n silent: configs.logs.graylog.silent,\n });\n\n this.configs = configs;\n this.graylogTransport = new Graylog2Transport({\n name: \"Periotto-TEST\",\n silent: false,\n handleExceptions: false,\n graylog: {\n servers: [{ host: \"localhost\", port: 12201 }],\n },\n });\n }\n\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const graylogCategory = this.configs.logs.graylog.categoriesLevel\n\n if (graylogCategory.includes(info.category) || graylogCategory.includes(ALL)) {\n this.graylogTransport.log(info, callback);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,MAAM;AAeZ,IAAM,aAAa;AAAA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M,OAAO,CAAC;AAAA,EAC7C,SAAS,KAAK;AACV,YAAQ,MAAM,GAAG;AACjB,WAAO,2BAAa,KAAK,EAAE,OAAO,OAAO,GAAG,EAAE,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACpE;AACJ;","names":["Transport","import_winston_transport","Transport","Graylog2Transport","import_next_cookies","winston"]}
|
package/dist/api/rpc.mjs
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// ../constants/src/index.ts
|
|
2
|
+
var ALL = "*";
|
|
3
|
+
var LOG_LEVELS = {
|
|
4
|
+
critical: 2,
|
|
5
|
+
error: 3,
|
|
6
|
+
warning: 4,
|
|
7
|
+
info: 6,
|
|
8
|
+
debug: 7
|
|
9
|
+
};
|
|
10
|
+
var DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1e3;
|
|
11
|
+
|
|
12
|
+
// src/sdk.ts
|
|
13
|
+
import { getConfigs } from "@c-rex/utils/next-cookies";
|
|
14
|
+
var CrexSDK = class {
|
|
15
|
+
userAuthConfig;
|
|
16
|
+
customerConfig;
|
|
17
|
+
async getConfig() {
|
|
18
|
+
if (!this.customerConfig) {
|
|
19
|
+
this.customerConfig = await getConfigs();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async getUserAuthConfig() {
|
|
23
|
+
if (this.userAuthConfig) {
|
|
24
|
+
return this.userAuthConfig;
|
|
25
|
+
}
|
|
26
|
+
await this.getConfig();
|
|
27
|
+
const user = this.customerConfig.OIDC.user;
|
|
28
|
+
if (user.enabled) {
|
|
29
|
+
this.userAuthConfig = {
|
|
30
|
+
providers: [
|
|
31
|
+
{
|
|
32
|
+
id: "crex",
|
|
33
|
+
name: "CREX",
|
|
34
|
+
type: "oauth",
|
|
35
|
+
clientId: user.id,
|
|
36
|
+
wellKnown: user.issuer,
|
|
37
|
+
clientSecret: user.secret,
|
|
38
|
+
authorization: { params: { scope: user.scope } },
|
|
39
|
+
profile(profile) {
|
|
40
|
+
return {
|
|
41
|
+
id: profile.id || "fake Id",
|
|
42
|
+
name: profile.name || "Fake Name",
|
|
43
|
+
email: profile.email || "fake Email",
|
|
44
|
+
image: profile.image || "fake Image"
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
;
|
|
52
|
+
return this.userAuthConfig;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// src/logger.ts
|
|
57
|
+
import winston from "winston";
|
|
58
|
+
|
|
59
|
+
// src/transports/matomo.ts
|
|
60
|
+
import Transport from "winston-transport";
|
|
61
|
+
var MatomoTransport = class extends Transport {
|
|
62
|
+
matomoTransport;
|
|
63
|
+
configs;
|
|
64
|
+
constructor(configs) {
|
|
65
|
+
super({
|
|
66
|
+
level: configs.logs.console.minimumLevel,
|
|
67
|
+
silent: configs.logs.console.silent
|
|
68
|
+
});
|
|
69
|
+
this.matomoTransport = new Transport();
|
|
70
|
+
this.configs = configs;
|
|
71
|
+
}
|
|
72
|
+
log(info, callback) {
|
|
73
|
+
const matomoCategory = this.configs.logs.matomo.categoriesLevel;
|
|
74
|
+
if (matomoCategory.includes(info.category) || matomoCategory.includes(ALL)) {
|
|
75
|
+
this.matomoTransport.log(info, callback);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/transports/graylog.ts
|
|
81
|
+
import Transport2 from "winston-transport";
|
|
82
|
+
import Graylog2Transport from "winston-graylog2";
|
|
83
|
+
var GraylogTransport = class extends Transport2 {
|
|
84
|
+
graylogTransport;
|
|
85
|
+
configs;
|
|
86
|
+
constructor(configs) {
|
|
87
|
+
super({
|
|
88
|
+
level: configs.logs.graylog.minimumLevel,
|
|
89
|
+
silent: configs.logs.graylog.silent
|
|
90
|
+
});
|
|
91
|
+
this.configs = configs;
|
|
92
|
+
this.graylogTransport = new Graylog2Transport({
|
|
93
|
+
name: "Periotto-TEST",
|
|
94
|
+
silent: false,
|
|
95
|
+
handleExceptions: false,
|
|
96
|
+
graylog: {
|
|
97
|
+
servers: [{ host: "localhost", port: 12201 }]
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
log(info, callback) {
|
|
102
|
+
const graylogCategory = this.configs.logs.graylog.categoriesLevel;
|
|
103
|
+
if (graylogCategory.includes(info.category) || graylogCategory.includes(ALL)) {
|
|
104
|
+
this.graylogTransport.log(info, callback);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/logger.ts
|
|
110
|
+
import { getConfigs as getConfigs2 } from "@c-rex/utils/next-cookies";
|
|
111
|
+
var CrexLogger = class {
|
|
112
|
+
customerConfig;
|
|
113
|
+
logger;
|
|
114
|
+
async initLogger() {
|
|
115
|
+
if (!this.customerConfig) {
|
|
116
|
+
this.customerConfig = await getConfigs2();
|
|
117
|
+
}
|
|
118
|
+
if (!this.logger) {
|
|
119
|
+
this.logger = this.createLogger();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async log({ level, message, category }) {
|
|
123
|
+
await this.initLogger();
|
|
124
|
+
this.logger.log(level, message, category);
|
|
125
|
+
}
|
|
126
|
+
createLogger() {
|
|
127
|
+
return winston.createLogger({
|
|
128
|
+
levels: LOG_LEVELS,
|
|
129
|
+
transports: [
|
|
130
|
+
new winston.transports.Console({
|
|
131
|
+
level: this.customerConfig.logs.console.minimumLevel,
|
|
132
|
+
silent: this.customerConfig.logs.console.silent
|
|
133
|
+
}),
|
|
134
|
+
new MatomoTransport(this.customerConfig),
|
|
135
|
+
new GraylogTransport(this.customerConfig)
|
|
136
|
+
]
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// src/api/rpc.ts
|
|
142
|
+
import { DirectoryNodesService, DocumentTypesService, InformationUnitsService, RenditionsService } from "@c-rex/services";
|
|
143
|
+
import { NextResponse } from "next/server";
|
|
144
|
+
var serviceRegistry = {
|
|
145
|
+
InformationUnitsService,
|
|
146
|
+
DocumentTypesService,
|
|
147
|
+
DirectoryNodesService,
|
|
148
|
+
RenditionsService,
|
|
149
|
+
CrexLogger,
|
|
150
|
+
CrexSDK
|
|
151
|
+
};
|
|
152
|
+
var POST = async (req) => {
|
|
153
|
+
try {
|
|
154
|
+
const { method, params } = await req.json();
|
|
155
|
+
const [serviceName, methodName] = method.split(".");
|
|
156
|
+
const ServiceClass = serviceRegistry[serviceName];
|
|
157
|
+
if (!ServiceClass) {
|
|
158
|
+
return NextResponse.json({ error: `Service '${serviceName}' not found` }, { status: 404 });
|
|
159
|
+
}
|
|
160
|
+
const serviceInstance = new ServiceClass();
|
|
161
|
+
const handler = serviceInstance[methodName];
|
|
162
|
+
if (typeof handler !== "function") {
|
|
163
|
+
return NextResponse.json({ error: `Method '${methodName}' not found on '${serviceName}'` }, { status: 404 });
|
|
164
|
+
}
|
|
165
|
+
const result = await handler.call(serviceInstance, params);
|
|
166
|
+
return NextResponse.json({ data: result });
|
|
167
|
+
} catch (err) {
|
|
168
|
+
console.error(err);
|
|
169
|
+
return NextResponse.json({ error: String(err) }, { status: 500 });
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
export {
|
|
173
|
+
POST
|
|
174
|
+
};
|
|
175
|
+
//# sourceMappingURL=rpc.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../constants/src/index.ts","../../src/sdk.ts","../../src/logger.ts","../../src/transports/matomo.ts","../../src/transports/graylog.ts","../../src/api/rpc.ts"],"sourcesContent":["export const ALL = \"*\"\n\nexport const LOG_CATEGORIES = [\n \"NoLicense\",\n \"Scenario\",\n \"Favorites\",\n \"Subscription\",\n \"Share\",\n \"Document\",\n \"Search\",\n \"History\",\n \"Notification\",\n \"UserProfile\",\n] as const;\n\nexport const LOG_LEVELS = {\n critical: 2,\n error: 3,\n warning: 4,\n info: 6,\n debug: 7,\n} as const;\n\nexport const RESULT_VIEW_STYLES = [\n \"cards\",\n \"table\",\n] as const;\n\nexport const API = {\n MAX_RETRY: 3,\n API_TIMEOUT: 10000,\n API_HEADERS: {\n \"content-Type\": \"application/json\",\n },\n};\n\nexport const SDK_CONFIG_KEY = \"crex-sdk-config\";\n\nexport const CONTENT_LANG_KEY = \"CONTENT_LANG_KEY\";\n\nexport const AVAILABLE_CONTENT_LANG_KEY = \"AVAILABLE_CONTENT_LANG_KEY\";\n\nexport const UI_LANG_KEY = \"UI_LANG_KEY\";\n\nexport const FLAGS_BY_LANG = {\n \"en\": \"US\",\n \"de\": \"DE\",\n};\n\nexport const DEFAULT_LANG = \"en-US\";\n\nexport const EN_LANG = \"en\";\n\nexport const UI_LANG_OPTIONS = [\"en-us\", \"de-de\"];\n\nexport const RESULT_TYPES = {\n TOPIC: \"TOPIC\",\n DOCUMENT: \"DOCUMENT\",\n PACKAGE: \"PACKAGE\",\n} as const;\n\nexport const FILES_EXTENSIONS = {\n PDF: \"application/pdf\",\n HTML: \"text/html\",\n} as const;\n\nexport const DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1000; // 7 days in milliseconds\n\nexport const ICONS_BY_FILE_EXTENSION = {\n \"application/pdf\": \"FaFilePdf\",\n} as const;\n\nexport const DEFAULT_ICON = \"file\";","import { ConfigInterface } from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\nexport class CrexSDK {\n public userAuthConfig!: any;\n public customerConfig!: ConfigInterface;\n\n private async getConfig() {\n if (!this.customerConfig) {\n this.customerConfig = await getConfigs()\n }\n }\n\n public async getUserAuthConfig() {\n if (this.userAuthConfig) {\n return this.userAuthConfig;\n }\n\n await this.getConfig();\n\n const user = this.customerConfig.OIDC.user;\n if (user.enabled) {\n this.userAuthConfig = {\n providers: [\n {\n id: \"crex\",\n name: \"CREX\",\n type: \"oauth\",\n clientId: user.id,\n wellKnown: user.issuer,\n clientSecret: user.secret,\n authorization: { params: { scope: user.scope } },\n profile(profile: any) {\n return {\n id: profile.id || \"fake Id\",\n name: profile.name || \"Fake Name\",\n email: profile.email || \"fake Email\",\n image: profile.image || \"fake Image\",\n }\n },\n },\n ]\n }\n };\n\n return this.userAuthConfig;\n }\n}","import winston from \"winston\";\nimport { MatomoTransport } from \"./transports/matomo\";\nimport { GraylogTransport } from \"./transports/graylog\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { LOG_LEVELS } from \"@c-rex/constants\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\nexport class CrexLogger {\n private customerConfig!: ConfigInterface;\n public logger!: winston.Logger;\n\n private async initLogger() {\n if (!this.customerConfig) {\n this.customerConfig = await getConfigs();\n }\n\n if (!this.logger) {\n this.logger = this.createLogger();\n }\n }\n\n public async log({ level, message, category }: {\n level: LogLevelType,\n message: string,\n category?: LogCategoriesType\n }) {\n await this.initLogger();\n this.logger.log(level, message, category);\n }\n\n private createLogger() {\n return winston.createLogger({\n levels: LOG_LEVELS,\n transports: [\n new winston.transports.Console({\n level: this.customerConfig.logs.console.minimumLevel,\n silent: this.customerConfig.logs.console.silent,\n }),\n new MatomoTransport(this.customerConfig),\n new GraylogTransport(this.customerConfig),\n ],\n });\n }\n}","import Transport from \"winston-transport\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\nexport class MatomoTransport extends Transport {\n public matomoTransport: any;\n private configs: ConfigInterface;\n\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.console.minimumLevel,\n silent: configs.logs.console.silent,\n });\n\n this.matomoTransport = new Transport();\n this.configs = configs;\n }\n\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const matomoCategory = this.configs.logs.matomo.categoriesLevel\n\n if (matomoCategory.includes(info.category) || matomoCategory.includes(ALL)) {\n\n this.matomoTransport.log(info, callback);\n }\n }\n}\n","import Transport from \"winston-transport\";\nimport Graylog2Transport from \"winston-graylog2\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\nexport class GraylogTransport extends Transport {\n public graylogTransport: any;\n public configs: ConfigInterface\n\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.graylog.minimumLevel,\n silent: configs.logs.graylog.silent,\n });\n\n this.configs = configs;\n this.graylogTransport = new Graylog2Transport({\n name: \"Periotto-TEST\",\n silent: false,\n handleExceptions: false,\n graylog: {\n servers: [{ host: \"localhost\", port: 12201 }],\n },\n });\n }\n\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const graylogCategory = this.configs.logs.graylog.categoriesLevel\n\n if (graylogCategory.includes(info.category) || graylogCategory.includes(ALL)) {\n this.graylogTransport.log(info, callback);\n }\n }\n}\n","import { CrexSDK } from '../';\nimport { CrexLogger } from '../logger';\nimport { DirectoryNodesService, DocumentTypesService, InformationUnitsService, RenditionsService } from '@c-rex/services';\nimport { NextRequest, NextResponse } from 'next/server';\n\nconst serviceRegistry = {\n InformationUnitsService,\n DocumentTypesService,\n DirectoryNodesService,\n RenditionsService,\n CrexLogger,\n CrexSDK,\n};\n\ntype RpcPayload = {\n method: string;\n params: any;\n};\n\nexport const POST = async (req: NextRequest) => {\n try {\n const { method, params }: RpcPayload = await req.json();\n const [serviceName, methodName] = method.split('.');\n const ServiceClass = serviceRegistry[serviceName as keyof typeof serviceRegistry];\n\n if (!ServiceClass) {\n return NextResponse.json({ error: `Service '${serviceName}' not found` }, { status: 404 });\n }\n\n const serviceInstance = new ServiceClass();\n const handler = (serviceInstance as any)[methodName as any];\n\n if (typeof handler !== 'function') {\n return NextResponse.json({ error: `Method '${methodName}' not found on '${serviceName}'` }, { status: 404 });\n }\n\n const result = await handler.call(serviceInstance, params);\n return NextResponse.json({ data: result });\n } catch (err) {\n console.error(err);\n return NextResponse.json({ error: String(err) }, { status: 500 });\n }\n}\n"],"mappings":";AAAO,IAAM,MAAM;AAeZ,IAAM,aAAa;AAAA,EACtB,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACX;AA6CO,IAAM,uBAAuB,IAAI,KAAK,KAAK,KAAK;;;ACjEvD,SAAS,kBAAkB;AAEpB,IAAM,UAAN,MAAc;AAAA,EACV;AAAA,EACA;AAAA,EAEP,MAAc,YAAY;AACtB,QAAI,CAAC,KAAK,gBAAgB;AACtB,WAAK,iBAAiB,MAAM,WAAW;AAAA,IAC3C;AAAA,EACJ;AAAA,EAEA,MAAa,oBAAoB;AAC7B,QAAI,KAAK,gBAAgB;AACrB,aAAO,KAAK;AAAA,IAChB;AAEA,UAAM,KAAK,UAAU;AAErB,UAAM,OAAO,KAAK,eAAe,KAAK;AACtC,QAAI,KAAK,SAAS;AACd,WAAK,iBAAiB;AAAA,QAClB,WAAW;AAAA,UACP;AAAA,YACI,IAAI;AAAA,YACJ,MAAM;AAAA,YACN,MAAM;AAAA,YACN,UAAU,KAAK;AAAA,YACf,WAAW,KAAK;AAAA,YAChB,cAAc,KAAK;AAAA,YACnB,eAAe,EAAE,QAAQ,EAAE,OAAO,KAAK,MAAM,EAAE;AAAA,YAC/C,QAAQ,SAAc;AAClB,qBAAO;AAAA,gBACH,IAAI,QAAQ,MAAM;AAAA,gBAClB,MAAM,QAAQ,QAAQ;AAAA,gBACtB,OAAO,QAAQ,SAAS;AAAA,gBACxB,OAAO,QAAQ,SAAS;AAAA,cAC5B;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAC;AAED,WAAO,KAAK;AAAA,EAChB;AACJ;;;AC/CA,OAAO,aAAa;;;ACApB,OAAO,eAAe;AAKf,IAAM,kBAAN,cAA8B,UAAU;AAAA,EACpC;AAAA,EACC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