-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from tigrisdata/main
Beta release
- Loading branch information
Showing
13 changed files
with
307 additions
and
9 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
export const NotSchema = { key: "value" }; |
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 @@ | ||
import { | ||
TigrisCollectionType, | ||
TigrisDataTypes, | ||
TigrisSchema | ||
} from '../../../../types' | ||
|
||
export interface Product extends TigrisCollectionType { | ||
id?: number; | ||
title: string; | ||
description: string; | ||
price: number; | ||
} | ||
|
||
export const ProductSchema: TigrisSchema<Product> = { | ||
id: { | ||
type: TigrisDataTypes.INT32, | ||
primary_key: { order: 1, autoGenerate: true } | ||
}, | ||
title: { type: TigrisDataTypes.STRING }, | ||
description: { type: TigrisDataTypes.STRING }, | ||
price: { type: TigrisDataTypes.NUMBER } | ||
} |
Empty file.
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,82 @@ | ||
import { canBeSchema, loadTigrisManifest, TigrisManifest } from "../../utils/manifest-loader"; | ||
import { TigrisDataTypes } from "../../types"; | ||
import { TigrisFileNotFoundError } from "../../error"; | ||
|
||
describe("Manifest loader", () => { | ||
|
||
it("generates manifest from file system", () => { | ||
const schemaPath = process.cwd() + "/src/__tests__/data/models"; | ||
const manifest: TigrisManifest = loadTigrisManifest(schemaPath); | ||
expect(manifest).toHaveLength(2); | ||
|
||
const expected: TigrisManifest = [{ | ||
"dbName": "catalog", | ||
"collections": [{ | ||
"collectionName": "products", | ||
"schema": { | ||
"id": { "type": "int32", "primary_key": { "order": 1, "autoGenerate": true } }, | ||
"title": { "type": "string" }, | ||
"description": { "type": "string" }, | ||
"price": { "type": "number" } | ||
}, | ||
"schemaName": "ProductSchema" | ||
}] | ||
}, { "dbName": "empty", "collections": [] }]; | ||
expect(manifest).toStrictEqual(expected); | ||
}); | ||
|
||
it("throws error for invalid path", () => { | ||
const schemaPath = "/src/__tests__/data/models"; | ||
expect(() => loadTigrisManifest(schemaPath)).toThrow(TigrisFileNotFoundError); | ||
}); | ||
|
||
const validSchemaDefinitions = [ | ||
{ key: { type: "value" } }, | ||
{ | ||
id: { | ||
type: TigrisDataTypes.INT32, | ||
primary_key: { | ||
order: 1, | ||
autoGenerate: true | ||
} | ||
}, | ||
active: { type: TigrisDataTypes.BOOLEAN } | ||
} | ||
]; | ||
test.each(validSchemaDefinitions)( | ||
"identifies valid schema definition %p", | ||
(definition) => { | ||
expect(canBeSchema(definition)).toBeTruthy(); | ||
} | ||
); | ||
|
||
const invalidSchemaDefinitions = [ | ||
{ key: "value" }, | ||
12, | ||
{ | ||
id: { | ||
type: TigrisDataTypes.INT32, | ||
primary_key: { | ||
order: 1, | ||
autoGenerate: true | ||
} | ||
}, | ||
active: false | ||
}, | ||
{ | ||
id: { | ||
key: "value" | ||
} | ||
}, | ||
{ type: "string" }, | ||
undefined, | ||
null | ||
]; | ||
|
||
test.each(invalidSchemaDefinitions)( | ||
"identifies invalid schema definition %p", | ||
(definition) => { | ||
expect(canBeSchema(definition)).toBeFalsy(); | ||
} | ||
); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import chalk from "chalk"; | ||
|
||
class Logger { | ||
private prefixes = { | ||
debug: chalk.green("debug") + " -", | ||
info: chalk.cyan("info") + " -", | ||
warn: chalk.yellow("warn") + " -", | ||
error: chalk.red("error") + " -", | ||
event: chalk.magenta("event") + " -", | ||
}; | ||
|
||
public debug(...message: unknown[]) { | ||
console.log(this.prefixes.debug, ...message); | ||
} | ||
|
||
public info(...message: unknown[]) { | ||
console.log(this.prefixes.info, ...message); | ||
} | ||
|
||
public error(...message: unknown[]) { | ||
console.log(this.prefixes.error, ...message); | ||
} | ||
|
||
public warn(...message: unknown[]) { | ||
console.log(this.prefixes.warn, ...message); | ||
} | ||
|
||
public event(...message: unknown[]) { | ||
console.log(this.prefixes.event, ...message); | ||
} | ||
} | ||
|
||
export const Log = new Logger(); |
Oops, something went wrong.