Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blaze_compiler

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blaze_compiler - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

.idea/inspectionProfiles/profiles_settings.xml

2

examples/mail_example.json
{
"predicates": [
"functions": [
{

@@ -4,0 +4,0 @@ "isLoggedIn()": "auth.username !== null"

@@ -15,7 +15,6 @@ module.exports = function(grunt) {

mail: ['test/mail_example_test.js'],
parse: ['test/parse_test.js'],
json: ['test/json/parser_test.js']
parse: ['test/parse_test.js']
},typescript: {
base: {
src: ['**/*.ts'],
src: ['src/**/*.ts', 'test/**/*.ts'],
dest: '.',

@@ -36,3 +35,2 @@ options: {

// Default task(s).

@@ -44,3 +42,2 @@ grunt.registerTask('default', ['nodeunit']);

grunt.registerTask('compile',["typescript:base"]);
};
{
"name": "blaze_compiler",
"version": "0.0.7",
"version": "0.0.8",
"description": "Transpiles extendable, schema orientated definitions into Firebase security rules",
"author": "Tom Larkworthy",
"license": "private",
"main": "blaze.js",
"bin" : { "blaze" : "./bin/blaze.js" },
"bin": {
"blaze": "./bin/blaze.js"
},
"repository": {
"type": "git",
"url": "https://github.com/firebase/blaze_compiler"
},
"scripts": {
"prepublish": "grunt compile"
},
"dependencies":{
"dependencies": {
"optimist": "~0.6.1",
"xregexp": "2.0.0",
"js-yaml": "3.0.2",
"source-processor": "0.0.3",
"tv4": "1.0.16",

@@ -23,9 +27,9 @@ "falafel": "0.3.1",

"devDependencies": {
"firebase": "1.0",
"firebase-token-generator": "0.1.4",
"grunt": "~0.4.2",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-typescript": "0.3.5",
"async": "0.7.0"
"async": "0.7.0",
"firebase": "1.0",
"firebase-token-generator": "0.1.4",
"grunt": "~0.4.2",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-typescript": "0.3.5"
}
}

@@ -15,3 +15,3 @@ # Blaze Security Compiler for Firebase

```YAML
predicates:
functions:
- isLoggedIn(): auth.id !== null

@@ -35,10 +35,10 @@

find more about the [predicates](#predicates), [simpler rule expressions](#simple-security-expressions), the [schema definitions](#schema), [access control](#access-control) or [inline tests](#inline-testing).
find more about the [functions](#functions), [simpler rule expressions](#simple-security-expressions), the [schema definitions](#schema), [access control](#access-control) or [inline tests](#inline-testing).
## Predicates
## Functions
Common expressions for reuse are defined in the *predicates* list. A predicate can take arguments (they are functions).
Common expressions for reuse are defined in the *functions* list. A function can take arguments (they are functions).
```YAML
predicates:
functions:
- isLoggedIn(): auth.username !== null

@@ -250,3 +250,3 @@ - isUser(username): auth.username === username

```YAML
predicates:
functions:
- isLoggedIn(): auth !== null

@@ -269,3 +269,3 @@ ...

```YAML
predicates: #reusable boolean functions
functions: #reusable boolean functions
- isLoggedIn(): auth.username !== null

@@ -340,2 +340,8 @@ - createOnly(): next.exists() && !prev.exists()

## Changelog
- 18th August 2014:
- predicates renamed to functions
- 14th July 2014:
- improved error reporting
- updated installation

@@ -348,5 +354,2 @@ - 9th July 2014:

- allowed untyped schema if type is not specified
- 14th July 2014:
- improved error reporting
- updated installation
{
"rules":{
".write":"true&&true&&(!newData.child('extra').parent().exists()||!(newData.child('extra').parent().isString()||newData.child('extra').parent().isNumber()||newData.child('extra').parent().isBoolean()))&&(newData.child('extra').parent().val()==null||true)&&true&&(!newData.child('extra').exists()||newData.child('extra').isString())&&false&&(false||true)",
".read":"false||true",
"extra": {
".write":"true&&(!newData.parent().exists()||!(newData.parent().isString()||newData.parent().isNumber()||newData.parent().isBoolean()))&&(newData.parent().val()==null||true)&&true&&(!newData.exists()||newData.isString())&&(false||true)",
".read":"false||true"
".write":"true&&true&&false&&false",
".read":"false",
"users": {
".write":"true&&false&&false",
".read":"false",
"$userid": {
".write":"true&&true&&false&&true&&false&&(false||false)",
".read":"false||$userid===auth.username",
"inbox": {
".write":"true&&false&&(false||newData.exists()&&!data.exists()&&auth.username!==null||data.exists()&&!newData.exists()&&$userid===auth.username||false)",
".read":"false||false||false||$userid===auth.username",
"$message": {
".write":"true&&true&&(!newData.child('from').parent().parent().parent().parent().parent().exists()||!(newData.child('from').parent().parent().parent().parent().parent().isString()||newData.child('from').parent().parent().parent().parent().parent().isNumber()||newData.child('from').parent().parent().parent().parent().parent().isBoolean()))&&(newData.child('from').parent().parent().parent().parent().parent().val()==null||true)&&true&&(!newData.child('from').parent().parent().parent().parent().exists()||!(newData.child('from').parent().parent().parent().parent().isString()||newData.child('from').parent().parent().parent().parent().isNumber()||newData.child('from').parent().parent().parent().parent().isBoolean()))&&(newData.child('from').parent().parent().parent().parent().val()==null||true)&&true&&(!newData.child('from').parent().parent().parent().exists()||!(newData.child('from').parent().parent().parent().isString()||newData.child('from').parent().parent().parent().isNumber()||newData.child('from').parent().parent().parent().isBoolean()))&&(newData.child('from').parent().parent().parent().val()==null||true)&&true&&(!newData.child('from').parent().parent().exists()||!(newData.child('from').parent().parent().isString()||newData.child('from').parent().parent().isNumber()||newData.child('from').parent().parent().isBoolean()))&&(newData.child('from').parent().parent().val()==null||true)&&true&&(!newData.child('from').parent().exists()||!(newData.child('from').parent().isString()||newData.child('from').parent().isNumber()||newData.child('from').parent().isBoolean()))&&(newData.child('from').parent().val()==null||true&&newData.child('from').parent().child('from').exists()&&newData.child('from').parent().child('to').exists()&&newData.child('from').parent().child('message').exists())&&(auth.username==newData.child('from').val()&&newData.exists()&&!data.exists()||$userid===auth.username&&data.exists()&&!newData.exists())&&(!newData.child('from').exists()||newData.child('from').isString())&&true&&(!newData.child('to').parent().parent().parent().parent().parent().exists()||!(newData.child('to').parent().parent().parent().parent().parent().isString()||newData.child('to').parent().parent().parent().parent().parent().isNumber()||newData.child('to').parent().parent().parent().parent().parent().isBoolean()))&&(newData.child('to').parent().parent().parent().parent().parent().val()==null||true)&&true&&(!newData.child('to').parent().parent().parent().parent().exists()||!(newData.child('to').parent().parent().parent().parent().isString()||newData.child('to').parent().parent().parent().parent().isNumber()||newData.child('to').parent().parent().parent().parent().isBoolean()))&&(newData.child('to').parent().parent().parent().parent().val()==null||true)&&true&&(!newData.child('to').parent().parent().parent().exists()||!(newData.child('to').parent().parent().parent().isString()||newData.child('to').parent().parent().parent().isNumber()||newData.child('to').parent().parent().parent().isBoolean()))&&(newData.child('to').parent().parent().parent().val()==null||true)&&true&&(!newData.child('to').parent().parent().exists()||!(newData.child('to').parent().parent().isString()||newData.child('to').parent().parent().isNumber()||newData.child('to').parent().parent().isBoolean()))&&(newData.child('to').parent().parent().val()==null||true)&&true&&(!newData.child('to').parent().exists()||!(newData.child('to').parent().isString()||newData.child('to').parent().isNumber()||newData.child('to').parent().isBoolean()))&&(newData.child('to').parent().val()==null||true&&newData.child('to').parent().child('from').exists()&&newData.child('to').parent().child('to').exists()&&newData.child('to').parent().child('message').exists())&&(newData.exists()&&!data.exists()||data.exists()&&!newData.exists())&&(!newData.child('to').exists()||newData.child('to').isString())&&true&&(!newData.child('message').parent().parent().parent().parent().parent().exists()||!(newData.child('message').parent().parent().parent().parent().parent().isString()||newData.child('message').parent().parent().parent().parent().parent().isNumber()||newData.child('message').parent().parent().parent().parent().parent().isBoolean()))&&(newData.child('message').parent().parent().parent().parent().parent().val()==null||true)&&true&&(!newData.child('message').parent().parent().parent().parent().exists()||!(newData.child('message').parent().parent().parent().parent().isString()||newData.child('message').parent().parent().parent().parent().isNumber()||newData.child('message').parent().parent().parent().parent().isBoolean()))&&(newData.child('message').parent().parent().parent().parent().val()==null||true)&&true&&(!newData.child('message').parent().parent().parent().exists()||!(newData.child('message').parent().parent().parent().isString()||newData.child('message').parent().parent().parent().isNumber()||newData.child('message').parent().parent().parent().isBoolean()))&&(newData.child('message').parent().parent().parent().val()==null||true)&&true&&(!newData.child('message').parent().parent().exists()||!(newData.child('message').parent().parent().isString()||newData.child('message').parent().parent().isNumber()||newData.child('message').parent().parent().isBoolean()))&&(newData.child('message').parent().parent().val()==null||true)&&true&&(!newData.child('message').parent().exists()||!(newData.child('message').parent().isString()||newData.child('message').parent().isNumber()||newData.child('message').parent().isBoolean()))&&(newData.child('message').parent().val()==null||true&&newData.child('message').parent().child('from').exists()&&newData.child('message').parent().child('to').exists()&&newData.child('message').parent().child('message').exists())&&(newData.exists()&&!data.exists()||data.exists()&&!newData.exists())&&(!newData.child('message').exists()||newData.child('message').isString())&&(false||newData.exists()&&!data.exists()&&auth.username!==null||data.exists()&&!newData.exists()&&$userid===auth.username||false)",
".read":"false||false||false||$userid===auth.username",
"from": {
".write":"true&&(!newData.parent().parent().parent().parent().parent().exists()||!(newData.parent().parent().parent().parent().parent().isString()||newData.parent().parent().parent().parent().parent().isNumber()||newData.parent().parent().parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().parent().parent().exists()||!(newData.parent().parent().parent().parent().isString()||newData.parent().parent().parent().parent().isNumber()||newData.parent().parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().parent().exists()||!(newData.parent().parent().parent().isString()||newData.parent().parent().parent().isNumber()||newData.parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().exists()||!(newData.parent().parent().isString()||newData.parent().parent().isNumber()||newData.parent().parent().isBoolean()))&&(newData.parent().parent().val()==null||true)&&true&&(!newData.parent().exists()||!(newData.parent().isString()||newData.parent().isNumber()||newData.parent().isBoolean()))&&(newData.parent().val()==null||true&&newData.parent().child('from').exists()&&newData.parent().child('to').exists()&&newData.parent().child('message').exists())&&(auth.username==newData.val()&&newData.exists()&&!data.exists()||$userid===auth.username&&data.exists()&&!newData.exists())&&(!newData.exists()||newData.isString())&&(false||newData.exists()&&!data.exists()&&auth.username!==null||data.exists()&&!newData.exists()&&$userid===auth.username||false)",
".read":"false||false||false||$userid===auth.username"
},
"to": {
".write":"true&&(!newData.parent().parent().parent().parent().parent().exists()||!(newData.parent().parent().parent().parent().parent().isString()||newData.parent().parent().parent().parent().parent().isNumber()||newData.parent().parent().parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().parent().parent().exists()||!(newData.parent().parent().parent().parent().isString()||newData.parent().parent().parent().parent().isNumber()||newData.parent().parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().parent().exists()||!(newData.parent().parent().parent().isString()||newData.parent().parent().parent().isNumber()||newData.parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().exists()||!(newData.parent().parent().isString()||newData.parent().parent().isNumber()||newData.parent().parent().isBoolean()))&&(newData.parent().parent().val()==null||true)&&true&&(!newData.parent().exists()||!(newData.parent().isString()||newData.parent().isNumber()||newData.parent().isBoolean()))&&(newData.parent().val()==null||true&&newData.parent().child('from').exists()&&newData.parent().child('to').exists()&&newData.parent().child('message').exists())&&(newData.exists()&&!data.exists()||data.exists()&&!newData.exists())&&(!newData.exists()||newData.isString())&&(false||newData.exists()&&!data.exists()&&auth.username!==null||data.exists()&&!newData.exists()&&$userid===auth.username||false)",
".read":"false||false||false||$userid===auth.username"
},
"message": {
".write":"true&&(!newData.parent().parent().parent().parent().parent().exists()||!(newData.parent().parent().parent().parent().parent().isString()||newData.parent().parent().parent().parent().parent().isNumber()||newData.parent().parent().parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().parent().parent().exists()||!(newData.parent().parent().parent().parent().isString()||newData.parent().parent().parent().parent().isNumber()||newData.parent().parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().parent().exists()||!(newData.parent().parent().parent().isString()||newData.parent().parent().parent().isNumber()||newData.parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().exists()||!(newData.parent().parent().isString()||newData.parent().parent().isNumber()||newData.parent().parent().isBoolean()))&&(newData.parent().parent().val()==null||true)&&true&&(!newData.parent().exists()||!(newData.parent().isString()||newData.parent().isNumber()||newData.parent().isBoolean()))&&(newData.parent().val()==null||true&&newData.parent().child('from').exists()&&newData.parent().child('to').exists()&&newData.parent().child('message').exists())&&(newData.exists()&&!data.exists()||data.exists()&&!newData.exists())&&(!newData.exists()||newData.isString())&&(false||newData.exists()&&!data.exists()&&auth.username!==null||data.exists()&&!newData.exists()&&$userid===auth.username||false)",
".read":"false||false||false||$userid===auth.username"
},
"$other":{".validate":"false"}
}
},
"outbox": {
".write":"true&&false&&(false||true||false)",
".read":"false||false||$userid===auth.username",
"$message": {
".write":"true&&true&&(!newData.child('from').parent().parent().parent().parent().parent().exists()||!(newData.child('from').parent().parent().parent().parent().parent().isString()||newData.child('from').parent().parent().parent().parent().parent().isNumber()||newData.child('from').parent().parent().parent().parent().parent().isBoolean()))&&(newData.child('from').parent().parent().parent().parent().parent().val()==null||true)&&true&&(!newData.child('from').parent().parent().parent().parent().exists()||!(newData.child('from').parent().parent().parent().parent().isString()||newData.child('from').parent().parent().parent().parent().isNumber()||newData.child('from').parent().parent().parent().parent().isBoolean()))&&(newData.child('from').parent().parent().parent().parent().val()==null||true)&&true&&(!newData.child('from').parent().parent().parent().exists()||!(newData.child('from').parent().parent().parent().isString()||newData.child('from').parent().parent().parent().isNumber()||newData.child('from').parent().parent().parent().isBoolean()))&&(newData.child('from').parent().parent().parent().val()==null||true)&&true&&(!newData.child('from').parent().parent().exists()||!(newData.child('from').parent().parent().isString()||newData.child('from').parent().parent().isNumber()||newData.child('from').parent().parent().isBoolean()))&&(newData.child('from').parent().parent().val()==null||true)&&true&&(!newData.child('from').parent().exists()||!(newData.child('from').parent().isString()||newData.child('from').parent().isNumber()||newData.child('from').parent().isBoolean()))&&(newData.child('from').parent().val()==null||true&&newData.child('from').parent().child('from').exists()&&newData.child('from').parent().child('to').exists()&&newData.child('from').parent().child('message').exists())&&(!newData.child('from').parent().exists()||!(newData.child('from').parent().isString()||newData.child('from').parent().isNumber()||newData.child('from').parent().isBoolean()))&&(newData.child('from').parent().val()==null||true&&newData.child('from').parent().child('from').exists()&&newData.child('from').parent().child('to').exists()&&newData.child('from').parent().child('message').exists())&&(auth.username==newData.child('from').val()&&newData.exists()&&!data.exists()||$userid===auth.username&&data.exists()&&!newData.exists())&&(!newData.child('from').exists()||newData.child('from').isString())&&(!newData.child('from').exists()||newData.child('from').isString())&&true&&(!newData.child('to').parent().parent().parent().parent().parent().exists()||!(newData.child('to').parent().parent().parent().parent().parent().isString()||newData.child('to').parent().parent().parent().parent().parent().isNumber()||newData.child('to').parent().parent().parent().parent().parent().isBoolean()))&&(newData.child('to').parent().parent().parent().parent().parent().val()==null||true)&&true&&(!newData.child('to').parent().parent().parent().parent().exists()||!(newData.child('to').parent().parent().parent().parent().isString()||newData.child('to').parent().parent().parent().parent().isNumber()||newData.child('to').parent().parent().parent().parent().isBoolean()))&&(newData.child('to').parent().parent().parent().parent().val()==null||true)&&true&&(!newData.child('to').parent().parent().parent().exists()||!(newData.child('to').parent().parent().parent().isString()||newData.child('to').parent().parent().parent().isNumber()||newData.child('to').parent().parent().parent().isBoolean()))&&(newData.child('to').parent().parent().parent().val()==null||true)&&true&&(!newData.child('to').parent().parent().exists()||!(newData.child('to').parent().parent().isString()||newData.child('to').parent().parent().isNumber()||newData.child('to').parent().parent().isBoolean()))&&(newData.child('to').parent().parent().val()==null||true)&&true&&(!newData.child('to').parent().exists()||!(newData.child('to').parent().isString()||newData.child('to').parent().isNumber()||newData.child('to').parent().isBoolean()))&&(newData.child('to').parent().val()==null||true&&newData.child('to').parent().child('from').exists()&&newData.child('to').parent().child('to').exists()&&newData.child('to').parent().child('message').exists())&&(!newData.child('to').parent().exists()||!(newData.child('to').parent().isString()||newData.child('to').parent().isNumber()||newData.child('to').parent().isBoolean()))&&(newData.child('to').parent().val()==null||true&&newData.child('to').parent().child('from').exists()&&newData.child('to').parent().child('to').exists()&&newData.child('to').parent().child('message').exists())&&(newData.exists()&&!data.exists()||data.exists()&&!newData.exists())&&(!newData.child('to').exists()||newData.child('to').isString())&&(!newData.child('to').exists()||newData.child('to').isString())&&true&&(!newData.child('message').parent().parent().parent().parent().parent().exists()||!(newData.child('message').parent().parent().parent().parent().parent().isString()||newData.child('message').parent().parent().parent().parent().parent().isNumber()||newData.child('message').parent().parent().parent().parent().parent().isBoolean()))&&(newData.child('message').parent().parent().parent().parent().parent().val()==null||true)&&true&&(!newData.child('message').parent().parent().parent().parent().exists()||!(newData.child('message').parent().parent().parent().parent().isString()||newData.child('message').parent().parent().parent().parent().isNumber()||newData.child('message').parent().parent().parent().parent().isBoolean()))&&(newData.child('message').parent().parent().parent().parent().val()==null||true)&&true&&(!newData.child('message').parent().parent().parent().exists()||!(newData.child('message').parent().parent().parent().isString()||newData.child('message').parent().parent().parent().isNumber()||newData.child('message').parent().parent().parent().isBoolean()))&&(newData.child('message').parent().parent().parent().val()==null||true)&&true&&(!newData.child('message').parent().parent().exists()||!(newData.child('message').parent().parent().isString()||newData.child('message').parent().parent().isNumber()||newData.child('message').parent().parent().isBoolean()))&&(newData.child('message').parent().parent().val()==null||true)&&true&&(!newData.child('message').parent().exists()||!(newData.child('message').parent().isString()||newData.child('message').parent().isNumber()||newData.child('message').parent().isBoolean()))&&(newData.child('message').parent().val()==null||true&&newData.child('message').parent().child('from').exists()&&newData.child('message').parent().child('to').exists()&&newData.child('message').parent().child('message').exists())&&(!newData.child('message').parent().exists()||!(newData.child('message').parent().isString()||newData.child('message').parent().isNumber()||newData.child('message').parent().isBoolean()))&&(newData.child('message').parent().val()==null||true&&newData.child('message').parent().child('from').exists()&&newData.child('message').parent().child('to').exists()&&newData.child('message').parent().child('message').exists())&&(newData.exists()&&!data.exists()||data.exists()&&!newData.exists())&&(!newData.child('message').exists()||newData.child('message').isString())&&(!newData.child('message').exists()||newData.child('message').isString())&&(false||true||false)",
".read":"false||false||$userid===auth.username",
"from": {
".write":"true&&(!newData.parent().parent().parent().parent().parent().exists()||!(newData.parent().parent().parent().parent().parent().isString()||newData.parent().parent().parent().parent().parent().isNumber()||newData.parent().parent().parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().parent().parent().exists()||!(newData.parent().parent().parent().parent().isString()||newData.parent().parent().parent().parent().isNumber()||newData.parent().parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().parent().exists()||!(newData.parent().parent().parent().isString()||newData.parent().parent().parent().isNumber()||newData.parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().exists()||!(newData.parent().parent().isString()||newData.parent().parent().isNumber()||newData.parent().parent().isBoolean()))&&(newData.parent().parent().val()==null||true)&&true&&(!newData.parent().exists()||!(newData.parent().isString()||newData.parent().isNumber()||newData.parent().isBoolean()))&&(newData.parent().val()==null||true&&newData.parent().child('from').exists()&&newData.parent().child('to').exists()&&newData.parent().child('message').exists())&&(!newData.parent().exists()||!(newData.parent().isString()||newData.parent().isNumber()||newData.parent().isBoolean()))&&(newData.parent().val()==null||true&&newData.parent().child('from').exists()&&newData.parent().child('to').exists()&&newData.parent().child('message').exists())&&(auth.username==newData.val()&&newData.exists()&&!data.exists()||$userid===auth.username&&data.exists()&&!newData.exists())&&(!newData.exists()||newData.isString())&&(!newData.exists()||newData.isString())&&(false||true||false)",
".read":"false||false||$userid===auth.username"
},
"to": {
".write":"true&&(!newData.parent().parent().parent().parent().parent().exists()||!(newData.parent().parent().parent().parent().parent().isString()||newData.parent().parent().parent().parent().parent().isNumber()||newData.parent().parent().parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().parent().parent().exists()||!(newData.parent().parent().parent().parent().isString()||newData.parent().parent().parent().parent().isNumber()||newData.parent().parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().parent().exists()||!(newData.parent().parent().parent().isString()||newData.parent().parent().parent().isNumber()||newData.parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().exists()||!(newData.parent().parent().isString()||newData.parent().parent().isNumber()||newData.parent().parent().isBoolean()))&&(newData.parent().parent().val()==null||true)&&true&&(!newData.parent().exists()||!(newData.parent().isString()||newData.parent().isNumber()||newData.parent().isBoolean()))&&(newData.parent().val()==null||true&&newData.parent().child('from').exists()&&newData.parent().child('to').exists()&&newData.parent().child('message').exists())&&(!newData.parent().exists()||!(newData.parent().isString()||newData.parent().isNumber()||newData.parent().isBoolean()))&&(newData.parent().val()==null||true&&newData.parent().child('from').exists()&&newData.parent().child('to').exists()&&newData.parent().child('message').exists())&&(newData.exists()&&!data.exists()||data.exists()&&!newData.exists())&&(!newData.exists()||newData.isString())&&(!newData.exists()||newData.isString())&&(false||true||false)",
".read":"false||false||$userid===auth.username"
},
"message": {
".write":"true&&(!newData.parent().parent().parent().parent().parent().exists()||!(newData.parent().parent().parent().parent().parent().isString()||newData.parent().parent().parent().parent().parent().isNumber()||newData.parent().parent().parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().parent().parent().exists()||!(newData.parent().parent().parent().parent().isString()||newData.parent().parent().parent().parent().isNumber()||newData.parent().parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().parent().exists()||!(newData.parent().parent().parent().isString()||newData.parent().parent().parent().isNumber()||newData.parent().parent().parent().isBoolean()))&&(newData.parent().parent().parent().val()==null||true)&&true&&(!newData.parent().parent().exists()||!(newData.parent().parent().isString()||newData.parent().parent().isNumber()||newData.parent().parent().isBoolean()))&&(newData.parent().parent().val()==null||true)&&true&&(!newData.parent().exists()||!(newData.parent().isString()||newData.parent().isNumber()||newData.parent().isBoolean()))&&(newData.parent().val()==null||true&&newData.parent().child('from').exists()&&newData.parent().child('to').exists()&&newData.parent().child('message').exists())&&(!newData.parent().exists()||!(newData.parent().isString()||newData.parent().isNumber()||newData.parent().isBoolean()))&&(newData.parent().val()==null||true&&newData.parent().child('from').exists()&&newData.parent().child('to').exists()&&newData.parent().child('message').exists())&&(newData.exists()&&!data.exists()||data.exists()&&!newData.exists())&&(!newData.exists()||newData.isString())&&(!newData.exists()||newData.isString())&&(false||true||false)",
".read":"false||false||$userid===auth.username"
},
"$other":{".validate":"false"}
}
}
}
},
"$chld": {
".write":"true&&(!newData.parent().exists()||!(newData.parent().isString()||newData.parent().isNumber()||newData.parent().isBoolean()))&&(newData.parent().val()==null||true)&&newData.val().contains('Y')&&(!newData.exists()||newData.isString())&&(false||true)",
".read":"false||true"
}
"$other":{".validate":"false"}
}
}

@@ -8,4 +8,4 @@ require('source-map-support').install();

var path = require('path');
var Json = require('./processors/Json');
var error = require('./error');
var Json = require('source-processor');
var error = require('source-processor');

@@ -136,3 +136,3 @@ exports.debug = false;

var rules = new Rules();
rules.predicates = expression.Predicates.parse(json.getOrNull("predicates"));
rules.functions = expression.Functions.parse(json.getOrNull("functions"));
rules.schema = SchemaRoot.parse(json.getOrThrow("schema", "no schema defined"));

@@ -139,0 +139,0 @@ rules.access = Access.parse(json.getOrWarn("access", "no access list defined, this Firebase will be inactive"));

/// <reference path="../types/js-yaml.d.ts" />
/// <reference path="../types/node.d.ts" />
/// <reference path="../types/tv4.d.ts" />
/// <reference path="../src/expression.ts" />
/// <reference path="../node_modules/source-processor/index.d.ts" />
require('source-map-support').install();

@@ -12,4 +12,4 @@

import path = require('path');
import Json = require('./processors/Json');
import error = require('./error');
import Json = require('source-processor');
import error = require('source-processor');

@@ -148,3 +148,3 @@ export var debug = false;

export class Rules{
predicates: expression.Predicates;
functions: expression.Functions;
schema: SchemaRoot;

@@ -157,3 +157,3 @@ access: Access;

var rules = new Rules();
rules.predicates = expression.Predicates.parse(json.getOrNull("predicates"));
rules.functions = expression.Functions.parse(json.getOrNull("functions"));
rules.schema = SchemaRoot.parse(json.getOrThrow("schema", "no schema defined"));

@@ -160,0 +160,0 @@ rules.access = Access.parse(json.getOrWarn("access", "no access list defined, this Firebase will be inactive"));

require('source-map-support').install();
import schema = require('../src/schema');
import blaze = require('./blaze');
import Json = require('./processors/Json');
import Json = require('source-processor');
import expression = require('../src/expression');

@@ -6,0 +6,0 @@ import fs = require('fs');

@@ -8,5 +8,5 @@ require('source-map-support').install();

var Predicate = (function () {
function Predicate(declaration, expression) {
var match = XRegExp.exec(declaration, Predicate.DECLARATION_FORMAT);
var Function = (function () {
function Function(declaration, expression) {
var match = XRegExp.exec(declaration, Function.DECLARATION_FORMAT);
var params = XRegExp.split(match.paramlist, /\s*,\s*/);

@@ -24,37 +24,37 @@

}
Predicate.parse = function (json) {
var predicate;
Function.parse = function (json) {
var fun;
json.asObject().forEach(function (key, val) {
predicate = new Predicate(key.asString().value, val.coerceString());
fun = new Function(key.asString().value, val.coerceString());
});
return predicate;
return fun;
};
Predicate.DECLARATION_FORMAT = XRegExp('(?<name>\\w+) \\s* # name is alphanumeric\n' + '\\( \\s* #open brace for function args \n' + '(?<paramlist> (\\w+\\s*(,\\s*\\w+\\s*)*)?) #comma seperated list of params\n' + '\\) \\s* #close brace for function args \n', 'gx');
return Predicate;
Function.DECLARATION_FORMAT = XRegExp('(?<name>\\w+) \\s* # name is alphanumeric\n' + '\\( \\s* #open brace for function args \n' + '(?<paramlist> (\\w+\\s*(,\\s*\\w+\\s*)*)?) #comma seperated list of params\n' + '\\) \\s* #close brace for function args \n', 'gx');
return Function;
})();
exports.Predicate = Predicate;
exports.Function = Function;
var Predicates = (function () {
function Predicates() {
var Functions = (function () {
function Functions() {
}
Predicates.parse = function (json) {
var predicates = new Predicates();
Functions.parse = function (json) {
var functions = new Functions();
if (json == null)
return predicates;
return functions;
json.asArray().forEach(function (val) {
var predicate = Predicate.parse(val);
predicates[predicate.identifier] = predicate;
var fun = Function.parse(val);
functions[fun.identifier] = fun;
});
return predicates;
return functions;
};
return Predicates;
return Functions;
})();
exports.Predicates = Predicates;
exports.Functions = Functions;
var Symbols = (function () {
function Symbols() {
this.predicates = {};
this.functions = {};
this.variables = {};

@@ -64,4 +64,4 @@ }

var clone = new Symbols();
for (var p in this.predicates)
clone.predicates[p] = this.predicates[p];
for (var p in this.functions)
clone.functions[p] = this.functions[p];
for (var v in this.variables)

@@ -72,5 +72,5 @@ clone.variables[v] = this.variables[v];

Symbols.prototype.loadPredicate = function (predicates) {
for (var identifier in predicates) {
this.predicates[identifier] = predicates[identifier];
Symbols.prototype.loadFunction = function (functions) {
for (var identifier in functions) {
this.functions[identifier] = functions[identifier];
}

@@ -141,3 +141,3 @@ };

node.expr_type = "map";
} else if (symbols.predicates[node.name]) {
} else if (symbols.functions[node.name]) {
node.expr_type = "pred";

@@ -234,5 +234,5 @@ } else if (symbols.variables[node.name]) {

} else if (node.callee.expr_type === "pred") {
var predicate = symbols.predicates[node.callee.name];
var fun = symbols.functions[node.callee.name];
var predicate_symbols = symbols.clone();
var function_symbols = symbols.clone();

@@ -242,7 +242,7 @@ var params = node.arguments;

var p_node = params[p_index];
var local_name = predicate.parameter_map[p_index];
predicate_symbols.variables[local_name] = p_node;
var local_name = fun.parameter_map[p_index];
function_symbols.variables[local_name] = p_node;
}
var expansion = predicate.expression.generate(predicate_symbols);
var expansion = fun.expression.generate(function_symbols);

@@ -249,0 +249,0 @@ node.update("(" + expansion + ")");

/// <reference path="../types/node.d.ts" />
/// <reference path="../node_modules/source-processor/index.d.ts" />
require('source-map-support').install();

@@ -7,4 +8,4 @@ var falafel = require("falafel");

import Json = require('./processors/Json');
import error = require('./error');
import Json = require('source-processor');
import error = require('source-processor');
import optimizer = require('../src/optimizer');

@@ -15,3 +16,3 @@

export class Predicate{
export class Function {
identifier: string; //the function name

@@ -31,3 +32,3 @@ signature: string; //the function name, and the number of params, e.g. f(x) signature is f(0)

//break the function declaration into its parts
var match = XRegExp.exec(declaration, Predicate.DECLARATION_FORMAT);
var match = XRegExp.exec(declaration, Function.DECLARATION_FORMAT);
var params = XRegExp.split(match.paramlist, /\s*,\s*/);

@@ -48,12 +49,12 @@

static parse(json: Json.JValue): Predicate{
//console.log("Predicate.parse:", json);
var predicate: Predicate;
static parse(json: Json.JValue): Function {
//console.log("Function.parse:", json);
var fun: Function;
//there should only be one entry
json.asObject().forEach(function(key: Json.JString, val: Json.JValue) {
predicate = new Predicate(key.asString().value, val.coerceString());
fun = new Function(key.asString().value, val.coerceString());
});
return predicate
return fun
}

@@ -63,17 +64,17 @@ }

/**
* instances support indexing like arrays, which maps cannocal predicate declarations to Predicate definitions
* instances support indexing like arrays, which maps cannocal function declarations to Function definitions
*/
export class Predicates{
[index: string]: Predicate;
export class Functions {
[index: string]: Function;
static parse(json: Json.JValue):Predicates{
//console.log("Predicates.parse:", json);
var predicates = new Predicates();
if (json == null) return predicates;
static parse(json: Json.JValue): Functions{
//console.log("Functions.parse:", json);
var functions = new Functions();
if (json == null) return functions;
json.asArray().forEach(function(val: Json.JValue) {
var predicate:Predicate = Predicate.parse(val);
predicates[predicate.identifier] = predicate;
var fun: Function = Function.parse(val);
functions[fun.identifier] = fun;
});
return predicates
return functions
}

@@ -83,8 +84,8 @@ }

export class Symbols{
predicates: {[index: string]: Predicate} = {};
variables: {[index: string]: any} = {}; //string->AST node
functions: {[index: string]: Function} = {};
variables: {[index: string]: any} = {}; //string->AST node
clone():Symbols{
var clone:Symbols = new Symbols()
for(var p in this.predicates)clone.predicates[p] = this.predicates[p];
var clone: Symbols = new Symbols();
for(var p in this.functions) clone.functions[p] = this.functions[p];
for(var v in this.variables) clone.variables[v] = this.variables[v];

@@ -94,5 +95,5 @@ return clone;

loadPredicate(predicates:Predicates){
for(var identifier in predicates){
this.predicates[identifier] = predicates[identifier];
loadFunction(functions: Functions){
for(var identifier in functions){
this.functions[identifier] = functions[identifier];
}

@@ -159,3 +160,3 @@ }

generate(symbols:Symbols):string {
generate(symbols: Symbols):string {
//the falafel visitor function replaces source with a different construction

@@ -181,3 +182,3 @@ var falafel_visitor = function(node){

node.expr_type = "map"
}else if(symbols.predicates[node.name]){
}else if(symbols.functions[node.name]){
node.expr_type = "pred"

@@ -307,7 +308,7 @@ }else if(symbols.variables[node.name]){

//console.log(node)
//we are calling a user defined predicate
var predicate:Predicate = symbols.predicates[node.callee.name];
//we are calling a user defined function
var fun: Function = symbols.functions[node.callee.name];
//clone the global symbol table and populate with binding to parameters
var predicate_symbols = symbols.clone();
var function_symbols = symbols.clone();

@@ -317,7 +318,7 @@ var params = node.arguments;

var p_node = params[p_index];
var local_name = predicate.parameter_map[p_index];
predicate_symbols.variables[local_name] = p_node;
var local_name = fun.parameter_map[p_index];
function_symbols.variables[local_name] = p_node;
}
var expansion = predicate.expression.generate(predicate_symbols);
var expansion = fun.expression.generate(function_symbols);

@@ -324,0 +325,0 @@ node.update("(" + expansion + ")");

@@ -7,4 +7,4 @@ require('source-map-support').install();

var fs = require('fs');
var Json = require('./processors/Json');
var error = require('./error');
var Json = require('source-processor');
var error = require('source-processor');

@@ -40,3 +40,3 @@ exports.debug = true;

var symbols = new expression.Symbols();
symbols.loadPredicate(model.predicates);
symbols.loadFunction(model.functions);

@@ -43,0 +43,0 @@ model.schema.root.generate(symbols, " ", buffer);

@@ -7,4 +7,4 @@ require('source-map-support').install();

import fs = require('fs');
import Json = require('./processors/Json');
import error = require('./error');
import Json = require('source-processor');
import error = require('source-processor');

@@ -57,3 +57,3 @@ //todo

var symbols = new expression.Symbols();
symbols.loadPredicate(model.predicates);
symbols.loadFunction(model.functions);

@@ -63,3 +63,3 @@ model.schema.root.generate(symbols, " ", buffer);

//convert buffer into big string
var code:string = buffer.join('');
var code: string = buffer.join('');
return code;

@@ -402,3 +402,3 @@ }

/**
* provides hooks for meta-data to pragmatically generate constraints and predicates
* provides hooks for meta-data to pragmatically generate constraints and functions
*/

@@ -405,0 +405,0 @@ export class SchemaAPI{

@@ -17,5 +17,5 @@ var test_utils = require('./test_utils');

function testPredicate_access(test) {
function testFunction_access(test) {
async.series([
firebase_io.setValidationRules.bind(null, compiler.compile("test/cases/predicate_access.yaml", true).code),
firebase_io.setValidationRules.bind(null, compiler.compile("test/cases/function_access.yaml", true).code),
test_utils.assert_cant_write.bind(null, "tom", "/", "string", test),

@@ -27,3 +27,3 @@ test_utils.assert_can_write.bind(null, "not", "/", "string", test),

}
exports.testPredicate_access = testPredicate_access;
exports.testFunction_access = testFunction_access;

@@ -30,0 +30,0 @@ function testAccess(test) {

@@ -19,5 +19,5 @@ /// <reference path="../types/nodeunit.d.ts" />

export function testPredicate_access(test:nodeunit.Test):void{
export function testFunction_access(test:nodeunit.Test):void{
async.series([
firebase_io.setValidationRules.bind(null, compiler.compile("test/cases/predicate_access.yaml", true).code),
firebase_io.setValidationRules.bind(null, compiler.compile("test/cases/function_access.yaml", true).code),
test_utils.assert_cant_write.bind(null, "tom", "/", "string", test),

@@ -24,0 +24,0 @@ test_utils.assert_can_write.bind (null, "not", "/", "string", test),

var expressions = require('../src/expression');
var Json = require('../src/processors/Json');
var Json = require('source-processor');
function translationTestCase(from, to, predicates, test) {
function translationTestCase(from, to, functions, test) {
var expr = expressions.Expression.parse(from);
var symbols = new expressions.Symbols();
symbols.predicates = predicates;
symbols.functions = functions;
var translation = expr.generate(symbols);

@@ -15,3 +15,3 @@

function testArrayLookup1(test) {
translationTestCase("next['c1'].val()", "newData.child('c1').val()", new expressions.Predicates(), test);
translationTestCase("next['c1'].val()", "newData.child('c1').val()", new expressions.Functions(), test);
test.done();

@@ -22,3 +22,3 @@ }

function testArrayLookup2(test) {
translationTestCase("next.c1.val()", "newData.child('c1').val()", new expressions.Predicates(), test);
translationTestCase("next.c1.val()", "newData.child('c1').val()", new expressions.Functions(), test);
test.done();

@@ -29,3 +29,3 @@ }

function testArrayLookup3(test) {
translationTestCase("next[prev.val()].val()", "newData.child(data.val()).val()", new expressions.Predicates(), test);
translationTestCase("next[prev.val()].val()", "newData.child(data.val()).val()", new expressions.Functions(), test);
test.done();

@@ -36,3 +36,3 @@ }

function testArrayLookup4(test) {
translationTestCase("next[prev].val()", "newData.child(data.val()).val()", new expressions.Predicates(), test);
translationTestCase("next[prev].val()", "newData.child(data.val()).val()", new expressions.Functions(), test);
test.done();

@@ -43,3 +43,3 @@ }

function testArrayLookup5(test) {
translationTestCase("next[prev.child].val()", "newData.child(data.child('child').val()).val()", new expressions.Predicates(), test);
translationTestCase("next[prev.child].val()", "newData.child(data.child('child').val()).val()", new expressions.Functions(), test);
test.done();

@@ -50,3 +50,3 @@ }

function testArrayLookup6(test) {
translationTestCase("next[prev[child]].val()", "newData.child(data.child('child').val()).val()", new expressions.Predicates(), test);
translationTestCase("next[prev[child]].val()", "newData.child(data.child('child').val()).val()", new expressions.Functions(), test);
test.done();

@@ -57,3 +57,3 @@ }

function testArrayLookup7(test) {
translationTestCase("next[prev[child]]['fred'].val()", "newData.child(data.child('child').val()).child('fred').val()", new expressions.Predicates(), test);
translationTestCase("next[prev[child]]['fred'].val()", "newData.child(data.child('child').val()).child('fred').val()", new expressions.Functions(), test);
test.done();

@@ -64,3 +64,3 @@ }

function testParent1(test) {
translationTestCase("next.parent()", "newData.parent()", new expressions.Predicates(), test);
translationTestCase("next.parent()", "newData.parent()", new expressions.Functions(), test);
test.done();

@@ -71,3 +71,3 @@ }

function testParent2(test) {
translationTestCase("next[prev.parent().val()]['blah'].c1.val()", "newData.child(data.parent().val()).child('blah').child('c1').val()", new expressions.Predicates(), test);
translationTestCase("next[prev.parent().val()]['blah'].c1.val()", "newData.child(data.parent().val()).child('blah').child('c1').val()", new expressions.Functions(), test);
test.done();

@@ -78,3 +78,3 @@ }

function testHasChildren(test) {
translationTestCase("next.c1.hasChildren(['eric'])", "newData.child('c1').hasChildren(['eric'])", new expressions.Predicates(), test);
translationTestCase("next.c1.hasChildren(['eric'])", "newData.child('c1').hasChildren(['eric'])", new expressions.Functions(), test);
test.done();

@@ -85,3 +85,3 @@ }

function testContains1(test) {
translationTestCase("next.c1.val().contains('yo')", "newData.child('c1').val().contains('yo')", new expressions.Predicates(), test);
translationTestCase("next.c1.val().contains('yo')", "newData.child('c1').val().contains('yo')", new expressions.Functions(), test);
test.done();

@@ -92,3 +92,3 @@ }

function testContains2(test) {
translationTestCase("'yo'.contains('yo')", "'yo'.contains('yo')", new expressions.Predicates(), test);
translationTestCase("'yo'.contains('yo')", "'yo'.contains('yo')", new expressions.Functions(), test);
test.done();

@@ -99,3 +99,3 @@ }

function testContains3(test) {
translationTestCase("'yo'.contains(prev.val())", "'yo'.contains(data.val())", new expressions.Predicates(), test);
translationTestCase("'yo'.contains(prev.val())", "'yo'.contains(data.val())", new expressions.Functions(), test);
test.done();

@@ -106,3 +106,3 @@ }

function testAuth1(test) {
translationTestCase("auth.id", "auth.id", new expressions.Predicates(), test);
translationTestCase("auth.id", "auth.id", new expressions.Functions(), test);
test.done();

@@ -113,3 +113,3 @@ }

function testAuth2(test) {
translationTestCase("root.users[auth.id]", "root.child('users').child(auth.id)", new expressions.Predicates(), test);
translationTestCase("root.users[auth.id]", "root.child('users').child(auth.id)", new expressions.Functions(), test);
test.done();

@@ -120,3 +120,3 @@ }

function testCoercion1(test) {
translationTestCase("root.superuser == auth.id", "root.child('superuser').val()==auth.id", new expressions.Predicates(), test);
translationTestCase("root.superuser == auth.id", "root.child('superuser').val()==auth.id", new expressions.Functions(), test);
test.done();

@@ -127,3 +127,3 @@ }

function testCoercion2(test) {
translationTestCase("auth.id == root[next]", "auth.id==root.child(newData.val()).val()", new expressions.Predicates(), test);
translationTestCase("auth.id == root[next]", "auth.id==root.child(newData.val()).val()", new expressions.Functions(), test);
test.done();

@@ -134,3 +134,3 @@ }

function test$var1(test) {
translationTestCase("auth.id == $userid", "auth.id==$userid", new expressions.Predicates(), test);
translationTestCase("auth.id == $userid", "auth.id==$userid", new expressions.Functions(), test);
test.done();

@@ -141,3 +141,3 @@ }

function test$var3(test) {
translationTestCase("prev[$userid].val()", "data.child($userid).val()", new expressions.Predicates(), test);
translationTestCase("prev[$userid].val()", "data.child($userid).val()", new expressions.Functions(), test);
test.done();

@@ -148,3 +148,3 @@ }

function test$var4(test) {
translationTestCase("prev.$userid.val()", "data.child($userid).val()", new expressions.Predicates(), test);
translationTestCase("prev.$userid.val()", "data.child($userid).val()", new expressions.Functions(), test);
test.done();

@@ -155,3 +155,3 @@ }

function testNow(test) {
translationTestCase("next < now", "newData.val()<now", new expressions.Predicates(), test);
translationTestCase("next < now", "newData.val()<now", new expressions.Functions(), test);
test.done();

@@ -162,3 +162,3 @@ }

function testRoot(test) {
translationTestCase("root.users[auth.id].active == true", "root.child('users').child(auth.id).child('active').val()==true", new expressions.Predicates(), test);
translationTestCase("root.users[auth.id].active == true", "root.child('users').child(auth.id).child('active').val()==true", new expressions.Functions(), test);
test.done();

@@ -169,3 +169,3 @@ }

function testHasChild(test) {
translationTestCase("next.hasChild('name')", "newData.hasChild('name')", new expressions.Predicates(), test);
translationTestCase("next.hasChild('name')", "newData.hasChild('name')", new expressions.Functions(), test);
test.done();

@@ -176,3 +176,3 @@ }

function testHasChildren1(test) {
translationTestCase("next.hasChildren()", "newData.hasChildren()", new expressions.Predicates(), test);
translationTestCase("next.hasChildren()", "newData.hasChildren()", new expressions.Functions(), test);
test.done();

@@ -183,3 +183,3 @@ }

function testHasChildren2(test) {
translationTestCase("next.hasChildren(['name', 'age'])", "newData.hasChildren(['name', 'age'])", new expressions.Predicates(), test);
translationTestCase("next.hasChildren(['name', 'age'])", "newData.hasChildren(['name', 'age'])", new expressions.Functions(), test);
test.done();

@@ -190,3 +190,3 @@ }

function testGetPriority(test) {
translationTestCase("next.getPriority() != null", "newData.getPriority()!=null", new expressions.Predicates(), test);
translationTestCase("next.getPriority() != null", "newData.getPriority()!=null", new expressions.Functions(), test);
test.done();

@@ -197,3 +197,3 @@ }

function testLength(test) {
translationTestCase("next.isString()&&next.val().length>=10", "newData.isString()&&newData.val().length>=10", new expressions.Predicates(), test);
translationTestCase("next.isString()&&next.val().length>=10", "newData.isString()&&newData.val().length>=10", new expressions.Functions(), test);
test.done();

@@ -204,3 +204,3 @@ }

function testBeginsWith(test) {
translationTestCase("auth.identifier.beginsWith('internal-')", "auth.identifier.beginsWith('internal-')", new expressions.Predicates(), test);
translationTestCase("auth.identifier.beginsWith('internal-')", "auth.identifier.beginsWith('internal-')", new expressions.Functions(), test);
test.done();

@@ -211,3 +211,3 @@ }

function testEndsWith(test) {
translationTestCase("next.val().endsWith('internal-')", "newData.val().endsWith('internal-')", new expressions.Predicates(), test);
translationTestCase("next.val().endsWith('internal-')", "newData.val().endsWith('internal-')", new expressions.Functions(), test);
test.done();

@@ -218,3 +218,3 @@ }

function testReplace(test) {
translationTestCase("root.users[auth.email.replace('.', ',')].exists()", "root.child('users').child(auth.email.replace('.', ',')).exists()", new expressions.Predicates(), test);
translationTestCase("root.users[auth.email.replace('.', ',')].exists()", "root.child('users').child(auth.email.replace('.', ',')).exists()", new expressions.Functions(), test);
test.done();

@@ -225,3 +225,3 @@ }

function testToLowerCase(test) {
translationTestCase("root.users[auth.identifier.toLowerCase()].exists()", "root.child('users').child(auth.identifier.toLowerCase()).exists()", new expressions.Predicates(), test);
translationTestCase("root.users[auth.identifier.toLowerCase()].exists()", "root.child('users').child(auth.identifier.toLowerCase()).exists()", new expressions.Functions(), test);
test.done();

@@ -232,3 +232,3 @@ }

function testToUpperCase(test) {
translationTestCase("root.users[auth.identifier.toUpperCase()].exists()", "root.child('users').child(auth.identifier.toUpperCase()).exists()", new expressions.Predicates(), test);
translationTestCase("root.users[auth.identifier.toUpperCase()].exists()", "root.child('users').child(auth.identifier.toUpperCase()).exists()", new expressions.Functions(), test);
test.done();

@@ -238,8 +238,8 @@ }

function Predicate(dec, expr) {
return new expressions.Predicate(dec, new Json.JString(expr, 0, 0));
function Function(dec, expr) {
return new expressions.Function(dec, new Json.JString(expr, 0, 0));
}
function testPredicateParsing1(test) {
var predicate = Predicate("f(x)", "true");
function testFunctionParsing1(test) {
var predicate = Function("f(x)", "true");

@@ -249,5 +249,5 @@ test.ok(predicate.signature == "f(1)");

}
exports.testPredicateParsing1 = testPredicateParsing1;
function testPredicateParsing2(test) {
var predicate = Predicate("f()", "true");
exports.testFunctionParsing1 = testFunctionParsing1;
function testFunctionParsing2(test) {
var predicate = Function("f()", "true");

@@ -257,5 +257,5 @@ test.ok(predicate.signature == "f(0)");

}
exports.testPredicateParsing2 = testPredicateParsing2;
function testPredicateParsing3(test) {
var predicate = Predicate("f(x, y)", "true");
exports.testFunctionParsing2 = testFunctionParsing2;
function testFunctionParsing3(test) {
var predicate = Function("f(x, y)", "true");
test.equals(predicate.signature, "f(2)");

@@ -265,24 +265,24 @@ test.deepEqual(predicate.parameter_map, ['x', 'y']);

}
exports.testPredicateParsing3 = testPredicateParsing3;
exports.testFunctionParsing3 = testFunctionParsing3;
function testPredicate1(test) {
translationTestCase("isLoggedIn()", "(auth.id==null)", expressions.Predicates.parse(Json.parse('[{"isLoggedIn()":"auth.id == null"}]')), test);
function testFunction1(test) {
translationTestCase("isLoggedIn()", "(auth.id==null)", expressions.Functions.parse(Json.parse('[{"isLoggedIn()":"auth.id == null"}]')), test);
test.done();
}
exports.testPredicate1 = testPredicate1;
exports.testFunction1 = testFunction1;
function testPredicate2(test) {
translationTestCase("isEqual(prev, next.name)", "(data.val()==newData.child('name').val())", expressions.Predicates.parse(Json.parse('[{"isEqual(a, b)":"a == b"}]')), test);
function testFunction2(test) {
translationTestCase("isEqual(prev, next.name)", "(data.val()==newData.child('name').val())", expressions.Functions.parse(Json.parse('[{"isEqual(a, b)":"a == b"}]')), test);
test.done();
}
exports.testPredicate2 = testPredicate2;
exports.testFunction2 = testFunction2;
function testPredicate3(test) {
translationTestCase("isLoggedIn(auth)", "(auth.id=='yo')", expressions.Predicates.parse(Json.parse('[{"isLoggedIn(q)":"q.id == \'yo\'"}]')), test);
function testFunction3(test) {
translationTestCase("isLoggedIn(auth)", "(auth.id=='yo')", expressions.Functions.parse(Json.parse('[{"isLoggedIn(q)":"q.id == \'yo\'"}]')), test);
test.done();
}
exports.testPredicate3 = testPredicate3;
exports.testFunction3 = testFunction3;
function testUnary(test) {
translationTestCase("!isLoggedIn(auth)", "!(auth.id=='yo')", expressions.Predicates.parse(Json.parse('[{"isLoggedIn(q)":"q.id == \'yo\'"}]')), test);
translationTestCase("!isLoggedIn(auth)", "!(auth.id=='yo')", expressions.Functions.parse(Json.parse('[{"isLoggedIn(q)":"q.id == \'yo\'"}]')), test);
test.done();

@@ -293,3 +293,3 @@ }

function testSanitizeQuotes1(test) {
translationTestCase("\"string\"=='string'", "\"string\"=='string'", new expressions.Predicates(), test);
translationTestCase("\"string\"=='string'", "\"string\"=='string'", new expressions.Functions(), test);
test.done();

@@ -300,3 +300,3 @@ }

function testSanitizeQuotes2(test) {
translationTestCase("next['string'] == prev[\"string\"]", 'newData.child(\'string\').val()==data.child("string").val()', new expressions.Predicates(), test);
translationTestCase("next['string'] == prev[\"string\"]", 'newData.child(\'string\').val()==data.child("string").val()', new expressions.Functions(), test);
test.done();

@@ -303,0 +303,0 @@ }

/// <reference path="../types/nodeunit.d.ts" />
/// <reference path="../src/expression.ts" />
import expressions = require('../src/expression');
import Json = require('../src/processors/Json');
import Json = require('source-processor');
function translationTestCase(from:string, to:string, predicates: expressions.Predicates, test:nodeunit.Test){
function translationTestCase(from:string, to:string, functions: expressions.Functions, test:nodeunit.Test){
var expr = expressions.Expression.parse(from);
var symbols:expressions.Symbols = new expressions.Symbols();
symbols.predicates = predicates;
symbols.functions = functions;
var translation = expr.generate(symbols);

@@ -21,3 +21,3 @@

"newData.child('c1').val()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -32,3 +32,3 @@ );

"newData.child('c1').val()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -43,3 +43,3 @@ );

"newData.child(data.val()).val()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -54,3 +54,3 @@ );

"newData.child(data.val()).val()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -65,3 +65,3 @@ );

"newData.child(data.child('child').val()).val()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -76,3 +76,3 @@ );

"newData.child(data.child('child').val()).val()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -87,3 +87,3 @@ );

"newData.child(data.child('child').val()).child('fred').val()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -98,3 +98,3 @@ );

"newData.parent()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -109,3 +109,3 @@ );

"newData.child(data.parent().val()).child('blah').child('c1').val()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -120,3 +120,3 @@ );

"newData.child('c1').hasChildren(['eric'])",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -132,3 +132,3 @@ );

"newData.child('c1').val().contains('yo')",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -143,3 +143,3 @@ );

"'yo'.contains('yo')",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -154,3 +154,3 @@ );

"'yo'.contains(data.val())",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -166,3 +166,3 @@ );

"auth.id",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -177,3 +177,3 @@ );

"root.child('users').child(auth.id)",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -188,3 +188,3 @@ );

"root.child('superuser').val()==auth.id",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -199,3 +199,3 @@ );

"auth.id==root.child(newData.val()).val()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -210,3 +210,3 @@ );

"auth.id==$userid",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -221,3 +221,3 @@ );

"data.child($userid).val()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -233,3 +233,3 @@ );

"data.child($userid).val()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -245,3 +245,3 @@ );

"newData.val()<now",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -257,3 +257,3 @@ );

"root.child('users').child(auth.id).child('active').val()==true",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -269,3 +269,3 @@ );

"newData.hasChild('name')",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -281,3 +281,3 @@ );

"newData.hasChildren()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -293,3 +293,3 @@ );

"newData.hasChildren(['name', 'age'])",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -305,3 +305,3 @@ );

"newData.getPriority()!=null",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -317,3 +317,3 @@ );

"newData.isString()&&newData.val().length>=10",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -329,3 +329,3 @@ );

"auth.identifier.beginsWith('internal-')",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -341,3 +341,3 @@ );

"newData.val().endsWith('internal-')",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -353,3 +353,3 @@ );

"root.child('users').child(auth.email.replace('.', ',')).exists()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -365,3 +365,3 @@ );

"root.child('users').child(auth.identifier.toLowerCase()).exists()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -377,3 +377,3 @@ );

"root.child('users').child(auth.identifier.toUpperCase()).exists()",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -384,8 +384,8 @@ );

function Predicate(dec: string, expr: string): expressions.Predicate {
return new expressions.Predicate(dec, new Json.JString(expr, 0, 0))
function Function(dec: string, expr: string): expressions.Function {
return new expressions.Function(dec, new Json.JString(expr, 0, 0))
}
export function testPredicateParsing1(test){
var predicate = Predicate("f(x)", "true");
export function testFunctionParsing1(test){
var predicate = Function("f(x)", "true");

@@ -395,4 +395,4 @@ test.ok(predicate.signature == "f(1)");

}
export function testPredicateParsing2(test){
var predicate = Predicate("f()", "true");
export function testFunctionParsing2(test){
var predicate = Function("f()", "true");

@@ -402,4 +402,4 @@ test.ok(predicate.signature == "f(0)");

}
export function testPredicateParsing3(test){
var predicate = Predicate("f(x, y)", "true");
export function testFunctionParsing3(test){
var predicate = Function("f(x, y)", "true");
test.equals(predicate.signature, "f(2)");

@@ -410,3 +410,3 @@ test.deepEqual(predicate.parameter_map, ['x', 'y']);

export function testPredicate1(test:nodeunit.Test):void{
export function testFunction1(test:nodeunit.Test):void{
//bit weird this works

@@ -416,3 +416,3 @@ translationTestCase(

"(auth.id==null)",
expressions.Predicates.parse(
expressions.Functions.parse(
Json.parse('[{"isLoggedIn()":"auth.id == null"}]')

@@ -425,3 +425,3 @@ ),

export function testPredicate2(test:nodeunit.Test):void{
export function testFunction2(test:nodeunit.Test):void{
//bit weird this works

@@ -431,3 +431,3 @@ translationTestCase(

"(data.val()==newData.child('name').val())",
expressions.Predicates.parse(
expressions.Functions.parse(
Json.parse('[{"isEqual(a, b)":"a == b"}]')

@@ -440,3 +440,3 @@ ),

export function testPredicate3(test:nodeunit.Test):void{
export function testFunction3(test:nodeunit.Test):void{
//bit weird this works

@@ -446,3 +446,3 @@ translationTestCase(

"(auth.id=='yo')",
expressions.Predicates.parse(
expressions.Functions.parse(
Json.parse('[{"isLoggedIn(q)":"q.id == \'yo\'"}]')

@@ -460,3 +460,3 @@ ),

"!(auth.id=='yo')",
expressions.Predicates.parse(
expressions.Functions.parse(
Json.parse('[{"isLoggedIn(q)":"q.id == \'yo\'"}]')

@@ -474,3 +474,3 @@ ),

"\"string\"=='string'",
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -486,3 +486,3 @@ );

'newData.child(\'string\').val()==data.child("string").val()',
new expressions.Predicates(),
new expressions.Functions(),
test

@@ -489,0 +489,0 @@ );

var blaze = require('../src/blaze');
var Json = require('../src/processors/Json');
var Json = require('source-processor');

@@ -4,0 +4,0 @@ function testEntryParseRoot1(test) {

/// <reference path="../types/nodeunit.d.ts" />
import blaze = require('../src/blaze');
import Json = require('../src/processors/Json');
import Json = require('source-processor');

@@ -5,0 +5,0 @@ export function testEntryParseRoot1(test) {

@@ -5,3 +5,3 @@ var fs = require("fs");

var compiler = require('../src/compiler');
var Json = require('../src/processors/Json');
var Json = require('source-processor');
var tv4 = require("tv4");

@@ -34,3 +34,3 @@

test.ok(rule.schema != null);
test.ok(rule.predicates["isLoggedIn"] != null);
test.ok(rule.functions["isLoggedIn"] != null);
test.done();

@@ -37,0 +37,0 @@ }

@@ -9,3 +9,3 @@ /// <reference path="../types/nodeunit.d.ts" />

import compiler = require('../src/compiler');
import Json = require('../src/processors/Json');
import Json = require('source-processor');
import tv4 = require("tv4");

@@ -38,3 +38,3 @@

test.ok(rule.schema != null);
test.ok(rule.predicates["isLoggedIn"] != null);
test.ok(rule.functions["isLoggedIn"] != null);
test.done();

@@ -41,0 +41,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc