Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

blimu

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blimu - npm Package Compare versions

Comparing version
1.1.1
to
1.1.4
+93
dist/index.cjs
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var index_exports = {};
__export(index_exports, {
BlimuConfigSchema: () => BlimuConfigSchema,
EntitlementDefinitionSchema: () => EntitlementDefinitionSchema,
FeatureDefinitionSchema: () => FeatureDefinitionSchema,
PlanDefinitionSchema: () => PlanDefinitionSchema,
ResourceDefinitionSchema: () => ResourceDefinitionSchema,
defineConfig: () => defineConfig
});
module.exports = __toCommonJS(index_exports);
// src/config/schema.ts
var import_zod = require("zod");
var ResourceDefinitionSchema = import_zod.z.object({
is_tenant: import_zod.z.boolean().optional(),
roles: import_zod.z.array(import_zod.z.string()).min(1, "At least one role must be defined"),
parents: import_zod.z.record(import_zod.z.string(), import_zod.z.object({ required: import_zod.z.boolean() })).optional(),
roles_inheritance: import_zod.z.record(
import_zod.z.string().min(1),
// local role
// Allow tokens containing letters, numbers, underscores or dashes
// Examples: parent->editor, organization->admin, workspace_v2->viewer
import_zod.z.array(import_zod.z.string().regex(/^([a-z0-9_-]+->)*[a-z0-9_-]+$/i)).min(1)
).optional()
});
var EntitlementDefinitionSchema = import_zod.z.object({
roles: import_zod.z.array(import_zod.z.string()).min(1).optional(),
plans: import_zod.z.array(import_zod.z.string()).optional(),
limit: import_zod.z.string().optional()
// Reference to usage-based limit
});
var FeatureDefinitionSchema = import_zod.z.object({
name: import_zod.z.string(),
summary: import_zod.z.string().optional(),
entitlements: import_zod.z.array(import_zod.z.string()).optional(),
plans: import_zod.z.array(import_zod.z.string()).optional(),
default_enabled: import_zod.z.boolean().optional()
});
var PlanDefinitionSchema = import_zod.z.object({
name: import_zod.z.string().min(1, "Plan name is required"),
summary: import_zod.z.string().optional(),
description: import_zod.z.string().min(1, "Plan description is required").optional(),
resource_limits: import_zod.z.record(import_zod.z.string(), import_zod.z.number().int().min(0)).optional(),
usage_based_limits: import_zod.z.record(
import_zod.z.string(),
import_zod.z.object({
value: import_zod.z.number().int().min(0),
period: import_zod.z.enum(["monthly", "yearly", "lifetime"])
})
).optional()
});
var BlimuConfigSchema = import_zod.z.object({
resources: import_zod.z.record(import_zod.z.string().min(1), ResourceDefinitionSchema),
entitlements: import_zod.z.record(import_zod.z.string().min(1), EntitlementDefinitionSchema).optional(),
features: import_zod.z.record(import_zod.z.string().min(1), FeatureDefinitionSchema).optional(),
plans: import_zod.z.record(import_zod.z.string().min(1), PlanDefinitionSchema).optional()
});
// src/config/define-config.ts
function defineConfig(config) {
const validated = BlimuConfigSchema.parse(config);
return config;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
BlimuConfigSchema,
EntitlementDefinitionSchema,
FeatureDefinitionSchema,
PlanDefinitionSchema,
ResourceDefinitionSchema,
defineConfig
});
//# sourceMappingURL=index.cjs.map
{"version":3,"sources":["../src/index.ts","../src/config/schema.ts","../src/config/define-config.ts"],"sourcesContent":["// Library exports for programmatic usage\n\n/**\n * Configuration utilities\n */\nexport { defineConfig } from './config/define-config';\nexport type {\n BlimuConfig,\n ResourceDefinition,\n EntitlementDefinition,\n FeatureDefinition,\n PlanDefinition,\n} from './config/schema';\nexport {\n BlimuConfigSchema,\n ResourceDefinitionSchema,\n EntitlementDefinitionSchema,\n FeatureDefinitionSchema,\n PlanDefinitionSchema,\n} from './config/schema';\n\n/**\n * Type inference utilities\n */\nexport type {\n InferResourceTypes,\n InferEntitlementTypes,\n InferPlanTypes,\n InferLimitTypes,\n InferUsageLimitTypes,\n} from './types/infer';\n","import { z } from 'zod';\n\n/**\n * Zod schema for resource definition\n */\nexport const ResourceDefinitionSchema = z.object({\n is_tenant: z.boolean().optional(),\n roles: z.array(z.string()).min(1, 'At least one role must be defined'),\n parents: z.record(z.string(), z.object({ required: z.boolean() })).optional(),\n roles_inheritance: z\n .record(\n z.string().min(1), // local role\n // Allow tokens containing letters, numbers, underscores or dashes\n // Examples: parent->editor, organization->admin, workspace_v2->viewer\n z.array(z.string().regex(/^([a-z0-9_-]+->)*[a-z0-9_-]+$/i)).min(1),\n )\n .optional(),\n});\n\n/**\n * Zod schema for entitlement definition\n */\nexport const EntitlementDefinitionSchema = z.object({\n roles: z.array(z.string()).min(1).optional(),\n plans: z.array(z.string()).optional(),\n limit: z.string().optional(), // Reference to usage-based limit\n});\n\n/**\n * Zod schema for feature definition\n */\nexport const FeatureDefinitionSchema = z.object({\n name: z.string(),\n summary: z.string().optional(),\n entitlements: z.array(z.string()).optional(),\n plans: z.array(z.string()).optional(),\n default_enabled: z.boolean().optional(),\n});\n\n/**\n * Zod schema for plan definition\n */\nexport const PlanDefinitionSchema = z.object({\n name: z.string().min(1, 'Plan name is required'),\n summary: z.string().optional(),\n description: z.string().min(1, 'Plan description is required').optional(),\n resource_limits: z.record(z.string(), z.number().int().min(0)).optional(),\n usage_based_limits: z\n .record(\n z.string(),\n z.object({\n value: z.number().int().min(0),\n period: z.enum(['monthly', 'yearly', 'lifetime']),\n }),\n )\n .optional(),\n});\n\n/**\n * Zod schema for complete Blimu configuration\n */\nexport const BlimuConfigSchema = z.object({\n resources: z.record(z.string().min(1), ResourceDefinitionSchema),\n entitlements: z.record(z.string().min(1), EntitlementDefinitionSchema).optional(),\n features: z.record(z.string().min(1), FeatureDefinitionSchema).optional(),\n plans: z.record(z.string().min(1), PlanDefinitionSchema).optional(),\n});\n\n/**\n * Type inference from schemas\n */\nexport type ResourceDefinition = z.infer<typeof ResourceDefinitionSchema>;\nexport type EntitlementDefinition = z.infer<typeof EntitlementDefinitionSchema>;\nexport type FeatureDefinition = z.infer<typeof FeatureDefinitionSchema>;\nexport type PlanDefinition = z.infer<typeof PlanDefinitionSchema>;\nexport type BlimuConfig = z.infer<typeof BlimuConfigSchema>;\n","import {\n BlimuConfigSchema,\n type BlimuConfig,\n type ResourceDefinition,\n type EntitlementDefinition,\n type FeatureDefinition,\n type PlanDefinition,\n} from './schema';\n\n/**\n * Input type for defineConfig (allows partial config during definition)\n * Uses proper types inferred from Zod schemas for full type safety\n */\nexport type BlimuConfigInput = {\n resources: Record<string, ResourceDefinition>;\n entitlements?: Record<string, EntitlementDefinition>;\n features?: Record<string, FeatureDefinition>;\n plans?: Record<string, PlanDefinition>;\n};\n\n/**\n * Defines and validates a Blimu configuration.\n *\n * This function validates the config using Zod schemas and returns\n * a type-safe, validated configuration object.\n *\n * @param config - The Blimu configuration object\n * @returns The validated configuration\n * @throws {z.ZodError} If the configuration is invalid\n *\n * @example\n * ```typescript\n * import { defineConfig } from 'blimu';\n *\n * export default defineConfig({\n * resources: {\n * workspace: {\n * roles: ['admin', 'editor', 'viewer'],\n * is_tenant: true,\n * },\n * },\n * entitlements: {\n * 'workspace:read': {\n * roles: ['admin', 'editor', 'viewer'],\n * },\n * },\n * });\n * ```\n */\nexport function defineConfig<T extends BlimuConfigInput>(config: T): T {\n // Validate the config using Zod schema\n const validated = BlimuConfigSchema.parse(config);\n\n // Return the original config (with proper typing) after validation\n // This preserves the exact structure and types from the input\n return config as T & BlimuConfig;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAA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B,EAAE,SAAS;AAAA,EACxE,iBAAiB,aAAE,OAAO,aAAE,OAAO,GAAG,aAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS;AAAA,EACxE,oBAAoB,aACjB;AAAA,IACC,aAAE,OAAO;AAAA,IACT,aAAE,OAAO;AAAA,MACP,OAAO,aAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;AAAA,MAC7B,QAAQ,aAAE,KAAK,CAAC,WAAW,UAAU,UAAU,CAAC;AAAA,IAClD,CAAC;AAAA,EACH,EACC,SAAS;AACd,CAAC;AAKM,IAAM,oBAAoB,aAAE,OAAO;AAAA,EACxC,WAAW,aAAE,OAAO,aAAE,OAAO,EAAE,IAAI,CAAC,GAAG,wBAAwB;AAAA,EAC/D,cAAc,aAAE,OAAO,aAAE,OAAO,EAAE,IAAI,CAAC,GAAG,2BAA2B,EAAE,SAAS;AAAA,EAChF,UAAU,aAAE,OAAO,aAAE,OAAO,EAAE,IAAI,CAAC,GAAG,uBAAuB,EAAE,SAAS;AAAA,EACxE,OAAO,aAAE,OAAO,aAAE,OAAO,EAAE,IAAI,CAAC,GAAG,oBAAoB,EAAE,SAAS;AACpE,CAAC;;;ACjBM,SAAS,aAAyC,QAAc;AAErE,QAAM,YAAY,kBAAkB,MAAM,MAAM;AAIhD,SAAO;AACT;","names":[]}
#!/usr/bin/env node
"use strict";var M=Object.create;var E=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var J=(i,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of Q(e))!H.call(i,t)&&t!==n&&E(i,t,{get:()=>e[t],enumerable:!(o=N(e,t))||o.enumerable});return i};var d=(i,e,n)=>(n=i!=null?M(V(i)):{},J(e||!i||!i.__esModule?E(n,"default",{value:i,enumerable:!0}):n,i));var K=require("commander");var u=d(require("path")),F=d(require("fs")),p=d(require("@clack/prompts"));var l=d(require("fs")),h=d(require("path"));function x(i){let{configPath:e,outputPath:n,typesPackages:o=["@blimu/types","@blimu/backend"]}=i,t=[],s=o.join(" and ");t.push("/**"),t.push(` * Type Augmentation for ${s}`),t.push(" *"),t.push(` * This file augments the ${s} packages with union types`),t.push(" * specific to your environment configuration."),t.push(" *"),t.push(" * Types are automatically inferred from your blimu.config.ts file."),t.push(" * No regeneration needed when you update your config!"),t.push(" *"),t.push(" * Make sure to include this file in your tsconfig.json:"),t.push(" * {"),t.push(' * "include": ["blimu-types.d.ts"]'),t.push(" * }"),t.push(" */"),t.push("");let a=h.dirname(n),f=h.isAbsolute(e)?h.resolve(e):h.resolve(a,e),D=h.relative(a,f).replace(/\.(ts|mjs|js)$/,""),W=D.startsWith(".")?D:`./${D}`;t.push(`import type config from '${W}';`),t.push("import type {"),t.push(" InferResourceTypes,"),t.push(" InferEntitlementTypes,"),t.push(" InferPlanTypes,"),t.push(" InferLimitTypes,"),t.push(" InferUsageLimitTypes,"),t.push("} from 'blimu';"),t.push("");for(let z of o)t.push(`declare module '${z}' {`),t.push(" /**"),t.push(" * Resource types inferred from your Blimu configuration."),t.push(" */"),t.push(" type ResourceType = InferResourceTypes<typeof config>;"),t.push(""),t.push(" /**"),t.push(" * Entitlement types inferred from your Blimu configuration."),t.push(" */"),t.push(" type EntitlementType = InferEntitlementTypes<typeof config>;"),t.push(""),t.push(" /**"),t.push(" * Plan types inferred from your Blimu configuration."),t.push(" */"),t.push(" type PlanType = InferPlanTypes<typeof config>;"),t.push(""),t.push(" /**"),t.push(" * Limit types inferred from your Blimu configuration."),t.push(" */"),t.push(" type LimitType = InferLimitTypes<typeof config>;"),t.push(""),t.push(" /**"),t.push(" * Usage limit types inferred from your Blimu configuration."),t.push(" */"),t.push(" type UsageLimitType = InferUsageLimitTypes<typeof config>;"),t.push("}"),t.push("");l.existsSync(a)||l.mkdirSync(a,{recursive:!0}),l.writeFileSync(n,t.join(`
`),"utf-8")}var m=d(require("path")),g=d(require("fs"));function y(){let i=[m.join(process.cwd(),"blimu.config.ts"),m.join(process.cwd(),"blimu.config.mjs"),m.join(process.cwd(),"blimu.config.js"),m.join(process.cwd(),"blimu.config.json")];for(let e of i)if(g.existsSync(e))return e;return null}async function _(i){let e=m.isAbsolute(i)?i:m.resolve(process.cwd(),i);if(!g.existsSync(e))throw new Error(`Config file not found: ${e}`);if(m.extname(e).toLowerCase()===".json"){let t=g.readFileSync(e,"utf-8");return JSON.parse(t)}let o=await import(e);return o.default||o}function A(i,e){let o=m.relative(i,e).replace(/\.(ts|mjs|js)$/,"");return o.startsWith(".")?o:`./${o}`}function L(i){i.command("codegen").description("Generate type augmentation file from Blimu config").option("--config <path>","Path to Blimu config file (defaults to blimu.config.ts in project root)").option("--output <path>","Output path for generated type augmentation file (defaults to blimu-types.d.ts in project root)").action(async e=>{let n=p.spinner();try{let o=e.config||y();o||(p.cancel("No config file found. Please provide --config or ensure blimu.config.ts exists in project root."),process.exit(1));let t=u.isAbsolute(o)?o:u.resolve(process.cwd(),o);F.existsSync(t)||(p.cancel(`Config file not found: ${t}`),process.exit(1)),p.log.step(`Using config file: ${t}`);let s=e.output?u.isAbsolute(e.output)?e.output:u.resolve(process.cwd(),e.output):u.join(process.cwd(),"blimu-types.d.ts");p.log.step(`Output: ${s}`);let a=u.dirname(s),f=A(a,t);n.start("Generating type augmentation file with type inference..."),x({configPath:f,outputPath:s}),n.stop("\u26A1\uFE0F Successfully generated type augmentation file"),p.log.success(`Generated at: ${s}`),p.log.info("\u{1F4A1} Tip: Types are automatically inferred from your config."),p.log.info(" No regeneration needed when you update blimu.config.ts!")}catch(o){n.stop("\u274C Failed to generate type augmentation"),p.log.error(`Failed to generate type augmentation: ${o instanceof Error?o.message:String(o)}`),o instanceof Error&&o.stack&&p.log.error(o.stack),process.exit(1)}})}var c=d(require("@clack/prompts"));var T=require("@blimu/fetch");function j(i){let e=[...i?.authStrategies??[]];return i.bearer&&e.push({type:"bearer",token:i.bearer}),i.apiKey&&e.push({type:"apiKey",key:i.apiKey,location:"header",name:"X-API-KEY"}),e}var R=class{constructor(e){this.core=e}list(e,n){return this.core.request({method:"GET",path:`/v1/workspace/${encodeURIComponent(e)}/api-keys`,...n??{}})}create(e,n,o){return this.core.request({method:"POST",path:`/v1/workspace/${encodeURIComponent(e)}/api-keys`,body:n,...o??{}})}delete(e,n,o){return this.core.request({method:"DELETE",path:`/v1/workspace/${encodeURIComponent(e)}/api-keys/${encodeURIComponent(n)}`,...o??{}})}get(e,n,o){return this.core.request({method:"GET",path:`/v1/workspace/${encodeURIComponent(e)}/api-keys/${encodeURIComponent(n)}`,...o??{}})}reveal(e,n,o){return this.core.request({method:"POST",path:`/v1/workspace/${encodeURIComponent(e)}/api-keys/${encodeURIComponent(n)}/reveal`,...o??{}})}};var C=class{constructor(e){this.core=e}get(e,n,o){return this.core.request({method:"GET",path:`/v1/workspace/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/definitions`,...o??{}})}update(e,n,o,t){return this.core.request({method:"PUT",path:`/v1/workspace/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/definitions`,body:o,...t??{}})}validate(e,n,o,t){return this.core.request({method:"POST",path:`/v1/workspace/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/definitions/validate`,body:o,...t??{}})}};var v=class{constructor(e){this.core=e}getRecords(e,n,o){return this.core.request({method:"GET",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/dns/records`,...o??{}})}validate(e,n,o){return this.core.request({method:"POST",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/dns/validate`,...o??{}})}};var I=class{constructor(e){this.core=e}list(e,n,o){return this.core.request({method:"GET",path:`/v1/workspace/${encodeURIComponent(e)}/environments`,query:n,...o??{}})}create(e,n,o){return this.core.request({method:"POST",path:`/v1/workspace/${encodeURIComponent(e)}/environments`,body:n,...o??{}})}delete(e,n,o){return this.core.request({method:"DELETE",path:`/v1/workspace/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}`,...o??{}})}read(e,n,o){return this.core.request({method:"GET",path:`/v1/workspace/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}`,...o??{}})}update(e,n,o,t){return this.core.request({method:"PUT",path:`/v1/workspace/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}`,body:o,...t??{}})}getAuthConfig(e,n,o){return this.core.request({method:"GET",path:`/v1/workspace/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/auth-config`,...o??{}})}updateAuthConfig(e,n,o,t){return this.core.request({method:"PUT",path:`/v1/workspace/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/auth-config`,body:o,...t??{}})}};var S=class{constructor(e){this.core=e}getAccess(e){return this.core.request({method:"GET",path:"/v1/me/access",...e??{}})}};var k=class{constructor(e){this.core=e}list(e,n,o,t){return this.core.request({method:"GET",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/resources`,query:o,...t??{}})}create(e,n,o,t){return this.core.request({method:"POST",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/resources`,body:o,...t??{}})}delete(e,n,o,t,s){return this.core.request({method:"DELETE",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/resources/${encodeURIComponent(o)}/${encodeURIComponent(t)}`,...s??{}})}get(e,n,o,t,s){return this.core.request({method:"GET",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/resources/${encodeURIComponent(o)}/${encodeURIComponent(t)}`,...s??{}})}update(e,n,o,t,s,a){return this.core.request({method:"PUT",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/resources/${encodeURIComponent(o)}/${encodeURIComponent(t)}`,body:s,...a??{}})}listChildren(e,n,o,t,s,a){return this.core.request({method:"GET",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/resources/${encodeURIComponent(o)}/${encodeURIComponent(t)}/children`,query:s,...a??{}})}getResourceUsers(e,n,o,t,s,a){return this.core.request({method:"GET",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/resources/${encodeURIComponent(o)}/${encodeURIComponent(t)}/users`,query:s,...a??{}})}};var b=class{constructor(e){this.core=e}provision(e,n,o){return this.core.request({method:"POST",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/ssl/provision`,...o??{}})}getStatus(e,n,o){return this.core.request({method:"GET",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/ssl/status`,...o??{}})}};var U=class{constructor(e){this.core=e}list(e,n,o,t){return this.core.request({method:"GET",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/users`,query:o,...t??{}})}get(e,n,o,t){return this.core.request({method:"GET",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/users/${encodeURIComponent(o)}`,...t??{}})}getUserResources(e,n,o,t){return this.core.request({method:"GET",path:`/v1/workspaces/${encodeURIComponent(e)}/environments/${encodeURIComponent(n)}/users/${encodeURIComponent(o)}/resources`,...t??{}})}};var P=class{constructor(e){this.core=e}list(e,n,o){return this.core.request({method:"GET",path:`/v1/workspaces/${encodeURIComponent(e)}/members`,query:n,...o??{}})}remove(e,n,o){return this.core.request({method:"DELETE",path:`/v1/workspaces/${encodeURIComponent(e)}/members/${encodeURIComponent(n)}`,...o??{}})}updateRole(e,n,o,t){return this.core.request({method:"PUT",path:`/v1/workspaces/${encodeURIComponent(e)}/members/${encodeURIComponent(n)}/role`,body:o,...t??{}})}invite(e,n,o){return this.core.request({method:"POST",path:`/v1/workspaces/${encodeURIComponent(e)}/members/invite`,body:n,...o??{}})}};var $=class{constructor(e){this.core=e}list(e){return this.core.request({method:"GET",path:"/v1/workspaces",...e??{}})}create(e,n){return this.core.request({method:"POST",path:"/v1/workspaces",body:e,...n??{}})}getCurrent(e,n){return this.core.request({method:"GET",path:`/v1/workspaces/${encodeURIComponent(e)}`,...n??{}})}update(e,n,o){return this.core.request({method:"PUT",path:`/v1/workspaces/${encodeURIComponent(e)}`,body:n,...o??{}})}};var w=class{apiKeys;definitions;dns;environments;me;resources;ssl;users;workspaceMembers;workspaces;constructor(e){let n={...e??{}};delete n.apiKey,delete n.bearer;let o=j(e??{}),t=new T.FetchClient({...n,baseURL:e?.baseURL??"https://runtime.blimu.dev",...o.length>0?{authStrategies:o}:{}});this.apiKeys=new R(t),this.definitions=new C(t),this.dns=new v(t),this.environments=new I(t),this.me=new S(t),this.resources=new k(t),this.ssl=new b(t),this.users=new U(t),this.workspaceMembers=new P(t),this.workspaces=new $(t)}};var r=require("zod"),X=r.z.object({is_tenant:r.z.boolean().optional(),roles:r.z.array(r.z.string()).min(1,"At least one role must be defined"),parents:r.z.record(r.z.string(),r.z.object({required:r.z.boolean()})).optional(),roles_inheritance:r.z.record(r.z.string().min(1),r.z.array(r.z.string().regex(/^([a-z0-9_-]+->)*[a-z0-9_-]+$/i)).min(1)).optional()}),Y=r.z.object({roles:r.z.array(r.z.string()).min(1).optional(),plans:r.z.array(r.z.string()).optional(),limit:r.z.string().optional()}),Z=r.z.object({name:r.z.string(),summary:r.z.string().optional(),entitlements:r.z.array(r.z.string()).optional(),plans:r.z.array(r.z.string()).optional(),default_enabled:r.z.boolean().optional()}),ee=r.z.object({name:r.z.string().min(1,"Plan name is required"),summary:r.z.string().optional(),description:r.z.string().min(1,"Plan description is required").optional(),resource_limits:r.z.record(r.z.string(),r.z.number().int().min(0)).optional(),usage_based_limits:r.z.record(r.z.string(),r.z.object({value:r.z.number().int().min(0),period:r.z.enum(["monthly","yearly","lifetime"])})).optional()}),G=r.z.object({resources:r.z.record(r.z.string().min(1),X),entitlements:r.z.record(r.z.string().min(1),Y).optional(),features:r.z.record(r.z.string().min(1),Z).optional(),plans:r.z.record(r.z.string().min(1),ee).optional()});function B(i){i.command("push").description("Push definitions to Blimu API").option("--config <path>","Path to Blimu config file (defaults to blimu.config.ts in project root)").option("--workspace-id <id>","Workspace ID (required)").option("--environment-id <id>","Environment ID (required)").option("--api-key <key>","API key for authentication").option("--bearer <token>","Bearer token for authentication").option("--base-url <url>","Base URL for the API","https://runtime.blimu.dev").action(async e=>{let n=c.spinner();try{e.workspaceId||(c.cancel("Workspace ID is required. Use --workspace-id <id>"),process.exit(1)),e.environmentId||(c.cancel("Environment ID is required. Use --environment-id <id>"),process.exit(1)),!e.apiKey&&!e.bearer&&(c.cancel("Authentication required. Provide either --api-key <key> or --bearer <token>"),process.exit(1));let o=e.config||y();o||(c.cancel("No config file found. Please provide --config or ensure blimu.config.ts exists in project root."),process.exit(1)),c.log.step(`Loading config from: ${o}`),n.start("Loading and validating config file...");let t=await _(o);n.stop("\u2713 Config loaded"),n.start("Validating config structure...");let s=G.safeParse(t);s.success||(n.stop("\u274C Config validation failed"),c.log.error("Config validation errors:"),s.error.issues.forEach(q=>{c.log.error(` - ${q.path.join(".")}: ${q.message}`)}),process.exit(1));let a=s.data;n.stop("\u2713 Config validated"),n.start("Connecting to Blimu API...");let f=new w({baseURL:e.baseUrl,...e.apiKey?{apiKey:e.apiKey}:{},...e.bearer?{bearer:e.bearer}:{}});n.stop("\u2713 Connected"),n.start("Pushing definitions to Blimu..."),await f.definitions.update(e.workspaceId,e.environmentId,{resources:a.resources,...a.entitlements?{entitlements:a.entitlements}:{},...a.features?{features:a.features}:{},...a.plans?{plans:a.plans}:{}}),n.stop("\u2713 Definitions pushed successfully"),c.log.success(`Successfully pushed definitions to workspace ${e.workspaceId}, environment ${e.environmentId}`)}catch(o){n.stop("\u274C Failed to push definitions"),c.log.error(`Failed to push definitions: ${o instanceof Error?o.message:String(o)}`),o instanceof Error&&o.stack&&c.log.error(o.stack),process.exit(1)}})}var O=new K.Command;O.name("blimu").description("Blimu - Authorization as a Service CLI").version(process.env.npm_package_version??"0.0.0");L(O);B(O);O.parse();
//# sourceMappingURL=main.cjs.map
{"version":3,"sources":["../src/main.ts","../src/commands/codegen.ts","../src/utils/type-augmentation-generator.ts","../src/utils/config-loader.ts","../src/commands/push.ts","../src/api-sdk/client.ts","../src/api-sdk/auth-strategies.ts","../src/api-sdk/services/api_keys.ts","../src/api-sdk/services/definitions.ts","../src/api-sdk/services/dns.ts","../src/api-sdk/services/environments.ts","../src/api-sdk/services/me.ts","../src/api-sdk/services/resources.ts","../src/api-sdk/services/ssl.ts","../src/api-sdk/services/users.ts","../src/api-sdk/services/workspace_members.ts","../src/api-sdk/services/workspaces.ts","../src/config/schema.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { codegenCommand } from './commands/codegen';\nimport { pushCommand } from './commands/push';\n\nconst program = new Command();\n\nprogram\n .name('blimu')\n .description('Blimu - Authorization as a Service CLI')\n .version(process.env['npm_package_version'] ?? '0.0.0');\n\n// Register commands\ncodegenCommand(program);\npushCommand(program);\n\n// Parse arguments\nprogram.parse();\n","import { Command } from 'commander';\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport * as clack from '@clack/prompts';\nimport { generateTypeAugmentationFile } from '../utils/type-augmentation-generator';\nimport {\n findDefaultConfig,\n getRelativeImportPath,\n} from '../utils/config-loader';\n\n/**\n * Register the codegen command\n */\nexport function codegenCommand(program: Command): void {\n program\n .command('codegen')\n .description('Generate type augmentation file from Blimu config')\n .option(\n '--config <path>',\n 'Path to Blimu config file (defaults to blimu.config.ts in project root)'\n )\n .option(\n '--output <path>',\n 'Output path for generated type augmentation file (defaults to blimu-types.d.ts in project root)'\n )\n .action(async (options) => {\n const spinner = clack.spinner();\n\n try {\n // Find config file\n const configPath = options.config || findDefaultConfig();\n if (!configPath) {\n clack.cancel(\n 'No config file found. Please provide --config or ensure blimu.config.ts exists in project root.'\n );\n process.exit(1);\n }\n\n // Resolve to absolute path\n const absoluteConfigPath = path.isAbsolute(configPath)\n ? configPath\n : path.resolve(process.cwd(), configPath);\n\n if (!fs.existsSync(absoluteConfigPath)) {\n clack.cancel(`Config file not found: ${absoluteConfigPath}`);\n process.exit(1);\n }\n\n clack.log.step(`Using config file: ${absoluteConfigPath}`);\n\n // Determine output path\n const outputPath = options.output\n ? path.isAbsolute(options.output)\n ? options.output\n : path.resolve(process.cwd(), options.output)\n : path.join(process.cwd(), 'blimu-types.d.ts');\n\n clack.log.step(`Output: ${outputPath}`);\n\n // Calculate relative path from output to config for import statement\n const outputDir = path.dirname(outputPath);\n const relativeConfigPath = getRelativeImportPath(\n outputDir,\n absoluteConfigPath\n );\n\n // Generate type augmentation file\n spinner.start(\n 'Generating type augmentation file with type inference...'\n );\n\n generateTypeAugmentationFile({\n configPath: relativeConfigPath,\n outputPath,\n // Always augment both @blimu/types and @blimu/backend\n // This is an internal implementation detail, not user-configurable\n });\n\n spinner.stop('⚡️ Successfully generated type augmentation file');\n\n clack.log.success(`Generated at: ${outputPath}`);\n clack.log.info(\n '💡 Tip: Types are automatically inferred from your config.'\n );\n clack.log.info(\n ' No regeneration needed when you update blimu.config.ts!'\n );\n } catch (error) {\n spinner.stop('❌ Failed to generate type augmentation');\n clack.log.error(\n `Failed to generate type augmentation: ${error instanceof Error ? error.message : String(error)}`\n );\n if (error instanceof Error && error.stack) {\n clack.log.error(error.stack);\n }\n process.exit(1);\n }\n });\n}\n","import * as fs from 'fs';\nimport * as path from 'path';\n\n/**\n * Options for generating type augmentation file\n */\nexport interface GenerateTypeAugmentationOptions {\n /** Path to the config file (relative to output directory or absolute) */\n configPath: string;\n /** Output path for the generated type augmentation file */\n outputPath: string;\n /** Types package names to augment (defaults to ['@blimu/types', '@blimu/backend']) */\n typesPackages?: string[];\n}\n\n/**\n * Generate type augmentation file for @blimu/types and @blimu/backend using type inference utilities.\n *\n * This generates a .d.ts file that imports the config and uses type inference\n * utilities to automatically extract types from the config structure.\n *\n * @param options - Generation options\n */\nexport function generateTypeAugmentationFile(options: GenerateTypeAugmentationOptions): void {\n const { configPath, outputPath, typesPackages = ['@blimu/types', '@blimu/backend'] } = options;\n\n const lines: string[] = [];\n\n // Header\n const packageNames = typesPackages.join(' and ');\n lines.push('/**');\n lines.push(` * Type Augmentation for ${packageNames}`);\n lines.push(' *');\n lines.push(` * This file augments the ${packageNames} packages with union types`);\n lines.push(' * specific to your environment configuration.');\n lines.push(' *');\n lines.push(' * Types are automatically inferred from your blimu.config.ts file.');\n lines.push(' * No regeneration needed when you update your config!');\n lines.push(' *');\n lines.push(' * Make sure to include this file in your tsconfig.json:');\n lines.push(' * {');\n lines.push(' * \"include\": [\"blimu-types.d.ts\"]');\n lines.push(' * }');\n lines.push(' */');\n lines.push('');\n\n // Calculate output directory and relative import path\n const outputDir = path.dirname(outputPath);\n const resolvedConfigPath = path.isAbsolute(configPath)\n ? path.resolve(configPath)\n : path.resolve(outputDir, configPath);\n const relativeConfigPath = path.relative(outputDir, resolvedConfigPath);\n // Remove .ts/.mjs/.js extension and ensure it starts with ./\n const importPath = relativeConfigPath.replace(/\\.(ts|mjs|js)$/, '');\n const finalImportPath = importPath.startsWith('.') ? importPath : `./${importPath}`;\n\n // Import config and type utilities\n lines.push(`import type config from '${finalImportPath}';`);\n lines.push('import type {');\n lines.push(' InferResourceTypes,');\n lines.push(' InferEntitlementTypes,');\n lines.push(' InferPlanTypes,');\n lines.push(' InferLimitTypes,');\n lines.push(' InferUsageLimitTypes,');\n lines.push(\"} from 'blimu';\");\n lines.push('');\n\n // Generate module augmentation for each package\n for (const typesPackage of typesPackages) {\n lines.push(`declare module '${typesPackage}' {`);\n lines.push(' /**');\n lines.push(' * Resource types inferred from your Blimu configuration.');\n lines.push(' */');\n lines.push(' type ResourceType = InferResourceTypes<typeof config>;');\n lines.push('');\n lines.push(' /**');\n lines.push(' * Entitlement types inferred from your Blimu configuration.');\n lines.push(' */');\n lines.push(' type EntitlementType = InferEntitlementTypes<typeof config>;');\n lines.push('');\n lines.push(' /**');\n lines.push(' * Plan types inferred from your Blimu configuration.');\n lines.push(' */');\n lines.push(' type PlanType = InferPlanTypes<typeof config>;');\n lines.push('');\n lines.push(' /**');\n lines.push(' * Limit types inferred from your Blimu configuration.');\n lines.push(' */');\n lines.push(' type LimitType = InferLimitTypes<typeof config>;');\n lines.push('');\n lines.push(' /**');\n lines.push(' * Usage limit types inferred from your Blimu configuration.');\n lines.push(' */');\n lines.push(' type UsageLimitType = InferUsageLimitTypes<typeof config>;');\n lines.push('}');\n lines.push('');\n }\n\n // Ensure output directory exists\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n // Write file\n fs.writeFileSync(outputPath, lines.join('\\n'), 'utf-8');\n}\n","import * as path from 'path';\nimport * as fs from 'fs';\n\n/**\n * Find default config file in project root\n */\nexport function findDefaultConfig(): string | null {\n const possiblePaths = [\n path.join(process.cwd(), 'blimu.config.ts'),\n path.join(process.cwd(), 'blimu.config.mjs'),\n path.join(process.cwd(), 'blimu.config.js'),\n path.join(process.cwd(), 'blimu.config.json'),\n ];\n\n for (const configPath of possiblePaths) {\n if (fs.existsSync(configPath)) {\n return configPath;\n }\n }\n\n return null;\n}\n\n/**\n * Load and parse config file\n */\nexport async function loadConfig(configPath: string): Promise<unknown> {\n const absolutePath = path.isAbsolute(configPath)\n ? configPath\n : path.resolve(process.cwd(), configPath);\n\n if (!fs.existsSync(absolutePath)) {\n throw new Error(`Config file not found: ${absolutePath}`);\n }\n\n const ext = path.extname(absolutePath).toLowerCase();\n\n if (ext === '.json') {\n const content = fs.readFileSync(absolutePath, 'utf-8');\n return JSON.parse(content);\n }\n\n // For .ts, .mjs, .js files, use dynamic import\n const module = await import(absolutePath);\n return module.default || module;\n}\n\n/**\n * Get relative import path from output directory to config file\n * Handles both relative paths and ensures proper extension handling\n */\nexport function getRelativeImportPath(fromDir: string, toFile: string): string {\n const relative = path.relative(fromDir, toFile);\n // Remove .ts/.mjs/.js extension for import\n const withoutExt = relative.replace(/\\.(ts|mjs|js)$/, '');\n // Ensure it starts with ./ or ../\n if (!withoutExt.startsWith('.')) {\n return `./${withoutExt}`;\n }\n return withoutExt;\n}\n","import { Command } from 'commander';\nimport * as clack from '@clack/prompts';\nimport { BlimuCli } from '../api-sdk/client';\nimport { BlimuConfigSchema } from '../config/schema';\nimport { findDefaultConfig, loadConfig } from '../utils/config-loader';\n\n/**\n * Register the push command\n */\nexport function pushCommand(program: Command): void {\n program\n .command('push')\n .description('Push definitions to Blimu API')\n .option(\n '--config <path>',\n 'Path to Blimu config file (defaults to blimu.config.ts in project root)'\n )\n .option('--workspace-id <id>', 'Workspace ID (required)')\n .option('--environment-id <id>', 'Environment ID (required)')\n .option('--api-key <key>', 'API key for authentication')\n .option('--bearer <token>', 'Bearer token for authentication')\n .option('--base-url <url>', 'Base URL for the API', 'https://runtime.blimu.dev')\n .action(async (options) => {\n const spinner = clack.spinner();\n\n try {\n // Validate required options\n if (!options.workspaceId) {\n clack.cancel('Workspace ID is required. Use --workspace-id <id>');\n process.exit(1);\n }\n\n if (!options.environmentId) {\n clack.cancel('Environment ID is required. Use --environment-id <id>');\n process.exit(1);\n }\n\n // Check authentication\n if (!options.apiKey && !options.bearer) {\n clack.cancel(\n 'Authentication required. Provide either --api-key <key> or --bearer <token>'\n );\n process.exit(1);\n }\n\n // Find and load config file\n const configPath = options.config || findDefaultConfig();\n if (!configPath) {\n clack.cancel(\n 'No config file found. Please provide --config or ensure blimu.config.ts exists in project root.'\n );\n process.exit(1);\n }\n\n clack.log.step(`Loading config from: ${configPath}`);\n\n spinner.start('Loading and validating config file...');\n const rawConfig = await loadConfig(configPath);\n spinner.stop('✓ Config loaded');\n\n // Validate config structure\n spinner.start('Validating config structure...');\n const validationResult = BlimuConfigSchema.safeParse(rawConfig);\n if (!validationResult.success) {\n spinner.stop('❌ Config validation failed');\n clack.log.error('Config validation errors:');\n validationResult.error.issues.forEach((err) => {\n clack.log.error(` - ${err.path.join('.')}: ${err.message}`);\n });\n process.exit(1);\n }\n const config = validationResult.data;\n spinner.stop('✓ Config validated');\n\n // Create API client\n spinner.start('Connecting to Blimu API...');\n const client = new BlimuCli({\n baseURL: options.baseUrl,\n ...(options.apiKey ? { apiKey: options.apiKey } : {}),\n ...(options.bearer ? { bearer: options.bearer } : {}),\n });\n spinner.stop('✓ Connected');\n\n // Push definitions\n spinner.start('Pushing definitions to Blimu...');\n await client.definitions.update(options.workspaceId, options.environmentId, {\n resources: config.resources,\n ...(config.entitlements ? { entitlements: config.entitlements } : {}),\n ...(config.features ? { features: config.features } : {}),\n ...(config.plans ? { plans: config.plans } : {}),\n });\n spinner.stop('✓ Definitions pushed successfully');\n\n clack.log.success(\n `Successfully pushed definitions to workspace ${options.workspaceId}, environment ${options.environmentId}`\n );\n } catch (error) {\n spinner.stop('❌ Failed to push definitions');\n clack.log.error(\n `Failed to push definitions: ${error instanceof Error ? error.message : String(error)}`\n );\n if (error instanceof Error && error.stack) {\n clack.log.error(error.stack);\n }\n process.exit(1);\n }\n });\n}\n","import { FetchClient, FetchError } from '@blimu/fetch';\nimport {\n type FetchClientConfig,\n type BearerAuthStrategy,\n type ApiKeyAuthStrategy,\n} from '@blimu/fetch';\nimport { buildAuthStrategies } from './auth-strategies';\nimport { ApiKeysService } from './services/api_keys';\nimport { DefinitionsService } from './services/definitions';\nimport { DnsService } from './services/dns';\nimport { EnvironmentsService } from './services/environments';\nimport { MeService } from './services/me';\nimport { ResourcesService } from './services/resources';\nimport { SslService } from './services/ssl';\nimport { UsersService } from './services/users';\nimport { WorkspaceMembersService } from './services/workspace_members';\nimport { WorkspacesService } from './services/workspaces';\n\nexport type ClientOption = FetchClientConfig & {\n apiKey?: ApiKeyAuthStrategy['key'];\n bearer?: BearerAuthStrategy['token'];\n};\n\nexport class BlimuCli {\n readonly apiKeys: ApiKeysService;\n readonly definitions: DefinitionsService;\n readonly dns: DnsService;\n readonly environments: EnvironmentsService;\n readonly me: MeService;\n readonly resources: ResourcesService;\n readonly ssl: SslService;\n readonly users: UsersService;\n readonly workspaceMembers: WorkspaceMembersService;\n readonly workspaces: WorkspacesService;\n\n constructor(options?: ClientOption) {\n const restCfg = { ...(options ?? {}) };\n delete restCfg.apiKey;\n delete restCfg.bearer;\n\n const authStrategies = buildAuthStrategies(options ?? {});\n\n const core = new FetchClient({\n ...restCfg,\n baseURL: options?.baseURL ?? 'https://runtime.blimu.dev',\n ...(authStrategies.length > 0 ? { authStrategies } : {}),\n });\n\n this.apiKeys = new ApiKeysService(core);\n this.definitions = new DefinitionsService(core);\n this.dns = new DnsService(core);\n this.environments = new EnvironmentsService(core);\n this.me = new MeService(core);\n this.resources = new ResourcesService(core);\n this.ssl = new SslService(core);\n this.users = new UsersService(core);\n this.workspaceMembers = new WorkspaceMembersService(core);\n this.workspaces = new WorkspacesService(core);\n }\n}\n\n// Re-export FetchError for backward compatibility\nexport { FetchError };\nexport const BlimuCliError = FetchError;\n","import type { AuthStrategy } from '@blimu/fetch';\nimport type { ClientOption } from './client';\n\nexport function buildAuthStrategies(cfg: ClientOption): AuthStrategy[] {\n const authStrategies: AuthStrategy[] = [...(cfg?.authStrategies ?? [])];\n\n if (cfg.bearer) {\n authStrategies.push({\n type: 'bearer',\n token: cfg.bearer,\n });\n }\n if (cfg.apiKey) {\n authStrategies.push({\n type: 'apiKey',\n key: cfg.apiKey,\n location: 'header',\n name: 'X-API-KEY',\n });\n }\n return authStrategies;\n}\n","import { FetchClient } from '@blimu/fetch';\nimport * as Schema from '../schema';\n\nexport class ApiKeysService {\n constructor(private core: FetchClient) {}\n\n /**\n * GET /v1/workspace/{workspaceId}/api-keys*\n * @returns List API keys*/\n list(\n workspaceId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.ApiKeyListDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/api-keys`,\n ...(init ?? {}),\n });\n }\n\n /**\n * POST /v1/workspace/{workspaceId}/api-keys*\n * @returns Create API key*/\n create(\n workspaceId: string,\n body: Schema.ApiKeyCreateDto,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.ApiKeyDto_Output> {\n return this.core.request({\n method: 'POST',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/api-keys`,\n body,\n ...(init ?? {}),\n });\n }\n\n /**\n * DELETE /v1/workspace/{workspaceId}/api-keys/{id}*\n * @returns Delete API key*/\n delete(\n workspaceId: string,\n id: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<unknown> {\n return this.core.request({\n method: 'DELETE',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/api-keys/${encodeURIComponent(id)}`,\n ...(init ?? {}),\n });\n }\n\n /**\n * GET /v1/workspace/{workspaceId}/api-keys/{id}*\n * @returns Get API key*/\n get(\n workspaceId: string,\n id: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.ApiKeyDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/api-keys/${encodeURIComponent(id)}`,\n ...(init ?? {}),\n });\n }\n\n /**\n * POST /v1/workspace/{workspaceId}/api-keys/{id}/reveal*\n * @returns Reveal API key*/\n reveal(\n workspaceId: string,\n id: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.ApiKeyRevealDto_Output> {\n return this.core.request({\n method: 'POST',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/api-keys/${encodeURIComponent(id)}/reveal`,\n ...(init ?? {}),\n });\n }\n}\n","import { FetchClient } from '@blimu/fetch';\nimport * as Schema from '../schema';\n\nexport class DefinitionsService {\n constructor(private core: FetchClient) {}\n\n /**\n * GET /v1/workspace/{workspaceId}/environments/{environmentId}/definitions*\n * @summary Get environment definitions*/\n get(\n workspaceId: string,\n environmentId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.DefinitionDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/definitions`,\n ...(init ?? {}),\n });\n }\n\n /**\n * PUT /v1/workspace/{workspaceId}/environments/{environmentId}/definitions*\n * @summary Update environment definitions*/\n update(\n workspaceId: string,\n environmentId: string,\n body: Schema.DefinitionUpdateDto,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<unknown> {\n return this.core.request({\n method: 'PUT',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/definitions`,\n body,\n ...(init ?? {}),\n });\n }\n\n /**\n * POST /v1/workspace/{workspaceId}/environments/{environmentId}/definitions/validate*\n * @summary Validate Blimu configuration*\n * @description Validates a complete Blimu configuration including resources, entitlements, features, and plans. Returns validation errors and optionally generates an OpenAPI spec if valid.*/\n validate(\n workspaceId: string,\n environmentId: string,\n body: Schema.DefinitionValidateRequestDto,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.DefinitionValidateResponseDto_Output> {\n return this.core.request({\n method: 'POST',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/definitions/validate`,\n body,\n ...(init ?? {}),\n });\n }\n}\n","import { FetchClient } from '@blimu/fetch';\nimport * as Schema from '../schema';\n\nexport class DnsService {\n constructor(private core: FetchClient) {}\n\n /**\n * GET /v1/workspaces/{workspaceId}/environments/{environmentId}/dns/records*\n * @summary Get DNS records for an environment*/\n getRecords(\n workspaceId: string,\n environmentId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.DnsRecordListDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/dns/records`,\n ...(init ?? {}),\n });\n }\n\n /**\n * POST /v1/workspaces/{workspaceId}/environments/{environmentId}/dns/validate*\n * @summary Validate DNS records for an environment*/\n validate(\n workspaceId: string,\n environmentId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.DnsRecordListDto_Output> {\n return this.core.request({\n method: 'POST',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/dns/validate`,\n ...(init ?? {}),\n });\n }\n}\n","import { FetchClient } from '@blimu/fetch';\nimport * as Schema from '../schema';\n\nexport class EnvironmentsService {\n constructor(private core: FetchClient) {}\n\n /**\n * GET /v1/workspace/{workspaceId}/environments*\n * @summary List environments*/\n list(\n workspaceId: string,\n query?: Schema.EnvironmentsListQuery,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.EnvironmentListDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/environments`,\n query,\n ...(init ?? {}),\n });\n }\n\n /**\n * POST /v1/workspace/{workspaceId}/environments*\n * @summary Create a new environment*/\n create(\n workspaceId: string,\n body: Schema.EnvironmentCreateDto,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.EnvironmentDto_Output> {\n return this.core.request({\n method: 'POST',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/environments`,\n body,\n ...(init ?? {}),\n });\n }\n\n /**\n * DELETE /v1/workspace/{workspaceId}/environments/{environmentId}*\n * @summary Delete an environment*/\n delete(\n workspaceId: string,\n environmentId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<unknown> {\n return this.core.request({\n method: 'DELETE',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}`,\n ...(init ?? {}),\n });\n }\n\n /**\n * GET /v1/workspace/{workspaceId}/environments/{environmentId}*\n * @summary Read an environment by ID*/\n read(\n workspaceId: string,\n environmentId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.EnvironmentWithDefinitionDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}`,\n ...(init ?? {}),\n });\n }\n\n /**\n * PUT /v1/workspace/{workspaceId}/environments/{environmentId}*\n * @summary Update an environment*/\n update(\n workspaceId: string,\n environmentId: string,\n body: Schema.EnvironmentUpdateDto,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.EnvironmentDto_Output> {\n return this.core.request({\n method: 'PUT',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}`,\n body,\n ...(init ?? {}),\n });\n }\n\n /**\n * GET /v1/workspace/{workspaceId}/environments/{environmentId}/auth-config*\n * @summary Get authentication configuration for environment*/\n getAuthConfig(\n workspaceId: string,\n environmentId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.EnvironmentAuthConfigDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/auth-config`,\n ...(init ?? {}),\n });\n }\n\n /**\n * PUT /v1/workspace/{workspaceId}/environments/{environmentId}/auth-config*\n * @summary Update authentication configuration for environment*/\n updateAuthConfig(\n workspaceId: string,\n environmentId: string,\n body: Schema.EnvironmentAuthConfigUpdateDto,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.EnvironmentAuthConfigDto_Output> {\n return this.core.request({\n method: 'PUT',\n path: `/v1/workspace/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/auth-config`,\n body,\n ...(init ?? {}),\n });\n }\n}\n","import { FetchClient } from '@blimu/fetch';\nimport * as Schema from '../schema';\n\nexport class MeService {\n constructor(private core: FetchClient) {}\n\n /**\n * GET /v1/me/access*\n * @summary Get active resources for current user*/\n getAccess(init?: Omit<RequestInit, 'method' | 'body'>): Promise<Schema.UserAccessDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/me/access`,\n ...(init ?? {}),\n });\n }\n}\n","import { FetchClient } from '@blimu/fetch';\nimport * as Schema from '../schema';\n\nexport class ResourcesService {\n constructor(private core: FetchClient) {}\n\n /**\n * GET /v1/workspaces/{workspaceId}/environments/{environmentId}/resources*\n * @summary List resources for an environment*/\n list(\n workspaceId: string,\n environmentId: string,\n query?: Schema.ResourcesListQuery,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.ResourceListResponseDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/resources`,\n query,\n ...(init ?? {}),\n });\n }\n\n /**\n * POST /v1/workspaces/{workspaceId}/environments/{environmentId}/resources*\n * @summary Create a new resource*/\n create(\n workspaceId: string,\n environmentId: string,\n body: Schema.ResourceCreateDto,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.ResourceDto_Output> {\n return this.core.request({\n method: 'POST',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/resources`,\n body,\n ...(init ?? {}),\n });\n }\n\n /**\n * DELETE /v1/workspaces/{workspaceId}/environments/{environmentId}/resources/{resourceType}/{resourceId}*\n * @summary Delete a resource*/\n delete(\n workspaceId: string,\n environmentId: string,\n resourceType: string,\n resourceId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<unknown> {\n return this.core.request({\n method: 'DELETE',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,\n ...(init ?? {}),\n });\n }\n\n /**\n * GET /v1/workspaces/{workspaceId}/environments/{environmentId}/resources/{resourceType}/{resourceId}*\n * @summary Get a specific resource*/\n get(\n workspaceId: string,\n environmentId: string,\n resourceType: string,\n resourceId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.ResourceDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,\n ...(init ?? {}),\n });\n }\n\n /**\n * PUT /v1/workspaces/{workspaceId}/environments/{environmentId}/resources/{resourceType}/{resourceId}*\n * @summary Update a resource*/\n update(\n workspaceId: string,\n environmentId: string,\n resourceType: string,\n resourceId: string,\n body: Schema.ResourceUpdateDto,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.ResourceDto_Output> {\n return this.core.request({\n method: 'PUT',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}`,\n body,\n ...(init ?? {}),\n });\n }\n\n /**\n * GET /v1/workspaces/{workspaceId}/environments/{environmentId}/resources/{resourceType}/{resourceId}/children*\n * @summary List children resources for a specific resource*/\n listChildren(\n workspaceId: string,\n environmentId: string,\n resourceType: string,\n resourceId: string,\n query?: Schema.ResourcesListChildrenQuery,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.ResourceListResponseDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/children`,\n query,\n ...(init ?? {}),\n });\n }\n\n /**\n * GET /v1/workspaces/{workspaceId}/environments/{environmentId}/resources/{resourceType}/{resourceId}/users*\n * @summary Get users with roles on a resource*/\n getResourceUsers(\n workspaceId: string,\n environmentId: string,\n resourceType: string,\n resourceId: string,\n query?: Schema.ResourcesGetResourceUsersQuery,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.ResourceUserListResponseDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/resources/${encodeURIComponent(resourceType)}/${encodeURIComponent(resourceId)}/users`,\n query,\n ...(init ?? {}),\n });\n }\n}\n","import { FetchClient } from '@blimu/fetch';\nimport * as Schema from '../schema';\n\nexport class SslService {\n constructor(private core: FetchClient) {}\n\n /**\n * POST /v1/workspaces/{workspaceId}/environments/{environmentId}/ssl/provision*\n * @summary Provision custom domains and SSL certificates for an environment*/\n provision(\n workspaceId: string,\n environmentId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.CustomHostnameListDto_Output> {\n return this.core.request({\n method: 'POST',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/ssl/provision`,\n ...(init ?? {}),\n });\n }\n\n /**\n * GET /v1/workspaces/{workspaceId}/environments/{environmentId}/ssl/status*\n * @summary Get SSL certificate status for an environment*/\n getStatus(\n workspaceId: string,\n environmentId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.SslStatusResponseDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/ssl/status`,\n ...(init ?? {}),\n });\n }\n}\n","import { FetchClient } from '@blimu/fetch';\nimport * as Schema from '../schema';\n\nexport class UsersService {\n constructor(private core: FetchClient) {}\n\n /**\n * GET /v1/workspaces/{workspaceId}/environments/{environmentId}/users*\n * @summary List users for an environment*/\n list(\n workspaceId: string,\n environmentId: string,\n query?: Schema.UsersListQuery,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.UserListResponseDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/users`,\n query,\n ...(init ?? {}),\n });\n }\n\n /**\n * GET /v1/workspaces/{workspaceId}/environments/{environmentId}/users/{userId}*\n * @summary Get user details by ID*/\n get(\n workspaceId: string,\n environmentId: string,\n userId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.UserDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/users/${encodeURIComponent(userId)}`,\n ...(init ?? {}),\n });\n }\n\n /**\n * GET /v1/workspaces/{workspaceId}/environments/{environmentId}/users/{userId}/resources*\n * @summary Get user resource relationships*/\n getUserResources(\n workspaceId: string,\n environmentId: string,\n userId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.UserResourceDto_Output[]> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/environments/${encodeURIComponent(environmentId)}/users/${encodeURIComponent(userId)}/resources`,\n ...(init ?? {}),\n });\n }\n}\n","import { FetchClient } from '@blimu/fetch';\nimport * as Schema from '../schema';\n\nexport class WorkspaceMembersService {\n constructor(private core: FetchClient) {}\n\n /**\n * GET /v1/workspaces/{workspaceId}/members*\n * @summary List workspace members with pagination and search*/\n list(\n workspaceId: string,\n query?: Schema.WorkspaceMembersListQuery,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.MemberListResponseDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/members`,\n query,\n ...(init ?? {}),\n });\n }\n\n /**\n * DELETE /v1/workspaces/{workspaceId}/members/{userId}*\n * @summary Remove member from workspace*/\n remove(\n workspaceId: string,\n userId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<unknown> {\n return this.core.request({\n method: 'DELETE',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/members/${encodeURIComponent(userId)}`,\n ...(init ?? {}),\n });\n }\n\n /**\n * PUT /v1/workspaces/{workspaceId}/members/{userId}/role*\n * @summary Update member role*/\n updateRole(\n workspaceId: string,\n userId: string,\n body: Schema.UpdateRoleDto,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<unknown> {\n return this.core.request({\n method: 'PUT',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/members/${encodeURIComponent(userId)}/role`,\n body,\n ...(init ?? {}),\n });\n }\n\n /**\n * POST /v1/workspaces/{workspaceId}/members/invite*\n * @summary Invite a member to the workspace*/\n invite(\n workspaceId: string,\n body: Schema.InviteMemberDto,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.InviteMemberResponseDto_Output> {\n return this.core.request({\n method: 'POST',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}/members/invite`,\n body,\n ...(init ?? {}),\n });\n }\n}\n","import { FetchClient } from '@blimu/fetch';\nimport * as Schema from '../schema';\n\nexport class WorkspacesService {\n constructor(private core: FetchClient) {}\n\n /**\n * GET /v1/workspaces*\n * @summary Get all workspaces*/\n list(init?: Omit<RequestInit, 'method' | 'body'>): Promise<Schema.WorkspaceListDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspaces`,\n ...(init ?? {}),\n });\n }\n\n /**\n * POST /v1/workspaces*\n * @summary Create a new workspace*/\n create(\n body: Schema.WorkspaceCreateDto,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.WorkspaceCreateResponseDto_Output> {\n return this.core.request({\n method: 'POST',\n path: `/v1/workspaces`,\n body,\n ...(init ?? {}),\n });\n }\n\n /**\n * GET /v1/workspaces/{workspaceId}*\n * @summary Get current authenticated workspace*/\n getCurrent(\n workspaceId: string,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.WorkspaceDto_Output> {\n return this.core.request({\n method: 'GET',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}`,\n ...(init ?? {}),\n });\n }\n\n /**\n * PUT /v1/workspaces/{workspaceId}*\n * @summary Update authenticated workspace*/\n update(\n workspaceId: string,\n body: Schema.WorkspaceUpdateDto,\n init?: Omit<RequestInit, 'method' | 'body'>\n ): Promise<Schema.WorkspaceDto_Output> {\n return this.core.request({\n method: 'PUT',\n path: `/v1/workspaces/${encodeURIComponent(workspaceId)}`,\n body,\n ...(init ?? {}),\n });\n }\n}\n","import { z } from 'zod';\n\n/**\n * Zod schema for resource definition\n */\nexport const ResourceDefinitionSchema = z.object({\n is_tenant: z.boolean().optional(),\n roles: z.array(z.string()).min(1, 'At least one role must be defined'),\n parents: z.record(z.string(), z.object({ required: z.boolean() })).optional(),\n roles_inheritance: z\n .record(\n z.string().min(1), // local role\n // Allow tokens containing letters, numbers, underscores or dashes\n // Examples: parent->editor, organization->admin, workspace_v2->viewer\n z.array(z.string().regex(/^([a-z0-9_-]+->)*[a-z0-9_-]+$/i)).min(1),\n )\n .optional(),\n});\n\n/**\n * Zod schema for entitlement definition\n */\nexport const EntitlementDefinitionSchema = z.object({\n roles: z.array(z.string()).min(1).optional(),\n plans: z.array(z.string()).optional(),\n limit: z.string().optional(), // Reference to usage-based limit\n});\n\n/**\n * Zod schema for feature definition\n */\nexport const FeatureDefinitionSchema = z.object({\n name: z.string(),\n summary: z.string().optional(),\n entitlements: z.array(z.string()).optional(),\n plans: z.array(z.string()).optional(),\n default_enabled: z.boolean().optional(),\n});\n\n/**\n * Zod schema for plan definition\n */\nexport const PlanDefinitionSchema = z.object({\n name: z.string().min(1, 'Plan name is required'),\n summary: z.string().optional(),\n description: z.string().min(1, 'Plan description is required').optional(),\n resource_limits: z.record(z.string(), z.number().int().min(0)).optional(),\n usage_based_limits: z\n .record(\n z.string(),\n z.object({\n value: z.number().int().min(0),\n period: z.enum(['monthly', 'yearly', 'lifetime']),\n }),\n )\n .optional(),\n});\n\n/**\n * Zod schema for complete Blimu configuration\n */\nexport const BlimuConfigSchema = z.object({\n resources: z.record(z.string().min(1), ResourceDefinitionSchema),\n entitlements: z.record(z.string().min(1), EntitlementDefinitionSchema).optional(),\n features: z.record(z.string().min(1), FeatureDefinitionSchema).optional(),\n plans: z.record(z.string().min(1), PlanDefinitionSchema).optional(),\n});\n\n/**\n * Type inference from schemas\n */\nexport type ResourceDefinition = z.infer<typeof ResourceDefinitionSchema>;\nexport type EntitlementDefinition = z.infer<typeof EntitlementDefinitionSchema>;\nexport type FeatureDefinition = z.infer<typeof FeatureDefinitionSchema>;\nexport type PlanDefinition = z.infer<typeof PlanDefinitionSchema>;\nexport type BlimuConfig = z.infer<typeof BlimuConfigSchema>;\n"],"mappings":";wdAAA,IAAAA,EAAwB,qBCCxB,IAAAC,EAAsB,mBACtBC,EAAoB,iBACpBC,EAA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","lines","packageNames","outputDir","resolvedConfigPath","importPath","finalImportPath","typesPackage","path","fs","findDefaultConfig","possiblePaths","configPath","loadConfig","absolutePath","content","module","getRelativeImportPath","fromDir","toFile","withoutExt","codegenCommand","program","options","spinner","configPath","findDefaultConfig","absoluteConfigPath","outputPath","outputDir","relativeConfigPath","getRelativeImportPath","generateTypeAugmentationFile","error","clack","import_fetch","buildAuthStrategies","cfg","authStrategies","ApiKeysService","core","workspaceId","init","body","id","DefinitionsService","core","workspaceId","environmentId","init","body","DnsService","core","workspaceId","environmentId","init","EnvironmentsService","core","workspaceId","query","init","body","environmentId","MeService","core","init","ResourcesService","core","workspaceId","environmentId","query","init","body","resourceType","resourceId","SslService","core","workspaceId","environmentId","init","UsersService","core","workspaceId","environmentId","query","init","userId","WorkspaceMembersService","core","workspaceId","query","init","userId","body","WorkspacesService","core","init","body","workspaceId","BlimuCli","options","restCfg","authStrategies","buildAuthStrategies","core","ApiKeysService","DefinitionsService","DnsService","EnvironmentsService","MeService","ResourcesService","SslService","UsersService","WorkspaceMembersService","WorkspacesService","import_zod","ResourceDefinitionSchema","EntitlementDefinitionSchema","FeatureDefinitionSchema","PlanDefinitionSchema","BlimuConfigSchema","pushCommand","program","options","spinner","configPath","findDefaultConfig","rawConfig","loadConfig","validationResult","BlimuConfigSchema","err","config","client","BlimuCli","error","program","codegenCommand","pushCommand"]}
+17
-4
{
"name": "blimu",
"version": "1.1.1",
"version": "1.1.4",
"description": "Blimu - Authorization as a Service CLI",
"main": "dist/index.js",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"bin": "./dist/main.js",
"bin": "./dist/main.cjs",
"files": [

@@ -13,6 +14,17 @@ "dist",

],
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"default": "./dist/index.cjs"
},
"./package.json": "./package.json"
},
"sideEffects": false,
"scripts": {
"d:build": "npm run build && npm run typecheck",
"build": "tsup",
"dev": "tsx watch src/main.ts",
"type-check": "tsc --noEmit",
"typecheck": "tsc --noEmit",
"test": "vitest run",

@@ -23,2 +35,3 @@ "test:watch": "vitest",

"dependencies": {
"@blimu/fetch": "^0.4.0",
"@clack/prompts": "^0.11.0",

@@ -25,0 +38,0 @@ "commander": "^14.0.2",

-93
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var index_exports = {};
__export(index_exports, {
BlimuConfigSchema: () => BlimuConfigSchema,
EntitlementDefinitionSchema: () => EntitlementDefinitionSchema,
FeatureDefinitionSchema: () => FeatureDefinitionSchema,
PlanDefinitionSchema: () => PlanDefinitionSchema,
ResourceDefinitionSchema: () => ResourceDefinitionSchema,
defineConfig: () => defineConfig
});
module.exports = __toCommonJS(index_exports);
// src/config/schema.ts
var import_zod = require("zod");
var ResourceDefinitionSchema = import_zod.z.object({
is_tenant: import_zod.z.boolean().optional(),
roles: import_zod.z.array(import_zod.z.string()).min(1, "At least one role must be defined"),
parents: import_zod.z.record(import_zod.z.string(), import_zod.z.object({ required: import_zod.z.boolean() })).optional(),
roles_inheritance: import_zod.z.record(
import_zod.z.string().min(1),
// local role
// Allow tokens containing letters, numbers, underscores or dashes
// Examples: parent->editor, organization->admin, workspace_v2->viewer
import_zod.z.array(import_zod.z.string().regex(/^([a-z0-9_-]+->)*[a-z0-9_-]+$/i)).min(1)
).optional()
});
var EntitlementDefinitionSchema = import_zod.z.object({
roles: import_zod.z.array(import_zod.z.string()).min(1).optional(),
plans: import_zod.z.array(import_zod.z.string()).optional(),
limit: import_zod.z.string().optional()
// Reference to usage-based limit
});
var FeatureDefinitionSchema = import_zod.z.object({
name: import_zod.z.string(),
summary: import_zod.z.string().optional(),
entitlements: import_zod.z.array(import_zod.z.string()).optional(),
plans: import_zod.z.array(import_zod.z.string()).optional(),
default_enabled: import_zod.z.boolean().optional()
});
var PlanDefinitionSchema = import_zod.z.object({
name: import_zod.z.string().min(1, "Plan name is required"),
summary: import_zod.z.string().optional(),
description: import_zod.z.string().min(1, "Plan description is required").optional(),
resource_limits: import_zod.z.record(import_zod.z.string(), import_zod.z.number().int().min(0)).optional(),
usage_based_limits: import_zod.z.record(
import_zod.z.string(),
import_zod.z.object({
value: import_zod.z.number().int().min(0),
period: import_zod.z.enum(["monthly", "yearly", "lifetime"])
})
).optional()
});
var BlimuConfigSchema = import_zod.z.object({
resources: import_zod.z.record(import_zod.z.string().min(1), ResourceDefinitionSchema),
entitlements: import_zod.z.record(import_zod.z.string().min(1), EntitlementDefinitionSchema).optional(),
features: import_zod.z.record(import_zod.z.string().min(1), FeatureDefinitionSchema).optional(),
plans: import_zod.z.record(import_zod.z.string().min(1), PlanDefinitionSchema).optional()
});
// src/config/define-config.ts
function defineConfig(config) {
const validated = BlimuConfigSchema.parse(config);
return config;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
BlimuConfigSchema,
EntitlementDefinitionSchema,
FeatureDefinitionSchema,
PlanDefinitionSchema,
ResourceDefinitionSchema,
defineConfig
});
//# sourceMappingURL=index.js.map
{"version":3,"sources":["../src/index.ts","../src/config/schema.ts","../src/config/define-config.ts"],"sourcesContent":["// Library exports for programmatic usage\n\n/**\n * Configuration utilities\n */\nexport { defineConfig } from './config/define-config';\nexport type {\n BlimuConfig,\n ResourceDefinition,\n EntitlementDefinition,\n FeatureDefinition,\n PlanDefinition,\n} from './config/schema';\nexport {\n BlimuConfigSchema,\n ResourceDefinitionSchema,\n EntitlementDefinitionSchema,\n FeatureDefinitionSchema,\n PlanDefinitionSchema,\n} from './config/schema';\n\n/**\n * Type inference utilities\n */\nexport type {\n InferResourceTypes,\n InferEntitlementTypes,\n InferPlanTypes,\n InferLimitTypes,\n InferUsageLimitTypes,\n} from './types/infer';\n","import { z } from 'zod';\n\n/**\n * Zod schema for resource definition\n */\nexport const ResourceDefinitionSchema = z.object({\n is_tenant: z.boolean().optional(),\n roles: z.array(z.string()).min(1, 'At least one role must be defined'),\n parents: z.record(z.string(), z.object({ required: z.boolean() })).optional(),\n roles_inheritance: z\n .record(\n z.string().min(1), // local role\n // Allow tokens containing letters, numbers, underscores or dashes\n // Examples: parent->editor, organization->admin, workspace_v2->viewer\n z.array(z.string().regex(/^([a-z0-9_-]+->)*[a-z0-9_-]+$/i)).min(1),\n )\n .optional(),\n});\n\n/**\n * Zod schema for entitlement definition\n */\nexport const EntitlementDefinitionSchema = z.object({\n roles: z.array(z.string()).min(1).optional(),\n plans: z.array(z.string()).optional(),\n limit: z.string().optional(), // Reference to usage-based limit\n});\n\n/**\n * Zod schema for feature definition\n */\nexport const FeatureDefinitionSchema = z.object({\n name: z.string(),\n summary: z.string().optional(),\n entitlements: z.array(z.string()).optional(),\n plans: z.array(z.string()).optional(),\n default_enabled: z.boolean().optional(),\n});\n\n/**\n * Zod schema for plan definition\n */\nexport const PlanDefinitionSchema = z.object({\n name: z.string().min(1, 'Plan name is required'),\n summary: z.string().optional(),\n description: z.string().min(1, 'Plan description is required').optional(),\n resource_limits: z.record(z.string(), z.number().int().min(0)).optional(),\n usage_based_limits: z\n .record(\n z.string(),\n z.object({\n value: z.number().int().min(0),\n period: z.enum(['monthly', 'yearly', 'lifetime']),\n }),\n )\n .optional(),\n});\n\n/**\n * Zod schema for complete Blimu configuration\n */\nexport const BlimuConfigSchema = z.object({\n resources: z.record(z.string().min(1), ResourceDefinitionSchema),\n entitlements: z.record(z.string().min(1), EntitlementDefinitionSchema).optional(),\n features: z.record(z.string().min(1), FeatureDefinitionSchema).optional(),\n plans: z.record(z.string().min(1), PlanDefinitionSchema).optional(),\n});\n\n/**\n * Type inference from schemas\n */\nexport type ResourceDefinition = z.infer<typeof ResourceDefinitionSchema>;\nexport type EntitlementDefinition = z.infer<typeof EntitlementDefinitionSchema>;\nexport type FeatureDefinition = z.infer<typeof FeatureDefinitionSchema>;\nexport type PlanDefinition = z.infer<typeof PlanDefinitionSchema>;\nexport type BlimuConfig = z.infer<typeof BlimuConfigSchema>;\n","import {\n BlimuConfigSchema,\n type BlimuConfig,\n type ResourceDefinition,\n type EntitlementDefinition,\n type FeatureDefinition,\n type PlanDefinition,\n} from './schema';\n\n/**\n * Input type for defineConfig (allows partial config during definition)\n * Uses proper types inferred from Zod schemas for full type safety\n */\nexport type BlimuConfigInput = {\n resources: Record<string, ResourceDefinition>;\n entitlements?: Record<string, EntitlementDefinition>;\n features?: Record<string, FeatureDefinition>;\n plans?: Record<string, PlanDefinition>;\n};\n\n/**\n * Defines and validates a Blimu configuration.\n *\n * This function validates the config using Zod schemas and returns\n * a type-safe, validated configuration object.\n *\n * @param config - The Blimu configuration object\n * @returns The validated configuration\n * @throws {z.ZodError} If the configuration is invalid\n *\n * @example\n * ```typescript\n * import { defineConfig } from 'blimu';\n *\n * export default defineConfig({\n * resources: {\n * workspace: {\n * roles: ['admin', 'editor', 'viewer'],\n * is_tenant: true,\n * },\n * },\n * entitlements: {\n * 'workspace:read': {\n * roles: ['admin', 'editor', 'viewer'],\n * },\n * },\n * });\n * ```\n */\nexport function defineConfig<T extends BlimuConfigInput>(config: T): T {\n // Validate the config using Zod schema\n const validated = BlimuConfigSchema.parse(config);\n\n // Return the original config (with proper typing) after validation\n // This preserves the exact structure and types from the input\n return config as T & BlimuConfig;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;AAKX,IAAM,2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E,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS;AAAA,EACxE,oBAAoB,aACjB;AAAA,IACC,aAAE,OAAO;AAAA,IACT,aAAE,OAAO;AAAA,MACP,OAAO,aAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;AAAA,MAC7B,QAAQ,aAAE,KAAK,CAAC,WAAW,UAAU,UAAU,CAAC;AAAA,IAClD,CAAC;AAAA,EACH,EACC,SAAS;AACd,CAAC;AAKM,IAAM,oBAAoB,aAAE,OAAO;AAAA,EACxC,WAAW,aAAE,OAAO,aAAE,OAAO,EAAE,IAAI,CAAC,GAAG,wBAAwB;AAAA,EAC/D,cAAc,aAAE,OAAO,aAAE,OAAO,EAAE,IAAI,CAAC,GAAG,2BAA2B,EAAE,SAAS;AAAA,EAChF,UAAU,aAAE,OAAO,aAAE,OAAO,EAAE,IAAI,CAAC,GAAG,uBAAuB,EAAE,SAAS;AAAA,EACxE,OAAO,aAAE,OAAO,aAAE,OAAO,EAAE,IAAI,CAAC,GAAG,oBAAoB,EAAE,SAAS;AACpE,CAAC;;;ACjBM,SAAS,aAAyC,QAAc;AAErE,QAAM,YAAY,kBAAkB,MAAM,MAAM;AAIhD,SAAO;AACT;","names":[]}
#!/usr/bin/env node
"use strict";var b=Object.create;var y=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var $=(i,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of w(t))!I.call(i,e)&&e!==s&&y(i,e,{get:()=>t[e],enumerable:!(o=j(t,e))||o.enumerable});return i};var f=(i,t,s)=>(s=i!=null?b(C(i)):{},$(t||!i||!i.__esModule?y(s,"default",{value:i,enumerable:!0}):s,i));var T=require("commander");var n=f(require("path")),h=f(require("fs")),r=f(require("@clack/prompts"));var c=f(require("fs")),p=f(require("path"));function d(i){let{configPath:t,outputPath:s,typesPackages:o=["@blimu/types","@blimu/backend"]}=i,e=[],a=o.join(" and ");e.push("/**"),e.push(` * Type Augmentation for ${a}`),e.push(" *"),e.push(` * This file augments the ${a} packages with union types`),e.push(" * specific to your environment configuration."),e.push(" *"),e.push(" * Types are automatically inferred from your blimu.config.ts file."),e.push(" * No regeneration needed when you update your config!"),e.push(" *"),e.push(" * Make sure to include this file in your tsconfig.json:"),e.push(" * {"),e.push(' * "include": ["blimu-types.d.ts"]'),e.push(" * }"),e.push(" */"),e.push("");let u=p.dirname(s),l=p.isAbsolute(t)?p.resolve(t):p.resolve(u,t),m=p.relative(u,l).replace(/\.(ts|mjs|js)$/,""),k=m.startsWith(".")?m:`./${m}`;e.push(`import type config from '${k}';`),e.push("import type {"),e.push(" InferResourceTypes,"),e.push(" InferEntitlementTypes,"),e.push(" InferPlanTypes,"),e.push(" InferLimitTypes,"),e.push(" InferUsageLimitTypes,"),e.push("} from 'blimu';"),e.push("");for(let v of o)e.push(`declare module '${v}' {`),e.push(" /**"),e.push(" * Resource types inferred from your Blimu configuration."),e.push(" */"),e.push(" type ResourceType = InferResourceTypes<typeof config>;"),e.push(""),e.push(" /**"),e.push(" * Entitlement types inferred from your Blimu configuration."),e.push(" */"),e.push(" type EntitlementType = InferEntitlementTypes<typeof config>;"),e.push(""),e.push(" /**"),e.push(" * Plan types inferred from your Blimu configuration."),e.push(" */"),e.push(" type PlanType = InferPlanTypes<typeof config>;"),e.push(""),e.push(" /**"),e.push(" * Limit types inferred from your Blimu configuration."),e.push(" */"),e.push(" type LimitType = InferLimitTypes<typeof config>;"),e.push(""),e.push(" /**"),e.push(" * Usage limit types inferred from your Blimu configuration."),e.push(" */"),e.push(" type UsageLimitType = InferUsageLimitTypes<typeof config>;"),e.push("}"),e.push("");c.existsSync(u)||c.mkdirSync(u,{recursive:!0}),c.writeFileSync(s,e.join(`
`),"utf-8")}function x(){let i=[n.join(process.cwd(),"blimu.config.ts"),n.join(process.cwd(),"blimu.config.mjs"),n.join(process.cwd(),"blimu.config.js")];for(let t of i)if(h.existsSync(t))return t;return null}function A(i,t){let o=n.relative(i,t).replace(/\.(ts|mjs|js)$/,"");return o.startsWith(".")?o:`./${o}`}function P(i){i.command("codegen").description("Generate type augmentation file from Blimu config").option("--config <path>","Path to Blimu config file (defaults to blimu.config.ts in project root)").option("--output <path>","Output path for generated type augmentation file (defaults to blimu-types.d.ts in project root)").action(async t=>{let s=r.spinner();try{let o=t.config||x();o||(r.cancel("No config file found. Please provide --config or ensure blimu.config.ts exists in project root."),process.exit(1));let e=n.isAbsolute(o)?o:n.resolve(process.cwd(),o);h.existsSync(e)||(r.cancel(`Config file not found: ${e}`),process.exit(1)),r.log.step(`Using config file: ${e}`);let a=t.output?n.isAbsolute(t.output)?t.output:n.resolve(process.cwd(),t.output):n.join(process.cwd(),"blimu-types.d.ts");r.log.step(`Output: ${a}`);let u=n.dirname(a),l=A(u,e);s.start("Generating type augmentation file with type inference..."),d({configPath:l,outputPath:a}),s.stop("\u26A1\uFE0F Successfully generated type augmentation file"),r.log.success(`Generated at: ${a}`),r.log.info("\u{1F4A1} Tip: Types are automatically inferred from your config."),r.log.info(" No regeneration needed when you update blimu.config.ts!")}catch(o){s.stop("\u274C Failed to generate type augmentation"),r.log.error(`Failed to generate type augmentation: ${o instanceof Error?o.message:String(o)}`),o instanceof Error&&o.stack&&r.log.error(o.stack),process.exit(1)}})}var g=new T.Command;g.name("blimu").description("Blimu - Authorization as a Service CLI").version(process.env.npm_package_version||"0.7.0");P(g);g.parse();
//# sourceMappingURL=main.js.map
{"version":3,"sources":["../src/main.ts","../src/commands/codegen.ts","../src/utils/type-augmentation-generator.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { codegenCommand } from './commands/codegen';\n\nconst program = new Command();\n\nprogram\n .name('blimu')\n .description('Blimu - Authorization as a Service CLI')\n .version(process.env.npm_package_version || '0.7.0');\n\n// Register commands\ncodegenCommand(program);\n\n// Parse arguments\nprogram.parse();\n","import { Command } from 'commander';\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport * as clack from '@clack/prompts';\nimport { generateTypeAugmentationFile } from '../utils/type-augmentation-generator';\n\n/**\n * Find default config file in project root\n */\nfunction findDefaultConfig(): string | null {\n const possiblePaths = [\n path.join(process.cwd(), 'blimu.config.ts'),\n path.join(process.cwd(), 'blimu.config.mjs'),\n path.join(process.cwd(), 'blimu.config.js'),\n ];\n\n for (const configPath of possiblePaths) {\n if (fs.existsSync(configPath)) {\n return configPath;\n }\n }\n\n return null;\n}\n\n/**\n * Get relative import path from output directory to config file\n * Handles both relative paths and ensures proper extension handling\n */\nfunction getRelativeImportPath(fromDir: string, toFile: string): string {\n const relative = path.relative(fromDir, toFile);\n // Remove .ts/.mjs/.js extension for import\n const withoutExt = relative.replace(/\\.(ts|mjs|js)$/, '');\n // Ensure it starts with ./ or ../\n if (!withoutExt.startsWith('.')) {\n return `./${withoutExt}`;\n }\n return withoutExt;\n}\n\n/**\n * Register the codegen command\n */\nexport function codegenCommand(program: Command): void {\n program\n .command('codegen')\n .description('Generate type augmentation file from Blimu config')\n .option(\n '--config <path>',\n 'Path to Blimu config file (defaults to blimu.config.ts in project root)',\n )\n .option(\n '--output <path>',\n 'Output path for generated type augmentation file (defaults to blimu-types.d.ts in project root)',\n )\n .action(async (options) => {\n const spinner = clack.spinner();\n\n try {\n // Find config file\n const configPath = options.config || findDefaultConfig();\n if (!configPath) {\n clack.cancel(\n 'No config file found. Please provide --config or ensure blimu.config.ts exists in project root.',\n );\n process.exit(1);\n }\n\n // Resolve to absolute path\n const absoluteConfigPath = path.isAbsolute(configPath)\n ? configPath\n : path.resolve(process.cwd(), configPath);\n\n if (!fs.existsSync(absoluteConfigPath)) {\n clack.cancel(`Config file not found: ${absoluteConfigPath}`);\n process.exit(1);\n }\n\n clack.log.step(`Using config file: ${absoluteConfigPath}`);\n\n // Determine output path\n const outputPath = options.output\n ? path.isAbsolute(options.output)\n ? options.output\n : path.resolve(process.cwd(), options.output)\n : path.join(process.cwd(), 'blimu-types.d.ts');\n\n clack.log.step(`Output: ${outputPath}`);\n\n // Calculate relative path from output to config for import statement\n const outputDir = path.dirname(outputPath);\n const relativeConfigPath = getRelativeImportPath(outputDir, absoluteConfigPath);\n\n // Generate type augmentation file\n spinner.start('Generating type augmentation file with type inference...');\n\n generateTypeAugmentationFile({\n configPath: relativeConfigPath,\n outputPath,\n // Always augment both @blimu/types and @blimu/backend\n // This is an internal implementation detail, not user-configurable\n });\n\n spinner.stop('⚡️ Successfully generated type augmentation file');\n\n clack.log.success(`Generated at: ${outputPath}`);\n clack.log.info('💡 Tip: Types are automatically inferred from your config.');\n clack.log.info(' No regeneration needed when you update blimu.config.ts!');\n } catch (error) {\n spinner.stop('❌ Failed to generate type augmentation');\n clack.log.error(\n `Failed to generate type augmentation: ${error instanceof Error ? error.message : String(error)}`,\n );\n if (error instanceof Error && error.stack) {\n clack.log.error(error.stack);\n }\n process.exit(1);\n }\n });\n}\n","import * as fs from 'fs';\nimport * as path from 'path';\n\n/**\n * Options for generating type augmentation file\n */\nexport interface GenerateTypeAugmentationOptions {\n /** Path to the config file (relative to output directory or absolute) */\n configPath: string;\n /** Output path for the generated type augmentation file */\n outputPath: string;\n /** Types package names to augment (defaults to ['@blimu/types', '@blimu/backend']) */\n typesPackages?: string[];\n}\n\n/**\n * Generate type augmentation file for @blimu/types and @blimu/backend using type inference utilities.\n *\n * This generates a .d.ts file that imports the config and uses type inference\n * utilities to automatically extract types from the config structure.\n *\n * @param options - Generation options\n */\nexport function generateTypeAugmentationFile(options: GenerateTypeAugmentationOptions): void {\n const { configPath, outputPath, typesPackages = ['@blimu/types', '@blimu/backend'] } = options;\n\n const lines: string[] = [];\n\n // Header\n const packageNames = typesPackages.join(' and ');\n lines.push('/**');\n lines.push(` * Type Augmentation for ${packageNames}`);\n lines.push(' *');\n lines.push(` * This file augments the ${packageNames} packages with union types`);\n lines.push(' * specific to your environment configuration.');\n lines.push(' *');\n lines.push(' * Types are automatically inferred from your blimu.config.ts file.');\n lines.push(' * No regeneration needed when you update your config!');\n lines.push(' *');\n lines.push(' * Make sure to include this file in your tsconfig.json:');\n lines.push(' * {');\n lines.push(' * \"include\": [\"blimu-types.d.ts\"]');\n lines.push(' * }');\n lines.push(' */');\n lines.push('');\n\n // Calculate output directory and relative import path\n const outputDir = path.dirname(outputPath);\n const resolvedConfigPath = path.isAbsolute(configPath)\n ? path.resolve(configPath)\n : path.resolve(outputDir, configPath);\n const relativeConfigPath = path.relative(outputDir, resolvedConfigPath);\n // Remove .ts/.mjs/.js extension and ensure it starts with ./\n const importPath = relativeConfigPath.replace(/\\.(ts|mjs|js)$/, '');\n const finalImportPath = importPath.startsWith('.') ? importPath : `./${importPath}`;\n\n // Import config and type utilities\n lines.push(`import type config from '${finalImportPath}';`);\n lines.push('import type {');\n lines.push(' InferResourceTypes,');\n lines.push(' InferEntitlementTypes,');\n lines.push(' InferPlanTypes,');\n lines.push(' InferLimitTypes,');\n lines.push(' InferUsageLimitTypes,');\n lines.push(\"} from 'blimu';\");\n lines.push('');\n\n // Generate module augmentation for each package\n for (const typesPackage of typesPackages) {\n lines.push(`declare module '${typesPackage}' {`);\n lines.push(' /**');\n lines.push(' * Resource types inferred from your Blimu configuration.');\n lines.push(' */');\n lines.push(' type ResourceType = InferResourceTypes<typeof config>;');\n lines.push('');\n lines.push(' /**');\n lines.push(' * Entitlement types inferred from your Blimu configuration.');\n lines.push(' */');\n lines.push(' type EntitlementType = InferEntitlementTypes<typeof config>;');\n lines.push('');\n lines.push(' /**');\n lines.push(' * Plan types inferred from your Blimu configuration.');\n lines.push(' */');\n lines.push(' type PlanType = InferPlanTypes<typeof config>;');\n lines.push('');\n lines.push(' /**');\n lines.push(' * Limit types inferred from your Blimu configuration.');\n lines.push(' */');\n lines.push(' type LimitType = InferLimitTypes<typeof config>;');\n lines.push('');\n lines.push(' /**');\n lines.push(' * Usage limit types inferred from your Blimu configuration.');\n lines.push(' */');\n lines.push(' type UsageLimitType = InferUsageLimitTypes<typeof config>;');\n lines.push('}');\n lines.push('');\n }\n\n // Ensure output directory exists\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n // Write file\n fs.writeFileSync(outputPath, lines.join('\\n'), 'utf-8');\n}\n"],"mappings":";wdAAA,IAAAA,EAAwB,qBCCxB,IAAAC,EAAsB,mBACtBC,EAAoB,iBACpBC,EAAuB,6BCHvB,IAAAC,EAAoB,iBACpBC,EAAsB,mBAsBf,SAASC,EAA6BC,EAAgD,CAC3F,GAAM,CAAE,WAAAC,EAAY,WAAAC,EAAY,cAAAC,EAAgB,CAAC,eAAgB,gBAAgB,CAAE,EAAIH,EAEjFI,EAAkB,CAAC,EAGnBC,EAAeF,EAAc,KAAK,OAAO,EAC/CC,EAAM,KAAK,KAAK,EAChBA,EAAM,KAAK,4BAA4BC,CAAY,EAAE,EACrDD,EAAM,KAAK,IAAI,EACfA,EAAM,KAAK,6BAA6BC,CAAY,4BAA4B,EAChFD,EAAM,KAAK,gDAAgD,EAC3DA,EAAM,KAAK,IAAI,EACfA,EAAM,KAAK,qEAAqE,EAChFA,EAAM,KAAK,wDAAwD,EACnEA,EAAM,KAAK,IAAI,EACfA,EAAM,KAAK,0DAA0D,EACrEA,EAAM,KAAK,MAAM,EACjBA,EAAM,KAAK,sCAAsC,EACjDA,EAAM,KAAK,MAAM,EACjBA,EAAM,KAAK,KAAK,EAChBA,EAAM,KAAK,EAAE,EAGb,IAAME,EAAiB,UAAQJ,CAAU,EACnCK,EAA0B,aAAWN,CAAU,EAC5C,UAAQA,CAAU,EAClB,UAAQK,EAAWL,CAAU,EAGhCO,EAF0B,WAASF,EAAWC,CAAkB,EAEhC,QAAQ,iBAAkB,EAAE,EAC5DE,EAAkBD,EAAW,WAAW,GAAG,EAAIA,EAAa,KAAKA,CAAU,GAGjFJ,EAAM,KAAK,4BAA4BK,CAAe,IAAI,EAC1DL,EAAM,KAAK,eAAe,EAC1BA,EAAM,KAAK,uBAAuB,EAClCA,EAAM,KAAK,0BAA0B,EACrCA,EA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M,QAAU,OAAOA,CAAK,CAAC,EACjG,EACIA,aAAiB,OAASA,EAAM,OAC5B,MAAI,MAAMA,EAAM,KAAK,EAE7B,QAAQ,KAAK,CAAC,CAChB,CACF,CAAC,CACL,CDpHA,IAAMC,EAAU,IAAI,UAEpBA,EACG,KAAK,OAAO,EACZ,YAAY,wCAAwC,EACpD,QAAQ,QAAQ,IAAI,qBAAuB,OAAO,EAGrDC,EAAeD,CAAO,EAGtBA,EAAQ,MAAM","names":["import_commander","path","fs","clack","fs","path","generateTypeAugmentationFile","options","configPath","outputPath","typesPackages","lines","packageNames","outputDir","resolvedConfigPath","importPath","finalImportPath","typesPackage","findDefaultConfig","possiblePaths","configPath","getRelativeImportPath","fromDir","toFile","withoutExt","codegenCommand","program","options","spinner","absoluteConfigPath","outputPath","outputDir","relativeConfigPath","generateTypeAugmentationFile","error","program","codegenCommand"]}