New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@defer/client

Package Overview
Dependencies
Maintainers
2
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@defer/client - npm Package Compare versions

Comparing version 2.3.0-alpha-20240305100458-967f19ce1da494deceacb326c813cb8ffaaffd35 to 2.3.0-alpha-20240305101023-c0322041cbab181db410146d91989cee3eaf9045

2

backend.d.ts

@@ -1,2 +0,2 @@

import { DeferableFunction, DeferredFunction } from "./index.js";
import { DeferableFunction, DeferredFunction } from "./index";
export type ExecutionState = "created" | "started" | "succeed" | "failed" | "cancelled" | "aborting" | "aborted" | "discarded";

@@ -3,0 +3,0 @@ export type ExecutionErrorCode = "ER0000" | "ER0001" | "ER0002" | "ER0003";

@@ -1,3 +0,3 @@

import { CancelExecutionResult, EnqueueResult, ExecutionFilters, GetExecutionResult, ListExecutionAttemptsResult, ListExecutionsResult, PageRequest, ReRunExecutionResult, RescheduleExecutionResult } from "../backend.js";
import { DeferableFunction, DeferredFunction } from "../index.js";
import { CancelExecutionResult, EnqueueResult, ExecutionFilters, GetExecutionResult, ListExecutionAttemptsResult, ListExecutionsResult, PageRequest, ReRunExecutionResult, RescheduleExecutionResult } from "../backend";
import { DeferableFunction, DeferredFunction } from "../index";
export declare function start(): () => Promise<void>;

@@ -4,0 +4,0 @@ export declare function enqueue<F extends DeferableFunction>(func: DeferredFunction<F>, args: Parameters<F>, scheduleFor: Date, discardAfter: Date | undefined, metadata: {

@@ -20,10 +20,10 @@ "use strict";

exports.listExecutionAttempts = exports.listExecutions = exports.reRunExecution = exports.rescheduleExecution = exports.cancelExecution = exports.getExecutionResult = exports.getExecution = exports.enqueue = exports.start = void 0;
const backend_js_1 = require("../backend.js");
const logger_js_1 = require("../logger.js");
const utils_js_1 = require("../utils.js");
const version_js_1 = __importDefault(require("../version.js"));
const counter_js_1 = require("./local/counter.js");
const kv_js_1 = require("./local/kv.js");
const concurrencyCounter = new counter_js_1.Counter();
const executionsStore = new kv_js_1.KV();
const backend_1 = require("../backend");
const logger_1 = require("../logger");
const utils_1 = require("../utils");
const version_1 = __importDefault(require("../version"));
const counter_1 = require("./local/counter");
const kv_1 = require("./local/kv");
const concurrencyCounter = new counter_1.Counter();
const executionsStore = new kv_1.KV();
const functionIdMapping = new Map();

@@ -33,3 +33,3 @@ const promisesState = new Set();

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Defer ${version_js_1.default}
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Defer ${version_1.default}
@@@@ @@@ @@@@ @@@@ Running in development mode

@@ -138,3 +138,3 @@ @@@@ @@@ @@@@ @@@@

function start() {
if ((0, utils_js_1.getEnv)("DEFER_NO_BANNER") === undefined || (0, utils_js_1.getEnv)("CI") !== undefined) {
if ((0, utils_1.getEnv)("DEFER_NO_BANNER") === undefined || (0, utils_1.getEnv)("CI") !== undefined) {
console.log(banner);

@@ -144,10 +144,10 @@ }

const getRunCond = () => runCond;
(0, logger_js_1.info)("starting local backend");
(0, logger_1.info)("starting local backend");
const ref = loop(getRunCond);
(0, logger_js_1.info)("local backend started");
(0, logger_1.info)("local backend started");
return async function () {
(0, logger_js_1.info)("stopping local backend");
(0, logger_1.info)("stopping local backend");
runCond = false;
await ref;
(0, logger_js_1.info)("local backend stopped");
(0, logger_1.info)("local backend stopped");
};

@@ -189,3 +189,3 @@ }

if (shouldDiscard) {
(0, logger_js_1.info)("execution discarded", {
(0, logger_1.info)("execution discarded", {
id: executionId,

@@ -204,3 +204,3 @@ function: execution.functionName,

let errorCode;
(0, logger_js_1.info)("execution started", {
(0, logger_1.info)("execution started", {
id: executionId,

@@ -213,3 +213,3 @@ function: execution.functionName,

state = "succeed";
(0, logger_js_1.info)("execution succeeded", {
(0, logger_1.info)("execution succeeded", {
id: executionId,

@@ -222,3 +222,3 @@ function: execution.functionName,

errorCode = "ER0003";
(0, logger_js_1.error)("execution failed", {
(0, logger_1.error)("execution failed", {
id: executionId,

@@ -234,3 +234,3 @@ function: execution.functionName,

execution.state = state;
execution.result = (0, utils_js_1.stringify)(result);
execution.result = (0, utils_1.stringify)(result);
execution.updatedAt = new Date();

@@ -244,3 +244,3 @@ execution.errorCode = errorCode;

}
await (0, utils_js_1.sleep)(10);
await (0, utils_1.sleep)(10);
}

@@ -250,3 +250,3 @@ await Promise.allSettled(promisesState.entries());

catch (e) {
(0, logger_js_1.error)("scheduler loop crash", { cause: e.message });
(0, logger_1.error)("scheduler loop crash", { cause: e.message });
}

@@ -257,3 +257,3 @@ }

if (functionId === undefined) {
functionId = (0, utils_js_1.randomUUID)();
functionId = (0, utils_1.randomUUID)();
functionIdMapping.set(func.__metadata.name, functionId);

@@ -263,3 +263,3 @@ }

const execution = {
id: (0, utils_js_1.randomUUID)(),
id: (0, utils_1.randomUUID)(),
state: "created",

@@ -269,3 +269,3 @@ functionId: functionId,

func,
args: (0, utils_js_1.stringify)(args),
args: (0, utils_1.stringify)(args),
metadata: metadata || {},

@@ -284,3 +284,3 @@ scheduleFor,

if (execution === undefined)
throw new backend_js_1.ExecutionNotFound(`cannot find execution "${id}"`);
throw new backend_1.ExecutionNotFound(`cannot find execution "${id}"`);
return buildExecution(execution);

@@ -292,7 +292,7 @@ }

if (execution === undefined)
throw new backend_js_1.ExecutionNotFound(`cannot find execution "${id}"`);
throw new backend_1.ExecutionNotFound(`cannot find execution "${id}"`);
switch (execution.state) {
case "created":
case "started":
throw new backend_js_1.ExecutionResultNotAvailableYet();
throw new backend_1.ExecutionResultNotAvailableYet();
case "failed":

@@ -302,3 +302,3 @@ case "succeed":

default:
throw new backend_js_1.ExecutionResultNotAvailable();
throw new backend_1.ExecutionResultNotAvailable();
}

@@ -310,3 +310,3 @@ }

if (execution === undefined)
throw new backend_js_1.ExecutionNotFound(`cannot find execution "${id}"`);
throw new backend_1.ExecutionNotFound(`cannot find execution "${id}"`);
execution = await executionsStore.transaction(id, async (execution) => {

@@ -316,3 +316,3 @@ if (force) {

case "aborting":
throw new backend_js_1.ExecutionAbortingAlreadyInProgress("aborting execution already in progress");
throw new backend_1.ExecutionAbortingAlreadyInProgress("aborting execution already in progress");
case "created":

@@ -325,3 +325,3 @@ execution.state = "cancelled";

default:
throw new backend_js_1.ExecutionNotCancellable(`cannot cancel execution in "${execution.state}" state`);
throw new backend_1.ExecutionNotCancellable(`cannot cancel execution in "${execution.state}" state`);
}

@@ -335,3 +335,3 @@ }

default:
throw new backend_js_1.ExecutionNotCancellable(`cannot cancel execution in "${execution.state}" state`);
throw new backend_1.ExecutionNotCancellable(`cannot cancel execution in "${execution.state}" state`);
}

@@ -348,6 +348,6 @@ }

if (execution === undefined)
throw new backend_js_1.ExecutionNotFound(`cannot find execution "${id}"`);
throw new backend_1.ExecutionNotFound(`cannot find execution "${id}"`);
execution = await executionsStore.transaction(id, async (execution) => {
if (execution.state !== "created")
throw new backend_js_1.ExecutionNotReschedulable(execution.state);
throw new backend_1.ExecutionNotReschedulable(execution.state);
execution.scheduleFor = scheduleFor;

@@ -363,6 +363,6 @@ execution.updatedAt = new Date();

if (execution === undefined)
throw new backend_js_1.ExecutionNotFound(`cannot find execution "${id}"`);
throw new backend_1.ExecutionNotFound(`cannot find execution "${id}"`);
const now = new Date();
const newExecution = {
id: (0, utils_js_1.randomUUID)(),
id: (0, utils_1.randomUUID)(),
state: "created",

@@ -369,0 +369,0 @@ functionId: execution.functionId,

@@ -1,3 +0,3 @@

import { CancelExecutionResult, DateInterval, EnqueueResult, ExecutionErrorCode, ExecutionFilters, ExecutionState, GetExecutionResult, ListExecutionAttemptsResult, ListExecutionsResult, PageRequest, ReRunExecutionResult, RescheduleExecutionResult } from "../backend.js";
import { DeferableFunction, DeferredFunction } from "../index.js";
import { CancelExecutionResult, DateInterval, EnqueueResult, ExecutionErrorCode, ExecutionFilters, ExecutionState, GetExecutionResult, ListExecutionAttemptsResult, ListExecutionsResult, PageRequest, ReRunExecutionResult, RescheduleExecutionResult } from "../backend";
import { DeferableFunction, DeferredFunction } from "../index";
export interface SingleObjectResponse<T> {

@@ -4,0 +4,0 @@ data: T;

@@ -17,5 +17,5 @@ "use strict";

exports.listExecutionAttempts = exports.listExecutions = exports.reRunExecution = exports.rescheduleExecution = exports.cancelExecution = exports.getExecutionResult = exports.getExecution = exports.enqueue = void 0;
const backend_js_1 = require("../backend.js");
const utils_js_1 = require("../utils.js");
const httpClient_js_1 = require("./remote/httpClient.js");
const backend_1 = require("../backend");
const utils_1 = require("../utils");
const httpClient_1 = require("./remote/httpClient");
function newExecution(o) {

@@ -33,5 +33,5 @@ return {

function newClientFromEnv() {
const accessToken = (0, utils_js_1.getEnv)("DEFER_TOKEN") || "";
const endpoint = (0, utils_js_1.getEnv)("DEFER_ENDPOINT") || "https://api.defer.run";
return (0, httpClient_js_1.makeHTTPClient)(endpoint, accessToken);
const accessToken = (0, utils_1.getEnv)("DEFER_TOKEN") || "";
const endpoint = (0, utils_1.getEnv)("DEFER_ENDPOINT") || "https://api.defer.run";
return (0, httpClient_1.makeHTTPClient)(endpoint, accessToken);
}

@@ -47,6 +47,6 @@ async function enqueue(func, args, scheduleFor, discardAfter, metadata) {

};
const { status, response } = await httpClient("PUT", "/public/v2/executions", (0, utils_js_1.stringify)(request));
const { status, response } = await httpClient("PUT", "/public/v2/executions", (0, utils_1.stringify)(request));
if (status === 201)
return newExecution(response.data);
throw new backend_js_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
throw new backend_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
}

@@ -60,4 +60,4 @@ exports.enqueue = enqueue;

else if (status === 404)
throw new backend_js_1.ExecutionNotFound(response.message);
throw new backend_js_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
throw new backend_1.ExecutionNotFound(response.message);
throw new backend_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
}

@@ -71,8 +71,8 @@ exports.getExecution = getExecution;

else if (status === 202)
throw new backend_js_1.ExecutionResultNotAvailableYet();
throw new backend_1.ExecutionResultNotAvailableYet();
else if (status === 204)
throw new backend_js_1.ExecutionResultNotAvailable();
throw new backend_1.ExecutionResultNotAvailable();
else if (status === 404)
throw new backend_js_1.ExecutionNotFound(response.message);
throw new backend_js_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
throw new backend_1.ExecutionNotFound(response.message);
throw new backend_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
}

@@ -83,12 +83,12 @@ exports.getExecutionResult = getExecutionResult;

const request = { force: force };
const { status, response } = await httpClient("POST", `/public/v2/executions/${id}/cancellation`, (0, utils_js_1.stringify)(request));
const { status, response } = await httpClient("POST", `/public/v2/executions/${id}/cancellation`, (0, utils_1.stringify)(request));
if (status === 200)
return newExecution(response.data);
else if (status === 202)
throw new backend_js_1.ExecutionAbortingAlreadyInProgress(response.message);
throw new backend_1.ExecutionAbortingAlreadyInProgress(response.message);
else if (status === 404)
throw new backend_js_1.ExecutionNotFound(response.message);
throw new backend_1.ExecutionNotFound(response.message);
else if (status === 409)
throw new backend_js_1.ExecutionNotCancellable(response.message);
throw new backend_js_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
throw new backend_1.ExecutionNotCancellable(response.message);
throw new backend_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
}

@@ -101,10 +101,10 @@ exports.cancelExecution = cancelExecution;

};
const { status, response } = await httpClient("PATCH", `/public/v2/executions/${id}/schedule`, (0, utils_js_1.stringify)(request));
const { status, response } = await httpClient("PATCH", `/public/v2/executions/${id}/schedule`, (0, utils_1.stringify)(request));
if (status === 200)
return newExecution(response.data);
else if (status === 404)
throw new backend_js_1.ExecutionNotFound(response.message);
throw new backend_1.ExecutionNotFound(response.message);
else if (status === 409)
throw new backend_js_1.ExecutionNotReschedulable(response.message);
throw new backend_js_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
throw new backend_1.ExecutionNotReschedulable(response.message);
throw new backend_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
}

@@ -115,8 +115,8 @@ exports.rescheduleExecution = rescheduleExecution;

const request = {};
const { status, response } = await httpClient("POST", `/public/v2/executions/${id}/reruns`, (0, utils_js_1.stringify)(request));
const { status, response } = await httpClient("POST", `/public/v2/executions/${id}/reruns`, (0, utils_1.stringify)(request));
if (status === 200)
return newExecution(response.data);
else if (status === 404)
throw new backend_js_1.ExecutionNotFound(response.message);
throw new backend_js_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
throw new backend_1.ExecutionNotFound(response.message);
throw new backend_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
}

@@ -140,3 +140,3 @@ exports.reRunExecution = reRunExecution;

};
const { status, response } = await httpClient("POST", `/public/v2/executions`, (0, utils_js_1.stringify)(request));
const { status, response } = await httpClient("POST", `/public/v2/executions`, (0, utils_1.stringify)(request));
if (status === 200) {

@@ -156,3 +156,3 @@ const executions = [];

}
throw new backend_js_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
throw new backend_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
}

@@ -176,3 +176,3 @@ exports.listExecutions = listExecutions;

};
const { status, response } = await httpClient("POST", `/public/v2/executions/${id}/attempts`, (0, utils_js_1.stringify)(request));
const { status, response } = await httpClient("POST", `/public/v2/executions/${id}/attempts`, (0, utils_1.stringify)(request));
if (status === 200) {

@@ -193,5 +193,5 @@ const executions = [];

else if (status === 404)
throw new backend_js_1.ExecutionNotFound(response.message);
throw new backend_js_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
throw new backend_1.ExecutionNotFound(response.message);
throw new backend_1.DeferError(`backend responds with "${status}" and message "${response.message}"`);
}
exports.listExecutionAttempts = listExecutionAttempts;

@@ -1,2 +0,2 @@

import { DeferError } from "../../backend.js";
import { DeferError } from "../../backend";
export type HTTPClient = <T>(method: string, path: string, body?: string | null) => Promise<{

@@ -3,0 +3,0 @@ status: number;

@@ -20,5 +20,5 @@ "use strict";

exports.makeHTTPClient = exports.ClientError = void 0;
const backend_js_1 = require("../../backend.js");
const utils_js_1 = require("../../utils.js");
const version_js_1 = __importDefault(require("../../version.js"));
const backend_1 = require("../../backend");
const utils_1 = require("../../utils");
const version_1 = __importDefault(require("../../version"));
const basicAuth = (username, password) => {

@@ -28,3 +28,3 @@ const credentials = btoa(`${username}:${password}`);

};
class ClientError extends backend_js_1.DeferError {
class ClientError extends backend_1.DeferError {
constructor(msg) {

@@ -45,3 +45,3 @@ super(msg);

if (error instanceof Error)
message = `invalid endpoint url: ${(0, utils_js_1.errorMessage)(error)}`;
message = `invalid endpoint url: ${(0, utils_1.errorMessage)(error)}`;
else

@@ -53,3 +53,3 @@ message = `unknown error: ${String(error)}`;

const options = Object.assign(Object.assign({}, clientOptions), { method,
body, cache: "no-store", headers: Object.assign(Object.assign({}, customHeaderFields), { "Content-type": "application/json", "User-Agent": `defer/${version_js_1.default} (source: https://github.com/defer-run/defer.client)`, Authorization: basicAuth("", accessToken) }) });
body, cache: "no-store", headers: Object.assign(Object.assign({}, customHeaderFields), { "Content-type": "application/json", "User-Agent": `defer/${version_1.default} (source: https://github.com/defer-run/defer.client)`, Authorization: basicAuth("", accessToken) }) });
let response;

@@ -63,3 +63,3 @@ let data;

if (error instanceof Error)
message = `cannot execute http request: ${(0, utils_js_1.errorMessage)(error)}`;
message = `cannot execute http request: ${(0, utils_1.errorMessage)(error)}`;
else

@@ -76,3 +76,3 @@ message = `unknown error: ${String(error)}`;

if (error instanceof Error)
message = `cannot decode http response: ${(0, utils_js_1.errorMessage)(error)}`;
message = `cannot decode http response: ${(0, utils_1.errorMessage)(error)}`;
else

@@ -79,0 +79,0 @@ message = `unknown error: ${String(error)}`;

# @defer/client
## 2.3.0-alpha-20240305100458-967f19ce1da494deceacb326c813cb8ffaaffd35
## 2.3.0-alpha-20240305101023-c0322041cbab181db410146d91989cee3eaf9045

@@ -5,0 +5,0 @@ ### Minor Changes

@@ -1,3 +0,3 @@

import { Backend, CancelExecutionResult, EnqueueResult, ExecutionFilters, GetExecutionResult, ListExecutionAttemptsResult, ListExecutionsResult, PageRequest, ReRunExecutionResult, RescheduleExecutionResult } from "./backend.js";
import { Duration } from "./utils.js";
import { Backend, CancelExecutionResult, EnqueueResult, ExecutionFilters, GetExecutionResult, ListExecutionAttemptsResult, ListExecutionsResult, PageRequest, ReRunExecutionResult, RescheduleExecutionResult } from "./backend";
import { Duration } from "./utils";
export declare let backend: Backend;

@@ -4,0 +4,0 @@ /**

@@ -40,14 +40,14 @@ "use strict";

exports.awaitResult = exports.listExecutions = exports.listExecutionAttempts = exports.getExecutionTries = exports.reRunExecution = exports.rescheduleExecution = exports.cancelExecution = exports.getExecutionResult = exports.getExecution = exports.assignOptions = exports.discardAfter = exports.addMetadata = exports.delay = exports.defer = exports.deferEnabled = exports.backend = void 0;
const backend_js_1 = require("./backend.js");
const localBackend = __importStar(require("./backend/local.js"));
const remoteBackend = __importStar(require("./backend/remote.js"));
const jitter_js_1 = require("./jitter.js");
const logger_js_1 = require("./logger.js");
const utils_js_1 = require("./utils.js");
const backend_1 = require("./backend");
const localBackend = __importStar(require("./backend/local"));
const remoteBackend = __importStar(require("./backend/remote"));
const jitter_1 = require("./jitter");
const logger_1 = require("./logger");
const utils_1 = require("./utils");
const INTERNAL_VERSION = 6;
const RETRY_MAX_ATTEMPTS_PLACEHOLDER = 13;
exports.backend = remoteBackend;
if ((0, utils_js_1.getEnv)("DEFER_TOKEN") === undefined) {
if ((0, utils_1.getEnv)("DEFER_TOKEN") === undefined) {
exports.backend = localBackend;
if ((0, utils_js_1.getEnv)("DEFER_NO_LOCAL_SCHEDULER") === undefined)
if ((0, utils_1.getEnv)("DEFER_NO_LOCAL_SCHEDULER") === undefined)
localBackend.start();

@@ -59,3 +59,3 @@ }

*/
const deferEnabled = () => !!(0, utils_js_1.getEnv)("DEFER_TOKEN");
const deferEnabled = () => !!(0, utils_1.getEnv)("DEFER_TOKEN");
exports.deferEnabled = deferEnabled;

@@ -121,3 +121,3 @@ function defaultRetryPolicy() {

const now = new Date();
scheduleFor = (0, utils_js_1.fromDurationToDate)(now, delay);
scheduleFor = (0, utils_1.fromDurationToDate)(now, delay);
}

@@ -133,3 +133,3 @@ else {

const now = new Date();
discardAfter = (0, utils_js_1.fromDurationToDate)(now, after);
discardAfter = (0, utils_1.fromDurationToDate)(now, after);
}

@@ -140,3 +140,3 @@ const metadata = ((_c = func.__execOptions) === null || _c === void 0 ? void 0 : _c.metadata)

const response = await exports.backend.enqueue(func, args, scheduleFor, discardAfter, metadata);
(0, logger_js_1.info)("execution enqueued", {
(0, logger_1.info)("execution enqueued", {
id: response.id,

@@ -300,3 +300,3 @@ function: response.functionName,

else if (value) {
scheduleFor = (0, utils_js_1.fromDurationToDate)(now, value);
scheduleFor = (0, utils_1.fromDurationToDate)(now, value);
}

@@ -331,3 +331,3 @@ else {

async function getExecutionTries(id) {
(0, logger_js_1.warn)(`"getExecutionTries" is deprecated and will be removed in future versions. Please use "listExecutionAttempts" instead.`);
(0, logger_1.warn)(`"getExecutionTries" is deprecated and will be removed in future versions. Please use "listExecutionAttempts" instead.`);
return listExecutionAttempts(id);

@@ -376,3 +376,3 @@ }

const enqueueResponse = await enqueue(fn, ...args);
await (0, utils_js_1.sleep)(1000);
await (0, utils_1.sleep)(1000);
let i = 0;

@@ -385,5 +385,5 @@ for (;;) {

const result = await getExecutionResult(enqueueResponse.id);
let error = new backend_js_1.DeferError(`execution ${enqueueResponse.id} has failed`);
let error = new backend_1.DeferError(`execution ${enqueueResponse.id} has failed`);
if (result === null || result === void 0 ? void 0 : result.message) {
error = new backend_js_1.DeferError(result.message);
error = new backend_1.DeferError(result.message);
error.stack = result.stack;

@@ -401,5 +401,5 @@ }

case "discarded":
throw new backend_js_1.DeferError(`execution "${enqueueResponse.id}" was "${response.state}"`);
throw new backend_1.DeferError(`execution "${enqueueResponse.id}" was "${response.state}"`);
default:
await (0, utils_js_1.sleep)((0, jitter_js_1.jitter)(i) * 1000);
await (0, utils_1.sleep)((0, jitter_1.jitter)(i) * 1000);
}

@@ -406,0 +406,0 @@ }

@@ -17,4 +17,4 @@ "use strict";

exports.debug = exports.warn = exports.error = exports.info = exports.log = void 0;
const utils_js_1 = require("./utils.js");
// source: https://github.com/csquared/node-logfmt/blob/master/lib/stringify.js
const utils_1 = require("./utils");
// source: https://github.com/csquared/node-logfmt/blob/master/lib/stringify
function fmtData(data) {

@@ -64,5 +64,5 @@ var line = "";

function debug(msg, data) {
if ((0, utils_js_1.isDebugEnabled)())
if ((0, utils_1.isDebugEnabled)())
log("debug", msg, data);
}
exports.debug = debug;
import type { NextRequest, NextResponse } from "next/server";
import { DeferredFunction } from "../index.js";
import { DeferredFunction } from "../index";
export interface DeferNextRoute {

@@ -4,0 +4,0 @@ GetHandler: (request: NextRequest) => Promise<NextResponse | Response>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.asNextRoute = void 0;
const backend_js_1 = require("../backend.js");
const index_js_1 = require("../index.js");
const backend_1 = require("../backend");
const index_1 = require("../index");
const ResponseJSON = Response.json;

@@ -14,5 +14,5 @@ function asNextRoute(deferFn, options) {

let result = undefined;
const { state } = await (0, index_js_1.getExecution)(id);
const { state } = await (0, index_1.getExecution)(id);
if (state === "succeed" || state === "failed") {
result = await (0, index_js_1.getExecutionResult)(id);
result = await (0, index_1.getExecutionResult)(id);
}

@@ -22,3 +22,3 @@ return ResponseJSON({ id, state, result });

catch (e) {
if (e instanceof backend_js_1.DeferError) {
if (e instanceof backend_1.DeferError) {
return ResponseJSON({ id, error: e.toString() }, {

@@ -25,0 +25,0 @@ status: 500,

@@ -1,2 +0,2 @@

export { DeferNextRoute, asNextRoute } from "./asNextRoute.js";
export { UseDeferRoute, useDeferRoute } from "./useDeferRoute.js";
export { DeferNextRoute, asNextRoute } from "./asNextRoute";
export { UseDeferRoute, useDeferRoute } from "./useDeferRoute";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useDeferRoute = exports.asNextRoute = void 0;
var asNextRoute_js_1 = require("./asNextRoute.js");
Object.defineProperty(exports, "asNextRoute", { enumerable: true, get: function () { return asNextRoute_js_1.asNextRoute; } });
var useDeferRoute_js_1 = require("./useDeferRoute.js");
Object.defineProperty(exports, "useDeferRoute", { enumerable: true, get: function () { return useDeferRoute_js_1.useDeferRoute; } });
var asNextRoute_1 = require("./asNextRoute");
Object.defineProperty(exports, "asNextRoute", { enumerable: true, get: function () { return asNextRoute_1.asNextRoute; } });
var useDeferRoute_1 = require("./useDeferRoute");
Object.defineProperty(exports, "useDeferRoute", { enumerable: true, get: function () { return useDeferRoute_1.useDeferRoute; } });

@@ -1,2 +0,2 @@

import type { DeferredFunction } from "../index.js";
import type { DeferredFunction } from "../index";
export type UseDeferRoute<ARA extends boolean, A extends any[], R> = [

@@ -10,5 +10,5 @@ execute: (...args: ARA extends true ? any : A) => void,

];
export declare const useDeferRoute: <DFR extends DeferredFunction<any> = any, F extends (...args: any[]) => Promise<any> = DFR extends DeferredFunction<infer RR extends import("../index.js").DeferableFunction> ? RR : any, HP extends boolean = false, R = ReturnType<F> extends Promise<infer RR_1> ? RR_1 : ReturnType<F>, A extends any[] = Parameters<F>>(routePath: string, { refreshInterval }?: {
export declare const useDeferRoute: <DFR extends DeferredFunction<any> = any, F extends (...args: any[]) => Promise<any> = DFR extends DeferredFunction<infer RR extends import("../index").DeferableFunction> ? RR : any, HP extends boolean = false, R = ReturnType<F> extends Promise<infer RR_1> ? RR_1 : ReturnType<F>, A extends any[] = Parameters<F>>(routePath: string, { refreshInterval }?: {
hasProxy: HP;
refreshInterval: number;
}) => UseDeferRoute<HP, A, R>;
{
"name": "@defer/client",
"version": "2.3.0-alpha-20240305100458-967f19ce1da494deceacb326c813cb8ffaaffd35",
"version": "2.3.0-alpha-20240305101023-c0322041cbab181db410146d91989cee3eaf9045",
"description": "Zero infrastructure NodeJS background jobs",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,2 +0,2 @@

declare const _default: "2.3.0-alpha-20240305100458-967f19ce1da494deceacb326c813cb8ffaaffd35";
declare const _default: "2.3.0-alpha-20240305101023-c0322041cbab181db410146d91989cee3eaf9045";
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = "2.3.0-alpha-20240305100458-967f19ce1da494deceacb326c813cb8ffaaffd35";
exports.default = "2.3.0-alpha-20240305101023-c0322041cbab181db410146d91989cee3eaf9045";
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc