Skip to content

Commit

Permalink
Merge branch 'main' into ships/add-stevie
Browse files Browse the repository at this point in the history
  • Loading branch information
ships authored May 7, 2024
2 parents 2453572 + ae535d8 commit 2f355f4
Show file tree
Hide file tree
Showing 21 changed files with 89 additions and 17 deletions.
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ FROM node:${NODE_VERSION}-alpine as base
ARG PNPM_VERSION=8.14.3

# Install python deps for node-gyp
RUN apk add g++ make py3-pip
RUN apk add g++ make py3-pip ca-certificates curl

# Setup RDS CA Certificates

RUN curl -L \
-o /usr/local/share/ca-certificates/rds-global-bundle.pem \
https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem \
&& update-ca-certificates

# Set working directory for all build stages.
WORKDIR /usr/src/app
Expand Down
2 changes: 1 addition & 1 deletion core/.env.docker
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DATABASE_URL=postgresql://${PGUSER}:${PGPASSWORD}@${PGHOST}:${PGPORT}/${PGDATABASE}?sslmode=require
DATABASE_URL=postgresql://${PGUSER}:${PGPASSWORD}@${PGHOST}:${PGPORT}/${PGDATABASE}
4 changes: 4 additions & 0 deletions core/actions/_lib/runActionInstance.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use server";

import { revalidateTag } from "next/cache";
import { captureException } from "@sentry/nextjs";
import { sql } from "kysely";

Expand Down Expand Up @@ -117,8 +118,11 @@ const _runActionInstance = async ({
values: values as any,
},
runParameters: runParameters,
stageId: actionInstance.stageId,
});

revalidateTag(`community-stages_${pub.communityId}`);

return result;
} catch (error) {
captureException(error);
Expand Down
2 changes: 2 additions & 0 deletions core/actions/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import type Event from "~/kysely/types/public/Event";
import * as email from "../email/action";
import * as log from "../log/action";
import * as move from "../move/action";
import * as pdf from "../pdf/action";
import * as pushToV6 from "../pushToV6/action";

Expand All @@ -11,6 +12,7 @@ export const actions = {
[pdf.action.name]: pdf.action,
[email.action.name]: email.action,
[pushToV6.action.name]: pushToV6.action,
[move.action.name]: move.action,
} as const;

export const getActionByName = (name: keyof typeof actions) => {
Expand Down
16 changes: 16 additions & 0 deletions core/actions/move/action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as z from "zod";

import { MoveHorizontal } from "ui/icon";

import { defineAction } from "../types";

export const action = defineAction({
name: "move",
config: z.object({
stage: z.string().describe("Destination stage"),
}),
description: "Move a pub to a different stage",
runParameters: z.object({}).optional(),
pubFields: [],
icon: MoveHorizontal,
});
42 changes: 42 additions & 0 deletions core/actions/move/run.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"use server";

import { logger } from "logger";

import type { action } from "./action";
import type { PubsId } from "~/kysely/types/public/Pubs";
import type { StagesId } from "~/kysely/types/public/Stages";
import { db } from "~/kysely/database";
import { defineRun } from "../types";

export const run = defineRun<typeof action>(async ({ pub, config, stageId }) => {
try {
await db
.with("leave-stage", (db) =>
db
.deleteFrom("PubsInStages")
.where("pubId", "=", pub.id as PubsId)
.where("stageId", "=", stageId)
)
.insertInto("PubsInStages")
.values({
pubId: pub.id as PubsId,
stageId: config.stage as StagesId,
})
.execute();
} catch (error) {
logger.error({ msg: "move", error });
return {
title: "Failed to move pub",
error: "An error occured while moving the pub",
cause: error,
};
}

logger.info({ msg: "move", pub, config });

return {
success: true,
report: "Pub moved",
data: {},
};
});
1 change: 1 addition & 0 deletions core/actions/runs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { run as pdf } from "./pdf/run";
export { run as email } from "./email/run";
export { run as log } from "./log/run";
export { run as move } from "./move/run";
export { run as pushToV6 } from "./pushToV6/run";
3 changes: 2 additions & 1 deletion core/actions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type * as Icons from "ui/icon";

import type { CorePubField } from "./corePubFields";
import type { ClientExceptionOptions } from "~/lib/serverActions";
import { StagesId } from "~/kysely/types/public/Stages";

export type ActionPubType = CorePubField[];

Expand All @@ -17,7 +18,7 @@ export type ActionPub<T extends ActionPubType> = {

export type RunProps<T extends Action> =
T extends Action<infer PT, infer AC, infer RP>
? { config: AC; pub: ActionPub<PT>; runParameters: RP }
? { config: AC; pub: ActionPub<PT>; runParameters: RP; stageId: StagesId }
: never;

export type ConfigProps<C> = {
Expand Down
1 change: 1 addition & 0 deletions core/kysely/types/public/Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ enum Action {
pdf = "pdf",
email = "email",
pushToV6 = "pushToV6",
move = "move",
}

export default Action;
4 changes: 2 additions & 2 deletions core/kysely/types/public/PublicSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import { type default as StagesTable } from "./Stages";
import { type default as UsersTable } from "./Users";

export default interface PublicSchema {
rules: RulesTable;

_prisma_migrations: PrismaMigrationsTable;

users: UsersTable;
Expand Down Expand Up @@ -83,4 +81,6 @@ export default interface PublicSchema {
action_instances: ActionInstancesTable;

PubsInStages: PubsInStagesTable;

rules: RulesTable;
}
1 change: 0 additions & 1 deletion core/next.docker.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const baseConfig = {
experimental: {
serverActions: true,
instrumentationHook: true,
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterEnum
ALTER TYPE "Action" ADD VALUE 'move';
1 change: 1 addition & 0 deletions core/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ enum Action {
pdf
email
pushToV6
move
}

model Rule {
Expand Down
5 changes: 5 additions & 0 deletions infrastructure/nginx/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ server {

location / {
proxy_pass $scheme://nextjs;

proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}

location /legacy_healthcheck {
Expand Down
6 changes: 0 additions & 6 deletions infrastructure/terraform/modules/core-services/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ locals {
db_user = aws_db_instance.core_postgres.username
db_name = aws_db_instance.core_postgres.db_name
db_host = aws_db_instance.core_postgres.address
db_sslmode = "require"
}

output "secrets" {
Expand All @@ -23,17 +22,12 @@ output "asset_uploader_key_id" {
value = aws_iam_access_key.asset_uploader.id
}

output "rds_connection_string_sans_password" {
value = "postgresql://${local.db_user}@${local.db_host}:5432/${local.db_name}?sslmode=${local.db_sslmode}"
}

output "rds_connection_components" {
value = {
user = local.db_user
database = local.db_name
host = local.db_host
port = "5432"
sslmode = local.db_sslmode
id = aws_db_instance.core_postgres.id
}
}
2 changes: 0 additions & 2 deletions infrastructure/terraform/modules/deployment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ module "service_core" {
configuration = {
container_port = 3000
environment = [
# { name = "DATABASE_URL", value = module.core_dependency_services.rds_connection_string_sans_password },
{ name = "PGUSER", value = module.core_dependency_services.rds_connection_components.user },
{ name = "PGDATABASE", value = module.core_dependency_services.rds_connection_components.database },
{ name = "PGHOST", value = module.core_dependency_services.rds_connection_components.host },
Expand Down Expand Up @@ -213,7 +212,6 @@ module "service_flock" {

configuration = {
environment = [
# { name = "DATABASE_URL", value = module.core_dependency_services.rds_connection_string_sans_password },
{ name = "PGUSER", value = module.core_dependency_services.rds_connection_components.user },
{ name = "PGDATABASE", value = module.core_dependency_services.rds_connection_components.database },
{ name = "PGHOST", value = module.core_dependency_services.rds_connection_components.host },
Expand Down
1 change: 0 additions & 1 deletion integrations/evaluations/next.docker.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const baseConfig = {
basePath: "/intg/evaluations",
assetPrefix: "/intg/evaluations",
experimental: {
serverActions: true,
instrumentationHook: true,
},
};
Expand Down
1 change: 0 additions & 1 deletion integrations/submissions/next.docker.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const baseConfig = {
basePath: "/intg/submissions",
assetPrefix: "/intg/submissions",
experimental: {
serverActions: true,
instrumentationHook: true,
},
};
Expand Down
1 change: 0 additions & 1 deletion jobs/next.docker.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const baseConfig = {
experimental: {
serverActions: true,
instrumentationHook: true,
},
};
Expand Down
1 change: 1 addition & 0 deletions packages/contracts/src/resources/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const GetPubResponseBodyBase = commonPubFields.extend({
id: z.string(),
values: z.record(JsonOutput),
assignee: User.optional(),
communityId: z.string(),
});
export type GetPubResponseBodyBase = z.infer<typeof GetPubResponseBodyBase>;

Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export {
Mail,
Menu,
MoreVertical,
MoveHorizontal,
Pencil,
Plus,
Play,
Expand Down

0 comments on commit 2f355f4

Please sign in to comment.