@enbox/gitd 0.0.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.
- package/LICENSE +177 -0
- package/README.md +134 -0
- package/dist/esm/ci.js +76 -0
- package/dist/esm/ci.js.map +1 -0
- package/dist/esm/cli/agent.js +86 -0
- package/dist/esm/cli/agent.js.map +1 -0
- package/dist/esm/cli/commands/ci.js +278 -0
- package/dist/esm/cli/commands/ci.js.map +1 -0
- package/dist/esm/cli/commands/clone.js +77 -0
- package/dist/esm/cli/commands/clone.js.map +1 -0
- package/dist/esm/cli/commands/daemon.js +132 -0
- package/dist/esm/cli/commands/daemon.js.map +1 -0
- package/dist/esm/cli/commands/github-api.js +36 -0
- package/dist/esm/cli/commands/github-api.js.map +1 -0
- package/dist/esm/cli/commands/init.js +69 -0
- package/dist/esm/cli/commands/init.js.map +1 -0
- package/dist/esm/cli/commands/issue.js +293 -0
- package/dist/esm/cli/commands/issue.js.map +1 -0
- package/dist/esm/cli/commands/log.js +90 -0
- package/dist/esm/cli/commands/log.js.map +1 -0
- package/dist/esm/cli/commands/migrate.js +444 -0
- package/dist/esm/cli/commands/migrate.js.map +1 -0
- package/dist/esm/cli/commands/notification.js +141 -0
- package/dist/esm/cli/commands/notification.js.map +1 -0
- package/dist/esm/cli/commands/org.js +353 -0
- package/dist/esm/cli/commands/org.js.map +1 -0
- package/dist/esm/cli/commands/patch.js +375 -0
- package/dist/esm/cli/commands/patch.js.map +1 -0
- package/dist/esm/cli/commands/registry.js +501 -0
- package/dist/esm/cli/commands/registry.js.map +1 -0
- package/dist/esm/cli/commands/release.js +197 -0
- package/dist/esm/cli/commands/release.js.map +1 -0
- package/dist/esm/cli/commands/repo.js +148 -0
- package/dist/esm/cli/commands/repo.js.map +1 -0
- package/dist/esm/cli/commands/serve.js +148 -0
- package/dist/esm/cli/commands/serve.js.map +1 -0
- package/dist/esm/cli/commands/setup.js +92 -0
- package/dist/esm/cli/commands/setup.js.map +1 -0
- package/dist/esm/cli/commands/shim.js +75 -0
- package/dist/esm/cli/commands/shim.js.map +1 -0
- package/dist/esm/cli/commands/social.js +206 -0
- package/dist/esm/cli/commands/social.js.map +1 -0
- package/dist/esm/cli/commands/web.js +36 -0
- package/dist/esm/cli/commands/web.js.map +1 -0
- package/dist/esm/cli/commands/wiki.js +185 -0
- package/dist/esm/cli/commands/wiki.js.map +1 -0
- package/dist/esm/cli/flags.js +29 -0
- package/dist/esm/cli/flags.js.map +1 -0
- package/dist/esm/cli/main.js +331 -0
- package/dist/esm/cli/main.js.map +1 -0
- package/dist/esm/cli/repo-context.js +53 -0
- package/dist/esm/cli/repo-context.js.map +1 -0
- package/dist/esm/daemon/adapter.js +18 -0
- package/dist/esm/daemon/adapter.js.map +1 -0
- package/dist/esm/daemon/adapters/github.js +112 -0
- package/dist/esm/daemon/adapters/github.js.map +1 -0
- package/dist/esm/daemon/adapters/go.js +51 -0
- package/dist/esm/daemon/adapters/go.js.map +1 -0
- package/dist/esm/daemon/adapters/index.js +32 -0
- package/dist/esm/daemon/adapters/index.js.map +1 -0
- package/dist/esm/daemon/adapters/npm.js +51 -0
- package/dist/esm/daemon/adapters/npm.js.map +1 -0
- package/dist/esm/daemon/adapters/oci.js +62 -0
- package/dist/esm/daemon/adapters/oci.js.map +1 -0
- package/dist/esm/daemon/index.js +12 -0
- package/dist/esm/daemon/index.js.map +1 -0
- package/dist/esm/daemon/server.js +167 -0
- package/dist/esm/daemon/server.js.map +1 -0
- package/dist/esm/git-remote/credential-helper.js +106 -0
- package/dist/esm/git-remote/credential-helper.js.map +1 -0
- package/dist/esm/git-remote/credential-main.js +109 -0
- package/dist/esm/git-remote/credential-main.js.map +1 -0
- package/dist/esm/git-remote/index.js +10 -0
- package/dist/esm/git-remote/index.js.map +1 -0
- package/dist/esm/git-remote/main.js +78 -0
- package/dist/esm/git-remote/main.js.map +1 -0
- package/dist/esm/git-remote/parse-url.js +60 -0
- package/dist/esm/git-remote/parse-url.js.map +1 -0
- package/dist/esm/git-remote/resolve.js +175 -0
- package/dist/esm/git-remote/resolve.js.map +1 -0
- package/dist/esm/git-remote/service.js +82 -0
- package/dist/esm/git-remote/service.js.map +1 -0
- package/dist/esm/git-server/auth.js +211 -0
- package/dist/esm/git-server/auth.js.map +1 -0
- package/dist/esm/git-server/bundle-restore.js +180 -0
- package/dist/esm/git-server/bundle-restore.js.map +1 -0
- package/dist/esm/git-server/bundle-sync.js +233 -0
- package/dist/esm/git-server/bundle-sync.js.map +1 -0
- package/dist/esm/git-server/did-service.js +73 -0
- package/dist/esm/git-server/did-service.js.map +1 -0
- package/dist/esm/git-server/git-backend.js +186 -0
- package/dist/esm/git-server/git-backend.js.map +1 -0
- package/dist/esm/git-server/http-handler.js +295 -0
- package/dist/esm/git-server/http-handler.js.map +1 -0
- package/dist/esm/git-server/index.js +16 -0
- package/dist/esm/git-server/index.js.map +1 -0
- package/dist/esm/git-server/push-authorizer.js +62 -0
- package/dist/esm/git-server/push-authorizer.js.map +1 -0
- package/dist/esm/git-server/ref-sync.js +132 -0
- package/dist/esm/git-server/ref-sync.js.map +1 -0
- package/dist/esm/git-server/server.js +185 -0
- package/dist/esm/git-server/server.js.map +1 -0
- package/dist/esm/git-server/verify.js +109 -0
- package/dist/esm/git-server/verify.js.map +1 -0
- package/dist/esm/github-shim/helpers.js +273 -0
- package/dist/esm/github-shim/helpers.js.map +1 -0
- package/dist/esm/github-shim/index.js +13 -0
- package/dist/esm/github-shim/index.js.map +1 -0
- package/dist/esm/github-shim/issues.js +318 -0
- package/dist/esm/github-shim/issues.js.map +1 -0
- package/dist/esm/github-shim/pulls.js +423 -0
- package/dist/esm/github-shim/pulls.js.map +1 -0
- package/dist/esm/github-shim/releases.js +154 -0
- package/dist/esm/github-shim/releases.js.map +1 -0
- package/dist/esm/github-shim/repos.js +86 -0
- package/dist/esm/github-shim/repos.js.map +1 -0
- package/dist/esm/github-shim/server.js +351 -0
- package/dist/esm/github-shim/server.js.map +1 -0
- package/dist/esm/github-shim/users.js +61 -0
- package/dist/esm/github-shim/users.js.map +1 -0
- package/dist/esm/index.js +26 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/indexer/api.js +132 -0
- package/dist/esm/indexer/api.js.map +1 -0
- package/dist/esm/indexer/crawler.js +256 -0
- package/dist/esm/indexer/crawler.js.map +1 -0
- package/dist/esm/indexer/index.js +9 -0
- package/dist/esm/indexer/index.js.map +1 -0
- package/dist/esm/indexer/main.js +76 -0
- package/dist/esm/indexer/main.js.map +1 -0
- package/dist/esm/indexer/store.js +334 -0
- package/dist/esm/indexer/store.js.map +1 -0
- package/dist/esm/issues.js +133 -0
- package/dist/esm/issues.js.map +1 -0
- package/dist/esm/notifications.js +47 -0
- package/dist/esm/notifications.js.map +1 -0
- package/dist/esm/org.js +90 -0
- package/dist/esm/org.js.map +1 -0
- package/dist/esm/patches.js +136 -0
- package/dist/esm/patches.js.map +1 -0
- package/dist/esm/refs.js +54 -0
- package/dist/esm/refs.js.map +1 -0
- package/dist/esm/registry.js +81 -0
- package/dist/esm/registry.js.map +1 -0
- package/dist/esm/releases.js +78 -0
- package/dist/esm/releases.js.map +1 -0
- package/dist/esm/repo.js +150 -0
- package/dist/esm/repo.js.map +1 -0
- package/dist/esm/resolver/index.js +10 -0
- package/dist/esm/resolver/index.js.map +1 -0
- package/dist/esm/resolver/resolve.js +189 -0
- package/dist/esm/resolver/resolve.js.map +1 -0
- package/dist/esm/resolver/trust-chain.js +155 -0
- package/dist/esm/resolver/trust-chain.js.map +1 -0
- package/dist/esm/resolver/verify.js +186 -0
- package/dist/esm/resolver/verify.js.map +1 -0
- package/dist/esm/shims/go/index.js +9 -0
- package/dist/esm/shims/go/index.js.map +1 -0
- package/dist/esm/shims/go/proxy.js +275 -0
- package/dist/esm/shims/go/proxy.js.map +1 -0
- package/dist/esm/shims/go/server.js +70 -0
- package/dist/esm/shims/go/server.js.map +1 -0
- package/dist/esm/shims/index.js +15 -0
- package/dist/esm/shims/index.js.map +1 -0
- package/dist/esm/shims/npm/index.js +9 -0
- package/dist/esm/shims/npm/index.js.map +1 -0
- package/dist/esm/shims/npm/registry.js +234 -0
- package/dist/esm/shims/npm/registry.js.map +1 -0
- package/dist/esm/shims/npm/server.js +72 -0
- package/dist/esm/shims/npm/server.js.map +1 -0
- package/dist/esm/shims/oci/index.js +9 -0
- package/dist/esm/shims/oci/index.js.map +1 -0
- package/dist/esm/shims/oci/registry.js +276 -0
- package/dist/esm/shims/oci/registry.js.map +1 -0
- package/dist/esm/shims/oci/server.js +82 -0
- package/dist/esm/shims/oci/server.js.map +1 -0
- package/dist/esm/social.js +70 -0
- package/dist/esm/social.js.map +1 -0
- package/dist/esm/web/html.js +123 -0
- package/dist/esm/web/html.js.map +1 -0
- package/dist/esm/web/index.js +7 -0
- package/dist/esm/web/index.js.map +1 -0
- package/dist/esm/web/routes.js +420 -0
- package/dist/esm/web/routes.js.map +1 -0
- package/dist/esm/web/server.js +225 -0
- package/dist/esm/web/server.js.map +1 -0
- package/dist/esm/wiki.js +63 -0
- package/dist/esm/wiki.js.map +1 -0
- package/dist/types/ci.d.ts +203 -0
- package/dist/types/ci.d.ts.map +1 -0
- package/dist/types/cli/agent.d.ts +59 -0
- package/dist/types/cli/agent.d.ts.map +1 -0
- package/dist/types/cli/commands/ci.d.ts +16 -0
- package/dist/types/cli/commands/ci.d.ts.map +1 -0
- package/dist/types/cli/commands/clone.d.ts +13 -0
- package/dist/types/cli/commands/clone.d.ts.map +1 -0
- package/dist/types/cli/commands/daemon.d.ts +29 -0
- package/dist/types/cli/commands/daemon.d.ts.map +1 -0
- package/dist/types/cli/commands/github-api.d.ts +14 -0
- package/dist/types/cli/commands/github-api.d.ts.map +1 -0
- package/dist/types/cli/commands/init.d.ts +11 -0
- package/dist/types/cli/commands/init.d.ts.map +1 -0
- package/dist/types/cli/commands/issue.d.ts +16 -0
- package/dist/types/cli/commands/issue.d.ts.map +1 -0
- package/dist/types/cli/commands/log.d.ts +13 -0
- package/dist/types/cli/commands/log.d.ts.map +1 -0
- package/dist/types/cli/commands/migrate.d.ts +19 -0
- package/dist/types/cli/commands/migrate.d.ts.map +1 -0
- package/dist/types/cli/commands/notification.d.ts +16 -0
- package/dist/types/cli/commands/notification.d.ts.map +1 -0
- package/dist/types/cli/commands/org.d.ts +19 -0
- package/dist/types/cli/commands/org.d.ts.map +1 -0
- package/dist/types/cli/commands/patch.d.ts +17 -0
- package/dist/types/cli/commands/patch.d.ts.map +1 -0
- package/dist/types/cli/commands/registry.d.ts +25 -0
- package/dist/types/cli/commands/registry.d.ts.map +1 -0
- package/dist/types/cli/commands/release.d.ts +13 -0
- package/dist/types/cli/commands/release.d.ts.map +1 -0
- package/dist/types/cli/commands/repo.d.ts +15 -0
- package/dist/types/cli/commands/repo.d.ts.map +1 -0
- package/dist/types/cli/commands/serve.d.ts +22 -0
- package/dist/types/cli/commands/serve.d.ts.map +1 -0
- package/dist/types/cli/commands/setup.d.ts +16 -0
- package/dist/types/cli/commands/setup.d.ts.map +1 -0
- package/dist/types/cli/commands/shim.d.ts +16 -0
- package/dist/types/cli/commands/shim.d.ts.map +1 -0
- package/dist/types/cli/commands/social.d.ts +19 -0
- package/dist/types/cli/commands/social.d.ts.map +1 -0
- package/dist/types/cli/commands/web.d.ts +14 -0
- package/dist/types/cli/commands/web.d.ts.map +1 -0
- package/dist/types/cli/commands/wiki.d.ts +14 -0
- package/dist/types/cli/commands/wiki.d.ts.map +1 -0
- package/dist/types/cli/flags.d.ts +16 -0
- package/dist/types/cli/flags.d.ts.map +1 -0
- package/dist/types/cli/main.d.ts +69 -0
- package/dist/types/cli/main.d.ts.map +1 -0
- package/dist/types/cli/repo-context.d.ts +30 -0
- package/dist/types/cli/repo-context.d.ts.map +1 -0
- package/dist/types/daemon/adapter.d.ts +74 -0
- package/dist/types/daemon/adapter.d.ts.map +1 -0
- package/dist/types/daemon/adapters/github.d.ts +10 -0
- package/dist/types/daemon/adapters/github.d.ts.map +1 -0
- package/dist/types/daemon/adapters/go.d.ts +10 -0
- package/dist/types/daemon/adapters/go.d.ts.map +1 -0
- package/dist/types/daemon/adapters/index.d.ts +22 -0
- package/dist/types/daemon/adapters/index.d.ts.map +1 -0
- package/dist/types/daemon/adapters/npm.d.ts +10 -0
- package/dist/types/daemon/adapters/npm.d.ts.map +1 -0
- package/dist/types/daemon/adapters/oci.d.ts +10 -0
- package/dist/types/daemon/adapters/oci.d.ts.map +1 -0
- package/dist/types/daemon/index.d.ts +14 -0
- package/dist/types/daemon/index.d.ts.map +1 -0
- package/dist/types/daemon/server.d.ts +55 -0
- package/dist/types/daemon/server.d.ts.map +1 -0
- package/dist/types/git-remote/credential-helper.d.ts +49 -0
- package/dist/types/git-remote/credential-helper.d.ts.map +1 -0
- package/dist/types/git-remote/credential-main.d.ts +24 -0
- package/dist/types/git-remote/credential-main.d.ts.map +1 -0
- package/dist/types/git-remote/index.d.ts +10 -0
- package/dist/types/git-remote/index.d.ts.map +1 -0
- package/dist/types/git-remote/main.d.ts +23 -0
- package/dist/types/git-remote/main.d.ts.map +1 -0
- package/dist/types/git-remote/parse-url.d.ts +32 -0
- package/dist/types/git-remote/parse-url.d.ts.map +1 -0
- package/dist/types/git-remote/resolve.d.ts +30 -0
- package/dist/types/git-remote/resolve.d.ts.map +1 -0
- package/dist/types/git-remote/service.d.ts +75 -0
- package/dist/types/git-remote/service.d.ts.map +1 -0
- package/dist/types/git-server/auth.d.ts +129 -0
- package/dist/types/git-server/auth.d.ts.map +1 -0
- package/dist/types/git-server/bundle-restore.d.ts +48 -0
- package/dist/types/git-server/bundle-restore.d.ts.map +1 -0
- package/dist/types/git-server/bundle-sync.d.ts +90 -0
- package/dist/types/git-server/bundle-sync.d.ts.map +1 -0
- package/dist/types/git-server/did-service.d.ts +26 -0
- package/dist/types/git-server/did-service.d.ts.map +1 -0
- package/dist/types/git-server/git-backend.d.ts +84 -0
- package/dist/types/git-server/git-backend.d.ts.map +1 -0
- package/dist/types/git-server/http-handler.d.ts +73 -0
- package/dist/types/git-server/http-handler.d.ts.map +1 -0
- package/dist/types/git-server/index.d.ts +16 -0
- package/dist/types/git-server/index.d.ts.map +1 -0
- package/dist/types/git-server/push-authorizer.d.ts +38 -0
- package/dist/types/git-server/push-authorizer.d.ts.map +1 -0
- package/dist/types/git-server/ref-sync.d.ts +52 -0
- package/dist/types/git-server/ref-sync.d.ts.map +1 -0
- package/dist/types/git-server/server.d.ts +70 -0
- package/dist/types/git-server/server.d.ts.map +1 -0
- package/dist/types/git-server/verify.d.ts +12 -0
- package/dist/types/git-server/verify.d.ts.map +1 -0
- package/dist/types/github-shim/helpers.d.ts +108 -0
- package/dist/types/github-shim/helpers.d.ts.map +1 -0
- package/dist/types/github-shim/index.d.ts +15 -0
- package/dist/types/github-shim/index.d.ts.map +1 -0
- package/dist/types/github-shim/issues.d.ts +24 -0
- package/dist/types/github-shim/issues.d.ts.map +1 -0
- package/dist/types/github-shim/pulls.d.ts +31 -0
- package/dist/types/github-shim/pulls.d.ts.map +1 -0
- package/dist/types/github-shim/releases.d.ts +18 -0
- package/dist/types/github-shim/releases.d.ts.map +1 -0
- package/dist/types/github-shim/repos.d.ts +21 -0
- package/dist/types/github-shim/repos.d.ts.map +1 -0
- package/dist/types/github-shim/server.d.ts +53 -0
- package/dist/types/github-shim/server.d.ts.map +1 -0
- package/dist/types/github-shim/users.d.ts +17 -0
- package/dist/types/github-shim/users.d.ts.map +1 -0
- package/dist/types/index.d.ts +26 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/indexer/api.d.ts +32 -0
- package/dist/types/indexer/api.d.ts.map +1 -0
- package/dist/types/indexer/crawler.d.ts +72 -0
- package/dist/types/indexer/crawler.d.ts.map +1 -0
- package/dist/types/indexer/index.d.ts +12 -0
- package/dist/types/indexer/index.d.ts.map +1 -0
- package/dist/types/indexer/main.d.ts +21 -0
- package/dist/types/indexer/main.d.ts.map +1 -0
- package/dist/types/indexer/store.d.ts +168 -0
- package/dist/types/indexer/store.d.ts.map +1 -0
- package/dist/types/issues.d.ts +395 -0
- package/dist/types/issues.d.ts.map +1 -0
- package/dist/types/notifications.d.ts +93 -0
- package/dist/types/notifications.d.ts.map +1 -0
- package/dist/types/org.d.ts +232 -0
- package/dist/types/org.d.ts.map +1 -0
- package/dist/types/patches.d.ts +410 -0
- package/dist/types/patches.d.ts.map +1 -0
- package/dist/types/refs.d.ts +114 -0
- package/dist/types/refs.d.ts.map +1 -0
- package/dist/types/registry.d.ts +212 -0
- package/dist/types/registry.d.ts.map +1 -0
- package/dist/types/releases.d.ts +204 -0
- package/dist/types/releases.d.ts.map +1 -0
- package/dist/types/repo.d.ts +450 -0
- package/dist/types/repo.d.ts.map +1 -0
- package/dist/types/resolver/index.d.ts +13 -0
- package/dist/types/resolver/index.d.ts.map +1 -0
- package/dist/types/resolver/resolve.d.ts +80 -0
- package/dist/types/resolver/resolve.d.ts.map +1 -0
- package/dist/types/resolver/trust-chain.d.ts +54 -0
- package/dist/types/resolver/trust-chain.d.ts.map +1 -0
- package/dist/types/resolver/verify.d.ts +62 -0
- package/dist/types/resolver/verify.d.ts.map +1 -0
- package/dist/types/shims/go/index.d.ts +11 -0
- package/dist/types/shims/go/index.d.ts.map +1 -0
- package/dist/types/shims/go/proxy.d.ts +51 -0
- package/dist/types/shims/go/proxy.d.ts.map +1 -0
- package/dist/types/shims/go/server.d.ts +23 -0
- package/dist/types/shims/go/server.d.ts.map +1 -0
- package/dist/types/shims/index.d.ts +18 -0
- package/dist/types/shims/index.d.ts.map +1 -0
- package/dist/types/shims/npm/index.d.ts +11 -0
- package/dist/types/shims/npm/index.d.ts.map +1 -0
- package/dist/types/shims/npm/registry.d.ts +46 -0
- package/dist/types/shims/npm/registry.d.ts.map +1 -0
- package/dist/types/shims/npm/server.d.ts +23 -0
- package/dist/types/shims/npm/server.d.ts.map +1 -0
- package/dist/types/shims/oci/index.d.ts +11 -0
- package/dist/types/shims/oci/index.d.ts.map +1 -0
- package/dist/types/shims/oci/registry.d.ts +56 -0
- package/dist/types/shims/oci/registry.d.ts.map +1 -0
- package/dist/types/shims/oci/server.d.ts +23 -0
- package/dist/types/shims/oci/server.d.ts.map +1 -0
- package/dist/types/social.d.ts +162 -0
- package/dist/types/social.d.ts.map +1 -0
- package/dist/types/web/html.d.ts +23 -0
- package/dist/types/web/html.d.ts.map +1 -0
- package/dist/types/web/index.d.ts +8 -0
- package/dist/types/web/index.d.ts.map +1 -0
- package/dist/types/web/routes.d.ts +21 -0
- package/dist/types/web/routes.d.ts.map +1 -0
- package/dist/types/web/server.d.ts +38 -0
- package/dist/types/web/server.d.ts.map +1 -0
- package/dist/types/wiki.d.ts +143 -0
- package/dist/types/wiki.d.ts.map +1 -0
- package/package.json +108 -0
- package/schemas/ci/check-run.json +23 -0
- package/schemas/ci/check-suite.json +23 -0
- package/schemas/issues/assignment.json +17 -0
- package/schemas/issues/comment.json +14 -0
- package/schemas/issues/issue.json +20 -0
- package/schemas/issues/label.json +17 -0
- package/schemas/issues/reaction.json +14 -0
- package/schemas/issues/status-change.json +14 -0
- package/schemas/notifications/notification.json +20 -0
- package/schemas/org/org-member.json +17 -0
- package/schemas/org/org.json +26 -0
- package/schemas/org/team-member.json +17 -0
- package/schemas/org/team.json +17 -0
- package/schemas/patches/merge-result.json +14 -0
- package/schemas/patches/patch-status-change.json +14 -0
- package/schemas/patches/patch.json +20 -0
- package/schemas/patches/review-comment.json +17 -0
- package/schemas/patches/review.json +14 -0
- package/schemas/patches/revision.json +30 -0
- package/schemas/refs/git-ref.json +32 -0
- package/schemas/registry/attestation.json +23 -0
- package/schemas/registry/package-version.json +23 -0
- package/schemas/registry/package.json +32 -0
- package/schemas/releases/release.json +17 -0
- package/schemas/repo/collaborator.json +17 -0
- package/schemas/repo/repo.json +35 -0
- package/schemas/repo/settings.json +39 -0
- package/schemas/repo/topic.json +14 -0
- package/schemas/repo/webhook.json +26 -0
- package/schemas/social/activity.json +23 -0
- package/schemas/social/follow.json +17 -0
- package/schemas/social/star.json +20 -0
- package/schemas/wiki/wiki-history.json +20 -0
- package/schemas/wiki/wiki-page.json +17 -0
- package/src/ci.ts +118 -0
- package/src/cli/agent.ts +117 -0
- package/src/cli/commands/ci.ts +300 -0
- package/src/cli/commands/clone.ts +78 -0
- package/src/cli/commands/daemon.ts +129 -0
- package/src/cli/commands/github-api.ts +30 -0
- package/src/cli/commands/init.ts +69 -0
- package/src/cli/commands/issue.ts +321 -0
- package/src/cli/commands/log.ts +106 -0
- package/src/cli/commands/migrate.ts +525 -0
- package/src/cli/commands/notification.ts +148 -0
- package/src/cli/commands/org.ts +381 -0
- package/src/cli/commands/patch.ts +413 -0
- package/src/cli/commands/registry.ts +542 -0
- package/src/cli/commands/release.ts +189 -0
- package/src/cli/commands/repo.ts +160 -0
- package/src/cli/commands/serve.ts +153 -0
- package/src/cli/commands/setup.ts +97 -0
- package/src/cli/commands/shim.ts +79 -0
- package/src/cli/commands/social.ts +221 -0
- package/src/cli/commands/web.ts +30 -0
- package/src/cli/commands/wiki.ts +199 -0
- package/src/cli/flags.ts +28 -0
- package/src/cli/main.ts +350 -0
- package/src/cli/repo-context.ts +55 -0
- package/src/daemon/adapter.ts +95 -0
- package/src/daemon/adapters/github.ts +86 -0
- package/src/daemon/adapters/go.ts +47 -0
- package/src/daemon/adapters/index.ts +36 -0
- package/src/daemon/adapters/npm.ts +47 -0
- package/src/daemon/adapters/oci.ts +59 -0
- package/src/daemon/index.ts +16 -0
- package/src/daemon/server.ts +204 -0
- package/src/git-remote/credential-helper.ts +114 -0
- package/src/git-remote/credential-main.ts +118 -0
- package/src/git-remote/index.ts +10 -0
- package/src/git-remote/main.ts +74 -0
- package/src/git-remote/parse-url.ts +81 -0
- package/src/git-remote/resolve.ts +207 -0
- package/src/git-remote/service.ts +126 -0
- package/src/git-server/auth.ts +308 -0
- package/src/git-server/bundle-restore.ts +217 -0
- package/src/git-server/bundle-sync.ts +300 -0
- package/src/git-server/did-service.ts +77 -0
- package/src/git-server/git-backend.ts +222 -0
- package/src/git-server/http-handler.ts +386 -0
- package/src/git-server/index.ts +16 -0
- package/src/git-server/push-authorizer.ts +77 -0
- package/src/git-server/ref-sync.ts +166 -0
- package/src/git-server/server.ts +236 -0
- package/src/git-server/verify.ts +116 -0
- package/src/github-shim/helpers.ts +311 -0
- package/src/github-shim/index.ts +35 -0
- package/src/github-shim/issues.ts +389 -0
- package/src/github-shim/pulls.ts +500 -0
- package/src/github-shim/releases.ts +185 -0
- package/src/github-shim/repos.ts +95 -0
- package/src/github-shim/server.ts +334 -0
- package/src/github-shim/users.ts +63 -0
- package/src/index.ts +26 -0
- package/src/indexer/api.ts +162 -0
- package/src/indexer/crawler.ts +290 -0
- package/src/indexer/index.ts +22 -0
- package/src/indexer/main.ts +83 -0
- package/src/indexer/store.ts +408 -0
- package/src/issues.ts +200 -0
- package/src/notifications.ts +80 -0
- package/src/org.ts +147 -0
- package/src/patches.ts +203 -0
- package/src/refs.ts +94 -0
- package/src/registry.ts +132 -0
- package/src/releases.ts +124 -0
- package/src/repo.ts +234 -0
- package/src/resolver/index.ts +42 -0
- package/src/resolver/resolve.ts +244 -0
- package/src/resolver/trust-chain.ts +217 -0
- package/src/resolver/verify.ts +237 -0
- package/src/shims/go/index.ts +14 -0
- package/src/shims/go/proxy.ts +336 -0
- package/src/shims/go/server.ts +82 -0
- package/src/shims/index.ts +20 -0
- package/src/shims/npm/index.ts +14 -0
- package/src/shims/npm/registry.ts +288 -0
- package/src/shims/npm/server.ts +84 -0
- package/src/shims/oci/index.ts +14 -0
- package/src/shims/oci/registry.ts +334 -0
- package/src/shims/oci/server.ts +94 -0
- package/src/social.ts +116 -0
- package/src/web/html.ts +120 -0
- package/src/web/index.ts +8 -0
- package/src/web/routes.ts +449 -0
- package/src/web/server.ts +256 -0
- package/src/wiki.ts +102 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub API shim — `/repos/:did/:repo` endpoint.
|
|
3
|
+
*
|
|
4
|
+
* Maps the DWN singleton repo record to a GitHub REST API v3
|
|
5
|
+
* repository response. The `:repo` segment is validated against the
|
|
6
|
+
* stored repo name but is otherwise informational — repos are singletons
|
|
7
|
+
* per DID in gitd.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { AgentContext } from '../cli/agent.js';
|
|
13
|
+
import type { JsonResponse, RepoInfo } from './helpers.js';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
buildApiUrl,
|
|
17
|
+
buildOwner,
|
|
18
|
+
getRepoRecord,
|
|
19
|
+
jsonNotFound,
|
|
20
|
+
jsonOk,
|
|
21
|
+
numericId,
|
|
22
|
+
toISODate,
|
|
23
|
+
} from './helpers.js';
|
|
24
|
+
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// GET /repos/:did/:repo
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
/** Build a GitHub-style repository object from DWN data. */
|
|
30
|
+
export function buildRepoResponse(
|
|
31
|
+
repo: RepoInfo, targetDid: string, repoName: string, baseUrl: string,
|
|
32
|
+
): Record<string, unknown> {
|
|
33
|
+
const owner = buildOwner(targetDid, baseUrl);
|
|
34
|
+
const fullName = `${targetDid}/${repoName}`;
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
id : numericId(repo.contextId || `${targetDid}/repo`),
|
|
38
|
+
node_id : repo.contextId || '',
|
|
39
|
+
name : repoName,
|
|
40
|
+
full_name : fullName,
|
|
41
|
+
private : repo.visibility !== 'public',
|
|
42
|
+
owner,
|
|
43
|
+
html_url : `${baseUrl}/repos/${fullName}`,
|
|
44
|
+
description : repo.description || null,
|
|
45
|
+
fork : false,
|
|
46
|
+
url : `${baseUrl}/repos/${fullName}`,
|
|
47
|
+
archive_url : `${baseUrl}/repos/${fullName}/{archive_format}{/ref}`,
|
|
48
|
+
issues_url : `${baseUrl}/repos/${fullName}/issues{/number}`,
|
|
49
|
+
pulls_url : `${baseUrl}/repos/${fullName}/pulls{/number}`,
|
|
50
|
+
releases_url : `${baseUrl}/repos/${fullName}/releases{/id}`,
|
|
51
|
+
created_at : toISODate(repo.dateCreated),
|
|
52
|
+
updated_at : toISODate(repo.timestamp),
|
|
53
|
+
pushed_at : toISODate(repo.timestamp),
|
|
54
|
+
git_url : `did://${targetDid}/${repoName}.git`,
|
|
55
|
+
clone_url : `did://${targetDid}/${repoName}.git`,
|
|
56
|
+
default_branch : repo.defaultBranch,
|
|
57
|
+
visibility : repo.visibility,
|
|
58
|
+
// Counts — zero unless enriched by an indexer.
|
|
59
|
+
stargazers_count : 0,
|
|
60
|
+
watchers_count : 0,
|
|
61
|
+
forks_count : 0,
|
|
62
|
+
open_issues_count : 0,
|
|
63
|
+
// Standard GitHub fields with sensible defaults.
|
|
64
|
+
language : null,
|
|
65
|
+
has_issues : true,
|
|
66
|
+
has_projects : false,
|
|
67
|
+
has_wiki : true,
|
|
68
|
+
has_pages : false,
|
|
69
|
+
has_downloads : true,
|
|
70
|
+
archived : false,
|
|
71
|
+
disabled : false,
|
|
72
|
+
license : null,
|
|
73
|
+
topics : [],
|
|
74
|
+
forks : 0,
|
|
75
|
+
watchers : 0,
|
|
76
|
+
size : 0,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Handle `GET /repos/:did/:repo`.
|
|
82
|
+
*
|
|
83
|
+
* Returns a GitHub-style repository JSON response.
|
|
84
|
+
*/
|
|
85
|
+
export async function handleGetRepo(
|
|
86
|
+
ctx: AgentContext, targetDid: string, repoName: string, url: URL,
|
|
87
|
+
): Promise<JsonResponse> {
|
|
88
|
+
const repo = await getRepoRecord(ctx, targetDid);
|
|
89
|
+
if (!repo) {
|
|
90
|
+
return jsonNotFound(`Repository '${repoName}' not found for DID '${targetDid}'.`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const baseUrl = buildApiUrl(url);
|
|
94
|
+
return jsonOk(buildRepoResponse(repo, targetDid, repo.name, baseUrl));
|
|
95
|
+
}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub API compatibility shim — HTTP server and router.
|
|
3
|
+
*
|
|
4
|
+
* Translates GitHub REST API v3 requests into DWN queries / writes and
|
|
5
|
+
* returns GitHub-compatible JSON responses. This allows existing tools
|
|
6
|
+
* that speak the GitHub API (VS Code extensions, `gh` CLI, CI/CD
|
|
7
|
+
* systems) to interact with any DWN-enabled git forge.
|
|
8
|
+
*
|
|
9
|
+
* Read endpoints (GET):
|
|
10
|
+
* GET /repos/:did/:repo Repository info
|
|
11
|
+
* GET /repos/:did/:repo/issues List issues
|
|
12
|
+
* GET /repos/:did/:repo/issues/:number Issue detail
|
|
13
|
+
* GET /repos/:did/:repo/issues/:number/comments Issue comments
|
|
14
|
+
* GET /repos/:did/:repo/pulls List pull requests
|
|
15
|
+
* GET /repos/:did/:repo/pulls/:number Pull request detail
|
|
16
|
+
* GET /repos/:did/:repo/pulls/:number/reviews Pull request reviews
|
|
17
|
+
* GET /repos/:did/:repo/releases List releases
|
|
18
|
+
* GET /repos/:did/:repo/releases/tags/:tag Release by tag
|
|
19
|
+
* GET /users/:did User profile
|
|
20
|
+
*
|
|
21
|
+
* Write endpoints (POST/PATCH/PUT):
|
|
22
|
+
* POST /repos/:did/:repo/issues Create issue
|
|
23
|
+
* PATCH /repos/:did/:repo/issues/:number Update issue
|
|
24
|
+
* POST /repos/:did/:repo/issues/:number/comments Create issue comment
|
|
25
|
+
* POST /repos/:did/:repo/pulls Create pull request
|
|
26
|
+
* PATCH /repos/:did/:repo/pulls/:number Update pull request
|
|
27
|
+
* PUT /repos/:did/:repo/pulls/:number/merge Merge pull request
|
|
28
|
+
* POST /repos/:did/:repo/pulls/:number/reviews Create pull review
|
|
29
|
+
* POST /repos/:did/:repo/releases Create release
|
|
30
|
+
*
|
|
31
|
+
* @module
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import type { AgentContext } from '../cli/agent.js';
|
|
35
|
+
import type { JsonResponse } from './helpers.js';
|
|
36
|
+
|
|
37
|
+
import type { Server } from 'node:http';
|
|
38
|
+
|
|
39
|
+
import { createServer } from 'node:http';
|
|
40
|
+
|
|
41
|
+
import { handleGetRepo } from './repos.js';
|
|
42
|
+
import { handleGetUser } from './users.js';
|
|
43
|
+
|
|
44
|
+
import { baseHeaders, jsonMethodNotAllowed, jsonNotFound, jsonUnauthorized, validateBearerToken } from './helpers.js';
|
|
45
|
+
import { handleCreateIssue, handleCreateIssueComment, handleGetIssue, handleListIssueComments, handleListIssues, handleUpdateIssue } from './issues.js';
|
|
46
|
+
import { handleCreatePull, handleCreatePullReview, handleGetPull, handleListPullReviews, handleListPulls, handleMergePull, handleUpdatePull } from './pulls.js';
|
|
47
|
+
import { handleCreateRelease, handleGetReleaseByTag, handleListReleases } from './releases.js';
|
|
48
|
+
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Types
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
export type ShimServerOptions = {
|
|
54
|
+
ctx : AgentContext;
|
|
55
|
+
port : number;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Supported HTTP methods
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
|
|
62
|
+
const ALLOWED_METHODS = new Set(['GET', 'POST', 'PATCH', 'PUT', 'DELETE', 'OPTIONS']);
|
|
63
|
+
|
|
64
|
+
/** Maximum JSON request body size (1 MB). */
|
|
65
|
+
const MAX_JSON_BODY = 1 * 1024 * 1024;
|
|
66
|
+
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// DID extraction regex
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* DID methods use the pattern `did:<method>:<id>`. We capture the full
|
|
73
|
+
* DID and the remaining path segments.
|
|
74
|
+
*/
|
|
75
|
+
const REPOS_RE = /^\/repos\/(did:[a-z0-9]+:[a-zA-Z0-9._:%-]+)\/([^/]+)(\/.*)?$/;
|
|
76
|
+
const USERS_RE = /^\/users\/(did:[a-z0-9]+:[a-zA-Z0-9._:%-]+)$/;
|
|
77
|
+
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
// Router
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Route an incoming request to the appropriate handler.
|
|
84
|
+
*
|
|
85
|
+
* This function is exported for testing — tests can call it directly
|
|
86
|
+
* with a constructed URL without starting an HTTP server.
|
|
87
|
+
*
|
|
88
|
+
* @param method HTTP method (defaults to `'GET'` for backward compat).
|
|
89
|
+
* @param reqBody Parsed JSON body for POST/PATCH/PUT requests.
|
|
90
|
+
* @param authHeader The Authorization header value (for write endpoint auth).
|
|
91
|
+
*/
|
|
92
|
+
export async function handleShimRequest(
|
|
93
|
+
ctx: AgentContext,
|
|
94
|
+
url: URL,
|
|
95
|
+
method: string = 'GET',
|
|
96
|
+
reqBody: Record<string, unknown> = {},
|
|
97
|
+
authHeader: string | null = null,
|
|
98
|
+
): Promise<JsonResponse> {
|
|
99
|
+
// Authenticate mutating requests when GITD_API_TOKEN is configured.
|
|
100
|
+
if (method === 'POST' || method === 'PATCH' || method === 'PUT' || method === 'DELETE') {
|
|
101
|
+
if (!validateBearerToken(authHeader)) {
|
|
102
|
+
return jsonUnauthorized('Valid Bearer token required for write operations.');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const path = url.pathname;
|
|
106
|
+
|
|
107
|
+
// -------------------------------------------------------------------------
|
|
108
|
+
// GET /users/:did
|
|
109
|
+
// -------------------------------------------------------------------------
|
|
110
|
+
const userMatch = path.match(USERS_RE);
|
|
111
|
+
if (userMatch) {
|
|
112
|
+
if (method !== 'GET') {
|
|
113
|
+
return jsonMethodNotAllowed(`${method} is not allowed on /users endpoints.`);
|
|
114
|
+
}
|
|
115
|
+
return handleGetUser(userMatch[1], url);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// -------------------------------------------------------------------------
|
|
119
|
+
// /repos/:did/:repo/...
|
|
120
|
+
// -------------------------------------------------------------------------
|
|
121
|
+
const repoMatch = path.match(REPOS_RE);
|
|
122
|
+
if (!repoMatch) {
|
|
123
|
+
return jsonNotFound('Not found');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const targetDid = repoMatch[1];
|
|
127
|
+
const repoName = repoMatch[2];
|
|
128
|
+
const rest = repoMatch[3] ?? '';
|
|
129
|
+
|
|
130
|
+
// Try/catch — DID resolution failures should return 502.
|
|
131
|
+
try {
|
|
132
|
+
return await dispatchRepoRoute(ctx, targetDid, repoName, rest, url, method, reqBody);
|
|
133
|
+
} catch (err) {
|
|
134
|
+
const msg = (err as Error).message ?? 'Unknown error';
|
|
135
|
+
return {
|
|
136
|
+
status : 502,
|
|
137
|
+
headers : baseHeaders(),
|
|
138
|
+
body : JSON.stringify({ message: `DWN error: ${msg}` }),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Dispatch to the correct handler within the `/repos/:did/:repo/...`
|
|
145
|
+
* namespace. Considers both the URL path and the HTTP method.
|
|
146
|
+
*/
|
|
147
|
+
async function dispatchRepoRoute(
|
|
148
|
+
ctx: AgentContext, targetDid: string, repoName: string,
|
|
149
|
+
rest: string, url: URL, method: string, reqBody: Record<string, unknown>,
|
|
150
|
+
): Promise<JsonResponse> {
|
|
151
|
+
// GET /repos/:did/:repo
|
|
152
|
+
if (rest === '' || rest === '/') {
|
|
153
|
+
if (method !== 'GET') { return jsonMethodNotAllowed(`${method} not allowed on /repos/:did/:repo.`); }
|
|
154
|
+
return handleGetRepo(ctx, targetDid, repoName, url);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// /repos/:did/:repo/issues[/...]
|
|
158
|
+
if (rest === '/issues') {
|
|
159
|
+
if (method === 'POST') { return handleCreateIssue(ctx, targetDid, repoName, reqBody, url); }
|
|
160
|
+
if (method === 'GET') { return handleListIssues(ctx, targetDid, repoName, url); }
|
|
161
|
+
return jsonMethodNotAllowed(`${method} not allowed on /issues.`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// /repos/:did/:repo/pulls[/...]
|
|
165
|
+
if (rest === '/pulls') {
|
|
166
|
+
if (method === 'POST') { return handleCreatePull(ctx, targetDid, repoName, reqBody, url); }
|
|
167
|
+
if (method === 'GET') { return handleListPulls(ctx, targetDid, repoName, url); }
|
|
168
|
+
return jsonMethodNotAllowed(`${method} not allowed on /pulls.`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// /repos/:did/:repo/releases
|
|
172
|
+
if (rest === '/releases') {
|
|
173
|
+
if (method === 'POST') { return handleCreateRelease(ctx, targetDid, repoName, reqBody, url); }
|
|
174
|
+
if (method === 'GET') { return handleListReleases(ctx, targetDid, repoName, url); }
|
|
175
|
+
return jsonMethodNotAllowed(`${method} not allowed on /releases.`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// GET /repos/:did/:repo/releases/tags/:tag
|
|
179
|
+
const releaseTagMatch = rest.match(/^\/releases\/tags\/(.+)$/);
|
|
180
|
+
if (releaseTagMatch) {
|
|
181
|
+
if (method !== 'GET') { return jsonMethodNotAllowed(`${method} not allowed on /releases/tags/:tag.`); }
|
|
182
|
+
return handleGetReleaseByTag(ctx, targetDid, repoName, releaseTagMatch[1], url);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// /repos/:did/:repo/issues/:number/comments
|
|
186
|
+
const issueCommentsMatch = rest.match(/^\/issues\/(\d+)\/comments$/);
|
|
187
|
+
if (issueCommentsMatch) {
|
|
188
|
+
if (method === 'POST') { return handleCreateIssueComment(ctx, targetDid, repoName, issueCommentsMatch[1], reqBody, url); }
|
|
189
|
+
if (method === 'GET') { return handleListIssueComments(ctx, targetDid, repoName, issueCommentsMatch[1], url); }
|
|
190
|
+
return jsonMethodNotAllowed(`${method} not allowed on /issues/:number/comments.`);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// /repos/:did/:repo/issues/:number
|
|
194
|
+
const issueMatch = rest.match(/^\/issues\/(\d+)$/);
|
|
195
|
+
if (issueMatch) {
|
|
196
|
+
if (method === 'PATCH') { return handleUpdateIssue(ctx, targetDid, repoName, issueMatch[1], reqBody, url); }
|
|
197
|
+
if (method === 'GET') { return handleGetIssue(ctx, targetDid, repoName, issueMatch[1], url); }
|
|
198
|
+
return jsonMethodNotAllowed(`${method} not allowed on /issues/:number.`);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// /repos/:did/:repo/pulls/:number/merge
|
|
202
|
+
const pullMergeMatch = rest.match(/^\/pulls\/(\d+)\/merge$/);
|
|
203
|
+
if (pullMergeMatch) {
|
|
204
|
+
if (method === 'PUT') { return handleMergePull(ctx, targetDid, repoName, pullMergeMatch[1], reqBody, url); }
|
|
205
|
+
return jsonMethodNotAllowed(`${method} not allowed on /pulls/:number/merge.`);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// /repos/:did/:repo/pulls/:number/reviews
|
|
209
|
+
const pullReviewsMatch = rest.match(/^\/pulls\/(\d+)\/reviews$/);
|
|
210
|
+
if (pullReviewsMatch) {
|
|
211
|
+
if (method === 'POST') { return handleCreatePullReview(ctx, targetDid, repoName, pullReviewsMatch[1], reqBody, url); }
|
|
212
|
+
if (method === 'GET') { return handleListPullReviews(ctx, targetDid, repoName, pullReviewsMatch[1], url); }
|
|
213
|
+
return jsonMethodNotAllowed(`${method} not allowed on /pulls/:number/reviews.`);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// /repos/:did/:repo/pulls/:number
|
|
217
|
+
const pullMatch = rest.match(/^\/pulls\/(\d+)$/);
|
|
218
|
+
if (pullMatch) {
|
|
219
|
+
if (method === 'PATCH') { return handleUpdatePull(ctx, targetDid, repoName, pullMatch[1], reqBody, url); }
|
|
220
|
+
if (method === 'GET') { return handleGetPull(ctx, targetDid, repoName, pullMatch[1], url); }
|
|
221
|
+
return jsonMethodNotAllowed(`${method} not allowed on /pulls/:number.`);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return jsonNotFound('Not found');
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// ---------------------------------------------------------------------------
|
|
228
|
+
// Server
|
|
229
|
+
// ---------------------------------------------------------------------------
|
|
230
|
+
|
|
231
|
+
/** Start the GitHub API shim server. Returns the server instance. */
|
|
232
|
+
export function startShimServer(options: ShimServerOptions): Server {
|
|
233
|
+
const { ctx, port } = options;
|
|
234
|
+
|
|
235
|
+
const server = createServer(async (req, res) => {
|
|
236
|
+
const method = req.method ?? 'GET';
|
|
237
|
+
|
|
238
|
+
// Health check endpoint.
|
|
239
|
+
if (req.url === '/health') {
|
|
240
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
241
|
+
res.end(JSON.stringify({ status: 'ok', service: 'github-api' }));
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Handle CORS preflight.
|
|
246
|
+
if (method === 'OPTIONS') {
|
|
247
|
+
res.writeHead(204, {
|
|
248
|
+
'Access-Control-Allow-Origin' : '*',
|
|
249
|
+
'Access-Control-Allow-Methods' : 'GET, POST, PATCH, PUT, DELETE, OPTIONS',
|
|
250
|
+
'Access-Control-Allow-Headers' : 'Authorization, Accept, Content-Type',
|
|
251
|
+
'Access-Control-Max-Age' : '86400',
|
|
252
|
+
});
|
|
253
|
+
res.end();
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Reject unsupported methods.
|
|
258
|
+
if (!ALLOWED_METHODS.has(method)) {
|
|
259
|
+
res.writeHead(405, baseHeaders());
|
|
260
|
+
res.end(JSON.stringify({ message: `Method ${method} is not supported.` }));
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
try {
|
|
265
|
+
const url = new URL(req.url ?? '/', `http://localhost:${port}`);
|
|
266
|
+
|
|
267
|
+
// Parse request body for mutating methods (with size limit).
|
|
268
|
+
let reqBody: Record<string, unknown> = {};
|
|
269
|
+
if (method === 'POST' || method === 'PATCH' || method === 'PUT') {
|
|
270
|
+
const chunks: Buffer[] = [];
|
|
271
|
+
let totalSize = 0;
|
|
272
|
+
let tooLarge = false;
|
|
273
|
+
for await (const chunk of req) {
|
|
274
|
+
const buf = typeof chunk === 'string' ? Buffer.from(chunk) : chunk;
|
|
275
|
+
totalSize += buf.length;
|
|
276
|
+
if (totalSize > MAX_JSON_BODY) { tooLarge = true; break; }
|
|
277
|
+
chunks.push(buf);
|
|
278
|
+
}
|
|
279
|
+
if (tooLarge) {
|
|
280
|
+
res.writeHead(413, baseHeaders());
|
|
281
|
+
res.end(JSON.stringify({ message: 'Payload Too Large' }));
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const raw = Buffer.concat(chunks).toString('utf-8');
|
|
285
|
+
if (raw.length > 0) {
|
|
286
|
+
try {
|
|
287
|
+
reqBody = JSON.parse(raw);
|
|
288
|
+
} catch {
|
|
289
|
+
res.writeHead(400, baseHeaders());
|
|
290
|
+
res.end(JSON.stringify({ message: 'Invalid JSON in request body.' }));
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const authHeader = req.headers.authorization ?? null;
|
|
297
|
+
const result = await handleShimRequest(ctx, url, method, reqBody, authHeader);
|
|
298
|
+
|
|
299
|
+
res.writeHead(result.status, result.headers);
|
|
300
|
+
res.end(result.body);
|
|
301
|
+
} catch (err) {
|
|
302
|
+
console.error(`[github-shim] Error: ${(err as Error).message}`);
|
|
303
|
+
res.writeHead(500, baseHeaders());
|
|
304
|
+
res.end(JSON.stringify({ message: 'Internal server error' }));
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
server.listen(port, () => {
|
|
309
|
+
console.log(`[github-shim] GitHub API compatibility shim running at http://localhost:${port}`);
|
|
310
|
+
console.log('[github-shim] Read endpoints (GET):');
|
|
311
|
+
console.log(' GET /repos/:did/:repo Repository info');
|
|
312
|
+
console.log(' GET /repos/:did/:repo/issues List issues');
|
|
313
|
+
console.log(' GET /repos/:did/:repo/issues/:number Issue detail');
|
|
314
|
+
console.log(' GET /repos/:did/:repo/issues/:n/comments Issue comments');
|
|
315
|
+
console.log(' GET /repos/:did/:repo/pulls List pull requests');
|
|
316
|
+
console.log(' GET /repos/:did/:repo/pulls/:number Pull request detail');
|
|
317
|
+
console.log(' GET /repos/:did/:repo/pulls/:n/reviews Pull request reviews');
|
|
318
|
+
console.log(' GET /repos/:did/:repo/releases List releases');
|
|
319
|
+
console.log(' GET /repos/:did/:repo/releases/tags/:t Release by tag');
|
|
320
|
+
console.log(' GET /users/:did User profile');
|
|
321
|
+
console.log('[github-shim] Write endpoints (POST/PATCH/PUT):');
|
|
322
|
+
console.log(' POST /repos/:did/:repo/issues Create issue');
|
|
323
|
+
console.log(' PATCH /repos/:did/:repo/issues/:number Update issue');
|
|
324
|
+
console.log(' POST /repos/:did/:repo/issues/:n/comments Create comment');
|
|
325
|
+
console.log(' POST /repos/:did/:repo/pulls Create pull request');
|
|
326
|
+
console.log(' PATCH /repos/:did/:repo/pulls/:number Update pull request');
|
|
327
|
+
console.log(' PUT /repos/:did/:repo/pulls/:n/merge Merge pull request');
|
|
328
|
+
console.log(' POST /repos/:did/:repo/pulls/:n/reviews Create review');
|
|
329
|
+
console.log(' POST /repos/:did/:repo/releases Create release');
|
|
330
|
+
console.log('');
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
return server;
|
|
334
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub API shim — `/users/:did` endpoint.
|
|
3
|
+
*
|
|
4
|
+
* Synthesizes a GitHub-style user object from a DID. Since DIDs are
|
|
5
|
+
* self-sovereign identifiers, we don't have profile data beyond the
|
|
6
|
+
* DID itself — fields like `name`, `bio`, etc. are left empty.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { JsonResponse } from './helpers.js';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
buildApiUrl,
|
|
15
|
+
jsonOk,
|
|
16
|
+
numericId,
|
|
17
|
+
toISODate,
|
|
18
|
+
} from './helpers.js';
|
|
19
|
+
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// GET /users/:did
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Handle `GET /users/:did`.
|
|
26
|
+
*
|
|
27
|
+
* Returns a GitHub-style user profile JSON response.
|
|
28
|
+
*/
|
|
29
|
+
export async function handleGetUser(
|
|
30
|
+
targetDid: string, url: URL,
|
|
31
|
+
): Promise<JsonResponse> {
|
|
32
|
+
const baseUrl = buildApiUrl(url);
|
|
33
|
+
const id = numericId(targetDid);
|
|
34
|
+
|
|
35
|
+
const user = {
|
|
36
|
+
login : targetDid,
|
|
37
|
+
id,
|
|
38
|
+
node_id : targetDid,
|
|
39
|
+
avatar_url : '',
|
|
40
|
+
gravatar_id : '',
|
|
41
|
+
url : `${baseUrl}/users/${targetDid}`,
|
|
42
|
+
html_url : `${baseUrl}/users/${targetDid}`,
|
|
43
|
+
repos_url : `${baseUrl}/users/${targetDid}/repos`,
|
|
44
|
+
type : 'User',
|
|
45
|
+
site_admin : false,
|
|
46
|
+
name : null,
|
|
47
|
+
company : null,
|
|
48
|
+
blog : '',
|
|
49
|
+
location : null,
|
|
50
|
+
email : null,
|
|
51
|
+
hireable : null,
|
|
52
|
+
bio : null,
|
|
53
|
+
twitter_username : null,
|
|
54
|
+
public_repos : 0,
|
|
55
|
+
public_gists : 0,
|
|
56
|
+
followers : 0,
|
|
57
|
+
following : 0,
|
|
58
|
+
created_at : toISODate(undefined),
|
|
59
|
+
updated_at : toISODate(undefined),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return jsonOk(user);
|
|
63
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @enbox/gitd — Decentralized forge protocols for DWN.
|
|
3
|
+
*
|
|
4
|
+
* Protocol definitions for a decentralized GitHub alternative.
|
|
5
|
+
* See PLAN.md for full architecture documentation.
|
|
6
|
+
*
|
|
7
|
+
* Each protocol exports:
|
|
8
|
+
* - Data shape types for each record type (e.g. `IssueData`, `RepoData`)
|
|
9
|
+
* - A `SchemaMap` type mapping type names to data shapes
|
|
10
|
+
* - A raw `ProtocolDefinition` (e.g. `ForgeRepoDefinition`)
|
|
11
|
+
* - A typed protocol created via `defineProtocol()` (e.g. `ForgeRepoProtocol`)
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export * from './repo.js';
|
|
17
|
+
export * from './refs.js';
|
|
18
|
+
export * from './issues.js';
|
|
19
|
+
export * from './patches.js';
|
|
20
|
+
export * from './ci.js';
|
|
21
|
+
export * from './releases.js';
|
|
22
|
+
export * from './registry.js';
|
|
23
|
+
export * from './social.js';
|
|
24
|
+
export * from './notifications.js';
|
|
25
|
+
export * from './wiki.js';
|
|
26
|
+
export * from './org.js';
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indexer REST API — serves JSON responses from the materialized views
|
|
3
|
+
* in the IndexerStore.
|
|
4
|
+
*
|
|
5
|
+
* Endpoints:
|
|
6
|
+
*
|
|
7
|
+
* GET /api/repos List all repos (sorted by stars)
|
|
8
|
+
* GET /api/repos/search?q=<query> Search repos by name/topic/language
|
|
9
|
+
* GET /api/repos/trending Trending repos (recent star activity)
|
|
10
|
+
* GET /api/repos/:did Repo detail for a specific DID
|
|
11
|
+
* GET /api/repos/:did/stars Stars for a specific repo
|
|
12
|
+
* GET /api/users/:did User profile summary
|
|
13
|
+
* GET /api/stats Indexer statistics
|
|
14
|
+
*
|
|
15
|
+
* All responses are JSON with `Content-Type: application/json`.
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { Server } from 'node:http';
|
|
21
|
+
|
|
22
|
+
import { createServer } from 'node:http';
|
|
23
|
+
|
|
24
|
+
import type { IndexerStore } from './store.js';
|
|
25
|
+
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Types
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
export type ApiServerOptions = {
|
|
31
|
+
store : IndexerStore;
|
|
32
|
+
port : number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Router
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
/** Route an incoming request to the appropriate API handler. */
|
|
40
|
+
export function handleApiRequest(
|
|
41
|
+
store: IndexerStore,
|
|
42
|
+
url: URL,
|
|
43
|
+
): { status: number; body: string } {
|
|
44
|
+
const path = url.pathname;
|
|
45
|
+
|
|
46
|
+
// GET /api/stats
|
|
47
|
+
if (path === '/api/stats') {
|
|
48
|
+
return json(200, store.getStats());
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// GET /api/repos/search?q=<query>
|
|
52
|
+
if (path === '/api/repos/search') {
|
|
53
|
+
const q = url.searchParams.get('q') ?? '';
|
|
54
|
+
const limit = parseInt(url.searchParams.get('limit') ?? '50', 10);
|
|
55
|
+
if (!q) {
|
|
56
|
+
return json(400, { error: 'Missing query parameter: q' });
|
|
57
|
+
}
|
|
58
|
+
return json(200, store.search(q, limit));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// GET /api/repos/trending
|
|
62
|
+
if (path === '/api/repos/trending') {
|
|
63
|
+
const limit = parseInt(url.searchParams.get('limit') ?? '20', 10);
|
|
64
|
+
const days = parseInt(url.searchParams.get('days') ?? '7', 10);
|
|
65
|
+
return json(200, store.getTrending(limit, days * 24 * 60 * 60 * 1000));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// GET /api/repos (list all)
|
|
69
|
+
if (path === '/api/repos') {
|
|
70
|
+
const language = url.searchParams.get('language');
|
|
71
|
+
const topic = url.searchParams.get('topic');
|
|
72
|
+
if (language) {
|
|
73
|
+
return json(200, store.getReposByLanguage(language));
|
|
74
|
+
}
|
|
75
|
+
if (topic) {
|
|
76
|
+
return json(200, store.getReposByTopic(topic));
|
|
77
|
+
}
|
|
78
|
+
return json(200, store.getReposWithStars());
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// GET /api/repos/:did/stars
|
|
82
|
+
const starsMatch = path.match(/^\/api\/repos\/(did:[a-z0-9]+:[a-zA-Z0-9._:%-]+)\/stars$/);
|
|
83
|
+
if (starsMatch) {
|
|
84
|
+
const did = starsMatch[1];
|
|
85
|
+
const repo = store.getRepo(did);
|
|
86
|
+
if (!repo) { return json(404, { error: 'Repo not found' }); }
|
|
87
|
+
return json(200, {
|
|
88
|
+
starCount : store.getStarCount(repo.did, repo.recordId),
|
|
89
|
+
stars : store.getStarsForRepo(repo.did, repo.recordId),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// GET /api/repos/:did
|
|
94
|
+
const repoMatch = path.match(/^\/api\/repos\/(did:[a-z0-9]+:[a-zA-Z0-9._:%-]+)$/);
|
|
95
|
+
if (repoMatch) {
|
|
96
|
+
const did = repoMatch[1];
|
|
97
|
+
const repo = store.getRepo(did);
|
|
98
|
+
if (!repo) { return json(404, { error: 'Repo not found' }); }
|
|
99
|
+
return json(200, {
|
|
100
|
+
...repo,
|
|
101
|
+
starCount: store.getStarCount(repo.did, repo.recordId),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// GET /api/users/:did
|
|
106
|
+
const userMatch = path.match(/^\/api\/users\/(did:[a-z0-9]+:[a-zA-Z0-9._:%-]+)$/);
|
|
107
|
+
if (userMatch) {
|
|
108
|
+
const did = userMatch[1];
|
|
109
|
+
return json(200, store.getUserProfile(did));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return json(404, { error: 'Not found' });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
// Server
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
/** Start the indexer API server. */
|
|
120
|
+
export function startApiServer(options: ApiServerOptions): Server {
|
|
121
|
+
const { store, port } = options;
|
|
122
|
+
|
|
123
|
+
const server = createServer((req, res) => {
|
|
124
|
+
try {
|
|
125
|
+
const url = new URL(req.url ?? '/', `http://localhost:${port}`);
|
|
126
|
+
const result = handleApiRequest(store, url);
|
|
127
|
+
|
|
128
|
+
res.writeHead(result.status, {
|
|
129
|
+
'Content-Type' : 'application/json; charset=utf-8',
|
|
130
|
+
'Access-Control-Allow-Origin' : '*',
|
|
131
|
+
});
|
|
132
|
+
res.end(result.body);
|
|
133
|
+
} catch (err) {
|
|
134
|
+
console.error(`[indexer-api] Error: ${(err as Error).message}`);
|
|
135
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
136
|
+
res.end(JSON.stringify({ error: 'Internal server error' }));
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
server.listen(port, () => {
|
|
141
|
+
console.log(`[indexer-api] Listening on http://localhost:${port}`);
|
|
142
|
+
console.log('[indexer-api] Endpoints:');
|
|
143
|
+
console.log(' GET /api/repos List all repos');
|
|
144
|
+
console.log(' GET /api/repos/search?q=<query> Search repos');
|
|
145
|
+
console.log(' GET /api/repos/trending Trending repos');
|
|
146
|
+
console.log(' GET /api/repos/:did Repo detail');
|
|
147
|
+
console.log(' GET /api/repos/:did/stars Star list');
|
|
148
|
+
console.log(' GET /api/users/:did User profile');
|
|
149
|
+
console.log(' GET /api/stats Indexer stats');
|
|
150
|
+
console.log('');
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
return server;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
// Helpers
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
|
|
160
|
+
function json(status: number, data: unknown): { status: number; body: string } {
|
|
161
|
+
return { status, body: JSON.stringify(data) };
|
|
162
|
+
}
|