@carddb/core 0.4.6 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +77 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -1
- package/dist/index.d.ts +29 -1
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -499,6 +499,22 @@ var SCHEMA_FIELDS = `
|
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
501
|
`;
|
|
502
|
+
var DATASET_FILTER_VALUE_CONNECTION_FIELDS = `
|
|
503
|
+
field
|
|
504
|
+
edges {
|
|
505
|
+
cursor
|
|
506
|
+
node {
|
|
507
|
+
value
|
|
508
|
+
count
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
pageInfo {
|
|
512
|
+
hasNextPage
|
|
513
|
+
hasPreviousPage
|
|
514
|
+
startCursor
|
|
515
|
+
endCursor
|
|
516
|
+
}
|
|
517
|
+
`;
|
|
502
518
|
var OBJECT_FIELD_FIELDS = `
|
|
503
519
|
id
|
|
504
520
|
objectTypeId
|
|
@@ -1880,6 +1896,67 @@ var QueryBuilder = {
|
|
|
1880
1896
|
`
|
|
1881
1897
|
};
|
|
1882
1898
|
},
|
|
1899
|
+
fetchDatasetFilterValues(params) {
|
|
1900
|
+
if (params.fields.length === 0) {
|
|
1901
|
+
throw new ValidationError("fields must contain at least one field key");
|
|
1902
|
+
}
|
|
1903
|
+
const byId = params.id !== void 0;
|
|
1904
|
+
const byKeys = params.publisherSlug !== void 0 && params.gameKey !== void 0 && params.datasetKey !== void 0;
|
|
1905
|
+
if (!byId && !byKeys) {
|
|
1906
|
+
throw new ValidationError("provide either id or publisherSlug, gameKey, and datasetKey");
|
|
1907
|
+
}
|
|
1908
|
+
const definitions = ["$fields: [String!]!"];
|
|
1909
|
+
const filterValueArgs = ["fields: $fields"];
|
|
1910
|
+
const variables = { fields: params.fields };
|
|
1911
|
+
if (params.search !== void 0) {
|
|
1912
|
+
definitions.push("$search: String");
|
|
1913
|
+
filterValueArgs.push("search: $search");
|
|
1914
|
+
variables["search"] = params.search;
|
|
1915
|
+
}
|
|
1916
|
+
if (params.includeCounts !== void 0) {
|
|
1917
|
+
definitions.push("$includeCounts: Boolean");
|
|
1918
|
+
filterValueArgs.push("includeCounts: $includeCounts");
|
|
1919
|
+
variables["includeCounts"] = params.includeCounts;
|
|
1920
|
+
}
|
|
1921
|
+
if (params.first !== void 0) {
|
|
1922
|
+
definitions.push("$first: Int");
|
|
1923
|
+
filterValueArgs.push("first: $first");
|
|
1924
|
+
variables["first"] = params.first;
|
|
1925
|
+
}
|
|
1926
|
+
if (params.after !== void 0) {
|
|
1927
|
+
definitions.push("$after: String");
|
|
1928
|
+
filterValueArgs.push("after: $after");
|
|
1929
|
+
variables["after"] = params.after;
|
|
1930
|
+
}
|
|
1931
|
+
const datasetArgs = [];
|
|
1932
|
+
if (byId) {
|
|
1933
|
+
definitions.push("$id: UUID!");
|
|
1934
|
+
datasetArgs.push("id: $id");
|
|
1935
|
+
variables["id"] = params.id;
|
|
1936
|
+
} else {
|
|
1937
|
+
definitions.push("$publisherSlug: String!", "$gameKey: String!", "$datasetKey: String!");
|
|
1938
|
+
datasetArgs.push(
|
|
1939
|
+
"publisherSlug: $publisherSlug",
|
|
1940
|
+
"gameKey: $gameKey",
|
|
1941
|
+
"datasetKey: $datasetKey"
|
|
1942
|
+
);
|
|
1943
|
+
variables["publisherSlug"] = params.publisherSlug;
|
|
1944
|
+
variables["gameKey"] = params.gameKey;
|
|
1945
|
+
variables["datasetKey"] = params.datasetKey;
|
|
1946
|
+
}
|
|
1947
|
+
return {
|
|
1948
|
+
query: `
|
|
1949
|
+
query FetchDatasetFilterValues(${definitions.join(", ")}) {
|
|
1950
|
+
fetchDataset(${datasetArgs.join(", ")}) {
|
|
1951
|
+
filterValues(${filterValueArgs.join(", ")}) {
|
|
1952
|
+
${DATASET_FILTER_VALUE_CONNECTION_FIELDS}
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
`,
|
|
1957
|
+
variables
|
|
1958
|
+
};
|
|
1959
|
+
},
|
|
1883
1960
|
listDatasets(params) {
|
|
1884
1961
|
const variables = { publisherId: params.publisherId };
|
|
1885
1962
|
const args = ["publisherId: $publisherId"];
|