Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@adaptable/utils

Package Overview
Dependencies
Maintainers
3
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adaptable/utils - npm Package Compare versions

Comparing version 1.26.0 to 1.27.0

20

dist/products.d.ts

@@ -12,4 +12,4 @@ import z from "zod";

export declare const scaleV3PlanId = "05eae30f-4a89-442d-a60d-8701be942d8e";
export declare const numericLimitKeys: readonly ["privateRepos", "domains", "databaseSizeMb", "concurrency", "instances", "minInstances", "cpuSeconds", "ramMb", "vCpus", "egressGb", "ingressGb"];
export declare const limitKeys: readonly ["privateRepos", "domains", "databaseSizeMb", "concurrency", "instances", "minInstances", "cpuSeconds", "ramMb", "vCpus", "egressGb", "ingressGb"];
export declare const numericLimitKeys: readonly ["privateRepos", "domains", "databaseSizeMb", "concurrency", "instances", "minInstances", "cpuSeconds", "ramMb", "requestTimeoutSeconds", "vCpus", "egressGb", "ingressGb"];
export declare const limitKeys: readonly ["privateRepos", "domains", "databaseSizeMb", "concurrency", "instances", "minInstances", "cpuSeconds", "ramMb", "requestTimeoutSeconds", "vCpus", "egressGb", "ingressGb"];
export declare type LimitKeys = typeof limitKeys[number];

@@ -27,2 +27,3 @@ export declare const UNLIMITED: number;

export declare function getExperimentId(input: any): ExperimentId;
export declare const timeStringSchema: z.ZodString;
export declare const resourceConfigSchema: z.ZodObject<{

@@ -33,5 +34,7 @@ maxConcurrentRequestsPerInstance: z.ZodNumber;

minInstances: z.ZodNumber;
requestTimeoutSeconds: z.ZodNumber;
vCpus: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
minInstances: number;
requestTimeoutSeconds: number;
vCpus: number;

@@ -43,2 +46,3 @@ maxConcurrentRequestsPerInstance: number;

minInstances: number;
requestTimeoutSeconds: number;
vCpus: number;

@@ -50,3 +54,3 @@ maxConcurrentRequestsPerInstance: number;

export declare type ResourceConfig = z.infer<typeof resourceConfigSchema>;
export declare const resourceKeys: ["minInstances", "vCpus", "maxConcurrentRequestsPerInstance", "maxInstances", "memory"];
export declare const resourceKeys: ["minInstances", "requestTimeoutSeconds", "vCpus", "maxConcurrentRequestsPerInstance", "maxInstances", "memory"];
export declare const resourceNameToLimitName: Record<keyof ResourceConfig, keyof ResourceLimits>;

@@ -56,2 +60,3 @@ export interface Plan {

allowSubscription: boolean;
attachesTo: "apps" | "organizations";
beta?: boolean;

@@ -78,3 +83,7 @@ buildsOnPlan?: string;

export declare const allPlans: Plan[];
export declare function getPlans(expId: ExperimentId): Plan[];
export interface GetPlansOptions {
expId: ExperimentId;
attachesTo?: Plan["attachesTo"][];
}
export declare function getPlans(optionsIn: ExperimentId | GetPlansOptions): Plan[];
export declare function getPlan(planId: string): Plan | undefined;

@@ -96,5 +105,8 @@ /**

ramMb: number;
requestTimeoutSeconds: number;
vCpus: number;
};
export declare const computeLimitsFromPlans: (plans: (Plan | undefined)[]) => ResourceLimits;
export declare function constrainToLimits(resources: ResourceConfig, limits: Partial<ResourceLimits>[]): ResourceConfig;
export {};
//# sourceMappingURL=products.d.ts.map

82

dist/products.js

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.resourcesToLimits = exports.getTrialPlan = exports.getFreePlan = exports.isNoBillingPlan = exports.isValidPlan = exports.allPlanIds = exports.getPlan = exports.getPlans = exports.allPlans = exports.resourceNameToLimitName = exports.resourceKeys = exports.resourceConfigSchema = exports.getExperimentId = exports.resourcePrices = exports.UNLIMITED = exports.limitKeys = exports.numericLimitKeys = exports.scaleV3PlanId = exports.buildV3PlanId = exports.scaleV2PlanId = exports.buildV2PlanId = exports.enterprisePlanId = exports.teamPlanId = exports.scalePlanId = exports.launchPlanId = exports.buildPlanId = exports.starterPlanId = void 0;
exports.constrainToLimits = exports.computeLimitsFromPlans = exports.resourcesToLimits = exports.getTrialPlan = exports.getFreePlan = exports.isNoBillingPlan = exports.isValidPlan = exports.allPlanIds = exports.getPlan = exports.getPlans = exports.allPlans = exports.resourceNameToLimitName = exports.resourceKeys = exports.resourceConfigSchema = exports.timeStringSchema = exports.getExperimentId = exports.resourcePrices = exports.UNLIMITED = exports.limitKeys = exports.numericLimitKeys = exports.scaleV3PlanId = exports.buildV3PlanId = exports.scaleV2PlanId = exports.buildV2PlanId = exports.enterprisePlanId = exports.teamPlanId = exports.scalePlanId = exports.launchPlanId = exports.buildPlanId = exports.starterPlanId = void 0;
const zod_1 = __importDefault(require("zod"));

@@ -28,2 +28,3 @@ exports.starterPlanId = "884c447f-1559-4144-ada2-d5efd8456ef9";

"ramMb",
"requestTimeoutSeconds",
"vCpus",

@@ -73,2 +74,3 @@ "egressGb",

exports.getExperimentId = getExperimentId;
exports.timeStringSchema = zod_1.default.string().regex(/^\d+[smhd]$/);
exports.resourceConfigSchema = zod_1.default.object({

@@ -79,2 +81,3 @@ maxConcurrentRequestsPerInstance: zod_1.default.number().int().gt(0),

minInstances: zod_1.default.number().int().gte(0),
requestTimeoutSeconds: zod_1.default.number().int().gt(0),
vCpus: zod_1.default.number().gt(0),

@@ -88,2 +91,3 @@ });

minInstances: "minInstances",
requestTimeoutSeconds: "requestTimeoutSeconds",
vCpus: "vCpus",

@@ -95,3 +99,4 @@ };

maxInstances: 8,
memory: 4 * 1000,
memory: 4 * 1024,
requestTimeoutSeconds: 10 * 60,
vCpus: 2,

@@ -103,2 +108,3 @@ };

allowSubscription: true,
attachesTo: "apps",
type: "fixed",

@@ -115,2 +121,3 @@ desc: "Take a test drive, kick the tires",

minInstances: 0,
requestTimeoutSeconds: 30,
vCpus: 0.5,

@@ -130,2 +137,3 @@ },

ingressGb: exports.UNLIMITED,
requestTimeoutSeconds: 30,
},

@@ -137,5 +145,6 @@ _id: exports.starterPlanId,

const buildV1 = {
name: "Build",
name: "Build (legacy v1)",
internalName: "Build v1",
allowSubscription: true,
attachesTo: "apps",
type: "fixed",

@@ -152,2 +161,3 @@ desc: "Start your top-secret project",

minInstances: 0,
requestTimeoutSeconds: 30,
vCpus: 1,

@@ -167,2 +177,3 @@ },

ingressGb: exports.UNLIMITED,
requestTimeoutSeconds: 300,
},

@@ -178,2 +189,3 @@ _id: exports.buildPlanId,

_id: exports.buildV2PlanId,
name: "Build",
internalName: "Build v2",

@@ -193,2 +205,3 @@ price: 3,

_id: exports.buildV3PlanId,
name: "Build",
internalName: "Build v3",

@@ -209,2 +222,3 @@ desc: "Private repo, custom domain, more runtime and RAM",

allowSubscription: true,
attachesTo: "apps",
type: "fixed",

@@ -221,2 +235,3 @@ desc: "Brand and launch your app",

minInstances: 0,
requestTimeoutSeconds: 30,
vCpus: 1,

@@ -236,2 +251,3 @@ },

ingressGb: exports.UNLIMITED,
requestTimeoutSeconds: 30,
},

@@ -248,2 +264,3 @@ _id: exports.launchPlanId,

allowSubscription: true,
attachesTo: "apps",
pitch: "Take your app to production with the ability to scale up, automatic backups, and more.",

@@ -259,2 +276,3 @@ price: 20,

minInstances: 0,
requestTimeoutSeconds: 30,
vCpus: 1,

@@ -268,3 +286,3 @@ },

vCpus: 4,
ramMb: 32 * 1000,
ramMb: 32 * 1024,
cpuSeconds: Math.floor(Number.MAX_VALUE),

@@ -275,2 +293,3 @@ databaseSizeMb: Math.floor(Number.MAX_VALUE),

ingressGb: exports.UNLIMITED,
requestTimeoutSeconds: 1 * 60 * 60, // 1 hour is a container service limit
},

@@ -303,5 +322,6 @@ _id: exports.scalePlanId,

allowSubscription: false,
attachesTo: "organizations",
type: "usage",
desc: "Bring your team on board and get unlimited apps",
pitch: "Bring your team on board and get unlimited apps",
desc: "Bring your team on board with no per-app charges",
pitch: "Bring your team on board with no per-app charges",
beta: true,

@@ -320,2 +340,3 @@ price: 20,

allowSubscription: false,
attachesTo: "organizations",
type: "enterprise",

@@ -342,4 +363,13 @@ desc: "For larger teams and apps with advanced requirements",

];
function getPlans(expId) {
return exports.allPlans.filter((p) => p.experimentIds.includes(expId));
function getPlans(optionsIn) {
const options = typeof optionsIn === "string" ? { expId: optionsIn } : optionsIn;
const { expId, attachesTo } = options;
let ret = [...exports.allPlans];
if (expId) {
ret = ret.filter((p) => p.experimentIds.includes(expId));
}
if (attachesTo) {
ret = ret.filter((p) => attachesTo.includes(p.attachesTo));
}
return ret;
}

@@ -400,2 +430,3 @@ exports.getPlans = getPlans;

ramMb: resources.memory,
requestTimeoutSeconds: resources.requestTimeoutSeconds,
vCpus: resources.vCpus,

@@ -405,2 +436,37 @@ };

exports.resourcesToLimits = resourcesToLimits;
function notUndef(p) { return p !== undefined; }
const computeLimitsFromPlans = (plans) => {
const limits = plans.map((p) => p?.limits).filter(notUndef);
return limits.reduce((res, cur) => {
const ret = { ...res };
for (const limitName of exports.limitKeys) {
// eslint-disable-next-line no-continue
if (cur[limitName] === undefined)
continue;
if (res[limitName] === undefined)
ret[limitName] = cur[limitName];
if (exports.numericLimitKeys.find((l) => l === limitName)) {
ret[limitName] = Math.max(res[limitName], cur[limitName]);
}
else {
ret[limitName] = cur[limitName];
// eslint-disable-next-line no-console
console.warn(`Don't know how to merge limit ${limitName}`, { limitName, plans });
}
}
return ret;
});
};
exports.computeLimitsFromPlans = computeLimitsFromPlans;
function constrainToLimits(resources, limits) {
const ret = { ...resources };
for (const resourceName of exports.resourceKeys) {
const limitName = exports.resourceNameToLimitName[resourceName];
const specificLimit = limits.map((l) => l[limitName])
.reduce((x, y) => Math.min(x ?? Number.MAX_VALUE, y ?? Number.MAX_VALUE), Number.MAX_VALUE);
ret[resourceName] = Math.min(resources[resourceName], specificLimit ?? Number.MAX_VALUE);
}
return ret;
}
exports.constrainToLimits = constrainToLimits;
//# sourceMappingURL=products.js.map
{
"name": "@adaptable/utils",
"version": "1.26.0",
"version": "1.27.0",
"description": "Common utilities for Adaptable.io",

@@ -48,3 +48,3 @@ "homepage": "https://adaptable.io",

},
"gitHead": "0d33b751ea86795a37713b34ce2c05d6fb32ea38"
"gitHead": "945178f6e173412e94f765df68aa8d4aea7ad7c9"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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