@push.rocks/smartregistry 1.1.1 → 1.3.1

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.
Files changed (51) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/cargo/classes.cargoregistry.d.ts +79 -0
  3. package/dist_ts/cargo/classes.cargoregistry.js +490 -0
  4. package/dist_ts/cargo/index.d.ts +5 -0
  5. package/dist_ts/cargo/index.js +6 -0
  6. package/dist_ts/cargo/interfaces.cargo.d.ts +160 -0
  7. package/dist_ts/cargo/interfaces.cargo.js +6 -0
  8. package/dist_ts/classes.smartregistry.d.ts +2 -2
  9. package/dist_ts/classes.smartregistry.js +50 -2
  10. package/dist_ts/composer/classes.composerregistry.d.ts +26 -0
  11. package/dist_ts/composer/classes.composerregistry.js +366 -0
  12. package/dist_ts/composer/helpers.composer.d.ts +35 -0
  13. package/dist_ts/composer/helpers.composer.js +120 -0
  14. package/dist_ts/composer/index.d.ts +7 -0
  15. package/dist_ts/composer/index.js +8 -0
  16. package/dist_ts/composer/interfaces.composer.d.ts +102 -0
  17. package/dist_ts/composer/interfaces.composer.js +6 -0
  18. package/dist_ts/core/classes.authmanager.d.ts +46 -1
  19. package/dist_ts/core/classes.authmanager.js +121 -12
  20. package/dist_ts/core/classes.registrystorage.d.ts +99 -0
  21. package/dist_ts/core/classes.registrystorage.js +246 -1
  22. package/dist_ts/core/interfaces.core.d.ts +4 -1
  23. package/dist_ts/index.d.ts +4 -1
  24. package/dist_ts/index.js +8 -2
  25. package/dist_ts/maven/classes.mavenregistry.d.ts +35 -0
  26. package/dist_ts/maven/classes.mavenregistry.js +407 -0
  27. package/dist_ts/maven/helpers.maven.d.ts +68 -0
  28. package/dist_ts/maven/helpers.maven.js +286 -0
  29. package/dist_ts/maven/index.d.ts +6 -0
  30. package/dist_ts/maven/index.js +7 -0
  31. package/dist_ts/maven/interfaces.maven.d.ts +116 -0
  32. package/dist_ts/maven/interfaces.maven.js +6 -0
  33. package/package.json +3 -2
  34. package/readme.md +288 -14
  35. package/ts/00_commitinfo_data.ts +1 -1
  36. package/ts/cargo/classes.cargoregistry.ts +604 -0
  37. package/ts/cargo/index.ts +6 -0
  38. package/ts/cargo/interfaces.cargo.ts +169 -0
  39. package/ts/classes.smartregistry.ts +56 -2
  40. package/ts/composer/classes.composerregistry.ts +475 -0
  41. package/ts/composer/helpers.composer.ts +139 -0
  42. package/ts/composer/index.ts +8 -0
  43. package/ts/composer/interfaces.composer.ts +111 -0
  44. package/ts/core/classes.authmanager.ts +145 -12
  45. package/ts/core/classes.registrystorage.ts +323 -0
  46. package/ts/core/interfaces.core.ts +4 -1
  47. package/ts/index.ts +10 -1
  48. package/ts/maven/classes.mavenregistry.ts +580 -0
  49. package/ts/maven/helpers.maven.ts +346 -0
  50. package/ts/maven/index.ts +7 -0
  51. package/ts/maven/interfaces.maven.ts +127 -0
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Cargo/crates.io registry type definitions
3
+ * Based on: https://doc.rust-lang.org/cargo/reference/registry-index.html
4
+ */
5
+
6
+ /**
7
+ * Dependency specification in Cargo index
8
+ */
9
+ export interface ICargoDepend {
10
+ /** Dependency package name */
11
+ name: string;
12
+ /** Version requirement (e.g., "^0.6", ">=1.0.0") */
13
+ req: string;
14
+ /** Optional features to enable */
15
+ features: string[];
16
+ /** Whether this dependency is optional */
17
+ optional: boolean;
18
+ /** Whether to include default features */
19
+ default_features: boolean;
20
+ /** Platform-specific target (e.g., "cfg(unix)") */
21
+ target: string | null;
22
+ /** Dependency kind: normal, dev, or build */
23
+ kind: 'normal' | 'dev' | 'build';
24
+ /** Alternative registry URL */
25
+ registry: string | null;
26
+ /** Rename to different package name */
27
+ package: string | null;
28
+ }
29
+
30
+ /**
31
+ * Single version entry in the Cargo index file
32
+ * Each line in the index file is one of these as JSON
33
+ */
34
+ export interface ICargoIndexEntry {
35
+ /** Crate name */
36
+ name: string;
37
+ /** Version string */
38
+ vers: string;
39
+ /** Dependencies */
40
+ deps: ICargoDepend[];
41
+ /** SHA256 checksum of the .crate file (hex) */
42
+ cksum: string;
43
+ /** Features (legacy format) */
44
+ features: Record<string, string[]>;
45
+ /** Features (extended format for newer Cargo) */
46
+ features2?: Record<string, string[]>;
47
+ /** Whether this version is yanked (deprecated but not deleted) */
48
+ yanked: boolean;
49
+ /** Optional native library link */
50
+ links?: string | null;
51
+ /** Index format version (2 is current) */
52
+ v?: number;
53
+ /** Minimum Rust version required */
54
+ rust_version?: string;
55
+ }
56
+
57
+ /**
58
+ * Metadata sent during crate publication
59
+ */
60
+ export interface ICargoPublishMetadata {
61
+ /** Crate name */
62
+ name: string;
63
+ /** Version string */
64
+ vers: string;
65
+ /** Dependencies */
66
+ deps: ICargoDepend[];
67
+ /** Features */
68
+ features: Record<string, string[]>;
69
+ /** Authors */
70
+ authors: string[];
71
+ /** Short description */
72
+ description?: string;
73
+ /** Documentation URL */
74
+ documentation?: string;
75
+ /** Homepage URL */
76
+ homepage?: string;
77
+ /** README content */
78
+ readme?: string;
79
+ /** README file path */
80
+ readme_file?: string;
81
+ /** Keywords for search */
82
+ keywords?: string[];
83
+ /** Categories */
84
+ categories?: string[];
85
+ /** License identifier (SPDX) */
86
+ license?: string;
87
+ /** License file path */
88
+ license_file?: string;
89
+ /** Repository URL */
90
+ repository?: string;
91
+ /** Badges */
92
+ badges?: Record<string, any>;
93
+ /** Native library link */
94
+ links?: string | null;
95
+ /** Minimum Rust version */
96
+ rust_version?: string;
97
+ }
98
+
99
+ /**
100
+ * Registry configuration (config.json)
101
+ * Required for sparse protocol support
102
+ */
103
+ export interface ICargoConfig {
104
+ /** Download URL template */
105
+ dl: string;
106
+ /** API base URL */
107
+ api: string;
108
+ /** Whether authentication is required for downloads */
109
+ 'auth-required'?: boolean;
110
+ }
111
+
112
+ /**
113
+ * Search result for a single crate
114
+ */
115
+ export interface ICargoSearchResult {
116
+ /** Crate name */
117
+ name: string;
118
+ /** Latest/maximum version */
119
+ max_version: string;
120
+ /** Description */
121
+ description: string;
122
+ }
123
+
124
+ /**
125
+ * Search response structure
126
+ */
127
+ export interface ICargoSearchResponse {
128
+ /** Array of matching crates */
129
+ crates: ICargoSearchResult[];
130
+ /** Metadata about results */
131
+ meta: {
132
+ /** Total number of results */
133
+ total: number;
134
+ };
135
+ }
136
+
137
+ /**
138
+ * Error response structure
139
+ */
140
+ export interface ICargoError {
141
+ /** Array of error details */
142
+ errors: Array<{
143
+ /** Error message */
144
+ detail: string;
145
+ }>;
146
+ }
147
+
148
+ /**
149
+ * Publish success response
150
+ */
151
+ export interface ICargoPublishResponse {
152
+ /** Warnings from validation */
153
+ warnings: {
154
+ /** Invalid categories */
155
+ invalid_categories: string[];
156
+ /** Invalid badges */
157
+ invalid_badges: string[];
158
+ /** Other warnings */
159
+ other: string[];
160
+ };
161
+ }
162
+
163
+ /**
164
+ * Yank/Unyank response
165
+ */
166
+ export interface ICargoYankResponse {
167
+ /** Success indicator */
168
+ ok: boolean;
169
+ }
@@ -4,10 +4,13 @@ import { BaseRegistry } from './core/classes.baseregistry.js';
4
4
  import type { IRegistryConfig, IRequestContext, IResponse } from './core/interfaces.core.js';
5
5
  import { OciRegistry } from './oci/classes.ociregistry.js';
6
6
  import { NpmRegistry } from './npm/classes.npmregistry.js';
7
+ import { MavenRegistry } from './maven/classes.mavenregistry.js';
8
+ import { CargoRegistry } from './cargo/classes.cargoregistry.js';
9
+ import { ComposerRegistry } from './composer/classes.composerregistry.js';
7
10
 
8
11
  /**
9
12
  * Main registry orchestrator
10
- * Routes requests to appropriate protocol handlers (OCI or NPM)
13
+ * Routes requests to appropriate protocol handlers (OCI, NPM, Maven, Cargo, or Composer)
11
14
  */
12
15
  export class SmartRegistry {
13
16
  private storage: RegistryStorage;
@@ -51,6 +54,33 @@ export class SmartRegistry {
51
54
  this.registries.set('npm', npmRegistry);
52
55
  }
53
56
 
57
+ // Initialize Maven registry if enabled
58
+ if (this.config.maven?.enabled) {
59
+ const mavenBasePath = this.config.maven.basePath || '/maven';
60
+ const registryUrl = `http://localhost:5000${mavenBasePath}`; // TODO: Make configurable
61
+ const mavenRegistry = new MavenRegistry(this.storage, this.authManager, mavenBasePath, registryUrl);
62
+ await mavenRegistry.init();
63
+ this.registries.set('maven', mavenRegistry);
64
+ }
65
+
66
+ // Initialize Cargo registry if enabled
67
+ if (this.config.cargo?.enabled) {
68
+ const cargoBasePath = this.config.cargo.basePath || '/cargo';
69
+ const registryUrl = `http://localhost:5000${cargoBasePath}`; // TODO: Make configurable
70
+ const cargoRegistry = new CargoRegistry(this.storage, this.authManager, cargoBasePath, registryUrl);
71
+ await cargoRegistry.init();
72
+ this.registries.set('cargo', cargoRegistry);
73
+ }
74
+
75
+ // Initialize Composer registry if enabled
76
+ if (this.config.composer?.enabled) {
77
+ const composerBasePath = this.config.composer.basePath || '/composer';
78
+ const registryUrl = `http://localhost:5000${composerBasePath}`; // TODO: Make configurable
79
+ const composerRegistry = new ComposerRegistry(this.storage, this.authManager, composerBasePath, registryUrl);
80
+ await composerRegistry.init();
81
+ this.registries.set('composer', composerRegistry);
82
+ }
83
+
54
84
  this.initialized = true;
55
85
  }
56
86
 
@@ -77,6 +107,30 @@ export class SmartRegistry {
77
107
  }
78
108
  }
79
109
 
110
+ // Route to Maven registry
111
+ if (this.config.maven?.enabled && path.startsWith(this.config.maven.basePath)) {
112
+ const mavenRegistry = this.registries.get('maven');
113
+ if (mavenRegistry) {
114
+ return mavenRegistry.handleRequest(context);
115
+ }
116
+ }
117
+
118
+ // Route to Cargo registry
119
+ if (this.config.cargo?.enabled && path.startsWith(this.config.cargo.basePath)) {
120
+ const cargoRegistry = this.registries.get('cargo');
121
+ if (cargoRegistry) {
122
+ return cargoRegistry.handleRequest(context);
123
+ }
124
+ }
125
+
126
+ // Route to Composer registry
127
+ if (this.config.composer?.enabled && path.startsWith(this.config.composer.basePath)) {
128
+ const composerRegistry = this.registries.get('composer');
129
+ if (composerRegistry) {
130
+ return composerRegistry.handleRequest(context);
131
+ }
132
+ }
133
+
80
134
  // No matching registry
81
135
  return {
82
136
  status: 404,
@@ -105,7 +159,7 @@ export class SmartRegistry {
105
159
  /**
106
160
  * Get a specific registry handler
107
161
  */
108
- public getRegistry(protocol: 'oci' | 'npm'): BaseRegistry | undefined {
162
+ public getRegistry(protocol: 'oci' | 'npm' | 'maven' | 'cargo' | 'composer'): BaseRegistry | undefined {
109
163
  return this.registries.get(protocol);
110
164
  }
111
165