@leed-ai/git-gateway-contract 0.0.0-stage → 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/LICENSE +201 -0
- package/README.md +50 -2
- package/dist/behaviour/assertions.d.ts +23 -0
- package/dist/behaviour/assertions.js +56 -0
- package/dist/behaviour/assertions.js.map +1 -0
- package/dist/behaviour/behaviour-case.d.ts +19 -0
- package/dist/behaviour/behaviour-case.js +12 -0
- package/dist/behaviour/behaviour-case.js.map +1 -0
- package/dist/behaviour/behaviour-suite.d.ts +30 -0
- package/dist/behaviour/behaviour-suite.js +50 -0
- package/dist/behaviour/behaviour-suite.js.map +1 -0
- package/dist/behaviour/commit-action-cases.d.ts +4 -0
- package/dist/behaviour/commit-action-cases.js +342 -0
- package/dist/behaviour/commit-action-cases.js.map +1 -0
- package/dist/behaviour/commit-write-cases.d.ts +4 -0
- package/dist/behaviour/commit-write-cases.js +234 -0
- package/dist/behaviour/commit-write-cases.js.map +1 -0
- package/dist/behaviour/fixtures.d.ts +29 -0
- package/dist/behaviour/fixtures.js +83 -0
- package/dist/behaviour/fixtures.js.map +1 -0
- package/dist/behaviour/lifecycle-cases.d.ts +4 -0
- package/dist/behaviour/lifecycle-cases.js +158 -0
- package/dist/behaviour/lifecycle-cases.js.map +1 -0
- package/dist/behaviour/promote-cases.d.ts +4 -0
- package/dist/behaviour/promote-cases.js +122 -0
- package/dist/behaviour/promote-cases.js.map +1 -0
- package/dist/behaviour/read-cases.d.ts +4 -0
- package/dist/behaviour/read-cases.js +248 -0
- package/dist/behaviour/read-cases.js.map +1 -0
- package/dist/behaviour/sync-cases.d.ts +4 -0
- package/dist/behaviour/sync-cases.js +205 -0
- package/dist/behaviour/sync-cases.js.map +1 -0
- package/dist/clock-B3MlpmVY.d.ts +10 -0
- package/dist/commit-BEZmeAOl.d.ts +23 -0
- package/dist/file-map-CxUveLWz.d.ts +18 -0
- package/dist/gateway-config-oVsdTEeK.d.ts +39 -0
- package/dist/gateway-error-body-BWzZFAQI.d.ts +214 -0
- package/dist/gateway-error.d.ts +30 -0
- package/dist/gateway-error.js +63 -0
- package/dist/gateway-error.js.map +1 -0
- package/dist/git-gateway-VA9Tc5tn.d.ts +358 -0
- package/dist/git-gateway.d.ts +2 -0
- package/dist/git-gateway.js +65 -0
- package/dist/git-gateway.js.map +1 -0
- package/dist/health.d.ts +9 -0
- package/dist/health.js +18 -0
- package/dist/health.js.map +1 -0
- package/dist/history-CqvHaUE-.d.ts +20 -0
- package/dist/package-name.d.ts +3 -0
- package/dist/package-name.js +6 -0
- package/dist/package-name.js.map +1 -0
- package/dist/proxy/audit-event.d.ts +61 -0
- package/dist/proxy/audit-event.js +97 -0
- package/dist/proxy/audit-event.js.map +1 -0
- package/dist/proxy/branch-rule.d.ts +72 -0
- package/dist/proxy/branch-rule.js +106 -0
- package/dist/proxy/branch-rule.js.map +1 -0
- package/dist/proxy/gateway-hooks.d.ts +58 -0
- package/dist/proxy/gateway-hooks.js +0 -0
- package/dist/proxy/git-operation.d.ts +17 -0
- package/dist/proxy/git-operation.js +32 -0
- package/dist/proxy/git-operation.js.map +1 -0
- package/dist/proxy/policy-result.d.ts +51 -0
- package/dist/proxy/policy-result.js +90 -0
- package/dist/proxy/policy-result.js.map +1 -0
- package/dist/proxy/principal.d.ts +18 -0
- package/dist/proxy/principal.js +32 -0
- package/dist/proxy/principal.js.map +1 -0
- package/dist/proxy/push-policy-result.d.ts +34 -0
- package/dist/proxy/push-policy-result.js +48 -0
- package/dist/proxy/push-policy-result.js.map +1 -0
- package/dist/proxy/push-policy.d.ts +146 -0
- package/dist/proxy/push-policy.js +112 -0
- package/dist/proxy/push-policy.js.map +1 -0
- package/dist/proxy/request-credential.d.ts +22 -0
- package/dist/proxy/request-credential.js +46 -0
- package/dist/proxy/request-credential.js.map +1 -0
- package/dist/proxy/smart-http-config.d.ts +22 -0
- package/dist/proxy/smart-http-config.js +40 -0
- package/dist/proxy/smart-http-config.js.map +1 -0
- package/dist/reference/apply-actions.d.ts +9 -0
- package/dist/reference/apply-actions.js +84 -0
- package/dist/reference/apply-actions.js.map +1 -0
- package/dist/reference/branch-methods.d.ts +7 -0
- package/dist/reference/branch-methods.js +105 -0
- package/dist/reference/branch-methods.js.map +1 -0
- package/dist/reference/bytes.d.ts +22 -0
- package/dist/reference/bytes.js +62 -0
- package/dist/reference/bytes.js.map +1 -0
- package/dist/reference/clock.d.ts +2 -0
- package/dist/reference/clock.js +18 -0
- package/dist/reference/clock.js.map +1 -0
- package/dist/reference/commit-method.d.ts +5 -0
- package/dist/reference/commit-method.js +83 -0
- package/dist/reference/commit-method.js.map +1 -0
- package/dist/reference/file-map.d.ts +2 -0
- package/dist/reference/file-map.js +24 -0
- package/dist/reference/file-map.js.map +1 -0
- package/dist/reference/hash.d.ts +10 -0
- package/dist/reference/hash.js +25 -0
- package/dist/reference/hash.js.map +1 -0
- package/dist/reference/history.d.ts +2 -0
- package/dist/reference/history.js +65 -0
- package/dist/reference/history.js.map +1 -0
- package/dist/reference/lifecycle-methods.d.ts +9 -0
- package/dist/reference/lifecycle-methods.js +48 -0
- package/dist/reference/lifecycle-methods.js.map +1 -0
- package/dist/reference/read-methods.d.ts +13 -0
- package/dist/reference/read-methods.js +68 -0
- package/dist/reference/read-methods.js.map +1 -0
- package/dist/reference/reference-gateway.d.ts +18 -0
- package/dist/reference/reference-gateway.js +35 -0
- package/dist/reference/reference-gateway.js.map +1 -0
- package/dist/reference/repo-state.d.ts +43 -0
- package/dist/reference/repo-state.js +45 -0
- package/dist/reference/repo-state.js.map +1 -0
- package/dist/reference/run-method.d.ts +13 -0
- package/dist/reference/run-method.js +15 -0
- package/dist/reference/run-method.js.map +1 -0
- package/dist/reference/three-way-merge.d.ts +16 -0
- package/dist/reference/three-way-merge.js +45 -0
- package/dist/reference/three-way-merge.js.map +1 -0
- package/dist/reference/trailer.d.ts +7 -0
- package/dist/reference/trailer.js +16 -0
- package/dist/reference/trailer.js.map +1 -0
- package/dist/reference/tree-index.d.ts +2 -0
- package/dist/reference/tree-index.js +66 -0
- package/dist/reference/tree-index.js.map +1 -0
- package/dist/reference/write-commit.d.ts +15 -0
- package/dist/reference/write-commit.js +44 -0
- package/dist/reference/write-commit.js.map +1 -0
- package/dist/rpc/commit-exists.d.ts +16 -0
- package/dist/rpc/commit-exists.js +30 -0
- package/dist/rpc/commit-exists.js.map +1 -0
- package/dist/rpc/commit.d.ts +172 -0
- package/dist/rpc/commit.js +115 -0
- package/dist/rpc/commit.js.map +1 -0
- package/dist/rpc/list-tree.d.ts +59 -0
- package/dist/rpc/list-tree.js +54 -0
- package/dist/rpc/list-tree.js.map +1 -0
- package/dist/rpc/log.d.ts +35 -0
- package/dist/rpc/log.js +41 -0
- package/dist/rpc/log.js.map +1 -0
- package/dist/rpc/mint-read-token.d.ts +17 -0
- package/dist/rpc/mint-read-token.js +36 -0
- package/dist/rpc/mint-read-token.js.map +1 -0
- package/dist/rpc/promote.d.ts +39 -0
- package/dist/rpc/promote.js +69 -0
- package/dist/rpc/promote.js.map +1 -0
- package/dist/rpc/read-file.d.ts +44 -0
- package/dist/rpc/read-file.js +56 -0
- package/dist/rpc/read-file.js.map +1 -0
- package/dist/rpc/repo-lifecycle.d.ts +39 -0
- package/dist/rpc/repo-lifecycle.js +64 -0
- package/dist/rpc/repo-lifecycle.js.map +1 -0
- package/dist/rpc/resolve-ref.d.ts +15 -0
- package/dist/rpc/resolve-ref.js +28 -0
- package/dist/rpc/resolve-ref.js.map +1 -0
- package/dist/rpc/sync-branch.d.ts +107 -0
- package/dist/rpc/sync-branch.js +114 -0
- package/dist/rpc/sync-branch.js.map +1 -0
- package/dist/schemas/commit-action.d.ts +100 -0
- package/dist/schemas/commit-action.js +138 -0
- package/dist/schemas/commit-action.js.map +1 -0
- package/dist/schemas/commit.d.ts +2 -0
- package/dist/schemas/commit.js +24 -0
- package/dist/schemas/commit.js.map +1 -0
- package/dist/schemas/content-encoding.d.ts +24 -0
- package/dist/schemas/content-encoding.js +41 -0
- package/dist/schemas/content-encoding.js.map +1 -0
- package/dist/schemas/examples.d.ts +38 -0
- package/dist/schemas/examples.js +32 -0
- package/dist/schemas/examples.js.map +1 -0
- package/dist/schemas/gateway-config.d.ts +2 -0
- package/dist/schemas/gateway-config.js +72 -0
- package/dist/schemas/gateway-config.js.map +1 -0
- package/dist/schemas/gateway-error-body.d.ts +2 -0
- package/dist/schemas/gateway-error-body.js +188 -0
- package/dist/schemas/gateway-error-body.js.map +1 -0
- package/dist/schemas/identity.d.ts +21 -0
- package/dist/schemas/identity.js +40 -0
- package/dist/schemas/identity.js.map +1 -0
- package/dist/schemas/names.d.ts +26 -0
- package/dist/schemas/names.js +58 -0
- package/dist/schemas/names.js.map +1 -0
- package/dist/schemas/ref-update.d.ts +10 -0
- package/dist/schemas/ref-update.js +25 -0
- package/dist/schemas/ref-update.js.map +1 -0
- package/dist/schemas/sha.d.ts +8 -0
- package/dist/schemas/sha.js +14 -0
- package/dist/schemas/sha.js.map +1 -0
- package/dist/schemas/tree-entry.d.ts +2 -0
- package/dist/schemas/tree-entry.js +62 -0
- package/dist/schemas/tree-entry.js.map +1 -0
- package/dist/storage/git-remote.d.ts +17 -0
- package/dist/storage/git-remote.js +31 -0
- package/dist/storage/git-remote.js.map +1 -0
- package/dist/storage/storage-backend.d.ts +61 -0
- package/dist/storage/storage-backend.js +0 -0
- package/dist/storage/storage-errors.d.ts +12 -0
- package/dist/storage/storage-errors.js +22 -0
- package/dist/storage/storage-errors.js.map +1 -0
- package/dist/storage/storage-input.d.ts +7 -0
- package/dist/storage/storage-input.js +14 -0
- package/dist/storage/storage-input.js.map +1 -0
- package/dist/storage/storage-read.d.ts +13 -0
- package/dist/storage/storage-read.js +30 -0
- package/dist/storage/storage-read.js.map +1 -0
- package/dist/storage/storage-repo-info.d.ts +16 -0
- package/dist/storage/storage-repo-info.js +30 -0
- package/dist/storage/storage-repo-info.js.map +1 -0
- package/dist/storage/storage-tree-entry.d.ts +21 -0
- package/dist/storage/storage-tree-entry.js +17 -0
- package/dist/storage/storage-tree-entry.js.map +1 -0
- package/dist/tree-entry-BM_1gou1.d.ts +41 -0
- package/dist/tree-index-Bk721Phv.d.ts +14 -0
- package/package.json +401 -4
- package/src/behaviour/assertions.ts +75 -0
- package/src/behaviour/behaviour-case.ts +28 -0
- package/src/behaviour/behaviour-suite.ts +76 -0
- package/src/behaviour/commit-action-cases.ts +253 -0
- package/src/behaviour/commit-write-cases.ts +205 -0
- package/src/behaviour/fixtures.ts +103 -0
- package/src/behaviour/lifecycle-cases.ts +104 -0
- package/src/behaviour/promote-cases.ts +78 -0
- package/src/behaviour/read-cases.ts +176 -0
- package/src/behaviour/sync-cases.ts +156 -0
- package/src/gateway-error.ts +72 -0
- package/src/git-gateway.ts +76 -0
- package/src/health.ts +26 -0
- package/src/package-name.ts +4 -0
- package/src/proxy/audit-event.ts +135 -0
- package/src/proxy/branch-rule.ts +190 -0
- package/src/proxy/gateway-hooks.ts +67 -0
- package/src/proxy/git-operation.ts +36 -0
- package/src/proxy/policy-result.ts +127 -0
- package/src/proxy/principal.ts +81 -0
- package/src/proxy/push-policy-result.ts +86 -0
- package/src/proxy/push-policy.ts +158 -0
- package/src/proxy/request-credential.ts +47 -0
- package/src/proxy/smart-http-config.ts +158 -0
- package/src/reference/apply-actions.ts +96 -0
- package/src/reference/branch-methods.ts +105 -0
- package/src/reference/bytes.ts +66 -0
- package/src/reference/clock.ts +19 -0
- package/src/reference/commit-method.ts +97 -0
- package/src/reference/file-map.ts +35 -0
- package/src/reference/hash.ts +25 -0
- package/src/reference/history.ts +78 -0
- package/src/reference/lifecycle-methods.ts +52 -0
- package/src/reference/read-methods.ts +87 -0
- package/src/reference/reference-gateway.ts +50 -0
- package/src/reference/repo-state.ts +83 -0
- package/src/reference/run-method.ts +25 -0
- package/src/reference/three-way-merge.ts +42 -0
- package/src/reference/trailer.ts +18 -0
- package/src/reference/tree-index.ts +65 -0
- package/src/reference/write-commit.ts +44 -0
- package/src/rpc/commit-exists.ts +46 -0
- package/src/rpc/commit.ts +156 -0
- package/src/rpc/list-tree.ts +78 -0
- package/src/rpc/log.ts +51 -0
- package/src/rpc/mint-read-token.ts +59 -0
- package/src/rpc/promote.ts +72 -0
- package/src/rpc/read-file.ts +75 -0
- package/src/rpc/repo-lifecycle.ts +103 -0
- package/src/rpc/resolve-ref.ts +41 -0
- package/src/rpc/sync-branch.ts +149 -0
- package/src/schemas/commit-action.ts +157 -0
- package/src/schemas/commit.ts +43 -0
- package/src/schemas/content-encoding.ts +58 -0
- package/src/schemas/examples.ts +24 -0
- package/src/schemas/gateway-config.ts +116 -0
- package/src/schemas/gateway-error-body.ts +230 -0
- package/src/schemas/identity.ts +57 -0
- package/src/schemas/names.ts +126 -0
- package/src/schemas/ref-update.ts +38 -0
- package/src/schemas/sha.ts +20 -0
- package/src/schemas/tree-entry.ts +72 -0
- package/src/storage/git-remote.ts +58 -0
- package/src/storage/storage-backend.ts +65 -0
- package/src/storage/storage-errors.ts +24 -0
- package/src/storage/storage-input.ts +14 -0
- package/src/storage/storage-read.ts +45 -0
- package/src/storage/storage-repo-info.ts +46 -0
- package/src/storage/storage-tree-entry.ts +20 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/schemas/examples.ts
|
|
2
|
+
/** Example values shared by the schemas' `examples` metadata, so examples agree with each other. */
|
|
3
|
+
const EXAMPLE_SHA_A = "1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d";
|
|
4
|
+
/** A second example commit id. */
|
|
5
|
+
const EXAMPLE_SHA_B = "8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a";
|
|
6
|
+
/** An example tree id (git's empty tree). */
|
|
7
|
+
const EXAMPLE_TREE = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
|
|
8
|
+
/** An example identity. */
|
|
9
|
+
const EXAMPLE_IDENTITY = {
|
|
10
|
+
name: "Ada Lovelace",
|
|
11
|
+
email: "ada@example.com"
|
|
12
|
+
};
|
|
13
|
+
/** An example timestamp. */
|
|
14
|
+
const EXAMPLE_TIMESTAMP = "2026-11-20T09:30:00.000Z";
|
|
15
|
+
/** An example signature. */
|
|
16
|
+
const EXAMPLE_SIGNATURE = {
|
|
17
|
+
...EXAMPLE_IDENTITY,
|
|
18
|
+
date: EXAMPLE_TIMESTAMP
|
|
19
|
+
};
|
|
20
|
+
/** An example stored commit. */
|
|
21
|
+
const EXAMPLE_COMMIT = {
|
|
22
|
+
sha: EXAMPLE_SHA_B,
|
|
23
|
+
tree: EXAMPLE_TREE,
|
|
24
|
+
parents: [EXAMPLE_SHA_A],
|
|
25
|
+
author: EXAMPLE_SIGNATURE,
|
|
26
|
+
committer: EXAMPLE_SIGNATURE,
|
|
27
|
+
message: "Update about page\n\nGateway-Idempotency-Key: cms:publish:2f9c1e\n",
|
|
28
|
+
idempotencyKey: "cms:publish:2f9c1e"
|
|
29
|
+
};
|
|
30
|
+
export { EXAMPLE_COMMIT, EXAMPLE_IDENTITY, EXAMPLE_SHA_A, EXAMPLE_SHA_B, EXAMPLE_SIGNATURE, EXAMPLE_TIMESTAMP, EXAMPLE_TREE };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=examples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"examples.js","names":[],"sources":["../../src/schemas/examples.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/** Example values shared by the schemas' `examples` metadata, so examples agree with each other. */\nexport const EXAMPLE_SHA_A = '1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d';\n/** A second example commit id. */\nexport const EXAMPLE_SHA_B = '8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a';\n/** An example tree id (git's empty tree). */\nexport const EXAMPLE_TREE = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';\n/** An example identity. */\nexport const EXAMPLE_IDENTITY = { name: 'Ada Lovelace', email: 'ada@example.com' };\n/** An example timestamp. */\nexport const EXAMPLE_TIMESTAMP = '2026-11-20T09:30:00.000Z';\n/** An example signature. */\nexport const EXAMPLE_SIGNATURE = { ...EXAMPLE_IDENTITY, date: EXAMPLE_TIMESTAMP };\n/** An example stored commit. */\nexport const EXAMPLE_COMMIT = {\n sha: EXAMPLE_SHA_B,\n tree: EXAMPLE_TREE,\n parents: [EXAMPLE_SHA_A],\n author: EXAMPLE_SIGNATURE,\n committer: EXAMPLE_SIGNATURE,\n message: 'Update about page\\n\\nGateway-Idempotency-Key: cms:publish:2f9c1e\\n',\n idempotencyKey: 'cms:publish:2f9c1e',\n};\n"],"mappings":";;AAGA,MAAa,gBAAgB;;AAE7B,MAAa,gBAAgB;;AAE7B,MAAa,eAAe;;AAE5B,MAAa,mBAAmB;CAAE,MAAM;CAAgB,OAAO;AAAkB;;AAEjF,MAAa,oBAAoB;;AAEjC,MAAa,oBAAoB;CAAE,GAAG;CAAkB,MAAM;AAAkB;;AAEhF,MAAa,iBAAiB;CAC5B,KAAK;CACL,MAAM;CACN,SAAS,CAAC,aAAa;CACvB,QAAQ;CACR,WAAW;CACX,SAAS;CACT,gBAAgB;AAClB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Identity } from "./identity.js";
|
|
2
|
+
import { BranchName } from "./names.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
// src/schemas/gateway-config.ts
|
|
5
|
+
/** How far back `commit()` looks for a commit carrying the same idempotency key. */
|
|
6
|
+
const IdempotencyConfig = z.object({
|
|
7
|
+
maxCommits: z.int().min(1).max(1e4).default(200).describe("Most commits of the branch history examined, newest first; 1–10000, default 200."),
|
|
8
|
+
maxAgeSeconds: z.int().min(60).max(2592e3).default(604800).describe("Commits committed longer ago than this many seconds are not examined; 60 s–30 days, default 7 days (604800).")
|
|
9
|
+
}).strict().meta({
|
|
10
|
+
id: "IdempotencyConfig",
|
|
11
|
+
title: "Idempotency window",
|
|
12
|
+
description: "How far back commit() looks through the target branch for a commit carrying the same idempotency key. Both bounds apply; the lookup stops at whichever is reached first.",
|
|
13
|
+
examples: [{
|
|
14
|
+
maxCommits: 200,
|
|
15
|
+
maxAgeSeconds: 604800
|
|
16
|
+
}]
|
|
17
|
+
});
|
|
18
|
+
/** An automatic sync run after every push to a branch. */
|
|
19
|
+
const SyncRule = z.object({
|
|
20
|
+
from: BranchName.describe("The branch whose pushes trigger the sync."),
|
|
21
|
+
into: BranchName.describe("The branch brought up to date with `from` by syncBranch.")
|
|
22
|
+
}).strict().refine((rule) => rule.from !== rule.into, {
|
|
23
|
+
message: "from and into must differ",
|
|
24
|
+
path: ["into"]
|
|
25
|
+
}).meta({
|
|
26
|
+
id: "SyncRule",
|
|
27
|
+
title: "Sync rule",
|
|
28
|
+
description: "An onPush rule: after any push to `from`, run syncBranch({ from, into }) as a SyncBranchWorkflow with retries.",
|
|
29
|
+
examples: [{
|
|
30
|
+
from: "main",
|
|
31
|
+
into: "staging"
|
|
32
|
+
}]
|
|
33
|
+
});
|
|
34
|
+
/** Settings shared by every gateway implementation of the RPC contract. */
|
|
35
|
+
const GatewayConfig = z.object({
|
|
36
|
+
publicBaseUrl: z.url({ protocol: /^https?$/ }).default("https://git.example.com").describe("Origin (and optional path prefix) repositories are served under, without a trailing slash; a repository is at <publicBaseUrl>/<repo>.git. Default https://git.example.com."),
|
|
37
|
+
serviceIdentity: Identity.default({
|
|
38
|
+
name: "git-gateway",
|
|
39
|
+
email: "git-gateway@noreply.invalid"
|
|
40
|
+
}).describe("Author and committer of commits the gateway makes on its own behalf (sync merges) when the caller names none. Default git-gateway <git-gateway@noreply.invalid>."),
|
|
41
|
+
idempotency: IdempotencyConfig.default({
|
|
42
|
+
maxCommits: 200,
|
|
43
|
+
maxAgeSeconds: 604800
|
|
44
|
+
}).describe("Idempotency lookback window; defaults to 200 commits or 7 days."),
|
|
45
|
+
inlineRetries: z.int().min(0).max(10).default(3).describe("Times a write is rebuilt and retried inline after a stale-head refusal before it is handed to a Workflow; 0–10, default 3."),
|
|
46
|
+
authCacheSeconds: z.int().min(0).max(3600).default(60).describe("Seconds an authentication and authorization decision is cached per principal and repository; 0 disables caching; at most 3600, default 60."),
|
|
47
|
+
syncRules: z.array(SyncRule).max(50).default([]).describe("Branch syncs started after every accepted push to a rule's `from` branch, through the smart-HTTP proxy or an RPC write. The worker starts each as a SyncBranchWorkflow and refuses to start without that Workflow binding when any rule is set; the in-memory reference has no push hooks and ignores them. At most 50, default none.")
|
|
48
|
+
}).strict().meta({
|
|
49
|
+
id: "GatewayConfig",
|
|
50
|
+
title: "Gateway configuration",
|
|
51
|
+
description: "Settings shared by every implementation of the RPC contract, the real gateway and the in-memory reference alike. Every field has a default, so {} is a complete configuration.",
|
|
52
|
+
examples: [{
|
|
53
|
+
publicBaseUrl: "https://git.example.com",
|
|
54
|
+
serviceIdentity: {
|
|
55
|
+
name: "git-gateway",
|
|
56
|
+
email: "git-gateway@noreply.invalid"
|
|
57
|
+
},
|
|
58
|
+
idempotency: {
|
|
59
|
+
maxCommits: 200,
|
|
60
|
+
maxAgeSeconds: 604800
|
|
61
|
+
},
|
|
62
|
+
inlineRetries: 3,
|
|
63
|
+
authCacheSeconds: 60,
|
|
64
|
+
syncRules: [{
|
|
65
|
+
from: "main",
|
|
66
|
+
into: "staging"
|
|
67
|
+
}]
|
|
68
|
+
}]
|
|
69
|
+
});
|
|
70
|
+
export { GatewayConfig, IdempotencyConfig, SyncRule };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=gateway-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-config.js","names":[],"sources":["../../src/schemas/gateway-config.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { z } from 'zod';\n\nimport { Identity } from './identity.ts';\nimport { BranchName } from './names.ts';\n\n/** How far back `commit()` looks for a commit carrying the same idempotency key. */\nexport const IdempotencyConfig = z\n .object({\n maxCommits: z\n .int()\n .min(1)\n .max(10_000)\n .default(200)\n .describe('Most commits of the branch history examined, newest first; 1–10000, default 200.'),\n maxAgeSeconds: z\n .int()\n .min(60)\n .max(30 * 24 * 3600)\n .default(7 * 24 * 3600)\n .describe(\n 'Commits committed longer ago than this many seconds are not examined; 60 s–30 days, default 7 days (604800).',\n ),\n })\n .strict()\n .meta({\n id: 'IdempotencyConfig',\n title: 'Idempotency window',\n description:\n 'How far back commit() looks through the target branch for a commit carrying the same idempotency key. Both bounds apply; the lookup stops at whichever is reached first.',\n examples: [{ maxCommits: 200, maxAgeSeconds: 604_800 }],\n });\n\n/** An idempotency window, inferred from {@link IdempotencyConfig}. */\nexport type IdempotencyConfig = z.infer<typeof IdempotencyConfig>;\n\n/** An automatic sync run after every push to a branch. */\nexport const SyncRule = z\n .object({\n from: BranchName.describe('The branch whose pushes trigger the sync.'),\n into: BranchName.describe('The branch brought up to date with `from` by syncBranch.'),\n })\n .strict()\n .refine((rule) => rule.from !== rule.into, { message: 'from and into must differ', path: ['into'] })\n .meta({\n id: 'SyncRule',\n title: 'Sync rule',\n description:\n 'An onPush rule: after any push to `from`, run syncBranch({ from, into }) as a SyncBranchWorkflow with retries.',\n examples: [{ from: 'main', into: 'staging' }],\n });\n\n/** An automatic sync rule, inferred from {@link SyncRule}. */\nexport type SyncRule = z.infer<typeof SyncRule>;\n\n/** Settings shared by every gateway implementation of the RPC contract. */\nexport const GatewayConfig = z\n .object({\n publicBaseUrl: z\n .url({ protocol: /^https?$/ })\n .default('https://git.example.com')\n .describe(\n 'Origin (and optional path prefix) repositories are served under, without a trailing slash; a repository is at <publicBaseUrl>/<repo>.git. Default https://git.example.com.',\n ),\n serviceIdentity: Identity.default({ name: 'git-gateway', email: 'git-gateway@noreply.invalid' }).describe(\n 'Author and committer of commits the gateway makes on its own behalf (sync merges) when the caller names none. Default git-gateway <git-gateway@noreply.invalid>.',\n ),\n idempotency: IdempotencyConfig.default({ maxCommits: 200, maxAgeSeconds: 604_800 }).describe(\n 'Idempotency lookback window; defaults to 200 commits or 7 days.',\n ),\n inlineRetries: z\n .int()\n .min(0)\n .max(10)\n .default(3)\n .describe(\n 'Times a write is rebuilt and retried inline after a stale-head refusal before it is handed to a Workflow; 0–10, default 3.',\n ),\n authCacheSeconds: z\n .int()\n .min(0)\n .max(3600)\n .default(60)\n .describe(\n 'Seconds an authentication and authorization decision is cached per principal and repository; 0 disables caching; at most 3600, default 60.',\n ),\n syncRules: z\n .array(SyncRule)\n .max(50)\n .default([])\n .describe(\n \"Branch syncs started after every accepted push to a rule's `from` branch, through the smart-HTTP proxy or an RPC write. The worker starts each as a SyncBranchWorkflow and refuses to start without that Workflow binding when any rule is set; the in-memory reference has no push hooks and ignores them. At most 50, default none.\",\n ),\n })\n .strict()\n .meta({\n id: 'GatewayConfig',\n title: 'Gateway configuration',\n description:\n 'Settings shared by every implementation of the RPC contract, the real gateway and the in-memory reference alike. Every field has a default, so {} is a complete configuration.',\n examples: [\n {\n publicBaseUrl: 'https://git.example.com',\n serviceIdentity: { name: 'git-gateway', email: 'git-gateway@noreply.invalid' },\n idempotency: { maxCommits: 200, maxAgeSeconds: 604_800 },\n inlineRetries: 3,\n authCacheSeconds: 60,\n syncRules: [{ from: 'main', into: 'staging' }],\n },\n ],\n });\n\n/** A gateway configuration as written (defaults optional). */\nexport type GatewayConfigInput = z.input<typeof GatewayConfig>;\n/** A complete gateway configuration, inferred from {@link GatewayConfig}. */\nexport type GatewayConfig = z.output<typeof GatewayConfig>;\n"],"mappings":";;;;;AAOA,MAAa,oBAAoB,EAC9B,OAAO;CACN,YAAY,EACT,IAAI,CAAC,CACL,IAAI,CAAC,CAAC,CACN,IAAI,GAAM,CAAC,CACX,QAAQ,GAAG,CAAC,CACZ,SAAS,kFAAkF;CAC9F,eAAe,EACZ,IAAI,CAAC,CACL,IAAI,EAAE,CAAC,CACP,IAAI,MAAc,CAAC,CACnB,QAAQ,MAAa,CAAC,CACtB,SACC,8GACF;AACJ,CAAC,CAAC,CACD,OAAO,CAAC,CACR,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aACE;CACF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e;EAAQ;EACvD,eAAe;EACf,kBAAkB;EAClB,WAAW,CAAC;GAAE,MAAM;GAAQ,MAAM;EAAU,CAAC;CAC/C,CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as NotHeadOfSourceError, c as PathNotFoundError, d as RepoNotFoundError, f as StaleHeadError, i as NotFastForwardError, l as RefNotFoundError, m as UnrelatedHistoriesError, n as GatewayErrorCode, o as PathConflictError, p as StorageUnavailableError, r as InvalidInputError, s as PathExistsError, t as GatewayErrorBody, u as RepoExistsError } from "../gateway-error-body-BWzZFAQI.js";
|
|
2
|
+
export { GatewayErrorBody, GatewayErrorCode, InvalidInputError, NotFastForwardError, NotHeadOfSourceError, PathConflictError, PathExistsError, PathNotFoundError, RefNotFoundError, RepoExistsError, RepoNotFoundError, StaleHeadError, StorageUnavailableError, UnrelatedHistoriesError };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { BranchName, FilePath, RepoName, Revision } from "./names.js";
|
|
2
|
+
import { Sha } from "./sha.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
// src/schemas/gateway-error-body.ts
|
|
5
|
+
const message = z.string().min(1).describe("Human-readable explanation, safe to show to an end user.");
|
|
6
|
+
const repo = RepoName.describe("The repository the call named.");
|
|
7
|
+
/** Builds one error variant: a code literal, a message and typed details. */
|
|
8
|
+
function variant(code, meaning, details, example) {
|
|
9
|
+
return z.object({
|
|
10
|
+
code: z.literal(code).describe(meaning),
|
|
11
|
+
message,
|
|
12
|
+
details: z.object(details).strict().describe(`Machine-readable facts about the ${code} error.`)
|
|
13
|
+
}).strict().meta({
|
|
14
|
+
id: `GatewayError.${code}`,
|
|
15
|
+
title: `${code} error`,
|
|
16
|
+
description: meaning,
|
|
17
|
+
examples: [{
|
|
18
|
+
code,
|
|
19
|
+
...example
|
|
20
|
+
}]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const PATH_EXAMPLE = { path: "content/about.md" };
|
|
24
|
+
const SHA_A = "1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d";
|
|
25
|
+
const SHA_B = "8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a";
|
|
26
|
+
/** The input failed schema validation. */
|
|
27
|
+
const InvalidInputError = variant("invalid_input", "The call input failed schema validation; nothing was read or written.", { issues: z.array(z.object({
|
|
28
|
+
path: z.string().describe("Dot-separated location of the bad value in the input; empty for the root."),
|
|
29
|
+
message: z.string().min(1).describe("What is wrong with the value.")
|
|
30
|
+
}).strict().describe("One validation failure.")).min(1).describe("Every validation failure found.") }, {
|
|
31
|
+
message: "Invalid input",
|
|
32
|
+
details: { issues: [{
|
|
33
|
+
path: "branch",
|
|
34
|
+
message: "Required"
|
|
35
|
+
}] }
|
|
36
|
+
});
|
|
37
|
+
/** The named repository does not exist. */
|
|
38
|
+
const RepoNotFoundError = variant("repo_not_found", "The named repository does not exist.", { repo }, {
|
|
39
|
+
message: "Repository not found",
|
|
40
|
+
details: { repo: "acme" }
|
|
41
|
+
});
|
|
42
|
+
/** A repository with that name already exists. */
|
|
43
|
+
const RepoExistsError = variant("repo_exists", "createRepo named a repository that already exists; it is left unchanged.", { repo }, {
|
|
44
|
+
message: "Repository already exists",
|
|
45
|
+
details: { repo: "acme" }
|
|
46
|
+
});
|
|
47
|
+
/** The named branch or commit does not exist. */
|
|
48
|
+
const RefNotFoundError = variant("ref_not_found", "A branch or commit the call named does not exist in the repository.", { ref: Revision.describe("The branch name or commit id that was not found.") }, {
|
|
49
|
+
message: "Branch not found: staging",
|
|
50
|
+
details: { ref: "staging" }
|
|
51
|
+
});
|
|
52
|
+
/** A create or move target already exists. */
|
|
53
|
+
const PathExistsError = variant("path_exists", "A create, upsert or move action targeted a path that is already a file or a directory.", { path: FilePath.describe("The path that already exists.") }, {
|
|
54
|
+
message: "File already exists",
|
|
55
|
+
details: PATH_EXAMPLE
|
|
56
|
+
});
|
|
57
|
+
/** An action needed a file that does not exist. */
|
|
58
|
+
const PathNotFoundError = variant("path_not_found", "An update, delete, move or chmod action named a path that is not a file.", { path: FilePath.describe("The path that is not a file.") }, {
|
|
59
|
+
message: "File not found",
|
|
60
|
+
details: PATH_EXAMPLE
|
|
61
|
+
});
|
|
62
|
+
/** A parent of the target path is a file. */
|
|
63
|
+
const PathConflictError = variant("path_conflict", "An action would place a file beneath a path that is itself a file.", {
|
|
64
|
+
path: FilePath.describe("The path the action targeted."),
|
|
65
|
+
conflictingPath: FilePath.describe("The parent of `path` that is a file.")
|
|
66
|
+
}, {
|
|
67
|
+
message: "A parent of the path is a file",
|
|
68
|
+
details: {
|
|
69
|
+
path: "a/b.md",
|
|
70
|
+
conflictingPath: "a"
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
/** The branch head is not the head the caller expected. */
|
|
74
|
+
const StaleHeadError = variant("stale_head", "The branch head is not the head the caller expected; nothing was written. Re-read and retry.", {
|
|
75
|
+
branch: BranchName.describe("The branch the write targeted."),
|
|
76
|
+
expectedHead: Sha.nullable().describe("The head the caller expected; null when it expected no branch."),
|
|
77
|
+
actualHead: Sha.nullable().describe("The current head; null when the branch does not exist.")
|
|
78
|
+
}, {
|
|
79
|
+
message: "Branch head moved",
|
|
80
|
+
details: {
|
|
81
|
+
branch: "main",
|
|
82
|
+
expectedHead: SHA_A,
|
|
83
|
+
actualHead: SHA_B
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
/** promote named a commit that is not the head of the source branch. */
|
|
87
|
+
const NotHeadOfSourceError = variant("not_head_of_source", "promote named a commit that is not the current head of the source branch; nothing moved.", {
|
|
88
|
+
from: BranchName.describe("The source branch."),
|
|
89
|
+
sha: Sha.describe("The commit the caller asked to promote."),
|
|
90
|
+
head: Sha.describe("The current head of the source branch.")
|
|
91
|
+
}, {
|
|
92
|
+
message: "Commit is not the head of staging",
|
|
93
|
+
details: {
|
|
94
|
+
from: "staging",
|
|
95
|
+
sha: SHA_A,
|
|
96
|
+
head: SHA_B
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
/** promote would not be a fast-forward. */
|
|
100
|
+
const NotFastForwardError = variant("not_fast_forward", "promote named a commit that does not contain the head of the target branch; nothing moved.", {
|
|
101
|
+
into: BranchName.describe("The target branch."),
|
|
102
|
+
sha: Sha.describe("The commit the caller asked to promote."),
|
|
103
|
+
head: Sha.describe("The current head of the target branch, which `sha` does not contain.")
|
|
104
|
+
}, {
|
|
105
|
+
message: "Not a fast-forward",
|
|
106
|
+
details: {
|
|
107
|
+
into: "main",
|
|
108
|
+
sha: SHA_A,
|
|
109
|
+
head: SHA_B
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
/** syncBranch found no common ancestor. */
|
|
113
|
+
const UnrelatedHistoriesError = variant("unrelated_histories", "syncBranch found no common ancestor between the branches, so there is nothing to merge against.", {
|
|
114
|
+
from: BranchName.describe("The branch being merged in."),
|
|
115
|
+
into: BranchName.describe("The branch being brought up to date.")
|
|
116
|
+
}, {
|
|
117
|
+
message: "Refusing to merge unrelated histories",
|
|
118
|
+
details: {
|
|
119
|
+
from: "main",
|
|
120
|
+
into: "staging"
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
/** The storage backend failed. */
|
|
124
|
+
const StorageUnavailableError = variant("storage_unavailable", "The storage backend failed or timed out; the call may be retried with the same input.", { retryable: z.literal(true).describe("Always true: the same call may succeed later.") }, {
|
|
125
|
+
message: "Storage backend unavailable",
|
|
126
|
+
details: { retryable: true }
|
|
127
|
+
});
|
|
128
|
+
/** Every error a gateway call can report, discriminated by `code`. */
|
|
129
|
+
const GatewayErrorBody = z.discriminatedUnion("code", [
|
|
130
|
+
InvalidInputError,
|
|
131
|
+
RepoNotFoundError,
|
|
132
|
+
RepoExistsError,
|
|
133
|
+
RefNotFoundError,
|
|
134
|
+
PathExistsError,
|
|
135
|
+
PathNotFoundError,
|
|
136
|
+
PathConflictError,
|
|
137
|
+
StaleHeadError,
|
|
138
|
+
NotHeadOfSourceError,
|
|
139
|
+
NotFastForwardError,
|
|
140
|
+
UnrelatedHistoriesError,
|
|
141
|
+
StorageUnavailableError
|
|
142
|
+
]).meta({
|
|
143
|
+
id: "GatewayErrorBody",
|
|
144
|
+
title: "Gateway error",
|
|
145
|
+
description: "Every error a gateway call can report, discriminated by `code`, with a message and typed details. Thrown as a GatewayError whose `body` holds it.",
|
|
146
|
+
examples: [{
|
|
147
|
+
code: "repo_not_found",
|
|
148
|
+
message: "Repository not found",
|
|
149
|
+
details: { repo: "acme" }
|
|
150
|
+
}]
|
|
151
|
+
});
|
|
152
|
+
/** The code of every gateway error; the same set as the `code` branches of {@link GatewayErrorBody}. */
|
|
153
|
+
const GatewayErrorCode = z.enum([
|
|
154
|
+
"invalid_input",
|
|
155
|
+
"repo_not_found",
|
|
156
|
+
"repo_exists",
|
|
157
|
+
"ref_not_found",
|
|
158
|
+
"path_exists",
|
|
159
|
+
"path_not_found",
|
|
160
|
+
"path_conflict",
|
|
161
|
+
"stale_head",
|
|
162
|
+
"not_head_of_source",
|
|
163
|
+
"not_fast_forward",
|
|
164
|
+
"unrelated_histories",
|
|
165
|
+
"storage_unavailable"
|
|
166
|
+
]).meta({
|
|
167
|
+
id: "GatewayErrorCode",
|
|
168
|
+
title: "Gateway error code",
|
|
169
|
+
description: "The machine-readable code of a gateway error.",
|
|
170
|
+
enumDescriptions: {
|
|
171
|
+
invalid_input: "The input failed schema validation.",
|
|
172
|
+
repo_not_found: "The named repository does not exist.",
|
|
173
|
+
repo_exists: "createRepo named an existing repository.",
|
|
174
|
+
ref_not_found: "A named branch or commit does not exist.",
|
|
175
|
+
path_exists: "A create, upsert or move target already exists.",
|
|
176
|
+
path_not_found: "An action needed a file that does not exist.",
|
|
177
|
+
path_conflict: "A parent of the target path is a file.",
|
|
178
|
+
stale_head: "The branch head is not the one the caller expected.",
|
|
179
|
+
not_head_of_source: "promote named a commit that is not the source head.",
|
|
180
|
+
not_fast_forward: "promote would not be a fast-forward.",
|
|
181
|
+
unrelated_histories: "syncBranch found no common ancestor.",
|
|
182
|
+
storage_unavailable: "The storage backend failed; retry later."
|
|
183
|
+
},
|
|
184
|
+
examples: ["stale_head"]
|
|
185
|
+
});
|
|
186
|
+
export { GatewayErrorBody, GatewayErrorCode, InvalidInputError, NotFastForwardError, NotHeadOfSourceError, PathConflictError, PathExistsError, PathNotFoundError, RefNotFoundError, RepoExistsError, RepoNotFoundError, StaleHeadError, StorageUnavailableError, UnrelatedHistoriesError };
|
|
187
|
+
|
|
188
|
+
//# sourceMappingURL=gateway-error-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-error-body.js","names":[],"sources":["../../src/schemas/gateway-error-body.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { z } from 'zod';\n\nimport { BranchName, FilePath, RepoName, Revision } from './names.ts';\nimport { Sha } from './sha.ts';\n\nconst message = z.string().min(1).describe('Human-readable explanation, safe to show to an end user.');\nconst repo = RepoName.describe('The repository the call named.');\n\n/** Builds one error variant: a code literal, a message and typed details. */\nfunction variant<const Code extends string, Shape extends z.ZodRawShape>(\n code: Code,\n meaning: string,\n details: Shape,\n example: { message: string; details: z.input<z.ZodObject<Shape>> },\n) {\n return z\n .object({\n code: z.literal(code).describe(meaning),\n message,\n details: z.object(details).strict().describe(`Machine-readable facts about the ${code} error.`),\n })\n .strict()\n .meta({\n id: `GatewayError.${code}`,\n title: `${code} error`,\n description: meaning,\n examples: [{ code, ...example }],\n });\n}\n\nconst PATH_EXAMPLE = { path: 'content/about.md' };\nconst SHA_A = '1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d';\nconst SHA_B = '8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a';\n\n/** The input failed schema validation. */\nexport const InvalidInputError = variant(\n 'invalid_input',\n 'The call input failed schema validation; nothing was read or written.',\n {\n issues: z\n .array(\n z\n .object({\n path: z\n .string()\n .describe('Dot-separated location of the bad value in the input; empty for the root.'),\n message: z.string().min(1).describe('What is wrong with the value.'),\n })\n .strict()\n .describe('One validation failure.'),\n )\n .min(1)\n .describe('Every validation failure found.'),\n },\n { message: 'Invalid input', details: { issues: [{ path: 'branch', message: 'Required' }] } },\n);\n\n/** The named repository does not exist. */\nexport const RepoNotFoundError = variant(\n 'repo_not_found',\n 'The named repository does not exist.',\n { repo },\n { message: 'Repository not found', details: { repo: 'acme' } },\n);\n\n/** A repository with that name already exists. */\nexport const RepoExistsError = variant(\n 'repo_exists',\n 'createRepo named a repository that already exists; it is left unchanged.',\n { repo },\n { message: 'Repository already exists', details: { repo: 'acme' } },\n);\n\n/** The named branch or commit does not exist. */\nexport const RefNotFoundError = variant(\n 'ref_not_found',\n 'A branch or commit the call named does not exist in the repository.',\n { ref: Revision.describe('The branch name or commit id that was not found.') },\n { message: 'Branch not found: staging', details: { ref: 'staging' } },\n);\n\n/** A create or move target already exists. */\nexport const PathExistsError = variant(\n 'path_exists',\n 'A create, upsert or move action targeted a path that is already a file or a directory.',\n { path: FilePath.describe('The path that already exists.') },\n { message: 'File already exists', details: PATH_EXAMPLE },\n);\n\n/** An action needed a file that does not exist. */\nexport const PathNotFoundError = variant(\n 'path_not_found',\n 'An update, delete, move or chmod action named a path that is not a file.',\n { path: FilePath.describe('The path that is not a file.') },\n { message: 'File not found', details: PATH_EXAMPLE },\n);\n\n/** A parent of the target path is a file. */\nexport const PathConflictError = variant(\n 'path_conflict',\n 'An action would place a file beneath a path that is itself a file.',\n {\n path: FilePath.describe('The path the action targeted.'),\n conflictingPath: FilePath.describe('The parent of `path` that is a file.'),\n },\n { message: 'A parent of the path is a file', details: { path: 'a/b.md', conflictingPath: 'a' } },\n);\n\n/** The branch head is not the head the caller expected. */\nexport const StaleHeadError = variant(\n 'stale_head',\n 'The branch head is not the head the caller expected; nothing was written. Re-read and retry.',\n {\n branch: BranchName.describe('The branch the write targeted.'),\n expectedHead: Sha.nullable().describe('The head the caller expected; null when it expected no branch.'),\n actualHead: Sha.nullable().describe('The current head; null when the branch does not exist.'),\n },\n { message: 'Branch head moved', details: { branch: 'main', expectedHead: SHA_A, actualHead: SHA_B } },\n);\n\n/** promote named a commit that is not the head of the source branch. */\nexport const NotHeadOfSourceError = variant(\n 'not_head_of_source',\n 'promote named a commit that is not the current head of the source branch; nothing moved.',\n {\n from: BranchName.describe('The source branch.'),\n sha: Sha.describe('The commit the caller asked to promote.'),\n head: Sha.describe('The current head of the source branch.'),\n },\n { message: 'Commit is not the head of staging', details: { from: 'staging', sha: SHA_A, head: SHA_B } },\n);\n\n/** promote would not be a fast-forward. */\nexport const NotFastForwardError = variant(\n 'not_fast_forward',\n 'promote named a commit that does not contain the head of the target branch; nothing moved.',\n {\n into: BranchName.describe('The target branch.'),\n sha: Sha.describe('The commit the caller asked to promote.'),\n head: Sha.describe('The current head of the target branch, which `sha` does not contain.'),\n },\n { message: 'Not a fast-forward', details: { into: 'main', sha: SHA_A, head: SHA_B } },\n);\n\n/** syncBranch found no common ancestor. */\nexport const UnrelatedHistoriesError = variant(\n 'unrelated_histories',\n 'syncBranch found no common ancestor between the branches, so there is nothing to merge against.',\n {\n from: BranchName.describe('The branch being merged in.'),\n into: BranchName.describe('The branch being brought up to date.'),\n },\n { message: 'Refusing to merge unrelated histories', details: { from: 'main', into: 'staging' } },\n);\n\n/** The storage backend failed. */\nexport const StorageUnavailableError = variant(\n 'storage_unavailable',\n 'The storage backend failed or timed out; the call may be retried with the same input.',\n { retryable: z.literal(true).describe('Always true: the same call may succeed later.') },\n { message: 'Storage backend unavailable', details: { retryable: true } },\n);\n\n/** Every error a gateway call can report, discriminated by `code`. */\nexport const GatewayErrorBody = z\n .discriminatedUnion('code', [\n InvalidInputError,\n RepoNotFoundError,\n RepoExistsError,\n RefNotFoundError,\n PathExistsError,\n PathNotFoundError,\n PathConflictError,\n StaleHeadError,\n NotHeadOfSourceError,\n NotFastForwardError,\n UnrelatedHistoriesError,\n StorageUnavailableError,\n ])\n .meta({\n id: 'GatewayErrorBody',\n title: 'Gateway error',\n description:\n 'Every error a gateway call can report, discriminated by `code`, with a message and typed details. Thrown as a GatewayError whose `body` holds it.',\n examples: [{ code: 'repo_not_found', message: 'Repository not found', details: { repo: 'acme' } }],\n });\n\n/** A gateway error body, inferred from {@link GatewayErrorBody}. */\nexport type GatewayErrorBody = z.infer<typeof GatewayErrorBody>;\n\n/** The code of every gateway error; the same set as the `code` branches of {@link GatewayErrorBody}. */\nexport const GatewayErrorCode = z\n .enum([\n 'invalid_input',\n 'repo_not_found',\n 'repo_exists',\n 'ref_not_found',\n 'path_exists',\n 'path_not_found',\n 'path_conflict',\n 'stale_head',\n 'not_head_of_source',\n 'not_fast_forward',\n 'unrelated_histories',\n 'storage_unavailable',\n ])\n .meta({\n id: 'GatewayErrorCode',\n title: 'Gateway error code',\n description: 'The machine-readable code of a gateway error.',\n enumDescriptions: {\n invalid_input: 'The input failed schema validation.',\n repo_not_found: 'The named repository does not exist.',\n repo_exists: 'createRepo named an existing repository.',\n ref_not_found: 'A named branch or commit does not exist.',\n path_exists: 'A create, upsert or move target already exists.',\n path_not_found: 'An action needed a file that does not exist.',\n path_conflict: 'A parent of the target path is a file.',\n stale_head: 'The branch head is not the one the caller expected.',\n not_head_of_source: 'promote named a commit that is not the source head.',\n not_fast_forward: 'promote would not be a fast-forward.',\n unrelated_histories: 'syncBranch found no common ancestor.',\n storage_unavailable: 'The storage backend failed; retry later.',\n },\n examples: ['stale_head'],\n });\n\n/** The code of a gateway error, inferred from {@link GatewayErrorCode}. */\nexport type GatewayErrorCode = z.infer<typeof GatewayErrorCode>;\n"],"mappings":";;;;AAMA,MAAM,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,0DAA0D;AACrG,MAAM,OAAO,SAAS,SAAS,gCAAgC;;AAG/D,SAAS,QACP,MACA,SACA,SACA,SACA;CACA,OAAO,EACJ,OAAO;EACN,MAAM,EAAE,QAAQ,IAAI,CAAC,CAAC,SAAS,OAAO;EACtC;EACA,SAAS,EAAE,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,QACrC,uBACA,yFACA,EAAE,WAAW,EAAE,QAAQ,IAAI,CAAC,CAAC,SAAS,+CAA+C,EAAE,GACvF;CAAE,SAAS;CAA+B,SAAS,EAAE,WAAW,KAAK;AAAE,CACzE;;AAGA,MAAa,mBAAmB,EAC7B,mBAAmB,QAAQ;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,CACD,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aACE;CACF,UAAU,CAAC;EAAE,MAAM;EAAkB,SAAS;EAAwB,SAAS,EAAE,MAAM,OAAO;CAAE,CAAC;AACnG,CAAC;;AAMH,MAAa,mBAAmB,EAC7B,KAAK;CACJ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,CACD,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aAAa;CACb,kBAAkB;EAChB,eAAe;EACf,gBAAgB;EAChB,aAAa;EACb,eAAe;EACf,aAAa;EACb,gBAAgB;EAChB,eAAe;EACf,YAAY;EACZ,oBAAoB;EACpB,kBAAkB;EAClB,qBAAqB;EACrB,qBAAqB;CACvB;CACA,UAAU,CAAC,YAAY;AACzB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** A UTC timestamp in ISO 8601 form. */
|
|
3
|
+
export declare const Timestamp: z.ZodISODateTime;
|
|
4
|
+
/** A UTC timestamp, inferred from {@link Timestamp}. */
|
|
5
|
+
export type Timestamp = z.infer<typeof Timestamp>;
|
|
6
|
+
/** The name and email a commit is attributed to. */
|
|
7
|
+
export declare const Identity: z.ZodObject<{
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
email: z.ZodEmail;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
/** A commit identity, inferred from {@link Identity}. */
|
|
12
|
+
export type Identity = z.infer<typeof Identity>;
|
|
13
|
+
/** An identity together with when it acted. */
|
|
14
|
+
export declare const Signature: z.ZodObject<{
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
email: z.ZodEmail;
|
|
17
|
+
date: z.ZodISODateTime;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
/** An identity with a date, inferred from {@link Signature}. */
|
|
20
|
+
export type Signature = z.infer<typeof Signature>;
|
|
21
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// src/schemas/identity.ts
|
|
3
|
+
/** A UTC timestamp in ISO 8601 form. */
|
|
4
|
+
const Timestamp = z.iso.datetime().meta({
|
|
5
|
+
id: "Timestamp",
|
|
6
|
+
title: "Timestamp",
|
|
7
|
+
description: "A point in time as an ISO 8601 UTC timestamp ending in \"Z\", with optional fractional seconds (e.g. 2026-11-20T09:30:00.000Z).",
|
|
8
|
+
examples: ["2026-11-20T09:30:00.000Z"]
|
|
9
|
+
});
|
|
10
|
+
/** The name and email a commit is attributed to. */
|
|
11
|
+
const Identity = z.object({
|
|
12
|
+
name: z.string().min(1).max(255).regex(/^[^<>\n\0]+$/).describe("Display name, 1–255 characters, without \"<\", \">\", newlines or NUL (git cannot store them)."),
|
|
13
|
+
email: z.email().max(255).describe("Email address, at most 255 characters.")
|
|
14
|
+
}).strict().meta({
|
|
15
|
+
id: "Identity",
|
|
16
|
+
title: "Identity",
|
|
17
|
+
description: "The name and email a commit is attributed to, as an author or a committer.",
|
|
18
|
+
examples: [{
|
|
19
|
+
name: "Ada Lovelace",
|
|
20
|
+
email: "ada@example.com"
|
|
21
|
+
}]
|
|
22
|
+
});
|
|
23
|
+
/** An identity together with when it acted. */
|
|
24
|
+
const Signature = z.object({
|
|
25
|
+
name: Identity.shape.name,
|
|
26
|
+
email: Identity.shape.email,
|
|
27
|
+
date: Timestamp.describe("When this person authored or committed the change, as an ISO 8601 UTC timestamp.")
|
|
28
|
+
}).strict().meta({
|
|
29
|
+
id: "Signature",
|
|
30
|
+
title: "Signature",
|
|
31
|
+
description: "An identity together with the time it authored or committed a commit, as stored in the commit.",
|
|
32
|
+
examples: [{
|
|
33
|
+
name: "Ada Lovelace",
|
|
34
|
+
email: "ada@example.com",
|
|
35
|
+
date: "2026-11-20T09:30:00.000Z"
|
|
36
|
+
}]
|
|
37
|
+
});
|
|
38
|
+
export { Identity, Signature, Timestamp };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","names":[],"sources":["../../src/schemas/identity.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { z } from 'zod';\n\n/** A UTC timestamp in ISO 8601 form. */\nexport const Timestamp = z.iso.datetime().meta({\n id: 'Timestamp',\n title: 'Timestamp',\n description:\n 'A point in time as an ISO 8601 UTC timestamp ending in \"Z\", with optional fractional seconds (e.g. 2026-11-20T09:30:00.000Z).',\n examples: ['2026-11-20T09:30:00.000Z'],\n});\n\n/** A UTC timestamp, inferred from {@link Timestamp}. */\nexport type Timestamp = z.infer<typeof Timestamp>;\n\n/** The name and email a commit is attributed to. */\nexport const Identity = z\n .object({\n name: z\n .string()\n .min(1)\n .max(255)\n .regex(/^[^<>\\n\\0]+$/)\n .describe('Display name, 1–255 characters, without \"<\", \">\", newlines or NUL (git cannot store them).'),\n email: z.email().max(255).describe('Email address, at most 255 characters.'),\n })\n .strict()\n .meta({\n id: 'Identity',\n title: 'Identity',\n description: 'The name and email a commit is attributed to, as an author or a committer.',\n examples: [{ name: 'Ada Lovelace', email: 'ada@example.com' }],\n });\n\n/** A commit identity, inferred from {@link Identity}. */\nexport type Identity = z.infer<typeof Identity>;\n\n/** An identity together with when it acted. */\nexport const Signature = z\n .object({\n name: Identity.shape.name,\n email: Identity.shape.email,\n date: Timestamp.describe(\n 'When this person authored or committed the change, as an ISO 8601 UTC timestamp.',\n ),\n })\n .strict()\n .meta({\n id: 'Signature',\n title: 'Signature',\n description:\n 'An identity together with the time it authored or committed a commit, as stored in the commit.',\n examples: [{ name: 'Ada Lovelace', email: 'ada@example.com', date: '2026-11-20T09:30:00.000Z' }],\n });\n\n/** An identity with a date, inferred from {@link Signature}. */\nexport type Signature = z.infer<typeof Signature>;\n"],"mappings":";;;AAIA,MAAa,YAAY,EAAE,IAAI,SAAS,CAAC,CAAC,KAAK;CAC7C,IAAI;CACJ,OAAO;CACP,aACE;CACF,UAAU,CAAC,0BAA0B;AACvC,CAAC;;AAMD,MAAa,WAAW,EACrB,OAAO;CACN,MAAM,EACH,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,GAAG,CAAC,CACR,MAAM,cAAc,CAAC,CACrB,SAAS,gGAA4F;CACxG,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS,wCAAwC;AAC7E,CAAC,CAAC,CACD,OAAO,CAAC,CACR,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aAAa;CACb,UAAU,CAAC;EAAE,MAAM;EAAgB,OAAO;CAAkB,CAAC;AAC/D,CAAC;;AAMH,MAAa,YAAY,EACtB,OAAO;CACN,MAAM,SAAS,MAAM;CACrB,OAAO,SAAS,MAAM;CACtB,MAAM,UAAU,SACd,kFACF;AACF,CAAC,CAAC,CACD,OAAO,CAAC,CACR,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aACE;CACF,UAAU,CAAC;EAAE,MAAM;EAAgB,OAAO;EAAmB,MAAM;CAA2B,CAAC;AACjG,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** A repository name: one URL path segment, served as `/<name>.git`. */
|
|
3
|
+
export declare const RepoName: z.ZodString;
|
|
4
|
+
/** A repository name, inferred from {@link RepoName}. */
|
|
5
|
+
export type RepoName = z.infer<typeof RepoName>;
|
|
6
|
+
/** A short branch name such as `main` or `feature/x` (never `refs/heads/…`). */
|
|
7
|
+
export declare const BranchName: z.ZodString;
|
|
8
|
+
/** A short branch name, inferred from {@link BranchName}. */
|
|
9
|
+
export type BranchName = z.infer<typeof BranchName>;
|
|
10
|
+
/** A fully qualified ref under `refs/heads/` or `refs/tags/`. */
|
|
11
|
+
export declare const FullRefName: z.ZodString;
|
|
12
|
+
/** A fully qualified ref, inferred from {@link FullRefName}. */
|
|
13
|
+
export type FullRefName = z.infer<typeof FullRefName>;
|
|
14
|
+
/** What a read is made against: a commit id or a branch name. */
|
|
15
|
+
export declare const Revision: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
16
|
+
/** A commit id or branch name, inferred from {@link Revision}. */
|
|
17
|
+
export type Revision = z.infer<typeof Revision>;
|
|
18
|
+
/** A file path inside a repository. */
|
|
19
|
+
export declare const FilePath: z.ZodString;
|
|
20
|
+
/** A file path inside a repository, inferred from {@link FilePath}. */
|
|
21
|
+
export type FilePath = z.infer<typeof FilePath>;
|
|
22
|
+
/** The key that makes a write idempotent. */
|
|
23
|
+
export declare const IdempotencyKey: z.ZodString;
|
|
24
|
+
/** An idempotency key, inferred from {@link IdempotencyKey}. */
|
|
25
|
+
export type IdempotencyKey = z.infer<typeof IdempotencyKey>;
|
|
26
|
+
//# sourceMappingURL=names.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Sha } from "./sha.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// src/schemas/names.ts
|
|
4
|
+
/**
|
|
5
|
+
* One or more slash-separated ref components following `git check-ref-format`: no component starts
|
|
6
|
+
* with "." or ends with ".lock", no "..", "@{", "//", control characters, space, ~ ^ : ? * [ or \,
|
|
7
|
+
* not "@" alone, and no trailing "/" or ".".
|
|
8
|
+
*/
|
|
9
|
+
const REF_COMPONENTS = String.raw`(?!@$)(?!.*\.\.)(?!.*@\{)(?!.*//)(?!.*/\.)(?!.*\.lock(?:/|$))(?!.*[./]$)[^\x00-\x20\x7f~^:?*[\\.\-/][^\x00-\x20\x7f~^:?*[\\]*`;
|
|
10
|
+
/** A repository name: one URL path segment, served as `/<name>.git`. */
|
|
11
|
+
const RepoName = z.string().min(1).max(100).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/).refine((name) => !name.toLowerCase().endsWith(".git"), { message: "must not end with \".git\"" }).meta({
|
|
12
|
+
id: "RepoName",
|
|
13
|
+
title: "Repository name",
|
|
14
|
+
description: "Name of a repository behind the gateway: 1–100 characters of letters, digits, \".\", \"_\" and \"-\", starting with a letter or digit and not ending in \".git\". Served at /<name>.git.",
|
|
15
|
+
examples: ["acme-raw-content", "site.example"]
|
|
16
|
+
});
|
|
17
|
+
/** A short branch name such as `main` or `feature/x` (never `refs/heads/…`). */
|
|
18
|
+
const BranchName = z.string().min(1).max(255).regex(new RegExp(`^(?!refs/)(?!HEAD$)(?![0-9a-f]{40}$)${REF_COMPONENTS}$`)).meta({
|
|
19
|
+
id: "BranchName",
|
|
20
|
+
title: "Branch name",
|
|
21
|
+
description: "A short branch name, 1–255 characters, valid under git check-ref-format (no \"..\", \"@{\", \"//\", spaces, control characters or ~ ^ : ? * [ or backslash; no component starting with \".\" or ending with \".lock\"; not starting with \"-\" or \"refs/\"; not \"HEAD\"; not 40 lowercase hex characters, which a Revision always reads as a commit id). The gateway stores it as refs/heads/<name>.",
|
|
22
|
+
examples: [
|
|
23
|
+
"main",
|
|
24
|
+
"staging",
|
|
25
|
+
"feature/new-page"
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
/** A fully qualified ref under `refs/heads/` or `refs/tags/`. */
|
|
29
|
+
const FullRefName = z.string().min(11).max(266).regex(new RegExp(`^refs/(?:heads|tags)/${REF_COMPONENTS}$`)).meta({
|
|
30
|
+
id: "FullRefName",
|
|
31
|
+
title: "Full ref name",
|
|
32
|
+
description: "A fully qualified ref, \"refs/heads/<branch>\" or \"refs/tags/<tag>\", where the name after the prefix follows the same rules as a branch name.",
|
|
33
|
+
examples: ["refs/heads/main", "refs/tags/v1.0.0"]
|
|
34
|
+
});
|
|
35
|
+
/** What a read is made against: a commit id or a branch name. */
|
|
36
|
+
const Revision = z.union([Sha.describe("A commit id. Any 40-character lowercase hex string is read as a commit id, never a branch."), BranchName.describe("A branch name, resolved to the branch head at the time of the call.")]).meta({
|
|
37
|
+
id: "Revision",
|
|
38
|
+
title: "Revision",
|
|
39
|
+
description: "What a read is made against: a 40-character lowercase hex commit id, or a short branch name resolved to its current head.",
|
|
40
|
+
examples: ["main", "8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a"]
|
|
41
|
+
});
|
|
42
|
+
/** A file path inside a repository. */
|
|
43
|
+
const FilePath = z.string().min(1).max(4096).regex(new RegExp(String.raw`^(?!\/)(?!.*\/\/)(?!.*\/$)(?!(?:.*\/)?[^/]{256})(?!(?:.*\/)?\.\.?(?:\/|$))(?!(?:.*\/)?\.[gG][iI][tT](?:\/|$))[^\x00-\x1f\x7f\\]+$`, "s")).meta({
|
|
44
|
+
id: "FilePath",
|
|
45
|
+
title: "File path",
|
|
46
|
+
description: "A path inside the repository relative to its root, 1–4096 characters, \"/\"-separated into segments of 1–255 characters: no leading or trailing \"/\", no empty, \".\" or \"..\" segment, no \".git\" segment (any case), no backslash and no control character (U+0000–U+001F, U+007F). Case-sensitive; unicode allowed.",
|
|
47
|
+
examples: ["content/index.md", "templates/layouts/page.hbs"]
|
|
48
|
+
});
|
|
49
|
+
/** The key that makes a write idempotent. */
|
|
50
|
+
const IdempotencyKey = z.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/).meta({
|
|
51
|
+
id: "IdempotencyKey",
|
|
52
|
+
title: "Idempotency key",
|
|
53
|
+
description: "Caller-chosen key that makes a commit idempotent: 1–128 characters of letters, digits, \".\", \"_\", \":\" and \"-\", starting with a letter or digit. Recorded as a \"Gateway-Idempotency-Key:\" trailer; a retried commit carrying a key already in the branch's recent history returns that commit instead of writing another.",
|
|
54
|
+
examples: ["cms:publish:2f9c1e", "6f1d2c3b-9a8e-4f7d-b6c5-a4e3d2c1b0a9"]
|
|
55
|
+
});
|
|
56
|
+
export { BranchName, FilePath, FullRefName, IdempotencyKey, RepoName, Revision };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","names":[],"sources":["../../src/schemas/names.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { z } from 'zod';\n\nimport { Sha } from './sha.ts';\n\n/**\n * One or more slash-separated ref components following `git check-ref-format`: no component starts\n * with \".\" or ends with \".lock\", no \"..\", \"@{\", \"//\", control characters, space, ~ ^ : ? * [ or \\,\n * not \"@\" alone, and no trailing \"/\" or \".\".\n */\nconst REF_COMPONENTS = String.raw`(?!@$)(?!.*\\.\\.)(?!.*@\\{)(?!.*//)(?!.*/\\.)(?!.*\\.lock(?:/|$))(?!.*[./]$)[^\\x00-\\x20\\x7f~^:?*[\\\\.\\-/][^\\x00-\\x20\\x7f~^:?*[\\\\]*`;\n\n/** A repository name: one URL path segment, served as `/<name>.git`. */\nexport const RepoName = z\n .string()\n .min(1)\n .max(100)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/)\n .refine((name) => !name.toLowerCase().endsWith('.git'), { message: 'must not end with \".git\"' })\n .meta({\n id: 'RepoName',\n title: 'Repository name',\n description:\n 'Name of a repository behind the gateway: 1–100 characters of letters, digits, \".\", \"_\" and \"-\", starting with a letter or digit and not ending in \".git\". Served at /<name>.git.',\n examples: ['acme-raw-content', 'site.example'],\n });\n\n/** A repository name, inferred from {@link RepoName}. */\nexport type RepoName = z.infer<typeof RepoName>;\n\n/** A short branch name such as `main` or `feature/x` (never `refs/heads/…`). */\nexport const BranchName = z\n .string()\n .min(1)\n .max(255)\n .regex(new RegExp(`^(?!refs/)(?!HEAD$)(?![0-9a-f]{40}$)${REF_COMPONENTS}$`))\n .meta({\n id: 'BranchName',\n title: 'Branch name',\n description:\n 'A short branch name, 1–255 characters, valid under git check-ref-format (no \"..\", \"@{\", \"//\", spaces, control characters or ~ ^ : ? * [ or backslash; no component starting with \".\" or ending with \".lock\"; not starting with \"-\" or \"refs/\"; not \"HEAD\"; not 40 lowercase hex characters, which a Revision always reads as a commit id). The gateway stores it as refs/heads/<name>.',\n examples: ['main', 'staging', 'feature/new-page'],\n });\n\n/** A short branch name, inferred from {@link BranchName}. */\nexport type BranchName = z.infer<typeof BranchName>;\n\n/** A fully qualified ref under `refs/heads/` or `refs/tags/`. */\nexport const FullRefName = z\n .string()\n .min(11)\n .max(266)\n .regex(new RegExp(`^refs/(?:heads|tags)/${REF_COMPONENTS}$`))\n .meta({\n id: 'FullRefName',\n title: 'Full ref name',\n description:\n 'A fully qualified ref, \"refs/heads/<branch>\" or \"refs/tags/<tag>\", where the name after the prefix follows the same rules as a branch name.',\n examples: ['refs/heads/main', 'refs/tags/v1.0.0'],\n });\n\n/** A fully qualified ref, inferred from {@link FullRefName}. */\nexport type FullRefName = z.infer<typeof FullRefName>;\n\n/** What a read is made against: a commit id or a branch name. */\nexport const Revision = z\n .union([\n Sha.describe(\n 'A commit id. Any 40-character lowercase hex string is read as a commit id, never a branch.',\n ),\n BranchName.describe('A branch name, resolved to the branch head at the time of the call.'),\n ])\n .meta({\n id: 'Revision',\n title: 'Revision',\n description:\n 'What a read is made against: a 40-character lowercase hex commit id, or a short branch name resolved to its current head.',\n examples: ['main', '8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a'],\n });\n\n/** A commit id or branch name, inferred from {@link Revision}. */\nexport type Revision = z.infer<typeof Revision>;\n\n/** A file path inside a repository. */\nexport const FilePath = z\n .string()\n .min(1)\n .max(4096)\n // Segments are capped at 255 characters, the limit a tree entry name has, so every committed path\n // can be listed back. Control characters (newline included) are excluded outright, so every lookahead sees the whole\n // string; the \"s\" flag keeps that true even if the character class is ever loosened. \".git\" is\n // matched case-insensitively by its character classes rather than an \"i\" flag, because JSON Schema\n // \"pattern\" drops regex flags and the published schema must enforce the same rule.\n .regex(\n new RegExp(\n String.raw`^(?!\\/)(?!.*\\/\\/)(?!.*\\/$)(?!(?:.*\\/)?[^/]{256})(?!(?:.*\\/)?\\.\\.?(?:\\/|$))(?!(?:.*\\/)?\\.[gG][iI][tT](?:\\/|$))[^\\x00-\\x1f\\x7f\\\\]+$`,\n 's',\n ),\n )\n .meta({\n id: 'FilePath',\n title: 'File path',\n description:\n 'A path inside the repository relative to its root, 1–4096 characters, \"/\"-separated into segments of 1–255 characters: no leading or trailing \"/\", no empty, \".\" or \"..\" segment, no \".git\" segment (any case), no backslash and no control character (U+0000–U+001F, U+007F). Case-sensitive; unicode allowed.',\n examples: ['content/index.md', 'templates/layouts/page.hbs'],\n });\n\n/** A file path inside a repository, inferred from {@link FilePath}. */\nexport type FilePath = z.infer<typeof FilePath>;\n\n/** The key that makes a write idempotent. */\nexport const IdempotencyKey = z\n .string()\n .min(1)\n .max(128)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/)\n .meta({\n id: 'IdempotencyKey',\n title: 'Idempotency key',\n description:\n 'Caller-chosen key that makes a commit idempotent: 1–128 characters of letters, digits, \".\", \"_\", \":\" and \"-\", starting with a letter or digit. Recorded as a \"Gateway-Idempotency-Key:\" trailer; a retried commit carrying a key already in the branch\\'s recent history returns that commit instead of writing another.',\n examples: ['cms:publish:2f9c1e', '6f1d2c3b-9a8e-4f7d-b6c5-a4e3d2c1b0a9'],\n });\n\n/** An idempotency key, inferred from {@link IdempotencyKey}. */\nexport type IdempotencyKey = z.infer<typeof IdempotencyKey>;\n"],"mappings":";;;;;;;;AAUA,MAAM,iBAAiB,OAAO,GAAG;;AAGjC,MAAa,WAAW,EACrB,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,IAAI,GAAG,CAAC,CACR,MAAM,8BAA8B,CAAC,CACrC,QAAQ,SAAS,CAAC,KAAK,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,EAAE,SAAS,6BAA2B,CAAC,CAAC,CAC/F,KAAK;CACJ,IAAI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the command a receive-pack request carries. */
|
|
3
|
+
export declare const RefUpdate: z.ZodObject<{
|
|
4
|
+
ref: z.ZodString;
|
|
5
|
+
oldSha: z.ZodString;
|
|
6
|
+
newSha: z.ZodString;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
/** A ref update, inferred from {@link RefUpdate}. */
|
|
9
|
+
export type RefUpdate = z.infer<typeof RefUpdate>;
|
|
10
|
+
//# sourceMappingURL=ref-update.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FullRefName } from "./names.js";
|
|
2
|
+
import { Sha } from "./sha.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
// src/schemas/ref-update.ts
|
|
5
|
+
/** One ref moved by a write: the command a receive-pack request carries. */
|
|
6
|
+
const RefUpdate = z.object({
|
|
7
|
+
ref: FullRefName.describe("The ref that moved, fully qualified (refs/heads/<branch>)."),
|
|
8
|
+
oldSha: Sha.describe("Id the ref pointed at before the update; the all-zero id when the update created the ref."),
|
|
9
|
+
newSha: Sha.describe("Id the ref points at after the update; the all-zero id when the update deleted the ref.")
|
|
10
|
+
}).strict().refine((update) => update.oldSha !== update.newSha, {
|
|
11
|
+
message: "an update must change the ref",
|
|
12
|
+
path: ["newSha"]
|
|
13
|
+
}).meta({
|
|
14
|
+
id: "RefUpdate",
|
|
15
|
+
title: "Ref update",
|
|
16
|
+
description: "One ref moved by a write, in receive-pack command form: the ref, the id it named before and the id it names after. Creation and deletion use the all-zero id on the missing side.",
|
|
17
|
+
examples: [{
|
|
18
|
+
ref: "refs/heads/main",
|
|
19
|
+
oldSha: "1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d",
|
|
20
|
+
newSha: "8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a"
|
|
21
|
+
}]
|
|
22
|
+
});
|
|
23
|
+
export { RefUpdate };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=ref-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ref-update.js","names":[],"sources":["../../src/schemas/ref-update.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { z } from 'zod';\n\nimport { FullRefName } from './names.ts';\nimport { Sha } from './sha.ts';\n\n/** One ref moved by a write: the command a receive-pack request carries. */\nexport const RefUpdate = z\n .object({\n ref: FullRefName.describe('The ref that moved, fully qualified (refs/heads/<branch>).'),\n oldSha: Sha.describe(\n 'Id the ref pointed at before the update; the all-zero id when the update created the ref.',\n ),\n newSha: Sha.describe(\n 'Id the ref points at after the update; the all-zero id when the update deleted the ref.',\n ),\n })\n .strict()\n .refine((update) => update.oldSha !== update.newSha, {\n message: 'an update must change the ref',\n path: ['newSha'],\n })\n .meta({\n id: 'RefUpdate',\n title: 'Ref update',\n description:\n 'One ref moved by a write, in receive-pack command form: the ref, the id it named before and the id it names after. Creation and deletion use the all-zero id on the missing side.',\n examples: [\n {\n ref: 'refs/heads/main',\n oldSha: '1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d',\n newSha: '8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a',\n },\n ],\n });\n\n/** A ref update, inferred from {@link RefUpdate}. */\nexport type RefUpdate = z.infer<typeof RefUpdate>;\n"],"mappings":";;;;;AAOA,MAAa,YAAY,EACtB,OAAO;CACN,KAAK,YAAY,SAAS,4DAA4D;CACtF,QAAQ,IAAI,SACV,2FACF;CACA,QAAQ,IAAI,SACV,yFACF;AACF,CAAC,CAAC,CACD,OAAO,CAAC,CACR,QAAQ,WAAW,OAAO,WAAW,OAAO,QAAQ;CACnD,SAAS;CACT,MAAM,CAAC,QAAQ;AACjB,CAAC,CAAC,CACD,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aACE;CACF,UAAU,CACR;EACE,KAAK;EACL,QAAQ;EACR,QAAQ;CACV,CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** A git object id: 40-character lowercase hex SHA-1. */
|
|
3
|
+
export declare const Sha: z.ZodString;
|
|
4
|
+
/** A git object id, inferred from {@link Sha}. */
|
|
5
|
+
export type Sha = z.infer<typeof Sha>;
|
|
6
|
+
/** The all-zero object id git uses for "no object". */
|
|
7
|
+
export declare const ZERO_SHA = "0000000000000000000000000000000000000000";
|
|
8
|
+
//# sourceMappingURL=sha.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// src/schemas/sha.ts
|
|
3
|
+
/** A git object id: 40-character lowercase hex SHA-1. */
|
|
4
|
+
const Sha = z.string().regex(/^[0-9a-f]{40}$/).meta({
|
|
5
|
+
id: "Sha",
|
|
6
|
+
title: "Object id",
|
|
7
|
+
description: "A git object id: 40-character lowercase hex SHA-1 naming a commit, tree or blob. Never abbreviated.",
|
|
8
|
+
examples: ["8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a"]
|
|
9
|
+
});
|
|
10
|
+
/** The all-zero object id git uses for "no object". */
|
|
11
|
+
const ZERO_SHA = "0000000000000000000000000000000000000000";
|
|
12
|
+
export { Sha, ZERO_SHA };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=sha.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha.js","names":[],"sources":["../../src/schemas/sha.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { z } from 'zod';\n\n/** A git object id: 40-character lowercase hex SHA-1. */\nexport const Sha = z\n .string()\n .regex(/^[0-9a-f]{40}$/)\n .meta({\n id: 'Sha',\n title: 'Object id',\n description:\n 'A git object id: 40-character lowercase hex SHA-1 naming a commit, tree or blob. Never abbreviated.',\n examples: ['8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a'],\n });\n\n/** A git object id, inferred from {@link Sha}. */\nexport type Sha = z.infer<typeof Sha>;\n\n/** The all-zero object id git uses for \"no object\". */\nexport const ZERO_SHA = '0000000000000000000000000000000000000000';\n"],"mappings":";;;AAIA,MAAa,MAAM,EAChB,OAAO,CAAC,CACR,MAAM,gBAAgB,CAAC,CACvB,KAAK;CACJ,IAAI;CACJ,OAAO;CACP,aACE;CACF,UAAU,CAAC,0CAA0C;AACvD,CAAC;;AAMH,MAAa,WAAW"}
|