@adonisjs/content 1.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.md +9 -0
- package/README.md +290 -0
- package/build/chunk-LB6JFRVG.js +7 -0
- package/build/chunk-ZX3KSI7U.js +130 -0
- package/build/configure.d.ts +5 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +16 -0
- package/build/providers/content_provider.d.ts +46 -0
- package/build/providers/content_provider.js +45 -0
- package/build/src/collection.d.ts +112 -0
- package/build/src/debug.d.ts +11 -0
- package/build/src/loaders/gh_contributors.d.ts +49 -0
- package/build/src/loaders/gh_releases.d.ts +52 -0
- package/build/src/loaders/gh_sponsors.d.ts +56 -0
- package/build/src/loaders/json.d.ts +43 -0
- package/build/src/loaders/main.d.ts +91 -0
- package/build/src/loaders/main.js +648 -0
- package/build/src/types.d.ts +280 -0
- package/build/src/utils.d.ts +82 -0
- package/package.json +146 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type Infer, type SchemaTypes } from '@vinejs/vine/types';
|
|
2
|
+
import type { GithubContributorsOptions, LoaderContract } from '../types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* A loader that fetches GitHub contributors from all repositories in an organization.
|
|
5
|
+
* Supports caching and automatic refresh based on a schedule.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const loader = new GithubContributorsLoader({
|
|
10
|
+
* org: 'adonisjs',
|
|
11
|
+
* ghToken: process.env.GITHUB_TOKEN,
|
|
12
|
+
* outputPath: './cache/contributors.json',
|
|
13
|
+
* refresh: 'weekly'
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class GithubContributorsLoader<Schema extends SchemaTypes> implements LoaderContract<Schema> {
|
|
18
|
+
#private;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new GitHub contributors loader instance.
|
|
21
|
+
*
|
|
22
|
+
* @param options - Configuration options for loading GitHub contributors
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const loader = new GithubContributorsLoader({
|
|
27
|
+
* org: 'adonisjs',
|
|
28
|
+
* ghToken: process.env.GITHUB_TOKEN,
|
|
29
|
+
* outputPath: './cache/contributors.json',
|
|
30
|
+
* refresh: 'weekly'
|
|
31
|
+
* })
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
constructor(options: GithubContributorsOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Loads and validates GitHub contributors data.
|
|
37
|
+
* Uses cached data if available and not expired, otherwise fetches fresh data
|
|
38
|
+
* from GitHub API and updates the cache.
|
|
39
|
+
*
|
|
40
|
+
* @param schema - VineJS schema to validate the contributors data against
|
|
41
|
+
* @param metadata - Optional metadata to pass to the validator
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const contributors = await loader.load(contributorsSchema)
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
load(schema: Schema, metadata?: any): Promise<Infer<Schema>>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type Infer, type SchemaTypes } from '@vinejs/vine/types';
|
|
2
|
+
import type { GithubReleasesOptions, LoaderContract } from '../types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* A loader that fetches GitHub releases from an organization's repositories.
|
|
5
|
+
* Supports caching, automatic refresh based on a schedule, and merging with existing data.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const loader = new GithubReleasesLoader({
|
|
10
|
+
* org: 'adonisjs',
|
|
11
|
+
* ghToken: process.env.GITHUB_TOKEN,
|
|
12
|
+
* outputPath: './cache/releases.json',
|
|
13
|
+
* refresh: 'daily',
|
|
14
|
+
* filters: {
|
|
15
|
+
* nameDoesntInclude: ['alpha', 'beta']
|
|
16
|
+
* }
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class GithubReleasesLoader<Schema extends SchemaTypes> implements LoaderContract<Schema> {
|
|
21
|
+
#private;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new GitHub release loader instance.
|
|
24
|
+
*
|
|
25
|
+
* @param options - Configuration options for loading GitHub releases
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const loader = new GithubReleasesLoader({
|
|
30
|
+
* org: 'adonisjs',
|
|
31
|
+
* ghToken: process.env.GITHUB_TOKEN,
|
|
32
|
+
* outputPath: './cache/releases.json',
|
|
33
|
+
* refresh: 'weekly'
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
constructor(options: GithubReleasesOptions);
|
|
38
|
+
/**
|
|
39
|
+
* Loads and validates GitHub releases data.
|
|
40
|
+
* Uses cached data if available and not expired, otherwise fetches fresh data
|
|
41
|
+
* from GitHub API and merges with existing releases.
|
|
42
|
+
*
|
|
43
|
+
* @param schema - VineJS schema to validate the releases data against
|
|
44
|
+
* @param metadata - Optional metadata to pass to the validator
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const releases = await loader.load(releasesSchema)
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
load(schema: Schema, metadata?: any): Promise<Infer<Schema>>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type Infer, type SchemaTypes } from '@vinejs/vine/types';
|
|
2
|
+
import type { GithubSponsorsOptions, LoaderContract } from '../types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* A loader that fetches GitHub sponsors for a user or organization.
|
|
5
|
+
* Supports caching and automatic refresh based on a schedule.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const loader = new GithubSponsorsLoader({
|
|
10
|
+
* login: 'adonisjs',
|
|
11
|
+
* isOrg: true,
|
|
12
|
+
* ghToken: process.env.GITHUB_TOKEN,
|
|
13
|
+
* outputPath: './cache/sponsors.json',
|
|
14
|
+
* refresh: 'daily'
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class GithubSponsorsLoader<Schema extends SchemaTypes> implements LoaderContract<Schema> {
|
|
19
|
+
#private;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new GitHub sponsors loader instance.
|
|
22
|
+
*
|
|
23
|
+
* @param options - Configuration options for loading GitHub sponsors
|
|
24
|
+
* @param options.login - GitHub username or organization name
|
|
25
|
+
* @param options.isOrg - Whether the login is an organization (true) or user (false)
|
|
26
|
+
* @param options.ghToken - GitHub personal access token for authentication
|
|
27
|
+
* @param options.outputPath - Path where cached sponsors will be stored
|
|
28
|
+
* @param options.refresh - Refresh schedule: 'daily', 'weekly', or 'monthly'
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const loader = new GithubSponsorsLoader({
|
|
33
|
+
* login: 'thetutlage',
|
|
34
|
+
* isOrg: false,
|
|
35
|
+
* ghToken: process.env.GITHUB_TOKEN,
|
|
36
|
+
* outputPath: './cache/sponsors.json',
|
|
37
|
+
* refresh: 'weekly'
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
constructor(options: GithubSponsorsOptions);
|
|
42
|
+
/**
|
|
43
|
+
* Loads and validates GitHub sponsors data.
|
|
44
|
+
* Uses cached data if available and not expired, otherwise fetches fresh data
|
|
45
|
+
* from GitHub API and updates the cache.
|
|
46
|
+
*
|
|
47
|
+
* @param schema - VineJS schema to validate the sponsors data against
|
|
48
|
+
* @param metadata - Optional metadata to pass to the validator
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const sponsors = await loader.load(sponsorsSchema)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
load(schema: Schema, metadata?: any): Promise<Infer<Schema>>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type SchemaTypes } from '@vinejs/vine/types';
|
|
2
|
+
import type { LoaderContract } from '../types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* A loader that reads and validates JSON data from a file.
|
|
5
|
+
* Implements the LoaderContract to provide JSON file loading with schema validation.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const loader = new JsonLoader('./data/config.json')
|
|
10
|
+
* const collection = new Collection({
|
|
11
|
+
* schema: configSchema,
|
|
12
|
+
* loader,
|
|
13
|
+
* cache: true
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class JsonLoader<Schema extends SchemaTypes> implements LoaderContract<Schema> {
|
|
18
|
+
#private;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new JSON loader instance.
|
|
21
|
+
*
|
|
22
|
+
* @param source - Absolute or relative path to the JSON file
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const loader = new JsonLoader('./data/menu.json')
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
constructor(source: string);
|
|
30
|
+
/**
|
|
31
|
+
* Loads and validates JSON data from the configured file.
|
|
32
|
+
* The directory of the source file is provided as metadata during validation.
|
|
33
|
+
*
|
|
34
|
+
* @param schema - VineJS schema to validate the loaded JSON data against
|
|
35
|
+
* @param metadata - Optional metadata to pass to the validator
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const data = await loader.load(menuSchema)
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
load(schema: Schema, metadata?: any): Promise<import("@vinejs/vine/types").Infer<Schema>>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type GithubSponsorsOptions, type GithubReleasesOptions, type GithubContributorsOptions } from '../types.ts';
|
|
2
|
+
import { GithubSponsorsLoader } from './gh_sponsors.ts';
|
|
3
|
+
import { GithubReleasesLoader } from './gh_releases.ts';
|
|
4
|
+
import { GithubContributorsLoader } from './gh_contributors.ts';
|
|
5
|
+
import { JsonLoader } from './json.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Factory functions for creating content loaders.
|
|
8
|
+
* Provides convenient access to GitHub-based data loaders.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const sponsorsLoader = loaders.ghSponsors({
|
|
13
|
+
* login: 'adonisjs',
|
|
14
|
+
* isOrg: true,
|
|
15
|
+
* ghToken: process.env.GITHUB_TOKEN,
|
|
16
|
+
* outputPath: './cache/sponsors.json',
|
|
17
|
+
* refresh: 'daily'
|
|
18
|
+
* })
|
|
19
|
+
*
|
|
20
|
+
* const collection = new Collection({
|
|
21
|
+
* schema: sponsorsSchema,
|
|
22
|
+
* loader: sponsorsLoader,
|
|
23
|
+
* cache: true
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const loaders: {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a GitHub sponsors loader instance.
|
|
30
|
+
*
|
|
31
|
+
* @param options - Configuration options for the sponsors loader
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const loader = loaders.ghSponsors({
|
|
36
|
+
* login: 'adonisjs',
|
|
37
|
+
* isOrg: true,
|
|
38
|
+
* ghToken: process.env.GITHUB_TOKEN,
|
|
39
|
+
* outputPath: './cache/sponsors.json',
|
|
40
|
+
* refresh: 'daily'
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
ghSponsors(options: GithubSponsorsOptions): GithubSponsorsLoader<import("@vinejs/vine/types").SchemaTypes>;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a GitHub contributors loader instance.
|
|
47
|
+
*
|
|
48
|
+
* @param options - Configuration options for the contributors loader
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const loader = loaders.ghContributors({
|
|
53
|
+
* org: 'adonisjs',
|
|
54
|
+
* ghToken: process.env.GITHUB_TOKEN,
|
|
55
|
+
* outputPath: './cache/contributors.json',
|
|
56
|
+
* refresh: 'weekly'
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
ghContributors(options: GithubContributorsOptions): GithubContributorsLoader<import("@vinejs/vine/types").SchemaTypes>;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a GitHub releases loader instance.
|
|
63
|
+
*
|
|
64
|
+
* @param options - Configuration options for the releases loader
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* const loader = loaders.ghReleases({
|
|
69
|
+
* org: 'adonisjs',
|
|
70
|
+
* ghToken: process.env.GITHUB_TOKEN,
|
|
71
|
+
* outputPath: './cache/releases.json',
|
|
72
|
+
* refresh: 'daily',
|
|
73
|
+
* filters: {
|
|
74
|
+
* nameDoesntInclude: ['alpha', 'beta']
|
|
75
|
+
* }
|
|
76
|
+
* })
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
ghReleases(options: GithubReleasesOptions): GithubReleasesLoader<import("@vinejs/vine/types").SchemaTypes>;
|
|
80
|
+
/**
|
|
81
|
+
* Creates a JSON file loader instance.
|
|
82
|
+
*
|
|
83
|
+
* @param source - Path to the JSON file to load
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const loader = loaders.jsonLoader('./data/menu.json')
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
jsonLoader(source: string): JsonLoader<import("@vinejs/vine/types").SchemaTypes>;
|
|
91
|
+
};
|