Skip to content

Commit

Permalink
Merge branch '0.21'
Browse files Browse the repository at this point in the history
  • Loading branch information
lorisleiva committed Aug 21, 2024
2 parents 93a318a + 7b3475d commit 279749c
Show file tree
Hide file tree
Showing 28 changed files with 146 additions and 18 deletions.
7 changes: 7 additions & 0 deletions packages/errors/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @kinobi-so/errors

## 0.21.4

### Patch Changes

- Updated dependencies []:
- @kinobi-so/node-types@0.21.4

## 0.21.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/errors/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinobi-so/errors",
"version": "0.21.3",
"version": "0.21.4",
"description": "Error management for Kinobi",
"exports": {
"types": "./dist/types/index.d.ts",
Expand Down
12 changes: 12 additions & 0 deletions packages/library/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# kinobi

## 0.21.4

### Patch Changes

- [#181](https://github.com/kinobi-so/kinobi/pull/181) [`28f3d38`](https://github.com/kinobi-so/kinobi/commit/28f3d381f570859cbea1c72b7e352ad3e72db37f) Thanks [@lorisleiva](https://github.com/lorisleiva)! - Fix TS bug on `accept` and `update` Kinobi function

- Updated dependencies []:
- @kinobi-so/errors@0.21.4
- @kinobi-so/nodes@0.21.4
- @kinobi-so/validators@0.21.4
- @kinobi-so/visitors@0.21.4

## 0.21.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kinobi",
"version": "0.21.3",
"version": "0.21.4",
"description": "A Solana framework for building standardised programs",
"exports": {
"types": "./dist/types/index.d.ts",
Expand Down
8 changes: 4 additions & 4 deletions packages/library/src/kinobi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import { assertIsNode, KinobiVersion, Node, RootNode } from '@kinobi-so/nodes';
import { visit, Visitor } from '@kinobi-so/visitors';

export interface Kinobi {
accept<T>(visitor: Visitor<T>): T;
accept<T>(visitor: Visitor<T, 'rootNode'>): T;
clone(): Kinobi;
getJson(): string;
getRoot(): RootNode;
update(visitor: Visitor<Node | null>): void;
update(visitor: Visitor<Node | null, 'rootNode'>): void;
}

export function createFromRoot(root: RootNode): Kinobi {
let currentRoot = root;
validateKinobiVersion(currentRoot.version);
return {
accept<T>(visitor: Visitor<T>): T {
accept<T>(visitor: Visitor<T, 'rootNode'>): T {
return visit(currentRoot, visitor);
},
clone(): Kinobi {
Expand All @@ -27,7 +27,7 @@ export function createFromRoot(root: RootNode): Kinobi {
getRoot(): RootNode {
return currentRoot;
},
update(visitor: Visitor<Node | null>): void {
update(visitor: Visitor<Node | null, 'rootNode'>): void {
const newRoot = visit(currentRoot, visitor);
assertIsNode(newRoot, 'rootNode');
currentRoot = newRoot;
Expand Down
16 changes: 15 additions & 1 deletion packages/library/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from 'vitest';

import { identityVisitor, rootNode } from '../src';
import { createFromRoot, identityVisitor, programNode, rootNode, rootNodeVisitor, voidVisitor } from '../src';

test('it exports node helpers', () => {
expect(typeof rootNode).toBe('function');
Expand All @@ -9,3 +9,17 @@ test('it exports node helpers', () => {
test('it exports visitors', () => {
expect(typeof identityVisitor).toBe('function');
});

test('it accepts visitors', () => {
const kinobi = createFromRoot(rootNode(programNode({ name: 'myProgram', publicKey: '1111' })));
const visitor = voidVisitor(['rootNode']);
const result = kinobi.accept(visitor) satisfies void;
expect(typeof result).toBe('undefined');
});

test('it updates the root node returned by visitors', () => {
const kinobi = createFromRoot(rootNode(programNode({ name: 'myProgram', publicKey: '1111' })));
const visitor = rootNodeVisitor(node => rootNode(programNode({ ...node.program, name: 'myTransformedProgram' })));
kinobi.update(visitor) satisfies void;
expect(kinobi.getRoot()).toEqual(rootNode(programNode({ name: 'myTransformedProgram', publicKey: '1111' })));
});
2 changes: 2 additions & 0 deletions packages/node-types/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @kinobi-so/node-types

## 0.21.4

## 0.21.3

## 0.21.2
Expand Down
2 changes: 1 addition & 1 deletion packages/node-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinobi-so/node-types",
"version": "0.21.3",
"version": "0.21.4",
"description": "Node specifications for the Kinobi standard",
"exports": {
"types": "./dist/types/index.d.ts",
Expand Down
9 changes: 9 additions & 0 deletions packages/nodes-from-anchor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @kinobi-so/nodes-from-anchor

## 0.21.2

### Patch Changes

- Updated dependencies []:
- @kinobi-so/errors@0.21.4
- @kinobi-so/nodes@0.21.4
- @kinobi-so/visitors@0.21.4

## 0.21.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-from-anchor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinobi-so/nodes-from-anchor",
"version": "0.21.1",
"version": "0.21.2",
"description": "Node specifications and helpers for the Kinobi standard",
"exports": {
"types": "./dist/types/index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions packages/nodes/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @kinobi-so/nodes

## 0.21.4

### Patch Changes

- Updated dependencies []:
- @kinobi-so/errors@0.21.4
- @kinobi-so/node-types@0.21.4

## 0.21.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinobi-so/nodes",
"version": "0.21.3",
"version": "0.21.4",
"description": "Node specifications and helpers for the Kinobi standard",
"exports": {
"types": "./dist/types/index.d.ts",
Expand Down
9 changes: 9 additions & 0 deletions packages/renderers-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @kinobi-so/renderers-core

## 0.21.2

### Patch Changes

- Updated dependencies []:
- @kinobi-so/errors@0.21.4
- @kinobi-so/nodes@0.21.4
- @kinobi-so/visitors-core@0.21.4

## 0.21.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/renderers-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinobi-so/renderers-core",
"version": "0.21.1",
"version": "0.21.2",
"description": "Core types and helpers for Kinobi renderers to use",
"exports": {
"types": "./dist/types/index.d.ts",
Expand Down
11 changes: 11 additions & 0 deletions packages/renderers-js-umi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @kinobi-so/renderers-js-umi

## 0.21.6

### Patch Changes

- Updated dependencies []:
- @kinobi-so/errors@0.21.4
- @kinobi-so/nodes@0.21.4
- @kinobi-so/validators@0.21.4
- @kinobi-so/visitors-core@0.21.4
- @kinobi-so/renderers-core@0.21.2

## 0.21.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/renderers-js-umi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinobi-so/renderers-js-umi",
"version": "0.21.5",
"version": "0.21.6",
"description": "JavaScript renderer compatible with the Umi framework",
"exports": {
"types": "./dist/types/index.d.ts",
Expand Down
11 changes: 11 additions & 0 deletions packages/renderers-js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @kinobi-so/renderers-js

## 0.21.7

### Patch Changes

- Updated dependencies []:
- @kinobi-so/errors@0.21.4
- @kinobi-so/nodes@0.21.4
- @kinobi-so/visitors-core@0.21.4
- @kinobi-so/nodes-from-anchor@0.21.2
- @kinobi-so/renderers-core@0.21.2

## 0.21.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/renderers-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinobi-so/renderers-js",
"version": "0.21.6",
"version": "0.21.7",
"description": "JavaScript renderer compatible with the Solana web3.js library",
"exports": {
"types": "./dist/types/index.d.ts",
Expand Down
10 changes: 10 additions & 0 deletions packages/renderers-rust/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @kinobi-so/renderers-rust

## 0.21.6

### Patch Changes

- Updated dependencies []:
- @kinobi-so/errors@0.21.4
- @kinobi-so/nodes@0.21.4
- @kinobi-so/visitors-core@0.21.4
- @kinobi-so/renderers-core@0.21.2

## 0.21.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/renderers-rust/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinobi-so/renderers-rust",
"version": "0.21.5",
"version": "0.21.6",
"description": "Renders Rust clients for your programs",
"exports": {
"types": "./dist/types/index.d.ts",
Expand Down
9 changes: 9 additions & 0 deletions packages/renderers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @kinobi-so/renderers

## 0.21.2

### Patch Changes

- Updated dependencies []:
- @kinobi-so/renderers-js@0.21.7
- @kinobi-so/renderers-js-umi@0.21.6
- @kinobi-so/renderers-rust@0.21.6

## 0.21.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/renderers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinobi-so/renderers",
"version": "0.21.1",
"version": "0.21.2",
"description": "Exports all Kinobi renderers",
"exports": {
"types": "./dist/types/index.d.ts",
Expand Down
9 changes: 9 additions & 0 deletions packages/validators/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @kinobi-so/validators

## 0.21.4

### Patch Changes

- Updated dependencies []:
- @kinobi-so/errors@0.21.4
- @kinobi-so/nodes@0.21.4
- @kinobi-so/visitors-core@0.21.4

## 0.21.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/validators/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinobi-so/validators",
"version": "0.21.3",
"version": "0.21.4",
"description": "Validator visitors for the Kinobi framework",
"exports": {
"types": "./dist/types/index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions packages/visitors-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @kinobi-so/visitors-core

## 0.21.4

### Patch Changes

- Updated dependencies []:
- @kinobi-so/errors@0.21.4
- @kinobi-so/nodes@0.21.4

## 0.21.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/visitors-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinobi-so/visitors-core",
"version": "0.21.3",
"version": "0.21.4",
"description": "Core visitors for the Kinobi framework",
"exports": {
"types": "./dist/types/index.d.ts",
Expand Down
9 changes: 9 additions & 0 deletions packages/visitors/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @kinobi-so/visitors

## 0.21.4

### Patch Changes

- Updated dependencies []:
- @kinobi-so/errors@0.21.4
- @kinobi-so/nodes@0.21.4
- @kinobi-so/visitors-core@0.21.4

## 0.21.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/visitors/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kinobi-so/visitors",
"version": "0.21.3",
"version": "0.21.4",
"description": "All visitors for the Kinobi framework",
"exports": {
"types": "./dist/types/index.d.ts",
Expand Down

0 comments on commit 279749c

Please sign in to comment.