Skip to content

Commit

Permalink
fix: provide ContentEntry class
Browse files Browse the repository at this point in the history
  • Loading branch information
arlac77 committed Feb 16, 2024
1 parent 1da947d commit 5516164
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 62 deletions.
3 changes: 2 additions & 1 deletion src/attribute-extras.mjs
@@ -1,5 +1,6 @@
import { setAttribute, getAttribute } from "pacc";


/**
* Create properties from options and default options.
* Already present properties (direct) are skipped.
Expand All @@ -19,7 +20,7 @@ import { setAttribute, getAttribute } from "pacc";
* @see Object.definedProperties()
* @see Object.getOwnPropertyDescriptor()
* @param {Object} object target object
* @param {Object} options as passed to object constructor
* @param {Object} options as passed to object constructor. Used as values for the attributes.
* @param {Object} properties object properties
* @param {Object} [attributes] attribute meta info
*/
Expand Down
2 changes: 1 addition & 1 deletion src/attributes.mjs
Expand Up @@ -3,7 +3,7 @@
*/

/**
* common attributes
* Common attribute properties.
* @type {AttributeDefinition}
*/
export const default_attribute = {
Expand Down
25 changes: 2 additions & 23 deletions src/base-provider.mjs
Expand Up @@ -305,7 +305,7 @@ export class BaseProvider extends BaseObject {
const rg = await this.repositoryGroup(group);
return rg.createRepository(repository, options);
}

/**
* List provider objects of a given type.
*
Expand Down Expand Up @@ -460,51 +460,30 @@ export class BaseProvider extends BaseObject {
return this.messageDestination.error(...args);
}

/**
* @return {typeof RepositoryGroup} repository group class used by the Provider
*/
get repositoryGroupClass() {
return RepositoryGroup;
}

/**
* @return {typeof Hook} hook class used by the Provider
*/
get hookClass() {
return Hook;
}

/**
* @return {typeof Repository} repository class used by the Provider
*/
get repositoryClass() {
return Repository;
}

/**
* @return {typeof Branch} branch class used by the Provider
*/
get branchClass() {
return Branch;
}

/**
* @return {typeof Tag} branch class used by the Provider
*/
get tagClass() {
return Tag;
}

/**
* @return {typeof ContentEntry} entry class used by the Provider
*/
get entryClass() {
return undefined;
return ContentEntry;
}

/**
* @return {typeof PullRequest} pull request class used by the Provider
*/
get pullRequestClass() {
return PullRequest;
}
Expand Down
40 changes: 8 additions & 32 deletions src/owned-object.mjs
@@ -1,14 +1,14 @@
import { ContentEntry } from "content-entry";
import { NamedObject } from "./named-object.mjs";

/**
* @typedef {import('./base-provider.mjs').BaseProvider} BaseProvider
* @typedef {import('./repository.mjs').Repository} Repository
* @typedef {import('./hook.mjs').Hook} Hook
* @typedef {import('./tag.mjs').Tag} Tag
* @typedef {import('./branch.mjs').Branch} Branch
* @typedef {import('./pull-request.mjs').PullRequest} PullRequest
*/
/**
* @typedef {import('./base-provider.mjs').BaseProvider} BaseProvider
* @typedef {import('./repository.mjs').Repository} Repository
* @typedef {import('./hook.mjs').Hook} Hook
* @typedef {import('./tag.mjs').Tag} Tag
* @typedef {import('./branch.mjs').Branch} Branch
* @typedef {import('./pull-request.mjs').PullRequest} PullRequest
*/

/**
* Named Object registering itself in the owner.
Expand Down Expand Up @@ -189,50 +189,26 @@ export class OwnedObject extends NamedObject {
return this.owner.debug(...args);
}

/**
* By default we use the owners implementation.
* @return {Repository} as defined in the owner
*/
get repositoryClass() {
return this.owner.repositoryClass;
}

/**
* By default we use the owners implementation.
* @return {PullRequest} as defined in the owner
*/
get pullRequestClass() {
return this.owner.pullRequestClass;
}

/**
* By default we use the owners implementation.
* @return {Branch} as defined in the owner
*/
get branchClass() {
return this.owner.branchClass;
}

/**
* By default we use the owners implementation.
* @return {Tag} as defined in the owner
*/
get tagClass() {
return this.owner.tagClass;
}

/**
* By default we use the owners implementation.
* @return {ContentEntry} as defined in the owner
*/
get entryClass() {
return this.owner.entryClass;
}

/**
* By default we use the owners implementation.
* @return {Hook} as defined in the owner
*/
get hookClass() {
return this.owner.hookClass;
}
Expand Down
3 changes: 2 additions & 1 deletion src/ref.mjs
Expand Up @@ -14,7 +14,8 @@ import { name_attribute, boolean_attribute } from "./attributes.mjs";
// @ts-ignore
export class Ref extends OwnedObject {
/**
* options
* Attributes
* @type {Object}
*/
static get attributes() {
return {
Expand Down
3 changes: 2 additions & 1 deletion tests/branch-ava.mjs
Expand Up @@ -7,6 +7,7 @@ import {
Branch,
PullRequest
} from "repository-provider";
import { ContentEntry } from "content-entry";

test("Branch type", t => t.is(Branch.type, "branch"));
test("Branch collection name", t => t.is(Branch.collectionName, "branches"));
Expand Down Expand Up @@ -43,7 +44,7 @@ test("branch init", async t => {
t.is(`${b}`, "SingleGroupProvider:r1#b1");
t.is(b.ref, "refs/heads/b1");
t.is(b.pullRequestClass, PullRequest);
t.is(b.entryClass, undefined);
t.is(b.entryClass, ContentEntry);
t.is(await repository.branch("b1"), b);
});

Expand Down
3 changes: 2 additions & 1 deletion tests/repository-ava.mjs
Expand Up @@ -6,6 +6,7 @@ import {
Branch,
PullRequest
} from "repository-provider";
import { ContentEntry } from "content-entry";

test("Repository type", t => t.is(Repository.type, "repository"));
test("Repository collection name", t => t.is(Repository.collectionName, "repositories"));
Expand Down Expand Up @@ -120,7 +121,7 @@ test("repository classes", t => {
const provider = new SingleGroupProvider();
const repository = new Repository(provider, "r1#branch");
t.is(repository.branchClass, Branch);
t.is(repository.entryClass, undefined);
t.is(repository.entryClass, ContentEntry);
t.is(repository.pullRequestClass, PullRequest);
});

Expand Down
3 changes: 2 additions & 1 deletion tests/repository-group-ava.mjs
@@ -1,4 +1,5 @@
import test from "ava";
import { ContentEntry } from "content-entry";
import {
MultiGroupProvider,
RepositoryGroup,
Expand Down Expand Up @@ -47,7 +48,7 @@ test("repository-group classes", t => {

t.is(rg.repositoryClass, Repository);
t.is(rg.branchClass, Branch);
t.is(rg.entryClass, undefined);
t.is(rg.entryClass, ContentEntry);
t.is(rg.pullRequestClass, PullRequest);
});

Expand Down
3 changes: 2 additions & 1 deletion tests/tag-ava.mjs
@@ -1,6 +1,7 @@
import test from "ava";
import { createMessageDestination } from "repository-provider-test-support";
import { Tag, SingleGroupProvider } from "repository-provider";
import { ContentEntry } from "content-entry";

test("Tag type", t => t.is(Tag.type, "tag"));
test("Tag collection name", t => t.is(Tag.collectionName, "tags"));
Expand All @@ -18,7 +19,7 @@ test("tag init", async t => {
t.is(b.name, "t1");
t.is(b.ref, "refs/tags/t1");
t.is(b.isWritable, false);
t.is(b.entryClass, undefined);
t.is(b.entryClass, ContentEntry);
// t.is(await repository.tags("t1"), b);

t.is(b.identifier, "SingleGroupProvider:r1#t1");
Expand Down

0 comments on commit 5516164

Please sign in to comment.