← Workspace Academy

Workspace Academy · 4 / 5

Declare a guarded note action

Describe a write boundary with an identity restriction before exposing a form.

YOUR TASK

Make this happen

3 steps
  1. Add the addCustomerNote action handler and an entityId constraint with minLength 1. Attach the handler to the document; its server implementation remains a platform integration step.

  2. Keep the working capabilities from the previous lesson and connect the new pieces to the same solution.

  3. Check the complete solution, then inspect any unmet requirements.

This step starts with the earlier solution and one new challenge. Each lesson keeps its own draft.

Read the starter files

main.cococo

workspace_document "handoff" {
  id = "customer-desk"
  title = "Customer desk"
  role = "Customer service"
  domains = "customer"
  children = [workspace_state.selection, workspace_panel.directory, workspace_panel.details]
}

directory.cococo

workspace_state "selection" {
  component = "state"
  name = "selectedCustomerId"
  value = ""
}
workspace_query_graphql "customers" {
  component = "query-graphql"
  source = "query CustomerDirectory { customers: listCustomers(first: 50) { edges { node { id name } } } }"
}
workspace_record_list "customers" {
  component = "record-list"
  id = "customer-list"
  bindings = { "for" = "customers.edges", "as" = "customer" }
  key = "customer.node.id"
  primary = "customer.node.name"
  select = "selectedCustomerId"
}
workspace_panel "directory" {
  component = "panel"
  id = "directory"
  title = "Customers"
  children = [workspace_query_graphql.customers, workspace_record_list.customers]
}

details.cococo

workspace_query_magicquery "customer" {
  component = "query-magicquery"
  noun = "customer"
  identifierState = "selectedCustomerId"
}
workspace_detail_field "email" {
  component = "detail-field"
  label = "Email"
  bindings = { "value" = "getCustomer.email" }
}
workspace_record_detail "customer" {
  component = "record-detail"
  id = "customer-profile"
  bindings = { "text" = "getCustomer.name" }
  children = [workspace_detail_field.email]
}
workspace_panel "details" {
  component = "panel"
  id = "details"
  title = "Customer profile"
  children = [workspace_query_magicquery.customer, workspace_record_detail.customer]
}

notes.cococo

workspace_handler_constraint "customer" {
  component = "handler-constraint"
  # TODO: add path — see the task above.
  # TODO: add minLength — see the task above.
}

workspace_handler "addNote" {
  component = "handler"
  name = "addCustomerNote"
  # TODO: add mode — see the task above.
  # TODO: add children — see the task above.
}
Supplied supporting files

Reference: workspaces · getting-startedworkspaces · binding-stateworkspaces · queriesworkspaces · formsworkspaces · server-luaworkspaces · publication