calabasas 0.6.0 → 0.6.1
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/index.js +34 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -3068,6 +3068,27 @@ function generateTypeForEvent(eventName) {
|
|
|
3068
3068
|
${fieldEntries}
|
|
3069
3069
|
}`;
|
|
3070
3070
|
}
|
|
3071
|
+
function splitObjectFields(content) {
|
|
3072
|
+
const fields = [];
|
|
3073
|
+
let depth = 0;
|
|
3074
|
+
let current = "";
|
|
3075
|
+
for (const char of content) {
|
|
3076
|
+
if (char === "(" || char === "{")
|
|
3077
|
+
depth++;
|
|
3078
|
+
if (char === ")" || char === "}")
|
|
3079
|
+
depth--;
|
|
3080
|
+
if (char === "," && depth === 0) {
|
|
3081
|
+
if (current.trim())
|
|
3082
|
+
fields.push(current.trim());
|
|
3083
|
+
current = "";
|
|
3084
|
+
} else {
|
|
3085
|
+
current += char;
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
if (current.trim())
|
|
3089
|
+
fields.push(current.trim());
|
|
3090
|
+
return fields;
|
|
3091
|
+
}
|
|
3071
3092
|
function validatorToType(validator) {
|
|
3072
3093
|
if (validator.startsWith("v.string()"))
|
|
3073
3094
|
return "string";
|
|
@@ -3086,7 +3107,19 @@ function validatorToType(validator) {
|
|
|
3086
3107
|
return `Array<${validatorToType(inner)}>`;
|
|
3087
3108
|
}
|
|
3088
3109
|
if (validator.startsWith("v.object(")) {
|
|
3089
|
-
|
|
3110
|
+
const objectLiteral = validator.slice(9, -1).trim();
|
|
3111
|
+
const content = objectLiteral.slice(1, -1).trim();
|
|
3112
|
+
if (!content)
|
|
3113
|
+
return "Record<string, never>";
|
|
3114
|
+
const fields = splitObjectFields(content);
|
|
3115
|
+
const fieldTypes = fields.filter((f) => f.includes(":")).map((field) => {
|
|
3116
|
+
const colonIndex = field.indexOf(":");
|
|
3117
|
+
const key = field.slice(0, colonIndex).trim();
|
|
3118
|
+
const fieldValidator = field.slice(colonIndex + 1).trim();
|
|
3119
|
+
const tsType = validatorToType(fieldValidator);
|
|
3120
|
+
return `${key}: ${tsType}`;
|
|
3121
|
+
});
|
|
3122
|
+
return `{ ${fieldTypes.join("; ")} }`;
|
|
3090
3123
|
}
|
|
3091
3124
|
return "unknown";
|
|
3092
3125
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "calabasas",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "CLI for Calabasas - Discord Gateway as a Service for Convex",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"build": "bun run build:cli && bun run build:lib",
|
|
20
20
|
"build:cli": "bun build src/index.ts --outdir dist --target node --splitting --external @clack/prompts --external picocolors && node scripts/fix-duplicate-exports.js",
|
|
21
21
|
"build:lib": "bun build src/config.ts --outfile dist/config.js --target node --format esm && cp src/config.d.ts dist/config.d.ts",
|
|
22
|
+
"test": "bun test",
|
|
22
23
|
"typecheck": "tsc --noEmit",
|
|
23
24
|
"prepublishOnly": "bun run build"
|
|
24
25
|
},
|