Add precommit hooks (#483)

Adds precommit hooks based on #433 to our repository. Only one file here is new - the configuration for the hooks, everything else is linting/formatting fixes. We do not run the typechecker globally since that would be quite lengthy to clean up - instead we will have to incrementally clean up type check issues as we go.
This commit is contained in:
Hammad Bashir
2023-05-09 22:52:12 -07:00
committed by GitHub
parent 38c99ac268
commit c17249b818
56 changed files with 444 additions and 716 deletions

View File

@@ -1,3 +1,3 @@
dist
node_modules
src/generated
src/generated

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env sh
# curl -s http://localhost:8000/openapi.json | jq > openapi.json
# curl -s http://localhost:8000/openapi.json | jq > openapi.json
curl -s http://localhost:8000/openapi.json | python -c "import sys, json; print(json.dumps(json.load(sys.stdin), indent=2))" > openapi.json
if [[ "$OSTYPE" == "darwin"* ]]; then
@@ -23,4 +23,4 @@ else
sed -i -e '/import "whatwg-fetch";/d' -e 's/window.fetch/fetch/g' src/generated/runtime.ts
fi
rm openapi.json
rm openapi.json

View File

@@ -39,4 +39,4 @@
"genapi": "./genapi.sh",
"prettier": "prettier --write ."
}
}
}

View File

@@ -2,10 +2,10 @@
// tslint:disable
/**
* FastAPI
*
*
*
* OpenAPI spec version: 0.1.0
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
@@ -53,7 +53,7 @@ export const ApiApiFetchParamCreator = function (configuration?: Configuration)
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
@@ -96,7 +96,7 @@ export const ApiApiFetchParamCreator = function (configuration?: Configuration)
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
@@ -139,7 +139,7 @@ export const ApiApiFetchParamCreator = function (configuration?: Configuration)
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
@@ -208,7 +208,7 @@ export const ApiApiFetchParamCreator = function (configuration?: Configuration)
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
@@ -347,7 +347,7 @@ export const ApiApiFetchParamCreator = function (configuration?: Configuration)
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
@@ -462,7 +462,7 @@ export const ApiApiFetchParamCreator = function (configuration?: Configuration)
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
@@ -557,7 +557,7 @@ export const ApiApiFetchParamCreator = function (configuration?: Configuration)
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
@@ -600,7 +600,7 @@ export const ApiApiFetchParamCreator = function (configuration?: Configuration)
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
@@ -643,7 +643,7 @@ export const ApiApiFetchParamCreator = function (configuration?: Configuration)
localVarHeaderParameter.set('Content-Type', 'application/json');
localVarRequestOptions.headers = localVarHeaderParameter;
if (request !== undefined) {
localVarRequestOptions.body = JSON.stringify(request || {});
}
@@ -705,7 +705,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 201) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -735,7 +735,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -765,7 +765,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -794,7 +794,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -823,7 +823,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -852,7 +852,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -881,7 +881,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -910,7 +910,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -940,7 +940,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -968,7 +968,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -990,7 +990,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -1012,7 +1012,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -1035,7 +1035,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -1063,7 +1063,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -1085,7 +1085,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -1109,7 +1109,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -1139,7 +1139,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -1169,7 +1169,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;
@@ -1197,7 +1197,7 @@ export const ApiApiFp = function(configuration?: Configuration) {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
const contentType = response.headers.get('Content-Type');
const mimeType = contentType ? contentType.replace(/;.*/, '') : undefined;
if (response.status === 200) {
if (mimeType === 'application/json') {
return response.json() as any;

View File

@@ -2,10 +2,10 @@
// tslint:disable
/**
* FastAPI
*
*
*
* OpenAPI spec version: 0.1.0
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
@@ -29,14 +29,14 @@ export class Configuration {
apiKey?: string | ((name: string) => string | null);
/**
* parameter for basic security
*
*
* @type {string}
* @memberof Configuration
*/
username?: string;
/**
* parameter for basic security
*
*
* @type {string}
* @memberof Configuration
*/
@@ -50,7 +50,7 @@ export class Configuration {
authorization?: string | ((name: string, scopes?: string[]) => string | null);
/**
* override base path
*
*
* @type {string}
* @memberof Configuration
*/

View File

@@ -2,10 +2,10 @@
// tslint:disable
/**
* FastAPI
*
*
*
* OpenAPI spec version: 0.1.0
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus

View File

@@ -2,10 +2,10 @@
// tslint:disable
/**
* FastAPI
*
*
*
* OpenAPI spec version: 0.1.0
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
@@ -23,7 +23,7 @@ export namespace Api {
ids?: string | Api.AddEmbedding.Ids.ArrayValue[];
'increment_index'?: boolean;
}
/**
* @export
* @namespace AddEmbedding
@@ -31,9 +31,9 @@ export namespace Api {
export namespace AddEmbedding {
export interface Embedding {
}
export type Metadatas = Api.AddEmbedding.Metadatas.ArrayValue[] | Api.AddEmbedding.Metadatas.ObjectValue;
/**
* @export
* @namespace Metadatas
@@ -41,14 +41,14 @@ export namespace Api {
export namespace Metadatas {
export interface ArrayValue {
}
export interface ObjectValue {
}
}
export type Documents = string | Api.AddEmbedding.Documents.ArrayValue[];
/**
* @export
* @namespace Documents
@@ -56,11 +56,11 @@ export namespace Api {
export namespace Documents {
export interface ArrayValue {
}
}
export type Ids = string | Api.AddEmbedding.Ids.ArrayValue[];
/**
* @export
* @namespace Ids
@@ -68,9 +68,9 @@ export namespace Api {
export namespace Ids {
export interface ArrayValue {
}
}
}
export interface ADelete200Response {
@@ -87,7 +87,7 @@ export namespace Api {
metadata?: Api.CreateCollection.Metadata;
'get_or_create'?: boolean;
}
/**
* @export
* @namespace CreateCollection
@@ -95,7 +95,7 @@ export namespace Api {
export namespace CreateCollection {
export interface Metadata {
}
}
export interface CreateCollection200Response {
@@ -112,7 +112,7 @@ export namespace Api {
where?: Api.DeleteEmbedding.Where;
'where_document'?: Api.DeleteEmbedding.WhereDocument;
}
/**
* @export
* @namespace DeleteEmbedding
@@ -120,13 +120,13 @@ export namespace Api {
export namespace DeleteEmbedding {
export interface Id {
}
export interface Where {
}
export interface WhereDocument {
}
}
export interface GetCollection200Response {
@@ -149,7 +149,7 @@ export namespace Api {
offset?: number;
include?: Api.GetEmbedding.IncludeEnum[];
}
/**
* @export
* @namespace GetEmbedding
@@ -157,20 +157,20 @@ export namespace Api {
export namespace GetEmbedding {
export interface Id {
}
export interface Where {
}
export interface WhereDocument {
}
export enum IncludeEnum {
Documents = 'documents',
Embeddings = 'embeddings',
Metadatas = 'metadatas',
Distances = 'distances'
}
}
export interface GetNearestNeighbors200Response {
@@ -200,7 +200,7 @@ export namespace Api {
'n_results'?: number;
include?: Api.QueryEmbedding.IncludeEnum[];
}
/**
* @export
* @namespace QueryEmbedding
@@ -208,20 +208,20 @@ export namespace Api {
export namespace QueryEmbedding {
export interface Where {
}
export interface WhereDocument {
}
export interface QueryEmbedding2 {
}
export enum IncludeEnum {
Documents = 'documents',
Embeddings = 'embeddings',
Metadatas = 'metadatas',
Distances = 'distances'
}
}
export interface RawSql {
@@ -244,7 +244,7 @@ export namespace Api {
'new_name'?: string;
'new_metadata'?: Api.UpdateCollection.NewMetadata;
}
/**
* @export
* @namespace UpdateCollection
@@ -252,7 +252,7 @@ export namespace Api {
export namespace UpdateCollection {
export interface NewMetadata {
}
}
export interface UpdateCollection200Response {
@@ -265,7 +265,7 @@ export namespace Api {
ids?: string | Api.UpdateEmbedding.Ids.ArrayValue[];
'increment_index'?: boolean;
}
/**
* @export
* @namespace UpdateEmbedding
@@ -273,9 +273,9 @@ export namespace Api {
export namespace UpdateEmbedding {
export interface Embedding {
}
export type Metadatas = Api.UpdateEmbedding.Metadatas.ArrayValue[] | Api.UpdateEmbedding.Metadatas.ObjectValue;
/**
* @export
* @namespace Metadatas
@@ -283,14 +283,14 @@ export namespace Api {
export namespace Metadatas {
export interface ArrayValue {
}
export interface ObjectValue {
}
}
export type Documents = string | Api.UpdateEmbedding.Documents.ArrayValue[];
/**
* @export
* @namespace Documents
@@ -298,11 +298,11 @@ export namespace Api {
export namespace Documents {
export interface ArrayValue {
}
}
export type Ids = string | Api.UpdateEmbedding.Ids.ArrayValue[];
/**
* @export
* @namespace Ids
@@ -310,9 +310,9 @@ export namespace Api {
export namespace Ids {
export interface ArrayValue {
}
}
}
export interface Upsert200Response {

View File

@@ -2,10 +2,10 @@
// tslint:disable
/**
* FastAPI
*
*
*
* OpenAPI spec version: 0.1.0
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator+.
* https://github.com/karlvr/openapi-generator-plus
@@ -36,7 +36,7 @@ export const COLLECTION_FORMATS = {
export type FetchAPI = typeof defaultFetch;
/**
*
*
* @export
* @interface FetchArgs
*/
@@ -46,7 +46,7 @@ export interface FetchArgs {
}
/**
*
*
* @export
* @class BaseAPI
*/
@@ -62,7 +62,7 @@ export class BaseAPI {
};
/**
*
*
* @export
* @class RequiredError
* @extends {Error}

View File

@@ -3,4 +3,4 @@ export enum IncludeEnum {
Embeddings = 'embeddings',
Metadatas = 'metadatas',
Distances = 'distances'
}
}

View File

@@ -59,4 +59,4 @@ test('It should return an error when inserting duplicate IDs in the same batch',
} catch (e: any) {
expect(e.message).toMatch('duplicates')
}
})
})

View File

@@ -26,4 +26,4 @@ test('it should upsert embeddings to a collection', async () => {
const count2 = await collection.count()
expect(count2).toBe(3)
})
})