diff --git a/NEWS.md b/NEWS.md index 31becf27..03724d2a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,7 @@ ### Features * Use static value for note types limit ([MODNOTES-274](https://folio-org.atlassian.net/browse/MODNOTES-274)) * Update an error message for note types limit reached ([MODNOTES-277](https://folio-org.atlassian.net/browse/MODNOTES-277)) +* Add support for FQM entity type generation based on the mod-notes data schema ([MODNOTES-294](https://folio-org.atlassian.net/browse/MODNOTES-294)) ### Bug fixes * Description ([ISSUE](https://folio-org.atlassian.net/browse/ISSUE)) diff --git a/fqm-config.toml b/fqm-config.toml new file mode 100644 index 00000000..e3a3373c --- /dev/null +++ b/fqm-config.toml @@ -0,0 +1,69 @@ +[metadata] +team = "spitfire" +domain = "other" +module = "mod-notes" + +[[sources]] +name = "note" +table = "note" + +[[sources]] +name = "link" +table = "link" + +[[sources]] +name = "note_link" +table = "note_link" + +[[sources]] +name = "note_type" +table = "type" + +[[entityTypes]] +name = "note" +source = "note" +schema = "src/main/resources/fqm/schemas/note.yaml" +permissions = ["notes.collection.get"] +sort = ["id", "ASC"] +includeJsonbField = false +fieldExclusions = ["type", "links"] + +[[entityTypes]] +name = "link" +source = "link" +schema = "src/main/resources/fqm/schemas/link.yaml" +permissions = ["note.links.collection.get"] +sort = ["id", "ASC"] +includeJsonbField = false + +[[entityTypes]] +name = "note_link" +source = "note_link" +schema = "src/main/resources/fqm/schemas/noteLink.yaml" +permissions = ["note.links.collection.get"] +sort = ["note_id", "ASC"] +includeJsonbField = false + +[[entityTypes]] +name = "note_type" +source = "note_type" +schema = "src/main/resources/fqm/schemas/noteType.yaml" +permissions = ["note.types.collection.get"] +sort = ["id", "ASC"] +includeJsonbField = false + +[entityTypes.fieldOverrides.metadata_created_date] +x-fqm-visible-by-default = false +x-fqm-essential = false + +[entityTypes.fieldOverrides.metadata_created_by_user_id] +x-fqm-visible-by-default = false +x-fqm-essential = false + +[entityTypes.fieldOverrides.metadata_updated_date] +x-fqm-visible-by-default = false +x-fqm-essential = false + +[entityTypes.fieldOverrides.metadata_updated_by_user_id] +x-fqm-visible-by-default = false +x-fqm-essential = false diff --git a/src/main/resources/fqm/schemas/link.yaml b/src/main/resources/fqm/schemas/link.yaml new file mode 100644 index 00000000..6cacc7ad --- /dev/null +++ b/src/main/resources/fqm/schemas/link.yaml @@ -0,0 +1,27 @@ +# This wrapper defines the FQM-only link shape directly so the runtime schema can +# stay focused on the API object exposed by mod-notes. +type: object +title: Note link +description: Link record for FQM +properties: + linkId: + $ref: '../../swagger.api/schemas/common.yaml#/uuid' + description: UUID primary key of the link row; used by note_link.link_id + x-fqm-value-getter: ${source}.id + x-fqm-is-id-column: true + x-fqm-visibility: "hidden" + x-fqm-visible-by-default: true + x-fqm-essential: true + x-fqm-joins-to: + - targetModule: mod-notes + targetEntity: link + targetField: link_id + type: equality-cast-uuid + objectId: + $ref: '../../swagger.api/schemas/link.yaml#/link/properties/id' + type: + $ref: '../../swagger.api/schemas/link.yaml#/link/properties/type' +required: + - linkId + - objectId + - type diff --git a/src/main/resources/fqm/schemas/note.yaml b/src/main/resources/fqm/schemas/note.yaml new file mode 100644 index 00000000..9d648382 --- /dev/null +++ b/src/main/resources/fqm/schemas/note.yaml @@ -0,0 +1,3 @@ +# fqm-tools only accepts a file path in `schema = ...`; it cannot target a nested +# schema fragment there, so this wrapper bridges to the real runtime schema. +$ref: '../../swagger.api/schemas/note.yaml#/note' diff --git a/src/main/resources/fqm/schemas/noteLink.yaml b/src/main/resources/fqm/schemas/noteLink.yaml new file mode 100644 index 00000000..b3b34fab --- /dev/null +++ b/src/main/resources/fqm/schemas/noteLink.yaml @@ -0,0 +1,35 @@ +# Unlike the other wrappers, note_link has no runtime schema to point at, so this +# file defines the FQM-only association shape directly. +type: object +title: Note-link association +description: Association between a note and a link record +properties: + noteId: + $ref: '../../swagger.api/schemas/common.yaml#/uuid' + description: UUID of the associated note + x-fqm-value-getter: ${source}.note_id + x-fqm-is-id-column: true # There are 2 ID columns here, matching the table's primary key. + x-fqm-visibility: "hidden" + x-fqm-essential: true + x-fqm-visible-by-default: false + x-fqm-joins-to: + - targetModule: mod-notes + targetEntity: note + targetField: id + type: equality-cast-uuid + linkId: + $ref: '../../swagger.api/schemas/common.yaml#/uuid' + description: UUID of the associated link + x-fqm-value-getter: ${source}.link_id + x-fqm-is-id-column: true # There are 2 ID columns here, matching the table's primary key. + x-fqm-visibility: "hidden" + x-fqm-essential: true + x-fqm-visible-by-default: false + x-fqm-joins-to: + - targetModule: mod-notes + targetEntity: link + targetField: link_id + type: equality-cast-uuid +required: + - noteId + - linkId diff --git a/src/main/resources/fqm/schemas/noteType.yaml b/src/main/resources/fqm/schemas/noteType.yaml new file mode 100644 index 00000000..7c843f01 --- /dev/null +++ b/src/main/resources/fqm/schemas/noteType.yaml @@ -0,0 +1,3 @@ +# fqm-tools only accepts a file path in `schema = ...`; it cannot target a nested +# schema fragment there, so this wrapper bridges to the real runtime schema. +$ref: '../../swagger.api/schemas/noteType.yaml#/noteType' diff --git a/src/main/resources/swagger.api/schemas/common.yaml b/src/main/resources/swagger.api/schemas/common.yaml index 9e21ea64..ebedf7f8 100644 --- a/src/main/resources/swagger.api/schemas/common.yaml +++ b/src/main/resources/swagger.api/schemas/common.yaml @@ -11,28 +11,66 @@ metadata: type: string format: date-time description: Date and time when the record was created + x-fqm-value-getter: to_char(${source}.created_date, 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"') + x-fqm-visibility: "all" + x-fqm-visible-by-default: true + x-fqm-essential: true createdByUserId: $ref: '#/uuid' description: ID of the user who created the record + x-fqm-value-getter: ${source}.created_by + x-fqm-visibility: "all" + x-fqm-visible-by-default: false + x-fqm-essential: true + x-fqm-joins-to-raw: + - targetId: bb058933-cd06-4539-bd3a-6f248ff98ee2 + targetField: id + direction: left + type: equality-cast-uuid + - targetId: f2615ea6-450b-425d-804d-6a495afd9308 + targetField: id + direction: left + type: equality-cast-uuid createdByUsername: type: string description: Username of the user who created the record (when available) + x-fqm-ignore: true createdBy: $ref: '#/userInfo' description: Additional information of the user who created the record (when available) + x-fqm-ignore: true updatedDate: type: string format: date-time description: Date and time when the record was last updated + x-fqm-value-getter: to_char(${source}.updated_date, 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"') + x-fqm-visibility: "all" + x-fqm-visible-by-default: false + x-fqm-essential: true updatedByUserId: $ref: '#/uuid' description: ID of the user who last updated the record + x-fqm-value-getter: ${source}.updated_by + x-fqm-visibility: "all" + x-fqm-visible-by-default: false + x-fqm-essential: true + x-fqm-joins-to-raw: + - targetId: bb058933-cd06-4539-bd3a-6f248ff98ee2 + targetField: id + direction: left + type: equality-cast-uuid + - targetId: f2615ea6-450b-425d-804d-6a495afd9308 + targetField: id + direction: left + type: equality-cast-uuid updatedByUsername: type: string description: Username of the user who updated the record (when available) + x-fqm-ignore: true updatedBy: $ref: '#/userInfo' description: Additional information of the user who updated the record (when available) + x-fqm-ignore: true required: - createdDate diff --git a/src/main/resources/swagger.api/schemas/link.yaml b/src/main/resources/swagger.api/schemas/link.yaml index 988157b1..29fca3dc 100644 --- a/src/main/resources/swagger.api/schemas/link.yaml +++ b/src/main/resources/swagger.api/schemas/link.yaml @@ -6,9 +6,25 @@ link: id: type: string description: Id of object linked to note + x-fqm-value-getter: ${source}.object_id + x-fqm-is-id-column: false # Despite the name, this is not the unique ID for the link record. + x-fqm-visibility: "hidden" + x-fqm-essential: true + x-fqm-joins-to-raw: + - targetId: bb058933-cd06-4539-bd3a-6f248ff98ee2 + targetField: id + direction: left + type: equality-cast-uuid + - targetId: f2615ea6-450b-425d-804d-6a495afd9308 + targetField: id + direction: left + type: equality-cast-uuid type: type: string description: Type of object linked to note + x-fqm-value-getter: ${source}.object_type + x-fqm-visibility: "hidden" + x-fqm-essential: true required: - id - type diff --git a/src/main/resources/swagger.api/schemas/note.yaml b/src/main/resources/swagger.api/schemas/note.yaml index 154cad85..0635bc8c 100644 --- a/src/main/resources/swagger.api/schemas/note.yaml +++ b/src/main/resources/swagger.api/schemas/note.yaml @@ -5,27 +5,58 @@ note: id: $ref: 'common.yaml#/uuid' description: Unique generated identifier for the note + x-fqm-value-getter: ${source}.id + x-fqm-filter-value-getter: ${source}.id + x-fqm-visibility: "all" + x-fqm-visible-by-default: false + x-fqm-essential: true typeId: $ref: 'common.yaml#/uuid' description: Type id of note + x-fqm-value-getter: ${source}.type_id + x-fqm-filter-value-getter: ${source}.type_id + x-fqm-visibility: "hidden" + x-fqm-essential: true + x-fqm-joins-to: + - targetModule: mod-notes + targetEntity: note_type + targetField: id + type: equality-cast-uuid type: type: string description: Type of note (configured in settings) title: type: string description: Note title + x-fqm-value-getter: ${source}.title + x-fqm-visibility: "all" + x-fqm-visible-by-default: true + x-fqm-essential: true domain: type: string description: Domain associated with this note + x-fqm-value-getter: ${source}.domain + x-fqm-visibility: "all" + x-fqm-visible-by-default: true + x-fqm-essential: true content: type: string description: Content of the note + x-fqm-value-getter: ${source}.content + x-fqm-visibility: "all" + x-fqm-essential: true popUpOnCheckOut: type: boolean description: Flag that specify need of pop-up on check-out app + x-fqm-value-getter: ${source}.pop_up_on_check_out + x-fqm-visibility: "all" + x-fqm-essential: true popUpOnUser: type: boolean description: Flag that specify need of pop-up on users app + x-fqm-value-getter: ${source}.pop_up_on_user + x-fqm-visibility: "all" + x-fqm-essential: true links: type: array description: Collection of links to associated objects diff --git a/src/main/resources/swagger.api/schemas/noteType.yaml b/src/main/resources/swagger.api/schemas/noteType.yaml index b061a16e..c909a370 100644 --- a/src/main/resources/swagger.api/schemas/noteType.yaml +++ b/src/main/resources/swagger.api/schemas/noteType.yaml @@ -6,14 +6,30 @@ noteType: id: $ref: 'common.yaml#/uuid' description: A UUID identifying this note type + x-fqm-value-getter: ${source}.id + x-fqm-visibility: "hidden" + x-fqm-essential: true name: type: string description: The unique name of this type maxLength: 255 + x-fqm-value-getter: ${source}.name + x-fqm-visibility: "all" + x-fqm-essential: true + x-fqm-id-column-name: id + x-fqm-source: + entityTypeId: 5cba8da3-3203-59a4-ad79-f91401850d9f + columnName: name + x-fqm-value-source-api: + path: note-types + valueJsonPath: $.noteTypes.*.id + labelJsonPath: $.noteTypes.*.name + x-fqm-visible-by-default: true usage: type: object readOnly: true description: Type usage statistics + x-fqm-ignore: true properties: isAssigned: type: boolean diff --git a/translations/mod-notes/en.json b/translations/mod-notes/en.json new file mode 100644 index 00000000..d2bb3318 --- /dev/null +++ b/translations/mod-notes/en.json @@ -0,0 +1,32 @@ +{ + "fqm.entityType.note": "Note", + "fqm.entityType.note._description": "Notes stored in mod-notes.", + "fqm.entityType.note.id": "Note UUID", + "fqm.entityType.note.type_id": "Note type UUID", + "fqm.entityType.note.title": "Title", + "fqm.entityType.note.domain": "Domain", + "fqm.entityType.note.content": "Content", + "fqm.entityType.note.pop_up_on_check_out": "Show pop-up on checkout", + "fqm.entityType.note.pop_up_on_user": "Show pop-up on user", + "fqm.entityType.note.metadata_created_date": "Created at", + "fqm.entityType.note.metadata_created_by_user_id": "Created by user UUID", + "fqm.entityType.note.metadata_updated_date": "Updated at", + "fqm.entityType.note.metadata_updated_by_user_id": "Updated by user UUID", + "fqm.entityType.link": "Link", + "fqm.entityType.link._description": "Link records used by notes.", + "fqm.entityType.link.link_id": "Link UUID", + "fqm.entityType.link.object_id": "Linked record ID", + "fqm.entityType.link.type": "Linked record type", + "fqm.entityType.note_link": "Note link", + "fqm.entityType.note_link._description": "Relationships between notes and link records.", + "fqm.entityType.note_link.note_id": "Note UUID", + "fqm.entityType.note_link.link_id": "Link UUID", + "fqm.entityType.note_type": "Note type", + "fqm.entityType.note_type._description": "Configured note types.", + "fqm.entityType.note_type.id": "Note type UUID", + "fqm.entityType.note_type.name": "Name", + "fqm.entityType.note_type.metadata_created_date": "Created at", + "fqm.entityType.note_type.metadata_created_by_user_id": "Created by user UUID", + "fqm.entityType.note_type.metadata_updated_date": "Updated at", + "fqm.entityType.note_type.metadata_updated_by_user_id": "Updated by user UUID" +}