Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
1138351
Drafting email sending
hejny Dec 10, 2023
87a6d62
Update send-email.ts
hejny Dec 10, 2023
6344c7d
Update send-email.ts
hejny Dec 10, 2023
a080783
Email object
hejny Dec 10, 2023
c26e192
TODOs
hejny Dec 10, 2023
8e67b27
Validate email dialogue (not finished)
hejny Dec 10, 2023
2805452
TODOs
hejny Dec 10, 2023
6780e97
TODOs
hejny Dec 11, 2023
baa1689
Update code snippets
hejny Dec 11, 2023
6302726
Use snippets in function to do
hejny Dec 11, 2023
2710d1e
Branded type for client_id
hejny Dec 11, 2023
b7f026e
Add $ prefix to non-pure function + TODOs
hejny Dec 11, 2023
fd97c45
Add $ prefix to non-pure function
hejny Dec 11, 2023
6e5c3f9
Split ForBrowser, ForServer version of functions
hejny Dec 11, 2023
c9086b5
Prepare for implementation
hejny Dec 11, 2023
2cf2d25
TODOs
hejny Dec 11, 2023
4b60c68
Sync new tables ClientEmailVerificationRequest and ClientEmailVerific…
hejny Dec 11, 2023
f5fbaff
<ClientVerificationComponent/>
hejny Dec 11, 2023
172bfd7
Update sendEmailForServer function
hejny Dec 11, 2023
d02580e
Implementing verification utils
hejny Dec 11, 2023
966959b
Add view ClientEmailVerification_withRequests
hejny Dec 11, 2023
bdbfdc5
Working on $isClientVerifiedForServer
hejny Dec 11, 2023
2ebb4a3
Add view ClientEmailVerification_withRequests
hejny Dec 11, 2023
9a95afb
Working on isClientVerified
hejny Dec 11, 2023
16e64e7
TODOs
hejny Dec 11, 2023
bf4bbf5
Fixing types
hejny Dec 11, 2023
a36a87c
Fixing types
hejny Dec 11, 2023
28fafac
Fixing types
hejny Dec 11, 2023
cb3b41f
Remove CodeValidationError
hejny Dec 11, 2023
1d228d3
Fixing types
hejny Dec 11, 2023
f9b8e5c
Fixing types
hejny Dec 11, 2023
c423f6c
Merge branch 'main' into feature/emails
hejny Dec 11, 2023
aa89914
Working on <ClientVerificationComponent/>
hejny Dec 11, 2023
3b049bb
Fixing types
hejny Dec 11, 2023
b967014
Manage TODOs
hejny Dec 11, 2023
9b35b1c
Manage TODOs
hejny Dec 11, 2023
be8b608
Manage TODOs
hejny Dec 11, 2023
8aff330
Working on verification process
hejny Dec 11, 2023
0b0d853
Automatic verification
hejny Dec 11, 2023
26ec4c4
Maxdown as a template literal tag function
hejny Dec 11, 2023
88bd93f
UX of Verification process
hejny Dec 11, 2023
99c5c41
Clicking on link in verification email | AutomaticVerification
hejny Dec 11, 2023
fce82b6
Redirects back after verification
hejny Dec 11, 2023
b61712f
TODOs
hejny Dec 11, 2023
90ae93d
TODOs
hejny Dec 11, 2023
d568c0e
Annotate types
hejny Dec 11, 2023
afd60b2
TODOs
hejny Dec 11, 2023
58dbd0e
Notes
hejny Dec 11, 2023
6aff6ec
TODOs
hejny Dec 11, 2023
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
9 changes: 6 additions & 3 deletions .vscode/hejny.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
},
"test": {
"scope": "typescript",
"prefix": "AI+TDD",
"description": "Test+Implementation ready to AI development",
"prefix": "Function with unit test",
"description": "Test+Implementation of one function ready to AI development",
"body": [
"import { describe, expect, it } from '@jest/globals';",
"import spaceTrim from 'spacetrim';",
Expand All @@ -53,7 +53,10 @@
" });",
"});",
"",
"function $1(value: string): boolean {",
"/**",
"* Function $1 will @@@",
"*/"
"export function $1(value: string): boolean {",
" return value === 'Foo';",
"}",
""
Expand Down
8 changes: 2 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@
- [ ] When importing type USE always `import type { ... } from '...'` automatically
Search & replace `import\s+(\{.*\/interfaces\/)` -> `import type $1` works
- [ ] Script for auto-generating fresh unused tags with emojis [👩‍🦱][👩‍🦲][👳‍♂️]

- [ ] Go through all .push(...) and decide to change to [...x,y] where better

- [ ] Do not use useEffect sooo often https://youtu.be/bGzanfKVFeU?si=CSebLURTV3RKqOsn



p
- [ ] Mark all non-pure functions/classes with $ prefix _(half done but need to go through code and do it for all)_
[ ] Explain all the point why the function is not pure

## Misc

Expand Down
35 changes: 20 additions & 15 deletions config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,17 @@ import spaceTrim from 'spacetrim';
import { Vector } from 'xyzt';
import packageJson from './package.json';
import type { DallePrompt } from './src/ai/text-to-image/dalle/interfaces/DallePrompt';
import { maxdown } from './src/components/Content/Maxdown/maxdown';
import { FULLHD } from './src/constants';
import type { AspectRatioRange } from './src/utils/aspect-ratio/AspectRatioRange';
import { expectAspectRatioInRange } from './src/utils/aspect-ratio/expectAspectRatioInRange';
import { DigitalOceanSpaces } from './src/utils/cdn/classes/DigitalOceanSpaces';
import { validateClientId } from './src/utils/client/validateClientId';
import { createColorfulComputeImageColorStats15 } from './src/utils/image/palette/15/createColorfulComputeImageColorStats15';
import type { IComputeImageColorStats } from './src/utils/image/utils/IImageColorStats';
import { isRunningInBrowser } from './src/utils/isRunningInWhatever';
import { string_email, string_font_family } from './src/utils/typeAliases';
import type { string_email, string_font_family, string_maxdown } from './src/utils/typeAliases';
import { isUrlOnPrivateNetwork } from './src/utils/validators/isUrlOnPrivateNetwork';
import { validateUuid } from './src/utils/validators/validateUuid';

export const APP_VERSION = packageJson.version;
export const APP_NAME = 'WebGPT';
export const ADMIN_EMAIL: string_email = 'pavol@webgpt.cz';

export const USE_DALLE_VERSION: 2 | 3 = 3;

export const USE_DALLE_MODEL_SETTINGS: DallePrompt['modelSettings'] = {
style: 'vivid',
quality: `standard`,
// <- TODO: !! Play with theeese to achieve best results
};

const config = ConfigChecker.from({
...process.env,
Expand All @@ -40,6 +29,20 @@ const config = ConfigChecker.from({
});

export const NEXT_PUBLIC_URL = config.get('NEXT_PUBLIC_URL').url().required().value;

export const APP_VERSION = packageJson.version;
export const APP_NAME = 'WebGPT';
export const ADMIN_EMAIL: string_email = 'pavol@webgpt.cz';
export const APP_SIGNATURE: string_maxdown = maxdown`[⏣ ${APP_NAME}](${NEXT_PUBLIC_URL.href})`;

export const USE_DALLE_VERSION: 2 | 3 = 3;

export const USE_DALLE_MODEL_SETTINGS: DallePrompt['modelSettings'] = {
style: 'vivid',
quality: `standard`,
// <- TODO: !! Play with theeese to achieve best results
};

export const NEXT_PUBLIC_PROMPTBOOK_SERVER_URL = config.get('NEXT_PUBLIC_PROMPTBOOK_SERVER_URL').url().required().value;
export const NEXT_PUBLIC_IMAGE_SERVER_URL = config.get('NEXT_PUBLIC_IMAGE_SERVER_URL').url().required().value;

Expand Down Expand Up @@ -123,6 +126,8 @@ export const LIMIT_WALLPAPERS_EXCLUDE = config.get('LIMIT_WALLPAPERS_EXCLUDE').l

export const OPENAI_API_KEY = config.get('OPENAI_API_KEY').value;

export const SENDGRID_API_KEY = config.get('SENDGRID_API_KEY').value;

export const AZURE_COMPUTER_VISION_ENDPOINT = config.get('AZURE_COMPUTER_VISION_ENDPOINT').url().value;
export const AZURE_COMPUTER_VISION_KEY = config.get('AZURE_COMPUTER_VISION_KEY').value;

Expand Down Expand Up @@ -1046,7 +1051,7 @@ export const TEXT_BACKGROUND_COLOR_DISTANCE_THEASHOLD_RATIO = 0.5; /* <- As a ra
*/
export const PRIMARY_TO_AVERAGE_MAX_COLOR_DISTANCE_THEASHOLD_RATIO = 0.1; /* <- As a ratio of distance between white and black */

export const SYSTEM_AUTHOR_ID = validateUuid('000d2940-4a35-4859-83a8-3c754ea5df51');
export const SYSTEM_AUTHOR_ID = validateClientId('000d2940-4a35-4859-83a8-3c754ea5df51');

// TODO: [🧠] How to do required only on server
export const CDN_BUCKET = config.get('CDN_BUCKET') /*.required([📐])*/.value;
Expand Down
167 changes: 167 additions & 0 deletions database/dumps/structure.dump.pgsql
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,92 @@ ALTER TABLE public."Client" OWNER TO postgres;
COMMENT ON TABLE public."Client" IS 'Client is one browser marked with unique id';


--
-- Name: ClientEmailVerification; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public."ClientEmailVerification" (
id bigint NOT NULL,
"verificationRequestId" bigint NOT NULL,
"createdAt" timestamp with time zone DEFAULT now() NOT NULL
);


ALTER TABLE public."ClientEmailVerification" OWNER TO postgres;

--
-- Name: TABLE "ClientEmailVerification"; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public."ClientEmailVerification" IS 'Verification of the client+email. Earch row means successfuly verified client.';


--
-- Name: ClientEmailVerificationRequest; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public."ClientEmailVerificationRequest" (
id bigint NOT NULL,
"createdAt" timestamp with time zone DEFAULT now() NOT NULL,
"clientId" uuid DEFAULT gen_random_uuid() NOT NULL,
email text NOT NULL,
code text NOT NULL
);


ALTER TABLE public."ClientEmailVerificationRequest" OWNER TO postgres;

--
-- Name: TABLE "ClientEmailVerificationRequest"; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON TABLE public."ClientEmailVerificationRequest" IS 'Requests for email verification of the client';


--
-- Name: ClientEmailVerificationRequest_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

ALTER TABLE public."ClientEmailVerificationRequest" ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public."ClientEmailVerificationRequest_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);


--
-- Name: ClientEmailVerification_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--

ALTER TABLE public."ClientEmailVerification" ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public."ClientEmailVerification_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);


--
-- Name: ClientEmailVerification_withRequests; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW public."ClientEmailVerification_withRequests" AS
SELECT "ClientEmailVerification"."createdAt",
"ClientEmailVerificationRequest"."clientId",
"ClientEmailVerificationRequest".email,
"ClientEmailVerification"."verificationRequestId",
"ClientEmailVerificationRequest".code
FROM (public."ClientEmailVerification"
LEFT JOIN public."ClientEmailVerificationRequest" ON (("ClientEmailVerification"."verificationRequestId" = "ClientEmailVerificationRequest".id)));


ALTER TABLE public."ClientEmailVerification_withRequests" OWNER TO postgres;

--
-- Name: PromptbookFeedback; Type: TABLE; Schema: public; Owner: postgres
--
Expand Down Expand Up @@ -1956,6 +2042,22 @@ ALTER TABLE ONLY auth.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);


--
-- Name: ClientEmailVerificationRequest ClientEmailVerificationRequest_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public."ClientEmailVerificationRequest"
ADD CONSTRAINT "ClientEmailVerificationRequest_pkey" PRIMARY KEY (id);


--
-- Name: ClientEmailVerification ClientEmailVerification_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public."ClientEmailVerification"
ADD CONSTRAINT "ClientEmailVerification_pkey" PRIMARY KEY (id);


--
-- Name: Client Client_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
Expand Down Expand Up @@ -2429,6 +2531,14 @@ ALTER TABLE ONLY auth.sso_domains
ADD CONSTRAINT sso_domains_sso_provider_id_fkey FOREIGN KEY (sso_provider_id) REFERENCES auth.sso_providers(id) ON DELETE CASCADE;


--
-- Name: ClientEmailVerification ClientEmailVerification_verificationRequestId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public."ClientEmailVerification"
ADD CONSTRAINT "ClientEmailVerification_verificationRequestId_fkey" FOREIGN KEY ("verificationRequestId") REFERENCES public."ClientEmailVerificationRequest"(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: WallpaperFeedback WallpaperFeedback_wallpaperId_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
Expand Down Expand Up @@ -2493,6 +2603,18 @@ CREATE POLICY "Anyone can insert a row" ON public."WallpaperFeedback" FOR INSERT

ALTER TABLE public."Client" ENABLE ROW LEVEL SECURITY;

--
-- Name: ClientEmailVerification; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public."ClientEmailVerification" ENABLE ROW LEVEL SECURITY;

--
-- Name: ClientEmailVerificationRequest; Type: ROW SECURITY; Schema: public; Owner: postgres
--

ALTER TABLE public."ClientEmailVerificationRequest" ENABLE ROW LEVEL SECURITY;

--
-- Name: ImagePromptExecution; Type: ROW SECURITY; Schema: public; Owner: postgres
--
Expand Down Expand Up @@ -3503,6 +3625,51 @@ GRANT ALL ON TABLE public."Client" TO authenticated;
GRANT ALL ON TABLE public."Client" TO service_role;


--
-- Name: TABLE "ClientEmailVerification"; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public."ClientEmailVerification" TO anon;
GRANT ALL ON TABLE public."ClientEmailVerification" TO authenticated;
GRANT ALL ON TABLE public."ClientEmailVerification" TO service_role;


--
-- Name: TABLE "ClientEmailVerificationRequest"; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public."ClientEmailVerificationRequest" TO anon;
GRANT ALL ON TABLE public."ClientEmailVerificationRequest" TO authenticated;
GRANT ALL ON TABLE public."ClientEmailVerificationRequest" TO service_role;


--
-- Name: SEQUENCE "ClientEmailVerificationRequest_id_seq"; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON SEQUENCE public."ClientEmailVerificationRequest_id_seq" TO anon;
GRANT ALL ON SEQUENCE public."ClientEmailVerificationRequest_id_seq" TO authenticated;
GRANT ALL ON SEQUENCE public."ClientEmailVerificationRequest_id_seq" TO service_role;


--
-- Name: SEQUENCE "ClientEmailVerification_id_seq"; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON SEQUENCE public."ClientEmailVerification_id_seq" TO anon;
GRANT ALL ON SEQUENCE public."ClientEmailVerification_id_seq" TO authenticated;
GRANT ALL ON SEQUENCE public."ClientEmailVerification_id_seq" TO service_role;


--
-- Name: TABLE "ClientEmailVerification_withRequests"; Type: ACL; Schema: public; Owner: postgres
--

GRANT ALL ON TABLE public."ClientEmailVerification_withRequests" TO anon;
GRANT ALL ON TABLE public."ClientEmailVerification_withRequests" TO authenticated;
GRANT ALL ON TABLE public."ClientEmailVerification_withRequests" TO service_role;


--
-- Name: TABLE "PromptbookFeedback"; Type: ACL; Schema: public; Owner: postgres
--
Expand Down
Loading