From d2202f700e45eb07a5645b91a5a969dd1d9ea2df Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 15 Mar 2017 21:27:09 -0300 Subject: [PATCH 001/625] Add rethinkdb npm pkg --- rethinkdb/.gitignore | 4 + rethinkdb/.npmignore | 0 rethinkdb/.npmrc | 2 + rethinkdb/.yarnrc | 3 + rethinkdb/build_and_publish.sh | 9 + rethinkdb/package.json | 29 + rethinkdb/rethinkdb.ts | 256 +++++ rethinkdb/tsconfig.json | 18 + rethinkdb/yarn.lock | 1622 ++++++++++++++++++++++++++++++++ 9 files changed, 1943 insertions(+) create mode 100644 rethinkdb/.gitignore create mode 100644 rethinkdb/.npmignore create mode 100644 rethinkdb/.npmrc create mode 100644 rethinkdb/.yarnrc create mode 100644 rethinkdb/build_and_publish.sh create mode 100644 rethinkdb/package.json create mode 100644 rethinkdb/rethinkdb.ts create mode 100644 rethinkdb/tsconfig.json create mode 100644 rethinkdb/yarn.lock diff --git a/rethinkdb/.gitignore b/rethinkdb/.gitignore new file mode 100644 index 0000000..00d619b --- /dev/null +++ b/rethinkdb/.gitignore @@ -0,0 +1,4 @@ +node_modules +rethinkdb.js +rethinkdb.js.map +rethinkdb.d.ts \ No newline at end of file diff --git a/rethinkdb/.npmignore b/rethinkdb/.npmignore new file mode 100644 index 0000000..e69de29 diff --git a/rethinkdb/.npmrc b/rethinkdb/.npmrc new file mode 100644 index 0000000..7173932 --- /dev/null +++ b/rethinkdb/.npmrc @@ -0,0 +1,2 @@ +registry=https://npm.cubos.io/ +//npm.cubos.io/:_authToken="P3LrfpI49SpXsspIMpzItQ==" diff --git a/rethinkdb/.yarnrc b/rethinkdb/.yarnrc new file mode 100644 index 0000000..d51da20 --- /dev/null +++ b/rethinkdb/.yarnrc @@ -0,0 +1,3 @@ +registry "https://npm.cubos.io/" +email tech@cubos.io +username cubos diff --git a/rethinkdb/build_and_publish.sh b/rethinkdb/build_and_publish.sh new file mode 100644 index 0000000..0ce620b --- /dev/null +++ b/rethinkdb/build_and_publish.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +VERSION=1.0.$1 + +export PATH=$(npm bin):$PATH +npm version $VERSION || true +tsc +babel api.js -o api.js +npm publish diff --git a/rethinkdb/package.json b/rethinkdb/package.json new file mode 100644 index 0000000..781837c --- /dev/null +++ b/rethinkdb/package.json @@ -0,0 +1,29 @@ +{ + "name": "@cubos/rethinkdb", + "version": "0.0", + "dependencies": { + "@types/node": "^7.0.8", + "babel-runtime": "^6.23.0", + "rethinkdbdash": "^2.3.28" + }, + "main": "api.js", + "types": "api.d.ts", + "babel": { + "plugins": [ + "transform-runtime" + ], + "presets": [ + "babel-preset-es2015", + "babel-preset-es2016", + "babel-preset-es2017" + ] + }, + "devDependencies": { + "babel-cli": "^6.23.0", + "babel-plugin-transform-runtime": "^6.23.0", + "babel-preset-es2015": "^6.22.0", + "babel-preset-es2016": "^6.22.0", + "babel-preset-es2017": "^6.22.0", + "typescript": "^2.2.1" + } +} diff --git a/rethinkdb/rethinkdb.ts b/rethinkdb/rethinkdb.ts new file mode 100644 index 0000000..32a2e3a --- /dev/null +++ b/rethinkdb/rethinkdb.ts @@ -0,0 +1,256 @@ + +let r: R; + +export default function(db: string) { + r = require("rethinkdbdash")({ + db: db, + pingInterval: 20, + servers: [{ + host: "rethinkdb", + port: 28015 + }] + }); + + return r; +} + +export interface Description { + [name: string]: { + indices?: any[] + } +} + +export async function updateDb(dbDescr: any) { + const tables = Object.keys(dbDescr); + const realTables = await r.tableList(); + + for (let i = 0; i < realTables.length; ++i) { + if (tables.indexOf(realTables[i]) >= 0) continue; + console.log(`Dropping table ${realTables[i]}...`); + await r.tableDrop(realTables[i]); + } + + for (let i = 0; i < tables.length; ++i) { + const table = tables[i]; + if (realTables.indexOf(table) < 0) { + console.log(`Creating table ${table}...`); + await r.tableCreate(table); + } + + const indicesCreationFunc = dbDescr[table].indices || []; + const indices = indicesCreationFunc.map((creationFunc: any) => { + const match = /^r\.table\("([^"]+)"\)\.indexCreate\("([^"]+)"/.exec(creationFunc.toString()); + if (match === null) + throw "Invalid index expression: creationFunc.toString()"; + if (match[1] !== table) + throw `Invalid index expression: Should use table ${table}, but uses ${match[1]}: creationFunc.toString()`; + + return match[2]; + }); + + const realIndices = await r.table(table).indexList(); + + for (let i = 0; i < realIndices.length; ++i) { + if (indices.indexOf(realIndices[i]) >= 0) continue; + console.log(`Dropping index ${table}.${realIndices[i]}...`); + await r.table(table).indexDrop(realIndices[i]); + } + + for (let i = 0; i < indices.length; ++i) { + if (realIndices.indexOf(indices[i]) < 0) { + console.log(`Creating index ${table}.${indices[i]}...`); + await indicesCreationFunc[i]; + } else { + const status = await r.table(table).indexStatus(indices[i])(0); + + let realDescr = status.query; + let descr = indicesCreationFunc[i].toString(); + + { + const match = /(function[\s\S]*\})/.exec(realDescr); + if (!match) throw `Index function doesn't contain a function??? ${JSON.stringify(realDescr)}`; + realDescr = match[1]; + } + + { + const match = /(function[\s\S]*\})/.exec(descr); + if (!match) descr = `function (var_1) { return var_1("${indices[i]}") }`; + else descr = match[1]; + } + + realDescr = global["eval"](`(${realDescr})`).toString(); + descr = global["eval"](`(${descr})`).toString(); + + descr = descr.replace(/\n\s*/g, " "); + realDescr = realDescr.replace(/\.getField/g, ""); + realDescr = realDescr.replace(/;/g, ""); + const varMapping: {[orig: string]: string} = {}; + const varMatches = /(_?var\d+)/.exec(realDescr) || []; + for (let i = 0; i < varMatches.length; ++i) { + if (varMapping[varMatches[i]] === undefined) { + varMapping[varMatches[i]] = "var_" + (Object.keys(varMapping).length + 1); + } + realDescr = realDescr.replace(varMatches[i], varMapping[varMatches[i]]); + } + + if (realDescr !== descr) { + console.log(`Recreating index ${table}.${indices[i]}...`); + await r.table(table).indexDrop(indices[i]); + await indicesCreationFunc[i]; + } + } + } + } + + console.log("Database structure is ready"); +} + +export interface R extends RDB { + db(name: string): RDB + expr(obj: any): RDatum + uuid(): RDatum + range(): RStream + range(count: number): RStream + range(initial: number, count: number): RStream + epochTime(epoch: number): RDatum +} + +export interface RDB { + table(name: string): RTable + tableList(): RArray + tableDrop(name: string): RDatum<{tables_dropped: 1, config_changes: {old_val: R_TableConfig, new_val: null}}> + tableCreate(name: string, opts?: R_TableCreateOptions): RDatum<{tables_created: 1, config_changes: {old_val: null, new_val: R_TableConfig}}> +} + +export type RPrimitive = null | string | number | Date | boolean | Buffer + +export type RDatumfy = { + [P in keyof T]: T[P] | RDatum; +}; + +export interface R_TableConfig { + +} + +export interface R_TableCreateOptions { + primaryKey?: string + durability?: "soft" | "hard" + shards?: number + replicas?: number | {[server: string]: number} + primaryReplicaTag?: string +} + +export interface RStreamOrDatum { + count(): RDatum + avg(): RDatum + min(): RDatum + max(): RDatum + orderBy(field: string): RArray +} + +export interface RDatum extends RStreamOrDatum, PromiseLike { + do(func: (obj: this) => X): RDatum + do(func: (obj: this) => any): RDatum + default(val: X): RDatum + default(val: any): RDatum + (idx: K): RDatum + (idx: number | RDatum): RDatum + merge(op: (e: RDatum) => any): RDatum + merge(op: any): RDatum + map(func: (e: RDatum) => any): RArray + sub(other: any): RDatum + add(...others: any[]): RDatum + append(other: any): RDatum +} + +export interface RArray extends RDatum { + (idx: number | RDatum): RDatum + map(func: (e: RDatum) => any): RArray + orderBy(field: string): RArray + append(other: T): RArray +} + +export interface RStream extends PromiseLike, RStreamOrDatum { + (idx: number): RDatum + map(func: (arg: RDatum) => any): RStream + orderBy(field: string): RArray + coerceTo(type: "array"): RArray +} + +export interface R_UpdateOptions { + durability?: "hard" | "soft" + returnChanges?: true | false | "always" + nonAtomic?: boolean +} + +export interface R_UpdateResult { + replaced: number + unchanged: number + skipped: number + errors: number + first_error?: string + deleted: 0 + inserted: 0 +} + +export type RUpdateObj = Partial | RDatum | ((obj: RDatum) => any) + +export interface RTableSlice extends RStream { + update(obj: RUpdateObj, options: Opts): RDatum + update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum + delete(): RDatum<{}> +} + +export interface RTableRow extends RDatum { + update(obj: RUpdateObj, options: Opts): RDatum + update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum + delete(): RDatum<{}> +} + +export interface R_InsertOptions { + durability?: "hard" | "soft" + returnChanges?: true | false | "always" + conflict?: "error" | "replace" | "update" | ((id: string, oldDoc: RDatum, newDoc: RDatum) => any) +} + +export interface R_InsertResult { + inserted: number + replaced: number + unchanged: number + errors: number + first_error?: string + deleted: 0 + skipped: 0 + generated_keys: string[] + warnings?: string[] +} + +export interface R_IndexStatus { + index: string + ready: boolean + progress?: number + function: Buffer + multi: boolean + geo: boolean + outdated: boolean + query: string +} + +export type RInsertObj = RDatumfy | RDatum | RStream | RDatum | RDatumfy[] | (() => RInsertObj) + +export interface RTable extends RTableSlice { + get(id: any): RTableRow + insert & {returnChanges: true | "always"}>(obj: RInsertObj, options: Opts): RDatum + insert(obj: RInsertObj, options?: R_InsertOptions): RDatum + + indexList(): RArray + indexCreate(name: string, func: (obj: RDatum) => any, opts?: {multi?: boolean, geo?: boolean}): RDatum<{created: 1}> + indexCreate(name: K, opts?: {multi?: boolean, geo?: boolean}): RDatum<{created: 1}> + indexDrop(name: string): RDatum<{dropped: 1}> + indexStatus(...names: string[]): RArray + + getAll(id: any, opts: {index: string}): RStream + getAll(id1: any, id2: any, opts: {index: string}): RStream + getAll(id1: any, id2: any, id3: any, opts: {index: string}): RStream + getAll(id1: any, id2: any, id3: any, id4: any, opts: {index: string}): RStream +} diff --git a/rethinkdb/tsconfig.json b/rethinkdb/tsconfig.json new file mode 100644 index 0000000..5deed1a --- /dev/null +++ b/rethinkdb/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "declaration": true, + "alwaysStrict": true, + "allowSyntheticDefaultImports": true, + "moduleResolution": "node", + "noImplicitAny": true, + "noImplicitThis": true, + "sourceMap": true, + "target": "ES2017", + "strictNullChecks": true + }, + "include": [ + "*.ts" + ], + "exclude": [] +} diff --git a/rethinkdb/yarn.lock b/rethinkdb/yarn.lock new file mode 100644 index 0000000..58e36cf --- /dev/null +++ b/rethinkdb/yarn.lock @@ -0,0 +1,1622 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/node@^7.0.8": + version "7.0.8" + resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.8.tgz#25e4dd804b630c916ae671233e6d71f6ce18124a" + +abbrev@1: + version "1.1.0" + resolved "https://npm.cubos.io/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" + +ajv@^4.9.1: + version "4.11.5" + resolved "https://npm.cubos.io/ajv/-/ajv-4.11.5.tgz#b6ee74657b993a01dce44b7944d56f485828d5bd" + dependencies: + co "^4.6.0" + json-stable-stringify "^1.0.1" + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://npm.cubos.io/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://npm.cubos.io/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +anymatch@^1.3.0: + version "1.3.0" + resolved "https://npm.cubos.io/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507" + dependencies: + arrify "^1.0.0" + micromatch "^2.1.5" + +aproba@^1.0.3: + version "1.1.1" + resolved "https://npm.cubos.io/aproba/-/aproba-1.1.1.tgz#95d3600f07710aa0e9298c726ad5ecf2eacbabab" + +are-we-there-yet@~1.1.2: + version "1.1.2" + resolved "https://npm.cubos.io/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz#80e470e95a084794fe1899262c5667c6e88de1b3" + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.0 || ^1.1.13" + +arr-diff@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" + dependencies: + arr-flatten "^1.0.1" + +arr-flatten@^1.0.1: + version "1.0.1" + resolved "https://npm.cubos.io/arr-flatten/-/arr-flatten-1.0.1.tgz#e5ffe54d45e19f32f216e91eb99c8ce892bb604b" + +array-unique@^0.2.1: + version "0.2.1" + resolved "https://npm.cubos.io/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" + +arrify@^1.0.0: + version "1.0.1" + resolved "https://npm.cubos.io/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + +asn1@~0.2.3: + version "0.2.3" + resolved "https://npm.cubos.io/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + +assert-plus@^0.2.0: + version "0.2.0" + resolved "https://npm.cubos.io/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" + +async-each@^1.0.0: + version "1.0.1" + resolved "https://npm.cubos.io/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://npm.cubos.io/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + +aws-sign2@~0.6.0: + version "0.6.0" + resolved "https://npm.cubos.io/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" + +aws4@^1.2.1: + version "1.6.0" + resolved "https://npm.cubos.io/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" + +babel-cli@^6.23.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-cli/-/babel-cli-6.24.0.tgz#a05ffd210dca0c288a26d5319c5ac8669a265ad0" + dependencies: + babel-core "^6.24.0" + babel-polyfill "^6.23.0" + babel-register "^6.24.0" + babel-runtime "^6.22.0" + commander "^2.8.1" + convert-source-map "^1.1.0" + fs-readdir-recursive "^1.0.0" + glob "^7.0.0" + lodash "^4.2.0" + output-file-sync "^1.1.0" + path-is-absolute "^1.0.0" + slash "^1.0.0" + source-map "^0.5.0" + v8flags "^2.0.10" + optionalDependencies: + chokidar "^1.6.1" + +babel-code-frame@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" + dependencies: + chalk "^1.1.0" + esutils "^2.0.2" + js-tokens "^3.0.0" + +babel-core@^6.24.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-core/-/babel-core-6.24.0.tgz#8f36a0a77f5c155aed6f920b844d23ba56742a02" + dependencies: + babel-code-frame "^6.22.0" + babel-generator "^6.24.0" + babel-helpers "^6.23.0" + babel-messages "^6.23.0" + babel-register "^6.24.0" + babel-runtime "^6.22.0" + babel-template "^6.23.0" + babel-traverse "^6.23.1" + babel-types "^6.23.0" + babylon "^6.11.0" + convert-source-map "^1.1.0" + debug "^2.1.1" + json5 "^0.5.0" + lodash "^4.2.0" + minimatch "^3.0.2" + path-is-absolute "^1.0.0" + private "^0.1.6" + slash "^1.0.0" + source-map "^0.5.0" + +babel-generator@^6.24.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.24.0.tgz#eba270a8cc4ce6e09a61be43465d7c62c1f87c56" + dependencies: + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-types "^6.23.0" + detect-indent "^4.0.0" + jsesc "^1.3.0" + lodash "^4.2.0" + source-map "^0.5.0" + trim-right "^1.0.1" + +babel-helper-builder-binary-assignment-operator-visitor@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.22.0.tgz#29df56be144d81bdeac08262bfa41d2c5e91cdcd" + dependencies: + babel-helper-explode-assignable-expression "^6.22.0" + babel-runtime "^6.22.0" + babel-types "^6.22.0" + +babel-helper-call-delegate@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-helper-call-delegate/-/babel-helper-call-delegate-6.22.0.tgz#119921b56120f17e9dae3f74b4f5cc7bcc1b37ef" + dependencies: + babel-helper-hoist-variables "^6.22.0" + babel-runtime "^6.22.0" + babel-traverse "^6.22.0" + babel-types "^6.22.0" + +babel-helper-define-map@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-helper-define-map/-/babel-helper-define-map-6.23.0.tgz#1444f960c9691d69a2ced6a205315f8fd00804e7" + dependencies: + babel-helper-function-name "^6.23.0" + babel-runtime "^6.22.0" + babel-types "^6.23.0" + lodash "^4.2.0" + +babel-helper-explode-assignable-expression@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.22.0.tgz#c97bf76eed3e0bae4048121f2b9dae1a4e7d0478" + dependencies: + babel-runtime "^6.22.0" + babel-traverse "^6.22.0" + babel-types "^6.22.0" + +babel-helper-function-name@^6.22.0, babel-helper-function-name@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-helper-function-name/-/babel-helper-function-name-6.23.0.tgz#25742d67175c8903dbe4b6cb9d9e1fcb8dcf23a6" + dependencies: + babel-helper-get-function-arity "^6.22.0" + babel-runtime "^6.22.0" + babel-template "^6.23.0" + babel-traverse "^6.23.0" + babel-types "^6.23.0" + +babel-helper-get-function-arity@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.22.0.tgz#0beb464ad69dc7347410ac6ade9f03a50634f5ce" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.22.0" + +babel-helper-hoist-variables@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.22.0.tgz#3eacbf731d80705845dd2e9718f600cfb9b4ba72" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.22.0" + +babel-helper-optimise-call-expression@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.23.0.tgz#f3ee7eed355b4282138b33d02b78369e470622f5" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.23.0" + +babel-helper-regex@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-helper-regex/-/babel-helper-regex-6.22.0.tgz#79f532be1647b1f0ee3474b5f5c3da58001d247d" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.22.0" + lodash "^4.2.0" + +babel-helper-remap-async-to-generator@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.22.0.tgz#2186ae73278ed03b8b15ced089609da981053383" + dependencies: + babel-helper-function-name "^6.22.0" + babel-runtime "^6.22.0" + babel-template "^6.22.0" + babel-traverse "^6.22.0" + babel-types "^6.22.0" + +babel-helper-replace-supers@^6.22.0, babel-helper-replace-supers@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-helper-replace-supers/-/babel-helper-replace-supers-6.23.0.tgz#eeaf8ad9b58ec4337ca94223bacdca1f8d9b4bfd" + dependencies: + babel-helper-optimise-call-expression "^6.23.0" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-template "^6.23.0" + babel-traverse "^6.23.0" + babel-types "^6.23.0" + +babel-helpers@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-helpers/-/babel-helpers-6.23.0.tgz#4f8f2e092d0b6a8808a4bde79c27f1e2ecf0d992" + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.23.0" + +babel-messages@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-check-es2015-constants@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-syntax-async-functions@^6.8.0: + version "6.13.0" + resolved "https://npm.cubos.io/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" + +babel-plugin-syntax-exponentiation-operator@^6.8.0: + version "6.13.0" + resolved "https://npm.cubos.io/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de" + +babel-plugin-syntax-trailing-function-commas@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" + +babel-plugin-transform-async-to-generator@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.22.0.tgz#194b6938ec195ad36efc4c33a971acf00d8cd35e" + dependencies: + babel-helper-remap-async-to-generator "^6.22.0" + babel-plugin-syntax-async-functions "^6.8.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-arrow-functions@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz#bbc51b49f964d70cb8d8e0b94e820246ce3a6141" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-block-scoping@^6.22.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.23.0.tgz#e48895cf0b375be148cd7c8879b422707a053b51" + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.23.0" + babel-traverse "^6.23.0" + babel-types "^6.23.0" + lodash "^4.2.0" + +babel-plugin-transform-es2015-classes@^6.22.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.23.0.tgz#49b53f326202a2fd1b3bbaa5e2edd8a4f78643c1" + dependencies: + babel-helper-define-map "^6.23.0" + babel-helper-function-name "^6.23.0" + babel-helper-optimise-call-expression "^6.23.0" + babel-helper-replace-supers "^6.23.0" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-template "^6.23.0" + babel-traverse "^6.23.0" + babel-types "^6.23.0" + +babel-plugin-transform-es2015-computed-properties@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.22.0.tgz#7c383e9629bba4820c11b0425bdd6290f7f057e7" + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.22.0" + +babel-plugin-transform-es2015-destructuring@^6.22.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-duplicate-keys@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.22.0.tgz#672397031c21610d72dd2bbb0ba9fb6277e1c36b" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.22.0" + +babel-plugin-transform-es2015-for-of@^6.22.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz#f47c95b2b613df1d3ecc2fdb7573623c75248691" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-function-name@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.22.0.tgz#f5fcc8b09093f9a23c76ac3d9e392c3ec4b77104" + dependencies: + babel-helper-function-name "^6.22.0" + babel-runtime "^6.22.0" + babel-types "^6.22.0" + +babel-plugin-transform-es2015-literals@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz#4f54a02d6cd66cf915280019a31d31925377ca2e" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-modules-amd@^6.24.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.0.tgz#a1911fb9b7ec7e05a43a63c5995007557bcf6a2e" + dependencies: + babel-plugin-transform-es2015-modules-commonjs "^6.24.0" + babel-runtime "^6.22.0" + babel-template "^6.22.0" + +babel-plugin-transform-es2015-modules-commonjs@^6.24.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.24.0.tgz#e921aefb72c2cc26cb03d107626156413222134f" + dependencies: + babel-plugin-transform-strict-mode "^6.22.0" + babel-runtime "^6.22.0" + babel-template "^6.23.0" + babel-types "^6.23.0" + +babel-plugin-transform-es2015-modules-systemjs@^6.22.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.23.0.tgz#ae3469227ffac39b0310d90fec73bfdc4f6317b0" + dependencies: + babel-helper-hoist-variables "^6.22.0" + babel-runtime "^6.22.0" + babel-template "^6.23.0" + +babel-plugin-transform-es2015-modules-umd@^6.24.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.0.tgz#fd5fa63521cae8d273927c3958afd7c067733450" + dependencies: + babel-plugin-transform-es2015-modules-amd "^6.24.0" + babel-runtime "^6.22.0" + babel-template "^6.23.0" + +babel-plugin-transform-es2015-object-super@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.22.0.tgz#daa60e114a042ea769dd53fe528fc82311eb98fc" + dependencies: + babel-helper-replace-supers "^6.22.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-parameters@^6.22.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.23.0.tgz#3a2aabb70c8af945d5ce386f1a4250625a83ae3b" + dependencies: + babel-helper-call-delegate "^6.22.0" + babel-helper-get-function-arity "^6.22.0" + babel-runtime "^6.22.0" + babel-template "^6.23.0" + babel-traverse "^6.23.0" + babel-types "^6.23.0" + +babel-plugin-transform-es2015-shorthand-properties@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.22.0.tgz#8ba776e0affaa60bff21e921403b8a652a2ff723" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.22.0" + +babel-plugin-transform-es2015-spread@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz#d6d68a99f89aedc4536c81a542e8dd9f1746f8d1" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-sticky-regex@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.22.0.tgz#ab316829e866ee3f4b9eb96939757d19a5bc4593" + dependencies: + babel-helper-regex "^6.22.0" + babel-runtime "^6.22.0" + babel-types "^6.22.0" + +babel-plugin-transform-es2015-template-literals@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz#a84b3450f7e9f8f1f6839d6d687da84bb1236d8d" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-typeof-symbol@^6.22.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz#dec09f1cddff94b52ac73d505c84df59dcceb372" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-unicode-regex@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.22.0.tgz#8d9cc27e7ee1decfe65454fb986452a04a613d20" + dependencies: + babel-helper-regex "^6.22.0" + babel-runtime "^6.22.0" + regexpu-core "^2.0.0" + +babel-plugin-transform-exponentiation-operator@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.22.0.tgz#d57c8335281918e54ef053118ce6eb108468084d" + dependencies: + babel-helper-builder-binary-assignment-operator-visitor "^6.22.0" + babel-plugin-syntax-exponentiation-operator "^6.8.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-regenerator@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.22.0.tgz#65740593a319c44522157538d690b84094617ea6" + dependencies: + regenerator-transform "0.9.8" + +babel-plugin-transform-runtime@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.23.0.tgz#88490d446502ea9b8e7efb0fe09ec4d99479b1ee" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-strict-mode@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.22.0.tgz#e008df01340fdc87e959da65991b7e05970c8c7c" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.22.0" + +babel-polyfill@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-polyfill/-/babel-polyfill-6.23.0.tgz#8364ca62df8eafb830499f699177466c3b03499d" + dependencies: + babel-runtime "^6.22.0" + core-js "^2.4.0" + regenerator-runtime "^0.10.0" + +babel-preset-es2015@^6.22.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-preset-es2015/-/babel-preset-es2015-6.24.0.tgz#c162d68b1932696e036cd3110dc1ccd303d2673a" + dependencies: + babel-plugin-check-es2015-constants "^6.22.0" + babel-plugin-transform-es2015-arrow-functions "^6.22.0" + babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" + babel-plugin-transform-es2015-block-scoping "^6.22.0" + babel-plugin-transform-es2015-classes "^6.22.0" + babel-plugin-transform-es2015-computed-properties "^6.22.0" + babel-plugin-transform-es2015-destructuring "^6.22.0" + babel-plugin-transform-es2015-duplicate-keys "^6.22.0" + babel-plugin-transform-es2015-for-of "^6.22.0" + babel-plugin-transform-es2015-function-name "^6.22.0" + babel-plugin-transform-es2015-literals "^6.22.0" + babel-plugin-transform-es2015-modules-amd "^6.24.0" + babel-plugin-transform-es2015-modules-commonjs "^6.24.0" + babel-plugin-transform-es2015-modules-systemjs "^6.22.0" + babel-plugin-transform-es2015-modules-umd "^6.24.0" + babel-plugin-transform-es2015-object-super "^6.22.0" + babel-plugin-transform-es2015-parameters "^6.22.0" + babel-plugin-transform-es2015-shorthand-properties "^6.22.0" + babel-plugin-transform-es2015-spread "^6.22.0" + babel-plugin-transform-es2015-sticky-regex "^6.22.0" + babel-plugin-transform-es2015-template-literals "^6.22.0" + babel-plugin-transform-es2015-typeof-symbol "^6.22.0" + babel-plugin-transform-es2015-unicode-regex "^6.22.0" + babel-plugin-transform-regenerator "^6.22.0" + +babel-preset-es2016@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-preset-es2016/-/babel-preset-es2016-6.22.0.tgz#b061aaa3983d40c9fbacfa3743b5df37f336156c" + dependencies: + babel-plugin-transform-exponentiation-operator "^6.22.0" + +babel-preset-es2017@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-preset-es2017/-/babel-preset-es2017-6.22.0.tgz#de2f9da5a30c50d293fb54a0ba15d6ddc573f0f2" + dependencies: + babel-plugin-syntax-trailing-function-commas "^6.22.0" + babel-plugin-transform-async-to-generator "^6.22.0" + +babel-register@^6.24.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-register/-/babel-register-6.24.0.tgz#5e89f8463ba9970356d02eb07dabe3308b080cfd" + dependencies: + babel-core "^6.24.0" + babel-runtime "^6.22.0" + core-js "^2.4.0" + home-or-tmp "^2.0.0" + lodash "^4.2.0" + mkdirp "^0.5.1" + source-map-support "^0.4.2" + +babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.10.0" + +babel-template@^6.22.0, babel-template@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-template/-/babel-template-6.23.0.tgz#04d4f270adbb3aa704a8143ae26faa529238e638" + dependencies: + babel-runtime "^6.22.0" + babel-traverse "^6.23.0" + babel-types "^6.23.0" + babylon "^6.11.0" + lodash "^4.2.0" + +babel-traverse@^6.22.0, babel-traverse@^6.23.0, babel-traverse@^6.23.1: + version "6.23.1" + resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.23.1.tgz#d3cb59010ecd06a97d81310065f966b699e14f48" + dependencies: + babel-code-frame "^6.22.0" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-types "^6.23.0" + babylon "^6.15.0" + debug "^2.2.0" + globals "^9.0.0" + invariant "^2.2.0" + lodash "^4.2.0" + +babel-types@^6.19.0, babel-types@^6.22.0, babel-types@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-types/-/babel-types-6.23.0.tgz#bb17179d7538bad38cd0c9e115d340f77e7e9acf" + dependencies: + babel-runtime "^6.22.0" + esutils "^2.0.2" + lodash "^4.2.0" + to-fast-properties "^1.0.1" + +babylon@^6.11.0, babylon@^6.15.0: + version "6.16.1" + resolved "https://npm.cubos.io/babylon/-/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3" + +balanced-match@^0.4.1: + version "0.4.2" + resolved "https://npm.cubos.io/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" + +bcrypt-pbkdf@^1.0.0: + version "1.0.1" + resolved "https://npm.cubos.io/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" + dependencies: + tweetnacl "^0.14.3" + +binary-extensions@^1.0.0: + version "1.8.0" + resolved "https://npm.cubos.io/binary-extensions/-/binary-extensions-1.8.0.tgz#48ec8d16df4377eae5fa5884682480af4d95c774" + +block-stream@*: + version "0.0.9" + resolved "https://npm.cubos.io/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" + dependencies: + inherits "~2.0.0" + +"bluebird@>= 3.0.1": + version "3.5.0" + resolved "https://npm.cubos.io/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c" + +boom@2.x.x: + version "2.10.1" + resolved "https://npm.cubos.io/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" + dependencies: + hoek "2.x.x" + +brace-expansion@^1.0.0: + version "1.1.6" + resolved "https://npm.cubos.io/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" + dependencies: + balanced-match "^0.4.1" + concat-map "0.0.1" + +braces@^1.8.2: + version "1.8.5" + resolved "https://npm.cubos.io/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" + dependencies: + expand-range "^1.8.1" + preserve "^0.2.0" + repeat-element "^1.1.2" + +buffer-shims@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" + +caseless@~0.12.0: + version "0.12.0" + resolved "https://npm.cubos.io/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + +chalk@^1.1.0: + version "1.1.3" + resolved "https://npm.cubos.io/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +chokidar@^1.6.1: + version "1.6.1" + resolved "https://npm.cubos.io/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2" + dependencies: + anymatch "^1.3.0" + async-each "^1.0.0" + glob-parent "^2.0.0" + inherits "^2.0.1" + is-binary-path "^1.0.0" + is-glob "^2.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.0.0" + optionalDependencies: + fsevents "^1.0.0" + +co@^4.6.0: + version "4.6.0" + resolved "https://npm.cubos.io/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://npm.cubos.io/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + +combined-stream@^1.0.5, combined-stream@~1.0.5: + version "1.0.5" + resolved "https://npm.cubos.io/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" + dependencies: + delayed-stream "~1.0.0" + +commander@^2.8.1: + version "2.9.0" + resolved "https://npm.cubos.io/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://npm.cubos.io/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://npm.cubos.io/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + +convert-source-map@^1.1.0: + version "1.4.0" + resolved "https://npm.cubos.io/convert-source-map/-/convert-source-map-1.4.0.tgz#e3dad195bf61bfe13a7a3c73e9876ec14a0268f3" + +core-js@^2.4.0: + version "2.4.1" + resolved "https://npm.cubos.io/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" + +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://npm.cubos.io/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +cryptiles@2.x.x: + version "2.0.5" + resolved "https://npm.cubos.io/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" + dependencies: + boom "2.x.x" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://npm.cubos.io/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + dependencies: + assert-plus "^1.0.0" + +debug@^2.1.1, debug@^2.2.0: + version "2.6.3" + resolved "https://npm.cubos.io/debug/-/debug-2.6.3.tgz#0f7eb8c30965ec08c72accfa0130c8b79984141d" + dependencies: + ms "0.7.2" + +debug@~2.2.0: + version "2.2.0" + resolved "https://npm.cubos.io/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + dependencies: + ms "0.7.1" + +deep-extend@~0.4.0: + version "0.4.1" + resolved "https://npm.cubos.io/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +delegates@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + +detect-indent@^4.0.0: + version "4.0.0" + resolved "https://npm.cubos.io/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" + dependencies: + repeating "^2.0.0" + +ecc-jsbn@~0.1.1: + version "0.1.1" + resolved "https://npm.cubos.io/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" + dependencies: + jsbn "~0.1.0" + +escape-string-regexp@^1.0.2: + version "1.0.5" + resolved "https://npm.cubos.io/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +esutils@^2.0.2: + version "2.0.2" + resolved "https://npm.cubos.io/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + +expand-brackets@^0.1.4: + version "0.1.5" + resolved "https://npm.cubos.io/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" + dependencies: + is-posix-bracket "^0.1.0" + +expand-range@^1.8.1: + version "1.8.2" + resolved "https://npm.cubos.io/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" + dependencies: + fill-range "^2.1.0" + +extend@~3.0.0: + version "3.0.0" + resolved "https://npm.cubos.io/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4" + +extglob@^0.3.1: + version "0.3.2" + resolved "https://npm.cubos.io/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" + dependencies: + is-extglob "^1.0.0" + +extsprintf@1.0.2: + version "1.0.2" + resolved "https://npm.cubos.io/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" + +filename-regex@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/filename-regex/-/filename-regex-2.0.0.tgz#996e3e80479b98b9897f15a8a58b3d084e926775" + +fill-range@^2.1.0: + version "2.2.3" + resolved "https://npm.cubos.io/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" + dependencies: + is-number "^2.1.0" + isobject "^2.0.0" + randomatic "^1.1.3" + repeat-element "^1.1.2" + repeat-string "^1.5.2" + +for-in@^1.0.1: + version "1.0.2" + resolved "https://npm.cubos.io/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + +for-own@^0.1.4: + version "0.1.5" + resolved "https://npm.cubos.io/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce" + dependencies: + for-in "^1.0.1" + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://npm.cubos.io/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + +form-data@~2.1.1: + version "2.1.2" + resolved "https://npm.cubos.io/form-data/-/form-data-2.1.2.tgz#89c3534008b97eada4cbb157d58f6f5df025eae4" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + +fs-readdir-recursive@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +fsevents@^1.0.0: + version "1.1.1" + resolved "https://npm.cubos.io/fsevents/-/fsevents-1.1.1.tgz#f19fd28f43eeaf761680e519a203c4d0b3d31aff" + dependencies: + nan "^2.3.0" + node-pre-gyp "^0.6.29" + +fstream-ignore@~1.0.5: + version "1.0.5" + resolved "https://npm.cubos.io/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" + dependencies: + fstream "^1.0.0" + inherits "2" + minimatch "^3.0.0" + +fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10: + version "1.0.11" + resolved "https://npm.cubos.io/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" + dependencies: + graceful-fs "^4.1.2" + inherits "~2.0.0" + mkdirp ">=0.5 0" + rimraf "2" + +gauge@~2.7.1: + version "2.7.3" + resolved "https://npm.cubos.io/gauge/-/gauge-2.7.3.tgz#1c23855f962f17b3ad3d0dc7443f304542edfe09" + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + wide-align "^1.1.0" + +getpass@^0.1.1: + version "0.1.6" + resolved "https://npm.cubos.io/getpass/-/getpass-0.1.6.tgz#283ffd9fc1256840875311c1b60e8c40187110e6" + dependencies: + assert-plus "^1.0.0" + +glob-base@^0.3.0: + version "0.3.0" + resolved "https://npm.cubos.io/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" + dependencies: + glob-parent "^2.0.0" + is-glob "^2.0.0" + +glob-parent@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" + dependencies: + is-glob "^2.0.0" + +glob@^7.0.0, glob@^7.0.5: + version "7.1.1" + resolved "https://npm.cubos.io/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.2" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globals@^9.0.0: + version "9.16.0" + resolved "https://npm.cubos.io/globals/-/globals-9.16.0.tgz#63e903658171ec2d9f51b1d31de5e2b8dc01fb80" + +graceful-fs@^4.1.2, graceful-fs@^4.1.4: + version "4.1.11" + resolved "https://npm.cubos.io/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + +"graceful-readlink@>= 1.0.0": + version "1.0.1" + resolved "https://npm.cubos.io/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" + +har-schema@^1.0.5: + version "1.0.5" + resolved "https://npm.cubos.io/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" + +har-validator@~4.2.1: + version "4.2.1" + resolved "https://npm.cubos.io/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" + dependencies: + ajv "^4.9.1" + har-schema "^1.0.5" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://npm.cubos.io/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + +hawk@~3.1.3: + version "3.1.3" + resolved "https://npm.cubos.io/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" + dependencies: + boom "2.x.x" + cryptiles "2.x.x" + hoek "2.x.x" + sntp "1.x.x" + +hoek@2.x.x: + version "2.16.3" + resolved "https://npm.cubos.io/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" + +home-or-tmp@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.1" + +http-signature@~1.1.0: + version "1.1.1" + resolved "https://npm.cubos.io/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" + dependencies: + assert-plus "^0.2.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://npm.cubos.io/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1: + version "2.0.3" + resolved "https://npm.cubos.io/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +ini@~1.3.0: + version "1.3.4" + resolved "https://npm.cubos.io/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" + +invariant@^2.2.0: + version "2.2.2" + resolved "https://npm.cubos.io/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" + dependencies: + loose-envify "^1.0.0" + +is-binary-path@^1.0.0: + version "1.0.1" + resolved "https://npm.cubos.io/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" + dependencies: + binary-extensions "^1.0.0" + +is-buffer@^1.0.2: + version "1.1.5" + resolved "https://npm.cubos.io/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" + +is-dotfile@^1.0.0: + version "1.0.2" + resolved "https://npm.cubos.io/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d" + +is-equal-shallow@^0.1.3: + version "0.1.3" + resolved "https://npm.cubos.io/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" + dependencies: + is-primitive "^2.0.0" + +is-extendable@^0.1.1: + version "0.1.1" + resolved "https://npm.cubos.io/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + +is-extglob@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" + +is-finite@^1.0.0: + version "1.0.2" + resolved "https://npm.cubos.io/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + dependencies: + number-is-nan "^1.0.0" + +is-glob@^2.0.0, is-glob@^2.0.1: + version "2.0.1" + resolved "https://npm.cubos.io/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" + dependencies: + is-extglob "^1.0.0" + +is-number@^2.0.2, is-number@^2.1.0: + version "2.1.0" + resolved "https://npm.cubos.io/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" + dependencies: + kind-of "^3.0.2" + +is-posix-bracket@^0.1.0: + version "0.1.1" + resolved "https://npm.cubos.io/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" + +is-primitive@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + +isarray@1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +isobject@^2.0.0: + version "2.1.0" + resolved "https://npm.cubos.io/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + dependencies: + isarray "1.0.0" + +isstream@~0.1.2: + version "0.1.2" + resolved "https://npm.cubos.io/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + +jodid25519@^1.0.0: + version "1.0.2" + resolved "https://npm.cubos.io/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967" + dependencies: + jsbn "~0.1.0" + +js-tokens@^3.0.0: + version "3.0.1" + resolved "https://npm.cubos.io/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" + +jsbn@~0.1.0: + version "0.1.1" + resolved "https://npm.cubos.io/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + +jsesc@^1.3.0: + version "1.3.0" + resolved "https://npm.cubos.io/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" + +jsesc@~0.5.0: + version "0.5.0" + resolved "https://npm.cubos.io/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" + +json-schema@0.2.3: + version "0.2.3" + resolved "https://npm.cubos.io/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + +json-stable-stringify@^1.0.1: + version "1.0.1" + resolved "https://npm.cubos.io/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" + dependencies: + jsonify "~0.0.0" + +json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://npm.cubos.io/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + +json5@^0.5.0: + version "0.5.1" + resolved "https://npm.cubos.io/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + +jsonify@~0.0.0: + version "0.0.0" + resolved "https://npm.cubos.io/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" + +jsprim@^1.2.2: + version "1.4.0" + resolved "https://npm.cubos.io/jsprim/-/jsprim-1.4.0.tgz#a3b87e40298d8c380552d8cc7628a0bb95a22918" + dependencies: + assert-plus "1.0.0" + extsprintf "1.0.2" + json-schema "0.2.3" + verror "1.3.6" + +kind-of@^3.0.2: + version "3.1.0" + resolved "https://npm.cubos.io/kind-of/-/kind-of-3.1.0.tgz#475d698a5e49ff5e53d14e3e732429dc8bf4cf47" + dependencies: + is-buffer "^1.0.2" + +lodash@^4.2.0: + version "4.17.4" + resolved "https://npm.cubos.io/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" + +loose-envify@^1.0.0: + version "1.3.1" + resolved "https://npm.cubos.io/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" + dependencies: + js-tokens "^3.0.0" + +micromatch@^2.1.5: + version "2.3.11" + resolved "https://npm.cubos.io/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" + dependencies: + arr-diff "^2.0.0" + array-unique "^0.2.1" + braces "^1.8.2" + expand-brackets "^0.1.4" + extglob "^0.3.1" + filename-regex "^2.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.1" + kind-of "^3.0.2" + normalize-path "^2.0.1" + object.omit "^2.0.0" + parse-glob "^3.0.4" + regex-cache "^0.4.2" + +mime-db@~1.26.0: + version "1.26.0" + resolved "https://npm.cubos.io/mime-db/-/mime-db-1.26.0.tgz#eaffcd0e4fc6935cf8134da246e2e6c35305adff" + +mime-types@^2.1.12, mime-types@~2.1.7: + version "2.1.14" + resolved "https://npm.cubos.io/mime-types/-/mime-types-2.1.14.tgz#f7ef7d97583fcaf3b7d282b6f8b5679dab1e94ee" + dependencies: + mime-db "~1.26.0" + +minimatch@^3.0.0, minimatch@^3.0.2: + version "3.0.3" + resolved "https://npm.cubos.io/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" + dependencies: + brace-expansion "^1.0.0" + +minimist@0.0.8: + version "0.0.8" + resolved "https://npm.cubos.io/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +minimist@^1.2.0: + version "1.2.0" + resolved "https://npm.cubos.io/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +"mkdirp@>=0.5 0", mkdirp@^0.5.1, mkdirp@~0.5.1: + version "0.5.1" + resolved "https://npm.cubos.io/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +ms@0.7.1: + version "0.7.1" + resolved "https://npm.cubos.io/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" + +ms@0.7.2: + version "0.7.2" + resolved "https://npm.cubos.io/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" + +nan@^2.3.0: + version "2.5.1" + resolved "https://npm.cubos.io/nan/-/nan-2.5.1.tgz#d5b01691253326a97a2bbee9e61c55d8d60351e2" + +node-pre-gyp@^0.6.29: + version "0.6.33" + resolved "https://npm.cubos.io/node-pre-gyp/-/node-pre-gyp-0.6.33.tgz#640ac55198f6a925972e0c16c4ac26a034d5ecc9" + dependencies: + mkdirp "~0.5.1" + nopt "~3.0.6" + npmlog "^4.0.1" + rc "~1.1.6" + request "^2.79.0" + rimraf "~2.5.4" + semver "~5.3.0" + tar "~2.2.1" + tar-pack "~3.3.0" + +nopt@~3.0.6: + version "3.0.6" + resolved "https://npm.cubos.io/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" + dependencies: + abbrev "1" + +normalize-path@^2.0.1: + version "2.0.1" + resolved "https://npm.cubos.io/normalize-path/-/normalize-path-2.0.1.tgz#47886ac1662760d4261b7d979d241709d3ce3f7a" + +npmlog@^4.0.1: + version "4.0.2" + resolved "https://npm.cubos.io/npmlog/-/npmlog-4.0.2.tgz#d03950e0e78ce1527ba26d2a7592e9348ac3e75f" + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.7.1" + set-blocking "~2.0.0" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://npm.cubos.io/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + +oauth-sign@~0.8.1: + version "0.8.2" + resolved "https://npm.cubos.io/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" + +object-assign@^4.1.0: + version "4.1.1" + resolved "https://npm.cubos.io/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + +object.omit@^2.0.0: + version "2.0.1" + resolved "https://npm.cubos.io/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" + dependencies: + for-own "^0.1.4" + is-extendable "^0.1.1" + +once@^1.3.0: + version "1.4.0" + resolved "https://npm.cubos.io/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +once@~1.3.3: + version "1.3.3" + resolved "https://npm.cubos.io/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20" + dependencies: + wrappy "1" + +os-homedir@^1.0.0: + version "1.0.2" + resolved "https://npm.cubos.io/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + +os-tmpdir@^1.0.1: + version "1.0.2" + resolved "https://npm.cubos.io/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + +output-file-sync@^1.1.0: + version "1.1.2" + resolved "https://npm.cubos.io/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" + dependencies: + graceful-fs "^4.1.4" + mkdirp "^0.5.1" + object-assign "^4.1.0" + +parse-glob@^3.0.4: + version "3.0.4" + resolved "https://npm.cubos.io/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" + dependencies: + glob-base "^0.3.0" + is-dotfile "^1.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.0" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://npm.cubos.io/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +performance-now@^0.2.0: + version "0.2.0" + resolved "https://npm.cubos.io/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" + +preserve@^0.2.0: + version "0.2.0" + resolved "https://npm.cubos.io/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" + +private@^0.1.6: + version "0.1.7" + resolved "https://npm.cubos.io/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1" + +process-nextick-args@~1.0.6: + version "1.0.7" + resolved "https://npm.cubos.io/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" + +punycode@^1.4.1: + version "1.4.1" + resolved "https://npm.cubos.io/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + +qs@~6.4.0: + version "6.4.0" + resolved "https://npm.cubos.io/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" + +randomatic@^1.1.3: + version "1.1.6" + resolved "https://npm.cubos.io/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb" + dependencies: + is-number "^2.0.2" + kind-of "^3.0.2" + +rc@~1.1.6: + version "1.1.7" + resolved "https://npm.cubos.io/rc/-/rc-1.1.7.tgz#c5ea564bb07aff9fd3a5b32e906c1d3a65940fea" + dependencies: + deep-extend "~0.4.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + +"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.2: + version "2.2.5" + resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.5.tgz#a0b187304e05bab01a4ce2b4cc9c607d5aa1d606" + dependencies: + buffer-shims "^1.0.0" + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~0.10.x" + util-deprecate "~1.0.1" + +readable-stream@~2.1.4: + version "2.1.5" + resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.1.5.tgz#66fa8b720e1438b364681f2ad1a63c618448c9d0" + dependencies: + buffer-shims "^1.0.0" + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~0.10.x" + util-deprecate "~1.0.1" + +readdirp@^2.0.0: + version "2.1.0" + resolved "https://npm.cubos.io/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78" + dependencies: + graceful-fs "^4.1.2" + minimatch "^3.0.2" + readable-stream "^2.0.2" + set-immediate-shim "^1.0.1" + +regenerate@^1.2.1: + version "1.3.2" + resolved "https://npm.cubos.io/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" + +regenerator-runtime@^0.10.0: + version "0.10.3" + resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.10.3.tgz#8c4367a904b51ea62a908ac310bf99ff90a82a3e" + +regenerator-transform@0.9.8: + version "0.9.8" + resolved "https://npm.cubos.io/regenerator-transform/-/regenerator-transform-0.9.8.tgz#0f88bb2bc03932ddb7b6b7312e68078f01026d6c" + dependencies: + babel-runtime "^6.18.0" + babel-types "^6.19.0" + private "^0.1.6" + +regex-cache@^0.4.2: + version "0.4.3" + resolved "https://npm.cubos.io/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" + dependencies: + is-equal-shallow "^0.1.3" + is-primitive "^2.0.0" + +regexpu-core@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240" + dependencies: + regenerate "^1.2.1" + regjsgen "^0.2.0" + regjsparser "^0.1.4" + +regjsgen@^0.2.0: + version "0.2.0" + resolved "https://npm.cubos.io/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" + +regjsparser@^0.1.4: + version "0.1.5" + resolved "https://npm.cubos.io/regjsparser/-/regjsparser-0.1.5.tgz#7ee8f84dc6fa792d3fd0ae228d24bd949ead205c" + dependencies: + jsesc "~0.5.0" + +repeat-element@^1.1.2: + version "1.1.2" + resolved "https://npm.cubos.io/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" + +repeat-string@^1.5.2: + version "1.6.1" + resolved "https://npm.cubos.io/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + +repeating@^2.0.0: + version "2.0.1" + resolved "https://npm.cubos.io/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + dependencies: + is-finite "^1.0.0" + +request@^2.79.0: + version "2.81.0" + resolved "https://npm.cubos.io/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" + dependencies: + aws-sign2 "~0.6.0" + aws4 "^1.2.1" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~4.2.1" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + oauth-sign "~0.8.1" + performance-now "^0.2.0" + qs "~6.4.0" + safe-buffer "^5.0.1" + stringstream "~0.0.4" + tough-cookie "~2.3.0" + tunnel-agent "^0.6.0" + uuid "^3.0.0" + +rethinkdbdash@^2.3.28: + version "2.3.28" + resolved "https://npm.cubos.io/rethinkdbdash/-/rethinkdbdash-2.3.28.tgz#f15fed3a2f0c178155fcadb6fc212b3df80f73df" + dependencies: + bluebird ">= 3.0.1" + +rimraf@2, rimraf@~2.5.1, rimraf@~2.5.4: + version "2.5.4" + resolved "https://npm.cubos.io/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" + dependencies: + glob "^7.0.5" + +safe-buffer@^5.0.1: + version "5.0.1" + resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" + +semver@~5.3.0: + version "5.3.0" + resolved "https://npm.cubos.io/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" + +set-blocking@~2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + +set-immediate-shim@^1.0.1: + version "1.0.1" + resolved "https://npm.cubos.io/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" + +signal-exit@^3.0.0: + version "3.0.2" + resolved "https://npm.cubos.io/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + +slash@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" + +sntp@1.x.x: + version "1.0.9" + resolved "https://npm.cubos.io/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" + dependencies: + hoek "2.x.x" + +source-map-support@^0.4.2: + version "0.4.12" + resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.12.tgz#f47d02bf01efaf0c160d3a37d038401b92b1867e" + dependencies: + source-map "^0.5.6" + +source-map@^0.5.0, source-map@^0.5.6: + version "0.5.6" + resolved "https://npm.cubos.io/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" + +sshpk@^1.7.0: + version "1.11.0" + resolved "https://npm.cubos.io/sshpk/-/sshpk-1.11.0.tgz#2d8d5ebb4a6fab28ffba37fa62a90f4a3ea59d77" + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + dashdash "^1.12.0" + getpass "^0.1.1" + optionalDependencies: + bcrypt-pbkdf "^1.0.0" + ecc-jsbn "~0.1.1" + jodid25519 "^1.0.0" + jsbn "~0.1.0" + tweetnacl "~0.14.0" + +string-width@^1.0.1: + version "1.0.2" + resolved "https://npm.cubos.io/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://npm.cubos.io/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + +stringstream@~0.0.4: + version "0.0.5" + resolved "https://npm.cubos.io/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://npm.cubos.io/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://npm.cubos.io/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +tar-pack@~3.3.0: + version "3.3.0" + resolved "https://npm.cubos.io/tar-pack/-/tar-pack-3.3.0.tgz#30931816418f55afc4d21775afdd6720cee45dae" + dependencies: + debug "~2.2.0" + fstream "~1.0.10" + fstream-ignore "~1.0.5" + once "~1.3.3" + readable-stream "~2.1.4" + rimraf "~2.5.1" + tar "~2.2.1" + uid-number "~0.0.6" + +tar@~2.2.1: + version "2.2.1" + resolved "https://npm.cubos.io/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" + dependencies: + block-stream "*" + fstream "^1.0.2" + inherits "2" + +to-fast-properties@^1.0.1: + version "1.0.2" + resolved "https://npm.cubos.io/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" + +tough-cookie@~2.3.0: + version "2.3.2" + resolved "https://npm.cubos.io/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" + dependencies: + punycode "^1.4.1" + +trim-right@^1.0.1: + version "1.0.1" + resolved "https://npm.cubos.io/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" + +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://npm.cubos.io/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + dependencies: + safe-buffer "^5.0.1" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://npm.cubos.io/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + +typescript@^2.2.1: + version "2.2.1" + resolved "https://npm.cubos.io/typescript/-/typescript-2.2.1.tgz#4862b662b988a4c8ff691cc7969622d24db76ae9" + +uid-number@~0.0.6: + version "0.0.6" + resolved "https://npm.cubos.io/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" + +user-home@^1.1.1: + version "1.1.1" + resolved "https://npm.cubos.io/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://npm.cubos.io/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + +uuid@^3.0.0: + version "3.0.1" + resolved "https://npm.cubos.io/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" + +v8flags@^2.0.10: + version "2.0.11" + resolved "https://npm.cubos.io/v8flags/-/v8flags-2.0.11.tgz#bca8f30f0d6d60612cc2c00641e6962d42ae6881" + dependencies: + user-home "^1.1.1" + +verror@1.3.6: + version "1.3.6" + resolved "https://npm.cubos.io/verror/-/verror-1.3.6.tgz#cff5df12946d297d2baaefaa2689e25be01c005c" + dependencies: + extsprintf "1.0.2" + +wide-align@^1.1.0: + version "1.1.0" + resolved "https://npm.cubos.io/wide-align/-/wide-align-1.1.0.tgz#40edde802a71fea1f070da3e62dcda2e7add96ad" + dependencies: + string-width "^1.0.1" + +wrappy@1: + version "1.0.2" + resolved "https://npm.cubos.io/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" From 5462b0c1cd7af09f422e5ffe9bac1472f7d08a1f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 15 Mar 2017 21:40:01 -0300 Subject: [PATCH 002/625] Fix file names --- rethinkdb/build_and_publish.sh | 2 +- rethinkdb/package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rethinkdb/build_and_publish.sh b/rethinkdb/build_and_publish.sh index 0ce620b..c14c413 100644 --- a/rethinkdb/build_and_publish.sh +++ b/rethinkdb/build_and_publish.sh @@ -5,5 +5,5 @@ VERSION=1.0.$1 export PATH=$(npm bin):$PATH npm version $VERSION || true tsc -babel api.js -o api.js +babel rethinkdb.js -o rethinkdb.js npm publish diff --git a/rethinkdb/package.json b/rethinkdb/package.json index 781837c..72c9d27 100644 --- a/rethinkdb/package.json +++ b/rethinkdb/package.json @@ -6,8 +6,8 @@ "babel-runtime": "^6.23.0", "rethinkdbdash": "^2.3.28" }, - "main": "api.js", - "types": "api.d.ts", + "main": "rethinkdb.js", + "types": "rethinkdb.d.ts", "babel": { "plugins": [ "transform-runtime" From 5d2e581445bddd8307f9aa8434bba8f39ac21ffb Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 15 Mar 2017 22:02:53 -0300 Subject: [PATCH 003/625] Change connect function --- rethinkdb/rethinkdb.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rethinkdb/rethinkdb.ts b/rethinkdb/rethinkdb.ts index 32a2e3a..8c06ff6 100644 --- a/rethinkdb/rethinkdb.ts +++ b/rethinkdb/rethinkdb.ts @@ -1,7 +1,7 @@ let r: R; -export default function(db: string) { +export function connect(db: string) { r = require("rethinkdbdash")({ db: db, pingInterval: 20, From 2a850de50ca3fc67c0459bc2807172235eb9b181 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 08:01:17 -0300 Subject: [PATCH 004/625] Change packages --- rethinkdb/index.ts | 108 ++++++++++++ rethinkdb/package.json | 4 +- rethinkdb/rethinkdb.ts | 256 ---------------------------- rethinkdb/tsconfig.json | 3 +- target-android/build_and_publish.sh | 4 +- target-web/build_and_publish.sh | 4 +- 6 files changed, 116 insertions(+), 263 deletions(-) create mode 100644 rethinkdb/index.ts delete mode 100644 rethinkdb/rethinkdb.ts diff --git a/rethinkdb/index.ts b/rethinkdb/index.ts new file mode 100644 index 0000000..4ad9677 --- /dev/null +++ b/rethinkdb/index.ts @@ -0,0 +1,108 @@ + +let r: R; + +export function connect(db: string, host: string = "rethinkdb") { + r = require("rethinkdbdash")({ + db: db, + pingInterval: 20, + servers: [{ + host: host, + port: 28015 + }] + }); + + return r; +} + +export interface ConfigureOptions { + tables: { + [name: string]: { + indices?: any[] + } + } +} + +export async function configure(options: ConfigureOptions) { + const tables = Object.keys(options.tables); + const realTables = await r.tableList(); + + for (let i = 0; i < realTables.length; ++i) { + if (tables.indexOf(realTables[i]) >= 0) continue; + console.log(`Dropping table ${realTables[i]}...`); + await r.tableDrop(realTables[i]); + } + + for (let i = 0; i < tables.length; ++i) { + const table = tables[i]; + if (realTables.indexOf(table) < 0) { + console.log(`Creating table ${table}...`); + await r.tableCreate(table); + } + + const indicesCreationFunc = options.tables[table].indices || []; + const indices = indicesCreationFunc.map((creationFunc: any) => { + const match = /^r\.table\("([^"]+)"\)\.indexCreate\("([^"]+)"/.exec(creationFunc.toString()); + if (match === null) + throw "Invalid index expression: creationFunc.toString()"; + if (match[1] !== table) + throw `Invalid index expression: Should use table ${table}, but uses ${match[1]}: creationFunc.toString()`; + + return match[2]; + }); + + const realIndices = await r.table(table).indexList(); + + for (let i = 0; i < realIndices.length; ++i) { + if (indices.indexOf(realIndices[i]) >= 0) continue; + console.log(`Dropping index ${table}.${realIndices[i]}...`); + await r.table(table).indexDrop(realIndices[i]); + } + + for (let i = 0; i < indices.length; ++i) { + if (realIndices.indexOf(indices[i]) < 0) { + console.log(`Creating index ${table}.${indices[i]}...`); + await indicesCreationFunc[i]; + } else { + const status = await r.table(table).indexStatus(indices[i])(0); + + let realDescr = status.query; + let descr = indicesCreationFunc[i].toString(); + + { + const match = /(function[\s\S]*\})/.exec(realDescr); + if (!match) throw `Index function doesn't contain a function??? ${JSON.stringify(realDescr)}`; + realDescr = match[1]; + } + + { + const match = /(function[\s\S]*\})/.exec(descr); + if (!match) descr = `function (var_1) { return var_1("${indices[i]}") }`; + else descr = match[1]; + } + + realDescr = global["eval"](`(${realDescr})`).toString(); + descr = global["eval"](`(${descr})`).toString(); + + descr = descr.replace(/\n\s*/g, " "); + realDescr = realDescr.replace(/\.getField/g, ""); + realDescr = realDescr.replace(/;/g, ""); + const varMapping: {[orig: string]: string} = {}; + const varMatches = /(_?var\d+)/.exec(realDescr) || []; + for (let i = 0; i < varMatches.length; ++i) { + if (varMapping[varMatches[i]] === undefined) { + varMapping[varMatches[i]] = "var_" + (Object.keys(varMapping).length + 1); + } + realDescr = realDescr.replace(varMatches[i], varMapping[varMatches[i]]); + } + + if (realDescr !== descr) { + console.log(`Recreating index ${table}.${indices[i]}...`); + await r.table(table).indexDrop(indices[i]); + await indicesCreationFunc[i]; + } + } + } + } + + console.log("Database structure is ready"); +} diff --git a/rethinkdb/package.json b/rethinkdb/package.json index 72c9d27..0f3f3dd 100644 --- a/rethinkdb/package.json +++ b/rethinkdb/package.json @@ -6,8 +6,8 @@ "babel-runtime": "^6.23.0", "rethinkdbdash": "^2.3.28" }, - "main": "rethinkdb.js", - "types": "rethinkdb.d.ts", + "main": "index.js", + "types": "index.d.ts", "babel": { "plugins": [ "transform-runtime" diff --git a/rethinkdb/rethinkdb.ts b/rethinkdb/rethinkdb.ts deleted file mode 100644 index 8c06ff6..0000000 --- a/rethinkdb/rethinkdb.ts +++ /dev/null @@ -1,256 +0,0 @@ - -let r: R; - -export function connect(db: string) { - r = require("rethinkdbdash")({ - db: db, - pingInterval: 20, - servers: [{ - host: "rethinkdb", - port: 28015 - }] - }); - - return r; -} - -export interface Description { - [name: string]: { - indices?: any[] - } -} - -export async function updateDb(dbDescr: any) { - const tables = Object.keys(dbDescr); - const realTables = await r.tableList(); - - for (let i = 0; i < realTables.length; ++i) { - if (tables.indexOf(realTables[i]) >= 0) continue; - console.log(`Dropping table ${realTables[i]}...`); - await r.tableDrop(realTables[i]); - } - - for (let i = 0; i < tables.length; ++i) { - const table = tables[i]; - if (realTables.indexOf(table) < 0) { - console.log(`Creating table ${table}...`); - await r.tableCreate(table); - } - - const indicesCreationFunc = dbDescr[table].indices || []; - const indices = indicesCreationFunc.map((creationFunc: any) => { - const match = /^r\.table\("([^"]+)"\)\.indexCreate\("([^"]+)"/.exec(creationFunc.toString()); - if (match === null) - throw "Invalid index expression: creationFunc.toString()"; - if (match[1] !== table) - throw `Invalid index expression: Should use table ${table}, but uses ${match[1]}: creationFunc.toString()`; - - return match[2]; - }); - - const realIndices = await r.table(table).indexList(); - - for (let i = 0; i < realIndices.length; ++i) { - if (indices.indexOf(realIndices[i]) >= 0) continue; - console.log(`Dropping index ${table}.${realIndices[i]}...`); - await r.table(table).indexDrop(realIndices[i]); - } - - for (let i = 0; i < indices.length; ++i) { - if (realIndices.indexOf(indices[i]) < 0) { - console.log(`Creating index ${table}.${indices[i]}...`); - await indicesCreationFunc[i]; - } else { - const status = await r.table(table).indexStatus(indices[i])(0); - - let realDescr = status.query; - let descr = indicesCreationFunc[i].toString(); - - { - const match = /(function[\s\S]*\})/.exec(realDescr); - if (!match) throw `Index function doesn't contain a function??? ${JSON.stringify(realDescr)}`; - realDescr = match[1]; - } - - { - const match = /(function[\s\S]*\})/.exec(descr); - if (!match) descr = `function (var_1) { return var_1("${indices[i]}") }`; - else descr = match[1]; - } - - realDescr = global["eval"](`(${realDescr})`).toString(); - descr = global["eval"](`(${descr})`).toString(); - - descr = descr.replace(/\n\s*/g, " "); - realDescr = realDescr.replace(/\.getField/g, ""); - realDescr = realDescr.replace(/;/g, ""); - const varMapping: {[orig: string]: string} = {}; - const varMatches = /(_?var\d+)/.exec(realDescr) || []; - for (let i = 0; i < varMatches.length; ++i) { - if (varMapping[varMatches[i]] === undefined) { - varMapping[varMatches[i]] = "var_" + (Object.keys(varMapping).length + 1); - } - realDescr = realDescr.replace(varMatches[i], varMapping[varMatches[i]]); - } - - if (realDescr !== descr) { - console.log(`Recreating index ${table}.${indices[i]}...`); - await r.table(table).indexDrop(indices[i]); - await indicesCreationFunc[i]; - } - } - } - } - - console.log("Database structure is ready"); -} - -export interface R extends RDB { - db(name: string): RDB - expr(obj: any): RDatum - uuid(): RDatum - range(): RStream - range(count: number): RStream - range(initial: number, count: number): RStream - epochTime(epoch: number): RDatum -} - -export interface RDB { - table(name: string): RTable - tableList(): RArray - tableDrop(name: string): RDatum<{tables_dropped: 1, config_changes: {old_val: R_TableConfig, new_val: null}}> - tableCreate(name: string, opts?: R_TableCreateOptions): RDatum<{tables_created: 1, config_changes: {old_val: null, new_val: R_TableConfig}}> -} - -export type RPrimitive = null | string | number | Date | boolean | Buffer - -export type RDatumfy = { - [P in keyof T]: T[P] | RDatum; -}; - -export interface R_TableConfig { - -} - -export interface R_TableCreateOptions { - primaryKey?: string - durability?: "soft" | "hard" - shards?: number - replicas?: number | {[server: string]: number} - primaryReplicaTag?: string -} - -export interface RStreamOrDatum { - count(): RDatum - avg(): RDatum - min(): RDatum - max(): RDatum - orderBy(field: string): RArray -} - -export interface RDatum extends RStreamOrDatum, PromiseLike { - do(func: (obj: this) => X): RDatum - do(func: (obj: this) => any): RDatum - default(val: X): RDatum - default(val: any): RDatum - (idx: K): RDatum - (idx: number | RDatum): RDatum - merge(op: (e: RDatum) => any): RDatum - merge(op: any): RDatum - map(func: (e: RDatum) => any): RArray - sub(other: any): RDatum - add(...others: any[]): RDatum - append(other: any): RDatum -} - -export interface RArray extends RDatum { - (idx: number | RDatum): RDatum - map(func: (e: RDatum) => any): RArray - orderBy(field: string): RArray - append(other: T): RArray -} - -export interface RStream extends PromiseLike, RStreamOrDatum { - (idx: number): RDatum - map(func: (arg: RDatum) => any): RStream - orderBy(field: string): RArray - coerceTo(type: "array"): RArray -} - -export interface R_UpdateOptions { - durability?: "hard" | "soft" - returnChanges?: true | false | "always" - nonAtomic?: boolean -} - -export interface R_UpdateResult { - replaced: number - unchanged: number - skipped: number - errors: number - first_error?: string - deleted: 0 - inserted: 0 -} - -export type RUpdateObj = Partial | RDatum | ((obj: RDatum) => any) - -export interface RTableSlice extends RStream { - update(obj: RUpdateObj, options: Opts): RDatum - update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum - delete(): RDatum<{}> -} - -export interface RTableRow extends RDatum { - update(obj: RUpdateObj, options: Opts): RDatum - update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum - delete(): RDatum<{}> -} - -export interface R_InsertOptions { - durability?: "hard" | "soft" - returnChanges?: true | false | "always" - conflict?: "error" | "replace" | "update" | ((id: string, oldDoc: RDatum, newDoc: RDatum) => any) -} - -export interface R_InsertResult { - inserted: number - replaced: number - unchanged: number - errors: number - first_error?: string - deleted: 0 - skipped: 0 - generated_keys: string[] - warnings?: string[] -} - -export interface R_IndexStatus { - index: string - ready: boolean - progress?: number - function: Buffer - multi: boolean - geo: boolean - outdated: boolean - query: string -} - -export type RInsertObj = RDatumfy | RDatum | RStream | RDatum | RDatumfy[] | (() => RInsertObj) - -export interface RTable extends RTableSlice { - get(id: any): RTableRow - insert & {returnChanges: true | "always"}>(obj: RInsertObj, options: Opts): RDatum - insert(obj: RInsertObj, options?: R_InsertOptions): RDatum - - indexList(): RArray - indexCreate(name: string, func: (obj: RDatum) => any, opts?: {multi?: boolean, geo?: boolean}): RDatum<{created: 1}> - indexCreate(name: K, opts?: {multi?: boolean, geo?: boolean}): RDatum<{created: 1}> - indexDrop(name: string): RDatum<{dropped: 1}> - indexStatus(...names: string[]): RArray - - getAll(id: any, opts: {index: string}): RStream - getAll(id1: any, id2: any, opts: {index: string}): RStream - getAll(id1: any, id2: any, id3: any, opts: {index: string}): RStream - getAll(id1: any, id2: any, id3: any, id4: any, opts: {index: string}): RStream -} diff --git a/rethinkdb/tsconfig.json b/rethinkdb/tsconfig.json index 5deed1a..b356b0a 100644 --- a/rethinkdb/tsconfig.json +++ b/rethinkdb/tsconfig.json @@ -12,7 +12,8 @@ "strictNullChecks": true }, "include": [ - "*.ts" + "index.ts", + "rethinkdb.d.ts" ], "exclude": [] } diff --git a/target-android/build_and_publish.sh b/target-android/build_and_publish.sh index 4b6e488..c3fecf2 100644 --- a/target-android/build_and_publish.sh +++ b/target-android/build_and_publish.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -NAME=$(basename `git rev-parse --show-toplevel` | sed -e 's/-api//g') -VERSION=1.0.$2 +NAME=$2 +VERSION=1.0.$3 LOCATION=/root rm -rf $LOCATION/api/src/main/java/io/cubos/api diff --git a/target-web/build_and_publish.sh b/target-web/build_and_publish.sh index 6742a96..17752f1 100644 --- a/target-web/build_and_publish.sh +++ b/target-web/build_and_publish.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -NAME=$(basename `git rev-parse --show-toplevel`) -VERSION=1.0.$2 +NAME=$2 +VERSION=1.0.$3 cp $1 /root/stage/api.ts cd /root/stage From 796c090478fe1b498b52760fc38fcc951368d599 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 08:06:22 -0300 Subject: [PATCH 005/625] @cubos/rethinkdb --- rethinkdb/.gitignore | 6 +- rethinkdb/build_and_publish.sh | 2 +- rethinkdb/rethinkdb.d.ts | 150 +++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+), 4 deletions(-) create mode 100644 rethinkdb/rethinkdb.d.ts diff --git a/rethinkdb/.gitignore b/rethinkdb/.gitignore index 00d619b..e83ca2b 100644 --- a/rethinkdb/.gitignore +++ b/rethinkdb/.gitignore @@ -1,4 +1,4 @@ node_modules -rethinkdb.js -rethinkdb.js.map -rethinkdb.d.ts \ No newline at end of file +index.js +index.js.map +index.d.ts \ No newline at end of file diff --git a/rethinkdb/build_and_publish.sh b/rethinkdb/build_and_publish.sh index c14c413..3a439e3 100644 --- a/rethinkdb/build_and_publish.sh +++ b/rethinkdb/build_and_publish.sh @@ -5,5 +5,5 @@ VERSION=1.0.$1 export PATH=$(npm bin):$PATH npm version $VERSION || true tsc -babel rethinkdb.js -o rethinkdb.js +babel index.js -o index.js npm publish diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts new file mode 100644 index 0000000..9132317 --- /dev/null +++ b/rethinkdb/rethinkdb.d.ts @@ -0,0 +1,150 @@ + +interface R extends RDB { + db(name: string): RDB + expr(obj: any): RDatum + uuid(): RDatum + range(): RStream + range(count: number): RStream + range(initial: number, count: number): RStream + epochTime(epoch: number): RDatum +} + +interface RDB { + table(name: string): RTable + tableList(): RArray + tableDrop(name: string): RDatum<{tables_dropped: 1, config_changes: {old_val: R_TableConfig, new_val: null}}> + tableCreate(name: string, opts?: R_TableCreateOptions): RDatum<{tables_created: 1, config_changes: {old_val: null, new_val: R_TableConfig}}> +} + +type RPrimitive = null | string | number | Date | boolean | Buffer + +type RDatumfy = { + [P in keyof T]: T[P] | RDatum; +}; + +interface R_TableConfig { + +} + +interface R_TableCreateOptions { + primaryKey?: string + durability?: "soft" | "hard" + shards?: number + replicas?: number | {[server: string]: number} + primaryReplicaTag?: string +} + +interface RStreamOrDatum { + count(): RDatum + avg(): RDatum + min(): RDatum + max(): RDatum + orderBy(field: string): RArray +} + +interface RDatum extends RStreamOrDatum, PromiseLike { + do(func: (obj: this) => X): RDatum + do(func: (obj: this) => any): RDatum + default(val: X): RDatum + default(val: any): RDatum + (idx: K): RDatum + (idx: number | RDatum): RDatum + merge(op: (e: RDatum) => any): RDatum + merge(op: any): RDatum + map(func: (e: RDatum) => any): RArray + sub(other: any): RDatum + add(...others: any[]): RDatum + append(other: any): RDatum +} + +interface RArray extends RDatum { + (idx: number | RDatum): RDatum + map(func: (e: RDatum) => any): RArray + orderBy(field: string): RArray + append(other: T): RArray +} + +interface RStream extends PromiseLike, RStreamOrDatum { + (idx: number): RDatum + map(func: (arg: RDatum) => any): RStream + orderBy(field: string): RArray + coerceTo(type: "array"): RArray +} + +interface R_UpdateOptions { + durability?: "hard" | "soft" + returnChanges?: true | false | "always" + nonAtomic?: boolean +} + +interface R_UpdateResult { + replaced: number + unchanged: number + skipped: number + errors: number + first_error?: string + deleted: 0 + inserted: 0 +} + +type RUpdateObj = Partial | RDatum | ((obj: RDatum) => any) + +interface RTableSlice extends RStream { + update(obj: RUpdateObj, options: Opts): RDatum + update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum + delete(): RDatum<{}> +} + +interface RTableRow extends RDatum { + update(obj: RUpdateObj, options: Opts): RDatum + update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum + delete(): RDatum<{}> +} + +interface R_InsertOptions { + durability?: "hard" | "soft" + returnChanges?: true | false | "always" + conflict?: "error" | "replace" | "update" | ((id: string, oldDoc: RDatum, newDoc: RDatum) => any) +} + +interface R_InsertResult { + inserted: number + replaced: number + unchanged: number + errors: number + first_error?: string + deleted: 0 + skipped: 0 + generated_keys: string[] + warnings?: string[] +} + +interface R_IndexStatus { + index: string + ready: boolean + progress?: number + function: Buffer + multi: boolean + geo: boolean + outdated: boolean + query: string +} + +type RInsertObj = RDatumfy | RDatum | RStream | RDatum | RDatumfy[] | (() => RInsertObj) + +interface RTable extends RTableSlice { + get(id: any): RTableRow + insert & {returnChanges: true | "always"}>(obj: RInsertObj, options: Opts): RDatum + insert(obj: RInsertObj, options?: R_InsertOptions): RDatum + + indexList(): RArray + indexCreate(name: string, func: (obj: RDatum) => any, opts?: {multi?: boolean, geo?: boolean}): RDatum<{created: 1}> + indexCreate(name: K, opts?: {multi?: boolean, geo?: boolean}): RDatum<{created: 1}> + indexDrop(name: string): RDatum<{dropped: 1}> + indexStatus(...names: string[]): RArray + + getAll(id: any, opts: {index: string}): RStream + getAll(id1: any, id2: any, opts: {index: string}): RStream + getAll(id1: any, id2: any, id3: any, opts: {index: string}): RStream + getAll(id1: any, id2: any, id3: any, id4: any, opts: {index: string}): RStream +} From 8917c3be8fdd034adf3cc938ee34581e597f87ad Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 09:00:01 -0300 Subject: [PATCH 006/625] add r.add --- rethinkdb/rethinkdb.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 9132317..8479ebd 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -7,6 +7,7 @@ interface R extends RDB { range(count: number): RStream range(initial: number, count: number): RStream epochTime(epoch: number): RDatum + add(...objs: any[]): RDatum } interface RDB { From b02f66c24ba6c9c833da20f930a3a37948bb5ef4 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 10:56:08 -0300 Subject: [PATCH 007/625] Handler on android --- target_java_android.cr | 43 +++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 5c57594..d3bfef3 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -271,26 +271,31 @@ END } @Override - public void onResponse(Call call, Response response) throws IOException { - if (response.code() >= 500) { - Log.e("API Fatal", response.body().string()); - callback.onFailure("HTTP " + response.code()); - return; - } - - try { - JSONObject body = new JSONObject(response.body().string()); - if (!body.getBoolean("ok")) { - String type = body.getJSONObject("error").getString("type"); - String message = body.getJSONObject("error").getString("message"); - callback.onError(type, message); - } else { - callback.onResult(body); + public void onResponse(Call call, final Response response) throws IOException { + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + if (response.code() >= 500) { + Log.e("API Fatal", response.body().string()); + callback.onFailure("HTTP " + response.code()); + return; + } + + try { + JSONObject body = new JSONObject(response.body().string()); + if (!body.getBoolean("ok")) { + String type = body.getJSONObject("error").getString("type"); + String message = body.getJSONObject("error").getString("message"); + callback.onError(type, message); + } else { + callback.onResult(body); + } + } catch (JSONException e) { + e.printStackTrace(); + callback.onError("bug", e.getMessage()); + } } - } catch (JSONException e) { - e.printStackTrace(); - callback.onError("bug", e.getMessage()); - } + }); } }); } From 2036f159e3969737694ed43dffd80aa224d0305e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 11:15:18 -0300 Subject: [PATCH 008/625] Fix import --- target_java_android.cr | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target_java_android.cr b/target_java_android.cr index d3bfef3..30dbb88 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -9,6 +9,8 @@ import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.Build; +import android.os.Handler; +import android.os.Looper; import android.provider.Settings; import android.util.Base64; import android.util.Log; From 21361305492560bf969de55b0dd22c52af2353ca Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 11:27:43 -0300 Subject: [PATCH 009/625] try catch --- target_java_android.cr | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 30dbb88..2f6a248 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -278,7 +278,11 @@ END @Override public void run() { if (response.code() >= 500) { - Log.e("API Fatal", response.body().string()); + try { + Log.e("API Fatal", response.body().string()); + } catch (IOException e) { + e.printStackTrace(); + } callback.onFailure("HTTP " + response.code()); return; } @@ -292,7 +296,7 @@ END } else { callback.onResult(body); } - } catch (JSONException e) { + } catch (JSONException | IOException e) { e.printStackTrace(); callback.onError("bug", e.getMessage()); } From 1eccb348c569df4dcb13aac8fdba25ae03f5c901 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 13:07:46 -0300 Subject: [PATCH 010/625] ios target --- main.cr | 1 + target.cr | 2 +- target_java.cr | 4 -- target_swift.cr | 125 +++++++++++++++++++++++++++++++++++ target_swift_ios.cr | 158 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 285 insertions(+), 5 deletions(-) create mode 100644 target_swift.cr create mode 100644 target_swift_ios.cr diff --git a/main.cr b/main.cr index 3e431b1..eacd374 100644 --- a/main.cr +++ b/main.cr @@ -2,6 +2,7 @@ require "./lexer" require "./parser" require "./ast_to_s" require "./target_java_android" +require "./target_swift_ios" require "./target_typescript_server" require "./target_typescript_web" require "option_parser" diff --git a/target.cr b/target.cr index f8e6899..f24ea61 100644 --- a/target.cr +++ b/target.cr @@ -36,6 +36,6 @@ abstract class Target end def ident(code) - code.split("\n").map {|line| " " + line}.join("\n").gsub(/\n\s+$/, "\n") + code.split("\n").map {|line| " " + line}.join("\n").gsub(/\n\s+$/m, "\n") end end \ No newline at end of file diff --git a/target_java.cr b/target_java.cr index 1b64b9a..bba3951 100644 --- a/target_java.cr +++ b/target_java.cr @@ -99,10 +99,6 @@ END end end - def operation_type(op : AST::Operation) - "#{operation_args(op)} => Promise<#{operation_ret(op)}>" - end - def get_field_from_json_object(t : AST::Type, src : String, name : String) case t when AST::StringPrimitiveType, AST::DatePrimitiveType, AST::DateTimePrimitiveType, AST::BytesPrimitiveType diff --git a/target_swift.cr b/target_swift.cr new file mode 100644 index 0000000..1e0089d --- /dev/null +++ b/target_swift.cr @@ -0,0 +1,125 @@ +require "./target" + +abstract class SwiftTarget < Target + def ident(code) + super super code + end + + def native_type(t : AST::PrimitiveType) + case t + when AST::StringPrimitiveType; "String" + when AST::IntPrimitiveType; "Int" + when AST::UIntPrimitiveType; "UInt" + when AST::FloatPrimitiveType; "Double" + when AST::DatePrimitiveType; "Date" + when AST::DateTimePrimitiveType; "Date" + when AST::BoolPrimitiveType; "Bool" + when AST::BytesPrimitiveType; "Data" + when AST::VoidPrimitiveType; "void" + else + raise "BUG! Should handle primitive #{t.class}" + end + end + + def native_type(t : AST::OptionalType) + native_type(t.base) + "?" + end + + def native_type(t : AST::ArrayType) + native_type(t.base) + "[]" + end + + def native_type(t : AST::CustomTypeReference) + t.name + end + + def generate_custom_type_interface(custom_type) + String.build do |io| + io << "class #{custom_type.name} {\n" + custom_type.fields.each do |field| + io << ident "var #{field.name}: #{native_type field.type}\n" + end + io << ident <<-END + +NSDictionary toJSON() { + let json: NSMutableDictionary = [:] + +END + custom_type.fields.each do |field| + io << ident ident "json[\"#{field.name}\"] = #{type_to_json field.type, field.name}\n" + end + io << ident <<-END + return json +} + +static #{custom_type.name} fromJSON(final NSDictionary json) { + let obj = #{custom_type.name}() + +END + custom_type.fields.each do |field| + io << ident ident "obj.#{field.name} = #{type_from_json field.type, "json[#{field.name.inspect}]"}\n" + end + io << ident <<-END + return obj; +} + +END + io << "}" + end + end + + def type_from_json(t : AST::Type, src : String) + case t + when AST::StringPrimitiveType + "#{src} as! String" + when AST::IntPrimitiveType + "#{src} as! Int" + when AST::UIntPrimitiveType + "#{src} as! UInt" + when AST::FloatPrimitiveType + "#{src} as! Double" + when AST::BoolPrimitiveType + "#{src} as! Bool" + when AST::DatePrimitiveType + "APIInternal.decodeDate(#{src})" + when AST::DateTimePrimitiveType + "APIInternal.decodeDateTime(#{src})" + when AST::BytesPrimitiveType + "Data(base64EncodedString: ${src} as! String, options: NSDataBase64DecodingOptions(rawValue: 0))!" + when AST::VoidPrimitiveType + "nil" + when AST::OptionalType + "#{src} == nil ? nil : #{type_from_json(t.base, src)}" + when AST::ArrayType + "(#{src} as! [AnyObject]).map({(el) -> #{native_type t.base} in return #{type_from_json t.base, "el"}})" + when AST::CustomTypeReference + ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! + "#{ct.name}.fromJSON(#{src})" + else + raise "Unknown type" + end + end + + def type_to_json(t : AST::Type, src : String) + case t + when AST::StringPrimitiveType, AST::IntPrimitiveType, AST::UIntPrimitiveType, AST::FloatPrimitiveType, AST::BoolPrimitiveType + "#{src}" + when AST::DatePrimitiveType + "APIInternal.encodeDate(#{src})" + when AST::DateTimePrimitiveType + "APIInternal.encodeDateTime(#{src})" + when AST::BytesPrimitiveType + "#{src}.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0))" + when AST::VoidPrimitiveType + "nil" + when AST::OptionalType + "#{src} == nil ? nil : #{type_to_json(t.base, src + "!")}" + when AST::ArrayType + "#{src}.map({ return #{type_to_json t.base, "$0"} })" + when AST::CustomTypeReference + "#{src}.toJSON()" + else + raise "Unknown type" + end + end +end diff --git a/target_swift_ios.cr b/target_swift_ios.cr new file mode 100644 index 0000000..601c4f0 --- /dev/null +++ b/target_swift_ios.cr @@ -0,0 +1,158 @@ +require "./target_swift" + +class SwiftIosTarget < SwiftTarget + def gen + @io << <<-END +import Alamofire + +class API { + +END + + @ast.custom_types.each do |custom_type| + @io << ident generate_custom_type_interface(custom_type) + @io << "\n\n" + end + + # static func logIn(email: String, callback: @escaping (_ result: String, _ error: APIInternal.Error?) -> Void) { + + # } + @ast.operations.each do |op| + args = op.args.map {|arg| "#{arg.name}: #{native_type arg.type}" } + if op.return_type.is_a? AST::VoidPrimitiveType + args << "callback: @escaping (_ error: APIInternal.Error?) -> Void" + else + args << "callback: @escaping (_ result: #{native_type op.return_type}, _ error: APIInternal.Error?) -> Void" + end + @io << ident(String.build do |io| + io << "static public func #{op.fnName}(#{args.join(", ")}) {\n" + io << ident(String.build do |io| + io << <<-END +let args: NSMutableDictionary = [:] + +END + op.args.each do |arg| + io << "args[\"#{arg.name}\"] = #{type_to_json arg.type, arg.name}\n" + end + io << <<-END + +APIInternal.makeRequest(#{op.fnName.inspect}, args) {(result: AnyObject?, error: APIInternal.Error?) -> Void in + if error { + callback(nil, error); + } else { + callback.onResult(#{"#{type_from_json op.return_type, "result"}, " unless op.return_type.is_a? AST::VoidPrimitiveType}nil); + } +} + +END + end) + io << "}" + end) + @io << "\n\n" + end + + @io << <<-END +} + +class APIInternal { + static var baseUrl = "api.nutriserie.com.br/user" + + class Error { + var type: String + var message: String + + init(type: String, message: String) { + self.type = type + self.message = message + } + } + + static func device() { + let device = NSMutableDictionary() + device["platform"] = "ios" + device["fingerprint"] = "." + device["platformVersion"] = "iOS " + UIDevice.current.systemVersion + " on " + UIDevice.current.model + if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String { + device["version"] = version + } else { + device["version"] = "unknown" + } + device["language"] = NSLocale.preferredLanguages[0] + if let deviceId = UserDefaults.standard.value(forKey: "device-id") as? String { + device["id"] = deviceId + } + return device + } + + static func randomBytesHex(len: Int32) { + var randomBytes = [UInt8](count: len, repeatedValue: 0) + SecRandomCopyBytes(kSecRandomDefault, len, &randomBytes) + return randomBytes.map({String(format: "%02hhx", $0)}).joinWithSeparator("") + } + + static func decodeDate(str: String) -> NSDate { + let formatter = NSDateFormatter() + formatter.calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian) + formatter.timeZone = NSTimeZone(name: "UTC") + formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") + formatter.dateFormat = "yyyy-MM-dd" + return formatter.dateFromString(str)! + } + + static func encodeDate(date: NSDate) -> String { + let formatter = NSDateFormatter() + formatter.calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian) + formatter.timeZone = NSTimeZone(name: "UTC") + formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") + formatter.dateFormat = "yyyy-MM-dd" + return formatter.stringFromDate(date) + } + + static func decodeDateTime(str: String) -> NSDate { + let formatter = NSDateFormatter() + formatter.calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian) + formatter.timeZone = NSTimeZone(name: "UTC") + formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") + formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" + return formatter.dateFromString(str)! + } + + static func encodeDateTime(date: NSDate) -> String { + let formatter = NSDateFormatter() + formatter.calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian) + formatter.timeZone = NSTimeZone(name: "UTC") + formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") + formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" + return formatter.stringFromDate(date) + } + + static func makeRequest(name: String, args: NSDictionary, callback: (result: AnyObject?, error: Error?) -> Void) { + let body = [ + "id": randomBytesHex(16), + "device": device(), + "name": name, + "args": args + ] + + Alamofire.request(.POST, "https://\(baseUrl)/\(name)", parameters: body, encoding: ParameterEncoding.JSON, headers: header).validate().responseJSON { (response) in + switch response.result { + case .Failure(let err): + callback(nil, Error("Connection", err)) + break + case .Success(let body): + if body["ok"] as Bool { + callback(result: body["result"], error: nil) + } else { + let error = body["error"] as! NSDictionary + callback(result: nil, error: Error(error["type"], error["message"])) + } + break + } + } + } +} +END + end +end + +Target.register(SwiftIosTarget, language: "swift", is_server: false) From bbbc51a9fb578ac73ac5fa273863fb0c543930d3 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 15:00:50 -0300 Subject: [PATCH 011/625] add node types to web target --- target-web/package.json | 1 + target-web/yarn.lock | 148 ++++++++++++++++++++++------------------ 2 files changed, 84 insertions(+), 65 deletions(-) diff --git a/target-web/package.json b/target-web/package.json index 203e89a..01d1ebf 100644 --- a/target-web/package.json +++ b/target-web/package.json @@ -2,6 +2,7 @@ "name": "@cubos/api", "version": "0.0", "dependencies": { + "@types/node": "^7.0.8", "@types/ua-parser-js": "^0.7.30", "babel-runtime": "^6.23.0", "moment": "^2.17.1", diff --git a/target-web/yarn.lock b/target-web/yarn.lock index 46f8607..04deb1a 100644 --- a/target-web/yarn.lock +++ b/target-web/yarn.lock @@ -2,6 +2,10 @@ # yarn lockfile v1 +"@types/node@^7.0.8": + version "7.0.8" + resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.8.tgz#25e4dd804b630c916ae671233e6d71f6ce18124a" + "@types/ua-parser-js@^0.7.30": version "0.7.30" resolved "https://npm.cubos.io/@types%2fua-parser-js/-/ua-parser-js-0.7.30.tgz#9096e5552ff02f8d018a17efac69b4dc75083f8b" @@ -11,8 +15,8 @@ abbrev@1: resolved "https://npm.cubos.io/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" ajv@^4.9.1: - version "4.11.4" - resolved "https://npm.cubos.io/ajv/-/ajv-4.11.4.tgz#ebf3a55d4b132ea60ff5847ae85d2ef069960b45" + version "4.11.5" + resolved "https://npm.cubos.io/ajv/-/ajv-4.11.5.tgz#b6ee74657b993a01dce44b7944d56f485828d5bd" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" @@ -65,14 +69,14 @@ asn1@~0.2.3: version "0.2.3" resolved "https://npm.cubos.io/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + assert-plus@^0.2.0: version "0.2.0" resolved "https://npm.cubos.io/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" -assert-plus@^1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - async-each@^1.0.0: version "1.0.1" resolved "https://npm.cubos.io/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" @@ -90,12 +94,12 @@ aws4@^1.2.1: resolved "https://npm.cubos.io/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" babel-cli@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-cli/-/babel-cli-6.23.0.tgz#52ff946a2b0f64645c35e7bd5eea267aa0948c0f" + version "6.24.0" + resolved "https://npm.cubos.io/babel-cli/-/babel-cli-6.24.0.tgz#a05ffd210dca0c288a26d5319c5ac8669a265ad0" dependencies: - babel-core "^6.23.0" + babel-core "^6.24.0" babel-polyfill "^6.23.0" - babel-register "^6.23.0" + babel-register "^6.24.0" babel-runtime "^6.22.0" commander "^2.8.1" convert-source-map "^1.1.0" @@ -118,15 +122,15 @@ babel-code-frame@^6.22.0: esutils "^2.0.2" js-tokens "^3.0.0" -babel-core@^6.23.0: - version "6.23.1" - resolved "https://npm.cubos.io/babel-core/-/babel-core-6.23.1.tgz#c143cb621bb2f621710c220c5d579d15b8a442df" +babel-core@^6.24.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-core/-/babel-core-6.24.0.tgz#8f36a0a77f5c155aed6f920b844d23ba56742a02" dependencies: babel-code-frame "^6.22.0" - babel-generator "^6.23.0" + babel-generator "^6.24.0" babel-helpers "^6.23.0" babel-messages "^6.23.0" - babel-register "^6.23.0" + babel-register "^6.24.0" babel-runtime "^6.22.0" babel-template "^6.23.0" babel-traverse "^6.23.1" @@ -142,9 +146,9 @@ babel-core@^6.23.0: slash "^1.0.0" source-map "^0.5.0" -babel-generator@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.23.0.tgz#6b8edab956ef3116f79d8c84c5a3c05f32a74bc5" +babel-generator@^6.24.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.24.0.tgz#eba270a8cc4ce6e09a61be43465d7c62c1f87c56" dependencies: babel-messages "^6.23.0" babel-runtime "^6.22.0" @@ -364,17 +368,17 @@ babel-plugin-transform-es2015-literals@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-modules-amd@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.22.0.tgz#bf69cd34889a41c33d90dfb740e0091ccff52f21" +babel-plugin-transform-es2015-modules-amd@^6.24.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.0.tgz#a1911fb9b7ec7e05a43a63c5995007557bcf6a2e" dependencies: - babel-plugin-transform-es2015-modules-commonjs "^6.22.0" + babel-plugin-transform-es2015-modules-commonjs "^6.24.0" babel-runtime "^6.22.0" babel-template "^6.22.0" -babel-plugin-transform-es2015-modules-commonjs@^6.22.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.23.0.tgz#cba7aa6379fb7ec99250e6d46de2973aaffa7b92" +babel-plugin-transform-es2015-modules-commonjs@^6.24.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.24.0.tgz#e921aefb72c2cc26cb03d107626156413222134f" dependencies: babel-plugin-transform-strict-mode "^6.22.0" babel-runtime "^6.22.0" @@ -389,11 +393,11 @@ babel-plugin-transform-es2015-modules-systemjs@^6.22.0: babel-runtime "^6.22.0" babel-template "^6.23.0" -babel-plugin-transform-es2015-modules-umd@^6.22.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.23.0.tgz#8d284ae2e19ed8fe21d2b1b26d6e7e0fcd94f0f1" +babel-plugin-transform-es2015-modules-umd@^6.24.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.0.tgz#fd5fa63521cae8d273927c3958afd7c067733450" dependencies: - babel-plugin-transform-es2015-modules-amd "^6.22.0" + babel-plugin-transform-es2015-modules-amd "^6.24.0" babel-runtime "^6.22.0" babel-template "^6.23.0" @@ -492,8 +496,8 @@ babel-polyfill@^6.23.0: regenerator-runtime "^0.10.0" babel-preset-es2015@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-preset-es2015/-/babel-preset-es2015-6.22.0.tgz#af5a98ecb35eb8af764ad8a5a05eb36dc4386835" + version "6.24.0" + resolved "https://npm.cubos.io/babel-preset-es2015/-/babel-preset-es2015-6.24.0.tgz#c162d68b1932696e036cd3110dc1ccd303d2673a" dependencies: babel-plugin-check-es2015-constants "^6.22.0" babel-plugin-transform-es2015-arrow-functions "^6.22.0" @@ -506,10 +510,10 @@ babel-preset-es2015@^6.22.0: babel-plugin-transform-es2015-for-of "^6.22.0" babel-plugin-transform-es2015-function-name "^6.22.0" babel-plugin-transform-es2015-literals "^6.22.0" - babel-plugin-transform-es2015-modules-amd "^6.22.0" - babel-plugin-transform-es2015-modules-commonjs "^6.22.0" + babel-plugin-transform-es2015-modules-amd "^6.24.0" + babel-plugin-transform-es2015-modules-commonjs "^6.24.0" babel-plugin-transform-es2015-modules-systemjs "^6.22.0" - babel-plugin-transform-es2015-modules-umd "^6.22.0" + babel-plugin-transform-es2015-modules-umd "^6.24.0" babel-plugin-transform-es2015-object-super "^6.22.0" babel-plugin-transform-es2015-parameters "^6.22.0" babel-plugin-transform-es2015-shorthand-properties "^6.22.0" @@ -533,11 +537,11 @@ babel-preset-es2017@^6.22.0: babel-plugin-syntax-trailing-function-commas "^6.22.0" babel-plugin-transform-async-to-generator "^6.22.0" -babel-register@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-register/-/babel-register-6.23.0.tgz#c9aa3d4cca94b51da34826c4a0f9e08145d74ff3" +babel-register@^6.24.0: + version "6.24.0" + resolved "https://npm.cubos.io/babel-register/-/babel-register-6.24.0.tgz#5e89f8463ba9970356d02eb07dabe3308b080cfd" dependencies: - babel-core "^6.23.0" + babel-core "^6.24.0" babel-runtime "^6.22.0" core-js "^2.4.0" home-or-tmp "^2.0.0" @@ -716,8 +720,8 @@ dashdash@^1.12.0: assert-plus "^1.0.0" debug@^2.1.1, debug@^2.2.0: - version "2.6.1" - resolved "https://npm.cubos.io/debug/-/debug-2.6.1.tgz#79855090ba2c4e3115cc7d8769491d58f0491351" + version "2.6.3" + resolved "https://npm.cubos.io/debug/-/debug-2.6.3.tgz#0f7eb8c30965ec08c72accfa0130c8b79984141d" dependencies: ms "0.7.2" @@ -845,8 +849,8 @@ fstream-ignore@~1.0.5: minimatch "^3.0.0" fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10: - version "1.0.10" - resolved "https://npm.cubos.io/fstream/-/fstream-1.0.10.tgz#604e8a92fe26ffd9f6fae30399d4984e1ab22822" + version "1.0.11" + resolved "https://npm.cubos.io/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" dependencies: graceful-fs "^4.1.2" inherits "~2.0.0" @@ -912,7 +916,7 @@ har-schema@^1.0.5: version "1.0.5" resolved "https://npm.cubos.io/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" -har-validator@~4.2.0: +har-validator@~4.2.1: version "4.2.1" resolved "https://npm.cubos.io/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" dependencies: @@ -985,8 +989,8 @@ is-binary-path@^1.0.0: binary-extensions "^1.0.0" is-buffer@^1.0.2: - version "1.1.4" - resolved "https://npm.cubos.io/is-buffer/-/is-buffer-1.1.4.tgz#cfc86ccd5dc5a52fa80489111c6920c457e2d98b" + version "1.1.5" + resolved "https://npm.cubos.io/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" is-dotfile@^1.0.0: version "1.0.2" @@ -1105,9 +1109,10 @@ jsonify@~0.0.0: resolved "https://npm.cubos.io/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" jsprim@^1.2.2: - version "1.3.1" - resolved "https://npm.cubos.io/jsprim/-/jsprim-1.3.1.tgz#2a7256f70412a29ee3670aaca625994c4dcff252" + version "1.4.0" + resolved "https://npm.cubos.io/jsprim/-/jsprim-1.4.0.tgz#a3b87e40298d8c380552d8cc7628a0bb95a22918" dependencies: + assert-plus "1.0.0" extsprintf "1.0.2" json-schema "0.2.3" verror "1.3.6" @@ -1244,7 +1249,13 @@ object.omit@^2.0.0: for-own "^0.1.4" is-extendable "^0.1.1" -once@^1.3.0, once@~1.3.3: +once@^1.3.0: + version "1.4.0" + resolved "https://npm.cubos.io/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +once@~1.3.3: version "1.3.3" resolved "https://npm.cubos.io/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20" dependencies: @@ -1299,9 +1310,9 @@ punycode@^1.4.1: version "1.4.1" resolved "https://npm.cubos.io/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" -qs@~6.3.0: - version "6.3.2" - resolved "https://npm.cubos.io/qs/-/qs-6.3.2.tgz#e75bd5f6e268122a2a0e0bda630b2550c166502c" +qs@~6.4.0: + version "6.4.0" + resolved "https://npm.cubos.io/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" randomatic@^1.1.3: version "1.1.6" @@ -1320,8 +1331,8 @@ rc@~1.1.6: strip-json-comments "~2.0.1" "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.2: - version "2.2.3" - resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.3.tgz#9cf49463985df016c8ae8813097a9293a9b33729" + version "2.2.6" + resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.6.tgz#8b43aed76e71483938d12a8d46c6cf1a00b1f816" dependencies: buffer-shims "^1.0.0" core-util-is "~1.0.0" @@ -1408,8 +1419,8 @@ repeating@^2.0.0: is-finite "^1.0.0" request@^2.79.0: - version "2.80.0" - resolved "https://npm.cubos.io/request/-/request-2.80.0.tgz#8cc162d76d79381cdefdd3505d76b80b60589bd0" + version "2.81.0" + resolved "https://npm.cubos.io/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" dependencies: aws-sign2 "~0.6.0" aws4 "^1.2.1" @@ -1418,7 +1429,7 @@ request@^2.79.0: extend "~3.0.0" forever-agent "~0.6.1" form-data "~2.1.1" - har-validator "~4.2.0" + har-validator "~4.2.1" hawk "~3.1.3" http-signature "~1.1.0" is-typedarray "~1.0.0" @@ -1427,10 +1438,11 @@ request@^2.79.0: mime-types "~2.1.7" oauth-sign "~0.8.1" performance-now "^0.2.0" - qs "~6.3.0" + qs "~6.4.0" + safe-buffer "^5.0.1" stringstream "~0.0.4" tough-cookie "~2.3.0" - tunnel-agent "~0.4.1" + tunnel-agent "^0.6.0" uuid "^3.0.0" rimraf@2, rimraf@~2.5.1, rimraf@~2.5.4: @@ -1439,6 +1451,10 @@ rimraf@2, rimraf@~2.5.1, rimraf@~2.5.4: dependencies: glob "^7.0.5" +safe-buffer@^5.0.1: + version "5.0.1" + resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" + semver@~5.3.0: version "5.3.0" resolved "https://npm.cubos.io/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" @@ -1466,12 +1482,12 @@ sntp@1.x.x: hoek "2.x.x" source-map-support@^0.4.2: - version "0.4.11" - resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.11.tgz#647f939978b38535909530885303daf23279f322" + version "0.4.13" + resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.13.tgz#9782e6f7deb424d5f173327a1879eb46453bdcd4" dependencies: - source-map "^0.5.3" + source-map "^0.5.6" -source-map@^0.5.0, source-map@^0.5.3: +source-map@^0.5.0, source-map@^0.5.6: version "0.5.6" resolved "https://npm.cubos.io/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" @@ -1555,9 +1571,11 @@ trim-right@^1.0.1: version "1.0.1" resolved "https://npm.cubos.io/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" -tunnel-agent@~0.4.1: - version "0.4.3" - resolved "https://npm.cubos.io/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://npm.cubos.io/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + dependencies: + safe-buffer "^5.0.1" tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" From 562ad89efb50cee3ae345047eabe54dd983a2dcd Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 15:00:57 -0300 Subject: [PATCH 012/625] io target --- target_swift.cr | 74 ++++++++++++++++++++++++++-------- target_swift_ios.cr | 98 +++++++++++++++++++++++---------------------- 2 files changed, 109 insertions(+), 63 deletions(-) diff --git a/target_swift.cr b/target_swift.cr index 1e0089d..61ea19a 100644 --- a/target_swift.cr +++ b/target_swift.cr @@ -26,7 +26,7 @@ abstract class SwiftTarget < Target end def native_type(t : AST::ArrayType) - native_type(t.base) + "[]" + "[#{native_type(t.base)}]" end def native_type(t : AST::CustomTypeReference) @@ -41,26 +41,42 @@ abstract class SwiftTarget < Target end io << ident <<-END -NSDictionary toJSON() { - let json: NSMutableDictionary = [:] +init() { END custom_type.fields.each do |field| - io << ident ident "json[\"#{field.name}\"] = #{type_to_json field.type, field.name}\n" + io << ident ident "#{field.name} = #{default_value field.type}\n" + end + io << ident <<-END +} + +init(#{custom_type.fields.map{|f| "#{f.name}: #{native_type f.type}"}.join(", ")}) { + +END + custom_type.fields.each do |field| + io << ident ident "self.#{field.name} = #{field.name}\n" end io << ident <<-END - return json } -static #{custom_type.name} fromJSON(final NSDictionary json) { - let obj = #{custom_type.name}() +init(json: NSDictionary) { + +END + custom_type.fields.each do |field| + io << ident ident "#{field.name} = #{type_from_json field.type, "json[#{field.name.inspect}]"}\n" + end + io << ident <<-END +} + +func toJSON() -> NSDictionary { + let json: NSMutableDictionary = [:] END custom_type.fields.each do |field| - io << ident ident "obj.#{field.name} = #{type_from_json field.type, "json[#{field.name.inspect}]"}\n" + io << ident ident "json[\"#{field.name}\"] = #{type_to_json field.type, field.name}\n" end io << ident <<-END - return obj; + return json } END @@ -68,6 +84,32 @@ END end end + def default_value(t : AST::Type) + case t + when AST::StringPrimitiveType + "\"\"" + when AST::IntPrimitiveType, AST::UIntPrimitiveType, AST::FloatPrimitiveType + "0" + when AST::BoolPrimitiveType + "false" + when AST::DatePrimitiveType, AST::DateTimePrimitiveType + "Date()" + when AST::BytesPrimitiveType + "Data()" + when AST::VoidPrimitiveType + "nil" + when AST::OptionalType + "nil" + when AST::ArrayType + "[]" + when AST::CustomTypeReference + ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! + "#{ct.name}()" + else + raise "Unknown type" + end + end + def type_from_json(t : AST::Type, src : String) case t when AST::StringPrimitiveType @@ -81,11 +123,11 @@ END when AST::BoolPrimitiveType "#{src} as! Bool" when AST::DatePrimitiveType - "APIInternal.decodeDate(#{src})" + "APIInternal.decodeDate(str: #{src} as! String)" when AST::DateTimePrimitiveType - "APIInternal.decodeDateTime(#{src})" + "APIInternal.decodeDateTime(str: #{src} as! String)" when AST::BytesPrimitiveType - "Data(base64EncodedString: ${src} as! String, options: NSDataBase64DecodingOptions(rawValue: 0))!" + "Data(base64Encoded: #{src} as! String)!" when AST::VoidPrimitiveType "nil" when AST::OptionalType @@ -94,7 +136,7 @@ END "(#{src} as! [AnyObject]).map({(el) -> #{native_type t.base} in return #{type_from_json t.base, "el"}})" when AST::CustomTypeReference ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! - "#{ct.name}.fromJSON(#{src})" + "#{ct.name}(json: #{src} as! NSDictionary)" else raise "Unknown type" end @@ -105,11 +147,11 @@ END when AST::StringPrimitiveType, AST::IntPrimitiveType, AST::UIntPrimitiveType, AST::FloatPrimitiveType, AST::BoolPrimitiveType "#{src}" when AST::DatePrimitiveType - "APIInternal.encodeDate(#{src})" + "APIInternal.encodeDate(date: #{src})" when AST::DateTimePrimitiveType - "APIInternal.encodeDateTime(#{src})" + "APIInternal.encodeDateTime(date: #{src})" when AST::BytesPrimitiveType - "#{src}.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0))" + "#{src}.base64EncodedString()" when AST::VoidPrimitiveType "nil" when AST::OptionalType diff --git a/target_swift_ios.cr b/target_swift_ios.cr index 601c4f0..9dd7034 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -19,10 +19,15 @@ END # } @ast.operations.each do |op| args = op.args.map {|arg| "#{arg.name}: #{native_type arg.type}" } + if op.return_type.is_a? AST::VoidPrimitiveType args << "callback: @escaping (_ error: APIInternal.Error?) -> Void" else - args << "callback: @escaping (_ result: #{native_type op.return_type}, _ error: APIInternal.Error?) -> Void" + ret = op.return_type + unless ret.is_a? AST::OptionalType + ret = AST::OptionalType.new ret + end + args << "callback: @escaping (_ result: #{native_type ret}, _ error: APIInternal.Error?) -> Void" end @io << ident(String.build do |io| io << "static public func #{op.fnName}(#{args.join(", ")}) {\n" @@ -36,11 +41,11 @@ END end io << <<-END -APIInternal.makeRequest(#{op.fnName.inspect}, args) {(result: AnyObject?, error: APIInternal.Error?) -> Void in - if error { - callback(nil, error); +APIInternal.makeRequest(#{op.fnName.inspect}, args) { result, error in + if error != nil { + callback(#{"nil, " unless op.return_type.is_a? AST::VoidPrimitiveType}error); } else { - callback.onResult(#{"#{type_from_json op.return_type, "result"}, " unless op.return_type.is_a? AST::VoidPrimitiveType}nil); + callback(#{"#{type_from_json op.return_type, "result"}, " unless op.return_type.is_a? AST::VoidPrimitiveType}nil); } } @@ -61,13 +66,13 @@ class APIInternal { var type: String var message: String - init(type: String, message: String) { + init(_ type: String, _ message: String) { self.type = type self.message = message } } - static func device() { + static func device() -> NSDictionary { let device = NSMutableDictionary() device["platform"] = "ios" device["fingerprint"] = "." @@ -77,74 +82,73 @@ class APIInternal { } else { device["version"] = "unknown" } - device["language"] = NSLocale.preferredLanguages[0] + device["language"] = Locale.preferredLanguages[0] if let deviceId = UserDefaults.standard.value(forKey: "device-id") as? String { device["id"] = deviceId } return device } - static func randomBytesHex(len: Int32) { - var randomBytes = [UInt8](count: len, repeatedValue: 0) - SecRandomCopyBytes(kSecRandomDefault, len, &randomBytes) - return randomBytes.map({String(format: "%02hhx", $0)}).joinWithSeparator("") + static func randomBytesHex(len: Int) -> String { + var randomBytes = [UInt8](repeating: 0, count: len) + let _ = SecRandomCopyBytes(kSecRandomDefault, len, &randomBytes) + return randomBytes.map({String(format: "%02hhx", $0)}).joined(separator: "") } - static func decodeDate(str: String) -> NSDate { - let formatter = NSDateFormatter() - formatter.calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian) - formatter.timeZone = NSTimeZone(name: "UTC") - formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") + static func decodeDate(str: String) -> Date { + let formatter = DateFormatter() + formatter.calendar = Calendar(identifier: .gregorian) + formatter.locale = Locale(identifier: "en_US_POSIX") formatter.dateFormat = "yyyy-MM-dd" - return formatter.dateFromString(str)! + return formatter.date(from: str)! } - static func encodeDate(date: NSDate) -> String { - let formatter = NSDateFormatter() - formatter.calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian) - formatter.timeZone = NSTimeZone(name: "UTC") - formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") + static func encodeDate(date: Date) -> String { + let formatter = DateFormatter() + formatter.calendar = Calendar(identifier: .gregorian) + formatter.locale = Locale(identifier: "en_US_POSIX") formatter.dateFormat = "yyyy-MM-dd" - return formatter.stringFromDate(date) + return formatter.string(from: date) } - static func decodeDateTime(str: String) -> NSDate { - let formatter = NSDateFormatter() - formatter.calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian) - formatter.timeZone = NSTimeZone(name: "UTC") - formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") + static func decodeDateTime(str: String) -> Date { + let formatter = DateFormatter() + formatter.calendar = Calendar(identifier: .gregorian) + formatter.timeZone = TimeZone(abbreviation: "UTC") + formatter.locale = Locale(identifier: "en_US_POSIX") formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" - return formatter.dateFromString(str)! + return formatter.date(from: str)! } - static func encodeDateTime(date: NSDate) -> String { - let formatter = NSDateFormatter() - formatter.calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian) - formatter.timeZone = NSTimeZone(name: "UTC") - formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") + static func encodeDateTime(date: Date) -> String { + let formatter = DateFormatter() + formatter.calendar = Calendar(identifier: .gregorian) + formatter.timeZone = TimeZone(abbreviation: "UTC") + formatter.locale = Locale(identifier: "en_US_POSIX") formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" - return formatter.stringFromDate(date) + return formatter.string(from: date) } - static func makeRequest(name: String, args: NSDictionary, callback: (result: AnyObject?, error: Error?) -> Void) { + static func makeRequest(_ name: String, _ args: NSDictionary, callback: @escaping (_ result: AnyObject?, _ error: Error?) -> Void) { let body = [ - "id": randomBytesHex(16), + "id": randomBytesHex(len: 16), "device": device(), "name": name, "args": args - ] + ] as [String : Any] - Alamofire.request(.POST, "https://\(baseUrl)/\(name)", parameters: body, encoding: ParameterEncoding.JSON, headers: header).validate().responseJSON { (response) in + Alamofire.request("https://\\(baseUrl)/\\(name)", method: .post, parameters: body).validate().responseJSON { response in switch response.result { - case .Failure(let err): - callback(nil, Error("Connection", err)) + case .failure(let err): + callback(nil, Error("Connection", err.localizedDescription)) break - case .Success(let body): - if body["ok"] as Bool { - callback(result: body["result"], error: nil) + case .success(let value): + let body = value as! [String: AnyObject?] + if body["ok"] as! Bool { + callback(body["result"]!, nil) } else { - let error = body["error"] as! NSDictionary - callback(result: nil, error: Error(error["type"], error["message"])) + let error = body["error"] as! [String: String] + callback(nil, Error(error["type"]!, error["message"]!)) } break } From b01cc0ece2c2a9b7c958351d7404ec4c73004c97 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 16:18:41 -0300 Subject: [PATCH 013/625] add r.branch --- rethinkdb/rethinkdb.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 8479ebd..8326dc2 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -8,6 +8,9 @@ interface R extends RDB { range(initial: number, count: number): RStream epochTime(epoch: number): RDatum add(...objs: any[]): RDatum + branch(cond1: any, case1: any, otherwise: any): RDatum + branch(cond1: any, case1: any, cond2: any, case2: any, otherwise: any): RDatum + branch(cond1: any, case1: any, cond2: any, case2: any, cond3: any, case3: any, otherwise: any): RDatum } interface RDB { From e0354d8b26ecc31896fe0f917a2c86759469c39c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 16:21:36 -0300 Subject: [PATCH 014/625] More types for rethink --- rethinkdb/rethinkdb.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 8326dc2..843a300 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -11,6 +11,7 @@ interface R extends RDB { branch(cond1: any, case1: any, otherwise: any): RDatum branch(cond1: any, case1: any, cond2: any, case2: any, otherwise: any): RDatum branch(cond1: any, case1: any, cond2: any, case2: any, cond3: any, case3: any, otherwise: any): RDatum + not(obj: any): RDatum } interface RDB { @@ -59,6 +60,14 @@ interface RDatum extends RStreamOrDatum, PromiseLike { sub(other: any): RDatum add(...others: any[]): RDatum append(other: any): RDatum + + eq(other: any): RDatum + ne(other: any): RDatum + gt(other: any): RDatum + lt(other: any): RDatum + ge(other: any): RDatum + le(other: any): RDatum + not(): RDatum } interface RArray extends RDatum { From d90de32b0af6fd8dbdbe412d7f8c2a4ea9825d50 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 16:37:41 -0300 Subject: [PATCH 015/625] Add filter --- rethinkdb/rethinkdb.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 843a300..212cb58 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -61,6 +61,9 @@ interface RDatum extends RStreamOrDatum, PromiseLike { add(...others: any[]): RDatum append(other: any): RDatum + filter(obj: any): RDatum + filter(criteria: (obj: any) => boolean | RDatum): RDatum + eq(other: any): RDatum ne(other: any): RDatum gt(other: any): RDatum @@ -75,6 +78,8 @@ interface RArray extends RDatum { map(func: (e: RDatum) => any): RArray orderBy(field: string): RArray append(other: T): RArray + filter(obj: Partial>): RArray + filter(criteria: (obj: RDatum) => boolean | RDatum): RArray } interface RStream extends PromiseLike, RStreamOrDatum { @@ -82,6 +87,8 @@ interface RStream extends PromiseLike, RStreamOrDatum { map(func: (arg: RDatum) => any): RStream orderBy(field: string): RArray coerceTo(type: "array"): RArray + filter(obj: Partial>): RStream + filter(criteria: (obj: RDatum) => boolean | RDatum): RStream } interface R_UpdateOptions { From 0c89fa389a9bb5d6a2d335098d588fe7296eb7a8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 16:51:45 -0300 Subject: [PATCH 016/625] Add limit --- rethinkdb/rethinkdb.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 212cb58..d33c8ac 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -60,6 +60,7 @@ interface RDatum extends RStreamOrDatum, PromiseLike { sub(other: any): RDatum add(...others: any[]): RDatum append(other: any): RDatum + limit(other: any): RDatum filter(obj: any): RDatum filter(criteria: (obj: any) => boolean | RDatum): RDatum @@ -80,6 +81,7 @@ interface RArray extends RDatum { append(other: T): RArray filter(obj: Partial>): RArray filter(criteria: (obj: RDatum) => boolean | RDatum): RArray + limit(other: any): RArray } interface RStream extends PromiseLike, RStreamOrDatum { @@ -89,6 +91,7 @@ interface RStream extends PromiseLike, RStreamOrDatum { coerceTo(type: "array"): RArray filter(obj: Partial>): RStream filter(criteria: (obj: RDatum) => boolean | RDatum): RStream + limit(other: any): RStream } interface R_UpdateOptions { From 9e8098e6a10f7abd8cb67fcc9fbe3a18d87abc79 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 16:52:26 -0300 Subject: [PATCH 017/625] getAll return tableslice --- rethinkdb/rethinkdb.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index d33c8ac..d9cd3c9 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -166,8 +166,8 @@ interface RTable extends RTableSlice { indexDrop(name: string): RDatum<{dropped: 1}> indexStatus(...names: string[]): RArray - getAll(id: any, opts: {index: string}): RStream - getAll(id1: any, id2: any, opts: {index: string}): RStream - getAll(id1: any, id2: any, id3: any, opts: {index: string}): RStream - getAll(id1: any, id2: any, id3: any, id4: any, opts: {index: string}): RStream + getAll(id: any, opts: {index: string}): RTableSlice + getAll(id1: any, id2: any, opts: {index: string}): RTableSlice + getAll(id1: any, id2: any, id3: any, opts: {index: string}): RTableSlice + getAll(id1: any, id2: any, id3: any, id4: any, opts: {index: string}): RTableSlice } From 274805621b77e0dea5c28d9a23f4800286c4ff64 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 17:04:15 -0300 Subject: [PATCH 018/625] and/or --- rethinkdb/rethinkdb.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index d9cd3c9..a41cfcf 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -12,6 +12,8 @@ interface R extends RDB { branch(cond1: any, case1: any, cond2: any, case2: any, otherwise: any): RDatum branch(cond1: any, case1: any, cond2: any, case2: any, cond3: any, case3: any, otherwise: any): RDatum not(obj: any): RDatum + and(...objs: any[]): RDatum + or(...objs: any[]): RDatum } interface RDB { @@ -71,7 +73,10 @@ interface RDatum extends RStreamOrDatum, PromiseLike { lt(other: any): RDatum ge(other: any): RDatum le(other: any): RDatum + not(): RDatum + and(...objs: any[]): RDatum + or(...objs: any[]): RDatum } interface RArray extends RDatum { From 64a0f4cfa31f0a7b1b48b5d923f2fe68bf5c4177 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 17:15:30 -0300 Subject: [PATCH 019/625] r.now() --- rethinkdb/rethinkdb.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index a41cfcf..e80ee55 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -14,6 +14,7 @@ interface R extends RDB { not(obj: any): RDatum and(...objs: any[]): RDatum or(...objs: any[]): RDatum + now(): RDatum } interface RDB { From dd658195e5699a16512ce48182796403df668814 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 18:51:27 -0300 Subject: [PATCH 020/625] deeppartial to rethinkdb --- rethinkdb/rethinkdb.d.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index e80ee55..3bc1cd1 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -27,7 +27,11 @@ interface RDB { type RPrimitive = null | string | number | Date | boolean | Buffer type RDatumfy = { - [P in keyof T]: T[P] | RDatum; + [P in keyof T]: T[P] | RDatum | RDatumfy; +}; + +type DeepPartial = { + [P in keyof T]?: DeepPartial; }; interface R_TableConfig { @@ -85,7 +89,7 @@ interface RArray extends RDatum { map(func: (e: RDatum) => any): RArray orderBy(field: string): RArray append(other: T): RArray - filter(obj: Partial>): RArray + filter(obj: DeepPartial>): RArray filter(criteria: (obj: RDatum) => boolean | RDatum): RArray limit(other: any): RArray } @@ -95,7 +99,7 @@ interface RStream extends PromiseLike, RStreamOrDatum { map(func: (arg: RDatum) => any): RStream orderBy(field: string): RArray coerceTo(type: "array"): RArray - filter(obj: Partial>): RStream + filter(obj: DeepPartial>): RStream filter(criteria: (obj: RDatum) => boolean | RDatum): RStream limit(other: any): RStream } @@ -116,7 +120,7 @@ interface R_UpdateResult { inserted: 0 } -type RUpdateObj = Partial | RDatum | ((obj: RDatum) => any) +type RUpdateObj = DeepPartial | RDatum | ((obj: RDatum) => any) interface RTableSlice extends RStream { update(obj: RUpdateObj, options: Opts): RDatum From 9e2632b1514f04005a9567b5fbc60b8363f0271c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 16 Mar 2017 20:03:32 -0300 Subject: [PATCH 021/625] little speedup on api execution --- target_typescript_server.cr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target_typescript_server.cr b/target_typescript_server.cr index 7c6ca60..a610ecc 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -104,12 +104,12 @@ export function start(port: number) { if (!context.device.id) { context.device.id = crypto.randomBytes(32).toString("hex"); - await r.table("devices").insert({ + r.table("devices").insert({ id: context.device.id, ...deviceInfo - }); + }).then(); } else { - await r.table("devices").get(context.device.id).update(deviceInfo); + r.table("devices").get(context.device.id).update(deviceInfo).then(); } const executionId = crypto.randomBytes(32).toString("hex"); @@ -132,8 +132,8 @@ export function start(port: number) { async function tryLock(): Promise { const priorCall = await r.table("api_calls").get(call.id); if (priorCall === null) { - await r.table("api_calls").insert(call); - return await tryLock(); + const res = await r.table("api_calls").insert(call); + return res.inserted > 0 ? true : await tryLock(); } if (!priorCall.running) { call = priorCall; From 1be5896d3ef87931e497883a642e4cac9039c985 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 20 Mar 2017 09:20:15 -0300 Subject: [PATCH 022/625] Fix main looper --- target_java_android.cr | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 2f6a248..48b835d 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -268,8 +268,13 @@ END http.newCall(request).enqueue(new okhttp3.Callback() { @Override public void onFailure(Call call, IOException e) { - e.printStackTrace(); - callback.onFailure(e.getMessage()); + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + e.printStackTrace(); + callback.onFailure(e.getMessage()); + } + }); } @Override From 479741f0e3a8f358987444b901b804073e873c6c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 20 Mar 2017 09:26:57 -0300 Subject: [PATCH 023/625] add final to variable --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 48b835d..2c338cc 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -267,7 +267,7 @@ END http.newCall(request).enqueue(new okhttp3.Callback() { @Override - public void onFailure(Call call, IOException e) { + public void onFailure(Call call, final IOException e) { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { From f12a13aa3d36656bd8bda3d54aeb863cfe3f38bf Mon Sep 17 00:00:00 2001 From: Victor Tavares-MBP Date: Tue, 21 Mar 2017 13:24:44 -0300 Subject: [PATCH 024/625] Bug fixes on iOS Target --- target_swift.cr | 10 +++++----- target_swift_ios.cr | 47 ++++++++++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/target_swift.cr b/target_swift.cr index 61ea19a..e7f5366 100644 --- a/target_swift.cr +++ b/target_swift.cr @@ -59,7 +59,7 @@ END io << ident <<-END } -init(json: NSDictionary) { +init(json: [String: Any]) { END custom_type.fields.each do |field| @@ -68,8 +68,8 @@ END io << ident <<-END } -func toJSON() -> NSDictionary { - let json: NSMutableDictionary = [:] +func toJSON() -> [String: Any] { + var json = [String: Any]() END custom_type.fields.each do |field| @@ -131,12 +131,12 @@ END when AST::VoidPrimitiveType "nil" when AST::OptionalType - "#{src} == nil ? nil : #{type_from_json(t.base, src)}" + "#{src} is NSNull ? nil : (#{type_from_json(t.base, src)})" when AST::ArrayType "(#{src} as! [AnyObject]).map({(el) -> #{native_type t.base} in return #{type_from_json t.base, "el"}})" when AST::CustomTypeReference ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! - "#{ct.name}(json: #{src} as! NSDictionary)" + "#{ct.name}(json: #{src} as! [String: Any])" else raise "Unknown type" end diff --git a/target_swift_ios.cr b/target_swift_ios.cr index 9dd7034..0a76987 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -32,10 +32,16 @@ END @io << ident(String.build do |io| io << "static public func #{op.fnName}(#{args.join(", ")}) {\n" io << ident(String.build do |io| - io << <<-END -let args: NSMutableDictionary = [:] +# io << <<-END +# var args = [String:Any]() + +# END + if op.args.size != 0 + io << "var args = [String: Any]()\n" + else + io << "let args = [String: Any]()\n" + end -END op.args.each do |arg| io << "args[\"#{arg.name}\"] = #{type_to_json arg.type, arg.name}\n" end @@ -45,7 +51,7 @@ APIInternal.makeRequest(#{op.fnName.inspect}, args) { result, error in if error != nil { callback(#{"nil, " unless op.return_type.is_a? AST::VoidPrimitiveType}error); } else { - callback(#{"#{type_from_json op.return_type, "result"}, " unless op.return_type.is_a? AST::VoidPrimitiveType}nil); + callback(#{"(#{type_from_json op.return_type, "result"}), " unless op.return_type.is_a? AST::VoidPrimitiveType}nil); } } @@ -61,19 +67,19 @@ END class APIInternal { static var baseUrl = "api.nutriserie.com.br/user" - + class Error { var type: String var message: String - + init(_ type: String, _ message: String) { self.type = type self.message = message } } - - static func device() -> NSDictionary { - let device = NSMutableDictionary() + + static func device() -> [String: Any] { + var device = [String: Any]() device["platform"] = "ios" device["fingerprint"] = "." device["platformVersion"] = "iOS " + UIDevice.current.systemVersion + " on " + UIDevice.current.model @@ -88,13 +94,13 @@ class APIInternal { } return device } - + static func randomBytesHex(len: Int) -> String { var randomBytes = [UInt8](repeating: 0, count: len) let _ = SecRandomCopyBytes(kSecRandomDefault, len, &randomBytes) return randomBytes.map({String(format: "%02hhx", $0)}).joined(separator: "") } - + static func decodeDate(str: String) -> Date { let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .gregorian) @@ -102,7 +108,7 @@ class APIInternal { formatter.dateFormat = "yyyy-MM-dd" return formatter.date(from: str)! } - + static func encodeDate(date: Date) -> String { let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .gregorian) @@ -110,7 +116,7 @@ class APIInternal { formatter.dateFormat = "yyyy-MM-dd" return formatter.string(from: date) } - + static func decodeDateTime(str: String) -> Date { let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .gregorian) @@ -119,7 +125,7 @@ class APIInternal { formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" return formatter.date(from: str)! } - + static func encodeDateTime(date: Date) -> String { let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .gregorian) @@ -128,22 +134,23 @@ class APIInternal { formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" return formatter.string(from: date) } - - static func makeRequest(_ name: String, _ args: NSDictionary, callback: @escaping (_ result: AnyObject?, _ error: Error?) -> Void) { + + static func makeRequest(_ name: String, _ args: [String: Any], callback: @escaping (_ result: Any?, _ error: Error?) -> Void) { + let body = [ "id": randomBytesHex(len: 16), "device": device(), "name": name, "args": args - ] as [String : Any] - - Alamofire.request("https://\\(baseUrl)/\\(name)", method: .post, parameters: body).validate().responseJSON { response in + ] as [String : Any] + + Alamofire.request("https://\\(baseUrl)/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).validate().responseJSON { response in switch response.result { case .failure(let err): callback(nil, Error("Connection", err.localizedDescription)) break case .success(let value): - let body = value as! [String: AnyObject?] + let body = value as! [String: Any] if body["ok"] as! Bool { callback(body["result"]!, nil) } else { From 5ad500db7f9ae5a15426e7a9c9c1214ecdd4c17a Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 21 Mar 2017 18:19:21 -0300 Subject: [PATCH 025/625] rethink desc/asc --- rethinkdb/rethinkdb.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 3bc1cd1..62238b8 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -1,4 +1,6 @@ +interface Sorting {} + interface R extends RDB { db(name: string): RDB expr(obj: any): RDatum @@ -15,6 +17,8 @@ interface R extends RDB { and(...objs: any[]): RDatum or(...objs: any[]): RDatum now(): RDatum + asc(name: string): Sorting + desc(name: string): Sorting } interface RDB { @@ -51,7 +55,7 @@ interface RStreamOrDatum { avg(): RDatum min(): RDatum max(): RDatum - orderBy(field: string): RArray + orderBy(field: string | Sorting | {index: string | Sorting}): RArray } interface RDatum extends RStreamOrDatum, PromiseLike { From 2b2128e1edd78933c1837892a8a3571e291ffed1 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 21 Mar 2017 18:26:12 -0300 Subject: [PATCH 026/625] Better typing --- rethinkdb/rethinkdb.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 62238b8..ff02417 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -55,7 +55,7 @@ interface RStreamOrDatum { avg(): RDatum min(): RDatum max(): RDatum - orderBy(field: string | Sorting | {index: string | Sorting}): RArray + orderBy(field: string | Sorting): RArray } interface RDatum extends RStreamOrDatum, PromiseLike { @@ -91,7 +91,7 @@ interface RDatum extends RStreamOrDatum, PromiseLike { interface RArray extends RDatum { (idx: number | RDatum): RDatum map(func: (e: RDatum) => any): RArray - orderBy(field: string): RArray + orderBy(field: string | Sorting): RArray append(other: T): RArray filter(obj: DeepPartial>): RArray filter(criteria: (obj: RDatum) => boolean | RDatum): RArray @@ -101,7 +101,8 @@ interface RArray extends RDatum { interface RStream extends PromiseLike, RStreamOrDatum { (idx: number): RDatum map(func: (arg: RDatum) => any): RStream - orderBy(field: string): RArray + orderBy(field: string | Sorting): RArray + orderBy(options: {index: string | Sorting}): RStream coerceTo(type: "array"): RArray filter(obj: DeepPartial>): RStream filter(criteria: (obj: RDatum) => boolean | RDatum): RStream From 0be336227039170da2911591ed80f526b3774198 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 23 Mar 2017 09:42:22 -0300 Subject: [PATCH 027/625] Add vscode extension --- ext/vscode/.vscode/launch.json | 13 ++ ext/vscode/CHANGELOG.md | 0 ext/vscode/README.md | 1 + ext/vscode/language-configuration.json | 30 +++++ ext/vscode/package.json | 26 ++++ ext/vscode/syntaxes/sdkgen.tmLanguage.json | 131 +++++++++++++++++++++ ext/vscode/vsc-extension-quickstart.md | 27 +++++ 7 files changed, 228 insertions(+) create mode 100644 ext/vscode/.vscode/launch.json create mode 100644 ext/vscode/CHANGELOG.md create mode 100644 ext/vscode/README.md create mode 100644 ext/vscode/language-configuration.json create mode 100644 ext/vscode/package.json create mode 100644 ext/vscode/syntaxes/sdkgen.tmLanguage.json create mode 100644 ext/vscode/vsc-extension-quickstart.md diff --git a/ext/vscode/.vscode/launch.json b/ext/vscode/.vscode/launch.json new file mode 100644 index 0000000..8384213 --- /dev/null +++ b/ext/vscode/.vscode/launch.json @@ -0,0 +1,13 @@ +// A launch configuration that launches the extension inside a new window +{ + "version": "0.1.0", + "configurations": [ + { + "name": "Launch Extension", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": ["--extensionDevelopmentPath=${workspaceRoot}" ] + } + ] +} \ No newline at end of file diff --git a/ext/vscode/CHANGELOG.md b/ext/vscode/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/ext/vscode/README.md b/ext/vscode/README.md new file mode 100644 index 0000000..e4c5d2c --- /dev/null +++ b/ext/vscode/README.md @@ -0,0 +1 @@ +Language support for the .sdkgen description language \ No newline at end of file diff --git a/ext/vscode/language-configuration.json b/ext/vscode/language-configuration.json new file mode 100644 index 0000000..aa25710 --- /dev/null +++ b/ext/vscode/language-configuration.json @@ -0,0 +1,30 @@ +{ + "comments": { + // symbol used for single line comment. Remove this entry if your language does not support line comments + "lineComment": "//", + // symbols used for start and end a block comment. Remove this entry if your language does not support block comments + "blockComment": [ "/*", "*/" ] + }, + // symbols used as brackets + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + // symbols that are auto closed when typing + "autoClosingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"] + ], + // symbols that that can be used to surround a selection + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"] + ] +} \ No newline at end of file diff --git a/ext/vscode/package.json b/ext/vscode/package.json new file mode 100644 index 0000000..280850a --- /dev/null +++ b/ext/vscode/package.json @@ -0,0 +1,26 @@ +{ + "name": "sdkgen", + "displayName": "sdkgen", + "description": "sdkgen language support", + "version": "0.0.1", + "publisher": "cubos", + "engines": { + "vscode": "^1.10.0" + }, + "categories": [ + "Languages" + ], + "contributes": { + "languages": [{ + "id": "sdkgen", + "aliases": ["sdkgen", "sdkgen"], + "extensions": [".sdkgen"], + "configuration": "./language-configuration.json" + }], + "grammars": [{ + "language": "sdkgen", + "scopeName": "source.sdkgen", + "path": "./syntaxes/sdkgen.tmLanguage.json" + }] + } +} \ No newline at end of file diff --git a/ext/vscode/syntaxes/sdkgen.tmLanguage.json b/ext/vscode/syntaxes/sdkgen.tmLanguage.json new file mode 100644 index 0000000..3946e7a --- /dev/null +++ b/ext/vscode/syntaxes/sdkgen.tmLanguage.json @@ -0,0 +1,131 @@ +{ + "name": "sdkgen", + "patterns": [ + { + "include": "#any" + }, { + "name": "meta.variable", + "begin": "(\\$[a-zA-Z0-9_]+) =", + "beginCaptures": { + "1": {"name": "variable.other"} + }, + "end": "\n", + "patterns": [ + { + "include": "#literal" + } + ] + }, { + "name": "meta.error", + "match": "(error) ([A-Z][a-zA-Z0-9_]*)", + "captures": { + "1": {"name": "keyword.control"}, + "2": {"name": "entity.name.type"} + } + }, { + "name": "meta.type", + "begin": "(type) ([A-Z][a-zA-Z0-9_]*) \\{", + "beginCaptures": { + "1": {"name": "keyword.control"}, + "2": {"name": "entity.name.type"} + }, + "end": "\\}", + "patterns": [ + { + "include": "#fields" + } + ] + }, { + "name": "meta.operation", + "begin": "(get|function|subscribe) ([a-zA-Z0-9_]+)", + "beginCaptures": { + "1": {"name": "keyword.control"}, + "2": {"name": "entity.name.function"} + }, + "end": "\n", + "patterns": [ + { + "name": "meta.operation.args", + "begin": "\\(", + "end": "\\)", + "patterns": [ + { + "include": "#fields" + } + ] + }, { + "include": "#type" + } + ] + } + ], + "repository": { + "any": { + "patterns": [ + { + "name": "comment.line", + "match": "//(.*?)\n" + } + ] + }, + "fields": { + "patterns": [ + { + "include": "#any" + }, + { + "name": "meta.field", + "begin": "(\\w+):", + "beginCaptures": { + "1": {"name": "variable.parameter"} + }, + "end": "(?=\n|,|;|\\)|\\})", + "patterns": [ + { + "include": "#type" + } + ] + } + ] + }, + "type": { + "patterns": [ + { + "include": "#any" + }, + { + "name": "keyword.type", + "match": "\\b(bool|int|uint|float|string|datetime|date|bytes|void)\\b" + }, { + "name": "markup.bold", + "match": "(\\?|\\[\\])" + }, { + "name": "entity.name.type", + "match": "\\b([A-Z][a-zA-Z0-9_]*)\\b" + }, { + "name": "constant.numeric", + "match": "(![a-zA-Z0-9_]+)\\b" + } + ] + }, + "literal": { + "patterns": [ + { + "include": "#any" + }, + { + "name": "string.quoted.double.untitled", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "constant.character.escape.untitled", + "match": "\\." + } + ] + } + ] + } + }, + "scopeName": "source.sdkgen" +} \ No newline at end of file diff --git a/ext/vscode/vsc-extension-quickstart.md b/ext/vscode/vsc-extension-quickstart.md new file mode 100644 index 0000000..968cbd8 --- /dev/null +++ b/ext/vscode/vsc-extension-quickstart.md @@ -0,0 +1,27 @@ +# Welcome to your VS Code Extension + +## What's in the folder +* This folder contains all of the files necessary for your extension +* `package.json` - this is the manifest file in which you declare your language support and define +the location of the grammar file that has been copied into you extension. +* `syntaxes/sdkgen.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization +* `language-configuration.json` - this the language configuration, defining the tokens that are used for +comments and brackets. + +## Get up and running straight away +* Make sure the language configuration settings in `language-configuration.json` are accurate +* press `F5` to open a new window with your extension loaded +* create a new file with a file name suffix matching your language +* verify that syntax highlight works and that the language configuration settings are working + +## Make changes +* you can relaunch the extension from the debug toolbar after making changes to the files listed above +* you can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes + +## Add more language features +* To add features such as intellisense, hovers and validators check out the VS Code extenders documentation at +https://code.visualstudio.com/docs + +## Install your extension +* To start using your extension with Visual Studio Code copy it into the `/.vscode/extensions` folder and restart Code. +* To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension. \ No newline at end of file From fd254671c3416fa10ea88c5768e9d58ca4cfb09e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 23 Mar 2017 18:10:32 -0300 Subject: [PATCH 028/625] Add enums, more checks and rename some fields --- .gitignore | 2 +- ast.cr | 38 +++++++++++++++++++++++++++++++++---- ast_to_s.cr | 2 +- lexer.cr | 7 +++++++ parser.cr | 38 ++++++++++++++++++++++++++++++++++--- target_java.cr | 8 ++++---- target_java_android.cr | 4 ++-- target_swift.cr | 8 ++++---- target_swift_ios.cr | 4 ++-- target_typescript.cr | 10 +++++----- target_typescript_server.cr | 8 ++++---- target_typescript_web.cr | 4 ++-- 12 files changed, 101 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 291a652..c083c61 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -test-server \ No newline at end of file +sdkgen2 \ No newline at end of file diff --git a/ast.cr b/ast.cr index f3d9072..e1045d2 100644 --- a/ast.cr +++ b/ast.cr @@ -6,6 +6,9 @@ module AST abstract class PrimitiveType < Type def check(ast) end + + def check_recursive_type(ast, stack) + end end class StringPrimitiveType < PrimitiveType @@ -43,6 +46,10 @@ module AST def check(ast) @base.check(ast) end + + def check_recursive_type(ast, stack) + @base.check_recursive_type(ast, stack) + end end class ArrayType < Type @@ -53,11 +60,16 @@ module AST def check(ast) @base.check(ast) end + + def check_recursive_type(ast, stack) + @base.check_recursive_type(ast, stack) + end end class ApiDescription property custom_types = [] of CustomType property operations = [] of Operation + property enums = [] of Enum property options = Options.new property errors = [] of String @@ -67,6 +79,11 @@ module AST end end + class Enum + property! name : String + property values = [] of String + end + class Options property url = "" end @@ -87,19 +104,32 @@ module AST def check(ast) fields.each &.check(ast) + check_recursive_type(ast, [] of CustomType) + end + + def check_recursive_type(ast, stack) + raise "Cannot allow recursive type #{stack.map(&.name).join(" -> ")} -> #{name}" if stack.find &.== self + stack << self + fields.each {|field| field.type.check_recursive_type(ast, stack) } + stack.pop end end - class CustomTypeReference < Type + class TypeReference < Type property name def initialize(@name : String) end def check(ast) - unless ast.custom_types.find {|t| t.name == name } + unless ast.custom_types.find {|t| t.name == name } || ast.enums.find {|t| t.name == name } raise "Could not find type '#{name}'" end end + + def check_recursive_type(ast, stack) + ref = ast.custom_types.find {|t| t.name == name } + ref.check_recursive_type(ast, stack) if ref + end end abstract class Operation @@ -111,13 +141,13 @@ module AST args.each &.check(ast) end - def fnName + def pretty_name name end end class GetOperation < Operation - def fnName + def pretty_name return_type.is_a?(BoolPrimitiveType) ? name : "get" + name[0].upcase + name[1..-1] end end diff --git a/ast_to_s.cr b/ast_to_s.cr index 474e141..75e7210 100644 --- a/ast_to_s.cr +++ b/ast_to_s.cr @@ -83,7 +83,7 @@ class CustomType end end -class CustomTypeReference +class TypeReference def to_s name end diff --git a/lexer.cr b/lexer.cr index 2cb1f65..0fc31fb 100644 --- a/lexer.cr +++ b/lexer.cr @@ -46,6 +46,7 @@ class Lexer return make_token(EqualSymbolToken.new) if literal_match("=") return make_token(TypeKeywordToken.new) if literal_match("type") + return make_token(EnumKeywordToken.new) if literal_match("enum") return make_token(GetKeywordToken.new) if literal_match("get") return make_token(FunctionKeywordToken.new) if literal_match("function") return make_token(SubscribeKeywordToken.new) if literal_match("subscribe") @@ -195,6 +196,12 @@ class TypeKeywordToken < Token end end +class EnumKeywordToken < Token + def try_ident + IdentifierToken.new("type") + end +end + class GetKeywordToken < Token def try_ident IdentifierToken.new("get") diff --git a/parser.cr b/parser.cr index e166702..c945280 100644 --- a/parser.cr +++ b/parser.cr @@ -15,9 +15,11 @@ class Parser def parse api = AST::ApiDescription.new while @token - case multi_expect(TypeKeywordToken, GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken, GlobalOptionToken, ErrorKeywordToken) + case multi_expect(TypeKeywordToken, EnumKeywordToken, GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken, GlobalOptionToken, ErrorKeywordToken) when TypeKeywordToken api.custom_types << parse_custom_type_definition + when EnumKeywordToken + api.enums << parse_enum when GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken api.operations << parse_operation when GlobalOptionToken @@ -74,6 +76,36 @@ class Parser token end + def parse_enum + expect EnumKeywordToken + next_token + + e = AST::Enum.new + name_token = expect(IdentifierToken) + unless name_token.name[0].uppercase? + raise ParserException.new "The enum name must start with an uppercase letter, but found '#{name_token.name}' at #{name_token.location}" + end + e.name = name_token.name + next_token + + expect CurlyOpenSymbolToken + next_token + + while true + case token = multi_expect(IdentifierToken, CurlyCloseSymbolToken) + when IdentifierToken + unless token.name[0].uppercase? + raise ParserException.new "The enum value must start with an uppercase letter, but found '#{name_token.name}' at #{name_token.location}" + end + e.values << token.name + next_token + when CurlyCloseSymbolToken + next_token + return e + end + end + end + def parse_custom_type_definition expect TypeKeywordToken next_token @@ -81,7 +113,7 @@ class Parser t = AST::CustomType.new name_token = expect(IdentifierToken) unless name_token.name[0].uppercase? - raise ParserException.new "A custom type name must start with an uppercase letter, but found '#{name_token.name}' at #{name_token.location}" + raise ParserException.new "The custom type name must start with an uppercase letter, but found '#{name_token.name}' at #{name_token.location}" end t.name = name_token.name next_token @@ -187,7 +219,7 @@ class Parser unless token.name[0].uppercase? raise ParserException.new "Expected a type but found '#{token.name}', at #{token.location}" end - AST::CustomTypeReference.new(token.name) + AST::TypeReference.new(token.name) when PrimitiveTypeToken case token.name when "string"; AST::StringPrimitiveType.new diff --git a/target_java.cr b/target_java.cr index bba3951..15d9381 100644 --- a/target_java.cr +++ b/target_java.cr @@ -49,7 +49,7 @@ abstract class JavaTarget < Target "ArrayList<#{native_type_not_primitive(t.base)}>" end - def native_type(t : AST::CustomTypeReference) + def native_type(t : AST::TypeReference) t.name end @@ -115,7 +115,7 @@ END "#{src}.isNull(#{name}) ? null : #{get_field_from_json_object(t.base, src, name)}" when AST::ArrayType "#{src}.getJSONArray(#{name})" - when AST::CustomTypeReference + when AST::TypeReference "#{src}.getJSONObject(#{name})" else raise "Unknown type" @@ -138,7 +138,7 @@ END "#{src} == null ? null : #{type_from_json(t.base, src)}" when AST::ArrayType "new #{native_type t}() {{ JSONArray ary = #{src}; for (int i = 0; i < ary.length(); ++i) add(#{type_from_json(t.base, get_field_from_json_object(t.base, "ary", "i"))}); }}" - when AST::CustomTypeReference + when AST::TypeReference ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! "#{ct.name}.fromJSON(#{src})" else @@ -162,7 +162,7 @@ END "#{src} == null ? null : #{type_to_json(t.base, src)}" when AST::ArrayType "new JSONArray() {{ for (#{native_type t.base} el : #{src}) put(#{type_to_json t.base, "el"}); }}" - when AST::CustomTypeReference + when AST::TypeReference "#{src}.toJSON()" else raise "Unknown type" diff --git a/target_java_android.cr b/target_java_android.cr index 2c338cc..4dc06ee 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -52,7 +52,7 @@ END args = op.args.map {|arg| "final #{native_type arg.type} #{arg.name}" } args << "final #{callback_type op.return_type} callback" @io << ident(String.build do |io| - io << "static public void #{op.fnName}(#{args.join(", ")}) {\n" + io << "static public void #{op.pretty_name}(#{args.join(", ")}) {\n" io << ident(String.build do |io| if op.args.size == 0 io << "JSONObject args = new JSONObject();" @@ -78,7 +78,7 @@ END end io << <<-END -Internal.makeRequest(#{op.fnName.inspect}, args, new Internal.RequestCallback() { +Internal.makeRequest(#{op.pretty_name.inspect}, args, new Internal.RequestCallback() { @Override public void onResult(final JSONObject result) { callback.onFinished(); diff --git a/target_swift.cr b/target_swift.cr index e7f5366..9eb3e63 100644 --- a/target_swift.cr +++ b/target_swift.cr @@ -29,7 +29,7 @@ abstract class SwiftTarget < Target "[#{native_type(t.base)}]" end - def native_type(t : AST::CustomTypeReference) + def native_type(t : AST::TypeReference) t.name end @@ -102,7 +102,7 @@ END "nil" when AST::ArrayType "[]" - when AST::CustomTypeReference + when AST::TypeReference ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! "#{ct.name}()" else @@ -134,7 +134,7 @@ END "#{src} is NSNull ? nil : (#{type_from_json(t.base, src)})" when AST::ArrayType "(#{src} as! [AnyObject]).map({(el) -> #{native_type t.base} in return #{type_from_json t.base, "el"}})" - when AST::CustomTypeReference + when AST::TypeReference ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! "#{ct.name}(json: #{src} as! [String: Any])" else @@ -158,7 +158,7 @@ END "#{src} == nil ? nil : #{type_to_json(t.base, src + "!")}" when AST::ArrayType "#{src}.map({ return #{type_to_json t.base, "$0"} })" - when AST::CustomTypeReference + when AST::TypeReference "#{src}.toJSON()" else raise "Unknown type" diff --git a/target_swift_ios.cr b/target_swift_ios.cr index 0a76987..fe4cadc 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -30,7 +30,7 @@ END args << "callback: @escaping (_ result: #{native_type ret}, _ error: APIInternal.Error?) -> Void" end @io << ident(String.build do |io| - io << "static public func #{op.fnName}(#{args.join(", ")}) {\n" + io << "static public func #{op.pretty_name}(#{args.join(", ")}) {\n" io << ident(String.build do |io| # io << <<-END # var args = [String:Any]() @@ -47,7 +47,7 @@ END end io << <<-END -APIInternal.makeRequest(#{op.fnName.inspect}, args) { result, error in +APIInternal.makeRequest(#{op.pretty_name.inspect}, args) { result, error in if error != nil { callback(#{"nil, " unless op.return_type.is_a? AST::VoidPrimitiveType}error); } else { diff --git a/target_typescript.cr b/target_typescript.cr index 7e64f92..dcfdfdc 100644 --- a/target_typescript.cr +++ b/target_typescript.cr @@ -25,7 +25,7 @@ abstract class TypeScriptTarget < Target native_type(t.base) + "[]" end - def native_type(t : AST::CustomTypeReference) + def native_type(t : AST::TypeReference) t.name end @@ -75,8 +75,8 @@ abstract class TypeScriptTarget < Target when AST::OptionalType "#{src} === null || #{src} === undefined ? null : #{type_from_json(t.base, src)}" when AST::ArrayType - t.base.is_a?(AST::CustomTypeReference) ? "#{src}.map(e => (#{type_from_json(t.base, "e")}))" : "#{src}.map(e => #{type_from_json(t.base, "e")})" - when AST::CustomTypeReference + t.base.is_a?(AST::TypeReference) ? "#{src}.map(e => (#{type_from_json(t.base, "e")}))" : "#{src}.map(e => #{type_from_json(t.base, "e")})" + when AST::TypeReference String::Builder.build do |io| io << "{\n" ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! @@ -106,8 +106,8 @@ abstract class TypeScriptTarget < Target when AST::OptionalType "#{src} === null || #{src} === undefined ? null : #{type_to_json(t.base, src)}" when AST::ArrayType - t.base.is_a?(AST::CustomTypeReference) ? "#{src}.map(e => (#{type_to_json(t.base, "e")}))" : "#{src}.map(e => #{type_to_json(t.base, "e")})" - when AST::CustomTypeReference + t.base.is_a?(AST::TypeReference) ? "#{src}.map(e => (#{type_to_json(t.base, "e")}))" : "#{src}.map(e => #{type_to_json(t.base, "e")})" + when AST::TypeReference String::Builder.build do |io| io << "{\n" ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! diff --git a/target_typescript_server.cr b/target_typescript_server.cr index a610ecc..dbade4f 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -14,11 +14,11 @@ END @io << "export const fn: {\n" @ast.operations.each do |op| - @io << " " << op.fnName << ": " << operation_type(op) << ";\n" + @io << " " << op.pretty_name << ": " << operation_type(op) << ";\n" end @io << "} = {\n"; @ast.operations.each do |op| - @io << " " << op.fnName << ": () => { throw \"not implemented\"; },\n" + @io << " " << op.pretty_name << ": () => { throw \"not implemented\"; },\n" end @io << "};\n\n" @@ -29,12 +29,12 @@ END @io << "const fnExec: {[name: string]: (ctx: Context, args: any) => Promise} = {\n" @ast.operations.each do |op| - @io << " " << op.fnName << ": async (ctx: Context, args: any) => {\n" + @io << " " << op.pretty_name << ": async (ctx: Context, args: any) => {\n" op.args.each do |arg| @io << ident ident "const #{arg.name} = #{type_from_json(arg.type, "args.#{arg.name}")};" @io << "\n" end - @io << " const ret = await fn.#{op.fnName}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" + @io << " const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident "return " + type_to_json(op.return_type, "ret") + ";" @io << "\n" @io << " },\n" diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 59233d9..5322fb2 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -17,7 +17,7 @@ END end @ast.operations.each do |op| - @io << "export async function #{op.fnName}#{operation_args(op)}: Promise<#{operation_ret(op)}> {\n" + @io << "export async function #{op.pretty_name}#{operation_args(op)}: Promise<#{operation_ret(op)}> {\n" if op.args.size > 0 @io << " const args = {\n" op.args.each do |arg| @@ -29,7 +29,7 @@ END @io << " " @io << "const ret: #{native_type op.return_type} = " unless op.return_type.is_a? AST::VoidPrimitiveType - @io << "await makeRequest({name: #{op.fnName.inspect}, #{op.args.size > 0 ? "args" : "args: {}"}});\n" + @io << "await makeRequest({name: #{op.pretty_name.inspect}, #{op.args.size > 0 ? "args" : "args: {}"}});\n" @io << ident "return " + type_from_json(op.return_type, "ret") + ";" @io << "\n" @io << "}\n\n" From 020bf3a1fbfd285eb12bfe25efaa634b19732783 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 24 Mar 2017 09:11:21 -0300 Subject: [PATCH 029/625] Rename CustomType to TypeDefinition --- ast.cr | 12 ++++++------ ast_to_s.cr | 4 ++-- parser.cr | 6 +++--- target_java.cr | 18 +++++++++--------- target_java_android.cr | 4 ++-- target_swift.cr | 20 ++++++++++---------- target_swift_ios.cr | 4 ++-- target_typescript.cr | 10 +++++----- target_typescript_server.cr | 4 ++-- target_typescript_web.cr | 4 ++-- 10 files changed, 43 insertions(+), 43 deletions(-) diff --git a/ast.cr b/ast.cr index e1045d2..6b131d8 100644 --- a/ast.cr +++ b/ast.cr @@ -67,14 +67,14 @@ module AST end class ApiDescription - property custom_types = [] of CustomType + property type_definitions = [] of TypeDefinition property operations = [] of Operation property enums = [] of Enum property options = Options.new property errors = [] of String def check - custom_types.each &.check(self) + type_definitions.each &.check(self) operations.each &.check(self) end end @@ -98,13 +98,13 @@ module AST end end - class CustomType + class TypeDefinition property! name : String property fields = [] of Field def check(ast) fields.each &.check(ast) - check_recursive_type(ast, [] of CustomType) + check_recursive_type(ast, [] of TypeDefinition) end def check_recursive_type(ast, stack) @@ -121,13 +121,13 @@ module AST end def check(ast) - unless ast.custom_types.find {|t| t.name == name } || ast.enums.find {|t| t.name == name } + unless ast.type_definitions.find {|t| t.name == name } || ast.enums.find {|t| t.name == name } raise "Could not find type '#{name}'" end end def check_recursive_type(ast, stack) - ref = ast.custom_types.find {|t| t.name == name } + ref = ast.type_definitions.find {|t| t.name == name } ref.check_recursive_type(ast, stack) if ref end end diff --git a/ast_to_s.cr b/ast_to_s.cr index 75e7210..21c4ce0 100644 --- a/ast_to_s.cr +++ b/ast_to_s.cr @@ -62,7 +62,7 @@ end class ApiDescription def to_s - custom_types.map(&.to_s).join("\n") + "\n" + + type_definitions.map(&.to_s).join("\n") + "\n" + operations.map(&.to_s).join("\n") end end @@ -75,7 +75,7 @@ class Field end end -class CustomType +class TypeDefinition def to_s "type #{name} {\n" + fields.map{|f| " #{f.to_s}\n" }.join + diff --git a/parser.cr b/parser.cr index c945280..59231a3 100644 --- a/parser.cr +++ b/parser.cr @@ -17,7 +17,7 @@ class Parser while @token case multi_expect(TypeKeywordToken, EnumKeywordToken, GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken, GlobalOptionToken, ErrorKeywordToken) when TypeKeywordToken - api.custom_types << parse_custom_type_definition + api.type_definitions << parse_type_definition_definition when EnumKeywordToken api.enums << parse_enum when GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken @@ -106,11 +106,11 @@ class Parser end end - def parse_custom_type_definition + def parse_type_definition_definition expect TypeKeywordToken next_token - t = AST::CustomType.new + t = AST::TypeDefinition.new name_token = expect(IdentifierToken) unless name_token.name[0].uppercase? raise ParserException.new "The custom type name must start with an uppercase letter, but found '#{name_token.name}' at #{name_token.location}" diff --git a/target_java.cr b/target_java.cr index 15d9381..afad493 100644 --- a/target_java.cr +++ b/target_java.cr @@ -53,10 +53,10 @@ abstract class JavaTarget < Target t.name end - def generate_custom_type_interface(custom_type) + def generate_type_definition_interface(type_definition) String.build do |io| - io << "public static class #{custom_type.name} {\n" - custom_type.fields.each do |field| + io << "public static class #{type_definition.name} {\n" + type_definition.fields.each do |field| io << ident "public #{native_type field.type} #{field.name};\n" end io << ident <<-END @@ -66,7 +66,7 @@ public JSONObject toJSON() { return new JSONObject() {{ END - custom_type.fields.each do |field| + type_definition.fields.each do |field| io << ident ident ident ident "put(\"#{field.name}\", #{type_to_json field.type, field.name});\n" end io << ident <<-END @@ -77,12 +77,12 @@ END } } -public static #{custom_type.name} fromJSON(final JSONObject json) { +public static #{type_definition.name} fromJSON(final JSONObject json) { try { - return new #{custom_type.name}() {{ + return new #{type_definition.name}() {{ END - custom_type.fields.each do |field| + type_definition.fields.each do |field| io << ident ident ident ident "#{field.name} = #{type_from_json field.type, get_field_from_json_object(field.type, "json", field.name.inspect)};\n" end io << ident <<-END @@ -90,7 +90,7 @@ END }}; } catch (JSONException e) { e.printStackTrace(); - return new #{custom_type.name}(); + return new #{type_definition.name}(); } } @@ -139,7 +139,7 @@ END when AST::ArrayType "new #{native_type t}() {{ JSONArray ary = #{src}; for (int i = 0; i < ary.length(); ++i) add(#{type_from_json(t.base, get_field_from_json_object(t.base, "ary", "i"))}); }}" when AST::TypeReference - ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! + ct = @ast.type_definitions.find {|x| x.name == t.name }.not_nil! "#{ct.name}.fromJSON(#{src})" else raise "Unknown type" diff --git a/target_java_android.cr b/target_java_android.cr index 4dc06ee..270cad1 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -43,8 +43,8 @@ public class API { END - @ast.custom_types.each do |custom_type| - @io << ident generate_custom_type_interface(custom_type) + @ast.type_definitions.each do |type_definition| + @io << ident generate_type_definition_interface(type_definition) @io << "\n\n" end diff --git a/target_swift.cr b/target_swift.cr index 9eb3e63..87c339a 100644 --- a/target_swift.cr +++ b/target_swift.cr @@ -33,10 +33,10 @@ abstract class SwiftTarget < Target t.name end - def generate_custom_type_interface(custom_type) + def generate_type_definition_interface(type_definition) String.build do |io| - io << "class #{custom_type.name} {\n" - custom_type.fields.each do |field| + io << "class #{type_definition.name} {\n" + type_definition.fields.each do |field| io << ident "var #{field.name}: #{native_type field.type}\n" end io << ident <<-END @@ -44,16 +44,16 @@ abstract class SwiftTarget < Target init() { END - custom_type.fields.each do |field| + type_definition.fields.each do |field| io << ident ident "#{field.name} = #{default_value field.type}\n" end io << ident <<-END } -init(#{custom_type.fields.map{|f| "#{f.name}: #{native_type f.type}"}.join(", ")}) { +init(#{type_definition.fields.map{|f| "#{f.name}: #{native_type f.type}"}.join(", ")}) { END - custom_type.fields.each do |field| + type_definition.fields.each do |field| io << ident ident "self.#{field.name} = #{field.name}\n" end io << ident <<-END @@ -62,7 +62,7 @@ END init(json: [String: Any]) { END - custom_type.fields.each do |field| + type_definition.fields.each do |field| io << ident ident "#{field.name} = #{type_from_json field.type, "json[#{field.name.inspect}]"}\n" end io << ident <<-END @@ -72,7 +72,7 @@ func toJSON() -> [String: Any] { var json = [String: Any]() END - custom_type.fields.each do |field| + type_definition.fields.each do |field| io << ident ident "json[\"#{field.name}\"] = #{type_to_json field.type, field.name}\n" end io << ident <<-END @@ -103,7 +103,7 @@ END when AST::ArrayType "[]" when AST::TypeReference - ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! + ct = @ast.type_definitions.find {|x| x.name == t.name }.not_nil! "#{ct.name}()" else raise "Unknown type" @@ -135,7 +135,7 @@ END when AST::ArrayType "(#{src} as! [AnyObject]).map({(el) -> #{native_type t.base} in return #{type_from_json t.base, "el"}})" when AST::TypeReference - ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! + ct = @ast.type_definitions.find {|x| x.name == t.name }.not_nil! "#{ct.name}(json: #{src} as! [String: Any])" else raise "Unknown type" diff --git a/target_swift_ios.cr b/target_swift_ios.cr index fe4cadc..7da0391 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -9,8 +9,8 @@ class API { END - @ast.custom_types.each do |custom_type| - @io << ident generate_custom_type_interface(custom_type) + @ast.type_definitions.each do |type_definition| + @io << ident generate_type_definition_interface(type_definition) @io << "\n\n" end diff --git a/target_typescript.cr b/target_typescript.cr index dcfdfdc..cf7a84d 100644 --- a/target_typescript.cr +++ b/target_typescript.cr @@ -29,10 +29,10 @@ abstract class TypeScriptTarget < Target t.name end - def generate_custom_type_interface(custom_type) + def generate_type_definition_interface(type_definition) String.build do |io| - io << "export interface #{custom_type.name} {\n" - custom_type.fields.each do |field| + io << "export interface #{type_definition.name} {\n" + type_definition.fields.each do |field| io << ident "#{field.name}: #{native_type field.type};\n" end io << "}" @@ -79,7 +79,7 @@ abstract class TypeScriptTarget < Target when AST::TypeReference String::Builder.build do |io| io << "{\n" - ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! + ct = @ast.type_definitions.find {|x| x.name == t.name }.not_nil! ct.fields.each do |field| io << ident "#{field.name}: #{type_from_json(field.type, "#{src}.#{field.name}")}," io << "\n" @@ -110,7 +110,7 @@ abstract class TypeScriptTarget < Target when AST::TypeReference String::Builder.build do |io| io << "{\n" - ct = @ast.custom_types.find {|x| x.name == t.name }.not_nil! + ct = @ast.type_definitions.find {|x| x.name == t.name }.not_nil! ct.fields.each do |field| io << ident "#{field.name}: #{type_to_json(field.type, "#{src}.#{field.name}")}," io << "\n" diff --git a/target_typescript_server.cr b/target_typescript_server.cr index dbade4f..9657cff 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -22,8 +22,8 @@ END end @io << "};\n\n" - @ast.custom_types.each do |custom_type| - @io << generate_custom_type_interface(custom_type) + @ast.type_definitions.each do |type_definition| + @io << generate_type_definition_interface(type_definition) @io << "\n\n" end diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 5322fb2..482b663 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -11,8 +11,8 @@ const baseUrl = #{@ast.options.url.inspect}; END - @ast.custom_types.each do |custom_type| - @io << generate_custom_type_interface(custom_type) + @ast.type_definitions.each do |type_definition| + @io << generate_type_definition_interface(type_definition) @io << "\n\n" end From b36dfaf0db313996584d2146d56c3dd54301eec3 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 24 Mar 2017 09:21:39 -0300 Subject: [PATCH 030/625] create a semantic pass --- ast.cr | 64 ++---------------------------------- ast_semantic.cr | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ main.cr | 2 +- parser.cr | 5 +-- 4 files changed, 92 insertions(+), 65 deletions(-) create mode 100644 ast_semantic.cr diff --git a/ast.cr b/ast.cr index 6b131d8..2cd8995 100644 --- a/ast.cr +++ b/ast.cr @@ -4,11 +4,6 @@ module AST end abstract class PrimitiveType < Type - def check(ast) - end - - def check_recursive_type(ast, stack) - end end class StringPrimitiveType < PrimitiveType @@ -42,44 +37,23 @@ module AST property base def initialize(@base : Type) end - - def check(ast) - @base.check(ast) - end - - def check_recursive_type(ast, stack) - @base.check_recursive_type(ast, stack) - end end class ArrayType < Type property base def initialize(@base : Type) end - - def check(ast) - @base.check(ast) - end - - def check_recursive_type(ast, stack) - @base.check_recursive_type(ast, stack) - end end class ApiDescription property type_definitions = [] of TypeDefinition + property enum_definitions = [] of EnumDefinition property operations = [] of Operation - property enums = [] of Enum property options = Options.new property errors = [] of String - - def check - type_definitions.each &.check(self) - operations.each &.check(self) - end end - class Enum + class EnumDefinition property! name : String property values = [] of String end @@ -101,55 +75,21 @@ module AST class TypeDefinition property! name : String property fields = [] of Field - - def check(ast) - fields.each &.check(ast) - check_recursive_type(ast, [] of TypeDefinition) - end - - def check_recursive_type(ast, stack) - raise "Cannot allow recursive type #{stack.map(&.name).join(" -> ")} -> #{name}" if stack.find &.== self - stack << self - fields.each {|field| field.type.check_recursive_type(ast, stack) } - stack.pop - end end class TypeReference < Type property name def initialize(@name : String) end - - def check(ast) - unless ast.type_definitions.find {|t| t.name == name } || ast.enums.find {|t| t.name == name } - raise "Could not find type '#{name}'" - end - end - - def check_recursive_type(ast, stack) - ref = ast.type_definitions.find {|t| t.name == name } - ref.check_recursive_type(ast, stack) if ref - end end abstract class Operation property! name : String property args = [] of Field property! return_type : Type - - def check(ast) - args.each &.check(ast) - end - - def pretty_name - name - end end class GetOperation < Operation - def pretty_name - return_type.is_a?(BoolPrimitiveType) ? name : "get" + name[0].upcase + name[1..-1] - end end class FunctionOperation < Operation diff --git a/ast_semantic.cr b/ast_semantic.cr new file mode 100644 index 0000000..5d884df --- /dev/null +++ b/ast_semantic.cr @@ -0,0 +1,86 @@ + +module AST + abstract class PrimitiveType < Type + def semantic(ast) + end + + def check_recursive_type(ast, stack) + end + end + + class OptionalType < Type + def semantic(ast) + @base.semantic(ast) + end + + def check_recursive_type(ast, stack) + @base.check_recursive_type(ast, stack) + end + end + + class ArrayType < Type + def semantic(ast) + @base.semantic(ast) + end + + def check_recursive_type(ast, stack) + @base.check_recursive_type(ast, stack) + end + end + + class ApiDescription + def semantic + type_definitions.each &.semantic(self) + operations.each &.semantic(self) + end + end + + class Field + def semantic(ast) + type.semantic(ast) + end + end + + class TypeDefinition + def semantic(ast) + fields.each &.semantic(ast) + check_recursive_type(ast, [] of TypeDefinition) + end + + def check_recursive_type(ast, stack) + raise "Cannot allow recursive type #{stack.map(&.name).join(" -> ")} -> #{name}" if stack.find &.== self + stack << self + fields.each {|field| field.type.check_recursive_type(ast, stack) } + stack.pop + end + end + + class TypeReference < Type + def semantic(ast) + unless ast.type_definitions.find {|t| t.name == name } || ast.enum_definitions.find {|t| t.name == name } + raise "Could not find type '#{name}'" + end + end + + def check_recursive_type(ast, stack) + ref = ast.type_definitions.find {|t| t.name == name } + ref.check_recursive_type(ast, stack) if ref + end + end + + abstract class Operation + def semantic(ast) + args.each &.semantic(ast) + end + + def pretty_name + name + end + end + + class GetOperation < Operation + def pretty_name + return_type.is_a?(BoolPrimitiveType) ? name : "get" + name[0].upcase + name[1..-1] + end + end +end \ No newline at end of file diff --git a/main.cr b/main.cr index eacd374..081c0ed 100644 --- a/main.cr +++ b/main.cr @@ -33,7 +33,7 @@ source = sources[0] lexer = Lexer.new(source) parser = Parser.new(lexer) ast = parser.parse -ast.check +ast.semantic if destination == "" STDERR.puts "You must specify an output file" diff --git a/parser.cr b/parser.cr index 59231a3..58bb10b 100644 --- a/parser.cr +++ b/parser.cr @@ -1,5 +1,6 @@ require "./lexer" require "./ast" +require "./ast_semantic" class Parser @@ -19,7 +20,7 @@ class Parser when TypeKeywordToken api.type_definitions << parse_type_definition_definition when EnumKeywordToken - api.enums << parse_enum + api.enum_definitions << parse_enum when GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken api.operations << parse_operation when GlobalOptionToken @@ -80,7 +81,7 @@ class Parser expect EnumKeywordToken next_token - e = AST::Enum.new + e = AST::EnumDefinition.new name_token = expect(IdentifierToken) unless name_token.name[0].uppercase? raise ParserException.new "The enum name must start with an uppercase letter, but found '#{name_token.name}' at #{name_token.location}" From 401e0f5ebbd5a17002182aba74f6d8254322b26f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 24 Mar 2017 09:35:05 -0300 Subject: [PATCH 031/625] semantic pass to collect type references --- ast_semantic.cr | 6 +++++- target_java.cr | 3 +-- target_swift.cr | 6 ++---- target_typescript.cr | 6 ++---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ast_semantic.cr b/ast_semantic.cr index 5d884df..0151caa 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -56,8 +56,11 @@ module AST end class TypeReference < Type + property! ref : TypeDefinition | EnumDefinition + def semantic(ast) - unless ast.type_definitions.find {|t| t.name == name } || ast.enum_definitions.find {|t| t.name == name } + @ref = ast.type_definitions.find {|t| t.name == name } || ast.enum_definitions.find {|t| t.name == name } + unless @ref raise "Could not find type '#{name}'" end end @@ -71,6 +74,7 @@ module AST abstract class Operation def semantic(ast) args.each &.semantic(ast) + return_type.semantic(ast) end def pretty_name diff --git a/target_java.cr b/target_java.cr index afad493..5bbb408 100644 --- a/target_java.cr +++ b/target_java.cr @@ -139,8 +139,7 @@ END when AST::ArrayType "new #{native_type t}() {{ JSONArray ary = #{src}; for (int i = 0; i < ary.length(); ++i) add(#{type_from_json(t.base, get_field_from_json_object(t.base, "ary", "i"))}); }}" when AST::TypeReference - ct = @ast.type_definitions.find {|x| x.name == t.name }.not_nil! - "#{ct.name}.fromJSON(#{src})" + "#{t.ref.name}.fromJSON(#{src})" else raise "Unknown type" end diff --git a/target_swift.cr b/target_swift.cr index 87c339a..8690c2e 100644 --- a/target_swift.cr +++ b/target_swift.cr @@ -103,8 +103,7 @@ END when AST::ArrayType "[]" when AST::TypeReference - ct = @ast.type_definitions.find {|x| x.name == t.name }.not_nil! - "#{ct.name}()" + "#{t.ref.name}()" else raise "Unknown type" end @@ -135,8 +134,7 @@ END when AST::ArrayType "(#{src} as! [AnyObject]).map({(el) -> #{native_type t.base} in return #{type_from_json t.base, "el"}})" when AST::TypeReference - ct = @ast.type_definitions.find {|x| x.name == t.name }.not_nil! - "#{ct.name}(json: #{src} as! [String: Any])" + "#{t.ref.name}(json: #{src} as! [String: Any])" else raise "Unknown type" end diff --git a/target_typescript.cr b/target_typescript.cr index cf7a84d..43d38bc 100644 --- a/target_typescript.cr +++ b/target_typescript.cr @@ -79,8 +79,7 @@ abstract class TypeScriptTarget < Target when AST::TypeReference String::Builder.build do |io| io << "{\n" - ct = @ast.type_definitions.find {|x| x.name == t.name }.not_nil! - ct.fields.each do |field| + (t.ref.as AST::TypeDefinition).fields.each do |field| io << ident "#{field.name}: #{type_from_json(field.type, "#{src}.#{field.name}")}," io << "\n" end @@ -110,8 +109,7 @@ abstract class TypeScriptTarget < Target when AST::TypeReference String::Builder.build do |io| io << "{\n" - ct = @ast.type_definitions.find {|x| x.name == t.name }.not_nil! - ct.fields.each do |field| + (t.ref.as AST::TypeDefinition).fields.each do |field| io << ident "#{field.name}: #{type_to_json(field.type, "#{src}.#{field.name}")}," io << "\n" end From 94b08be20a17040c97955d80316056f9c9e033b4 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 24 Mar 2017 09:44:22 -0300 Subject: [PATCH 032/625] empty parens now optional --- parser.cr | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/parser.cr b/parser.cr index 58bb10b..bbec50e 100644 --- a/parser.cr +++ b/parser.cr @@ -149,19 +149,20 @@ class Parser next_token op.name = expect(IdentifierToken).name next_token - expect ParensOpenSymbolToken - next_token - while true - case token = multi_expect(IdentifierToken, ParensCloseSymbolToken, CommaSymbolToken) - when IdentifierToken - op.args << parse_field - when ParensCloseSymbolToken - next_token - break - when CommaSymbolToken - next_token - next + if @token.is_a? ParensOpenSymbolToken + next_token + while true + case token = multi_expect(IdentifierToken, ParensCloseSymbolToken, CommaSymbolToken) + when IdentifierToken + op.args << parse_field + when ParensCloseSymbolToken + next_token + break + when CommaSymbolToken + next_token + next + end end end From 19dff5eba250823c61ba8459d7912c985d59e3be Mon Sep 17 00:00:00 2001 From: Victor Tavares-MBP Date: Fri, 24 Mar 2017 10:02:48 -0300 Subject: [PATCH 033/625] Adding errors and bug fixes --- target_swift.cr | 2 +- target_swift_ios.cr | 93 ++++++++++++++++++++++++++++++++------------- 2 files changed, 67 insertions(+), 28 deletions(-) diff --git a/target_swift.cr b/target_swift.cr index e7f5366..5348340 100644 --- a/target_swift.cr +++ b/target_swift.cr @@ -131,7 +131,7 @@ END when AST::VoidPrimitiveType "nil" when AST::OptionalType - "#{src} is NSNull ? nil : (#{type_from_json(t.base, src)})" + "APIInternal.isNull(value: #{src}) ? nil : (#{type_from_json(t.base, src)})" when AST::ArrayType "(#{src} as! [AnyObject]).map({(el) -> #{native_type t.base} in return #{type_from_json t.base, "el"}})" when AST::CustomTypeReference diff --git a/target_swift_ios.cr b/target_swift_ios.cr index 0a76987..8d1abf8 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -9,33 +9,38 @@ class API { END + + @io << "\n" + @io << ident "enum ErrorType: String {\n" + @ast.errors.each do |error| + @io << ident ident "case #{error} = #{error.inspect}\n" + end + @io << ident ident "case ConnectionError = \"ConnectionError\" \n" + @io << ident ident "case UnknownError = \"UnknownError\" \n" + @io << ident "}" + @io << "\n\n" + @ast.custom_types.each do |custom_type| @io << ident generate_custom_type_interface(custom_type) @io << "\n\n" end - # static func logIn(email: String, callback: @escaping (_ result: String, _ error: APIInternal.Error?) -> Void) { - - # } @ast.operations.each do |op| args = op.args.map {|arg| "#{arg.name}: #{native_type arg.type}" } if op.return_type.is_a? AST::VoidPrimitiveType - args << "callback: @escaping (_ error: APIInternal.Error?) -> Void" + args << "callback: ((_ error: APIInternal.Error?) -> Void)?" else ret = op.return_type unless ret.is_a? AST::OptionalType ret = AST::OptionalType.new ret end - args << "callback: @escaping (_ result: #{native_type ret}, _ error: APIInternal.Error?) -> Void" + args << "callback: ((_ result: #{native_type ret}, _ error: APIInternal.Error?) -> Void)?" end @io << ident(String.build do |io| io << "static public func #{op.fnName}(#{args.join(", ")}) {\n" io << ident(String.build do |io| -# io << <<-END -# var args = [String:Any]() -# END if op.args.size != 0 io << "var args = [String: Any]()\n" else @@ -49,9 +54,9 @@ END APIInternal.makeRequest(#{op.fnName.inspect}, args) { result, error in if error != nil { - callback(#{"nil, " unless op.return_type.is_a? AST::VoidPrimitiveType}error); + callback?(#{"nil, " unless op.return_type.is_a? AST::VoidPrimitiveType}error); } else { - callback(#{"(#{type_from_json op.return_type, "result"}), " unless op.return_type.is_a? AST::VoidPrimitiveType}nil); + callback?(#{"(#{type_from_json op.return_type, "result"}), " unless op.return_type.is_a? AST::VoidPrimitiveType}nil); } } @@ -69,15 +74,34 @@ class APIInternal { static var baseUrl = "api.nutriserie.com.br/user" class Error { - var type: String + var type: API.ErrorType var message: String - init(_ type: String, _ message: String) { + init(_ type: API.ErrorType, _ message: String) { self.type = type self.message = message } + + init(json: [String: Any]) { + self.type = API.ErrorType(rawValue: json["type"] as! String) ?? API.ErrorType.UnknownError + self.message = json["message"] as! String + } } + class HTTPResponse { + var ok: Bool! + var deviceId: String! + var result: Any? + var error: Error? + + init(json: [String: Any]) { + self.ok = json["ok"] as! Bool + self.deviceId = json["deviceId"] as! String + self.result = json["result"] is NSNull ? nil : json["result"]! + self.error = json["error"] is NSNull ? nil: (Error(json: json["error"] as! [String: Any])) + } + } + static func device() -> [String: Any] { var device = [String: Any]() device["platform"] = "ios" @@ -89,7 +113,7 @@ class APIInternal { device["version"] = "unknown" } device["language"] = Locale.preferredLanguages[0] - if let deviceId = UserDefaults.standard.value(forKey: "device-id") as? String { + if let deviceId = deviceID { device["id"] = deviceId } return device @@ -135,7 +159,21 @@ class APIInternal { return formatter.string(from: date) } + static var deviceID: String? { + return UserDefaults.standard.value(forKey: "device-id") as? String + } + + static func saveDeviceID(_ id: String) { + UserDefaults.standard.setValue(id, forKey: "device-id") + UserDefaults.standard.synchronize() + } + + static func isNull(value: Any?) -> Bool { + return value == nil || value is NSNull + } + static func makeRequest(_ name: String, _ args: [String: Any], callback: @escaping (_ result: Any?, _ error: Error?) -> Void) { + let api = SessionManager.default let body = [ "id": randomBytesHex(len: 16), @@ -144,21 +182,22 @@ class APIInternal { "args": args ] as [String : Any] - Alamofire.request("https://\\(baseUrl)/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).validate().responseJSON { response in - switch response.result { - case .failure(let err): - callback(nil, Error("Connection", err.localizedDescription)) - break - case .success(let value): - let body = value as! [String: Any] - if body["ok"] as! Bool { - callback(body["result"]!, nil) - } else { - let error = body["error"] as! [String: String] - callback(nil, Error(error["type"]!, error["message"]!)) - } - break + api.request("https://\\(baseUrl)/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).responseJSON { response in + + guard let responseValue = response.result.value else { + callback(nil, Error(API.ErrorType.ConnectionError, "no result value")) + return + } + + let response = HTTPResponse(json: responseValue as! [String: Any]) + saveDeviceID(response.deviceId) + + guard response.error == nil && response.ok else { + callback(nil, response.error) + return } + + callback(response.result, nil) } } } From e0e9d3449348829cd3dc748c6c5216f15b55b470 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 24 Mar 2017 10:31:03 -0300 Subject: [PATCH 034/625] Implement import --- lexer.cr | 8 ++++++++ main.cr | 3 +-- parser.cr | 33 ++++++++++++++++++++++++++------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/lexer.cr b/lexer.cr index 0fc31fb..d0b7b5a 100644 --- a/lexer.cr +++ b/lexer.cr @@ -1,4 +1,5 @@ class Lexer + property filename : String class LexerException < Exception end @@ -45,6 +46,7 @@ class Lexer return make_token(CommaSymbolToken.new) if literal_match(",") return make_token(EqualSymbolToken.new) if literal_match("=") + return make_token(ImportKeywordToken.new) if literal_match("import") return make_token(TypeKeywordToken.new) if literal_match("type") return make_token(EnumKeywordToken.new) if literal_match("enum") return make_token(GetKeywordToken.new) if literal_match("get") @@ -190,6 +192,12 @@ class Token end end +class ImportKeywordToken < Token + def try_ident + IdentifierToken.new("import") + end +end + class TypeKeywordToken < Token def try_ident IdentifierToken.new("type") diff --git a/main.cr b/main.cr index 081c0ed..687731a 100644 --- a/main.cr +++ b/main.cr @@ -30,8 +30,7 @@ end source = sources[0] -lexer = Lexer.new(source) -parser = Parser.new(lexer) +parser = Parser.new(source) ast = parser.parse ast.semantic diff --git a/parser.cr b/parser.cr index bbec50e..818ba82 100644 --- a/parser.cr +++ b/parser.cr @@ -7,16 +7,39 @@ class Parser class ParserException < Exception end + @lexers = [] of Lexer @token : Token | Nil - def initialize(@lexer : Lexer) - @token = @lexer.next_token + def initialize(source : String) + @lexers << Lexer.new(source) + next_token + end + + def next_token + while @lexers.size > 0 + @token = @lexers.last.next_token + if @token + return + else + @lexers.pop + end + end + end + + def current_source + @lexers.last.filename if @lexers.size > 0 end def parse api = AST::ApiDescription.new while @token - case multi_expect(TypeKeywordToken, EnumKeywordToken, GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken, GlobalOptionToken, ErrorKeywordToken) + case multi_expect(ImportKeywordToken, TypeKeywordToken, EnumKeywordToken, GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken, GlobalOptionToken, ErrorKeywordToken) + when ImportKeywordToken + next_token + token = expect StringLiteralToken + source = File.expand_path(token.str + ".sdkgen", File.dirname(current_source.not_nil!)) + @lexers << Lexer.new(source) + next_token when TypeKeywordToken api.type_definitions << parse_type_definition_definition when EnumKeywordToken @@ -35,10 +58,6 @@ class Parser api end - def next_token - @token = @lexer.next_token - end - macro multi_expect(*token_types) token = @token unless token From bf9bd03b4c7597f309e629bbc8c223f20f20b46f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 24 Mar 2017 18:05:33 -0300 Subject: [PATCH 035/625] small naming fixes --- parser.cr | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/parser.cr b/parser.cr index 818ba82..daa2c1a 100644 --- a/parser.cr +++ b/parser.cr @@ -3,7 +3,6 @@ require "./ast" require "./ast_semantic" class Parser - class ParserException < Exception end @@ -41,7 +40,7 @@ class Parser @lexers << Lexer.new(source) next_token when TypeKeywordToken - api.type_definitions << parse_type_definition_definition + api.type_definitions << parse_type_definition when EnumKeywordToken api.enum_definitions << parse_enum when GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken @@ -126,7 +125,7 @@ class Parser end end - def parse_type_definition_definition + def parse_type_definition expect TypeKeywordToken next_token From 7754eb4dd87db8501b959c3e91b8f63d655268cc Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 24 Mar 2017 18:05:41 -0300 Subject: [PATCH 036/625] update extension --- ext/vscode/package.json | 2 +- ext/vscode/syntaxes/sdkgen.tmLanguage.json | 29 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ext/vscode/package.json b/ext/vscode/package.json index 280850a..cb48f57 100644 --- a/ext/vscode/package.json +++ b/ext/vscode/package.json @@ -2,7 +2,7 @@ "name": "sdkgen", "displayName": "sdkgen", "description": "sdkgen language support", - "version": "0.0.1", + "version": "0.0.2", "publisher": "cubos", "engines": { "vscode": "^1.10.0" diff --git a/ext/vscode/syntaxes/sdkgen.tmLanguage.json b/ext/vscode/syntaxes/sdkgen.tmLanguage.json index 3946e7a..1f5f222 100644 --- a/ext/vscode/syntaxes/sdkgen.tmLanguage.json +++ b/ext/vscode/syntaxes/sdkgen.tmLanguage.json @@ -15,6 +15,18 @@ "include": "#literal" } ] + }, { + "name": "meta.import", + "begin": "(import) ", + "beginCaptures": { + "1": {"name": "keyword.control"} + }, + "end": "\n", + "patterns": [ + { + "include": "#literal" + } + ] }, { "name": "meta.error", "match": "(error) ([A-Z][a-zA-Z0-9_]*)", @@ -35,6 +47,23 @@ "include": "#fields" } ] + }, { + "name": "meta.enum", + "begin": "(enum) ([A-Z][a-zA-Z0-9_]*) \\{", + "beginCaptures": { + "1": {"name": "keyword.control"}, + "2": {"name": "entity.name.type"} + }, + "end": "\\}", + "patterns": [ + { + "include": "#any" + }, + { + "name": "variable.parameter", + "match": "(\\w+)" + } + ] }, { "name": "meta.operation", "begin": "(get|function|subscribe) ([a-zA-Z0-9_]+)", From 5d1a7ea28addefe04f21bc782d0e12a61299f1a6 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 27 Mar 2017 18:13:47 -0300 Subject: [PATCH 037/625] Save deviceId for android --- target_java_android.cr | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target_java_android.cr b/target_java_android.cr index 270cad1..22f290e 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -294,6 +294,10 @@ END try { JSONObject body = new JSONObject(response.body().string()); + + SharedPreferences pref = context().getSharedPreferences("api", Context.MODE_PRIVATE); + pref.edit().putString("deviceId", body.getString("deviceId")).apply(); + if (!body.getBoolean("ok")) { String type = body.getJSONObject("error").getString("type"); String message = body.getJSONObject("error").getString("message"); From df2d96815b36e444b80cd7b7f86a09e15a1e1cd3 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 27 Mar 2017 18:14:10 -0300 Subject: [PATCH 038/625] Integrate with stetho by default --- target-android/api/build.gradle | 2 ++ target_java_android.cr | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/target-android/api/build.gradle b/target-android/api/build.gradle index 5f6c335..8095238 100644 --- a/target-android/api/build.gradle +++ b/target-android/api/build.gradle @@ -23,6 +23,8 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.squareup.okhttp3:okhttp:3.6.0' + compile 'com.facebook.stetho:stetho:1.4.2' + compile 'com.facebook.stetho:stetho-okhttp3:1.4.2' } publishing { diff --git a/target_java_android.cr b/target_java_android.cr index 22f290e..27a9b6d 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -15,6 +15,9 @@ import android.provider.Settings; import android.util.Base64; import android.util.Log; +import com.facebook.stetho.Stetho; +import com.facebook.stetho.okhttp3.StethoInterceptor; + import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -155,8 +158,15 @@ END private static class Internal { private static final String baseUrl = #{@ast.options.url.inspect}; - private static final OkHttpClient http = new OkHttpClient(); + private static final OkHttpClient http = new OkHttpClient.Builder() + .addNetworkInterceptor(new StethoInterceptor()) + .build(); private static final SecureRandom random = new SecureRandom(); + private static boolean initialized = false; + + private static void initialize() { + Stetho.initializeWithDefaults(context()); + } private static Context context() { try { @@ -249,6 +259,8 @@ END } private static void makeRequest(String name, JSONObject args, final RequestCallback callback) { + if (!initialized) initialize(); + JSONObject body = new JSONObject(); try { body.put("id", randomBytesHex(16)); From d732307415314c5d6899dd059a1243dd57e9600f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 27 Mar 2017 18:14:33 -0300 Subject: [PATCH 039/625] cleaner server code for more device info --- target_typescript_server.cr | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/target_typescript_server.cr b/target_typescript_server.cr index 9657cff..157588a 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -94,12 +94,7 @@ export function start(port: number) { const startTime = process.hrtime(); (async () => { - const deviceInfo = { - platform: request.device.platform, - platformVersion: request.device.platformVersion, - version: request.device.version, - language: request.device.language - }; + const {id, ...deviceInfo} = context.device; if (!context.device.id) { context.device.id = crypto.randomBytes(32).toString("hex"); From d0a2186f1deca38814e57d751d9b5fe3151e27d0 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 27 Mar 2017 19:02:11 -0300 Subject: [PATCH 040/625] use correct fingerprint on android --- target_java_android.cr | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 27a9b6d..5322fdb 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -165,6 +165,7 @@ END private static boolean initialized = false; private static void initialize() { + initialized = true; Stetho.initializeWithDefaults(context()); } @@ -232,7 +233,7 @@ END private static JSONObject device() throws JSONException { JSONObject device = new JSONObject(); device.put("platform", "android"); - device.put("fingerprint", "" + Settings.Secure.ANDROID_ID); + device.put("fingerprint", "" + Secure.getString(context().getContentResolver(), Secure.ANDROID_ID)); device.put("platformVersion", "Android " + Build.VERSION.RELEASE + "(API " + Build.VERSION.SDK_INT + ") on " + Build.BRAND + " " + Build.MODEL); try { device.put("version", context().getPackageManager().getPackageInfo(context().getPackageName(), 0).versionName); From 39cd8416f2d4e9c7585723b1e162507ac5829249 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 27 Mar 2017 19:02:23 -0300 Subject: [PATCH 041/625] save device date on signup --- target_typescript_server.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/target_typescript_server.cr b/target_typescript_server.cr index 157588a..dc7a82d 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -101,6 +101,7 @@ export function start(port: number) { r.table("devices").insert({ id: context.device.id, + date: r.now(), ...deviceInfo }).then(); } else { From f35e53681da943a929e3cc163d6dcc94add725d7 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 28 Mar 2017 09:47:24 -0300 Subject: [PATCH 042/625] Rename generate_type_definition_interface --- target_java.cr | 2 +- target_java_android.cr | 2 +- target_swift.cr | 2 +- target_swift_ios.cr | 2 +- target_typescript.cr | 2 +- target_typescript_server.cr | 2 +- target_typescript_web.cr | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/target_java.cr b/target_java.cr index 5bbb408..493ae10 100644 --- a/target_java.cr +++ b/target_java.cr @@ -53,7 +53,7 @@ abstract class JavaTarget < Target t.name end - def generate_type_definition_interface(type_definition) + def generate_type_definition_type(type_definition) String.build do |io| io << "public static class #{type_definition.name} {\n" type_definition.fields.each do |field| diff --git a/target_java_android.cr b/target_java_android.cr index 5322fdb..d90a727 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -47,7 +47,7 @@ public class API { END @ast.type_definitions.each do |type_definition| - @io << ident generate_type_definition_interface(type_definition) + @io << ident generate_type_definition_type(type_definition) @io << "\n\n" end diff --git a/target_swift.cr b/target_swift.cr index df4e250..afa5907 100644 --- a/target_swift.cr +++ b/target_swift.cr @@ -33,7 +33,7 @@ abstract class SwiftTarget < Target t.name end - def generate_type_definition_interface(type_definition) + def generate_type_definition_type(type_definition) String.build do |io| io << "class #{type_definition.name} {\n" type_definition.fields.each do |field| diff --git a/target_swift_ios.cr b/target_swift_ios.cr index 9b5f62b..11eb9d1 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -21,7 +21,7 @@ END @io << "\n\n" @ast.type_definitions.each do |type_definition| - @io << ident generate_type_definition_interface(type_definition) + @io << ident generate_type_definition_type(type_definition) @io << "\n\n" end diff --git a/target_typescript.cr b/target_typescript.cr index 43d38bc..98272ca 100644 --- a/target_typescript.cr +++ b/target_typescript.cr @@ -29,7 +29,7 @@ abstract class TypeScriptTarget < Target t.name end - def generate_type_definition_interface(type_definition) + def generate_type_definition_type(type_definition) String.build do |io| io << "export interface #{type_definition.name} {\n" type_definition.fields.each do |field| diff --git a/target_typescript_server.cr b/target_typescript_server.cr index dc7a82d..8b22fcc 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -23,7 +23,7 @@ END @io << "};\n\n" @ast.type_definitions.each do |type_definition| - @io << generate_type_definition_interface(type_definition) + @io << generate_type_definition_type(type_definition) @io << "\n\n" end diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 482b663..d2bb5be 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -12,7 +12,7 @@ const baseUrl = #{@ast.options.url.inspect}; END @ast.type_definitions.each do |type_definition| - @io << generate_type_definition_interface(type_definition) + @io << generate_type_definition_type(type_definition) @io << "\n\n" end From 88024a329394803bc98512098b57ed9448b338c3 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 30 Mar 2017 15:36:14 -0300 Subject: [PATCH 043/625] Rewrite semantics and type parse logic. Support annonymus types --- ast.cr | 41 +++++---- ast_semantic.cr | 165 +++++++++++++++++++++++++----------- lexer.cr | 4 +- main.cr | 4 +- parser.cr | 29 ++++--- target_typescript.cr | 28 ++++-- target_typescript_server.cr | 9 +- target_typescript_web.cr | 9 +- 8 files changed, 195 insertions(+), 94 deletions(-) diff --git a/ast.cr b/ast.cr index 2cd8995..94589c2 100644 --- a/ast.cr +++ b/ast.cr @@ -1,6 +1,7 @@ module AST abstract class Type + include AST end abstract class PrimitiveType < Type @@ -45,24 +46,40 @@ module AST end end + class EnumType < Type + property values = [] of String + end + + class StructType < Type + property fields = [] of Field + end + + class TypeDefinition + include AST + property! name : String + property! type : Type + end + + class TypeReference < Type + property name + def initialize(@name : String) + end + end + class ApiDescription + include AST property type_definitions = [] of TypeDefinition - property enum_definitions = [] of EnumDefinition property operations = [] of Operation property options = Options.new property errors = [] of String end - class EnumDefinition - property! name : String - property values = [] of String - end - class Options property url = "" end class Field + include AST property! name : String property! type : Type property secret = false @@ -72,18 +89,8 @@ module AST end end - class TypeDefinition - property! name : String - property fields = [] of Field - end - - class TypeReference < Type - property name - def initialize(@name : String) - end - end - abstract class Operation + include AST property! name : String property args = [] of Field property! return_type : Type diff --git a/ast_semantic.cr b/ast_semantic.cr index 0151caa..51049b6 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -1,82 +1,151 @@ -module AST - abstract class PrimitiveType < Type - def semantic(ast) +module Semantic + class Visitor + def initialize(@ast : AST::ApiDescription) end - def check_recursive_type(ast, stack) + def visit(node : AST::ApiDescription) + node.type_definitions.each {|e| visit e } + node.operations.each {|e| visit e } end - end - class OptionalType < Type - def semantic(ast) - @base.semantic(ast) + def visit(op : AST::Operation) + op.args.each {|arg| visit arg } + visit op.return_type end - def check_recursive_type(ast, stack) - @base.check_recursive_type(ast, stack) + def visit(field : AST::Field) + visit field.type end - end - class ArrayType < Type - def semantic(ast) - @base.semantic(ast) + def visit(definition : AST::TypeDefinition) + visit definition.type end - def check_recursive_type(ast, stack) - @base.check_recursive_type(ast, stack) + def visit(t : AST::StructType) + t.fields.each {|field| visit field } end - end - class ApiDescription - def semantic - type_definitions.each &.semantic(self) - operations.each &.semantic(self) + def visit(t : AST::ArrayType) + visit t.base + end + + def visit(t : AST::OptionalType) + visit t.base + end + + def visit(t : AST::PrimitiveType | AST::EnumType | AST::TypeReference) end end - class Field - def semantic(ast) - type.semantic(ast) + class CheckEveryTypeDefined < Visitor + def visit(ref : AST::TypeReference) + definition = @ast.type_definitions.find {|t| t.name == ref.name } + unless definition + raise "Could not find type '#{ref.name}'" + end + ref.type = definition.type + super end end - class TypeDefinition - def semantic(ast) - fields.each &.semantic(ast) - check_recursive_type(ast, [] of TypeDefinition) + class CheckNoRecursiveTypes < Visitor + @path = [] of String + @root_type : AST::Type? + + def visit(definition : AST::TypeDefinition) + @path = [definition.name] + @root_type = definition.type + super + @root_type = nil end - def check_recursive_type(ast, stack) - raise "Cannot allow recursive type #{stack.map(&.name).join(" -> ")} -> #{name}" if stack.find &.== self - stack << self - fields.each {|field| field.type.check_recursive_type(ast, stack) } - stack.pop + def visit(field : AST::Field) + @path.push field.name + super + @path.pop end - end - class TypeReference < Type - property! ref : TypeDefinition | EnumDefinition + def visit(ref : AST::TypeReference) + if ref.type == @root_type + @path.push(@path[0]) + raise "Detected recursive type #{@path.join(" -> ")}" + end + visit ref.type + super + end + end - def semantic(ast) - @ref = ast.type_definitions.find {|t| t.name == name } || ast.enum_definitions.find {|t| t.name == name } - unless @ref - raise "Could not find type '#{name}'" + class CheckDefineOnlyStructOrEnum < Visitor + def visit(definition : AST::TypeDefinition) + t = definition.type + unless t.is_a? AST::StructType || t.is_a? AST::EnumType + raise "Can't define 'definition.name' to be something other than a struct or an enum" end + super + end + end + + class GiveStructAndEnumTypeNames < Visitor + @path = [] of String + + def visit(definition : AST::TypeDefinition) + @path = [definition.name] + super end - def check_recursive_type(ast, stack) - ref = ast.type_definitions.find {|t| t.name == name } - ref.check_recursive_type(ast, stack) if ref + def visit(field : AST::Field) + @path.push field.name + super + @path.pop + end + + def visit(t : AST::StructType) + t.name = @path.join("_") + super end end - abstract class Operation - def semantic(ast) - args.each &.semantic(ast) - return_type.semantic(ast) + class CollectStructAndEnumTypes < Visitor + def visit(t : AST::StructType) + @ast.struct_types << t + super + end + + def visit(t : AST::EnumType) + @ast.enum_types << t + super + end + end +end + +module AST + class ApiDescription + property struct_types = [] of AST::StructType + property enum_types = [] of AST::EnumType + + def semantic + Semantic::CheckEveryTypeDefined.new(self).visit(self) + Semantic::CheckNoRecursiveTypes.new(self).visit(self) + Semantic::CheckDefineOnlyStructOrEnum.new(self).visit(self) + Semantic::GiveStructAndEnumTypeNames.new(self).visit(self) + Semantic::CollectStructAndEnumTypes.new(self).visit(self) end + end + + class TypeReference + property! type : Type + end + class StructType + property! name : String + end + + class EnumType + property! name : String + end + + abstract class Operation def pretty_name name end @@ -87,4 +156,4 @@ module AST return_type.is_a?(BoolPrimitiveType) ? name : "get" + name[0].upcase + name[1..-1] end end -end \ No newline at end of file +end diff --git a/lexer.cr b/lexer.cr index d0b7b5a..e0449ff 100644 --- a/lexer.cr +++ b/lexer.cr @@ -64,7 +64,7 @@ class Lexer return make_token(PrimitiveTypeToken.new("void")) if literal_match("void") if current_char!.letter? - while current_char && (current_char!.letter? || current_char!.number? || current_char! == '_') + while current_char && (current_char!.letter? || current_char!.number?) next_char end return make_token(IdentifierToken.new(@raw[@start...@pos])) @@ -72,7 +72,7 @@ class Lexer if current_char! == '$' next_char - while current_char && (current_char!.letter? || current_char!.number? || current_char! == '_') + while current_char && (current_char!.letter? || current_char!.number?) next_char end return make_token(GlobalOptionToken.new(@raw[@start+1...@pos])) diff --git a/main.cr b/main.cr index 687731a..6c81d61 100644 --- a/main.cr +++ b/main.cr @@ -1,8 +1,8 @@ require "./lexer" require "./parser" require "./ast_to_s" -require "./target_java_android" -require "./target_swift_ios" +# require "./target_java_android" +# require "./target_swift_ios" require "./target_typescript_server" require "./target_typescript_web" require "option_parser" diff --git a/parser.cr b/parser.cr index daa2c1a..52f1146 100644 --- a/parser.cr +++ b/parser.cr @@ -32,7 +32,7 @@ class Parser def parse api = AST::ApiDescription.new while @token - case multi_expect(ImportKeywordToken, TypeKeywordToken, EnumKeywordToken, GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken, GlobalOptionToken, ErrorKeywordToken) + case multi_expect(ImportKeywordToken, TypeKeywordToken, GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken, GlobalOptionToken, ErrorKeywordToken) when ImportKeywordToken next_token token = expect StringLiteralToken @@ -41,8 +41,6 @@ class Parser next_token when TypeKeywordToken api.type_definitions << parse_type_definition - when EnumKeywordToken - api.enum_definitions << parse_enum when GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken api.operations << parse_operation when GlobalOptionToken @@ -99,13 +97,7 @@ class Parser expect EnumKeywordToken next_token - e = AST::EnumDefinition.new - name_token = expect(IdentifierToken) - unless name_token.name[0].uppercase? - raise ParserException.new "The enum name must start with an uppercase letter, but found '#{name_token.name}' at #{name_token.location}" - end - e.name = name_token.name - next_token + e = AST::EnumType.new expect CurlyOpenSymbolToken next_token @@ -113,8 +105,8 @@ class Parser while true case token = multi_expect(IdentifierToken, CurlyCloseSymbolToken) when IdentifierToken - unless token.name[0].uppercase? - raise ParserException.new "The enum value must start with an uppercase letter, but found '#{name_token.name}' at #{name_token.location}" + unless token.name[0].lowercase? + raise ParserException.new "The enum value must start with an lowercase letter, but found '#{token.name}' at #{token.location}" end e.values << token.name next_token @@ -137,9 +129,16 @@ class Parser t.name = name_token.name next_token + t.type = parse_type + t + end + + def parse_struct expect CurlyOpenSymbolToken next_token + t = AST::StructType.new + while true case token = multi_expect(IdentifierToken, CurlyCloseSymbolToken) when IdentifierToken @@ -234,7 +233,11 @@ class Parser end def parse_type(allow_void = true) - result = case token = multi_expect(PrimitiveTypeToken, IdentifierToken) + result = case token = multi_expect(CurlyOpenSymbolToken, EnumKeywordToken, PrimitiveTypeToken, IdentifierToken) + when CurlyOpenSymbolToken + return parse_struct + when EnumKeywordToken + return parse_enum when IdentifierToken unless token.name[0].uppercase? raise ParserException.new "Expected a type but found '#{token.name}', at #{token.location}" diff --git a/target_typescript.cr b/target_typescript.cr index 98272ca..203ae29 100644 --- a/target_typescript.cr +++ b/target_typescript.cr @@ -25,20 +25,24 @@ abstract class TypeScriptTarget < Target native_type(t.base) + "[]" end - def native_type(t : AST::TypeReference) + def native_type(t : AST::StructType | AST::EnumType | AST::TypeReference) t.name end - def generate_type_definition_type(type_definition) + def generate_struct_type(t) String.build do |io| - io << "export interface #{type_definition.name} {\n" - type_definition.fields.each do |field| + io << "export interface #{t.name} {\n" + t.fields.each do |field| io << ident "#{field.name}: #{native_type field.type};\n" end io << "}" end end + def generate_enum_type(t) + "export type #{t.name} = #{t.values.map(&.inspect).join(" | ")};" + end + def operation_ret(op : AST::GetOperation | AST::FunctionOperation) op.return_type.is_a?(AST::VoidPrimitiveType) ? "void" : native_type op.return_type end @@ -76,15 +80,19 @@ abstract class TypeScriptTarget < Target "#{src} === null || #{src} === undefined ? null : #{type_from_json(t.base, src)}" when AST::ArrayType t.base.is_a?(AST::TypeReference) ? "#{src}.map(e => (#{type_from_json(t.base, "e")}))" : "#{src}.map(e => #{type_from_json(t.base, "e")})" - when AST::TypeReference + when AST::StructType String::Builder.build do |io| io << "{\n" - (t.ref.as AST::TypeDefinition).fields.each do |field| + t.fields.each do |field| io << ident "#{field.name}: #{type_from_json(field.type, "#{src}.#{field.name}")}," io << "\n" end io << "}" end + when AST::EnumType + "#{src}" + when AST::TypeReference + type_from_json(t.type, src) else raise "Unknown type" end @@ -106,15 +114,19 @@ abstract class TypeScriptTarget < Target "#{src} === null || #{src} === undefined ? null : #{type_to_json(t.base, src)}" when AST::ArrayType t.base.is_a?(AST::TypeReference) ? "#{src}.map(e => (#{type_to_json(t.base, "e")}))" : "#{src}.map(e => #{type_to_json(t.base, "e")})" - when AST::TypeReference + when AST::StructType String::Builder.build do |io| io << "{\n" - (t.ref.as AST::TypeDefinition).fields.each do |field| + t.fields.each do |field| io << ident "#{field.name}: #{type_to_json(field.type, "#{src}.#{field.name}")}," io << "\n" end io << "}" end + when AST::EnumType + "#{src}" + when AST::TypeReference + type_to_json(t.type, src) else raise "Unknown type" end diff --git a/target_typescript_server.cr b/target_typescript_server.cr index 8b22fcc..bc6f11c 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -22,8 +22,13 @@ END end @io << "};\n\n" - @ast.type_definitions.each do |type_definition| - @io << generate_type_definition_type(type_definition) + @ast.struct_types.each do |t| + @io << generate_struct_type(t) + @io << "\n\n" + end + + @ast.enum_types.each do |t| + @io << generate_enum_type(t) @io << "\n\n" end diff --git a/target_typescript_web.cr b/target_typescript_web.cr index d2bb5be..a4d820b 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -11,8 +11,13 @@ const baseUrl = #{@ast.options.url.inspect}; END - @ast.type_definitions.each do |type_definition| - @io << generate_type_definition_type(type_definition) + @ast.struct_types.each do |t| + @io << generate_struct_type(t) + @io << "\n\n" + end + + @ast.enum_types.each do |t| + @io << generate_enum_type(t) @io << "\n\n" end From 47cdbe38bea8d1fcb34356fe8f0fda3eb098c7ea Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 30 Mar 2017 18:14:30 -0300 Subject: [PATCH 044/625] Fix java for enum and annonymos struc --- main.cr | 2 +- target_java.cr | 40 +++++++++++++++++++++++++++++----------- target_java_android.cr | 9 +++++++-- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/main.cr b/main.cr index 6c81d61..01ddd38 100644 --- a/main.cr +++ b/main.cr @@ -1,7 +1,7 @@ require "./lexer" require "./parser" require "./ast_to_s" -# require "./target_java_android" +require "./target_java_android" # require "./target_swift_ios" require "./target_typescript_server" require "./target_typescript_web" diff --git a/target_java.cr b/target_java.cr index 493ae10..6c76b31 100644 --- a/target_java.cr +++ b/target_java.cr @@ -49,14 +49,14 @@ abstract class JavaTarget < Target "ArrayList<#{native_type_not_primitive(t.base)}>" end - def native_type(t : AST::TypeReference) + def native_type(t : AST::StructType | AST::EnumType | AST::TypeReference) t.name end - def generate_type_definition_type(type_definition) + def generate_struct_type(t) String.build do |io| - io << "public static class #{type_definition.name} {\n" - type_definition.fields.each do |field| + io << "public static class #{t.name} {\n" + t.fields.each do |field| io << ident "public #{native_type field.type} #{field.name};\n" end io << ident <<-END @@ -66,7 +66,7 @@ public JSONObject toJSON() { return new JSONObject() {{ END - type_definition.fields.each do |field| + t.fields.each do |field| io << ident ident ident ident "put(\"#{field.name}\", #{type_to_json field.type, field.name});\n" end io << ident <<-END @@ -77,12 +77,12 @@ END } } -public static #{type_definition.name} fromJSON(final JSONObject json) { +public static #{t.name} fromJSON(final JSONObject json) { try { - return new #{type_definition.name}() {{ + return new #{t.name}() {{ END - type_definition.fields.each do |field| + t.fields.each do |field| io << ident ident ident ident "#{field.name} = #{type_from_json field.type, get_field_from_json_object(field.type, "json", field.name.inspect)};\n" end io << ident <<-END @@ -90,7 +90,7 @@ END }}; } catch (JSONException e) { e.printStackTrace(); - return new #{type_definition.name}(); + return new #{t.name}(); } } @@ -99,6 +99,16 @@ END end end + def generate_enum_type(t) + String.build do |io| + io << "public enum #{t.name} {\n" + t.values.each do |value| + io << ident "#{value},\n" + end + io << "}" + end + end + def get_field_from_json_object(t : AST::Type, src : String, name : String) case t when AST::StringPrimitiveType, AST::DatePrimitiveType, AST::DateTimePrimitiveType, AST::BytesPrimitiveType @@ -138,8 +148,12 @@ END "#{src} == null ? null : #{type_from_json(t.base, src)}" when AST::ArrayType "new #{native_type t}() {{ JSONArray ary = #{src}; for (int i = 0; i < ary.length(); ++i) add(#{type_from_json(t.base, get_field_from_json_object(t.base, "ary", "i"))}); }}" + when AST::StructType + "#{t.name}.fromJSON(#{src})" + when AST::EnumType + "#{t.values.map {|v| "#{src} == #{v.inspect} ? #{t.name}.#{v} : " }.join}null" when AST::TypeReference - "#{t.ref.name}.fromJSON(#{src})" + type_from_json(t.type, src) else raise "Unknown type" end @@ -161,8 +175,12 @@ END "#{src} == null ? null : #{type_to_json(t.base, src)}" when AST::ArrayType "new JSONArray() {{ for (#{native_type t.base} el : #{src}) put(#{type_to_json t.base, "el"}); }}" - when AST::TypeReference + when AST::StructType "#{src}.toJSON()" + when AST::EnumType + "#{t.values.map {|v| "#{src} == #{t.name}.#{v} ? #{v.inspect} : " }.join}null" + when AST::TypeReference + type_to_json(t.type, src) else raise "Unknown type" end diff --git a/target_java_android.cr b/target_java_android.cr index d90a727..f718611 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -46,8 +46,13 @@ public class API { END - @ast.type_definitions.each do |type_definition| - @io << ident generate_type_definition_type(type_definition) + @ast.struct_types.each do |t| + @io << ident generate_struct_type(t) + @io << "\n\n" + end + + @ast.enum_types.each do |t| + @io << ident generate_enum_type(t) @io << "\n\n" end From f48e83f53f0cfe9097c353c8fc72281faedff9d8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 30 Mar 2017 18:25:01 -0300 Subject: [PATCH 045/625] Fix swift for enum and struct --- main.cr | 2 +- target_swift.cr | 46 ++++++++++++++++++++++++++++----------- target_swift_ios.cr | 52 ++++++++++++++++++++------------------------- 3 files changed, 58 insertions(+), 42 deletions(-) diff --git a/main.cr b/main.cr index 01ddd38..687731a 100644 --- a/main.cr +++ b/main.cr @@ -2,7 +2,7 @@ require "./lexer" require "./parser" require "./ast_to_s" require "./target_java_android" -# require "./target_swift_ios" +require "./target_swift_ios" require "./target_typescript_server" require "./target_typescript_web" require "option_parser" diff --git a/target_swift.cr b/target_swift.cr index afa5907..b50d56f 100644 --- a/target_swift.cr +++ b/target_swift.cr @@ -29,14 +29,14 @@ abstract class SwiftTarget < Target "[#{native_type(t.base)}]" end - def native_type(t : AST::TypeReference) + def native_type(t : AST::StructType | AST::EnumType | AST::TypeReference) t.name end - def generate_type_definition_type(type_definition) + def generate_struct_type(t) String.build do |io| - io << "class #{type_definition.name} {\n" - type_definition.fields.each do |field| + io << "class #{t.name} {\n" + t.fields.each do |field| io << ident "var #{field.name}: #{native_type field.type}\n" end io << ident <<-END @@ -44,16 +44,16 @@ abstract class SwiftTarget < Target init() { END - type_definition.fields.each do |field| + t.fields.each do |field| io << ident ident "#{field.name} = #{default_value field.type}\n" end io << ident <<-END } -init(#{type_definition.fields.map{|f| "#{f.name}: #{native_type f.type}"}.join(", ")}) { +init(#{t.fields.map{|f| "#{f.name}: #{native_type f.type}"}.join(", ")}) { END - type_definition.fields.each do |field| + t.fields.each do |field| io << ident ident "self.#{field.name} = #{field.name}\n" end io << ident <<-END @@ -62,7 +62,7 @@ END init(json: [String: Any]) { END - type_definition.fields.each do |field| + t.fields.each do |field| io << ident ident "#{field.name} = #{type_from_json field.type, "json[#{field.name.inspect}]"}\n" end io << ident <<-END @@ -72,7 +72,7 @@ func toJSON() -> [String: Any] { var json = [String: Any]() END - type_definition.fields.each do |field| + t.fields.each do |field| io << ident ident "json[\"#{field.name}\"] = #{type_to_json field.type, field.name}\n" end io << ident <<-END @@ -84,6 +84,16 @@ END end end + def generate_enum_type(t) + String.build do |io| + io << "enum #{t.name}: String {\n" + t.values.each do |value| + io << ident "case #{value} = #{value.inspect}\n" + end + io << "}" + end + end + def default_value(t : AST::Type) case t when AST::StringPrimitiveType @@ -102,8 +112,12 @@ END "nil" when AST::ArrayType "[]" + when AST::StructType + "#{t.name}()" + when AST::EnumType + "#{t.name}(rawValue: \"\")" when AST::TypeReference - "#{t.ref.name}()" + default_value(t.type) else raise "Unknown type" end @@ -133,8 +147,12 @@ END "APIInternal.isNull(value: #{src}) ? nil : (#{type_from_json(t.base, src)})" when AST::ArrayType "(#{src} as! [AnyObject]).map({(el) -> #{native_type t.base} in return #{type_from_json t.base, "el"}})" + when AST::StructType + "#{t.name}(json: #{src} as! [String: Any])" + when AST::EnumType + "#{t.name}(rawValue: #{src} as! String)" when AST::TypeReference - "#{t.ref.name}(json: #{src} as! [String: Any])" + type_from_json(t.type, src) else raise "Unknown type" end @@ -156,8 +174,12 @@ END "#{src} == nil ? nil : #{type_to_json(t.base, src + "!")}" when AST::ArrayType "#{src}.map({ return #{type_to_json t.base, "$0"} })" - when AST::TypeReference + when AST::StructType "#{src}.toJSON()" + when AST::EnumType + "#{src}.rawValue" + when AST::TypeReference + type_to_json(t.type, src) else raise "Unknown type" end diff --git a/target_swift_ios.cr b/target_swift_ios.cr index 11eb9d1..ed39a20 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -9,19 +9,13 @@ class API { END - #generate error index - @io << "\n" - @io << ident "enum ErrorType: String {\n" - @ast.errors.each do |error| - @io << ident ident "case #{error} = #{error.inspect}\n" + @ast.struct_types.each do |t| + @io << ident generate_struct_type(t) + @io << "\n\n" end - @io << ident ident "case ConnectionError = \"ConnectionError\" \n" - @io << ident ident "case UnknownError = \"UnknownError\" \n" - @io << ident "}" - @io << "\n\n" - @ast.type_definitions.each do |type_definition| - @io << ident generate_type_definition_type(type_definition) + @ast.enum_types.each do |t| + @io << ident generate_enum_type(t) @io << "\n\n" end @@ -72,28 +66,28 @@ END class APIInternal { static var baseUrl = "api.nutriserie.com.br/user" - + class Error { var type: API.ErrorType var message: String - + init(_ type: API.ErrorType, _ message: String) { self.type = type self.message = message } - + init(json: [String: Any]) { self.type = API.ErrorType(rawValue: json["type"] as! String) ?? API.ErrorType.UnknownError self.message = json["message"] as! String } } - + class HTTPResponse { var ok: Bool! var deviceId: String! var result: Any? var error: Error? - + init(json: [String: Any]) { self.ok = json["ok"] as! Bool self.deviceId = json["deviceId"] as! String @@ -118,13 +112,13 @@ class APIInternal { } return device } - + static func randomBytesHex(len: Int) -> String { var randomBytes = [UInt8](repeating: 0, count: len) let _ = SecRandomCopyBytes(kSecRandomDefault, len, &randomBytes) return randomBytes.map({String(format: "%02hhx", $0)}).joined(separator: "") } - + static func decodeDate(str: String) -> Date { let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .gregorian) @@ -132,7 +126,7 @@ class APIInternal { formatter.dateFormat = "yyyy-MM-dd" return formatter.date(from: str)! } - + static func encodeDate(date: Date) -> String { let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .gregorian) @@ -140,7 +134,7 @@ class APIInternal { formatter.dateFormat = "yyyy-MM-dd" return formatter.string(from: date) } - + static func decodeDateTime(str: String) -> Date { let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .gregorian) @@ -149,7 +143,7 @@ class APIInternal { formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" return formatter.date(from: str)! } - + static func encodeDateTime(date: Date) -> String { let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .gregorian) @@ -158,11 +152,11 @@ class APIInternal { formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" return formatter.string(from: date) } - + static var deviceID: String? { return UserDefaults.standard.value(forKey: "device-id") as? String } - + static func saveDeviceID(_ id: String) { UserDefaults.standard.setValue(id, forKey: "device-id") UserDefaults.standard.synchronize() @@ -174,29 +168,29 @@ class APIInternal { static func makeRequest(_ name: String, _ args: [String: Any], callback: @escaping (_ result: Any?, _ error: Error?) -> Void) { let api = SessionManager.default - + let body = [ "id": randomBytesHex(len: 16), "device": device(), "name": name, "args": args ] as [String : Any] - + api.request("https://\\(baseUrl)/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).responseJSON { response in - + guard let responseValue = response.result.value else { callback(nil, Error(API.ErrorType.ConnectionError, "no result value")) return } - + let response = HTTPResponse(json: responseValue as! [String: Any]) saveDeviceID(response.deviceId) - + guard response.error == nil && response.ok else { callback(nil, response.error) return } - + callback(response.result, nil) } } From 957c6b4b89bf87dbdee23d78d780600b71e76c55 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 30 Mar 2017 18:25:12 -0300 Subject: [PATCH 046/625] Add ErrorType enum by default --- ast_semantic.cr | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ast_semantic.cr b/ast_semantic.cr index 51049b6..22e6e4f 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -125,6 +125,13 @@ module AST property enum_types = [] of AST::EnumType def semantic + error_types_enum = AST::EnumType.new + error_types_enum.values = errors + error_types_enum_def = AST::TypeDefinition.new + error_types_enum_def.name = "ErrorType" + error_types_enum_def.type = error_types_enum + type_definitions << error_types_enum_def + Semantic::CheckEveryTypeDefined.new(self).visit(self) Semantic::CheckNoRecursiveTypes.new(self).visit(self) Semantic::CheckDefineOnlyStructOrEnum.new(self).visit(self) From e3e1a45f81e32b54a7278c6f7bbd2a5207293b57 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 30 Mar 2017 18:29:13 -0300 Subject: [PATCH 047/625] Fix: Enums should get names too --- ast_semantic.cr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ast_semantic.cr b/ast_semantic.cr index 22e6e4f..552c304 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -104,6 +104,11 @@ module Semantic t.name = @path.join("_") super end + + def visit(t : AST::EnumType) + t.name = @path.join("_") + super + end end class CollectStructAndEnumTypes < Visitor From 605f3a7fad762b109f19ad39d771ee52f91b2143 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 30 Mar 2017 18:35:25 -0300 Subject: [PATCH 048/625] Improve error about recursive type --- ast_semantic.cr | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ast_semantic.cr b/ast_semantic.cr index 552c304..397eec7 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -68,8 +68,7 @@ module Semantic def visit(ref : AST::TypeReference) if ref.type == @root_type - @path.push(@path[0]) - raise "Detected recursive type #{@path.join(" -> ")}" + raise "Detected type recursion: #{@path.join(" -> ")}" end visit ref.type super From f3016a1a6c16b2d6dc8d74037ca1349eb855ea14 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 30 Mar 2017 18:35:46 -0300 Subject: [PATCH 049/625] Parser: handle string[]?[]?[]?[] --- parser.cr | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/parser.cr b/parser.cr index 52f1146..069b3b3 100644 --- a/parser.cr +++ b/parser.cr @@ -267,14 +267,16 @@ class Parser end next_token - while @token.is_a? ArraySymbolToken - next_token - result = AST::ArrayType.new(result) - end + while @token.is_a? ArraySymbolToken || @token.is_a? OptionalSymbolToken + if @token.is_a? ArraySymbolToken + next_token + result = AST::ArrayType.new(result) + end - if @token.is_a?(OptionalSymbolToken) - next_token - result = AST::OptionalType.new(result) + if @token.is_a?(OptionalSymbolToken) + next_token + result = AST::OptionalType.new(result) + end end result From bc87f99969b32e4e6f556f8eb7879bd43a7dcf87 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 30 Mar 2017 19:48:01 -0300 Subject: [PATCH 050/625] Update syntax for vscode --- ext/vscode/syntaxes/sdkgen.tmLanguage.json | 61 +++++++++++++--------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/ext/vscode/syntaxes/sdkgen.tmLanguage.json b/ext/vscode/syntaxes/sdkgen.tmLanguage.json index 1f5f222..de27309 100644 --- a/ext/vscode/syntaxes/sdkgen.tmLanguage.json +++ b/ext/vscode/syntaxes/sdkgen.tmLanguage.json @@ -36,32 +36,15 @@ } }, { "name": "meta.type", - "begin": "(type) ([A-Z][a-zA-Z0-9_]*) \\{", + "begin": "(type) ([A-Z][a-zA-Z0-9_]*) ", "beginCaptures": { "1": {"name": "keyword.control"}, "2": {"name": "entity.name.type"} }, - "end": "\\}", - "patterns": [ - { - "include": "#fields" - } - ] - }, { - "name": "meta.enum", - "begin": "(enum) ([A-Z][a-zA-Z0-9_]*) \\{", - "beginCaptures": { - "1": {"name": "keyword.control"}, - "2": {"name": "entity.name.type"} - }, - "end": "\\}", + "end": "\n", "patterns": [ { - "include": "#any" - }, - { - "name": "variable.parameter", - "match": "(\\w+)" + "include": "#type" } ] }, { @@ -101,8 +84,7 @@ "patterns": [ { "include": "#any" - }, - { + }, { "name": "meta.field", "begin": "(\\w+):", "beginCaptures": { @@ -121,8 +103,7 @@ "patterns": [ { "include": "#any" - }, - { + }, { "name": "keyword.type", "match": "\\b(bool|int|uint|float|string|datetime|date|bytes|void)\\b" }, { @@ -134,6 +115,35 @@ }, { "name": "constant.numeric", "match": "(![a-zA-Z0-9_]+)\\b" + }, { + "name": "meta.type", + "begin": "\\{", + "beginCaptures": { + "1": {"name": "keyword.control"}, + "2": {"name": "entity.name.type"} + }, + "end": "\\}", + "patterns": [ + { + "include": "#fields" + } + ] + }, { + "name": "meta.enum", + "begin": "(enum) \\{", + "beginCaptures": { + "1": {"name": "keyword.control"}, + "2": {"name": "entity.name.type"} + }, + "end": "\\}", + "patterns": [ + { + "include": "#any" + }, { + "name": "variable.parameter", + "match": "(\\w+)" + } + ] } ] }, @@ -141,8 +151,7 @@ "patterns": [ { "include": "#any" - }, - { + }, { "name": "string.quoted.double.untitled", "begin": "\"", "end": "\"", From 74f60ccc3430b10383104bee830b138b5b30480b Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 30 Mar 2017 19:49:02 -0300 Subject: [PATCH 051/625] publish vscode ext 0.0.3 --- ext/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/vscode/package.json b/ext/vscode/package.json index cb48f57..aa8e03a 100644 --- a/ext/vscode/package.json +++ b/ext/vscode/package.json @@ -2,7 +2,7 @@ "name": "sdkgen", "displayName": "sdkgen", "description": "sdkgen language support", - "version": "0.0.2", + "version": "0.0.3", "publisher": "cubos", "engines": { "vscode": "^1.10.0" From 0d1b501983e2050679a65f276aeeecd5bb743fb0 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 31 Mar 2017 09:22:21 -0300 Subject: [PATCH 052/625] Support to define all kinds of types, not only structs and enums --- ast_semantic.cr | 11 ----------- target_java.cr | 6 +++++- target_swift.cr | 6 +++++- target_typescript.cr | 6 +++++- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/ast_semantic.cr b/ast_semantic.cr index 397eec7..147f5f3 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -75,16 +75,6 @@ module Semantic end end - class CheckDefineOnlyStructOrEnum < Visitor - def visit(definition : AST::TypeDefinition) - t = definition.type - unless t.is_a? AST::StructType || t.is_a? AST::EnumType - raise "Can't define 'definition.name' to be something other than a struct or an enum" - end - super - end - end - class GiveStructAndEnumTypeNames < Visitor @path = [] of String @@ -138,7 +128,6 @@ module AST Semantic::CheckEveryTypeDefined.new(self).visit(self) Semantic::CheckNoRecursiveTypes.new(self).visit(self) - Semantic::CheckDefineOnlyStructOrEnum.new(self).visit(self) Semantic::GiveStructAndEnumTypeNames.new(self).visit(self) Semantic::CollectStructAndEnumTypes.new(self).visit(self) end diff --git a/target_java.cr b/target_java.cr index 6c76b31..0fbde67 100644 --- a/target_java.cr +++ b/target_java.cr @@ -49,10 +49,14 @@ abstract class JavaTarget < Target "ArrayList<#{native_type_not_primitive(t.base)}>" end - def native_type(t : AST::StructType | AST::EnumType | AST::TypeReference) + def native_type(t : AST::StructType | AST::EnumType) t.name end + def native_type(ref : AST::TypeReference) + native_type ref.type + end + def generate_struct_type(t) String.build do |io| io << "public static class #{t.name} {\n" diff --git a/target_swift.cr b/target_swift.cr index b50d56f..f26d991 100644 --- a/target_swift.cr +++ b/target_swift.cr @@ -29,10 +29,14 @@ abstract class SwiftTarget < Target "[#{native_type(t.base)}]" end - def native_type(t : AST::StructType | AST::EnumType | AST::TypeReference) + def native_type(t : AST::StructType | AST::EnumType) t.name end + def native_type(ref : AST::TypeReference) + native_type ref.type + end + def generate_struct_type(t) String.build do |io| io << "class #{t.name} {\n" diff --git a/target_typescript.cr b/target_typescript.cr index 203ae29..66f6621 100644 --- a/target_typescript.cr +++ b/target_typescript.cr @@ -25,10 +25,14 @@ abstract class TypeScriptTarget < Target native_type(t.base) + "[]" end - def native_type(t : AST::StructType | AST::EnumType | AST::TypeReference) + def native_type(t : AST::StructType | AST::EnumType) t.name end + def native_type(ref : AST::TypeReference) + native_type ref.type + end + def generate_struct_type(t) String.build do |io| io << "export interface #{t.name} {\n" From 0c61fb27192ed97dd14e23b9016a3215ebc42a26 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 31 Mar 2017 09:30:41 -0300 Subject: [PATCH 053/625] Send more device info from Android --- target_java_android.cr | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index f718611..459bb13 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -237,15 +237,28 @@ END private static JSONObject device() throws JSONException { JSONObject device = new JSONObject(); - device.put("platform", "android"); + device.put("type", "android"); device.put("fingerprint", "" + Secure.getString(context().getContentResolver(), Secure.ANDROID_ID)); - device.put("platformVersion", "Android " + Build.VERSION.RELEASE + "(API " + Build.VERSION.SDK_INT + ") on " + Build.BRAND + " " + Build.MODEL); + device.put("platform", new JSONObject() {{ + put("version", Build.VERSION.RELEASE); + put("sdkVersion", Build.VERSION.SDK_INT); + put("brand", Build.BRAND); + put("model", Build.MODEL); + }}); try { device.put("version", context().getPackageManager().getPackageInfo(context().getPackageName(), 0).versionName); } catch (PackageManager.NameNotFoundException e) { device.put("version", "unknown"); } device.put("language", language()); + device.put("screen", new JSONObject() {{ + WindowManager manager = (WindowManager) context().getSystemService(Context.WINDOW_SERVICE); + Display display = manager.getDefaultDisplay(); + Point size = new Point(); + display.getSize(size); + put("width", size.x); + put("height", size.y); + }}); SharedPreferences pref = context().getSharedPreferences("api", Context.MODE_PRIVATE); if (pref.contains("deviceId")) device.put("id", pref.getString("deviceId", null)); From d56960bee58224da2bceb9d2bb90cc2a41ea0061 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 31 Mar 2017 09:31:01 -0300 Subject: [PATCH 054/625] move device and apicalls tables into rethinkdb typing --- rethinkdb/rethinkdb.d.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index ff02417..fada76d 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -1,4 +1,28 @@ +interface DBDevice { + id: string; + type: "android" | "ios" | "web"; + platform: any; + screen: {width: number, height: number}; + version: string; + language: string; +} + +interface DBApiCall { + id: string; + name: string; + args: object; + executionId: string; + running: boolean; + device: DBDevice; + date: Date; + duration: number; + host: string; + ok: boolean; + result: any; + error: {type: string, message: string} | null; +} + interface Sorting {} interface R extends RDB { @@ -23,6 +47,8 @@ interface R extends RDB { interface RDB { table(name: string): RTable + table(name: "devices"): RTable; + table(name: "api_calls"): RTable; tableList(): RArray tableDrop(name: string): RDatum<{tables_dropped: 1, config_changes: {old_val: R_TableConfig, new_val: null}}> tableCreate(name: string, opts?: R_TableCreateOptions): RDatum<{tables_created: 1, config_changes: {old_val: null, new_val: R_TableConfig}}> @@ -86,6 +112,9 @@ interface RDatum extends RStreamOrDatum, PromiseLike { not(): RDatum and(...objs: any[]): RDatum or(...objs: any[]): RDatum + + coerceTo(type: "array"): RArray + coerceTo(type: "string"): RDatum } interface RArray extends RDatum { From 535f21cf5892ea47cfeb3c8215dceb28d3e9a9b8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 31 Mar 2017 09:34:41 -0300 Subject: [PATCH 055/625] Create db if not exists --- rethinkdb/index.ts | 6 ++++++ rethinkdb/rethinkdb.d.ts | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/rethinkdb/index.ts b/rethinkdb/index.ts index 4ad9677..fc80d4d 100644 --- a/rethinkdb/index.ts +++ b/rethinkdb/index.ts @@ -1,7 +1,9 @@ let r: R; +let dbName: string; export function connect(db: string, host: string = "rethinkdb") { + dbName = db; r = require("rethinkdbdash")({ db: db, pingInterval: 20, @@ -23,6 +25,10 @@ export interface ConfigureOptions { } export async function configure(options: ConfigureOptions) { + if (await r.not(r.dbList().contains(dbName))) { + await r.dbCreate(dbName); + } + const tables = Object.keys(options.tables); const realTables = await r.tableList(); diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index fada76d..4a2974c 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -27,6 +27,8 @@ interface Sorting {} interface R extends RDB { db(name: string): RDB + dbList(): RArray + dbCreate(name: string): RDatum<{}> expr(obj: any): RDatum uuid(): RDatum range(): RStream @@ -101,6 +103,7 @@ interface RDatum extends RStreamOrDatum, PromiseLike { filter(obj: any): RDatum filter(criteria: (obj: any) => boolean | RDatum): RDatum + contains(obj: any): RDatum eq(other: any): RDatum ne(other: any): RDatum @@ -125,6 +128,7 @@ interface RArray extends RDatum { filter(obj: DeepPartial>): RArray filter(criteria: (obj: RDatum) => boolean | RDatum): RArray limit(other: any): RArray + contains(obj: T): RDatum } interface RStream extends PromiseLike, RStreamOrDatum { From 0136ef70b5ab9d882b28e9de8b7ae158bd9cc7fa Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 31 Mar 2017 14:59:57 -0300 Subject: [PATCH 056/625] Several better rethinkdb typings --- rethinkdb/rethinkdb.d.ts | 104 ++++++++++++++++++++++++++++++++------- 1 file changed, 86 insertions(+), 18 deletions(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 4a2974c..067ad2d 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -23,7 +23,7 @@ interface DBApiCall { error: {type: string, message: string} | null; } -interface Sorting {} +interface R_Sorting {} interface R extends RDB { db(name: string): RDB @@ -43,8 +43,13 @@ interface R extends RDB { and(...objs: any[]): RDatum or(...objs: any[]): RDatum now(): RDatum - asc(name: string): Sorting - desc(name: string): Sorting + asc(name: string): R_Sorting + desc(name: string): R_Sorting + args(array: any): any + row: RTableRow + minval: RDatum + maxval: RDatum + error(message: string): RDatum } interface RDB { @@ -80,10 +85,7 @@ interface R_TableCreateOptions { interface RStreamOrDatum { count(): RDatum - avg(): RDatum - min(): RDatum - max(): RDatum - orderBy(field: string | Sorting): RArray + orderBy(field: string | R_Sorting): RArray } interface RDatum extends RStreamOrDatum, PromiseLike { @@ -96,13 +98,14 @@ interface RDatum extends RStreamOrDatum, PromiseLike { merge(op: (e: RDatum) => any): RDatum merge(op: any): RDatum map(func: (e: RDatum) => any): RArray + concatMap(func: (e: RDatum) => any): RArray sub(other: any): RDatum add(...others: any[]): RDatum append(other: any): RDatum limit(other: any): RDatum - filter(obj: any): RDatum filter(criteria: (obj: any) => boolean | RDatum): RDatum + filter(obj: any): RDatum contains(obj: any): RDatum eq(other: any): RDatum @@ -116,30 +119,90 @@ interface RDatum extends RStreamOrDatum, PromiseLike { and(...objs: any[]): RDatum or(...objs: any[]): RDatum + split(by: string): RArray coerceTo(type: "array"): RArray coerceTo(type: "string"): RDatum + + setInsert(other: any): RArray + setUnion(other: any): RArray + setIntersection(other: any): RArray + setDifference(other: any): RArray + append(value: any): RArray + prepend(value: any): RArray + difference(other: any): RArray + + sum(): RDatum + sum(idx: string): RDatum + avg(): RDatum + avg(idx: string): RDatum + min(): RDatum + min(idx: string): RDatum + max(): RDatum + max(idx: string): RDatum + + ungroup(): RArray<{group: any, reduction: any}> } interface RArray extends RDatum { (idx: number | RDatum): RDatum + (idx: K): RArray map(func: (e: RDatum) => any): RArray - orderBy(field: string | Sorting): RArray + concatMap(func: (e: RDatum) => any): RArray + orderBy(field: string | R_Sorting): RArray append(other: T): RArray - filter(obj: DeepPartial>): RArray filter(criteria: (obj: RDatum) => boolean | RDatum): RArray + filter(obj: DeepPartial>): RArray limit(other: any): RArray contains(obj: T): RDatum + reduce(func: (a: RDatum, b: RDatum) => any): RDatum + + setInsert(other: any): RArray + setUnion(other: any): RArray + setIntersection(other: any): RArray + setDifference(other: any): RArray + append(value: any): RArray + prepend(value: any): RArray + difference(other: any): RArray + + sum(): RDatum + sum(idx: K): RDatum + avg(): RDatum + avg(idx: K): RDatum + min(): RDatum + min(idx: K): RDatum + max(): RDatum + max(idx: K): RDatum + + group(idx: K): RGroupedStream } interface RStream extends PromiseLike, RStreamOrDatum { (idx: number): RDatum + (field: string): RArray map(func: (arg: RDatum) => any): RStream - orderBy(field: string | Sorting): RArray - orderBy(options: {index: string | Sorting}): RStream + concatMap(func: (arg: RDatum) => any): RStream + orderBy(field: string | R_Sorting): RArray + orderBy(options: {index: string | R_Sorting}): RStream coerceTo(type: "array"): RArray - filter(obj: DeepPartial>): RStream filter(criteria: (obj: RDatum) => boolean | RDatum): RStream + filter(obj: DeepPartial>): RStream limit(other: any): RStream + reduce(func: (a: RDatum, b: RDatum) => any): RDatum + + sum(): RDatum + sum(idx: K): RDatum + avg(): RDatum + avg(idx: K): RDatum + min(): RDatum + min(idx: K): RDatum + max(): RDatum + max(idx: K): RDatum + + group(idx: K): RGroupedStream +} + +interface RGroupedStream extends RArray { + ungroup(): RArray<{group: G, reduction: T[]}> } interface R_UpdateOptions { @@ -158,15 +221,19 @@ interface R_UpdateResult { inserted: 0 } -type RUpdateObj = DeepPartial | RDatum | ((obj: RDatum) => any) +type RUpdateObj = RDatum | DeepPartial interface RTableSlice extends RStream { + update(obj: (obj: RDatum) => any, options: Opts): RDatum + update(obj: (obj: RDatum) => any, options?: R_UpdateOptions): RDatum update(obj: RUpdateObj, options: Opts): RDatum update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum delete(): RDatum<{}> } interface RTableRow extends RDatum { + update(obj: (obj: RDatum) => any, options: Opts): RDatum + update(obj: (obj: RDatum) => any, options?: R_UpdateOptions): RDatum update(obj: RUpdateObj, options: Opts): RDatum update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum delete(): RDatum<{}> @@ -214,8 +281,9 @@ interface RTable extends RTableSlice { indexDrop(name: string): RDatum<{dropped: 1}> indexStatus(...names: string[]): RArray - getAll(id: any, opts: {index: string}): RTableSlice - getAll(id1: any, id2: any, opts: {index: string}): RTableSlice - getAll(id1: any, id2: any, id3: any, opts: {index: string}): RTableSlice - getAll(id1: any, id2: any, id3: any, id4: any, opts: {index: string}): RTableSlice + getAll(id: any, opts?: {index: string}): RTableSlice + getAll(id1: any, id2: any, opts?: {index: string}): RTableSlice + getAll(id1: any, id2: any, id3: any, opts?: {index: string}): RTableSlice + getAll(id1: any, id2: any, id3: any, id4: any, opts?: {index: string}): RTableSlice + between(lower: any, upper: any, opts?: {index: string}): RTableSlice } From 1938b221484da0917600a10ba65119fb883bab0d Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 31 Mar 2017 15:18:04 -0300 Subject: [PATCH 057/625] collect more info from web --- target_typescript_web.cr | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index a4d820b..da97f9f 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -49,8 +49,17 @@ function device() { const agent = parser.getResult(); const me = document.currentScript as HTMLScriptElement; const device: any = { - platform: "web", - platformVersion: `${agent.browser.name} ${agent.browser.version} on ${agent.os.name} ${agent.os.version}`, + type: "web", + platform: { + browser: agent.browser.name, + browserVersion: agent.browser.version, + os: agent.os.name, + osVersion: agent.os.version + }, + screen: { + width: screen.width, + height: screen.height + }, version: me ? me.src : "", language: navigator.language }; @@ -89,7 +98,7 @@ async function makeRequest({name, args}: {name: string, args: any}) { } } catch (e) { console.error(e); - reject({type: "ServerError", message: e.toString()}); + reject({type: "Fatal", message: e.toString()}); } }; req.send(JSON.stringify(body)); From dbc1ab65ed45cd15ca5c9c878e2bda25a706302b Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 31 Mar 2017 15:18:11 -0300 Subject: [PATCH 058/625] Add base fatal error --- ast_semantic.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/ast_semantic.cr b/ast_semantic.cr index 147f5f3..1f03851 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -119,6 +119,7 @@ module AST property enum_types = [] of AST::EnumType def semantic + errors << "Fatal" error_types_enum = AST::EnumType.new error_types_enum.values = errors error_types_enum_def = AST::TypeDefinition.new From dbabd2292c9b99f2e58ee5e08eba2ed16cbd8688 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 2 Apr 2017 17:19:53 -0300 Subject: [PATCH 059/625] Improved logging --- ast_semantic.cr | 29 +++++++++++++++- rethinkdb/rethinkdb.d.ts | 2 +- target_java_android.cr | 2 +- target_swift_ios.cr | 2 +- target_typescript_server.cr | 66 +++++++++++++++++++++++++++++++++++-- 5 files changed, 94 insertions(+), 7 deletions(-) diff --git a/ast_semantic.cr b/ast_semantic.cr index 1f03851..e0229d6 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -68,13 +68,39 @@ module Semantic def visit(ref : AST::TypeReference) if ref.type == @root_type - raise "Detected type recursion: #{@path.join(" -> ")}" + raise "Detected type recursion: #{@path.join(".")}" end visit ref.type super end end + class CheckDontReturnSecret < Visitor + @inreturn = false + @path = [] of String + + def visit(op : AST::Operation) + @inreturn = true + @path.push op.name + "()" + visit op.return_type + @path.pop + @inreturn = false + end + + def visit(ref : AST::TypeReference) + visit ref.type + end + + def visit(field : AST::Field) + @path.push field.name + if @inreturn && field.secret + raise "Can't return a secret value at #{@path.join(".")}" + end + super + @path.pop + end + end + class GiveStructAndEnumTypeNames < Visitor @path = [] of String @@ -129,6 +155,7 @@ module AST Semantic::CheckEveryTypeDefined.new(self).visit(self) Semantic::CheckNoRecursiveTypes.new(self).visit(self) + Semantic::CheckDontReturnSecret.new(self).visit(self) Semantic::GiveStructAndEnumTypeNames.new(self).visit(self) Semantic::CollectStructAndEnumTypes.new(self).visit(self) end diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 067ad2d..0940a1c 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -11,7 +11,7 @@ interface DBDevice { interface DBApiCall { id: string; name: string; - args: object; + args: any; executionId: string; running: boolean; device: DBDevice; diff --git a/target_java_android.cr b/target_java_android.cr index 459bb13..5273766 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -282,7 +282,7 @@ END JSONObject body = new JSONObject(); try { - body.put("id", randomBytesHex(16)); + body.put("id", randomBytesHex(8)); body.put("device", device()); body.put("name", name); body.put("args", args); diff --git a/target_swift_ios.cr b/target_swift_ios.cr index ed39a20..2e6ebf0 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -170,7 +170,7 @@ class APIInternal { let api = SessionManager.default let body = [ - "id": randomBytesHex(len: 16), + "id": randomBytesHex(len: 8), "device": device(), "name": name, "args": args diff --git a/target_typescript_server.cr b/target_typescript_server.cr index bc6f11c..dd86d03 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -46,6 +46,18 @@ END end @io << "};\n\n" + @io << "const clearForLogging: {[name: string]: (call: DBApiCall) => void} = {\n" + @ast.operations.each do |op| + cmds_args = String.build {|io| emit_clear_for_logging(io, op, "call.args") } + + if cmds_args != "" + @io << " " << op.pretty_name << ": async (call: DBApiCall) => {\n" + @io << ident ident cmds_args + @io << " },\n" + end + end + @io << "};\n\n" + @io << "export const err = {\n" @ast.errors.each do |error| @io << " #{error}: (message: string = \"\") => { throw {type: #{error.inspect}, message}; },\n" @@ -102,7 +114,7 @@ export function start(port: number) { const {id, ...deviceInfo} = context.device; if (!context.device.id) { - context.device.id = crypto.randomBytes(32).toString("hex"); + context.device.id = crypto.randomBytes(20).toString("hex"); r.table("devices").insert({ id: context.device.id, @@ -113,10 +125,10 @@ export function start(port: number) { r.table("devices").get(context.device.id).update(deviceInfo).then(); } - const executionId = crypto.randomBytes(32).toString("hex"); + const executionId = crypto.randomBytes(20).toString("hex"); let call: DBApiCall = { - id: `${context.device.id}_${request.id}`, + id: `${request.id}@${context.device.id}`, name: request.name, args: request.args, executionId: executionId, @@ -130,6 +142,9 @@ export function start(port: number) { error: null as {type: string, message: string}|null }; + if (clearForLogging[name]) + clearForLogging[name](call); + async function tryLock(): Promise { const priorCall = await r.table("api_calls").get(call.id); if (priorCall === null) { @@ -203,6 +218,14 @@ export function start(port: number) { res.end(); await r.table("api_calls").get(call.id).update(call); + + let log = `${call.id} [${call.duration.toFixed(6)}s] #{call.name}() -> `; + if (call.ok) + log += "OK" + else + log += call.error.type + + console.log(log) })().catch(err => { console.error(err); res.writeHead(500); @@ -240,6 +263,43 @@ END "(#{args.join(", ")})" end + + @i = 0 + def emit_clear_for_logging(io : IO, t : AST::Type | AST::Operation | AST::Field, path : String) + case t + when AST::Operation + t.args.each do |field| + emit_clear_for_logging(io, field, "#{path}.#{field.name}") + end + when AST::StructType + t.fields.each do |field| + emit_clear_for_logging(io, field, "#{path}.#{field.name}") + end + when AST::Field + if t.secret + io << "#{path} = \"\";\n" + else + emit_clear_for_logging(io, t.type, path) + end + when AST::TypeReference + emit_clear_for_logging(io, t.type, path) + when AST::OptionalType + cmd = String.build {|io| emit_clear_for_logging(io, t.base, path) } + if cmd != "" + io << "if (#{path}) {\n" << ident(cmd) << "}\n" + end + when AST::ArrayType + var = ('i' + @i).to_s + @i += 1 + cmd = String.build {|io| emit_clear_for_logging(io, t.base, "#{path}[#{var}]") } + @i -= 1 + if cmd != "" + io << "for (let #{var} = 0; #{var} < #{path}.length; ++#{var}) {\n" << ident(cmd) << "}\n" + end + when AST::BytesPrimitiveType + io << "#{path} = `<${#{path}.length} bytes>`;\n" + end + end end Target.register(TypeScriptServerTarget, language: "ts", is_server: true) From f0dfba59eec19694bf5aa6144e1b4a52d0bed43a Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 2 Apr 2017 17:21:18 -0300 Subject: [PATCH 060/625] fix interpolation --- target_typescript_server.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_server.cr b/target_typescript_server.cr index dd86d03..ccde253 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -219,7 +219,7 @@ export function start(port: number) { await r.table("api_calls").get(call.id).update(call); - let log = `${call.id} [${call.duration.toFixed(6)}s] #{call.name}() -> `; + let log = `${call.id} [${call.duration.toFixed(6)}s] ${call.name}() -> `; if (call.ok) log += "OK" else From 0a5f0ab789b541d4e74ea66337eb6c176a0323c6 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 2 Apr 2017 17:25:07 -0300 Subject: [PATCH 061/625] Fix android target --- target_java_android.cr | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 5273766..ffc65be 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -4,16 +4,20 @@ class JavaAndroidTarget < JavaTarget def gen @io << <<-END +import android.annotation.SuppressLint; import android.app.Application; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageManager; +import android.graphics.Point; import android.os.Build; import android.os.Handler; import android.os.Looper; import android.provider.Settings; import android.util.Base64; import android.util.Log; +import android.view.Display; +import android.view.WindowManager; import com.facebook.stetho.Stetho; import com.facebook.stetho.okhttp3.StethoInterceptor; @@ -235,10 +239,11 @@ END return bcp47Tag.toString(); } + @SuppressLint("HardwareIds") private static JSONObject device() throws JSONException { JSONObject device = new JSONObject(); device.put("type", "android"); - device.put("fingerprint", "" + Secure.getString(context().getContentResolver(), Secure.ANDROID_ID)); + device.put("fingerprint", "" + Settings.Secure.getString(context().getContentResolver(), Settings.Secure.ANDROID_ID)); device.put("platform", new JSONObject() {{ put("version", Build.VERSION.RELEASE); put("sdkVersion", Build.VERSION.SDK_INT); From 9f42aaa077b1c24c143c277eb7bfe748e39c63dd Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 2 Apr 2017 17:28:26 -0300 Subject: [PATCH 062/625] name -> call.name --- target_typescript_server.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_typescript_server.cr b/target_typescript_server.cr index ccde253..cb8468a 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -142,8 +142,8 @@ export function start(port: number) { error: null as {type: string, message: string}|null }; - if (clearForLogging[name]) - clearForLogging[name](call); + if (clearForLogging[call.name]) + clearForLogging[call.name](call); async function tryLock(): Promise { const priorCall = await r.table("api_calls").get(call.id); From 6f4df4693f69a8796b90dbf7ab061b9cfc2704bf Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 2 Apr 2017 17:29:38 -0300 Subject: [PATCH 063/625] Fix log on error --- target_typescript_server.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_server.cr b/target_typescript_server.cr index cb8468a..f875656 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -223,7 +223,7 @@ export function start(port: number) { if (call.ok) log += "OK" else - log += call.error.type + log += call.error ? call.error.type : "???" console.log(log) })().catch(err => { From c6e027efbe99a6cf0d6cf0df253a6fb9f1c0ce14 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 2 Apr 2017 17:41:55 -0300 Subject: [PATCH 064/625] cleanup logging --- target_typescript_server.cr | 221 +++++++++++++++++------------------- 1 file changed, 105 insertions(+), 116 deletions(-) diff --git a/target_typescript_server.cr b/target_typescript_server.cr index f875656..de03a47 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -102,7 +102,7 @@ export function start(port: number) { let data = ""; req.on("data", chunk => data += chunk.toString()); req.on("end", () => { - try { + (async () => { const request = JSON.parse(data); const context: Context = { device: request.device, @@ -110,137 +110,126 @@ export function start(port: number) { }; const startTime = process.hrtime(); - (async () => { - const {id, ...deviceInfo} = context.device; + const {id, ...deviceInfo} = context.device; + + if (!context.device.id) { + context.device.id = crypto.randomBytes(20).toString("hex"); + + r.table("devices").insert({ + id: context.device.id, + date: r.now(), + ...deviceInfo + }).then(); + } else { + r.table("devices").get(context.device.id).update(deviceInfo).then(); + } + + const executionId = crypto.randomBytes(20).toString("hex"); + + let call: DBApiCall = { + id: `${request.id}-${context.device.id}`, + name: request.name, + args: request.args, + executionId: executionId, + running: true, + device: context.device, + date: context.startTime, + duration: 0, + host: os.hostname(), + ok: true, + result: null as any, + error: null as {type: string, message: string}|null + }; - if (!context.device.id) { - context.device.id = crypto.randomBytes(20).toString("hex"); + if (clearForLogging[call.name]) + clearForLogging[call.name](call); - r.table("devices").insert({ - id: context.device.id, - date: r.now(), - ...deviceInfo - }).then(); - } else { - r.table("devices").get(context.device.id).update(deviceInfo).then(); + async function tryLock(): Promise { + const priorCall = await r.table("api_calls").get(call.id); + if (priorCall === null) { + const res = await r.table("api_calls").insert(call); + return res.inserted > 0 ? true : await tryLock(); } - - const executionId = crypto.randomBytes(20).toString("hex"); - - let call: DBApiCall = { - id: `${request.id}@${context.device.id}`, - name: request.name, - args: request.args, - executionId: executionId, - running: true, - device: context.device, - date: context.startTime, - duration: 0, - host: os.hostname(), - ok: true, - result: null as any, - error: null as {type: string, message: string}|null - }; - - if (clearForLogging[call.name]) - clearForLogging[call.name](call); - - async function tryLock(): Promise { - const priorCall = await r.table("api_calls").get(call.id); - if (priorCall === null) { - const res = await r.table("api_calls").insert(call); - return res.inserted > 0 ? true : await tryLock(); - } - if (!priorCall.running) { - call = priorCall; - return true; - } - if (priorCall.executionId === executionId) { - return true; - } - return false; + if (!priorCall.running) { + call = priorCall; + return true; } - - for (let i = 0; i < 30; ++i) { - if (tryLock()) break; - await sleep(100); + if (priorCall.executionId === executionId) { + return true; } - - if (call.running) { - if (call.executionId !== executionId) { + return false; + } + + for (let i = 0; i < 30; ++i) { + if (tryLock()) break; + await sleep(100); + } + + if (call.running) { + if (call.executionId !== executionId) { + call.ok = false; + call.error = { + type: "CallExecutionTimeout", + message: "Timeout while waiting for execution somewhere else" + }; + } else { + try { + call.result = await fnExec[call.name](context, call.args); + } catch (err) { call.ok = false; - call.error = { - type: "CallExecutionTimeout", - message: "Timeout while waiting for execution somewhere else" - }; - } else { - try { - call.result = await fnExec[call.name](context, call.args); - } catch (err) { - call.ok = false; - if (err.type) { - call.error = { - type: err.type, - message: err.message - }; - } else { - call.error = { - type: "bug", - message: err.toString() - }; - } + if (err.type) { + call.error = { + type: err.type, + message: err.message + }; + } else { + call.error = { + type: "bug", + message: err.toString() + }; } } } + } + + const deltaTime = process.hrtime(startTime); + call.duration = deltaTime[0] + deltaTime[1] * 1e-9; + + const response = { + id: call.id, + ok: call.ok, + executed: call.executionId === executionId, + deviceId: call.device.id, + startTime: call.date, + duration: call.duration, + host: call.host, + result: call.result, + error: call.error + }; + + res.writeHead(200); + res.write(JSON.stringify(response)); + res.end(); + + await r.table("api_calls").get(call.id).update(call); + + let log = `${moment().format("YYYY-MM-DD HH:mm:ss")} ${call.id} [${call.duration.toFixed(6)}s] ${call.name}() -> `; + if (call.ok) + log += "OK" + else + log += call.error ? call.error.type : "???" - const deltaTime = process.hrtime(startTime); - call.duration = deltaTime[0] + deltaTime[1] * 1e-9; - - const response = { - id: call.id, - ok: call.ok, - executed: call.executionId === executionId, - deviceId: call.device.id, - startTime: call.date, - duration: call.duration, - host: call.host, - result: call.result, - error: call.error - }; - - console.log({ - request, - response - }); - - res.writeHead(200); - res.write(JSON.stringify(response)); - res.end(); - - await r.table("api_calls").get(call.id).update(call); - - let log = `${call.id} [${call.duration.toFixed(6)}s] ${call.name}() -> `; - if (call.ok) - log += "OK" - else - log += call.error ? call.error.type : "???" - - console.log(log) - })().catch(err => { - console.error(err); - res.writeHead(500); - res.end(); - }); - } catch (err) { + console.log(log) + })().catch(err => { console.error(err); - res.writeHead(400); + res.writeHead(500); res.end(); - } + }); }); break; } default: { - res.writeHead(400); + res.writeHead(500); res.end(); } } From bbb2c0c0b29c8ec5173487564170159f20fd16f6 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 3 Apr 2017 18:47:31 -0300 Subject: [PATCH 065/625] Fix secret arguments --- target_typescript_server.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_typescript_server.cr b/target_typescript_server.cr index de03a47..6f2ddab 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -129,7 +129,7 @@ export function start(port: number) { let call: DBApiCall = { id: `${request.id}-${context.device.id}`, name: request.name, - args: request.args, + args: JSON.parse(JSON.stringify(request.args)), executionId: executionId, running: true, device: context.device, @@ -174,7 +174,7 @@ export function start(port: number) { }; } else { try { - call.result = await fnExec[call.name](context, call.args); + call.result = await fnExec[request.name](context, request.args); } catch (err) { call.ok = false; if (err.type) { From b5a85de8a70e17979f06b0a029e2368c3512004d Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 3 Apr 2017 18:47:44 -0300 Subject: [PATCH 066/625] Allow any identifier for enum --- parser.cr | 3 --- 1 file changed, 3 deletions(-) diff --git a/parser.cr b/parser.cr index 069b3b3..1aa1abf 100644 --- a/parser.cr +++ b/parser.cr @@ -105,9 +105,6 @@ class Parser while true case token = multi_expect(IdentifierToken, CurlyCloseSymbolToken) when IdentifierToken - unless token.name[0].lowercase? - raise ParserException.new "The enum value must start with an lowercase letter, but found '#{token.name}' at #{token.location}" - end e.values << token.name next_token when CurlyCloseSymbolToken From c2ede448b884bb3c02904c26080dc64e0d3407e5 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 3 Apr 2017 18:48:01 -0300 Subject: [PATCH 067/625] fix ts error for array argument --- target_typescript.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript.cr b/target_typescript.cr index 66f6621..4591bbe 100644 --- a/target_typescript.cr +++ b/target_typescript.cr @@ -83,7 +83,7 @@ abstract class TypeScriptTarget < Target when AST::OptionalType "#{src} === null || #{src} === undefined ? null : #{type_from_json(t.base, src)}" when AST::ArrayType - t.base.is_a?(AST::TypeReference) ? "#{src}.map(e => (#{type_from_json(t.base, "e")}))" : "#{src}.map(e => #{type_from_json(t.base, "e")})" + t.base.is_a?(AST::TypeReference) ? "#{src}.map((e: any) => (#{type_from_json(t.base, "e")}))" : "#{src}.map((e: any) => #{type_from_json(t.base, "e")})" when AST::StructType String::Builder.build do |io| io << "{\n" From af0064351b4466dc9157a70137b5be845c401bab Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 4 Apr 2017 15:05:09 -0300 Subject: [PATCH 068/625] Fix parser for inner struct --- parser.cr | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/parser.cr b/parser.cr index 1aa1abf..e111fa5 100644 --- a/parser.cr +++ b/parser.cr @@ -230,18 +230,19 @@ class Parser end def parse_type(allow_void = true) - result = case token = multi_expect(CurlyOpenSymbolToken, EnumKeywordToken, PrimitiveTypeToken, IdentifierToken) + case token = multi_expect(CurlyOpenSymbolToken, EnumKeywordToken, PrimitiveTypeToken, IdentifierToken) when CurlyOpenSymbolToken - return parse_struct + result = parse_struct when EnumKeywordToken - return parse_enum + result = parse_enum when IdentifierToken unless token.name[0].uppercase? raise ParserException.new "Expected a type but found '#{token.name}', at #{token.location}" end - AST::TypeReference.new(token.name) + result = AST::TypeReference.new(token.name) + next_token when PrimitiveTypeToken - case token.name + result = case token.name when "string"; AST::StringPrimitiveType.new when "int"; AST::IntPrimitiveType.new when "uint"; AST::UIntPrimitiveType.new @@ -259,21 +260,19 @@ class Parser else raise "BUG! Should handle primitive #{token.name}" end + next_token else raise "never" end - next_token while @token.is_a? ArraySymbolToken || @token.is_a? OptionalSymbolToken - if @token.is_a? ArraySymbolToken - next_token + case @token + when ArraySymbolToken result = AST::ArrayType.new(result) - end - - if @token.is_a?(OptionalSymbolToken) - next_token + when OptionalSymbolToken result = AST::OptionalType.new(result) end + next_token end result From c654175175ad8a6379187d5af3106ab7504d95e4 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 4 Apr 2017 15:14:58 -0300 Subject: [PATCH 069/625] rethink typing --- rethinkdb/rethinkdb.d.ts | 47 ++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 0940a1c..fb0aefc 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -23,7 +23,7 @@ interface DBApiCall { error: {type: string, message: string} | null; } -interface R_Sorting {} +interface R_Sorting { __dummy: string } interface R extends RDB { db(name: string): RDB @@ -43,13 +43,17 @@ interface R extends RDB { and(...objs: any[]): RDatum or(...objs: any[]): RDatum now(): RDatum - asc(name: string): R_Sorting - desc(name: string): R_Sorting + asc(name: T): R_Sorting + desc(name: T): R_Sorting args(array: any): any row: RTableRow minval: RDatum maxval: RDatum error(message: string): RDatum + union(stream1: RStream, stream2: RStream): RStream + union(stream1: RStream, stream2: RStream, stream3: RStream): RStream + union(...streams: any[]): RArray + js(code: string): RDatum } interface RDB { @@ -85,7 +89,6 @@ interface R_TableCreateOptions { interface RStreamOrDatum { count(): RDatum - orderBy(field: string | R_Sorting): RArray } interface RDatum extends RStreamOrDatum, PromiseLike { @@ -95,25 +98,31 @@ interface RDatum extends RStreamOrDatum, PromiseLike { default(val: any): RDatum (idx: K): RDatum (idx: number | RDatum): RDatum + orderBy(field: string | R_Sorting): RArray merge(op: (e: RDatum) => any): RDatum merge(op: any): RDatum map(func: (e: RDatum) => any): RArray concatMap(func: (e: RDatum) => any): RArray sub(other: any): RDatum + div(other: any): RDatum add(...others: any[]): RDatum + mul(...others: any[]): RDatum append(other: any): RDatum limit(other: any): RDatum + round(): RDatum + floor(): RDatum + ceil(): RDatum filter(criteria: (obj: any) => boolean | RDatum): RDatum filter(obj: any): RDatum contains(obj: any): RDatum - eq(other: any): RDatum - ne(other: any): RDatum - gt(other: any): RDatum - lt(other: any): RDatum - ge(other: any): RDatum - le(other: any): RDatum + eq(other: T | RDatum): RDatum + ne(other: T | RDatum): RDatum + gt(other: T | RDatum): RDatum + lt(other: T | RDatum): RDatum + ge(other: T | RDatum): RDatum + le(other: T | RDatum): RDatum not(): RDatum and(...objs: any[]): RDatum @@ -140,7 +149,9 @@ interface RDatum extends RStreamOrDatum, PromiseLike { max(): RDatum max(idx: string): RDatum + group(idx: K): RGroupedStream ungroup(): RArray<{group: any, reduction: any}> + forEach(func: (e: RDatum) => any): RDatum<{}> } interface RArray extends RDatum { @@ -148,13 +159,14 @@ interface RArray extends RDatum { (idx: K): RArray map(func: (e: RDatum) => any): RArray concatMap(func: (e: RDatum) => any): RArray - orderBy(field: string | R_Sorting): RArray + orderBy(field: K | R_Sorting): RArray append(other: T): RArray filter(criteria: (obj: RDatum) => boolean | RDatum): RArray filter(obj: DeepPartial>): RArray limit(other: any): RArray contains(obj: T): RDatum reduce(func: (a: RDatum, b: RDatum) => any): RDatum + distinct(): RArray setInsert(other: any): RArray setUnion(other: any): RArray @@ -174,6 +186,7 @@ interface RArray extends RDatum { max(idx: K): RDatum group(idx: K): RGroupedStream + forEach(func: (e: RDatum) => any): RDatum<{}> } interface RStream extends PromiseLike, RStreamOrDatum { @@ -181,13 +194,14 @@ interface RStream extends PromiseLike, RStreamOrDatum { (field: string): RArray map(func: (arg: RDatum) => any): RStream concatMap(func: (arg: RDatum) => any): RStream - orderBy(field: string | R_Sorting): RArray - orderBy(options: {index: string | R_Sorting}): RStream + orderBy(field: keyof T | R_Sorting): RArray + orderBy(options: {index: string | R_Sorting}): RStream coerceTo(type: "array"): RArray filter(criteria: (obj: RDatum) => boolean | RDatum): RStream filter(obj: DeepPartial>): RStream limit(other: any): RStream reduce(func: (a: RDatum, b: RDatum) => any): RDatum + distinct(): RArray sum(): RDatum sum(idx: K): RDatum @@ -199,6 +213,7 @@ interface RStream extends PromiseLike, RStreamOrDatum { max(idx: K): RDatum group(idx: K): RGroupedStream + forEach(func: (e: RDatum) => any): RDatum<{}> } interface RGroupedStream extends RArray { @@ -268,7 +283,7 @@ interface R_IndexStatus { query: string } -type RInsertObj = RDatumfy | RDatum | RStream | RDatum | RDatumfy[] | (() => RInsertObj) +type RInsertObj = RDatum | RStream | RDatum | RDatumfy[] | (() => RInsertObj) | RDatumfy interface RTable extends RTableSlice { get(id: any): RTableRow @@ -277,7 +292,7 @@ interface RTable extends RTableSlice { indexList(): RArray indexCreate(name: string, func: (obj: RDatum) => any, opts?: {multi?: boolean, geo?: boolean}): RDatum<{created: 1}> - indexCreate(name: K, opts?: {multi?: boolean, geo?: boolean}): RDatum<{created: 1}> + indexCreate(name: keyof T, opts?: {multi?: boolean, geo?: boolean}): RDatum<{created: 1}> indexDrop(name: string): RDatum<{dropped: 1}> indexStatus(...names: string[]): RArray @@ -285,5 +300,5 @@ interface RTable extends RTableSlice { getAll(id1: any, id2: any, opts?: {index: string}): RTableSlice getAll(id1: any, id2: any, id3: any, opts?: {index: string}): RTableSlice getAll(id1: any, id2: any, id3: any, id4: any, opts?: {index: string}): RTableSlice - between(lower: any, upper: any, opts?: {index: string}): RTableSlice + between(lower: any, upper: any, opts?: {index: string, leftBound?: "closed" | "opened", rightBound?: "closed" | "opened"}): RTableSlice } From 699dd5d533c823bfc3a8b48b1757e7cc33e84049 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 4 Apr 2017 15:37:26 -0300 Subject: [PATCH 070/625] Fix array to/from json --- target_typescript.cr | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target_typescript.cr b/target_typescript.cr index 4591bbe..20e26df 100644 --- a/target_typescript.cr +++ b/target_typescript.cr @@ -83,7 +83,8 @@ abstract class TypeScriptTarget < Target when AST::OptionalType "#{src} === null || #{src} === undefined ? null : #{type_from_json(t.base, src)}" when AST::ArrayType - t.base.is_a?(AST::TypeReference) ? "#{src}.map((e: any) => (#{type_from_json(t.base, "e")}))" : "#{src}.map((e: any) => #{type_from_json(t.base, "e")})" + inner = type_from_json(t.base, "e") + inner[0] == '{' ? "#{src}.map((e: any) => (#{inner}))" : "#{src}.map((e: any) => #{inner})" when AST::StructType String::Builder.build do |io| io << "{\n" @@ -117,7 +118,8 @@ abstract class TypeScriptTarget < Target when AST::OptionalType "#{src} === null || #{src} === undefined ? null : #{type_to_json(t.base, src)}" when AST::ArrayType - t.base.is_a?(AST::TypeReference) ? "#{src}.map(e => (#{type_to_json(t.base, "e")}))" : "#{src}.map(e => #{type_to_json(t.base, "e")})" + inner = type_to_json(t.base, "e") + inner[0] == '{' ? "#{src}.map(e => (#{inner}))" : "#{src}.map(e => #{inner})" when AST::StructType String::Builder.build do |io| io << "{\n" From a294a8d76513ab61496a77efd6b7a998b434bb1d Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 4 Apr 2017 15:39:16 -0300 Subject: [PATCH 071/625] Fix rethink type --- rethinkdb/rethinkdb.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index fb0aefc..aa9f39b 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -149,7 +149,7 @@ interface RDatum extends RStreamOrDatum, PromiseLike { max(): RDatum max(idx: string): RDatum - group(idx: K): RGroupedStream + group(idx: string): RGroupedStream ungroup(): RArray<{group: any, reduction: any}> forEach(func: (e: RDatum) => any): RDatum<{}> } From 2de7472e8f50c030ba4def00f0a208db1283e984 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 5 Apr 2017 12:51:19 -0300 Subject: [PATCH 072/625] rethink typing --- rethinkdb/rethinkdb.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index aa9f39b..84e761f 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -29,7 +29,7 @@ interface R extends RDB { db(name: string): RDB dbList(): RArray dbCreate(name: string): RDatum<{}> - expr(obj: any): RDatum + expr(obj: any): RDatum uuid(): RDatum range(): RStream range(count: number): RStream @@ -102,6 +102,7 @@ interface RDatum extends RStreamOrDatum, PromiseLike { merge(op: (e: RDatum) => any): RDatum merge(op: any): RDatum map(func: (e: RDatum) => any): RArray + merge(func: (e: RDatum) => any): RArray concatMap(func: (e: RDatum) => any): RArray sub(other: any): RDatum div(other: any): RDatum @@ -158,6 +159,7 @@ interface RArray extends RDatum { (idx: number | RDatum): RDatum (idx: K): RArray map(func: (e: RDatum) => any): RArray + merge(func: (e: RDatum) => any): RArray concatMap(func: (e: RDatum) => any): RArray orderBy(field: K | R_Sorting): RArray append(other: T): RArray @@ -193,6 +195,7 @@ interface RStream extends PromiseLike, RStreamOrDatum { (idx: number): RDatum (field: string): RArray map(func: (arg: RDatum) => any): RStream + merge(func: (arg: RDatum) => any): RStream concatMap(func: (arg: RDatum) => any): RStream orderBy(field: keyof T | R_Sorting): RArray orderBy(options: {index: string | R_Sorting}): RStream From edd5e5742eaf2f366c6f667ff602851b2635633b Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 5 Apr 2017 12:54:30 -0300 Subject: [PATCH 073/625] use json content type --- target_typescript_server.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/target_typescript_server.cr b/target_typescript_server.cr index 6f2ddab..ec58a98 100644 --- a/target_typescript_server.cr +++ b/target_typescript_server.cr @@ -90,6 +90,7 @@ export function start(port: number) { res.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS"); res.setHeader("Access-Control-Allow-Headers", "Content-Type"); res.setHeader("Access-Control-Max-Age", "86400"); + res.setHeader("Content-Type", "application/json"); switch (req.method) { case "GET": { From d5de726947b6c9f896c1cf8f68a5256c9c6079ea Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 6 Apr 2017 14:52:10 -0300 Subject: [PATCH 074/625] better typing --- rethinkdb/rethinkdb.d.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 84e761f..95bbd23 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -36,9 +36,13 @@ interface R extends RDB { range(initial: number, count: number): RStream epochTime(epoch: number): RDatum add(...objs: any[]): RDatum - branch(cond1: any, case1: any, otherwise: any): RDatum - branch(cond1: any, case1: any, cond2: any, case2: any, otherwise: any): RDatum - branch(cond1: any, case1: any, cond2: any, case2: any, cond3: any, case3: any, otherwise: any): RDatum + branch(c1: any, v1: any, otherwise: any): RDatum + branch(c1: any, v1: any, c2: any, v2: any, otherwise: any): RDatum + branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, otherwise: any): RDatum + branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, c4: any, v4: any, otherwise: any): RDatum + branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, c4: any, v4: any, c5: any, v5: any, otherwise: any): RDatum + branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, c4: any, v4: any, c5: any, v5: any, c6: any, v6: any, otherwise: any): RDatum + branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, c4: any, v4: any, c5: any, v5: any, c6: any, v6: any, c7: any, v7: any, otherwise: any): RDatum not(obj: any): RDatum and(...objs: any[]): RDatum or(...objs: any[]): RDatum @@ -93,12 +97,12 @@ interface RStreamOrDatum { interface RDatum extends RStreamOrDatum, PromiseLike { do(func: (obj: this) => X): RDatum - do(func: (obj: this) => any): RDatum + do(func: (obj: this) => any): RDatum default(val: X): RDatum default(val: any): RDatum (idx: K): RDatum (idx: number | RDatum): RDatum - orderBy(field: string | R_Sorting): RArray + orderBy(field: string | R_Sorting | ((e: RDatum) => any)): RArray merge(op: (e: RDatum) => any): RDatum merge(op: any): RDatum map(func: (e: RDatum) => any): RArray @@ -161,7 +165,7 @@ interface RArray extends RDatum { map(func: (e: RDatum) => any): RArray merge(func: (e: RDatum) => any): RArray concatMap(func: (e: RDatum) => any): RArray - orderBy(field: K | R_Sorting): RArray + orderBy(field: keyof T | R_Sorting | ((e: RDatum) => any)): RArray append(other: T): RArray filter(criteria: (obj: RDatum) => boolean | RDatum): RArray filter(obj: DeepPartial>): RArray @@ -197,7 +201,7 @@ interface RStream extends PromiseLike, RStreamOrDatum { map(func: (arg: RDatum) => any): RStream merge(func: (arg: RDatum) => any): RStream concatMap(func: (arg: RDatum) => any): RStream - orderBy(field: keyof T | R_Sorting): RArray + orderBy(field: keyof T | R_Sorting | ((e: RDatum) => any)): RArray orderBy(options: {index: string | R_Sorting}): RStream coerceTo(type: "array"): RArray filter(criteria: (obj: RDatum) => boolean | RDatum): RStream @@ -247,6 +251,8 @@ interface RTableSlice extends RStream { update(obj: RUpdateObj, options: Opts): RDatum update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum delete(): RDatum<{}> + filter(criteria: (obj: RDatum) => boolean | RDatum): RTableSlice + filter(obj: DeepPartial>): RTableSlice } interface RTableRow extends RDatum { From 067755dcc9754a04dc14d9944a8bb2bc7a617236 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 6 Apr 2017 14:56:24 -0300 Subject: [PATCH 075/625] Android, fix network on main thread --- target_java_android.cr | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index ffc65be..b4e71aa 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -315,12 +315,13 @@ END @Override public void onResponse(Call call, final Response response) throws IOException { + final String body = response.body().string(); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (response.code() >= 500) { try { - Log.e("API Fatal", response.body().string()); + Log.e("API Fatal", body); } catch (IOException e) { e.printStackTrace(); } @@ -329,7 +330,7 @@ END } try { - JSONObject body = new JSONObject(response.body().string()); + JSONObject body = new JSONObject(body); SharedPreferences pref = context().getSharedPreferences("api", Context.MODE_PRIVATE); pref.edit().putString("deviceId", body.getString("deviceId")).apply(); From 834109856a49a65f21e4ede84c31134b001d0f1b Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 6 Apr 2017 15:02:24 -0300 Subject: [PATCH 076/625] Fix variable name --- target_java_android.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index b4e71aa..810452d 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -315,13 +315,13 @@ END @Override public void onResponse(Call call, final Response response) throws IOException { - final String body = response.body().string(); + final String stringBody = response.body().string(); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { if (response.code() >= 500) { try { - Log.e("API Fatal", body); + Log.e("API Fatal", stringBody); } catch (IOException e) { e.printStackTrace(); } @@ -330,7 +330,7 @@ END } try { - JSONObject body = new JSONObject(body); + JSONObject body = new JSONObject(stringBody); SharedPreferences pref = context().getSharedPreferences("api", Context.MODE_PRIVATE); pref.edit().putString("deviceId", body.getString("deviceId")).apply(); From ab9c874816a779fcb34e24f502e0cf2dfd94a5e7 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 6 Apr 2017 15:07:27 -0300 Subject: [PATCH 077/625] Fix android AGAIN --- target_java_android.cr | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 810452d..14fff7c 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -320,11 +320,7 @@ END @Override public void run() { if (response.code() >= 500) { - try { - Log.e("API Fatal", stringBody); - } catch (IOException e) { - e.printStackTrace(); - } + Log.e("API Fatal", stringBody); callback.onFailure("HTTP " + response.code()); return; } @@ -342,7 +338,7 @@ END } else { callback.onResult(body); } - } catch (JSONException | IOException e) { + } catch (JSONException e) { e.printStackTrace(); callback.onError("bug", e.getMessage()); } From 0710e0776da87ede59c569ddab906ba719eb84e8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 7 Apr 2017 07:24:06 -0300 Subject: [PATCH 078/625] fix default typing --- rethinkdb/rethinkdb.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 95bbd23..1b2af2c 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -99,7 +99,7 @@ interface RDatum extends RStreamOrDatum, PromiseLike { do(func: (obj: this) => X): RDatum do(func: (obj: this) => any): RDatum default(val: X): RDatum - default(val: any): RDatum + default(val: any): RDatum (idx: K): RDatum (idx: number | RDatum): RDatum orderBy(field: string | R_Sorting | ((e: RDatum) => any)): RArray From cd5dd4c1c3c0633e02db319879fa66fd599e05dd Mon Sep 17 00:00:00 2001 From: Roberto Date: Fri, 7 Apr 2017 10:10:19 -0300 Subject: [PATCH 079/625] remove target deduction --- main.cr | 13 ++++++++++--- target.cr | 19 +++++++------------ target_java_android.cr | 2 +- target_swift_ios.cr | 2 +- ...rver.cr => target_typescript_nodeserver.cr | 2 +- target_typescript_web.cr | 2 +- 6 files changed, 21 insertions(+), 19 deletions(-) rename target_typescript_server.cr => target_typescript_nodeserver.cr (99%) diff --git a/main.cr b/main.cr index 687731a..a42a7f1 100644 --- a/main.cr +++ b/main.cr @@ -3,19 +3,21 @@ require "./parser" require "./ast_to_s" require "./target_java_android" require "./target_swift_ios" -require "./target_typescript_server" +require "./target_typescript_nodeserver" require "./target_typescript_web" require "option_parser" require "file_utils" is_server = false destination = "" +target_name = "" sources = [] of String OptionParser.parse! do |parser| parser.banner = "Usage: salute [arguments]" - parser.on("-s", "--server", "Generates server-side code") { is_server = true } + # parser.on("-s", "--server", "Generates server-side code") { is_server = true } parser.on("-o NAME", "--output=NAME", "Specifies the output file") { |name| destination = name } + parser.on("-t TARGET", "--target=TARGET", "Specifies the target platform") { |target| target_name = target } parser.on("-h", "--help", "Show this help") { puts parser } parser.unknown_args {|args| sources = args } end @@ -39,5 +41,10 @@ if destination == "" exit end +if target_name == "" + STDERR.puts "You must specify a target" + exit +end + FileUtils.mkdir_p(File.dirname(destination)) -Target.process(ast, destination, is_server: is_server) +Target.process(ast, destination, target_name) diff --git a/target.cr b/target.cr index f24ea61..27bbc7d 100644 --- a/target.cr +++ b/target.cr @@ -3,7 +3,7 @@ require "./lexer" require "./parser" abstract class Target - @@targets = {} of {String, Bool} => Target.class + @@targets = {} of String => Target.class def initialize(@output : String, @ast : AST::ApiDescription) @io = IO::Memory.new @@ -16,19 +16,14 @@ abstract class Target abstract def gen - def self.register(target, language, is_server = false) - @@targets[{language, is_server}] = target + def self.register(target, target_name) + @@targets[target_name] = target end - def self.process(ast, output, is_server = false) - match = output.match(/\.(\w+)$/) - unless match - raise "Unrecognized extension for '#{output}'" - end - language = match[1] - target = @@targets[{language, is_server}]? + def self.process(ast, output, target_name) + target = @@targets[target_name]? unless target - raise "Language extension '.#{language}' is not supported" + raise "Target '#{target_name}' is not supported" end t = target.new(output, ast) t.gen @@ -38,4 +33,4 @@ abstract class Target def ident(code) code.split("\n").map {|line| " " + line}.join("\n").gsub(/\n\s+$/m, "\n") end -end \ No newline at end of file +end diff --git a/target_java_android.cr b/target_java_android.cr index 14fff7c..6fdc1ba 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -405,4 +405,4 @@ END end end -Target.register(JavaAndroidTarget, language: "java", is_server: false) +Target.register(JavaAndroidTarget, target_name: "java_android") diff --git a/target_swift_ios.cr b/target_swift_ios.cr index 2e6ebf0..bee8a9a 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -199,4 +199,4 @@ END end end -Target.register(SwiftIosTarget, language: "swift", is_server: false) +Target.register(SwiftIosTarget, target_name: "swift_ios") diff --git a/target_typescript_server.cr b/target_typescript_nodeserver.cr similarity index 99% rename from target_typescript_server.cr rename to target_typescript_nodeserver.cr index ec58a98..418281f 100644 --- a/target_typescript_server.cr +++ b/target_typescript_nodeserver.cr @@ -292,4 +292,4 @@ END end end -Target.register(TypeScriptServerTarget, language: "ts", is_server: true) +Target.register(TypeScriptServerTarget, target_name: "typescript_nodeserver") diff --git a/target_typescript_web.cr b/target_typescript_web.cr index da97f9f..72979c3 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -109,4 +109,4 @@ END end end -Target.register(TypeScriptWebTarget, language: "ts", is_server: false) +Target.register(TypeScriptWebTarget, target_name: "typescript_web") From b9738dee8a0d6a3fdc4ddc92ec75d44ea79bf615 Mon Sep 17 00:00:00 2001 From: Roberto Date: Fri, 7 Apr 2017 11:14:24 -0300 Subject: [PATCH 080/625] add nodeclient target --- main.cr | 1 + target_typescript_nodeclient.cr | 144 ++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 target_typescript_nodeclient.cr diff --git a/main.cr b/main.cr index a42a7f1..df68849 100644 --- a/main.cr +++ b/main.cr @@ -4,6 +4,7 @@ require "./ast_to_s" require "./target_java_android" require "./target_swift_ios" require "./target_typescript_nodeserver" +require "./target_typescript_nodeclient" require "./target_typescript_web" require "option_parser" require "file_utils" diff --git a/target_typescript_nodeclient.cr b/target_typescript_nodeclient.cr new file mode 100644 index 0000000..822a3b1 --- /dev/null +++ b/target_typescript_nodeclient.cr @@ -0,0 +1,144 @@ +require "./target_typescript" + +class TypeScriptClientTarget < TypeScriptTarget + def gen + @io << <<-END +import * as moment from "moment"; +import * as request from "request"; +import * as fs from "fs"; +import {version as nodeVersion} from "process"; + +const baseUrl = #{@ast.options.url.inspect}; +let gDeviceId = null; +let gDevicePath = "deviceId"; + +END + + @ast.struct_types.each do |t| + @io << generate_struct_type(t) + @io << "\n\n" + end + + @ast.enum_types.each do |t| + @io << generate_enum_type(t) + @io << "\n\n" + end + + @ast.operations.each do |op| + @io << "export async function #{op.pretty_name}#{operation_args(op)}: Promise<#{operation_ret(op)}> {\n" + if op.args.size > 0 + @io << " const args = {\n" + op.args.each do |arg| + @io << ident ident "#{arg.name}: #{type_to_json(arg.type, arg.name)}," + @io << "\n" + end + @io << " };\n" + end + + @io << " " + @io << "const ret: #{native_type op.return_type} = " unless op.return_type.is_a? AST::VoidPrimitiveType + @io << "await makeRequest({name: #{op.pretty_name.inspect}, #{op.args.size > 0 ? "args" : "args: {}"}});\n" + @io << ident "return " + type_from_json(op.return_type, "ret") + ";" + @io << "\n" + @io << "}\n\n" + end + + @io << <<-END +////////////////////////////////////////////////////// + +async function getDeviceId(){ + if(!gDeviceId){ + try{ + gDeviceId = await new Promise((resolve, reject) => fs.readFile(gDevicePath, "utf8", + (err, data) => { + if(err) + reject(err); + else + resolve(); + }) + ); + } catch(e){ + return null; + } + } + return gDeviceId; +} + +async function setDeviceId(newDeviceId){ + if(newDeviceId !== gDeviceId){ + await new Promise((resolve, reject) => fs.writeFile(gDevicePath, newDeviceId, "utf8", + (err) => { + if(err) + reject(err); + else + resolve(); + }) + ); + gDeviceId = newDeviceId; + } +} + +async function device() { + const device: any = { + type: "node", + platform: nodeVersion, + screen: { + width: 1, + height: 1 + }, + version: "0.0.0", + language: "en_US" + }; + + const deviceId = await getDeviceId(); + if (deviceId) + device.id = deviceId; + return device; +} + +function randomBytesHex(len: number) { + let hex = ""; + for (let i = 0; i < 2 * len; ++i) + hex += "0123456789abcdef"[Math.floor(Math.random()*16)]; + return hex; +} + +async function makeRequest({name, args}: {name: string, args: any}) { + return new Promise(async (resolve, reject) => { + const body = { + id: randomBytesHex(16), + device: await device(), + name: name, + args: args + }; + + request.post( + "https://" + baseUrl + "/" + name, + {json: body}, + async (err, res, body) => { + if(!err){ + try{ + if(body.ok){ + await setDeviceId(body.deviceId); + resolve(body.result); + } else { + reject(body.error); + } + } catch(e){ + console.error(e); + reject({type: "Fatal", message: e.toString()}); + } + } else { + console.error(err); + reject({type: "Fatal", message: err.toString()}); + } + } + ); + }); +} + +END + end +end + +Target.register(TypeScriptClientTarget, target_name: "typescript_nodeclient") From ecc23f79f1bc26fea97cee008406a1728c6531f1 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 7 Apr 2017 17:01:18 -0300 Subject: [PATCH 081/625] web: allow undefined as null --- target_typescript_web.cr | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index da97f9f..b81cf05 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -107,6 +107,10 @@ async function makeRequest({name, args}: {name: string, args: any}) { END end + + def native_type(t : AST::OptionalType) + native_type(t.base) + " | null | undefined" + end end Target.register(TypeScriptWebTarget, language: "ts", is_server: false) From dd0ae552816eece84a117b6169e6ba24256cfb51 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 10 Apr 2017 10:53:13 -0300 Subject: [PATCH 082/625] cleanup --- main.cr | 1 - target_typescript_nodeclient.cr | 14 ++++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/main.cr b/main.cr index df68849..d36105c 100644 --- a/main.cr +++ b/main.cr @@ -16,7 +16,6 @@ sources = [] of String OptionParser.parse! do |parser| parser.banner = "Usage: salute [arguments]" - # parser.on("-s", "--server", "Generates server-side code") { is_server = true } parser.on("-o NAME", "--output=NAME", "Specifies the output file") { |name| destination = name } parser.on("-t TARGET", "--target=TARGET", "Specifies the target platform") { |target| target_name = target } parser.on("-h", "--help", "Show this help") { puts parser } diff --git a/target_typescript_nodeclient.cr b/target_typescript_nodeclient.cr index 822a3b1..cf68e62 100644 --- a/target_typescript_nodeclient.cr +++ b/target_typescript_nodeclient.cr @@ -10,7 +10,7 @@ import {version as nodeVersion} from "process"; const baseUrl = #{@ast.options.url.inspect}; let gDeviceId = null; -let gDevicePath = "deviceId"; +let gDevicePath = "/root/config/deviceId"; END @@ -81,13 +81,15 @@ async function setDeviceId(newDeviceId){ async function device() { const device: any = { type: "node", - platform: nodeVersion, + platform: { + nodeVersion: nodeVersion, + }, screen: { - width: 1, - height: 1 + width: 0, + height: 0 }, version: "0.0.0", - language: "en_US" + language: "en-US" }; const deviceId = await getDeviceId(); @@ -133,7 +135,7 @@ async function makeRequest({name, args}: {name: string, args: any}) { reject({type: "Fatal", message: err.toString()}); } } - ); + ); }); } From 55c0517b1a1c99b6bcd211c746741c992187be2b Mon Sep 17 00:00:00 2001 From: Roberto Date: Mon, 10 Apr 2017 11:00:36 -0300 Subject: [PATCH 083/625] add target-node --- target-node/.dockerignore | 4 + target-node/.gitignore | 4 + target-node/.npmignore | 0 target-node/.yarnrc | 3 + target-node/Dockerfile | 8 + target-node/api.ts | 0 target-node/build_and_publish.sh | 14 + target-node/package.json | 31 + target-node/tsconfig.json | 20 + target-node/yarn.lock | 1608 ++++++++++++++++++++++++++++++ 10 files changed, 1692 insertions(+) create mode 100644 target-node/.dockerignore create mode 100644 target-node/.gitignore create mode 100644 target-node/.npmignore create mode 100644 target-node/.yarnrc create mode 100644 target-node/Dockerfile create mode 100644 target-node/api.ts create mode 100644 target-node/build_and_publish.sh create mode 100644 target-node/package.json create mode 100644 target-node/tsconfig.json create mode 100644 target-node/yarn.lock diff --git a/target-node/.dockerignore b/target-node/.dockerignore new file mode 100644 index 0000000..868bd46 --- /dev/null +++ b/target-node/.dockerignore @@ -0,0 +1,4 @@ +node_modules +api.js +api.js.map +api.d.ts \ No newline at end of file diff --git a/target-node/.gitignore b/target-node/.gitignore new file mode 100644 index 0000000..868bd46 --- /dev/null +++ b/target-node/.gitignore @@ -0,0 +1,4 @@ +node_modules +api.js +api.js.map +api.d.ts \ No newline at end of file diff --git a/target-node/.npmignore b/target-node/.npmignore new file mode 100644 index 0000000..e69de29 diff --git a/target-node/.yarnrc b/target-node/.yarnrc new file mode 100644 index 0000000..d51da20 --- /dev/null +++ b/target-node/.yarnrc @@ -0,0 +1,3 @@ +registry "https://npm.cubos.io/" +email tech@cubos.io +username cubos diff --git a/target-node/Dockerfile b/target-node/Dockerfile new file mode 100644 index 0000000..f13e6a8 --- /dev/null +++ b/target-node/Dockerfile @@ -0,0 +1,8 @@ +FROM node +WORKDIR /root/stage/ +ADD package.json /root/stage/ +ADD yarn.lock /root/stage/ +RUN yarn install +ADD . /root/stage/ +ADD build_and_publish.sh / +RUN chmod +x /build_and_publish.sh diff --git a/target-node/api.ts b/target-node/api.ts new file mode 100644 index 0000000..e69de29 diff --git a/target-node/build_and_publish.sh b/target-node/build_and_publish.sh new file mode 100644 index 0000000..17752f1 --- /dev/null +++ b/target-node/build_and_publish.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +NAME=$2 +VERSION=1.0.$3 + +cp $1 /root/stage/api.ts +cd /root/stage + +export PATH=$(npm bin):$PATH +json -I -f package.json -e 'this.name="@cubos/'$NAME'"' +npm version $VERSION || true +tsc +babel api.js -o api.js +npm publish diff --git a/target-node/package.json b/target-node/package.json new file mode 100644 index 0000000..0b8f4b5 --- /dev/null +++ b/target-node/package.json @@ -0,0 +1,31 @@ +{ + "name": "@cubos/api", + "version": "0.0", + "dependencies": { + "@types/node": "^7.0.8", + "babel-runtime": "^6.23.0", + "moment": "^2.17.1", + "request": "^2.81.0" + }, + "main": "api.js", + "types": "api.d.ts", + "babel": { + "plugins": [ + "transform-runtime" + ], + "presets": [ + "babel-preset-es2015", + "babel-preset-es2016", + "babel-preset-es2017" + ] + }, + "devDependencies": { + "babel-cli": "^6.23.0", + "babel-plugin-transform-runtime": "^6.23.0", + "babel-preset-es2015": "^6.22.0", + "babel-preset-es2016": "^6.22.0", + "babel-preset-es2017": "^6.22.0", + "json": "^9.0.4", + "typescript": "^2.2.1" + } +} diff --git a/target-node/tsconfig.json b/target-node/tsconfig.json new file mode 100644 index 0000000..5a881b0 --- /dev/null +++ b/target-node/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "declaration": true, + "alwaysStrict": true, + "allowSyntheticDefaultImports": true, + "experimentalDecorators": true, + "noImplicitAny": true, + "noImplicitThis": true, + "sourceMap": true, + "target": "ES2017", + "strictNullChecks": true, + "module": "commonjs", + "lib": ["es2017"] + }, + "include": [ + "*.ts" + ], + "exclude": [] +} diff --git a/target-node/yarn.lock b/target-node/yarn.lock new file mode 100644 index 0000000..e74112a --- /dev/null +++ b/target-node/yarn.lock @@ -0,0 +1,1608 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/node@^7.0.8": + version "7.0.12" + resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.12.tgz#ae5f67a19c15f752148004db07cbbb372e69efc9" + +abbrev@1: + version "1.1.0" + resolved "https://npm.cubos.io/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" + +ajv@^4.9.1: + version "4.11.6" + resolved "https://npm.cubos.io/ajv/-/ajv-4.11.6.tgz#947e93049790942b2a2d60a8289b28924d39f987" + dependencies: + co "^4.6.0" + json-stable-stringify "^1.0.1" + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://npm.cubos.io/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://npm.cubos.io/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +anymatch@^1.3.0: + version "1.3.0" + resolved "https://npm.cubos.io/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507" + dependencies: + arrify "^1.0.0" + micromatch "^2.1.5" + +aproba@^1.0.3: + version "1.1.1" + resolved "https://npm.cubos.io/aproba/-/aproba-1.1.1.tgz#95d3600f07710aa0e9298c726ad5ecf2eacbabab" + +are-we-there-yet@~1.1.2: + version "1.1.2" + resolved "https://npm.cubos.io/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz#80e470e95a084794fe1899262c5667c6e88de1b3" + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.0 || ^1.1.13" + +arr-diff@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" + dependencies: + arr-flatten "^1.0.1" + +arr-flatten@^1.0.1: + version "1.0.1" + resolved "https://npm.cubos.io/arr-flatten/-/arr-flatten-1.0.1.tgz#e5ffe54d45e19f32f216e91eb99c8ce892bb604b" + +array-unique@^0.2.1: + version "0.2.1" + resolved "https://npm.cubos.io/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" + +arrify@^1.0.0: + version "1.0.1" + resolved "https://npm.cubos.io/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + +asn1@~0.2.3: + version "0.2.3" + resolved "https://npm.cubos.io/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + +assert-plus@^0.2.0: + version "0.2.0" + resolved "https://npm.cubos.io/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" + +async-each@^1.0.0: + version "1.0.1" + resolved "https://npm.cubos.io/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://npm.cubos.io/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + +aws-sign2@~0.6.0: + version "0.6.0" + resolved "https://npm.cubos.io/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" + +aws4@^1.2.1: + version "1.6.0" + resolved "https://npm.cubos.io/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" + +babel-cli@^6.23.0: + version "6.24.1" + resolved "https://npm.cubos.io/babel-cli/-/babel-cli-6.24.1.tgz#207cd705bba61489b2ea41b5312341cf6aca2283" + dependencies: + babel-core "^6.24.1" + babel-polyfill "^6.23.0" + babel-register "^6.24.1" + babel-runtime "^6.22.0" + commander "^2.8.1" + convert-source-map "^1.1.0" + fs-readdir-recursive "^1.0.0" + glob "^7.0.0" + lodash "^4.2.0" + output-file-sync "^1.1.0" + path-is-absolute "^1.0.0" + slash "^1.0.0" + source-map "^0.5.0" + v8flags "^2.0.10" + optionalDependencies: + chokidar "^1.6.1" + +babel-code-frame@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" + dependencies: + chalk "^1.1.0" + esutils "^2.0.2" + js-tokens "^3.0.0" + +babel-core@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-core/-/babel-core-6.24.1.tgz#8c428564dce1e1f41fb337ec34f4c3b022b5ad83" + dependencies: + babel-code-frame "^6.22.0" + babel-generator "^6.24.1" + babel-helpers "^6.24.1" + babel-messages "^6.23.0" + babel-register "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + babylon "^6.11.0" + convert-source-map "^1.1.0" + debug "^2.1.1" + json5 "^0.5.0" + lodash "^4.2.0" + minimatch "^3.0.2" + path-is-absolute "^1.0.0" + private "^0.1.6" + slash "^1.0.0" + source-map "^0.5.0" + +babel-generator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.24.1.tgz#e715f486c58ded25649d888944d52aa07c5d9497" + dependencies: + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + detect-indent "^4.0.0" + jsesc "^1.3.0" + lodash "^4.2.0" + source-map "^0.5.0" + trim-right "^1.0.1" + +babel-helper-builder-binary-assignment-operator-visitor@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz#cce4517ada356f4220bcae8a02c2b346f9a56664" + dependencies: + babel-helper-explode-assignable-expression "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-call-delegate@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz#ece6aacddc76e41c3461f88bfc575bd0daa2df8d" + dependencies: + babel-helper-hoist-variables "^6.24.1" + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-define-map@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-define-map/-/babel-helper-define-map-6.24.1.tgz#7a9747f258d8947d32d515f6aa1c7bd02204a080" + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + lodash "^4.2.0" + +babel-helper-explode-assignable-expression@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz#f25b82cf7dc10433c55f70592d5746400ac22caa" + dependencies: + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-function-name@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" + dependencies: + babel-helper-get-function-arity "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-get-function-arity@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-hoist-variables@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz#1ecb27689c9d25513eadbc9914a73f5408be7a76" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-optimise-call-expression@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz#f7a13427ba9f73f8f4fa993c54a97882d1244257" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-regex@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-regex/-/babel-helper-regex-6.24.1.tgz#d36e22fab1008d79d88648e32116868128456ce8" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + lodash "^4.2.0" + +babel-helper-remap-async-to-generator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-replace-supers@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz#bf6dbfe43938d17369a213ca8a8bf74b6a90ab1a" + dependencies: + babel-helper-optimise-call-expression "^6.24.1" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helpers@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-messages@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-check-es2015-constants@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-syntax-async-functions@^6.8.0: + version "6.13.0" + resolved "https://npm.cubos.io/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" + +babel-plugin-syntax-exponentiation-operator@^6.8.0: + version "6.13.0" + resolved "https://npm.cubos.io/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de" + +babel-plugin-syntax-trailing-function-commas@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" + +babel-plugin-transform-async-to-generator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761" + dependencies: + babel-helper-remap-async-to-generator "^6.24.1" + babel-plugin-syntax-async-functions "^6.8.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-arrow-functions@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz#bbc51b49f964d70cb8d8e0b94e820246ce3a6141" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-block-scoping@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.24.1.tgz#76c295dc3a4741b1665adfd3167215dcff32a576" + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + lodash "^4.2.0" + +babel-plugin-transform-es2015-classes@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db" + dependencies: + babel-helper-define-map "^6.24.1" + babel-helper-function-name "^6.24.1" + babel-helper-optimise-call-expression "^6.24.1" + babel-helper-replace-supers "^6.24.1" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-computed-properties@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz#6fe2a8d16895d5634f4cd999b6d3480a308159b3" + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-destructuring@^6.22.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-duplicate-keys@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz#73eb3d310ca969e3ef9ec91c53741a6f1576423e" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-for-of@^6.22.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz#f47c95b2b613df1d3ecc2fdb7573623c75248691" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-function-name@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz#834c89853bc36b1af0f3a4c5dbaa94fd8eacaa8b" + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-literals@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz#4f54a02d6cd66cf915280019a31d31925377ca2e" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-modules-amd@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154" + dependencies: + babel-plugin-transform-es2015-modules-commonjs "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-modules-commonjs@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.24.1.tgz#d3e310b40ef664a36622200097c6d440298f2bfe" + dependencies: + babel-plugin-transform-strict-mode "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-modules-systemjs@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" + dependencies: + babel-helper-hoist-variables "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-modules-umd@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz#ac997e6285cd18ed6176adb607d602344ad38468" + dependencies: + babel-plugin-transform-es2015-modules-amd "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-object-super@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz#24cef69ae21cb83a7f8603dad021f572eb278f8d" + dependencies: + babel-helper-replace-supers "^6.24.1" + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-parameters@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" + dependencies: + babel-helper-call-delegate "^6.24.1" + babel-helper-get-function-arity "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-shorthand-properties@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz#24f875d6721c87661bbd99a4622e51f14de38aa0" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-spread@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz#d6d68a99f89aedc4536c81a542e8dd9f1746f8d1" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-sticky-regex@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz#00c1cdb1aca71112cdf0cf6126c2ed6b457ccdbc" + dependencies: + babel-helper-regex "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-template-literals@^6.22.0: + version "6.22.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz#a84b3450f7e9f8f1f6839d6d687da84bb1236d8d" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-typeof-symbol@^6.22.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz#dec09f1cddff94b52ac73d505c84df59dcceb372" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-unicode-regex@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz#d38b12f42ea7323f729387f18a7c5ae1faeb35e9" + dependencies: + babel-helper-regex "^6.24.1" + babel-runtime "^6.22.0" + regexpu-core "^2.0.0" + +babel-plugin-transform-exponentiation-operator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz#2ab0c9c7f3098fa48907772bb813fe41e8de3a0e" + dependencies: + babel-helper-builder-binary-assignment-operator-visitor "^6.24.1" + babel-plugin-syntax-exponentiation-operator "^6.8.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-regenerator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.24.1.tgz#b8da305ad43c3c99b4848e4fe4037b770d23c418" + dependencies: + regenerator-transform "0.9.11" + +babel-plugin-transform-runtime@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.23.0.tgz#88490d446502ea9b8e7efb0fe09ec4d99479b1ee" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-strict-mode@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-polyfill@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-polyfill/-/babel-polyfill-6.23.0.tgz#8364ca62df8eafb830499f699177466c3b03499d" + dependencies: + babel-runtime "^6.22.0" + core-js "^2.4.0" + regenerator-runtime "^0.10.0" + +babel-preset-es2015@^6.22.0: + version "6.24.1" + resolved "https://npm.cubos.io/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz#d44050d6bc2c9feea702aaf38d727a0210538939" + dependencies: + babel-plugin-check-es2015-constants "^6.22.0" + babel-plugin-transform-es2015-arrow-functions "^6.22.0" + babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" + babel-plugin-transform-es2015-block-scoping "^6.24.1" + babel-plugin-transform-es2015-classes "^6.24.1" + babel-plugin-transform-es2015-computed-properties "^6.24.1" + babel-plugin-transform-es2015-destructuring "^6.22.0" + babel-plugin-transform-es2015-duplicate-keys "^6.24.1" + babel-plugin-transform-es2015-for-of "^6.22.0" + babel-plugin-transform-es2015-function-name "^6.24.1" + babel-plugin-transform-es2015-literals "^6.22.0" + babel-plugin-transform-es2015-modules-amd "^6.24.1" + babel-plugin-transform-es2015-modules-commonjs "^6.24.1" + babel-plugin-transform-es2015-modules-systemjs "^6.24.1" + babel-plugin-transform-es2015-modules-umd "^6.24.1" + babel-plugin-transform-es2015-object-super "^6.24.1" + babel-plugin-transform-es2015-parameters "^6.24.1" + babel-plugin-transform-es2015-shorthand-properties "^6.24.1" + babel-plugin-transform-es2015-spread "^6.22.0" + babel-plugin-transform-es2015-sticky-regex "^6.24.1" + babel-plugin-transform-es2015-template-literals "^6.22.0" + babel-plugin-transform-es2015-typeof-symbol "^6.22.0" + babel-plugin-transform-es2015-unicode-regex "^6.24.1" + babel-plugin-transform-regenerator "^6.24.1" + +babel-preset-es2016@^6.22.0: + version "6.24.1" + resolved "https://npm.cubos.io/babel-preset-es2016/-/babel-preset-es2016-6.24.1.tgz#f900bf93e2ebc0d276df9b8ab59724ebfd959f8b" + dependencies: + babel-plugin-transform-exponentiation-operator "^6.24.1" + +babel-preset-es2017@^6.22.0: + version "6.24.1" + resolved "https://npm.cubos.io/babel-preset-es2017/-/babel-preset-es2017-6.24.1.tgz#597beadfb9f7f208bcfd8a12e9b2b29b8b2f14d1" + dependencies: + babel-plugin-syntax-trailing-function-commas "^6.22.0" + babel-plugin-transform-async-to-generator "^6.24.1" + +babel-register@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-register/-/babel-register-6.24.1.tgz#7e10e13a2f71065bdfad5a1787ba45bca6ded75f" + dependencies: + babel-core "^6.24.1" + babel-runtime "^6.22.0" + core-js "^2.4.0" + home-or-tmp "^2.0.0" + lodash "^4.2.0" + mkdirp "^0.5.1" + source-map-support "^0.4.2" + +babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0: + version "6.23.0" + resolved "https://npm.cubos.io/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.10.0" + +babel-template@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-template/-/babel-template-6.24.1.tgz#04ae514f1f93b3a2537f2a0f60a5a45fb8308333" + dependencies: + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + babylon "^6.11.0" + lodash "^4.2.0" + +babel-traverse@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.24.1.tgz#ab36673fd356f9a0948659e7b338d5feadb31695" + dependencies: + babel-code-frame "^6.22.0" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + babylon "^6.15.0" + debug "^2.2.0" + globals "^9.0.0" + invariant "^2.2.0" + lodash "^4.2.0" + +babel-types@^6.19.0, babel-types@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-types/-/babel-types-6.24.1.tgz#a136879dc15b3606bda0d90c1fc74304c2ff0975" + dependencies: + babel-runtime "^6.22.0" + esutils "^2.0.2" + lodash "^4.2.0" + to-fast-properties "^1.0.1" + +babylon@^6.11.0, babylon@^6.15.0: + version "6.16.1" + resolved "https://npm.cubos.io/babylon/-/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3" + +balanced-match@^0.4.1: + version "0.4.2" + resolved "https://npm.cubos.io/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" + +bcrypt-pbkdf@^1.0.0: + version "1.0.1" + resolved "https://npm.cubos.io/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" + dependencies: + tweetnacl "^0.14.3" + +binary-extensions@^1.0.0: + version "1.8.0" + resolved "https://npm.cubos.io/binary-extensions/-/binary-extensions-1.8.0.tgz#48ec8d16df4377eae5fa5884682480af4d95c774" + +block-stream@*: + version "0.0.9" + resolved "https://npm.cubos.io/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" + dependencies: + inherits "~2.0.0" + +boom@2.x.x: + version "2.10.1" + resolved "https://npm.cubos.io/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" + dependencies: + hoek "2.x.x" + +brace-expansion@^1.0.0: + version "1.1.7" + resolved "https://npm.cubos.io/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59" + dependencies: + balanced-match "^0.4.1" + concat-map "0.0.1" + +braces@^1.8.2: + version "1.8.5" + resolved "https://npm.cubos.io/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" + dependencies: + expand-range "^1.8.1" + preserve "^0.2.0" + repeat-element "^1.1.2" + +buffer-shims@~1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" + +caseless@~0.12.0: + version "0.12.0" + resolved "https://npm.cubos.io/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + +chalk@^1.1.0: + version "1.1.3" + resolved "https://npm.cubos.io/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +chokidar@^1.6.1: + version "1.6.1" + resolved "https://npm.cubos.io/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2" + dependencies: + anymatch "^1.3.0" + async-each "^1.0.0" + glob-parent "^2.0.0" + inherits "^2.0.1" + is-binary-path "^1.0.0" + is-glob "^2.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.0.0" + optionalDependencies: + fsevents "^1.0.0" + +co@^4.6.0: + version "4.6.0" + resolved "https://npm.cubos.io/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://npm.cubos.io/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + +combined-stream@^1.0.5, combined-stream@~1.0.5: + version "1.0.5" + resolved "https://npm.cubos.io/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" + dependencies: + delayed-stream "~1.0.0" + +commander@^2.8.1: + version "2.9.0" + resolved "https://npm.cubos.io/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://npm.cubos.io/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://npm.cubos.io/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + +convert-source-map@^1.1.0: + version "1.5.0" + resolved "https://npm.cubos.io/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" + +core-js@^2.4.0: + version "2.4.1" + resolved "https://npm.cubos.io/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" + +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://npm.cubos.io/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +cryptiles@2.x.x: + version "2.0.5" + resolved "https://npm.cubos.io/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" + dependencies: + boom "2.x.x" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://npm.cubos.io/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + dependencies: + assert-plus "^1.0.0" + +debug@^2.1.1, debug@^2.2.0: + version "2.6.3" + resolved "https://npm.cubos.io/debug/-/debug-2.6.3.tgz#0f7eb8c30965ec08c72accfa0130c8b79984141d" + dependencies: + ms "0.7.2" + +deep-extend@~0.4.0: + version "0.4.1" + resolved "https://npm.cubos.io/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +delegates@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + +detect-indent@^4.0.0: + version "4.0.0" + resolved "https://npm.cubos.io/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" + dependencies: + repeating "^2.0.0" + +ecc-jsbn@~0.1.1: + version "0.1.1" + resolved "https://npm.cubos.io/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" + dependencies: + jsbn "~0.1.0" + +escape-string-regexp@^1.0.2: + version "1.0.5" + resolved "https://npm.cubos.io/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +esutils@^2.0.2: + version "2.0.2" + resolved "https://npm.cubos.io/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + +expand-brackets@^0.1.4: + version "0.1.5" + resolved "https://npm.cubos.io/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" + dependencies: + is-posix-bracket "^0.1.0" + +expand-range@^1.8.1: + version "1.8.2" + resolved "https://npm.cubos.io/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" + dependencies: + fill-range "^2.1.0" + +extend@~3.0.0: + version "3.0.0" + resolved "https://npm.cubos.io/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4" + +extglob@^0.3.1: + version "0.3.2" + resolved "https://npm.cubos.io/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" + dependencies: + is-extglob "^1.0.0" + +extsprintf@1.0.2: + version "1.0.2" + resolved "https://npm.cubos.io/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" + +filename-regex@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/filename-regex/-/filename-regex-2.0.0.tgz#996e3e80479b98b9897f15a8a58b3d084e926775" + +fill-range@^2.1.0: + version "2.2.3" + resolved "https://npm.cubos.io/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" + dependencies: + is-number "^2.1.0" + isobject "^2.0.0" + randomatic "^1.1.3" + repeat-element "^1.1.2" + repeat-string "^1.5.2" + +for-in@^1.0.1: + version "1.0.2" + resolved "https://npm.cubos.io/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + +for-own@^0.1.4: + version "0.1.5" + resolved "https://npm.cubos.io/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce" + dependencies: + for-in "^1.0.1" + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://npm.cubos.io/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + +form-data@~2.1.1: + version "2.1.4" + resolved "https://npm.cubos.io/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + +fs-readdir-recursive@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +fsevents@^1.0.0: + version "1.1.1" + resolved "https://npm.cubos.io/fsevents/-/fsevents-1.1.1.tgz#f19fd28f43eeaf761680e519a203c4d0b3d31aff" + dependencies: + nan "^2.3.0" + node-pre-gyp "^0.6.29" + +fstream-ignore@^1.0.5: + version "1.0.5" + resolved "https://npm.cubos.io/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" + dependencies: + fstream "^1.0.0" + inherits "2" + minimatch "^3.0.0" + +fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: + version "1.0.11" + resolved "https://npm.cubos.io/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" + dependencies: + graceful-fs "^4.1.2" + inherits "~2.0.0" + mkdirp ">=0.5 0" + rimraf "2" + +gauge@~2.7.1: + version "2.7.3" + resolved "https://npm.cubos.io/gauge/-/gauge-2.7.3.tgz#1c23855f962f17b3ad3d0dc7443f304542edfe09" + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + wide-align "^1.1.0" + +getpass@^0.1.1: + version "0.1.6" + resolved "https://npm.cubos.io/getpass/-/getpass-0.1.6.tgz#283ffd9fc1256840875311c1b60e8c40187110e6" + dependencies: + assert-plus "^1.0.0" + +glob-base@^0.3.0: + version "0.3.0" + resolved "https://npm.cubos.io/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" + dependencies: + glob-parent "^2.0.0" + is-glob "^2.0.0" + +glob-parent@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" + dependencies: + is-glob "^2.0.0" + +glob@^7.0.0, glob@^7.0.5: + version "7.1.1" + resolved "https://npm.cubos.io/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.2" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globals@^9.0.0: + version "9.17.0" + resolved "https://npm.cubos.io/globals/-/globals-9.17.0.tgz#0c0ca696d9b9bb694d2e5470bd37777caad50286" + +graceful-fs@^4.1.2, graceful-fs@^4.1.4: + version "4.1.11" + resolved "https://npm.cubos.io/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + +"graceful-readlink@>= 1.0.0": + version "1.0.1" + resolved "https://npm.cubos.io/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" + +har-schema@^1.0.5: + version "1.0.5" + resolved "https://npm.cubos.io/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" + +har-validator@~4.2.1: + version "4.2.1" + resolved "https://npm.cubos.io/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" + dependencies: + ajv "^4.9.1" + har-schema "^1.0.5" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://npm.cubos.io/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + +hawk@~3.1.3: + version "3.1.3" + resolved "https://npm.cubos.io/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" + dependencies: + boom "2.x.x" + cryptiles "2.x.x" + hoek "2.x.x" + sntp "1.x.x" + +hoek@2.x.x: + version "2.16.3" + resolved "https://npm.cubos.io/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" + +home-or-tmp@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.1" + +http-signature@~1.1.0: + version "1.1.1" + resolved "https://npm.cubos.io/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" + dependencies: + assert-plus "^0.2.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://npm.cubos.io/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1: + version "2.0.3" + resolved "https://npm.cubos.io/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +ini@~1.3.0: + version "1.3.4" + resolved "https://npm.cubos.io/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" + +invariant@^2.2.0: + version "2.2.2" + resolved "https://npm.cubos.io/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" + dependencies: + loose-envify "^1.0.0" + +is-binary-path@^1.0.0: + version "1.0.1" + resolved "https://npm.cubos.io/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" + dependencies: + binary-extensions "^1.0.0" + +is-buffer@^1.0.2: + version "1.1.5" + resolved "https://npm.cubos.io/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" + +is-dotfile@^1.0.0: + version "1.0.2" + resolved "https://npm.cubos.io/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d" + +is-equal-shallow@^0.1.3: + version "0.1.3" + resolved "https://npm.cubos.io/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" + dependencies: + is-primitive "^2.0.0" + +is-extendable@^0.1.1: + version "0.1.1" + resolved "https://npm.cubos.io/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + +is-extglob@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" + +is-finite@^1.0.0: + version "1.0.2" + resolved "https://npm.cubos.io/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + dependencies: + number-is-nan "^1.0.0" + +is-glob@^2.0.0, is-glob@^2.0.1: + version "2.0.1" + resolved "https://npm.cubos.io/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" + dependencies: + is-extglob "^1.0.0" + +is-number@^2.0.2, is-number@^2.1.0: + version "2.1.0" + resolved "https://npm.cubos.io/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" + dependencies: + kind-of "^3.0.2" + +is-posix-bracket@^0.1.0: + version "0.1.1" + resolved "https://npm.cubos.io/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" + +is-primitive@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + +isarray@1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +isobject@^2.0.0: + version "2.1.0" + resolved "https://npm.cubos.io/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + dependencies: + isarray "1.0.0" + +isstream@~0.1.2: + version "0.1.2" + resolved "https://npm.cubos.io/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + +jodid25519@^1.0.0: + version "1.0.2" + resolved "https://npm.cubos.io/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967" + dependencies: + jsbn "~0.1.0" + +js-tokens@^3.0.0: + version "3.0.1" + resolved "https://npm.cubos.io/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" + +jsbn@~0.1.0: + version "0.1.1" + resolved "https://npm.cubos.io/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + +jsesc@^1.3.0: + version "1.3.0" + resolved "https://npm.cubos.io/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" + +jsesc@~0.5.0: + version "0.5.0" + resolved "https://npm.cubos.io/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" + +json-schema@0.2.3: + version "0.2.3" + resolved "https://npm.cubos.io/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + +json-stable-stringify@^1.0.1: + version "1.0.1" + resolved "https://npm.cubos.io/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" + dependencies: + jsonify "~0.0.0" + +json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://npm.cubos.io/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + +json5@^0.5.0: + version "0.5.1" + resolved "https://npm.cubos.io/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + +json@^9.0.4: + version "9.0.6" + resolved "https://npm.cubos.io/json/-/json-9.0.6.tgz#7972c2a5a48a42678db2730c7c2c4ee6e4e24585" + +jsonify@~0.0.0: + version "0.0.0" + resolved "https://npm.cubos.io/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" + +jsprim@^1.2.2: + version "1.4.0" + resolved "https://npm.cubos.io/jsprim/-/jsprim-1.4.0.tgz#a3b87e40298d8c380552d8cc7628a0bb95a22918" + dependencies: + assert-plus "1.0.0" + extsprintf "1.0.2" + json-schema "0.2.3" + verror "1.3.6" + +kind-of@^3.0.2: + version "3.1.0" + resolved "https://npm.cubos.io/kind-of/-/kind-of-3.1.0.tgz#475d698a5e49ff5e53d14e3e732429dc8bf4cf47" + dependencies: + is-buffer "^1.0.2" + +lodash@^4.2.0: + version "4.17.4" + resolved "https://npm.cubos.io/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" + +loose-envify@^1.0.0: + version "1.3.1" + resolved "https://npm.cubos.io/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" + dependencies: + js-tokens "^3.0.0" + +micromatch@^2.1.5: + version "2.3.11" + resolved "https://npm.cubos.io/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" + dependencies: + arr-diff "^2.0.0" + array-unique "^0.2.1" + braces "^1.8.2" + expand-brackets "^0.1.4" + extglob "^0.3.1" + filename-regex "^2.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.1" + kind-of "^3.0.2" + normalize-path "^2.0.1" + object.omit "^2.0.0" + parse-glob "^3.0.4" + regex-cache "^0.4.2" + +mime-db@~1.27.0: + version "1.27.0" + resolved "https://npm.cubos.io/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1" + +mime-types@^2.1.12, mime-types@~2.1.7: + version "2.1.15" + resolved "https://npm.cubos.io/mime-types/-/mime-types-2.1.15.tgz#a4ebf5064094569237b8cf70046776d09fc92aed" + dependencies: + mime-db "~1.27.0" + +minimatch@^3.0.0, minimatch@^3.0.2: + version "3.0.3" + resolved "https://npm.cubos.io/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" + dependencies: + brace-expansion "^1.0.0" + +minimist@0.0.8: + version "0.0.8" + resolved "https://npm.cubos.io/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +minimist@^1.2.0: + version "1.2.0" + resolved "https://npm.cubos.io/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +"mkdirp@>=0.5 0", mkdirp@^0.5.1: + version "0.5.1" + resolved "https://npm.cubos.io/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +moment@^2.17.1: + version "2.18.1" + resolved "https://npm.cubos.io/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" + +ms@0.7.2: + version "0.7.2" + resolved "https://npm.cubos.io/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" + +nan@^2.3.0: + version "2.6.1" + resolved "https://npm.cubos.io/nan/-/nan-2.6.1.tgz#8c84f7b14c96b89f57fbc838012180ec8ca39a01" + +node-pre-gyp@^0.6.29: + version "0.6.34" + resolved "https://npm.cubos.io/node-pre-gyp/-/node-pre-gyp-0.6.34.tgz#94ad1c798a11d7fc67381b50d47f8cc18d9799f7" + dependencies: + mkdirp "^0.5.1" + nopt "^4.0.1" + npmlog "^4.0.2" + rc "^1.1.7" + request "^2.81.0" + rimraf "^2.6.1" + semver "^5.3.0" + tar "^2.2.1" + tar-pack "^3.4.0" + +nopt@^4.0.1: + version "4.0.1" + resolved "https://npm.cubos.io/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" + dependencies: + abbrev "1" + osenv "^0.1.4" + +normalize-path@^2.0.1: + version "2.1.1" + resolved "https://npm.cubos.io/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + dependencies: + remove-trailing-separator "^1.0.1" + +npmlog@^4.0.2: + version "4.0.2" + resolved "https://npm.cubos.io/npmlog/-/npmlog-4.0.2.tgz#d03950e0e78ce1527ba26d2a7592e9348ac3e75f" + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.7.1" + set-blocking "~2.0.0" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://npm.cubos.io/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + +oauth-sign@~0.8.1: + version "0.8.2" + resolved "https://npm.cubos.io/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" + +object-assign@^4.1.0: + version "4.1.1" + resolved "https://npm.cubos.io/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + +object.omit@^2.0.0: + version "2.0.1" + resolved "https://npm.cubos.io/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" + dependencies: + for-own "^0.1.4" + is-extendable "^0.1.1" + +once@^1.3.0, once@^1.3.3: + version "1.4.0" + resolved "https://npm.cubos.io/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +os-homedir@^1.0.0: + version "1.0.2" + resolved "https://npm.cubos.io/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: + version "1.0.2" + resolved "https://npm.cubos.io/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + +osenv@^0.1.4: + version "0.1.4" + resolved "https://npm.cubos.io/osenv/-/osenv-0.1.4.tgz#42fe6d5953df06c8064be6f176c3d05aaaa34644" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.0" + +output-file-sync@^1.1.0: + version "1.1.2" + resolved "https://npm.cubos.io/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" + dependencies: + graceful-fs "^4.1.4" + mkdirp "^0.5.1" + object-assign "^4.1.0" + +parse-glob@^3.0.4: + version "3.0.4" + resolved "https://npm.cubos.io/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" + dependencies: + glob-base "^0.3.0" + is-dotfile "^1.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.0" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://npm.cubos.io/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +performance-now@^0.2.0: + version "0.2.0" + resolved "https://npm.cubos.io/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" + +preserve@^0.2.0: + version "0.2.0" + resolved "https://npm.cubos.io/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" + +private@^0.1.6: + version "0.1.7" + resolved "https://npm.cubos.io/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1" + +process-nextick-args@~1.0.6: + version "1.0.7" + resolved "https://npm.cubos.io/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" + +punycode@^1.4.1: + version "1.4.1" + resolved "https://npm.cubos.io/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + +qs@~6.4.0: + version "6.4.0" + resolved "https://npm.cubos.io/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" + +randomatic@^1.1.3: + version "1.1.6" + resolved "https://npm.cubos.io/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb" + dependencies: + is-number "^2.0.2" + kind-of "^3.0.2" + +rc@^1.1.7: + version "1.2.1" + resolved "https://npm.cubos.io/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95" + dependencies: + deep-extend "~0.4.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + +"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.2, readable-stream@^2.1.4: + version "2.2.9" + resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.9.tgz#cf78ec6f4a6d1eb43d26488cac97f042e74b7fc8" + dependencies: + buffer-shims "~1.0.0" + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~1.0.0" + util-deprecate "~1.0.1" + +readdirp@^2.0.0: + version "2.1.0" + resolved "https://npm.cubos.io/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78" + dependencies: + graceful-fs "^4.1.2" + minimatch "^3.0.2" + readable-stream "^2.0.2" + set-immediate-shim "^1.0.1" + +regenerate@^1.2.1: + version "1.3.2" + resolved "https://npm.cubos.io/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" + +regenerator-runtime@^0.10.0: + version "0.10.3" + resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.10.3.tgz#8c4367a904b51ea62a908ac310bf99ff90a82a3e" + +regenerator-transform@0.9.11: + version "0.9.11" + resolved "https://npm.cubos.io/regenerator-transform/-/regenerator-transform-0.9.11.tgz#3a7d067520cb7b7176769eb5ff868691befe1283" + dependencies: + babel-runtime "^6.18.0" + babel-types "^6.19.0" + private "^0.1.6" + +regex-cache@^0.4.2: + version "0.4.3" + resolved "https://npm.cubos.io/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" + dependencies: + is-equal-shallow "^0.1.3" + is-primitive "^2.0.0" + +regexpu-core@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240" + dependencies: + regenerate "^1.2.1" + regjsgen "^0.2.0" + regjsparser "^0.1.4" + +regjsgen@^0.2.0: + version "0.2.0" + resolved "https://npm.cubos.io/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" + +regjsparser@^0.1.4: + version "0.1.5" + resolved "https://npm.cubos.io/regjsparser/-/regjsparser-0.1.5.tgz#7ee8f84dc6fa792d3fd0ae228d24bd949ead205c" + dependencies: + jsesc "~0.5.0" + +remove-trailing-separator@^1.0.1: + version "1.0.1" + resolved "https://npm.cubos.io/remove-trailing-separator/-/remove-trailing-separator-1.0.1.tgz#615ebb96af559552d4bf4057c8436d486ab63cc4" + +repeat-element@^1.1.2: + version "1.1.2" + resolved "https://npm.cubos.io/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" + +repeat-string@^1.5.2: + version "1.6.1" + resolved "https://npm.cubos.io/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + +repeating@^2.0.0: + version "2.0.1" + resolved "https://npm.cubos.io/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + dependencies: + is-finite "^1.0.0" + +request@^2.81.0: + version "2.81.0" + resolved "https://npm.cubos.io/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" + dependencies: + aws-sign2 "~0.6.0" + aws4 "^1.2.1" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~4.2.1" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + oauth-sign "~0.8.1" + performance-now "^0.2.0" + qs "~6.4.0" + safe-buffer "^5.0.1" + stringstream "~0.0.4" + tough-cookie "~2.3.0" + tunnel-agent "^0.6.0" + uuid "^3.0.0" + +rimraf@2, rimraf@^2.5.1, rimraf@^2.6.1: + version "2.6.1" + resolved "https://npm.cubos.io/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" + dependencies: + glob "^7.0.5" + +safe-buffer@^5.0.1: + version "5.0.1" + resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" + +semver@^5.3.0: + version "5.3.0" + resolved "https://npm.cubos.io/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" + +set-blocking@~2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + +set-immediate-shim@^1.0.1: + version "1.0.1" + resolved "https://npm.cubos.io/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" + +signal-exit@^3.0.0: + version "3.0.2" + resolved "https://npm.cubos.io/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + +slash@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" + +sntp@1.x.x: + version "1.0.9" + resolved "https://npm.cubos.io/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" + dependencies: + hoek "2.x.x" + +source-map-support@^0.4.2: + version "0.4.14" + resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.14.tgz#9d4463772598b86271b4f523f6c1f4e02a7d6aef" + dependencies: + source-map "^0.5.6" + +source-map@^0.5.0, source-map@^0.5.6: + version "0.5.6" + resolved "https://npm.cubos.io/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" + +sshpk@^1.7.0: + version "1.11.0" + resolved "https://npm.cubos.io/sshpk/-/sshpk-1.11.0.tgz#2d8d5ebb4a6fab28ffba37fa62a90f4a3ea59d77" + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + dashdash "^1.12.0" + getpass "^0.1.1" + optionalDependencies: + bcrypt-pbkdf "^1.0.0" + ecc-jsbn "~0.1.1" + jodid25519 "^1.0.0" + jsbn "~0.1.0" + tweetnacl "~0.14.0" + +string-width@^1.0.1: + version "1.0.2" + resolved "https://npm.cubos.io/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +string_decoder@~1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/string_decoder/-/string_decoder-1.0.0.tgz#f06f41157b664d86069f84bdbdc9b0d8ab281667" + dependencies: + buffer-shims "~1.0.0" + +stringstream@~0.0.4: + version "0.0.5" + resolved "https://npm.cubos.io/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://npm.cubos.io/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://npm.cubos.io/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +tar-pack@^3.4.0: + version "3.4.0" + resolved "https://npm.cubos.io/tar-pack/-/tar-pack-3.4.0.tgz#23be2d7f671a8339376cbdb0b8fe3fdebf317984" + dependencies: + debug "^2.2.0" + fstream "^1.0.10" + fstream-ignore "^1.0.5" + once "^1.3.3" + readable-stream "^2.1.4" + rimraf "^2.5.1" + tar "^2.2.1" + uid-number "^0.0.6" + +tar@^2.2.1: + version "2.2.1" + resolved "https://npm.cubos.io/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" + dependencies: + block-stream "*" + fstream "^1.0.2" + inherits "2" + +to-fast-properties@^1.0.1: + version "1.0.2" + resolved "https://npm.cubos.io/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" + +tough-cookie@~2.3.0: + version "2.3.2" + resolved "https://npm.cubos.io/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" + dependencies: + punycode "^1.4.1" + +trim-right@^1.0.1: + version "1.0.1" + resolved "https://npm.cubos.io/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" + +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://npm.cubos.io/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + dependencies: + safe-buffer "^5.0.1" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://npm.cubos.io/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + +typescript@^2.2.1: + version "2.2.2" + resolved "https://npm.cubos.io/typescript/-/typescript-2.2.2.tgz#606022508479b55ffa368b58fee963a03dfd7b0c" + +uid-number@^0.0.6: + version "0.0.6" + resolved "https://npm.cubos.io/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" + +user-home@^1.1.1: + version "1.1.1" + resolved "https://npm.cubos.io/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://npm.cubos.io/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + +uuid@^3.0.0: + version "3.0.1" + resolved "https://npm.cubos.io/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" + +v8flags@^2.0.10: + version "2.0.12" + resolved "https://npm.cubos.io/v8flags/-/v8flags-2.0.12.tgz#73235d9f7176f8e8833fb286795445f7938d84e5" + dependencies: + user-home "^1.1.1" + +verror@1.3.6: + version "1.3.6" + resolved "https://npm.cubos.io/verror/-/verror-1.3.6.tgz#cff5df12946d297d2baaefaa2689e25be01c005c" + dependencies: + extsprintf "1.0.2" + +wide-align@^1.1.0: + version "1.1.0" + resolved "https://npm.cubos.io/wide-align/-/wide-align-1.1.0.tgz#40edde802a71fea1f070da3e62dcda2e7add96ad" + dependencies: + string-width "^1.0.1" + +wrappy@1: + version "1.0.2" + resolved "https://npm.cubos.io/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" From c1f0940c406924f7937c729327d6604e763f7f42 Mon Sep 17 00:00:00 2001 From: Victor Tavares-MBP Date: Mon, 10 Apr 2017 16:37:59 -0300 Subject: [PATCH 084/625] Improve swift target --- ast_semantic.cr | 1 + target_swift.cr | 3 +- target_swift_ios.cr | 77 ++++++++++++++++++++++++++++----------------- 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/ast_semantic.cr b/ast_semantic.cr index e0229d6..7fedfee 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -146,6 +146,7 @@ module AST def semantic errors << "Fatal" + errors << "Connection" error_types_enum = AST::EnumType.new error_types_enum.values = errors error_types_enum_def = AST::TypeDefinition.new diff --git a/target_swift.cr b/target_swift.cr index f26d991..4afce12 100644 --- a/target_swift.cr +++ b/target_swift.cr @@ -150,7 +150,8 @@ END when AST::OptionalType "APIInternal.isNull(value: #{src}) ? nil : (#{type_from_json(t.base, src)})" when AST::ArrayType - "(#{src} as! [AnyObject]).map({(el) -> #{native_type t.base} in return #{type_from_json t.base, "el"}})" + #"(#{src} as! [AnyObject]).map({(el) -> #{native_type t.base} in return #{type_from_json t.base, "el"}})" + "(#{src} as! [AnyObject]).map({ #{type_from_json t.base, "$0"} })" when AST::StructType "#{t.name}(json: #{src} as! [String: Any])" when AST::EnumType diff --git a/target_swift_ios.cr b/target_swift_ios.cr index bee8a9a..553285a 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -23,13 +23,10 @@ END args = op.args.map {|arg| "#{arg.name}: #{native_type arg.type}" } if op.return_type.is_a? AST::VoidPrimitiveType - args << "callback: ((_ error: APIInternal.Error?) -> Void)?" + args << "callback: ((_ result: APIInternal.Result) -> Void)?" else ret = op.return_type - unless ret.is_a? AST::OptionalType - ret = AST::OptionalType.new ret - end - args << "callback: ((_ result: #{native_type ret}, _ error: APIInternal.Error?) -> Void)?" + args << "callback: ((_ result: APIInternal.Result<#{native_type ret}>) -> Void)?" end @io << ident(String.build do |io| io << "static public func #{op.pretty_name}(#{args.join(", ")}) {\n" @@ -42,31 +39,53 @@ END end op.args.each do |arg| - io << "args[\"#{arg.name}\"] = #{type_to_json arg.type, arg.name}\n" + io << "args[\"#{arg.name}\"] = #{type_to_json arg.type, arg.name}\n\n" end - io << <<-END -APIInternal.makeRequest(#{op.pretty_name.inspect}, args) { result, error in - if error != nil { - callback?(#{"nil, " unless op.return_type.is_a? AST::VoidPrimitiveType}error); - } else { - callback?(#{"(#{type_from_json op.return_type, "result"}), " unless op.return_type.is_a? AST::VoidPrimitiveType}nil); - } -} + io << "APIInternal.makeRequest(#{op.pretty_name.inspect}, args) { response in \n" -END - end) + io << ident(String.build do |io| + io << "switch response {\n" + io << <<-END + case .failure(let error): + callback?(APIInternal.Result.failure(error))\n + END + + if op.return_type.is_a? AST::VoidPrimitiveType + io << <<-END + case .success: + callback?(APIInternal.Result.success())\n + END + else + io << <<-END + case .success(let value): + let returnObject = #{type_from_json(op.return_type, "value")} + callback?(APIInternal.Result.success(returnObject))\n + END + end + io << "}\n" + end) # end of make request body indentation. + + + + io << "}\n\n" + end) io << "}" end) @io << "\n\n" end + @io << <<-END } class APIInternal { - static var baseUrl = "api.nutriserie.com.br/user" + static var baseUrl = #{@ast.options.url.inspect} + enum Result { + case success(T) + case failure(Error) + } class Error { var type: API.ErrorType var message: String @@ -77,7 +96,7 @@ class APIInternal { } init(json: [String: Any]) { - self.type = API.ErrorType(rawValue: json["type"] as! String) ?? API.ErrorType.UnknownError + self.type = API.ErrorType(rawValue: json["type"] as! String) ?? API.ErrorType.Fatal self.message = json["message"] as! String } } @@ -166,32 +185,32 @@ class APIInternal { return value == nil || value is NSNull } - static func makeRequest(_ name: String, _ args: [String: Any], callback: @escaping (_ result: Any?, _ error: Error?) -> Void) { + static func makeRequest(_ name: String, _ args: [String: Any], callback: @escaping (Result) -> Void) { let api = SessionManager.default - + let body = [ - "id": randomBytesHex(len: 8), + "id": randomBytesHex(len: 16), "device": device(), "name": name, "args": args ] as [String : Any] - + api.request("https://\\(baseUrl)/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).responseJSON { response in - + guard let responseValue = response.result.value else { - callback(nil, Error(API.ErrorType.ConnectionError, "no result value")) + let error = Error(API.ErrorType.Connection, "no result value") + callback(Result.failure(error)) return } - + let response = HTTPResponse(json: responseValue as! [String: Any]) saveDeviceID(response.deviceId) - + guard response.error == nil && response.ok else { - callback(nil, response.error) + callback(Result.failure(response.error!)) return } - - callback(response.result, nil) + callback(Result.success(response.result)) } } } From 481128c2c9d4741cb0e621782f16edd34a530dcc Mon Sep 17 00:00:00 2001 From: Victor Tavares-MBP Date: Mon, 10 Apr 2017 16:40:15 -0300 Subject: [PATCH 085/625] Remove commented line. --- target_swift.cr | 1 - 1 file changed, 1 deletion(-) diff --git a/target_swift.cr b/target_swift.cr index 4afce12..44ee887 100644 --- a/target_swift.cr +++ b/target_swift.cr @@ -150,7 +150,6 @@ END when AST::OptionalType "APIInternal.isNull(value: #{src}) ? nil : (#{type_from_json(t.base, src)})" when AST::ArrayType - #"(#{src} as! [AnyObject]).map({(el) -> #{native_type t.base} in return #{type_from_json t.base, "el"}})" "(#{src} as! [AnyObject]).map({ #{type_from_json t.base, "$0"} })" when AST::StructType "#{t.name}(json: #{src} as! [String: Any])" From 13561ab9dbb023350cfa6680d0737403a6f3cd37 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 11 Apr 2017 09:33:18 -0300 Subject: [PATCH 086/625] Add replace --- rethinkdb/rethinkdb.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 1b2af2c..8e268ca 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -298,6 +298,7 @@ interface RTable extends RTableSlice { get(id: any): RTableRow insert & {returnChanges: true | "always"}>(obj: RInsertObj, options: Opts): RDatum insert(obj: RInsertObj, options?: R_InsertOptions): RDatum + replace(obj: RInsertObj): RDatum indexList(): RArray indexCreate(name: string, func: (obj: RDatum) => any, opts?: {multi?: boolean, geo?: boolean}): RDatum<{created: 1}> From 53bf6edbbe34d5d9d74226ea74c785ee33d3e20c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 11 Apr 2017 09:49:22 -0300 Subject: [PATCH 087/625] Add replace --- rethinkdb/rethinkdb.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 8e268ca..26ccc2d 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -250,6 +250,7 @@ interface RTableSlice extends RStream { update(obj: (obj: RDatum) => any, options?: R_UpdateOptions): RDatum update(obj: RUpdateObj, options: Opts): RDatum update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum + replace(obj: RInsertObj): RDatum delete(): RDatum<{}> filter(criteria: (obj: RDatum) => boolean | RDatum): RTableSlice filter(obj: DeepPartial>): RTableSlice @@ -260,6 +261,7 @@ interface RTableRow extends RDatum { update(obj: (obj: RDatum) => any, options?: R_UpdateOptions): RDatum update(obj: RUpdateObj, options: Opts): RDatum update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum + replace(obj: RInsertObj): RDatum delete(): RDatum<{}> } @@ -298,7 +300,6 @@ interface RTable extends RTableSlice { get(id: any): RTableRow insert & {returnChanges: true | "always"}>(obj: RInsertObj, options: Opts): RDatum insert(obj: RInsertObj, options?: R_InsertOptions): RDatum - replace(obj: RInsertObj): RDatum indexList(): RArray indexCreate(name: string, func: (obj: RDatum) => any, opts?: {multi?: boolean, geo?: boolean}): RDatum<{created: 1}> From 1ab067ed8329f467de288a101dc88daa8b8f26c3 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 11 Apr 2017 11:42:11 -0300 Subject: [PATCH 088/625] Support unnamed types under operation --- ast_semantic.cr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ast_semantic.cr b/ast_semantic.cr index 7fedfee..89189a5 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -109,6 +109,11 @@ module Semantic super end + def visit(operation : AST::Operation) + @path = [operation.name] + super + end + def visit(field : AST::Field) @path.push field.name super From 6c046329ecb88e9f2bda5e9c88185d4a19d386ff Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 11 Apr 2017 14:28:25 -0300 Subject: [PATCH 089/625] Fix java for enum&structs --- target_java.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target_java.cr b/target_java.cr index 0fbde67..40d6e83 100644 --- a/target_java.cr +++ b/target_java.cr @@ -129,8 +129,12 @@ END "#{src}.isNull(#{name}) ? null : #{get_field_from_json_object(t.base, src, name)}" when AST::ArrayType "#{src}.getJSONArray(#{name})" - when AST::TypeReference + when AST::EnumType + "#{src}.getString(#{name})" + when AST::StructType "#{src}.getJSONObject(#{name})" + when AST::TypeReference + get_field_from_json_object(t.type, src, name) else raise "Unknown type" end From 4f7f72659b1d9119fe1c78f542b55b74c6125b57 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 11 Apr 2017 18:16:05 -0300 Subject: [PATCH 090/625] Remove extra merge definition --- rethinkdb/rethinkdb.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 26ccc2d..5b06d02 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -106,7 +106,6 @@ interface RDatum extends RStreamOrDatum, PromiseLike { merge(op: (e: RDatum) => any): RDatum merge(op: any): RDatum map(func: (e: RDatum) => any): RArray - merge(func: (e: RDatum) => any): RArray concatMap(func: (e: RDatum) => any): RArray sub(other: any): RDatum div(other: any): RDatum From 1d791c457ac98ee8ed964b5cc2bf6b0d317e0842 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 11 Apr 2017 18:18:33 -0300 Subject: [PATCH 091/625] Correctly lex words --- lexer.cr | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/lexer.cr b/lexer.cr index e0449ff..55c418b 100644 --- a/lexer.cr +++ b/lexer.cr @@ -46,22 +46,22 @@ class Lexer return make_token(CommaSymbolToken.new) if literal_match(",") return make_token(EqualSymbolToken.new) if literal_match("=") - return make_token(ImportKeywordToken.new) if literal_match("import") - return make_token(TypeKeywordToken.new) if literal_match("type") - return make_token(EnumKeywordToken.new) if literal_match("enum") - return make_token(GetKeywordToken.new) if literal_match("get") - return make_token(FunctionKeywordToken.new) if literal_match("function") - return make_token(SubscribeKeywordToken.new) if literal_match("subscribe") - return make_token(ErrorKeywordToken.new) if literal_match("error") - return make_token(PrimitiveTypeToken.new("bool")) if literal_match("bool") - return make_token(PrimitiveTypeToken.new("int")) if literal_match("int") - return make_token(PrimitiveTypeToken.new("uint")) if literal_match("uint") - return make_token(PrimitiveTypeToken.new("float")) if literal_match("float") - return make_token(PrimitiveTypeToken.new("string")) if literal_match("string") - return make_token(PrimitiveTypeToken.new("datetime")) if literal_match("datetime") - return make_token(PrimitiveTypeToken.new("date")) if literal_match("date") - return make_token(PrimitiveTypeToken.new("bytes")) if literal_match("bytes") - return make_token(PrimitiveTypeToken.new("void")) if literal_match("void") + return make_token(ImportKeywordToken.new) if word_match("import") + return make_token(TypeKeywordToken.new) if word_match("type") + return make_token(EnumKeywordToken.new) if word_match("enum") + return make_token(GetKeywordToken.new) if word_match("get") + return make_token(FunctionKeywordToken.new) if word_match("function") + return make_token(SubscribeKeywordToken.new) if word_match("subscribe") + return make_token(ErrorKeywordToken.new) if word_match("error") + return make_token(PrimitiveTypeToken.new("bool")) if word_match("bool") + return make_token(PrimitiveTypeToken.new("int")) if word_match("int") + return make_token(PrimitiveTypeToken.new("uint")) if word_match("uint") + return make_token(PrimitiveTypeToken.new("float")) if word_match("float") + return make_token(PrimitiveTypeToken.new("string")) if word_match("string") + return make_token(PrimitiveTypeToken.new("datetime")) if word_match("datetime") + return make_token(PrimitiveTypeToken.new("date")) if word_match("date") + return make_token(PrimitiveTypeToken.new("bytes")) if word_match("bytes") + return make_token(PrimitiveTypeToken.new("void")) if word_match("void") if current_char!.letter? while current_char && (current_char!.letter? || current_char!.number?) @@ -131,9 +131,16 @@ class Lexer str.each_char.with_index.each do |c, i| return false unless @raw[@pos+i]? == c end + @pos += str.size end + private def word_match(str : String) + after = @raw[@pos+str.size]? + return false if after && after.letter? + return literal_match(str) + end + private def string_match unless current_char != "\"" raise LexerException.new("BUG: Expected string start here") From b386e242f3836267f369cd074262874b8ca01beb Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 11 Apr 2017 18:43:19 -0300 Subject: [PATCH 092/625] Fixes for java --- target_java.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target_java.cr b/target_java.cr index 40d6e83..38434ff 100644 --- a/target_java.cr +++ b/target_java.cr @@ -11,8 +11,8 @@ abstract class JavaTarget < Target when AST::IntPrimitiveType; "Integer" when AST::UIntPrimitiveType; "Integer" when AST::FloatPrimitiveType; "Double" - when AST::DatePrimitiveType; "Date" - when AST::DateTimePrimitiveType; "Date" + when AST::DatePrimitiveType; "Calendar" + when AST::DateTimePrimitiveType; "Calendar" when AST::BoolPrimitiveType; "Boolean" when AST::BytesPrimitiveType; "byte[]" when AST::VoidPrimitiveType; "void" @@ -153,7 +153,7 @@ END when AST::VoidPrimitiveType "null" when AST::OptionalType - "#{src} == null ? null : #{type_from_json(t.base, src)}" + type_from_json(t.base, src) when AST::ArrayType "new #{native_type t}() {{ JSONArray ary = #{src}; for (int i = 0; i < ary.length(); ++i) add(#{type_from_json(t.base, get_field_from_json_object(t.base, "ary", "i"))}); }}" when AST::StructType From 2d9bf89923ee9c71480910c550a2a097203826c4 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 11 Apr 2017 20:13:43 -0300 Subject: [PATCH 093/625] Allow get().eq(null) --- rethinkdb/rethinkdb.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 5b06d02..f989039 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -262,6 +262,8 @@ interface RTableRow extends RDatum { update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum replace(obj: RInsertObj): RDatum delete(): RDatum<{}> + eq(other: T | RDatum | null): RDatum + ne(other: T | RDatum | null): RDatum } interface R_InsertOptions { From f858b324d2eabf7ffb62972ec97206d0c54c39c6 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 11 Apr 2017 20:16:27 -0300 Subject: [PATCH 094/625] support multimaps --- rethinkdb/rethinkdb.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index f989039..3edc122 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -106,6 +106,8 @@ interface RDatum extends RStreamOrDatum, PromiseLike { merge(op: (e: RDatum) => any): RDatum merge(op: any): RDatum map(func: (e: RDatum) => any): RArray + map(other: RArray | RStream, func: (e: RDatum, x: RDatum) => any): RArray + map(other: any, func: (e: RDatum, x: RDatum) => any): RArray concatMap(func: (e: RDatum) => any): RArray sub(other: any): RDatum div(other: any): RDatum @@ -162,6 +164,8 @@ interface RArray extends RDatum { (idx: number | RDatum): RDatum (idx: K): RArray map(func: (e: RDatum) => any): RArray + map(other: RArray | RStream, func: (e: RDatum, x: RDatum) => any): RArray + map(other: any, func: (e: RDatum, x: RDatum) => any): RArray merge(func: (e: RDatum) => any): RArray concatMap(func: (e: RDatum) => any): RArray orderBy(field: keyof T | R_Sorting | ((e: RDatum) => any)): RArray @@ -198,6 +202,8 @@ interface RStream extends PromiseLike, RStreamOrDatum { (idx: number): RDatum (field: string): RArray map(func: (arg: RDatum) => any): RStream + map(other: RArray | RStream, func: (e: RDatum, x: RDatum) => any): RArray + map(other: any, func: (e: RDatum, x: RDatum) => any): RArray merge(func: (arg: RDatum) => any): RStream concatMap(func: (arg: RDatum) => any): RStream orderBy(field: keyof T | R_Sorting | ((e: RDatum) => any)): RArray From 44eca4e304515b465677e59a945bcd7717b81ebe Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 11 Apr 2017 20:27:19 -0300 Subject: [PATCH 095/625] change maven upload url --- target-android/api/build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target-android/api/build.gradle b/target-android/api/build.gradle index 8095238..8b83cd4 100644 --- a/target-android/api/build.gradle +++ b/target-android/api/build.gradle @@ -30,7 +30,11 @@ dependencies { publishing { repositories { maven { - url 'https://mymavenrepo.com/repo/4XBKk8BMCyMc24joS8Od/' + url 'https://maven.cubos.io/' + credentials { + username 'cubos' + password '4XBKk8BMCyMc24joS8Od' + } } } From 82903d934cf9f5dd17c1148155f2a2ce176f1fea Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 12 Apr 2017 06:05:09 -0300 Subject: [PATCH 096/625] Change maven url --- target-android/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target-android/build.gradle b/target-android/build.gradle index 1ea4bd0..026c200 100644 --- a/target-android/build.gradle +++ b/target-android/build.gradle @@ -15,6 +15,9 @@ buildscript { allprojects { repositories { jcenter() + maven { + url 'https://maven.cubos.io/4XBKk8BMCyMc24joS8Od/' + } } } From 09bdf60f90c6ba345bd307975f00444ab0276a18 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 12 Apr 2017 06:17:12 -0300 Subject: [PATCH 097/625] maven back to basic auth --- target-android/build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target-android/build.gradle b/target-android/build.gradle index 026c200..2e666f2 100644 --- a/target-android/build.gradle +++ b/target-android/build.gradle @@ -16,7 +16,11 @@ allprojects { repositories { jcenter() maven { - url 'https://maven.cubos.io/4XBKk8BMCyMc24joS8Od/' + url 'https://maven.cubos.io/' + credentials { + username 'cubos' + password '4XBKk8BMCyMc24joS8Od' + } } } } From f1c3a2b4fe0db928707c78cbd2bb73b313e5791f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 12 Apr 2017 07:25:10 -0300 Subject: [PATCH 098/625] Add without, pluck and fold --- rethinkdb/rethinkdb.d.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 3edc122..088511c 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -35,6 +35,8 @@ interface R extends RDB { range(count: number): RStream range(initial: number, count: number): RStream epochTime(epoch: number): RDatum + time(year: number | RDatum, month: number | RDatum, day: number | RDatum, tz: string | RDatum): RDatum + time(year: number | RDatum, month: number | RDatum, day: number | RDatum, hour: number | RDatum, minute: number | RDatum, second: number | RDatum, tz: string | RDatum): RDatum add(...objs: any[]): RDatum branch(c1: any, v1: any, otherwise: any): RDatum branch(c1: any, v1: any, c2: any, v2: any, otherwise: any): RDatum @@ -118,6 +120,8 @@ interface RDatum extends RStreamOrDatum, PromiseLike { round(): RDatum floor(): RDatum ceil(): RDatum + without(field: any): RDatum + pluck(...field: any[]): RDatum filter(criteria: (obj: any) => boolean | RDatum): RDatum filter(obj: any): RDatum @@ -134,6 +138,13 @@ interface RDatum extends RStreamOrDatum, PromiseLike { and(...objs: any[]): RDatum or(...objs: any[]): RDatum + year(): RDatum + month(): RDatum + day(): RDatum + hours(): RDatum + minutes(): RDatum + seconds(): RDatum + split(by: string): RArray coerceTo(type: "array"): RArray coerceTo(type: "string"): RDatum @@ -158,6 +169,8 @@ interface RDatum extends RStreamOrDatum, PromiseLike { group(idx: string): RGroupedStream ungroup(): RArray<{group: any, reduction: any}> forEach(func: (e: RDatum) => any): RDatum<{}> + + fold(base: any, func: (acc: RDatum, row: RDatum) => any, options?: {emit: (state: RDatum, row: RDatum, newState: RDatum) => any}): RDatum } interface RArray extends RDatum { From caad04bde6584ca83f6e16fb5dd715345ef8c2ac Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 12 Apr 2017 13:48:14 -0300 Subject: [PATCH 099/625] Reduce apicallid to 8 bytes --- target_swift_ios.cr | 16 ++++++++-------- target_typescript_nodeclient.cr | 2 +- target_typescript_web.cr | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/target_swift_ios.cr b/target_swift_ios.cr index 553285a..4f5cd40 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -64,8 +64,8 @@ END END end io << "}\n" - end) # end of make request body indentation. - + end) # end of make request body indentation. + io << "}\n\n" @@ -187,25 +187,25 @@ class APIInternal { static func makeRequest(_ name: String, _ args: [String: Any], callback: @escaping (Result) -> Void) { let api = SessionManager.default - + let body = [ - "id": randomBytesHex(len: 16), + "id": randomBytesHex(len: 8), "device": device(), "name": name, "args": args ] as [String : Any] - + api.request("https://\\(baseUrl)/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).responseJSON { response in - + guard let responseValue = response.result.value else { let error = Error(API.ErrorType.Connection, "no result value") callback(Result.failure(error)) return } - + let response = HTTPResponse(json: responseValue as! [String: Any]) saveDeviceID(response.deviceId) - + guard response.error == nil && response.ok else { callback(Result.failure(response.error!)) return diff --git a/target_typescript_nodeclient.cr b/target_typescript_nodeclient.cr index cf68e62..97f2ee2 100644 --- a/target_typescript_nodeclient.cr +++ b/target_typescript_nodeclient.cr @@ -108,7 +108,7 @@ function randomBytesHex(len: number) { async function makeRequest({name, args}: {name: string, args: any}) { return new Promise(async (resolve, reject) => { const body = { - id: randomBytesHex(16), + id: randomBytesHex(8), device: await device(), name: name, args: args diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 0e15eeb..24aa265 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -81,7 +81,7 @@ async function makeRequest({name, args}: {name: string, args: any}) { const req = new XMLHttpRequest(); req.open("POST", "https://" + baseUrl + "/" + name); const body = { - id: randomBytesHex(16), + id: randomBytesHex(8), device: device(), name: name, args: args From 20207d81d6cc942f31568d1e88985ed7ae993efe Mon Sep 17 00:00:00 2001 From: Victor Tavares-MBP Date: Wed, 12 Apr 2017 19:29:44 -0300 Subject: [PATCH 100/625] Fix enum types --- target_swift.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_swift.cr b/target_swift.cr index 44ee887..c208d2c 100644 --- a/target_swift.cr +++ b/target_swift.cr @@ -119,7 +119,7 @@ END when AST::StructType "#{t.name}()" when AST::EnumType - "#{t.name}(rawValue: \"\")" + "#{t.name}.#{t.values[0]}"#(rawValue: \"\")" when AST::TypeReference default_value(t.type) else @@ -154,7 +154,7 @@ END when AST::StructType "#{t.name}(json: #{src} as! [String: Any])" when AST::EnumType - "#{t.name}(rawValue: #{src} as! String)" + "#{t.name}(rawValue: #{src} as! String)!" when AST::TypeReference type_from_json(t.type, src) else From e105e9448daf6c0f2ac6c4234a4b2c9a2433df40 Mon Sep 17 00:00:00 2001 From: Victor Tavares-MBP Date: Thu, 13 Apr 2017 11:06:03 -0300 Subject: [PATCH 101/625] add Error protocol to ErrorType --- target_swift.cr | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target_swift.cr b/target_swift.cr index c208d2c..225a741 100644 --- a/target_swift.cr +++ b/target_swift.cr @@ -90,7 +90,12 @@ END def generate_enum_type(t) String.build do |io| - io << "enum #{t.name}: String {\n" + if t.name == "ErrorType" + io << "enum #{t.name}: String,Error {\n" + else + io << "enum #{t.name}: String {\n" + end + t.values.each do |value| io << ident "case #{value} = #{value.inspect}\n" end From 1a0381ced9a33d5d188ebc14394c4cc7ba02a685 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 13 Apr 2017 16:21:28 -0300 Subject: [PATCH 102/625] Go back to previous maven url --- target-android/build.gradle | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/target-android/build.gradle b/target-android/build.gradle index 2e666f2..7537247 100644 --- a/target-android/build.gradle +++ b/target-android/build.gradle @@ -16,11 +16,7 @@ allprojects { repositories { jcenter() maven { - url 'https://maven.cubos.io/' - credentials { - username 'cubos' - password '4XBKk8BMCyMc24joS8Od' - } + url 'https://mymavenrepo.com/repo/4XBKk8BMCyMc24joS8Od/' } } } From 850936e475d4b21409567f419a13fdcbe3b28575 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 13 Apr 2017 17:40:34 -0300 Subject: [PATCH 103/625] target android url --- target-android/build.gradle | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target-android/build.gradle b/target-android/build.gradle index 7537247..cef440c 100644 --- a/target-android/build.gradle +++ b/target-android/build.gradle @@ -15,9 +15,7 @@ buildscript { allprojects { repositories { jcenter() - maven { - url 'https://mymavenrepo.com/repo/4XBKk8BMCyMc24joS8Od/' - } + maven url 'https://mymavenrepo.com/repo/4XBKk8BMCyMc24joS8Od/' } } From 6609224778d60bd7f9384c42fe8be909eb3a30cc Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 13 Apr 2017 17:45:45 -0300 Subject: [PATCH 104/625] Change maven again --- target-android/build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target-android/build.gradle b/target-android/build.gradle index cef440c..7537247 100644 --- a/target-android/build.gradle +++ b/target-android/build.gradle @@ -15,7 +15,9 @@ buildscript { allprojects { repositories { jcenter() - maven url 'https://mymavenrepo.com/repo/4XBKk8BMCyMc24joS8Od/' + maven { + url 'https://mymavenrepo.com/repo/4XBKk8BMCyMc24joS8Od/' + } } } From 8d640a6fd0e7efce2e10bd2ff5a0b8c023afe4e8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 13 Apr 2017 17:51:18 -0300 Subject: [PATCH 105/625] Use better name for annonymus types --- ast_semantic.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ast_semantic.cr b/ast_semantic.cr index 89189a5..7c8aa08 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -115,18 +115,18 @@ module Semantic end def visit(field : AST::Field) - @path.push field.name + @path.push field.name[0].upcase + field.name[1..-1] super @path.pop end def visit(t : AST::StructType) - t.name = @path.join("_") + t.name = @path.join("") super end def visit(t : AST::EnumType) - t.name = @path.join("_") + t.name = @path.join("") super end end From 058ea0d6177cc08659864288a2286e231ab95f73 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 13 Apr 2017 17:58:20 -0300 Subject: [PATCH 106/625] Fix androdi --- target-android/api/build.gradle | 6 +----- target-android/build.gradle | 3 --- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/target-android/api/build.gradle b/target-android/api/build.gradle index 8b83cd4..8095238 100644 --- a/target-android/api/build.gradle +++ b/target-android/api/build.gradle @@ -30,11 +30,7 @@ dependencies { publishing { repositories { maven { - url 'https://maven.cubos.io/' - credentials { - username 'cubos' - password '4XBKk8BMCyMc24joS8Od' - } + url 'https://mymavenrepo.com/repo/4XBKk8BMCyMc24joS8Od/' } } diff --git a/target-android/build.gradle b/target-android/build.gradle index 7537247..1ea4bd0 100644 --- a/target-android/build.gradle +++ b/target-android/build.gradle @@ -15,9 +15,6 @@ buildscript { allprojects { repositories { jcenter() - maven { - url 'https://mymavenrepo.com/repo/4XBKk8BMCyMc24joS8Od/' - } } } From 197aaff94c286ea4d5d7b5d29f62bbfc39f76508 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 14 Apr 2017 14:23:44 -0300 Subject: [PATCH 107/625] Fix optional types on Android --- target_java.cr | 51 +++++++++++++----------------------------- target_java_android.cr | 2 +- 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/target_java.cr b/target_java.cr index 38434ff..eecadf8 100644 --- a/target_java.cr +++ b/target_java.cr @@ -87,7 +87,7 @@ public static #{t.name} fromJSON(final JSONObject json) { END t.fields.each do |field| - io << ident ident ident ident "#{field.name} = #{type_from_json field.type, get_field_from_json_object(field.type, "json", field.name.inspect)};\n" + io << ident ident ident ident "#{field.name} = #{type_from_json field.type, "json", field.name.inspect};\n" end io << ident <<-END @@ -113,55 +113,34 @@ END end end - def get_field_from_json_object(t : AST::Type, src : String, name : String) + def type_from_json(t : AST::Type, obj : String, name : String) case t - when AST::StringPrimitiveType, AST::DatePrimitiveType, AST::DateTimePrimitiveType, AST::BytesPrimitiveType - "#{src}.getString(#{name})" + when AST::StringPrimitiveType + "#{obj}.getString(#{name})" when AST::IntPrimitiveType, AST::UIntPrimitiveType - "#{src}.getInt(#{name})" + "#{obj}.getInt(#{name})" when AST::FloatPrimitiveType - "#{src}.getDouble(#{name})" + "#{obj}.getDouble(#{name})" when AST::BoolPrimitiveType - "#{src}.getBoolean(#{name})" - when AST::VoidPrimitiveType - "#{src}.get(#{name})" - when AST::OptionalType - "#{src}.isNull(#{name}) ? null : #{get_field_from_json_object(t.base, src, name)}" - when AST::ArrayType - "#{src}.getJSONArray(#{name})" - when AST::EnumType - "#{src}.getString(#{name})" - when AST::StructType - "#{src}.getJSONObject(#{name})" - when AST::TypeReference - get_field_from_json_object(t.type, src, name) - else - raise "Unknown type" - end - end - - def type_from_json(t : AST::Type, src : String) - case t - when AST::StringPrimitiveType, AST::IntPrimitiveType, AST::UIntPrimitiveType, AST::FloatPrimitiveType, AST::BoolPrimitiveType - "#{src}" + "#{obj}.getBoolean(#{name})" when AST::DatePrimitiveType - "Internal.decodeDate(#{src})" + "Internal.decodeDate(#{obj}.getString(#{name}))" when AST::DateTimePrimitiveType - "Internal.decodeDateTime(#{src})" + "Internal.decodeDateTime(#{obj}.getString(#{name}))" when AST::BytesPrimitiveType - "Base64.decode(#{src}, Base64.DEFAULT)" + "Base64.decode(#{obj}.getString(#{name}), Base64.DEFAULT)" when AST::VoidPrimitiveType "null" when AST::OptionalType - type_from_json(t.base, src) + "#{obj}.isNull(#{name}) ? null : #{type_from_json(t.base, obj, name)}" when AST::ArrayType - "new #{native_type t}() {{ JSONArray ary = #{src}; for (int i = 0; i < ary.length(); ++i) add(#{type_from_json(t.base, get_field_from_json_object(t.base, "ary", "i"))}); }}" + "new #{native_type t}() {{ JSONArray ary = #{obj}.getJSONArray(#{name}); for (int i = 0; i < ary.length(); ++i) add(#{type_from_json(t.base, "ary", "i")}); }}" when AST::StructType - "#{t.name}.fromJSON(#{src})" + "#{t.name}.fromJSON(#{obj}.getJSONObject(#{name}))" when AST::EnumType - "#{t.values.map {|v| "#{src} == #{v.inspect} ? #{t.name}.#{v} : " }.join}null" + "#{t.values.map {|v| "#{obj}.getString(#{name}) == #{v.inspect} ? #{t.name}.#{v} : " }.join}null" when AST::TypeReference - type_from_json(t.type, src) + type_from_json(t.type, obj, name) else raise "Unknown type" end diff --git a/target_java_android.cr b/target_java_android.cr index 6fdc1ba..7886a3b 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -104,7 +104,7 @@ END else io << <<-END try { - callback.onResult(#{type_from_json op.return_type, get_field_from_json_object(op.return_type, "result", "result".inspect)}); + callback.onResult(#{type_from_json op.return_type, "result", "result".inspect}); } catch (JSONException e) { e.printStackTrace(); callback.onError("bug", e.getMessage()); From b7d968cc7cc82c71992c3fc08f9e84a2d4317c15 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 14 Apr 2017 14:46:50 -0300 Subject: [PATCH 108/625] Take into account enum error types --- target_java_android.cr | 78 ++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 48 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 7886a3b..fa81c0f 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -82,8 +82,7 @@ END }}; } catch (JSONException e) { e.printStackTrace(); - callback.onFinished(); - callback.onError("bug", e.getMessage()); + callback.onResult(ErrorType.Fatal, e.getMessage()#{op.return_type.is_a?(AST::VoidPrimitiveType) ? "" : ", null"}); return; } END @@ -92,39 +91,34 @@ END Internal.makeRequest(#{op.pretty_name.inspect}, args, new Internal.RequestCallback() { @Override - public void onResult(final JSONObject result) { - callback.onFinished(); + public void onResult(final ErrorType type, final String message, final JSONObject result) { END if op.return_type.is_a? AST::VoidPrimitiveType io << <<-END - callback.onResult(); + if (type != null) { + callback.onResult(type, message); + } else { + callback.onResult(null, null); + } END else io << <<-END - try { - callback.onResult(#{type_from_json op.return_type, "result", "result".inspect}); - } catch (JSONException e) { - e.printStackTrace(); - callback.onError("bug", e.getMessage()); + if (type != null) { + callback.onResult(type, message, null); + } else { + try { + callback.onResult(null, null, #{type_from_json op.return_type, "result", "result".inspect}); + } catch (JSONException e) { + e.printStackTrace(); + callback.onResult(ErrorType.Fatal, e.getMessage(), null); + } } END end io << <<-END } - - @Override - public void onError(String type, String message) { - callback.onFinished(); - callback.onError(type, message); - } - - @Override - public void onFailure(String message) { - callback.onFinished(); - callback.onError("Connection", message); - } }); END end) @@ -136,33 +130,23 @@ END @io << <<-END public interface Callback { - void onFinished(); - void onResult(T result); - void onError(String type, String message); + void onResult(ErrorType error, String message, T result); } public interface IntCallback { - void onFinished(); - void onResult(int result); - void onError(String type, String message); + void onResult(ErrorType error, String message, int result); } public interface DoubleCallback { - void onFinished(); - void onResult(double result); - void onError(String type, String message); + void onResult(ErrorType error, String message, double result); } public interface BooleanCallback { - void onFinished(); - void onResult(boolean result); - void onError(String type, String message); + void onResult(ErrorType error, String message, boolean result); } public interface VoidCallback { - void onFinished(); - void onResult(); - void onError(String type, String message); + void onResult(ErrorType error, String message); } private static class Internal { @@ -277,9 +261,7 @@ END } private interface RequestCallback { - void onResult(JSONObject result); - void onError(String type, String message); - void onFailure(String message); + void onResult(ErrorType type, String message, JSONObject result); } private static void makeRequest(String name, JSONObject args, final RequestCallback callback) { @@ -293,7 +275,7 @@ END body.put("args", args); } catch (JSONException e) { e.printStackTrace(); - callback.onError("bug", e.getMessage()); + callback.onResult(ErrorType.Fatal, e.getMessage(), null); } Request request = new Request.Builder() @@ -308,7 +290,7 @@ END @Override public void run() { e.printStackTrace(); - callback.onFailure(e.getMessage()); + callback.onResult(ErrorType.Fatal, e.getMessage(), null); } }); } @@ -321,7 +303,7 @@ END public void run() { if (response.code() >= 500) { Log.e("API Fatal", stringBody); - callback.onFailure("HTTP " + response.code()); + callback.onResult(ErrorType.Fatal, "HTTP " + response.code(), null); return; } @@ -332,15 +314,15 @@ END pref.edit().putString("deviceId", body.getString("deviceId")).apply(); if (!body.getBoolean("ok")) { - String type = body.getJSONObject("error").getString("type"); - String message = body.getJSONObject("error").getString("message"); - callback.onError(type, message); + JSONObject error = body.getJSONObject("error"); + String message = error.getString("message"); + callback.onResult(#{type_from_json(@ast.enum_types.find {|e| e.name == "ErrorType"}.not_nil!, "error", "type".inspect)}, message, null); } else { - callback.onResult(body); + callback.onResult(null, null, body); } } catch (JSONException e) { e.printStackTrace(); - callback.onError("bug", e.getMessage()); + callback.onResult(ErrorType.Fatal, e.getMessage(), null); } } }); From 96b0e3075ff4f12a88e9a656391bb05be6464db8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 16 Apr 2017 14:26:10 -0300 Subject: [PATCH 109/625] Semantics for Bool --- ast_semantic.cr | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ast_semantic.cr b/ast_semantic.cr index 7c8aa08..087dff4 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -101,6 +101,19 @@ module Semantic end end + class CheckNamingForGettersReturningBool < Visitor + def visit(op : AST::GetOperation) + super + is_bool = op.return_type.is_a? AST::BoolPrimitiveType + has_bool_name = op.name =~ /^(is|has|can|may|should)/ + if is_bool && !has_bool_name + raise "Get operation '#{op.name}' returns bool but isn't named accordingly" + elsif !is_bool && has_bool_name + raise "Get operation '#{op.name}' doesn't return bool but its name suggest it does" + end + end + end + class GiveStructAndEnumTypeNames < Visitor @path = [] of String @@ -162,6 +175,7 @@ module AST Semantic::CheckEveryTypeDefined.new(self).visit(self) Semantic::CheckNoRecursiveTypes.new(self).visit(self) Semantic::CheckDontReturnSecret.new(self).visit(self) + Semantic::CheckNamingForGettersReturningBool.new(self).visit(self) Semantic::GiveStructAndEnumTypeNames.new(self).visit(self) Semantic::CollectStructAndEnumTypes.new(self).visit(self) end From bc0bb1574c95ef16b5962daef5880650d3e3dd99 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 16 Apr 2017 16:15:31 -0300 Subject: [PATCH 110/625] Parceable to java --- target_java.cr | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/target_java.cr b/target_java.cr index eecadf8..64c6193 100644 --- a/target_java.cr +++ b/target_java.cr @@ -59,7 +59,7 @@ abstract class JavaTarget < Target def generate_struct_type(t) String.build do |io| - io << "public static class #{t.name} {\n" + io << "public static class #{t.name} implements Parcelable {\n" t.fields.each do |field| io << ident "public #{native_type field.type} #{field.name};\n" end @@ -82,22 +82,52 @@ END } public static #{t.name} fromJSON(final JSONObject json) { - try { - return new #{t.name}() {{ + return new #{t.name}(json); +} +protected #{t.name}(final JSONObject json) { + try { END t.fields.each do |field| - io << ident ident ident ident "#{field.name} = #{type_from_json field.type, "json", field.name.inspect};\n" + io << ident ident ident "#{field.name} = #{type_from_json field.type, "json", field.name.inspect};\n" end io << ident <<-END - }}; } catch (JSONException e) { e.printStackTrace(); - return new #{t.name}(); } } +protected #{t.name}(Parcel in) { + try { + fromJSON(new JSONObject(in.readString())); + } catch (JSONException e) { + e.printStackTrace(); + } +} + +@Override +public void writeToParcel(Parcel dest, int flags) { + dest.writeString(toJSON().toString()); +} + +@Override +public int describeContents() { + return 0; +} + +public static final Parcelable.Creator<#{t.name}> CREATOR = new Parcelable.Creator<#{t.name}>() { + @Override + public #{t.name} createFromParcel(Parcel in) { + return new #{t.name}(in); + } + + @Override + public #{t.name}[] newArray(int size) { + return new #{t.name}[size]; + } +}; + END io << "}" end From 00d5b2ffe4bc2e8de34206e01b931292efe5fe31 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 16 Apr 2017 16:25:26 -0300 Subject: [PATCH 111/625] Add missing java imports --- target_java_android.cr | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target_java_android.cr b/target_java_android.cr index fa81c0f..44eafb4 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -13,6 +13,8 @@ import android.graphics.Point; import android.os.Build; import android.os.Handler; import android.os.Looper; +import android.os.Parcel; +import android.os.Parcelable; import android.provider.Settings; import android.util.Base64; import android.util.Log; From 50ff12c91bd963b1cb0818622721c0d40b0d15c9 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 16 Apr 2017 16:32:14 -0300 Subject: [PATCH 112/625] Warmup gradle on android build --- target-android/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/target-android/Dockerfile b/target-android/Dockerfile index 7bdd3c3..d76d321 100644 --- a/target-android/Dockerfile +++ b/target-android/Dockerfile @@ -1,5 +1,6 @@ FROM registry.cubos.io/cubos/android-builder WORKDIR /root ADD . /root/ +RUN ./gradlew assembleDebug ADD build_and_publish.sh / RUN chmod +x /build_and_publish.sh \ No newline at end of file From 2a89f2ad2f6d3d23a1813bd9bd8abbf36570a75c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 16 Apr 2017 22:47:59 -0300 Subject: [PATCH 113/625] Add public default ctor to java classes --- target_java.cr | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target_java.cr b/target_java.cr index 64c6193..3aa4f7e 100644 --- a/target_java.cr +++ b/target_java.cr @@ -85,6 +85,9 @@ public static #{t.name} fromJSON(final JSONObject json) { return new #{t.name}(json); } +public #{t.name}() { +} + protected #{t.name}(final JSONObject json) { try { END From 5f408219d96cd3e2b7d2826ae95aa637d317b25a Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 16 Apr 2017 23:49:02 -0300 Subject: [PATCH 114/625] Check database is available by running query --- target_typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 418281f..feb7477 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -95,7 +95,7 @@ export function start(port: number) { switch (req.method) { case "GET": { res.writeHead(200); - res.write(`{"ok": true}`); + res.write(await r.expr(`{"ok": true}`)); res.end(); break; } From 0fe44b591ce91a3f684e27bd76aac4372816b3ff Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 17 Apr 2017 11:00:26 -0300 Subject: [PATCH 115/625] Fix status check --- target_typescript_nodeserver.cr | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index feb7477..7b84f88 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -94,9 +94,11 @@ export function start(port: number) { switch (req.method) { case "GET": { - res.writeHead(200); - res.write(await r.expr(`{"ok": true}`)); - res.end(); + r.expr(`{"ok": true}`).then(result => { + res.writeHead(200); + res.write(result); + res.end(); + }); break; } case "POST": { From df27b2be08f5c12b4f8dc20d5eaa9b8944124a5e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 17 Apr 2017 12:15:20 -0300 Subject: [PATCH 116/625] Fix android enum to json --- target_java.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java.cr b/target_java.cr index 3aa4f7e..6791762 100644 --- a/target_java.cr +++ b/target_java.cr @@ -198,7 +198,7 @@ END when AST::StructType "#{src}.toJSON()" when AST::EnumType - "#{t.values.map {|v| "#{src} == #{t.name}.#{v} ? #{v.inspect} : " }.join}null" + "#{t.values.map {|v| "#{src} == #{t.name}.#{v} ? #{v.inspect} : " }.join}\"\"" when AST::TypeReference type_to_json(t.type, src) else From 907e97f7fd2f7d80e400b87cf46289901ebf3f24 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 17 Apr 2017 13:28:13 -0300 Subject: [PATCH 117/625] Fix parcel --- target_java.cr | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target_java.cr b/target_java.cr index 6791762..f64cb0c 100644 --- a/target_java.cr +++ b/target_java.cr @@ -103,7 +103,12 @@ END protected #{t.name}(Parcel in) { try { - fromJSON(new JSONObject(in.readString())); + final JSONOnject json = new JSONObject(in.readString()); +END + t.fields.each do |field| + io << ident ident ident "#{field.name} = #{type_from_json field.type, "json", field.name.inspect};\n" + end + io << ident <<-END } catch (JSONException e) { e.printStackTrace(); } From 62342f38b7bacc630c77ca9958d4c88028597c67 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 17 Apr 2017 13:31:08 -0300 Subject: [PATCH 118/625] Fix typo --- target_java.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java.cr b/target_java.cr index f64cb0c..4e461f4 100644 --- a/target_java.cr +++ b/target_java.cr @@ -103,7 +103,7 @@ END protected #{t.name}(Parcel in) { try { - final JSONOnject json = new JSONObject(in.readString()); + final JSONObject json = new JSONObject(in.readString()); END t.fields.each do |field| io << ident ident ident "#{field.name} = #{type_from_json field.type, "json", field.name.inspect};\n" From d74e85cfcbf3bd8cc934dad5edf09c3c09953605 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 17 Apr 2017 14:32:48 -0300 Subject: [PATCH 119/625] Fix java enum: compare with equals --- target_java.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java.cr b/target_java.cr index 4e461f4..94feb95 100644 --- a/target_java.cr +++ b/target_java.cr @@ -176,7 +176,7 @@ END when AST::StructType "#{t.name}.fromJSON(#{obj}.getJSONObject(#{name}))" when AST::EnumType - "#{t.values.map {|v| "#{obj}.getString(#{name}) == #{v.inspect} ? #{t.name}.#{v} : " }.join}null" + "#{t.values.map {|v| "#{obj}.getString(#{name}).equals(#{v.inspect}) ? #{t.name}.#{v} : " }.join}null" when AST::TypeReference type_from_json(t.type, obj, name) else From ad4c15e14f409de84e672ac1bcdc9f75dfb31e5c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 17 Apr 2017 14:35:59 -0300 Subject: [PATCH 120/625] Fix moment import --- target_typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 7b84f88..07d46ab 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -6,7 +6,7 @@ class TypeScriptServerTarget < TypeScriptTarget import http from "http"; import crypto from "crypto"; import os from "os"; -import moment from "moment"; +import * as moment from "moment"; import r from "../rethinkdb"; From c233a5b1361cf81796234b086b0e2f6115780b46 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 17 Apr 2017 14:46:55 -0300 Subject: [PATCH 121/625] bug -> Fatal --- target_typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 07d46ab..d739440 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -187,7 +187,7 @@ export function start(port: number) { }; } else { call.error = { - type: "bug", + type: "Fatal", message: err.toString() }; } From 704977a07d7b69d62fc66b2c6500f428639f81ad Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 17 Apr 2017 14:47:05 -0300 Subject: [PATCH 122/625] fix randomBytesHex --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 44eafb4..4cc0687 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -258,7 +258,7 @@ END private static String randomBytesHex(int len) { String str = new BigInteger(8 * len, random).toString(16); - while (str.length() < len) str = "0" + str; + while (str.length() < 2*len) str = "0" + str; return str; } From 806221a443e1d7762c50c7c6c5aefc7dc3aac75c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 17 Apr 2017 15:39:12 -0300 Subject: [PATCH 123/625] android: add staging --- target_java_android.cr | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 4cc0687..7ceb7e0 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -49,6 +49,7 @@ import okhttp3.RequestBody; import okhttp3.Response; public class API { + static public boolean useStaging = false; END @@ -281,7 +282,7 @@ END } Request request = new Request.Builder() - .url("https://" + baseUrl + "/" + name) + .url("https://" + baseUrl + (API.useStaging ? "-staging" : "") + "/" + name) .post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), body.toString())) .build(); From 49771030417055d1910e34c5e01f0c4fc3d58a9a Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 18 Apr 2017 13:43:51 -0300 Subject: [PATCH 124/625] Import moment direcly --- target_typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index d739440..6dab287 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -6,7 +6,7 @@ class TypeScriptServerTarget < TypeScriptTarget import http from "http"; import crypto from "crypto"; import os from "os"; -import * as moment from "moment"; +import moment from "moment"; import r from "../rethinkdb"; From f597322fc67faa6f588da229f765441078744a1d Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 18 Apr 2017 19:50:18 -0300 Subject: [PATCH 125/625] Fix array of nullable types on typescript --- target_typescript.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target_typescript.cr b/target_typescript.cr index 20e26df..5e059fe 100644 --- a/target_typescript.cr +++ b/target_typescript.cr @@ -22,7 +22,11 @@ abstract class TypeScriptTarget < Target end def native_type(t : AST::ArrayType) - native_type(t.base) + "[]" + if t.base.is_a? AST::OptionalType + "(#{native_type(t.base)})[]" + else + native_type(t.base) + "[]" + end end def native_type(t : AST::StructType | AST::EnumType) From 6a9319538963e9b198c5fe76e987affa440d43f3 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 18 Apr 2017 22:39:06 -0300 Subject: [PATCH 126/625] Add extra line break for java --- target_java.cr | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target_java.cr b/target_java.cr index 94feb95..bcf5569 100644 --- a/target_java.cr +++ b/target_java.cr @@ -90,6 +90,7 @@ public #{t.name}() { protected #{t.name}(final JSONObject json) { try { + END t.fields.each do |field| io << ident ident ident "#{field.name} = #{type_from_json field.type, "json", field.name.inspect};\n" @@ -104,6 +105,7 @@ END protected #{t.name}(Parcel in) { try { final JSONObject json = new JSONObject(in.readString()); + END t.fields.each do |field| io << ident ident ident "#{field.name} = #{type_from_json field.type, "json", field.name.inspect};\n" From ed9c2f8e511cce489a197814b04b1f0612996db2 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 19 Apr 2017 12:14:33 -0300 Subject: [PATCH 127/625] Implement Comparable --- target_java.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target_java.cr b/target_java.cr index bcf5569..5704230 100644 --- a/target_java.cr +++ b/target_java.cr @@ -59,12 +59,16 @@ abstract class JavaTarget < Target def generate_struct_type(t) String.build do |io| - io << "public static class #{t.name} implements Parcelable {\n" + io << "public static class #{t.name} implements Parcelable, Comparable<#{t.name}> {\n" t.fields.each do |field| io << ident "public #{native_type field.type} #{field.name};\n" end io << ident <<-END +public int compareTo(#{t.name} other) { + toJSON().toString().compareTo(other.toJSON().toString()); +} + public JSONObject toJSON() { try { return new JSONObject() {{ From 6fb4ad554660b48ddc93c02a79596d1be0a0c813 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 19 Apr 2017 12:17:38 -0300 Subject: [PATCH 128/625] Fix missing return --- target_java.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java.cr b/target_java.cr index 5704230..080708f 100644 --- a/target_java.cr +++ b/target_java.cr @@ -66,7 +66,7 @@ abstract class JavaTarget < Target io << ident <<-END public int compareTo(#{t.name} other) { - toJSON().toString().compareTo(other.toJSON().toString()); + return toJSON().toString().compareTo(other.toJSON().toString()); } public JSONObject toJSON() { From ac318dc0e3b9cd70c1a605cfa09d9b52e09a6e42 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 19 Apr 2017 16:23:47 -0300 Subject: [PATCH 129/625] android: do several request until one works --- target_java_android.cr | 88 +++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 7ceb7e0..c0b04af 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -286,51 +286,67 @@ END .post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), body.toString())) .build(); - http.newCall(request).enqueue(new okhttp3.Callback() { + final boolean shouldReceiveResponse[] = new boolean[1]; + shouldReceiveResponse[0] = true; + final Timer timer = new Timer(); + final TimerTask task = new TimerTask() { @Override - public void onFailure(Call call, final IOException e) { - new Handler(Looper.getMainLooper()).post(new Runnable() { + public void run() { + http.newCall(request).enqueue(new okhttp3.Callback() { @Override - public void run() { - e.printStackTrace(); - callback.onResult(ErrorType.Fatal, e.getMessage(), null); + public void onFailure(Call call, final IOException e) { + if (!shouldReceiveResponse[0]) return; + shouldReceiveResponse[0] = false; + timer.cancel(); + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + e.printStackTrace(); + callback.onResult(ErrorType.Fatal, e.getMessage(), null); + } + }); } - }); - } - @Override - public void onResponse(Call call, final Response response) throws IOException { - final String stringBody = response.body().string(); - new Handler(Looper.getMainLooper()).post(new Runnable() { @Override - public void run() { - if (response.code() >= 500) { - Log.e("API Fatal", stringBody); - callback.onResult(ErrorType.Fatal, "HTTP " + response.code(), null); - return; - } - - try { - JSONObject body = new JSONObject(stringBody); - - SharedPreferences pref = context().getSharedPreferences("api", Context.MODE_PRIVATE); - pref.edit().putString("deviceId", body.getString("deviceId")).apply(); - - if (!body.getBoolean("ok")) { - JSONObject error = body.getJSONObject("error"); - String message = error.getString("message"); - callback.onResult(#{type_from_json(@ast.enum_types.find {|e| e.name == "ErrorType"}.not_nil!, "error", "type".inspect)}, message, null); - } else { - callback.onResult(null, null, body); + public void onResponse(Call call, final Response response) throws IOException { + if (!shouldReceiveResponse[0]) return; + shouldReceiveResponse[0] = false; + timer.cancel(); + final String stringBody = response.body().string(); + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + if (response.code() >= 500) { + Log.e("API Fatal", stringBody); + callback.onResult(ErrorType.Fatal, "HTTP " + response.code(), null); + return; + } + + try { + JSONObject body = new JSONObject(stringBody); + + SharedPreferences pref = context().getSharedPreferences("api", Context.MODE_PRIVATE); + pref.edit().putString("deviceId", body.getString("deviceId")).apply(); + + if (!body.getBoolean("ok")) { + JSONObject error = body.getJSONObject("error"); + String message = error.getString("message"); + callback.onResult(#{type_from_json(@ast.enum_types.find {|e| e.name == "ErrorType"}.not_nil!, "error", "type".inspect)}, message, null); + } else { + callback.onResult(null, null, body); + } + } catch (JSONException e) { + e.printStackTrace(); + callback.onResult(ErrorType.Fatal, e.getMessage(), null); + } } - } catch (JSONException e) { - e.printStackTrace(); - callback.onResult(ErrorType.Fatal, e.getMessage(), null); - } + }); } }); } - }); + }; + + timer.schedule(task, 0, 1000); } static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); From cce68eb55fd1c8ecd5cc8902e13049fa86158223 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 19 Apr 2017 16:28:26 -0300 Subject: [PATCH 130/625] Add missing imports --- target_java_android.cr | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target_java_android.cr b/target_java_android.cr index c0b04af..031a450 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -18,6 +18,8 @@ import android.os.Parcelable; import android.provider.Settings; import android.util.Base64; import android.util.Log; +import java.util.Timer; +import java.util.TimerTask; import android.view.Display; import android.view.WindowManager; From f9dfe0ada0c1174de57c25c951ada49b057d7dce Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 19 Apr 2017 16:33:07 -0300 Subject: [PATCH 131/625] Add missing final --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 031a450..c7d2d26 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -283,7 +283,7 @@ END callback.onResult(ErrorType.Fatal, e.getMessage(), null); } - Request request = new Request.Builder() + final Request request = new Request.Builder() .url("https://" + baseUrl + (API.useStaging ? "-staging" : "") + "/" + name) .post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), body.toString())) .build(); From ac009c7d8ec1b8b6c59db748ec0421be0f0bebcf Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 20 Apr 2017 10:00:21 -0300 Subject: [PATCH 132/625] Add okhttp timeouts --- target_java_android.cr | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target_java_android.cr b/target_java_android.cr index c7d2d26..7fd025b 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -157,6 +157,9 @@ END private static class Internal { private static final String baseUrl = #{@ast.options.url.inspect}; private static final OkHttpClient http = new OkHttpClient.Builder() + .connectTimeout(3, TimeUnit.SECONDS) + .writeTimeout(3, TimeUnit.SECONDS) + .readTimeout(5, TimeUnit.SECONDS) .addNetworkInterceptor(new StethoInterceptor()) .build(); private static final SecureRandom random = new SecureRandom(); From a87595065a872a746c6665280f6802b1d9b4a2fd Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 20 Apr 2017 10:22:52 -0300 Subject: [PATCH 133/625] Add ping function and add getDeviceId for android --- ast_semantic.cr | 5 +++++ target_java_android.cr | 17 +++++++++++++++++ target_typescript_nodeserver.cr | 2 ++ 3 files changed, 24 insertions(+) diff --git a/ast_semantic.cr b/ast_semantic.cr index 087dff4..6ad38ab 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -172,6 +172,11 @@ module AST error_types_enum_def.type = error_types_enum type_definitions << error_types_enum_def + op = AST::FunctionOperation.new + op.name = "ping" + op.return_type = AST::StringPrimitiveType.new + operations << op + Semantic::CheckEveryTypeDefined.new(self).visit(self) Semantic::CheckNoRecursiveTypes.new(self).visit(self) Semantic::CheckDontReturnSecret.new(self).visit(self) diff --git a/target_java_android.cr b/target_java_android.cr index 7fd025b..5c87a73 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -154,6 +154,23 @@ END void onResult(ErrorType error, String message); } + static public void getDeviceId(final Callback callback) { + SharedPreferences pref = context().getSharedPreferences("api", Context.MODE_PRIVATE); + if (pref.contains("deviceId")) + callback.onResult(null, null, pref.getString("deviceId", null)); + else { + ping(new Callback { + @Override + public void onResult(ErrorType error, String message, String result) { + if (error != null) + callback.onResult(error, message, null); + else + getDeviceId(callback); + } + }); + } + } + private static class Internal { private static final String baseUrl = #{@ast.options.url.inspect}; private static final OkHttpClient http = new OkHttpClient.Builder() diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 6dab287..04e9f7d 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -243,6 +243,8 @@ export function start(port: number) { }); } +fn.ping = async (ctx: api.Context) => "pong"; + END end From 60b573355af2e1e3e9d2825036a55cb9ba354b4e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 20 Apr 2017 10:53:23 -0300 Subject: [PATCH 134/625] Fix generated node server --- target_typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 04e9f7d..07ea4ba 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -243,7 +243,7 @@ export function start(port: number) { }); } -fn.ping = async (ctx: api.Context) => "pong"; +fn.ping = async (ctx: Context) => "pong"; END From 871fb97b93847444a0559465ca1145a25e65c380 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 20 Apr 2017 10:58:27 -0300 Subject: [PATCH 135/625] Fix java syntax --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 5c87a73..895add0 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -159,7 +159,7 @@ END if (pref.contains("deviceId")) callback.onResult(null, null, pref.getString("deviceId", null)); else { - ping(new Callback { + ping(new Callback() { @Override public void onResult(ErrorType error, String message, String result) { if (error != null) From 962c4aa9649eb9797a4f893b58e598fa4559d9f9 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 20 Apr 2017 11:08:09 -0300 Subject: [PATCH 136/625] Java fixes --- target_java_android.cr | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 895add0..b35736b 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -18,8 +18,6 @@ import android.os.Parcelable; import android.provider.Settings; import android.util.Base64; import android.util.Log; -import java.util.Timer; -import java.util.TimerTask; import android.view.Display; import android.view.WindowManager; @@ -42,6 +40,9 @@ import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.TimeUnit; import okhttp3.Call; import okhttp3.MediaType; @@ -155,7 +156,7 @@ END } static public void getDeviceId(final Callback callback) { - SharedPreferences pref = context().getSharedPreferences("api", Context.MODE_PRIVATE); + SharedPreferences pref = Internal.context().getSharedPreferences("api", Context.MODE_PRIVATE); if (pref.contains("deviceId")) callback.onResult(null, null, pref.getString("deviceId", null)); else { @@ -172,22 +173,22 @@ END } private static class Internal { - private static final String baseUrl = #{@ast.options.url.inspect}; - private static final OkHttpClient http = new OkHttpClient.Builder() + static final String baseUrl = #{@ast.options.url.inspect}; + static final OkHttpClient http = new OkHttpClient.Builder() .connectTimeout(3, TimeUnit.SECONDS) .writeTimeout(3, TimeUnit.SECONDS) .readTimeout(5, TimeUnit.SECONDS) .addNetworkInterceptor(new StethoInterceptor()) .build(); - private static final SecureRandom random = new SecureRandom(); - private static boolean initialized = false; + static final SecureRandom random = new SecureRandom(); + static boolean initialized = false; - private static void initialize() { + static void initialize() { initialized = true; Stetho.initializeWithDefaults(context()); } - private static Context context() { + static Context context() { try { final Class activityThreadClass = Class.forName("android.app.ActivityThread"); @@ -202,7 +203,7 @@ END } } - private static String language() { + static String language() { Locale loc = Locale.getDefault(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return loc.toLanguageTag(); @@ -249,7 +250,7 @@ END } @SuppressLint("HardwareIds") - private static JSONObject device() throws JSONException { + static JSONObject device() throws JSONException { JSONObject device = new JSONObject(); device.put("type", "android"); device.put("fingerprint", "" + Settings.Secure.getString(context().getContentResolver(), Settings.Secure.ANDROID_ID)); @@ -279,17 +280,17 @@ END return device; } - private static String randomBytesHex(int len) { + static String randomBytesHex(int len) { String str = new BigInteger(8 * len, random).toString(16); while (str.length() < 2*len) str = "0" + str; return str; } - private interface RequestCallback { + interface RequestCallback { void onResult(ErrorType type, String message, JSONObject result); } - private static void makeRequest(String name, JSONObject args, final RequestCallback callback) { + static void makeRequest(String name, JSONObject args, final RequestCallback callback) { if (!initialized) initialize(); JSONObject body = new JSONObject(); From addf30814948f057ba288065568ee4bda0a2d864 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 20 Apr 2017 19:26:39 -0300 Subject: [PATCH 137/625] print error to stdout --- target_typescript_nodeserver.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 07ea4ba..9bd0ffe 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -179,6 +179,7 @@ export function start(port: number) { try { call.result = await fnExec[request.name](context, request.args); } catch (err) { + console.error(err); call.ok = false; if (err.type) { call.error = { From 6a03e56af146b8b1191bbbeaaf2d043b21da0009 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 20 Apr 2017 19:38:21 -0300 Subject: [PATCH 138/625] Change maven upload target --- target-android/api/build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target-android/api/build.gradle b/target-android/api/build.gradle index 8095238..6c15279 100644 --- a/target-android/api/build.gradle +++ b/target-android/api/build.gradle @@ -30,7 +30,11 @@ dependencies { publishing { repositories { maven { - url 'https://mymavenrepo.com/repo/4XBKk8BMCyMc24joS8Od/' + url 'https://maven.cubos.io/upload/' + credentials { + username "cubos" + password "4XBKk8BMCyMc24joS8Od" + } } } From 8a57dae95d6da14994efdcdd43749da63fd68827 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 21 Apr 2017 09:12:55 -0300 Subject: [PATCH 139/625] Correctly reply to HEAD --- target_typescript_nodeserver.cr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 9bd0ffe..b1b5b36 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -93,6 +93,11 @@ export function start(port: number) { res.setHeader("Content-Type", "application/json"); switch (req.method) { + case "HEAD": { + res.writeHead(200); + res.end(); + break; + } case "GET": { r.expr(`{"ok": true}`).then(result => { res.writeHead(200); From 1947f01a773c23dd76d8f6fee9ee86458dae68a8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 21 Apr 2017 09:33:45 -0300 Subject: [PATCH 140/625] Syntax fix for crystal 0.22.0 --- lexer.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lexer.cr b/lexer.cr index 55c418b..d54185a 100644 --- a/lexer.cr +++ b/lexer.cr @@ -167,7 +167,7 @@ class Lexer when 't' contents << '\t' when '"' - contents << '\"' + contents << '"' when '\\' contents << '\\' when nil From b35f9693ac01c54507d89bfaa6f34e354410ae2d Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 21 Apr 2017 12:28:52 -0300 Subject: [PATCH 141/625] Add run() --- rethinkdb/rethinkdb.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 088511c..c7ccf35 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -98,6 +98,7 @@ interface RStreamOrDatum { } interface RDatum extends RStreamOrDatum, PromiseLike { + run(): PromiseLike do(func: (obj: this) => X): RDatum do(func: (obj: this) => any): RDatum default(val: X): RDatum @@ -212,6 +213,7 @@ interface RArray extends RDatum { } interface RStream extends PromiseLike, RStreamOrDatum { + run(): PromiseLike (idx: number): RDatum (field: string): RArray map(func: (arg: RDatum) => any): RStream From 4e0b73129729bc0c41c149732437b1717aa57da3 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 21 Apr 2017 18:00:00 -0300 Subject: [PATCH 142/625] Support for group() with a function as argument --- rethinkdb/rethinkdb.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index c7ccf35..abaf58f 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -168,6 +168,7 @@ interface RDatum extends RStreamOrDatum, PromiseLike { max(idx: string): RDatum group(idx: string): RGroupedStream + group(func: (obj: RDatum) => any): RGroupedStream ungroup(): RArray<{group: any, reduction: any}> forEach(func: (e: RDatum) => any): RDatum<{}> @@ -209,6 +210,7 @@ interface RArray extends RDatum { max(idx: K): RDatum group(idx: K): RGroupedStream + group(func: (obj: RDatum) => any): RGroupedStream forEach(func: (e: RDatum) => any): RDatum<{}> } @@ -240,6 +242,7 @@ interface RStream extends PromiseLike, RStreamOrDatum { max(idx: K): RDatum group(idx: K): RGroupedStream + group(func: (obj: RDatum) => any): RGroupedStream forEach(func: (e: RDatum) => any): RDatum<{}> } From 24f04058ed24ab76a343b0c35cd32de872d60a4e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 22 Apr 2017 09:20:47 -0300 Subject: [PATCH 143/625] Fix npm license warning --- target-node/package.json | 1 + target-web/package.json | 1 + 2 files changed, 2 insertions(+) diff --git a/target-node/package.json b/target-node/package.json index 0b8f4b5..c70d5de 100644 --- a/target-node/package.json +++ b/target-node/package.json @@ -9,6 +9,7 @@ }, "main": "api.js", "types": "api.d.ts", + "license": "UNLICENSED", "babel": { "plugins": [ "transform-runtime" diff --git a/target-web/package.json b/target-web/package.json index 01d1ebf..6824d22 100644 --- a/target-web/package.json +++ b/target-web/package.json @@ -10,6 +10,7 @@ }, "main": "api.js", "types": "api.d.ts", + "license": "UNLICENSED", "babel": { "plugins": [ "transform-runtime" From bd6619ef72a0e3fa9443c6beaf100123919c618f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 22 Apr 2017 09:21:24 -0300 Subject: [PATCH 144/625] yarn upgrade --- target-node/yarn.lock | 56 ++-- target-web/yarn.lock | 668 +++++++++++++++++++++--------------------- 2 files changed, 356 insertions(+), 368 deletions(-) diff --git a/target-node/yarn.lock b/target-node/yarn.lock index e74112a..190dd8c 100644 --- a/target-node/yarn.lock +++ b/target-node/yarn.lock @@ -3,16 +3,16 @@ "@types/node@^7.0.8": - version "7.0.12" - resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.12.tgz#ae5f67a19c15f752148004db07cbbb372e69efc9" + version "7.0.13" + resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.13.tgz#1b0a53fe9ef9c3a5d061b126cc9b915bca43a3f5" abbrev@1: version "1.1.0" resolved "https://npm.cubos.io/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" ajv@^4.9.1: - version "4.11.6" - resolved "https://npm.cubos.io/ajv/-/ajv-4.11.6.tgz#947e93049790942b2a2d60a8289b28924d39f987" + version "4.11.7" + resolved "https://npm.cubos.io/ajv/-/ajv-4.11.7.tgz#8655a5d86d0824985cc471a1d913fb6729a0ec48" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" @@ -37,11 +37,11 @@ aproba@^1.0.3: resolved "https://npm.cubos.io/aproba/-/aproba-1.1.1.tgz#95d3600f07710aa0e9298c726ad5ecf2eacbabab" are-we-there-yet@~1.1.2: - version "1.1.2" - resolved "https://npm.cubos.io/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz#80e470e95a084794fe1899262c5667c6e88de1b3" + version "1.1.4" + resolved "https://npm.cubos.io/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz#bb5dca382bb94f05e15194373d16fd3ba1ca110d" dependencies: delegates "^1.0.0" - readable-stream "^2.0.0 || ^1.1.13" + readable-stream "^2.0.6" arr-diff@^2.0.0: version "2.0.0" @@ -50,8 +50,8 @@ arr-diff@^2.0.0: arr-flatten "^1.0.1" arr-flatten@^1.0.1: - version "1.0.1" - resolved "https://npm.cubos.io/arr-flatten/-/arr-flatten-1.0.1.tgz#e5ffe54d45e19f32f216e91eb99c8ce892bb604b" + version "1.0.3" + resolved "https://npm.cubos.io/arr-flatten/-/arr-flatten-1.0.3.tgz#a274ed85ac08849b6bd7847c4580745dc51adfb1" array-unique@^0.2.1: version "0.2.1" @@ -586,8 +586,8 @@ babel-types@^6.19.0, babel-types@^6.24.1: to-fast-properties "^1.0.1" babylon@^6.11.0, babylon@^6.15.0: - version "6.16.1" - resolved "https://npm.cubos.io/babylon/-/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3" + version "6.17.0" + resolved "https://npm.cubos.io/babylon/-/babylon-6.17.0.tgz#37da948878488b9c4e3c4038893fa3314b3fc932" balanced-match@^0.4.1: version "0.4.2" @@ -716,10 +716,10 @@ dashdash@^1.12.0: assert-plus "^1.0.0" debug@^2.1.1, debug@^2.2.0: - version "2.6.3" - resolved "https://npm.cubos.io/debug/-/debug-2.6.3.tgz#0f7eb8c30965ec08c72accfa0130c8b79984141d" + version "2.6.4" + resolved "https://npm.cubos.io/debug/-/debug-2.6.4.tgz#7586a9b3c39741c0282ae33445c4e8ac74734fe0" dependencies: - ms "0.7.2" + ms "0.7.3" deep-extend@~0.4.0: version "0.4.1" @@ -848,8 +848,8 @@ fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: rimraf "2" gauge@~2.7.1: - version "2.7.3" - resolved "https://npm.cubos.io/gauge/-/gauge-2.7.3.tgz#1c23855f962f17b3ad3d0dc7443f304542edfe09" + version "2.7.4" + resolved "https://npm.cubos.io/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" dependencies: aproba "^1.0.3" console-control-strings "^1.0.0" @@ -1175,13 +1175,13 @@ moment@^2.17.1: version "2.18.1" resolved "https://npm.cubos.io/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" -ms@0.7.2: - version "0.7.2" - resolved "https://npm.cubos.io/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" +ms@0.7.3: + version "0.7.3" + resolved "https://npm.cubos.io/ms/-/ms-0.7.3.tgz#708155a5e44e33f5fd0fc53e81d0d40a91be1fff" nan@^2.3.0: - version "2.6.1" - resolved "https://npm.cubos.io/nan/-/nan-2.6.1.tgz#8c84f7b14c96b89f57fbc838012180ec8ca39a01" + version "2.6.2" + resolved "https://npm.cubos.io/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" node-pre-gyp@^0.6.29: version "0.6.34" @@ -1320,7 +1320,7 @@ rc@^1.1.7: minimist "^1.2.0" strip-json-comments "~2.0.1" -"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.2, readable-stream@^2.1.4: +readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.4: version "2.2.9" resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.9.tgz#cf78ec6f4a6d1eb43d26488cac97f042e74b7fc8" dependencies: @@ -1474,8 +1474,8 @@ source-map@^0.5.0, source-map@^0.5.6: resolved "https://npm.cubos.io/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" sshpk@^1.7.0: - version "1.11.0" - resolved "https://npm.cubos.io/sshpk/-/sshpk-1.11.0.tgz#2d8d5ebb4a6fab28ffba37fa62a90f4a3ea59d77" + version "1.13.0" + resolved "https://npm.cubos.io/sshpk/-/sshpk-1.13.0.tgz#ff2a3e4fd04497555fed97b39a0fd82fafb3a33c" dependencies: asn1 "~0.2.3" assert-plus "^1.0.0" @@ -1566,8 +1566,8 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: resolved "https://npm.cubos.io/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" typescript@^2.2.1: - version "2.2.2" - resolved "https://npm.cubos.io/typescript/-/typescript-2.2.2.tgz#606022508479b55ffa368b58fee963a03dfd7b0c" + version "2.3.0" + resolved "https://npm.cubos.io/typescript/-/typescript-2.3.0.tgz#2e63e09284392bc8158a2444c33e2093795c0418" uid-number@^0.0.6: version "0.0.6" @@ -1586,8 +1586,8 @@ uuid@^3.0.0: resolved "https://npm.cubos.io/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" v8flags@^2.0.10: - version "2.0.12" - resolved "https://npm.cubos.io/v8flags/-/v8flags-2.0.12.tgz#73235d9f7176f8e8833fb286795445f7938d84e5" + version "2.1.1" + resolved "https://npm.cubos.io/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" dependencies: user-home "^1.1.1" diff --git a/target-web/yarn.lock b/target-web/yarn.lock index 04deb1a..de31340 100644 --- a/target-web/yarn.lock +++ b/target-web/yarn.lock @@ -3,8 +3,8 @@ "@types/node@^7.0.8": - version "7.0.8" - resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.8.tgz#25e4dd804b630c916ae671233e6d71f6ce18124a" + version "7.0.13" + resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.13.tgz#1b0a53fe9ef9c3a5d061b126cc9b915bca43a3f5" "@types/ua-parser-js@^0.7.30": version "0.7.30" @@ -15,8 +15,8 @@ abbrev@1: resolved "https://npm.cubos.io/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" ajv@^4.9.1: - version "4.11.5" - resolved "https://npm.cubos.io/ajv/-/ajv-4.11.5.tgz#b6ee74657b993a01dce44b7944d56f485828d5bd" + version "4.11.7" + resolved "https://npm.cubos.io/ajv/-/ajv-4.11.7.tgz#8655a5d86d0824985cc471a1d913fb6729a0ec48" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" @@ -41,11 +41,11 @@ aproba@^1.0.3: resolved "https://npm.cubos.io/aproba/-/aproba-1.1.1.tgz#95d3600f07710aa0e9298c726ad5ecf2eacbabab" are-we-there-yet@~1.1.2: - version "1.1.2" - resolved "https://npm.cubos.io/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz#80e470e95a084794fe1899262c5667c6e88de1b3" + version "1.1.4" + resolved "https://npm.cubos.io/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz#bb5dca382bb94f05e15194373d16fd3ba1ca110d" dependencies: delegates "^1.0.0" - readable-stream "^2.0.0 || ^1.1.13" + readable-stream "^2.0.6" arr-diff@^2.0.0: version "2.0.0" @@ -54,8 +54,8 @@ arr-diff@^2.0.0: arr-flatten "^1.0.1" arr-flatten@^1.0.1: - version "1.0.1" - resolved "https://npm.cubos.io/arr-flatten/-/arr-flatten-1.0.1.tgz#e5ffe54d45e19f32f216e91eb99c8ce892bb604b" + version "1.0.3" + resolved "https://npm.cubos.io/arr-flatten/-/arr-flatten-1.0.3.tgz#a274ed85ac08849b6bd7847c4580745dc51adfb1" array-unique@^0.2.1: version "0.2.1" @@ -94,12 +94,12 @@ aws4@^1.2.1: resolved "https://npm.cubos.io/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" babel-cli@^6.23.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-cli/-/babel-cli-6.24.0.tgz#a05ffd210dca0c288a26d5319c5ac8669a265ad0" + version "6.24.1" + resolved "https://npm.cubos.io/babel-cli/-/babel-cli-6.24.1.tgz#207cd705bba61489b2ea41b5312341cf6aca2283" dependencies: - babel-core "^6.24.0" + babel-core "^6.24.1" babel-polyfill "^6.23.0" - babel-register "^6.24.0" + babel-register "^6.24.1" babel-runtime "^6.22.0" commander "^2.8.1" convert-source-map "^1.1.0" @@ -122,19 +122,19 @@ babel-code-frame@^6.22.0: esutils "^2.0.2" js-tokens "^3.0.0" -babel-core@^6.24.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-core/-/babel-core-6.24.0.tgz#8f36a0a77f5c155aed6f920b844d23ba56742a02" +babel-core@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-core/-/babel-core-6.24.1.tgz#8c428564dce1e1f41fb337ec34f4c3b022b5ad83" dependencies: babel-code-frame "^6.22.0" - babel-generator "^6.24.0" - babel-helpers "^6.23.0" + babel-generator "^6.24.1" + babel-helpers "^6.24.1" babel-messages "^6.23.0" - babel-register "^6.24.0" + babel-register "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.1" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" babylon "^6.11.0" convert-source-map "^1.1.0" debug "^2.1.1" @@ -146,119 +146,119 @@ babel-core@^6.24.0: slash "^1.0.0" source-map "^0.5.0" -babel-generator@^6.24.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.24.0.tgz#eba270a8cc4ce6e09a61be43465d7c62c1f87c56" +babel-generator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.24.1.tgz#e715f486c58ded25649d888944d52aa07c5d9497" dependencies: babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-types "^6.23.0" + babel-types "^6.24.1" detect-indent "^4.0.0" jsesc "^1.3.0" lodash "^4.2.0" source-map "^0.5.0" trim-right "^1.0.1" -babel-helper-builder-binary-assignment-operator-visitor@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.22.0.tgz#29df56be144d81bdeac08262bfa41d2c5e91cdcd" +babel-helper-builder-binary-assignment-operator-visitor@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz#cce4517ada356f4220bcae8a02c2b346f9a56664" dependencies: - babel-helper-explode-assignable-expression "^6.22.0" + babel-helper-explode-assignable-expression "^6.24.1" babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" -babel-helper-call-delegate@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-call-delegate/-/babel-helper-call-delegate-6.22.0.tgz#119921b56120f17e9dae3f74b4f5cc7bcc1b37ef" +babel-helper-call-delegate@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz#ece6aacddc76e41c3461f88bfc575bd0daa2df8d" dependencies: - babel-helper-hoist-variables "^6.22.0" + babel-helper-hoist-variables "^6.24.1" babel-runtime "^6.22.0" - babel-traverse "^6.22.0" - babel-types "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-helper-define-map@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-helper-define-map/-/babel-helper-define-map-6.23.0.tgz#1444f960c9691d69a2ced6a205315f8fd00804e7" +babel-helper-define-map@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-define-map/-/babel-helper-define-map-6.24.1.tgz#7a9747f258d8947d32d515f6aa1c7bd02204a080" dependencies: - babel-helper-function-name "^6.23.0" + babel-helper-function-name "^6.24.1" babel-runtime "^6.22.0" - babel-types "^6.23.0" + babel-types "^6.24.1" lodash "^4.2.0" -babel-helper-explode-assignable-expression@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.22.0.tgz#c97bf76eed3e0bae4048121f2b9dae1a4e7d0478" +babel-helper-explode-assignable-expression@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz#f25b82cf7dc10433c55f70592d5746400ac22caa" dependencies: babel-runtime "^6.22.0" - babel-traverse "^6.22.0" - babel-types "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-helper-function-name@^6.22.0, babel-helper-function-name@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-helper-function-name/-/babel-helper-function-name-6.23.0.tgz#25742d67175c8903dbe4b6cb9d9e1fcb8dcf23a6" +babel-helper-function-name@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" dependencies: - babel-helper-get-function-arity "^6.22.0" + babel-helper-get-function-arity "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-helper-get-function-arity@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.22.0.tgz#0beb464ad69dc7347410ac6ade9f03a50634f5ce" +babel-helper-get-function-arity@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" -babel-helper-hoist-variables@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.22.0.tgz#3eacbf731d80705845dd2e9718f600cfb9b4ba72" +babel-helper-hoist-variables@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz#1ecb27689c9d25513eadbc9914a73f5408be7a76" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" -babel-helper-optimise-call-expression@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.23.0.tgz#f3ee7eed355b4282138b33d02b78369e470622f5" +babel-helper-optimise-call-expression@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz#f7a13427ba9f73f8f4fa993c54a97882d1244257" dependencies: babel-runtime "^6.22.0" - babel-types "^6.23.0" + babel-types "^6.24.1" -babel-helper-regex@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-regex/-/babel-helper-regex-6.22.0.tgz#79f532be1647b1f0ee3474b5f5c3da58001d247d" +babel-helper-regex@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-regex/-/babel-helper-regex-6.24.1.tgz#d36e22fab1008d79d88648e32116868128456ce8" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" lodash "^4.2.0" -babel-helper-remap-async-to-generator@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.22.0.tgz#2186ae73278ed03b8b15ced089609da981053383" +babel-helper-remap-async-to-generator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" dependencies: - babel-helper-function-name "^6.22.0" + babel-helper-function-name "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.22.0" - babel-traverse "^6.22.0" - babel-types "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-helper-replace-supers@^6.22.0, babel-helper-replace-supers@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-helper-replace-supers/-/babel-helper-replace-supers-6.23.0.tgz#eeaf8ad9b58ec4337ca94223bacdca1f8d9b4bfd" +babel-helper-replace-supers@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz#bf6dbfe43938d17369a213ca8a8bf74b6a90ab1a" dependencies: - babel-helper-optimise-call-expression "^6.23.0" + babel-helper-optimise-call-expression "^6.24.1" babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-helpers@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-helpers/-/babel-helpers-6.23.0.tgz#4f8f2e092d0b6a8808a4bde79c27f1e2ecf0d992" +babel-helpers@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" dependencies: babel-runtime "^6.22.0" - babel-template "^6.23.0" + babel-template "^6.24.1" babel-messages@^6.23.0: version "6.23.0" @@ -284,11 +284,11 @@ babel-plugin-syntax-trailing-function-commas@^6.22.0: version "6.22.0" resolved "https://npm.cubos.io/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" -babel-plugin-transform-async-to-generator@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.22.0.tgz#194b6938ec195ad36efc4c33a971acf00d8cd35e" +babel-plugin-transform-async-to-generator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761" dependencies: - babel-helper-remap-async-to-generator "^6.22.0" + babel-helper-remap-async-to-generator "^6.24.1" babel-plugin-syntax-async-functions "^6.8.0" babel-runtime "^6.22.0" @@ -304,36 +304,36 @@ babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-block-scoping@^6.22.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.23.0.tgz#e48895cf0b375be148cd7c8879b422707a053b51" +babel-plugin-transform-es2015-block-scoping@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.24.1.tgz#76c295dc3a4741b1665adfd3167215dcff32a576" dependencies: babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" lodash "^4.2.0" -babel-plugin-transform-es2015-classes@^6.22.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.23.0.tgz#49b53f326202a2fd1b3bbaa5e2edd8a4f78643c1" +babel-plugin-transform-es2015-classes@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db" dependencies: - babel-helper-define-map "^6.23.0" - babel-helper-function-name "^6.23.0" - babel-helper-optimise-call-expression "^6.23.0" - babel-helper-replace-supers "^6.23.0" + babel-helper-define-map "^6.24.1" + babel-helper-function-name "^6.24.1" + babel-helper-optimise-call-expression "^6.24.1" + babel-helper-replace-supers "^6.24.1" babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-plugin-transform-es2015-computed-properties@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.22.0.tgz#7c383e9629bba4820c11b0425bdd6290f7f057e7" +babel-plugin-transform-es2015-computed-properties@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz#6fe2a8d16895d5634f4cd999b6d3480a308159b3" dependencies: babel-runtime "^6.22.0" - babel-template "^6.22.0" + babel-template "^6.24.1" babel-plugin-transform-es2015-destructuring@^6.22.0: version "6.23.0" @@ -341,12 +341,12 @@ babel-plugin-transform-es2015-destructuring@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-duplicate-keys@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.22.0.tgz#672397031c21610d72dd2bbb0ba9fb6277e1c36b" +babel-plugin-transform-es2015-duplicate-keys@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz#73eb3d310ca969e3ef9ec91c53741a6f1576423e" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" babel-plugin-transform-es2015-for-of@^6.22.0: version "6.23.0" @@ -354,13 +354,13 @@ babel-plugin-transform-es2015-for-of@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-function-name@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.22.0.tgz#f5fcc8b09093f9a23c76ac3d9e392c3ec4b77104" +babel-plugin-transform-es2015-function-name@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz#834c89853bc36b1af0f3a4c5dbaa94fd8eacaa8b" dependencies: - babel-helper-function-name "^6.22.0" + babel-helper-function-name "^6.24.1" babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" babel-plugin-transform-es2015-literals@^6.22.0: version "6.22.0" @@ -368,63 +368,63 @@ babel-plugin-transform-es2015-literals@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-modules-amd@^6.24.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.0.tgz#a1911fb9b7ec7e05a43a63c5995007557bcf6a2e" +babel-plugin-transform-es2015-modules-amd@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154" dependencies: - babel-plugin-transform-es2015-modules-commonjs "^6.24.0" + babel-plugin-transform-es2015-modules-commonjs "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.22.0" + babel-template "^6.24.1" -babel-plugin-transform-es2015-modules-commonjs@^6.24.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.24.0.tgz#e921aefb72c2cc26cb03d107626156413222134f" +babel-plugin-transform-es2015-modules-commonjs@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.24.1.tgz#d3e310b40ef664a36622200097c6d440298f2bfe" dependencies: - babel-plugin-transform-strict-mode "^6.22.0" + babel-plugin-transform-strict-mode "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-types "^6.24.1" -babel-plugin-transform-es2015-modules-systemjs@^6.22.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.23.0.tgz#ae3469227ffac39b0310d90fec73bfdc4f6317b0" +babel-plugin-transform-es2015-modules-systemjs@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" dependencies: - babel-helper-hoist-variables "^6.22.0" + babel-helper-hoist-variables "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" + babel-template "^6.24.1" -babel-plugin-transform-es2015-modules-umd@^6.24.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.0.tgz#fd5fa63521cae8d273927c3958afd7c067733450" +babel-plugin-transform-es2015-modules-umd@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz#ac997e6285cd18ed6176adb607d602344ad38468" dependencies: - babel-plugin-transform-es2015-modules-amd "^6.24.0" + babel-plugin-transform-es2015-modules-amd "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" + babel-template "^6.24.1" -babel-plugin-transform-es2015-object-super@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.22.0.tgz#daa60e114a042ea769dd53fe528fc82311eb98fc" +babel-plugin-transform-es2015-object-super@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz#24cef69ae21cb83a7f8603dad021f572eb278f8d" dependencies: - babel-helper-replace-supers "^6.22.0" + babel-helper-replace-supers "^6.24.1" babel-runtime "^6.22.0" -babel-plugin-transform-es2015-parameters@^6.22.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.23.0.tgz#3a2aabb70c8af945d5ce386f1a4250625a83ae3b" +babel-plugin-transform-es2015-parameters@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" dependencies: - babel-helper-call-delegate "^6.22.0" - babel-helper-get-function-arity "^6.22.0" + babel-helper-call-delegate "^6.24.1" + babel-helper-get-function-arity "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-plugin-transform-es2015-shorthand-properties@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.22.0.tgz#8ba776e0affaa60bff21e921403b8a652a2ff723" +babel-plugin-transform-es2015-shorthand-properties@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz#24f875d6721c87661bbd99a4622e51f14de38aa0" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" babel-plugin-transform-es2015-spread@^6.22.0: version "6.22.0" @@ -432,13 +432,13 @@ babel-plugin-transform-es2015-spread@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-sticky-regex@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.22.0.tgz#ab316829e866ee3f4b9eb96939757d19a5bc4593" +babel-plugin-transform-es2015-sticky-regex@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz#00c1cdb1aca71112cdf0cf6126c2ed6b457ccdbc" dependencies: - babel-helper-regex "^6.22.0" + babel-helper-regex "^6.24.1" babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" babel-plugin-transform-es2015-template-literals@^6.22.0: version "6.22.0" @@ -452,27 +452,27 @@ babel-plugin-transform-es2015-typeof-symbol@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-unicode-regex@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.22.0.tgz#8d9cc27e7ee1decfe65454fb986452a04a613d20" +babel-plugin-transform-es2015-unicode-regex@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz#d38b12f42ea7323f729387f18a7c5ae1faeb35e9" dependencies: - babel-helper-regex "^6.22.0" + babel-helper-regex "^6.24.1" babel-runtime "^6.22.0" regexpu-core "^2.0.0" -babel-plugin-transform-exponentiation-operator@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.22.0.tgz#d57c8335281918e54ef053118ce6eb108468084d" +babel-plugin-transform-exponentiation-operator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz#2ab0c9c7f3098fa48907772bb813fe41e8de3a0e" dependencies: - babel-helper-builder-binary-assignment-operator-visitor "^6.22.0" + babel-helper-builder-binary-assignment-operator-visitor "^6.24.1" babel-plugin-syntax-exponentiation-operator "^6.8.0" babel-runtime "^6.22.0" -babel-plugin-transform-regenerator@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.22.0.tgz#65740593a319c44522157538d690b84094617ea6" +babel-plugin-transform-regenerator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.24.1.tgz#b8da305ad43c3c99b4848e4fe4037b770d23c418" dependencies: - regenerator-transform "0.9.8" + regenerator-transform "0.9.11" babel-plugin-transform-runtime@^6.23.0: version "6.23.0" @@ -480,12 +480,12 @@ babel-plugin-transform-runtime@^6.23.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-strict-mode@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.22.0.tgz#e008df01340fdc87e959da65991b7e05970c8c7c" +babel-plugin-transform-strict-mode@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" babel-polyfill@^6.23.0: version "6.23.0" @@ -496,52 +496,52 @@ babel-polyfill@^6.23.0: regenerator-runtime "^0.10.0" babel-preset-es2015@^6.22.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-preset-es2015/-/babel-preset-es2015-6.24.0.tgz#c162d68b1932696e036cd3110dc1ccd303d2673a" + version "6.24.1" + resolved "https://npm.cubos.io/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz#d44050d6bc2c9feea702aaf38d727a0210538939" dependencies: babel-plugin-check-es2015-constants "^6.22.0" babel-plugin-transform-es2015-arrow-functions "^6.22.0" babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoping "^6.22.0" - babel-plugin-transform-es2015-classes "^6.22.0" - babel-plugin-transform-es2015-computed-properties "^6.22.0" + babel-plugin-transform-es2015-block-scoping "^6.24.1" + babel-plugin-transform-es2015-classes "^6.24.1" + babel-plugin-transform-es2015-computed-properties "^6.24.1" babel-plugin-transform-es2015-destructuring "^6.22.0" - babel-plugin-transform-es2015-duplicate-keys "^6.22.0" + babel-plugin-transform-es2015-duplicate-keys "^6.24.1" babel-plugin-transform-es2015-for-of "^6.22.0" - babel-plugin-transform-es2015-function-name "^6.22.0" + babel-plugin-transform-es2015-function-name "^6.24.1" babel-plugin-transform-es2015-literals "^6.22.0" - babel-plugin-transform-es2015-modules-amd "^6.24.0" - babel-plugin-transform-es2015-modules-commonjs "^6.24.0" - babel-plugin-transform-es2015-modules-systemjs "^6.22.0" - babel-plugin-transform-es2015-modules-umd "^6.24.0" - babel-plugin-transform-es2015-object-super "^6.22.0" - babel-plugin-transform-es2015-parameters "^6.22.0" - babel-plugin-transform-es2015-shorthand-properties "^6.22.0" + babel-plugin-transform-es2015-modules-amd "^6.24.1" + babel-plugin-transform-es2015-modules-commonjs "^6.24.1" + babel-plugin-transform-es2015-modules-systemjs "^6.24.1" + babel-plugin-transform-es2015-modules-umd "^6.24.1" + babel-plugin-transform-es2015-object-super "^6.24.1" + babel-plugin-transform-es2015-parameters "^6.24.1" + babel-plugin-transform-es2015-shorthand-properties "^6.24.1" babel-plugin-transform-es2015-spread "^6.22.0" - babel-plugin-transform-es2015-sticky-regex "^6.22.0" + babel-plugin-transform-es2015-sticky-regex "^6.24.1" babel-plugin-transform-es2015-template-literals "^6.22.0" babel-plugin-transform-es2015-typeof-symbol "^6.22.0" - babel-plugin-transform-es2015-unicode-regex "^6.22.0" - babel-plugin-transform-regenerator "^6.22.0" + babel-plugin-transform-es2015-unicode-regex "^6.24.1" + babel-plugin-transform-regenerator "^6.24.1" babel-preset-es2016@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-preset-es2016/-/babel-preset-es2016-6.22.0.tgz#b061aaa3983d40c9fbacfa3743b5df37f336156c" + version "6.24.1" + resolved "https://npm.cubos.io/babel-preset-es2016/-/babel-preset-es2016-6.24.1.tgz#f900bf93e2ebc0d276df9b8ab59724ebfd959f8b" dependencies: - babel-plugin-transform-exponentiation-operator "^6.22.0" + babel-plugin-transform-exponentiation-operator "^6.24.1" babel-preset-es2017@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-preset-es2017/-/babel-preset-es2017-6.22.0.tgz#de2f9da5a30c50d293fb54a0ba15d6ddc573f0f2" + version "6.24.1" + resolved "https://npm.cubos.io/babel-preset-es2017/-/babel-preset-es2017-6.24.1.tgz#597beadfb9f7f208bcfd8a12e9b2b29b8b2f14d1" dependencies: babel-plugin-syntax-trailing-function-commas "^6.22.0" - babel-plugin-transform-async-to-generator "^6.22.0" + babel-plugin-transform-async-to-generator "^6.24.1" -babel-register@^6.24.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-register/-/babel-register-6.24.0.tgz#5e89f8463ba9970356d02eb07dabe3308b080cfd" +babel-register@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-register/-/babel-register-6.24.1.tgz#7e10e13a2f71065bdfad5a1787ba45bca6ded75f" dependencies: - babel-core "^6.24.0" + babel-core "^6.24.1" babel-runtime "^6.22.0" core-js "^2.4.0" home-or-tmp "^2.0.0" @@ -556,33 +556,33 @@ babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0: core-js "^2.4.0" regenerator-runtime "^0.10.0" -babel-template@^6.22.0, babel-template@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-template/-/babel-template-6.23.0.tgz#04d4f270adbb3aa704a8143ae26faa529238e638" +babel-template@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-template/-/babel-template-6.24.1.tgz#04ae514f1f93b3a2537f2a0f60a5a45fb8308333" dependencies: babel-runtime "^6.22.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" babylon "^6.11.0" lodash "^4.2.0" -babel-traverse@^6.22.0, babel-traverse@^6.23.0, babel-traverse@^6.23.1: - version "6.23.1" - resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.23.1.tgz#d3cb59010ecd06a97d81310065f966b699e14f48" +babel-traverse@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.24.1.tgz#ab36673fd356f9a0948659e7b338d5feadb31695" dependencies: babel-code-frame "^6.22.0" babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-types "^6.23.0" + babel-types "^6.24.1" babylon "^6.15.0" debug "^2.2.0" globals "^9.0.0" invariant "^2.2.0" lodash "^4.2.0" -babel-types@^6.19.0, babel-types@^6.22.0, babel-types@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-types/-/babel-types-6.23.0.tgz#bb17179d7538bad38cd0c9e115d340f77e7e9acf" +babel-types@^6.19.0, babel-types@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-types/-/babel-types-6.24.1.tgz#a136879dc15b3606bda0d90c1fc74304c2ff0975" dependencies: babel-runtime "^6.22.0" esutils "^2.0.2" @@ -590,8 +590,8 @@ babel-types@^6.19.0, babel-types@^6.22.0, babel-types@^6.23.0: to-fast-properties "^1.0.1" babylon@^6.11.0, babylon@^6.15.0: - version "6.16.1" - resolved "https://npm.cubos.io/babylon/-/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3" + version "6.17.0" + resolved "https://npm.cubos.io/babylon/-/babylon-6.17.0.tgz#37da948878488b9c4e3c4038893fa3314b3fc932" balanced-match@^0.4.1: version "0.4.2" @@ -620,8 +620,8 @@ boom@2.x.x: hoek "2.x.x" brace-expansion@^1.0.0: - version "1.1.6" - resolved "https://npm.cubos.io/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" + version "1.1.7" + resolved "https://npm.cubos.io/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59" dependencies: balanced-match "^0.4.1" concat-map "0.0.1" @@ -634,7 +634,7 @@ braces@^1.8.2: preserve "^0.2.0" repeat-element "^1.1.2" -buffer-shims@^1.0.0: +buffer-shims@~1.0.0: version "1.0.0" resolved "https://npm.cubos.io/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" @@ -696,8 +696,8 @@ console-control-strings@^1.0.0, console-control-strings@~1.1.0: resolved "https://npm.cubos.io/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" convert-source-map@^1.1.0: - version "1.4.0" - resolved "https://npm.cubos.io/convert-source-map/-/convert-source-map-1.4.0.tgz#e3dad195bf61bfe13a7a3c73e9876ec14a0268f3" + version "1.5.0" + resolved "https://npm.cubos.io/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" core-js@^2.4.0: version "2.4.1" @@ -720,16 +720,10 @@ dashdash@^1.12.0: assert-plus "^1.0.0" debug@^2.1.1, debug@^2.2.0: - version "2.6.3" - resolved "https://npm.cubos.io/debug/-/debug-2.6.3.tgz#0f7eb8c30965ec08c72accfa0130c8b79984141d" - dependencies: - ms "0.7.2" - -debug@~2.2.0: - version "2.2.0" - resolved "https://npm.cubos.io/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + version "2.6.4" + resolved "https://npm.cubos.io/debug/-/debug-2.6.4.tgz#7586a9b3c39741c0282ae33445c4e8ac74734fe0" dependencies: - ms "0.7.1" + ms "0.7.3" deep-extend@~0.4.0: version "0.4.1" @@ -818,8 +812,8 @@ forever-agent@~0.6.1: resolved "https://npm.cubos.io/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" form-data@~2.1.1: - version "2.1.2" - resolved "https://npm.cubos.io/form-data/-/form-data-2.1.2.tgz#89c3534008b97eada4cbb157d58f6f5df025eae4" + version "2.1.4" + resolved "https://npm.cubos.io/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" dependencies: asynckit "^0.4.0" combined-stream "^1.0.5" @@ -840,7 +834,7 @@ fsevents@^1.0.0: nan "^2.3.0" node-pre-gyp "^0.6.29" -fstream-ignore@~1.0.5: +fstream-ignore@^1.0.5: version "1.0.5" resolved "https://npm.cubos.io/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" dependencies: @@ -848,7 +842,7 @@ fstream-ignore@~1.0.5: inherits "2" minimatch "^3.0.0" -fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10: +fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: version "1.0.11" resolved "https://npm.cubos.io/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" dependencies: @@ -858,8 +852,8 @@ fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10: rimraf "2" gauge@~2.7.1: - version "2.7.3" - resolved "https://npm.cubos.io/gauge/-/gauge-2.7.3.tgz#1c23855f962f17b3ad3d0dc7443f304542edfe09" + version "2.7.4" + resolved "https://npm.cubos.io/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" dependencies: aproba "^1.0.3" console-control-strings "^1.0.0" @@ -901,8 +895,8 @@ glob@^7.0.0, glob@^7.0.5: path-is-absolute "^1.0.0" globals@^9.0.0: - version "9.16.0" - resolved "https://npm.cubos.io/globals/-/globals-9.16.0.tgz#63e903658171ec2d9f51b1d31de5e2b8dc01fb80" + version "9.17.0" + resolved "https://npm.cubos.io/globals/-/globals-9.17.0.tgz#0c0ca696d9b9bb694d2e5470bd37777caad50286" graceful-fs@^4.1.2, graceful-fs@^4.1.4: version "4.1.11" @@ -1151,15 +1145,15 @@ micromatch@^2.1.5: parse-glob "^3.0.4" regex-cache "^0.4.2" -mime-db@~1.26.0: - version "1.26.0" - resolved "https://npm.cubos.io/mime-db/-/mime-db-1.26.0.tgz#eaffcd0e4fc6935cf8134da246e2e6c35305adff" +mime-db@~1.27.0: + version "1.27.0" + resolved "https://npm.cubos.io/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1" mime-types@^2.1.12, mime-types@~2.1.7: - version "2.1.14" - resolved "https://npm.cubos.io/mime-types/-/mime-types-2.1.14.tgz#f7ef7d97583fcaf3b7d282b6f8b5679dab1e94ee" + version "2.1.15" + resolved "https://npm.cubos.io/mime-types/-/mime-types-2.1.15.tgz#a4ebf5064094569237b8cf70046776d09fc92aed" dependencies: - mime-db "~1.26.0" + mime-db "~1.27.0" minimatch@^3.0.0, minimatch@^3.0.2: version "3.0.3" @@ -1175,53 +1169,52 @@ minimist@^1.2.0: version "1.2.0" resolved "https://npm.cubos.io/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" -"mkdirp@>=0.5 0", mkdirp@^0.5.1, mkdirp@~0.5.1: +"mkdirp@>=0.5 0", mkdirp@^0.5.1: version "0.5.1" resolved "https://npm.cubos.io/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: minimist "0.0.8" moment@^2.17.1: - version "2.17.1" - resolved "https://npm.cubos.io/moment/-/moment-2.17.1.tgz#fed9506063f36b10f066c8b59a144d7faebe1d82" + version "2.18.1" + resolved "https://npm.cubos.io/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" -ms@0.7.1: - version "0.7.1" - resolved "https://npm.cubos.io/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" - -ms@0.7.2: - version "0.7.2" - resolved "https://npm.cubos.io/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" +ms@0.7.3: + version "0.7.3" + resolved "https://npm.cubos.io/ms/-/ms-0.7.3.tgz#708155a5e44e33f5fd0fc53e81d0d40a91be1fff" nan@^2.3.0: - version "2.5.1" - resolved "https://npm.cubos.io/nan/-/nan-2.5.1.tgz#d5b01691253326a97a2bbee9e61c55d8d60351e2" + version "2.6.2" + resolved "https://npm.cubos.io/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" node-pre-gyp@^0.6.29: - version "0.6.33" - resolved "https://npm.cubos.io/node-pre-gyp/-/node-pre-gyp-0.6.33.tgz#640ac55198f6a925972e0c16c4ac26a034d5ecc9" - dependencies: - mkdirp "~0.5.1" - nopt "~3.0.6" - npmlog "^4.0.1" - rc "~1.1.6" - request "^2.79.0" - rimraf "~2.5.4" - semver "~5.3.0" - tar "~2.2.1" - tar-pack "~3.3.0" - -nopt@~3.0.6: - version "3.0.6" - resolved "https://npm.cubos.io/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" + version "0.6.34" + resolved "https://npm.cubos.io/node-pre-gyp/-/node-pre-gyp-0.6.34.tgz#94ad1c798a11d7fc67381b50d47f8cc18d9799f7" + dependencies: + mkdirp "^0.5.1" + nopt "^4.0.1" + npmlog "^4.0.2" + rc "^1.1.7" + request "^2.81.0" + rimraf "^2.6.1" + semver "^5.3.0" + tar "^2.2.1" + tar-pack "^3.4.0" + +nopt@^4.0.1: + version "4.0.1" + resolved "https://npm.cubos.io/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" dependencies: abbrev "1" + osenv "^0.1.4" normalize-path@^2.0.1: - version "2.0.1" - resolved "https://npm.cubos.io/normalize-path/-/normalize-path-2.0.1.tgz#47886ac1662760d4261b7d979d241709d3ce3f7a" + version "2.1.1" + resolved "https://npm.cubos.io/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + dependencies: + remove-trailing-separator "^1.0.1" -npmlog@^4.0.1: +npmlog@^4.0.2: version "4.0.2" resolved "https://npm.cubos.io/npmlog/-/npmlog-4.0.2.tgz#d03950e0e78ce1527ba26d2a7592e9348ac3e75f" dependencies: @@ -1249,26 +1242,27 @@ object.omit@^2.0.0: for-own "^0.1.4" is-extendable "^0.1.1" -once@^1.3.0: +once@^1.3.0, once@^1.3.3: version "1.4.0" resolved "https://npm.cubos.io/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" dependencies: wrappy "1" -once@~1.3.3: - version "1.3.3" - resolved "https://npm.cubos.io/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20" - dependencies: - wrappy "1" - os-homedir@^1.0.0: version "1.0.2" resolved "https://npm.cubos.io/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" -os-tmpdir@^1.0.1: +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: version "1.0.2" resolved "https://npm.cubos.io/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" +osenv@^0.1.4: + version "0.1.4" + resolved "https://npm.cubos.io/osenv/-/osenv-0.1.4.tgz#42fe6d5953df06c8064be6f176c3d05aaaa34644" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.0" + output-file-sync@^1.1.0: version "1.1.2" resolved "https://npm.cubos.io/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" @@ -1321,37 +1315,25 @@ randomatic@^1.1.3: is-number "^2.0.2" kind-of "^3.0.2" -rc@~1.1.6: - version "1.1.7" - resolved "https://npm.cubos.io/rc/-/rc-1.1.7.tgz#c5ea564bb07aff9fd3a5b32e906c1d3a65940fea" +rc@^1.1.7: + version "1.2.1" + resolved "https://npm.cubos.io/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95" dependencies: deep-extend "~0.4.0" ini "~1.3.0" minimist "^1.2.0" strip-json-comments "~2.0.1" -"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.2: - version "2.2.6" - resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.6.tgz#8b43aed76e71483938d12a8d46c6cf1a00b1f816" - dependencies: - buffer-shims "^1.0.0" - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "~1.0.0" - process-nextick-args "~1.0.6" - string_decoder "~0.10.x" - util-deprecate "~1.0.1" - -readable-stream@~2.1.4: - version "2.1.5" - resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.1.5.tgz#66fa8b720e1438b364681f2ad1a63c618448c9d0" +readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.4: + version "2.2.9" + resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.9.tgz#cf78ec6f4a6d1eb43d26488cac97f042e74b7fc8" dependencies: - buffer-shims "^1.0.0" + buffer-shims "~1.0.0" core-util-is "~1.0.0" inherits "~2.0.1" isarray "~1.0.0" process-nextick-args "~1.0.6" - string_decoder "~0.10.x" + string_decoder "~1.0.0" util-deprecate "~1.0.1" readdirp@^2.0.0: @@ -1371,9 +1353,9 @@ regenerator-runtime@^0.10.0: version "0.10.3" resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.10.3.tgz#8c4367a904b51ea62a908ac310bf99ff90a82a3e" -regenerator-transform@0.9.8: - version "0.9.8" - resolved "https://npm.cubos.io/regenerator-transform/-/regenerator-transform-0.9.8.tgz#0f88bb2bc03932ddb7b6b7312e68078f01026d6c" +regenerator-transform@0.9.11: + version "0.9.11" + resolved "https://npm.cubos.io/regenerator-transform/-/regenerator-transform-0.9.11.tgz#3a7d067520cb7b7176769eb5ff868691befe1283" dependencies: babel-runtime "^6.18.0" babel-types "^6.19.0" @@ -1404,6 +1386,10 @@ regjsparser@^0.1.4: dependencies: jsesc "~0.5.0" +remove-trailing-separator@^1.0.1: + version "1.0.1" + resolved "https://npm.cubos.io/remove-trailing-separator/-/remove-trailing-separator-1.0.1.tgz#615ebb96af559552d4bf4057c8436d486ab63cc4" + repeat-element@^1.1.2: version "1.1.2" resolved "https://npm.cubos.io/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" @@ -1418,7 +1404,7 @@ repeating@^2.0.0: dependencies: is-finite "^1.0.0" -request@^2.79.0: +request@^2.81.0: version "2.81.0" resolved "https://npm.cubos.io/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" dependencies: @@ -1445,9 +1431,9 @@ request@^2.79.0: tunnel-agent "^0.6.0" uuid "^3.0.0" -rimraf@2, rimraf@~2.5.1, rimraf@~2.5.4: - version "2.5.4" - resolved "https://npm.cubos.io/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" +rimraf@2, rimraf@^2.5.1, rimraf@^2.6.1: + version "2.6.1" + resolved "https://npm.cubos.io/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" dependencies: glob "^7.0.5" @@ -1455,7 +1441,7 @@ safe-buffer@^5.0.1: version "5.0.1" resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" -semver@~5.3.0: +semver@^5.3.0: version "5.3.0" resolved "https://npm.cubos.io/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" @@ -1482,8 +1468,8 @@ sntp@1.x.x: hoek "2.x.x" source-map-support@^0.4.2: - version "0.4.13" - resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.13.tgz#9782e6f7deb424d5f173327a1879eb46453bdcd4" + version "0.4.14" + resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.14.tgz#9d4463772598b86271b4f523f6c1f4e02a7d6aef" dependencies: source-map "^0.5.6" @@ -1492,8 +1478,8 @@ source-map@^0.5.0, source-map@^0.5.6: resolved "https://npm.cubos.io/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" sshpk@^1.7.0: - version "1.11.0" - resolved "https://npm.cubos.io/sshpk/-/sshpk-1.11.0.tgz#2d8d5ebb4a6fab28ffba37fa62a90f4a3ea59d77" + version "1.13.0" + resolved "https://npm.cubos.io/sshpk/-/sshpk-1.13.0.tgz#ff2a3e4fd04497555fed97b39a0fd82fafb3a33c" dependencies: asn1 "~0.2.3" assert-plus "^1.0.0" @@ -1514,9 +1500,11 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string_decoder@~0.10.x: - version "0.10.31" - resolved "https://npm.cubos.io/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" +string_decoder@~1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/string_decoder/-/string_decoder-1.0.0.tgz#f06f41157b664d86069f84bdbdc9b0d8ab281667" + dependencies: + buffer-shims "~1.0.0" stringstream@~0.0.4: version "0.0.5" @@ -1536,20 +1524,20 @@ supports-color@^2.0.0: version "2.0.0" resolved "https://npm.cubos.io/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" -tar-pack@~3.3.0: - version "3.3.0" - resolved "https://npm.cubos.io/tar-pack/-/tar-pack-3.3.0.tgz#30931816418f55afc4d21775afdd6720cee45dae" +tar-pack@^3.4.0: + version "3.4.0" + resolved "https://npm.cubos.io/tar-pack/-/tar-pack-3.4.0.tgz#23be2d7f671a8339376cbdb0b8fe3fdebf317984" dependencies: - debug "~2.2.0" - fstream "~1.0.10" - fstream-ignore "~1.0.5" - once "~1.3.3" - readable-stream "~2.1.4" - rimraf "~2.5.1" - tar "~2.2.1" - uid-number "~0.0.6" - -tar@~2.2.1: + debug "^2.2.0" + fstream "^1.0.10" + fstream-ignore "^1.0.5" + once "^1.3.3" + readable-stream "^2.1.4" + rimraf "^2.5.1" + tar "^2.2.1" + uid-number "^0.0.6" + +tar@^2.2.1: version "2.2.1" resolved "https://npm.cubos.io/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" dependencies: @@ -1582,14 +1570,14 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: resolved "https://npm.cubos.io/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" typescript@^2.2.1: - version "2.2.1" - resolved "https://npm.cubos.io/typescript/-/typescript-2.2.1.tgz#4862b662b988a4c8ff691cc7969622d24db76ae9" + version "2.3.0" + resolved "https://npm.cubos.io/typescript/-/typescript-2.3.0.tgz#2e63e09284392bc8158a2444c33e2093795c0418" ua-parser-js@^0.7.12: version "0.7.12" resolved "https://npm.cubos.io/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb" -uid-number@~0.0.6: +uid-number@^0.0.6: version "0.0.6" resolved "https://npm.cubos.io/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" @@ -1606,8 +1594,8 @@ uuid@^3.0.0: resolved "https://npm.cubos.io/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" v8flags@^2.0.10: - version "2.0.11" - resolved "https://npm.cubos.io/v8flags/-/v8flags-2.0.11.tgz#bca8f30f0d6d60612cc2c00641e6962d42ae6881" + version "2.1.1" + resolved "https://npm.cubos.io/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" dependencies: user-home "^1.1.1" From 51799bdefda119302be1c35618b873428faf8817 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 26 Apr 2017 10:36:10 -0300 Subject: [PATCH 145/625] Add match --- rethinkdb/rethinkdb.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index abaf58f..1e95907 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -123,6 +123,7 @@ interface RDatum extends RStreamOrDatum, PromiseLike { ceil(): RDatum without(field: any): RDatum pluck(...field: any[]): RDatum + match(regex: string | RDatum): RDatum filter(criteria: (obj: any) => boolean | RDatum): RDatum filter(obj: any): RDatum From a65e190b72806de46fb960d4ddb6454aad240154 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 27 Apr 2017 14:20:26 -0300 Subject: [PATCH 146/625] Fix maven url --- target-android/api/build.gradle | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target-android/api/build.gradle b/target-android/api/build.gradle index 6c15279..f1a5f81 100644 --- a/target-android/api/build.gradle +++ b/target-android/api/build.gradle @@ -30,11 +30,12 @@ dependencies { publishing { repositories { maven { - url 'https://maven.cubos.io/upload/' - credentials { - username "cubos" - password "4XBKk8BMCyMc24joS8Od" - } + url 'https://mymavenrepo.com/repo/4XBKk8BMCyMc24joS8Od/' + // url 'https://maven.cubos.io/upload/' + // credentials { + // username "cubos" + // password "4XBKk8BMCyMc24joS8Od" + // } } } From f0d2eba9af4a5bb9b71497da7cca29aa719084ca Mon Sep 17 00:00:00 2001 From: Jose Messias Junior Date: Thu, 27 Apr 2017 19:05:20 -0300 Subject: [PATCH 147/625] test method --- target_java_android.cr | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target_java_android.cr b/target_java_android.cr index b35736b..d34921d 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -183,6 +183,10 @@ END static final SecureRandom random = new SecureRandom(); static boolean initialized = false; + static void test() { + Log.d("TESTE", "etacuzao"); + } + static void initialize() { initialized = true; Stetho.initializeWithDefaults(context()); From 2d3126618ae644405b1c9136a9ed6e3668326adf Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 28 Apr 2017 13:01:27 -0300 Subject: [PATCH 148/625] Implement webhooks on api --- target_typescript_nodeserver.cr | 63 ++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index b1b5b36..8fad5ac 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -6,6 +6,7 @@ class TypeScriptServerTarget < TypeScriptTarget import http from "http"; import crypto from "crypto"; import os from "os"; +import url from "url"; import moment from "moment"; import r from "../rethinkdb"; @@ -67,6 +68,14 @@ END @io << <<-END ////////////////////////////////////////////////////// +const webhooks: { + [signature: string]: (body: string, res: http.ServerResponse) => void +} = {} + +export function addWebHook(method: "GET" | "POST", path: string, func: (body: string, res: http.ServerResponse) => void) { + webhooks[method + path] = func; +} + export interface Context { device: DBDevice; startTime: Date; @@ -92,26 +101,32 @@ export function start(port: number) { res.setHeader("Access-Control-Max-Age", "86400"); res.setHeader("Content-Type", "application/json"); - switch (req.method) { - case "HEAD": { - res.writeHead(200); - res.end(); - break; + let body = ""; + req.on("body", (chunk: any) => body += chunk.toString()); + req.on("end", () => { + const signatures = req.method! + url.parse(req.url || "").pathname; + if (webhooks[signatures]) { + webhooks[signatures](body, res); + return; } - case "GET": { - r.expr(`{"ok": true}`).then(result => { + + switch (req.method) { + case "HEAD": { res.writeHead(200); - res.write(result); res.end(); - }); - break; - } - case "POST": { - let data = ""; - req.on("data", chunk => data += chunk.toString()); - req.on("end", () => { + break; + } + case "GET": { + r.expr(`{"ok": true}`).then(result => { + res.writeHead(200); + res.write(result); + res.end(); + }); + break; + } + case "POST": { (async () => { - const request = JSON.parse(data); + const request = JSON.parse(body); const context: Context = { device: request.device, startTime: new Date @@ -169,7 +184,7 @@ export function start(port: number) { } for (let i = 0; i < 30; ++i) { - if (tryLock()) break; + if (await tryLock()) break; await sleep(100); } @@ -234,14 +249,14 @@ export function start(port: number) { res.writeHead(500); res.end(); }); - }); - break; - } - default: { - res.writeHead(500); - res.end(); + break; + } + default: { + res.writeHead(500); + res.end(); + } } - } + }); }); server.listen(port, () => { From f10da3b0169dab43d1b44b054394cd47be41a660 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 28 Apr 2017 16:02:11 +0000 Subject: [PATCH 149/625] Revert "test method" This reverts commit 3f1c9623f352cfb843a495b653dfbff476c3ff42 --- target_java_android.cr | 4 ---- 1 file changed, 4 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index d34921d..b35736b 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -183,10 +183,6 @@ END static final SecureRandom random = new SecureRandom(); static boolean initialized = false; - static void test() { - Log.d("TESTE", "etacuzao"); - } - static void initialize() { initialized = true; Stetho.initializeWithDefaults(context()); From 468a58476b17829729b063014684d9c2d0b5195e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 28 Apr 2017 13:24:51 -0300 Subject: [PATCH 150/625] adjust webhooks --- target_typescript_nodeserver.cr | 60 ++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 8fad5ac..5333711 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -101,30 +101,34 @@ export function start(port: number) { res.setHeader("Access-Control-Max-Age", "86400"); res.setHeader("Content-Type", "application/json"); - let body = ""; - req.on("body", (chunk: any) => body += chunk.toString()); - req.on("end", () => { - const signatures = req.method! + url.parse(req.url || "").pathname; - if (webhooks[signatures]) { - webhooks[signatures](body, res); - return; - } + const signature = req.method! + url.parse(req.url || "").pathname; - switch (req.method) { - case "HEAD": { - res.writeHead(200); - res.end(); - break; - } - case "GET": { - r.expr(`{"ok": true}`).then(result => { - res.writeHead(200); - res.write(result); - res.end(); - }); + switch (req.method) { + case "HEAD": { + res.writeHead(200); + res.end(); + break; + } + case "GET": { + if (webhooks[signature]) { + webhooks[signature]("", res); break; } - case "POST": { + r.expr(`{"ok": true}`).then(result => { + res.writeHead(200); + res.write(result); + res.end(); + }); + break; + } + case "POST": { + let body = ""; + req.on("body", (chunk: any) => body += chunk.toString()); + req.on("end", () => { + if (webhooks[signature]) { + webhooks[signature](body, res); + return; + } (async () => { const request = JSON.parse(body); const context: Context = { @@ -249,14 +253,14 @@ export function start(port: number) { res.writeHead(500); res.end(); }); - break; - } - default: { - res.writeHead(500); - res.end(); - } + }); + break; } - }); + default: { + res.writeHead(500); + res.end(); + } + } }); server.listen(port, () => { From fe26e6c3e31d16f3f613e7760e17d3aa2b079554 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 28 Apr 2017 13:52:39 -0300 Subject: [PATCH 151/625] Fix POST + revert previous fix --- target_typescript_nodeserver.cr | 60 +++++++++++++++------------------ 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 5333711..6d89fb4 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -101,34 +101,30 @@ export function start(port: number) { res.setHeader("Access-Control-Max-Age", "86400"); res.setHeader("Content-Type", "application/json"); - const signature = req.method! + url.parse(req.url || "").pathname; - - switch (req.method) { - case "HEAD": { - res.writeHead(200); - res.end(); - break; + let body = ""; + req.on("data", (chunk: any) => body += chunk.toString()); + req.on("end", () => { + const signature = req.method! + url.parse(req.url || "").pathname; + if (webhooks[signature]) { + webhooks[signature](body, res); + return; } - case "GET": { - if (webhooks[signature]) { - webhooks[signature]("", res); - break; - } - r.expr(`{"ok": true}`).then(result => { + + switch (req.method) { + case "HEAD": { res.writeHead(200); - res.write(result); res.end(); - }); - break; - } - case "POST": { - let body = ""; - req.on("body", (chunk: any) => body += chunk.toString()); - req.on("end", () => { - if (webhooks[signature]) { - webhooks[signature](body, res); - return; - } + break; + } + case "GET": { + r.expr(`{"ok": true}`).then(result => { + res.writeHead(200); + res.write(result); + res.end(); + }); + break; + } + case "POST": { (async () => { const request = JSON.parse(body); const context: Context = { @@ -253,14 +249,14 @@ export function start(port: number) { res.writeHead(500); res.end(); }); - }); - break; - } - default: { - res.writeHead(500); - res.end(); + break; + } + default: { + res.writeHead(500); + res.end(); + } } - } + }); }); server.listen(port, () => { From 5367d6828ade890bda90e9cf38fa2d7a111f9126 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 28 Apr 2017 20:59:38 -0300 Subject: [PATCH 152/625] Improve android gradle --- target-android/api/build.gradle | 35 ++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/target-android/api/build.gradle b/target-android/api/build.gradle index f1a5f81..81e6bc8 100644 --- a/target-android/api/build.gradle +++ b/target-android/api/build.gradle @@ -22,9 +22,9 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.squareup.okhttp3:okhttp:3.6.0' - compile 'com.facebook.stetho:stetho:1.4.2' - compile 'com.facebook.stetho:stetho-okhttp3:1.4.2' + compile 'com.squareup.okhttp3:okhttp:3.7.0' + compile 'com.facebook.stetho:stetho:1.5.0' + compile 'com.facebook.stetho:stetho-okhttp3:1.5.0' } publishing { @@ -46,6 +46,35 @@ publishing { artifactId 'sdkgen2' version '1.0.10' artifact 'build/outputs/aar/api-release.aar' + + pom.withXml { + //Creating additional node for dependencies + def dependenciesNode = asNode().appendNode('dependencies') + + //Defining configuration names from which dependencies will be taken (debugCompile or releaseCompile and compile) + def configurationNames = ["releaseCompile", 'compile'] + + configurationNames.each { configurationName -> + configurations[configurationName].allDependencies.each { + if (it.group != null && it.name != null) { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + + //If there are any exclusions in dependency + if (it.excludeRules.size() > 0) { + def exclusionsNode = dependencyNode.appendNode('exclusions') + it.excludeRules.each { rule -> + def exclusionNode = exclusionsNode.appendNode('exclusion') + exclusionNode.appendNode('groupId', rule.group) + exclusionNode.appendNode('artifactId', rule.module) + } + } + } + } + } + } } } } From 8334b0e01b38b08fbecd5b76b7b02f8d7af5cb6f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 28 Apr 2017 21:37:37 -0300 Subject: [PATCH 153/625] Improve network recovery and enable TLS 1.2 always --- target_java_android.cr | 145 ++++++++++++++++++++++++++++++++++------- 1 file changed, 123 insertions(+), 22 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index b35736b..0fe2b4a 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -32,10 +32,18 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigInteger; +import java.net.InetAddress; +import java.net.Socket; +import java.net.UnknownHostException; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.Locale; @@ -44,7 +52,15 @@ import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.TimeUnit; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; + import okhttp3.Call; +import okhttp3.ConnectionPool; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -173,15 +189,47 @@ END } private static class Internal { - static final String baseUrl = #{@ast.options.url.inspect}; - static final OkHttpClient http = new OkHttpClient.Builder() - .connectTimeout(3, TimeUnit.SECONDS) - .writeTimeout(3, TimeUnit.SECONDS) - .readTimeout(5, TimeUnit.SECONDS) - .addNetworkInterceptor(new StethoInterceptor()) - .build(); - static final SecureRandom random = new SecureRandom(); + static String baseUrl = "api.zigcore.com.br/pdv"; + static OkHttpClient http = null; + static ConnectionPool connectionPool = new ConnectionPool(); + static SecureRandom random = new SecureRandom(); static boolean initialized = false; + static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); + static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US); + + static { + dateTimeFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + + TrustManagerFactory trustManagerFactory; + try { + trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + trustManagerFactory.init((KeyStore) null); + } catch (NoSuchAlgorithmException | KeyStoreException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); + if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) { + throw new IllegalStateException("Unexpected default trust managers:" + + Arrays.toString(trustManagers)); + } + X509TrustManager trustManager = (X509TrustManager) trustManagers[0]; + + SSLSocketFactory sslSocketFactory; + try { + sslSocketFactory = new TLSSocketFactory(); + } catch (KeyManagementException | NoSuchAlgorithmException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + + http = new OkHttpClient.Builder() + .connectionPool(connectionPool) + .sslSocketFactory(sslSocketFactory, trustManager) + .addNetworkInterceptor(new StethoInterceptor()) + .build(); + } static void initialize() { initialized = true; @@ -220,7 +268,7 @@ END variant = ""; } - if (language.isEmpty() || !language.matches("\\\\p{Alpha}{2,8}")) { + if (language.isEmpty() || !language.matches("\\p{Alpha}{2,8}")) { language = "und"; } else if (language.equals("iw")) { language = "he"; @@ -230,11 +278,11 @@ END language = "yi"; } - if (!region.matches("\\\\p{Alpha}{2}|\\\\p{Digit}{3}")) { + if (!region.matches("\\p{Alpha}{2}|\\p{Digit}{3}")) { region = ""; } - if (!variant.matches("\\\\p{Alnum}{5,8}|\\\\p{Digit}\\\\p{Alnum}{3}")) { + if (!variant.matches("\\p{Alnum}{5,8}|\\p{Digit}\\p{Alnum}{3}")) { variant = ""; } @@ -309,12 +357,16 @@ END .post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), body.toString())) .build(); - final boolean shouldReceiveResponse[] = new boolean[1]; - shouldReceiveResponse[0] = true; + final boolean shouldReceiveResponse[] = new boolean[] {true}; + final int sentCount[] = new int[] {0}; final Timer timer = new Timer(); final TimerTask task = new TimerTask() { @Override public void run() { + sentCount[0] += 1; + if (sentCount[0] % 5 == 0) { + connectionPool.evictAll(); + } http.newCall(request).enqueue(new okhttp3.Callback() { @Override public void onFailure(Call call, final IOException e) { @@ -354,7 +406,7 @@ END if (!body.getBoolean("ok")) { JSONObject error = body.getJSONObject("error"); String message = error.getString("message"); - callback.onResult(#{type_from_json(@ast.enum_types.find {|e| e.name == "ErrorType"}.not_nil!, "error", "type".inspect)}, message, null); + callback.onResult(error.getString("type").equals("NotLoggedIn") ? ErrorType.NotLoggedIn : error.getString("type").equals("LacksPermission") ? ErrorType.LacksPermission : error.getString("type").equals("InvalidArgument") ? ErrorType.InvalidArgument : error.getString("type").equals("WrongLogin") ? ErrorType.WrongLogin : error.getString("type").equals("DoesntExist") ? ErrorType.DoesntExist : error.getString("type").equals("Fatal") ? ErrorType.Fatal : error.getString("type").equals("Connection") ? ErrorType.Connection : null, message, null); } else { callback.onResult(null, null, body); } @@ -372,14 +424,6 @@ END timer.schedule(task, 0, 1000); } - static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); - static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US); - - static { - dateTimeFormat.setTimeZone(TimeZone.getTimeZone("GMT")); - dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); - } - static Calendar toCalendar(Date date){ Calendar cal = Calendar.getInstance(); cal.setTime(date); @@ -411,6 +455,63 @@ END static String encodeDate(Calendar cal) { return dateFormat.format(cal.getTime()); } + + static private class TLSSocketFactory extends SSLSocketFactory { + private SSLSocketFactory internalSSLSocketFactory; + + TLSSocketFactory() throws KeyManagementException, NoSuchAlgorithmException { + SSLContext context = SSLContext.getInstance("TLS"); + context.init(null, null, null); + internalSSLSocketFactory = context.getSocketFactory(); + } + + @Override + public String[] getDefaultCipherSuites() { + return internalSSLSocketFactory.getDefaultCipherSuites(); + } + + @Override + public String[] getSupportedCipherSuites() { + return internalSSLSocketFactory.getSupportedCipherSuites(); + } + + @Override + public Socket createSocket() throws IOException { + return enableTLSOnSocket(internalSSLSocketFactory.createSocket()); + } + + @Override + public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException { + return enableTLSOnSocket(internalSSLSocketFactory.createSocket(s, host, port, autoClose)); + } + + @Override + public Socket createSocket(String host, int port) throws IOException, UnknownHostException { + return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port)); + } + + @Override + public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException, UnknownHostException { + return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port, localHost, localPort)); + } + + @Override + public Socket createSocket(InetAddress host, int port) throws IOException { + return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port)); + } + + @Override + public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException { + return enableTLSOnSocket(internalSSLSocketFactory.createSocket(address, port, localAddress, localPort)); + } + + private Socket enableTLSOnSocket(Socket socket) { + if (socket != null && (socket instanceof SSLSocket)) { + ((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.2"}); + } + return socket; + } + } } } END From 13a5382cce2a5e898cc50fdd84d564c5d4e17ff8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 28 Apr 2017 21:42:32 -0300 Subject: [PATCH 154/625] Fix language regex --- target_java_android.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 0fe2b4a..45bc071 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -268,7 +268,7 @@ END variant = ""; } - if (language.isEmpty() || !language.matches("\\p{Alpha}{2,8}")) { + if (language.isEmpty() || !language.matches("\\\\p{Alpha}{2,8}")) { language = "und"; } else if (language.equals("iw")) { language = "he"; @@ -278,11 +278,11 @@ END language = "yi"; } - if (!region.matches("\\p{Alpha}{2}|\\p{Digit}{3}")) { + if (!region.matches("\\\\p{Alpha}{2}|\\\\p{Digit}{3}")) { region = ""; } - if (!variant.matches("\\p{Alnum}{5,8}|\\p{Digit}\\p{Alnum}{3}")) { + if (!variant.matches("\\\\p{Alnum}{5,8}|\\\\p{Digit}\\\\p{Alnum}{3}")) { variant = ""; } From a0714ef1f3478012f6b571aab21b4fdd6e2f1e5f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 28 Apr 2017 22:31:51 -0300 Subject: [PATCH 155/625] Add loading --- target_java_android.cr | 44 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 45bc071..0f29fb9 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -6,6 +6,7 @@ class JavaAndroidTarget < JavaTarget import android.annotation.SuppressLint; import android.app.Application; +import android.app.ProgressDialog; import android.content.Context; import android.content.SharedPreferences; import android.content.pm.PackageManager; @@ -70,6 +71,11 @@ import okhttp3.Response; public class API { static public boolean useStaging = false; + static public int Default = 0; + static public int Loading = 1; + static public int Cache = 2; + + END @ast.struct_types.each do |t| @@ -85,6 +91,13 @@ END @ast.operations.each do |op| args = op.args.map {|arg| "final #{native_type arg.type} #{arg.name}" } args << "final #{callback_type op.return_type} callback" + @io << ident(String.build do |io| + io << "static public void #{op.pretty_name}(#{args.join(", ")}) {\n" + io << " #{op.pretty_name}(#{(op.args.map {|arg| arg.name } + ["0", "callback"]).join(", ")});\n" + io << "}" + end) + @io << "\n\n" + args = args[0..-2] + ["final int flags", args[-1]] @io << ident(String.build do |io| io << "static public void #{op.pretty_name}(#{args.join(", ")}) {\n" io << ident(String.build do |io| @@ -107,11 +120,12 @@ END callback.onResult(ErrorType.Fatal, e.getMessage()#{op.return_type.is_a?(AST::VoidPrimitiveType) ? "" : ", null"}); return; } + END end io << <<-END -Internal.makeRequest(#{op.pretty_name.inspect}, args, new Internal.RequestCallback() { +Internal.RequestCallback reqCallback = new Internal.RequestCallback() { @Override public void onResult(final ErrorType type, final String message, final JSONObject result) { @@ -141,7 +155,12 @@ END end io << <<-END } -}); +}; +if ((flags & API.Loading) != 0) { + reqCallback = Internal.withLoading(reqCallback); +} +Internal.makeRequest(#{op.pretty_name.inspect}, args, reqCallback); + END end) io << "}" @@ -338,6 +357,27 @@ END void onResult(ErrorType type, String message, JSONObject result); } + static RequestCallback withLoading(final RequestCallback callback) { + final ProgressDialog[] progress = new ProgressDialog[] {null}; + final Timer timer = new Timer(); + final TimerTask task = new TimerTask() { + @Override + public void run() { + progress[0] = ProgressDialog.show(context(), "Aguarde", "Carregando...", true, true); + } + }; + timer.schedule(task, 0, 800); + return new RequestCallback() { + @Override + public void onResult(final ErrorType type, final String message, final JSONObject result) { + timer.cancel(); + if (progress[0] != null) + progress[0].dismiss(); + callback.onResult(type, message, result); + } + }; + } + static void makeRequest(String name, JSONObject args, final RequestCallback callback) { if (!initialized) initialize(); From 263b292db96e7f07ee879e93dc98eb1e7f8a3cb4 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 28 Apr 2017 22:37:49 -0300 Subject: [PATCH 156/625] Only touch UI on main thread --- target_java_android.cr | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 0f29fb9..5989275 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -363,7 +363,12 @@ END final TimerTask task = new TimerTask() { @Override public void run() { - progress[0] = ProgressDialog.show(context(), "Aguarde", "Carregando...", true, true); + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + progress[0] = ProgressDialog.show(context(), "Aguarde", "Carregando...", true, true); + } + }); } }; timer.schedule(task, 0, 800); @@ -371,8 +376,13 @@ END @Override public void onResult(final ErrorType type, final String message, final JSONObject result) { timer.cancel(); - if (progress[0] != null) - progress[0].dismiss(); + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + if (progress[0] != null) + progress[0].dismiss(); + } + }); callback.onResult(type, message, result); } }; From ca1a4fd414fa41926c8007888754be299a90afbb Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 28 Apr 2017 22:44:05 -0300 Subject: [PATCH 157/625] Fix: dont show dialog without delay --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 5989275..98acd86 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -371,7 +371,7 @@ END }); } }; - timer.schedule(task, 0, 800); + timer.schedule(task, 800, 800); return new RequestCallback() { @Override public void onResult(final ErrorType type, final String message, final JSONObject result) { From d2f1663dbd76038fb5aa2706d3ad4f71d9c26121 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 28 Apr 2017 23:01:47 -0300 Subject: [PATCH 158/625] Get current activity --- target_java_android.cr | 44 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 98acd86..cf08785 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -5,6 +5,7 @@ class JavaAndroidTarget < JavaTarget @io << <<-END import android.annotation.SuppressLint; +import android.app.Activity; import android.app.Application; import android.app.ProgressDialog; import android.content.Context; @@ -30,6 +31,7 @@ import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; +import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.math.BigInteger; @@ -48,6 +50,7 @@ import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.Locale; +import java.util.Map; import java.util.TimeZone; import java.util.Timer; import java.util.TimerTask; @@ -257,16 +260,47 @@ END static Context context() { try { - final Class activityThreadClass = + Class activityThreadClass = Class.forName("android.app.ActivityThread"); - final Method method = activityThreadClass.getMethod("currentApplication"); + Method method = activityThreadClass.getMethod("currentApplication"); Application app = (Application)method.invoke(null, (Object[]) null); if (app == null) throw new RuntimeException(""); return app; } catch (final ClassNotFoundException | NoSuchMethodException | IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { - throw new RuntimeException(""); + throw new RuntimeException("Failed to get application from android.app.ActivityThread"); + } + } + + static Activity getCurrentActivity() { + try { + Class activityThreadClass = Class.forName("android.app.ActivityThread"); + Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null); + Field activitiesField = activityThreadClass.getDeclaredField("mActivities"); + activitiesField.setAccessible(true); + + @SuppressWarnings("unchecked") + Map activities = (Map) activitiesField.get(activityThread); + + if (activities == null) + return null; + + for (Object activityRecord : activities.values()) { + Class activityRecordClass = activityRecord.getClass(); + Field pausedField = activityRecordClass.getDeclaredField("paused"); + pausedField.setAccessible(true); + if (!pausedField.getBoolean(activityRecord)) { + Field activityField = activityRecordClass.getDeclaredField("activity"); + activityField.setAccessible(true); + return (Activity) activityField.get(activityRecord); + } + } + + return null; + } catch (final ClassNotFoundException | NoSuchMethodException | NoSuchFieldException | + IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException("Failed to get current activity from android.app.ActivityThread"); } } @@ -366,12 +400,12 @@ END new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { - progress[0] = ProgressDialog.show(context(), "Aguarde", "Carregando...", true, true); + progress[0] = ProgressDialog.show(getCurrentActivity(), "Aguarde", "Carregando...", true, true); } }); } }; - timer.schedule(task, 800, 800); + timer.schedule(task, 800); return new RequestCallback() { @Override public void onResult(final ErrorType type, final String message, final JSONObject result) { From 15af04a39dd9cddd313a8b297539253ebd7853f6 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 08:55:49 -0300 Subject: [PATCH 159/625] Change error handling --- target_java_android.cr | 91 +++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index cf08785..de2e7b3 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -54,7 +54,6 @@ import java.util.Map; import java.util.TimeZone; import java.util.Timer; import java.util.TimerTask; -import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; @@ -118,9 +117,9 @@ END end io << <<-END }}; -} catch (JSONException e) { +} catch (final JSONException e) { e.printStackTrace(); - callback.onResult(ErrorType.Fatal, e.getMessage()#{op.return_type.is_a?(AST::VoidPrimitiveType) ? "" : ", null"}); + callback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}#{op.return_type.is_a?(AST::VoidPrimitiveType) ? "" : ", null"}); return; } @@ -130,28 +129,28 @@ END Internal.RequestCallback reqCallback = new Internal.RequestCallback() { @Override - public void onResult(final ErrorType type, final String message, final JSONObject result) { + public void onResult(final Error error, final JSONObject result) { END if op.return_type.is_a? AST::VoidPrimitiveType io << <<-END - if (type != null) { - callback.onResult(type, message); + if (error != null) { + callback.onResult(error); } else { - callback.onResult(null, null); + callback.onResult(null); } END else io << <<-END - if (type != null) { - callback.onResult(type, message, null); + if (error != null) { + callback.onResult(error, null); } else { try { - callback.onResult(null, null, #{type_from_json op.return_type, "result", "result".inspect}); - } catch (JSONException e) { + callback.onResult(null, #{type_from_json op.return_type, "result", "result".inspect}); + } catch (final JSONException e) { e.printStackTrace(); - callback.onResult(ErrorType.Fatal, e.getMessage(), null); + callback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null); } } END @@ -172,37 +171,46 @@ END end @io << <<-END + public static class Error { + ErrorType type; + String message; + } - public interface Callback { - void onResult(ErrorType error, String message, T result); + public abstract static class Callback { + int cacheAge = 0; + abstract void onResult(Error error, T result); } - public interface IntCallback { - void onResult(ErrorType error, String message, int result); + public abstract static class IntCallback { + int cacheAge = 0; + abstract void onResult(Error error, int result); } - public interface DoubleCallback { - void onResult(ErrorType error, String message, double result); + public abstract static class DoubleCallback { + int cacheAge = 0; + abstract void onResult(Error error, double result); } - public interface BooleanCallback { - void onResult(ErrorType error, String message, boolean result); + public abstract static class BooleanCallback { + int cacheAge = 0; + abstract void onResult(Error error, boolean result); } - public interface VoidCallback { - void onResult(ErrorType error, String message); + public abstract static class VoidCallback { + int cacheAge = 0; + abstract void onResult(Error error); } static public void getDeviceId(final Callback callback) { SharedPreferences pref = Internal.context().getSharedPreferences("api", Context.MODE_PRIVATE); if (pref.contains("deviceId")) - callback.onResult(null, null, pref.getString("deviceId", null)); + callback.onResult(null, pref.getString("deviceId", null)); else { ping(new Callback() { @Override - public void onResult(ErrorType error, String message, String result) { + public void onResult(Error error, String result) { if (error != null) - callback.onResult(error, message, null); + callback.onResult(error, null); else getDeviceId(callback); } @@ -267,7 +275,7 @@ END if (app == null) throw new RuntimeException(""); return app; - } catch (final ClassNotFoundException | NoSuchMethodException | + } catch (ClassNotFoundException | NoSuchMethodException | IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException("Failed to get application from android.app.ActivityThread"); } @@ -298,7 +306,7 @@ END } return null; - } catch (final ClassNotFoundException | NoSuchMethodException | NoSuchFieldException | + } catch (ClassNotFoundException | NoSuchMethodException | NoSuchFieldException | IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException("Failed to get current activity from android.app.ActivityThread"); } @@ -388,7 +396,7 @@ END } interface RequestCallback { - void onResult(ErrorType type, String message, JSONObject result); + void onResult(Error error, JSONObject result); } static RequestCallback withLoading(final RequestCallback callback) { @@ -408,7 +416,7 @@ END timer.schedule(task, 800); return new RequestCallback() { @Override - public void onResult(final ErrorType type, final String message, final JSONObject result) { + public void onResult(Error error, JSONObject result) { timer.cancel(); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override @@ -417,7 +425,7 @@ END progress[0].dismiss(); } }); - callback.onResult(type, message, result); + callback.onResult(error, result); } }; } @@ -431,9 +439,9 @@ END body.put("device", device()); body.put("name", name); body.put("args", args); - } catch (JSONException e) { + } catch (final JSONException e) { e.printStackTrace(); - callback.onResult(ErrorType.Fatal, e.getMessage(), null); + callback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null); } final Request request = new Request.Builder() @@ -461,7 +469,7 @@ END @Override public void run() { e.printStackTrace(); - callback.onResult(ErrorType.Fatal, e.getMessage(), null); + callback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null); } }); } @@ -477,7 +485,7 @@ END public void run() { if (response.code() >= 500) { Log.e("API Fatal", stringBody); - callback.onResult(ErrorType.Fatal, "HTTP " + response.code(), null); + callback.onResult(new Error() {{type = ErrorType.Fatal; message = "HTTP " + response.code();}}, null); return; } @@ -488,15 +496,18 @@ END pref.edit().putString("deviceId", body.getString("deviceId")).apply(); if (!body.getBoolean("ok")) { - JSONObject error = body.getJSONObject("error"); - String message = error.getString("message"); - callback.onResult(error.getString("type").equals("NotLoggedIn") ? ErrorType.NotLoggedIn : error.getString("type").equals("LacksPermission") ? ErrorType.LacksPermission : error.getString("type").equals("InvalidArgument") ? ErrorType.InvalidArgument : error.getString("type").equals("WrongLogin") ? ErrorType.WrongLogin : error.getString("type").equals("DoesntExist") ? ErrorType.DoesntExist : error.getString("type").equals("Fatal") ? ErrorType.Fatal : error.getString("type").equals("Connection") ? ErrorType.Connection : null, message, null); + JSONObject jsonError = body.getJSONObject("error"); + Error error = new Error(); + error.tyṕe = #{type_from_json(@ast.enum_types.find {|e| e.name == "ErrorType"}.not_nil!, "jsonError", "type".inspect)}; + error.message = jsonError.getString("message"); + Log.e("API Error", jsonError.getString("type") + " - " + error.message); + callback.onResult(error, null); } else { - callback.onResult(null, null, body); + callback.onResult(null, body); } - } catch (JSONException e) { + } catch (final JSONException e) { e.printStackTrace(); - callback.onResult(ErrorType.Fatal, e.getMessage(), null); + callback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null); } } }); From 7279557179474dde1238d6a9463d2d9b07e2f486 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 09:02:45 -0300 Subject: [PATCH 160/625] Fix typo --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index de2e7b3..9516c5b 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -498,7 +498,7 @@ END if (!body.getBoolean("ok")) { JSONObject jsonError = body.getJSONObject("error"); Error error = new Error(); - error.tyṕe = #{type_from_json(@ast.enum_types.find {|e| e.name == "ErrorType"}.not_nil!, "jsonError", "type".inspect)}; + error.type = #{type_from_json(@ast.enum_types.find {|e| e.name == "ErrorType"}.not_nil!, "jsonError", "type".inspect)}; error.message = jsonError.getString("message"); Log.e("API Error", jsonError.getString("type") + " - " + error.message); callback.onResult(error, null); From 05eb0b4cd2ef7fa27d462b3f81bd2f386fffdc09 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 09:08:29 -0300 Subject: [PATCH 161/625] Error fields must be public --- target_java_android.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 9516c5b..9d11908 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -172,8 +172,8 @@ END @io << <<-END public static class Error { - ErrorType type; - String message; + public ErrorType type; + public String message; } public abstract static class Callback { From 14b1fbc08bd4e60c46ac6e244ea57e900eca3028 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 09:10:21 -0300 Subject: [PATCH 162/625] Make callback things public --- target_java_android.cr | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 9d11908..ca92bd5 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -177,28 +177,28 @@ END } public abstract static class Callback { - int cacheAge = 0; - abstract void onResult(Error error, T result); + public int cacheAge = 0; + abstract public void onResult(Error error, T result); } public abstract static class IntCallback { - int cacheAge = 0; - abstract void onResult(Error error, int result); + public int cacheAge = 0; + abstract public void onResult(Error error, int result); } public abstract static class DoubleCallback { - int cacheAge = 0; - abstract void onResult(Error error, double result); + public int cacheAge = 0; + abstract public void onResult(Error error, double result); } public abstract static class BooleanCallback { - int cacheAge = 0; - abstract void onResult(Error error, boolean result); + public int cacheAge = 0; + abstract public void onResult(Error error, boolean result); } public abstract static class VoidCallback { - int cacheAge = 0; - abstract void onResult(Error error); + public int cacheAge = 0; + abstract public void onResult(Error error); } static public void getDeviceId(final Callback callback) { From d8414360d3a470d4dc8629fa3729d5cb73a3a767 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 10:15:18 -0300 Subject: [PATCH 163/625] Implement cache --- target_java_android.cr | 138 ++++++++++++++++++++++++++++++++++------- 1 file changed, 117 insertions(+), 21 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index ca92bd5..e122050 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -23,6 +23,9 @@ import android.util.Log; import android.view.Display; import android.view.WindowManager; +import com.anupcowkur.reservoir.Reservoir; +import com.anupcowkur.reservoir.ReservoirGetCallback; +import com.anupcowkur.reservoir.ReservoirPutCallback; import com.facebook.stetho.Stetho; import com.facebook.stetho.okhttp3.StethoInterceptor; @@ -41,6 +44,7 @@ import java.net.UnknownHostException; import java.security.KeyManagementException; import java.security.KeyStore; import java.security.KeyStoreException; +import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.text.ParseException; @@ -49,6 +53,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Date; +import java.util.GregorianCalendar; import java.util.Locale; import java.util.Map; import java.util.TimeZone; @@ -104,10 +109,10 @@ END io << "static public void #{op.pretty_name}(#{args.join(", ")}) {\n" io << ident(String.build do |io| if op.args.size == 0 - io << "JSONObject args = new JSONObject();" + io << "final JSONObject args = new JSONObject();" else io << <<-END -JSONObject args; +final JSONObject args; try { args = new JSONObject() {{ @@ -161,7 +166,43 @@ END if ((flags & API.Loading) != 0) { reqCallback = Internal.withLoading(reqCallback); } -Internal.makeRequest(#{op.pretty_name.inspect}, args, reqCallback); +if ((flags & API.Cache) != 0) { + String signature = "getProducts:" + Internal.hash(args.toString()); + final Internal.RequestCallback reqCallbackPure = reqCallback; + final Internal.RequestCallback reqCallbackSaveCache = Internal.withSavingOnCache(signature, reqCallback); + Reservoir.getAsync(signature, String.class, new ReservoirGetCallback() { + @Override + public void onSuccess(String json) { + try { + JSONObject data = new JSONObject(json); + Calendar time = Internal.decodeDateTime(data.getString("time")); + callback.cacheAge = (int)((new GregorianCalendar().getTimeInMillis() - time.getTimeInMillis()) / 1000); + callback.repeatWithoutCacheRunnable = new Runnable() { + @Override + public void run() { + Internal.makeRequest("getProducts", args, new Internal.RequestCallback() { + @Override + public void onResult(Error error, JSONObject result) { + callback.cacheAge = 0; + reqCallbackSaveCache.onResult(error, result); + } + }); + } + }; + reqCallbackPure.onResult(null, data.getJSONObject("result")); + } catch (JSONException e) { + Internal.makeRequest("getProducts", args, reqCallbackSaveCache); + } + } + + @Override + public void onFailure(Exception e) { + Internal.makeRequest("getProducts", args, reqCallbackSaveCache); + } + }); +} else { + Internal.makeRequest("getProducts", args, reqCallback); +} END end) @@ -176,29 +217,33 @@ END public String message; } - public abstract static class Callback { - public int cacheAge = 0; - abstract public void onResult(Error error, T result); + public static class BaseCallback { + private int cacheAge = 0; + Runnable repeatWithoutCacheRunnable; + + public void repeatWithoutCache() { + repeatWithoutCacheRunnable.run(); + } + } + + public abstract static class Callback extends BaseCallback { + abstract void onResult(Error error, T result); } - public abstract static class IntCallback { - public int cacheAge = 0; - abstract public void onResult(Error error, int result); + public abstract static class IntCallback extends BaseCallback { + abstract void onResult(Error error, int result); } - public abstract static class DoubleCallback { - public int cacheAge = 0; - abstract public void onResult(Error error, double result); + public abstract static class DoubleCallback extends BaseCallback { + abstract void onResult(Error error, double result); } - public abstract static class BooleanCallback { - public int cacheAge = 0; - abstract public void onResult(Error error, boolean result); + public abstract static class BooleanCallback extends BaseCallback { + abstract void onResult(Error error, boolean result); } - public abstract static class VoidCallback { - public int cacheAge = 0; - abstract public void onResult(Error error); + public abstract static class VoidCallback extends BaseCallback { + abstract void onResult(Error error); } static public void getDeviceId(final Callback callback) { @@ -264,6 +309,11 @@ END static void initialize() { initialized = true; Stetho.initializeWithDefaults(context()); + try { + Reservoir.init(context(), 10 * 1024 * 1024 /* 10 MB */); + } catch (IOException e) { + e.printStackTrace(); + } } static Context context() { @@ -389,10 +439,32 @@ END return device; } + final private static char[] hexArray = "0123456789abcdef".toCharArray(); + static String bytesToHex(byte[] bytes) { + char[] hexChars = new char[bytes.length * 2]; + for ( int j = 0; j < bytes.length; j++ ) { + int v = bytes[j] & 0xFF; + hexChars[j * 2] = hexArray[v >>> 4]; + hexChars[j * 2 + 1] = hexArray[v & 0x0F]; + } + return new String(hexChars); + } + static String randomBytesHex(int len) { - String str = new BigInteger(8 * len, random).toString(16); - while (str.length() < 2*len) str = "0" + str; - return str; + byte[] bytes = new byte[len]; + random.nextBytes(bytes); + return bytesToHex(bytes); + } + + static String hash(String message) { + MessageDigest digest; + try { + digest = MessageDigest.getInstance("SHA-256"); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + return null; + } + return bytesToHex(digest.digest(message.getBytes())); } interface RequestCallback { @@ -430,6 +502,30 @@ END }; } + static RequestCallback withSavingOnCache(final String signature, final RequestCallback callback) { + return new RequestCallback() { + @Override + public void onResult(Error error, final JSONObject result) { + if (error == null) { + Reservoir.putAsync(signature, new JSONObject() {{ + try { + put("time", encodeDateTime(new GregorianCalendar())); + put("result", result); + } catch (JSONException e) { + e.printStackTrace(); + } + }}.toString(), new ReservoirPutCallback() { + @Override + public void onSuccess() {} + @Override + public void onFailure(Exception e) {} + }); + } + callback.onResult(error, result); + } + }; + } + static void makeRequest(String name, JSONObject args, final RequestCallback callback) { if (!initialized) initialize(); From 76995ec0c5fdc62e783d9410fd5666b8aa1cfc98 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 10:15:31 -0300 Subject: [PATCH 164/625] Add reservoir lib for cache --- target-android/api/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/target-android/api/build.gradle b/target-android/api/build.gradle index 81e6bc8..2818cb2 100644 --- a/target-android/api/build.gradle +++ b/target-android/api/build.gradle @@ -25,6 +25,7 @@ dependencies { compile 'com.squareup.okhttp3:okhttp:3.7.0' compile 'com.facebook.stetho:stetho:1.5.0' compile 'com.facebook.stetho:stetho-okhttp3:1.5.0' + compile 'com.anupcowkur:reservoir:3.1.0' } publishing { From 93cb5834100e90c5ac724ec4842e5ccf42a955fd Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 10:19:39 -0300 Subject: [PATCH 165/625] cacheAge should not be private --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index e122050..3a71e01 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -218,7 +218,7 @@ END } public static class BaseCallback { - private int cacheAge = 0; + int cacheAge = 0; Runnable repeatWithoutCacheRunnable; public void repeatWithoutCache() { From df23313dc1ea9a7b76e79079fb65f3e72ed8590f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 10:45:48 -0300 Subject: [PATCH 166/625] adjust method visibility --- target_java_android.cr | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 3a71e01..caf2272 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -221,29 +221,29 @@ END int cacheAge = 0; Runnable repeatWithoutCacheRunnable; - public void repeatWithoutCache() { + protected void repeatWithoutCache() { repeatWithoutCacheRunnable.run(); } } public abstract static class Callback extends BaseCallback { - abstract void onResult(Error error, T result); + public abstract void onResult(Error error, T result); } public abstract static class IntCallback extends BaseCallback { - abstract void onResult(Error error, int result); + public abstract void onResult(Error error, int result); } public abstract static class DoubleCallback extends BaseCallback { - abstract void onResult(Error error, double result); + public abstract void onResult(Error error, double result); } public abstract static class BooleanCallback extends BaseCallback { - abstract void onResult(Error error, boolean result); + public abstract void onResult(Error error, boolean result); } public abstract static class VoidCallback extends BaseCallback { - abstract void onResult(Error error); + public abstract void onResult(Error error); } static public void getDeviceId(final Callback callback) { From 528025ea60f5c7c17c7888ccd02ddd2c20c79527 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 11:07:40 -0300 Subject: [PATCH 167/625] Fix return with cached data --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index caf2272..212eb62 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -189,7 +189,7 @@ if ((flags & API.Cache) != 0) { }); } }; - reqCallbackPure.onResult(null, data.getJSONObject("result")); + reqCallbackPure.onResult(null, data); } catch (JSONException e) { Internal.makeRequest("getProducts", args, reqCallbackSaveCache); } From 6272e85e44a49de291c03f4b798281f2e774e3ea Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 11:08:47 -0300 Subject: [PATCH 168/625] Fix cache function name --- target_java_android.cr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 212eb62..e198aca 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -167,7 +167,7 @@ if ((flags & API.Loading) != 0) { reqCallback = Internal.withLoading(reqCallback); } if ((flags & API.Cache) != 0) { - String signature = "getProducts:" + Internal.hash(args.toString()); + String signature = "#{op.pretty_name}:" + Internal.hash(args.toString()); final Internal.RequestCallback reqCallbackPure = reqCallback; final Internal.RequestCallback reqCallbackSaveCache = Internal.withSavingOnCache(signature, reqCallback); Reservoir.getAsync(signature, String.class, new ReservoirGetCallback() { @@ -180,7 +180,7 @@ if ((flags & API.Cache) != 0) { callback.repeatWithoutCacheRunnable = new Runnable() { @Override public void run() { - Internal.makeRequest("getProducts", args, new Internal.RequestCallback() { + Internal.makeRequest(#{op.pretty_name.inspect}, args, new Internal.RequestCallback() { @Override public void onResult(Error error, JSONObject result) { callback.cacheAge = 0; @@ -191,17 +191,17 @@ if ((flags & API.Cache) != 0) { }; reqCallbackPure.onResult(null, data); } catch (JSONException e) { - Internal.makeRequest("getProducts", args, reqCallbackSaveCache); + Internal.makeRequest(#{op.pretty_name.inspect}, args, reqCallbackSaveCache); } } @Override public void onFailure(Exception e) { - Internal.makeRequest("getProducts", args, reqCallbackSaveCache); + Internal.makeRequest(#{op.pretty_name.inspect}, args, reqCallbackSaveCache); } }); } else { - Internal.makeRequest("getProducts", args, reqCallback); + Internal.makeRequest(#{op.pretty_name.inspect}, args, reqCallback); } END From de86a0b501bd77257b82c84ecd2fb107125f1562 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 11:20:20 -0300 Subject: [PATCH 169/625] Initialize early --- target_java_android.cr | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target_java_android.cr b/target_java_android.cr index e198aca..8e6e086 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -163,6 +163,7 @@ END io << <<-END } }; +Internal.initialize(); if ((flags & API.Loading) != 0) { reqCallback = Internal.withLoading(reqCallback); } @@ -307,6 +308,7 @@ END } static void initialize() { + if (initialized) return; initialized = true; Stetho.initializeWithDefaults(context()); try { From 6c80149b83306d598609f7bab28d5e48e3078e4b Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 11:20:50 -0300 Subject: [PATCH 170/625] Remove redundant check --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 8e6e086..cde6363 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -529,7 +529,7 @@ END } static void makeRequest(String name, JSONObject args, final RequestCallback callback) { - if (!initialized) initialize(); + initialize(); JSONObject body = new JSONObject(); try { From 2c6aefd720c824cccd6f0e6b1ad22e8585147a92 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 11:28:57 -0300 Subject: [PATCH 171/625] Fix cache save --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index cde6363..fefc3ba 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -512,7 +512,7 @@ END Reservoir.putAsync(signature, new JSONObject() {{ try { put("time", encodeDateTime(new GregorianCalendar())); - put("result", result); + put("result", result.getJSONObject("result")); } catch (JSONException e) { e.printStackTrace(); } From 570d058288d468a4c639c119cf6e667e1b008040 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 29 Apr 2017 11:38:28 -0300 Subject: [PATCH 172/625] expose cacheage --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index fefc3ba..cf009c8 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -219,7 +219,7 @@ END } public static class BaseCallback { - int cacheAge = 0; + public int cacheAge = 0; Runnable repeatWithoutCacheRunnable; protected void repeatWithoutCache() { From 232486f98ff9c599d0660acc5dec8d8aa70e98c2 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 2 May 2017 10:39:45 -0300 Subject: [PATCH 173/625] rethink: add sample --- rethinkdb/rethinkdb.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 1e95907..30dfc0c 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -192,6 +192,7 @@ interface RArray extends RDatum { contains(obj: T): RDatum reduce(func: (a: RDatum, b: RDatum) => any): RDatum distinct(): RArray + sample(count: number | RDatum): RArray setInsert(other: any): RArray setUnion(other: any): RArray @@ -232,6 +233,7 @@ interface RStream extends PromiseLike, RStreamOrDatum { limit(other: any): RStream reduce(func: (a: RDatum, b: RDatum) => any): RDatum distinct(): RArray + sample(count: number | RDatum): RStream sum(): RDatum sum(idx: K): RDatum From 8d10d1e5e53bc9715f0153d41da2e635b6cd927a Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 2 May 2017 10:40:14 -0300 Subject: [PATCH 174/625] Don't take a destructive action on a table --- rethinkdb/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rethinkdb/index.ts b/rethinkdb/index.ts index fc80d4d..8532127 100644 --- a/rethinkdb/index.ts +++ b/rethinkdb/index.ts @@ -34,8 +34,8 @@ export async function configure(options: ConfigureOptions) { for (let i = 0; i < realTables.length; ++i) { if (tables.indexOf(realTables[i]) >= 0) continue; - console.log(`Dropping table ${realTables[i]}...`); - await r.tableDrop(realTables[i]); + console.log(`WARNING: Should dropping table ${realTables[i]}...`); + // await r.tableDrop(realTables[i]); } for (let i = 0; i < tables.length; ++i) { From 28024e52d2ad88d9e56f1f9f2f490c05855efb7f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 3 May 2017 11:10:31 -0300 Subject: [PATCH 175/625] Add push --- ast_semantic.cr | 8 ++++++++ rethinkdb/rethinkdb.d.ts | 1 + target_typescript_nodeserver.cr | 3 +++ 3 files changed, 12 insertions(+) diff --git a/ast_semantic.cr b/ast_semantic.cr index 6ad38ab..0675471 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -177,6 +177,14 @@ module AST op.return_type = AST::StringPrimitiveType.new operations << op + op = AST::FunctionOperation.new + op.name = "setPushToken" + op.args = [AST::Field.new] + op.args[0].name = "token" + op.args[0].type = AST::StringPrimitiveType.new + op.return_type = AST::VoidPrimitiveType.new + operations << op + Semantic::CheckEveryTypeDefined.new(self).visit(self) Semantic::CheckNoRecursiveTypes.new(self).visit(self) Semantic::CheckDontReturnSecret.new(self).visit(self) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 30dfc0c..ad67aa3 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -6,6 +6,7 @@ interface DBDevice { screen: {width: number, height: number}; version: string; language: string; + push?: string } interface DBApiCall { diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 6d89fb4..e3847f5 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -266,6 +266,9 @@ export function start(port: number) { fn.ping = async (ctx: Context) => "pong"; +fn.setPushToken = async (ctx: Context, token: string) => { + await r.table("devices").get(ctx.device.id).update({push: token}); +}; END end From 0392c782622f39f069854fde2eabc67db1f0a991 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 3 May 2017 12:32:18 -0300 Subject: [PATCH 176/625] Dont make default overload --- target_java_android.cr | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index cf009c8..d5c2dcd 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -98,12 +98,12 @@ END @ast.operations.each do |op| args = op.args.map {|arg| "final #{native_type arg.type} #{arg.name}" } args << "final #{callback_type op.return_type} callback" - @io << ident(String.build do |io| - io << "static public void #{op.pretty_name}(#{args.join(", ")}) {\n" - io << " #{op.pretty_name}(#{(op.args.map {|arg| arg.name } + ["0", "callback"]).join(", ")});\n" - io << "}" - end) - @io << "\n\n" + #@io << ident(String.build do |io| + # io << "static public void #{op.pretty_name}(#{args.join(", ")}) {\n" + # io << " #{op.pretty_name}(#{(op.args.map {|arg| arg.name } + ["0", "callback"]).join(", ")});\n" + # io << "}" + #end) + #@io << "\n\n" args = args[0..-2] + ["final int flags", args[-1]] @io << ident(String.build do |io| io << "static public void #{op.pretty_name}(#{args.join(", ")}) {\n" @@ -231,18 +231,6 @@ END public abstract void onResult(Error error, T result); } - public abstract static class IntCallback extends BaseCallback { - public abstract void onResult(Error error, int result); - } - - public abstract static class DoubleCallback extends BaseCallback { - public abstract void onResult(Error error, double result); - } - - public abstract static class BooleanCallback extends BaseCallback { - public abstract void onResult(Error error, boolean result); - } - public abstract static class VoidCallback extends BaseCallback { public abstract void onResult(Error error); } @@ -711,15 +699,7 @@ END end def callback_type(t : AST::Type) - case t - when AST::IntPrimitiveType; "IntCallback" - when AST::UIntPrimitiveType; "IntCallback" - when AST::FloatPrimitiveType; "DoubleCallback" - when AST::BoolPrimitiveType; "BooleanCallback" - when AST::VoidPrimitiveType; "VoidCallback" - else - "Callback<#{native_type_not_primitive(t)}>" - end + t.is_a?(AST::VoidPrimitiveType) ? "VoidCallback" : "Callback<#{native_type_not_primitive(t)}>" end end From 5ba08ee9dbd9d2e4d45607b3b1baa2b2d373f170 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 3 May 2017 13:01:10 -0300 Subject: [PATCH 177/625] Fix getDeviceId --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index d5c2dcd..a74fe86 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -240,7 +240,7 @@ END if (pref.contains("deviceId")) callback.onResult(null, pref.getString("deviceId", null)); else { - ping(new Callback() { + ping(API.Default, new Callback() { @Override public void onResult(Error error, String result) { if (error != null) From ad3894371baf4627621e61b156389932af9cb713 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 3 May 2017 13:31:39 -0300 Subject: [PATCH 178/625] Fix base yrl --- target_java_android.cr | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index a74fe86..c25443a 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -98,12 +98,12 @@ END @ast.operations.each do |op| args = op.args.map {|arg| "final #{native_type arg.type} #{arg.name}" } args << "final #{callback_type op.return_type} callback" - #@io << ident(String.build do |io| - # io << "static public void #{op.pretty_name}(#{args.join(", ")}) {\n" - # io << " #{op.pretty_name}(#{(op.args.map {|arg| arg.name } + ["0", "callback"]).join(", ")});\n" - # io << "}" - #end) - #@io << "\n\n" + @io << ident(String.build do |io| + io << "static public void #{op.pretty_name}(#{args.join(", ")}) {\n" + io << " #{op.pretty_name}(#{(op.args.map {|arg| arg.name } + ["0", "callback"]).join(", ")});\n" + io << "}" + end) + @io << "\n\n" args = args[0..-2] + ["final int flags", args[-1]] @io << ident(String.build do |io| io << "static public void #{op.pretty_name}(#{args.join(", ")}) {\n" @@ -253,7 +253,7 @@ END } private static class Internal { - static String baseUrl = "api.zigcore.com.br/pdv"; + static String baseUrl = #{@ast.options.url.inspect}; static OkHttpClient http = null; static ConnectionPool connectionPool = new ConnectionPool(); static SecureRandom random = new SecureRandom(); From be0e642f92e1a7e1031843690765c86d2b8bed49 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 3 May 2017 14:33:57 -0300 Subject: [PATCH 179/625] Improve killing http after too much time --- target_java_android.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index c25443a..29f2ea4 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -264,7 +264,10 @@ END static { dateTimeFormat.setTimeZone(TimeZone.getTimeZone("GMT")); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + createHttpClient(); + } + static void createHttpClient() { TrustManagerFactory trustManagerFactory; try { trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); @@ -543,7 +546,8 @@ END public void run() { sentCount[0] += 1; if (sentCount[0] % 5 == 0) { - connectionPool.evictAll(); + http.dispatcher().executorService().shutdown(); + createHttpClient(); } http.newCall(request).enqueue(new okhttp3.Callback() { @Override From 4392f8f55e39e5672115e967767dced2b561dd01 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 4 May 2017 07:52:34 -0300 Subject: [PATCH 180/625] android: ensure a new connection pool is created every time --- target_java_android.cr | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 29f2ea4..c645916 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -255,7 +255,7 @@ END private static class Internal { static String baseUrl = #{@ast.options.url.inspect}; static OkHttpClient http = null; - static ConnectionPool connectionPool = new ConnectionPool(); + static ConnectionPool connectionPool; static SecureRandom random = new SecureRandom(); static boolean initialized = false; static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); @@ -268,6 +268,8 @@ END } static void createHttpClient() { + connectionPool = new ConnectionPool(); + TrustManagerFactory trustManagerFactory; try { trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); From 12b65868323b8eede1b881932bf9a79dbd16cc22 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 5 May 2017 15:31:01 -0300 Subject: [PATCH 181/625] add timeout on request, and ignore no success --- target_java_android.cr | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index c645916..af7cbed 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -547,6 +547,21 @@ END @Override public void run() { sentCount[0] += 1; + if (sentCount[0] >= 22) { + return; + } + if (sentCount[0] >= 25) { + if (!shouldReceiveResponse[0]) return; + shouldReceiveResponse[0] = false; + timer.cancel(); + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + callback.onResult(new Error() {{type = ErrorType.Connection; message = "Sem Internet";}}, null); + } + }); + return; + } if (sentCount[0] % 5 == 0) { http.dispatcher().executorService().shutdown(); createHttpClient(); @@ -569,18 +584,16 @@ END @Override public void onResponse(Call call, final Response response) throws IOException { if (!shouldReceiveResponse[0]) return; + if (response.code() != 200) { + Log.e("API", "HTTP " + response.code()); + return; + } shouldReceiveResponse[0] = false; timer.cancel(); final String stringBody = response.body().string(); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { - if (response.code() >= 500) { - Log.e("API Fatal", stringBody); - callback.onResult(new Error() {{type = ErrorType.Fatal; message = "HTTP " + response.code();}}, null); - return; - } - try { JSONObject body = new JSONObject(stringBody); @@ -608,7 +621,7 @@ END } }; - timer.schedule(task, 0, 1000); + timer.schedule(task, 0, 1500); } static Calendar toCalendar(Date date){ From 05f20b4189cb20631beaad42ba9833a57616499c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 5 May 2017 18:43:28 -0300 Subject: [PATCH 182/625] Fix waiting for repeated call --- target_typescript_nodeserver.cr | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index e3847f5..602ac69 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -192,8 +192,8 @@ export function start(port: number) { if (call.executionId !== executionId) { call.ok = false; call.error = { - type: "CallExecutionTimeout", - message: "Timeout while waiting for execution somewhere else" + type: "Fatal", + message: "CallExecutionTimeout: Timeout while waiting for execution somewhere else" }; } else { try { @@ -213,6 +213,7 @@ export function start(port: number) { }; } } + call.running = false; } } @@ -235,7 +236,7 @@ export function start(port: number) { res.write(JSON.stringify(response)); res.end(); - await r.table("api_calls").get(call.id).update(call); + r.table("api_calls").get(call.id).update(call).then(); let log = `${moment().format("YYYY-MM-DD HH:mm:ss")} ${call.id} [${call.duration.toFixed(6)}s] ${call.name}() -> `; if (call.ok) From 3de471b355d99d5e7cfbc177c4a6cc0e507f60db Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 5 May 2017 19:12:52 -0300 Subject: [PATCH 183/625] Change connection limit on android --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index af7cbed..db0e5d2 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -268,7 +268,7 @@ END } static void createHttpClient() { - connectionPool = new ConnectionPool(); + connectionPool = new ConnectionPool(10s0); TrustManagerFactory trustManagerFactory; try { From a780d1e88944bb537577580f9b1097fb4e34081c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 5 May 2017 19:13:10 -0300 Subject: [PATCH 184/625] Fix typo --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index db0e5d2..74bf7bb 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -268,7 +268,7 @@ END } static void createHttpClient() { - connectionPool = new ConnectionPool(10s0); + connectionPool = new ConnectionPool(100); TrustManagerFactory trustManagerFactory; try { From c4b243f7703177a36a4ac88030601ede70a206bf Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 5 May 2017 19:17:38 -0300 Subject: [PATCH 185/625] Fix connectionPool ctor --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 74bf7bb..eeeeba5 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -268,7 +268,7 @@ END } static void createHttpClient() { - connectionPool = new ConnectionPool(100); + connectionPool = new ConnectionPool(100, 5, TimeUnit.MINUTES); TrustManagerFactory trustManagerFactory; try { From f2b7a773d511ef20c2845bc35f57034388f1c863 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 5 May 2017 19:20:57 -0300 Subject: [PATCH 186/625] missing import --- target_java_android.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/target_java_android.cr b/target_java_android.cr index eeeeba5..6dd9652 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -59,6 +59,7 @@ import java.util.Map; import java.util.TimeZone; import java.util.Timer; import java.util.TimerTask; +import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; From 5ca7600164df2276430b16799957221ba66d21a5 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 5 May 2017 19:42:12 -0300 Subject: [PATCH 187/625] Avoid dispatcher limit --- target_java_android.cr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target_java_android.cr b/target_java_android.cr index 6dd9652..eb1d979 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -294,8 +294,13 @@ END throw new RuntimeException(e); } + Dispatcher dispatcher = new Dispatcher(); + dispatcher.setMaxRequests(200); + dispatcher.setMaxRequestsPerHost(200); + http = new OkHttpClient.Builder() .connectionPool(connectionPool) + .dispatcher(dispatcher) .sslSocketFactory(sslSocketFactory, trustManager) .addNetworkInterceptor(new StethoInterceptor()) .build(); From 753102e1fbbc9eeff05947fdb9eef6ff96ef5821 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 5 May 2017 19:45:50 -0300 Subject: [PATCH 188/625] fix missing import --- target_java_android.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/target_java_android.cr b/target_java_android.cr index eb1d979..b7509df 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -70,6 +70,7 @@ import javax.net.ssl.X509TrustManager; import okhttp3.Call; import okhttp3.ConnectionPool; +import okhttp3.Dispatcher; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; From c62474c112c9662f5e5aabdb222d04a50a794ffb Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 5 May 2017 20:46:39 -0300 Subject: [PATCH 189/625] okhttp: don't shutdown the previous executor --- target_java_android.cr | 1 - 1 file changed, 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index b7509df..a3525d0 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -570,7 +570,6 @@ END return; } if (sentCount[0] % 5 == 0) { - http.dispatcher().executorService().shutdown(); createHttpClient(); } http.newCall(request).enqueue(new okhttp3.Callback() { From c2062220c2ee86e11e722a5743d3c918be1200a3 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 5 May 2017 21:01:41 -0300 Subject: [PATCH 190/625] Some android timing adjustments --- target_java_android.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index a3525d0..7d95741 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -569,7 +569,7 @@ END }); return; } - if (sentCount[0] % 5 == 0) { + if (sentCount[0] % 4 == 0) { createHttpClient(); } http.newCall(request).enqueue(new okhttp3.Callback() { @@ -627,7 +627,7 @@ END } }; - timer.schedule(task, 0, 1500); + timer.schedule(task, 0, 2000); } static Calendar toCalendar(Date date){ From 5fe28982a2d7f3646dce1eba644b0c9503eae0b4 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 6 May 2017 14:08:46 -0300 Subject: [PATCH 191/625] Check empty enum --- ast_semantic.cr | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ast_semantic.cr b/ast_semantic.cr index 0675471..c5e019e 100644 --- a/ast_semantic.cr +++ b/ast_semantic.cr @@ -114,6 +114,15 @@ module Semantic end end + class CheckEmptyEnum < Visitor + def visit(t : AST::EnumType) + super + if t.values.size == 0 + raise "Enum '#{t.name}' is empty" + end + end + end + class GiveStructAndEnumTypeNames < Visitor @path = [] of String @@ -185,11 +194,13 @@ module AST op.return_type = AST::VoidPrimitiveType.new operations << op + # TODO: Topological Ordering: Semantic::CheckEveryTypeDefined.new(self).visit(self) Semantic::CheckNoRecursiveTypes.new(self).visit(self) Semantic::CheckDontReturnSecret.new(self).visit(self) Semantic::CheckNamingForGettersReturningBool.new(self).visit(self) Semantic::GiveStructAndEnumTypeNames.new(self).visit(self) + Semantic::CheckEmptyEnum.new(self).visit(self) Semantic::CollectStructAndEnumTypes.new(self).visit(self) end end From 54c7679c591f8ae7def72c6d5c2ec5c386d0f5fa Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 6 May 2017 17:53:01 -0300 Subject: [PATCH 192/625] Add API.serviceContext --- target_java_android.cr | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 7d95741..7299314 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -79,6 +79,7 @@ import okhttp3.Response; public class API { static public boolean useStaging = false; + static public Context serviceContext = null; static public int Default = 0; static public int Loading = 1; @@ -324,8 +325,12 @@ END Class.forName("android.app.ActivityThread"); Method method = activityThreadClass.getMethod("currentApplication"); Application app = (Application)method.invoke(null, (Object[]) null); - if (app == null) - throw new RuntimeException(""); + if (app == null) { + if (API.serviceContext != null) + return API.serviceContext; + else + throw new RuntimeException("Failed to get Application, use API.serviceContext to provide a Context"); + } return app; } catch (ClassNotFoundException | NoSuchMethodException | IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { From 87237bea3e2b873ad6140f231867fb25b148bfd3 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 7 May 2017 09:35:01 -0300 Subject: [PATCH 193/625] drop invalid device ids --- target_typescript_nodeserver.cr | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 602ac69..519ba72 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -135,6 +135,9 @@ export function start(port: number) { const {id, ...deviceInfo} = context.device; + if (await r.table("devices").get(context.device.id).eq(null)) + context.device.id = null; + if (!context.device.id) { context.device.id = crypto.randomBytes(20).toString("hex"); From 70b7a84981bc6c090bc0d7c2e29a8145d4ed4bc6 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 7 May 2017 14:11:56 -0300 Subject: [PATCH 194/625] Fix check for invalid device id --- target_typescript_nodeserver.cr | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 519ba72..bc22acc 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -135,10 +135,7 @@ export function start(port: number) { const {id, ...deviceInfo} = context.device; - if (await r.table("devices").get(context.device.id).eq(null)) - context.device.id = null; - - if (!context.device.id) { + if (!context.device.id || await r.table("devices").get(context.device.id).eq(null)) { context.device.id = crypto.randomBytes(20).toString("hex"); r.table("devices").insert({ From b31ac79a33253873ba61aa217a5148d41fbe322f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 8 May 2017 17:41:33 -0300 Subject: [PATCH 195/625] Add ip --- target_typescript_nodeserver.cr | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index bc22acc..7fc4832 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -69,16 +69,17 @@ END ////////////////////////////////////////////////////// const webhooks: { - [signature: string]: (body: string, res: http.ServerResponse) => void + [signature: string]: (body: string, res: http.ServerResponse, ip: string) => void } = {} -export function addWebHook(method: "GET" | "POST", path: string, func: (body: string, res: http.ServerResponse) => void) { +export function addWebHook(method: "GET" | "POST", path: string, func: (body: string, res: http.ServerResponse, ip: string) => void) { webhooks[method + path] = func; } export interface Context { device: DBDevice; startTime: Date; + ip: string; } function sleep(ms: number) { @@ -87,6 +88,7 @@ function sleep(ms: number) { export function start(port: number) { const server = http.createServer((req, res) => { + const ip = (req.headers["x-forwarded-for"] || "").split(",")[0] || req.connection.remoteAddress; req.on("error", (err) => { console.error(err); }); @@ -106,7 +108,7 @@ export function start(port: number) { req.on("end", () => { const signature = req.method! + url.parse(req.url || "").pathname; if (webhooks[signature]) { - webhooks[signature](body, res); + webhooks[signature](body, res, ip); return; } @@ -129,7 +131,8 @@ export function start(port: number) { const request = JSON.parse(body); const context: Context = { device: request.device, - startTime: new Date + startTime: new Date, + ip: ip }; const startTime = process.hrtime(); From eee27c010efe985315888702ec6942aa48dfb1c6 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 8 May 2017 17:52:12 -0300 Subject: [PATCH 196/625] log ip and webhook --- target_typescript_nodeserver.cr | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 7fc4832..adeffde 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -108,6 +108,7 @@ export function start(port: number) { req.on("end", () => { const signature = req.method! + url.parse(req.url || "").pathname; if (webhooks[signature]) { + console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} ${ip} webhook ${signature} with ${body.length} bytes`); webhooks[signature](body, res, ip); return; } @@ -241,7 +242,7 @@ export function start(port: number) { r.table("api_calls").get(call.id).update(call).then(); - let log = `${moment().format("YYYY-MM-DD HH:mm:ss")} ${call.id} [${call.duration.toFixed(6)}s] ${call.name}() -> `; + let log = `${moment().format("YYYY-MM-DD HH:mm:ss")} ${ip} ${call.id} [${call.duration.toFixed(6)}s] ${call.name}() -> `; if (call.ok) log += "OK" else From c125a237ff1d56b2bc18da0113d29f509f977982 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 8 May 2017 18:09:48 -0300 Subject: [PATCH 197/625] IncomingMessage --- target_typescript_nodeserver.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index adeffde..c8990a8 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -69,10 +69,10 @@ END ////////////////////////////////////////////////////// const webhooks: { - [signature: string]: (body: string, res: http.ServerResponse, ip: string) => void + [signature: string]: (body: string, res: http.ServerResponse, req: http.IncomingMessage) => void } = {} -export function addWebHook(method: "GET" | "POST", path: string, func: (body: string, res: http.ServerResponse, ip: string) => void) { +export function addWebHook(method: "GET" | "POST", path: string, func: (body: string, res: http.ServerResponse, req: http.IncomingMessage) => void) { webhooks[method + path] = func; } @@ -109,7 +109,7 @@ export function start(port: number) { const signature = req.method! + url.parse(req.url || "").pathname; if (webhooks[signature]) { console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} ${ip} webhook ${signature} with ${body.length} bytes`); - webhooks[signature](body, res, ip); + webhooks[signature](body, res, req); return; } From e495cd7cdde05ee5f9f24846fd1d6b4ee34d51cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Sun, 21 May 2017 10:49:51 -0300 Subject: [PATCH 198/625] Include hasFields in rethinkdb typing --- rethinkdb/rethinkdb.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index ad67aa3..b457a44 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -281,6 +281,8 @@ interface RTableSlice extends RStream { delete(): RDatum<{}> filter(criteria: (obj: RDatum) => boolean | RDatum): RTableSlice filter(obj: DeepPartial>): RTableSlice + hasFields(fields: Array): RTableSlice + hasFields(field: keyof T): RTableSlice } interface RTableRow extends RDatum { From f28a88f99d9a3ed35b8b1d24f7592c589013d543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Sun, 21 May 2017 11:20:28 -0300 Subject: [PATCH 199/625] Maybe RDatum also has hasField method? --- rethinkdb/rethinkdb.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index b457a44..7861c99 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -215,6 +215,9 @@ interface RArray extends RDatum { group(idx: K): RGroupedStream group(func: (obj: RDatum) => any): RGroupedStream forEach(func: (e: RDatum) => any): RDatum<{}> + + hasFields(fields: Array): RTableSlice + hasFields(field: keyof T): RTableSlice } interface RStream extends PromiseLike, RStreamOrDatum { From 8c98eda58159394574c8ee75762ba3ed9ac7ab36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Sun, 21 May 2017 11:32:51 -0300 Subject: [PATCH 200/625] Oops --- rethinkdb/rethinkdb.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 7861c99..aa263c4 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -175,6 +175,9 @@ interface RDatum extends RStreamOrDatum, PromiseLike { forEach(func: (e: RDatum) => any): RDatum<{}> fold(base: any, func: (acc: RDatum, row: RDatum) => any, options?: {emit: (state: RDatum, row: RDatum, newState: RDatum) => any}): RDatum + + hasFields(fields: Array): RDatum + hasFields(field: keyof T): RDatum } interface RArray extends RDatum { @@ -215,9 +218,6 @@ interface RArray extends RDatum { group(idx: K): RGroupedStream group(func: (obj: RDatum) => any): RGroupedStream forEach(func: (e: RDatum) => any): RDatum<{}> - - hasFields(fields: Array): RTableSlice - hasFields(field: keyof T): RTableSlice } interface RStream extends PromiseLike, RStreamOrDatum { From 64deeb649ffdeab31aa48e98762c73c0e8ea6710 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 31 May 2017 09:49:26 -0400 Subject: [PATCH 201/625] Remove ip from server: Docker doesnt allow getting this --- target_typescript_nodeserver.cr | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index c8990a8..edc9b3b 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -79,7 +79,6 @@ export function addWebHook(method: "GET" | "POST", path: string, func: (body: st export interface Context { device: DBDevice; startTime: Date; - ip: string; } function sleep(ms: number) { @@ -88,7 +87,6 @@ function sleep(ms: number) { export function start(port: number) { const server = http.createServer((req, res) => { - const ip = (req.headers["x-forwarded-for"] || "").split(",")[0] || req.connection.remoteAddress; req.on("error", (err) => { console.error(err); }); @@ -108,7 +106,7 @@ export function start(port: number) { req.on("end", () => { const signature = req.method! + url.parse(req.url || "").pathname; if (webhooks[signature]) { - console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} ${ip} webhook ${signature} with ${body.length} bytes`); + console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} webhook ${signature} with ${body.length} bytes`); webhooks[signature](body, res, req); return; } @@ -132,8 +130,7 @@ export function start(port: number) { const request = JSON.parse(body); const context: Context = { device: request.device, - startTime: new Date, - ip: ip + startTime: new Date }; const startTime = process.hrtime(); @@ -242,7 +239,7 @@ export function start(port: number) { r.table("api_calls").get(call.id).update(call).then(); - let log = `${moment().format("YYYY-MM-DD HH:mm:ss")} ${ip} ${call.id} [${call.duration.toFixed(6)}s] ${call.name}() -> `; + let log = `${moment().format("YYYY-MM-DD HH:mm:ss")} ${call.id} [${call.duration.toFixed(6)}s] ${call.name}() -> `; if (call.ok) log += "OK" else From 80301999165aff71299518b6a1e02825ec95a5c4 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 31 May 2017 09:55:09 -0400 Subject: [PATCH 202/625] Add staging to context, from java --- target_java_android.cr | 1 + target_typescript_nodeserver.cr | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 7299314..e563e9f 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -542,6 +542,7 @@ END body.put("device", device()); body.put("name", name); body.put("args", args); + body.put("staging", API.useStaging); } catch (final JSONException e) { e.printStackTrace(); callback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null); diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index edc9b3b..a212b60 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -79,6 +79,7 @@ export function addWebHook(method: "GET" | "POST", path: string, func: (body: st export interface Context { device: DBDevice; startTime: Date; + staging: boolean; } function sleep(ms: number) { @@ -130,7 +131,8 @@ export function start(port: number) { const request = JSON.parse(body); const context: Context = { device: request.device, - startTime: new Date + startTime: new Date, + staging: request.staging || false }; const startTime = process.hrtime(); From 729646e30e54834568b30605b1d3e553269ae3ae Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 31 May 2017 09:58:42 -0400 Subject: [PATCH 203/625] useStaging for iOS --- target_swift_ios.cr | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/target_swift_ios.cr b/target_swift_ios.cr index 4f5cd40..4845f84 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -6,6 +6,7 @@ class SwiftIosTarget < SwiftTarget import Alamofire class API { + static var useStaging = false END @@ -192,11 +193,11 @@ class APIInternal { "id": randomBytesHex(len: 8), "device": device(), "name": name, - "args": args - ] as [String : Any] - - api.request("https://\\(baseUrl)/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).responseJSON { response in + "args": args, + "staging": API.useStaging + ] as [String : Any] + api.request("https://\\(baseUrl)\\(API.useStaging ? "-staging" : "")/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).responseJSON { response in guard let responseValue = response.result.value else { let error = Error(API.ErrorType.Connection, "no result value") callback(Result.failure(error)) From e0713ee8f60ffd68209b2ef9fffbf994f2d6ff31 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 31 May 2017 12:00:06 -0400 Subject: [PATCH 204/625] mangle java keywords --- target_java.cr | 37 +++++++++++++++++++++++++------------ target_java_android.cr | 18 +++++++++--------- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/target_java.cr b/target_java.cr index 080708f..d95c394 100644 --- a/target_java.cr +++ b/target_java.cr @@ -5,6 +5,19 @@ abstract class JavaTarget < Target super super code end + def mangle(ident) + if %w[ + boolean class if int byte do for while void float double long char synchronized + instanceof extends implements interface abstract static public private protected + final import package throw throws catch finally try new null else return continue + break goto switch default case + ] + "_" + ident + else + ident + end + end + def native_type_not_primitive(t : AST::PrimitiveType) case t when AST::StringPrimitiveType; "String" @@ -59,9 +72,9 @@ abstract class JavaTarget < Target def generate_struct_type(t) String.build do |io| - io << "public static class #{t.name} implements Parcelable, Comparable<#{t.name}> {\n" + io << "public static class #{mangle t.name} implements Parcelable, Comparable<#{t.name}> {\n" t.fields.each do |field| - io << ident "public #{native_type field.type} #{field.name};\n" + io << ident "public #{native_type field.type} #{mangle field.name};\n" end io << ident <<-END @@ -130,15 +143,15 @@ public int describeContents() { return 0; } -public static final Parcelable.Creator<#{t.name}> CREATOR = new Parcelable.Creator<#{t.name}>() { +public static final Parcelable.Creator<#{mangle t.name}> CREATOR = new Parcelable.Creator<#{mangle t.name}>() { @Override - public #{t.name} createFromParcel(Parcel in) { - return new #{t.name}(in); + public #{mangle t.name} createFromParcel(Parcel in) { + return new #{mangle t.name}(in); } @Override - public #{t.name}[] newArray(int size) { - return new #{t.name}[size]; + public #{mangle t.name}[] newArray(int size) { + return new #{mangle t.name}[size]; } }; @@ -149,9 +162,9 @@ END def generate_enum_type(t) String.build do |io| - io << "public enum #{t.name} {\n" + io << "public enum #{mangle t.name} {\n" t.values.each do |value| - io << ident "#{value},\n" + io << ident "#{mangle value},\n" end io << "}" end @@ -180,9 +193,9 @@ END when AST::ArrayType "new #{native_type t}() {{ JSONArray ary = #{obj}.getJSONArray(#{name}); for (int i = 0; i < ary.length(); ++i) add(#{type_from_json(t.base, "ary", "i")}); }}" when AST::StructType - "#{t.name}.fromJSON(#{obj}.getJSONObject(#{name}))" + "#{mangle t.name}.fromJSON(#{obj}.getJSONObject(#{name}))" when AST::EnumType - "#{t.values.map {|v| "#{obj}.getString(#{name}).equals(#{v.inspect}) ? #{t.name}.#{v} : " }.join}null" + "#{t.values.map {|v| "#{obj}.getString(#{name}).equals(#{v.inspect}) ? #{mangle t.name}.#{mangle v} : " }.join}null" when AST::TypeReference type_from_json(t.type, obj, name) else @@ -209,7 +222,7 @@ END when AST::StructType "#{src}.toJSON()" when AST::EnumType - "#{t.values.map {|v| "#{src} == #{t.name}.#{v} ? #{v.inspect} : " }.join}\"\"" + "#{t.values.map {|v| "#{src} == #{mangle t.name}.#{mangle v} ? #{v.inspect} : " }.join}\"\"" when AST::TypeReference type_to_json(t.type, src) else diff --git a/target_java_android.cr b/target_java_android.cr index e563e9f..5fa13ea 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -99,17 +99,17 @@ END end @ast.operations.each do |op| - args = op.args.map {|arg| "final #{native_type arg.type} #{arg.name}" } + args = op.args.map {|arg| "final #{native_type arg.type} #{mangle arg.name}" } args << "final #{callback_type op.return_type} callback" @io << ident(String.build do |io| - io << "static public void #{op.pretty_name}(#{args.join(", ")}) {\n" - io << " #{op.pretty_name}(#{(op.args.map {|arg| arg.name } + ["0", "callback"]).join(", ")});\n" + io << "static public void #{mangle op.pretty_name}(#{args.join(", ")}) {\n" + io << " #{mangle op.pretty_name}(#{(op.args.map {|arg| mngle arg.name } + ["0", "callback"]).join(", ")});\n" io << "}" end) @io << "\n\n" args = args[0..-2] + ["final int flags", args[-1]] @io << ident(String.build do |io| - io << "static public void #{op.pretty_name}(#{args.join(", ")}) {\n" + io << "static public void #{mangle op.pretty_name}(#{args.join(", ")}) {\n" io << ident(String.build do |io| if op.args.size == 0 io << "final JSONObject args = new JSONObject();" @@ -171,7 +171,7 @@ if ((flags & API.Loading) != 0) { reqCallback = Internal.withLoading(reqCallback); } if ((flags & API.Cache) != 0) { - String signature = "#{op.pretty_name}:" + Internal.hash(args.toString()); + String signature = "#{mangle op.pretty_name}:" + Internal.hash(args.toString()); final Internal.RequestCallback reqCallbackPure = reqCallback; final Internal.RequestCallback reqCallbackSaveCache = Internal.withSavingOnCache(signature, reqCallback); Reservoir.getAsync(signature, String.class, new ReservoirGetCallback() { @@ -184,7 +184,7 @@ if ((flags & API.Cache) != 0) { callback.repeatWithoutCacheRunnable = new Runnable() { @Override public void run() { - Internal.makeRequest(#{op.pretty_name.inspect}, args, new Internal.RequestCallback() { + Internal.makeRequest(#{mangle(op.pretty_name).inspect}, args, new Internal.RequestCallback() { @Override public void onResult(Error error, JSONObject result) { callback.cacheAge = 0; @@ -195,17 +195,17 @@ if ((flags & API.Cache) != 0) { }; reqCallbackPure.onResult(null, data); } catch (JSONException e) { - Internal.makeRequest(#{op.pretty_name.inspect}, args, reqCallbackSaveCache); + Internal.makeRequest(#{mangle(op.pretty_name).inspect}, args, reqCallbackSaveCache); } } @Override public void onFailure(Exception e) { - Internal.makeRequest(#{op.pretty_name.inspect}, args, reqCallbackSaveCache); + Internal.makeRequest(#{mangle(op.pretty_name).inspect}, args, reqCallbackSaveCache); } }); } else { - Internal.makeRequest(#{op.pretty_name.inspect}, args, reqCallback); + Internal.makeRequest(#{mangle(op.pretty_name).inspect}, args, reqCallback); } END From 5717d8b077eaae34086920f338f2042d14a36efb Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 31 May 2017 12:26:35 -0400 Subject: [PATCH 205/625] fix mangle --- target_java.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java.cr b/target_java.cr index d95c394..4542cfd 100644 --- a/target_java.cr +++ b/target_java.cr @@ -11,7 +11,7 @@ abstract class JavaTarget < Target instanceof extends implements interface abstract static public private protected final import package throw throws catch finally try new null else return continue break goto switch default case - ] + ].includes? ident "_" + ident else ident From 2d374ffdf89d96f94419071ec324e73278566c89 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 31 May 2017 12:29:46 -0400 Subject: [PATCH 206/625] Fix mangle --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 5fa13ea..545dcd1 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -103,7 +103,7 @@ END args << "final #{callback_type op.return_type} callback" @io << ident(String.build do |io| io << "static public void #{mangle op.pretty_name}(#{args.join(", ")}) {\n" - io << " #{mangle op.pretty_name}(#{(op.args.map {|arg| mngle arg.name } + ["0", "callback"]).join(", ")});\n" + io << " #{mangle op.pretty_name}(#{(op.args.map {|arg| mangle arg.name } + ["0", "callback"]).join(", ")});\n" io << "}" end) @io << "\n\n" From e8815317e9615aa41d5c6461d345497870d9dc74 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 31 May 2017 12:37:50 -0400 Subject: [PATCH 207/625] Fix invoke --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 545dcd1..2ce297b 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -341,7 +341,7 @@ END static Activity getCurrentActivity() { try { Class activityThreadClass = Class.forName("android.app.ActivityThread"); - Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null); + Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null, (Object[]) null); Field activitiesField = activityThreadClass.getDeclaredField("mActivities"); activitiesField.setAccessible(true); From b2b4fe42ff95486e7839bf3e87a7e4f01c50b2b5 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 31 May 2017 12:47:08 -0400 Subject: [PATCH 208/625] Explicit java.lang.Object --- target_java_android.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 2ce297b..5475a7f 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -341,17 +341,17 @@ END static Activity getCurrentActivity() { try { Class activityThreadClass = Class.forName("android.app.ActivityThread"); - Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null, (Object[]) null); + java.lang.Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(null); Field activitiesField = activityThreadClass.getDeclaredField("mActivities"); activitiesField.setAccessible(true); @SuppressWarnings("unchecked") - Map activities = (Map) activitiesField.get(activityThread); + Map activities = (Map) activitiesField.get(activityThread); if (activities == null) return null; - for (Object activityRecord : activities.values()) { + for (java.lang.Object activityRecord : activities.values()) { Class activityRecordClass = activityRecord.getClass(); Field pausedField = activityRecordClass.getDeclaredField("paused"); pausedField.setAccessible(true); From ddce434bce288de24b833068e128b8e14979bd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Wed, 31 May 2017 17:12:25 -0300 Subject: [PATCH 209/625] Include RTable.getNearest and r.point at typing --- rethinkdb/rethinkdb.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index aa263c4..ef07d47 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -26,11 +26,17 @@ interface DBApiCall { interface R_Sorting { __dummy: string } +interface RPoint { + coordinates: [number, number]; + type: "Point"; +} + interface R extends RDB { db(name: string): RDB dbList(): RArray dbCreate(name: string): RDatum<{}> expr(obj: any): RDatum + point(longitude: number, latitude: number): RPoint; uuid(): RDatum range(): RStream range(count: number): RStream @@ -346,4 +352,6 @@ interface RTable extends RTableSlice { getAll(id1: any, id2: any, id3: any, opts?: {index: string}): RTableSlice getAll(id1: any, id2: any, id3: any, id4: any, opts?: {index: string}): RTableSlice between(lower: any, upper: any, opts?: {index: string, leftBound?: "closed" | "opened", rightBound?: "closed" | "opened"}): RTableSlice + + getNearest(id: RPoint, opts: { index: string, maxResults: number, unit: "m" | "km" | "mi" | "nm" | "ft", maxDist: number, geoSystem: "WGS84" | "unit_sphere" }): RTableSlice; } From f1adbccfa13cf869e232a87ec83d88c612f81866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Wed, 31 May 2017 17:14:59 -0300 Subject: [PATCH 210/625] Actually set optional configurations as optional --- rethinkdb/rethinkdb.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index ef07d47..fd1206b 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -353,5 +353,5 @@ interface RTable extends RTableSlice { getAll(id1: any, id2: any, id3: any, id4: any, opts?: {index: string}): RTableSlice between(lower: any, upper: any, opts?: {index: string, leftBound?: "closed" | "opened", rightBound?: "closed" | "opened"}): RTableSlice - getNearest(id: RPoint, opts: { index: string, maxResults: number, unit: "m" | "km" | "mi" | "nm" | "ft", maxDist: number, geoSystem: "WGS84" | "unit_sphere" }): RTableSlice; + getNearest(id: RPoint, opts: { index: string, maxResults?: number, unit?: "m" | "km" | "mi" | "nm" | "ft", maxDist?: number, geoSystem?: "WGS84" | "unit_sphere" }): RTableSlice; } From a81e0b05e8f83bfdfd3e05e55da3a9d7c05be34a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Wed, 31 May 2017 17:25:37 -0300 Subject: [PATCH 211/625] Fix r.point typing --- rethinkdb/rethinkdb.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index fd1206b..2170b06 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -36,7 +36,7 @@ interface R extends RDB { dbList(): RArray dbCreate(name: string): RDatum<{}> expr(obj: any): RDatum - point(longitude: number, latitude: number): RPoint; + point(longitude: RDatum, latitude: RDatum): RPoint; uuid(): RDatum range(): RStream range(count: number): RStream From f8f6124d12a839b977ea07ca5e1ddf9a078eb562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Wed, 31 May 2017 19:38:43 -0300 Subject: [PATCH 212/625] Maybe give IP to API? --- rethinkdb/rethinkdb.d.ts | 1 + target_typescript_nodeserver.cr | 1 + target_typescript_web.cr | 30 ++++++++++++++++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 2170b06..960d43b 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -1,6 +1,7 @@ interface DBDevice { id: string; + ip: string; type: "android" | "ios" | "web"; platform: any; screen: {width: number, height: number}; diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index a212b60..b740a36 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -78,6 +78,7 @@ export function addWebHook(method: "GET" | "POST", path: string, func: (body: st export interface Context { device: DBDevice; + ip: string; startTime: Date; staging: boolean; } diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 24aa265..4a899e8 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -43,12 +43,14 @@ END @io << <<-END ////////////////////////////////////////////////////// -function device() { +async function device() { + const ip = localStorage.getItem("ip") || await getIP(); const parser = new UAParser(); parser.setUA(navigator.userAgent); const agent = parser.getResult(); const me = document.currentScript as HTMLScriptElement; const device: any = { + ip, type: "web", platform: { browser: agent.browser.name, @@ -76,13 +78,37 @@ function randomBytesHex(len: number) { return hex; } +function getIP() { + return new Promise((resolve, reject) => { + const req = new XMLHttpRequest(); + req.open("GET", "https://api.ipify.org/?format=json"); + req.onreadystatechange = () => { + if (req.readyState !== 4) return; + try { + const response = JSON.parse(req.responseText); + localStorage.setItem("ip", response.ip); + + if (response.ip) { + resolve(response.ip); + } else { + reject(); + } + } catch (err) { + console.log(err); + reject(); + } + }; + req.send(); + }); +} + async function makeRequest({name, args}: {name: string, args: any}) { return new Promise((resolve, reject) => { const req = new XMLHttpRequest(); req.open("POST", "https://" + baseUrl + "/" + name); const body = { id: randomBytesHex(8), - device: device(), + device: await device(), name: name, args: args }; From 078d7faac060e31151bedb1a4677bb4847214b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Wed, 31 May 2017 19:54:28 -0300 Subject: [PATCH 213/625] Fix context typing --- target_typescript_nodeserver.cr | 1 - 1 file changed, 1 deletion(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index b740a36..a212b60 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -78,7 +78,6 @@ export function addWebHook(method: "GET" | "POST", path: string, func: (body: st export interface Context { device: DBDevice; - ip: string; startTime: Date; staging: boolean; } From afed375726d3bc0a448541792bf672d4b50b2eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Wed, 31 May 2017 20:13:12 -0300 Subject: [PATCH 214/625] Fix await inside non-async function --- target_typescript_web.cr | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 4a899e8..08f26aa 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -103,12 +103,13 @@ function getIP() { } async function makeRequest({name, args}: {name: string, args: any}) { + const device = await device(); return new Promise((resolve, reject) => { const req = new XMLHttpRequest(); req.open("POST", "https://" + baseUrl + "/" + name); const body = { id: randomBytesHex(8), - device: await device(), + device, name: name, args: args }; From a506dd905ff5a8b9e40a5957227c46301409ca34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Wed, 31 May 2017 20:35:31 -0300 Subject: [PATCH 215/625] Fix device scope name bug and prevent multiple ip requests --- target_typescript_web.cr | 47 ++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 08f26aa..ead9cc0 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -78,38 +78,43 @@ function randomBytesHex(len: number) { return hex; } +const ipRequest: Promise; function getIP() { - return new Promise((resolve, reject) => { - const req = new XMLHttpRequest(); - req.open("GET", "https://api.ipify.org/?format=json"); - req.onreadystatechange = () => { - if (req.readyState !== 4) return; - try { - const response = JSON.parse(req.responseText); - localStorage.setItem("ip", response.ip); - - if (response.ip) { - resolve(response.ip); - } else { + if (!ipRequest) { + ipRequest = new Promise((resolve, reject) => { + const req = new XMLHttpRequest(); + req.open("GET", "https://api.ipify.org/?format=json"); + req.onreadystatechange = () => { + if (req.readyState !== 4) return; + try { + const response = JSON.parse(req.responseText); + localStorage.setItem("ip", response.ip); + + if (response.ip) { + resolve(response.ip); + } else { + reject(); + } + } catch (err) { + console.log(err); reject(); } - } catch (err) { - console.log(err); - reject(); - } - }; - req.send(); - }); + }; + req.send(); + }); + } + + return ipRequest; } async function makeRequest({name, args}: {name: string, args: any}) { - const device = await device(); + const deviceData = await device(); return new Promise((resolve, reject) => { const req = new XMLHttpRequest(); req.open("POST", "https://" + baseUrl + "/" + name); const body = { id: randomBytesHex(8), - device, + device: deviceData, name: name, args: args }; From e673926d23408bd994db097c113b40f577e5c90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Wed, 31 May 2017 20:43:57 -0300 Subject: [PATCH 216/625] const? rly? --- target_typescript_web.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index ead9cc0..387fe8c 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -78,7 +78,7 @@ function randomBytesHex(len: number) { return hex; } -const ipRequest: Promise; +let ipRequest: Promise; function getIP() { if (!ipRequest) { ipRequest = new Promise((resolve, reject) => { From cef7ad25fb0e6b6ed3ec3f1dd72e7bbb47492241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Thu, 1 Jun 2017 11:13:48 -0300 Subject: [PATCH 217/625] Better point typing --- rethinkdb/rethinkdb.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 960d43b..0aebaac 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -37,7 +37,7 @@ interface R extends RDB { dbList(): RArray dbCreate(name: string): RDatum<{}> expr(obj: any): RDatum - point(longitude: RDatum, latitude: RDatum): RPoint; + point(longitude: number | RDatum, latitude: number | RDatum): RPoint; uuid(): RDatum range(): RStream range(count: number): RStream From 0ac736a058b5c7362ce7afcb56e916ac10610c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Thu, 1 Jun 2017 11:14:10 -0300 Subject: [PATCH 218/625] Expose date at RDatum & isEmpty at RArray --- rethinkdb/rethinkdb.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 0aebaac..c4d6607 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -185,6 +185,8 @@ interface RDatum extends RStreamOrDatum, PromiseLike { hasFields(fields: Array): RDatum hasFields(field: keyof T): RDatum + + date(): RDatum; } interface RArray extends RDatum { @@ -204,6 +206,7 @@ interface RArray extends RDatum { reduce(func: (a: RDatum, b: RDatum) => any): RDatum distinct(): RArray sample(count: number | RDatum): RArray + isEmpty(): RDatum; setInsert(other: any): RArray setUnion(other: any): RArray From 1bd4a3cbb7266722ad19d60c4525a8795471ad50 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 5 Jun 2017 11:12:16 -0300 Subject: [PATCH 219/625] useStaging for web --- target_typescript_web.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 24aa265..2973b4c 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -7,7 +7,11 @@ import * as moment from "moment"; import {UAParser} from "ua-parser-js"; const baseUrl = #{@ast.options.url.inspect}; +const useStaging = false; +export function setStaging(use: boolean) { + useStaging = !!use; +} END @@ -79,7 +83,7 @@ function randomBytesHex(len: number) { async function makeRequest({name, args}: {name: string, args: any}) { return new Promise((resolve, reject) => { const req = new XMLHttpRequest(); - req.open("POST", "https://" + baseUrl + "/" + name); + req.open("POST", "https://" + baseUrl + (useStaging ? "-staging" : "") + "/" + name); const body = { id: randomBytesHex(8), device: device(), From ae19a9025a5330c9f2a1c67ac09f7a31fab1fc35 Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Mon, 5 Jun 2017 14:29:47 -0300 Subject: [PATCH 220/625] replacing const for let on useStaging --- target_typescript_web.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 9e1dc4b..ac85a58 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -7,7 +7,7 @@ import * as moment from "moment"; import {UAParser} from "ua-parser-js"; const baseUrl = #{@ast.options.url.inspect}; -const useStaging = false; +let useStaging = false; export function setStaging(use: boolean) { useStaging = !!use; From 3f3e5d5e4de9c9c1335a93ba9b835d9d88676557 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 6 Jun 2017 15:36:13 -0300 Subject: [PATCH 221/625] protect "Object" with mangle --- target_java.cr | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/target_java.cr b/target_java.cr index 4542cfd..18884fd 100644 --- a/target_java.cr +++ b/target_java.cr @@ -11,6 +11,7 @@ abstract class JavaTarget < Target instanceof extends implements interface abstract static public private protected final import package throw throws catch finally try new null else return continue break goto switch default case + Object Class ].includes? ident "_" + ident else @@ -72,13 +73,13 @@ abstract class JavaTarget < Target def generate_struct_type(t) String.build do |io| - io << "public static class #{mangle t.name} implements Parcelable, Comparable<#{t.name}> {\n" + io << "public static class #{mangle t.name} implements Parcelable, Comparable<#{mangle t.name}> {\n" t.fields.each do |field| io << ident "public #{native_type field.type} #{mangle field.name};\n" end io << ident <<-END -public int compareTo(#{t.name} other) { +public int compareTo(#{mangle t.name} other) { return toJSON().toString().compareTo(other.toJSON().toString()); } @@ -98,14 +99,14 @@ END } } -public static #{t.name} fromJSON(final JSONObject json) { - return new #{t.name}(json); +public static #{mangle t.name} fromJSON(final JSONObject json) { + return new #{mangle t.name}(json); } -public #{t.name}() { +public #{mangle t.name}() { } -protected #{t.name}(final JSONObject json) { +protected #{mangle t.name}(final JSONObject json) { try { END @@ -119,7 +120,7 @@ END } } -protected #{t.name}(Parcel in) { +protected #{mangle t.name}(Parcel in) { try { final JSONObject json = new JSONObject(in.readString()); From 057b68ca3a14f480ef2082b7672e9ff136d72571 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 6 Jun 2017 15:43:02 -0300 Subject: [PATCH 222/625] Fix missing mangle --- target_java.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java.cr b/target_java.cr index 18884fd..65d84ce 100644 --- a/target_java.cr +++ b/target_java.cr @@ -64,7 +64,7 @@ abstract class JavaTarget < Target end def native_type(t : AST::StructType | AST::EnumType) - t.name + mangle t.name end def native_type(ref : AST::TypeReference) From 65214639d9b75fc86bf691fd028b34f0b41de384 Mon Sep 17 00:00:00 2001 From: Roberto Date: Thu, 8 Jun 2017 16:49:08 -0300 Subject: [PATCH 223/625] add comparators to R --- rethinkdb/rethinkdb.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index ad67aa3..07f61cd 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -49,6 +49,12 @@ interface R extends RDB { not(obj: any): RDatum and(...objs: any[]): RDatum or(...objs: any[]): RDatum + eq(...objs: any[]): RDatum + ne(...objs: any[]): RDatum + gt(...objs: any[]): RDatum + lt(...objs: any[]): RDatum + ge(...objs: any[]): RDatum + le(...objs: any[]): RDatum now(): RDatum asc(name: T): R_Sorting desc(name: T): R_Sorting From b6509c38c2cd8e2455c28efe1c2db5a2d76c329a Mon Sep 17 00:00:00 2001 From: David Pires Date: Fri, 9 Jun 2017 09:37:39 -0300 Subject: [PATCH 224/625] fold and object --- rethinkdb/rethinkdb.d.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 5482218..645219c 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -50,10 +50,17 @@ interface R extends RDB { branch(c1: any, v1: any, c2: any, v2: any, otherwise: any): RDatum branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, otherwise: any): RDatum branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, c4: any, v4: any, otherwise: any): RDatum - branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, c4: any, v4: any, c5: any, v5: any, otherwise: any): RDatum + branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, c4: any, v4: any, k5: any, v5: any, otherwise: any): RDatum branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, c4: any, v4: any, c5: any, v5: any, c6: any, v6: any, otherwise: any): RDatum branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, c4: any, v4: any, c5: any, v5: any, c6: any, v6: any, c7: any, v7: any, otherwise: any): RDatum not(obj: any): RDatum + object(k1: any, v1: any): RDatum + object(k1: any, v1: any, k2: any, v2: any): RDatum + object(k1: any, v1: any, k2: any, v2: any, k3: any, v3: any): RDatum + object(k1: any, v1: any, k2: any, v2: any, k3: any, v3: any, k4: any, v4: any): RDatum + object(k1: any, v1: any, k2: any, v2: any, k3: any, v3: any, k4: any, v4: any, k5: any, v5: any): RDatum + object(k1: any, v1: any, k2: any, v2: any, k3: any, v3: any, k4: any, v4: any, k5: any, v5: any, k6: any, v6: any): RDatum + object(k1: any, v1: any, k2: any, v2: any, k3: any, v3: any, k4: any, v4: any, k5: any, v5: any, k6: any, v6: any, k7: any, v7: any): RDatum and(...objs: any[]): RDatum or(...objs: any[]): RDatum eq(...objs: any[]): RDatum @@ -267,6 +274,7 @@ interface RStream extends PromiseLike, RStreamOrDatum { group(idx: K): RGroupedStream group(func: (obj: RDatum) => any): RGroupedStream forEach(func: (e: RDatum) => any): RDatum<{}> + fold(base: any, func: (acc: RDatum, row: RDatum) => any, options?: {emit: (state: RDatum, row: RDatum, newState: RDatum) => any}): RDatum } interface RGroupedStream extends RArray { From 7a9bac01245eacf0d52b414653128c8149a857db Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 10 Jun 2017 13:04:29 -0300 Subject: [PATCH 225/625] prevent timeouted calls from executing --- target_typescript_nodeserver.cr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index a212b60..f8ff7ff 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -176,17 +176,17 @@ export function start(port: number) { const res = await r.table("api_calls").insert(call); return res.inserted > 0 ? true : await tryLock(); } - if (!priorCall.running) { - call = priorCall; + call = priorCall; + if (!call.running) { return true; } - if (priorCall.executionId === executionId) { + if (call.executionId === executionId) { return true; } return false; } - for (let i = 0; i < 30; ++i) { + for (let i = 0; i < 600; ++i) { if (await tryLock()) break; await sleep(100); } @@ -196,7 +196,7 @@ export function start(port: number) { call.ok = false; call.error = { type: "Fatal", - message: "CallExecutionTimeout: Timeout while waiting for execution somewhere else" + message: "CallExecutionTimeout: Timeout while waiting for execution somewhere else (is the original container that received this request dead?)" }; } else { try { From 04225d98e88a1ebd5cee39c8f782556c09a6507e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 10 Jun 2017 14:45:39 -0300 Subject: [PATCH 226/625] Await for device creation --- target_typescript_nodeserver.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index f8ff7ff..23aad54 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -141,13 +141,13 @@ export function start(port: number) { if (!context.device.id || await r.table("devices").get(context.device.id).eq(null)) { context.device.id = crypto.randomBytes(20).toString("hex"); - r.table("devices").insert({ + await r.table("devices").insert({ id: context.device.id, date: r.now(), ...deviceInfo - }).then(); + }); } else { - r.table("devices").get(context.device.id).update(deviceInfo).then(); + r.table("devices").get(context.device.id).update(deviceInfo).run(); } const executionId = crypto.randomBytes(20).toString("hex"); @@ -239,7 +239,7 @@ export function start(port: number) { res.write(JSON.stringify(response)); res.end(); - r.table("api_calls").get(call.id).update(call).then(); + r.table("api_calls").get(call.id).update(call).run(); let log = `${moment().format("YYYY-MM-DD HH:mm:ss")} ${call.id} [${call.duration.toFixed(6)}s] ${call.name}() -> `; if (call.ok) From 5d3560045822754ce8b158aeda9bc6a9834f2afb Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 10 Jun 2017 15:12:50 -0300 Subject: [PATCH 227/625] Don't set duration unless ran --- target_typescript_nodeserver.cr | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 23aad54..fc879cc 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -217,12 +217,11 @@ export function start(port: number) { } } call.running = false; + const deltaTime = process.hrtime(startTime); + call.duration = deltaTime[0] + deltaTime[1] * 1e-9; } } - const deltaTime = process.hrtime(startTime); - call.duration = deltaTime[0] + deltaTime[1] * 1e-9; - const response = { id: call.id, ok: call.ok, From 7ec4cd5ce516c051d2419282a78f4eb28bdba188 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 10 Jun 2017 15:15:14 -0300 Subject: [PATCH 228/625] update call only if needed --- target_typescript_nodeserver.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index fc879cc..d139368 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -220,6 +220,8 @@ export function start(port: number) { const deltaTime = process.hrtime(startTime); call.duration = deltaTime[0] + deltaTime[1] * 1e-9; } + + r.table("api_calls").get(call.id).update(call).run(); } const response = { @@ -238,8 +240,6 @@ export function start(port: number) { res.write(JSON.stringify(response)); res.end(); - r.table("api_calls").get(call.id).update(call).run(); - let log = `${moment().format("YYYY-MM-DD HH:mm:ss")} ${call.id} [${call.duration.toFixed(6)}s] ${call.name}() -> `; if (call.ok) log += "OK" From 9fda1cf7f6e81a68545594b32dde4537e9e58139 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 10 Jun 2017 15:16:34 -0300 Subject: [PATCH 229/625] refactor log printing --- target_typescript_nodeserver.cr | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index d139368..15dc952 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -240,13 +240,11 @@ export function start(port: number) { res.write(JSON.stringify(response)); res.end(); - let log = `${moment().format("YYYY-MM-DD HH:mm:ss")} ${call.id} [${call.duration.toFixed(6)}s] ${call.name}() -> `; - if (call.ok) - log += "OK" - else - log += call.error ? call.error.type : "???" - - console.log(log) + console.log( + `${moment().format("YYYY-MM-DD HH:mm:ss")} ` + + `${call.id} [${call.duration.toFixed(6)}s] ` + + `${call.name}() -> ${call.ok ? "OK" : call.error ? call.error.type : "???"}` + ); })().catch(err => { console.error(err); res.writeHead(500); From 638a7648e0207d3a1a96ac7f83ad0bac1d169c2a Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 13 Jun 2017 10:53:13 -0300 Subject: [PATCH 230/625] Never fail for lack of IP --- target_typescript_web.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index ac85a58..24496a2 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -97,11 +97,11 @@ function getIP() { if (response.ip) { resolve(response.ip); } else { - reject(); + resolve("0.0.0.0"); } } catch (err) { console.log(err); - reject(); + resolve("0.0.0.0"); } }; req.send(); From fb87fbc02db80c2d4ea4953fe243a40f0d5ce617 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 15 Jun 2017 11:15:52 -0300 Subject: [PATCH 231/625] Allow integrate server with sentry --- target_typescript_nodeserver.cr | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 15dc952..f0d4c7f 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -10,6 +10,11 @@ import url from "url"; import moment from "moment"; import r from "../rethinkdb"; +let captureError: (e: Error) => void = () => {}; +export function setCaptureErrorFn(fn: (e: Error) => void) { + captureError = fn; +} + END @@ -219,6 +224,9 @@ export function start(port: number) { call.running = false; const deltaTime = process.hrtime(startTime); call.duration = deltaTime[0] + deltaTime[1] * 1e-9; + if (call.error && call.error.type === "Fatal") { + captureError(new Error(call.error.message)); + } } r.table("api_calls").get(call.id).update(call).run(); From 811bcdb78a834a4587de01bc59d580a9e9cc42f1 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 15 Jun 2017 20:09:20 -0300 Subject: [PATCH 232/625] Disable keepAliveTimeout on node --- target_typescript_nodeserver.cr | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index f0d4c7f..64ab231 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -268,6 +268,9 @@ export function start(port: number) { }); }); + if ((server as any).keepAliveTimeout) + (server as any).keepAliveTimeout = 0; + server.listen(port, () => { console.log(`Listening on ${server.address().address}:${server.address().port}`); }); From 03695e86d5c5d65850d6bfc4d1f4880cc771df11 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 16 Jun 2017 08:23:14 -0300 Subject: [PATCH 233/625] Better support for integrating http apis --- target_typescript_nodeserver.cr | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 64ab231..4d65b6d 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -73,12 +73,16 @@ END @io << <<-END ////////////////////////////////////////////////////// -const webhooks: { +const httpHandlers: { [signature: string]: (body: string, res: http.ServerResponse, req: http.IncomingMessage) => void } = {} -export function addWebHook(method: "GET" | "POST", path: string, func: (body: string, res: http.ServerResponse, req: http.IncomingMessage) => void) { - webhooks[method + path] = func; +export function handleHttp(method: "GET" | "POST" | "PUT" | "DELETE", path: string, func: (body: string, res: http.ServerResponse, req: http.IncomingMessage) => void) { + httpHandlers[method + path] = func; +} + +export function handleHttpPrefix(method: "GET" | "POST" | "PUT" | "DELETE", path: string, func: (body: string, res: http.ServerResponse, req: http.IncomingMessage) => void) { + httpHandlers["prefix " + method + path] = func; } export interface Context { @@ -111,11 +115,18 @@ export function start(port: number) { req.on("data", (chunk: any) => body += chunk.toString()); req.on("end", () => { const signature = req.method! + url.parse(req.url || "").pathname; - if (webhooks[signature]) { - console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} webhook ${signature} with ${body.length} bytes`); - webhooks[signature](body, res, req); + if (httpHandlers[signature]) { + console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${signature} -> answered ${body.length} bytes`); + httpHandlers[signature](body, res, req); return; } + for (let target in httpHandlers) { + if (("prefix " + signature).startsWith(target)) { + console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${target} -> answered ${body.length} bytes`); + httpHandlers[target](body, res, req); + return; + } + } switch (req.method) { case "HEAD": { From 29c042b19452cd52f03695b7f804b15fef9643dd Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 16 Jun 2017 14:22:22 -0300 Subject: [PATCH 234/625] Remove wrong information on log --- target_typescript_nodeserver.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 4d65b6d..643f4bf 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -116,13 +116,13 @@ export function start(port: number) { req.on("end", () => { const signature = req.method! + url.parse(req.url || "").pathname; if (httpHandlers[signature]) { - console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${signature} -> answered ${body.length} bytes`); + console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${signature}`); httpHandlers[signature](body, res, req); return; } for (let target in httpHandlers) { if (("prefix " + signature).startsWith(target)) { - console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${target} -> answered ${body.length} bytes`); + console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${target}`); httpHandlers[target](body, res, req); return; } From 633dc5786acd2cf7907e544a54c3e40e6462eb36 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 16 Jun 2017 18:34:09 -0300 Subject: [PATCH 235/625] Add skip --- rethinkdb/rethinkdb.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 645219c..cf61ecd 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -138,6 +138,7 @@ interface RDatum extends RStreamOrDatum, PromiseLike { add(...others: any[]): RDatum mul(...others: any[]): RDatum append(other: any): RDatum + skip(other: any): RDatum limit(other: any): RDatum round(): RDatum floor(): RDatum @@ -214,6 +215,7 @@ interface RArray extends RDatum { append(other: T): RArray filter(criteria: (obj: RDatum) => boolean | RDatum): RArray filter(obj: DeepPartial>): RArray + skip(other: any): RArray limit(other: any): RArray contains(obj: T): RDatum reduce(func: (a: RDatum, b: RDatum) => any): RDatum @@ -257,6 +259,7 @@ interface RStream extends PromiseLike, RStreamOrDatum { coerceTo(type: "array"): RArray filter(criteria: (obj: RDatum) => boolean | RDatum): RStream filter(obj: DeepPartial>): RStream + skip(other: any): RStream limit(other: any): RStream reduce(func: (a: RDatum, b: RDatum) => any): RDatum distinct(): RArray From 89c534172aa71db3136ea2d2d58345d214bfd041 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 16 Jun 2017 18:37:02 -0300 Subject: [PATCH 236/625] yarn update --- rethinkdb/package.json | 14 +- rethinkdb/yarn.lock | 821 +++++++++++++++++++-------------------- target-node/package.json | 4 +- target-node/yarn.lock | 253 ++++++------ target-web/package.json | 4 +- target-web/yarn.lock | 251 ++++++------ 6 files changed, 671 insertions(+), 676 deletions(-) diff --git a/rethinkdb/package.json b/rethinkdb/package.json index 0f3f3dd..36ba420 100644 --- a/rethinkdb/package.json +++ b/rethinkdb/package.json @@ -2,9 +2,9 @@ "name": "@cubos/rethinkdb", "version": "0.0", "dependencies": { - "@types/node": "^7.0.8", + "@types/node": "^7.0.31", "babel-runtime": "^6.23.0", - "rethinkdbdash": "^2.3.28" + "rethinkdbdash": "^2.3.29" }, "main": "index.js", "types": "index.d.ts", @@ -19,11 +19,11 @@ ] }, "devDependencies": { - "babel-cli": "^6.23.0", + "babel-cli": "^6.24.1", "babel-plugin-transform-runtime": "^6.23.0", - "babel-preset-es2015": "^6.22.0", - "babel-preset-es2016": "^6.22.0", - "babel-preset-es2017": "^6.22.0", - "typescript": "^2.2.1" + "babel-preset-es2015": "^6.24.1", + "babel-preset-es2016": "^6.24.1", + "babel-preset-es2017": "^6.24.1", + "typescript": "^2.3.4" } } diff --git a/rethinkdb/yarn.lock b/rethinkdb/yarn.lock index 58e36cf..9721328 100644 --- a/rethinkdb/yarn.lock +++ b/rethinkdb/yarn.lock @@ -2,17 +2,17 @@ # yarn lockfile v1 -"@types/node@^7.0.8": - version "7.0.8" - resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.8.tgz#25e4dd804b630c916ae671233e6d71f6ce18124a" +"@types/node@^7.0.31": + version "7.0.31" + resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.31.tgz#80ea4d175599b2a00149c29a10a4eb2dff592e86" abbrev@1: version "1.1.0" resolved "https://npm.cubos.io/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" ajv@^4.9.1: - version "4.11.5" - resolved "https://npm.cubos.io/ajv/-/ajv-4.11.5.tgz#b6ee74657b993a01dce44b7944d56f485828d5bd" + version "4.11.8" + resolved "https://npm.cubos.io/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" @@ -33,15 +33,15 @@ anymatch@^1.3.0: micromatch "^2.1.5" aproba@^1.0.3: - version "1.1.1" - resolved "https://npm.cubos.io/aproba/-/aproba-1.1.1.tgz#95d3600f07710aa0e9298c726ad5ecf2eacbabab" + version "1.1.2" + resolved "https://npm.cubos.io/aproba/-/aproba-1.1.2.tgz#45c6629094de4e96f693ef7eab74ae079c240fc1" are-we-there-yet@~1.1.2: - version "1.1.2" - resolved "https://npm.cubos.io/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz#80e470e95a084794fe1899262c5667c6e88de1b3" + version "1.1.4" + resolved "https://npm.cubos.io/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz#bb5dca382bb94f05e15194373d16fd3ba1ca110d" dependencies: delegates "^1.0.0" - readable-stream "^2.0.0 || ^1.1.13" + readable-stream "^2.0.6" arr-diff@^2.0.0: version "2.0.0" @@ -50,8 +50,8 @@ arr-diff@^2.0.0: arr-flatten "^1.0.1" arr-flatten@^1.0.1: - version "1.0.1" - resolved "https://npm.cubos.io/arr-flatten/-/arr-flatten-1.0.1.tgz#e5ffe54d45e19f32f216e91eb99c8ce892bb604b" + version "1.0.3" + resolved "https://npm.cubos.io/arr-flatten/-/arr-flatten-1.0.3.tgz#a274ed85ac08849b6bd7847c4580745dc51adfb1" array-unique@^0.2.1: version "0.2.1" @@ -89,13 +89,13 @@ aws4@^1.2.1: version "1.6.0" resolved "https://npm.cubos.io/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" -babel-cli@^6.23.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-cli/-/babel-cli-6.24.0.tgz#a05ffd210dca0c288a26d5319c5ac8669a265ad0" +babel-cli@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-cli/-/babel-cli-6.24.1.tgz#207cd705bba61489b2ea41b5312341cf6aca2283" dependencies: - babel-core "^6.24.0" + babel-core "^6.24.1" babel-polyfill "^6.23.0" - babel-register "^6.24.0" + babel-register "^6.24.1" babel-runtime "^6.22.0" commander "^2.8.1" convert-source-map "^1.1.0" @@ -118,20 +118,20 @@ babel-code-frame@^6.22.0: esutils "^2.0.2" js-tokens "^3.0.0" -babel-core@^6.24.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-core/-/babel-core-6.24.0.tgz#8f36a0a77f5c155aed6f920b844d23ba56742a02" +babel-core@^6.24.1: + version "6.25.0" + resolved "https://npm.cubos.io/babel-core/-/babel-core-6.25.0.tgz#7dd42b0463c742e9d5296deb3ec67a9322dad729" dependencies: babel-code-frame "^6.22.0" - babel-generator "^6.24.0" - babel-helpers "^6.23.0" + babel-generator "^6.25.0" + babel-helpers "^6.24.1" babel-messages "^6.23.0" - babel-register "^6.24.0" + babel-register "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.1" - babel-types "^6.23.0" - babylon "^6.11.0" + babel-template "^6.25.0" + babel-traverse "^6.25.0" + babel-types "^6.25.0" + babylon "^6.17.2" convert-source-map "^1.1.0" debug "^2.1.1" json5 "^0.5.0" @@ -142,119 +142,119 @@ babel-core@^6.24.0: slash "^1.0.0" source-map "^0.5.0" -babel-generator@^6.24.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.24.0.tgz#eba270a8cc4ce6e09a61be43465d7c62c1f87c56" +babel-generator@^6.25.0: + version "6.25.0" + resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.25.0.tgz#33a1af70d5f2890aeb465a4a7793c1df6a9ea9fc" dependencies: babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-types "^6.23.0" + babel-types "^6.25.0" detect-indent "^4.0.0" jsesc "^1.3.0" lodash "^4.2.0" source-map "^0.5.0" trim-right "^1.0.1" -babel-helper-builder-binary-assignment-operator-visitor@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.22.0.tgz#29df56be144d81bdeac08262bfa41d2c5e91cdcd" +babel-helper-builder-binary-assignment-operator-visitor@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz#cce4517ada356f4220bcae8a02c2b346f9a56664" dependencies: - babel-helper-explode-assignable-expression "^6.22.0" + babel-helper-explode-assignable-expression "^6.24.1" babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" -babel-helper-call-delegate@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-call-delegate/-/babel-helper-call-delegate-6.22.0.tgz#119921b56120f17e9dae3f74b4f5cc7bcc1b37ef" +babel-helper-call-delegate@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz#ece6aacddc76e41c3461f88bfc575bd0daa2df8d" dependencies: - babel-helper-hoist-variables "^6.22.0" + babel-helper-hoist-variables "^6.24.1" babel-runtime "^6.22.0" - babel-traverse "^6.22.0" - babel-types "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-helper-define-map@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-helper-define-map/-/babel-helper-define-map-6.23.0.tgz#1444f960c9691d69a2ced6a205315f8fd00804e7" +babel-helper-define-map@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-define-map/-/babel-helper-define-map-6.24.1.tgz#7a9747f258d8947d32d515f6aa1c7bd02204a080" dependencies: - babel-helper-function-name "^6.23.0" + babel-helper-function-name "^6.24.1" babel-runtime "^6.22.0" - babel-types "^6.23.0" + babel-types "^6.24.1" lodash "^4.2.0" -babel-helper-explode-assignable-expression@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.22.0.tgz#c97bf76eed3e0bae4048121f2b9dae1a4e7d0478" +babel-helper-explode-assignable-expression@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz#f25b82cf7dc10433c55f70592d5746400ac22caa" dependencies: babel-runtime "^6.22.0" - babel-traverse "^6.22.0" - babel-types "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-helper-function-name@^6.22.0, babel-helper-function-name@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-helper-function-name/-/babel-helper-function-name-6.23.0.tgz#25742d67175c8903dbe4b6cb9d9e1fcb8dcf23a6" +babel-helper-function-name@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" dependencies: - babel-helper-get-function-arity "^6.22.0" + babel-helper-get-function-arity "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-helper-get-function-arity@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.22.0.tgz#0beb464ad69dc7347410ac6ade9f03a50634f5ce" +babel-helper-get-function-arity@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" -babel-helper-hoist-variables@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.22.0.tgz#3eacbf731d80705845dd2e9718f600cfb9b4ba72" +babel-helper-hoist-variables@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz#1ecb27689c9d25513eadbc9914a73f5408be7a76" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" -babel-helper-optimise-call-expression@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.23.0.tgz#f3ee7eed355b4282138b33d02b78369e470622f5" +babel-helper-optimise-call-expression@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz#f7a13427ba9f73f8f4fa993c54a97882d1244257" dependencies: babel-runtime "^6.22.0" - babel-types "^6.23.0" + babel-types "^6.24.1" -babel-helper-regex@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-regex/-/babel-helper-regex-6.22.0.tgz#79f532be1647b1f0ee3474b5f5c3da58001d247d" +babel-helper-regex@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-regex/-/babel-helper-regex-6.24.1.tgz#d36e22fab1008d79d88648e32116868128456ce8" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" lodash "^4.2.0" -babel-helper-remap-async-to-generator@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.22.0.tgz#2186ae73278ed03b8b15ced089609da981053383" +babel-helper-remap-async-to-generator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" dependencies: - babel-helper-function-name "^6.22.0" + babel-helper-function-name "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.22.0" - babel-traverse "^6.22.0" - babel-types "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-helper-replace-supers@^6.22.0, babel-helper-replace-supers@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-helper-replace-supers/-/babel-helper-replace-supers-6.23.0.tgz#eeaf8ad9b58ec4337ca94223bacdca1f8d9b4bfd" +babel-helper-replace-supers@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz#bf6dbfe43938d17369a213ca8a8bf74b6a90ab1a" dependencies: - babel-helper-optimise-call-expression "^6.23.0" + babel-helper-optimise-call-expression "^6.24.1" babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-helpers@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-helpers/-/babel-helpers-6.23.0.tgz#4f8f2e092d0b6a8808a4bde79c27f1e2ecf0d992" +babel-helpers@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" dependencies: babel-runtime "^6.22.0" - babel-template "^6.23.0" + babel-template "^6.24.1" babel-messages@^6.23.0: version "6.23.0" @@ -280,11 +280,11 @@ babel-plugin-syntax-trailing-function-commas@^6.22.0: version "6.22.0" resolved "https://npm.cubos.io/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" -babel-plugin-transform-async-to-generator@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.22.0.tgz#194b6938ec195ad36efc4c33a971acf00d8cd35e" +babel-plugin-transform-async-to-generator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761" dependencies: - babel-helper-remap-async-to-generator "^6.22.0" + babel-helper-remap-async-to-generator "^6.24.1" babel-plugin-syntax-async-functions "^6.8.0" babel-runtime "^6.22.0" @@ -300,36 +300,36 @@ babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-block-scoping@^6.22.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.23.0.tgz#e48895cf0b375be148cd7c8879b422707a053b51" +babel-plugin-transform-es2015-block-scoping@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.24.1.tgz#76c295dc3a4741b1665adfd3167215dcff32a576" dependencies: babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" lodash "^4.2.0" -babel-plugin-transform-es2015-classes@^6.22.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.23.0.tgz#49b53f326202a2fd1b3bbaa5e2edd8a4f78643c1" +babel-plugin-transform-es2015-classes@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db" dependencies: - babel-helper-define-map "^6.23.0" - babel-helper-function-name "^6.23.0" - babel-helper-optimise-call-expression "^6.23.0" - babel-helper-replace-supers "^6.23.0" + babel-helper-define-map "^6.24.1" + babel-helper-function-name "^6.24.1" + babel-helper-optimise-call-expression "^6.24.1" + babel-helper-replace-supers "^6.24.1" babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-plugin-transform-es2015-computed-properties@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.22.0.tgz#7c383e9629bba4820c11b0425bdd6290f7f057e7" +babel-plugin-transform-es2015-computed-properties@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz#6fe2a8d16895d5634f4cd999b6d3480a308159b3" dependencies: babel-runtime "^6.22.0" - babel-template "^6.22.0" + babel-template "^6.24.1" babel-plugin-transform-es2015-destructuring@^6.22.0: version "6.23.0" @@ -337,12 +337,12 @@ babel-plugin-transform-es2015-destructuring@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-duplicate-keys@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.22.0.tgz#672397031c21610d72dd2bbb0ba9fb6277e1c36b" +babel-plugin-transform-es2015-duplicate-keys@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz#73eb3d310ca969e3ef9ec91c53741a6f1576423e" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" babel-plugin-transform-es2015-for-of@^6.22.0: version "6.23.0" @@ -350,13 +350,13 @@ babel-plugin-transform-es2015-for-of@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-function-name@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.22.0.tgz#f5fcc8b09093f9a23c76ac3d9e392c3ec4b77104" +babel-plugin-transform-es2015-function-name@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz#834c89853bc36b1af0f3a4c5dbaa94fd8eacaa8b" dependencies: - babel-helper-function-name "^6.22.0" + babel-helper-function-name "^6.24.1" babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" babel-plugin-transform-es2015-literals@^6.22.0: version "6.22.0" @@ -364,63 +364,63 @@ babel-plugin-transform-es2015-literals@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-modules-amd@^6.24.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.0.tgz#a1911fb9b7ec7e05a43a63c5995007557bcf6a2e" +babel-plugin-transform-es2015-modules-amd@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154" dependencies: - babel-plugin-transform-es2015-modules-commonjs "^6.24.0" + babel-plugin-transform-es2015-modules-commonjs "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.22.0" + babel-template "^6.24.1" -babel-plugin-transform-es2015-modules-commonjs@^6.24.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.24.0.tgz#e921aefb72c2cc26cb03d107626156413222134f" +babel-plugin-transform-es2015-modules-commonjs@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.24.1.tgz#d3e310b40ef664a36622200097c6d440298f2bfe" dependencies: - babel-plugin-transform-strict-mode "^6.22.0" + babel-plugin-transform-strict-mode "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-types "^6.24.1" -babel-plugin-transform-es2015-modules-systemjs@^6.22.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.23.0.tgz#ae3469227ffac39b0310d90fec73bfdc4f6317b0" +babel-plugin-transform-es2015-modules-systemjs@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" dependencies: - babel-helper-hoist-variables "^6.22.0" + babel-helper-hoist-variables "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" + babel-template "^6.24.1" -babel-plugin-transform-es2015-modules-umd@^6.24.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.0.tgz#fd5fa63521cae8d273927c3958afd7c067733450" +babel-plugin-transform-es2015-modules-umd@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz#ac997e6285cd18ed6176adb607d602344ad38468" dependencies: - babel-plugin-transform-es2015-modules-amd "^6.24.0" + babel-plugin-transform-es2015-modules-amd "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" + babel-template "^6.24.1" -babel-plugin-transform-es2015-object-super@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.22.0.tgz#daa60e114a042ea769dd53fe528fc82311eb98fc" +babel-plugin-transform-es2015-object-super@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz#24cef69ae21cb83a7f8603dad021f572eb278f8d" dependencies: - babel-helper-replace-supers "^6.22.0" + babel-helper-replace-supers "^6.24.1" babel-runtime "^6.22.0" -babel-plugin-transform-es2015-parameters@^6.22.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.23.0.tgz#3a2aabb70c8af945d5ce386f1a4250625a83ae3b" +babel-plugin-transform-es2015-parameters@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" dependencies: - babel-helper-call-delegate "^6.22.0" - babel-helper-get-function-arity "^6.22.0" + babel-helper-call-delegate "^6.24.1" + babel-helper-get-function-arity "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.23.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" -babel-plugin-transform-es2015-shorthand-properties@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.22.0.tgz#8ba776e0affaa60bff21e921403b8a652a2ff723" +babel-plugin-transform-es2015-shorthand-properties@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz#24f875d6721c87661bbd99a4622e51f14de38aa0" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" babel-plugin-transform-es2015-spread@^6.22.0: version "6.22.0" @@ -428,13 +428,13 @@ babel-plugin-transform-es2015-spread@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-sticky-regex@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.22.0.tgz#ab316829e866ee3f4b9eb96939757d19a5bc4593" +babel-plugin-transform-es2015-sticky-regex@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz#00c1cdb1aca71112cdf0cf6126c2ed6b457ccdbc" dependencies: - babel-helper-regex "^6.22.0" + babel-helper-regex "^6.24.1" babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" babel-plugin-transform-es2015-template-literals@^6.22.0: version "6.22.0" @@ -448,27 +448,27 @@ babel-plugin-transform-es2015-typeof-symbol@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-unicode-regex@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.22.0.tgz#8d9cc27e7ee1decfe65454fb986452a04a613d20" +babel-plugin-transform-es2015-unicode-regex@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz#d38b12f42ea7323f729387f18a7c5ae1faeb35e9" dependencies: - babel-helper-regex "^6.22.0" + babel-helper-regex "^6.24.1" babel-runtime "^6.22.0" regexpu-core "^2.0.0" -babel-plugin-transform-exponentiation-operator@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.22.0.tgz#d57c8335281918e54ef053118ce6eb108468084d" +babel-plugin-transform-exponentiation-operator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz#2ab0c9c7f3098fa48907772bb813fe41e8de3a0e" dependencies: - babel-helper-builder-binary-assignment-operator-visitor "^6.22.0" + babel-helper-builder-binary-assignment-operator-visitor "^6.24.1" babel-plugin-syntax-exponentiation-operator "^6.8.0" babel-runtime "^6.22.0" -babel-plugin-transform-regenerator@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.22.0.tgz#65740593a319c44522157538d690b84094617ea6" +babel-plugin-transform-regenerator@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.24.1.tgz#b8da305ad43c3c99b4848e4fe4037b770d23c418" dependencies: - regenerator-transform "0.9.8" + regenerator-transform "0.9.11" babel-plugin-transform-runtime@^6.23.0: version "6.23.0" @@ -476,12 +476,12 @@ babel-plugin-transform-runtime@^6.23.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-strict-mode@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.22.0.tgz#e008df01340fdc87e959da65991b7e05970c8c7c" +babel-plugin-transform-strict-mode@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758" dependencies: babel-runtime "^6.22.0" - babel-types "^6.22.0" + babel-types "^6.24.1" babel-polyfill@^6.23.0: version "6.23.0" @@ -491,53 +491,53 @@ babel-polyfill@^6.23.0: core-js "^2.4.0" regenerator-runtime "^0.10.0" -babel-preset-es2015@^6.22.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-preset-es2015/-/babel-preset-es2015-6.24.0.tgz#c162d68b1932696e036cd3110dc1ccd303d2673a" +babel-preset-es2015@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz#d44050d6bc2c9feea702aaf38d727a0210538939" dependencies: babel-plugin-check-es2015-constants "^6.22.0" babel-plugin-transform-es2015-arrow-functions "^6.22.0" babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoping "^6.22.0" - babel-plugin-transform-es2015-classes "^6.22.0" - babel-plugin-transform-es2015-computed-properties "^6.22.0" + babel-plugin-transform-es2015-block-scoping "^6.24.1" + babel-plugin-transform-es2015-classes "^6.24.1" + babel-plugin-transform-es2015-computed-properties "^6.24.1" babel-plugin-transform-es2015-destructuring "^6.22.0" - babel-plugin-transform-es2015-duplicate-keys "^6.22.0" + babel-plugin-transform-es2015-duplicate-keys "^6.24.1" babel-plugin-transform-es2015-for-of "^6.22.0" - babel-plugin-transform-es2015-function-name "^6.22.0" + babel-plugin-transform-es2015-function-name "^6.24.1" babel-plugin-transform-es2015-literals "^6.22.0" - babel-plugin-transform-es2015-modules-amd "^6.24.0" - babel-plugin-transform-es2015-modules-commonjs "^6.24.0" - babel-plugin-transform-es2015-modules-systemjs "^6.22.0" - babel-plugin-transform-es2015-modules-umd "^6.24.0" - babel-plugin-transform-es2015-object-super "^6.22.0" - babel-plugin-transform-es2015-parameters "^6.22.0" - babel-plugin-transform-es2015-shorthand-properties "^6.22.0" + babel-plugin-transform-es2015-modules-amd "^6.24.1" + babel-plugin-transform-es2015-modules-commonjs "^6.24.1" + babel-plugin-transform-es2015-modules-systemjs "^6.24.1" + babel-plugin-transform-es2015-modules-umd "^6.24.1" + babel-plugin-transform-es2015-object-super "^6.24.1" + babel-plugin-transform-es2015-parameters "^6.24.1" + babel-plugin-transform-es2015-shorthand-properties "^6.24.1" babel-plugin-transform-es2015-spread "^6.22.0" - babel-plugin-transform-es2015-sticky-regex "^6.22.0" + babel-plugin-transform-es2015-sticky-regex "^6.24.1" babel-plugin-transform-es2015-template-literals "^6.22.0" babel-plugin-transform-es2015-typeof-symbol "^6.22.0" - babel-plugin-transform-es2015-unicode-regex "^6.22.0" - babel-plugin-transform-regenerator "^6.22.0" + babel-plugin-transform-es2015-unicode-regex "^6.24.1" + babel-plugin-transform-regenerator "^6.24.1" -babel-preset-es2016@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-preset-es2016/-/babel-preset-es2016-6.22.0.tgz#b061aaa3983d40c9fbacfa3743b5df37f336156c" +babel-preset-es2016@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-preset-es2016/-/babel-preset-es2016-6.24.1.tgz#f900bf93e2ebc0d276df9b8ab59724ebfd959f8b" dependencies: - babel-plugin-transform-exponentiation-operator "^6.22.0" + babel-plugin-transform-exponentiation-operator "^6.24.1" -babel-preset-es2017@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-preset-es2017/-/babel-preset-es2017-6.22.0.tgz#de2f9da5a30c50d293fb54a0ba15d6ddc573f0f2" +babel-preset-es2017@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-preset-es2017/-/babel-preset-es2017-6.24.1.tgz#597beadfb9f7f208bcfd8a12e9b2b29b8b2f14d1" dependencies: babel-plugin-syntax-trailing-function-commas "^6.22.0" - babel-plugin-transform-async-to-generator "^6.22.0" + babel-plugin-transform-async-to-generator "^6.24.1" -babel-register@^6.24.0: - version "6.24.0" - resolved "https://npm.cubos.io/babel-register/-/babel-register-6.24.0.tgz#5e89f8463ba9970356d02eb07dabe3308b080cfd" +babel-register@^6.24.1: + version "6.24.1" + resolved "https://npm.cubos.io/babel-register/-/babel-register-6.24.1.tgz#7e10e13a2f71065bdfad5a1787ba45bca6ded75f" dependencies: - babel-core "^6.24.0" + babel-core "^6.24.1" babel-runtime "^6.22.0" core-js "^2.4.0" home-or-tmp "^2.0.0" @@ -552,46 +552,46 @@ babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0: core-js "^2.4.0" regenerator-runtime "^0.10.0" -babel-template@^6.22.0, babel-template@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-template/-/babel-template-6.23.0.tgz#04d4f270adbb3aa704a8143ae26faa529238e638" +babel-template@^6.24.1, babel-template@^6.25.0: + version "6.25.0" + resolved "https://npm.cubos.io/babel-template/-/babel-template-6.25.0.tgz#665241166b7c2aa4c619d71e192969552b10c071" dependencies: babel-runtime "^6.22.0" - babel-traverse "^6.23.0" - babel-types "^6.23.0" - babylon "^6.11.0" + babel-traverse "^6.25.0" + babel-types "^6.25.0" + babylon "^6.17.2" lodash "^4.2.0" -babel-traverse@^6.22.0, babel-traverse@^6.23.0, babel-traverse@^6.23.1: - version "6.23.1" - resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.23.1.tgz#d3cb59010ecd06a97d81310065f966b699e14f48" +babel-traverse@^6.24.1, babel-traverse@^6.25.0: + version "6.25.0" + resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.25.0.tgz#2257497e2fcd19b89edc13c4c91381f9512496f1" dependencies: babel-code-frame "^6.22.0" babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-types "^6.23.0" - babylon "^6.15.0" + babel-types "^6.25.0" + babylon "^6.17.2" debug "^2.2.0" globals "^9.0.0" invariant "^2.2.0" lodash "^4.2.0" -babel-types@^6.19.0, babel-types@^6.22.0, babel-types@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-types/-/babel-types-6.23.0.tgz#bb17179d7538bad38cd0c9e115d340f77e7e9acf" +babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.25.0: + version "6.25.0" + resolved "https://npm.cubos.io/babel-types/-/babel-types-6.25.0.tgz#70afb248d5660e5d18f811d91c8303b54134a18e" dependencies: babel-runtime "^6.22.0" esutils "^2.0.2" lodash "^4.2.0" to-fast-properties "^1.0.1" -babylon@^6.11.0, babylon@^6.15.0: - version "6.16.1" - resolved "https://npm.cubos.io/babylon/-/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3" +babylon@^6.17.2: + version "6.17.3" + resolved "https://npm.cubos.io/babylon/-/babylon-6.17.3.tgz#1327d709950b558f204e5352587fd0290f8d8e48" -balanced-match@^0.4.1: - version "0.4.2" - resolved "https://npm.cubos.io/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" bcrypt-pbkdf@^1.0.0: version "1.0.1" @@ -619,11 +619,11 @@ boom@2.x.x: dependencies: hoek "2.x.x" -brace-expansion@^1.0.0: - version "1.1.6" - resolved "https://npm.cubos.io/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" +brace-expansion@^1.1.7: + version "1.1.8" + resolved "https://npm.cubos.io/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" dependencies: - balanced-match "^0.4.1" + balanced-match "^1.0.0" concat-map "0.0.1" braces@^1.8.2: @@ -634,10 +634,6 @@ braces@^1.8.2: preserve "^0.2.0" repeat-element "^1.1.2" -buffer-shims@^1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" - caseless@~0.12.0: version "0.12.0" resolved "https://npm.cubos.io/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" @@ -653,8 +649,8 @@ chalk@^1.1.0: supports-color "^2.0.0" chokidar@^1.6.1: - version "1.6.1" - resolved "https://npm.cubos.io/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2" + version "1.7.0" + resolved "https://npm.cubos.io/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" dependencies: anymatch "^1.3.0" async-each "^1.0.0" @@ -696,8 +692,8 @@ console-control-strings@^1.0.0, console-control-strings@~1.1.0: resolved "https://npm.cubos.io/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" convert-source-map@^1.1.0: - version "1.4.0" - resolved "https://npm.cubos.io/convert-source-map/-/convert-source-map-1.4.0.tgz#e3dad195bf61bfe13a7a3c73e9876ec14a0268f3" + version "1.5.0" + resolved "https://npm.cubos.io/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" core-js@^2.4.0: version "2.4.1" @@ -720,20 +716,14 @@ dashdash@^1.12.0: assert-plus "^1.0.0" debug@^2.1.1, debug@^2.2.0: - version "2.6.3" - resolved "https://npm.cubos.io/debug/-/debug-2.6.3.tgz#0f7eb8c30965ec08c72accfa0130c8b79984141d" - dependencies: - ms "0.7.2" - -debug@~2.2.0: - version "2.2.0" - resolved "https://npm.cubos.io/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + version "2.6.8" + resolved "https://npm.cubos.io/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" dependencies: - ms "0.7.1" + ms "2.0.0" deep-extend@~0.4.0: - version "0.4.1" - resolved "https://npm.cubos.io/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253" + version "0.4.2" + resolved "https://npm.cubos.io/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" delayed-stream@~1.0.0: version "1.0.0" @@ -776,8 +766,8 @@ expand-range@^1.8.1: fill-range "^2.1.0" extend@~3.0.0: - version "3.0.0" - resolved "https://npm.cubos.io/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4" + version "3.0.1" + resolved "https://npm.cubos.io/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" extglob@^0.3.1: version "0.3.2" @@ -790,8 +780,8 @@ extsprintf@1.0.2: resolved "https://npm.cubos.io/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" filename-regex@^2.0.0: - version "2.0.0" - resolved "https://npm.cubos.io/filename-regex/-/filename-regex-2.0.0.tgz#996e3e80479b98b9897f15a8a58b3d084e926775" + version "2.0.1" + resolved "https://npm.cubos.io/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" fill-range@^2.1.0: version "2.2.3" @@ -818,8 +808,8 @@ forever-agent@~0.6.1: resolved "https://npm.cubos.io/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" form-data@~2.1.1: - version "2.1.2" - resolved "https://npm.cubos.io/form-data/-/form-data-2.1.2.tgz#89c3534008b97eada4cbb157d58f6f5df025eae4" + version "2.1.4" + resolved "https://npm.cubos.io/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" dependencies: asynckit "^0.4.0" combined-stream "^1.0.5" @@ -834,13 +824,13 @@ fs.realpath@^1.0.0: resolved "https://npm.cubos.io/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" fsevents@^1.0.0: - version "1.1.1" - resolved "https://npm.cubos.io/fsevents/-/fsevents-1.1.1.tgz#f19fd28f43eeaf761680e519a203c4d0b3d31aff" + version "1.1.2" + resolved "https://npm.cubos.io/fsevents/-/fsevents-1.1.2.tgz#3282b713fb3ad80ede0e9fcf4611b5aa6fc033f4" dependencies: nan "^2.3.0" - node-pre-gyp "^0.6.29" + node-pre-gyp "^0.6.36" -fstream-ignore@~1.0.5: +fstream-ignore@^1.0.5: version "1.0.5" resolved "https://npm.cubos.io/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" dependencies: @@ -848,7 +838,7 @@ fstream-ignore@~1.0.5: inherits "2" minimatch "^3.0.0" -fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10: +fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: version "1.0.11" resolved "https://npm.cubos.io/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" dependencies: @@ -857,9 +847,9 @@ fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10: mkdirp ">=0.5 0" rimraf "2" -gauge@~2.7.1: - version "2.7.3" - resolved "https://npm.cubos.io/gauge/-/gauge-2.7.3.tgz#1c23855f962f17b3ad3d0dc7443f304542edfe09" +gauge@~2.7.3: + version "2.7.4" + resolved "https://npm.cubos.io/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" dependencies: aproba "^1.0.3" console-control-strings "^1.0.0" @@ -871,8 +861,8 @@ gauge@~2.7.1: wide-align "^1.1.0" getpass@^0.1.1: - version "0.1.6" - resolved "https://npm.cubos.io/getpass/-/getpass-0.1.6.tgz#283ffd9fc1256840875311c1b60e8c40187110e6" + version "0.1.7" + resolved "https://npm.cubos.io/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" dependencies: assert-plus "^1.0.0" @@ -890,19 +880,19 @@ glob-parent@^2.0.0: is-glob "^2.0.0" glob@^7.0.0, glob@^7.0.5: - version "7.1.1" - resolved "https://npm.cubos.io/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" + version "7.1.2" + resolved "https://npm.cubos.io/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "^3.0.2" + minimatch "^3.0.4" once "^1.3.0" path-is-absolute "^1.0.0" globals@^9.0.0: - version "9.16.0" - resolved "https://npm.cubos.io/globals/-/globals-9.16.0.tgz#63e903658171ec2d9f51b1d31de5e2b8dc01fb80" + version "9.18.0" + resolved "https://npm.cubos.io/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" graceful-fs@^4.1.2, graceful-fs@^4.1.4: version "4.1.11" @@ -988,13 +978,13 @@ is-binary-path@^1.0.0: dependencies: binary-extensions "^1.0.0" -is-buffer@^1.0.2: +is-buffer@^1.1.5: version "1.1.5" resolved "https://npm.cubos.io/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" is-dotfile@^1.0.0: - version "1.0.2" - resolved "https://npm.cubos.io/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d" + version "1.0.3" + resolved "https://npm.cubos.io/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" is-equal-shallow@^0.1.3: version "0.1.3" @@ -1028,12 +1018,18 @@ is-glob@^2.0.0, is-glob@^2.0.1: dependencies: is-extglob "^1.0.0" -is-number@^2.0.2, is-number@^2.1.0: +is-number@^2.1.0: version "2.1.0" resolved "https://npm.cubos.io/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" dependencies: kind-of "^3.0.2" +is-number@^3.0.0: + version "3.0.0" + resolved "https://npm.cubos.io/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + dependencies: + kind-of "^3.0.2" + is-posix-bracket@^0.1.0: version "0.1.1" resolved "https://npm.cubos.io/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" @@ -1060,12 +1056,6 @@ isstream@~0.1.2: version "0.1.2" resolved "https://npm.cubos.io/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" -jodid25519@^1.0.0: - version "1.0.2" - resolved "https://npm.cubos.io/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967" - dependencies: - jsbn "~0.1.0" - js-tokens@^3.0.0: version "3.0.1" resolved "https://npm.cubos.io/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" @@ -1114,10 +1104,16 @@ jsprim@^1.2.2: verror "1.3.6" kind-of@^3.0.2: - version "3.1.0" - resolved "https://npm.cubos.io/kind-of/-/kind-of-3.1.0.tgz#475d698a5e49ff5e53d14e3e732429dc8bf4cf47" + version "3.2.2" + resolved "https://npm.cubos.io/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + dependencies: + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://npm.cubos.io/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" dependencies: - is-buffer "^1.0.2" + is-buffer "^1.1.5" lodash@^4.2.0: version "4.17.4" @@ -1147,21 +1143,21 @@ micromatch@^2.1.5: parse-glob "^3.0.4" regex-cache "^0.4.2" -mime-db@~1.26.0: - version "1.26.0" - resolved "https://npm.cubos.io/mime-db/-/mime-db-1.26.0.tgz#eaffcd0e4fc6935cf8134da246e2e6c35305adff" +mime-db@~1.27.0: + version "1.27.0" + resolved "https://npm.cubos.io/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1" mime-types@^2.1.12, mime-types@~2.1.7: - version "2.1.14" - resolved "https://npm.cubos.io/mime-types/-/mime-types-2.1.14.tgz#f7ef7d97583fcaf3b7d282b6f8b5679dab1e94ee" + version "2.1.15" + resolved "https://npm.cubos.io/mime-types/-/mime-types-2.1.15.tgz#a4ebf5064094569237b8cf70046776d09fc92aed" dependencies: - mime-db "~1.26.0" + mime-db "~1.27.0" -minimatch@^3.0.0, minimatch@^3.0.2: - version "3.0.3" - resolved "https://npm.cubos.io/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" +minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: + version "3.0.4" + resolved "https://npm.cubos.io/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: - brace-expansion "^1.0.0" + brace-expansion "^1.1.7" minimist@0.0.8: version "0.0.8" @@ -1171,55 +1167,54 @@ minimist@^1.2.0: version "1.2.0" resolved "https://npm.cubos.io/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" -"mkdirp@>=0.5 0", mkdirp@^0.5.1, mkdirp@~0.5.1: +"mkdirp@>=0.5 0", mkdirp@^0.5.1: version "0.5.1" resolved "https://npm.cubos.io/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: minimist "0.0.8" -ms@0.7.1: - version "0.7.1" - resolved "https://npm.cubos.io/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" - -ms@0.7.2: - version "0.7.2" - resolved "https://npm.cubos.io/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" +ms@2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" nan@^2.3.0: - version "2.5.1" - resolved "https://npm.cubos.io/nan/-/nan-2.5.1.tgz#d5b01691253326a97a2bbee9e61c55d8d60351e2" - -node-pre-gyp@^0.6.29: - version "0.6.33" - resolved "https://npm.cubos.io/node-pre-gyp/-/node-pre-gyp-0.6.33.tgz#640ac55198f6a925972e0c16c4ac26a034d5ecc9" - dependencies: - mkdirp "~0.5.1" - nopt "~3.0.6" - npmlog "^4.0.1" - rc "~1.1.6" - request "^2.79.0" - rimraf "~2.5.4" - semver "~5.3.0" - tar "~2.2.1" - tar-pack "~3.3.0" - -nopt@~3.0.6: - version "3.0.6" - resolved "https://npm.cubos.io/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" + version "2.6.2" + resolved "https://npm.cubos.io/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" + +node-pre-gyp@^0.6.36: + version "0.6.36" + resolved "https://npm.cubos.io/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz#db604112cb74e0d477554e9b505b17abddfab786" + dependencies: + mkdirp "^0.5.1" + nopt "^4.0.1" + npmlog "^4.0.2" + rc "^1.1.7" + request "^2.81.0" + rimraf "^2.6.1" + semver "^5.3.0" + tar "^2.2.1" + tar-pack "^3.4.0" + +nopt@^4.0.1: + version "4.0.1" + resolved "https://npm.cubos.io/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" dependencies: abbrev "1" + osenv "^0.1.4" normalize-path@^2.0.1: - version "2.0.1" - resolved "https://npm.cubos.io/normalize-path/-/normalize-path-2.0.1.tgz#47886ac1662760d4261b7d979d241709d3ce3f7a" + version "2.1.1" + resolved "https://npm.cubos.io/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + dependencies: + remove-trailing-separator "^1.0.1" -npmlog@^4.0.1: - version "4.0.2" - resolved "https://npm.cubos.io/npmlog/-/npmlog-4.0.2.tgz#d03950e0e78ce1527ba26d2a7592e9348ac3e75f" +npmlog@^4.0.2: + version "4.1.0" + resolved "https://npm.cubos.io/npmlog/-/npmlog-4.1.0.tgz#dc59bee85f64f00ed424efb2af0783df25d1c0b5" dependencies: are-we-there-yet "~1.1.2" console-control-strings "~1.1.0" - gauge "~2.7.1" + gauge "~2.7.3" set-blocking "~2.0.0" number-is-nan@^1.0.0: @@ -1241,26 +1236,27 @@ object.omit@^2.0.0: for-own "^0.1.4" is-extendable "^0.1.1" -once@^1.3.0: +once@^1.3.0, once@^1.3.3: version "1.4.0" resolved "https://npm.cubos.io/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" dependencies: wrappy "1" -once@~1.3.3: - version "1.3.3" - resolved "https://npm.cubos.io/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20" - dependencies: - wrappy "1" - os-homedir@^1.0.0: version "1.0.2" resolved "https://npm.cubos.io/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" -os-tmpdir@^1.0.1: +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: version "1.0.2" resolved "https://npm.cubos.io/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" +osenv@^0.1.4: + version "0.1.4" + resolved "https://npm.cubos.io/osenv/-/osenv-0.1.4.tgz#42fe6d5953df06c8064be6f176c3d05aaaa34644" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.0" + output-file-sync@^1.1.0: version "1.1.2" resolved "https://npm.cubos.io/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" @@ -1307,43 +1303,31 @@ qs@~6.4.0: resolved "https://npm.cubos.io/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" randomatic@^1.1.3: - version "1.1.6" - resolved "https://npm.cubos.io/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb" + version "1.1.7" + resolved "https://npm.cubos.io/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" dependencies: - is-number "^2.0.2" - kind-of "^3.0.2" + is-number "^3.0.0" + kind-of "^4.0.0" -rc@~1.1.6: - version "1.1.7" - resolved "https://npm.cubos.io/rc/-/rc-1.1.7.tgz#c5ea564bb07aff9fd3a5b32e906c1d3a65940fea" +rc@^1.1.7: + version "1.2.1" + resolved "https://npm.cubos.io/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95" dependencies: deep-extend "~0.4.0" ini "~1.3.0" minimist "^1.2.0" strip-json-comments "~2.0.1" -"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.2: - version "2.2.5" - resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.5.tgz#a0b187304e05bab01a4ce2b4cc9c607d5aa1d606" +readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.4: + version "2.2.11" + resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.11.tgz#0796b31f8d7688007ff0b93a8088d34aa17c0f72" dependencies: - buffer-shims "^1.0.0" core-util-is "~1.0.0" inherits "~2.0.1" isarray "~1.0.0" process-nextick-args "~1.0.6" - string_decoder "~0.10.x" - util-deprecate "~1.0.1" - -readable-stream@~2.1.4: - version "2.1.5" - resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.1.5.tgz#66fa8b720e1438b364681f2ad1a63c618448c9d0" - dependencies: - buffer-shims "^1.0.0" - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "~1.0.0" - process-nextick-args "~1.0.6" - string_decoder "~0.10.x" + safe-buffer "~5.0.1" + string_decoder "~1.0.0" util-deprecate "~1.0.1" readdirp@^2.0.0: @@ -1360,12 +1344,12 @@ regenerate@^1.2.1: resolved "https://npm.cubos.io/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" regenerator-runtime@^0.10.0: - version "0.10.3" - resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.10.3.tgz#8c4367a904b51ea62a908ac310bf99ff90a82a3e" + version "0.10.5" + resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" -regenerator-transform@0.9.8: - version "0.9.8" - resolved "https://npm.cubos.io/regenerator-transform/-/regenerator-transform-0.9.8.tgz#0f88bb2bc03932ddb7b6b7312e68078f01026d6c" +regenerator-transform@0.9.11: + version "0.9.11" + resolved "https://npm.cubos.io/regenerator-transform/-/regenerator-transform-0.9.11.tgz#3a7d067520cb7b7176769eb5ff868691befe1283" dependencies: babel-runtime "^6.18.0" babel-types "^6.19.0" @@ -1396,6 +1380,10 @@ regjsparser@^0.1.4: dependencies: jsesc "~0.5.0" +remove-trailing-separator@^1.0.1: + version "1.0.2" + resolved "https://npm.cubos.io/remove-trailing-separator/-/remove-trailing-separator-1.0.2.tgz#69b062d978727ad14dc6b56ba4ab772fd8d70511" + repeat-element@^1.1.2: version "1.1.2" resolved "https://npm.cubos.io/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" @@ -1410,7 +1398,7 @@ repeating@^2.0.0: dependencies: is-finite "^1.0.0" -request@^2.79.0: +request@^2.81.0: version "2.81.0" resolved "https://npm.cubos.io/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" dependencies: @@ -1437,23 +1425,23 @@ request@^2.79.0: tunnel-agent "^0.6.0" uuid "^3.0.0" -rethinkdbdash@^2.3.28: - version "2.3.28" - resolved "https://npm.cubos.io/rethinkdbdash/-/rethinkdbdash-2.3.28.tgz#f15fed3a2f0c178155fcadb6fc212b3df80f73df" +rethinkdbdash@^2.3.29: + version "2.3.29" + resolved "https://npm.cubos.io/rethinkdbdash/-/rethinkdbdash-2.3.29.tgz#252e454c89a86783301eb4171959386bdb268c0c" dependencies: bluebird ">= 3.0.1" -rimraf@2, rimraf@~2.5.1, rimraf@~2.5.4: - version "2.5.4" - resolved "https://npm.cubos.io/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" +rimraf@2, rimraf@^2.5.1, rimraf@^2.6.1: + version "2.6.1" + resolved "https://npm.cubos.io/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" dependencies: glob "^7.0.5" -safe-buffer@^5.0.1: +safe-buffer@^5.0.1, safe-buffer@~5.0.1: version "5.0.1" resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" -semver@~5.3.0: +semver@^5.3.0: version "5.3.0" resolved "https://npm.cubos.io/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" @@ -1480,8 +1468,8 @@ sntp@1.x.x: hoek "2.x.x" source-map-support@^0.4.2: - version "0.4.12" - resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.12.tgz#f47d02bf01efaf0c160d3a37d038401b92b1867e" + version "0.4.15" + resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.15.tgz#03202df65c06d2bd8c7ec2362a193056fef8d3b1" dependencies: source-map "^0.5.6" @@ -1490,8 +1478,8 @@ source-map@^0.5.0, source-map@^0.5.6: resolved "https://npm.cubos.io/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" sshpk@^1.7.0: - version "1.11.0" - resolved "https://npm.cubos.io/sshpk/-/sshpk-1.11.0.tgz#2d8d5ebb4a6fab28ffba37fa62a90f4a3ea59d77" + version "1.13.1" + resolved "https://npm.cubos.io/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" dependencies: asn1 "~0.2.3" assert-plus "^1.0.0" @@ -1500,11 +1488,10 @@ sshpk@^1.7.0: optionalDependencies: bcrypt-pbkdf "^1.0.0" ecc-jsbn "~0.1.1" - jodid25519 "^1.0.0" jsbn "~0.1.0" tweetnacl "~0.14.0" -string-width@^1.0.1: +string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" resolved "https://npm.cubos.io/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" dependencies: @@ -1512,9 +1499,11 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string_decoder@~0.10.x: - version "0.10.31" - resolved "https://npm.cubos.io/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" +string_decoder@~1.0.0: + version "1.0.2" + resolved "https://npm.cubos.io/string_decoder/-/string_decoder-1.0.2.tgz#b29e1f4e1125fa97a10382b8a533737b7491e179" + dependencies: + safe-buffer "~5.0.1" stringstream@~0.0.4: version "0.0.5" @@ -1534,20 +1523,20 @@ supports-color@^2.0.0: version "2.0.0" resolved "https://npm.cubos.io/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" -tar-pack@~3.3.0: - version "3.3.0" - resolved "https://npm.cubos.io/tar-pack/-/tar-pack-3.3.0.tgz#30931816418f55afc4d21775afdd6720cee45dae" +tar-pack@^3.4.0: + version "3.4.0" + resolved "https://npm.cubos.io/tar-pack/-/tar-pack-3.4.0.tgz#23be2d7f671a8339376cbdb0b8fe3fdebf317984" dependencies: - debug "~2.2.0" - fstream "~1.0.10" - fstream-ignore "~1.0.5" - once "~1.3.3" - readable-stream "~2.1.4" - rimraf "~2.5.1" - tar "~2.2.1" - uid-number "~0.0.6" - -tar@~2.2.1: + debug "^2.2.0" + fstream "^1.0.10" + fstream-ignore "^1.0.5" + once "^1.3.3" + readable-stream "^2.1.4" + rimraf "^2.5.1" + tar "^2.2.1" + uid-number "^0.0.6" + +tar@^2.2.1: version "2.2.1" resolved "https://npm.cubos.io/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" dependencies: @@ -1556,8 +1545,8 @@ tar@~2.2.1: inherits "2" to-fast-properties@^1.0.1: - version "1.0.2" - resolved "https://npm.cubos.io/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" + version "1.0.3" + resolved "https://npm.cubos.io/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" tough-cookie@~2.3.0: version "2.3.2" @@ -1579,11 +1568,11 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://npm.cubos.io/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" -typescript@^2.2.1: - version "2.2.1" - resolved "https://npm.cubos.io/typescript/-/typescript-2.2.1.tgz#4862b662b988a4c8ff691cc7969622d24db76ae9" +typescript@^2.3.4: + version "2.4.0" + resolved "https://npm.cubos.io/typescript/-/typescript-2.4.0.tgz#aef5a8d404beba36ad339abf079ddddfffba86dd" -uid-number@~0.0.6: +uid-number@^0.0.6: version "0.0.6" resolved "https://npm.cubos.io/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" @@ -1596,12 +1585,12 @@ util-deprecate@~1.0.1: resolved "https://npm.cubos.io/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" uuid@^3.0.0: - version "3.0.1" - resolved "https://npm.cubos.io/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" + version "3.1.0" + resolved "https://npm.cubos.io/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" v8flags@^2.0.10: - version "2.0.11" - resolved "https://npm.cubos.io/v8flags/-/v8flags-2.0.11.tgz#bca8f30f0d6d60612cc2c00641e6962d42ae6881" + version "2.1.1" + resolved "https://npm.cubos.io/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" dependencies: user-home "^1.1.1" @@ -1612,10 +1601,10 @@ verror@1.3.6: extsprintf "1.0.2" wide-align@^1.1.0: - version "1.1.0" - resolved "https://npm.cubos.io/wide-align/-/wide-align-1.1.0.tgz#40edde802a71fea1f070da3e62dcda2e7add96ad" + version "1.1.2" + resolved "https://npm.cubos.io/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710" dependencies: - string-width "^1.0.1" + string-width "^1.0.2" wrappy@1: version "1.0.2" diff --git a/target-node/package.json b/target-node/package.json index c70d5de..df64ae1 100644 --- a/target-node/package.json +++ b/target-node/package.json @@ -2,7 +2,7 @@ "name": "@cubos/api", "version": "0.0", "dependencies": { - "@types/node": "^7.0.8", + "@types/node": "^7.0.31", "babel-runtime": "^6.23.0", "moment": "^2.17.1", "request": "^2.81.0" @@ -27,6 +27,6 @@ "babel-preset-es2016": "^6.22.0", "babel-preset-es2017": "^6.22.0", "json": "^9.0.4", - "typescript": "^2.2.1" + "typescript": "^2.3.4" } } diff --git a/target-node/yarn.lock b/target-node/yarn.lock index 190dd8c..452b9f2 100644 --- a/target-node/yarn.lock +++ b/target-node/yarn.lock @@ -2,17 +2,17 @@ # yarn lockfile v1 -"@types/node@^7.0.8": - version "7.0.13" - resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.13.tgz#1b0a53fe9ef9c3a5d061b126cc9b915bca43a3f5" +"@types/node@^7.0.31": + version "7.0.31" + resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.31.tgz#80ea4d175599b2a00149c29a10a4eb2dff592e86" abbrev@1: version "1.1.0" resolved "https://npm.cubos.io/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" ajv@^4.9.1: - version "4.11.7" - resolved "https://npm.cubos.io/ajv/-/ajv-4.11.7.tgz#8655a5d86d0824985cc471a1d913fb6729a0ec48" + version "4.11.8" + resolved "https://npm.cubos.io/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" @@ -33,8 +33,8 @@ anymatch@^1.3.0: micromatch "^2.1.5" aproba@^1.0.3: - version "1.1.1" - resolved "https://npm.cubos.io/aproba/-/aproba-1.1.1.tgz#95d3600f07710aa0e9298c726ad5ecf2eacbabab" + version "1.1.2" + resolved "https://npm.cubos.io/aproba/-/aproba-1.1.2.tgz#45c6629094de4e96f693ef7eab74ae079c240fc1" are-we-there-yet@~1.1.2: version "1.1.4" @@ -119,19 +119,19 @@ babel-code-frame@^6.22.0: js-tokens "^3.0.0" babel-core@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-core/-/babel-core-6.24.1.tgz#8c428564dce1e1f41fb337ec34f4c3b022b5ad83" + version "6.25.0" + resolved "https://npm.cubos.io/babel-core/-/babel-core-6.25.0.tgz#7dd42b0463c742e9d5296deb3ec67a9322dad729" dependencies: babel-code-frame "^6.22.0" - babel-generator "^6.24.1" + babel-generator "^6.25.0" babel-helpers "^6.24.1" babel-messages "^6.23.0" babel-register "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - babylon "^6.11.0" + babel-template "^6.25.0" + babel-traverse "^6.25.0" + babel-types "^6.25.0" + babylon "^6.17.2" convert-source-map "^1.1.0" debug "^2.1.1" json5 "^0.5.0" @@ -142,13 +142,13 @@ babel-core@^6.24.1: slash "^1.0.0" source-map "^0.5.0" -babel-generator@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.24.1.tgz#e715f486c58ded25649d888944d52aa07c5d9497" +babel-generator@^6.25.0: + version "6.25.0" + resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.25.0.tgz#33a1af70d5f2890aeb465a4a7793c1df6a9ea9fc" dependencies: babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-types "^6.24.1" + babel-types "^6.25.0" detect-indent "^4.0.0" jsesc "^1.3.0" lodash "^4.2.0" @@ -552,46 +552,46 @@ babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0: core-js "^2.4.0" regenerator-runtime "^0.10.0" -babel-template@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-template/-/babel-template-6.24.1.tgz#04ae514f1f93b3a2537f2a0f60a5a45fb8308333" +babel-template@^6.24.1, babel-template@^6.25.0: + version "6.25.0" + resolved "https://npm.cubos.io/babel-template/-/babel-template-6.25.0.tgz#665241166b7c2aa4c619d71e192969552b10c071" dependencies: babel-runtime "^6.22.0" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - babylon "^6.11.0" + babel-traverse "^6.25.0" + babel-types "^6.25.0" + babylon "^6.17.2" lodash "^4.2.0" -babel-traverse@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.24.1.tgz#ab36673fd356f9a0948659e7b338d5feadb31695" +babel-traverse@^6.24.1, babel-traverse@^6.25.0: + version "6.25.0" + resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.25.0.tgz#2257497e2fcd19b89edc13c4c91381f9512496f1" dependencies: babel-code-frame "^6.22.0" babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-types "^6.24.1" - babylon "^6.15.0" + babel-types "^6.25.0" + babylon "^6.17.2" debug "^2.2.0" globals "^9.0.0" invariant "^2.2.0" lodash "^4.2.0" -babel-types@^6.19.0, babel-types@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-types/-/babel-types-6.24.1.tgz#a136879dc15b3606bda0d90c1fc74304c2ff0975" +babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.25.0: + version "6.25.0" + resolved "https://npm.cubos.io/babel-types/-/babel-types-6.25.0.tgz#70afb248d5660e5d18f811d91c8303b54134a18e" dependencies: babel-runtime "^6.22.0" esutils "^2.0.2" lodash "^4.2.0" to-fast-properties "^1.0.1" -babylon@^6.11.0, babylon@^6.15.0: - version "6.17.0" - resolved "https://npm.cubos.io/babylon/-/babylon-6.17.0.tgz#37da948878488b9c4e3c4038893fa3314b3fc932" +babylon@^6.17.2: + version "6.17.3" + resolved "https://npm.cubos.io/babylon/-/babylon-6.17.3.tgz#1327d709950b558f204e5352587fd0290f8d8e48" -balanced-match@^0.4.1: - version "0.4.2" - resolved "https://npm.cubos.io/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" bcrypt-pbkdf@^1.0.0: version "1.0.1" @@ -615,11 +615,11 @@ boom@2.x.x: dependencies: hoek "2.x.x" -brace-expansion@^1.0.0: - version "1.1.7" - resolved "https://npm.cubos.io/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59" +brace-expansion@^1.1.7: + version "1.1.8" + resolved "https://npm.cubos.io/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" dependencies: - balanced-match "^0.4.1" + balanced-match "^1.0.0" concat-map "0.0.1" braces@^1.8.2: @@ -630,10 +630,6 @@ braces@^1.8.2: preserve "^0.2.0" repeat-element "^1.1.2" -buffer-shims@~1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" - caseless@~0.12.0: version "0.12.0" resolved "https://npm.cubos.io/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" @@ -649,8 +645,8 @@ chalk@^1.1.0: supports-color "^2.0.0" chokidar@^1.6.1: - version "1.6.1" - resolved "https://npm.cubos.io/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2" + version "1.7.0" + resolved "https://npm.cubos.io/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" dependencies: anymatch "^1.3.0" async-each "^1.0.0" @@ -716,14 +712,14 @@ dashdash@^1.12.0: assert-plus "^1.0.0" debug@^2.1.1, debug@^2.2.0: - version "2.6.4" - resolved "https://npm.cubos.io/debug/-/debug-2.6.4.tgz#7586a9b3c39741c0282ae33445c4e8ac74734fe0" + version "2.6.8" + resolved "https://npm.cubos.io/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" dependencies: - ms "0.7.3" + ms "2.0.0" deep-extend@~0.4.0: - version "0.4.1" - resolved "https://npm.cubos.io/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253" + version "0.4.2" + resolved "https://npm.cubos.io/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" delayed-stream@~1.0.0: version "1.0.0" @@ -766,8 +762,8 @@ expand-range@^1.8.1: fill-range "^2.1.0" extend@~3.0.0: - version "3.0.0" - resolved "https://npm.cubos.io/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4" + version "3.0.1" + resolved "https://npm.cubos.io/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" extglob@^0.3.1: version "0.3.2" @@ -780,8 +776,8 @@ extsprintf@1.0.2: resolved "https://npm.cubos.io/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" filename-regex@^2.0.0: - version "2.0.0" - resolved "https://npm.cubos.io/filename-regex/-/filename-regex-2.0.0.tgz#996e3e80479b98b9897f15a8a58b3d084e926775" + version "2.0.1" + resolved "https://npm.cubos.io/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" fill-range@^2.1.0: version "2.2.3" @@ -824,11 +820,11 @@ fs.realpath@^1.0.0: resolved "https://npm.cubos.io/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" fsevents@^1.0.0: - version "1.1.1" - resolved "https://npm.cubos.io/fsevents/-/fsevents-1.1.1.tgz#f19fd28f43eeaf761680e519a203c4d0b3d31aff" + version "1.1.2" + resolved "https://npm.cubos.io/fsevents/-/fsevents-1.1.2.tgz#3282b713fb3ad80ede0e9fcf4611b5aa6fc033f4" dependencies: nan "^2.3.0" - node-pre-gyp "^0.6.29" + node-pre-gyp "^0.6.36" fstream-ignore@^1.0.5: version "1.0.5" @@ -847,7 +843,7 @@ fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: mkdirp ">=0.5 0" rimraf "2" -gauge@~2.7.1: +gauge@~2.7.3: version "2.7.4" resolved "https://npm.cubos.io/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" dependencies: @@ -861,8 +857,8 @@ gauge@~2.7.1: wide-align "^1.1.0" getpass@^0.1.1: - version "0.1.6" - resolved "https://npm.cubos.io/getpass/-/getpass-0.1.6.tgz#283ffd9fc1256840875311c1b60e8c40187110e6" + version "0.1.7" + resolved "https://npm.cubos.io/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" dependencies: assert-plus "^1.0.0" @@ -880,19 +876,19 @@ glob-parent@^2.0.0: is-glob "^2.0.0" glob@^7.0.0, glob@^7.0.5: - version "7.1.1" - resolved "https://npm.cubos.io/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" + version "7.1.2" + resolved "https://npm.cubos.io/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "^3.0.2" + minimatch "^3.0.4" once "^1.3.0" path-is-absolute "^1.0.0" globals@^9.0.0: - version "9.17.0" - resolved "https://npm.cubos.io/globals/-/globals-9.17.0.tgz#0c0ca696d9b9bb694d2e5470bd37777caad50286" + version "9.18.0" + resolved "https://npm.cubos.io/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" graceful-fs@^4.1.2, graceful-fs@^4.1.4: version "4.1.11" @@ -978,13 +974,13 @@ is-binary-path@^1.0.0: dependencies: binary-extensions "^1.0.0" -is-buffer@^1.0.2: +is-buffer@^1.1.5: version "1.1.5" resolved "https://npm.cubos.io/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" is-dotfile@^1.0.0: - version "1.0.2" - resolved "https://npm.cubos.io/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d" + version "1.0.3" + resolved "https://npm.cubos.io/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" is-equal-shallow@^0.1.3: version "0.1.3" @@ -1018,12 +1014,18 @@ is-glob@^2.0.0, is-glob@^2.0.1: dependencies: is-extglob "^1.0.0" -is-number@^2.0.2, is-number@^2.1.0: +is-number@^2.1.0: version "2.1.0" resolved "https://npm.cubos.io/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" dependencies: kind-of "^3.0.2" +is-number@^3.0.0: + version "3.0.0" + resolved "https://npm.cubos.io/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + dependencies: + kind-of "^3.0.2" + is-posix-bracket@^0.1.0: version "0.1.1" resolved "https://npm.cubos.io/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" @@ -1050,12 +1052,6 @@ isstream@~0.1.2: version "0.1.2" resolved "https://npm.cubos.io/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" -jodid25519@^1.0.0: - version "1.0.2" - resolved "https://npm.cubos.io/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967" - dependencies: - jsbn "~0.1.0" - js-tokens@^3.0.0: version "3.0.1" resolved "https://npm.cubos.io/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" @@ -1108,10 +1104,16 @@ jsprim@^1.2.2: verror "1.3.6" kind-of@^3.0.2: - version "3.1.0" - resolved "https://npm.cubos.io/kind-of/-/kind-of-3.1.0.tgz#475d698a5e49ff5e53d14e3e732429dc8bf4cf47" + version "3.2.2" + resolved "https://npm.cubos.io/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" dependencies: - is-buffer "^1.0.2" + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://npm.cubos.io/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + dependencies: + is-buffer "^1.1.5" lodash@^4.2.0: version "4.17.4" @@ -1151,11 +1153,11 @@ mime-types@^2.1.12, mime-types@~2.1.7: dependencies: mime-db "~1.27.0" -minimatch@^3.0.0, minimatch@^3.0.2: - version "3.0.3" - resolved "https://npm.cubos.io/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" +minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: + version "3.0.4" + resolved "https://npm.cubos.io/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: - brace-expansion "^1.0.0" + brace-expansion "^1.1.7" minimist@0.0.8: version "0.0.8" @@ -1175,17 +1177,17 @@ moment@^2.17.1: version "2.18.1" resolved "https://npm.cubos.io/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" -ms@0.7.3: - version "0.7.3" - resolved "https://npm.cubos.io/ms/-/ms-0.7.3.tgz#708155a5e44e33f5fd0fc53e81d0d40a91be1fff" +ms@2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" nan@^2.3.0: version "2.6.2" resolved "https://npm.cubos.io/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" -node-pre-gyp@^0.6.29: - version "0.6.34" - resolved "https://npm.cubos.io/node-pre-gyp/-/node-pre-gyp-0.6.34.tgz#94ad1c798a11d7fc67381b50d47f8cc18d9799f7" +node-pre-gyp@^0.6.36: + version "0.6.36" + resolved "https://npm.cubos.io/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz#db604112cb74e0d477554e9b505b17abddfab786" dependencies: mkdirp "^0.5.1" nopt "^4.0.1" @@ -1211,12 +1213,12 @@ normalize-path@^2.0.1: remove-trailing-separator "^1.0.1" npmlog@^4.0.2: - version "4.0.2" - resolved "https://npm.cubos.io/npmlog/-/npmlog-4.0.2.tgz#d03950e0e78ce1527ba26d2a7592e9348ac3e75f" + version "4.1.0" + resolved "https://npm.cubos.io/npmlog/-/npmlog-4.1.0.tgz#dc59bee85f64f00ed424efb2af0783df25d1c0b5" dependencies: are-we-there-yet "~1.1.2" console-control-strings "~1.1.0" - gauge "~2.7.1" + gauge "~2.7.3" set-blocking "~2.0.0" number-is-nan@^1.0.0: @@ -1305,11 +1307,11 @@ qs@~6.4.0: resolved "https://npm.cubos.io/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" randomatic@^1.1.3: - version "1.1.6" - resolved "https://npm.cubos.io/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb" + version "1.1.7" + resolved "https://npm.cubos.io/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" dependencies: - is-number "^2.0.2" - kind-of "^3.0.2" + is-number "^3.0.0" + kind-of "^4.0.0" rc@^1.1.7: version "1.2.1" @@ -1321,14 +1323,14 @@ rc@^1.1.7: strip-json-comments "~2.0.1" readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.4: - version "2.2.9" - resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.9.tgz#cf78ec6f4a6d1eb43d26488cac97f042e74b7fc8" + version "2.2.11" + resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.11.tgz#0796b31f8d7688007ff0b93a8088d34aa17c0f72" dependencies: - buffer-shims "~1.0.0" core-util-is "~1.0.0" inherits "~2.0.1" isarray "~1.0.0" process-nextick-args "~1.0.6" + safe-buffer "~5.0.1" string_decoder "~1.0.0" util-deprecate "~1.0.1" @@ -1346,8 +1348,8 @@ regenerate@^1.2.1: resolved "https://npm.cubos.io/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" regenerator-runtime@^0.10.0: - version "0.10.3" - resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.10.3.tgz#8c4367a904b51ea62a908ac310bf99ff90a82a3e" + version "0.10.5" + resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" regenerator-transform@0.9.11: version "0.9.11" @@ -1383,8 +1385,8 @@ regjsparser@^0.1.4: jsesc "~0.5.0" remove-trailing-separator@^1.0.1: - version "1.0.1" - resolved "https://npm.cubos.io/remove-trailing-separator/-/remove-trailing-separator-1.0.1.tgz#615ebb96af559552d4bf4057c8436d486ab63cc4" + version "1.0.2" + resolved "https://npm.cubos.io/remove-trailing-separator/-/remove-trailing-separator-1.0.2.tgz#69b062d978727ad14dc6b56ba4ab772fd8d70511" repeat-element@^1.1.2: version "1.1.2" @@ -1434,6 +1436,10 @@ rimraf@2, rimraf@^2.5.1, rimraf@^2.6.1: glob "^7.0.5" safe-buffer@^5.0.1: + version "5.1.0" + resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.1.0.tgz#fe4c8460397f9eaaaa58e73be46273408a45e223" + +safe-buffer@~5.0.1: version "5.0.1" resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" @@ -1464,8 +1470,8 @@ sntp@1.x.x: hoek "2.x.x" source-map-support@^0.4.2: - version "0.4.14" - resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.14.tgz#9d4463772598b86271b4f523f6c1f4e02a7d6aef" + version "0.4.15" + resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.15.tgz#03202df65c06d2bd8c7ec2362a193056fef8d3b1" dependencies: source-map "^0.5.6" @@ -1474,8 +1480,8 @@ source-map@^0.5.0, source-map@^0.5.6: resolved "https://npm.cubos.io/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" sshpk@^1.7.0: - version "1.13.0" - resolved "https://npm.cubos.io/sshpk/-/sshpk-1.13.0.tgz#ff2a3e4fd04497555fed97b39a0fd82fafb3a33c" + version "1.13.1" + resolved "https://npm.cubos.io/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" dependencies: asn1 "~0.2.3" assert-plus "^1.0.0" @@ -1484,11 +1490,10 @@ sshpk@^1.7.0: optionalDependencies: bcrypt-pbkdf "^1.0.0" ecc-jsbn "~0.1.1" - jodid25519 "^1.0.0" jsbn "~0.1.0" tweetnacl "~0.14.0" -string-width@^1.0.1: +string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" resolved "https://npm.cubos.io/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" dependencies: @@ -1497,10 +1502,10 @@ string-width@^1.0.1: strip-ansi "^3.0.0" string_decoder@~1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/string_decoder/-/string_decoder-1.0.0.tgz#f06f41157b664d86069f84bdbdc9b0d8ab281667" + version "1.0.2" + resolved "https://npm.cubos.io/string_decoder/-/string_decoder-1.0.2.tgz#b29e1f4e1125fa97a10382b8a533737b7491e179" dependencies: - buffer-shims "~1.0.0" + safe-buffer "~5.0.1" stringstream@~0.0.4: version "0.0.5" @@ -1542,8 +1547,8 @@ tar@^2.2.1: inherits "2" to-fast-properties@^1.0.1: - version "1.0.2" - resolved "https://npm.cubos.io/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" + version "1.0.3" + resolved "https://npm.cubos.io/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" tough-cookie@~2.3.0: version "2.3.2" @@ -1565,9 +1570,9 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://npm.cubos.io/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" -typescript@^2.2.1: - version "2.3.0" - resolved "https://npm.cubos.io/typescript/-/typescript-2.3.0.tgz#2e63e09284392bc8158a2444c33e2093795c0418" +typescript@^2.3.4: + version "2.4.0" + resolved "https://npm.cubos.io/typescript/-/typescript-2.4.0.tgz#aef5a8d404beba36ad339abf079ddddfffba86dd" uid-number@^0.0.6: version "0.0.6" @@ -1582,8 +1587,8 @@ util-deprecate@~1.0.1: resolved "https://npm.cubos.io/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" uuid@^3.0.0: - version "3.0.1" - resolved "https://npm.cubos.io/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" + version "3.1.0" + resolved "https://npm.cubos.io/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" v8flags@^2.0.10: version "2.1.1" @@ -1598,10 +1603,10 @@ verror@1.3.6: extsprintf "1.0.2" wide-align@^1.1.0: - version "1.1.0" - resolved "https://npm.cubos.io/wide-align/-/wide-align-1.1.0.tgz#40edde802a71fea1f070da3e62dcda2e7add96ad" + version "1.1.2" + resolved "https://npm.cubos.io/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710" dependencies: - string-width "^1.0.1" + string-width "^1.0.2" wrappy@1: version "1.0.2" diff --git a/target-web/package.json b/target-web/package.json index 6824d22..814059c 100644 --- a/target-web/package.json +++ b/target-web/package.json @@ -2,7 +2,7 @@ "name": "@cubos/api", "version": "0.0", "dependencies": { - "@types/node": "^7.0.8", + "@types/node": "^7.0.31", "@types/ua-parser-js": "^0.7.30", "babel-runtime": "^6.23.0", "moment": "^2.17.1", @@ -28,6 +28,6 @@ "babel-preset-es2016": "^6.22.0", "babel-preset-es2017": "^6.22.0", "json": "^9.0.4", - "typescript": "^2.2.1" + "typescript": "^2.3.4" } } diff --git a/target-web/yarn.lock b/target-web/yarn.lock index de31340..8217821 100644 --- a/target-web/yarn.lock +++ b/target-web/yarn.lock @@ -2,9 +2,9 @@ # yarn lockfile v1 -"@types/node@^7.0.8": - version "7.0.13" - resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.13.tgz#1b0a53fe9ef9c3a5d061b126cc9b915bca43a3f5" +"@types/node@^7.0.31": + version "7.0.31" + resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.31.tgz#80ea4d175599b2a00149c29a10a4eb2dff592e86" "@types/ua-parser-js@^0.7.30": version "0.7.30" @@ -15,8 +15,8 @@ abbrev@1: resolved "https://npm.cubos.io/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" ajv@^4.9.1: - version "4.11.7" - resolved "https://npm.cubos.io/ajv/-/ajv-4.11.7.tgz#8655a5d86d0824985cc471a1d913fb6729a0ec48" + version "4.11.8" + resolved "https://npm.cubos.io/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" @@ -37,8 +37,8 @@ anymatch@^1.3.0: micromatch "^2.1.5" aproba@^1.0.3: - version "1.1.1" - resolved "https://npm.cubos.io/aproba/-/aproba-1.1.1.tgz#95d3600f07710aa0e9298c726ad5ecf2eacbabab" + version "1.1.2" + resolved "https://npm.cubos.io/aproba/-/aproba-1.1.2.tgz#45c6629094de4e96f693ef7eab74ae079c240fc1" are-we-there-yet@~1.1.2: version "1.1.4" @@ -123,19 +123,19 @@ babel-code-frame@^6.22.0: js-tokens "^3.0.0" babel-core@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-core/-/babel-core-6.24.1.tgz#8c428564dce1e1f41fb337ec34f4c3b022b5ad83" + version "6.25.0" + resolved "https://npm.cubos.io/babel-core/-/babel-core-6.25.0.tgz#7dd42b0463c742e9d5296deb3ec67a9322dad729" dependencies: babel-code-frame "^6.22.0" - babel-generator "^6.24.1" + babel-generator "^6.25.0" babel-helpers "^6.24.1" babel-messages "^6.23.0" babel-register "^6.24.1" babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - babylon "^6.11.0" + babel-template "^6.25.0" + babel-traverse "^6.25.0" + babel-types "^6.25.0" + babylon "^6.17.2" convert-source-map "^1.1.0" debug "^2.1.1" json5 "^0.5.0" @@ -146,13 +146,13 @@ babel-core@^6.24.1: slash "^1.0.0" source-map "^0.5.0" -babel-generator@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.24.1.tgz#e715f486c58ded25649d888944d52aa07c5d9497" +babel-generator@^6.25.0: + version "6.25.0" + resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.25.0.tgz#33a1af70d5f2890aeb465a4a7793c1df6a9ea9fc" dependencies: babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-types "^6.24.1" + babel-types "^6.25.0" detect-indent "^4.0.0" jsesc "^1.3.0" lodash "^4.2.0" @@ -556,46 +556,46 @@ babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0: core-js "^2.4.0" regenerator-runtime "^0.10.0" -babel-template@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-template/-/babel-template-6.24.1.tgz#04ae514f1f93b3a2537f2a0f60a5a45fb8308333" +babel-template@^6.24.1, babel-template@^6.25.0: + version "6.25.0" + resolved "https://npm.cubos.io/babel-template/-/babel-template-6.25.0.tgz#665241166b7c2aa4c619d71e192969552b10c071" dependencies: babel-runtime "^6.22.0" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - babylon "^6.11.0" + babel-traverse "^6.25.0" + babel-types "^6.25.0" + babylon "^6.17.2" lodash "^4.2.0" -babel-traverse@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.24.1.tgz#ab36673fd356f9a0948659e7b338d5feadb31695" +babel-traverse@^6.24.1, babel-traverse@^6.25.0: + version "6.25.0" + resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.25.0.tgz#2257497e2fcd19b89edc13c4c91381f9512496f1" dependencies: babel-code-frame "^6.22.0" babel-messages "^6.23.0" babel-runtime "^6.22.0" - babel-types "^6.24.1" - babylon "^6.15.0" + babel-types "^6.25.0" + babylon "^6.17.2" debug "^2.2.0" globals "^9.0.0" invariant "^2.2.0" lodash "^4.2.0" -babel-types@^6.19.0, babel-types@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-types/-/babel-types-6.24.1.tgz#a136879dc15b3606bda0d90c1fc74304c2ff0975" +babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.25.0: + version "6.25.0" + resolved "https://npm.cubos.io/babel-types/-/babel-types-6.25.0.tgz#70afb248d5660e5d18f811d91c8303b54134a18e" dependencies: babel-runtime "^6.22.0" esutils "^2.0.2" lodash "^4.2.0" to-fast-properties "^1.0.1" -babylon@^6.11.0, babylon@^6.15.0: - version "6.17.0" - resolved "https://npm.cubos.io/babylon/-/babylon-6.17.0.tgz#37da948878488b9c4e3c4038893fa3314b3fc932" +babylon@^6.17.2: + version "6.17.3" + resolved "https://npm.cubos.io/babylon/-/babylon-6.17.3.tgz#1327d709950b558f204e5352587fd0290f8d8e48" -balanced-match@^0.4.1: - version "0.4.2" - resolved "https://npm.cubos.io/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" bcrypt-pbkdf@^1.0.0: version "1.0.1" @@ -619,11 +619,11 @@ boom@2.x.x: dependencies: hoek "2.x.x" -brace-expansion@^1.0.0: - version "1.1.7" - resolved "https://npm.cubos.io/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59" +brace-expansion@^1.1.7: + version "1.1.8" + resolved "https://npm.cubos.io/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" dependencies: - balanced-match "^0.4.1" + balanced-match "^1.0.0" concat-map "0.0.1" braces@^1.8.2: @@ -634,10 +634,6 @@ braces@^1.8.2: preserve "^0.2.0" repeat-element "^1.1.2" -buffer-shims@~1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" - caseless@~0.12.0: version "0.12.0" resolved "https://npm.cubos.io/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" @@ -653,8 +649,8 @@ chalk@^1.1.0: supports-color "^2.0.0" chokidar@^1.6.1: - version "1.6.1" - resolved "https://npm.cubos.io/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2" + version "1.7.0" + resolved "https://npm.cubos.io/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" dependencies: anymatch "^1.3.0" async-each "^1.0.0" @@ -720,14 +716,14 @@ dashdash@^1.12.0: assert-plus "^1.0.0" debug@^2.1.1, debug@^2.2.0: - version "2.6.4" - resolved "https://npm.cubos.io/debug/-/debug-2.6.4.tgz#7586a9b3c39741c0282ae33445c4e8ac74734fe0" + version "2.6.8" + resolved "https://npm.cubos.io/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" dependencies: - ms "0.7.3" + ms "2.0.0" deep-extend@~0.4.0: - version "0.4.1" - resolved "https://npm.cubos.io/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253" + version "0.4.2" + resolved "https://npm.cubos.io/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" delayed-stream@~1.0.0: version "1.0.0" @@ -770,8 +766,8 @@ expand-range@^1.8.1: fill-range "^2.1.0" extend@~3.0.0: - version "3.0.0" - resolved "https://npm.cubos.io/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4" + version "3.0.1" + resolved "https://npm.cubos.io/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" extglob@^0.3.1: version "0.3.2" @@ -784,8 +780,8 @@ extsprintf@1.0.2: resolved "https://npm.cubos.io/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" filename-regex@^2.0.0: - version "2.0.0" - resolved "https://npm.cubos.io/filename-regex/-/filename-regex-2.0.0.tgz#996e3e80479b98b9897f15a8a58b3d084e926775" + version "2.0.1" + resolved "https://npm.cubos.io/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" fill-range@^2.1.0: version "2.2.3" @@ -828,11 +824,11 @@ fs.realpath@^1.0.0: resolved "https://npm.cubos.io/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" fsevents@^1.0.0: - version "1.1.1" - resolved "https://npm.cubos.io/fsevents/-/fsevents-1.1.1.tgz#f19fd28f43eeaf761680e519a203c4d0b3d31aff" + version "1.1.2" + resolved "https://npm.cubos.io/fsevents/-/fsevents-1.1.2.tgz#3282b713fb3ad80ede0e9fcf4611b5aa6fc033f4" dependencies: nan "^2.3.0" - node-pre-gyp "^0.6.29" + node-pre-gyp "^0.6.36" fstream-ignore@^1.0.5: version "1.0.5" @@ -851,7 +847,7 @@ fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: mkdirp ">=0.5 0" rimraf "2" -gauge@~2.7.1: +gauge@~2.7.3: version "2.7.4" resolved "https://npm.cubos.io/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" dependencies: @@ -865,8 +861,8 @@ gauge@~2.7.1: wide-align "^1.1.0" getpass@^0.1.1: - version "0.1.6" - resolved "https://npm.cubos.io/getpass/-/getpass-0.1.6.tgz#283ffd9fc1256840875311c1b60e8c40187110e6" + version "0.1.7" + resolved "https://npm.cubos.io/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" dependencies: assert-plus "^1.0.0" @@ -884,19 +880,19 @@ glob-parent@^2.0.0: is-glob "^2.0.0" glob@^7.0.0, glob@^7.0.5: - version "7.1.1" - resolved "https://npm.cubos.io/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" + version "7.1.2" + resolved "https://npm.cubos.io/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "^3.0.2" + minimatch "^3.0.4" once "^1.3.0" path-is-absolute "^1.0.0" globals@^9.0.0: - version "9.17.0" - resolved "https://npm.cubos.io/globals/-/globals-9.17.0.tgz#0c0ca696d9b9bb694d2e5470bd37777caad50286" + version "9.18.0" + resolved "https://npm.cubos.io/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" graceful-fs@^4.1.2, graceful-fs@^4.1.4: version "4.1.11" @@ -982,13 +978,13 @@ is-binary-path@^1.0.0: dependencies: binary-extensions "^1.0.0" -is-buffer@^1.0.2: +is-buffer@^1.1.5: version "1.1.5" resolved "https://npm.cubos.io/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" is-dotfile@^1.0.0: - version "1.0.2" - resolved "https://npm.cubos.io/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d" + version "1.0.3" + resolved "https://npm.cubos.io/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" is-equal-shallow@^0.1.3: version "0.1.3" @@ -1022,12 +1018,18 @@ is-glob@^2.0.0, is-glob@^2.0.1: dependencies: is-extglob "^1.0.0" -is-number@^2.0.2, is-number@^2.1.0: +is-number@^2.1.0: version "2.1.0" resolved "https://npm.cubos.io/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" dependencies: kind-of "^3.0.2" +is-number@^3.0.0: + version "3.0.0" + resolved "https://npm.cubos.io/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + dependencies: + kind-of "^3.0.2" + is-posix-bracket@^0.1.0: version "0.1.1" resolved "https://npm.cubos.io/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" @@ -1054,12 +1056,6 @@ isstream@~0.1.2: version "0.1.2" resolved "https://npm.cubos.io/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" -jodid25519@^1.0.0: - version "1.0.2" - resolved "https://npm.cubos.io/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967" - dependencies: - jsbn "~0.1.0" - js-tokens@^3.0.0: version "3.0.1" resolved "https://npm.cubos.io/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" @@ -1112,10 +1108,16 @@ jsprim@^1.2.2: verror "1.3.6" kind-of@^3.0.2: - version "3.1.0" - resolved "https://npm.cubos.io/kind-of/-/kind-of-3.1.0.tgz#475d698a5e49ff5e53d14e3e732429dc8bf4cf47" + version "3.2.2" + resolved "https://npm.cubos.io/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" dependencies: - is-buffer "^1.0.2" + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://npm.cubos.io/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + dependencies: + is-buffer "^1.1.5" lodash@^4.2.0: version "4.17.4" @@ -1155,11 +1157,11 @@ mime-types@^2.1.12, mime-types@~2.1.7: dependencies: mime-db "~1.27.0" -minimatch@^3.0.0, minimatch@^3.0.2: - version "3.0.3" - resolved "https://npm.cubos.io/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" +minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: + version "3.0.4" + resolved "https://npm.cubos.io/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: - brace-expansion "^1.0.0" + brace-expansion "^1.1.7" minimist@0.0.8: version "0.0.8" @@ -1179,17 +1181,17 @@ moment@^2.17.1: version "2.18.1" resolved "https://npm.cubos.io/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" -ms@0.7.3: - version "0.7.3" - resolved "https://npm.cubos.io/ms/-/ms-0.7.3.tgz#708155a5e44e33f5fd0fc53e81d0d40a91be1fff" +ms@2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" nan@^2.3.0: version "2.6.2" resolved "https://npm.cubos.io/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" -node-pre-gyp@^0.6.29: - version "0.6.34" - resolved "https://npm.cubos.io/node-pre-gyp/-/node-pre-gyp-0.6.34.tgz#94ad1c798a11d7fc67381b50d47f8cc18d9799f7" +node-pre-gyp@^0.6.36: + version "0.6.36" + resolved "https://npm.cubos.io/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz#db604112cb74e0d477554e9b505b17abddfab786" dependencies: mkdirp "^0.5.1" nopt "^4.0.1" @@ -1215,12 +1217,12 @@ normalize-path@^2.0.1: remove-trailing-separator "^1.0.1" npmlog@^4.0.2: - version "4.0.2" - resolved "https://npm.cubos.io/npmlog/-/npmlog-4.0.2.tgz#d03950e0e78ce1527ba26d2a7592e9348ac3e75f" + version "4.1.0" + resolved "https://npm.cubos.io/npmlog/-/npmlog-4.1.0.tgz#dc59bee85f64f00ed424efb2af0783df25d1c0b5" dependencies: are-we-there-yet "~1.1.2" console-control-strings "~1.1.0" - gauge "~2.7.1" + gauge "~2.7.3" set-blocking "~2.0.0" number-is-nan@^1.0.0: @@ -1309,11 +1311,11 @@ qs@~6.4.0: resolved "https://npm.cubos.io/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" randomatic@^1.1.3: - version "1.1.6" - resolved "https://npm.cubos.io/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb" + version "1.1.7" + resolved "https://npm.cubos.io/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" dependencies: - is-number "^2.0.2" - kind-of "^3.0.2" + is-number "^3.0.0" + kind-of "^4.0.0" rc@^1.1.7: version "1.2.1" @@ -1325,14 +1327,14 @@ rc@^1.1.7: strip-json-comments "~2.0.1" readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.4: - version "2.2.9" - resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.9.tgz#cf78ec6f4a6d1eb43d26488cac97f042e74b7fc8" + version "2.2.11" + resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.11.tgz#0796b31f8d7688007ff0b93a8088d34aa17c0f72" dependencies: - buffer-shims "~1.0.0" core-util-is "~1.0.0" inherits "~2.0.1" isarray "~1.0.0" process-nextick-args "~1.0.6" + safe-buffer "~5.0.1" string_decoder "~1.0.0" util-deprecate "~1.0.1" @@ -1350,8 +1352,8 @@ regenerate@^1.2.1: resolved "https://npm.cubos.io/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" regenerator-runtime@^0.10.0: - version "0.10.3" - resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.10.3.tgz#8c4367a904b51ea62a908ac310bf99ff90a82a3e" + version "0.10.5" + resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" regenerator-transform@0.9.11: version "0.9.11" @@ -1387,8 +1389,8 @@ regjsparser@^0.1.4: jsesc "~0.5.0" remove-trailing-separator@^1.0.1: - version "1.0.1" - resolved "https://npm.cubos.io/remove-trailing-separator/-/remove-trailing-separator-1.0.1.tgz#615ebb96af559552d4bf4057c8436d486ab63cc4" + version "1.0.2" + resolved "https://npm.cubos.io/remove-trailing-separator/-/remove-trailing-separator-1.0.2.tgz#69b062d978727ad14dc6b56ba4ab772fd8d70511" repeat-element@^1.1.2: version "1.1.2" @@ -1437,7 +1439,7 @@ rimraf@2, rimraf@^2.5.1, rimraf@^2.6.1: dependencies: glob "^7.0.5" -safe-buffer@^5.0.1: +safe-buffer@^5.0.1, safe-buffer@~5.0.1: version "5.0.1" resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" @@ -1468,8 +1470,8 @@ sntp@1.x.x: hoek "2.x.x" source-map-support@^0.4.2: - version "0.4.14" - resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.14.tgz#9d4463772598b86271b4f523f6c1f4e02a7d6aef" + version "0.4.15" + resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.15.tgz#03202df65c06d2bd8c7ec2362a193056fef8d3b1" dependencies: source-map "^0.5.6" @@ -1478,8 +1480,8 @@ source-map@^0.5.0, source-map@^0.5.6: resolved "https://npm.cubos.io/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" sshpk@^1.7.0: - version "1.13.0" - resolved "https://npm.cubos.io/sshpk/-/sshpk-1.13.0.tgz#ff2a3e4fd04497555fed97b39a0fd82fafb3a33c" + version "1.13.1" + resolved "https://npm.cubos.io/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" dependencies: asn1 "~0.2.3" assert-plus "^1.0.0" @@ -1488,11 +1490,10 @@ sshpk@^1.7.0: optionalDependencies: bcrypt-pbkdf "^1.0.0" ecc-jsbn "~0.1.1" - jodid25519 "^1.0.0" jsbn "~0.1.0" tweetnacl "~0.14.0" -string-width@^1.0.1: +string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" resolved "https://npm.cubos.io/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" dependencies: @@ -1501,10 +1502,10 @@ string-width@^1.0.1: strip-ansi "^3.0.0" string_decoder@~1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/string_decoder/-/string_decoder-1.0.0.tgz#f06f41157b664d86069f84bdbdc9b0d8ab281667" + version "1.0.2" + resolved "https://npm.cubos.io/string_decoder/-/string_decoder-1.0.2.tgz#b29e1f4e1125fa97a10382b8a533737b7491e179" dependencies: - buffer-shims "~1.0.0" + safe-buffer "~5.0.1" stringstream@~0.0.4: version "0.0.5" @@ -1546,8 +1547,8 @@ tar@^2.2.1: inherits "2" to-fast-properties@^1.0.1: - version "1.0.2" - resolved "https://npm.cubos.io/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" + version "1.0.3" + resolved "https://npm.cubos.io/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" tough-cookie@~2.3.0: version "2.3.2" @@ -1569,9 +1570,9 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://npm.cubos.io/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" -typescript@^2.2.1: - version "2.3.0" - resolved "https://npm.cubos.io/typescript/-/typescript-2.3.0.tgz#2e63e09284392bc8158a2444c33e2093795c0418" +typescript@^2.3.4: + version "2.4.0" + resolved "https://npm.cubos.io/typescript/-/typescript-2.4.0.tgz#aef5a8d404beba36ad339abf079ddddfffba86dd" ua-parser-js@^0.7.12: version "0.7.12" @@ -1590,8 +1591,8 @@ util-deprecate@~1.0.1: resolved "https://npm.cubos.io/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" uuid@^3.0.0: - version "3.0.1" - resolved "https://npm.cubos.io/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" + version "3.1.0" + resolved "https://npm.cubos.io/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" v8flags@^2.0.10: version "2.1.1" @@ -1606,10 +1607,10 @@ verror@1.3.6: extsprintf "1.0.2" wide-align@^1.1.0: - version "1.1.0" - resolved "https://npm.cubos.io/wide-align/-/wide-align-1.1.0.tgz#40edde802a71fea1f070da3e62dcda2e7add96ad" + version "1.1.2" + resolved "https://npm.cubos.io/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710" dependencies: - string-width "^1.0.1" + string-width "^1.0.2" wrappy@1: version "1.0.2" From c02c5be33a8cd535b2a4e0f165009bbda34fce4e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 20 Jun 2017 16:17:53 -0300 Subject: [PATCH 237/625] Obtain IP from caddy --- target_typescript_nodeserver.cr | 2 ++ target_typescript_web.cr | 31 ------------------------------- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 643f4bf..fa143bd 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -114,6 +114,7 @@ export function start(port: number) { let body = ""; req.on("data", (chunk: any) => body += chunk.toString()); req.on("end", () => { + const ip = req.headers["x-real-ip"] || ""; const signature = req.method! + url.parse(req.url || "").pathname; if (httpHandlers[signature]) { console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${signature}`); @@ -153,6 +154,7 @@ export function start(port: number) { const startTime = process.hrtime(); const {id, ...deviceInfo} = context.device; + deviceInfo.ip = ip; if (!context.device.id || await r.table("devices").get(context.device.id).eq(null)) { context.device.id = crypto.randomBytes(20).toString("hex"); diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 24496a2..9211b89 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -48,13 +48,11 @@ END ////////////////////////////////////////////////////// async function device() { - const ip = localStorage.getItem("ip") || await getIP(); const parser = new UAParser(); parser.setUA(navigator.userAgent); const agent = parser.getResult(); const me = document.currentScript as HTMLScriptElement; const device: any = { - ip, type: "web", platform: { browser: agent.browser.name, @@ -82,35 +80,6 @@ function randomBytesHex(len: number) { return hex; } -let ipRequest: Promise; -function getIP() { - if (!ipRequest) { - ipRequest = new Promise((resolve, reject) => { - const req = new XMLHttpRequest(); - req.open("GET", "https://api.ipify.org/?format=json"); - req.onreadystatechange = () => { - if (req.readyState !== 4) return; - try { - const response = JSON.parse(req.responseText); - localStorage.setItem("ip", response.ip); - - if (response.ip) { - resolve(response.ip); - } else { - resolve("0.0.0.0"); - } - } catch (err) { - console.log(err); - resolve("0.0.0.0"); - } - }; - req.send(); - }); - } - - return ipRequest; -} - async function makeRequest({name, args}: {name: string, args: any}) { const deviceData = await device(); return new Promise((resolve, reject) => { From f93d1ef389a0a2a5e2df51c9a0bb8539f44a5ea8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 20 Jun 2017 16:25:03 -0300 Subject: [PATCH 238/625] ip is string --- target_typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index fa143bd..750e5bd 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -114,7 +114,7 @@ export function start(port: number) { let body = ""; req.on("data", (chunk: any) => body += chunk.toString()); req.on("end", () => { - const ip = req.headers["x-real-ip"] || ""; + const ip = req.headers["x-real-ip"] as string || ""; const signature = req.method! + url.parse(req.url || "").pathname; if (httpHandlers[signature]) { console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${signature}`); From 1ea019a2840ccedbb87985772ab64e5f06e2f9dc Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 21 Jun 2017 14:54:33 -0300 Subject: [PATCH 239/625] Add replace options --- rethinkdb/rethinkdb.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index cf61ecd..c84a00a 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -320,7 +320,7 @@ interface RTableRow extends RDatum { update(obj: (obj: RDatum) => any, options?: R_UpdateOptions): RDatum update(obj: RUpdateObj, options: Opts): RDatum update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum - replace(obj: RInsertObj): RDatum + replace(obj: RInsertObj, options?: R_UpdateOptions): RDatum delete(): RDatum<{}> eq(other: T | RDatum | null): RDatum ne(other: T | RDatum | null): RDatum From 5b67d0968d7ed77575cf6080fb7df4b2000b872e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 22 Jun 2017 09:37:10 -0300 Subject: [PATCH 240/625] Allow method put --- target_typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 750e5bd..5d6068f 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -106,7 +106,7 @@ export function start(port: number) { }); res.setHeader("Access-Control-Allow-Origin", "*"); - res.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS"); + res.setHeader("Access-Control-Allow-Methods", "PUT, POST, GET, OPTIONS"); res.setHeader("Access-Control-Allow-Headers", "Content-Type"); res.setHeader("Access-Control-Max-Age", "86400"); res.setHeader("Content-Type", "application/json"); From 704c696b9cb548f3bd471652190282412c25ba37 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 22 Jun 2017 11:09:04 -0300 Subject: [PATCH 241/625] Fix between bounds --- rethinkdb/rethinkdb.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index c84a00a..61e19d2 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -372,7 +372,7 @@ interface RTable extends RTableSlice { getAll(id1: any, id2: any, opts?: {index: string}): RTableSlice getAll(id1: any, id2: any, id3: any, opts?: {index: string}): RTableSlice getAll(id1: any, id2: any, id3: any, id4: any, opts?: {index: string}): RTableSlice - between(lower: any, upper: any, opts?: {index: string, leftBound?: "closed" | "opened", rightBound?: "closed" | "opened"}): RTableSlice + between(lower: any, upper: any, opts?: {index: string, leftBound?: "closed" | "open", rightBound?: "closed" | "open"}): RTableSlice getNearest(id: RPoint, opts: { index: string, maxResults?: number, unit?: "m" | "km" | "mi" | "nm" | "ft", maxDist?: number, geoSystem?: "WGS84" | "unit_sphere" }): RTableSlice; } From 17fd8329b977351cf206f6d2639836103a3467bd Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 25 Jun 2017 19:04:10 -0300 Subject: [PATCH 242/625] Add coerceTo(type: "number") --- rethinkdb/rethinkdb.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index 61e19d2..a53f1ef 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -172,6 +172,7 @@ interface RDatum extends RStreamOrDatum, PromiseLike { split(by: string): RArray coerceTo(type: "array"): RArray coerceTo(type: "string"): RDatum + coerceTo(type: "number"): RDatum setInsert(other: any): RArray setUnion(other: any): RArray From 3a0feac7f177cfe2d2fdc2b7fb19f24f176cdd2e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 25 Jun 2017 19:07:59 -0300 Subject: [PATCH 243/625] Fix RPoint fields --- rethinkdb/rethinkdb.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index a53f1ef..b8ab8d5 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -28,8 +28,7 @@ interface DBApiCall { interface R_Sorting { __dummy: string } interface RPoint { - coordinates: [number, number]; - type: "Point"; + __dummy: string } interface R extends RDB { From 2fb7b79ab1704ba5460c3fc5a8b0b9e2c85a991f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 28 Jun 2017 12:17:42 -0300 Subject: [PATCH 244/625] Fix assigning IP to request --- target_typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 5d6068f..28f8026 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -146,6 +146,7 @@ export function start(port: number) { case "POST": { (async () => { const request = JSON.parse(body); + request.device.ip = ip; const context: Context = { device: request.device, startTime: new Date, @@ -154,7 +155,6 @@ export function start(port: number) { const startTime = process.hrtime(); const {id, ...deviceInfo} = context.device; - deviceInfo.ip = ip; if (!context.device.id || await r.table("devices").get(context.device.id).eq(null)) { context.device.id = crypto.randomBytes(20).toString("hex"); From 5b67da26f11e7575190cfc9e41e9008b99fb99f1 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 1 Jul 2017 11:29:57 -0300 Subject: [PATCH 245/625] Add replace with function --- rethinkdb/rethinkdb.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts index b8ab8d5..d4ed40b 100644 --- a/rethinkdb/rethinkdb.d.ts +++ b/rethinkdb/rethinkdb.d.ts @@ -320,6 +320,7 @@ interface RTableRow extends RDatum { update(obj: (obj: RDatum) => any, options?: R_UpdateOptions): RDatum update(obj: RUpdateObj, options: Opts): RDatum update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum + replace(obj: (obj: RDatum) => any, options?: R_UpdateOptions): RDatum replace(obj: RInsertObj, options?: R_UpdateOptions): RDatum delete(): RDatum<{}> eq(other: T | RDatum | null): RDatum From ed6b8e2f9d7d8f078d59145ea9ebb8e27c7d29ff Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 2 Jul 2017 16:34:31 -0300 Subject: [PATCH 246/625] Move rethinkDB to its own repo --- rethinkdb/.gitignore | 4 - rethinkdb/.npmignore | 0 rethinkdb/.npmrc | 2 - rethinkdb/.yarnrc | 3 - rethinkdb/build_and_publish.sh | 9 - rethinkdb/index.ts | 114 --- rethinkdb/package.json | 29 - rethinkdb/rethinkdb.d.ts | 379 -------- rethinkdb/tsconfig.json | 19 - rethinkdb/yarn.lock | 1611 -------------------------------- 10 files changed, 2170 deletions(-) delete mode 100644 rethinkdb/.gitignore delete mode 100644 rethinkdb/.npmignore delete mode 100644 rethinkdb/.npmrc delete mode 100644 rethinkdb/.yarnrc delete mode 100644 rethinkdb/build_and_publish.sh delete mode 100644 rethinkdb/index.ts delete mode 100644 rethinkdb/package.json delete mode 100644 rethinkdb/rethinkdb.d.ts delete mode 100644 rethinkdb/tsconfig.json delete mode 100644 rethinkdb/yarn.lock diff --git a/rethinkdb/.gitignore b/rethinkdb/.gitignore deleted file mode 100644 index e83ca2b..0000000 --- a/rethinkdb/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules -index.js -index.js.map -index.d.ts \ No newline at end of file diff --git a/rethinkdb/.npmignore b/rethinkdb/.npmignore deleted file mode 100644 index e69de29..0000000 diff --git a/rethinkdb/.npmrc b/rethinkdb/.npmrc deleted file mode 100644 index 7173932..0000000 --- a/rethinkdb/.npmrc +++ /dev/null @@ -1,2 +0,0 @@ -registry=https://npm.cubos.io/ -//npm.cubos.io/:_authToken="P3LrfpI49SpXsspIMpzItQ==" diff --git a/rethinkdb/.yarnrc b/rethinkdb/.yarnrc deleted file mode 100644 index d51da20..0000000 --- a/rethinkdb/.yarnrc +++ /dev/null @@ -1,3 +0,0 @@ -registry "https://npm.cubos.io/" -email tech@cubos.io -username cubos diff --git a/rethinkdb/build_and_publish.sh b/rethinkdb/build_and_publish.sh deleted file mode 100644 index 3a439e3..0000000 --- a/rethinkdb/build_and_publish.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -VERSION=1.0.$1 - -export PATH=$(npm bin):$PATH -npm version $VERSION || true -tsc -babel index.js -o index.js -npm publish diff --git a/rethinkdb/index.ts b/rethinkdb/index.ts deleted file mode 100644 index 8532127..0000000 --- a/rethinkdb/index.ts +++ /dev/null @@ -1,114 +0,0 @@ - -let r: R; -let dbName: string; - -export function connect(db: string, host: string = "rethinkdb") { - dbName = db; - r = require("rethinkdbdash")({ - db: db, - pingInterval: 20, - servers: [{ - host: host, - port: 28015 - }] - }); - - return r; -} - -export interface ConfigureOptions { - tables: { - [name: string]: { - indices?: any[] - } - } -} - -export async function configure(options: ConfigureOptions) { - if (await r.not(r.dbList().contains(dbName))) { - await r.dbCreate(dbName); - } - - const tables = Object.keys(options.tables); - const realTables = await r.tableList(); - - for (let i = 0; i < realTables.length; ++i) { - if (tables.indexOf(realTables[i]) >= 0) continue; - console.log(`WARNING: Should dropping table ${realTables[i]}...`); - // await r.tableDrop(realTables[i]); - } - - for (let i = 0; i < tables.length; ++i) { - const table = tables[i]; - if (realTables.indexOf(table) < 0) { - console.log(`Creating table ${table}...`); - await r.tableCreate(table); - } - - const indicesCreationFunc = options.tables[table].indices || []; - const indices = indicesCreationFunc.map((creationFunc: any) => { - const match = /^r\.table\("([^"]+)"\)\.indexCreate\("([^"]+)"/.exec(creationFunc.toString()); - if (match === null) - throw "Invalid index expression: creationFunc.toString()"; - if (match[1] !== table) - throw `Invalid index expression: Should use table ${table}, but uses ${match[1]}: creationFunc.toString()`; - - return match[2]; - }); - - const realIndices = await r.table(table).indexList(); - - for (let i = 0; i < realIndices.length; ++i) { - if (indices.indexOf(realIndices[i]) >= 0) continue; - console.log(`Dropping index ${table}.${realIndices[i]}...`); - await r.table(table).indexDrop(realIndices[i]); - } - - for (let i = 0; i < indices.length; ++i) { - if (realIndices.indexOf(indices[i]) < 0) { - console.log(`Creating index ${table}.${indices[i]}...`); - await indicesCreationFunc[i]; - } else { - const status = await r.table(table).indexStatus(indices[i])(0); - - let realDescr = status.query; - let descr = indicesCreationFunc[i].toString(); - - { - const match = /(function[\s\S]*\})/.exec(realDescr); - if (!match) throw `Index function doesn't contain a function??? ${JSON.stringify(realDescr)}`; - realDescr = match[1]; - } - - { - const match = /(function[\s\S]*\})/.exec(descr); - if (!match) descr = `function (var_1) { return var_1("${indices[i]}") }`; - else descr = match[1]; - } - - realDescr = global["eval"](`(${realDescr})`).toString(); - descr = global["eval"](`(${descr})`).toString(); - - descr = descr.replace(/\n\s*/g, " "); - realDescr = realDescr.replace(/\.getField/g, ""); - realDescr = realDescr.replace(/;/g, ""); - const varMapping: {[orig: string]: string} = {}; - const varMatches = /(_?var\d+)/.exec(realDescr) || []; - for (let i = 0; i < varMatches.length; ++i) { - if (varMapping[varMatches[i]] === undefined) { - varMapping[varMatches[i]] = "var_" + (Object.keys(varMapping).length + 1); - } - realDescr = realDescr.replace(varMatches[i], varMapping[varMatches[i]]); - } - - if (realDescr !== descr) { - console.log(`Recreating index ${table}.${indices[i]}...`); - await r.table(table).indexDrop(indices[i]); - await indicesCreationFunc[i]; - } - } - } - } - - console.log("Database structure is ready"); -} diff --git a/rethinkdb/package.json b/rethinkdb/package.json deleted file mode 100644 index 36ba420..0000000 --- a/rethinkdb/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "@cubos/rethinkdb", - "version": "0.0", - "dependencies": { - "@types/node": "^7.0.31", - "babel-runtime": "^6.23.0", - "rethinkdbdash": "^2.3.29" - }, - "main": "index.js", - "types": "index.d.ts", - "babel": { - "plugins": [ - "transform-runtime" - ], - "presets": [ - "babel-preset-es2015", - "babel-preset-es2016", - "babel-preset-es2017" - ] - }, - "devDependencies": { - "babel-cli": "^6.24.1", - "babel-plugin-transform-runtime": "^6.23.0", - "babel-preset-es2015": "^6.24.1", - "babel-preset-es2016": "^6.24.1", - "babel-preset-es2017": "^6.24.1", - "typescript": "^2.3.4" - } -} diff --git a/rethinkdb/rethinkdb.d.ts b/rethinkdb/rethinkdb.d.ts deleted file mode 100644 index d4ed40b..0000000 --- a/rethinkdb/rethinkdb.d.ts +++ /dev/null @@ -1,379 +0,0 @@ - -interface DBDevice { - id: string; - ip: string; - type: "android" | "ios" | "web"; - platform: any; - screen: {width: number, height: number}; - version: string; - language: string; - push?: string -} - -interface DBApiCall { - id: string; - name: string; - args: any; - executionId: string; - running: boolean; - device: DBDevice; - date: Date; - duration: number; - host: string; - ok: boolean; - result: any; - error: {type: string, message: string} | null; -} - -interface R_Sorting { __dummy: string } - -interface RPoint { - __dummy: string -} - -interface R extends RDB { - db(name: string): RDB - dbList(): RArray - dbCreate(name: string): RDatum<{}> - expr(obj: any): RDatum - point(longitude: number | RDatum, latitude: number | RDatum): RPoint; - uuid(): RDatum - range(): RStream - range(count: number): RStream - range(initial: number, count: number): RStream - epochTime(epoch: number): RDatum - time(year: number | RDatum, month: number | RDatum, day: number | RDatum, tz: string | RDatum): RDatum - time(year: number | RDatum, month: number | RDatum, day: number | RDatum, hour: number | RDatum, minute: number | RDatum, second: number | RDatum, tz: string | RDatum): RDatum - add(...objs: any[]): RDatum - branch(c1: any, v1: any, otherwise: any): RDatum - branch(c1: any, v1: any, c2: any, v2: any, otherwise: any): RDatum - branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, otherwise: any): RDatum - branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, c4: any, v4: any, otherwise: any): RDatum - branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, c4: any, v4: any, k5: any, v5: any, otherwise: any): RDatum - branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, c4: any, v4: any, c5: any, v5: any, c6: any, v6: any, otherwise: any): RDatum - branch(c1: any, v1: any, c2: any, v2: any, c3: any, v3: any, c4: any, v4: any, c5: any, v5: any, c6: any, v6: any, c7: any, v7: any, otherwise: any): RDatum - not(obj: any): RDatum - object(k1: any, v1: any): RDatum - object(k1: any, v1: any, k2: any, v2: any): RDatum - object(k1: any, v1: any, k2: any, v2: any, k3: any, v3: any): RDatum - object(k1: any, v1: any, k2: any, v2: any, k3: any, v3: any, k4: any, v4: any): RDatum - object(k1: any, v1: any, k2: any, v2: any, k3: any, v3: any, k4: any, v4: any, k5: any, v5: any): RDatum - object(k1: any, v1: any, k2: any, v2: any, k3: any, v3: any, k4: any, v4: any, k5: any, v5: any, k6: any, v6: any): RDatum - object(k1: any, v1: any, k2: any, v2: any, k3: any, v3: any, k4: any, v4: any, k5: any, v5: any, k6: any, v6: any, k7: any, v7: any): RDatum - and(...objs: any[]): RDatum - or(...objs: any[]): RDatum - eq(...objs: any[]): RDatum - ne(...objs: any[]): RDatum - gt(...objs: any[]): RDatum - lt(...objs: any[]): RDatum - ge(...objs: any[]): RDatum - le(...objs: any[]): RDatum - now(): RDatum - asc(name: T): R_Sorting - desc(name: T): R_Sorting - args(array: any): any - row: RTableRow - minval: RDatum - maxval: RDatum - error(message: string): RDatum - union(stream1: RStream, stream2: RStream): RStream - union(stream1: RStream, stream2: RStream, stream3: RStream): RStream - union(...streams: any[]): RArray - js(code: string): RDatum -} - -interface RDB { - table(name: string): RTable - table(name: "devices"): RTable; - table(name: "api_calls"): RTable; - tableList(): RArray - tableDrop(name: string): RDatum<{tables_dropped: 1, config_changes: {old_val: R_TableConfig, new_val: null}}> - tableCreate(name: string, opts?: R_TableCreateOptions): RDatum<{tables_created: 1, config_changes: {old_val: null, new_val: R_TableConfig}}> -} - -type RPrimitive = null | string | number | Date | boolean | Buffer - -type RDatumfy = { - [P in keyof T]: T[P] | RDatum | RDatumfy; -}; - -type DeepPartial = { - [P in keyof T]?: DeepPartial; -}; - -interface R_TableConfig { - -} - -interface R_TableCreateOptions { - primaryKey?: string - durability?: "soft" | "hard" - shards?: number - replicas?: number | {[server: string]: number} - primaryReplicaTag?: string -} - -interface RStreamOrDatum { - count(): RDatum -} - -interface RDatum extends RStreamOrDatum, PromiseLike { - run(): PromiseLike - do(func: (obj: this) => X): RDatum - do(func: (obj: this) => any): RDatum - default(val: X): RDatum - default(val: any): RDatum - (idx: K): RDatum - (idx: number | RDatum): RDatum - orderBy(field: string | R_Sorting | ((e: RDatum) => any)): RArray - merge(op: (e: RDatum) => any): RDatum - merge(op: any): RDatum - map(func: (e: RDatum) => any): RArray - map(other: RArray | RStream, func: (e: RDatum, x: RDatum) => any): RArray - map(other: any, func: (e: RDatum, x: RDatum) => any): RArray - concatMap(func: (e: RDatum) => any): RArray - sub(other: any): RDatum - div(other: any): RDatum - add(...others: any[]): RDatum - mul(...others: any[]): RDatum - append(other: any): RDatum - skip(other: any): RDatum - limit(other: any): RDatum - round(): RDatum - floor(): RDatum - ceil(): RDatum - without(field: any): RDatum - pluck(...field: any[]): RDatum - match(regex: string | RDatum): RDatum - - filter(criteria: (obj: any) => boolean | RDatum): RDatum - filter(obj: any): RDatum - contains(obj: any): RDatum - - eq(other: T | RDatum): RDatum - ne(other: T | RDatum): RDatum - gt(other: T | RDatum): RDatum - lt(other: T | RDatum): RDatum - ge(other: T | RDatum): RDatum - le(other: T | RDatum): RDatum - - not(): RDatum - and(...objs: any[]): RDatum - or(...objs: any[]): RDatum - - year(): RDatum - month(): RDatum - day(): RDatum - hours(): RDatum - minutes(): RDatum - seconds(): RDatum - - split(by: string): RArray - coerceTo(type: "array"): RArray - coerceTo(type: "string"): RDatum - coerceTo(type: "number"): RDatum - - setInsert(other: any): RArray - setUnion(other: any): RArray - setIntersection(other: any): RArray - setDifference(other: any): RArray - append(value: any): RArray - prepend(value: any): RArray - difference(other: any): RArray - - sum(): RDatum - sum(idx: string): RDatum - avg(): RDatum - avg(idx: string): RDatum - min(): RDatum - min(idx: string): RDatum - max(): RDatum - max(idx: string): RDatum - - group(idx: string): RGroupedStream - group(func: (obj: RDatum) => any): RGroupedStream - ungroup(): RArray<{group: any, reduction: any}> - forEach(func: (e: RDatum) => any): RDatum<{}> - - fold(base: any, func: (acc: RDatum, row: RDatum) => any, options?: {emit: (state: RDatum, row: RDatum, newState: RDatum) => any}): RDatum - - hasFields(fields: Array): RDatum - hasFields(field: keyof T): RDatum - - date(): RDatum; -} - -interface RArray extends RDatum { - (idx: number | RDatum): RDatum - (idx: K): RArray - map(func: (e: RDatum) => any): RArray - map(other: RArray | RStream, func: (e: RDatum, x: RDatum) => any): RArray - map(other: any, func: (e: RDatum, x: RDatum) => any): RArray - merge(func: (e: RDatum) => any): RArray - concatMap(func: (e: RDatum) => any): RArray - orderBy(field: keyof T | R_Sorting | ((e: RDatum) => any)): RArray - append(other: T): RArray - filter(criteria: (obj: RDatum) => boolean | RDatum): RArray - filter(obj: DeepPartial>): RArray - skip(other: any): RArray - limit(other: any): RArray - contains(obj: T): RDatum - reduce(func: (a: RDatum, b: RDatum) => any): RDatum - distinct(): RArray - sample(count: number | RDatum): RArray - isEmpty(): RDatum; - - setInsert(other: any): RArray - setUnion(other: any): RArray - setIntersection(other: any): RArray - setDifference(other: any): RArray - append(value: any): RArray - prepend(value: any): RArray - difference(other: any): RArray - - sum(): RDatum - sum(idx: K): RDatum - avg(): RDatum - avg(idx: K): RDatum - min(): RDatum - min(idx: K): RDatum - max(): RDatum - max(idx: K): RDatum - - group(idx: K): RGroupedStream - group(func: (obj: RDatum) => any): RGroupedStream - forEach(func: (e: RDatum) => any): RDatum<{}> -} - -interface RStream extends PromiseLike, RStreamOrDatum { - run(): PromiseLike - (idx: number): RDatum - (field: string): RArray - map(func: (arg: RDatum) => any): RStream - map(other: RArray | RStream, func: (e: RDatum, x: RDatum) => any): RArray - map(other: any, func: (e: RDatum, x: RDatum) => any): RArray - merge(func: (arg: RDatum) => any): RStream - concatMap(func: (arg: RDatum) => any): RStream - orderBy(field: keyof T | R_Sorting | ((e: RDatum) => any)): RArray - orderBy(options: {index: string | R_Sorting}): RStream - coerceTo(type: "array"): RArray - filter(criteria: (obj: RDatum) => boolean | RDatum): RStream - filter(obj: DeepPartial>): RStream - skip(other: any): RStream - limit(other: any): RStream - reduce(func: (a: RDatum, b: RDatum) => any): RDatum - distinct(): RArray - sample(count: number | RDatum): RStream - - sum(): RDatum - sum(idx: K): RDatum - avg(): RDatum - avg(idx: K): RDatum - min(): RDatum - min(idx: K): RDatum - max(): RDatum - max(idx: K): RDatum - - group(idx: K): RGroupedStream - group(func: (obj: RDatum) => any): RGroupedStream - forEach(func: (e: RDatum) => any): RDatum<{}> - fold(base: any, func: (acc: RDatum, row: RDatum) => any, options?: {emit: (state: RDatum, row: RDatum, newState: RDatum) => any}): RDatum -} - -interface RGroupedStream extends RArray { - ungroup(): RArray<{group: G, reduction: T[]}> -} - -interface R_UpdateOptions { - durability?: "hard" | "soft" - returnChanges?: true | false | "always" - nonAtomic?: boolean -} - -interface R_UpdateResult { - replaced: number - unchanged: number - skipped: number - errors: number - first_error?: string - deleted: 0 - inserted: 0 -} - -type RUpdateObj = RDatum | DeepPartial - -interface RTableSlice extends RStream { - update(obj: (obj: RDatum) => any, options: Opts): RDatum - update(obj: (obj: RDatum) => any, options?: R_UpdateOptions): RDatum - update(obj: RUpdateObj, options: Opts): RDatum - update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum - replace(obj: RInsertObj): RDatum - delete(): RDatum<{}> - filter(criteria: (obj: RDatum) => boolean | RDatum): RTableSlice - filter(obj: DeepPartial>): RTableSlice - hasFields(fields: Array): RTableSlice - hasFields(field: keyof T): RTableSlice -} - -interface RTableRow extends RDatum { - update(obj: (obj: RDatum) => any, options: Opts): RDatum - update(obj: (obj: RDatum) => any, options?: R_UpdateOptions): RDatum - update(obj: RUpdateObj, options: Opts): RDatum - update(obj: RUpdateObj, options?: R_UpdateOptions): RDatum - replace(obj: (obj: RDatum) => any, options?: R_UpdateOptions): RDatum - replace(obj: RInsertObj, options?: R_UpdateOptions): RDatum - delete(): RDatum<{}> - eq(other: T | RDatum | null): RDatum - ne(other: T | RDatum | null): RDatum -} - -interface R_InsertOptions { - durability?: "hard" | "soft" - returnChanges?: true | false | "always" - conflict?: "error" | "replace" | "update" | ((id: string, oldDoc: RDatum, newDoc: RDatum) => any) -} - -interface R_InsertResult { - inserted: number - replaced: number - unchanged: number - errors: number - first_error?: string - deleted: 0 - skipped: 0 - generated_keys: string[] - warnings?: string[] -} - -interface R_IndexStatus { - index: string - ready: boolean - progress?: number - function: Buffer - multi: boolean - geo: boolean - outdated: boolean - query: string -} - -type RInsertObj = RDatum | RStream | RDatum | RDatumfy[] | (() => RInsertObj) | RDatumfy - -interface RTable extends RTableSlice { - get(id: any): RTableRow - insert & {returnChanges: true | "always"}>(obj: RInsertObj, options: Opts): RDatum - insert(obj: RInsertObj, options?: R_InsertOptions): RDatum - - indexList(): RArray - indexCreate(name: string, func: (obj: RDatum) => any, opts?: {multi?: boolean, geo?: boolean}): RDatum<{created: 1}> - indexCreate(name: keyof T, opts?: {multi?: boolean, geo?: boolean}): RDatum<{created: 1}> - indexDrop(name: string): RDatum<{dropped: 1}> - indexStatus(...names: string[]): RArray - - getAll(id: any, opts?: {index: string}): RTableSlice - getAll(id1: any, id2: any, opts?: {index: string}): RTableSlice - getAll(id1: any, id2: any, id3: any, opts?: {index: string}): RTableSlice - getAll(id1: any, id2: any, id3: any, id4: any, opts?: {index: string}): RTableSlice - between(lower: any, upper: any, opts?: {index: string, leftBound?: "closed" | "open", rightBound?: "closed" | "open"}): RTableSlice - - getNearest(id: RPoint, opts: { index: string, maxResults?: number, unit?: "m" | "km" | "mi" | "nm" | "ft", maxDist?: number, geoSystem?: "WGS84" | "unit_sphere" }): RTableSlice; -} diff --git a/rethinkdb/tsconfig.json b/rethinkdb/tsconfig.json deleted file mode 100644 index b356b0a..0000000 --- a/rethinkdb/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compileOnSave": false, - "compilerOptions": { - "declaration": true, - "alwaysStrict": true, - "allowSyntheticDefaultImports": true, - "moduleResolution": "node", - "noImplicitAny": true, - "noImplicitThis": true, - "sourceMap": true, - "target": "ES2017", - "strictNullChecks": true - }, - "include": [ - "index.ts", - "rethinkdb.d.ts" - ], - "exclude": [] -} diff --git a/rethinkdb/yarn.lock b/rethinkdb/yarn.lock deleted file mode 100644 index 9721328..0000000 --- a/rethinkdb/yarn.lock +++ /dev/null @@ -1,1611 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@types/node@^7.0.31": - version "7.0.31" - resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.31.tgz#80ea4d175599b2a00149c29a10a4eb2dff592e86" - -abbrev@1: - version "1.1.0" - resolved "https://npm.cubos.io/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" - -ajv@^4.9.1: - version "4.11.8" - resolved "https://npm.cubos.io/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" - dependencies: - co "^4.6.0" - json-stable-stringify "^1.0.1" - -ansi-regex@^2.0.0: - version "2.1.1" - resolved "https://npm.cubos.io/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" - -ansi-styles@^2.2.1: - version "2.2.1" - resolved "https://npm.cubos.io/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" - -anymatch@^1.3.0: - version "1.3.0" - resolved "https://npm.cubos.io/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507" - dependencies: - arrify "^1.0.0" - micromatch "^2.1.5" - -aproba@^1.0.3: - version "1.1.2" - resolved "https://npm.cubos.io/aproba/-/aproba-1.1.2.tgz#45c6629094de4e96f693ef7eab74ae079c240fc1" - -are-we-there-yet@~1.1.2: - version "1.1.4" - resolved "https://npm.cubos.io/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz#bb5dca382bb94f05e15194373d16fd3ba1ca110d" - dependencies: - delegates "^1.0.0" - readable-stream "^2.0.6" - -arr-diff@^2.0.0: - version "2.0.0" - resolved "https://npm.cubos.io/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" - dependencies: - arr-flatten "^1.0.1" - -arr-flatten@^1.0.1: - version "1.0.3" - resolved "https://npm.cubos.io/arr-flatten/-/arr-flatten-1.0.3.tgz#a274ed85ac08849b6bd7847c4580745dc51adfb1" - -array-unique@^0.2.1: - version "0.2.1" - resolved "https://npm.cubos.io/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" - -arrify@^1.0.0: - version "1.0.1" - resolved "https://npm.cubos.io/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" - -asn1@~0.2.3: - version "0.2.3" - resolved "https://npm.cubos.io/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" - -assert-plus@1.0.0, assert-plus@^1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - -assert-plus@^0.2.0: - version "0.2.0" - resolved "https://npm.cubos.io/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" - -async-each@^1.0.0: - version "1.0.1" - resolved "https://npm.cubos.io/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://npm.cubos.io/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - -aws-sign2@~0.6.0: - version "0.6.0" - resolved "https://npm.cubos.io/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" - -aws4@^1.2.1: - version "1.6.0" - resolved "https://npm.cubos.io/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" - -babel-cli@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-cli/-/babel-cli-6.24.1.tgz#207cd705bba61489b2ea41b5312341cf6aca2283" - dependencies: - babel-core "^6.24.1" - babel-polyfill "^6.23.0" - babel-register "^6.24.1" - babel-runtime "^6.22.0" - commander "^2.8.1" - convert-source-map "^1.1.0" - fs-readdir-recursive "^1.0.0" - glob "^7.0.0" - lodash "^4.2.0" - output-file-sync "^1.1.0" - path-is-absolute "^1.0.0" - slash "^1.0.0" - source-map "^0.5.0" - v8flags "^2.0.10" - optionalDependencies: - chokidar "^1.6.1" - -babel-code-frame@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" - dependencies: - chalk "^1.1.0" - esutils "^2.0.2" - js-tokens "^3.0.0" - -babel-core@^6.24.1: - version "6.25.0" - resolved "https://npm.cubos.io/babel-core/-/babel-core-6.25.0.tgz#7dd42b0463c742e9d5296deb3ec67a9322dad729" - dependencies: - babel-code-frame "^6.22.0" - babel-generator "^6.25.0" - babel-helpers "^6.24.1" - babel-messages "^6.23.0" - babel-register "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.25.0" - babel-traverse "^6.25.0" - babel-types "^6.25.0" - babylon "^6.17.2" - convert-source-map "^1.1.0" - debug "^2.1.1" - json5 "^0.5.0" - lodash "^4.2.0" - minimatch "^3.0.2" - path-is-absolute "^1.0.0" - private "^0.1.6" - slash "^1.0.0" - source-map "^0.5.0" - -babel-generator@^6.25.0: - version "6.25.0" - resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.25.0.tgz#33a1af70d5f2890aeb465a4a7793c1df6a9ea9fc" - dependencies: - babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-types "^6.25.0" - detect-indent "^4.0.0" - jsesc "^1.3.0" - lodash "^4.2.0" - source-map "^0.5.0" - trim-right "^1.0.1" - -babel-helper-builder-binary-assignment-operator-visitor@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz#cce4517ada356f4220bcae8a02c2b346f9a56664" - dependencies: - babel-helper-explode-assignable-expression "^6.24.1" - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-helper-call-delegate@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz#ece6aacddc76e41c3461f88bfc575bd0daa2df8d" - dependencies: - babel-helper-hoist-variables "^6.24.1" - babel-runtime "^6.22.0" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helper-define-map@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helper-define-map/-/babel-helper-define-map-6.24.1.tgz#7a9747f258d8947d32d515f6aa1c7bd02204a080" - dependencies: - babel-helper-function-name "^6.24.1" - babel-runtime "^6.22.0" - babel-types "^6.24.1" - lodash "^4.2.0" - -babel-helper-explode-assignable-expression@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz#f25b82cf7dc10433c55f70592d5746400ac22caa" - dependencies: - babel-runtime "^6.22.0" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helper-function-name@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" - dependencies: - babel-helper-get-function-arity "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helper-get-function-arity@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-helper-hoist-variables@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz#1ecb27689c9d25513eadbc9914a73f5408be7a76" - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-helper-optimise-call-expression@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz#f7a13427ba9f73f8f4fa993c54a97882d1244257" - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-helper-regex@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helper-regex/-/babel-helper-regex-6.24.1.tgz#d36e22fab1008d79d88648e32116868128456ce8" - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - lodash "^4.2.0" - -babel-helper-remap-async-to-generator@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" - dependencies: - babel-helper-function-name "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helper-replace-supers@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz#bf6dbfe43938d17369a213ca8a8bf74b6a90ab1a" - dependencies: - babel-helper-optimise-call-expression "^6.24.1" - babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-helpers@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" - dependencies: - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-messages@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-check-es2015-constants@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-syntax-async-functions@^6.8.0: - version "6.13.0" - resolved "https://npm.cubos.io/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" - -babel-plugin-syntax-exponentiation-operator@^6.8.0: - version "6.13.0" - resolved "https://npm.cubos.io/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de" - -babel-plugin-syntax-trailing-function-commas@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" - -babel-plugin-transform-async-to-generator@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761" - dependencies: - babel-helper-remap-async-to-generator "^6.24.1" - babel-plugin-syntax-async-functions "^6.8.0" - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-arrow-functions@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221" - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz#bbc51b49f964d70cb8d8e0b94e820246ce3a6141" - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-block-scoping@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.24.1.tgz#76c295dc3a4741b1665adfd3167215dcff32a576" - dependencies: - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - lodash "^4.2.0" - -babel-plugin-transform-es2015-classes@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db" - dependencies: - babel-helper-define-map "^6.24.1" - babel-helper-function-name "^6.24.1" - babel-helper-optimise-call-expression "^6.24.1" - babel-helper-replace-supers "^6.24.1" - babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-computed-properties@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz#6fe2a8d16895d5634f4cd999b6d3480a308159b3" - dependencies: - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-plugin-transform-es2015-destructuring@^6.22.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-duplicate-keys@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz#73eb3d310ca969e3ef9ec91c53741a6f1576423e" - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-for-of@^6.22.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz#f47c95b2b613df1d3ecc2fdb7573623c75248691" - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-function-name@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz#834c89853bc36b1af0f3a4c5dbaa94fd8eacaa8b" - dependencies: - babel-helper-function-name "^6.24.1" - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-literals@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz#4f54a02d6cd66cf915280019a31d31925377ca2e" - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-modules-amd@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154" - dependencies: - babel-plugin-transform-es2015-modules-commonjs "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-plugin-transform-es2015-modules-commonjs@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.24.1.tgz#d3e310b40ef664a36622200097c6d440298f2bfe" - dependencies: - babel-plugin-transform-strict-mode "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-modules-systemjs@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" - dependencies: - babel-helper-hoist-variables "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-plugin-transform-es2015-modules-umd@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz#ac997e6285cd18ed6176adb607d602344ad38468" - dependencies: - babel-plugin-transform-es2015-modules-amd "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - -babel-plugin-transform-es2015-object-super@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz#24cef69ae21cb83a7f8603dad021f572eb278f8d" - dependencies: - babel-helper-replace-supers "^6.24.1" - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-parameters@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" - dependencies: - babel-helper-call-delegate "^6.24.1" - babel-helper-get-function-arity "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-shorthand-properties@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz#24f875d6721c87661bbd99a4622e51f14de38aa0" - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-spread@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz#d6d68a99f89aedc4536c81a542e8dd9f1746f8d1" - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-sticky-regex@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz#00c1cdb1aca71112cdf0cf6126c2ed6b457ccdbc" - dependencies: - babel-helper-regex "^6.24.1" - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-plugin-transform-es2015-template-literals@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz#a84b3450f7e9f8f1f6839d6d687da84bb1236d8d" - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-typeof-symbol@^6.22.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz#dec09f1cddff94b52ac73d505c84df59dcceb372" - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-es2015-unicode-regex@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz#d38b12f42ea7323f729387f18a7c5ae1faeb35e9" - dependencies: - babel-helper-regex "^6.24.1" - babel-runtime "^6.22.0" - regexpu-core "^2.0.0" - -babel-plugin-transform-exponentiation-operator@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz#2ab0c9c7f3098fa48907772bb813fe41e8de3a0e" - dependencies: - babel-helper-builder-binary-assignment-operator-visitor "^6.24.1" - babel-plugin-syntax-exponentiation-operator "^6.8.0" - babel-runtime "^6.22.0" - -babel-plugin-transform-regenerator@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.24.1.tgz#b8da305ad43c3c99b4848e4fe4037b770d23c418" - dependencies: - regenerator-transform "0.9.11" - -babel-plugin-transform-runtime@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.23.0.tgz#88490d446502ea9b8e7efb0fe09ec4d99479b1ee" - dependencies: - babel-runtime "^6.22.0" - -babel-plugin-transform-strict-mode@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758" - dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - -babel-polyfill@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-polyfill/-/babel-polyfill-6.23.0.tgz#8364ca62df8eafb830499f699177466c3b03499d" - dependencies: - babel-runtime "^6.22.0" - core-js "^2.4.0" - regenerator-runtime "^0.10.0" - -babel-preset-es2015@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz#d44050d6bc2c9feea702aaf38d727a0210538939" - dependencies: - babel-plugin-check-es2015-constants "^6.22.0" - babel-plugin-transform-es2015-arrow-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoping "^6.24.1" - babel-plugin-transform-es2015-classes "^6.24.1" - babel-plugin-transform-es2015-computed-properties "^6.24.1" - babel-plugin-transform-es2015-destructuring "^6.22.0" - babel-plugin-transform-es2015-duplicate-keys "^6.24.1" - babel-plugin-transform-es2015-for-of "^6.22.0" - babel-plugin-transform-es2015-function-name "^6.24.1" - babel-plugin-transform-es2015-literals "^6.22.0" - babel-plugin-transform-es2015-modules-amd "^6.24.1" - babel-plugin-transform-es2015-modules-commonjs "^6.24.1" - babel-plugin-transform-es2015-modules-systemjs "^6.24.1" - babel-plugin-transform-es2015-modules-umd "^6.24.1" - babel-plugin-transform-es2015-object-super "^6.24.1" - babel-plugin-transform-es2015-parameters "^6.24.1" - babel-plugin-transform-es2015-shorthand-properties "^6.24.1" - babel-plugin-transform-es2015-spread "^6.22.0" - babel-plugin-transform-es2015-sticky-regex "^6.24.1" - babel-plugin-transform-es2015-template-literals "^6.22.0" - babel-plugin-transform-es2015-typeof-symbol "^6.22.0" - babel-plugin-transform-es2015-unicode-regex "^6.24.1" - babel-plugin-transform-regenerator "^6.24.1" - -babel-preset-es2016@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-preset-es2016/-/babel-preset-es2016-6.24.1.tgz#f900bf93e2ebc0d276df9b8ab59724ebfd959f8b" - dependencies: - babel-plugin-transform-exponentiation-operator "^6.24.1" - -babel-preset-es2017@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-preset-es2017/-/babel-preset-es2017-6.24.1.tgz#597beadfb9f7f208bcfd8a12e9b2b29b8b2f14d1" - dependencies: - babel-plugin-syntax-trailing-function-commas "^6.22.0" - babel-plugin-transform-async-to-generator "^6.24.1" - -babel-register@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-register/-/babel-register-6.24.1.tgz#7e10e13a2f71065bdfad5a1787ba45bca6ded75f" - dependencies: - babel-core "^6.24.1" - babel-runtime "^6.22.0" - core-js "^2.4.0" - home-or-tmp "^2.0.0" - lodash "^4.2.0" - mkdirp "^0.5.1" - source-map-support "^0.4.2" - -babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b" - dependencies: - core-js "^2.4.0" - regenerator-runtime "^0.10.0" - -babel-template@^6.24.1, babel-template@^6.25.0: - version "6.25.0" - resolved "https://npm.cubos.io/babel-template/-/babel-template-6.25.0.tgz#665241166b7c2aa4c619d71e192969552b10c071" - dependencies: - babel-runtime "^6.22.0" - babel-traverse "^6.25.0" - babel-types "^6.25.0" - babylon "^6.17.2" - lodash "^4.2.0" - -babel-traverse@^6.24.1, babel-traverse@^6.25.0: - version "6.25.0" - resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.25.0.tgz#2257497e2fcd19b89edc13c4c91381f9512496f1" - dependencies: - babel-code-frame "^6.22.0" - babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-types "^6.25.0" - babylon "^6.17.2" - debug "^2.2.0" - globals "^9.0.0" - invariant "^2.2.0" - lodash "^4.2.0" - -babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.25.0: - version "6.25.0" - resolved "https://npm.cubos.io/babel-types/-/babel-types-6.25.0.tgz#70afb248d5660e5d18f811d91c8303b54134a18e" - dependencies: - babel-runtime "^6.22.0" - esutils "^2.0.2" - lodash "^4.2.0" - to-fast-properties "^1.0.1" - -babylon@^6.17.2: - version "6.17.3" - resolved "https://npm.cubos.io/babylon/-/babylon-6.17.3.tgz#1327d709950b558f204e5352587fd0290f8d8e48" - -balanced-match@^1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - -bcrypt-pbkdf@^1.0.0: - version "1.0.1" - resolved "https://npm.cubos.io/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" - dependencies: - tweetnacl "^0.14.3" - -binary-extensions@^1.0.0: - version "1.8.0" - resolved "https://npm.cubos.io/binary-extensions/-/binary-extensions-1.8.0.tgz#48ec8d16df4377eae5fa5884682480af4d95c774" - -block-stream@*: - version "0.0.9" - resolved "https://npm.cubos.io/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" - dependencies: - inherits "~2.0.0" - -"bluebird@>= 3.0.1": - version "3.5.0" - resolved "https://npm.cubos.io/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c" - -boom@2.x.x: - version "2.10.1" - resolved "https://npm.cubos.io/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" - dependencies: - hoek "2.x.x" - -brace-expansion@^1.1.7: - version "1.1.8" - resolved "https://npm.cubos.io/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@^1.8.2: - version "1.8.5" - resolved "https://npm.cubos.io/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" - dependencies: - expand-range "^1.8.1" - preserve "^0.2.0" - repeat-element "^1.1.2" - -caseless@~0.12.0: - version "0.12.0" - resolved "https://npm.cubos.io/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" - -chalk@^1.1.0: - version "1.1.3" - resolved "https://npm.cubos.io/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" - dependencies: - ansi-styles "^2.2.1" - escape-string-regexp "^1.0.2" - has-ansi "^2.0.0" - strip-ansi "^3.0.0" - supports-color "^2.0.0" - -chokidar@^1.6.1: - version "1.7.0" - resolved "https://npm.cubos.io/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" - dependencies: - anymatch "^1.3.0" - async-each "^1.0.0" - glob-parent "^2.0.0" - inherits "^2.0.1" - is-binary-path "^1.0.0" - is-glob "^2.0.0" - path-is-absolute "^1.0.0" - readdirp "^2.0.0" - optionalDependencies: - fsevents "^1.0.0" - -co@^4.6.0: - version "4.6.0" - resolved "https://npm.cubos.io/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" - -code-point-at@^1.0.0: - version "1.1.0" - resolved "https://npm.cubos.io/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" - -combined-stream@^1.0.5, combined-stream@~1.0.5: - version "1.0.5" - resolved "https://npm.cubos.io/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" - dependencies: - delayed-stream "~1.0.0" - -commander@^2.8.1: - version "2.9.0" - resolved "https://npm.cubos.io/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" - dependencies: - graceful-readlink ">= 1.0.0" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://npm.cubos.io/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - -console-control-strings@^1.0.0, console-control-strings@~1.1.0: - version "1.1.0" - resolved "https://npm.cubos.io/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" - -convert-source-map@^1.1.0: - version "1.5.0" - resolved "https://npm.cubos.io/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" - -core-js@^2.4.0: - version "2.4.1" - resolved "https://npm.cubos.io/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" - -core-util-is@~1.0.0: - version "1.0.2" - resolved "https://npm.cubos.io/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - -cryptiles@2.x.x: - version "2.0.5" - resolved "https://npm.cubos.io/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" - dependencies: - boom "2.x.x" - -dashdash@^1.12.0: - version "1.14.1" - resolved "https://npm.cubos.io/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" - dependencies: - assert-plus "^1.0.0" - -debug@^2.1.1, debug@^2.2.0: - version "2.6.8" - resolved "https://npm.cubos.io/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" - dependencies: - ms "2.0.0" - -deep-extend@~0.4.0: - version "0.4.2" - resolved "https://npm.cubos.io/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - -delegates@^1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" - -detect-indent@^4.0.0: - version "4.0.0" - resolved "https://npm.cubos.io/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" - dependencies: - repeating "^2.0.0" - -ecc-jsbn@~0.1.1: - version "0.1.1" - resolved "https://npm.cubos.io/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" - dependencies: - jsbn "~0.1.0" - -escape-string-regexp@^1.0.2: - version "1.0.5" - resolved "https://npm.cubos.io/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - -esutils@^2.0.2: - version "2.0.2" - resolved "https://npm.cubos.io/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" - -expand-brackets@^0.1.4: - version "0.1.5" - resolved "https://npm.cubos.io/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" - dependencies: - is-posix-bracket "^0.1.0" - -expand-range@^1.8.1: - version "1.8.2" - resolved "https://npm.cubos.io/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" - dependencies: - fill-range "^2.1.0" - -extend@~3.0.0: - version "3.0.1" - resolved "https://npm.cubos.io/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" - -extglob@^0.3.1: - version "0.3.2" - resolved "https://npm.cubos.io/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" - dependencies: - is-extglob "^1.0.0" - -extsprintf@1.0.2: - version "1.0.2" - resolved "https://npm.cubos.io/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" - -filename-regex@^2.0.0: - version "2.0.1" - resolved "https://npm.cubos.io/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" - -fill-range@^2.1.0: - version "2.2.3" - resolved "https://npm.cubos.io/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" - dependencies: - is-number "^2.1.0" - isobject "^2.0.0" - randomatic "^1.1.3" - repeat-element "^1.1.2" - repeat-string "^1.5.2" - -for-in@^1.0.1: - version "1.0.2" - resolved "https://npm.cubos.io/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" - -for-own@^0.1.4: - version "0.1.5" - resolved "https://npm.cubos.io/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce" - dependencies: - for-in "^1.0.1" - -forever-agent@~0.6.1: - version "0.6.1" - resolved "https://npm.cubos.io/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" - -form-data@~2.1.1: - version "2.1.4" - resolved "https://npm.cubos.io/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.5" - mime-types "^2.1.12" - -fs-readdir-recursive@^1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - -fsevents@^1.0.0: - version "1.1.2" - resolved "https://npm.cubos.io/fsevents/-/fsevents-1.1.2.tgz#3282b713fb3ad80ede0e9fcf4611b5aa6fc033f4" - dependencies: - nan "^2.3.0" - node-pre-gyp "^0.6.36" - -fstream-ignore@^1.0.5: - version "1.0.5" - resolved "https://npm.cubos.io/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" - dependencies: - fstream "^1.0.0" - inherits "2" - minimatch "^3.0.0" - -fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: - version "1.0.11" - resolved "https://npm.cubos.io/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" - dependencies: - graceful-fs "^4.1.2" - inherits "~2.0.0" - mkdirp ">=0.5 0" - rimraf "2" - -gauge@~2.7.3: - version "2.7.4" - resolved "https://npm.cubos.io/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" - dependencies: - aproba "^1.0.3" - console-control-strings "^1.0.0" - has-unicode "^2.0.0" - object-assign "^4.1.0" - signal-exit "^3.0.0" - string-width "^1.0.1" - strip-ansi "^3.0.1" - wide-align "^1.1.0" - -getpass@^0.1.1: - version "0.1.7" - resolved "https://npm.cubos.io/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" - dependencies: - assert-plus "^1.0.0" - -glob-base@^0.3.0: - version "0.3.0" - resolved "https://npm.cubos.io/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" - dependencies: - glob-parent "^2.0.0" - is-glob "^2.0.0" - -glob-parent@^2.0.0: - version "2.0.0" - resolved "https://npm.cubos.io/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" - dependencies: - is-glob "^2.0.0" - -glob@^7.0.0, glob@^7.0.5: - version "7.1.2" - resolved "https://npm.cubos.io/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -globals@^9.0.0: - version "9.18.0" - resolved "https://npm.cubos.io/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" - -graceful-fs@^4.1.2, graceful-fs@^4.1.4: - version "4.1.11" - resolved "https://npm.cubos.io/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" - -"graceful-readlink@>= 1.0.0": - version "1.0.1" - resolved "https://npm.cubos.io/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" - -har-schema@^1.0.5: - version "1.0.5" - resolved "https://npm.cubos.io/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" - -har-validator@~4.2.1: - version "4.2.1" - resolved "https://npm.cubos.io/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" - dependencies: - ajv "^4.9.1" - har-schema "^1.0.5" - -has-ansi@^2.0.0: - version "2.0.0" - resolved "https://npm.cubos.io/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" - dependencies: - ansi-regex "^2.0.0" - -has-unicode@^2.0.0: - version "2.0.1" - resolved "https://npm.cubos.io/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" - -hawk@~3.1.3: - version "3.1.3" - resolved "https://npm.cubos.io/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" - dependencies: - boom "2.x.x" - cryptiles "2.x.x" - hoek "2.x.x" - sntp "1.x.x" - -hoek@2.x.x: - version "2.16.3" - resolved "https://npm.cubos.io/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" - -home-or-tmp@^2.0.0: - version "2.0.0" - resolved "https://npm.cubos.io/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" - dependencies: - os-homedir "^1.0.0" - os-tmpdir "^1.0.1" - -http-signature@~1.1.0: - version "1.1.1" - resolved "https://npm.cubos.io/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" - dependencies: - assert-plus "^0.2.0" - jsprim "^1.2.2" - sshpk "^1.7.0" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://npm.cubos.io/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1: - version "2.0.3" - resolved "https://npm.cubos.io/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - -ini@~1.3.0: - version "1.3.4" - resolved "https://npm.cubos.io/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" - -invariant@^2.2.0: - version "2.2.2" - resolved "https://npm.cubos.io/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" - dependencies: - loose-envify "^1.0.0" - -is-binary-path@^1.0.0: - version "1.0.1" - resolved "https://npm.cubos.io/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" - dependencies: - binary-extensions "^1.0.0" - -is-buffer@^1.1.5: - version "1.1.5" - resolved "https://npm.cubos.io/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" - -is-dotfile@^1.0.0: - version "1.0.3" - resolved "https://npm.cubos.io/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" - -is-equal-shallow@^0.1.3: - version "0.1.3" - resolved "https://npm.cubos.io/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" - dependencies: - is-primitive "^2.0.0" - -is-extendable@^0.1.1: - version "0.1.1" - resolved "https://npm.cubos.io/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" - -is-extglob@^1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" - -is-finite@^1.0.0: - version "1.0.2" - resolved "https://npm.cubos.io/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" - dependencies: - number-is-nan "^1.0.0" - -is-fullwidth-code-point@^1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" - dependencies: - number-is-nan "^1.0.0" - -is-glob@^2.0.0, is-glob@^2.0.1: - version "2.0.1" - resolved "https://npm.cubos.io/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" - dependencies: - is-extglob "^1.0.0" - -is-number@^2.1.0: - version "2.1.0" - resolved "https://npm.cubos.io/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" - dependencies: - kind-of "^3.0.2" - -is-number@^3.0.0: - version "3.0.0" - resolved "https://npm.cubos.io/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" - dependencies: - kind-of "^3.0.2" - -is-posix-bracket@^0.1.0: - version "0.1.1" - resolved "https://npm.cubos.io/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" - -is-primitive@^2.0.0: - version "2.0.0" - resolved "https://npm.cubos.io/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" - -is-typedarray@~1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" - -isarray@1.0.0, isarray@~1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - -isobject@^2.0.0: - version "2.1.0" - resolved "https://npm.cubos.io/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" - dependencies: - isarray "1.0.0" - -isstream@~0.1.2: - version "0.1.2" - resolved "https://npm.cubos.io/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" - -js-tokens@^3.0.0: - version "3.0.1" - resolved "https://npm.cubos.io/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" - -jsbn@~0.1.0: - version "0.1.1" - resolved "https://npm.cubos.io/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" - -jsesc@^1.3.0: - version "1.3.0" - resolved "https://npm.cubos.io/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" - -jsesc@~0.5.0: - version "0.5.0" - resolved "https://npm.cubos.io/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" - -json-schema@0.2.3: - version "0.2.3" - resolved "https://npm.cubos.io/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" - -json-stable-stringify@^1.0.1: - version "1.0.1" - resolved "https://npm.cubos.io/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" - dependencies: - jsonify "~0.0.0" - -json-stringify-safe@~5.0.1: - version "5.0.1" - resolved "https://npm.cubos.io/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - -json5@^0.5.0: - version "0.5.1" - resolved "https://npm.cubos.io/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" - -jsonify@~0.0.0: - version "0.0.0" - resolved "https://npm.cubos.io/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" - -jsprim@^1.2.2: - version "1.4.0" - resolved "https://npm.cubos.io/jsprim/-/jsprim-1.4.0.tgz#a3b87e40298d8c380552d8cc7628a0bb95a22918" - dependencies: - assert-plus "1.0.0" - extsprintf "1.0.2" - json-schema "0.2.3" - verror "1.3.6" - -kind-of@^3.0.2: - version "3.2.2" - resolved "https://npm.cubos.io/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" - dependencies: - is-buffer "^1.1.5" - -kind-of@^4.0.0: - version "4.0.0" - resolved "https://npm.cubos.io/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" - dependencies: - is-buffer "^1.1.5" - -lodash@^4.2.0: - version "4.17.4" - resolved "https://npm.cubos.io/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" - -loose-envify@^1.0.0: - version "1.3.1" - resolved "https://npm.cubos.io/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" - dependencies: - js-tokens "^3.0.0" - -micromatch@^2.1.5: - version "2.3.11" - resolved "https://npm.cubos.io/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" - dependencies: - arr-diff "^2.0.0" - array-unique "^0.2.1" - braces "^1.8.2" - expand-brackets "^0.1.4" - extglob "^0.3.1" - filename-regex "^2.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.1" - kind-of "^3.0.2" - normalize-path "^2.0.1" - object.omit "^2.0.0" - parse-glob "^3.0.4" - regex-cache "^0.4.2" - -mime-db@~1.27.0: - version "1.27.0" - resolved "https://npm.cubos.io/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1" - -mime-types@^2.1.12, mime-types@~2.1.7: - version "2.1.15" - resolved "https://npm.cubos.io/mime-types/-/mime-types-2.1.15.tgz#a4ebf5064094569237b8cf70046776d09fc92aed" - dependencies: - mime-db "~1.27.0" - -minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: - version "3.0.4" - resolved "https://npm.cubos.io/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - dependencies: - brace-expansion "^1.1.7" - -minimist@0.0.8: - version "0.0.8" - resolved "https://npm.cubos.io/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" - -minimist@^1.2.0: - version "1.2.0" - resolved "https://npm.cubos.io/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" - -"mkdirp@>=0.5 0", mkdirp@^0.5.1: - version "0.5.1" - resolved "https://npm.cubos.io/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" - dependencies: - minimist "0.0.8" - -ms@2.0.0: - version "2.0.0" - resolved "https://npm.cubos.io/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - -nan@^2.3.0: - version "2.6.2" - resolved "https://npm.cubos.io/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" - -node-pre-gyp@^0.6.36: - version "0.6.36" - resolved "https://npm.cubos.io/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz#db604112cb74e0d477554e9b505b17abddfab786" - dependencies: - mkdirp "^0.5.1" - nopt "^4.0.1" - npmlog "^4.0.2" - rc "^1.1.7" - request "^2.81.0" - rimraf "^2.6.1" - semver "^5.3.0" - tar "^2.2.1" - tar-pack "^3.4.0" - -nopt@^4.0.1: - version "4.0.1" - resolved "https://npm.cubos.io/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" - dependencies: - abbrev "1" - osenv "^0.1.4" - -normalize-path@^2.0.1: - version "2.1.1" - resolved "https://npm.cubos.io/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" - dependencies: - remove-trailing-separator "^1.0.1" - -npmlog@^4.0.2: - version "4.1.0" - resolved "https://npm.cubos.io/npmlog/-/npmlog-4.1.0.tgz#dc59bee85f64f00ed424efb2af0783df25d1c0b5" - dependencies: - are-we-there-yet "~1.1.2" - console-control-strings "~1.1.0" - gauge "~2.7.3" - set-blocking "~2.0.0" - -number-is-nan@^1.0.0: - version "1.0.1" - resolved "https://npm.cubos.io/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" - -oauth-sign@~0.8.1: - version "0.8.2" - resolved "https://npm.cubos.io/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" - -object-assign@^4.1.0: - version "4.1.1" - resolved "https://npm.cubos.io/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - -object.omit@^2.0.0: - version "2.0.1" - resolved "https://npm.cubos.io/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" - dependencies: - for-own "^0.1.4" - is-extendable "^0.1.1" - -once@^1.3.0, once@^1.3.3: - version "1.4.0" - resolved "https://npm.cubos.io/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - dependencies: - wrappy "1" - -os-homedir@^1.0.0: - version "1.0.2" - resolved "https://npm.cubos.io/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" - -os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: - version "1.0.2" - resolved "https://npm.cubos.io/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - -osenv@^0.1.4: - version "0.1.4" - resolved "https://npm.cubos.io/osenv/-/osenv-0.1.4.tgz#42fe6d5953df06c8064be6f176c3d05aaaa34644" - dependencies: - os-homedir "^1.0.0" - os-tmpdir "^1.0.0" - -output-file-sync@^1.1.0: - version "1.1.2" - resolved "https://npm.cubos.io/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" - dependencies: - graceful-fs "^4.1.4" - mkdirp "^0.5.1" - object-assign "^4.1.0" - -parse-glob@^3.0.4: - version "3.0.4" - resolved "https://npm.cubos.io/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" - dependencies: - glob-base "^0.3.0" - is-dotfile "^1.0.0" - is-extglob "^1.0.0" - is-glob "^2.0.0" - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://npm.cubos.io/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - -performance-now@^0.2.0: - version "0.2.0" - resolved "https://npm.cubos.io/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" - -preserve@^0.2.0: - version "0.2.0" - resolved "https://npm.cubos.io/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" - -private@^0.1.6: - version "0.1.7" - resolved "https://npm.cubos.io/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1" - -process-nextick-args@~1.0.6: - version "1.0.7" - resolved "https://npm.cubos.io/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" - -punycode@^1.4.1: - version "1.4.1" - resolved "https://npm.cubos.io/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" - -qs@~6.4.0: - version "6.4.0" - resolved "https://npm.cubos.io/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" - -randomatic@^1.1.3: - version "1.1.7" - resolved "https://npm.cubos.io/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" - dependencies: - is-number "^3.0.0" - kind-of "^4.0.0" - -rc@^1.1.7: - version "1.2.1" - resolved "https://npm.cubos.io/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95" - dependencies: - deep-extend "~0.4.0" - ini "~1.3.0" - minimist "^1.2.0" - strip-json-comments "~2.0.1" - -readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.4: - version "2.2.11" - resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.11.tgz#0796b31f8d7688007ff0b93a8088d34aa17c0f72" - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.1" - isarray "~1.0.0" - process-nextick-args "~1.0.6" - safe-buffer "~5.0.1" - string_decoder "~1.0.0" - util-deprecate "~1.0.1" - -readdirp@^2.0.0: - version "2.1.0" - resolved "https://npm.cubos.io/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78" - dependencies: - graceful-fs "^4.1.2" - minimatch "^3.0.2" - readable-stream "^2.0.2" - set-immediate-shim "^1.0.1" - -regenerate@^1.2.1: - version "1.3.2" - resolved "https://npm.cubos.io/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" - -regenerator-runtime@^0.10.0: - version "0.10.5" - resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" - -regenerator-transform@0.9.11: - version "0.9.11" - resolved "https://npm.cubos.io/regenerator-transform/-/regenerator-transform-0.9.11.tgz#3a7d067520cb7b7176769eb5ff868691befe1283" - dependencies: - babel-runtime "^6.18.0" - babel-types "^6.19.0" - private "^0.1.6" - -regex-cache@^0.4.2: - version "0.4.3" - resolved "https://npm.cubos.io/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" - dependencies: - is-equal-shallow "^0.1.3" - is-primitive "^2.0.0" - -regexpu-core@^2.0.0: - version "2.0.0" - resolved "https://npm.cubos.io/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240" - dependencies: - regenerate "^1.2.1" - regjsgen "^0.2.0" - regjsparser "^0.1.4" - -regjsgen@^0.2.0: - version "0.2.0" - resolved "https://npm.cubos.io/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" - -regjsparser@^0.1.4: - version "0.1.5" - resolved "https://npm.cubos.io/regjsparser/-/regjsparser-0.1.5.tgz#7ee8f84dc6fa792d3fd0ae228d24bd949ead205c" - dependencies: - jsesc "~0.5.0" - -remove-trailing-separator@^1.0.1: - version "1.0.2" - resolved "https://npm.cubos.io/remove-trailing-separator/-/remove-trailing-separator-1.0.2.tgz#69b062d978727ad14dc6b56ba4ab772fd8d70511" - -repeat-element@^1.1.2: - version "1.1.2" - resolved "https://npm.cubos.io/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" - -repeat-string@^1.5.2: - version "1.6.1" - resolved "https://npm.cubos.io/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" - -repeating@^2.0.0: - version "2.0.1" - resolved "https://npm.cubos.io/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" - dependencies: - is-finite "^1.0.0" - -request@^2.81.0: - version "2.81.0" - resolved "https://npm.cubos.io/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" - dependencies: - aws-sign2 "~0.6.0" - aws4 "^1.2.1" - caseless "~0.12.0" - combined-stream "~1.0.5" - extend "~3.0.0" - forever-agent "~0.6.1" - form-data "~2.1.1" - har-validator "~4.2.1" - hawk "~3.1.3" - http-signature "~1.1.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.7" - oauth-sign "~0.8.1" - performance-now "^0.2.0" - qs "~6.4.0" - safe-buffer "^5.0.1" - stringstream "~0.0.4" - tough-cookie "~2.3.0" - tunnel-agent "^0.6.0" - uuid "^3.0.0" - -rethinkdbdash@^2.3.29: - version "2.3.29" - resolved "https://npm.cubos.io/rethinkdbdash/-/rethinkdbdash-2.3.29.tgz#252e454c89a86783301eb4171959386bdb268c0c" - dependencies: - bluebird ">= 3.0.1" - -rimraf@2, rimraf@^2.5.1, rimraf@^2.6.1: - version "2.6.1" - resolved "https://npm.cubos.io/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" - dependencies: - glob "^7.0.5" - -safe-buffer@^5.0.1, safe-buffer@~5.0.1: - version "5.0.1" - resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" - -semver@^5.3.0: - version "5.3.0" - resolved "https://npm.cubos.io/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" - -set-blocking@~2.0.0: - version "2.0.0" - resolved "https://npm.cubos.io/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" - -set-immediate-shim@^1.0.1: - version "1.0.1" - resolved "https://npm.cubos.io/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" - -signal-exit@^3.0.0: - version "3.0.2" - resolved "https://npm.cubos.io/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" - -slash@^1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" - -sntp@1.x.x: - version "1.0.9" - resolved "https://npm.cubos.io/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" - dependencies: - hoek "2.x.x" - -source-map-support@^0.4.2: - version "0.4.15" - resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.15.tgz#03202df65c06d2bd8c7ec2362a193056fef8d3b1" - dependencies: - source-map "^0.5.6" - -source-map@^0.5.0, source-map@^0.5.6: - version "0.5.6" - resolved "https://npm.cubos.io/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" - -sshpk@^1.7.0: - version "1.13.1" - resolved "https://npm.cubos.io/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" - dependencies: - asn1 "~0.2.3" - assert-plus "^1.0.0" - dashdash "^1.12.0" - getpass "^0.1.1" - optionalDependencies: - bcrypt-pbkdf "^1.0.0" - ecc-jsbn "~0.1.1" - jsbn "~0.1.0" - tweetnacl "~0.14.0" - -string-width@^1.0.1, string-width@^1.0.2: - version "1.0.2" - resolved "https://npm.cubos.io/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" - dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - strip-ansi "^3.0.0" - -string_decoder@~1.0.0: - version "1.0.2" - resolved "https://npm.cubos.io/string_decoder/-/string_decoder-1.0.2.tgz#b29e1f4e1125fa97a10382b8a533737b7491e179" - dependencies: - safe-buffer "~5.0.1" - -stringstream@~0.0.4: - version "0.0.5" - resolved "https://npm.cubos.io/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" - -strip-ansi@^3.0.0, strip-ansi@^3.0.1: - version "3.0.1" - resolved "https://npm.cubos.io/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - dependencies: - ansi-regex "^2.0.0" - -strip-json-comments@~2.0.1: - version "2.0.1" - resolved "https://npm.cubos.io/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - -supports-color@^2.0.0: - version "2.0.0" - resolved "https://npm.cubos.io/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" - -tar-pack@^3.4.0: - version "3.4.0" - resolved "https://npm.cubos.io/tar-pack/-/tar-pack-3.4.0.tgz#23be2d7f671a8339376cbdb0b8fe3fdebf317984" - dependencies: - debug "^2.2.0" - fstream "^1.0.10" - fstream-ignore "^1.0.5" - once "^1.3.3" - readable-stream "^2.1.4" - rimraf "^2.5.1" - tar "^2.2.1" - uid-number "^0.0.6" - -tar@^2.2.1: - version "2.2.1" - resolved "https://npm.cubos.io/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" - dependencies: - block-stream "*" - fstream "^1.0.2" - inherits "2" - -to-fast-properties@^1.0.1: - version "1.0.3" - resolved "https://npm.cubos.io/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" - -tough-cookie@~2.3.0: - version "2.3.2" - resolved "https://npm.cubos.io/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" - dependencies: - punycode "^1.4.1" - -trim-right@^1.0.1: - version "1.0.1" - resolved "https://npm.cubos.io/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" - -tunnel-agent@^0.6.0: - version "0.6.0" - resolved "https://npm.cubos.io/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" - dependencies: - safe-buffer "^5.0.1" - -tweetnacl@^0.14.3, tweetnacl@~0.14.0: - version "0.14.5" - resolved "https://npm.cubos.io/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" - -typescript@^2.3.4: - version "2.4.0" - resolved "https://npm.cubos.io/typescript/-/typescript-2.4.0.tgz#aef5a8d404beba36ad339abf079ddddfffba86dd" - -uid-number@^0.0.6: - version "0.0.6" - resolved "https://npm.cubos.io/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" - -user-home@^1.1.1: - version "1.1.1" - resolved "https://npm.cubos.io/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" - -util-deprecate@~1.0.1: - version "1.0.2" - resolved "https://npm.cubos.io/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - -uuid@^3.0.0: - version "3.1.0" - resolved "https://npm.cubos.io/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" - -v8flags@^2.0.10: - version "2.1.1" - resolved "https://npm.cubos.io/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" - dependencies: - user-home "^1.1.1" - -verror@1.3.6: - version "1.3.6" - resolved "https://npm.cubos.io/verror/-/verror-1.3.6.tgz#cff5df12946d297d2baaefaa2689e25be01c005c" - dependencies: - extsprintf "1.0.2" - -wide-align@^1.1.0: - version "1.1.2" - resolved "https://npm.cubos.io/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710" - dependencies: - string-width "^1.0.2" - -wrappy@1: - version "1.0.2" - resolved "https://npm.cubos.io/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" From 22f3972703a785fb0d594e8470ead5c036bacacc Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 2 Jul 2017 16:35:05 -0300 Subject: [PATCH 247/625] Remove test file --- test.api | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 test.api diff --git a/test.api b/test.api deleted file mode 100644 index 7e8f9f7..0000000 --- a/test.api +++ /dev/null @@ -1,36 +0,0 @@ - -// primitive types: int, uint, float, string, bytes, date, datetime, bool - -$db = "test" - -type Image { - url: string - width: int - height: int -} - -type User { - name: string - avatar: Image -} - -type Message { - date: date - message: string - image: bytes? -} - -type CardData { - cardNumber: string !secret - holder: string - month: uint - year: uint - ccv: string !secret -} - -get currentUser(): User? -get lastMessage(user: User): Message -function logIn(user: string, pass: string !secret): User - -// subscribe messages(since: date): Message - From 7e5fa26fe687793b6739549dee744093f65c77b9 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Mon, 10 Jul 2017 18:13:53 -0300 Subject: [PATCH 248/625] expose httpclient for android target --- target_java_android.cr | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target_java_android.cr b/target_java_android.cr index 5475a7f..19ffd3c 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -255,6 +255,11 @@ END } } + static public OkHttpClient getHttpClient() { + Internal.initialize(); + return Internal.getHttpClientForThirdParty() + } + private static class Internal { static String baseUrl = #{@ast.options.url.inspect}; static OkHttpClient http = null; @@ -270,6 +275,14 @@ END createHttpClient(); } + static OkHttpClient getHttpClientForThirdParty() { + if (http == null) { + createHttpClient() + } + + return http; + } + static void createHttpClient() { connectionPool = new ConnectionPool(100, 5, TimeUnit.MINUTES); From 3515b0b27fea5995745e857774c0b1f0301da1fd Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Mon, 10 Jul 2017 18:22:35 -0300 Subject: [PATCH 249/625] fix --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 19ffd3c..8e42986 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -257,7 +257,7 @@ END static public OkHttpClient getHttpClient() { Internal.initialize(); - return Internal.getHttpClientForThirdParty() + return Internal.getHttpClientForThirdParty(); } private static class Internal { From 43688c78ba7b140fcd6f800d171498b5f32f4ff7 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Mon, 10 Jul 2017 18:35:07 -0300 Subject: [PATCH 250/625] fix2 --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 8e42986..58dcee9 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -277,7 +277,7 @@ END static OkHttpClient getHttpClientForThirdParty() { if (http == null) { - createHttpClient() + createHttpClient(); } return http; From c974aab884d2db10f531296086085c466ab6b7aa Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Wed, 12 Jul 2017 15:22:10 -0300 Subject: [PATCH 251/625] from and to JSONArray --- target_java.cr | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/target_java.cr b/target_java.cr index 65d84ce..94ab57c 100644 --- a/target_java.cr +++ b/target_java.cr @@ -99,10 +99,40 @@ END } } +public static JSONArray toJSONArray(List<#{mangle t.name}> list) { + JSONArray array = null; + if (list != null && !list.isEmpty()) { + JSONArray array = new JSONArray(); + for (int i=0; i fromJSONArray(final JSONArray jsonArray) { + ArrayList<#{mangle t.name}> list = null; + if (jsonArray != null && jsonArray.length() > 0) { + list = new ArrayList<#{mangle t.name}>(); + for (int i = 0; i < jsonArray.length(); i++) { + try { + JSONObject obj = jsonArray.getJSONObject; + list.add(fromJSON(obj)); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return list; +} + public #{mangle t.name}() { } From 9e8deffc6f65b5fa17902b02d0e2ee4db9ad6fda Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Wed, 12 Jul 2017 16:04:55 -0300 Subject: [PATCH 252/625] imports fix --- target_java_android.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/target_java_android.cr b/target_java_android.cr index 58dcee9..71dc95b 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -50,6 +50,7 @@ import java.security.SecureRandom; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.List; import java.util.Arrays; import java.util.Calendar; import java.util.Date; From 59c5bfc1508a7db7a1f623af376a8b397ba4e803 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Wed, 12 Jul 2017 16:11:14 -0300 Subject: [PATCH 253/625] fix --- target_java.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java.cr b/target_java.cr index 94ab57c..5e9692d 100644 --- a/target_java.cr +++ b/target_java.cr @@ -102,7 +102,7 @@ END public static JSONArray toJSONArray(List<#{mangle t.name}> list) { JSONArray array = null; if (list != null && !list.isEmpty()) { - JSONArray array = new JSONArray(); + array = new JSONArray(); for (int i=0; i Date: Wed, 12 Jul 2017 16:20:41 -0300 Subject: [PATCH 254/625] fix --- target_java.cr | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target_java.cr b/target_java.cr index 5e9692d..ee0a65d 100644 --- a/target_java.cr +++ b/target_java.cr @@ -111,6 +111,7 @@ public static JSONArray toJSONArray(List<#{mangle t.name}> list) { } } } + return array; } public static #{mangle t.name} fromJSON(final JSONObject json) { @@ -123,7 +124,7 @@ public static List<#{mangle t.name}> fromJSONArray(final JSONArray jsonArray) { list = new ArrayList<#{mangle t.name}>(); for (int i = 0; i < jsonArray.length(); i++) { try { - JSONObject obj = jsonArray.getJSONObject; + JSONObject obj = jsonArray.getJSONObject(i); list.add(fromJSON(obj)); } catch (Exception e) { e.printStackTrace(); From 4332d5e5a6b763b15f4acdf65722389c68dd2c64 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Wed, 12 Jul 2017 16:28:20 -0300 Subject: [PATCH 255/625] fix3 --- target_java.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_java.cr b/target_java.cr index ee0a65d..d8bf8f7 100644 --- a/target_java.cr +++ b/target_java.cr @@ -105,7 +105,7 @@ public static JSONArray toJSONArray(List<#{mangle t.name}> list) { array = new JSONArray(); for (int i=0; i fromJSONArray(final JSONArray jsonArray) { for (int i = 0; i < jsonArray.length(); i++) { try { JSONObject obj = jsonArray.getJSONObject(i); - list.add(fromJSON(obj)); + list.add(this.fromJSON(obj)); } catch (Exception e) { e.printStackTrace(); } From 5d4c26b2a295bb1a8bd82029a18fad8414da3484 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Wed, 12 Jul 2017 17:01:18 -0300 Subject: [PATCH 256/625] fix4 --- target_java.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_java.cr b/target_java.cr index d8bf8f7..047ba8d 100644 --- a/target_java.cr +++ b/target_java.cr @@ -105,7 +105,7 @@ public static JSONArray toJSONArray(List<#{mangle t.name}> list) { array = new JSONArray(); for (int i=0; i fromJSONArray(final JSONArray jsonArray) { for (int i = 0; i < jsonArray.length(); i++) { try { JSONObject obj = jsonArray.getJSONObject(i); - list.add(this.fromJSON(obj)); + list.add(fromJSON(obj)); } catch (Exception e) { e.printStackTrace(); } From 88aad736b75640fe0a25c7962863fd0841d37ae4 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Thu, 13 Jul 2017 17:32:35 -0300 Subject: [PATCH 257/625] global error handling --- target_java_android.cr | 53 ++++++++++++++++++++++++++++++++++-------- target_swift_ios.cr | 11 +++++---- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 71dc95b..a4b2b5f 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -79,14 +79,23 @@ import okhttp3.RequestBody; import okhttp3.Response; public class API { + interface GlobalRequestCallback { + public void onResult(Error error, JSONObject result, Callback callback); + }; + static public boolean useStaging = false; static public Context serviceContext = null; + static public GlobalRequestCallback globalCallback = new GlobalRequestCallback() { + @Override + public void onResult(Error error, JSONObject result, Callback callback) { + callback.onResult(error, result); + } + }; static public int Default = 0; static public int Loading = 1; static public int Cache = 2; - END @ast.struct_types.each do |t| @@ -128,7 +137,12 @@ END }}; } catch (final JSONException e) { e.printStackTrace(); - callback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}#{op.return_type.is_a?(AST::VoidPrimitiveType) ? "" : ", null"}); + globalCallback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null, new Callback() { + @Override + public void onResult(Error error, JSONObject result) { + callback.onResult(error#{op.return_type.is_a?(AST::VoidPrimitiveType) ? "" : ", #{type_from_json op.return_type, "result", "result".inspect}"}); + } + }); return; } @@ -143,23 +157,42 @@ Internal.RequestCallback reqCallback = new Internal.RequestCallback() { END if op.return_type.is_a? AST::VoidPrimitiveType io << <<-END - if (error != null) { - callback.onResult(error); - } else { - callback.onResult(null); - } + globalCallback.onResult(error, null, new Callback() { + @Override + public void onResult(Error error, JSONObject result) { + callback.onResult(error); + } + }); + END else io << <<-END if (error != null) { - callback.onResult(error, null); + globalCallback.onResult(error, null, new Callback() { + @Override + public void onResult(Error error, JSONObject result) { + if (error != null) { + callback.onResult(error,null); + elkse + } + }); } else { try { - callback.onResult(null, #{type_from_json op.return_type, "result", "result".inspect}); + globalCallback.onResult(null, #{type_from_json op.return_type, "result", "result".inspect}, new Callback() { + @Override + public void onResult(Error error, JSONObject result) { + callback.onResult(error, #{type_from_json op.return_type, "result", "result".inspect}); + } + }); } catch (final JSONException e) { e.printStackTrace(); - callback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null); + globalCallback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null, new Callback() { + @Override + public void onResult(Error error, JSONObject result) { + callback.onResult(error#{op.return_type.is_a?(AST::VoidPrimitiveType) ? "" : ", #{type_from_json op.return_type, "result", "result".inspect}"}); + } + }); } } END diff --git a/target_swift_ios.cr b/target_swift_ios.cr index 4845f84..6dc6738 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -7,6 +7,9 @@ import Alamofire class API { static var useStaging = false + static var globalCallback: (_ method: String, _ result: Result, _ callback: @escaping ((Result) -> Void)) -> Void = { _, result, callback in + callback(result) + } END @@ -199,8 +202,8 @@ class APIInternal { api.request("https://\\(baseUrl)\\(API.useStaging ? "-staging" : "")/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).responseJSON { response in guard let responseValue = response.result.value else { - let error = Error(API.ErrorType.Connection, "no result value") - callback(Result.failure(error)) + let error = Error(API.ErrorType.Connection, "Erro de Conexão, tente novamente mais tarde") + globalCallback(name, result: Result.failure(error), callback: callback) return } @@ -208,10 +211,10 @@ class APIInternal { saveDeviceID(response.deviceId) guard response.error == nil && response.ok else { - callback(Result.failure(response.error!)) + globalCallback(name, result: Result.failure(response.error!), callback: callback) return } - callback(Result.success(response.result)) + globalCallback(name, result: Result.success(response.result), callback: callback) } } } From 02f86338eab76cee000a6e3c13d38fdec7e78503 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Thu, 13 Jul 2017 17:37:19 -0300 Subject: [PATCH 258/625] global error handling2 --- target_java_android.cr | 57 ++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index a4b2b5f..49ec327 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -80,14 +80,14 @@ import okhttp3.Response; public class API { interface GlobalRequestCallback { - public void onResult(Error error, JSONObject result, Callback callback); + public void onResult(String method, Error error, JSONObject result, Callback callback); }; static public boolean useStaging = false; static public Context serviceContext = null; static public GlobalRequestCallback globalCallback = new GlobalRequestCallback() { @Override - public void onResult(Error error, JSONObject result, Callback callback) { + public void onResult(String method, Error error, JSONObject result, Callback callback) { callback.onResult(error, result); } }; @@ -137,10 +137,19 @@ END }}; } catch (final JSONException e) { e.printStackTrace(); - globalCallback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null, new Callback() { + globalCallback.onResult(#{op.pretty_name.inspect}, new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null, new Callback() { @Override public void onResult(Error error, JSONObject result) { - callback.onResult(error#{op.return_type.is_a?(AST::VoidPrimitiveType) ? "" : ", #{type_from_json op.return_type, "result", "result".inspect}"}); + if (error != null) { + callback.onResult(error, null); + } else { + try { + callback.onResult(null, #{type_from_json op.return_type, "result", "result".inspect}); + } catch (final JSONException e) { + e.printStackTrace(); + callback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null); + } + } } }); return; @@ -157,7 +166,7 @@ Internal.RequestCallback reqCallback = new Internal.RequestCallback() { END if op.return_type.is_a? AST::VoidPrimitiveType io << <<-END - globalCallback.onResult(error, null, new Callback() { + globalCallback.onResult(#{op.pretty_name.inspect}, error, null, new Callback() { @Override public void onResult(Error error, JSONObject result) { callback.onResult(error); @@ -168,33 +177,21 @@ END END else io << <<-END - if (error != null) { - globalCallback.onResult(error, null, new Callback() { - @Override - public void onResult(Error error, JSONObject result) { - if (error != null) { - callback.onResult(error,null); - elkse - } - }); - } else { - try { - globalCallback.onResult(null, #{type_from_json op.return_type, "result", "result".inspect}, new Callback() { - @Override - public void onResult(Error error, JSONObject result) { - callback.onResult(error, #{type_from_json op.return_type, "result", "result".inspect}); + globalCallback.onResult(#{op.pretty_name.inspect}, error, result, new Callback() { + @Override + public void onResult(Error error, JSONObject result) { + if (error != null) { + callback.onResult(error, null); + } else { + try { + callback.onResult(null, #{type_from_json op.return_type, "result", "result".inspect}); + } catch (final JSONException e) { + e.printStackTrace(); + callback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null); } - }); - } catch (final JSONException e) { - e.printStackTrace(); - globalCallback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null, new Callback() { - @Override - public void onResult(Error error, JSONObject result) { - callback.onResult(error#{op.return_type.is_a?(AST::VoidPrimitiveType) ? "" : ", #{type_from_json op.return_type, "result", "result".inspect}"}); - } - }); + } } - } + }); END end io << <<-END From 4305c6afb071588d0dbcb3cb16b05fcffcd48c41 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Thu, 13 Jul 2017 18:04:16 -0300 Subject: [PATCH 259/625] global error handling3 --- target_java_android.cr | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target_java_android.cr b/target_java_android.cr index 49ec327..948f5c4 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -140,6 +140,15 @@ END globalCallback.onResult(#{op.pretty_name.inspect}, new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null, new Callback() { @Override public void onResult(Error error, JSONObject result) { + +END + if op.return_type.is_a? AST::VoidPrimitiveType + io << <<-END + callback.onResult(error); + +END + else + io << <<-END if (error != null) { callback.onResult(error, null); } else { @@ -150,6 +159,10 @@ END callback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null); } } +END + end + io << <<-END + } }); return; From 433792e66f5769449f479e7b208dabf14a7ae0d7 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Thu, 13 Jul 2017 18:14:48 -0300 Subject: [PATCH 260/625] global error handling4 --- target_java_android.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 948f5c4..b9c4d8b 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -80,14 +80,14 @@ import okhttp3.Response; public class API { interface GlobalRequestCallback { - public void onResult(String method, Error error, JSONObject result, Callback callback); + public void onResult(final String method, final Error error, final JSONObject result, final Callback callback); }; static public boolean useStaging = false; static public Context serviceContext = null; static public GlobalRequestCallback globalCallback = new GlobalRequestCallback() { @Override - public void onResult(String method, Error error, JSONObject result, Callback callback) { + public void onResult(final String method, final Error error, final JSONObject result, final Callback callback) { callback.onResult(error, result); } }; From 5ab0fbb03b1d6fc90a2100748c26f4988bf921d3 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Thu, 13 Jul 2017 18:30:04 -0300 Subject: [PATCH 261/625] global error handling5 --- target_java_android.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index b9c4d8b..555b1ef 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -275,11 +275,11 @@ END } public abstract static class Callback extends BaseCallback { - public abstract void onResult(Error error, T result); + public abstract void onResult(final Error error, final T result); } public abstract static class VoidCallback extends BaseCallback { - public abstract void onResult(Error error); + public abstract void onResult(final Error error); } static public void getDeviceId(final Callback callback) { From bdb2745ec6d4c6230bbc4978884e7a8dcbbba2d4 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Thu, 13 Jul 2017 18:43:44 -0300 Subject: [PATCH 262/625] global error handling6 --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 555b1ef..aa1afce 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -275,7 +275,7 @@ END } public abstract static class Callback extends BaseCallback { - public abstract void onResult(final Error error, final T result); + public abstract void onResult(final Error error, final T result); } public abstract static class VoidCallback extends BaseCallback { From 550ee31b4ea2c048ca039b346d0f33507fe03c13 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Thu, 13 Jul 2017 18:50:38 -0300 Subject: [PATCH 263/625] global error handling7 --- target_java_android.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index aa1afce..9160638 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -181,7 +181,7 @@ END io << <<-END globalCallback.onResult(#{op.pretty_name.inspect}, error, null, new Callback() { @Override - public void onResult(Error error, JSONObject result) { + public void onResult(final Error error,final JSONObject result) { callback.onResult(error); } }); @@ -192,7 +192,7 @@ END io << <<-END globalCallback.onResult(#{op.pretty_name.inspect}, error, result, new Callback() { @Override - public void onResult(Error error, JSONObject result) { + public void onResult(final Error error,final JSONObject result) { if (error != null) { callback.onResult(error, null); } else { From 4f2d8d092ec5bcb40f9c4ab36560dd511317525c Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Thu, 13 Jul 2017 19:01:36 -0300 Subject: [PATCH 264/625] global error handling8 --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 9160638..ca98d6f 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -139,7 +139,7 @@ END e.printStackTrace(); globalCallback.onResult(#{op.pretty_name.inspect}, new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null, new Callback() { @Override - public void onResult(Error error, JSONObject result) { + public void onResult(final Error error,final JSONObject result) { END if op.return_type.is_a? AST::VoidPrimitiveType From 09115eeef393ad765cdfcfab584859050e8f50de Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Fri, 14 Jul 2017 09:48:56 -0300 Subject: [PATCH 265/625] fix --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index ca98d6f..4816cf5 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -79,7 +79,7 @@ import okhttp3.RequestBody; import okhttp3.Response; public class API { - interface GlobalRequestCallback { + public interface GlobalRequestCallback { public void onResult(final String method, final Error error, final JSONObject result, final Callback callback); }; From 9a0a89df0664ab7a29f1cee72ae134cbb20cb9b0 Mon Sep 17 00:00:00 2001 From: Victor Tavares-MBP Date: Mon, 17 Jul 2017 11:06:24 -0300 Subject: [PATCH 266/625] Fix globalCallbacks --- target_swift_ios.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target_swift_ios.cr b/target_swift_ios.cr index 6dc6738..be24ed0 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -7,7 +7,7 @@ import Alamofire class API { static var useStaging = false - static var globalCallback: (_ method: String, _ result: Result, _ callback: @escaping ((Result) -> Void)) -> Void = { _, result, callback in + static var globalCallback: (_ method: String, _ result: APIInternal.Result, _ callback: @escaping ((APIInternal.Result) -> Void)) -> Void = { _, result, callback in callback(result) } @@ -203,7 +203,7 @@ class APIInternal { api.request("https://\\(baseUrl)\\(API.useStaging ? "-staging" : "")/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).responseJSON { response in guard let responseValue = response.result.value else { let error = Error(API.ErrorType.Connection, "Erro de Conexão, tente novamente mais tarde") - globalCallback(name, result: Result.failure(error), callback: callback) + API.globalCallback(name, result: Result.failure(error), callback: callback) return } @@ -211,10 +211,10 @@ class APIInternal { saveDeviceID(response.deviceId) guard response.error == nil && response.ok else { - globalCallback(name, result: Result.failure(response.error!), callback: callback) + API.globalCallback(name, result: Result.failure(response.error!), callback: callback) return } - globalCallback(name, result: Result.success(response.result), callback: callback) + API.globalCallback(name, result: Result.success(response.result), callback: callback) } } } From ffa4baccce0dfea61d7d4327b0ee33e7caabb813 Mon Sep 17 00:00:00 2001 From: Victor Tavares-MBP Date: Mon, 17 Jul 2017 11:08:41 -0300 Subject: [PATCH 267/625] fix globalcallbacks (2) --- target_swift_ios.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target_swift_ios.cr b/target_swift_ios.cr index be24ed0..b41e1c1 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -203,7 +203,7 @@ class APIInternal { api.request("https://\\(baseUrl)\\(API.useStaging ? "-staging" : "")/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).responseJSON { response in guard let responseValue = response.result.value else { let error = Error(API.ErrorType.Connection, "Erro de Conexão, tente novamente mais tarde") - API.globalCallback(name, result: Result.failure(error), callback: callback) + API.globalCallback(name, Result.failure(error), callback) return } @@ -211,10 +211,10 @@ class APIInternal { saveDeviceID(response.deviceId) guard response.error == nil && response.ok else { - API.globalCallback(name, result: Result.failure(response.error!), callback: callback) + API.globalCallback(name, Result.failure(response.error!), callback) return } - API.globalCallback(name, result: Result.success(response.result), callback: callback) + API.globalCallback(name, Result.success(response.result), callback: callback) } } } From 12848535289bad470fed9cbe929cfc82b58e0537 Mon Sep 17 00:00:00 2001 From: Victor Tavares-MBP Date: Mon, 17 Jul 2017 11:09:28 -0300 Subject: [PATCH 268/625] Remove "callback" text from globalcallback method. --- target_swift_ios.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_swift_ios.cr b/target_swift_ios.cr index b41e1c1..c5a54ae 100644 --- a/target_swift_ios.cr +++ b/target_swift_ios.cr @@ -214,7 +214,7 @@ class APIInternal { API.globalCallback(name, Result.failure(response.error!), callback) return } - API.globalCallback(name, Result.success(response.result), callback: callback) + API.globalCallback(name, Result.success(response.result), callback) } } } From 94801431072658f4b04e6189dd52817219c17858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Thu, 20 Jul 2017 10:46:26 -0300 Subject: [PATCH 269/625] Fix target ts node server imports --- target_typescript_nodeserver.cr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 28f8026..b555394 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -3,11 +3,11 @@ require "./target_typescript" class TypeScriptServerTarget < TypeScriptTarget def gen @io << <<-END -import http from "http"; -import crypto from "crypto"; -import os from "os"; -import url from "url"; -import moment from "moment"; +import * http from "http"; +import * crypto from "crypto"; +import * os from "os"; +import * url from "url"; +import * moment from "moment"; import r from "../rethinkdb"; let captureError: (e: Error) => void = () => {}; From 129c322d1df6370a769b21b676b4f4c8d68a5c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Thu, 20 Jul 2017 10:48:10 -0300 Subject: [PATCH 270/625] Fix target ts node server imports (from me) --- target_typescript_nodeserver.cr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index b555394..a9df220 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -3,11 +3,11 @@ require "./target_typescript" class TypeScriptServerTarget < TypeScriptTarget def gen @io << <<-END -import * http from "http"; -import * crypto from "crypto"; -import * os from "os"; -import * url from "url"; -import * moment from "moment"; +import * as http from "http"; +import * as crypto from "crypto"; +import * as os from "os"; +import * as url from "url"; +import * as moment from "moment"; import r from "../rethinkdb"; let captureError: (e: Error) => void = () => {}; From 2d322d0ee790097ce80d243755d61dd54e9ec3cd Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 20 Jul 2017 14:40:01 -0300 Subject: [PATCH 271/625] Remove stetho --- target-android/api/build.gradle | 2 -- target_java_android.cr | 10 +++------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/target-android/api/build.gradle b/target-android/api/build.gradle index 2818cb2..890390c 100644 --- a/target-android/api/build.gradle +++ b/target-android/api/build.gradle @@ -23,8 +23,6 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.squareup.okhttp3:okhttp:3.7.0' - compile 'com.facebook.stetho:stetho:1.5.0' - compile 'com.facebook.stetho:stetho-okhttp3:1.5.0' compile 'com.anupcowkur:reservoir:3.1.0' } diff --git a/target_java_android.cr b/target_java_android.cr index 4816cf5..9723dd4 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -26,8 +26,6 @@ import android.view.WindowManager; import com.anupcowkur.reservoir.Reservoir; import com.anupcowkur.reservoir.ReservoirGetCallback; import com.anupcowkur.reservoir.ReservoirPutCallback; -import com.facebook.stetho.Stetho; -import com.facebook.stetho.okhttp3.StethoInterceptor; import org.json.JSONArray; import org.json.JSONException; @@ -163,7 +161,7 @@ END end io << <<-END - } + } }); return; } @@ -183,7 +181,7 @@ END @Override public void onResult(final Error error,final JSONObject result) { callback.onResult(error); - } + } }); @@ -275,7 +273,7 @@ END } public abstract static class Callback extends BaseCallback { - public abstract void onResult(final Error error, final T result); + public abstract void onResult(final Error error, final T result); } public abstract static class VoidCallback extends BaseCallback { @@ -361,14 +359,12 @@ END .connectionPool(connectionPool) .dispatcher(dispatcher) .sslSocketFactory(sslSocketFactory, trustManager) - .addNetworkInterceptor(new StethoInterceptor()) .build(); } static void initialize() { if (initialized) return; initialized = true; - Stetho.initializeWithDefaults(context()); try { Reservoir.init(context(), 10 * 1024 * 1024 /* 10 MB */); } catch (IOException e) { From b152eddb812989bd011e2b0c0c44bbd6eec05ced Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 20 Jul 2017 16:40:03 -0300 Subject: [PATCH 272/625] imports --- target_typescript_nodeserver.cr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index a9df220..28f8026 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -3,11 +3,11 @@ require "./target_typescript" class TypeScriptServerTarget < TypeScriptTarget def gen @io << <<-END -import * as http from "http"; -import * as crypto from "crypto"; -import * as os from "os"; -import * as url from "url"; -import * as moment from "moment"; +import http from "http"; +import crypto from "crypto"; +import os from "os"; +import url from "url"; +import moment from "moment"; import r from "../rethinkdb"; let captureError: (e: Error) => void = () => {}; From e19e35d68a797f0e082b51a09e6cae84bede535b Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Fri, 21 Jul 2017 16:17:30 -0300 Subject: [PATCH 273/625] change timout of client and 'Sem Internet' error msg --- target_java_android.cr | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 4816cf5..8491cdb 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -362,6 +362,7 @@ END .dispatcher(dispatcher) .sslSocketFactory(sslSocketFactory, trustManager) .addNetworkInterceptor(new StethoInterceptor()) + .connectTimeout(5, TimeUnit.MINUTES) .build(); } @@ -627,7 +628,7 @@ END new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { - callback.onResult(new Error() {{type = ErrorType.Connection; message = "Sem Internet";}}, null); + callback.onResult(new Error() {{type = ErrorType.Connection; message = "Erro de conexão, tente novamente mais tarde.";}}, null); } }); return; From f2c76e76d430105dea5ee0e693b1ba0cf3a1913b Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Fri, 21 Jul 2017 16:37:59 -0300 Subject: [PATCH 274/625] remove stetho --- target_java_android.cr | 1 - 1 file changed, 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index a9be1dd..6481daf 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -359,7 +359,6 @@ END .connectionPool(connectionPool) .dispatcher(dispatcher) .sslSocketFactory(sslSocketFactory, trustManager) - .addNetworkInterceptor(new StethoInterceptor()) .connectTimeout(5, TimeUnit.MINUTES) .build(); } From a5a21159a6d40e6f3314cd1cc451ed3d31c24458 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 26 Jul 2017 18:24:05 -0300 Subject: [PATCH 275/625] Fix duplicated variable on android --- target_java.cr | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/target_java.cr b/target_java.cr index 047ba8d..0194e9a 100644 --- a/target_java.cr +++ b/target_java.cr @@ -109,7 +109,7 @@ public static JSONArray toJSONArray(List<#{mangle t.name}> list) { } catch (Exception e) { e.printStackTrace(); } - } + } } return array; } @@ -223,7 +223,9 @@ END when AST::OptionalType "#{obj}.isNull(#{name}) ? null : #{type_from_json(t.base, obj, name)}" when AST::ArrayType - "new #{native_type t}() {{ JSONArray ary = #{obj}.getJSONArray(#{name}); for (int i = 0; i < ary.length(); ++i) add(#{type_from_json(t.base, "ary", "i")}); }}" + i = "i" + SecureRandom.hex[0, 5] + ary = "ary" + SecureRandom.hex[0, 5] + "new #{native_type t}() {{ JSONArray #{ary} = #{obj}.getJSONArray(#{name}); for (int #{i} = 0; #{i} < #{ary}.length(); ++#{i}) add(#{type_from_json(t.base, "#{ary}", "#{i}")}); }}" when AST::StructType "#{mangle t.name}.fromJSON(#{obj}.getJSONObject(#{name}))" when AST::EnumType @@ -250,7 +252,8 @@ END when AST::OptionalType "#{src} == null ? null : #{type_to_json(t.base, src)}" when AST::ArrayType - "new JSONArray() {{ for (#{native_type t.base} el : #{src}) put(#{type_to_json t.base, "el"}); }}" + el = "el" + SecureRandom.hex[0, 5] + "new JSONArray() {{ for (#{native_type t.base} #{el} : #{src}) put(#{type_to_json t.base, "#{el}"}); }}" when AST::StructType "#{src}.toJSON()" when AST::EnumType From 3968b999565efeb2f26ca74fa530f70614050743 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 26 Jul 2017 18:59:06 -0300 Subject: [PATCH 276/625] fix missing require --- target_java.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/target_java.cr b/target_java.cr index 0194e9a..5e9c766 100644 --- a/target_java.cr +++ b/target_java.cr @@ -1,4 +1,5 @@ require "./target" +require "secure_random" abstract class JavaTarget < Target def ident(code) From c4c6d0573aef9e7cfe2ff91073a421b5f61560c9 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 26 Jul 2017 19:08:56 -0300 Subject: [PATCH 277/625] better fix array inside array for java --- target_java.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_java.cr b/target_java.cr index 5e9c766..19d2fb5 100644 --- a/target_java.cr +++ b/target_java.cr @@ -226,7 +226,7 @@ END when AST::ArrayType i = "i" + SecureRandom.hex[0, 5] ary = "ary" + SecureRandom.hex[0, 5] - "new #{native_type t}() {{ JSONArray #{ary} = #{obj}.getJSONArray(#{name}); for (int #{i} = 0; #{i} < #{ary}.length(); ++#{i}) add(#{type_from_json(t.base, "#{ary}", "#{i}")}); }}" + "new #{native_type t}() {{ final JSONArray #{ary} = #{obj}.getJSONArray(#{name}); for (int #{i} = 0; #{i} < #{ary}.length(); ++#{i}) {final int x#{i} = #{i}; add(#{type_from_json(t.base, "#{ary}", "x#{i}")});} }}" when AST::StructType "#{mangle t.name}.fromJSON(#{obj}.getJSONObject(#{name}))" when AST::EnumType @@ -254,7 +254,7 @@ END "#{src} == null ? null : #{type_to_json(t.base, src)}" when AST::ArrayType el = "el" + SecureRandom.hex[0, 5] - "new JSONArray() {{ for (#{native_type t.base} #{el} : #{src}) put(#{type_to_json t.base, "#{el}"}); }}" + "new JSONArray() {{ for (final #{native_type t.base} #{el} : #{src}) put(#{type_to_json t.base, "#{el}"}); }}" when AST::StructType "#{src}.toJSON()" when AST::EnumType From 26fbc7a98a4b7897f53a692a5fc15084985aa340 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 22 Sep 2017 10:37:49 -0300 Subject: [PATCH 278/625] Fix for CORS --- target_typescript_nodeserver.cr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 28f8026..9927818 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -114,6 +114,11 @@ export function start(port: number) { let body = ""; req.on("data", (chunk: any) => body += chunk.toString()); req.on("end", () => { + if (req.method === "OPTIONS") { + res.writeHead(200); + res.end(); + return; + } const ip = req.headers["x-real-ip"] as string || ""; const signature = req.method! + url.parse(req.url || "").pathname; if (httpHandlers[signature]) { From ebfb5cedcb6dea779bfb0dddd028f07b0ac269d8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 22 Sep 2017 10:48:19 -0300 Subject: [PATCH 279/625] import libs --- target-web/package.json | 12 +- target-web/yarn.lock | 296 ++++++++++++++++++++++++---------------- 2 files changed, 184 insertions(+), 124 deletions(-) diff --git a/target-web/package.json b/target-web/package.json index 814059c..edd9f1d 100644 --- a/target-web/package.json +++ b/target-web/package.json @@ -2,11 +2,11 @@ "name": "@cubos/api", "version": "0.0", "dependencies": { - "@types/node": "^7.0.31", - "@types/ua-parser-js": "^0.7.30", - "babel-runtime": "^6.23.0", + "@types/node": "^8.0.29", + "@types/ua-parser-js": "^0.7.32", + "babel-runtime": "^6.26.0", "moment": "^2.17.1", - "ua-parser-js": "^0.7.12" + "ua-parser-js": "^0.7.14" }, "main": "api.js", "types": "api.d.ts", @@ -22,12 +22,12 @@ ] }, "devDependencies": { - "babel-cli": "^6.23.0", + "babel-cli": "^6.26.0", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-es2015": "^6.22.0", "babel-preset-es2016": "^6.22.0", "babel-preset-es2017": "^6.22.0", "json": "^9.0.4", - "typescript": "^2.3.4" + "typescript": "^2.5.2" } } diff --git a/target-web/yarn.lock b/target-web/yarn.lock index 8217821..35c6193 100644 --- a/target-web/yarn.lock +++ b/target-web/yarn.lock @@ -2,13 +2,13 @@ # yarn lockfile v1 -"@types/node@^7.0.31": - version "7.0.31" - resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.31.tgz#80ea4d175599b2a00149c29a10a4eb2dff592e86" +"@types/node@^8.0.29": + version "8.0.29" + resolved "https://npm.cubos.io/@types%2fnode/-/node-8.0.29.tgz#4d6b33df66b15611b40452a581c40d9c94341ba1" -"@types/ua-parser-js@^0.7.30": - version "0.7.30" - resolved "https://npm.cubos.io/@types%2fua-parser-js/-/ua-parser-js-0.7.30.tgz#9096e5552ff02f8d018a17efac69b4dc75083f8b" +"@types/ua-parser-js@^0.7.32": + version "0.7.32" + resolved "https://npm.cubos.io/@types%2fua-parser-js/-/ua-parser-js-0.7.32.tgz#8827d451d6702307248073b5d98aa9293d02b5e5" abbrev@1: version "1.1.0" @@ -54,8 +54,8 @@ arr-diff@^2.0.0: arr-flatten "^1.0.1" arr-flatten@^1.0.1: - version "1.0.3" - resolved "https://npm.cubos.io/arr-flatten/-/arr-flatten-1.0.3.tgz#a274ed85ac08849b6bd7847c4580745dc51adfb1" + version "1.1.0" + resolved "https://npm.cubos.io/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" array-unique@^0.2.1: version "0.2.1" @@ -93,24 +93,24 @@ aws4@^1.2.1: version "1.6.0" resolved "https://npm.cubos.io/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" -babel-cli@^6.23.0: - version "6.24.1" - resolved "https://npm.cubos.io/babel-cli/-/babel-cli-6.24.1.tgz#207cd705bba61489b2ea41b5312341cf6aca2283" +babel-cli@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-cli/-/babel-cli-6.26.0.tgz#502ab54874d7db88ad00b887a06383ce03d002f1" dependencies: - babel-core "^6.24.1" - babel-polyfill "^6.23.0" - babel-register "^6.24.1" - babel-runtime "^6.22.0" - commander "^2.8.1" - convert-source-map "^1.1.0" + babel-core "^6.26.0" + babel-polyfill "^6.26.0" + babel-register "^6.26.0" + babel-runtime "^6.26.0" + commander "^2.11.0" + convert-source-map "^1.5.0" fs-readdir-recursive "^1.0.0" - glob "^7.0.0" - lodash "^4.2.0" - output-file-sync "^1.1.0" - path-is-absolute "^1.0.0" + glob "^7.1.2" + lodash "^4.17.4" + output-file-sync "^1.1.2" + path-is-absolute "^1.0.1" slash "^1.0.0" - source-map "^0.5.0" - v8flags "^2.0.10" + source-map "^0.5.6" + v8flags "^2.1.1" optionalDependencies: chokidar "^1.6.1" @@ -122,41 +122,49 @@ babel-code-frame@^6.22.0: esutils "^2.0.2" js-tokens "^3.0.0" -babel-core@^6.24.1: - version "6.25.0" - resolved "https://npm.cubos.io/babel-core/-/babel-core-6.25.0.tgz#7dd42b0463c742e9d5296deb3ec67a9322dad729" +babel-code-frame@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" dependencies: - babel-code-frame "^6.22.0" - babel-generator "^6.25.0" + chalk "^1.1.3" + esutils "^2.0.2" + js-tokens "^3.0.2" + +babel-core@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-core/-/babel-core-6.26.0.tgz#af32f78b31a6fcef119c87b0fd8d9753f03a0bb8" + dependencies: + babel-code-frame "^6.26.0" + babel-generator "^6.26.0" babel-helpers "^6.24.1" babel-messages "^6.23.0" - babel-register "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.25.0" - babel-traverse "^6.25.0" - babel-types "^6.25.0" - babylon "^6.17.2" - convert-source-map "^1.1.0" - debug "^2.1.1" - json5 "^0.5.0" - lodash "^4.2.0" - minimatch "^3.0.2" - path-is-absolute "^1.0.0" - private "^0.1.6" + babel-register "^6.26.0" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + convert-source-map "^1.5.0" + debug "^2.6.8" + json5 "^0.5.1" + lodash "^4.17.4" + minimatch "^3.0.4" + path-is-absolute "^1.0.1" + private "^0.1.7" slash "^1.0.0" - source-map "^0.5.0" + source-map "^0.5.6" -babel-generator@^6.25.0: - version "6.25.0" - resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.25.0.tgz#33a1af70d5f2890aeb465a4a7793c1df6a9ea9fc" +babel-generator@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.26.0.tgz#ac1ae20070b79f6e3ca1d3269613053774f20dc5" dependencies: babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-types "^6.25.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" detect-indent "^4.0.0" jsesc "^1.3.0" - lodash "^4.2.0" - source-map "^0.5.0" + lodash "^4.17.4" + source-map "^0.5.6" trim-right "^1.0.1" babel-helper-builder-binary-assignment-operator-visitor@^6.24.1: @@ -487,13 +495,13 @@ babel-plugin-transform-strict-mode@^6.24.1: babel-runtime "^6.22.0" babel-types "^6.24.1" -babel-polyfill@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-polyfill/-/babel-polyfill-6.23.0.tgz#8364ca62df8eafb830499f699177466c3b03499d" +babel-polyfill@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153" dependencies: - babel-runtime "^6.22.0" - core-js "^2.4.0" - regenerator-runtime "^0.10.0" + babel-runtime "^6.26.0" + core-js "^2.5.0" + regenerator-runtime "^0.10.5" babel-preset-es2015@^6.22.0: version "6.24.1" @@ -537,26 +545,33 @@ babel-preset-es2017@^6.22.0: babel-plugin-syntax-trailing-function-commas "^6.22.0" babel-plugin-transform-async-to-generator "^6.24.1" -babel-register@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-register/-/babel-register-6.24.1.tgz#7e10e13a2f71065bdfad5a1787ba45bca6ded75f" +babel-register@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071" dependencies: - babel-core "^6.24.1" - babel-runtime "^6.22.0" - core-js "^2.4.0" + babel-core "^6.26.0" + babel-runtime "^6.26.0" + core-js "^2.5.0" home-or-tmp "^2.0.0" - lodash "^4.2.0" + lodash "^4.17.4" mkdirp "^0.5.1" - source-map-support "^0.4.2" + source-map-support "^0.4.15" -babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0: +babel-runtime@^6.18.0, babel-runtime@^6.22.0: version "6.23.0" resolved "https://npm.cubos.io/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b" dependencies: core-js "^2.4.0" regenerator-runtime "^0.10.0" -babel-template@^6.24.1, babel-template@^6.25.0: +babel-runtime@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.11.0" + +babel-template@^6.24.1: version "6.25.0" resolved "https://npm.cubos.io/babel-template/-/babel-template-6.25.0.tgz#665241166b7c2aa4c619d71e192969552b10c071" dependencies: @@ -566,6 +581,16 @@ babel-template@^6.24.1, babel-template@^6.25.0: babylon "^6.17.2" lodash "^4.2.0" +babel-template@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" + dependencies: + babel-runtime "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + lodash "^4.17.4" + babel-traverse@^6.24.1, babel-traverse@^6.25.0: version "6.25.0" resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.25.0.tgz#2257497e2fcd19b89edc13c4c91381f9512496f1" @@ -580,6 +605,20 @@ babel-traverse@^6.24.1, babel-traverse@^6.25.0: invariant "^2.2.0" lodash "^4.2.0" +babel-traverse@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" + dependencies: + babel-code-frame "^6.26.0" + babel-messages "^6.23.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + debug "^2.6.8" + globals "^9.18.0" + invariant "^2.2.2" + lodash "^4.17.4" + babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.25.0: version "6.25.0" resolved "https://npm.cubos.io/babel-types/-/babel-types-6.25.0.tgz#70afb248d5660e5d18f811d91c8303b54134a18e" @@ -589,9 +628,22 @@ babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.25.0: lodash "^4.2.0" to-fast-properties "^1.0.1" +babel-types@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" + dependencies: + babel-runtime "^6.26.0" + esutils "^2.0.2" + lodash "^4.17.4" + to-fast-properties "^1.0.3" + babylon@^6.17.2: - version "6.17.3" - resolved "https://npm.cubos.io/babylon/-/babylon-6.17.3.tgz#1327d709950b558f204e5352587fd0290f8d8e48" + version "6.17.4" + resolved "https://npm.cubos.io/babylon/-/babylon-6.17.4.tgz#3e8b7402b88d22c3423e137a1577883b15ff869a" + +babylon@^6.18.0: + version "6.18.0" + resolved "https://npm.cubos.io/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" balanced-match@^1.0.0: version "1.0.0" @@ -638,7 +690,7 @@ caseless@~0.12.0: version "0.12.0" resolved "https://npm.cubos.io/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" -chalk@^1.1.0: +chalk@^1.1.0, chalk@^1.1.3: version "1.1.3" resolved "https://npm.cubos.io/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" dependencies: @@ -677,11 +729,9 @@ combined-stream@^1.0.5, combined-stream@~1.0.5: dependencies: delayed-stream "~1.0.0" -commander@^2.8.1: - version "2.9.0" - resolved "https://npm.cubos.io/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" - dependencies: - graceful-readlink ">= 1.0.0" +commander@^2.11.0: + version "2.11.0" + resolved "https://npm.cubos.io/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" concat-map@0.0.1: version "0.0.1" @@ -691,7 +741,7 @@ console-control-strings@^1.0.0, console-control-strings@~1.1.0: version "1.1.0" resolved "https://npm.cubos.io/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" -convert-source-map@^1.1.0: +convert-source-map@^1.5.0: version "1.5.0" resolved "https://npm.cubos.io/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" @@ -699,6 +749,10 @@ core-js@^2.4.0: version "2.4.1" resolved "https://npm.cubos.io/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" +core-js@^2.5.0: + version "2.5.1" + resolved "https://npm.cubos.io/core-js/-/core-js-2.5.1.tgz#ae6874dc66937789b80754ff5428df66819ca50b" + core-util-is@~1.0.0: version "1.0.2" resolved "https://npm.cubos.io/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -715,12 +769,18 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" -debug@^2.1.1, debug@^2.2.0: +debug@^2.2.0: version "2.6.8" resolved "https://npm.cubos.io/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" dependencies: ms "2.0.0" +debug@^2.6.8: + version "2.6.9" + resolved "https://npm.cubos.io/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + deep-extend@~0.4.0: version "0.4.2" resolved "https://npm.cubos.io/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" @@ -879,7 +939,7 @@ glob-parent@^2.0.0: dependencies: is-glob "^2.0.0" -glob@^7.0.0, glob@^7.0.5: +glob@^7.0.5, glob@^7.1.2: version "7.1.2" resolved "https://npm.cubos.io/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: @@ -890,7 +950,7 @@ glob@^7.0.0, glob@^7.0.5: once "^1.3.0" path-is-absolute "^1.0.0" -globals@^9.0.0: +globals@^9.0.0, globals@^9.18.0: version "9.18.0" resolved "https://npm.cubos.io/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" @@ -898,10 +958,6 @@ graceful-fs@^4.1.2, graceful-fs@^4.1.4: version "4.1.11" resolved "https://npm.cubos.io/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" -"graceful-readlink@>= 1.0.0": - version "1.0.1" - resolved "https://npm.cubos.io/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" - har-schema@^1.0.5: version "1.0.5" resolved "https://npm.cubos.io/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" @@ -958,7 +1014,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1: +inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.3: version "2.0.3" resolved "https://npm.cubos.io/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" @@ -966,7 +1022,7 @@ ini@~1.3.0: version "1.3.4" resolved "https://npm.cubos.io/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" -invariant@^2.2.0: +invariant@^2.2.0, invariant@^2.2.2: version "2.2.2" resolved "https://npm.cubos.io/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" dependencies: @@ -1056,9 +1112,9 @@ isstream@~0.1.2: version "0.1.2" resolved "https://npm.cubos.io/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" -js-tokens@^3.0.0: - version "3.0.1" - resolved "https://npm.cubos.io/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" +js-tokens@^3.0.0, js-tokens@^3.0.2: + version "3.0.2" + resolved "https://npm.cubos.io/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" jsbn@~0.1.0: version "0.1.1" @@ -1086,7 +1142,7 @@ json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://npm.cubos.io/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" -json5@^0.5.0: +json5@^0.5.1: version "0.5.1" resolved "https://npm.cubos.io/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" @@ -1119,7 +1175,7 @@ kind-of@^4.0.0: dependencies: is-buffer "^1.1.5" -lodash@^4.2.0: +lodash@^4.17.4, lodash@^4.2.0: version "4.17.4" resolved "https://npm.cubos.io/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -1217,8 +1273,8 @@ normalize-path@^2.0.1: remove-trailing-separator "^1.0.1" npmlog@^4.0.2: - version "4.1.0" - resolved "https://npm.cubos.io/npmlog/-/npmlog-4.1.0.tgz#dc59bee85f64f00ed424efb2af0783df25d1c0b5" + version "4.1.2" + resolved "https://npm.cubos.io/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" dependencies: are-we-there-yet "~1.1.2" console-control-strings "~1.1.0" @@ -1265,7 +1321,7 @@ osenv@^0.1.4: os-homedir "^1.0.0" os-tmpdir "^1.0.0" -output-file-sync@^1.1.0: +output-file-sync@^1.1.2: version "1.1.2" resolved "https://npm.cubos.io/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" dependencies: @@ -1282,7 +1338,7 @@ parse-glob@^3.0.4: is-extglob "^1.0.0" is-glob "^2.0.0" -path-is-absolute@^1.0.0: +path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: version "1.0.1" resolved "https://npm.cubos.io/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" @@ -1294,7 +1350,7 @@ preserve@^0.2.0: version "0.2.0" resolved "https://npm.cubos.io/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" -private@^0.1.6: +private@^0.1.6, private@^0.1.7: version "0.1.7" resolved "https://npm.cubos.io/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1" @@ -1327,15 +1383,15 @@ rc@^1.1.7: strip-json-comments "~2.0.1" readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.4: - version "2.2.11" - resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.11.tgz#0796b31f8d7688007ff0b93a8088d34aa17c0f72" + version "2.3.3" + resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" dependencies: core-util-is "~1.0.0" - inherits "~2.0.1" + inherits "~2.0.3" isarray "~1.0.0" process-nextick-args "~1.0.6" - safe-buffer "~5.0.1" - string_decoder "~1.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.0.3" util-deprecate "~1.0.1" readdirp@^2.0.0: @@ -1351,10 +1407,14 @@ regenerate@^1.2.1: version "1.3.2" resolved "https://npm.cubos.io/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" -regenerator-runtime@^0.10.0: +regenerator-runtime@^0.10.0, regenerator-runtime@^0.10.5: version "0.10.5" resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" +regenerator-runtime@^0.11.0: + version "0.11.0" + resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz#7e54fe5b5ccd5d6624ea6255c3473be090b802e1" + regenerator-transform@0.9.11: version "0.9.11" resolved "https://npm.cubos.io/regenerator-transform/-/regenerator-transform-0.9.11.tgz#3a7d067520cb7b7176769eb5ff868691befe1283" @@ -1439,9 +1499,9 @@ rimraf@2, rimraf@^2.5.1, rimraf@^2.6.1: dependencies: glob "^7.0.5" -safe-buffer@^5.0.1, safe-buffer@~5.0.1: - version "5.0.1" - resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" +safe-buffer@^5.0.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.1" + resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" semver@^5.3.0: version "5.3.0" @@ -1469,13 +1529,13 @@ sntp@1.x.x: dependencies: hoek "2.x.x" -source-map-support@^0.4.2: - version "0.4.15" - resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.15.tgz#03202df65c06d2bd8c7ec2362a193056fef8d3b1" +source-map-support@^0.4.15: + version "0.4.18" + resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" dependencies: source-map "^0.5.6" -source-map@^0.5.0, source-map@^0.5.6: +source-map@^0.5.6: version "0.5.6" resolved "https://npm.cubos.io/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" @@ -1501,11 +1561,11 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string_decoder@~1.0.0: - version "1.0.2" - resolved "https://npm.cubos.io/string_decoder/-/string_decoder-1.0.2.tgz#b29e1f4e1125fa97a10382b8a533737b7491e179" +string_decoder@~1.0.3: + version "1.0.3" + resolved "https://npm.cubos.io/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" dependencies: - safe-buffer "~5.0.1" + safe-buffer "~5.1.0" stringstream@~0.0.4: version "0.0.5" @@ -1546,7 +1606,7 @@ tar@^2.2.1: fstream "^1.0.2" inherits "2" -to-fast-properties@^1.0.1: +to-fast-properties@^1.0.1, to-fast-properties@^1.0.3: version "1.0.3" resolved "https://npm.cubos.io/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" @@ -1570,13 +1630,13 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://npm.cubos.io/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" -typescript@^2.3.4: - version "2.4.0" - resolved "https://npm.cubos.io/typescript/-/typescript-2.4.0.tgz#aef5a8d404beba36ad339abf079ddddfffba86dd" +typescript@^2.5.2: + version "2.5.2" + resolved "https://npm.cubos.io/typescript/-/typescript-2.5.2.tgz#038a95f7d9bbb420b1bf35ba31d4c5c1dd3ffe34" -ua-parser-js@^0.7.12: - version "0.7.12" - resolved "https://npm.cubos.io/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb" +ua-parser-js@^0.7.14: + version "0.7.14" + resolved "https://npm.cubos.io/ua-parser-js/-/ua-parser-js-0.7.14.tgz#110d53fa4c3f326c121292bbeac904d2e03387ca" uid-number@^0.0.6: version "0.0.6" @@ -1594,7 +1654,7 @@ uuid@^3.0.0: version "3.1.0" resolved "https://npm.cubos.io/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" -v8flags@^2.0.10: +v8flags@^2.1.1: version "2.1.1" resolved "https://npm.cubos.io/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" dependencies: From a66aad3a5639af7b4dfc63d93e6680c4d2e9b146 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Fri, 22 Sep 2017 18:34:05 -0300 Subject: [PATCH 280/625] pass context manually to android target --- target_java_android.cr | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 6481daf..ce5437b 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -310,6 +310,7 @@ END static boolean initialized = false; static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US); + static Application application; static { dateTimeFormat.setTimeZone(TimeZone.getTimeZone("GMT")); @@ -373,22 +374,33 @@ END } } + static void initialize(Application application) { + if (application != null) { + this.application = application; + } + initialize(); + } + static Context context() { - try { - Class activityThreadClass = - Class.forName("android.app.ActivityThread"); - Method method = activityThreadClass.getMethod("currentApplication"); - Application app = (Application)method.invoke(null, (Object[]) null); - if (app == null) { - if (API.serviceContext != null) - return API.serviceContext; - else - throw new RuntimeException("Failed to get Application, use API.serviceContext to provide a Context"); + if (this.application == null) { + try { + Class activityThreadClass = + Class.forName("android.app.ActivityThread"); + Method method = activityThreadClass.getMethod("currentApplication"); + Application app = (Application)method.invoke(null, (Object[]) null); + if (app == null) { + if (API.serviceContext != null) + return API.serviceContext; + else + throw new RuntimeException("Failed to get Application, use API.serviceContext to provide a Context"); + } + return app; + } catch (ClassNotFoundException | NoSuchMethodException | + IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException("Failed to get application from android.app.ActivityThread"); } - return app; - } catch (ClassNotFoundException | NoSuchMethodException | - IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { - throw new RuntimeException("Failed to get application from android.app.ActivityThread"); + } else { + return this.application; } } From 6a391e0d453c9f158f31d6d0c96c112a0d35d21b Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Fri, 22 Sep 2017 18:49:52 -0300 Subject: [PATCH 281/625] pass context manually to android target 2 --- target_java_android.cr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index ce5437b..fcdffb3 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -374,15 +374,15 @@ END } } - static void initialize(Application application) { - if (application != null) { - this.application = application; + static void initialize(Application app) { + if (app != null) { + this.application = app; } initialize(); } static Context context() { - if (this.application == null) { + if (application == null) { try { Class activityThreadClass = Class.forName("android.app.ActivityThread"); @@ -400,7 +400,7 @@ END throw new RuntimeException("Failed to get application from android.app.ActivityThread"); } } else { - return this.application; + return application; } } From 8e2bdd379b9b3073201825e9c1f6c55d23be9325 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Fri, 22 Sep 2017 19:02:58 -0300 Subject: [PATCH 282/625] pass context manually to android target 2 --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index fcdffb3..48abe31 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -376,7 +376,7 @@ END static void initialize(Application app) { if (app != null) { - this.application = app; + application = app; } initialize(); } From 58ccb742ddcb7fbab8dea4a528b1cb7e488f80bb Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Mon, 25 Sep 2017 12:55:48 -0300 Subject: [PATCH 283/625] init method android target --- target_java_android.cr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target_java_android.cr b/target_java_android.cr index 48abe31..d327062 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -81,6 +81,7 @@ public class API { public void onResult(final String method, final Error error, final JSONObject result, final Callback callback); }; + static public Application application; static public boolean useStaging = false; static public Context serviceContext = null; static public GlobalRequestCallback globalCallback = new GlobalRequestCallback() { @@ -90,6 +91,10 @@ public class API { } }; + static public void initialize(Application application) { + Internal.initialize(application); + } + static public int Default = 0; static public int Loading = 1; static public int Cache = 2; From 33ef8288fcef0b998458c7edd40e1279b4a553de Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Mon, 25 Sep 2017 17:56:43 -0300 Subject: [PATCH 284/625] init method android target --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index d327062..8e433e6 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -380,7 +380,7 @@ END } static void initialize(Application app) { - if (app != null) { + if (app == null) { application = app; } initialize(); From dcdfbf02678ab5ea15d16523fc0202fbcf5e30f6 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Mon, 25 Sep 2017 18:20:21 -0300 Subject: [PATCH 285/625] init method android target --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 8e433e6..79b067a 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -380,7 +380,7 @@ END } static void initialize(Application app) { - if (app == null) { + if (application == null && app != null) { application = app; } initialize(); From ced5be22075419d044df277fb66ebac8beed6d71 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Mon, 25 Sep 2017 19:36:10 -0300 Subject: [PATCH 286/625] create calls interface - making android target testable - --- target_java_android.cr | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/target_java_android.cr b/target_java_android.cr index 79b067a..c88e0c7 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -101,6 +101,25 @@ public class API { END +#CREATING API'S CALLS INTERFACE +@io << <<-END +public interface APICalls { + +END + + @ast.operations.each do |op| + args = op.args.map {|arg| "final #{native_type arg.type} #{mangle arg.name}" } + args << "final #{callback_type op.return_type} callback" + @io << indent(String.build do |io| + io << "void #{mangle op.pretty_name}(#{args.join(", ")})\n" + end) + end + +@io << <<-END +} +END +#CREATING API'S CALLS INTERFACE + @ast.struct_types.each do |t| @io << ident generate_struct_type(t) @io << "\n\n" From 31e444d3b0e5d1aedac4caca1ce54f9dfdc3d7d7 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Mon, 25 Sep 2017 19:38:53 -0300 Subject: [PATCH 287/625] create calls interface - making android target testable - --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index c88e0c7..007d2a8 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -110,7 +110,7 @@ END @ast.operations.each do |op| args = op.args.map {|arg| "final #{native_type arg.type} #{mangle arg.name}" } args << "final #{callback_type op.return_type} callback" - @io << indent(String.build do |io| + @io << ident(String.build do |io| io << "void #{mangle op.pretty_name}(#{args.join(", ")})\n" end) end From 60a21ff9f84fc88cb269aaf4fa6c270d194feeb2 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Mon, 25 Sep 2017 19:45:46 -0300 Subject: [PATCH 288/625] create calls interface 2 - making android target testable - --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 007d2a8..5259c23 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -111,7 +111,7 @@ END args = op.args.map {|arg| "final #{native_type arg.type} #{mangle arg.name}" } args << "final #{callback_type op.return_type} callback" @io << ident(String.build do |io| - io << "void #{mangle op.pretty_name}(#{args.join(", ")})\n" + io << "void #{mangle op.pretty_name}(#{args.join(", ")});\n" end) end From 8c9f0e840bf236b43c5cd30ca174356723186ad3 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Tue, 26 Sep 2017 10:24:12 -0300 Subject: [PATCH 289/625] implementing calls interface - making android target testable - --- target_java_android.cr | 47 +++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index 5259c23..a4ebc06 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -60,7 +60,7 @@ import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.TimeUnit; -import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLContext;x import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; @@ -76,7 +76,30 @@ import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; -public class API { +END + +#CREATING API'S CALLS INTERFACE +@io << <<-END +public interface APICalls { + +END + + @ast.operations.each do |op| + args = op.args.map {|arg| "final #{native_type arg.type} #{mangle arg.name}" } + args << "final #{callback_type op.return_type} callback" + @io << ident(String.build do |io| + io << "void #{mangle op.pretty_name}(#{args.join(", ")});\n" + end) + end + +@io << <<-END +} +END +#CREATING API'S CALLS INTERFACE + +@io << <<-END + +public class API implements APICalls { public interface GlobalRequestCallback { public void onResult(final String method, final Error error, final JSONObject result, final Callback callback); }; @@ -101,25 +124,6 @@ public class API { END -#CREATING API'S CALLS INTERFACE -@io << <<-END -public interface APICalls { - -END - - @ast.operations.each do |op| - args = op.args.map {|arg| "final #{native_type arg.type} #{mangle arg.name}" } - args << "final #{callback_type op.return_type} callback" - @io << ident(String.build do |io| - io << "void #{mangle op.pretty_name}(#{args.join(", ")});\n" - end) - end - -@io << <<-END -} -END -#CREATING API'S CALLS INTERFACE - @ast.struct_types.each do |t| @io << ident generate_struct_type(t) @io << "\n\n" @@ -134,6 +138,7 @@ END args = op.args.map {|arg| "final #{native_type arg.type} #{mangle arg.name}" } args << "final #{callback_type op.return_type} callback" @io << ident(String.build do |io| + io << "@Override \n" io << "static public void #{mangle op.pretty_name}(#{args.join(", ")}) {\n" io << " #{mangle op.pretty_name}(#{(op.args.map {|arg| mangle arg.name } + ["0", "callback"]).join(", ")});\n" io << "}" From 1cb569cec2e7af29e5452d226eb7c5c74ee1cf7b Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Tue, 26 Sep 2017 10:32:21 -0300 Subject: [PATCH 290/625] implementing calls interface 2 - making android target testable - --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index a4ebc06..b18d3c0 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -60,7 +60,7 @@ import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.TimeUnit; -import javax.net.ssl.SSLContext;x +import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; From fd06f7a03c3179e84fffd79f53650b759ea3c320 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Tue, 26 Sep 2017 11:42:47 -0300 Subject: [PATCH 291/625] implementing calls interface 3 - making android target testable - --- target_java_android.cr | 57 +++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index b18d3c0..b63d854 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -76,29 +76,6 @@ import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; -END - -#CREATING API'S CALLS INTERFACE -@io << <<-END -public interface APICalls { - -END - - @ast.operations.each do |op| - args = op.args.map {|arg| "final #{native_type arg.type} #{mangle arg.name}" } - args << "final #{callback_type op.return_type} callback" - @io << ident(String.build do |io| - io << "void #{mangle op.pretty_name}(#{args.join(", ")});\n" - end) - end - -@io << <<-END -} -END -#CREATING API'S CALLS INTERFACE - -@io << <<-END - public class API implements APICalls { public interface GlobalRequestCallback { public void onResult(final String method, final Error error, final JSONObject result, final Callback callback); @@ -124,6 +101,25 @@ public class API implements APICalls { END +# INIT CREATING API'S CALLS INTERFACE +@io << <<-END +public interface APICalls { + +END + + @ast.operations.each do |op| + args = op.args.map {|arg| "final #{native_type arg.type} #{mangle arg.name}" } + args << "final #{callback_type op.return_type} callback" + @io << ident(String.build do |io| + io << "void #{mangle op.pretty_name}(#{args.join(", ")});\n" + end) + end + +@io << <<-END +} +END +# END CREATING API'S CALLS INTERFACE + @ast.struct_types.each do |t| @io << ident generate_struct_type(t) @io << "\n\n" @@ -134,6 +130,13 @@ END @io << "\n\n" end +# INIT CREATING CALLS +@io << <<-END + + public static class Calls implements APICalls { + +END + @ast.operations.each do |op| args = op.args.map {|arg| "final #{native_type arg.type} #{mangle arg.name}" } args << "final #{callback_type op.return_type} callback" @@ -286,6 +289,14 @@ END @io << "\n\n" end +@io << <<-END + +} + +END + +# END CREATING CALLS + @io << <<-END public static class Error { public ErrorType type; From 46409e815ad54758b63c0a97ea6e1f8cc435230f Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Tue, 26 Sep 2017 11:58:02 -0300 Subject: [PATCH 292/625] implementing calls interface 4 - making android target testable - --- target_java_android.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target_java_android.cr b/target_java_android.cr index b63d854..208d073 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -111,7 +111,7 @@ END args = op.args.map {|arg| "final #{native_type arg.type} #{mangle arg.name}" } args << "final #{callback_type op.return_type} callback" @io << ident(String.build do |io| - io << "void #{mangle op.pretty_name}(#{args.join(", ")});\n" + io << "public void #{mangle op.pretty_name}(#{args.join(", ")});\n" end) end @@ -142,14 +142,14 @@ END args << "final #{callback_type op.return_type} callback" @io << ident(String.build do |io| io << "@Override \n" - io << "static public void #{mangle op.pretty_name}(#{args.join(", ")}) {\n" + io << "public void #{mangle op.pretty_name}(#{args.join(", ")}) {\n" io << " #{mangle op.pretty_name}(#{(op.args.map {|arg| mangle arg.name } + ["0", "callback"]).join(", ")});\n" io << "}" end) @io << "\n\n" args = args[0..-2] + ["final int flags", args[-1]] @io << ident(String.build do |io| - io << "static public void #{mangle op.pretty_name}(#{args.join(", ")}) {\n" + io << "public void #{mangle op.pretty_name}(#{args.join(", ")}) {\n" io << ident(String.build do |io| if op.args.size == 0 io << "final JSONObject args = new JSONObject();" From b9bcdcf3a7158796030f2d6665976ea032e2aca7 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Tue, 26 Sep 2017 12:18:20 -0300 Subject: [PATCH 293/625] implementing calls interface 5 - making android target testable - --- target_java_android.cr | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 208d073..1da6c8c 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -81,6 +81,7 @@ public class API implements APICalls { public void onResult(final String method, final Error error, final JSONObject result, final Callback callback); }; + static public Calls calls = new Calls(); static public Application application; static public boolean useStaging = false; static public Context serviceContext = null; @@ -325,7 +326,7 @@ END if (pref.contains("deviceId")) callback.onResult(null, pref.getString("deviceId", null)); else { - ping(API.Default, new Callback() { + calls.ping(API.Default, new Callback() { @Override public void onResult(Error error, String result) { if (error != null) From d5b5f21c3f160b88c20b8b8e70c9121fd3c57df2 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Tue, 26 Sep 2017 12:23:44 -0300 Subject: [PATCH 294/625] implementing calls interface 6 - making android target testable - --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 1da6c8c..6d1308d 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -76,7 +76,7 @@ import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; -public class API implements APICalls { +public class API { public interface GlobalRequestCallback { public void onResult(final String method, final Error error, final JSONObject result, final Callback callback); }; From fd6d440075eccf124c229be67f23508e11e309ff Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Tue, 26 Sep 2017 14:14:10 -0300 Subject: [PATCH 295/625] implementing calls abstract class 6 - making android target testable - --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 6d1308d..fa65d67 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -81,7 +81,7 @@ public class API { public void onResult(final String method, final Error error, final JSONObject result, final Callback callback); }; - static public Calls calls = new Calls(); + static public APICalls calls = new Calls(); static public Application application; static public boolean useStaging = false; static public Context serviceContext = null; From 70a3fe122ace3fe12cbc0474dc096281f90bb4f5 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Tue, 26 Sep 2017 14:22:26 -0300 Subject: [PATCH 296/625] implementing calls abstract class 7 - making android target testable - --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index fa65d67..6d1308d 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -81,7 +81,7 @@ public class API { public void onResult(final String method, final Error error, final JSONObject result, final Callback callback); }; - static public APICalls calls = new Calls(); + static public Calls calls = new Calls(); static public Application application; static public boolean useStaging = false; static public Context serviceContext = null; From 9db3d06aec346c523140af1ce82f37ce99d609c6 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Tue, 10 Oct 2017 10:21:28 -0300 Subject: [PATCH 297/625] Loading crash fix --- target_java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index 6d1308d..ac9bacf 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -594,7 +594,7 @@ END new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { - progress[0] = ProgressDialog.show(getCurrentActivity(), "Aguarde", "Carregando...", true, true); + progress[0] = ProgressDialog.show(getCurrentActivity() != null ? getCurrentActivity() : context(), "Aguarde", "Carregando...", true, true); } }); } From a96672cc62600273324faf6a2965f8aeb4262471 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Tue, 10 Oct 2017 10:48:30 -0300 Subject: [PATCH 298/625] undo --- target_java_android.cr | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/target_java_android.cr b/target_java_android.cr index ac9bacf..0fa9e11 100644 --- a/target_java_android.cr +++ b/target_java_android.cr @@ -594,7 +594,10 @@ END new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { - progress[0] = ProgressDialog.show(getCurrentActivity() != null ? getCurrentActivity() : context(), "Aguarde", "Carregando...", true, true); + Activity currentActivity = getCurrentActivity(); + if (currentActivity != null) { + progress[0] = ProgressDialog.show(currentActivity, "Aguarde", "Carregando...", true, true); + } } }); } From 9adb226df0255993411f2cb3819909ca9c2414fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Wed, 18 Oct 2017 22:45:29 -0300 Subject: [PATCH 299/625] First iteration for listeners addition and remotion --- target_typescript_web.cr | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 9211b89..831227c 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -80,6 +80,32 @@ function randomBytesHex(len: number) { return hex; } +interface ListenerTypes { + fail: (e: Error) => void; + fatal: (e: Error) => void; + success: (res: string) => void; +} + +type HookArray = Array; +type Listenables = keyof ListenerTypes; +type ListenersDict = { [k in Listenables]: Array }; + +const listenersDict: ListenersDict = { + fail: [], + fatal: [], + success: [], +}; + +export function addEventListener(listenable: Listenables, hook: ListenerTypes[typeof listenable]) { + const listeners: HookArray = listenersDict[listenable]; + listeners.push(hook); +} + +export function removeEventListener(listenable: Listenables, hook: ListenerTypes[typeof listenable]) { + const listeners: HookArray = listenersDict[listenable]; + listenersDict[listenable] = listeners.filter(h => h !== hook) as any; +} + async function makeRequest({name, args}: {name: string, args: any}) { const deviceData = await device(); return new Promise((resolve, reject) => { @@ -97,12 +123,15 @@ async function makeRequest({name, args}: {name: string, args: any}) { const response = JSON.parse(req.responseText); localStorage.setItem("deviceId", response.deviceId); if (response.ok) { + listenersDict["success"].forEach(hook => hook(response.result)); resolve(response.result); } else { + listenersDict["fail"].forEach(hook => hook(response.error)); reject(response.error); } } catch (e) { console.error(e); + listenersDict["fatal"].forEach(hook => hook(response.error)); reject({type: "Fatal", message: e.toString()}); } }; From f95dc99e905159a8e4fdb51f7a1ccf9b5e91204b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Wed, 18 Oct 2017 23:10:15 -0300 Subject: [PATCH 300/625] Fix --- target_typescript_web.cr | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 9211b89..5a6d314 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -95,15 +95,21 @@ async function makeRequest({name, args}: {name: string, args: any}) { if (req.readyState !== 4) return; try { const response = JSON.parse(req.responseText); - localStorage.setItem("deviceId", response.deviceId); - if (response.ok) { - resolve(response.result); - } else { - reject(response.error); + + try { + localStorage.setItem("deviceId", response.deviceId); + if (response.ok) { + resolve(response.result); + } else { + reject(response.error); + } + } catch (e) { + console.error(e); + reject({type: "Fatal", message: e.toString()}); } } catch (e) { console.error(e); - reject({type: "Fatal", message: e.toString()}); + reject({type: "BadFormattedMessage", message: `Response couldn't be parsed as JSON (${req.responseText}):\\n${e.toString()}`}); } }; req.send(JSON.stringify(body)); From d8b729a5929e63b749290052d5c7914d8532a33d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Wed, 18 Oct 2017 23:13:49 -0300 Subject: [PATCH 301/625] Better error type name --- target_typescript_web.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index ec4cc25..3681395 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -138,7 +138,7 @@ async function makeRequest({name, args}: {name: string, args: any}) { } } catch (e) { console.error(e); - reject({type: "BadFormattedMessage", message: `Response couldn't be parsed as JSON (${req.responseText}):\\n${e.toString()}`}); + reject({type: "BadFormattedResponse", message: `Response couldn't be parsed as JSON (${req.responseText}):\\n${e.toString()}`}); listenersDict["fatal"].forEach(hook => hook(e)); } }; From 2a7675ed3c1227185e10254f00abae7040911014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Wed, 18 Oct 2017 23:48:32 -0300 Subject: [PATCH 302/625] Revert "Better error type name" This reverts commit 7e1e7fd1f4c7bf0928b5465344de29e349c59ca5. --- target_typescript_web.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 3681395..ec4cc25 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -138,7 +138,7 @@ async function makeRequest({name, args}: {name: string, args: any}) { } } catch (e) { console.error(e); - reject({type: "BadFormattedResponse", message: `Response couldn't be parsed as JSON (${req.responseText}):\\n${e.toString()}`}); + reject({type: "BadFormattedMessage", message: `Response couldn't be parsed as JSON (${req.responseText}):\\n${e.toString()}`}); listenersDict["fatal"].forEach(hook => hook(e)); } }; From dedceb57b4093110f10d55a76c42035e52c1d0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Wed, 18 Oct 2017 23:49:15 -0300 Subject: [PATCH 303/625] Revert "First iteration for listeners addition and remotion" This reverts commit 0f084f5d85aa65f520fb313dc7a5a5d977b6037d. --- target_typescript_web.cr | 48 +++++----------------------------------- 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index ec4cc25..9211b89 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -80,32 +80,6 @@ function randomBytesHex(len: number) { return hex; } -interface ListenerTypes { - fail: (e: Error) => void; - fatal: (e: Error) => void; - success: (res: string) => void; -} - -type HookArray = Array; -type Listenables = keyof ListenerTypes; -type ListenersDict = { [k in Listenables]: Array }; - -const listenersDict: ListenersDict = { - fail: [], - fatal: [], - success: [], -}; - -export function addEventListener(listenable: Listenables, hook: ListenerTypes[typeof listenable]) { - const listeners: HookArray = listenersDict[listenable]; - listeners.push(hook); -} - -export function removeEventListener(listenable: Listenables, hook: ListenerTypes[typeof listenable]) { - const listeners: HookArray = listenersDict[listenable]; - listenersDict[listenable] = listeners.filter(h => h !== hook) as any; -} - async function makeRequest({name, args}: {name: string, args: any}) { const deviceData = await device(); return new Promise((resolve, reject) => { @@ -121,25 +95,15 @@ async function makeRequest({name, args}: {name: string, args: any}) { if (req.readyState !== 4) return; try { const response = JSON.parse(req.responseText); - - try { - localStorage.setItem("deviceId", response.deviceId); - if (response.ok) { - resolve(response.result); - listenersDict["success"].forEach(hook => hook(response.result)); - } else { - reject(response.error); - listenersDict["fail"].forEach(hook => hook(response.error)); - } - } catch (e) { - console.error(e); - reject({type: "Fatal", message: e.toString()}); - listenersDict["fatal"].forEach(hook => hook(response.error)); + localStorage.setItem("deviceId", response.deviceId); + if (response.ok) { + resolve(response.result); + } else { + reject(response.error); } } catch (e) { console.error(e); - reject({type: "BadFormattedMessage", message: `Response couldn't be parsed as JSON (${req.responseText}):\\n${e.toString()}`}); - listenersDict["fatal"].forEach(hook => hook(e)); + reject({type: "Fatal", message: e.toString()}); } }; req.send(JSON.stringify(body)); From dba324b7595bf9e0c65cbb96af5e400bb4ec7cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Fri, 20 Oct 2017 11:57:35 -0300 Subject: [PATCH 304/625] Revert "Revert "First iteration for listeners addition and remotion"" This reverts commit fae13ca49df2bd4d42b6b4e76ed9e5c9a76f69f7. --- target_typescript_web.cr | 48 +++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 9211b89..ec4cc25 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -80,6 +80,32 @@ function randomBytesHex(len: number) { return hex; } +interface ListenerTypes { + fail: (e: Error) => void; + fatal: (e: Error) => void; + success: (res: string) => void; +} + +type HookArray = Array; +type Listenables = keyof ListenerTypes; +type ListenersDict = { [k in Listenables]: Array }; + +const listenersDict: ListenersDict = { + fail: [], + fatal: [], + success: [], +}; + +export function addEventListener(listenable: Listenables, hook: ListenerTypes[typeof listenable]) { + const listeners: HookArray = listenersDict[listenable]; + listeners.push(hook); +} + +export function removeEventListener(listenable: Listenables, hook: ListenerTypes[typeof listenable]) { + const listeners: HookArray = listenersDict[listenable]; + listenersDict[listenable] = listeners.filter(h => h !== hook) as any; +} + async function makeRequest({name, args}: {name: string, args: any}) { const deviceData = await device(); return new Promise((resolve, reject) => { @@ -95,15 +121,25 @@ async function makeRequest({name, args}: {name: string, args: any}) { if (req.readyState !== 4) return; try { const response = JSON.parse(req.responseText); - localStorage.setItem("deviceId", response.deviceId); - if (response.ok) { - resolve(response.result); - } else { - reject(response.error); + + try { + localStorage.setItem("deviceId", response.deviceId); + if (response.ok) { + resolve(response.result); + listenersDict["success"].forEach(hook => hook(response.result)); + } else { + reject(response.error); + listenersDict["fail"].forEach(hook => hook(response.error)); + } + } catch (e) { + console.error(e); + reject({type: "Fatal", message: e.toString()}); + listenersDict["fatal"].forEach(hook => hook(response.error)); } } catch (e) { console.error(e); - reject({type: "Fatal", message: e.toString()}); + reject({type: "BadFormattedMessage", message: `Response couldn't be parsed as JSON (${req.responseText}):\\n${e.toString()}`}); + listenersDict["fatal"].forEach(hook => hook(e)); } }; req.send(JSON.stringify(body)); From 7cf5b5b86ad1c000bb9a5fbb24fe372db7447dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Fri, 20 Oct 2017 11:57:43 -0300 Subject: [PATCH 305/625] Revert "Revert "Better error type name"" This reverts commit 8f4f1df7f819e0b3199e1ae60d517adb4ab800b5. --- target_typescript_web.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index ec4cc25..3681395 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -138,7 +138,7 @@ async function makeRequest({name, args}: {name: string, args: any}) { } } catch (e) { console.error(e); - reject({type: "BadFormattedMessage", message: `Response couldn't be parsed as JSON (${req.responseText}):\\n${e.toString()}`}); + reject({type: "BadFormattedResponse", message: `Response couldn't be parsed as JSON (${req.responseText}):\\n${e.toString()}`}); listenersDict["fatal"].forEach(hook => hook(e)); } }; From 72c76a86625700835859499937c3f649bcde8d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Fri, 20 Oct 2017 11:58:34 -0300 Subject: [PATCH 306/625] Fix deployment error by exporting publicly expose declared types --- target_typescript_web.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 3681395..75edf28 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -80,15 +80,15 @@ function randomBytesHex(len: number) { return hex; } -interface ListenerTypes { +export interface ListenerTypes { fail: (e: Error) => void; fatal: (e: Error) => void; success: (res: string) => void; } type HookArray = Array; -type Listenables = keyof ListenerTypes; -type ListenersDict = { [k in Listenables]: Array }; +export type Listenables = keyof ListenerTypes; +export type ListenersDict = { [k in Listenables]: Array }; const listenersDict: ListenersDict = { fail: [], From 6ced238b43a414084777677566244ba8e39731e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Fri, 20 Oct 2017 15:35:10 -0300 Subject: [PATCH 307/625] Remove necessary files from ignore files --- target-web/.dockerignore | 5 +---- target-web/.gitignore | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/target-web/.dockerignore b/target-web/.dockerignore index 868bd46..b512c09 100644 --- a/target-web/.dockerignore +++ b/target-web/.dockerignore @@ -1,4 +1 @@ -node_modules -api.js -api.js.map -api.d.ts \ No newline at end of file +node_modules \ No newline at end of file diff --git a/target-web/.gitignore b/target-web/.gitignore index 868bd46..b512c09 100644 --- a/target-web/.gitignore +++ b/target-web/.gitignore @@ -1,4 +1 @@ -node_modules -api.js -api.js.map -api.d.ts \ No newline at end of file +node_modules \ No newline at end of file From 5a16c3262f21fa2803ee13f3b9e0db1d7c51bab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Fri, 20 Oct 2017 15:44:34 -0300 Subject: [PATCH 308/625] Log the shit all over --- target-web/build_and_publish.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target-web/build_and_publish.sh b/target-web/build_and_publish.sh index 17752f1..4eb8c66 100644 --- a/target-web/build_and_publish.sh +++ b/target-web/build_and_publish.sh @@ -9,6 +9,15 @@ cd /root/stage export PATH=$(npm bin):$PATH json -I -f package.json -e 'this.name="@cubos/'$NAME'"' npm version $VERSION || true +ls +echo "tsc will run" tsc +echo "tsc runned" +ls +echo "babel will run" babel api.js -o api.js +echo "babel runned" +ls +echo "YAY" +cat .gitignore npm publish From 5ddadaebd4d63e2e76bf0933d379e3cd077244b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Fri, 20 Oct 2017 16:17:02 -0300 Subject: [PATCH 309/625] Fail on error + better messages --- target-web/build_and_publish.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/target-web/build_and_publish.sh b/target-web/build_and_publish.sh index 4eb8c66..9e6c781 100644 --- a/target-web/build_and_publish.sh +++ b/target-web/build_and_publish.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -e NAME=$2 VERSION=1.0.$3 @@ -9,15 +10,10 @@ cd /root/stage export PATH=$(npm bin):$PATH json -I -f package.json -e 'this.name="@cubos/'$NAME'"' npm version $VERSION || true -ls -echo "tsc will run" +echo "[tsc] START" tsc -echo "tsc runned" -ls -echo "babel will run" +echo "[tsc] END" +echo "[babel] START" babel api.js -o api.js -echo "babel runned" -ls -echo "YAY" -cat .gitignore +echo "[babel] END" npm publish From a266c666338c819a97168a31acbf349d81be2570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Fri, 20 Oct 2017 17:07:15 -0300 Subject: [PATCH 310/625] Remove type enforcement from makeRequest call result --- target_typescript_web.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index 75edf28..b9caa7f 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -37,7 +37,7 @@ END end @io << " " - @io << "const ret: #{native_type op.return_type} = " unless op.return_type.is_a? AST::VoidPrimitiveType + @io << "const ret = " unless op.return_type.is_a? AST::VoidPrimitiveType @io << "await makeRequest({name: #{op.pretty_name.inspect}, #{op.args.size > 0 ? "args" : "args: {}"}});\n" @io << ident "return " + type_from_json(op.return_type, "ret") + ";" @io << "\n" From ce0ee54b4c6e06d1f382be710b334e417fcb8275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Fri, 20 Oct 2017 17:26:23 -0300 Subject: [PATCH 311/625] Include meta data at API hooks for clarity --- target_typescript_web.cr | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/target_typescript_web.cr b/target_typescript_web.cr index b9caa7f..e4a9475 100644 --- a/target_typescript_web.cr +++ b/target_typescript_web.cr @@ -81,9 +81,9 @@ function randomBytesHex(len: number) { } export interface ListenerTypes { - fail: (e: Error) => void; - fatal: (e: Error) => void; - success: (res: string) => void; + fail: (e: Error, name: string, args: any) => void; + fatal: (e: Error, name: string, args: any) => void; + success: (res: string, name: string, args: any) => void; } type HookArray = Array; @@ -126,20 +126,20 @@ async function makeRequest({name, args}: {name: string, args: any}) { localStorage.setItem("deviceId", response.deviceId); if (response.ok) { resolve(response.result); - listenersDict["success"].forEach(hook => hook(response.result)); + listenersDict["success"].forEach(hook => hook(response.result, name, args)); } else { reject(response.error); - listenersDict["fail"].forEach(hook => hook(response.error)); + listenersDict["fail"].forEach(hook => hook(response.error, name, args)); } } catch (e) { console.error(e); reject({type: "Fatal", message: e.toString()}); - listenersDict["fatal"].forEach(hook => hook(response.error)); + listenersDict["fatal"].forEach(hook => hook(response.error, name, args)); } } catch (e) { console.error(e); reject({type: "BadFormattedResponse", message: `Response couldn't be parsed as JSON (${req.responseText}):\\n${e.toString()}`}); - listenersDict["fatal"].forEach(hook => hook(e)); + listenersDict["fatal"].forEach(hook => hook(e, name, args)); } }; req.send(JSON.stringify(body)); From 30dab2b4a38f0ae3dc19f991dc4db070bc7e16d2 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 11:54:59 -0300 Subject: [PATCH 312/625] Fix ast_to_s so that it can work again --- ast_to_s.cr | 240 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 148 insertions(+), 92 deletions(-) diff --git a/ast_to_s.cr b/ast_to_s.cr index 21c4ce0..c17e0b7 100644 --- a/ast_to_s.cr +++ b/ast_to_s.cr @@ -1,108 +1,164 @@ require "./ast" -class StringPrimitiveType - def to_s - "string" +module AST + class StringPrimitiveType + def to_s(io) + io << "string" + end end -end - -class IntPrimitiveType - def to_s - "int" - end -end - -class UIntPrimitiveType - def to_s - "uint" - end -end - -class FloatPrimitiveType - def to_s - "float" - end -end - -class DatePrimitiveType - def to_s - "date" - end -end - -class DateTimePrimitiveType - def to_s - "datetime" - end -end - -class BoolPrimitiveType - def to_s - "bool" - end -end - -class BytesPrimitiveType - def to_s - "bytes" - end -end - -class VoidPrimitiveType - def to_s - "void" - end -end - -class OptionalType - def to_s - "#{@base.to_s}?" - end -end -class ApiDescription - def to_s - type_definitions.map(&.to_s).join("\n") + "\n" + - operations.map(&.to_s).join("\n") + class IntPrimitiveType + def to_s(io) + io << "int" + end end -end -class Field - def to_s - str = "#{name}: #{type.to_s}" - str += " !secret" if secret - str + class UIntPrimitiveType + def to_s(io) + io << "uint" + end end -end -class TypeDefinition - def to_s - "type #{name} {\n" + - fields.map{|f| " #{f.to_s}\n" }.join + - "}\n" + class FloatPrimitiveType + def to_s(io) + io << "float" + end end -end -class TypeReference - def to_s - name + class DatePrimitiveType + def to_s(io) + io << "date" + end end -end -class GetOperation - def to_s - "get #{name}(#{args.map(&.to_s).join(", ")}): #{return_type.to_s}" + class DateTimePrimitiveType + def to_s(io) + io << "datetime" + end end -end - -class FunctionOperation - def to_s - "function #{name}(#{args.map(&.to_s).join(", ")}): #{return_type.to_s}" - end -end -class SubscribeOperation - def to_s - "subscribe #{name}(#{args.map(&.to_s).join(", ")}): #{return_type.to_s}" + class BoolPrimitiveType + def to_s(io) + io << "bool" + end + end + + class BytesPrimitiveType + def to_s(io) + io << "bytes" + end + end + + class VoidPrimitiveType + def to_s(io) + io << "void" + end + end + + class OptionalType + def to_s(io) + @base.to_s(io) + io << "?" + end + end + + class ArrayType + def to_s(io) + @base.to_s(io) + io << "[]" + end + end + + class ApiDescription + def to_s(io) + type_definitions.each_with_index do |tdef, i| + io << "\n" unless i == 0 + tdef.to_s(io) + io << "\n" + end + io << "\n" if type_definitions.size != 0 && operations.size != 0 + operations.each do |op| + op.to_s(io) + io << "\n" + end + end + end + + class Field + def to_s(io) + io << name << ": " + type.to_s(io) + io << " !secret" if secret + end + end + + class TypeDefinition + def to_s(io) + io << "type " << name << " " + type.to_s(io) + end + end + + class StructType + def to_s(io) + io << "{\n" + fields.each do |field| + io << " " + field.to_s(io) + io << "\n" + end + io << "}" + end + end + + class TypeReference + def to_s(io) + io << name + end + end + + class GetOperation + def to_s(io) + io << "get " << name << "(" + args.each_with_index do |arg, i| + arg.to_s(io) + io << ", " if i != args.size-1 + end + io << ")" + unless return_type.is_a? VoidPrimitiveType + io << ": " + return_type.to_s(io) + end + end + end + + class FunctionOperation + def to_s + io << "function " << name << "(" + args.each_with_index do |arg, i| + arg.to_s(io) + io << ", " if i != args.size-1 + end + io << ")" + unless return_type.is_a? VoidPrimitiveType + io << ": " + return_type.to_s(io) + end + end + end + + class SubscribeOperation + def to_s + io << "subscribe " << name << "(" + args.each_with_index do |arg, i| + arg.to_s(io) + io << ", " if i != args.size-1 + end + io << ")" + unless return_type.is_a? VoidPrimitiveType + io << ": " + return_type.to_s(io) + end + end end end From c632f6cc545d9adc1d2157742e08ab014890d15f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 11:55:30 -0300 Subject: [PATCH 313/625] support parsing pure string not from a file --- lexer.cr | 9 +++++++++ parser.cr | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lexer.cr b/lexer.cr index d54185a..0ab740c 100644 --- a/lexer.cr +++ b/lexer.cr @@ -12,6 +12,15 @@ class Lexer @col = 0 end + def initialize(io : IO) + @filename = "" + @raw = io.gets_to_end + @start = 0 + @pos = 0 + @line = 1 + @col = 0 + end + private def current_char @raw[@pos]? end diff --git a/parser.cr b/parser.cr index e111fa5..081ad10 100644 --- a/parser.cr +++ b/parser.cr @@ -9,7 +9,7 @@ class Parser @lexers = [] of Lexer @token : Token | Nil - def initialize(source : String) + def initialize(source) @lexers << Lexer.new(source) next_token end From 4e54c19961cbb140bc997c9b4415a5d08182db6e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 11:56:08 -0300 Subject: [PATCH 314/625] Move token class to another file, out of lexer --- lexer.cr | 116 +------------------------------------------------------ token.cr | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 114 deletions(-) create mode 100644 token.cr diff --git a/lexer.cr b/lexer.cr index 0ab740c..a984bd3 100644 --- a/lexer.cr +++ b/lexer.cr @@ -1,3 +1,5 @@ +require "./token" + class Lexer property filename : String @@ -193,117 +195,3 @@ class Lexer return make_token(StringLiteralToken.new(contents.to_s)) end end - -class Token - property! filename : String - property! line : Int32 - property! col : Int32 - - def try_ident - self - end - - def location - "#{filename}:#{line}:#{col}" - end -end - -class ImportKeywordToken < Token - def try_ident - IdentifierToken.new("import") - end -end - -class TypeKeywordToken < Token - def try_ident - IdentifierToken.new("type") - end -end - -class EnumKeywordToken < Token - def try_ident - IdentifierToken.new("type") - end -end - -class GetKeywordToken < Token - def try_ident - IdentifierToken.new("get") - end -end - -class FunctionKeywordToken < Token - def try_ident - IdentifierToken.new("function") - end -end - -class SubscribeKeywordToken < Token - def try_ident - IdentifierToken.new("subscribe") - end -end - -class ErrorKeywordToken < Token - def try_ident - IdentifierToken.new("error") - end -end - -class PrimitiveTypeToken < Token - property name : String - def initialize(@name) - end - - def try_ident - IdentifierToken.new(@name) - end -end - -class IdentifierToken < Token - property name : String - def initialize(@name) - end -end - -class GlobalOptionToken < Token - property name : String - def initialize(@name) - end -end - -class StringLiteralToken < Token - property str : String - def initialize(@str) - end -end - -class EqualSymbolToken < Token -end - -class ExclamationMarkSymbolToken < Token -end - -class CurlyOpenSymbolToken < Token -end - -class CurlyCloseSymbolToken < Token -end - -class ParensOpenSymbolToken < Token -end - -class ParensCloseSymbolToken < Token -end - -class ColonSymbolToken < Token -end - -class OptionalSymbolToken < Token -end - -class ArraySymbolToken < Token -end - -class CommaSymbolToken < Token -end \ No newline at end of file diff --git a/token.cr b/token.cr new file mode 100644 index 0000000..3520e29 --- /dev/null +++ b/token.cr @@ -0,0 +1,114 @@ + +class Token + property! filename : String + property! line : Int32 + property! col : Int32 + + def try_ident + self + end + + def location + "#{filename}:#{line}:#{col}" + end +end + +class ImportKeywordToken < Token + def try_ident + IdentifierToken.new("import") + end +end + +class TypeKeywordToken < Token + def try_ident + IdentifierToken.new("type") + end +end + +class EnumKeywordToken < Token + def try_ident + IdentifierToken.new("type") + end +end + +class GetKeywordToken < Token + def try_ident + IdentifierToken.new("get") + end +end + +class FunctionKeywordToken < Token + def try_ident + IdentifierToken.new("function") + end +end + +class SubscribeKeywordToken < Token + def try_ident + IdentifierToken.new("subscribe") + end +end + +class ErrorKeywordToken < Token + def try_ident + IdentifierToken.new("error") + end +end + +class PrimitiveTypeToken < Token + property name : String + def initialize(@name) + end + + def try_ident + IdentifierToken.new(@name) + end +end + +class IdentifierToken < Token + property name : String + def initialize(@name) + end +end + +class GlobalOptionToken < Token + property name : String + def initialize(@name) + end +end + +class StringLiteralToken < Token + property str : String + def initialize(@str) + end +end + +class EqualSymbolToken < Token +end + +class ExclamationMarkSymbolToken < Token +end + +class CurlyOpenSymbolToken < Token +end + +class CurlyCloseSymbolToken < Token +end + +class ParensOpenSymbolToken < Token +end + +class ParensCloseSymbolToken < Token +end + +class ColonSymbolToken < Token +end + +class OptionalSymbolToken < Token +end + +class ArraySymbolToken < Token +end + +class CommaSymbolToken < Token +end \ No newline at end of file From e6d9d97b24da72312d9b8faa6ef0fcdb338d4007 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 12:02:44 -0300 Subject: [PATCH 315/625] Add (failing due to a bug) spec --- Dockerfile | 1 + spec/parser_spec.cr | 51 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 spec/parser_spec.cr diff --git a/Dockerfile b/Dockerfile index 5f45474..ae2f2d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,5 +2,6 @@ FROM crystallang/crystal CMD ["bash"] WORKDIR /root ADD *.cr /tmp/ +RUN crystal spec RUN crystal build /tmp/main.cr -o sdkgen2 && rm /tmp/*.cr RUN cp sdkgen2 /usr/bin \ No newline at end of file diff --git a/spec/parser_spec.cr b/spec/parser_spec.cr new file mode 100644 index 0000000..f7f2215 --- /dev/null +++ b/spec/parser_spec.cr @@ -0,0 +1,51 @@ +require "spec" +require "../lexer" +require "../parser" +require "../ast_to_s" + +def clear(code) + code = code.strip + code = code.gsub /\/\/.*/, "" + code = code.gsub /\n\s+/, "\n" + code = code.gsub /\n+/, "\n" + code +end + +def check_parses(code) + parser = Parser.new(IO::Memory.new(code)) + ast = parser.parse + clear(ast.to_s).should eq clear(code) +end + +describe Parser do + {% for p in %w[string int uint date datetime bytes float bool] %} + it "handles primitive type '#{{{p}}}'" do + check_parses <<-END + type Foo { + foo: #{{{p}}} + } + END + end + {% end %} + + {% for kw in %w[string int uint date datetime bytes float bool type get function enum import error void] %} + it "handles '#{{{kw}}}' on the name of a field" do + check_parses <<-END + type Foo { + #{{{kw}}}: int + } + END + end + {% end %} + + it "handles arrays and optionals" do + check_parses <<-END + type Foo { + aa: string[] + bbb: int?[]?? + cccc: int[][][] + ddddd: uint[][][]??[]???[][] + } + END + end +end From 1c55ce571a8fffe3f2e1e6dcf02994b0275b46cc Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 12:04:40 -0300 Subject: [PATCH 316/625] Fix build errors --- target_typescript.cr | 2 +- target_typescript_nodeserver.cr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target_typescript.cr b/target_typescript.cr index 5e059fe..ed9fe58 100644 --- a/target_typescript.cr +++ b/target_typescript.cr @@ -61,7 +61,7 @@ abstract class TypeScriptTarget < Target def operation_args(op : AST::Operation) args = op.args.map {|arg| "#{arg.name}: #{native_type arg.type}" } - if op.is_a? SubscribeOperation + if op.is_a? AST::SubscribeOperation args << "callback: (result: #{native_type op.return_type}) => null" end diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 9927818..4ad0a18 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -305,7 +305,7 @@ END def operation_args(op : AST::Operation) args = ["ctx: Context"] + op.args.map {|arg| "#{arg.name}: #{native_type arg.type}" } - if op.is_a? SubscribeOperation + if op.is_a? AST::SubscribeOperation args << "callback: (result: #{native_type op.return_type}) => void" end From bf5153c5d1d5cc2152fe8b14f1c12492931a8f6f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 12:06:27 -0300 Subject: [PATCH 317/625] Fix Dockerfile for spec --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ae2f2d3..c7abe8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM crystallang/crystal CMD ["bash"] -WORKDIR /root ADD *.cr /tmp/ +WORKDIR /tmp RUN crystal spec +WORKDIR /root RUN crystal build /tmp/main.cr -o sdkgen2 && rm /tmp/*.cr RUN cp sdkgen2 /usr/bin \ No newline at end of file From d1993b545d9b84f1be07485985e8267c1537a765 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 12:08:49 -0300 Subject: [PATCH 318/625] Add everything on dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c7abe8c..8f5b337 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ FROM crystallang/crystal CMD ["bash"] -ADD *.cr /tmp/ +ADD . /tmp/ WORKDIR /tmp RUN crystal spec WORKDIR /root -RUN crystal build /tmp/main.cr -o sdkgen2 && rm /tmp/*.cr +RUN crystal build /tmp/main.cr -o sdkgen2 RUN cp sdkgen2 /usr/bin \ No newline at end of file From 0fc68b15bc61d0af8af2fa5f9b28b5502dbce44c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 12:10:51 -0300 Subject: [PATCH 319/625] Fix the bug identified by the spec --- token.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/token.cr b/token.cr index 3520e29..bdcd1c3 100644 --- a/token.cr +++ b/token.cr @@ -27,7 +27,7 @@ end class EnumKeywordToken < Token def try_ident - IdentifierToken.new("type") + IdentifierToken.new("enum") end end From 22a40384d250882e384874130c3433ffb4c7dddf Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 12:22:00 -0300 Subject: [PATCH 320/625] Add more tests about error and getters --- ast_to_s.cr | 5 ++++- spec/parser_spec.cr | 24 ++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ast_to_s.cr b/ast_to_s.cr index c17e0b7..6cb0e28 100644 --- a/ast_to_s.cr +++ b/ast_to_s.cr @@ -71,8 +71,11 @@ module AST class ApiDescription def to_s(io) + errors.each do |err| + io << "error " << err << "\n" + end + io << "\n" if errors.size != 0 && type_definitions.size != 0 type_definitions.each_with_index do |tdef, i| - io << "\n" unless i == 0 tdef.to_s(io) io << "\n" end diff --git a/spec/parser_spec.cr b/spec/parser_spec.cr index f7f2215..756ec0a 100644 --- a/spec/parser_spec.cr +++ b/spec/parser_spec.cr @@ -17,8 +17,10 @@ def check_parses(code) clear(ast.to_s).should eq clear(code) end +PRIMITIVES = %w[string int uint date datetime bytes float bool] describe Parser do - {% for p in %w[string int uint date datetime bytes float bool] %} + + {% for p in PRIMITIVES %} it "handles primitive type '#{{{p}}}'" do check_parses <<-END type Foo { @@ -28,7 +30,7 @@ describe Parser do end {% end %} - {% for kw in %w[string int uint date datetime bytes float bool type get function enum import error void] %} + {% for kw in PRIMITIVES + %w[type get function enum import error void] %} it "handles '#{{{kw}}}' on the name of a field" do check_parses <<-END type Foo { @@ -48,4 +50,22 @@ describe Parser do } END end + + it "handles errors" do + check_parses <<-END + error Foo + error Bar + error FooBar + END + end + + it "handles simple get operations" do + PRIMITIVES.each do |primitive| + check_parses <<-END + get foo(): #{primitive} + get bar(): #{primitive}? + get baz(): #{primitive}[] + END + end + end end From fabd03a65b535edf86e5d1b90e43703eddcf4b6e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 12:30:05 -0300 Subject: [PATCH 321/625] Add more spec, including options --- ast_to_s.cr | 8 ++++++++ spec/parser_spec.cr | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/ast_to_s.cr b/ast_to_s.cr index 6cb0e28..34d184a 100644 --- a/ast_to_s.cr +++ b/ast_to_s.cr @@ -71,6 +71,14 @@ module AST class ApiDescription def to_s(io) + anyopt = false + if options.url != "" + io << "$url = " + options.url.inspect(io) + io << "\n" + anyop = true + end + io << "\n" if anyop && errors.size != 0 errors.each do |err| io << "error " << err << "\n" end diff --git a/spec/parser_spec.cr b/spec/parser_spec.cr index 756ec0a..57a9922 100644 --- a/spec/parser_spec.cr +++ b/spec/parser_spec.cr @@ -68,4 +68,26 @@ describe Parser do END end end + + it "handles options on the top" do + check_parses <<-END + $url = "api.cubos.io/sdkgenspec" + END + end + + it "handles combinations of all parts" do + check_parses <<-END + $url = "api.cubos.io/sdkgenspec" + + error Foo + error Bar + + type Baz { + a: string? + b: int + } + + get baz(): Baz + END + end end From 6b8688b4ff74af4e152bedafa9a4e06e9d1a2b00 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 18:59:45 -0300 Subject: [PATCH 322/625] Fully rewrite Lexer (using TDD!) --- lexer.cr | 298 +++++++++++++++++++++------------------------ parser.cr | 11 +- spec/lexer_spec.cr | 235 +++++++++++++++++++++++++++++++++++ token.cr | 26 +++- 4 files changed, 405 insertions(+), 165 deletions(-) create mode 100644 spec/lexer_spec.cr diff --git a/lexer.cr b/lexer.cr index a984bd3..7361ba4 100644 --- a/lexer.cr +++ b/lexer.cr @@ -6,192 +6,170 @@ class Lexer class LexerException < Exception end - def initialize(@filename : String) - @raw = File.read(filename) - @start = 0 - @pos = 0 - @line = 1 - @col = 0 + @start_pos = 0 + @start_line = 1 + @start_column = 1 + @line = 1 + @column = 1 + + def initialize(string : String, filename : String? = nil) + @filename = filename || "-" + @reader = Char::Reader.new(string) end - def initialize(io : IO) - @filename = "" - @raw = io.gets_to_end - @start = 0 - @pos = 0 - @line = 1 - @col = 0 + private def pos + @reader.pos end private def current_char - @raw[@pos]? - end - - private def current_char! - @raw[@pos] - end - - private def peek_next_char - @raw[@pos+1]? + @reader.current_char end private def next_char - @pos += 1 - current_char + @reader.next_char + @column += 1 + @reader.current_char end - def next_token - skip - start_token - - return nil unless current_char - - return make_token(CurlyOpenSymbolToken.new) if literal_match("{") - return make_token(CurlyCloseSymbolToken.new) if literal_match("}") - return make_token(ParensOpenSymbolToken.new) if literal_match("(") - return make_token(ParensCloseSymbolToken.new) if literal_match(")") - return make_token(OptionalSymbolToken.new) if literal_match("?") - return make_token(ArraySymbolToken.new) if literal_match("[]") - return make_token(ColonSymbolToken.new) if literal_match(":") - return make_token(ExclamationMarkSymbolToken.new) if literal_match("!") - return make_token(CommaSymbolToken.new) if literal_match(",") - return make_token(EqualSymbolToken.new) if literal_match("=") - - return make_token(ImportKeywordToken.new) if word_match("import") - return make_token(TypeKeywordToken.new) if word_match("type") - return make_token(EnumKeywordToken.new) if word_match("enum") - return make_token(GetKeywordToken.new) if word_match("get") - return make_token(FunctionKeywordToken.new) if word_match("function") - return make_token(SubscribeKeywordToken.new) if word_match("subscribe") - return make_token(ErrorKeywordToken.new) if word_match("error") - return make_token(PrimitiveTypeToken.new("bool")) if word_match("bool") - return make_token(PrimitiveTypeToken.new("int")) if word_match("int") - return make_token(PrimitiveTypeToken.new("uint")) if word_match("uint") - return make_token(PrimitiveTypeToken.new("float")) if word_match("float") - return make_token(PrimitiveTypeToken.new("string")) if word_match("string") - return make_token(PrimitiveTypeToken.new("datetime")) if word_match("datetime") - return make_token(PrimitiveTypeToken.new("date")) if word_match("date") - return make_token(PrimitiveTypeToken.new("bytes")) if word_match("bytes") - return make_token(PrimitiveTypeToken.new("void")) if word_match("void") - - if current_char!.letter? - while current_char && (current_char!.letter? || current_char!.number?) - next_char + private def substring(start_pos, end_pos) + reader = Char::Reader.new(@reader.string) + reader.pos = start_pos + String.build do |io| + while reader.pos <= end_pos + io << reader.current_char + reader.next_char end - return make_token(IdentifierToken.new(@raw[@start...@pos])) end + end - if current_char! == '$' + def next_token + @start_pos = @reader.pos + @start_line = @line + @start_column = @column + token = nil + + case current_char + when '\0' + return nil + when ' ', '\n' next_char - while current_char && (current_char!.letter? || current_char!.number?) - next_char + return next_token + when '/' + case next_char + when '/' + while true + case next_char + when '\0' + return nil + when '\n' + next_char + return next_token + end + end end - return make_token(GlobalOptionToken.new(@raw[@start+1...@pos])) - end - - if current_char! == '"' - return string_match - end - - until [' ', '\t', '\r', '\n'].includes? current_char + when '{' next_char - end - - raise LexerException.new("Invalid token at #{@filename}:#{@line}:#{@col}: \"#{@raw[@start...@pos]}\"") - end - - private def skip - while true - if [' ', '\t', '\r', '\n'].includes? current_char + token = CurlyOpenSymbolToken.new + when '}' + next_char + token = CurlyCloseSymbolToken.new + when '(' + next_char + token = ParensOpenSymbolToken.new + when ')' + next_char + token = ParensCloseSymbolToken.new + when '?' + next_char + token = OptionalSymbolToken.new + when ':' + next_char + token = ColonSymbolToken.new + when '!' + next_char + token = ExclamationMarkSymbolToken.new + when ',' + next_char + token = CommaSymbolToken.new + when '=' + next_char + token = EqualSymbolToken.new + when '[' + case next_char + when ']' next_char - next + token = ArraySymbolToken.new end - - if current_char == '/' && peek_next_char == '/' - while true - break if next_char == '\n' + when '$' + next_char + if current_char.ascii_letter? + while current_char.ascii_letter? || current_char.ascii_number? + next_char end - next_char - next - end - - break - end - end - - private def start_token - while @start < @pos - if @raw[@start] == '\n' - @line += 1 - @col = 0 - else - @col += 1 - end - @start += 1 - end - end - - private def make_token(token) - token.filename = @filename - token.line = @line - token.col = @col - token - end - - private def literal_match(str : String) - str.each_char.with_index.each do |c, i| - return false unless @raw[@pos+i]? == c - end - - @pos += str.size - end - - private def word_match(str : String) - after = @raw[@pos+str.size]? - return false if after && after.letter? - return literal_match(str) - end - private def string_match - unless current_char != "\"" - raise LexerException.new("BUG: Expected string start here") - end - - next_char - contents = String::Builder.new; - while true - c = current_char - unless c - raise LexerException.new("Unexpected end of input inside string literal at #{@filename}:#{@line}:#{@col}") + token = GlobalOptionToken.new(substring(@start_pos+1, pos-1)) end - if c == '"' - next_char - break - end - if c == '\\' - next_char - case current_char - when 'n' - contents << '\n' - when 'r' - contents << '\r' - when 't' - contents << '\t' - when '"' - contents << '"' + when '"' + builder = String::Builder.new + while true + case next_char + when '\0' + break when '\\' - contents << '\\' - when nil - raise LexerException.new("Unexpected end of input on escape sequence inside string literal at #{@filename}:#{@line}:#{@col}") + case next_char + when '\0' + break + when 'n'; builder << '\n' + when 't'; builder << '\t' + when '"'; builder << '"' + when '\\'; builder << '\\' + else + builder << current_char + end + when '"' + next_char + token = StringLiteralToken.new(builder.to_s) + break else - contents << current_char! + builder << current_char end + end + else + if current_char.ascii_letter? next_char - next + while current_char.ascii_letter? || current_char.ascii_number? + next_char + end + + str = substring(@start_pos, pos-1) + + token = case str + when "error"; ErrorKeywordToken.new + when "enum"; EnumKeywordToken.new + when "type"; TypeKeywordToken.new + when "import"; ImportKeywordToken.new + when "get"; GetKeywordToken.new + when "function"; FunctionKeywordToken.new + when "subscribe"; SubscribeKeywordToken.new + when "bool", "int", "uint", "float", "string", "date", "datetime", "bytes", "void" + PrimitiveTypeToken.new(str) + else + IdentifierToken.new(str) + end + end + end + + if token + token.filename = @filename + token.line = @start_line + token.column = @start_column + return token + else + if current_char != '\0' + raise LexerException.new("Unexpected character #{current_char.inspect} at #{@filename}:#{@line}:#{@column}") + else + raise LexerException.new("Unexpected end of file at #{@filename}") end - contents << c - next_char end - return make_token(StringLiteralToken.new(contents.to_s)) end end diff --git a/parser.cr b/parser.cr index 081ad10..4965775 100644 --- a/parser.cr +++ b/parser.cr @@ -9,8 +9,13 @@ class Parser @lexers = [] of Lexer @token : Token | Nil - def initialize(source) - @lexers << Lexer.new(source) + def initialize(filename : String) + @lexers << Lexer.new(File.read(filename), filename) + next_token + end + + def initialize(io : IO) + @lexers << Lexer.new(io.gets_to_end) next_token end @@ -37,7 +42,7 @@ class Parser next_token token = expect StringLiteralToken source = File.expand_path(token.str + ".sdkgen", File.dirname(current_source.not_nil!)) - @lexers << Lexer.new(source) + @lexers << Lexer.new(File.read(source), source) next_token when TypeKeywordToken api.type_definitions << parse_type_definition diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr new file mode 100644 index 0000000..7be106d --- /dev/null +++ b/spec/lexer_spec.cr @@ -0,0 +1,235 @@ +require "spec" +require "../lexer" + +describe Lexer do + it_lexes "", [] of Token + + it_lexes "type", [ + TypeKeywordToken.new + ] + + it_doesnt_lex "23", "Unexpected character '2' at -:1:1" + + it_lexes "type", [ + IdentifierToken.new("type") + ] + + it_lexes "type2", [ + IdentifierToken.new("type2") + ] + + it_lexes "aaa", [ + IdentifierToken.new("aaa") + ] + + it_lexes "a b c", [ + IdentifierToken.new("a"), + IdentifierToken.new("b"), + IdentifierToken.new("c"), + ] + + it_doesnt_lex "aa_bb", "Unexpected character '_' at -:1:3" + + it_lexes "type type", [ + TypeKeywordToken.new, + TypeKeywordToken.new + ] + + it_lexes "enum", [ + EnumKeywordToken.new + ] + + it_lexes "error", [ + ErrorKeywordToken.new + ] + + it_lexes "import", [ + ImportKeywordToken.new + ] + + it_lexes "get", [ + GetKeywordToken.new + ] + + it_lexes "Get", [ + IdentifierToken.new("Get") + ] + + it_lexes "function", [ + FunctionKeywordToken.new + ] + + it_lexes "subscribe", [ + SubscribeKeywordToken.new + ] + + it_lexes "enuma", [ + IdentifierToken.new("enuma") + ] + + it_lexes "errorh", [ + IdentifierToken.new("errorh") + ] + + %w[string int uint date datetime bytes float bool void].each do |primitive| + it_lexes primitive, [ + PrimitiveTypeToken.new(primitive) + ] + + it_lexes primitive + "a", [ + IdentifierToken.new(primitive + "a") + ] + end + + it_lexes "err", [ + IdentifierToken.new("err") + ] + + it_lexes "{", [ + CurlyOpenSymbolToken.new + ] + + it_lexes "{{", [ + CurlyOpenSymbolToken.new, + CurlyOpenSymbolToken.new + ] + + it_lexes "}{", [ + CurlyCloseSymbolToken.new, + CurlyOpenSymbolToken.new + ] + + it_lexes " } { ", [ + CurlyCloseSymbolToken.new, + CurlyOpenSymbolToken.new + ] + + it_lexes "({!:?,=})", [ + ParensOpenSymbolToken.new, + CurlyOpenSymbolToken.new, + ExclamationMarkSymbolToken.new, + ColonSymbolToken.new, + OptionalSymbolToken.new, + CommaSymbolToken.new, + EqualSymbolToken.new, + CurlyCloseSymbolToken.new, + ParensCloseSymbolToken.new + ] + + it_lexes " [][] ", [ + ArraySymbolToken.new, + ArraySymbolToken.new + ] + + it_lexes "nice[]", [ + IdentifierToken.new("nice"), + ArraySymbolToken.new + ] + + it_lexes "nice\n[]", [ + IdentifierToken.new("nice"), + ArraySymbolToken.new + ] + + it_doesnt_lex "[", "Unexpected end of file" + + it_lexes "type Str string", [ + TypeKeywordToken.new, + IdentifierToken.new("Str"), + PrimitiveTypeToken.new("string") + ] + + it_lexes "$url", [ + GlobalOptionToken.new("url") + ] + + it_lexes "$F", [ + GlobalOptionToken.new("F") + ] + + it_lexes "$x123", [ + GlobalOptionToken.new("x123") + ] + + it_lexes "$ah[]?", [ + GlobalOptionToken.new("ah"), + ArraySymbolToken.new, + OptionalSymbolToken.new + ] + + it_doesnt_lex "$", "Unexpected end of file" + + it_doesnt_lex "$_a", "Unexpected character '_'" + + it_doesnt_lex "$ a", "Unexpected character ' '" + + it_lexes "\"ab\"", [ + StringLiteralToken.new("ab") + ] + + it_lexes "\"\"", [ + StringLiteralToken.new("") + ] + + it_lexes "\"aa\\nbb\"", [ + StringLiteralToken.new("aa\nbb") + ] + + it_lexes "\"aa\\bb\"", [ + StringLiteralToken.new("aabb") + ] + + it_lexes "\"'\"", [ + StringLiteralToken.new("'") + ] + + it_lexes "\"\\n\\t\\\"\"", [ + StringLiteralToken.new("\n\t\"") + ] + + it_lexes "//hmmm", [] of Token + + it_lexes "x//hmmm", [ + IdentifierToken.new("x") + ] + + it_lexes "a//hmmm\nb", [ + IdentifierToken.new("a"), + IdentifierToken.new("b") + ] + + it_lexes "a // hmmm \n b", [ + IdentifierToken.new("a"), + IdentifierToken.new("b") + ] + + it_lexes "// héýça\n z", [ + IdentifierToken.new("z") + ] +end + +def it_lexes(code, expected_tokens) + it "lexes '#{code}' as [#{expected_tokens.map(&.to_s).join(" ")}]" do + lexer = Lexer.new(code) + + tokens = [] of Token + while token = lexer.next_token + tokens << token + end + tokens.map_with_index! do |token, i| + expected_tokens[i]?.is_a?(IdentifierToken) ? token.try_ident : token + end + + tokens.should eq expected_tokens + end +end + +def it_doesnt_lex(code, message) + it "doesn't lex '#{code}'" do + lexer = Lexer.new(code) + expect_raises(Lexer::LexerException, message) do + while lexer.next_token + end + end + end +end diff --git a/token.cr b/token.cr index bdcd1c3..66af815 100644 --- a/token.cr +++ b/token.cr @@ -2,14 +2,32 @@ class Token property! filename : String property! line : Int32 - property! col : Int32 + property! column : Int32 def try_ident self end def location - "#{filename}:#{line}:#{col}" + "#{filename}:#{line}:#{column}" + end + + def to_s(io) + io << self.class.name.sub("Token", "") + vars = [] of String + {% for ivar in @type.instance_vars.map(&.id).reject {|s| %w[filename line column].map(&.id).includes? s } %} + vars << @{{ivar.id}} + {% end %} + vars.inspect(io) if vars.size > 0 + end + + def inspect(io) + to_s(io) + end + + def ==(other : Token) + return false if other.class != self.class + return true end end @@ -57,6 +75,7 @@ end class PrimitiveTypeToken < Token property name : String + def_equals name def initialize(@name) end @@ -67,18 +86,21 @@ end class IdentifierToken < Token property name : String + def_equals name def initialize(@name) end end class GlobalOptionToken < Token property name : String + def_equals name def initialize(@name) end end class StringLiteralToken < Token property str : String + def_equals str def initialize(@str) end end From 562b6712d4d8ace2a3eed2ed9d1fe67d2cb2bdcf Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 19:09:04 -0300 Subject: [PATCH 323/625] Some refactoring on Parser --- parser.cr | 66 +++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/parser.cr b/parser.cr index 4965775..04f4bb3 100644 --- a/parser.cr +++ b/parser.cr @@ -11,15 +11,15 @@ class Parser def initialize(filename : String) @lexers << Lexer.new(File.read(filename), filename) - next_token + read_next_token end def initialize(io : IO) @lexers << Lexer.new(io.gets_to_end) - next_token + read_next_token end - def next_token + private def read_next_token while @lexers.size > 0 @token = @lexers.last.next_token if @token @@ -30,7 +30,7 @@ class Parser end end - def current_source + private def current_filename @lexers.last.filename if @lexers.size > 0 end @@ -39,11 +39,11 @@ class Parser while @token case multi_expect(ImportKeywordToken, TypeKeywordToken, GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken, GlobalOptionToken, ErrorKeywordToken) when ImportKeywordToken - next_token + read_next_token token = expect StringLiteralToken - source = File.expand_path(token.str + ".sdkgen", File.dirname(current_source.not_nil!)) + source = File.expand_path(token.str + ".sdkgen", File.dirname(current_filename.not_nil!)) @lexers << Lexer.new(File.read(source), source) - next_token + read_next_token when TypeKeywordToken api.type_definitions << parse_type_definition when GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken @@ -51,9 +51,9 @@ class Parser when GlobalOptionToken parse_option(api.options) when ErrorKeywordToken - next_token + read_next_token token = expect IdentifierToken - next_token + read_next_token api.errors << token.name end end @@ -100,20 +100,20 @@ class Parser def parse_enum expect EnumKeywordToken - next_token + read_next_token e = AST::EnumType.new expect CurlyOpenSymbolToken - next_token + read_next_token while true case token = multi_expect(IdentifierToken, CurlyCloseSymbolToken) when IdentifierToken e.values << token.name - next_token + read_next_token when CurlyCloseSymbolToken - next_token + read_next_token return e end end @@ -121,7 +121,7 @@ class Parser def parse_type_definition expect TypeKeywordToken - next_token + read_next_token t = AST::TypeDefinition.new name_token = expect(IdentifierToken) @@ -129,7 +129,7 @@ class Parser raise ParserException.new "The custom type name must start with an uppercase letter, but found '#{name_token.name}' at #{name_token.location}" end t.name = name_token.name - next_token + read_next_token t.type = parse_type t @@ -137,7 +137,7 @@ class Parser def parse_struct expect CurlyOpenSymbolToken - next_token + read_next_token t = AST::StructType.new @@ -146,7 +146,7 @@ class Parser when IdentifierToken t.fields << parse_field when CurlyCloseSymbolToken - next_token + read_next_token return t end end @@ -165,21 +165,21 @@ class Parser raise "never" end - next_token + read_next_token op.name = expect(IdentifierToken).name - next_token + read_next_token if @token.is_a? ParensOpenSymbolToken - next_token + read_next_token while true case token = multi_expect(IdentifierToken, ParensCloseSymbolToken, CommaSymbolToken) when IdentifierToken op.args << parse_field when ParensCloseSymbolToken - next_token + read_next_token break when CommaSymbolToken - next_token + read_next_token next end end @@ -187,7 +187,7 @@ class Parser if @token.is_a? ColonSymbolToken expect ColonSymbolToken - next_token + read_next_token op.return_type = parse_type else op.return_type = AST::VoidPrimitiveType.new @@ -198,14 +198,14 @@ class Parser def parse_option(options) var = expect GlobalOptionToken - next_token + read_next_token expect EqualSymbolToken - next_token + read_next_token case var.name when "url" token = expect StringLiteralToken - next_token + read_next_token options.url = token.str else raise ParserException.new("Unknown option $#{var.name} at #{var.location}") @@ -215,20 +215,20 @@ class Parser def parse_field field = AST::Field.new field.name = expect(IdentifierToken).name - next_token + read_next_token expect ColonSymbolToken - next_token + read_next_token field.type = parse_type(allow_void: false) while @token.is_a?(ExclamationMarkSymbolToken) - next_token + read_next_token case (token = expect(IdentifierToken)).name when "secret" field.secret = true else raise ParserException.new "Unknown field mark !#{token.name} at #{token.location}" end - next_token + read_next_token end field @@ -245,7 +245,7 @@ class Parser raise ParserException.new "Expected a type but found '#{token.name}', at #{token.location}" end result = AST::TypeReference.new(token.name) - next_token + read_next_token when PrimitiveTypeToken result = case token.name when "string"; AST::StringPrimitiveType.new @@ -265,7 +265,7 @@ class Parser else raise "BUG! Should handle primitive #{token.name}" end - next_token + read_next_token else raise "never" end @@ -277,7 +277,7 @@ class Parser when OptionalSymbolToken result = AST::OptionalType.new(result) end - next_token + read_next_token end result From 9c559766e2963710ed80554e82c41dcb3c10c118 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 19:10:37 -0300 Subject: [PATCH 324/625] Remove subscription --- ast.cr | 3 --- ast_to_s.cr | 15 --------------- ext/vscode/syntaxes/sdkgen.tmLanguage.json | 2 +- language.md | 5 ----- lexer.cr | 1 - parser.cr | 8 +++----- spec/lexer_spec.cr | 4 ---- target_typescript.cr | 8 -------- target_typescript_nodeserver.cr | 4 ---- token.cr | 6 ------ 10 files changed, 4 insertions(+), 52 deletions(-) diff --git a/ast.cr b/ast.cr index 94589c2..e18fd91 100644 --- a/ast.cr +++ b/ast.cr @@ -101,7 +101,4 @@ module AST class FunctionOperation < Operation end - - class SubscribeOperation < Operation - end end \ No newline at end of file diff --git a/ast_to_s.cr b/ast_to_s.cr index 34d184a..f77edc6 100644 --- a/ast_to_s.cr +++ b/ast_to_s.cr @@ -157,19 +157,4 @@ module AST end end end - - class SubscribeOperation - def to_s - io << "subscribe " << name << "(" - args.each_with_index do |arg, i| - arg.to_s(io) - io << ", " if i != args.size-1 - end - io << ")" - unless return_type.is_a? VoidPrimitiveType - io << ": " - return_type.to_s(io) - end - end - end end diff --git a/ext/vscode/syntaxes/sdkgen.tmLanguage.json b/ext/vscode/syntaxes/sdkgen.tmLanguage.json index de27309..718acec 100644 --- a/ext/vscode/syntaxes/sdkgen.tmLanguage.json +++ b/ext/vscode/syntaxes/sdkgen.tmLanguage.json @@ -49,7 +49,7 @@ ] }, { "name": "meta.operation", - "begin": "(get|function|subscribe) ([a-zA-Z0-9_]+)", + "begin": "(get|function) ([a-zA-Z0-9_]+)", "beginCaptures": { "1": {"name": "keyword.control"}, "2": {"name": "entity.name.function"} diff --git a/language.md b/language.md index 68a213e..68fcb72 100644 --- a/language.md +++ b/language.md @@ -71,7 +71,6 @@ Operations are represented as functions called by the client and executed by the - `get`: This operation will fetch some data from the server into the client, it is meant to be a read-only operation. This type of operation can support cache. A connection failure by default should a non blocking warning to the end user. This can be safely retried on failure. - `function`: This operation will do some action and optionally return some information about it. It is not cacheable, but supports "do eventually" semantics. On a connection failure, a more intrusive error is shown to the end user by default. There will be no automatic retries. -- `subscribe`: This request is always stream based and will keep a connection open receiving events from the server. Examples: @@ -81,10 +80,6 @@ Examples: // Sends a message, returns nothing function sendMessage(target: string, message: Message): void - // Subscribes for new messages - // The "return type" is the event - subscribe messages(since: date): Message - ## Marks A mark can be added after a field or an operation parameter to add some special meaning. It starts with an exclamation and is followed by some word. Supported marks are: diff --git a/lexer.cr b/lexer.cr index 7361ba4..8728b29 100644 --- a/lexer.cr +++ b/lexer.cr @@ -150,7 +150,6 @@ class Lexer when "import"; ImportKeywordToken.new when "get"; GetKeywordToken.new when "function"; FunctionKeywordToken.new - when "subscribe"; SubscribeKeywordToken.new when "bool", "int", "uint", "float", "string", "date", "datetime", "bytes", "void" PrimitiveTypeToken.new(str) else diff --git a/parser.cr b/parser.cr index 04f4bb3..8739f9d 100644 --- a/parser.cr +++ b/parser.cr @@ -37,7 +37,7 @@ class Parser def parse api = AST::ApiDescription.new while @token - case multi_expect(ImportKeywordToken, TypeKeywordToken, GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken, GlobalOptionToken, ErrorKeywordToken) + case multi_expect(ImportKeywordToken, TypeKeywordToken, GetKeywordToken, FunctionKeywordToken, GlobalOptionToken, ErrorKeywordToken) when ImportKeywordToken read_next_token token = expect StringLiteralToken @@ -46,7 +46,7 @@ class Parser read_next_token when TypeKeywordToken api.type_definitions << parse_type_definition - when GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken + when GetKeywordToken, FunctionKeywordToken api.operations << parse_operation when GlobalOptionToken parse_option(api.options) @@ -154,13 +154,11 @@ class Parser def parse_operation op = nil - case token = multi_expect(GetKeywordToken, FunctionKeywordToken, SubscribeKeywordToken) + case token = multi_expect(GetKeywordToken, FunctionKeywordToken) when GetKeywordToken op = AST::GetOperation.new when FunctionKeywordToken op = AST::FunctionOperation.new - when SubscribeKeywordToken - op = AST::SubscribeOperation.new else raise "never" end diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index 7be106d..267b666 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -59,10 +59,6 @@ describe Lexer do FunctionKeywordToken.new ] - it_lexes "subscribe", [ - SubscribeKeywordToken.new - ] - it_lexes "enuma", [ IdentifierToken.new("enuma") ] diff --git a/target_typescript.cr b/target_typescript.cr index ed9fe58..bf6bd70 100644 --- a/target_typescript.cr +++ b/target_typescript.cr @@ -55,16 +55,8 @@ abstract class TypeScriptTarget < Target op.return_type.is_a?(AST::VoidPrimitiveType) ? "void" : native_type op.return_type end - def operation_ret(op : AST::SubscribeOperation) - "null" - end - def operation_args(op : AST::Operation) args = op.args.map {|arg| "#{arg.name}: #{native_type arg.type}" } - if op.is_a? AST::SubscribeOperation - args << "callback: (result: #{native_type op.return_type}) => null" - end - "(#{args.join(", ")})" end diff --git a/target_typescript_nodeserver.cr b/target_typescript_nodeserver.cr index 4ad0a18..23795ff 100644 --- a/target_typescript_nodeserver.cr +++ b/target_typescript_nodeserver.cr @@ -305,10 +305,6 @@ END def operation_args(op : AST::Operation) args = ["ctx: Context"] + op.args.map {|arg| "#{arg.name}: #{native_type arg.type}" } - if op.is_a? AST::SubscribeOperation - args << "callback: (result: #{native_type op.return_type}) => void" - end - "(#{args.join(", ")})" end diff --git a/token.cr b/token.cr index 66af815..7615560 100644 --- a/token.cr +++ b/token.cr @@ -61,12 +61,6 @@ class FunctionKeywordToken < Token end end -class SubscribeKeywordToken < Token - def try_ident - IdentifierToken.new("subscribe") - end -end - class ErrorKeywordToken < Token def try_ident IdentifierToken.new("error") From 70b1897a4eb3f3b4aa2aff2db0768520c54ba695 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 19:12:49 -0300 Subject: [PATCH 325/625] Move src to 'src' --- main.cr | 16 ++++++++-------- spec/lexer_spec.cr | 2 +- spec/parser_spec.cr | 6 +++--- ast.cr => src/ast.cr | 0 ast_semantic.cr => src/ast_semantic.cr | 0 ast_to_s.cr => src/ast_to_s.cr | 0 lexer.cr => src/lexer.cr | 0 parser.cr => src/parser.cr | 0 target.cr => src/target.cr | 0 target_java.cr => src/target_java.cr | 0 .../target_java_android.cr | 0 target_swift.cr => src/target_swift.cr | 0 target_swift_ios.cr => src/target_swift_ios.cr | 0 target_typescript.cr => src/target_typescript.cr | 0 .../target_typescript_nodeclient.cr | 0 .../target_typescript_nodeserver.cr | 0 .../target_typescript_web.cr | 0 token.cr => src/token.cr | 0 18 files changed, 12 insertions(+), 12 deletions(-) rename ast.cr => src/ast.cr (100%) rename ast_semantic.cr => src/ast_semantic.cr (100%) rename ast_to_s.cr => src/ast_to_s.cr (100%) rename lexer.cr => src/lexer.cr (100%) rename parser.cr => src/parser.cr (100%) rename target.cr => src/target.cr (100%) rename target_java.cr => src/target_java.cr (100%) rename target_java_android.cr => src/target_java_android.cr (100%) rename target_swift.cr => src/target_swift.cr (100%) rename target_swift_ios.cr => src/target_swift_ios.cr (100%) rename target_typescript.cr => src/target_typescript.cr (100%) rename target_typescript_nodeclient.cr => src/target_typescript_nodeclient.cr (100%) rename target_typescript_nodeserver.cr => src/target_typescript_nodeserver.cr (100%) rename target_typescript_web.cr => src/target_typescript_web.cr (100%) rename token.cr => src/token.cr (100%) diff --git a/main.cr b/main.cr index d36105c..ae41ad9 100644 --- a/main.cr +++ b/main.cr @@ -1,11 +1,11 @@ -require "./lexer" -require "./parser" -require "./ast_to_s" -require "./target_java_android" -require "./target_swift_ios" -require "./target_typescript_nodeserver" -require "./target_typescript_nodeclient" -require "./target_typescript_web" +require "./src/lexer" +require "./src/parser" +require "./src/ast_to_s" +require "./src/target_java_android" +require "./src/target_swift_ios" +require "./src/target_typescript_nodeserver" +require "./src/target_typescript_nodeclient" +require "./src/target_typescript_web" require "option_parser" require "file_utils" diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index 267b666..be8000b 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -1,5 +1,5 @@ require "spec" -require "../lexer" +require "../src/lexer" describe Lexer do it_lexes "", [] of Token diff --git a/spec/parser_spec.cr b/spec/parser_spec.cr index 57a9922..d4a9ba2 100644 --- a/spec/parser_spec.cr +++ b/spec/parser_spec.cr @@ -1,7 +1,7 @@ require "spec" -require "../lexer" -require "../parser" -require "../ast_to_s" +require "../src/lexer" +require "../src/parser" +require "../src/ast_to_s" def clear(code) code = code.strip diff --git a/ast.cr b/src/ast.cr similarity index 100% rename from ast.cr rename to src/ast.cr diff --git a/ast_semantic.cr b/src/ast_semantic.cr similarity index 100% rename from ast_semantic.cr rename to src/ast_semantic.cr diff --git a/ast_to_s.cr b/src/ast_to_s.cr similarity index 100% rename from ast_to_s.cr rename to src/ast_to_s.cr diff --git a/lexer.cr b/src/lexer.cr similarity index 100% rename from lexer.cr rename to src/lexer.cr diff --git a/parser.cr b/src/parser.cr similarity index 100% rename from parser.cr rename to src/parser.cr diff --git a/target.cr b/src/target.cr similarity index 100% rename from target.cr rename to src/target.cr diff --git a/target_java.cr b/src/target_java.cr similarity index 100% rename from target_java.cr rename to src/target_java.cr diff --git a/target_java_android.cr b/src/target_java_android.cr similarity index 100% rename from target_java_android.cr rename to src/target_java_android.cr diff --git a/target_swift.cr b/src/target_swift.cr similarity index 100% rename from target_swift.cr rename to src/target_swift.cr diff --git a/target_swift_ios.cr b/src/target_swift_ios.cr similarity index 100% rename from target_swift_ios.cr rename to src/target_swift_ios.cr diff --git a/target_typescript.cr b/src/target_typescript.cr similarity index 100% rename from target_typescript.cr rename to src/target_typescript.cr diff --git a/target_typescript_nodeclient.cr b/src/target_typescript_nodeclient.cr similarity index 100% rename from target_typescript_nodeclient.cr rename to src/target_typescript_nodeclient.cr diff --git a/target_typescript_nodeserver.cr b/src/target_typescript_nodeserver.cr similarity index 100% rename from target_typescript_nodeserver.cr rename to src/target_typescript_nodeserver.cr diff --git a/target_typescript_web.cr b/src/target_typescript_web.cr similarity index 100% rename from target_typescript_web.cr rename to src/target_typescript_web.cr diff --git a/token.cr b/src/token.cr similarity index 100% rename from token.cr rename to src/token.cr From 90e0864bffbfb389bfbadbccff7436a73f24268a Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 19:18:20 -0300 Subject: [PATCH 326/625] Better show error message --- main.cr | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/main.cr b/main.cr index ae41ad9..1e9afc5 100644 --- a/main.cr +++ b/main.cr @@ -8,6 +8,7 @@ require "./src/target_typescript_nodeclient" require "./src/target_typescript_web" require "option_parser" require "file_utils" +require "colorize" is_server = false destination = "" @@ -32,19 +33,25 @@ end source = sources[0] -parser = Parser.new(source) -ast = parser.parse -ast.semantic - -if destination == "" - STDERR.puts "You must specify an output file" - exit -end - -if target_name == "" - STDERR.puts "You must specify a target" - exit +begin + parser = Parser.new(source) + ast = parser.parse + ast.semantic + + if destination == "" + STDERR.puts "You must specify an output file" + exit + end + + if target_name == "" + STDERR.puts "You must specify a target" + exit + end + + FileUtils.mkdir_p(File.dirname(destination)) + Target.process(ast, destination, target_name) +rescue ex : Lexer::LexerException | Parser::ParserException + STDERR.puts (ex.message || "Invalid source").colorize.light_red +rescue ex : Exception + raise ex end - -FileUtils.mkdir_p(File.dirname(destination)) -Target.process(ast, destination, target_name) From 02d897382f3d4c0b469710a56b4a6f5cc1fd6c76 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 19:38:51 -0300 Subject: [PATCH 327/625] Remove explicit "void" type --- spec/lexer_spec.cr | 2 +- src/lexer.cr | 2 +- src/parser.cr | 10 ++-------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index be8000b..479210c 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -67,7 +67,7 @@ describe Lexer do IdentifierToken.new("errorh") ] - %w[string int uint date datetime bytes float bool void].each do |primitive| + %w[string int uint date datetime bytes float bool].each do |primitive| it_lexes primitive, [ PrimitiveTypeToken.new(primitive) ] diff --git a/src/lexer.cr b/src/lexer.cr index 8728b29..bd43e18 100644 --- a/src/lexer.cr +++ b/src/lexer.cr @@ -150,7 +150,7 @@ class Lexer when "import"; ImportKeywordToken.new when "get"; GetKeywordToken.new when "function"; FunctionKeywordToken.new - when "bool", "int", "uint", "float", "string", "date", "datetime", "bytes", "void" + when "bool", "int", "uint", "float", "string", "date", "datetime", "bytes" PrimitiveTypeToken.new(str) else IdentifierToken.new(str) diff --git a/src/parser.cr b/src/parser.cr index 8739f9d..4175e62 100644 --- a/src/parser.cr +++ b/src/parser.cr @@ -216,7 +216,7 @@ class Parser read_next_token expect ColonSymbolToken read_next_token - field.type = parse_type(allow_void: false) + field.type = parse_type while @token.is_a?(ExclamationMarkSymbolToken) read_next_token @@ -232,7 +232,7 @@ class Parser field end - def parse_type(allow_void = true) + def parse_type case token = multi_expect(CurlyOpenSymbolToken, EnumKeywordToken, PrimitiveTypeToken, IdentifierToken) when CurlyOpenSymbolToken result = parse_struct @@ -254,12 +254,6 @@ class Parser when "float"; AST::FloatPrimitiveType.new when "bool"; AST::BoolPrimitiveType.new when "bytes"; AST::BytesPrimitiveType.new - when "void" - if allow_void - AST::VoidPrimitiveType.new - else - raise ParserException.new "Can't use 'void' here, at #{token.location}" - end else raise "BUG! Should handle primitive #{token.name}" end From d066f3318c03beffb25a7e84f7a992a8df29b875 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 19:44:35 -0300 Subject: [PATCH 328/625] Add deprecated warning about function without "()" --- src/parser.cr | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/parser.cr b/src/parser.cr index 4175e62..4e69d0b 100644 --- a/src/parser.cr +++ b/src/parser.cr @@ -78,7 +78,7 @@ class Parser {% end %} unless result - raise ParserException.new "Expected #{{{token_types.map{|t| t.stringify.gsub(/Token$/, "")}.join(" or ")}}} at #{token.location}, but found #{token.class.to_s.gsub(/Token$/, "")}" + raise ParserException.new "Expected #{{{token_types.map{|t| t.stringify.gsub(/Token$/, "")}.join(" or ")}}} at #{token.location}, but found #{token}" end result @@ -93,7 +93,7 @@ class Parser token = token.try_ident {% end %} unless token.is_a?({{token_type}}) - raise ParserException.new "Expected #{{{token_type.stringify.gsub(/Token$/, "")}}} at #{token.location}, but found #{token.class.to_s.sub(/Token$/, "")}" + raise ParserException.new "Expected #{{{token_type.stringify.gsub(/Token$/, "")}}} at #{token.location}, but found #{token}" end token end @@ -165,6 +165,7 @@ class Parser read_next_token op.name = expect(IdentifierToken).name + ref_deprecated_location_token = @token.not_nil! read_next_token if @token.is_a? ParensOpenSymbolToken @@ -181,6 +182,8 @@ class Parser next end end + else + STDERR.puts "DEPRECATED: Should use '()' even for functions without arguments. See '#{op.name}' at #{ref_deprecated_location_token.location}.".colorize.light_yellow end if @token.is_a? ColonSymbolToken From 78906664f4d25611d7866bcd04afdf76094140e5 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 21:05:39 -0300 Subject: [PATCH 329/625] Remove _ from highlight --- ext/vscode/syntaxes/sdkgen.tmLanguage.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/vscode/syntaxes/sdkgen.tmLanguage.json b/ext/vscode/syntaxes/sdkgen.tmLanguage.json index 718acec..49981e2 100644 --- a/ext/vscode/syntaxes/sdkgen.tmLanguage.json +++ b/ext/vscode/syntaxes/sdkgen.tmLanguage.json @@ -5,7 +5,7 @@ "include": "#any" }, { "name": "meta.variable", - "begin": "(\\$[a-zA-Z0-9_]+) =", + "begin": "(\\$[a-zA-Z0-9]+) =", "beginCaptures": { "1": {"name": "variable.other"} }, @@ -29,14 +29,14 @@ ] }, { "name": "meta.error", - "match": "(error) ([A-Z][a-zA-Z0-9_]*)", + "match": "(error) ([A-Z][a-zA-Z0-9]*)", "captures": { "1": {"name": "keyword.control"}, "2": {"name": "entity.name.type"} } }, { "name": "meta.type", - "begin": "(type) ([A-Z][a-zA-Z0-9_]*) ", + "begin": "(type) ([A-Z][a-zA-Z0-9]*) ", "beginCaptures": { "1": {"name": "keyword.control"}, "2": {"name": "entity.name.type"} @@ -49,7 +49,7 @@ ] }, { "name": "meta.operation", - "begin": "(get|function) ([a-zA-Z0-9_]+)", + "begin": "(get|function) ([a-zA-Z0-9]+)", "beginCaptures": { "1": {"name": "keyword.control"}, "2": {"name": "entity.name.function"} @@ -111,10 +111,10 @@ "match": "(\\?|\\[\\])" }, { "name": "entity.name.type", - "match": "\\b([A-Z][a-zA-Z0-9_]*)\\b" + "match": "\\b([A-Z][a-zA-Z0-9]*)\\b" }, { "name": "constant.numeric", - "match": "(![a-zA-Z0-9_]+)\\b" + "match": "(![a-zA-Z0-9]+)\\b" }, { "name": "meta.type", "begin": "\\{", From fc2ed365e112b339393998b05503229e5dddd940 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 21 Oct 2017 21:47:49 -0300 Subject: [PATCH 330/625] Allow more skips chars --- src/lexer.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lexer.cr b/src/lexer.cr index bd43e18..5e24710 100644 --- a/src/lexer.cr +++ b/src/lexer.cr @@ -51,7 +51,7 @@ class Lexer case current_char when '\0' return nil - when ' ', '\n' + when ' ', '\n', '\r' ,'\t' next_char return next_token when '/' From ae454c3dc1eb58efa6814b48c3893c03aed998d0 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 22 Oct 2017 17:38:38 -0300 Subject: [PATCH 331/625] Don't include AST module on AST classes --- src/ast.cr | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/ast.cr b/src/ast.cr index e18fd91..0af7ef8 100644 --- a/src/ast.cr +++ b/src/ast.cr @@ -1,7 +1,6 @@ module AST abstract class Type - include AST end abstract class PrimitiveType < Type @@ -55,7 +54,6 @@ module AST end class TypeDefinition - include AST property! name : String property! type : Type end @@ -67,7 +65,6 @@ module AST end class ApiDescription - include AST property type_definitions = [] of TypeDefinition property operations = [] of Operation property options = Options.new @@ -79,7 +76,6 @@ module AST end class Field - include AST property! name : String property! type : Type property secret = false @@ -90,7 +86,6 @@ module AST end abstract class Operation - include AST property! name : String property args = [] of Field property! return_type : Type From e048f9a7b9fda1f43bd373d37b502f9f24d160b8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 22 Oct 2017 18:38:24 -0300 Subject: [PATCH 332/625] Disable nodeclient target for now --- src/target_typescript_nodeclient.cr | 292 ++++++++++++++-------------- 1 file changed, 146 insertions(+), 146 deletions(-) diff --git a/src/target_typescript_nodeclient.cr b/src/target_typescript_nodeclient.cr index 97f2ee2..54b6a9e 100644 --- a/src/target_typescript_nodeclient.cr +++ b/src/target_typescript_nodeclient.cr @@ -1,146 +1,146 @@ -require "./target_typescript" - -class TypeScriptClientTarget < TypeScriptTarget - def gen - @io << <<-END -import * as moment from "moment"; -import * as request from "request"; -import * as fs from "fs"; -import {version as nodeVersion} from "process"; - -const baseUrl = #{@ast.options.url.inspect}; -let gDeviceId = null; -let gDevicePath = "/root/config/deviceId"; - -END - - @ast.struct_types.each do |t| - @io << generate_struct_type(t) - @io << "\n\n" - end - - @ast.enum_types.each do |t| - @io << generate_enum_type(t) - @io << "\n\n" - end - - @ast.operations.each do |op| - @io << "export async function #{op.pretty_name}#{operation_args(op)}: Promise<#{operation_ret(op)}> {\n" - if op.args.size > 0 - @io << " const args = {\n" - op.args.each do |arg| - @io << ident ident "#{arg.name}: #{type_to_json(arg.type, arg.name)}," - @io << "\n" - end - @io << " };\n" - end - - @io << " " - @io << "const ret: #{native_type op.return_type} = " unless op.return_type.is_a? AST::VoidPrimitiveType - @io << "await makeRequest({name: #{op.pretty_name.inspect}, #{op.args.size > 0 ? "args" : "args: {}"}});\n" - @io << ident "return " + type_from_json(op.return_type, "ret") + ";" - @io << "\n" - @io << "}\n\n" - end - - @io << <<-END -////////////////////////////////////////////////////// - -async function getDeviceId(){ - if(!gDeviceId){ - try{ - gDeviceId = await new Promise((resolve, reject) => fs.readFile(gDevicePath, "utf8", - (err, data) => { - if(err) - reject(err); - else - resolve(); - }) - ); - } catch(e){ - return null; - } - } - return gDeviceId; -} - -async function setDeviceId(newDeviceId){ - if(newDeviceId !== gDeviceId){ - await new Promise((resolve, reject) => fs.writeFile(gDevicePath, newDeviceId, "utf8", - (err) => { - if(err) - reject(err); - else - resolve(); - }) - ); - gDeviceId = newDeviceId; - } -} - -async function device() { - const device: any = { - type: "node", - platform: { - nodeVersion: nodeVersion, - }, - screen: { - width: 0, - height: 0 - }, - version: "0.0.0", - language: "en-US" - }; - - const deviceId = await getDeviceId(); - if (deviceId) - device.id = deviceId; - return device; -} - -function randomBytesHex(len: number) { - let hex = ""; - for (let i = 0; i < 2 * len; ++i) - hex += "0123456789abcdef"[Math.floor(Math.random()*16)]; - return hex; -} - -async function makeRequest({name, args}: {name: string, args: any}) { - return new Promise(async (resolve, reject) => { - const body = { - id: randomBytesHex(8), - device: await device(), - name: name, - args: args - }; - - request.post( - "https://" + baseUrl + "/" + name, - {json: body}, - async (err, res, body) => { - if(!err){ - try{ - if(body.ok){ - await setDeviceId(body.deviceId); - resolve(body.result); - } else { - reject(body.error); - } - } catch(e){ - console.error(e); - reject({type: "Fatal", message: e.toString()}); - } - } else { - console.error(err); - reject({type: "Fatal", message: err.toString()}); - } - } - ); - }); -} - -END - end -end - -Target.register(TypeScriptClientTarget, target_name: "typescript_nodeclient") +# require "./target_typescript" + +# class TypeScriptClientTarget < TypeScriptTarget +# def gen +# @io << <<-END +# import * as moment from "moment"; +# import * as request from "request"; +# import * as fs from "fs"; +# import {version as nodeVersion} from "process"; + +# const baseUrl = #{@ast.options.url.inspect}; +# let gDeviceId = null; +# let gDevicePath = "/root/config/deviceId"; + +# END + +# @ast.struct_types.each do |t| +# @io << generate_struct_type(t) +# @io << "\n\n" +# end + +# @ast.enum_types.each do |t| +# @io << generate_enum_type(t) +# @io << "\n\n" +# end + +# @ast.operations.each do |op| +# @io << "export async function #{op.pretty_name}#{operation_args(op)}: Promise<#{operation_ret(op)}> {\n" +# if op.args.size > 0 +# @io << " const args = {\n" +# op.args.each do |arg| +# @io << ident ident "#{arg.name}: #{type_to_json(arg.type, arg.name)}," +# @io << "\n" +# end +# @io << " };\n" +# end + +# @io << " " +# @io << "const ret: #{native_type op.return_type} = " unless op.return_type.is_a? AST::VoidPrimitiveType +# @io << "await makeRequest({name: #{op.pretty_name.inspect}, #{op.args.size > 0 ? "args" : "args: {}"}});\n" +# @io << ident "return " + type_from_json(op.return_type, "ret") + ";" +# @io << "\n" +# @io << "}\n\n" +# end + +# @io << <<-END +# ////////////////////////////////////////////////////// + +# async function getDeviceId(){ +# if(!gDeviceId){ +# try{ +# gDeviceId = await new Promise((resolve, reject) => fs.readFile(gDevicePath, "utf8", +# (err, data) => { +# if(err) +# reject(err); +# else +# resolve(); +# }) +# ); +# } catch(e){ +# return null; +# } +# } +# return gDeviceId; +# } + +# async function setDeviceId(newDeviceId){ +# if(newDeviceId !== gDeviceId){ +# await new Promise((resolve, reject) => fs.writeFile(gDevicePath, newDeviceId, "utf8", +# (err) => { +# if(err) +# reject(err); +# else +# resolve(); +# }) +# ); +# gDeviceId = newDeviceId; +# } +# } + +# async function device() { +# const device: any = { +# type: "node", +# platform: { +# nodeVersion: nodeVersion, +# }, +# screen: { +# width: 0, +# height: 0 +# }, +# version: "0.0.0", +# language: "en-US" +# }; + +# const deviceId = await getDeviceId(); +# if (deviceId) +# device.id = deviceId; +# return device; +# } + +# function randomBytesHex(len: number) { +# let hex = ""; +# for (let i = 0; i < 2 * len; ++i) +# hex += "0123456789abcdef"[Math.floor(Math.random()*16)]; +# return hex; +# } + +# async function makeRequest({name, args}: {name: string, args: any}) { +# return new Promise(async (resolve, reject) => { +# const body = { +# id: randomBytesHex(8), +# device: await device(), +# name: name, +# args: args +# }; + +# request.post( +# "https://" + baseUrl + "/" + name, +# {json: body}, +# async (err, res, body) => { +# if(!err){ +# try{ +# if(body.ok){ +# await setDeviceId(body.deviceId); +# resolve(body.result); +# } else { +# reject(body.error); +# } +# } catch(e){ +# console.error(e); +# reject({type: "Fatal", message: e.toString()}); +# } +# } else { +# console.error(err); +# reject({type: "Fatal", message: err.toString()}); +# } +# } +# ); +# }); +# } + +# END +# end +# end + +# Target.register(TypeScriptClientTarget, target_name: "typescript_nodeclient") From 7954ce7b38b31c2418f404e76f08912e34caf6b5 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 22 Oct 2017 18:40:47 -0300 Subject: [PATCH 333/625] Typescript: Move type codegen to per type files --- src/codegen_types/array.cr | 23 ++++++ src/codegen_types/bool.cr | 15 ++++ src/codegen_types/bytes.cr | 15 ++++ src/codegen_types/date.cr | 15 ++++ src/codegen_types/datetime.cr | 15 ++++ src/codegen_types/enum.cr | 15 ++++ src/codegen_types/float.cr | 15 ++++ src/codegen_types/int.cr | 15 ++++ src/codegen_types/optional.cr | 15 ++++ src/codegen_types/reference.cr | 15 ++++ src/codegen_types/string.cr | 15 ++++ src/codegen_types/struct.cr | 27 +++++++ src/codegen_types/type.cr | 15 ++++ src/codegen_types/uint.cr | 15 ++++ src/codegen_types/void.cr | 15 ++++ src/target.cr | 1 + src/target_typescript.cr | 112 +--------------------------- src/target_typescript_nodeserver.cr | 6 +- src/target_typescript_web.cr | 12 ++- 19 files changed, 260 insertions(+), 116 deletions(-) create mode 100644 src/codegen_types/array.cr create mode 100644 src/codegen_types/bool.cr create mode 100644 src/codegen_types/bytes.cr create mode 100644 src/codegen_types/date.cr create mode 100644 src/codegen_types/datetime.cr create mode 100644 src/codegen_types/enum.cr create mode 100644 src/codegen_types/float.cr create mode 100644 src/codegen_types/int.cr create mode 100644 src/codegen_types/optional.cr create mode 100644 src/codegen_types/reference.cr create mode 100644 src/codegen_types/string.cr create mode 100644 src/codegen_types/struct.cr create mode 100644 src/codegen_types/type.cr create mode 100644 src/codegen_types/uint.cr create mode 100644 src/codegen_types/void.cr diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr new file mode 100644 index 0000000..83d8a0a --- /dev/null +++ b/src/codegen_types/array.cr @@ -0,0 +1,23 @@ +module AST + class ArrayType + def typescript_decode(expr) + inner = base.typescript_decode("e") + inner = "(#{inner})" if inner[0] == '{' + "#{expr}.map((e: any) => #{inner})" + end + + def typescript_encode(expr) + inner = base.typescript_encode("e") + inner = "(#{inner})" if inner[0] == '{' + "#{expr}.map(e => #{inner})" + end + + def typescript_native_type + if base.is_a? AST::OptionalType + "(#{base.typescript_native_type})[]" + else + base.typescript_native_type + "[]" + end + end + end +end diff --git a/src/codegen_types/bool.cr b/src/codegen_types/bool.cr new file mode 100644 index 0000000..96ca239 --- /dev/null +++ b/src/codegen_types/bool.cr @@ -0,0 +1,15 @@ +module AST + class BoolPrimitiveType + def typescript_decode(expr) + "!!#{expr}" + end + + def typescript_encode(expr) + "!!#{expr}" + end + + def typescript_native_type + "boolean" + end + end +end diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr new file mode 100644 index 0000000..d9bf380 --- /dev/null +++ b/src/codegen_types/bytes.cr @@ -0,0 +1,15 @@ +module AST + class BytesPrimitiveType + def typescript_decode(expr) + "Buffer.from(#{expr}, \"base64\")" + end + + def typescript_encode(expr) + "#{expr}.toString(\"base64\")" + end + + def typescript_native_type + "Buffer" + end + end +end diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr new file mode 100644 index 0000000..d0e9811 --- /dev/null +++ b/src/codegen_types/date.cr @@ -0,0 +1,15 @@ +module AST + class DatePrimitiveType + def typescript_decode(expr) + "moment(#{expr}, \"YYYY-MM-DD\").toDate()" + end + + def typescript_encode(expr) + "moment(#{expr}).format(\"YYYY-MM-DD\")" + end + + def typescript_native_type + "Date" + end + end +end diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr new file mode 100644 index 0000000..ace62d9 --- /dev/null +++ b/src/codegen_types/datetime.cr @@ -0,0 +1,15 @@ +module AST + class DateTimePrimitiveType + def typescript_decode(expr) + "moment.utc(#{expr}, \"YYYY-MM-DDTHH:mm:ss.SSS\").toDate()" + end + + def typescript_encode(expr) + "moment.utc(#{expr}).format(\"YYYY-MM-DDTHH:mm:ss.SSS\")" + end + + def typescript_native_type + "Date" + end + end +end diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr new file mode 100644 index 0000000..544a371 --- /dev/null +++ b/src/codegen_types/enum.cr @@ -0,0 +1,15 @@ +module AST + class EnumType + def typescript_decode(expr) + "#{expr}" + end + + def typescript_encode(expr) + "#{expr}" + end + + def typescript_native_type + name + end + end +end diff --git a/src/codegen_types/float.cr b/src/codegen_types/float.cr new file mode 100644 index 0000000..cb98bfc --- /dev/null +++ b/src/codegen_types/float.cr @@ -0,0 +1,15 @@ +module AST + class FloatPrimitiveType + def typescript_decode(expr) + "#{expr}" + end + + def typescript_encode(expr) + "#{expr}" + end + + def typescript_native_type + "number" + end + end +end diff --git a/src/codegen_types/int.cr b/src/codegen_types/int.cr new file mode 100644 index 0000000..37e1f0b --- /dev/null +++ b/src/codegen_types/int.cr @@ -0,0 +1,15 @@ +module AST + class IntPrimitiveType + def typescript_decode(expr) + "#{expr}|0" + end + + def typescript_encode(expr) + "#{expr}|0" + end + + def typescript_native_type + "number" + end + end +end diff --git a/src/codegen_types/optional.cr b/src/codegen_types/optional.cr new file mode 100644 index 0000000..93e7077 --- /dev/null +++ b/src/codegen_types/optional.cr @@ -0,0 +1,15 @@ +module AST + class OptionalType + def typescript_decode(expr) + "#{expr} === null || #{expr} === undefined ? null : #{base.typescript_decode(expr)}" + end + + def typescript_encode(expr) + "#{expr} === null || #{expr} === undefined ? null : #{base.typescript_encode(expr)}" + end + + def typescript_native_type + "#{base.typescript_native_type} | null" + end + end +end diff --git a/src/codegen_types/reference.cr b/src/codegen_types/reference.cr new file mode 100644 index 0000000..73e78ec --- /dev/null +++ b/src/codegen_types/reference.cr @@ -0,0 +1,15 @@ +module AST + class TypeReference + def typescript_decode(expr) + type.typescript_decode(expr) + end + + def typescript_encode(expr) + type.typescript_encode(expr) + end + + def typescript_native_type + type.typescript_native_type + end + end +end diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr new file mode 100644 index 0000000..035c090 --- /dev/null +++ b/src/codegen_types/string.cr @@ -0,0 +1,15 @@ +module AST + class StringPrimitiveType + def typescript_decode(expr) + "#{expr}.normalize()" + end + + def typescript_encode(expr) + "#{expr}.normalize()" + end + + def typescript_native_type + "string" + end + end +end diff --git a/src/codegen_types/struct.cr b/src/codegen_types/struct.cr new file mode 100644 index 0000000..fe48a45 --- /dev/null +++ b/src/codegen_types/struct.cr @@ -0,0 +1,27 @@ +module AST + class StructType + def typescript_decode(expr) + String::Builder.build do |io| + io << "{\n" + fields.each do |field| + io << " #{field.name}: #{field.type.typescript_decode("#{expr}.#{field.name}")},\n" + end + io << "}" + end + end + + def typescript_encode(expr) + String::Builder.build do |io| + io << "{\n" + fields.each do |field| + io << " #{field.name}: #{field.type.typescript_encode("#{expr}.#{field.name}")},\n" + end + io << "}" + end + end + + def typescript_native_type + name + end + end +end diff --git a/src/codegen_types/type.cr b/src/codegen_types/type.cr new file mode 100644 index 0000000..c283e77 --- /dev/null +++ b/src/codegen_types/type.cr @@ -0,0 +1,15 @@ +module AST + class Type + def typescript_decode(expr) + raise "TODO: #{self.class}" + end + + def typescript_encode(expr) + raise "TODO: #{self.class}" + end + + def typescript_native_type + raise "TODO: #{self.class}" + end + end +end diff --git a/src/codegen_types/uint.cr b/src/codegen_types/uint.cr new file mode 100644 index 0000000..2201d82 --- /dev/null +++ b/src/codegen_types/uint.cr @@ -0,0 +1,15 @@ +module AST + class UIntPrimitiveType + def typescript_decode(expr) + "#{expr}|0" + end + + def typescript_encode(expr) + "#{expr}|0" + end + + def typescript_native_type + "number" + end + end +end diff --git a/src/codegen_types/void.cr b/src/codegen_types/void.cr new file mode 100644 index 0000000..53987f9 --- /dev/null +++ b/src/codegen_types/void.cr @@ -0,0 +1,15 @@ +module AST + class VoidPrimitiveType + def typescript_decode(expr) + "undefined" + end + + def typescript_encode(expr) + "null" + end + + def typescript_native_type + "null" + end + end +end diff --git a/src/target.cr b/src/target.cr index 27bbc7d..6a1299b 100644 --- a/src/target.cr +++ b/src/target.cr @@ -1,6 +1,7 @@ require "./ast" require "./lexer" require "./parser" +require "./codegen_types/**" abstract class Target @@targets = {} of String => Target.class diff --git a/src/target_typescript.cr b/src/target_typescript.cr index bf6bd70..4dc0e46 100644 --- a/src/target_typescript.cr +++ b/src/target_typescript.cr @@ -1,47 +1,11 @@ require "./target" abstract class TypeScriptTarget < Target - def native_type(t : AST::PrimitiveType) - case t - when AST::StringPrimitiveType; "string" - when AST::IntPrimitiveType; "number" - when AST::UIntPrimitiveType; "number" - when AST::FloatPrimitiveType; "number" - when AST::DatePrimitiveType; "Date" - when AST::DateTimePrimitiveType; "Date" - when AST::BoolPrimitiveType; "boolean" - when AST::BytesPrimitiveType; "Buffer" - when AST::VoidPrimitiveType; "null" - else - raise "BUG! Should handle primitive #{t.class}" - end - end - - def native_type(t : AST::OptionalType) - native_type(t.base) + " | null" - end - - def native_type(t : AST::ArrayType) - if t.base.is_a? AST::OptionalType - "(#{native_type(t.base)})[]" - else - native_type(t.base) + "[]" - end - end - - def native_type(t : AST::StructType | AST::EnumType) - t.name - end - - def native_type(ref : AST::TypeReference) - native_type ref.type - end - def generate_struct_type(t) String.build do |io| io << "export interface #{t.name} {\n" t.fields.each do |field| - io << ident "#{field.name}: #{native_type field.type};\n" + io << ident "#{field.name}: #{field.type.typescript_native_type};\n" end io << "}" end @@ -52,85 +16,15 @@ abstract class TypeScriptTarget < Target end def operation_ret(op : AST::GetOperation | AST::FunctionOperation) - op.return_type.is_a?(AST::VoidPrimitiveType) ? "void" : native_type op.return_type + op.return_type.is_a?(AST::VoidPrimitiveType) ? "void" : op.return_type.typescript_native_type end def operation_args(op : AST::Operation) - args = op.args.map {|arg| "#{arg.name}: #{native_type arg.type}" } + args = op.args.map {|arg| "#{arg.name}: #{arg.type.typescript_native_type}" } "(#{args.join(", ")})" end def operation_type(op : AST::Operation) "#{operation_args(op)} => Promise<#{operation_ret(op)}>" end - - def type_from_json(t : AST::Type, src : String) - case t - when AST::StringPrimitiveType, AST::IntPrimitiveType, AST::UIntPrimitiveType, AST::FloatPrimitiveType, AST::BoolPrimitiveType - "#{src}" - when AST::DatePrimitiveType - "moment(#{src}, \"YYYY-MM-DD\").toDate()" - when AST::DateTimePrimitiveType - "moment.utc(#{src}, \"YYYY-MM-DDTHH:mm:ss.SSS\").toDate()" - when AST::BytesPrimitiveType - "Buffer.from(#{src}, \"base64\")" - when AST::VoidPrimitiveType - "undefined" - when AST::OptionalType - "#{src} === null || #{src} === undefined ? null : #{type_from_json(t.base, src)}" - when AST::ArrayType - inner = type_from_json(t.base, "e") - inner[0] == '{' ? "#{src}.map((e: any) => (#{inner}))" : "#{src}.map((e: any) => #{inner})" - when AST::StructType - String::Builder.build do |io| - io << "{\n" - t.fields.each do |field| - io << ident "#{field.name}: #{type_from_json(field.type, "#{src}.#{field.name}")}," - io << "\n" - end - io << "}" - end - when AST::EnumType - "#{src}" - when AST::TypeReference - type_from_json(t.type, src) - else - raise "Unknown type" - end - end - - def type_to_json(t : AST::Type, src : String) - case t - when AST::StringPrimitiveType, AST::IntPrimitiveType, AST::UIntPrimitiveType, AST::FloatPrimitiveType, AST::BoolPrimitiveType - "#{src}" - when AST::DatePrimitiveType - "moment(#{src}).format(\"YYYY-MM-DD\")" - when AST::DateTimePrimitiveType - "moment.utc(#{src}).format(\"YYYY-MM-DDTHH:mm:ss.SSS\")" - when AST::BytesPrimitiveType - "#{src}.toString(\"base64\")" - when AST::VoidPrimitiveType - "null" - when AST::OptionalType - "#{src} === null || #{src} === undefined ? null : #{type_to_json(t.base, src)}" - when AST::ArrayType - inner = type_to_json(t.base, "e") - inner[0] == '{' ? "#{src}.map(e => (#{inner}))" : "#{src}.map(e => #{inner})" - when AST::StructType - String::Builder.build do |io| - io << "{\n" - t.fields.each do |field| - io << ident "#{field.name}: #{type_to_json(field.type, "#{src}.#{field.name}")}," - io << "\n" - end - io << "}" - end - when AST::EnumType - "#{src}" - when AST::TypeReference - type_to_json(t.type, src) - else - raise "Unknown type" - end - end end diff --git a/src/target_typescript_nodeserver.cr b/src/target_typescript_nodeserver.cr index 23795ff..3fd6469 100644 --- a/src/target_typescript_nodeserver.cr +++ b/src/target_typescript_nodeserver.cr @@ -42,11 +42,11 @@ END @ast.operations.each do |op| @io << " " << op.pretty_name << ": async (ctx: Context, args: any) => {\n" op.args.each do |arg| - @io << ident ident "const #{arg.name} = #{type_from_json(arg.type, "args.#{arg.name}")};" + @io << ident ident "const #{arg.name} = #{arg.type.typescript_decode("args.#{arg.name}")};" @io << "\n" end @io << " const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" - @io << ident ident "return " + type_to_json(op.return_type, "ret") + ";" + @io << ident ident "return " + op.return_type.typescript_encode("ret") + ";" @io << "\n" @io << " },\n" end @@ -304,7 +304,7 @@ END end def operation_args(op : AST::Operation) - args = ["ctx: Context"] + op.args.map {|arg| "#{arg.name}: #{native_type arg.type}" } + args = ["ctx: Context"] + op.args.map {|arg| "#{arg.name}: #{arg.type.typescript_native_type}" } "(#{args.join(", ")})" end diff --git a/src/target_typescript_web.cr b/src/target_typescript_web.cr index e4a9475..fd03c8e 100644 --- a/src/target_typescript_web.cr +++ b/src/target_typescript_web.cr @@ -30,7 +30,7 @@ END if op.args.size > 0 @io << " const args = {\n" op.args.each do |arg| - @io << ident ident "#{arg.name}: #{type_to_json(arg.type, arg.name)}," + @io << ident ident "#{arg.name}: #{arg.type.typescript_encode(arg.name)}," @io << "\n" end @io << " };\n" @@ -39,7 +39,7 @@ END @io << " " @io << "const ret = " unless op.return_type.is_a? AST::VoidPrimitiveType @io << "await makeRequest({name: #{op.pretty_name.inspect}, #{op.args.size > 0 ? "args" : "args: {}"}});\n" - @io << ident "return " + type_from_json(op.return_type, "ret") + ";" + @io << ident "return " + op.return_type.typescript_decode("ret") + ";" @io << "\n" @io << "}\n\n" end @@ -149,8 +149,12 @@ async function makeRequest({name, args}: {name: string, args: any}) { END end - def native_type(t : AST::OptionalType) - native_type(t.base) + " | null | undefined" + def native_type(t : AST::Type) + if t.is_a? AST::OptionalType + t.typescript_native_type + " | undefined" + else + t.typescript_native_type + end end end From b3a98006e3c2422b6e87e0658caa32be666c2be1 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 22 Oct 2017 18:41:52 -0300 Subject: [PATCH 334/625] Remove base codegen methods --- src/codegen_types/type.cr | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/codegen_types/type.cr b/src/codegen_types/type.cr index c283e77..3c0ee72 100644 --- a/src/codegen_types/type.cr +++ b/src/codegen_types/type.cr @@ -1,15 +1,4 @@ module AST class Type - def typescript_decode(expr) - raise "TODO: #{self.class}" - end - - def typescript_encode(expr) - raise "TODO: #{self.class}" - end - - def typescript_native_type - raise "TODO: #{self.class}" - end end end From 5871d6be897e4890725e9a92d08fa27445996929 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 22 Oct 2017 18:56:47 -0300 Subject: [PATCH 335/625] Move struct and enum declaration to type fiels --- src/codegen_types/enum.cr | 4 ++++ src/codegen_types/struct.cr | 10 ++++++++++ src/target_typescript.cr | 14 -------------- src/target_typescript_nodeserver.cr | 4 ++-- src/target_typescript_web.cr | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index 544a371..6ddf72f 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -11,5 +11,9 @@ module AST def typescript_native_type name end + + def typescript_definition + "export type #{name} = #{values.map(&.inspect).join(" | ")};" + end end end diff --git a/src/codegen_types/struct.cr b/src/codegen_types/struct.cr index fe48a45..b003f24 100644 --- a/src/codegen_types/struct.cr +++ b/src/codegen_types/struct.cr @@ -23,5 +23,15 @@ module AST def typescript_native_type name end + + def typescript_definition + String.build do |io| + io << "export interface #{name} {\n" + fields.each do |field| + io << " #{field.name}: #{field.type.typescript_native_type};\n" + end + io << "}" + end + end end end diff --git a/src/target_typescript.cr b/src/target_typescript.cr index 4dc0e46..711ecd3 100644 --- a/src/target_typescript.cr +++ b/src/target_typescript.cr @@ -1,20 +1,6 @@ require "./target" abstract class TypeScriptTarget < Target - def generate_struct_type(t) - String.build do |io| - io << "export interface #{t.name} {\n" - t.fields.each do |field| - io << ident "#{field.name}: #{field.type.typescript_native_type};\n" - end - io << "}" - end - end - - def generate_enum_type(t) - "export type #{t.name} = #{t.values.map(&.inspect).join(" | ")};" - end - def operation_ret(op : AST::GetOperation | AST::FunctionOperation) op.return_type.is_a?(AST::VoidPrimitiveType) ? "void" : op.return_type.typescript_native_type end diff --git a/src/target_typescript_nodeserver.cr b/src/target_typescript_nodeserver.cr index 3fd6469..cd3733c 100644 --- a/src/target_typescript_nodeserver.cr +++ b/src/target_typescript_nodeserver.cr @@ -29,12 +29,12 @@ END @io << "};\n\n" @ast.struct_types.each do |t| - @io << generate_struct_type(t) + @io << t.typescript_definition @io << "\n\n" end @ast.enum_types.each do |t| - @io << generate_enum_type(t) + @io << t.typescript_definition @io << "\n\n" end diff --git a/src/target_typescript_web.cr b/src/target_typescript_web.cr index fd03c8e..9174cde 100644 --- a/src/target_typescript_web.cr +++ b/src/target_typescript_web.cr @@ -16,12 +16,12 @@ export function setStaging(use: boolean) { END @ast.struct_types.each do |t| - @io << generate_struct_type(t) + @io << t.typescript_definition @io << "\n\n" end @ast.enum_types.each do |t| - @io << generate_enum_type(t) + @io << t.typescript_definition @io << "\n\n" end From 21e13dca8ca8978db1c8b5bdb8eebcbd5f355670 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 22 Oct 2017 19:02:14 -0300 Subject: [PATCH 336/625] Move lexer/parser to syntax dir --- main.cr | 4 +--- spec/lexer_spec.cr | 2 +- spec/parser_spec.cr | 6 +++--- src/{ => syntax}/ast_to_s.cr | 2 +- src/{ => syntax}/lexer.cr | 0 src/{ => syntax}/parser.cr | 4 ++-- src/{ => syntax}/token.cr | 0 src/target.cr | 2 -- 8 files changed, 8 insertions(+), 12 deletions(-) rename src/{ => syntax}/ast_to_s.cr (99%) rename src/{ => syntax}/lexer.cr (100%) rename src/{ => syntax}/parser.cr (99%) rename src/{ => syntax}/token.cr (100%) diff --git a/main.cr b/main.cr index 1e9afc5..2c0ed0d 100644 --- a/main.cr +++ b/main.cr @@ -1,6 +1,4 @@ -require "./src/lexer" -require "./src/parser" -require "./src/ast_to_s" +require "./src/syntax/parser" require "./src/target_java_android" require "./src/target_swift_ios" require "./src/target_typescript_nodeserver" diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index 479210c..4435653 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -1,5 +1,5 @@ require "spec" -require "../src/lexer" +require "../src/syntax/lexer" describe Lexer do it_lexes "", [] of Token diff --git a/spec/parser_spec.cr b/spec/parser_spec.cr index d4a9ba2..4fd320c 100644 --- a/spec/parser_spec.cr +++ b/spec/parser_spec.cr @@ -1,7 +1,7 @@ require "spec" -require "../src/lexer" -require "../src/parser" -require "../src/ast_to_s" +require "../src/syntax/lexer" +require "../src/syntax/parser" +require "../src/syntax/ast_to_s" def clear(code) code = code.strip diff --git a/src/ast_to_s.cr b/src/syntax/ast_to_s.cr similarity index 99% rename from src/ast_to_s.cr rename to src/syntax/ast_to_s.cr index f77edc6..37af9c7 100644 --- a/src/ast_to_s.cr +++ b/src/syntax/ast_to_s.cr @@ -1,4 +1,4 @@ -require "./ast" +require "../ast" module AST class StringPrimitiveType diff --git a/src/lexer.cr b/src/syntax/lexer.cr similarity index 100% rename from src/lexer.cr rename to src/syntax/lexer.cr diff --git a/src/parser.cr b/src/syntax/parser.cr similarity index 99% rename from src/parser.cr rename to src/syntax/parser.cr index 4e69d0b..8e76da0 100644 --- a/src/parser.cr +++ b/src/syntax/parser.cr @@ -1,6 +1,6 @@ require "./lexer" -require "./ast" -require "./ast_semantic" +require "../ast" +require "../ast_semantic" class Parser class ParserException < Exception diff --git a/src/token.cr b/src/syntax/token.cr similarity index 100% rename from src/token.cr rename to src/syntax/token.cr diff --git a/src/target.cr b/src/target.cr index 6a1299b..cff74d4 100644 --- a/src/target.cr +++ b/src/target.cr @@ -1,6 +1,4 @@ require "./ast" -require "./lexer" -require "./parser" require "./codegen_types/**" abstract class Target From eead4bc68deaf70ac4ff7d1414f8822f7e8b4e54 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 22 Oct 2017 19:27:52 -0300 Subject: [PATCH 337/625] Move semantic pass to dir, and split code into more files --- main.cr | 1 + src/ast_semantic.cr | 231 ------------------ src/semantic/ast_semantic.cr | 71 ++++++ src/semantic/check_dont_return_secret.cr | 29 +++ src/semantic/check_empty_enum.cr | 12 + ...check_naming_for_getters_returning_bool.cr | 16 ++ src/semantic/check_no_recursive_types.cr | 29 +++ src/semantic/collect_struct_and_enum_types.cr | 15 ++ src/semantic/give_struct_and_enum_names.cr | 33 +++ src/semantic/match_type_definitions.cr | 14 ++ src/semantic/visitor.cr | 45 ++++ src/syntax/parser.cr | 1 - 12 files changed, 265 insertions(+), 232 deletions(-) delete mode 100644 src/ast_semantic.cr create mode 100644 src/semantic/ast_semantic.cr create mode 100644 src/semantic/check_dont_return_secret.cr create mode 100644 src/semantic/check_empty_enum.cr create mode 100644 src/semantic/check_naming_for_getters_returning_bool.cr create mode 100644 src/semantic/check_no_recursive_types.cr create mode 100644 src/semantic/collect_struct_and_enum_types.cr create mode 100644 src/semantic/give_struct_and_enum_names.cr create mode 100644 src/semantic/match_type_definitions.cr create mode 100644 src/semantic/visitor.cr diff --git a/main.cr b/main.cr index 2c0ed0d..23939f3 100644 --- a/main.cr +++ b/main.cr @@ -1,4 +1,5 @@ require "./src/syntax/parser" +require "./src/semantic/ast_semantic" require "./src/target_java_android" require "./src/target_swift_ios" require "./src/target_typescript_nodeserver" diff --git a/src/ast_semantic.cr b/src/ast_semantic.cr deleted file mode 100644 index c5e019e..0000000 --- a/src/ast_semantic.cr +++ /dev/null @@ -1,231 +0,0 @@ - -module Semantic - class Visitor - def initialize(@ast : AST::ApiDescription) - end - - def visit(node : AST::ApiDescription) - node.type_definitions.each {|e| visit e } - node.operations.each {|e| visit e } - end - - def visit(op : AST::Operation) - op.args.each {|arg| visit arg } - visit op.return_type - end - - def visit(field : AST::Field) - visit field.type - end - - def visit(definition : AST::TypeDefinition) - visit definition.type - end - - def visit(t : AST::StructType) - t.fields.each {|field| visit field } - end - - def visit(t : AST::ArrayType) - visit t.base - end - - def visit(t : AST::OptionalType) - visit t.base - end - - def visit(t : AST::PrimitiveType | AST::EnumType | AST::TypeReference) - end - end - - class CheckEveryTypeDefined < Visitor - def visit(ref : AST::TypeReference) - definition = @ast.type_definitions.find {|t| t.name == ref.name } - unless definition - raise "Could not find type '#{ref.name}'" - end - ref.type = definition.type - super - end - end - - class CheckNoRecursiveTypes < Visitor - @path = [] of String - @root_type : AST::Type? - - def visit(definition : AST::TypeDefinition) - @path = [definition.name] - @root_type = definition.type - super - @root_type = nil - end - - def visit(field : AST::Field) - @path.push field.name - super - @path.pop - end - - def visit(ref : AST::TypeReference) - if ref.type == @root_type - raise "Detected type recursion: #{@path.join(".")}" - end - visit ref.type - super - end - end - - class CheckDontReturnSecret < Visitor - @inreturn = false - @path = [] of String - - def visit(op : AST::Operation) - @inreturn = true - @path.push op.name + "()" - visit op.return_type - @path.pop - @inreturn = false - end - - def visit(ref : AST::TypeReference) - visit ref.type - end - - def visit(field : AST::Field) - @path.push field.name - if @inreturn && field.secret - raise "Can't return a secret value at #{@path.join(".")}" - end - super - @path.pop - end - end - - class CheckNamingForGettersReturningBool < Visitor - def visit(op : AST::GetOperation) - super - is_bool = op.return_type.is_a? AST::BoolPrimitiveType - has_bool_name = op.name =~ /^(is|has|can|may|should)/ - if is_bool && !has_bool_name - raise "Get operation '#{op.name}' returns bool but isn't named accordingly" - elsif !is_bool && has_bool_name - raise "Get operation '#{op.name}' doesn't return bool but its name suggest it does" - end - end - end - - class CheckEmptyEnum < Visitor - def visit(t : AST::EnumType) - super - if t.values.size == 0 - raise "Enum '#{t.name}' is empty" - end - end - end - - class GiveStructAndEnumTypeNames < Visitor - @path = [] of String - - def visit(definition : AST::TypeDefinition) - @path = [definition.name] - super - end - - def visit(operation : AST::Operation) - @path = [operation.name] - super - end - - def visit(field : AST::Field) - @path.push field.name[0].upcase + field.name[1..-1] - super - @path.pop - end - - def visit(t : AST::StructType) - t.name = @path.join("") - super - end - - def visit(t : AST::EnumType) - t.name = @path.join("") - super - end - end - - class CollectStructAndEnumTypes < Visitor - def visit(t : AST::StructType) - @ast.struct_types << t - super - end - - def visit(t : AST::EnumType) - @ast.enum_types << t - super - end - end -end - -module AST - class ApiDescription - property struct_types = [] of AST::StructType - property enum_types = [] of AST::EnumType - - def semantic - errors << "Fatal" - errors << "Connection" - error_types_enum = AST::EnumType.new - error_types_enum.values = errors - error_types_enum_def = AST::TypeDefinition.new - error_types_enum_def.name = "ErrorType" - error_types_enum_def.type = error_types_enum - type_definitions << error_types_enum_def - - op = AST::FunctionOperation.new - op.name = "ping" - op.return_type = AST::StringPrimitiveType.new - operations << op - - op = AST::FunctionOperation.new - op.name = "setPushToken" - op.args = [AST::Field.new] - op.args[0].name = "token" - op.args[0].type = AST::StringPrimitiveType.new - op.return_type = AST::VoidPrimitiveType.new - operations << op - - # TODO: Topological Ordering: - Semantic::CheckEveryTypeDefined.new(self).visit(self) - Semantic::CheckNoRecursiveTypes.new(self).visit(self) - Semantic::CheckDontReturnSecret.new(self).visit(self) - Semantic::CheckNamingForGettersReturningBool.new(self).visit(self) - Semantic::GiveStructAndEnumTypeNames.new(self).visit(self) - Semantic::CheckEmptyEnum.new(self).visit(self) - Semantic::CollectStructAndEnumTypes.new(self).visit(self) - end - end - - class TypeReference - property! type : Type - end - - class StructType - property! name : String - end - - class EnumType - property! name : String - end - - abstract class Operation - def pretty_name - name - end - end - - class GetOperation < Operation - def pretty_name - return_type.is_a?(BoolPrimitiveType) ? name : "get" + name[0].upcase + name[1..-1] - end - end -end diff --git a/src/semantic/ast_semantic.cr b/src/semantic/ast_semantic.cr new file mode 100644 index 0000000..5f3c570 --- /dev/null +++ b/src/semantic/ast_semantic.cr @@ -0,0 +1,71 @@ +require "./visitor" +require "./match_type_definitions" +require "./check_no_recursive_types" +require "./check_dont_return_secret" +require "./check_naming_for_getters_returning_bool" +require "./check_empty_enum" +require "./give_struct_and_enum_names" +require "./collect_struct_and_enum_types" + +module AST + class ApiDescription + property struct_types = [] of AST::StructType + property enum_types = [] of AST::EnumType + + def semantic + errors << "Fatal" + errors << "Connection" + error_types_enum = AST::EnumType.new + error_types_enum.values = errors + error_types_enum_def = AST::TypeDefinition.new + error_types_enum_def.name = "ErrorType" + error_types_enum_def.type = error_types_enum + type_definitions << error_types_enum_def + + op = AST::FunctionOperation.new + op.name = "ping" + op.return_type = AST::StringPrimitiveType.new + operations << op + + op = AST::FunctionOperation.new + op.name = "setPushToken" + op.args = [AST::Field.new] + op.args[0].name = "token" + op.args[0].type = AST::StringPrimitiveType.new + op.return_type = AST::VoidPrimitiveType.new + operations << op + + Semantic::MatchTypeDefinitions.visit(self) + Semantic::CheckNoRecursiveTypes.visit(self) + Semantic::CheckDontReturnSecret.visit(self) + Semantic::CheckNamingForGettersReturningBool.visit(self) + Semantic::GiveStructAndEnumNames.visit(self) + Semantic::CheckEmptyEnum.visit(self) + Semantic::CollectStructAndEnumTypes.visit(self) + end + end + + class TypeReference + property! type : Type + end + + class StructType + property! name : String + end + + class EnumType + property! name : String + end + + abstract class Operation + def pretty_name + name + end + end + + class GetOperation < Operation + def pretty_name + return_type.is_a?(BoolPrimitiveType) ? name : "get" + name[0].upcase + name[1..-1] + end + end +end diff --git a/src/semantic/check_dont_return_secret.cr b/src/semantic/check_dont_return_secret.cr new file mode 100644 index 0000000..5658cb6 --- /dev/null +++ b/src/semantic/check_dont_return_secret.cr @@ -0,0 +1,29 @@ +require "./visitor" + +module Semantic + class CheckDontReturnSecret < Visitor + @inreturn = false + @path = [] of String + + def visit(op : AST::Operation) + @inreturn = true + @path.push op.name + "()" + visit op.return_type + @path.pop + @inreturn = false + end + + def visit(ref : AST::TypeReference) + visit ref.type + end + + def visit(field : AST::Field) + @path.push field.name + if @inreturn && field.secret + raise "Can't return a secret value at #{@path.join(".")}" + end + super + @path.pop + end + end +end diff --git a/src/semantic/check_empty_enum.cr b/src/semantic/check_empty_enum.cr new file mode 100644 index 0000000..0dd2259 --- /dev/null +++ b/src/semantic/check_empty_enum.cr @@ -0,0 +1,12 @@ +require "./visitor" + +module Semantic + class CheckEmptyEnum < Visitor + def visit(t : AST::EnumType) + super + if t.values.size == 0 + raise "Enum '#{t.name}' is empty" + end + end + end +end diff --git a/src/semantic/check_naming_for_getters_returning_bool.cr b/src/semantic/check_naming_for_getters_returning_bool.cr new file mode 100644 index 0000000..a5adda1 --- /dev/null +++ b/src/semantic/check_naming_for_getters_returning_bool.cr @@ -0,0 +1,16 @@ +require "./visitor" + +module Semantic + class CheckNamingForGettersReturningBool < Visitor + def visit(op : AST::GetOperation) + super + is_bool = op.return_type.is_a? AST::BoolPrimitiveType + has_bool_name = op.name =~ /^(is|has|can|may|should)/ + if is_bool && !has_bool_name + raise "Get operation '#{op.name}' returns bool but isn't named accordingly" + elsif !is_bool && has_bool_name + raise "Get operation '#{op.name}' doesn't return bool but its name suggest it does" + end + end + end +end diff --git a/src/semantic/check_no_recursive_types.cr b/src/semantic/check_no_recursive_types.cr new file mode 100644 index 0000000..b39aa64 --- /dev/null +++ b/src/semantic/check_no_recursive_types.cr @@ -0,0 +1,29 @@ +require "./visitor" + +module Semantic + class CheckNoRecursiveTypes < Visitor + @path = [] of String + @root_type : AST::Type? + + def visit(definition : AST::TypeDefinition) + @path = [definition.name] + @root_type = definition.type + super + @root_type = nil + end + + def visit(field : AST::Field) + @path.push field.name + super + @path.pop + end + + def visit(ref : AST::TypeReference) + if ref.type == @root_type + raise "Detected type recursion: #{@path.join(".")}" + end + visit ref.type + super + end + end +end diff --git a/src/semantic/collect_struct_and_enum_types.cr b/src/semantic/collect_struct_and_enum_types.cr new file mode 100644 index 0000000..5f99808 --- /dev/null +++ b/src/semantic/collect_struct_and_enum_types.cr @@ -0,0 +1,15 @@ +require "./visitor" + +module Semantic + class CollectStructAndEnumTypes < Visitor + def visit(t : AST::StructType) + @ast.struct_types << t + super + end + + def visit(t : AST::EnumType) + @ast.enum_types << t + super + end + end +end diff --git a/src/semantic/give_struct_and_enum_names.cr b/src/semantic/give_struct_and_enum_names.cr new file mode 100644 index 0000000..9e35be3 --- /dev/null +++ b/src/semantic/give_struct_and_enum_names.cr @@ -0,0 +1,33 @@ +require "./visitor" + +module Semantic + class GiveStructAndEnumNames < Visitor + @path = [] of String + + def visit(definition : AST::TypeDefinition) + @path = [definition.name] + super + end + + def visit(operation : AST::Operation) + @path = [operation.name] + super + end + + def visit(field : AST::Field) + @path.push field.name[0].upcase + field.name[1..-1] + super + @path.pop + end + + def visit(t : AST::StructType) + t.name = @path.join("") + super + end + + def visit(t : AST::EnumType) + t.name = @path.join("") + super + end + end +end diff --git a/src/semantic/match_type_definitions.cr b/src/semantic/match_type_definitions.cr new file mode 100644 index 0000000..eeed630 --- /dev/null +++ b/src/semantic/match_type_definitions.cr @@ -0,0 +1,14 @@ +require "./visitor" + +module Semantic + class MatchTypeDefinitions < Visitor + def visit(ref : AST::TypeReference) + definition = @ast.type_definitions.find {|t| t.name == ref.name } + unless definition + raise "Could not find type '#{ref.name}'" + end + ref.type = definition.type + super + end + end +end diff --git a/src/semantic/visitor.cr b/src/semantic/visitor.cr new file mode 100644 index 0000000..fbdc777 --- /dev/null +++ b/src/semantic/visitor.cr @@ -0,0 +1,45 @@ +require "../ast" + +module Semantic + class Visitor + def self.visit(ast : AST::ApiDescription) + new(ast).visit(ast) + end + + def initialize(@ast : AST::ApiDescription) + end + + def visit(node : AST::ApiDescription) + node.type_definitions.each {|e| visit e } + node.operations.each {|e| visit e } + end + + def visit(op : AST::Operation) + op.args.each {|arg| visit arg } + visit op.return_type + end + + def visit(field : AST::Field) + visit field.type + end + + def visit(definition : AST::TypeDefinition) + visit definition.type + end + + def visit(t : AST::StructType) + t.fields.each {|field| visit field } + end + + def visit(t : AST::ArrayType) + visit t.base + end + + def visit(t : AST::OptionalType) + visit t.base + end + + def visit(t : AST::PrimitiveType | AST::EnumType | AST::TypeReference) + end + end +end diff --git a/src/syntax/parser.cr b/src/syntax/parser.cr index 8e76da0..9e9d8c1 100644 --- a/src/syntax/parser.cr +++ b/src/syntax/parser.cr @@ -1,6 +1,5 @@ require "./lexer" require "../ast" -require "../ast_semantic" class Parser class ParserException < Exception From 03241742ad39692df8bf675cdc38505227ccd376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Mon, 23 Oct 2017 06:34:35 -0300 Subject: [PATCH 338/625] Fix error hooks parameters --- src/target_typescript_web.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target_typescript_web.cr b/src/target_typescript_web.cr index 9174cde..b5443ab 100644 --- a/src/target_typescript_web.cr +++ b/src/target_typescript_web.cr @@ -129,12 +129,12 @@ async function makeRequest({name, args}: {name: string, args: any}) { listenersDict["success"].forEach(hook => hook(response.result, name, args)); } else { reject(response.error); - listenersDict["fail"].forEach(hook => hook(response.error, name, args)); + listenersDict["fail"].forEach(hook => hook(new Error((response.error || "").toString()), name, args)); } } catch (e) { console.error(e); reject({type: "Fatal", message: e.toString()}); - listenersDict["fatal"].forEach(hook => hook(response.error, name, args)); + listenersDict["fatal"].forEach(hook => hook(e, name, args)); } } catch (e) { console.error(e); From 218b2c7446668d92f47d03d7b8e31b0698d2c4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Mon, 23 Oct 2017 08:55:29 -0300 Subject: [PATCH 339/625] Revert --- src/target_typescript_web.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target_typescript_web.cr b/src/target_typescript_web.cr index b5443ab..ea2f289 100644 --- a/src/target_typescript_web.cr +++ b/src/target_typescript_web.cr @@ -129,7 +129,7 @@ async function makeRequest({name, args}: {name: string, args: any}) { listenersDict["success"].forEach(hook => hook(response.result, name, args)); } else { reject(response.error); - listenersDict["fail"].forEach(hook => hook(new Error((response.error || "").toString()), name, args)); + listenersDict["fail"].forEach(hook => hook(response.error, name, args)); } } catch (e) { console.error(e); From 2cf3f769250edb789776c3620ca8c82445487944 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 23 Oct 2017 08:55:46 -0300 Subject: [PATCH 340/625] Add few more lexer tests --- spec/lexer_spec.cr | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index 4435653..3da8ba5 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -10,9 +10,7 @@ describe Lexer do it_doesnt_lex "23", "Unexpected character '2' at -:1:1" - it_lexes "type", [ - IdentifierToken.new("type") - ] + it_doesnt_lex "2a", "Unexpected character '2' at -:1:1" it_lexes "type2", [ IdentifierToken.new("type2") @@ -67,11 +65,21 @@ describe Lexer do IdentifierToken.new("errorh") ] + %w[enum type error import get function].each do |kw| + it_lexes kw, [ + IdentifierToken.new(kw) + ] + end + %w[string int uint date datetime bytes float bool].each do |primitive| it_lexes primitive, [ PrimitiveTypeToken.new(primitive) ] + it_lexes primitive, [ + IdentifierToken.new(primitive) + ] + it_lexes primitive + "a", [ IdentifierToken.new(primitive + "a") ] From 59a47f94f0fe8e94dd96c57b92a681b295e58187 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 23 Oct 2017 16:18:46 -0300 Subject: [PATCH 341/625] Fix lexer to count lines --- src/syntax/lexer.cr | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index 5e24710..c714d44 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -51,9 +51,14 @@ class Lexer case current_char when '\0' return nil - when ' ', '\n', '\r' ,'\t' + when ' ', '\r' ,'\t' next_char return next_token + when '\n' + next_char + @column = 1 + @line += 1 + return next_token when '/' case next_char when '/' @@ -150,7 +155,9 @@ class Lexer when "import"; ImportKeywordToken.new when "get"; GetKeywordToken.new when "function"; FunctionKeywordToken.new - when "bool", "int", "uint", "float", "string", "date", "datetime", "bytes" + when "bool", "int", "uint", "float", "string", "date", "datetime", "bytes", + "money", "cpf", "cnpj", "email", "phone", "cep", "latlng", "url", + "uuid", "hex", "base64", "safehtml", "xml" PrimitiveTypeToken.new(str) else IdentifierToken.new(str) From 9d49ebe151920e0739fe2ba607c57f7237cea526 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 24 Oct 2017 11:06:41 -0300 Subject: [PATCH 342/625] Fix parse of dates on Android target --- src/target_java_android.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/target_java_android.cr b/src/target_java_android.cr index 0fa9e11..e1c1900 100644 --- a/src/target_java_android.cr +++ b/src/target_java_android.cr @@ -119,7 +119,7 @@ END @io << <<-END } END -# END CREATING API'S CALLS INTERFACE +# END CREATING API'S CALLS INTERFACE @ast.struct_types.each do |t| @io << ident generate_struct_type(t) @@ -133,8 +133,8 @@ END # INIT CREATING CALLS @io << <<-END - - public static class Calls implements APICalls { + + public static class Calls implements APICalls { END @@ -350,7 +350,7 @@ END static SecureRandom random = new SecureRandom(); static boolean initialized = false; static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); - static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US); + static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); static Application application; static { From 1677a5aec0e604b914b81055d5b5936e105d2d4f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 25 Oct 2017 13:38:39 -0300 Subject: [PATCH 343/625] Remove normalize() for now... until zig fixes it --- src/codegen_types/string.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index 035c090..10a81a3 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -1,11 +1,11 @@ module AST class StringPrimitiveType def typescript_decode(expr) - "#{expr}.normalize()" + "#{expr}" end def typescript_encode(expr) - "#{expr}.normalize()" + "#{expr}" end def typescript_native_type From d3623a278deb710ce2fec7d13703df49537d63bf Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 25 Oct 2017 13:48:10 -0300 Subject: [PATCH 344/625] add normalize back --- src/codegen_types/string.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index 10a81a3..035c090 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -1,11 +1,11 @@ module AST class StringPrimitiveType def typescript_decode(expr) - "#{expr}" + "#{expr}.normalize()" end def typescript_encode(expr) - "#{expr}" + "#{expr}.normalize()" end def typescript_native_type From 96996f4ac5177f80f35ca8e242c68e9b0e019905 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 25 Oct 2017 14:54:18 -0300 Subject: [PATCH 345/625] Remove normalize --- src/codegen_types/string.cr | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index 035c090..5bb08cf 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -1,11 +1,13 @@ module AST class StringPrimitiveType def typescript_decode(expr) - "#{expr}.normalize()" + "#{expr}" + # "#{expr}.normalize()" end def typescript_encode(expr) - "#{expr}.normalize()" + "#{expr}" + # "#{expr}.normalize()" end def typescript_native_type From af45b8c7d17f3ff51c2a3d9c5d296b136073a4ba Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 25 Oct 2017 14:55:10 -0300 Subject: [PATCH 346/625] Remove unused function --- src/target_typescript_web.cr | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/target_typescript_web.cr b/src/target_typescript_web.cr index ea2f289..24c3126 100644 --- a/src/target_typescript_web.cr +++ b/src/target_typescript_web.cr @@ -148,14 +148,6 @@ async function makeRequest({name, args}: {name: string, args: any}) { END end - - def native_type(t : AST::Type) - if t.is_a? AST::OptionalType - t.typescript_native_type + " | undefined" - else - t.typescript_native_type - end - end end Target.register(TypeScriptWebTarget, target_name: "typescript_web") From 4ed6c5ca1a051be015e466845aba0051fc721f81 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 08:39:54 -0300 Subject: [PATCH 347/625] crystal tool format --- src/ast.cr | 6 ++- src/semantic/match_type_definitions.cr | 2 +- src/semantic/visitor.cr | 8 ++-- src/syntax/ast_to_s.cr | 4 +- src/syntax/lexer.cr | 38 +++++++++---------- src/syntax/parser.cr | 26 ++++++------- src/syntax/token.cr | 9 +++-- src/target.cr | 2 +- src/target_java.cr | 48 ++++++++++++------------ src/target_java_android.cr | 52 +++++++++++++------------- src/target_swift.cr | 20 +++++----- src/target_swift_ios.cr | 52 ++++++++++++-------------- src/target_typescript.cr | 2 +- src/target_typescript_nodeserver.cr | 11 +++--- 14 files changed, 141 insertions(+), 139 deletions(-) diff --git a/src/ast.cr b/src/ast.cr index 0af7ef8..375b56a 100644 --- a/src/ast.cr +++ b/src/ast.cr @@ -1,4 +1,3 @@ - module AST abstract class Type end @@ -35,12 +34,14 @@ module AST class OptionalType < Type property base + def initialize(@base : Type) end end class ArrayType < Type property base + def initialize(@base : Type) end end @@ -60,6 +61,7 @@ module AST class TypeReference < Type property name + def initialize(@name : String) end end @@ -96,4 +98,4 @@ module AST class FunctionOperation < Operation end -end \ No newline at end of file +end diff --git a/src/semantic/match_type_definitions.cr b/src/semantic/match_type_definitions.cr index eeed630..fe7cb82 100644 --- a/src/semantic/match_type_definitions.cr +++ b/src/semantic/match_type_definitions.cr @@ -3,7 +3,7 @@ require "./visitor" module Semantic class MatchTypeDefinitions < Visitor def visit(ref : AST::TypeReference) - definition = @ast.type_definitions.find {|t| t.name == ref.name } + definition = @ast.type_definitions.find { |t| t.name == ref.name } unless definition raise "Could not find type '#{ref.name}'" end diff --git a/src/semantic/visitor.cr b/src/semantic/visitor.cr index fbdc777..25a7d5e 100644 --- a/src/semantic/visitor.cr +++ b/src/semantic/visitor.cr @@ -10,12 +10,12 @@ module Semantic end def visit(node : AST::ApiDescription) - node.type_definitions.each {|e| visit e } - node.operations.each {|e| visit e } + node.type_definitions.each { |e| visit e } + node.operations.each { |e| visit e } end def visit(op : AST::Operation) - op.args.each {|arg| visit arg } + op.args.each { |arg| visit arg } visit op.return_type end @@ -28,7 +28,7 @@ module Semantic end def visit(t : AST::StructType) - t.fields.each {|field| visit field } + t.fields.each { |field| visit field } end def visit(t : AST::ArrayType) diff --git a/src/syntax/ast_to_s.cr b/src/syntax/ast_to_s.cr index 37af9c7..483ded8 100644 --- a/src/syntax/ast_to_s.cr +++ b/src/syntax/ast_to_s.cr @@ -133,7 +133,7 @@ module AST io << "get " << name << "(" args.each_with_index do |arg, i| arg.to_s(io) - io << ", " if i != args.size-1 + io << ", " if i != args.size - 1 end io << ")" unless return_type.is_a? VoidPrimitiveType @@ -148,7 +148,7 @@ module AST io << "function " << name << "(" args.each_with_index do |arg, i| arg.to_s(io) - io << ", " if i != args.size-1 + io << ", " if i != args.size - 1 end io << ")" unless return_type.is_a? VoidPrimitiveType diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index c714d44..952a526 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -51,7 +51,7 @@ class Lexer case current_char when '\0' return nil - when ' ', '\r' ,'\t' + when ' ', '\r', '\t' next_char return next_token when '\n' @@ -112,7 +112,7 @@ class Lexer next_char end - token = GlobalOptionToken.new(substring(@start_pos+1, pos-1)) + token = GlobalOptionToken.new(substring(@start_pos + 1, pos - 1)) end when '"' builder = String::Builder.new @@ -124,9 +124,9 @@ class Lexer case next_char when '\0' break - when 'n'; builder << '\n' - when 't'; builder << '\t' - when '"'; builder << '"' + when 'n' ; builder << '\n' + when 't' ; builder << '\t' + when '"' ; builder << '"' when '\\'; builder << '\\' else builder << current_char @@ -146,22 +146,22 @@ class Lexer next_char end - str = substring(@start_pos, pos-1) + str = substring(@start_pos, pos - 1) token = case str - when "error"; ErrorKeywordToken.new - when "enum"; EnumKeywordToken.new - when "type"; TypeKeywordToken.new - when "import"; ImportKeywordToken.new - when "get"; GetKeywordToken.new - when "function"; FunctionKeywordToken.new - when "bool", "int", "uint", "float", "string", "date", "datetime", "bytes", - "money", "cpf", "cnpj", "email", "phone", "cep", "latlng", "url", - "uuid", "hex", "base64", "safehtml", "xml" - PrimitiveTypeToken.new(str) - else - IdentifierToken.new(str) - end + when "error" ; ErrorKeywordToken.new + when "enum" ; EnumKeywordToken.new + when "type" ; TypeKeywordToken.new + when "import" ; ImportKeywordToken.new + when "get" ; GetKeywordToken.new + when "function"; FunctionKeywordToken.new + when "bool", "int", "uint", "float", "string", "date", "datetime", "bytes", + "money", "cpf", "cnpj", "email", "phone", "cep", "latlng", "url", + "uuid", "hex", "base64", "safehtml", "xml" + PrimitiveTypeToken.new(str) + else + IdentifierToken.new(str) + end end end diff --git a/src/syntax/parser.cr b/src/syntax/parser.cr index 9e9d8c1..150b8ae 100644 --- a/src/syntax/parser.cr +++ b/src/syntax/parser.cr @@ -62,7 +62,7 @@ class Parser macro multi_expect(*token_types) token = @token unless token - raise ParserException.new "Expected #{{{token_types.map{|t| t.stringify.gsub(/Token$/, "")}.join(" or ")}}}, but found end of file" + raise ParserException.new "Expected #{{{token_types.map { |t| t.stringify.gsub(/Token$/, "") }.join(" or ")}}}, but found end of file" end result = nil @@ -77,7 +77,7 @@ class Parser {% end %} unless result - raise ParserException.new "Expected #{{{token_types.map{|t| t.stringify.gsub(/Token$/, "")}.join(" or ")}}} at #{token.location}, but found #{token}" + raise ParserException.new "Expected #{{{token_types.map { |t| t.stringify.gsub(/Token$/, "") }.join(" or ")}}} at #{token.location}, but found #{token}" end result @@ -248,17 +248,17 @@ class Parser read_next_token when PrimitiveTypeToken result = case token.name - when "string"; AST::StringPrimitiveType.new - when "int"; AST::IntPrimitiveType.new - when "uint"; AST::UIntPrimitiveType.new - when "date"; AST::DatePrimitiveType.new - when "datetime"; AST::DateTimePrimitiveType.new - when "float"; AST::FloatPrimitiveType.new - when "bool"; AST::BoolPrimitiveType.new - when "bytes"; AST::BytesPrimitiveType.new - else - raise "BUG! Should handle primitive #{token.name}" - end + when "string" ; AST::StringPrimitiveType.new + when "int" ; AST::IntPrimitiveType.new + when "uint" ; AST::UIntPrimitiveType.new + when "date" ; AST::DatePrimitiveType.new + when "datetime"; AST::DateTimePrimitiveType.new + when "float" ; AST::FloatPrimitiveType.new + when "bool" ; AST::BoolPrimitiveType.new + when "bytes" ; AST::BytesPrimitiveType.new + else + raise "BUG! Should handle primitive #{token.name}" + end read_next_token else raise "never" diff --git a/src/syntax/token.cr b/src/syntax/token.cr index 7615560..26a0523 100644 --- a/src/syntax/token.cr +++ b/src/syntax/token.cr @@ -1,4 +1,3 @@ - class Token property! filename : String property! line : Int32 @@ -15,7 +14,7 @@ class Token def to_s(io) io << self.class.name.sub("Token", "") vars = [] of String - {% for ivar in @type.instance_vars.map(&.id).reject {|s| %w[filename line column].map(&.id).includes? s } %} + {% for ivar in @type.instance_vars.map(&.id).reject { |s| %w[filename line column].map(&.id).includes? s } %} vars << @{{ivar.id}} {% end %} vars.inspect(io) if vars.size > 0 @@ -70,6 +69,7 @@ end class PrimitiveTypeToken < Token property name : String def_equals name + def initialize(@name) end @@ -81,6 +81,7 @@ end class IdentifierToken < Token property name : String def_equals name + def initialize(@name) end end @@ -88,6 +89,7 @@ end class GlobalOptionToken < Token property name : String def_equals name + def initialize(@name) end end @@ -95,6 +97,7 @@ end class StringLiteralToken < Token property str : String def_equals str + def initialize(@str) end end @@ -127,4 +130,4 @@ class ArraySymbolToken < Token end class CommaSymbolToken < Token -end \ No newline at end of file +end diff --git a/src/target.cr b/src/target.cr index cff74d4..5cf7df5 100644 --- a/src/target.cr +++ b/src/target.cr @@ -30,6 +30,6 @@ abstract class Target end def ident(code) - code.split("\n").map {|line| " " + line}.join("\n").gsub(/\n\s+$/m, "\n") + code.split("\n").map { |line| " " + line }.join("\n").gsub(/\n\s+$/m, "\n") end end diff --git a/src/target_java.cr b/src/target_java.cr index 19d2fb5..d431436 100644 --- a/src/target_java.cr +++ b/src/target_java.cr @@ -8,12 +8,12 @@ abstract class JavaTarget < Target def mangle(ident) if %w[ - boolean class if int byte do for while void float double long char synchronized - instanceof extends implements interface abstract static public private protected - final import package throw throws catch finally try new null else return continue - break goto switch default case - Object Class - ].includes? ident + boolean class if int byte do for while void float double long char synchronized + instanceof extends implements interface abstract static public private protected + final import package throw throws catch finally try new null else return continue + break goto switch default case + Object Class + ].includes? ident "_" + ident else ident @@ -22,15 +22,15 @@ abstract class JavaTarget < Target def native_type_not_primitive(t : AST::PrimitiveType) case t - when AST::StringPrimitiveType; "String" - when AST::IntPrimitiveType; "Integer" - when AST::UIntPrimitiveType; "Integer" - when AST::FloatPrimitiveType; "Double" - when AST::DatePrimitiveType; "Calendar" + when AST::StringPrimitiveType ; "String" + when AST::IntPrimitiveType ; "Integer" + when AST::UIntPrimitiveType ; "Integer" + when AST::FloatPrimitiveType ; "Double" + when AST::DatePrimitiveType ; "Calendar" when AST::DateTimePrimitiveType; "Calendar" - when AST::BoolPrimitiveType; "Boolean" - when AST::BytesPrimitiveType; "byte[]" - when AST::VoidPrimitiveType; "void" + when AST::BoolPrimitiveType ; "Boolean" + when AST::BytesPrimitiveType ; "byte[]" + when AST::VoidPrimitiveType ; "void" else raise "BUG! Should handle primitive #{t.class}" end @@ -42,15 +42,15 @@ abstract class JavaTarget < Target def native_type(t : AST::PrimitiveType) case t - when AST::StringPrimitiveType; "String" - when AST::IntPrimitiveType; "int" - when AST::UIntPrimitiveType; "int" - when AST::FloatPrimitiveType; "double" - when AST::DatePrimitiveType; "Calendar" + when AST::StringPrimitiveType ; "String" + when AST::IntPrimitiveType ; "int" + when AST::UIntPrimitiveType ; "int" + when AST::FloatPrimitiveType ; "double" + when AST::DatePrimitiveType ; "Calendar" when AST::DateTimePrimitiveType; "Calendar" - when AST::BoolPrimitiveType; "boolean" - when AST::BytesPrimitiveType; "byte[]" - when AST::VoidPrimitiveType; "void" + when AST::BoolPrimitiveType ; "boolean" + when AST::BytesPrimitiveType ; "byte[]" + when AST::VoidPrimitiveType ; "void" else raise "BUG! Should handle primitive #{t.class}" end @@ -230,7 +230,7 @@ END when AST::StructType "#{mangle t.name}.fromJSON(#{obj}.getJSONObject(#{name}))" when AST::EnumType - "#{t.values.map {|v| "#{obj}.getString(#{name}).equals(#{v.inspect}) ? #{mangle t.name}.#{mangle v} : " }.join}null" + "#{t.values.map { |v| "#{obj}.getString(#{name}).equals(#{v.inspect}) ? #{mangle t.name}.#{mangle v} : " }.join}null" when AST::TypeReference type_from_json(t.type, obj, name) else @@ -258,7 +258,7 @@ END when AST::StructType "#{src}.toJSON()" when AST::EnumType - "#{t.values.map {|v| "#{src} == #{mangle t.name}.#{mangle v} ? #{v.inspect} : " }.join}\"\"" + "#{t.values.map { |v| "#{src} == #{mangle t.name}.#{mangle v} ? #{v.inspect} : " }.join}\"\"" when AST::TypeReference type_to_json(t.type, src) else diff --git a/src/target_java_android.cr b/src/target_java_android.cr index e1c1900..5d0bc16 100644 --- a/src/target_java_android.cr +++ b/src/target_java_android.cr @@ -102,24 +102,24 @@ public class API { END -# INIT CREATING API'S CALLS INTERFACE -@io << <<-END + # INIT CREATING API'S CALLS INTERFACE + @io << <<-END public interface APICalls { END @ast.operations.each do |op| - args = op.args.map {|arg| "final #{native_type arg.type} #{mangle arg.name}" } - args << "final #{callback_type op.return_type} callback" - @io << ident(String.build do |io| - io << "public void #{mangle op.pretty_name}(#{args.join(", ")});\n" - end) + args = op.args.map { |arg| "final #{native_type arg.type} #{mangle arg.name}" } + args << "final #{callback_type op.return_type} callback" + @io << ident(String.build do |io| + io << "public void #{mangle op.pretty_name}(#{args.join(", ")});\n" + end) end -@io << <<-END + @io << <<-END } END -# END CREATING API'S CALLS INTERFACE + # END CREATING API'S CALLS INTERFACE @ast.struct_types.each do |t| @io << ident generate_struct_type(t) @@ -131,20 +131,20 @@ END @io << "\n\n" end -# INIT CREATING CALLS -@io << <<-END + # INIT CREATING CALLS + @io << <<-END public static class Calls implements APICalls { END @ast.operations.each do |op| - args = op.args.map {|arg| "final #{native_type arg.type} #{mangle arg.name}" } + args = op.args.map { |arg| "final #{native_type arg.type} #{mangle arg.name}" } args << "final #{callback_type op.return_type} callback" @io << ident(String.build do |io| io << "@Override \n" io << "public void #{mangle op.pretty_name}(#{args.join(", ")}) {\n" - io << " #{mangle op.pretty_name}(#{(op.args.map {|arg| mangle arg.name } + ["0", "callback"]).join(", ")});\n" + io << " #{mangle op.pretty_name}(#{(op.args.map { |arg| mangle arg.name } + ["0", "callback"]).join(", ")});\n" io << "}" end) @io << "\n\n" @@ -161,10 +161,10 @@ try { args = new JSONObject() {{ END - op.args.each do |arg| - io << ident ident "put(\"#{arg.name}\", #{type_to_json arg.type, arg.name});\n" - end - io << <<-END + op.args.each do |arg| + io << ident ident "put(\"#{arg.name}\", #{type_to_json arg.type, arg.name});\n" + end + io << <<-END }}; } catch (final JSONException e) { e.printStackTrace(); @@ -173,13 +173,13 @@ END public void onResult(final Error error,final JSONObject result) { END - if op.return_type.is_a? AST::VoidPrimitiveType - io << <<-END + if op.return_type.is_a? AST::VoidPrimitiveType + io << <<-END callback.onResult(error); END - else - io << <<-END + else + io << <<-END if (error != null) { callback.onResult(error, null); } else { @@ -191,8 +191,8 @@ END } } END - end - io << <<-END + end + io << <<-END } }); @@ -290,13 +290,13 @@ END @io << "\n\n" end -@io << <<-END + @io << <<-END } END -# END CREATING CALLS + # END CREATING CALLS @io << <<-END public static class Error { @@ -725,7 +725,7 @@ END if (!body.getBoolean("ok")) { JSONObject jsonError = body.getJSONObject("error"); Error error = new Error(); - error.type = #{type_from_json(@ast.enum_types.find {|e| e.name == "ErrorType"}.not_nil!, "jsonError", "type".inspect)}; + error.type = #{type_from_json(@ast.enum_types.find { |e| e.name == "ErrorType" }.not_nil!, "jsonError", "type".inspect)}; error.message = jsonError.getString("message"); Log.e("API Error", jsonError.getString("type") + " - " + error.message); callback.onResult(error, null); diff --git a/src/target_swift.cr b/src/target_swift.cr index 225a741..10caad6 100644 --- a/src/target_swift.cr +++ b/src/target_swift.cr @@ -7,15 +7,15 @@ abstract class SwiftTarget < Target def native_type(t : AST::PrimitiveType) case t - when AST::StringPrimitiveType; "String" - when AST::IntPrimitiveType; "Int" - when AST::UIntPrimitiveType; "UInt" - when AST::FloatPrimitiveType; "Double" - when AST::DatePrimitiveType; "Date" + when AST::StringPrimitiveType ; "String" + when AST::IntPrimitiveType ; "Int" + when AST::UIntPrimitiveType ; "UInt" + when AST::FloatPrimitiveType ; "Double" + when AST::DatePrimitiveType ; "Date" when AST::DateTimePrimitiveType; "Date" - when AST::BoolPrimitiveType; "Bool" - when AST::BytesPrimitiveType; "Data" - when AST::VoidPrimitiveType; "void" + when AST::BoolPrimitiveType ; "Bool" + when AST::BytesPrimitiveType ; "Data" + when AST::VoidPrimitiveType ; "void" else raise "BUG! Should handle primitive #{t.class}" end @@ -54,7 +54,7 @@ END io << ident <<-END } -init(#{t.fields.map{|f| "#{f.name}: #{native_type f.type}"}.join(", ")}) { +init(#{t.fields.map { |f| "#{f.name}: #{native_type f.type}" }.join(", ")}) { END t.fields.each do |field| @@ -124,7 +124,7 @@ END when AST::StructType "#{t.name}()" when AST::EnumType - "#{t.name}.#{t.values[0]}"#(rawValue: \"\")" + "#{t.name}.#{t.values[0]}" # (rawValue: \"\")" when AST::TypeReference default_value(t.type) else diff --git a/src/target_swift_ios.cr b/src/target_swift_ios.cr index c5a54ae..f1e2304 100644 --- a/src/target_swift_ios.cr +++ b/src/target_swift_ios.cr @@ -24,10 +24,10 @@ END end @ast.operations.each do |op| - args = op.args.map {|arg| "#{arg.name}: #{native_type arg.type}" } + args = op.args.map { |arg| "#{arg.name}: #{native_type arg.type}" } if op.return_type.is_a? AST::VoidPrimitiveType - args << "callback: ((_ result: APIInternal.Result) -> Void)?" + args << "callback: ((_ result: APIInternal.Result) -> Void)?" else ret = op.return_type args << "callback: ((_ result: APIInternal.Result<#{native_type ret}>) -> Void)?" @@ -35,20 +35,19 @@ END @io << ident(String.build do |io| io << "static public func #{op.pretty_name}(#{args.join(", ")}) {\n" io << ident(String.build do |io| + if op.args.size != 0 + io << "var args = [String: Any]()\n" + else + io << "let args = [String: Any]()\n" + end - if op.args.size != 0 - io << "var args = [String: Any]()\n" - else - io << "let args = [String: Any]()\n" - end - - op.args.each do |arg| - io << "args[\"#{arg.name}\"] = #{type_to_json arg.type, arg.name}\n\n" - end + op.args.each do |arg| + io << "args[\"#{arg.name}\"] = #{type_to_json arg.type, arg.name}\n\n" + end - io << "APIInternal.makeRequest(#{op.pretty_name.inspect}, args) { response in \n" + io << "APIInternal.makeRequest(#{op.pretty_name.inspect}, args) { response in \n" - io << ident(String.build do |io| + io << ident(String.build do |io| io << "switch response {\n" io << <<-END case .failure(let error): @@ -56,30 +55,27 @@ END END if op.return_type.is_a? AST::VoidPrimitiveType - io << <<-END - case .success: - callback?(APIInternal.Result.success())\n - END + io << <<-END + case .success: + callback?(APIInternal.Result.success())\n + END else - io << <<-END - case .success(let value): - let returnObject = #{type_from_json(op.return_type, "value")} - callback?(APIInternal.Result.success(returnObject))\n - END + io << <<-END + case .success(let value): + let returnObject = #{type_from_json(op.return_type, "value")} + callback?(APIInternal.Result.success(returnObject))\n + END end io << "}\n" - end) # end of make request body indentation. - + end) # end of make request body indentation. - - io << "}\n\n" - end) + io << "}\n\n" + end) io << "}" end) @io << "\n\n" end - @io << <<-END } diff --git a/src/target_typescript.cr b/src/target_typescript.cr index 711ecd3..98bf83c 100644 --- a/src/target_typescript.cr +++ b/src/target_typescript.cr @@ -6,7 +6,7 @@ abstract class TypeScriptTarget < Target end def operation_args(op : AST::Operation) - args = op.args.map {|arg| "#{arg.name}: #{arg.type.typescript_native_type}" } + args = op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } "(#{args.join(", ")})" end diff --git a/src/target_typescript_nodeserver.cr b/src/target_typescript_nodeserver.cr index cd3733c..a570d58 100644 --- a/src/target_typescript_nodeserver.cr +++ b/src/target_typescript_nodeserver.cr @@ -22,7 +22,7 @@ END @ast.operations.each do |op| @io << " " << op.pretty_name << ": " << operation_type(op) << ";\n" end - @io << "} = {\n"; + @io << "} = {\n" @ast.operations.each do |op| @io << " " << op.pretty_name << ": () => { throw \"not implemented\"; },\n" end @@ -54,7 +54,7 @@ END @io << "const clearForLogging: {[name: string]: (call: DBApiCall) => void} = {\n" @ast.operations.each do |op| - cmds_args = String.build {|io| emit_clear_for_logging(io, op, "call.args") } + cmds_args = String.build { |io| emit_clear_for_logging(io, op, "call.args") } if cmds_args != "" @io << " " << op.pretty_name << ": async (call: DBApiCall) => {\n" @@ -304,11 +304,12 @@ END end def operation_args(op : AST::Operation) - args = ["ctx: Context"] + op.args.map {|arg| "#{arg.name}: #{arg.type.typescript_native_type}" } + args = ["ctx: Context"] + op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } "(#{args.join(", ")})" end @i = 0 + def emit_clear_for_logging(io : IO, t : AST::Type | AST::Operation | AST::Field, path : String) case t when AST::Operation @@ -328,14 +329,14 @@ END when AST::TypeReference emit_clear_for_logging(io, t.type, path) when AST::OptionalType - cmd = String.build {|io| emit_clear_for_logging(io, t.base, path) } + cmd = String.build { |io| emit_clear_for_logging(io, t.base, path) } if cmd != "" io << "if (#{path}) {\n" << ident(cmd) << "}\n" end when AST::ArrayType var = ('i' + @i).to_s @i += 1 - cmd = String.build {|io| emit_clear_for_logging(io, t.base, "#{path}[#{var}]") } + cmd = String.build { |io| emit_clear_for_logging(io, t.base, "#{path}[#{var}]") } @i -= 1 if cmd != "" io << "for (let #{var} = 0; #{var} < #{path}.length; ++#{var}) {\n" << ident(cmd) << "}\n" From 6f38cc3af31fde350b035f624b28ddc7abd444d7 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 08:44:25 -0300 Subject: [PATCH 348/625] Remove operation_ret from typescript --- src/codegen_types/void.cr | 2 +- src/target_typescript.cr | 6 +----- src/target_typescript_web.cr | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/codegen_types/void.cr b/src/codegen_types/void.cr index 53987f9..2dcbb34 100644 --- a/src/codegen_types/void.cr +++ b/src/codegen_types/void.cr @@ -9,7 +9,7 @@ module AST end def typescript_native_type - "null" + "void" end end end diff --git a/src/target_typescript.cr b/src/target_typescript.cr index 98bf83c..43397b5 100644 --- a/src/target_typescript.cr +++ b/src/target_typescript.cr @@ -1,16 +1,12 @@ require "./target" abstract class TypeScriptTarget < Target - def operation_ret(op : AST::GetOperation | AST::FunctionOperation) - op.return_type.is_a?(AST::VoidPrimitiveType) ? "void" : op.return_type.typescript_native_type - end - def operation_args(op : AST::Operation) args = op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } "(#{args.join(", ")})" end def operation_type(op : AST::Operation) - "#{operation_args(op)} => Promise<#{operation_ret(op)}>" + "#{operation_args(op)} => Promise<#{op.return_type.typescript_native_type}>" end end diff --git a/src/target_typescript_web.cr b/src/target_typescript_web.cr index 24c3126..7caace6 100644 --- a/src/target_typescript_web.cr +++ b/src/target_typescript_web.cr @@ -26,7 +26,7 @@ END end @ast.operations.each do |op| - @io << "export async function #{op.pretty_name}#{operation_args(op)}: Promise<#{operation_ret(op)}> {\n" + @io << "export async function #{op.pretty_name}#{operation_args(op)}: Promise<#{op.return_type.typescript_native_type}> {\n" if op.args.size > 0 @io << " const args = {\n" op.args.each do |arg| From 0d7473733b0c5c94a71e2de88a1f0052354056c2 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 08:49:18 -0300 Subject: [PATCH 349/625] Remove typescript target subclass --- src/target_typescript.cr | 12 ------------ src/target_typescript_nodeserver.cr | 12 ++++-------- src/target_typescript_web.cr | 7 ++++--- 3 files changed, 8 insertions(+), 23 deletions(-) delete mode 100644 src/target_typescript.cr diff --git a/src/target_typescript.cr b/src/target_typescript.cr deleted file mode 100644 index 43397b5..0000000 --- a/src/target_typescript.cr +++ /dev/null @@ -1,12 +0,0 @@ -require "./target" - -abstract class TypeScriptTarget < Target - def operation_args(op : AST::Operation) - args = op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } - "(#{args.join(", ")})" - end - - def operation_type(op : AST::Operation) - "#{operation_args(op)} => Promise<#{op.return_type.typescript_native_type}>" - end -end diff --git a/src/target_typescript_nodeserver.cr b/src/target_typescript_nodeserver.cr index a570d58..ba27890 100644 --- a/src/target_typescript_nodeserver.cr +++ b/src/target_typescript_nodeserver.cr @@ -1,6 +1,6 @@ -require "./target_typescript" +require "./target" -class TypeScriptServerTarget < TypeScriptTarget +class TypeScriptServerTarget < Target def gen @io << <<-END import http from "http"; @@ -20,7 +20,8 @@ END @io << "export const fn: {\n" @ast.operations.each do |op| - @io << " " << op.pretty_name << ": " << operation_type(op) << ";\n" + args = op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } + @io << " " << op.pretty_name << ": (#{args.join(", ")}) => Promise<#{op.return_type.typescript_native_type}>;\n" end @io << "} = {\n" @ast.operations.each do |op| @@ -303,11 +304,6 @@ fn.setPushToken = async (ctx: Context, token: string) => { END end - def operation_args(op : AST::Operation) - args = ["ctx: Context"] + op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } - "(#{args.join(", ")})" - end - @i = 0 def emit_clear_for_logging(io : IO, t : AST::Type | AST::Operation | AST::Field, path : String) diff --git a/src/target_typescript_web.cr b/src/target_typescript_web.cr index 7caace6..51ab613 100644 --- a/src/target_typescript_web.cr +++ b/src/target_typescript_web.cr @@ -1,6 +1,6 @@ -require "./target_typescript" +require "./target" -class TypeScriptWebTarget < TypeScriptTarget +class TypeScriptWebTarget < Target def gen @io << <<-END import * as moment from "moment"; @@ -26,7 +26,8 @@ END end @ast.operations.each do |op| - @io << "export async function #{op.pretty_name}#{operation_args(op)}: Promise<#{op.return_type.typescript_native_type}> {\n" + args = op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } + @io << "export async function #{op.pretty_name}(#{args.join(", ")}): Promise<#{op.return_type.typescript_native_type}> {\n" if op.args.size > 0 @io << " const args = {\n" op.args.each do |arg| From 8e1d87c775658893c56b7cb73888f57d88d19fea Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 08:49:47 -0300 Subject: [PATCH 350/625] Fully remove nodeclient --- src/target_typescript_nodeclient.cr | 146 ---------------------------- 1 file changed, 146 deletions(-) delete mode 100644 src/target_typescript_nodeclient.cr diff --git a/src/target_typescript_nodeclient.cr b/src/target_typescript_nodeclient.cr deleted file mode 100644 index 54b6a9e..0000000 --- a/src/target_typescript_nodeclient.cr +++ /dev/null @@ -1,146 +0,0 @@ -# require "./target_typescript" - -# class TypeScriptClientTarget < TypeScriptTarget -# def gen -# @io << <<-END -# import * as moment from "moment"; -# import * as request from "request"; -# import * as fs from "fs"; -# import {version as nodeVersion} from "process"; - -# const baseUrl = #{@ast.options.url.inspect}; -# let gDeviceId = null; -# let gDevicePath = "/root/config/deviceId"; - -# END - -# @ast.struct_types.each do |t| -# @io << generate_struct_type(t) -# @io << "\n\n" -# end - -# @ast.enum_types.each do |t| -# @io << generate_enum_type(t) -# @io << "\n\n" -# end - -# @ast.operations.each do |op| -# @io << "export async function #{op.pretty_name}#{operation_args(op)}: Promise<#{operation_ret(op)}> {\n" -# if op.args.size > 0 -# @io << " const args = {\n" -# op.args.each do |arg| -# @io << ident ident "#{arg.name}: #{type_to_json(arg.type, arg.name)}," -# @io << "\n" -# end -# @io << " };\n" -# end - -# @io << " " -# @io << "const ret: #{native_type op.return_type} = " unless op.return_type.is_a? AST::VoidPrimitiveType -# @io << "await makeRequest({name: #{op.pretty_name.inspect}, #{op.args.size > 0 ? "args" : "args: {}"}});\n" -# @io << ident "return " + type_from_json(op.return_type, "ret") + ";" -# @io << "\n" -# @io << "}\n\n" -# end - -# @io << <<-END -# ////////////////////////////////////////////////////// - -# async function getDeviceId(){ -# if(!gDeviceId){ -# try{ -# gDeviceId = await new Promise((resolve, reject) => fs.readFile(gDevicePath, "utf8", -# (err, data) => { -# if(err) -# reject(err); -# else -# resolve(); -# }) -# ); -# } catch(e){ -# return null; -# } -# } -# return gDeviceId; -# } - -# async function setDeviceId(newDeviceId){ -# if(newDeviceId !== gDeviceId){ -# await new Promise((resolve, reject) => fs.writeFile(gDevicePath, newDeviceId, "utf8", -# (err) => { -# if(err) -# reject(err); -# else -# resolve(); -# }) -# ); -# gDeviceId = newDeviceId; -# } -# } - -# async function device() { -# const device: any = { -# type: "node", -# platform: { -# nodeVersion: nodeVersion, -# }, -# screen: { -# width: 0, -# height: 0 -# }, -# version: "0.0.0", -# language: "en-US" -# }; - -# const deviceId = await getDeviceId(); -# if (deviceId) -# device.id = deviceId; -# return device; -# } - -# function randomBytesHex(len: number) { -# let hex = ""; -# for (let i = 0; i < 2 * len; ++i) -# hex += "0123456789abcdef"[Math.floor(Math.random()*16)]; -# return hex; -# } - -# async function makeRequest({name, args}: {name: string, args: any}) { -# return new Promise(async (resolve, reject) => { -# const body = { -# id: randomBytesHex(8), -# device: await device(), -# name: name, -# args: args -# }; - -# request.post( -# "https://" + baseUrl + "/" + name, -# {json: body}, -# async (err, res, body) => { -# if(!err){ -# try{ -# if(body.ok){ -# await setDeviceId(body.deviceId); -# resolve(body.result); -# } else { -# reject(body.error); -# } -# } catch(e){ -# console.error(e); -# reject({type: "Fatal", message: e.toString()}); -# } -# } else { -# console.error(err); -# reject({type: "Fatal", message: err.toString()}); -# } -# } -# ); -# }); -# } - -# END -# end -# end - -# Target.register(TypeScriptClientTarget, target_name: "typescript_nodeclient") From 8cbacc56eb92b0cf246d044b3ad1f4ac30476f11 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 08:50:44 -0300 Subject: [PATCH 351/625] Move main to src --- main.cr | 57 +---------------------------------------------------- src/main.cr | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 56 deletions(-) create mode 100644 src/main.cr diff --git a/main.cr b/main.cr index 23939f3..bf43b40 100644 --- a/main.cr +++ b/main.cr @@ -1,56 +1 @@ -require "./src/syntax/parser" -require "./src/semantic/ast_semantic" -require "./src/target_java_android" -require "./src/target_swift_ios" -require "./src/target_typescript_nodeserver" -require "./src/target_typescript_nodeclient" -require "./src/target_typescript_web" -require "option_parser" -require "file_utils" -require "colorize" - -is_server = false -destination = "" -target_name = "" -sources = [] of String - -OptionParser.parse! do |parser| - parser.banner = "Usage: salute [arguments]" - parser.on("-o NAME", "--output=NAME", "Specifies the output file") { |name| destination = name } - parser.on("-t TARGET", "--target=TARGET", "Specifies the target platform") { |target| target_name = target } - parser.on("-h", "--help", "Show this help") { puts parser } - parser.unknown_args {|args| sources = args } -end - -if sources.size == 0 - STDERR.puts "You must specify one source file" - exit -elsif sources.size > 1 - STDERR.puts "You must specify only one source file" - exit -end - -source = sources[0] - -begin - parser = Parser.new(source) - ast = parser.parse - ast.semantic - - if destination == "" - STDERR.puts "You must specify an output file" - exit - end - - if target_name == "" - STDERR.puts "You must specify a target" - exit - end - - FileUtils.mkdir_p(File.dirname(destination)) - Target.process(ast, destination, target_name) -rescue ex : Lexer::LexerException | Parser::ParserException - STDERR.puts (ex.message || "Invalid source").colorize.light_red -rescue ex : Exception - raise ex -end +require "./src/main.cr" diff --git a/src/main.cr b/src/main.cr new file mode 100644 index 0000000..43282b4 --- /dev/null +++ b/src/main.cr @@ -0,0 +1,55 @@ +require "./syntax/parser" +require "./semantic/ast_semantic" +require "./target_java_android" +require "./target_swift_ios" +require "./target_typescript_nodeserver" +require "./target_typescript_web" +require "option_parser" +require "file_utils" +require "colorize" + +is_server = false +destination = "" +target_name = "" +sources = [] of String + +OptionParser.parse! do |parser| + parser.banner = "Usage: salute [arguments]" + parser.on("-o NAME", "--output=NAME", "Specifies the output file") { |name| destination = name } + parser.on("-t TARGET", "--target=TARGET", "Specifies the target platform") { |target| target_name = target } + parser.on("-h", "--help", "Show this help") { puts parser } + parser.unknown_args {|args| sources = args } +end + +if sources.size == 0 + STDERR.puts "You must specify one source file" + exit +elsif sources.size > 1 + STDERR.puts "You must specify only one source file" + exit +end + +source = sources[0] + +begin + parser = Parser.new(source) + ast = parser.parse + ast.semantic + + if destination == "" + STDERR.puts "You must specify an output file" + exit + end + + if target_name == "" + STDERR.puts "You must specify a target" + exit + end + + FileUtils.mkdir_p(File.dirname(destination)) + Target.process(ast, destination, target_name) +rescue ex : Lexer::LexerException | Parser::ParserException + STDERR.puts (ex.message || "Invalid source").colorize.light_red +rescue ex : Exception + raise ex +end From bf20b205f2ddbc660f08ee0a14fcc77598c08b53 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 08:50:55 -0300 Subject: [PATCH 352/625] format main --- src/main.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cr b/src/main.cr index 43282b4..4dd63db 100644 --- a/src/main.cr +++ b/src/main.cr @@ -18,7 +18,7 @@ OptionParser.parse! do |parser| parser.on("-o NAME", "--output=NAME", "Specifies the output file") { |name| destination = name } parser.on("-t TARGET", "--target=TARGET", "Specifies the target platform") { |target| target_name = target } parser.on("-h", "--help", "Show this help") { puts parser } - parser.unknown_args {|args| sources = args } + parser.unknown_args { |args| sources = args } end if sources.size == 0 From f6a6af08ad6f20cd5a16a53f43c0d6f932b21109 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 08:52:46 -0300 Subject: [PATCH 353/625] Move targets to a subdir --- src/main.cr | 8 ++++---- src/{target_java.cr => target/java.cr} | 0 src/{target_java_android.cr => target/java_android.cr} | 2 +- src/{target_swift.cr => target/swift.cr} | 0 src/{target_swift_ios.cr => target/swift_ios.cr} | 4 ++-- src/{ => target}/target.cr | 4 ++-- .../typescript_nodeserver.cr} | 0 .../typescript_web.cr} | 0 8 files changed, 9 insertions(+), 9 deletions(-) rename src/{target_java.cr => target/java.cr} (100%) rename src/{target_java_android.cr => target/java_android.cr} (99%) rename src/{target_swift.cr => target/swift.cr} (100%) rename src/{target_swift_ios.cr => target/swift_ios.cr} (99%) rename src/{ => target}/target.cr (93%) rename src/{target_typescript_nodeserver.cr => target/typescript_nodeserver.cr} (100%) rename src/{target_typescript_web.cr => target/typescript_web.cr} (100%) diff --git a/src/main.cr b/src/main.cr index 4dd63db..aade26a 100644 --- a/src/main.cr +++ b/src/main.cr @@ -1,9 +1,9 @@ require "./syntax/parser" require "./semantic/ast_semantic" -require "./target_java_android" -require "./target_swift_ios" -require "./target_typescript_nodeserver" -require "./target_typescript_web" +require "./target/java_android" +require "./target/swift_ios" +require "./target/typescript_nodeserver" +require "./target/typescript_web" require "option_parser" require "file_utils" require "colorize" diff --git a/src/target_java.cr b/src/target/java.cr similarity index 100% rename from src/target_java.cr rename to src/target/java.cr diff --git a/src/target_java_android.cr b/src/target/java_android.cr similarity index 99% rename from src/target_java_android.cr rename to src/target/java_android.cr index 5d0bc16..4b93096 100644 --- a/src/target_java_android.cr +++ b/src/target/java_android.cr @@ -1,4 +1,4 @@ -require "./target_java" +require "./java" class JavaAndroidTarget < JavaTarget def gen diff --git a/src/target_swift.cr b/src/target/swift.cr similarity index 100% rename from src/target_swift.cr rename to src/target/swift.cr diff --git a/src/target_swift_ios.cr b/src/target/swift_ios.cr similarity index 99% rename from src/target_swift_ios.cr rename to src/target/swift_ios.cr index f1e2304..eb2d220 100644 --- a/src/target_swift_ios.cr +++ b/src/target/swift_ios.cr @@ -1,4 +1,4 @@ -require "./target_swift" +require "./swift" class SwiftIosTarget < SwiftTarget def gen @@ -9,7 +9,7 @@ class API { static var useStaging = false static var globalCallback: (_ method: String, _ result: APIInternal.Result, _ callback: @escaping ((APIInternal.Result) -> Void)) -> Void = { _, result, callback in callback(result) - } + } END diff --git a/src/target.cr b/src/target/target.cr similarity index 93% rename from src/target.cr rename to src/target/target.cr index 5cf7df5..8dd1252 100644 --- a/src/target.cr +++ b/src/target/target.cr @@ -1,5 +1,5 @@ -require "./ast" -require "./codegen_types/**" +require "../ast" +require "../codegen_types/**" abstract class Target @@targets = {} of String => Target.class diff --git a/src/target_typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr similarity index 100% rename from src/target_typescript_nodeserver.cr rename to src/target/typescript_nodeserver.cr diff --git a/src/target_typescript_web.cr b/src/target/typescript_web.cr similarity index 100% rename from src/target_typescript_web.cr rename to src/target/typescript_web.cr From 54d4c26038c859ac8abd43e03760de4534bdadd4 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 09:33:03 -0300 Subject: [PATCH 354/625] simplify CheckNoRecursiveTypes --- src/semantic/check_no_recursive_types.cr | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/semantic/check_no_recursive_types.cr b/src/semantic/check_no_recursive_types.cr index b39aa64..d76fb29 100644 --- a/src/semantic/check_no_recursive_types.cr +++ b/src/semantic/check_no_recursive_types.cr @@ -3,13 +3,10 @@ require "./visitor" module Semantic class CheckNoRecursiveTypes < Visitor @path = [] of String - @root_type : AST::Type? def visit(definition : AST::TypeDefinition) @path = [definition.name] - @root_type = definition.type super - @root_type = nil end def visit(field : AST::Field) @@ -19,7 +16,7 @@ module Semantic end def visit(ref : AST::TypeReference) - if ref.type == @root_type + if ref.name == @path[0] raise "Detected type recursion: #{@path.join(".")}" end visit ref.type From 43de4e0bccfb6551918614e70a76b37930b7a1f2 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 09:33:24 -0300 Subject: [PATCH 355/625] Fix GiveStructAndEnumNames for operation return type being struct or enum --- src/semantic/give_struct_and_enum_names.cr | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/semantic/give_struct_and_enum_names.cr b/src/semantic/give_struct_and_enum_names.cr index 9e35be3..2ab0008 100644 --- a/src/semantic/give_struct_and_enum_names.cr +++ b/src/semantic/give_struct_and_enum_names.cr @@ -10,7 +10,7 @@ module Semantic end def visit(operation : AST::Operation) - @path = [operation.name] + @path = [operation.name[0].upcase + operation.name[1..-1]] super end @@ -20,12 +20,7 @@ module Semantic @path.pop end - def visit(t : AST::StructType) - t.name = @path.join("") - super - end - - def visit(t : AST::EnumType) + def visit(t : AST::StructType | AST::EnumType) t.name = @path.join("") super end From db235dcffe38f39f48b20e1b82de4df2e33888a5 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 09:33:37 -0300 Subject: [PATCH 356/625] server: start args with context --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index ba27890..19dcd4e 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -20,7 +20,7 @@ END @io << "export const fn: {\n" @ast.operations.each do |op| - args = op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } + args = ["ctx: Context"] + op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } @io << " " << op.pretty_name << ": (#{args.join(", ")}) => Promise<#{op.return_type.typescript_native_type}>;\n" end @io << "} = {\n" From a8c9994feba577197b14ad877ec289f660af061e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 09:36:28 -0300 Subject: [PATCH 357/625] Enforce format --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 8f5b337..33ae950 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM crystallang/crystal CMD ["bash"] ADD . /tmp/ WORKDIR /tmp +RUN crystal tool format src --check RUN crystal spec WORKDIR /root RUN crystal build /tmp/main.cr -o sdkgen2 From 30c989cf5f7a8634633fe1e0c5c5cd27d213d2d1 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 09:37:05 -0300 Subject: [PATCH 358/625] Remove extra yarn.lock --- yarn.lock | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 yarn.lock diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index 23048a6..0000000 --- a/yarn.lock +++ /dev/null @@ -1,7 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -moment@^2.17.1: - version "2.17.1" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.17.1.tgz#fed9506063f36b10f066c8b59a144d7faebe1d82" From b9b94f08fe6ef0d469a20aa7f05681ef6976a32c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 12:00:59 -0300 Subject: [PATCH 359/625] improve error report for server --- src/target/typescript_nodeserver.cr | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 19dcd4e..6160a70 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -10,8 +10,8 @@ import url from "url"; import moment from "moment"; import r from "../rethinkdb"; -let captureError: (e: Error) => void = () => {}; -export function setCaptureErrorFn(fn: (e: Error) => void) { +let captureError: (e: Error, req: http.IncomingMessage, extra: any) => void = () => {}; +export function setCaptureErrorFn(fn: (e: Error, req: http.IncomingMessage, extra: any) => void) { captureError = fn; } @@ -244,7 +244,9 @@ export function start(port: number) { const deltaTime = process.hrtime(startTime); call.duration = deltaTime[0] + deltaTime[1] * 1e-9; if (call.error && call.error.type === "Fatal") { - captureError(new Error(call.error.message)); + captureError(new Error(call.error.type + ": " + call.error.message), req, { + call + }); } } From 7cd589e776d1210d414473c361a56e763e0c23a9 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 12:01:13 -0300 Subject: [PATCH 360/625] change identation to 4 spaces by default --- src/target/target.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/target.cr b/src/target/target.cr index 8dd1252..f9d8d47 100644 --- a/src/target/target.cr +++ b/src/target/target.cr @@ -30,6 +30,6 @@ abstract class Target end def ident(code) - code.split("\n").map { |line| " " + line }.join("\n").gsub(/\n\s+$/m, "\n") + code.split("\n").map { |line| " " + line }.join("\n").gsub(/\n\s+$/m, "\n") end end From 5b1c70d978eb0cc89c394bbb6fe651516285e418 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 12:49:44 -0300 Subject: [PATCH 361/625] Notify error later --- src/target/typescript_nodeserver.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 6160a70..8864e9d 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -244,9 +244,9 @@ export function start(port: number) { const deltaTime = process.hrtime(startTime); call.duration = deltaTime[0] + deltaTime[1] * 1e-9; if (call.error && call.error.type === "Fatal") { - captureError(new Error(call.error.type + ": " + call.error.message), req, { + setTimeout(() => captureError(new Error(call.error.type + ": " + call.error.message), req, { call - }); + }), 1); } } From d24d67054805d2d30ca8d9061938440b6fc32180 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 12:53:59 -0300 Subject: [PATCH 362/625] Fix build error for TS --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 8864e9d..871545c 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -244,7 +244,7 @@ export function start(port: number) { const deltaTime = process.hrtime(startTime); call.duration = deltaTime[0] + deltaTime[1] * 1e-9; if (call.error && call.error.type === "Fatal") { - setTimeout(() => captureError(new Error(call.error.type + ": " + call.error.message), req, { + setTimeout(() => captureError(new Error(call.error!.type + ": " + call.error!.message), req, { call }), 1); } From 173ea7b6d143db0036a2341a444ba38c36238ef8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 13:31:02 -0300 Subject: [PATCH 363/625] Implement initial type check for typescript server --- src/codegen_types/array.cr | 4 ++++ src/codegen_types/bool.cr | 4 ++++ src/codegen_types/bytes.cr | 4 ++++ src/codegen_types/date.cr | 4 ++++ src/codegen_types/datetime.cr | 4 ++++ src/codegen_types/enum.cr | 4 ++++ src/codegen_types/float.cr | 4 ++++ src/codegen_types/int.cr | 4 ++++ src/codegen_types/optional.cr | 4 ++++ src/codegen_types/reference.cr | 4 ++++ src/codegen_types/string.cr | 8 ++++++++ src/codegen_types/struct.cr | 4 ++++ src/codegen_types/uint.cr | 4 ++++ src/codegen_types/void.cr | 4 ++++ src/target/typescript_nodeserver.cr | 9 +++++++-- 15 files changed, 67 insertions(+), 2 deletions(-) diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr index 83d8a0a..5f54249 100644 --- a/src/codegen_types/array.cr +++ b/src/codegen_types/array.cr @@ -19,5 +19,9 @@ module AST base.typescript_native_type + "[]" end end + + def typescript_check_decoded(expr, descr) + "" + end end end diff --git a/src/codegen_types/bool.cr b/src/codegen_types/bool.cr index 96ca239..5d6d37a 100644 --- a/src/codegen_types/bool.cr +++ b/src/codegen_types/bool.cr @@ -11,5 +11,9 @@ module AST def typescript_native_type "boolean" end + + def typescript_check_decoded(expr, descr) + "" + end end end diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr index d9bf380..4a20481 100644 --- a/src/codegen_types/bytes.cr +++ b/src/codegen_types/bytes.cr @@ -11,5 +11,9 @@ module AST def typescript_native_type "Buffer" end + + def typescript_check_decoded(expr, descr) + "" + end end end diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index d0e9811..0af4673 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -11,5 +11,9 @@ module AST def typescript_native_type "Date" end + + def typescript_check_decoded(expr, descr) + "" + end end end diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index ace62d9..70b5ed8 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -11,5 +11,9 @@ module AST def typescript_native_type "Date" end + + def typescript_check_decoded(expr, descr) + "" + end end end diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index 6ddf72f..8afb5cd 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -15,5 +15,9 @@ module AST def typescript_definition "export type #{name} = #{values.map(&.inspect).join(" | ")};" end + + def typescript_check_decoded(expr, descr) + "" + end end end diff --git a/src/codegen_types/float.cr b/src/codegen_types/float.cr index cb98bfc..cfdc427 100644 --- a/src/codegen_types/float.cr +++ b/src/codegen_types/float.cr @@ -11,5 +11,9 @@ module AST def typescript_native_type "number" end + + def typescript_check_decoded(expr, descr) + "" + end end end diff --git a/src/codegen_types/int.cr b/src/codegen_types/int.cr index 37e1f0b..1c15f49 100644 --- a/src/codegen_types/int.cr +++ b/src/codegen_types/int.cr @@ -11,5 +11,9 @@ module AST def typescript_native_type "number" end + + def typescript_check_decoded(expr, descr) + "" + end end end diff --git a/src/codegen_types/optional.cr b/src/codegen_types/optional.cr index 93e7077..59393ff 100644 --- a/src/codegen_types/optional.cr +++ b/src/codegen_types/optional.cr @@ -11,5 +11,9 @@ module AST def typescript_native_type "#{base.typescript_native_type} | null" end + + def typescript_check_decoded(expr, descr) + "" + end end end diff --git a/src/codegen_types/reference.cr b/src/codegen_types/reference.cr index 73e78ec..32dc3a3 100644 --- a/src/codegen_types/reference.cr +++ b/src/codegen_types/reference.cr @@ -11,5 +11,9 @@ module AST def typescript_native_type type.typescript_native_type end + + def typescript_check_decoded(expr, descr) + type.typescript_check_decoded(expr, descr) + end end end diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index 5bb08cf..c516403 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -13,5 +13,13 @@ module AST def typescript_native_type "string" end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof (#{expr}) !== \"string\") {\n" + io << " failedCheckTypeError(#{descr});\n" + io << "}\n" + end + end end end diff --git a/src/codegen_types/struct.cr b/src/codegen_types/struct.cr index b003f24..896f8f2 100644 --- a/src/codegen_types/struct.cr +++ b/src/codegen_types/struct.cr @@ -33,5 +33,9 @@ module AST io << "}" end end + + def typescript_check_decoded(expr, descr) + "" + end end end diff --git a/src/codegen_types/uint.cr b/src/codegen_types/uint.cr index 2201d82..f95d4d4 100644 --- a/src/codegen_types/uint.cr +++ b/src/codegen_types/uint.cr @@ -11,5 +11,9 @@ module AST def typescript_native_type "number" end + + def typescript_check_decoded(expr, descr) + "" + end end end diff --git a/src/codegen_types/void.cr b/src/codegen_types/void.cr index 2dcbb34..9e957d1 100644 --- a/src/codegen_types/void.cr +++ b/src/codegen_types/void.cr @@ -11,5 +11,9 @@ module AST def typescript_native_type "void" end + + def typescript_check_decoded(expr, descr) + "" + end end end diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 871545c..d3ab0fe 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -10,11 +10,15 @@ import url from "url"; import moment from "moment"; import r from "../rethinkdb"; -let captureError: (e: Error, req: http.IncomingMessage, extra: any) => void = () => {}; -export function setCaptureErrorFn(fn: (e: Error, req: http.IncomingMessage, extra: any) => void) { +let captureError: (e: Error, req?: http.IncomingMessage, extra?: any) => void = () => {}; +export function setCaptureErrorFn(fn: (e: Error, req?: http.IncomingMessage, extra?: any) => void) { captureError = fn; } +function failedCheckTypeError(descr: string) { + setTimeout(() => captureError(new Error("Invalid Type at '" + descr + "'")), 1); +} + END @@ -43,6 +47,7 @@ END @ast.operations.each do |op| @io << " " << op.pretty_name << ": async (ctx: Context, args: any) => {\n" op.args.each do |arg| + @io << ident ident arg.type.typescript_check_decoded("args.#{arg.name}", "\"#{op.pretty_name}.args.#{arg.name}\"") @io << ident ident "const #{arg.name} = #{arg.type.typescript_decode("args.#{arg.name}")};" @io << "\n" end From 5e8a1e31e72d3c744d27efdc4e5c6d5522a899ec Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 13:34:27 -0300 Subject: [PATCH 364/625] four spaces identation --- src/target/typescript_nodeserver.cr | 408 ++++++++++++++-------------- 1 file changed, 204 insertions(+), 204 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index d3ab0fe..ba1b6ea 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -12,11 +12,11 @@ import r from "../rethinkdb"; let captureError: (e: Error, req?: http.IncomingMessage, extra?: any) => void = () => {}; export function setCaptureErrorFn(fn: (e: Error, req?: http.IncomingMessage, extra?: any) => void) { - captureError = fn; + captureError = fn; } function failedCheckTypeError(descr: string) { - setTimeout(() => captureError(new Error("Invalid Type at '" + descr + "'")), 1); + setTimeout(() => captureError(new Error("Invalid Type at '" + descr + "'")), 1); } @@ -25,11 +25,11 @@ END @io << "export const fn: {\n" @ast.operations.each do |op| args = ["ctx: Context"] + op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } - @io << " " << op.pretty_name << ": (#{args.join(", ")}) => Promise<#{op.return_type.typescript_native_type}>;\n" + @io << " " << op.pretty_name << ": (#{args.join(", ")}) => Promise<#{op.return_type.typescript_native_type}>;\n" end @io << "} = {\n" @ast.operations.each do |op| - @io << " " << op.pretty_name << ": () => { throw \"not implemented\"; },\n" + @io << " " << op.pretty_name << ": () => { throw \"not implemented\"; },\n" end @io << "};\n\n" @@ -45,13 +45,13 @@ END @io << "const fnExec: {[name: string]: (ctx: Context, args: any) => Promise} = {\n" @ast.operations.each do |op| - @io << " " << op.pretty_name << ": async (ctx: Context, args: any) => {\n" + @io << " " << op.pretty_name << ": async (ctx: Context, args: any) => {\n" op.args.each do |arg| @io << ident ident arg.type.typescript_check_decoded("args.#{arg.name}", "\"#{op.pretty_name}.args.#{arg.name}\"") @io << ident ident "const #{arg.name} = #{arg.type.typescript_decode("args.#{arg.name}")};" @io << "\n" end - @io << " const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" + @io << ident ident "const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident "return " + op.return_type.typescript_encode("ret") + ";" @io << "\n" @io << " },\n" @@ -63,16 +63,16 @@ END cmds_args = String.build { |io| emit_clear_for_logging(io, op, "call.args") } if cmds_args != "" - @io << " " << op.pretty_name << ": async (call: DBApiCall) => {\n" + @io << " " << op.pretty_name << ": async (call: DBApiCall) => {\n" @io << ident ident cmds_args - @io << " },\n" + @io << ident "},\n" end end @io << "};\n\n" @io << "export const err = {\n" @ast.errors.each do |error| - @io << " #{error}: (message: string = \"\") => { throw {type: #{error.inspect}, message}; },\n" + @io << ident "#{error}: (message: string = \"\") => { throw {type: #{error.inspect}, message}; },\n" end @io << "};\n\n" @@ -80,232 +80,232 @@ END ////////////////////////////////////////////////////// const httpHandlers: { - [signature: string]: (body: string, res: http.ServerResponse, req: http.IncomingMessage) => void + [signature: string]: (body: string, res: http.ServerResponse, req: http.IncomingMessage) => void } = {} export function handleHttp(method: "GET" | "POST" | "PUT" | "DELETE", path: string, func: (body: string, res: http.ServerResponse, req: http.IncomingMessage) => void) { - httpHandlers[method + path] = func; + httpHandlers[method + path] = func; } export function handleHttpPrefix(method: "GET" | "POST" | "PUT" | "DELETE", path: string, func: (body: string, res: http.ServerResponse, req: http.IncomingMessage) => void) { - httpHandlers["prefix " + method + path] = func; + httpHandlers["prefix " + method + path] = func; } export interface Context { - device: DBDevice; - startTime: Date; - staging: boolean; + device: DBDevice; + startTime: Date; + staging: boolean; } function sleep(ms: number) { - return new Promise(resolve => setTimeout(resolve, ms)); + return new Promise(resolve => setTimeout(resolve, ms)); } export function start(port: number) { - const server = http.createServer((req, res) => { - req.on("error", (err) => { - console.error(err); - }); - - res.on("error", (err) => { - console.error(err); - }); + const server = http.createServer((req, res) => { + req.on("error", (err) => { + console.error(err); + }); - res.setHeader("Access-Control-Allow-Origin", "*"); - res.setHeader("Access-Control-Allow-Methods", "PUT, POST, GET, OPTIONS"); - res.setHeader("Access-Control-Allow-Headers", "Content-Type"); - res.setHeader("Access-Control-Max-Age", "86400"); - res.setHeader("Content-Type", "application/json"); - - let body = ""; - req.on("data", (chunk: any) => body += chunk.toString()); - req.on("end", () => { - if (req.method === "OPTIONS") { - res.writeHead(200); - res.end(); - return; - } - const ip = req.headers["x-real-ip"] as string || ""; - const signature = req.method! + url.parse(req.url || "").pathname; - if (httpHandlers[signature]) { - console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${signature}`); - httpHandlers[signature](body, res, req); - return; - } - for (let target in httpHandlers) { - if (("prefix " + signature).startsWith(target)) { - console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${target}`); - httpHandlers[target](body, res, req); - return; - } - } - - switch (req.method) { - case "HEAD": { - res.writeHead(200); - res.end(); - break; - } - case "GET": { - r.expr(`{"ok": true}`).then(result => { - res.writeHead(200); - res.write(result); - res.end(); - }); - break; - } - case "POST": { - (async () => { - const request = JSON.parse(body); - request.device.ip = ip; - const context: Context = { - device: request.device, - startTime: new Date, - staging: request.staging || false - }; - const startTime = process.hrtime(); - - const {id, ...deviceInfo} = context.device; - - if (!context.device.id || await r.table("devices").get(context.device.id).eq(null)) { - context.device.id = crypto.randomBytes(20).toString("hex"); - - await r.table("devices").insert({ - id: context.device.id, - date: r.now(), - ...deviceInfo - }); - } else { - r.table("devices").get(context.device.id).update(deviceInfo).run(); + res.on("error", (err) => { + console.error(err); + }); + + res.setHeader("Access-Control-Allow-Origin", "*"); + res.setHeader("Access-Control-Allow-Methods", "PUT, POST, GET, OPTIONS"); + res.setHeader("Access-Control-Allow-Headers", "Content-Type"); + res.setHeader("Access-Control-Max-Age", "86400"); + res.setHeader("Content-Type", "application/json"); + + let body = ""; + req.on("data", (chunk: any) => body += chunk.toString()); + req.on("end", () => { + if (req.method === "OPTIONS") { + res.writeHead(200); + res.end(); + return; } - - const executionId = crypto.randomBytes(20).toString("hex"); - - let call: DBApiCall = { - id: `${request.id}-${context.device.id}`, - name: request.name, - args: JSON.parse(JSON.stringify(request.args)), - executionId: executionId, - running: true, - device: context.device, - date: context.startTime, - duration: 0, - host: os.hostname(), - ok: true, - result: null as any, - error: null as {type: string, message: string}|null - }; - - if (clearForLogging[call.name]) - clearForLogging[call.name](call); - - async function tryLock(): Promise { - const priorCall = await r.table("api_calls").get(call.id); - if (priorCall === null) { - const res = await r.table("api_calls").insert(call); - return res.inserted > 0 ? true : await tryLock(); - } - call = priorCall; - if (!call.running) { - return true; - } - if (call.executionId === executionId) { - return true; - } - return false; + const ip = req.headers["x-real-ip"] as string || ""; + const signature = req.method! + url.parse(req.url || "").pathname; + if (httpHandlers[signature]) { + console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${signature}`); + httpHandlers[signature](body, res, req); + return; } - - for (let i = 0; i < 600; ++i) { - if (await tryLock()) break; - await sleep(100); + for (let target in httpHandlers) { + if (("prefix " + signature).startsWith(target)) { + console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${target}`); + httpHandlers[target](body, res, req); + return; + } } - if (call.running) { - if (call.executionId !== executionId) { - call.ok = false; - call.error = { - type: "Fatal", - message: "CallExecutionTimeout: Timeout while waiting for execution somewhere else (is the original container that received this request dead?)" - }; - } else { - try { - call.result = await fnExec[request.name](context, request.args); - } catch (err) { - console.error(err); - call.ok = false; - if (err.type) { - call.error = { - type: err.type, - message: err.message - }; - } else { - call.error = { - type: "Fatal", - message: err.toString() - }; - } + switch (req.method) { + case "HEAD": { + res.writeHead(200); + res.end(); + break; } - call.running = false; - const deltaTime = process.hrtime(startTime); - call.duration = deltaTime[0] + deltaTime[1] * 1e-9; - if (call.error && call.error.type === "Fatal") { - setTimeout(() => captureError(new Error(call.error!.type + ": " + call.error!.message), req, { - call - }), 1); + case "GET": { + r.expr(`{"ok": true}`).then(result => { + res.writeHead(200); + res.write(result); + res.end(); + }); + break; + } + case "POST": { + (async () => { + const request = JSON.parse(body); + request.device.ip = ip; + const context: Context = { + device: request.device, + startTime: new Date, + staging: request.staging || false + }; + const startTime = process.hrtime(); + + const {id, ...deviceInfo} = context.device; + + if (!context.device.id || await r.table("devices").get(context.device.id).eq(null)) { + context.device.id = crypto.randomBytes(20).toString("hex"); + + await r.table("devices").insert({ + id: context.device.id, + date: r.now(), + ...deviceInfo + }); + } else { + r.table("devices").get(context.device.id).update(deviceInfo).run(); + } + + const executionId = crypto.randomBytes(20).toString("hex"); + + let call: DBApiCall = { + id: `${request.id}-${context.device.id}`, + name: request.name, + args: JSON.parse(JSON.stringify(request.args)), + executionId: executionId, + running: true, + device: context.device, + date: context.startTime, + duration: 0, + host: os.hostname(), + ok: true, + result: null as any, + error: null as {type: string, message: string}|null + }; + + if (clearForLogging[call.name]) + clearForLogging[call.name](call); + + async function tryLock(): Promise { + const priorCall = await r.table("api_calls").get(call.id); + if (priorCall === null) { + const res = await r.table("api_calls").insert(call); + return res.inserted > 0 ? true : await tryLock(); + } + call = priorCall; + if (!call.running) { + return true; + } + if (call.executionId === executionId) { + return true; + } + return false; + } + + for (let i = 0; i < 600; ++i) { + if (await tryLock()) break; + await sleep(100); + } + + if (call.running) { + if (call.executionId !== executionId) { + call.ok = false; + call.error = { + type: "Fatal", + message: "CallExecutionTimeout: Timeout while waiting for execution somewhere else (is the original container that received this request dead?)" + }; + } else { + try { + call.result = await fnExec[request.name](context, request.args); + } catch (err) { + console.error(err); + call.ok = false; + if (err.type) { + call.error = { + type: err.type, + message: err.message + }; + } else { + call.error = { + type: "Fatal", + message: err.toString() + }; + } + } + call.running = false; + const deltaTime = process.hrtime(startTime); + call.duration = deltaTime[0] + deltaTime[1] * 1e-9; + if (call.error && call.error.type === "Fatal") { + setTimeout(() => captureError(new Error(call.error!.type + ": " + call.error!.message), req, { + call + }), 1); + } + } + + r.table("api_calls").get(call.id).update(call).run(); + } + + const response = { + id: call.id, + ok: call.ok, + executed: call.executionId === executionId, + deviceId: call.device.id, + startTime: call.date, + duration: call.duration, + host: call.host, + result: call.result, + error: call.error + }; + + res.writeHead(200); + res.write(JSON.stringify(response)); + res.end(); + + console.log( + `${moment().format("YYYY-MM-DD HH:mm:ss")} ` + + `${call.id} [${call.duration.toFixed(6)}s] ` + + `${call.name}() -> ${call.ok ? "OK" : call.error ? call.error.type : "???"}` + ); + })().catch(err => { + console.error(err); + res.writeHead(500); + res.end(); + }); + break; + } + default: { + res.writeHead(500); + res.end(); } - } - - r.table("api_calls").get(call.id).update(call).run(); } - - const response = { - id: call.id, - ok: call.ok, - executed: call.executionId === executionId, - deviceId: call.device.id, - startTime: call.date, - duration: call.duration, - host: call.host, - result: call.result, - error: call.error - }; - - res.writeHead(200); - res.write(JSON.stringify(response)); - res.end(); - - console.log( - `${moment().format("YYYY-MM-DD HH:mm:ss")} ` + - `${call.id} [${call.duration.toFixed(6)}s] ` + - `${call.name}() -> ${call.ok ? "OK" : call.error ? call.error.type : "???"}` - ); - })().catch(err => { - console.error(err); - res.writeHead(500); - res.end(); - }); - break; - } - default: { - res.writeHead(500); - res.end(); - } - } + }); }); - }); - if ((server as any).keepAliveTimeout) - (server as any).keepAliveTimeout = 0; + if ((server as any).keepAliveTimeout) + (server as any).keepAliveTimeout = 0; - server.listen(port, () => { - console.log(`Listening on ${server.address().address}:${server.address().port}`); - }); + server.listen(port, () => { + console.log(`Listening on ${server.address().address}:${server.address().port}`); + }); } fn.ping = async (ctx: Context) => "pong"; fn.setPushToken = async (ctx: Context, token: string) => { - await r.table("devices").get(ctx.device.id).update({push: token}); + await r.table("devices").get(ctx.device.id).update({push: token}); }; END From 0f2ad4e01e105bf5c8b3e467be72f2147026c2ec Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 15:53:12 -0300 Subject: [PATCH 365/625] Add type checks for strings on most situations --- src/codegen_types/array.cr | 13 ++++++++++++- src/codegen_types/optional.cr | 6 +++++- src/codegen_types/string.cr | 4 ++-- src/codegen_types/struct.cr | 6 +++++- src/target/java.cr | 4 ---- src/target/swift.cr | 4 ---- src/target/target.cr | 4 ---- src/target/typescript_nodeserver.cr | 6 ++++-- src/utils.cr | 14 ++++++++++++++ 9 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 src/utils.cr diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr index 5f54249..875d85d 100644 --- a/src/codegen_types/array.cr +++ b/src/codegen_types/array.cr @@ -1,3 +1,5 @@ +require "../utils" + module AST class ArrayType def typescript_decode(expr) @@ -21,7 +23,16 @@ module AST end def typescript_check_decoded(expr, descr) - "" + String.build do |io| + io << "if (!(#{expr} instanceof Array)) {\n" + io << " failTypeCheck(#{descr});\n" + io << "} else {\n" + i = random_var + io << ident "for (let #{i} = 0; #{i} < #{expr}.length; ++#{i}) {\n" + io << ident ident base.typescript_check_decoded("#{expr}[#{i}]", "#{descr} + \"[\" + #{i} + \"]\"") + io << ident "}\n" + io << "}\n" + end end end end diff --git a/src/codegen_types/optional.cr b/src/codegen_types/optional.cr index 59393ff..4c497c5 100644 --- a/src/codegen_types/optional.cr +++ b/src/codegen_types/optional.cr @@ -13,7 +13,11 @@ module AST end def typescript_check_decoded(expr, descr) - "" + String.build do |io| + io << "if (#{expr}) {\n" + io << ident base.typescript_check_decoded(expr, descr) + io << "}\n" + end end end end diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index c516403..fcf20bc 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -16,8 +16,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof (#{expr}) !== \"string\") {\n" - io << " failedCheckTypeError(#{descr});\n" + io << "if (typeof #{expr} !== \"string\") {\n" + io << " failTypeCheck(#{descr});\n" io << "}\n" end end diff --git a/src/codegen_types/struct.cr b/src/codegen_types/struct.cr index 896f8f2..171d91f 100644 --- a/src/codegen_types/struct.cr +++ b/src/codegen_types/struct.cr @@ -35,7 +35,11 @@ module AST end def typescript_check_decoded(expr, descr) - "" + String.build do |io| + fields.each do |field| + io << field.type.typescript_check_decoded("#{expr}.#{field.name}", "#{descr} + \".#{field.name}\"") + end + end end end end diff --git a/src/target/java.cr b/src/target/java.cr index d431436..f5ccb35 100644 --- a/src/target/java.cr +++ b/src/target/java.cr @@ -2,10 +2,6 @@ require "./target" require "secure_random" abstract class JavaTarget < Target - def ident(code) - super super code - end - def mangle(ident) if %w[ boolean class if int byte do for while void float double long char synchronized diff --git a/src/target/swift.cr b/src/target/swift.cr index 10caad6..e5c5f6a 100644 --- a/src/target/swift.cr +++ b/src/target/swift.cr @@ -1,10 +1,6 @@ require "./target" abstract class SwiftTarget < Target - def ident(code) - super super code - end - def native_type(t : AST::PrimitiveType) case t when AST::StringPrimitiveType ; "String" diff --git a/src/target/target.cr b/src/target/target.cr index f9d8d47..d4e051c 100644 --- a/src/target/target.cr +++ b/src/target/target.cr @@ -28,8 +28,4 @@ abstract class Target t.gen t.write end - - def ident(code) - code.split("\n").map { |line| " " + line }.join("\n").gsub(/\n\s+$/m, "\n") - end end diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index ba1b6ea..49b4d06 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -15,7 +15,7 @@ export function setCaptureErrorFn(fn: (e: Error, req?: http.IncomingMessage, ext captureError = fn; } -function failedCheckTypeError(descr: string) { +function failTypeCheck(descr: string) { setTimeout(() => captureError(new Error("Invalid Type at '" + descr + "'")), 1); } @@ -52,7 +52,9 @@ END @io << "\n" end @io << ident ident "const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" - @io << ident ident "return " + op.return_type.typescript_encode("ret") + ";" + @io << ident ident "const retEncoded = " + op.return_type.typescript_encode("ret") + ";\n" + @io << ident ident op.return_type.typescript_check_decoded("retEncoded", "\"#{op.pretty_name}.ret\"") + @io << ident ident "return retEncoded" @io << "\n" @io << " },\n" end diff --git a/src/utils.cr b/src/utils.cr new file mode 100644 index 0000000..2db5a91 --- /dev/null +++ b/src/utils.cr @@ -0,0 +1,14 @@ +module RandomGen + @@gen = Random::PCG32.new(17) + def self.random_u + @@gen.next_u + end +end + +def random_var + "x#{RandomGen.random_u}" +end + +def ident(code) + code.split("\n").map { |line| " " + line }.join("\n").gsub(/\n\s+$/m, "\n") +end From baa88b9d77d249a8a445f2438bba46d11b95b388 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 15:54:52 -0300 Subject: [PATCH 366/625] format code --- Dockerfile | 2 +- spec/lexer_spec.cr | 80 ++++++++++++++++++++++----------------------- spec/parser_spec.cr | 1 - src/utils.cr | 11 ++++--- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Dockerfile b/Dockerfile index 33ae950..77ed13a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM crystallang/crystal CMD ["bash"] ADD . /tmp/ WORKDIR /tmp -RUN crystal tool format src --check +RUN crystal tool format --check RUN crystal spec WORKDIR /root RUN crystal build /tmp/main.cr -o sdkgen2 diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index 3da8ba5..7a03649 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -5,7 +5,7 @@ describe Lexer do it_lexes "", [] of Token it_lexes "type", [ - TypeKeywordToken.new + TypeKeywordToken.new, ] it_doesnt_lex "23", "Unexpected character '2' at -:1:1" @@ -13,11 +13,11 @@ describe Lexer do it_doesnt_lex "2a", "Unexpected character '2' at -:1:1" it_lexes "type2", [ - IdentifierToken.new("type2") + IdentifierToken.new("type2"), ] it_lexes "aaa", [ - IdentifierToken.new("aaa") + IdentifierToken.new("aaa"), ] it_lexes "a b c", [ @@ -30,82 +30,82 @@ describe Lexer do it_lexes "type type", [ TypeKeywordToken.new, - TypeKeywordToken.new + TypeKeywordToken.new, ] it_lexes "enum", [ - EnumKeywordToken.new + EnumKeywordToken.new, ] it_lexes "error", [ - ErrorKeywordToken.new + ErrorKeywordToken.new, ] it_lexes "import", [ - ImportKeywordToken.new + ImportKeywordToken.new, ] it_lexes "get", [ - GetKeywordToken.new + GetKeywordToken.new, ] it_lexes "Get", [ - IdentifierToken.new("Get") + IdentifierToken.new("Get"), ] it_lexes "function", [ - FunctionKeywordToken.new + FunctionKeywordToken.new, ] it_lexes "enuma", [ - IdentifierToken.new("enuma") + IdentifierToken.new("enuma"), ] it_lexes "errorh", [ - IdentifierToken.new("errorh") + IdentifierToken.new("errorh"), ] %w[enum type error import get function].each do |kw| it_lexes kw, [ - IdentifierToken.new(kw) + IdentifierToken.new(kw), ] end %w[string int uint date datetime bytes float bool].each do |primitive| it_lexes primitive, [ - PrimitiveTypeToken.new(primitive) + PrimitiveTypeToken.new(primitive), ] it_lexes primitive, [ - IdentifierToken.new(primitive) + IdentifierToken.new(primitive), ] it_lexes primitive + "a", [ - IdentifierToken.new(primitive + "a") + IdentifierToken.new(primitive + "a"), ] end it_lexes "err", [ - IdentifierToken.new("err") + IdentifierToken.new("err"), ] it_lexes "{", [ - CurlyOpenSymbolToken.new + CurlyOpenSymbolToken.new, ] it_lexes "{{", [ CurlyOpenSymbolToken.new, - CurlyOpenSymbolToken.new + CurlyOpenSymbolToken.new, ] it_lexes "}{", [ CurlyCloseSymbolToken.new, - CurlyOpenSymbolToken.new + CurlyOpenSymbolToken.new, ] it_lexes " } { ", [ CurlyCloseSymbolToken.new, - CurlyOpenSymbolToken.new + CurlyOpenSymbolToken.new, ] it_lexes "({!:?,=})", [ @@ -117,22 +117,22 @@ describe Lexer do CommaSymbolToken.new, EqualSymbolToken.new, CurlyCloseSymbolToken.new, - ParensCloseSymbolToken.new + ParensCloseSymbolToken.new, ] it_lexes " [][] ", [ ArraySymbolToken.new, - ArraySymbolToken.new + ArraySymbolToken.new, ] it_lexes "nice[]", [ IdentifierToken.new("nice"), - ArraySymbolToken.new + ArraySymbolToken.new, ] it_lexes "nice\n[]", [ IdentifierToken.new("nice"), - ArraySymbolToken.new + ArraySymbolToken.new, ] it_doesnt_lex "[", "Unexpected end of file" @@ -140,25 +140,25 @@ describe Lexer do it_lexes "type Str string", [ TypeKeywordToken.new, IdentifierToken.new("Str"), - PrimitiveTypeToken.new("string") + PrimitiveTypeToken.new("string"), ] it_lexes "$url", [ - GlobalOptionToken.new("url") + GlobalOptionToken.new("url"), ] it_lexes "$F", [ - GlobalOptionToken.new("F") + GlobalOptionToken.new("F"), ] it_lexes "$x123", [ - GlobalOptionToken.new("x123") + GlobalOptionToken.new("x123"), ] it_lexes "$ah[]?", [ GlobalOptionToken.new("ah"), ArraySymbolToken.new, - OptionalSymbolToken.new + OptionalSymbolToken.new, ] it_doesnt_lex "$", "Unexpected end of file" @@ -168,47 +168,47 @@ describe Lexer do it_doesnt_lex "$ a", "Unexpected character ' '" it_lexes "\"ab\"", [ - StringLiteralToken.new("ab") + StringLiteralToken.new("ab"), ] it_lexes "\"\"", [ - StringLiteralToken.new("") + StringLiteralToken.new(""), ] it_lexes "\"aa\\nbb\"", [ - StringLiteralToken.new("aa\nbb") + StringLiteralToken.new("aa\nbb"), ] it_lexes "\"aa\\bb\"", [ - StringLiteralToken.new("aabb") + StringLiteralToken.new("aabb"), ] it_lexes "\"'\"", [ - StringLiteralToken.new("'") + StringLiteralToken.new("'"), ] it_lexes "\"\\n\\t\\\"\"", [ - StringLiteralToken.new("\n\t\"") + StringLiteralToken.new("\n\t\""), ] it_lexes "//hmmm", [] of Token it_lexes "x//hmmm", [ - IdentifierToken.new("x") + IdentifierToken.new("x"), ] it_lexes "a//hmmm\nb", [ IdentifierToken.new("a"), - IdentifierToken.new("b") + IdentifierToken.new("b"), ] it_lexes "a // hmmm \n b", [ IdentifierToken.new("a"), - IdentifierToken.new("b") + IdentifierToken.new("b"), ] it_lexes "// héýça\n z", [ - IdentifierToken.new("z") + IdentifierToken.new("z"), ] end diff --git a/spec/parser_spec.cr b/spec/parser_spec.cr index 4fd320c..ca979f1 100644 --- a/spec/parser_spec.cr +++ b/spec/parser_spec.cr @@ -19,7 +19,6 @@ end PRIMITIVES = %w[string int uint date datetime bytes float bool] describe Parser do - {% for p in PRIMITIVES %} it "handles primitive type '#{{{p}}}'" do check_parses <<-END diff --git a/src/utils.cr b/src/utils.cr index 2db5a91..518b8e2 100644 --- a/src/utils.cr +++ b/src/utils.cr @@ -1,12 +1,13 @@ module RandomGen - @@gen = Random::PCG32.new(17) - def self.random_u - @@gen.next_u - end + @@gen = Random::PCG32.new(17) + + def self.random_u + @@gen.next_u + end end def random_var - "x#{RandomGen.random_u}" + "x#{RandomGen.random_u}" end def ident(code) From cd605163c1fb3c4cc8120e16e86ce99949703742 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 16:00:07 -0300 Subject: [PATCH 367/625] Fix codegen of optional check --- src/codegen_types/optional.cr | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/codegen_types/optional.cr b/src/codegen_types/optional.cr index 4c497c5..857d51e 100644 --- a/src/codegen_types/optional.cr +++ b/src/codegen_types/optional.cr @@ -14,8 +14,10 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (#{expr}) {\n" - io << ident base.typescript_check_decoded(expr, descr) + x = random_var + io << "const #{x} = #{expr};\n" + io << "if (#{x}) {\n" + io << ident base.typescript_check_decoded(x, descr) io << "}\n" end end From ad58ad03a423e738002c63f71e7556eb4d80fc84 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 16:23:09 -0300 Subject: [PATCH 368/625] Remove extra file --- src/codegen_types/type.cr | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 src/codegen_types/type.cr diff --git a/src/codegen_types/type.cr b/src/codegen_types/type.cr deleted file mode 100644 index 3c0ee72..0000000 --- a/src/codegen_types/type.cr +++ /dev/null @@ -1,4 +0,0 @@ -module AST - class Type - end -end From b376d35902375a9f58f3b5f401cb293046958cc8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 16:35:18 -0300 Subject: [PATCH 369/625] Add checking for more types --- src/codegen_types/array.cr | 2 +- src/codegen_types/bool.cr | 6 +++++- src/codegen_types/enum.cr | 6 +++++- src/codegen_types/float.cr | 6 +++++- src/codegen_types/int.cr | 6 +++++- src/codegen_types/string.cr | 2 +- src/codegen_types/uint.cr | 6 +++++- src/target/typescript_nodeserver.cr | 6 +++++- 8 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr index 875d85d..9fbd21d 100644 --- a/src/codegen_types/array.cr +++ b/src/codegen_types/array.cr @@ -25,7 +25,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (!(#{expr} instanceof Array)) {\n" - io << " failTypeCheck(#{descr});\n" + io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" io << "} else {\n" i = random_var io << ident "for (let #{i} = 0; #{i} < #{expr}.length; ++#{i}) {\n" diff --git a/src/codegen_types/bool.cr b/src/codegen_types/bool.cr index 5d6d37a..817ee43 100644 --- a/src/codegen_types/bool.cr +++ b/src/codegen_types/bool.cr @@ -13,7 +13,11 @@ module AST end def typescript_check_decoded(expr, descr) - "" + String.build do |io| + io << "if (#{expr} !== true && #{expr} !== false) {\n" + io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" + io << "}\n" + end end end end diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index 8afb5cd..ffcb4e2 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -17,7 +17,11 @@ module AST end def typescript_check_decoded(expr, descr) - "" + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" + io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" + io << "}\n" + end end end end diff --git a/src/codegen_types/float.cr b/src/codegen_types/float.cr index cfdc427..cc78605 100644 --- a/src/codegen_types/float.cr +++ b/src/codegen_types/float.cr @@ -13,7 +13,11 @@ module AST end def typescript_check_decoded(expr, descr) - "" + String.build do |io| + io << "if (typeof #{expr} !== \"number\") {\n" + io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" + io << "}\n" + end end end end diff --git a/src/codegen_types/int.cr b/src/codegen_types/int.cr index 1c15f49..2733336 100644 --- a/src/codegen_types/int.cr +++ b/src/codegen_types/int.cr @@ -13,7 +13,11 @@ module AST end def typescript_check_decoded(expr, descr) - "" + String.build do |io| + io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" + io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" + io << "}\n" + end end end end diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index fcf20bc..165cfd7 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -17,7 +17,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" - io << " failTypeCheck(#{descr});\n" + io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" io << "}\n" end end diff --git a/src/codegen_types/uint.cr b/src/codegen_types/uint.cr index f95d4d4..9b3f779 100644 --- a/src/codegen_types/uint.cr +++ b/src/codegen_types/uint.cr @@ -13,7 +13,11 @@ module AST end def typescript_check_decoded(expr, descr) - "" + String.build do |io| + io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" + io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" + io << "}\n" + end end end end diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 49b4d06..7ec078b 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -56,7 +56,7 @@ END @io << ident ident op.return_type.typescript_check_decoded("retEncoded", "\"#{op.pretty_name}.ret\"") @io << ident ident "return retEncoded" @io << "\n" - @io << " },\n" + @io << ident "},\n" end @io << "};\n\n" @@ -94,6 +94,7 @@ export function handleHttpPrefix(method: "GET" | "POST" | "PUT" | "DELETE", path } export interface Context { + callId: string; device: DBDevice; startTime: Date; staging: boolean; @@ -161,6 +162,7 @@ export function start(port: number) { const request = JSON.parse(body); request.device.ip = ip; const context: Context = { + callId: "", device: request.device, startTime: new Date, staging: request.staging || false @@ -198,6 +200,8 @@ export function start(port: number) { error: null as {type: string, message: string}|null }; + context.callId = call.id; + if (clearForLogging[call.name]) clearForLogging[call.name](call); From 1550d95696372db6e95b4f66a82e54ee636a4333 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 16:47:10 -0300 Subject: [PATCH 370/625] Add bytes check, and better check output with callId --- src/codegen_types/array.cr | 6 +++--- src/codegen_types/bool.cr | 4 ++-- src/codegen_types/bytes.cr | 8 ++++++-- src/codegen_types/date.cr | 2 +- src/codegen_types/datetime.cr | 2 +- src/codegen_types/enum.cr | 4 ++-- src/codegen_types/float.cr | 4 ++-- src/codegen_types/int.cr | 4 ++-- src/codegen_types/optional.cr | 4 ++-- src/codegen_types/reference.cr | 4 ++-- src/codegen_types/string.cr | 4 ++-- src/codegen_types/struct.cr | 4 ++-- src/codegen_types/uint.cr | 4 ++-- src/codegen_types/void.cr | 2 +- src/target/typescript_nodeserver.cr | 8 ++++---- 15 files changed, 34 insertions(+), 30 deletions(-) diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr index 9fbd21d..383130a 100644 --- a/src/codegen_types/array.cr +++ b/src/codegen_types/array.cr @@ -22,14 +22,14 @@ module AST end end - def typescript_check_decoded(expr, descr) + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (!(#{expr} instanceof Array)) {\n" - io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" + io << " failTypeCheck(#{descr}, ctx);\n" io << "} else {\n" i = random_var io << ident "for (let #{i} = 0; #{i} < #{expr}.length; ++#{i}) {\n" - io << ident ident base.typescript_check_decoded("#{expr}[#{i}]", "#{descr} + \"[\" + #{i} + \"]\"") + io << ident ident base.typescript_check_encoded("#{expr}[#{i}]", "#{descr} + \"[\" + #{i} + \"]\"") io << ident "}\n" io << "}\n" end diff --git a/src/codegen_types/bool.cr b/src/codegen_types/bool.cr index 817ee43..f72d214 100644 --- a/src/codegen_types/bool.cr +++ b/src/codegen_types/bool.cr @@ -12,10 +12,10 @@ module AST "boolean" end - def typescript_check_decoded(expr, descr) + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} !== true && #{expr} !== false) {\n" - io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" + io << " failTypeCheck(#{descr}, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr index 4a20481..1c0fc3b 100644 --- a/src/codegen_types/bytes.cr +++ b/src/codegen_types/bytes.cr @@ -12,8 +12,12 @@ module AST "Buffer" end - def typescript_check_decoded(expr, descr) - "" + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end end end end diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index 0af4673..3b84aac 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -12,7 +12,7 @@ module AST "Date" end - def typescript_check_decoded(expr, descr) + def typescript_check_encoded(expr, descr) "" end end diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index 70b5ed8..efa38ef 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -12,7 +12,7 @@ module AST "Date" end - def typescript_check_decoded(expr, descr) + def typescript_check_encoded(expr, descr) "" end end diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index ffcb4e2..89084c9 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -16,10 +16,10 @@ module AST "export type #{name} = #{values.map(&.inspect).join(" | ")};" end - def typescript_check_decoded(expr, descr) + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" - io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" + io << " failTypeCheck(#{descr}, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/float.cr b/src/codegen_types/float.cr index cc78605..d7e1395 100644 --- a/src/codegen_types/float.cr +++ b/src/codegen_types/float.cr @@ -12,10 +12,10 @@ module AST "number" end - def typescript_check_decoded(expr, descr) + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"number\") {\n" - io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" + io << " failTypeCheck(#{descr}, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/int.cr b/src/codegen_types/int.cr index 2733336..b3941b8 100644 --- a/src/codegen_types/int.cr +++ b/src/codegen_types/int.cr @@ -12,10 +12,10 @@ module AST "number" end - def typescript_check_decoded(expr, descr) + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" - io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" + io << " failTypeCheck(#{descr}, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/optional.cr b/src/codegen_types/optional.cr index 857d51e..4987985 100644 --- a/src/codegen_types/optional.cr +++ b/src/codegen_types/optional.cr @@ -12,12 +12,12 @@ module AST "#{base.typescript_native_type} | null" end - def typescript_check_decoded(expr, descr) + def typescript_check_encoded(expr, descr) String.build do |io| x = random_var io << "const #{x} = #{expr};\n" io << "if (#{x}) {\n" - io << ident base.typescript_check_decoded(x, descr) + io << ident base.typescript_check_encoded(x, descr) io << "}\n" end end diff --git a/src/codegen_types/reference.cr b/src/codegen_types/reference.cr index 32dc3a3..220c8a9 100644 --- a/src/codegen_types/reference.cr +++ b/src/codegen_types/reference.cr @@ -12,8 +12,8 @@ module AST type.typescript_native_type end - def typescript_check_decoded(expr, descr) - type.typescript_check_decoded(expr, descr) + def typescript_check_encoded(expr, descr) + type.typescript_check_encoded(expr, descr) end end end diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index 165cfd7..1b8fd90 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -14,10 +14,10 @@ module AST "string" end - def typescript_check_decoded(expr, descr) + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" - io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" + io << " failTypeCheck(#{descr}, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/struct.cr b/src/codegen_types/struct.cr index 171d91f..f97cef3 100644 --- a/src/codegen_types/struct.cr +++ b/src/codegen_types/struct.cr @@ -34,10 +34,10 @@ module AST end end - def typescript_check_decoded(expr, descr) + def typescript_check_encoded(expr, descr) String.build do |io| fields.each do |field| - io << field.type.typescript_check_decoded("#{expr}.#{field.name}", "#{descr} + \".#{field.name}\"") + io << field.type.typescript_check_encoded("#{expr}.#{field.name}", "#{descr} + \".#{field.name}\"") end end end diff --git a/src/codegen_types/uint.cr b/src/codegen_types/uint.cr index 9b3f779..b2d5db9 100644 --- a/src/codegen_types/uint.cr +++ b/src/codegen_types/uint.cr @@ -12,10 +12,10 @@ module AST "number" end - def typescript_check_decoded(expr, descr) + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" - io << " failTypeCheck(#{descr} + \", callId = \" + ctx.callId);\n" + io << " failTypeCheck(#{descr}, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/void.cr b/src/codegen_types/void.cr index 9e957d1..ea8a6cb 100644 --- a/src/codegen_types/void.cr +++ b/src/codegen_types/void.cr @@ -12,7 +12,7 @@ module AST "void" end - def typescript_check_decoded(expr, descr) + def typescript_check_encoded(expr, descr) "" end end diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 7ec078b..aa67705 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -15,8 +15,8 @@ export function setCaptureErrorFn(fn: (e: Error, req?: http.IncomingMessage, ext captureError = fn; } -function failTypeCheck(descr: string) { - setTimeout(() => captureError(new Error("Invalid Type at '" + descr + "'")), 1); +function failTypeCheck(descr: string, ctx: Context) { + setTimeout(() => captureError(new Error("Invalid Type at '" + descr + "'"), undefined, ctx), 1); } @@ -47,13 +47,13 @@ END @ast.operations.each do |op| @io << " " << op.pretty_name << ": async (ctx: Context, args: any) => {\n" op.args.each do |arg| - @io << ident ident arg.type.typescript_check_decoded("args.#{arg.name}", "\"#{op.pretty_name}.args.#{arg.name}\"") + @io << ident ident arg.type.typescript_check_encoded("args.#{arg.name}", "\"#{op.pretty_name}.args.#{arg.name}\"") @io << ident ident "const #{arg.name} = #{arg.type.typescript_decode("args.#{arg.name}")};" @io << "\n" end @io << ident ident "const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident "const retEncoded = " + op.return_type.typescript_encode("ret") + ";\n" - @io << ident ident op.return_type.typescript_check_decoded("retEncoded", "\"#{op.pretty_name}.ret\"") + @io << ident ident op.return_type.typescript_check_encoded("retEncoded", "\"#{op.pretty_name}.ret\"") @io << ident ident "return retEncoded" @io << "\n" @io << ident "},\n" From 6af2bd67c2f25ef476c4d88753327205a5f5dc0d Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 16:51:31 -0300 Subject: [PATCH 371/625] Add checking for Dates --- src/codegen_types/date.cr | 6 +++++- src/codegen_types/datetime.cr | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index 3b84aac..36fac59 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -13,7 +13,11 @@ module AST end def typescript_check_encoded(expr, descr) - "" + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]$/)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end end end end diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index efa38ef..b289a4c 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -13,7 +13,11 @@ module AST end def typescript_check_encoded(expr, descr) - "" + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end end end end From cb421a5f1003701f955585985f50501a24c6a276 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 16:58:38 -0300 Subject: [PATCH 372/625] Add decoded check for return types --- src/codegen_types/array.cr | 13 +++++++++++++ src/codegen_types/bool.cr | 8 ++++++++ src/codegen_types/bytes.cr | 8 ++++++++ src/codegen_types/date.cr | 8 ++++++++ src/codegen_types/datetime.cr | 8 ++++++++ src/codegen_types/enum.cr | 8 ++++++++ src/codegen_types/float.cr | 8 ++++++++ src/codegen_types/int.cr | 8 ++++++++ src/codegen_types/optional.cr | 10 ++++++++++ src/codegen_types/reference.cr | 4 ++++ src/codegen_types/string.cr | 8 ++++++++ src/codegen_types/struct.cr | 8 ++++++++ src/codegen_types/uint.cr | 8 ++++++++ src/codegen_types/void.cr | 4 ++++ src/target/typescript_nodeserver.cr | 6 ++---- 15 files changed, 113 insertions(+), 4 deletions(-) diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr index 383130a..b8f7d9b 100644 --- a/src/codegen_types/array.cr +++ b/src/codegen_types/array.cr @@ -34,5 +34,18 @@ module AST io << "}\n" end end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (!(#{expr} instanceof Array)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "} else {\n" + i = random_var + io << ident "for (let #{i} = 0; #{i} < #{expr}.length; ++#{i}) {\n" + io << ident ident base.typescript_check_decoded("#{expr}[#{i}]", "#{descr} + \"[\" + #{i} + \"]\"") + io << ident "}\n" + io << "}\n" + end + end end end diff --git a/src/codegen_types/bool.cr b/src/codegen_types/bool.cr index f72d214..85a09d0 100644 --- a/src/codegen_types/bool.cr +++ b/src/codegen_types/bool.cr @@ -19,5 +19,13 @@ module AST io << "}\n" end end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (#{expr} !== true && #{expr} !== false) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end end end diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr index 1c0fc3b..8610f51 100644 --- a/src/codegen_types/bytes.cr +++ b/src/codegen_types/bytes.cr @@ -19,5 +19,13 @@ module AST io << "}\n" end end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (!(#{expr} instanceof Buffer)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end end end diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index 36fac59..a026b90 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -19,5 +19,13 @@ module AST io << "}\n" end end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (!(#{expr} instanceof Date)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end end end diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index b289a4c..6d3b7ed 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -19,5 +19,13 @@ module AST io << "}\n" end end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (!(#{expr} instanceof Date)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end end end diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index 89084c9..4ea4a39 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -23,5 +23,13 @@ module AST io << "}\n" end end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end end end diff --git a/src/codegen_types/float.cr b/src/codegen_types/float.cr index d7e1395..5b79f14 100644 --- a/src/codegen_types/float.cr +++ b/src/codegen_types/float.cr @@ -19,5 +19,13 @@ module AST io << "}\n" end end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"number\") {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end end end diff --git a/src/codegen_types/int.cr b/src/codegen_types/int.cr index b3941b8..9cfcaf2 100644 --- a/src/codegen_types/int.cr +++ b/src/codegen_types/int.cr @@ -19,5 +19,13 @@ module AST io << "}\n" end end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end end end diff --git a/src/codegen_types/optional.cr b/src/codegen_types/optional.cr index 4987985..b64e5c5 100644 --- a/src/codegen_types/optional.cr +++ b/src/codegen_types/optional.cr @@ -21,5 +21,15 @@ module AST io << "}\n" end end + + def typescript_check_decoded(expr, descr) + String.build do |io| + x = random_var + io << "const #{x} = #{expr};\n" + io << "if (#{x}) {\n" + io << ident base.typescript_check_decoded(x, descr) + io << "}\n" + end + end end end diff --git a/src/codegen_types/reference.cr b/src/codegen_types/reference.cr index 220c8a9..68818bf 100644 --- a/src/codegen_types/reference.cr +++ b/src/codegen_types/reference.cr @@ -15,5 +15,9 @@ module AST def typescript_check_encoded(expr, descr) type.typescript_check_encoded(expr, descr) end + + def typescript_check_decoded(expr, descr) + type.typescript_check_decoded(expr, descr) + end end end diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index 1b8fd90..206572f 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -21,5 +21,13 @@ module AST io << "}\n" end end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\") {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end end end diff --git a/src/codegen_types/struct.cr b/src/codegen_types/struct.cr index f97cef3..8d47139 100644 --- a/src/codegen_types/struct.cr +++ b/src/codegen_types/struct.cr @@ -41,5 +41,13 @@ module AST end end end + + def typescript_check_decoded(expr, descr) + String.build do |io| + fields.each do |field| + io << field.type.typescript_check_decoded("#{expr}.#{field.name}", "#{descr} + \".#{field.name}\"") + end + end + end end end diff --git a/src/codegen_types/uint.cr b/src/codegen_types/uint.cr index b2d5db9..497d72c 100644 --- a/src/codegen_types/uint.cr +++ b/src/codegen_types/uint.cr @@ -19,5 +19,13 @@ module AST io << "}\n" end end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end end end diff --git a/src/codegen_types/void.cr b/src/codegen_types/void.cr index ea8a6cb..7dead1b 100644 --- a/src/codegen_types/void.cr +++ b/src/codegen_types/void.cr @@ -15,5 +15,9 @@ module AST def typescript_check_encoded(expr, descr) "" end + + def typescript_check_decoded(expr, descr) + "" + end end end diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index aa67705..388c55b 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -52,10 +52,8 @@ END @io << "\n" end @io << ident ident "const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" - @io << ident ident "const retEncoded = " + op.return_type.typescript_encode("ret") + ";\n" - @io << ident ident op.return_type.typescript_check_encoded("retEncoded", "\"#{op.pretty_name}.ret\"") - @io << ident ident "return retEncoded" - @io << "\n" + @io << ident ident op.return_type.typescript_check_decoded("ret", "\"#{op.pretty_name}.ret\"") + @io << ident ident "return " + op.return_type.typescript_encode("ret") + ";\n" @io << ident "},\n" end @io << "};\n\n" From bae6a8f409fd4a554116efb735ccfcbce15452fe Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 17:05:19 -0300 Subject: [PATCH 373/625] improve identation --- src/codegen_types/struct.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codegen_types/struct.cr b/src/codegen_types/struct.cr index 8d47139..dd81a2e 100644 --- a/src/codegen_types/struct.cr +++ b/src/codegen_types/struct.cr @@ -4,7 +4,7 @@ module AST String::Builder.build do |io| io << "{\n" fields.each do |field| - io << " #{field.name}: #{field.type.typescript_decode("#{expr}.#{field.name}")},\n" + io << ident "#{field.name}: #{field.type.typescript_decode("#{expr}.#{field.name}")},\n" end io << "}" end @@ -14,7 +14,7 @@ module AST String::Builder.build do |io| io << "{\n" fields.each do |field| - io << " #{field.name}: #{field.type.typescript_encode("#{expr}.#{field.name}")},\n" + io << ident "#{field.name}: #{field.type.typescript_encode("#{expr}.#{field.name}")},\n" end io << "}" end From d9cb329cd5b12f8a815a1de17028a2dfc4d450fc Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 17:27:51 -0300 Subject: [PATCH 374/625] Check and fail when redefining type or field --- spec/parser_spec.cr | 76 +++++++++++++++------- spec/semantic_spec.cr | 26 ++++++++ src/semantic/ast_semantic.cr | 2 + src/semantic/check_multiple_declaration.cr | 15 +++++ src/syntax/parser.cr | 16 ++++- 5 files changed, 110 insertions(+), 25 deletions(-) create mode 100644 spec/semantic_spec.cr create mode 100644 src/semantic/check_multiple_declaration.cr diff --git a/spec/parser_spec.cr b/spec/parser_spec.cr index ca979f1..5f3e516 100644 --- a/spec/parser_spec.cr +++ b/spec/parser_spec.cr @@ -1,43 +1,29 @@ require "spec" -require "../src/syntax/lexer" require "../src/syntax/parser" require "../src/syntax/ast_to_s" -def clear(code) - code = code.strip - code = code.gsub /\/\/.*/, "" - code = code.gsub /\n\s+/, "\n" - code = code.gsub /\n+/, "\n" - code -end - -def check_parses(code) - parser = Parser.new(IO::Memory.new(code)) - ast = parser.parse - clear(ast.to_s).should eq clear(code) -end - PRIMITIVES = %w[string int uint date datetime bytes float bool] + describe Parser do - {% for p in PRIMITIVES %} - it "handles primitive type '#{{{p}}}'" do + PRIMITIVES.each do |p| + it "handles primitive type '#{p}'" do check_parses <<-END type Foo { - foo: #{{{p}}} + foo: #{p} } END end - {% end %} + end - {% for kw in PRIMITIVES + %w[type get function enum import error void] %} - it "handles '#{{{kw}}}' on the name of a field" do + (PRIMITIVES + %w[type get function enum import error void]).each do |kw| + it "handles '#{kw}' on the name of a field" do check_parses <<-END type Foo { - #{{{kw}}}: int + #{kw}: int } END end - {% end %} + end it "handles arrays and optionals" do check_parses <<-END @@ -89,4 +75,48 @@ describe Parser do get baz(): Baz END end + + it "fails when field happens twice" do + check_doesnt_parse(<<-END + type Baz { + a: int + b: bool + a: int + } + END + , "redeclare") + + check_doesnt_parse(<<-END + type Baz { + b: int + xx: bool + xx: int + } + END + , "redeclare") + + check_doesnt_parse(<<-END + function foo(a: string, a: int) + END + , "redeclare") + end +end + +def clear(code) + code = code.strip + code = code.gsub /\/\/.*/, "" + code = code.gsub /\n\s+/, "\n" + code = code.gsub /\n+/, "\n" + code +end + +def check_parses(code) + parser = Parser.new(IO::Memory.new(code)) + ast = parser.parse + clear(ast.to_s).should eq clear(code) +end + +def check_doesnt_parse(code, message) + parser = Parser.new(IO::Memory.new(code)) + expect_raises(Parser::ParserException, message) { parser.parse } end diff --git a/spec/semantic_spec.cr b/spec/semantic_spec.cr new file mode 100644 index 0000000..b186167 --- /dev/null +++ b/spec/semantic_spec.cr @@ -0,0 +1,26 @@ +require "spec" +require "../src/syntax/parser" +require "../src/semantic/ast_semantic" + +describe Semantic do + it "fails when type definition appears twice" do + expect_raises(Exception, "already defined") do + parse <<-END + type X { + + } + + type X { + + } + END + end + end +end + +def parse(code) + parser = Parser.new(IO::Memory.new(code)) + ast = parser.parse + ast.semantic + ast +end diff --git a/src/semantic/ast_semantic.cr b/src/semantic/ast_semantic.cr index 5f3c570..9f7cd60 100644 --- a/src/semantic/ast_semantic.cr +++ b/src/semantic/ast_semantic.cr @@ -6,6 +6,7 @@ require "./check_naming_for_getters_returning_bool" require "./check_empty_enum" require "./give_struct_and_enum_names" require "./collect_struct_and_enum_types" +require "./check_multiple_declaration" module AST class ApiDescription @@ -35,6 +36,7 @@ module AST op.return_type = AST::VoidPrimitiveType.new operations << op + Semantic::CheckMultipleDeclaration.visit(self) Semantic::MatchTypeDefinitions.visit(self) Semantic::CheckNoRecursiveTypes.visit(self) Semantic::CheckDontReturnSecret.visit(self) diff --git a/src/semantic/check_multiple_declaration.cr b/src/semantic/check_multiple_declaration.cr new file mode 100644 index 0000000..e5b2ca3 --- /dev/null +++ b/src/semantic/check_multiple_declaration.cr @@ -0,0 +1,15 @@ +require "./visitor" + +module Semantic + class CheckMultipleDeclaration < Visitor + @names = Set(String).new + + def visit(definition : AST::TypeDefinition) + if @names.includes? definition.name + raise "Type '#{definition.name}' is already defined" + end + @names << definition.name + super + end + end +end diff --git a/src/syntax/parser.cr b/src/syntax/parser.cr index 150b8ae..34ed78c 100644 --- a/src/syntax/parser.cr +++ b/src/syntax/parser.cr @@ -139,11 +139,17 @@ class Parser read_next_token t = AST::StructType.new + field_names = Set(String).new while true case token = multi_expect(IdentifierToken, CurlyCloseSymbolToken) when IdentifierToken - t.fields << parse_field + f = parse_field + if field_names.includes? f.name + raise ParserException.new "Cannot redeclare field '#{f.name}'" + end + field_names << f.name + t.fields << f when CurlyCloseSymbolToken read_next_token return t @@ -166,13 +172,19 @@ class Parser op.name = expect(IdentifierToken).name ref_deprecated_location_token = @token.not_nil! read_next_token + arg_names = Set(String).new if @token.is_a? ParensOpenSymbolToken read_next_token while true case token = multi_expect(IdentifierToken, ParensCloseSymbolToken, CommaSymbolToken) when IdentifierToken - op.args << parse_field + f = parse_field + if arg_names.includes? f.name + raise ParserException.new "Cannot redeclare argument '#{f.name}'" + end + arg_names << f.name + op.args << f when ParensCloseSymbolToken read_next_token break From 38d2ba9527743fe712684e7388383005e2026bac Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 28 Oct 2017 20:23:07 -0300 Subject: [PATCH 375/625] Improve semantic exceptions --- spec/semantic_spec.cr | 2 +- src/main.cr | 2 +- src/semantic/ast_semantic.cr | 5 +++++ src/semantic/check_dont_return_secret.cr | 2 +- src/semantic/check_empty_enum.cr | 2 +- src/semantic/check_multiple_declaration.cr | 2 +- src/semantic/check_naming_for_getters_returning_bool.cr | 4 ++-- src/semantic/check_no_recursive_types.cr | 2 +- src/semantic/match_type_definitions.cr | 2 +- 9 files changed, 14 insertions(+), 9 deletions(-) diff --git a/spec/semantic_spec.cr b/spec/semantic_spec.cr index b186167..fd09014 100644 --- a/spec/semantic_spec.cr +++ b/spec/semantic_spec.cr @@ -4,7 +4,7 @@ require "../src/semantic/ast_semantic" describe Semantic do it "fails when type definition appears twice" do - expect_raises(Exception, "already defined") do + expect_raises(Exception, "defined") do parse <<-END type X { diff --git a/src/main.cr b/src/main.cr index aade26a..12e7a58 100644 --- a/src/main.cr +++ b/src/main.cr @@ -48,7 +48,7 @@ begin FileUtils.mkdir_p(File.dirname(destination)) Target.process(ast, destination, target_name) -rescue ex : Lexer::LexerException | Parser::ParserException +rescue ex : Lexer::LexerException | Parser::ParserException | Semantic::SemanticException STDERR.puts (ex.message || "Invalid source").colorize.light_red rescue ex : Exception raise ex diff --git a/src/semantic/ast_semantic.cr b/src/semantic/ast_semantic.cr index 9f7cd60..cdea8e5 100644 --- a/src/semantic/ast_semantic.cr +++ b/src/semantic/ast_semantic.cr @@ -8,6 +8,11 @@ require "./give_struct_and_enum_names" require "./collect_struct_and_enum_types" require "./check_multiple_declaration" +module Semantic + class SemanticException < Exception + end +end + module AST class ApiDescription property struct_types = [] of AST::StructType diff --git a/src/semantic/check_dont_return_secret.cr b/src/semantic/check_dont_return_secret.cr index 5658cb6..c504c79 100644 --- a/src/semantic/check_dont_return_secret.cr +++ b/src/semantic/check_dont_return_secret.cr @@ -20,7 +20,7 @@ module Semantic def visit(field : AST::Field) @path.push field.name if @inreturn && field.secret - raise "Can't return a secret value at #{@path.join(".")}" + raise SemanticException.new("Can't return a secret value at #{@path.join(".")}") end super @path.pop diff --git a/src/semantic/check_empty_enum.cr b/src/semantic/check_empty_enum.cr index 0dd2259..194b70e 100644 --- a/src/semantic/check_empty_enum.cr +++ b/src/semantic/check_empty_enum.cr @@ -5,7 +5,7 @@ module Semantic def visit(t : AST::EnumType) super if t.values.size == 0 - raise "Enum '#{t.name}' is empty" + raise SemanticException.new("Enum '#{t.name}' is empty") end end end diff --git a/src/semantic/check_multiple_declaration.cr b/src/semantic/check_multiple_declaration.cr index e5b2ca3..c96c180 100644 --- a/src/semantic/check_multiple_declaration.cr +++ b/src/semantic/check_multiple_declaration.cr @@ -6,7 +6,7 @@ module Semantic def visit(definition : AST::TypeDefinition) if @names.includes? definition.name - raise "Type '#{definition.name}' is already defined" + raise SemanticException.new("Type '#{definition.name}' is defined multiple times") end @names << definition.name super diff --git a/src/semantic/check_naming_for_getters_returning_bool.cr b/src/semantic/check_naming_for_getters_returning_bool.cr index a5adda1..9af565b 100644 --- a/src/semantic/check_naming_for_getters_returning_bool.cr +++ b/src/semantic/check_naming_for_getters_returning_bool.cr @@ -7,9 +7,9 @@ module Semantic is_bool = op.return_type.is_a? AST::BoolPrimitiveType has_bool_name = op.name =~ /^(is|has|can|may|should)/ if is_bool && !has_bool_name - raise "Get operation '#{op.name}' returns bool but isn't named accordingly" + raise SemanticException.new("Get operation '#{op.name}' returns bool but isn't named accordingly") elsif !is_bool && has_bool_name - raise "Get operation '#{op.name}' doesn't return bool but its name suggest it does" + raise SemanticException.new("Get operation '#{op.name}' doesn't return bool but its name suggest it does") end end end diff --git a/src/semantic/check_no_recursive_types.cr b/src/semantic/check_no_recursive_types.cr index d76fb29..30ec185 100644 --- a/src/semantic/check_no_recursive_types.cr +++ b/src/semantic/check_no_recursive_types.cr @@ -17,7 +17,7 @@ module Semantic def visit(ref : AST::TypeReference) if ref.name == @path[0] - raise "Detected type recursion: #{@path.join(".")}" + raise SemanticException.new("Detected type recursion: #{@path.join(".")}") end visit ref.type super diff --git a/src/semantic/match_type_definitions.cr b/src/semantic/match_type_definitions.cr index fe7cb82..e3103a4 100644 --- a/src/semantic/match_type_definitions.cr +++ b/src/semantic/match_type_definitions.cr @@ -5,7 +5,7 @@ module Semantic def visit(ref : AST::TypeReference) definition = @ast.type_definitions.find { |t| t.name == ref.name } unless definition - raise "Could not find type '#{ref.name}'" + raise SemanticException.new("Could not find type '#{ref.name}'") end ref.type = definition.type super From 4caeaee6ad520b8f643683171eb35b41d15270af Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 29 Oct 2017 07:59:03 -0300 Subject: [PATCH 376/625] Add many new types --- ext/vscode/syntaxes/sdkgen.tmLanguage.json | 2 +- spec/lexer_spec.cr | 2 +- spec/parser_spec.cr | 8 +-- src/ast.cr | 39 +++++++++++ src/codegen_types/base64.cr | 31 +++++++++ src/codegen_types/cep.cr | 31 +++++++++ src/codegen_types/cnpj.cr | 31 +++++++++ src/codegen_types/cpf.cr | 31 +++++++++ src/codegen_types/email.cr | 31 +++++++++ src/codegen_types/hex.cr | 31 +++++++++ src/codegen_types/latlng.cr | 27 ++++++++ src/codegen_types/money.cr | 31 +++++++++ src/codegen_types/phone.cr | 31 +++++++++ src/codegen_types/safehtml.cr | 31 +++++++++ src/codegen_types/url.cr | 31 +++++++++ src/codegen_types/uuid.cr | 31 +++++++++ src/codegen_types/xml.cr | 31 +++++++++ src/syntax/ast_to_s.cr | 78 ++++++++++++++++++++++ src/syntax/lexer.cr | 16 +++-- src/syntax/parser.cr | 13 ++++ 20 files changed, 545 insertions(+), 12 deletions(-) create mode 100644 src/codegen_types/base64.cr create mode 100644 src/codegen_types/cep.cr create mode 100644 src/codegen_types/cnpj.cr create mode 100644 src/codegen_types/cpf.cr create mode 100644 src/codegen_types/email.cr create mode 100644 src/codegen_types/hex.cr create mode 100644 src/codegen_types/latlng.cr create mode 100644 src/codegen_types/money.cr create mode 100644 src/codegen_types/phone.cr create mode 100644 src/codegen_types/safehtml.cr create mode 100644 src/codegen_types/url.cr create mode 100644 src/codegen_types/uuid.cr create mode 100644 src/codegen_types/xml.cr diff --git a/ext/vscode/syntaxes/sdkgen.tmLanguage.json b/ext/vscode/syntaxes/sdkgen.tmLanguage.json index 49981e2..04cacd7 100644 --- a/ext/vscode/syntaxes/sdkgen.tmLanguage.json +++ b/ext/vscode/syntaxes/sdkgen.tmLanguage.json @@ -105,7 +105,7 @@ "include": "#any" }, { "name": "keyword.type", - "match": "\\b(bool|int|uint|float|string|datetime|date|bytes|void)\\b" + "match": "\\b(bool|int|uint|float|string|datetime|date|bytes|void|money|cpf|cnpj|email|phone|cep|latlng|url|uuid|hex|base64|safehtml|xml)\\b" }, { "name": "markup.bold", "match": "(\\?|\\[\\])" diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index 7a03649..3fe14fc 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -71,7 +71,7 @@ describe Lexer do ] end - %w[string int uint date datetime bytes float bool].each do |primitive| + Lexer::PRIMITIVES.each do |primitive| it_lexes primitive, [ PrimitiveTypeToken.new(primitive), ] diff --git a/spec/parser_spec.cr b/spec/parser_spec.cr index 5f3e516..5397fb6 100644 --- a/spec/parser_spec.cr +++ b/spec/parser_spec.cr @@ -2,10 +2,8 @@ require "spec" require "../src/syntax/parser" require "../src/syntax/ast_to_s" -PRIMITIVES = %w[string int uint date datetime bytes float bool] - describe Parser do - PRIMITIVES.each do |p| + Lexer::PRIMITIVES.each do |p| it "handles primitive type '#{p}'" do check_parses <<-END type Foo { @@ -15,7 +13,7 @@ describe Parser do end end - (PRIMITIVES + %w[type get function enum import error void]).each do |kw| + (Lexer::PRIMITIVES + %w[type get function enum import error void]).each do |kw| it "handles '#{kw}' on the name of a field" do check_parses <<-END type Foo { @@ -45,7 +43,7 @@ describe Parser do end it "handles simple get operations" do - PRIMITIVES.each do |primitive| + Lexer::PRIMITIVES.each do |primitive| check_parses <<-END get foo(): #{primitive} get bar(): #{primitive}? diff --git a/src/ast.cr b/src/ast.cr index 375b56a..60656d1 100644 --- a/src/ast.cr +++ b/src/ast.cr @@ -32,6 +32,45 @@ module AST class VoidPrimitiveType < PrimitiveType end + class MoneyPrimitiveType < PrimitiveType + end + + class CpfPrimitiveType < PrimitiveType + end + + class CnpjPrimitiveType < PrimitiveType + end + + class EmailPrimitiveType < PrimitiveType + end + + class PhonePrimitiveType < PrimitiveType + end + + class CepPrimitiveType < PrimitiveType + end + + class LatLngPrimitiveType < PrimitiveType + end + + class UrlPrimitiveType < PrimitiveType + end + + class UuidPrimitiveType < PrimitiveType + end + + class HexPrimitiveType < PrimitiveType + end + + class Base64PrimitiveType < PrimitiveType + end + + class SafeHtmlPrimitiveType < PrimitiveType + end + + class XmlPrimitiveType < PrimitiveType + end + class OptionalType < Type property base diff --git a/src/codegen_types/base64.cr b/src/codegen_types/base64.cr new file mode 100644 index 0000000..98d1a67 --- /dev/null +++ b/src/codegen_types/base64.cr @@ -0,0 +1,31 @@ +module AST + class Base64PrimitiveType + def typescript_decode(expr) + "#{expr}" + end + + def typescript_encode(expr) + "#{expr}" + end + + def typescript_native_type + "string" + end + + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + end +end diff --git a/src/codegen_types/cep.cr b/src/codegen_types/cep.cr new file mode 100644 index 0000000..d78dcf2 --- /dev/null +++ b/src/codegen_types/cep.cr @@ -0,0 +1,31 @@ +module AST + class CepPrimitiveType + def typescript_decode(expr) + "#{expr}.replace(/(..)(...)(...)/, \"$1.$2-$3\")" + end + + def typescript_encode(expr) + "#{expr}.replace(/[^0-9]/g, \"\").padStart(8, \"0\")" + end + + def typescript_native_type + "string" + end + + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + end +end diff --git a/src/codegen_types/cnpj.cr b/src/codegen_types/cnpj.cr new file mode 100644 index 0000000..789c25b --- /dev/null +++ b/src/codegen_types/cnpj.cr @@ -0,0 +1,31 @@ +module AST + class CnpjPrimitiveType + def typescript_decode(expr) + "#{expr}.replace(/(..)(...)(...)(....)(..)/, \"$1.$2.$3/$4-$5\")" + end + + def typescript_encode(expr) + "#{expr}.replace(/[^0-9]/g, \"\").padStart(14, \"0\")" + end + + def typescript_native_type + "string" + end + + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + end +end diff --git a/src/codegen_types/cpf.cr b/src/codegen_types/cpf.cr new file mode 100644 index 0000000..8f83b33 --- /dev/null +++ b/src/codegen_types/cpf.cr @@ -0,0 +1,31 @@ +module AST + class CpfPrimitiveType + def typescript_decode(expr) + "#{expr}.replace(/(...)(...)(...)(..)/, \"$1.$2.$3-$4\")" + end + + def typescript_encode(expr) + "#{expr}.replace(/[^0-9]/g, \"\").padStart(11, \"0\")" + end + + def typescript_native_type + "string" + end + + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + end +end diff --git a/src/codegen_types/email.cr b/src/codegen_types/email.cr new file mode 100644 index 0000000..152ba1f --- /dev/null +++ b/src/codegen_types/email.cr @@ -0,0 +1,31 @@ +module AST + class EmailPrimitiveType + def typescript_decode(expr) + "#{expr}.normalize()" + end + + def typescript_encode(expr) + "#{expr}.normalize()" + end + + def typescript_native_type + "string" + end + + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + end +end diff --git a/src/codegen_types/hex.cr b/src/codegen_types/hex.cr new file mode 100644 index 0000000..25bd5c9 --- /dev/null +++ b/src/codegen_types/hex.cr @@ -0,0 +1,31 @@ +module AST + class HexPrimitiveType + def typescript_decode(expr) + "#{expr}" + end + + def typescript_encode(expr) + "#{expr}" + end + + def typescript_native_type + "string" + end + + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + end +end diff --git a/src/codegen_types/latlng.cr b/src/codegen_types/latlng.cr new file mode 100644 index 0000000..98dbbaf --- /dev/null +++ b/src/codegen_types/latlng.cr @@ -0,0 +1,27 @@ +module AST + class LatLngPrimitiveType + def typescript_decode(expr) + "{lat: #{expr}.lat, lng: #{expr}.lng}" + end + + def typescript_encode(expr) + "{lat: #{expr}.lat, lng: #{expr}.lng}" + end + + def typescript_native_type + "{lat: number, lng: number}" + end + + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"object\" || typeof #{expr}.lat !== \"number\" || typeof #{expr}.lng !== \"number\") {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + + def typescript_check_decoded(expr, descr) + typescript_check_encoded(expr, descr) + end + end +end diff --git a/src/codegen_types/money.cr b/src/codegen_types/money.cr new file mode 100644 index 0000000..19d862d --- /dev/null +++ b/src/codegen_types/money.cr @@ -0,0 +1,31 @@ +module AST + class MoneyPrimitiveType + def typescript_decode(expr) + "#{expr}|0" + end + + def typescript_encode(expr) + "#{expr}|0" + end + + def typescript_native_type + "number" + end + + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + end +end diff --git a/src/codegen_types/phone.cr b/src/codegen_types/phone.cr new file mode 100644 index 0000000..a0bea59 --- /dev/null +++ b/src/codegen_types/phone.cr @@ -0,0 +1,31 @@ +module AST + class PhonePrimitiveType + def typescript_decode(expr) + "#{expr}" + end + + def typescript_encode(expr) + "#{expr}.replace(/[^0-9+]/g, \"\")" + end + + def typescript_native_type + "string" + end + + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + end +end diff --git a/src/codegen_types/safehtml.cr b/src/codegen_types/safehtml.cr new file mode 100644 index 0000000..92eefc4 --- /dev/null +++ b/src/codegen_types/safehtml.cr @@ -0,0 +1,31 @@ +module AST + class SafeHtmlPrimitiveType + def typescript_decode(expr) + "#{expr}.normalize()" + end + + def typescript_encode(expr) + "#{expr}.normalize()" + end + + def typescript_native_type + "string" + end + + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\") {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\") {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + end +end diff --git a/src/codegen_types/url.cr b/src/codegen_types/url.cr new file mode 100644 index 0000000..0b37488 --- /dev/null +++ b/src/codegen_types/url.cr @@ -0,0 +1,31 @@ +module AST + class UrlPrimitiveType + def typescript_decode(expr) + "#{expr}.normalize()" + end + + def typescript_encode(expr) + "#{expr}.normalize()" + end + + def typescript_native_type + "string" + end + + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\") {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\") {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + end +end diff --git a/src/codegen_types/uuid.cr b/src/codegen_types/uuid.cr new file mode 100644 index 0000000..7038e1e --- /dev/null +++ b/src/codegen_types/uuid.cr @@ -0,0 +1,31 @@ +module AST + class UuidPrimitiveType + def typescript_decode(expr) + "#{expr}" + end + + def typescript_encode(expr) + "#{expr}" + end + + def typescript_native_type + "string" + end + + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + end +end diff --git a/src/codegen_types/xml.cr b/src/codegen_types/xml.cr new file mode 100644 index 0000000..02f5c7f --- /dev/null +++ b/src/codegen_types/xml.cr @@ -0,0 +1,31 @@ +module AST + class XmlPrimitiveType + def typescript_decode(expr) + "#{expr}.normalize()" + end + + def typescript_encode(expr) + "#{expr}.normalize()" + end + + def typescript_native_type + "string" + end + + def typescript_check_encoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\") {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + + def typescript_check_decoded(expr, descr) + String.build do |io| + io << "if (typeof #{expr} !== \"string\") {\n" + io << " failTypeCheck(#{descr}, ctx);\n" + io << "}\n" + end + end + end +end diff --git a/src/syntax/ast_to_s.cr b/src/syntax/ast_to_s.cr index 483ded8..435606e 100644 --- a/src/syntax/ast_to_s.cr +++ b/src/syntax/ast_to_s.cr @@ -55,6 +55,84 @@ module AST end end + class MoneyPrimitiveType + def to_s(io) + io << "money" + end + end + + class CpfPrimitiveType + def to_s(io) + io << "cpf" + end + end + + class CnpjPrimitiveType + def to_s(io) + io << "cnpj" + end + end + + class EmailPrimitiveType + def to_s(io) + io << "email" + end + end + + class PhonePrimitiveType + def to_s(io) + io << "phone" + end + end + + class CepPrimitiveType + def to_s(io) + io << "cep" + end + end + + class LatLngPrimitiveType + def to_s(io) + io << "latlng" + end + end + + class UrlPrimitiveType + def to_s(io) + io << "url" + end + end + + class UuidPrimitiveType + def to_s(io) + io << "uuid" + end + end + + class HexPrimitiveType + def to_s(io) + io << "hex" + end + end + + class Base64PrimitiveType + def to_s(io) + io << "base64" + end + end + + class SafeHtmlPrimitiveType + def to_s(io) + io << "safehtml" + end + end + + class XmlPrimitiveType + def to_s(io) + io << "xml" + end + end + class OptionalType def to_s(io) @base.to_s(io) diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index 952a526..cf4e231 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -1,6 +1,12 @@ require "./token" class Lexer + PRIMITIVES = %w[ + bool int uint float string date datetime bytes + money cpf cnpj email phone cep latlng url + uuid hex base64 safehtml xml + ] + property filename : String class LexerException < Exception @@ -155,12 +161,12 @@ class Lexer when "import" ; ImportKeywordToken.new when "get" ; GetKeywordToken.new when "function"; FunctionKeywordToken.new - when "bool", "int", "uint", "float", "string", "date", "datetime", "bytes", - "money", "cpf", "cnpj", "email", "phone", "cep", "latlng", "url", - "uuid", "hex", "base64", "safehtml", "xml" - PrimitiveTypeToken.new(str) else - IdentifierToken.new(str) + if PRIMITIVES.includes? str + PrimitiveTypeToken.new(str) + else + IdentifierToken.new(str) + end end end end diff --git a/src/syntax/parser.cr b/src/syntax/parser.cr index 34ed78c..464b5b8 100644 --- a/src/syntax/parser.cr +++ b/src/syntax/parser.cr @@ -268,6 +268,19 @@ class Parser when "float" ; AST::FloatPrimitiveType.new when "bool" ; AST::BoolPrimitiveType.new when "bytes" ; AST::BytesPrimitiveType.new + when "money" ; AST::MoneyPrimitiveType.new + when "cpf" ; AST::CpfPrimitiveType.new + when "cnpj" ; AST::CnpjPrimitiveType.new + when "email" ; AST::EmailPrimitiveType.new + when "phone" ; AST::PhonePrimitiveType.new + when "cep" ; AST::CepPrimitiveType.new + when "latlng" ; AST::LatLngPrimitiveType.new + when "url" ; AST::UrlPrimitiveType.new + when "uuid" ; AST::UuidPrimitiveType.new + when "hex" ; AST::HexPrimitiveType.new + when "base64" ; AST::Base64PrimitiveType.new + when "safehtml"; AST::SafeHtmlPrimitiveType.new + when "xml" ; AST::XmlPrimitiveType.new else raise "BUG! Should handle primitive #{token.name}" end From ea31bd02ef6d0102ff85a0671ab41c6d39f8a0ee Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 30 Oct 2017 19:13:08 -0300 Subject: [PATCH 377/625] More rich info for failTypeCheck --- src/target/typescript_nodeserver.cr | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 388c55b..9b12d3f 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -16,7 +16,7 @@ export function setCaptureErrorFn(fn: (e: Error, req?: http.IncomingMessage, ext } function failTypeCheck(descr: string, ctx: Context) { - setTimeout(() => captureError(new Error("Invalid Type at '" + descr + "'"), undefined, ctx), 1); + setTimeout(() => captureError(new Error("Invalid Type at '" + descr + "'"), ctx.req, ctx.call), 1); } @@ -92,8 +92,9 @@ export function handleHttpPrefix(method: "GET" | "POST" | "PUT" | "DELETE", path } export interface Context { - callId: string; + call: DBApiCall; device: DBDevice; + req: http.IncomingMessage; startTime: Date; staging: boolean; } @@ -160,7 +161,8 @@ export function start(port: number) { const request = JSON.parse(body); request.device.ip = ip; const context: Context = { - callId: "", + call: null as any, + req: req, device: request.device, startTime: new Date, staging: request.staging || false @@ -198,7 +200,7 @@ export function start(port: number) { error: null as {type: string, message: string}|null }; - context.callId = call.id; + context.call = call; if (clearForLogging[call.name]) clearForLogging[call.name](call); From dda0c06e02429e0a89a1ed27dfd45a379cbe303f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 30 Oct 2017 19:26:42 -0300 Subject: [PATCH 378/625] Fix wrong identation --- src/utils.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils.cr b/src/utils.cr index 518b8e2..35852d4 100644 --- a/src/utils.cr +++ b/src/utils.cr @@ -11,5 +11,6 @@ def random_var end def ident(code) + return "" if code.strip == "" code.split("\n").map { |line| " " + line }.join("\n").gsub(/\n\s+$/m, "\n") end From 1ec7ea08b256d0bc5b94a3d8943ee63d2135c539 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 4 Nov 2017 13:10:04 -0300 Subject: [PATCH 379/625] Expose node server --- src/target/typescript_nodeserver.cr | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 9b12d3f..ecf78c9 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -103,8 +103,11 @@ function sleep(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)); } +export let server: http.Server; + export function start(port: number) { - const server = http.createServer((req, res) => { + if (server) return; + server = http.createServer((req, res) => { req.on("error", (err) => { console.error(err); }); From b772a0683dd53ac15bb5a7acc3971b69061db345 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 4 Nov 2017 13:10:07 -0300 Subject: [PATCH 380/625] update ext --- ext/vscode/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/vscode/package.json b/ext/vscode/package.json index aa8e03a..3ed6ca4 100644 --- a/ext/vscode/package.json +++ b/ext/vscode/package.json @@ -2,7 +2,7 @@ "name": "sdkgen", "displayName": "sdkgen", "description": "sdkgen language support", - "version": "0.0.3", + "version": "0.0.4", "publisher": "cubos", "engines": { "vscode": "^1.10.0" @@ -23,4 +23,4 @@ "path": "./syntaxes/sdkgen.tmLanguage.json" }] } -} \ No newline at end of file +} From 7c450c051ef6aa5f56ca13c199bae7f4722f1efa Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 6 Nov 2017 10:45:45 -0300 Subject: [PATCH 381/625] For node, turn errors into classes --- src/target/typescript_nodeserver.cr | 30 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index ecf78c9..886fd43 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -70,9 +70,17 @@ END end @io << "};\n\n" + @ast.errors.each do |error| + @io << "export class #{error} extends Error {\n" + @io << ident "constructor(message: string) {\n" + @io << ident ident "super(message ? \"#{error}: \" + message : #{error.inspect});\n" + @io << ident "}\n" + @io << "}\n\n" + end + @io << "export const err = {\n" @ast.errors.each do |error| - @io << ident "#{error}: (message: string = \"\") => { throw {type: #{error.inspect}, message}; },\n" + @io << ident "#{error}: (message: string = \"\") => { throw new #{error}(message); },\n" end @io << "};\n\n" @@ -242,17 +250,15 @@ export function start(port: number) { } catch (err) { console.error(err); call.ok = false; - if (err.type) { - call.error = { - type: err.type, - message: err.message - }; - } else { - call.error = { - type: "Fatal", - message: err.toString() - }; - } + call.error = { + type: "Fatal", + message: err.toString() + }; +#{ident ident ident ident ident ident ident ident ident(String.build do |io| + @ast.errors.each do |error| + io << "if (err instanceof #{error})\n call.error = {type: #{error.inspect}, message: err.message};\n" + end +end)} } call.running = false; const deltaTime = process.hrtime(startTime); From a0a453ec415139d9c839e0dc74b9aec0fb607d31 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 6 Nov 2017 11:23:38 -0300 Subject: [PATCH 382/625] fix format --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 886fd43..1493923 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -258,7 +258,7 @@ export function start(port: number) { @ast.errors.each do |error| io << "if (err instanceof #{error})\n call.error = {type: #{error.inspect}, message: err.message};\n" end -end)} + end)} } call.running = false; const deltaTime = process.hrtime(startTime); From faab1757192dc64378d6f5c57af877b6d8cefccb Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 6 Nov 2017 13:05:51 -0300 Subject: [PATCH 383/625] failtypecheck inline for better error stack trace --- src/codegen_types/array.cr | 6 ++++-- src/codegen_types/base64.cr | 6 ++++-- src/codegen_types/bool.cr | 6 ++++-- src/codegen_types/bytes.cr | 6 ++++-- src/codegen_types/cep.cr | 6 ++++-- src/codegen_types/cnpj.cr | 6 ++++-- src/codegen_types/cpf.cr | 6 ++++-- src/codegen_types/date.cr | 6 ++++-- src/codegen_types/datetime.cr | 6 ++++-- src/codegen_types/email.cr | 6 ++++-- src/codegen_types/enum.cr | 6 ++++-- src/codegen_types/float.cr | 6 ++++-- src/codegen_types/hex.cr | 6 ++++-- src/codegen_types/int.cr | 6 ++++-- src/codegen_types/latlng.cr | 3 ++- src/codegen_types/money.cr | 6 ++++-- src/codegen_types/phone.cr | 6 ++++-- src/codegen_types/safehtml.cr | 6 ++++-- src/codegen_types/string.cr | 6 ++++-- src/codegen_types/uint.cr | 6 ++++-- src/codegen_types/url.cr | 6 ++++-- src/codegen_types/uuid.cr | 6 ++++-- src/codegen_types/xml.cr | 6 ++++-- src/target/typescript_nodeserver.cr | 4 ---- 24 files changed, 90 insertions(+), 49 deletions(-) diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr index b8f7d9b..a6ad093 100644 --- a/src/codegen_types/array.cr +++ b/src/codegen_types/array.cr @@ -25,7 +25,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (!(#{expr} instanceof Array)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "} else {\n" i = random_var io << ident "for (let #{i} = 0; #{i} < #{expr}.length; ++#{i}) {\n" @@ -38,7 +39,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (!(#{expr} instanceof Array)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "} else {\n" i = random_var io << ident "for (let #{i} = 0; #{i} < #{expr}.length; ++#{i}) {\n" diff --git a/src/codegen_types/base64.cr b/src/codegen_types/base64.cr index 98d1a67..071f596 100644 --- a/src/codegen_types/base64.cr +++ b/src/codegen_types/base64.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/bool.cr b/src/codegen_types/bool.cr index 85a09d0..01b91c7 100644 --- a/src/codegen_types/bool.cr +++ b/src/codegen_types/bool.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} !== true && #{expr} !== false) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} !== true && #{expr} !== false) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr index 8610f51..b8ff007 100644 --- a/src/codegen_types/bytes.cr +++ b/src/codegen_types/bytes.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (!(#{expr} instanceof Buffer)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/cep.cr b/src/codegen_types/cep.cr index d78dcf2..d3a37f0 100644 --- a/src/codegen_types/cep.cr +++ b/src/codegen_types/cep.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/cnpj.cr b/src/codegen_types/cnpj.cr index 789c25b..7836312 100644 --- a/src/codegen_types/cnpj.cr +++ b/src/codegen_types/cnpj.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/cpf.cr b/src/codegen_types/cpf.cr index 8f83b33..c7bb682 100644 --- a/src/codegen_types/cpf.cr +++ b/src/codegen_types/cpf.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index a026b90..105853f 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]$/)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (!(#{expr} instanceof Date)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index 6d3b7ed..e0d185c 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (!(#{expr} instanceof Date)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/email.cr b/src/codegen_types/email.cr index 152ba1f..022db78 100644 --- a/src/codegen_types/email.cr +++ b/src/codegen_types/email.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index 4ea4a39..480ce0f 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -19,7 +19,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -27,7 +28,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/float.cr b/src/codegen_types/float.cr index 5b79f14..540d1d4 100644 --- a/src/codegen_types/float.cr +++ b/src/codegen_types/float.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"number\") {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"number\") {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/hex.cr b/src/codegen_types/hex.cr index 25bd5c9..7ebdb08 100644 --- a/src/codegen_types/hex.cr +++ b/src/codegen_types/hex.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/int.cr b/src/codegen_types/int.cr index 9cfcaf2..eee9aa8 100644 --- a/src/codegen_types/int.cr +++ b/src/codegen_types/int.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/latlng.cr b/src/codegen_types/latlng.cr index 98dbbaf..b11fe80 100644 --- a/src/codegen_types/latlng.cr +++ b/src/codegen_types/latlng.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"object\" || typeof #{expr}.lat !== \"number\" || typeof #{expr}.lng !== \"number\") {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/money.cr b/src/codegen_types/money.cr index 19d862d..3414217 100644 --- a/src/codegen_types/money.cr +++ b/src/codegen_types/money.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/phone.cr b/src/codegen_types/phone.cr index a0bea59..bc09bc8 100644 --- a/src/codegen_types/phone.cr +++ b/src/codegen_types/phone.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/safehtml.cr b/src/codegen_types/safehtml.cr index 92eefc4..81a98ec 100644 --- a/src/codegen_types/safehtml.cr +++ b/src/codegen_types/safehtml.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index 206572f..00e881c 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -17,7 +17,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -25,7 +26,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/uint.cr b/src/codegen_types/uint.cr index 497d72c..23a8491 100644 --- a/src/codegen_types/uint.cr +++ b/src/codegen_types/uint.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/url.cr b/src/codegen_types/url.cr index 0b37488..29b353d 100644 --- a/src/codegen_types/url.cr +++ b/src/codegen_types/url.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/uuid.cr b/src/codegen_types/uuid.cr index 7038e1e..bc8d89b 100644 --- a/src/codegen_types/uuid.cr +++ b/src/codegen_types/uuid.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/codegen_types/xml.cr b/src/codegen_types/xml.cr index 02f5c7f..8199799 100644 --- a/src/codegen_types/xml.cr +++ b/src/codegen_types/xml.cr @@ -15,7 +15,8 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end @@ -23,7 +24,8 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" - io << " failTypeCheck(#{descr}, ctx);\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" io << "}\n" end end diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 1493923..a6e38db 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -15,10 +15,6 @@ export function setCaptureErrorFn(fn: (e: Error, req?: http.IncomingMessage, ext captureError = fn; } -function failTypeCheck(descr: string, ctx: Context) { - setTimeout(() => captureError(new Error("Invalid Type at '" + descr + "'"), ctx.req, ctx.call), 1); -} - END From 8e15a86b01892d4a171ab3452f01a4471610299f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 7 Nov 2017 10:39:12 -0300 Subject: [PATCH 384/625] Change function calling --- src/target/typescript_nodeserver.cr | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index a6e38db..6cc70f5 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -242,7 +242,13 @@ export function start(port: number) { }; } else { try { - call.result = await fnExec[request.name](context, request.args); + const func = fnExec[request.name]; + if (func) { + call.result = await func(context, request.args); + } else { + console.error(JSON.stringify(Object.keys(fnExec))); + throw "Function does not exist: " + request.name; + } } catch (err) { console.error(err); call.ok = false; From 37fc06d354ba6f2e2e1c7de7f3e0f3cd7daa899c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 7 Nov 2017 10:40:04 -0300 Subject: [PATCH 385/625] Delay sentry error to ensure complete info --- src/codegen_types/array.cr | 4 ++-- src/codegen_types/base64.cr | 4 ++-- src/codegen_types/bool.cr | 4 ++-- src/codegen_types/bytes.cr | 4 ++-- src/codegen_types/cep.cr | 4 ++-- src/codegen_types/cnpj.cr | 4 ++-- src/codegen_types/cpf.cr | 4 ++-- src/codegen_types/date.cr | 4 ++-- src/codegen_types/datetime.cr | 4 ++-- src/codegen_types/email.cr | 4 ++-- src/codegen_types/enum.cr | 4 ++-- src/codegen_types/float.cr | 4 ++-- src/codegen_types/hex.cr | 4 ++-- src/codegen_types/int.cr | 4 ++-- src/codegen_types/latlng.cr | 2 +- src/codegen_types/money.cr | 4 ++-- src/codegen_types/phone.cr | 4 ++-- src/codegen_types/safehtml.cr | 4 ++-- src/codegen_types/string.cr | 4 ++-- src/codegen_types/uint.cr | 4 ++-- src/codegen_types/url.cr | 4 ++-- src/codegen_types/uuid.cr | 4 ++-- src/codegen_types/xml.cr | 4 ++-- 23 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr index a6ad093..8c507c6 100644 --- a/src/codegen_types/array.cr +++ b/src/codegen_types/array.cr @@ -26,7 +26,7 @@ module AST String.build do |io| io << "if (!(#{expr} instanceof Array)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "} else {\n" i = random_var io << ident "for (let #{i} = 0; #{i} < #{expr}.length; ++#{i}) {\n" @@ -40,7 +40,7 @@ module AST String.build do |io| io << "if (!(#{expr} instanceof Array)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "} else {\n" i = random_var io << ident "for (let #{i} = 0; #{i} < #{expr}.length; ++#{i}) {\n" diff --git a/src/codegen_types/base64.cr b/src/codegen_types/base64.cr index 071f596..575ed5d 100644 --- a/src/codegen_types/base64.cr +++ b/src/codegen_types/base64.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/bool.cr b/src/codegen_types/bool.cr index 01b91c7..c3c9538 100644 --- a/src/codegen_types/bool.cr +++ b/src/codegen_types/bool.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (#{expr} !== true && #{expr} !== false) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (#{expr} !== true && #{expr} !== false) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr index b8ff007..2ca0334 100644 --- a/src/codegen_types/bytes.cr +++ b/src/codegen_types/bytes.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (!(#{expr} instanceof Buffer)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/cep.cr b/src/codegen_types/cep.cr index d3a37f0..9297643 100644 --- a/src/codegen_types/cep.cr +++ b/src/codegen_types/cep.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/cnpj.cr b/src/codegen_types/cnpj.cr index 7836312..95ed6fb 100644 --- a/src/codegen_types/cnpj.cr +++ b/src/codegen_types/cnpj.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/cpf.cr b/src/codegen_types/cpf.cr index c7bb682..926b7e8 100644 --- a/src/codegen_types/cpf.cr +++ b/src/codegen_types/cpf.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index 105853f..ce2d6bf 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (!(#{expr} instanceof Date)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index e0d185c..2894f3f 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (!(#{expr} instanceof Date)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/email.cr b/src/codegen_types/email.cr index 022db78..2020cf6 100644 --- a/src/codegen_types/email.cr +++ b/src/codegen_types/email.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index 480ce0f..f6a962a 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -20,7 +20,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -29,7 +29,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/float.cr b/src/codegen_types/float.cr index 540d1d4..f389f4a 100644 --- a/src/codegen_types/float.cr +++ b/src/codegen_types/float.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"number\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"number\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/hex.cr b/src/codegen_types/hex.cr index 7ebdb08..21e37f1 100644 --- a/src/codegen_types/hex.cr +++ b/src/codegen_types/hex.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/int.cr b/src/codegen_types/int.cr index eee9aa8..94d027e 100644 --- a/src/codegen_types/int.cr +++ b/src/codegen_types/int.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/latlng.cr b/src/codegen_types/latlng.cr index b11fe80..44e0a53 100644 --- a/src/codegen_types/latlng.cr +++ b/src/codegen_types/latlng.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"object\" || typeof #{expr}.lat !== \"number\" || typeof #{expr}.lng !== \"number\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/money.cr b/src/codegen_types/money.cr index 3414217..3d3aef8 100644 --- a/src/codegen_types/money.cr +++ b/src/codegen_types/money.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/phone.cr b/src/codegen_types/phone.cr index bc09bc8..30c0a81 100644 --- a/src/codegen_types/phone.cr +++ b/src/codegen_types/phone.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/safehtml.cr b/src/codegen_types/safehtml.cr index 81a98ec..c9312ed 100644 --- a/src/codegen_types/safehtml.cr +++ b/src/codegen_types/safehtml.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index 00e881c..29f59c4 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -18,7 +18,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -27,7 +27,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/uint.cr b/src/codegen_types/uint.cr index 23a8491..6b3716e 100644 --- a/src/codegen_types/uint.cr +++ b/src/codegen_types/uint.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/url.cr b/src/codegen_types/url.cr index 29b353d..1b5be5f 100644 --- a/src/codegen_types/url.cr +++ b/src/codegen_types/url.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/uuid.cr b/src/codegen_types/uuid.cr index bc8d89b..a016ffc 100644 --- a/src/codegen_types/uuid.cr +++ b/src/codegen_types/uuid.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end diff --git a/src/codegen_types/xml.cr b/src/codegen_types/xml.cr index 8199799..604ba57 100644 --- a/src/codegen_types/xml.cr +++ b/src/codegen_types/xml.cr @@ -16,7 +16,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end @@ -25,7 +25,7 @@ module AST String.build do |io| io << "if (typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1);\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" end end From 915d26e46ba46d26cfac348a490331f0246092c3 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 8 Nov 2017 13:52:35 -0300 Subject: [PATCH 386/625] Fix types --- src/target/typescript_nodeserver.cr | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 6cc70f5..aecd20c 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -68,8 +68,9 @@ END @ast.errors.each do |error| @io << "export class #{error} extends Error {\n" - @io << ident "constructor(message: string) {\n" - @io << ident ident "super(message ? \"#{error}: \" + message : #{error.inspect});\n" + @io << ident "_type = #{error.inspect};\n" + @io << ident "constructor(public _msg: string) {\n" + @io << ident ident "super(_msg ? \"#{error}: \" + _msg : #{error.inspect});\n" @io << ident "}\n" @io << "}\n\n" end @@ -258,7 +259,7 @@ export function start(port: number) { }; #{ident ident ident ident ident ident ident ident ident(String.build do |io| @ast.errors.each do |error| - io << "if (err instanceof #{error})\n call.error = {type: #{error.inspect}, message: err.message};\n" + io << "if (err._type === #{error.inspect})\n call.error = {type: #{error.inspect}, message: err._msg};\n" end end)} } From 49d971afc04d7d3fbdde532ec77b8d7aa1ff0804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Fri, 10 Nov 2017 16:05:47 -0300 Subject: [PATCH 387/625] feat(extension): Add code snippet for vscode for files .sdkgen --- ext/vscode/package.json | 6 +++++- ext/vscode/snippets/sdkgen.json | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 ext/vscode/snippets/sdkgen.json diff --git a/ext/vscode/package.json b/ext/vscode/package.json index 3ed6ca4..bbb097e 100644 --- a/ext/vscode/package.json +++ b/ext/vscode/package.json @@ -8,7 +8,7 @@ "vscode": "^1.10.0" }, "categories": [ - "Languages" + "Languages", "Snippets" ], "contributes": { "languages": [{ @@ -21,6 +21,10 @@ "language": "sdkgen", "scopeName": "source.sdkgen", "path": "./syntaxes/sdkgen.tmLanguage.json" + }], + "snippets": [{ + "language": "sdkgen", + "path": "./snippets/sdkgen.json" }] } } diff --git a/ext/vscode/snippets/sdkgen.json b/ext/vscode/snippets/sdkgen.json new file mode 100644 index 0000000..f1a6f89 --- /dev/null +++ b/ext/vscode/snippets/sdkgen.json @@ -0,0 +1,28 @@ +{ + "error declaration": { + "prefix": "ed", + "body": "error ${1:ErrorName}", + "description": "Produce a error declaration with a name" + }, + "function declaration": { + "prefix": "fd", + "body": "function ${1:functionName}(${2:parameterName}${3:: ${4:parameterType}})${5:: ${6:returnType}", + "description": "Produce a generic function with name, parameter, parameter type and return type." + }, + "get function declaration": { + "prefix": "gfd", + "body": "get ${1:functionName}(${2:parameterName}${3:: ${4:parameterType}})${5:: ${6:returnType}}", + "description": "Produce a get function with name, parameter, parameter type and return type." + }, + "type declaration": { + "prefix": "td", + "body": [ + "type ${1:typeName} {", + " ${2:propertyName}${3:: ${4:parameterType}}", + " ${5:propertyName}${6:: ${7:parameterType}}", + "${0}}" + + ], + "description": "Produce a type declaration with a name, property name and a property type." + } +} \ No newline at end of file From b980cca30e1fc1f5b081321e9d6df856af5030b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Fri, 10 Nov 2017 16:06:25 -0300 Subject: [PATCH 388/625] chore(extension): bump version to 0.0.5 of package.json --- ext/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/vscode/package.json b/ext/vscode/package.json index bbb097e..15b356e 100644 --- a/ext/vscode/package.json +++ b/ext/vscode/package.json @@ -2,7 +2,7 @@ "name": "sdkgen", "displayName": "sdkgen", "description": "sdkgen language support", - "version": "0.0.4", + "version": "0.0.5", "publisher": "cubos", "engines": { "vscode": "^1.10.0" From b3a8beb4e30560fa9170338404d461d19a5a26e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Fri, 10 Nov 2017 21:43:09 -0300 Subject: [PATCH 389/625] fix(extension/snippet): adjust end of bracket in function declaration body string --- ext/vscode/snippets/sdkgen.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/vscode/snippets/sdkgen.json b/ext/vscode/snippets/sdkgen.json index f1a6f89..91cf0a8 100644 --- a/ext/vscode/snippets/sdkgen.json +++ b/ext/vscode/snippets/sdkgen.json @@ -6,7 +6,7 @@ }, "function declaration": { "prefix": "fd", - "body": "function ${1:functionName}(${2:parameterName}${3:: ${4:parameterType}})${5:: ${6:returnType}", + "body": "function ${1:functionName}(${2:parameterName}${3:: ${4:parameterType}})${5:: ${6:returnType}}", "description": "Produce a generic function with name, parameter, parameter type and return type." }, "get function declaration": { From 9cd131db3c01320bf22d6cb984d980950a55dd15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Fri, 10 Nov 2017 21:44:46 -0300 Subject: [PATCH 390/625] fix(ext/snippet): adjust type declaration wordcase in body script --- ext/vscode/snippets/sdkgen.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/vscode/snippets/sdkgen.json b/ext/vscode/snippets/sdkgen.json index 91cf0a8..d2f0f0c 100644 --- a/ext/vscode/snippets/sdkgen.json +++ b/ext/vscode/snippets/sdkgen.json @@ -17,7 +17,7 @@ "type declaration": { "prefix": "td", "body": [ - "type ${1:typeName} {", + "type ${1:TypeName} {", " ${2:propertyName}${3:: ${4:parameterType}}", " ${5:propertyName}${6:: ${7:parameterType}}", "${0}}" From 3ba73875e3b0da14c8e15d2288ed9e47cf19d7bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Fri, 10 Nov 2017 21:47:19 -0300 Subject: [PATCH 391/625] refactor(ext/snippet): adjust error declation prefix to erd instead of ed --- ext/vscode/snippets/sdkgen.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/vscode/snippets/sdkgen.json b/ext/vscode/snippets/sdkgen.json index d2f0f0c..15df850 100644 --- a/ext/vscode/snippets/sdkgen.json +++ b/ext/vscode/snippets/sdkgen.json @@ -1,6 +1,6 @@ { "error declaration": { - "prefix": "ed", + "prefix": "erd", "body": "error ${1:ErrorName}", "description": "Produce a error declaration with a name" }, From 991c0c63ee8e76c6e40a52bcaf07282c6ed7d1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Fri, 10 Nov 2017 21:48:43 -0300 Subject: [PATCH 392/625] feat(ext/snippet): Add enum, enum type, import, url declarations --- ext/vscode/snippets/sdkgen.json | 34 ++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/ext/vscode/snippets/sdkgen.json b/ext/vscode/snippets/sdkgen.json index 15df850..297cf9a 100644 --- a/ext/vscode/snippets/sdkgen.json +++ b/ext/vscode/snippets/sdkgen.json @@ -2,7 +2,29 @@ "error declaration": { "prefix": "erd", "body": "error ${1:ErrorName}", - "description": "Produce a error declaration with a name" + "description": "Produce a error declaration with a name." + }, + "enum declaration:": { + "prefix": "ed", + "body": [ + "enum {", + " ${1:enumValue}", + " ${2:enumValue}", + " ${3:enumValue}", + "}" + ], + "description": "Produce an enum declaration." + }, + "enum type declaration": { + "prefix": "etd", + "body": [ + "type ${1:TypeName} enum {", + " ${2:enumValue}", + " ${3:enumValue}", + " ${4:enumValue}", + "${0}}" + ], + "description": "Produce an enum type declaration with three kinds of enum." }, "function declaration": { "prefix": "fd", @@ -14,6 +36,11 @@ "body": "get ${1:functionName}(${2:parameterName}${3:: ${4:parameterType}})${5:: ${6:returnType}}", "description": "Produce a get function with name, parameter, parameter type and return type." }, + "import declaration": { + "prefix": "impd", + "body": "import \"${1:importModulePath}\"", + "description": "Produce a get function with relative path." + }, "type declaration": { "prefix": "td", "body": [ @@ -24,5 +51,10 @@ ], "description": "Produce a type declaration with a name, property name and a property type." + }, + "url declaration": { + "prefix": "ud", + "body": "\\$url = \"${1:urlName}\"", + "description": "Produce a url variable." } } \ No newline at end of file From 784b08ee68526494afc1c2d661cc3f6b92d2656c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Fri, 10 Nov 2017 21:49:44 -0300 Subject: [PATCH 393/625] chore(ext): bump version to 0.0.6 --- ext/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/vscode/package.json b/ext/vscode/package.json index 15b356e..76e6d68 100644 --- a/ext/vscode/package.json +++ b/ext/vscode/package.json @@ -2,7 +2,7 @@ "name": "sdkgen", "displayName": "sdkgen", "description": "sdkgen language support", - "version": "0.0.5", + "version": "0.0.6", "publisher": "cubos", "engines": { "vscode": "^1.10.0" From 4a1b01c8800a9853336d745d87420b24e6a04be2 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 11 Nov 2017 12:23:22 -0300 Subject: [PATCH 394/625] Fix hex checker --- src/codegen_types/bytes.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr index 2ca0334..9eb4d94 100644 --- a/src/codegen_types/bytes.cr +++ b/src/codegen_types/bytes.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" + io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" From de47ca01bbb130eeda5af60f4583898bc55dcde0 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 13 Nov 2017 10:28:39 -0300 Subject: [PATCH 395/625] Add checks for non null types --- src/codegen_types/array.cr | 4 ++-- src/codegen_types/base64.cr | 4 ++-- src/codegen_types/bytes.cr | 4 ++-- src/codegen_types/cep.cr | 4 ++-- src/codegen_types/cnpj.cr | 4 ++-- src/codegen_types/cpf.cr | 4 ++-- src/codegen_types/date.cr | 4 ++-- src/codegen_types/datetime.cr | 4 ++-- src/codegen_types/email.cr | 4 ++-- src/codegen_types/enum.cr | 4 ++-- src/codegen_types/float.cr | 4 ++-- src/codegen_types/hex.cr | 4 ++-- src/codegen_types/int.cr | 4 ++-- src/codegen_types/latlng.cr | 2 +- src/codegen_types/money.cr | 4 ++-- src/codegen_types/phone.cr | 4 ++-- src/codegen_types/safehtml.cr | 4 ++-- src/codegen_types/string.cr | 4 ++-- src/codegen_types/struct.cr | 8 ++++++++ src/codegen_types/uint.cr | 4 ++-- src/codegen_types/url.cr | 4 ++-- src/codegen_types/uuid.cr | 4 ++-- src/codegen_types/xml.cr | 4 ++-- 23 files changed, 51 insertions(+), 43 deletions(-) diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr index 8c507c6..41c6a4e 100644 --- a/src/codegen_types/array.cr +++ b/src/codegen_types/array.cr @@ -24,7 +24,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (!(#{expr} instanceof Array)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Array)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "} else {\n" @@ -38,7 +38,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (!(#{expr} instanceof Array)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Array)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "} else {\n" diff --git a/src/codegen_types/base64.cr b/src/codegen_types/base64.cr index 575ed5d..a140dfd 100644 --- a/src/codegen_types/base64.cr +++ b/src/codegen_types/base64.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr index 9eb4d94..23e533d 100644 --- a/src/codegen_types/bytes.cr +++ b/src/codegen_types/bytes.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (!(#{expr} instanceof Buffer)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Buffer)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/cep.cr b/src/codegen_types/cep.cr index 9297643..6b9e5c5 100644 --- a/src/codegen_types/cep.cr +++ b/src/codegen_types/cep.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/cnpj.cr b/src/codegen_types/cnpj.cr index 95ed6fb..0e55124 100644 --- a/src/codegen_types/cnpj.cr +++ b/src/codegen_types/cnpj.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/cpf.cr b/src/codegen_types/cpf.cr index 926b7e8..7b9d894 100644 --- a/src/codegen_types/cpf.cr +++ b/src/codegen_types/cpf.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index ce2d6bf..628c7dc 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (!(#{expr} instanceof Date)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index 2894f3f..ab1000d 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (!(#{expr} instanceof Date)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/email.cr b/src/codegen_types/email.cr index 2020cf6..18b1486 100644 --- a/src/codegen_types/email.cr +++ b/src/codegen_types/email.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index f6a962a..5146ce5 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -18,7 +18,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -27,7 +27,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/float.cr b/src/codegen_types/float.cr index f389f4a..dc3f39b 100644 --- a/src/codegen_types/float.cr +++ b/src/codegen_types/float.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"number\") {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"number\") {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/hex.cr b/src/codegen_types/hex.cr index 21e37f1..ca5f1f3 100644 --- a/src/codegen_types/hex.cr +++ b/src/codegen_types/hex.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/int.cr b/src/codegen_types/int.cr index 94d027e..fdda908 100644 --- a/src/codegen_types/int.cr +++ b/src/codegen_types/int.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/latlng.cr b/src/codegen_types/latlng.cr index 44e0a53..9ee7528 100644 --- a/src/codegen_types/latlng.cr +++ b/src/codegen_types/latlng.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"object\" || typeof #{expr}.lat !== \"number\" || typeof #{expr}.lng !== \"number\") {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"object\" || typeof #{expr}.lat !== \"number\" || typeof #{expr}.lng !== \"number\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/money.cr b/src/codegen_types/money.cr index 3d3aef8..10bbe4e 100644 --- a/src/codegen_types/money.cr +++ b/src/codegen_types/money.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/phone.cr b/src/codegen_types/phone.cr index 30c0a81..ded9a4b 100644 --- a/src/codegen_types/phone.cr +++ b/src/codegen_types/phone.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/safehtml.cr b/src/codegen_types/safehtml.cr index c9312ed..5f76e64 100644 --- a/src/codegen_types/safehtml.cr +++ b/src/codegen_types/safehtml.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\") {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\") {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index 29f59c4..b197647 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -16,7 +16,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\") {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -25,7 +25,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\") {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/struct.cr b/src/codegen_types/struct.cr index dd81a2e..df30676 100644 --- a/src/codegen_types/struct.cr +++ b/src/codegen_types/struct.cr @@ -36,6 +36,10 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| + io << "if (#{expr} === null || #{expr} === undefined) {\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << "}\n" fields.each do |field| io << field.type.typescript_check_encoded("#{expr}.#{field.name}", "#{descr} + \".#{field.name}\"") end @@ -44,6 +48,10 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| + io << "if (#{expr} === null || #{expr} === undefined) {\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << "}\n" fields.each do |field| io << field.type.typescript_check_decoded("#{expr}.#{field.name}", "#{descr} + \".#{field.name}\"") end diff --git a/src/codegen_types/uint.cr b/src/codegen_types/uint.cr index 6b3716e..21cee86 100644 --- a/src/codegen_types/uint.cr +++ b/src/codegen_types/uint.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/url.cr b/src/codegen_types/url.cr index 1b5be5f..9c67c32 100644 --- a/src/codegen_types/url.cr +++ b/src/codegen_types/url.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\") {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\") {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/uuid.cr b/src/codegen_types/uuid.cr index a016ffc..64d1aef 100644 --- a/src/codegen_types/uuid.cr +++ b/src/codegen_types/uuid.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" diff --git a/src/codegen_types/xml.cr b/src/codegen_types/xml.cr index 604ba57..e9240e6 100644 --- a/src/codegen_types/xml.cr +++ b/src/codegen_types/xml.cr @@ -14,7 +14,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\") {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" @@ -23,7 +23,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (typeof #{expr} !== \"string\") {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" io << "}\n" From 0b1df3795968ff737ad46163b91fcd20e19a506f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 13 Nov 2017 17:49:18 -0300 Subject: [PATCH 396/625] Implement useRethink --- src/ast.cr | 1 + src/syntax/lexer.cr | 2 + src/syntax/parser.cr | 8 +++ src/syntax/token.cr | 12 +++++ src/target/java_android.cr | 7 +++ src/target/typescript_nodeserver.cr | 80 ++++++++++++++++++++++++++++- 6 files changed, 109 insertions(+), 1 deletion(-) diff --git a/src/ast.cr b/src/ast.cr index 60656d1..b71904c 100644 --- a/src/ast.cr +++ b/src/ast.cr @@ -114,6 +114,7 @@ module AST class Options property url = "" + property useRethink = true end class Field diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index cf4e231..b20d143 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -161,6 +161,8 @@ class Lexer when "import" ; ImportKeywordToken.new when "get" ; GetKeywordToken.new when "function"; FunctionKeywordToken.new + when "true" ; TrueKeywordToken.new + when "false" ; FalseKeywordToken.new else if PRIMITIVES.includes? str PrimitiveTypeToken.new(str) diff --git a/src/syntax/parser.cr b/src/syntax/parser.cr index 464b5b8..50dfdf9 100644 --- a/src/syntax/parser.cr +++ b/src/syntax/parser.cr @@ -219,6 +219,14 @@ class Parser token = expect StringLiteralToken read_next_token options.url = token.str + when "useRethink" + case token = multi_expect(TrueKeywordToken, FalseKeywordToken) + when TrueKeywordToken + options.useRethink = true + when FalseKeywordToken + options.useRethink = false + end + read_next_token else raise ParserException.new("Unknown option $#{var.name} at #{var.location}") end diff --git a/src/syntax/token.cr b/src/syntax/token.cr index 26a0523..cc5053b 100644 --- a/src/syntax/token.cr +++ b/src/syntax/token.cr @@ -66,6 +66,18 @@ class ErrorKeywordToken < Token end end +class TrueKeywordToken < Token + def try_ident + IdentifierToken.new("true") + end +end + +class FalseKeywordToken < Token + def try_ident + IdentifierToken.new("false") + end +end + class PrimitiveTypeToken < Token property name : String def_equals name diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 4b93096..6028942 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -669,6 +669,13 @@ END final TimerTask task = new TimerTask() { @Override public void run() { +#{String.build do |io| + unless @ast.options.useRethink + io << <<-END + timer.cancel(); +END + end + end} sentCount[0] += 1; if (sentCount[0] >= 22) { return; diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index aecd20c..7b8ac5d 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -8,7 +8,44 @@ import crypto from "crypto"; import os from "os"; import url from "url"; import moment from "moment"; +#{String.build do |io| + if @ast.options.useRethink + io << <<-END import r from "../rethinkdb"; +END + else + io << <<-END + +interface DBDevice { + id: string + ip: string + type: "android" | "ios" | "web" + platform: any + fingerprint: string + screen: {width: number, height: number} + version: string + language: string + push?: string +} + +interface DBApiCall { + id: string + name: string + args: any + executionId: string + running: boolean + device: DBDevice + date: Date + duration: number + host: string + ok: boolean + result: any + error: {type: string, message: string} | null +} + +END + end + end} let captureError: (e: Error, req?: http.IncomingMessage, extra?: any) => void = () => {}; export function setCaptureErrorFn(fn: (e: Error, req?: http.IncomingMessage, extra?: any) => void) { @@ -157,11 +194,23 @@ export function start(port: number) { break; } case "GET": { - r.expr(`{"ok": true}`).then(result => { +#{String.build do |io| + if @ast.options.useRethink + io << <<-END + r.expr(`{\"ok\": true}`).then(result => { res.writeHead(200); res.write(result); res.end(); }); +END + else + io << <<-END + res.writeHead(200); + res.write({ok: true}); + res.end(); +END + end + end} break; } case "POST": { @@ -179,6 +228,9 @@ export function start(port: number) { const {id, ...deviceInfo} = context.device; +#{String.build do |io| + if @ast.options.useRethink + io << <<-END if (!context.device.id || await r.table("devices").get(context.device.id).eq(null)) { context.device.id = crypto.randomBytes(20).toString("hex"); @@ -190,6 +242,14 @@ export function start(port: number) { } else { r.table("devices").get(context.device.id).update(deviceInfo).run(); } +END + else + io << <<-END + context.device.id = crypto.randomBytes(20).toString("hex"); +END + end + end} + const executionId = crypto.randomBytes(20).toString("hex"); @@ -213,6 +273,9 @@ export function start(port: number) { if (clearForLogging[call.name]) clearForLogging[call.name](call); +#{String.build do |io| + if @ast.options.useRethink + io << <<-END async function tryLock(): Promise { const priorCall = await r.table("api_calls").get(call.id); if (priorCall === null) { @@ -233,6 +296,9 @@ export function start(port: number) { if (await tryLock()) break; await sleep(100); } +END + end + end} if (call.running) { if (call.executionId !== executionId) { @@ -273,7 +339,13 @@ export function start(port: number) { } } +#{String.build do |io| + if @ast.options.useRethink + io << <<-END r.table("api_calls").get(call.id).update(call).run(); +END + end + end} } const response = { @@ -322,9 +394,15 @@ export function start(port: number) { fn.ping = async (ctx: Context) => "pong"; +#{String.build do |io| + if @ast.options.useRethink + io << <<-END fn.setPushToken = async (ctx: Context, token: string) => { await r.table("devices").get(ctx.device.id).update({push: token}); }; +END + end + end} END end From 33510daee181db20bb739f982ea6dea0b4028bcf Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 14 Nov 2017 08:47:53 -0300 Subject: [PATCH 397/625] Fix norethink status check --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 7b8ac5d..44f4395 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -206,7 +206,7 @@ END else io << <<-END res.writeHead(200); - res.write({ok: true}); + res.write(`{\"ok\": true}`); res.end(); END end From 43d03757de879458141b6a7844a0160e7bd31b2d Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 15 Nov 2017 13:44:41 -0300 Subject: [PATCH 398/625] Implement type assertions for tests --- src/codegen_types/array.cr | 10 +++ src/codegen_types/base64.cr | 7 ++ src/codegen_types/bool.cr | 6 ++ src/codegen_types/bytes.cr | 6 ++ src/codegen_types/cep.cr | 7 ++ src/codegen_types/cnpj.cr | 7 ++ src/codegen_types/cpf.cr | 7 ++ src/codegen_types/date.cr | 10 +++ src/codegen_types/datetime.cr | 6 ++ src/codegen_types/email.cr | 7 ++ src/codegen_types/enum.cr | 7 ++ src/codegen_types/float.cr | 6 ++ src/codegen_types/hex.cr | 7 ++ src/codegen_types/int.cr | 7 ++ src/codegen_types/latlng.cr | 8 ++ src/codegen_types/money.cr | 8 ++ src/codegen_types/optional.cr | 14 ++- src/codegen_types/phone.cr | 8 ++ src/codegen_types/reference.cr | 4 + src/codegen_types/safehtml.cr | 6 ++ src/codegen_types/string.cr | 6 ++ src/codegen_types/struct.cr | 9 ++ src/codegen_types/uint.cr | 8 ++ src/codegen_types/url.cr | 6 ++ src/codegen_types/uuid.cr | 7 ++ src/codegen_types/void.cr | 4 + src/codegen_types/xml.cr | 6 ++ src/main.cr | 1 + src/target/typescript_servertest.cr | 127 ++++++++++++++++++++++++++++ 29 files changed, 320 insertions(+), 2 deletions(-) create mode 100644 src/target/typescript_servertest.cr diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr index 41c6a4e..709d3b2 100644 --- a/src/codegen_types/array.cr +++ b/src/codegen_types/array.cr @@ -22,6 +22,16 @@ module AST end end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"array\");\n" + i = random_var + io << "for (let #{i} = 0; #{i} < #{expr}.length; ++#{i}) {\n" + io << ident base.typescript_expect("#{expr}[#{i}]") + io << "}\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Array)) {\n" diff --git a/src/codegen_types/base64.cr b/src/codegen_types/base64.cr index a140dfd..2ce692c 100644 --- a/src/codegen_types/base64.cr +++ b/src/codegen_types/base64.cr @@ -12,6 +12,13 @@ module AST "string" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"string\");\n" + io << "expect(#{expr}).toMatch(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" diff --git a/src/codegen_types/bool.cr b/src/codegen_types/bool.cr index c3c9538..02248d0 100644 --- a/src/codegen_types/bool.cr +++ b/src/codegen_types/bool.cr @@ -12,6 +12,12 @@ module AST "boolean" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"boolean\");\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} !== true && #{expr} !== false) {\n" diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr index 23e533d..6355631 100644 --- a/src/codegen_types/bytes.cr +++ b/src/codegen_types/bytes.cr @@ -12,6 +12,12 @@ module AST "Buffer" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeInstanceOf(Buffer);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" diff --git a/src/codegen_types/cep.cr b/src/codegen_types/cep.cr index 6b9e5c5..02179fc 100644 --- a/src/codegen_types/cep.cr +++ b/src/codegen_types/cep.cr @@ -12,6 +12,13 @@ module AST "string" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"string\");\n" + io << "expect({expr}.replace(/[^0-9]/g, \"\").length).toBe(8);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" diff --git a/src/codegen_types/cnpj.cr b/src/codegen_types/cnpj.cr index 0e55124..2c5f64a 100644 --- a/src/codegen_types/cnpj.cr +++ b/src/codegen_types/cnpj.cr @@ -12,6 +12,13 @@ module AST "string" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"string\");\n" + io << "expect({expr}.replace(/[^0-9]/g, \"\").length).toBe(14);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" diff --git a/src/codegen_types/cpf.cr b/src/codegen_types/cpf.cr index 7b9d894..53b5d9b 100644 --- a/src/codegen_types/cpf.cr +++ b/src/codegen_types/cpf.cr @@ -12,6 +12,13 @@ module AST "string" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"string\");\n" + io << "expect({expr}.replace(/[^0-9]/g, \"\").length).toBe(11);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index 628c7dc..23fff62 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -12,6 +12,16 @@ module AST "Date" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeInstanceOf(Date);\n" + io << "expect(#{expr}.getHours()).toBe(0);\n" + io << "expect(#{expr}.getMinutes()).toBe(0);\n" + io << "expect(#{expr}.getSeconds()).toBe(0);\n" + io << "expect(#{expr}.getMilliseconds()).toBe(0);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]$/)) {\n" diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index ab1000d..14baadd 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -12,6 +12,12 @@ module AST "Date" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeInstanceOf(Date);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/)) {\n" diff --git a/src/codegen_types/email.cr b/src/codegen_types/email.cr index 18b1486..12b9d29 100644 --- a/src/codegen_types/email.cr +++ b/src/codegen_types/email.cr @@ -12,6 +12,13 @@ module AST "string" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"string\");\n" + io << "expect(#{expr}).toMatch(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index 5146ce5..1f8e05f 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -16,6 +16,13 @@ module AST "export type #{name} = #{values.map(&.inspect).join(" | ")};" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"string\");\n" + io << "expect(#{expr}).toMatch(/#{values.join("|")}/);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" diff --git a/src/codegen_types/float.cr b/src/codegen_types/float.cr index dc3f39b..4db9e39 100644 --- a/src/codegen_types/float.cr +++ b/src/codegen_types/float.cr @@ -12,6 +12,12 @@ module AST "number" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"number\");\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\") {\n" diff --git a/src/codegen_types/hex.cr b/src/codegen_types/hex.cr index ca5f1f3..f69ab2c 100644 --- a/src/codegen_types/hex.cr +++ b/src/codegen_types/hex.cr @@ -12,6 +12,13 @@ module AST "string" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"string\");\n" + io << "expect(#{expr}).toMatch(/^([0-9a-f]{2})*$/);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" diff --git a/src/codegen_types/int.cr b/src/codegen_types/int.cr index fdda908..16277b1 100644 --- a/src/codegen_types/int.cr +++ b/src/codegen_types/int.cr @@ -12,6 +12,13 @@ module AST "number" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"number\");\n" + io << "expect(#{expr} - (#{expr}|0)).toBe(0);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" diff --git a/src/codegen_types/latlng.cr b/src/codegen_types/latlng.cr index 9ee7528..547f031 100644 --- a/src/codegen_types/latlng.cr +++ b/src/codegen_types/latlng.cr @@ -12,6 +12,14 @@ module AST "{lat: number, lng: number}" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"object\");\n" + io << "expect(#{expr}.lat).toBeTypeOf(\"number\");\n" + io << "expect(#{expr}.lng).toBeTypeOf(\"number\");\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"object\" || typeof #{expr}.lat !== \"number\" || typeof #{expr}.lng !== \"number\") {\n" diff --git a/src/codegen_types/money.cr b/src/codegen_types/money.cr index 10bbe4e..de010d0 100644 --- a/src/codegen_types/money.cr +++ b/src/codegen_types/money.cr @@ -12,6 +12,14 @@ module AST "number" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"number\");\n" + io << "expect(#{expr} - (#{expr}|0)).toBe(0);\n" + io << "expect(#{expr}).toBeGreaterThanOrEqual(0);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" diff --git a/src/codegen_types/optional.cr b/src/codegen_types/optional.cr index b64e5c5..1a93b91 100644 --- a/src/codegen_types/optional.cr +++ b/src/codegen_types/optional.cr @@ -12,11 +12,21 @@ module AST "#{base.typescript_native_type} | null" end + def typescript_expect(expr) + String.build do |io| + x = random_var + io << "const #{x} = #{expr};\n" + io << "if (#{x} !== null && #{x} !== undefined) {\n" + io << ident base.typescript_expect(x) + io << "}\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| x = random_var io << "const #{x} = #{expr};\n" - io << "if (#{x}) {\n" + io << "if (#{x} !== null && #{x} !== undefined) {\n" io << ident base.typescript_check_encoded(x, descr) io << "}\n" end @@ -26,7 +36,7 @@ module AST String.build do |io| x = random_var io << "const #{x} = #{expr};\n" - io << "if (#{x}) {\n" + io << "if (#{x} !== null && #{x} !== undefined) {\n" io << ident base.typescript_check_decoded(x, descr) io << "}\n" end diff --git a/src/codegen_types/phone.cr b/src/codegen_types/phone.cr index ded9a4b..2bbe9df 100644 --- a/src/codegen_types/phone.cr +++ b/src/codegen_types/phone.cr @@ -12,6 +12,14 @@ module AST "string" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"string\");\n" + io << "expect(#{expr}.replace(/[^0-9+]/g, \"\").length).toBeGreaterThanOrEqual(5);\n" + io << "expect(#{expr}[0]).toBe(\"+\");\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" diff --git a/src/codegen_types/reference.cr b/src/codegen_types/reference.cr index 68818bf..40707c8 100644 --- a/src/codegen_types/reference.cr +++ b/src/codegen_types/reference.cr @@ -12,6 +12,10 @@ module AST type.typescript_native_type end + def typescript_expect(expr) + type.typescript_expect(expr) + end + def typescript_check_encoded(expr, descr) type.typescript_check_encoded(expr, descr) end diff --git a/src/codegen_types/safehtml.cr b/src/codegen_types/safehtml.cr index 5f76e64..86c506c 100644 --- a/src/codegen_types/safehtml.cr +++ b/src/codegen_types/safehtml.cr @@ -12,6 +12,12 @@ module AST "string" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"string\");\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index b197647..3b9d153 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -14,6 +14,12 @@ module AST "string" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"string\");\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" diff --git a/src/codegen_types/struct.cr b/src/codegen_types/struct.cr index df30676..15fe6e4 100644 --- a/src/codegen_types/struct.cr +++ b/src/codegen_types/struct.cr @@ -34,6 +34,15 @@ module AST end end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"object\");\n" + fields.each do |field| + io << field.type.typescript_expect("#{expr}.#{field.name}") + end + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined) {\n" diff --git a/src/codegen_types/uint.cr b/src/codegen_types/uint.cr index 21cee86..8da3717 100644 --- a/src/codegen_types/uint.cr +++ b/src/codegen_types/uint.cr @@ -12,6 +12,14 @@ module AST "number" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"number\");\n" + io << "expect(#{expr} - (#{expr}|0)).toBe(0);\n" + io << "expect(#{expr}).toBeGreaterThanOrEqual(0);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" diff --git a/src/codegen_types/url.cr b/src/codegen_types/url.cr index 9c67c32..8fff850 100644 --- a/src/codegen_types/url.cr +++ b/src/codegen_types/url.cr @@ -12,6 +12,12 @@ module AST "string" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"string\");\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" diff --git a/src/codegen_types/uuid.cr b/src/codegen_types/uuid.cr index 64d1aef..cade55c 100644 --- a/src/codegen_types/uuid.cr +++ b/src/codegen_types/uuid.cr @@ -12,6 +12,13 @@ module AST "string" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"string\");\n" + io << "expect(#{expr}).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/);\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" diff --git a/src/codegen_types/void.cr b/src/codegen_types/void.cr index 7dead1b..d49a596 100644 --- a/src/codegen_types/void.cr +++ b/src/codegen_types/void.cr @@ -12,6 +12,10 @@ module AST "void" end + def typescript_expect(expr) + "" + end + def typescript_check_encoded(expr, descr) "" end diff --git a/src/codegen_types/xml.cr b/src/codegen_types/xml.cr index e9240e6..2c4aa3d 100644 --- a/src/codegen_types/xml.cr +++ b/src/codegen_types/xml.cr @@ -12,6 +12,12 @@ module AST "string" end + def typescript_expect(expr) + String.build do |io| + io << "expect(#{expr}).toBeTypeOf(\"string\");\n" + end + end + def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" diff --git a/src/main.cr b/src/main.cr index 12e7a58..39acfc4 100644 --- a/src/main.cr +++ b/src/main.cr @@ -3,6 +3,7 @@ require "./semantic/ast_semantic" require "./target/java_android" require "./target/swift_ios" require "./target/typescript_nodeserver" +require "./target/typescript_servertest" require "./target/typescript_web" require "option_parser" require "file_utils" diff --git a/src/target/typescript_servertest.cr b/src/target/typescript_servertest.cr new file mode 100644 index 0000000..50fc835 --- /dev/null +++ b/src/target/typescript_servertest.cr @@ -0,0 +1,127 @@ +require "./target" + +class TypeScriptServerTestTarget < Target + def gen + @io << <<-END +import http from "http"; +import moment from "moment"; + +export interface Context { + call: DBApiCall; + device: DBDevice; + req: http.IncomingMessage; + startTime: Date; + staging: boolean; +} + +expect.extend({ + toBeTypeOf(received, argument) { + const initialType = typeof received; + const type = initialType === "object" ? Array.isArray(received) ? "array" : initialType : initialType; + return type === argument ? { + message: () => `expected ${received} to be type ${argument}`, + pass: true + } : { + message: () => `expected ${received} to be type ${argument}`, + pass: false + }; + } +}); + +declare global { + namespace jest { + interface Matchers { + toBeTypeOf(type: string): void + } + } +} + + +END +@io << "type ApiFn = {\n" +@ast.operations.each do |op| + args = ["ctx: Context"] + op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } + @io << " " << op.pretty_name << ": (#{args.join(", ")}) => Promise<#{op.return_type.typescript_native_type}>;\n" +end +@io << "};\n\n" +@ast.struct_types.each do |t| + @io << t.typescript_definition + @io << "\n\n" +end + +@ast.enum_types.each do |t| + @io << t.typescript_definition + @io << "\n\n" +end + +@io << <<-END +export function wrapApiFn(fn: ApiFn) { + return {\n +END +@ast.operations.each do |op| + args = ["ctx: Context"] + op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } + @io << " " << op.pretty_name << ": async (#{args.join(", ")}) => {\n" + op.args.each do |arg| + @io << ident ident ident arg.type.typescript_expect(arg.name) + end + @io << " " + @io << "const ret = " unless op.return_type.is_a? AST::VoidPrimitiveType + @io << "await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" + unless op.return_type.is_a? AST::VoidPrimitiveType + @io << ident ident ident op.return_type.typescript_expect("ret") + @io << " return ret;\n" + end + @io << " },\n" +end +@io << <<-END + }; +} + +END + + + # @io << "const fnExec: {[name: string]: (ctx: Context, args: any) => Promise} = {\n" + # @ast.operations.each do |op| + # @io << " " << op.pretty_name << ": async (ctx: Context, args: any) => {\n" + # op.args.each do |arg| + # @io << ident ident arg.type.typescript_check_encoded("args.#{arg.name}", "\"#{op.pretty_name}.args.#{arg.name}\"") + # @io << ident ident "const #{arg.name} = #{arg.type.typescript_decode("args.#{arg.name}")};" + # @io << "\n" + # end + # @io << ident ident "const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" + # @io << ident ident op.return_type.typescript_check_decoded("ret", "\"#{op.pretty_name}.ret\"") + # @io << ident ident "return " + op.return_type.typescript_encode("ret") + ";\n" + # @io << ident "},\n" + # end + # @io << "};\n\n" + + # @io << "const clearForLogging: {[name: string]: (call: DBApiCall) => void} = {\n" + # @ast.operations.each do |op| + # cmds_args = String.build { |io| emit_clear_for_logging(io, op, "call.args") } + + # if cmds_args != "" + # @io << " " << op.pretty_name << ": async (call: DBApiCall) => {\n" + # @io << ident ident cmds_args + # @io << ident "},\n" + # end + # end + # @io << "};\n\n" + + # @ast.errors.each do |error| + # @io << "export class #{error} extends Error {\n" + # @io << ident "_type = #{error.inspect};\n" + # @io << ident "constructor(public _msg: string) {\n" + # @io << ident ident "super(_msg ? \"#{error}: \" + _msg : #{error.inspect});\n" + # @io << ident "}\n" + # @io << "}\n\n" + # end + + # @io << "export const err = {\n" + # @ast.errors.each do |error| + # @io << ident "#{error}: (message: string = \"\") => { throw new #{error}(message); },\n" + # end + # @io << "};\n\n" + end +end + +Target.register(TypeScriptServerTestTarget, target_name: "typescript_servertest") From 8dee0d2c5f32eb3261e6c58e0a6eadfc5b94c894 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 15 Nov 2017 13:55:01 -0300 Subject: [PATCH 399/625] Remove dead code --- src/target/typescript_servertest.cr | 97 ++++++++--------------------- 1 file changed, 27 insertions(+), 70 deletions(-) diff --git a/src/target/typescript_servertest.cr b/src/target/typescript_servertest.cr index 50fc835..b343fff 100644 --- a/src/target/typescript_servertest.cr +++ b/src/target/typescript_servertest.cr @@ -38,89 +38,46 @@ declare global { END -@io << "type ApiFn = {\n" -@ast.operations.each do |op| - args = ["ctx: Context"] + op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } - @io << " " << op.pretty_name << ": (#{args.join(", ")}) => Promise<#{op.return_type.typescript_native_type}>;\n" -end -@io << "};\n\n" -@ast.struct_types.each do |t| - @io << t.typescript_definition - @io << "\n\n" -end + @io << "type ApiFn = {\n" + @ast.operations.each do |op| + args = ["ctx: Context"] + op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } + @io << " " << op.pretty_name << ": (#{args.join(", ")}) => Promise<#{op.return_type.typescript_native_type}>;\n" + end + @io << "};\n\n" + @ast.struct_types.each do |t| + @io << t.typescript_definition + @io << "\n\n" + end -@ast.enum_types.each do |t| - @io << t.typescript_definition - @io << "\n\n" -end + @ast.enum_types.each do |t| + @io << t.typescript_definition + @io << "\n\n" + end -@io << <<-END + @io << <<-END export function wrapApiFn(fn: ApiFn) { return {\n END -@ast.operations.each do |op| - args = ["ctx: Context"] + op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } - @io << " " << op.pretty_name << ": async (#{args.join(", ")}) => {\n" - op.args.each do |arg| + @ast.operations.each do |op| + args = ["ctx: Context"] + op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } + @io << " " << op.pretty_name << ": async (#{args.join(", ")}) => {\n" + op.args.each do |arg| @io << ident ident ident arg.type.typescript_expect(arg.name) - end - @io << " " - @io << "const ret = " unless op.return_type.is_a? AST::VoidPrimitiveType - @io << "await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" - unless op.return_type.is_a? AST::VoidPrimitiveType + end + @io << " " + @io << "const ret = " unless op.return_type.is_a? AST::VoidPrimitiveType + @io << "await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" + unless op.return_type.is_a? AST::VoidPrimitiveType @io << ident ident ident op.return_type.typescript_expect("ret") @io << " return ret;\n" + end + @io << " },\n" end - @io << " },\n" -end -@io << <<-END + @io << <<-END }; } END - - - # @io << "const fnExec: {[name: string]: (ctx: Context, args: any) => Promise} = {\n" - # @ast.operations.each do |op| - # @io << " " << op.pretty_name << ": async (ctx: Context, args: any) => {\n" - # op.args.each do |arg| - # @io << ident ident arg.type.typescript_check_encoded("args.#{arg.name}", "\"#{op.pretty_name}.args.#{arg.name}\"") - # @io << ident ident "const #{arg.name} = #{arg.type.typescript_decode("args.#{arg.name}")};" - # @io << "\n" - # end - # @io << ident ident "const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" - # @io << ident ident op.return_type.typescript_check_decoded("ret", "\"#{op.pretty_name}.ret\"") - # @io << ident ident "return " + op.return_type.typescript_encode("ret") + ";\n" - # @io << ident "},\n" - # end - # @io << "};\n\n" - - # @io << "const clearForLogging: {[name: string]: (call: DBApiCall) => void} = {\n" - # @ast.operations.each do |op| - # cmds_args = String.build { |io| emit_clear_for_logging(io, op, "call.args") } - - # if cmds_args != "" - # @io << " " << op.pretty_name << ": async (call: DBApiCall) => {\n" - # @io << ident ident cmds_args - # @io << ident "},\n" - # end - # end - # @io << "};\n\n" - - # @ast.errors.each do |error| - # @io << "export class #{error} extends Error {\n" - # @io << ident "_type = #{error.inspect};\n" - # @io << ident "constructor(public _msg: string) {\n" - # @io << ident ident "super(_msg ? \"#{error}: \" + _msg : #{error.inspect});\n" - # @io << ident "}\n" - # @io << "}\n\n" - # end - - # @io << "export const err = {\n" - # @ast.errors.each do |error| - # @io << ident "#{error}: (message: string = \"\") => { throw new #{error}(message); },\n" - # end - # @io << "};\n\n" end end From 34fdc0f418a05a49a1c5d1beb520fba895e6a6b4 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 15 Nov 2017 13:56:11 -0300 Subject: [PATCH 400/625] Add comment to ignore for coverage --- src/target/typescript_servertest.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/src/target/typescript_servertest.cr b/src/target/typescript_servertest.cr index b343fff..e2861c8 100644 --- a/src/target/typescript_servertest.cr +++ b/src/target/typescript_servertest.cr @@ -14,6 +14,7 @@ export interface Context { staging: boolean; } +/* istanbul ignore next */ expect.extend({ toBeTypeOf(received, argument) { const initialType = typeof received; From 11d5650e6eacccc7dc17053da32272ab6d7776a2 Mon Sep 17 00:00:00 2001 From: Tironi Date: Thu, 16 Nov 2017 17:29:57 -0300 Subject: [PATCH 401/625] fix to locale from dateformat --- src/target/java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 6028942..b5e4a88 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -350,7 +350,7 @@ END static SecureRandom random = new SecureRandom(); static boolean initialized = false; static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); - static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); + static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US); static Application application; static { From 8abc59cd2831cacb51f7c07d7bfc4191c0788480 Mon Sep 17 00:00:00 2001 From: Tironi Date: Thu, 16 Nov 2017 17:55:22 -0300 Subject: [PATCH 402/625] trying to fix calendar --- src/target/java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index b5e4a88..370f05a 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -754,7 +754,7 @@ END } static Calendar toCalendar(Date date){ - Calendar cal = Calendar.getInstance(); + Calendar cal = Calendar.getInstance(Locale.US); cal.setTime(date); return cal; } From aeb080f0a66196a2980387075deb1d7c8fb08a89 Mon Sep 17 00:00:00 2001 From: Tironi Date: Thu, 16 Nov 2017 18:08:42 -0300 Subject: [PATCH 403/625] roll back --- src/target/java_android.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 370f05a..6028942 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -350,7 +350,7 @@ END static SecureRandom random = new SecureRandom(); static boolean initialized = false; static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); - static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US); + static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); static Application application; static { @@ -754,7 +754,7 @@ END } static Calendar toCalendar(Date date){ - Calendar cal = Calendar.getInstance(Locale.US); + Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal; } From 868f0172441c303925ff3ce844b5dd73f466439a Mon Sep 17 00:00:00 2001 From: Tironi Date: Thu, 16 Nov 2017 18:17:49 -0300 Subject: [PATCH 404/625] trying to fix dateformat --- src/target/java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 6028942..81f7d99 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -355,7 +355,7 @@ END static { dateTimeFormat.setTimeZone(TimeZone.getTimeZone("GMT")); - dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + //dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); createHttpClient(); } From dc7ccac85d1cf2931c8e76c8081bd5289d6a8a5b Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 19 Nov 2017 12:35:03 -0300 Subject: [PATCH 405/625] update android target --- target-android/.idea/misc.xml | 15 +---------- target-android/api/build.gradle | 26 +++++++++---------- target-android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/target-android/.idea/misc.xml b/target-android/.idea/misc.xml index fbb6828..ba7052b 100644 --- a/target-android/.idea/misc.xml +++ b/target-android/.idea/misc.xml @@ -1,8 +1,5 @@ - - - - - - - - - - - - - - + diff --git a/target-android/api/build.gradle b/target-android/api/build.gradle index 890390c..7493518 100644 --- a/target-android/api/build.gradle +++ b/target-android/api/build.gradle @@ -2,12 +2,12 @@ apply plugin: 'com.android.library' apply plugin: 'maven-publish' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 26 + buildToolsVersion "26.0.2" defaultConfig { minSdkVersion 16 - targetSdkVersion 25 + targetSdkVersion 26 versionCode 1 versionName "1.0" } @@ -22,19 +22,19 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.squareup.okhttp3:okhttp:3.7.0' + compile 'com.squareup.okhttp3:okhttp:3.8.0' compile 'com.anupcowkur:reservoir:3.1.0' } publishing { repositories { maven { - url 'https://mymavenrepo.com/repo/4XBKk8BMCyMc24joS8Od/' - // url 'https://maven.cubos.io/upload/' - // credentials { - // username "cubos" - // password "4XBKk8BMCyMc24joS8Od" - // } +// url 'https://mymavenrepo.com/repo/4XBKk8BMCyMc24joS8Od/' + url 'https://maven.cubos.io/upload/' + credentials { + username "cubos" + password "4XBKk8BMCyMc24joS8Od" + } } } @@ -47,10 +47,10 @@ publishing { artifact 'build/outputs/aar/api-release.aar' pom.withXml { - //Creating additional node for dependencies + // Creating additional node for dependencies def dependenciesNode = asNode().appendNode('dependencies') - //Defining configuration names from which dependencies will be taken (debugCompile or releaseCompile and compile) + // Defining configuration names from which dependencies will be taken (debugCompile or releaseCompile and compile) def configurationNames = ["releaseCompile", 'compile'] configurationNames.each { configurationName -> @@ -61,7 +61,7 @@ publishing { dependencyNode.appendNode('artifactId', it.name) dependencyNode.appendNode('version', it.version) - //If there are any exclusions in dependency + // If there are any exclusions in dependency if (it.excludeRules.size() > 0) { def exclusionsNode = dependencyNode.appendNode('exclusions') it.excludeRules.each { rule -> diff --git a/target-android/build.gradle b/target-android/build.gradle index 1ea4bd0..c33a638 100644 --- a/target-android/build.gradle +++ b/target-android/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0' + classpath 'com.android.tools.build:gradle:3.0.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/target-android/gradle/wrapper/gradle-wrapper.properties b/target-android/gradle/wrapper/gradle-wrapper.properties index 04f6041..3a75351 100644 --- a/target-android/gradle/wrapper/gradle-wrapper.properties +++ b/target-android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip From 57c6dcdffd558c5a7020271bf186b6060352df38 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 19 Nov 2017 13:06:53 -0300 Subject: [PATCH 406/625] Update repositories --- target-android/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target-android/build.gradle b/target-android/build.gradle index c33a638..910f28c 100644 --- a/target-android/build.gradle +++ b/target-android/build.gradle @@ -3,6 +3,7 @@ buildscript { repositories { jcenter() + mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' @@ -15,6 +16,7 @@ buildscript { allprojects { repositories { jcenter() + mavenCentral() } } From a7aef3b9636fb18338829a5d7bec84b3a5189f70 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 19 Nov 2017 13:09:52 -0300 Subject: [PATCH 407/625] Add google repo --- target-android/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target-android/build.gradle b/target-android/build.gradle index 910f28c..127bad0 100644 --- a/target-android/build.gradle +++ b/target-android/build.gradle @@ -4,6 +4,7 @@ buildscript { repositories { jcenter() mavenCentral() + google() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' @@ -17,6 +18,7 @@ allprojects { repositories { jcenter() mavenCentral() + google() } } From 2e12b6e519886c82d25ca6662c80e94e1067d245 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 19 Nov 2017 19:30:20 -0300 Subject: [PATCH 408/625] Implement spread inheritance! --- ext/vscode/package.json | 2 +- ext/vscode/syntaxes/sdkgen.tmLanguage.json | 7 +++++ spec/lexer_spec.cr | 5 ++++ spec/parser_spec.cr | 10 ++++++++ src/ast.cr | 1 + src/semantic/apply_struct_spreads.cr | 30 ++++++++++++++++++++++ src/semantic/ast_semantic.cr | 2 ++ src/semantic/visitor.cr | 1 + src/syntax/ast_to_s.cr | 3 +++ src/syntax/lexer.cr | 9 +++++++ src/syntax/parser.cr | 10 +++++++- src/syntax/token.cr | 3 +++ 12 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 src/semantic/apply_struct_spreads.cr diff --git a/ext/vscode/package.json b/ext/vscode/package.json index 76e6d68..2a95934 100644 --- a/ext/vscode/package.json +++ b/ext/vscode/package.json @@ -2,7 +2,7 @@ "name": "sdkgen", "displayName": "sdkgen", "description": "sdkgen language support", - "version": "0.0.6", + "version": "0.0.8", "publisher": "cubos", "engines": { "vscode": "^1.10.0" diff --git a/ext/vscode/syntaxes/sdkgen.tmLanguage.json b/ext/vscode/syntaxes/sdkgen.tmLanguage.json index 04cacd7..5a7dd34 100644 --- a/ext/vscode/syntaxes/sdkgen.tmLanguage.json +++ b/ext/vscode/syntaxes/sdkgen.tmLanguage.json @@ -96,6 +96,13 @@ "include": "#type" } ] + }, { + "name": "meta.spread", + "match": "(\\.\\.\\.)\\s?([A-Z][a-zA-Z0-9]*)", + "captures": { + "1": {"name": "markup.bold"}, + "2": {"name": "entity.name.type"} + } } ] }, diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index 3fe14fc..d321a19 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -20,6 +20,11 @@ describe Lexer do IdentifierToken.new("aaa"), ] + it_lexes "...aaa", [ + SpreadSymbolToken.new, + IdentifierToken.new("aaa"), + ] + it_lexes "a b c", [ IdentifierToken.new("a"), IdentifierToken.new("b"), diff --git a/spec/parser_spec.cr b/spec/parser_spec.cr index 5397fb6..d19e0cf 100644 --- a/spec/parser_spec.cr +++ b/spec/parser_spec.cr @@ -98,6 +98,16 @@ describe Parser do END , "redeclare") end + + it "handles spreads in structs" do + check_parses <<-END + type Foo { + ...Bar + ...Baz + aa: string + } + END + end end def clear(code) diff --git a/src/ast.cr b/src/ast.cr index b71904c..301a148 100644 --- a/src/ast.cr +++ b/src/ast.cr @@ -91,6 +91,7 @@ module AST class StructType < Type property fields = [] of Field + property spreads = [] of TypeReference end class TypeDefinition diff --git a/src/semantic/apply_struct_spreads.cr b/src/semantic/apply_struct_spreads.cr new file mode 100644 index 0000000..b6c4d85 --- /dev/null +++ b/src/semantic/apply_struct_spreads.cr @@ -0,0 +1,30 @@ +require "./visitor" + +module Semantic + class ApplyStructSpreads < Visitor + # Here we may visit the same struct multiple times + # We must make sure we only process each one once + @processed = Set(AST::StructType).new + + def visit(t : AST::StructType) + return if @processed.includes? t + @processed << t + + super + + t.spreads.map(&.type).each do |other| + unless other.is_a? AST::StructType + raise SemanticException.new("A spread operator in a struct can't refer to something that is not a struct, in '#{t.name}'.") + end + visit other # recursion! + + other.fields.each do |other_field| + if t.fields.find { |f| f.name == other_field.name } + raise SemanticException.new("The field '#{other_field.name}' happens on both '#{t.name}' and '#{other.name}'.") + end + t.fields << other_field + end + end + end + end +end diff --git a/src/semantic/ast_semantic.cr b/src/semantic/ast_semantic.cr index cdea8e5..b0c7745 100644 --- a/src/semantic/ast_semantic.cr +++ b/src/semantic/ast_semantic.cr @@ -7,6 +7,7 @@ require "./check_empty_enum" require "./give_struct_and_enum_names" require "./collect_struct_and_enum_types" require "./check_multiple_declaration" +require "./apply_struct_spreads" module Semantic class SemanticException < Exception @@ -49,6 +50,7 @@ module AST Semantic::GiveStructAndEnumNames.visit(self) Semantic::CheckEmptyEnum.visit(self) Semantic::CollectStructAndEnumTypes.visit(self) + Semantic::ApplyStructSpreads.visit(self) end end diff --git a/src/semantic/visitor.cr b/src/semantic/visitor.cr index 25a7d5e..18011e8 100644 --- a/src/semantic/visitor.cr +++ b/src/semantic/visitor.cr @@ -29,6 +29,7 @@ module Semantic def visit(t : AST::StructType) t.fields.each { |field| visit field } + t.spreads.each { |ref| visit ref } end def visit(t : AST::ArrayType) diff --git a/src/syntax/ast_to_s.cr b/src/syntax/ast_to_s.cr index 435606e..a13de07 100644 --- a/src/syntax/ast_to_s.cr +++ b/src/syntax/ast_to_s.cr @@ -191,6 +191,9 @@ module AST class StructType def to_s(io) io << "{\n" + spreads.each do |ref| + io << " ..." << ref.name << "\n" + end fields.each do |field| io << " " field.to_s(io) diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index b20d143..9768cc1 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -111,6 +111,15 @@ class Lexer next_char token = ArraySymbolToken.new end + when '.' + case next_char + when '.' + case next_char + when '.' + next_char + token = SpreadSymbolToken.new + end + end when '$' next_char if current_char.ascii_letter? diff --git a/src/syntax/parser.cr b/src/syntax/parser.cr index 50dfdf9..dbf2ad4 100644 --- a/src/syntax/parser.cr +++ b/src/syntax/parser.cr @@ -142,7 +142,7 @@ class Parser field_names = Set(String).new while true - case token = multi_expect(IdentifierToken, CurlyCloseSymbolToken) + case token = multi_expect(IdentifierToken, CurlyCloseSymbolToken, SpreadSymbolToken) when IdentifierToken f = parse_field if field_names.includes? f.name @@ -150,6 +150,14 @@ class Parser end field_names << f.name t.fields << f + when SpreadSymbolToken + read_next_token + token = expect IdentifierToken + unless token.name[0].uppercase? + raise ParserException.new "Expected a type name but found '#{token.name}', at #{token.location}" + end + t.spreads << AST::TypeReference.new(token.name) + read_next_token when CurlyCloseSymbolToken read_next_token return t diff --git a/src/syntax/token.cr b/src/syntax/token.cr index cc5053b..f68893c 100644 --- a/src/syntax/token.cr +++ b/src/syntax/token.cr @@ -143,3 +143,6 @@ end class CommaSymbolToken < Token end + +class SpreadSymbolToken < Token +end From 31273dc4b1a59fa4d1740b4bfc2dbb147cd26ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Wed, 22 Nov 2017 11:04:28 -0300 Subject: [PATCH 409/625] feat(syntax/lexer, spec/lexer_spec): initial test and implementation to multiline comments --- spec/lexer_spec.cr | 6 ++++++ src/syntax/lexer.cr | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index d321a19..ee0f033 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -215,6 +215,12 @@ describe Lexer do it_lexes "// héýça\n z", [ IdentifierToken.new("z"), ] + + # Add multi-line comments tests + + it_lexes "/**/", [] of Token + + it_lexes "/**/", [] of Token end def it_lexes(code, expected_tokens) diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index 9768cc1..94cb91f 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -77,6 +77,19 @@ class Lexer return next_token end end + when '*' + while true + case next_char + when '\0' + return nil + when '*' + case next_char + when '/' + next_char + return next_token + end + end + end end when '{' next_char From ed1705741db6abe15f0d9f51cfdd997cb40f0c82 Mon Sep 17 00:00:00 2001 From: Tironi Date: Wed, 22 Nov 2017 11:07:57 -0300 Subject: [PATCH 410/625] removing bytes validation --- src/codegen_types/bytes.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr index 6355631..bfbc85a 100644 --- a/src/codegen_types/bytes.cr +++ b/src/codegen_types/bytes.cr @@ -20,10 +20,10 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" - io << "}\n" + #io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" + #io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + #io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + #io << "}\n" end end From c974ca149e122bd5f2721c77724a041d6dac9751 Mon Sep 17 00:00:00 2001 From: Tironi Date: Wed, 22 Nov 2017 11:09:55 -0300 Subject: [PATCH 411/625] prettify --- src/codegen_types/bytes.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr index bfbc85a..db7de9b 100644 --- a/src/codegen_types/bytes.cr +++ b/src/codegen_types/bytes.cr @@ -20,10 +20,10 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| - #io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" - #io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - #io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" - #io << "}\n" + # io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" + # io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + # io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + # io << "}\n" end end From d20920b4c5f33100f3b6e567b9416a0a936261ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Wed, 22 Nov 2017 11:13:31 -0300 Subject: [PATCH 412/625] feat(lexer): add case where multicomment doesn't have a closed bound --- spec/lexer_spec.cr | 5 +++++ src/syntax/lexer.cr | 2 ++ 2 files changed, 7 insertions(+) diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index ee0f033..e5d392b 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -219,6 +219,11 @@ describe Lexer do # Add multi-line comments tests it_lexes "/**/", [] of Token + it_lexes "/*a */", [] of Token + it_lexes "/*a \n*/", [] of Token + it_lexes "/*a**/", [] of Token + + it_lexes "/* *", [] of Token it_lexes "/**/", [] of Token end diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index 94cb91f..e93dd8a 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -84,6 +84,8 @@ class Lexer return nil when '*' case next_char + when '\0' + return nil when '/' next_char return next_token From df6df7d7c58966e7895c7bda2592786a521668ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Wed, 22 Nov 2017 11:58:26 -0300 Subject: [PATCH 413/625] feat(spec/lexer_spec): add extensive tests to verify multi-line commets --- spec/lexer_spec.cr | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index e5d392b..eb0165f 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -196,6 +196,10 @@ describe Lexer do StringLiteralToken.new("\n\t\""), ] + it_lexes "\"/* */\"", [ + StringLiteralToken.new("/* */") + ] + it_lexes "//hmmm", [] of Token it_lexes "x//hmmm", [ @@ -222,10 +226,40 @@ describe Lexer do it_lexes "/*a */", [] of Token it_lexes "/*a \n*/", [] of Token it_lexes "/*a**/", [] of Token - it_lexes "/* *", [] of Token + it_lexes "/* *\/", [] of Token + it_lexes "/* \tae\n\n", [] of Token + it_lexes "/*", [] of Token + it_lexes "\/*", [] of Token - it_lexes "/**/", [] of Token + it_lexes "/*a*/b/*c*/", [ + IdentifierToken.new("b") + ] + + it_lexes "/* đðđ\n */u", [ + IdentifierToken.new("u") + ] + + it_lexes "c/* a*/", [ + IdentifierToken.new("c") + ] + + it_lexes "/* bce */a", [ + IdentifierToken.new("a") + ] + + it_lexes "b/* baed */c", [ + IdentifierToken.new("b"), + IdentifierToken.new("c") + ] + + it_lexes "/* \n\nb */a", [ + IdentifierToken.new("a") + ] + + it_lexes "/* *\/a", [ + IdentifierToken.new("a") + ] end def it_lexes(code, expected_tokens) From 3b6d1c025f63d04dbe9990dec599e00060384e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Wed, 22 Nov 2017 14:01:38 -0300 Subject: [PATCH 414/625] feat(vscode/extension): add multiline comment syntax highlight --- ext/vscode/language-configuration.json | 3 ++- ext/vscode/syntaxes/sdkgen.tmLanguage.json | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/vscode/language-configuration.json b/ext/vscode/language-configuration.json index aa25710..e1a6c25 100644 --- a/ext/vscode/language-configuration.json +++ b/ext/vscode/language-configuration.json @@ -25,6 +25,7 @@ ["[", "]"], ["(", ")"], ["\"", "\""], - ["'", "'"] + ["'", "'"], + ["/*", "*/"] ] } \ No newline at end of file diff --git a/ext/vscode/syntaxes/sdkgen.tmLanguage.json b/ext/vscode/syntaxes/sdkgen.tmLanguage.json index 5a7dd34..3741545 100644 --- a/ext/vscode/syntaxes/sdkgen.tmLanguage.json +++ b/ext/vscode/syntaxes/sdkgen.tmLanguage.json @@ -77,6 +77,11 @@ { "name": "comment.line", "match": "//(.*?)\n" + }, + { + "name": "comment.block", + "begin": "/\\*", + "end": "\\*/" } ] }, From b4c0768c52fb493015cc6bd913232a4b69a1d5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Wed, 22 Nov 2017 14:02:44 -0300 Subject: [PATCH 415/625] project: bump version to 0.0.9 --- ext/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/vscode/package.json b/ext/vscode/package.json index 2a95934..b3272a0 100644 --- a/ext/vscode/package.json +++ b/ext/vscode/package.json @@ -2,7 +2,7 @@ "name": "sdkgen", "displayName": "sdkgen", "description": "sdkgen language support", - "version": "0.0.8", + "version": "0.0.9", "publisher": "cubos", "engines": { "vscode": "^1.10.0" From 853631c90a161c377e702a819b1e7e7e1217ff97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Wed, 22 Nov 2017 21:28:49 -0300 Subject: [PATCH 416/625] test(lexer_spec): add more cases and adjust order --- spec/lexer_spec.cr | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index eb0165f..95bf02a 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -222,15 +222,20 @@ describe Lexer do # Add multi-line comments tests + it_doesnt_lex "/* *", "Unexpected end of file" + it_doesnt_lex "/* \tae\n\n", "Unexpected end of file" + it_doesnt_lex "/*", "Unexpected end of file" + it_doesnt_lex "\/*", "Unexpected end of file" + it_doesnt_lex "/* dsvibwi", "Unexpected end of file" + it_doesnt_lex "/* cdibweic *", "Unexpected end of file" + it_doesnt_lex "/* * /", "Unexpected end of file" + it_lexes "/**/", [] of Token it_lexes "/*a */", [] of Token it_lexes "/*a \n*/", [] of Token + it_lexes "/**a*/", [] of Token it_lexes "/*a**/", [] of Token - it_lexes "/* *", [] of Token it_lexes "/* *\/", [] of Token - it_lexes "/* \tae\n\n", [] of Token - it_lexes "/*", [] of Token - it_lexes "\/*", [] of Token it_lexes "/*a*/b/*c*/", [ IdentifierToken.new("b") From 1d345af9db303672d938e5279b096e9231cc353d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Wed, 22 Nov 2017 21:30:22 -0300 Subject: [PATCH 417/625] feat(lexer): adjust cases to exceptions and sequences of asterisks --- src/syntax/lexer.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index e93dd8a..af0d329 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -79,13 +79,13 @@ class Lexer end when '*' while true - case next_char + case current_char == '*' ? current_char : next_char when '\0' - return nil + break when '*' case next_char when '\0' - return nil + break when '/' next_char return next_token From 8ddab2ed2977dd39ea2cb9d9bc0d5ca9d3ff422d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Wed, 22 Nov 2017 22:41:39 -0300 Subject: [PATCH 418/625] test(lexer_spec): add /*/ case to comment block test --- spec/lexer_spec.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index 95bf02a..3ca3b14 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -229,6 +229,7 @@ describe Lexer do it_doesnt_lex "/* dsvibwi", "Unexpected end of file" it_doesnt_lex "/* cdibweic *", "Unexpected end of file" it_doesnt_lex "/* * /", "Unexpected end of file" + it_doesnt_lex "/*/", "Unexpected end of file" it_lexes "/**/", [] of Token it_lexes "/*a */", [] of Token From d1f834d89def09c572f57362586a3383d1531d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Wed, 22 Nov 2017 22:42:53 -0300 Subject: [PATCH 419/625] fix(lexer): adjust algorithm to case where characters are as /*/ --- src/syntax/lexer.cr | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index af0d329..036e3ea 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -79,16 +79,21 @@ class Lexer end when '*' while true - case current_char == '*' ? current_char : next_char + case next_char when '\0' break when '*' case next_char - when '\0' - break - when '/' - next_char - return next_token + when '*' + if (next_char) == '/' + next_char + return next_token + end + when '\0' + break + when '/' + next_char + return next_token end end end From 2638dbde05b41a2e441d862af5f7e630f38f38ae Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 23 Nov 2017 08:19:20 -0300 Subject: [PATCH 420/625] Add peek_next_char --- src/syntax/lexer.cr | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index 036e3ea..32c4a3a 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -37,6 +37,10 @@ class Lexer @reader.current_char end + private def peek_next_char + @reader.peek_next_char + end + private def substring(start_pos, end_pos) reader = Char::Reader.new(@reader.string) reader.pos = start_pos From 91aadbd2c099095ae7ea048b35822c20779faba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Mon, 27 Nov 2017 09:21:41 -0300 Subject: [PATCH 421/625] fix(lexer): adjust block comment to not break multiple asterisks is the sequence --- src/syntax/lexer.cr | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index 32c4a3a..295d1c3 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -83,22 +83,19 @@ class Lexer end when '*' while true - case next_char - when '\0' - break + next_char + case current_char when '*' - case next_char - when '*' - if (next_char) == '/' - next_char - return next_token - end - when '\0' - break + while true + next_char + case current_char when '/' next_char return next_token + end end + when '\0' + break end end end From 9077f37b1e5aa3819a93dccb6581c422c571fa9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Mon, 27 Nov 2017 10:26:30 -0300 Subject: [PATCH 422/625] fix(lexer): fix block comment when '/**x/' case --- src/syntax/lexer.cr | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index 295d1c3..b8b367b 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -88,12 +88,17 @@ class Lexer when '*' while true next_char - case current_char - when '/' - next_char - return next_token + if current_char != '*' + break end end + case current_char + when '\0' + break + when '/' + next_char + return next_token + end when '\0' break end From 33835dfb1742ed4b5670ecdc034ad565ca3527b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Mon, 27 Nov 2017 10:27:04 -0300 Subject: [PATCH 423/625] test(lexer_spec): add more cases --- spec/lexer_spec.cr | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index 3ca3b14..76616ab 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -220,18 +220,46 @@ describe Lexer do IdentifierToken.new("z"), ] - # Add multi-line comments tests + # New-line tests + it_doesnt_lex "2", "Unexpected character '2' at -:1:1" + it_doesnt_lex "\n2", "Unexpected character '2' at -:2:1" + it_doesnt_lex "/*\n*/2", "Unexpected character '2' at -:2:1" + it_doesnt_lex "/*\n\n\n\n*/2", "Unexpected character '2' at -:5:1" + it_doesnt_lex "//x\n2", "Unexpected character '2' at -:2:1" + # Add multi-line comments tests it_doesnt_lex "/* *", "Unexpected end of file" it_doesnt_lex "/* \tae\n\n", "Unexpected end of file" it_doesnt_lex "/*", "Unexpected end of file" it_doesnt_lex "\/*", "Unexpected end of file" it_doesnt_lex "/* dsvibwi", "Unexpected end of file" it_doesnt_lex "/* cdibweic *", "Unexpected end of file" + it_doesnt_lex "/* cdibweic *a", "Unexpected end of file" it_doesnt_lex "/* * /", "Unexpected end of file" + it_doesnt_lex "/* * /", "Unexpected end of file" + it_doesnt_lex "/* * /", "Unexpected end of file" it_doesnt_lex "/*/", "Unexpected end of file" + it_doesnt_lex "/* /", "Unexpected end of file" + it_doesnt_lex "/* * /", "Unexpected end of file" + it_doesnt_lex "/* * * * /", "Unexpected end of file" + it_doesnt_lex "/* *a/", "Unexpected end of file" + it_lexes "/* * * * * */", [] of Token + it_lexes "/* * ***_ */", [] of Token it_lexes "/**/", [] of Token + it_lexes "/***/", [] of Token + it_lexes "/****/", [] of Token + it_lexes "/*****/", [] of Token + it_lexes "/******/", [] of Token + it_lexes "/*******/", [] of Token + it_lexes "/********/", [] of Token + it_lexes "/****aas ********/", [] of Token + it_lexes "/*******a ********/", [] of Token + it_lexes "/**********/", [] of Token + it_lexes "/************/", [] of Token + it_lexes "/*************/", [] of Token + it_lexes "/**************/", [] of Token + it_lexes "/***************/", [] of Token it_lexes "/*a */", [] of Token it_lexes "/*a \n*/", [] of Token it_lexes "/**a*/", [] of Token From d373ff3443113f690938cb11496ea19ca29f3a61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Mon, 27 Nov 2017 11:00:18 -0300 Subject: [PATCH 424/625] fix(lexer): adjust position in comments when newline cases --- src/syntax/lexer.cr | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index b8b367b..889b41c 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -78,6 +78,8 @@ class Lexer return nil when '\n' next_char + @column = 1 + @line += 1 return next_token end end From 5612eae563afe674dc5ba52a125f0157084b84c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Mon, 27 Nov 2017 11:03:21 -0300 Subject: [PATCH 425/625] test(lexer_spec): add test case when single line comment has a new line --- spec/lexer_spec.cr | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index 76616ab..65a52dd 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -223,8 +223,7 @@ describe Lexer do # New-line tests it_doesnt_lex "2", "Unexpected character '2' at -:1:1" it_doesnt_lex "\n2", "Unexpected character '2' at -:2:1" - it_doesnt_lex "/*\n*/2", "Unexpected character '2' at -:2:1" - it_doesnt_lex "/*\n\n\n\n*/2", "Unexpected character '2' at -:5:1" + it_doesnt_lex "//\n2", "Unexpected character '2' at -:2:1" it_doesnt_lex "//x\n2", "Unexpected character '2' at -:2:1" # Add multi-line comments tests From e0da76f4f73d3309a9fb3c5885d7ec7904f1dd59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Mon, 27 Nov 2017 14:47:27 -0300 Subject: [PATCH 426/625] refactor(lexer): adjust multi-line comment to be more concise --- src/syntax/lexer.cr | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index 889b41c..60b51dc 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -85,14 +85,9 @@ class Lexer end when '*' while true - next_char - case current_char + case next_char when '*' - while true - next_char - if current_char != '*' - break - end + while next_char == '*' end case current_char when '\0' From d3de564a0712d969d152b22202c63126d670c02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Mon, 27 Nov 2017 14:54:19 -0300 Subject: [PATCH 427/625] test(lexer_spec): add more test cases --- spec/lexer_spec.cr | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index 65a52dd..cc2803d 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -224,9 +224,16 @@ describe Lexer do it_doesnt_lex "2", "Unexpected character '2' at -:1:1" it_doesnt_lex "\n2", "Unexpected character '2' at -:2:1" it_doesnt_lex "//\n2", "Unexpected character '2' at -:2:1" + it_doesnt_lex "//\n 2", "Unexpected character '2' at -:2:2" it_doesnt_lex "//x\n2", "Unexpected character '2' at -:2:1" + it_doesnt_lex "//x\n 2", "Unexpected character '2' at -:2:2" + it_doesnt_lex "/*\n*/3", "Unexpected character '3' at -:2:3" + it_doesnt_lex "/*\n\n\n\n*/2", "Unexpected character '2' at -:5:1" + it_doesnt_lex "/*a*/\n2", "Unexpected character '2' at -:2:1" + it_doesnt_lex "/*a*/\n 2", "Unexpected character '2' at -:2:2" # Add multi-line comments tests + it_doesnt_lex "/*\n", "Unexpected end of file" it_doesnt_lex "/* *", "Unexpected end of file" it_doesnt_lex "/* \tae\n\n", "Unexpected end of file" it_doesnt_lex "/*", "Unexpected end of file" @@ -243,6 +250,7 @@ describe Lexer do it_doesnt_lex "/* * * * /", "Unexpected end of file" it_doesnt_lex "/* *a/", "Unexpected end of file" + it_lexes "/*\n*/", [] of Token it_lexes "/* * * * * */", [] of Token it_lexes "/* * ***_ */", [] of Token it_lexes "/**/", [] of Token @@ -261,6 +269,7 @@ describe Lexer do it_lexes "/***************/", [] of Token it_lexes "/*a */", [] of Token it_lexes "/*a \n*/", [] of Token + it_lexes "/*a \n\n\n\n\n*/", [] of Token it_lexes "/**a*/", [] of Token it_lexes "/*a**/", [] of Token it_lexes "/* *\/", [] of Token From ea32cb54e0165207873fc173eff47e2b18918f43 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 27 Nov 2017 18:18:46 -0300 Subject: [PATCH 428/625] Fix keeping deviceId on lack of rethinkdb --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 44f4395..7def1c2 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -245,7 +245,7 @@ END END else io << <<-END - context.device.id = crypto.randomBytes(20).toString("hex"); + if (!context.device.id) context.device.id = crypto.randomBytes(20).toString("hex"); END end end} From 8089461ced379f88f3060b5d8d8fe4355e89b660 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 27 Nov 2017 18:20:02 -0300 Subject: [PATCH 429/625] Fix format --- spec/lexer_spec.cr | 16 ++++++++-------- src/syntax/lexer.cr | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index 3ca3b14..3e716d8 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -197,7 +197,7 @@ describe Lexer do ] it_lexes "\"/* */\"", [ - StringLiteralToken.new("/* */") + StringLiteralToken.new("/* */"), ] it_lexes "//hmmm", [] of Token @@ -239,32 +239,32 @@ describe Lexer do it_lexes "/* *\/", [] of Token it_lexes "/*a*/b/*c*/", [ - IdentifierToken.new("b") + IdentifierToken.new("b"), ] it_lexes "/* đðđ\n */u", [ - IdentifierToken.new("u") + IdentifierToken.new("u"), ] it_lexes "c/* a*/", [ - IdentifierToken.new("c") + IdentifierToken.new("c"), ] it_lexes "/* bce */a", [ - IdentifierToken.new("a") + IdentifierToken.new("a"), ] it_lexes "b/* baed */c", [ IdentifierToken.new("b"), - IdentifierToken.new("c") + IdentifierToken.new("c"), ] it_lexes "/* \n\nb */a", [ - IdentifierToken.new("a") + IdentifierToken.new("a"), ] it_lexes "/* *\/a", [ - IdentifierToken.new("a") + IdentifierToken.new("a"), ] end diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index 32c4a3a..c39b61a 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -88,16 +88,16 @@ class Lexer break when '*' case next_char - when '*' - if (next_char) == '/' - next_char - return next_token - end - when '\0' - break - when '/' + when '*' + if (next_char) == '/' next_char return next_token + end + when '\0' + break + when '/' + next_char + return next_token end end end From b3c53026faa406be85ebcf2bd0bdba2c2870c4cc Mon Sep 17 00:00:00 2001 From: Tironi Date: Tue, 28 Nov 2017 10:26:30 -0300 Subject: [PATCH 430/625] return DataRequest as @discardableResult in target swift --- src/target/swift_ios.cr | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/target/swift_ios.cr b/src/target/swift_ios.cr index eb2d220..b97c584 100644 --- a/src/target/swift_ios.cr +++ b/src/target/swift_ios.cr @@ -33,7 +33,8 @@ END args << "callback: ((_ result: APIInternal.Result<#{native_type ret}>) -> Void)?" end @io << ident(String.build do |io| - io << "static public func #{op.pretty_name}(#{args.join(", ")}) {\n" + io << "@discardableResult\n" + io << "static public func #{op.pretty_name}(#{args.join(", ")}) -> DataRequest {\n" io << ident(String.build do |io| if op.args.size != 0 io << "var args = [String: Any]()\n" @@ -45,7 +46,7 @@ END io << "args[\"#{arg.name}\"] = #{type_to_json arg.type, arg.name}\n\n" end - io << "APIInternal.makeRequest(#{op.pretty_name.inspect}, args) { response in \n" + io << "return APIInternal.makeRequest(#{op.pretty_name.inspect}, args) { response in \n" io << ident(String.build do |io| io << "switch response {\n" @@ -185,7 +186,8 @@ class APIInternal { return value == nil || value is NSNull } - static func makeRequest(_ name: String, _ args: [String: Any], callback: @escaping (Result) -> Void) { + @discardableResult + static func makeRequest(_ name: String, _ args: [String: Any], callback: @escaping (Result) -> Void) -> DataRequest { let api = SessionManager.default let body = [ @@ -196,7 +198,7 @@ class APIInternal { "staging": API.useStaging ] as [String : Any] - api.request("https://\\(baseUrl)\\(API.useStaging ? "-staging" : "")/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).responseJSON { response in + return api.request("https://\\(baseUrl)\\(API.useStaging ? "-staging" : "")/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).responseJSON { response in guard let responseValue = response.result.value else { let error = Error(API.ErrorType.Connection, "Erro de Conexão, tente novamente mais tarde") API.globalCallback(name, Result.failure(error), callback) From 65ece18bda0b61795b2ece642ea00583afcc512f Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 29 Nov 2017 12:45:40 -0300 Subject: [PATCH 431/625] exit 1 on error --- src/main.cr | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.cr b/src/main.cr index 39acfc4..4a97c49 100644 --- a/src/main.cr +++ b/src/main.cr @@ -24,10 +24,10 @@ end if sources.size == 0 STDERR.puts "You must specify one source file" - exit + exit 1 elsif sources.size > 1 STDERR.puts "You must specify only one source file" - exit + exit 1 end source = sources[0] @@ -39,18 +39,19 @@ begin if destination == "" STDERR.puts "You must specify an output file" - exit + exit 1 end if target_name == "" STDERR.puts "You must specify a target" - exit + exit 1 end FileUtils.mkdir_p(File.dirname(destination)) Target.process(ast, destination, target_name) rescue ex : Lexer::LexerException | Parser::ParserException | Semantic::SemanticException STDERR.puts (ex.message || "Invalid source").colorize.light_red + exit 1 rescue ex : Exception raise ex end From 9a8e3245baee216536e2a76846a32378383151f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20=27Eowfenth=27=20De=C3=A7ordi?= Date: Wed, 29 Nov 2017 18:12:20 -0300 Subject: [PATCH 432/625] feat(lexer): adjust character position in multiline comments --- spec/lexer_spec.cr | 18 +++++++++--------- src/syntax/lexer.cr | 6 ++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/spec/lexer_spec.cr b/spec/lexer_spec.cr index cc2803d..42d1923 100644 --- a/spec/lexer_spec.cr +++ b/spec/lexer_spec.cr @@ -197,7 +197,7 @@ describe Lexer do ] it_lexes "\"/* */\"", [ - StringLiteralToken.new("/* */") + StringLiteralToken.new("/* */"), ] it_lexes "//hmmm", [] of Token @@ -228,7 +228,7 @@ describe Lexer do it_doesnt_lex "//x\n2", "Unexpected character '2' at -:2:1" it_doesnt_lex "//x\n 2", "Unexpected character '2' at -:2:2" it_doesnt_lex "/*\n*/3", "Unexpected character '3' at -:2:3" - it_doesnt_lex "/*\n\n\n\n*/2", "Unexpected character '2' at -:5:1" + it_doesnt_lex "/*\n\n\n\n*/ 2", "Unexpected character '2' at -:5:4" it_doesnt_lex "/*a*/\n2", "Unexpected character '2' at -:2:1" it_doesnt_lex "/*a*/\n 2", "Unexpected character '2' at -:2:2" @@ -275,32 +275,32 @@ describe Lexer do it_lexes "/* *\/", [] of Token it_lexes "/*a*/b/*c*/", [ - IdentifierToken.new("b") + IdentifierToken.new("b"), ] it_lexes "/* đðđ\n */u", [ - IdentifierToken.new("u") + IdentifierToken.new("u"), ] it_lexes "c/* a*/", [ - IdentifierToken.new("c") + IdentifierToken.new("c"), ] it_lexes "/* bce */a", [ - IdentifierToken.new("a") + IdentifierToken.new("a"), ] it_lexes "b/* baed */c", [ IdentifierToken.new("b"), - IdentifierToken.new("c") + IdentifierToken.new("c"), ] it_lexes "/* \n\nb */a", [ - IdentifierToken.new("a") + IdentifierToken.new("a"), ] it_lexes "/* *\/a", [ - IdentifierToken.new("a") + IdentifierToken.new("a"), ] end diff --git a/src/syntax/lexer.cr b/src/syntax/lexer.cr index 60b51dc..c866af0 100644 --- a/src/syntax/lexer.cr +++ b/src/syntax/lexer.cr @@ -86,10 +86,16 @@ class Lexer when '*' while true case next_char + when '\n' + @column = 0 + @line += 1 when '*' while next_char == '*' end case current_char + when '\n' + @column = 0 + @line += 1 when '\0' break when '/' From d2682527e59dd1fdba511f8791b1a9e557cdc928 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 30 Nov 2017 08:30:02 -0300 Subject: [PATCH 433/625] Fix support for device id on safari mobile icognito --- src/target/typescript_web.cr | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/target/typescript_web.cr b/src/target/typescript_web.cr index 51ab613..b3c4209 100644 --- a/src/target/typescript_web.cr +++ b/src/target/typescript_web.cr @@ -48,6 +48,22 @@ END @io << <<-END ////////////////////////////////////////////////////// +let fallbackDeviceId = null; + +function setDeviceId(deviceId: string) { + fallbackDeviceId = deviceId; + try { + localStorage.setItem("deviceId", deviceId); + } catch (e) {} +} + +function getDeviceId() { + try { + return localStorage.getItem("deviceId"); + } catch (e) {} + return fallbackDeviceId; +} + async function device() { const parser = new UAParser(); parser.setUA(navigator.userAgent); @@ -68,7 +84,7 @@ async function device() { version: me ? me.src : "", language: navigator.language }; - const deviceId = localStorage.getItem("deviceId"); + const deviceId = getDeviceId(); if (deviceId) device.id = deviceId; return device; @@ -124,7 +140,7 @@ async function makeRequest({name, args}: {name: string, args: any}) { const response = JSON.parse(req.responseText); try { - localStorage.setItem("deviceId", response.deviceId); + setDeviceId(response.deviceId); if (response.ok) { resolve(response.result); listenersDict["success"].forEach(hook => hook(response.result, name, args)); From 9c3a4827bdfaee549030dad314999b3d32a42b06 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 30 Nov 2017 08:40:23 -0300 Subject: [PATCH 434/625] Fix var type --- src/target/typescript_web.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_web.cr b/src/target/typescript_web.cr index b3c4209..a12fa29 100644 --- a/src/target/typescript_web.cr +++ b/src/target/typescript_web.cr @@ -48,7 +48,7 @@ END @io << <<-END ////////////////////////////////////////////////////// -let fallbackDeviceId = null; +let fallbackDeviceId: string | null = null; function setDeviceId(deviceId: string) { fallbackDeviceId = deviceId; From 820c7e140428008ef6b3974929b6824a9c0e7e4a Mon Sep 17 00:00:00 2001 From: Arthur Hardmann Date: Thu, 30 Nov 2017 17:35:42 -0300 Subject: [PATCH 435/625] generate fingerprint for ios target; --- src/target/swift_ios.cr | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/target/swift_ios.cr b/src/target/swift_ios.cr index b97c584..88e2cda 100644 --- a/src/target/swift_ios.cr +++ b/src/target/swift_ios.cr @@ -4,6 +4,7 @@ class SwiftIosTarget < SwiftTarget def gen @io << <<-END import Alamofire +import KeychainSwift class API { static var useStaging = false @@ -119,7 +120,7 @@ class APIInternal { static func device() -> [String: Any] { var device = [String: Any]() device["platform"] = "ios" - device["fingerprint"] = "." + device["fingerprint"] = phoneFingerprint() device["platformVersion"] = "iOS " + UIDevice.current.systemVersion + " on " + UIDevice.current.model if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String { device["version"] = version @@ -186,6 +187,19 @@ class APIInternal { return value == nil || value is NSNull } + static func phoneFingerprint() -> String { + let keychain = KeychainSwift() + let phoneFingerprint = keychain.get("iuFingerprint") + if phoneFingerprint == nil { + let newPhoneFingerprint = UIDevice.current.identifierForVendor!.uuidString + keychain.set(newPhoneFingerprint, forKey: "iuFingerprint", withAccess: .accessibleAlwaysThisDeviceOnly) + return newPhoneFingerprint + + } else { + return phoneFingerprint! + } + } + @discardableResult static func makeRequest(_ name: String, _ args: [String: Any], callback: @escaping (Result) -> Void) -> DataRequest { let api = SessionManager.default From 4fea5dc36ed88c010982c05e24b594d6797bf434 Mon Sep 17 00:00:00 2001 From: Arthur Hardmann Date: Fri, 1 Dec 2017 20:38:39 -0300 Subject: [PATCH 436/625] adjust finger print --- src/target/swift_ios.cr | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/target/swift_ios.cr b/src/target/swift_ios.cr index 88e2cda..d25920d 100644 --- a/src/target/swift_ios.cr +++ b/src/target/swift_ios.cr @@ -189,15 +189,13 @@ class APIInternal { static func phoneFingerprint() -> String { let keychain = KeychainSwift() - let phoneFingerprint = keychain.get("iuFingerprint") - if phoneFingerprint == nil { - let newPhoneFingerprint = UIDevice.current.identifierForVendor!.uuidString - keychain.set(newPhoneFingerprint, forKey: "iuFingerprint", withAccess: .accessibleAlwaysThisDeviceOnly) + guard let phoneFingerprint = keychain.get("phoneFingerprint") else { + let newPhoneFingerprint = randomBytesHex(len: 32) + keychain.set(newPhoneFingerprint, forKey: "phoneFingerprint", withAccess: .accessibleAlwaysThisDeviceOnly) return newPhoneFingerprint - - } else { - return phoneFingerprint! } + + return phoneFingerprint } @discardableResult From 0fcf9d5234bc51514d0f299d881dcdf915dba8a7 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 4 Dec 2017 07:57:46 -0300 Subject: [PATCH 437/625] Add opt-in strict mode --- src/ast.cr | 1 + src/codegen_types/array.cr | 4 ++-- src/codegen_types/base64.cr | 4 ++-- src/codegen_types/bool.cr | 4 ++-- src/codegen_types/bytes.cr | 4 ++-- src/codegen_types/cep.cr | 4 ++-- src/codegen_types/cnpj.cr | 4 ++-- src/codegen_types/cpf.cr | 4 ++-- src/codegen_types/date.cr | 4 ++-- src/codegen_types/datetime.cr | 4 ++-- src/codegen_types/email.cr | 4 ++-- src/codegen_types/enum.cr | 4 ++-- src/codegen_types/float.cr | 4 ++-- src/codegen_types/hex.cr | 4 ++-- src/codegen_types/int.cr | 4 ++-- src/codegen_types/latlng.cr | 2 +- src/codegen_types/money.cr | 4 ++-- src/codegen_types/phone.cr | 4 ++-- src/codegen_types/safehtml.cr | 4 ++-- src/codegen_types/string.cr | 4 ++-- src/codegen_types/struct.cr | 4 ++-- src/codegen_types/uint.cr | 4 ++-- src/codegen_types/url.cr | 4 ++-- src/codegen_types/uuid.cr | 4 ++-- src/codegen_types/xml.cr | 4 ++-- src/syntax/ast_to_s.cr | 12 ++++++++++++ src/syntax/parser.cr | 8 ++++++++ src/target/typescript_nodeserver.cr | 4 ++++ 28 files changed, 72 insertions(+), 47 deletions(-) diff --git a/src/ast.cr b/src/ast.cr index 301a148..0d7e301 100644 --- a/src/ast.cr +++ b/src/ast.cr @@ -116,6 +116,7 @@ module AST class Options property url = "" property useRethink = true + property strict = false end class Field diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr index 709d3b2..eb434bd 100644 --- a/src/codegen_types/array.cr +++ b/src/codegen_types/array.cr @@ -36,7 +36,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Array)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "} else {\n" i = random_var io << ident "for (let #{i} = 0; #{i} < #{expr}.length; ++#{i}) {\n" @@ -50,7 +50,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Array)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "} else {\n" i = random_var io << ident "for (let #{i} = 0; #{i} < #{expr}.length; ++#{i}) {\n" diff --git a/src/codegen_types/base64.cr b/src/codegen_types/base64.cr index 2ce692c..4276e35 100644 --- a/src/codegen_types/base64.cr +++ b/src/codegen_types/base64.cr @@ -23,7 +23,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -32,7 +32,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/bool.cr b/src/codegen_types/bool.cr index 02248d0..4cb0643 100644 --- a/src/codegen_types/bool.cr +++ b/src/codegen_types/bool.cr @@ -22,7 +22,7 @@ module AST String.build do |io| io << "if (#{expr} !== true && #{expr} !== false) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -31,7 +31,7 @@ module AST String.build do |io| io << "if (#{expr} !== true && #{expr} !== false) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr index db7de9b..0ce6265 100644 --- a/src/codegen_types/bytes.cr +++ b/src/codegen_types/bytes.cr @@ -22,7 +22,7 @@ module AST String.build do |io| # io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" # io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - # io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + # io << " typeCheckerError(err, ctx);\n" # io << "}\n" end end @@ -31,7 +31,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Buffer)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/cep.cr b/src/codegen_types/cep.cr index 02179fc..d866292 100644 --- a/src/codegen_types/cep.cr +++ b/src/codegen_types/cep.cr @@ -23,7 +23,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -32,7 +32,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/cnpj.cr b/src/codegen_types/cnpj.cr index 2c5f64a..e93a9c1 100644 --- a/src/codegen_types/cnpj.cr +++ b/src/codegen_types/cnpj.cr @@ -23,7 +23,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -32,7 +32,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/cpf.cr b/src/codegen_types/cpf.cr index 53b5d9b..8ac321f 100644 --- a/src/codegen_types/cpf.cr +++ b/src/codegen_types/cpf.cr @@ -23,7 +23,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -32,7 +32,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index 23fff62..fb55493 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -26,7 +26,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -35,7 +35,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index 14baadd..9901b74 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -22,7 +22,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -31,7 +31,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/email.cr b/src/codegen_types/email.cr index 12b9d29..c3beba7 100644 --- a/src/codegen_types/email.cr +++ b/src/codegen_types/email.cr @@ -23,7 +23,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -32,7 +32,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index 1f8e05f..c9a3c11 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -27,7 +27,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -36,7 +36,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/float.cr b/src/codegen_types/float.cr index 4db9e39..d5a763e 100644 --- a/src/codegen_types/float.cr +++ b/src/codegen_types/float.cr @@ -22,7 +22,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -31,7 +31,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/hex.cr b/src/codegen_types/hex.cr index f69ab2c..fb2e513 100644 --- a/src/codegen_types/hex.cr +++ b/src/codegen_types/hex.cr @@ -23,7 +23,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -32,7 +32,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/int.cr b/src/codegen_types/int.cr index 16277b1..3021e0a 100644 --- a/src/codegen_types/int.cr +++ b/src/codegen_types/int.cr @@ -23,7 +23,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -32,7 +32,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/latlng.cr b/src/codegen_types/latlng.cr index 547f031..241257e 100644 --- a/src/codegen_types/latlng.cr +++ b/src/codegen_types/latlng.cr @@ -24,7 +24,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"object\" || typeof #{expr}.lat !== \"number\" || typeof #{expr}.lng !== \"number\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/money.cr b/src/codegen_types/money.cr index de010d0..773e7e3 100644 --- a/src/codegen_types/money.cr +++ b/src/codegen_types/money.cr @@ -24,7 +24,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -33,7 +33,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/phone.cr b/src/codegen_types/phone.cr index 2bbe9df..371d90e 100644 --- a/src/codegen_types/phone.cr +++ b/src/codegen_types/phone.cr @@ -24,7 +24,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -33,7 +33,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/safehtml.cr b/src/codegen_types/safehtml.cr index 86c506c..090f22f 100644 --- a/src/codegen_types/safehtml.cr +++ b/src/codegen_types/safehtml.cr @@ -22,7 +22,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -31,7 +31,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index 3b9d153..b04a184 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -24,7 +24,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -33,7 +33,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/struct.cr b/src/codegen_types/struct.cr index 15fe6e4..c9e600c 100644 --- a/src/codegen_types/struct.cr +++ b/src/codegen_types/struct.cr @@ -47,7 +47,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" fields.each do |field| io << field.type.typescript_check_encoded("#{expr}.#{field.name}", "#{descr} + \".#{field.name}\"") @@ -59,7 +59,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" fields.each do |field| io << field.type.typescript_check_decoded("#{expr}.#{field.name}", "#{descr} + \".#{field.name}\"") diff --git a/src/codegen_types/uint.cr b/src/codegen_types/uint.cr index 8da3717..b840446 100644 --- a/src/codegen_types/uint.cr +++ b/src/codegen_types/uint.cr @@ -24,7 +24,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -33,7 +33,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/url.cr b/src/codegen_types/url.cr index 8fff850..b6657d5 100644 --- a/src/codegen_types/url.cr +++ b/src/codegen_types/url.cr @@ -22,7 +22,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -31,7 +31,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/uuid.cr b/src/codegen_types/uuid.cr index cade55c..754bfe6 100644 --- a/src/codegen_types/uuid.cr +++ b/src/codegen_types/uuid.cr @@ -23,7 +23,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -32,7 +32,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/codegen_types/xml.cr b/src/codegen_types/xml.cr index 2c4aa3d..a6cf529 100644 --- a/src/codegen_types/xml.cr +++ b/src/codegen_types/xml.cr @@ -22,7 +22,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end @@ -31,7 +31,7 @@ module AST String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" - io << " setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);\n" + io << " typeCheckerError(err, ctx);\n" io << "}\n" end end diff --git a/src/syntax/ast_to_s.cr b/src/syntax/ast_to_s.cr index a13de07..9bb816f 100644 --- a/src/syntax/ast_to_s.cr +++ b/src/syntax/ast_to_s.cr @@ -156,6 +156,18 @@ module AST io << "\n" anyop = true end + if options.useRethink != "" + io << "$useRethink = " + options.useRethink.inspect(io) + io << "\n" + anyop = true + end + if options.strict != "" + io << "$strict = " + options.strict.inspect(io) + io << "\n" + anyop = true + end io << "\n" if anyop && errors.size != 0 errors.each do |err| io << "error " << err << "\n" diff --git a/src/syntax/parser.cr b/src/syntax/parser.cr index dbf2ad4..acc7bff 100644 --- a/src/syntax/parser.cr +++ b/src/syntax/parser.cr @@ -235,6 +235,14 @@ class Parser options.useRethink = false end read_next_token + when "strict" + case token = multi_expect(TrueKeywordToken, FalseKeywordToken) + when TrueKeywordToken + options.strict = true + when FalseKeywordToken + options.strict = false + end + read_next_token else raise ParserException.new("Unknown option $#{var.name} at #{var.location}") end diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 7def1c2..b3620a9 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -52,6 +52,10 @@ export function setCaptureErrorFn(fn: (e: Error, req?: http.IncomingMessage, ext captureError = fn; } +function typeCheckerError(e: error, ctx: Context) { + #{@ast.options.strict ? "throw err;" : "setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);"} +} + END From ff602029de5c80983c9cac03167e5e00d13765ce Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 4 Dec 2017 07:59:51 -0300 Subject: [PATCH 438/625] Fix default options --- src/syntax/ast_to_s.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/syntax/ast_to_s.cr b/src/syntax/ast_to_s.cr index 9bb816f..6473e18 100644 --- a/src/syntax/ast_to_s.cr +++ b/src/syntax/ast_to_s.cr @@ -156,13 +156,13 @@ module AST io << "\n" anyop = true end - if options.useRethink != "" + if options.useRethink != true io << "$useRethink = " options.useRethink.inspect(io) io << "\n" anyop = true end - if options.strict != "" + if options.strict != false io << "$strict = " options.strict.inspect(io) io << "\n" From 3732d007052e79060628ed058e274662ce10f82b Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 4 Dec 2017 08:06:40 -0300 Subject: [PATCH 439/625] Highlight for true/false --- ext/vscode/package.json | 2 +- ext/vscode/syntaxes/sdkgen.tmLanguage.json | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/vscode/package.json b/ext/vscode/package.json index b3272a0..a27de3f 100644 --- a/ext/vscode/package.json +++ b/ext/vscode/package.json @@ -2,7 +2,7 @@ "name": "sdkgen", "displayName": "sdkgen", "description": "sdkgen language support", - "version": "0.0.9", + "version": "0.0.10", "publisher": "cubos", "engines": { "vscode": "^1.10.0" diff --git a/ext/vscode/syntaxes/sdkgen.tmLanguage.json b/ext/vscode/syntaxes/sdkgen.tmLanguage.json index 3741545..d3264bf 100644 --- a/ext/vscode/syntaxes/sdkgen.tmLanguage.json +++ b/ext/vscode/syntaxes/sdkgen.tmLanguage.json @@ -173,6 +173,9 @@ "match": "\\." } ] + }, { + "name": "keyword.literal", + "match": "\\b(true|false)\\b" } ] } From 563b0ea6c6c10ff55bed95cf731b5c5bce63f9a5 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 4 Dec 2017 09:37:51 -0300 Subject: [PATCH 440/625] Fix wrong type --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index b3620a9..3d9e0e9 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -52,7 +52,7 @@ export function setCaptureErrorFn(fn: (e: Error, req?: http.IncomingMessage, ext captureError = fn; } -function typeCheckerError(e: error, ctx: Context) { +function typeCheckerError(e: Error, ctx: Context) { #{@ast.options.strict ? "throw err;" : "setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);"} } From 18a146ab68b7c1fb3d336747c6e345974fae8af0 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 4 Dec 2017 11:09:15 -0300 Subject: [PATCH 441/625] Fix wrong variable --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 3d9e0e9..3fa1f36 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -53,7 +53,7 @@ export function setCaptureErrorFn(fn: (e: Error, req?: http.IncomingMessage, ext } function typeCheckerError(e: Error, ctx: Context) { - #{@ast.options.strict ? "throw err;" : "setTimeout(() => captureError(err, ctx.req, ctx.call), 1000);"} + #{@ast.options.strict ? "throw e;" : "setTimeout(() => captureError(e, ctx.req, ctx.call), 1000);"} } From 9434c7e593aecc8c8aea46967179f9b9246537ca Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 6 Dec 2017 17:45:53 -0300 Subject: [PATCH 442/625] export functions to convert to json --- src/target/typescript_nodeserver.cr | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 3fa1f36..5af2a57 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -107,6 +107,12 @@ END end @io << "};\n\n" + @ast.struct_types.each do |t| + @io << "export function transform#{t.name}ToJson(x: #{t.typescript_native_type}) {\n" + @io << ident "return " + t.typescript_encode("x") + ";\n" + @io << "}\n" + end + @ast.errors.each do |error| @io << "export class #{error} extends Error {\n" @io << ident "_type = #{error.inspect};\n" From ff8868f70dd39546fd85a70c4163018db1a53c26 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 6 Dec 2017 18:52:56 -0300 Subject: [PATCH 443/625] set null fields to null on java sdkgen --- src/target/java.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/target/java.cr b/src/target/java.cr index f5ccb35..1b35c36 100644 --- a/src/target/java.cr +++ b/src/target/java.cr @@ -234,7 +234,7 @@ END end end - def type_to_json(t : AST::Type, src : String) + def type_-to_json(t : AST::Type, src : String) case t when AST::StringPrimitiveType, AST::IntPrimitiveType, AST::UIntPrimitiveType, AST::FloatPrimitiveType, AST::BoolPrimitiveType "#{src}" @@ -245,9 +245,9 @@ END when AST::BytesPrimitiveType "Base64.encodeToString(#{src}, Base64.DEFAULT)" when AST::VoidPrimitiveType - "null" + "JSONObject.NULL" when AST::OptionalType - "#{src} == null ? null : #{type_to_json(t.base, src)}" + "#{src} == null ? JSONObject.NULL : #{type_to_json(t.base, src)}" when AST::ArrayType el = "el" + SecureRandom.hex[0, 5] "new JSONArray() {{ for (final #{native_type t.base} #{el} : #{src}) put(#{type_to_json t.base, "#{el}"}); }}" From a747e89fcc4555ae48f0a7a33a04e47d88dfc923 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 6 Dec 2017 18:55:42 -0300 Subject: [PATCH 444/625] fix syntax --- src/target/java.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java.cr b/src/target/java.cr index 1b35c36..2a3598c 100644 --- a/src/target/java.cr +++ b/src/target/java.cr @@ -234,7 +234,7 @@ END end end - def type_-to_json(t : AST::Type, src : String) + def type_to_json(t : AST::Type, src : String) case t when AST::StringPrimitiveType, AST::IntPrimitiveType, AST::UIntPrimitiveType, AST::FloatPrimitiveType, AST::BoolPrimitiveType "#{src}" From 157869bdd89046ab33b3777a37bc957c7b1b6f76 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 11 Dec 2017 16:41:17 -0300 Subject: [PATCH 445/625] Increase timeout --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 5af2a57..853dc15 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -302,7 +302,7 @@ END return false; } - for (let i = 0; i < 600; ++i) { + for (let i = 0; i < 1500; ++i) { if (await tryLock()) break; await sleep(100); } From 40d1efaf48f6a9e04db762995d2541de9d75c9c1 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 11 Dec 2017 17:08:47 -0300 Subject: [PATCH 446/625] iOS: support nullable enums --- src/target/swift.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/target/swift.cr b/src/target/swift.cr index e5c5f6a..ccc9a47 100644 --- a/src/target/swift.cr +++ b/src/target/swift.cr @@ -149,7 +149,11 @@ END when AST::VoidPrimitiveType "nil" when AST::OptionalType - "APIInternal.isNull(value: #{src}) ? nil : (#{type_from_json(t.base, src)})" + if t.base.is_a? AST::EnumType + "APIInternal.isNull(value: #{src}) ? nil : #{t.base.name}(rawValue: #{src} as! String)" + else + "APIInternal.isNull(value: #{src}) ? nil : (#{type_from_json(t.base, src)})" + end when AST::ArrayType "(#{src} as! [AnyObject]).map({ #{type_from_json t.base, "$0"} })" when AST::StructType From e802187d7140c218613faa359676b123def896f8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 11 Dec 2017 17:35:40 -0300 Subject: [PATCH 447/625] Fix wrong type restriction on optionaltype --- src/target/swift.cr | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/target/swift.cr b/src/target/swift.cr index ccc9a47..82b8256 100644 --- a/src/target/swift.cr +++ b/src/target/swift.cr @@ -149,8 +149,9 @@ END when AST::VoidPrimitiveType "nil" when AST::OptionalType - if t.base.is_a? AST::EnumType - "APIInternal.isNull(value: #{src}) ? nil : #{t.base.name}(rawValue: #{src} as! String)" + base = t.base + if base.is_a? AST::EnumType + "APIInternal.isNull(value: #{src}) ? nil : #{base.name}(rawValue: #{src} as! String)" else "APIInternal.isNull(value: #{src}) ? nil : (#{type_from_json(t.base, src)})" end From 07c8a4dca3bbc1c74a9fbf1b299710cbec77a363 Mon Sep 17 00:00:00 2001 From: Tironi Date: Wed, 13 Dec 2017 13:53:14 -0300 Subject: [PATCH 448/625] update sdkgen2 to swift4 --- src/target/swift_ios.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/swift_ios.cr b/src/target/swift_ios.cr index d25920d..0d4754a 100644 --- a/src/target/swift_ios.cr +++ b/src/target/swift_ios.cr @@ -59,7 +59,7 @@ END if op.return_type.is_a? AST::VoidPrimitiveType io << <<-END case .success: - callback?(APIInternal.Result.success())\n + callback?(APIInternal.Result.success(()))\n END else io << <<-END From 10d66a461c37928d3a15a2ef7a62229be5cfee0a Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 13 Dec 2017 14:11:06 -0300 Subject: [PATCH 449/625] java stuff --- target-android/.project | 17 ++++++++++++++ .../org.eclipse.buildship.core.prefs | 2 ++ target-android/api/.classpath | 6 +++++ target-android/api/.project | 23 +++++++++++++++++++ .../org.eclipse.buildship.core.prefs | 2 ++ 5 files changed, 50 insertions(+) create mode 100644 target-android/.project create mode 100644 target-android/.settings/org.eclipse.buildship.core.prefs create mode 100644 target-android/api/.classpath create mode 100644 target-android/api/.project create mode 100644 target-android/api/.settings/org.eclipse.buildship.core.prefs diff --git a/target-android/.project b/target-android/.project new file mode 100644 index 0000000..0747141 --- /dev/null +++ b/target-android/.project @@ -0,0 +1,17 @@ + + + target-android + Project target-android created by Buildship. + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/target-android/.settings/org.eclipse.buildship.core.prefs b/target-android/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..b888301 --- /dev/null +++ b/target-android/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +#Wed Dec 13 10:40:10 BRT 2017 +connection.project.dir= diff --git a/target-android/api/.classpath b/target-android/api/.classpath new file mode 100644 index 0000000..8d8d85f --- /dev/null +++ b/target-android/api/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/target-android/api/.project b/target-android/api/.project new file mode 100644 index 0000000..f90ee76 --- /dev/null +++ b/target-android/api/.project @@ -0,0 +1,23 @@ + + + api + Project api created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/target-android/api/.settings/org.eclipse.buildship.core.prefs b/target-android/api/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..963d2e5 --- /dev/null +++ b/target-android/api/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +#Wed Dec 13 10:40:10 BRT 2017 +connection.project.dir=.. From 59abec2a0ad2d29f49fb6e239bf66e0dac5b0535 Mon Sep 17 00:00:00 2001 From: David Pires Date: Tue, 19 Dec 2017 11:11:18 -0300 Subject: [PATCH 450/625] added fromJson --- src/target/typescript_nodeserver.cr | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 853dc15..25686a6 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -113,6 +113,12 @@ END @io << "}\n" end + @ast.struct_types.each do |t| + @io << "export function transform#{t.name}FromJson(x: string) {\n" + @io << ident "return " + t.typescript_decode("x") + ";\n" + @io << "}\n" + end + @ast.errors.each do |error| @io << "export class #{error} extends Error {\n" @io << ident "_type = #{error.inspect};\n" From ab619c6de31c3f76e31f93b63ea25158e337fda1 Mon Sep 17 00:00:00 2001 From: David Pires Date: Tue, 19 Dec 2017 11:14:55 -0300 Subject: [PATCH 451/625] changed name --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 25686a6..c7e5cad 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -114,7 +114,7 @@ END end @ast.struct_types.each do |t| - @io << "export function transform#{t.name}FromJson(x: string) {\n" + @io << "export function transformJsonTo#{t.name}(x: string) {\n" @io << ident "return " + t.typescript_decode("x") + ";\n" @io << "}\n" end From a3b4671f91601696fc9790c1c5f83afb06db4001 Mon Sep 17 00:00:00 2001 From: David Pires Date: Tue, 19 Dec 2017 13:33:01 -0300 Subject: [PATCH 452/625] fix json --- src/target/typescript_nodeserver.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index c7e5cad..5232e22 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -115,6 +115,7 @@ END @ast.struct_types.each do |t| @io << "export function transformJsonTo#{t.name}(x: string) {\n" + @io << "const y = JSON.parse(x);" @io << ident "return " + t.typescript_decode("x") + ";\n" @io << "}\n" end From 189dd59d1fdfb6d243320f753d3ba648d1ae8509 Mon Sep 17 00:00:00 2001 From: David Pires Date: Tue, 19 Dec 2017 14:46:46 -0300 Subject: [PATCH 453/625] fix --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 5232e22..d8918ec 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -116,7 +116,7 @@ END @ast.struct_types.each do |t| @io << "export function transformJsonTo#{t.name}(x: string) {\n" @io << "const y = JSON.parse(x);" - @io << ident "return " + t.typescript_decode("x") + ";\n" + @io << ident "return " + t.typescript_decode("y") + ";\n" @io << "}\n" end From ebb4ef837aa60e79f6b79225c0eeb83ce50a81f4 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 26 Dec 2017 16:14:55 -0300 Subject: [PATCH 454/625] Crystal 0.24.1 --- src/target/java.cr | 8 ++++---- src/utils.cr | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/target/java.cr b/src/target/java.cr index 2a3598c..f9a642f 100644 --- a/src/target/java.cr +++ b/src/target/java.cr @@ -1,5 +1,5 @@ require "./target" -require "secure_random" +require "random/secure" abstract class JavaTarget < Target def mangle(ident) @@ -220,8 +220,8 @@ END when AST::OptionalType "#{obj}.isNull(#{name}) ? null : #{type_from_json(t.base, obj, name)}" when AST::ArrayType - i = "i" + SecureRandom.hex[0, 5] - ary = "ary" + SecureRandom.hex[0, 5] + i = "i" + Random::Secure.hex[0, 5] + ary = "ary" + Random::Secure.hex[0, 5] "new #{native_type t}() {{ final JSONArray #{ary} = #{obj}.getJSONArray(#{name}); for (int #{i} = 0; #{i} < #{ary}.length(); ++#{i}) {final int x#{i} = #{i}; add(#{type_from_json(t.base, "#{ary}", "x#{i}")});} }}" when AST::StructType "#{mangle t.name}.fromJSON(#{obj}.getJSONObject(#{name}))" @@ -249,7 +249,7 @@ END when AST::OptionalType "#{src} == null ? JSONObject.NULL : #{type_to_json(t.base, src)}" when AST::ArrayType - el = "el" + SecureRandom.hex[0, 5] + el = "el" + Random::Secure.hex[0, 5] "new JSONArray() {{ for (final #{native_type t.base} #{el} : #{src}) put(#{type_to_json t.base, "#{el}"}); }}" when AST::StructType "#{src}.toJSON()" diff --git a/src/utils.cr b/src/utils.cr index 35852d4..5f14996 100644 --- a/src/utils.cr +++ b/src/utils.cr @@ -1,5 +1,5 @@ module RandomGen - @@gen = Random::PCG32.new(17) + @@gen = Random::PCG32.new(17u64) def self.random_u @@gen.next_u From 320a13d71a24451d03f59ea99c7cf0f361b153c1 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 3 Jan 2018 11:59:53 -0300 Subject: [PATCH 455/625] Include sentry and debugging with localtunnel --- src/target/typescript_nodeserver.cr | 37 +- target-node/package.json | 23 +- target-node/yarn.lock | 893 ++++++++++++++++++---------- 3 files changed, 620 insertions(+), 333 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index d8918ec..31db965 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -8,6 +8,7 @@ import crypto from "crypto"; import os from "os"; import url from "url"; import moment from "moment"; +import Raven from "raven"; #{String.build do |io| if @ast.options.useRethink io << <<-END @@ -52,6 +53,11 @@ export function setCaptureErrorFn(fn: (e: Error, req?: http.IncomingMessage, ext captureError = fn; } +let sentryUrl: string | null = null +export function setSentryUrl(url: string) { + sentryUrl = url; +} + function typeCheckerError(e: Error, ctx: Context) { #{@ast.options.strict ? "throw e;" : "setTimeout(() => captureError(e, ctx.req, ctx.call), 1000);"} } @@ -404,9 +410,34 @@ END if ((server as any).keepAliveTimeout) (server as any).keepAliveTimeout = 0; - server.listen(port, () => { - console.log(`Listening on ${server.address().address}:${server.address().port}`); - }); + if (!process.env.TEST && !process.env.DEBUGGING && sentryUrl) { + Raven.config(sentryUrl).install(); + api.setCaptureErrorFn((e, req, extra) => + Raven.captureException(e, { + req, + extra, + fingerprint: [e.message.replace(/[0-9]+/g, "X").replace(/"[^"]*"/g, "X")] + }) + ); + } + + if (process.env.DEBUGGING) { + port = (Math.random() * 50000 + 10000) | 0; + } + + if (!process.env.TEST) { + server.listen(port, () => { + console.log(`Listening on ${server.address().address}:${server.address().port}`); + }); + } + + if (process.env.DEBUGGING) { + const subdomain = require("crypto").createHash("md5").update(process.argv[1]).digest("hex").substr(0, 8); + require("localtunnel")(8000, {subdomain}, (err: Error | null, tunnel: any) => { + if (err) throw err; + console.log("Tunnel URL:", tunnel.url); + }); + } } fn.ping = async (ctx: Context) => "pong"; diff --git a/target-node/package.json b/target-node/package.json index df64ae1..3a81f4a 100644 --- a/target-node/package.json +++ b/target-node/package.json @@ -2,10 +2,13 @@ "name": "@cubos/api", "version": "0.0", "dependencies": { - "@types/node": "^7.0.31", - "babel-runtime": "^6.23.0", - "moment": "^2.17.1", - "request": "^2.81.0" + "@types/node": "^8.5.2", + "@types/raven": "^2.1.3", + "babel-runtime": "^6.26.0", + "localtunnel": "^1.8.3", + "moment": "^2.20.1", + "raven": "^2.3.0", + "request": "^2.83.0" }, "main": "api.js", "types": "api.d.ts", @@ -15,18 +18,14 @@ "transform-runtime" ], "presets": [ - "babel-preset-es2015", - "babel-preset-es2016", - "babel-preset-es2017" + "babel-preset-env" ] }, "devDependencies": { - "babel-cli": "^6.23.0", + "babel-cli": "^6.26.0", "babel-plugin-transform-runtime": "^6.23.0", - "babel-preset-es2015": "^6.22.0", - "babel-preset-es2016": "^6.22.0", - "babel-preset-es2017": "^6.22.0", + "babel-preset-env": "^1.6.1", "json": "^9.0.4", - "typescript": "^2.3.4" + "typescript": "^2.6.2" } } diff --git a/target-node/yarn.lock b/target-node/yarn.lock index 452b9f2..c7d8f4c 100644 --- a/target-node/yarn.lock +++ b/target-node/yarn.lock @@ -2,13 +2,24 @@ # yarn lockfile v1 -"@types/node@^7.0.31": - version "7.0.31" - resolved "https://npm.cubos.io/@types%2fnode/-/node-7.0.31.tgz#80ea4d175599b2a00149c29a10a4eb2dff592e86" +"@types/events@*": + version "1.1.0" + resolved "https://npm.cubos.io/@types%2fevents/-/events-1.1.0.tgz#93b1be91f63c184450385272c47b6496fd028e02" + +"@types/node@*", "@types/node@^8.5.2": + version "8.5.2" + resolved "https://npm.cubos.io/@types%2fnode/-/node-8.5.2.tgz#83b8103fa9a2c2e83d78f701a9aa7c9539739aa5" + +"@types/raven@^2.1.3": + version "2.1.3" + resolved "https://npm.cubos.io/@types%2fraven/-/raven-2.1.3.tgz#b241ccb42aba90d8b8863741dad29e01508bd37c" + dependencies: + "@types/events" "*" + "@types/node" "*" abbrev@1: - version "1.1.0" - resolved "https://npm.cubos.io/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" + version "1.1.1" + resolved "https://npm.cubos.io/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" ajv@^4.9.1: version "4.11.8" @@ -17,6 +28,15 @@ ajv@^4.9.1: co "^4.6.0" json-stable-stringify "^1.0.1" +ajv@^5.1.0: + version "5.5.2" + resolved "https://npm.cubos.io/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" + dependencies: + co "^4.6.0" + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + ansi-regex@^2.0.0: version "2.1.1" resolved "https://npm.cubos.io/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" @@ -26,15 +46,15 @@ ansi-styles@^2.2.1: resolved "https://npm.cubos.io/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" anymatch@^1.3.0: - version "1.3.0" - resolved "https://npm.cubos.io/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507" + version "1.3.2" + resolved "https://npm.cubos.io/anymatch/-/anymatch-1.3.2.tgz#553dcb8f91e3c889845dfdba34c77721b90b9d7a" dependencies: - arrify "^1.0.0" micromatch "^2.1.5" + normalize-path "^2.0.0" aproba@^1.0.3: - version "1.1.2" - resolved "https://npm.cubos.io/aproba/-/aproba-1.1.2.tgz#45c6629094de4e96f693ef7eab74ae079c240fc1" + version "1.2.0" + resolved "https://npm.cubos.io/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" are-we-there-yet@~1.1.2: version "1.1.4" @@ -50,17 +70,13 @@ arr-diff@^2.0.0: arr-flatten "^1.0.1" arr-flatten@^1.0.1: - version "1.0.3" - resolved "https://npm.cubos.io/arr-flatten/-/arr-flatten-1.0.3.tgz#a274ed85ac08849b6bd7847c4580745dc51adfb1" + version "1.1.0" + resolved "https://npm.cubos.io/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" array-unique@^0.2.1: version "0.2.1" resolved "https://npm.cubos.io/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" -arrify@^1.0.0: - version "1.0.1" - resolved "https://npm.cubos.io/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" - asn1@~0.2.3: version "0.2.3" resolved "https://npm.cubos.io/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" @@ -85,74 +101,78 @@ aws-sign2@~0.6.0: version "0.6.0" resolved "https://npm.cubos.io/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" -aws4@^1.2.1: +aws-sign2@~0.7.0: + version "0.7.0" + resolved "https://npm.cubos.io/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + +aws4@^1.2.1, aws4@^1.6.0: version "1.6.0" resolved "https://npm.cubos.io/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" -babel-cli@^6.23.0: - version "6.24.1" - resolved "https://npm.cubos.io/babel-cli/-/babel-cli-6.24.1.tgz#207cd705bba61489b2ea41b5312341cf6aca2283" +babel-cli@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-cli/-/babel-cli-6.26.0.tgz#502ab54874d7db88ad00b887a06383ce03d002f1" dependencies: - babel-core "^6.24.1" - babel-polyfill "^6.23.0" - babel-register "^6.24.1" - babel-runtime "^6.22.0" - commander "^2.8.1" - convert-source-map "^1.1.0" + babel-core "^6.26.0" + babel-polyfill "^6.26.0" + babel-register "^6.26.0" + babel-runtime "^6.26.0" + commander "^2.11.0" + convert-source-map "^1.5.0" fs-readdir-recursive "^1.0.0" - glob "^7.0.0" - lodash "^4.2.0" - output-file-sync "^1.1.0" - path-is-absolute "^1.0.0" + glob "^7.1.2" + lodash "^4.17.4" + output-file-sync "^1.1.2" + path-is-absolute "^1.0.1" slash "^1.0.0" - source-map "^0.5.0" - v8flags "^2.0.10" + source-map "^0.5.6" + v8flags "^2.1.1" optionalDependencies: chokidar "^1.6.1" -babel-code-frame@^6.22.0: - version "6.22.0" - resolved "https://npm.cubos.io/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" +babel-code-frame@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" dependencies: - chalk "^1.1.0" + chalk "^1.1.3" esutils "^2.0.2" - js-tokens "^3.0.0" + js-tokens "^3.0.2" -babel-core@^6.24.1: - version "6.25.0" - resolved "https://npm.cubos.io/babel-core/-/babel-core-6.25.0.tgz#7dd42b0463c742e9d5296deb3ec67a9322dad729" +babel-core@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-core/-/babel-core-6.26.0.tgz#af32f78b31a6fcef119c87b0fd8d9753f03a0bb8" dependencies: - babel-code-frame "^6.22.0" - babel-generator "^6.25.0" + babel-code-frame "^6.26.0" + babel-generator "^6.26.0" babel-helpers "^6.24.1" babel-messages "^6.23.0" - babel-register "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.25.0" - babel-traverse "^6.25.0" - babel-types "^6.25.0" - babylon "^6.17.2" - convert-source-map "^1.1.0" - debug "^2.1.1" - json5 "^0.5.0" - lodash "^4.2.0" - minimatch "^3.0.2" - path-is-absolute "^1.0.0" - private "^0.1.6" + babel-register "^6.26.0" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + convert-source-map "^1.5.0" + debug "^2.6.8" + json5 "^0.5.1" + lodash "^4.17.4" + minimatch "^3.0.4" + path-is-absolute "^1.0.1" + private "^0.1.7" slash "^1.0.0" - source-map "^0.5.0" + source-map "^0.5.6" -babel-generator@^6.25.0: - version "6.25.0" - resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.25.0.tgz#33a1af70d5f2890aeb465a4a7793c1df6a9ea9fc" +babel-generator@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-generator/-/babel-generator-6.26.0.tgz#ac1ae20070b79f6e3ca1d3269613053774f20dc5" dependencies: babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-types "^6.25.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" detect-indent "^4.0.0" jsesc "^1.3.0" - lodash "^4.2.0" - source-map "^0.5.0" + lodash "^4.17.4" + source-map "^0.5.6" trim-right "^1.0.1" babel-helper-builder-binary-assignment-operator-visitor@^6.24.1: @@ -173,13 +193,13 @@ babel-helper-call-delegate@^6.24.1: babel-types "^6.24.1" babel-helper-define-map@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helper-define-map/-/babel-helper-define-map-6.24.1.tgz#7a9747f258d8947d32d515f6aa1c7bd02204a080" + version "6.26.0" + resolved "https://npm.cubos.io/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz#a5f56dab41a25f97ecb498c7ebaca9819f95be5f" dependencies: babel-helper-function-name "^6.24.1" - babel-runtime "^6.22.0" - babel-types "^6.24.1" - lodash "^4.2.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" babel-helper-explode-assignable-expression@^6.24.1: version "6.24.1" @@ -221,12 +241,12 @@ babel-helper-optimise-call-expression@^6.24.1: babel-types "^6.24.1" babel-helper-regex@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-helper-regex/-/babel-helper-regex-6.24.1.tgz#d36e22fab1008d79d88648e32116868128456ce8" + version "6.26.0" + resolved "https://npm.cubos.io/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz#325c59f902f82f24b74faceed0363954f6495e72" dependencies: - babel-runtime "^6.22.0" - babel-types "^6.24.1" - lodash "^4.2.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" babel-helper-remap-async-to-generator@^6.24.1: version "6.24.1" @@ -280,7 +300,7 @@ babel-plugin-syntax-trailing-function-commas@^6.22.0: version "6.22.0" resolved "https://npm.cubos.io/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" -babel-plugin-transform-async-to-generator@^6.24.1: +babel-plugin-transform-async-to-generator@^6.22.0: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761" dependencies: @@ -300,17 +320,17 @@ babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-block-scoping@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.24.1.tgz#76c295dc3a4741b1665adfd3167215dcff32a576" +babel-plugin-transform-es2015-block-scoping@^6.23.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz#d70f5299c1308d05c12f463813b0a09e73b1895f" dependencies: - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - lodash "^4.2.0" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" -babel-plugin-transform-es2015-classes@^6.24.1: +babel-plugin-transform-es2015-classes@^6.23.0: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db" dependencies: @@ -324,33 +344,33 @@ babel-plugin-transform-es2015-classes@^6.24.1: babel-traverse "^6.24.1" babel-types "^6.24.1" -babel-plugin-transform-es2015-computed-properties@^6.24.1: +babel-plugin-transform-es2015-computed-properties@^6.22.0: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz#6fe2a8d16895d5634f4cd999b6d3480a308159b3" dependencies: babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-es2015-destructuring@^6.22.0: +babel-plugin-transform-es2015-destructuring@^6.23.0: version "6.23.0" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-duplicate-keys@^6.24.1: +babel-plugin-transform-es2015-duplicate-keys@^6.22.0: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz#73eb3d310ca969e3ef9ec91c53741a6f1576423e" dependencies: babel-runtime "^6.22.0" babel-types "^6.24.1" -babel-plugin-transform-es2015-for-of@^6.22.0: +babel-plugin-transform-es2015-for-of@^6.23.0: version "6.23.0" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz#f47c95b2b613df1d3ecc2fdb7573623c75248691" dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-function-name@^6.24.1: +babel-plugin-transform-es2015-function-name@^6.22.0: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz#834c89853bc36b1af0f3a4c5dbaa94fd8eacaa8b" dependencies: @@ -364,7 +384,7 @@ babel-plugin-transform-es2015-literals@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-modules-amd@^6.24.1: +babel-plugin-transform-es2015-modules-amd@^6.22.0, babel-plugin-transform-es2015-modules-amd@^6.24.1: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154" dependencies: @@ -372,16 +392,16 @@ babel-plugin-transform-es2015-modules-amd@^6.24.1: babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-es2015-modules-commonjs@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.24.1.tgz#d3e310b40ef664a36622200097c6d440298f2bfe" +babel-plugin-transform-es2015-modules-commonjs@^6.23.0, babel-plugin-transform-es2015-modules-commonjs@^6.24.1: + version "6.26.0" + resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz#0d8394029b7dc6abe1a97ef181e00758dd2e5d8a" dependencies: babel-plugin-transform-strict-mode "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-types "^6.24.1" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-types "^6.26.0" -babel-plugin-transform-es2015-modules-systemjs@^6.24.1: +babel-plugin-transform-es2015-modules-systemjs@^6.23.0: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" dependencies: @@ -389,7 +409,7 @@ babel-plugin-transform-es2015-modules-systemjs@^6.24.1: babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-es2015-modules-umd@^6.24.1: +babel-plugin-transform-es2015-modules-umd@^6.23.0: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz#ac997e6285cd18ed6176adb607d602344ad38468" dependencies: @@ -397,14 +417,14 @@ babel-plugin-transform-es2015-modules-umd@^6.24.1: babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-es2015-object-super@^6.24.1: +babel-plugin-transform-es2015-object-super@^6.22.0: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz#24cef69ae21cb83a7f8603dad021f572eb278f8d" dependencies: babel-helper-replace-supers "^6.24.1" babel-runtime "^6.22.0" -babel-plugin-transform-es2015-parameters@^6.24.1: +babel-plugin-transform-es2015-parameters@^6.23.0: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" dependencies: @@ -415,7 +435,7 @@ babel-plugin-transform-es2015-parameters@^6.24.1: babel-traverse "^6.24.1" babel-types "^6.24.1" -babel-plugin-transform-es2015-shorthand-properties@^6.24.1: +babel-plugin-transform-es2015-shorthand-properties@^6.22.0: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz#24f875d6721c87661bbd99a4622e51f14de38aa0" dependencies: @@ -428,7 +448,7 @@ babel-plugin-transform-es2015-spread@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-sticky-regex@^6.24.1: +babel-plugin-transform-es2015-sticky-regex@^6.22.0: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz#00c1cdb1aca71112cdf0cf6126c2ed6b457ccdbc" dependencies: @@ -442,13 +462,13 @@ babel-plugin-transform-es2015-template-literals@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-typeof-symbol@^6.22.0: +babel-plugin-transform-es2015-typeof-symbol@^6.23.0: version "6.23.0" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz#dec09f1cddff94b52ac73d505c84df59dcceb372" dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-unicode-regex@^6.24.1: +babel-plugin-transform-es2015-unicode-regex@^6.22.0: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz#d38b12f42ea7323f729387f18a7c5ae1faeb35e9" dependencies: @@ -456,7 +476,7 @@ babel-plugin-transform-es2015-unicode-regex@^6.24.1: babel-runtime "^6.22.0" regexpu-core "^2.0.0" -babel-plugin-transform-exponentiation-operator@^6.24.1: +babel-plugin-transform-exponentiation-operator@^6.22.0: version "6.24.1" resolved "https://npm.cubos.io/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz#2ab0c9c7f3098fa48907772bb813fe41e8de3a0e" dependencies: @@ -464,11 +484,11 @@ babel-plugin-transform-exponentiation-operator@^6.24.1: babel-plugin-syntax-exponentiation-operator "^6.8.0" babel-runtime "^6.22.0" -babel-plugin-transform-regenerator@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.24.1.tgz#b8da305ad43c3c99b4848e4fe4037b770d23c418" +babel-plugin-transform-regenerator@^6.22.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz#e0703696fbde27f0a3efcacf8b4dca2f7b3a8f2f" dependencies: - regenerator-transform "0.9.11" + regenerator-transform "^0.10.0" babel-plugin-transform-runtime@^6.23.0: version "6.23.0" @@ -483,111 +503,104 @@ babel-plugin-transform-strict-mode@^6.24.1: babel-runtime "^6.22.0" babel-types "^6.24.1" -babel-polyfill@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-polyfill/-/babel-polyfill-6.23.0.tgz#8364ca62df8eafb830499f699177466c3b03499d" +babel-polyfill@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153" dependencies: - babel-runtime "^6.22.0" - core-js "^2.4.0" - regenerator-runtime "^0.10.0" + babel-runtime "^6.26.0" + core-js "^2.5.0" + regenerator-runtime "^0.10.5" -babel-preset-es2015@^6.22.0: - version "6.24.1" - resolved "https://npm.cubos.io/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz#d44050d6bc2c9feea702aaf38d727a0210538939" +babel-preset-env@^1.6.1: + version "1.6.1" + resolved "https://npm.cubos.io/babel-preset-env/-/babel-preset-env-1.6.1.tgz#a18b564cc9b9afdf4aae57ae3c1b0d99188e6f48" dependencies: babel-plugin-check-es2015-constants "^6.22.0" + babel-plugin-syntax-trailing-function-commas "^6.22.0" + babel-plugin-transform-async-to-generator "^6.22.0" babel-plugin-transform-es2015-arrow-functions "^6.22.0" babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoping "^6.24.1" - babel-plugin-transform-es2015-classes "^6.24.1" - babel-plugin-transform-es2015-computed-properties "^6.24.1" - babel-plugin-transform-es2015-destructuring "^6.22.0" - babel-plugin-transform-es2015-duplicate-keys "^6.24.1" - babel-plugin-transform-es2015-for-of "^6.22.0" - babel-plugin-transform-es2015-function-name "^6.24.1" + babel-plugin-transform-es2015-block-scoping "^6.23.0" + babel-plugin-transform-es2015-classes "^6.23.0" + babel-plugin-transform-es2015-computed-properties "^6.22.0" + babel-plugin-transform-es2015-destructuring "^6.23.0" + babel-plugin-transform-es2015-duplicate-keys "^6.22.0" + babel-plugin-transform-es2015-for-of "^6.23.0" + babel-plugin-transform-es2015-function-name "^6.22.0" babel-plugin-transform-es2015-literals "^6.22.0" - babel-plugin-transform-es2015-modules-amd "^6.24.1" - babel-plugin-transform-es2015-modules-commonjs "^6.24.1" - babel-plugin-transform-es2015-modules-systemjs "^6.24.1" - babel-plugin-transform-es2015-modules-umd "^6.24.1" - babel-plugin-transform-es2015-object-super "^6.24.1" - babel-plugin-transform-es2015-parameters "^6.24.1" - babel-plugin-transform-es2015-shorthand-properties "^6.24.1" + babel-plugin-transform-es2015-modules-amd "^6.22.0" + babel-plugin-transform-es2015-modules-commonjs "^6.23.0" + babel-plugin-transform-es2015-modules-systemjs "^6.23.0" + babel-plugin-transform-es2015-modules-umd "^6.23.0" + babel-plugin-transform-es2015-object-super "^6.22.0" + babel-plugin-transform-es2015-parameters "^6.23.0" + babel-plugin-transform-es2015-shorthand-properties "^6.22.0" babel-plugin-transform-es2015-spread "^6.22.0" - babel-plugin-transform-es2015-sticky-regex "^6.24.1" + babel-plugin-transform-es2015-sticky-regex "^6.22.0" babel-plugin-transform-es2015-template-literals "^6.22.0" - babel-plugin-transform-es2015-typeof-symbol "^6.22.0" - babel-plugin-transform-es2015-unicode-regex "^6.24.1" - babel-plugin-transform-regenerator "^6.24.1" - -babel-preset-es2016@^6.22.0: - version "6.24.1" - resolved "https://npm.cubos.io/babel-preset-es2016/-/babel-preset-es2016-6.24.1.tgz#f900bf93e2ebc0d276df9b8ab59724ebfd959f8b" - dependencies: - babel-plugin-transform-exponentiation-operator "^6.24.1" + babel-plugin-transform-es2015-typeof-symbol "^6.23.0" + babel-plugin-transform-es2015-unicode-regex "^6.22.0" + babel-plugin-transform-exponentiation-operator "^6.22.0" + babel-plugin-transform-regenerator "^6.22.0" + browserslist "^2.1.2" + invariant "^2.2.2" + semver "^5.3.0" -babel-preset-es2017@^6.22.0: - version "6.24.1" - resolved "https://npm.cubos.io/babel-preset-es2017/-/babel-preset-es2017-6.24.1.tgz#597beadfb9f7f208bcfd8a12e9b2b29b8b2f14d1" +babel-register@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071" dependencies: - babel-plugin-syntax-trailing-function-commas "^6.22.0" - babel-plugin-transform-async-to-generator "^6.24.1" - -babel-register@^6.24.1: - version "6.24.1" - resolved "https://npm.cubos.io/babel-register/-/babel-register-6.24.1.tgz#7e10e13a2f71065bdfad5a1787ba45bca6ded75f" - dependencies: - babel-core "^6.24.1" - babel-runtime "^6.22.0" - core-js "^2.4.0" + babel-core "^6.26.0" + babel-runtime "^6.26.0" + core-js "^2.5.0" home-or-tmp "^2.0.0" - lodash "^4.2.0" + lodash "^4.17.4" mkdirp "^0.5.1" - source-map-support "^0.4.2" + source-map-support "^0.4.15" -babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0: - version "6.23.0" - resolved "https://npm.cubos.io/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b" +babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" dependencies: core-js "^2.4.0" - regenerator-runtime "^0.10.0" + regenerator-runtime "^0.11.0" -babel-template@^6.24.1, babel-template@^6.25.0: - version "6.25.0" - resolved "https://npm.cubos.io/babel-template/-/babel-template-6.25.0.tgz#665241166b7c2aa4c619d71e192969552b10c071" +babel-template@^6.24.1, babel-template@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" dependencies: - babel-runtime "^6.22.0" - babel-traverse "^6.25.0" - babel-types "^6.25.0" - babylon "^6.17.2" - lodash "^4.2.0" + babel-runtime "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + lodash "^4.17.4" -babel-traverse@^6.24.1, babel-traverse@^6.25.0: - version "6.25.0" - resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.25.0.tgz#2257497e2fcd19b89edc13c4c91381f9512496f1" +babel-traverse@^6.24.1, babel-traverse@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" dependencies: - babel-code-frame "^6.22.0" + babel-code-frame "^6.26.0" babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-types "^6.25.0" - babylon "^6.17.2" - debug "^2.2.0" - globals "^9.0.0" - invariant "^2.2.0" - lodash "^4.2.0" - -babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.25.0: - version "6.25.0" - resolved "https://npm.cubos.io/babel-types/-/babel-types-6.25.0.tgz#70afb248d5660e5d18f811d91c8303b54134a18e" - dependencies: - babel-runtime "^6.22.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + debug "^2.6.8" + globals "^9.18.0" + invariant "^2.2.2" + lodash "^4.17.4" + +babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26.0: + version "6.26.0" + resolved "https://npm.cubos.io/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" + dependencies: + babel-runtime "^6.26.0" esutils "^2.0.2" - lodash "^4.2.0" - to-fast-properties "^1.0.1" + lodash "^4.17.4" + to-fast-properties "^1.0.3" -babylon@^6.17.2: - version "6.17.3" - resolved "https://npm.cubos.io/babylon/-/babylon-6.17.3.tgz#1327d709950b558f204e5352587fd0290f8d8e48" +babylon@^6.18.0: + version "6.18.0" + resolved "https://npm.cubos.io/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" balanced-match@^1.0.0: version "1.0.0" @@ -600,8 +613,8 @@ bcrypt-pbkdf@^1.0.0: tweetnacl "^0.14.3" binary-extensions@^1.0.0: - version "1.8.0" - resolved "https://npm.cubos.io/binary-extensions/-/binary-extensions-1.8.0.tgz#48ec8d16df4377eae5fa5884682480af4d95c774" + version "1.11.0" + resolved "https://npm.cubos.io/binary-extensions/-/binary-extensions-1.11.0.tgz#46aa1751fb6a2f93ee5e689bb1087d4b14c6c205" block-stream@*: version "0.0.9" @@ -615,6 +628,18 @@ boom@2.x.x: dependencies: hoek "2.x.x" +boom@4.x.x: + version "4.3.1" + resolved "https://npm.cubos.io/boom/-/boom-4.3.1.tgz#4f8a3005cb4a7e3889f749030fd25b96e01d2e31" + dependencies: + hoek "4.x.x" + +boom@5.x.x: + version "5.2.0" + resolved "https://npm.cubos.io/boom/-/boom-5.2.0.tgz#5dd9da6ee3a5f302077436290cb717d3f4a54e02" + dependencies: + hoek "4.x.x" + brace-expansion@^1.1.7: version "1.1.8" resolved "https://npm.cubos.io/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" @@ -630,11 +655,26 @@ braces@^1.8.2: preserve "^0.2.0" repeat-element "^1.1.2" +browserslist@^2.1.2: + version "2.11.0" + resolved "https://npm.cubos.io/browserslist/-/browserslist-2.11.0.tgz#50350d6873a82ebe0f3ae5483658c571ae5f9d7d" + dependencies: + caniuse-lite "^1.0.30000784" + electron-to-chromium "^1.3.30" + +camelcase@^1.2.1: + version "1.2.1" + resolved "https://npm.cubos.io/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" + +caniuse-lite@^1.0.30000784: + version "1.0.30000784" + resolved "https://npm.cubos.io/caniuse-lite/-/caniuse-lite-1.0.30000784.tgz#129ced74e9a1280a441880b6cd2bce30ef59e6c0" + caseless@~0.12.0: version "0.12.0" resolved "https://npm.cubos.io/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" -chalk@^1.1.0: +chalk@^1.1.3: version "1.1.3" resolved "https://npm.cubos.io/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" dependencies: @@ -659,6 +699,14 @@ chokidar@^1.6.1: optionalDependencies: fsevents "^1.0.0" +cliui@^3.0.3: + version "3.2.0" + resolved "https://npm.cubos.io/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + wrap-ansi "^2.0.0" + co@^4.6.0: version "4.6.0" resolved "https://npm.cubos.io/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" @@ -673,11 +721,9 @@ combined-stream@^1.0.5, combined-stream@~1.0.5: dependencies: delayed-stream "~1.0.0" -commander@^2.8.1: - version "2.9.0" - resolved "https://npm.cubos.io/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" - dependencies: - graceful-readlink ">= 1.0.0" +commander@^2.11.0: + version "2.12.2" + resolved "https://npm.cubos.io/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555" concat-map@0.0.1: version "0.0.1" @@ -687,15 +733,19 @@ console-control-strings@^1.0.0, console-control-strings@~1.1.0: version "1.1.0" resolved "https://npm.cubos.io/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" -convert-source-map@^1.1.0: - version "1.5.0" - resolved "https://npm.cubos.io/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" +convert-source-map@^1.5.0: + version "1.5.1" + resolved "https://npm.cubos.io/convert-source-map/-/convert-source-map-1.5.1.tgz#b8278097b9bc229365de5c62cf5fcaed8b5599e5" + +cookie@0.3.1: + version "0.3.1" + resolved "https://npm.cubos.io/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" -core-js@^2.4.0: - version "2.4.1" - resolved "https://npm.cubos.io/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" +core-js@^2.4.0, core-js@^2.5.0: + version "2.5.3" + resolved "https://npm.cubos.io/core-js/-/core-js-2.5.3.tgz#8acc38345824f16d8365b7c9b4259168e8ed603e" -core-util-is@~1.0.0: +core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" resolved "https://npm.cubos.io/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -705,18 +755,34 @@ cryptiles@2.x.x: dependencies: boom "2.x.x" +cryptiles@3.x.x: + version "3.1.2" + resolved "https://npm.cubos.io/cryptiles/-/cryptiles-3.1.2.tgz#a89fbb220f5ce25ec56e8c4aa8a4fd7b5b0d29fe" + dependencies: + boom "5.x.x" + dashdash@^1.12.0: version "1.14.1" resolved "https://npm.cubos.io/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" dependencies: assert-plus "^1.0.0" -debug@^2.1.1, debug@^2.2.0: +debug@2.6.8: version "2.6.8" resolved "https://npm.cubos.io/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" dependencies: ms "2.0.0" +debug@^2.2.0, debug@^2.6.8: + version "2.6.9" + resolved "https://npm.cubos.io/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + +decamelize@^1.0.0: + version "1.2.0" + resolved "https://npm.cubos.io/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + deep-extend@~0.4.0: version "0.4.2" resolved "https://npm.cubos.io/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" @@ -735,12 +801,26 @@ detect-indent@^4.0.0: dependencies: repeating "^2.0.0" +detect-libc@^1.0.2: + version "1.0.3" + resolved "https://npm.cubos.io/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" + ecc-jsbn@~0.1.1: version "0.1.1" resolved "https://npm.cubos.io/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" dependencies: jsbn "~0.1.0" +electron-releases@^2.1.0: + version "2.1.0" + resolved "https://npm.cubos.io/electron-releases/-/electron-releases-2.1.0.tgz#c5614bf811f176ce3c836e368a0625782341fd4e" + +electron-to-chromium@^1.3.30: + version "1.3.30" + resolved "https://npm.cubos.io/electron-to-chromium/-/electron-to-chromium-1.3.30.tgz#9666f532a64586651fc56a72513692e820d06a80" + dependencies: + electron-releases "^2.1.0" + escape-string-regexp@^1.0.2: version "1.0.5" resolved "https://npm.cubos.io/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -761,7 +841,7 @@ expand-range@^1.8.1: dependencies: fill-range "^2.1.0" -extend@~3.0.0: +extend@~3.0.0, extend@~3.0.1: version "3.0.1" resolved "https://npm.cubos.io/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" @@ -771,9 +851,21 @@ extglob@^0.3.1: dependencies: is-extglob "^1.0.0" -extsprintf@1.0.2: - version "1.0.2" - resolved "https://npm.cubos.io/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" +extsprintf@1.3.0: + version "1.3.0" + resolved "https://npm.cubos.io/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + +extsprintf@^1.2.0: + version "1.4.0" + resolved "https://npm.cubos.io/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" + +fast-deep-equal@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" + +fast-json-stable-stringify@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" filename-regex@^2.0.0: version "2.0.1" @@ -811,20 +903,28 @@ form-data@~2.1.1: combined-stream "^1.0.5" mime-types "^2.1.12" +form-data@~2.3.1: + version "2.3.1" + resolved "https://npm.cubos.io/form-data/-/form-data-2.3.1.tgz#6fb94fbd71885306d73d15cc497fe4cc4ecd44bf" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + fs-readdir-recursive@^1.0.0: - version "1.0.0" - resolved "https://npm.cubos.io/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560" + version "1.1.0" + resolved "https://npm.cubos.io/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27" fs.realpath@^1.0.0: version "1.0.0" resolved "https://npm.cubos.io/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" fsevents@^1.0.0: - version "1.1.2" - resolved "https://npm.cubos.io/fsevents/-/fsevents-1.1.2.tgz#3282b713fb3ad80ede0e9fcf4611b5aa6fc033f4" + version "1.1.3" + resolved "https://npm.cubos.io/fsevents/-/fsevents-1.1.3.tgz#11f82318f5fe7bb2cd22965a108e9306208216d8" dependencies: nan "^2.3.0" - node-pre-gyp "^0.6.36" + node-pre-gyp "^0.6.39" fstream-ignore@^1.0.5: version "1.0.5" @@ -875,7 +975,7 @@ glob-parent@^2.0.0: dependencies: is-glob "^2.0.0" -glob@^7.0.0, glob@^7.0.5: +glob@^7.0.5, glob@^7.1.2: version "7.1.2" resolved "https://npm.cubos.io/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: @@ -886,7 +986,7 @@ glob@^7.0.0, glob@^7.0.5: once "^1.3.0" path-is-absolute "^1.0.0" -globals@^9.0.0: +globals@^9.18.0: version "9.18.0" resolved "https://npm.cubos.io/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" @@ -894,14 +994,14 @@ graceful-fs@^4.1.2, graceful-fs@^4.1.4: version "4.1.11" resolved "https://npm.cubos.io/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" -"graceful-readlink@>= 1.0.0": - version "1.0.1" - resolved "https://npm.cubos.io/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" - har-schema@^1.0.5: version "1.0.5" resolved "https://npm.cubos.io/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" +har-schema@^2.0.0: + version "2.0.0" + resolved "https://npm.cubos.io/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + har-validator@~4.2.1: version "4.2.1" resolved "https://npm.cubos.io/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" @@ -909,6 +1009,13 @@ har-validator@~4.2.1: ajv "^4.9.1" har-schema "^1.0.5" +har-validator@~5.0.3: + version "5.0.3" + resolved "https://npm.cubos.io/har-validator/-/har-validator-5.0.3.tgz#ba402c266194f15956ef15e0fcf242993f6a7dfd" + dependencies: + ajv "^5.1.0" + har-schema "^2.0.0" + has-ansi@^2.0.0: version "2.0.0" resolved "https://npm.cubos.io/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" @@ -919,7 +1026,7 @@ has-unicode@^2.0.0: version "2.0.1" resolved "https://npm.cubos.io/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" -hawk@~3.1.3: +hawk@3.1.3, hawk@~3.1.3: version "3.1.3" resolved "https://npm.cubos.io/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" dependencies: @@ -928,10 +1035,23 @@ hawk@~3.1.3: hoek "2.x.x" sntp "1.x.x" +hawk@~6.0.2: + version "6.0.2" + resolved "https://npm.cubos.io/hawk/-/hawk-6.0.2.tgz#af4d914eb065f9b5ce4d9d11c1cb2126eecc3038" + dependencies: + boom "4.x.x" + cryptiles "3.x.x" + hoek "4.x.x" + sntp "2.x.x" + hoek@2.x.x: version "2.16.3" resolved "https://npm.cubos.io/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" +hoek@4.x.x: + version "4.2.0" + resolved "https://npm.cubos.io/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d" + home-or-tmp@^2.0.0: version "2.0.0" resolved "https://npm.cubos.io/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" @@ -947,6 +1067,14 @@ http-signature@~1.1.0: jsprim "^1.2.2" sshpk "^1.7.0" +http-signature@~1.2.0: + version "1.2.0" + resolved "https://npm.cubos.io/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + inflight@^1.0.4: version "1.0.6" resolved "https://npm.cubos.io/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" @@ -954,20 +1082,24 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1: +inherits@2, inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.3: version "2.0.3" resolved "https://npm.cubos.io/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" ini@~1.3.0: - version "1.3.4" - resolved "https://npm.cubos.io/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" + version "1.3.5" + resolved "https://npm.cubos.io/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" -invariant@^2.2.0: +invariant@^2.2.2: version "2.2.2" resolved "https://npm.cubos.io/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" dependencies: loose-envify "^1.0.0" +invert-kv@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" + is-binary-path@^1.0.0: version "1.0.1" resolved "https://npm.cubos.io/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" @@ -975,8 +1107,8 @@ is-binary-path@^1.0.0: binary-extensions "^1.0.0" is-buffer@^1.1.5: - version "1.1.5" - resolved "https://npm.cubos.io/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" + version "1.1.6" + resolved "https://npm.cubos.io/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" is-dotfile@^1.0.0: version "1.0.3" @@ -1052,9 +1184,9 @@ isstream@~0.1.2: version "0.1.2" resolved "https://npm.cubos.io/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" -js-tokens@^3.0.0: - version "3.0.1" - resolved "https://npm.cubos.io/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7" +js-tokens@^3.0.0, js-tokens@^3.0.2: + version "3.0.2" + resolved "https://npm.cubos.io/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" jsbn@~0.1.0: version "0.1.1" @@ -1068,6 +1200,10 @@ jsesc@~0.5.0: version "0.5.0" resolved "https://npm.cubos.io/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" +json-schema-traverse@^0.3.0: + version "0.3.1" + resolved "https://npm.cubos.io/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" + json-schema@0.2.3: version "0.2.3" resolved "https://npm.cubos.io/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" @@ -1082,7 +1218,7 @@ json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://npm.cubos.io/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" -json5@^0.5.0: +json5@^0.5.1: version "0.5.1" resolved "https://npm.cubos.io/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" @@ -1095,13 +1231,13 @@ jsonify@~0.0.0: resolved "https://npm.cubos.io/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" jsprim@^1.2.2: - version "1.4.0" - resolved "https://npm.cubos.io/jsprim/-/jsprim-1.4.0.tgz#a3b87e40298d8c380552d8cc7628a0bb95a22918" + version "1.4.1" + resolved "https://npm.cubos.io/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" dependencies: assert-plus "1.0.0" - extsprintf "1.0.2" + extsprintf "1.3.0" json-schema "0.2.3" - verror "1.3.6" + verror "1.10.0" kind-of@^3.0.2: version "3.2.2" @@ -1115,7 +1251,22 @@ kind-of@^4.0.0: dependencies: is-buffer "^1.1.5" -lodash@^4.2.0: +lcid@^1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" + dependencies: + invert-kv "^1.0.0" + +localtunnel@^1.8.3: + version "1.8.3" + resolved "https://npm.cubos.io/localtunnel/-/localtunnel-1.8.3.tgz#dcc5922fd85651037d4bde24fd93248d0b24eb05" + dependencies: + debug "2.6.8" + openurl "1.1.1" + request "2.81.0" + yargs "3.29.0" + +lodash@^4.17.4: version "4.17.4" resolved "https://npm.cubos.io/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -1125,6 +1276,10 @@ loose-envify@^1.0.0: dependencies: js-tokens "^3.0.0" +lsmod@1.0.0: + version "1.0.0" + resolved "https://npm.cubos.io/lsmod/-/lsmod-1.0.0.tgz#9a00f76dca36eb23fa05350afe1b585d4299e64b" + micromatch@^2.1.5: version "2.3.11" resolved "https://npm.cubos.io/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" @@ -1143,15 +1298,15 @@ micromatch@^2.1.5: parse-glob "^3.0.4" regex-cache "^0.4.2" -mime-db@~1.27.0: - version "1.27.0" - resolved "https://npm.cubos.io/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1" +mime-db@~1.30.0: + version "1.30.0" + resolved "https://npm.cubos.io/mime-db/-/mime-db-1.30.0.tgz#74c643da2dd9d6a45399963465b26d5ca7d71f01" -mime-types@^2.1.12, mime-types@~2.1.7: - version "2.1.15" - resolved "https://npm.cubos.io/mime-types/-/mime-types-2.1.15.tgz#a4ebf5064094569237b8cf70046776d09fc92aed" +mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.7: + version "2.1.17" + resolved "https://npm.cubos.io/mime-types/-/mime-types-2.1.17.tgz#09d7a393f03e995a79f8af857b70a9e0ab16557a" dependencies: - mime-db "~1.27.0" + mime-db "~1.30.0" minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: version "3.0.4" @@ -1173,27 +1328,29 @@ minimist@^1.2.0: dependencies: minimist "0.0.8" -moment@^2.17.1: - version "2.18.1" - resolved "https://npm.cubos.io/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" +moment@^2.20.1: + version "2.20.1" + resolved "https://npm.cubos.io/moment/-/moment-2.20.1.tgz#d6eb1a46cbcc14a2b2f9434112c1ff8907f313fd" ms@2.0.0: version "2.0.0" resolved "https://npm.cubos.io/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" nan@^2.3.0: - version "2.6.2" - resolved "https://npm.cubos.io/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" + version "2.8.0" + resolved "https://npm.cubos.io/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a" -node-pre-gyp@^0.6.36: - version "0.6.36" - resolved "https://npm.cubos.io/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz#db604112cb74e0d477554e9b505b17abddfab786" +node-pre-gyp@^0.6.39: + version "0.6.39" + resolved "https://npm.cubos.io/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz#c00e96860b23c0e1420ac7befc5044e1d78d8649" dependencies: + detect-libc "^1.0.2" + hawk "3.1.3" mkdirp "^0.5.1" nopt "^4.0.1" npmlog "^4.0.2" rc "^1.1.7" - request "^2.81.0" + request "2.81.0" rimraf "^2.6.1" semver "^5.3.0" tar "^2.2.1" @@ -1206,15 +1363,15 @@ nopt@^4.0.1: abbrev "1" osenv "^0.1.4" -normalize-path@^2.0.1: +normalize-path@^2.0.0, normalize-path@^2.0.1: version "2.1.1" resolved "https://npm.cubos.io/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" dependencies: remove-trailing-separator "^1.0.1" npmlog@^4.0.2: - version "4.1.0" - resolved "https://npm.cubos.io/npmlog/-/npmlog-4.1.0.tgz#dc59bee85f64f00ed424efb2af0783df25d1c0b5" + version "4.1.2" + resolved "https://npm.cubos.io/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" dependencies: are-we-there-yet "~1.1.2" console-control-strings "~1.1.0" @@ -1225,7 +1382,7 @@ number-is-nan@^1.0.0: version "1.0.1" resolved "https://npm.cubos.io/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" -oauth-sign@~0.8.1: +oauth-sign@~0.8.1, oauth-sign@~0.8.2: version "0.8.2" resolved "https://npm.cubos.io/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" @@ -1246,10 +1403,20 @@ once@^1.3.0, once@^1.3.3: dependencies: wrappy "1" +openurl@1.1.1: + version "1.1.1" + resolved "https://npm.cubos.io/openurl/-/openurl-1.1.1.tgz#3875b4b0ef7a52c156f0db41d4609dbb0f94b387" + os-homedir@^1.0.0: version "1.0.2" resolved "https://npm.cubos.io/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" +os-locale@^1.4.0: + version "1.4.0" + resolved "https://npm.cubos.io/os-locale/-/os-locale-1.4.0.tgz#20f9f17ae29ed345e8bde583b13d2009803c14d9" + dependencies: + lcid "^1.0.0" + os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: version "1.0.2" resolved "https://npm.cubos.io/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -1261,7 +1428,7 @@ osenv@^0.1.4: os-homedir "^1.0.0" os-tmpdir "^1.0.0" -output-file-sync@^1.1.0: +output-file-sync@^1.1.2: version "1.1.2" resolved "https://npm.cubos.io/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" dependencies: @@ -1278,7 +1445,7 @@ parse-glob@^3.0.4: is-extglob "^1.0.0" is-glob "^2.0.0" -path-is-absolute@^1.0.0: +path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: version "1.0.1" resolved "https://npm.cubos.io/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" @@ -1286,13 +1453,17 @@ performance-now@^0.2.0: version "0.2.0" resolved "https://npm.cubos.io/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" +performance-now@^2.1.0: + version "2.1.0" + resolved "https://npm.cubos.io/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + preserve@^0.2.0: version "0.2.0" resolved "https://npm.cubos.io/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" -private@^0.1.6: - version "0.1.7" - resolved "https://npm.cubos.io/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1" +private@^0.1.6, private@^0.1.7: + version "0.1.8" + resolved "https://npm.cubos.io/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" process-nextick-args@~1.0.6: version "1.0.7" @@ -1306,6 +1477,10 @@ qs@~6.4.0: version "6.4.0" resolved "https://npm.cubos.io/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" +qs@~6.5.1: + version "6.5.1" + resolved "https://npm.cubos.io/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" + randomatic@^1.1.3: version "1.1.7" resolved "https://npm.cubos.io/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" @@ -1313,9 +1488,19 @@ randomatic@^1.1.3: is-number "^3.0.0" kind-of "^4.0.0" +raven@^2.3.0: + version "2.3.0" + resolved "https://npm.cubos.io/raven/-/raven-2.3.0.tgz#96f15346bdaa433b3b6d47130804506155833d69" + dependencies: + cookie "0.3.1" + lsmod "1.0.0" + stack-trace "0.0.9" + timed-out "4.0.1" + uuid "3.0.0" + rc@^1.1.7: - version "1.2.1" - resolved "https://npm.cubos.io/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95" + version "1.2.2" + resolved "https://npm.cubos.io/rc/-/rc-1.2.2.tgz#d8ce9cb57e8d64d9c7badd9876c7c34cbe3c7077" dependencies: deep-extend "~0.4.0" ini "~1.3.0" @@ -1323,15 +1508,15 @@ rc@^1.1.7: strip-json-comments "~2.0.1" readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.4: - version "2.2.11" - resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.2.11.tgz#0796b31f8d7688007ff0b93a8088d34aa17c0f72" + version "2.3.3" + resolved "https://npm.cubos.io/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" dependencies: core-util-is "~1.0.0" - inherits "~2.0.1" + inherits "~2.0.3" isarray "~1.0.0" process-nextick-args "~1.0.6" - safe-buffer "~5.0.1" - string_decoder "~1.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.0.3" util-deprecate "~1.0.1" readdirp@^2.0.0: @@ -1344,27 +1529,30 @@ readdirp@^2.0.0: set-immediate-shim "^1.0.1" regenerate@^1.2.1: - version "1.3.2" - resolved "https://npm.cubos.io/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" + version "1.3.3" + resolved "https://npm.cubos.io/regenerate/-/regenerate-1.3.3.tgz#0c336d3980553d755c39b586ae3b20aa49c82b7f" -regenerator-runtime@^0.10.0: +regenerator-runtime@^0.10.5: version "0.10.5" resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" -regenerator-transform@0.9.11: - version "0.9.11" - resolved "https://npm.cubos.io/regenerator-transform/-/regenerator-transform-0.9.11.tgz#3a7d067520cb7b7176769eb5ff868691befe1283" +regenerator-runtime@^0.11.0: + version "0.11.1" + resolved "https://npm.cubos.io/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" + +regenerator-transform@^0.10.0: + version "0.10.1" + resolved "https://npm.cubos.io/regenerator-transform/-/regenerator-transform-0.10.1.tgz#1e4996837231da8b7f3cf4114d71b5691a0680dd" dependencies: babel-runtime "^6.18.0" babel-types "^6.19.0" private "^0.1.6" regex-cache@^0.4.2: - version "0.4.3" - resolved "https://npm.cubos.io/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" + version "0.4.4" + resolved "https://npm.cubos.io/regex-cache/-/regex-cache-0.4.4.tgz#75bdc58a2a1496cec48a12835bc54c8d562336dd" dependencies: is-equal-shallow "^0.1.3" - is-primitive "^2.0.0" regexpu-core@^2.0.0: version "2.0.0" @@ -1385,8 +1573,8 @@ regjsparser@^0.1.4: jsesc "~0.5.0" remove-trailing-separator@^1.0.1: - version "1.0.2" - resolved "https://npm.cubos.io/remove-trailing-separator/-/remove-trailing-separator-1.0.2.tgz#69b062d978727ad14dc6b56ba4ab772fd8d70511" + version "1.1.0" + resolved "https://npm.cubos.io/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" repeat-element@^1.1.2: version "1.1.2" @@ -1402,7 +1590,7 @@ repeating@^2.0.0: dependencies: is-finite "^1.0.0" -request@^2.81.0: +request@2.81.0: version "2.81.0" resolved "https://npm.cubos.io/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" dependencies: @@ -1429,23 +1617,46 @@ request@^2.81.0: tunnel-agent "^0.6.0" uuid "^3.0.0" +request@^2.83.0: + version "2.83.0" + resolved "https://npm.cubos.io/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356" + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.6.0" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.1" + forever-agent "~0.6.1" + form-data "~2.3.1" + har-validator "~5.0.3" + hawk "~6.0.2" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.17" + oauth-sign "~0.8.2" + performance-now "^2.1.0" + qs "~6.5.1" + safe-buffer "^5.1.1" + stringstream "~0.0.5" + tough-cookie "~2.3.3" + tunnel-agent "^0.6.0" + uuid "^3.1.0" + rimraf@2, rimraf@^2.5.1, rimraf@^2.6.1: - version "2.6.1" - resolved "https://npm.cubos.io/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" + version "2.6.2" + resolved "https://npm.cubos.io/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: glob "^7.0.5" -safe-buffer@^5.0.1: - version "5.1.0" - resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.1.0.tgz#fe4c8460397f9eaaaa58e73be46273408a45e223" - -safe-buffer@~5.0.1: - version "5.0.1" - resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" +safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.1" + resolved "https://npm.cubos.io/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" semver@^5.3.0: - version "5.3.0" - resolved "https://npm.cubos.io/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" + version "5.4.1" + resolved "https://npm.cubos.io/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" set-blocking@~2.0.0: version "2.0.0" @@ -1469,15 +1680,21 @@ sntp@1.x.x: dependencies: hoek "2.x.x" -source-map-support@^0.4.2: - version "0.4.15" - resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.15.tgz#03202df65c06d2bd8c7ec2362a193056fef8d3b1" +sntp@2.x.x: + version "2.1.0" + resolved "https://npm.cubos.io/sntp/-/sntp-2.1.0.tgz#2c6cec14fedc2222739caf9b5c3d85d1cc5a2cc8" + dependencies: + hoek "4.x.x" + +source-map-support@^0.4.15: + version "0.4.18" + resolved "https://npm.cubos.io/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" dependencies: source-map "^0.5.6" -source-map@^0.5.0, source-map@^0.5.6: - version "0.5.6" - resolved "https://npm.cubos.io/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" +source-map@^0.5.6: + version "0.5.7" + resolved "https://npm.cubos.io/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" sshpk@^1.7.0: version "1.13.1" @@ -1493,6 +1710,10 @@ sshpk@^1.7.0: jsbn "~0.1.0" tweetnacl "~0.14.0" +stack-trace@0.0.9: + version "0.0.9" + resolved "https://npm.cubos.io/stack-trace/-/stack-trace-0.0.9.tgz#a8f6eaeca90674c333e7c43953f275b451510695" + string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" resolved "https://npm.cubos.io/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" @@ -1501,13 +1722,13 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string_decoder@~1.0.0: - version "1.0.2" - resolved "https://npm.cubos.io/string_decoder/-/string_decoder-1.0.2.tgz#b29e1f4e1125fa97a10382b8a533737b7491e179" +string_decoder@~1.0.3: + version "1.0.3" + resolved "https://npm.cubos.io/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" dependencies: - safe-buffer "~5.0.1" + safe-buffer "~5.1.0" -stringstream@~0.0.4: +stringstream@~0.0.4, stringstream@~0.0.5: version "0.0.5" resolved "https://npm.cubos.io/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" @@ -1526,8 +1747,8 @@ supports-color@^2.0.0: resolved "https://npm.cubos.io/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" tar-pack@^3.4.0: - version "3.4.0" - resolved "https://npm.cubos.io/tar-pack/-/tar-pack-3.4.0.tgz#23be2d7f671a8339376cbdb0b8fe3fdebf317984" + version "3.4.1" + resolved "https://npm.cubos.io/tar-pack/-/tar-pack-3.4.1.tgz#e1dbc03a9b9d3ba07e896ad027317eb679a10a1f" dependencies: debug "^2.2.0" fstream "^1.0.10" @@ -1546,13 +1767,17 @@ tar@^2.2.1: fstream "^1.0.2" inherits "2" -to-fast-properties@^1.0.1: +timed-out@4.0.1: + version "4.0.1" + resolved "https://npm.cubos.io/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" + +to-fast-properties@^1.0.3: version "1.0.3" resolved "https://npm.cubos.io/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" -tough-cookie@~2.3.0: - version "2.3.2" - resolved "https://npm.cubos.io/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" +tough-cookie@~2.3.0, tough-cookie@~2.3.3: + version "2.3.3" + resolved "https://npm.cubos.io/tough-cookie/-/tough-cookie-2.3.3.tgz#0b618a5565b6dea90bf3425d04d55edc475a7561" dependencies: punycode "^1.4.1" @@ -1570,9 +1795,9 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://npm.cubos.io/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" -typescript@^2.3.4: - version "2.4.0" - resolved "https://npm.cubos.io/typescript/-/typescript-2.4.0.tgz#aef5a8d404beba36ad339abf079ddddfffba86dd" +typescript@^2.6.2: + version "2.6.2" + resolved "https://npm.cubos.io/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4" uid-number@^0.0.6: version "0.0.6" @@ -1586,21 +1811,27 @@ util-deprecate@~1.0.1: version "1.0.2" resolved "https://npm.cubos.io/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" -uuid@^3.0.0: +uuid@3.0.0: + version "3.0.0" + resolved "https://npm.cubos.io/uuid/-/uuid-3.0.0.tgz#6728fc0459c450d796a99c31837569bdf672d728" + +uuid@^3.0.0, uuid@^3.1.0: version "3.1.0" resolved "https://npm.cubos.io/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" -v8flags@^2.0.10: +v8flags@^2.1.1: version "2.1.1" resolved "https://npm.cubos.io/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" dependencies: user-home "^1.1.1" -verror@1.3.6: - version "1.3.6" - resolved "https://npm.cubos.io/verror/-/verror-1.3.6.tgz#cff5df12946d297d2baaefaa2689e25be01c005c" +verror@1.10.0: + version "1.10.0" + resolved "https://npm.cubos.io/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" dependencies: - extsprintf "1.0.2" + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" wide-align@^1.1.0: version "1.1.2" @@ -1608,6 +1839,32 @@ wide-align@^1.1.0: dependencies: string-width "^1.0.2" +window-size@^0.1.2: + version "0.1.4" + resolved "https://npm.cubos.io/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876" + +wrap-ansi@^2.0.0: + version "2.1.0" + resolved "https://npm.cubos.io/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + wrappy@1: version "1.0.2" resolved "https://npm.cubos.io/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +y18n@^3.2.0: + version "3.2.1" + resolved "https://npm.cubos.io/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" + +yargs@3.29.0: + version "3.29.0" + resolved "https://npm.cubos.io/yargs/-/yargs-3.29.0.tgz#1aab9660eae79d8b8f675bcaeeab6ee34c2cf69c" + dependencies: + camelcase "^1.2.1" + cliui "^3.0.3" + decamelize "^1.0.0" + os-locale "^1.4.0" + window-size "^0.1.2" + y18n "^3.2.0" From caad5149d4f1266e9f6d25ac1d2af18be0ce1a2a Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 3 Jan 2018 12:02:10 -0300 Subject: [PATCH 456/625] Fix build error and make port optional --- src/target/typescript_nodeserver.cr | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 31db965..225ed63 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -170,7 +170,7 @@ function sleep(ms: number) { export let server: http.Server; -export function start(port: number) { +export function start(port: number = 8000) { if (server) return; server = http.createServer((req, res) => { req.on("error", (err) => { @@ -412,13 +412,11 @@ END if (!process.env.TEST && !process.env.DEBUGGING && sentryUrl) { Raven.config(sentryUrl).install(); - api.setCaptureErrorFn((e, req, extra) => - Raven.captureException(e, { - req, - extra, - fingerprint: [e.message.replace(/[0-9]+/g, "X").replace(/"[^"]*"/g, "X")] - }) - ); + captureError = (e, req, extra) => Raven.captureException(e, { + req, + extra, + fingerprint: [e.message.replace(/[0-9]+/g, "X").replace(/"[^"]*"/g, "X")] + }); } if (process.env.DEBUGGING) { From e3c8d5fd0fdf4129756ceccdb88ab08e9b0aec43 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 7 Jan 2018 11:10:34 -0300 Subject: [PATCH 457/625] implement setting url --- src/target/java_android.cr | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 81f7d99..72471a6 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -343,7 +343,12 @@ END return Internal.getHttpClientForThirdParty(); } + static public void setApiUrl(String url) { + Internal.forcedUrl = url; + } + private static class Internal { + statis String forcedUrl = null; static String baseUrl = #{@ast.options.url.inspect}; static OkHttpClient http = null; static ConnectionPool connectionPool; @@ -659,7 +664,7 @@ END } final Request request = new Request.Builder() - .url("https://" + baseUrl + (API.useStaging ? "-staging" : "") + "/" + name) + .url(forcedUrl != null ? forcedUrl : "https://" + baseUrl + (API.useStaging ? "-staging" : "") + "/" + name) .post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), body.toString())) .build(); From e775c87f5bfea3e431d64740d12f9c09ac239e59 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 7 Jan 2018 11:20:11 -0300 Subject: [PATCH 458/625] fix type --- src/target/java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 72471a6..4f14c2b 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -348,7 +348,7 @@ END } private static class Internal { - statis String forcedUrl = null; + static String forcedUrl = null; static String baseUrl = #{@ast.options.url.inspect}; static OkHttpClient http = null; static ConnectionPool connectionPool; From 2272b48843bb54407bc8f4810370b0cccdc818eb Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 7 Jan 2018 12:13:44 -0300 Subject: [PATCH 459/625] fix debugging --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 225ed63..fe37728 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -431,7 +431,7 @@ END if (process.env.DEBUGGING) { const subdomain = require("crypto").createHash("md5").update(process.argv[1]).digest("hex").substr(0, 8); - require("localtunnel")(8000, {subdomain}, (err: Error | null, tunnel: any) => { + require("localtunnel")(port, {subdomain}, (err: Error | null, tunnel: any) => { if (err) throw err; console.log("Tunnel URL:", tunnel.url); }); From a21064afb059b9c150b312700abe7fb3d42aebc6 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 11 Jan 2018 14:04:58 -0300 Subject: [PATCH 460/625] Add lastActiveAt --- src/target/typescript_nodeserver.cr | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index fe37728..a15fa79 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -26,6 +26,7 @@ interface DBDevice { screen: {width: number, height: number} version: string language: string + lastActiveAt?: Date push?: string } @@ -240,6 +241,7 @@ END (async () => { const request = JSON.parse(body); request.device.ip = ip; + request.device.lastActiveAt = new Date(); const context: Context = { call: null as any, req: req, From 5e95ca55b4df16386d93190e645cc9ded4e4d765 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 11 Jan 2018 22:16:30 -0300 Subject: [PATCH 461/625] Detect more name conflicts --- src/semantic/give_struct_and_enum_names.cr | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/semantic/give_struct_and_enum_names.cr b/src/semantic/give_struct_and_enum_names.cr index 2ab0008..8c546ae 100644 --- a/src/semantic/give_struct_and_enum_names.cr +++ b/src/semantic/give_struct_and_enum_names.cr @@ -3,6 +3,7 @@ require "./visitor" module Semantic class GiveStructAndEnumNames < Visitor @path = [] of String + @names = Hash(String, Array(String)).new def visit(definition : AST::TypeDefinition) @path = [definition.name] @@ -10,18 +11,22 @@ module Semantic end def visit(operation : AST::Operation) - @path = [operation.name[0].upcase + operation.name[1..-1]] + @path = [operation.name] super end def visit(field : AST::Field) - @path.push field.name[0].upcase + field.name[1..-1] + @path.push field.name super @path.pop end def visit(t : AST::StructType | AST::EnumType) - t.name = @path.join("") + t.name = @path.map { |s| s[0].upcase + s[1..-1] }.join("") + if @names.has_key? t.name + raise SemanticException.new("The name of the type '#{@path.join(".")}' will conflict with '#{@names[t.name].join(".")}'") + end + @names[t.name] = @path.dup super end end From e7275a19198221f185b1501917d90275e2bf1f75 Mon Sep 17 00:00:00 2001 From: Tironi Date: Tue, 16 Jan 2018 16:07:15 -0300 Subject: [PATCH 462/625] added enum value to enum in typescript --- src/codegen_types/enum.cr | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index c9a3c11..b2ac74d 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -13,7 +13,13 @@ module AST end def typescript_definition - "export type #{name} = #{values.map(&.inspect).join(" | ")};" + String::Builder.build do |io| + io << "export enum #{name}{\n" + values.each do |value| + io << ident "#{value} = \"#{value}\",\n" + end + io << "}" + end end def typescript_expect(expr) From 136044c0374121807cf65e3475bc7adc3ffd91fd Mon Sep 17 00:00:00 2001 From: Tironi Date: Tue, 16 Jan 2018 16:23:41 -0300 Subject: [PATCH 463/625] rollback from enum change --- src/codegen_types/enum.cr | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index b2ac74d..a81c3a4 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -13,13 +13,14 @@ module AST end def typescript_definition - String::Builder.build do |io| - io << "export enum #{name}{\n" - values.each do |value| - io << ident "#{value} = \"#{value}\",\n" - end - io << "}" - end + "export type #{name} = #{values.map(&.inspect).join(" | ")};" + # String::Builder.build do |io| + # io << "export enum #{name} {\n" + # values.each do |value| + # io << ident "#{value} = \"#{value}\",\n" + # end + # io << "}" + # end end def typescript_expect(expr) From 1a9b7cd451e4f8084b1a2381254f8272604a00f0 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 19 Jan 2018 10:46:41 -0300 Subject: [PATCH 464/625] improve identation --- src/target/typescript_nodeserver.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index a15fa79..0ed789e 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -117,14 +117,14 @@ END @ast.struct_types.each do |t| @io << "export function transform#{t.name}ToJson(x: #{t.typescript_native_type}) {\n" @io << ident "return " + t.typescript_encode("x") + ";\n" - @io << "}\n" + @io << "}\n\n" end @ast.struct_types.each do |t| @io << "export function transformJsonTo#{t.name}(x: string) {\n" - @io << "const y = JSON.parse(x);" + @io << ident "const y = JSON.parse(x);\n" @io << ident "return " + t.typescript_decode("y") + ";\n" - @io << "}\n" + @io << "}\n\n" end @ast.errors.each do |error| From 0d88db1702290cf1cb984d4cad43d35052752b17 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 19 Jan 2018 17:08:59 -0300 Subject: [PATCH 465/625] fix missing mangle --- src/target/java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 4f14c2b..0909353 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -162,7 +162,7 @@ try { END op.args.each do |arg| - io << ident ident "put(\"#{arg.name}\", #{type_to_json arg.type, arg.name});\n" + io << ident ident "put(\"#{arg.name}\", #{type_to_json arg.type, mangle arg.name});\n" end io << <<-END }}; From 1deabf7782e6fdb27a3ad6b14cb620bbd8fa4a0c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 19 Jan 2018 17:13:06 -0300 Subject: [PATCH 466/625] Add another missing mangle --- src/target/java.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java.cr b/src/target/java.cr index f9a642f..24f3777 100644 --- a/src/target/java.cr +++ b/src/target/java.cr @@ -86,7 +86,7 @@ public JSONObject toJSON() { END t.fields.each do |field| - io << ident ident ident ident "put(\"#{field.name}\", #{type_to_json field.type, field.name});\n" + io << ident ident ident ident "put(\"#{field.name}\", #{type_to_json field.type, mangle field.name});\n" end io << ident <<-END }}; From f04ae213fa7cdd5c05da0e0ede76284a76304d8c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 19 Jan 2018 17:17:41 -0300 Subject: [PATCH 467/625] a few more mangle --- src/target/java.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/java.cr b/src/target/java.cr index 24f3777..56310a4 100644 --- a/src/target/java.cr +++ b/src/target/java.cr @@ -139,7 +139,7 @@ protected #{mangle t.name}(final JSONObject json) { END t.fields.each do |field| - io << ident ident ident "#{field.name} = #{type_from_json field.type, "json", field.name.inspect};\n" + io << ident ident ident "#{mangle field.name} = #{type_from_json field.type, "json", field.name.inspect};\n" end io << ident <<-END @@ -154,7 +154,7 @@ protected #{mangle t.name}(Parcel in) { END t.fields.each do |field| - io << ident ident ident "#{field.name} = #{type_from_json field.type, "json", field.name.inspect};\n" + io << ident ident ident "#{mangle field.name} = #{type_from_json field.type, "json", field.name.inspect};\n" end io << ident <<-END } catch (JSONException e) { From ca6a2b00316728e036b6399debe0aa9616450861 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 24 Jan 2018 21:34:29 -0300 Subject: [PATCH 468/625] $syntheticDefaultImports --- src/ast.cr | 1 + src/syntax/ast_to_s.cr | 6 ++++++ src/syntax/parser.cr | 8 ++++++++ src/target/typescript_nodeserver.cr | 17 ++++++++++++++++- 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/ast.cr b/src/ast.cr index 0d7e301..6a27d2a 100644 --- a/src/ast.cr +++ b/src/ast.cr @@ -117,6 +117,7 @@ module AST property url = "" property useRethink = true property strict = false + property syntheticDefaultImports = true end class Field diff --git a/src/syntax/ast_to_s.cr b/src/syntax/ast_to_s.cr index 6473e18..7c67efc 100644 --- a/src/syntax/ast_to_s.cr +++ b/src/syntax/ast_to_s.cr @@ -168,6 +168,12 @@ module AST io << "\n" anyop = true end + if options.syntheticDefaultImports != false + io << "$syntheticDefaultImports = " + options.syntheticDefaultImports.inspect(io) + io << "\n" + anyop = true + end io << "\n" if anyop && errors.size != 0 errors.each do |err| io << "error " << err << "\n" diff --git a/src/syntax/parser.cr b/src/syntax/parser.cr index acc7bff..f2f5788 100644 --- a/src/syntax/parser.cr +++ b/src/syntax/parser.cr @@ -243,6 +243,14 @@ class Parser options.strict = false end read_next_token + when "syntheticDefaultImports" + case token = multi_expect(TrueKeywordToken, FalseKeywordToken) + when TrueKeywordToken + options.syntheticDefaultImports = true + when FalseKeywordToken + options.syntheticDefaultImports = false + end + read_next_token else raise ParserException.new("Unknown option $#{var.name} at #{var.location}") end diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 0ed789e..abad9f4 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -3,16 +3,31 @@ require "./target" class TypeScriptServerTarget < Target def gen @io << <<-END +#{String.build do |io| + if @ast.options.syntheticDefaultImports + io << <<-END import http from "http"; import crypto from "crypto"; import os from "os"; import url from "url"; import moment from "moment"; import Raven from "raven"; +END + else + io << <<-END +import * http from "http"; +import * crypto from "crypto"; +import * os from "os"; +import * url from "url"; +import * moment from "moment"; +import * Raven from "raven"; +END + end + end} #{String.build do |io| if @ast.options.useRethink io << <<-END -import r from "../rethinkdb"; +import * as r from "../rethinkdb"; END else io << <<-END From f63fa85b47e6dea11774d968f6b903d6000cac4b Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 24 Jan 2018 21:35:58 -0300 Subject: [PATCH 469/625] fix to_s --- src/syntax/ast_to_s.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syntax/ast_to_s.cr b/src/syntax/ast_to_s.cr index 7c67efc..3373c61 100644 --- a/src/syntax/ast_to_s.cr +++ b/src/syntax/ast_to_s.cr @@ -168,7 +168,7 @@ module AST io << "\n" anyop = true end - if options.syntheticDefaultImports != false + if options.syntheticDefaultImports != true io << "$syntheticDefaultImports = " options.syntheticDefaultImports.inspect(io) io << "\n" From 94ae49c22a7e2ef2a47bb2c0ba4ef591ee8c6829 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 24 Jan 2018 21:40:12 -0300 Subject: [PATCH 470/625] import r --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index abad9f4..1f55821 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -27,7 +27,7 @@ END #{String.build do |io| if @ast.options.useRethink io << <<-END -import * as r from "../rethinkdb"; +import r from "../rethinkdb"; END else io << <<-END From 0ad88d2d57dacf7b3a2ac4059a1fa034ca277003 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 26 Jan 2018 18:37:34 -0300 Subject: [PATCH 471/625] fix invalid imports --- src/target/typescript_nodeserver.cr | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 1f55821..025ac4c 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -15,12 +15,12 @@ import Raven from "raven"; END else io << <<-END -import * http from "http"; -import * crypto from "crypto"; -import * os from "os"; -import * url from "url"; -import * moment from "moment"; -import * Raven from "raven"; +import * as http from "http"; +import * as crypto from "crypto"; +import * as os from "os"; +import * as url from "url"; +import * as moment from "moment"; +import * as Raven from "raven"; END end end} From 6852e955ac7d431110640872b9a0278493c0a4c4 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sat, 27 Jan 2018 07:16:02 -0300 Subject: [PATCH 472/625] Fix Raven for ES6 --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 025ac4c..475c8d5 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -20,7 +20,7 @@ import * as crypto from "crypto"; import * as os from "os"; import * as url from "url"; import * as moment from "moment"; -import * as Raven from "raven"; +const Raven = require("raven"); END end end} From f34f8d331f8c3c8434aa545d4c8acc0f616c8d04 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 29 Jan 2018 15:46:38 -0300 Subject: [PATCH 473/625] add check for header sent on error --- src/target/typescript_nodeserver.cr | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 475c8d5..825b6eb 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -411,7 +411,8 @@ END ); })().catch(err => { console.error(err); - res.writeHead(500); + if (!res.headersSent) + res.writeHead(500); res.end(); }); break; From 5a9a3e1f9f956adcbc8187bba1aef90b07267aee Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 29 Jan 2018 15:53:03 -0300 Subject: [PATCH 474/625] moment import --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 825b6eb..379482a 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -19,7 +19,7 @@ import * as http from "http"; import * as crypto from "crypto"; import * as os from "os"; import * as url from "url"; -import * as moment from "moment"; +const moment = require("moment"); const Raven = require("raven"); END end From a2611e65933fc7ec4e1174f6672c9fdf0bf70e06 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 6 Feb 2018 10:04:33 -0300 Subject: [PATCH 475/625] change response status in case of error --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 379482a..71452c5 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -400,7 +400,7 @@ END error: call.error }; - res.writeHead(200); + res.writeHead(response.ok ? 200 : response.error.type === "Fatal" ? 500 : 400); res.write(JSON.stringify(response)); res.end(); From f40cc0aedde78c7d280514ecee7f9428901418ce Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 6 Feb 2018 10:10:36 -0300 Subject: [PATCH 476/625] fix build --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 71452c5..2abedd9 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -400,7 +400,7 @@ END error: call.error }; - res.writeHead(response.ok ? 200 : response.error.type === "Fatal" ? 500 : 400); + res.writeHead(!response.error ? 200 : response.error.type === "Fatal" ? 500 : 400); res.write(JSON.stringify(response)); res.end(); From 4837c145f6294369881d3e4631f4b13c55374640 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 6 Feb 2018 10:23:05 -0300 Subject: [PATCH 477/625] Fix android target ignoring status != 200 --- src/target/java_android.cr | 2 +- src/target/typescript_nodeserver.cr | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 0909353..97fd310 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -718,7 +718,7 @@ END @Override public void onResponse(Call call, final Response response) throws IOException { if (!shouldReceiveResponse[0]) return; - if (response.code() != 200) { + if (response.code() == 502) { Log.e("API", "HTTP " + response.code()); return; } diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 2abedd9..2924286 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -400,7 +400,8 @@ END error: call.error }; - res.writeHead(!response.error ? 200 : response.error.type === "Fatal" ? 500 : 400); + // res.writeHead(!response.error ? 200 : response.error.type === "Fatal" ? 500 : 400); + res.writeHead(200); res.write(JSON.stringify(response)); res.end(); From e80bc4b761765c04656a03fdb2f791de7c4107e0 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 6 Feb 2018 17:42:33 -0300 Subject: [PATCH 478/625] simplify toBeTypeOf --- src/target/typescript_servertest.cr | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/target/typescript_servertest.cr b/src/target/typescript_servertest.cr index e2861c8..904cadd 100644 --- a/src/target/typescript_servertest.cr +++ b/src/target/typescript_servertest.cr @@ -17,14 +17,10 @@ export interface Context { /* istanbul ignore next */ expect.extend({ toBeTypeOf(received, argument) { - const initialType = typeof received; - const type = initialType === "object" ? Array.isArray(received) ? "array" : initialType : initialType; - return type === argument ? { + const type = Array.isArray(received) ? "array" : typeof received; + return { message: () => `expected ${received} to be type ${argument}`, - pass: true - } : { - message: () => `expected ${received} to be type ${argument}`, - pass: false + pass: type === argument }; } }); From b89c409d80303c8ab6272b14d832f2abd0acbc85 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 9 Feb 2018 14:20:57 -0300 Subject: [PATCH 479/625] setHttpClientInterceptor --- src/target/java_android.cr | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 97fd310..26230a1 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -75,6 +75,7 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; +import okhttp3.Interceptor; public class API { public interface GlobalRequestCallback { @@ -338,9 +339,15 @@ END } } + static public void setHttpClientInterceptor(Interceptor interceptor) { + Internal.initialize(); + Internal.interceptor = interceptor; + Internal.createHttpClient(); + } + static public OkHttpClient getHttpClient() { Internal.initialize(); - return Internal.getHttpClientForThirdParty(); + return Internal.getHttpClient(); } static public void setApiUrl(String url) { @@ -357,6 +364,7 @@ END static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); static Application application; + static Interceptor interceptor = null static { dateTimeFormat.setTimeZone(TimeZone.getTimeZone("GMT")); @@ -364,7 +372,7 @@ END createHttpClient(); } - static OkHttpClient getHttpClientForThirdParty() { + static OkHttpClient getHttpClient() { if (http == null) { createHttpClient(); } @@ -402,12 +410,16 @@ END dispatcher.setMaxRequests(200); dispatcher.setMaxRequestsPerHost(200); - http = new OkHttpClient.Builder() + OkHttpClient.Builder builder = new OkHttpClient.Builder() .connectionPool(connectionPool) .dispatcher(dispatcher) .sslSocketFactory(sslSocketFactory, trustManager) .connectTimeout(5, TimeUnit.MINUTES) - .build(); + + if (interceptor) + builder.addInterceptor(interceptor); + + http = builder.build(); } static void initialize() { From 5221824650f9145f84a54b17e2f319d922a29040 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 9 Feb 2018 14:23:45 -0300 Subject: [PATCH 480/625] missing semicolon --- src/target/java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 26230a1..eebf971 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -364,7 +364,7 @@ END static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); static Application application; - static Interceptor interceptor = null + static Interceptor interceptor = null; static { dateTimeFormat.setTimeZone(TimeZone.getTimeZone("GMT")); From 4b66e4343eb1595803a4689901cfa4a55967e564 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 9 Feb 2018 14:26:48 -0300 Subject: [PATCH 481/625] semicolon again --- src/target/java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index eebf971..8e79ad9 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -414,7 +414,7 @@ END .connectionPool(connectionPool) .dispatcher(dispatcher) .sslSocketFactory(sslSocketFactory, trustManager) - .connectTimeout(5, TimeUnit.MINUTES) + .connectTimeout(5, TimeUnit.MINUTES); if (interceptor) builder.addInterceptor(interceptor); From f79319aece147d5366bb5e634bd41359b487c6d8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 9 Feb 2018 14:29:19 -0300 Subject: [PATCH 482/625] proper null check --- src/target/java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 8e79ad9..83d8a35 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -416,7 +416,7 @@ END .sslSocketFactory(sslSocketFactory, trustManager) .connectTimeout(5, TimeUnit.MINUTES); - if (interceptor) + if (interceptor != null) builder.addInterceptor(interceptor); http = builder.build(); From 1b4733f8119472ed1ab89293fa055f27016ec0ca Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 9 Feb 2018 15:13:44 -0300 Subject: [PATCH 483/625] addNetworkInterceptor --- src/target/java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 83d8a35..fea0795 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -417,7 +417,7 @@ END .connectTimeout(5, TimeUnit.MINUTES); if (interceptor != null) - builder.addInterceptor(interceptor); + builder.addNetworkInterceptor(interceptor); http = builder.build(); } From 0154922aea5f9cdf035b658901c376ab98f9362c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 9 Feb 2018 15:50:41 -0300 Subject: [PATCH 484/625] improve strict check description --- src/codegen_types/array.cr | 4 ++-- src/codegen_types/base64.cr | 4 ++-- src/codegen_types/bool.cr | 4 ++-- src/codegen_types/bytes.cr | 4 ++-- src/codegen_types/cep.cr | 4 ++-- src/codegen_types/cnpj.cr | 4 ++-- src/codegen_types/cpf.cr | 4 ++-- src/codegen_types/date.cr | 4 ++-- src/codegen_types/datetime.cr | 4 ++-- src/codegen_types/email.cr | 4 ++-- src/codegen_types/enum.cr | 4 ++-- src/codegen_types/float.cr | 4 ++-- src/codegen_types/hex.cr | 4 ++-- src/codegen_types/int.cr | 4 ++-- src/codegen_types/latlng.cr | 2 +- src/codegen_types/money.cr | 4 ++-- src/codegen_types/phone.cr | 4 ++-- src/codegen_types/safehtml.cr | 4 ++-- src/codegen_types/string.cr | 4 ++-- src/codegen_types/struct.cr | 4 ++-- src/codegen_types/uint.cr | 4 ++-- src/codegen_types/url.cr | 4 ++-- src/codegen_types/uuid.cr | 4 ++-- src/codegen_types/xml.cr | 4 ++-- 24 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr index eb434bd..76c23dc 100644 --- a/src/codegen_types/array.cr +++ b/src/codegen_types/array.cr @@ -35,7 +35,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Array)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "} else {\n" i = random_var @@ -49,7 +49,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Array)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "} else {\n" i = random_var diff --git a/src/codegen_types/base64.cr b/src/codegen_types/base64.cr index 4276e35..99d6b95 100644 --- a/src/codegen_types/base64.cr +++ b/src/codegen_types/base64.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/bool.cr b/src/codegen_types/bool.cr index 4cb0643..5b88f4d 100644 --- a/src/codegen_types/bool.cr +++ b/src/codegen_types/bool.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} !== true && #{expr} !== false) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} !== true && #{expr} !== false) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr index 0ce6265..b659da8 100644 --- a/src/codegen_types/bytes.cr +++ b/src/codegen_types/bytes.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| # io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" - # io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + # io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" # io << " typeCheckerError(err, ctx);\n" # io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Buffer)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/cep.cr b/src/codegen_types/cep.cr index d866292..27402f8 100644 --- a/src/codegen_types/cep.cr +++ b/src/codegen_types/cep.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/cnpj.cr b/src/codegen_types/cnpj.cr index e93a9c1..7406fc8 100644 --- a/src/codegen_types/cnpj.cr +++ b/src/codegen_types/cnpj.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/cpf.cr b/src/codegen_types/cpf.cr index 8ac321f..a008b47 100644 --- a/src/codegen_types/cpf.cr +++ b/src/codegen_types/cpf.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index fb55493..fa72dc7 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -25,7 +25,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -34,7 +34,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index 9901b74..ca9e7d3 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/email.cr b/src/codegen_types/email.cr index c3beba7..1a7074e 100644 --- a/src/codegen_types/email.cr +++ b/src/codegen_types/email.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index a81c3a4..ef405ee 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -33,7 +33,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -42,7 +42,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/float.cr b/src/codegen_types/float.cr index d5a763e..ddf9c22 100644 --- a/src/codegen_types/float.cr +++ b/src/codegen_types/float.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/hex.cr b/src/codegen_types/hex.cr index fb2e513..86fdcc2 100644 --- a/src/codegen_types/hex.cr +++ b/src/codegen_types/hex.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/int.cr b/src/codegen_types/int.cr index 3021e0a..f498567 100644 --- a/src/codegen_types/int.cr +++ b/src/codegen_types/int.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/latlng.cr b/src/codegen_types/latlng.cr index 241257e..58f27a0 100644 --- a/src/codegen_types/latlng.cr +++ b/src/codegen_types/latlng.cr @@ -23,7 +23,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"object\" || typeof #{expr}.lat !== \"number\" || typeof #{expr}.lng !== \"number\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/money.cr b/src/codegen_types/money.cr index 773e7e3..9c8ede7 100644 --- a/src/codegen_types/money.cr +++ b/src/codegen_types/money.cr @@ -23,7 +23,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -32,7 +32,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/phone.cr b/src/codegen_types/phone.cr index 371d90e..8748773 100644 --- a/src/codegen_types/phone.cr +++ b/src/codegen_types/phone.cr @@ -23,7 +23,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -32,7 +32,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/safehtml.cr b/src/codegen_types/safehtml.cr index 090f22f..4b8176f 100644 --- a/src/codegen_types/safehtml.cr +++ b/src/codegen_types/safehtml.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index b04a184..0c71789 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -23,7 +23,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -32,7 +32,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/struct.cr b/src/codegen_types/struct.cr index c9e600c..ae0e09c 100644 --- a/src/codegen_types/struct.cr +++ b/src/codegen_types/struct.cr @@ -46,7 +46,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" fields.each do |field| @@ -58,7 +58,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" fields.each do |field| diff --git a/src/codegen_types/uint.cr b/src/codegen_types/uint.cr index b840446..19760fa 100644 --- a/src/codegen_types/uint.cr +++ b/src/codegen_types/uint.cr @@ -23,7 +23,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -32,7 +32,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/url.cr b/src/codegen_types/url.cr index b6657d5..ff1bfc4 100644 --- a/src/codegen_types/url.cr +++ b/src/codegen_types/url.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/uuid.cr b/src/codegen_types/uuid.cr index 754bfe6..c092c6e 100644 --- a/src/codegen_types/uuid.cr +++ b/src/codegen_types/uuid.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/xml.cr b/src/codegen_types/xml.cr index a6cf529..a445bc2 100644 --- a/src/codegen_types/xml.cr +++ b/src/codegen_types/xml.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end From 2bf6766dcb30c866b33aa4b2570183c2254d103c Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 9 Feb 2018 16:03:18 -0300 Subject: [PATCH 485/625] fix build --- src/codegen_types/array.cr | 4 ++-- src/codegen_types/base64.cr | 4 ++-- src/codegen_types/bool.cr | 4 ++-- src/codegen_types/bytes.cr | 4 ++-- src/codegen_types/cep.cr | 4 ++-- src/codegen_types/cnpj.cr | 4 ++-- src/codegen_types/cpf.cr | 4 ++-- src/codegen_types/date.cr | 4 ++-- src/codegen_types/datetime.cr | 4 ++-- src/codegen_types/email.cr | 4 ++-- src/codegen_types/enum.cr | 4 ++-- src/codegen_types/float.cr | 4 ++-- src/codegen_types/hex.cr | 4 ++-- src/codegen_types/int.cr | 4 ++-- src/codegen_types/latlng.cr | 2 +- src/codegen_types/money.cr | 4 ++-- src/codegen_types/phone.cr | 4 ++-- src/codegen_types/safehtml.cr | 4 ++-- src/codegen_types/string.cr | 4 ++-- src/codegen_types/struct.cr | 4 ++-- src/codegen_types/uint.cr | 4 ++-- src/codegen_types/url.cr | 4 ++-- src/codegen_types/uuid.cr | 4 ++-- src/codegen_types/xml.cr | 4 ++-- 24 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr index 76c23dc..06cff87 100644 --- a/src/codegen_types/array.cr +++ b/src/codegen_types/array.cr @@ -35,7 +35,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Array)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "} else {\n" i = random_var @@ -49,7 +49,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Array)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "} else {\n" i = random_var diff --git a/src/codegen_types/base64.cr b/src/codegen_types/base64.cr index 99d6b95..dd6e8a6 100644 --- a/src/codegen_types/base64.cr +++ b/src/codegen_types/base64.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/bool.cr b/src/codegen_types/bool.cr index 5b88f4d..8dcdade 100644 --- a/src/codegen_types/bool.cr +++ b/src/codegen_types/bool.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} !== true && #{expr} !== false) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} !== true && #{expr} !== false) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/bytes.cr b/src/codegen_types/bytes.cr index b659da8..f5532db 100644 --- a/src/codegen_types/bytes.cr +++ b/src/codegen_types/bytes.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| # io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[A-Za-z0-9+\/]{4}\\n?)*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)$/)) {\n" - # io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + # io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" # io << " typeCheckerError(err, ctx);\n" # io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Buffer)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/cep.cr b/src/codegen_types/cep.cr index 27402f8..a6d68e1 100644 --- a/src/codegen_types/cep.cr +++ b/src/codegen_types/cep.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 8) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/cnpj.cr b/src/codegen_types/cnpj.cr index 7406fc8..3fa6ad3 100644 --- a/src/codegen_types/cnpj.cr +++ b/src/codegen_types/cnpj.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 14) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/cpf.cr b/src/codegen_types/cpf.cr index a008b47..b6b3051 100644 --- a/src/codegen_types/cpf.cr +++ b/src/codegen_types/cpf.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9]/g, \"\").length !== 11) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index fa72dc7..a6c8eb6 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -25,7 +25,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -34,7 +34,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index ca9e7d3..a1de323 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/email.cr b/src/codegen_types/email.cr index 1a7074e..6bb7b41 100644 --- a/src/codegen_types/email.cr +++ b/src/codegen_types/email.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/enum.cr b/src/codegen_types/enum.cr index ef405ee..4a2b82a 100644 --- a/src/codegen_types/enum.cr +++ b/src/codegen_types/enum.cr @@ -33,7 +33,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -42,7 +42,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{values.inspect}.includes(#{expr})) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/float.cr b/src/codegen_types/float.cr index ddf9c22..32aacf5 100644 --- a/src/codegen_types/float.cr +++ b/src/codegen_types/float.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/hex.cr b/src/codegen_types/hex.cr index 86fdcc2..050f41f 100644 --- a/src/codegen_types/hex.cr +++ b/src/codegen_types/hex.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^([0-9a-f]{2})*$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/int.cr b/src/codegen_types/int.cr index f498567..4a5464a 100644 --- a/src/codegen_types/int.cr +++ b/src/codegen_types/int.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr}) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/latlng.cr b/src/codegen_types/latlng.cr index 58f27a0..22a346c 100644 --- a/src/codegen_types/latlng.cr +++ b/src/codegen_types/latlng.cr @@ -23,7 +23,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"object\" || typeof #{expr}.lat !== \"number\" || typeof #{expr}.lng !== \"number\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/money.cr b/src/codegen_types/money.cr index 9c8ede7..6fcb8f6 100644 --- a/src/codegen_types/money.cr +++ b/src/codegen_types/money.cr @@ -23,7 +23,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -32,7 +32,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/phone.cr b/src/codegen_types/phone.cr index 8748773..1f2a05b 100644 --- a/src/codegen_types/phone.cr +++ b/src/codegen_types/phone.cr @@ -23,7 +23,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -32,7 +32,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || #{expr}.replace(/[^0-9+]/g, \"\").length < 5 || #{expr}[0] !== \"+\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/safehtml.cr b/src/codegen_types/safehtml.cr index 4b8176f..429aa49 100644 --- a/src/codegen_types/safehtml.cr +++ b/src/codegen_types/safehtml.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/string.cr b/src/codegen_types/string.cr index 0c71789..a99b193 100644 --- a/src/codegen_types/string.cr +++ b/src/codegen_types/string.cr @@ -23,7 +23,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -32,7 +32,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/struct.cr b/src/codegen_types/struct.cr index ae0e09c..4e91e67 100644 --- a/src/codegen_types/struct.cr +++ b/src/codegen_types/struct.cr @@ -46,7 +46,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" fields.each do |field| @@ -58,7 +58,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" fields.each do |field| diff --git a/src/codegen_types/uint.cr b/src/codegen_types/uint.cr index 19760fa..4a7993f 100644 --- a/src/codegen_types/uint.cr +++ b/src/codegen_types/uint.cr @@ -23,7 +23,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -32,7 +32,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"number\" || (#{expr} | 0) !== #{expr} || #{expr} < 0) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/url.cr b/src/codegen_types/url.cr index ff1bfc4..7d9bf64 100644 --- a/src/codegen_types/url.cr +++ b/src/codegen_types/url.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/uuid.cr b/src/codegen_types/uuid.cr index c092c6e..a0790ef 100644 --- a/src/codegen_types/uuid.cr +++ b/src/codegen_types/uuid.cr @@ -22,7 +22,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -31,7 +31,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)) {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end diff --git a/src/codegen_types/xml.cr b/src/codegen_types/xml.cr index a445bc2..7e2743a 100644 --- a/src/codegen_types/xml.cr +++ b/src/codegen_types/xml.cr @@ -21,7 +21,7 @@ module AST def typescript_check_encoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\") {\n" - io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{class.name}, got '\" + #{expr} + \"'\");\n" + io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" end From 9a6c092434268ddbf782ef0400af0407ca5b4dd4 Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Sun, 11 Feb 2018 15:09:37 -0300 Subject: [PATCH 486/625] Adding description and todos --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..151eaec --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# sdkgen + +The sdkgen is a tool that aims on solving client-server communication and data layout sharing between server, web, android and ios using a description language also called sdkgen. + + +## TODO + +- [ ] Improve README +- [ ] Create and host documentation page +- [ ] Make it database neutral From 3994c6fad2d4915f27de49e5a939a78cb26d0976 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 12 Feb 2018 09:08:02 -0300 Subject: [PATCH 487/625] Create CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..dde5728 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at contact@cubos.io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ From 2207b8c58964704273a5189ecac183ae63046dd8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 12 Feb 2018 09:11:09 -0300 Subject: [PATCH 488/625] MIT License --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8f36511 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Cubos + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From c42e58a97e502a54c0464d192f1881db0c874c46 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 7 Mar 2018 14:21:48 -0300 Subject: [PATCH 489/625] Add initial travis ci --- .travis.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..debf548 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +sudo: required + +services: + - docker + +script: + - docker build -t cubos/sdkgen . + +deploy: + provider: script + script: + - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; + - docker push cubos/sdkgen + on: + branch: master From 9b65373c2e52372b4c232437d052211c8b746eec Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 7 Mar 2018 14:31:05 -0300 Subject: [PATCH 490/625] Travis: skip_cleanup: true --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index debf548..1a64c91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ script: deploy: provider: script + skip_cleanup: true script: - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; - docker push cubos/sdkgen From 516da7f71f693ce2e41457e133b6b0f1b31e8679 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 7 Mar 2018 14:31:48 -0300 Subject: [PATCH 491/625] Add Travis badge --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 151eaec..db00ff6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# sdkgen +# sdkgen [![Build Status](https://travis-ci.org/cubos/sdkgen.svg?branch=master)](https://travis-ci.org/cubos/sdkgen) The sdkgen is a tool that aims on solving client-server communication and data layout sharing between server, web, android and ios using a description language also called sdkgen. - + ## TODO From 28baf870ea37ea1c1a061735851534b243791dd2 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 7 Mar 2018 14:37:34 -0300 Subject: [PATCH 492/625] Travis: one liner deploy --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1a64c91..ef3d24f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,6 @@ script: deploy: provider: script skip_cleanup: true - script: - - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; - - docker push cubos/sdkgen + script: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" && docker push cubos/sdkgen on: branch: master From cd83ea5c1a95a7b16a74ddae3e98afc0909ff3f3 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 7 Mar 2018 14:59:44 -0300 Subject: [PATCH 493/625] Rename executable to "sdkgen" --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 77ed13a..f97dcae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,5 +5,5 @@ WORKDIR /tmp RUN crystal tool format --check RUN crystal spec WORKDIR /root -RUN crystal build /tmp/main.cr -o sdkgen2 -RUN cp sdkgen2 /usr/bin \ No newline at end of file +RUN crystal build /tmp/main.cr -o sdkgen +RUN cp sdkgen /usr/bin From 2691a4f4dae27bc10d953f1798fc6231885ffdc0 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 9 Mar 2018 07:56:59 -0300 Subject: [PATCH 494/625] Create hooks for the server. Isolate database specific parts there. --- src/target/typescript_nodeserver.cr | 202 ++++++++++++++-------------- 1 file changed, 104 insertions(+), 98 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 2924286..68cab7d 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -1,3 +1,4 @@ +require "json" require "./target" class TypeScriptServerTarget < Target @@ -26,9 +27,6 @@ END end} #{String.build do |io| if @ast.options.useRethink - io << <<-END -import r from "../rethinkdb"; -END else io << <<-END @@ -186,6 +184,18 @@ function sleep(ms: number) { export let server: http.Server; +export const hook: { + onHealthCheck: () => Promise + onDevice: (id: string, deviceInfo: any) => Promise + onReceiveCall: (call: DBApiCall) => Promise + afterProcessCall: (call: DBApiCall) => Promise +} = { + onHealthCheck: async () => true, + onDevice: async () => {}, + onReceiveCall: async () => {}, + afterProcessCall: async () => {} +}; + export function start(port: number = 8000) { if (server) return; server = http.createServer((req, res) => { @@ -233,23 +243,16 @@ export function start(port: number = 8000) { break; } case "GET": { -#{String.build do |io| - if @ast.options.useRethink - io << <<-END - r.expr(`{\"ok\": true}`).then(result => { - res.writeHead(200); - res.write(result); + hook.onHealthCheck().then(ok => { + res.writeHead(ok ? 200 : 500); + res.write(JSON.stringify({ok})); + res.end(); + }, error => { + console.error(error); + res.writeHead(500); + res.write(JSON.stringify({ok: false})); res.end(); }); -END - else - io << <<-END - res.writeHead(200); - res.write(`{\"ok\": true}`); - res.end(); -END - end - end} break; } case "POST": { @@ -268,28 +271,10 @@ END const {id, ...deviceInfo} = context.device; -#{String.build do |io| - if @ast.options.useRethink - io << <<-END - if (!context.device.id || await r.table("devices").get(context.device.id).eq(null)) { + if (!context.device.id) context.device.id = crypto.randomBytes(20).toString("hex"); - await r.table("devices").insert({ - id: context.device.id, - date: r.now(), - ...deviceInfo - }); - } else { - r.table("devices").get(context.device.id).update(deviceInfo).run(); - } -END - else - io << <<-END - if (!context.device.id) context.device.id = crypto.randomBytes(20).toString("hex"); -END - end - end} - + await hook.onDevice(context.device.id, deviceInfo); const executionId = crypto.randomBytes(20).toString("hex"); @@ -313,79 +298,49 @@ END if (clearForLogging[call.name]) clearForLogging[call.name](call); -#{String.build do |io| - if @ast.options.useRethink - io << <<-END - async function tryLock(): Promise { - const priorCall = await r.table("api_calls").get(call.id); - if (priorCall === null) { - const res = await r.table("api_calls").insert(call); - return res.inserted > 0 ? true : await tryLock(); - } - call = priorCall; - if (!call.running) { - return true; - } - if (call.executionId === executionId) { - return true; - } - return false; - } - - for (let i = 0; i < 1500; ++i) { - if (await tryLock()) break; - await sleep(100); + try { + call = await hook.onReceiveCall(call) || call; + } catch (e) { + call.ok = false; + call.error = { + type: "Fatal", + message: e.message + }; + call.running = false; } -END - end - end} if (call.running) { - if (call.executionId !== executionId) { + try { + const func = fnExec[request.name]; + if (func) { + call.result = await func(context, request.args); + } else { + console.error(JSON.stringify(Object.keys(fnExec))); + throw "Function does not exist: " + request.name; + } + } catch (err) { + console.error(err); call.ok = false; - call.error = { - type: "Fatal", - message: "CallExecutionTimeout: Timeout while waiting for execution somewhere else (is the original container that received this request dead?)" - }; - } else { - try { - const func = fnExec[request.name]; - if (func) { - call.result = await func(context, request.args); - } else { - console.error(JSON.stringify(Object.keys(fnExec))); - throw "Function does not exist: " + request.name; - } - } catch (err) { - console.error(err); - call.ok = false; + if (#{@ast.errors.to_json}.includes(err._type)) { + call.error = { + type: err._type, + message: err._msg + }; + } else { call.error = { type: "Fatal", message: err.toString() }; -#{ident ident ident ident ident ident ident ident ident(String.build do |io| - @ast.errors.each do |error| - io << "if (err._type === #{error.inspect})\n call.error = {type: #{error.inspect}, message: err._msg};\n" - end - end)} - } - call.running = false; - const deltaTime = process.hrtime(startTime); - call.duration = deltaTime[0] + deltaTime[1] * 1e-9; - if (call.error && call.error.type === "Fatal") { - setTimeout(() => captureError(new Error(call.error!.type + ": " + call.error!.message), req, { + setTimeout(() => captureError(err, req, { call }), 1); } } + call.running = false; + const deltaTime = process.hrtime(startTime); + call.duration = deltaTime[0] + deltaTime[1] * 1e-9; -#{String.build do |io| - if @ast.options.useRethink - io << <<-END - r.table("api_calls").get(call.id).update(call).run(); -END - end - end} + await hook.afterProcessCall(call); } const response = { @@ -469,6 +424,57 @@ END end end} +#{String.build do |io| + if @ast.options.useRethink + io << <<-END +import r from "../rethinkdb"; + +hook.onHealthCheck = async () => { + return await r.expr(true); +}; + +hook.onDevice = async (id, deviceInfo) => { + if (await r.table("devices").get(id).eq(null)) { + await r.table("devices").insert({ + id: id, + date: r.now(), + ...deviceInfo + }); + } else { + r.table("devices").get(id).update(deviceInfo).run(); + } +}; + +hook.onReceiveCall = async (call) => { + for (let i = 0; i < 1500; ++i) { + const priorCall = await r.table("api_calls").get(call.id); + if (priorCall === null) { + const res = await r.table("api_calls").insert(call); + if (res.inserted > 0) + return; + else + continue; + } + if (!priorCall.running) { + return priorCall; + } + if (priorCall.executionId === call.executionId) { + return; + } + + await sleep(100); + } + + throw "CallExecutionTimeout: Timeout while waiting for execution somewhere else (is the original container that received this request dead?)"; +}; + +hook.afterProcessCall = async (call) => { + r.table("api_calls").get(call.id).update(call).run(); +}; + +END + end +end} END end From 4c9658f6ab62ffabb8f549cfbbfd49b887a9a62a Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 9 Mar 2018 07:59:27 -0300 Subject: [PATCH 495/625] Fix style --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 68cab7d..0429a4e 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -474,7 +474,7 @@ hook.afterProcessCall = async (call) => { END end -end} + end} END end From 901a8c1be1ab73332d82fa7d846e6be65b3779e8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 9 Mar 2018 19:33:07 -0300 Subject: [PATCH 496/625] Add getApiUrl for android --- src/target/java_android.cr | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index fea0795..16901d4 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -350,6 +350,10 @@ END return Internal.getHttpClient(); } + static public String getApiUrl() { + return Internal.forcedUrl == null ? Internal.baseUrl : Internal.forcedUrl; + } + static public void setApiUrl(String url) { Internal.forcedUrl = url; } From d7daf8bec4e0e3966f09bc3b1c48495c5d66dd86 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 12 Mar 2018 13:36:00 -0300 Subject: [PATCH 497/625] error is not always a Error object --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 0429a4e..16bdb45 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -389,7 +389,7 @@ export function start(port: number = 8000) { captureError = (e, req, extra) => Raven.captureException(e, { req, extra, - fingerprint: [e.message.replace(/[0-9]+/g, "X").replace(/"[^"]*"/g, "X")] + fingerprint: [(e.message || e.toString()).replace(/[0-9]+/g, "X").replace(/"[^"]*"/g, "X")] }); } From d3576b184fe2f3d3c948ef49b7c6c8c82685419d Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Wed, 14 Mar 2018 10:16:26 -0300 Subject: [PATCH 498/625] target java android - call callback when 502 response --- src/target/java_android.cr | 1 + 1 file changed, 1 insertion(+) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index fea0795..c84ea90 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -732,6 +732,7 @@ END if (!shouldReceiveResponse[0]) return; if (response.code() == 502) { Log.e("API", "HTTP " + response.code()); + callback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null); return; } shouldReceiveResponse[0] = false; From b4dc79d3f4a448e2092b00e55b25bf3950474587 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Wed, 14 Mar 2018 10:23:25 -0300 Subject: [PATCH 499/625] fix error message when 502 --- src/target/java_android.cr | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 8e3cd67..7e8cc8d 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -350,10 +350,6 @@ END return Internal.getHttpClient(); } - static public String getApiUrl() { - return Internal.forcedUrl == null ? Internal.baseUrl : Internal.forcedUrl; - } - static public void setApiUrl(String url) { Internal.forcedUrl = url; } @@ -736,7 +732,7 @@ END if (!shouldReceiveResponse[0]) return; if (response.code() == 502) { Log.e("API", "HTTP " + response.code()); - callback.onResult(new Error() {{type = ErrorType.Fatal; message = e.getMessage();}}, null); + callback.onResult(new Error() {{type = ErrorType.Fatal; message = "Erro Fatal (502) - Tente novamente";}}, null); return; } shouldReceiveResponse[0] = false; From 65c4dadf3da535e2a064e9f6ede3dd833b1394da Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 15 Mar 2018 17:03:08 -0300 Subject: [PATCH 500/625] unfix 502 --- src/target/java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 7e8cc8d..9fa7863 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -732,7 +732,7 @@ END if (!shouldReceiveResponse[0]) return; if (response.code() == 502) { Log.e("API", "HTTP " + response.code()); - callback.onResult(new Error() {{type = ErrorType.Fatal; message = "Erro Fatal (502) - Tente novamente";}}, null); + // callback.onResult(new Error() {{type = ErrorType.Fatal; message = "Erro Fatal (502) - Tente novamente";}}, null); return; } shouldReceiveResponse[0] = false; From 1fb8812cc22287e7eb05bb6b7292daae456f9787 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 16 Mar 2018 08:03:24 -0300 Subject: [PATCH 501/625] fix 502 --- src/target/java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 9fa7863..7e8cc8d 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -732,7 +732,7 @@ END if (!shouldReceiveResponse[0]) return; if (response.code() == 502) { Log.e("API", "HTTP " + response.code()); - // callback.onResult(new Error() {{type = ErrorType.Fatal; message = "Erro Fatal (502) - Tente novamente";}}, null); + callback.onResult(new Error() {{type = ErrorType.Fatal; message = "Erro Fatal (502) - Tente novamente";}}, null); return; } shouldReceiveResponse[0] = false; From 747e375c3665ab03ca5f5b9219cd9754870d9d5a Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 16 Mar 2018 12:58:05 -0300 Subject: [PATCH 502/625] Add getApiUrl --- src/target/java_android.cr | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 7e8cc8d..81ed7dd 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -354,6 +354,10 @@ END Internal.forcedUrl = url; } + static public String getApiUrl() { + return Internal.forcedUrl != null ? Internal.forcedUrl : "https://" + Internal.baseUrl + (API.useStaging ? "-staging" : "") + } + private static class Internal { static String forcedUrl = null; static String baseUrl = #{@ast.options.url.inspect}; From 1ab48d2c093afd168bf0e23478e1e8c760a564d3 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Fri, 16 Mar 2018 13:14:48 -0300 Subject: [PATCH 503/625] Missing semicolon --- src/target/java_android.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 81ed7dd..f044b81 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -355,7 +355,7 @@ END } static public String getApiUrl() { - return Internal.forcedUrl != null ? Internal.forcedUrl : "https://" + Internal.baseUrl + (API.useStaging ? "-staging" : "") + return Internal.forcedUrl != null ? Internal.forcedUrl : "https://" + Internal.baseUrl + (API.useStaging ? "-staging" : ""); } private static class Internal { From ca277f1e78be6f5f37c059c49ead78f66bfc6709 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 21 Mar 2018 20:52:18 -0300 Subject: [PATCH 504/625] Fix for e being string --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 16bdb45..9e54fb2 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -304,7 +304,7 @@ export function start(port: number = 8000) { call.ok = false; call.error = { type: "Fatal", - message: e.message + message: e.toString() }; call.running = false; } From 0f7f82ab58aa82dbefb8040f2a8ebb6c852d7ab4 Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Sun, 1 Apr 2018 18:47:19 -0300 Subject: [PATCH 505/625] adding short How to use it section --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index db00ff6..bd58426 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ The sdkgen is a tool that aims on solving client-server communication and data layout sharing between server, web, android and ios using a description language also called sdkgen. +## How to use it + +`crystal run main.cr -- api.sdkgen -o api.ts -t typescript_nodeserver` + ## TODO From 8c8682024c853f54ccb2d7f2192d0736c5413216 Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Mon, 2 Apr 2018 02:29:44 -0300 Subject: [PATCH 506/625] adding typescript_nodeclient --- src/main.cr | 1 + src/target/typescript_nodeclient.cr | 174 ++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100644 src/target/typescript_nodeclient.cr diff --git a/src/main.cr b/src/main.cr index 4a97c49..035f5ba 100644 --- a/src/main.cr +++ b/src/main.cr @@ -3,6 +3,7 @@ require "./semantic/ast_semantic" require "./target/java_android" require "./target/swift_ios" require "./target/typescript_nodeserver" +require "./target/typescript_nodeclient" require "./target/typescript_servertest" require "./target/typescript_web" require "option_parser" diff --git a/src/target/typescript_nodeclient.cr b/src/target/typescript_nodeclient.cr new file mode 100644 index 0000000..ad08231 --- /dev/null +++ b/src/target/typescript_nodeclient.cr @@ -0,0 +1,174 @@ +require "./target" + +class TypeScriptNodeClient < Target + def gen + @io << <<-END +import * as moment from "moment"; +import * as https from "https"; +import { URL } from "url"; + +const baseUrl = #{@ast.options.url.inspect}; +let useStaging = false; + +export function setStaging(use: boolean) { + useStaging = !!use; +} + +END + + @ast.struct_types.each do |t| + @io << t.typescript_definition + @io << "\n\n" + end + + @ast.enum_types.each do |t| + @io << t.typescript_definition + @io << "\n\n" + end + + @ast.operations.each do |op| + args = op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } + @io << "export async function #{op.pretty_name}(#{args.join(", ")}): Promise<#{op.return_type.typescript_native_type}> {\n" + if op.args.size > 0 + @io << " const args = {\n" + op.args.each do |arg| + @io << ident ident "#{arg.name}: #{arg.type.typescript_encode(arg.name)}," + @io << "\n" + end + @io << " };\n" + end + + @io << " " + @io << "const ret = " unless op.return_type.is_a? AST::VoidPrimitiveType + @io << "await makeRequest({name: #{op.pretty_name.inspect}, #{op.args.size > 0 ? "args" : "args: {}"}});\n" + @io << ident "return " + op.return_type.typescript_decode("ret") + ";" + @io << "\n" + @io << "}\n\n" + end + + @io << <<-END +////////////////////////////////////////////////////// + +let fallbackDeviceId: string | null = null; + +function setDeviceId(deviceId: string) { + fallbackDeviceId = deviceId; + try { + localStorage.setItem("deviceId", deviceId); + } catch (e) {} +} + +function getDeviceId() { + try { + return localStorage.getItem("deviceId"); + } catch (e) {} + return fallbackDeviceId; +} + +async function device() { + const device: any = { + type: "node", + }; + const deviceId = getDeviceId(); + if (deviceId) + device.id = deviceId; + return device; +} + +function randomBytesHex(len: number) { + let hex = ""; + for (let i = 0; i < 2 * len; ++i) + hex += "0123456789abcdef"[Math.floor(Math.random()*16)]; + return hex; +} + +export interface ListenerTypes { + fail: (e: Error, name: string, args: any) => void; + fatal: (e: Error, name: string, args: any) => void; + success: (res: string, name: string, args: any) => void; +} + +type HookArray = Array; +export type Listenables = keyof ListenerTypes; +export type ListenersDict = { [k in Listenables]: Array }; + +const listenersDict: ListenersDict = { + fail: [], + fatal: [], + success: [], +}; + +export function addEventListener(listenable: Listenables, hook: ListenerTypes[typeof listenable]) { + const listeners: HookArray = listenersDict[listenable]; + listeners.push(hook); +} + +export function removeEventListener(listenable: Listenables, hook: ListenerTypes[typeof listenable]) { + const listeners: HookArray = listenersDict[listenable]; + listenersDict[listenable] = listeners.filter(h => h !== hook) as any; +} + +async function makeRequest({name, args}: {name: string, args: any}) { + const deviceData = await device(); + const body = { + id: randomBytesHex(8), + device: deviceData, + name: name, + args: args + }; + + const url = new URL("https://" + baseUrl + (useStaging ? "-staging" : "") + "/" + name); + const options = { + hostname: url.hostname, + path: url.pathname, + method: 'POST', + }; + + return new Promise((resolve, reject) => { + const req = https.request(options, (resp) => { + let data = ''; + resp.on('data', (chunk) => { + data += chunk; + }); + resp.on('end', () => { + try { + const response = JSON.parse(data); + + try { + setDeviceId(response.deviceId); + if (response.ok) { + resolve(response.result); + listenersDict["success"].forEach(hook => hook(response.result, name, args)); + } else { + reject(response.error); + listenersDict["fail"].forEach(hook => hook(response.error, name, args)); + } + } catch (e) { + console.error(e); + reject({type: "Fatal", message: e.toString()}); + listenersDict["fatal"].forEach(hook => hook(e, name, args)); + } + } catch (e) { + console.error(e); + reject({type: "BadFormattedResponse", message: `Response couldn't be parsed as JSON (${data}):\\n${e.toString()}`}); + listenersDict["fatal"].forEach(hook => hook(e, name, args)); + } + }); + + }); + + req.on('error', (e) => { + console.error(`problem with request: ${e.message}`); + }); + + // write data to request body + req.write(JSON.stringify(body)); + req.end(); + }); +} + +END + end +end + +Target.register(TypeScriptNodeClient, target_name: "typescript_nodeclient") From 59a6da69d645bbcecd90065497290d1023e6ec7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Mon, 2 Apr 2018 10:09:59 -0300 Subject: [PATCH 507/625] refactor: Remove moment as a depedency from generated packages --- target-node/package.json | 1 - target-node/yarn.lock | 4 ---- target-web/package.json | 1 - target-web/yarn.lock | 4 ---- 4 files changed, 10 deletions(-) diff --git a/target-node/package.json b/target-node/package.json index 3a81f4a..03e153a 100644 --- a/target-node/package.json +++ b/target-node/package.json @@ -6,7 +6,6 @@ "@types/raven": "^2.1.3", "babel-runtime": "^6.26.0", "localtunnel": "^1.8.3", - "moment": "^2.20.1", "raven": "^2.3.0", "request": "^2.83.0" }, diff --git a/target-node/yarn.lock b/target-node/yarn.lock index c7d8f4c..934ffa0 100644 --- a/target-node/yarn.lock +++ b/target-node/yarn.lock @@ -1328,10 +1328,6 @@ minimist@^1.2.0: dependencies: minimist "0.0.8" -moment@^2.20.1: - version "2.20.1" - resolved "https://npm.cubos.io/moment/-/moment-2.20.1.tgz#d6eb1a46cbcc14a2b2f9434112c1ff8907f313fd" - ms@2.0.0: version "2.0.0" resolved "https://npm.cubos.io/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" diff --git a/target-web/package.json b/target-web/package.json index edd9f1d..848c99d 100644 --- a/target-web/package.json +++ b/target-web/package.json @@ -5,7 +5,6 @@ "@types/node": "^8.0.29", "@types/ua-parser-js": "^0.7.32", "babel-runtime": "^6.26.0", - "moment": "^2.17.1", "ua-parser-js": "^0.7.14" }, "main": "api.js", diff --git a/target-web/yarn.lock b/target-web/yarn.lock index 35c6193..54550f7 100644 --- a/target-web/yarn.lock +++ b/target-web/yarn.lock @@ -1233,10 +1233,6 @@ minimist@^1.2.0: dependencies: minimist "0.0.8" -moment@^2.17.1: - version "2.18.1" - resolved "https://npm.cubos.io/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" - ms@2.0.0: version "2.0.0" resolved "https://npm.cubos.io/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" From 7e58a1b8c57600be81f7a7a96cfecd74516d6f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Mon, 2 Apr 2018 10:10:36 -0300 Subject: [PATCH 508/625] feat: Implement date & date time encoding/decoding without moment --- src/codegen_types/date.cr | 4 ++-- src/codegen_types/datetime.cr | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index a6c8eb6..34042ce 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -1,11 +1,11 @@ module AST class DatePrimitiveType def typescript_decode(expr) - "moment(#{expr}, \"YYYY-MM-DD\").toDate()" + "new Date(#{expr})" end def typescript_encode(expr) - "moment(#{expr}).format(\"YYYY-MM-DD\")" + "#{expr}.toISOString().split('T')[0]" end def typescript_native_type diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index a1de323..2d55129 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -1,11 +1,11 @@ module AST class DateTimePrimitiveType def typescript_decode(expr) - "moment.utc(#{expr}, \"YYYY-MM-DDTHH:mm:ss.SSS\").toDate()" + "new Date(#{expr})" end def typescript_encode(expr) - "moment.utc(#{expr}).format(\"YYYY-MM-DDTHH:mm:ss.SSS\")" + "#{expr}.toISOString()" end def typescript_native_type From 87973f001f7f1970e581c190a959b8ac779ddd96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Mon, 2 Apr 2018 10:11:44 -0300 Subject: [PATCH 509/625] refactor: Stop importing moment --- src/target/typescript_nodeclient.cr | 1 - src/target/typescript_nodeserver.cr | 2 -- src/target/typescript_servertest.cr | 1 - src/target/typescript_web.cr | 1 - 4 files changed, 5 deletions(-) diff --git a/src/target/typescript_nodeclient.cr b/src/target/typescript_nodeclient.cr index ad08231..6cd8160 100644 --- a/src/target/typescript_nodeclient.cr +++ b/src/target/typescript_nodeclient.cr @@ -3,7 +3,6 @@ require "./target" class TypeScriptNodeClient < Target def gen @io << <<-END -import * as moment from "moment"; import * as https from "https"; import { URL } from "url"; diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 9e54fb2..77dd677 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -11,7 +11,6 @@ import http from "http"; import crypto from "crypto"; import os from "os"; import url from "url"; -import moment from "moment"; import Raven from "raven"; END else @@ -20,7 +19,6 @@ import * as http from "http"; import * as crypto from "crypto"; import * as os from "os"; import * as url from "url"; -const moment = require("moment"); const Raven = require("raven"); END end diff --git a/src/target/typescript_servertest.cr b/src/target/typescript_servertest.cr index 904cadd..a916e75 100644 --- a/src/target/typescript_servertest.cr +++ b/src/target/typescript_servertest.cr @@ -4,7 +4,6 @@ class TypeScriptServerTestTarget < Target def gen @io << <<-END import http from "http"; -import moment from "moment"; export interface Context { call: DBApiCall; diff --git a/src/target/typescript_web.cr b/src/target/typescript_web.cr index a12fa29..cb0264e 100644 --- a/src/target/typescript_web.cr +++ b/src/target/typescript_web.cr @@ -3,7 +3,6 @@ require "./target" class TypeScriptWebTarget < Target def gen @io << <<-END -import * as moment from "moment"; import {UAParser} from "ua-parser-js"; const baseUrl = #{@ast.options.url.inspect}; From a70aee89111e46109bfb9425a716b50ee7ea0785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Mon, 2 Apr 2018 10:13:02 -0300 Subject: [PATCH 510/625] refactor: Reimplement server-side date logging without moment --- src/target/typescript_nodeserver.cr | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 77dd677..466edd7 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -74,6 +74,9 @@ function typeCheckerError(e: Error, ctx: Context) { #{@ast.options.strict ? "throw e;" : "setTimeout(() => captureError(e, ctx.req, ctx.call), 1000);"} } +function toDateTimeString(date: Date) { + return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`; +} END @@ -222,13 +225,13 @@ export function start(port: number = 8000) { const ip = req.headers["x-real-ip"] as string || ""; const signature = req.method! + url.parse(req.url || "").pathname; if (httpHandlers[signature]) { - console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${signature}`); + console.log(`${toDateTimeString(new Date())} http ${signature}`); httpHandlers[signature](body, res, req); return; } for (let target in httpHandlers) { if (("prefix " + signature).startsWith(target)) { - console.log(`${moment().format("YYYY-MM-DD HH:mm:ss")} http ${target}`); + console.log(`${toDateTimeString(new Date())} http ${target}`); httpHandlers[target](body, res, req); return; } @@ -359,7 +362,7 @@ export function start(port: number = 8000) { res.end(); console.log( - `${moment().format("YYYY-MM-DD HH:mm:ss")} ` + + `${toDateTimeString(new Date())} ` + `${call.id} [${call.duration.toFixed(6)}s] ` + `${call.name}() -> ${call.ok ? "OK" : call.error ? call.error.type : "???"}` ); From 7b3507c2f2a26dd37af9c14073a430d413186a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Tue, 3 Apr 2018 11:10:36 -0300 Subject: [PATCH 511/625] fix: Handle timezone on DateTime encoding & decoding --- src/codegen_types/datetime.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index 2d55129..e698d75 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -1,11 +1,11 @@ module AST class DateTimePrimitiveType def typescript_decode(expr) - "new Date(#{expr})" + "new Date(#{expr} + 'Z')" end def typescript_encode(expr) - "#{expr}.toISOString()" + "#{expr}.toISOString().replace('Z', '')" end def typescript_native_type From 5773da4ad13413cf3af248d26c78d114ab39fc36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Fri, 6 Apr 2018 15:41:27 -0300 Subject: [PATCH 512/625] fix: Better formatting for date logs --- src/target/typescript_nodeserver.cr | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 466edd7..7490b55 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -74,8 +74,24 @@ function typeCheckerError(e: Error, ctx: Context) { #{@ast.options.strict ? "throw e;" : "setTimeout(() => captureError(e, ctx.req, ctx.call), 1000);"} } +function padNumber(value: number, length: number) { + return value.toString().padStart(length, "0"); +} + function toDateTimeString(date: Date) { - return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`; + return `${ + padNumber(date.getFullYear(), 4) + }-${ + padNumber(date.getMonth(), 2) + }-${ + padNumber(date.getDate(), 2) + } ${ + padNumber(date.getHours(), 2) + }:${ + padNumber(date.getMinutes(), 2) + }:${ + padNumber(date.getSeconds(), 2) + }`; } END From 078b1ebbe4ffaf15d02c533c451593a0b9fad2dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Magalh=C3=A3es?= Date: Fri, 6 Apr 2018 20:17:11 -0300 Subject: [PATCH 513/625] fix: Date.getMonth is 0-based, so add 1 for logging --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 7490b55..1b7d38a 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -82,7 +82,7 @@ function toDateTimeString(date: Date) { return `${ padNumber(date.getFullYear(), 4) }-${ - padNumber(date.getMonth(), 2) + padNumber(date.getMonth() + 1, 2) }-${ padNumber(date.getDate(), 2) } ${ From bdc139e59f57205bb7623f5c625ce126ba9155bb Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 9 Apr 2018 12:51:43 -0300 Subject: [PATCH 514/625] Reduce connectTimeout for android --- src/target/java_android.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index f044b81..974a719 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -385,7 +385,7 @@ END } static void createHttpClient() { - connectionPool = new ConnectionPool(100, 5, TimeUnit.MINUTES); + connectionPool = new ConnectionPool(100, 45, TimeUnit.SECONDS); TrustManagerFactory trustManagerFactory; try { @@ -418,7 +418,7 @@ END .connectionPool(connectionPool) .dispatcher(dispatcher) .sslSocketFactory(sslSocketFactory, trustManager) - .connectTimeout(5, TimeUnit.MINUTES); + .connectTimeout(45, TimeUnit.SECONDS); if (interceptor != null) builder.addNetworkInterceptor(interceptor); From b763fa712c0f10b8f1ac77469cc5c6139876bf8f Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Tue, 17 Apr 2018 15:26:19 -0300 Subject: [PATCH 515/625] adding setBaseUrl method to web target --- src/target/typescript_web.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/target/typescript_web.cr b/src/target/typescript_web.cr index cb0264e..34757d9 100644 --- a/src/target/typescript_web.cr +++ b/src/target/typescript_web.cr @@ -5,13 +5,17 @@ class TypeScriptWebTarget < Target @io << <<-END import {UAParser} from "ua-parser-js"; -const baseUrl = #{@ast.options.url.inspect}; +let baseUrl = #{@ast.options.url.inspect}; let useStaging = false; export function setStaging(use: boolean) { useStaging = !!use; } +export function setBaseUrl(url: string) { + baseUrl = url; +} + END @ast.struct_types.each do |t| From acef80719ef877142cfc7c8d07f552f4e7971c5b Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Tue, 17 Apr 2018 15:26:56 -0300 Subject: [PATCH 516/625] adding setBaseUrl to nodeclient target --- src/target/typescript_nodeclient.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/target/typescript_nodeclient.cr b/src/target/typescript_nodeclient.cr index 6cd8160..b6e4546 100644 --- a/src/target/typescript_nodeclient.cr +++ b/src/target/typescript_nodeclient.cr @@ -6,13 +6,17 @@ class TypeScriptNodeClient < Target import * as https from "https"; import { URL } from "url"; -const baseUrl = #{@ast.options.url.inspect}; +let baseUrl = #{@ast.options.url.inspect}; let useStaging = false; export function setStaging(use: boolean) { useStaging = !!use; } +export function setBaseUrl(url: string) { + baseUrl = url; +} + END @ast.struct_types.each do |t| From eca82a0ff759755580cc8b7641238d466aac4256 Mon Sep 17 00:00:00 2001 From: Tironi Date: Mon, 30 Apr 2018 18:03:35 -0300 Subject: [PATCH 517/625] added .copy property for structures --- src/target/swift.cr | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/target/swift.cr b/src/target/swift.cr index 82b8256..4d645e7 100644 --- a/src/target/swift.cr +++ b/src/target/swift.cr @@ -33,14 +33,41 @@ abstract class SwiftTarget < Target native_type ref.type end + def generate_property_copy(t : AST::Type, path : String) + case t + when AST::StringPrimitiveType ; path + when AST::IntPrimitiveType ; path + when AST::UIntPrimitiveType ; path + when AST::FloatPrimitiveType ; path + when AST::DatePrimitiveType ; path + when AST::DateTimePrimitiveType; path + when AST::BoolPrimitiveType ; path + when AST::BytesPrimitiveType ; path + when AST::ArrayType ; "#{path}.map { #{generate_property_copy(t.base, "$0")} }" + when AST::EnumType ; "#{native_type(t)}(rawValue: #{path}.rawValue)" + when AST::StructType ; "#{path}.copy" + when AST::OptionalType ; "#{path} != nil ? #{generate_property_copy(t.base, path + "!")} : nil" + when AST::TypeReference ; generate_property_copy(t.type, path) + else + raise "BUG! Should handle primitive #{t.class}" + end + end + + def generate_struct_type(t) String.build do |io| io << "class #{t.name} {\n" t.fields.each do |field| io << ident "var #{field.name}: #{native_type field.type}\n" end + io << ident "\nvar copy: #{t.name} {\n" + io << ident ident "return #{t.name}(\n" + io << ident ident ident t.fields.map { |field| "#{field.name}: #{generate_property_copy(field.type, field.name)}"}.join(",\n") + io << ident ident "\n)\n" + io << ident "}\n" io << ident <<-END + init() { END From 5ddeadab62964032030b4c3e8004ba03a0a326d4 Mon Sep 17 00:00:00 2001 From: Tironi Date: Tue, 1 May 2018 10:49:53 -0300 Subject: [PATCH 518/625] unsafe unwrap enums when generating copy --- src/target/swift.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/swift.cr b/src/target/swift.cr index 4d645e7..d57cce6 100644 --- a/src/target/swift.cr +++ b/src/target/swift.cr @@ -44,7 +44,7 @@ abstract class SwiftTarget < Target when AST::BoolPrimitiveType ; path when AST::BytesPrimitiveType ; path when AST::ArrayType ; "#{path}.map { #{generate_property_copy(t.base, "$0")} }" - when AST::EnumType ; "#{native_type(t)}(rawValue: #{path}.rawValue)" + when AST::EnumType ; "#{native_type(t)}(rawValue: #{path}.rawValue)!" when AST::StructType ; "#{path}.copy" when AST::OptionalType ; "#{path} != nil ? #{generate_property_copy(t.base, path + "!")} : nil" when AST::TypeReference ; generate_property_copy(t.type, path) From 245fce339f3701969a8090015bfabb91ca06d760 Mon Sep 17 00:00:00 2001 From: Tironi Date: Tue, 1 May 2018 11:14:05 -0300 Subject: [PATCH 519/625] added enum extension to make enum iterable --- src/target/swift.cr | 32 +++++++++++++++++++++++++++++++- src/target/swift_ios.cr | 30 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/target/swift.cr b/src/target/swift.cr index d57cce6..6c910db 100644 --- a/src/target/swift.cr +++ b/src/target/swift.cr @@ -44,7 +44,7 @@ abstract class SwiftTarget < Target when AST::BoolPrimitiveType ; path when AST::BytesPrimitiveType ; path when AST::ArrayType ; "#{path}.map { #{generate_property_copy(t.base, "$0")} }" - when AST::EnumType ; "#{native_type(t)}(rawValue: #{path}.rawValue)!" + when AST::EnumType ; "#{path}.copy" when AST::StructType ; "#{path}.copy" when AST::OptionalType ; "#{path} != nil ? #{generate_property_copy(t.base, path + "!")} : nil" when AST::TypeReference ; generate_property_copy(t.type, path) @@ -122,6 +122,36 @@ END t.values.each do |value| io << ident "case #{value} = #{value.inspect}\n" end + io << ident "\nvar copy: #{t.name} {\n" + io << ident ident "return #{t.name}(rawValue: self.rawValue)!\n" + io << ident "}\n" + io << "}" + end + end + + def generate_enum_type_extension(t) + String.build do |io| + io << "extension #{t.name}: EnumCollection {\n" + io << ident "func displayableValue() -> String {\n" + io << ident ident "return self.rawValue\n" + io << ident "}\n" + + io << ident "\nstatic func valuesDictionary() -> [String : #{t.name}] {\n" + io << ident ident "var dictionary: [String : #{t.name}] = [:]\n" + io << ident ident "for enumCase in self.allValues {\n" + io << ident ident ident "dictionary[enumCase.displayableValue()] = enumCase\n" + io << ident ident "}\n" + io << ident ident "return dictionary\n" + io << ident "}\n" + + io << ident "\nstatic func allDisplayableValues() -> [String] {\n" + io << ident ident "var displayableValues: [String] = []\n" + io << ident ident "for value in self.allValues {\n" + io << ident ident ident "displayableValues.append(value.displayableValue())\n" + io << ident ident "}\n" + io << ident ident "return displayableValues.sorted()\n" + io << ident "}\n" + io << "}" end end diff --git a/src/target/swift_ios.cr b/src/target/swift_ios.cr index 0d4754a..7824f80 100644 --- a/src/target/swift_ios.cr +++ b/src/target/swift_ios.cr @@ -22,6 +22,8 @@ END @ast.enum_types.each do |t| @io << ident generate_enum_type(t) @io << "\n\n" + @io << ident generate_enum_type_extension(t) + @io << "\n\n" end @ast.operations.each do |op| @@ -228,6 +230,34 @@ class APIInternal { } } } + +protocol EnumCollection: Hashable { + static var allValues: [Self] { get } +} + +extension EnumCollection { + + static func cases() -> AnySequence { + typealias S = Self + return AnySequence { () -> AnyIterator in + var raw = 0 + return AnyIterator { + let current: Self = withUnsafePointer(to: &raw) { + $0.withMemoryRebound(to: S.self, capacity: 1) { $0.pointee } + } + + guard current.hashValue == raw else { return nil } + raw += 1 + return current + } + } + } + + static var allValues: [Self] { + return Array(self.cases()) + } +} + END end end From 39ac448478c0101d9ae752f7213c12e43d1dce15 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Tue, 1 May 2018 11:57:49 -0300 Subject: [PATCH 520/625] fix email regex --- src/codegen_types/email.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/codegen_types/email.cr b/src/codegen_types/email.cr index 6bb7b41..a569b81 100644 --- a/src/codegen_types/email.cr +++ b/src/codegen_types/email.cr @@ -15,13 +15,13 @@ module AST def typescript_expect(expr) String.build do |io| io << "expect(#{expr}).toBeTypeOf(\"string\");\n" - io << "expect(#{expr}).toMatch(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/);\n" + io << "expect(#{expr}).toMatch(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])$/);\n" end end def typescript_check_encoded(expr, descr) String.build do |io| - io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" @@ -30,7 +30,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || typeof #{expr} !== \"string\" || !#{expr}.match(/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" From 14615465ad8602ea2d94f5680578ae4fe816ea8f Mon Sep 17 00:00:00 2001 From: Tironi Date: Tue, 1 May 2018 14:14:25 -0300 Subject: [PATCH 521/625] added displayableValue variable as overridable for the iOS developer --- src/target/swift.cr | 54 +++++++++++++++++------------------------ src/target/swift_ios.cr | 14 ++++++++--- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/target/swift.cr b/src/target/swift.cr index 6c910db..c49e5eb 100644 --- a/src/target/swift.cr +++ b/src/target/swift.cr @@ -114,44 +114,34 @@ END def generate_enum_type(t) String.build do |io| if t.name == "ErrorType" - io << "enum #{t.name}: String,Error {\n" + io << "enum #{t.name}: String, Error {\n" else - io << "enum #{t.name}: String {\n" + io << "enum #{t.name}: String, EnumCollection {\n" end t.values.each do |value| io << ident "case #{value} = #{value.inspect}\n" end - io << ident "\nvar copy: #{t.name} {\n" - io << ident ident "return #{t.name}(rawValue: self.rawValue)!\n" - io << ident "}\n" - io << "}" - end - end - - def generate_enum_type_extension(t) - String.build do |io| - io << "extension #{t.name}: EnumCollection {\n" - io << ident "func displayableValue() -> String {\n" - io << ident ident "return self.rawValue\n" - io << ident "}\n" - - io << ident "\nstatic func valuesDictionary() -> [String : #{t.name}] {\n" - io << ident ident "var dictionary: [String : #{t.name}] = [:]\n" - io << ident ident "for enumCase in self.allValues {\n" - io << ident ident ident "dictionary[enumCase.displayableValue()] = enumCase\n" - io << ident ident "}\n" - io << ident ident "return dictionary\n" - io << ident "}\n" - - io << ident "\nstatic func allDisplayableValues() -> [String] {\n" - io << ident ident "var displayableValues: [String] = []\n" - io << ident ident "for value in self.allValues {\n" - io << ident ident ident "displayableValues.append(value.displayableValue())\n" - io << ident ident "}\n" - io << ident ident "return displayableValues.sorted()\n" - io << ident "}\n" - + if t.name != "ErrorType" + io << ident "\nvar copy: #{t.name} {\n" + io << ident ident "return #{t.name}(rawValue: self.rawValue)!\n" + io << ident "}\n" + io << ident "\nstatic func valuesDictionary() -> [String: #{t.name}] {\n" + io << ident ident "var dictionary: [String: #{t.name}] = [:]\n" + io << ident ident "for enumCase in self.allValues {\n" + io << ident ident ident "dictionary[enumCase.displayableValue] = enumCase\n" + io << ident ident "}\n" + io << ident ident "return dictionary\n" + io << ident "}\n" + + io << ident "\nstatic func allDisplayableValues() -> [String] {\n" + io << ident ident "var displayableValues: [String] = []\n" + io << ident ident "for enumCase in self.allValues {\n" + io << ident ident ident "displayableValues.append(enumCase.displayableValue)\n" + io << ident ident "}\n" + io << ident ident "return displayableValues.sorted()\n" + io << ident "}\n" + end io << "}" end end diff --git a/src/target/swift_ios.cr b/src/target/swift_ios.cr index 7824f80..7ea69e9 100644 --- a/src/target/swift_ios.cr +++ b/src/target/swift_ios.cr @@ -22,8 +22,6 @@ END @ast.enum_types.each do |t| @io << ident generate_enum_type(t) @io << "\n\n" - @io << ident generate_enum_type_extension(t) - @io << "\n\n" end @ast.operations.each do |op| @@ -231,10 +229,20 @@ class APIInternal { } } -protocol EnumCollection: Hashable { +protocol EnumCollection: Hashable, EnumDisplayableValue { static var allValues: [Self] { get } } +protocol EnumDisplayableValue: RawRepresentable { + var displayableValue: String { get } +} + +extension EnumDisplayableValue where RawValue == String { + var displayableValue: String { + return self.rawValue + } +} + extension EnumCollection { static func cases() -> AnySequence { From e3d23bedfc9fcee2ccd53122397059de0cd8eaca Mon Sep 17 00:00:00 2001 From: Tironi Date: Wed, 2 May 2018 19:56:50 -0300 Subject: [PATCH 522/625] added variable for every spread type --- src/target/swift.cr | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/target/swift.cr b/src/target/swift.cr index c49e5eb..bac052a 100644 --- a/src/target/swift.cr +++ b/src/target/swift.cr @@ -53,7 +53,6 @@ abstract class SwiftTarget < Target end end - def generate_struct_type(t) String.build do |io| io << "class #{t.name} {\n" @@ -62,9 +61,16 @@ abstract class SwiftTarget < Target end io << ident "\nvar copy: #{t.name} {\n" io << ident ident "return #{t.name}(\n" - io << ident ident ident t.fields.map { |field| "#{field.name}: #{generate_property_copy(field.type, field.name)}"}.join(",\n") + io << ident ident ident t.fields.map { |field| "#{field.name}: #{generate_property_copy(field.type, field.name)}" }.join(",\n") io << ident ident "\n)\n" io << ident "}\n" + t.spreads.map(&.type.as(AST::StructType)).map { |spread| + io << ident "\nvar #{spread.name.split("").map_with_index { |char, i| i == 0 ? char.downcase : char }.join("")}: #{spread.name} {\n" + io << ident ident "return #{spread.name}(\n" + spread.fields.map { |field| io << ident ident ident "#{field.name}: #{field.name}\n" } + io << ident ident ")\n" + io << ident "}\n" + } io << ident <<-END From b74edb840bb22367e935f796eb46bb777b7583f6 Mon Sep 17 00:00:00 2001 From: Tironi Date: Thu, 3 May 2018 09:16:45 -0300 Subject: [PATCH 523/625] added missing comma in spreads initialization --- src/target/swift.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/swift.cr b/src/target/swift.cr index bac052a..e46a537 100644 --- a/src/target/swift.cr +++ b/src/target/swift.cr @@ -67,8 +67,8 @@ abstract class SwiftTarget < Target t.spreads.map(&.type.as(AST::StructType)).map { |spread| io << ident "\nvar #{spread.name.split("").map_with_index { |char, i| i == 0 ? char.downcase : char }.join("")}: #{spread.name} {\n" io << ident ident "return #{spread.name}(\n" - spread.fields.map { |field| io << ident ident ident "#{field.name}: #{field.name}\n" } - io << ident ident ")\n" + io << ident ident ident spread.fields.map { |field| "#{field.name}: #{field.name}" }.join(",\n") + io << ident ident "\n)\n" io << ident "}\n" } io << ident <<-END From 997c698343b617a1ffc717ed0df740bd44d5216e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 7 May 2018 15:55:39 -0300 Subject: [PATCH 524/625] Modify nodeclient to expose a client --- src/target/typescript_nodeclient.cr | 211 +++++++++++----------------- 1 file changed, 81 insertions(+), 130 deletions(-) diff --git a/src/target/typescript_nodeclient.cr b/src/target/typescript_nodeclient.cr index b6e4546..eabe1fd 100644 --- a/src/target/typescript_nodeclient.cr +++ b/src/target/typescript_nodeclient.cr @@ -6,17 +6,6 @@ class TypeScriptNodeClient < Target import * as https from "https"; import { URL } from "url"; -let baseUrl = #{@ast.options.url.inspect}; -let useStaging = false; - -export function setStaging(use: boolean) { - useStaging = !!use; -} - -export function setBaseUrl(url: string) { - baseUrl = url; -} - END @ast.struct_types.each do |t| @@ -29,145 +18,107 @@ END @io << "\n\n" end + @io << <<-END +export class ApiClient { + useStaging = false; + deviceId: string | null = null; + + constructor(private baseUrl = #{("https://" + @ast.options.url).inspect}) {} + + +END + @ast.operations.each do |op| args = op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } - @io << "export async function #{op.pretty_name}(#{args.join(", ")}): Promise<#{op.return_type.typescript_native_type}> {\n" + @io << " async #{op.pretty_name}(#{args.join(", ")}): Promise<#{op.return_type.typescript_native_type}> {\n" if op.args.size > 0 - @io << " const args = {\n" + @io << " const args = {\n" op.args.each do |arg| - @io << ident ident "#{arg.name}: #{arg.type.typescript_encode(arg.name)}," + @io << " #{arg.name}: #{arg.type.typescript_encode(arg.name)}," @io << "\n" end - @io << " };\n" + @io << " };\n" end - @io << " " + @io << " " @io << "const ret = " unless op.return_type.is_a? AST::VoidPrimitiveType - @io << "await makeRequest({name: #{op.pretty_name.inspect}, #{op.args.size > 0 ? "args" : "args: {}"}});\n" - @io << ident "return " + op.return_type.typescript_decode("ret") + ";" - @io << "\n" - @io << "}\n\n" + @io << "await this.makeRequest({name: #{op.pretty_name.inspect}, #{op.args.size > 0 ? "args" : "args: {}"}});\n" + @io << " return " + op.return_type.typescript_decode("ret") + ";\n" unless op.return_type.is_a? AST::VoidPrimitiveType + @io << " }\n\n" end @io << <<-END -////////////////////////////////////////////////////// - -let fallbackDeviceId: string | null = null; - -function setDeviceId(deviceId: string) { - fallbackDeviceId = deviceId; - try { - localStorage.setItem("deviceId", deviceId); - } catch (e) {} -} - -function getDeviceId() { - try { - return localStorage.getItem("deviceId"); - } catch (e) {} - return fallbackDeviceId; -} - -async function device() { - const device: any = { - type: "node", - }; - const deviceId = getDeviceId(); - if (deviceId) - device.id = deviceId; - return device; -} - -function randomBytesHex(len: number) { - let hex = ""; - for (let i = 0; i < 2 * len; ++i) - hex += "0123456789abcdef"[Math.floor(Math.random()*16)]; - return hex; -} - -export interface ListenerTypes { - fail: (e: Error, name: string, args: any) => void; - fatal: (e: Error, name: string, args: any) => void; - success: (res: string, name: string, args: any) => void; -} - -type HookArray = Array; -export type Listenables = keyof ListenerTypes; -export type ListenersDict = { [k in Listenables]: Array }; - -const listenersDict: ListenersDict = { - fail: [], - fatal: [], - success: [], -}; - -export function addEventListener(listenable: Listenables, hook: ListenerTypes[typeof listenable]) { - const listeners: HookArray = listenersDict[listenable]; - listeners.push(hook); -} - -export function removeEventListener(listenable: Listenables, hook: ListenerTypes[typeof listenable]) { - const listeners: HookArray = listenersDict[listenable]; - listenersDict[listenable] = listeners.filter(h => h !== hook) as any; -} - -async function makeRequest({name, args}: {name: string, args: any}) { - const deviceData = await device(); - const body = { - id: randomBytesHex(8), - device: deviceData, - name: name, - args: args - }; - - const url = new URL("https://" + baseUrl + (useStaging ? "-staging" : "") + "/" + name); - const options = { - hostname: url.hostname, - path: url.pathname, - method: 'POST', - }; - - return new Promise((resolve, reject) => { - const req = https.request(options, (resp) => { - let data = ''; - resp.on('data', (chunk) => { - data += chunk; - }); - resp.on('end', () => { - try { - const response = JSON.parse(data); - + private device() { + const device: any = { + type: "node", + }; + if (this.deviceId) + device.id = this.deviceId; + return device; + } + + private randomBytesHex(len: number) { + let hex = ""; + for (let i = 0; i < 2 * len; ++i) + hex += "0123456789abcdef"[Math.floor(Math.random() * 16)]; + return hex; + } + + private async makeRequest({name, args}: {name: string, args: any}) { + const deviceData = this.device(); + const body = { + id: this.randomBytesHex(8), + device: deviceData, + name: name, + args: args + }; + + const url = new URL(this.baseUrl + (this.useStaging ? "-staging" : "") + "/" + name); + const options = { + hostname: url.hostname, + path: url.pathname, + method: "POST", + }; + + return new Promise((resolve, reject) => { + const req = https.request(options, resp => { + let data = ""; + resp.on("data", (chunk) => { + data += chunk; + }); + resp.on("end", () => { try { - setDeviceId(response.deviceId); - if (response.ok) { - resolve(response.result); - listenersDict["success"].forEach(hook => hook(response.result, name, args)); - } else { - reject(response.error); - listenersDict["fail"].forEach(hook => hook(response.error, name, args)); + const response = JSON.parse(data); + + try { + this.deviceId = response.deviceId; + if (response.ok) { + resolve(response.result); + } else { + reject(response.error); + } + } catch (e) { + console.error(e); + reject({type: "Fatal", message: e.toString()}); } } catch (e) { console.error(e); - reject({type: "Fatal", message: e.toString()}); - listenersDict["fatal"].forEach(hook => hook(e, name, args)); + reject({type: "BadFormattedResponse", message: `Response couldn't be parsed as JSON (${data}):\\n${e.toString()}`}); } - } catch (e) { - console.error(e); - reject({type: "BadFormattedResponse", message: `Response couldn't be parsed as JSON (${data}):\\n${e.toString()}`}); - listenersDict["fatal"].forEach(hook => hook(e, name, args)); - } + }); + }); - - }); - req.on('error', (e) => { - console.error(`problem with request: ${e.message}`); - }); + req.on("error", (e) => { + console.error(`problem with request: ${e.message}`); + reject({type: "Fatal", message: e.toString()}); + }); - // write data to request body - req.write(JSON.stringify(body)); - req.end(); - }); + // write data to request body + req.write(JSON.stringify(body)); + req.end(); + }); + } } END From 442b1bdac597be250c5476fa9fee7142a5d4e25b Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 7 May 2018 18:09:11 -0300 Subject: [PATCH 525/625] ApiClient constructor: take useStaging argument --- src/target/typescript_nodeclient.cr | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/target/typescript_nodeclient.cr b/src/target/typescript_nodeclient.cr index eabe1fd..9326fb6 100644 --- a/src/target/typescript_nodeclient.cr +++ b/src/target/typescript_nodeclient.cr @@ -20,10 +20,9 @@ END @io << <<-END export class ApiClient { - useStaging = false; deviceId: string | null = null; - constructor(private baseUrl = #{("https://" + @ast.options.url).inspect}) {} + constructor(private baseUrl = #{("https://" + @ast.options.url).inspect}, private useStaging = false) {} END From 004c30abea5417f36316c76ec6323db01f002bca Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Mon, 7 May 2018 19:45:16 -0300 Subject: [PATCH 526/625] improve generated typescript code style --- src/codegen_types/date.cr | 2 +- src/codegen_types/datetime.cr | 4 ++-- src/codegen_types/int.cr | 6 +++--- src/codegen_types/money.cr | 6 +++--- src/codegen_types/uint.cr | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index 34042ce..cfe1439 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -5,7 +5,7 @@ module AST end def typescript_encode(expr) - "#{expr}.toISOString().split('T')[0]" + "#{expr}.toISOString().split(\"T\")[0]" end def typescript_native_type diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index e698d75..602dfdc 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -1,11 +1,11 @@ module AST class DateTimePrimitiveType def typescript_decode(expr) - "new Date(#{expr} + 'Z')" + "new Date(#{expr} + \"Z\")" end def typescript_encode(expr) - "#{expr}.toISOString().replace('Z', '')" + "#{expr}.toISOString().replace(\"Z\", \"\")" end def typescript_native_type diff --git a/src/codegen_types/int.cr b/src/codegen_types/int.cr index 4a5464a..b3a245b 100644 --- a/src/codegen_types/int.cr +++ b/src/codegen_types/int.cr @@ -1,11 +1,11 @@ module AST class IntPrimitiveType def typescript_decode(expr) - "#{expr}|0" + "#{expr} | 0" end def typescript_encode(expr) - "#{expr}|0" + "#{expr} | 0" end def typescript_native_type @@ -15,7 +15,7 @@ module AST def typescript_expect(expr) String.build do |io| io << "expect(#{expr}).toBeTypeOf(\"number\");\n" - io << "expect(#{expr} - (#{expr}|0)).toBe(0);\n" + io << "expect(#{expr} - (#{expr} | 0)).toBe(0);\n" end end diff --git a/src/codegen_types/money.cr b/src/codegen_types/money.cr index 6fcb8f6..c224541 100644 --- a/src/codegen_types/money.cr +++ b/src/codegen_types/money.cr @@ -1,11 +1,11 @@ module AST class MoneyPrimitiveType def typescript_decode(expr) - "#{expr}|0" + "#{expr} | 0" end def typescript_encode(expr) - "#{expr}|0" + "#{expr} | 0" end def typescript_native_type @@ -15,7 +15,7 @@ module AST def typescript_expect(expr) String.build do |io| io << "expect(#{expr}).toBeTypeOf(\"number\");\n" - io << "expect(#{expr} - (#{expr}|0)).toBe(0);\n" + io << "expect(#{expr} - (#{expr} | 0)).toBe(0);\n" io << "expect(#{expr}).toBeGreaterThanOrEqual(0);\n" end end diff --git a/src/codegen_types/uint.cr b/src/codegen_types/uint.cr index 4a7993f..db132ee 100644 --- a/src/codegen_types/uint.cr +++ b/src/codegen_types/uint.cr @@ -1,11 +1,11 @@ module AST class UIntPrimitiveType def typescript_decode(expr) - "#{expr}|0" + "#{expr} | 0" end def typescript_encode(expr) - "#{expr}|0" + "#{expr} | 0" end def typescript_native_type @@ -15,7 +15,7 @@ module AST def typescript_expect(expr) String.build do |io| io << "expect(#{expr}).toBeTypeOf(\"number\");\n" - io << "expect(#{expr} - (#{expr}|0)).toBe(0);\n" + io << "expect(#{expr} - (#{expr} | 0)).toBe(0);\n" io << "expect(#{expr}).toBeGreaterThanOrEqual(0);\n" end end From 874e39200df3f4aba432eef4901499c20ccc7e85 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 9 May 2018 14:37:10 -0300 Subject: [PATCH 527/625] Fix for node:10 --- src/target/typescript_nodeserver.cr | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 1b7d38a..311ba60 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -416,7 +416,9 @@ export function start(port: number = 8000) { if (!process.env.TEST) { server.listen(port, () => { - console.log(`Listening on ${server.address().address}:${server.address().port}`); + const addr = server.address(); + const addrString = typeof addr === "string" ? addr : `${addr.address}:${addr.port}`; + console.log(`Listening on ${addrString}`); }); } From 2c58556b8969dc59d2a61e654ddf675af6f266ad Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 9 May 2018 16:10:39 -0300 Subject: [PATCH 528/625] Fix decoding type date --- src/codegen_types/date.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen_types/date.cr b/src/codegen_types/date.cr index cfe1439..b051176 100644 --- a/src/codegen_types/date.cr +++ b/src/codegen_types/date.cr @@ -1,7 +1,7 @@ module AST class DatePrimitiveType def typescript_decode(expr) - "new Date(#{expr})" + "new Date(parseInt(#{expr}.split(\"-\")[0], 10), parseInt(#{expr}.split(\"-\")[1], 10) - 1, parseInt(#{expr}.split(\"-\")[2], 10))" end def typescript_encode(expr) From 6cc63cc9aa546d17ef9cd4f944f721571878fb3f Mon Sep 17 00:00:00 2001 From: Joshua Passos Date: Mon, 14 May 2018 16:38:51 -0300 Subject: [PATCH 529/625] up --- src/target/typescript_nodeclient.cr | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/target/typescript_nodeclient.cr b/src/target/typescript_nodeclient.cr index 9326fb6..d32dfd3 100644 --- a/src/target/typescript_nodeclient.cr +++ b/src/target/typescript_nodeclient.cr @@ -4,6 +4,7 @@ class TypeScriptNodeClient < Target def gen @io << <<-END import * as https from "https"; +import * as http from "http"; import { URL } from "url"; END @@ -77,8 +78,46 @@ END hostname: url.hostname, path: url.pathname, method: "POST", + port: url.port }; + if (url.protocol === "http:") { + return new Promise((resolve, reject) => { + const req = http.request(options, resp => { + let data = ""; + resp.on("data", (chunk) => { + data += chunk; + }); + resp.on("end", () => { + try { + const response = JSON.parse(data); + + try { + this.deviceId = response.deviceId; + if (response.ok) { + resolve(response.result); + } else { + reject(response.error); + } + } catch (e) { + console.error(e); + reject({type: "Fatal", message: e.toString()}); + } + } catch (e) { + console.error(e); + reject({type: "BadFormattedResponse", message: `Response couldn't be parsed as JSON (${data}):\n${e.toString()}`}); + } + }); + }); + req.on("error", (e) => { + console.error(`problem with request: ${e.message}`); + reject({type: "Fatal", message: e.toString()}); + }); + // write data to request body + req.write(JSON.stringify(body)); + req.end(); + }); + } return new Promise((resolve, reject) => { const req = https.request(options, resp => { let data = ""; @@ -125,3 +164,4 @@ END end Target.register(TypeScriptNodeClient, target_name: "typescript_nodeclient") + From 736904ab8eb1c0572b22925ce3e00ba21aab97ca Mon Sep 17 00:00:00 2001 From: Joshua Passos Date: Mon, 14 May 2018 16:58:13 -0300 Subject: [PATCH 530/625] Update typescript_nodeclient.cr --- src/target/typescript_nodeclient.cr | 42 +++-------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/src/target/typescript_nodeclient.cr b/src/target/typescript_nodeclient.cr index d32dfd3..5d433ab 100644 --- a/src/target/typescript_nodeclient.cr +++ b/src/target/typescript_nodeclient.cr @@ -81,45 +81,9 @@ END port: url.port }; - if (url.protocol === "http:") { - return new Promise((resolve, reject) => { - const req = http.request(options, resp => { - let data = ""; - resp.on("data", (chunk) => { - data += chunk; - }); - resp.on("end", () => { - try { - const response = JSON.parse(data); - - try { - this.deviceId = response.deviceId; - if (response.ok) { - resolve(response.result); - } else { - reject(response.error); - } - } catch (e) { - console.error(e); - reject({type: "Fatal", message: e.toString()}); - } - } catch (e) { - console.error(e); - reject({type: "BadFormattedResponse", message: `Response couldn't be parsed as JSON (${data}):\n${e.toString()}`}); - } - }); - }); - req.on("error", (e) => { - console.error(`problem with request: ${e.message}`); - reject({type: "Fatal", message: e.toString()}); - }); - // write data to request body - req.write(JSON.stringify(body)); - req.end(); - }); - } return new Promise((resolve, reject) => { - const req = https.request(options, resp => { + const request = (url.protocol === "http:" ? http.request : https.request) + const req = request(options, resp => { let data = ""; resp.on("data", (chunk) => { data += chunk; @@ -141,7 +105,7 @@ END } } catch (e) { console.error(e); - reject({type: "BadFormattedResponse", message: `Response couldn't be parsed as JSON (${data}):\\n${e.toString()}`}); + reject({type: "BadFormattedResponse", message: `Response couldn't be parsed as JSON (${data}):\n${e.toString()}`}); } }); From 3567d84a2f8a37b1e605affe4907051d9b535ccb Mon Sep 17 00:00:00 2001 From: Joshua Passos Date: Mon, 14 May 2018 17:00:18 -0300 Subject: [PATCH 531/625] Update typescript_nodeclient.cr --- src/target/typescript_nodeclient.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeclient.cr b/src/target/typescript_nodeclient.cr index 5d433ab..71e77c6 100644 --- a/src/target/typescript_nodeclient.cr +++ b/src/target/typescript_nodeclient.cr @@ -105,7 +105,7 @@ END } } catch (e) { console.error(e); - reject({type: "BadFormattedResponse", message: `Response couldn't be parsed as JSON (${data}):\n${e.toString()}`}); + reject({type: "BadFormattedResponse", message: `Response couldn't be parsed as JSON (${data}):\\n${e.toString()}`}); } }); From db07745c3a6805fa7cb213ef66a9480eb91227d6 Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Mon, 14 May 2018 17:20:06 -0300 Subject: [PATCH 532/625] fixing typescript_nodeclient format by running crystal tool format --- src/target/typescript_nodeclient.cr | 1 - 1 file changed, 1 deletion(-) diff --git a/src/target/typescript_nodeclient.cr b/src/target/typescript_nodeclient.cr index 71e77c6..37cf5a6 100644 --- a/src/target/typescript_nodeclient.cr +++ b/src/target/typescript_nodeclient.cr @@ -128,4 +128,3 @@ END end Target.register(TypeScriptNodeClient, target_name: "typescript_nodeclient") - From 96b9fd55583ac70dbfad21f2723a10544ecb9b9d Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 17 May 2018 09:56:26 -0300 Subject: [PATCH 533/625] android: throw 502 error on the correct thread --- src/target/java_android.cr | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 974a719..86a4efb 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -736,7 +736,12 @@ END if (!shouldReceiveResponse[0]) return; if (response.code() == 502) { Log.e("API", "HTTP " + response.code()); - callback.onResult(new Error() {{type = ErrorType.Fatal; message = "Erro Fatal (502) - Tente novamente";}}, null); + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + callback.onResult(new Error() {{type = ErrorType.Fatal; message = "Erro Fatal (502) - Tente novamente";}}, null); + } + }); return; } shouldReceiveResponse[0] = false; From 67c9dcc8ae41fe015f0496d4640f8ebda140b8ba Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 23 May 2018 17:07:33 -0300 Subject: [PATCH 534/625] feature(ios-date-optimization) Optimize the date moving the init of dateFormatter to an static variable. Create the customUrl variable, given the user the option to input a custom url. --- src/target/swift_ios.cr | 55 +++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/src/target/swift_ios.cr b/src/target/swift_ios.cr index 7ea69e9..f048946 100644 --- a/src/target/swift_ios.cr +++ b/src/target/swift_ios.cr @@ -7,6 +7,7 @@ import Alamofire import KeychainSwift class API { + static var customUrl: String? static var useStaging = false static var globalCallback: (_ method: String, _ result: APIInternal.Result, _ callback: @escaping ((APIInternal.Result) -> Void)) -> Void = { _, result, callback in callback(result) @@ -47,7 +48,7 @@ END io << "args[\"#{arg.name}\"] = #{type_to_json arg.type, arg.name}\n\n" end - io << "return APIInternal.makeRequest(#{op.pretty_name.inspect}, args) { response in \n" + io << "return APIInternal.makeRequest(#{op.pretty_name.inspect}, args) { response in \n" io << ident(String.build do |io| io << "switch response {\n" @@ -84,6 +85,23 @@ END class APIInternal { static var baseUrl = #{@ast.options.url.inspect} + private static let dateAndTimeFormatter: DateFormatter = { + let formatter = DateFormatter() + formatter.calendar = Calendar(identifier: .gregorian) + formatter.timeZone = TimeZone(abbreviation: "UTC") + formatter.locale = Locale(identifier: "en_US_POSIX") + formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" + return formatter + }() + + private static let dateFormatter: DateFormatter = { + let formatter = DateFormatter() + formatter.calendar = Calendar(identifier: .gregorian) + formatter.locale = Locale(identifier: "en_US_POSIX") + formatter.dateFormat = "yyyy-MM-dd" + return formatter + }() + enum Result { case success(T) case failure(Error) @@ -141,37 +159,19 @@ class APIInternal { } static func decodeDate(str: String) -> Date { - let formatter = DateFormatter() - formatter.calendar = Calendar(identifier: .gregorian) - formatter.locale = Locale(identifier: "en_US_POSIX") - formatter.dateFormat = "yyyy-MM-dd" - return formatter.date(from: str)! + return dateFormatter.date(from: str) ?? Date() } static func encodeDate(date: Date) -> String { - let formatter = DateFormatter() - formatter.calendar = Calendar(identifier: .gregorian) - formatter.locale = Locale(identifier: "en_US_POSIX") - formatter.dateFormat = "yyyy-MM-dd" - return formatter.string(from: date) + return dateFormatter.string(from: date) } static func decodeDateTime(str: String) -> Date { - let formatter = DateFormatter() - formatter.calendar = Calendar(identifier: .gregorian) - formatter.timeZone = TimeZone(abbreviation: "UTC") - formatter.locale = Locale(identifier: "en_US_POSIX") - formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" - return formatter.date(from: str)! + return dateAndTimeFormatter.date(from: str) ?? Date() } static func encodeDateTime(date: Date) -> String { - let formatter = DateFormatter() - formatter.calendar = Calendar(identifier: .gregorian) - formatter.timeZone = TimeZone(abbreviation: "UTC") - formatter.locale = Locale(identifier: "en_US_POSIX") - formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" - return formatter.string(from: date) + return dateAndTimeFormatter.string(from: date) } static var deviceID: String? { @@ -210,7 +210,13 @@ class APIInternal { "staging": API.useStaging ] as [String : Any] - return api.request("https://\\(baseUrl)\\(API.useStaging ? "-staging" : "")/\\(name)", method: .post, parameters: body, encoding: JSONEncoding.default).responseJSON { response in + let url = API.customUrl ?? "https://\\(baseUrl)\\(API.useStaging ? "-staging" : "")" + return api.request( + "\\(url)/\\(name)", + method: .post, + parameters: body, + encoding: JSONEncoding.default + ).responseJSON { response in guard let responseValue = response.result.value else { let error = Error(API.ErrorType.Connection, "Erro de Conexão, tente novamente mais tarde") API.globalCallback(name, Result.failure(error), callback) @@ -224,6 +230,7 @@ class APIInternal { API.globalCallback(name, Result.failure(response.error!), callback) return } + API.globalCallback(name, Result.success(response.result), callback) } } From fc0cc9f0cd12655f6a1dc55e6f3120e83c80982e Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Thu, 24 May 2018 09:54:10 -0300 Subject: [PATCH 535/625] datetime convertion outside Internal static class in android target, to make it easier to uso toJSON method on unit tests --- src/target/java.cr | 4 ++-- src/target/java_android.cr | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/target/java.cr b/src/target/java.cr index 56310a4..414f2d4 100644 --- a/src/target/java.cr +++ b/src/target/java.cr @@ -239,9 +239,9 @@ END when AST::StringPrimitiveType, AST::IntPrimitiveType, AST::UIntPrimitiveType, AST::FloatPrimitiveType, AST::BoolPrimitiveType "#{src}" when AST::DatePrimitiveType - "Internal.encodeDate(#{src})" + "DateHelpers.encodeDate(#{src})" when AST::DateTimePrimitiveType - "Internal.encodeDateTime(#{src})" + "DateHelpers.encodeDateTime(#{src})" when AST::BytesPrimitiveType "Base64.encodeToString(#{src}, Base64.DEFAULT)" when AST::VoidPrimitiveType diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 86a4efb..d6c14d7 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -358,6 +358,19 @@ END return Internal.forcedUrl != null ? Internal.forcedUrl : "https://" + Internal.baseUrl + (API.useStaging ? "-staging" : ""); } + private static class DateHelpers { + static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); + static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); + + static String encodeDateTime(Calendar cal) { + return dateTimeFormat.format(cal.getTime()); + } + + static String encodeDate(Calendar cal) { + return dateFormat.format(cal.getTime()); + } + } + private static class Internal { static String forcedUrl = null; static String baseUrl = #{@ast.options.url.inspect}; From 9ca40d4eb46402fc15dcaa1e5ee56aad92002bfd Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Thu, 24 May 2018 10:50:56 -0300 Subject: [PATCH 536/625] datetime convertion outside Internal static class in android target, to make it easier to uso fromJSON method on unit tests --- src/target/java.cr | 4 ++-- src/target/java_android.cr | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/target/java.cr b/src/target/java.cr index 414f2d4..455be48 100644 --- a/src/target/java.cr +++ b/src/target/java.cr @@ -210,9 +210,9 @@ END when AST::BoolPrimitiveType "#{obj}.getBoolean(#{name})" when AST::DatePrimitiveType - "Internal.decodeDate(#{obj}.getString(#{name}))" + "DateHelpers.decodeDate(#{obj}.getString(#{name}))" when AST::DateTimePrimitiveType - "Internal.decodeDateTime(#{obj}.getString(#{name}))" + "DateHelpers.decodeDateTime(#{obj}.getString(#{name}))" when AST::BytesPrimitiveType "Base64.decode(#{obj}.getString(#{name}), Base64.DEFAULT)" when AST::VoidPrimitiveType diff --git a/src/target/java_android.cr b/src/target/java_android.cr index d6c14d7..39c9cd8 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -369,6 +369,24 @@ END static String encodeDate(Calendar cal) { return dateFormat.format(cal.getTime()); } + + static Calendar decodeDateTime(String str) { + try { + return toCalendar(dateTimeFormat.parse(str)); + } catch (ParseException e) { + e.printStackTrace(); + return null; + } + } + + static Calendar decodeDate(String str) { + try { + return toCalendar(dateFormat.parse(str)); + } catch (ParseException e) { + e.printStackTrace(); + return null; + } + } } private static class Internal { From c90e623aef0a2d65d24b1c7d57936b383430faff Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Thu, 24 May 2018 13:46:22 -0300 Subject: [PATCH 537/625] date time conversion - target java fix --- src/target/java_android.cr | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 39c9cd8..9101932 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -370,6 +370,12 @@ END return dateFormat.format(cal.getTime()); } + static Calendar toCalendar(Date date){ + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + return cal; + } + static Calendar decodeDateTime(String str) { try { return toCalendar(dateTimeFormat.parse(str)); From ebb3c4205f079ccc5ea3b546312d2610d0bab29e Mon Sep 17 00:00:00 2001 From: David Pires Date: Fri, 1 Jun 2018 17:56:32 -0300 Subject: [PATCH 538/625] fix 502 multiple errors in android response --- src/target/java_android.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 9101932..121adce 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -771,6 +771,8 @@ END @Override public void onResponse(Call call, final Response response) throws IOException { if (!shouldReceiveResponse[0]) return; + shouldReceiveResponse[0] = false; + timer.cancel(); if (response.code() == 502) { Log.e("API", "HTTP " + response.code()); new Handler(Looper.getMainLooper()).post(new Runnable() { @@ -781,8 +783,6 @@ END }); return; } - shouldReceiveResponse[0] = false; - timer.cancel(); final String stringBody = response.body().string(); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override From 0ea7865c23b7ffead513f6cf37ede84e55b953e8 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 13 Jun 2018 18:18:31 -0300 Subject: [PATCH 539/625] accept preencoded datetime --- src/codegen_types/datetime.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index 602dfdc..f7b6d12 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -5,7 +5,7 @@ module AST end def typescript_encode(expr) - "#{expr}.toISOString().replace(\"Z\", \"\")" + "#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/) ? #{expr} : #{expr}.toISOString().replace(\"Z\", \"\")" end def typescript_native_type @@ -29,7 +29,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date || #{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/)) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" From 1ad41ffaf8af8e18e54f818396d9e8ef0ceda9e9 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 13 Jun 2018 18:37:10 -0300 Subject: [PATCH 540/625] Fix missing closing parens --- src/codegen_types/datetime.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index f7b6d12..561d8ff 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -29,7 +29,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date || #{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/)) {\n" + io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date || #{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/))) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" From 73fc6170abcc712c907d27b59a9a199b8d7c247d Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 13 Jun 2018 18:46:58 -0300 Subject: [PATCH 541/625] Fix datetime encoding --- src/codegen_types/datetime.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index 561d8ff..653bfa6 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -5,7 +5,7 @@ module AST end def typescript_encode(expr) - "#{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/) ? #{expr} : #{expr}.toISOString().replace(\"Z\", \"\")" + "(typeof #{expr} === \"string\" && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/) ? #{expr} : #{expr}.toISOString().replace(\"Z\", \"\")))" end def typescript_native_type From 626ff803256bb73f02144a743b9d076edeb9cc1a Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 13 Jun 2018 18:51:39 -0300 Subject: [PATCH 542/625] remove extra paren closing --- src/codegen_types/datetime.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index 653bfa6..a100551 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -5,7 +5,7 @@ module AST end def typescript_encode(expr) - "(typeof #{expr} === \"string\" && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/) ? #{expr} : #{expr}.toISOString().replace(\"Z\", \"\")))" + "(typeof #{expr} === \"string\" && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/) ? #{expr} : #{expr}.toISOString().replace(\"Z\", \"\"))" end def typescript_native_type From 31c9e69a7c18d0253f23fb0a982a55eb8bb9a76a Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Wed, 13 Jun 2018 18:59:32 -0300 Subject: [PATCH 543/625] fix datetime again --- src/codegen_types/datetime.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index a100551..5802b43 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -29,7 +29,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date || #{expr}.match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/))) {\n" + io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date || ((#{expr} as any).match && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/)))) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" From 0c9c7374a55ee86a21b97503c57065ac8b11d6ea Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 14 Jun 2018 11:11:59 -0300 Subject: [PATCH 544/625] Allow datetime "Z" --- src/codegen_types/datetime.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index 5802b43..bbc9c2a 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -5,7 +5,7 @@ module AST end def typescript_encode(expr) - "(typeof #{expr} === \"string\" && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/) ? #{expr} : #{expr}.toISOString().replace(\"Z\", \"\"))" + "(typeof #{expr} === \"string\" && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}Z?$/) ? #{expr}.replace(\"Z\", \"\") : #{expr}.toISOString().replace(\"Z\", \"\"))" end def typescript_native_type @@ -29,7 +29,7 @@ module AST def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date || ((#{expr} as any).match && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}$/)))) {\n" + io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date || ((#{expr} as any).match && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}Z?$/)))) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" From adb209ea0e5f0bb6b8a66af3babc6bee54b8a90e Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 14 Jun 2018 13:12:58 -0300 Subject: [PATCH 545/625] Add extra as any --- src/codegen_types/datetime.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index bbc9c2a..d88b8ea 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -5,7 +5,7 @@ module AST end def typescript_encode(expr) - "(typeof #{expr} === \"string\" && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}Z?$/) ? #{expr}.replace(\"Z\", \"\") : #{expr}.toISOString().replace(\"Z\", \"\"))" + "(typeof #{expr} === \"string\" && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}Z?$/) ? (#{expr} as any).replace(\"Z\", \"\") : #{expr}.toISOString().replace(\"Z\", \"\"))" end def typescript_native_type From 3b2dd27eb445a7071623574b9c7c0e5227aaa539 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 14 Jun 2018 14:27:53 -0300 Subject: [PATCH 546/625] Allow 2-digit milliseconds --- src/codegen_types/datetime.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index d88b8ea..db3b0c5 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -5,7 +5,7 @@ module AST end def typescript_encode(expr) - "(typeof #{expr} === \"string\" && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}Z?$/) ? (#{expr} as any).replace(\"Z\", \"\") : #{expr}.toISOString().replace(\"Z\", \"\"))" + "(typeof #{expr} === \"string\" && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{1,3}Z?$/) ? (#{expr} as any).replace(\"Z\", \"\") : #{expr}.toISOString().replace(\"Z\", \"\"))" end def typescript_native_type @@ -24,12 +24,12 @@ module AST io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" - end + endtalvez end def typescript_check_decoded(expr, descr) String.build do |io| - io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date || ((#{expr} as any).match && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{3}Z?$/)))) {\n" + io << "if (#{expr} === null || #{expr} === undefined || !(#{expr} instanceof Date || ((#{expr} as any).match && (#{expr} as any).match(/^[0-9]{4}-[01][0-9]-[0123][0-9]T[012][0-9]:[0123456][0-9]:[0123456][0-9].[0-9]{1,3}Z?$/)))) {\n" io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" From 9e1a3f26f02b88d529e0a51489dcc8149c3330d0 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 14 Jun 2018 14:33:52 -0300 Subject: [PATCH 547/625] fix typo --- src/codegen_types/datetime.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen_types/datetime.cr b/src/codegen_types/datetime.cr index db3b0c5..05fb0d2 100644 --- a/src/codegen_types/datetime.cr +++ b/src/codegen_types/datetime.cr @@ -24,7 +24,7 @@ module AST io << " const err = new Error(\"Invalid Type at '\" + #{descr} + \"', expected #{self.class.name}, got '\" + #{expr} + \"'\");\n" io << " typeCheckerError(err, ctx);\n" io << "}\n" - endtalvez + end end def typescript_check_decoded(expr, descr) From fdc44ab6ef318919025a7bf3ca69fdc5b9f38342 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 17 Jun 2018 09:40:44 -0300 Subject: [PATCH 548/625] Support for Crystal 0.25.0 --- src/target/java_android.cr | 4 +--- src/target/typescript_nodeserver.cr | 32 ++++++++++++++--------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 121adce..18251ee 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -729,9 +729,7 @@ END public void run() { #{String.build do |io| unless @ast.options.useRethink - io << <<-END - timer.cancel(); -END + io << "\n timer.cancel();" end end} sentCount[0] += 1; diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 311ba60..8551a80 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -3,30 +3,28 @@ require "./target" class TypeScriptServerTarget < Target def gen - @io << <<-END -#{String.build do |io| if @ast.options.syntheticDefaultImports - io << <<-END + @io << <<-END import http from "http"; import crypto from "crypto"; import os from "os"; import url from "url"; import Raven from "raven"; + END else - io << <<-END + @io << <<-END import * as http from "http"; import * as crypto from "crypto"; import * as os from "os"; import * as url from "url"; const Raven = require("raven"); + END end - end} -#{String.build do |io| - if @ast.options.useRethink - else - io << <<-END + + unless @ast.options.useRethink + @io << <<-END interface DBDevice { id: string @@ -58,7 +56,8 @@ interface DBApiCall { END end - end} + + @io << <<-END let captureError: (e: Error, req?: http.IncomingMessage, extra?: any) => void = () => {}; export function setCaptureErrorFn(fn: (e: Error, req?: http.IncomingMessage, extra?: any) => void) { @@ -432,20 +431,20 @@ export function start(port: number = 8000) { } fn.ping = async (ctx: Context) => "pong"; +END -#{String.build do |io| if @ast.options.useRethink - io << <<-END + @io << <<-END fn.setPushToken = async (ctx: Context, token: string) => { await r.table("devices").get(ctx.device.id).update({push: token}); }; END end - end} -#{String.build do |io| if @ast.options.useRethink - io << <<-END + @io << <<-END + + import r from "../rethinkdb"; hook.onHealthCheck = async () => { @@ -493,8 +492,7 @@ hook.afterProcessCall = async (call) => { END end - end} -END + end @i = 0 From e9e1545beb5776a711bd238d5820a83c587a96a3 Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Sun, 17 Jun 2018 10:08:17 -0300 Subject: [PATCH 549/625] crystal tool format --- src/target/typescript_nodeserver.cr | 1 - 1 file changed, 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 8551a80..35306e1 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -492,7 +492,6 @@ hook.afterProcessCall = async (call) => { END end - end @i = 0 From b8a901baf84c0c6048745df7bb9378e152647e71 Mon Sep 17 00:00:00 2001 From: Icaro Leite Date: Mon, 18 Jun 2018 19:29:12 -0300 Subject: [PATCH 550/625] Fix Multiple Function Declaration --- src/semantic/check_multiple_declaration.cr | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/semantic/check_multiple_declaration.cr b/src/semantic/check_multiple_declaration.cr index c96c180..65b9f2a 100644 --- a/src/semantic/check_multiple_declaration.cr +++ b/src/semantic/check_multiple_declaration.cr @@ -11,5 +11,13 @@ module Semantic @names << definition.name super end + + def visit(op : AST::Operation) + if @operationsNames.includes? op.name + raise SemanticException.new("Function '#{op.name}' is declared multiples times") + end + @operationsNames << op.name + super + end end end From 034ce3ff50c8d08f5e5fc0b466cf9e816290b2ec Mon Sep 17 00:00:00 2001 From: Icaro Leite Date: Mon, 18 Jun 2018 22:43:53 -0300 Subject: [PATCH 551/625] Better name to operations names and add forgotten declaration --- src/semantic/check_multiple_declaration.cr | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/semantic/check_multiple_declaration.cr b/src/semantic/check_multiple_declaration.cr index 65b9f2a..200e925 100644 --- a/src/semantic/check_multiple_declaration.cr +++ b/src/semantic/check_multiple_declaration.cr @@ -3,6 +3,7 @@ require "./visitor" module Semantic class CheckMultipleDeclaration < Visitor @names = Set(String).new + @op_names = Set(String).new def visit(definition : AST::TypeDefinition) if @names.includes? definition.name @@ -13,10 +14,10 @@ module Semantic end def visit(op : AST::Operation) - if @operationsNames.includes? op.name + if @op_names.includes? op.name raise SemanticException.new("Function '#{op.name}' is declared multiples times") end - @operationsNames << op.name + @op_names << op.name super end end From 5083dc9369fbe8d29bbeca861bfff9a8b4e4c24f Mon Sep 17 00:00:00 2001 From: Icaro Leite Date: Mon, 18 Jun 2018 22:58:06 -0300 Subject: [PATCH 552/625] Formating Code with crystal tool format --- src/semantic/check_multiple_declaration.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/semantic/check_multiple_declaration.cr b/src/semantic/check_multiple_declaration.cr index 200e925..9674f1d 100644 --- a/src/semantic/check_multiple_declaration.cr +++ b/src/semantic/check_multiple_declaration.cr @@ -12,7 +12,7 @@ module Semantic @names << definition.name super end - + def visit(op : AST::Operation) if @op_names.includes? op.name raise SemanticException.new("Function '#{op.name}' is declared multiples times") From 6ee25a78d77227388182e0187ac9f9f06e9bf734 Mon Sep 17 00:00:00 2001 From: Daniel Santiago Date: Thu, 21 Jun 2018 10:32:38 -0300 Subject: [PATCH 553/625] fix date encode decode, user timezone --- src/target/java_android.cr | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/target/java_android.cr b/src/target/java_android.cr index 18251ee..b1be7c2 100644 --- a/src/target/java_android.cr +++ b/src/target/java_android.cr @@ -359,8 +359,14 @@ END } private static class DateHelpers { - static SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); - static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); + static SimpleDateFormat dateTimeFormat; + static SimpleDateFormat dateFormat; + + static { + dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US); + dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); + dateTimeFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + } static String encodeDateTime(Calendar cal) { return dateTimeFormat.format(cal.getTime()); From 1ed16cc83fbedf293d0e408a5115006d01ef7049 Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Thu, 21 Jun 2018 13:13:32 -0300 Subject: [PATCH 554/625] adding logo --- README.md | 6 +++++- assets/ze_polvinho_sdkgen.png | Bin 0 -> 50375 bytes assets/ze_polvinho_sdkgen_small.png | Bin 0 -> 11608 bytes 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 assets/ze_polvinho_sdkgen.png create mode 100644 assets/ze_polvinho_sdkgen_small.png diff --git a/README.md b/README.md index bd58426..eac78d5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ -# sdkgen [![Build Status](https://travis-ci.org/cubos/sdkgen.svg?branch=master)](https://travis-ci.org/cubos/sdkgen) +# sdkgen + +![Zé Polvinho](assets/ze_polvinho_sdkgen_small.png) The sdkgen is a tool that aims on solving client-server communication and data layout sharing between server, web, android and ios using a description language also called sdkgen. +[![Build Status](https://travis-ci.org/cubos/sdkgen.svg?branch=master)](https://travis-ci.org/cubos/sdkgen) + ## How to use it `crystal run main.cr -- api.sdkgen -o api.ts -t typescript_nodeserver` diff --git a/assets/ze_polvinho_sdkgen.png b/assets/ze_polvinho_sdkgen.png new file mode 100644 index 0000000000000000000000000000000000000000..a14a8725ec93ad02dfd83d797bc680384809d6fb GIT binary patch literal 50375 zcmeFY2Uk1K4I#r3Y6rGE>zbVgda7-qFnB(OY{{D+^5v)A!!ae=H;bpxx%}>wmSq zrnYA(e$43kKRGkN={6r%SiHT#eJ%;9CiPMd_P(L)^^a@h{qJv6?lV=GdU$+izU6w_ zOJb?k{g1Q9dW!xdS1N(^Pu$cN&Mt>RBC##EnRPb@hR3z{;q& zL!*@yx`!ucT3o3{GH3dFG4WRzCeDEx?vQ@Igmd&(cLmg+5px4BR=l;?s-c}GC`pFH ztX@41%di*Nw7g7OQ6rV0p$yi=LrIc@qm9+AQS&4C#ZQ@%O#0?bkPOYB>iCsS8m(ZwJ zk;2S(SgGYLt@J8BG|T?D3vlZta{wk)DDwOz`oMtY8RH#8R6n(Gojx0}V8Ym+#1T=i z`pb0`8(YD1sZ??rhbEDQ`W&~5U-Tpu*yUP8absWLJbb&JNqeb0o2JGol z2Y-v3k@)I9vZ`Bv5{(H_Sw>xpt)m#NZpU~klr-qp1Mb;fu303#F)0+_23OhQO6ZBl z-`h&8vdBD-o+#rw72Lu2>Fkvq-adJ6_yKT@h+Za^Y2xKQ(@{Tbi?@#e?>lmH>%WWm ztf_+5*jtFLUy)o~&kh)6erruCgG->Ulp>5zZ43VT82t5)tN3-~%ha1C9=0^V=0xkz z&T`Il9%jD!{O1~A?MKWVbp54XByRjWxV?gD=lc2{0@tja2#8Ne6=P-L{;C;_ZpFzo-*%lrnHD0ril4oF!>{?koteGhCX_N10LNDlNQ{{d78 zaH0}Ks-B19L|qvb69GzCH_dJ442PR#z~(>;vNh%ha^~AM=M8|1rhz`d4_vZz)-zx; z0vsi}mxtlf8eOdb16m3@T-vA$V@TDduR#EJ6O(z9-e2LXA6W(%0d;;BB`Y{x+Q?nt z9Q2Xyx;lNmbk121TS_3mHaKURFENVrt0PYm@TeKIbf-&eDaRrm@Sc6nyje`o_)bvD z3lfS)pVvI@UHWNmkpqR#Y|Wc`R6~GsHn6kA5B|Y5KLwPoZ+U-iRaiqxNnlPUX6)zQ zpgmd!ujeZ@DAvqXUitRS@VpbixO+0=FR~u$azDHLC`mNV2$%2FL6)+aHlJ%Ln=0HX&MRnc)pCfA8do zGPeDsbupY+w)y9uB4QJZ$1UNHxLy^1_<@(%Lb_SL%`_w@vQ-A{Yff+hl+GtTaaZh} zbrQrGXBlzEcf#v1se!-Q!D!_#CmFv<)y2U%F)~iPtOXsS^iX$?lNjMUoH$@R@{Kry z+-E59_EzqXW=1GK3D>Kliw7J*Q{Zeyy1{+IT zm@Xy`8GVak_``XbQa35ZlukYFNP9Xb{rB-orByf1j9!uzo>)jmXN ztmbaDo$cH4k;fTO#Cg!xnVpZ9b+y;_g4@B{R{9_D^mE^A^|lSakgAh{dk{&mh77t# z0k%Jqoija)?sfUsn)AqXl$0kV!O;D!T4q_pH+)le#}Zqf<#232ik|vLm9<%U(f-;{ zao+WQTq~}|{whHh_{t30Hq^Fu+Ju`SlETKl#G1UO6xOu%y&67SepysGYd`3qbKG z0F?5k*ugx1^VFAXQT%gJ8E&)SoSLn#{gte@Q)G1w_=41+?!C1F^So=F`Vcjc1K z2^KUgt;y_@_F9V%GT*(-jT*zcJ8#hv)MI>ikg(%+NjN%C)sw}FY zsjO7(1-nV$4Nyvu3$AzH)#afvYcd1-ptki1`b*d<0?6DbHd`A_wma1j@`f#@?z>tKSFrh8&EKv-6>NgTiAsvNhgLg(`^?UJuGf zWcF$DNW-gp@LuT87#$1H54BE8Bc&t>}lf>^cM^qZ9?GW zR~`&&mm*yXpx`#7QUclJ^yO zYRuqrIVH!*2rzA)^uS~Xggv_FWsXjcVwG-Xj3W(MB^`E%akuIjyD$@6qOsZ8OWI1$ zLH`)|V?K1jw>S1Nc?&#)7HudSR*00zb)B%2V6N4Ac1X^LKQvx&wWUOEOn z#r7eG@KeDAw3*oH#__fxoIx|Mkj`wj1`IgIp&0=21Z)}1Ioeb){K);uM})z6)$HZ> zv9><=P2tZFqqEq=rCHC^G^D{-xu&MnJONhSG4nXWh>yT_JEObE*3=xnd6h|C=1A%f z<--|Jff3SHx{utO+IIiYG;{xTnF(kAR7x;+a1xWrDrg^sc1}((oKlnFnqK4AM-gJ$ zQLCTecZiF=0~987g}>a?z2pqf-WXpLf8;`0Np)kp3!XLPX;K%`nCUCtC?f}Vp003c z=-)-UI)(;vP87voUks~{cg;cEcbX~7SBFL%#7M&Hc;i!*FA+`yMS zWEL81VeCdf1fSjE@w`M~Pm__7qQ2u+YW))l9~;9l3-{(7{%#z+>@`$^fP)cRnh+JW zfZk!CXe^b!sI{$T72f@7_jM}5c-O&qehuEHGU|gGj?EiJ7la9l3nWiL4Yc%ptu{9| zT%I$wEZ7~)%`+um{lr36Aa+?VzAi2|!$7BR&PXJJD+H025rgT#{AEk(eaXuYbrBXU zYu%}V^V1$j?Djl0x|OKWf`dUpe$j)hJx_O!oH>*OSq{-_{~{0=_OLtO&<$1BMei;f zUTWIt$;SjbfgO9=SO%?v(ZoFr&KXSEmr!|XmP|0+ko^+$J}g0v89JhEaWZQi@6d9rJGCx zgP;$kOG^63TZF9aym*v)&aOqDm2pu5_9|77NJPJ`7Z3E%3Y1ommztp?_rqttJl?_A z=i!#C$V;t_oKYQh4C@(Vj}%V(oAj(qW&b*Oyp)mUC!sL83EIyycN>0M;49~#?K3vI zy=|A2koG2ac(~ucw5m$Ty~dNL?$XiLQj9W+Djl=O!)oVeY5q+>fBbj2K7>q2pyj;o zkOTsSH{ZuWKxZM**xJNN?s)2QHYTN{DL?59{o4cN<>sX|M5#r_H%s#im2dRd)Kur7 zqEV!H-tbzAQbyyH2xryKx&oo@4}*1>ZJ)+5!1@O0INXnyC-pr0W;1f7hQ%9JafED|1#B(vJ>Y|HOMi%`;DH>h-&B?F4 z8}r&%oQ<}s&e5H9jO#^X8J)X|lQ^>;Ztfttgb$=n4_(En)4DenrQg*{7R43BJ^hZu zqQ^BV4r=U>g+i=f-96@YUSfaSJuTSUMTb>RMlIFNUbH`t7 ztSxOI$rfp*et%qx0qL61U8U>u6O&kjII7Y%WoHjL3?F^OI<5f{?q%yIC@JoDSvS4V z9d=mJ))5dLigelubA5?2E&i8MQUYUSq&EH#h;m{ETD)hzwVKP*OsLsHZCT;QIBDDt zOX2bNR_@o|F!|X+{N4`bm?gXNclWN&HvYJ@$hn5Qil8i%$O|&na_xjo>tu(Cxk0v7 z76by~9*_Uz*H+p2xNWgFl)ZZ|YLPk5zpftrqSy7X(RkWeoAj^u+9Uv=Odis2!26s_Q~d<1@a# zlJA0n5lOijA|sF`FQg5{?^*5-u&7Or_6CuHfm5B#2ZMRfn_VB z7wkl%9$J4noP0X2riG>Ry@}GSuG6Lj!woSEEv;CXdDh)^n_8zOF9EY507XRvXH-{RX|1>pyu6 zd+o;AZLUHNsagfot+ZFB7&DBxkQ6jcr;2fvc+;Fs2?Y-)-Z5l0wDI?xcda?w3n8!R zH^}E0Gc&u%n!Ad|v|0-6{X&-NGTQQ}g5<95lYD zgY0B=TkzfqB5O{EyV6|Q;9c`F;&8Fa6K&{1yYgk`y~;oB{1ASOP^dv z*K;Gg`yz|sc`=U_c?W}Ces2~-y(GA__ktE$yfQr8LF@D5LeB92D#4(;BRlN3kY@rjkQihzJR_g@*r49Hj96>vFz%u8Ec0Nk|3 zCU++y3UHGP?R`8f<$CDyEOQ^cD|A2LYJaSxe@P50wIl_(Vf)A>$Zvc(FU#hKDzvAd zzY*|P!j2c^Yzq`T)jbQZEF&yUG)5^*Sn2f(kA+&&>R@z1mVx-|);_)hUdlaW1^Hal zQ*K~DsWXJ*!R1X5U>ToV_u;F2DW%n`~Dh6Obx(e2Mswz#`H zEh^GRP*3db*)&%cf2}TBbvDy$ex;PTR9b5O!Gt>vmYJx(9%wHtpNq{>lbgR|_U(hB zF~z&Qw;wD)LYIH(D8$3^Gi!;&1I+dB3$(0!tvZb7&mUGcG{L;3=LZv^(0AX}nFedJ zVr*`@1n`vU#S-_SMjy+pZW&7!y)F2GADItO$Z10i440Q=RhIeGkEMFnndm9#iKal6 z4Pda%oo$bdf`Se6!SP?$M3M9p+5a0kX$oW>O>_a>=B_Uxl`+Rv^YvixYq7HkwB_C? z=X9YN1pObLU@dLX=^RG2Mes**+Zp;%?T5ClAo)rr{7UlWZsFdtQttC-D7cqCn zWTL+uuYXzIPHucP{fqPGO(}^QN?|}@py7N)Tb?`f*3jBql#Ra{o)G8>-t3K!)w25K z=7;aB94EDKb7vIXEDN&KLucj3SZj`L8m1OE7|qQcBDvGqEaf|H9~f+LO`;K=U`pp+$W8lmQZ8M4 zBsIm5DItVZkcWtVpqCS8&}*LbW3;>8`hq~OKw6adL@nO&VEt?ks@#u~zIu&mX`!t@7{sj6zqO^^BmMDXe9yt7hg9T)R1nzST+Eq7jJJR^w3r*Nd7l!czSnKoDD z9m0v&XmU{Vfc-6)ez>Sg|2}a-TTMZyi7m(`OA@(qs`wDu{&CIJpB6;(G zg))a$Hr8hUz3a$o67|Z%fbDkC`T0gxOMCa9Jx0|?2^h>gP+`hLBPO~=e$c8kg z7@ftR9%sb%evoM1png`fzSDdBe?s?tYc~)N7UOugmx%YY?n_5u^@_TiHyj$+BI@}>S?@bN{z5&3UVR$^3h(jPGK^cULxx~~&=hsbEgXhMqLoXZl{^j=A= ze#OGy)}dJacyglw@8h+pTHH!rO5uhe-dPHYu9DO$F71{Bsu;dga$X~a=or{Y8`I*;;s2V4L-ns zrkYCMzJ8V-qGtTrpF>TVN<;+%m@lLyd~cdvgO(rfZ}td7JiH#l?|dJIeY#QpPAHfHFvA_%#E&&cA20PsGgdd(lSumDok?>c)RdB zhWX`h&L?YDHvVX)&uPh-?tOI0+@cZ@IiHG_7)>+C`zuX%r`A=H9$3EyJ7?{qv!6$> zcgKRWAA1E-Bi1q7c5Z}YAb#?=T`O-WGf&0jPbC9tV9HrTt^Rlk>4qC+5X5bBE8YB4 z(Bw?{Ghck*3kZeT^|G{IpXl>4r;KY_|LHL2UfB!qdhCz?+%=2|a2n!9h|zyApFy6s z3?6P5!AfVomLUDKe9l*yk}D*++5hPpm%-Rv<Q>78H5}7Bj-09oJajJX|?-x396R za&t2Bh57P6G*25SEbrjQjbYMw=97ea!=;%0FMj9cN}(ekDL90|GWq84@Yp0`>wgF< z^B zX@^axmX5uyrYf?avb+5pb`**_rY@~}ZW!1{N@)m4Vb9i|SW2yIEJJTR0u|&8nkEg} zuM8~PHVp-N>Jx^=>o7-qCBsxh8$UBYIcWxITIq&6ffwDC=ntP`;yjCjLtbaxZ@Ayd z;~~(vn8bsQ1BJlaK&#_}jV%`DROGluSJiD9VUVPL{q}U`>hKhf(Yf&U6>sP(~lq3LWgegzA0@EfXVj#4M!Sn9$nD6kp@)@eUzTNx-YGP9@*3kXom<>gedpSYj!!q#-|zQ<#0ViN2-lH~U9 zH{9#wv9xGf#M)D8oJnGRj?ZIKlInXjt_S_4H6fC@J~uE}vC6LVbOxDlBUkviNNu=M zz{bailTHaw5i*4TKR3>jmX_i-EU~8(C>g1KOmS3Mk)^BK+Z_(oH%vY8^=9-(j$rn1 z*p+R51qOfE3R@L>j){*(>50$`yWX6*7{|+>CGiaM z=`l!9be)V5F9g&VVNewSh@-146|TAKP*^k0+&XIPf28h>5y=m!jAuY%rznQhnj92n zN%aRYO6DzwmZn597GTvSqs{EPykyhdlR&`~q#vI3q?q&P^Ow`bBBI&+V~;+L)XJq6 z)y&nh86H+#)iaXxwh;&Y1%+W5(phB5Ns>>ZKYQ(8dFOt(K%m#cm(Khk0r!e4WXZ>( zdnAhHt$I?vK5M25w*gLBaAkCE{t8OFR>n6=DzrBC-pDraapS#l*}(-O5(OHZKj*+k z6yUC_i-JYS{I3cAqgqe5QCnLPjCz6l3~Dz@UI?B~G22)=+%&zc!zroR{va0@@5Y9t z*9q1LRhV&q;s5swDGj!vnB>>0!>RlIMC1 z5q2G-Eb9TsA2ukwP3Y+X?NERM7~AMeEf%6K%|eY@T^*MnhxOz986`v)GqeYfDW}u8 zW{_Xc8fvLWY5gBzUmb^SFm>Jl@&m(bNm>}+P3mrVzXe$s6d9V2JE|g!PIA^E3Au_E zY`kb=-($c`9ygg2wqmewW3fy1M?_QeL1;0W=Oyx|Whq66PTwSC z^nn0CfNj8pF3am;4gN~UgFZRkosP7ipy`zYjIlo8q=CG%pPqiQ>g#6Me@*x;+b1$t ziT+cZ%gFJy2%)3>zeNbYB%j%6!OBp8GeG!ZuwVYE9e2kJk%>F#-(}?DP=gngWo9+M zVgfd4Dob2)o&NO{bMMF%l2(QWJ?tZ)KZ^pb4 zJ3h|8jw<*zzMUV@_47p*pL}|6R*Nsa`3*o&3@p|c$#ApSas3SE#h)LQO5~{f&drwb zsGPcMUz+yBc>fmON!B_doy(5V)r@52hg+Kh5U?%?wqlQ`M)BRhoFY*WvWup}iVyAY zQV957dTo1A9dcot>R^7c1FvbyfF+)=+&@7Kob^SeZGCicM0JDr?iDB;l7um=6 ztZ0Nc1WrTT@|Un}iJVn_P66@%g0C*Tvhj5!ShY9(Ng7*PgkOY|L4hGT58JgMI-__S zVgQm>#e06A&;JaU-R#%K8|=PvEIl*!wZCKPHA^&70@-cy-7&6j&P6y7F;z)j|- z9?eT(tg&Fu9{uW`7S)XaV(Le70I?4(}MW^Dba545An$^rhP`J2dA{ z9UhG63q5g#CInVv!&-%{wD2l2KXZKdsr1VeQzY-$H=Wa+ds=38gWrKNLC`?lzoVFW z5S+D_H8B#&S4VjdHTDWocQJNvWBo_x?>{H6?{d|W&T>>>i9s6mm6HNVQJ|gRi*4|> z-MA~|yFOPlfq}1P2rV)lL#k}=!b*)} zOJ^5_$~ccYW-A{U02%rOSGY;2XyhJ;PFAK|be6nNKOgP_Umd5&-f6OVzm836j`pHF zfaXgNV$5$rcBw-6tK08ouL352Fv@@lfBdg1ZdjO_pGlPAACQoLl1FHPSh^2|RNf;o z_?P0 ztSZ~`3w+XOd+R@h6mM2KS*q%Q{S4rF(hjvNA_543oKImuZ#2c$X!~H&fkE>D$ zWSt2H1PM$D5&%?C)lYM~%cU=**QPh4|O3DFFzf1^s?~`5#04 zj%!S=tlISLTir&4U)v|Lg@A<)aHM_W)UGbyt6gdqT+lvwe(pV2v+XecH{eYT!aVkg zn~bIQkxT87`nP39J0@t&zrukaSJ1~6xRdbKYd5SPj+D87HF;?c9+qE;=`n-U{Y(b8=E)D>c%>kx|-j;fcgUfAP zk37xn!ub`IfPrmrY{9CD9Yh&^|8qoTN3SQ&c5)8Un)!|QCt@Ja9DMCB>JuQ?Aglt& z2yC5KcI|Sj_B#}Gx<-MF2h8B{KGak>(ZBOF#Uzr#`=do~s6QcRaLfDE^hCvBPl-)@ zJg=m6*k+bRG6_c;-C?xIsEf9QQzM@_uouS) z6kIH*+wze?*}!azZjn*FixtO;ry_DhO5>t=KKGJ zYf!Fs1T&cdRjML7&Y=I?$nTL92yZ`@bcdX6U%1Cf-K~+!aJT-4?upd{?)>ksu4#+= z3?H8&1p^MSgmm{lJ*{|YD|tF`{~N92qXY1Z`zE@*VLCm=24Oq@wLh^9d=d*A zL<7nMW5=Cm?Ns?(tYj&!L?js^<BW=1I>n?c} z9t2r}#pjG?c76-{LLJ#`HDg%!_KM~NQJn()M^+Kko2%4YeEI1*UM}4(zjeGuORf&b zC0zyPc%k!&)g{udGd>MdLt~(3a8j#~{!oc+dD!YoLNGDyVbW9ld21cJ&AjOIq659B za8i0c{pLb3T?CE42(>?F=dYoO)9x^)YUyomkdA<1V(qnBuSfmxLY<$lbiKPfF;VNj zxFfD8SQgHNLT}kB>Dg`Ze%3xB8qEQPm{)o*%YJW^Z)fh9G*bgh zW_6aMbjgL-l=YE*pPgveEvt@O#eWiWMHtL(?eU{MWF8QO}l~v?4>V_4_CHJDSq0dKmzI08{o6odMH(*t>C4nfg zm?k4TeHkA!FCqRy^eckFz4o;7C8{933ZslGa#y3wId1tDDt6`AXlq{Yu#Ww;zI3I- zcit0wW9GDdCp@Y@1X}*jL2F*qc~~(`&))XJBXgv`td$Q= zdg4b(Lv8beL&4x1YjY24n5uIF4X}G;EaKlD`q+y2FYm?V{eJRf6FX0TGM&3-TfZuI zJS)N58dY8*xF+f6f(apuyaEItgYHR*SPgu5E|UhQO5^dM=v4}$J1HNV$9c`t`!t)u zJbffoL3nFVl5Y-q} zz0nJUmpsf8U71t;OZheXoF2FQe(Nv|HyAe+vu^6^G~uw~f88sW=-n%?Rtyw|##tma z7{r;@INQYpzwcFxL5&n^=QUpej38$T3e_?aOTbXC5KyuE4de8fLF{^I-aaS%#?^Mq zsoOFgQ%}QDxd#n!wb>V+YwW$HT#qlOMaN)RP`Eq4B|bq0t+q_NRF!TL5ddm!}r46Sa4|fhg2f=%R>t&#pik%)e*t(54 z>V9MRK=1$WM&6K{Swg8NQ|noi3rr_nU~h5s@1qL2`jpR})@XDe z@?%OW`rii;A{@?khn7<9g&z1YDVXxLAjYOrkef38D+yY7x}MYj5enwz?%_n&(J@;4 zH%5fsS^1Fhy^eT0RL^Qrr!Hy@en%{s$od+%_D!R`)=VDs#75uA*_1d{`rk{@Lq;Rq zC9Jwhq&6v4rQ@JnP*hAC*%uj;D=4}1PibalaFK|mw`SjM1f#zYZBBW)ggmiKDo6#? zF=EKmW$L?D5t8obOVm^r*nRI?rCA~uECCB~Xh~`J15tsJ+)mXT+9xqNvF5*R+?L$V zg&)i_1qesQq$n4NY`rhd6w!6=U7G0N?~N!7f!xQ8_D1#z7VSBAbVv$&2i|J>mSFGx5LE4lHwtJ~&mJU{ zexvJp5pBbZ)#zl^Js#XZxQnBHbavn4N^Js01irk)pL0&B<4~5Ce9LQrLC4G zI{8t*E82=)6`lGN2f9}eLG&LA5M`(mmaL@lqt?sqC%?zIPlXFOtvg2c^8@EIF0DBp z^pUF{dhoZTw0MtIk?s6x#=7^qknk5b%hMj%ep$Y2o(o=59^oRau3$O&^W6ATJlqT& z>@mK822YJfZHS42UC;iScV%}hE!~1r!p$FcA;%i%bYHZGBlT14Qd~>Eb*chM;62)) z`pSb3zsK(?a4;1lI|jcHHRNs9nW*|>&qL{Yic*1m1P=hnarwGs)>F&$^& zoPq*@8Z=stB^%*-&Xj%PG5NYUtzDF6U7p92^BwGqj@?(R-uh*-qPcZs4oV%^3?nQ{ zV~+T0VZS&EySHVusF?%(tfyzUqskK4-(%ePdtt?kQR>`I%-MFo*Zyo$P|D>{Ilt=b z>FLODox`8?h(u^ei34*cRfp)Eb;T5cst zY(M91Z{z0XYzFN}xrp9UO2O#&w$V?J)Tjq0ah*el3FLtLD=_^TKJC9NB0M$0QcV@Z zyX8Mdsnu6=f&``1<@HeTA`Ch0?0$mN|EY4;*6ucC2 zY_&Om`Mpi#v#n_kt8OMyJYfmBNg<>%O<oxvR$Tuyp+#Z zH2Be}4PF__XDGQr)ZLVu;4fq~yZB8`T7CRQV>qL{ZwbWjTrab%Jx9&}L7P+|62Fx4 z7xtwJVr=&mlpEBafP`_yNT3&)H16!QCCy^ADvlhDW5P{U?U9rn5etTGRa@3x}_)v8md=1HEPV;*reWsAg!v2rzmND zddnK7wsqIkipbfaLzI3UTE)X?Ce(AQh@hsqgJ%Yr5+P8CJ0#m&{4?Tgdsv4rvG6(( z@a0u*cAoBuXEEvv`?$q)!RJ+S+xM=;9(vyHly04F9g+fbM(H&5^V~L*V~Ipg2rftK zLx2$?z3;$^?r{J*&>;7}dbM;_8`0MA}h^Duj#;HepFDWR3QefbX z!xfE66p~Y1aHwo?bY!AH@Xm)(eO0ySJZ)^i2r7K_^YcKetB&A)?Gx{H*&;!S!4%3s zOZu@{+T?oq)DU1L3RLb^H21D#UkWXQYyZ3flDM0tDEh#cqGBs6c|~x6^6>S^#InV% zw4nqh^U_M{APK@(A4-*<6?iNPvU=kwRaJNxjry2UMGTRApP(U-P9vb31q7zL%7ZkL zmpSN39%z=>3-C?}$CIuXb$n53Uvw;T%4;O9lgOYze&3zi7NeF(q|QEiqqMDeTbTos zBYLAevK0Wi_9H!EDW|ifrS@K4o^MTD)gF56jUN@y;%aue(<|TebuQeCsJaGtgP$=x zGImr}qiWLUde8SUC}u9eeKf69-RVy&V}EAJ*r6y_`wM!KfuDOSU^;HxkQDi4ak^4F z#dUuRB+JbQ6nb$aA8gT^8_-k#ad+~k5J*a;^KPf8aOBQ5wi>3;moLG!+akhCCxKiXLreowwI9tv~O4|36f{6tTQGE%M)h_kfh&R^WF* zp5t;B7%GNp7$34Q_72ep>n{lJg7?mY-hHv329Ki;dA_Bl2liDT*TeYoXDOck`XO6% zwTpE9Sajy<$9KhBrO()T*k1QwU2rmtU$oPbhe+mOt>U#u4CK=Hn+o#pzc?y1#1XQw zGZmGalI_msTS;eE2qar1k40K63F&GAF@G;29FLqqumkx*0$|Y8J-z!*LbA$0={*~{ z5xy(EK~r|%>(Y$wh@?2bFxMKD%tLU4@PqKKNuC?kbLQjvNF8g~2@* z()07^{hS?nNuV>l4YkIy0|QH-F3xN&2t*OS{!y|2?|6P(wEFD+mwLUu0GyKGH5FFW ziOBjN8JkGnm{CAo7BsHyg}j^B@hCL&FpFcL*?ZlB@ni0t^+q2^r!ByE-1LSPQ0F2@ z3gN$L0}$ySjHepdPEI_nZzL(E969f5dGqUbB@~0pq9aUd7+0fkJ-kwmP`bVvp&sN=E6V}cu7`9 z1Na{AV^Obm+%y~Y2ayl zZQw~H`0yX_p^nwL$?AV>ui9v&n00}B@JYax(6r!dQhoUwGQ|Y@iYcjca)s;QmjkWQ zkGNM($M@6+X75qSkPrYG_cGn8%M%vz_gv3$K9St8n30(Nwm%#8MyC_7d5Kd14P)Q2 zc(b{w^eY%2dE!lP@rZy!#4AfpR(snDGln2W4~K~|6#x7EV!3Nnx!|_ITbX(OT$2Ap z0c{n~=t7Fi z*!>RJedN7ibGz|7fOat0rqCKU_;r3nuLV47sDP__Z%3AaCYUsQ=^$(tYHDBYxS{M@ zGLg@kL7c@Wm)%uQ+CLzIxNaI38yf2w_)J$Z*xty` z*w7lRfk?W8y%9Dyk?R3--D|F*KBkhXg#WgIQ&cz(t9{H9c>t`WgOk~ww@YKzW3!05 zn{wU1=N`3;R`a|yF;Jl^A-P&}1iKxQTSM@GMAzobXU@%u#@S4zQ$J~BSOmsM21Y=;zAtq0(zgF0F(91ZV3@@xOVyh zZ@`&V_{DmAD69MsDidJ*?_q*(`rtL-eU6B*`P)C7hUHb$yTR%fgX>v)roCj30tusA zxhZPQ>-co=DkaLy3#^f}5aiCpXR7D+m$s8Ml*f|hQvWG^G9KHCRkq+6t(4|}?>!*A zSH?8D*<>3}J&-}octNyaN0Nj2qas0fs0XC`|s>>sHM^!uedc z?>aUMe9`C)Xi$!DT7k`sqP83~0=D+CnCrK!|}T zg6DSF6GS3POlV!x%c!ei#PFGrK?QE0$V+hL)tEnj=XZj-fAA0hln6=ODS)6VU*$#& zPgD!AyqK2f5b!P8VG`TQQi+z5gg^AN6_Ipy6J%yi@;V^H7fYhEPEu|9J8(9L`xYt| zS2JGqZblMDV$w#|Fm&UW9Pbkshu7&6elCwIyVAF}-UPoiP9w;7C8bhv;lE>59|I!P zph@FiN|fi!;ctdSj|uw!t|rv|3MJR8qs}SIRO6%|cyvwl&*sZr0rbe(aTW%L`mpFq z9OT((rsT8b&X9||qVmrs>Zm(d{hapJ_;R=0B2=>f2fn!!!Gk;I;#J0rWIziAAyjMIx{u*zlFe5zK4sZ)MbXvvY*M4XCrqZigzl%gk2Ew@?rM+Q0`j%0~*^k42sfTRXSmLaA6IFbG zKK>l&`qR%BRNsyr=e+fIKNfAoA|x?-Y{W-nT*5gg^HSf#=Y4Y>`lGz42V{YKLV2b4 z*?3*OvjSLUDBc_!Pude=n$6#SWr;doLVTzuuQU;clRw%Ilg%Q- z%L@lISUxy9o2@;TydI--In6c_5bQ_8BRXVIHL|c3-0}m@ILxC zB@%cfTlBfPd(%BEWB4~woM#l2_kDo-P~CWG&( z+;+RxqxuG?*;~eQ`mTKF;%K7?!*a@s_bL{WQ_j^{cCQD>C@5JLA_C$-1g#QxEPV!A zt@(UO(CcV*m1paS!^0Gj(|gQzr{totcDj3;=8rfI3vzc-?lxs#Gzrr0m#|HAY$}Wdf0%itZcWqPcei2j>Kq;hcS%fBuv+BLe*aAw?3#ZU+&%iL)1J?<9$ELG zyy*F+x%)fhvy-d7Ol?1x?l1}&S@26$P(Z8AxKK_-)EH?pEb7!2$@egtTlRQT71?|A ztm+--;13g-hLY!zJ1P5|GyC-vLym!$acFzI^~LuX+Mbc#HiD=GGZeemy7olsXwz-W z*E5yYC?qxhG?yB;CWOYHQ7e&YIY*D#(vMk8Z)T5aM}jJ2#{`49fW7=BFuMnc`Qo(vY#Ca%tQc4H^3rPG|0`e*DFhi+WYU z4JqRqPbD4HsO4>QF5{7Z`q#+?c7K99j6dg2?^QV`Cl3JHRH@$+|f zTKez-8O{W5lfT;)W31V?9#OoafJcv_&tRTEV67vFG{%w1I#67M1w@WFI-Ijav-N&q zw}=o0VU^k6M_Hk;T;#el_t;XE<3z>wMdvN#YVQD|U36O6OgXZgpCCXnoi~A3Jir2C z25-mMfyNel_4m?vF};Yo?X1o5BJU;iU{&Co9fQe$=kf3Ajz4dZ?TF~P#)({S;N9w5 z6>ZQQZz?L?jj@XS#;*(CGC%PYX(h^6BE)#fkF9rLU7d0dscv30xU8VydS0K_4J!W} z-jdg2#9xm6vuPfMTN*9Ef3wn@CQ;CI9{R2fY<>n0dm~Y8I##yzH%d8|%h_PYg`V5p zXu4T^<{o#`we5|8Pr+K|;0&k(JuP~0ovJE&t10YpT>~!uMTn7G*D?Y?#O}r?kDkuC zVb@C(yD&!Y#@$N}*T4*s#Ijt9ti4QKL>{s?bPL5cgBo5Ba*vHVRax3^TU!UEk9s=Z z#Tiw=U#;691=jpG1wL>9kH#G)bW3JmAiYzoyE79sPFh~38y*Ijvkjv$fqQQ$$6iN2 zyss8`_2e_Sk@L7SbH*ZhGrK5$;Z7*fO%V6$biMW=Q)e{_S_mjl-AQ`j(H=czd9)t0(7{V%$ z4HNDY6mX5${Ylnh(?YZ1cQf5)5yH8ixS5_IRFAKgqnd%wVc56hVn>Nsp5YCD9)1FD+&qCmGOIB|DY zDU&My)q-E=gRO!-%T!9_Tnjo4*kMnqTYB3EW}=HO;lKEDYP3=-p@?Jt{E<4Eb#BRuLY+o85}!Ft@AUCx7Sji;?FO2tu|^;xKGgQ z_~FDdlHk{CLG{{x$6iqUiaO`+O7 zI_(TUWF@6IVBYT9k$Xw_$3S572k1rGBO~y%Jn$mT(Mh?m|L#QrW=^sJut#2e2DRUx!DY(+IA$~`{?_@ZIM&)`lPp8HpQ1)Ztn}0FQGoSmLXg=e zPmBm{J_Xd@g3OIke#8xZjz^{o<4#yl%He1$vg-BClg6ET3g)|AS-hyxM$Yj%&ZrOk z^o6dZGHirurxQp9IEwMOy}T=hw1VVuzvFfiS(=j=awcIOXbX6}98c%J7z`MRPVa}wthzxl@<9{Jl%pSvRS zciDsGa{aL__@j|a%<;ZgonoLNPk2)#t#J%E8KXaelkxJDuGVfPW{^m>o!{t`Ni;q? z!r}P6B~cEDA)W%ahu*&zY>Pi`g4Pv*2hf9A0Y9+*#3K47pKhbU6Ug z=>|b^2iKlcLA@5qGH=J#M(90QBHVj}EOuxE4DO5Swo7bO(s|?m8>e zckql`&!jnD1uSJcNY?E(A^eTQ4?fnP81Pa$#ZXSYQ>KA`91JURzcahq=8_+-bvYjCGP%*6d^jt)!Idb5&(M|DTA3RIHut=EA~6 zhDkzfz8#IRa^SluBItvoB}hdBW3e;ZSJl-5V@^k=7QE$eV1 zgt=`xE9N4#Rh5zP{~i^S4`I|j3AW(LUbGysY||C08+&o}r0u9Cnc?Gkh+lB(7Q+p_ z9plE2jR}mSdg3j+8m%>B9)<92`_*!sqD!WM7^(UWQ=%WFXoi2j)#2w&q7~WnRm`;F zDOA20!X!6|*A4S0f5JoxaW)?F^DiEa-~H@!F=5tme+9AsSGi#&>C5wlkxIoxnxw`O zintYEM-Bv~9xDH-Msy|6zuP`Lmkr^@OpMyudTmDhRLfQX5F7_Qb6JC)$e>+dAkhHO z4sYp3()I&|E2*;}5ZZ|AnVKX;t4=w6mMFz!4Joaq{*=6U^Z6y?dFR?6jmB_N(hlG6 z`sSZEI=kf~*@q7=7xQx$H|OO>k0G3f53SHqUChRFlWm=92pR^*fE_E?=gjue_irbz zhCYZNy~b_(xGuxQ_&)KkTbV3>!UvtUwhk>ne9}8zh~JBK>t0fJ7uWXqcp+LAApKX|LvAuIJ32x`93aNh*an^ zw9KynME#Py#f`l8*wC`Rz}p-OJykZH1jH;q-1GxA)&0^r(2lBNq!37@x#aE6M|ueV z+JtGlw26__$6Lm0cw=7LxG6CvlEoR85Ci+q;B^Jtx?BETQ~3C^nno4#x;Wln@bCNh zlU^ELwo5W3rL6&zOoE z7}NMKKUPqtf`0h@&t!i~Y5FtEGpy85iai~zF8t7m>RwWTAMy`)%Jq!SV9h_=?znIZ zS#yQ4qIT`u-*6bQ*+<&Tlfn&XZO#!bP;}M z0sV>!cjiZg0W+V_wRfemlbUyz>=N2xM7eY6rVT-J3zS0UY=;LEo+0YodACEHh&sE) zCB)n=he_^NFMr|GOA%Xa8O>*bTJavGvmA@fZara_Twjftu2-+aI|s{Z?-JJ|p9_s8^-dc_9i>V_d@)8K>JAegJ1a< zuX8iC7jlekc<%V0)n_BEDzTtOyGMHrgV|L@elpX=#Pb06g=;1Rm2V3jq+;qe8#LFB zS8{&dE&I-5MDGhTZ4G<&^+C2DEFzXMR!xwDl4!ElM()+;`ZB2?$kM)PT|6X8Q#w#{ zL!8co5;$F0s&s(wX5Nt(X)^yRx4=F`+#};SC=cG^wL9Zb4v_ z75ueO2bbePS`u2*P;~?E5Yo5`$fA6QFKfZYVs^nu@CH)Xh*lom)X8v1&H9CNv5Uz` z{>6Jb9Jd?Ut9owk5g60~kv`8FFGHh{+JF7cUaK-m_l57N{wW^RqCA1K?c() zY5f3kKLnHaN4&M2f54H@d-2WDvNDO-wOq7c1o87n#^I$s7@G^)NJ5V;4NBW%b-c}{l(3VZQ>hHm6#tMznmB*Z%PI(|e84R$WX9!klh_C>oE;#!sOIASrKq!F>m1G}C~} z-E<~+eWn&Qrzzl)75k=RmREZ8Zq;gT!v?n6+SSol`Ju%0%HfjePm=*&?06}A9>Q=T zRExm73NI*h;T_*%VoXkl^{LB5On2Xhi+Q;_rYYY9p@_@Zvc#O+1uT+|jD#2M^53K1 zuys(qZ`wIJ`_3sU6bG+6k;14+cj;7(aX$pX9sFb%T}Nm`)b-Pr*c9GRyPc)Z3fwsO zX_Th?Rpy%cTQ&_XXA79)_|DC{Dr+t2iw7|pN;jSjpRe!{z`mN=8JaM74V-v-PJj2U0=K6nupifL|#n-=h_)ZdFgJ zeSP0z3Ns~YQuw4QvQt!3&UQ}W1US|-WAx%1_4E@c-&b?*T$@<4t9iYr94FRWwvFlR%89y^m1esBw@^g< zsIdhA1dL91S$W^YxNdrJ&wEI%uSId5DBn-vemFIif?$Nm@fl=S<3uztX?%@OuznKb zF<7Mbv{F1Jwc(3F6$!_&?#zHl76*2z-1DtB`yVVwy$Lfukx1Sde7O=NF?wL+IA4&y zUH9>f#f?68FG9dt`$L&rjx(R5dEKtSFA9Y$-|JIf4!Y4`%nAJZ z)UUirBzFWQ=+(qCXmAM7>yt(}uiJ9xNQ*%OxR*M4sVkFz?i+u`Lw&u+n4Ip4Bjh7^gtjqmF zlx99t!XM964#&NOlI|G9FH`jiK6WJP#euHw8w9W%_CfK+4J1KEa2l|De{1*`&Zf(5_Fk_(2$GnLnRM=wMh~gy4cy45BIq4qc6kIO zJ8y*6`R=d-8n=5?ViGh{r{pme`D$MR=OrP&wuC*Fix_WN8g1z#Z8hy2CWrnQU7&^9 z?8C3+-Te4GjOY#7^zs_cMd2_rAGb_lsQ3+cNUx6xP%74R4?ljpbXv8eJ1c4ni_sK` z47rib#Y}vg1qgC8Yazk>bKcxuxA5!n4?o9W>T3UIqxqZRyOuB=(FO6?%1z zKm5wAY=VqOpvfynOlpUt0G@tcY)O|P)>fVuTl+O}K6C@yoSMNylQ3h!o8MiWAm;I8 zjbSbP%HqA|xD;@%pe7V}_JChOw^oJV@^MYHrR~rGI633$f0jHRngRXsK0WIbx zErv0hHF!s8xJ@>&k4Fto1}WhM{KN{J+f$Nb-rm>?Y$7)ft6XgLMK)e*g0m>{B_3AmNA~m7HyI!%9%!?=WO+2}q zzY#aRqhmusrnkxCV(hM8kre9u$Xek&MlWOf?QgCWj)?s&fId^>l2}&p8jVA^`MA5t#hO|`Wvu%mriq8M>Io~6A~&Gw*Z0Ut1l4k#mEO#AfMD<;v;5#9 zM!=U8iCe6xu+ZGPMxgwawc1_8uu8pZ>0^EN)qj07BC9KhKOu9&TsGknr1tNWq6?+9X~7@Z1nuVo zhDdySWwP)fDS(x!l1r2y`3gSI@!7l7f~igXIB%8oHqY~w8r)xv!v##j%B#wzwQB3i z2bfxln8LMu4X3)Biiq`%zH~~H5OD{CHlMK`R+O?XOy2{8!F*NsnY?p(Jp`fg98%00 z2nA2FxJ8%mnNe)LD!}!#Cf~#Dt~T#P=hR+s00&NYP83z@N1#;IGvTI-ba6Nw?z)Fw z4Djta7R6j)>^XOx?$ZgclJ-{f!_uOTj^D%?|DJ6&$b}@)__@cW2v(nb`Z?{kI{Z&Z zo#%$JcnEZuU-LcN)6Vbq6xyK^u{Lgds0&xlEW*9bE+b#9&>k7Lf=8l5s401TBX;Rd3V7bH=%;UAp3 z;$)R~aM`H$w0)cXRByjdD_CrUN3dDX^fvU`CBB~+3LE;q zp}mpI^uf`6j{S~W_bFH7b-e}nqbh$CokwrvC1?R;WF!`?id=%97NXJ2QaNYR zxA%)fYO0l~t8-?NO{Ua(3#OjV{56!rt7*0C98kMw9=>nQNf>cs(Efy+{Yyq8a5$d3 zER3J6a*UWb;pUv)k61j?*UdbByMvzPRnujFn_SFaJk^~vH;nQikwoLqw&Jm_`iiq4 zUI`^%4cv&6S2#9?)KlpMreA6G0JG|K6uiz{z15X^@^(jambb|?yF#dWR)b>2fjdMOMQRH_I&;=o&AD~9hyFYt?Glyy^vpV!i<0;V9(Wah9 z+{k;tV5^}tY97G3V#Y-s()}+N8fhcCMjaVpx=je`78M3<=}JXsha{9nW()x`A6llu zYd#X+ZW3~!uIHuuf=!B|7o1slf-3vMz$e4cZWLHyu= z*(BiFVibcZ?ox}hfM|b?B11}^bZxU zbxfb1qt@Zm@h=NEe0V|zYs-+5f&RNj}YQ~ASgMb82@kxWIYrG@^7Pnk(j|)0z)6`6JXw$0O zu{nIBdDf`EB^r$lVJ@#Isq36L%4_)5zVIz^3l!Bxbw3%T4!^F~bI&7P&%%`)<|q}Qhn*>nG~nRljdsx z*2&3MwJJT$x#Mi-6qp*U^gmOwTMo~q~pbb#^gV4qaliY*_2$y>b~V?u@Z8RI*_=Xjz9PwDB@LC6QeG;u%TPNRQ1wddh9 zZqy>D;;`dTJj8>!MUvrC=01DXs_HbKBVp|>V8`V*epAH@-s3J>_HSj4oh&*#nb zlAMhd41fytzbT}T!bQn5{&6N}9HPbu9NMn0g(35#nErL}3UttZgO?Ej?c+0JJ+k*M z9?RYHz}?SXVF-T!+LON{eHbrwbbzaBDXb^|?r{^tcWBwJrEa%Np1-@A;sX!)9mhij zordA3?6{p`UCj-@vcDmxIbpwK+rZdPZRBHpwxZWT&S7L#Zm>R3xSvv0pIwep3HL0z zzrj<;t41iv4AhHW+>~vbt_KEfmzS$tausf+Il~yQHX31+(1hY>_*f_G;-@ZsplW;{ zip49&C_3ryq%wY(UBouqr3`!vj;9hX$$Nh)GUE0DPhOe*72rXQVL#MduPl7PS;d}_ zzxWX`%|uUQMVd$+4RYGpBTt8NokGs0l*hGsbANiCPOy<@iTLT&*H;j`~=>LJc zDn7&(g>C=lg8#Ct1Si|oPwj%|_SQ=#E{4{>J)-`urCtH2(z?I+2aY$S1R411j^6{6 zZ^%f;1nbkOBxnlsrE-MrIxdZPy4|f@v7|F$E<3+2Jx%w}zYwqUqVFj%vSTf>Puj2Q z`79&*oJ`{r*sZle2AZTaV5y8hh1@K$mpvu3V+CgzWjI2>p|rzkLXo*T{D==-YKwbKHD zH~HIS@(ACVAy6RMvyovoI1b7pJrPIvidFj?Y6G8(7uBkkc5_Z--A*07WEJ<^onUI; zqBRAr#(zxOEL61jbo*6E&*>-F*m0C21`8Y?< z@JHl!Tiwu3(DiB>Tjz=h-ru;K8)6!o1isUx!axTUlMUTpA55FHUPKiq=Omn^=wLepL zokW9ogQvUy8I&at?1cq6J-4>aAPJ9?&8P&X@|4R7rWLgdU$T$nO&Tii6^KL^>xl@^ zUlh78BJ$?Sc)nkPh<&qH4Qy}KVj~M?TB7#NhGYJkO&5vE9jUCV$gJS1kL+%)(>$Up zoFa8=GhfjD>0|jhNc%?}C4ui-N`q-j_ykXFG-(B{=pYU^iNHX95=ai=3Dbv&8Fl)J z0(YdZHy#~56~Al8H%zghHDG#N%YjzpyyWiqBxXhYp`1ankX>EhiTSH8u2(w#>_Zvs zU*sQ;d*-^IHObo^eBy!^hN=fSN~KkuYE^BmI_k&AG(}oG)#NSWZ5EIvfE@7RNMLqn zHybw>lHV@hW%2s(PRYKbZ)>(gPP|0FCX8Rb#k_g5duZa4kO<#iJba&!Kh+rS;6ZT1z4uyX4HDr#02^08A|qcWwj9z(M?!3ri6a$dduz1Fz^yE@q8zu^1s>bd&?GFgG{h5=rM z2u5_o6D9`ZI~nc^(b+@eO`Xl;RYN(aHT}4EEvqLf;UrRI4xi^6_Et@Gt1758y7Cif zyn+|LNrUuX9vGSz8U!``-earO4mfS=Q;T;12%f>6W&HT~yj!_nM6lJ7U_YpQ!Po8p ziMLE(kMy-$OGKr|$Blm{Z$N`+Z(zQ4Ctv+Y{o>Jkae$fo zc_77^_!3_S4Jw+4LD@H8jK7?-|K5IJH=`OTrbPrzfpkJ>>8ju_u<6seEZ$YcQzbKx z0OWjZ3>aqjTrZb4b9)}s!Tra#B{p~#d*#&E2d_dlR$y3V&>h+zF&FcV0tujQJT}ZF zfU4~(?+pIH2gyjT8xe@zs{+w7GjjlEP*yfm^ zOnCFpkFj!{+LKq3!nlVb8lZz`}TPgHyHId1g$22<0qHkBB~ z?6>XoZFcmfr&z-&pjM!ELgd%~`x<_|;GPAg1snM9g-z=q92IU6d(Q$rDpAs|X_7u> zWFnovJs-bH2UBO4vRVX;w8QlGb(_Wr5}m(cF>ulq?0*z&si@Z{o06a9L;~Tnwr?llxrowp zm(fY!k>18b7)!~lTaU>X;lXtOqrjuIDm?UF5Gsowx(!h6p|ILIoa^{xICZ!>wYvV% ze1MqOw6lWGc*n{R%a=Yu0`GaSdy3cdA3fX;tN(ZkNNBm$zGo_LPj6ZslNFdusrBUI zKTn1C_3tLHBhFIRQ2XaK#Z7N>u50b3_x#?iUXELK>m%j5N$mX*2x7_a6MTFHE6Vpc zP-inSQ%`p#+;_(;=9XUvDc#LA)$dl@()Fx6a1L?iZodcMB+Kz_Q@G7RNCBU08`jvO zcEzgN!(lIPMy7=S{KzCC_-W;+O=9c%6LEk1(OJ-=em%t|48K z2FRW?pr^65N55o~703}#A_G{BAEV{<*(Z4wMsa8jmi~WSMW#R*=ry2HR!zMK)0LhU z>G3JN3Z4c^&mc0c`&H4rUIN1l5y2m-zG@AmBM-b#$G6$f<=|v>bYQ4UI>@|kTLfn# zq4#y*8j!pjK$gE4aPwZm`Ft^&)NA2mP^9A84jnS--oT}E%#PFC^bh&{CD-+V1OsMgQ?6* z=hereJ5CSP@F+-qvdQ_J>Uj7)DZnxyRtJ&O3f49R<)pv)Idwi9AVQMK#lbnXO$bw? zi1AP@TL#|$Wb1uC;dg;81<@MjjIb!RtxLb^2%Qt)BX7$ z4(&d{h2Zqh82zucoP(N9A8IpwC4KnO%yNeoJ>)+yNDL_kdLhzW)|x*xcez-zg}?SV z8_92r$F9t*Q!;xza)b3;3ravX=V8%*izD8r`(5Zc-ug0-E{dxOXKmLVEI%Eh=hnCX zbeQUon%Equ^s-wWB+_Drb^**XMEy4*$I7avLfA(3=XfCf34nN_Jnz;XY-!hopW2t4 zE5y4sc!l6-aT2>!EshLxwmEb(pu!Dc&W-Cq-e*ytNFd=#vkwLX+!Pe|wXOEwjOb0c zV7J>M3a4>BZiVXdv4zSXdtFxz1l%Xn){mQ2<8Wf`e}8v--DA#H6F`PwH#kIF9AEd9 zT8r>+uiqQs#ca?(t>AVT2;iEi^GgW+FlkHBq7^)~_FDUJSS{go$L$z{A=VVW;j&-8 zew=IVanQpX{b%WJnd?@ifa#XYQfm27nO5NPcwY;1RJjkN%v^d#YL)BCC&^_!;Unt_=Oav*Y}I^EnG9iwUjf z9@f_O9>r4H@cNDFcZ+|`QOj!^;<))5F-PI+ac9{+{G0xlq)3&f*V) zLq07#;pda4DdrPyOyQEA4W<0fqZ<4Bl`Ga(@_Mlz5AkOTZm@$*0$ChW$1m7gPtT3HGee~nq&>2obiHiZ%5LeF7CxEg zX!btTDA@bC5`{f{0`22L#$1e%dGLEcnJ;;a}%+X{UrJ79HLM*25SBiTYHoAyrJR|9hJ;6wE$GF zRR|f6fcs2q8-{_VjFwPi(M6RC0M>b74rsb0-zD2%Vo2#rhpHLxW;pkV3OeZ_8n=6J zyQ%VtES*_?7jy3xxGqhXmC?Q-rekmRJ-o5=`|7FP`0MwY}Pwz9` zcX@uJMwj1t5-&HjW+(KRVc2<7*+L1gSr&yS>&n2McG7dQJq#Djr_th447|31m<{nf z`aPiVfr7l^0$~QIr%`-`AB3B@{hX8d^!Z%m@NI=HhFgy@=GX3Se^ck=ed=jc0-Y&% zo))Ix3?H2sAe#QzbgD&bw6&mdr#2a)0@#>0z1csK5UQZr#`Cvmi*n_nD?N=4hhC=G z=7wuTpOE~;P5B|!O--@$>3&GIc=11S2Z{V44Stfiyg@iwN_~R`^#1bF0KG z0J3S~vDT;EECEJ@8aeGs#WFLiCWD)K_css5@NAp800;451=Fbw%^ne{(ch} zXVsaLhw9ZXmU!~#dmU`-3uTA0mzm*Kukw_dIGliN40p1QU|rjKx{wZPJ~f zY`*Jnj1E=L@4k#;PHViJTg{E?*Zg?AN2mAhIsALF?@-Jm-675E&S;kG&I0xyni`zy zI+d{vVzyl=KHls=4gNiXO2o|jS)FyquRHJ}E~F_OedG4>@G3ZwYW>RT>7UP0t)vI7T_D@H9wSM?X-xwopQSfvbr=kK8NQI}){TdcL*-FT}9 zmhe_cZ81Q(eJd^LlN?O{cf*>gnNM2-Tj7^bHjxfW%4+wgqT9RQ*OxGQnd{dZH3*N> zy0Qy{*3@Bixy+lKL=%rIp3v)-_7f;c@i;c#*ae*Fnfs33Mfcv@BK?FSi>ny`7e|qP z@={eUbH$Em!Ux=$`(7=FG1>&~>Z;%GsX3rR1n9DNJ^OmVUsgTS7)xs25)lb60a0ZR zn5A@q!}7w)dhPsoCC`MQlxuG(x-O_rE_hy3a`23PH&kle3M9Uh*>|nwm0OdG>(}eQ zTR096iAB?8g!-~VtE*{VrAHhC_ns$g&S-n)VGB9`%$D%e-^00g`D2P+IBaZu)k1dI zvr;OUlInYMjrtd?Es14S(-^9JRk9Pv3HfW8vA3kkK{}L{RW=`{$qK}Kq{2b0o04F=8VvN8ZqlP$FOC` zjK@$sV<~Xw32%%{W?|1C8M#0eO`QQ8&x+cj*3+YF0kyeW#bYG`^jpK^-aI}kBNv2q zDxrNK8Wo)?U61wN3AL=p`uopr&~u#-xISnOyP;k5!o;%O6+>OG3wi?C?TSuRVxBeG zd}jO}&I^gD;@$|Kun}VXWBz?u?HS!u99L7?GJnZhZF z326$>#9`o5&OpYMTE|X!ZhiWG$lT(3T(UzCZm262SuJZ^a^@Hp6CQA#eIL#kgsaZ` zX{jsPTV^FG`G&HqC?x;h#@xCM#yJ32o$TQrR1$)mk*SVf9b+_R`uIZSb-t;-TqAz~ z?B5t3i?ZOT#N2Dju3a-weHj-{dA@GHhLRAmJx!8LGd)b$z~L0s1WR%C{>|VB^mVo7 zME9w!wbh8AUH?uqi8>4;cJchNr7!HfhnL7VjhB_H&zoBCQv~j@UQBX^?Y)l?uw37Z z7OUH0#?3=c!3pQ9TM0td7BxaTZ2Tm+Yi^RoxB1rT3#Nm|E&LpcP5>qM&~XaI|--}KtAy5?-pH9pjjfasTPNy(_7dRv^t9V7CVB*Ln zYqpNCV$^ z;)HUy`Ft4eRg1uagy$cG*x|6zGyrI!7qNF36uQA&oyUER|1l@&3dq?l%m%YRjJFa) z2ONFBCGGH_u&cijfe5<=cVR*{GkkpV>i~5=l()%GF1Z1$ZN0q%hACy9BTp2SnTnf0 z&|6lHUUrdVV1IgecK&?;#&?*mZC4>ca2tsH zD)XfcdbW~jx7*>@rg|Gn<2V-cWE2x_!UZ@NW(()a~7ThnTTzFR{7EUSuLCae+{3>DW!;s9=QuE<+q-Wxt4}YtYO9pDh zU3a_f{M7Tm*HC$>=ROV;`~AD6d}{ZZw+k@hOe@&@jsl}unS!QF1ul=8#%dG4(-(E! zMFu>SXYvv}54w8ESYbhDL~P`!fuBrr8kj1b10MYfOb4u10~J`4$8hJ*_f7djO=N3! z+B3Pi7TR2QtY@d2-9Eem5Bk|6eD0~hOe_Ryvi}C{MiyGrswLdCdhcImrzRmW>G~IF zhAa{k+#rj?FT8P7nargN1+t(1;*m`AkzikWh~RhqN(C-uD*$sj@dCw?{WM29(}M;# zgUiX(yF#T3_W9CKBq*@AafBHTjgA`3DdpCp87zzAb=v#uMgoq$9rY*Q_;NaS*tyQ( zT@R?TdowPTKr+ml|5B+yPsC{*lS^HKec7uTKU_fh&oMUXYH1cUcK+PO&Rx^?^2t82h@&y*qcI|HBrtJf_4R7VCZ{~!Np;DT$Z$Z- zx5>r5Vm!drMt}+SMqMz?JDdrc8h6MmLOz&4%a`tHdQuwS+|sjyY_5QBT}NE z){;_2v(EL?kR*)2_-a0SOicY~j{kzB30NcAM2t$J+ecT-u^c9y_W)@97Q5oI({pXW zcYwd6t*oa=KUBEd>C91G44AwTqR2DYD+R}VE=U7E0K$zb4`ZDVQ@`g}lS`T{wW9Ul zIUnAmTS4CQ&CXjXUF!P04PS08J+&Ox;O{jnJ+U0t8mJV2S6g}6mkdq8OucLYxKn%| z3?Y#`S#c21yrWtXoW20KNswQQg5r*0U;Tgo36S3bEC#VL9% zUu`(r4E@TkWgR`nDV1~Vk~OK;XO-W%@2LMyR?zh1T*>Ti-a|g#+Pjb9_y}r~r4d70 zi^u0qMfyD@`j!0r0oRaDTG``*yPq?C=$Tq?HJJLUrSc47b>QO|M^{!jV?tY@vu!-b zxXkc}D=^JU<|6sh!e+#P<{FJBFB7}qm)-Wk`^P2%t$8uPvIjzRy=B|q$WWSMY;Hdm*CafxSt#rb8-EU%Ne+o0EV zwMPYgg=q2X9wskiZ1sSDIbMMzep&B1Q~)aUy;+uNb-Ub7y>ukK9xYumI~_WOg$Lz5 zo-=q*nu4&$7VR)E z`l?p}13aT~4#oWs-FZZidF(e1`6?7%y}xEz^3m}m-?GyV50{0wmxy<4o^^=4WfE<4uv6jN1#tq@hF%Xal8 zEo^?Bz9Rj-LR~6G-C;}$swfi(5Kqr=qtP7^Q`gh}D9PB z4J)tEC^f^9Prl6Or+U9*$y(LVddg&NqphY>oh_WOu6GIQ1=uX!3`N{JTV}Wi6(8U_ zf2M~#EelCcbvk2tY+>(26n-M@w}ZwkXUW_G#3G+`aAzATAH{0yb338NfcGS^MQ4Rz z{*MO%y^nSP>f2=W^5;0cNl{9T3#HUtNLY~^H^#7%Qbzxebr)936ka!84WQOZZ%&AdVkbRGXe!G8y!*7S4 z9he@$JWz*!AUE$7O-H1XA?mx(>jM!=XEM=E6OUUsZ&I1ij=&J}{R6kSC*(H-3h!GX zg2JQ9)jaKZgSR&0*Ob25VK5a-0D5EIpE40*xrkWg=BPq5J$(4A^ZMA^+Qi)bw&)7s zH>El@!Q14ClHKhPNfez?5Zl>}9hEc<7|+qTId5V6`_W&iP3A7Ui6#APYwz#7S*q>C zX^y3DHka!-lPKN}NhNsDtMjcG2+^8>^ONsinN1$GR-|BE6S1xt*fDEL7QPQBf0Z=E z%gRd3&3vT=v`Vexhd+LA66OH6Ya&0M%}UofdK2p$5ZwQimYqd!SG#u&Mq15uundHYeQ0e)-k!1VOjdI-#x3kA`@>0-ApNDEKsWT@> zs`vsus{z+AIakRa0p6GoeIB7wmeEe)V=9F`hfRm&m`je=ByWL@{5mV;jHxDN9rHSi z`!)G=V%TG&8}=oKt-_0yEhsH!UYd&Y1M>4}S}V7cHWD~+1f6g?G6@z5$Sp)R)DIl* z_i5=G$G60;Dm*#0!tiU=$M}m@cm<<1uD!bx zN(uee!2!aIEFor{F@T~!nPB&9C`}wIuWy+UAz?g180M${kRYrVETKDJOl|ZH?MpC?otw|owZt^ZPY+?nYgsZWqikO(X!Q*+wQa-aVgtNl zWXAanw?>O>rBixiFf!CO61wZQhp)38_GLk{l`T48J!`99q1L;X$)oE|lfxVv>r&Wg z?7aTvXHN8N#H)8(tDfrj{)IapWP+8r0mmI{6vy2K;u5G1#@WR%+XN#AOM_u^3>+IKk1hV!$2e{F~r`~crr@0 z6nsE^$6R;PWSB-02ehUAC@agH$e`lqAX1kcWNNNUu#dlwIAK*hbDLvhBof3(FGYW- z5uYRb0%1YofA10}2eJ1axL)|(A8d9sVWJm!FuMVup1W12_N=Xh-okMr>Kh~KPE#mb zB|B(e5cKAAu@I89AyJeD`%HfQJ%Qr$&m7+5Kv!4M5N!1~+Dho5b|X!UW*y512kX(L zJSYo0K&$zji9W;o)E4mrKPQHgBA*RSr!;!QEiC@7t&}#bApcCC_qQrQh58K-}uCL$PL6Sbwz2 zH5F+CenW5v{2P3I#u6B#f$UMpHS@0g^kVUjB-F6~T)K=pgGingU9Dzp)d%O1wiy`H zn_aLtVteOK#L9@cS9fTjYT!ah-11m%-dg{FJI)J-gtCwRdFS|vAgl%Ok${&X3=9Lj zUIV-#@JkZhcZUD>0Y4Z#c%_0az^_C+ToHJMfg4=GFK;EVFW|SL`Tt9eRUapjL4iLZ z6?IU3tVn`)ZTXE!$P^RT-ej#gSmvTLy8xZW;Vami#G;|v(TkG&VB8u0m1Fs@x`36~ zwmEtc@&It-k}U4P9mzT-A)dkl=^aG<_dW$kb6R*V=($9-!CaHV;vJ2dFJ-D;VCsS- zRlxEy0sE9WwsBXW zJq@XgV2l5MLJ(ji{~wX!|Fb8*^c1lAKmU=%=HM*Tn}yh4_4fb# z0sohAy4(WLShXMVa;0@ZBV^hdIH@GDKz4%HKQVJ(f}YLg$;2ODQYg{-Q51j*x-Sqm zZ+{l)>ql~nY4E~-;pJ}oYF6mA0r=rP0vi8)n-UE@_(Ttq{Hp*`*Z<|I*hVTof<#}u z*xIL3=miMO_*k#`^Pt&M;mNVonK~L?NQjY0(u@84;n#=V&Ce-13Jhkj()5s|5m+Kd=sAjAnzytC(-@Vl~ulw(@d&iV5u1_``~(^ zCYW$`9;bW2^H=gsZtLb6e`e}j17AUkN?=6JU6HI1{vUDhkGD@02z^6lU@sCqPbI#Y zv1T%s0BG%7ha}KoAbv)?TF110Bs_2W?a7qwxam+$N%uV*2JYv!GU;R${qBjr>q0cPIxgm^|2jV+p zJQdGp-JHpYdO?w}MZSqqf#t;n&j{A9j7&K#qr?ykKCG;1b)CSN>c18C_B6i9`QOl# zZoXC`>ezjDs#j=I(B<1q>iq(2@?*H{j_J&O!3J1ftx_skf#U~f2xvbL=ipaX2zrUX z>nfA4t5&O!uY>zY=))V6s$&k*Hx~(R?K%-PK}fwv7;TH;Ey3&D&J zT`4H>`D~HAS!CfBZ>cyncbZxUh|{-;AOeM4m6pYh|~M3;)xTanuz93qtQ-c#0;^45wtWHgn4|s!{`)I_CIn z(v4!UgzwJeY@(HI=1v#O#I9h6oI(TNL5ffQ+qhoh)MQ8;8vF*fN$IJywNTr`G7-VE z=dZ@BrPLpWG?&!rngv(ie{*rDjxg~MEX|L*wXg5x)1MzS>DQ^GU3s^YlnkXYhlnZM zCI0uhVnU38;K;(Bh8(ypK}5!Jr4mvM?Jxzzk9NB>ZRF2llg{-iiaCEa(|Vwo^l4348$wKEL1R5PG}npA$%CQsaoL zRTOw)p7Q@35M{eaz=0&@m7_>cW69}&*W8cjjXxxl%mv(%xE(XiH}h<6l7nqRBceNx zuf<>|!aJ8V-BBeCtMiP=dw?6Fwve6CeoJK_H#VdqXFP5YJtxxjy{OtA|UGs3U>o27d6_A^?85sPf^br(Yr>26SG<_>e$8agIP>@vBChsvAa3$~6VC zp|eClp4bh*iVhAQGujNV1&HAFn|cDs(e(tu*L(Nt*EX!6RXhl!ZV-*vupE^Ee+h-W z$|_7mPIOT?z*5Rd=a45J7H${~!8@5q|I3aY3a&2|dKx+Fw&-E3@BVBhsa+Sf{t!jM zakFYY>s7)ONSmg>Pbv;f%FMj=PgJhq3cX1=Aw%{AB0fzaoxTA|bc_H_YPDpDqfL#u zq%!lnAG|+(AjlB<@dG5#im;=sl%rE+4C^;H$#~K2++CoZHOKsw|E8WYYs#&1MD|sb z94A8-Zn>ay-(4qSJ;1n{uf-S!(u4T%xO~Bm)Lx-6>tU7IAKmg-pv~{ZynaB52wFIp z!k-bZ#(27(lQ;@_6J*eX)hYg!b8H(OGtqV^SDk7d)~3$uk~3qAjF(u4^q<=;;GS|$wz2cGiu1w+gxb-dHplWEP2&r ze*01kod|e9`01fvVbT)vsy%bwC&d}E-B`@{U1`+)2Fnf?aWVfjS%8fOvl7v zB@MuGgSI|(r#k!n2_qlgb5oT^ENz((2^3BbvxM%hC&}(WzMSTSfjngSTXl2g=YLeR z7N^vqF}u*c=ELr@oo6*nM{Ew+yoGP)1TQ5;m#hS~@5%PC7RF#5MO^&}U4*~8IvU;$Zx?DC-y(b`->!wqsy+VCQ>A%k;2p5A)l+>k zXgE@?O77>K>Gm5VOUYL-Rue{HNVgeaW2#e$5iFQCl;VwFMR;ojbV6gh-6hfaX2XT6mgDAPJL2!1T=GtPJ6ab9 z433q2X}sNJ-NIlf+AMHHq5Nmn&pu{JyC*+`b%%5alWMv&1vD*CJJa{$* zR=9L#hK(Hr`2w7PfI=mH{%;rkxDNTf`)^+RP*y8f*mv1XoDQ~Q{)YshWtcq8GtRwe z)Fi;K&&)n2R)}CagAQJ_0A;ST#R!lDwng5mX;8~1} z$=k^kfUGXDdYM_tzBkXC+{didPDpwrN9p8W$80C6_e)aaBdz9i=$a>k z5nCpGRa;z*hA9Whm^SUr`vhWh;cZdB40ghD5Tx72J)8 ziB(8aXYZsdwi=xbFKo63dLDPH=gvT>JBbd66oibTR)gNYQX$UkCD`rI(hW4jcG&%s z9DxlQ=KY7DR`{1p0X1!#o%}0ihq-y_;S3Jv<8A+C1=K?`8U86x6Y9s1xLaKh-9-8F z1jb*ox9WbP(Z2a;6(7KyKR%Ym1k+l0pyn~){qQm52;^P`C@NeYwV4YSEo0a20|KiC z<0$sReTedd;!<3{p#b%?KwrjyLIwUyHrasjUe%&_lC_S5w#_qmOi5QF&llUZ#cs4a zr0^w>wQ*m@!3gUSmKBO-U&rD-2Pl%|o+|kQN`VVE%&({2vl5WO_UzqOTY*L%7Nqc2 z{VZG)2D0nlDtW|;CYfwZK~;zgLXvIygJmzRYNM3LY;EywpPU-#Vqtbp@iGUqAP&|s8 zDnbhmYP}kZWJI3fLA;Qf7#ReT(YF1^h5i(qn!0&sJOxS3#q8@@6?S{q<}_+z^1ki! zpnMNV*HN?mwL7^V*evOfhL>rCg7&KD$# z{jVku3_f1w>2n6pM9-_AQI5|3%flw zY^QeXFm`bxQmcMAn~r^_dJE(4t&?=22WX~N?H|rG<;l_fP!+}Tj#2LWi2berzvaiR z{p_X_NjkOBmLM2iWX?{^jA3u&A9&@mXR#P4cf37b{<$lO1P_{u$O#a;^5Z}>=bCk` z(>X(qZUGt*>>JxfN5WYJ_U&OLbjdXZ{(_d7%ytH4vO62ycfk_>g5(9rh3092-Ugif zrOcY^X=W_`7C%Mnhw}5ADi5hfCt9n(?^#fCIU9VUZl1esHm(V3nC_J20tq68t|Pxj z$P#@q_0<^m@t;b)|I1SDyP|O9#Qg+6Yz|wk6bC0rz9Vt%?sEzI5OQHDop_a^<4-a9 zp`Qm9NM3)PewPtLniNfKjM$fRaA!zO8fcBcy{d~J`Nh}%ZbAH1Eu6X^ChS*d@k$mn zqXY6((xQ4b*s`g+ess%c}SAZc~^7T+(152FhJ0{TNSdWhzHr#Pm%fJpj*VQ>g^Z`~m^Y6q%i-$(e1mI`%nV{I^B9T0s4^3TNVE zw$-UXO0Ycgyd}@IebWKjc0t2%A#JM zsEB7ervO=W!-l9X{F#`qJFiPWetN)7@B6jl>J_Zz`3raT#y5ssUKh__&=se`q^A-{ z*GNnZ9d28o1cKEF)+Zd#n6b_{Pb~E>nA_iIsLks*bJ3?_>+n?{W=Ktrl^s|JbU`b{ z2mY;FK6-0@p&3)K%II+j@#`;>Rg|Z4uTk+ZAbv}z-+HtzQ@XJJV zvG;M?7{wZ5C`{>nEKuEV)Hv|BsF;N`_Rn{nnLV?*$Oxfj4e-M@e&8N|e(??B@`~e2!#eP*}$xX2Y^(JZd*jYM`~Gs);hv zS=d$Ig=67LTb^>Fj?M-n1BwaYXNn9boY^l!R))X)=EzpM(7a>Q7=TJYS}EDnd_3ts zf4BRenR1;4>thHL*>}tg^YaAawc!?m1@aMkYm>oY^PPpduT0Q7Jy|mcizfDj;YEdhA9LPV7rdoY*?#hr5$az`&jN!NAW4 zvDo+!JLXc+e3fM_oZ0&FUKbh2Q)yJjs%e=q(QY1XqtwvX=wJ%_8Z#aUxg3}wQ-CZF z+I5ieIkp!`%FCMV>GM|!4w={m|1}-2nGV1n#s4JEdJu+P0eKbzq=xC7 zE3T3qMxAuegK#s2-Q}i>i5dz%#R0oniRQWHW(7`YS;@iRKa^l>`mL zc;NbAK>pk7*(wo|Y?<$zLB-Kqfm4TpDp%{;?onicSwF8N$$BdaFcq#nZqeaXd`j+yheRVv%Q@8Gxql; zpnZErayoJ@;;)%-%KBiU4-^Mm9v=TCvd}cSTo=g`r*@RXDG&V}&GWVXE6>Y&TQVWk zt`OHS@KC!dDa~YUMNZKy(4mnwO&jB2ahc#84zlA{*eL&W7rg;zGvD;SIH~UjJDTld zk^7`S9(o;M>`BrGLmW4!FUnd6Hy`4U<(2(!UFqzVZ+eJYE>$Rl#o4zSqq1feD z*d7}|+7d0#r`_8eY!0Pr#i^mo?VoCo8HY@dl~D}43PW5fVU7Nl3XdUqH;P!0yzHcM z0|!Yz+sLg|$@9=c9|~$I8thX`W$9NgH%sENhjW1rB?@X63=6p!EIf73!~K49ETNlc zy`lWCh67KMAdtKhJgfkZG}p*!S#-3Q_DR_e@4h}8eCbq0jFn3}_d*wDr1pqvmc&2N zpWeLjm3%OXN5!nLe>wj}UMj~(LWm^*@OXbZa!K)@IowlC4(Ua&Ex%>+KUcGID`OsX zs@)(&4FQdh$c$6AxM9GQl1XsN22nI~eB-pI?G-n#|*Jr1$#i^7CKQa=DO;nqSd zvVE;tHt`&r7%q@WXOKmh=s&g1zCi99phAJUf3}x zMQ}j;%rpQ9@AVR$*b79QHS54Nn*~nUPQ1ahf7okMUf~ZVz5Mi2!0cW_yz#D*8*MeG z_L;eJ9i~IfT`gDqtZ2y+FLL9sEH9x>w;L6gS$YHgq^A&Xy9|8DMM2VoAE-6b>I=Sc zt*=)#v9+CFB}Ly%!{k18jkk6Fv6q|dLatwTR`~9<|EqeH>{qaa`0Kd7=(uCt(1>Ke zcK}nt2+MV_7pAWb6)iv}`_0Vkj+ogrinOSVnoQVZW_W<7_FjSJj>nx;>G$0=3hoDQ z;a3!fEX!-lZL_VOH5-lN^(>#%l3UJ;L;a>iK3ge`3AbU#IooiD;{dyDVT- zxp_&c1Di6NBQzcSQA6tX#~hAv^qJ`cgl=+zG{j__s-PuDghkhW&pIo2QQIbURsV2I zzp%i;G*dF!0cn0&!XLPO%HHVEr>FP;Zf1HK2%Vf+Ry_<41LaBrL~sd3h-*BAQo36_ z!9vhJa(w9KmlvOhs%c}UA#PMZP!J`^mXqAo!HZ-MN8W~~nEW4Sjk1Rs1A*wr z%$mq?&C|_#8@5g3LE$}W>{1gNs^z$a7h!d?RSj-<*~3{t(shO7fk9D z`l{JoY{;-xlr9>Lev*<??k5j&?aMKJV5|#!lXNO_g2UHI?8l zE$I0fYBKQzrUyAL|8Os3fI(K-7yiC*f&TKea6)0!HZ5v6x7uKPmxo3Wr%cZ)-k#GE zCRwMiw8vJhG{$$Nf)#>XYoIJ@j9N;zzF^%1Ib^fFa^L-(L~^9A1amAu736ho{Em`B zS9ZKYlP2lKKD?6$K`?;q9ht^{eW(N_&)L7(CxTW434e($7M z(9u}+5I*HQAdAp}uHVl)O~c!(xd6tq`SiwERXo}#QMHLORH7sC_iTPsT=&$4`}HQF z37x>??Z?&jo8(%*JqQoS9;5y&;8mO+YildR({_^ z7MFIHd8#U_9*9>okuKJbeaG}JA=2p#+lX_I;hkU$)`R_XQ#x}tjI=PKSRlz-Tkfv+ zcQPMGBr;GqowBLim5BWVY%gjf&SFExO7=A zb~5B|SP#lNa%PZ}n)x(lQTrUOgws!AG*`kIyUuhl)~Yu&(%LA9LtAA>{Dr&6Gv_3Q zZS$=lJ&hdF900pdaOtILyvKvfQLZ6VPLq7>);OfOfpgIOvuUxjG6m0IPSILp{BitU zqh}4!%YiF+pm)`i63L;1l1<|{{~afKuDcg5D(RK(W}hzQkSoPp6QS4-DPUn9DJR_` zDXow+mH=#5y+c`#0+C0#8)b1uJB6NnHH~+>D&r53nxwCxyFJZ(iuHkw{V>cYQd+Zy zUV#o?m=RgT7Kz1qBX{zCb@HBcJ!oQ}DPr7Tp6xIbqrKzmlAM7bP#S9dbUBzSuI>&w zH>FZK$SA@p4;ZqtG3+c=tF4yjRLhc4r02|WeOnOE@S`_S&>iU= z{|Je+=<4e#d_Bt_2$fz3+(;umE{$OdI{rLY$|Vq+8I@q|^RUEn27l*jUd)SG)GPGJ zVO5a3%B9^j5Z2(v8<&m^4WEq^YG3!ZW=Z!wg4p0=i)>;%YqR zwNH-w`7BIUi-N|-Iby7XpuF+jiI2=0L0=Jln;m4C;2m`_3{c(C>(TVZaPod|D5SF( z^oNuhb3l;|ls;T%?bltmV5+07Ox`6g$!mt}hYxJC@ zZvchItvzVJQW|H%7THiH#-$CaijzUQf5L1hU#Hi8p%)$VnDM%>|7JY7`OiQ_5Ep7z z+{*Ap`}wZ2^f-{6=@*W^sR!!4}P*g{_T&n_0_97-&+F`c%#E zn=K zQcrQi16>+8cmD0lUX8D;J;7^U5~rT;2-P^|WygCl$6=h#9kkP5y709-5So&97PK_Q zGgHHpPOX$npA=#K7Nh0>3!`wf$unXZTUlwv)B0|%lB}c^Gb1w9?s~3Xlx1shWgi~p zUG311>;Kn;-rn+Dryp;j2+vfzQS46BNWed03pzH$w(&^V8pf7UZhDBq57&?v;d zm72Lry^~b|hgd%W6;(nTk=_!MH9u(o-LD1$BzK``$@1V;zuN_Qll5v!(+a-dwmX2c zP)=`UjSpVcCzvR*l&1MH{db%G!Ek)kjAew$ggBxAKVTZLzJ|2P8)-ydy?GLAO4&5M z^VVTKsp;jDenHpeO?_yUqsbMrNX<(?watpMv>e<@pA$(D4 zGDS&=XZ{m75bqqrz&J}`;o~yZ1({M&=#;yC-B_N*2Y$QwcjO)m=zsK=zC7&d8vDh1 zTKrq&CEze`?93CA-^--3$CY($auIg&NollXP|D6mFHQgN4A~#QWVjLf|X1%zeTIgOgg%VKbB&Vht?H*vpggt-w1Pv_8iJ zuJxT99oCfPdYe~a2&`iJ>Kb$J{+*yX7xGk}cxH*MQ6+TEtP*KJl(g@rv(ss;=%b&Z zmh*Y&m<~@$uKp44hze#%Ve-y9%m9K;rSp0rsM|Nh+bH8qZUOGSqOj3b%CO{(#H{dO zc)N%38}k8!UaIZ0mc!B!MNY%A2AQXX9#f1=`K z&N)oe&0tw>)`)wRT=p8#@;%#dY((Q8dtgGs8|0>GbHV=|eSiDk%JvaVl+d=5-#xx! zymc{t+dZT34{d-~Xu|ST%*PxQ-hqZ)#z~IXl=G)I_o?xPXVMy9ziO@S{vb76hCUCZ zJ-t-llIlWTik*8SRVpL58H zx>Z<>8+nFx@2CqQ-{=dyfq&S^yt`|EhGaOBuDDhSbUZej%^VL-qws9$qAZ)azSsCa zmpGuw^D{5NqysMC*mC>G%O{SQGzjjoYeo=Z%=&86t3AIOgdni@Mdn0h*&JHDEfJhN z8EmVe5X{gUJgY_2x$MCXhkbha`p?f(=nHY`ZGK?5Mru&x_r4_CBZzi$gY9kRwDg?} zp7XgrI_4mBX#9kr#j;9wu}zT0p2zrm7i=mU7%EG-*vGCFZGdPRJDN4B(aqv)J+jzZ z4z^Xwaj0)L_Evd`V`^>&gZK91Ibx3A`;KYtO}a2aAkI>X57RA+uJQB%%Un1qZ#?`r zSY`3S>m~1Lh1gZj@DNOBV*F`rQtRp``izH|P-(j+UoyDZU86WRH%5ekgmI^LSGEuDKCe|FU!MvZO(jWW2Oat8W>8Kr*nH z$5XqjL#BxPv3amX>o+bSoGlv$&o!JAL%c;xeSlovcF2nw4j{s>M?guRIH^D4|Ezs`% zqultv;b?&pCniTX#mZgr2c0v+7CxOkte0-718?}b8mR_e&LiDRF6uZR7p<{u)7R$ri;?QJ*5cY*8eLGYZCl(r8;lGA%Rys|Mx0 z(#3I~xYiTxmKB;Q-R|mBSc`2^+}j=Ix^*^Bhe;i*FbAQV>ZWo@nm}FY65wAH8fPra zDJzk)GYjyxonPjbO>mO=-VoQGfK7c?F-x?^`C@L-qQeT|rX0kE*QW9&zn-PV9lvRE zeQ&2?H8^3$=O+m{wp2n&OG62DfHhJK6dn7Gw7Be*pVwtGh4Lsw?*rj(q5HQ?-P$vJ zDEWIj%tBl$H?`j@o>KE-#dauU%0joDu)9afvXRUEG-cUpNJ=V@6-iWDf>$_jnyhal z+43%OOE2r0hQ~-1b$w z$se*43rf0gb}VWn#^4rn@2<~Jd+&Fc&c|Vu1#BX@!OkY|WYXwZbpj8`+kMi_UNj?g5+SOhCbS2dHI=2)#1U}hLxhvWqpc_%qd@KM^DcMUvF}H zE#9+28Uigf;B=1k@1xDPj!s$q>Lc(MYyCPox2G4T`&+|LI&!`aS+Y;tIiFnY^DdN@ zkTzZ<-1JHMfk%Xz>J1$~NOB?_s2uothUaJs%)_KnCz^CjZcb7*?<${e4 zN88a}cWMdk0BhT^bS*Gj+-<|1c#Y$&sbNr>ARG2tLn1jNBW03gk=`us>E2?bSZ9w_?&x4*<`{43`$W4P^IV1$r&~qZ9+xp|_zaFaW>)YTgX4k9 za#?a$WZlEi7S&f)4|_rbCZ4aBqIJs}HDWdSA%?e}{xP;EXF-VD{TYSth4WiYA98}u ztIF(!CU*>VJ3_iTo7%3xC@9=XozjMfg$?#*;WR85C9%_X-JL2b7_Jcz%Adyx^Sd#t zc>J*fC1w;DMXxY*;*1xVIOy(rRh6|bu+RG~fd+r=zMZrEz3r7>%dfXQXK9hONP_ko zw)A~>8Z1!|P5gTiwqq^UyE_xpu5ihC`CO%{_)*e|$KM7niw%?OZT4fs`J?IcR$P)1 z9#CbhE>EdbCtim#jaf*uL>P?na>=XPeAVo-5s&h0@gEKU1Slw-05l5WRUbh$BSz<2 zke0oGQ^d?yBLP*RNw2J2{iq znc=GkEK#_qhQyMZB*vnj^6b(ifC~tpZ*+M zQf6<8zl30qGR$30`s0Feb+FHStmSjp{#pHv(7tJ(L+MOO^X~MPP-|4YrXKa0c#xZ1 z=z{k@eI*g$dd~^kn**0aFQ}}GEif$5kA3@>W+$rmFiP-juM95)>jW5ho)D5Q(UyEK3?d2o# ze(NOCNrRlkKIAhywA>ZSS%|T&Jaxo*LiaOKXXt|00UbKQfvUf!{bCaNW?G6PM_~d; zn2;egM7e$G^b3h2jRr7Z# z+%z>V*~(OE{>&TBd`y9g@JaEQbmyz=U`z=R|jD}j``l~LvJR(nZCPwh3V^DM@A zV)>JCRMG0yyBYV!aGR2zP7EgpN!wj*(9%&1Bu53DhZPqIl(-3UojmOa__?J7Ce7<;>9!gM#grL$TMa_oBAF@ z{HQRWlW&;2kS~7_av;svS0HviKaZ^OZe*y`6k-3UiL75`*_s>T`fyZfqm@&9z>je_ zc{$2oWuv!hB*iu+7kl0i3E{y7=d*h)ckbx>fC#b*(~{iD_^@ zc~0bkAiWf&6Q2(*>(xk$0sPrQ@esnr$fBPF3?<^4u?z#4?6if+F49eU_9~EXzd&N_>30BaHHS5<$aC~`90qH&j8pB z-H?G|Jh)v^0ye}!6-;j=oP>l!4XvZt3s5=l%c?39M_ySfilm@Hq+eUt5M%P{M(m82 zlf2RlfXL0M`IZQGlUP0c9lBlIyExtVBMukB%?wV9rC8QS^|ZPBQXkeL{S*9%^h(@O zkB5lfTzD2_^EZgsJ=el&{NQ80&ae}V+nM^)I6dbmul3~H#`492eWXM(jWZbe9u?JJMuMwy$n8ixaH&2CyD7_@jt;eX6l6EpAET9@t3`KG zV3aAih^vm~ga)=jT!CK;IaaHzJz;!(Y$5jRkySL=Gj30c*qwfYS}J#ktFqR}kzbwuU+~NO^p~mY?NeV8uPsJE9)mg!QVKYTt%>&YuV6NX>k7p#eHm<2r206W5 zwySE}>Fkh<`P;afnOug6nPh?PE8-j3U&WV$wJ93W(~{o8`JBF7hdg_50MNcO?w>;0(>XV|=acn!&P1r;O| z_{q{vSY@hh=bdoAR;|t0Yd8(wH(8a1IeSS|n0UR5UDuyXh6(+KvB+kKIxV1TD5Iwv z!EJo0gFh#I?h44IVVYKReu5Sp$Iw=5uh&_z|3&kWJD1?{o&;FB)$P(%lvAD<~|J0ajx{-GnUsozFr?qeod#_EEguDcGno2lOU8Py`9L6v8hIPX9vy{ z7C0Vl;oNezs<{OOMTKsn&Bp^s`%GmOGg7b{nVx-g_@3B@e+D>Zx}erhuIU7Dk>K&+ zrixqy63Pel+p~VNSJ>fx>X5Cu^_I?mIf5yeo@**+Z!nys_GCif4uokB3zwnMJuv&- zUI@$bxVd34(9v&qBTE-LqE5T5ywtmQ+%5^0!fcDllCz=LK6Vzm02c3<0t!mz z0`!v?KMZNdx>01h4-utJAcBUeYTs~TUr?niFXya17n?f^n4}i$PKHAmgaO?vt*gr9 z^_JXXci@?bw_c+AM#W3vPxPN`8ud>94au^|#I>qQCX=k?Ap!yJEQ{c>!#L3U==M(M zOHHz-O$CX>9j-Gg{$EC=@ED1?=7GqdX8tq!j$_v^JG#frO%2bRTXiVi7W*T>#-h{) z2jVP+!e9u4%L-UacIhq2sr^L_jsN=L4V{@UQ6O#Zz9xn?qO4wU>4Y1qTBWbZK+)uLt{L=(~`r(_`2v(B&AosJt_`ps3GFo@a zc@OqTBlRk_N|1{}e5Z7gqMPV?WBaKJf5j%}ihq;5&bFSX{qIxz=A}LyhMC4-K#5Oa zlj?N1pON7I@4)e4acHlju%F^ItpROmW1-id<`x&ng67G_ihtWMmu)(MZa+n}^y3mS z79b$V`a+BznK(s=^M)>G+^UcX#jD!%mO$MmP4XkDS&`4m#r9YgjDLOoo=cph_}{FW zc>nYL`Dur?J`bZtPUWb3MTGu-LWb}M$hqF1m1K`0FhHp9G%A|7qtfF`i_o8i9!yMVp&os! zAgIO*)_5{^F~Y<10G-cFpVX!^Ca(V+efF0UE8gG^^K0C-#xa?{eU~NVEoF#M`la~} z#ba>RibZkGTt3A&0@gZS=A$1PH&7)PU@T0MNtZ`_{|y zKZT1FdFXd!0aw-Em_QX7h#D{?gfQo~|Jrdvb2&S1;@t2w&H2v0Hk|o(5As|a*y-xa=IwENRNeEe~F2N7IPd3^g zS`$07=uf;Wm|eY7@5NT6k84&>6P-i>Q;AL2AW$fS5p*LkzZ$L7b?UKe;Vv&;@ls~M2&x(!`@hZ zURhI{EP1uKRh`(PSShL&H2CPYD>p}6Z+tayPK!i^W zyK;WQZ~DQ%jy=>zNCp;I##f;Y&?jOL-=M9(>nqsv@6s3N@V|P0yT7iu9Q1U4!4FX< z00inwaonNxo%A)Byk91$Fq#vXl8mV;fGWeVEhr51O$nxoly5_WyxZ5lyJg` z%mo`!R6O@-#otDYp#S9}jMu#UummghCkrrP_s)RjDQEva&orY(Mh}Lungz>Hw z(>Oq$B>|e%C_gi^Y%deLSV!j?2kFc(N2`zhc9EdV<{sI5_E~asmc9-tbgMokc^J>q zzzu>bPt7pB%AUmbpw~dmp{jT+<-KTE26RYVlJaNaWYy6#PFf2?YXASGpVp`_n2D&F zn|A`*r znEkFU9e;|>>$bXa^w~RKLh0b#R$~7DzyD8x|54ys&kdCcgaCEP%P4~R0-;1JxM!2`n}L4yNI0Oa_KEU8^gS)%CYjB(8 z-TkrOpFL+!S67!jRnM(^tNYyQsxVb$S!_&FOe7>EYp1(z&uSrg%b+YensOOe1_v9tW%5<=Qu7#AG{g?fFf|!3sEIjvB z{uA+EkrQu2%s(L-uU^Vc3eR3*Xx!!t4AFAKl5-*_+A5>cgJ`;X0U#Q#URu4xpcmK+ zpy8^r`~uN@EoC(NUsb~uU;g<^&*IK=|MmYL{&KkTA7AeAOF~Ylgtzc~Z}Ry?40+)e z?uI)B!B$zN?ib|Cc&DrWw~+JCQkwmQ|20367i>nHA^wl#e0gUt`gtjQ2~9gMl0Wh0 z{70dzyYNEyl6Wzhiek5F{^?f!#eDvOO3~@k2;%t}p)As$6TXt-x41rzs0mzd&pHfq znVxRB5_g#a@Qy{kIqhaB*fUX=JOgqw{CMQ{H6Hkj@- zEnzV+T=maUdtkoqR8FKt(r`pp4nERzt6X@hBHDUZcB-6rGE#bi*h7f^T(J7u+gG%Y zXn*RCSvOMb(vt32s=r6{-Xh>Pvjg`XdFzPQd&J27Z2B&L;Uxl&Ky=;C^xX+U9}wdY z3W9B%Imffrmx#eTdEQ3;m*Lc2Bc>jg8?F({2*egbQ4qe?^rXbssUX~@B+wj<7*S5J`9E9a9Q|jtxyKh(zhqz1FXpgr`yBP6=x}Fs z<*(0u8VAq6pPqi47Cn8v6iZdVT8H;fF$J0VcbShruUvZQ8@N74G7Id&vh{!2CuyZb z=Bb7EjZ-f>G+UpooGqL;mv*ZUL8@^Nw^?|8^;n$3mg4nYq_Y)Z@3+ubx$&kWrM7PO=X1kdUa5*#NUAa$Myf8>!87~wx){cGGz3;+7G}0zA|_^eWtVDzR?X3 zX9m1UFN}R0EHyyZYJIXNt*V*r%*o1+qIkG#El1WGS-QK%cx0Eh3l93*Qygsbr^!rR zR@O?keW1fj_QCgQ0Cdu{9|b$x(2QpwASB#LK49?!czOeY*``jJ6@HppU@C3K*S5B- z0HwF?@=8jI$8w6pY>MO@Nf=qDm{?g*^$ez=0=FEt;ZZvry?!>9ns#(LdL2ys5GnL% z5O@uY&G@575VpmetgOT3=0r8P#8Wgp?D?n<2ud@+ATEW8Rs5+fVkc1J(fy)AdAW2@ zm_V6WU(a`YLjV|A^|Vj0TAP*pqGZJ?tv6gW%7H1(=3kRYB3SpXOsIz6VUlX?14Det z&!j7$2D6EYiDswhr|mqtv&8}D!Yl2q%FkJio_$L{y>rl7GsP9z{L!E@+?}R}|1$3d z=y3S@xA*reFKxpCj^3U&M{t!43Lf)~%Y6=TzRJ@jX?(Am4L7D?Kp_w4S#NM93wNJO%}Y8l0_C?KnP$_RKtNlNI4onTFixH8L6e3Ld zjc;I63pO=hV&9t#_V4quxvqO^t8^uD@_%eChU2~Z4Wcsi!^_uEN6#ztq(b{WT{Zbi zv$S+?V|3T1Ca2n_hJ)YqBW}!b>~37IaG1XSMM8#b|-8{>eR!~t2G!UL*sASs^Q3M6@ayh`&+^!MM{zf8^!tVOmVd=0P0Lsb!hz# zK)Ye3?#E#6m)(NbaO=B|GgR+D&pV%28<9boi3G25GK-!%5X+2M4w@?DCuxLoB`S=y z>^^qyp0I%(zr2)eC^x=>E1eA!QEEfBm-scN8x~HqE2@9$G!S;XfOT}3@>iETSyl446^Zm95Gvsy==Lv@ylaM>-@+T@7D_L>q6=;_=ql#dj)tFo7 z;bY(KQuI?m8;$ANGX;@#MfgRr%lJKDCL}(&U~tEn`1Ew`(@+~U-`l+|kEX`?HyilS zM6@hA`+Qp3`Qme-(?i|y@X!Ez$$U=H=!igr(;1GgbWl`zc}|MTPd*QO9Tgr1*S)$& zT!g~lDD3(27-72)qxGRExahE=6aXv`<`jmz+6bnWj=%a;l^e}$hRr$Hx5R%-zTQ26 zwKSvfkyS0R62q{@=B};nUrFsFhBfm)#h>_Cz?GI%D1(fJB$$YqiPd%xI$Okp8sE7N z`vV2VcfJ+H`)&mh@H%~72&cwLwv%**dv4$bUu`3-8xP3{-&lX(ka$z-Q^vB;#w%Iy zg@%3$rTaTiA`&~gE>en2LI09#^aiqy>0}7o5eZcE$_I=UqQXYwC-Fmiel6aNB97C^ zhMcNI(BKt|IhszsWa-F?M}>d5+sG-k~2p5JwFjoFd6;#Glcv8@=Xm@JAj5Uw}R#_-w{EjB@r>GFimTmV49 zLL~GzsQ%!f!0R!*roSmJ)*NIEK9?g*( z6Gwr{@0~pxDd(xm=McjXN(sHsgsC=_J0#|S}3K{Be5iJcB@TV0>L zu|7Oy2e>JMD(X^(uMUo$h^^!)LEn#>!&@2!Lim_1UisFyCq3&bNEy8<^Hl1I_L&F? zVzn+PTft%uAtCLgFH3>apY!q$o&P!N=xh;Wv26E$ZL?`zx3M`q^KetTmMxTL>aR6t z%;Vv)Y$frdrD@zcSdAK{K_=R`jReZi&wr0O^p#idy5k4~6Ne+YJ(k|-u~bVm=HiP4 z3kJCTfW^?XCdsA&w*8hkT|Vn$)>i`q1M?X%4&8HEB6cQ5zOAWNd?Mx4O^WlnOyy*c zY&tYBr{>h|>8k%jvq5Ef-uBw^$J(V&oDMyxV-J)2+$8g0#k1Un^(|8gjz1&mt@h=c zs)+mtoWEBKGKt?4(FA_u)?>ScMXji{plt+rJ*oVZPBbkm;XQPoXNWOqtu>#WuQGQ# zZuogCmqg-$rw5uWniM5J{$(PEY8D;h_`t$u3&eaGo&gP%UAgU-_aB_WPgof5kP>B* zy|*q{b2|*#tt!@3(90-BruK$Hv2L$L|JJQ>P?(>+;~Ou%X{j$=!Nmf%93ly4DW32` zY&#Zf$(PU_1cqD5S4`P0$k4iNxvRe|TKDMF=Bu#%Ho26w6hH$eoWl20v-+o$qwS$i1syoy7mMU^DLQZ z8wKMw{sNSEM&0*mcgBc5&&}=7cE6I;mpR@BKq5d`^?=$}LAORVa~~2`$^i@S1>&(p z_q53ZGgh{1Yh`|Q$0xo^UO&R4xTMEmi6i>1Jx-`b&ktrjJ;_qG24W2=BsUD+ZpJL2 zpyPzXj2$eaLU_y+4#&P}CF7A(-MV8iVFhl7#<=yQ(3zk7$c9E!uzz`WZ?~OYSZp4% zstTxQO=B#5UaPEEoldLv9h6P<&p#iP<6B49k7wc4dggB;dY ztnxZwdg2yb#imhQTYP~=R;$)hD%ZR*wuFF!bRc47`j z--Uc5$rxTo!a&RGYU^#f=btkw`fBhxxtm^U@u!PR`YDnQLkCXjqdqQ)L;@zj;w|Kv zA_SoTV}|yx<{SL>)6zQoEklDSB|SP^3CK_c_93z zmHva3lhMk#Gh^;EwlH2#;FCDM1)qJp1=R+83x$uRWPhlL{?Hqrq9L^HscfwC#u&_} z7aH|xZ@;x+e)Q6}WVtEE18DA-peXRO*I^5L>@Z5$1UkS zxa_So!6kXHrle%f3ch4TS8;Z9X#Ug*rJt~_%5)KMzXadV z?W}Ec#yMxR|yKwE6~vVJVJ-fYDV%CMmj5+`H`|2*0{7w(ZEP0*j@dpEPp#XS%Q zR>h>SG?2xqo8O;C9w1=%%Rm7~P=0@9efW7hOW5)RQnw z()5Ok6Zo3Jtfsame9Q`M(^-5-1SBro}yJ`LYCT)Em zuG8?Dc)}SymV7ocUETgr67FDXM$(4AalY`QkF)W$b)*ALbLzJ5)RM00ZyaY6L2R3X zb(zr$$r?KI-n7tYR1j5Z^MG=##!gs!;idC zlb?60!Ug%)zsaJ@KvlmdXew+58%rAX%B@XV@#^&lICdKnU1^v0Fn8ZxXtFq*&Pu&L z+sxzsK>x+qubG`zmRt|-2llt}`11!7;{YgA>fhJetJ^9g@8u%U3u}fGBX@ml2yo=Q zFo8A#x^|hFJZrAayX=Ri>)+8ir)Nm|J7eIAPP)2e`Q}1q79RCbebMbcr^P4oIjEkn=%O@$=0&CPX8q+#u`6|s`qCye77{mm??WQ z(T(IAzLbS^0e|h&#kq}3k8Qd%V+wSrw3IGo;VE`1-_>jAxb~0ov56%l4?|UIB3z35 zs@@aQkb$FW|7FgM5Bi$dt!-;4_5HIX3MIsX@fN_}&+_l1EWdl>zDRaW?^^mkQmre$ zZo!Pjl)&&x6*S0LVbE4cSsNnY*-;Z0N@OIzE?y9WiYoxIt$mRRkAqXLlv~j~F z7d~K!ik#$-{VuC_*5eA}F3NU!Sh*%uR34^CPH-QKrr~&9^;jMz`IQ-j{@-m)l?-Q` z2`ysY?VAYl4-;Wmhj#l@%8ALmnimJRKqeG_jSdrQK*lQco#}EXHo3$2Z>}S1;%HCw zE-dZdXuGzb*n``hvYcGbhQC~vsEHqx4eHG;Ei0#D-s-=;Y2mx9)g>wu*L2w+?Dw@ZzO%{ki~C zM}Wx@M5Em`YpTpmeQJ#f$$@bCSe*Kvh+ouLw10*`WhoS(3YQZk;!0B3!r_H>oL^#e zHI$OX!{-aUi!dbF^yv51v6kpfD|?zVC_bT}YT=?%Y$GUF@4QmXxVe*v8Kbl`vf7qk zsA{O|?I)ce3(Uc6uL7y$l`a%J+`Xj4ge1P?LEct^7;h^)9gwxWFR6!4Z7A!30$8|3 zK;g;e$F1zvHRl1 zS{lZj9#F=PN7MMO=KiVf%fL??=g)NDU)J(RKm?a0OXa(=c^${yte~>bW>-?C(~w7l z^4p~r4RzS}SmqEF=t?GICAH9eVs^Lx$})|9sZ-%$-8_@Xp)I5PeyY(HobIXEdN91! zbaEOuh;`+N&$G{@-*%~6qLjZO7j8D_F*BQ_9H$Q28sMMis3q3z?uL*EC_%zZ^2;e zlXlvsX$LNv&gd^yn207(5RDp1r$#MXansAde0S1q{aG3mdFr^;L@keUn@MO%H)cg@ zNw%;3oD&bM3R-^y)wEL$A;oW(^v29xH zXjoJXI5|SvPThyn`D>|Lr5kI@TvGKFM=oRTLdKWj&ALV(mt4FiY1$S~t9kOmlDc-A zzl0bDN!Jo*NbGd?h#XcBd8kFgs0&u(=7O9YtX`7;OySIZ6pZwC#XjS&{!0&**s^K1@hwZ&aM$|GscKOcQNt50%r@GZQk$h zRLZ$Gh`8c>B(CX%_Ny_8kQI4t^WOFV4w0yJv+Mi2SagyXc1kb%9AI!&-sS>v zjLU1_&-@AYS>Li80!g3xcYmfz$b_<0({9v3tj3cC27NKYyQ>b`U<1_939r^DHwAB| zJ7O^&H!A$k-_YI>HtcB8GZ213VJrI^HxawgL2%n&6+UxTGA9sA^KDldz+#gjXhE8* z%HHyhFg$`}akr=o4u|jjRKN6L%iC%mKEu1SrZ11i$$}!k#VR9b^FC_-l$Nm|L^LSe zmdvx&oR*m`^x2fuC(D1o1_sts&5ylUuXB6UZGCD%9&OS*({3RoY(U?=d0J;Xr}s^| zHSjsTe=FU7O8W)|M$bngdJTg<1I|~UDFJM6QvBaWd`;?%q04B;T-in^Aruks%|woI zit$q2zWUK7M@X2mUYAj46CK0rrOw{eSqcAGS0~a8y;;I+R3jf;e4sU&)>PMQ5c0I+G5?B)%Ze=&vf`E@JcBDcaP$EV7DSc`#n-0 zkYZ-fpH?HOBA&?_4SxR%x5S7XQ~?u+N_fkz$v&zT+h`13P-PERlcStD{O~p?531+K zd4X-sJriZU*3o$B3JbboZYNdgAZ`?R1=6}03i(B#e0cF0dXt2vtJ4v3Mg0-8Q^2qK6!+=*z{5j(Wqu$94Uh#->xI3tI-!{o098UcscdMb9jb^|jP$0Z7Z%T1Qm z831n>BJpQlK&s{iBng^#Bh=}rOvr;u+Nd)&KE7&cmyWQs&b7|>ffzi4lVX(Nb!>QG zj}J4*^w{tUg}nD3m8q@gZ%WuS$rjNDAapKZ3<&}w#cuX-;lOP|uVGwQ4N@EM2gMS6 zMZT4@${SQz5;Zh+fK>!agwal#17)Q-Ms8ts02>DgVw#P6RVyPg&kL`Q%v2!Jyb+V{ zR4~-fSW_?;M-okIe~)uJB*SiPkY%WsD$-q^F@`As@Dcq(Pa)L99&7~Bg+qRQ65by% zD0d?M4z_K9Y%xvjIspf72-NWC%ip_0IzdOLQe5vtc;c>e=aDGA1SwO^a%!dFiXV4O zPj?RSs)Ewb{Qg0lRwdx5`O4)uNHT z5u-)Im;xNC94cQ>>0=`q$ll!@N>?uAIlCEfwBG3t00`)bFUQ9PYme2eZ=)pk^L!>A z-6EhAt^)SQPy{QG63RcF*BfrFW#Aqi{E^q-R{k9$ZhmrcuQjJ2FL=wnqm+boe%g=y z^$qm=kudK24`Oo>`j{6{FTw{(<4dOKOR>u)F|TNdtm2--BJ0WC-_2dYeGZC~aLs^GfmjVS`(aA&}Clq0UoY5avP@HDveuJvsL zxw3M?n4c4tgv^73hc@4*iYr(r>fI6?QHcOj;QsF6I!1yzMvmC$e0rjPA`VJ|)c}7P zmiLpI6%2bc@d~=P*8>FHiG{#pY~SPm&JnsYeUhQ##eCXZdgC);gvp##?LU@0Bo$4Na($xMBTW8C>fnC20$hG_J}7F@;rI?1&2*eLExV zf~{5jF*WDn=xSk3JWjx@Q8q^-+oeK6!Z7;pEC5mHwJY)HGmgu4bz}S=1_dly27a(* z^{`1$PzOWT*Rp47wqKbYYDV!|dikfOAbaM8LF^_niV?3`hBI#|L&OQ2_b{te?bpdA1%?hX z_5&;k{M}jE(R9eF|b_w{~k zOf2S5wCYH_axQU8{7!$r@Kgk4Z#d~EoizVLlnQy%6+OEz6Yd2QiQttr^4pxauZ|*= zmX=PddOfJ(-~58|#MFltvKtx_2oiC>1SKv>p_w1V05crfXzf#5jm4cp*$e~Z08?U? z(o#a;M}Z7xmTX?Q`serW=YW}4W)lH#EYLAZjN!%1caO+r9Sj(xbsZenXdUfZfsiyK zDH9fnlBK>0g#i}#hb!qV_FJ$tn>Ll&r}`<=Dt&VNbFs7!;y(o)PP*P$`i~|GZDU9C z8_1gkV=xT!P3BnE@1YP=-{>&^4&13UJRcjk4obeT=rs1WzpQkzHjnbzjJS!!Wu0ea z`i=DCR2BbtWL^S88KJMpiKn@#7ndtfYQECJQzPC1;KL1`>$i#sw?-)}F@&e^_LjSQ zEa#YxFYSNS22+K(u=%i?4K3QW)w%oEW@S|K^NFo8tfQ7eV4~d=1jll!6ltOP9lgK=;{6^csKgbodg}Qq$DL$|F=Em zRbq9A?NEy|MiD`z_Mw)}GfyXPhv<*?_jrCzhj=a*%1P?Z8YHIeMGI5K7hvdf+z`e%mUuteVFU z!wF;lCWHUV$mVffzM;N;4wrpDlZGZ=I$~T$hCLf$r>^e&9tE80m_o*E+Z;lXv(o_h zX~M@A@|Fp2BqGvmMp?KVRdU#SxqDbd6EII=ICR7Za(sku3gckuiI zgAqsb;clBb@KCC$$LnIxeN?ZhMP;)B zzsb?f#Ovz;m06MS0fnrvd}aMl4XzSQ4VB^zhWTERp zJVkfFpwW}%~R5%gF=PMRE!gTI0Ik7%gSs&F43V?rlWPSs#^mrG)v{b@wR zAoWp+Q>&55nv|5uJn*Jl@0U3y)hlGKM)x;LaT2lUoCulgcA-W|V zb)1%IUqZG%Fj0?7x~omdpfh>qbviOJ%OBa?5LVqL;{n(_kSH)D1}n1#KFa^+*H)E# zTLInY=9cqrWPzP<+?ok-7;0=?tk6e6#n52)ec`OUv$$h7gwBVU%bC7gY(bzu{E#@< zU!FJ&_x!Avy%-e6qsOh%iGy!!cRH~_u=k2!rSci08EelaSI~CVo3tkR&W^~wzih*` z&hKTvE%r@I1O-HHU^-fF>rscc$%^+znpxlHDPRd`W1JDaXm#fk>13_(9e>?B23e5tQG1U)Y&~L%DkX@YRCQ}O#0?nst!h3 zjG@D8b`1^;$S#mlNc`otMKYuTszjkCj4#4&2y$w zGFnSh3d{{K4HZwzl-`xNa2)9|j_ZU^i46-by8%B8P5e{V+19G|A98rN`;3M?Bj+>H zFzqgki_T#|nr9Upvo8E@89AD8gQ>Nc;Cplc4~d8cEO>`x&hbg%d|27`UBF+ppEyCt z5qa3hWfkdV7iryEWd?cM_tSwEuCi@2!`)-ObSn)oiwD{g96Ffz!+a71 zSHqES_tys&#AQ01(BAC~{K*pzhZA57g>UaRS=2%@1wcNXO7n@T*7Z15HSI zDHD_23ZzvwmW}}vEFRD;%IjEAI!{`?1uK6v$?m{Ewjup4+RvUpG0n`}iAaXlA)gyK zEkMLW41gX81EV9|@a+uuR5O>?v7}2N!P$y7mdKC7V%puT-D0RVLG_69*_VLtNkLkg zni54tR)tootOo4c>kPviDZP!F>s(A^#l=>A4I{n+(*E9(&3TOLr$Z?mCU;Y3c_n5W zHmSbUWYU$#5unR&0=E1a)(0<6SR?+>2kbcQYTIRMS9LWVxae%4!&m9aHN8Xsv@y&R zlTA3Y9g7XuvwqV}!2fY#5mXpx81#QHh5vWe00RAN YS=c22EPVZP927}jT3M=0!qESJ0ebBajQ{`u literal 0 HcmV?d00001 From 8f045469a8b38b5a15aae31883a1b00e2c314eca Mon Sep 17 00:00:00 2001 From: David Pires Date: Thu, 21 Jun 2018 19:12:10 -0300 Subject: [PATCH 555/625] implemented possibility to cache functions --- src/target/typescript_nodeserver.cr | 38 +++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 35306e1..a4426cf 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -95,6 +95,23 @@ function toDateTimeString(date: Date) { END + @io << "export const cacheConfig: {\n" + @ast.operations.each do |op| + args = ["ctx: Context"] + op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } + @io << " " << op.pretty_name << "?: (#{args.join(", ")}) => Promise<{key: any, expirationSeconds: number, version: number}>;\n" + end + @io << "} = {};\n\n" + + @ast.struct_types.each do |t| + @io << t.typescript_definition + @io << "\n\n" + end + + @ast.enum_types.each do |t| + @io << t.typescript_definition + @io << "\n\n" + end + @io << "export const fn: {\n" @ast.operations.each do |op| args = ["ctx: Context"] + op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } @@ -124,9 +141,22 @@ END @io << ident ident "const #{arg.name} = #{arg.type.typescript_decode("args.#{arg.name}")};" @io << "\n" end + @io << "\n" + @io << ident ident "let cacheKey: string | null = null, cacheExpirationSeconds: number | null = null, cacheVersion: number | null = null;" + @io << ident ident "if (cacheConfig.#{op.pretty_name}) {" + @io << ident ident ident "try {\n" + @io << ident ident ident ident "const {key, expirationSeconds, version} = await cacheConfig.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" + @io << ident ident ident ident "if (!key) throw "";\n" + @io << ident ident ident ident "cacheKey = JSON.stringfy(key) + \"-#{op.pretty_name}\"; cacheExpirationSeconds = expiresSeconds; cacheVersion = version;" + @io << ident ident ident ident "const cache = await hook.getCache(cacheKey, version);\n" + @io << ident ident ident ident "if (cache && cache.expirationDate > new Date()) return cache.ret;\n" + @io << ident ident ident "} catch(e) {}\n" + @io << ident ident "}\n" @io << ident ident "const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident op.return_type.typescript_check_decoded("ret", "\"#{op.pretty_name}.ret\"") - @io << ident ident "return " + op.return_type.typescript_encode("ret") + ";\n" + @io << ident ident "const encodedRet = " + op.return_type.typescript_encode("ret") + ";\n" + @io << ident ident "if (cacheKey !== null && cacheVersion !== null) hook.setCache(cacheKey, new Date(new Date().getTime() + cacheExpirationSeconds), cacheVersion, encodedRet)" + @io << ident ident "return encodedRet" @io << ident "},\n" end @io << "};\n\n" @@ -205,11 +235,15 @@ export const hook: { onDevice: (id: string, deviceInfo: any) => Promise onReceiveCall: (call: DBApiCall) => Promise afterProcessCall: (call: DBApiCall) => Promise + setCache: (cacheKey: string, expirationDate: Date, version: number, ret: any) => Promise + getCache: (cacheKey: string, version: number) => Promise<{expirationDate: Date, ret: any} | null> } = { onHealthCheck: async () => true, onDevice: async () => {}, onReceiveCall: async () => {}, - afterProcessCall: async () => {} + afterProcessCall: async () => {}, + setCache: async () => {}, + getCache: async () => null }; export function start(port: number = 8000) { From b9026513793c1e3bff300bd7250d15963b8bda58 Mon Sep 17 00:00:00 2001 From: David Pires Date: Thu, 21 Jun 2018 19:14:19 -0300 Subject: [PATCH 556/625] fix missing \ --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index a4426cf..cefa18e 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -146,7 +146,7 @@ END @io << ident ident "if (cacheConfig.#{op.pretty_name}) {" @io << ident ident ident "try {\n" @io << ident ident ident ident "const {key, expirationSeconds, version} = await cacheConfig.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" - @io << ident ident ident ident "if (!key) throw "";\n" + @io << ident ident ident ident "if (!key) throw \"\";\n" @io << ident ident ident ident "cacheKey = JSON.stringfy(key) + \"-#{op.pretty_name}\"; cacheExpirationSeconds = expiresSeconds; cacheVersion = version;" @io << ident ident ident ident "const cache = await hook.getCache(cacheKey, version);\n" @io << ident ident ident ident "if (cache && cache.expirationDate > new Date()) return cache.ret;\n" From 75d390b53c47aa14cb678e6c3734abe23af35ee6 Mon Sep 17 00:00:00 2001 From: David Pires Date: Thu, 21 Jun 2018 19:22:36 -0300 Subject: [PATCH 557/625] fix build --- src/target/typescript_nodeserver.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index cefa18e..5ee89f4 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -147,7 +147,7 @@ END @io << ident ident ident "try {\n" @io << ident ident ident ident "const {key, expirationSeconds, version} = await cacheConfig.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident ident ident "if (!key) throw \"\";\n" - @io << ident ident ident ident "cacheKey = JSON.stringfy(key) + \"-#{op.pretty_name}\"; cacheExpirationSeconds = expiresSeconds; cacheVersion = version;" + @io << ident ident ident ident "cacheKey = JSON.stringfy(key) + \"-#{op.pretty_name}\"; cacheExpirationSeconds = expirationSeconds; cacheVersion = version;" @io << ident ident ident ident "const cache = await hook.getCache(cacheKey, version);\n" @io << ident ident ident ident "if (cache && cache.expirationDate > new Date()) return cache.ret;\n" @io << ident ident ident "} catch(e) {}\n" @@ -155,7 +155,7 @@ END @io << ident ident "const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident op.return_type.typescript_check_decoded("ret", "\"#{op.pretty_name}.ret\"") @io << ident ident "const encodedRet = " + op.return_type.typescript_encode("ret") + ";\n" - @io << ident ident "if (cacheKey !== null && cacheVersion !== null) hook.setCache(cacheKey, new Date(new Date().getTime() + cacheExpirationSeconds), cacheVersion, encodedRet)" + @io << ident ident "if (cacheKey !== null && cacheVersion !== null && cacheExpirationSeconds !== null) hook.setCache(cacheKey, new Date(new Date().getTime() + cacheExpirationSeconds), cacheVersion, encodedRet)" @io << ident ident "return encodedRet" @io << ident "},\n" end From 95ea936112fd9c78f9b6038ec59c8c08fde91ede Mon Sep 17 00:00:00 2001 From: David Pires Date: Thu, 21 Jun 2018 19:27:33 -0300 Subject: [PATCH 558/625] fix build --- src/target/typescript_nodeserver.cr | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 5ee89f4..fe1b861 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -123,16 +123,6 @@ END end @io << "};\n\n" - @ast.struct_types.each do |t| - @io << t.typescript_definition - @io << "\n\n" - end - - @ast.enum_types.each do |t| - @io << t.typescript_definition - @io << "\n\n" - end - @io << "const fnExec: {[name: string]: (ctx: Context, args: any) => Promise} = {\n" @ast.operations.each do |op| @io << " " << op.pretty_name << ": async (ctx: Context, args: any) => {\n" @@ -147,7 +137,7 @@ END @io << ident ident ident "try {\n" @io << ident ident ident ident "const {key, expirationSeconds, version} = await cacheConfig.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident ident ident "if (!key) throw \"\";\n" - @io << ident ident ident ident "cacheKey = JSON.stringfy(key) + \"-#{op.pretty_name}\"; cacheExpirationSeconds = expirationSeconds; cacheVersion = version;" + @io << ident ident ident ident "cacheKey = JSON.stringify(key) + \"-#{op.pretty_name}\"; cacheExpirationSeconds = expirationSeconds; cacheVersion = version;" @io << ident ident ident ident "const cache = await hook.getCache(cacheKey, version);\n" @io << ident ident ident ident "if (cache && cache.expirationDate > new Date()) return cache.ret;\n" @io << ident ident ident "} catch(e) {}\n" @@ -155,7 +145,7 @@ END @io << ident ident "const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident op.return_type.typescript_check_decoded("ret", "\"#{op.pretty_name}.ret\"") @io << ident ident "const encodedRet = " + op.return_type.typescript_encode("ret") + ";\n" - @io << ident ident "if (cacheKey !== null && cacheVersion !== null && cacheExpirationSeconds !== null) hook.setCache(cacheKey, new Date(new Date().getTime() + cacheExpirationSeconds), cacheVersion, encodedRet)" + @io << ident ident "if (cacheKey !== null && cacheVersion !== null && cacheExpirationSeconds !== null) hook.setCache(cacheKey, new Date(new Date().getTime() + cacheExpirationSeconds), cacheVersion, encodedRet);\n" @io << ident ident "return encodedRet" @io << ident "},\n" end From 85fcf9e8cefad8da7695cdceec2d999ed746ae3e Mon Sep 17 00:00:00 2001 From: David Pires Date: Thu, 21 Jun 2018 19:51:48 -0300 Subject: [PATCH 559/625] fix hash --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index fe1b861..b1fb74f 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -137,7 +137,7 @@ END @io << ident ident ident "try {\n" @io << ident ident ident ident "const {key, expirationSeconds, version} = await cacheConfig.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident ident ident "if (!key) throw \"\";\n" - @io << ident ident ident ident "cacheKey = JSON.stringify(key) + \"-#{op.pretty_name}\"; cacheExpirationSeconds = expirationSeconds; cacheVersion = version;" + @io << ident ident ident ident "cacheKey = crypto.createHash(\"sha256\").update(JSON.stringify(key)+ \"-#{op.pretty_name}\").digest(\"hex\").substr(0, 100); cacheExpirationSeconds = expirationSeconds; cacheVersion = version;\n" @io << ident ident ident ident "const cache = await hook.getCache(cacheKey, version);\n" @io << ident ident ident ident "if (cache && cache.expirationDate > new Date()) return cache.ret;\n" @io << ident ident ident "} catch(e) {}\n" From 0bbfc72eb27cb9bbd88d8bd0a1671fefa584acba Mon Sep 17 00:00:00 2001 From: Guilherme Bernal Date: Thu, 21 Jun 2018 19:59:31 -0300 Subject: [PATCH 560/625] Check duplicated function by pretty_name --- src/semantic/check_multiple_declaration.cr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/semantic/check_multiple_declaration.cr b/src/semantic/check_multiple_declaration.cr index 9674f1d..ed403d8 100644 --- a/src/semantic/check_multiple_declaration.cr +++ b/src/semantic/check_multiple_declaration.cr @@ -14,10 +14,10 @@ module Semantic end def visit(op : AST::Operation) - if @op_names.includes? op.name - raise SemanticException.new("Function '#{op.name}' is declared multiples times") + if @op_names.includes? op.pretty_name + raise SemanticException.new("Function '#{op.pretty_name}' is declared multiples times") end - @op_names << op.name + @op_names << op.pretty_name super end end From 96b2a0d6bca24a2063882a7d7f924302ef56b98f Mon Sep 17 00:00:00 2001 From: David Pires Date: Thu, 21 Jun 2018 20:19:33 -0300 Subject: [PATCH 561/625] fix expirationSeconds in cache --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index b1fb74f..b7e27f5 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -145,7 +145,7 @@ END @io << ident ident "const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident op.return_type.typescript_check_decoded("ret", "\"#{op.pretty_name}.ret\"") @io << ident ident "const encodedRet = " + op.return_type.typescript_encode("ret") + ";\n" - @io << ident ident "if (cacheKey !== null && cacheVersion !== null && cacheExpirationSeconds !== null) hook.setCache(cacheKey, new Date(new Date().getTime() + cacheExpirationSeconds), cacheVersion, encodedRet);\n" + @io << ident ident "if (cacheKey !== null && cacheVersion !== null && cacheExpirationSeconds !== null) hook.setCache(cacheKey, new Date(new Date().getTime() + (cacheExpirationSeconds * 1000)), cacheVersion, encodedRet);\n" @io << ident ident "return encodedRet" @io << ident "},\n" end From c891f7137b47c698a8a7922d1a7610815c986db4 Mon Sep 17 00:00:00 2001 From: David Pires Date: Thu, 21 Jun 2018 20:32:17 -0300 Subject: [PATCH 562/625] logs --- src/target/typescript_nodeserver.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index b7e27f5..b359a39 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -132,15 +132,15 @@ END @io << "\n" end @io << "\n" - @io << ident ident "let cacheKey: string | null = null, cacheExpirationSeconds: number | null = null, cacheVersion: number | null = null;" - @io << ident ident "if (cacheConfig.#{op.pretty_name}) {" + @io << ident ident "let cacheKey: string | null = null, cacheExpirationSeconds: number | null = null, cacheVersion: number | null = null;\n" + @io << ident ident "if (cacheConfig.#{op.pretty_name}) {\n" @io << ident ident ident "try {\n" @io << ident ident ident ident "const {key, expirationSeconds, version} = await cacheConfig.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident ident ident "if (!key) throw \"\";\n" @io << ident ident ident ident "cacheKey = crypto.createHash(\"sha256\").update(JSON.stringify(key)+ \"-#{op.pretty_name}\").digest(\"hex\").substr(0, 100); cacheExpirationSeconds = expirationSeconds; cacheVersion = version;\n" - @io << ident ident ident ident "const cache = await hook.getCache(cacheKey, version);\n" + @io << ident ident ident ident "const cache = await hook.getCache(cacheKey, version);console.log(JSON.stringify(cache));\n" @io << ident ident ident ident "if (cache && cache.expirationDate > new Date()) return cache.ret;\n" - @io << ident ident ident "} catch(e) {}\n" + @io << ident ident ident "} catch(e) {console.log(JSON.stringify(e));}\n" @io << ident ident "}\n" @io << ident ident "const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident op.return_type.typescript_check_decoded("ret", "\"#{op.pretty_name}.ret\"") From aadda3da48db9a89600c7c21a12fdadf9c767a2b Mon Sep 17 00:00:00 2001 From: David Pires Date: Thu, 21 Jun 2018 21:01:27 -0300 Subject: [PATCH 563/625] added possibility to expiration date to be null --- src/target/typescript_nodeserver.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index b359a39..8423a1a 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -139,13 +139,13 @@ END @io << ident ident ident ident "if (!key) throw \"\";\n" @io << ident ident ident ident "cacheKey = crypto.createHash(\"sha256\").update(JSON.stringify(key)+ \"-#{op.pretty_name}\").digest(\"hex\").substr(0, 100); cacheExpirationSeconds = expirationSeconds; cacheVersion = version;\n" @io << ident ident ident ident "const cache = await hook.getCache(cacheKey, version);console.log(JSON.stringify(cache));\n" - @io << ident ident ident ident "if (cache && cache.expirationDate > new Date()) return cache.ret;\n" + @io << ident ident ident ident "if (cache && (!cache.expirationDate || cache.expirationDate > new Date())) return cache.ret;\n" @io << ident ident ident "} catch(e) {console.log(JSON.stringify(e));}\n" @io << ident ident "}\n" @io << ident ident "const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident op.return_type.typescript_check_decoded("ret", "\"#{op.pretty_name}.ret\"") @io << ident ident "const encodedRet = " + op.return_type.typescript_encode("ret") + ";\n" - @io << ident ident "if (cacheKey !== null && cacheVersion !== null && cacheExpirationSeconds !== null) hook.setCache(cacheKey, new Date(new Date().getTime() + (cacheExpirationSeconds * 1000)), cacheVersion, encodedRet);\n" + @io << ident ident "if (cacheKey !== null && cacheVersion !== null) hook.setCache(cacheKey, cacheExpirationSeconds ? new Date(new Date().getTime() + (cacheExpirationSeconds * 1000)) : null, cacheVersion, encodedRet);\n" @io << ident ident "return encodedRet" @io << ident "},\n" end @@ -225,8 +225,8 @@ export const hook: { onDevice: (id: string, deviceInfo: any) => Promise onReceiveCall: (call: DBApiCall) => Promise afterProcessCall: (call: DBApiCall) => Promise - setCache: (cacheKey: string, expirationDate: Date, version: number, ret: any) => Promise - getCache: (cacheKey: string, version: number) => Promise<{expirationDate: Date, ret: any} | null> + setCache: (cacheKey: string, expirationDate: Date | null, version: number, ret: any) => Promise + getCache: (cacheKey: string, version: number) => Promise<{expirationDate: Date | null, ret: any} | null> } = { onHealthCheck: async () => true, onDevice: async () => {}, From dba2559fb72bc0b6c31cafb8a41d85470c30734b Mon Sep 17 00:00:00 2001 From: David Pires Date: Thu, 21 Jun 2018 21:04:53 -0300 Subject: [PATCH 564/625] added possibility to expiration date to be null --- src/target/typescript_nodeserver.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 8423a1a..4ebe0c6 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -98,7 +98,7 @@ END @io << "export const cacheConfig: {\n" @ast.operations.each do |op| args = ["ctx: Context"] + op.args.map { |arg| "#{arg.name}: #{arg.type.typescript_native_type}" } - @io << " " << op.pretty_name << "?: (#{args.join(", ")}) => Promise<{key: any, expirationSeconds: number, version: number}>;\n" + @io << " " << op.pretty_name << "?: (#{args.join(", ")}) => Promise<{key: any, expirationSeconds: number | null, version: number}>;\n" end @io << "} = {};\n\n" From 0cd41720395857deb463978cc9f76d2f42dcc85c Mon Sep 17 00:00:00 2001 From: davidcpires Date: Fri, 22 Jun 2018 11:52:16 -0300 Subject: [PATCH 565/625] Added function name and decoded key to set cache (#34) * added function name and decoded key to set cache * added function name and decoded key to set cache * added function name and decoded key to set cache * stringfy the name of the funciton --- src/target/typescript_nodeserver.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/target/typescript_nodeserver.cr b/src/target/typescript_nodeserver.cr index 4ebe0c6..670f50a 100644 --- a/src/target/typescript_nodeserver.cr +++ b/src/target/typescript_nodeserver.cr @@ -132,12 +132,12 @@ END @io << "\n" end @io << "\n" - @io << ident ident "let cacheKey: string | null = null, cacheExpirationSeconds: number | null = null, cacheVersion: number | null = null;\n" + @io << ident ident "let cacheKey: string | null = null, decodedKey: string | null = null, cacheExpirationSeconds: number | null = null, cacheVersion: number | null = null;\n" @io << ident ident "if (cacheConfig.#{op.pretty_name}) {\n" @io << ident ident ident "try {\n" @io << ident ident ident ident "const {key, expirationSeconds, version} = await cacheConfig.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident ident ident "if (!key) throw \"\";\n" - @io << ident ident ident ident "cacheKey = crypto.createHash(\"sha256\").update(JSON.stringify(key)+ \"-#{op.pretty_name}\").digest(\"hex\").substr(0, 100); cacheExpirationSeconds = expirationSeconds; cacheVersion = version;\n" + @io << ident ident ident ident "cacheKey = crypto.createHash(\"sha256\").update(JSON.stringify(key)+ \"-#{op.pretty_name}\").digest(\"hex\").substr(0, 100); decodedKey = JSON.stringify(key); cacheExpirationSeconds = expirationSeconds; cacheVersion = version;\n" @io << ident ident ident ident "const cache = await hook.getCache(cacheKey, version);console.log(JSON.stringify(cache));\n" @io << ident ident ident ident "if (cache && (!cache.expirationDate || cache.expirationDate > new Date())) return cache.ret;\n" @io << ident ident ident "} catch(e) {console.log(JSON.stringify(e));}\n" @@ -145,7 +145,7 @@ END @io << ident ident "const ret = await fn.#{op.pretty_name}(#{(["ctx"] + op.args.map(&.name)).join(", ")});\n" @io << ident ident op.return_type.typescript_check_decoded("ret", "\"#{op.pretty_name}.ret\"") @io << ident ident "const encodedRet = " + op.return_type.typescript_encode("ret") + ";\n" - @io << ident ident "if (cacheKey !== null && cacheVersion !== null) hook.setCache(cacheKey, cacheExpirationSeconds ? new Date(new Date().getTime() + (cacheExpirationSeconds * 1000)) : null, cacheVersion, encodedRet);\n" + @io << ident ident "if (cacheKey !== null && cacheVersion !== null) hook.setCache(cacheKey, cacheExpirationSeconds ? new Date(new Date().getTime() + (cacheExpirationSeconds * 1000)) : null, cacheVersion, decodedKey!, \"#{op.pretty_name}\", encodedRet);\n" @io << ident ident "return encodedRet" @io << ident "},\n" end @@ -225,7 +225,7 @@ export const hook: { onDevice: (id: string, deviceInfo: any) => Promise onReceiveCall: (call: DBApiCall) => Promise afterProcessCall: (call: DBApiCall) => Promise - setCache: (cacheKey: string, expirationDate: Date | null, version: number, ret: any) => Promise + setCache: (cacheKey: string, expirationDate: Date | null, version: number, decodedKey: string, fnName: string, ret: any) => Promise getCache: (cacheKey: string, version: number) => Promise<{expirationDate: Date | null, ret: any} | null> } = { onHealthCheck: async () => true, From d37aba8bfd8e30bca650ca7ab22679872315b2b8 Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Tue, 3 Jul 2018 21:16:26 -0300 Subject: [PATCH 566/625] only push image to registry when a tag is present --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ef3d24f..4dcfad0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ services: - docker script: - - docker build -t cubos/sdkgen . + - docker build -t cubos/sdkgen -t whenry/fedora-jboss:${TRAVIS_TAG} . deploy: provider: script @@ -12,3 +12,4 @@ deploy: script: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" && docker push cubos/sdkgen on: branch: master + tags: true From d2db0719aa6c8697cc602b7cb202a691a5ef1fba Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Tue, 3 Jul 2018 21:25:49 -0300 Subject: [PATCH 567/625] fixing typo on env variable importation --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4dcfad0..ee1e5e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ services: - docker script: - - docker build -t cubos/sdkgen -t whenry/fedora-jboss:${TRAVIS_TAG} . + - docker build -t cubos/sdkgen -t cubos/sdkgen:$TRAVIS_TAG . deploy: provider: script From d0859a6cbb4f14ca2363466c9a7269d7910c892b Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Tue, 3 Jul 2018 21:34:03 -0300 Subject: [PATCH 568/625] adding quotation marks for the env variable to get them parsed by travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ee1e5e7..2781217 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ services: - docker script: - - docker build -t cubos/sdkgen -t cubos/sdkgen:$TRAVIS_TAG . + - docker build -t cubos/sdkgen -t cubos/sdkgen:"$TRAVIS_TAG" . deploy: provider: script From 427e0907126c05629e4e8dbc0aa786e0f152c608 Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Tue, 3 Jul 2018 22:13:04 -0300 Subject: [PATCH 569/625] verifing TRAVIS_TAG existence before build --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2781217..2f5596f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,9 @@ services: - docker script: - - docker build -t cubos/sdkgen -t cubos/sdkgen:"$TRAVIS_TAG" . + - if [[ "$TRAVIS_TAG" ]] ; then + docker build -t cubos/sdkgen -t cubos/sdkgen:$TRAVIS_TAG . ; + fi deploy: provider: script From 7b579d00bddaa7feec128c894c26d644a9e81b99 Mon Sep 17 00:00:00 2001 From: Rodrigo Araujo Date: Tue, 3 Jul 2018 22:13:47 -0300 Subject: [PATCH 570/625] adding raw docusaurus --- .gitignore | 15 +- docs/doc1.md | 29 +++ docs/doc2.md | 7 + docs/doc3.md | 13 ++ docs/exampledoc4.md | 6 + docs/exampledoc5.md | 6 + website/blog/2016-03-11-blog-post.md | 18 ++ website/blog/2017-04-10-blog-post-two.md | 18 ++ website/blog/2017-09-25-testing-rss.md | 11 + website/blog/2017-09-26-adding-rss.md | 10 + website/blog/2017-10-24-new-version-1.0.0.md | 8 + website/core/Footer.js | 102 +++++++++ website/package.json | 14 ++ website/pages/en/help.js | 57 +++++ website/pages/en/index.js | 219 +++++++++++++++++++ website/pages/en/users.js | 49 +++++ website/sidebars.json | 10 + website/siteConfig.js | 99 +++++++++ website/static/css/custom.css | 16 ++ website/static/img/docusaurus.svg | 1 + website/static/img/favicon.png | Bin 0 -> 984 bytes website/static/img/favicon/favicon.ico | Bin 0 -> 9662 bytes website/static/img/oss_logo.png | Bin 0 -> 4370 bytes 23 files changed, 707 insertions(+), 1 deletion(-) create mode 100644 docs/doc1.md create mode 100644 docs/doc2.md create mode 100644 docs/doc3.md create mode 100644 docs/exampledoc4.md create mode 100644 docs/exampledoc5.md create mode 100755 website/blog/2016-03-11-blog-post.md create mode 100644 website/blog/2017-04-10-blog-post-two.md create mode 100644 website/blog/2017-09-25-testing-rss.md create mode 100644 website/blog/2017-09-26-adding-rss.md create mode 100644 website/blog/2017-10-24-new-version-1.0.0.md create mode 100644 website/core/Footer.js create mode 100644 website/package.json create mode 100755 website/pages/en/help.js create mode 100755 website/pages/en/index.js create mode 100644 website/pages/en/users.js create mode 100644 website/sidebars.json create mode 100644 website/siteConfig.js create mode 100644 website/static/css/custom.css create mode 100644 website/static/img/docusaurus.svg create mode 100644 website/static/img/favicon.png create mode 100644 website/static/img/favicon/favicon.ico create mode 100644 website/static/img/oss_logo.png diff --git a/.gitignore b/.gitignore index c083c61..44c3355 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,14 @@ -sdkgen2 \ No newline at end of file +sdkgen2 + +.DS_Store + +node_modules + +lib/core/metadata.js +lib/core/MetadataBlog.js + +website/translated_docs +website/build/ +website/yarn.lock +website/node_modules +website/i18n/* diff --git a/docs/doc1.md b/docs/doc1.md new file mode 100644 index 0000000..37fa73f --- /dev/null +++ b/docs/doc1.md @@ -0,0 +1,29 @@ +--- +id: doc1 +title: Latin-ish +sidebar_label: Example Page +--- + +Check the [documentation](https://docusaurus.io) for how to use Docusaurus. + +## Lorem + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus elementum massa eget nulla aliquet sagittis. Proin odio tortor, vulputate ut odio in, ultrices ultricies augue. Cras ornare ultrices lorem malesuada iaculis. Etiam sit amet libero tempor, pulvinar mauris sed, sollicitudin sapien. + +## Mauris In Code + +``` +Mauris vestibulum ullamcorper nibh, ut semper purus pulvinar ut. Donec volutpat orci sit amet mauris malesuada, non pulvinar augue aliquam. Vestibulum ultricies at urna ut suscipit. Morbi iaculis, erat at imperdiet semper, ipsum nulla sodales erat, eget tincidunt justo dui quis justo. Pellentesque dictum bibendum diam at aliquet. Sed pulvinar, dolor quis finibus ornare, eros odio facilisis erat, eu rhoncus nunc dui sed ex. Nunc gravida dui massa, sed ornare arcu tincidunt sit amet. Maecenas efficitur sapien neque, a laoreet libero feugiat ut. +``` + +## Nulla + +Nulla facilisi. Maecenas sodales nec purus eget posuere. Sed sapien quam, pretium a risus in, porttitor dapibus erat. Sed sit amet fringilla ipsum, eget iaculis augue. Integer sollicitudin tortor quis ultricies aliquam. Suspendisse fringilla nunc in tellus cursus, at placerat tellus scelerisque. Sed tempus elit a sollicitudin rhoncus. Nulla facilisi. Morbi nec dolor dolor. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras et aliquet lectus. Pellentesque sit amet eros nisi. Quisque ac sapien in sapien congue accumsan. Nullam in posuere ante. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin lacinia leo a nibh fringilla pharetra. + +## Orci + +Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin venenatis lectus dui, vel ultrices ante bibendum hendrerit. Aenean egestas feugiat dui id hendrerit. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Curabitur in tellus laoreet, eleifend nunc id, viverra leo. Proin vulputate non dolor vel vulputate. Curabitur pretium lobortis felis, sit amet finibus lorem suscipit ut. Sed non mollis risus. Duis sagittis, mi in euismod tincidunt, nunc mauris vestibulum urna, at euismod est elit quis erat. Phasellus accumsan vitae neque eu placerat. In elementum arcu nec tellus imperdiet, eget maximus nulla sodales. Curabitur eu sapien eget nisl sodales fermentum. + +## Phasellus + +Phasellus pulvinar ex id commodo imperdiet. Praesent odio nibh, sollicitudin sit amet faucibus id, placerat at metus. Donec vitae eros vitae tortor hendrerit finibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque vitae purus dolor. Duis suscipit ac nulla et finibus. Phasellus ac sem sed dui dictum gravida. Phasellus eleifend vestibulum facilisis. Integer pharetra nec enim vitae mattis. Duis auctor, lectus quis condimentum bibendum, nunc dolor aliquam massa, id bibendum orci velit quis magna. Ut volutpat nulla nunc, sed interdum magna condimentum non. Sed urna metus, scelerisque vitae consectetur a, feugiat quis magna. Donec dignissim ornare nisl, eget tempor risus malesuada quis. diff --git a/docs/doc2.md b/docs/doc2.md new file mode 100644 index 0000000..20c0c95 --- /dev/null +++ b/docs/doc2.md @@ -0,0 +1,7 @@ +--- +id: doc2 +title: document number 2 +--- + +This is a link to [another document.](doc3.md) +This is a link to an [external page.](http://www.example.com) diff --git a/docs/doc3.md b/docs/doc3.md new file mode 100644 index 0000000..bcb9054 --- /dev/null +++ b/docs/doc3.md @@ -0,0 +1,13 @@ +--- +id: doc3 +title: This is document number 3 +--- +Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ac euismod odio, eu consequat dui. Nullam molestie consectetur risus id imperdiet. Proin sodales ornare turpis, non mollis massa ultricies id. Nam at nibh scelerisque, feugiat ante non, dapibus tortor. Vivamus volutpat diam quis tellus elementum bibendum. Praesent semper gravida velit quis aliquam. Etiam in cursus neque. Nam lectus ligula, malesuada et mauris a, bibendum faucibus mi. Phasellus ut interdum felis. Phasellus in odio pulvinar, porttitor urna eget, fringilla lectus. Aliquam sollicitudin est eros. Mauris consectetur quam vitae mauris interdum hendrerit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. + +Duis et egestas libero, imperdiet faucibus ipsum. Sed posuere eget urna vel feugiat. Vivamus a arcu sagittis, fermentum urna dapibus, congue lectus. Fusce vulputate porttitor nisl, ac cursus elit volutpat vitae. Nullam vitae ipsum egestas, convallis quam non, porta nibh. Morbi gravida erat nec neque bibendum, eu pellentesque velit posuere. Fusce aliquam erat eu massa eleifend tristique. + +Sed consequat sollicitudin ipsum eget tempus. Integer a aliquet velit. In justo nibh, pellentesque non suscipit eget, gravida vel lacus. Donec odio ante, malesuada in massa quis, pharetra tristique ligula. Donec eros est, tristique eget finibus quis, semper non nisl. Vivamus et elit nec enim ornare placerat. Sed posuere odio a elit cursus sagittis. + +Phasellus feugiat purus eu tortor ultrices finibus. Ut libero nibh, lobortis et libero nec, dapibus posuere eros. Sed sagittis euismod justo at consectetur. Nulla finibus libero placerat, cursus sapien at, eleifend ligula. Vivamus elit nisl, hendrerit ac nibh eu, ultrices tempus dui. Nam tellus neque, commodo non rhoncus eu, gravida in risus. Nullam id iaculis tortor. + +Nullam at odio in sem varius tempor sit amet vel lorem. Etiam eu hendrerit nisl. Fusce nibh mauris, vulputate sit amet ex vitae, congue rhoncus nisl. Sed eget tellus purus. Nullam tempus commodo erat ut tristique. Cras accumsan massa sit amet justo consequat eleifend. Integer scelerisque vitae tellus id consectetur. diff --git a/docs/exampledoc4.md b/docs/exampledoc4.md new file mode 100644 index 0000000..6f94ffe --- /dev/null +++ b/docs/exampledoc4.md @@ -0,0 +1,6 @@ +--- +id: doc4 +title: Other Document +--- + +this is another document diff --git a/docs/exampledoc5.md b/docs/exampledoc5.md new file mode 100644 index 0000000..92e2d0d --- /dev/null +++ b/docs/exampledoc5.md @@ -0,0 +1,6 @@ +--- +id: doc5 +title: Fifth Document +--- + +Another one diff --git a/website/blog/2016-03-11-blog-post.md b/website/blog/2016-03-11-blog-post.md new file mode 100755 index 0000000..cf2ba29 --- /dev/null +++ b/website/blog/2016-03-11-blog-post.md @@ -0,0 +1,18 @@ +--- +title: Blog Title +author: Blog Author +authorURL: http://twitter.com/ +authorFBID: 100002976521003 +--- + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus elementum massa eget nulla aliquet sagittis. Proin odio tortor, vulputate ut odio in, ultrices ultricies augue. Cras ornare ultrices lorem malesuada iaculis. Etiam sit amet libero tempor, pulvinar mauris sed, sollicitudin sapien. + + + +Mauris vestibulum ullamcorper nibh, ut semper purus pulvinar ut. Donec volutpat orci sit amet mauris malesuada, non pulvinar augue aliquam. Vestibulum ultricies at urna ut suscipit. Morbi iaculis, erat at imperdiet semper, ipsum nulla sodales erat, eget tincidunt justo dui quis justo. Pellentesque dictum bibendum diam at aliquet. Sed pulvinar, dolor quis finibus ornare, eros odio facilisis erat, eu rhoncus nunc dui sed ex. Nunc gravida dui massa, sed ornare arcu tincidunt sit amet. Maecenas efficitur sapien neque, a laoreet libero feugiat ut. + +Nulla facilisi. Maecenas sodales nec purus eget posuere. Sed sapien quam, pretium a risus in, porttitor dapibus erat. Sed sit amet fringilla ipsum, eget iaculis augue. Integer sollicitudin tortor quis ultricies aliquam. Suspendisse fringilla nunc in tellus cursus, at placerat tellus scelerisque. Sed tempus elit a sollicitudin rhoncus. Nulla facilisi. Morbi nec dolor dolor. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras et aliquet lectus. Pellentesque sit amet eros nisi. Quisque ac sapien in sapien congue accumsan. Nullam in posuere ante. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin lacinia leo a nibh fringilla pharetra. + +Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin venenatis lectus dui, vel ultrices ante bibendum hendrerit. Aenean egestas feugiat dui id hendrerit. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Curabitur in tellus laoreet, eleifend nunc id, viverra leo. Proin vulputate non dolor vel vulputate. Curabitur pretium lobortis felis, sit amet finibus lorem suscipit ut. Sed non mollis risus. Duis sagittis, mi in euismod tincidunt, nunc mauris vestibulum urna, at euismod est elit quis erat. Phasellus accumsan vitae neque eu placerat. In elementum arcu nec tellus imperdiet, eget maximus nulla sodales. Curabitur eu sapien eget nisl sodales fermentum. + +Phasellus pulvinar ex id commodo imperdiet. Praesent odio nibh, sollicitudin sit amet faucibus id, placerat at metus. Donec vitae eros vitae tortor hendrerit finibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque vitae purus dolor. Duis suscipit ac nulla et finibus. Phasellus ac sem sed dui dictum gravida. Phasellus eleifend vestibulum facilisis. Integer pharetra nec enim vitae mattis. Duis auctor, lectus quis condimentum bibendum, nunc dolor aliquam massa, id bibendum orci velit quis magna. Ut volutpat nulla nunc, sed interdum magna condimentum non. Sed urna metus, scelerisque vitae consectetur a, feugiat quis magna. Donec dignissim ornare nisl, eget tempor risus malesuada quis. diff --git a/website/blog/2017-04-10-blog-post-two.md b/website/blog/2017-04-10-blog-post-two.md new file mode 100644 index 0000000..3ab4637 --- /dev/null +++ b/website/blog/2017-04-10-blog-post-two.md @@ -0,0 +1,18 @@ +--- +title: New Blog Post +author: Blog Author +authorURL: http://twitter.com/ +authorFBID: 100002976521003 +--- + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus elementum massa eget nulla aliquet sagittis. Proin odio tortor, vulputate ut odio in, ultrices ultricies augue. Cras ornare ultrices lorem malesuada iaculis. Etiam sit amet libero tempor, pulvinar mauris sed, sollicitudin sapien. + + + +Mauris vestibulum ullamcorper nibh, ut semper purus pulvinar ut. Donec volutpat orci sit amet mauris malesuada, non pulvinar augue aliquam. Vestibulum ultricies at urna ut suscipit. Morbi iaculis, erat at imperdiet semper, ipsum nulla sodales erat, eget tincidunt justo dui quis justo. Pellentesque dictum bibendum diam at aliquet. Sed pulvinar, dolor quis finibus ornare, eros odio facilisis erat, eu rhoncus nunc dui sed ex. Nunc gravida dui massa, sed ornare arcu tincidunt sit amet. Maecenas efficitur sapien neque, a laoreet libero feugiat ut. + +Nulla facilisi. Maecenas sodales nec purus eget posuere. Sed sapien quam, pretium a risus in, porttitor dapibus erat. Sed sit amet fringilla ipsum, eget iaculis augue. Integer sollicitudin tortor quis ultricies aliquam. Suspendisse fringilla nunc in tellus cursus, at placerat tellus scelerisque. Sed tempus elit a sollicitudin rhoncus. Nulla facilisi. Morbi nec dolor dolor. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras et aliquet lectus. Pellentesque sit amet eros nisi. Quisque ac sapien in sapien congue accumsan. Nullam in posuere ante. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Proin lacinia leo a nibh fringilla pharetra. + +Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin venenatis lectus dui, vel ultrices ante bibendum hendrerit. Aenean egestas feugiat dui id hendrerit. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Curabitur in tellus laoreet, eleifend nunc id, viverra leo. Proin vulputate non dolor vel vulputate. Curabitur pretium lobortis felis, sit amet finibus lorem suscipit ut. Sed non mollis risus. Duis sagittis, mi in euismod tincidunt, nunc mauris vestibulum urna, at euismod est elit quis erat. Phasellus accumsan vitae neque eu placerat. In elementum arcu nec tellus imperdiet, eget maximus nulla sodales. Curabitur eu sapien eget nisl sodales fermentum. + +Phasellus pulvinar ex id commodo imperdiet. Praesent odio nibh, sollicitudin sit amet faucibus id, placerat at metus. Donec vitae eros vitae tortor hendrerit finibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque vitae purus dolor. Duis suscipit ac nulla et finibus. Phasellus ac sem sed dui dictum gravida. Phasellus eleifend vestibulum facilisis. Integer pharetra nec enim vitae mattis. Duis auctor, lectus quis condimentum bibendum, nunc dolor aliquam massa, id bibendum orci velit quis magna. Ut volutpat nulla nunc, sed interdum magna condimentum non. Sed urna metus, scelerisque vitae consectetur a, feugiat quis magna. Donec dignissim ornare nisl, eget tempor risus malesuada quis. diff --git a/website/blog/2017-09-25-testing-rss.md b/website/blog/2017-09-25-testing-rss.md new file mode 100644 index 0000000..b7ff812 --- /dev/null +++ b/website/blog/2017-09-25-testing-rss.md @@ -0,0 +1,11 @@ +--- +title: Adding RSS Support - RSS Truncation Test +author: Eric Nakagawa +authorURL: http://twitter.com/ericnakagawa +authorFBID: 661277173 +--- +1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 + +This should be truncated. + +This line should never render in XML. diff --git a/website/blog/2017-09-26-adding-rss.md b/website/blog/2017-09-26-adding-rss.md new file mode 100644 index 0000000..eeb4f04 --- /dev/null +++ b/website/blog/2017-09-26-adding-rss.md @@ -0,0 +1,10 @@ +--- +title: Adding RSS Support +author: Eric Nakagawa +authorURL: http://twitter.com/ericnakagawa +authorFBID: 661277173 +--- + +This is a test post. + +A whole bunch of other information. diff --git a/website/blog/2017-10-24-new-version-1.0.0.md b/website/blog/2017-10-24-new-version-1.0.0.md new file mode 100644 index 0000000..60761c0 --- /dev/null +++ b/website/blog/2017-10-24-new-version-1.0.0.md @@ -0,0 +1,8 @@ +--- +title: New Version 1.0.0 +author: Eric Nakagawa +authorURL: http://twitter.com/ericnakagawa +authorFBID: 661277173 +--- + +This blog post will test file name parsing issues when periods are present. diff --git a/website/core/Footer.js b/website/core/Footer.js new file mode 100644 index 0000000..b43f1d6 --- /dev/null +++ b/website/core/Footer.js @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +const React = require('react'); + +class Footer extends React.Component { + docUrl(doc, language) { + const baseUrl = this.props.config.baseUrl; + return baseUrl + 'docs/' + (language ? language + '/' : '') + doc; + } + + pageUrl(doc, language) { + const baseUrl = this.props.config.baseUrl; + return baseUrl + (language ? language + '/' : '') + doc; + } + + render() { + const currentYear = new Date().getFullYear(); + return ( + + ); + } +} + +module.exports = Footer; diff --git a/website/package.json b/website/package.json new file mode 100644 index 0000000..6b6365d --- /dev/null +++ b/website/package.json @@ -0,0 +1,14 @@ +{ + "scripts": { + "examples": "docusaurus-examples", + "start": "docusaurus-start", + "build": "docusaurus-build", + "publish-gh-pages": "docusaurus-publish", + "write-translations": "docusaurus-write-translations", + "version": "docusaurus-version", + "rename-version": "docusaurus-rename-version" + }, + "devDependencies": { + "docusaurus": "^1.3.1" + } +} diff --git a/website/pages/en/help.js b/website/pages/en/help.js new file mode 100755 index 0000000..6434d77 --- /dev/null +++ b/website/pages/en/help.js @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +const React = require('react'); + +const CompLibrary = require('../../core/CompLibrary.js'); +const Container = CompLibrary.Container; +const GridBlock = CompLibrary.GridBlock; + +const siteConfig = require(process.cwd() + '/siteConfig.js'); + +function docUrl(doc, language) { + return siteConfig.baseUrl + 'docs/' + (language ? language + '/' : '') + doc; +} + +class Help extends React.Component { + render() { + let language = this.props.language || ''; + const supportLinks = [ + { + content: `Learn more using the [documentation on this site.](${docUrl( + 'doc1.html', + language + )})`, + title: 'Browse Docs', + }, + { + content: 'Ask questions about the documentation and project', + title: 'Join the community', + }, + { + content: "Find out what's new with this project", + title: 'Stay up to date', + }, + ]; + + return ( +
+ +
+
+

Need help?

+
+

This project is maintained by a dedicated group of people.

+ +
+
+
+ ); + } +} + +module.exports = Help; diff --git a/website/pages/en/index.js b/website/pages/en/index.js new file mode 100755 index 0000000..d6db81e --- /dev/null +++ b/website/pages/en/index.js @@ -0,0 +1,219 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +const React = require('react'); + +const CompLibrary = require('../../core/CompLibrary.js'); +const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */ +const Container = CompLibrary.Container; +const GridBlock = CompLibrary.GridBlock; + +const siteConfig = require(process.cwd() + '/siteConfig.js'); + +function imgUrl(img) { + return siteConfig.baseUrl + 'img/' + img; +} + +function docUrl(doc, language) { + return siteConfig.baseUrl + 'docs/' + (language ? language + '/' : '') + doc; +} + +function pageUrl(page, language) { + return siteConfig.baseUrl + (language ? language + '/' : '') + page; +} + +class Button extends React.Component { + render() { + return ( + + ); + } +} + +Button.defaultProps = { + target: '_self', +}; + +const SplashContainer = props => ( +
+
+
{props.children}
+
+
+); + +const Logo = props => ( +
+ +
+); + +const ProjectTitle = props => ( +

+ {siteConfig.title} + {siteConfig.tagline} +

+); + +const PromoSection = props => ( +
+
+
{props.children}
+
+
+); + +class HomeSplash extends React.Component { + render() { + let language = this.props.language || ''; + return ( + + +
+ + + + + + +
+
+ ); + } +} + +const Block = props => ( + + + +); + +const Features = props => ( + + {[ + { + content: 'This is the content of my feature', + image: imgUrl('docusaurus.svg'), + imageAlign: 'top', + title: 'Feature One', + }, + { + content: 'The content of my second feature', + image: imgUrl('docusaurus.svg'), + imageAlign: 'top', + title: 'Feature Two', + }, + ]} + +); + +const FeatureCallout = props => ( +
+

Feature Callout

+ These are features of this project +
+); + +const LearnHow = props => ( + + {[ + { + content: 'Talk about learning how to use this', + image: imgUrl('docusaurus.svg'), + imageAlign: 'right', + title: 'Learn How', + }, + ]} + +); + +const TryOut = props => ( + + {[ + { + content: 'Talk about trying this out', + image: imgUrl('docusaurus.svg'), + imageAlign: 'left', + title: 'Try it Out', + }, + ]} + +); + +const Description = props => ( + + {[ + { + content: 'This is another description of how this project is useful', + image: imgUrl('docusaurus.svg'), + imageAlign: 'right', + title: 'Description', + }, + ]} + +); + +const Showcase = props => { + if ((siteConfig.users || []).length === 0) { + return null; + } + const showcase = siteConfig.users + .filter(user => { + return user.pinned; + }) + .map((user, i) => { + return ( + + {user.caption} + + ); + }); + + return ( +
+

{"Who's Using This?"}

+

This project is used by all these people

+
{showcase}
+ +
+ ); +}; + +class Index extends React.Component { + render() { + let language = this.props.language || ''; + + return ( +
+ +
+ + + + + + +
+
+ ); + } +} + +module.exports = Index; diff --git a/website/pages/en/users.js b/website/pages/en/users.js new file mode 100644 index 0000000..c113bf5 --- /dev/null +++ b/website/pages/en/users.js @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +const React = require('react'); + +const CompLibrary = require('../../core/CompLibrary.js'); +const Container = CompLibrary.Container; + +const siteConfig = require(process.cwd() + '/siteConfig.js'); + +class Users extends React.Component { + render() { + if ((siteConfig.users || []).length === 0) { + return null; + } + const editUrl = siteConfig.repoUrl + '/edit/master/website/siteConfig.js'; + const showcase = siteConfig.users.map((user, i) => { + return ( + + {user.caption} + + ); + }); + + return ( +
+ +
+
+

Who's Using This?

+

This project is used by many folks

+
+
{showcase}
+

Are you using this project?

+ + Add your company + +
+
+
+ ); + } +} + +module.exports = Users; diff --git a/website/sidebars.json b/website/sidebars.json new file mode 100644 index 0000000..7a1d054 --- /dev/null +++ b/website/sidebars.json @@ -0,0 +1,10 @@ +{ + "docs": { + "Docusaurus": ["doc1"], + "First Category": ["doc2"], + "Second Category": ["doc3"] + }, + "docs-other": { + "First Category": ["doc4", "doc5"] + } +} diff --git a/website/siteConfig.js b/website/siteConfig.js new file mode 100644 index 0000000..b73026b --- /dev/null +++ b/website/siteConfig.js @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +// See https://docusaurus.io/docs/site-config.html for all the possible +// site configuration options. + +/* List of projects/orgs using your project for the users page */ +const users = [ + { + caption: 'User1', + // You will need to prepend the image path with your baseUrl + // if it is not '/', like: '/test-site/img/docusaurus.svg'. + image: '/img/docusaurus.svg', + infoLink: 'https://www.facebook.com', + pinned: true, + }, +]; + +const siteConfig = { + title: 'Test Site' /* title for your website */, + tagline: 'A website for testing', + url: 'https://your-docusaurus-test-site.com' /* your website url */, + baseUrl: '/' /* base url for your project */, + // For github.io type URLs, you would set the url and baseUrl like: + // url: 'https://facebook.github.io', + // baseUrl: '/test-site/', + + // Used for publishing and more + projectName: 'test-site', + organizationName: 'facebook', + // For top-level user or org sites, the organization is still the same. + // e.g., for the https://JoelMarcey.github.io site, it would be set like... + // organizationName: 'JoelMarcey' + + // For no header links in the top nav bar -> headerLinks: [], + headerLinks: [ + {doc: 'doc1', label: 'Docs'}, + {doc: 'doc4', label: 'API'}, + {page: 'help', label: 'Help'}, + {blog: true, label: 'Blog'}, + ], + + // If you have users set above, you add it here: + users, + + /* path to images for header/footer */ + headerIcon: 'img/docusaurus.svg', + footerIcon: 'img/docusaurus.svg', + favicon: 'img/favicon.png', + + /* colors for website */ + colors: { + primaryColor: '#2E8555', + secondaryColor: '#205C3B', + }, + + /* custom fonts for website */ + /*fonts: { + myFont: [ + "Times New Roman", + "Serif" + ], + myOtherFont: [ + "-apple-system", + "system-ui" + ] + },*/ + + // This copyright info is used in /core/Footer.js and blog rss/atom feeds. + copyright: + 'Copyright © ' + + new Date().getFullYear() + + ' Your Name or Your Company Name', + + highlight: { + // Highlight.js theme to use for syntax highlighting in code blocks + theme: 'default', + }, + + // Add custom scripts here that would be placed in