@clivly/core 0.9.1 → 0.9.3

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.
@@ -1,4 +1,4 @@
1
- import { b as RelationshipsMap, m as FilterExpr, y as RelationshipVia } from "./entity-config-CLxI8dVb.cjs";
1
+ import { b as RelationshipVia, h as FilterExpr, x as RelationshipsMap } from "./entity-config-buOIVtMM.cjs";
2
2
  //#region src/mapping-form.d.ts
3
3
  /**
4
4
  * A relationship the mapping UI can offer or has configured, in the shape the
@@ -1,4 +1,4 @@
1
- import { b as RelationshipsMap, m as FilterExpr, y as RelationshipVia } from "./entity-config-CLxI8dVb.mjs";
1
+ import { b as RelationshipVia, h as FilterExpr, x as RelationshipsMap } from "./entity-config-buOIVtMM.mjs";
2
2
  //#region src/mapping-form.d.ts
3
3
  /**
4
4
  * A relationship the mapping UI can offer or has configured, in the shape the
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_entity_config = require("./entity-config-Dh8aEcgj.cjs");
2
+ const require_entity_config = require("./entity-config-Bfq3OkCU.cjs");
3
3
  //#region src/mappings-config.ts
4
4
  const RESERVED_FIELD = "id";
5
5
  /**
@@ -122,5 +122,29 @@ function mappingsToEntitiesConfig(rows) {
122
122
  for (const { row, key } of assigned) entities[key] = buildEntity(row, refIndex);
123
123
  return { entities };
124
124
  }
125
+ const CUSTOM_CONCEPT = "custom";
126
+ function entitiesToMappings(config) {
127
+ const rows = [];
128
+ for (const [entityKey, entity] of Object.entries(config.entities)) {
129
+ const row = {
130
+ entityKey,
131
+ sourceTable: entity.projection?.baseTable ?? entity.source,
132
+ targetConcept: entity.concept,
133
+ role: entity.role ?? DEFAULT_ROLE,
134
+ fieldMap: entity.projection ? {} : entity.fields
135
+ };
136
+ if (entity.filter) row.filter = entity.filter;
137
+ if (entity.relationships) row.relationships = entity.relationships;
138
+ if (entity.projection) row.projection = entity.projection;
139
+ if (entity.concept === CUSTOM_CONCEPT) {
140
+ row.objectTypeSlug = entityKey;
141
+ if (entity.objectType) row.objectType = entity.objectType;
142
+ }
143
+ if (entity.targetObjectTypeId) row.targetObjectTypeId = entity.targetObjectTypeId;
144
+ rows.push(row);
145
+ }
146
+ return rows;
147
+ }
125
148
  //#endregion
149
+ exports.entitiesToMappings = entitiesToMappings;
126
150
  exports.mappingsToEntitiesConfig = mappingsToEntitiesConfig;
@@ -1,4 +1,4 @@
1
- import { M as ProjectionMapping, a as ClivlyEntitiesConfig } from "./entity-config-CLxI8dVb.cjs";
1
+ import { P as ProjectionMapping, a as ClivlyEntitiesConfig, h as FilterExpr, x as RelationshipsMap } from "./entity-config-buOIVtMM.cjs";
2
2
  //#region src/mappings-config.d.ts
3
3
  /**
4
4
  * Mappings → Entity Config bridge.
@@ -43,5 +43,43 @@ interface EntityMappingRow {
43
43
  * eligible — a no-op the view compiler and sync engine both tolerate.
44
44
  */
45
45
  declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
46
+ /**
47
+ * Entity Config → Mappings, the inverse of `mappingsToEntitiesConfig`.
48
+ *
49
+ * `objectType` in config creates the custom object but nothing creates the
50
+ * MAPPING, so config-as-code ended at a created object and a sync that stored
51
+ * nothing. This produces the rows that close that gap.
52
+ *
53
+ * The two shapes align column for column, with one asymmetry that cannot be
54
+ * resolved by naming: the row model has no entity-key column — a row is keyed by
55
+ * `(sourceTable, targetConcept, role)` — while a CUSTOM entity's key *is* its
56
+ * object type slug, and is routinely different from its source table
57
+ * ("client-accounts" derived from "accounts"). So the key travels explicitly on
58
+ * every row rather than being left for the reverse derivation to guess.
59
+ */
60
+ interface MappingFromConfig {
61
+ /**
62
+ * The config entity key this row came from. Not a row column — the caller
63
+ * needs it to resolve a custom object type and to report what it wrote.
64
+ */
65
+ entityKey: string;
66
+ fieldMap: Record<string, string>;
67
+ filter?: FilterExpr;
68
+ /** Declared custom object, when the config declares one rather than pinning an id. */
69
+ objectType?: {
70
+ iconKey?: string;
71
+ name: string;
72
+ pluralName?: string;
73
+ };
74
+ /** The custom object type's slug — the entity key. Custom entities only. */
75
+ objectTypeSlug?: string;
76
+ projection?: ProjectionMapping;
77
+ relationships?: RelationshipsMap;
78
+ role: string;
79
+ sourceTable: string;
80
+ targetConcept: string;
81
+ targetObjectTypeId?: string;
82
+ }
83
+ declare function entitiesToMappings(config: ClivlyEntitiesConfig): MappingFromConfig[];
46
84
  //#endregion
47
- export { EntityMappingRow, mappingsToEntitiesConfig };
85
+ export { EntityMappingRow, MappingFromConfig, entitiesToMappings, mappingsToEntitiesConfig };
@@ -1,4 +1,4 @@
1
- import { M as ProjectionMapping, a as ClivlyEntitiesConfig } from "./entity-config-CLxI8dVb.mjs";
1
+ import { P as ProjectionMapping, a as ClivlyEntitiesConfig, h as FilterExpr, x as RelationshipsMap } from "./entity-config-buOIVtMM.mjs";
2
2
  //#region src/mappings-config.d.ts
3
3
  /**
4
4
  * Mappings → Entity Config bridge.
@@ -43,5 +43,43 @@ interface EntityMappingRow {
43
43
  * eligible — a no-op the view compiler and sync engine both tolerate.
44
44
  */
45
45
  declare function mappingsToEntitiesConfig(rows: EntityMappingRow[]): ClivlyEntitiesConfig;
46
+ /**
47
+ * Entity Config → Mappings, the inverse of `mappingsToEntitiesConfig`.
48
+ *
49
+ * `objectType` in config creates the custom object but nothing creates the
50
+ * MAPPING, so config-as-code ended at a created object and a sync that stored
51
+ * nothing. This produces the rows that close that gap.
52
+ *
53
+ * The two shapes align column for column, with one asymmetry that cannot be
54
+ * resolved by naming: the row model has no entity-key column — a row is keyed by
55
+ * `(sourceTable, targetConcept, role)` — while a CUSTOM entity's key *is* its
56
+ * object type slug, and is routinely different from its source table
57
+ * ("client-accounts" derived from "accounts"). So the key travels explicitly on
58
+ * every row rather than being left for the reverse derivation to guess.
59
+ */
60
+ interface MappingFromConfig {
61
+ /**
62
+ * The config entity key this row came from. Not a row column — the caller
63
+ * needs it to resolve a custom object type and to report what it wrote.
64
+ */
65
+ entityKey: string;
66
+ fieldMap: Record<string, string>;
67
+ filter?: FilterExpr;
68
+ /** Declared custom object, when the config declares one rather than pinning an id. */
69
+ objectType?: {
70
+ iconKey?: string;
71
+ name: string;
72
+ pluralName?: string;
73
+ };
74
+ /** The custom object type's slug — the entity key. Custom entities only. */
75
+ objectTypeSlug?: string;
76
+ projection?: ProjectionMapping;
77
+ relationships?: RelationshipsMap;
78
+ role: string;
79
+ sourceTable: string;
80
+ targetConcept: string;
81
+ targetObjectTypeId?: string;
82
+ }
83
+ declare function entitiesToMappings(config: ClivlyEntitiesConfig): MappingFromConfig[];
46
84
  //#endregion
47
- export { EntityMappingRow, mappingsToEntitiesConfig };
85
+ export { EntityMappingRow, MappingFromConfig, entitiesToMappings, mappingsToEntitiesConfig };
@@ -1,4 +1,4 @@
1
- import { t as CANONICAL_FIELDS } from "./entity-config-8Fgr6IOH.mjs";
1
+ import { t as CANONICAL_FIELDS } from "./entity-config-DFJ8L9jm.mjs";
2
2
  //#region src/mappings-config.ts
3
3
  const RESERVED_FIELD = "id";
4
4
  /**
@@ -121,5 +121,28 @@ function mappingsToEntitiesConfig(rows) {
121
121
  for (const { row, key } of assigned) entities[key] = buildEntity(row, refIndex);
122
122
  return { entities };
123
123
  }
124
+ const CUSTOM_CONCEPT = "custom";
125
+ function entitiesToMappings(config) {
126
+ const rows = [];
127
+ for (const [entityKey, entity] of Object.entries(config.entities)) {
128
+ const row = {
129
+ entityKey,
130
+ sourceTable: entity.projection?.baseTable ?? entity.source,
131
+ targetConcept: entity.concept,
132
+ role: entity.role ?? DEFAULT_ROLE,
133
+ fieldMap: entity.projection ? {} : entity.fields
134
+ };
135
+ if (entity.filter) row.filter = entity.filter;
136
+ if (entity.relationships) row.relationships = entity.relationships;
137
+ if (entity.projection) row.projection = entity.projection;
138
+ if (entity.concept === CUSTOM_CONCEPT) {
139
+ row.objectTypeSlug = entityKey;
140
+ if (entity.objectType) row.objectType = entity.objectType;
141
+ }
142
+ if (entity.targetObjectTypeId) row.targetObjectTypeId = entity.targetObjectTypeId;
143
+ rows.push(row);
144
+ }
145
+ return rows;
146
+ }
124
147
  //#endregion
125
- export { mappingsToEntitiesConfig };
148
+ export { entitiesToMappings, mappingsToEntitiesConfig };
@@ -1,4 +1,4 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-CLxI8dVb.cjs";
1
+ import { a as ClivlyEntitiesConfig } from "./entity-config-buOIVtMM.cjs";
2
2
  import { CompileOptions, CompiledView } from "./view-compiler.cjs";
3
3
  //#region src/sync-engine.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-CLxI8dVb.mjs";
1
+ import { a as ClivlyEntitiesConfig } from "./entity-config-buOIVtMM.mjs";
2
2
  import { CompileOptions, CompiledView } from "./view-compiler.mjs";
3
3
  //#region src/sync-engine.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-CLxI8dVb.cjs";
1
+ import { a as ClivlyEntitiesConfig } from "./entity-config-buOIVtMM.cjs";
2
2
  //#region src/view-compiler.d.ts
3
3
  declare const DEFAULT_VIEW_PREFIX = "crm_src_";
4
4
  interface CompileOptions {
@@ -1,4 +1,4 @@
1
- import { a as ClivlyEntitiesConfig } from "./entity-config-CLxI8dVb.mjs";
1
+ import { a as ClivlyEntitiesConfig } from "./entity-config-buOIVtMM.mjs";
2
2
  //#region src/view-compiler.d.ts
3
3
  declare const DEFAULT_VIEW_PREFIX = "crm_src_";
4
4
  interface CompileOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clivly/core",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "ORM/auth-agnostic CRM adapter contracts and shared domain types for Clivly.",