feat: attributes v2 api (#16461)

* WIP

* services

* controllers + outputs

* unit tests for repositories

* use hard coded enum type

* use prisma import

* remove redunant input file

* fix packagejson

* rename to spec files

* fix typo in option service file name

* move membership call to org membership service

* move logic to service > repo

* fix membership query

* attribute controller e2e spec

* add options e2e test

* add jest watch for e2e

---------

Co-authored-by: Morgan Vernay <[email protected]>
This commit is contained in:
sean-brydonandMorgan Vernay authored and GitHub committed 2024-09-05 10:15:12 +02:00
1 parent 36e79bf69c
commit 2de33fe1bf
33 files changed
+2554 -4

No files matched your search

+962
View File
@@ -2285,6 +2285,492 @@
]
}
},
"/v2/organizations/{orgId}/attributes": {
"get": {
"operationId": "OrganizationsAttributesController_getOrganizationAttributes",
"parameters": [
{
"name": "orgId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
},
{
"name": "take",
"required": false,
"in": "query",
"description": "The number of items to return",
"example": 10,
"schema": {
"type": "number"
}
},
{
"name": "skip",
"required": false,
"in": "query",
"description": "The number of items to skip",
"example": 0,
"schema": {
"type": "number"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetOrganizationAttributesOutput"
}
}
}
}
}
},
"post": {
"operationId": "OrganizationsAttributesController_createOrganizationAttribute",
"parameters": [
{
"name": "orgId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateOrganizationAttributeInput"
}
}
}
},
"responses": {
"201": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateOrganizationAttributesOutput"
}
}
}
}
}
}
},
"/v2/organizations/{orgId}/attributes/{attributeId}": {
"get": {
"operationId": "OrganizationsAttributesController_getOrganizationAttribute",
"parameters": [
{
"name": "orgId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
},
{
"name": "attributeId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetSingleAttributeOutput"
}
}
}
}
}
},
"patch": {
"operationId": "OrganizationsAttributesController_updateOrganizationAttribute",
"parameters": [
{
"name": "orgId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
},
{
"name": "attributeId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateOrganizationAttributeInput"
}
}
}
},
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateOrganizationAttributesOutput"
}
}
}
}
}
},
"delete": {
"operationId": "OrganizationsAttributesController_deleteOrganizationAttribute",
"parameters": [
{
"name": "orgId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
},
{
"name": "attributeId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DeleteOrganizationAttributesOutput"
}
}
}
}
}
}
},
"/v2/organizations/{orgId}/attributes/{attributeId}/options": {
"post": {
"operationId": "OrganizationsOptionsAttributesController_createOrganizationAttributeOption",
"parameters": [
{
"name": "orgId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
},
{
"name": "attributeId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateOrganizationAttributeOptionInput"
}
}
}
},
"responses": {
"201": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateAttributeOptionOutput"
}
}
}
}
}
},
"get": {
"operationId": "OrganizationsOptionsAttributesController_getOrganizationAttributeOptions",
"parameters": [
{
"name": "orgId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
},
{
"name": "attributeId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetAllAttributeOptionOutput"
}
}
}
}
}
}
},
"/v2/organizations/{orgId}/attributes/{attributeId}/options/{optionId}": {
"delete": {
"operationId": "OrganizationsOptionsAttributesController_deleteOrganizationAttributeOption",
"parameters": [
{
"name": "orgId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
},
{
"name": "attributeId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
},
{
"name": "optionId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DeleteAttributeOptionOutput"
}
}
}
}
}
},
"patch": {
"operationId": "OrganizationsOptionsAttributesController_updateOrganizationAttributeOption",
"parameters": [
{
"name": "orgId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
},
{
"name": "attributeId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
},
{
"name": "optionId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateOrganizationAttributeOptionInput"
}
}
}
},
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UpdateAttributeOptionOutput"
}
}
}
}
}
}
},
"/v2/organizations/{orgId}/attributes/options/{userId}": {
"post": {
"operationId": "OrganizationsOptionsAttributesController_assignOrganizationAttributeOptionToUser",
"parameters": [
{
"name": "orgId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
},
{
"name": "userId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AssignOrganizationAttributeOptionToUserInput"
}
}
}
},
"responses": {
"201": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AssignOptionUserOutput"
}
}
}
}
}
},
"get": {
"operationId": "OrganizationsOptionsAttributesController_getOrganizationAttributeOptionsForUser",
"parameters": [
{
"name": "orgId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
},
{
"name": "userId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetOptionUserOutput"
}
}
}
}
}
}
},
"/v2/organizations/{orgId}/attributes/options/{userId}/{attributeOptionId}": {
"delete": {
"operationId": "OrganizationsOptionsAttributesController_unassignOrganizationAttributeOptionFromUser",
"parameters": [
{
"name": "orgId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
},
{
"name": "userId",
"required": true,
"in": "path",
"schema": {
"type": "number"
}
},
{
"name": "attributeOptionId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UnassignOptionUserOutput"
}
}
}
}
}
}
},
"/v2/organizations/{orgId}/webhooks": {
"get": {
"operationId": "OrganizationsWebhooksController_getAllOrganizationWebhooks",
@@ -7578,6 +8064,482 @@
"userId"
]
},
"Attribute": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The ID of the attribute",
"example": "attr_123"
},
"teamId": {
"type": "number",
"description": "The team ID associated with the attribute",
"example": 1
},
"type": {
"type": "string",
"description": "The type of the attribute",
"enum": [
"TEXT",
"NUMBER",
"SINGLE_SELECT",
"MULTI_SELECT"
]
},
"name": {
"type": "string",
"description": "The name of the attribute",
"example": "Attribute Name"
},
"slug": {
"type": "string",
"description": "The slug of the attribute",
"example": "attribute-name"
},
"enabled": {
"type": "boolean",
"description": "Whether the attribute is enabled and displayed on their profile",
"example": true
},
"usersCanEditRelation": {
"type": "boolean",
"description": "Whether users can edit the relation",
"example": true
}
},
"required": [
"id",
"teamId",
"type",
"name",
"slug",
"enabled"
]
},
"GetOrganizationAttributesOutput": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "success",
"enum": [
"success",
"error"
]
},
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Attribute"
}
}
},
"required": [
"status",
"data"
]
},
"GetSingleAttributeOutput": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "success",
"enum": [
"success",
"error"
]
},
"data": {
"nullable": true,
"allOf": [
{
"$ref": "#/components/schemas/Attribute"
}
]
}
},
"required": [
"status",
"data"
]
},
"CreateOrganizationAttributeOptionInput": {
"type": "object",
"properties": {
"value": {
"type": "string"
},
"slug": {
"type": "string"
}
},
"required": [
"value",
"slug"
]
},
"CreateOrganizationAttributeInput": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"slug": {
"type": "string"
},
"type": {
"type": "object"
},
"options": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CreateOrganizationAttributeOptionInput"
}
},
"enabled": {
"type": "boolean"
}
},
"required": [
"name",
"slug",
"type",
"options"
]
},
"CreateOrganizationAttributesOutput": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "success",
"enum": [
"success",
"error"
]
},
"data": {
"$ref": "#/components/schemas/Attribute"
}
},
"required": [
"status",
"data"
]
},
"UpdateOrganizationAttributeInput": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"slug": {
"type": "string"
},
"type": {
"type": "object"
},
"enabled": {
"type": "boolean"
}
}
},
"UpdateOrganizationAttributesOutput": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "success",
"enum": [
"success",
"error"
]
},
"data": {
"$ref": "#/components/schemas/Attribute"
}
},
"required": [
"status",
"data"
]
},
"DeleteOrganizationAttributesOutput": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "success",
"enum": [
"success",
"error"
]
},
"data": {
"$ref": "#/components/schemas/Attribute"
}
},
"required": [
"status",
"data"
]
},
"OptionOutput": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The ID of the option",
"example": "attr_option_id"
},
"attributeId": {
"type": "string",
"description": "The ID of the attribute",
"example": "attr_id"
},
"value": {
"type": "string",
"description": "The value of the option",
"example": "option_value"
},
"slug": {
"type": "string",
"description": "The slug of the option",
"example": "option-slug"
}
},
"required": [
"id",
"attributeId",
"value",
"slug"
]
},
"CreateAttributeOptionOutput": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "success",
"enum": [
"success",
"error"
]
},
"data": {
"$ref": "#/components/schemas/OptionOutput"
}
},
"required": [
"status",
"data"
]
},
"DeleteAttributeOptionOutput": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "success",
"enum": [
"success",
"error"
]
},
"data": {
"$ref": "#/components/schemas/OptionOutput"
}
},
"required": [
"status",
"data"
]
},
"UpdateOrganizationAttributeOptionInput": {
"type": "object",
"properties": {
"value": {
"type": "string"
},
"slug": {
"type": "string"
}
}
},
"UpdateAttributeOptionOutput": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "success",
"enum": [
"success",
"error"
]
},
"data": {
"$ref": "#/components/schemas/OptionOutput"
}
},
"required": [
"status",
"data"
]
},
"GetAllAttributeOptionOutput": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "success",
"enum": [
"success",
"error"
]
},
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/OptionOutput"
}
}
},
"required": [
"status",
"data"
]
},
"AssignOrganizationAttributeOptionToUserInput": {
"type": "object",
"properties": {
"value": {
"type": "string"
},
"attributeOptionId": {
"type": "string"
},
"attributeId": {
"type": "string"
}
},
"required": [
"attributeId"
]
},
"AssignOptionUserOutputData": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The ID of the option assigned to the user"
},
"memberId": {
"type": "number",
"description": "The ID form the org membership for the user"
},
"attributeOptionId": {
"type": "string",
"description": "The value of the option"
}
},
"required": [
"id",
"memberId",
"attributeOptionId"
]
},
"AssignOptionUserOutput": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "success",
"enum": [
"success",
"error"
]
},
"data": {
"$ref": "#/components/schemas/AssignOptionUserOutputData"
}
},
"required": [
"status",
"data"
]
},
"UnassignOptionUserOutput": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "success",
"enum": [
"success",
"error"
]
},
"data": {
"$ref": "#/components/schemas/AssignOptionUserOutputData"
}
},
"required": [
"status",
"data"
]
},
"GetOptionUserOutputData": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The ID of the option assigned to the user"
},
"attributeId": {
"type": "string",
"description": "The ID of the attribute"
},
"value": {
"type": "string",
"description": "The value of the option"
},
"slug": {
"type": "string",
"description": "The slug of the option"
}
},
"required": [
"id",
"attributeId",
"value",
"slug"
]
},
"GetOptionUserOutput": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "success",
"enum": [
"success",
"error"
]
},
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/GetOptionUserOutputData"
}
}
},
"required": [
"status",
"data"
]
},
"TeamWebhookOutputDto": {
"type": "object",
"properties": {