@trebired/git-host 0.1.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.
- package/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +451 -0
- package/dist/api/handler/action.d.ts +5 -0
- package/dist/api/handler/action.d.ts.map +1 -0
- package/dist/api/handler/action.js +47 -0
- package/dist/api/handler/action.js.map +1 -0
- package/dist/api/handler/response.d.ts +34 -0
- package/dist/api/handler/response.d.ts.map +1 -0
- package/dist/api/handler/response.js +87 -0
- package/dist/api/handler/response.js.map +1 -0
- package/dist/api/handler/route.d.ts +15 -0
- package/dist/api/handler/route.d.ts.map +1 -0
- package/dist/api/handler/route.js +51 -0
- package/dist/api/handler/route.js.map +1 -0
- package/dist/api/handler.d.ts +6 -0
- package/dist/api/handler.d.ts.map +1 -0
- package/dist/api/handler.js +117 -0
- package/dist/api/handler.js.map +1 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +16 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/create_git_host/branch_methods.d.ts +5 -0
- package/dist/core/create_git_host/branch_methods.d.ts.map +1 -0
- package/dist/core/create_git_host/branch_methods.js +137 -0
- package/dist/core/create_git_host/branch_methods.js.map +1 -0
- package/dist/core/create_git_host/content_methods.d.ts +5 -0
- package/dist/core/create_git_host/content_methods.d.ts.map +1 -0
- package/dist/core/create_git_host/content_methods.js +24 -0
- package/dist/core/create_git_host/content_methods.js.map +1 -0
- package/dist/core/create_git_host/remote_methods.d.ts +5 -0
- package/dist/core/create_git_host/remote_methods.d.ts.map +1 -0
- package/dist/core/create_git_host/remote_methods.js +48 -0
- package/dist/core/create_git_host/remote_methods.js.map +1 -0
- package/dist/core/create_git_host/shared.d.ts +21 -0
- package/dist/core/create_git_host/shared.d.ts.map +1 -0
- package/dist/core/create_git_host/shared.js +17 -0
- package/dist/core/create_git_host/shared.js.map +1 -0
- package/dist/core/create_git_host/working_tree_methods.d.ts +5 -0
- package/dist/core/create_git_host/working_tree_methods.d.ts.map +1 -0
- package/dist/core/create_git_host/working_tree_methods.js +63 -0
- package/dist/core/create_git_host/working_tree_methods.js.map +1 -0
- package/dist/core/create_git_host.d.ts +4 -0
- package/dist/core/create_git_host.d.ts.map +1 -0
- package/dist/core/create_git_host.js +167 -0
- package/dist/core/create_git_host.js.map +1 -0
- package/dist/core/inspect/helpers.d.ts +27 -0
- package/dist/core/inspect/helpers.d.ts.map +1 -0
- package/dist/core/inspect/helpers.js +86 -0
- package/dist/core/inspect/helpers.js.map +1 -0
- package/dist/core/inspect.d.ts +17 -0
- package/dist/core/inspect.d.ts.map +1 -0
- package/dist/core/inspect.js +174 -0
- package/dist/core/inspect.js.map +1 -0
- package/dist/core/locks.d.ts +5 -0
- package/dist/core/locks.d.ts.map +1 -0
- package/dist/core/locks.js +27 -0
- package/dist/core/locks.js.map +1 -0
- package/dist/core/operation_state.d.ts +4 -0
- package/dist/core/operation_state.d.ts.map +1 -0
- package/dist/core/operation_state.js +51 -0
- package/dist/core/operation_state.js.map +1 -0
- package/dist/core/remote.d.ts +13 -0
- package/dist/core/remote.d.ts.map +1 -0
- package/dist/core/remote.js +187 -0
- package/dist/core/remote.js.map +1 -0
- package/dist/core/repository/parsers.d.ts +12 -0
- package/dist/core/repository/parsers.d.ts.map +1 -0
- package/dist/core/repository/parsers.js +181 -0
- package/dist/core/repository/parsers.js.map +1 -0
- package/dist/core/repository.d.ts +11 -0
- package/dist/core/repository.d.ts.map +1 -0
- package/dist/core/repository.js +81 -0
- package/dist/core/repository.js.map +1 -0
- package/dist/core/run_git/env.d.ts +7 -0
- package/dist/core/run_git/env.d.ts.map +1 -0
- package/dist/core/run_git/env.js +18 -0
- package/dist/core/run_git/env.js.map +1 -0
- package/dist/core/run_git/process.d.ts +13 -0
- package/dist/core/run_git/process.d.ts.map +1 -0
- package/dist/core/run_git/process.js +96 -0
- package/dist/core/run_git/process.js.map +1 -0
- package/dist/core/run_git/repository_setup.d.ts +20 -0
- package/dist/core/run_git/repository_setup.d.ts.map +1 -0
- package/dist/core/run_git/repository_setup.js +116 -0
- package/dist/core/run_git/repository_setup.js.map +1 -0
- package/dist/core/run_git.d.ts +6 -0
- package/dist/core/run_git.d.ts.map +1 -0
- package/dist/core/run_git.js +6 -0
- package/dist/core/run_git.js.map +1 -0
- package/dist/core/working_tree/mutate.d.ts +9 -0
- package/dist/core/working_tree/mutate.d.ts.map +1 -0
- package/dist/core/working_tree/mutate.js +159 -0
- package/dist/core/working_tree/mutate.js.map +1 -0
- package/dist/core/working_tree/read.d.ts +6 -0
- package/dist/core/working_tree/read.d.ts.map +1 -0
- package/dist/core/working_tree/read.js +108 -0
- package/dist/core/working_tree/read.js.map +1 -0
- package/dist/core/working_tree/shared.d.ts +20 -0
- package/dist/core/working_tree/shared.d.ts.map +1 -0
- package/dist/core/working_tree/shared.js +87 -0
- package/dist/core/working_tree/shared.js.map +1 -0
- package/dist/core/working_tree.d.ts +3 -0
- package/dist/core/working_tree.d.ts.map +1 -0
- package/dist/core/working_tree.js +3 -0
- package/dist/core/working_tree.js.map +1 -0
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/http/handler/helpers.d.ts +35 -0
- package/dist/http/handler/helpers.d.ts.map +1 -0
- package/dist/http/handler/helpers.js +146 -0
- package/dist/http/handler/helpers.js.map +1 -0
- package/dist/http/handler.d.ts +6 -0
- package/dist/http/handler.d.ts.map +1 -0
- package/dist/http/handler.js +208 -0
- package/dist/http/handler.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/logging.d.ts +4 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +134 -0
- package/dist/logging.js.map +1 -0
- package/dist/react/client/error.d.ts +14 -0
- package/dist/react/client/error.d.ts.map +1 -0
- package/dist/react/client/error.js +32 -0
- package/dist/react/client/error.js.map +1 -0
- package/dist/react/client/helpers.d.ts +12 -0
- package/dist/react/client/helpers.d.ts.map +1 -0
- package/dist/react/client/helpers.js +45 -0
- package/dist/react/client/helpers.js.map +1 -0
- package/dist/react/client/types.d.ts +61 -0
- package/dist/react/client/types.d.ts.map +1 -0
- package/dist/react/client/types.js +2 -0
- package/dist/react/client/types.js.map +1 -0
- package/dist/react/client.d.ts +6 -0
- package/dist/react/client.d.ts.map +1 -0
- package/dist/react/client.js +115 -0
- package/dist/react/client.js.map +1 -0
- package/dist/react/hooks/query.d.ts +10 -0
- package/dist/react/hooks/query.d.ts.map +1 -0
- package/dist/react/hooks/query.js +74 -0
- package/dist/react/hooks/query.js.map +1 -0
- package/dist/react/hooks/resources.d.ts +11 -0
- package/dist/react/hooks/resources.d.ts.map +1 -0
- package/dist/react/hooks/resources.js +113 -0
- package/dist/react/hooks/resources.js.map +1 -0
- package/dist/react/hooks/types.d.ts +40 -0
- package/dist/react/hooks/types.d.ts.map +1 -0
- package/dist/react/hooks/types.js +2 -0
- package/dist/react/hooks/types.js.map +1 -0
- package/dist/react/hooks.d.ts +4 -0
- package/dist/react/hooks.d.ts.map +1 -0
- package/dist/react/hooks.js +3 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/index.d.ts +5 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +3 -0
- package/dist/react/index.js.map +1 -0
- package/dist/ssh/keys.d.ts +18 -0
- package/dist/ssh/keys.d.ts.map +1 -0
- package/dist/ssh/keys.js +41 -0
- package/dist/ssh/keys.js.map +1 -0
- package/dist/ssh/server/audit.d.ts +5 -0
- package/dist/ssh/server/audit.d.ts.map +1 -0
- package/dist/ssh/server/audit.js +21 -0
- package/dist/ssh/server/audit.js.map +1 -0
- package/dist/ssh/server/shared.d.ts +30 -0
- package/dist/ssh/server/shared.d.ts.map +1 -0
- package/dist/ssh/server/shared.js +93 -0
- package/dist/ssh/server/shared.js.map +1 -0
- package/dist/ssh/server.d.ts +5 -0
- package/dist/ssh/server.d.ts.map +1 -0
- package/dist/ssh/server.js +265 -0
- package/dist/ssh/server.js.map +1 -0
- package/dist/types/common.d.ts +32 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +2 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/host.d.ts +142 -0
- package/dist/types/host.d.ts.map +1 -0
- package/dist/types/host.js +2 -0
- package/dist/types/host.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/repository.d.ts +163 -0
- package/dist/types/repository.d.ts.map +1 -0
- package/dist/types/repository.js +2 -0
- package/dist/types/repository.js.map +1 -0
- package/dist/types/transports.d.ts +156 -0
- package/dist/types/transports.d.ts.map +1 -0
- package/dist/types/transports.js +2 -0
- package/dist/types/transports.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/paths.d.ts +10 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +51 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/text.d.ts +4 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +10 -0
- package/dist/utils/text.js.map +1 -0
- package/package.json +81 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { DEFAULT_ACTOR_EMAIL, DEFAULT_ACTOR_NAME, DEFAULT_BRANCH, DEFAULT_COMMIT_MESSAGE, DEFAULT_MANAGED_EXCLUDE_HEADER, DEFAULT_MANAGED_EXCLUDE_PATTERNS, } from "./constants.js";
|
|
2
|
+
export { RepositoryLockManager } from "./core/locks.js";
|
|
3
|
+
export { readRepositoryOperationState } from "./core/operation_state.js";
|
|
4
|
+
export { createGitHost } from "./core/create_git_host.js";
|
|
5
|
+
export { createGitApiHandler, parseGitApiRoute } from "./api/handler.js";
|
|
6
|
+
export { fetchRepository, pullRepository, pushRepository } from "./core/remote.js";
|
|
7
|
+
export { createGitHttpHandler, parseGitHttpRoute } from "./http/handler.js";
|
|
8
|
+
export { compareSshPublicKeys, fingerprintSshPublicKey, generateSshKeyPair, normalizeSshPublicKey, } from "./ssh/keys.js";
|
|
9
|
+
export { createGitSshServer, parseGitSshCommand } from "./ssh/server.js";
|
|
10
|
+
export { listRepositoryTree, readRepositoryBlob, readRepositoryCommit, readRepositoryCompare, } from "./core/inspect.js";
|
|
11
|
+
export { abortRepositoryOperation, commitRepository, continueRepositoryOperation, discardRepositoryPaths, readRepositoryStagedFile, readRepositoryUnstagedFile, readRepositoryWorkingTree, stageRepositoryPaths, unstageRepositoryPaths, } from "./core/working_tree.js";
|
|
12
|
+
export { buildGitEnv, cloneRepository, createInitialCommit, ensureManagedExcludeFile, initRepository, repositoryExists, runGit, runGitBuffer, } from "./core/run_git.js";
|
|
13
|
+
export { GitHostError, isGitHostError } from "./errors.js";
|
|
14
|
+
export { assertAbsoluteRepositoryPath, normalizeRepositoryRelativePath, resolveRepositoryPath } from "./utils/paths.js";
|
|
15
|
+
export type { GitHostErrorCode } from "./errors.js";
|
|
16
|
+
export type { GenerateGitSshKeyPairOptions, GitSshKeyAlgorithm, GitSshKeyPair } from "./ssh/keys.js";
|
|
17
|
+
export type { BuildGitEnvOptions, CheckoutBranchInput, CheckoutRefInput, CommitInput, ContinueOperationInput, CreateBranchInput, CreateGitApiHandlerOptions, CreateGitHostOptions, DeleteBranchInput, DiscardPathsInput, DiffOptions, EnsureRepositoryOptions, FetchOptions, GitApiAuthorizationResult, GitApiResource, CreateGitHttpHandlerOptions, CreateGitSshServerOptions, GitActor, GitBlob, GitBlobEncoding, GitFileContent, GitFileContentSource, GitHttpAuthenticationResult, GitHttpAuditEvent, GitHttpAuditOutcome, GitHttpAuthorizationResult, GitHttpResolvedRepository, GitHttpService, GitBranchSummary, GitCommandBufferResult, GitCommandResult, GitCommitDetail, GitCommitSummary, GitCompareSummary, GitDiffFile, GitHost, GitHostGenericLogMethod, GitHostLogEvent, GitHostLogMethod, GitHostLogger, GitOperationKind, GitOperationState, GitRemoteCredentials, GitRemoteSummary, GitRemoteTransportOptions, GitRepositoryHandle, GitRepositoryStatus, GitRepositorySummary, GitSshAuditEvent, GitSshAuditOutcome, GitSshAuthenticationResult, GitSshAuthorizationResult, GitSshResolvedRepository, GitSshService, GitStatusEntry, GitTreeEntry, GitWorkingTree, GitWorkingTreeEntry, ListCommitsOptions, ListTreeOptions, MaybePromise, NormalizedGitHostLogger, PullOptions, PushOptions, ReadBlobOptions, ReadWorkingTreeFileOptions, ReadSummaryOptions, ResolveRepositoryPathOptions, StagePathsInput, UnstagePathsInput, } from "./types.js";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,8BAA8B,EAC9B,gCAAgC,GACjC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,eAAe,CAAC;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AO,EACP,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,uBAAuB,EACvB,WAAW,EACX,WAAW,EACX,eAAe,EACf,0BAA0B,EAC1B,kBAAkB,EAClB,4BAA4B,EAC5B,eAAe,EACf,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { DEFAULT_ACTOR_EMAIL, DEFAULT_ACTOR_NAME, DEFAULT_BRANCH, DEFAULT_COMMIT_MESSAGE, DEFAULT_MANAGED_EXCLUDE_HEADER, DEFAULT_MANAGED_EXCLUDE_PATTERNS, } from "./constants.js";
|
|
2
|
+
export { RepositoryLockManager } from "./core/locks.js";
|
|
3
|
+
export { readRepositoryOperationState } from "./core/operation_state.js";
|
|
4
|
+
export { createGitHost } from "./core/create_git_host.js";
|
|
5
|
+
export { createGitApiHandler, parseGitApiRoute } from "./api/handler.js";
|
|
6
|
+
export { fetchRepository, pullRepository, pushRepository } from "./core/remote.js";
|
|
7
|
+
export { createGitHttpHandler, parseGitHttpRoute } from "./http/handler.js";
|
|
8
|
+
export { compareSshPublicKeys, fingerprintSshPublicKey, generateSshKeyPair, normalizeSshPublicKey, } from "./ssh/keys.js";
|
|
9
|
+
export { createGitSshServer, parseGitSshCommand } from "./ssh/server.js";
|
|
10
|
+
export { listRepositoryTree, readRepositoryBlob, readRepositoryCommit, readRepositoryCompare, } from "./core/inspect.js";
|
|
11
|
+
export { abortRepositoryOperation, commitRepository, continueRepositoryOperation, discardRepositoryPaths, readRepositoryStagedFile, readRepositoryUnstagedFile, readRepositoryWorkingTree, stageRepositoryPaths, unstageRepositoryPaths, } from "./core/working_tree.js";
|
|
12
|
+
export { buildGitEnv, cloneRepository, createInitialCommit, ensureManagedExcludeFile, initRepository, repositoryExists, runGit, runGitBuffer, } from "./core/run_git.js";
|
|
13
|
+
export { GitHostError, isGitHostError } from "./errors.js";
|
|
14
|
+
export { assertAbsoluteRepositoryPath, normalizeRepositoryRelativePath, resolveRepositoryPath } from "./utils/paths.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,8BAA8B,EAC9B,gCAAgC,GACjC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,2BAA2B,EAC3B,sBAAsB,EACtB,wBAAwB,EACxB,0BAA0B,EAC1B,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,gBAAgB,EAChB,MAAM,EACN,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,4BAA4B,EAAE,+BAA+B,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,aAAa,EACb,uBAAuB,EACxB,MAAM,YAAY,CAAC;AA2JpB,iBAAS,aAAa,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,uBAAuB,CAStE;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/logging.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
let defaultLoggerCache;
|
|
3
|
+
function isRecord(value) {
|
|
4
|
+
return value != null && typeof value === "object";
|
|
5
|
+
}
|
|
6
|
+
function isPlainObject(value) {
|
|
7
|
+
if (!isRecord(value))
|
|
8
|
+
return false;
|
|
9
|
+
const proto = Object.getPrototypeOf(value);
|
|
10
|
+
return proto === Object.prototype || proto === null;
|
|
11
|
+
}
|
|
12
|
+
function getLoggerMethod(source, name) {
|
|
13
|
+
if (!isRecord(source))
|
|
14
|
+
return null;
|
|
15
|
+
const value = source[name];
|
|
16
|
+
return typeof value === "function" ? value : null;
|
|
17
|
+
}
|
|
18
|
+
function buildLogEvent(level, group, message, metadata) {
|
|
19
|
+
return metadata === undefined
|
|
20
|
+
? { group, level, message }
|
|
21
|
+
: { group, level, message, metadata };
|
|
22
|
+
}
|
|
23
|
+
function formatLogMessage(group, message) {
|
|
24
|
+
return `[${group}] ${message}`;
|
|
25
|
+
}
|
|
26
|
+
function buildStructuredPayload(event) {
|
|
27
|
+
if (isPlainObject(event.metadata)) {
|
|
28
|
+
return {
|
|
29
|
+
group: event.group,
|
|
30
|
+
...event.metadata,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return event.metadata === undefined
|
|
34
|
+
? { group: event.group }
|
|
35
|
+
: {
|
|
36
|
+
group: event.group,
|
|
37
|
+
metadata: event.metadata,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function fallbackLogger(level) {
|
|
41
|
+
return (group, message, metadata) => {
|
|
42
|
+
const prefix = formatLogMessage(group, message);
|
|
43
|
+
if (metadata !== undefined)
|
|
44
|
+
console[level](prefix, metadata);
|
|
45
|
+
else
|
|
46
|
+
console[level](prefix);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function looksLikeTrebiredLogger(source) {
|
|
50
|
+
return Boolean(getLoggerMethod(source, "fail")
|
|
51
|
+
|| getLoggerMethod(source, "group")
|
|
52
|
+
|| getLoggerMethod(source, "withScope")
|
|
53
|
+
|| getLoggerMethod(source, "flush")
|
|
54
|
+
|| getLoggerMethod(source, "getStats"));
|
|
55
|
+
}
|
|
56
|
+
function looksLikeObjectFirstLevelLogger(source) {
|
|
57
|
+
if (!isRecord(source))
|
|
58
|
+
return false;
|
|
59
|
+
return Boolean(getLoggerMethod(source, "child")
|
|
60
|
+
|| getLoggerMethod(source, "bindings")
|
|
61
|
+
|| (source.levels && typeof source.levels === "object"));
|
|
62
|
+
}
|
|
63
|
+
function callEventSink(source, event) {
|
|
64
|
+
if (typeof source === "function") {
|
|
65
|
+
source(event);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
const sink = getLoggerMethod(source, "write") || getLoggerMethod(source, "log");
|
|
69
|
+
if (!sink)
|
|
70
|
+
return false;
|
|
71
|
+
sink.call(source, event);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
function callLevelMethod(source, level, event) {
|
|
75
|
+
const alias = level === "fail" ? "fatal" : level;
|
|
76
|
+
const method = getLoggerMethod(source, level) || getLoggerMethod(source, alias);
|
|
77
|
+
if (!method)
|
|
78
|
+
return false;
|
|
79
|
+
if (looksLikeTrebiredLogger(source)) {
|
|
80
|
+
method.call(source, event.group, event.message, event.metadata);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
if (looksLikeObjectFirstLevelLogger(source)) {
|
|
84
|
+
method.call(source, buildStructuredPayload(event), event.message);
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
if (event.metadata === undefined) {
|
|
88
|
+
method.call(source, formatLogMessage(event.group, event.message));
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
method.call(source, formatLogMessage(event.group, event.message), event.metadata);
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
function tryResolveDefaultLogger() {
|
|
95
|
+
if (defaultLoggerCache !== undefined)
|
|
96
|
+
return defaultLoggerCache;
|
|
97
|
+
try {
|
|
98
|
+
const require = createRequire(import.meta.url);
|
|
99
|
+
const mod = require("@trebired/logger");
|
|
100
|
+
if (typeof mod.createLog === "function") {
|
|
101
|
+
defaultLoggerCache = mod.createLog({
|
|
102
|
+
console: true,
|
|
103
|
+
quiet: true,
|
|
104
|
+
save: false,
|
|
105
|
+
source: "@trebired/git-host",
|
|
106
|
+
});
|
|
107
|
+
return defaultLoggerCache;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
catch { }
|
|
111
|
+
defaultLoggerCache = null;
|
|
112
|
+
return defaultLoggerCache;
|
|
113
|
+
}
|
|
114
|
+
function resolveLogMethod(source, level, fallback) {
|
|
115
|
+
return (group, message, metadata) => {
|
|
116
|
+
const event = buildLogEvent(level, group, message, metadata);
|
|
117
|
+
if (callLevelMethod(source, level, event))
|
|
118
|
+
return;
|
|
119
|
+
if (callEventSink(source, event))
|
|
120
|
+
return;
|
|
121
|
+
fallback(group, message, metadata);
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function resolveLogger(logger) {
|
|
125
|
+
const source = logger ?? tryResolveDefaultLogger();
|
|
126
|
+
return {
|
|
127
|
+
info: resolveLogMethod(source, "info", fallbackLogger("info")),
|
|
128
|
+
warn: resolveLogMethod(source, "warn", fallbackLogger("warn")),
|
|
129
|
+
error: resolveLogMethod(source, "error", fallbackLogger("error")),
|
|
130
|
+
fail: resolveLogMethod(source, "fail", fallbackLogger("error")),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export { resolveLogger };
|
|
134
|
+
//# sourceMappingURL=logging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAgB5C,IAAI,kBAAoD,CAAC;AAEzD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACpD,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACnC,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC;AAED,SAAS,eAAe,CAAC,MAAwC,EAAE,IAAY;IAC7E,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK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
status: number;
|
|
5
|
+
constructor(input: {
|
|
6
|
+
code?: string;
|
|
7
|
+
details?: unknown;
|
|
8
|
+
message: string;
|
|
9
|
+
status: number;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
declare function parseJsonResponse(response: Response): Promise<unknown>;
|
|
13
|
+
export { GitApiClientError, parseJsonResponse };
|
|
14
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/react/client/error.ts"],"names":[],"mappings":"AAAA,cAAM,iBAAkB,SAAQ,KAAK;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;gBAEH,KAAK,EAAE;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB;CAOF;AAED,iBAAe,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,oBAoBlD;AAED,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class GitApiClientError extends Error {
|
|
2
|
+
constructor(input) {
|
|
3
|
+
super(input.message);
|
|
4
|
+
this.name = "GitApiClientError";
|
|
5
|
+
this.code = String(input.code || "git_api_error");
|
|
6
|
+
this.details = input.details;
|
|
7
|
+
this.status = Number(input.status) || 500;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
async function parseJsonResponse(response) {
|
|
11
|
+
const bodyText = await response.text();
|
|
12
|
+
if (!bodyText)
|
|
13
|
+
return null;
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(bodyText);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new GitApiClientError({
|
|
20
|
+
message: bodyText,
|
|
21
|
+
status: response.status,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
throw new GitApiClientError({
|
|
25
|
+
code: "invalid_json",
|
|
26
|
+
message: "Git API response was not valid JSON.",
|
|
27
|
+
status: response.status || 500,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export { GitApiClientError, parseJsonResponse };
|
|
32
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/react/client/error.ts"],"names":[],"mappings":"AAAA,MAAM,iBAAkB,SAAQ,KAAK;IAKnC,YAAY,KAKX;QACC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,eAAe,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC;IAC5C,CAAC;CACF;AAED,KAAK,UAAU,iBAAiB,CAAC,QAAkB;IACjD,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACvC,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE3B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAY,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,iBAAiB,CAAC;gBAC1B,OAAO,EAAE,QAAQ;gBACjB,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB,CAAC,CAAC;QACL,CAAC;QAED,MAAM,IAAI,iBAAiB,CAAC;YAC1B,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,sCAAsC;YAC/C,MAAM,EAAE,QAAQ,CAAC,MAAM,IAAI,GAAG;SAC/B,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GitApiClientHeaders, GitApiHeaderResolver } from "./types.js";
|
|
2
|
+
declare function normalizeBaseUrl(value: string): string;
|
|
3
|
+
declare function encodePathSegment(value: string): string;
|
|
4
|
+
declare function appendQuery(url: string, query: URLSearchParams | undefined): string;
|
|
5
|
+
declare function buildQuery(values: Record<string, boolean | number | string | undefined>): URLSearchParams | undefined;
|
|
6
|
+
declare function resolveHeaders(resolver: GitApiHeaderResolver | undefined, input: {
|
|
7
|
+
path: string;
|
|
8
|
+
repositoryKey?: string;
|
|
9
|
+
}): Promise<GitApiClientHeaders>;
|
|
10
|
+
declare function mergeHeaders(left: GitApiClientHeaders | undefined, right: GitApiClientHeaders | undefined): GitApiClientHeaders | undefined;
|
|
11
|
+
export { appendQuery, buildQuery, encodePathSegment, mergeHeaders, normalizeBaseUrl, resolveHeaders };
|
|
12
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/react/client/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE5E,iBAAS,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAM/C;AAED,iBAAS,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,iBAAS,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG,MAAM,CAI5E;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,GAAG,eAAe,GAAG,SAAS,CAU9G;AAED,iBAAe,cAAc,CAC3B,QAAQ,EAAE,oBAAoB,GAAG,SAAS,EAC1C,KAAK,EAAE;IACL,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,gCAOF;AAED,iBAAS,YAAY,CACnB,IAAI,EAAE,mBAAmB,GAAG,SAAS,EACrC,KAAK,EAAE,mBAAmB,GAAG,SAAS,GACrC,mBAAmB,GAAG,SAAS,CAMjC;AAED,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function normalizeBaseUrl(value) {
|
|
2
|
+
const next = String(value || "").trim().replace(/\/+$/g, "");
|
|
3
|
+
if (!next) {
|
|
4
|
+
throw new TypeError("createGitApiClient() requires a baseUrl.");
|
|
5
|
+
}
|
|
6
|
+
return next;
|
|
7
|
+
}
|
|
8
|
+
function encodePathSegment(value) {
|
|
9
|
+
return encodeURIComponent(String(value || ""));
|
|
10
|
+
}
|
|
11
|
+
function appendQuery(url, query) {
|
|
12
|
+
const suffix = query && String(query).trim();
|
|
13
|
+
if (!suffix)
|
|
14
|
+
return url;
|
|
15
|
+
return `${url}?${suffix}`;
|
|
16
|
+
}
|
|
17
|
+
function buildQuery(values) {
|
|
18
|
+
const query = new URLSearchParams();
|
|
19
|
+
for (const [name, value] of Object.entries(values)) {
|
|
20
|
+
if (value == null)
|
|
21
|
+
continue;
|
|
22
|
+
if (typeof value === "string" && value === "")
|
|
23
|
+
continue;
|
|
24
|
+
query.set(name, typeof value === "boolean" ? String(value) : String(value));
|
|
25
|
+
}
|
|
26
|
+
return String(query) ? query : undefined;
|
|
27
|
+
}
|
|
28
|
+
async function resolveHeaders(resolver, input) {
|
|
29
|
+
if (!resolver)
|
|
30
|
+
return undefined;
|
|
31
|
+
if (typeof resolver === "function") {
|
|
32
|
+
return await resolver(input);
|
|
33
|
+
}
|
|
34
|
+
return resolver;
|
|
35
|
+
}
|
|
36
|
+
function mergeHeaders(left, right) {
|
|
37
|
+
if (!left && !right)
|
|
38
|
+
return undefined;
|
|
39
|
+
return {
|
|
40
|
+
...(left || {}),
|
|
41
|
+
...(right || {}),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export { appendQuery, buildQuery, encodePathSegment, mergeHeaders, normalizeBaseUrl, resolveHeaders };
|
|
45
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/react/client/helpers.ts"],"names":[],"mappings":"AAEA,SAAS,gBAAgB,CAAC,KAAa;IACrC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC7D,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,SAAS,CAAC,0CAA0C,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAa;IACtC,OAAO,kBAAkB,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,WAAW,CAAC,GAAW,EAAE,KAAkC;IAClE,MAAM,MAAM,GAAG,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7C,IAAI,CAAC,MAAM;QAAE,OAAO,GAAG,CAAC;IACxB,OAAO,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC;AAC5B,CAAC;AAED,SAAS,UAAU,CAAC,MAA6D;IAC/E,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC;IAEpC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,IAAI,KAAK,IAAI,IAAI;YAAE,SAAS;QAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE;YAAE,SAAS;QACxD,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3C,CAAC;AAED,KAAK,UAAU,cAAc,CAC3B,QAA0C,EAC1C,KAGC;IAED,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChC,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACnC,OAAO,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,YAAY,CACnB,IAAqC,EACrC,KAAsC;IAEtC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IACtC,OAAO;QACL,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QACf,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;KACjB,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { GitApiResource, GitBlob, GitBranchSummary, GitCommitDetail, GitCommitSummary, GitCompareSummary, GitRepositorySummary, GitTreeEntry, MaybePromise } from "../../types.js";
|
|
2
|
+
type GitApiClientHeaders = Record<string, string>;
|
|
3
|
+
type GitApiClientFetch = (input: string, init?: RequestInit) => Promise<Response>;
|
|
4
|
+
type GitApiHeaderResolver = GitApiClientHeaders | ((input: {
|
|
5
|
+
path: string;
|
|
6
|
+
repositoryKey?: string;
|
|
7
|
+
}) => MaybePromise<GitApiClientHeaders | undefined>);
|
|
8
|
+
type CreateGitApiClientOptions = {
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
fetch?: GitApiClientFetch;
|
|
11
|
+
headers?: GitApiHeaderResolver;
|
|
12
|
+
};
|
|
13
|
+
type GitApiClientRequestOptions = {
|
|
14
|
+
headers?: GitApiClientHeaders;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
};
|
|
17
|
+
type GitApiSuccessResponse<TAction extends GitApiResource, TData> = {
|
|
18
|
+
action: TAction;
|
|
19
|
+
data: TData;
|
|
20
|
+
ok: true;
|
|
21
|
+
repository_id: string;
|
|
22
|
+
repository_key: string;
|
|
23
|
+
};
|
|
24
|
+
type GitApiFailureResponse = {
|
|
25
|
+
error: {
|
|
26
|
+
code: string;
|
|
27
|
+
details?: unknown;
|
|
28
|
+
message: string;
|
|
29
|
+
};
|
|
30
|
+
ok: false;
|
|
31
|
+
};
|
|
32
|
+
type GitApiResponse<TAction extends GitApiResource, TData> = GitApiFailureResponse | GitApiSuccessResponse<TAction, TData>;
|
|
33
|
+
type GitApiClient = {
|
|
34
|
+
baseUrl: string;
|
|
35
|
+
diff(repositoryKey: string, options: GitApiClientRequestOptions & {
|
|
36
|
+
baseRef: string;
|
|
37
|
+
headRef: string;
|
|
38
|
+
}): Promise<GitCompareSummary>;
|
|
39
|
+
listBranches(repositoryKey: string, options?: GitApiClientRequestOptions): Promise<GitBranchSummary[]>;
|
|
40
|
+
listCommits(repositoryKey: string, options?: GitApiClientRequestOptions & {
|
|
41
|
+
limit?: number;
|
|
42
|
+
}): Promise<GitCommitSummary[]>;
|
|
43
|
+
listTree(repositoryKey: string, options?: GitApiClientRequestOptions & {
|
|
44
|
+
path?: string;
|
|
45
|
+
recursive?: boolean;
|
|
46
|
+
ref?: string;
|
|
47
|
+
}): Promise<GitTreeEntry[]>;
|
|
48
|
+
readBlob(repositoryKey: string, options: GitApiClientRequestOptions & {
|
|
49
|
+
path: string;
|
|
50
|
+
ref?: string;
|
|
51
|
+
}): Promise<GitBlob>;
|
|
52
|
+
readCommit(repositoryKey: string, commitRef: string, options?: GitApiClientRequestOptions): Promise<GitCommitDetail>;
|
|
53
|
+
readSummary(repositoryKey: string, options?: GitApiClientRequestOptions & {
|
|
54
|
+
commitLimit?: number;
|
|
55
|
+
}): Promise<GitRepositorySummary>;
|
|
56
|
+
request<TAction extends GitApiResource, TData>(repositoryKey: string, actionPath: string, options?: GitApiClientRequestOptions & {
|
|
57
|
+
query?: URLSearchParams;
|
|
58
|
+
}): Promise<GitApiSuccessResponse<TAction, TData>>;
|
|
59
|
+
};
|
|
60
|
+
export type { CreateGitApiClientOptions, GitApiClient, GitApiClientFetch, GitApiClientHeaders, GitApiClientRequestOptions, GitApiFailureResponse, GitApiHeaderResolver, GitApiResponse, GitApiResource, GitApiSuccessResponse, };
|
|
61
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/react/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,OAAO,EACP,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACb,MAAM,gBAAgB,CAAC;AAExB,KAAK,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAElD,KAAK,iBAAiB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAElF,KAAK,oBAAoB,GAAG,mBAAmB,GAAG,CA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B,EAC1B,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,qBAAqB,GACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/react/client/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CreateGitApiClientOptions, GitApiClient } from "./client/types.js";
|
|
2
|
+
import { GitApiClientError } from "./client/error.js";
|
|
3
|
+
declare function createGitApiClient(options: CreateGitApiClientOptions): GitApiClient;
|
|
4
|
+
export { GitApiClientError, createGitApiClient };
|
|
5
|
+
export type { CreateGitApiClientOptions, GitApiClient, GitApiClientFetch, GitApiClientHeaders, GitApiClientRequestOptions, GitApiFailureResponse, GitApiHeaderResolver, GitApiResponse, GitApiSuccessResponse, } from "./client/types.js";
|
|
6
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/react/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,YAAY,EAKb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAqB,MAAM,mBAAmB,CAAC;AAGzE,iBAAS,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,YAAY,CAmI5E;AAED,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAC;AAEjD,YAAY,EACV,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,GACtB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { GitApiClientError, parseJsonResponse } from "./client/error.js";
|
|
2
|
+
import { appendQuery, buildQuery, encodePathSegment, mergeHeaders, normalizeBaseUrl, resolveHeaders } from "./client/helpers.js";
|
|
3
|
+
function createGitApiClient(options) {
|
|
4
|
+
const baseUrl = normalizeBaseUrl(options.baseUrl);
|
|
5
|
+
const fetchImpl = options.fetch || globalThis.fetch;
|
|
6
|
+
if (typeof fetchImpl !== "function") {
|
|
7
|
+
throw new TypeError("createGitApiClient() requires fetch support.");
|
|
8
|
+
}
|
|
9
|
+
async function request(repositoryKey, actionPath, input) {
|
|
10
|
+
const repositoryBasePath = `/repositories/${encodePathSegment(repositoryKey)}`;
|
|
11
|
+
const requestPath = `${repositoryBasePath}/${String(actionPath || "").replace(/^\/+/, "")}`;
|
|
12
|
+
const url = appendQuery(`${baseUrl}${requestPath}`, input?.query);
|
|
13
|
+
const resolvedHeaders = mergeHeaders(await resolveHeaders(options.headers, {
|
|
14
|
+
path: requestPath,
|
|
15
|
+
repositoryKey,
|
|
16
|
+
}), input?.headers);
|
|
17
|
+
const response = await fetchImpl(url, {
|
|
18
|
+
headers: resolvedHeaders,
|
|
19
|
+
method: "GET",
|
|
20
|
+
signal: input?.signal,
|
|
21
|
+
});
|
|
22
|
+
const payload = await parseJsonResponse(response);
|
|
23
|
+
if (!payload && response.ok) {
|
|
24
|
+
throw new GitApiClientError({
|
|
25
|
+
code: "empty_response",
|
|
26
|
+
message: "Git API returned an empty response.",
|
|
27
|
+
status: response.status || 500,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (payload && payload.ok === false) {
|
|
31
|
+
throw new GitApiClientError({
|
|
32
|
+
code: payload.error.code,
|
|
33
|
+
details: payload.error.details,
|
|
34
|
+
message: payload.error.message,
|
|
35
|
+
status: response.status || 500,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
throw new GitApiClientError({
|
|
40
|
+
code: "http_error",
|
|
41
|
+
message: `Git API request failed with status ${response.status}.`,
|
|
42
|
+
status: response.status || 500,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return payload;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
baseUrl,
|
|
49
|
+
async diff(repositoryKey, input) {
|
|
50
|
+
const response = await request(repositoryKey, "diff", {
|
|
51
|
+
headers: input.headers,
|
|
52
|
+
query: buildQuery({
|
|
53
|
+
baseRef: input.baseRef,
|
|
54
|
+
headRef: input.headRef,
|
|
55
|
+
}),
|
|
56
|
+
signal: input.signal,
|
|
57
|
+
});
|
|
58
|
+
return response.data;
|
|
59
|
+
},
|
|
60
|
+
async listBranches(repositoryKey, input) {
|
|
61
|
+
const response = await request(repositoryKey, "branches", input);
|
|
62
|
+
return response.data;
|
|
63
|
+
},
|
|
64
|
+
async listCommits(repositoryKey, input) {
|
|
65
|
+
const response = await request(repositoryKey, "commits", {
|
|
66
|
+
headers: input?.headers,
|
|
67
|
+
query: buildQuery({
|
|
68
|
+
limit: input?.limit,
|
|
69
|
+
}),
|
|
70
|
+
signal: input?.signal,
|
|
71
|
+
});
|
|
72
|
+
return response.data;
|
|
73
|
+
},
|
|
74
|
+
async listTree(repositoryKey, input) {
|
|
75
|
+
const response = await request(repositoryKey, "tree", {
|
|
76
|
+
headers: input?.headers,
|
|
77
|
+
query: buildQuery({
|
|
78
|
+
path: input?.path,
|
|
79
|
+
recursive: input?.recursive,
|
|
80
|
+
ref: input?.ref,
|
|
81
|
+
}),
|
|
82
|
+
signal: input?.signal,
|
|
83
|
+
});
|
|
84
|
+
return response.data;
|
|
85
|
+
},
|
|
86
|
+
async readBlob(repositoryKey, input) {
|
|
87
|
+
const response = await request(repositoryKey, "blob", {
|
|
88
|
+
headers: input.headers,
|
|
89
|
+
query: buildQuery({
|
|
90
|
+
path: input.path,
|
|
91
|
+
ref: input.ref,
|
|
92
|
+
}),
|
|
93
|
+
signal: input.signal,
|
|
94
|
+
});
|
|
95
|
+
return response.data;
|
|
96
|
+
},
|
|
97
|
+
async readCommit(repositoryKey, commitRef, input) {
|
|
98
|
+
const response = await request(repositoryKey, `commits/${encodePathSegment(commitRef)}`, input);
|
|
99
|
+
return response.data;
|
|
100
|
+
},
|
|
101
|
+
async readSummary(repositoryKey, input) {
|
|
102
|
+
const response = await request(repositoryKey, "summary", {
|
|
103
|
+
headers: input?.headers,
|
|
104
|
+
query: buildQuery({
|
|
105
|
+
commitLimit: input?.commitLimit,
|
|
106
|
+
}),
|
|
107
|
+
signal: input?.signal,
|
|
108
|
+
});
|
|
109
|
+
return response.data;
|
|
110
|
+
},
|
|
111
|
+
request,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export { GitApiClientError, createGitApiClient };
|
|
115
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/react/client.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEjI,SAAS,kBAAkB,CAAC,OAAkC;IAC5D,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;IAEpD,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;QACpC,MAAM,IAAI,SAAS,CAAC,8CAA8C,CAAC,CAAC;IACtE,CAAC;IAED,KAAK,UAAU,OAAO,CACpB,aAAqB,EACrB,UAAkB,EAClB,KAEC;QAED,MAAM,kBAAkB,GAAG,iBAAiB,iBAAiB,CAAC,aAAa,CAAC,EAAE,CAAC;QAC/E,MAAM,WAAW,GAAG,GAAG,kBAAkB,IAAI,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QAC5F,MAAM,GAAG,GAAG,WAAW,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GitApiClient } from "../client.js";
|
|
2
|
+
import type { GitApiClientProviderProps, GitApiQueryOptions, GitApiQueryResult } from "./types.js";
|
|
3
|
+
declare function GitApiClientProvider(props: GitApiClientProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<GitApiClient>>;
|
|
4
|
+
declare function useGitApiClient(client?: GitApiClient): GitApiClient;
|
|
5
|
+
declare function useGitApiQuery<TData>(input: GitApiQueryOptions<TData> & {
|
|
6
|
+
key: unknown[];
|
|
7
|
+
load: (client: GitApiClient, signal: AbortSignal) => Promise<TData>;
|
|
8
|
+
}): GitApiQueryResult<TData>;
|
|
9
|
+
export { GitApiClientProvider, useGitApiClient, useGitApiQuery };
|
|
10
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/query.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAInG,iBAAS,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,yFAK7D;AAED,iBAAS,eAAe,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,YAAY,CAO5D;AAMD,iBAAS,cAAc,CAAC,KAAK,EAC3B,KAAK,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG;IACjC,GAAG,EAAE,OAAO,EAAE,CAAC;IACf,IAAI,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;CACrE,GACA,iBAAiB,CAAC,KAAK,CAAC,CAuD1B;AAED,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createContext, createElement, startTransition, useContext, useEffect, useRef, useState, } from "react";
|
|
2
|
+
const GitApiClientContext = createContext(null);
|
|
3
|
+
function GitApiClientProvider(props) {
|
|
4
|
+
return createElement(GitApiClientContext.Provider, {
|
|
5
|
+
value: props.client,
|
|
6
|
+
children: props.children,
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
function useGitApiClient(client) {
|
|
10
|
+
const contextClient = useContext(GitApiClientContext);
|
|
11
|
+
const resolvedClient = client || contextClient;
|
|
12
|
+
if (!resolvedClient) {
|
|
13
|
+
throw new Error("GitApiClientProvider is missing. Pass a client or wrap your tree in the provider.");
|
|
14
|
+
}
|
|
15
|
+
return resolvedClient;
|
|
16
|
+
}
|
|
17
|
+
function normalizeQueryKey(value) {
|
|
18
|
+
return JSON.stringify(value);
|
|
19
|
+
}
|
|
20
|
+
function useGitApiQuery(input) {
|
|
21
|
+
const client = useGitApiClient(input.client);
|
|
22
|
+
const enabled = input.enabled !== false;
|
|
23
|
+
const loadRef = useRef(input.load);
|
|
24
|
+
loadRef.current = input.load;
|
|
25
|
+
const queryKey = normalizeQueryKey(input.key);
|
|
26
|
+
const [data, setData] = useState(input.initialData ?? null);
|
|
27
|
+
const [error, setError] = useState(null);
|
|
28
|
+
const [loading, setLoading] = useState(enabled);
|
|
29
|
+
const [reloadNonce, setReloadNonce] = useState(0);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!enabled) {
|
|
32
|
+
setLoading(false);
|
|
33
|
+
setError(null);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const controller = new AbortController();
|
|
37
|
+
let canceled = false;
|
|
38
|
+
setLoading(true);
|
|
39
|
+
setError(null);
|
|
40
|
+
void loadRef.current(client, controller.signal)
|
|
41
|
+
.then((nextData) => {
|
|
42
|
+
if (canceled)
|
|
43
|
+
return;
|
|
44
|
+
startTransition(() => {
|
|
45
|
+
setData(nextData);
|
|
46
|
+
setLoading(false);
|
|
47
|
+
});
|
|
48
|
+
})
|
|
49
|
+
.catch((nextError) => {
|
|
50
|
+
if (canceled)
|
|
51
|
+
return;
|
|
52
|
+
if (nextError instanceof Error && nextError.name === "AbortError")
|
|
53
|
+
return;
|
|
54
|
+
startTransition(() => {
|
|
55
|
+
setError(nextError instanceof Error ? nextError : new Error(String(nextError)));
|
|
56
|
+
setLoading(false);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
return () => {
|
|
60
|
+
canceled = true;
|
|
61
|
+
controller.abort();
|
|
62
|
+
};
|
|
63
|
+
}, [client, enabled, queryKey, reloadNonce]);
|
|
64
|
+
return {
|
|
65
|
+
data,
|
|
66
|
+
error,
|
|
67
|
+
loading,
|
|
68
|
+
reload() {
|
|
69
|
+
setReloadNonce((value) => value + 1);
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export { GitApiClientProvider, useGitApiClient, useGitApiQuery };
|
|
74
|
+
//# sourceMappingURL=query.js.map
|