Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

chore: support extension through abstract base class #18

Merged
merged 8 commits into from
Jul 31, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 47 additions & 109 deletions API.md
Original file line number Diff line number Diff line change
@@ -1,114 +1,5 @@
# API Reference <a name="API Reference" id="api-reference"></a>

## Constructs <a name="Constructs" id="Constructs"></a>

### Polycon <a name="Polycon" id="@monadahq/polycons.Polycon"></a>

A polymorphic construct that can be resolved at construction time into a more specific construct.

#### Initializers <a name="Initializers" id="@monadahq/polycons.Polycon.Initializer"></a>

```typescript
import { Polycon } from '@monadahq/polycons'

new Polycon(qualifier: string, scope: Construct, id: string, props?: any)
```

| **Name** | **Type** | **Description** |
| --- | --- | --- |
| <code><a href="#@monadahq/polycons.Polycon.Initializer.parameter.qualifier">qualifier</a></code> | <code>string</code> | *No description.* |
| <code><a href="#@monadahq/polycons.Polycon.Initializer.parameter.scope">scope</a></code> | <code>constructs.Construct</code> | *No description.* |
| <code><a href="#@monadahq/polycons.Polycon.Initializer.parameter.id">id</a></code> | <code>string</code> | *No description.* |
| <code><a href="#@monadahq/polycons.Polycon.Initializer.parameter.props">props</a></code> | <code>any</code> | *No description.* |

---

##### `qualifier`<sup>Required</sup> <a name="qualifier" id="@monadahq/polycons.Polycon.Initializer.parameter.qualifier"></a>

- *Type:* string

---

##### `scope`<sup>Required</sup> <a name="scope" id="@monadahq/polycons.Polycon.Initializer.parameter.scope"></a>

- *Type:* constructs.Construct

---

##### `id`<sup>Required</sup> <a name="id" id="@monadahq/polycons.Polycon.Initializer.parameter.id"></a>

- *Type:* string

---

##### `props`<sup>Optional</sup> <a name="props" id="@monadahq/polycons.Polycon.Initializer.parameter.props"></a>

- *Type:* any

---

#### Methods <a name="Methods" id="Methods"></a>

| **Name** | **Description** |
| --- | --- |
| <code><a href="#@monadahq/polycons.Polycon.toString">toString</a></code> | Returns a string representation of this construct. |

---

##### `toString` <a name="toString" id="@monadahq/polycons.Polycon.toString"></a>

```typescript
public toString(): string
```

Returns a string representation of this construct.

#### Static Functions <a name="Static Functions" id="Static Functions"></a>

| **Name** | **Description** |
| --- | --- |
| <code><a href="#@monadahq/polycons.Polycon.isConstruct">isConstruct</a></code> | Checks if `x` is a construct. |

---

##### ~~`isConstruct`~~ <a name="isConstruct" id="@monadahq/polycons.Polycon.isConstruct"></a>

```typescript
import { Polycon } from '@monadahq/polycons'

Polycon.isConstruct(x: any)
```

Checks if `x` is a construct.

###### `x`<sup>Required</sup> <a name="x" id="@monadahq/polycons.Polycon.isConstruct.parameter.x"></a>

- *Type:* any

Any object.

---

#### Properties <a name="Properties" id="Properties"></a>

| **Name** | **Type** | **Description** |
| --- | --- | --- |
| <code><a href="#@monadahq/polycons.Polycon.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |

---

##### `node`<sup>Required</sup> <a name="node" id="@monadahq/polycons.Polycon.property.node"></a>

```typescript
public readonly node: Node;
```

- *Type:* constructs.Node

The tree node.

---


## Structs <a name="Structs" id="Structs"></a>

Expand Down Expand Up @@ -492,6 +383,53 @@ This factory will be used for resolving all polycons into constructs.



### Polycons <a name="Polycons" id="@monadahq/polycons.Polycons"></a>

A class used to create polycons.


#### Static Functions <a name="Static Functions" id="Static Functions"></a>

| **Name** | **Description** |
| --- | --- |
| <code><a href="#@monadahq/polycons.Polycons.create">create</a></code> | *No description.* |

---

##### `create` <a name="create" id="@monadahq/polycons.Polycons.create"></a>

```typescript
import { Polycons } from '@monadahq/polycons'

Polycons.create(qualifier: string, scope: Construct, id: string, props?: any)
```

###### `qualifier`<sup>Required</sup> <a name="qualifier" id="@monadahq/polycons.Polycons.create.parameter.qualifier"></a>

- *Type:* string

---

###### `scope`<sup>Required</sup> <a name="scope" id="@monadahq/polycons.Polycons.create.parameter.scope"></a>

- *Type:* constructs.Construct

---

###### `id`<sup>Required</sup> <a name="id" id="@monadahq/polycons.Polycons.create.parameter.id"></a>

- *Type:* string

---

###### `props`<sup>Optional</sup> <a name="props" id="@monadahq/polycons.Polycons.create.parameter.props"></a>

- *Type:* any

---



### Process <a name="Process" id="@monadahq/polycons.Process"></a>

Runtime code with a named entrypoint.
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./process";
export * from "./polycon";
export * from "./polycons";
export * from "./polycon-factory";
48 changes: 0 additions & 48 deletions src/polycon.ts

This file was deleted.

23 changes: 23 additions & 0 deletions src/polycons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Construct } from "constructs";
import { PolyconFactory } from "./polycon-factory";

/**
* A class used to create polycons
*/
export class Polycons {
eladb marked this conversation as resolved.
Show resolved Hide resolved
public static create(
qualifier: string,
scope: Construct,
id: string,
props?: any
) {
const factory = PolyconFactory.of(scope);
if (!factory) {
throw new Error(`No factory defined within scope of "${id}"`);
}

return factory.resolveConstruct(qualifier, scope, id, props);
}

private constructor() {}
}
Loading