Skip to content

Commit

Permalink
create separate normalize function
Browse files Browse the repository at this point in the history
  • Loading branch information
elizamaria committed Nov 16, 2023
1 parent e789780 commit 5658d6e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dist/caisy.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 13 additions & 10 deletions dist/caisy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const l = (e, t) => {
)}`
);
return t;
}, w = async (e) => {
}, A = async (e) => {
const { projectId: t, query: s } = e, r = d(t), n = await fetch(r, {
method: "POST",
headers: {
Expand Down Expand Up @@ -144,7 +144,7 @@ const l = (e, t) => {
page: i.toString(),
after: j
});
}, A = async (e) => {
}, E = async (e) => {
const { projectId: t, query: s } = e, r = d(t), n = await fetch(r, {
method: "POST",
headers: {
Expand All @@ -154,23 +154,26 @@ const l = (e, t) => {
body: JSON.stringify({
query: s
})
}), a = await g(n);
let o = a.data[Object.keys(a.data)[0]];
return o = {
}), a = await g(n), o = a.data[Object.keys(a.data)[0]];
return w(o);
}, w = (e) => {
const t = {
pageInfo: {},
edges: [
{
node: { ...o }
node: { ...e }
}
]
}, l(o);
};
return l(t);
};
export {
w as getEntities,
A as getEntities,
P as getEntitiesWithPagination,
_ as getEntityByAttribute,
A as getSingleEntityType,
E as getSingleEntityType,
O as normalizeCaisyAssetData,
C as normalizeCaisyItemContent,
l as normalizeCaisyListContent
l as normalizeCaisyListContent,
w as normalizeSingleTypeAsList
};
3 changes: 2 additions & 1 deletion dist/caisy/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export { getEntitiesData as getEntities } from './entities';
export { getDataByAttribute as getEntityByAttribute } from "./entityByAttribute";
export { getEntitiesByPage as getEntitiesWithPagination } from "./entitiesByPage";
export { getSingleEntity as getSingleEntityType } from "./singleEntity";
export { normalizeList as normalizeCaisyListContent } from "./utils";
export { normalizeItem as normalizeCaisyItemContent } from "./utils";
export { normalizeAssetData as normalizeCaisyAssetData } from "./utils";
export { getSingleEntity as getSingleEntityType } from "./singleEntity";
export { normalizeSingleTypeAsList as normalizeSingleTypeAsList } from "./singleEntity";
//# sourceMappingURL=index.d.ts.map
2 changes: 1 addition & 1 deletion dist/caisy/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/caisy/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
export { getEntitiesData as getEntities } from './entities'
export { getDataByAttribute as getEntityByAttribute } from "./entityByAttribute";
export { getEntitiesByPage as getEntitiesWithPagination } from "./entitiesByPage";
export { getSingleEntity as getSingleEntityType } from "./singleEntity";

export { normalizeList as normalizeCaisyListContent } from "./utils";
export { normalizeItem as normalizeCaisyItemContent } from "./utils";
export { normalizeAssetData as normalizeCaisyAssetData } from "./utils";
export { getSingleEntity as getSingleEntityType } from "./singleEntity";
export { normalizeSingleTypeAsList as normalizeSingleTypeAsList } from "./singleEntity";


11 changes: 8 additions & 3 deletions src/caisy/singleEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ export const getSingleEntity = async (params: { projectId: string; query: string
})

const responseJSON = await handleFetchResponse(response)
let responseData = responseJSON.data[Object.keys(responseJSON.data)[0]]
const responseData = responseJSON.data[Object.keys(responseJSON.data)[0]]

responseData = {
return normalizeSingleTypeAsList(responseData)
}

export const normalizeSingleTypeAsList = (input: any) => {

Check warning on line 24 in src/caisy/singleEntity.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
// here we are builing the response similar to a get list of entities response, in order to use the same normalize function
const responseData = {
pageInfo: {},
edges: [
{
node: { ...responseData },
node: { ...input },
},
],
}
Expand Down

0 comments on commit 5658d6e

Please sign in to comment.