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

Release v1.0.0-alpha.81 #1063

Merged
merged 6 commits into from
Nov 25, 2023
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ services:
environment:
MINIO_ROOT_USER: space-access-key-id
MINIO_ROOT_PASSWORD: space-access-key-secret-id
hostname: fra1.space.liexp.dev
volumes:
- space-data:/data
healthcheck:
Expand All @@ -52,13 +53,14 @@ services:
container_name: liexp-api
env_file:
- ./services/api/.env
# - .env.alpha
# - ./services/api/.env.alpha
environment:
DEBUG: "@liexp*"
DB_HOST: db
DB_PORT: 5432
API_PORT: 4010
DEV_DATA_HOST: http://localhost:9007
API_HOST: api.liexp.dev
hostname: api.liexp.dev
depends_on:
- db
- space
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"pm2": "^5.3.0",
"prettier": "^3.1.0",
"terser": "^5.24.0",
"typescript": "^5.2.2",
"typescript": "^5.3.2",
"vitest": "^0.34.6",
"webpack": "^5.89.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/@liexp/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"puppeteer-extra": "^3.3.6",
"puppeteer-extra-plugin-stealth": "^2.11.2",
"typeorm": "^0.3.17",
"typescript": "^5.2.2"
"typescript": "^5.3.2"
},
"peerDependencies": {
"@react-page/editor": "^5.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@liexp/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"style-loader": "^3.3.3",
"ts-loader": "^9.5.1",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"typescript": "^5.2.2",
"typescript": "^5.3.2",
"url-loader": "^4.1.1",
"webpack": "^5.89.0",
"webpack-bundle-analyzer": "^4.10.1",
Expand Down
10 changes: 5 additions & 5 deletions packages/@liexp/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"test": "vitest"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.451.0",
"@aws-sdk/lib-storage": "^3.451.0",
"@aws-sdk/s3-request-presigner": "^3.451.0",
"@aws-sdk/client-s3": "^3.456.0",
"@aws-sdk/lib-storage": "^3.456.0",
"@aws-sdk/s3-request-presigner": "^3.456.0",
"@databases/escape-identifier": "^1.0.3",
"@databases/sql": "^3.3.0",
"@liexp/core": "0.1.0",
Expand All @@ -45,12 +45,12 @@
"@types/bs58": "^4.0.4",
"@types/prettier": "^3.0.0",
"@types/react": "^18.2.38",
"@types/react-dom": "^18.2.16",
"@types/react-dom": "^18.2.17",
"@types/throttle-debounce": "^5.0.2",
"@types/uuid": "^9.0.7",
"@visx/network": "^3.3.0",
"fast-csv": "^4.3.6",
"typescript": "^5.2.2",
"typescript": "^5.3.2",
"vitest": "^0.34.6"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@liexp/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"fast-check": "^2.25.0",
"fast-check-io-ts": "^0.5.0",
"prettier": "^3.1.0",
"typescript": "^5.2.2"
"typescript": "^5.3.2"
},
"peerDependencies": {
"debug": "^4.3.1"
Expand Down
12 changes: 6 additions & 6 deletions packages/@liexp/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@
"lodash": "^4.17.21",
"ol": "^8.2.0",
"query-string": "^7.1.3",
"ra-core": "^4.16.0",
"ra-i18n-polyglot": "^4.16.0",
"ra-input-rich-text": "^4.16.0",
"ra-ui-materialui": "^4.16.0",
"ra-core": "^4.16.1",
"ra-i18n-polyglot": "^4.16.1",
"ra-input-rich-text": "^4.16.1",
"ra-ui-materialui": "^4.16.1",
"react": "^18.2.0",
"react-admin": "^4.16.0",
"react-admin": "^4.16.1",
"react-audio-player": "^0.17.0",
"react-dom": "^18.2.0",
"react-dropzone": "^12.1.0",
Expand Down Expand Up @@ -123,7 +123,7 @@
"eslint-plugin-import": "^2.29.0",
"prettier": "^3.1.0",
"reactflow": "^11.10.1",
"typescript": "^5.2.2"
"typescript": "^5.3.2"
},
"lint-staged": {
"**/*.(ts|tsx|js|jsx)": "eslint --fix",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ const ageGroupColors = {
[TwelveToSixteenYears.value]: "#cd23d9",
[EighteenToSixtyFourYears.value]: "#83db7e",
[SixtyFiveToEightyfiveYears.value]: "#c0cbcf",
[EighteenToSixtyFourYears.value]: "#4f7185",
[MoreThanEightyFiveYears.value]: "#5175dc",
};

Expand Down
16 changes: 8 additions & 8 deletions services/admin-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
"fp-ts": "^2.16.1",
"history": "^5.3.0",
"mini-create-react-context": "^0.4.1",
"ra-core": "^4.16.0",
"ra-i18n-polyglot": "^4.16.0",
"ra-input-rich-text": "^4.16.0",
"ra-ui-materialui": "^4.16.0",
"ra-core": "^4.16.1",
"ra-i18n-polyglot": "^4.16.1",
"ra-input-rich-text": "^4.16.1",
"ra-ui-materialui": "^4.16.1",
"react": "^18.2.0",
"react-admin": "^4.16.0",
"react-admin": "^4.16.1",
"react-dom": "^18.2.0",
"react-final-form": "^6.5.9",
"react-final-form-arrays": "^3.1.4",
Expand All @@ -57,10 +57,10 @@
"@testing-library/user-event": "^14.5.1",
"@types/debug": "^4.1.12",
"@types/lodash": "^4.14.202",
"@types/node": "^18.18.11",
"@types/node": "^18.18.12",
"@types/prettier": "^3.0.0",
"@types/react": "^18.2.38",
"@types/react-dom": "^18.2.16",
"@types/react-dom": "^18.2.17",
"@types/webpack-bundle-analyzer": "^4.6.3",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
Expand All @@ -77,7 +77,7 @@
"page-metadata-parser": "^1.1.4",
"prettier": "^3.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"typescript": "^5.3.2",
"webpack": "^5.89.0",
"webpack-bundle-analyzer": "^4.10.1",
"webpack-cli": "^5.1.4"
Expand Down
5 changes: 2 additions & 3 deletions services/api/.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ DB_SSL_MODE=off
WEB_URL=http://localhost:4020

SPACE_BUCKET=local
SPACE_ENDPOINT=fra1.space.endpoint
SPACE_REGION=space.endpoint
SPACE_ENDPOINT=space.liexp.dev:9007
SPACE_REGION=fra1
SPACE_ACCESS_KEY_ID=space-access-key-id
SPACE_ACCESS_KEY_SECRET=space-access-key-secret-id

Expand All @@ -25,7 +25,6 @@ JWT_SECRET=my-secret
DOWNLOAD_VACCINE_DATA_CRON="*/5 * * * *"
SOCIAL_POSTING_CRON="* 1 * * *"
TEMP_FOLDER_CLEAN_UP_CRON="* 12 * * *" # every day at midnight
DEV_DATA_HOST=http://localhost:9007
TG_BOT_TOKEN=not-valid
TG_BOT_CHAT=not-valid
TG_BOT_USERNAME=not-valid
Expand Down
1 change: 0 additions & 1 deletion services/api/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ DEFAULT_PAGE_SIZE=20
API_PORT=4010
API_HOST=localhost
JWT_SECRET=my-secret
DEV_DATA_HOST=localhost:3010

# Cron jobs
DOWNLOAD_VACCINE_DATA_CRON="0 * * * * *"
Expand Down
2 changes: 1 addition & 1 deletion services/api/bin/upsert-nlp-entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const run = async (): Promise<any> => {
fetchKeywords(ctx)({
_start: O.some(skip as any),
_end: O.some(amount as any),
}),
}, true),
([, t]) => t,
([rr]) => rr,
0,
Expand Down
11 changes: 6 additions & 5 deletions services/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"import-from-kmz": "yarn ts:node:build ./bin/import-from-kmz.ts"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.451.0",
"@aws-sdk/lib-storage": "^3.451.0",
"@aws-sdk/s3-request-presigner": "^3.451.0",
"@aws-sdk/client-s3": "^3.456.0",
"@aws-sdk/lib-storage": "^3.456.0",
"@aws-sdk/s3-request-presigner": "^3.456.0",
"@databases/escape-identifier": "^1.0.3",
"@liexp/backend": "0.1.0",
"@liexp/core": "0.1.0",
Expand Down Expand Up @@ -84,7 +84,7 @@
"ts-shared": "2.0.0-alpha.6",
"tsconfig-paths": "^4.2.0",
"typeorm": "^0.3.17",
"typescript": "^5.2.2",
"typescript": "^5.3.2",
"uuid": "^9.0.1",
"wikipedia": "^2.1.1",
"wink-eng-lite-web-model": "^1.5.2",
Expand All @@ -104,7 +104,7 @@
"@types/lodash": "^4.14.202",
"@types/module-alias": "^2.0.4",
"@types/multer": "^1.4.11",
"@types/node": "^18.18.11",
"@types/node": "^18.18.12",
"@types/node-cron": "^3.0.11",
"@types/node-telegram-bot-api": "^0.63.3",
"@types/pg": "^8.10.9",
Expand All @@ -129,6 +129,7 @@
"@io": "build/io",
"@entities": "build/entities",
"@flows": "build/flows",
"@providers": "build/providers",
"@queries": "build/queries",
"@routes": "build/routes",
"@utils": "build/utils"
Expand Down
19 changes: 10 additions & 9 deletions services/api/src/flows/links/takeLinkScreenshot.flow.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { fp } from "@liexp/core/lib/fp";
import { PngType } from "@liexp/shared/lib/io/http/Media";
import {
getMediaThumbKey,
} from "@liexp/shared/lib/utils/media.utils";
import { getMediaThumbKey } from "@liexp/shared/lib/utils/media.utils";
import { pipe } from "fp-ts/function";
import { type LinkEntity } from "@entities/Link.entity";
import { type MediaEntity } from "@entities/Media.entity";
Expand Down Expand Up @@ -35,15 +33,18 @@ export const takeLinkScreenshot: TEFlow<[LinkEntity], Buffer> =
export const uploadScreenshot: TEFlow<
[LinkEntity, Buffer],
Partial<MediaEntity>
> = (ctx) => (link, base64) => {
> = (ctx) => (link, buffer) => {
const mediaKey = getMediaThumbKey(
link.image?.id ? link.image.id : link.id,
PngType.value,
);
return pipe(
ctx.s3.upload({
Bucket: ctx.env.SPACE_BUCKET,
Key: getMediaThumbKey(
link.image?.id ? link.image.id : link.id,
PngType.value,
),
Body: base64,
Key: mediaKey,
Body: buffer,
ContentType: PngType.value,
ACL: 'public-read'
}),
fp.TE.map((upload) => ({
...link.image,
Expand Down
3 changes: 2 additions & 1 deletion services/api/src/flows/social-posts/postToPlatforms.flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { postToTG } from './postToTG.flow';
import { type TEFlow } from "@flows/flow.types";

export const postToSocialPlatforms: TEFlow<[UUID, CreateSocialPost], { tg?: TelegramBot.Message; ig: any }> =
(ctx) => (id, {platforms, ...body}) => {
(ctx) => (id, { platforms: _platforms, ...body }) => {
const platforms = _platforms ?? { IG: false, TG: false }
return pipe(
sequenceS(fp.TE.ApplicativePar)({
ig: platforms.IG
Expand Down
1 change: 0 additions & 1 deletion services/api/src/io/ENV.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const ENV = t.intersection(
t.strict({
NODE_ENV: t.union([DEVELOPMENT, TEST]),
DOWNLOAD_VACCINE_DATA_CRON: t.string,
DEV_DATA_HOST: t.string,
}),
t.strict({
NODE_ENV: PRODUCTION,
Expand Down
14 changes: 9 additions & 5 deletions services/api/src/jobs/socialPostScheduler.job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { pipe } from "fp-ts/function";
import Cron from "node-cron";
import { LessThanOrEqual } from "typeorm";
import { SocialPostEntity } from "@entities/SocialPost.entity";
import { postToSocialPlatforms } from '@flows/social-posts/postToPlatforms.flow';
import { postToSocialPlatforms } from "@flows/social-posts/postToPlatforms.flow";
import { type RouteContext } from "@routes/route.types";

export const postOnSocialJob = (ctx: RouteContext): Cron.ScheduledTask =>
Expand All @@ -28,10 +28,14 @@ export const postOnSocialJob = (ctx: RouteContext): Cron.ScheduledTask =>
postToSocialPlatforms(ctx)(p.entity, p.content),
fp.TE.chain(({ ig, tg }) =>
ctx.db.save(SocialPostEntity, [
{ ...p, status: PUBLISHED.value, result: {
ig: ig ?? p.result.ig,
tg: tg ?? p.result.tg
}, },
{
...p,
status: PUBLISHED.value,
result: {
ig: ig ?? p.result.ig,
tg: tg ?? p.result.tg,
},
},
]),
),
),
Expand Down
32 changes: 32 additions & 0 deletions services/api/src/providers/context/s3.context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { type S3ClientConfig } from "@aws-sdk/client-s3";
import {
S3Provider,
type SpaceProvider,
} from "@liexp/backend/lib/providers/space";
import { type ENV } from "@io/ENV";

export const createS3Provider = (env: ENV): SpaceProvider.SpaceProvider => {
const config: S3ClientConfig =
env.NODE_ENV === "development" || env.NODE_ENV === "test"
? {
endpoint: `http://${env.SPACE_REGION}.${env.SPACE_ENDPOINT}`,
region: env.SPACE_REGION,
credentials: {
accessKeyId: env.SPACE_ACCESS_KEY_ID,
secretAccessKey: env.SPACE_ACCESS_KEY_SECRET,
},
tls: false,
forcePathStyle: true
}
: {
endpoint: `https://${env.SPACE_REGION}.${env.SPACE_ENDPOINT}`,
region: env.SPACE_REGION,
credentials: {
accessKeyId: env.SPACE_ACCESS_KEY_ID,
secretAccessKey: env.SPACE_ACCESS_KEY_SECRET,
},
tls: true,
};

return S3Provider.GetS3Provider(config);
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const MakeCreateSocialPostRoute: Route = (r, ctx) => {
{
entity: id,
type,
content: body,
content: {...body, platforms },
status: TO_PUBLISH.value,
scheduledAt: addHours(new Date(), body.schedule ?? 0),
},
Expand All @@ -28,6 +28,7 @@ export const MakeCreateSocialPostRoute: Route = (r, ctx) => {
TE.right({
content: {
...body,
platforms,
},
scheduledAt: new Date(),
}),
Expand Down
Loading