@push.rocks/smartregistry 1.1.1 → 1.4.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.
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 +103 -0
  21. package/dist_ts/core/classes.registrystorage.js +253 -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 +334 -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
package/readme.md CHANGED
@@ -1,18 +1,21 @@
1
1
  # @push.rocks/smartregistry
2
2
 
3
- > 🚀 A composable TypeScript library implementing both **OCI Distribution Specification v1.1** and **NPM Registry API** for building unified container and package registries.
3
+ > 🚀 A composable TypeScript library implementing **OCI Distribution Specification v1.1**, **NPM Registry API**, **Maven Repository**, **Cargo/crates.io Registry**, and **Composer/Packagist** for building unified container and package registries.
4
4
 
5
5
  ## ✨ Features
6
6
 
7
- ### 🔄 Dual Protocol Support
7
+ ### 🔄 Multi-Protocol Support
8
8
  - **OCI Distribution Spec v1.1**: Full container registry with manifest/blob operations
9
9
  - **NPM Registry API**: Complete package registry with publish/install/search
10
+ - **Maven Repository**: Java/JVM artifact management with POM support
11
+ - **Cargo/crates.io Registry**: Rust crate registry with sparse HTTP protocol
12
+ - **Composer/Packagist**: PHP package registry with Composer v2 protocol
10
13
 
11
14
  ### 🏗️ Unified Architecture
12
15
  - **Composable Design**: Core infrastructure with protocol plugins
13
16
  - **Shared Storage**: Cloud-agnostic S3-compatible backend ([@push.rocks/smartbucket](https://www.npmjs.com/package/@push.rocks/smartbucket))
14
- - **Unified Authentication**: Scope-based permissions across both protocols
15
- - **Path-based Routing**: `/oci/*` for containers, `/npm/*` for packages
17
+ - **Unified Authentication**: Scope-based permissions across all protocols
18
+ - **Path-based Routing**: `/oci/*` for containers, `/npm/*` for packages, `/maven/*` for Java artifacts, `/cargo/*` for Rust crates, `/composer/*` for PHP packages
16
19
 
17
20
  ### 🔐 Authentication & Authorization
18
21
  - NPM UUID tokens for package operations
@@ -35,6 +38,27 @@
35
38
  - ✅ Dist-tag management
36
39
  - ✅ Token management
37
40
 
41
+ **Maven Features:**
42
+ - ✅ Artifact upload/download
43
+ - ✅ POM and metadata management
44
+ - ✅ Snapshot and release versions
45
+ - ✅ Checksum verification (MD5, SHA1)
46
+
47
+ **Cargo Features:**
48
+ - ✅ Crate publish (.crate files)
49
+ - ✅ Sparse HTTP protocol (modern index)
50
+ - ✅ Version yank/unyank
51
+ - ✅ Dependency resolution
52
+ - ✅ Search functionality
53
+
54
+ **Composer Features:**
55
+ - ✅ Package publish/download (ZIP format)
56
+ - ✅ Composer v2 repository API
57
+ - ✅ Package metadata (packages.json)
58
+ - ✅ Version management
59
+ - ✅ Dependency resolution
60
+ - ✅ PSR-4/PSR-0 autoloading support
61
+
38
62
  ## 📥 Installation
39
63
 
40
64
  ```bash
@@ -78,6 +102,18 @@ const config: IRegistryConfig = {
78
102
  enabled: true,
79
103
  basePath: '/npm',
80
104
  },
105
+ maven: {
106
+ enabled: true,
107
+ basePath: '/maven',
108
+ },
109
+ cargo: {
110
+ enabled: true,
111
+ basePath: '/cargo',
112
+ },
113
+ composer: {
114
+ enabled: true,
115
+ basePath: '/composer',
116
+ },
81
117
  };
82
118
 
83
119
  const registry = new SmartRegistry(config);
@@ -212,6 +248,167 @@ const searchResults = await registry.handleRequest({
212
248
  });
213
249
  ```
214
250
 
251
+ ### 🦀 Cargo Registry (Rust Crates)
252
+
253
+ ```typescript
254
+ // Get config.json (required for Cargo)
255
+ const config = await registry.handleRequest({
256
+ method: 'GET',
257
+ path: '/cargo/config.json',
258
+ headers: {},
259
+ query: {},
260
+ });
261
+
262
+ // Get index file for a crate
263
+ const index = await registry.handleRequest({
264
+ method: 'GET',
265
+ path: '/cargo/se/rd/serde', // Path based on crate name length
266
+ headers: {},
267
+ query: {},
268
+ });
269
+
270
+ // Download a crate file
271
+ const crateFile = await registry.handleRequest({
272
+ method: 'GET',
273
+ path: '/cargo/api/v1/crates/serde/1.0.0/download',
274
+ headers: {},
275
+ query: {},
276
+ });
277
+
278
+ // Publish a crate (binary format: [4 bytes JSON len][JSON][4 bytes crate len][.crate])
279
+ const publishResponse = await registry.handleRequest({
280
+ method: 'PUT',
281
+ path: '/cargo/api/v1/crates/new',
282
+ headers: { 'Authorization': '<cargo-token>' }, // No "Bearer" prefix
283
+ query: {},
284
+ body: binaryPublishData, // Length-prefixed binary format
285
+ });
286
+
287
+ // Yank a version (deprecate without deleting)
288
+ const yankResponse = await registry.handleRequest({
289
+ method: 'DELETE',
290
+ path: '/cargo/api/v1/crates/my-crate/0.1.0/yank',
291
+ headers: { 'Authorization': '<cargo-token>' },
292
+ query: {},
293
+ });
294
+
295
+ // Unyank a version
296
+ const unyankResponse = await registry.handleRequest({
297
+ method: 'PUT',
298
+ path: '/cargo/api/v1/crates/my-crate/0.1.0/unyank',
299
+ headers: { 'Authorization': '<cargo-token>' },
300
+ query: {},
301
+ });
302
+
303
+ // Search crates
304
+ const search = await registry.handleRequest({
305
+ method: 'GET',
306
+ path: '/cargo/api/v1/crates',
307
+ headers: {},
308
+ query: { q: 'serde', per_page: '10' },
309
+ });
310
+ ```
311
+
312
+ **Using with Cargo CLI:**
313
+
314
+ ```toml
315
+ # .cargo/config.toml
316
+ [registries.myregistry]
317
+ index = "sparse+https://registry.example.com/cargo/"
318
+
319
+ [registries.myregistry.credential-provider]
320
+ # Or use credentials directly:
321
+ # [registries.myregistry]
322
+ # token = "your-api-token"
323
+ ```
324
+
325
+ ```bash
326
+ # Publish to custom registry
327
+ cargo publish --registry=myregistry
328
+
329
+ # Install from custom registry
330
+ cargo install --registry=myregistry my-crate
331
+
332
+ # Search custom registry
333
+ cargo search --registry=myregistry tokio
334
+ ```
335
+
336
+ ### 🎼 Composer Registry (PHP Packages)
337
+
338
+ ```typescript
339
+ // Get repository root (packages.json)
340
+ const packagesJson = await registry.handleRequest({
341
+ method: 'GET',
342
+ path: '/composer/packages.json',
343
+ headers: {},
344
+ query: {},
345
+ });
346
+
347
+ // Get package metadata
348
+ const metadata = await registry.handleRequest({
349
+ method: 'GET',
350
+ path: '/composer/p2/vendor/package.json',
351
+ headers: {},
352
+ query: {},
353
+ });
354
+
355
+ // Upload a package (ZIP with composer.json)
356
+ const zipBuffer = await readFile('package.zip');
357
+ const uploadResponse = await registry.handleRequest({
358
+ method: 'PUT',
359
+ path: '/composer/packages/vendor/package',
360
+ headers: { 'Authorization': `Bearer <composer-token>` },
361
+ query: {},
362
+ body: zipBuffer,
363
+ });
364
+
365
+ // Download package ZIP
366
+ const download = await registry.handleRequest({
367
+ method: 'GET',
368
+ path: '/composer/dists/vendor/package/ref123.zip',
369
+ headers: {},
370
+ query: {},
371
+ });
372
+
373
+ // List all packages
374
+ const list = await registry.handleRequest({
375
+ method: 'GET',
376
+ path: '/composer/packages/list.json',
377
+ headers: {},
378
+ query: {},
379
+ });
380
+
381
+ // Delete a specific version
382
+ const deleteVersion = await registry.handleRequest({
383
+ method: 'DELETE',
384
+ path: '/composer/packages/vendor/package/1.0.0',
385
+ headers: { 'Authorization': `Bearer <composer-token>` },
386
+ query: {},
387
+ });
388
+ ```
389
+
390
+ **Using with Composer CLI:**
391
+
392
+ ```json
393
+ // composer.json
394
+ {
395
+ "repositories": [
396
+ {
397
+ "type": "composer",
398
+ "url": "https://registry.example.com/composer"
399
+ }
400
+ ]
401
+ }
402
+ ```
403
+
404
+ ```bash
405
+ # Install from custom registry
406
+ composer require vendor/package
407
+
408
+ # Update packages
409
+ composer update
410
+ ```
411
+
215
412
  ### 🔐 Authentication
216
413
 
217
414
  ```typescript
@@ -374,6 +571,48 @@ NPM registry API compliant implementation.
374
571
  - `POST /-/npm/v1/tokens` - Create token
375
572
  - `PUT /-/package/{pkg}/dist-tags/{tag}` - Update tag
376
573
 
574
+ #### CargoRegistry
575
+
576
+ Cargo/crates.io registry with sparse HTTP protocol support.
577
+
578
+ **Endpoints:**
579
+ - `GET /config.json` - Registry configuration (sparse protocol)
580
+ - `GET /index/{path}` - Index files (hierarchical structure)
581
+ - `/1/{name}` - 1-character crate names
582
+ - `/2/{name}` - 2-character crate names
583
+ - `/3/{c}/{name}` - 3-character crate names
584
+ - `/{p1}/{p2}/{name}` - 4+ character crate names
585
+ - `PUT /api/v1/crates/new` - Publish crate (binary format)
586
+ - `GET /api/v1/crates/{crate}/{version}/download` - Download .crate file
587
+ - `DELETE /api/v1/crates/{crate}/{version}/yank` - Yank (deprecate) version
588
+ - `PUT /api/v1/crates/{crate}/{version}/unyank` - Unyank version
589
+ - `GET /api/v1/crates?q={query}` - Search crates
590
+
591
+ **Index Format:**
592
+ - Newline-delimited JSON (one line per version)
593
+ - SHA256 checksums for .crate files
594
+ - Yanked flag (keep files, mark unavailable)
595
+
596
+ #### ComposerRegistry
597
+
598
+ Composer v2 repository API compliant implementation.
599
+
600
+ **Endpoints:**
601
+ - `GET /packages.json` - Repository metadata and configuration
602
+ - `GET /p2/{vendor}/{package}.json` - Package version metadata
603
+ - `GET /p2/{vendor}/{package}~dev.json` - Dev versions metadata
604
+ - `GET /packages/list.json` - List all packages
605
+ - `GET /dists/{vendor}/{package}/{ref}.zip` - Download package ZIP
606
+ - `PUT /packages/{vendor}/{package}` - Upload package (requires auth)
607
+ - `DELETE /packages/{vendor}/{package}` - Delete entire package
608
+ - `DELETE /packages/{vendor}/{package}/{version}` - Delete specific version
609
+
610
+ **Package Format:**
611
+ - ZIP archives with composer.json in root
612
+ - SHA-1 checksums for verification
613
+ - Version normalization (1.0.0 → 1.0.0.0)
614
+ - PSR-4/PSR-0 autoloading configuration
615
+
377
616
  ## 🗄️ Storage Structure
378
617
 
379
618
  ```
@@ -385,16 +624,38 @@ bucket/
385
624
  │ │ └── {repository}/{digest}
386
625
  │ └── tags/
387
626
  │ └── {repository}/tags.json
388
- └── npm/
389
- ├── packages/
390
- │ ├── {name}/
391
- │ │ ├── index.json # Packument
392
- │ │ └── {name}-{ver}.tgz # Tarball
393
- │ └── @{scope}/{name}/
394
- │ ├── index.json
395
- │ └── {name}-{ver}.tgz
396
- └── users/
397
- └── {username}.json
627
+ ├── npm/
628
+ ├── packages/
629
+ ├── {name}/
630
+ │ │ ├── index.json # Packument
631
+ │ │ └── {name}-{ver}.tgz # Tarball
632
+ └── @{scope}/{name}/
633
+ ├── index.json
634
+ └── {name}-{ver}.tgz
635
+ └── users/
636
+ └── {username}.json
637
+ ├── maven/
638
+ │ ├── artifacts/
639
+ │ │ └── {group-path}/{artifact}/{version}/
640
+ │ │ ├── {artifact}-{version}.jar
641
+ │ │ ├── {artifact}-{version}.pom
642
+ │ │ └── {artifact}-{version}.{ext}
643
+ │ └── metadata/
644
+ │ └── {group-path}/{artifact}/maven-metadata.xml
645
+ ├── cargo/
646
+ │ ├── config.json # Registry configuration (sparse protocol)
647
+ │ ├── index/ # Hierarchical index structure
648
+ │ │ ├── 1/{name} # 1-char crate names (e.g., "a")
649
+ │ │ ├── 2/{name} # 2-char crate names (e.g., "io")
650
+ │ │ ├── 3/{c}/{name} # 3-char crate names (e.g., "3/a/axo")
651
+ │ │ └── {p1}/{p2}/{name} # 4+ char (e.g., "se/rd/serde")
652
+ │ └── crates/
653
+ │ └── {name}/{name}-{version}.crate # Gzipped tar archives
654
+ └── composer/
655
+ └── packages/
656
+ └── {vendor}/{package}/
657
+ ├── metadata.json # All versions metadata
658
+ └── {reference}.zip # Package ZIP files
398
659
  ```
399
660
 
400
661
  ## 🎯 Scope Format
@@ -408,9 +669,22 @@ Examples:
408
669
  npm:package:express:read # Read express package
409
670
  npm:package:*:write # Write any package
410
671
  npm:*:*:* # Full NPM access
672
+
411
673
  oci:repository:nginx:pull # Pull nginx image
412
674
  oci:repository:*:push # Push any image
413
675
  oci:*:*:* # Full OCI access
676
+
677
+ maven:artifact:com.example:read # Read Maven artifact
678
+ maven:artifact:*:write # Write any artifact
679
+ maven:*:*:* # Full Maven access
680
+
681
+ cargo:crate:serde:write # Write serde crate
682
+ cargo:crate:*:read # Read any crate
683
+ cargo:*:*:* # Full Cargo access
684
+
685
+ composer:package:vendor/package:read # Read Composer package
686
+ composer:package:*:write # Write any package
687
+ composer:*:*:* # Full Composer access
414
688
  ```
415
689
 
416
690
  ## 🔌 Integration Examples
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartregistry',
6
- version: '1.1.1',
6
+ version: '1.4.0',
7
7
  description: 'a registry for npm modules and oci images'
8
8
  }