@powerhousedao/registry 6.0.2-staging.2 → 6.0.2-staging.3

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 (38) hide show
  1. package/{dist/cdn-cache/@powerhousedao/vetra/6.0.0-dev.59/LICENSE → LICENSE} +1 -1
  2. package/README.md +152 -28
  3. package/dist/cli.d.mts +41 -0
  4. package/dist/cli.d.mts.map +1 -0
  5. package/dist/cli.mjs +898 -0
  6. package/dist/cli.mjs.map +1 -0
  7. package/package.json +16 -13
  8. package/static/favicon.ico +0 -0
  9. package/static/logo.svg +11 -0
  10. package/dist/bundle.d.ts +0 -2
  11. package/dist/bundle.d.ts.map +0 -1
  12. package/dist/cdn-cache/@powerhousedao/vetra/6.0.0-dev.59/package.json +0 -114
  13. package/dist/src/cdn.d.ts +0 -12
  14. package/dist/src/cdn.d.ts.map +0 -1
  15. package/dist/src/cli.d.ts +0 -32
  16. package/dist/src/cli.d.ts.map +0 -1
  17. package/dist/src/cli.js +0 -161040
  18. package/dist/src/constants.d.ts +0 -4
  19. package/dist/src/constants.d.ts.map +0 -1
  20. package/dist/src/index.d.ts +0 -6
  21. package/dist/src/index.d.ts.map +0 -1
  22. package/dist/src/index.js +0 -74
  23. package/dist/src/middleware.d.ts +0 -6
  24. package/dist/src/middleware.d.ts.map +0 -1
  25. package/dist/src/packages.d.ts +0 -5
  26. package/dist/src/packages.d.ts.map +0 -1
  27. package/dist/src/run.d.ts +0 -3
  28. package/dist/src/run.d.ts.map +0 -1
  29. package/dist/src/types.d.ts +0 -69
  30. package/dist/src/types.d.ts.map +0 -1
  31. package/dist/src/verdaccio-config.d.ts +0 -3
  32. package/dist/src/verdaccio-config.d.ts.map +0 -1
  33. package/dist/storage/@powerhousedao/vetra/package.json +0 -154
  34. package/dist/tests/e2e.test.d.ts +0 -2
  35. package/dist/tests/e2e.test.d.ts.map +0 -1
  36. package/dist/tsconfig.tsbuildinfo +0 -1
  37. package/dist/vitest.config.d.ts +0 -3
  38. package/dist/vitest.config.d.ts.map +0 -1
@@ -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,176 @@
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
19
26
 
20
- Arguments:
27
+ #### `GET /-/cdn/<packageName>/<filePath>`
21
28
 
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`)
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.
30
+
31
+ If the package is not published locally, Verdaccio transparently proxies metadata and tarballs from the configured upstream (`--uplink`, default `https://registry.npmjs.org/`). The CDN then extracts the upstream tarball into `cdn-cache/<pkg>/<version>/` exactly as it does for locally-published packages, so subsequent requests are served from the local cache without re-hitting the upstream. The same fallback applies to `@powerhousedao/*` packages: the registry prefers its local copy, and falls back to the upstream when the package isn't published locally.
32
+
33
+ ### Publish Notifications
34
+
35
+ When a package is published, the registry can notify subscribers in real time via Server-Sent Events (SSE) and webhooks.
36
+
37
+ #### SSE — `GET /-/events`
38
+
39
+ Opens a persistent SSE connection. The server sends:
40
+
41
+ - `connected` event on initial connection
42
+ - `publish` event whenever a package is published, with payload:
43
+
44
+ ```json
45
+ { "packageName": "@scope/pkg", "version": "1.0.0" }
46
+ ```
24
47
 
25
- ### Library
48
+ Example (browser):
26
49
 
27
50
  ```ts
28
- import express from "express";
29
- import { createRegistryRouter } from "@powerhousedao/registry";
51
+ const source = new EventSource("http://localhost:8080/-/events");
52
+ source.addEventListener("publish", (e) => {
53
+ const { packageName, version } = JSON.parse(e.data);
54
+ console.log(`${packageName}@${version} published`);
55
+ });
56
+ ```
57
+
58
+ #### Webhooks
59
+
60
+ Webhooks are persisted to disk and survive restarts. Predefined webhooks can also be provided via configuration.
61
+
62
+ ##### `GET /-/webhooks`
30
63
 
31
- const app = express();
32
- app.use(createRegistryRouter("./packages"));
33
- app.listen(3000);
64
+ Returns all registered webhooks (predefined + dynamic).
65
+
66
+ ##### `POST /-/webhooks`
67
+
68
+ Registers a new webhook. Body:
69
+
70
+ ```json
71
+ { "endpoint": "https://example.com/hook", "headers": { "X-Token": "secret" } }
34
72
  ```
35
73
 
36
- ## API
74
+ `headers` is optional. Returns `201` on success. Duplicate endpoints are ignored.
75
+
76
+ ##### `DELETE /-/webhooks`
77
+
78
+ Removes a dynamic webhook. Body:
79
+
80
+ ```json
81
+ { "endpoint": "https://example.com/hook" }
82
+ ```
83
+
84
+ Returns `204` on success, `404` if not found. Predefined webhooks cannot be removed.
85
+
86
+ When a package is published, each webhook receives a POST with:
87
+
88
+ ```json
89
+ { "packageName": "@scope/pkg", "version": "1.0.0" }
90
+ ```
37
91
 
38
- ### `createPowerhouseRouter(config)`
92
+ ### npm Protocol
39
93
 
40
- Creates an Express `Router` that serves packages.
94
+ All standard npm registry operations (publish, install, etc.) are handled by Verdaccio.
41
95
 
42
- ### `GET /packages`
96
+ ## Publishing Packages
43
97
 
44
- Returns a JSON array of all discovered packages.
98
+ ```sh
99
+ npm publish --registry http://localhost:8080/
100
+ ```
101
+
102
+ On publish, the CDN cache for that package is automatically invalidated and the new version is extracted immediately.
103
+
104
+ ## CLI
105
+
106
+ ```sh
107
+ ph-registry --port 8080 --storage-dir ./storage --cdn-cache-dir ./cdn-cache
108
+ ```
109
+
110
+ Options:
111
+
112
+ | Option | Env Variable | Default | Description |
113
+ | ------------------------ | ---------------------- | ----------------------------- | ------------------------------------------------- |
114
+ | `--port` | `PORT` | `8080` | Port to listen on |
115
+ | `--storage-dir` | `REGISTRY_STORAGE` | `./storage` | Verdaccio storage directory |
116
+ | `--cdn-cache-dir` | `REGISTRY_CDN_CACHE` | `./cdn-cache` | CDN cache directory |
117
+ | `--uplink` | `REGISTRY_UPLINK` | `https://registry.npmjs.org/` | Upstream npm registry URL used for fallback proxy |
118
+ | `--web-enabled` | `REGISTRY_WEB` | `true` | Enable Verdaccio web UI |
119
+ | `--webhook` | `REGISTRY_WEBHOOKS` | — | Comma-separated webhook URLs to notify on publish |
120
+ | `--s3-bucket` | `S3_BUCKET` | — | S3 bucket for storage |
121
+ | `--s3-endpoint` | `S3_ENDPOINT` | — | S3 endpoint URL |
122
+ | `--s3-region` | `S3_REGION` | — | S3 region |
123
+ | `--s3-access-key-id` | `S3_ACCESS_KEY_ID` | — | S3 access key |
124
+ | `--s3-secret-access-key` | `S3_SECRET_ACCESS_KEY` | — | S3 secret key |
125
+ | `--s3-key-prefix` | `S3_KEY_PREFIX` | — | S3 key prefix |
126
+ | `--s3-force-path-style` | `S3_FORCE_PATH_STYLE` | `true` | Force S3 path-style URLs |
127
+
128
+ ## Deployment
129
+
130
+ ### Build
131
+
132
+ ```sh
133
+ # Latest version
134
+ docker build -t ph-registry .
135
+
136
+ # Specific version
137
+ docker build --build-arg TAG=6.0.0-dev.112 -t ph-registry .
138
+ ```
139
+
140
+ The `TAG` build arg controls the npm version of `@powerhousedao/registry` to install (defaults to `latest`).
45
141
 
46
- ### `GET /packages/by-document-type?type=<documentType>`
142
+ ### Run
47
143
 
48
- Returns package names that contain the specified document type.
144
+ ```sh
145
+ docker run -p 4873:4873 -v ph-data:/data ph-registry
146
+ ```
147
+
148
+ #### Environment variables
149
+
150
+ Pass env variables with `-e`:
151
+
152
+ ```sh
153
+ docker run -p 4873:4873 -v ph-data:/data \
154
+ -e REGISTRY_UPLINK=https://registry.npmjs.org \
155
+ -e S3_BUCKET=my-bucket \
156
+ -e S3_REGION=us-east-1 \
157
+ ph-registry
158
+ ```
159
+
160
+ Or use an env file:
49
161
 
50
- ### `GET /-/cdn/<packageName>/<filePath>`
162
+ ```sh
163
+ docker run -p 4873:4873 -v ph-data:/data --env-file .env ph-registry
164
+ ```
165
+
166
+ See the [CLI](#cli) section for all supported environment variables.
167
+
168
+ #### CLI arguments
169
+
170
+ Since the image uses `ENTRYPOINT`, CLI args can be passed directly:
171
+
172
+ ```sh
173
+ docker run -p 8080:8080 -v ph-data:/data ph-registry --port 8080 --uplink https://registry.npmjs.org
174
+ ```
51
175
 
52
- Serves files from the CDN cache for a package.
176
+ CLI arguments take precedence over environment variables.
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"}