Skip to content

Commit

Permalink
Merge pull request #21 from OldSneerJaw/issue-19-release-1.0.0
Browse files Browse the repository at this point in the history
Issue 19: Preparation for release of 1.0.0
  • Loading branch information
dkichler authored May 9, 2018
2 parents 786d84d + 10e9548 commit 26d1431
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/). All notable changes will be documented in this file.

## [Unreleased]
## [1.0.0] - 2018-05-10
### Added
- [#8](https://github.com/OldSneerJaw/couchster/issues/8): Regular expression pattern constraint for document ID
- [#10](https://github.com/OldSneerJaw/couchster/issues/10): Extended year format in date strings
Expand All @@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). All notable c
## [0.1.0] - 2018-02-28
Adapted from [synctos](https://github.com/Kashoo/synctos) for use with CouchDB

[Unreleased]: https://github.com/OldSneerJaw/couchster/compare/v0.2.0...HEAD
[Unreleased]: https://github.com/OldSneerJaw/couchster/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/OldSneerJaw/couchster/compare/v0.2.0...v1.0.0
[0.2.0]: https://github.com/OldSneerJaw/couchster/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/OldSneerJaw/couchster/compare/73ba6a5...v0.1.0
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,8 @@ Additional properties that provide finer grained control over documents:
* `cannotReplace`: (optional) As with the `immutable` constraint, the document cannot be replaced after it is created. However, this constraint does not prevent the document from being deleted. Note that, even if attachments are allowed for this document type (see the `allowAttachments` document constraint for more info), it will not be possible to create, modify or delete attachments in a document that already exists, which means that they must be created inline in the document's `_attachments` property when the document is first created. In addition to a static value (e.g. `cannotReplace: true`), this constraint may also be assigned a value dynamically via a function (e.g. `cannotReplace: function(newDoc, oldDoc) { ... }`) where the parameters are as follows: (1) the new document (if deleted, the `_deleted` property will be `true`) and (2) the document that is being replaced (if any; it will be `null` if it has been deleted or does not exist). Defaults to `false`.
* `cannotDelete`: (optional) As with the `immutable` constraint, the document cannot be deleted after it is created. However, this constraint does not prevent the document from being replaced. In addition to a static value (e.g. `cannotDelete: true`), this constraint may also be assigned a value dynamically via a function (e.g. `cannotDelete: function(newDoc, oldDoc) { ... }`) where the parameters are as follows: (1) the new document (if deleted, the `_deleted` property will be `true`) and (2) the document that is being replaced (if any; it will be `null` if it has been deleted or does not exist). Defaults to `false`.
* `allowAttachments`: (optional) Whether to allow the addition of [file attachments](http://docs.couchdb.org/en/latest/intro/api.html#attachments) for the document type. In addition to a static value (e.g. `allowAttachments: true`), this constraint may also be assigned a value dynamically via a function (e.g. `allowAttachments: function(newDoc, oldDoc) { ... }`) where the parameters are as follows: (1) the new document (if deleted, the `_deleted` property will be `true`) and (2) the document that is being replaced (if any; it will be `null` if it has been deleted or does not exist). Defaults to `false` to prevent malicious/misbehaving clients from polluting the database with unwanted files. See the `attachmentConstraints` constraint and the `attachmentReference` validation type for more options.
* `attachmentConstraints`: (optional) Various constraints to apply to file attachments associated with a document type. Its settings only apply if the document definition's `allowAttachments` constraint is `true`. In addition to a static value (e.g. `attachmentConstraints: { }`), this constraint may also be assigned a value dynamically via a function (e.g. `attachmentConstraints: function(newDoc, oldDoc) { ... }`) where the parameters are as follows: (1) the new document (if deleted, the `_deleted` property will be `true`) and (2) the document that is being replaced (if any; it will be `null` if it has been deleted or does not exist). Additional parameters:
* `attachmentConstraints`: (optional) Various constraints to apply to file attachments associated with a document type. Its settings only apply if the document definition's `allowAttachments` constraint is `true`. In addition to a static value (e.g. `attachmentConstraints: { }`), this constraint may also be assigned a value dynamically via a function (e.g. `attachmentConstraints: function(newDoc, oldDoc) { ... }`) where the parameters are as follows: (1) the new document (if deleted, the `_deleted` property will be `true`) and (2) the document that is being replaced (if any; it will be `null` if it has been deleted or does not exist). NOTE: the only way to (indirectly) limit the size of file attachments (and documents) is to set the global CouchDB configuration option [`httpd/max_http_request_size`](http://docs.couchdb.org/en/latest/config/http.html#httpd/max_http_request_size) ([more info](https://github.com/apache/couchdb/issues/1320)). Additional parameters:
* `maximumAttachmentCount`: (optional) The maximum number of attachments that may be assigned to a single document of this type. In addition to a static value (e.g. `maximumAttachmentCount: 2`), this constraint may also be assigned a value dynamically via a function (e.g. `maximumAttachmentCount: function(newDoc, oldDoc) { ... }`) where the parameters are as follows: (1) the new document (if deleted, the `_deleted` property will be `true`) and (2) the document that is being replaced (if any; it will be `null` if it has been deleted or does not exist). Unlimited by default.
* `maximumIndividualSize`: (optional) The maximum file size, in bytes, allowed for any single attachment assigned to a document of this type. In addition to a static value (e.g. `maximumIndividualSize: 256`), this constraint may also be assigned a value dynamically via a function (e.g. `maximumIndividualSize: function(newDoc, oldDoc) { ... }`) where the parameters are as follows: (1) the new document (if deleted, the `_deleted` property will be `true`) and (2) the document that is being replaced (if any; it will be `null` if it has been deleted or does not exist). Unlimited by default.
* `maximumTotalSize`: (optional) The maximum total size, in bytes, of _all_ attachments assigned to a single document of this type. In other words, when the sizes of all of a document's attachments are added together, it must not exceed this value. In addition to a static value (e.g. `maximumTotalSize: 1024`), this constraint may also be assigned a value dynamically via a function (e.g. `maximumTotalSize: function(newDoc, oldDoc) { ... }`) where the parameters are as follows: (1) the new document (if deleted, the `_deleted` property will be `true`) and (2) the document that is being replaced (if any; it will be `null` if it has been deleted or does not exist). Unlimited by default.
* `supportedExtensions`: (optional) An array of case-insensitive file extensions that are allowed for an attachment's filename (e.g. "txt", "jpg", "pdf"). In addition to a static value (e.g. `supportedExtensions: [ 'png', 'gif', 'jpg' ]`), this constraint may also be assigned a value dynamically via a function (e.g. `supportedExtensions: function(newDoc, oldDoc) { ... }`) where the parameters are as follows: (1) the new document (if deleted, the `_deleted` property will be `true`) and (2) the document that is being replaced (if any; it will be `null` if it has been deleted or does not exist). No restriction by default.
* `supportedContentTypes`: (optional) An array of content/MIME types that are allowed for an attachment's contents (e.g. "image/png", "text/html", "application/xml"). In addition to a static value (e.g. `supportedContentTypes: [ 'image/png', 'image/gif', 'image/jpeg' ]`), this constraint may also be assigned a value dynamically via a function (e.g. `supportedContentTypes: function(newDoc, oldDoc) { ... }`) where the parameters are as follows: (1) the new document (if deleted, the `_deleted` property will be `true`) and (2) the document that is being replaced (if any; it will be `null` if it has been deleted or does not exist). No restriction by default.
* `requireAttachmentReferences`: (optional) Whether every one of a document's attachments must have a corresponding `attachmentReference`-type property referencing it. In addition to a static value (e.g. `requireAttachmentReferences: true`), this constraint may also be assigned a value dynamically via a function (e.g. `requireAttachmentReferences: function(newDoc, oldDoc) { ... }`) where the parameters are as follows: (1) the new document (if deleted, the `_deleted` property will be `true`) and (2) the document that is being replaced (if any; it will be `null` if it has been deleted or does not exist). Defaults to `false`.
Expand Down Expand Up @@ -342,7 +340,6 @@ Validation for simple data types (e.g. strings, booleans, integers, floating poi
* `attachmentReference`: The value is the name of one of the document's file attachments. Note that, because the addition of an attachment is often a separate CouchDB API operation from the creation/replacement of the associated document, this validation type is only applied if the attachment is actually present in the document. However, since the validation function is run twice in such situations (i.e. once when the _document_ is created/replaced and once when the _attachment_ is created/replaced), the validation will be performed eventually. The top-level `allowAttachments` document constraint should be `true` so that documents of this type can actually store attachments. Additional parameters:
* `supportedExtensions`: An array of case-insensitive file extensions that are allowed for the attachment's filename (e.g. "txt", "jpg", "pdf"). Takes precedence over the document-wide `supportedExtensions` constraint for the referenced attachment. No restriction by default.
* `supportedContentTypes`: An array of content/MIME types that are allowed for the attachment's contents (e.g. "image/png", "text/html", "application/xml"). Takes precedence over the document-wide `supportedContentTypes` constraint for the referenced attachment. No restriction by default.
* `maximumSize`: The maximum file size, in bytes, of the attachment. Takes precedence over the document-wide `maximumIndividualSize` constraint for the referenced attachment. Unlimited by default.

##### Complex type validation

Expand Down Expand Up @@ -661,6 +658,8 @@ function() {

As you can see, the fragments can also reference functions (e.g. `myDocTypeFilter`) and variables (e.g. `authorizedRoles`) that were defined in the main document definitions file. Organizing document definitions in this manner helps to keep configuration manageable.

NOTE: couchster does not currently support CouchDB's implementation of [CommonJS modules](http://docs.couchdb.org/en/latest/query-server/javascript.html#commonjs-modules) and the [`require`](http://docs.couchdb.org/en/latest/query-server/javascript.html#require) function.

### Helper functions

Custom code (e.g. type filters, custom validation functions, custom actions) within document definitions have access to CouchDB's built in [utility functions](http://docs.couchdb.org/en/latest/query-server/javascript.html). In addition, couchster provides some predefined functions for common operations:
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "couchster",
"version": "0.2.0",
"version": "1.0.0",
"description": "A tool to build comprehensive validation functions for Apache CouchDB",
"keywords": [
"apache",
Expand Down

0 comments on commit 26d1431

Please sign in to comment.