mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-12-22 16:35:52 -05:00
Add query mechanisms
This commit is contained in:
parent
9694a3e37d
commit
694658ca46
38
101.md
38
101.md
|
@ -28,13 +28,12 @@ Event `30168` describes a form as a parametrized replaceable event, with `field`
|
|||
|
||||
The different tags used to detail the form are described as:
|
||||
|
||||
| Tags | Description |
|
||||
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| d | The unique identifier of a form, for a user |
|
||||
| name | A text serving as the name of the form |
|
||||
| settings | An optional global config for the form. |
|
||||
| field | Contains the following values<table><tr><th>index</th><th>name</th><th>description</th></tr><tbody><tr><td>1</td><td>FieldId</td><td>an id that uniqely identifies a field in the forn</td></tr><tr><td>2</td><td>input-type</td><td>A field that describes the type of value that can be expected as a response to this field, values can be: `text`, `option` or `label`</td></tr><tr><td>3</td><td>label</td><td>A label for the field</td></tr><tr><td>4</td><td>options</td> <td>Only used for input-type option, is a Json stringified array of option Tags. |
|
||||
| Option Tags | Option Tags are defined as: [`<OptionId`>, <`label`>, `<optional config>`], optionId can be any alphanumeric string </td> </tr><tr><td>5</td><td>fieldSettings</td><td>An optional JSON stringified object that contains settings specific to the field, for example `renderElement`, a setting which indicates what UI element to render to the client </td></tr> |
|
||||
| Tags | Description |
|
||||
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| d | The unique identifier of a form, for a user |
|
||||
| name | A text serving as the name of the form |
|
||||
| settings | An optional global config for the form. |
|
||||
| field | Contains the following values<table><tr><th>index</th><th>name</th><th>description</th></tr><tbody><tr><td>1</td><td>FieldId</td><td>an id that uniqely identifies a field in the forn</td></tr><tr><td>2</td><td>input-type</td><td>A field that describes the type of value that can be expected as a response to this field, values can be: `text`, `option` or `label`</td></tr><tr><td>3</td><td>label</td><td>A label for the field</td></tr><tr><td>4</td><td>options</td> <td>Only used for input-type option, is a Json stringified array of option Tags.</tr><tr></td><td> - </td> <td> Option Tags </td> <td>Option Tags are defined as: [`<OptionId`>, <`label`>, `<optional config>`], optionId can be any alphanumeric string </td> </tr><tr><td>5</td><td>fieldSettings</td><td>An optional JSON stringified object that contains settings specific to the field, for example `renderElement`, a setting which indicates what UI element to render to the client </td></tr> |
|
||||
|
||||
</tbody></table>
|
||||
|
||||
|
@ -71,7 +70,8 @@ for option fields, the response is the id of the option selected. In case of mul
|
|||
"kind": 30169,
|
||||
"content": "",
|
||||
"tags": [
|
||||
["a", "30168:<pubkey of the author>:<form identifier>"],
|
||||
["d", "<pubkey of the form author>:<formId>"],
|
||||
["a", "30168:<pubkey of the form author>:<formId>"],
|
||||
[
|
||||
"response",
|
||||
"<FieldId>",
|
||||
|
@ -145,3 +145,25 @@ let encyptedKey = nip44.v2.encrypt(bytesToHex(signingKey), conversationKey);
|
|||
|
||||
The rest of the mechanism remains same as in public forms editable by a group except that the
|
||||
form fields should be placed in the `.content` key, encrypted by a `view-key`, which is shared in the 3rd index of the key tag for the viewers.
|
||||
|
||||
## Querying Form Template & Responses
|
||||
|
||||
form template maybe filtered using the form author's pubkey and the d-tag as follows
|
||||
|
||||
```js
|
||||
const filter = {
|
||||
kinds: [30168],
|
||||
authors: [formIdPubkey],
|
||||
"#d": [formIdentifier],
|
||||
};
|
||||
```
|
||||
|
||||
Responses can be queried using the a-tag, and an optional authors tag depending the visibility of the form, for example
|
||||
|
||||
```js
|
||||
const filter: Filter = {
|
||||
kinds: [30169],
|
||||
"#a": [`30168:${pubKey}:${formId}`],
|
||||
};
|
||||
if (allowedPubkeys) filter.authors = allowedPubkeys;
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue
Block a user