Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

repository-provider

Package Overview
Dependencies
Maintainers
1
Versions
662
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

repository-provider - npm Package Compare versions

Comparing version 2.24.1 to 3.0.0

src/repository-group.js

83

dist/repository-provider.js

@@ -73,6 +73,6 @@ 'use strict';

class Repository {
constructor(provider, name, options) {
constructor(owner, name, options) {
Object.defineProperties(this, {
name: { value: name },
provider: { value: provider },
owner: { value: owner },
_branches: { value: new Map() },

@@ -82,2 +82,5 @@ _pullRequests: { value: new Map() }

}
get provider() {
return this.owner.provider;
}
async initialize() {}

@@ -130,3 +133,3 @@ async content(...args) {

async delete() {
return this.provider.deleteRepository(this.name);
return this.owner.deleteRepository(this.name);
}

@@ -149,3 +152,3 @@ async createPullRequest() {

get type() {
return this.provider.type;
return this.owner.type;
}

@@ -160,2 +163,13 @@ get rateLimitReached() {

class Content {
constructor(path, content = undefined, type = 'blob', mode = '100644') {
Object.defineProperties(this, {
path: { value: path },
content: { value: content, writeable: true },
type: { value: type },
mode: { value: mode }
});
}
}
class Owner {

@@ -170,2 +184,8 @@ constructor() {

}
get branchClass() {
return Branch;
}
get contentClass() {
return Content;
}
async deleteRepository(name) {

@@ -251,3 +271,3 @@ await this._initialize();

class Project extends Owner {
class RepositoryGroup extends Owner {
constructor(provider, name) {

@@ -262,13 +282,2 @@ super();

class Content {
constructor(path, content = undefined, type = 'blob', mode = '100644') {
Object.defineProperties(this, {
path: { value: path },
content: { value: content, writeable: true },
type: { value: type },
mode: { value: mode }
});
}
}
class Provider extends Owner {

@@ -290,6 +299,6 @@ static get defaultOptions() {

},
projects: { value: new Map() }
repositoryGroups: { value: new Map() }
});
}
async project(name) {
async repositoryGroup(name) {
if (name === undefined) {

@@ -299,20 +308,27 @@ return undefined;

await this._initialize();
return this.projects.get(name);
return this.repositoryGroups.get(name);
}
async createProject(name, options) {
async createRepositoryGroup(name, options) {
await this._initialize();
const project = new this.projectClass(this, name, options);
await project.initialize();
this.projects.set(name, project);
return project;
const repositoryGroup = new this.repositoryGroupClass(this, name, options);
await repositoryGroup.initialize();
this.repositoryGroups.set(name, repositoryGroup);
return repositoryGroup;
}
get branchClass() {
return Branch;
async repository(name) {
let r = await super.repository(name);
if (r !== undefined) {
return r;
}
for (const p of this.repositoryGroups.values()) {
r = await p.repository(name);
if (r !== undefined) {
return r;
}
}
return r;
}
get projectClass() {
return Project;
get repositoryGroupClass() {
return RepositoryGroup;
}
get contentClass() {
return Content;
}
get pullRequestClass() {

@@ -327,2 +343,5 @@ return PullRequest;

}
get provider() {
return this;
}
}

@@ -334,4 +353,4 @@

exports.Owner = Owner;
exports.Project = Project;
exports.RepositoryGroup = RepositoryGroup;
exports.Content = Content;
exports.Provider = Provider;
{
"name": "repository-provider",
"version": "2.24.1",
"version": "3.0.0",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

@@ -49,24 +49,25 @@ [![npm](https://img.shields.io/npm/v/repository-provider.svg)](https://www.npmjs.com/package/repository-provider)

- [Properties](#properties)
- [project](#project)
- [repositoryGroup](#repositorygroup)
- [Parameters](#parameters-1)
- [createProject](#createproject)
- [createRepositoryGroup](#createrepositorygroup)
- [Parameters](#parameters-2)
- [branchClass](#branchclass)
- [projectClass](#projectclass)
- [contentClass](#contentclass)
- [repository](#repository)
- [Parameters](#parameters-3)
- [repositoryGroupClass](#repositorygroupclass)
- [pullRequestClass](#pullrequestclass)
- [rateLimitReached](#ratelimitreached)
- [name](#name)
- [provider](#provider-1)
- [defaultOptions](#defaultoptions)
- [optionsFromEnvironment](#optionsfromenvironment)
- [Parameters](#parameters-3)
- [Parameters](#parameters-4)
- [options](#options)
- [Parameters](#parameters-4)
- [Parameters](#parameters-5)
- [Branch](#branch)
- [Parameters](#parameters-5)
- [Parameters](#parameters-6)
- [Properties](#properties-1)
- [initialize](#initialize)
- [provider](#provider-1)
- [provider](#provider-2)
- [owner](#owner)
- [project](#project-1)
- [project](#project)
- [fullName](#fullname)

@@ -80,30 +81,33 @@ - [fullCondensedName](#fullcondensedname)

- [content](#content)
- [Parameters](#parameters-6)
- [Parameters](#parameters-7)
- [commit](#commit)
- [Parameters](#parameters-7)
- [Parameters](#parameters-8)
- [createPullRequest](#createpullrequest)
- [Parameters](#parameters-8)
- [Parameters](#parameters-9)
- [list](#list)
- [rateLimitReached](#ratelimitreached-1)
- [rateLimitReached](#ratelimitreached-2)
- [Parameters](#parameters-9)
- [Parameters](#parameters-10)
- [Owner](#owner-1)
- [Properties](#properties-2)
- [repositoryClass](#repositoryclass)
- [branchClass](#branchclass)
- [contentClass](#contentclass)
- [deleteRepository](#deleterepository)
- [Parameters](#parameters-10)
- [repository](#repository)
- [Parameters](#parameters-11)
- [repository](#repository-1)
- [Parameters](#parameters-12)
- [createRepository](#createrepository)
- [Parameters](#parameters-12)
- [Parameters](#parameters-13)
- [branch](#branch-1)
- [Parameters](#parameters-13)
- [Parameters](#parameters-14)
- [initialize](#initialize-1)
- [type](#type)
- [Repository](#repository-1)
- [Parameters](#parameters-14)
- [Repository](#repository-2)
- [Parameters](#parameters-15)
- [Properties](#properties-3)
- [provider](#provider-3)
- [initialize](#initialize-2)
- [content](#content-1)
- [Parameters](#parameters-15)
- [Parameters](#parameters-16)
- [urls](#urls)

@@ -114,38 +118,38 @@ - [url](#url-1)

- [owner](#owner-2)
- [project](#project-2)
- [project](#project-1)
- [condensedName](#condensedname)
- [branch](#branch-2)
- [Parameters](#parameters-16)
- [Parameters](#parameters-17)
- [defaultBranch](#defaultbranch)
- [branches](#branches)
- [createBranch](#createbranch)
- [Parameters](#parameters-17)
- [Parameters](#parameters-18)
- [deleteBranch](#deletebranch)
- [Parameters](#parameters-18)
- [Parameters](#parameters-19)
- [addBranch](#addbranch)
- [Parameters](#parameters-19)
- [Parameters](#parameters-20)
- [delete](#delete-1)
- [pullRequests](#pullrequests)
- [pullRequest](#pullrequest)
- [Parameters](#parameters-20)
- [Parameters](#parameters-21)
- [addPullRequest](#addpullrequest)
- [Parameters](#parameters-21)
- [Parameters](#parameters-22)
- [deletePullRequest](#deletepullrequest)
- [Parameters](#parameters-22)
- [Parameters](#parameters-23)
- [type](#type-1)
- [rateLimitReached](#ratelimitreached-3)
- [rateLimitReached](#ratelimitreached-4)
- [Parameters](#parameters-23)
- [Parameters](#parameters-24)
- [PullRequest](#pullrequest-1)
- [Parameters](#parameters-24)
- [Parameters](#parameters-25)
- [Properties](#properties-4)
- [provider](#provider-2)
- [provider](#provider-4)
- [delete](#delete-2)
- [merge](#merge)
- [decline](#decline)
- [Project](#project-3)
- [Parameters](#parameters-25)
- [RepositoryGroup](#repositorygroup-1)
- [Parameters](#parameters-26)
- [Properties](#properties-5)
- [Content](#content-2)
- [Parameters](#parameters-26)
- [Parameters](#parameters-27)
- [Properties](#properties-6)

@@ -165,18 +169,18 @@

- `projects` **[Map](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [Project](#project)>**
- `repositoryGroups` **[Map](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [RepositoryGroup](#repositorygroup)>**
- `config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
### project
### repositoryGroup
Lookup a project
Lookup a repository group
#### Parameters
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** of the project
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** of the group
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Project](#project)>**
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[RepositoryGroup](#repositorygroup)>**
### createProject
### createRepositoryGroup
Create a new project
Create a new repository group

@@ -188,16 +192,18 @@ #### Parameters

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Project](#project)>**
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[RepositoryGroup](#repositorygroup)>**
### branchClass
### repository
Returns **Class** branch class used by the Provider
Lookup a repository in the provider and all of its repository groups
### projectClass
#### Parameters
Returns **Class** project class used by the Provider
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
### contentClass
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Repository](#repository)>**
Returns **Class** content class used by the Provider
### repositoryGroupClass
Returns **Class** repository group class used by the Provider
### pullRequestClass

@@ -220,2 +226,8 @@

### provider
we are our own provider
Returns **[Provider](#provider)** this
### defaultOptions

@@ -401,2 +413,4 @@

Collection of repositories
### Properties

@@ -410,2 +424,10 @@

### branchClass
Returns **Class** branch class used by the Provider
### contentClass
Returns **Class** content class used by the Provider
### deleteRepository

@@ -458,3 +480,3 @@

- **See: [Provider#repository](Provider#repository)**
- **See: [Provider#repository](#providerrepository)**
- **See: [Provider#branch](Provider#branch)**

@@ -481,3 +503,3 @@ - **See: [Provider#createRepository](Provider#createRepository)**

- `provider` **[Provider](#provider)**
- `owner` **[Owner](#owner)**
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**

@@ -488,6 +510,12 @@ - `options`

- `provider` **[Provider](#provider)**
- `owner` **[Owner](#owner)**
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
### provider
the owners provider
Returns **[Provider](#provider)**
### initialize

@@ -708,7 +736,7 @@

## Project
## RepositoryGroup
**Extends Owner**
Abstract project
Abstract repository as a collection

@@ -718,3 +746,3 @@ ### Parameters

- `provider` **[Provider](#provider)**
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** of the group

@@ -721,0 +749,0 @@ ### Properties

import { Repository } from './repository';
import { Branch } from './branch';
import { Content } from './content';
/**
* Collection of repositories
* @property {Map<string,Repository>} repositories

@@ -21,2 +24,16 @@ */

/**
* @return {Class} branch class used by the Provider
*/
get branchClass() {
return Branch;
}
/**
* @return {Class} content class used by the Provider
*/
get contentClass() {
return Content;
}
/**
* Delete a repository

@@ -23,0 +40,0 @@ * @param {string} name

@@ -5,7 +5,7 @@ import { Branch } from './branch';

import { PullRequest } from './pull-request';
import { Project } from './project';
import { RepositoryGroup } from './repository-group';
import { Content } from './content';
import { notImplementedError } from './util';
export { Repository, Branch, PullRequest, Owner, Project, Content };
export { Repository, Branch, PullRequest, Owner, RepositoryGroup, Content };

@@ -15,3 +15,3 @@ /**

* @param {Object} options
* @property {Map<string,Project>} projects
* @property {Map<string,RepositoryGroup>} repositoryGroups
* @property {Object} config

@@ -54,3 +54,3 @@ */

},
projects: { value: new Map() }
repositoryGroups: { value: new Map() }
});

@@ -60,7 +60,7 @@ }

/**
* Lookup a project
* @param {string} name of the project
* @return {Promise<Project>}
* Lookup a repository group
* @param {string} name of the group
* @return {Promise<RepositoryGroup>}
*/
async project(name) {
async repositoryGroup(name) {
if (name === undefined) {

@@ -70,38 +70,46 @@ return undefined;

await this._initialize();
return this.projects.get(name);
return this.repositoryGroups.get(name);
}
/**
* Create a new project
* Create a new repository group
* @param {string} name
* @param {Object} options
* @return {Promise<Project>}
* @return {Promise<RepositoryGroup>}
*/
async createProject(name, options) {
async createRepositoryGroup(name, options) {
await this._initialize();
const project = new this.projectClass(this, name, options);
await project.initialize();
this.projects.set(name, project);
return project;
const repositoryGroup = new this.repositoryGroupClass(this, name, options);
await repositoryGroup.initialize();
this.repositoryGroups.set(name, repositoryGroup);
return repositoryGroup;
}
/**
* @return {Class} branch class used by the Provider
* Lookup a repository in the provider and all of its repository groups
* @param {string} name
* @return {Promise<Repository>}
*/
get branchClass() {
return Branch;
}
async repository(name) {
let r = await super.repository(name);
/**
* @return {Class} project class used by the Provider
*/
get projectClass() {
return Project;
if (r !== undefined) {
return r;
}
for (const p of this.repositoryGroups.values()) {
r = await p.repository(name);
if (r !== undefined) {
return r;
}
}
return r;
}
/**
* @return {Class} content class used by the Provider
* @return {Class} repository group class used by the Provider
*/
get contentClass() {
return Content;
get repositoryGroupClass() {
return RepositoryGroup;
}

@@ -132,2 +140,10 @@

}
/**
* we are our own provider
* @return {Provider} this
*/
get provider() {
return this;
}
}

@@ -5,5 +5,5 @@ import { notImplementedError } from './util';

* Abstract repository
* @param {Provider} provider
* @param {Owner} owner
* @param {string} name
* @property {Provider} provider
* @property {Owner} owner
* @property {string} name

@@ -13,6 +13,6 @@ * @property {Object} options

export class Repository {
constructor(provider, name, options) {
constructor(owner, name, options) {
Object.defineProperties(this, {
name: { value: name },
provider: { value: provider },
owner: { value: owner },
_branches: { value: new Map() },

@@ -24,2 +24,10 @@ _pullRequests: { value: new Map() }

/**
* the owners provider
* @return {Provider}
*/
get provider() {
return this.owner.provider;
}
/**
* Called one after constructing

@@ -159,3 +167,3 @@ * @return {Promise<undefined>}

async delete() {
return this.provider.deleteRepository(this.name);
return this.owner.deleteRepository(this.name);
}

@@ -206,3 +214,3 @@

get type() {
return this.provider.type;
return this.owner.type;
}

@@ -209,0 +217,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc