@memberjunction/component-registry-server 2.99.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.
package/dist/Server.js ADDED
@@ -0,0 +1,450 @@
1
+ import express from 'express';
2
+ import cors from 'cors';
3
+ import { Metadata, RunView, LogStatus, LogError } from '@memberjunction/core';
4
+ import { setupSQLServerClient, SQLServerProviderConfigData } from '@memberjunction/sqlserver-dataprovider';
5
+ import * as sql from 'mssql';
6
+ import { configInfo, componentRegistrySettings, dbDatabase, dbHost, dbPassword, dbPort, dbUsername, dbInstanceName, dbTrustServerCertificate } from './config.js';
7
+ /**
8
+ * Base class for the Component Registry API Server.
9
+ * This class provides a complete implementation of the Component Registry API v1 specification.
10
+ *
11
+ * To customize the server behavior, extend this class and override the appropriate methods.
12
+ * Common customization points include:
13
+ * - Authentication: Override `checkAPIKey()` to implement custom authentication
14
+ * - Component filtering: Override `getComponentFilter()` to customize which components are served
15
+ * - Response formatting: Override the route handler methods to customize response formats
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * class MyCustomRegistryServer extends ComponentRegistryAPIServer {
20
+ * protected async checkAPIKey(req: Request): Promise<boolean> {
21
+ * const apiKey = req.headers['x-api-key'];
22
+ * return await myCustomAuthProvider.validateKey(apiKey);
23
+ * }
24
+ * }
25
+ * ```
26
+ */
27
+ export class ComponentRegistryAPIServer {
28
+ app;
29
+ registry = null;
30
+ metadata;
31
+ pool = null;
32
+ constructor() {
33
+ this.app = express();
34
+ this.metadata = new Metadata();
35
+ }
36
+ /**
37
+ * Initialize the server, including database connection, middleware, and routes.
38
+ * This method should be called before starting the server.
39
+ *
40
+ * @returns Promise that resolves when initialization is complete
41
+ * @throws Error if database connection fails or registry cannot be loaded
42
+ */
43
+ async initialize() {
44
+ // Setup database connection
45
+ await this.setupDatabase();
46
+ // Load registry metadata if ID provided
47
+ if (componentRegistrySettings?.registryId) {
48
+ await this.loadRegistry();
49
+ }
50
+ // Setup middleware and routes
51
+ this.setupMiddleware();
52
+ this.setupRoutes();
53
+ }
54
+ /**
55
+ * Start the Express server on the configured port.
56
+ * Must be called after `initialize()`.
57
+ *
58
+ * @returns Promise that resolves when the server is listening
59
+ */
60
+ async start() {
61
+ const port = componentRegistrySettings?.port || 3200;
62
+ return new Promise((resolve) => {
63
+ this.app.listen(port, () => {
64
+ LogStatus(`Component Registry API Server running on port ${port}`);
65
+ LogStatus(`API endpoint: http://localhost:${port}/api/v1`);
66
+ resolve();
67
+ });
68
+ });
69
+ }
70
+ /**
71
+ * Set up the database connection using MemberJunction's SQL Server provider.
72
+ * Override this method to use a different database provider or connection strategy.
73
+ *
74
+ * @protected
75
+ * @virtual
76
+ */
77
+ async setupDatabase() {
78
+ const poolConfig = {
79
+ server: dbHost,
80
+ port: dbPort,
81
+ user: dbUsername,
82
+ password: dbPassword,
83
+ database: dbDatabase,
84
+ requestTimeout: configInfo.databaseSettings.requestTimeout,
85
+ connectionTimeout: configInfo.databaseSettings.connectionTimeout,
86
+ options: {
87
+ encrypt: true,
88
+ enableArithAbort: true,
89
+ trustServerCertificate: dbTrustServerCertificate === 'Y'
90
+ }
91
+ };
92
+ if (dbInstanceName !== null && dbInstanceName !== undefined && dbInstanceName.trim().length > 0) {
93
+ poolConfig.options.instanceName = dbInstanceName;
94
+ }
95
+ this.pool = new sql.ConnectionPool(poolConfig);
96
+ await this.pool.connect();
97
+ const config = new SQLServerProviderConfigData(this.pool, configInfo.mjCoreSchema);
98
+ await setupSQLServerClient(config);
99
+ LogStatus('Database connection established');
100
+ }
101
+ /**
102
+ * Load the registry metadata from the database.
103
+ * This is called automatically if a registryId is provided in the configuration.
104
+ *
105
+ * @protected
106
+ * @virtual
107
+ */
108
+ async loadRegistry() {
109
+ if (!componentRegistrySettings?.registryId) {
110
+ return;
111
+ }
112
+ this.registry = await this.metadata.GetEntityObject('MJ: Component Registries');
113
+ const loaded = await this.registry.Load(componentRegistrySettings.registryId);
114
+ if (!loaded) {
115
+ throw new Error(`Failed to load registry with ID: ${componentRegistrySettings.registryId}`);
116
+ }
117
+ LogStatus(`Loaded registry: ${this.registry.Name}`);
118
+ }
119
+ /**
120
+ * Set up Express middleware.
121
+ * Override this method to add custom middleware or modify the middleware stack.
122
+ *
123
+ * @protected
124
+ * @virtual
125
+ */
126
+ setupMiddleware() {
127
+ // CORS
128
+ this.app.use(cors({
129
+ origin: componentRegistrySettings?.corsOrigins || ['*']
130
+ }));
131
+ // JSON parsing
132
+ this.app.use(express.json());
133
+ // Auth middleware (if enabled)
134
+ if (componentRegistrySettings?.requireAuth) {
135
+ this.app.use('/api/v1/components', this.authMiddleware.bind(this));
136
+ }
137
+ }
138
+ /**
139
+ * Authentication middleware that calls the checkAPIKey method.
140
+ * This middleware is automatically applied to /api/v1/components routes when requireAuth is true.
141
+ *
142
+ * @protected
143
+ */
144
+ async authMiddleware(req, res, next) {
145
+ try {
146
+ const isValid = await this.checkAPIKey(req);
147
+ if (!isValid) {
148
+ res.status(401).json({ error: 'Unauthorized' });
149
+ return;
150
+ }
151
+ next();
152
+ }
153
+ catch (error) {
154
+ LogError(`Authentication error: ${error instanceof Error ? error.message : String(error)}`);
155
+ res.status(500).json({ error: 'Authentication error' });
156
+ }
157
+ }
158
+ /**
159
+ * Check if the API key in the request is valid.
160
+ * By default, this method always returns true (no authentication).
161
+ *
162
+ * Override this method to implement custom authentication logic.
163
+ * Common patterns include:
164
+ * - Checking Bearer tokens in Authorization header
165
+ * - Validating API keys in custom headers
166
+ * - Verifying JWT tokens
167
+ * - Checking against a database of valid keys
168
+ *
169
+ * @param req - The Express request object
170
+ * @returns Promise<boolean> - True if the request is authenticated, false otherwise
171
+ *
172
+ * @protected
173
+ * @virtual
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * protected async checkAPIKey(req: Request): Promise<boolean> {
178
+ * const apiKey = req.headers['x-api-key'] as string;
179
+ * if (!apiKey) return false;
180
+ *
181
+ * // Check against database, cache, or external service
182
+ * return await this.validateKeyInDatabase(apiKey);
183
+ * }
184
+ * ```
185
+ */
186
+ async checkAPIKey(req) {
187
+ // Default implementation: no authentication required
188
+ // Override this method in a subclass to implement custom authentication
189
+ return true;
190
+ }
191
+ /**
192
+ * Set up the API routes.
193
+ * Override this method to add custom routes or modify existing ones.
194
+ *
195
+ * @protected
196
+ * @virtual
197
+ */
198
+ setupRoutes() {
199
+ // Registry info
200
+ this.app.get('/api/v1/registry', this.getRegistryInfo.bind(this));
201
+ this.app.get('/api/v1/health', this.getHealth.bind(this));
202
+ // Component operations
203
+ this.app.get('/api/v1/components', this.listComponents.bind(this));
204
+ this.app.get('/api/v1/components/search', this.searchComponents.bind(this));
205
+ this.app.get('/api/v1/components/:namespace/:name', this.getComponent.bind(this));
206
+ }
207
+ /**
208
+ * Get the base filter for component queries.
209
+ * By default, this returns components where SourceRegistryID IS NULL (local components only).
210
+ *
211
+ * Override this method to customize which components are served by the registry.
212
+ *
213
+ * @returns The SQL filter string to apply to all component queries
214
+ *
215
+ * @protected
216
+ * @virtual
217
+ *
218
+ * @example
219
+ * ```typescript
220
+ * protected getComponentFilter(): string {
221
+ * // Include both local and specific external registry components
222
+ * return "(SourceRegistryID IS NULL OR SourceRegistryID = 'abc-123')";
223
+ * }
224
+ * ```
225
+ */
226
+ getComponentFilter() {
227
+ return 'SourceRegistryID IS NULL';
228
+ }
229
+ /**
230
+ * Handler for GET /api/v1/registry
231
+ * Returns basic information about the registry.
232
+ *
233
+ * @protected
234
+ * @virtual
235
+ */
236
+ async getRegistryInfo(req, res) {
237
+ res.json({
238
+ name: this.registry?.Name || 'Local Component Registry',
239
+ description: this.registry?.Description || 'MemberJunction Component Registry',
240
+ version: 'v1',
241
+ requiresAuth: componentRegistrySettings?.requireAuth || false
242
+ });
243
+ }
244
+ /**
245
+ * Handler for GET /api/v1/health
246
+ * Returns the health status of the registry server.
247
+ *
248
+ * @protected
249
+ * @virtual
250
+ */
251
+ async getHealth(req, res) {
252
+ try {
253
+ const rv = new RunView();
254
+ const result = await rv.RunView({
255
+ EntityName: 'MJ: Components',
256
+ ExtraFilter: this.getComponentFilter(),
257
+ MaxRows: 1
258
+ });
259
+ res.json({
260
+ status: 'healthy',
261
+ timestamp: new Date().toISOString(),
262
+ version: 'v1',
263
+ componentCount: result.TotalRowCount
264
+ });
265
+ }
266
+ catch (error) {
267
+ res.status(503).json({
268
+ status: 'unhealthy',
269
+ timestamp: new Date().toISOString(),
270
+ version: 'v1',
271
+ error: error instanceof Error ? error.message : 'Unknown error'
272
+ });
273
+ }
274
+ }
275
+ /**
276
+ * Handler for GET /api/v1/components
277
+ * Lists all published components in the registry, showing only the latest version of each.
278
+ *
279
+ * @protected
280
+ * @virtual
281
+ */
282
+ async listComponents(req, res) {
283
+ try {
284
+ const baseFilter = this.getComponentFilter();
285
+ const filter = `${baseFilter} AND Status = 'Published'`;
286
+ const rv = new RunView();
287
+ const result = await rv.RunView({
288
+ EntityName: 'MJ: Components',
289
+ ExtraFilter: filter,
290
+ OrderBy: 'Namespace, Name, VersionSequence DESC'
291
+ });
292
+ if (!result.Success) {
293
+ res.status(500).json({ error: result.ErrorMessage });
294
+ return;
295
+ }
296
+ // Group by namespace/name and take latest version
297
+ const latestComponents = this.getLatestVersions(result.Results || []);
298
+ const components = latestComponents.map(c => ({
299
+ namespace: c.Namespace,
300
+ name: c.Name,
301
+ version: c.Version,
302
+ title: c.Title,
303
+ description: c.Description,
304
+ type: c.Type,
305
+ status: c.Status
306
+ }));
307
+ res.json({
308
+ components,
309
+ total: components.length
310
+ });
311
+ }
312
+ catch (error) {
313
+ LogError(`Failed to list components: ${error instanceof Error ? error.message : String(error)}`);
314
+ res.status(500).json({ error: 'Failed to list components' });
315
+ }
316
+ }
317
+ /**
318
+ * Handler for GET /api/v1/components/search
319
+ * Search for components by query string and optional type filter.
320
+ *
321
+ * @protected
322
+ * @virtual
323
+ */
324
+ async searchComponents(req, res) {
325
+ try {
326
+ const { q, type } = req.query;
327
+ let filter = `${this.getComponentFilter()} AND Status = 'Published'`;
328
+ if (q && typeof q === 'string') {
329
+ // Escape single quotes in the search query
330
+ const escapedQuery = q.replace(/'/g, "''");
331
+ filter += ` AND (Name LIKE '%${escapedQuery}%' OR Title LIKE '%${escapedQuery}%' OR Description LIKE '%${escapedQuery}%')`;
332
+ }
333
+ if (type && typeof type === 'string') {
334
+ const escapedType = type.replace(/'/g, "''");
335
+ filter += ` AND Type = '${escapedType}'`;
336
+ }
337
+ const rv = new RunView();
338
+ const result = await rv.RunView({
339
+ EntityName: 'MJ: Components',
340
+ ExtraFilter: filter,
341
+ OrderBy: 'Namespace, Name, VersionSequence DESC'
342
+ });
343
+ if (!result.Success) {
344
+ res.status(500).json({ error: result.ErrorMessage });
345
+ return;
346
+ }
347
+ // Group by namespace/name and take latest version
348
+ const latestComponents = this.getLatestVersions(result.Results || []);
349
+ const results = latestComponents.map(c => ({
350
+ namespace: c.Namespace,
351
+ name: c.Name,
352
+ version: c.Version,
353
+ title: c.Title,
354
+ description: c.Description,
355
+ type: c.Type,
356
+ status: c.Status
357
+ }));
358
+ res.json({
359
+ results,
360
+ total: results.length,
361
+ query: q || ''
362
+ });
363
+ }
364
+ catch (error) {
365
+ LogError(`Search failed: ${error instanceof Error ? error.message : String(error)}`);
366
+ res.status(500).json({ error: 'Search failed' });
367
+ }
368
+ }
369
+ /**
370
+ * Handler for GET /api/v1/components/:namespace/:name
371
+ * Get a specific component by namespace and name.
372
+ * Optionally specify a version with ?version=x.x.x query parameter.
373
+ *
374
+ * @protected
375
+ * @virtual
376
+ */
377
+ async getComponent(req, res) {
378
+ try {
379
+ const { namespace, name } = req.params;
380
+ const { version } = req.query;
381
+ // Escape single quotes in parameters
382
+ const escapedNamespace = namespace.replace(/'/g, "''");
383
+ const escapedName = name.replace(/'/g, "''");
384
+ let filter = `Namespace = '${escapedNamespace}' AND Name = '${escapedName}' AND ${this.getComponentFilter()}`;
385
+ if (version && typeof version === 'string') {
386
+ const escapedVersion = version.replace(/'/g, "''");
387
+ filter += ` AND Version = '${escapedVersion}'`;
388
+ }
389
+ const rv = new RunView();
390
+ const result = await rv.RunView({
391
+ EntityName: 'MJ: Components',
392
+ ExtraFilter: filter,
393
+ OrderBy: 'VersionSequence DESC',
394
+ MaxRows: 1
395
+ });
396
+ if (!result.Success || !result.Results?.length) {
397
+ res.status(404).json({ error: 'Component not found' });
398
+ return;
399
+ }
400
+ const component = result.Results[0];
401
+ res.json({
402
+ id: component.ID,
403
+ namespace: component.Namespace,
404
+ name: component.Name,
405
+ version: component.Version,
406
+ specification: JSON.parse(component.Specification)
407
+ });
408
+ }
409
+ catch (error) {
410
+ LogError(`Failed to fetch component: ${error instanceof Error ? error.message : String(error)}`);
411
+ res.status(500).json({ error: 'Failed to fetch component' });
412
+ }
413
+ }
414
+ /**
415
+ * Helper method to get the latest version of each component from a list.
416
+ * Components are grouped by namespace/name and the highest version is selected.
417
+ *
418
+ * @param components - Array of components potentially containing multiple versions
419
+ * @returns Array of components with only the latest version of each
420
+ *
421
+ * @protected
422
+ */
423
+ getLatestVersions(components) {
424
+ const latestComponents = new Map();
425
+ for (const component of components) {
426
+ const key = `${component.Namespace}/${component.Name}`;
427
+ if (!latestComponents.has(key)) {
428
+ latestComponents.set(key, component);
429
+ }
430
+ }
431
+ return Array.from(latestComponents.values());
432
+ }
433
+ }
434
+ /**
435
+ * Start the Component Registry Server using the default implementation.
436
+ * This function checks if the registry is enabled in configuration before starting.
437
+ *
438
+ * @returns Promise that resolves when the server is running
439
+ * @throws Error if initialization or startup fails
440
+ */
441
+ export async function startComponentRegistryServer() {
442
+ if (!componentRegistrySettings?.enableRegistry) {
443
+ LogStatus('Component Registry Server is disabled in configuration');
444
+ return;
445
+ }
446
+ const server = new ComponentRegistryAPIServer();
447
+ await server.initialize();
448
+ await server.start();
449
+ }
450
+ //# sourceMappingURL=Server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Server.js","sourceRoot":"","sources":["../src/Server.ts"],"names":[],"mappings":"AAAA,OAAO,OAA4C,MAAM,SAAS,CAAC;AACn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AM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACjG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,2BAA2B,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACO,iBAAiB,CAAC,UAA6B;QACvD,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA2B,CAAC;QAE5D,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,GAAG,SAAS,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;YACvD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC/B,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B;IAChD,IAAI,CAAC,yBAAyB,EAAE,cAAc,EAAE,CAAC;QAC/C,SAAS,CAAC,wDAAwD,CAAC,CAAC;QACpE,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,0BAA0B,EAAE,CAAC;IAChD,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAC1B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;AACvB,CAAC"}
@@ -0,0 +1,145 @@
1
+ import { z } from 'zod';
2
+ declare const databaseSettingsInfoSchema: z.ZodObject<{
3
+ connectionTimeout: z.ZodNumber;
4
+ requestTimeout: z.ZodNumber;
5
+ dbReadOnlyUsername: z.ZodOptional<z.ZodString>;
6
+ dbReadOnlyPassword: z.ZodOptional<z.ZodString>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ connectionTimeout: number;
9
+ requestTimeout: number;
10
+ dbReadOnlyUsername?: string | undefined;
11
+ dbReadOnlyPassword?: string | undefined;
12
+ }, {
13
+ connectionTimeout: number;
14
+ requestTimeout: number;
15
+ dbReadOnlyUsername?: string | undefined;
16
+ dbReadOnlyPassword?: string | undefined;
17
+ }>;
18
+ declare const componentRegistrySettingsSchema: z.ZodObject<{
19
+ port: z.ZodDefault<z.ZodNumber>;
20
+ enableRegistry: z.ZodDefault<z.ZodBoolean>;
21
+ registryId: z.ZodOptional<z.ZodString>;
22
+ requireAuth: z.ZodDefault<z.ZodBoolean>;
23
+ corsOrigins: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
24
+ }, "strip", z.ZodTypeAny, {
25
+ port: number;
26
+ enableRegistry: boolean;
27
+ requireAuth: boolean;
28
+ corsOrigins: string[];
29
+ registryId?: string | undefined;
30
+ }, {
31
+ port?: number | undefined;
32
+ enableRegistry?: boolean | undefined;
33
+ registryId?: string | undefined;
34
+ requireAuth?: boolean | undefined;
35
+ corsOrigins?: string[] | undefined;
36
+ }>;
37
+ declare const configInfoSchema: z.ZodObject<{
38
+ databaseSettings: z.ZodObject<{
39
+ connectionTimeout: z.ZodNumber;
40
+ requestTimeout: z.ZodNumber;
41
+ dbReadOnlyUsername: z.ZodOptional<z.ZodString>;
42
+ dbReadOnlyPassword: z.ZodOptional<z.ZodString>;
43
+ }, "strip", z.ZodTypeAny, {
44
+ connectionTimeout: number;
45
+ requestTimeout: number;
46
+ dbReadOnlyUsername?: string | undefined;
47
+ dbReadOnlyPassword?: string | undefined;
48
+ }, {
49
+ connectionTimeout: number;
50
+ requestTimeout: number;
51
+ dbReadOnlyUsername?: string | undefined;
52
+ dbReadOnlyPassword?: string | undefined;
53
+ }>;
54
+ dbHost: z.ZodDefault<z.ZodString>;
55
+ dbDatabase: z.ZodString;
56
+ dbPort: z.ZodDefault<z.ZodNumber>;
57
+ dbUsername: z.ZodString;
58
+ dbPassword: z.ZodString;
59
+ dbReadOnlyUsername: z.ZodOptional<z.ZodString>;
60
+ dbReadOnlyPassword: z.ZodOptional<z.ZodString>;
61
+ dbTrustServerCertificate: z.ZodEffects<z.ZodDefault<z.ZodBoolean>, "Y" | "N", boolean | undefined>;
62
+ dbInstanceName: z.ZodOptional<z.ZodString>;
63
+ mjCoreSchema: z.ZodString;
64
+ componentRegistrySettings: z.ZodOptional<z.ZodObject<{
65
+ port: z.ZodDefault<z.ZodNumber>;
66
+ enableRegistry: z.ZodDefault<z.ZodBoolean>;
67
+ registryId: z.ZodOptional<z.ZodString>;
68
+ requireAuth: z.ZodDefault<z.ZodBoolean>;
69
+ corsOrigins: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
70
+ }, "strip", z.ZodTypeAny, {
71
+ port: number;
72
+ enableRegistry: boolean;
73
+ requireAuth: boolean;
74
+ corsOrigins: string[];
75
+ registryId?: string | undefined;
76
+ }, {
77
+ port?: number | undefined;
78
+ enableRegistry?: boolean | undefined;
79
+ registryId?: string | undefined;
80
+ requireAuth?: boolean | undefined;
81
+ corsOrigins?: string[] | undefined;
82
+ }>>;
83
+ }, "strip", z.ZodTypeAny, {
84
+ databaseSettings: {
85
+ connectionTimeout: number;
86
+ requestTimeout: number;
87
+ dbReadOnlyUsername?: string | undefined;
88
+ dbReadOnlyPassword?: string | undefined;
89
+ };
90
+ dbHost: string;
91
+ dbDatabase: string;
92
+ dbPort: number;
93
+ dbUsername: string;
94
+ dbPassword: string;
95
+ dbTrustServerCertificate: "Y" | "N";
96
+ mjCoreSchema: string;
97
+ dbReadOnlyUsername?: string | undefined;
98
+ dbReadOnlyPassword?: string | undefined;
99
+ dbInstanceName?: string | undefined;
100
+ componentRegistrySettings?: {
101
+ port: number;
102
+ enableRegistry: boolean;
103
+ requireAuth: boolean;
104
+ corsOrigins: string[];
105
+ registryId?: string | undefined;
106
+ } | undefined;
107
+ }, {
108
+ databaseSettings: {
109
+ connectionTimeout: number;
110
+ requestTimeout: number;
111
+ dbReadOnlyUsername?: string | undefined;
112
+ dbReadOnlyPassword?: string | undefined;
113
+ };
114
+ dbDatabase: string;
115
+ dbUsername: string;
116
+ dbPassword: string;
117
+ mjCoreSchema: string;
118
+ dbReadOnlyUsername?: string | undefined;
119
+ dbReadOnlyPassword?: string | undefined;
120
+ dbHost?: string | undefined;
121
+ dbPort?: number | undefined;
122
+ dbTrustServerCertificate?: boolean | undefined;
123
+ dbInstanceName?: string | undefined;
124
+ componentRegistrySettings?: {
125
+ port?: number | undefined;
126
+ enableRegistry?: boolean | undefined;
127
+ registryId?: string | undefined;
128
+ requireAuth?: boolean | undefined;
129
+ corsOrigins?: string[] | undefined;
130
+ } | undefined;
131
+ }>;
132
+ export type DatabaseSettingsInfo = z.infer<typeof databaseSettingsInfoSchema>;
133
+ export type ComponentRegistrySettings = z.infer<typeof componentRegistrySettingsSchema>;
134
+ export type ConfigInfo = z.infer<typeof configInfoSchema>;
135
+ export declare const configInfo: ConfigInfo;
136
+ export declare const dbUsername: string, dbPassword: string, dbHost: string, dbDatabase: string, dbPort: number, dbTrustServerCertificate: "Y" | "N", dbInstanceName: string | undefined, mj_core_schema: string, dbReadOnlyUsername: string | undefined, dbReadOnlyPassword: string | undefined, componentRegistrySettings: {
137
+ port: number;
138
+ enableRegistry: boolean;
139
+ requireAuth: boolean;
140
+ corsOrigins: string[];
141
+ registryId?: string | undefined;
142
+ } | undefined;
143
+ export declare function loadConfig(): ConfigInfo;
144
+ export {};
145
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,QAAA,MAAM,0BAA0B;;;;;;;;;;;;;;;EAK9B,CAAC;AAEH,QAAA,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;EAMnC,CAAC;AAEH,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBpB,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AACxF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,UAAU,EAAE,UAAyB,CAAC;AAEnD,eAAO,MACL,UAAU,UACV,UAAU,UACV,MAAM,UACN,UAAU,UACV,MAAM,UACN,wBAAwB,aACxB,cAAc,sBACA,cAAc,UAC5B,kBAAkB,sBAClB,kBAAkB,sBAClB,yBAAyB;;;;;;aACb,CAAC;AAEf,wBAAgB,UAAU,IAAI,UAAU,CAevC"}
package/dist/config.js ADDED
@@ -0,0 +1,53 @@
1
+ import dotenv from 'dotenv';
2
+ dotenv.config();
3
+ import { z } from 'zod';
4
+ import { cosmiconfigSync } from 'cosmiconfig';
5
+ import { LogError } from '@memberjunction/core';
6
+ const explorer = cosmiconfigSync('mj', { searchStrategy: 'global' });
7
+ const databaseSettingsInfoSchema = z.object({
8
+ connectionTimeout: z.number(),
9
+ requestTimeout: z.number(),
10
+ dbReadOnlyUsername: z.string().optional(),
11
+ dbReadOnlyPassword: z.string().optional(),
12
+ });
13
+ const componentRegistrySettingsSchema = z.object({
14
+ port: z.number().default(3200),
15
+ enableRegistry: z.boolean().default(false), // Default to disabled
16
+ registryId: z.string().uuid().optional(),
17
+ requireAuth: z.boolean().default(false),
18
+ corsOrigins: z.array(z.string()).default(['*'])
19
+ });
20
+ const configInfoSchema = z.object({
21
+ databaseSettings: databaseSettingsInfoSchema,
22
+ dbHost: z.string().default('localhost'),
23
+ dbDatabase: z.string(),
24
+ dbPort: z.number({ coerce: true }).default(1433),
25
+ dbUsername: z.string(),
26
+ dbPassword: z.string(),
27
+ dbReadOnlyUsername: z.string().optional(),
28
+ dbReadOnlyPassword: z.string().optional(),
29
+ dbTrustServerCertificate: z.coerce
30
+ .boolean()
31
+ .default(false)
32
+ .transform((v) => (v ? 'Y' : 'N')),
33
+ dbInstanceName: z.string().optional(),
34
+ mjCoreSchema: z.string(),
35
+ componentRegistrySettings: componentRegistrySettingsSchema.optional()
36
+ });
37
+ export const configInfo = loadConfig();
38
+ export const { dbUsername, dbPassword, dbHost, dbDatabase, dbPort, dbTrustServerCertificate, dbInstanceName, mjCoreSchema: mj_core_schema, dbReadOnlyUsername, dbReadOnlyPassword, componentRegistrySettings, } = configInfo;
39
+ export function loadConfig() {
40
+ const configSearchResult = explorer.search(process.cwd());
41
+ if (!configSearchResult) {
42
+ throw new Error('Config file not found.');
43
+ }
44
+ if (configSearchResult.isEmpty) {
45
+ throw new Error(`Config file ${configSearchResult.filepath} is empty or does not exist.`);
46
+ }
47
+ const configParsing = configInfoSchema.safeParse(configSearchResult.config);
48
+ if (!configParsing.success) {
49
+ LogError('Error parsing config file', null, JSON.stringify(configParsing.error.issues, null, 2));
50
+ }
51
+ return configParsing.data;
52
+ }
53
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,CAAC;AAErE,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAA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