Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(properties): team-owned properties, remove organization ownership (#4376)

gbirmandf297ed17451
diff --git a/js/app/packages/entity/mocks/mockEntityData.ts b/js/app/packages/entity/mocks/mockEntityData.ts
index 64d17c24f2..b669f88ece 100644
--- a/js/app/packages/entity/mocks/mockEntityData.ts
+++ b/js/app/packages/entity/mocks/mockEntityData.ts
@@ -71,7 +71,7 @@ const MOCK_PROPERTIES: Property[] = [
display_order: 2,
},
],
- owner: { scope: 'organization', organization_id: 1 },
+ owner: { scope: 'team', team_id: '00000000-0000-0000-0000-000000000001' },
createdAt: MOCK_TIMESTAMPS.lastMonth,
updatedAt: MOCK_TIMESTAMPS.today,
},
@@ -108,7 +108,7 @@ const MOCK_PROPERTIES: Property[] = [
display_order: 2,
},
],
- owner: { scope: 'organization', organization_id: 1 },
+ owner: { scope: 'team', team_id: '00000000-0000-0000-0000-000000000001' },
createdAt: MOCK_TIMESTAMPS.lastMonth,
updatedAt: MOCK_TIMESTAMPS.today,
},
@@ -119,7 +119,7 @@ const MOCK_PROPERTIES: Property[] = [
isMultiSelect: false,
valueType: 'DATE',
value: applyDurationToDate(MOCK_TIMESTAMPS.now, { value: 7, unit: 'd' }), // 7 days from now
- owner: { scope: 'organization', organization_id: 1 },
+ owner: { scope: 'team', team_id: '00000000-0000-0000-0000-000000000001' },
createdAt: MOCK_TIMESTAMPS.lastMonth,
updatedAt: MOCK_TIMESTAMPS.today,
},
diff --git a/js/app/packages/property/src/component/modal/CreatePropertyModal.tsx b/js/app/packages/property/src/component/modal/CreatePropertyModal.tsx
index 63793b1ebf..69d5a073c4 100644
--- a/js/app/packages/property/src/component/modal/CreatePropertyModal.tsx
+++ b/js/app/packages/property/src/component/modal/CreatePropertyModal.tsx
@@ -368,7 +368,6 @@ export const CreatePropertyModal: Component<CreatePropertyModalProps> = (
const bodyData = {
scope: 'user' as const,
- user_id: currentUserId!,
display_name: newPropertyName().trim(),
data_type: buildDataType(),
};
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/createPropertyDefinitionRequest.ts b/js/app/packages/service-clients/service-properties/generated/schemas/createPropertyDefinitionRequest.ts
index 3bd9570ffa..cf088efb44 100644
--- a/js/app/packages/service-clients/service-properties/generated/schemas/createPropertyDefinitionRequest.ts
+++ b/js/app/packages/service-clients/service-properties/generated/schemas/createPropertyDefinitionRequest.ts
@@ -5,11 +5,14 @@
* OpenAPI spec version: 0.1.0
*/
-import type { CreatePropertyDefinitionRequestAllOf } from './createPropertyDefinitionRequestAllOf';
-import type { PropertyOwner } from './propertyOwner';
+import type { CreatePropertyScope } from './createPropertyScope';
+import type { PropertyDataType } from './propertyDataType';
/**
* Request to create a new property definition.
*/
-export type CreatePropertyDefinitionRequest = PropertyOwner &
- CreatePropertyDefinitionRequestAllOf;
+export interface CreatePropertyDefinitionRequest {
+ data_type: PropertyDataType;
+ display_name: string;
+ scope: CreatePropertyScope;
+}
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/createPropertyDefinitionRequestAllOf.ts b/js/app/packages/service-clients/service-properties/generated/schemas/createPropertyDefinitionRequestAllOf.ts
deleted file mode 100644
index 3b216db480..0000000000
--- a/js/app/packages/service-clients/service-properties/generated/schemas/createPropertyDefinitionRequestAllOf.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * Generated by orval v7.21.0 🍺
- * Do not edit manually.
- * properties_service
- * OpenAPI spec version: 0.1.0
- */
-import type { PropertyDataType } from './propertyDataType';
-
-export type CreatePropertyDefinitionRequestAllOf = {
- data_type: PropertyDataType;
- display_name: string;
-};
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/createPropertyScope.ts b/js/app/packages/service-clients/service-properties/generated/schemas/createPropertyScope.ts
new file mode 100644
index 0000000000..7801aba1cd
--- /dev/null
+++ b/js/app/packages/service-clients/service-properties/generated/schemas/createPropertyScope.ts
@@ -0,0 +1,20 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * properties_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Ownership scope a client may request when creating a property definition.
+The owning user or team is derived server-side from the authenticated caller -
+clients never supply owner ids. System properties are not creatable via the API.
+ */
+export type CreatePropertyScope =
+ (typeof CreatePropertyScope)[keyof typeof CreatePropertyScope];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const CreatePropertyScope = {
+ user: 'user',
+ team: 'team',
+} as const;
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/listPropertiesParams.ts b/js/app/packages/service-clients/service-properties/generated/schemas/listPropertiesParams.ts
index 303b778424..843030e5bb 100644
--- a/js/app/packages/service-clients/service-properties/generated/schemas/listPropertiesParams.ts
+++ b/js/app/packages/service-clients/service-properties/generated/schemas/listPropertiesParams.ts
@@ -10,7 +10,7 @@ import type { PropertyScope } from './propertyScope';
export type ListPropertiesParams = {
/**
- * Filter by scope: 'user', 'org', 'system', or 'all'
+ * Filter by scope: 'user', 'team', 'system', or 'all'
*/
scope: PropertyScope;
/**
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwner.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwner.ts
index 251d228a0b..83fb1ba1d9 100644
--- a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwner.ts
+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwner.ts
@@ -6,14 +6,12 @@
*/
import type { PropertyOwnerOneOf } from './propertyOwnerOneOf';
import type { PropertyOwnerOneOfFive } from './propertyOwnerOneOfFive';
-import type { PropertyOwnerOneOfSeven } from './propertyOwnerOneOfSeven';
import type { PropertyOwnerOneOfThree } from './propertyOwnerOneOfThree';
/**
- * Defines who owns a property - user-scoped, org-scoped, system, or both user and org.
+ * Defines who owns a property - user-scoped, team-scoped, or system.
*/
export type PropertyOwner =
| PropertyOwnerOneOf
| PropertyOwnerOneOfThree
- | PropertyOwnerOneOfFive
- | PropertyOwnerOneOfSeven;
+ | PropertyOwnerOneOfFive;
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOf.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOf.ts
index f0b014b612..862f91ee2e 100644
--- a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOf.ts
+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOf.ts
@@ -7,7 +7,7 @@
import type { PropertyOwnerOneOfScope } from './propertyOwnerOneOfScope';
/**
- * User-scoped property only
+ * User-scoped property.
*/
export type PropertyOwnerOneOf = {
scope: PropertyOwnerOneOfScope;
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfFive.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfFive.ts
index f9fcbb6ad4..4fd8075b40 100644
--- a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfFive.ts
+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfFive.ts
@@ -7,10 +7,8 @@
import type { PropertyOwnerOneOfFiveScope } from './propertyOwnerOneOfFiveScope';
/**
- * Both user and organization-scoped
+ * System-owned property (no user or team owner).
*/
export type PropertyOwnerOneOfFive = {
- organization_id: number;
scope: PropertyOwnerOneOfFiveScope;
- user_id: string;
};
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfFiveScope.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfFiveScope.ts
index 10773e9eae..976f7512bd 100644
--- a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfFiveScope.ts
+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfFiveScope.ts
@@ -10,5 +10,5 @@ export type PropertyOwnerOneOfFiveScope =
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PropertyOwnerOneOfFiveScope = {
- user_and_organization: 'user_and_organization',
+ system: 'system',
} as const;
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfSeven.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfSeven.ts
deleted file mode 100644
index 821b210fa9..0000000000
--- a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfSeven.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Generated by orval v7.21.0 🍺
- * Do not edit manually.
- * properties_service
- * OpenAPI spec version: 0.1.0
- */
-import type { PropertyOwnerOneOfSevenScope } from './propertyOwnerOneOfSevenScope';
-
-/**
- * System-owned property (no user or org owner)
- */
-export type PropertyOwnerOneOfSeven = {
- scope: PropertyOwnerOneOfSevenScope;
-};
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfSevenScope.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfSevenScope.ts
deleted file mode 100644
index a386a083f5..0000000000
--- a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfSevenScope.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Generated by orval v7.21.0 🍺
- * Do not edit manually.
- * properties_service
- * OpenAPI spec version: 0.1.0
- */
-
-export type PropertyOwnerOneOfSevenScope =
- (typeof PropertyOwnerOneOfSevenScope)[keyof typeof PropertyOwnerOneOfSevenScope];
-
-// eslint-disable-next-line @typescript-eslint/no-redeclare
-export const PropertyOwnerOneOfSevenScope = {
- system: 'system',
-} as const;
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfThree.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfThree.ts
index 71e0b8bf21..a74796a56f 100644
--- a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfThree.ts
+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfThree.ts
@@ -7,9 +7,9 @@
import type { PropertyOwnerOneOfThreeScope } from './propertyOwnerOneOfThreeScope';
/**
- * Organization-scoped property only
+ * Team-scoped property.
*/
export type PropertyOwnerOneOfThree = {
- organization_id: number;
scope: PropertyOwnerOneOfThreeScope;
+ team_id: string;
};
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfThreeScope.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfThreeScope.ts
index 0ac0a4c4b6..f4afd0d014 100644
--- a/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfThreeScope.ts
+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyOwnerOneOfThreeScope.ts
@@ -10,5 +10,5 @@ export type PropertyOwnerOneOfThreeScope =
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PropertyOwnerOneOfThreeScope = {
- organization: 'organization',
+ team: 'team',
} as const;
diff --git a/js/app/packages/service-clients/service-properties/generated/schemas/propertyScope.ts b/js/app/packages/service-clients/service-properties/generated/schemas/propertyScope.ts
index 99e987418f..48c310d69e 100644
--- a/js/app/packages/service-clients/service-properties/generated/schemas/propertyScope.ts
+++ b/js/app/packages/service-clients/service-properties/generated/schemas/propertyScope.ts
@@ -13,7 +13,7 @@ export type PropertyScope = (typeof PropertyScope)[keyof typeof PropertyScope];
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PropertyScope = {
user: 'user',
- org: 'org',
+ team: 'team',
system: 'system',
all: 'all',
} as const;
diff --git a/js/app/packages/service-clients/service-properties/generated/zod.ts b/js/app/packages/service-clients/service-properties/generated/zod.ts
index 3930e7cd7c..e7d3fd6a17 100644
--- a/js/app/packages/service-clients/service-properties/generated/zod.ts
+++ b/js/app/packages/service-clients/service-properties/generated/zod.ts
@@ -11,8 +11,8 @@ import * as zod from 'zod';
*/
export const listPropertiesQueryParams = zod.object({
scope: zod
- .enum(['user', 'org', 'system', 'all'])
- .describe("Filter by scope: 'user', 'org', 'system', or 'all'"),
+ .enum(['user', 'team', 'system', 'all'])
+ .describe("Filter by scope: 'user', 'team', 'system', or 'all'"),
include_options: zod
.boolean()
.optional()
@@ -71,28 +71,21 @@ export const listPropertiesResponseItem = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe('Organization-scoped property only'),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum(['user_and_organization']),
- user_id: zod.string(),
- })
- .describe('Both user and organization-scoped'),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
- .describe('System-owned property (no user or org owner)'),
+ .describe('System-owned property (no user or team owner).'),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -155,28 +148,21 @@ export const listPropertiesResponseItem = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
- })
- .describe('Organization-scoped property only'),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['user_and_organization']),
- user_id: zod.string(),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe('Both user and organization-scoped'),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
- .describe('System-owned property (no user or org owner)'),
+ .describe('System-owned property (no user or team owner).'),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -247,125 +233,99 @@ export const listPropertiesResponse = zod.array(listPropertiesResponseItem);
* @summary Create a new property definition
*/
export const createPropertyDefinitionBody = zod
- .union([
- zod
- .object({
- scope: zod.enum(['user']),
- user_id: zod.string(),
- })
- .describe('User-scoped property only'),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
- })
- .describe('Organization-scoped property only'),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum(['user_and_organization']),
- user_id: zod.string(),
- })
- .describe('Both user and organization-scoped'),
- zod
- .object({
- scope: zod.enum(['system']),
- })
- .describe('System-owned property (no user or org owner)'),
- ])
- .describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
- )
- .and(
- zod.object({
- data_type: zod
- .union([
- zod
- .object({
- type: zod.enum(['boolean']),
- })
- .describe('Boolean true\/false values.'),
- zod
- .object({
- type: zod.enum(['date']),
- })
- .describe('Date and time values.'),
- zod
- .object({
- type: zod.enum(['number']),
- })
- .describe('Numeric values.'),
- zod
- .object({
- type: zod.enum(['string']),
- })
- .describe('String\/text values.'),
- zod
- .object({
- multi: zod.boolean(),
- options: zod.array(
- zod
- .object({
- display_order: zod.number(),
- value: zod.number(),
- })
- .describe('Option for select number properties in requests.')
- ),
- type: zod.enum(['select_number']),
- })
- .describe('Select property with numeric options.'),
- zod
- .object({
- multi: zod.boolean(),
- options: zod.array(
+ .object({
+ data_type: zod
+ .union([
+ zod
+ .object({
+ type: zod.enum(['boolean']),
+ })
+ .describe('Boolean true\/false values.'),
+ zod
+ .object({
+ type: zod.enum(['date']),
+ })
+ .describe('Date and time values.'),
+ zod
+ .object({
+ type: zod.enum(['number']),
+ })
+ .describe('Numeric values.'),
+ zod
+ .object({
+ type: zod.enum(['string']),
+ })
+ .describe('String\/text values.'),
+ zod
+ .object({
+ multi: zod.boolean(),
+ options: zod.array(
+ zod
+ .object({
+ display_order: zod.number(),
+ value: zod.number(),
+ })
+ .describe('Option for select number properties in requests.')
+ ),
+ type: zod.enum(['select_number']),
+ })
+ .describe('Select property with numeric options.'),
+ zod
+ .object({
+ multi: zod.boolean(),
+ options: zod.array(
+ zod
+ .object({
+ display_order: zod.number(),
+ value: zod.string(),
+ })
+ .describe('Option for select-type properties in requests.')
+ ),
+ type: zod.enum(['select_string']),
+ })
+ .describe('Select property with string options.'),
+ zod
+ .object({
+ multi: zod.boolean(),
+ specific_type: zod
+ .union([
+ zod.null(),
zod
- .object({
- display_order: zod.number(),
- value: zod.string(),
- })
- .describe('Option for select-type properties in requests.')
- ),
- type: zod.enum(['select_string']),
- })
- .describe('Select property with string options.'),
- zod
- .object({
- multi: zod.boolean(),
- specific_type: 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(),
- type: zod.enum(['entity']),
- })
- .describe('Entity reference property.'),
- zod
- .object({
- multi: zod.boolean(),
- type: zod.enum(['link']),
- })
- .describe('Link property.'),
- ])
- .describe(
- 'Data type with embedded options for requests - provides compile-time validation.'
- ),
- display_name: zod.string(),
- })
- )
+ .enum([
+ 'CHANNEL',
+ 'CHAT',
+ 'COMPANY',
+ 'DOCUMENT',
+ 'PROJECT',
+ 'TASK',
+ 'THREAD',
+ 'USER',
+ ])
+ .describe(
+ 'Type of entity that can be referenced by entity properties.'
+ ),
+ ])
+ .optional(),
+ type: zod.enum(['entity']),
+ })
+ .describe('Entity reference property.'),
+ zod
+ .object({
+ multi: zod.boolean(),
+ type: zod.enum(['link']),
+ })
+ .describe('Link property.'),
+ ])
+ .describe(
+ 'Data type with embedded options for requests - provides compile-time validation.'
+ ),
+ display_name: zod.string(),
+ scope: zod
+ .enum(['user', 'team'])
+ .describe(
+ 'Ownership scope a client may request when creating a property definition.\nThe owning user or team is derived server-side from the authenticated caller -\nclients never supply owner ids. System properties are not creatable via the API.'
+ ),
+ })
.describe('Request to create a new property definition.');
/**
@@ -555,28 +515,23 @@ export const getBulkEntityPropertiesResponse = zod.record(
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
- })
- .describe('Organization-scoped property only'),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['user_and_organization']),
- user_id: zod.string(),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe('Both user and organization-scoped'),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
- .describe('System-owned property (no user or org owner)'),
+ .describe(
+ 'System-owned property (no user or team owner).'
+ ),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -867,28 +822,21 @@ export const getEntityPropertiesResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
- })
- .describe('Organization-scoped property only'),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum(['user_and_organization']),
- user_id: zod.string(),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe('Both user and organization-scoped'),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
- .describe('System-owned property (no user or org owner)'),
+ .describe('System-owned property (no user or team owner).'),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
diff --git a/js/app/packages/service-clients/service-properties/openapi.json b/js/app/packages/service-clients/service-properties/openapi.json
index 122f065225..0a47c7a010 100644
--- a/js/app/packages/service-clients/service-properties/openapi.json
+++ b/js/app/packages/service-clients/service-properties/openapi.json
@@ -19,7 +19,7 @@
{
"name": "scope",
"in": "query",
- "description": "Filter by scope: 'user', 'org', 'system', or 'all'",
+ "description": "Filter by scope: 'user', 'team', 'system', or 'all'",
"required": true,
"schema": {
"$ref": "#/components/schemas/PropertyScope"
@@ -94,6 +94,9 @@
"400": {
"description": "Invalid request"
},
+ "403": {
+ "description": "Team membership required for team scope"
+ },
"500": {
"description": "Internal server error"
}
@@ -560,24 +563,25 @@
}
},
"CreatePropertyDefinitionRequest": {
- "allOf": [
- {
- "$ref": "#/components/schemas/PropertyOwner"
+ "type": "object",
+ "description": "Request to create a new property definition.",
+ "required": ["scope", "display_name", "data_type"],
+ "properties": {
+ "data_type": {
+ "$ref": "#/components/schemas/PropertyDataType"
},
- {
- "type": "object",
- "required": ["display_name", "data_type"],
- "properties": {
- "data_type": {
- "$ref": "#/components/schemas/PropertyDataType"
- },
- "display_name": {
- "type": "string"
- }
- }
+ "display_name": {
+ "type": "string"
+ },
+ "scope": {
+ "$ref": "#/components/schemas/CreatePropertyScope"
}
- ],
- "description": "Request to create a new property definition."
+ }
+ },
+ "CreatePropertyScope": {
+ "type": "string",
+ "description": "Ownership scope a client may request when creating a property definition.\nThe owning user or team is derived server-side from the authenticated caller -\nclients never supply owner ids. System properties are not creatable via the API.",
+ "enum": ["user", "team"]
},
"DataType": {
"type": "string",
@@ -1128,7 +1132,7 @@
"oneOf": [
{
"type": "object",
- "description": "User-scoped property only",
+ "description": "User-scoped property.",
"required": ["user_id", "scope"],
"properties": {
"scope": {
@@ -1142,40 +1146,22 @@
},
{
"type": "object",
- "description": "Organization-scoped property only",
- "required": ["organization_id", "scope"],
+ "description": "Team-scoped property.",
+ "required": ["team_id", "scope"],
"properties": {
- "organization_id": {
- "type": "integer",
- "format": "int32"
- },
"scope": {
"type": "string",
- "enum": ["organization"]
- }
- }
- },
- {
- "type": "object",
- "description": "Both user and organization-scoped",
- "required": ["user_id", "organization_id", "scope"],
- "properties": {
- "organization_id": {
- "type": "integer",
- "format": "int32"
+ "enum": ["team"]
},
- "scope": {
+ "team_id": {
"type": "string",
- "enum": ["user_and_organization"]
- },
- "user_id": {
- "type": "string"
+ "format": "uuid"
}
}
},
{
"type": "object",
- "description": "System-owned property (no user or org owner)",
+ "description": "System-owned property (no user or team owner).",
"required": ["scope"],
"properties": {
"scope": {
@@ -1185,12 +1171,12 @@
}
}
],
- "description": "Defines who owns a property - user-scoped, org-scoped, system, or both user and org."
+ "description": "Defines who owns a property - user-scoped, team-scoped, or system."
},
"PropertyScope": {
"type": "string",
"description": "Scope filter for property queries",
- "enum": ["user", "org", "system", "all"]
+ "enum": ["user", "team", "system", "all"]
},
"PropertyValue": {
"oneOf": [
diff --git a/js/app/packages/service-clients/service-search/generated/models/index.ts b/js/app/packages/service-clients/service-search/generated/models/index.ts
index 1759ce85f6..e01a6439ff 100644
--- a/js/app/packages/service-clients/service-search/generated/models/index.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/index.ts
@@ -171,8 +171,6 @@ export * from './propertyOwnerOneOf';
export * from './propertyOwnerOneOfFive';
export * from './propertyOwnerOneOfFiveScope';
export * from './propertyOwnerOneOfScope';
-export * from './propertyOwnerOneOfSeven';
-export * from './propertyOwnerOneOfSevenScope';
export * from './propertyOwnerOneOfThree';
export * from './propertyOwnerOneOfThreeScope';
export * from './propertyValue';
diff --git a/js/app/packages/service-clients/service-search/generated/models/propertyOwner.ts b/js/app/packages/service-clients/service-search/generated/models/propertyOwner.ts
index afe78ba8c9..fc09603317 100644
--- a/js/app/packages/service-clients/service-search/generated/models/propertyOwner.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/propertyOwner.ts
@@ -6,14 +6,12 @@
*/
import type { PropertyOwnerOneOf } from './propertyOwnerOneOf';
import type { PropertyOwnerOneOfFive } from './propertyOwnerOneOfFive';
-import type { PropertyOwnerOneOfSeven } from './propertyOwnerOneOfSeven';
import type { PropertyOwnerOneOfThree } from './propertyOwnerOneOfThree';
/**
- * Defines who owns a property - user-scoped, org-scoped, system, or both user and org.
+ * Defines who owns a property - user-scoped, team-scoped, or system.
*/
export type PropertyOwner =
| PropertyOwnerOneOf
| PropertyOwnerOneOfThree
- | PropertyOwnerOneOfFive
- | PropertyOwnerOneOfSeven;
+ | PropertyOwnerOneOfFive;
diff --git a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOf.ts b/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOf.ts
index da94f4e250..a3d8b18f5f 100644
--- a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOf.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOf.ts
@@ -7,7 +7,7 @@
import type { PropertyOwnerOneOfScope } from './propertyOwnerOneOfScope';
/**
- * User-scoped property only
+ * User-scoped property.
*/
export type PropertyOwnerOneOf = {
scope: PropertyOwnerOneOfScope;
diff --git a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfFive.ts b/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfFive.ts
index 3b398fa65e..3b9a03c851 100644
--- a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfFive.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfFive.ts
@@ -7,10 +7,8 @@
import type { PropertyOwnerOneOfFiveScope } from './propertyOwnerOneOfFiveScope';
/**
- * Both user and organization-scoped
+ * System-owned property (no user or team owner).
*/
export type PropertyOwnerOneOfFive = {
- organization_id: number;
scope: PropertyOwnerOneOfFiveScope;
- user_id: string;
};
diff --git a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfFiveScope.ts b/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfFiveScope.ts
index 2eb6704f08..4dca48585a 100644
--- a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfFiveScope.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfFiveScope.ts
@@ -10,5 +10,5 @@ export type PropertyOwnerOneOfFiveScope =
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PropertyOwnerOneOfFiveScope = {
- user_and_organization: 'user_and_organization',
+ system: 'system',
} as const;
diff --git a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfSeven.ts b/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfSeven.ts
deleted file mode 100644
index b52df928c5..0000000000
--- a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfSeven.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Generated by orval v7.21.0 🍺
- * Do not edit manually.
- * search_service
- * OpenAPI spec version: 0.1.0
- */
-import type { PropertyOwnerOneOfSevenScope } from './propertyOwnerOneOfSevenScope';
-
-/**
- * System-owned property (no user or org owner)
- */
-export type PropertyOwnerOneOfSeven = {
- scope: PropertyOwnerOneOfSevenScope;
-};
diff --git a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfSevenScope.ts b/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfSevenScope.ts
deleted file mode 100644
index 4070809b1d..0000000000
--- a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfSevenScope.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Generated by orval v7.21.0 🍺
- * Do not edit manually.
- * search_service
- * OpenAPI spec version: 0.1.0
- */
-
-export type PropertyOwnerOneOfSevenScope =
- (typeof PropertyOwnerOneOfSevenScope)[keyof typeof PropertyOwnerOneOfSevenScope];
-
-// eslint-disable-next-line @typescript-eslint/no-redeclare
-export const PropertyOwnerOneOfSevenScope = {
- system: 'system',
-} as const;
diff --git a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfThree.ts b/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfThree.ts
index ba59bf9cd6..d2dfe77f79 100644
--- a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfThree.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfThree.ts
@@ -7,9 +7,9 @@
import type { PropertyOwnerOneOfThreeScope } from './propertyOwnerOneOfThreeScope';
/**
- * Organization-scoped property only
+ * Team-scoped property.
*/
export type PropertyOwnerOneOfThree = {
- organization_id: number;
scope: PropertyOwnerOneOfThreeScope;
+ team_id: string;
};
diff --git a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfThreeScope.ts b/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfThreeScope.ts
index 31e6d81595..6063e75d77 100644
--- a/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfThreeScope.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/propertyOwnerOneOfThreeScope.ts
@@ -10,5 +10,5 @@ export type PropertyOwnerOneOfThreeScope =
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PropertyOwnerOneOfThreeScope = {
- organization: 'organization',
+ team: 'team',
} as const;
diff --git a/js/app/packages/service-clients/service-search/openapi.json b/js/app/packages/service-clients/service-search/openapi.json
index 3e5f84aeb0..5cfb085503 100644
--- a/js/app/packages/service-clients/service-search/openapi.json
+++ b/js/app/packages/service-clients/service-search/openapi.json
@@ -2463,7 +2463,7 @@
"oneOf": [
{
"type": "object",
- "description": "User-scoped property only",
+ "description": "User-scoped property.",
"required": ["user_id", "scope"],
"properties": {
"scope": {
@@ -2477,40 +2477,22 @@
},
{
"type": "object",
- "description": "Organization-scoped property only",
- "required": ["organization_id", "scope"],
+ "description": "Team-scoped property.",
+ "required": ["team_id", "scope"],
"properties": {
- "organization_id": {
- "type": "integer",
- "format": "int32"
- },
"scope": {
"type": "string",
- "enum": ["organization"]
- }
- }
- },
- {
- "type": "object",
- "description": "Both user and organization-scoped",
- "required": ["user_id", "organization_id", "scope"],
- "properties": {
- "organization_id": {
- "type": "integer",
- "format": "int32"
+ "enum": ["team"]
},
- "scope": {
+ "team_id": {
"type": "string",
- "enum": ["user_and_organization"]
- },
- "user_id": {
- "type": "string"
+ "format": "uuid"
}
}
},
{
"type": "object",
- "description": "System-owned property (no user or org owner)",
+ "description": "System-owned property (no user or team owner).",
"required": ["scope"],
"properties": {
"scope": {
@@ -2520,7 +2502,7 @@
}
}
],
- "description": "Defines who owns a property - user-scoped, org-scoped, system, or both user and org."
+ "description": "Defines who owns a property - user-scoped, team-scoped, or system."
},
"PropertyValue": {
"oneOf": [
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
index 04bb5d0bba..051d7e70a2 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
@@ -768,8 +768,6 @@ export * from './propertyOwnerOneOf';
export * from './propertyOwnerOneOfFive';
export * from './propertyOwnerOneOfFiveScope';
export * from './propertyOwnerOneOfScope';
-export * from './propertyOwnerOneOfSeven';
-export * from './propertyOwnerOneOfSevenScope';
export * from './propertyOwnerOneOfThree';
export * from './propertyOwnerOneOfThreeScope';
export * from './propertyValue';
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwner.ts b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwner.ts
index 763d015ac8..a5a7c5a0d2 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwner.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwner.ts
@@ -6,14 +6,12 @@
*/
import type { PropertyOwnerOneOf } from './propertyOwnerOneOf';
import type { PropertyOwnerOneOfFive } from './propertyOwnerOneOfFive';
-import type { PropertyOwnerOneOfSeven } from './propertyOwnerOneOfSeven';
import type { PropertyOwnerOneOfThree } from './propertyOwnerOneOfThree';
/**
- * Defines who owns a property - user-scoped, org-scoped, system, or both user and org.
+ * Defines who owns a property - user-scoped, team-scoped, or system.
*/
export type PropertyOwner =
| PropertyOwnerOneOf
| PropertyOwnerOneOfThree
- | PropertyOwnerOneOfFive
- | PropertyOwnerOneOfSeven;
+ | PropertyOwnerOneOfFive;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOf.ts b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOf.ts
index 7d8360ef6b..a9c1147da3 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOf.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOf.ts
@@ -7,7 +7,7 @@
import type { PropertyOwnerOneOfScope } from './propertyOwnerOneOfScope';
/**
- * User-scoped property only
+ * User-scoped property.
*/
export type PropertyOwnerOneOf = {
scope: PropertyOwnerOneOfScope;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfFive.ts b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfFive.ts
index 2a03a22cf4..798ec86b20 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfFive.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfFive.ts
@@ -7,10 +7,8 @@
import type { PropertyOwnerOneOfFiveScope } from './propertyOwnerOneOfFiveScope';
/**
- * Both user and organization-scoped
+ * System-owned property (no user or team owner).
*/
export type PropertyOwnerOneOfFive = {
- organization_id: number;
scope: PropertyOwnerOneOfFiveScope;
- user_id: string;
};
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfFiveScope.ts b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfFiveScope.ts
index 57b1b2fc31..268a62e267 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfFiveScope.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfFiveScope.ts
@@ -10,5 +10,5 @@ export type PropertyOwnerOneOfFiveScope =
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PropertyOwnerOneOfFiveScope = {
- user_and_organization: 'user_and_organization',
+ system: 'system',
} as const;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfSeven.ts b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfSeven.ts
deleted file mode 100644
index 1e4b459232..0000000000
--- a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfSeven.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Generated by orval v7.21.0 🍺
- * Do not edit manually.
- * document_storage_service
- * OpenAPI spec version: 0.1.0
- */
-import type { PropertyOwnerOneOfSevenScope } from './propertyOwnerOneOfSevenScope';
-
-/**
- * System-owned property (no user or org owner)
- */
-export type PropertyOwnerOneOfSeven = {
- scope: PropertyOwnerOneOfSevenScope;
-};
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfSevenScope.ts b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfSevenScope.ts
deleted file mode 100644
index 82d2a0912e..0000000000
--- a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfSevenScope.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Generated by orval v7.21.0 🍺
- * Do not edit manually.
- * document_storage_service
- * OpenAPI spec version: 0.1.0
- */
-
-export type PropertyOwnerOneOfSevenScope =
- (typeof PropertyOwnerOneOfSevenScope)[keyof typeof PropertyOwnerOneOfSevenScope];
-
-// eslint-disable-next-line @typescript-eslint/no-redeclare
-export const PropertyOwnerOneOfSevenScope = {
- system: 'system',
-} as const;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfThree.ts b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfThree.ts
index 2782e71556..f9d8c9fcc0 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfThree.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfThree.ts
@@ -7,9 +7,9 @@
import type { PropertyOwnerOneOfThreeScope } from './propertyOwnerOneOfThreeScope';
/**
- * Organization-scoped property only
+ * Team-scoped property.
*/
export type PropertyOwnerOneOfThree = {
- organization_id: number;
scope: PropertyOwnerOneOfThreeScope;
+ team_id: string;
};
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfThreeScope.ts b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfThreeScope.ts
index c43e15e75d..12c7636b98 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfThreeScope.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/propertyOwnerOneOfThreeScope.ts
@@ -10,5 +10,5 @@ export type PropertyOwnerOneOfThreeScope =
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const PropertyOwnerOneOfThreeScope = {
- organization: 'organization',
+ team: 'team',
} 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.ts
index ee471fa531..d8842c4af6 100644
--- a/js/app/packages/service-clients/service-storage/generated/zod.ts
+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts
@@ -6517,36 +6517,23 @@ export const getItemsSoupResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -6811,36 +6798,23 @@ export const getItemsSoupResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -7068,36 +7042,23 @@ export const getItemsSoupResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -7476,36 +7437,23 @@ export const getItemsSoupResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -8894,36 +8842,23 @@ export const postItemsSoupResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
- })
- .describe(
- 'Organization-scoped property only'
- ),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -9188,36 +9123,23 @@ export const postItemsSoupResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -9445,36 +9367,23 @@ export const postItemsSoupResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -9853,36 +9762,23 @@ export const postItemsSoupResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -10813,36 +10709,23 @@ export const postItemsSoupAstResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
- })
- .describe(
- 'Organization-scoped property only'
- ),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -11107,36 +10990,23 @@ export const postItemsSoupAstResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
- })
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -11364,36 +11234,23 @@ export const postItemsSoupAstResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -11772,36 +11629,23 @@ export const postItemsSoupAstResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe('User-scoped property only'),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
- })
- .describe(
- 'Organization-scoped property only'
- ),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -12990,38 +12834,23 @@ export const postItemsSoupAstGroupedResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe(
- 'User-scoped property only'
- ),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -13290,38 +13119,23 @@ export const postItemsSoupAstGroupedResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe(
- 'User-scoped property only'
- ),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -13549,38 +13363,23 @@ export const postItemsSoupAstGroupedResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe(
- 'User-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
- })
- .describe(
- 'Organization-scoped property only'
- ),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -13980,38 +13779,23 @@ export const postItemsSoupAstGroupedResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe(
- 'User-scoped property only'
- ),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -14921,38 +14705,23 @@ export const postItemsSoupAstGroupedResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe(
- 'User-scoped property only'
- ),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
- })
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -15221,38 +14990,23 @@ export const postItemsSoupAstGroupedResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe(
- 'User-scoped property only'
- ),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -15480,38 +15234,23 @@ export const postItemsSoupAstGroupedResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe(
- 'User-scoped property only'
- ),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
@@ -15911,38 +15650,23 @@ export const postItemsSoupAstGroupedResponse = zod
scope: zod.enum(['user']),
user_id: zod.string(),
})
- .describe(
- 'User-scoped property only'
- ),
+ .describe('User-scoped property.'),
zod
.object({
- organization_id: zod.number(),
- scope: zod.enum(['organization']),
+ scope: zod.enum(['team']),
+ team_id: zod.uuid(),
})
- .describe(
- 'Organization-scoped property only'
- ),
- zod
- .object({
- organization_id: zod.number(),
- scope: zod.enum([
- 'user_and_organization',
- ]),
- user_id: zod.string(),
- })
- .describe(
- 'Both user and organization-scoped'
- ),
+ .describe('Team-scoped property.'),
zod
.object({
scope: zod.enum(['system']),
})
.describe(
- 'System-owned property (no user or org owner)'
+ 'System-owned property (no user or team owner).'
),
])
.describe(
- 'Defines who owns a property - user-scoped, org-scoped, system, or both user and org.'
+ 'Defines who owns a property - user-scoped, team-scoped, or system.'
),
specific_entity_type: zod
.union([
diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.json
index 494cb6a94c..89c92c7566 100644
--- a/js/app/packages/service-clients/service-storage/openapi.json
+++ b/js/app/packages/service-clients/service-storage/openapi.json
@@ -16986,7 +16986,7 @@
"oneOf": [
{
"type": "object",
- "description": "User-scoped property only",
+ "description": "User-scoped property.",
"required": ["user_id", "scope"],
"properties": {
"scope": {
@@ -17000,40 +17000,22 @@
},
{
"type": "object",
- "description": "Organization-scoped property only",
- "required": ["organization_id", "scope"],
+ "description": "Team-scoped property.",
+ "required": ["team_id", "scope"],
"properties": {
- "organization_id": {
- "type": "integer",
- "format": "int32"
- },
"scope": {
"type": "string",
- "enum": ["organization"]
- }
- }
- },
- {
- "type": "object",
- "description": "Both user and organization-scoped",
- "required": ["user_id", "organization_id", "scope"],
- "properties": {
- "organization_id": {
- "type": "integer",
- "format": "int32"
+ "enum": ["team"]
},
- "scope": {
+ "team_id": {
"type": "string",
- "enum": ["user_and_organization"]
- },
- "user_id": {
- "type": "string"
+ "format": "uuid"
}
}
},
{
"type": "object",
- "description": "System-owned property (no user or org owner)",
+ "description": "System-owned property (no user or team owner).",
"required": ["scope"],
"properties": {
"scope": {
@@ -17043,7 +17025,7 @@
}
}
],
- "description": "Defines who owns a property - user-scoped, org-scoped, system, or both user and org."
+ "description": "Defines who owns a property - user-scoped, team-scoped, or system."
},
"PropertyValue": {
"oneOf": [
diff --git a/rust/cloud-storage/.sqlx/query-1b324f7419bf6620c5eae611b237ee202fb2b3b011422dc27f351a2c3d10813c.json b/rust/cloud-storage/.sqlx/query-301f5b3142a30e271df62607b5743ff019bff1a5b0142fc260ff772837db3f39.json
similarity index 84%
rename from rust/cloud-storage/.sqlx/query-1b324f7419bf6620c5eae611b237ee202fb2b3b011422dc27f351a2c3d10813c.json
rename to rust/cloud-storage/.sqlx/query-301f5b3142a30e271df62607b5743ff019bff1a5b0142fc260ff772837db3f39.json
index 8257f56f38..9add09cfba 100644
--- a/rust/cloud-storage/.sqlx/query-1b324f7419bf6620c5eae611b237ee202fb2b3b011422dc27f351a2c3d10813c.json
+++ b/rust/cloud-storage/.sqlx/query-301f5b3142a30e271df62607b5743ff019bff1a5b0142fc260ff772837db3f39.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\nSELECT\n ep.id as entity_property_id,\n ep.entity_id,\n ep.entity_type as \"entity_type: EntityType\",\n ep.property_definition_id,\n ep.values as \"values: sqlx::types::JsonValue\",\n ep.created_at as entity_property_created_at,\n ep.updated_at as entity_property_updated_at,\n pd.organization_id as definition_organization_id,\n pd.user_id as definition_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 as definition_created_at,\n pd.updated_at as definition_updated_at,\n pd.is_system as definition_is_system\nFROM entity_properties ep\nINNER JOIN property_definitions pd ON ep.property_definition_id = pd.id\nWHERE (ep.entity_id, ep.entity_type) IN (\n SELECT * FROM UNNEST($1::TEXT[], $2::property_entity_type[])\n)\n",
+ "query": "\nSELECT\n ep.id as entity_property_id,\n ep.entity_id,\n ep.entity_type as \"entity_type: EntityType\",\n ep.property_definition_id,\n ep.values as \"values: sqlx::types::JsonValue\",\n ep.created_at as entity_property_created_at,\n ep.updated_at as entity_property_updated_at,\n pd.team_id as definition_team_id,\n pd.user_id as definition_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 as definition_created_at,\n pd.updated_at as definition_updated_at,\n pd.is_system as definition_is_system\nFROM entity_properties ep\nINNER JOIN property_definitions pd ON ep.property_definition_id = pd.id\nWHERE (ep.entity_id, ep.entity_type) IN (\n SELECT * FROM UNNEST($1::TEXT[], $2::property_entity_type[])\n)\n",
"describe": {
"columns": [
{
@@ -56,8 +56,8 @@
},
{
"ordinal": 7,
- "name": "definition_organization_id",
- "type_info": "Int4"
+ "name": "definition_team_id",
+ "type_info": "Uuid"
},
{
"ordinal": 8,
@@ -180,5 +180,5 @@
false
]
},
- "hash": "1b324f7419bf6620c5eae611b237ee202fb2b3b011422dc27f351a2c3d10813c"
+ "hash": "301f5b3142a30e271df62607b5743ff019bff1a5b0142fc260ff772837db3f39"
}
diff --git a/rust/cloud-storage/.sqlx/query-b9570b07121de0df914dd0579cc92a5e92973cf114526f80dbe7ab714493090b.json b/rust/cloud-storage/.sqlx/query-3bc6b02fb5df57994ccaa3c7aad24bb2528c2f38c6cbc30cd56e6eb36b270cea.json
similarity index 67%
rename from rust/cloud-storage/.sqlx/query-b9570b07121de0df914dd0579cc92a5e92973cf114526f80dbe7ab714493090b.json
rename to rust/cloud-storage/.sqlx/query-3bc6b02fb5df57994ccaa3c7aad24bb2528c2f38c6cbc30cd56e6eb36b270cea.json
index 4063a3122f..57021867a5 100644
--- a/rust/cloud-storage/.sqlx/query-b9570b07121de0df914dd0579cc92a5e92973cf114526f80dbe7ab714493090b.json
+++ b/rust/cloud-storage/.sqlx/query-3bc6b02fb5df57994ccaa3c7aad24bb2528c2f38c6cbc30cd56e6eb36b270cea.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT \n pd.id,\n pd.organization_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::int IS NOT NULL AND pd.organization_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.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": [
{
@@ -10,8 +10,8 @@
},
{
"ordinal": 1,
- "name": "organization_id",
- "type_info": "Int4"
+ "name": "team_id",
+ "type_info": "Uuid"
},
{
"ordinal": 2,
@@ -118,7 +118,7 @@
],
"parameters": {
"Left": [
- "Int4",
+ "Uuid",
"Text",
"Bool"
]
@@ -142,5 +142,5 @@
false
]
},
- "hash": "b9570b07121de0df914dd0579cc92a5e92973cf114526f80dbe7ab714493090b"
+ "hash": "3bc6b02fb5df57994ccaa3c7aad24bb2528c2f38c6cbc30cd56e6eb36b270cea"
}
diff --git a/rust/cloud-storage/.sqlx/query-5fabf029c6dd06505963dab2b60eccb8ea77088f535970dbcf5f80d57a9a4c5b.json b/rust/cloud-storage/.sqlx/query-462655d9cce541e4b25cb2d85e9d2e8ce3c84e28b4f459e4ea4ef62881278ae8.json
similarity index 73%
rename from rust/cloud-storage/.sqlx/query-5fabf029c6dd06505963dab2b60eccb8ea77088f535970dbcf5f80d57a9a4c5b.json
rename to rust/cloud-storage/.sqlx/query-462655d9cce541e4b25cb2d85e9d2e8ce3c84e28b4f459e4ea4ef62881278ae8.json
index c853ae04b7..7000f58e6e 100644
--- a/rust/cloud-storage/.sqlx/query-5fabf029c6dd06505963dab2b60eccb8ea77088f535970dbcf5f80d57a9a4c5b.json
+++ b/rust/cloud-storage/.sqlx/query-462655d9cce541e4b25cb2d85e9d2e8ce3c84e28b4f459e4ea4ef62881278ae8.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT \n id,\n organization_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 id = $1\n AND is_system = FALSE\n AND (\n user_id = $2\n OR ($3::int IS NOT NULL AND organization_id = $3)\n )\n ",
+ "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 id = $1\n AND is_system = FALSE\n AND (\n user_id = $2\n OR ($3::uuid IS NOT NULL AND team_id = $3)\n )\n ",
"describe": {
"columns": [
{
@@ -10,8 +10,8 @@
},
{
"ordinal": 1,
- "name": "organization_id",
- "type_info": "Int4"
+ "name": "team_id",
+ "type_info": "Uuid"
},
{
"ordinal": 2,
@@ -90,7 +90,7 @@
"Left": [
"Uuid",
"Text",
- "Int4"
+ "Uuid"
]
},
"nullable": [
@@ -106,5 +106,5 @@
false
]
},
- "hash": "5fabf029c6dd06505963dab2b60eccb8ea77088f535970dbcf5f80d57a9a4c5b"
+ "hash": "462655d9cce541e4b25cb2d85e9d2e8ce3c84e28b4f459e4ea4ef62881278ae8"
}
diff --git a/rust/cloud-storage/.sqlx/query-e0b90388e3a9f7dbd1e6586cb0633b0d2d39d64dcc88a0f0c5cd310303e7dc92.json b/rust/cloud-storage/.sqlx/query-6fd87794b687b1687b8c4f0bc0390ffcc91811ae9909ce333273e6bf77013b03.json
similarity index 79%
rename from rust/cloud-storage/.sqlx/query-e0b90388e3a9f7dbd1e6586cb0633b0d2d39d64dcc88a0f0c5cd310303e7dc92.json
rename to rust/cloud-storage/.sqlx/query-6fd87794b687b1687b8c4f0bc0390ffcc91811ae9909ce333273e6bf77013b03.json
index a6d8c54236..60dd7e49b0 100644
--- a/rust/cloud-storage/.sqlx/query-e0b90388e3a9f7dbd1e6586cb0633b0d2d39d64dcc88a0f0c5cd310303e7dc92.json
+++ b/rust/cloud-storage/.sqlx/query-6fd87794b687b1687b8c4f0bc0390ffcc91811ae9909ce333273e6bf77013b03.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n INSERT INTO property_definitions (\n id,\n organization_id, \n user_id, \n display_name, \n data_type, \n is_multi_select,\n specific_entity_type\n )\n VALUES ($1, $2, $3, $4, $5, $6, $7)\n RETURNING \n id,\n organization_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 ",
+ "query": "\n INSERT INTO property_definitions (\n id,\n team_id,\n user_id,\n display_name,\n data_type,\n is_multi_select,\n specific_entity_type\n )\n VALUES ($1, $2, $3, $4, $5, $6, $7)\n RETURNING\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 ",
"describe": {
"columns": [
{
@@ -10,8 +10,8 @@
},
{
"ordinal": 1,
- "name": "organization_id",
- "type_info": "Int4"
+ "name": "team_id",
+ "type_info": "Uuid"
},
{
"ordinal": 2,
@@ -84,7 +84,7 @@
"parameters": {
"Left": [
"Uuid",
- "Int4",
+ "Uuid",
"Text",
"Text",
{
@@ -136,5 +136,5 @@
false
]
},
- "hash": "e0b90388e3a9f7dbd1e6586cb0633b0d2d39d64dcc88a0f0c5cd310303e7dc92"
+ "hash": "6fd87794b687b1687b8c4f0bc0390ffcc91811ae9909ce333273e6bf77013b03"
}
diff --git a/rust/cloud-storage/.sqlx/query-732141210551d42218ce027266c6dfa3dd1f0ddb2c37493ed1235fe488073d89.json b/rust/cloud-storage/.sqlx/query-a63c0f9e0b3c58438d46cff265e3f412890402e3627b85d5dfb74a08d72787e1.json
similarity index 77%
rename from rust/cloud-storage/.sqlx/query-732141210551d42218ce027266c6dfa3dd1f0ddb2c37493ed1235fe488073d89.json
rename to rust/cloud-storage/.sqlx/query-a63c0f9e0b3c58438d46cff265e3f412890402e3627b85d5dfb74a08d72787e1.json
index ea49b9c1cd..f53e848896 100644
--- a/rust/cloud-storage/.sqlx/query-732141210551d42218ce027266c6dfa3dd1f0ddb2c37493ed1235fe488073d89.json
+++ b/rust/cloud-storage/.sqlx/query-a63c0f9e0b3c58438d46cff265e3f412890402e3627b85d5dfb74a08d72787e1.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT \n id,\n organization_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 id = $1\n ",
+ "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 id = $1\n ",
"describe": {
"columns": [
{
@@ -10,8 +10,8 @@
},
{
"ordinal": 1,
- "name": "organization_id",
- "type_info": "Int4"
+ "name": "team_id",
+ "type_info": "Uuid"
},
{
"ordinal": 2,
@@ -104,5 +104,5 @@
false
]
},
- "hash": "732141210551d42218ce027266c6dfa3dd1f0ddb2c37493ed1235fe488073d89"
+ "hash": "a63c0f9e0b3c58438d46cff265e3f412890402e3627b85d5dfb74a08d72787e1"
}
diff --git a/rust/cloud-storage/.sqlx/query-827b998f442f5f6cb6ff85dc35f01c5782128a4cb9a020e22ab83a24a6c2b4f5.json b/rust/cloud-storage/.sqlx/query-b6a900ce4ef05b399b15c5df9df622228577a112642245990b64442fb691305f.json
similarity index 71%
rename from rust/cloud-storage/.sqlx/query-827b998f442f5f6cb6ff85dc35f01c5782128a4cb9a020e22ab83a24a6c2b4f5.json
rename to rust/cloud-storage/.sqlx/query-b6a900ce4ef05b399b15c5df9df622228577a112642245990b64442fb691305f.json
index d172804854..0443fd2ce5 100644
--- a/rust/cloud-storage/.sqlx/query-827b998f442f5f6cb6ff85dc35f01c5782128a4cb9a020e22ab83a24a6c2b4f5.json
+++ b/rust/cloud-storage/.sqlx/query-b6a900ce4ef05b399b15c5df9df622228577a112642245990b64442fb691305f.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT \n id,\n organization_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 \n ($3 AND is_system)\n OR (\n ($1::int IS NOT NULL AND organization_id = $1) \n OR ($2::text IS NOT NULL AND user_id = $2)\n )\n ORDER BY LOWER(display_name) ASC\n ",
+ "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\n ($3 AND is_system)\n OR (\n ($1::uuid IS NOT NULL AND team_id = $1)\n OR ($2::text IS NOT NULL AND user_id = $2)\n )\n ORDER BY LOWER(display_name) ASC\n ",
"describe": {
"columns": [
{
@@ -10,8 +10,8 @@
},
{
"ordinal": 1,
- "name": "organization_id",
- "type_info": "Int4"
+ "name": "team_id",
+ "type_info": "Uuid"
},
{
"ordinal": 2,
@@ -88,7 +88,7 @@
],
"parameters": {
"Left": [
- "Int4",
+ "Uuid",
"Text",
"Bool"
]
@@ -106,5 +106,5 @@
false
]
},
- "hash": "827b998f442f5f6cb6ff85dc35f01c5782128a4cb9a020e22ab83a24a6c2b4f5"
+ "hash": "b6a900ce4ef05b399b15c5df9df622228577a112642245990b64442fb691305f"
}
diff --git a/rust/cloud-storage/.sqlx/query-35aa1ada3371fd09902d19b1218c2034a348d30889a11f28b98a9e4a0daf4525.json b/rust/cloud-storage/.sqlx/query-d09a22b5d0a049677c6fc96d0aef74260d592ae30752c12a50512ebf95592e5f.json
similarity index 84%
rename from rust/cloud-storage/.sqlx/query-35aa1ada3371fd09902d19b1218c2034a348d30889a11f28b98a9e4a0daf4525.json
rename to rust/cloud-storage/.sqlx/query-d09a22b5d0a049677c6fc96d0aef74260d592ae30752c12a50512ebf95592e5f.json
index 0bc29e54eb..071cc5d68a 100644
--- a/rust/cloud-storage/.sqlx/query-35aa1ada3371fd09902d19b1218c2034a348d30889a11f28b98a9e4a0daf4525.json
+++ b/rust/cloud-storage/.sqlx/query-d09a22b5d0a049677c6fc96d0aef74260d592ae30752c12a50512ebf95592e5f.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\nSELECT\n ep.id as entity_property_id,\n ep.entity_id,\n ep.entity_type as \"entity_type: EntityType\",\n ep.property_definition_id,\n ep.values as \"values: sqlx::types::JsonValue\",\n ep.created_at as entity_property_created_at,\n ep.updated_at as entity_property_updated_at,\n pd.organization_id as definition_organization_id,\n pd.user_id as definition_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 as definition_created_at,\n pd.updated_at as definition_updated_at,\n pd.is_system as definition_is_system\nFROM entity_properties ep\nINNER JOIN property_definitions pd ON ep.property_definition_id = pd.id\nWHERE ep.entity_id = $1 AND ep.entity_type = $2\n ",
+ "query": "\nSELECT\n ep.id as entity_property_id,\n ep.entity_id,\n ep.entity_type as \"entity_type: EntityType\",\n ep.property_definition_id,\n ep.values as \"values: sqlx::types::JsonValue\",\n ep.created_at as entity_property_created_at,\n ep.updated_at as entity_property_updated_at,\n pd.team_id as definition_team_id,\n pd.user_id as definition_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 as definition_created_at,\n pd.updated_at as definition_updated_at,\n pd.is_system as definition_is_system\nFROM entity_properties ep\nINNER JOIN property_definitions pd ON ep.property_definition_id = pd.id\nWHERE ep.entity_id = $1 AND ep.entity_type = $2\n ",
"describe": {
"columns": [
{
@@ -56,8 +56,8 @@
},
{
"ordinal": 7,
- "name": "definition_organization_id",
- "type_info": "Int4"
+ "name": "definition_team_id",
+ "type_info": "Uuid"
},
{
"ordinal": 8,
@@ -173,5 +173,5 @@
false
]
},
- "hash": "35aa1ada3371fd09902d19b1218c2034a348d30889a11f28b98a9e4a0daf4525"
+ "hash": "d09a22b5d0a049677c6fc96d0aef74260d592ae30752c12a50512ebf95592e5f"
}
diff --git a/rust/cloud-storage/.sqlx/query-edce1ca1979c9bd7c42f7e89d80a8d25037d25951b1f406dddb8d62cc13f74f0.json b/rust/cloud-storage/.sqlx/query-f08b1a5fbea1fba7b91975fdcaa5c5adde2d9bc89eece2cbf17133b7e5f6d6d9.json
similarity index 83%
rename from rust/cloud-storage/.sqlx/query-edce1ca1979c9bd7c42f7e89d80a8d25037d25951b1f406dddb8d62cc13f74f0.json
rename to rust/cloud-storage/.sqlx/query-f08b1a5fbea1fba7b91975fdcaa5c5adde2d9bc89eece2cbf17133b7e5f6d6d9.json
index 13653d45bf..22e39fb653 100644
--- a/rust/cloud-storage/.sqlx/query-edce1ca1979c9bd7c42f7e89d80a8d25037d25951b1f406dddb8d62cc13f74f0.json
+++ b/rust/cloud-storage/.sqlx/query-f08b1a5fbea1fba7b91975fdcaa5c5adde2d9bc89eece2cbf17133b7e5f6d6d9.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\nSELECT\n ep.id as entity_property_id,\n ep.entity_id,\n ep.entity_type as \"entity_type: EntityType\",\n ep.property_definition_id,\n ep.values as \"values: sqlx::types::JsonValue\",\n ep.created_at as entity_property_created_at,\n ep.updated_at as entity_property_updated_at,\n pd.organization_id as definition_organization_id,\n pd.user_id as definition_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 as definition_created_at,\n pd.updated_at as definition_updated_at,\n pd.is_system as definition_is_system\nFROM entity_properties ep\nINNER JOIN property_definitions pd ON ep.property_definition_id = pd.id\nWHERE (ep.entity_id, ep.entity_type) IN (\n SELECT * FROM UNNEST($1::TEXT[], $2::property_entity_type[])\n)\nAND pd.id = ANY($3::UUID[])\n ",
+ "query": "\nSELECT\n ep.id as entity_property_id,\n ep.entity_id,\n ep.entity_type as \"entity_type: EntityType\",\n ep.property_definition_id,\n ep.values as \"values: sqlx::types::JsonValue\",\n ep.created_at as entity_property_created_at,\n ep.updated_at as entity_property_updated_at,\n pd.team_id as definition_team_id,\n pd.user_id as definition_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 as definition_created_at,\n pd.updated_at as definition_updated_at,\n pd.is_system as definition_is_system\nFROM entity_properties ep\nINNER JOIN property_definitions pd ON ep.property_definition_id = pd.id\nWHERE (ep.entity_id, ep.entity_type) IN (\n SELECT * FROM UNNEST($1::TEXT[], $2::property_entity_type[])\n)\nAND pd.id = ANY($3::UUID[])\n ",
"describe": {
"columns": [
{
@@ -56,8 +56,8 @@
},
{
"ordinal": 7,
- "name": "definition_organization_id",
- "type_info": "Int4"
+ "name": "definition_team_id",
+ "type_info": "Uuid"
},
{
"ordinal": 8,
@@ -181,5 +181,5 @@
false
]
},
- "hash": "edce1ca1979c9bd7c42f7e89d80a8d25037d25951b1f406dddb8d62cc13f74f0"
+ "hash": "f08b1a5fbea1fba7b91975fdcaa5c5adde2d9bc89eece2cbf17133b7e5f6d6d9"
}
diff --git a/rust/cloud-storage/macro_db_client/migrations/20260622223029_kill_org_properties_add_team.sql b/rust/cloud-storage/macro_db_client/migrations/20260622223029_kill_org_properties_add_team.sql
new file mode 100644
index 0000000000..619d4b2eab
--- /dev/null
+++ b/rust/cloud-storage/macro_db_client/migrations/20260622223029_kill_org_properties_add_team.sql
@@ -0,0 +1,48 @@
+-- macro-1987: remove organization-owned properties, introduce team-owned properties.
+--
+-- Organization ownership is removed entirely. Every organization-referencing property
+-- definition is discarded along with its options and entity values (intentional: no
+-- organization property data is preserved). Property definitions are now owned by a
+-- user, a team, or the system.
+
+-- 1. Discard every organization-referencing property definition. property_options and
+-- entity_properties rows cascade via their ON DELETE CASCADE foreign keys.
+DELETE FROM property_definitions WHERE organization_id IS NOT NULL;
+
+-- 2. Tear down organization ownership. Dropping the column also drops its FK to "Organization".
+ALTER TABLE property_definitions DROP CONSTRAINT owned_by_org_or_user_or_system;
+ALTER TABLE property_definitions DROP CONSTRAINT unique_property_definitions_org_display_name;
+DROP INDEX idx_property_definitions_organization_id;
+ALTER TABLE property_definitions DROP COLUMN organization_id;
+
+-- 3. Introduce team ownership.
+ALTER TABLE property_definitions
+ ADD COLUMN team_id UUID REFERENCES "team"(id) ON DELETE CASCADE;
+
+-- Exactly one owner: a definition belongs to the system, a user, or a team.
+ALTER TABLE property_definitions ADD CONSTRAINT owned_by_team_or_user_or_system CHECK (
+ is_system::int + (team_id IS NOT NULL)::int + (user_id IS NOT NULL)::int = 1
+);
+
+ALTER TABLE property_definitions
+ ADD CONSTRAINT unique_property_definitions_team_display_name UNIQUE (team_id, display_name);
+
+CREATE INDEX idx_property_definitions_team_id ON property_definitions(team_id)
+ WHERE team_id IS NOT NULL;
+
+-- 4. Repoint the orphan-cleanup trigger from organization_id to team_id. A definition is
+-- orphaned only when it has no team owner, no user owner, and is not a system property
+-- (e.g. after the owning user is deleted, which sets user_id to NULL).
+CREATE OR REPLACE FUNCTION delete_orphaned_property_definition()
+ RETURNS TRIGGER
+ LANGUAGE PLPGSQL
+ AS
+$$
+ BEGIN
+ IF NEW.team_id IS NULL AND NEW.user_id IS NULL AND NEW.is_system = FALSE THEN
+ DELETE FROM property_definitions WHERE id = NEW.id;
+ RETURN NULL;
+ END IF;
+ RETURN NEW;
+ END;
+$$;
diff --git a/rust/cloud-storage/models_properties/src/api/mod.rs b/rust/cloud-storage/models_properties/src/api/mod.rs
index 703c228bd3..d63ea1baf6 100644
--- a/rust/cloud-storage/models_properties/src/api/mod.rs
+++ b/rust/cloud-storage/models_properties/src/api/mod.rs
@@ -15,8 +15,8 @@ pub use error::{
pub use query_params::{BulkEntityQueryParams, EntityQueryParams};
pub use requests::{
AddNumberOptionRequest, AddPropertyOptionRequest, AddStringOptionRequest,
- CreatePropertyDefinitionRequest, PropertyDataType, SelectNumberOption, SelectStringOption,
- SetPropertyValue,
+ CreatePropertyDefinitionRequest, CreatePropertyScope, PropertyDataType, SelectNumberOption,
+ SelectStringOption, SetPropertyValue,
};
pub use responses::{
BulkEntityPropertiesResponse, EntityPropertiesResponse, EntityPropertyResponse,
diff --git a/rust/cloud-storage/models_properties/src/api/requests.rs b/rust/cloud-storage/models_properties/src/api/requests.rs
index 83bdc92272..52d3bf692f 100644
--- a/rust/cloud-storage/models_properties/src/api/requests.rs
+++ b/rust/cloud-storage/models_properties/src/api/requests.rs
@@ -8,7 +8,7 @@ use uuid::Uuid;
use crate::api::error::{
PropertyDefinitionValidationError, PropertyOptionValidationError, PropertyValueValidationError,
};
-use crate::shared::{DataType, EntityReference, EntityType, PropertyOwner};
+use crate::shared::{DataType, EntityReference, EntityType};
// ===== Property Definition Requests =====
@@ -96,11 +96,22 @@ impl PropertyDataType {
}
}
+/// Ownership scope a client may request when creating a property definition.
+/// The owning user or team is derived server-side from the authenticated caller -
+/// clients never supply owner ids. System properties are not creatable via the API.
+#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema, PartialEq)]
+#[serde(rename_all = "snake_case")]
+pub enum CreatePropertyScope {
+ /// Owned by the requesting user.
+ User,
+ /// Owned by the requesting user's team. Requires team membership.
+ Team,
+}
+
/// Request to create a new property definition.
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct CreatePropertyDefinitionRequest {
- #[serde(flatten)]
- pub owner: PropertyOwner,
+ pub scope: CreatePropertyScope,
pub display_name: String,
pub data_type: PropertyDataType,
}
diff --git a/rust/cloud-storage/models_properties/src/db/property_definition.rs b/rust/cloud-storage/models_properties/src/db/property_definition.rs
index 0801ac373d..2143014894 100644
--- a/rust/cloud-storage/models_properties/src/db/property_definition.rs
+++ b/rust/cloud-storage/models_properties/src/db/property_definition.rs
@@ -10,7 +10,7 @@ use crate::shared::{DataType, EntityType};
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)]
pub struct PropertyDefinition {
pub id: Uuid,
- pub organization_id: Option<i32>,
+ pub team_id: Option<Uuid>,
pub user_id: Option<String>,
pub display_name: String,
pub data_type: DataType,
@@ -27,7 +27,7 @@ impl From<PropertyDefinition> for crate::service::property_definition::PropertyD
fn from(db: PropertyDefinition) -> Self {
use crate::shared::PropertyOwner;
- let owner = PropertyOwner::from_optional_ids(db.organization_id, db.user_id, db.is_system);
+ let owner = PropertyOwner::from_optional_ids(db.team_id, db.user_id, db.is_system);
Self {
id: db.id,
diff --git a/rust/cloud-storage/models_properties/src/shared/property_owner.rs b/rust/cloud-storage/models_properties/src/shared/property_owner.rs
index 7f2092c0ee..acbf3cc52e 100644
--- a/rust/cloud-storage/models_properties/src/shared/property_owner.rs
+++ b/rust/cloud-storage/models_properties/src/shared/property_owner.rs
@@ -2,68 +2,53 @@
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
+use uuid::Uuid;
-/// Defines who owns a property - user-scoped, org-scoped, system, or both user and org.
+/// Defines who owns a property - user-scoped, team-scoped, or system.
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, PartialEq)]
#[serde(rename_all = "snake_case", tag = "scope")]
pub enum PropertyOwner {
- /// User-scoped property only
+ /// User-scoped property.
User { user_id: String },
- /// Organization-scoped property only
- Organization { organization_id: i32 },
- /// Both user and organization-scoped
- UserAndOrganization {
- user_id: String,
- organization_id: i32,
- },
- /// System-owned property (no user or org owner)
+ /// Team-scoped property.
+ Team { team_id: Uuid },
+ /// System-owned property (no user or team owner).
System,
}
impl PropertyOwner {
- /// Get the organization_id if present
- pub fn organization_id(&self) -> Option<i32> {
+ /// Get the team_id if present.
+ pub fn team_id(&self) -> Option<Uuid> {
match self {
- PropertyOwner::Organization { organization_id } => Some(*organization_id),
- PropertyOwner::UserAndOrganization {
- organization_id, ..
- } => Some(*organization_id),
+ PropertyOwner::Team { team_id } => Some(*team_id),
PropertyOwner::User { .. } | PropertyOwner::System => None,
}
}
- /// Get the user_id if present
+ /// Get the user_id if present.
pub fn user_id(&self) -> Option<&str> {
match self {
PropertyOwner::User { user_id } => Some(user_id.as_str()),
- PropertyOwner::UserAndOrganization { user_id, .. } => Some(user_id.as_str()),
- PropertyOwner::Organization { .. } | PropertyOwner::System => None,
+ PropertyOwner::Team { .. } | PropertyOwner::System => None,
}
}
- /// Create from optional org_id, user_id, and is_system flag (for DB conversions)
+ /// Create from optional team_id, user_id, and is_system flag (for DB conversions).
+ /// A definition is owned by exactly one of: the system, a user, or a team.
pub fn from_optional_ids(
- organization_id: Option<i32>,
+ team_id: Option<Uuid>,
user_id: Option<String>,
is_system: bool,
) -> Self {
if is_system {
return PropertyOwner::System;
}
- match (organization_id, user_id) {
- (Some(org_id), Some(uid)) => PropertyOwner::UserAndOrganization {
- user_id: uid,
- organization_id: org_id,
+ match user_id {
+ Some(user_id) => PropertyOwner::User { user_id },
+ None => match team_id {
+ Some(team_id) => PropertyOwner::Team { team_id },
+ None => PropertyOwner::System,
},
- (Some(org_id), None) => PropertyOwner::Organization {
- organization_id: org_id,
- },
- (None, Some(uid)) => PropertyOwner::User { user_id: uid },
- (None, None) => {
- // This should not happen for non-system properties
- // but we handle it gracefully by returning System
- PropertyOwner::System
- }
}
}
}
diff --git a/rust/cloud-storage/properties/src/outbound/property_definition_queries.rs b/rust/cloud-storage/properties/src/outbound/property_definition_queries.rs
index 793325a51b..28012226c0 100644
--- a/rust/cloud-storage/properties/src/outbound/property_definition_queries.rs
+++ b/rust/cloud-storage/properties/src/outbound/property_definition_queries.rs
@@ -12,9 +12,9 @@ pub async fn get_property_definition(
) -> anyhow::Result<Option<PropertyDefinition>> {
let row = sqlx::query!(
r#"
- SELECT
+ SELECT
id,
- organization_id,
+ team_id,
user_id,
display_name,
data_type as "data_type: DataType",
@@ -34,7 +34,7 @@ pub async fn get_property_definition(
let result = row.map(|row| {
let db_prop = db::PropertyDefinition {
id: row.id,
- organization_id: row.organization_id,
+ team_id: row.team_id,
user_id: row.user_id,
display_name: row.display_name,
data_type: row.data_type,
diff --git a/rust/cloud-storage/properties_db_client/fixtures/properties.sql b/rust/cloud-storage/properties_db_client/fixtures/properties.sql
index 69032ecb1c..1fd2a9b038 100644
--- a/rust/cloud-storage/properties_db_client/fixtures/properties.sql
+++ b/rust/cloud-storage/properties_db_client/fixtures/properties.sql
@@ -1,10 +1,6 @@
--- Test organizations and users
--- These reference the Organization and User tables which should exist from macro_db migrations
-INSERT INTO "Organization" (id, name)
-VALUES (1, 'Test Org 1'),
- (2, 'Test Org 2')
-ON CONFLICT (id) DO NOTHING;
-
+-- Test users, teams, and properties for properties_db_client tests.
+-- Property definitions are owned by a team, a user, or the system.
+-- The schema enforces UNIQUE (user_id) on team_user, so each user belongs to one team.
INSERT INTO "macro_user" (id, username, email, stripe_customer_id)
VALUES
('a1111111-1111-1111-1111-111111111111', '[email protected]', '[email protected]', 'cus_test1'),
@@ -18,30 +14,42 @@ VALUES ('user1', '[email protected]', 'Test User 1', 'cus_test1', 'a1111111-1111-11
('user3', '[email protected]', 'Test User 3', 'cus_test3', 'a3333333-3333-3333-3333-333333333333')
ON CONFLICT (id) DO NOTHING;
+-- Teams: Team 1 has two members (user1 owner, user3 member); Team 2 has user2.
+INSERT INTO team (id, name, owner_id)
+VALUES ('0e000000-0000-0000-0000-000000000001', 'Test Team 1', 'user1'),
+ ('0e000000-0000-0000-0000-000000000002', 'Test Team 2', 'user2')
+ON CONFLICT (id) DO NOTHING;
+
+INSERT INTO team_user (user_id, team_id, team_role)
+VALUES ('user1', '0e000000-0000-0000-0000-000000000001', 'owner'),
+ ('user3', '0e000000-0000-0000-0000-000000000001', 'member'),
+ ('user2', '0e000000-0000-0000-0000-000000000002', 'owner')
+ON CONFLICT DO NOTHING;
+
-- Property definitions with various data types
-- Note: Names are prefixed with "Test" to avoid conflicts with system properties
-INSERT INTO property_definitions (id, organization_id, user_id, display_name, data_type, is_multi_select, specific_entity_type)
-VALUES
- -- Organization-owned properties
- ('11111111-1111-1111-1111-111111111111', 1, NULL, 'Test Priority', 'SELECT_STRING', false, NULL),
- ('22222222-2222-2222-2222-222222222222', 1, NULL, 'Test Department', 'SELECT_STRING', true, NULL),
- ('33333333-3333-3333-3333-333333333333', 1, NULL, 'Test Assigned To', 'ENTITY', true, 'USER'),
- ('44444444-4444-4444-4444-444444444444', 1, NULL, 'Test Score', 'SELECT_NUMBER', false, NULL),
- ('55555555-5555-5555-5555-555555555555', 1, NULL, 'Test Completed', 'BOOLEAN', false, NULL),
- ('66666666-6666-6666-6666-666666666666', 1, NULL, 'Test Due Date', 'DATE', false, NULL),
- ('77777777-7777-7777-7777-777777777777', 1, NULL, 'Test Budget', 'NUMBER', false, NULL),
- ('88888888-8888-8888-8888-888888888888', 1, NULL, 'Test Description', 'STRING', false, NULL),
- ('99999999-9999-9999-9999-999999999999', 1, NULL, 'Test Website', 'LINK', false, NULL),
- ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 1, NULL, 'Test Relevant Documents', 'ENTITY', false, 'DOCUMENT'),
- -- User-owned properties
+INSERT INTO property_definitions (id, team_id, user_id, display_name, data_type, is_multi_select, specific_entity_type)
+VALUES
+ -- Team 1-owned properties
+ ('11111111-1111-1111-1111-111111111111', '0e000000-0000-0000-0000-000000000001', NULL, 'Test Priority', 'SELECT_STRING', false, NULL),
+ ('22222222-2222-2222-2222-222222222222', '0e000000-0000-0000-0000-000000000001', NULL, 'Test Department', 'SELECT_STRING', true, NULL),
+ ('33333333-3333-3333-3333-333333333333', '0e000000-0000-0000-0000-000000000001', NULL, 'Test Assigned To', 'ENTITY', true, 'USER'),
+ ('44444444-4444-4444-4444-444444444444', '0e000000-0000-0000-0000-000000000001', NULL, 'Test Score', 'SELECT_NUMBER', false, NULL),
+ ('55555555-5555-5555-5555-555555555555', '0e000000-0000-0000-0000-000000000001', NULL, 'Test Completed', 'BOOLEAN', false, NULL),
+ ('66666666-6666-6666-6666-666666666666', '0e000000-0000-0000-0000-000000000001', NULL, 'Test Due Date', 'DATE', false, NULL),
+ ('77777777-7777-7777-7777-777777777777', '0e000000-0000-0000-0000-000000000001', NULL, 'Test Budget', 'NUMBER', false, NULL),
+ ('88888888-8888-8888-8888-888888888888', '0e000000-0000-0000-0000-000000000001', NULL, 'Test Description', 'STRING', false, NULL),
+ ('99999999-9999-9999-9999-999999999999', '0e000000-0000-0000-0000-000000000001', NULL, 'Test Website', 'LINK', false, NULL),
+ ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '0e000000-0000-0000-0000-000000000001', NULL, 'Test Relevant Documents', 'ENTITY', false, 'DOCUMENT'),
+ -- User-owned properties (user1)
('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', NULL, 'user1', 'Test Personal Priority', 'SELECT_STRING', false, NULL),
('cccccccc-cccc-cccc-cccc-cccccccccccc', NULL, 'user1', 'Test Notes', 'STRING', false, NULL),
- -- Mixed ownership property (org and user)
- ('dddddddd-dddd-dddd-dddd-dddddddddddd', 2, 'user2', 'Test Shared Status', 'SELECT_STRING', false, NULL);
+ -- Team 2-owned property
+ ('dddddddd-dddd-dddd-dddd-dddddddddddd', '0e000000-0000-0000-0000-000000000002', NULL, 'Test Shared Status', 'SELECT_STRING', false, NULL);
-- Property options for select types
INSERT INTO property_options (id, property_definition_id, display_order, number_value, string_value)
-VALUES
+VALUES
-- Priority options (string)
('10111111-1111-1111-1111-111111111111', '11111111-1111-1111-1111-111111111111', 0, NULL, 'Low'),
('10111111-1111-1111-1111-111111111112', '11111111-1111-1111-1111-111111111111', 1, NULL, 'Medium'),
@@ -66,7 +74,7 @@ VALUES
-- Entity properties with various values
INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)
-VALUES
+VALUES
-- Document entities
('e0111111-1111-1111-1111-111111111111', 'doc1', 'DOCUMENT', '11111111-1111-1111-1111-111111111111', '{"type": "SelectOption", "value": ["10111111-1111-1111-1111-111111111113"]}'),
('e0111111-1111-1111-1111-111111111112', 'doc1', 'DOCUMENT', '22222222-2222-2222-2222-222222222222', '{"type": "SelectOption", "value": ["10222222-2222-2222-2222-222222222222"]}'),
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.rs
index 18ec57b649..633d781a3b 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
@@ -21,7 +21,7 @@ struct EntityPropertyRow {
property_definition_id: Uuid,
entity_property_created_at: chrono::DateTime<chrono::Utc>,
entity_property_updated_at: chrono::DateTime<chrono::Utc>,
- definition_organization_id: Option<i32>,
+ definition_team_id: Option<Uuid>,
definition_user_id: Option<String>,
display_name: String,
data_type: DataType,
@@ -38,7 +38,7 @@ fn row_to_entity_property_with_definition(
row: EntityPropertyRow,
) -> Result<EntityPropertyWithDefinition> {
let owner = models_properties::PropertyOwner::from_optional_ids(
- row.definition_organization_id,
+ row.definition_team_id,
row.definition_user_id,
row.definition_is_system,
);
@@ -322,7 +322,7 @@ SELECT
ep.values as "values: sqlx::types::JsonValue",
ep.created_at as entity_property_created_at,
ep.updated_at as entity_property_updated_at,
- pd.organization_id as definition_organization_id,
+ pd.team_id as definition_team_id,
pd.user_id as definition_user_id,
pd.display_name,
pd.data_type as "data_type: DataType",
@@ -351,7 +351,7 @@ WHERE ep.entity_id = $1 AND ep.entity_type = $2
property_definition_id: row.property_definition_id,
entity_property_created_at: row.entity_property_created_at,
entity_property_updated_at: row.entity_property_updated_at,
- definition_organization_id: row.definition_organization_id,
+ definition_team_id: row.definition_team_id,
definition_user_id: row.definition_user_id,
display_name: row.display_name,
data_type: row.data_type,
@@ -400,7 +400,7 @@ SELECT
ep.values as "values: sqlx::types::JsonValue",
ep.created_at as entity_property_created_at,
ep.updated_at as entity_property_updated_at,
- pd.organization_id as definition_organization_id,
+ pd.team_id as definition_team_id,
pd.user_id as definition_user_id,
pd.display_name,
pd.data_type as "data_type: DataType",
@@ -434,7 +434,7 @@ WHERE (ep.entity_id, ep.entity_type) IN (
property_definition_id: row.property_definition_id,
entity_property_created_at: row.entity_property_created_at,
entity_property_updated_at: row.entity_property_updated_at,
- definition_organization_id: row.definition_organization_id,
+ definition_team_id: row.definition_team_id,
definition_user_id: row.definition_user_id,
display_name: row.display_name,
data_type: row.data_type,
@@ -500,7 +500,7 @@ SELECT
ep.values as "values: sqlx::types::JsonValue",
ep.created_at as entity_property_created_at,
ep.updated_at as entity_property_updated_at,
- pd.organization_id as definition_organization_id,
+ pd.team_id as definition_team_id,
pd.user_id as definition_user_id,
pd.display_name,
pd.data_type as "data_type: DataType",
@@ -535,7 +535,7 @@ AND pd.id = ANY($3::UUID[])
property_definition_id: row.property_definition_id,
entity_property_created_at: row.entity_property_created_at,
entity_property_updated_at: row.entity_property_updated_at,
- definition_organization_id: row.definition_organization_id,
+ definition_team_id: row.definition_team_id,
definition_user_id: row.definition_user_id,
display_name: row.display_name,
data_type: row.data_type,
diff --git a/rust/cloud-storage/properties_db_client/src/error.rs b/rust/cloud-storage/properties_db_client/src/error.rs
index e8f0a5afee..3d0b919d24 100644
--- a/rust/cloud-storage/properties_db_client/src/error.rs
+++ b/rust/cloud-storage/properties_db_client/src/error.rs
@@ -15,9 +15,6 @@ pub enum PropertiesDatabaseError {
property_id: Uuid,
},
- #[error("Either organization_id or user_id is required when creating property definitions")]
- MissingOwner,
-
#[error("Failed to serialize property value to JSON: {0}")]
SerializationError(#[source] serde_json::Error),
diff --git a/rust/cloud-storage/properties_db_client/src/property_definitions/get.rs b/rust/cloud-storage/properties_db_client/src/property_definitions/get.rs
index d89433b4e5..a63747520f 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
@@ -11,20 +11,20 @@ use uuid::Uuid;
type Result<T> = std::result::Result<T, PropertiesDatabaseError>;
-/// Gets property definitions based on optional organization and optional user access.
+/// Gets property definitions based on optional team and optional user access.
/// Set `include_system` to true to also include system properties.
#[tracing::instrument(skip(db))]
pub async fn get_properties(
db: &Pool<Postgres>,
- organization_id: Option<i32>,
+ team_id: Option<Uuid>,
user_id: Option<&str>,
include_system: bool,
) -> Result<Vec<PropertyDefinition>> {
let rows = sqlx::query!(
r#"
- SELECT
+ SELECT
id,
- organization_id,
+ team_id,
user_id,
display_name,
data_type as "data_type: DataType",
@@ -34,15 +34,15 @@ pub async fn get_properties(
updated_at,
is_system
FROM property_definitions
- WHERE
+ WHERE
($3 AND is_system)
OR (
- ($1::int IS NOT NULL AND organization_id = $1)
+ ($1::uuid IS NOT NULL AND team_id = $1)
OR ($2::text IS NOT NULL AND user_id = $2)
)
ORDER BY LOWER(display_name) ASC
"#,
- organization_id,
+ team_id,
user_id,
include_system
)
@@ -54,7 +54,7 @@ pub async fn get_properties(
.map(|row| {
let db_def = db::PropertyDefinition {
id: row.id,
- organization_id: row.organization_id,
+ team_id: row.team_id,
user_id: row.user_id,
display_name: row.display_name,
data_type: row.data_type,
@@ -79,9 +79,9 @@ pub async fn get_property_definition(
) -> Result<Option<PropertyDefinition>> {
let row = sqlx::query!(
r#"
- SELECT
+ SELECT
id,
- organization_id,
+ team_id,
user_id,
display_name,
data_type as "data_type: DataType",
@@ -101,7 +101,7 @@ pub async fn get_property_definition(
let result = row.map(|row| {
let db_prop = db::PropertyDefinition {
id: row.id,
- organization_id: row.organization_id,
+ team_id: row.team_id,
user_id: row.user_id,
display_name: row.display_name,
data_type: row.data_type,
@@ -118,20 +118,21 @@ pub async fn get_property_definition(
}
/// Gets a single property definition by ID with ownership validation.
-/// Returns None if the property doesn't exist, if the user doesn't own it, or if it's a system property.
+/// Returns None if the property doesn't exist, if the caller doesn't own it, or if it's a system property.
+/// The caller owns it when it is their user property, or a property of the team they belong to.
/// System properties don't have owners and should be fetched via `get_property_definition`.
#[tracing::instrument(skip(db))]
pub async fn get_property_definition_with_owner(
db: &Pool<Postgres>,
property_id: uuid::Uuid,
user_id: &str,
- organization_id: Option<i32>,
+ team_id: Option<Uuid>,
) -> Result<Option<PropertyDefinition>> {
let row = sqlx::query!(
r#"
- SELECT
+ SELECT
id,
- organization_id,
+ team_id,
user_id,
display_name,
data_type as "data_type: DataType",
@@ -145,12 +146,12 @@ pub async fn get_property_definition_with_owner(
AND is_system = FALSE
AND (
user_id = $2
- OR ($3::int IS NOT NULL AND organization_id = $3)
+ OR ($3::uuid IS NOT NULL AND team_id = $3)
)
"#,
property_id,
user_id,
- organization_id
+ team_id
)
.fetch_optional(db)
.await?;
@@ -158,7 +159,7 @@ pub async fn get_property_definition_with_owner(
let result = row.map(|row| {
let db_prop = db::PropertyDefinition {
id: row.id,
- organization_id: row.organization_id,
+ team_id: row.team_id,
user_id: row.user_id,
display_name: row.display_name,
data_type: row.data_type,
@@ -174,20 +175,20 @@ pub async fn get_property_definition_with_owner(
Ok(result)
}
-/// Gets property definitions with options based on organization and optional user access.
+/// 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))]
pub async fn get_properties_with_options(
db: &Pool<Postgres>,
- organization_id: Option<i32>,
+ team_id: Option<Uuid>,
user_id: Option<&str>,
include_system: bool,
) -> Result<Vec<PropertyDefinitionWithOptions>> {
let rows = sqlx::query!(
r#"
- SELECT
+ SELECT
pd.id,
- pd.organization_id,
+ pd.team_id,
pd.user_id,
pd.display_name,
pd.data_type as "data_type: DataType",
@@ -204,15 +205,15 @@ pub async fn get_properties_with_options(
po.updated_at as "option_updated_at?"
FROM property_definitions pd
LEFT JOIN property_options po ON pd.id = po.property_definition_id
- WHERE
+ WHERE
($3 AND pd.is_system)
OR (
- ($1::int IS NOT NULL AND pd.organization_id = $1)
+ ($1::uuid IS NOT NULL AND pd.team_id = $1)
OR ($2::text IS NOT NULL AND pd.user_id = $2)
)
ORDER BY LOWER(pd.display_name), po.display_order, po.number_value, LOWER(po.string_value)
"#,
- organization_id,
+ team_id,
user_id,
include_system
)
@@ -223,7 +224,7 @@ pub async fn get_properties_with_options(
for row in rows {
let owner = models_properties::PropertyOwner::from_optional_ids(
- row.organization_id,
+ row.team_id,
row.user_id.clone(),
row.is_system,
);
@@ -304,16 +305,24 @@ mod tests {
use macro_db_migrator::MACRO_DB_MIGRATIONS;
use sqlx::{Pool, Postgres};
+ fn team_1() -> Uuid {
+ "0e000000-0000-0000-0000-000000000001".parse().unwrap()
+ }
+
+ fn team_2() -> Uuid {
+ "0e000000-0000-0000-0000-000000000002".parse().unwrap()
+ }
+
#[sqlx::test(
migrator = "MACRO_DB_MIGRATIONS",
fixtures(path = "../../fixtures", scripts("properties"))
)]
- async fn test_get_properties_by_organization(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ async fn test_get_properties_by_team(pool: Pool<Postgres>) -> anyhow::Result<()> {
const _: &sqlx::migrate::Migrator = &MACRO_DB_MIGRATIONS; // Dummy reference for IDE
- let properties = get_properties(&pool, Some(1), None, false).await?;
+ let properties = get_properties(&pool, Some(team_1()), None, false).await?;
- assert_eq!(properties.len(), 10); // Organization 1 has 10 properties
+ assert_eq!(properties.len(), 10); // Team 1 has 10 properties
// Verify they are sorted by display name (case-insensitive alphabetical)
assert_eq!(properties[0].display_name, "Test Assigned To");
@@ -391,18 +400,46 @@ mod tests {
async fn test_get_property_definition_with_owner(pool: Pool<Postgres>) -> anyhow::Result<()> {
const _: &sqlx::migrate::Migrator = &MACRO_DB_MIGRATIONS;
- let property_id = "11111111-1111-1111-1111-111111111111"
+ let team_property_id = "11111111-1111-1111-1111-111111111111"
.parse::<Uuid>()
.unwrap();
- // User in organization 1 should have access
+ // The team owner can access the team property.
+ let property =
+ get_property_definition_with_owner(&pool, team_property_id, "user1", Some(team_1()))
+ .await?;
+ assert!(property.is_some());
+
+ // A different member of the same team can also access it.
+ let property =
+ get_property_definition_with_owner(&pool, team_property_id, "user3", Some(team_1()))
+ .await?;
+ assert!(property.is_some());
+
+ // A user on a different team cannot access it.
+ let property =
+ get_property_definition_with_owner(&pool, team_property_id, "user2", Some(team_2()))
+ .await?;
+ assert!(property.is_none());
+
+ // A user with no team cannot access it.
+ let property =
+ get_property_definition_with_owner(&pool, team_property_id, "user2", None).await?;
+ assert!(property.is_none());
+
+ // The owning user can access their own user property.
+ let user_property_id = "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"
+ .parse::<Uuid>()
+ .unwrap();
let property =
- get_property_definition_with_owner(&pool, property_id, "user1", Some(1)).await?;
+ get_property_definition_with_owner(&pool, user_property_id, "user1", Some(team_1()))
+ .await?;
assert!(property.is_some());
- // User not in organization should not have access
+ // A different user cannot access someone else's user property.
let property =
- get_property_definition_with_owner(&pool, property_id, "user1", Some(99)).await?;
+ get_property_definition_with_owner(&pool, user_property_id, "user3", Some(team_1()))
+ .await?;
assert!(property.is_none());
Ok(())
@@ -415,7 +452,7 @@ mod tests {
async fn test_get_properties_with_options(pool: Pool<Postgres>) -> anyhow::Result<()> {
const _: &sqlx::migrate::Migrator = &MACRO_DB_MIGRATIONS;
- let properties = get_properties_with_options(&pool, Some(1), None, false).await?;
+ let properties = get_properties_with_options(&pool, Some(team_1()), None, false).await?;
assert_eq!(properties.len(), 10);
@@ -449,7 +486,7 @@ mod tests {
) -> anyhow::Result<()> {
const _: &sqlx::migrate::Migrator = &MACRO_DB_MIGRATIONS;
- let properties = get_properties_with_options(&pool, Some(1), None, false).await?;
+ let properties = get_properties_with_options(&pool, Some(team_1()), None, false).await?;
// Find non-select properties (should have 0 options)
let completed_prop = properties
@@ -470,7 +507,7 @@ mod tests {
async fn test_get_properties_with_number_options(pool: Pool<Postgres>) -> anyhow::Result<()> {
const _: &sqlx::migrate::Migrator = &MACRO_DB_MIGRATIONS;
- let properties = get_properties_with_options(&pool, Some(1), None, false).await?;
+ let properties = get_properties_with_options(&pool, Some(team_1()), None, false).await?;
// Find Score property which has number options
let score_prop = properties
@@ -502,7 +539,7 @@ mod tests {
) -> anyhow::Result<()> {
const _: &sqlx::migrate::Migrator = &MACRO_DB_MIGRATIONS;
- let properties = get_properties_with_options(&pool, Some(1), None, false).await?;
+ let properties = get_properties_with_options(&pool, Some(team_1()), None, false).await?;
// Find Department property which is multi-select
let dept_prop = properties
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.rs
index 48ab0201d1..ecb85835a9 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
@@ -5,23 +5,42 @@ use models_properties::service::property_definition::PropertyDefinition;
use models_properties::service::property_option::PropertyOption;
use models_properties::{DataType, EntityType, db};
use sqlx::{Pool, Postgres};
+use uuid::Uuid;
type Result<T> = std::result::Result<T, PropertiesDatabaseError>;
+/// The owner of a user- or team-created property definition. Encodes the
+/// "exactly one of user / team" invariant in the type, so neither a both-owners
+/// nor a no-owner row is representable. System properties are not created here.
+#[derive(Debug, Clone, Copy)]
+pub enum DefinitionOwner<'a> {
+ /// Owned by a single user.
+ User(&'a str),
+ /// Owned by a team.
+ Team(Uuid),
+}
+
+impl<'a> DefinitionOwner<'a> {
+ /// Split into the nullable (team_id, user_id) columns the row stores.
+ fn into_ids(self) -> (Option<Uuid>, Option<&'a str>) {
+ match self {
+ DefinitionOwner::User(user_id) => (None, Some(user_id)),
+ DefinitionOwner::Team(team_id) => (Some(team_id), None),
+ }
+ }
+}
+
/// Creates a new property definition.
#[tracing::instrument(skip(db))]
pub async fn create_property_definition(
db: &Pool<Postgres>,
- organization_id: Option<i32>,
- user_id: Option<&str>,
+ owner: DefinitionOwner<'_>,
display_name: &str,
data_type: DataType,
is_multi_select: bool,
specific_entity_type: Option<EntityType>,
) -> Result<PropertyDefinition> {
- if organization_id.is_none() && user_id.is_none() {
- return Err(PropertiesDatabaseError::MissingOwner);
- }
+ let (team_id, user_id) = owner.into_ids();
let id = macro_uuid::generate_uuid_v7();
@@ -29,17 +48,17 @@ pub async fn create_property_definition(
r#"
INSERT INTO property_definitions (
id,
- organization_id,
- user_id,
- display_name,
- data_type,
+ team_id,
+ user_id,
+ display_name,
+ data_type,
is_multi_select,
specific_entity_type
)
VALUES ($1, $2, $3, $4, $5, $6, $7)
- RETURNING
+ RETURNING
id,
- organization_id,
+ team_id,
user_id,
display_name,
data_type as "data_type: DataType",
@@ -49,7 +68,7 @@ pub async fn create_property_definition(
updated_at
"#,
id,
- organization_id,
+ team_id,
user_id,
display_name,
data_type as DataType,
@@ -61,7 +80,7 @@ pub async fn create_property_definition(
let db_result = db::PropertyDefinition {
id: row.id,
- organization_id: row.organization_id,
+ team_id: row.team_id,
user_id: row.user_id,
display_name: row.display_name,
data_type: row.data_type,
@@ -77,23 +96,16 @@ pub async fn create_property_definition(
/// Creates a property definition with options in a single transaction.
#[tracing::instrument(skip(db, options))]
-#[expect(
- clippy::too_many_arguments,
- reason = "no good reason but too hard to fix right now"
-)]
pub async fn create_property_definition_with_options(
db: &Pool<Postgres>,
- organization_id: Option<i32>,
- user_id: Option<&str>,
+ owner: DefinitionOwner<'_>,
display_name: &str,
data_type: DataType,
is_multi_select: bool,
specific_entity_type: Option<EntityType>,
options: Vec<PropertyOption>,
) -> Result<PropertyDefinition> {
- if organization_id.is_none() && user_id.is_none() {
- return Err(PropertiesDatabaseError::MissingOwner);
- }
+ let (team_id, user_id) = owner.into_ids();
let mut tx = db.begin().await?;
@@ -103,17 +115,17 @@ pub async fn create_property_definition_with_options(
r#"
INSERT INTO property_definitions (
id,
- organization_id,
- user_id,
- display_name,
- data_type,
+ team_id,
+ user_id,
+ display_name,
+ data_type,
is_multi_select,
specific_entity_type
)
VALUES ($1, $2, $3, $4, $5, $6, $7)
- RETURNING
+ RETURNING
id,
- organization_id,
+ team_id,
user_id,
display_name,
data_type as "data_type: DataType",
@@ -123,7 +135,7 @@ pub async fn create_property_definition_with_options(
updated_at
"#,
id,
- organization_id,
+ team_id,
user_id,
display_name,
data_type as DataType,
@@ -152,7 +164,7 @@ pub async fn create_property_definition_with_options(
let db_property_def = db::PropertyDefinition {
id: row.id,
- organization_id: row.organization_id,
+ team_id: row.team_id,
user_id: row.user_id,
display_name: row.display_name,
data_type: row.data_type,
@@ -206,6 +218,10 @@ mod tests {
use models_properties::service::property_option::PropertyOptionValue;
use sqlx::{Pool, Postgres};
+ fn team_1() -> Uuid {
+ "0e000000-0000-0000-0000-000000000001".parse().unwrap()
+ }
+
#[sqlx::test(
migrator = "MACRO_DB_MIGRATIONS",
fixtures(path = "../../fixtures", scripts("properties"))
@@ -215,8 +231,7 @@ mod tests {
let property = create_property_definition(
&pool,
- Some(1),
- None,
+ DefinitionOwner::Team(team_1()),
"New Test Property",
DataType::String,
false,
@@ -243,8 +258,7 @@ mod tests {
let property = create_property_definition(
&pool,
- None,
- Some("user1"),
+ DefinitionOwner::User("user1"),
"User Property",
DataType::Number,
false,
@@ -259,35 +273,6 @@ mod tests {
Ok(())
}
- #[sqlx::test(
- migrator = "MACRO_DB_MIGRATIONS",
- fixtures(path = "../../fixtures", scripts("properties"))
- )]
- async fn test_create_property_definition_no_owner_fails(
- pool: Pool<Postgres>,
- ) -> anyhow::Result<()> {
- const _: &sqlx::migrate::Migrator = &MACRO_DB_MIGRATIONS;
-
- let result = create_property_definition(
- &pool,
- None,
- None,
- "No Owner Property",
- DataType::String,
- false,
- None,
- )
- .await;
-
- assert!(result.is_err());
- match result.unwrap_err() {
- PropertiesDatabaseError::MissingOwner => {}
- _ => panic!("Expected MissingOwner error"),
- }
-
- Ok(())
- }
-
#[sqlx::test(
migrator = "MACRO_DB_MIGRATIONS",
fixtures(path = "../../fixtures", scripts("properties"))
@@ -297,11 +282,10 @@ mod tests {
) -> anyhow::Result<()> {
const _: &sqlx::migrate::Migrator = &MACRO_DB_MIGRATIONS;
- // Try to create a property with the same name as an existing one in org 1
+ // Try to create a property with the same name as an existing one in team 1
let result = create_property_definition(
&pool,
- Some(1),
- None,
+ DefinitionOwner::Team(team_1()),
"Test Priority", // Already exists in fixtures
DataType::String,
false,
@@ -344,8 +328,7 @@ mod tests {
let property = create_property_definition_with_options(
&pool,
- Some(1),
- None,
+ DefinitionOwner::Team(team_1()),
"Property With Options",
DataType::SelectString,
false,
@@ -377,8 +360,7 @@ mod tests {
let property = create_property_definition(
&pool,
- Some(1),
- None,
+ DefinitionOwner::Team(team_1()),
"Multi Select Property",
DataType::SelectString,
true, // multi-select
@@ -403,8 +385,7 @@ mod tests {
let property = create_property_definition(
&pool,
- Some(1),
- None,
+ DefinitionOwner::Team(team_1()),
"Multi Select Documents",
DataType::Entity,
true,
diff --git a/rust/cloud-storage/properties_service/src/api/context.rs b/rust/cloud-storage/properties_service/src/api/context.rs
index 6280b33fc7..d9006836f1 100644
--- a/rust/cloud-storage/properties_service/src/api/context.rs
+++ b/rust/cloud-storage/properties_service/src/api/context.rs
@@ -1,9 +1,12 @@
use axum::extract::FromRef;
+use entity_access::domain::models::MemberTeamRole;
+use entity_access::inbound::axum_extractors::OptionalMacroUserTeamExtractor;
use entity_access::{domain::service::EntityAccessServiceImpl, outbound::PgAccessRepository};
use notification::domain::service::SqsNotificationIngress;
use notification::outbound::queue::SqsQueue;
use sqlx::PgPool;
use std::sync::Arc;
+use uuid::Uuid;
use properties::PropertiesServiceImpl;
@@ -13,6 +16,20 @@ type NotificationIngressType = SqsNotificationIngress<SqsQueue>;
/// Type alias for the entity access service.
pub type EntityAccessServiceType = EntityAccessServiceImpl<PgAccessRepository>;
+/// Team extractor used by property definition endpoints. Resolves the caller's team
+/// membership without failing when they have no team. Member role is required, matching
+/// the model where anyone on a team can manage that team's properties.
+pub type PropertyTeamExtractor =
+ OptionalMacroUserTeamExtractor<MemberTeamRole, EntityAccessServiceType>;
+
+/// The team the caller belongs to, if any. A `None` team scopes the caller to their own
+/// user properties.
+pub fn caller_team_id(team: &PropertyTeamExtractor) -> Option<Uuid> {
+ team.entity_access_receipt
+ .as_ref()
+ .and_then(|receipt| Uuid::parse_str(&receipt.entity().entity_id).ok())
+}
+
/// Type alias for the properties service implementation used throughout the service.
pub type PropertiesService = PropertiesServiceImpl<
properties::PropertiesPgRepo,
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.rs
index ffa3e1f991..b5276c7dcf 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
@@ -7,13 +7,16 @@ use axum::{
use thiserror::Error;
use uuid::Uuid;
-use crate::api::context::PropertiesHandlerState;
+use crate::api::context::{PropertiesHandlerState, PropertyTeamExtractor, caller_team_id};
use model::user::UserContext;
-use models_properties::api::{CreatePropertyDefinitionRequest, PropertyDataType};
+use models_properties::api::{
+ CreatePropertyDefinitionRequest, CreatePropertyScope, PropertyDataType,
+};
use models_properties::service::property_definition::PropertyDefinition;
use models_properties::service::property_option::{PropertyOption, PropertyOptionValue};
use properties_db_client::{
- error::PropertiesDatabaseError, property_definitions::insert as property_definitions_insert,
+ error::PropertiesDatabaseError,
+ property_definitions::insert::{self as property_definitions_insert, DefinitionOwner},
};
#[derive(Debug, Error)]
@@ -24,6 +27,8 @@ pub enum CreatePropertyDefinitionErr {
DatabaseError(#[from] PropertiesDatabaseError),
#[error("{0}")]
InvalidRequest(String),
+ #[error("You must be on a team to create a team property")]
+ TeamMembershipRequired,
}
impl IntoResponse for CreatePropertyDefinitionErr {
@@ -32,6 +37,7 @@ impl IntoResponse for CreatePropertyDefinitionErr {
CreatePropertyDefinitionErr::InternalError(_)
| CreatePropertyDefinitionErr::DatabaseError(_) => StatusCode::INTERNAL_SERVER_ERROR,
CreatePropertyDefinitionErr::InvalidRequest(_) => StatusCode::BAD_REQUEST,
+ CreatePropertyDefinitionErr::TeamMembershipRequired => StatusCode::FORBIDDEN,
};
if status_code.is_server_error() {
@@ -54,22 +60,18 @@ impl IntoResponse for CreatePropertyDefinitionErr {
responses(
(status = 201, description = "Property definition created successfully", body = PropertyDefinition),
(status = 400, description = "Invalid request"),
+ (status = 403, description = "Team membership required for team scope"),
(status = 500, description = "Internal server error")
),
tags = ["Properties"]
)]
-#[tracing::instrument(skip(state, user_context), fields(user_id = %user_context.user_id), err)]
+#[tracing::instrument(skip(state, user_context, team), fields(user_id = %user_context.user_id), err)]
pub async fn create_property_definition(
State(state): State<PropertiesHandlerState>,
Extension(user_context): Extension<UserContext>,
+ team: PropertyTeamExtractor,
Json(request): Json<CreatePropertyDefinitionRequest>,
) -> Result<(StatusCode, Json<PropertyDefinition>), CreatePropertyDefinitionErr> {
- tracing::info!(
- organization_id = ?request.owner.organization_id(),
- user_id = ?request.owner.user_id(),
- "creating property definition"
- );
-
if let Err(err) = request.validate() {
tracing::error!(
error = %err,
@@ -78,6 +80,22 @@ pub async fn create_property_definition(
return Err(CreatePropertyDefinitionErr::InvalidRequest(err.to_string()));
}
+ // Derive the owner from the authenticated caller - clients never supply owner ids.
+ let owner = match request.scope {
+ CreatePropertyScope::User => DefinitionOwner::User(user_context.user_id.as_str()),
+ CreatePropertyScope::Team => {
+ let team_id =
+ caller_team_id(&team).ok_or(CreatePropertyDefinitionErr::TeamMembershipRequired)?;
+ DefinitionOwner::Team(team_id)
+ }
+ };
+
+ tracing::info!(
+ owner = ?owner,
+ scope = ?request.scope,
+ "creating property definition"
+ );
+
let (base_data_type, property_options) = match &request.data_type {
PropertyDataType::SelectString { options, .. } => {
let property_options: Vec<PropertyOption> = options
@@ -115,8 +133,7 @@ pub async fn create_property_definition(
property_definitions_insert::create_property_definition(
&state.db,
- request.owner.organization_id(),
- request.owner.user_id(),
+ owner,
&request.display_name,
base_data_type,
request.data_type.is_multi_select(),
@@ -138,8 +155,7 @@ pub async fn create_property_definition(
property_definitions_insert::create_property_definition_with_options(
&state.db,
- request.owner.organization_id(),
- request.owner.user_id(),
+ owner,
&request.display_name,
base_data_type,
request.data_type.is_multi_select(),
diff --git a/rust/cloud-storage/properties_service/src/api/properties/definitions/delete.rs b/rust/cloud-storage/properties_service/src/api/properties/definitions/delete.rs
index 34331fb75f..bb95cdcef8 100644
--- a/rust/cloud-storage/properties_service/src/api/properties/definitions/delete.rs
+++ b/rust/cloud-storage/properties_service/src/api/properties/definitions/delete.rs
@@ -7,7 +7,7 @@ use system_properties::SystemPropertyKey;
use thiserror::Error;
use uuid::Uuid;
-use crate::api::context::PropertiesHandlerState;
+use crate::api::context::{PropertiesHandlerState, PropertyTeamExtractor, caller_team_id};
use model::user::UserContext;
use properties_db_client::{
error::PropertiesDatabaseError,
@@ -65,11 +65,12 @@ impl IntoResponse for DeletePropertyDefinitionError {
),
tag = "Properties"
)]
-#[tracing::instrument(skip(state, user_context), err)]
+#[tracing::instrument(skip(state, user_context, team), err)]
pub async fn delete_property_definition(
Path(property_uuid): Path<Uuid>,
State(state): State<PropertiesHandlerState>,
Extension(user_context): Extension<UserContext>,
+ team: PropertyTeamExtractor,
) -> Result<Response, DeletePropertyDefinitionError> {
tracing::info!("deleting property definition");
@@ -87,7 +88,7 @@ pub async fn delete_property_definition(
&state.db,
property_uuid,
&user_context.user_id,
- user_context.organization_id,
+ caller_team_id(&team),
)
.await?
.ok_or(DeletePropertyDefinitionError::NotFound)?;
diff --git a/rust/cloud-storage/properties_service/src/api/properties/definitions/list.rs b/rust/cloud-storage/properties_service/src/api/properties/definitions/list.rs
index 22b1fd9f13..11b3ef871a 100644
--- a/rust/cloud-storage/properties_service/src/api/properties/definitions/list.rs
+++ b/rust/cloud-storage/properties_service/src/api/properties/definitions/list.rs
@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
use thiserror::Error;
use utoipa::ToSchema;
-use crate::api::context::PropertiesHandlerState;
+use crate::api::context::{PropertiesHandlerState, PropertyTeamExtractor, caller_team_id};
use model::user::UserContext;
use models_properties::EntityType;
use models_properties::service::property_definition::PropertyDefinition;
@@ -24,8 +24,6 @@ pub enum ListPropertiesErr {
InternalError(#[from] anyhow::Error),
#[error("An internal error occurred")]
DatabaseError(#[from] PropertiesDatabaseError),
- #[error("Organization ID is required for org scope")]
- MissingOrganizationId,
}
impl IntoResponse for ListPropertiesErr {
@@ -34,7 +32,6 @@ impl IntoResponse for ListPropertiesErr {
ListPropertiesErr::InternalError(_) | ListPropertiesErr::DatabaseError(_) => {
StatusCode::INTERNAL_SERVER_ERROR
}
- ListPropertiesErr::MissingOrganizationId => StatusCode::BAD_REQUEST,
};
if status_code.is_server_error() {
@@ -55,11 +52,11 @@ impl IntoResponse for ListPropertiesErr {
pub enum PropertyScope {
/// User-scoped properties only
User,
- /// Organization-scoped properties only
- Org,
+ /// The caller's team properties only
+ Team,
/// System properties only
System,
- /// User, organization, and system properties
+ /// User, team, and system properties
All,
}
@@ -90,7 +87,7 @@ pub enum PropertyDefinitionResponse {
get,
path = "/properties/definitions",
params(
- ("scope" = PropertyScope, Query, description = "Filter by scope: 'user', 'org', 'system', or 'all'"),
+ ("scope" = PropertyScope, Query, description = "Filter by scope: 'user', 'team', 'system', or 'all'"),
("include_options" = Option<bool>, Query, description = "Whether to include property options in the response"),
("for_entity_type" = Option<EntityType>, Query, description = "Filter properties applicable to a specific entity type")
),
@@ -101,32 +98,26 @@ pub enum PropertyDefinitionResponse {
),
tag = "Properties"
)]
-#[tracing::instrument(skip(state, user_context), err)]
+#[tracing::instrument(skip(state, user_context, team), err)]
pub async fn list_properties(
Query(query): Query<ListPropertiesQuery>,
State(state): State<PropertiesHandlerState>,
Extension(user_context): Extension<UserContext>,
+ team: PropertyTeamExtractor,
) -> Result<Json<Vec<PropertyDefinitionResponse>>, ListPropertiesErr> {
- // Note - NOT using organization properties for now
- let enable_organization_properties = false;
- // Determine query parameters based on scope
- let (org_id, user_id_opt, include_system) = match query.scope {
+ let callers_team = caller_team_id(&team);
+
+ // Determine query parameters based on scope. Team and user ids are derived from the
+ // authenticated caller, never from the request.
+ let (team_id, user_id_opt, include_system) = match query.scope {
PropertyScope::User => (None, Some(user_context.user_id.as_str()), false),
- PropertyScope::Org if enable_organization_properties => {
- (user_context.organization_id, None, false)
- }
- PropertyScope::Org => (None, None, false),
+ PropertyScope::Team => (callers_team, None, false),
PropertyScope::System => (None, None, true),
- PropertyScope::All if enable_organization_properties => (
- user_context.organization_id,
- Some(user_context.user_id.as_str()),
- true,
- ),
- PropertyScope::All => (None, Some(user_context.user_id.as_str()), true),
+ PropertyScope::All => (callers_team, Some(user_context.user_id.as_str()), true),
};
tracing::info!(
- organization_id = ?org_id,
+ team_id = ?team_id,
scope = ?query.scope,
include_system = include_system,
for_entity_type = ?query.for_entity_type,
@@ -136,14 +127,10 @@ pub async fn list_properties(
let filter_entity_type = query.for_entity_type;
- if enable_organization_properties && query.scope == PropertyScope::Org && org_id.is_none() {
- return Err(ListPropertiesErr::MissingOrganizationId);
- }
-
let response = if query.include_options {
let properties_with_options = property_definitions_get::get_properties_with_options(
&state.db,
- org_id,
+ team_id,
user_id_opt,
include_system,
)
@@ -151,7 +138,7 @@ pub async fn list_properties(
.inspect_err(|e| {
tracing::error!(
error = ?e,
- organization_id = ?org_id,
+ team_id = ?team_id,
scope = ?query.scope,
user_id = %user_context.user_id,
"failed to retrieve properties with options"
@@ -170,7 +157,7 @@ pub async fn list_properties(
tracing::info!(
properties_count = response.len(),
- organization_id = ?org_id,
+ team_id = ?team_id,
scope = ?query.scope,
user_id = %user_context.user_id,
"successfully retrieved properties with options"
@@ -179,7 +166,7 @@ pub async fn list_properties(
} else {
let properties = property_definitions_get::get_properties(
&state.db,
- org_id,
+ team_id,
user_id_opt,
include_system,
)
@@ -187,7 +174,7 @@ pub async fn list_properties(
.inspect_err(|e| {
tracing::error!(
error = ?e,
- organization_id = ?org_id,
+ team_id = ?team_id,
scope = ?query.scope,
user_id = %user_context.user_id,
"failed to retrieve properties"
@@ -206,7 +193,7 @@ pub async fn list_properties(
tracing::info!(
properties_count = response.len(),
- organization_id = ?org_id,
+ team_id = ?team_id,
scope = ?query.scope,
user_id = %user_context.user_id,
"successfully retrieved properties"
diff --git a/rust/cloud-storage/properties_service/src/api/properties/options/create.rs b/rust/cloud-storage/properties_service/src/api/properties/options/create.rs
index 38ef7db4f0..85ee793582 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
@@ -7,7 +7,7 @@ use axum::{
use thiserror::Error;
use uuid::Uuid;
-use crate::api::context::PropertiesHandlerState;
+use crate::api::context::{PropertiesHandlerState, PropertyTeamExtractor, caller_team_id};
use model::user::UserContext;
use models_properties::api::AddPropertyOptionRequest;
use models_properties::service::property_option::{PropertyOption, PropertyOptionValue};
@@ -70,11 +70,12 @@ impl IntoResponse for AddPropertyOptionErr {
),
tags = ["Properties"]
)]
-#[tracing::instrument(skip(state, user_context), fields(property_id = %property_uuid, request = ?request), err)]
+#[tracing::instrument(skip(state, user_context, team), fields(property_id = %property_uuid, request = ?request), err)]
pub async fn add_property_option(
Path(property_uuid): Path<Uuid>,
State(state): State<PropertiesHandlerState>,
Extension(user_context): Extension<UserContext>,
+ team: PropertyTeamExtractor,
Json(request): Json<AddPropertyOptionRequest>,
) -> Result<(StatusCode, Json<PropertyOption>), AddPropertyOptionErr> {
tracing::info!("adding property option");
@@ -99,7 +100,7 @@ pub async fn add_property_option(
&state.db,
property_uuid,
&user_context.user_id,
- user_context.organization_id,
+ caller_team_id(&team),
)
.await
.inspect_err(|e| {
diff --git a/rust/cloud-storage/properties_service/src/api/properties/options/delete.rs b/rust/cloud-storage/properties_service/src/api/properties/options/delete.rs
index cd34590b29..85fa908c17 100644
--- a/rust/cloud-storage/properties_service/src/api/properties/options/delete.rs
+++ b/rust/cloud-storage/properties_service/src/api/properties/options/delete.rs
@@ -6,7 +6,7 @@ use axum::{
use thiserror::Error;
use uuid::Uuid;
-use crate::api::context::PropertiesHandlerState;
+use crate::api::context::{PropertiesHandlerState, PropertyTeamExtractor, caller_team_id};
use model::user::UserContext;
use properties_db_client::{
error::PropertiesDatabaseError,
@@ -68,11 +68,12 @@ impl IntoResponse for DeletePropertyOptionErr {
),
tag = "Properties"
)]
-#[tracing::instrument(skip(state, user_context), err)]
+#[tracing::instrument(skip(state, user_context, team), err)]
pub async fn delete_property_option(
Path((def_uuid, option_uuid)): Path<(Uuid, Uuid)>,
State(state): State<PropertiesHandlerState>,
Extension(user_context): Extension<UserContext>,
+ team: PropertyTeamExtractor,
) -> Result<StatusCode, DeletePropertyOptionErr> {
tracing::info!("deleting property option");
@@ -96,7 +97,7 @@ pub async fn delete_property_option(
&state.db,
def_uuid,
&user_context.user_id,
- user_context.organization_id,
+ caller_team_id(&team),
)
.await
.inspect_err(|e| {
diff --git a/rust/cloud-storage/properties_service/src/api/swagger.rs b/rust/cloud-storage/properties_service/src/api/swagger.rs
index b0a628ad3c..1e24f79286 100644
--- a/rust/cloud-storage/properties_service/src/api/swagger.rs
+++ b/rust/cloud-storage/properties_service/src/api/swagger.rs
@@ -31,6 +31,7 @@ use utoipa::OpenApi;
components(
schemas(
api::CreatePropertyDefinitionRequest,
+ api::CreatePropertyScope,
api::PropertyDataType,
api::SelectStringOption,
api::SelectNumberOption,
diff --git a/rust/cloud-storage/system_properties/fixtures/system_properties.sql b/rust/cloud-storage/system_properties/fixtures/system_properties.sql
index aa01c47ba4..5bb1c1d83e 100644
--- a/rust/cloud-storage/system_properties/fixtures/system_properties.sql
+++ b/rust/cloud-storage/system_properties/fixtures/system_properties.sql
@@ -11,10 +11,10 @@ VALUES ('user1', '[email protected]', 'Test User 1', 'cus_test1', 'a1111111-1111-11
ON CONFLICT (id) DO NOTHING;
-- Custom property definitions
-INSERT INTO property_definitions (id, organization_id, user_id, display_name, data_type, is_multi_select, specific_entity_type)
-VALUES
- ('cccccccc-cccc-cccc-cccc-cccccccccc01', NULL, 'user1', 'Custom Notes', 'STRING', false, 'TASK'),
- ('cccccccc-cccc-cccc-cccc-cccccccccc02', NULL, 'user1', 'Custom Tags', 'SELECT_STRING', true, 'TASK')
+INSERT INTO property_definitions (id, user_id, display_name, data_type, is_multi_select, specific_entity_type)
+VALUES
+ ('cccccccc-cccc-cccc-cccc-cccccccccc01', 'user1', 'Custom Notes', 'STRING', false, 'TASK'),
+ ('cccccccc-cccc-cccc-cccc-cccccccccc02', 'user1', 'Custom Tags', 'SELECT_STRING', true, 'TASK')
ON CONFLICT (id) DO NOTHING;
-- Property options for Custom Tags