Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(properties): tag system (backend) (#4386)
gbirman00b821f387e2
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/addStringOptionRequest.ts b/js/app/packages/service-clients/service-properties/generated/schemas/addStringOptionRequest.tsindex d3ad7a9202..8f1a6071de 100644--- a/js/app/packages/service-clients/service-properties/generated/schemas/addStringOptionRequest.ts+++ b/js/app/packages/service-clients/service-properties/generated/schemas/addStringOptionRequest.ts@@ -4,11 +4,13 @@* properties_service* OpenAPI spec version: 0.1.0*/+import type { AddStringOptionRequestColor } from './addStringOptionRequestColor';/*** Type-safe request to add a string option to a SelectString property.*/export interface AddStringOptionRequest {+ color?: AddStringOptionRequestColor;display_order: number;value: string;}diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/addStringOptionRequestColor.ts b/js/app/packages/service-clients/service-properties/generated/schemas/addStringOptionRequestColor.tsnew file mode 100644index 0000000000..5d953bb110--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/addStringOptionRequestColor.ts@@ -0,0 +1,8 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */++export type AddStringOptionRequestColor = string | null;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/dataType.ts b/js/app/packages/service-clients/service-properties/generated/schemas/dataType.tsindex 63669e6314..ce27febacf 100644--- a/js/app/packages/service-clients/service-properties/generated/schemas/dataType.ts+++ b/js/app/packages/service-clients/service-properties/generated/schemas/dataType.ts@@ -18,6 +18,7 @@ export const DataType = {STRING: 'STRING',SELECT_NUMBER: 'SELECT_NUMBER',SELECT_STRING: 'SELECT_STRING',+ TAG: 'TAG',ENTITY: 'ENTITY',LINK: 'LINK',} as const;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/ensureTagSetRequest.ts b/js/app/packages/service-clients/service-properties/generated/schemas/ensureTagSetRequest.tsnew file mode 100644index 0000000000..9ef65d8748--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/ensureTagSetRequest.ts@@ -0,0 +1,14 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */+import type { TagScope } from './tagScope';++/**+ * Request to provision (get-or-create) the caller's tag set for a scope.+ */+export interface EnsureTagSetRequest {+ scope: TagScope;+}diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/entityPropertyWithDefinitionResponse.ts b/js/app/packages/service-clients/service-properties/generated/schemas/entityPropertyWithDefinitionResponse.tsindex 707b5b1af9..a3a9807c42 100644--- a/js/app/packages/service-clients/service-properties/generated/schemas/entityPropertyWithDefinitionResponse.ts+++ b/js/app/packages/service-clients/service-properties/generated/schemas/entityPropertyWithDefinitionResponse.ts@@ -8,13 +8,13 @@import type { EntityPropertyResponse } from './entityPropertyResponse';import type { EntityPropertyWithDefinitionResponseOptions } from './entityPropertyWithDefinitionResponseOptions';import type { EntityPropertyWithDefinitionResponseValue } from './entityPropertyWithDefinitionResponseValue';-import type { PropertyDefinitionResponse } from './propertyDefinitionResponse';+import type { PropertyDefinitionDetailResponse } from './propertyDefinitionDetailResponse';/*** Entity property with definition response (API representation).*/export interface EntityPropertyWithDefinitionResponse {- definition: PropertyDefinitionResponse;+ definition: PropertyDefinitionDetailResponse;options?: EntityPropertyWithDefinitionResponseOptions;property: EntityPropertyResponse;value?: EntityPropertyWithDefinitionResponseValue;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponse.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponse.tsnew file mode 100644index 0000000000..5c278c3ff9--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponse.ts@@ -0,0 +1,15 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */++import type { PropertyDefinitionDetailResponseAllOf } from './propertyDefinitionDetailResponseAllOf';+import type { PropertyOwner } from './propertyOwner';++/**+ * Property definition response (API representation).+ */+export type PropertyDefinitionDetailResponse = PropertyOwner &+ PropertyDefinitionDetailResponseAllOf;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponseAllOf.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponseAllOf.tsnew file mode 100644index 0000000000..1dcd7308a4--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponseAllOf.ts@@ -0,0 +1,25 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */++import type { DataType } from './dataType';+import type { PropertyDefinitionDetailResponseAllOfCreatedAt } from './propertyDefinitionDetailResponseAllOfCreatedAt';+import type { PropertyDefinitionDetailResponseAllOfSpecificEntityType } from './propertyDefinitionDetailResponseAllOfSpecificEntityType';+import type { PropertyDefinitionDetailResponseAllOfUpdatedAt } from './propertyDefinitionDetailResponseAllOfUpdatedAt';++export type PropertyDefinitionDetailResponseAllOf = {+ createdAt?: PropertyDefinitionDetailResponseAllOfCreatedAt;+ dataType: DataType;+ displayName: string;+ id: string;+ /** Flag to indicate if this is a system-generated metadata property */+ isMetadata: boolean;+ isMultiSelect: boolean;+ /** Flag to indicate if this is a system property (managed by the system) */+ isSystem: boolean;+ specificEntityType?: PropertyDefinitionDetailResponseAllOfSpecificEntityType;+ updatedAt?: PropertyDefinitionDetailResponseAllOfUpdatedAt;+};diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponseAllOfCreatedAt.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponseAllOfCreatedAt.tsnew file mode 100644index 0000000000..9dea13e482--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponseAllOfCreatedAt.ts@@ -0,0 +1,8 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */++export type PropertyDefinitionDetailResponseAllOfCreatedAt = string | null;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponseAllOfSpecificEntityType.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponseAllOfSpecificEntityType.tsnew file mode 100644index 0000000000..6fb8c6845e--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponseAllOfSpecificEntityType.ts@@ -0,0 +1,10 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */+import type { EntityType } from './entityType';++export type PropertyDefinitionDetailResponseAllOfSpecificEntityType =+ null | EntityType;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponseAllOfUpdatedAt.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponseAllOfUpdatedAt.tsnew file mode 100644index 0000000000..7f4cc43d80--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionDetailResponseAllOfUpdatedAt.ts@@ -0,0 +1,8 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */++export type PropertyDefinitionDetailResponseAllOfUpdatedAt = string | null;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionWithOptionsResponse.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionWithOptionsResponse.tsindex f357e8c9eb..64988cab2a 100644--- a/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionWithOptionsResponse.ts+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyDefinitionWithOptionsResponse.ts@@ -4,13 +4,13 @@* properties_service* OpenAPI spec version: 0.1.0*/-import type { PropertyDefinitionResponse } from './propertyDefinitionResponse';+import type { PropertyDefinitionDetailResponse } from './propertyDefinitionDetailResponse';import type { PropertyOptionResponse } from './propertyOptionResponse';/*** Property definition with options response.*/export interface PropertyDefinitionWithOptionsResponse {- definition: PropertyDefinitionResponse;+ definition: PropertyDefinitionDetailResponse;propertyOptions: PropertyOptionResponse[];}diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOption.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOption.tsindex 40473b99c7..8d8e2edb6e 100644--- a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOption.ts+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOption.ts@@ -4,12 +4,14 @@* properties_service* OpenAPI spec version: 0.1.0*/+import type { PropertyOptionColor } from './propertyOptionColor';import type { PropertyOptionValue } from './propertyOptionValue';/*** A selectable option for select-type properties (service representation).*/export interface PropertyOption {+ color?: PropertyOptionColor;created_at: string;display_order: number;id: string;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOptionColor.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOptionColor.tsnew file mode 100644index 0000000000..ed8d346441--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOptionColor.ts@@ -0,0 +1,8 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */++export type PropertyOptionColor = string | null;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOptionResponse.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOptionResponse.tsindex 9d42640a98..b67f900c94 100644--- a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOptionResponse.ts+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOptionResponse.ts@@ -4,12 +4,14 @@* properties_service* OpenAPI spec version: 0.1.0*/+import type { PropertyOptionResponseColor } from './propertyOptionResponseColor';import type { PropertyOptionValue } from './propertyOptionValue';/*** Property option response (API representation).*/export interface PropertyOptionResponse {+ color?: PropertyOptionResponseColor;displayOrder: number;id: string;propertyDefinitionId: string;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOptionResponseColor.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOptionResponseColor.tsnew file mode 100644index 0000000000..fe3c3f331e--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOptionResponseColor.ts@@ -0,0 +1,8 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */++export type PropertyOptionResponseColor = string | null;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/tagScope.ts b/js/app/packages/service-clients/service-properties/generated/schemas/tagScope.tsnew file mode 100644index 0000000000..3ad6628e83--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/tagScope.ts@@ -0,0 +1,17 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * Which owner a tag set belongs to.+ */+export type TagScope = (typeof TagScope)[keyof typeof TagScope];++// eslint-disable-next-line @typescript-eslint/no-redeclare+export const TagScope = {+ user: 'user',+ team: 'team',+} as const;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/tagSetResponse.ts b/js/app/packages/service-clients/service-properties/generated/schemas/tagSetResponse.tsnew file mode 100644index 0000000000..a8713c7dfc--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/tagSetResponse.ts@@ -0,0 +1,20 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */++import type { PropertyOptionResponse } from './propertyOptionResponse';+import type { TagScope } from './tagScope';+import type { TagSetResponseDefinition } from './tagSetResponseDefinition';++/**+ * A tag set the caller can use. `definition` is absent until the set is provisioned+(on first label create), in which case `options` is empty.+ */+export interface TagSetResponse {+ definition?: TagSetResponseDefinition;+ options: PropertyOptionResponse[];+ scope: TagScope;+}diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/tagSetResponseDefinition.ts b/js/app/packages/service-clients/service-properties/generated/schemas/tagSetResponseDefinition.tsnew file mode 100644index 0000000000..3e08d58797--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/tagSetResponseDefinition.ts@@ -0,0 +1,9 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */+import type { PropertyDefinitionDetailResponse } from './propertyDefinitionDetailResponse';++export type TagSetResponseDefinition = null | PropertyDefinitionDetailResponse;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/updatePropertyOptionRequest.ts b/js/app/packages/service-clients/service-properties/generated/schemas/updatePropertyOptionRequest.tsnew file mode 100644index 0000000000..07b930aed5--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/updatePropertyOptionRequest.ts@@ -0,0 +1,22 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */+import type { UpdatePropertyOptionRequestColor } from './updatePropertyOptionRequestColor';+import type { UpdatePropertyOptionRequestDisplayOrder } from './updatePropertyOptionRequestDisplayOrder';+import type { UpdatePropertyOptionRequestValue } from './updatePropertyOptionRequestValue';++/**+ * Request to update a property option in place. Omitted fields keep their current value.+The option id is preserved, so the change propagates to every entity referencing it.+ */+export interface UpdatePropertyOptionRequest {+ /** New color as a hex string like `#RRGGBB`. */+ color?: UpdatePropertyOptionRequestColor;+ /** New display order. */+ display_order?: UpdatePropertyOptionRequestDisplayOrder;+ /** New string value (label text). Only valid for SelectString and Tag properties. */+ value?: UpdatePropertyOptionRequestValue;+}diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/updatePropertyOptionRequestColor.ts b/js/app/packages/service-clients/service-properties/generated/schemas/updatePropertyOptionRequestColor.tsnew file mode 100644index 0000000000..2707e5758e--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/updatePropertyOptionRequestColor.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * New color as a hex string like `#RRGGBB`.+ */+export type UpdatePropertyOptionRequestColor = string | null;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/updatePropertyOptionRequestDisplayOrder.ts b/js/app/packages/service-clients/service-properties/generated/schemas/updatePropertyOptionRequestDisplayOrder.tsnew file mode 100644index 0000000000..3f6f5c1c97--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/updatePropertyOptionRequestDisplayOrder.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * New display order.+ */+export type UpdatePropertyOptionRequestDisplayOrder = number | null;diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/updatePropertyOptionRequestValue.ts b/js/app/packages/service-clients/service-properties/generated/schemas/updatePropertyOptionRequestValue.tsnew file mode 100644index 0000000000..2cfd4a4b80--- /dev/null+++ b/js/app/packages/service-clients/service-properties/generated/schemas/updatePropertyOptionRequestValue.ts@@ -0,0 +1,11 @@+/**+ * Generated by orval v7.21.0 🍺+ * Do not edit manually.+ * properties_service+ * OpenAPI spec version: 0.1.0+ */++/**+ * New string value (label text). Only valid for SelectString and Tag properties.+ */+export type UpdatePropertyOptionRequestValue = string | null;diff --git a/js/app/packages/service-clients/service-properties/generated/zod.ts b/js/app/packages/service-clients/service-properties/generated/zod.tsindex e7d3fd6a17..514b841800 100644--- a/js/app/packages/service-clients/service-properties/generated/zod.ts+++ b/js/app/packages/service-clients/service-properties/generated/zod.ts@@ -45,6 +45,7 @@ export const listPropertiesResponseItem = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -122,6 +123,7 @@ export const listPropertiesResponseItem = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -189,6 +191,7 @@ export const listPropertiesResponseItem = zodproperty_options: zod.array(zod.object({+ color: zod.string().nullish(),created_at: zod.iso.datetime({}),display_order: zod.number(),id: zod.uuid(),@@ -344,6 +347,7 @@ export const getPropertyOptionsParams = zod.object({export const getPropertyOptionsResponseItem = zod.object({+ color: zod.string().nullish(),created_at: zod.iso.datetime({}),display_order: zod.number(),id: zod.uuid(),@@ -392,6 +396,7 @@ export const addPropertyOptionBody = zod.object({option: zod.object({+ color: zod.string().nullish(),display_order: zod.number(),value: zod.string(),})@@ -425,6 +430,68 @@ export const deletePropertyOptionParams = zod.object({option_id: zod.uuid().describe('Property option ID'),});+/**+ * The option id is preserved, so the change is reflected on every entity that references it.+ * @summary Update a property option in place (rename / recolor / reorder).+ */+export const updatePropertyOptionParams = zod.object({+ definition_id: zod.uuid().describe('Property definition ID'),+ option_id: zod.uuid().describe('Property option ID'),+});++export const updatePropertyOptionBody = zod+ .object({+ color: zod+ .string()+ .nullish()+ .describe('New color as a hex string like `#RRGGBB`.'),+ display_order: zod.number().nullish().describe('New display order.'),+ value: zod+ .string()+ .nullish()+ .describe(+ 'New string value (label text). Only valid for SelectString and Tag properties.'+ ),+ })+ .describe(+ 'Request to update a property option in place. Omitted fields keep their current value.\nThe option id is preserved, so the change propagates to every entity referencing it.'+ );++export const updatePropertyOptionResponse = zod+ .object({+ color: zod.string().nullish(),+ created_at: zod.iso.datetime({}),+ display_order: zod.number(),+ id: zod.uuid(),+ property_definition_id: zod.uuid(),+ updated_at: zod.iso.datetime({}),+ value: zod+ .union([+ zod+ .object({+ type: zod.enum(['string']),+ value: zod+ .string()+ .describe('String value for SelectString properties'),+ })+ .describe('String value for SelectString properties'),+ zod+ .object({+ type: zod.enum(['number']),+ value: zod+ .number()+ .describe('Number value for SelectNumber properties'),+ })+ .describe('Number value for SelectNumber properties'),+ ])+ .describe(+ 'The value of a property option - either a string or a number.'+ ),+ })+ .describe(+ 'A selectable option for select-type properties (service representation).'+ );+/*** Only returns properties for entities the user has view permission for.Entities without permission are silently omitted from the response.@@ -489,6 +556,7 @@ export const getBulkEntityPropertiesResponse = zod.record('STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -559,6 +627,7 @@ export const getBulkEntityPropertiesResponse = zod.record(.array(zod.object({+ color: zod.string().nullish(),created_at: zod.iso.datetime({}),display_order: zod.number(),id: zod.uuid(),@@ -796,6 +865,7 @@ export const getEntityPropertiesResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -864,6 +934,7 @@ export const getEntityPropertiesResponse = zod.array(zod.object({+ color: zod.string().nullish(),created_at: zod.iso.datetime({}),display_order: zod.number(),id: zod.uuid(),@@ -1219,3 +1290,270 @@ export const setEntityPropertyBody = zodexport const deleteEntityPropertyParams = zod.object({entity_property_id: zod.uuid().describe('Entity Property ID'),});++/**+ * @summary List the caller's tag sets: their personal set, plus their team's set when on a team.+Pure read - a scope with no provisioned definition yet returns an empty set.+ */+export const listTagsResponseItem = zod+ .object({+ definition: zod+ .union([+ zod.null(),+ zod+ .union([+ zod+ .object({+ scope: zod.enum(['user']),+ user_id: zod.string(),+ })+ .describe('User-scoped property.'),+ zod+ .object({+ scope: zod.enum(['team']),+ team_id: zod.uuid(),+ })+ .describe('Team-scoped property.'),+ zod+ .object({+ scope: zod.enum(['system']),+ })+ .describe('System-owned property (no user or team owner).'),+ ])+ .describe(+ 'Defines who owns a property - user-scoped, team-scoped, or system.'+ )+ .and(+ zod.object({+ createdAt: zod.iso.datetime({}).nullish(),+ dataType: zod+ .enum([+ 'BOOLEAN',+ 'DATE',+ 'NUMBER',+ 'STRING',+ 'SELECT_NUMBER',+ 'SELECT_STRING',+ 'TAG',+ 'ENTITY',+ 'LINK',+ ])+ .describe(+ 'Data type for property values, determining storage and validation.'+ ),+ displayName: zod.string(),+ id: zod.uuid(),+ isMetadata: zod+ .boolean()+ .describe(+ 'Flag to indicate if this is a system-generated metadata property'+ ),+ isMultiSelect: zod.boolean(),+ isSystem: zod+ .boolean()+ .describe(+ 'Flag to indicate if this is a system property (managed by the system)'+ ),+ specificEntityType: zod+ .union([+ zod.null(),+ zod+ .enum([+ 'CHANNEL',+ 'CHAT',+ 'COMPANY',+ 'DOCUMENT',+ 'PROJECT',+ 'TASK',+ 'THREAD',+ 'USER',+ ])+ .describe(+ 'Type of entity that can be referenced by entity properties.'+ ),+ ])+ .optional(),+ updatedAt: zod.iso.datetime({}).nullish(),+ })+ )+ .describe('Property definition response (API representation).'),+ ])+ .optional(),+ options: zod.array(+ zod+ .object({+ color: zod.string().nullish(),+ displayOrder: zod.number(),+ id: zod.uuid(),+ propertyDefinitionId: zod.uuid(),+ value: zod+ .union([+ zod+ .object({+ type: zod.enum(['string']),+ value: zod+ .string()+ .describe('String value for SelectString properties'),+ })+ .describe('String value for SelectString properties'),+ zod+ .object({+ type: zod.enum(['number']),+ value: zod+ .number()+ .describe('Number value for SelectNumber properties'),+ })+ .describe('Number value for SelectNumber properties'),+ ])+ .describe(+ 'The value of a property option - either a string or a number.'+ ),+ })+ .describe('Property option response (API representation).')+ ),+ scope: zod+ .enum(['user', 'team'])+ .describe('Which owner a tag set belongs to.'),+ })+ .describe(+ 'A tag set the caller can use. `definition` is absent until the set is provisioned\n(on first label create), in which case `options` is empty.'+ );+export const listTagsResponse = zod.array(listTagsResponseItem);++/**+ * @summary Provision (get-or-create) the caller's tag set for a scope and return it. Called when+the caller creates their first label for that scope, so the read path stays side-effect free.+ */+export const ensureTagSetBody = zod+ .object({+ scope: zod+ .enum(['user', 'team'])+ .describe('Which owner a tag set belongs to.'),+ })+ .describe(+ "Request to provision (get-or-create) the caller's tag set for a scope."+ );++export const ensureTagSetResponse = zod+ .object({+ definition: zod+ .union([+ zod.null(),+ zod+ .union([+ zod+ .object({+ scope: zod.enum(['user']),+ user_id: zod.string(),+ })+ .describe('User-scoped property.'),+ zod+ .object({+ scope: zod.enum(['team']),+ team_id: zod.uuid(),+ })+ .describe('Team-scoped property.'),+ zod+ .object({+ scope: zod.enum(['system']),+ })+ .describe('System-owned property (no user or team owner).'),+ ])+ .describe(+ 'Defines who owns a property - user-scoped, team-scoped, or system.'+ )+ .and(+ zod.object({+ createdAt: zod.iso.datetime({}).nullish(),+ dataType: zod+ .enum([+ 'BOOLEAN',+ 'DATE',+ 'NUMBER',+ 'STRING',+ 'SELECT_NUMBER',+ 'SELECT_STRING',+ 'TAG',+ 'ENTITY',+ 'LINK',+ ])+ .describe(+ 'Data type for property values, determining storage and validation.'+ ),+ displayName: zod.string(),+ id: zod.uuid(),+ isMetadata: zod+ .boolean()+ .describe(+ 'Flag to indicate if this is a system-generated metadata property'+ ),+ isMultiSelect: zod.boolean(),+ isSystem: zod+ .boolean()+ .describe(+ 'Flag to indicate if this is a system property (managed by the system)'+ ),+ specificEntityType: zod+ .union([+ zod.null(),+ zod+ .enum([+ 'CHANNEL',+ 'CHAT',+ 'COMPANY',+ 'DOCUMENT',+ 'PROJECT',+ 'TASK',+ 'THREAD',+ 'USER',+ ])+ .describe(+ 'Type of entity that can be referenced by entity properties.'+ ),+ ])+ .optional(),+ updatedAt: zod.iso.datetime({}).nullish(),+ })+ )+ .describe('Property definition response (API representation).'),+ ])+ .optional(),+ options: zod.array(+ zod+ .object({+ color: zod.string().nullish(),+ displayOrder: zod.number(),+ id: zod.uuid(),+ propertyDefinitionId: zod.uuid(),+ value: zod+ .union([+ zod+ .object({+ type: zod.enum(['string']),+ value: zod+ .string()+ .describe('String value for SelectString properties'),+ })+ .describe('String value for SelectString properties'),+ zod+ .object({+ type: zod.enum(['number']),+ value: zod+ .number()+ .describe('Number value for SelectNumber properties'),+ })+ .describe('Number value for SelectNumber properties'),+ ])+ .describe(+ 'The value of a property option - either a string or a number.'+ ),+ })+ .describe('Property option response (API representation).')+ ),+ scope: zod+ .enum(['user', 'team'])+ .describe('Which owner a tag set belongs to.'),+ })+ .describe(+ 'A tag set the caller can use. `definition` is absent until the set is provisioned\n(on first label create), in which case `options` is empty.'+ );diff --git a/js/app/packages/service-clients/service-properties/openapi.json b/js/app/packages/service-clients/service-properties/openapi.jsonindex 0a47c7a010..0ecbf524ff 100644--- a/js/app/packages/service-clients/service-properties/openapi.json+++ b/js/app/packages/service-clients/service-properties/openapi.json@@ -274,6 +274,71 @@"description": "Internal server error"}}+ },+ "patch": {+ "tags": ["Properties"],+ "summary": "Update a property option in place (rename / recolor / reorder).",+ "description": "The option id is preserved, so the change is reflected on every entity that references it.",+ "operationId": "update_property_option",+ "parameters": [+ {+ "name": "definition_id",+ "in": "path",+ "description": "Property definition ID",+ "required": true,+ "schema": {+ "type": "string",+ "format": "uuid"+ }+ },+ {+ "name": "option_id",+ "in": "path",+ "description": "Property option ID",+ "required": true,+ "schema": {+ "type": "string",+ "format": "uuid"+ }+ }+ ],+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/UpdatePropertyOptionRequest"+ }+ }+ },+ "required": true+ },+ "responses": {+ "200": {+ "description": "Property option updated",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/PropertyOption"+ }+ }+ }+ },+ "400": {+ "description": "Invalid request"+ },+ "403": {+ "description": "Cannot modify system properties"+ },+ "404": {+ "description": "Property or option not found"+ },+ "409": {+ "description": "An option with that value already exists"+ },+ "500": {+ "description": "Internal server error"+ }+ }}},"/properties/entities/bulk": {@@ -474,6 +539,64 @@}}}+ },+ "/properties/tags": {+ "get": {+ "tags": ["Properties"],+ "summary": "List the caller's tag sets: their personal set, plus their team's set when on a team.\nPure read - a scope with no provisioned definition yet returns an empty set.",+ "operationId": "list_tags",+ "responses": {+ "200": {+ "description": "Tag sets retrieved",+ "content": {+ "application/json": {+ "schema": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/TagSetResponse"+ }+ }+ }+ }+ },+ "500": {+ "description": "Internal server error"+ }+ }+ },+ "post": {+ "tags": ["Properties"],+ "summary": "Provision (get-or-create) the caller's tag set for a scope and return it. Called when\nthe caller creates their first label for that scope, so the read path stays side-effect free.",+ "operationId": "ensure_tag_set",+ "requestBody": {+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/EnsureTagSetRequest"+ }+ }+ },+ "required": true+ },+ "responses": {+ "200": {+ "description": "Tag set provisioned",+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/TagSetResponse"+ }+ }+ }+ },+ "403": {+ "description": "Team membership required for team scope"+ },+ "500": {+ "description": "Internal server error"+ }+ }+ }}},"components": {@@ -531,6 +654,9 @@"description": "Type-safe request to add a string option to a SelectString property.","required": ["display_order", "value"],"properties": {+ "color": {+ "type": ["string", "null"]+ },"display_order": {"type": "integer","format": "int32"@@ -593,10 +719,21 @@"STRING","SELECT_NUMBER","SELECT_STRING",+ "TAG","ENTITY","LINK"]},+ "EnsureTagSetRequest": {+ "type": "object",+ "description": "Request to provision (get-or-create) the caller's tag set for a scope.",+ "required": ["scope"],+ "properties": {+ "scope": {+ "$ref": "#/components/schemas/TagScope"+ }+ }+ },"EntityPropertiesResponse": {"type": "object","description": "Response for document/entity properties endpoint.",@@ -713,7 +850,7 @@"required": ["property", "definition"],"properties": {"definition": {- "$ref": "#/components/schemas/PropertyDefinitionResponse"+ "$ref": "#/components/schemas/PropertyDefinitionDetailResponse"},"options": {"type": ["array", "null"],@@ -990,6 +1127,66 @@}}},+ "PropertyDefinitionDetailResponse": {+ "allOf": [+ {+ "$ref": "#/components/schemas/PropertyOwner"+ },+ {+ "type": "object",+ "required": [+ "id",+ "displayName",+ "dataType",+ "isMultiSelect",+ "isSystem",+ "isMetadata"+ ],+ "properties": {+ "createdAt": {+ "type": ["string", "null"],+ "format": "date-time"+ },+ "dataType": {+ "$ref": "#/components/schemas/DataType"+ },+ "displayName": {+ "type": "string"+ },+ "id": {+ "type": "string",+ "format": "uuid"+ },+ "isMetadata": {+ "type": "boolean",+ "description": "Flag to indicate if this is a system-generated metadata property"+ },+ "isMultiSelect": {+ "type": "boolean"+ },+ "isSystem": {+ "type": "boolean",+ "description": "Flag to indicate if this is a system property (managed by the system)"+ },+ "specificEntityType": {+ "oneOf": [+ {+ "type": "null"+ },+ {+ "$ref": "#/components/schemas/EntityType"+ }+ ]+ },+ "updatedAt": {+ "type": ["string", "null"],+ "format": "date-time"+ }+ }+ }+ ],+ "description": "Property definition response (API representation)."+ },"PropertyDefinitionResponse": {"oneOf": [{@@ -1023,7 +1220,7 @@"required": ["definition", "propertyOptions"],"properties": {"definition": {- "$ref": "#/components/schemas/PropertyDefinitionResponse"+ "$ref": "#/components/schemas/PropertyDefinitionDetailResponse"},"propertyOptions": {"type": "array",@@ -1045,6 +1242,9 @@"updated_at"],"properties": {+ "color": {+ "type": ["string", "null"]+ },"created_at": {"type": "string","format": "date-time"@@ -1075,6 +1275,9 @@"description": "Property option response (API representation).","required": ["id", "propertyDefinitionId", "displayOrder", "value"],"properties": {+ "color": {+ "type": ["string", "null"]+ },"displayOrder": {"type": "integer","format": "int32"@@ -1503,6 +1706,56 @@}],"description": "Type-safe enum for setting entity property values - provides compile-time validation."+ },+ "TagScope": {+ "type": "string",+ "description": "Which owner a tag set belongs to.",+ "enum": ["user", "team"]+ },+ "TagSetResponse": {+ "type": "object",+ "description": "A tag set the caller can use. `definition` is absent until the set is provisioned\n(on first label create), in which case `options` is empty.",+ "required": ["scope", "options"],+ "properties": {+ "definition": {+ "oneOf": [+ {+ "type": "null"+ },+ {+ "$ref": "#/components/schemas/PropertyDefinitionDetailResponse"+ }+ ]+ },+ "options": {+ "type": "array",+ "items": {+ "$ref": "#/components/schemas/PropertyOptionResponse"+ }+ },+ "scope": {+ "$ref": "#/components/schemas/TagScope"+ }+ }+ },+ "UpdatePropertyOptionRequest": {+ "type": "object",+ "description": "Request to update a property option in place. Omitted fields keep their current value.\nThe option id is preserved, so the change propagates to every entity referencing it.",+ "properties": {+ "color": {+ "type": ["string", "null"],+ "description": "New color as a hex string like `#RRGGBB`."+ },+ "display_order": {+ "type": ["integer", "null"],+ "format": "int32",+ "description": "New display order."+ },+ "value": {+ "type": ["string", "null"],+ "description": "New string value (label text). Only valid for SelectString and Tag properties."+ }+ }}}},diff --git a/js/app/packages/service-clients/service-search/generated/models/dataType.ts b/js/app/packages/service-clients/service-search/generated/models/dataType.tsindex d6a1ba907b..892771b3b7 100644--- a/js/app/packages/service-clients/service-search/generated/models/dataType.ts+++ b/js/app/packages/service-clients/service-search/generated/models/dataType.ts@@ -18,6 +18,7 @@ export const DataType = {STRING: 'STRING',SELECT_NUMBER: 'SELECT_NUMBER',SELECT_STRING: 'SELECT_STRING',+ TAG: 'TAG',ENTITY: 'ENTITY',LINK: 'LINK',} as const;diff --git a/js/app/packages/service-clients/service-search/openapi.json b/js/app/packages/service-clients/service-search/openapi.jsonindex 5cfb085503..48bfaf2ac4 100644--- a/js/app/packages/service-clients/service-search/openapi.json+++ b/js/app/packages/service-clients/service-search/openapi.json@@ -976,6 +976,7 @@"STRING","SELECT_NUMBER","SELECT_STRING",+ "TAG","ENTITY","LINK"]diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/dataType.ts b/js/app/packages/service-clients/service-storage/generated/schemas/dataType.tsindex d9030725bb..fdd4dbad81 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/dataType.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/dataType.ts@@ -18,6 +18,7 @@ export const DataType = {STRING: 'STRING',SELECT_NUMBER: 'SELECT_NUMBER',SELECT_STRING: 'SELECT_STRING',+ TAG: 'TAG',ENTITY: 'ENTITY',LINK: 'LINK',} as const;diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.tsindex c8f9f5e1e2..a0069df955 100644--- a/js/app/packages/service-clients/service-storage/generated/zod.ts+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts@@ -6539,6 +6539,7 @@ export const getItemsSoupResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -6820,6 +6821,7 @@ export const getItemsSoupResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -7064,6 +7066,7 @@ export const getItemsSoupResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -7459,6 +7462,7 @@ export const getItemsSoupResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -8864,6 +8868,7 @@ export const postItemsSoupResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -9145,6 +9150,7 @@ export const postItemsSoupResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -9389,6 +9395,7 @@ export const postItemsSoupResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -9784,6 +9791,7 @@ export const postItemsSoupResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -10731,6 +10739,7 @@ export const postItemsSoupAstResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -11012,6 +11021,7 @@ export const postItemsSoupAstResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -11256,6 +11266,7 @@ export const postItemsSoupAstResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -11651,6 +11662,7 @@ export const postItemsSoupAstResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -12856,6 +12868,7 @@ export const postItemsSoupAstGroupedResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -13141,6 +13154,7 @@ export const postItemsSoupAstGroupedResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -13385,6 +13399,7 @@ export const postItemsSoupAstGroupedResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -13801,6 +13816,7 @@ export const postItemsSoupAstGroupedResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -14727,6 +14743,7 @@ export const postItemsSoupAstGroupedResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -15012,6 +15029,7 @@ export const postItemsSoupAstGroupedResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -15256,6 +15274,7 @@ export const postItemsSoupAstGroupedResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])@@ -15672,6 +15691,7 @@ export const postItemsSoupAstGroupedResponse = zod'STRING','SELECT_NUMBER','SELECT_STRING',+ 'TAG','ENTITY','LINK',])diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.jsonindex 9dccef8f90..f5f5e583ea 100644--- a/js/app/packages/service-clients/service-storage/openapi.json+++ b/js/app/packages/service-clients/service-storage/openapi.json@@ -12678,6 +12678,7 @@"STRING","SELECT_NUMBER","SELECT_STRING",+ "TAG","ENTITY","LINK"]diff --git a/rust/cloud-storage/.sqlx/query-301f5b3142a30e271df62607b5743ff019bff1a5b0142fc260ff772837db3f39.json b/rust/cloud-storage/.sqlx/query-301f5b3142a30e271df62607b5743ff019bff1a5b0142fc260ff772837db3f39.jsonindex 9add09cfba..3b5b423da4 100644--- a/rust/cloud-storage/.sqlx/query-301f5b3142a30e271df62607b5743ff019bff1a5b0142fc260ff772837db3f39.json+++ b/rust/cloud-storage/.sqlx/query-301f5b3142a30e271df62607b5743ff019bff1a5b0142fc260ff772837db3f39.json@@ -84,7 +84,8 @@"SELECT_NUMBER","SELECT_STRING","ENTITY",- "LINK"+ "LINK",+ "TAG"]}}diff --git a/rust/cloud-storage/.sqlx/query-41682a8f6e1e2fb8836f76ca3ceab5fe676b45c9942ec0c99486c03e52733a47.json b/rust/cloud-storage/.sqlx/query-3361ff2e8d90c65b188ef614379cdbf977e4f89f8c22603071fc169fdfa038e2.jsonsimilarity index 71%rename from rust/cloud-storage/.sqlx/query-41682a8f6e1e2fb8836f76ca3ceab5fe676b45c9942ec0c99486c03e52733a47.jsonrename to rust/cloud-storage/.sqlx/query-3361ff2e8d90c65b188ef614379cdbf977e4f89f8c22603071fc169fdfa038e2.jsonindex 7eab7370d7..d592cf7ba7 100644--- a/rust/cloud-storage/.sqlx/query-41682a8f6e1e2fb8836f76ca3ceab5fe676b45c9942ec0c99486c03e52733a47.json+++ b/rust/cloud-storage/.sqlx/query-3361ff2e8d90c65b188ef614379cdbf977e4f89f8c22603071fc169fdfa038e2.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n INSERT INTO property_options (\n id,\n property_definition_id,\n display_order,\n number_value,\n string_value\n )\n VALUES ($1, $2, $3, $4, $5)\n RETURNING id, created_at, updated_at\n ",+ "query": "\n INSERT INTO property_options (\n id,\n property_definition_id,\n display_order,\n number_value,\n string_value,\n color\n )\n VALUES ($1, $2, $3, $4, $5, $6)\n RETURNING id, created_at, updated_at\n ","describe": {"columns": [{@@ -25,6 +25,7 @@"Uuid","Int4","Float8",+ "Text","Text"]},@@ -34,5 +35,5 @@false]},- "hash": "41682a8f6e1e2fb8836f76ca3ceab5fe676b45c9942ec0c99486c03e52733a47"+ "hash": "3361ff2e8d90c65b188ef614379cdbf977e4f89f8c22603071fc169fdfa038e2"}diff --git a/rust/cloud-storage/.sqlx/query-462655d9cce541e4b25cb2d85e9d2e8ce3c84e28b4f459e4ea4ef62881278ae8.json b/rust/cloud-storage/.sqlx/query-462655d9cce541e4b25cb2d85e9d2e8ce3c84e28b4f459e4ea4ef62881278ae8.jsonindex 7000f58e6e..2dbdd8559c 100644--- a/rust/cloud-storage/.sqlx/query-462655d9cce541e4b25cb2d85e9d2e8ce3c84e28b4f459e4ea4ef62881278ae8.json+++ b/rust/cloud-storage/.sqlx/query-462655d9cce541e4b25cb2d85e9d2e8ce3c84e28b4f459e4ea4ef62881278ae8.json@@ -38,7 +38,8 @@"SELECT_NUMBER","SELECT_STRING","ENTITY",- "LINK"+ "LINK",+ "TAG"]}}diff --git a/rust/cloud-storage/.sqlx/query-4e7dff37296c4976495ee40673ee20a6729b6ce030222e1776a0fd22d93bafb7.json b/rust/cloud-storage/.sqlx/query-4e7dff37296c4976495ee40673ee20a6729b6ce030222e1776a0fd22d93bafb7.jsonnew file mode 100644index 0000000000..b54de1a07a--- /dev/null+++ b/rust/cloud-storage/.sqlx/query-4e7dff37296c4976495ee40673ee20a6729b6ce030222e1776a0fd22d93bafb7.json@@ -0,0 +1,128 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT\n id,\n team_id,\n user_id,\n display_name,\n data_type as \"data_type: DataType\",\n is_multi_select,\n specific_entity_type as \"specific_entity_type: Option<EntityType>\",\n created_at,\n updated_at,\n is_system\n FROM property_definitions\n WHERE data_type = $3\n AND (\n ($1::uuid IS NOT NULL AND team_id = $1)\n OR ($2::text IS NOT NULL AND user_id = $2)\n )\n LIMIT 1\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "team_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 2,+ "name": "user_id",+ "type_info": "Text"+ },+ {+ "ordinal": 3,+ "name": "display_name",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "data_type: DataType",+ "type_info": {+ "Custom": {+ "name": "property_data_type",+ "kind": {+ "Enum": [+ "BOOLEAN",+ "DATE",+ "NUMBER",+ "STRING",+ "SELECT_NUMBER",+ "SELECT_STRING",+ "ENTITY",+ "LINK",+ "TAG"+ ]+ }+ }+ }+ },+ {+ "ordinal": 5,+ "name": "is_multi_select",+ "type_info": "Bool"+ },+ {+ "ordinal": 6,+ "name": "specific_entity_type: Option<EntityType>",+ "type_info": {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 7,+ "name": "created_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 8,+ "name": "updated_at",+ "type_info": "Timestamptz"+ },+ {+ "ordinal": 9,+ "name": "is_system",+ "type_info": "Bool"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid",+ "Text",+ {+ "Custom": {+ "name": "property_data_type",+ "kind": {+ "Enum": [+ "BOOLEAN",+ "DATE",+ "NUMBER",+ "STRING",+ "SELECT_NUMBER",+ "SELECT_STRING",+ "ENTITY",+ "LINK",+ "TAG"+ ]+ }+ }+ }+ ]+ },+ "nullable": [+ false,+ true,+ true,+ false,+ false,+ false,+ true,+ false,+ false,+ false+ ]+ },+ "hash": "4e7dff37296c4976495ee40673ee20a6729b6ce030222e1776a0fd22d93bafb7"+}diff --git a/rust/cloud-storage/.sqlx/query-6fd87794b687b1687b8c4f0bc0390ffcc91811ae9909ce333273e6bf77013b03.json b/rust/cloud-storage/.sqlx/query-6fd87794b687b1687b8c4f0bc0390ffcc91811ae9909ce333273e6bf77013b03.jsonindex 60dd7e49b0..354995e8a1 100644--- a/rust/cloud-storage/.sqlx/query-6fd87794b687b1687b8c4f0bc0390ffcc91811ae9909ce333273e6bf77013b03.json+++ b/rust/cloud-storage/.sqlx/query-6fd87794b687b1687b8c4f0bc0390ffcc91811ae9909ce333273e6bf77013b03.json@@ -38,7 +38,8 @@"SELECT_NUMBER","SELECT_STRING","ENTITY",- "LINK"+ "LINK",+ "TAG"]}}@@ -99,7 +100,8 @@"SELECT_NUMBER","SELECT_STRING","ENTITY",- "LINK"+ "LINK",+ "TAG"]}}diff --git a/rust/cloud-storage/.sqlx/query-8d5ffbdd5be9b1031c7da47bc2d4bcbee35802a575387ef081a09031b42f7de9.json b/rust/cloud-storage/.sqlx/query-8d5ffbdd5be9b1031c7da47bc2d4bcbee35802a575387ef081a09031b42f7de9.jsonindex 4860272b0d..7fe732d356 100644--- a/rust/cloud-storage/.sqlx/query-8d5ffbdd5be9b1031c7da47bc2d4bcbee35802a575387ef081a09031b42f7de9.json+++ b/rust/cloud-storage/.sqlx/query-8d5ffbdd5be9b1031c7da47bc2d4bcbee35802a575387ef081a09031b42f7de9.json@@ -28,7 +28,8 @@"SELECT_NUMBER","SELECT_STRING","ENTITY",- "LINK"+ "LINK",+ "TAG"]}}diff --git a/rust/cloud-storage/.sqlx/query-a63c0f9e0b3c58438d46cff265e3f412890402e3627b85d5dfb74a08d72787e1.json b/rust/cloud-storage/.sqlx/query-a63c0f9e0b3c58438d46cff265e3f412890402e3627b85d5dfb74a08d72787e1.jsonindex f53e848896..ae7e70b085 100644--- a/rust/cloud-storage/.sqlx/query-a63c0f9e0b3c58438d46cff265e3f412890402e3627b85d5dfb74a08d72787e1.json+++ b/rust/cloud-storage/.sqlx/query-a63c0f9e0b3c58438d46cff265e3f412890402e3627b85d5dfb74a08d72787e1.json@@ -38,7 +38,8 @@"SELECT_NUMBER","SELECT_STRING","ENTITY",- "LINK"+ "LINK",+ "TAG"]}}diff --git a/rust/cloud-storage/.sqlx/query-b6a900ce4ef05b399b15c5df9df622228577a112642245990b64442fb691305f.json b/rust/cloud-storage/.sqlx/query-b6a900ce4ef05b399b15c5df9df622228577a112642245990b64442fb691305f.jsonindex 0443fd2ce5..c2d448113f 100644--- a/rust/cloud-storage/.sqlx/query-b6a900ce4ef05b399b15c5df9df622228577a112642245990b64442fb691305f.json+++ b/rust/cloud-storage/.sqlx/query-b6a900ce4ef05b399b15c5df9df622228577a112642245990b64442fb691305f.json@@ -38,7 +38,8 @@"SELECT_NUMBER","SELECT_STRING","ENTITY",- "LINK"+ "LINK",+ "TAG"]}}diff --git a/rust/cloud-storage/.sqlx/query-3bc6b02fb5df57994ccaa3c7aad24bb2528c2f38c6cbc30cd56e6eb36b270cea.json b/rust/cloud-storage/.sqlx/query-be9196900ae5aa5d1bf5bdee0a4e8bb94fa15e24fe46ee1fd0cbeb9b644c80ea.jsonsimilarity index 80%rename from rust/cloud-storage/.sqlx/query-3bc6b02fb5df57994ccaa3c7aad24bb2528c2f38c6cbc30cd56e6eb36b270cea.jsonrename to rust/cloud-storage/.sqlx/query-be9196900ae5aa5d1bf5bdee0a4e8bb94fa15e24fe46ee1fd0cbeb9b644c80ea.jsonindex 57021867a5..ab32428f61 100644--- a/rust/cloud-storage/.sqlx/query-3bc6b02fb5df57994ccaa3c7aad24bb2528c2f38c6cbc30cd56e6eb36b270cea.json+++ b/rust/cloud-storage/.sqlx/query-be9196900ae5aa5d1bf5bdee0a4e8bb94fa15e24fe46ee1fd0cbeb9b644c80ea.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n pd.id,\n pd.team_id,\n pd.user_id,\n pd.display_name,\n pd.data_type as \"data_type: DataType\",\n pd.is_multi_select,\n pd.specific_entity_type as \"specific_entity_type: Option<EntityType>\",\n pd.created_at,\n pd.updated_at,\n pd.is_system,\n po.id as \"option_id?\",\n po.display_order as \"option_display_order?\",\n po.number_value as option_number_value,\n po.string_value as option_string_value,\n po.created_at as \"option_created_at?\",\n po.updated_at as \"option_updated_at?\"\n FROM property_definitions pd\n LEFT JOIN property_options po ON pd.id = po.property_definition_id\n WHERE\n ($3 AND pd.is_system)\n OR (\n ($1::uuid IS NOT NULL AND pd.team_id = $1)\n OR ($2::text IS NOT NULL AND pd.user_id = $2)\n )\n ORDER BY LOWER(pd.display_name), po.display_order, po.number_value, LOWER(po.string_value)\n ",+ "query": "\n SELECT\n pd.id,\n pd.team_id,\n pd.user_id,\n pd.display_name,\n pd.data_type as \"data_type: DataType\",\n pd.is_multi_select,\n pd.specific_entity_type as \"specific_entity_type: Option<EntityType>\",\n pd.created_at,\n pd.updated_at,\n pd.is_system,\n po.id as \"option_id?\",\n po.display_order as \"option_display_order?\",\n po.number_value as option_number_value,\n po.string_value as option_string_value,\n po.color as option_color,\n po.created_at as \"option_created_at?\",\n po.updated_at as \"option_updated_at?\"\n FROM property_definitions pd\n LEFT JOIN property_options po ON pd.id = po.property_definition_id\n WHERE\n ($3 AND pd.is_system)\n OR (\n ($1::uuid IS NOT NULL AND pd.team_id = $1)\n OR ($2::text IS NOT NULL AND pd.user_id = $2)\n )\n ORDER BY LOWER(pd.display_name), po.display_order, po.number_value, LOWER(po.string_value)\n ","describe": {"columns": [{@@ -38,7 +38,8 @@"SELECT_NUMBER","SELECT_STRING","ENTITY",- "LINK"+ "LINK",+ "TAG"]}}@@ -107,11 +108,16 @@},{"ordinal": 14,+ "name": "option_color",+ "type_info": "Text"+ },+ {+ "ordinal": 15,"name": "option_created_at?","type_info": "Timestamptz"},{- "ordinal": 15,+ "ordinal": 16,"name": "option_updated_at?","type_info": "Timestamptz"}@@ -138,9 +144,10 @@false,true,true,+ true,false,false]},- "hash": "3bc6b02fb5df57994ccaa3c7aad24bb2528c2f38c6cbc30cd56e6eb36b270cea"+ "hash": "be9196900ae5aa5d1bf5bdee0a4e8bb94fa15e24fe46ee1fd0cbeb9b644c80ea"}diff --git a/rust/cloud-storage/.sqlx/query-d09a22b5d0a049677c6fc96d0aef74260d592ae30752c12a50512ebf95592e5f.json b/rust/cloud-storage/.sqlx/query-d09a22b5d0a049677c6fc96d0aef74260d592ae30752c12a50512ebf95592e5f.jsonindex 071cc5d68a..2a3dbfedef 100644--- a/rust/cloud-storage/.sqlx/query-d09a22b5d0a049677c6fc96d0aef74260d592ae30752c12a50512ebf95592e5f.json+++ b/rust/cloud-storage/.sqlx/query-d09a22b5d0a049677c6fc96d0aef74260d592ae30752c12a50512ebf95592e5f.json@@ -84,7 +84,8 @@"SELECT_NUMBER","SELECT_STRING","ENTITY",- "LINK"+ "LINK",+ "TAG"]}}diff --git a/rust/cloud-storage/.sqlx/query-9e45ba072fbc5266f7edba0fecb99d19192e10139d6ea089be4a3a4a7923361c.json b/rust/cloud-storage/.sqlx/query-d9521e04db4b5f1603cf5daf48a5e7216c9eee8a4c99f254b1b9471a918b884c.jsonsimilarity index 59%rename from rust/cloud-storage/.sqlx/query-9e45ba072fbc5266f7edba0fecb99d19192e10139d6ea089be4a3a4a7923361c.jsonrename to rust/cloud-storage/.sqlx/query-d9521e04db4b5f1603cf5daf48a5e7216c9eee8a4c99f254b1b9471a918b884c.jsonindex 357e50473e..0f3b8edba3 100644--- a/rust/cloud-storage/.sqlx/query-9e45ba072fbc5266f7edba0fecb99d19192e10139d6ea089be4a3a4a7923361c.json+++ b/rust/cloud-storage/.sqlx/query-d9521e04db4b5f1603cf5daf48a5e7216c9eee8a4c99f254b1b9471a918b884c.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n INSERT INTO property_options (\n id,\n property_definition_id,\n display_order,\n number_value,\n string_value\n )\n VALUES ($1, $2, $3, $4, $5)\n ",+ "query": "\n INSERT INTO property_options (\n id,\n property_definition_id,\n display_order,\n number_value,\n string_value,\n color\n )\n VALUES ($1, $2, $3, $4, $5, $6)\n ","describe": {"columns": [],"parameters": {@@ -9,10 +9,11 @@"Uuid","Int4","Float8",+ "Text","Text"]},"nullable": []},- "hash": "9e45ba072fbc5266f7edba0fecb99d19192e10139d6ea089be4a3a4a7923361c"+ "hash": "d9521e04db4b5f1603cf5daf48a5e7216c9eee8a4c99f254b1b9471a918b884c"}diff --git a/rust/cloud-storage/.sqlx/query-f08b1a5fbea1fba7b91975fdcaa5c5adde2d9bc89eece2cbf17133b7e5f6d6d9.json b/rust/cloud-storage/.sqlx/query-f08b1a5fbea1fba7b91975fdcaa5c5adde2d9bc89eece2cbf17133b7e5f6d6d9.jsonindex 22e39fb653..8372c988bd 100644--- a/rust/cloud-storage/.sqlx/query-f08b1a5fbea1fba7b91975fdcaa5c5adde2d9bc89eece2cbf17133b7e5f6d6d9.json+++ b/rust/cloud-storage/.sqlx/query-f08b1a5fbea1fba7b91975fdcaa5c5adde2d9bc89eece2cbf17133b7e5f6d6d9.json@@ -84,7 +84,8 @@"SELECT_NUMBER","SELECT_STRING","ENTITY",- "LINK"+ "LINK",+ "TAG"]}}diff --git a/rust/cloud-storage/macro_db_client/migrations/20260629214704_tag_property_data_type.sql b/rust/cloud-storage/macro_db_client/migrations/20260629214704_tag_property_data_type.sqlnew file mode 100644index 0000000000..1286951c08--- /dev/null+++ b/rust/cloud-storage/macro_db_client/migrations/20260629214704_tag_property_data_type.sql@@ -0,0 +1,6 @@+-- macro-2102: tags v0. Introduce the TAG property data type.+--+-- Isolated in its own migration on purpose: a newly added enum value cannot be+-- referenced in the same transaction that adds it, and the follow-up migration+-- creates a partial index predicated on data_type = 'TAG'.+ALTER TYPE property_data_type ADD VALUE IF NOT EXISTS 'TAG';diff --git a/rust/cloud-storage/macro_db_client/migrations/20260629215320_tag_option_color_and_owner_uniqueness.sql b/rust/cloud-storage/macro_db_client/migrations/20260629215320_tag_option_color_and_owner_uniqueness.sqlnew file mode 100644index 0000000000..b59da60abe--- /dev/null+++ b/rust/cloud-storage/macro_db_client/migrations/20260629215320_tag_option_color_and_owner_uniqueness.sql@@ -0,0 +1,36 @@+-- macro-2102: tags v0. Per-option color, and one tag set per owner.++-- Per-label color, stored as a hex string (e.g. '#E5484D'). NULL for non-tag options.+ALTER TABLE property_options ADD COLUMN IF NOT EXISTS color TEXT;++-- Keep persisted colors aligned with the handler validation: NULL or a #RRGGBB hex string.+ALTER TABLE property_options DROP CONSTRAINT IF EXISTS property_options_color_hex;+ALTER TABLE property_options+ ADD CONSTRAINT property_options_color_hex+ CHECK (color IS NULL OR color ~ '^#[0-9A-Fa-f]{6}$');++-- A user or a team owns at most one tag set. These partial unique indexes enforce a+-- single TAG-typed definition per owner, so the tag set resolves deterministically.+-- (System-owned tag definitions are not used - tags are always user- or team-owned.)+CREATE UNIQUE INDEX IF NOT EXISTS uq_tag_definition_per_team+ ON property_definitions (team_id)+ WHERE data_type = 'TAG' AND team_id IS NOT NULL;++CREATE UNIQUE INDEX IF NOT EXISTS uq_tag_definition_per_user+ ON property_definitions (user_id)+ WHERE data_type = 'TAG' AND user_id IS NOT NULL;++-- Tag definitions are owner singletons (the indexes above), so exempt them from the+-- display-name uniqueness that applies to user-created properties. This lets the+-- auto-provisioned tag definition coexist with a same-named user property instead of+-- failing to provision the tag set. Non-tag properties keep their per-owner name uniqueness.+ALTER TABLE property_definitions+ DROP CONSTRAINT IF EXISTS unique_property_definitions_user_display_name;+ALTER TABLE property_definitions+ DROP CONSTRAINT IF EXISTS unique_property_definitions_team_display_name;+CREATE UNIQUE INDEX IF NOT EXISTS unique_property_definitions_user_display_name+ ON property_definitions (user_id, display_name)+ WHERE user_id IS NOT NULL AND data_type <> 'TAG';+CREATE UNIQUE INDEX IF NOT EXISTS unique_property_definitions_team_display_name+ ON property_definitions (team_id, display_name)+ WHERE team_id IS NOT NULL AND data_type <> 'TAG';diff --git a/rust/cloud-storage/models_properties/src/api/error.rs b/rust/cloud-storage/models_properties/src/api/error.rsindex af59fba43c..5a58c6f9ee 100644--- a/rust/cloud-storage/models_properties/src/api/error.rs+++ b/rust/cloud-storage/models_properties/src/api/error.rs@@ -27,6 +27,12 @@ pub enum PropertyOptionValidationError {#[error("Number option value must be finite (not NaN or Infinity)")]InvalidNumberValue,++ #[error("Color must be a hex string like #RRGGBB")]+ InvalidColor,++ #[error("Tag options require a color")]+ MissingColor,}/// Errors that can occur during property value validationdiff --git a/rust/cloud-storage/models_properties/src/api/mod.rs b/rust/cloud-storage/models_properties/src/api/mod.rsindex d63ea1baf6..f2446ccb9b 100644--- a/rust/cloud-storage/models_properties/src/api/mod.rs+++ b/rust/cloud-storage/models_properties/src/api/mod.rs@@ -16,11 +16,11 @@ pub use query_params::{BulkEntityQueryParams, EntityQueryParams};pub use requests::{AddNumberOptionRequest, AddPropertyOptionRequest, AddStringOptionRequest,CreatePropertyDefinitionRequest, CreatePropertyScope, PropertyDataType, SelectNumberOption,- SelectStringOption, SetPropertyValue,+ SelectStringOption, SetPropertyValue, UpdatePropertyOptionRequest, is_valid_hex_color,};pub use responses::{BulkEntityPropertiesResponse, EntityPropertiesResponse, EntityPropertyResponse,- EntityPropertyWithDefinitionResponse, PropertyDefinitionResponse,+ EntityPropertyWithDefinitionResponse, PropertyDefinitionDetailResponse,PropertyDefinitionWithOptionsResponse, PropertyOptionResponse, PropertyOptionValue,PropertyValue,};diff --git a/rust/cloud-storage/models_properties/src/api/requests.rs b/rust/cloud-storage/models_properties/src/api/requests.rsindex 52d3bf692f..834773fd6d 100644--- a/rust/cloud-storage/models_properties/src/api/requests.rs+++ b/rust/cloud-storage/models_properties/src/api/requests.rs@@ -155,6 +155,7 @@ impl CreatePropertyDefinitionRequest {pub struct AddStringOptionRequest {pub display_order: i32,pub value: String,+ pub color: Option<String>,}/// Type-safe request to add a number option to a SelectNumber property.@@ -185,6 +186,7 @@ impl AddPropertyOptionRequest {match (self, data_type) {(AddPropertyOptionRequest::SelectString { .. }, DataType::SelectString) => Ok(()),(AddPropertyOptionRequest::SelectNumber { .. }, DataType::SelectNumber) => Ok(()),+ (AddPropertyOptionRequest::SelectString { .. }, DataType::Tag) => Ok(()),(AddPropertyOptionRequest::SelectString { .. }, _) => {Err(PropertyOptionValidationError::StringOptionWrongType)}@@ -213,6 +215,27 @@ impl AddPropertyOptionRequest {}}+/// Request to update a property option in place. Omitted fields keep their current value.+/// The option id is preserved, so the change propagates to every entity referencing it.+#[derive(Debug, Serialize, Deserialize, ToSchema, Clone)]+pub struct UpdatePropertyOptionRequest {+ /// New string value (label text). Only valid for SelectString and Tag properties.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub value: Option<String>,+ /// New color as a hex string like `#RRGGBB`.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub color: Option<String>,+ /// New display order.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub display_order: Option<i32>,+}++/// Returns true if `color` is a 6-digit hex string like `#RRGGBB`.+pub fn is_valid_hex_color(color: &str) -> bool {+ let bytes = color.as_bytes();+ bytes.len() == 7 && bytes[0] == b'#' && bytes[1..].iter().all(u8::is_ascii_hexdigit)+}+// ===== Entity Property Value Requests =====/// Type-safe enum for setting entity property values - provides compile-time validation.@@ -290,7 +313,10 @@ impl SetPropertyValue {}SetPropertyValue::SelectOption { .. } => {- if !matches!(data_type, DataType::SelectString | DataType::SelectNumber) {+ if !matches!(+ data_type,+ DataType::SelectString | DataType::SelectNumber | DataType::Tag+ ) {return Err(PropertyValueValidationError::SelectOptionWrongType);}if is_multi_select {@@ -300,7 +326,10 @@ impl SetPropertyValue {}SetPropertyValue::MultiSelectOption { .. } => {- if !matches!(data_type, DataType::SelectString | DataType::SelectNumber) {+ if !matches!(+ data_type,+ DataType::SelectString | DataType::SelectNumber | DataType::Tag+ ) {return Err(PropertyValueValidationError::MultiSelectOptionWrongType);}if !is_multi_select {diff --git a/rust/cloud-storage/models_properties/src/api/responses.rs b/rust/cloud-storage/models_properties/src/api/responses.rsindex b25a9de67d..c45856b7a8 100644--- a/rust/cloud-storage/models_properties/src/api/responses.rs+++ b/rust/cloud-storage/models_properties/src/api/responses.rs@@ -13,7 +13,7 @@ use crate::shared::{DataType, EntityType, PropertyOwner};/// Property definition response (API representation).#[derive(ToSchema, Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]-pub struct PropertyDefinitionResponse {+pub struct PropertyDefinitionDetailResponse {pub id: Uuid,#[serde(flatten)]pub owner: PropertyOwner,@@ -35,7 +35,7 @@ pub struct PropertyDefinitionResponse {#[derive(ToSchema, Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct PropertyDefinitionWithOptionsResponse {- pub definition: PropertyDefinitionResponse,+ pub definition: PropertyDefinitionDetailResponse,pub property_options: Vec<PropertyOptionResponse>,}@@ -59,6 +59,7 @@ pub struct PropertyOptionResponse {pub property_definition_id: Uuid,pub display_order: i32,pub value: PropertyOptionValue,+ pub color: Option<String>,}// ===== Entity Property Responses =====@@ -121,7 +122,7 @@ pub enum PropertyValue {#[serde(rename_all = "camelCase")]pub struct EntityPropertyWithDefinitionResponse {pub property: EntityPropertyResponse,- pub definition: PropertyDefinitionResponse,+ pub definition: PropertyDefinitionDetailResponse,pub value: Option<PropertyValue>,#[serde(skip_serializing_if = "Option::is_none")]pub options: Option<Vec<PropertyOptionResponse>>,diff --git a/rust/cloud-storage/models_properties/src/db/property_option.rs b/rust/cloud-storage/models_properties/src/db/property_option.rsindex bc48233df8..5e20c52c5b 100644--- a/rust/cloud-storage/models_properties/src/db/property_option.rs+++ b/rust/cloud-storage/models_properties/src/db/property_option.rs@@ -17,6 +17,7 @@ pub struct PropertyOption {pub display_order: i32,pub number_value: Option<f64>,pub string_value: Option<String>,+ pub color: Option<String>,pub created_at: DateTime<Utc>,pub updated_at: DateTime<Utc>,}@@ -31,6 +32,7 @@ impl<'r> sqlx::FromRow<'r, sqlx::postgres::PgRow> for PropertyOption {display_order: row.try_get("display_order")?,number_value: row.try_get("number_value")?,string_value: row.try_get("string_value")?,+ color: row.try_get("color")?,created_at: row.try_get("created_at")?,updated_at: row.try_get("updated_at")?,})@@ -61,6 +63,7 @@ impl std::convert::TryFrom<PropertyOption> for crate::service::property_option::property_definition_id: db.property_definition_id,display_order: db.display_order,value,+ color: db.color,created_at: db.created_at,updated_at: db.updated_at,})diff --git a/rust/cloud-storage/models_properties/src/service/property_definition.rs b/rust/cloud-storage/models_properties/src/service/property_definition.rsindex b8a3cae6de..93094cf81a 100644--- a/rust/cloud-storage/models_properties/src/service/property_definition.rs+++ b/rust/cloud-storage/models_properties/src/service/property_definition.rs@@ -26,7 +26,7 @@ pub struct PropertyDefinition {// ===== Conversions =====-impl From<PropertyDefinition> for crate::api::PropertyDefinitionResponse {+impl From<PropertyDefinition> for crate::api::PropertyDefinitionDetailResponse {fn from(svc: PropertyDefinition) -> Self {Self {id: svc.id,diff --git a/rust/cloud-storage/models_properties/src/service/property_option.rs b/rust/cloud-storage/models_properties/src/service/property_option.rsindex c0fe804f85..273c9622c7 100644--- a/rust/cloud-storage/models_properties/src/service/property_option.rs+++ b/rust/cloud-storage/models_properties/src/service/property_option.rs@@ -47,6 +47,7 @@ pub struct PropertyOption {pub property_definition_id: Uuid,pub display_order: i32,pub value: PropertyOptionValue,+ pub color: Option<String>,pub created_at: DateTime<Utc>,pub updated_at: DateTime<Utc>,}@@ -69,6 +70,7 @@ impl From<PropertyOption> for crate::api::PropertyOptionResponse {property_definition_id: svc.property_definition_id,display_order: svc.display_order,value: svc.value.into(),+ color: svc.color,}}}diff --git a/rust/cloud-storage/models_properties/src/shared/data_type.rs b/rust/cloud-storage/models_properties/src/shared/data_type.rsindex 6cb2f27e55..c44ced85fb 100644--- a/rust/cloud-storage/models_properties/src/shared/data_type.rs+++ b/rust/cloud-storage/models_properties/src/shared/data_type.rs@@ -20,6 +20,8 @@ pub enum DataType {SelectNumber,/// Select property with string options.SelectString,+ /// Tag property - user- or team-scoped colored labels (always multi-select).+ Tag,/// Entity reference property.Entity,/// Link value Property.diff --git a/rust/cloud-storage/properties/src/inbound/toolset/get_entity_properties.rs b/rust/cloud-storage/properties/src/inbound/toolset/get_entity_properties.rsindex f8d4b46133..f95b85cf09 100644--- a/rust/cloud-storage/properties/src/inbound/toolset/get_entity_properties.rs+++ b/rust/cloud-storage/properties/src/inbound/toolset/get_entity_properties.rs@@ -154,6 +154,7 @@ fn to_tool_property(info: EntityPropertyInfo) -> ToolPropertyItem {DataType::String => "string",DataType::SelectNumber => "select_number",DataType::SelectString => "select_string",+ DataType::Tag => "tag",DataType::Entity => "entity",DataType::Link => "link",}diff --git a/rust/cloud-storage/properties/src/outbound/entity_properties_get_query.rs b/rust/cloud-storage/properties/src/outbound/entity_properties_get_query.rsindex 1887fcf936..ea296ade0c 100644--- a/rust/cloud-storage/properties/src/outbound/entity_properties_get_query.rs+++ b/rust/cloud-storage/properties/src/outbound/entity_properties_get_query.rs@@ -65,7 +65,12 @@ pub async fn get_entity_properties(// Collect all property definition IDs that are select types to fetch optionslet select_prop_ids: Vec<Uuid> = rows.iter()- .filter(|r| matches!(r.data_type, DataType::SelectString | DataType::SelectNumber))+ .filter(|r| {+ matches!(+ r.data_type,+ DataType::SelectString | DataType::SelectNumber | DataType::Tag+ )+ }).map(|r| r.property_definition_id).collect();diff --git a/rust/cloud-storage/properties_db_client/src/entity_properties/get.rs b/rust/cloud-storage/properties_db_client/src/entity_properties/get.rsindex 633d781a3b..9610cb592d 100644--- a/rust/cloud-storage/properties_db_client/src/entity_properties/get.rs+++ b/rust/cloud-storage/properties_db_client/src/entity_properties/get.rs@@ -191,7 +191,7 @@ async fn attach_property_options(.filter(|p| {matches!(p.definition.data_type,- DataType::SelectString | DataType::SelectNumber+ DataType::SelectString | DataType::SelectNumber | DataType::Tag)}).map(|p| p.definition.id)@@ -209,7 +209,7 @@ async fn attach_property_options(for property in properties {let is_select_type = matches!(property.definition.data_type,- DataType::SelectString | DataType::SelectNumber+ DataType::SelectString | DataType::SelectNumber | DataType::Tag);if is_select_type {@@ -241,7 +241,7 @@ async fn attach_property_options_bulk(.filter(|p| {matches!(p.definition.data_type,- DataType::SelectString | DataType::SelectNumber+ DataType::SelectString | DataType::SelectNumber | DataType::Tag)}).map(|p| p.definition.id)@@ -258,7 +258,7 @@ async fn attach_property_options_bulk(for property in properties.iter_mut() {let is_select_type = matches!(property.definition.data_type,- DataType::SelectString | DataType::SelectNumber+ DataType::SelectString | DataType::SelectNumber | DataType::Tag);if is_select_type {let options = options_mapdiff --git a/rust/cloud-storage/properties_db_client/src/property_definitions/get.rs b/rust/cloud-storage/properties_db_client/src/property_definitions/get.rsindex a63747520f..73423430b5 100644--- a/rust/cloud-storage/properties_db_client/src/property_definitions/get.rs+++ b/rust/cloud-storage/properties_db_client/src/property_definitions/get.rs@@ -175,6 +175,61 @@ pub async fn get_property_definition_with_owner(Ok(result)}+/// Display name used for the auto-provisioned tag definition.+pub const TAG_DEFINITION_DISPLAY_NAME: &str = "Tags";++/// Gets the single tag definition owned by the given team or user, if it exists.+/// Exactly one of `team_id` / `user_id` is expected to be set.+#[tracing::instrument(skip(db), err)]+pub async fn get_tag_definition(+ db: &Pool<Postgres>,+ team_id: Option<Uuid>,+ user_id: Option<&str>,+) -> Result<Option<PropertyDefinition>> {+ let row = sqlx::query!(+ r#"+ SELECT+ id,+ team_id,+ user_id,+ display_name,+ data_type as "data_type: DataType",+ is_multi_select,+ specific_entity_type as "specific_entity_type: Option<EntityType>",+ created_at,+ updated_at,+ is_system+ FROM property_definitions+ WHERE data_type = $3+ AND (+ ($1::uuid IS NOT NULL AND team_id = $1)+ OR ($2::text IS NOT NULL AND user_id = $2)+ )+ LIMIT 1+ "#,+ team_id,+ user_id,+ DataType::Tag as DataType+ )+ .fetch_optional(db)+ .await?;++ Ok(row.map(|row| {+ PropertyDefinition::from(db::PropertyDefinition {+ id: row.id,+ team_id: row.team_id,+ user_id: row.user_id,+ display_name: row.display_name,+ data_type: row.data_type,+ is_multi_select: row.is_multi_select,+ specific_entity_type: row.specific_entity_type.flatten(),+ created_at: row.created_at,+ updated_at: row.updated_at,+ is_system: row.is_system,+ })+ }))+}+/// Gets property definitions with options based on team and optional user access./// Set `include_system` to true to also include system properties.#[tracing::instrument(skip(db))]@@ -201,6 +256,7 @@ pub async fn get_properties_with_options(po.display_order as "option_display_order?",po.number_value as option_number_value,po.string_value as option_string_value,+ po.color as option_color,po.created_at as "option_created_at?",po.updated_at as "option_updated_at?"FROM property_definitions pd@@ -252,7 +308,9 @@ pub async fn get_properties_with_options(// Only process options if option_id is present (from LEFT JOIN)if let Some(option_id) = row.option_id&& (row.option_number_value.is_some() || row.option_string_value.is_some())- && (row.data_type == DataType::SelectNumber || row.data_type == DataType::SelectString)+ && (row.data_type == DataType::SelectNumber+ || row.data_type == DataType::SelectString+ || row.data_type == DataType::Tag){let value = match (row.option_number_value, &row.option_string_value) {(Some(num), None) => PropertyOptionValue::Number(num),@@ -280,6 +338,7 @@ pub async fn get_properties_with_options(property_definition_id: row.id,display_order: row.option_display_order.unwrap_or(0),value,+ color: row.option_color,created_at: row.option_created_at.unwrap_or(row.created_at),updated_at: row.option_updated_at.unwrap_or(row.updated_at),};diff --git a/rust/cloud-storage/properties_db_client/src/property_definitions/insert.rs b/rust/cloud-storage/properties_db_client/src/property_definitions/insert.rsindex ecb85835a9..43884fe591 100644--- a/rust/cloud-storage/properties_db_client/src/property_definitions/insert.rs+++ b/rust/cloud-storage/properties_db_client/src/property_definitions/insert.rs@@ -181,6 +181,7 @@ pub async fn create_property_definition_with_options(db_property_def.id,option.display_order,option.value,+ option.color,).await{@@ -211,6 +212,44 @@ pub async fn create_property_definition_with_options(}}+/// Returns the owner's tag definition, creating it on first use.+///+/// Tag definitions are TAG-typed, multi-select, and unique per owner (enforced by a partial+/// unique index). A lost create race re-fetches the definition the winner just created.+#[tracing::instrument(skip(db), err)]+pub async fn get_or_create_tag_definition(+ db: &Pool<Postgres>,+ owner: DefinitionOwner<'_>,+) -> Result<PropertyDefinition> {+ let (team_id, user_id) = owner.into_ids();++ if let Some(existing) =+ crate::property_definitions::get::get_tag_definition(db, team_id, user_id).await?+ {+ return Ok(existing);+ }++ match create_property_definition(+ db,+ owner,+ crate::property_definitions::get::TAG_DEFINITION_DISPLAY_NAME,+ DataType::Tag,+ true,+ None,+ )+ .await+ {+ Ok(def) => Ok(def),+ Err(create_err) => {+ match crate::property_definitions::get::get_tag_definition(db, team_id, user_id).await?+ {+ Some(existing) => Ok(existing),+ None => Err(create_err),+ }+ }+ }+}+#[cfg(test)]mod tests {use super::*;@@ -313,6 +352,7 @@ mod tests {property_definition_id: uuid::Uuid::nil(), // Will be set by the functiondisplay_order: 0,value: PropertyOptionValue::String("Option 1".to_string()),+ color: None,created_at: chrono::Utc::now(),updated_at: chrono::Utc::now(),},@@ -321,6 +361,7 @@ mod tests {property_definition_id: uuid::Uuid::nil(),display_order: 1,value: PropertyOptionValue::String("Option 2".to_string()),+ color: None,created_at: chrono::Utc::now(),updated_at: chrono::Utc::now(),},@@ -399,4 +440,78 @@ mod tests {Ok(())}++ #[sqlx::test(+ migrator = "MACRO_DB_MIGRATIONS",+ fixtures(path = "../../fixtures", scripts("properties"))+ )]+ async fn test_get_or_create_tag_definition_is_idempotent(+ pool: Pool<Postgres>,+ ) -> anyhow::Result<()> {+ const _: &sqlx::migrate::Migrator = &MACRO_DB_MIGRATIONS;++ let owner = DefinitionOwner::Team(team_1());+ let first = get_or_create_tag_definition(&pool, owner).await?;+ assert_eq!(first.data_type, DataType::Tag);+ assert!(first.is_multi_select);++ // A second call returns the same definition rather than creating a duplicate.+ let second = get_or_create_tag_definition(&pool, owner).await?;+ assert_eq!(first.id, second.id);++ Ok(())+ }++ #[sqlx::test(+ migrator = "MACRO_DB_MIGRATIONS",+ fixtures(path = "../../fixtures", scripts("properties"))+ )]+ async fn test_get_tag_definition_none_then_some(pool: Pool<Postgres>) -> anyhow::Result<()> {+ const _: &sqlx::migrate::Migrator = &MACRO_DB_MIGRATIONS;++ let before =+ crate::property_definitions::get::get_tag_definition(&pool, Some(team_1()), None)+ .await?;+ assert!(before.is_none());++ let created = get_or_create_tag_definition(&pool, DefinitionOwner::Team(team_1())).await?;++ let after =+ crate::property_definitions::get::get_tag_definition(&pool, Some(team_1()), None)+ .await?;+ assert_eq!(after.map(|d| d.id), Some(created.id));++ Ok(())+ }++ #[sqlx::test(+ migrator = "MACRO_DB_MIGRATIONS",+ fixtures(path = "../../fixtures", scripts("properties"))+ )]+ async fn test_get_or_create_tag_definition_coexists_with_same_named_property(+ pool: Pool<Postgres>,+ ) -> anyhow::Result<()> {+ const _: &sqlx::migrate::Migrator = &MACRO_DB_MIGRATIONS;++ // Owner already has a non-tag property literally named "Tags".+ create_property_definition(+ &pool,+ DefinitionOwner::Team(team_1()),+ "Tags",+ DataType::String,+ false,+ None,+ )+ .await?;++ // Provisioning the tag set still succeeds: tag definitions are exempt from the+ // display-name uniqueness that applies to user-created properties.+ let tag_def = get_or_create_tag_definition(&pool, DefinitionOwner::Team(team_1())).await?;+ assert_eq!(tag_def.data_type, DataType::Tag);++ let again = get_or_create_tag_definition(&pool, DefinitionOwner::Team(team_1())).await?;+ assert_eq!(tag_def.id, again.id);++ Ok(())+ }}diff --git a/rust/cloud-storage/properties_db_client/src/property_options/get.rs b/rust/cloud-storage/properties_db_client/src/property_options/get.rsindex 6fe918d060..b3ebb4b01d 100644--- a/rust/cloud-storage/properties_db_client/src/property_options/get.rs+++ b/rust/cloud-storage/properties_db_client/src/property_options/get.rs@@ -24,6 +24,7 @@ pub async fn get_property_option_by_id(display_order,number_value,string_value,+ color,created_at,updated_atFROM property_options@@ -52,6 +53,7 @@ pub async fn get_property_options(display_order,number_value,string_value,+ color,created_at,updated_atFROM property_options@@ -112,6 +114,7 @@ pub async fn get_property_options_batch(display_order,number_value,string_value,+ color,created_at,updated_atFROM property_optionsdiff --git a/rust/cloud-storage/properties_db_client/src/property_options/insert.rs b/rust/cloud-storage/properties_db_client/src/property_options/insert.rsindex b42f36fbfc..b60be42215 100644--- a/rust/cloud-storage/properties_db_client/src/property_options/insert.rs+++ b/rust/cloud-storage/properties_db_client/src/property_options/insert.rs@@ -13,6 +13,7 @@ pub async fn create_property_option(property_definition_id: uuid::Uuid,display_order: i32,value: PropertyOptionValue,+ color: Option<String>,) -> Result<PropertyOption> {let id = macro_uuid::generate_uuid_v7();let (number_value, string_value) = value.to_db_values();@@ -24,16 +25,18 @@ pub async fn create_property_option(property_definition_id,display_order,number_value,- string_value+ string_value,+ color)- VALUES ($1, $2, $3, $4, $5)+ VALUES ($1, $2, $3, $4, $5, $6)RETURNING id, created_at, updated_at"#,id,property_definition_id,display_order,number_value,- string_value+ string_value,+ color.clone()).fetch_one(db).await?;@@ -43,6 +46,7 @@ pub async fn create_property_option(property_definition_id,display_order,value,+ color,created_at: row.created_at,updated_at: row.updated_at,})@@ -55,6 +59,7 @@ pub async fn create_property_option_tx(property_definition_id: uuid::Uuid,display_order: i32,value: PropertyOptionValue,+ color: Option<String>,) -> Result<()> {let id = macro_uuid::generate_uuid_v7();let (number_value, string_value) = value.to_db_values();@@ -66,15 +71,17 @@ pub async fn create_property_option_tx(property_definition_id,display_order,number_value,- string_value+ string_value,+ color)- VALUES ($1, $2, $3, $4, $5)+ VALUES ($1, $2, $3, $4, $5, $6)"#,id,property_definition_id,display_order,number_value,- string_value+ string_value,+ color).execute(&mut **tx).await?;@@ -104,7 +111,7 @@ mod tests {let options_before = get_property_options(&pool, property_id).await?;assert_eq!(options_before.len(), 4);- let option = create_property_option(&pool, property_id, 4, value).await?;+ let option = create_property_option(&pool, property_id, 4, value, None).await?;let options_after = get_property_options(&pool, property_id).await?;assert_eq!(options_after.len(), 5);@@ -133,7 +140,7 @@ mod tests {.unwrap();let value = PropertyOptionValue::Number(10.5);- let option = create_property_option(&pool, property_id, 99, value).await?;+ let option = create_property_option(&pool, property_id, 99, value, None).await?;assert_eq!(option.display_order, 99);@@ -158,7 +165,7 @@ mod tests {.unwrap();let value = PropertyOptionValue::Number(3.5);- let option = create_property_option(&pool, property_id, 0, value).await?;+ let option = create_property_option(&pool, property_id, 0, value, None).await?;assert_eq!(option.display_order, 0);@@ -194,7 +201,7 @@ mod tests {.unwrap();let value = PropertyOptionValue::String("Low".to_string()); // Already exists- let result = create_property_option(&pool, property_id, 4, value).await;+ let result = create_property_option(&pool, property_id, 4, value, None).await;assert!(result.is_err());@@ -215,7 +222,7 @@ mod tests {.unwrap();let value = PropertyOptionValue::Number(1.0); // Already exists- let result = create_property_option(&pool, property_id, 5, value).await;+ let result = create_property_option(&pool, property_id, 5, value, None).await;assert!(result.is_err());@@ -236,7 +243,7 @@ mod tests {.unwrap();let value = PropertyOptionValue::String("Test".to_string());- let result = create_property_option(&pool, property_id, 0, value).await;+ let result = create_property_option(&pool, property_id, 0, value, None).await;assert!(result.is_err()); // Foreign key constraint violation@@ -256,7 +263,7 @@ mod tests {let value = PropertyOptionValue::String("Test Option".to_string());let mut tx = pool.begin().await?;- create_property_option_tx(&mut tx, property_id, 10, value).await?;+ create_property_option_tx(&mut tx, property_id, 10, value, None).await?;tx.commit().await?;// Verify it was createddiff --git a/rust/cloud-storage/properties_db_client/src/property_options/mod.rs b/rust/cloud-storage/properties_db_client/src/property_options/mod.rsindex 7a8fba0945..b467dea63e 100644--- a/rust/cloud-storage/properties_db_client/src/property_options/mod.rs+++ b/rust/cloud-storage/properties_db_client/src/property_options/mod.rs@@ -3,3 +3,4 @@pub mod delete;pub mod get;pub mod insert;+pub mod update;diff --git a/rust/cloud-storage/properties_db_client/src/property_options/update.rs b/rust/cloud-storage/properties_db_client/src/property_options/update.rsnew file mode 100644index 0000000000..f019117961--- /dev/null+++ b/rust/cloud-storage/properties_db_client/src/property_options/update.rs@@ -0,0 +1,132 @@+//! Property options update operations.++use crate::error::PropertiesDatabaseError;+use models_properties::db;+use models_properties::service::property_option::{PropertyOption, PropertyOptionValue};+use sqlx::{Pool, Postgres};++type Result<T> = std::result::Result<T, PropertiesDatabaseError>;++/// Updates a property option's value, color, and display order in place.+///+/// The option id is preserved, so every entity referencing this option by id in its+/// `entity_properties.values` reflects the new value and color with no per-entity rewrite.+/// Returns `None` if no option with the given id exists.+#[tracing::instrument(skip(db), err)]+#[allow(+ clippy::disallowed_methods,+ reason = "runtime query mirrors property_options::get"+)]+pub async fn update_property_option(+ db: &Pool<Postgres>,+ option_id: uuid::Uuid,+ value: PropertyOptionValue,+ color: Option<String>,+ display_order: i32,+) -> Result<Option<PropertyOption>> {+ let (number_value, string_value) = value.to_db_values();++ let row = sqlx::query_as::<_, db::PropertyOption>(+ r#"+ UPDATE property_options+ SET number_value = $2,+ string_value = $3,+ color = $4,+ display_order = $5,+ updated_at = NOW()+ WHERE id = $1+ RETURNING+ id,+ property_definition_id,+ display_order,+ number_value,+ string_value,+ color,+ created_at,+ updated_at+ "#,+ )+ .bind(option_id)+ .bind(number_value)+ .bind(string_value)+ .bind(color)+ .bind(display_order)+ .fetch_optional(db)+ .await?;++ Ok(row.map(TryInto::try_into).transpose()?)+}++#[cfg(test)]+mod tests {+ use super::*;+ use crate::property_options::get::get_property_option_by_id;+ use macro_db_migrator::MACRO_DB_MIGRATIONS;+ use sqlx::{Pool, Postgres};++ #[sqlx::test(+ migrator = "MACRO_DB_MIGRATIONS",+ fixtures(path = "../../fixtures", scripts("properties"))+ )]+ async fn test_update_property_option_renames_and_recolors(+ pool: Pool<Postgres>,+ ) -> anyhow::Result<()> {+ const _: &sqlx::migrate::Migrator = &MACRO_DB_MIGRATIONS;++ let option_id = "10111111-1111-1111-1111-111111111111"+ .parse::<uuid::Uuid>()+ .unwrap();++ let updated = update_property_option(+ &pool,+ option_id,+ PropertyOptionValue::String("Lowest".to_string()),+ Some("#FF0000".to_string()),+ 3,+ )+ .await?+ .expect("option should exist");++ // Same id, so every entity referencing it resolves the new value/color (propagation by id).+ assert_eq!(updated.id, option_id);+ assert_eq!(updated.color.as_deref(), Some("#FF0000"));+ assert_eq!(updated.display_order, 3);+ match &updated.value {+ PropertyOptionValue::String(s) => assert_eq!(s, "Lowest"),+ _ => panic!("expected string value"),+ }++ let fetched = get_property_option_by_id(&pool, option_id)+ .await?+ .expect("option should still exist");+ assert_eq!(fetched.color.as_deref(), Some("#FF0000"));++ Ok(())+ }++ #[sqlx::test(+ migrator = "MACRO_DB_MIGRATIONS",+ fixtures(path = "../../fixtures", scripts("properties"))+ )]+ async fn test_update_property_option_missing_returns_none(+ pool: Pool<Postgres>,+ ) -> anyhow::Result<()> {+ const _: &sqlx::migrate::Migrator = &MACRO_DB_MIGRATIONS;++ let missing = "00000000-0000-0000-0000-000000000000"+ .parse::<uuid::Uuid>()+ .unwrap();++ let result = update_property_option(+ &pool,+ missing,+ PropertyOptionValue::String("x".to_string()),+ None,+ 0,+ )+ .await?;+ assert!(result.is_none());++ Ok(())+ }+}diff --git a/rust/cloud-storage/properties_service/src/api/properties/definitions/create.rs b/rust/cloud-storage/properties_service/src/api/properties/definitions/create.rsindex b5276c7dcf..f52e78e56c 100644--- a/rust/cloud-storage/properties_service/src/api/properties/definitions/create.rs+++ b/rust/cloud-storage/properties_service/src/api/properties/definitions/create.rs@@ -105,6 +105,7 @@ pub async fn create_property_definition(property_definition_id: Uuid::nil(), // Temporary ID, will be replaced by DBdisplay_order: opt.display_order,value: PropertyOptionValue::String(opt.value.clone()),+ color: None,created_at: chrono::Utc::now(),updated_at: chrono::Utc::now(),})@@ -119,6 +120,7 @@ pub async fn create_property_definition(property_definition_id: Uuid::nil(), // Temporary ID, will be replaced by DBdisplay_order: opt.display_order,value: PropertyOptionValue::Number(opt.value),+ color: None,created_at: chrono::Utc::now(),updated_at: chrono::Utc::now(),})diff --git a/rust/cloud-storage/properties_service/src/api/properties/entities/get.rs b/rust/cloud-storage/properties_service/src/api/properties/entities/get.rsindex a883abcc16..b3a7974e43 100644--- a/rust/cloud-storage/properties_service/src/api/properties/entities/get.rs+++ b/rust/cloud-storage/properties_service/src/api/properties/entities/get.rs@@ -8,7 +8,9 @@ use thiserror::Error;use crate::api::{context::PropertiesHandlerState,- properties::entities::types::{EntityPropertiesResponse, EntityQueryParams},+ properties::entities::types::{+ EntityPropertiesResponse, EntityQueryParams, retain_caller_visible_tags,+ },};use model::user::UserContext;use models_properties::EntityType;@@ -169,6 +171,8 @@ pub async fn get_entity_properties(let mut all_properties = user_properties;all_properties.extend(metadata_properties);+ retain_caller_visible_tags(&mut all_properties, &user_context.user_id);+let response = EntityPropertiesResponse {entity_id: entity_id.to_string(),properties: all_properties,diff --git a/rust/cloud-storage/properties_service/src/api/properties/entities/get_bulk.rs b/rust/cloud-storage/properties_service/src/api/properties/entities/get_bulk.rsindex cf69bf0c45..841269b331 100644--- a/rust/cloud-storage/properties_service/src/api/properties/entities/get_bulk.rs+++ b/rust/cloud-storage/properties_service/src/api/properties/entities/get_bulk.rs@@ -186,7 +186,12 @@ pub async fn get_bulk_entity_properties(property_ids: request.property_ids.clone(),};- get_bulk_entity_properties_impl(&state, filtered_request)- .await- .map(Json)+ let mut result = get_bulk_entity_properties_impl(&state, filtered_request).await?;+ for response in result.values_mut() {+ crate::api::properties::entities::types::retain_caller_visible_tags(+ &mut response.properties,+ &user_context.user_id,+ );+ }+ Ok(Json(result))}diff --git a/rust/cloud-storage/properties_service/src/api/properties/entities/set.rs b/rust/cloud-storage/properties_service/src/api/properties/entities/set.rsindex 29c9c3c8db..7e96ce3e93 100644--- a/rust/cloud-storage/properties_service/src/api/properties/entities/set.rs+++ b/rust/cloud-storage/properties_service/src/api/properties/entities/set.rs@@ -113,6 +113,7 @@ mod tests {property_definition_id: property_id,display_order: 1,value,+ color: None,created_at: Utc::now(),updated_at: Utc::now(),}diff --git a/rust/cloud-storage/properties_service/src/api/properties/entities/types.rs b/rust/cloud-storage/properties_service/src/api/properties/entities/types.rsindex 07f9dfb2d3..30959e24cf 100644--- a/rust/cloud-storage/properties_service/src/api/properties/entities/types.rs+++ b/rust/cloud-storage/properties_service/src/api/properties/entities/types.rs@@ -5,6 +5,7 @@ use uuid::Uuid;use models_properties::EntityReference;use models_properties::api::SetPropertyValue;use models_properties::service::entity_property_with_definition::EntityPropertyWithDefinition;+use models_properties::{DataType, PropertyOwner};// Re-export EntityQueryParams from models_properties for conveniencepub use models_properties::api::EntityQueryParams;@@ -33,3 +34,22 @@ pub struct BulkEntityPropertiesRequest {#[serde(default)]pub property_ids: Vec<Uuid>,}++/// Drops tag-typed properties the caller may not see. A user-owned tag set (personal labels)+/// is visible only to its owner, so personal tags stay private even on a shared entity.+/// Team- and system-owned tags are the shared vocabulary and are left in place. Non-tag+/// properties are unaffected.+pub fn retain_caller_visible_tags(+ properties: &mut Vec<EntityPropertyWithDefinition>,+ caller_user_id: &str,+) {+ properties.retain(|property| {+ if property.definition.data_type != DataType::Tag {+ return true;+ }+ match &property.definition.owner {+ PropertyOwner::User { user_id } => user_id == caller_user_id,+ PropertyOwner::Team { .. } | PropertyOwner::System => true,+ }+ });+}diff --git a/rust/cloud-storage/properties_service/src/api/properties/mod.rs b/rust/cloud-storage/properties_service/src/api/properties/mod.rsindex 4c846a1386..2156ef3957 100644--- a/rust/cloud-storage/properties_service/src/api/properties/mod.rs+++ b/rust/cloud-storage/properties_service/src/api/properties/mod.rs@@ -8,6 +8,7 @@ pub mod definitions;pub mod entities;pub mod metadata;pub mod options;+pub mod tags;/// Creates the properties router. Works with any state type that implements `FromRef<PropertiesHandlerState>`.pub fn router() -> Router<PropertiesHandlerState> {@@ -36,7 +37,15 @@ pub fn router() -> Router<PropertiesHandlerState> {).route("/definitions/{definition_id}/options/{option_id}",- delete(options::delete::delete_property_option).layer(ensure_user_exists.clone()),+ delete(options::delete::delete_property_option)+ .patch(options::update::update_property_option)+ .layer(ensure_user_exists.clone()),+ )+ .route(+ "/tags",+ get(tags::list_tags)+ .post(tags::ensure_tag_set)+ .layer(ensure_user_exists.clone()),)// Entity Property Operations// GET allows anonymous access for public entitiesdiff --git a/rust/cloud-storage/properties_service/src/api/properties/options/create.rs b/rust/cloud-storage/properties_service/src/api/properties/options/create.rsindex 85ee793582..3b27843612 100644--- a/rust/cloud-storage/properties_service/src/api/properties/options/create.rs+++ b/rust/cloud-storage/properties_service/src/api/properties/options/create.rs@@ -129,22 +129,43 @@ pub async fn add_property_option(return Err(AddPropertyOptionErr::InvalidRequest(err.to_string()));}- let (display_order, option_value) = match &request {+ let (display_order, option_value, color) = match &request {AddPropertyOptionRequest::SelectString { option } => (option.display_order,PropertyOptionValue::String(option.value.clone()),+ option.color.clone(),),AddPropertyOptionRequest::SelectNumber { option } => (option.display_order,PropertyOptionValue::Number(option.value),+ None,),};+ if color.is_some() && property_definition.data_type != models_properties::DataType::Tag {+ return Err(AddPropertyOptionErr::InvalidRequest(+ "color is only supported on tag options".to_string(),+ ));+ }+ if let Some(color) = &color+ && !models_properties::api::is_valid_hex_color(color)+ {+ return Err(AddPropertyOptionErr::InvalidRequest(+ "color must be a hex string like #RRGGBB".to_string(),+ ));+ }+ if property_definition.data_type == models_properties::DataType::Tag && color.is_none() {+ return Err(AddPropertyOptionErr::InvalidRequest(+ "tag options require a color".to_string(),+ ));+ }+let option = property_options_insert::create_property_option(&state.db,property_uuid,display_order,option_value,+ color,).await.inspect_err(|e| {diff --git a/rust/cloud-storage/properties_service/src/api/properties/options/mod.rs b/rust/cloud-storage/properties_service/src/api/properties/options/mod.rsindex d340a9ce1e..f4b0d33ab6 100644--- a/rust/cloud-storage/properties_service/src/api/properties/options/mod.rs+++ b/rust/cloud-storage/properties_service/src/api/properties/options/mod.rs@@ -1,3 +1,4 @@pub mod create;pub mod delete;pub mod get;+pub mod update;diff --git a/rust/cloud-storage/properties_service/src/api/properties/options/update.rs b/rust/cloud-storage/properties_service/src/api/properties/options/update.rsnew file mode 100644index 0000000000..a104c73773--- /dev/null+++ b/rust/cloud-storage/properties_service/src/api/properties/options/update.rs@@ -0,0 +1,177 @@+use axum::{+ Json,+ extract::{Extension, Path, State},+ http::StatusCode,+ response::{IntoResponse, Response},+};+use thiserror::Error;+use uuid::Uuid;++use crate::api::context::{PropertiesHandlerState, PropertyTeamExtractor, caller_team_id};+use model::user::UserContext;+use models_properties::DataType;+use models_properties::api::{UpdatePropertyOptionRequest, is_valid_hex_color};+use models_properties::service::property_option::{PropertyOption, PropertyOptionValue};+use properties_db_client::{+ error::PropertiesDatabaseError, property_definitions::get as property_definitions_get,+ property_options::get as property_options_get,+ property_options::update as property_options_update,+};++#[derive(Debug, Error)]+pub enum UpdatePropertyOptionErr {+ #[error("An internal error occurred")]+ InternalError(#[from] anyhow::Error),+ #[error("An internal error occurred")]+ DatabaseError(#[from] PropertiesDatabaseError),+ #[error("Property definition not found")]+ PropertyNotFound,+ #[error("Cannot modify system properties")]+ SystemPropertyNotModifiable,+ #[error("Property option not found")]+ OptionNotFound,+ #[error("{0}")]+ InvalidRequest(String),+ #[error("An option with that value already exists")]+ Conflict,+}++impl IntoResponse for UpdatePropertyOptionErr {+ fn into_response(self) -> Response {+ let status_code = match &self {+ UpdatePropertyOptionErr::InternalError(_)+ | UpdatePropertyOptionErr::DatabaseError(_) => StatusCode::INTERNAL_SERVER_ERROR,+ UpdatePropertyOptionErr::PropertyNotFound | UpdatePropertyOptionErr::OptionNotFound => {+ StatusCode::NOT_FOUND+ }+ UpdatePropertyOptionErr::SystemPropertyNotModifiable => StatusCode::FORBIDDEN,+ UpdatePropertyOptionErr::InvalidRequest(_) => StatusCode::BAD_REQUEST,+ UpdatePropertyOptionErr::Conflict => StatusCode::CONFLICT,+ };++ if status_code.is_server_error() {+ tracing::error!(+ error = ?self,+ error_type = "UpdatePropertyOptionErr",+ "Internal server error"+ );+ }++ (status_code, self.to_string()).into_response()+ }+}++/// Update a property option in place (rename / recolor / reorder).+///+/// The option id is preserved, so the change is reflected on every entity that references it.+#[utoipa::path(+ patch,+ path = "/properties/definitions/{definition_id}/options/{option_id}",+ params(+ ("definition_id" = Uuid, Path, description = "Property definition ID"),+ ("option_id" = Uuid, Path, description = "Property option ID")+ ),+ request_body = UpdatePropertyOptionRequest,+ responses(+ (status = 200, description = "Property option updated", body = PropertyOption),+ (status = 400, description = "Invalid request"),+ (status = 403, description = "Cannot modify system properties"),+ (status = 404, description = "Property or option not found"),+ (status = 409, description = "An option with that value already exists"),+ (status = 500, description = "Internal server error")+ ),+ tags = ["Properties"]+)]+#[tracing::instrument(skip(state, user_context, team), fields(property_id = %def_uuid, option_id = %option_uuid, request = ?request), err)]+pub async fn update_property_option(+ Path((def_uuid, option_uuid)): Path<(Uuid, Uuid)>,+ State(state): State<PropertiesHandlerState>,+ Extension(user_context): Extension<UserContext>,+ team: PropertyTeamExtractor,+ Json(request): Json<UpdatePropertyOptionRequest>,+) -> Result<(StatusCode, Json<PropertyOption>), UpdatePropertyOptionErr> {+ let property = property_definitions_get::get_property_definition(&state.db, def_uuid)+ .await?+ .ok_or(UpdatePropertyOptionErr::PropertyNotFound)?;++ if property.is_system {+ return Err(UpdatePropertyOptionErr::SystemPropertyNotModifiable);+ }++ let definition = property_definitions_get::get_property_definition_with_owner(+ &state.db,+ def_uuid,+ &user_context.user_id,+ caller_team_id(&team),+ )+ .await?+ .ok_or(UpdatePropertyOptionErr::PropertyNotFound)?;++ let option = property_options_get::get_property_option_by_id(&state.db, option_uuid)+ .await?+ .ok_or(UpdatePropertyOptionErr::OptionNotFound)?;++ if option.property_definition_id != def_uuid {+ return Err(UpdatePropertyOptionErr::OptionNotFound);+ }++ let new_value = match &request.value {+ Some(value) => match definition.data_type {+ DataType::SelectString | DataType::Tag => {+ if value.trim().is_empty() {+ return Err(UpdatePropertyOptionErr::InvalidRequest(+ "value cannot be empty".to_string(),+ ));+ }+ PropertyOptionValue::String(value.clone())+ }+ _ => {+ return Err(UpdatePropertyOptionErr::InvalidRequest(+ "value updates are only supported for string and tag options".to_string(),+ ));+ }+ },+ None => option.value.clone(),+ };++ if request.color.is_some() && definition.data_type != DataType::Tag {+ return Err(UpdatePropertyOptionErr::InvalidRequest(+ "color is only supported on tag options".to_string(),+ ));+ }++ if let Some(color) = &request.color+ && !is_valid_hex_color(color)+ {+ return Err(UpdatePropertyOptionErr::InvalidRequest(+ "color must be a hex string like #RRGGBB".to_string(),+ ));+ }+ let new_color = request.color.clone().or_else(|| option.color.clone());+ if definition.data_type == DataType::Tag && new_color.is_none() {+ return Err(UpdatePropertyOptionErr::InvalidRequest(+ "tag options require a color".to_string(),+ ));+ }++ let new_display_order = request.display_order.unwrap_or(option.display_order);++ match property_options_update::update_property_option(+ &state.db,+ option_uuid,+ new_value,+ new_color,+ new_display_order,+ )+ .await+ {+ Ok(Some(updated)) => Ok((StatusCode::OK, Json(updated))),+ Ok(None) => Err(UpdatePropertyOptionErr::OptionNotFound),+ Err(PropertiesDatabaseError::Query(sqlx::Error::Database(db_err)))+ if db_err.is_unique_violation() =>+ {+ Err(UpdatePropertyOptionErr::Conflict)+ }+ Err(e) => Err(e.into()),+ }+}diff --git a/rust/cloud-storage/properties_service/src/api/properties/tags.rs b/rust/cloud-storage/properties_service/src/api/properties/tags.rsnew file mode 100644index 0000000000..01629d3f3d--- /dev/null+++ b/rust/cloud-storage/properties_service/src/api/properties/tags.rs@@ -0,0 +1,164 @@+use axum::{+ Json,+ extract::{Extension, State},+ http::StatusCode,+ response::{IntoResponse, Response},+};+use serde::{Deserialize, Serialize};+use thiserror::Error;+use utoipa::ToSchema;++use crate::api::context::{PropertiesHandlerState, PropertyTeamExtractor, caller_team_id};+use model::user::UserContext;+use models_properties::api::{PropertyDefinitionDetailResponse, PropertyOptionResponse};+use models_properties::service::property_definition::PropertyDefinition;+use properties_db_client::{+ error::PropertiesDatabaseError,+ property_definitions::{+ get as property_definitions_get,+ insert::{self as property_definitions_insert, DefinitionOwner},+ },+ property_options::get as property_options_get,+};++/// Which owner a tag set belongs to.+#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema, PartialEq)]+#[serde(rename_all = "snake_case")]+pub enum TagScope {+ /// The caller's personal tag set.+ User,+ /// The caller's team tag set.+ Team,+}++/// A tag set the caller can use. `definition` is absent until the set is provisioned+/// (on first label create), in which case `options` is empty.+#[derive(Debug, Serialize, ToSchema)]+pub struct TagSetResponse {+ pub scope: TagScope,+ #[serde(skip_serializing_if = "Option::is_none")]+ pub definition: Option<PropertyDefinitionDetailResponse>,+ pub options: Vec<PropertyOptionResponse>,+}++/// Request to provision (get-or-create) the caller's tag set for a scope.+#[derive(Debug, Deserialize, ToSchema)]+pub struct EnsureTagSetRequest {+ pub scope: TagScope,+}++#[derive(Debug, Error)]+pub enum TagsError {+ #[error("An internal error occurred")]+ Internal(#[from] anyhow::Error),+ #[error("An internal error occurred")]+ Database(#[from] PropertiesDatabaseError),+ #[error("You must be on a team to use team tags")]+ TeamMembershipRequired,+}++impl IntoResponse for TagsError {+ fn into_response(self) -> Response {+ let status_code = match &self {+ TagsError::Internal(_) | TagsError::Database(_) => StatusCode::INTERNAL_SERVER_ERROR,+ TagsError::TeamMembershipRequired => StatusCode::FORBIDDEN,+ };++ if status_code.is_server_error() {+ tracing::error!(error = ?self, error_type = "TagsError", "Internal server error");+ }++ (status_code, self.to_string()).into_response()+ }+}++/// List the caller's tag sets: their personal set, plus their team's set when on a team.+/// Pure read - a scope with no provisioned definition yet returns an empty set.+#[utoipa::path(+ get,+ path = "/properties/tags",+ responses(+ (status = 200, description = "Tag sets retrieved", body = Vec<TagSetResponse>),+ (status = 500, description = "Internal server error")+ ),+ tag = "Properties"+)]+#[tracing::instrument(skip(state, user_context, team), fields(user_id = %user_context.user_id), err)]+pub async fn list_tags(+ State(state): State<PropertiesHandlerState>,+ Extension(user_context): Extension<UserContext>,+ team: PropertyTeamExtractor,+) -> Result<Json<Vec<TagSetResponse>>, TagsError> {+ let mut sets = Vec::new();++ let user_definition =+ property_definitions_get::get_tag_definition(&state.db, None, Some(&user_context.user_id))+ .await?;+ sets.push(build_tag_set(&state.db, TagScope::User, user_definition).await?);++ if let Some(team_id) = caller_team_id(&team) {+ let team_definition =+ property_definitions_get::get_tag_definition(&state.db, Some(team_id), None).await?;+ sets.push(build_tag_set(&state.db, TagScope::Team, team_definition).await?);+ }++ Ok(Json(sets))+}++/// Provision (get-or-create) the caller's tag set for a scope and return it. Called when+/// the caller creates their first label for that scope, so the read path stays side-effect free.+#[utoipa::path(+ post,+ path = "/properties/tags",+ request_body = EnsureTagSetRequest,+ responses(+ (status = 200, description = "Tag set provisioned", body = TagSetResponse),+ (status = 403, description = "Team membership required for team scope"),+ (status = 500, description = "Internal server error")+ ),+ tag = "Properties"+)]+#[tracing::instrument(skip(state, user_context, team), fields(user_id = %user_context.user_id, scope = ?request.scope), err)]+pub async fn ensure_tag_set(+ State(state): State<PropertiesHandlerState>,+ Extension(user_context): Extension<UserContext>,+ team: PropertyTeamExtractor,+ Json(request): Json<EnsureTagSetRequest>,+) -> Result<Json<TagSetResponse>, TagsError> {+ let owner = match request.scope {+ TagScope::User => DefinitionOwner::User(user_context.user_id.as_str()),+ TagScope::Team => {+ let team_id = caller_team_id(&team).ok_or(TagsError::TeamMembershipRequired)?;+ DefinitionOwner::Team(team_id)+ }+ };++ let definition =+ property_definitions_insert::get_or_create_tag_definition(&state.db, owner).await?;+ let set = build_tag_set(&state.db, request.scope, Some(definition)).await?;++ Ok(Json(set))+}++/// Resolve a tag set's options into the response shape. A missing definition yields an empty set.+async fn build_tag_set(+ db: &sqlx::PgPool,+ scope: TagScope,+ definition: Option<PropertyDefinition>,+) -> Result<TagSetResponse, PropertiesDatabaseError> {+ match definition {+ Some(definition) => {+ let options = property_options_get::get_property_options(db, definition.id).await?;+ Ok(TagSetResponse {+ scope,+ definition: Some(definition.into()),+ options: options.into_iter().map(Into::into).collect(),+ })+ }+ None => Ok(TagSetResponse {+ scope,+ definition: None,+ options: Vec::new(),+ }),+ }+}diff --git a/rust/cloud-storage/properties_service/src/api/swagger.rs b/rust/cloud-storage/properties_service/src/api/swagger.rsindex 1e24f79286..4293a1a5fe 100644--- a/rust/cloud-storage/properties_service/src/api/swagger.rs+++ b/rust/cloud-storage/properties_service/src/api/swagger.rs@@ -4,6 +4,7 @@ use crate::api::properties::{EntityPropertiesResponse, EntityQueryParams, SetEntityPropertyRequest,types::BulkEntityPropertiesRequest,},+ tags::{EnsureTagSetRequest, TagScope, TagSetResponse},};use models_properties::api;use utoipa::OpenApi;@@ -21,7 +22,10 @@ use utoipa::OpenApi;// Property optionscrate::api::properties::options::get::get_property_options,crate::api::properties::options::create::add_property_option,+ crate::api::properties::options::update::update_property_option,crate::api::properties::options::delete::delete_property_option,+ crate::api::properties::tags::list_tags,+ crate::api::properties::tags::ensure_tag_set,// Entity propertiescrate::api::properties::entities::get::get_entity_properties,crate::api::properties::entities::get_bulk::get_bulk_entity_properties,@@ -47,12 +51,16 @@ use utoipa::OpenApi;api::AddPropertyOptionRequest,api::AddStringOptionRequest,api::AddNumberOptionRequest,- api::PropertyDefinitionResponse,+ api::UpdatePropertyOptionRequest,+ api::PropertyDefinitionDetailResponse,api::PropertyOptionResponse,models_properties::EntityType,models_properties::DataType,api::EntityPropertyWithDefinitionResponse,api::PropertyValue,+ TagScope,+ TagSetResponse,+ EnsureTagSetRequest,)),tags(