-
Notifications
You must be signed in to change notification settings - Fork 251
/
xep0055.ts
67 lines (61 loc) · 1.87 KB
/
xep0055.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// ====================================================================
// XEP-0055: Jabber Search
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0055.html
// Version: 1.3 (2009-09-15)
// ====================================================================
import { JID } from '../JID';
import { addAlias, childText, DefinitionOptions, JIDAttribute } from '../jxt';
import { NS_DATAFORM, NS_RSM, NS_SEARCH } from '../Namespaces';
import { DataForm, Paging } from './';
declare module './' {
export interface IQPayload {
search?: Search;
}
}
export interface Search {
instructions?: string;
givenName?: string;
familyName?: string;
nick?: string;
email?: string;
items?: SearchResultItem[];
form?: DataForm;
paging?: Paging;
}
export interface SearchResultItem {
jid?: JID;
givenName?: string;
familyName?: string;
nick?: string;
email?: string;
}
const Protocol: DefinitionOptions[] = [
addAlias(NS_DATAFORM, 'x', ['iq.search.form']),
addAlias(NS_RSM, 'set', ['iq.search.paging']),
{
element: 'query',
fields: {
email: childText(null, 'email'),
familyName: childText(null, 'last'),
givenName: childText(null, 'first'),
instructions: childText(null, 'instructions'),
nick: childText(null, 'nick')
},
namespace: NS_SEARCH,
path: 'iq.search'
},
{
aliases: [{ path: 'iq.search.items', multiple: true }],
element: 'item',
fields: {
email: childText(null, 'email'),
familyName: childText(null, 'last'),
givenName: childText(null, 'first'),
jid: JIDAttribute('jid'),
nick: childText(null, 'nick')
},
namespace: NS_SEARCH
}
];
export default Protocol;