Skip to content
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
7 changes: 1 addition & 6 deletions packages/contracts/src/http/groups/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@ import {
completedInviteOnboardingSchema,
completeInviteOnboardingSchema,
completeOnboardingSchema,
onboardingStatusSchema,
} from "../../onboarding.ts";
import { refused } from "../errors.ts";
import { Session } from "../middleware.ts";

/** Whether the signed-in person has finished setting up, and marking that they have. */
/** The signed-in person finishing setting up a workspace, or joining one by invitation. */
export class OnboardingApi extends HttpApiGroup.make("onboarding")
.add(
HttpApiEndpoint.get("status", "/onboarding", {
success: onboardingStatusSchema,
}),
HttpApiEndpoint.post("complete", "/onboarding/complete", {
payload: completeOnboardingSchema,
success: onboardingStatusSchema,
error: refused,
}),
HttpApiEndpoint.post("completeInvite", "/onboarding/complete-invite", {
Expand Down
9 changes: 3 additions & 6 deletions packages/contracts/src/me.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { Schema } from "effect";
import { sessionUserSchema } from "./api.ts";
import { workspaceSchema } from "./membership.ts";
import { onboardingStatusSchema } from "./onboarding.ts";

/**
* Who the caller is, whether they have finished setting up, and their
* workspaces: what the web app needs before it can draw anything, in one
* answer rather than three requests, the second and third of which would wait
* for the first to say they are signed in.
* Who the caller is and their workspaces: what the web app needs before it can
* draw anything, in one answer rather than two requests, the second of which
* would wait for the first to say they are signed in.
*/
export const meSchema = Schema.Struct({
user: sessionUserSchema,
onboarding: onboardingStatusSchema,
workspaces: Schema.Array(workspaceSchema),
});

Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/src/membership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export const workspaceSchema = Schema.Struct({
* know must not stop the workspace loading.
*/
timeZone: Schema.String,
/** When its setup was finished, or null while it is still being set up. */
setupCompletedAt: Schema.NullOr(isoTimestampSchema),
});
export type Workspace = typeof workspaceSchema.Type;

Expand Down
3 changes: 0 additions & 3 deletions packages/contracts/src/onboarding.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Schema } from "effect";
import { uuidSchema } from "./uuid.ts";

export const onboardingStatusSchema = Schema.Struct({ completed: Schema.Boolean });
export type OnboardingStatus = typeof onboardingStatusSchema.Type;

export const completeOnboardingSchema = Schema.Struct({
workspaceId: uuidSchema,
podId: uuidSchema,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE "workspace" ADD COLUMN "setup_completed_at" timestamp with time zone;--> statement-breakpoint
-- Every workspace made before this was recorded counts as set up, as of when it was made.
UPDATE "workspace" SET "setup_completed_at" = "created_at";--> statement-breakpoint
ALTER TABLE "user" DROP COLUMN "onboarding_completed_at";
Loading
Loading