@memberjunction/server-bootstrap 4.2.0 → 4.3.0
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-bootstrap.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/server-bootstrap.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
vi.mock('@memberjunction/server', () => ({
|
|
3
|
+
serve: vi.fn().mockResolvedValue(undefined),
|
|
4
|
+
MJServerOptions: class {
|
|
5
|
+
},
|
|
6
|
+
configInfo: {},
|
|
7
|
+
}));
|
|
8
|
+
vi.mock('cosmiconfig', () => ({
|
|
9
|
+
cosmiconfigSync: vi.fn().mockReturnValue({
|
|
10
|
+
search: vi.fn().mockReturnValue({
|
|
11
|
+
config: {
|
|
12
|
+
codeGeneration: {
|
|
13
|
+
packages: {
|
|
14
|
+
entities: { name: '@test/generated-entities' },
|
|
15
|
+
actions: { name: '@test/generated-actions' },
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
filepath: '/test/mj.config.cjs',
|
|
20
|
+
isEmpty: false,
|
|
21
|
+
}),
|
|
22
|
+
}),
|
|
23
|
+
}));
|
|
24
|
+
import { createMJServer } from '../index.js';
|
|
25
|
+
import { serve } from '@memberjunction/server';
|
|
26
|
+
import { cosmiconfigSync } from 'cosmiconfig';
|
|
27
|
+
describe('ServerBootstrap', () => {
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
vi.clearAllMocks();
|
|
30
|
+
});
|
|
31
|
+
describe('createMJServer', () => {
|
|
32
|
+
it('should be a function', () => {
|
|
33
|
+
expect(typeof createMJServer).toBe('function');
|
|
34
|
+
});
|
|
35
|
+
it('should call cosmiconfigSync with mj module name', async () => {
|
|
36
|
+
await createMJServer();
|
|
37
|
+
expect(cosmiconfigSync).toHaveBeenCalledWith('mj', expect.objectContaining({
|
|
38
|
+
searchStrategy: 'global',
|
|
39
|
+
}));
|
|
40
|
+
});
|
|
41
|
+
it('should call serve with default resolver paths when none provided', async () => {
|
|
42
|
+
await createMJServer();
|
|
43
|
+
expect(serve).toHaveBeenCalledWith(expect.arrayContaining([
|
|
44
|
+
expect.stringContaining('generated.{js,ts}'),
|
|
45
|
+
]), undefined, expect.objectContaining({}));
|
|
46
|
+
});
|
|
47
|
+
it('should call serve with custom resolver paths when provided', async () => {
|
|
48
|
+
const customPaths = ['./custom/**/*Resolver.ts'];
|
|
49
|
+
await createMJServer({ resolverPaths: customPaths });
|
|
50
|
+
expect(serve).toHaveBeenCalledWith(customPaths, undefined, expect.objectContaining({}));
|
|
51
|
+
});
|
|
52
|
+
it('should call beforeStart hook if provided', async () => {
|
|
53
|
+
const beforeStart = vi.fn();
|
|
54
|
+
await createMJServer({ beforeStart });
|
|
55
|
+
expect(beforeStart).toHaveBeenCalled();
|
|
56
|
+
});
|
|
57
|
+
it('should call afterStart hook if provided', async () => {
|
|
58
|
+
const afterStart = vi.fn();
|
|
59
|
+
await createMJServer({ afterStart });
|
|
60
|
+
expect(afterStart).toHaveBeenCalled();
|
|
61
|
+
});
|
|
62
|
+
it('should pass restApiOptions to serve', async () => {
|
|
63
|
+
const restApiOptions = { enabled: true };
|
|
64
|
+
await createMJServer({ restApiOptions });
|
|
65
|
+
expect(serve).toHaveBeenCalledWith(expect.anything(), undefined, expect.objectContaining({ restApiOptions }));
|
|
66
|
+
});
|
|
67
|
+
it('should use custom configPath when provided', async () => {
|
|
68
|
+
const mockSearch = vi.fn().mockReturnValue({
|
|
69
|
+
config: {},
|
|
70
|
+
filepath: '/custom/path/mj.config.cjs',
|
|
71
|
+
isEmpty: false,
|
|
72
|
+
});
|
|
73
|
+
cosmiconfigSync.mockReturnValue({ search: mockSearch });
|
|
74
|
+
await createMJServer({ configPath: '/custom/path' });
|
|
75
|
+
expect(mockSearch).toHaveBeenCalledWith('/custom/path');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
describe('MJServerConfig interface', () => {
|
|
79
|
+
it('should accept empty config object', async () => {
|
|
80
|
+
const config = {};
|
|
81
|
+
expect(config).toBeDefined();
|
|
82
|
+
expect(config.configPath).toBeUndefined();
|
|
83
|
+
expect(config.resolverPaths).toBeUndefined();
|
|
84
|
+
expect(config.beforeStart).toBeUndefined();
|
|
85
|
+
expect(config.afterStart).toBeUndefined();
|
|
86
|
+
});
|
|
87
|
+
it('should accept all optional properties', () => {
|
|
88
|
+
const config = {
|
|
89
|
+
configPath: '/test/config',
|
|
90
|
+
resolverPaths: ['./resolvers/**/*.ts'],
|
|
91
|
+
beforeStart: async () => { },
|
|
92
|
+
afterStart: async () => { },
|
|
93
|
+
};
|
|
94
|
+
expect(config.configPath).toBe('/test/config');
|
|
95
|
+
expect(config.resolverPaths).toHaveLength(1);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=server-bootstrap.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-bootstrap.test.js","sourceRoot":"","sources":["../../src/__tests__/server-bootstrap.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE9D,EAAE,CAAC,IAAI,CAAC,wBAAwB,EAAE,GAAG,EAAE,CAAC,CAAC;IACrC,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC;IAC3C,eAAe,EAAE;KAAQ;IACzB,UAAU,EAAE,EAAE;CACjB,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1B,eAAe,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC;QACrC,MAAM,E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AAC;aAC7B,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC/C,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/server-bootstrap",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "MemberJunction Server Bootstrap - Encapsulates all server initialization logic",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
"prebuild": "mj codegen manifest --output ./src/generated/mj-class-registrations.ts || echo 'Warning: mj codegen manifest not available, using existing manifest'",
|
|
20
20
|
"build": "tsc && tsc-alias -f",
|
|
21
21
|
"watch": "tsc --watch",
|
|
22
|
-
"clean": "rimraf dist"
|
|
22
|
+
"clean": "rimraf dist",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"test:watch": "vitest"
|
|
23
25
|
},
|
|
24
26
|
"keywords": [
|
|
25
27
|
"memberjunction",
|
|
@@ -29,40 +31,40 @@
|
|
|
29
31
|
"author": "MemberJunction",
|
|
30
32
|
"license": "MIT",
|
|
31
33
|
"dependencies": {
|
|
32
|
-
"@memberjunction/actions": "4.
|
|
33
|
-
"@memberjunction/actions-apollo": "4.
|
|
34
|
-
"@memberjunction/actions-base": "4.
|
|
35
|
-
"@memberjunction/actions-bizapps-accounting": "4.
|
|
36
|
-
"@memberjunction/actions-bizapps-crm": "4.
|
|
37
|
-
"@memberjunction/actions-bizapps-formbuilders": "4.
|
|
38
|
-
"@memberjunction/actions-bizapps-lms": "4.
|
|
39
|
-
"@memberjunction/actions-bizapps-social": "4.
|
|
40
|
-
"@memberjunction/ai-agent-manager": "4.
|
|
41
|
-
"@memberjunction/ai-agents": "4.
|
|
42
|
-
"@memberjunction/ai-core-plus": "4.
|
|
43
|
-
"@memberjunction/ai-engine-base": "4.
|
|
44
|
-
"@memberjunction/ai-provider-bundle": "4.
|
|
45
|
-
"@memberjunction/ai-reranker": "4.
|
|
46
|
-
"@memberjunction/communication-ms-graph": "4.
|
|
47
|
-
"@memberjunction/communication-sendgrid": "4.
|
|
48
|
-
"@memberjunction/communication-types": "4.
|
|
49
|
-
"@memberjunction/content-autotagging": "4.
|
|
50
|
-
"@memberjunction/core": "4.
|
|
51
|
-
"@memberjunction/core-actions": "4.
|
|
52
|
-
"@memberjunction/core-entities": "4.
|
|
53
|
-
"@memberjunction/core-entities-server": "4.
|
|
54
|
-
"@memberjunction/data-context-server": "4.
|
|
55
|
-
"@memberjunction/doc-utils": "4.
|
|
56
|
-
"@memberjunction/encryption": "4.
|
|
57
|
-
"@memberjunction/entity-communications-base": "4.
|
|
58
|
-
"@memberjunction/queue": "4.
|
|
59
|
-
"@memberjunction/scheduling-actions": "4.
|
|
60
|
-
"@memberjunction/scheduling-engine": "4.
|
|
61
|
-
"@memberjunction/scheduling-engine-base": "4.
|
|
62
|
-
"@memberjunction/server": "4.
|
|
63
|
-
"@memberjunction/storage": "4.
|
|
64
|
-
"@memberjunction/templates": "4.
|
|
65
|
-
"@memberjunction/testing-engine": "4.
|
|
34
|
+
"@memberjunction/actions": "4.3.0",
|
|
35
|
+
"@memberjunction/actions-apollo": "4.3.0",
|
|
36
|
+
"@memberjunction/actions-base": "4.3.0",
|
|
37
|
+
"@memberjunction/actions-bizapps-accounting": "4.3.0",
|
|
38
|
+
"@memberjunction/actions-bizapps-crm": "4.3.0",
|
|
39
|
+
"@memberjunction/actions-bizapps-formbuilders": "4.3.0",
|
|
40
|
+
"@memberjunction/actions-bizapps-lms": "4.3.0",
|
|
41
|
+
"@memberjunction/actions-bizapps-social": "4.3.0",
|
|
42
|
+
"@memberjunction/ai-agent-manager": "4.3.0",
|
|
43
|
+
"@memberjunction/ai-agents": "4.3.0",
|
|
44
|
+
"@memberjunction/ai-core-plus": "4.3.0",
|
|
45
|
+
"@memberjunction/ai-engine-base": "4.3.0",
|
|
46
|
+
"@memberjunction/ai-provider-bundle": "4.3.0",
|
|
47
|
+
"@memberjunction/ai-reranker": "4.3.0",
|
|
48
|
+
"@memberjunction/communication-ms-graph": "4.3.0",
|
|
49
|
+
"@memberjunction/communication-sendgrid": "4.3.0",
|
|
50
|
+
"@memberjunction/communication-types": "4.3.0",
|
|
51
|
+
"@memberjunction/content-autotagging": "4.3.0",
|
|
52
|
+
"@memberjunction/core": "4.3.0",
|
|
53
|
+
"@memberjunction/core-actions": "4.3.0",
|
|
54
|
+
"@memberjunction/core-entities": "4.3.0",
|
|
55
|
+
"@memberjunction/core-entities-server": "4.3.0",
|
|
56
|
+
"@memberjunction/data-context-server": "4.3.0",
|
|
57
|
+
"@memberjunction/doc-utils": "4.3.0",
|
|
58
|
+
"@memberjunction/encryption": "4.3.0",
|
|
59
|
+
"@memberjunction/entity-communications-base": "4.3.0",
|
|
60
|
+
"@memberjunction/queue": "4.3.0",
|
|
61
|
+
"@memberjunction/scheduling-actions": "4.3.0",
|
|
62
|
+
"@memberjunction/scheduling-engine": "4.3.0",
|
|
63
|
+
"@memberjunction/scheduling-engine-base": "4.3.0",
|
|
64
|
+
"@memberjunction/server": "4.3.0",
|
|
65
|
+
"@memberjunction/storage": "4.3.0",
|
|
66
|
+
"@memberjunction/templates": "4.3.0",
|
|
67
|
+
"@memberjunction/testing-engine": "4.3.0",
|
|
66
68
|
"cosmiconfig": "^9.0.0"
|
|
67
69
|
},
|
|
68
70
|
"devDependencies": {
|