# proto-file: metacore/api/v1/schema.proto # proto-message: metacore.api.v1.Schema # The lifecycle of a product, from its design to the day it leaves the range. # A message of metacore.api.v1.Schema, in the text format of Protocol Buffers. # # A product is one record, by its code: # # identity global what the product is # specification global how it is made: a change waits for a second person # compliance market what each market asks of it # availability market when it is on sale there, by period # # A line of the bill of materials is a record of its own, by product and # position, and a part is one by its number. Only the role costing reads what # a part costs. # # A release goes through a workflow: engineering and compliance both sign it # off, and then a handler puts the product on sale. A gate rule judges each # change of the bill of materials, and a source brings the parts in from the # ERP every night. # # The org declares the scope market under global before the first deployment. entities { name: "product" key { name: "code" type: FIELD_TYPE_TEXT } layers { name: "identity" scope: "global" fields { name: "name" type: FIELD_TYPE_TEXT required: true min_length: 2 max_length: 120 exposed: true } fields { name: "family" type: FIELD_TYPE_REFERENCE reference { entity: "family" } } fields { name: "kind" type: FIELD_TYPE_TEXT allowed_values: "new" allowed_values: "revision" allowed_values: "carry_over" } } layers { name: "specification" scope: "global" second_person: true hold_timeout { seconds: 432000 } fields { name: "revision" type: FIELD_TYPE_TEXT pattern: "[A-Z][0-9]{2}" } fields { name: "description" type: FIELD_TYPE_TEXT } fields { name: "weight_grams" type: FIELD_TYPE_INTEGER least { integer: 0 } } fields { name: "materials" type: FIELD_TYPE_TEXT list: true max_length: 60 } fields { name: "drawing" type: FIELD_TYPE_FILE file { media_types: FILE_MEDIA_TYPE_PDF max_bytes: 52428800 } } } layers { name: "compliance" scope: "market" fields { name: "status" type: FIELD_TYPE_TEXT allowed_values: "pending" allowed_values: "cleared" allowed_values: "blocked" } fields { name: "cleared_on" type: FIELD_TYPE_DATE } fields { name: "certificate" type: FIELD_TYPE_FILE file { media_types: FILE_MEDIA_TYPE_PDF max_bytes: 20971520 } } } # A stage holds over a period that its change names: on sale from a day, # last orders for the quarter after it. layers { name: "availability" scope: "market" dated: true fields { name: "stage" type: FIELD_TYPE_TEXT allowed_values: "on_sale" allowed_values: "last_orders" allowed_values: "withdrawn" exposed: true } } } entities { name: "bom_line" key { name: "product" type: FIELD_TYPE_TEXT } key { name: "position" type: FIELD_TYPE_INTEGER } layers { name: "main" scope: "global" fields { name: "part" type: FIELD_TYPE_REFERENCE required: true reference { entity: "part" carries: "name" } } fields { name: "quantity" type: FIELD_TYPE_DECIMAL decimal_places: 3 least { decimal: "0" } } fields { name: "unit" type: FIELD_TYPE_TEXT allowed_values: "piece" allowed_values: "metre" allowed_values: "gram" } } } entities { name: "part" key { name: "number" type: FIELD_TYPE_TEXT } layers { name: "main" scope: "global" fields { name: "name" type: FIELD_TYPE_TEXT required: true } fields { name: "supplier" type: FIELD_TYPE_TEXT } fields { name: "cost" type: FIELD_TYPE_DECIMAL decimal_places: 4 least { decimal: "0" } restricted { read_roles: "costing" write_roles: "costing" } } } } entities { name: "family" key { name: "code" type: FIELD_TYPE_TEXT } layers { name: "main" scope: "global" fields { name: "label" type: FIELD_TYPE_TEXT required: true } } } roles { name: "designer" permissions { operation: OPERATION_READ entity: "product" } permissions { operation: OPERATION_READ entity: "bom_line" } permissions { operation: OPERATION_READ entity: "part" } permissions { operation: OPERATION_READ entity: "family" } permissions { operation: OPERATION_CHANGE entity: "product" layer: "identity" } permissions { operation: OPERATION_CHANGE entity: "product" layer: "specification" } permissions { operation: OPERATION_CHANGE entity: "bom_line" layer: "main" } permissions { operation: OPERATION_CHANGE entity: "family" layer: "main" } permissions { operation: OPERATION_START workflow: "release" } } roles { name: "engineer" permissions { operation: OPERATION_READ entity: "product" } permissions { operation: OPERATION_READ entity: "bom_line" } permissions { operation: OPERATION_READ entity: "part" } permissions { operation: OPERATION_DECIDE entity: "product" layer: "specification" } permissions { operation: OPERATION_GO_BACK entity: "product" layer: "specification" } permissions { operation: OPERATION_DECIDE entity: "bom_line" layer: "main" } } roles { name: "compliance" permissions { operation: OPERATION_READ entity: "product" } permissions { operation: OPERATION_CHANGE entity: "product" layer: "compliance" } } roles { name: "costing" permissions { operation: OPERATION_READ entity: "part" } permissions { operation: OPERATION_READ entity: "bom_line" } permissions { operation: OPERATION_CHANGE entity: "part" layer: "main" } } roles { name: "planner" permissions { operation: OPERATION_READ entity: "product" } permissions { operation: OPERATION_CHANGE entity: "product" layer: "availability" } } atoms { name: "bom_check" connection: "engineering" timeout { seconds: 10 } gate_rule { layer { entity: "bom_line" layer: "main" } } } atoms { name: "release" connection: "engineering" timeout { seconds: 30 } handler { inputs { name: "code" type: FIELD_TYPE_TEXT required: true } outcomes: "released" outcomes: "blocked" changes { entity: "product" layer: "availability" } events: "product_released" } } atoms { name: "import_parts" connection: "erp" timeout { seconds: 60 } source { changes { entity: "part" layer: "main" } } } events { name: "product_released" entity: "product" exposed: true } triggers { name: "nightly_parts" schedule { cron: "0 3 * * *" time_zone: "UTC" } atom: "import_parts" } # Engineering and compliance sign a release off together: one of them can # send it back, and only both move it on. Then the handler puts the product # on sale, or blocks it and sends it back to them. workflows { name: "release" inputs { name: "code" type: FIELD_TYPE_TEXT required: true } first_stage: "sign_off" stages { name: "sign_off" person { roles { role: "engineer" } roles { role: "compliance" } timeout { seconds: 604800 } outcomes: "approved" outcomes: "sent_back" agreed_outcome: "approved" second_person: true } transitions { outcome: "approved" next_stage: "go_live" } transitions { outcome: "sent_back" } } stages { name: "go_live" handler: "release" transitions { outcome: "released" } transitions { outcome: "blocked" next_stage: "sign_off" } } }