@memberjunction/server 0.9.75 → 0.9.76
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/index.js +9 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +11 -16
package/dist/index.js
CHANGED
|
@@ -40,9 +40,9 @@ const body_parser_1 = require("body-parser");
|
|
|
40
40
|
const cors_1 = __importDefault(require("cors"));
|
|
41
41
|
const express_1 = __importDefault(require("express"));
|
|
42
42
|
const fast_glob_1 = require("fast-glob");
|
|
43
|
-
const node_path_1 = require("node:path");
|
|
44
43
|
const ws_1 = require("graphql-ws/lib/use/ws");
|
|
45
44
|
const node_http_1 = require("node:http");
|
|
45
|
+
const node_path_1 = require("node:path");
|
|
46
46
|
require("reflect-metadata");
|
|
47
47
|
const rxjs_1 = require("rxjs");
|
|
48
48
|
const type_graphql_1 = require("type-graphql");
|
|
@@ -62,29 +62,23 @@ Object.defineProperty(exports, "NewUserBase", { enumerable: true, get: function
|
|
|
62
62
|
var config_2 = require("./config");
|
|
63
63
|
Object.defineProperty(exports, "configInfo", { enumerable: true, get: function () { return config_2.configInfo; } });
|
|
64
64
|
__exportStar(require("./directives"), exports);
|
|
65
|
-
__exportStar(require("./types"), exports);
|
|
66
65
|
__exportStar(require("./entitySubclasses/userViewEntity.server"), exports);
|
|
66
|
+
__exportStar(require("./types"), exports);
|
|
67
67
|
const serve = async (resolverPaths) => {
|
|
68
68
|
const replaceBackslashes = node_path_1.sep === '\\';
|
|
69
|
-
const paths = resolverPaths.flatMap((path) => (0, fast_glob_1.globSync)(replaceBackslashes ? path.replace(/\\/g, '/') :
|
|
69
|
+
const paths = resolverPaths.flatMap((path) => (0, fast_glob_1.globSync)(replaceBackslashes ? path.replace(/\\/g, '/') : path));
|
|
70
70
|
if (paths.length === 0) {
|
|
71
71
|
console.warn(`No resolvers found in ${resolverPaths.join(', ')}`);
|
|
72
72
|
console.log({ resolverPaths, paths, cwd: process.cwd() });
|
|
73
73
|
}
|
|
74
74
|
const dataSource = new typeorm_1.DataSource((0, orm_1.default)(paths));
|
|
75
75
|
const setupComplete$ = new rxjs_1.ReplaySubject(1);
|
|
76
|
-
dataSource
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
console.log(`Data Source has been initialized. ${md?.Entities ? md.Entities.length : 0} entities loaded.`);
|
|
83
|
-
setupComplete$.next(true);
|
|
84
|
-
})
|
|
85
|
-
.catch((err) => {
|
|
86
|
-
console.error('Error during Data Source initialization', err);
|
|
87
|
-
});
|
|
76
|
+
await dataSource.initialize();
|
|
77
|
+
const config = new sqlserver_dataprovider_1.SQLServerProviderConfigData(dataSource, '', config_1.mj_core_schema, cacheRefreshInterval);
|
|
78
|
+
await (0, sqlserver_dataprovider_1.setupSQLServerClient)(config);
|
|
79
|
+
const md = new core_1.Metadata();
|
|
80
|
+
console.log(`Data Source has been initialized. ${md?.Entities ? md.Entities.length : 0} entities loaded.`);
|
|
81
|
+
setupComplete$.next(true);
|
|
88
82
|
const dynamicModules = await Promise.all(paths.map((modulePath) => { var _a; return _a = modulePath.replace(/\.[jt]s$/, ''), Promise.resolve().then(() => __importStar(require(_a))); }));
|
|
89
83
|
const resolvers = dynamicModules.flatMap((module) => Object.values(module).filter((value) => typeof value === 'function'));
|
|
90
84
|
const schema = directives_1.publicDirective.transformer((0, schema_1.mergeSchemas)({
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA4B;AAE5B,gBAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,sDAA4D;AAC5D,kDAAqD;AACrD,+CAAgD;AAChD,mFAA2G;AAC3G,6CAAmC;AACnC,gDAAwB;AACxB,sDAA8B;AAC9B,yCAAqC;AACrC,
|
|
1
|
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,CAAC,CAAC;IACxF,OAAO,CAAC,GAAG,CAAC,uCAAuC,oBAAW,GAAG,CAAC,CAAC;AACrE,CAAC,CAAC;AAnEW,QAAA,KAAK,SAmEhB;AAEF,kBAAe,aAAK,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -10,9 +10,9 @@ import { json } from 'body-parser';
|
|
|
10
10
|
import cors from 'cors';
|
|
11
11
|
import express from 'express';
|
|
12
12
|
import { globSync } from 'fast-glob';
|
|
13
|
-
import { sep } from 'node:path';
|
|
14
13
|
import { useServer } from 'graphql-ws/lib/use/ws';
|
|
15
14
|
import { createServer } from 'node:http';
|
|
15
|
+
import { sep } from 'node:path';
|
|
16
16
|
import 'reflect-metadata';
|
|
17
17
|
import { ReplaySubject } from 'rxjs';
|
|
18
18
|
import { BuildSchemaOptions, buildSchemaSync, GraphQLTimestamp } from 'type-graphql';
|
|
@@ -31,12 +31,12 @@ export * from 'type-graphql';
|
|
|
31
31
|
export { NewUserBase } from './auth/newUsers';
|
|
32
32
|
export { configInfo } from './config';
|
|
33
33
|
export * from './directives';
|
|
34
|
+
export * from './entitySubclasses/userViewEntity.server';
|
|
34
35
|
export * from './types';
|
|
35
|
-
export * from './entitySubclasses/userViewEntity.server'
|
|
36
36
|
|
|
37
37
|
export const serve = async (resolverPaths: Array<string>) => {
|
|
38
38
|
const replaceBackslashes = sep === '\\';
|
|
39
|
-
const paths = resolverPaths.flatMap((path) => globSync(replaceBackslashes ?
|
|
39
|
+
const paths = resolverPaths.flatMap((path) => globSync(replaceBackslashes ? path.replace(/\\/g, '/') : path));
|
|
40
40
|
if (paths.length === 0) {
|
|
41
41
|
console.warn(`No resolvers found in ${resolverPaths.join(', ')}`);
|
|
42
42
|
console.log({ resolverPaths, paths, cwd: process.cwd() });
|
|
@@ -44,19 +44,14 @@ export const serve = async (resolverPaths: Array<string>) => {
|
|
|
44
44
|
|
|
45
45
|
const dataSource = new DataSource(orm(paths));
|
|
46
46
|
const setupComplete$ = new ReplaySubject(1);
|
|
47
|
-
dataSource
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
setupComplete$.next(true);
|
|
56
|
-
})
|
|
57
|
-
.catch((err) => {
|
|
58
|
-
console.error('Error during Data Source initialization', err);
|
|
59
|
-
});
|
|
47
|
+
await dataSource.initialize();
|
|
48
|
+
|
|
49
|
+
const config = new SQLServerProviderConfigData(dataSource, '', mj_core_schema, cacheRefreshInterval);
|
|
50
|
+
await setupSQLServerClient(config); // datasource is already initialized, so we can setup the client right away
|
|
51
|
+
const md = new Metadata();
|
|
52
|
+
console.log(`Data Source has been initialized. ${md?.Entities ? md.Entities.length : 0} entities loaded.`);
|
|
53
|
+
|
|
54
|
+
setupComplete$.next(true);
|
|
60
55
|
|
|
61
56
|
const dynamicModules = await Promise.all(paths.map((modulePath) => import(modulePath.replace(/\.[jt]s$/, ''))));
|
|
62
57
|
const resolvers = dynamicModules.flatMap((module) =>
|