Documentation
¶
Index ¶
- type BulkCreateConsumptionInput
- type BulkCreateProductionOutputInput
- type BulkCreateProductionStepInput
- type BulkCreateProductionStepsEndpoint
- type BulkCreateProductionStepsRequest
- type BulkUpsertProductionStepsEndpoint
- type BulkUpsertProductionStepsRequest
- type CreateConsumptionInput
- type CreateProductionInput
- type CreateProductionStepEndpoint
- type CreateProductionStepRequest
- type CreateRateInput
- type DeleteProductionStepEndpoint
- type DeleteProductionStepRequest
- type ExportProductionStepsEndpoint
- type ExportProductionStepsRequest
- type ListProductionStepsEndpoint
- type ListProductionStepsRequest
- type ProductionStepSvc
- type ProductionStepSvcConfig
- type RetrieveProductionEndpoint
- type RetrieveProductionRequest
- type RetrieveProductionStepEndpoint
- type RetrieveProductionStepRequest
- type UpdateProductionEndpoint
- type UpdateProductionRequest
- type UpdateProductionStepEndpoint
- type UpdateProductionStepRequest
- type UpsertProductionStepInput
- type UpsertRateInput
- type UpsertStepConsumptionInput
- type UpsertStepProductionInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BulkCreateConsumptionInput ¶
type BulkCreateConsumptionInput struct {
// SKU of the consumed material.
SKU string `json:"sku" validate:"required"`
// Quantity consumed, in the item's base unit.
Measure float64 `json:"measure" validate:"required,gt=0"`
// Instructions for this consumption.
Instructions field.Optional[string] `json:"instructions,omitzero"`
}
A material the step consumes, matched to an existing item by SKU.
Materials added this way record no expected waste.
type BulkCreateProductionOutputInput ¶
type BulkCreateProductionOutputInput struct {
// SKU of the produced item.
SKU string `json:"sku" validate:"required"`
// Quantity produced, in the item's base unit.
Measure float64 `json:"measure" validate:"required,gt=0"`
}
An item the step produces, matched to an existing item by SKU.
type BulkCreateProductionStepInput ¶
type BulkCreateProductionStepInput struct {
// Display name of the production step.
//
// Used to match existing steps: if a step with this name already exists in the account, that step is updated in place instead of creating a new one.
Name string `json:"name" validate:"required"`
// Materials consumed by the step, matched by SKU.
Consumptions []BulkCreateConsumptionInput `json:"consumptions"`
// Items produced by the step, matched by SKU.
Productions []BulkCreateProductionOutputInput `json:"productions" validate:"required,min=1"`
// Labor rate in dollars per hour.
LaborRate float64 `json:"labor_rate" validate:"required,gt=0"`
// Labor time required per unit of output.
//
// Recorded as `labor_time_unit` per one base unit of the first item in `productions`.
LaborTime float64 `json:"labor_time" validate:"required,gt=0"`
// Unit that `labor_time` is expressed in.
//
// One of `hr`, `min`, `minute`, `sec`, `second`, or `day`; a row naming anything else is skipped. Labor time is read as hours when this is omitted.
LaborTimeUnit field.Optional[string] `json:"labor_time_unit,omitzero"`
// Overhead rate in dollars per hour.
OverheadRate float64 `json:"overhead_rate" validate:"required,gt=0"`
// Allowance correction factor applied to labor time in cost calculations.
//
// When omitted, no allowance adjustment is applied.
Allowances field.Optional[float64] `json:"allowances,omitzero"`
// Leveling correction factor applied to labor time in cost calculations.
//
// When omitted, no leveling adjustment is applied.
LevelingFactor field.Optional[float64] `json:"leveling_factor,omitzero"`
// Name of an existing scanning station to assign to the step.
//
// Resolved by exact name; rows referencing an unknown station are skipped.
Station field.Optional[string] `json:"station,omitzero"`
}
A production step to create or update.
type BulkCreateProductionStepsEndpoint ¶
type BulkCreateProductionStepsEndpoint struct{}
Creates or updates multiple production steps in a single request.
Rows are matched to existing steps by name. A matched step has its production outputs and consumptions replaced, and its allowances, leveling factor, and scanning station overwritten from the row — omitting any of those three resets it — while its labor rate, labor time, and overhead rate keep the values they already had. Unmatched rows are created in full, and every created or updated step is reconnected into the production flow graph from the items it produces and consumes.
Each row succeeds or fails independently: a row referencing an unknown SKU, scanning station, or labor time unit is skipped and reported in the response instead of failing the whole request.
func (*BulkCreateProductionStepsEndpoint) Materialize ¶
func (e *BulkCreateProductionStepsEndpoint) Materialize() *apiendpoint.APIEndpoint[*BulkCreateProductionStepsRequest, *apiresource.BulkCreateProductionStepsResponse]
type BulkCreateProductionStepsRequest ¶
type BulkCreateProductionStepsRequest struct {
// Production steps to create or update.
Steps []BulkCreateProductionStepInput `json:"steps" validate:"required"`
}
Request to bulk create production steps.
func (*BulkCreateProductionStepsRequest) SchemaExample ¶
func (*BulkCreateProductionStepsRequest) SchemaExample() any
type BulkUpsertProductionStepsEndpoint ¶
type BulkUpsertProductionStepsEndpoint struct{}
Creates or updates multiple production steps for the account, matched by name (case-insensitive). Validates and resolves synchronously, then writes asynchronously — 202 with a job to poll.
func (*BulkUpsertProductionStepsEndpoint) Materialize ¶
func (e *BulkUpsertProductionStepsEndpoint) Materialize() *apiendpoint.APIEndpoint[*BulkUpsertProductionStepsRequest, *apiresource.Job]
type BulkUpsertProductionStepsRequest ¶
type BulkUpsertProductionStepsRequest struct {
// Production steps to create or update, matched by name (case-insensitive) within
// the account.
ProductionSteps []UpsertProductionStepInput `json:"production_steps" validate:"required,min=1,max=1000,dive"`
}
Request to bulk upsert production steps.
func (*BulkUpsertProductionStepsRequest) SchemaExample ¶
func (*BulkUpsertProductionStepsRequest) SchemaExample() any
type CreateConsumptionInput ¶
type CreateConsumptionInput struct {
// Material the step consumes.
ItemID string `json:"item_id" validate:"required"`
// Quantity value as a decimal string.
QuantityValue string `json:"quantity_value" validate:"required"`
// Unit for `quantity_value`.
QuantityUnitID string `json:"quantity_unit_id" validate:"required"`
// Quantity expected to be lost as scrap or waste, as a decimal string.
WasteQuantityValue string `json:"waste_quantity_value" validate:"required"`
// Unit for `waste_quantity_value`.
WasteQuantityUnitID string `json:"waste_quantity_unit_id" validate:"required"`
// Instructions for how this material is consumed.
Instructions field.Optional[string] `json:"instructions,omitzero"`
}
A material a production step consumes, with its quantity and expected waste.
type CreateProductionInput ¶
type CreateProductionInput struct {
// Item the step produces.
ItemID string `json:"item_id" validate:"required"`
// Quantity value as a decimal string.
QuantityValue string `json:"quantity_value" validate:"required"`
// Unit for `quantity_value`.
QuantityUnitID string `json:"quantity_unit_id" validate:"required"`
}
The item and quantity a production step produces.
type CreateProductionStepEndpoint ¶
type CreateProductionStepEndpoint struct{}
Creates a production step with its production output, cost rates, and consumptions.
The step is automatically connected into the production flow graph based on the items it produces and consumes.
Returns a conflict error if a production step with the same name already exists in the account.
func (*CreateProductionStepEndpoint) Materialize ¶
func (e *CreateProductionStepEndpoint) Materialize() *apiendpoint.APIEndpoint[*CreateProductionStepRequest, *apiresource.ProductionStep]
type CreateProductionStepRequest ¶
type CreateProductionStepRequest struct {
// Display name of the step.
//
// Must be unique within the account.
Name string `json:"name" validate:"required,max=255"`
// Free-form notes about the step.
Notes field.Optional[string] `json:"notes,omitzero"`
// Leveling correction factor applied to labor time in cost calculations, as a decimal string.
//
// Effective labor time per unit is `labor_time × (1 + leveling_factor) × (1 + allowances)`, so `0` applies no leveling correction.
LevelingFactor string `json:"leveling_factor" validate:"required"`
// Allowance correction factor applied to labor time in cost calculations, as a decimal string.
//
// Effective labor time per unit is `labor_time × (1 + leveling_factor) × (1 + allowances)`, so `0` applies no allowance.
Allowances string `json:"allowances" validate:"required"`
// Scanning station where batches at this step are scanned.
ScanningStationID field.Optional[string] `json:"scanning_station_id,omitzero" validate:"omitempty"`
// Department responsible for this step.
DepartmentID field.Optional[string] `json:"department_id,omitzero" validate:"omitempty"`
// Cost of labor for this step, expressed as a rate of currency per unit of time (e.g. `$` per `hr`).
//
// The numerator unit must be a currency and the denominator must not be.
LaborRate CreateRateInput `json:"labor_rate" validate:"required"`
// Labor duration for this step, expressed as a rate (e.g. time per unit of output).
LaborTime CreateRateInput `json:"labor_time" validate:"required"`
// Overhead cost for this step, expressed as a rate of currency per unit of time (e.g. `$` per `hr`).
//
// The numerator unit must be a currency and the denominator must not be.
OverheadRate CreateRateInput `json:"overhead_rate" validate:"required"`
// The item and quantity this step produces.
Production CreateProductionInput `json:"production" validate:"required"`
// Materials consumed by the step.
Consumptions []CreateConsumptionInput `json:"consumptions,omitzero"`
}
Request to create a production step.
func (*CreateProductionStepRequest) SchemaExample ¶
func (*CreateProductionStepRequest) SchemaExample() any
type CreateRateInput ¶
type CreateRateInput struct {
// Value as a decimal string.
Value string `json:"value" validate:"required"`
// Unit of the rate's numerator.
NumeratorUnitID string `json:"numerator_unit_id" validate:"required"`
// Unit of the rate's denominator.
DenominatorUnitID string `json:"denominator_unit_id" validate:"required"`
}
A rate, expressed as a value together with the units of its numerator and denominator (for example, `25.00` `$` per `hr`).
type DeleteProductionStepEndpoint ¶
type DeleteProductionStepEndpoint struct{}
Deletes a production step.
The step's connections to its upstream and downstream steps are removed as part of the deletion, so the neighboring steps are left unconnected to each other. Deleting a step that was already deleted returns an already-deleted error rather than a not-found error.
func (*DeleteProductionStepEndpoint) Materialize ¶
func (e *DeleteProductionStepEndpoint) Materialize() *apiendpoint.APIEndpoint[*DeleteProductionStepRequest, *apiresource.EmptyResource]
type DeleteProductionStepRequest ¶
type DeleteProductionStepRequest struct {
// Production step ID.
ProductionStepID string `path:"id" validate:"required"`
}
Request to delete a production step.
type ExportProductionStepsEndpoint ¶
type ExportProductionStepsEndpoint struct{}
Starts an export of every matching production step and returns the job that tracks it; the file lists a step's consumptions one per row.
func (*ExportProductionStepsEndpoint) Materialize ¶
func (e *ExportProductionStepsEndpoint) Materialize() *apiendpoint.APIEndpoint[*ExportProductionStepsRequest, *apiresource.Job]
type ExportProductionStepsRequest ¶
type ExportProductionStepsRequest struct {
// Free-text search term matched against production step names.
Query *string `json:"q"`
}
Filters which production steps land in the exported file.
func (*ExportProductionStepsRequest) SchemaExample ¶
func (*ExportProductionStepsRequest) SchemaExample() any
type ListProductionStepsEndpoint ¶
type ListProductionStepsEndpoint struct{}
Returns a paginated list of production steps for the current account, newest first.
The `q` search term matches against the step name. Filters combine with AND, while the values within a single filter combine with OR.
func (*ListProductionStepsEndpoint) Materialize ¶
func (e *ListProductionStepsEndpoint) Materialize() *apiendpoint.APIEndpoint[*ListProductionStepsRequest, *apiresource.List[apiresource.ProductionStep]]
type ListProductionStepsRequest ¶
type ListProductionStepsRequest struct {
apiresource.PaginationRequest
// Only return steps that produce or consume any of these items.
ItemIDs []string `query:"item_ids"`
// Only return steps with any of these machines assigned.
MachineIDs []string `query:"machine_ids"`
// Only return steps assigned to any of these scanning stations.
ScanningStationIDs []string `query:"scanning_station_ids"`
// Only return steps that are directly fed by any of these upstream steps.
InputStepIDs []string `query:"input_step_ids"`
// Only return steps that feed directly into any of these downstream steps.
OutputStepIDs []string `query:"output_step_ids"`
// Only return steps created on or after this timestamp (inclusive).
StartDate *time.Time `query:"starts_at"`
// Only return steps created on or before this timestamp (inclusive).
EndDate *time.Time `query:"ends_at"`
}
Request to list production steps.
type ProductionStepSvc ¶
type ProductionStepSvc interface {
ListProductionSteps(ctx context.Context, req *ListProductionStepsRequest) (*apiresource.List[apiresource.ProductionStep], *apierror.APIError)
ExportProductionSteps(ctx context.Context, req *ExportProductionStepsRequest) (*apiresource.Job, *apierror.APIError)
GetProductionStep(ctx context.Context, req *RetrieveProductionStepRequest) (*apiresource.ProductionStep, *apierror.APIError)
CreateProductionStep(ctx context.Context, req *CreateProductionStepRequest) (*apiresource.ProductionStep, *apierror.APIError)
UpdateProductionStep(ctx context.Context, req *UpdateProductionStepRequest) (*apiresource.ProductionStep, *apierror.APIError)
DeleteProductionStep(ctx context.Context, req *DeleteProductionStepRequest) (*apiresource.EmptyResource, *apierror.APIError)
GetProduction(ctx context.Context, req *RetrieveProductionRequest) (*apiresource.ProductionOutput, *apierror.APIError)
UpdateProduction(ctx context.Context, req *UpdateProductionRequest) (*apiresource.ProductionOutput, *apierror.APIError)
BulkCreateProductionSteps(ctx context.Context, req *BulkCreateProductionStepsRequest) (*apiresource.BulkCreateProductionStepsResponse, *apierror.APIError)
BulkUpsertProductionSteps(ctx context.Context, req *BulkUpsertProductionStepsRequest) (*apiresource.Job, *apierror.APIError)
}
func NewProductionStepSvc ¶
func NewProductionStepSvc(config *ProductionStepSvcConfig) ProductionStepSvc
type ProductionStepSvcConfig ¶
type ProductionStepSvcConfig struct {
// CoreClient (required) is the core-service production-step gRPC client.
CoreClient pb.CoreProductionStepServiceClient
}
type RetrieveProductionEndpoint ¶
type RetrieveProductionEndpoint struct{}
Returns a production output by ID within a production step.
func (*RetrieveProductionEndpoint) Materialize ¶
func (e *RetrieveProductionEndpoint) Materialize() *apiendpoint.APIEndpoint[*RetrieveProductionRequest, *apiresource.ProductionOutput]
type RetrieveProductionRequest ¶
type RetrieveProductionRequest struct {
// Production step ID.
ProductionStepID string `path:"production_step_id" validate:"required"`
// Production ID.
ProductionID string `path:"id" validate:"required"`
}
Request to retrieve a production output.
type RetrieveProductionStepEndpoint ¶
type RetrieveProductionStepEndpoint struct{}
Returns a production step by ID.
func (*RetrieveProductionStepEndpoint) Materialize ¶
func (e *RetrieveProductionStepEndpoint) Materialize() *apiendpoint.APIEndpoint[*RetrieveProductionStepRequest, *apiresource.ProductionStep]
type RetrieveProductionStepRequest ¶
type RetrieveProductionStepRequest struct {
// Production step ID.
ProductionStepID string `path:"id" validate:"required"`
}
Request to retrieve a production step.
type UpdateProductionEndpoint ¶
type UpdateProductionEndpoint struct{}
Partially updates a production output within a production step.
func (*UpdateProductionEndpoint) Materialize ¶
func (e *UpdateProductionEndpoint) Materialize() *apiendpoint.APIEndpoint[*UpdateProductionRequest, *apiresource.ProductionOutput]
type UpdateProductionRequest ¶
type UpdateProductionRequest struct {
// Production step ID.
ProductionStepID string `path:"production_step_id" validate:"required"`
// Production ID.
ProductionID string `path:"id" validate:"required"`
// Item this step produces.
//
// Changing the item recomputes all of the step's connections in the production flow graph from the items it now produces and consumes, which discards connections that were made manually.
ItemID field.Optional[string] `json:"item_id,omitzero" validate:"omitempty"`
// Quantity value as a decimal string.
//
// Ignored unless `quantity_unit_id` is also provided.
QuantityValue field.Optional[string] `json:"quantity_value,omitzero"`
// Unit ID for `quantity_value`.
//
// Ignored unless `quantity_value` is also provided.
QuantityUnitID field.Optional[string] `json:"quantity_unit_id,omitzero" validate:"omitempty"`
}
Request to update a production output.
func (*UpdateProductionRequest) SchemaExample ¶
func (*UpdateProductionRequest) SchemaExample() any
type UpdateProductionStepEndpoint ¶
type UpdateProductionStepEndpoint struct{}
Partially updates a production step.
Returns a conflict error if another production step in the account already uses the requested name.
func (*UpdateProductionStepEndpoint) Materialize ¶
func (e *UpdateProductionStepEndpoint) Materialize() *apiendpoint.APIEndpoint[*UpdateProductionStepRequest, *apiresource.ProductionStep]
type UpdateProductionStepRequest ¶
type UpdateProductionStepRequest struct {
// Production step ID.
ProductionStepID string `path:"id" validate:"required"`
// New display name.
//
// Must be unique within the account.
Name field.Optional[string] `json:"name,omitzero" validate:"omitempty,max=255"`
// Leveling correction factor applied to labor time in cost calculations, as a decimal string.
LevelingFactor field.Optional[string] `json:"leveling_factor,omitzero"`
// Allowance correction factor applied to labor time in cost calculations, as a decimal string.
Allowances field.Optional[string] `json:"allowances,omitzero"`
// Scanning station where batches at this step are scanned.
ScanningStationID field.Optional[string] `json:"scanning_station_id,omitzero" validate:"omitempty"`
}
Request to update a production step.
func (*UpdateProductionStepRequest) SchemaExample ¶
func (*UpdateProductionStepRequest) SchemaExample() any
type UpsertProductionStepInput ¶
type UpsertProductionStepInput struct {
// Display name of the step. Rows are matched against existing production steps by
// name (case-insensitive): a match updates that step, no match creates a new one.
Name string `json:"name" validate:"required,max=255"`
// Free-form notes about the step. Preserved when omitted on update.
Notes field.Optional[string] `json:"notes,omitzero"`
// Leveling correction factor applied to labor time in cost calculations, as a
// decimal string. Defaults to `0` on create; preserved when omitted on update.
LevelingFactor field.Optional[string] `json:"leveling_factor,omitzero" format:"decimal"`
// Allowance correction factor applied to labor time in cost calculations, as a
// decimal string. Defaults to `0` on create; preserved when omitted on update.
Allowances field.Optional[string] `json:"allowances,omitzero" format:"decimal"`
// Scanning station this step reports at, referenced by `id` or `name`. Preserved when
// omitted on update.
ScanningStation field.Optional[apirequest.ObjectIdentifier] `json:"scanning_station,omitzero"`
// Department this step belongs to, referenced by `id` or `name`. Create-only: a row
// updating an existing step must omit it or state the step's current department.
Department field.Optional[apirequest.ObjectIdentifier] `json:"department,omitzero"`
// Cost of labor for this step, expressed as a rate of currency per unit of time
// (e.g. `$` per `hr`). The numerator unit must be a currency and the denominator
// must not be. On update a fresh rate is written.
LaborRate UpsertRateInput `json:"labor_rate" validate:"required"`
// Labor duration for this step, expressed as a rate (e.g. time per unit of
// output). On update a fresh rate is written.
LaborTime UpsertRateInput `json:"labor_time" validate:"required"`
// Overhead cost for this step, expressed as a rate of currency per unit of time
// (e.g. `$` per `hr`). The numerator unit must be a currency and the denominator
// must not be. On update a fresh rate is written.
OverheadRate UpsertRateInput `json:"overhead_rate" validate:"required"`
// The item and quantity this step produces. Replaced on update.
Production UpsertStepProductionInput `json:"production" validate:"required"`
// Materials consumed by the step. Replaced wholesale on update. Flow DAG edges
// are derived automatically from item flows: a step consuming an item is linked
// under the steps producing it.
Consumptions []UpsertStepConsumptionInput `json:"consumptions" validate:"dive"`
}
Input for a single production step in a bulk upsert operation.
type UpsertRateInput ¶
type UpsertRateInput struct {
// Value as a decimal string.
Value string `json:"value" validate:"required" format:"decimal"`
// Numerator unit (for example, `$`), referenced by `id`, `name`, or `abbreviation`.
NumeratorUnit apirequest.UnitIdentifier `json:"numerator_unit" validate:"required"`
// Denominator unit (for example, `hr`), referenced by `id`, `name`, or `abbreviation`.
DenominatorUnit apirequest.UnitIdentifier `json:"denominator_unit" validate:"required"`
}
Rate in a bulk upsert operation: a decimal value over a numerator and denominator unit.
type UpsertStepConsumptionInput ¶
type UpsertStepConsumptionInput struct {
// Item consumed by the step, referenced by `id` or `sku`.
Item apirequest.ItemIdentifier `json:"item" validate:"required"`
// Quantity value as a decimal string.
QuantityValue string `json:"quantity_value" validate:"required" format:"decimal"`
// Unit for `quantity_value`, referenced by `id`, `name`, or `abbreviation`.
QuantityUnit apirequest.UnitIdentifier `json:"quantity_unit" validate:"required"`
// Quantity expected to be lost as scrap or waste, as a decimal string. Defaults to zero.
WasteQuantityValue field.Optional[string] `json:"waste_quantity_value,omitzero" format:"decimal"`
// Unit for `waste_quantity_value`, referenced by `id`, `name`, or `abbreviation`.
// Defaults to `quantity_unit`.
WasteQuantityUnit field.Optional[apirequest.UnitIdentifier] `json:"waste_quantity_unit,omitzero"`
// Instructions for how this material is consumed.
Instructions field.Optional[string] `json:"instructions,omitzero"`
}
Material consumption in a bulk upsert operation.
type UpsertStepProductionInput ¶
type UpsertStepProductionInput struct {
// Item produced by the step, referenced by `id` or `sku`.
Item apirequest.ItemIdentifier `json:"item" validate:"required"`
// Quantity value as a decimal string.
QuantityValue string `json:"quantity_value" validate:"required" format:"decimal"`
// Unit for `quantity_value`, referenced by `id`, `name`, or `abbreviation`.
QuantityUnit apirequest.UnitIdentifier `json:"quantity_unit" validate:"required"`
}
Production output in a bulk upsert operation.
Source Files
¶
- endpoint_bulk_create_production_steps.go
- endpoint_bulk_upsert_production_steps.go
- endpoint_create_production_step.go
- endpoint_delete_production_step.go
- endpoint_export_production_steps.go
- endpoint_list_production_steps.go
- endpoint_retrieve_production.go
- endpoint_retrieve_production_step.go
- endpoint_update_production.go
- endpoint_update_production_step.go
- service.go