clivly 0.9.5 → 0.9.6

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 (62) hide show
  1. package/README.md +7 -0
  2. package/core-entity-config.cjs +1 -1
  3. package/core-entity-config.mjs +1 -1
  4. package/core-mappings-config.cjs +1 -1
  5. package/core-mappings-config.mjs +1 -1
  6. package/core-sync-engine.cjs +1 -1
  7. package/core-sync-engine.mjs +1 -1
  8. package/core-view-compiler.cjs +1 -1
  9. package/core-view-compiler.mjs +1 -1
  10. package/core.cjs +13 -7
  11. package/core.d.cts +2 -2
  12. package/core.d.mts +2 -2
  13. package/core.mjs +8 -8
  14. package/drizzle.cjs +19 -2
  15. package/drizzle.d.cts +1 -1
  16. package/drizzle.d.mts +1 -1
  17. package/drizzle.mjs +19 -2
  18. package/{entity-config-B74SPOUZ.mjs → entity-config-CusbTOJ1.mjs} +1 -1
  19. package/{entity-config-7sGCk_nw.cjs → entity-config-DE30_RpU.cjs} +1 -1
  20. package/index.cjs +9 -8
  21. package/index.mjs +9 -8
  22. package/internal-BQ47iN6f.cjs +259 -0
  23. package/internal-ChufvXE6.mjs +212 -0
  24. package/{internal-o2M7FGlR.d.mts → internal-CvlFk3KC.d.mts} +82 -2
  25. package/{internal-wCXSELDN.d.cts → internal-DGUOLQAq.d.cts} +82 -2
  26. package/internal-entity-config.cjs +1 -1
  27. package/internal-entity-config.mjs +1 -1
  28. package/internal-entity-heuristics.cjs +1 -1
  29. package/internal-entity-heuristics.mjs +1 -1
  30. package/internal-mappings-config.cjs +1 -1
  31. package/internal-mappings-config.mjs +1 -1
  32. package/internal-sync-engine.cjs +1 -1
  33. package/internal-sync-engine.mjs +1 -1
  34. package/internal-view-compiler.cjs +1 -1
  35. package/internal-view-compiler.mjs +1 -1
  36. package/internal.cjs +13 -7
  37. package/internal.d.cts +2 -2
  38. package/internal.d.mts +2 -2
  39. package/internal.mjs +8 -8
  40. package/{mappings-config-DQS_s4dg.mjs → mappings-config-7qQ47p9K.mjs} +1 -1
  41. package/{mappings-config-CLyEg0sf.cjs → mappings-config-CjCmT-aU.cjs} +1 -1
  42. package/{namespace-probe-Cn7voAd0.d.mts → namespace-probe-Ckn9yJ6F.d.mts} +45 -2
  43. package/{namespace-probe-BoGI18dQ.d.cts → namespace-probe-DaTJINS-.d.cts} +45 -2
  44. package/package.json +1 -1
  45. package/{projection-Dz6_i1-w.cjs → projection-DEwL-D8R.cjs} +6 -0
  46. package/{projection-CSGJbZlZ.mjs → projection-hnPSgH6G.mjs} +1 -1
  47. package/{projection-sql-BgnfiGqF.mjs → projection-sql-9zzTVGvf.mjs} +34 -2
  48. package/{projection-sql-Cl1qIn8m.cjs → projection-sql-iHy-Cx6V.cjs} +45 -1
  49. package/{sdk-DYBDR939.mjs → sdk-Dkq6ELkf.mjs} +32 -8
  50. package/{sdk-CM1UO-I7.cjs → sdk-w8Kv_XnW.cjs} +32 -8
  51. package/sdk.cjs +2 -2
  52. package/sdk.d.cts +2 -2
  53. package/sdk.d.mts +2 -2
  54. package/sdk.mjs +2 -2
  55. package/{sync-engine-C4A5jgA4.cjs → sync-engine-BLgwLpR6.cjs} +1 -1
  56. package/{sync-engine-Dt5QQSKO.mjs → sync-engine-B_IzoUSx.mjs} +1 -1
  57. package/{view-compiler-B5nDal14.cjs → view-compiler-BHI5E4QI.cjs} +2 -2
  58. package/{view-compiler-CSYwEWf5.mjs → view-compiler-D_6gfXFr.mjs} +2 -2
  59. package/vite.d.cts +1 -1
  60. package/vite.d.mts +1 -1
  61. package/internal-CykXpEGk.mjs +0 -68
  62. package/internal-DqduZU3l.cjs +0 -97
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_entity_config = require("./entity-config-7sGCk_nw.cjs");
2
+ const require_entity_config = require("./entity-config-DE30_RpU.cjs");
3
3
  exports.CANONICAL_FIELDS = require_entity_config.CANONICAL_FIELDS;
4
4
  exports.CRM_CONCEPTS = require_entity_config.CRM_CONCEPTS;
5
5
  exports.CUSTOM_CONCEPT = require_entity_config.CUSTOM_CONCEPT;
@@ -1,2 +1,2 @@
1
- import { a as MATERIALIZING_CONCEPTS, c as entitiesConfigSchema, d as relationshipSchema, f as relationshipsSchema, i as ClivlyConfigError, l as filterSchema, n as CRM_CONCEPTS, o as customObjectDeclarations, p as validateEntitiesConfig, r as CUSTOM_CONCEPT, s as defineClivlyConfig, t as CANONICAL_FIELDS, u as projectionFields } from "./entity-config-B74SPOUZ.mjs";
1
+ import { a as MATERIALIZING_CONCEPTS, c as entitiesConfigSchema, d as relationshipSchema, f as relationshipsSchema, i as ClivlyConfigError, l as filterSchema, n as CRM_CONCEPTS, o as customObjectDeclarations, p as validateEntitiesConfig, r as CUSTOM_CONCEPT, s as defineClivlyConfig, t as CANONICAL_FIELDS, u as projectionFields } from "./entity-config-CusbTOJ1.mjs";
2
2
  export { CANONICAL_FIELDS, CRM_CONCEPTS, CUSTOM_CONCEPT, ClivlyConfigError, MATERIALIZING_CONCEPTS, customObjectDeclarations, defineClivlyConfig, entitiesConfigSchema, filterSchema, projectionFields, relationshipSchema, relationshipsSchema, validateEntitiesConfig };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_entity_config = require("./entity-config-7sGCk_nw.cjs");
2
+ const require_entity_config = require("./entity-config-DE30_RpU.cjs");
3
3
  const require_mapping_score = require("./mapping-score-CaB3F4Uu.cjs");
4
4
  //#region ../core/src/entity-heuristics.ts
5
5
  const TARGET_CONCEPTS = [
@@ -1,4 +1,4 @@
1
- import { a as MATERIALIZING_CONCEPTS } from "./entity-config-B74SPOUZ.mjs";
1
+ import { a as MATERIALIZING_CONCEPTS } from "./entity-config-CusbTOJ1.mjs";
2
2
  import { a as W, c as isTextLike, i as RELATIONSHIP_TIERS, l as isTimestampLike, n as CONCEPT_TIERS, o as isAmbiguous, r as FIELD_TIERS, s as isNumericLike, u as tierFor } from "./mapping-score-C68uAqGB.mjs";
3
3
  //#region ../core/src/entity-heuristics.ts
4
4
  const TARGET_CONCEPTS = [
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_mappings_config = require("./mappings-config-CLyEg0sf.cjs");
2
+ const require_mappings_config = require("./mappings-config-CjCmT-aU.cjs");
3
3
  exports.entitiesToMappings = require_mappings_config.entitiesToMappings;
4
4
  exports.mappingsToEntitiesConfig = require_mappings_config.mappingsToEntitiesConfig;
@@ -1,2 +1,2 @@
1
- import { n as mappingsToEntitiesConfig, t as entitiesToMappings } from "./mappings-config-DQS_s4dg.mjs";
1
+ import { n as mappingsToEntitiesConfig, t as entitiesToMappings } from "./mappings-config-7qQ47p9K.mjs";
2
2
  export { entitiesToMappings, mappingsToEntitiesConfig };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sync_engine = require("./sync-engine-C4A5jgA4.cjs");
2
+ const require_sync_engine = require("./sync-engine-BLgwLpR6.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;
@@ -1,2 +1,2 @@
1
- import { i as runSync, n as previewSync, r as reconcile, t as computeSampleWarnings } from "./sync-engine-Dt5QQSKO.mjs";
1
+ import { i as runSync, n as previewSync, r as reconcile, t as computeSampleWarnings } from "./sync-engine-B_IzoUSx.mjs";
2
2
  export { computeSampleWarnings, previewSync, reconcile, runSync };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_view_compiler = require("./view-compiler-B5nDal14.cjs");
2
+ const require_view_compiler = require("./view-compiler-BHI5E4QI.cjs");
3
3
  exports.DEFAULT_VIEW_PREFIX = require_view_compiler.DEFAULT_VIEW_PREFIX;
4
4
  exports.compileEntityView = require_view_compiler.compileEntityView;
5
5
  exports.compileEntityViews = require_view_compiler.compileEntityViews;
@@ -1,2 +1,2 @@
1
- import { a as explainViewExecutionError, i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-CSYwEWf5.mjs";
1
+ import { a as explainViewExecutionError, i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-D_6gfXFr.mjs";
2
2
  export { DEFAULT_VIEW_PREFIX, compileEntityView, compileEntityViews, explainEntitiesConfig, explainViewExecutionError };
package/internal.cjs CHANGED
@@ -1,19 +1,21 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_projection = require("./projection-Dz6_i1-w.cjs");
3
- const require_entity_config = require("./entity-config-7sGCk_nw.cjs");
4
- const require_mappings_config = require("./mappings-config-CLyEg0sf.cjs");
2
+ const require_projection = require("./projection-DEwL-D8R.cjs");
3
+ const require_entity_config = require("./entity-config-DE30_RpU.cjs");
4
+ const require_mappings_config = require("./mappings-config-CjCmT-aU.cjs");
5
5
  const require_auth_adapter = require("./auth-adapter-CiEXcweZ.cjs");
6
6
  const require_mapping_form = require("./mapping-form-BpfON_ME.cjs");
7
- const require_internal = require("./internal-DqduZU3l.cjs");
8
- const require_projection_sql = require("./projection-sql-Cl1qIn8m.cjs");
9
- const require_view_compiler = require("./view-compiler-B5nDal14.cjs");
10
- const require_sync_engine = require("./sync-engine-C4A5jgA4.cjs");
7
+ const require_internal = require("./internal-BQ47iN6f.cjs");
8
+ const require_projection_sql = require("./projection-sql-iHy-Cx6V.cjs");
9
+ const require_view_compiler = require("./view-compiler-BHI5E4QI.cjs");
10
+ const require_sync_engine = require("./sync-engine-BLgwLpR6.cjs");
11
11
  exports.BASE_REF = require_projection.BASE_REF;
12
12
  exports.CANONICAL_FIELDS = require_entity_config.CANONICAL_FIELDS;
13
13
  exports.CRM_CONCEPTS = require_entity_config.CRM_CONCEPTS;
14
14
  exports.ClivlyConfigError = require_entity_config.ClivlyConfigError;
15
15
  exports.DEFAULT_VIEW_PREFIX = require_view_compiler.DEFAULT_VIEW_PREFIX;
16
16
  exports.MATERIALIZING_CONCEPTS = require_entity_config.MATERIALIZING_CONCEPTS;
17
+ exports.PREVIEW_MAX_ROWS = require_projection_sql.PREVIEW_MAX_ROWS;
18
+ exports.addDraftJoin = require_internal.addDraftJoin;
17
19
  exports.authCustom = require_auth_adapter.authCustom;
18
20
  exports.buildFilterFromDiscriminator = require_mapping_form.buildFilterFromDiscriminator;
19
21
  exports.buildRelationships = require_mapping_form.buildRelationships;
@@ -23,10 +25,13 @@ exports.compileEntityViews = require_view_compiler.compileEntityViews;
23
25
  exports.compileProjectionFrom = require_projection_sql.compileProjectionFrom;
24
26
  exports.compileProjectionIdentity = require_projection_sql.compileProjectionIdentity;
25
27
  exports.compileProjectionJoins = require_projection_sql.compileProjectionJoins;
28
+ exports.compileProjectionPreview = require_projection_sql.compileProjectionPreview;
29
+ exports.compileProjectionSelect = require_projection_sql.compileProjectionSelect;
26
30
  exports.coversUniqueKey = require_entity_config.coversUniqueKey;
27
31
  exports.defineClivlyConfig = require_entity_config.defineClivlyConfig;
28
32
  exports.describeCardinality = require_internal.describeCardinality;
29
33
  exports.draftErrors = require_internal.draftErrors;
34
+ exports.draftRefOptions = require_internal.draftRefOptions;
30
35
  exports.draftToProjection = require_internal.draftToProjection;
31
36
  exports.emptyProjectionDraft = require_internal.emptyProjectionDraft;
32
37
  exports.entitiesConfigSchema = require_entity_config.entitiesConfigSchema;
@@ -44,6 +49,7 @@ exports.reconcile = require_sync_engine.reconcile;
44
49
  exports.relationshipSchema = require_entity_config.relationshipSchema;
45
50
  exports.relationshipViaSignature = require_mapping_form.relationshipViaSignature;
46
51
  exports.relationshipsSchema = require_entity_config.relationshipsSchema;
52
+ exports.removeDraftJoin = require_internal.removeDraftJoin;
47
53
  exports.runSync = require_sync_engine.runSync;
48
54
  exports.suggestJoinConditions = require_internal.suggestJoinConditions;
49
55
  exports.validateEntitiesConfig = require_entity_config.validateEntitiesConfig;
package/internal.d.cts CHANGED
@@ -7,5 +7,5 @@ import { i as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings
7
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-CmEdAMwj.cjs";
8
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-BG2O1an2.cjs";
9
9
  import { a as IntegrationStep, c as StepProblem, i as IntegrationStatus, l as StepState, n as IntegrationFacts, o as NextAction, r as IntegrationState, s as StepId, t as ConnectionLiveness } from "./integration-state-BK-riZnm.cjs";
10
- import { _ as joinFansOut, a as validateProjection, c as compileProjectionJoins, d as describeCardinality, f as draftErrors, g as fanOutJoins, h as suggestJoinConditions, i as primaryKeyColumns, l as quoteIdent, m as emptyProjectionDraft, n as coversUniqueKey, o as compileProjectionFrom, p as draftToProjection, r as hasRichMeta, s as compileProjectionIdentity, t as columnMetaFor, u as ProjectionDraft } from "./internal-wCXSELDN.cjs";
11
- export { type Activity, type ActivityType, BASE_REF, CANONICAL_FIELDS, type CRMAdapter, CRM_CONCEPTS, type ClivlyAuthAdapter, ClivlyConfigError, type ClivlyEntitiesConfig, type ClivlyEntityConfig, type ClivlyUser, type Company, type CompileOptions, type CompiledView, type ConfigValidationError, type ConfigValidationResult, type ConnectionLiveness, type Contact, type ContactFilters, type ContactStatus, type CreateActivityInput, type CreateCompanyInput, type CreateContactInput, type CreateDealInput, type CreateTaskInput, type CrmConcept, type CrmMembership, type CrmRole, DEFAULT_VIEW_PREFIX, type Deal, type DealStage, type DiscoveredColumnMeta, type DiscoveredSchemaTable, type EntityMappingRow, type EntitySyncResult, type ExplainResult, type FilterExpr, type FilterValue, type IntegrationFacts, type IntegrationState, type IntegrationStatus, type IntegrationStep, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type NextAction, type Note, type PersistAction, type ProjectionDraft, type ProjectionFieldBinding, type ProjectionIdentity, type ProjectionJoin, type ProjectionMapping, type ProjectionRef, type RecordSource, type RelationshipCandidate, type RelationshipSpec, type RelationshipVia, type RelationshipsMap, type SourceRow, type StepId, type StepProblem, type StepState, type SyncAction, type SyncResult, type SyncStore, type Task, type TaskEntityType, type TaskFilters, type TaskPriority, type TaskStatus, type UpdateContactInput, type UpdateDealInput, type UpdateTaskInput, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, quoteIdent, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
10
+ import { C as fanOutJoins, S as suggestJoinConditions, _ as draftErrors, a as validateProjection, b as emptyProjectionDraft, c as compileProjectionIdentity, d as compileProjectionSelect, f as quoteIdent, g as describeCardinality, h as addDraftJoin, i as primaryKeyColumns, l as compileProjectionJoins, m as ProjectionDraft, n as coversUniqueKey, o as PREVIEW_MAX_ROWS, p as DraftRefOption, r as hasRichMeta, s as compileProjectionFrom, t as columnMetaFor, u as compileProjectionPreview, v as draftRefOptions, w as joinFansOut, x as removeDraftJoin, y as draftToProjection } from "./internal-DGUOLQAq.cjs";
11
+ export { type Activity, type ActivityType, BASE_REF, CANONICAL_FIELDS, type CRMAdapter, CRM_CONCEPTS, type ClivlyAuthAdapter, ClivlyConfigError, type ClivlyEntitiesConfig, type ClivlyEntityConfig, type ClivlyUser, type Company, type CompileOptions, type CompiledView, type ConfigValidationError, type ConfigValidationResult, type ConnectionLiveness, type Contact, type ContactFilters, type ContactStatus, type CreateActivityInput, type CreateCompanyInput, type CreateContactInput, type CreateDealInput, type CreateTaskInput, type CrmConcept, type CrmMembership, type CrmRole, DEFAULT_VIEW_PREFIX, type Deal, type DealStage, type DiscoveredColumnMeta, type DiscoveredSchemaTable, type DraftRefOption, type EntityMappingRow, type EntitySyncResult, type ExplainResult, type FilterExpr, type FilterValue, type IntegrationFacts, type IntegrationState, type IntegrationStatus, type IntegrationStep, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type NextAction, type Note, PREVIEW_MAX_ROWS, type PersistAction, type ProjectionDraft, type ProjectionFieldBinding, type ProjectionIdentity, type ProjectionJoin, type ProjectionMapping, type ProjectionRef, type RecordSource, type RelationshipCandidate, type RelationshipSpec, type RelationshipVia, type RelationshipsMap, type SourceRow, type StepId, type StepProblem, type StepState, type SyncAction, type SyncResult, type SyncStore, type Task, type TaskEntityType, type TaskFilters, type TaskPriority, type TaskStatus, type UpdateContactInput, type UpdateDealInput, type UpdateTaskInput, addDraftJoin, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, compileProjectionPreview, compileProjectionSelect, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftRefOptions, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, quoteIdent, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, removeDraftJoin, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
package/internal.d.mts CHANGED
@@ -7,5 +7,5 @@ import { i as mappingsToEntitiesConfig, t as EntityMappingRow } from "./mappings
7
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-Bo7pqXW3.mjs";
8
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-DgQbrJON.mjs";
9
9
  import { a as IntegrationStep, c as StepProblem, i as IntegrationStatus, l as StepState, n as IntegrationFacts, o as NextAction, r as IntegrationState, s as StepId, t as ConnectionLiveness } from "./integration-state-BK-riZnm.mjs";
10
- import { _ as joinFansOut, a as validateProjection, c as compileProjectionJoins, d as describeCardinality, f as draftErrors, g as fanOutJoins, h as suggestJoinConditions, i as primaryKeyColumns, l as quoteIdent, m as emptyProjectionDraft, n as coversUniqueKey, o as compileProjectionFrom, p as draftToProjection, r as hasRichMeta, s as compileProjectionIdentity, t as columnMetaFor, u as ProjectionDraft } from "./internal-o2M7FGlR.mjs";
11
- export { type Activity, type ActivityType, BASE_REF, CANONICAL_FIELDS, type CRMAdapter, CRM_CONCEPTS, type ClivlyAuthAdapter, ClivlyConfigError, type ClivlyEntitiesConfig, type ClivlyEntityConfig, type ClivlyUser, type Company, type CompileOptions, type CompiledView, type ConfigValidationError, type ConfigValidationResult, type ConnectionLiveness, type Contact, type ContactFilters, type ContactStatus, type CreateActivityInput, type CreateCompanyInput, type CreateContactInput, type CreateDealInput, type CreateTaskInput, type CrmConcept, type CrmMembership, type CrmRole, DEFAULT_VIEW_PREFIX, type Deal, type DealStage, type DiscoveredColumnMeta, type DiscoveredSchemaTable, type EntityMappingRow, type EntitySyncResult, type ExplainResult, type FilterExpr, type FilterValue, type IntegrationFacts, type IntegrationState, type IntegrationStatus, type IntegrationStep, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type NextAction, type Note, type PersistAction, type ProjectionDraft, type ProjectionFieldBinding, type ProjectionIdentity, type ProjectionJoin, type ProjectionMapping, type ProjectionRef, type RecordSource, type RelationshipCandidate, type RelationshipSpec, type RelationshipVia, type RelationshipsMap, type SourceRow, type StepId, type StepProblem, type StepState, type SyncAction, type SyncResult, type SyncStore, type Task, type TaskEntityType, type TaskFilters, type TaskPriority, type TaskStatus, type UpdateContactInput, type UpdateDealInput, type UpdateTaskInput, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, quoteIdent, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
10
+ import { C as fanOutJoins, S as suggestJoinConditions, _ as draftErrors, a as validateProjection, b as emptyProjectionDraft, c as compileProjectionIdentity, d as compileProjectionSelect, f as quoteIdent, g as describeCardinality, h as addDraftJoin, i as primaryKeyColumns, l as compileProjectionJoins, m as ProjectionDraft, n as coversUniqueKey, o as PREVIEW_MAX_ROWS, p as DraftRefOption, r as hasRichMeta, s as compileProjectionFrom, t as columnMetaFor, u as compileProjectionPreview, v as draftRefOptions, w as joinFansOut, x as removeDraftJoin, y as draftToProjection } from "./internal-CvlFk3KC.mjs";
11
+ export { type Activity, type ActivityType, BASE_REF, CANONICAL_FIELDS, type CRMAdapter, CRM_CONCEPTS, type ClivlyAuthAdapter, ClivlyConfigError, type ClivlyEntitiesConfig, type ClivlyEntityConfig, type ClivlyUser, type Company, type CompileOptions, type CompiledView, type ConfigValidationError, type ConfigValidationResult, type ConnectionLiveness, type Contact, type ContactFilters, type ContactStatus, type CreateActivityInput, type CreateCompanyInput, type CreateContactInput, type CreateDealInput, type CreateTaskInput, type CrmConcept, type CrmMembership, type CrmRole, DEFAULT_VIEW_PREFIX, type Deal, type DealStage, type DiscoveredColumnMeta, type DiscoveredSchemaTable, type DraftRefOption, type EntityMappingRow, type EntitySyncResult, type ExplainResult, type FilterExpr, type FilterValue, type IntegrationFacts, type IntegrationState, type IntegrationStatus, type IntegrationStep, MATERIALIZING_CONCEPTS, type MaterializingConcept, type MembershipResolver, type MirrorRecord, type NextAction, type Note, PREVIEW_MAX_ROWS, type PersistAction, type ProjectionDraft, type ProjectionFieldBinding, type ProjectionIdentity, type ProjectionJoin, type ProjectionMapping, type ProjectionRef, type RecordSource, type RelationshipCandidate, type RelationshipSpec, type RelationshipVia, type RelationshipsMap, type SourceRow, type StepId, type StepProblem, type StepState, type SyncAction, type SyncResult, type SyncStore, type Task, type TaskEntityType, type TaskFilters, type TaskPriority, type TaskStatus, type UpdateContactInput, type UpdateDealInput, type UpdateTaskInput, addDraftJoin, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, compileProjectionPreview, compileProjectionSelect, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftRefOptions, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, quoteIdent, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, removeDraftJoin, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
package/internal.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { i as projectionSchema, r as identityRefs, t as BASE_REF } from "./projection-CSGJbZlZ.mjs";
2
- import { _ as columnMetaFor, a as MATERIALIZING_CONCEPTS, b as primaryKeyColumns, c as entitiesConfigSchema, d as relationshipSchema, f as relationshipsSchema, g as joinFansOut, h as fanOutJoins, i as ClivlyConfigError, l as filterSchema, m as validateProjection, n as CRM_CONCEPTS, p as validateEntitiesConfig, s as defineClivlyConfig, t as CANONICAL_FIELDS, v as coversUniqueKey, y as hasRichMeta } from "./entity-config-B74SPOUZ.mjs";
3
- import { n as mappingsToEntitiesConfig } from "./mappings-config-DQS_s4dg.mjs";
1
+ import { a as projectionSchema, i as identityRefs, t as BASE_REF } from "./projection-hnPSgH6G.mjs";
2
+ import { _ as columnMetaFor, a as MATERIALIZING_CONCEPTS, b as primaryKeyColumns, c as entitiesConfigSchema, d as relationshipSchema, f as relationshipsSchema, g as joinFansOut, h as fanOutJoins, i as ClivlyConfigError, l as filterSchema, m as validateProjection, n as CRM_CONCEPTS, p as validateEntitiesConfig, s as defineClivlyConfig, t as CANONICAL_FIELDS, v as coversUniqueKey, y as hasRichMeta } from "./entity-config-CusbTOJ1.mjs";
3
+ import { n as mappingsToEntitiesConfig } from "./mappings-config-7qQ47p9K.mjs";
4
4
  import { t as authCustom } from "./auth-adapter-gfVDxf3d.mjs";
5
5
  import { n as buildRelationships, r as relationshipViaSignature, t as buildFilterFromDiscriminator } from "./mapping-form-DigkuvFc.mjs";
6
- import { a as suggestJoinConditions, i as emptyProjectionDraft, n as draftErrors, r as draftToProjection, t as describeCardinality } from "./internal-CykXpEGk.mjs";
7
- import { a as quoteIdent, n as compileProjectionIdentity, r as compileProjectionJoins, t as compileProjectionFrom } from "./projection-sql-BgnfiGqF.mjs";
8
- import { i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-CSYwEWf5.mjs";
9
- import { i as runSync, r as reconcile } from "./sync-engine-Dt5QQSKO.mjs";
10
- export { BASE_REF, CANONICAL_FIELDS, CRM_CONCEPTS, ClivlyConfigError, DEFAULT_VIEW_PREFIX, MATERIALIZING_CONCEPTS, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, quoteIdent, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
6
+ import { a as draftToProjection, c as suggestJoinConditions, i as draftRefOptions, n as describeCardinality, o as emptyProjectionDraft, r as draftErrors, s as removeDraftJoin, t as addDraftJoin } from "./internal-ChufvXE6.mjs";
7
+ import { a as compileProjectionPreview, i as compileProjectionJoins, n as compileProjectionFrom, o as compileProjectionSelect, r as compileProjectionIdentity, s as quoteIdent, t as PREVIEW_MAX_ROWS } from "./projection-sql-9zzTVGvf.mjs";
8
+ import { i as explainEntitiesConfig, n as compileEntityView, r as compileEntityViews, t as DEFAULT_VIEW_PREFIX } from "./view-compiler-D_6gfXFr.mjs";
9
+ import { i as runSync, r as reconcile } from "./sync-engine-B_IzoUSx.mjs";
10
+ export { BASE_REF, CANONICAL_FIELDS, CRM_CONCEPTS, ClivlyConfigError, DEFAULT_VIEW_PREFIX, MATERIALIZING_CONCEPTS, PREVIEW_MAX_ROWS, addDraftJoin, authCustom, buildFilterFromDiscriminator, buildRelationships, columnMetaFor, compileEntityView, compileEntityViews, compileProjectionFrom, compileProjectionIdentity, compileProjectionJoins, compileProjectionPreview, compileProjectionSelect, coversUniqueKey, defineClivlyConfig, describeCardinality, draftErrors, draftRefOptions, draftToProjection, emptyProjectionDraft, entitiesConfigSchema, explainEntitiesConfig, fanOutJoins, filterSchema, hasRichMeta, identityRefs, joinFansOut, mappingsToEntitiesConfig, primaryKeyColumns, projectionSchema, quoteIdent, reconcile, relationshipSchema, relationshipViaSignature, relationshipsSchema, removeDraftJoin, runSync, suggestJoinConditions, validateEntitiesConfig, validateProjection };
@@ -1,4 +1,4 @@
1
- import { t as CANONICAL_FIELDS } from "./entity-config-B74SPOUZ.mjs";
1
+ import { t as CANONICAL_FIELDS } from "./entity-config-CusbTOJ1.mjs";
2
2
  //#region ../core/src/mappings-config.ts
3
3
  const RESERVED_FIELD = "id";
4
4
  /**
@@ -1,4 +1,4 @@
1
- const require_entity_config = require("./entity-config-7sGCk_nw.cjs");
1
+ const require_entity_config = require("./entity-config-DE30_RpU.cjs");
2
2
  //#region ../core/src/mappings-config.ts
3
3
  const RESERVED_FIELD = "id";
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-B2RA53nw.mjs";
1
+ import { P as ProjectionMapping, a as ClivlyEntitiesConfig } from "./entity-config-B2RA53nw.mjs";
2
2
  import { r as IntegrationState } from "./integration-state-BK-riZnm.mjs";
3
3
  //#region ../sdk/src/drizzle-meta.d.ts
4
4
  declare const DRIZZLE_META: "__clivly_drizzle_source_meta__";
@@ -340,6 +340,20 @@ interface CursorStore {
340
340
  get(entity: string): Promise<SyncCursor | null> | SyncCursor | null;
341
341
  set(entity: string, cursor: SyncCursor | null): Promise<void> | void;
342
342
  }
343
+ /** @see ClivlySDK.describeSyncTrigger */
344
+ interface SyncTriggerDescription {
345
+ /**
346
+ * `syncTrigger.url` exactly as configured, placeholder and all. The raw
347
+ * value, so a caller can say what is in the file rather than what survived
348
+ * resolution.
349
+ */
350
+ configured?: string;
351
+ /**
352
+ * The URL that would be reported to Clivly on the next heartbeat, or
353
+ * `undefined` when nothing resolves. An unedited placeholder never resolves.
354
+ */
355
+ resolved?: string;
356
+ }
343
357
  interface ClivlySDK {
344
358
  /**
345
359
  * Send a single heartbeat and report the outcome richly: `ok`, the HTTP
@@ -375,6 +389,18 @@ interface ClivlySDK {
375
389
  * anyone who can reach it — set a secret if it's publicly routable.
376
390
  */
377
391
  createClivlyHandler(): (req: Request) => Promise<Response>;
392
+ /**
393
+ * What this app would tell Clivly about its sync trigger route, right now.
394
+ *
395
+ * Computed per call rather than frozen at creation: `resolved` can start as
396
+ * `undefined` and become a real URL once the mounted route has served its
397
+ * first request and observed its own origin.
398
+ *
399
+ * Exists for `clivly status`, which has to tell "no trigger configured"
400
+ * apart from "configured, but still the scaffolded placeholder" — a
401
+ * distinction `resolved` alone erases, since it skips placeholders by design.
402
+ */
403
+ describeSyncTrigger(): SyncTriggerDescription;
378
404
  /** Validate this setup end-to-end (read-only) before the first sync. */
379
405
  doctor(): Promise<DoctorReport>;
380
406
  /**
@@ -451,8 +477,25 @@ interface ClivlySDK {
451
477
  interface NamespaceIntrospector {
452
478
  /** All base table names in the reachable schema. */
453
479
  listTables(): Promise<string[]>;
480
+ /**
481
+ * Read a few rows through an unsaved projection, for the dashboard's derived
482
+ * object preview. Rows are keyed by field name.
483
+ *
484
+ * Optional because it is the only capability here that needs more than a
485
+ * table name, and because an introspector may be hand-written. Absent, the
486
+ * dashboard says preview is unavailable rather than failing — see
487
+ * `previewProjection`.
488
+ *
489
+ * This is what makes preview cost the host an SDK upgrade and nothing else:
490
+ * `drizzleIntrospector(db)` already closes over the connection, so a config
491
+ * that set `introspector` for the "Namespace reachable" check gains preview
492
+ * without touching a line.
493
+ */
494
+ runProjection?(projection: ProjectionMapping, opts: {
495
+ limit: number;
496
+ }): Promise<Record<string, unknown>[]>;
454
497
  /** Prove a table is genuinely selectable (SELECT ... LIMIT 1). Throws if unreachable/denied. */
455
498
  sampleSelect(table: string): Promise<void>;
456
499
  }
457
500
  //#endregion
458
- export { SyncSource as _, ClivlyConnectResult as a, ClivlyUser as c, DiscoveredTable as d, DoctorCheck as f, EnsuredObjectTypeResult as g, EnsuredMappingResult as h, ClivlyConnectReason as i, CreateChatSessionHandlerOptions as l, EnsureSchemaResult as m, ChatSessionRequestBody as n, ClivlySDK as o, DoctorReport as p, ChatWidgetVisitor as r, ClivlySDKConfig as s, NamespaceIntrospector as t, CursorStore as u };
501
+ export { SyncSource as _, ClivlyConnectResult as a, ClivlyUser as c, DiscoveredTable as d, DoctorCheck as f, EnsuredObjectTypeResult as g, EnsuredMappingResult as h, ClivlyConnectReason as i, CreateChatSessionHandlerOptions as l, EnsureSchemaResult as m, ChatSessionRequestBody as n, ClivlySDK as o, DoctorReport as p, ChatWidgetVisitor as r, ClivlySDKConfig as s, NamespaceIntrospector as t, CursorStore as u, SyncTriggerDescription as v };
@@ -1,4 +1,4 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-B2RA53nw.cjs";
1
+ import { P as ProjectionMapping, a as ClivlyEntitiesConfig } from "./entity-config-B2RA53nw.cjs";
2
2
  import { r as IntegrationState } from "./integration-state-BK-riZnm.cjs";
3
3
  //#region ../sdk/src/drizzle-meta.d.ts
4
4
  declare const DRIZZLE_META: "__clivly_drizzle_source_meta__";
@@ -340,6 +340,20 @@ interface CursorStore {
340
340
  get(entity: string): Promise<SyncCursor | null> | SyncCursor | null;
341
341
  set(entity: string, cursor: SyncCursor | null): Promise<void> | void;
342
342
  }
343
+ /** @see ClivlySDK.describeSyncTrigger */
344
+ interface SyncTriggerDescription {
345
+ /**
346
+ * `syncTrigger.url` exactly as configured, placeholder and all. The raw
347
+ * value, so a caller can say what is in the file rather than what survived
348
+ * resolution.
349
+ */
350
+ configured?: string;
351
+ /**
352
+ * The URL that would be reported to Clivly on the next heartbeat, or
353
+ * `undefined` when nothing resolves. An unedited placeholder never resolves.
354
+ */
355
+ resolved?: string;
356
+ }
343
357
  interface ClivlySDK {
344
358
  /**
345
359
  * Send a single heartbeat and report the outcome richly: `ok`, the HTTP
@@ -375,6 +389,18 @@ interface ClivlySDK {
375
389
  * anyone who can reach it — set a secret if it's publicly routable.
376
390
  */
377
391
  createClivlyHandler(): (req: Request) => Promise<Response>;
392
+ /**
393
+ * What this app would tell Clivly about its sync trigger route, right now.
394
+ *
395
+ * Computed per call rather than frozen at creation: `resolved` can start as
396
+ * `undefined` and become a real URL once the mounted route has served its
397
+ * first request and observed its own origin.
398
+ *
399
+ * Exists for `clivly status`, which has to tell "no trigger configured"
400
+ * apart from "configured, but still the scaffolded placeholder" — a
401
+ * distinction `resolved` alone erases, since it skips placeholders by design.
402
+ */
403
+ describeSyncTrigger(): SyncTriggerDescription;
378
404
  /** Validate this setup end-to-end (read-only) before the first sync. */
379
405
  doctor(): Promise<DoctorReport>;
380
406
  /**
@@ -451,8 +477,25 @@ interface ClivlySDK {
451
477
  interface NamespaceIntrospector {
452
478
  /** All base table names in the reachable schema. */
453
479
  listTables(): Promise<string[]>;
480
+ /**
481
+ * Read a few rows through an unsaved projection, for the dashboard's derived
482
+ * object preview. Rows are keyed by field name.
483
+ *
484
+ * Optional because it is the only capability here that needs more than a
485
+ * table name, and because an introspector may be hand-written. Absent, the
486
+ * dashboard says preview is unavailable rather than failing — see
487
+ * `previewProjection`.
488
+ *
489
+ * This is what makes preview cost the host an SDK upgrade and nothing else:
490
+ * `drizzleIntrospector(db)` already closes over the connection, so a config
491
+ * that set `introspector` for the "Namespace reachable" check gains preview
492
+ * without touching a line.
493
+ */
494
+ runProjection?(projection: ProjectionMapping, opts: {
495
+ limit: number;
496
+ }): Promise<Record<string, unknown>[]>;
454
497
  /** Prove a table is genuinely selectable (SELECT ... LIMIT 1). Throws if unreachable/denied. */
455
498
  sampleSelect(table: string): Promise<void>;
456
499
  }
457
500
  //#endregion
458
- export { SyncSource as _, ClivlyConnectResult as a, ClivlyUser as c, DiscoveredTable as d, DoctorCheck as f, EnsuredObjectTypeResult as g, EnsuredMappingResult as h, ClivlyConnectReason as i, CreateChatSessionHandlerOptions as l, EnsureSchemaResult as m, ChatSessionRequestBody as n, ClivlySDK as o, DoctorReport as p, ChatWidgetVisitor as r, ClivlySDKConfig as s, NamespaceIntrospector as t, CursorStore as u };
501
+ export { SyncSource as _, ClivlyConnectResult as a, ClivlyUser as c, DiscoveredTable as d, DoctorCheck as f, EnsuredObjectTypeResult as g, EnsuredMappingResult as h, ClivlyConnectReason as i, CreateChatSessionHandlerOptions as l, EnsureSchemaResult as m, ChatSessionRequestBody as n, ClivlySDK as o, DoctorReport as p, ChatWidgetVisitor as r, ClivlySDKConfig as s, NamespaceIntrospector as t, CursorStore as u, SyncTriggerDescription as v };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clivly",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Clivly CLI — scaffold a CRM into your app (clivly init).",
@@ -4303,6 +4303,12 @@ Object.defineProperty(exports, "BASE_REF", {
4303
4303
  return BASE_REF;
4304
4304
  }
4305
4305
  });
4306
+ Object.defineProperty(exports, "PROJECTION_KEY_MESSAGE", {
4307
+ enumerable: true,
4308
+ get: function() {
4309
+ return PROJECTION_KEY_MESSAGE;
4310
+ }
4311
+ });
4306
4312
  Object.defineProperty(exports, "PROJECTION_KEY_PATTERN", {
4307
4313
  enumerable: true,
4308
4314
  get: function() {
@@ -4297,4 +4297,4 @@ function identityRefs(identity, basePkColumn) {
4297
4297
  return identity.parts;
4298
4298
  }
4299
4299
  //#endregion
4300
- export { _enum as a, literal as c, strictObject as d, string as f, projectionSchema as i, number as l, PROJECTION_KEY_PATTERN as n, array as o, union as p, identityRefs as r, boolean as s, BASE_REF as t, record as u };
4300
+ export { projectionSchema as a, boolean as c, record as d, strictObject as f, identityRefs as i, literal as l, union as m, PROJECTION_KEY_MESSAGE as n, _enum as o, string as p, PROJECTION_KEY_PATTERN as r, array as s, BASE_REF as t, number as u };
@@ -1,4 +1,4 @@
1
- import { r as identityRefs, t as BASE_REF } from "./projection-CSGJbZlZ.mjs";
1
+ import { i as identityRefs, t as BASE_REF } from "./projection-hnPSgH6G.mjs";
2
2
  //#region ../core/src/projection-sql.ts
3
3
  /**
4
4
  * SQL generation for projection-backed entities.
@@ -61,5 +61,37 @@ function compileProjectionJoins(projection) {
61
61
  function compileProjectionFrom(projection) {
62
62
  return `FROM ${quoteIdent(projection.baseTable)} AS ${quoteIdent(BASE_REF)}`;
63
63
  }
64
+ /**
65
+ * Hard ceiling on preview rows, regardless of what a caller asks for.
66
+ *
67
+ * A preview runs against a production database from a button a user can click
68
+ * as often as they like, so the cap belongs beside the query rather than in
69
+ * whichever caller happens to be passing a limit today.
70
+ */
71
+ const PREVIEW_MAX_ROWS = 50;
72
+ /**
73
+ * One SELECT reading a few rows through an UNSAVED projection, for the derived
74
+ * object builder's preview.
75
+ *
76
+ * Lives here, beside the view compiler, because both sides of the round trip
77
+ * need the identical statement: an embedded org runs it against its own
78
+ * database from `@clivly.com/api`, and a cloud org's host app runs it from
79
+ * `@clivly/sdk`. Two copies would be free to disagree about what the user is
80
+ * being shown, which is the whole value of a preview.
81
+ *
82
+ * Columns are aliased by FIELD NAME, not by ref token. That is the deliberate
83
+ * difference from the push source, which aliases by token because cloud ingest
84
+ * reads `row[token]`; a preview is read by a person, in a table whose headers
85
+ * are the field names they just typed.
86
+ */
87
+ function compileProjectionPreview(projection, limit) {
88
+ const { selectItems } = compileProjectionSelect(projection, projection.identity.kind === "base_pk" ? projection.identity.column ?? "id" : "id");
89
+ return [
90
+ `SELECT ${selectItems.join(", ")}`,
91
+ compileProjectionFrom(projection),
92
+ ...compileProjectionJoins(projection),
93
+ `LIMIT ${Math.max(1, Math.min(Math.floor(limit), 50))}`
94
+ ].join(" ");
95
+ }
64
96
  //#endregion
65
- export { quoteIdent as a, compileProjectionSelect as i, compileProjectionIdentity as n, compileProjectionJoins as r, compileProjectionFrom as t };
97
+ export { compileProjectionPreview as a, compileProjectionJoins as i, compileProjectionFrom as n, compileProjectionSelect as o, compileProjectionIdentity as r, quoteIdent as s, PREVIEW_MAX_ROWS as t };
@@ -1,4 +1,4 @@
1
- const require_projection = require("./projection-Dz6_i1-w.cjs");
1
+ const require_projection = require("./projection-DEwL-D8R.cjs");
2
2
  //#region ../core/src/projection-sql.ts
3
3
  /**
4
4
  * SQL generation for projection-backed entities.
@@ -61,7 +61,45 @@ function compileProjectionJoins(projection) {
61
61
  function compileProjectionFrom(projection) {
62
62
  return `FROM ${quoteIdent(projection.baseTable)} AS ${quoteIdent(require_projection.BASE_REF)}`;
63
63
  }
64
+ /**
65
+ * Hard ceiling on preview rows, regardless of what a caller asks for.
66
+ *
67
+ * A preview runs against a production database from a button a user can click
68
+ * as often as they like, so the cap belongs beside the query rather than in
69
+ * whichever caller happens to be passing a limit today.
70
+ */
71
+ const PREVIEW_MAX_ROWS = 50;
72
+ /**
73
+ * One SELECT reading a few rows through an UNSAVED projection, for the derived
74
+ * object builder's preview.
75
+ *
76
+ * Lives here, beside the view compiler, because both sides of the round trip
77
+ * need the identical statement: an embedded org runs it against its own
78
+ * database from `@clivly.com/api`, and a cloud org's host app runs it from
79
+ * `@clivly/sdk`. Two copies would be free to disagree about what the user is
80
+ * being shown, which is the whole value of a preview.
81
+ *
82
+ * Columns are aliased by FIELD NAME, not by ref token. That is the deliberate
83
+ * difference from the push source, which aliases by token because cloud ingest
84
+ * reads `row[token]`; a preview is read by a person, in a table whose headers
85
+ * are the field names they just typed.
86
+ */
87
+ function compileProjectionPreview(projection, limit) {
88
+ const { selectItems } = compileProjectionSelect(projection, projection.identity.kind === "base_pk" ? projection.identity.column ?? "id" : "id");
89
+ return [
90
+ `SELECT ${selectItems.join(", ")}`,
91
+ compileProjectionFrom(projection),
92
+ ...compileProjectionJoins(projection),
93
+ `LIMIT ${Math.max(1, Math.min(Math.floor(limit), 50))}`
94
+ ].join(" ");
95
+ }
64
96
  //#endregion
97
+ Object.defineProperty(exports, "PREVIEW_MAX_ROWS", {
98
+ enumerable: true,
99
+ get: function() {
100
+ return PREVIEW_MAX_ROWS;
101
+ }
102
+ });
65
103
  Object.defineProperty(exports, "compileProjectionFrom", {
66
104
  enumerable: true,
67
105
  get: function() {
@@ -80,6 +118,12 @@ Object.defineProperty(exports, "compileProjectionJoins", {
80
118
  return compileProjectionJoins;
81
119
  }
82
120
  });
121
+ Object.defineProperty(exports, "compileProjectionPreview", {
122
+ enumerable: true,
123
+ get: function() {
124
+ return compileProjectionPreview;
125
+ }
126
+ });
83
127
  Object.defineProperty(exports, "compileProjectionSelect", {
84
128
  enumerable: true,
85
129
  get: function() {
@@ -1,5 +1,5 @@
1
- import { o as customObjectDeclarations } from "./entity-config-B74SPOUZ.mjs";
2
- import { t as entitiesToMappings } from "./mappings-config-DQS_s4dg.mjs";
1
+ import { o as customObjectDeclarations } from "./entity-config-CusbTOJ1.mjs";
2
+ import { t as entitiesToMappings } from "./mappings-config-7qQ47p9K.mjs";
3
3
  import { t as DRIZZLE_META } from "./drizzle-meta-D-5k3n0i.mjs";
4
4
  //#region ../sdk/src/deployment-identity.ts
5
5
  const MAX_DEPLOYMENT_ID_LENGTH = 128;
@@ -572,12 +572,21 @@ async function runDoctor(args) {
572
572
  ok: entityCount > 0,
573
573
  detail: entityCount > 0 ? `${entityCount} entit${entityCount === 1 ? "y" : "ies"} configured.` : "No `entities` config — pass defineClivlyConfig(...) as `entities`."
574
574
  });
575
+ const sourcesDetail = (count, deferred) => {
576
+ if (deferred) return "Deferred — the coverage check below names the entity and the source key it expected.";
577
+ return count === 0 ? "No `source.contacts` — nothing to sync." : `${count} source(s) to mirror.`;
578
+ };
579
+ const coverage = checkConceptCoverage(config);
580
+ const coverageOwnsIt = !(coverage.ok || coverage.skipped);
581
+ const noSources = sources.length === 0;
582
+ const deferred = noSources && coverageOwnsIt;
575
583
  checks.push({
576
584
  name: "Sources configured",
577
- ok: sources.length > 0,
578
- detail: sources.length > 0 ? `${sources.length} source(s) to mirror.` : "No `source.contacts` — nothing to sync."
585
+ ok: !noSources,
586
+ skipped: deferred,
587
+ detail: sourcesDetail(sources.length, deferred)
579
588
  });
580
- checks.push(checkConceptCoverage(config));
589
+ checks.push(coverage);
581
590
  checks.push(...cursorColumnChecks(sources));
582
591
  for (const source of sources) {
583
592
  const check = cursorMonotonicityCheck(source);
@@ -1533,6 +1542,15 @@ async function handlePreviewRequest(config, preview) {
1533
1542
  sampledCount: rows.length
1534
1543
  }, 200);
1535
1544
  }
1545
+ async function handleProjectionPreviewRequest(config, request) {
1546
+ const run = config.introspector?.runProjection;
1547
+ if (!run) return jsonResponse({ error: "This app cannot preview derived objects. Set `introspector: drizzleIntrospector(db)` in clivly.config.ts, on a clivly version that supports runProjection." }, 400);
1548
+ const rows = await run.call(config.introspector, request.projection, { limit: request.limit });
1549
+ return jsonResponse({
1550
+ rows,
1551
+ sampledCount: rows.length
1552
+ }, 200);
1553
+ }
1536
1554
  /**
1537
1555
  * Create the Clivly SDK. The implemented surface — heartbeat/discovery reporting
1538
1556
  * and the auth-verify handler — connects a developer's app to a running Clivly
@@ -1662,13 +1680,17 @@ function createClivlySDK(config) {
1662
1680
  lastPushFailure = null;
1663
1681
  if (!await syncOne(resolved.source, resolved.path, "delta", resolved.objectType, runId, SAMPLE_BATCH_SIZE, SAMPLE_BATCH_SIZE, false)) throw new Error(describePushFailure([resolved.source.entity]));
1664
1682
  };
1665
- const sendHeartbeat = () => {
1666
- const triggerUrl = resolveTriggerUrl({
1683
+ const describeSyncTrigger = () => ({
1684
+ configured: config.syncTrigger?.url,
1685
+ resolved: resolveTriggerUrl({
1667
1686
  configuredUrl: config.syncTrigger?.url,
1668
1687
  configuredPath: config.syncTrigger?.path,
1669
1688
  env: config.env ?? process.env,
1670
1689
  observedUrl
1671
- });
1690
+ })
1691
+ });
1692
+ const sendHeartbeat = () => {
1693
+ const triggerUrl = describeSyncTrigger().resolved;
1672
1694
  return fetcher(`${apiUrl}/clivly/sdk/heartbeat`, {
1673
1695
  method: "POST",
1674
1696
  headers: {
@@ -1896,6 +1918,7 @@ function createClivlySDK(config) {
1896
1918
  const startedAt = Date.now();
1897
1919
  try {
1898
1920
  if (payload.preview) return await handlePreviewRequest(config, payload.preview);
1921
+ if (payload.previewProjection) return await handleProjectionPreviewRequest(config, payload.previewProjection);
1899
1922
  if (payload.sample) await runSampleSync(payload.sample.entityKey, payload.runId);
1900
1923
  else await runScheduled({
1901
1924
  mode: payload.mode,
@@ -1991,6 +2014,7 @@ function createClivlySDK(config) {
1991
2014
  connect,
1992
2015
  ping,
1993
2016
  doctor,
2017
+ describeSyncTrigger,
1994
2018
  runScheduled,
1995
2019
  createClivlyHandler,
1996
2020
  sync: runSync,