Skip to content

Instantly share code, notes, and snippets.

@dmdeklerk
Created May 6, 2017 22:23
Show Gist options
  • Save dmdeklerk/d47a2d074170f447e6be3152310cb053 to your computer and use it in GitHub Desktop.
Save dmdeklerk/d47a2d074170f447e6be3152310cb053 to your computer and use it in GitHub Desktop.
Sample index.js.map for README
{
"version": 3,
"sources": [
"lib/console.ts",
"lib/global.ts",
"lib/microservice.ts",
"lib/subscriber.ts",
"lib/util.ts",
"microservice/sample/service.ts",
"microservice/sample/test.ts"
],
"names": [],
"mappings": "AAsBA;IAAA;IAIA,CAAC;IAHQ,qBAAG,GAAV,UAAW,OAAe;QACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IACH,cAAC;AAAD,CAJA,AAIC,IAAA;;ACJD,IAAI,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAG5B,IAAI,IAAI,GAAwB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACxD,IAAI,SAAS,GAA4B,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;AACrE,IAAI,UAAU,GAA6B,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;AACxE,IAAI,OAAO,GAAqC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC;AACrF,IAAI,OAAO,GAAsC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC;AACvF,IAAI,OAAO,GAAgC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC;;ACS3E,IAAO,YAAY,CAsDlB;AAtDD,WAAO,YAAY;IAGjB,sBAA6B,IAAY;QACvC,MAAM,CAAC,UAAU,MAAM;YACrB,YAAY,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE;gBACtC,WAAW,IAAI;oBACb,MAAM,CAAC,MAAM,CAAC,KAAK,CA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AAY;IAAC,IAAA,MAAM,CAQzB;IARmB,WAAA,MAAM;QAExB,IAAM,aAAa;YAAS,iCAAoB;YAC9C,uBAAoB,MAAW;gBAA/B,YACE,iBAAO,SAER;gBAHmB,YAAM,GAAN,MAAM,CAAK;gBAE7B,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;;YAClD,CAAC;YACH,oBAAC;QAAD,CALA,AAKC,CAL2B,aAAA,oBAAoB,GAK/C;QALK,aAAa;YADlB,aAAA,YAAY,CAAC,gBAAgB,CAAC;WACzB,aAAa,CAKlB;IACH,CAAC,EARmB,MAAM,GAAN,mBAAM,KAAN,mBAAM,QAQzB;AAAD,CAAC,EARM,YAAY,KAAZ,YAAY,QAQlB;;ACRD,IAAO,YAAY,CAKlB;AALD,WAAO,YAAY;IAAC,IAAA,MAAM,CAKzB;IALmB,WAAA,MAAM;QACxB;YACE,YAAY,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;YACxD,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,CAAC;QAHe,WAAI,OAGnB,CAAA;IACH,CAAC,EALmB,MAAM,GAAN,mBAAM,KAAN,mBAAM,QAKzB;AAAD,CAAC,EALM,YAAY,KAAZ,YAAY,QAKlB",
"file": "index.js",
"sourcesContent": [
"/*\n * The MIT License (MIT)\n * Copyright (c) 2017 Heat Ledger Ltd.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n * the Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * */\nclass Console {\n public log(message: string) {\n heat.logger.info(message); \n }\n}",
"/*\n * The MIT License (MIT)\n * Copyright (c) 2017 Heat Ledger Ltd.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n * the Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * */\nvar console = new Console();\n\n/* Java Class constants that expose static methods */\nvar Long: Java.java.lang.Long = Packages.java.lang.Long;\nvar ByteOrder: Java.java.nio.ByteOrder = Packages.java.nio.ByteOrder;\nvar ByteBuffer: Java.java.nio.ByteBuffer = Packages.java.nio.ByteBuffer;\nvar Convert: Java.com.heatledger.util.Convert = Packages.com.heatledger.util.Convert;\nvar Crypto2: Java.com.heatledger.crypto.Crypto = Packages.com.heatledger.crypto.Crypto;\nvar Account: Java.com.heatledger.Account = Packages.com.heatledger.Account;",
"/*\n * The MIT License (MIT)\n * Copyright (c) 2017 Heat Ledger Ltd.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n * the Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * */\ndeclare namespace microservice {\n interface Config {\n account: string;\n settings: lang.IStringHashMap<any>;\n methods: lang.IStringHashMap<Method>;\n }\n interface Method {\n fee?: string;\n param?: lang.IStringHashMap<any>;\n }\n interface Call {\n service: string;\n method: string;\n param: lang.IStringHashMap<string>;\n }\n}\n\nmodule microservice {\n\n /* MicroService annotation */\n export function MicroService(name: string) {\n return function (target) {\n microservice.manager().addService(name, function () {\n function F(args): void {\n return target.apply(this, args);\n }\n F.prototype = target.prototype;\n return new F(arguments);\n });\n }\n } \n\n /* Base class for all MicroService annotated classes */\n export abstract class AbstractMicroService {\n public destroy() {}\n } \n\n /* Access the _manager */\n export function manager(): ServiceManager {\n return this['_manager'] || (this['_manager'] = new ServiceManager());\n }\n\n class Service {\n constructor(public name: string, public factory: Function) { }\n }\n\n class ServiceManager {\n private services: lang.IStringHashMap<Service> = {};\n private running: Array<any> = [];\n\n /* Add a service, called from MicroService annotation */\n public addService(name: string, factory: Function) {\n this.services[name] = new Service(name, factory);\n }\n\n /* Tests if a service is registered, called from java */\n public hasService(name: string): boolean {\n return !!this.services[name];\n } \n\n /* Create and run a service instance, called from java */\n public runService(name: string, config: lang.IStringHashMap<any>): number {\n var service = this.services[name];\n if (!service) {\n return 1;\n }\n this.running.push(service.factory.call(null, config));\n return 0;\n }\n }\n\n}",
"/*\n * The MIT License (MIT)\n * Copyright (c) 2017 Heat Ledger Ltd.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n * the Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * */\nmodule subscriber {\n export var COMPLETE = \"COMPLETE\";\n export var TRUE = \"TRUE\"\n export var FALSE = \"FALSE\";\n\n export function create(serviceId: string) {\n return new Subscriber(serviceId);\n }\n\n class Subscriber {\n constructor(private serviceId: string) { }\n\n public payment() {\n return new PaymentSubscriberBuilder(this.serviceId);\n }\n\n public assetTransfer() {\n return new AssetTransferSubscriberBuilder(this.serviceId);\n }\n }\n\n\n abstract class TransactionSubscriberBuilder {\n private serviceId: string;\n private _account: number = 0;\n private _sender: number = 0;\n private _recipient: number = 0;\n private _onAdd: Java.java.util._function.Consumer<Java.com.heatledger.scripting.NativeTransactionEvent> = null;\n private _onRemove: Java.java.util._function.Consumer<Java.com.heatledger.scripting.NativeTransactionEvent> = null;\n private _onConfirmed: Java.java.util._function.Consumer<Java.com.heatledger.scripting.NativeTransactionEvent> = null;\n private _unconfirmed: boolean = false;\n private _confirmations: number = 0;\n private _type: number;\n private _subtype: number;\n\n constructor(serviceId: string) {\n this.serviceId = serviceId;\n }\n\n public account(account: number) {\n this._account = account;\n return this;\n }\n\n public sender(sender: number) {\n this._sender = sender;\n return this;\n }\n\n public recipient(recipient: number) {\n this._recipient = recipient;\n return this;\n }\n\n public onAdd(onAdd: (event: Java.com.heatledger.scripting.NativeTransactionEvent) => void) {\n this._onAdd = onAdd;\n return this;\n }\n\n public onRemove(onRemove: (event: Java.com.heatledger.scripting.NativeTransactionEvent) => void) {\n this._onRemove = onRemove;\n return this;\n }\n\n public onConfirmed(onConfirmed: (event: Java.com.heatledger.scripting.NativeTransactionEvent) => void) {\n this._onConfirmed = onConfirmed;\n return this;\n }\n\n public unconfirmed(unconfirmed: boolean) {\n this._unconfirmed = unconfirmed;\n return this;\n }\n\n public confirmations(confirmations: number) {\n this._confirmations = confirmations;\n return this;\n }\n\n protected type(type: number) {\n this._type = type;\n return this;\n }\n\n protected subtype(subtype: number) {\n this._subtype = subtype;\n return this;\n }\n\n public subscribe() {\n var unsubscribe: Array<Java.java.lang.Runnable> = [];\n if (util.isDefined(this._onConfirmed)) {\n unsubscribe.push(this.subscribeConfirmed());\n }\n if (util.isDefined(this._onAdd) || util.isDefined(this._onRemove)) {\n unsubscribe.push(heat.events.subscribeTransaction(this._type, this._subtype, this._account, this._sender, this._recipient, this._unconfirmed, this._onAdd, this._onRemove));\n }\n return () => unsubscribe.forEach((fn) => { fn() });\n }\n\n private subscribeConfirmed(): Java.java.lang.Runnable {\n var unsubscribe: Array<Java.java.lang.Runnable> = [];\n var add = (event: Java.com.heatledger.scripting.NativeTransactionEvent) => {\n\n /* Always call addTransaction, if already added this operation does nothing */\n heat.transactionStore.addTransaction(this.serviceId, event.transaction);\n\n /* Determine if this invocation was completed already, if so exit */\n if (this.get(event.transaction.id, COMPLETE) == TRUE) {\n return;\n }\n\n var onConfirmed = (event: Java.com.heatledger.scripting.NativeTransactionEvent) => {\n\n /* Determine if this invocation was completed already, if so exit */\n if (this.get(event.transaction.id, COMPLETE) == TRUE) {\n return;\n }\n\n /* Call the onConfirmed handler */\n this._onConfirmed(event);\n };\n\n /* Register a listener for when the number of confirmations is reached */\n heat.transactionStore.registerConfirmedListener(event.transaction.id, this._confirmations, onConfirmed);\n unsubscribe.push(() => {\n heat.transactionStore.unRegisterConfirmedListener(event.transaction.id, this._confirmations, onConfirmed);\n });\n };\n unsubscribe.push(heat.events.subscribeTransaction(this._type, this._subtype, this._account, this._sender, this._recipient, this._unconfirmed, add, null));\n return () => unsubscribe.forEach((fn) => { fn() });\n }\n\n public get(transactionId: number, key: string): string {\n return heat.transactionStore.getEntryValue(this.serviceId, transactionId, key);\n }\n\n public put(transactionId: number, key: string, value: string) {\n return heat.transactionStore.setEntryValue(this.serviceId, transactionId, key, value);\n }\n }\n\n class PaymentSubscriberBuilder extends TransactionSubscriberBuilder {\n constructor(id) {\n super(id)\n }\n public subscribe() {\n this.type(0);\n this.subtype(0);\n return super.subscribe();\n }\n }\n\n class AssetTransferSubscriberBuilder extends TransactionSubscriberBuilder {\n constructor(id) {\n super(id)\n }\n public subscribe() {\n this.type(2);\n this.subtype(2);\n return super.subscribe();\n }\n }\n\n}",
"/*\n * The MIT License (MIT)\n * Copyright (c) 2017 Heat Ledger Ltd.\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of\n * this software and associated documentation files (the \"Software\"), to deal in\n * the Software without restriction, including without limitation the rights to\n * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n * the Software, and to permit persons to whom the Software is furnished to do so,\n * subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * */\nmodule util {\n export function isDefined(value) {return typeof value !== 'undefined';}\n\n export function decryptEncryptedMessage(transaction: Java.com.heatledger.Transaction, secretPhrase: string): string {\n var encryptedData = transaction.encryptedMessage.encryptedData;\n var privateKey = Crypto2.getPrivateKey(secretPhrase);\n var bytes = encryptedData.decrypt(privateKey, transaction.senderPublicKey);\n return Convert.toString(bytes);\n }\n}",
"module microservice.sample {\n @MicroService('sample.service')\n class SampleService extends AbstractMicroService {\n constructor(private config: any) {\n super();\n console.log(\"Sample microservice says: Hello!\");\n }\n }\n}",
"module microservice.sample {\n export function test() {\n microservice.manager().runService('sample.service', {});\n heat.exit();\n }\n}"
],
"sourceRoot": "/source/"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment