UNPKG

@camunda8/sdk

Version:

[![NPM](https://nodei.co/npm/@camunda8/sdk.png)](https://www.npmjs.com/package/@camunda8/sdk)

36 lines 1.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createSpecializedRestApiJobClass = void 0; const C8Dto_1 = require("./C8Dto"); const factory = createMemoizedSpecializedRestApiJobClassFactory(); // Creates a specialized RestApiJob class that is cached based on input variables and custom headers. const createSpecializedRestApiJobClass = (inputVariableDto, customHeaders) => { // Assuming `createMemoizedSpecializedRestApiJobClassFactory` is available return factory(inputVariableDto, customHeaders); }; exports.createSpecializedRestApiJobClass = createSpecializedRestApiJobClass; function createMemoizedSpecializedRestApiJobClassFactory() { const cache = new Map(); return function (inputVariableDto, customHeadersDto) { // Create a unique cache key based on the class and inputs const cacheKey = JSON.stringify({ inputVariableDto, customHeadersDto, }); // Check for cached result if (cache.has(cacheKey)) { return cache.get(cacheKey); } // Create a new class that extends the original class class NewRestApiJobClass extends C8Dto_1.RestApiJob { } // Use Reflect to define the metadata on the new class's prototype Reflect.defineMetadata('child:class', inputVariableDto, NewRestApiJobClass.prototype, 'variables'); Reflect.defineMetadata('child:class', customHeadersDto, NewRestApiJobClass.prototype, 'customHeaders'); // Store the new class in cache cache.set(cacheKey, NewRestApiJobClass); // Return the new class return NewRestApiJobClass; }; } //# sourceMappingURL=RestApiJobClassFactory.js.map