@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,103 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import { EXAMPLE_TIMESTAMP } from '../schemas/examples.ts';
|
|
5
|
+
import { Timestamp } from '../schemas/identity.ts';
|
|
6
|
+
import { BranchName, RepoName } from '../schemas/names.ts';
|
|
7
|
+
|
|
8
|
+
/** Input of `createRepo`. */
|
|
9
|
+
export const CreateRepoInput = z
|
|
10
|
+
.object({
|
|
11
|
+
repo: RepoName.describe('Name of the repository to create.'),
|
|
12
|
+
defaultBranch: BranchName.default('main').describe(
|
|
13
|
+
'Branch HEAD names; it comes into being with the first commit to it. Default "main".',
|
|
14
|
+
),
|
|
15
|
+
})
|
|
16
|
+
.strict()
|
|
17
|
+
.meta({
|
|
18
|
+
id: 'CreateRepoInput',
|
|
19
|
+
title: 'createRepo input',
|
|
20
|
+
description:
|
|
21
|
+
'Input of createRepo(): create an empty repository. Fails with repo_exists if the name is taken.',
|
|
22
|
+
examples: [{ repo: 'acme-raw-content', defaultBranch: 'main' }],
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/** Input of `createRepo` as accepted (defaults optional). */
|
|
26
|
+
export type CreateRepoInput = z.input<typeof CreateRepoInput>;
|
|
27
|
+
|
|
28
|
+
/** A repository behind the gateway. */
|
|
29
|
+
export const RepoInfo = z
|
|
30
|
+
.object({
|
|
31
|
+
name: RepoName.describe('The repository name.'),
|
|
32
|
+
defaultBranch: BranchName.describe('The branch HEAD names.'),
|
|
33
|
+
createdAt: Timestamp.describe('When the repository was created.'),
|
|
34
|
+
remoteUrl: z.url().describe('Clone URL of the repository on the gateway: <publicBaseUrl>/<name>.git.'),
|
|
35
|
+
})
|
|
36
|
+
.strict()
|
|
37
|
+
.meta({
|
|
38
|
+
id: 'RepoInfo',
|
|
39
|
+
title: 'Repository',
|
|
40
|
+
description: 'A repository behind the gateway.',
|
|
41
|
+
examples: [
|
|
42
|
+
{
|
|
43
|
+
name: 'acme-raw-content',
|
|
44
|
+
defaultBranch: 'main',
|
|
45
|
+
createdAt: EXAMPLE_TIMESTAMP,
|
|
46
|
+
remoteUrl: 'https://git.example.com/acme-raw-content.git',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/** A repository, inferred from {@link RepoInfo}. */
|
|
52
|
+
export type RepoInfo = z.infer<typeof RepoInfo>;
|
|
53
|
+
|
|
54
|
+
/** Output of `createRepo`: the new repository. */
|
|
55
|
+
export const CreateRepoOutput = RepoInfo.meta({
|
|
56
|
+
id: 'CreateRepoOutput',
|
|
57
|
+
title: 'createRepo output',
|
|
58
|
+
description: 'Output of createRepo(): the repository created, empty (no branches until the first commit).',
|
|
59
|
+
examples: [
|
|
60
|
+
{
|
|
61
|
+
name: 'acme-raw-content',
|
|
62
|
+
defaultBranch: 'main',
|
|
63
|
+
createdAt: EXAMPLE_TIMESTAMP,
|
|
64
|
+
remoteUrl: 'https://git.example.com/acme-raw-content.git',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
/** Output of `createRepo`, inferred from {@link CreateRepoOutput}. */
|
|
70
|
+
export type CreateRepoOutput = z.infer<typeof CreateRepoOutput>;
|
|
71
|
+
|
|
72
|
+
/** Input of `deleteRepo`. */
|
|
73
|
+
export const DeleteRepoInput = z
|
|
74
|
+
.object({
|
|
75
|
+
repo: RepoName.describe('Name of the repository to delete, with all its branches and history.'),
|
|
76
|
+
})
|
|
77
|
+
.strict()
|
|
78
|
+
.meta({
|
|
79
|
+
id: 'DeleteRepoInput',
|
|
80
|
+
title: 'deleteRepo input',
|
|
81
|
+
description:
|
|
82
|
+
'Input of deleteRepo(): permanently delete a repository. Deleting a missing repository is not an error.',
|
|
83
|
+
examples: [{ repo: 'acme-raw-content' }],
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
/** Input of `deleteRepo`, inferred from {@link DeleteRepoInput}. */
|
|
87
|
+
export type DeleteRepoInput = z.input<typeof DeleteRepoInput>;
|
|
88
|
+
|
|
89
|
+
/** Output of `deleteRepo`. */
|
|
90
|
+
export const DeleteRepoOutput = z
|
|
91
|
+
.object({
|
|
92
|
+
deleted: z.boolean().describe('true when a repository was deleted; false when none had that name.'),
|
|
93
|
+
})
|
|
94
|
+
.strict()
|
|
95
|
+
.meta({
|
|
96
|
+
id: 'DeleteRepoOutput',
|
|
97
|
+
title: 'deleteRepo output',
|
|
98
|
+
description: 'Output of deleteRepo().',
|
|
99
|
+
examples: [{ deleted: true }],
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
/** Output of `deleteRepo`, inferred from {@link DeleteRepoOutput}. */
|
|
103
|
+
export type DeleteRepoOutput = z.infer<typeof DeleteRepoOutput>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import { EXAMPLE_SHA_B } from '../schemas/examples.ts';
|
|
5
|
+
import { RepoName, Revision } from '../schemas/names.ts';
|
|
6
|
+
import { Sha } from '../schemas/sha.ts';
|
|
7
|
+
|
|
8
|
+
/** Input of `resolveRef`. */
|
|
9
|
+
export const ResolveRefInput = z
|
|
10
|
+
.object({
|
|
11
|
+
repo: RepoName.describe('Repository to look in.'),
|
|
12
|
+
ref: Revision.describe('Branch name to resolve, or commit id to check.'),
|
|
13
|
+
})
|
|
14
|
+
.strict()
|
|
15
|
+
.meta({
|
|
16
|
+
id: 'ResolveRefInput',
|
|
17
|
+
title: 'resolveRef input',
|
|
18
|
+
description: 'Input of resolveRef(): resolve a branch to its head, or confirm a commit id exists.',
|
|
19
|
+
examples: [{ repo: 'acme-raw-content', ref: 'main' }],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/** Input of `resolveRef`, inferred from {@link ResolveRefInput}. */
|
|
23
|
+
export type ResolveRefInput = z.input<typeof ResolveRefInput>;
|
|
24
|
+
|
|
25
|
+
/** Output of `resolveRef`. */
|
|
26
|
+
export const ResolveRefOutput = z
|
|
27
|
+
.object({
|
|
28
|
+
sha: Sha.describe('Id of the commit the ref names.'),
|
|
29
|
+
})
|
|
30
|
+
.strict()
|
|
31
|
+
.nullable()
|
|
32
|
+
.meta({
|
|
33
|
+
id: 'ResolveRefOutput',
|
|
34
|
+
title: 'resolveRef output',
|
|
35
|
+
description:
|
|
36
|
+
'Output of resolveRef(): the commit id the ref names, or null when the branch or commit does not exist.',
|
|
37
|
+
examples: [{ sha: EXAMPLE_SHA_B }, null],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/** Output of `resolveRef`, inferred from {@link ResolveRefOutput}. */
|
|
41
|
+
export type ResolveRefOutput = z.infer<typeof ResolveRefOutput>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import { Commit } from '../schemas/commit.ts';
|
|
5
|
+
import { EXAMPLE_COMMIT, EXAMPLE_SHA_A, EXAMPLE_SHA_B } from '../schemas/examples.ts';
|
|
6
|
+
import { Identity } from '../schemas/identity.ts';
|
|
7
|
+
import { BranchName, FilePath, RepoName } from '../schemas/names.ts';
|
|
8
|
+
import { RefUpdate } from '../schemas/ref-update.ts';
|
|
9
|
+
import { Sha } from '../schemas/sha.ts';
|
|
10
|
+
|
|
11
|
+
/** Input of `syncBranch`. */
|
|
12
|
+
export const SyncBranchInput = z
|
|
13
|
+
.object({
|
|
14
|
+
repo: RepoName.describe('Repository holding both branches.'),
|
|
15
|
+
from: BranchName.describe('Branch whose commits are brought into `into`.'),
|
|
16
|
+
into: BranchName.describe(
|
|
17
|
+
'Branch brought up to date; never rewritten, only fast-forwarded or merged into.',
|
|
18
|
+
),
|
|
19
|
+
author: Identity.optional().describe(
|
|
20
|
+
'Author and committer of a merge commit, if one is needed. Absent: the configured service identity.',
|
|
21
|
+
),
|
|
22
|
+
message: z
|
|
23
|
+
.string()
|
|
24
|
+
.min(1)
|
|
25
|
+
.max(65_536)
|
|
26
|
+
.optional()
|
|
27
|
+
.describe(
|
|
28
|
+
'Message of a merge commit, if one is needed. Absent: "Merge branch \'<from>\' into <into>".',
|
|
29
|
+
),
|
|
30
|
+
})
|
|
31
|
+
.strict()
|
|
32
|
+
.refine((input) => input.from !== input.into, { message: 'from and into must differ', path: ['into'] })
|
|
33
|
+
.meta({
|
|
34
|
+
id: 'SyncBranchInput',
|
|
35
|
+
title: 'syncBranch input',
|
|
36
|
+
description:
|
|
37
|
+
'Input of syncBranch(): bring `into` up to date with `from` without rewriting `into`. Fails with ref_not_found if either branch is missing and unrelated_histories if they share no ancestor.',
|
|
38
|
+
examples: [{ repo: 'acme-raw-content', from: 'main', into: 'staging' }],
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/** Input of `syncBranch`, inferred from {@link SyncBranchInput}. */
|
|
42
|
+
export type SyncBranchInput = z.input<typeof SyncBranchInput>;
|
|
43
|
+
|
|
44
|
+
/** `into` already contains `from`. */
|
|
45
|
+
export const SyncUpToDate = z
|
|
46
|
+
.object({
|
|
47
|
+
status: z.literal('up_to_date').describe('`into` already contains the head of `from`; nothing changed.'),
|
|
48
|
+
head: Sha.describe('The head of `into`, unchanged.'),
|
|
49
|
+
})
|
|
50
|
+
.strict()
|
|
51
|
+
.meta({
|
|
52
|
+
id: 'SyncUpToDate',
|
|
53
|
+
title: 'syncBranch: up to date',
|
|
54
|
+
description: 'syncBranch() found that `into` already contains the head of `from`.',
|
|
55
|
+
examples: [{ status: 'up_to_date', head: EXAMPLE_SHA_A }],
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/** `into` had no commits of its own and was fast-forwarded. */
|
|
59
|
+
export const SyncFastForward = z
|
|
60
|
+
.object({
|
|
61
|
+
status: z
|
|
62
|
+
.literal('fast_forward')
|
|
63
|
+
.describe('`into` had no commits of its own and now points at the head of `from`.'),
|
|
64
|
+
refUpdate: RefUpdate.describe('How `into` moved.'),
|
|
65
|
+
})
|
|
66
|
+
.strict()
|
|
67
|
+
.meta({
|
|
68
|
+
id: 'SyncFastForward',
|
|
69
|
+
title: 'syncBranch: fast-forward',
|
|
70
|
+
description:
|
|
71
|
+
'syncBranch() fast-forwarded `into` to the head of `from` with a ref update naming the old head.',
|
|
72
|
+
examples: [
|
|
73
|
+
{
|
|
74
|
+
status: 'fast_forward',
|
|
75
|
+
refUpdate: { ref: 'refs/heads/staging', oldSha: EXAMPLE_SHA_A, newSha: EXAMPLE_SHA_B },
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
/** Both sides had commits; a merge commit was written. */
|
|
81
|
+
export const SyncMerged = z
|
|
82
|
+
.object({
|
|
83
|
+
status: z
|
|
84
|
+
.literal('merged')
|
|
85
|
+
.describe('Both branches had commits; a file-level merge commit was written to `into`.'),
|
|
86
|
+
commit: Commit.describe(
|
|
87
|
+
'The merge commit; its parents are the old head of `into`, then the head of `from`.',
|
|
88
|
+
),
|
|
89
|
+
refUpdate: RefUpdate.describe('How `into` moved.'),
|
|
90
|
+
})
|
|
91
|
+
.strict()
|
|
92
|
+
.meta({
|
|
93
|
+
id: 'SyncMerged',
|
|
94
|
+
title: 'syncBranch: merged',
|
|
95
|
+
description:
|
|
96
|
+
'syncBranch() merged file by file against the merge base: a path changed on one side takes that side.',
|
|
97
|
+
examples: [
|
|
98
|
+
{
|
|
99
|
+
status: 'merged',
|
|
100
|
+
commit: EXAMPLE_COMMIT,
|
|
101
|
+
refUpdate: { ref: 'refs/heads/staging', oldSha: EXAMPLE_SHA_A, newSha: EXAMPLE_SHA_B },
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
/** Both sides changed the same paths differently; nothing was written. */
|
|
107
|
+
export const SyncConflict = z
|
|
108
|
+
.object({
|
|
109
|
+
status: z
|
|
110
|
+
.literal('conflict')
|
|
111
|
+
.describe('Some paths changed differently on both sides; nothing was written.'),
|
|
112
|
+
paths: z
|
|
113
|
+
.array(FilePath.describe('A conflicting path.'))
|
|
114
|
+
.min(1)
|
|
115
|
+
.describe(
|
|
116
|
+
'Every conflicting path, sorted in byte order: changed differently on both sides, or a file on one side where the other has a directory.',
|
|
117
|
+
),
|
|
118
|
+
base: Sha.describe('The merge base used.'),
|
|
119
|
+
fromHead: Sha.describe('The head of `from` merged.'),
|
|
120
|
+
intoHead: Sha.describe('The head of `into`, unchanged.'),
|
|
121
|
+
})
|
|
122
|
+
.strict()
|
|
123
|
+
.meta({
|
|
124
|
+
id: 'SyncConflict',
|
|
125
|
+
title: 'syncBranch: conflict',
|
|
126
|
+
description: 'syncBranch() could not merge: the listed paths conflict. `into` is unchanged.',
|
|
127
|
+
examples: [
|
|
128
|
+
{
|
|
129
|
+
status: 'conflict',
|
|
130
|
+
paths: ['content/about.md'],
|
|
131
|
+
base: '4b825dc642cb6eb9a060e54bf8d69288fbee4904',
|
|
132
|
+
fromHead: EXAMPLE_SHA_B,
|
|
133
|
+
intoHead: EXAMPLE_SHA_A,
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
/** Output of `syncBranch`, discriminated by `status`. */
|
|
139
|
+
export const SyncBranchOutput = z
|
|
140
|
+
.discriminatedUnion('status', [SyncUpToDate, SyncFastForward, SyncMerged, SyncConflict])
|
|
141
|
+
.meta({
|
|
142
|
+
id: 'SyncBranchOutput',
|
|
143
|
+
title: 'syncBranch output',
|
|
144
|
+
description: 'Output of syncBranch(), discriminated by `status`.',
|
|
145
|
+
examples: [{ status: 'up_to_date', head: EXAMPLE_SHA_A }],
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
/** Output of `syncBranch`, inferred from {@link SyncBranchOutput}. */
|
|
149
|
+
export type SyncBranchOutput = z.infer<typeof SyncBranchOutput>;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import { ContentEncoding, FileContent, isBase64 } from './content-encoding.ts';
|
|
5
|
+
import { FilePath } from './names.ts';
|
|
6
|
+
|
|
7
|
+
const encodingField = ContentEncoding.default('text').describe(
|
|
8
|
+
'How `content` is encoded; defaults to "text".',
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
/** Rejects base64 content that is not valid padded base64. */
|
|
12
|
+
function base64Valid(value: { content?: string | undefined; encoding: 'text' | 'base64' }): boolean {
|
|
13
|
+
return value.encoding !== 'base64' || value.content === undefined || isBase64(value.content);
|
|
14
|
+
}
|
|
15
|
+
const base64Message = { message: 'content is not valid base64', path: ['content'] };
|
|
16
|
+
|
|
17
|
+
/** Create a file that must not exist yet. */
|
|
18
|
+
export const CreateAction = z
|
|
19
|
+
.object({
|
|
20
|
+
action: z.literal('create').describe('Create a new file. Fails with path_exists if the path exists.'),
|
|
21
|
+
path: FilePath.describe('Path of the file to create; it and every parent must not already be a file.'),
|
|
22
|
+
content: FileContent.describe('Content of the new file, encoded as `encoding` says.'),
|
|
23
|
+
encoding: encodingField,
|
|
24
|
+
})
|
|
25
|
+
.strict()
|
|
26
|
+
.refine(base64Valid, base64Message)
|
|
27
|
+
.meta({
|
|
28
|
+
id: 'CreateAction',
|
|
29
|
+
title: 'Create action',
|
|
30
|
+
description:
|
|
31
|
+
'Creates a file that does not exist yet. Fails with path_exists if the path is a file or a directory, and with path_conflict if a parent is a file. The new file is not executable.',
|
|
32
|
+
examples: [{ action: 'create', path: 'content/about.md', content: '# About\n', encoding: 'text' }],
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/** Replace the content of an existing file. */
|
|
36
|
+
export const UpdateAction = z
|
|
37
|
+
.object({
|
|
38
|
+
action: z
|
|
39
|
+
.literal('update')
|
|
40
|
+
.describe('Replace an existing file. Fails with path_not_found if it is absent.'),
|
|
41
|
+
path: FilePath.describe('Path of the existing file to replace.'),
|
|
42
|
+
content: FileContent.describe('New content of the file, encoded as `encoding` says.'),
|
|
43
|
+
encoding: encodingField,
|
|
44
|
+
})
|
|
45
|
+
.strict()
|
|
46
|
+
.refine(base64Valid, base64Message)
|
|
47
|
+
.meta({
|
|
48
|
+
id: 'UpdateAction',
|
|
49
|
+
title: 'Update action',
|
|
50
|
+
description:
|
|
51
|
+
'Replaces the content of an existing file, keeping its executable bit. Fails with path_not_found if the path is not a file.',
|
|
52
|
+
examples: [{ action: 'update', path: 'content/about.md', content: '# About us\n', encoding: 'text' }],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
/** Create or replace a file. */
|
|
56
|
+
export const UpsertAction = z
|
|
57
|
+
.object({
|
|
58
|
+
action: z.literal('upsert').describe('Create the file, or replace it if it exists.'),
|
|
59
|
+
path: FilePath.describe('Path of the file to create or replace.'),
|
|
60
|
+
content: FileContent.describe('Content of the file, encoded as `encoding` says.'),
|
|
61
|
+
encoding: encodingField,
|
|
62
|
+
})
|
|
63
|
+
.strict()
|
|
64
|
+
.refine(base64Valid, base64Message)
|
|
65
|
+
.meta({
|
|
66
|
+
id: 'UpsertAction',
|
|
67
|
+
title: 'Upsert action',
|
|
68
|
+
description:
|
|
69
|
+
'Creates the file, or replaces it (keeping its executable bit) if it exists. Fails with path_exists if the path is a directory and path_conflict if a parent is a file. Not part of the GitLab Commits API.',
|
|
70
|
+
examples: [{ action: 'upsert', path: 'assets/logo.png', content: 'iVBORw0KGgo=', encoding: 'base64' }],
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/** Delete an existing file. */
|
|
74
|
+
export const DeleteAction = z
|
|
75
|
+
.object({
|
|
76
|
+
action: z
|
|
77
|
+
.literal('delete')
|
|
78
|
+
.describe('Delete an existing file. Fails with path_not_found if it is absent.'),
|
|
79
|
+
path: FilePath.describe('Path of the file to delete. Directories left empty disappear with it.'),
|
|
80
|
+
})
|
|
81
|
+
.strict()
|
|
82
|
+
.meta({
|
|
83
|
+
id: 'DeleteAction',
|
|
84
|
+
title: 'Delete action',
|
|
85
|
+
description:
|
|
86
|
+
'Deletes an existing file. Fails with path_not_found if the path is not a file (a directory cannot be deleted in one action).',
|
|
87
|
+
examples: [{ action: 'delete', path: 'content/old.md' }],
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/** Move (rename) a file, optionally replacing its content. */
|
|
91
|
+
export const MoveAction = z
|
|
92
|
+
.object({
|
|
93
|
+
action: z.literal('move').describe('Move a file from `previousPath` to `path`.'),
|
|
94
|
+
path: FilePath.describe('Destination path; it must not exist and no parent of it may be a file.'),
|
|
95
|
+
previousPath: FilePath.describe('Path of the existing file to move.'),
|
|
96
|
+
content: FileContent.optional().describe(
|
|
97
|
+
'New content for the moved file, encoded as `encoding` says. Absent: the content is kept.',
|
|
98
|
+
),
|
|
99
|
+
encoding: encodingField,
|
|
100
|
+
})
|
|
101
|
+
.strict()
|
|
102
|
+
.refine((value) => value.path !== value.previousPath, {
|
|
103
|
+
message: 'path and previousPath must differ',
|
|
104
|
+
path: ['path'],
|
|
105
|
+
})
|
|
106
|
+
.refine(base64Valid, base64Message)
|
|
107
|
+
.meta({
|
|
108
|
+
id: 'MoveAction',
|
|
109
|
+
title: 'Move action',
|
|
110
|
+
description:
|
|
111
|
+
'Moves a file, keeping its executable bit and, unless `content` is given, its content. Fails with path_not_found if `previousPath` is not a file, path_exists if `path` exists, and path_conflict if a parent of `path` is a file.',
|
|
112
|
+
examples: [{ action: 'move', path: 'content/new.md', previousPath: 'content/old.md', encoding: 'text' }],
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
/** Set or clear the executable bit of an existing file. */
|
|
116
|
+
export const ChmodAction = z
|
|
117
|
+
.object({
|
|
118
|
+
action: z.literal('chmod').describe('Set or clear the executable bit of an existing file.'),
|
|
119
|
+
path: FilePath.describe('Path of the existing file.'),
|
|
120
|
+
executeFilemode: z
|
|
121
|
+
.boolean()
|
|
122
|
+
.describe('true: mode 100755 (executable); false: mode 100644 (not executable).'),
|
|
123
|
+
})
|
|
124
|
+
.strict()
|
|
125
|
+
.meta({
|
|
126
|
+
id: 'ChmodAction',
|
|
127
|
+
title: 'Chmod action',
|
|
128
|
+
description:
|
|
129
|
+
'Sets (true) or clears (false) the executable bit of an existing file. Fails with path_not_found if the path is not a file. Setting the bit it already has changes nothing.',
|
|
130
|
+
examples: [{ action: 'chmod', path: 'scripts/build.sh', executeFilemode: true }],
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
/** One change in a commit, discriminated by `action`. */
|
|
134
|
+
export const CommitAction = z
|
|
135
|
+
.discriminatedUnion('action', [
|
|
136
|
+
CreateAction,
|
|
137
|
+
UpdateAction,
|
|
138
|
+
UpsertAction,
|
|
139
|
+
DeleteAction,
|
|
140
|
+
MoveAction,
|
|
141
|
+
ChmodAction,
|
|
142
|
+
])
|
|
143
|
+
.meta({
|
|
144
|
+
id: 'CommitAction',
|
|
145
|
+
title: 'Commit action',
|
|
146
|
+
description:
|
|
147
|
+
'One change in a commit, discriminated by `action`. Actions apply in order, each to the result of the one before, with the GitLab Commits API semantics (plus upsert).',
|
|
148
|
+
examples: [
|
|
149
|
+
{ action: 'create', path: 'content/about.md', content: '# About\n', encoding: 'text' },
|
|
150
|
+
{ action: 'delete', path: 'content/old.md' },
|
|
151
|
+
],
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
/** One change in a commit, as accepted (before defaults). */
|
|
155
|
+
export type CommitActionInput = z.input<typeof CommitAction>;
|
|
156
|
+
/** One change in a commit, after parsing. */
|
|
157
|
+
export type CommitAction = z.output<typeof CommitAction>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import { EXAMPLE_COMMIT } from './examples.ts';
|
|
5
|
+
import { IdempotencyKey } from './names.ts';
|
|
6
|
+
import { Sha } from './sha.ts';
|
|
7
|
+
import { Signature } from './identity.ts';
|
|
8
|
+
|
|
9
|
+
/** A commit as stored in a repository. */
|
|
10
|
+
export const Commit = z
|
|
11
|
+
.object({
|
|
12
|
+
sha: Sha.describe('Id of this commit.'),
|
|
13
|
+
tree: Sha.describe('Id of the root tree this commit records.'),
|
|
14
|
+
parents: z
|
|
15
|
+
.array(Sha.describe('Id of a parent commit.'))
|
|
16
|
+
.max(2)
|
|
17
|
+
.describe(
|
|
18
|
+
'Parent commit ids in order: empty for a root commit, one for an ordinary commit, two for a merge (the branch merged into first).',
|
|
19
|
+
),
|
|
20
|
+
author: Signature.describe('Who wrote the change, and when.'),
|
|
21
|
+
committer: Signature.describe(
|
|
22
|
+
'Who recorded the commit, and when; equals the author unless one was given.',
|
|
23
|
+
),
|
|
24
|
+
message: z
|
|
25
|
+
.string()
|
|
26
|
+
.min(1)
|
|
27
|
+
.describe(
|
|
28
|
+
'Full commit message as stored, including any "Gateway-Idempotency-Key:" trailer the gateway appended.',
|
|
29
|
+
),
|
|
30
|
+
idempotencyKey: IdempotencyKey.nullable().describe(
|
|
31
|
+
'The key from the message\'s "Gateway-Idempotency-Key:" trailer, or null when the commit has none.',
|
|
32
|
+
),
|
|
33
|
+
})
|
|
34
|
+
.strict()
|
|
35
|
+
.meta({
|
|
36
|
+
id: 'Commit',
|
|
37
|
+
title: 'Commit',
|
|
38
|
+
description: 'A commit as stored in a repository, with its message trailer parsed out.',
|
|
39
|
+
examples: [EXAMPLE_COMMIT],
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/** A stored commit, inferred from {@link Commit}. */
|
|
43
|
+
export type Commit = z.infer<typeof Commit>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/** How file content is carried in a string. */
|
|
5
|
+
export const ContentEncoding = z.enum(['text', 'base64']).meta({
|
|
6
|
+
id: 'ContentEncoding',
|
|
7
|
+
title: 'Content encoding',
|
|
8
|
+
description: 'How file content is carried in a JSON string.',
|
|
9
|
+
enumDescriptions: {
|
|
10
|
+
text: 'The string is the file content itself, stored as UTF-8 bytes.',
|
|
11
|
+
base64:
|
|
12
|
+
'The string is standard base64 (RFC 4648, with padding) of the raw file bytes; use for binary files.',
|
|
13
|
+
},
|
|
14
|
+
examples: ['text', 'base64'],
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/** How file content is carried, inferred from {@link ContentEncoding}. */
|
|
18
|
+
export type ContentEncoding = z.infer<typeof ContentEncoding>;
|
|
19
|
+
|
|
20
|
+
/** The base64 alphabet followed by at most two "=" padding characters. */
|
|
21
|
+
const BASE64_CHARACTERS = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Whether a string is standard padded base64 (RFC 4648 §4): a multiple of four characters from the
|
|
25
|
+
* base64 alphabet, with "=" padding only at the end. Checked with a length test and one
|
|
26
|
+
* character-class scan rather than a grouped pattern, so it runs in linear time without recursion
|
|
27
|
+
* and stays safe at the full {@link FileContent} size on every JavaScript engine.
|
|
28
|
+
*/
|
|
29
|
+
export function isBase64(value: string): boolean {
|
|
30
|
+
return value.length % 4 === 0 && BASE64_CHARACTERS.test(value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** File content as text or base64, at most 48 MiB of characters. */
|
|
34
|
+
export const FileContent = z
|
|
35
|
+
.string()
|
|
36
|
+
.max(48 * 1024 * 1024)
|
|
37
|
+
.meta({
|
|
38
|
+
id: 'FileContent',
|
|
39
|
+
title: 'File content',
|
|
40
|
+
description:
|
|
41
|
+
'File content as a string, interpreted according to the accompanying encoding: UTF-8 text, or base64 of the raw bytes. At most 48 MiB of characters (32 MiB of bytes as base64). An empty string is an empty file.',
|
|
42
|
+
examples: ['# Hello\n', 'iVBORw0KGgo='],
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/** File content, inferred from {@link FileContent}. */
|
|
46
|
+
export type FileContent = z.infer<typeof FileContent>;
|
|
47
|
+
|
|
48
|
+
/** File content returned by a read, with no length cap. */
|
|
49
|
+
export const ReadContent = z.string().meta({
|
|
50
|
+
id: 'ReadContent',
|
|
51
|
+
title: 'Read content',
|
|
52
|
+
description:
|
|
53
|
+
'File content returned by a read, interpreted according to the accompanying encoding: UTF-8 text, or base64 of the raw bytes. Not length-capped: base64 output is 4/3 the size of the bytes and files can arrive over git push at any size, so a read returns whatever the repository holds. An empty string is an empty file.',
|
|
54
|
+
examples: ['# Hello\n', 'iVBORw0KGgo='],
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/** File content returned by a read, inferred from {@link ReadContent}. */
|
|
58
|
+
export type ReadContent = z.infer<typeof ReadContent>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
|
|
3
|
+
/** Example values shared by the schemas' `examples` metadata, so examples agree with each other. */
|
|
4
|
+
export const EXAMPLE_SHA_A = '1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d';
|
|
5
|
+
/** A second example commit id. */
|
|
6
|
+
export const EXAMPLE_SHA_B = '8f3c2a9e1b7d4c6f0a5e2d9b8c7a6f5e4d3c2b1a';
|
|
7
|
+
/** An example tree id (git's empty tree). */
|
|
8
|
+
export const EXAMPLE_TREE = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
|
|
9
|
+
/** An example identity. */
|
|
10
|
+
export const EXAMPLE_IDENTITY = { name: 'Ada Lovelace', email: 'ada@example.com' };
|
|
11
|
+
/** An example timestamp. */
|
|
12
|
+
export const EXAMPLE_TIMESTAMP = '2026-11-20T09:30:00.000Z';
|
|
13
|
+
/** An example signature. */
|
|
14
|
+
export const EXAMPLE_SIGNATURE = { ...EXAMPLE_IDENTITY, date: EXAMPLE_TIMESTAMP };
|
|
15
|
+
/** An example stored commit. */
|
|
16
|
+
export const EXAMPLE_COMMIT = {
|
|
17
|
+
sha: EXAMPLE_SHA_B,
|
|
18
|
+
tree: EXAMPLE_TREE,
|
|
19
|
+
parents: [EXAMPLE_SHA_A],
|
|
20
|
+
author: EXAMPLE_SIGNATURE,
|
|
21
|
+
committer: EXAMPLE_SIGNATURE,
|
|
22
|
+
message: 'Update about page\n\nGateway-Idempotency-Key: cms:publish:2f9c1e\n',
|
|
23
|
+
idempotencyKey: 'cms:publish:2f9c1e',
|
|
24
|
+
};
|