Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] Update npm packages #1002 #1003

Merged
merged 2 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agdb_api/typescript/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"tabWidth": 4,
"printWidth": 100
"endOfLine": "auto"
}
846 changes: 480 additions & 366 deletions agdb_api/typescript/package-lock.json

Large diffs are not rendered by default.

116 changes: 90 additions & 26 deletions agdb_api/typescript/src/query_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import type { Components } from "./schema";
type QueryId = number | string;

function intoQueryIds(
ids: QueryId[] | Components.Schemas.QueryType | Components.Schemas.QueryResult,
ids:
| QueryId[]
| Components.Schemas.QueryType
| Components.Schemas.QueryResult,
): Components.Schemas.QueryIds {
if ("Search" in ids) {
return ids;
Expand Down Expand Up @@ -35,12 +38,16 @@ class InsertNodesAliasesBuilder {
this.data = data;
}

values_uniform(values: Components.Schemas.DbKeyValue[]): InsertNodesValuesBuilder {
values_uniform(
values: Components.Schemas.DbKeyValue[],
): InsertNodesValuesBuilder {
this.data.values = { Single: values };
return new InsertNodesValuesBuilder(this.data);
}

values(values: Components.Schemas.DbKeyValue[][]): InsertNodesValuesBuilder {
values(
values: Components.Schemas.DbKeyValue[][],
): InsertNodesValuesBuilder {
this.data.values = { Multi: values };
return new InsertNodesValuesBuilder(this.data);
}
Expand Down Expand Up @@ -73,12 +80,16 @@ class InsertNodesBuilder {
return new InsertNodesCountBuilder(this.data);
}

values_uniform(values: Components.Schemas.DbKeyValue[]): InsertNodesValuesBuilder {
values_uniform(
values: Components.Schemas.DbKeyValue[],
): InsertNodesValuesBuilder {
this.data.values = { Single: values };
return new InsertNodesValuesBuilder(this.data);
}

values(values: Components.Schemas.DbKeyValue[][]): InsertNodesValuesBuilder {
values(
values: Components.Schemas.DbKeyValue[][],
): InsertNodesValuesBuilder {
this.data.values = { Multi: values };
return new InsertNodesValuesBuilder(this.data);
}
Expand All @@ -91,7 +102,9 @@ class InsertNodesCountBuilder {
this.data = data;
}

values_uniform(values: Components.Schemas.DbKeyValue[]): InsertNodesValuesBuilder {
values_uniform(
values: Components.Schemas.DbKeyValue[],
): InsertNodesValuesBuilder {
this.data.values = { Single: values };
return new InsertNodesValuesBuilder(this.data);
}
Expand Down Expand Up @@ -132,12 +145,16 @@ class InsertEdgesToEachBuilder {
this.data = query;
}

values(values: Components.Schemas.DbKeyValue[][]): InsertEdgesValuesBuilder {
values(
values: Components.Schemas.DbKeyValue[][],
): InsertEdgesValuesBuilder {
this.data.values = { Multi: values };
return new InsertEdgesValuesBuilder(this.data);
}

values_uniform(values: Components.Schemas.DbKeyValue[]): InsertEdgesValuesBuilder {
values_uniform(
values: Components.Schemas.DbKeyValue[],
): InsertEdgesValuesBuilder {
this.data.values = { Single: values };
return new InsertEdgesValuesBuilder(this.data);
}
Expand All @@ -159,12 +176,16 @@ class InsertEdgesToBuilder {
return new InsertEdgesToEachBuilder(this.data);
}

values(values: Components.Schemas.DbKeyValue[][]): InsertEdgesValuesBuilder {
values(
values: Components.Schemas.DbKeyValue[][],
): InsertEdgesValuesBuilder {
this.data.values = { Multi: values };
return new InsertEdgesValuesBuilder(this.data);
}

values_uniform(values: Components.Schemas.DbKeyValue[]): InsertEdgesValuesBuilder {
values_uniform(
values: Components.Schemas.DbKeyValue[],
): InsertEdgesValuesBuilder {
this.data.values = { Single: values };
return new InsertEdgesValuesBuilder(this.data);
}
Expand All @@ -182,7 +203,10 @@ class InsertEdgesFromBuilder {
}

to(
ids: QueryId[] | Components.Schemas.QueryType | Components.Schemas.QueryResult,
ids:
| QueryId[]
| Components.Schemas.QueryType
| Components.Schemas.QueryResult,
): InsertEdgesToBuilder {
this.data.to = intoQueryIds(ids);
return new InsertEdgesToBuilder(this.data);
Expand All @@ -202,7 +226,10 @@ class InsertEdgesBuilder {
}

from(
ids: QueryId[] | Components.Schemas.QueryType | Components.Schemas.QueryResult,
ids:
| QueryId[]
| Components.Schemas.QueryType
| Components.Schemas.QueryResult,
): InsertEdgesFromBuilder {
this.data.from = intoQueryIds(ids);
return new InsertEdgesFromBuilder(this.data);
Expand All @@ -229,7 +256,10 @@ class InsertAliasesBuilder {
}

ids(
ids: QueryId[] | Components.Schemas.QueryType | Components.Schemas.QueryResult,
ids:
| QueryId[]
| Components.Schemas.QueryType
| Components.Schemas.QueryResult,
): InsertAliasesIdsBuilder {
this.data.ids = intoQueryIds(ids);
return new InsertAliasesIdsBuilder(this.data);
Expand All @@ -256,7 +286,10 @@ class InsertValuesBuilder {
}

ids(
ids: QueryId[] | Components.Schemas.QueryType | Components.Schemas.QueryResult,
ids:
| QueryId[]
| Components.Schemas.QueryType
| Components.Schemas.QueryResult,
): InsertValuesIdsBuilder {
this.data.ids = intoQueryIds(ids);
return new InsertValuesIdsBuilder(this.data);
Expand Down Expand Up @@ -388,7 +421,10 @@ class RemoveValuesBuilder {
}

ids(
ids: QueryId[] | Components.Schemas.QueryType | Components.Schemas.QueryResult,
ids:
| QueryId[]
| Components.Schemas.QueryType
| Components.Schemas.QueryResult,
): RemoveValuesIdsBuilder {
this.data.ids = intoQueryIds(ids);
return new RemoveValuesIdsBuilder(this.data);
Expand All @@ -413,7 +449,10 @@ class RemoveBuilder {
}

ids(
ids: QueryId[] | Components.Schemas.QueryType | Components.Schemas.QueryResult,
ids:
| QueryId[]
| Components.Schemas.QueryType
| Components.Schemas.QueryResult,
): RemoveIdsBuilder {
if (Array.isArray(ids)) {
return new RemoveIdsBuilder(intoQueryIds(ids));
Expand Down Expand Up @@ -453,7 +492,10 @@ class SelectAliasesBuilder {
}

ids(
ids: QueryId[] | Components.Schemas.QueryType | Components.Schemas.QueryResult,
ids:
| QueryId[]
| Components.Schemas.QueryType
| Components.Schemas.QueryResult,
): SelectAliasesIdsBuilder {
if (Array.isArray(ids)) {
return new SelectAliasesIdsBuilder(intoQueryIds(ids));
Expand Down Expand Up @@ -499,7 +541,10 @@ class SelectValuesBuilder {
}

ids(
ids: QueryId[] | Components.Schemas.QueryType | Components.Schemas.QueryResult,
ids:
| QueryId[]
| Components.Schemas.QueryType
| Components.Schemas.QueryResult,
): SelectValuesIdsBuilder {
this.data.ids = intoQueryIds(ids);
return new SelectValuesIdsBuilder(this.data);
Expand All @@ -526,7 +571,10 @@ class SelectKeysBuilder {
}

ids(
ids: QueryId[] | Components.Schemas.QueryType | Components.Schemas.QueryResult,
ids:
| QueryId[]
| Components.Schemas.QueryType
| Components.Schemas.QueryResult,
): SelectKeysIdsBuilder {
this.data = intoQueryIds(ids);
return new SelectKeysIdsBuilder(this.data);
Expand All @@ -553,7 +601,10 @@ class SelectKeyCountBuilder {
}

ids(
ids: QueryId[] | Components.Schemas.QueryType | Components.Schemas.QueryResult,
ids:
| QueryId[]
| Components.Schemas.QueryType
| Components.Schemas.QueryResult,
): SelectKeyCountIdsBuilder {
this.data = intoQueryIds(ids);
return new SelectKeyCountIdsBuilder(this.data);
Expand All @@ -572,7 +623,10 @@ class SelectBuilder {
}

ids(
ids: QueryId[] | Components.Schemas.QueryType | Components.Schemas.QueryResult,
ids:
| QueryId[]
| Components.Schemas.QueryType
| Components.Schemas.QueryResult,
): SelectIdsBuilder {
return new SelectIdsBuilder(intoQueryIds(ids));
}
Expand All @@ -594,7 +648,9 @@ class SelectBuilder {
}
}

function collapse_conditions(conditions: Components.Schemas.QueryCondition[][]): boolean {
function collapse_conditions(
conditions: Components.Schemas.QueryCondition[][],
): boolean {
if (conditions.length > 1) {
let last = conditions.pop();
let current = conditions[conditions.length - 1];
Expand Down Expand Up @@ -683,7 +739,9 @@ class SearchWhereBuilder {
return this;
}

distance(distance: Components.Schemas.CountComparison): SearchWhereLogicBuilder {
distance(
distance: Components.Schemas.CountComparison,
): SearchWhereLogicBuilder {
return push_condition(this, {
data: { Distance: distance },
logic: this.logic,
Expand All @@ -699,23 +757,29 @@ class SearchWhereBuilder {
});
}

edge_count(count: Components.Schemas.CountComparison): SearchWhereLogicBuilder {
edge_count(
count: Components.Schemas.CountComparison,
): SearchWhereLogicBuilder {
return push_condition(this, {
data: { EdgeCount: count },
logic: this.logic,
modifier: this.modifier,
});
}

edge_count_from(count: Components.Schemas.CountComparison): SearchWhereLogicBuilder {
edge_count_from(
count: Components.Schemas.CountComparison,
): SearchWhereLogicBuilder {
return push_condition(this, {
data: { EdgeCountFrom: count },
logic: this.logic,
modifier: this.modifier,
});
}

edge_count_to(count: Components.Schemas.CountComparison): SearchWhereLogicBuilder {
edge_count_to(
count: Components.Schemas.CountComparison,
): SearchWhereLogicBuilder {
return push_condition(this, {
data: { EdgeCountTo: count },
logic: this.logic,
Expand Down
4 changes: 3 additions & 1 deletion agdb_api/typescript/tests/InsertElements.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ describe("insert elements", () => {
name: "John",
age: 30,
};
expect(() => QueryBuilder.insert().elements([e]).query()).toThrowError("invalid db_id");
expect(() => QueryBuilder.insert().elements([e]).query()).toThrowError(
"invalid db_id",
);
});
});
16 changes: 13 additions & 3 deletions agdb_api/typescript/tests/OpenApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ import { AgdbApi } from "../src/index";
describe("openapi test", () => {
it("insert nodes with edges", async () => {
let client = await AgdbApi.client("http://localhost", 3000);
let admin_token = await client.user_login(null, { username: "admin", password: "admin" });
let admin_token = await client.user_login(null, {
username: "admin",
password: "admin",
});
AgdbApi.setToken(admin_token.data);

await client.admin_user_add("user1", { password: "password123" });
let token = await client.user_login(null, { username: "user1", password: "password123" });
let token = await client.user_login(null, {
username: "user1",
password: "password123",
});
AgdbApi.setToken(token.data);

await client.db_add({
Expand All @@ -26,7 +32,11 @@ describe("openapi test", () => {
expect(res.status).toEqual(200);

let res2 = await client.db_exec({ owner: "user1", db: "db1" }, [
QueryBuilder.insert().edges().from(["alias"]).to(res.data[1]).query(),
QueryBuilder.insert()
.edges()
.from(["alias"])
.to(res.data[1])
.query(),
]);

expect(res2.status).toEqual(200);
Expand Down
4 changes: 3 additions & 1 deletion agdb_api/typescript/tests/Remove.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ describe("remove", () => {
});

it("remove ids - nested queries", () => {
QueryBuilder.remove().ids(QueryBuilder.search().from(1).query()).query();
QueryBuilder.remove()
.ids(QueryBuilder.search().from(1).query())
.query();
});
});
Loading