Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var isTitanium = typeof Titanium !== 'undefined';
var _, generatePlatformArray;
if (isTitanium) {
_ = require('alloy/underscore')._;
} else {
var platforms = require('../../platforms/index');
_ = require('../lib/alloy/underscore')._;
// iterate through supported platforms to create specific constants
generatePlatformArray = function(key) {
var ret = [];
_.each(_.keys(platforms), function(p) {
ret.push(platforms[p][key]);
});
return ret;
};
// generate compile time constants based on supported platforms
exports.PLATFORMS = generatePlatformArray('platform');
exports.PLATFORM_FOLDERS_ALLOY = generatePlatformArray('alloyFolder');
var isTitanium = typeof Titanium !== 'undefined';
var _, generatePlatformArray;
if (isTitanium) {
_ = require('alloy/underscore')._;
} else {
var platforms = require('../../platforms/index');
_ = require('../lib/alloy/underscore')._;
// iterate through supported platforms to create specific constants
generatePlatformArray = function(key) {
var ret = [];
_.each(_.keys(platforms), function(p) {
ret.push(platforms[p][key]);
});
return ret;
};
// generate compile time constants based on supported platforms
exports.PLATFORMS = generatePlatformArray('platform');
exports.PLATFORM_FOLDERS_ALLOY = generatePlatformArray('alloyFolder');
/**
* SQL Rest Adapter for Titanium Alloy
* @author Mads Møller
* @version 0.3.4
* Copyright Napp ApS
* www.napp.dk
*/
var _ = require('alloy/underscore')._,
Alloy = require("alloy"),
Backbone = Alloy.Backbone,
moment = require('alloy/moment');
// The database name used when none is specified in the
// model configuration.
var ALLOY_DB_DEFAULT = '_alloy_';
var ALLOY_ID_DEFAULT = 'alloy_id';
var cache = {
config : {},
Model : {},
URL : null
};
// The sql-specific migration object, which is the main parameter
storeModel(data);
resp = model.toJSON();
break;
case "delete":
delete data[model.id];
storeModel(data);
resp = model.toJSON();
}
if (resp) {
_.isFunction(opts.success) && opts.success(resp);
"read" === method && model.trigger("fetch");
} else _.isFunction(opts.error) && opts.error(resp);
}
var _ = require("alloy/underscore")._;
module.exports.sync = Sync;
module.exports.beforeModelCreate = function(config) {
config = config || {};
config.data = {};
InitAdapter();
return config;
};
module.exports.afterModelCreate = function(Model) {
Model = Model || {};
Model.prototype.config.Model = Model;
return Model;
};
/**
* Set the ETag for the given url
* @param {Object} url
* @param {Object} eTag
*/
function setETag(url, eTag) {
if (eTag && url) {
var obj = Ti.App.Properties.getObject("NAPP_REST_ADAPTER", {});
obj[url] = eTag;
Ti.App.Properties.setObject("NAPP_REST_ADAPTER", obj);
}
}
//we need underscore
var _ = require("alloy/underscore")._;
//until this issue is fixed: https://jira.appcelerator.org/browse/TIMOB-11752
var Alloy = require("alloy"), Backbone = Alloy.Backbone;
module.exports.sync = Sync;
module.exports.beforeModelCreate = function(config, name) {
config = config || {};
InitAdapter(config);
return config;
};
module.exports.afterModelCreate = function(Model, name) {
Model = Model || {};
Model.prototype.config.Model = Model;
Model.prototype.idAttribute = Model.prototype.config.adapter.idAttribute;
/**
* Set the ETag for the given url
* @param {Object} url
* @param {Object} eTag
*/
function setETag(url, eTag) {
if (eTag && url) {
var obj = Ti.App.Properties.getObject("NAPP_REST_ADAPTER", {});
obj[url] = eTag;
Ti.App.Properties.setObject("NAPP_REST_ADAPTER", obj);
}
}
//we need underscore
var _ = require("alloy/underscore")._;
//until this issue is fixed: https://jira.appcelerator.org/browse/TIMOB-11752
var Alloy = require("alloy"), Backbone = Alloy.Backbone;
module.exports.sync = Sync;
module.exports.beforeModelCreate = function(config, name) {
config = config || {};
InitAdapter(config);
return config;
};
module.exports.afterModelCreate = function(Model, name) {
Model = Model || {};
Model.prototype.config.Model = Model;
Model.prototype.idAttribute = Model.prototype.config.adapter.idAttribute;
var Alloy = require("alloy"), _ = require("alloy/underscore")._, model, collection;
var Q = require("q");
exports.definition = {
config: {
columns: {
objectId: "text PRIMARY KEY",
User_objectId: "text",
User_object: "text",
mainPhone: "text",
User_objectId_To: "text",
User_object_To: "text",
firstName: "text",
middleName: "text",
lastName: "text",
fullName: "text",
var packageDir = "ti.meteor/packages/";
_ = typeof Alloy != "undefined" ? require("alloy/underscore")._ : require(packageDir + 'underscore');
Meteor = require(packageDir + 'meteor').Meteor;
var Accounts = {},
OS_ANDROID = OS_ANDROID || Ti.Platform.osname == "android",
OS_IOS = OS_IOS || !OS_ANDROID,
Session = require(packageDir + 'reactive-dict').ReactiveDict;
require(packageDir + 'dynamics_browser');
require(packageDir + 'errors');
ServiceConfiguration = {};
ServiceConfiguration.configurations = {
findOne:function(query) {
return ServiceConfiguration.loginServices[query.service];
}
}
ServiceConfiguration.loginServices = {};
model.set(model.idAttribute, model.id);
}
TAP.setObject(prefix + "-" + model.id, model.toJSON() || {});
resp = model.toJSON();
} else if ("delete" === method) {
TAP.removeProperty(prefix + "-" + model.id);
model.clear();
resp = model.toJSON();
}
if (resp) {
_.isFunction(opts.success) && opts.success(resp);
"read" === method && model.trigger("fetch");
} else _.isFunction(opts.error) && opts.error(resp);
}
var Alloy = require("alloy"), _ = require("alloy/underscore")._, TAP = Ti.App.Properties;
module.exports.sync = Sync;
module.exports.beforeModelCreate = function(config) {
config = config || {};
config.columns = config.columns || {};
config.defaults = config.defaults || {};
("undefined" == typeof config.columns.id || null === config.columns.id) && (config.columns.id = "String");
return config;
};
_.each(config.columns, function(type, name) {
colStrings.push(name);
fullStrings.push(name + " " + type);
});
var colsString = colStrings.join(",");
db.execute("ALTER TABLE " + table + " RENAME TO " + table + "_temp;");
db.execute("CREATE TABLE " + table + "(" + fullStrings.join(",") + "," + ALLOY_ID_DEFAULT + " TEXT UNIQUE);");
db.execute("INSERT INTO " + table + "(" + colsString + "," + ALLOY_ID_DEFAULT + ") SELECT " + colsString + ",CAST(_ROWID_ AS TEXT) FROM " + table + "_temp;");
db.execute("DROP TABLE " + table + "_temp;");
config.columns[ALLOY_ID_DEFAULT] = "TEXT UNIQUE";
config.adapter.idAttribute = ALLOY_ID_DEFAULT;
}
db.close();
}
var _ = require("alloy/underscore")._;
var ALLOY_DB_DEFAULT = "_alloy_";
var ALLOY_ID_DEFAULT = "alloy_id";
var cache = {
config: {},
Model: {}
};
module.exports.beforeModelCreate = function(config, name) {
if (cache.config[name]) return cache.config[name];
throw "No support for Titanium.Database in MobileWeb environment.";
};
module.exports.afterModelCreate = function(Model, name) {