Skip to content

Commit d7b73fb

Browse files
authored
Dev (#347)
* update * cleanup * update * update orval * update * auth update * fix gowrap version - no option for alias * update pregen
1 parent ca4343b commit d7b73fb

File tree

210 files changed

+1474
-1106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+1474
-1106
lines changed

bin/project

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ x.install-tools() {
293293
"go install github.com/air-verse/air@latest"
294294
"go install github.com/danicc097/xo/v5@v5.6.0"
295295
"go install github.com/mikefarah/yq/v4@v4.34.2"
296-
"go install github.com/hexdigest/gowrap/cmd/gowrap@latest"
296+
"go install github.com/hexdigest/gowrap/cmd/gowrap@v1.4.0"
297297
"go install golang.org/x/tools/cmd/stringer@latest"
298298
"go install github.com/maxbrunsfeld/counterfeiter/v6@latest"
299299
"go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1"
@@ -372,19 +372,19 @@ x.gen.pregen() {
372372
echo "${YELLOW}Generating missing rest package \$ref's:"
373373
printf "${YELLOW} - %s\n" "${missing_rest_models[@]}"
374374
echo "${OFF}"
375-
fi
376375

377-
local new_schemas=""
378-
for ref in "${missing_rest_models[@]}"; do
379-
new_schemas+="\"$ref\": {
376+
local new_schemas=""
377+
for ref in "${missing_rest_models[@]}"; do
378+
new_schemas+="\"$ref\": {
380379
\"x-gen-struct\": \"$ref\",
381380
\"x-is-generated\": true
382381
},"
383-
done
382+
done
384383

385-
yq eval-all ".components.schemas += {
386-
${new_schemas%,}
387-
}" -i "$SPEC_PATH"
384+
yq eval-all ".components.schemas += {
385+
${new_schemas%,}
386+
}" -i "$SPEC_PATH"
387+
fi
388388

389389
codegen validate-spec -env=".env.$X_ENV"
390390
# useless after merging models and db
@@ -419,12 +419,9 @@ x.gen.pregen() {
419419

420420
update_roles_and_scopes
421421

422-
codegen pre -env=".env.$X_ENV" -op-id-auth="$OPID_AUTH_PATH" &
423-
validate_spec &
424-
update_spec_with_structs &
425-
426-
wait_without_error
427-
422+
validate_spec
423+
codegen pre -env=".env.$X_ENV" -op-id-auth="$OPID_AUTH_PATH" # should not edit spec
424+
update_spec_with_structs
428425
remove_schemas_marked_for_deletion
429426
} 2>&4 | xlog >&3; } 4>&1 | xerr >&3; } 3>&1
430427
xsetup.backup.cleanup
@@ -590,7 +587,6 @@ generate_repo_constructor() {
590587
go-utils.find_interfaces repo_interfaces $repos
591588

592589
for iface in "${repo_interfaces[@]}"; do
593-
local struct_init+=("${iface}: ${iface,}")
594590
local struct_fields+=("${iface} ${iface}")
595591
done
596592

db/post-migrations/001_public_triggers.up.sql renamed to db/post-migrations/001_public_triggers_and_functions.up.sql

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,32 @@ begin
4141
end;
4242
$BODY$
4343
language plpgsql;
44+
45+
--
46+
--
47+
--
48+
--
49+
--
50+
--
51+
--
52+
-- FUNCTIONS
53+
--
54+
--
55+
--
56+
--
57+
--
58+
--
59+
--
60+
--
61+
create or replace function row_estimator (query text)
62+
returns bigint
63+
language plpgsql
64+
as $$
65+
declare
66+
plan jsonb;
67+
begin
68+
execute 'EXPLAIN (FORMAT JSON) ' || query into plan;
69+
70+
return (plan -> 0 -> 'Plan' ->> 'Plan Rows')::bigint;
71+
end;
72+
$$;

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"moment": "^2.29.4",
8080
"msw": "^2.2.1",
8181
"openapi-typescript": "^6.4.3",
82-
"orval": "^6.25.0",
82+
"orval": "6.30.2",
8383
"postcss": "^8.4.24",
8484
"postcss-preset-mantine": "1.9.0",
8585
"postcss-simple-vars": "^7.0.1",

frontend/pnpm-lock.yaml

Lines changed: 63 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/gen/activity/activity.msw.ts

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type * as EntityIDs from 'src/gen/entity-ids'
22
/**
3-
* Generated by orval v6.25.0 🍺
3+
* Generated by orval v6.30.2 🍺
44
* Do not edit manually.
55
* OpenAPI openapi-go-gin-postgres-sqlc
66
* openapi-go-gin-postgres-sqlc
@@ -18,19 +18,20 @@ import type {
1818
ActivityResponse
1919
} from '.././model'
2020

21-
export const getCreateActivityResponseMock = (overrideResponse: any = {}): ActivityResponse => ({activityID: faker.number.int({min: undefined, max: undefined}) as EntityIDs.ActivityID, deletedAt: faker.helpers.arrayElement([(() => faker.date.past())(), null]), description: faker.word.sample(), isProductive: faker.datatype.boolean(), name: faker.word.sample(), projectID: faker.number.int({min: undefined, max: undefined}) as EntityIDs.ProjectID, ...overrideResponse})
21+
export const getCreateActivityResponseMock = (overrideResponse: Partial< ActivityResponse > = {}): ActivityResponse => ({activityID: faker.number.int({min: undefined, max: undefined}) as EntityIDs.ActivityID, deletedAt: faker.helpers.arrayElement([(() => faker.date.past())(), null]), description: faker.word.sample(), isProductive: faker.datatype.boolean(), name: faker.word.sample(), projectID: faker.number.int({min: undefined, max: undefined}) as EntityIDs.ProjectID, ...overrideResponse})
2222

23-
export const getGetActivityResponseMock = (overrideResponse: any = {}): ActivityResponse => ({activityID: faker.number.int({min: undefined, max: undefined}) as EntityIDs.ActivityID, deletedAt: faker.helpers.arrayElement([(() => faker.date.past())(), null]), description: faker.word.sample(), isProductive: faker.datatype.boolean(), name: faker.word.sample(), projectID: faker.number.int({min: undefined, max: undefined}) as EntityIDs.ProjectID, ...overrideResponse})
23+
export const getGetActivityResponseMock = (overrideResponse: Partial< ActivityResponse > = {}): ActivityResponse => ({activityID: faker.number.int({min: undefined, max: undefined}) as EntityIDs.ActivityID, deletedAt: faker.helpers.arrayElement([(() => faker.date.past())(), null]), description: faker.word.sample(), isProductive: faker.datatype.boolean(), name: faker.word.sample(), projectID: faker.number.int({min: undefined, max: undefined}) as EntityIDs.ProjectID, ...overrideResponse})
2424

25-
export const getUpdateActivityResponseMock = (overrideResponse: any = {}): ActivityResponse => ({activityID: faker.number.int({min: undefined, max: undefined}) as EntityIDs.ActivityID, deletedAt: faker.helpers.arrayElement([(() => faker.date.past())(), null]), description: faker.word.sample(), isProductive: faker.datatype.boolean(), name: faker.word.sample(), projectID: faker.number.int({min: undefined, max: undefined}) as EntityIDs.ProjectID, ...overrideResponse})
25+
export const getUpdateActivityResponseMock = (overrideResponse: Partial< ActivityResponse > = {}): ActivityResponse => ({activityID: faker.number.int({min: undefined, max: undefined}) as EntityIDs.ActivityID, deletedAt: faker.helpers.arrayElement([(() => faker.date.past())(), null]), description: faker.word.sample(), isProductive: faker.datatype.boolean(), name: faker.word.sample(), projectID: faker.number.int({min: undefined, max: undefined}) as EntityIDs.ProjectID, ...overrideResponse})
2626

2727

28-
export const getCreateActivityMockHandler = (overrideResponse?: ActivityResponse) => {
29-
return http.post('*/project/:projectName/activity/', async () => {
30-
await delay(200);
31-
return new HttpResponse(JSON.stringify(overrideResponse ? overrideResponse : getCreateActivityResponseMock()),
28+
export const getCreateActivityMockHandler = (overrideResponse?: ActivityResponse | ((info: Parameters<Parameters<typeof http.post>[1]>[0]) => Promise<ActivityResponse> | ActivityResponse)) => {
29+
return http.post('*/project/:projectName/activity/', async (info) => {await delay(200);
30+
return new HttpResponse(JSON.stringify(overrideResponse !== undefined
31+
? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse)
32+
: getCreateActivityResponseMock()),
3233
{
33-
status: 200,
34+
status: 201,
3435
headers: {
3536
'Content-Type': 'application/json',
3637
}
@@ -39,10 +40,11 @@ export const getCreateActivityMockHandler = (overrideResponse?: ActivityResponse
3940
})
4041
}
4142

42-
export const getGetActivityMockHandler = (overrideResponse?: ActivityResponse) => {
43-
return http.get('*/activity/:activityID', async () => {
44-
await delay(200);
45-
return new HttpResponse(JSON.stringify(overrideResponse ? overrideResponse : getGetActivityResponseMock()),
43+
export const getGetActivityMockHandler = (overrideResponse?: ActivityResponse | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<ActivityResponse> | ActivityResponse)) => {
44+
return http.get('*/activity/:activityID', async (info) => {await delay(200);
45+
return new HttpResponse(JSON.stringify(overrideResponse !== undefined
46+
? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse)
47+
: getGetActivityResponseMock()),
4648
{
4749
status: 200,
4850
headers: {
@@ -53,10 +55,11 @@ export const getGetActivityMockHandler = (overrideResponse?: ActivityResponse) =
5355
})
5456
}
5557

56-
export const getUpdateActivityMockHandler = (overrideResponse?: ActivityResponse) => {
57-
return http.patch('*/activity/:activityID', async () => {
58-
await delay(200);
59-
return new HttpResponse(JSON.stringify(overrideResponse ? overrideResponse : getUpdateActivityResponseMock()),
58+
export const getUpdateActivityMockHandler = (overrideResponse?: ActivityResponse | ((info: Parameters<Parameters<typeof http.patch>[1]>[0]) => Promise<ActivityResponse> | ActivityResponse)) => {
59+
return http.patch('*/activity/:activityID', async (info) => {await delay(200);
60+
return new HttpResponse(JSON.stringify(overrideResponse !== undefined
61+
? (typeof overrideResponse === "function" ? await overrideResponse(info) : overrideResponse)
62+
: getUpdateActivityResponseMock()),
6063
{
6164
status: 200,
6265
headers: {
@@ -68,11 +71,10 @@ export const getUpdateActivityMockHandler = (overrideResponse?: ActivityResponse
6871
}
6972

7073
export const getDeleteActivityMockHandler = () => {
71-
return http.delete('*/activity/:activityID', async () => {
72-
await delay(200);
74+
return http.delete('*/activity/:activityID', async () => {await delay(200);
7375
return new HttpResponse(null,
7476
{
75-
status: 200,
77+
status: 204,
7678
headers: {
7779
'Content-Type': 'application/json',
7880
}

0 commit comments

Comments
 (0)