@journeyapps/cloudcode
Advanced tools
Comparing version 0.0.0-dev.e1b1b23 to 0.0.0-dev.e1d19c3
@@ -30,3 +30,3 @@ 'use strict'; | ||
assert(instance, 'instance is required'); | ||
DatabaseAuth_1.validateAuth(auth); | ||
(0, DatabaseAuth_1.validateAuth)(auth); | ||
let url = `${baseUrl}/api/v4/${instance}`; | ||
@@ -40,3 +40,3 @@ // Returning type T is kind of equivalent to returning "any" - it will take the form of whatever the type of the | ||
// Typical error: Type 'Database & GenericDatabaseCollections' is missing the following properties from type 'DB': user, push_notification | ||
return db_1.OnlineDB({ | ||
return (0, db_1.OnlineDB)({ | ||
baseUrl: url, | ||
@@ -52,3 +52,3 @@ dataModelPath: './app/schema.xml', | ||
assert(instance, 'instance is required'); | ||
DatabaseAuth_1.validateAuth(auth); | ||
(0, DatabaseAuth_1.validateAuth)(auth); | ||
let url = `${baseUrl}/api/v4/${instance}`; | ||
@@ -55,0 +55,0 @@ const credentials = new db_1.ApiCredentials({ baseUrl: url, ...auth }); |
@@ -6,3 +6,3 @@ "use strict"; | ||
const source_map_support_1 = require("source-map-support"); | ||
source_map_support_1.install({ | ||
(0, source_map_support_1.install)({ | ||
hookRequire: true, | ||
@@ -34,3 +34,3 @@ handleUncaughtExceptions: false | ||
} | ||
const { system: systemConsole } = logs_1.createLoggers({ | ||
const { system: systemConsole } = (0, logs_1.createLoggers)({ | ||
console: console, | ||
@@ -40,3 +40,3 @@ globalObject: global, | ||
}); | ||
environment_1.setup(exports.config.appId, exports.config.env, exports.config.task); | ||
(0, environment_1.setup)(exports.config.appId, exports.config.env, exports.config.task); | ||
systemConsole.event({ | ||
@@ -68,3 +68,3 @@ event: 'START_PROCESS', | ||
function flushAndExit() { | ||
logs_1.flush(); | ||
(0, logs_1.flush)(); | ||
// Exit process after the logs have been flushed. | ||
@@ -71,0 +71,0 @@ // HACK: It would be better to have some callback on the logs. |
@@ -51,3 +51,3 @@ "use strict"; | ||
createDB(baseUrl, instanceId, auth) { | ||
if (!DatabaseAuth_1.isBasicAuth(auth) && !DatabaseAuth_1.isTokenAuth(auth)) { | ||
if (!(0, DatabaseAuth_1.isBasicAuth)(auth) && !(0, DatabaseAuth_1.isTokenAuth)(auth)) { | ||
if (!this.currentTaskContext || !this.currentTaskContext.token) { | ||
@@ -58,3 +58,3 @@ throw new Error('No authentication specified and no current task session available'); | ||
} | ||
return api_db_1.createDB(baseUrl, instanceId, auth); | ||
return (0, api_db_1.createDB)(baseUrl, instanceId, auth); | ||
} | ||
@@ -71,3 +71,3 @@ /** | ||
createRemoteDB(baseUrl, instanceId, auth) { | ||
if (!DatabaseAuth_1.isBasicAuth(auth) && !DatabaseAuth_1.isTokenAuth(auth)) { | ||
if (!(0, DatabaseAuth_1.isBasicAuth)(auth) && !(0, DatabaseAuth_1.isTokenAuth)(auth)) { | ||
if (!this.currentTaskContext || !this.currentTaskContext.token) { | ||
@@ -78,3 +78,3 @@ throw new Error('No authentication specified and no current task session available'); | ||
} | ||
return api_db_1.createRemoteDB(baseUrl, instanceId, auth); | ||
return (0, api_db_1.createRemoteDB)(baseUrl, instanceId, auth); | ||
} | ||
@@ -131,3 +131,3 @@ /** | ||
logs_1.systemConsole.debug('Enqueue request:', payload); | ||
const response = await node_fetch_1.default(`${SCHEDULER_ENDPOINT}/api/tasks/enqueue`, { | ||
const response = await (0, node_fetch_1.default)(`${SCHEDULER_ENDPOINT}/api/tasks/enqueue`, { | ||
headers: { | ||
@@ -134,0 +134,0 @@ Authorization: `Token ${this.currentTaskContext.token}`, |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { Headers } from 'node-fetch'; | ||
@@ -3,0 +4,0 @@ import { URL, URLSearchParams } from 'url'; |
@@ -74,3 +74,3 @@ 'use strict'; | ||
// Some of the details are only populated later. | ||
const taskContext = environment_1.createTaskContext(context, rawRequest.eventSource, traceId, bootstrap_1.config.backendUrl); | ||
const taskContext = (0, environment_1.createTaskContext)(context, rawRequest.eventSource, traceId, bootstrap_1.config.backendUrl); | ||
// Log in process logs | ||
@@ -85,3 +85,3 @@ logs_1.systemConsole.event({ | ||
// Start task logs | ||
logs_1.setLogContext(taskContext); | ||
(0, logs_1.setLogContext)(taskContext); | ||
logs_1.systemConsole.event({ | ||
@@ -239,3 +239,3 @@ event: 'START_REQUEST', | ||
}); | ||
busycheck_1.busycheck(); | ||
(0, busycheck_1.busycheck)(); | ||
response.header('X-CloudCode-TraceId', traceId); | ||
@@ -246,3 +246,3 @@ if (debug) { | ||
let result = response.toJSON(); | ||
logs_1.flush(); | ||
(0, logs_1.flush)(); | ||
return result; | ||
@@ -279,7 +279,7 @@ }); | ||
.then(function (result) { | ||
environment_1.stopCurrentMonitor(); | ||
(0, environment_1.stopCurrentMonitor)(); | ||
callback(null, result); | ||
}) | ||
.catch(function (error) { | ||
environment_1.stopCurrentMonitor(); | ||
(0, environment_1.stopCurrentMonitor)(); | ||
logs_1.systemConsole.error('Fatal error:', error); | ||
@@ -299,3 +299,3 @@ callback(error, null); | ||
.then(function (result) { | ||
environment_1.stopCurrentMonitor(); | ||
(0, environment_1.stopCurrentMonitor)(); | ||
if (json) { | ||
@@ -309,3 +309,3 @@ term.log(JSON.stringify(result)); | ||
.catch(function (error) { | ||
environment_1.stopCurrentMonitor(); | ||
(0, environment_1.stopCurrentMonitor)(); | ||
if (json) { | ||
@@ -330,3 +330,3 @@ term.log(JSON.stringify({ | ||
// Lambda | ||
bootstrap_1.bootstrap({ dev: false, taskPath: taskPath }); | ||
(0, bootstrap_1.bootstrap)({ dev: false, taskPath: taskPath }); | ||
task = loadTask(); | ||
@@ -338,3 +338,3 @@ }; | ||
} | ||
bootstrap_1.bootstrap({ dev: true, taskPath: taskPath }); | ||
(0, bootstrap_1.bootstrap)({ dev: true, taskPath: taskPath }); | ||
task = loadTask(); | ||
@@ -364,3 +364,3 @@ let events = process.argv.splice(2).map((arg) => JSON.parse(arg)); | ||
} | ||
logs_1.flush(); | ||
(0, logs_1.flush)(); | ||
// Ignore outstanding events and exit (CLI only!). | ||
@@ -367,0 +367,0 @@ // We give some time for flush() to take effect. |
@@ -15,3 +15,2 @@ import { TaskContextBackend } from './TaskContextBackend'; | ||
private startTime; | ||
token: string; | ||
backend: TaskContextBackend; | ||
@@ -29,2 +28,3 @@ monitor: TaskMonitor; | ||
setToken(token: string): void; | ||
get token(): any; | ||
setBackend(opts: { | ||
@@ -31,0 +31,0 @@ baseUrl?: string; |
@@ -14,2 +14,3 @@ 'use strict'; | ||
const _backendUrl = Symbol(); | ||
const _token = Symbol(); | ||
class InternalTaskContext { | ||
@@ -24,3 +25,3 @@ constructor(opts) { | ||
this[_backendUrl] = opts.backendUrl; | ||
this.token = null; | ||
this[_token] = null; | ||
this.backend = new TaskContextBackend_1.TaskContextBackend(this[_backendUrl]); | ||
@@ -36,4 +37,9 @@ this.userContext = new TaskContext_1.TaskContext(this); | ||
setToken(token) { | ||
this.token = token; | ||
this[_token] = token; | ||
} | ||
get token() { | ||
// By having a non-enumerable getter instead of a direct writable property, we avoid broken versions of Rollbar | ||
// attempting to replace the token with '********'. | ||
return this[_token]; | ||
} | ||
setBackend(opts) { | ||
@@ -63,3 +69,3 @@ assert(this.token, 'No token set'); | ||
hydrateObject(obj) { | ||
return api_db_1.hydrateObject(this.backend.DB, obj); | ||
return (0, api_db_1.hydrateObject)(this.backend.DB, obj); | ||
} | ||
@@ -66,0 +72,0 @@ } |
@@ -49,3 +49,3 @@ 'use strict'; | ||
} | ||
let response = await node_fetch_1.default(`${SCHEDULER_ENDPOINT}/api/logs/stream/${traceId}`, { | ||
let response = await (0, node_fetch_1.default)(`${SCHEDULER_ENDPOINT}/api/logs/stream/${traceId}`, { | ||
method: 'POST', | ||
@@ -52,0 +52,0 @@ body: JSON.stringify(logs), |
@@ -14,5 +14,5 @@ "use strict"; | ||
const datePart = new Date().toISOString().replace(/(?:\d{3}Z$)|(?:[^\d])/g, ''); // drop millis and non-digits | ||
return prefix + datePart + bs58_1.encode(crypto.randomBytes(16)); | ||
return prefix + datePart + (0, bs58_1.encode)(crypto.randomBytes(16)); | ||
} | ||
exports.generateId = generateId; | ||
//# sourceMappingURL=naming.js.map |
@@ -70,3 +70,3 @@ "use strict"; | ||
if (!this[_DB] && this.available) { | ||
this[_DB] = api_db_1.createDB(this[_baseUrl], this[_instance], { | ||
this[_DB] = (0, api_db_1.createDB)(this[_baseUrl], this[_instance], { | ||
token: this[_token] | ||
@@ -73,0 +73,0 @@ }); |
{ | ||
"name": "@journeyapps/cloudcode", | ||
"version": "0.0.0-dev.e1b1b23", | ||
"version": "0.0.0-dev.e1d19c3", | ||
"main": "./dist/index", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
159429
2779