@powerhousedao/registry 6.0.0-dev.105 → 6.0.0-dev.106

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.
@@ -658,4 +658,4 @@ specific requirements.
658
658
  You should also get your employer (if you work as a programmer) or school,
659
659
  if any, to sign a "copyright disclaimer" for the program, if necessary.
660
660
  For more information on this, and how to apply and follow the GNU AGPL, see
661
- <https://www.gnu.org/licenses/>.
661
+ <https://www.gnu.org/licenses/>.
package/README.md CHANGED
@@ -1,52 +1,124 @@
1
1
  # @powerhousedao/registry
2
2
 
3
- Express-based server that serves Powerhouse packages (ESM bundles) for dynamic loading via `import()` in browsers and Node.js.
3
+ Powerhouse package registry built on Verdaccio. Serves as both an npm registry and a CDN for Powerhouse package bundles (ESM) for dynamic `import()` in browsers and Node.js.
4
4
 
5
- ## Quick Start
5
+ ## API
6
6
 
7
- ### CLI
7
+ ### Packages
8
8
 
9
- ```sh
10
- # Serve packages from a directory
11
- ph-registry ./path/to/packages 3000
9
+ #### `GET /packages`
12
10
 
13
- # Or with environment variables
14
- REGISTRY_DIR=./packages PORT=3000 ph-registry
11
+ Returns a JSON array of all discovered packages. Supports filtering by document type:
15
12
 
16
- # Or run directly
17
- node dist/src/run.js ./path/to/packages 3000
18
13
  ```
14
+ GET /packages?documentType=powerhouse/package
15
+ ```
16
+
17
+ #### `GET /packages/by-document-type?type=<documentType>`
18
+
19
+ Returns an array of package names that contain the specified document type.
20
+
21
+ #### `GET /packages/<packageName>`
22
+
23
+ Returns info for a single package (supports scoped names like `@powerhousedao/vetra`).
24
+
25
+ ### CDN
26
+
27
+ #### `GET /-/cdn/<packageName>/<filePath>`
19
28
 
20
- Arguments:
29
+ Serves files from the CDN cache. On first request, fetches and extracts the tarball from Verdaccio. Looks for files in the package root, then `cdn/`, `dist/cdn/`, and `dist/` subdirectories.
21
30
 
22
- - `dir` (positional, 1st) -- directory to serve packages from (default: `.`, env: `REGISTRY_DIR`)
23
- - `port` (positional, 2nd) -- port to listen on (default: `8080`, env: `PORT`)
31
+ ### Publish Notifications
24
32
 
25
- ### Library
33
+ When a package is published, the registry can notify subscribers in real time via Server-Sent Events (SSE) and webhooks.
34
+
35
+ #### SSE — `GET /-/events`
36
+
37
+ Opens a persistent SSE connection. The server sends:
38
+
39
+ - `connected` event on initial connection
40
+ - `publish` event whenever a package is published, with payload:
41
+
42
+ ```json
43
+ { "packageName": "@scope/pkg", "version": "1.0.0" }
44
+ ```
45
+
46
+ Example (browser):
26
47
 
27
48
  ```ts
28
- import express from "express";
29
- import { createRegistryRouter } from "@powerhousedao/registry";
49
+ const source = new EventSource("http://localhost:8080/-/events");
50
+ source.addEventListener("publish", (e) => {
51
+ const { packageName, version } = JSON.parse(e.data);
52
+ console.log(`${packageName}@${version} published`);
53
+ });
54
+ ```
55
+
56
+ #### Webhooks
57
+
58
+ Webhooks are persisted to disk and survive restarts. Predefined webhooks can also be provided via configuration.
30
59
 
31
- const app = express();
32
- app.use(createRegistryRouter("./packages"));
33
- app.listen(3000);
60
+ ##### `GET /-/webhooks`
61
+
62
+ Returns all registered webhooks (predefined + dynamic).
63
+
64
+ ##### `POST /-/webhooks`
65
+
66
+ Registers a new webhook. Body:
67
+
68
+ ```json
69
+ { "endpoint": "https://example.com/hook", "headers": { "X-Token": "secret" } }
34
70
  ```
35
71
 
36
- ## API
72
+ `headers` is optional. Returns `201` on success. Duplicate endpoints are ignored.
37
73
 
38
- ### `createPowerhouseRouter(config)`
74
+ ##### `DELETE /-/webhooks`
39
75
 
40
- Creates an Express `Router` that serves packages.
76
+ Removes a dynamic webhook. Body:
41
77
 
42
- ### `GET /packages`
78
+ ```json
79
+ { "endpoint": "https://example.com/hook" }
80
+ ```
81
+
82
+ Returns `204` on success, `404` if not found. Predefined webhooks cannot be removed.
43
83
 
44
- Returns a JSON array of all discovered packages.
84
+ When a package is published, each webhook receives a POST with:
85
+
86
+ ```json
87
+ { "packageName": "@scope/pkg", "version": "1.0.0" }
88
+ ```
45
89
 
46
- ### `GET /packages/by-document-type?type=<documentType>`
90
+ ### npm Protocol
47
91
 
48
- Returns package names that contain the specified document type.
92
+ All standard npm registry operations (publish, install, etc.) are handled by Verdaccio.
49
93
 
50
- ### `GET /-/cdn/<packageName>/<filePath>`
94
+ ## Publishing Packages
95
+
96
+ ```sh
97
+ npm publish --registry http://localhost:8080/
98
+ ```
99
+
100
+ On publish, the CDN cache for that package is automatically invalidated and the new version is extracted immediately.
101
+
102
+ ## CLI
103
+
104
+ ```sh
105
+ ph-registry --port 8080 --storage-dir ./storage --cdn-cache-dir ./cdn-cache
106
+ ```
51
107
 
52
- Serves files from the CDN cache for a package.
108
+ Options:
109
+
110
+ | Option | Env Variable | Default | Description |
111
+ |---|---|---|---|
112
+ | `--port` | `PORT` | `8080` | Port to listen on |
113
+ | `--storage-dir` | `REGISTRY_STORAGE` | `./storage` | Verdaccio storage directory |
114
+ | `--cdn-cache-dir` | `REGISTRY_CDN_CACHE` | `./cdn-cache` | CDN cache directory |
115
+ | `--uplink` | `REGISTRY_UPLINK` | — | Upstream npm registry URL |
116
+ | `--web-enabled` | `REGISTRY_WEB` | `true` | Enable Verdaccio web UI |
117
+ | `--webhook` | `REGISTRY_WEBHOOKS` | — | Comma-separated webhook URLs to notify on publish |
118
+ | `--s3-bucket` | `S3_BUCKET` | — | S3 bucket for storage |
119
+ | `--s3-endpoint` | `S3_ENDPOINT` | — | S3 endpoint URL |
120
+ | `--s3-region` | `S3_REGION` | — | S3 region |
121
+ | `--s3-access-key-id` | `S3_ACCESS_KEY_ID` | — | S3 access key |
122
+ | `--s3-secret-access-key` | `S3_SECRET_ACCESS_KEY` | — | S3 secret key |
123
+ | `--s3-key-prefix` | `S3_KEY_PREFIX` | — | S3 key prefix |
124
+ | `--s3-force-path-style` | `S3_FORCE_PATH_STYLE` | `true` | Force S3 path-style URLs |
package/dist/cli.d.mts ADDED
@@ -0,0 +1,41 @@
1
+ import * as cmd_ts_dist_cjs_argparser_js0 from "cmd-ts/dist/cjs/argparser.js";
2
+ import * as cmd_ts_dist_cjs_helpdoc_js0 from "cmd-ts/dist/cjs/helpdoc.js";
3
+ import * as cmd_ts_dist_cjs_runner_js0 from "cmd-ts/dist/cjs/runner.js";
4
+
5
+ //#region cli.d.ts
6
+ declare const registryCommand: Partial<cmd_ts_dist_cjs_argparser_js0.Register> & {
7
+ parse(context: cmd_ts_dist_cjs_argparser_js0.ParseContext): Promise<cmd_ts_dist_cjs_argparser_js0.ParsingResult<{
8
+ port: number;
9
+ storageDir: string;
10
+ cdnCacheDir: string;
11
+ uplink: string | undefined;
12
+ s3Bucket: string | undefined;
13
+ s3Endpoint: string | undefined;
14
+ s3Region: string | undefined;
15
+ s3AccessKeyId: string | undefined;
16
+ s3SecretAccessKey: string | undefined;
17
+ s3KeyPrefix: string | undefined;
18
+ s3ForcePathStyle: boolean;
19
+ webEnabled: boolean;
20
+ webhooks: string | undefined;
21
+ }>>;
22
+ } & cmd_ts_dist_cjs_helpdoc_js0.PrintHelp & cmd_ts_dist_cjs_helpdoc_js0.ProvidesHelp & cmd_ts_dist_cjs_helpdoc_js0.Named & Partial<cmd_ts_dist_cjs_helpdoc_js0.Versioned> & cmd_ts_dist_cjs_argparser_js0.Register & cmd_ts_dist_cjs_runner_js0.Handling<{
23
+ port: number;
24
+ storageDir: string;
25
+ cdnCacheDir: string;
26
+ uplink: string | undefined;
27
+ s3Bucket: string | undefined;
28
+ s3Endpoint: string | undefined;
29
+ s3Region: string | undefined;
30
+ s3AccessKeyId: string | undefined;
31
+ s3SecretAccessKey: string | undefined;
32
+ s3KeyPrefix: string | undefined;
33
+ s3ForcePathStyle: boolean;
34
+ webEnabled: boolean;
35
+ webhooks: string | undefined;
36
+ }, Promise<void>> & {
37
+ run(context: cmd_ts_dist_cjs_argparser_js0.ParseContext): Promise<cmd_ts_dist_cjs_argparser_js0.ParsingResult<Promise<void>>>;
38
+ } & Partial<cmd_ts_dist_cjs_helpdoc_js0.Versioned & cmd_ts_dist_cjs_helpdoc_js0.Descriptive & cmd_ts_dist_cjs_helpdoc_js0.Aliased>;
39
+ //#endregion
40
+ export { registryCommand };
41
+ //# sourceMappingURL=cli.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.mts","names":[],"sources":["../cli.ts"],"mappings":";;;;;cAiBa,eAAA,EAAe,OAAA,CA8F1B,6BAAA,CA9F0B,QAAA;iBAAA,6BAAA,CAAA,YAAA"}