@memberjunction/component-registry-client-sdk 2.100.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/README.md ADDED
@@ -0,0 +1,197 @@
1
+ # Component Registry Client SDK
2
+
3
+ A TypeScript SDK for interacting with Component Registry servers. This package provides a robust REST API client for fetching, searching, and managing interactive components from remote registries.
4
+
5
+ ## Features
6
+
7
+ - 🚀 **Native Fetch**: Uses native fetch API, no external HTTP dependencies
8
+ - 🔄 **Retry Logic**: Automatic retry with exponential backoff
9
+ - ⏱️ **Timeout Support**: Configurable request timeouts
10
+ - 🔍 **Type Safety**: Full TypeScript support with comprehensive types
11
+ - 📦 **Component Management**: Get, search, and resolve component dependencies
12
+ - 🔒 **Authentication**: Support for API key and Bearer token authentication
13
+ - 🏗️ **Registry Integration**: Used by MJServer for external registry communication
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @memberjunction/component-registry-client-sdk
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ### Basic Setup
24
+
25
+ ```typescript
26
+ import { ComponentRegistryClient } from '@memberjunction/component-registry-client-sdk';
27
+
28
+ const client = new ComponentRegistryClient({
29
+ baseUrl: 'https://registry.example.com',
30
+ apiKey: 'your-api-key',
31
+ timeout: 30000
32
+ });
33
+ ```
34
+
35
+ ### Get a Component
36
+
37
+ ```typescript
38
+ const component = await client.getComponent({
39
+ registry: 'mj-central',
40
+ namespace: 'core/ui',
41
+ name: 'DataGrid',
42
+ version: '1.0.0' // or 'latest'
43
+ });
44
+
45
+ console.log(component.name);
46
+ console.log(component.code);
47
+ ```
48
+
49
+ ### Search Components
50
+
51
+ ```typescript
52
+ const results = await client.searchComponents({
53
+ namespace: 'core/ui',
54
+ query: 'dashboard',
55
+ type: 'dashboard',
56
+ tags: ['analytics', 'reporting'],
57
+ limit: 20,
58
+ offset: 0
59
+ });
60
+
61
+ console.log(`Found ${results.total} components`);
62
+ results.components.forEach(comp => {
63
+ console.log(`- ${comp.name}: ${comp.description}`);
64
+ });
65
+ ```
66
+
67
+ ### Resolve Dependencies
68
+
69
+ ```typescript
70
+ const dependencyTree = await client.resolveDependencies('component-123');
71
+
72
+ console.log(`Component has ${dependencyTree.totalCount} total dependencies`);
73
+ if (dependencyTree.circular) {
74
+ console.warn('Circular dependency detected!');
75
+ }
76
+ ```
77
+
78
+ ## Configuration Options
79
+
80
+ ```typescript
81
+ interface ComponentRegistryClientConfig {
82
+ baseUrl: string; // Registry server URL
83
+ apiKey?: string; // API key for authentication
84
+ timeout?: number; // Request timeout in ms (default: 30000)
85
+ headers?: HeadersInit; // Additional headers
86
+ retryPolicy?: {
87
+ maxRetries: number; // Max retry attempts (default: 3)
88
+ initialDelay: number; // Initial delay in ms (default: 1000)
89
+ maxDelay: number; // Max delay in ms (default: 10000)
90
+ backoffMultiplier: number; // Delay multiplier (default: 2)
91
+ };
92
+ }
93
+ ```
94
+
95
+ ## Error Handling
96
+
97
+ The SDK provides typed errors with specific error codes:
98
+
99
+ ```typescript
100
+ import { RegistryError, RegistryErrorCode } from '@memberjunction/component-registry-client-sdk';
101
+
102
+ try {
103
+ const component = await client.getComponent({...});
104
+ } catch (error) {
105
+ if (error instanceof RegistryError) {
106
+ switch (error.code) {
107
+ case RegistryErrorCode.COMPONENT_NOT_FOUND:
108
+ console.log('Component not found');
109
+ break;
110
+ case RegistryErrorCode.AUTHENTICATION_FAILED:
111
+ console.log('Invalid API key');
112
+ break;
113
+ case RegistryErrorCode.NETWORK_ERROR:
114
+ console.log('Network issue:', error.details);
115
+ break;
116
+ default:
117
+ console.error('Registry error:', error.message);
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
123
+ ## Integration with MemberJunction
124
+
125
+ This SDK integrates seamlessly with the MemberJunction platform:
126
+
127
+ ### GraphQL Integration
128
+
129
+ Use with the GraphQL data provider:
130
+
131
+ ```typescript
132
+ import { GraphQLComponentRegistryClient } from '@memberjunction/graphql-dataprovider';
133
+
134
+ const graphQLClient = new GraphQLComponentRegistryClient(dataProvider);
135
+ const component = await graphQLClient.GetRegistryComponent({
136
+ registryName: 'MJ', // Registry name (globally unique)
137
+ namespace: 'core/ui',
138
+ name: 'DataGrid',
139
+ version: 'latest'
140
+ });
141
+ ```
142
+
143
+ ### React Runtime Integration
144
+
145
+ Integrate with the React runtime:
146
+
147
+ ```typescript
148
+ import { ComponentRegistryService } from '@memberjunction/react-runtime';
149
+
150
+ const registryService = ComponentRegistryService.getInstance(
151
+ compiler,
152
+ runtimeContext,
153
+ debug,
154
+ graphQLClient
155
+ );
156
+ ```
157
+
158
+ ## Architecture Overview
159
+
160
+ ### Registry Communication Flow
161
+
162
+ 1. **React Runtime** → Requests component with `registry` field in spec
163
+ 2. **React Runtime** → Calls GraphQL API via `GraphQLComponentRegistryClient`
164
+ 3. **MJServer** → Receives GraphQL request with registry name
165
+ 4. **MJServer** → Creates `ComponentRegistryClient` on-demand
166
+ 5. **MJServer** → Fetches component from external registry using API key
167
+ 6. **External Registry** → Returns component specification
168
+ 7. **MJServer** → Returns spec to React Runtime
169
+ 8. **React Runtime** → Compiles and caches component
170
+
171
+ ### Key Design Decisions
172
+
173
+ - **On-Demand Client Creation**: MJServer creates registry clients per-request, not pre-initialized
174
+ - **Registry Name Resolution**: Components reference registries by globally unique names, not IDs
175
+ - **API Key Management**: All API keys handled server-side in MJServer, never exposed to client
176
+ - **No Client-Side Caching**: This SDK doesn't cache responses; caching happens at higher layers
177
+
178
+ ## API Reference
179
+
180
+ ### `getComponent(params)`
181
+ Fetches a specific component from a registry.
182
+
183
+ ### `searchComponents(params)`
184
+ Searches for components matching criteria.
185
+
186
+ ### `resolveDependencies(componentId)`
187
+ Resolves the full dependency tree for a component.
188
+
189
+ ### `getLatestVersion(registry, namespace, name)`
190
+ Gets the latest version of a component.
191
+
192
+ ### `checkHealth()`
193
+ Checks if the registry server is healthy.
194
+
195
+ ## License
196
+
197
+ MIT
@@ -0,0 +1,70 @@
1
+ import { ComponentSpec } from '@memberjunction/interactive-component-types';
2
+ import { ComponentRegistryClientConfig, GetComponentParams, SearchComponentsParams, ComponentSearchResult, ComponentResponse, ResolvedVersion, RegistryInfo, Namespace, DependencyTree } from './types';
3
+ /**
4
+ * Client for interacting with Component Registry Servers
5
+ */
6
+ export declare class ComponentRegistryClient {
7
+ private config;
8
+ private defaultTimeout;
9
+ private defaultRetryPolicy;
10
+ constructor(config: ComponentRegistryClientConfig);
11
+ /**
12
+ * Get a specific component from the registry (backward compatible)
13
+ */
14
+ getComponent(params: GetComponentParams): Promise<ComponentSpec>;
15
+ /**
16
+ * Get a specific component from the registry with hash support
17
+ * Returns ComponentResponse which includes hash and notModified flag
18
+ */
19
+ getComponentWithHash(params: GetComponentParams): Promise<ComponentResponse>;
20
+ /**
21
+ * Search for components in the registry
22
+ */
23
+ searchComponents(params: SearchComponentsParams): Promise<ComponentSearchResult>;
24
+ /**
25
+ * Resolve a version range to a specific version
26
+ */
27
+ resolveVersion(params: {
28
+ registry: string;
29
+ namespace: string;
30
+ name: string;
31
+ versionRange: string;
32
+ }): Promise<ResolvedVersion>;
33
+ /**
34
+ * Get information about a registry
35
+ */
36
+ getRegistryInfo(registry: string): Promise<RegistryInfo>;
37
+ /**
38
+ * List namespaces in a registry
39
+ */
40
+ listNamespaces(registry: string): Promise<Namespace[]>;
41
+ /**
42
+ * Resolve dependencies for a component
43
+ */
44
+ resolveDependencies(componentId: string): Promise<DependencyTree>;
45
+ /**
46
+ * Health check for the registry server
47
+ */
48
+ ping(): Promise<boolean>;
49
+ /**
50
+ * Make an HTTP request with retry logic
51
+ */
52
+ private makeRequest;
53
+ /**
54
+ * Determine if a request should be retried
55
+ */
56
+ private shouldRetry;
57
+ /**
58
+ * Calculate retry delay with exponential backoff
59
+ */
60
+ private getRetryDelay;
61
+ /**
62
+ * Sleep for specified milliseconds
63
+ */
64
+ private sleep;
65
+ /**
66
+ * Map error codes from server to client enum
67
+ */
68
+ private mapErrorCode;
69
+ }
70
+ //# sourceMappingURL=ComponentRegistryCl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,OAAO,CAAC;IAW9B;;OAEG;YACW,WAAW;IA4HzB;;OAEG;IACH,OAAO,CAAC,WAAW;IAenB;;OAEG;IACH,OAAO,CAAC,aAAa;IAMrB;;OAEG;IACH,OAAO,CAAC,KAAK;IAIb;;OAEG;IACH,OAAO,CAAC,YAAY;CAgBrB"}
@@ -0,0 +1,332 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ComponentRegistryClient = void 0;
4
+ const types_1 = require("./types");
5
+ /**
6
+ * Client for interacting with Component Registry Servers
7
+ */
8
+ class ComponentRegistryClient {
9
+ constructor(config) {
10
+ this.defaultTimeout = 30000; // 30 seconds
11
+ this.defaultRetryPolicy = {
12
+ maxRetries: 3,
13
+ initialDelay: 1000,
14
+ maxDelay: 10000,
15
+ backoffMultiplier: 2
16
+ };
17
+ this.config = {
18
+ ...config,
19
+ timeout: config.timeout || this.defaultTimeout,
20
+ retryPolicy: config.retryPolicy || this.defaultRetryPolicy
21
+ };
22
+ // Ensure baseUrl doesn't end with slash
23
+ if (this.config.baseUrl.endsWith('/')) {
24
+ this.config.baseUrl = this.config.baseUrl.slice(0, -1);
25
+ }
26
+ }
27
+ /**
28
+ * Get a specific component from the registry (backward compatible)
29
+ */
30
+ async getComponent(params) {
31
+ const response = await this.getComponentWithHash(params);
32
+ if (!response.specification) {
33
+ throw new types_1.RegistryError(`Component ${params.namespace}/${params.name} returned without specification`, types_1.RegistryErrorCode.UNKNOWN);
34
+ }
35
+ return response.specification;
36
+ }
37
+ /**
38
+ * Get a specific component from the registry with hash support
39
+ * Returns ComponentResponse which includes hash and notModified flag
40
+ */
41
+ async getComponentWithHash(params) {
42
+ const { namespace, name, version = 'latest', hash } = params;
43
+ // Build query parameters
44
+ const queryParams = new URLSearchParams();
45
+ if (version !== 'latest') {
46
+ queryParams.append('version', version);
47
+ }
48
+ if (hash) {
49
+ queryParams.append('hash', hash);
50
+ }
51
+ const queryString = queryParams.toString();
52
+ const path = `/api/v1/components/${encodeURIComponent(namespace)}/${encodeURIComponent(name)}${queryString ? `?${queryString}` : ''}`;
53
+ try {
54
+ const response = await this.makeRequest('GET', path);
55
+ // Handle 304 Not Modified response
56
+ if (response && typeof response === 'object' && 'message' in response && response.message === 'Not modified') {
57
+ return {
58
+ ...response,
59
+ notModified: true
60
+ };
61
+ }
62
+ return response;
63
+ }
64
+ catch (error) {
65
+ if (error instanceof types_1.RegistryError) {
66
+ throw error;
67
+ }
68
+ throw new types_1.RegistryError(`Failed to get component ${namespace}/${name}@${version}`, types_1.RegistryErrorCode.UNKNOWN, undefined, error);
69
+ }
70
+ }
71
+ /**
72
+ * Search for components in the registry
73
+ */
74
+ async searchComponents(params) {
75
+ const queryParams = new URLSearchParams();
76
+ if (params.registry)
77
+ queryParams.append('registry', params.registry);
78
+ if (params.namespace)
79
+ queryParams.append('namespace', params.namespace);
80
+ if (params.query)
81
+ queryParams.append('q', params.query);
82
+ if (params.type)
83
+ queryParams.append('type', params.type);
84
+ if (params.tags)
85
+ params.tags.forEach(tag => queryParams.append('tag', tag));
86
+ if (params.limit !== undefined)
87
+ queryParams.append('limit', params.limit.toString());
88
+ if (params.offset !== undefined)
89
+ queryParams.append('offset', params.offset.toString());
90
+ if (params.sortBy)
91
+ queryParams.append('sortBy', params.sortBy);
92
+ if (params.sortDirection)
93
+ queryParams.append('sortDirection', params.sortDirection);
94
+ const path = `/api/v1/components/search?${queryParams.toString()}`;
95
+ try {
96
+ const response = await this.makeRequest('GET', path);
97
+ return response;
98
+ }
99
+ catch (error) {
100
+ if (error instanceof types_1.RegistryError) {
101
+ throw error;
102
+ }
103
+ throw new types_1.RegistryError('Failed to search components', types_1.RegistryErrorCode.UNKNOWN, undefined, error);
104
+ }
105
+ }
106
+ /**
107
+ * Resolve a version range to a specific version
108
+ */
109
+ async resolveVersion(params) {
110
+ const { registry, namespace, name, versionRange } = params;
111
+ const path = `/api/v1/components/${encodeURIComponent(registry)}/${encodeURIComponent(namespace)}/${encodeURIComponent(name)}/versions/resolve`;
112
+ try {
113
+ const response = await this.makeRequest('POST', path, {
114
+ versionRange
115
+ });
116
+ return response;
117
+ }
118
+ catch (error) {
119
+ if (error instanceof types_1.RegistryError) {
120
+ throw error;
121
+ }
122
+ throw new types_1.RegistryError(`Failed to resolve version for ${registry}/${namespace}/${name}`, types_1.RegistryErrorCode.UNKNOWN, undefined, error);
123
+ }
124
+ }
125
+ /**
126
+ * Get information about a registry
127
+ */
128
+ async getRegistryInfo(registry) {
129
+ const path = `/api/v1/registries/${encodeURIComponent(registry)}`;
130
+ try {
131
+ const response = await this.makeRequest('GET', path);
132
+ return response;
133
+ }
134
+ catch (error) {
135
+ if (error instanceof types_1.RegistryError) {
136
+ throw error;
137
+ }
138
+ throw new types_1.RegistryError(`Failed to get registry info for ${registry}`, types_1.RegistryErrorCode.UNKNOWN, undefined, error);
139
+ }
140
+ }
141
+ /**
142
+ * List namespaces in a registry
143
+ */
144
+ async listNamespaces(registry) {
145
+ const path = `/api/v1/registries/${encodeURIComponent(registry)}/namespaces`;
146
+ try {
147
+ const response = await this.makeRequest('GET', path);
148
+ return response;
149
+ }
150
+ catch (error) {
151
+ if (error instanceof types_1.RegistryError) {
152
+ throw error;
153
+ }
154
+ throw new types_1.RegistryError(`Failed to list namespaces for registry ${registry}`, types_1.RegistryErrorCode.UNKNOWN, undefined, error);
155
+ }
156
+ }
157
+ /**
158
+ * Resolve dependencies for a component
159
+ */
160
+ async resolveDependencies(componentId) {
161
+ const path = `/api/v1/components/${encodeURIComponent(componentId)}/dependencies`;
162
+ try {
163
+ const response = await this.makeRequest('GET', path);
164
+ return response;
165
+ }
166
+ catch (error) {
167
+ if (error instanceof types_1.RegistryError) {
168
+ throw error;
169
+ }
170
+ throw new types_1.RegistryError(`Failed to resolve dependencies for component ${componentId}`, types_1.RegistryErrorCode.UNKNOWN, undefined, error);
171
+ }
172
+ }
173
+ /**
174
+ * Health check for the registry server
175
+ */
176
+ async ping() {
177
+ const path = '/api/v1/health';
178
+ try {
179
+ await this.makeRequest('GET', path);
180
+ return true;
181
+ }
182
+ catch (error) {
183
+ return false;
184
+ }
185
+ }
186
+ /**
187
+ * Make an HTTP request with retry logic
188
+ */
189
+ async makeRequest(method, path, body, retryCount = 0) {
190
+ const url = `${this.config.baseUrl}${path}`;
191
+ // Build headers
192
+ const headers = {
193
+ 'Accept': 'application/json',
194
+ 'Content-Type': 'application/json',
195
+ ...this.config.headers
196
+ };
197
+ if (this.config.apiKey) {
198
+ headers['Authorization'] = `Bearer ${this.config.apiKey}`;
199
+ }
200
+ // Create abort controller for timeout
201
+ const controller = new AbortController();
202
+ const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
203
+ try {
204
+ const response = await fetch(url, {
205
+ method,
206
+ headers,
207
+ body: body ? JSON.stringify(body) : undefined,
208
+ signal: controller.signal
209
+ });
210
+ clearTimeout(timeoutId);
211
+ // Handle response - include 304 Not Modified as success
212
+ if (response.ok || response.status === 304) {
213
+ const contentType = response.headers.get('content-type');
214
+ if (contentType && contentType.includes('application/json')) {
215
+ return await response.json();
216
+ }
217
+ return await response.text();
218
+ }
219
+ // Handle errors
220
+ let errorMessage = `Request failed with status ${response.status}`;
221
+ let errorCode = types_1.RegistryErrorCode.UNKNOWN;
222
+ let errorDetails;
223
+ try {
224
+ const errorBody = await response.json();
225
+ if (errorBody.message)
226
+ errorMessage = errorBody.message;
227
+ if (errorBody.code)
228
+ errorCode = this.mapErrorCode(errorBody.code);
229
+ errorDetails = errorBody;
230
+ }
231
+ catch {
232
+ // If response isn't JSON, use status text
233
+ errorMessage = response.statusText || errorMessage;
234
+ }
235
+ // Map HTTP status to error codes
236
+ if (!errorDetails || !errorDetails.code) {
237
+ switch (response.status) {
238
+ case 401:
239
+ errorCode = types_1.RegistryErrorCode.UNAUTHORIZED;
240
+ break;
241
+ case 403:
242
+ errorCode = types_1.RegistryErrorCode.FORBIDDEN;
243
+ break;
244
+ case 404:
245
+ errorCode = types_1.RegistryErrorCode.COMPONENT_NOT_FOUND;
246
+ break;
247
+ case 429:
248
+ errorCode = types_1.RegistryErrorCode.RATE_LIMITED;
249
+ break;
250
+ case 500:
251
+ case 502:
252
+ case 503:
253
+ case 504:
254
+ errorCode = types_1.RegistryErrorCode.SERVER_ERROR;
255
+ break;
256
+ }
257
+ }
258
+ throw new types_1.RegistryError(errorMessage, errorCode, response.status, errorDetails);
259
+ }
260
+ catch (error) {
261
+ clearTimeout(timeoutId);
262
+ // Handle timeout
263
+ if (error.name === 'AbortError') {
264
+ throw new types_1.RegistryError(`Request timeout after ${this.config.timeout}ms`, types_1.RegistryErrorCode.TIMEOUT);
265
+ }
266
+ // Handle network errors
267
+ if (error instanceof TypeError && error.message.includes('fetch')) {
268
+ throw new types_1.RegistryError('Network error: Unable to connect to registry', types_1.RegistryErrorCode.NETWORK_ERROR, undefined, error);
269
+ }
270
+ // If it's already a RegistryError, check if we should retry
271
+ if (error instanceof types_1.RegistryError) {
272
+ if (this.shouldRetry(error, retryCount)) {
273
+ const delay = this.getRetryDelay(retryCount);
274
+ await this.sleep(delay);
275
+ return this.makeRequest(method, path, body, retryCount + 1);
276
+ }
277
+ throw error;
278
+ }
279
+ // Unknown error
280
+ throw new types_1.RegistryError('Unexpected error during request', types_1.RegistryErrorCode.UNKNOWN, undefined, error);
281
+ }
282
+ }
283
+ /**
284
+ * Determine if a request should be retried
285
+ */
286
+ shouldRetry(error, retryCount) {
287
+ if (retryCount >= this.config.retryPolicy.maxRetries) {
288
+ return false;
289
+ }
290
+ // Retry on network errors, timeouts, and server errors
291
+ const retryableCodes = [
292
+ types_1.RegistryErrorCode.NETWORK_ERROR,
293
+ types_1.RegistryErrorCode.TIMEOUT,
294
+ types_1.RegistryErrorCode.SERVER_ERROR
295
+ ];
296
+ return retryableCodes.includes(error.code);
297
+ }
298
+ /**
299
+ * Calculate retry delay with exponential backoff
300
+ */
301
+ getRetryDelay(retryCount) {
302
+ const policy = this.config.retryPolicy;
303
+ const delay = policy.initialDelay * Math.pow(policy.backoffMultiplier, retryCount);
304
+ return Math.min(delay, policy.maxDelay);
305
+ }
306
+ /**
307
+ * Sleep for specified milliseconds
308
+ */
309
+ sleep(ms) {
310
+ return new Promise(resolve => setTimeout(resolve, ms));
311
+ }
312
+ /**
313
+ * Map error codes from server to client enum
314
+ */
315
+ mapErrorCode(code) {
316
+ const codeMap = {
317
+ 'COMPONENT_NOT_FOUND': types_1.RegistryErrorCode.COMPONENT_NOT_FOUND,
318
+ 'UNAUTHORIZED': types_1.RegistryErrorCode.UNAUTHORIZED,
319
+ 'FORBIDDEN': types_1.RegistryErrorCode.FORBIDDEN,
320
+ 'RATE_LIMITED': types_1.RegistryErrorCode.RATE_LIMITED,
321
+ 'INVALID_VERSION': types_1.RegistryErrorCode.INVALID_VERSION,
322
+ 'INVALID_NAMESPACE': types_1.RegistryErrorCode.INVALID_NAMESPACE,
323
+ 'NETWORK_ERROR': types_1.RegistryErrorCode.NETWORK_ERROR,
324
+ 'TIMEOUT': types_1.RegistryErrorCode.TIMEOUT,
325
+ 'SERVER_ERROR': types_1.RegistryErrorCode.SERVER_ERROR,
326
+ 'INVALID_RESPONSE': types_1.RegistryErrorCode.INVALID_RESPONSE
327
+ };
328
+ return codeMap[code] || types_1.RegistryErrorCode.UNKNOWN;
329
+ }
330
+ }
331
+ exports.ComponentRegistryClient = ComponentRegistryClient;
332
+ //# sourceMappingURL=ComponentRegistryClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentRegistryClient.js","sourceRoot":"","sources":["../src/ComponentRegistryClient.ts"],"names":[],"mappings":";;;AACA,mCAaiB;AAEjB;;GAEG;AACH,MAAa,uBAAuB;IAUlC,YAAY,MAAqC;QARzC,mBAAc,GAAG,KAAK,CAAC,CAAC,aAAa;QACrC,uBAAkB,GAAgB;YACxC,UAAU,EAAE,CAAC;YACb,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,KAAK;YACf,iBAAiB,EAAE,CAAC;SACrB,CAAC;QAGA,IAAI,CAAC,MAAM,GAAG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D,CAAC;QAEF,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,yBAAiB,CAAC,OAAO,CAAC;IACpD,CAAC;CACF;AAxZD,0DAwZC"}
@@ -0,0 +1,3 @@
1
+ export * from './ComponentRegistryClient';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // PUBLIC API SURFACE AREA
18
+ __exportStar(require("./ComponentRegistryClient"), exports);
19
+ __exportStar(require("./types"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0BAA0B;AAC1B,4DAA0C;AAC1C,0CAAwB"}
@@ -0,0 +1,305 @@
1
+ import { ComponentSpec } from '@memberjunction/interactive-component-types';
2
+ /**
3
+ * Configuration for the Component Registry Client
4
+ */
5
+ export interface ComponentRegistryClientConfig {
6
+ /**
7
+ * Base URL of the Component Registry Server
8
+ */
9
+ baseUrl: string;
10
+ /**
11
+ * Optional API key for authentication
12
+ */
13
+ apiKey?: string;
14
+ /**
15
+ * Request timeout in milliseconds
16
+ */
17
+ timeout?: number;
18
+ /**
19
+ * Retry policy configuration
20
+ */
21
+ retryPolicy?: RetryPolicy;
22
+ /**
23
+ * Custom headers to include with all requests
24
+ */
25
+ headers?: Record<string, string>;
26
+ }
27
+ /**
28
+ * Retry policy configuration
29
+ */
30
+ export interface RetryPolicy {
31
+ /**
32
+ * Maximum number of retry attempts
33
+ */
34
+ maxRetries: number;
35
+ /**
36
+ * Initial delay in milliseconds
37
+ */
38
+ initialDelay?: number;
39
+ /**
40
+ * Maximum delay in milliseconds
41
+ */
42
+ maxDelay?: number;
43
+ /**
44
+ * Backoff multiplier for exponential backoff
45
+ */
46
+ backoffMultiplier?: number;
47
+ }
48
+ /**
49
+ * Parameters for getting a component
50
+ */
51
+ export interface GetComponentParams {
52
+ /**
53
+ * Registry identifier
54
+ */
55
+ registry: string;
56
+ /**
57
+ * Component namespace
58
+ */
59
+ namespace: string;
60
+ /**
61
+ * Component name
62
+ */
63
+ name: string;
64
+ /**
65
+ * Component version (defaults to 'latest')
66
+ */
67
+ version?: string;
68
+ /**
69
+ * Optional hash for caching - if provided and matches current spec, returns 304
70
+ */
71
+ hash?: string;
72
+ }
73
+ /**
74
+ * Component response with hash and caching support
75
+ */
76
+ export interface ComponentResponse {
77
+ /**
78
+ * Component ID
79
+ */
80
+ id: string;
81
+ /**
82
+ * Component namespace
83
+ */
84
+ namespace: string;
85
+ /**
86
+ * Component name
87
+ */
88
+ name: string;
89
+ /**
90
+ * Component version
91
+ */
92
+ version: string;
93
+ /**
94
+ * Component specification (undefined if not modified - 304 response)
95
+ */
96
+ specification?: ComponentSpec;
97
+ /**
98
+ * SHA-256 hash of the specification
99
+ */
100
+ hash: string;
101
+ /**
102
+ * Indicates if the component was not modified (304 response)
103
+ */
104
+ notModified?: boolean;
105
+ /**
106
+ * Message from server (e.g., "Not modified")
107
+ */
108
+ message?: string;
109
+ }
110
+ /**
111
+ * Parameters for searching components
112
+ */
113
+ export interface SearchComponentsParams {
114
+ /**
115
+ * Optional registry filter
116
+ */
117
+ registry?: string;
118
+ /**
119
+ * Optional namespace filter
120
+ */
121
+ namespace?: string;
122
+ /**
123
+ * Search query string
124
+ */
125
+ query?: string;
126
+ /**
127
+ * Component type filter
128
+ */
129
+ type?: string;
130
+ /**
131
+ * Tags to filter by
132
+ */
133
+ tags?: string[];
134
+ /**
135
+ * Maximum number of results
136
+ */
137
+ limit?: number;
138
+ /**
139
+ * Offset for pagination
140
+ */
141
+ offset?: number;
142
+ /**
143
+ * Sort field
144
+ */
145
+ sortBy?: 'name' | 'version' | 'createdAt' | 'updatedAt';
146
+ /**
147
+ * Sort direction
148
+ */
149
+ sortDirection?: 'asc' | 'desc';
150
+ }
151
+ /**
152
+ * Search result containing components and metadata
153
+ */
154
+ export interface ComponentSearchResult {
155
+ /**
156
+ * Array of matching components
157
+ */
158
+ components: ComponentSpec[];
159
+ /**
160
+ * Total number of matches
161
+ */
162
+ total: number;
163
+ /**
164
+ * Current offset
165
+ */
166
+ offset: number;
167
+ /**
168
+ * Current limit
169
+ */
170
+ limit: number;
171
+ }
172
+ /**
173
+ * Resolved version information
174
+ */
175
+ export interface ResolvedVersion {
176
+ /**
177
+ * The resolved version number
178
+ */
179
+ version: string;
180
+ /**
181
+ * Whether this is the latest version
182
+ */
183
+ isLatest: boolean;
184
+ /**
185
+ * Available versions that match the range
186
+ */
187
+ availableVersions?: string[];
188
+ }
189
+ /**
190
+ * Registry information
191
+ */
192
+ export interface RegistryInfo {
193
+ /**
194
+ * Registry identifier
195
+ */
196
+ id: string;
197
+ /**
198
+ * Registry name
199
+ */
200
+ name: string;
201
+ /**
202
+ * Registry description
203
+ */
204
+ description?: string;
205
+ /**
206
+ * Registry version
207
+ */
208
+ version: string;
209
+ /**
210
+ * Available namespaces
211
+ */
212
+ namespaces?: string[];
213
+ /**
214
+ * Total component count
215
+ */
216
+ componentCount?: number;
217
+ /**
218
+ * Registry capabilities
219
+ */
220
+ capabilities?: string[];
221
+ }
222
+ /**
223
+ * Namespace information
224
+ */
225
+ export interface Namespace {
226
+ /**
227
+ * Namespace path
228
+ */
229
+ path: string;
230
+ /**
231
+ * Display name
232
+ */
233
+ name?: string;
234
+ /**
235
+ * Description
236
+ */
237
+ description?: string;
238
+ /**
239
+ * Number of components in namespace
240
+ */
241
+ componentCount?: number;
242
+ /**
243
+ * Child namespaces
244
+ */
245
+ children?: Namespace[];
246
+ }
247
+ /**
248
+ * Dependency tree structure
249
+ */
250
+ export interface DependencyTree {
251
+ /**
252
+ * Component identifier
253
+ */
254
+ componentId: string;
255
+ /**
256
+ * Component name
257
+ */
258
+ name?: string;
259
+ /**
260
+ * Component namespace
261
+ */
262
+ namespace?: string;
263
+ /**
264
+ * Component version
265
+ */
266
+ version?: string;
267
+ /**
268
+ * Direct dependencies
269
+ */
270
+ dependencies?: DependencyTree[];
271
+ /**
272
+ * Whether this is a circular dependency
273
+ */
274
+ circular?: boolean;
275
+ /**
276
+ * Total count of all dependencies
277
+ */
278
+ totalCount?: number;
279
+ }
280
+ /**
281
+ * Error codes for registry operations
282
+ */
283
+ export declare enum RegistryErrorCode {
284
+ COMPONENT_NOT_FOUND = "COMPONENT_NOT_FOUND",
285
+ UNAUTHORIZED = "UNAUTHORIZED",
286
+ FORBIDDEN = "FORBIDDEN",
287
+ RATE_LIMITED = "RATE_LIMITED",
288
+ INVALID_VERSION = "INVALID_VERSION",
289
+ INVALID_NAMESPACE = "INVALID_NAMESPACE",
290
+ NETWORK_ERROR = "NETWORK_ERROR",
291
+ TIMEOUT = "TIMEOUT",
292
+ SERVER_ERROR = "SERVER_ERROR",
293
+ INVALID_RESPONSE = "INVALID_RESPONSE",
294
+ UNKNOWN = "UNKNOWN"
295
+ }
296
+ /**
297
+ * Registry-specific error class
298
+ */
299
+ export declare class RegistryError extends Error {
300
+ code: RegistryErrorCode;
301
+ statusCode?: number;
302
+ details?: any;
303
+ constructor(message: string, code: RegistryErrorCode, statusCode?: number, details?: any);
304
+ }
305
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;I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qB;IACrC,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IAG7B,IAAI,EAAE,iBAAiB;IACvB,UAAU,CAAC,EAAE,MAAM;IACnB,OAAO,CAAC,EAAE,GAAG;gBAHpB,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,iBAAiB,EACvB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,GAAG;CAKvB"}
package/dist/types.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RegistryError = exports.RegistryErrorCode = void 0;
4
+ /**
5
+ * Error codes for registry operations
6
+ */
7
+ var RegistryErrorCode;
8
+ (function (RegistryErrorCode) {
9
+ RegistryErrorCode["COMPONENT_NOT_FOUND"] = "COMPONENT_NOT_FOUND";
10
+ RegistryErrorCode["UNAUTHORIZED"] = "UNAUTHORIZED";
11
+ RegistryErrorCode["FORBIDDEN"] = "FORBIDDEN";
12
+ RegistryErrorCode["RATE_LIMITED"] = "RATE_LIMITED";
13
+ RegistryErrorCode["INVALID_VERSION"] = "INVALID_VERSION";
14
+ RegistryErrorCode["INVALID_NAMESPACE"] = "INVALID_NAMESPACE";
15
+ RegistryErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
16
+ RegistryErrorCode["TIMEOUT"] = "TIMEOUT";
17
+ RegistryErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
18
+ RegistryErrorCode["INVALID_RESPONSE"] = "INVALID_RESPONSE";
19
+ RegistryErrorCode["UNKNOWN"] = "UNKNOWN";
20
+ })(RegistryErrorCode || (exports.RegistryErrorCode = RegistryErrorCode = {}));
21
+ /**
22
+ * Registry-specific error class
23
+ */
24
+ class RegistryError extends Error {
25
+ constructor(message, code, statusCode, details) {
26
+ super(message);
27
+ this.code = code;
28
+ this.statusCode = statusCode;
29
+ this.details = details;
30
+ this.name = 'RegistryError';
31
+ }
32
+ }
33
+ exports.RegistryError = RegistryError;
34
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAiVA;;GAEG;AACH,IAAY,iBAYX;AAZD,WAAY,iBAAiB;IAC3B,gEAA2C,CAAA;IAC3C,kDAA6B,CAAA;IAC7B,4CAAuB,CAAA;IACvB,kDAA6B,CAAA;IAC7B,wDAAmC,CAAA;IACnC,4DAAuC,CAAA;IACvC,oDAA+B,CAAA;IAC/B,wCAAmB,CAAA;IACnB,kDAA6B,CAAA;IAC7B,0DAAqC,CAAA;IACrC,wCAAmB,CAAA;AACrB,CAAC,EAZW,iBAAiB,iCAAjB,iBAAiB,QAY5B;AAED;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IACtC,YACE,OAAe,EACR,IAAuB,EACvB,UAAmB,EACnB,OAAa;QAEpB,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,SAAI,GAAJ,IAAI,CAAmB;QACvB,eAAU,GAAV,UAAU,CAAS;QACnB,YAAO,GAAP,OAAO,CAAM;QAGpB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAVD,sCAUC"}
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@memberjunction/component-registry-client-sdk",
3
+ "version": "2.100.0",
4
+ "description": "MemberJunction: Component Registry Client SDK",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "/dist"
9
+ ],
10
+ "scripts": {
11
+ "start": "ts-node-dev src/index.ts",
12
+ "build": "tsc",
13
+ "test": "echo \"Error: no test specified\" && exit 1"
14
+ },
15
+ "author": "MemberJunction.com",
16
+ "license": "ISC",
17
+ "devDependencies": {
18
+ "ts-node-dev": "^2.0.0",
19
+ "typescript": "^5.4.5"
20
+ },
21
+ "dependencies": {
22
+ "@memberjunction/global": "2.100.0",
23
+ "@memberjunction/core": "2.100.0",
24
+ "@memberjunction/interactive-component-types": "2.100.0"
25
+ }
26
+ }