@mcma/api
Advanced tools
Comparing version 0.13.15 to 0.13.16
@@ -21,3 +21,3 @@ "use strict"; | ||
async handleRequest(requestContext) { | ||
var _a, _b; | ||
var _a; | ||
const request = requestContext.request; | ||
@@ -118,7 +118,4 @@ const response = requestContext.response; | ||
} | ||
if (response.body && ((_b = response.headers[Object.keys(response.headers).find(h => h.toLowerCase() === "content-type")]) === null || _b === void 0 ? void 0 : _b.toLowerCase().startsWith("application/json"))) { | ||
response.body = JSON.stringify(response.body); | ||
} | ||
} | ||
} | ||
exports.McmaApiController = McmaApiController; |
@@ -1,11 +0,10 @@ | ||
import { ContextVariableProvider, McmaTracker, McmaResource, LoggerProvider, Logger } from "@mcma/core"; | ||
import { EnvironmentVariables, Logger, LoggerProvider, McmaResource, McmaTracker } from "@mcma/core"; | ||
import { McmaApiRequest } from "./mcma-api-request"; | ||
import { McmaApiResponse } from "./mcma-api-response"; | ||
export declare class McmaApiRequestContext extends ContextVariableProvider { | ||
export declare class McmaApiRequestContext { | ||
readonly request: McmaApiRequest; | ||
private loggerProvider?; | ||
private loggerProvider; | ||
readonly environmentVariables: EnvironmentVariables; | ||
readonly response: McmaApiResponse; | ||
constructor(request: McmaApiRequest, contextVariables: { | ||
[key: string]: any; | ||
}, loggerProvider?: LoggerProvider); | ||
constructor(request: McmaApiRequest, loggerProvider: LoggerProvider, environmentVariables: EnvironmentVariables); | ||
hasRequestBody(): boolean; | ||
@@ -12,0 +11,0 @@ getRequestBody<T = any>(): T; |
@@ -8,7 +8,7 @@ "use strict"; | ||
const mcma_api_response_1 = require("./mcma-api-response"); | ||
class McmaApiRequestContext extends core_1.ContextVariableProvider { | ||
constructor(request, contextVariables, loggerProvider) { | ||
super(contextVariables); | ||
class McmaApiRequestContext { | ||
constructor(request, loggerProvider, environmentVariables) { | ||
this.request = request; | ||
this.loggerProvider = loggerProvider; | ||
this.environmentVariables = environmentVariables; | ||
this.response = new mcma_api_response_1.McmaApiResponse(); | ||
@@ -15,0 +15,0 @@ } |
export * from "./routing"; | ||
export * from "./http"; | ||
export * from "./context-variable-provider-ext"; | ||
export * from "./environment-variables-ext"; | ||
export * from "./filters"; | ||
export * from "./strings"; |
@@ -15,4 +15,4 @@ "use strict"; | ||
__exportStar(require("./http"), exports); | ||
__exportStar(require("./context-variable-provider-ext"), exports); | ||
__exportStar(require("./environment-variables-ext"), exports); | ||
__exportStar(require("./filters"), exports); | ||
__exportStar(require("./strings"), exports); |
@@ -6,3 +6,4 @@ "use strict"; | ||
const core_1 = require("@mcma/core"); | ||
const context_variable_provider_ext_1 = require("../../context-variable-provider-ext"); | ||
const data_1 = require("@mcma/data"); | ||
const environment_variables_ext_1 = require("../../environment-variables-ext"); | ||
const route_1 = require("../route"); | ||
@@ -29,4 +30,4 @@ class DefaultCreateRoute extends route_1.McmaApiRoute { | ||
const resourcePath = this.root + "/" + uuid_1.v4(); | ||
core_1.onResourceCreate(resource, context_variable_provider_ext_1.getPublicUrl(requestContext) + resourcePath); | ||
const dbTable = await this.dbTableProvider.get(core_1.getTableName(requestContext)); | ||
core_1.onResourceCreate(resource, environment_variables_ext_1.getPublicUrl(requestContext.environmentVariables) + resourcePath); | ||
const dbTable = await this.dbTableProvider.get(data_1.getTableName(requestContext.environmentVariables)); | ||
await dbTable.put(resourcePath, resource); | ||
@@ -33,0 +34,0 @@ if (this.onCompleted) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DefaultDeleteRoute = void 0; | ||
const core_1 = require("@mcma/core"); | ||
const data_1 = require("@mcma/data"); | ||
const route_1 = require("../route"); | ||
@@ -20,3 +20,3 @@ class DefaultDeleteRoute extends route_1.McmaApiRoute { | ||
} | ||
const table = await this.dbTableProvider.get(core_1.getTableName(requestContext)); | ||
const table = await this.dbTableProvider.get(data_1.getTableName(requestContext.environmentVariables)); | ||
const resource = await table.get(requestContext.request.path); | ||
@@ -23,0 +23,0 @@ if (!resource) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DefaultGetRoute = void 0; | ||
const core_1 = require("@mcma/core"); | ||
const data_1 = require("@mcma/data"); | ||
const route_1 = require("../route"); | ||
@@ -20,3 +20,3 @@ class DefaultGetRoute extends route_1.McmaApiRoute { | ||
} | ||
const dbTable = await this.dbTableProvider.get(core_1.getTableName(requestContext)); | ||
const dbTable = await this.dbTableProvider.get(data_1.getTableName(requestContext.environmentVariables)); | ||
const resource = await dbTable.get(requestContext.request.path); | ||
@@ -23,0 +23,0 @@ if (this.onCompleted) { |
@@ -8,3 +8,3 @@ "use strict"; | ||
const default_route_collection_1 = require("./default-route-collection"); | ||
const context_variable_provider_ext_1 = require("../../context-variable-provider-ext"); | ||
const environment_variables_ext_1 = require("../../environment-variables-ext"); | ||
class DefaultJobRouteCollection extends default_route_collection_1.DefaultRouteCollection { | ||
@@ -25,6 +25,6 @@ constructor(dbTableProvider, invokeWorker, root) { | ||
async onJobAssignmentCreationCompleted(requestContext, jobAssignment) { | ||
await this.workerInvoker.invoke(context_variable_provider_ext_1.getWorkerFunctionId(requestContext), { | ||
await this.workerInvoker.invoke(worker_invoker_1.getWorkerFunctionId(requestContext.environmentVariables), { | ||
operationName: "ProcessJobAssignment", | ||
input: { | ||
jobAssignmentDatabaseId: jobAssignment.id.replace(context_variable_provider_ext_1.getPublicUrl(requestContext), "") | ||
jobAssignmentDatabaseId: jobAssignment.id.replace(environment_variables_ext_1.getPublicUrl(requestContext.environmentVariables), "") | ||
}, | ||
@@ -31,0 +31,0 @@ tracker: jobAssignment.tracker |
import { McmaResource } from "@mcma/core"; | ||
import { DocumentDatabaseTableProvider, Query, CustomQuery, QueryResults } from "@mcma/data"; | ||
import { CustomQuery, DocumentDatabaseTableProvider, Query, QueryResults } from "@mcma/data"; | ||
import { McmaApiRequestContext } from "../../http"; | ||
@@ -4,0 +4,0 @@ import { McmaApiRoute } from "../route"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DefaultQueryRoute = void 0; | ||
const core_1 = require("@mcma/core"); | ||
const data_1 = require("@mcma/data"); | ||
@@ -68,3 +67,3 @@ const route_1 = require("../route"); | ||
} | ||
const table = await this.dbTableProvider.get(core_1.getTableName(requestContext)); | ||
const table = await this.dbTableProvider.get(data_1.getTableName(requestContext.environmentVariables)); | ||
const query = this.buildQuery(requestContext); | ||
@@ -71,0 +70,0 @@ const queryResults = data_1.isCustomQuery(query) ? await table.customQuery(query) : await table.query(query); |
@@ -5,3 +5,4 @@ "use strict"; | ||
const core_1 = require("@mcma/core"); | ||
const context_variable_provider_ext_1 = require("../../context-variable-provider-ext"); | ||
const data_1 = require("@mcma/data"); | ||
const environment_variables_ext_1 = require("../../environment-variables-ext"); | ||
const route_1 = require("../route"); | ||
@@ -27,4 +28,4 @@ class DefaultUpdateRoute extends route_1.McmaApiRoute { | ||
} | ||
core_1.onResourceUpsert(resource, context_variable_provider_ext_1.getPublicUrl(requestContext) + requestContext.request.path); | ||
const dbTable = await this.dbTableProvider.get(core_1.getTableName(requestContext)); | ||
core_1.onResourceUpsert(resource, environment_variables_ext_1.getPublicUrl(requestContext.environmentVariables) + requestContext.request.path); | ||
const dbTable = await this.dbTableProvider.get(data_1.getTableName(requestContext.environmentVariables)); | ||
await dbTable.put(requestContext.request.path, resource); | ||
@@ -31,0 +32,0 @@ if (this.onCompleted) { |
{ | ||
"name": "@mcma/api", | ||
"version": "0.13.15", | ||
"version": "0.13.16", | ||
"description": "Node module for building APIs based on the EBU MCMA framework", | ||
@@ -40,12 +40,12 @@ "engines": { | ||
"peerDependencies": { | ||
"@mcma/client": "0.13.15", | ||
"@mcma/core": "0.13.15", | ||
"@mcma/data": "0.13.15", | ||
"@mcma/worker-invoker": "0.13.15" | ||
"@mcma/client": "0.13.16", | ||
"@mcma/core": "0.13.16", | ||
"@mcma/data": "0.13.16", | ||
"@mcma/worker-invoker": "0.13.16" | ||
}, | ||
"devDependencies": { | ||
"@mcma/client": "0.13.15", | ||
"@mcma/core": "0.13.15", | ||
"@mcma/data": "0.13.15", | ||
"@mcma/worker-invoker": "0.13.15", | ||
"@mcma/client": "0.13.16", | ||
"@mcma/core": "0.13.16", | ||
"@mcma/data": "0.13.16", | ||
"@mcma/worker-invoker": "0.13.16", | ||
"@types/node": "^13.7.4", | ||
@@ -52,0 +52,0 @@ "@types/pluralize": "0.0.29", |
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
58119
1204