clivly 0.3.0-next.7 → 0.4.0
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 +4 -0
- package/core-sync-engine.cjs +1 -1
- package/core-sync-engine.d.cts +1 -1
- package/core-sync-engine.d.mts +1 -1
- package/core-sync-engine.mjs +1 -1
- package/core-view-compiler.cjs +2 -1
- package/core-view-compiler.d.cts +2 -2
- package/core-view-compiler.d.mts +2 -2
- package/core-view-compiler.mjs +2 -2
- package/core.cjs +3 -2
- package/core.d.cts +3 -3
- package/core.d.mts +3 -3
- package/core.mjs +3 -3
- package/index.cjs +165 -10
- package/index.d.cts +5 -0
- package/index.d.mts +5 -0
- package/index.mjs +166 -11
- package/package.json +1 -1
- package/{sync-engine-DUc0qWgo.cjs → sync-engine-BtzkzKmY.cjs} +1 -1
- package/{sync-engine-DedXngop.mjs → sync-engine-D9vghQab.mjs} +1 -1
- package/{sync-engine-uhfzKM-e.d.cts → sync-engine-DIVMG9EV.d.cts} +1 -1
- package/{sync-engine-DWnQPjV3.d.mts → sync-engine-DLx243iw.d.mts} +1 -1
- package/{view-compiler-B4UYTvRM.d.cts → view-compiler-4HsRUTWH.d.cts} +2 -1
- package/{view-compiler-BHzbI9b7.cjs → view-compiler-BcgJINr7.cjs} +7 -1
- package/{view-compiler-i_xFf-L0.d.mts → view-compiler-BpIDExjd.d.mts} +2 -1
- package/{view-compiler-CosFGar8.mjs → view-compiler-DeZzx_jn.mjs} +2 -2
package/README.md
CHANGED
|
@@ -21,6 +21,10 @@ npx clivly push-schema # report your schema to Clivly without deploying
|
|
|
21
21
|
|
|
22
22
|
`ping` and `doctor` remain as aliases that run subsets of the `status` ladder.
|
|
23
23
|
|
|
24
|
+
Clivly's stable packages publish on npm's `latest` tag. Once installed, the
|
|
25
|
+
`npx clivly …` commands above use your local copy. Use `@next` only when you
|
|
26
|
+
are intentionally testing a prerelease cut.
|
|
27
|
+
|
|
24
28
|
## Imports
|
|
25
29
|
|
|
26
30
|
`clivly` is the consolidated public package. The CLI remains available as
|
package/core-sync-engine.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sync_engine = require("./sync-engine-
|
|
2
|
+
const require_sync_engine = require("./sync-engine-BtzkzKmY.cjs");
|
|
3
3
|
exports.computeSampleWarnings = require_sync_engine.computeSampleWarnings;
|
|
4
4
|
exports.previewSync = require_sync_engine.previewSync;
|
|
5
5
|
exports.reconcile = require_sync_engine.reconcile;
|
package/core-sync-engine.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as PreviewWarning, c as SyncResult, d as previewSync, f as reconcile, i as PreviewResult, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult, u as computeSampleWarnings } from "./sync-engine-
|
|
1
|
+
import { a as PreviewWarning, c as SyncResult, d as previewSync, f as reconcile, i as PreviewResult, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult, u as computeSampleWarnings } from "./sync-engine-DIVMG9EV.cjs";
|
|
2
2
|
export { EntitySyncResult, MirrorRecord, PersistAction, PreviewResult, PreviewWarning, SourceRow, SyncAction, SyncResult, SyncStore, computeSampleWarnings, previewSync, reconcile, runSync };
|
package/core-sync-engine.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as PreviewWarning, c as SyncResult, d as previewSync, f as reconcile, i as PreviewResult, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult, u as computeSampleWarnings } from "./sync-engine-
|
|
1
|
+
import { a as PreviewWarning, c as SyncResult, d as previewSync, f as reconcile, i as PreviewResult, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult, u as computeSampleWarnings } from "./sync-engine-DLx243iw.mjs";
|
|
2
2
|
export { EntitySyncResult, MirrorRecord, PersistAction, PreviewResult, PreviewWarning, SourceRow, SyncAction, SyncResult, SyncStore, computeSampleWarnings, previewSync, reconcile, runSync };
|
package/core-sync-engine.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as runSync, n as previewSync, r as reconcile, t as computeSampleWarnings } from "./sync-engine-
|
|
1
|
+
import { i as runSync, n as previewSync, r as reconcile, t as computeSampleWarnings } from "./sync-engine-D9vghQab.mjs";
|
|
2
2
|
export { computeSampleWarnings, previewSync, reconcile, runSync };
|
package/core-view-compiler.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_view_compiler = require("./view-compiler-
|
|
2
|
+
const require_view_compiler = require("./view-compiler-BcgJINr7.cjs");
|
|
3
|
+
exports.DEFAULT_VIEW_PREFIX = require_view_compiler.DEFAULT_VIEW_PREFIX;
|
|
3
4
|
exports.compileEntityView = require_view_compiler.compileEntityView;
|
|
4
5
|
exports.compileEntityViews = require_view_compiler.compileEntityViews;
|
|
5
6
|
exports.explainEntitiesConfig = require_view_compiler.explainEntitiesConfig;
|
package/core-view-compiler.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { CompileOptions, CompiledView, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig };
|
|
1
|
+
import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-4HsRUTWH.cjs";
|
|
2
|
+
export { CompileOptions, CompiledView, DEFAULT_VIEW_PREFIX, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig };
|
package/core-view-compiler.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { CompileOptions, CompiledView, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig };
|
|
1
|
+
import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-BpIDExjd.mjs";
|
|
2
|
+
export { CompileOptions, CompiledView, DEFAULT_VIEW_PREFIX, ExplainResult, compileEntityView, compileEntityViews, explainEntitiesConfig };
|
package/core-view-compiler.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
export { compileEntityView, compileEntityViews, explainEntitiesConfig };
|
|
1
|
+
import { i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-DeZzx_jn.mjs";
|
|
2
|
+
export { DEFAULT_VIEW_PREFIX, compileEntityView, compileEntityViews, explainEntitiesConfig };
|
package/core.cjs
CHANGED
|
@@ -3,11 +3,12 @@ const require_entity_config = require("./entity-config-DMuZpchz.cjs");
|
|
|
3
3
|
const require_auth_adapter = require("./auth-adapter-CBOKDhlc.cjs");
|
|
4
4
|
const require_mapping_form = require("./mapping-form-DdmDebC3.cjs");
|
|
5
5
|
const require_mappings_config = require("./mappings-config-DYZ_uOOB.cjs");
|
|
6
|
-
const require_view_compiler = require("./view-compiler-
|
|
7
|
-
const require_sync_engine = require("./sync-engine-
|
|
6
|
+
const require_view_compiler = require("./view-compiler-BcgJINr7.cjs");
|
|
7
|
+
const require_sync_engine = require("./sync-engine-BtzkzKmY.cjs");
|
|
8
8
|
exports.CANONICAL_FIELDS = require_entity_config.CANONICAL_FIELDS;
|
|
9
9
|
exports.CRM_CONCEPTS = require_entity_config.CRM_CONCEPTS;
|
|
10
10
|
exports.ClivlyConfigError = require_entity_config.ClivlyConfigError;
|
|
11
|
+
exports.DEFAULT_VIEW_PREFIX = require_view_compiler.DEFAULT_VIEW_PREFIX;
|
|
11
12
|
exports.MATERIALIZING_CONCEPTS = require_entity_config.MATERIALIZING_CONCEPTS;
|
|
12
13
|
exports.authCustom = require_auth_adapter.authCustom;
|
|
13
14
|
exports.buildFilterFromDiscriminator = require_mapping_form.buildFilterFromDiscriminator;
|
package/core.d.cts
CHANGED
|
@@ -4,6 +4,6 @@ import { t as CRMAdapter } from "./adapter-CXr12l4K.cjs";
|
|
|
4
4
|
import { C as validateEntitiesConfig, S as relationshipsSchema, _ as RelationshipsMap, a as ClivlyEntitiesConfig, b as filterSchema, c as ConfigValidationResult, d as FilterExpr, f as FilterValue, g as RelationshipVia, h as RelationshipSpec, i as ClivlyConfigError, l as CrmConcept, m as MaterializingConcept, n as CRM_CONCEPTS, o as ClivlyEntityConfig, p as MATERIALIZING_CONCEPTS, s as ConfigValidationError, t as CANONICAL_FIELDS, u as DiscoveredSchemaTable, v as defineClivlyConfig, x as relationshipSchema, y as entitiesConfigSchema } from "./entity-config-GczjD3y8.cjs";
|
|
5
5
|
import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-CUlFVfG8.cjs";
|
|
6
6
|
import { n as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-DjRLCb2Q.cjs";
|
|
7
|
-
import { a as
|
|
8
|
-
import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine-
|
|
9
|
-
export { Activity, ActivityType, CANONICAL_FIELDS, CRMAdapter, CRM_CONCEPTS, ClivlyAuthAdapter, ClivlyConfigError, ClivlyEntitiesConfig, ClivlyEntityConfig, ClivlyUser, Company, CompileOptions, CompiledView, ConfigValidationError, ConfigValidationResult, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmConcept, CrmMembership, CrmRole, Deal, DealStage, DiscoveredSchemaTable, EntityMappingRow, EntitySyncResult, ExplainResult, FilterExpr, FilterValue, MATERIALIZING_CONCEPTS, MaterializingConcept, MembershipResolver, MirrorRecord, Note, PersistAction, RecordSource, RelationshipCandidate, RelationshipSpec, RelationshipVia, RelationshipsMap, SourceRow, SyncAction, SyncResult, SyncStore, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateContactInput, UpdateDealInput, UpdateTaskInput, authCustom, buildFilterFromDiscriminator, buildRelationships, compileEntityView, compileEntityViews, defineClivlyConfig, entitiesConfigSchema, explainEntitiesConfig, filterSchema, mappingsToEntitiesConfig, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, validateEntitiesConfig };
|
|
7
|
+
import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-4HsRUTWH.cjs";
|
|
8
|
+
import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine-DIVMG9EV.cjs";
|
|
9
|
+
export { Activity, ActivityType, CANONICAL_FIELDS, CRMAdapter, CRM_CONCEPTS, ClivlyAuthAdapter, ClivlyConfigError, ClivlyEntitiesConfig, ClivlyEntityConfig, ClivlyUser, Company, CompileOptions, CompiledView, ConfigValidationError, ConfigValidationResult, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmConcept, CrmMembership, CrmRole, DEFAULT_VIEW_PREFIX, Deal, DealStage, DiscoveredSchemaTable, EntityMappingRow, EntitySyncResult, ExplainResult, FilterExpr, FilterValue, MATERIALIZING_CONCEPTS, MaterializingConcept, MembershipResolver, MirrorRecord, Note, PersistAction, RecordSource, RelationshipCandidate, RelationshipSpec, RelationshipVia, RelationshipsMap, SourceRow, SyncAction, SyncResult, SyncStore, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateContactInput, UpdateDealInput, UpdateTaskInput, authCustom, buildFilterFromDiscriminator, buildRelationships, compileEntityView, compileEntityViews, defineClivlyConfig, entitiesConfigSchema, explainEntitiesConfig, filterSchema, mappingsToEntitiesConfig, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, validateEntitiesConfig };
|
package/core.d.mts
CHANGED
|
@@ -4,6 +4,6 @@ import { t as CRMAdapter } from "./adapter-CvNBD_3y.mjs";
|
|
|
4
4
|
import { C as validateEntitiesConfig, S as relationshipsSchema, _ as RelationshipsMap, a as ClivlyEntitiesConfig, b as filterSchema, c as ConfigValidationResult, d as FilterExpr, f as FilterValue, g as RelationshipVia, h as RelationshipSpec, i as ClivlyConfigError, l as CrmConcept, m as MaterializingConcept, n as CRM_CONCEPTS, o as ClivlyEntityConfig, p as MATERIALIZING_CONCEPTS, s as ConfigValidationError, t as CANONICAL_FIELDS, u as DiscoveredSchemaTable, v as defineClivlyConfig, x as relationshipSchema, y as entitiesConfigSchema } from "./entity-config-D1DFyeUp.mjs";
|
|
5
5
|
import { i as relationshipViaSignature, n as buildFilterFromDiscriminator, r as buildRelationships, t as RelationshipCandidate } from "./mapping-form-kjSiJaCX.mjs";
|
|
6
6
|
import { n as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings-config-GxiYsSBQ.mjs";
|
|
7
|
-
import { a as
|
|
8
|
-
import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine-
|
|
9
|
-
export { Activity, ActivityType, CANONICAL_FIELDS, CRMAdapter, CRM_CONCEPTS, ClivlyAuthAdapter, ClivlyConfigError, ClivlyEntitiesConfig, ClivlyEntityConfig, ClivlyUser, Company, CompileOptions, CompiledView, ConfigValidationError, ConfigValidationResult, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmConcept, CrmMembership, CrmRole, Deal, DealStage, DiscoveredSchemaTable, EntityMappingRow, EntitySyncResult, ExplainResult, FilterExpr, FilterValue, MATERIALIZING_CONCEPTS, MaterializingConcept, MembershipResolver, MirrorRecord, Note, PersistAction, RecordSource, RelationshipCandidate, RelationshipSpec, RelationshipVia, RelationshipsMap, SourceRow, SyncAction, SyncResult, SyncStore, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateContactInput, UpdateDealInput, UpdateTaskInput, authCustom, buildFilterFromDiscriminator, buildRelationships, compileEntityView, compileEntityViews, defineClivlyConfig, entitiesConfigSchema, explainEntitiesConfig, filterSchema, mappingsToEntitiesConfig, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, validateEntitiesConfig };
|
|
7
|
+
import { a as compileEntityView, i as ExplainResult, n as CompiledView, o as compileEntityViews, r as DEFAULT_VIEW_PREFIX, s as explainEntitiesConfig, t as CompileOptions } from "./view-compiler-BpIDExjd.mjs";
|
|
8
|
+
import { c as SyncResult, f as reconcile, l as SyncStore, n as MirrorRecord, o as SourceRow, p as runSync, r as PersistAction, s as SyncAction, t as EntitySyncResult } from "./sync-engine-DLx243iw.mjs";
|
|
9
|
+
export { Activity, ActivityType, CANONICAL_FIELDS, CRMAdapter, CRM_CONCEPTS, ClivlyAuthAdapter, ClivlyConfigError, ClivlyEntitiesConfig, ClivlyEntityConfig, ClivlyUser, Company, CompileOptions, CompiledView, ConfigValidationError, ConfigValidationResult, Contact, ContactFilters, ContactStatus, CreateActivityInput, CreateCompanyInput, CreateContactInput, CreateDealInput, CreateTaskInput, CrmConcept, CrmMembership, CrmRole, DEFAULT_VIEW_PREFIX, Deal, DealStage, DiscoveredSchemaTable, EntityMappingRow, EntitySyncResult, ExplainResult, FilterExpr, FilterValue, MATERIALIZING_CONCEPTS, MaterializingConcept, MembershipResolver, MirrorRecord, Note, PersistAction, RecordSource, RelationshipCandidate, RelationshipSpec, RelationshipVia, RelationshipsMap, SourceRow, SyncAction, SyncResult, SyncStore, Task, TaskEntityType, TaskFilters, TaskPriority, TaskStatus, UpdateContactInput, UpdateDealInput, UpdateTaskInput, authCustom, buildFilterFromDiscriminator, buildRelationships, compileEntityView, compileEntityViews, defineClivlyConfig, entitiesConfigSchema, explainEntitiesConfig, filterSchema, mappingsToEntitiesConfig, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, validateEntitiesConfig };
|
package/core.mjs
CHANGED
|
@@ -2,6 +2,6 @@ import { a as MATERIALIZING_CONCEPTS, c as filterSchema, d as validateEntitiesCo
|
|
|
2
2
|
import { t as authCustom } from "./auth-adapter-wqnnEjo3.mjs";
|
|
3
3
|
import { n as buildRelationships, r as relationshipViaSignature, t as buildFilterFromDiscriminator } from "./mapping-form-BHtPexzI.mjs";
|
|
4
4
|
import { t as mappingsToEntitiesConfig } from "./mappings-config-CNTZRD4g.mjs";
|
|
5
|
-
import { n as
|
|
6
|
-
import { i as runSync, r as reconcile } from "./sync-engine-
|
|
7
|
-
export { CANONICAL_FIELDS, CRM_CONCEPTS, ClivlyConfigError, MATERIALIZING_CONCEPTS, authCustom, buildFilterFromDiscriminator, buildRelationships, compileEntityView, compileEntityViews, defineClivlyConfig, entitiesConfigSchema, explainEntitiesConfig, filterSchema, mappingsToEntitiesConfig, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, validateEntitiesConfig };
|
|
5
|
+
import { i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-DeZzx_jn.mjs";
|
|
6
|
+
import { i as runSync, r as reconcile } from "./sync-engine-D9vghQab.mjs";
|
|
7
|
+
export { CANONICAL_FIELDS, CRM_CONCEPTS, ClivlyConfigError, DEFAULT_VIEW_PREFIX, MATERIALIZING_CONCEPTS, authCustom, buildFilterFromDiscriminator, buildRelationships, compileEntityView, compileEntityViews, defineClivlyConfig, entitiesConfigSchema, explainEntitiesConfig, filterSchema, mappingsToEntitiesConfig, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, validateEntitiesConfig };
|
package/index.cjs
CHANGED
|
@@ -106,8 +106,13 @@ const LOCKFILES = [
|
|
|
106
106
|
}
|
|
107
107
|
];
|
|
108
108
|
function detectPackageManager(cwd, fileExists = node_fs.existsSync) {
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
let current = cwd;
|
|
110
|
+
while (true) {
|
|
111
|
+
for (const { file, pm } of LOCKFILES) if (fileExists((0, node_path.join)(current, file))) return pm;
|
|
112
|
+
const parent = (0, node_path.dirname)(current);
|
|
113
|
+
if (parent === current) return "npm";
|
|
114
|
+
current = parent;
|
|
115
|
+
}
|
|
111
116
|
}
|
|
112
117
|
function addCommand(pm, packages) {
|
|
113
118
|
return {
|
|
@@ -748,15 +753,15 @@ function toScoredTable(table) {
|
|
|
748
753
|
}))
|
|
749
754
|
};
|
|
750
755
|
}
|
|
751
|
-
function rankCandidates(tables, concept) {
|
|
756
|
+
function rankCandidates$1(tables, concept) {
|
|
752
757
|
return tables.map((t) => ({
|
|
753
758
|
t,
|
|
754
759
|
m: require_core_entity_heuristics.matchesConcept(t.tableName, concept)
|
|
755
760
|
})).filter((c) => Boolean(c.m)).sort((a, b) => Number(b.m.exact) - Number(a.m.exact)).map((c) => c.t);
|
|
756
761
|
}
|
|
757
762
|
function selectEntities(tables) {
|
|
758
|
-
const contactCands = rankCandidates(tables, "contact");
|
|
759
|
-
const companyCands = rankCandidates(tables, "company");
|
|
763
|
+
const contactCands = rankCandidates$1(tables, "contact");
|
|
764
|
+
const companyCands = rankCandidates$1(tables, "company");
|
|
760
765
|
const contactNames = new Set(contactCands.map((t) => t.tableName));
|
|
761
766
|
const companyNames = new Set(companyCands.map((t) => t.tableName));
|
|
762
767
|
const contactExclusive = contactCands.filter((t) => !companyNames.has(t.tableName));
|
|
@@ -1359,6 +1364,127 @@ function resolveSchemaPath(opts) {
|
|
|
1359
1364
|
return null;
|
|
1360
1365
|
}
|
|
1361
1366
|
//#endregion
|
|
1367
|
+
//#region src/resolve-target-app.ts
|
|
1368
|
+
function readPackageJson(dir) {
|
|
1369
|
+
const path = (0, node_path.join)(dir, "package.json");
|
|
1370
|
+
if (!(0, node_fs.existsSync)(path)) return null;
|
|
1371
|
+
try {
|
|
1372
|
+
return JSON.parse((0, node_fs.readFileSync)(path, "utf8"));
|
|
1373
|
+
} catch {
|
|
1374
|
+
return null;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
function packageDeps(dir) {
|
|
1378
|
+
const pkg = readPackageJson(dir);
|
|
1379
|
+
return {
|
|
1380
|
+
...pkg?.dependencies,
|
|
1381
|
+
...pkg?.devDependencies
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
function isDrizzleApp(dir) {
|
|
1385
|
+
const deps = packageDeps(dir);
|
|
1386
|
+
return detectFramework(deps) !== "unknown" && detectOrm(deps) === "drizzle";
|
|
1387
|
+
}
|
|
1388
|
+
function parentDir(dir) {
|
|
1389
|
+
const parent = (0, node_path.dirname)(dir);
|
|
1390
|
+
return parent === dir ? null : parent;
|
|
1391
|
+
}
|
|
1392
|
+
function findNearestPackageDir(start) {
|
|
1393
|
+
let current = (0, node_path.resolve)(start);
|
|
1394
|
+
while (true) {
|
|
1395
|
+
if ((0, node_fs.existsSync)((0, node_path.join)(current, "package.json"))) return current;
|
|
1396
|
+
const parent = parentDir(current);
|
|
1397
|
+
if (!parent) return null;
|
|
1398
|
+
current = parent;
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
function readWorkspaceGlobs(dir) {
|
|
1402
|
+
const pkg = readPackageJson(dir);
|
|
1403
|
+
const workspaces = Array.isArray(pkg?.workspaces) ? pkg.workspaces : pkg?.workspaces?.packages;
|
|
1404
|
+
if (Array.isArray(workspaces) && workspaces.length > 0) return workspaces;
|
|
1405
|
+
const pnpmWorkspacePath = (0, node_path.join)(dir, "pnpm-workspace.yaml");
|
|
1406
|
+
if (!(0, node_fs.existsSync)(pnpmWorkspacePath)) return [];
|
|
1407
|
+
try {
|
|
1408
|
+
return (0, node_fs.readFileSync)(pnpmWorkspacePath, "utf8").split("\n").map((line) => line.trim()).filter((line) => line.startsWith("- ")).map((line) => line.slice(2).trim().replace(/^['"]|['"]$/g, "")).filter((glob) => glob.length > 0 && !glob.startsWith("!"));
|
|
1409
|
+
} catch {
|
|
1410
|
+
return [];
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
function expandWorkspaceGlob(root, pattern) {
|
|
1414
|
+
if (pattern.endsWith("/*")) {
|
|
1415
|
+
const base = (0, node_path.join)(root, pattern.slice(0, -2));
|
|
1416
|
+
if (!(0, node_fs.existsSync)(base)) return [];
|
|
1417
|
+
try {
|
|
1418
|
+
return (0, node_fs.readdirSync)(base, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => (0, node_path.join)(base, entry.name)).filter((dir) => (0, node_fs.existsSync)((0, node_path.join)(dir, "package.json")));
|
|
1419
|
+
} catch {
|
|
1420
|
+
return [];
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
const exact = (0, node_path.join)(root, pattern);
|
|
1424
|
+
return (0, node_fs.existsSync)((0, node_path.join)(exact, "package.json")) ? [exact] : [];
|
|
1425
|
+
}
|
|
1426
|
+
function findWorkspaceRoot(start) {
|
|
1427
|
+
let current = (0, node_path.resolve)(start);
|
|
1428
|
+
while (true) {
|
|
1429
|
+
if (readWorkspaceGlobs(current).length > 0) return current;
|
|
1430
|
+
const parent = parentDir(current);
|
|
1431
|
+
if (!parent) return null;
|
|
1432
|
+
current = parent;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
function uniquePaths(paths) {
|
|
1436
|
+
return [...new Set(paths.map((path) => (0, node_path.resolve)(path)))];
|
|
1437
|
+
}
|
|
1438
|
+
function rankCandidates(paths, start) {
|
|
1439
|
+
const rootRelative = (path) => path.split("/apps/").length > 1;
|
|
1440
|
+
const distance = (path) => Math.abs((0, node_path.resolve)(path).split("/").length - (0, node_path.resolve)(start).split("/").length);
|
|
1441
|
+
return [...paths].sort((a, b) => {
|
|
1442
|
+
const appBias = Number(rootRelative(b)) - Number(rootRelative(a));
|
|
1443
|
+
if (appBias !== 0) return appBias;
|
|
1444
|
+
return distance(a) - distance(b) || a.localeCompare(b);
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
function resolveTargetApp(start) {
|
|
1448
|
+
const nearestPackageDir = findNearestPackageDir(start);
|
|
1449
|
+
if (nearestPackageDir && isDrizzleApp(nearestPackageDir)) return {
|
|
1450
|
+
cwd: nearestPackageDir,
|
|
1451
|
+
reason: "direct"
|
|
1452
|
+
};
|
|
1453
|
+
const workspaceRoot = findWorkspaceRoot(start);
|
|
1454
|
+
if (!workspaceRoot) return {
|
|
1455
|
+
cwd: nearestPackageDir ?? (0, node_path.resolve)(start),
|
|
1456
|
+
reason: "direct"
|
|
1457
|
+
};
|
|
1458
|
+
const workspaceCandidates = uniquePaths(readWorkspaceGlobs(workspaceRoot).flatMap((pattern) => expandWorkspaceGlob(workspaceRoot, pattern)).filter((dir) => isDrizzleApp(dir)));
|
|
1459
|
+
if (workspaceCandidates.length === 0) return {
|
|
1460
|
+
cwd: nearestPackageDir ?? (0, node_path.resolve)(start),
|
|
1461
|
+
reason: "direct"
|
|
1462
|
+
};
|
|
1463
|
+
if (workspaceCandidates.length === 1) {
|
|
1464
|
+
const onlyCandidate = workspaceCandidates[0];
|
|
1465
|
+
if (!onlyCandidate) return {
|
|
1466
|
+
cwd: nearestPackageDir ?? (0, node_path.resolve)(start),
|
|
1467
|
+
reason: "direct"
|
|
1468
|
+
};
|
|
1469
|
+
return {
|
|
1470
|
+
cwd: onlyCandidate,
|
|
1471
|
+
reason: "workspace-match"
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
const ranked = rankCandidates(workspaceCandidates, start);
|
|
1475
|
+
if (nearestPackageDir) {
|
|
1476
|
+
for (const candidate of ranked) if (start.startsWith(`${candidate}/`) || start === candidate) return {
|
|
1477
|
+
cwd: candidate,
|
|
1478
|
+
reason: "workspace-match"
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
return {
|
|
1482
|
+
cwd: nearestPackageDir ?? workspaceRoot,
|
|
1483
|
+
reason: "workspace-ambiguous",
|
|
1484
|
+
candidates: ranked
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
//#endregion
|
|
1362
1488
|
//#region src/status-ladder.ts
|
|
1363
1489
|
const SATISFYING = new Set(["pass", "warn"]);
|
|
1364
1490
|
function unmetPrerequisites(stage, satisfied) {
|
|
@@ -1768,11 +1894,16 @@ function pairingSkipReason(options, deps) {
|
|
|
1768
1894
|
if (!deps.isInteractive()) return "non-interactive shell";
|
|
1769
1895
|
return null;
|
|
1770
1896
|
}
|
|
1897
|
+
function resolveRuntimeInstallSpec(deps, env = process.env) {
|
|
1898
|
+
const override = env.CLIVLY_INSTALL_SPEC?.trim();
|
|
1899
|
+
if (override) return override;
|
|
1900
|
+
const version = deps.readOwnVersion();
|
|
1901
|
+
return version ? `clivly@${version}` : "clivly";
|
|
1902
|
+
}
|
|
1771
1903
|
async function scaffold(options, deps, plan) {
|
|
1772
1904
|
const { out } = deps;
|
|
1773
1905
|
const pm = deps.detectPackageManager(options.cwd);
|
|
1774
|
-
const
|
|
1775
|
-
const packages = [version ? `clivly@${version}` : "clivly", ...deps.authWiring.packages];
|
|
1906
|
+
const packages = [resolveRuntimeInstallSpec(deps), ...deps.authWiring.packages];
|
|
1776
1907
|
const mutations = mutationsFor(options, deps, plan);
|
|
1777
1908
|
if (options.dryRun) {
|
|
1778
1909
|
out(`\nWould install (${pm}): ${packages.join(", ")}\n`);
|
|
@@ -1798,13 +1929,37 @@ async function scaffold(options, deps, plan) {
|
|
|
1798
1929
|
printNextSteps(out, deps.authWiring.complete, loginRan);
|
|
1799
1930
|
return plan.contactDetected ? 0 : 1;
|
|
1800
1931
|
}
|
|
1932
|
+
function normalizeAppRoot(options) {
|
|
1933
|
+
const resolution = (options.resolveTargetApp ?? resolveTargetApp)(options.cwd);
|
|
1934
|
+
const out = options.out ?? ((line) => process.stdout.write(line));
|
|
1935
|
+
if (resolution.reason === "workspace-ambiguous") {
|
|
1936
|
+
out([
|
|
1937
|
+
"Found more than one Drizzle app in this workspace.",
|
|
1938
|
+
"Run `clivly init` from the app directory you want to wire, or pass `--schema` from there.",
|
|
1939
|
+
...(resolution.candidates ?? []).map((path) => ` • ${path}`),
|
|
1940
|
+
""
|
|
1941
|
+
].join("\n"));
|
|
1942
|
+
return {
|
|
1943
|
+
cwd: resolution.cwd,
|
|
1944
|
+
code: 1
|
|
1945
|
+
};
|
|
1946
|
+
}
|
|
1947
|
+
if (resolution.cwd !== options.cwd) out(`Using app root: ${resolution.cwd}\n`);
|
|
1948
|
+
return { cwd: resolution.cwd };
|
|
1949
|
+
}
|
|
1801
1950
|
async function runInit(options) {
|
|
1802
|
-
const
|
|
1803
|
-
|
|
1951
|
+
const normalized = normalizeAppRoot(options);
|
|
1952
|
+
if (normalized.code) return normalized.code;
|
|
1953
|
+
const resolvedOptions = {
|
|
1954
|
+
...options,
|
|
1955
|
+
cwd: normalized.cwd
|
|
1956
|
+
};
|
|
1957
|
+
const deps = resolveInitDeps(resolvedOptions);
|
|
1958
|
+
const acquired = await acquireSchema(resolvedOptions, deps);
|
|
1804
1959
|
if ("code" in acquired) return acquired.code;
|
|
1805
1960
|
const plan = planInit(acquired);
|
|
1806
1961
|
printPlan(deps.out, plan);
|
|
1807
|
-
return scaffold(
|
|
1962
|
+
return scaffold(resolvedOptions, deps, plan);
|
|
1808
1963
|
}
|
|
1809
1964
|
function hasCloudflaredOnPath() {
|
|
1810
1965
|
const pathEnv = process.env.PATH ?? "";
|
package/index.d.cts
CHANGED
|
@@ -62,6 +62,11 @@ interface RunInitOptions {
|
|
|
62
62
|
readEnv?: (cwd: string) => string;
|
|
63
63
|
readOwnVersion?: () => string | undefined;
|
|
64
64
|
resolveSchemaPath?: (cwd: string) => string | null;
|
|
65
|
+
resolveTargetApp?: (cwd: string) => {
|
|
66
|
+
candidates?: string[];
|
|
67
|
+
cwd: string;
|
|
68
|
+
reason: "direct" | "workspace-match" | "workspace-ambiguous";
|
|
69
|
+
};
|
|
65
70
|
schemaFlag?: string;
|
|
66
71
|
writeConfig?: (path: string, contents: string) => void;
|
|
67
72
|
writeEnv?: (cwd: string, contents: string) => void;
|
package/index.d.mts
CHANGED
|
@@ -62,6 +62,11 @@ interface RunInitOptions {
|
|
|
62
62
|
readEnv?: (cwd: string) => string;
|
|
63
63
|
readOwnVersion?: () => string | undefined;
|
|
64
64
|
resolveSchemaPath?: (cwd: string) => string | null;
|
|
65
|
+
resolveTargetApp?: (cwd: string) => {
|
|
66
|
+
candidates?: string[];
|
|
67
|
+
cwd: string;
|
|
68
|
+
reason: "direct" | "workspace-match" | "workspace-ambiguous";
|
|
69
|
+
};
|
|
65
70
|
schemaFlag?: string;
|
|
66
71
|
writeConfig?: (path: string, contents: string) => void;
|
|
67
72
|
writeEnv?: (cwd: string, contents: string) => void;
|
package/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { matchesConcept, requiredFieldsFor, scoreFieldMap, scoreRelationships, s
|
|
|
5
5
|
import { t as createClivlySDK } from "./sdk-DdzBxgMx.mjs";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
8
|
-
import { accessSync, constants, existsSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { accessSync, constants, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { hostname } from "node:os";
|
|
10
10
|
import { delimiter, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
11
11
|
import { createInterface } from "node:readline/promises";
|
|
@@ -105,8 +105,13 @@ const LOCKFILES = [
|
|
|
105
105
|
}
|
|
106
106
|
];
|
|
107
107
|
function detectPackageManager(cwd, fileExists = existsSync) {
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
let current = cwd;
|
|
109
|
+
while (true) {
|
|
110
|
+
for (const { file, pm } of LOCKFILES) if (fileExists(join(current, file))) return pm;
|
|
111
|
+
const parent = dirname(current);
|
|
112
|
+
if (parent === current) return "npm";
|
|
113
|
+
current = parent;
|
|
114
|
+
}
|
|
110
115
|
}
|
|
111
116
|
function addCommand(pm, packages) {
|
|
112
117
|
return {
|
|
@@ -747,15 +752,15 @@ function toScoredTable(table) {
|
|
|
747
752
|
}))
|
|
748
753
|
};
|
|
749
754
|
}
|
|
750
|
-
function rankCandidates(tables, concept) {
|
|
755
|
+
function rankCandidates$1(tables, concept) {
|
|
751
756
|
return tables.map((t) => ({
|
|
752
757
|
t,
|
|
753
758
|
m: matchesConcept(t.tableName, concept)
|
|
754
759
|
})).filter((c) => Boolean(c.m)).sort((a, b) => Number(b.m.exact) - Number(a.m.exact)).map((c) => c.t);
|
|
755
760
|
}
|
|
756
761
|
function selectEntities(tables) {
|
|
757
|
-
const contactCands = rankCandidates(tables, "contact");
|
|
758
|
-
const companyCands = rankCandidates(tables, "company");
|
|
762
|
+
const contactCands = rankCandidates$1(tables, "contact");
|
|
763
|
+
const companyCands = rankCandidates$1(tables, "company");
|
|
759
764
|
const contactNames = new Set(contactCands.map((t) => t.tableName));
|
|
760
765
|
const companyNames = new Set(companyCands.map((t) => t.tableName));
|
|
761
766
|
const contactExclusive = contactCands.filter((t) => !companyNames.has(t.tableName));
|
|
@@ -1358,6 +1363,127 @@ function resolveSchemaPath(opts) {
|
|
|
1358
1363
|
return null;
|
|
1359
1364
|
}
|
|
1360
1365
|
//#endregion
|
|
1366
|
+
//#region src/resolve-target-app.ts
|
|
1367
|
+
function readPackageJson(dir) {
|
|
1368
|
+
const path = join(dir, "package.json");
|
|
1369
|
+
if (!existsSync(path)) return null;
|
|
1370
|
+
try {
|
|
1371
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
1372
|
+
} catch {
|
|
1373
|
+
return null;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
function packageDeps(dir) {
|
|
1377
|
+
const pkg = readPackageJson(dir);
|
|
1378
|
+
return {
|
|
1379
|
+
...pkg?.dependencies,
|
|
1380
|
+
...pkg?.devDependencies
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
function isDrizzleApp(dir) {
|
|
1384
|
+
const deps = packageDeps(dir);
|
|
1385
|
+
return detectFramework(deps) !== "unknown" && detectOrm(deps) === "drizzle";
|
|
1386
|
+
}
|
|
1387
|
+
function parentDir(dir) {
|
|
1388
|
+
const parent = dirname(dir);
|
|
1389
|
+
return parent === dir ? null : parent;
|
|
1390
|
+
}
|
|
1391
|
+
function findNearestPackageDir(start) {
|
|
1392
|
+
let current = resolve(start);
|
|
1393
|
+
while (true) {
|
|
1394
|
+
if (existsSync(join(current, "package.json"))) return current;
|
|
1395
|
+
const parent = parentDir(current);
|
|
1396
|
+
if (!parent) return null;
|
|
1397
|
+
current = parent;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
function readWorkspaceGlobs(dir) {
|
|
1401
|
+
const pkg = readPackageJson(dir);
|
|
1402
|
+
const workspaces = Array.isArray(pkg?.workspaces) ? pkg.workspaces : pkg?.workspaces?.packages;
|
|
1403
|
+
if (Array.isArray(workspaces) && workspaces.length > 0) return workspaces;
|
|
1404
|
+
const pnpmWorkspacePath = join(dir, "pnpm-workspace.yaml");
|
|
1405
|
+
if (!existsSync(pnpmWorkspacePath)) return [];
|
|
1406
|
+
try {
|
|
1407
|
+
return readFileSync(pnpmWorkspacePath, "utf8").split("\n").map((line) => line.trim()).filter((line) => line.startsWith("- ")).map((line) => line.slice(2).trim().replace(/^['"]|['"]$/g, "")).filter((glob) => glob.length > 0 && !glob.startsWith("!"));
|
|
1408
|
+
} catch {
|
|
1409
|
+
return [];
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
function expandWorkspaceGlob(root, pattern) {
|
|
1413
|
+
if (pattern.endsWith("/*")) {
|
|
1414
|
+
const base = join(root, pattern.slice(0, -2));
|
|
1415
|
+
if (!existsSync(base)) return [];
|
|
1416
|
+
try {
|
|
1417
|
+
return readdirSync(base, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join(base, entry.name)).filter((dir) => existsSync(join(dir, "package.json")));
|
|
1418
|
+
} catch {
|
|
1419
|
+
return [];
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
const exact = join(root, pattern);
|
|
1423
|
+
return existsSync(join(exact, "package.json")) ? [exact] : [];
|
|
1424
|
+
}
|
|
1425
|
+
function findWorkspaceRoot(start) {
|
|
1426
|
+
let current = resolve(start);
|
|
1427
|
+
while (true) {
|
|
1428
|
+
if (readWorkspaceGlobs(current).length > 0) return current;
|
|
1429
|
+
const parent = parentDir(current);
|
|
1430
|
+
if (!parent) return null;
|
|
1431
|
+
current = parent;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
function uniquePaths(paths) {
|
|
1435
|
+
return [...new Set(paths.map((path) => resolve(path)))];
|
|
1436
|
+
}
|
|
1437
|
+
function rankCandidates(paths, start) {
|
|
1438
|
+
const rootRelative = (path) => path.split("/apps/").length > 1;
|
|
1439
|
+
const distance = (path) => Math.abs(resolve(path).split("/").length - resolve(start).split("/").length);
|
|
1440
|
+
return [...paths].sort((a, b) => {
|
|
1441
|
+
const appBias = Number(rootRelative(b)) - Number(rootRelative(a));
|
|
1442
|
+
if (appBias !== 0) return appBias;
|
|
1443
|
+
return distance(a) - distance(b) || a.localeCompare(b);
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
function resolveTargetApp(start) {
|
|
1447
|
+
const nearestPackageDir = findNearestPackageDir(start);
|
|
1448
|
+
if (nearestPackageDir && isDrizzleApp(nearestPackageDir)) return {
|
|
1449
|
+
cwd: nearestPackageDir,
|
|
1450
|
+
reason: "direct"
|
|
1451
|
+
};
|
|
1452
|
+
const workspaceRoot = findWorkspaceRoot(start);
|
|
1453
|
+
if (!workspaceRoot) return {
|
|
1454
|
+
cwd: nearestPackageDir ?? resolve(start),
|
|
1455
|
+
reason: "direct"
|
|
1456
|
+
};
|
|
1457
|
+
const workspaceCandidates = uniquePaths(readWorkspaceGlobs(workspaceRoot).flatMap((pattern) => expandWorkspaceGlob(workspaceRoot, pattern)).filter((dir) => isDrizzleApp(dir)));
|
|
1458
|
+
if (workspaceCandidates.length === 0) return {
|
|
1459
|
+
cwd: nearestPackageDir ?? resolve(start),
|
|
1460
|
+
reason: "direct"
|
|
1461
|
+
};
|
|
1462
|
+
if (workspaceCandidates.length === 1) {
|
|
1463
|
+
const onlyCandidate = workspaceCandidates[0];
|
|
1464
|
+
if (!onlyCandidate) return {
|
|
1465
|
+
cwd: nearestPackageDir ?? resolve(start),
|
|
1466
|
+
reason: "direct"
|
|
1467
|
+
};
|
|
1468
|
+
return {
|
|
1469
|
+
cwd: onlyCandidate,
|
|
1470
|
+
reason: "workspace-match"
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1473
|
+
const ranked = rankCandidates(workspaceCandidates, start);
|
|
1474
|
+
if (nearestPackageDir) {
|
|
1475
|
+
for (const candidate of ranked) if (start.startsWith(`${candidate}/`) || start === candidate) return {
|
|
1476
|
+
cwd: candidate,
|
|
1477
|
+
reason: "workspace-match"
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
return {
|
|
1481
|
+
cwd: nearestPackageDir ?? workspaceRoot,
|
|
1482
|
+
reason: "workspace-ambiguous",
|
|
1483
|
+
candidates: ranked
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
//#endregion
|
|
1361
1487
|
//#region src/status-ladder.ts
|
|
1362
1488
|
const SATISFYING = new Set(["pass", "warn"]);
|
|
1363
1489
|
function unmetPrerequisites(stage, satisfied) {
|
|
@@ -1767,11 +1893,16 @@ function pairingSkipReason(options, deps) {
|
|
|
1767
1893
|
if (!deps.isInteractive()) return "non-interactive shell";
|
|
1768
1894
|
return null;
|
|
1769
1895
|
}
|
|
1896
|
+
function resolveRuntimeInstallSpec(deps, env = process.env) {
|
|
1897
|
+
const override = env.CLIVLY_INSTALL_SPEC?.trim();
|
|
1898
|
+
if (override) return override;
|
|
1899
|
+
const version = deps.readOwnVersion();
|
|
1900
|
+
return version ? `clivly@${version}` : "clivly";
|
|
1901
|
+
}
|
|
1770
1902
|
async function scaffold(options, deps, plan) {
|
|
1771
1903
|
const { out } = deps;
|
|
1772
1904
|
const pm = deps.detectPackageManager(options.cwd);
|
|
1773
|
-
const
|
|
1774
|
-
const packages = [version ? `clivly@${version}` : "clivly", ...deps.authWiring.packages];
|
|
1905
|
+
const packages = [resolveRuntimeInstallSpec(deps), ...deps.authWiring.packages];
|
|
1775
1906
|
const mutations = mutationsFor(options, deps, plan);
|
|
1776
1907
|
if (options.dryRun) {
|
|
1777
1908
|
out(`\nWould install (${pm}): ${packages.join(", ")}\n`);
|
|
@@ -1797,13 +1928,37 @@ async function scaffold(options, deps, plan) {
|
|
|
1797
1928
|
printNextSteps(out, deps.authWiring.complete, loginRan);
|
|
1798
1929
|
return plan.contactDetected ? 0 : 1;
|
|
1799
1930
|
}
|
|
1931
|
+
function normalizeAppRoot(options) {
|
|
1932
|
+
const resolution = (options.resolveTargetApp ?? resolveTargetApp)(options.cwd);
|
|
1933
|
+
const out = options.out ?? ((line) => process.stdout.write(line));
|
|
1934
|
+
if (resolution.reason === "workspace-ambiguous") {
|
|
1935
|
+
out([
|
|
1936
|
+
"Found more than one Drizzle app in this workspace.",
|
|
1937
|
+
"Run `clivly init` from the app directory you want to wire, or pass `--schema` from there.",
|
|
1938
|
+
...(resolution.candidates ?? []).map((path) => ` • ${path}`),
|
|
1939
|
+
""
|
|
1940
|
+
].join("\n"));
|
|
1941
|
+
return {
|
|
1942
|
+
cwd: resolution.cwd,
|
|
1943
|
+
code: 1
|
|
1944
|
+
};
|
|
1945
|
+
}
|
|
1946
|
+
if (resolution.cwd !== options.cwd) out(`Using app root: ${resolution.cwd}\n`);
|
|
1947
|
+
return { cwd: resolution.cwd };
|
|
1948
|
+
}
|
|
1800
1949
|
async function runInit(options) {
|
|
1801
|
-
const
|
|
1802
|
-
|
|
1950
|
+
const normalized = normalizeAppRoot(options);
|
|
1951
|
+
if (normalized.code) return normalized.code;
|
|
1952
|
+
const resolvedOptions = {
|
|
1953
|
+
...options,
|
|
1954
|
+
cwd: normalized.cwd
|
|
1955
|
+
};
|
|
1956
|
+
const deps = resolveInitDeps(resolvedOptions);
|
|
1957
|
+
const acquired = await acquireSchema(resolvedOptions, deps);
|
|
1803
1958
|
if ("code" in acquired) return acquired.code;
|
|
1804
1959
|
const plan = planInit(acquired);
|
|
1805
1960
|
printPlan(deps.out, plan);
|
|
1806
|
-
return scaffold(
|
|
1961
|
+
return scaffold(resolvedOptions, deps, plan);
|
|
1807
1962
|
}
|
|
1808
1963
|
function hasCloudflaredOnPath() {
|
|
1809
1964
|
const pathEnv = process.env.PATH ?? "";
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as ClivlyEntitiesConfig } from "./entity-config-GczjD3y8.cjs";
|
|
2
|
-
import { n as CompiledView, t as CompileOptions } from "./view-compiler-
|
|
2
|
+
import { n as CompiledView, t as CompileOptions } from "./view-compiler-4HsRUTWH.cjs";
|
|
3
3
|
|
|
4
4
|
//#region ../core/src/sync-engine.d.ts
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as ClivlyEntitiesConfig } from "./entity-config-D1DFyeUp.mjs";
|
|
2
|
-
import { n as CompiledView, t as CompileOptions } from "./view-compiler-
|
|
2
|
+
import { n as CompiledView, t as CompileOptions } from "./view-compiler-BpIDExjd.mjs";
|
|
3
3
|
|
|
4
4
|
//#region ../core/src/sync-engine.d.ts
|
|
5
5
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { a as ClivlyEntitiesConfig } from "./entity-config-GczjD3y8.cjs";
|
|
2
2
|
|
|
3
3
|
//#region ../core/src/view-compiler.d.ts
|
|
4
|
+
declare const DEFAULT_VIEW_PREFIX = "crm_src_";
|
|
4
5
|
interface CompileOptions {
|
|
5
6
|
/**
|
|
6
7
|
* Optional tenant-scoping predicate ANDed into every view's WHERE, e.g.
|
|
@@ -68,4 +69,4 @@ interface ExplainResult {
|
|
|
68
69
|
*/
|
|
69
70
|
declare function explainEntitiesConfig(config: ClivlyEntitiesConfig, run: (sql: string) => Promise<unknown>, options?: CompileOptions): Promise<ExplainResult[]>;
|
|
70
71
|
//#endregion
|
|
71
|
-
export {
|
|
72
|
+
export { compileEntityView as a, ExplainResult as i, CompiledView as n, compileEntityViews as o, DEFAULT_VIEW_PREFIX as r, explainEntitiesConfig as s, CompileOptions as t };
|
|
@@ -109,7 +109,7 @@ function compileRelationship(relName, rel, source, related) {
|
|
|
109
109
|
function compileEntityView(config, entityKey, options = {}) {
|
|
110
110
|
const entity = config.entities[entityKey];
|
|
111
111
|
if (!entity) throw new Error(`entity "${entityKey}" is not defined`);
|
|
112
|
-
const viewName = `${options.viewPrefix ??
|
|
112
|
+
const viewName = `${options.viewPrefix ?? "crm_src_"}${entityKey}`;
|
|
113
113
|
const src = entity.source;
|
|
114
114
|
const selectItems = [`${quoteIdent(src)}.${quoteIdent(SOURCE_KEY)} AS ${quoteIdent("id")}`];
|
|
115
115
|
const columns = ["id"];
|
|
@@ -182,6 +182,12 @@ async function explainEntitiesConfig(config, run, options = {}) {
|
|
|
182
182
|
return results;
|
|
183
183
|
}
|
|
184
184
|
//#endregion
|
|
185
|
+
Object.defineProperty(exports, "DEFAULT_VIEW_PREFIX", {
|
|
186
|
+
enumerable: true,
|
|
187
|
+
get: function() {
|
|
188
|
+
return DEFAULT_VIEW_PREFIX;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
185
191
|
Object.defineProperty(exports, "compileEntityView", {
|
|
186
192
|
enumerable: true,
|
|
187
193
|
get: function() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { a as ClivlyEntitiesConfig } from "./entity-config-D1DFyeUp.mjs";
|
|
2
2
|
|
|
3
3
|
//#region ../core/src/view-compiler.d.ts
|
|
4
|
+
declare const DEFAULT_VIEW_PREFIX = "crm_src_";
|
|
4
5
|
interface CompileOptions {
|
|
5
6
|
/**
|
|
6
7
|
* Optional tenant-scoping predicate ANDed into every view's WHERE, e.g.
|
|
@@ -68,4 +69,4 @@ interface ExplainResult {
|
|
|
68
69
|
*/
|
|
69
70
|
declare function explainEntitiesConfig(config: ClivlyEntitiesConfig, run: (sql: string) => Promise<unknown>, options?: CompileOptions): Promise<ExplainResult[]>;
|
|
70
71
|
//#endregion
|
|
71
|
-
export {
|
|
72
|
+
export { compileEntityView as a, ExplainResult as i, CompiledView as n, compileEntityViews as o, DEFAULT_VIEW_PREFIX as r, explainEntitiesConfig as s, CompileOptions as t };
|
|
@@ -109,7 +109,7 @@ function compileRelationship(relName, rel, source, related) {
|
|
|
109
109
|
function compileEntityView(config, entityKey, options = {}) {
|
|
110
110
|
const entity = config.entities[entityKey];
|
|
111
111
|
if (!entity) throw new Error(`entity "${entityKey}" is not defined`);
|
|
112
|
-
const viewName = `${options.viewPrefix ??
|
|
112
|
+
const viewName = `${options.viewPrefix ?? "crm_src_"}${entityKey}`;
|
|
113
113
|
const src = entity.source;
|
|
114
114
|
const selectItems = [`${quoteIdent(src)}.${quoteIdent(SOURCE_KEY)} AS ${quoteIdent("id")}`];
|
|
115
115
|
const columns = ["id"];
|
|
@@ -182,4 +182,4 @@ async function explainEntitiesConfig(config, run, options = {}) {
|
|
|
182
182
|
return results;
|
|
183
183
|
}
|
|
184
184
|
//#endregion
|
|
185
|
-
export {
|
|
185
|
+
export { explainEntitiesConfig as i, compileEntityView as n, compileEntityViews as r, DEFAULT_VIEW_PREFIX as t };
|