Skip to content

Commit aecb0f6

Browse files
authored
Dev (#282)
* rename * event source update * raise exception on post migration if cache not indexed * rename * notes update * remove old interceptors * some warnings alert tooltips implementation in input fields * show warnings per field and allow for typesafe adhoc warnings based on formvalue * notes for warningfn in arrays * showcase warnings in leaf items and array of objects * array of objects child update * xo update * readme update
1 parent 5471bcb commit aecb0f6

38 files changed

+408
-195
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,4 @@ Simplified:
157157

158158
- System design docs/diagrams.
159159

160-
- [Oauth2 as openapi
161-
spec](https://github.com/ybelenko/oauth2_as_oas3_components/tree/master/dist/components)
162-
with endpoints clearly documented based on RFCs
163-
Can generate a mock with e.g.
164-
[openapi-mock](https://github.com/muonsoft/openapi-mock).
165160

db/migrations/README.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
# Schema dumping (obtuse version, do not implement)
2-
3-
**breaks plpgsql lsp extension, would need opt migration names to skip regex option,
4-
or via flag on top of the file (preferred)**
5-
6-
Eventually, accumulated migrations will take too long to run compared to
7-
creating the final schema in one go.
8-
You can create a new migration via `project migrate.create x_schema_dump` (must be named
9-
x_schema_dump).
10-
These migration files will be detected before executing `up` migrations.
11-
12-
The latest x_schema_dump migration will be the new reference point for further
13-
migrations.
14-
15-
If current revision is 0 (i.e. `error: no migration` exit 1),
16-
it will execute `force $((latest_schema_dump_revision - 1))`
17-
and then `up` normally. Ideal for tests, gen db, etc.
18-
19-
If current revision is within 1 and `$((latest_schema_dump_revision -1))` (e.g.
20-
in prod environment)
21-
it will skip all x_schema_dump migrations in between, executing
22-
`goto $((schema_dump_revision - 1))` and then `force $schema_dump_revision` in ascending x_schema_dump
23-
migrations order.
24-
25-
In any other case, it simply runs `up` as usual.
1+
> # Schema dumping (obtuse version, do not implement)
2+
> **breaks plpgsql lsp extension, would need opt migration names to skip regex > option,
3+
> or via flag on top of the file (preferred)**
4+
>
5+
> Eventually, accumulated migrations will take too long to run compared to
6+
> creating the final schema in one go.
7+
> You can create a new migration via `project migrate.create x_schema_dump` > (must be named
8+
> x_schema_dump).
9+
> These migration files will be detected before executing `up` migrations.
10+
>
11+
> The latest x_schema_dump migration will be the new reference point for further
12+
> migrations.
13+
>
14+
> If current revision is 0 (i.e. `error: no migration` exit 1),
15+
> it will execute `force $((latest_schema_dump_revision - 1))`
16+
> and then `up` normally. Ideal for tests, gen db, etc.
17+
>
18+
> If current revision is within 1 and `$((latest_schema_dump_revision -1))` (e.g.
19+
> in prod environment)
20+
> it will skip all x_schema_dump migrations in between, executing
21+
> `goto $((schema_dump_revision - 1))` and then `force $schema_dump_revision` in > ascending x_schema_dump
22+
> migrations order.
23+
>
24+
> In any other case, it simply runs `up` as usual.
2625
2726

2827
# Schema dumping (less obtuse version)
@@ -36,9 +35,10 @@ project db.bash
3635
```
3736

3837
TODO: all comments will be lost. should instead make use of comments on tables
39-
instead of sql comments so they're saved after migrating a to a schema dump
38+
instead of sql comments so they're saved after migrating to a schema dump
4039
and removing old files. (not like anyone would read old migration files comments
41-
anyway). Can use `project dev-utils.show-table-comments` to make maintenance easier.
40+
anyway). Can use `project dev-utils.show-table-comments` to make maintenance
41+
easier.
4242

4343
Once prod is up to date (i.e. revision at latest_schema_dump_revision minus
4444
one),

db/post-migrations/003_cache_tables_triggers.up.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ end;
126126
$$
127127
language plpgsql;
128128

129-
create or replace function create_work_item_cache_table (project_name text)
129+
create or replace function create_or_update_work_item_cache_table (project_name text)
130130
returns VOID
131131
as $$
132132
declare
@@ -223,7 +223,7 @@ begin
223223
from
224224
projects loop
225225
perform
226-
create_work_item_cache_table (project_name);
226+
create_or_update_work_item_cache_table (project_name);
227227

228228
idx_name := FORMAT('cache__%I_gin_index' , project_name);
229229

@@ -239,7 +239,7 @@ begin
239239
title extensions.gin_trgm_ops
240240
)';
241241
else
242-
idx_def := ''; raise notice 'No index definitions for cache__%' , project_name;
242+
idx_def := ''; raise exception 'No index definition found for cache__%' , project_name;
243243
end case;
244244

245245
if idx_def <> '' and not same_index_definition (idx_name , idx_def) then

db/post-migrations/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
All `*.up.sql` files are always executed like regular migrations after main `migrations`'s `up` regardless of `post-migrations` current
2-
version. `post-migrations` always applies its down migrations before execution.
2+
version.
3+
4+
`post-migrations` always applies its down migrations before execution.
5+
36
Post-migration commands should be idempotent. Do not use `*.down.sql` files.

e2e/client/gen/model/topic.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type Topic = typeof Topic[keyof typeof Topic]
1313

1414
// eslint-disable-next-line @typescript-eslint/no-redeclare
1515
export const Topic = {
16+
AppDebug: 'AppDebug',
1617
WorkItemUpdated: 'WorkItemUpdated',
1718
TeamCreated: 'TeamCreated',
1819
GlobalAlerts: 'GlobalAlerts',

frontend/src/client-validator/gen/dereferenced-schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3214,6 +3214,7 @@
32143214
"description": "string identifiers for SSE event listeners.",
32153215
"type": "string",
32163216
"enum": [
3217+
"AppDebug",
32173218
"WorkItemUpdated",
32183219
"TeamCreated",
32193220
"GlobalAlerts"
@@ -3225,6 +3226,7 @@
32253226
"description": "string identifiers for SSE event listeners.",
32263227
"type": "string",
32273228
"enum": [
3229+
"AppDebug",
32283230
"WorkItemUpdated",
32293231
"TeamCreated",
32303232
"GlobalAlerts"
@@ -9532,6 +9534,7 @@
95329534
"description": "string identifiers for SSE event listeners.",
95339535
"type": "string",
95349536
"enum": [
9537+
"AppDebug",
95359538
"WorkItemUpdated",
95369539
"TeamCreated",
95379540
"GlobalAlerts"
@@ -9543,6 +9546,7 @@
95439546
"description": "string identifiers for SSE event listeners.",
95449547
"type": "string",
95459548
"enum": [
9549+
"AppDebug",
95469550
"WorkItemUpdated",
95479551
"TeamCreated",
95489552
"GlobalAlerts"

frontend/src/client-validator/gen/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export type Location1 = string[]
8989
/**
9090
* string identifiers for SSE event listeners.
9191
*/
92-
export type Topic = 'WorkItemUpdated' | 'TeamCreated' | 'GlobalAlerts'
92+
export type Topic = 'AppDebug' | 'WorkItemUpdated' | 'TeamCreated' | 'GlobalAlerts'
9393
export type Topics = Topic[]
9494
export type UuidUUID = string
9595
export type WorkItem = DemoWorkItem | DemoTwoWorkItem

frontend/src/client-validator/gen/schema.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,7 @@
16221622
"description": "string identifiers for SSE event listeners.",
16231623
"type": "string",
16241624
"enum": [
1625+
"AppDebug",
16251626
"WorkItemUpdated",
16261627
"TeamCreated",
16271628
"GlobalAlerts"

frontend/src/components/Callout/DynamicFormErrorCallout.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@ export default function DynamicFormErrorCallout() {
4242
const warnings = calloutWarnings ? entries(calloutWarnings).map(([schemaKey, warning], idx) => warning) : []
4343
const errors = concat(
4444
extractCalloutErrors(),
45-
entries(rhfErrors).map(([schemaKey, error], idx) => {
45+
entries(rhfErrors).map(([schemaKey, error], _) => {
4646
let message = lowerFirst(error.message) // lowerCase breaks regexes
4747
schemaKey = schemaKey.replace(/\.\d+$/, '') as SchemaKey // TODO: in flattener instead
4848

49-
console.log({ schemaKey, error })
5049
const itemName = options.labels[schemaKey] || ''
5150

5251
if (error.index) {
@@ -58,8 +57,6 @@ export default function DynamicFormErrorCallout() {
5857
message = `${message} (example: ${randexp(match[1] || '')})`
5958
}
6059

61-
console.log({ message })
62-
6360
return `${itemName}: ${message}`
6461
}),
6562
)

frontend/src/components/Callout/useCalloutErrors.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const useCalloutErrors = (formName: string) => {
5656
return errors
5757
}
5858

59-
const extractCalloutTitle = () => {
59+
const extractCalloutTitle = (): string => {
6060
if (Object.keys(form?.customErrors ?? {}).length > 0) {
6161
return 'Validation error'
6262
}
@@ -79,13 +79,14 @@ export const useCalloutErrors = (formName: string) => {
7979
case 'Unauthorized':
8080
return 'Unauthorized'
8181
case 'Unknown':
82+
return unknownError
8283
default:
8384
return calloutError.message
8485
}
8586
}
8687

8788
// external call error
88-
if (calloutErrors instanceof AxiosError) return calloutError
89+
if (calloutError instanceof AxiosError) return calloutError.message
8990
}
9091

9192
// errors unrelated to api calls and validation

0 commit comments

Comments
 (0)