Skip to content
This repository has been archived by the owner on May 3, 2020. It is now read-only.

Commit

Permalink
add index definition schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Abbott committed Oct 27, 2017
1 parent 1d2448a commit 6005baf
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 7 deletions.
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
"**/.git": true,
"**/.DS_Store": true,
".vscode-test": true
}
},
"json.schemas": [
{
"fileMatch": ["*.indexes.json"],
"url": "./syntaxes/index.schema.json"
}
]
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.3.0
- Add [JSON Schema](https://code.visualstudio.com/docs/languages/json#_intellisense-validation) for [Index Definitions](https://cloud.google.com/firestore/docs/reference/rest/v1beta1/projects.databases.indexes) (enables completions and hovers).
- [#8](https://github.com/toba/vsfire/issues/8)
Fix access modifier highlighting if last element on line.

# 1.2.0
- [#4](https://github.com/toba/vsfire/issues/4)
Initial hover support.
Expand Down
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@
[![Installs](https://vsmarketplacebadge.apphb.com/installs/toba.vsfire.svg)](https://marketplace.visualstudio.com/items?itemName=toba.vsfire)
[![David](https://david-dm.org/toba/vsfire.svg)](https://david-dm.org/toba/vsfire)

# Firestore Security Rules
Syntax highlighting, code completions and hover help for new [Firestore security rules](https://cloud.google.com/firestore/docs/reference/security/). Priority for [additional language features](https://code.visualstudio.com/docs/extensionAPI/language-support) ordered by the likelihood I'll get to them:
# Firestore Security Rules and Indexes
Syntax highlighting, code completions and hover help for new [Firestore security rules](https://cloud.google.com/firestore/docs/reference/security/) and [index definitions](https://cloud.google.com/firestore/docs/reference/rest/v1beta1/projects.databases.indexes). The priority for [additional rules language features](https://code.visualstudio.com/docs/extensionAPI/language-support) in roughly the order I'll get to them, if ever, is …

- [x] Syntax Highlighting
- [x] Code Completions
- [x] Hover Definitions
- [ ] [JSON Schema](https://code.visualstudio.com/docs/languages/json#_intellisense-validation) for [Index Definitions](https://firebase.google.com/docs/firestore/query-data/indexing)
- [x] [Code Completions](#code-completions)
- [x] [Hover Definitions](#hover-definitions)
- [ ] Snippets
- [ ] Signature Helpers
- [ ] Incremental Formatting
- [ ] Rule validation (moonshot)

![Basic example](./images/completion.gif)
### Rules

![rules completions](./images/rules-completions.gif)

![rules hovers](./images/rules-hovers.gif)

### Index Definitions
![index completions](./images/index-completions.gif)

![index hovers](./images/index-hovers.gif)

# Status

Expand Down
Binary file modified images/basic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/completion.gif
Binary file not shown.
Binary file added images/index-completions.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/index-hovers.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/rules-completions.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/rules-hovers.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
"scopeName": "source.firerules",
"path": "./syntaxes/firerules.json"
}
],
"jsonValidation": [
{
"fileMatch": "*.indexes.json",
"url": "./syntaxes/index.schema.json"
}
]
},
"devDependencies": {
Expand Down
61 changes: 61 additions & 0 deletions syntaxes/index.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"title": "Firestore Index Definitions",
"type": "object",
"properties": {
"indexes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The resource name of the index."
},
"collectionId": {
"type": "string",
"pattern": "^[a-zA-Z0-9_]+$",
"description": "The collection ID to which this index applies."
},
"fields": {
"type": "array",
"items": {
"type": "object",
"properties": {
"fieldPath": {
"type": "string",
"pattern": "^[a-zA-Z0-9_\/]+$",
"description": "The path of the field. Special field paths __name__, __type__, and __scatter__ may be used."
},
"mode": {
"enum": [
"ASCENDING",
"DESCENDING",
"MODE_UNSPECIFIED"
],
"description": "The mode determines how a field is indexed."
}
},
"uniqueItems": true,
"required": ["fieldPath"]
},
"minItems": 1
},
"state": {
"enum": [
"STATE_UNSPECIFIED",
"DISABLED",
"ENABLED",
"ENABLING",
"DISABLING",
"ERROR"
],
"description": "The state of the index. The state is read-only and is manipulated by using the enable and disable RPCs. During enabling, the process could result in an error, in which case the index will move to the ERROR state. The process can be recovered by either fixing the data that caused the error and retrying by calling enable or by aborting the index build by calling disable."
}
},
"required": ["collectionId", "fields"]
},
"minItems": 1
}
},
"required": ["indexes"]
}
13 changes: 13 additions & 0 deletions syntaxes/sample.indexes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"indexes": [
{
"name": "my index",
"collectionId": "widgets",
"fields": [
{ "fieldPath": "foo", "mode": "ASCENDING" },
{ "fieldPath": "bar", "mode": "DESCENDING" },
{ "fieldPath": "baz", "mode": "ASCENDING" }
]
}
]
}

0 comments on commit 6005baf

Please sign in to comment.