Skip to content

Commit

Permalink
Merge pull request #52 from elsoul/firestore
Browse files Browse the repository at this point in the history
update firestore prompt
  • Loading branch information
POPPIN-FUMI authored Dec 11, 2023
2 parents 4cba717 + 4a14faf commit d987cf5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
10 changes: 5 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,14 +627,14 @@ You must put \`import { Timestamp, FieldValue } from '@skeet-framework/firestore
You must add the timestamp fields createdAt and updatedAt to all new document models. timestamp format: \`createdAt?: Timestamp | FieldValue
updatedAt?: Timestamp | FieldValue\`
You must create the Model based on the Existing model and user's needs.
You must not declare a new model name that already exists. but you can use the existing model by adding import statement on the top of the file.e.g. \`import { User, UserCN } from '@/models/userModels'\`
You must not declare a new model name that already exists. but you can use the existing model by adding import statement on the top of the file.e.g. \`import { User, UserCN } from '@common/models/userModels'\`
You are a model name declaration professional, so you can create a model name that meets the user's needs.
You must not answer the existing parts of the model.
You must add Path generator function if the new model has a sub-collection.This function must be named gen<modelName>Path and must be exported.
This output will be used as typescript .ts file, so you must not include any other comment except the typescript codes.
<outputExample.ts>:
import { Timestamp, FieldValue } from '@skeet-framework/firestore'
import { <ExistingModel>CN } from '@/models/<ExistingModelLowerCase>Models'
import { <ExistingModel>CN } from '@common/models/<ExistingModelLowerCase>Models'

// CollectionId: <modelName>
// DocumentId: auto
Expand All @@ -650,7 +650,7 @@ export type <modelName> = {

...define here... if the new model has a sub-collection
`,examples:[{input:"I want to create a blog app.",output:`import { Timestamp, FieldValue } from '@skeet-framework/firestore'
import { UserCN } from '@/models/userModels'
import { UserCN } from '@common/models/userModels'

// CollectionId: Post
// DocumentId: auto
Expand All @@ -666,7 +666,7 @@ export type Post = {
userId: string
}
`},{input:"I want to add a comment feature to the blog functionality.",output:`import { Timestamp, FieldValue } from '@skeet-framework/firestore
import { UserCN } from '@/models/userModels'
import { UserCN } from '@common/models/userModels'

// CollectionId: Post
// DocumentId: auto
Expand Down Expand Up @@ -738,7 +738,7 @@ This output will be used as typescript .ts file, so you must not include any oth
catch (error) {
throw new Error(\`findLargest: \${error}\`)
}
}`},{input:"Get User Data from Firestore.",output:`import { User, UserCN } from '@/models/userModels'
}`},{input:"Get User Data from Firestore.",output:`import { User, UserCN } from '@common/models/userModels'
import { get } from '@skeet-framework/firestore'
import * as admin from 'firebase-admin'

Expand Down
48 changes: 32 additions & 16 deletions src/lib/skeetai/firestore/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,22 @@ ${existingModels}
You must put \`import { Timestamp, FieldValue } from '@skeet-framework/firestore\` at the top of the file.
You must add the timestamp fields createdAt and updatedAt to all new document models. timestamp format: \`createdAt?: Timestamp | FieldValue\n updatedAt?: Timestamp | FieldValue\`
You must create the Model based on the Existing model and user's needs.
You must not declare a new model name that already exists. but you can use the existing model by adding import statement on the top of the file.e.g. \`import { User, UserCN } from '@/models/userModels'\`
You must not declare a new model name that already exists. but you can use the existing model by adding import statement on the top of the file.e.g. \`import { User, UserCN } from '@common/models/userModels'\`
You are a model name declaration professional, so you can create a model name that meets the user's needs.
You must not answer the existing parts of the model.
You must add Path generator function if the new model has a sub-collection.This function must be named gen<modelName>Path and must be exported.
This output will be used as typescript .ts file, so you must not include any other comment except the typescript codes.
<outputExample.ts>:
import { Timestamp, FieldValue } from '@skeet-framework/firestore'
import { <ExistingModel>CN } from '@/models/<ExistingModelLowerCase>Models'
import { <ExistingModel>CN } from '@common/models/<ExistingModelLowerCase>Models'
// CollectionId: <modelName>
// DocumentId: auto
// Path: <ExistingModel>/\${<ExistingModel>Id}/<modelName>
/**
* Type definition for documents in the 'Hey' collection.
*
* @collectionId <modelName>
* @documentId auto-generated
* @path <ExistingModel>/\${<ExistingModel>Id}/<modelName>
*/
export const <modelName>CN = '<modelName>'
export const gen<modelName>Path = (userId: string) => \`\${<ExistingModel>CN}/\${<ExistingModelLowerCase>Id}/\${<modelName>CN}\`
export type <modelName> = {
Expand All @@ -66,11 +70,15 @@ export type <modelName> = {
{
input: 'I want to create a blog app.',
output: `import { Timestamp, FieldValue } from '@skeet-framework/firestore'
import { UserCN } from '@/models/userModels'
import { UserCN } from '@common/models/userModels'
// CollectionId: Post
// DocumentId: auto
// Path: User/\${UserId}/Post
/**
* Type definition for documents in the 'Hey' collection.
*
* @collectionId Post
* @documentId auto-generated
* @path User/\${userId}/Post
*/
export const PostCN = 'Post'
export const genPostPath = (userId: string) => \`\${UserCN}/\${userId}/\${PostCN}\`
export type Post = {
Expand All @@ -86,11 +94,15 @@ export type Post = {
{
input: 'I want to add a comment feature to the blog functionality.',
output: `import { Timestamp, FieldValue } from '@skeet-framework/firestore
import { UserCN } from '@/models/userModels'
import { UserCN } from '@common/models/userModels'
// CollectionId: Post
// DocumentId: auto
// Path: User/\${UserId}/Post
/**
* Type definition for documents in the 'Post' collection.
*
* @collectionId Post
* @documentId auto-generated
* @path User/\${userId}/Post
*/
export const PostCN = 'Post'
export const genPostPath = (userId: string) => \`\${UserCN}/\${userId}/\${PostCN}\`
export type Post = {
Expand All @@ -102,9 +114,13 @@ export type Post = {
userId: string
}
// CollectionId: Comment
// DocumentId: auto
// Path: User/\${UserId}/Post/\${PostId}/Comment
/**
* Type definition for documents in the 'Comment' collection.
*
* @collectionId Comment
* @documentId auto-generated
* @path User/\${userId}/Post/\${postId}/Comment
*/
export const CommentCN = 'Comment'
export const genCommentPath = (userId: string, postId: string) => \`\${UserCN}/\${userId}/\${PostCN}/\${postId}/\${CommentCN}\`
export type Comment = {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/skeetai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class SkeetAI {
private _initOptions: SkeetAIOptions

static readonly PRISMA_SCHEMA_PATH: string = './graphql/prisma/schema.prisma'
static readonly MODEL_PATH: string = './functions/skeet/src/models'
static readonly MODEL_PATH: string = './common/models'
static readonly FUNCTION_ROOT = './functions'
aiInstance: VertexAI | OpenAI

Expand Down
2 changes: 1 addition & 1 deletion src/lib/skeetai/method/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ This output will be used as typescript .ts file, so you must not include any oth
},
{
input: 'Get User Data from Firestore.',
output: `import { User, UserCN } from '@/models/userModels'
output: `import { User, UserCN } from '@common/models/userModels'
import { get } from '@skeet-framework/firestore'
import * as admin from 'firebase-admin'
Expand Down

0 comments on commit d987cf5

Please sign in to comment.