npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gitgov/core-gitlab

v1.0.0

Published

GitLab REST API provider for the GitGovernance SDK

Readme

@gitgov/core-gitlab

License: MPL-2.0 TypeScript

GitLab REST API provider for the GitGovernance SDK. Implements the same 5 core interfaces as @gitgov/core/github, but using GitLab REST API via @gitbeaker/rest.

Install

npm install @gitgov/core-gitlab
# or
pnpm add @gitgov/core-gitlab

Quick Start

GitLab API Backend

For SaaS, Forge apps, or GitLab CI — no filesystem needed:

import { Gitlab } from '@gitbeaker/rest';
import {
  GitLabRecordStore,
  GitLabConfigStore,
  GitLabGitModule,
  GitLabFileLister,
} from '@gitgov/core-gitlab';
import type { TaskRecord } from '@gitgov/core';

const api = new Gitlab({ token: process.env.GITLAB_TOKEN });
const projectId = 12345; // or 'my-org/my-repo' (URL-encoded path)

const taskStore = new GitLabRecordStore<TaskRecord>({
  projectId, api, basePath: '.gitgov/tasks',
});

// Read — returns parsed JSON, caches blob_id for optimistic concurrency
const task = await taskStore.get('task-001');

// Write — returns { commitSha } from the created commit
const result = await taskStore.put('task-002', newTask);

// Atomic batch — single commit for N records (NO GitModule dependency needed!)
await taskStore.putMany([
  { id: 'task-003', value: task3 },
  { id: 'task-004', value: task4 },
]);
// → 1 API call via POST /repository/commits with actions[]

Full GitGovernance Setup with GitLab

Drop-in replacement for the GitHub backend — same adapters, same interfaces:

import { Gitlab } from '@gitbeaker/rest';
import { Adapters, EventBus } from '@gitgov/core';
import {
  GitLabRecordStore,
  GitLabConfigStore,
  GitLabFileLister,
  GitLabGitModule,
} from '@gitgov/core-gitlab';
import type { TaskRecord, CycleRecord, ActorRecord, AgentRecord } from '@gitgov/core';

const api = new Gitlab({ token: process.env.GITLAB_TOKEN });
const projectId = 12345;
const opts = { projectId, api, ref: 'gitgov-state' };

// Infrastructure — same interfaces as GitHub, different backend
const eventBus = new EventBus.EventBus();
const taskStore = new GitLabRecordStore<TaskRecord>({ ...opts, basePath: '.gitgov/tasks' });
const cycleStore = new GitLabRecordStore<CycleRecord>({ ...opts, basePath: '.gitgov/cycles' });
const actorStore = new GitLabRecordStore<ActorRecord>({ ...opts, basePath: '.gitgov/actors' });
const agentStore = new GitLabRecordStore<AgentRecord>({ ...opts, basePath: '.gitgov/agents' });

// Adapters compose modules — identical to GitHub setup
const identity = new Adapters.IdentityAdapter({ actorStore, agentStore });
const workflow = Adapters.WorkflowAdapter.createDefault();
const backlog = new Adapters.BacklogAdapter({
  taskStore, cycleStore, identity, eventBus, workflowAdapter: workflow,
});

// Create a task — works exactly like GitHub
const task = await backlog.createTask(
  { title: 'Implement auth', priority: 'high' },
  'human:project-lead',
);

Comparison: GitHub vs GitLab Setup

// GitHub
import { Octokit } from '@octokit/rest';
import { GitHubRecordStore } from '@gitgov/core/github';
const octokit = new Octokit({ auth: token });
const store = new GitHubRecordStore({ owner, repo, basePath }, octokit);

// GitLab — same interface, different constructor
import { Gitlab } from '@gitbeaker/rest';
import { GitLabRecordStore } from '@gitgov/core-gitlab';
const api = new Gitlab({ token });
const store = new GitLabRecordStore({ projectId, api, basePath });

// From here on, the code is IDENTICAL:
await store.put('task-001', record);
const task = await store.get('task-001');
const ids = await store.list();

Modules

| Module | Interface | Description | |--------|-----------|-------------| | GitLabFileLister | FileLister | Repository Tree + Files API | | GitLabConfigStore | ConfigStore | Files API for config.json | | GitLabRecordStore | RecordStore | Files API CRUD + Commits API batch | | GitLabGitModule | IGitModule | Commits, Branches, Compare API | | GitLabSyncStateModule | ISyncStateModule | Push/pull state branch | | GitLabWebhookHandler | — | Push event processing |

Key Advantage: 1-Call Atomic Commits

GitLab's Commits API allows multi-file atomic commits in 1 API call:

const git = new GitLabGitModule({ projectId: 12345, api });

await git.add(['file1.json', 'file2.json'], {
  contentMap: { 'file1.json': '...', 'file2.json': '...' }
});
await git.commit('batch update');
// → 1 POST /repository/commits with actions[]

Compare with GitHub which requires 6 API calls (blob → tree → commit → ref).

Development

# Type check
pnpm typecheck

# Tests (unit — mocked Gitbeaker)
pnpm test

# Tests with coverage
pnpm test:coverage

Architecture

src/
├── index.ts              # Barrel export
├── gitlab.ts             # GitLabApiError, mapGitbeakerError, isGitbeakerRequestError
├── file_lister/          # GitLabFileLister
├── config_store/         # GitLabConfigStore
├── record_store/         # GitLabRecordStore
├── git/                  # GitLabGitModule
├── sync_state/           # GitLabSyncStateModule
└── webhook/              # GitLabWebhookHandler

Related

License

Mozilla Public License 2.0 (MPL-2.0)