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

nikelborm / fetch-github-folder / 12944157393

24 Jan 2025 05:59AM UTC coverage: 82.833% (-0.7%) from 83.502%
12944157393

push

github

nikelborm
quick save: Fri Jan 24 08:59:54 MSK 2025

73 of 83 branches covered (87.95%)

Branch coverage included in aggregate %.

506 of 616 relevant lines covered (82.14%)

4.18 hits per line

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

88.0
/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
  TaggedErrorClassWithNoStaticContext,
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 FailedToParseResponseFromRepoPathContentsMetaInfoAPIError(
×
29
        parseError,
×
30
        {
×
31
          response,
×
32
        },
×
33
      ),
×
34
  );
8✔
35
});
8✔
36

37
const GitSomethingFields = {
1✔
38
  size: SchemaNumber,
1✔
39
  name: SchemaString,
1✔
40
  path: SchemaString,
1✔
41
  sha: SchemaString,
1✔
42
};
1✔
43

44
const dirLiteral = Literal('dir');
1✔
45
const nonDirLiterals = Literal('file', 'submodule', 'symlink');
1✔
46

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

64
const decodeResponse = decodeUnknownEither(ResponseSchema, {
1✔
65
  exact: true,
1✔
66
});
1✔
67

68
// Extracting to a separate type is required by JSR, so that consumers of the
69
// library will have much faster type inference
70
export type FailedToParseResponseFromRepoPathContentsMetaInfoAPIErrorClass =
71
  TaggedErrorClassWithNoStaticContext<
72
    'FailedToParseResponseFromRepoPathContentsMetaInfoAPI',
73
    typeof ParseError,
74
    { response: unknown }
75
  >;
76

77
export type FailedToParseResponseFromRepoPathContentsMetaInfoAPIError =
78
  InstanceType<FailedToParseResponseFromRepoPathContentsMetaInfoAPIErrorClass>;
79

80
export const FailedToParseResponseFromRepoPathContentsMetaInfoAPIError: FailedToParseResponseFromRepoPathContentsMetaInfoAPIErrorClass =
1✔
81
  TaggedErrorVerifyingCause<{ response: unknown }>()(
1✔
82
    'FailedToParseResponseFromRepoPathContentsMetaInfoAPI',
1✔
83
    `Failed to parse response from repo path contents meta info API`,
1✔
84
    ParseError,
1✔
85
  );
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