Skip to content
Open
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
6 changes: 4 additions & 2 deletions packages/database/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const nanoId = customType<{ data: string; notNull: true }>({
return `varchar(${nanoIdLength})`;
},
});
// TODO: This will replace `nanoId` in: https://github.com/CapSoftware/Cap/pull/1105
const nanoIdRequired = (name: string) =>
varchar(name, { length: nanoIdLength }).notNull();

const nanoIdNullable = customType<{ data: string; notNull: false }>({
dataType() {
Expand Down Expand Up @@ -247,8 +250,7 @@ export const videos = mysqlTable(
{
id: nanoId("id").notNull().primaryKey().unique().$type<Video.VideoId>(),
ownerId: nanoId("ownerId").notNull(),
// TODO: make this non-null
orgId: nanoIdNullable("orgId"),
orgId: nanoIdRequired("orgId"),
name: varchar("name", { length: 255 }).notNull().default("My Video"),
bucket: nanoIdNullable("bucket").$type<S3Bucket.S3BucketId>(),
// in seconds
Expand Down
2 changes: 1 addition & 1 deletion packages/web-backend/src/Loom/ImportVideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const LoomImportVideoLive = LoomImportVideo.toLayer(

const videoId = yield* videos.create({
ownerId: payload.cap.userId,
orgId: Option.some(payload.cap.orgId),
orgId: payload.cap.orgId,
bucketId: customBucketId,
source: { type: "desktopMP4" as const },
name: payload.loom.video.name,
Expand Down
6 changes: 3 additions & 3 deletions packages/web-backend/src/Videos/VideosRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class VideosRepo extends Effect.Service<VideosRepo>()("VideosRepo", {
{
...data,
id,
orgId: Option.getOrNull(data.orgId ?? Option.none()),
orgId: data.orgId,
bucket: Option.getOrNull(data.bucketId ?? Option.none()),
metadata: Option.getOrNull(data.metadata ?? Option.none()),
transcriptionStatus: Option.getOrNull(
Expand All @@ -72,12 +72,12 @@ export class VideosRepo extends Effect.Service<VideosRepo>()("VideosRepo", {
]),
];

if (data.importSource && Option.isSome(data.orgId))
if (data.importSource)
promises.push(
db.insert(Db.importedVideos).values([
{
id,
orgId: data.orgId.value,
orgId: data.orgId,
source: data.importSource.source,
sourceId: data.importSource.id,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/web-domain/src/Video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type VideoId = typeof VideoId.Type;
export class Video extends Schema.Class<Video>("Video")({
id: VideoId,
ownerId: Schema.String,
orgId: Schema.OptionFromNullOr(Schema.String),
orgId: Schema.String,
name: Schema.String,
public: Schema.Boolean,
source: Schema.Struct({
Expand Down
Loading