Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

768 Add ViewMessages Intent & SearchCriteria Context #797

Conversation

symphony-jean-michael
Copy link
Contributor

This PR adds the 'ViewMessages' intent.
See initial discussion #768

@netlify
Copy link

netlify bot commented Aug 8, 2022

Deploy Preview for lambent-kulfi-cf51a7 canceled.

Name Link
🔨 Latest commit 41b3384
🔍 Latest deploy log https://app.netlify.com/sites/lambent-kulfi-cf51a7/deploys/636cdb132d5c9200094fd968

@mistryvinay mistryvinay added enhancement New feature or request intents Context Data & Intents Contexts & Intents Discussion Group labels Aug 17, 2022
@mistryvinay mistryvinay added this to the 2.1-candidates milestone Aug 24, 2022
@mistryvinay mistryvinay requested a review from a team August 24, 2022 10:09
@mistryvinay mistryvinay linked an issue Aug 24, 2022 that may be closed by this pull request
| Property | Type | Required | Example Value |
|------------------|-----------------|----------|----------------------|
| `type` | string | Yes | `'fdc3.searchCriteria'` |
| `contexts` | (Instrument&#124;<br>Contact&#124;<br>Organization&#124;<br>string)[] | Yes | <pre>[<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.instrument",<br>&emsp;&emsp;&emsp;&emsp;"id": {<br>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"ticker": "AAPL"<br>&emsp;&emsp;&emsp;&emsp;}<br>&emsp;&emsp;},<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.contact",<br>&emsp;&emsp;&emsp;&emsp;"name":"Jane Doe",<br>&emsp;&emsp;&emsp;&emsp;"id": {<br>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"email": "jane.doe@mail.com"<br>&emsp;&emsp;&emsp;&emsp;}<br>&emsp;&emsp;},<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.organization",<br>&emsp;&emsp;&emsp;&emsp;"name":"Symphony",<br>&emsp;&emsp;},<br>&emsp;&emsp;"#OrderID45788422",<br>]</pre> |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this example need to be revisited? removing the html entities.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mistryvinay
I removed the HTML entities from the example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the HTML entities are there to make it render on the web. Markdown has some shortcomings when it comes to code examples...

Heres what it looks like in github's preview without the HTML entities:
image

and with them:
image

Use the rich preview (the file icon) to see the markdown rendered:
image

We need to have another go at asking FINOS to adjust the netlify config to ensure it builds previews for PRs like this - right now it only builds if it detects changes in the /website directory...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. @kriswest Do you want me to restore the changes (HTML entities)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Managed to track down the preview - still showing state before they were removed:
image

If you merge master into your PR (needs doing anyway) it should refresh so you can see it without at: https://deploy-preview-797--lambent-kulfi-cf51a7.netlify.app/docs/next/context/ref/searchcriteria (once the deploy has run).

From memory docusaurus really struggles with long code lines in tables. Might be worth a check first in case I'm mis-remembering.

Copy link
Contributor

@mistryvinay mistryvinay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think the detail/example may need reworking to remove the html entitites. (docs/context/ref/SearchCriteria.md)

@mistryvinay mistryvinay changed the title Add ViewMessages Intent 768 Add ViewMessages Intent Aug 24, 2022
@kriswest kriswest changed the title 768 Add ViewMessages Intent 768 Add ViewMessages Intent & SearchCriteria Context Sep 1, 2022
Copy link
Contributor

@kriswest kriswest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to discuss this further as I think there are a few ways it could be further clarified/future proofed. See individual comments

---
# `SearchCriteria`

A context type representing a search criteria that can be used to filter and display messages from a chat.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the generic name, type name and structure (an array of context objects), the description should also be generic (but can use chat as an example).

Suggested change
A context type representing a search criteria that can be used to filter and display messages from a chat.
A context type that represents a simple search criterion, based on a list of other context objects, that can be used to search or filter content in an application (such as messages in a chat app).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm tempted to also suggest tweaking the name to acknowledge the simplicity of the criterion (a bag of contexts) in case we want to introduce more complex search types in future (but haven't come to a conclusion on that yet - after all we might expand this one with additional fields instead...).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think an explanation of how multiple contexts in the list should be interpreted (to encourage similar behaviour). Should they be combined with AND or OR?

If variation in behaviour is expected or desirable an enumerated field should be added for that (e.g. combinationLogic: "AND") or the contexts field replaced with separate fields (e.g. contexts: { and: [...], or: [...], not: [...]}).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kriswest I like your idea about using contexts: { and: [...], or: [...], not: [...]}
It's very generic :)
I'll update the PR accordingly.

| Property | Type | Required | Example Value |
|------------------|-----------------|----------|----------------------|
| `type` | string | Yes | `'fdc3.searchCriteria'` |
| `contexts` | (Instrument&#124;<br>Contact&#124;<br>Organization&#124;<br>string)[] | Yes | `[{ type: "fdc3.instrument", id: { ticker: "AAPL" }}, { type: "fdc3.contact", name: "Jane Doe", id: { email: "jane.doe@mail.com" }}, { type: "fdc3.organization", name: "Symphony" }, "#OrderID45788422"]` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend restoring the HTML entities as they make a big difference when rendered (despite looking nuts in the markdown source)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm struggling with the field name as it doesn't accept arbitrary contexts, rather several specific types - one of which isn't actually a context but a string.

Either it needs renaming to criteria or add optional named fields for each type (which allows setting none to reset the filter BTW).

Do you expect more than one contact or instrument to be added? If so those separate fields would also be arrays, otherwise single, optional objects.

Do you think this might extend to additional types in future. That is more likely if the type is generic and used beyond chat. In which case contexts is a valid name, if the string criteria is moved to a separate field.

Copy link
Contributor Author

@symphony-jean-michael symphony-jean-michael Sep 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll rename 'contexts' into 'criteria'.

@kriswest I don't get your point: 'If so those separate fields would also be arrays'

I have in mind to use something like that in case of multiple Contact, Instrument:

criteria: [
        {
            type: "fdc3.contact",
            name: "Jane Doe",
            id: {
                email: "jane.doe@mail.com"
            }
        },
        {
            type: "fdc3.contact",
            name: "Jean Dupont",
            id: {
                email: "jean.dupond@mail.com"
            }
        },
        {
            type: "fdc3.organization",
            name: "Symphony"
        },
        {
            type: "fdc3.instrument",
            id: {
                ticker: "AAPL"
            }
        },
        {
            type: "fdc3.instrument",
            id: {
                ticker: "ABC"
            }
        }
]

So, there is only 1 array accepting any Contact, Intents, et ....
Of course, what is missing here is the AND/OR/NOT criteria ;)

Copy link
Contributor

@kriswest kriswest Sep 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you expect more than one contact or instrument to be added? If so those separate fields would also be arrays, otherwise single, optional objects.

What I meant was, if you separated out the 'contexts' into separate fields for each type, would you be accept just a single contact or an array of contacts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have in mind to use only one array (criteria) and not one field/array per type.
This array could contain objects of different types (like Contact and Organization and Instrument...)
@kriswest Do you agree with this solution? Or would you prefer an array by type?

---
# `ViewMessages`

Search and display a list of messages to the user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Search and display a list of messages to the user.
Search and display a list of messages (for example in a chat application or CRM) to the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I updated the PR.


## Example

Request to display messages for a specific ticker:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Request to display messages for a specific ticker:
Request display of messages relating to a specific `fdc3.instrument` (representing a ticker):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I updated the PR.

fdc3.raiseIntent('ViewMessages', searchCriteria);
```

Request to display messages for a specific **contact**:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Request to display messages for a specific **contact**:
Request display of messages relating to a specific `fdc3.contact`:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I updated the PR.

fdc3.raiseIntent('ViewMessages', searchCriteria);
```

Request to display messages for a specific **organization**:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably redundant. It'd be more succinct to add a line of copy either at the start of the example section or under possible contexts explaining that any appropriate contexts (or combination of contexts!) can be added to the search criteria.

fdc3.raiseIntent('ViewMessages', searchCriteria);
```

Request to display messages with **multiples** criteria:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Request to display messages with **multiples** criteria:
Request display of messages matching _multiple_ criteria:

Again, we need an indication of how the multiple criteria are expected to be combined.

Comment on lines 117 to 120
* [Instrument](../../context/ref/Instrument)
* [Contact](../../context/ref/Contact)
* [Organization](../../context/ref/Organization)
* [SearchCriteria](../../context/ref/SearchCriteria)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* [Instrument](../../context/ref/Instrument)
* [Contact](../../context/ref/Contact)
* [Organization](../../context/ref/Organization)
* [SearchCriteria](../../context/ref/SearchCriteria)
* [SearchCriteria](../../context/ref/SearchCriteria)
* [Instrument](../../context/ref/Instrument)
* [Contact](../../context/ref/Contact)
* [Organization](../../context/ref/Organization)

Might as well promote SearchCriteria to the head of the list as its of most interest here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I updated the order.

@@ -8,10 +8,11 @@ export enum ContextTypes {
Email = 'fdc3.email',
Instrument = 'fdc3.instrument',
InstrumentList = 'fdc3.instrumentList',
Nothing = 'fdc3.nothing',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha, good catch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

@symphony-jean-michael
Copy link
Contributor Author

Hi @kriswest
I updated the PR to take into account your remarks.
For the criteria operators, I did what we discussed yesterday, and I updated the description of SearchCriteria to explain that the operators are not defined in the SearchCriteira, but it is up to the application that receives the Intent to choose and apply the operators. (See https://github.com/finos/FDC3/pull/797/files#diff-10b12f0cd7551554329f046508ee812f15561a1ceb30fdd0b99e5e02005a01f6R26 )
Could you have a second look at the PR please?
Thanks :)

@kriswest
Copy link
Contributor

kriswest commented Sep 5, 2022

Could you have a second look at the PR please?

I haven't yet had a chance for a full review, but as the query fields are restricted so is the use-case. Hence, I still think the type should be scoped for chat. I.e. fdc3.chat.searchCriteria

@kriswest kriswest self-requested a review September 5, 2022 13:03
@symphony-jean-michael
Copy link
Contributor Author

@kriswest You're right, I renamed fdc3.searchCriteria into fdc3.chat.searchCriteria

@mistryvinay
Copy link
Contributor

Including notes from our last meeting (Sep 2022). With recommended changes for this PR.

  • 768 Add ViewMessages Intent & SearchCriteria Context #797
    • Is this a general search criteria, or a specific search criteria for chat? The context specifically limits the criteria and query construction that can be used in a search...
      • Option 1: Make this more flexible to support all search purposes
        • We don't want to define a query for all use-cases at the moment, it would be too large an undertaking
      • Option 2: Refactor it to be chat specific, with a rename to fdc3.chat.searchcriteria
    • Further options for supporting more complex search criteria were discussed
      • E.g. use a Google type search
        • All search clauses are combined with OR
        • Then ranked results are returned based on those OR search criteria values
        • Ranked in order of filter word occurrences
      • Empty search criteria could supported to allow reset of filters (which is a common issue in FDC3 for filters based on context broadcasts)
      • Rename contexts array to criteria to acknowledge that it may contain strings, not just contexts

@symphony-jean-michael
Copy link
Contributor Author

@mistryvinay FYI:

  • "Is this a general search criteria, or a specific search criteria for chat?"
    The Option 2: has been chosen. It has been renamed to fdc3.chat.searchcriteria Done
  • "Further options for supporting more complex search criteria were discussed"
    • "E.g. use a Google type search"
      There is a paragraph in SearchCriteria.md explaining there are no implementation details in the FDC3 standard. It is up to the application that receives the intent to define how it handles the criteria. Done
    • "Empty search criteria could supported to allow reset of filters (which is a common issue in FDC3 for filters based on context broadcasts)"
      I've just added a new line about it in the SearchCriteria.md file. Done
    • "Rename contexts array to criteria to acknowledge that it may contain strings, not just contexts" Done

Copy link
Contributor

@kriswest kriswest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a changelog entry and I think SearchCriteria should be renamed ChatSearchCriteria. Otherwise LGTM

---
# `SearchCriteria`

A context type that represents a simple search criterion, based on a list of other context objects, that can be used to search or filter content in an application (such as messages in a chat app).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A context type that represents a simple search criterion, based on a list of other context objects, that can be used to search or filter content in an application (such as messages in a chat app).
A context type that represents a simple search criterion, based on a list of other context objects, that can be used to search or filter messages in a chat application.

Change description as we're only covering that use case now

@@ -0,0 +1,64 @@
---
id: SearchCriteria
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably rename this ChatMessageSearchCriteria or ChatSearchCriteria as this doesn't cover all types of search and something in the future might.

| Property | Type | Required | Example Value |
|------------------|-----------------|----------|----------------------|
| `type` | string | Yes | `'fdc3.chat.searchCriteria'` |
| `criteria` | (Instrument&#124;<br>Contact&#124;<br>Organization&#124;<br>string)[] | Yes | <pre>[<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.instrument",<br>&emsp;&emsp;&emsp;&emsp;"id": {<br>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"ticker": "AAPL"<br>&emsp;&emsp;&emsp;&emsp;}<br>&emsp;&emsp;},<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.contact",<br>&emsp;&emsp;&emsp;&emsp;"name":"Jane Doe",<br>&emsp;&emsp;&emsp;&emsp;"id": {<br>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"email": "jane.doe@mail.com"<br>&emsp;&emsp;&emsp;&emsp;}<br>&emsp;&emsp;},<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.organization",<br>&emsp;&emsp;&emsp;&emsp;"name":"Symphony",<br>&emsp;&emsp;},<br>&emsp;&emsp;"#OrderID45788422",<br>]</pre> |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| `criteria` | (Instrument&#124;<br>Contact&#124;<br>Organization&#124;<br>string)[] | Yes | <pre>[<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.instrument",<br>&emsp;&emsp;&emsp;&emsp;"id": {<br>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"ticker": "AAPL"<br>&emsp;&emsp;&emsp;&emsp;}<br>&emsp;&emsp;},<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.contact",<br>&emsp;&emsp;&emsp;&emsp;"name":"Jane Doe",<br>&emsp;&emsp;&emsp;&emsp;"id": {<br>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"email": "jane.doe@mail.com"<br>&emsp;&emsp;&emsp;&emsp;}<br>&emsp;&emsp;},<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.organization",<br>&emsp;&emsp;&emsp;&emsp;"name":"Symphony",<br>&emsp;&emsp;},<br>&emsp;&emsp;"#OrderID45788422",<br>]</pre> |
| `criteria` | (Instrument &#124;<br>Contact &#124;<br>Organization &#124;<br>string)[] | Yes | <pre>[<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.instrument",<br>&emsp;&emsp;&emsp;&emsp;"id": {<br>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"ticker": "AAPL"<br>&emsp;&emsp;&emsp;&emsp;}<br>&emsp;&emsp;},<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.contact",<br>&emsp;&emsp;&emsp;&emsp;"name":"Jane Doe",<br>&emsp;&emsp;&emsp;&emsp;"id": {<br>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"email": "jane.doe@mail.com"<br>&emsp;&emsp;&emsp;&emsp;}<br>&emsp;&emsp;},<br>&emsp;&emsp;{<br>&emsp;&emsp;&emsp;&emsp;"type": "fdc3.organization",<br>&emsp;&emsp;&emsp;&emsp;"name":"Symphony",<br>&emsp;&emsp;},<br>&emsp;&emsp;"#OrderID45788422",<br>]</pre> |

@@ -159,6 +159,7 @@ The following are standard FDC3 context types:

* [`fdc3.chart`](ref/Chart) ([schema](/schemas/next/chart.schema.json))
* [`fdc3.chat.initSettings`](ref/ChatInitSettings) ([schema](/schemas/next/chatInitSettings.schema.json))
* [`fdc3.chat.searchCriteria`](ref/SearchCriteria) ([schema](/schemas/next/searchCriteria.schema.json))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If renamed correct links

Organization = 'fdc3.organization',
Portfolio = 'fdc3.portfolio',
Position = 'fdc3.position',
Nothing = 'fdc3.nothing',
SearchCriteria = 'fdc3.chat.searchCriteria',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct this if renamed

@@ -187,6 +187,11 @@ export interface Position {
name?: string;
}

export interface SearchCriteria {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct this if renamed

@@ -13,6 +13,7 @@
"Organization": ["https://fdc3.finos.org/schemas/next/organization.schema.json"],
"Portfolio": ["https://fdc3.finos.org/schemas/next/portfolio.schema.json"],
"Position": ["https://fdc3.finos.org/schemas/next/position.schema.json"],
"SearchCriteria": ["https://fdc3.finos.org/schemas/next/searchCriteria.schema.json"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct this if renamed

}
}
},
"required": ["type", "criteria"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"required": ["type", "criteria"]
"required": ["criteria"]

type is already required by context schema

@@ -73,6 +74,7 @@
"context/ref/Organization",
"context/ref/Portfolio",
"context/ref/Position",
"context/ref/SearchCriteria",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct this if renamed

}
}
},
"required": ["type", "criteria"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"required": ["type", "criteria"]
"required": ["criteria"]

Already required by context schema

@symphony-jean-michael
Copy link
Contributor Author

Hi @kriswest
I've updated the PR accordingly to your remarks. Can you have a second look, please?
Thanks

@symphony-jean-michael
Copy link
Contributor Author

FYI, this PR is included in new one #882

@kriswest kriswest modified the milestones: 2.1-candidates, 2.1 Apr 27, 2023
@kriswest kriswest removed this from the 2.1 milestone Jul 25, 2023
@bingenito bingenito mentioned this pull request Nov 6, 2023
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Context Data & Intents Contexts & Intents Discussion Group enhancement New feature or request intents
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'View Messages' intent
3 participants