clivly 0.1.0 → 0.2.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.
Files changed (117) hide show
  1. package/README.md +63 -3
  2. package/adapter-nLfZpgIG.d.cts +40 -0
  3. package/adapter-xs04z0KX.d.mts +40 -0
  4. package/auth-adapter-CBOKDhlc.cjs +11 -0
  5. package/auth-adapter-FEOR1nx-.d.mts +30 -0
  6. package/auth-adapter-wqnnEjo3.mjs +6 -0
  7. package/auth-adapter-wvfGKsOJ.d.cts +30 -0
  8. package/auth-better-auth.cjs +28 -0
  9. package/auth-better-auth.d.cts +33 -0
  10. package/auth-better-auth.d.mts +33 -0
  11. package/auth-better-auth.mjs +26 -0
  12. package/auth-clerk.cjs +34 -0
  13. package/auth-clerk.d.cts +32 -0
  14. package/auth-clerk.d.mts +32 -0
  15. package/auth-clerk.mjs +32 -0
  16. package/auth-workos.cjs +47 -0
  17. package/auth-workos.d.cts +30 -0
  18. package/auth-workos.d.mts +30 -0
  19. package/auth-workos.mjs +45 -0
  20. package/core-adapter.cjs +0 -0
  21. package/core-adapter.d.cts +2 -0
  22. package/core-adapter.d.mts +2 -0
  23. package/core-adapter.mjs +1 -0
  24. package/core-auth-adapter.cjs +3 -0
  25. package/core-auth-adapter.d.cts +2 -0
  26. package/core-auth-adapter.d.mts +2 -0
  27. package/core-auth-adapter.mjs +2 -0
  28. package/core-drizzle.cjs +32 -0
  29. package/core-drizzle.d.cts +21 -0
  30. package/core-drizzle.d.mts +21 -0
  31. package/core-drizzle.mjs +31 -0
  32. package/core-entity-config.cjs +13 -0
  33. package/core-entity-config.d.cts +2 -0
  34. package/core-entity-config.d.mts +2 -0
  35. package/core-entity-config.mjs +2 -0
  36. package/core-entity-heuristics.cjs +442 -0
  37. package/core-entity-heuristics.d.cts +68 -0
  38. package/core-entity-heuristics.d.mts +68 -0
  39. package/core-entity-heuristics.mjs +431 -0
  40. package/core-mapping-form.cjs +5 -0
  41. package/core-mapping-form.d.cts +2 -0
  42. package/core-mapping-form.d.mts +2 -0
  43. package/core-mapping-form.mjs +2 -0
  44. package/core-mapping-score.cjs +12 -0
  45. package/core-mapping-score.d.cts +2 -0
  46. package/core-mapping-score.d.mts +2 -0
  47. package/core-mapping-score.mjs +2 -0
  48. package/core-mappings-config.cjs +3 -0
  49. package/core-mappings-config.d.cts +2 -0
  50. package/core-mappings-config.d.mts +2 -0
  51. package/core-mappings-config.mjs +2 -0
  52. package/core-sync-engine.cjs +6 -0
  53. package/core-sync-engine.d.cts +2 -0
  54. package/core-sync-engine.d.mts +2 -0
  55. package/core-sync-engine.mjs +2 -0
  56. package/core-types.cjs +0 -0
  57. package/core-types.d.cts +2 -0
  58. package/core-types.d.mts +2 -0
  59. package/core-types.mjs +1 -0
  60. package/core-view-compiler.cjs +5 -0
  61. package/core-view-compiler.d.cts +2 -0
  62. package/core-view-compiler.d.mts +2 -0
  63. package/core-view-compiler.mjs +2 -0
  64. package/core.cjs +27 -0
  65. package/core.d.cts +9 -0
  66. package/core.d.mts +9 -0
  67. package/core.mjs +7 -0
  68. package/drizzle-meta-BGn0BqGb.cjs +9 -0
  69. package/drizzle-meta-CnC336L-.mjs +4 -0
  70. package/drizzle.cjs +107 -0
  71. package/drizzle.d.cts +28 -0
  72. package/drizzle.d.mts +28 -0
  73. package/drizzle.mjs +105 -0
  74. package/entity-config-Cvjo1cpv.cjs +4598 -0
  75. package/entity-config-D1DFyeUp.d.mts +2403 -0
  76. package/entity-config-DoR0khce.mjs +4533 -0
  77. package/entity-config-GczjD3y8.d.cts +2403 -0
  78. package/index.cjs +926 -0
  79. package/index.d.cts +56 -0
  80. package/index.d.mts +56 -0
  81. package/index.mjs +925 -0
  82. package/mapping-form-BHtPexzI.mjs +47 -0
  83. package/mapping-form-CUlFVfG8.d.cts +35 -0
  84. package/mapping-form-DdmDebC3.cjs +64 -0
  85. package/mapping-form-kjSiJaCX.d.mts +35 -0
  86. package/mapping-score-A2lRnlpk.d.mts +49 -0
  87. package/mapping-score-BJNe0lFn.mjs +87 -0
  88. package/mapping-score-BcjC0ZQs.d.cts +49 -0
  89. package/mapping-score-D9gfhtRu.cjs +146 -0
  90. package/mappings-config-CYPrzB3K.mjs +99 -0
  91. package/mappings-config-DTu_2cyx.cjs +104 -0
  92. package/mappings-config-DjRLCb2Q.d.cts +42 -0
  93. package/mappings-config-GxiYsSBQ.d.mts +42 -0
  94. package/namespace-probe-BtS0nXcr.d.cts +299 -0
  95. package/namespace-probe-CYMie-BI.d.mts +299 -0
  96. package/package.json +224 -21
  97. package/sdk-BZUn6wzs.mjs +764 -0
  98. package/sdk-CP_mYZa5.cjs +793 -0
  99. package/sdk.cjs +7 -0
  100. package/sdk.d.cts +33 -0
  101. package/sdk.d.mts +33 -0
  102. package/sdk.mjs +2 -0
  103. package/sync-engine-DUc0qWgo.cjs +230 -0
  104. package/sync-engine-DWnQPjV3.d.mts +183 -0
  105. package/sync-engine-DedXngop.mjs +207 -0
  106. package/sync-engine-uhfzKM-e.d.cts +183 -0
  107. package/types-C4POUcvk.d.mts +158 -0
  108. package/types-LJTBhkcN.d.cts +158 -0
  109. package/view-compiler-B4UYTvRM.d.cts +71 -0
  110. package/view-compiler-BHzbI9b7.cjs +202 -0
  111. package/view-compiler-CosFGar8.mjs +185 -0
  112. package/view-compiler-i_xFf-L0.d.mts +71 -0
  113. package/vite.cjs +38 -0
  114. package/vite.d.cts +23 -0
  115. package/vite.d.mts +23 -0
  116. package/vite.mjs +37 -0
  117. package/dist/index.mjs +0 -193
package/dist/index.mjs DELETED
@@ -1,193 +0,0 @@
1
- #!/usr/bin/env node
2
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
3
- import { join } from "node:path";
4
- //#region src/detect.ts
5
- const FRAMEWORK_MARKERS = [
6
- {
7
- framework: "nextjs",
8
- deps: ["next"]
9
- },
10
- {
11
- framework: "tanstack-start",
12
- deps: ["@tanstack/react-start"]
13
- },
14
- {
15
- framework: "sveltekit",
16
- deps: ["@sveltejs/kit"]
17
- },
18
- {
19
- framework: "remix",
20
- deps: ["@remix-run/react", "@remix-run/node"]
21
- },
22
- {
23
- framework: "nuxt",
24
- deps: ["nuxt"]
25
- }
26
- ];
27
- const ORM_MARKERS = [
28
- {
29
- orm: "drizzle",
30
- deps: ["drizzle-orm"]
31
- },
32
- {
33
- orm: "prisma",
34
- deps: ["@prisma/client", "prisma"]
35
- },
36
- {
37
- orm: "kysely",
38
- deps: ["kysely"]
39
- }
40
- ];
41
- const FRAMEWORK_LABELS = {
42
- nextjs: "Next.js",
43
- "tanstack-start": "TanStack Start",
44
- sveltekit: "SvelteKit",
45
- remix: "Remix",
46
- nuxt: "Nuxt",
47
- unknown: "Unknown"
48
- };
49
- function detectFramework(deps) {
50
- for (const { framework, deps: markers } of FRAMEWORK_MARKERS) if (markers.some((dep) => dep in deps)) return framework;
51
- return "unknown";
52
- }
53
- function detectOrm(deps) {
54
- for (const { orm, deps: markers } of ORM_MARKERS) if (markers.some((dep) => dep in deps)) return orm;
55
- return "unknown";
56
- }
57
- //#endregion
58
- //#region src/scaffold.ts
59
- const FRAMEWORK_ROUTES = {
60
- nextjs: [{
61
- path: "app/crm/[[...slug]]/page.tsx",
62
- description: "Mounts the Clivly SPA at /crm",
63
- owned: true
64
- }, {
65
- path: "app/api/clivly/[...path]/route.ts",
66
- description: "Clivly API handler",
67
- owned: true
68
- }],
69
- "tanstack-start": [{
70
- path: "src/routes/crm/$.tsx",
71
- description: "Mounts the Clivly SPA at /crm",
72
- owned: true
73
- }, {
74
- path: "src/routes/api/clivly/$.ts",
75
- description: "Clivly API handler",
76
- owned: true
77
- }],
78
- sveltekit: [{
79
- path: "src/routes/crm/[...slug]/+page.svelte",
80
- description: "Mounts the Clivly SPA at /crm",
81
- owned: true
82
- }, {
83
- path: "src/routes/api/clivly/[...path]/+server.ts",
84
- description: "Clivly API handler",
85
- owned: true
86
- }],
87
- remix: [{
88
- path: "app/routes/crm.$.tsx",
89
- description: "Mounts the Clivly SPA at /crm",
90
- owned: true
91
- }, {
92
- path: "app/routes/api.clivly.$.ts",
93
- description: "Clivly API handler",
94
- owned: true
95
- }],
96
- nuxt: [{
97
- path: "pages/crm/[...slug].vue",
98
- description: "Mounts the Clivly SPA at /crm",
99
- owned: true
100
- }, {
101
- path: "server/api/clivly/[...path].ts",
102
- description: "Clivly API handler",
103
- owned: true
104
- }],
105
- unknown: []
106
- };
107
- const COMMON_FILES = [{
108
- path: "drizzle/schema/clivly.ts",
109
- description: "crm_* schema fragment — merge into your schema",
110
- owned: false
111
- }, {
112
- path: "clivly.config.ts",
113
- description: "Your Clivly configuration",
114
- owned: false
115
- }];
116
- function planScaffold(framework) {
117
- return [...FRAMEWORK_ROUTES[framework] ?? [], ...COMMON_FILES];
118
- }
119
- function renderConfigTemplate(contactEntity) {
120
- return `import { defineClivlyConfig } from "clivly";
121
-
122
- export default defineClivlyConfig({
123
- // The host table Clivly treats as the contact entity.
124
- contactEntity: "${contactEntity}",
125
- contactFields: ["id", "email", "name", "created_at"],
126
- });
127
- `;
128
- }
129
- //#endregion
130
- //#region src/index.ts
131
- function readDeps(cwd) {
132
- const pkgPath = join(cwd, "package.json");
133
- if (!existsSync(pkgPath)) return {};
134
- try {
135
- const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
136
- return {
137
- ...pkg.dependencies,
138
- ...pkg.devDependencies
139
- };
140
- } catch {
141
- return {};
142
- }
143
- }
144
- function runInit(cwd, write) {
145
- const deps = readDeps(cwd);
146
- if (Object.keys(deps).length === 0) {
147
- process.stdout.write("No package.json found here. Run `clivly init` from your app root.\n");
148
- return 1;
149
- }
150
- const framework = detectFramework(deps);
151
- const orm = detectOrm(deps);
152
- process.stdout.write("\nClivly init\n");
153
- process.stdout.write(` Framework: ${FRAMEWORK_LABELS[framework]}\n`);
154
- process.stdout.write(` ORM: ${orm}\n\n`);
155
- if (framework === "unknown") {
156
- process.stdout.write("Could not detect a supported framework. Supported: Next.js, TanStack Start, SvelteKit, Remix, Nuxt.\n");
157
- return 1;
158
- }
159
- const files = planScaffold(framework);
160
- process.stdout.write("Will scaffold:\n");
161
- for (const file of files) {
162
- const tag = file.owned ? "generated" : "yours";
163
- process.stdout.write(` ${file.path} (${tag}) — ${file.description}\n`);
164
- }
165
- process.stdout.write("\n");
166
- if (write) {
167
- const configPath = join(cwd, "clivly.config.ts");
168
- if (existsSync(configPath)) process.stdout.write("clivly.config.ts already exists — skipped.\n");
169
- else {
170
- writeFileSync(configPath, renderConfigTemplate("users"), "utf8");
171
- process.stdout.write("Created clivly.config.ts\n");
172
- }
173
- } else process.stdout.write("Dry run. Re-run with --write to scaffold.\n");
174
- return 0;
175
- }
176
- function main(argv) {
177
- const [command, ...rest] = argv;
178
- const write = rest.includes("--write");
179
- switch (command) {
180
- case "init": return runInit(process.cwd(), write);
181
- case void 0:
182
- case "help":
183
- case "--help":
184
- process.stdout.write("clivly — embed a CRM in your app\n\nUsage:\n clivly init [--write] Detect your stack and scaffold Clivly\n");
185
- return 0;
186
- default:
187
- process.stdout.write(`Unknown command: ${command}\n`);
188
- return 1;
189
- }
190
- }
191
- process.exitCode = main(process.argv.slice(2));
192
- //#endregion
193
- export {};