diff --git a/0-intro.md b/0-intro.md index f6fc0ce..7084ffc 100644 --- a/0-intro.md +++ b/0-intro.md @@ -7,7 +7,7 @@ Sealious is a declarative, resource-oriented framework for creating application When creating a Sealious application, the developer has to focus on the "what" of the application, not the "how". Consider the following Sealious resource-type declaration: ```javascript -var Person = new Sealious.ResourceType({ +var Person = new Sealious.Collection({ name: "people", fields: [ {name: "full-name", type: "text", required: true}, @@ -73,7 +73,7 @@ Sealious uses `npm` as a way to distribute it's modules. To distinguish them fro Sealious plugins contain one or more "chips". Chips are small entities that contain a singular purpose. Every chip is one of these types: * Channel -* ResourceType +* Collection * FieldType * AccessStrategyType * Datastore @@ -200,7 +200,7 @@ digraph lifespan{ subgraph clusterResourceTypeCreate { style="dashed"; - label="ResourceTypePerson:create"; + label="PersonCollection:create"; validate_values [label="Validate all values\n(iterate through FieldTypes)", style=filled]; check_access [label="check access\n(via AccessStrategy)", style=filled]; check_missing [label="check if any required\nfields are missing"]; diff --git a/1-declarations.md b/1-declarations.md index 264f76e..d5ae723 100644 --- a/1-declarations.md +++ b/1-declarations.md @@ -39,7 +39,8 @@ type Params: Object; params: Params, value_in_db: Any ) => Promise<decoded_value: Any> & Any, - extends?: FieldType + extends?: FieldType, + has_index?: (params: Any) => false | index_type: String | Promise<false | index_type: String> } | FieldTypeName @@ -53,6 +54,7 @@ type Params: Object; * `encode`: **optional**. Takes the value for a field from client's input and transforms it into something else. The result of calling that function for the client's input is what will be stored in the database. * `decode`: **optional**. A function reverse to `encode`. If declared, the value in the database will be run through that function before being returned to the client. * `extends`: **optional**. Must be a proper `FieldType` declaration. When specified, the field-type being declared will inherit behavior from the type it is extending. All specified methods will obscure the parent's methods. The unspecified will be inherited. + * `has_index`: **optional**. Whether or not to instruct the Datastore to create an index on that field. In order to include the contents of the fields of this type in full-text-search, return "text" here. * Usage @@ -98,7 +100,7 @@ type Params: Object; ### Field -Fields are the most important part of a ResourceType. They describe it's behavior and structure. +Fields are the most important part of a Collection. They describe it's behavior and structure. * Syntax @@ -114,13 +116,13 @@ Fields are the most important part of a ResourceType. They describe it's behavio * Explanation * `type`: required. A FieldType declaration. It's more comfortable to use the "short" FieldType notation here (that is: just entering the name of the registered FieldType). - * `name`: the name of the field. Has to be unique within the ResourceType. + * `name`: the name of the field. Has to be unique within the Collection. * `required`: **optional**. Defaults to `false`. If set to `true`, Sealious won't allow modifications of the resource that would result in removing a value from that field. * `params`: **optional**. A set of parameters that configure the behavior of the FieldType for that particular field. * Usage - Use it when describing a [ResourceType](#resourcetype). + Use it when describing a [Collection](#collection). * Example @@ -130,7 +132,7 @@ Fields are the most important part of a ResourceType. They describe it's behavio ### AccessStrategyType -AccessStrategyType describes a type of an access strategy that can be parametrized, instantiated, and, for example, assigned to a ResourceType. +AccessStrategyType describes a type of an access strategy that can be parametrized, instantiated, and, for example, assigned to a Collection. * Syntax @@ -205,7 +207,7 @@ AccessStrategyType describes a type of an access strategy that can be parametriz * Usage - Currently this declaration is only being used when describing access strategies to resource actions in [ResourceType](#resourcetype) declaration. + Currently this declaration is only being used when describing access strategies to resource actions in [Collection](#collection) declaration. * Examples @@ -225,15 +227,15 @@ AccessStrategyType describes a type of an access strategy that can be parametriz * Usage - It does not have it's own constructor, as it doesn't do anything by itself. It can be used when describing access strategies in [ResourceType](#resourcetype) declaration. + It does not have it's own constructor, as it doesn't do anything by itself. It can be used when describing access strategies in [Collection](#collection) declaration. -### ResourceType +### Collection * Syntax
-	type ResourceType: {
+	type Collection: {
 		name: String,
 		fields: Array<Field>,
 		access_strategy: AccessStrategy | Object<ResourceActionName, AccessStrategy>
@@ -250,10 +252,10 @@ AccessStrategyType describes a type of an access strategy that can be parametriz
 
 * Usage
 
-	To create a new ResourceType, call the `ResourceType` constructor:
+	To create a new Collection, call the `Collection` constructor:
 
 	```javascript
-	var Person = new Sealious.ResourceType({
+	var Person = new Sealious.Collection({
 		name: "person",
 		fields: //...
 	});
diff --git a/2-base-chips.md b/2-base-chips.md
index bcae8da..b45d278 100644
--- a/2-base-chips.md
+++ b/2-base-chips.md
@@ -162,7 +162,7 @@ Resolves only if the provided Context is an instance of SuperContext.
 
 Resolves only if the `user_id` in the `context` argument matches the `id` attribute of the `item` argument. 
 
-Useful for creating access strategies for the `User` ResourceType. 
+Useful for creating access strategies for the `User` Collection. 
 
 *  Sensitivity
 
@@ -423,11 +423,11 @@ Can reference any other resource.
 
 	```javascript
 	type single_reference_params: {
-		resource_type: ResourceTypeName
+		collection: CollectionDeclaration
 	}
 	```
 	
-	* `resource_type`: **required**. Only references to resources of that particular type will be accepted.
+	* `collection`: **required**. Only references to resources of that particular type will be accepted.
 	
 * **sensitivity**
 
diff --git a/README.md b/README.md
index f88ba35..3e2ce20 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ Table of Contents
     -   [AccessStrategyType](#accessstrategytype-1)
     -   [AccessStrategy](#accessstrategy)
     -   [ResourceActionName](#resourceactionname)
-    -   [ResourceType](#resourcetype)
+    -   [Collection](#collection)
 -   [Base Chips](#base-chips)
     -   [Access Strategy Types](#access-strategy-types)
         -   [and](#and)
@@ -73,7 +73,7 @@ Sealious is a declarative, resource-oriented framework for creating application
 When creating a Sealious application, the developer has to focus on the "what" of the application, not the "how". Consider the following Sealious resource-type declaration:
 
 ``` javascript
-var Person = new Sealious.ResourceType({
+var Person = new Sealious.Collection({
     name: "people",
     fields: [
         {name: "full-name", type: "text", required: true},
@@ -106,7 +106,7 @@ Sealious uses `npm` as a way to distribute it's modules. To distinguish them fro
 Sealious plugins contain one or more "chips". Chips are small entities that contain a singular purpose. Every chip is one of these types:
 
 -   Channel
--   ResourceType
+-   Collection
 -   FieldType
 -   AccessStrategyType
 -   Datastore
@@ -195,7 +195,7 @@ Assume the following client input:
 
 The exact syntax of a call can be different for each Channel, but essentially it always has to contain the information presented above. The differences between call syntax for Sealious Channels does not fit inside the scope of this reference.
 
-![](graphviz-images/4ed5f199fd1cfab80ae0df0518fb2296.png)
+![](graphviz-images/76b1670cffb07b9196b91cc9ca8cbc9b.png)
 
 The darker nodes represent functions that are context-sensitive.
 
@@ -292,7 +292,7 @@ Creating a Sealious application consists mainly of composing various declaration
 
 ### Field
 
-Fields are the most important part of a ResourceType. They describe it's behavior and structure.
+Fields are the most important part of a Collection. They describe it's behavior and structure.
 
 -   Syntax
 
@@ -308,12 +308,12 @@ Fields are the most important part of a ResourceType. They describe it's behavio
 -   Explanation
 
     -   `type`: required. A FieldType declaration. It's more comfortable to use the "short" FieldType notation here (that is: just entering the name of the registered FieldType).
-    -   `name`: the name of the field. Has to be unique within the ResourceType.
+    -   `name`: the name of the field. Has to be unique within the Collection.
     -   `required`: **optional**. Defaults to `false`. If set to `true`, Sealious won't allow modifications of the resource that would result in removing a value from that field.
     -   `params`: **optional**. A set of parameters that configure the behavior of the FieldType for that particular field.
 -   Usage
 
-    Use it when describing a [ResourceType](#resourcetype).
+    Use it when describing a [Collection](#collection).
 
 -   Example
 
@@ -323,7 +323,7 @@ Fields are the most important part of a ResourceType. They describe it's behavio
 
 ### AccessStrategyType
 
-AccessStrategyType describes a type of an access strategy that can be parametrized, instantiated, and, for example, assigned to a ResourceType.
+AccessStrategyType describes a type of an access strategy that can be parametrized, instantiated, and, for example, assigned to a Collection.
 
 -   Syntax
 
@@ -397,7 +397,7 @@ AccessStrategyType describes a type of an access strategy that can be parametriz
 
 -   Usage
 
-    Currently this declaration is only being used when describing access strategies to resource actions in [ResourceType](#resourcetype) declaration.
+    Currently this declaration is only being used when describing access strategies to resource actions in [Collection](#collection) declaration.
 
 -   Examples
 
@@ -413,14 +413,14 @@ AccessStrategyType describes a type of an access strategy that can be parametriz
 
 -   Usage
 
-    It does not have it's own constructor, as it doesn't do anything by itself. It can be used when describing access strategies in [ResourceType](#resourcetype) declaration.
+    It does not have it's own constructor, as it doesn't do anything by itself. It can be used when describing access strategies in [Collection](#collection) declaration.
 
-### ResourceType
+### Collection
 
 -   Syntax
 
     
-    type ResourceType: {
+    type Collection: {
         name: String,
         fields: Array<Field>,
         access_strategy: AccessStrategy | Object<ResourceActionName, AccessStrategy>
@@ -436,10 +436,10 @@ AccessStrategyType describes a type of an access strategy that can be parametriz
     -   `access_strategy`: **required**. Describes what access strategies will be used for granting access to calling various resource actions. When a single [AccessStrategy](#accessstrategy) is specified, it will be used for all of the actions. If the `Object` notation is being used, then each action can have a different access\_strategy assigned. If an action does not have an AccessStrategy assigned, it will use the `default` one.
 -   Usage
 
-    To create a new ResourceType, call the `ResourceType` constructor:
+    To create a new Collection, call the `Collection` constructor:
 
     ``` javascript
-    var Person = new Sealious.ResourceType({
+    var Person = new Sealious.Collection({
         name: "person",
         fields: //...
     });
@@ -627,7 +627,7 @@ Resolves only if the provided Context is an instance of SuperContext.
 
 Resolves only if the `user_id` in the `context` argument matches the `id` attribute of the `item` argument.
 
-Useful for creating access strategies for the `User` ResourceType.
+Useful for creating access strategies for the `User` Collection.
 
 -   Sensitivity
 
@@ -879,11 +879,11 @@ Can reference any other resource.
 
     ``` javascript
     type single_reference_params: {
-        resource_type: ResourceTypeName
+        collection: CollectionDeclaration
     }
     ```
 
-    -   `resource_type`: **required**. Only references to resources of that particular type will be accepted.
+    -   `collection`: **required**. Only references to resources of that particular type will be accepted.
 -   **sensitivity**
 
     The behavior of this resource type depends on `context`, `params` and `value`.
diff --git a/graphviz-images/4ed5f199fd1cfab80ae0df0518fb2296.png b/graphviz-images/76b1670cffb07b9196b91cc9ca8cbc9b.png
similarity index 51%
rename from graphviz-images/4ed5f199fd1cfab80ae0df0518fb2296.png
rename to graphviz-images/76b1670cffb07b9196b91cc9ca8cbc9b.png
index c9979b6..194e72d 100644
Binary files a/graphviz-images/4ed5f199fd1cfab80ae0df0518fb2296.png and b/graphviz-images/76b1670cffb07b9196b91cc9ca8cbc9b.png differ