fix: put types

feat/type-attributes
Tomáš Mládek 2023-04-25 19:57:15 +02:00
parent d2d9ebe54a
commit 9923716691
4 changed files with 17 additions and 10 deletions

View File

@ -48,9 +48,16 @@ export type InAddress =
| Address
| { t: "Attribute" | "Url" | "Uuid"; c?: string };
export type InEntry =
| IEntry
| IEntry[]
export type InEntry = {
entity: Address;
attribute: string;
value: IValue;
provenance?: string;
};
export type PutInput =
| InEntry
| InEntry[]
| InvariantEntry
| { entity: InAddress };

View File

@ -3,7 +3,7 @@ import { UpListing, UpObject } from "upend";
import type {
Address,
IJob,
InEntry,
PutInput,
IValue,
ListingResult,
PutResult,
@ -59,11 +59,11 @@ export async function queryOnce(query: string): Promise<UpListing> {
}
}
export async function putEntry(entry: InEntry): Promise<PutResult> {
export async function putEntry(input: PutInput): Promise<PutResult> {
const response = await fetch(`${API_URL}/obj`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(entry),
body: JSON.stringify(input),
});
return await response.json();

View File

@ -1,4 +1,4 @@
import type { InEntry } from "upend/types";
import type { PutInput } from "upend/types";
import { putEntry, queryOnce } from "../lib/api";
import { query as queryFn } from "../lib/entity";
@ -15,7 +15,7 @@ export function baseSearchOnce(query: string) {
}
export async function createLabelled(label: string) {
let body: InEntry;
let body: PutInput;
if (label.match("^[\\w]+://[\\w]")) {
body = {
entity: {

View File

@ -12560,8 +12560,8 @@ __metadata:
"upend@file:../tools/upend_js::locator=upend-kestrel%40workspace%3A.":
version: 0.0.1
resolution: "upend@file:../tools/upend_js#../tools/upend_js::hash=af6a68&locator=upend-kestrel%40workspace%3A."
checksum: b8899b7aa5ba3a398001d0a3ab2d7e3e5d09801da5a1e522787fc609dfe4358fa8aad4323870cb1d59766b69f5b438d26af44ad942fcf5d603653cd272937bbb
resolution: "upend@file:../tools/upend_js#../tools/upend_js::hash=4c6736&locator=upend-kestrel%40workspace%3A."
checksum: 65175c69f6281820b0b6072a3c2e3d7c4705b7f158f68d9934dfe091b0da5c21ad02f01b5c90469196486b7cc7929bd3cf993b03b58b9f21b7527abcd7fedcf6
languageName: node
linkType: hard