@ref0/git 0.7.0 → 0.8.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.
Files changed (191) hide show
  1. package/dist/access/private-refs.mjs +0 -2
  2. package/dist/auth/authorize.mjs +31 -24
  3. package/dist/auth/bridge.mjs +8 -8
  4. package/dist/auth/fences.d.mts +0 -1
  5. package/dist/auth/fences.mjs +1 -1
  6. package/dist/auth/grants.d.mts +0 -1
  7. package/dist/auth/grants.mjs +2 -2
  8. package/dist/auth/host-function.d.mts +1 -7
  9. package/dist/auth/host-function.mjs +38 -38
  10. package/dist/auth/identify.d.mts +0 -1
  11. package/dist/auth/identify.mjs +1 -1
  12. package/dist/auth/policy.d.mts +7 -4
  13. package/dist/auth/policy.mjs +13 -10
  14. package/dist/auth/token-rows.mjs +2 -5
  15. package/dist/auth/tokens-layer.d.mts +0 -2
  16. package/dist/auth/tokens-public.d.mts +3 -3
  17. package/dist/auth/tokens-public.mjs +4 -2
  18. package/dist/auth/tokens.d.mts +6 -1
  19. package/dist/auth/tokens.mjs +7 -1
  20. package/dist/client/client.d.mts +22 -15
  21. package/dist/client/client.mjs +31 -27
  22. package/dist/client/git-http.mjs +22 -5
  23. package/dist/client/local.mjs +1 -1
  24. package/dist/client/namespace.d.mts +2 -0
  25. package/dist/client/push-upload.d.mts +1 -0
  26. package/dist/client/push-upload.mjs +169 -2
  27. package/dist/client/remote-helper.mjs +2 -4
  28. package/dist/client/remote.mjs +37 -15
  29. package/dist/client/run-remote-helper.mjs +4 -4
  30. package/dist/client/transport.mjs +26 -19
  31. package/dist/contracts/actors.d.mts +57 -28
  32. package/dist/contracts/actors.mjs +38 -2
  33. package/dist/contracts/authorize.d.mts +21 -15
  34. package/dist/contracts/callers.mjs +40 -0
  35. package/dist/contracts/client.d.mts +16 -9
  36. package/dist/contracts/events.d.mts +12 -10
  37. package/dist/contracts/events.mjs +8 -6
  38. package/dist/contracts/files.d.mts +42 -42
  39. package/dist/contracts/forks.d.mts +0 -24
  40. package/dist/contracts/git-hooks.d.mts +217 -0
  41. package/dist/contracts/git-hooks.mjs +3 -1
  42. package/dist/contracts/grants.d.mts +46 -27
  43. package/dist/contracts/lfs.d.mts +17 -4
  44. package/dist/contracts/merges.d.mts +7 -7
  45. package/dist/contracts/objects.d.mts +20 -4
  46. package/dist/contracts/opaque.mjs +19 -1
  47. package/dist/contracts/operations.d.mts +8 -1
  48. package/dist/contracts/operations.mjs +209 -0
  49. package/dist/contracts/queue.d.mts +3 -3
  50. package/dist/contracts/queue.mjs +5 -18
  51. package/dist/contracts/remote.d.mts +13 -4
  52. package/dist/contracts/remote.mjs +3 -3
  53. package/dist/contracts/repos.d.mts +11 -40
  54. package/dist/contracts/repos.mjs +11 -10
  55. package/dist/contracts/result.d.mts +28 -11
  56. package/dist/contracts/result.mjs +32 -2
  57. package/dist/contracts/rules.d.mts +706 -46
  58. package/dist/contracts/rules.mjs +81 -2
  59. package/dist/contracts/server.d.mts +5 -275
  60. package/dist/contracts/services.d.mts +0 -3
  61. package/dist/contracts/services.mjs +1 -3
  62. package/dist/contracts/signin.d.mts +2 -2
  63. package/dist/contracts/signin.mjs +4 -5
  64. package/dist/contracts/sync.d.mts +1 -4
  65. package/dist/contracts/tokens.d.mts +29 -17
  66. package/dist/contracts/tokens.mjs +14 -3
  67. package/dist/contracts/topics.d.mts +38 -11
  68. package/dist/contracts/topics.mjs +8 -2
  69. package/dist/core/access.d.mts +0 -2
  70. package/dist/core/access.mjs +15 -4
  71. package/dist/core/events/deliver.mjs +19 -1
  72. package/dist/core/forks.mjs +30 -11
  73. package/dist/core/hooks/groups.d.mts +0 -1
  74. package/dist/core/hooks/groups.mjs +8 -9
  75. package/dist/core/loose-tally.mjs +46 -0
  76. package/dist/core/objects/writing.mjs +1 -0
  77. package/dist/core/promise.mjs +1 -15
  78. package/dist/core/purge.mjs +14 -9
  79. package/dist/core/push.mjs +13 -6
  80. package/dist/core/ref-view.mjs +14 -6
  81. package/dist/core/repack.mjs +19 -14
  82. package/dist/core/repo-info.mjs +8 -6
  83. package/dist/core/repos.mjs +1 -0
  84. package/dist/core/rules/check.mjs +10 -10
  85. package/dist/core/rules/context.d.mts +3 -1
  86. package/dist/core/rules/context.mjs +16 -13
  87. package/dist/core/rules/fetch.mjs +17 -23
  88. package/dist/core/tokens.mjs +2 -1
  89. package/dist/effect.d.mts +2 -4
  90. package/dist/effect.mjs +2 -4
  91. package/dist/engine/commits.mjs +19 -47
  92. package/dist/engine/failures.d.mts +1 -2
  93. package/dist/engine/failures.mjs +1 -3
  94. package/dist/engine/merge-base-walk.mjs +57 -142
  95. package/dist/engine/merge-bases.mjs +5 -5
  96. package/dist/engine/merge.mjs +16 -14
  97. package/dist/extend.d.mts +1 -2
  98. package/dist/extend.mjs +1 -2
  99. package/dist/http/core-parts.mjs +1 -2
  100. package/dist/http/handler.mjs +11 -31
  101. package/dist/http/parts.d.mts +0 -1
  102. package/dist/index.d.mts +28 -21
  103. package/dist/index.mjs +5 -2
  104. package/dist/lfs/base.d.mts +6 -3
  105. package/dist/lfs/base.mjs +2 -1
  106. package/dist/lfs/layer.d.mts +4 -3
  107. package/dist/lfs/layer.mjs +23 -9
  108. package/dist/lfs/objects.mjs +90 -41
  109. package/dist/lfs/pointers.mjs +69 -18
  110. package/dist/lfs/purge.mjs +6 -2
  111. package/dist/lfs/rows.mjs +24 -7
  112. package/dist/lfs/service.d.mts +6 -3
  113. package/dist/lfs/service.mjs +8 -2
  114. package/dist/lfs/upkeep.mjs +44 -26
  115. package/dist/lfs/upload-most.mjs +41 -0
  116. package/dist/lfs/uploaded.mjs +59 -0
  117. package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
  118. package/dist/protocol/bytes/text.mjs +6 -1
  119. package/dist/protocol/objects/fsck.mjs +6 -3
  120. package/dist/queue/advance.mjs +38 -8
  121. package/dist/queue/calls.mjs +4 -14
  122. package/dist/queue/lanes.mjs +1 -1
  123. package/dist/queue/rows.mjs +8 -0
  124. package/dist/queue/schedule.mjs +1 -1
  125. package/dist/queue/search.mjs +3 -4
  126. package/dist/rest/client-namespace.d.mts +2 -0
  127. package/dist/rest/client.d.mts +32 -8
  128. package/dist/rest/client.mjs +308 -382
  129. package/dist/rest/commits.d.mts +240 -240
  130. package/dist/rest/files.d.mts +18 -18
  131. package/dist/rest/forks.d.mts +45 -57
  132. package/dist/rest/handlers.mjs +2 -1
  133. package/dist/rest/listen.d.mts +8 -6
  134. package/dist/rest/listen.mjs +31 -75
  135. package/dist/rest/me.d.mts +2 -2
  136. package/dist/rest/merges.d.mts +7 -7
  137. package/dist/rest/refs.d.mts +139 -139
  138. package/dist/rest/repos.d.mts +54 -66
  139. package/dist/rest/tokens.d.mts +12 -12
  140. package/dist/rest/topics.d.mts +110 -110
  141. package/dist/rest/trees.d.mts +66 -66
  142. package/dist/rest/wire.d.mts +1 -1
  143. package/dist/rest.d.mts +1 -7
  144. package/dist/rest.mjs +1 -5
  145. package/dist/server/git-layer.d.mts +10 -2
  146. package/dist/server/git-layer.mjs +29 -10
  147. package/dist/server/joined.d.mts +1 -1
  148. package/dist/server/server.d.mts +0 -1
  149. package/dist/server/server.mjs +26 -45
  150. package/dist/signin/context.d.mts +0 -1
  151. package/dist/signin/context.mjs +5 -9
  152. package/dist/storage/clean-up.mjs +3 -1
  153. package/dist/storage/fsck.mjs +12 -2
  154. package/dist/storage/graph-rebuild.mjs +262 -0
  155. package/dist/storage/index-build.mjs +100 -12
  156. package/dist/storage/lfs-pointers.d.mts +5 -5
  157. package/dist/storage/lfs-pointers.mjs +37 -11
  158. package/dist/storage/loose.mjs +4 -1
  159. package/dist/storage/memory-budget.mjs +1 -1
  160. package/dist/storage/merge-fence.mjs +81 -19
  161. package/dist/storage/merge-most.mjs +1 -0
  162. package/dist/storage/merge-row.mjs +16 -4
  163. package/dist/storage/merge-stream.mjs +9 -6
  164. package/dist/storage/object-rows.mjs +17 -1
  165. package/dist/storage/pack-receive.mjs +10 -6
  166. package/dist/storage/packs.mjs +58 -27
  167. package/dist/storage/prune.mjs +68 -40
  168. package/dist/storage/ready.d.mts +1 -1
  169. package/dist/storage/ready.mjs +12 -3
  170. package/dist/storage/receive-state.mjs +1 -1
  171. package/dist/storage/repack-contained.mjs +22 -14
  172. package/dist/storage/repack.d.mts +1 -1
  173. package/dist/storage/repack.mjs +3 -2
  174. package/dist/storage/unpack.mjs +7 -0
  175. package/dist/store/call-count.d.mts +23 -3
  176. package/dist/store/call-count.mjs +36 -13
  177. package/dist/store/records.mjs +10 -4
  178. package/dist/store/repo-record.mjs +29 -12
  179. package/dist/store/scopes.mjs +6 -1
  180. package/dist/sync/import.mjs +14 -2
  181. package/dist/sync/layer.d.mts +5 -1
  182. package/dist/sync/layer.mjs +7 -2
  183. package/dist/sync/step.mjs +15 -15
  184. package/dist/topics/advance.mjs +7 -6
  185. package/dist/topics/members.mjs +38 -9
  186. package/package.json +3 -3
  187. package/dist/engine/merge-base-walk.d.mts +0 -3
  188. package/dist/server/routes.d.mts +0 -32
  189. package/dist/server/routes.mjs +0 -69
  190. package/dist/sync/bridge.d.mts +0 -6
  191. package/dist/sync/bridge.mjs +0 -29
@@ -1,69 +0,0 @@
1
- import { Auth } from "../auth/auth.mjs";
2
- import { hostAuth, hostPolicy } from "../auth/bridge.mjs";
3
- import { Policy } from "../auth/policy.mjs";
4
- import { createRestHandler } from "../rest/handler.mjs";
5
- import { serverWith } from "./server.mjs";
6
- import * as Effect from "effect/Effect";
7
- import * as Option from "effect/Option";
8
- import { Bucket } from "@ref0/infra";
9
- import * as Context from "effect/Context";
10
- import * as Layer from "effect/Layer";
11
- import * as HttpServerResponse from "effect/http/HttpServerResponse";
12
- import * as HttpRouter from "effect/http/HttpRouter";
13
- import * as HttpServerRequest from "effect/http/HttpServerRequest";
14
- // src/server/routes.ts
15
- /** Every path under `base`, as the router matches it. */
16
- const pathUnder = (base) => {
17
- const trimmed = base.replace(/^\/+|\/+$/g, "");
18
- return trimmed === "" ? "*" : `/${trimmed}/*`;
19
- };
20
- /** Objects that need no bucket, as `needsBucket` says: `createGitServer` checks it again. */
21
- const looseOnly = (objects) => {
22
- if (objects.needsBucket) throw new TypeError("GitServer.routes' objects need a Bucket: provide one");
23
- return {
24
- ...objects,
25
- needsBucket: false
26
- };
27
- };
28
- /** The options of a server with a bucket, with `lfs` only when the host passed `lfs()`. */
29
- const withBucket = ({ lfs, ...rest }) => lfs === void 0 ? rest : {
30
- ...rest,
31
- lfs
32
- };
33
- /** The options of a server with no bucket, which `lfs()` needs: `createGitServer` checks it again. */
34
- const withoutLfs = ({ lfs, ...rest }) => {
35
- if (lfs !== void 0) throw new TypeError("GitServer.routes' lfs() needs a Bucket: provide one");
36
- return rest;
37
- };
38
- /**
39
- * Git's routes on a host's `HttpRouter`: the server `createGitServer` makes from `options`, over
40
- * the host's services, its `Records`, `JobQueue`, `CallLimits` and `Bucket`, deciding with its `Policy` and `Auth`.
41
- * Every URL under `basePath` answers as `createRestHandler`'s `fetch` does: REST's, then Git's
42
- * protocol, then a JSON `404`. The server closes with the Layer.
43
- */
44
- const routes = (options) => HttpRouter.use((router) => Effect.gen(function* () {
45
- const context = yield* Effect.context();
46
- const adapter = Layer.succeedContext(context);
47
- const bucket = Context.getOrUndefined(context, Bucket.Bucket);
48
- const policy = yield* Policy;
49
- const auth = Option.getOrUndefined(yield* Effect.serviceOption(Auth));
50
- const deciders = (reports) => ({
51
- policy: hostPolicy(policy, reports),
52
- auth: hostAuth(auth, reports)
53
- });
54
- const made = () => bucket === void 0 ? serverWith({
55
- ...withoutLfs(options),
56
- objects: looseOnly(options.objects),
57
- adapter
58
- }, deciders) : serverWith({
59
- ...withBucket(options),
60
- adapter: Layer.merge(adapter, Layer.succeed(Bucket.Bucket, bucket))
61
- }, deciders);
62
- const git = yield* Effect.acquireRelease(Effect.sync(made), (made) => Effect.promise(() => made.close()));
63
- const rest = createRestHandler(git);
64
- const serve = (request) => Effect.orDie(HttpServerRequest.toWeb(request)).pipe(Effect.flatMap((web) => Effect.promise(() => rest.fetch(web))), Effect.map((response) => HttpServerResponse.raw(response)));
65
- yield* router.add("*", pathUnder(options.basePath ?? ""), serve);
66
- }));
67
- /** The server's calls as Effects, and its routes as a Layer a host's router serves. */
68
- const GitServer = Object.assign(Context.Service("@ref0/git/GitServer"), { routes });
69
- export { GitServer };
@@ -1,6 +0,0 @@
1
- import { GitError, Result } from "../contracts/result.mjs";
2
- import { Sync } from "../contracts/sync.mjs";
3
- import { GitServer } from "../contracts/server.mjs";
4
- import * as Effect from "effect/Effect";
5
- /** The temporary Promise bridge for createGitServer's worlds; step 2c-1b deletes it. */
6
- export declare const syncOn: <A>(git: GitServer, effect: Effect.Effect<A, GitError, Sync>, signal?: AbortSignal) => Promise<Result<A>>;
@@ -1,29 +0,0 @@
1
- import { Sync } from "../contracts/sync.mjs";
2
- import { fail } from "../contracts/result.mjs";
3
- import { seamOf } from "../core/seam.mjs";
4
- import { exitOn, resultIn, uncounted } from "../store/crossing.mjs";
5
- import { openDoor, throughBridge } from "../store/promises.mjs";
6
- import * as Effect from "effect/Effect";
7
- import * as Option from "effect/Option";
8
- import * as Exit from "effect/Exit";
9
- import * as Result from "effect/Result";
10
- // src/sync/bridge.ts
11
- /** The temporary Promise bridge for createGitServer's worlds; step 2c-1b deletes it. */
12
- const syncOn = (git, effect, signal) => {
13
- const seam = seamOf(git);
14
- const call = Effect.flatMap(Effect.serviceOption(Sync), (sync) => Option.isSome(sync) ? Effect.provideService(effect, Sync, sync.value) : noSync());
15
- return resultIn(throughBridge(seam?.door ?? openDoor)(Effect.gen(function* () {
16
- yield* seam?.parts ?? Effect.void;
17
- const exit = yield* Effect.promise((stopped) => exitOn(git.runtime, Effect.result(call), uncounted("a host's sync call: no Git request"), stopped));
18
- if (Exit.isFailure(exit)) return yield* Effect.orDie(Effect.failCause(exit.cause));
19
- const result = exit.value;
20
- return yield* Result.isSuccess(result) ? Effect.succeed(result.success) : Effect.fail(result.failure);
21
- })), uncounted("a host's sync call: no Git request"), signal);
22
- };
23
- /** The feature-off answer, read before a world can call the feature. */
24
- const noSync = () => fail("NOT_FOUND", "This server doesn't offer import or mirroring", {
25
- hint: "This server doesn't offer import or mirroring",
26
- hostHint: "Compose Sync.layer({ providers }) with Git.layer to offer import or mirroring",
27
- context: { reason: "no-sync" }
28
- });
29
- export { syncOn };