• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nikelborm / fetch-github-folder / 12884498323

21 Jan 2025 10:01AM UTC coverage: 84.12% (+0.5%) from 83.58%
12884498323

push

github

nikelborm
quick save: Tue Jan 21 13:01:36 MSK 2025

72 of 79 branches covered (91.14%)

Branch coverage included in aggregate %.

516 of 620 relevant lines covered (83.23%)

4.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.75
/src/getPathContents/ParsedMetaInfoAboutPathContentsFromGitHubAPI.ts
1
import { gen } from 'effect/Effect';
1✔
2
import { mapLeft } from 'effect/Either';
3
import { ParseError } from 'effect/ParseResult';
4
import {
5
  Array as ArraySchema,
6
  decodeUnknownEither,
7
  Literal,
8
  Number as SchemaNumber,
9
  String as SchemaString,
10
  Struct,
11
  Union,
12
} from 'effect/Schema';
13
import {
14
  ReturnTypeNoStatic,
15
  TaggedErrorVerifyingCause,
16
} from '../TaggedErrorVerifyingCause.js';
17
import { RepoPathContentsFromGitHubAPI } from './RepoPathContentsFromGitHubAPI.js';
18

19
export const UnparsedMetaInfoAboutPathContentsFromGitHubAPI =
1✔
20
  RepoPathContentsFromGitHubAPI('object');
1✔
21

22
export const ParsedMetaInfoAboutPathContentsFromGitHubAPI = gen(function* () {
1✔
23
  const response = yield* UnparsedMetaInfoAboutPathContentsFromGitHubAPI;
8✔
24

25
  return yield* mapLeft(
8✔
26
    decodeResponse(response.data),
8✔
27
    parseError =>
8✔
28
      new FailedToParseResponseFromRepoPathContentsMetaInfoAPI(parseError, {
×
29
        response,
×
30
      }),
×
31
  );
8✔
32
});
8✔
33

34
const GitSomethingFields = {
1✔
35
  size: SchemaNumber,
1✔
36
  name: SchemaString,
1✔
37
  path: SchemaString,
1✔
38
  sha: SchemaString,
1✔
39
};
1✔
40

41
const dirLiteral = Literal('dir');
1✔
42
const nonDirLiterals = Literal('file', 'submodule', 'symlink');
1✔
43

44
export const ResponseSchema = Union(
1✔
45
  Struct({
1✔
46
    type: Literal('dir'),
1✔
47
    entries: Struct({
1✔
48
      type: Union(dirLiteral, nonDirLiterals),
1✔
49
      ...GitSomethingFields,
1✔
50
    }).pipe(ArraySchema),
1✔
51
    ...GitSomethingFields,
1✔
52
  }),
1✔
53
  Struct({
1✔
54
    type: Literal('file'),
1✔
55
    encoding: Literal('base64', 'none'),
1✔
56
    content: SchemaString,
1✔
57
    ...GitSomethingFields,
1✔
58
  }),
1✔
59
);
1✔
60

61
const decodeResponse = decodeUnknownEither(ResponseSchema, {
1✔
62
  exact: true,
1✔
63
});
1✔
64

65
// Extracted to a const to please JSR
66
const _Err: ReturnTypeNoStatic<
1✔
67
  'FailedToParseResponseFromRepoPathContentsMetaInfoAPI',
68
  typeof ParseError,
69
  { response: unknown }
70
> = TaggedErrorVerifyingCause<{ response: unknown }>()(
1✔
71
  'FailedToParseResponseFromRepoPathContentsMetaInfoAPI',
1✔
72
  `Failed to parse response from repo path contents meta info API`,
1✔
73
  ParseError,
1✔
74
);
1✔
75

76
export class FailedToParseResponseFromRepoPathContentsMetaInfoAPI extends _Err {}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc