-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kb): knowledge base repository done (#18)
Because we need knowledge base api. This commit is partial implementation for 1. fix service and repository dependency tanggled 2. create migration 3. impl knowledge base related db operation 4. make run-local and make build-local for local development Note: need some work to align the details with other backend services in the future
- Loading branch information
Showing
27 changed files
with
2,410 additions
and
676 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package service | ||
package customerror | ||
|
||
import "errors" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE knowledge_base; |
22 changes: 22 additions & 0 deletions
22
pkg/db/migration/000002_create_knowledge_base_table.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
CREATE TABLE knowledge_base ( | ||
id UUID PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(), | ||
kb_id VARCHAR(255) NOT NULL UNIQUE, | ||
name VARCHAR(255) NOT NULL, | ||
description VARCHAR(1023), | ||
tags VARCHAR(255)[], | ||
owner VARCHAR(255) NOT NULL, | ||
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
update_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
delete_time TIMESTAMP | ||
); | ||
|
||
COMMENT ON TABLE knowledge_base IS 'Table to store knowledge base information'; | ||
COMMENT ON COLUMN knowledge_base.id IS 'Primary key, auto-generated UUID'; | ||
COMMENT ON COLUMN knowledge_base.name IS 'Name of the knowledge base, up to 255 characters'; | ||
COMMENT ON COLUMN knowledge_base.kb_id IS 'Unique identifier for the knowledge base, up to 255 characters'; | ||
COMMENT ON COLUMN knowledge_base.description IS 'Description of the knowledge base, up to 1023 characters'; | ||
COMMENT ON COLUMN knowledge_base.update_time IS 'Timestamp of the last update, stored in UTC'; | ||
COMMENT ON COLUMN knowledge_base.create_time IS 'Timestamp when the entry was created, stored in UTC'; | ||
COMMENT ON COLUMN knowledge_base.owner IS 'Owner of the knowledge base, up to 255 characters'; | ||
COMMENT ON COLUMN knowledge_base.tags IS 'Array of tags associated with the knowledge base'; | ||
COMMENT ON COLUMN knowledge_base.delete_time IS 'Timestamp when the entry was marked as deleted, stored in UTC'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package handler | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"google.golang.org/grpc/metadata" | ||
|
||
artifactpb "github.com/instill-ai/protogen-go/artifact/artifact/v1alpha" | ||
) | ||
|
||
func (ph *PublicHandler) CreateKnowledgeBase(ctx context.Context, req *artifactpb.CreateKnowledgeBaseRequest) (*artifactpb.CreateKnowledgeBaseResponse, error) { | ||
fmt.Println("CreateKnowledgeBase") | ||
return nil, nil | ||
} | ||
func (ph *PublicHandler) GetKnowledgeBases(ctx context.Context, req *artifactpb.GetKnowledgeBasesRequest) (*artifactpb.GetKnowledgeBasesResponse, error) { | ||
fmt.Println("GetKnowledgeBases") | ||
return nil, nil | ||
} | ||
func (ph *PublicHandler) UpdateKnowledgeBase(ctx context.Context, req *artifactpb.UpdateKnowledgeBaseRequest) (*artifactpb.UpdateKnowledgeBaseResponse, error) { | ||
fmt.Println("UpdateKnowledgeBase") | ||
return nil, nil | ||
} | ||
func (ph *PublicHandler) DeleteKnowledgeBase(ctx context.Context, req *artifactpb.DeleteKnowledgeBaseRequest) (*artifactpb.DeleteKnowledgeBaseResponse, error) { | ||
// get header | ||
md, _ := metadata.FromIncomingContext(ctx) | ||
fmt.Println(md) | ||
|
||
fmt.Println("DeleteKnowledgeBase") | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package mock | ||
|
||
//go:generate minimock -g -i github.com/instill-ai/artifact-backend/pkg/service.RegistryClient -o ./ -s "_mock.gen.go" | ||
//go:generate minimock -g -i github.com/instill-ai/artifact-backend/pkg/service.Repository -o ./ -s "_mock.gen.go" | ||
//go:generate minimock -g -i github.com/instill-ai/artifact-backend/pkg/repository.RepositoryI -o ./ -s "_mock.gen.go" |
Oops, something went wrong.