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

alaska-settings

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alaska-settings - npm Package Compare versions

Comparing version 0.10.1 to 0.11.0

views/.babelrc

15

config/alaska-settings.js

@@ -1,14 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* @copyright Maichong Software Ltd. 2016 http://maichong.it
* @date 2016-03-01
* @author Liang <liang@maichong.it>
*/
exports.default = {
export default {
prefix: false
};
};

@@ -1,35 +0,13 @@

'use strict';
// @flow
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.routes = undefined;
import { Service } from 'alaska';
var _co = require('co');
var _alaska = require('alaska');
var _alaska2 = _interopRequireDefault(_alaska);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const debug = require('debug')('alaska-settings');
//为 alaska-admin-view 注入设置编辑器
/**
* @copyright Maichong Software Ltd. 2016 http://maichong.it
* @date 2016-03-01
* @author Liang <liang@maichong.it>
* @class SettingsService
*/
class SettingsService extends Service {
const routes = exports.routes = [{
component: __dirname + '/views/SettingsEditor',
path: 'settings'
}];
/**
* @class SettingsService
*/
class SettingsService extends _alaska2.default.Service {
constructor(options) {
constructor(options?: Alaska$Service$options) {
options = options || {};

@@ -43,22 +21,19 @@ options.dir = options.dir || __dirname;

* 注册新设置选项
* @param {Object} data
* @param data
* @returns {Settings}
*/
register(data) {
var _this = this;
async register(data: Object) {
const Settings = this.model('Settings');
return (0, _co.wrap)(function* () {
const Settings = _this.model('Settings');
const id = data.id || data._id;
let settings = yield Settings.findCache(id);
if (settings) {
return settings;
}
settings = new Settings(data);
settings._id = id;
debug('register', id);
yield settings.save();
const id = data.id || data._id;
// $Flow
let settings: Settings = await Settings.findById(id);
if (settings) {
return settings;
})();
}
settings = new Settings(data);
settings._id = id;
debug('register', id);
await settings.save();
return settings;
}

@@ -71,12 +46,9 @@

*/
get(id) {
var _this2 = this;
return (0, _co.wrap)(function* () {
const Settings = _this2.model('Settings');
let record = yield Settings.findCache(id);
let value = record ? record.value : undefined;
debug('get', id, '=>', value);
return value;
})();
async get(id: string|number) {
const Settings = this.model('Settings');
// $Flow
let record = await Settings.findById(id);
let value = record ? record.value : undefined;
debug('get', id, '=>', value);
return value;
}

@@ -90,19 +62,16 @@

*/
set(id, value) {
var _this3 = this;
return (0, _co.wrap)(function* () {
debug('set', id, '=>', value);
const Settings = _this3.model('Settings');
let record = yield Settings.findCache(id);
if (!record) {
return null;
}
record.value = value;
yield record.save();
return record;
})();
async set(id: string|number, value: any) {
debug('set', id, '=>', value);
const Settings = this.model('Settings');
// $Flow
let record = await Settings.findById(id);
if (!record) {
return null;
}
record.value = value;
await record.save();
return record;
}
}
exports.default = new SettingsService();
export default new SettingsService();

@@ -1,13 +0,2 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* @copyright Maichong Software Ltd. 2016 http://maichong.it
* @date 2016-04-03
* @author Liang <liang@maichong.it>
*/
exports.default = {
export default{
Settings: 'Settings',

@@ -19,2 +8,2 @@ Group: 'Group',

'Basic Settings': 'Basic Settings'
};
};

@@ -1,13 +0,2 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* @copyright Maichong Software Ltd. 2016 http://maichong.it
* @date 2016-04-03
* @author Liang <liang@maichong.it>
*/
exports.default = {
export default{
Settings: '设置',

@@ -19,2 +8,2 @@ Group: '组',

'Basic Settings': '基础设置'
};
};

@@ -1,97 +0,96 @@

'use strict';
// @flow
Object.defineProperty(exports, "__esModule", {
value: true
});
import { Model } from 'alaska';
var _alaska = require('alaska');
export default class Settings extends Model {
static label = 'Settings';
static icon = 'cogs';
static defaultSort = 'group service';
static defaultColumns = '_id title group service';
static cache = 600; //缓存10分钟
var _alaska2 = _interopRequireDefault(_alaska);
static defaultFilters = (ctx) => {
if (!ctx.state.superMode) {
return { super: { $ne: true } };
}
return {};
};
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class Settings extends _alaska2.default.Model {}
exports.default = Settings; /**
* @copyright Maichong Software Ltd. 2016 http://maichong.it
* @date 2016-04-03
* @author Liang <liang@maichong.it>
*/
Settings.label = 'Settings';
Settings.icon = 'cogs';
Settings.defaultSort = 'group service';
Settings.defaultColumns = '_id title group service';
Settings.cache = 600;
Settings.defaultFilters = ctx => {
if (!ctx.state.superMode) {
return { super: { $ne: true } };
}
};
Settings.fields = {
_id: String,
title: {
label: 'Title',
type: String
},
service: {
label: 'Service',
type: String
},
group: {
label: 'Group',
type: String
},
value: {
label: 'Value',
type: Object,
default: null
},
help: {
label: 'Help',
type: String
},
type: {
label: 'Type',
type: 'select',
default: 'MixedFieldView',
options: [{
label: 'Text',
value: 'TextFieldView'
}, {
label: 'Number',
value: 'NumberFieldView'
}, {
label: 'Checkbox',
value: 'CheckboxFieldView'
}, {
label: 'Select',
value: 'SelectFieldView'
}, {
label: 'Date',
value: 'DateFieldView'
}, {
label: 'Datetime',
value: 'DatetimeFieldView'
}, {
label: 'Mixed',
value: 'MixedFieldView'
}, {
label: 'Html',
value: 'HtmlFieldView'
}, {
label: 'Image',
value: 'ImageFieldView'
}]
},
super: {
label: 'Super',
type: Boolean
},
options: {
label: 'Options',
type: Object,
default: {}
}
};
static fields = {
_id: {
type: String
},
title: {
label: 'Title',
type: String
},
service: {
label: 'Service',
type: String
},
group: {
label: 'Group',
type: String
},
value: {
label: 'Value',
type: Object,
default: null
},
help: {
label: 'Help',
type: String
},
type: {
label: 'Type',
type: 'select',
default: 'MixedFieldView',
options: [{
label: 'Text',
value: 'TextFieldView'
}, {
label: 'Number',
value: 'NumberFieldView'
}, {
label: 'Checkbox',
value: 'CheckboxFieldView'
}, {
label: 'Select',
value: 'SelectFieldView'
}, {
label: 'Date',
value: 'DateFieldView'
}, {
label: 'Datetime',
value: 'DatetimeFieldView'
}, {
label: 'Mixed',
value: 'MixedFieldView'
}, {
label: 'Html',
value: 'HtmlFieldView'
}, {
label: 'Image',
value: 'ImageFieldView'
}]
},
super: {
label: 'Super',
type: Boolean
},
options: {
label: 'Options',
type: Object,
default: {}
}
};
_id: string|number|Object|any;
title: string;
service: string;
group: string;
value: Object;
help: string;
type: string;
super: boolean;
options: Object;
}
{
"name": "alaska-settings",
"version": "0.10.1",
"version": "0.11.0",
"description": "Alaska settings service",

@@ -10,31 +10,11 @@ "keywords": [

"main": "index.js",
"scripts": {
"build": "babel ./src --out-dir ./",
"watch": "babel ./src --out-dir ./ -w",
"prebuild": "rimraf lib api controllers config locales middlewares models sleds views",
"prepublish": "npm run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/maichong/alaska-settings.git"
},
"author": {
"email": "liang@maichong.it",
"name": "liang",
"url": "https://github.com/liangxingchen"
},
"repository": "https://github.com/maichong/alaska/tree/master/packages/alaska-settings",
"author": "Liang <liang@maichong.it> (https://github.com/liangxingchen)",
"license": "MIT",
"bugs": {
"url": "https://github.com/maichong/alaska-settings/issues"
},
"homepage": "https://github.com/maichong/alaska-settings#readme",
"peerDependencies": {
"alaska": "^0.10.6"
},
"dependencies": {
"alaska-field-mixed": "^0.10.1",
"alaska-field-select": "^0.10.2",
"alaska-field-text": "^0.10.3",
"debug": "^2.2.0"
"alaska-field-mixed": "^0.11.0",
"alaska-field-select": "^0.11.0",
"alaska-field-text": "^0.11.0",
"debug": "^2.6.3"
}
}
# alaska-settings
Alaska settings service
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc