@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
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @leed-ai/git-gateway-contract
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Zod schemas and the RPC interface of git-gateway (the API contract), with an in-memory reference implementation.
|
|
4
|
+
|
|
5
|
+
Part of [git-gateway](https://github.com/leed-ai/git-gateway). Status: in development; see the [design](https://github.com/leed-ai/git-gateway/blob/main/docs/design.md).
|
|
6
|
+
|
|
7
|
+
Peer dependencies: `zod` (`^4`). Install them alongside this package.
|
|
8
|
+
|
|
9
|
+
## Modules
|
|
10
|
+
|
|
11
|
+
Every module is its own export; there is no barrel.
|
|
12
|
+
|
|
13
|
+
| Export | Contents |
|
|
14
|
+
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| `./git-gateway` | `GitGateway` (the RPC interface) and `RPC_SCHEMAS`, the input and output schema per method. |
|
|
16
|
+
| `./rpc/<method>` | `<Method>Input` and `<Method>Output` schemas and types for each RPC method. |
|
|
17
|
+
| `./schemas/<name>` | Shared schemas: `Sha`, names, `Identity`, `CommitAction`, `Commit`, `RefUpdate`, `TreeEntry`, `GatewayConfig`, `GatewayErrorBody`. |
|
|
18
|
+
| `./gateway-error` | `GatewayError`, `readGatewayError` (also across Workers RPC), `isGatewayError`. |
|
|
19
|
+
| `./reference/reference-gateway` | `createReferenceGateway()`: the whole interface in memory. |
|
|
20
|
+
| `./reference/clock` | `steppingClock()`: a deterministic clock, for deterministic ids. |
|
|
21
|
+
| `./behaviour/behaviour-suite` | `registerBehaviourSuite()` and `BEHAVIOUR_CASES`: the suite every implementation must pass. |
|
|
22
|
+
|
|
23
|
+
## Testing a consumer against the reference
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { createReferenceGateway } from '@leed-ai/git-gateway-contract/reference/reference-gateway';
|
|
27
|
+
|
|
28
|
+
const gateway = createReferenceGateway();
|
|
29
|
+
await gateway.createRepo({ repo: 'site' });
|
|
30
|
+
await gateway.commit({
|
|
31
|
+
repo: 'site',
|
|
32
|
+
branch: 'main',
|
|
33
|
+
message: 'Seed',
|
|
34
|
+
author: { name: 'CMS', email: 'cms@example.com' },
|
|
35
|
+
idempotencyKey: 'seed-1',
|
|
36
|
+
actions: [{ action: 'create', path: 'index.md', content: '# Hello\n' }],
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Running the behaviour suite against an implementation
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { describe, it } from 'vitest';
|
|
44
|
+
import { registerBehaviourSuite } from '@leed-ai/git-gateway-contract/behaviour/behaviour-suite';
|
|
45
|
+
|
|
46
|
+
registerBehaviourSuite({ describe, it }, { createGateway: () => myGateway, cleanup: true });
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
Apache-2.0
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { GatewayErrorOf } from "../gateway-error.js";
|
|
2
|
+
import { n as GatewayErrorCode } from "../gateway-error-body-BWzZFAQI.js";
|
|
3
|
+
/** The error a behaviour case throws when the implementation under test breaks a rule. */
|
|
4
|
+
export declare class BehaviourFailure extends Error {
|
|
5
|
+
readonly name = "BehaviourFailure";
|
|
6
|
+
}
|
|
7
|
+
/** True when two values are structurally equal (plain objects, arrays and primitives). */
|
|
8
|
+
export declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
9
|
+
/** Fails unless `condition` holds. */
|
|
10
|
+
export declare function assertTrue(condition: boolean, message: string): asserts condition;
|
|
11
|
+
/** Fails unless `actual` structurally equals `expected`. */
|
|
12
|
+
export declare function assertEqual(actual: unknown, expected: unknown, message: string): void;
|
|
13
|
+
/** Awaits `call`, fails unless it rejects with a gateway error of `code`, and returns that error's body. */
|
|
14
|
+
export declare function expectGatewayError<C extends GatewayErrorCode>(call: Promise<unknown>, code: C): Promise<GatewayErrorOf<C>>;
|
|
15
|
+
/** Fails unless the output has `status`, and returns it narrowed to that branch. */
|
|
16
|
+
export declare function expectStatus<T extends {
|
|
17
|
+
status: string;
|
|
18
|
+
}, S extends T['status']>(output: T, status: S): Extract<T, {
|
|
19
|
+
status: S;
|
|
20
|
+
}>;
|
|
21
|
+
/** Fails when the value is null or undefined, and returns it otherwise. */
|
|
22
|
+
export declare function present<T>(value: T | null | undefined, message: string): T;
|
|
23
|
+
//# sourceMappingURL=assertions.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readGatewayError } from "../gateway-error.js";
|
|
2
|
+
// src/behaviour/assertions.ts
|
|
3
|
+
/** The error a behaviour case throws when the implementation under test breaks a rule. */
|
|
4
|
+
var BehaviourFailure = class extends Error {
|
|
5
|
+
name = "BehaviourFailure";
|
|
6
|
+
};
|
|
7
|
+
const show = (value) => JSON.stringify(value, null, 2) ?? String(value);
|
|
8
|
+
/** True when two values are structurally equal (plain objects, arrays and primitives). */
|
|
9
|
+
function deepEqual(a, b) {
|
|
10
|
+
if (Object.is(a, b)) return true;
|
|
11
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
12
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
13
|
+
const keysA = Object.keys(a).filter((key) => Reflect.get(a, key) !== void 0);
|
|
14
|
+
const keysB = Object.keys(b).filter((key) => Reflect.get(b, key) !== void 0);
|
|
15
|
+
if (keysA.length !== keysB.length) return false;
|
|
16
|
+
return keysA.every((key) => deepEqual(Reflect.get(a, key), Reflect.get(b, key)));
|
|
17
|
+
}
|
|
18
|
+
/** Fails unless `condition` holds. */
|
|
19
|
+
function assertTrue(condition, message) {
|
|
20
|
+
if (!condition) throw new BehaviourFailure(message);
|
|
21
|
+
}
|
|
22
|
+
/** Fails unless `actual` structurally equals `expected`. */
|
|
23
|
+
function assertEqual(actual, expected, message) {
|
|
24
|
+
if (!deepEqual(actual, expected)) throw new BehaviourFailure(`${message}\nexpected: ${show(expected)}\nactual: ${show(actual)}`);
|
|
25
|
+
}
|
|
26
|
+
function hasCode(body, code) {
|
|
27
|
+
return body.code === code;
|
|
28
|
+
}
|
|
29
|
+
/** Awaits `call`, fails unless it rejects with a gateway error of `code`, and returns that error's body. */
|
|
30
|
+
async function expectGatewayError(call, code) {
|
|
31
|
+
let outcome;
|
|
32
|
+
try {
|
|
33
|
+
outcome = await call;
|
|
34
|
+
} catch (thrown) {
|
|
35
|
+
const body = readGatewayError(thrown);
|
|
36
|
+
if (body !== null && hasCode(body, code)) return body;
|
|
37
|
+
throw new BehaviourFailure(`expected a ${code} gateway error, got: ${show(body ?? String(thrown))}`);
|
|
38
|
+
}
|
|
39
|
+
throw new BehaviourFailure(`expected a ${code} gateway error, but the call resolved to ${show(outcome)}`);
|
|
40
|
+
}
|
|
41
|
+
function hasStatus(output, status) {
|
|
42
|
+
return output.status === status;
|
|
43
|
+
}
|
|
44
|
+
/** Fails unless the output has `status`, and returns it narrowed to that branch. */
|
|
45
|
+
function expectStatus(output, status) {
|
|
46
|
+
if (hasStatus(output, status)) return output;
|
|
47
|
+
throw new BehaviourFailure(`expected status "${status}", got ${show(output)}`);
|
|
48
|
+
}
|
|
49
|
+
/** Fails when the value is null or undefined, and returns it otherwise. */
|
|
50
|
+
function present(value, message) {
|
|
51
|
+
if (value === null || value === void 0) throw new BehaviourFailure(message);
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
export { BehaviourFailure, assertEqual, assertTrue, deepEqual, expectGatewayError, expectStatus, present };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=assertions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertions.js","names":[],"sources":["../../src/behaviour/assertions.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { readGatewayError, type GatewayErrorOf } from '../gateway-error.ts';\nimport type { GatewayErrorBody, GatewayErrorCode } from '../schemas/gateway-error-body.ts';\n\n/** The error a behaviour case throws when the implementation under test breaks a rule. */\nexport class BehaviourFailure extends Error {\n override readonly name = 'BehaviourFailure';\n}\n\nconst show = (value: unknown): string => JSON.stringify(value, null, 2) ?? String(value);\n\n/** True when two values are structurally equal (plain objects, arrays and primitives). */\nexport function deepEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n const keysA = Object.keys(a).filter((key) => Reflect.get(a, key) !== undefined);\n const keysB = Object.keys(b).filter((key) => Reflect.get(b, key) !== undefined);\n if (keysA.length !== keysB.length) return false;\n return keysA.every((key) => deepEqual(Reflect.get(a, key), Reflect.get(b, key)));\n}\n\n/** Fails unless `condition` holds. */\nexport function assertTrue(condition: boolean, message: string): asserts condition {\n if (!condition) throw new BehaviourFailure(message);\n}\n\n/** Fails unless `actual` structurally equals `expected`. */\nexport function assertEqual(actual: unknown, expected: unknown, message: string): void {\n if (!deepEqual(actual, expected)) {\n throw new BehaviourFailure(`${message}\\nexpected: ${show(expected)}\\nactual: ${show(actual)}`);\n }\n}\n\nfunction hasCode<C extends GatewayErrorCode>(body: GatewayErrorBody, code: C): body is GatewayErrorOf<C> {\n return body.code === code;\n}\n\n/** Awaits `call`, fails unless it rejects with a gateway error of `code`, and returns that error's body. */\nexport async function expectGatewayError<C extends GatewayErrorCode>(\n call: Promise<unknown>,\n code: C,\n): Promise<GatewayErrorOf<C>> {\n let outcome: unknown;\n try {\n outcome = await call;\n } catch (thrown) {\n const body = readGatewayError(thrown);\n if (body !== null && hasCode(body, code)) return body;\n throw new BehaviourFailure(`expected a ${code} gateway error, got: ${show(body ?? String(thrown))}`);\n }\n throw new BehaviourFailure(`expected a ${code} gateway error, but the call resolved to ${show(outcome)}`);\n}\n\nfunction hasStatus<T extends { status: string }, S extends T['status']>(\n output: T,\n status: S,\n): output is Extract<T, { status: S }> {\n return output.status === status;\n}\n\n/** Fails unless the output has `status`, and returns it narrowed to that branch. */\nexport function expectStatus<T extends { status: string }, S extends T['status']>(\n output: T,\n status: S,\n): Extract<T, { status: S }> {\n if (hasStatus(output, status)) return output;\n throw new BehaviourFailure(`expected status \"${status}\", got ${show(output)}`);\n}\n\n/** Fails when the value is null or undefined, and returns it otherwise. */\nexport function present<T>(value: T | null | undefined, message: string): T {\n if (value === null || value === undefined) throw new BehaviourFailure(message);\n return value;\n}\n"],"mappings":";;;AAKA,IAAa,mBAAb,cAAsC,MAAM;CAC1C,OAAyB;AAC3B;AAEA,MAAM,QAAQ,UAA2B,KAAK,UAAU,OAAO,MAAM,CAAC,KAAK,OAAO,KAAK;;AAGvF,SAAgB,UAAU,GAAY,GAAqB;CACzD,IAAI,OAAO,GAAG,GAAG,CAAC,GAAG,OAAO;CAC5B,IAAI,OAAO,MAAM,YAAY,OAAO,MAAM,YAAY,MAAM,QAAQ,MAAM,MAAM,OAAO;CACvF,IAAI,MAAM,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,GAAG,OAAO;CAClD,MAAM,QAAQ,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,QAAQ,QAAQ,IAAI,GAAG,GAAG,MAAM,KAAA,CAAS;CAC9E,MAAM,QAAQ,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,QAAQ,QAAQ,IAAI,GAAG,GAAG,MAAM,KAAA,CAAS;CAC9E,IAAI,MAAM,WAAW,MAAM,QAAQ,OAAO;CAC1C,OAAO,MAAM,OAAO,QAAQ,UAAU,QAAQ,IAAI,GAAG,GAAG,GAAG,QAAQ,IAAI,GAAG,GAAG,CAAC,CAAC;AACjF;;AAGA,SAAgB,WAAW,WAAoB,SAAoC;CACjF,IAAI,CAAC,WAAW,MAAM,IAAI,iBAAiB,OAAO;AACpD;;AAGA,SAAgB,YAAY,QAAiB,UAAmB,SAAuB;CACrF,IAAI,CAAC,UAAU,QAAQ,QAAQ,GAC7B,MAAM,IAAI,iBAAiB,GAAG,QAAQ,cAAc,KAAK,QAAQ,EAAE,cAAc,KAAK,MAAM,GAAG;AAEnG;AAEA,SAAS,QAAoC,MAAwB,MAAoC;CACvG,OAAO,KAAK,SAAS;AACvB;;AAGA,eAAsB,mBACpB,MACA,MAC4B;CAC5B,IAAI;CACJ,IAAI;EACF,UAAU,MAAM;CAClB,SAAS,QAAQ;EACf,MAAM,OAAO,iBAAiB,MAAM;EACpC,IAAI,SAAS,QAAQ,QAAQ,MAAM,IAAI,GAAG,OAAO;EACjD,MAAM,IAAI,iBAAiB,cAAc,KAAK,uBAAuB,KAAK,QAAQ,OAAO,MAAM,CAAC,GAAG;CACrG;CACA,MAAM,IAAI,iBAAiB,cAAc,KAAK,2CAA2C,KAAK,OAAO,GAAG;AAC1G;AAEA,SAAS,UACP,QACA,QACqC;CACrC,OAAO,OAAO,WAAW;AAC3B;;AAGA,SAAgB,aACd,QACA,QAC2B;CAC3B,IAAI,UAAU,QAAQ,MAAM,GAAG,OAAO;CACtC,MAAM,IAAI,iBAAiB,oBAAoB,OAAO,SAAS,KAAK,MAAM,GAAG;AAC/E;;AAGA,SAAgB,QAAW,OAA6B,SAAoB;CAC1E,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,MAAM,IAAI,iBAAiB,OAAO;CAC7E,OAAO;AACT"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { t as GitGateway } from "../git-gateway-VA9Tc5tn.js";
|
|
2
|
+
/** What a behaviour case runs against: the gateway under test and a repository name of its own. */
|
|
3
|
+
export interface BehaviourContext {
|
|
4
|
+
readonly gateway: GitGateway;
|
|
5
|
+
/** A repository name no other case uses; the case creates the repository itself. */
|
|
6
|
+
readonly repo: string;
|
|
7
|
+
}
|
|
8
|
+
/** One rule of the contract, checked through the {@link GitGateway} interface alone. */
|
|
9
|
+
export interface BehaviourCase {
|
|
10
|
+
/** The area of the contract, e.g. "commit actions". */
|
|
11
|
+
readonly group: string;
|
|
12
|
+
/** What the case checks, phrased as the rule. */
|
|
13
|
+
readonly name: string;
|
|
14
|
+
/** Resolves when the implementation follows the rule; rejects with a BehaviourFailure otherwise. */
|
|
15
|
+
readonly run: (context: BehaviourContext) => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/** Declares a behaviour case. */
|
|
18
|
+
export declare function behaviourCase(group: string, name: string, run: (context: BehaviourContext) => Promise<void>): BehaviourCase;
|
|
19
|
+
//# sourceMappingURL=behaviour-case.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behaviour-case.js","names":[],"sources":["../../src/behaviour/behaviour-case.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport type { GitGateway } from '../git-gateway.ts';\n\n/** What a behaviour case runs against: the gateway under test and a repository name of its own. */\nexport interface BehaviourContext {\n readonly gateway: GitGateway;\n /** A repository name no other case uses; the case creates the repository itself. */\n readonly repo: string;\n}\n\n/** One rule of the contract, checked through the {@link GitGateway} interface alone. */\nexport interface BehaviourCase {\n /** The area of the contract, e.g. \"commit actions\". */\n readonly group: string;\n /** What the case checks, phrased as the rule. */\n readonly name: string;\n /** Resolves when the implementation follows the rule; rejects with a BehaviourFailure otherwise. */\n readonly run: (context: BehaviourContext) => Promise<void>;\n}\n\n/** Declares a behaviour case. */\nexport function behaviourCase(\n group: string,\n name: string,\n run: (context: BehaviourContext) => Promise<void>,\n): BehaviourCase {\n return { group, name, run };\n}\n"],"mappings":";;AAqBA,SAAgB,cACd,OACA,MACA,KACe;CACf,OAAO;EAAE;EAAO;EAAM;CAAI;AAC5B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { t as GitGateway } from "../git-gateway-VA9Tc5tn.js";
|
|
2
|
+
import { BehaviourCase } from "./behaviour-case.js";
|
|
3
|
+
/** Every behaviour case, grouped by area of the contract. */
|
|
4
|
+
export declare const BEHAVIOUR_CASES: readonly BehaviourCase[];
|
|
5
|
+
/** The two functions of a test framework the suite registers through (Vitest, Jest, bun:test, node:test…). */
|
|
6
|
+
export interface TestRegistrar {
|
|
7
|
+
describe(name: string, body: () => void): void;
|
|
8
|
+
it(name: string, body: () => Promise<void>): void;
|
|
9
|
+
}
|
|
10
|
+
/** How to run the suite against one implementation. */
|
|
11
|
+
export interface BehaviourSuiteOptions {
|
|
12
|
+
/** Suite title; default "GitGateway behaviour". */
|
|
13
|
+
readonly name?: string;
|
|
14
|
+
/** Returns the implementation under test; called once per case. */
|
|
15
|
+
readonly createGateway: () => GitGateway | Promise<GitGateway>;
|
|
16
|
+
/** Prefix of every repository name the cases create; default "behaviour". Keep it short. */
|
|
17
|
+
readonly repoPrefix?: string;
|
|
18
|
+
/** Delete each case's repository when the case ends (for shared, long-lived gateways); default false. */
|
|
19
|
+
readonly cleanup?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** Runs one case against a fresh gateway and a repository name no other case uses. */
|
|
22
|
+
export declare function runBehaviourCase(entry: BehaviourCase, options: BehaviourSuiteOptions): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Registers the behaviour suite of the {@link GitGateway} contract with a test framework: one test
|
|
25
|
+
* per case, grouped by area. The in-memory reference passes it; the real gateway must pass it too.
|
|
26
|
+
*
|
|
27
|
+
* registerBehaviourSuite({ describe, it }, { createGateway: () => createReferenceGateway() });
|
|
28
|
+
*/
|
|
29
|
+
export declare function registerBehaviourSuite(test: TestRegistrar, options: BehaviourSuiteOptions): void;
|
|
30
|
+
//# sourceMappingURL=behaviour-suite.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { commitActionCases } from "./commit-action-cases.js";
|
|
2
|
+
import { commitWriteCases } from "./commit-write-cases.js";
|
|
3
|
+
import { lifecycleCases } from "./lifecycle-cases.js";
|
|
4
|
+
import { promoteCases } from "./promote-cases.js";
|
|
5
|
+
import { readCases } from "./read-cases.js";
|
|
6
|
+
import { syncCases } from "./sync-cases.js";
|
|
7
|
+
// src/behaviour/behaviour-suite.ts
|
|
8
|
+
/** Every behaviour case, grouped by area of the contract. */
|
|
9
|
+
const BEHAVIOUR_CASES = [
|
|
10
|
+
...lifecycleCases,
|
|
11
|
+
...commitActionCases,
|
|
12
|
+
...commitWriteCases,
|
|
13
|
+
...readCases,
|
|
14
|
+
...syncCases,
|
|
15
|
+
...promoteCases
|
|
16
|
+
];
|
|
17
|
+
const slug = (text) => text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40);
|
|
18
|
+
let runCounter = 0;
|
|
19
|
+
/** Runs one case against a fresh gateway and a repository name no other case uses. */
|
|
20
|
+
async function runBehaviourCase(entry, options) {
|
|
21
|
+
runCounter += 1;
|
|
22
|
+
const gateway = await options.createGateway();
|
|
23
|
+
const unique = `${runCounter}-${crypto.randomUUID().slice(0, 8)}`;
|
|
24
|
+
const repo = `${options.repoPrefix ?? "behaviour"}-${slug(entry.name)}-${unique}`.slice(0, 100);
|
|
25
|
+
try {
|
|
26
|
+
await entry.run({
|
|
27
|
+
gateway,
|
|
28
|
+
repo
|
|
29
|
+
});
|
|
30
|
+
} finally {
|
|
31
|
+
if (options.cleanup === true) await gateway.deleteRepo({ repo });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Registers the behaviour suite of the {@link GitGateway} contract with a test framework: one test
|
|
36
|
+
* per case, grouped by area. The in-memory reference passes it; the real gateway must pass it too.
|
|
37
|
+
*
|
|
38
|
+
* registerBehaviourSuite({ describe, it }, { createGateway: () => createReferenceGateway() });
|
|
39
|
+
*/
|
|
40
|
+
function registerBehaviourSuite(test, options) {
|
|
41
|
+
const groups = Map.groupBy(BEHAVIOUR_CASES, (entry) => entry.group);
|
|
42
|
+
test.describe(options.name ?? "GitGateway behaviour", () => {
|
|
43
|
+
for (const [group, cases] of groups) test.describe(group, () => {
|
|
44
|
+
for (const entry of cases) test.it(entry.name, () => runBehaviourCase(entry, options));
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export { BEHAVIOUR_CASES, registerBehaviourSuite, runBehaviourCase };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=behaviour-suite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behaviour-suite.js","names":[],"sources":["../../src/behaviour/behaviour-suite.ts"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport type { GitGateway } from '../git-gateway.ts';\nimport type { BehaviourCase } from './behaviour-case.ts';\nimport { commitActionCases } from './commit-action-cases.ts';\nimport { commitWriteCases } from './commit-write-cases.ts';\nimport { lifecycleCases } from './lifecycle-cases.ts';\nimport { promoteCases } from './promote-cases.ts';\nimport { readCases } from './read-cases.ts';\nimport { syncCases } from './sync-cases.ts';\n\n/** Every behaviour case, grouped by area of the contract. */\nexport const BEHAVIOUR_CASES: readonly BehaviourCase[] = [\n ...lifecycleCases,\n ...commitActionCases,\n ...commitWriteCases,\n ...readCases,\n ...syncCases,\n ...promoteCases,\n];\n\n/** The two functions of a test framework the suite registers through (Vitest, Jest, bun:test, node:test…). */\nexport interface TestRegistrar {\n describe(name: string, body: () => void): void;\n it(name: string, body: () => Promise<void>): void;\n}\n\n/** How to run the suite against one implementation. */\nexport interface BehaviourSuiteOptions {\n /** Suite title; default \"GitGateway behaviour\". */\n readonly name?: string;\n /** Returns the implementation under test; called once per case. */\n readonly createGateway: () => GitGateway | Promise<GitGateway>;\n /** Prefix of every repository name the cases create; default \"behaviour\". Keep it short. */\n readonly repoPrefix?: string;\n /** Delete each case's repository when the case ends (for shared, long-lived gateways); default false. */\n readonly cleanup?: boolean;\n}\n\nconst slug = (text: string): string =>\n text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-|-$/g, '')\n .slice(0, 40);\n\nlet runCounter = 0;\n\n/** Runs one case against a fresh gateway and a repository name no other case uses. */\nexport async function runBehaviourCase(entry: BehaviourCase, options: BehaviourSuiteOptions): Promise<void> {\n runCounter += 1;\n const gateway = await options.createGateway();\n const unique = `${runCounter}-${crypto.randomUUID().slice(0, 8)}`;\n const repo = `${options.repoPrefix ?? 'behaviour'}-${slug(entry.name)}-${unique}`.slice(0, 100);\n try {\n await entry.run({ gateway, repo });\n } finally {\n if (options.cleanup === true) await gateway.deleteRepo({ repo });\n }\n}\n\n/**\n * Registers the behaviour suite of the {@link GitGateway} contract with a test framework: one test\n * per case, grouped by area. The in-memory reference passes it; the real gateway must pass it too.\n *\n * registerBehaviourSuite({ describe, it }, { createGateway: () => createReferenceGateway() });\n */\nexport function registerBehaviourSuite(test: TestRegistrar, options: BehaviourSuiteOptions): void {\n const groups = Map.groupBy(BEHAVIOUR_CASES, (entry) => entry.group);\n test.describe(options.name ?? 'GitGateway behaviour', () => {\n for (const [group, cases] of groups) {\n test.describe(group, () => {\n for (const entry of cases) test.it(entry.name, () => runBehaviourCase(entry, options));\n });\n }\n });\n}\n"],"mappings":";;;;;;;;AAWA,MAAa,kBAA4C;CACvD,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACL;AAoBA,MAAM,QAAQ,SACZ,KACG,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,UAAU,EAAE,CAAC,CACrB,MAAM,GAAG,EAAE;AAEhB,IAAI,aAAa;;AAGjB,eAAsB,iBAAiB,OAAsB,SAA+C;CAC1G,cAAc;CACd,MAAM,UAAU,MAAM,QAAQ,cAAc;CAC5C,MAAM,SAAS,GAAG,WAAW,GAAG,OAAO,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC;CAC9D,MAAM,OAAO,GAAG,QAAQ,cAAc,YAAY,GAAG,KAAK,MAAM,IAAI,EAAE,GAAG,SAAS,MAAM,GAAG,GAAG;CAC9F,IAAI;EACF,MAAM,MAAM,IAAI;GAAE;GAAS;EAAK,CAAC;CACnC,UAAU;EACR,IAAI,QAAQ,YAAY,MAAM,MAAM,QAAQ,WAAW,EAAE,KAAK,CAAC;CACjE;AACF;;;;;;;AAQA,SAAgB,uBAAuB,MAAqB,SAAsC;CAChG,MAAM,SAAS,IAAI,QAAQ,kBAAkB,UAAU,MAAM,KAAK;CAClE,KAAK,SAAS,QAAQ,QAAQ,8BAA8B;EAC1D,KAAK,MAAM,CAAC,OAAO,UAAU,QAC3B,KAAK,SAAS,aAAa;GACzB,KAAK,MAAM,SAAS,OAAO,KAAK,GAAG,MAAM,YAAY,iBAAiB,OAAO,OAAO,CAAC;EACvF,CAAC;CAEL,CAAC;AACH"}
|