khotan-data 0.3.0 → 0.3.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/README.md +2 -2
- package/dist/cli.js +37 -16
- package/dist/templates/khotan-config.ts +5 -6
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# khotan-data
|
|
2
2
|
|
|
3
|
-
Data
|
|
3
|
+
Data sync, ETL, and webhook primitives for Next.js + Drizzle + Postgres. shadcn for data plumbing.
|
|
4
4
|
|
|
5
|
-
Built for **Next.js + Drizzle + Postgres** projects. Think better-auth for data
|
|
5
|
+
Built for **Next.js + Drizzle + Postgres** projects. Think shadcn × better-auth, but for data.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
package/dist/cli.js
CHANGED
|
@@ -46,7 +46,7 @@ function checkNpmPackages(cwd, packages) {
|
|
|
46
46
|
...pkgJson.dependencies,
|
|
47
47
|
...pkgJson.devDependencies
|
|
48
48
|
};
|
|
49
|
-
return packages.filter((
|
|
49
|
+
return packages.filter((pkg2) => !(pkg2 in allDeps));
|
|
50
50
|
} catch {
|
|
51
51
|
return packages;
|
|
52
52
|
}
|
|
@@ -708,11 +708,6 @@ function scaffoldCoreFiles(cwd, outputDir) {
|
|
|
708
708
|
"templates",
|
|
709
709
|
"khotan-config.ts"
|
|
710
710
|
);
|
|
711
|
-
const routeTemplatePath = path2.resolve(
|
|
712
|
-
__dirname2,
|
|
713
|
-
"templates",
|
|
714
|
-
"khotan-route.ts"
|
|
715
|
-
);
|
|
716
711
|
const khotanTsPath = path2.join(path2.resolve(cwd, outputDir), "khotan.ts");
|
|
717
712
|
if (!fs4.existsSync(khotanTsPath)) {
|
|
718
713
|
fs4.mkdirSync(path2.dirname(khotanTsPath), { recursive: true });
|
|
@@ -730,7 +725,22 @@ function scaffoldCoreFiles(cwd, outputDir) {
|
|
|
730
725
|
const routePath = path2.join(routeDir, "route.ts");
|
|
731
726
|
if (!fs4.existsSync(routePath)) {
|
|
732
727
|
fs4.mkdirSync(routeDir, { recursive: true });
|
|
733
|
-
|
|
728
|
+
const khotanImportPath = outputDir.startsWith("src/") ? `@/${outputDir.slice(4)}/khotan` : `@/${outputDir}/khotan`;
|
|
729
|
+
const routeContent = `// ============================================================================
|
|
730
|
+
// Khotan API Route \u2014 catch-all handler for /api/khotan/*
|
|
731
|
+
// Generated by khotan CLI \xB7 https://github.com/khotan-io/khotan-data
|
|
732
|
+
//
|
|
733
|
+
// This file wires your khotan config into a Next.js App Router route.
|
|
734
|
+
// ============================================================================
|
|
735
|
+
|
|
736
|
+
import { toNextJsHandler } from "khotan-data/factory";
|
|
737
|
+
import khotanData from "${khotanImportPath}";
|
|
738
|
+
|
|
739
|
+
export const { GET, POST, PUT, PATCH, DELETE } = toNextJsHandler(
|
|
740
|
+
khotanData.handler,
|
|
741
|
+
);
|
|
742
|
+
`;
|
|
743
|
+
fs4.writeFileSync(routePath, routeContent, "utf-8");
|
|
734
744
|
created.push(path2.relative(cwd, routePath));
|
|
735
745
|
} else {
|
|
736
746
|
console.log(`\u2713 ${path2.relative(cwd, routePath)} already exists, skipping`);
|
|
@@ -888,6 +898,13 @@ Installing shadcn components: ${missingShadcn.join(", ")}...`
|
|
|
888
898
|
}
|
|
889
899
|
results.push(ensureKhotanDataInstalled(cwd));
|
|
890
900
|
warnAboutWorkflowProxy(cwd);
|
|
901
|
+
const skillCount = scaffoldAgentSkills(cwd);
|
|
902
|
+
if (skillCount > 0) {
|
|
903
|
+
console.log(`\u2713 Installed ${String(skillCount)} agent skills`);
|
|
904
|
+
results.push({ name: "Install agent skills", status: "success" });
|
|
905
|
+
} else {
|
|
906
|
+
results.push({ name: "Install agent skills", status: "skipped" });
|
|
907
|
+
}
|
|
891
908
|
return results;
|
|
892
909
|
}
|
|
893
910
|
function ensureKhotanDataInstalled(cwd) {
|
|
@@ -1856,13 +1873,13 @@ function diffSchemas(expected, actual, basePath = "$") {
|
|
|
1856
1873
|
}
|
|
1857
1874
|
return diffObjectSchema(expected, actual, basePath);
|
|
1858
1875
|
}
|
|
1859
|
-
function diffTypedNode(expected, actual,
|
|
1876
|
+
function diffTypedNode(expected, actual, path17) {
|
|
1860
1877
|
const expectedType = expected["_type"];
|
|
1861
1878
|
if (expectedType === "array") {
|
|
1862
1879
|
if (actual.type !== "array") {
|
|
1863
1880
|
return [
|
|
1864
1881
|
{
|
|
1865
|
-
path:
|
|
1882
|
+
path: path17,
|
|
1866
1883
|
issue: "type_mismatch",
|
|
1867
1884
|
note: `expected array, got ${actual.type}`
|
|
1868
1885
|
}
|
|
@@ -1870,13 +1887,13 @@ function diffTypedNode(expected, actual, path16) {
|
|
|
1870
1887
|
}
|
|
1871
1888
|
const itemSchema = expected["items"];
|
|
1872
1889
|
if (!itemSchema || !actual.items) return [];
|
|
1873
|
-
return diffSchemas(itemSchema, actual.items, `${
|
|
1890
|
+
return diffSchemas(itemSchema, actual.items, `${path17}[]`);
|
|
1874
1891
|
}
|
|
1875
1892
|
const normalizedExpected = normalizeType(expectedType);
|
|
1876
1893
|
if (normalizedExpected !== actual.type && actual.type !== "null") {
|
|
1877
1894
|
return [
|
|
1878
1895
|
{
|
|
1879
|
-
path:
|
|
1896
|
+
path: path17,
|
|
1880
1897
|
issue: "type_mismatch",
|
|
1881
1898
|
note: `expected ${expectedType}, got ${actual.type}`
|
|
1882
1899
|
}
|
|
@@ -1884,11 +1901,11 @@ function diffTypedNode(expected, actual, path16) {
|
|
|
1884
1901
|
}
|
|
1885
1902
|
return [];
|
|
1886
1903
|
}
|
|
1887
|
-
function diffObjectSchema(expected, actual,
|
|
1904
|
+
function diffObjectSchema(expected, actual, path17) {
|
|
1888
1905
|
if (actual.type !== "object") {
|
|
1889
1906
|
return [
|
|
1890
1907
|
{
|
|
1891
|
-
path:
|
|
1908
|
+
path: path17,
|
|
1892
1909
|
issue: "type_mismatch",
|
|
1893
1910
|
note: `expected object, got ${actual.type}`
|
|
1894
1911
|
}
|
|
@@ -1897,7 +1914,7 @@ function diffObjectSchema(expected, actual, path16) {
|
|
|
1897
1914
|
const mismatches = [];
|
|
1898
1915
|
const actualProps = actual.properties;
|
|
1899
1916
|
for (const [key, typeDesc] of Object.entries(expected)) {
|
|
1900
|
-
const childPath =
|
|
1917
|
+
const childPath = path17 === "$" ? `$.${key}` : `${path17}.${key}`;
|
|
1901
1918
|
const typeStr = typeof typeDesc === "string" ? typeDesc : null;
|
|
1902
1919
|
const isOptional = typeStr?.endsWith("?") ?? false;
|
|
1903
1920
|
if (!(key in actualProps)) {
|
|
@@ -1935,7 +1952,7 @@ function diffObjectSchema(expected, actual, path16) {
|
|
|
1935
1952
|
}
|
|
1936
1953
|
for (const key of Object.keys(actualProps)) {
|
|
1937
1954
|
if (!(key in expected)) {
|
|
1938
|
-
const childPath =
|
|
1955
|
+
const childPath = path17 === "$" ? `$.${key}` : `${path17}.${key}`;
|
|
1939
1956
|
mismatches.push({ path: childPath, issue: "extra" });
|
|
1940
1957
|
}
|
|
1941
1958
|
}
|
|
@@ -2993,8 +3010,12 @@ withApiOptions2(
|
|
|
2993
3010
|
});
|
|
2994
3011
|
|
|
2995
3012
|
// src/cli/index.ts
|
|
3013
|
+
var __cliDirname = path2.dirname(fileURLToPath(import.meta.url));
|
|
3014
|
+
var pkg = JSON.parse(
|
|
3015
|
+
fs4.readFileSync(path2.resolve(__cliDirname, "..", "package.json"), "utf-8")
|
|
3016
|
+
);
|
|
2996
3017
|
var program = new Command();
|
|
2997
|
-
program.name("khotan").description("Scaffold data components into your project").version(
|
|
3018
|
+
program.name("khotan").description("Scaffold data components into your project").version(pkg.version);
|
|
2998
3019
|
program.addCommand(initCommand);
|
|
2999
3020
|
program.addCommand(addCommand);
|
|
3000
3021
|
program.addCommand(generateCommand);
|
|
@@ -42,14 +42,13 @@ const khotanData = khotan({
|
|
|
42
42
|
plugs: [
|
|
43
43
|
// Example plug registration:
|
|
44
44
|
//
|
|
45
|
+
// import { stripePlug } from "./plugs/stripe";
|
|
46
|
+
// import { stripeProductsInflow } from "./flows/stripe-products";
|
|
47
|
+
//
|
|
45
48
|
// {
|
|
46
49
|
// name: "stripe",
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
// flows: [
|
|
50
|
-
// { name: "products-inflow", type: "inflow", schedule: "0 * * * *", resource: "products" },
|
|
51
|
-
// { name: "invoices-inflow", type: "inflow", schedule: "0 0 * * *" },
|
|
52
|
-
// ],
|
|
50
|
+
// plug: stripePlug,
|
|
51
|
+
// flows: [stripeProductsInflow],
|
|
53
52
|
// },
|
|
54
53
|
],
|
|
55
54
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "khotan-data",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "Data
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Data sync, ETL, and webhook primitives for Next.js + Drizzle + Postgres. shadcn for data plumbing.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -107,11 +107,11 @@
|
|
|
107
107
|
"transform",
|
|
108
108
|
"data-management"
|
|
109
109
|
],
|
|
110
|
-
"author": "",
|
|
110
|
+
"author": "Khotan",
|
|
111
111
|
"license": "MIT",
|
|
112
112
|
"repository": {
|
|
113
113
|
"type": "git",
|
|
114
|
-
"url": ""
|
|
114
|
+
"url": "https://github.com/khotan-io/khotan-data"
|
|
115
115
|
},
|
|
116
116
|
"engines": {
|
|
117
117
|
"node": ">=18"
|