main = "src/lib/worker.ts"
compatibility_date = "2023-10-16"

[dev]
port = 8787

# these migrations are append-only. you can't change them. if you do need to change something, do so
# by creating new migrations
[[migrations]]
tag = "v1" # Should be unique for each entry
new_classes = ["TLDrawDurableObject"]

[[migrations]]
tag = "v2" 
new_classes = ["TLProWorkspaceDurableObject"]

[[migrations]]
tag = "v3"
deleted_classes = ["TLProWorkspaceDurableObject"]

[[analytics_engine_datasets]]
binding = "MEASURE"

#################### Environment names ####################
# dev should never actually get deployed anywhere
[env.dev]
name = "dev-tldraw-multiplayer"

# we don't have a hard-coded name for preview. we instead have to generate it at build time and append it to this file.

# staging is the same as a preview on main:
[env.staging]
name = "main-tldraw-multiplayer"

# production gets the proper name
[env.production]
name = "tldraw-multiplayer"

#################### Durable objects ####################
# durable objects have the same configuration in all environments:
[[env.dev.durable_objects.bindings]]
name = "TLDR_DOC"
class_name = "TLDrawDurableObject"

[durable_objects]
bindings = [
  { name = "TLDR_DOC", class_name = "TLDrawDurableObject" },
]

[[env.preview.durable_objects.bindings]]
name = "TLDR_DOC"
class_name = "TLDrawDurableObject"

[[env.staging.durable_objects.bindings]]
name = "TLDR_DOC"
class_name = "TLDrawDurableObject"

[[env.production.durable_objects.bindings]]
name = "TLDR_DOC"
class_name = "TLDrawDurableObject"

#################### Analytics engine ####################
# durable objects have the same configuration in all environments:
[[env.dev.analytics_engine_datasets]]
binding = "MEASURE"

[[env.preview.analytics_engine_datasets]]
binding = "MEASURE"

[[env.staging.analytics_engine_datasets]]
binding = "MEASURE"

[[env.production.analytics_engine_datasets]]
binding = "MEASURE"

#################### Rooms R2 bucket ####################
# in dev, we write to the preview bucket and need a `preview_bucket_name`
[[env.dev.r2_buckets]]
binding = "ROOMS"
bucket_name = "rooms-preview"
preview_bucket_name = "rooms-preview"

# in preview and staging we write to the preview bucket
[[env.preview.r2_buckets]]
binding = "ROOMS"
bucket_name = "rooms-preview"

[[env.staging.r2_buckets]]
binding = "ROOMS"
bucket_name = "rooms-preview"

# in production, we write to the main bucket
[[env.production.r2_buckets]]
binding = "ROOMS"
bucket_name = "rooms"

#################### Rooms History bucket ####################
# in dev, we write to the preview bucket and need a `preview_bucket_name`
[[env.dev.r2_buckets]]
binding = "ROOMS_HISTORY_EPHEMERAL"
bucket_name = "rooms-history-ephemeral-preview"
preview_bucket_name = "rooms-history-ephemeral-preview"

# in preview and staging we write to the preview bucket
[[env.preview.r2_buckets]]
binding = "ROOMS_HISTORY_EPHEMERAL"
bucket_name = "rooms-history-ephemeral-preview"

[[env.staging.r2_buckets]]
binding = "ROOMS_HISTORY_EPHEMERAL"
bucket_name = "rooms-history-ephemeral-preview"

# in production, we write to the main bucket
[[env.production.r2_buckets]]
binding = "ROOMS_HISTORY_EPHEMERAL"
bucket_name = "rooms-history-ephemeral"
