Skip to content

collectium - API documentation

Classes

Checker

Checker class to validate schemas against specified content files. This class is designed to work with Zod schemas and supports dynamic content validation from either a configuration object or a configuration file path.

Examples

ts
// Example usage with a configuration file path:
import { Checker } from '@collectium/check';

const checker = new Checker("/path/to/config.js");
checker.run("config-key", { cwd: "/path/to/dir" });
ts
// Example usage with an options object:
import { Checker } from '@collectium/check';

const opts = {
  github: [
    {
      content: {
        "config-key": {
          input: ["configs/**/*.json"],
          schema: (z) => z.object({
            name: z.string(),
            version: z.string(),
          }),
        },
      },
    },
  ],
};

const checker = new Checker(opts);
checker.run("config-key", { cwd: "/path/to/dir" });

Constructors

new Checker()
ts
new Checker(opts: CheckOpts): Checker
Parameters
ParameterType
optsCheckOpts
Returns

Checker

Methods

run()
ts
run(id: string, opts?: {
  cwd: string;
}): Promise<undefined>
Parameters
ParameterType
idstring
opts?object
opts.cwd?string
Returns

Promise<undefined>


Collectium

Create a Collectium instance

See

https://collectium.pigeonposse.com/guide/core

Example

ts
import { argv } from 'node:process';

// Retrieve the GitHub token from the command line arguments
const token = argv[2];

// Initialize a new Collectium instance
const collectium = new Collectium({
  github: {
    test: {
      user: 'pigeonposse',  // GitHub username or organization
      branch: 'main',       // Target branch
      userType: 'org',      // User type: 'org' for organization, 'user' for individual
      token,                // Authentication token for GitHub
    },
  },
  config: {
    skipError: true, // Skip errors during execution
    skipWarn: true,  // Skip warnings during execution
  },
});

// Fetch data using the Collectium instance
const data = await collectium.get();

// Log the retrieved data to the console with full depth
console.dir(data, { depth: Infinity });

Extends

  • CollectiumSuperMininal

Constructors

new Collectium()
ts
new Collectium(opts: CollectiumOpts): Collectium
Parameters
ParameterType
optsCollectiumOpts
Returns

Collectium

Overrides

CollectiumSuperMininal.constructor

Methods

get()
ts
get(): Promise<CollectiumRes>
Returns

Promise<CollectiumRes>

Properties

PropertyTypeDescriptionInherited from
configCollectiumConfigConfugrationCollectiumSuperMininal.config
customCustom--
githubGitHub--
optsCollectiumOpts--
schema{ res: ZodObject<{ custom: ZodOptional<ZodObject<{}, "strip", ZodTypeAny, {}, {}>>; github: ZodOptional<ZodObject<{ data: ZodRecord<ZodString, ZodObject<{ repo: ZodOptional<ZodArray<..., ...>>; user: ZodOptional<ZodObject<..., ..., ..., ..., ...>>; }, "strip", ZodTypeAny, { repo: ...[]; user: { avatar: ...; blog: ...; description: ...; email: ...; followers: ...; funding: ...; id: ...; name: ...; publicRepos: ...; social: ...; teams: ...; }; }, { repo: ...[]; user: { avatar: ...; blog: ...; description: ...; email: ...; followers: ...; funding: ...; id: ...; name: ...; publicRepos: ...; social: ...; teams: ...; }; }>>; rate: ZodUnion<[ZodObject<{ limit: ZodNumber; remaining: ZodNumber; reset: ZodNumber; used: ZodNumber; }, "strip", ZodTypeAny, { limit: number; remaining: number; reset: number; used: number; }, { limit: number; remaining: number; reset: number; used: number; }>, ZodLiteral<false>]>; }, "strip", ZodTypeAny, { data: Record<string, { repo: { content: ...; createdAt: ...; defaultBranch: ...; desc: ...; forks: ...; homepage: ...; id: ...; isArchived: ...; isDisabled: ...; isFork: ...; isPinned: ...; isPrivate: ...; issues: ...; isTemplate: ...; language: ...; license: ...; releases: ...; size: ...; stargazers: ...; tags: ...; updatedAt: ...; url: ...; watchers: ...; }[]; user: { avatar: string; blog: ... | ...; description: ... | ...; email: ... | ...; followers: number; funding: ... | ...; id: string; name: ... | ...; publicRepos: number; social: ... | ...; teams: ... | ...; }; }>; rate: false | { limit: number; remaining: number; reset: number; used: number; }; }, { data: Record<string, { repo: { content: ...; createdAt: ...; defaultBranch: ...; desc: ...; forks: ...; homepage: ...; id: ...; isArchived: ...; isDisabled: ...; isFork: ...; isPinned: ...; isPrivate: ...; issues: ...; isTemplate: ...; language: ...; license: ...; releases: ...; size: ...; stargazers: ...; tags: ...; updatedAt: ...; url: ...; watchers: ...; }[]; user: { avatar: string; blog: ... | ...; description: ... | ...; email: ... | ...; followers: number; funding: ... | ...; id: string; name: ... | ...; publicRepos: number; social: ... | ...; teams: ... | ...; }; }>; rate: false | { limit: number; remaining: number; reset: number; used: number; }; }>>; timeout: ZodNumber; }, "strip", ZodTypeAny, { custom: {}; github: { data: Record<string, { repo: { content: ... | ... | ...; createdAt: ... | ...; defaultBranch: ... | ...; desc: ... | ...; forks: number; homepage: ... | ...; id: string; isArchived: boolean; isDisabled: boolean; isFork: boolean; isPinned: boolean; isPrivate: boolean; issues: number; isTemplate: boolean; language: ... | ...; license: ... | ...; releases: ... | ...; size: ... | ...; stargazers: number; tags: ... | ...; updatedAt: ... | ...; url: string; watchers: number; }[]; user: { avatar: string; blog: string; description: string; email: string; followers: number; funding: ...[]; id: string; name: string; publicRepos: number; social: ...[]; teams: ...[]; }; }>; rate: false | { limit: number; remaining: number; reset: number; used: number; }; }; timeout: number; }, { custom: {}; github: { data: Record<string, { repo: { content: ... | ... | ...; createdAt: ... | ...; defaultBranch: ... | ...; desc: ... | ...; forks: number; homepage: ... | ...; id: string; isArchived: boolean; isDisabled: boolean; isFork: boolean; isPinned: boolean; isPrivate: boolean; issues: number; isTemplate: boolean; language: ... | ...; license: ... | ...; releases: ... | ...; size: ... | ...; stargazers: number; tags: ... | ...; updatedAt: ... | ...; url: string; watchers: number; }[]; user: { avatar: string; blog: string; description: string; email: string; followers: number; funding: ...[]; id: string; name: string; publicRepos: number; social: ...[]; teams: ...[]; }; }>; rate: false | { limit: number; remaining: number; reset: number; used: number; }; }; timeout: number; }>; }--
schema.resZodObject<{ custom: ZodOptional<ZodObject<{}, "strip", ZodTypeAny, {}, {}>>; github: ZodOptional<ZodObject<{ data: ZodRecord<ZodString, ZodObject<{ repo: ZodOptional<ZodArray<..., ...>>; user: ZodOptional<ZodObject<..., ..., ..., ..., ...>>; }, "strip", ZodTypeAny, { repo: ...[]; user: { avatar: ...; blog: ...; description: ...; email: ...; followers: ...; funding: ...; id: ...; name: ...; publicRepos: ...; social: ...; teams: ...; }; }, { repo: ...[]; user: { avatar: ...; blog: ...; description: ...; email: ...; followers: ...; funding: ...; id: ...; name: ...; publicRepos: ...; social: ...; teams: ...; }; }>>; rate: ZodUnion<[ZodObject<{ limit: ZodNumber; remaining: ZodNumber; reset: ZodNumber; used: ZodNumber; }, "strip", ZodTypeAny, { limit: number; remaining: number; reset: number; used: number; }, { limit: number; remaining: number; reset: number; used: number; }>, ZodLiteral<false>]>; }, "strip", ZodTypeAny, { data: Record<string, { repo: { content: ...; createdAt: ...; defaultBranch: ...; desc: ...; forks: ...; homepage: ...; id: ...; isArchived: ...; isDisabled: ...; isFork: ...; isPinned: ...; isPrivate: ...; issues: ...; isTemplate: ...; language: ...; license: ...; releases: ...; size: ...; stargazers: ...; tags: ...; updatedAt: ...; url: ...; watchers: ...; }[]; user: { avatar: string; blog: ... | ...; description: ... | ...; email: ... | ...; followers: number; funding: ... | ...; id: string; name: ... | ...; publicRepos: number; social: ... | ...; teams: ... | ...; }; }>; rate: false | { limit: number; remaining: number; reset: number; used: number; }; }, { data: Record<string, { repo: { content: ...; createdAt: ...; defaultBranch: ...; desc: ...; forks: ...; homepage: ...; id: ...; isArchived: ...; isDisabled: ...; isFork: ...; isPinned: ...; isPrivate: ...; issues: ...; isTemplate: ...; language: ...; license: ...; releases: ...; size: ...; stargazers: ...; tags: ...; updatedAt: ...; url: ...; watchers: ...; }[]; user: { avatar: string; blog: ... | ...; description: ... | ...; email: ... | ...; followers: number; funding: ... | ...; id: string; name: ... | ...; publicRepos: number; social: ... | ...; teams: ... | ...; }; }>; rate: false | { limit: number; remaining: number; reset: number; used: number; }; }>>; timeout: ZodNumber; }, "strip", ZodTypeAny, { custom: {}; github: { data: Record<string, { repo: { content: ... | ... | ...; createdAt: ... | ...; defaultBranch: ... | ...; desc: ... | ...; forks: number; homepage: ... | ...; id: string; isArchived: boolean; isDisabled: boolean; isFork: boolean; isPinned: boolean; isPrivate: boolean; issues: number; isTemplate: boolean; language: ... | ...; license: ... | ...; releases: ... | ...; size: ... | ...; stargazers: number; tags: ... | ...; updatedAt: ... | ...; url: string; watchers: number; }[]; user: { avatar: string; blog: string; description: string; email: string; followers: number; funding: ...[]; id: string; name: string; publicRepos: number; social: ...[]; teams: ...[]; }; }>; rate: false | { limit: number; remaining: number; reset: number; used: number; }; }; timeout: number; }, { custom: {}; github: { data: Record<string, { repo: { content: ... | ... | ...; createdAt: ... | ...; defaultBranch: ... | ...; desc: ... | ...; forks: number; homepage: ... | ...; id: string; isArchived: boolean; isDisabled: boolean; isFork: boolean; isPinned: boolean; isPrivate: boolean; issues: number; isTemplate: boolean; language: ... | ...; license: ... | ...; releases: ... | ...; size: ... | ...; stargazers: number; tags: ... | ...; updatedAt: ... | ...; url: string; watchers: number; }[]; user: { avatar: string; blog: string; description: string; email: string; followers: number; funding: ...[]; id: string; name: string; publicRepos: number; social: ...[]; teams: ...[]; }; }>; rate: false | { limit: number; remaining: number; reset: number; used: number; }; }; timeout: number; }>--

Functions

defineConfig()

ts
function defineConfig(v: CollectiumOpts): CollectiumOpts

Parameters

ParameterType
vCollectiumOpts

Returns

CollectiumOpts

Type Aliases

CheckOpts

ts
type CheckOpts: CollectiumOpts | CollectiumOptsPath;

CollectiumOpts

ts
type CollectiumOpts: {
  config: CollectiumConfig;
  custom: CustomOpts;
  github: GitHubOpts;
};

Type declaration

NameTypeDescription
config?CollectiumConfigGlobal Configuration
custom?CustomOptsCustom options
github?GitHubOptsGithub options

CollectiumRes

ts
type CollectiumRes: {
  custom: Awaited<ReturnType<Custom["get"]>>;
  github: Awaited<ReturnType<GitHub["get"]>>;
  timeout: number;
};

Type declaration

NameTypeDescription
custom?Awaited<ReturnType<Custom["get"]>>-
github?Awaited<ReturnType<GitHub["get"]>>-
timeoutnumberExecution time in miliseconds