cleo-dev 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +67 -7
- package/dist/index.js +63 -5
- package/dist/public/cleo-bundle.iife.js +37 -37
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -55718,7 +55718,7 @@ var {
|
|
|
55718
55718
|
} = import_index.default;
|
|
55719
55719
|
|
|
55720
55720
|
// package.json
|
|
55721
|
-
var version = "0.1.
|
|
55721
|
+
var version = "0.1.4";
|
|
55722
55722
|
|
|
55723
55723
|
// src/commands/init.ts
|
|
55724
55724
|
init_cjs_shims();
|
|
@@ -99785,19 +99785,21 @@ function parseAiGatewayOptions(options) {
|
|
|
99785
99785
|
// src/utils/logger.ts
|
|
99786
99786
|
init_cjs_shims();
|
|
99787
99787
|
var import_chalk2 = __toESM(require_source());
|
|
99788
|
-
|
|
99788
|
+
function isDebug() {
|
|
99789
|
+
return process.env.DEBUG === "true" || process.env.CLEO_DEBUG === "true";
|
|
99790
|
+
}
|
|
99789
99791
|
var debug = {
|
|
99790
99792
|
log: (...args) => {
|
|
99791
|
-
if (isDebug) console.log(...args);
|
|
99793
|
+
if (isDebug()) console.log(...args);
|
|
99792
99794
|
},
|
|
99793
99795
|
warn: (...args) => {
|
|
99794
|
-
if (isDebug) console.warn(...args);
|
|
99796
|
+
if (isDebug()) console.warn(...args);
|
|
99795
99797
|
},
|
|
99796
99798
|
error: (...args) => {
|
|
99797
99799
|
console.error(...args);
|
|
99798
99800
|
},
|
|
99799
99801
|
info: (...args) => {
|
|
99800
|
-
if (isDebug) console.log(...args);
|
|
99802
|
+
if (isDebug()) console.log(...args);
|
|
99801
99803
|
}
|
|
99802
99804
|
};
|
|
99803
99805
|
var logger3 = {
|
|
@@ -131374,9 +131376,14 @@ async function startDevServer(options) {
|
|
|
131374
131376
|
} catch (cancelError) {
|
|
131375
131377
|
debug.log(`Note: Could not cancel free plan (may not exist)`);
|
|
131376
131378
|
}
|
|
131379
|
+
const { name: name16, email: email5 } = req.body || {};
|
|
131377
131380
|
const result = await Autumn.attach({
|
|
131378
131381
|
customer_id: userId,
|
|
131379
|
-
product_id: "early-tester"
|
|
131382
|
+
product_id: "early-tester",
|
|
131383
|
+
customer_data: {
|
|
131384
|
+
...name16 && { name: name16 },
|
|
131385
|
+
...email5 && { email: email5 }
|
|
131386
|
+
}
|
|
131380
131387
|
});
|
|
131381
131388
|
debug.log(`\u2713 Attached early-tester plan to user ${userId.slice(0, 10)}...`);
|
|
131382
131389
|
res.json({ success: true, message: "Early tester plan attached" });
|
|
@@ -131386,6 +131393,57 @@ async function startDevServer(options) {
|
|
|
131386
131393
|
res.status(500).json({ error: "Failed to attach plan", details: errorMsg });
|
|
131387
131394
|
}
|
|
131388
131395
|
});
|
|
131396
|
+
app.post("/api/autumn/sync-customer", async (req, res) => {
|
|
131397
|
+
const authHeader = req.headers.authorization;
|
|
131398
|
+
if (!authHeader || !authHeader.startsWith("Bearer ")) {
|
|
131399
|
+
res.status(401).json({ error: "User not authenticated" });
|
|
131400
|
+
return;
|
|
131401
|
+
}
|
|
131402
|
+
const userId = authHeader.replace("Bearer ", "");
|
|
131403
|
+
const { name: name16, email: email5 } = req.body || {};
|
|
131404
|
+
debug.log(`[Autumn Sync] Syncing customer ${userId.slice(0, 10)}... name: ${name16}, email: ${email5}`);
|
|
131405
|
+
try {
|
|
131406
|
+
let customerExists = false;
|
|
131407
|
+
let hasProducts = false;
|
|
131408
|
+
try {
|
|
131409
|
+
const customer = await Autumn.customers.get(userId);
|
|
131410
|
+
customerExists = !!customer.data;
|
|
131411
|
+
hasProducts = customer.data?.products?.some(
|
|
131412
|
+
(p) => p.status === "active" || p.status === "scheduled"
|
|
131413
|
+
) ?? false;
|
|
131414
|
+
debug.log(`[Autumn Sync] Customer exists: ${customerExists}, has products: ${hasProducts}`);
|
|
131415
|
+
} catch {
|
|
131416
|
+
debug.log(`[Autumn Sync] Customer doesn't exist yet`);
|
|
131417
|
+
}
|
|
131418
|
+
if (!customerExists || !hasProducts) {
|
|
131419
|
+
debug.log(`[Autumn Sync] Attaching free plan for new customer`);
|
|
131420
|
+
await Autumn.attach({
|
|
131421
|
+
customer_id: userId,
|
|
131422
|
+
product_id: "free",
|
|
131423
|
+
customer_data: {
|
|
131424
|
+
...name16 && { name: name16 },
|
|
131425
|
+
...email5 && { email: email5 }
|
|
131426
|
+
}
|
|
131427
|
+
});
|
|
131428
|
+
}
|
|
131429
|
+
if (name16 || email5) {
|
|
131430
|
+
try {
|
|
131431
|
+
await Autumn.customers.update(userId, {
|
|
131432
|
+
...name16 && { name: name16 },
|
|
131433
|
+
...email5 && { email: email5 }
|
|
131434
|
+
});
|
|
131435
|
+
} catch {
|
|
131436
|
+
}
|
|
131437
|
+
}
|
|
131438
|
+
debug.log(`\u2713 Synced Autumn customer ${userId.slice(0, 10)}... with name: ${name16}, email: ${email5}`);
|
|
131439
|
+
res.json({ success: true });
|
|
131440
|
+
} catch (error85) {
|
|
131441
|
+
const errorMsg = error85 instanceof Error ? error85.message : String(error85);
|
|
131442
|
+
debug.log(`[Autumn Sync] Failed to sync customer:`, error85);
|
|
131443
|
+
logger3.error("Server", "Error syncing Autumn customer:", error85);
|
|
131444
|
+
res.status(500).json({ error: "Failed to sync customer", details: errorMsg });
|
|
131445
|
+
}
|
|
131446
|
+
});
|
|
131389
131447
|
} else {
|
|
131390
131448
|
const productionApiUrl = "https://api.cleo.build";
|
|
131391
131449
|
app.post("/api/attach-early-tester", async (req, res) => {
|
|
@@ -132222,7 +132280,9 @@ var BUNDLED_CF_GATEWAY_NAME = "cleo-gateway";
|
|
|
132222
132280
|
var BUNDLED_CF_API_KEY = "BBBLe4UXD4UkBywIDlrxSCpUGabiVENmkfkCsmZU";
|
|
132223
132281
|
var BUNDLED_AUTUMN_KEY = "am_sk_live_Q1UHqTaRHW83nLppZVCQK8MDzXAYCTpklpsoKttaoB";
|
|
132224
132282
|
process.env.CONVEX_URL = PRODUCTION_CONVEX_URL;
|
|
132225
|
-
process.env.
|
|
132283
|
+
if (process.env.CLEO_DEBUG !== "true") {
|
|
132284
|
+
process.env.CLEO_API_URL = PRODUCTION_API_URL;
|
|
132285
|
+
}
|
|
132226
132286
|
if (BUNDLED_CF_ACCOUNT_ID) {
|
|
132227
132287
|
process.env.CLOUDFLARE_ACCOUNT_ID = BUNDLED_CF_ACCOUNT_ID;
|
|
132228
132288
|
}
|
package/dist/index.js
CHANGED
|
@@ -91392,19 +91392,21 @@ function parseAiGatewayOptions(options) {
|
|
|
91392
91392
|
// src/utils/logger.ts
|
|
91393
91393
|
init_cjs_shims();
|
|
91394
91394
|
var import_chalk = __toESM(require_source());
|
|
91395
|
-
|
|
91395
|
+
function isDebug() {
|
|
91396
|
+
return process.env.DEBUG === "true" || process.env.CLEO_DEBUG === "true";
|
|
91397
|
+
}
|
|
91396
91398
|
var debug = {
|
|
91397
91399
|
log: (...args) => {
|
|
91398
|
-
if (isDebug) console.log(...args);
|
|
91400
|
+
if (isDebug()) console.log(...args);
|
|
91399
91401
|
},
|
|
91400
91402
|
warn: (...args) => {
|
|
91401
|
-
if (isDebug) console.warn(...args);
|
|
91403
|
+
if (isDebug()) console.warn(...args);
|
|
91402
91404
|
},
|
|
91403
91405
|
error: (...args) => {
|
|
91404
91406
|
console.error(...args);
|
|
91405
91407
|
},
|
|
91406
91408
|
info: (...args) => {
|
|
91407
|
-
if (isDebug) console.log(...args);
|
|
91409
|
+
if (isDebug()) console.log(...args);
|
|
91408
91410
|
}
|
|
91409
91411
|
};
|
|
91410
91412
|
var logger3 = {
|
|
@@ -122981,9 +122983,14 @@ async function startDevServer(options) {
|
|
|
122981
122983
|
} catch (cancelError) {
|
|
122982
122984
|
debug.log(`Note: Could not cancel free plan (may not exist)`);
|
|
122983
122985
|
}
|
|
122986
|
+
const { name: name16, email: email5 } = req.body || {};
|
|
122984
122987
|
const result = await Autumn.attach({
|
|
122985
122988
|
customer_id: userId,
|
|
122986
|
-
product_id: "early-tester"
|
|
122989
|
+
product_id: "early-tester",
|
|
122990
|
+
customer_data: {
|
|
122991
|
+
...name16 && { name: name16 },
|
|
122992
|
+
...email5 && { email: email5 }
|
|
122993
|
+
}
|
|
122987
122994
|
});
|
|
122988
122995
|
debug.log(`\u2713 Attached early-tester plan to user ${userId.slice(0, 10)}...`);
|
|
122989
122996
|
res.json({ success: true, message: "Early tester plan attached" });
|
|
@@ -122993,6 +123000,57 @@ async function startDevServer(options) {
|
|
|
122993
123000
|
res.status(500).json({ error: "Failed to attach plan", details: errorMsg });
|
|
122994
123001
|
}
|
|
122995
123002
|
});
|
|
123003
|
+
app.post("/api/autumn/sync-customer", async (req, res) => {
|
|
123004
|
+
const authHeader = req.headers.authorization;
|
|
123005
|
+
if (!authHeader || !authHeader.startsWith("Bearer ")) {
|
|
123006
|
+
res.status(401).json({ error: "User not authenticated" });
|
|
123007
|
+
return;
|
|
123008
|
+
}
|
|
123009
|
+
const userId = authHeader.replace("Bearer ", "");
|
|
123010
|
+
const { name: name16, email: email5 } = req.body || {};
|
|
123011
|
+
debug.log(`[Autumn Sync] Syncing customer ${userId.slice(0, 10)}... name: ${name16}, email: ${email5}`);
|
|
123012
|
+
try {
|
|
123013
|
+
let customerExists = false;
|
|
123014
|
+
let hasProducts = false;
|
|
123015
|
+
try {
|
|
123016
|
+
const customer = await Autumn.customers.get(userId);
|
|
123017
|
+
customerExists = !!customer.data;
|
|
123018
|
+
hasProducts = customer.data?.products?.some(
|
|
123019
|
+
(p) => p.status === "active" || p.status === "scheduled"
|
|
123020
|
+
) ?? false;
|
|
123021
|
+
debug.log(`[Autumn Sync] Customer exists: ${customerExists}, has products: ${hasProducts}`);
|
|
123022
|
+
} catch {
|
|
123023
|
+
debug.log(`[Autumn Sync] Customer doesn't exist yet`);
|
|
123024
|
+
}
|
|
123025
|
+
if (!customerExists || !hasProducts) {
|
|
123026
|
+
debug.log(`[Autumn Sync] Attaching free plan for new customer`);
|
|
123027
|
+
await Autumn.attach({
|
|
123028
|
+
customer_id: userId,
|
|
123029
|
+
product_id: "free",
|
|
123030
|
+
customer_data: {
|
|
123031
|
+
...name16 && { name: name16 },
|
|
123032
|
+
...email5 && { email: email5 }
|
|
123033
|
+
}
|
|
123034
|
+
});
|
|
123035
|
+
}
|
|
123036
|
+
if (name16 || email5) {
|
|
123037
|
+
try {
|
|
123038
|
+
await Autumn.customers.update(userId, {
|
|
123039
|
+
...name16 && { name: name16 },
|
|
123040
|
+
...email5 && { email: email5 }
|
|
123041
|
+
});
|
|
123042
|
+
} catch {
|
|
123043
|
+
}
|
|
123044
|
+
}
|
|
123045
|
+
debug.log(`\u2713 Synced Autumn customer ${userId.slice(0, 10)}... with name: ${name16}, email: ${email5}`);
|
|
123046
|
+
res.json({ success: true });
|
|
123047
|
+
} catch (error85) {
|
|
123048
|
+
const errorMsg = error85 instanceof Error ? error85.message : String(error85);
|
|
123049
|
+
debug.log(`[Autumn Sync] Failed to sync customer:`, error85);
|
|
123050
|
+
logger3.error("Server", "Error syncing Autumn customer:", error85);
|
|
123051
|
+
res.status(500).json({ error: "Failed to sync customer", details: errorMsg });
|
|
123052
|
+
}
|
|
123053
|
+
});
|
|
122996
123054
|
} else {
|
|
122997
123055
|
const productionApiUrl = "https://api.cleo.build";
|
|
122998
123056
|
app.post("/api/attach-early-tester", async (req, res) => {
|