Przeglądaj źródła

Merge branch '0.21'

Loris Leiva 1 rok temu
rodzic
commit
279749c331

+ 7 - 0
packages/errors/CHANGELOG.md

@@ -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

+ 1 - 1
packages/errors/package.json

@@ -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",

+ 12 - 0
packages/library/CHANGELOG.md

@@ -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

+ 1 - 1
packages/library/package.json

@@ -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",

+ 4 - 4
packages/library/src/kinobi.ts

@@ -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 {
@@ -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;

+ 15 - 1
packages/library/test/index.test.ts

@@ -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');
@@ -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 - 0
packages/node-types/CHANGELOG.md

@@ -1,5 +1,7 @@
 # @kinobi-so/node-types
 
+## 0.21.4
+
 ## 0.21.3
 
 ## 0.21.2

+ 1 - 1
packages/node-types/package.json

@@ -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",

+ 9 - 0
packages/nodes-from-anchor/CHANGELOG.md

@@ -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

+ 1 - 1
packages/nodes-from-anchor/package.json

@@ -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",

+ 8 - 0
packages/nodes/CHANGELOG.md

@@ -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

+ 1 - 1
packages/nodes/package.json

@@ -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",

+ 9 - 0
packages/renderers-core/CHANGELOG.md

@@ -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

+ 1 - 1
packages/renderers-core/package.json

@@ -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",

+ 11 - 0
packages/renderers-js-umi/CHANGELOG.md

@@ -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

+ 1 - 1
packages/renderers-js-umi/package.json

@@ -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",

+ 11 - 0
packages/renderers-js/CHANGELOG.md

@@ -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

+ 1 - 1
packages/renderers-js/package.json

@@ -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",

+ 10 - 0
packages/renderers-rust/CHANGELOG.md

@@ -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

+ 1 - 1
packages/renderers-rust/package.json

@@ -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",

+ 9 - 0
packages/renderers/CHANGELOG.md

@@ -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

+ 1 - 1
packages/renderers/package.json

@@ -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",

+ 9 - 0
packages/validators/CHANGELOG.md

@@ -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

+ 1 - 1
packages/validators/package.json

@@ -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",

+ 8 - 0
packages/visitors-core/CHANGELOG.md

@@ -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

+ 1 - 1
packages/visitors-core/package.json

@@ -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",

+ 9 - 0
packages/visitors/CHANGELOG.md

@@ -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

+ 1 - 1
packages/visitors/package.json

@@ -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",