Skip to content
Open
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
24,045 changes: 23,984 additions & 61 deletions client/package-lock.json

Large diffs are not rendered by default.

2,957 changes: 1,714 additions & 1,243 deletions demo/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dev": "NODE_ENV=development DEVCLIENT=true nodemon --watch ../typings --watch ./ --watch ../src --ext ts,json --exec npx ts-node --files server/server.ts"
},
"dependencies": {
"@cotype/local-thumbnail-provider": "0.0.2",
"@cotype/local-thumbnail-provider": "git+https://github.com/saifookhan/local-thumbnail-provider.git",
"got": "^11.1.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions demo/server/reinit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { log } from "../../src";
import { Opts, knexAdapter } from "../../src";
import { KnexConfig } from "../../src/persistence/adapter/knex";
import { unlinkSync } from "fs";
import { Sqlite3ConnectionConfig } from "knex";
import { Knex } from "knex";

export type ReinitOpts = {
config?: Partial<Opts>;
Expand All @@ -31,7 +31,7 @@ function getJsonBody(req: IncomingMessage) {
function isSqlite3ConnectionConfig(
connection: KnexConfig["connection"],
client: KnexConfig["client"]
): connection is Sqlite3ConnectionConfig {
): connection is Knex.Sqlite3ConnectionConfig {
return client === "sqlite3";
}

Expand Down
20,088 changes: 0 additions & 20,088 deletions package-lock.json

This file was deleted.

36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"clean": "rm -rf ./dist && rm -rf ./lib",
"reinit": "rm -rf node_modules; rm -rf demo/node_modules; rm demo/dev_db; rm -rf client/node-modules; npm i",
"reinit:yarn": "rm -rf node_modules; rm -rf demo/node_modules; rm demo/dev_db; rm -rf client/node-modules; yarn install",
"prepare": "concurrently npm:install:client npm:install:demo npm:schema",
"install:client": "npm --prefix client i",
"install:demo": "npm --prefix demo i",
Expand Down Expand Up @@ -49,34 +50,34 @@
"crypto-random-string": "^3.2.0",
"express": "^4.17.1",
"express-promise-router": "^3.0.3",
"file-type": "^14.3.0",
"file-type": "^18.4.0",
"fs-extra": "^9.0.0",
"glob-promise": "^3.4.0",
"got": "^11.1.1",
"graphql": "^15.0.0",
"hasha": "^5.2.0",
"http-proxy-middleware": "1.0.3",
"image-size": "^0.8.3",
"knex": "^0.21.1",
"knex": "^2.4.0",
"lodash": "^4.17.15",
"mdi-json": "^1.0.0",
"mudder": "^1.0.9",
"multer": "^1.4.2",
"multer": "^1.4.4-lts.1",
"openapi3-ts": "^1.3.0",
"pg-monitor": "^1.4.0",
"pluralize": "^8.0.0",
"probe-image-size": "^5.0.0",
"probe-image-size": "^7.2.3",
"quill": "^1.3.7",
"quill-delta-to-html": "^0.11.0",
"swagger-ui-dist": "^3.25.2",
"swagger-ui-dist": "^4.18.3",
"temp-write": "^4.0.0",
"tempy": "^0.5.0",
"title-case": "^3.0.2",
"url-join": "^4.0.1",
"webpack": "^4.43.0"
"webpack": "^5.83.1"
},
"devDependencies": {
"@cotype/local-thumbnail-provider": "0.0.2",
"@cotype/local-thumbnail-provider": "git+https://github.com/saifookhan/local-thumbnail-provider.git",
"@types/bcryptjs": "2.4.2",
"@types/cookie": "^0.3.3",
"@types/cookie-session": "^2.0.39",
Expand All @@ -94,34 +95,33 @@
"@types/swagger-ui-dist": "^3.0.5",
"@types/tough-cookie": "^4.0.0",
"@types/url-join": "^4.0.0",
"@xiphe/cypress-parcel-preprocessor": "1.0.1-RC.1",
"codecov": "3.6.5",
"codecov": "^3.8.3",
"concurrently": "^5.2.0",
"cypress": "^3.8.3",
"cypress-file-upload": "^3.3.4",
"decorate-gh-pr": "1.2.3",
"cypress": "^12.12.0",
"cypress-file-upload": "^5.0.8",
"decorate-gh-pr": "^1.5.4",
"faker": "^4.1.0",
"get-port-cli": "^2.0.0",
"get-port-cli": "^3.0.0",
"install": "^0.13.0",
"jest": "^26.0.1",
"mysql": "^2.18.1",
"pg": "^8.0.3",
"prettier": "^2.0.5",
"qs": "^6.9.4",
"semantic-release": "17.0.7",
"semantic-release": "^17.4.5",
"semantish-prerelease": "3.1.1",
"sharp": "0.23.1",
"sharp": "^0.31",
"source-map-support": "^0.5.19",
"sqlite3": "^4.2.0",
"supertest": "^4.0.2",
"tough-cookie": "^4.0.0",
"ts-jest": "^25.5.1",
"ts-jest": "^26.0.1",
"ts-loader": "^7.0.4",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0",
"tslint-react": "^5.0.0",
"typescript": "^3.8.3",
"typescript-json-schema": "^0.42.0",
"typescript": "^4.9.5",
"typescript-json-schema": "^0.56.0",
"wait-for-expect": "^3.0.2",
"with-server": "^1.1.0"
},
Expand Down
158 changes: 89 additions & 69 deletions src/content/rest/__tests__/restApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ describe("rest api", () => {
"admin"
));

({ find, list, search, findByField, suggest } = createApiReadHelpers(
server
));
({ find, list, search, findByField, suggest } =
createApiReadHelpers(server));
({ create, update } = createApiWriteHelpers(server, headers));

const mediaBuffer = Buffer.from(faker.lorem.paragraphs(), "utf8");
Expand Down Expand Up @@ -145,10 +144,10 @@ describe("rest api", () => {
credit: null,
focusX: null,
focusY: null,
height: null,
// height: null,
search: ` ${mediaFile.originalname}`,
tags: null,
width: null,
// width: null,
...mediaFile
}
};
Expand Down Expand Up @@ -203,45 +202,55 @@ describe("rest api", () => {
});

await expect(
(await list(
"news",
{ search: { term: "foo-new-t", scope: "title" } },
false
)).total
(
await list(
"news",
{ search: { term: "foo-new-t", scope: "title" } },
false
)
).total
).toBe(1);

await expect(
(await list(
"news",
{ search: { term: "lololor", scope: "global" } },
false
)).total
(
await list(
"news",
{ search: { term: "lololor", scope: "global" } },
false
)
).total
).toBe(1);
});

it("should not list news with wrong search criteria", async () => {
await expect(
(await list(
"news",
{ search: { term: "lololor", scope: "title" } },
false
)).total
(
await list(
"news",
{ search: { term: "lololor", scope: "title" } },
false
)
).total
).toBe(0);

await expect(
(await list(
"news",
{ search: { term: "foo-new-txx", scope: "title" } },
false
)).total
(
await list(
"news",
{ search: { term: "foo-new-txx", scope: "title" } },
false
)
).total
).toBe(0);

await expect(
(await list(
"news",
{ search: { term: "lololor-xx", scope: "global" } },
false
)).total
(
await list(
"news",
{ search: { term: "lololor-xx", scope: "global" } },
false
)
).total
).toBe(0);
});

Expand Down Expand Up @@ -524,59 +533,73 @@ describe("rest api", () => {

it("results should contain description", async () => {
await expect(
(await search(description, {
published: false,
linkableOnly: false,
includeModels: ["news"]
})).items[0]
(
await search(description, {
published: false,
linkableOnly: false,
includeModels: ["news"]
})
).items[0]
).toMatchObject({ description });
});

it("should find only linkable content by search", async () => {
await expect(
(await search(searchForAllContent, {
published: false,
linkableOnly: true
})).total
(
await search(searchForAllContent, {
published: false,
linkableOnly: true
})
).total
).toBe(2);
});

it("should find limited content by search", async () => {
await expect(
(await search(searchForAllContent, {
published: false,
linkableOnly: true,
includeModels: ["products"]
})).total
(
await search(searchForAllContent, {
published: false,
linkableOnly: true,
includeModels: ["products"]
})
).total
).toBe(1);
await expect(
(await search(searchForAllContent, {
published: false,
linkableOnly: true,
includeModels: ["news"]
})).total
(
await search(searchForAllContent, {
published: false,
linkableOnly: true,
includeModels: ["news"]
})
).total
).toBe(1);
await expect(
(await search(searchForAllContent, {
published: false,
linkableOnly: true,
excludeModels: ["news", "products"]
})).total
(
await search(searchForAllContent, {
published: false,
linkableOnly: true,
excludeModels: ["news", "products"]
})
).total
).toBe(0);
await expect(
(await search(searchForProduct, {
published: false,
linkableOnly: true,
excludeModels: ["products"]
})).total
(
await search(searchForProduct, {
published: false,
linkableOnly: true,
excludeModels: ["products"]
})
).total
).toBe(0);
await expect(
(await search(searchForNews, {
published: false,
linkableOnly: true,
includeModels: ["news"],
excludeModels: ["products"]
})).total
(
await search(searchForNews, {
published: false,
linkableOnly: true,
includeModels: ["news"],
excludeModels: ["products"]
})
).total
).toBe(1);
});

Expand Down Expand Up @@ -632,10 +655,7 @@ describe("rest api", () => {
}
);
await expect(res).toMatchObject([
searchForNews
.split(" ")
.slice(0, 2)
.join(" ")
searchForNews.split(" ").slice(0, 2).join(" ")
]);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/media/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Models, ThumbnailProvider } from "../../typings";
import express, { Router } from "express";
import express, { Router, Request } from "express";
import { OpenApiBuilder } from "openapi3-ts";
import { Persistence } from "../persistence";
import routes from "./routes";
Expand All @@ -25,7 +25,7 @@ export default function media(
if (storage instanceof FsStorage) {
router.use("/media", express.static(storage.uploadDir));
}
router.get("/thumbs/:format/*", async (req, res) => {
router.get("/thumbs/:format/*", async (req: Request, res) => {
const { format } = req.params;
const id = req.params["0"];
try {
Expand Down
8 changes: 4 additions & 4 deletions src/media/inspect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import probe from "probe-image-size";
import fileType from "file-type";
import { fileTypeFromStream } from "file-type";
import { Readable } from "stream";
import hasha from "hasha";

Expand All @@ -19,7 +19,7 @@ const inspect = async (
readableStream.wrap(fileStream);

const [pipedFileStream, hash] = await Promise.all([
fileType.stream(readableStream),
fileTypeFromStream(readableStream),
hasha.fromFile(filePath, {
algorithm: "md5"
})
Expand All @@ -32,13 +32,13 @@ const inspect = async (
ext: null,
mime: null
};
if (!pipedFileStream || !pipedFileStream.fileType) {
if (!pipedFileStream || !pipedFileStream.mime) {
return fileImageInfo;
}

fileImageInfo = {
...fileImageInfo,
...pipedFileStream.fileType
...pipedFileStream
};
if (fileImageInfo.mime!.startsWith("image")) {
const imageInfo = await probe(pipedFileStream);
Expand Down
Loading