-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4169c83
commit 1525955
Showing
13 changed files
with
959 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,6 @@ | |
node_modules | ||
oclif.lock | ||
oclif.manifest.json | ||
|
||
code-genie/ | ||
scavenger-hunt-app/ |
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 @@ | ||
experimentalTernaries: true | ||
semi: false | ||
singleQuote: true | ||
printWidth: 180 | ||
printWidth: 160 |
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 |
---|---|---|
@@ -0,0 +1,202 @@ | ||
import util from 'node:util' | ||
import { expect } from '@oclif/test' | ||
import { App, getJsonSchemasFromEntities } from './app-definition-generator.js' | ||
import codeGenieSampleOpenAiOutputJson from './sample-api-output.js' | ||
|
||
describe('main', () => { | ||
it('getJsonSchemasFromEntities returns entity schemas from openai response', () => { | ||
const entitySchemas = getJsonSchemasFromEntities({ app: codeGenieSampleOpenAiOutputJson as unknown as App }) | ||
console.log(util.inspect(entitySchemas, { showHidden: false, depth: null, colors: true })) | ||
expect(entitySchemas).equal([ | ||
{ | ||
entityName: 'App', | ||
fileName: 'app.yaml', | ||
jsonSchema: { | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
title: 'App', | ||
'x-codeGenie': { | ||
idProperty: 'appId', | ||
nameProperty: 'name', | ||
dynamodb: { partitionKey: 'userId', sortKey: 'appId' }, | ||
isRootEntity: true, | ||
hasMany: { | ||
Entity: { $ref: './entity.yaml' }, | ||
Build: { $ref: './build.yaml' }, | ||
}, | ||
}, | ||
allOf: [{ type: 'object', $ref: '#/definitions/attributes' }], | ||
definitions: { | ||
attributes: { | ||
type: 'object', | ||
properties: { | ||
userId: { type: 'string', readOnly: true }, | ||
appId: { type: 'string', readOnly: true }, | ||
name: { type: 'string' }, | ||
description: { type: 'string' }, | ||
logo: { | ||
type: 'string', | ||
contentEncoding: 'base64', | ||
contentMediaType: 'image/png', | ||
}, | ||
primaryBrandColor: { type: 'string' }, | ||
region: { | ||
type: 'enum', | ||
enum: ['us-east-1', 'us-west-2', 'eu-west-1', 'ap-southeast-1', 'ap-northeast-1'], | ||
}, | ||
permissionModel: { | ||
type: 'enum', | ||
enum: ['Global', 'User', 'Organization'], | ||
}, | ||
}, | ||
required: ['appId', 'name'], | ||
additionalProperties: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
entityName: 'Entity', | ||
fileName: 'entity.yaml', | ||
jsonSchema: { | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
title: 'Entity', | ||
'x-codeGenie': { | ||
idProperty: 'entityId', | ||
nameProperty: 'name', | ||
dynamodb: { partitionKey: 'appId', sortKey: 'entityId' }, | ||
hasMany: { | ||
Property: { $ref: './property.yaml' }, | ||
Many: { $ref: './many.yaml' }, | ||
}, | ||
}, | ||
allOf: [{ type: 'object', $ref: '#/definitions/attributes' }], | ||
definitions: { | ||
attributes: { | ||
type: 'object', | ||
properties: { | ||
entityId: { type: 'string', readOnly: true }, | ||
appId: { | ||
type: 'string', | ||
readOnly: true, | ||
'x-codeGenie': { foreignKey: { referencedEntity: 'App' } }, | ||
}, | ||
name: { type: 'string' }, | ||
idProperty: { type: 'string' }, | ||
nameProperty: { type: 'string' }, | ||
imageProperty: { type: 'string' }, | ||
partitionKey: { type: 'string' }, | ||
sortKey: { type: 'string' }, | ||
listView: { type: 'enum', enum: ['Card List', 'Table'] }, | ||
}, | ||
required: ['entityId', 'appId', 'name'], | ||
additionalProperties: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
entityName: 'Property', | ||
fileName: 'property.yaml', | ||
jsonSchema: { | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
title: 'Property', | ||
'x-codeGenie': { | ||
idProperty: 'propertyId', | ||
nameProperty: 'propertyId', | ||
dynamodb: { partitionKey: 'entityId', sortKey: 'propertyId' }, | ||
onCreate: 'REMAIN_ON_CURRENT_PAGE', | ||
buildDetailsPage: false, | ||
}, | ||
allOf: [{ type: 'object', $ref: '#/definitions/attributes' }], | ||
definitions: { | ||
attributes: { | ||
type: 'object', | ||
properties: { | ||
propertyId: { type: 'string', readOnly: true }, | ||
entityId: { | ||
type: 'string', | ||
readOnly: true, | ||
'x-codeGenie': { foreignKey: { referencedEntity: 'Entity' } }, | ||
}, | ||
name: { type: 'string' }, | ||
description: { type: 'string' }, | ||
type: { | ||
type: 'enum', | ||
enum: ['string', 'number', 'integer', 'boolean', 'enum', 'array'], | ||
}, | ||
enum: { type: 'array', items: { type: 'string' }, enum: [] }, | ||
}, | ||
required: ['propertyId', 'entityId'], | ||
additionalProperties: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
entityName: 'Many', | ||
fileName: 'many.yaml', | ||
jsonSchema: { | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
title: 'Many', | ||
'x-codeGenie': { | ||
idProperty: 'manyId', | ||
nameProperty: 'manyId', | ||
dynamodb: { partitionKey: 'entityId', sortKey: 'manyId' }, | ||
onCreate: 'REMAIN_ON_CURRENT_PAGE', | ||
buildDetailsPage: false, | ||
}, | ||
allOf: [{ type: 'object', $ref: '#/definitions/attributes' }], | ||
definitions: { | ||
attributes: { | ||
type: 'object', | ||
properties: { | ||
manyId: { type: 'string', readOnly: true }, | ||
entityId: { | ||
type: 'string', | ||
readOnly: true, | ||
'x-codeGenie': { foreignKey: { referencedEntity: 'Entity' } }, | ||
}, | ||
foreignEntityId: { type: 'string' }, | ||
}, | ||
required: ['manyId', 'entityId'], | ||
additionalProperties: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
entityName: 'Build', | ||
fileName: 'build.yaml', | ||
jsonSchema: { | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
title: 'Build', | ||
'x-codeGenie': { | ||
idProperty: 'buildId', | ||
nameProperty: 'buildId', | ||
dynamodb: { partitionKey: 'appId', sortKey: 'buildId' }, | ||
onCreate: 'REMAIN_ON_CURRENT_PAGE', | ||
buildDetailsPage: false, | ||
}, | ||
allOf: [{ type: 'object', $ref: '#/definitions/attributes' }], | ||
definitions: { | ||
attributes: { | ||
type: 'object', | ||
properties: { | ||
buildId: { type: 'string', readOnly: true }, | ||
appId: { | ||
type: 'string', | ||
readOnly: true, | ||
'x-codeGenie': { foreignKey: { referencedEntity: 'App' } }, | ||
}, | ||
entityId: { type: 'string' }, | ||
buildDateTime: { type: 'string', format: 'date-time' }, | ||
}, | ||
required: ['buildId', 'appId'], | ||
additionalProperties: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
]) | ||
}) | ||
}) |
Oops, something went wrong.