cipher-solomon

cipher/keychain/aws/s3/storage/database/restoration/table/controls

Usage no npm install needed!

<script type="module">
  import cipherSolomon from 'https://cdn.skypack.dev/cipher-solomon';
</script>

README

Module

import

import { cipher, decipher, random, createDate, calculateAge, hash, hostname, calculateAge, Client, Storage, Database, Backend, restoration, tableControls, SuggestionInput } from 'cipher-solomon';

Keychain

encrypt

cipher(...)

decrypt

decipher(...)

random

random()

createDate

createDate(0, 0, 0)

calculateAge

calculateAge(dateString)

hash

hash(...)

hostname

hostname()

S3 Adapter

init

const options = {
  region: process.env.VUE_APP_DEFAULT_S3_REGION,
  bucket: process.env.VUE_APP_DEFAULT_S3_BUCKET,
  accessKeyId: process.env.VUE_APP_DEFAULT_S3_ACCESSKEYID,
  secretAccessKey: process.env.VUE_APP_DEFAULT_S3_SECRETACCESSKEY
};
const client = new Client(options);
Vue.prototype.$client = client;

list

this.$client.listObjects(Prefix)
          .then((data) => {
            ...
          })
          .catch((error) => {
            ...
          });

put

this.$client.putObject(object, Key)
          .then((data) => {
            ...
          })
          .catch((error) => {
            ...
          });

delete

this.$client.deleteObject(Key)
          .then((data) => {
            ...
          })
          .catch((error) => {
            ...
          });

Storage

init

const storage = new Storage({
  APP_BASE_URL: process.env.VUE_APP_DEFAULT_LEAN_BASEURL,
  APP_LEAN_APPID: process.env.VUE_APP_DEFAULT_LEAN_APPID,
  APP_LEAN_APPKEY: process.env.VUE_APP_DEFAULT_LEAN_APPKEY
});
Vue.prototype.$database = storage;

Database (Backend)

init (Database)

const database = new Database({
  APP_BASE_URL: process.env.VUE_APP_DEFAULT_PARSE_BASEURL,
  APP_PARSE_APPID: process.env.VUE_APP_DEFAULT_PARSE_APPID
});
Vue.prototype.$database = database;

init (Backend)

const backend = new Backend({
  APP_BASE_URL: process.env.VUE_APP_DEFAULT_PARSE_BASEURL,
  APP_PARSE_APPID: process.env.VUE_APP_DEFAULT_PARSE_APPID,
  APP_PARSE_JAVASCRIPTKEY: process.env.VUE_APP_DEFAULT_PARSE_JAVASCRIPTKEY,
  APP_PARSE_APIKEY: process.env.VUE_APP_DEFAULT_PARSE_APIKEY
});
Vue.prototype.$database = backend;

create

this.$database
.create(resource, body)
.then(response => {

})
.catch(error => {

})

retrieve

this.$database
.retrieve(resource, params)
.then(response => {

})
.catch(error => {

})

retrieveById

this.$database
.retrieveById(resource, objectId, params)
.then(response => {

})
.catch(error => {

})

updateById

this.$database
.updateById(resource, objectId, body)
.then(response => {

})
.catch(error => {

})

deleteById

this.$database
.deleteById(resource, objectId, body)
.then(response => {

})
.catch(error => {

})

aggregate

this.$database
.aggregate(resource, params)
.then(response => {

})
.catch(error => {

})

batch

this.$database
.batch(body)
.then(response => {

})
.catch(error => {

})

user

this.$database.user()

new user

this.$database.newUser(...)

session

this.$database.session()

role

this.$database.role()

query

this.$databse.query()

Restoration

apply

export default {
    ...
    mixins: [restoration],
    ...
}

save

this.saveRestorationState(data);

load

const data = this.loadRestorationState();

example

export default {
    ...
    watch: {
      data: {
        handler: function (newValue, oldValue) {
          this.saveRestorationState(newValue);
          const object = this.transformation(newValue);
          this.$emit("update", object);
        },
        deep: true,
        immediate: true,
      },
    },
    methods: {
      transformation(data) {
        return ...
      },
      reset() {
        const data = this.loadRestorationState();
        const _data = this.transformation(data);
        this.$emit("update", _data);
        this.data = data;
      },
    },
    ...
}

Table Controls

data

data() {
    return {
      ...
      tableConfig: tableConfig,
      ...
    };
},

mixins

mixins: [..., tableControls, ...],

computed

computed: {
    include() {
      return "...,...";
    },
    exclude() {
      return [...];
    },
    resource() {
      return ...;
    },
    where() {
      return ...;
    },
    formName() {
      return ...;
    },
    sessionToken() {
      return ...;
    },
    masterKey() {
      return ...;
    }
},

example

import tableConfig from "./tableConfig";
import { _invoiceWhere } from "@/utils/defaultWheres";
import { tableControls } from 'cipher-table-controls-mixins';

const _resource = process.env.VUE_APP_DEFAULT_INVOICE;
export default {
  name: "InvoiceTable",
  components: {},
  data() {
    return {
      tableConfig: tableConfig,
    };
  },
  mixins: [tableControls],
  computed: {
    include() {
      return "from,to";
    },
    exclude() {
      return ["items"];
    },
    resource() {
      return _resource;
    },
    where() {
      if (this.keywords.length === 0) {
        return undefined;
      }
      return _invoiceWhere(this.keywords);
    },
    formName() {
      return "Invoice Form";
    },
  },
  mounted() {},
  created() {},
  destroyed() {},
  methods: {},
};

SuggestionInput

components

components: {
    SuggestionInput,
},

data

data() {
    return {
      ...
      suggestions: [],
      ...
    };
},

template

<suggestion-input
          :suggestions="suggestions"
          :value="item.description"
          placeholder="Enter description"
          @update="updateSelected"
        />