@clivly/core 0.10.6 → 0.10.7

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.
@@ -283,6 +283,54 @@ const SENSITIVE_COLUMNS = /* @__PURE__ */ new Set([
283
283
  function hasSensitiveColumns(columns) {
284
284
  return columns.some((column) => SENSITIVE_COLUMNS.has(column.toLowerCase().replaceAll("-", "_")));
285
285
  }
286
+ /**
287
+ * Table names the supported auth libraries create.
288
+ *
289
+ * `hasSensitiveColumns` cannot catch these. Better Auth's `organization` table
290
+ * is `{id, name, slug, logo}` — no credential column anywhere, a real `name`,
291
+ * and "organizations" is in the company vocabulary above. It is, by every
292
+ * signal this module has, an excellent company candidate. On `vue-academy`
293
+ * `clivly init` duly chose it over `campuses`, the actual business table that
294
+ * every student row points at, and the first sync exported rows nothing could
295
+ * receive.
296
+ *
297
+ * Matched on name, deliberately, and this is the inverse of the rule above:
298
+ * withholding a table on a wrong guess is a real loss, so that is decided on
299
+ * columns; *ranking* one below another is cheap to get wrong, so a name match
300
+ * is enough. These are fixed names the plugins create, and an app whose own
301
+ * business table is called `member` still ranks — just after its rivals.
302
+ */
303
+ const FRAMEWORK_TABLE_NAMES = /* @__PURE__ */ new Set([
304
+ "account",
305
+ "session",
306
+ "user",
307
+ "verification",
308
+ "invitation",
309
+ "member",
310
+ "organization",
311
+ "team",
312
+ "team_member",
313
+ "apikey",
314
+ "api_key",
315
+ "jwks",
316
+ "passkey",
317
+ "rate_limit",
318
+ "ratelimit",
319
+ "two_factor",
320
+ "twofactor",
321
+ "__drizzle_migrations",
322
+ "drizzle_migrations"
323
+ ]);
324
+ /**
325
+ * Is this table one your auth library created, rather than one you wrote?
326
+ *
327
+ * Used to rank such tables below the developer's own when both could serve a
328
+ * concept. Never to exclude them: mapping `user` as the contact entity is
329
+ * legitimate for plenty of apps, and it stays selectable.
330
+ */
331
+ function isFrameworkTable(name) {
332
+ return FRAMEWORK_TABLE_NAMES.has(name.toLowerCase().replaceAll("-", "_"));
333
+ }
286
334
  function metaFor(table, column) {
287
335
  return table.columnsMeta?.find((c) => c.name === column);
288
336
  }
@@ -497,6 +545,7 @@ function toFieldMap(scored) {
497
545
  exports.TARGET_CONCEPTS = TARGET_CONCEPTS;
498
546
  exports.hasDefiningColumn = hasDefiningColumn;
499
547
  exports.hasSensitiveColumns = hasSensitiveColumns;
548
+ exports.isFrameworkTable = isFrameworkTable;
500
549
  exports.matchesConcept = matchesConcept;
501
550
  exports.requiredFieldsFor = requiredFieldsFor;
502
551
  exports.scoreConcepts = scoreConcepts;
@@ -19,6 +19,14 @@ interface ScoredTable {
19
19
  * They stay manually selectable — an explicit, informed choice is legitimate.
20
20
  */
21
21
  declare function hasSensitiveColumns(columns: string[]): boolean;
22
+ /**
23
+ * Is this table one your auth library created, rather than one you wrote?
24
+ *
25
+ * Used to rank such tables below the developer's own when both could serve a
26
+ * concept. Never to exclude them: mapping `user` as the contact entity is
27
+ * legitimate for plenty of apps, and it stays selectable.
28
+ */
29
+ declare function isFrameworkTable(name: string): boolean;
22
30
  declare function hasDefiningColumn(concept: TargetConcept, columns: string[]): boolean;
23
31
  declare function scoreConcepts(table: ScoredTable): Scored<TargetConcept>[];
24
32
  declare function topConcept(table: ScoredTable): {
@@ -61,4 +69,4 @@ interface FieldSuggestion {
61
69
  declare function scoreFieldMap(concept: TargetConcept, table: ScoredTable): Scored<FieldSuggestion>[];
62
70
  declare function toFieldMap(scored: Scored<FieldSuggestion>[]): Record<string, string>;
63
71
  //#endregion
64
- export { type DiscoveredColumnMeta, FieldSuggestion, RelationshipSuggestion, ScoredTable, SuggestedVia, TARGET_CONCEPTS, TargetConcept, hasDefiningColumn, hasSensitiveColumns, matchesConcept, requiredFieldsFor, scoreConcepts, scoreFieldMap, scoreRelationships, suggestCursorField, suggestDiscriminatorColumns, toFieldMap, topConcept, validateMapping };
72
+ export { type DiscoveredColumnMeta, FieldSuggestion, RelationshipSuggestion, ScoredTable, SuggestedVia, TARGET_CONCEPTS, TargetConcept, hasDefiningColumn, hasSensitiveColumns, isFrameworkTable, matchesConcept, requiredFieldsFor, scoreConcepts, scoreFieldMap, scoreRelationships, suggestCursorField, suggestDiscriminatorColumns, toFieldMap, topConcept, validateMapping };
@@ -19,6 +19,14 @@ interface ScoredTable {
19
19
  * They stay manually selectable — an explicit, informed choice is legitimate.
20
20
  */
21
21
  declare function hasSensitiveColumns(columns: string[]): boolean;
22
+ /**
23
+ * Is this table one your auth library created, rather than one you wrote?
24
+ *
25
+ * Used to rank such tables below the developer's own when both could serve a
26
+ * concept. Never to exclude them: mapping `user` as the contact entity is
27
+ * legitimate for plenty of apps, and it stays selectable.
28
+ */
29
+ declare function isFrameworkTable(name: string): boolean;
22
30
  declare function hasDefiningColumn(concept: TargetConcept, columns: string[]): boolean;
23
31
  declare function scoreConcepts(table: ScoredTable): Scored<TargetConcept>[];
24
32
  declare function topConcept(table: ScoredTable): {
@@ -61,4 +69,4 @@ interface FieldSuggestion {
61
69
  declare function scoreFieldMap(concept: TargetConcept, table: ScoredTable): Scored<FieldSuggestion>[];
62
70
  declare function toFieldMap(scored: Scored<FieldSuggestion>[]): Record<string, string>;
63
71
  //#endregion
64
- export { type DiscoveredColumnMeta, FieldSuggestion, RelationshipSuggestion, ScoredTable, SuggestedVia, TARGET_CONCEPTS, TargetConcept, hasDefiningColumn, hasSensitiveColumns, matchesConcept, requiredFieldsFor, scoreConcepts, scoreFieldMap, scoreRelationships, suggestCursorField, suggestDiscriminatorColumns, toFieldMap, topConcept, validateMapping };
72
+ export { type DiscoveredColumnMeta, FieldSuggestion, RelationshipSuggestion, ScoredTable, SuggestedVia, TARGET_CONCEPTS, TargetConcept, hasDefiningColumn, hasSensitiveColumns, isFrameworkTable, matchesConcept, requiredFieldsFor, scoreConcepts, scoreFieldMap, scoreRelationships, suggestCursorField, suggestDiscriminatorColumns, toFieldMap, topConcept, validateMapping };
@@ -282,6 +282,54 @@ const SENSITIVE_COLUMNS = /* @__PURE__ */ new Set([
282
282
  function hasSensitiveColumns(columns) {
283
283
  return columns.some((column) => SENSITIVE_COLUMNS.has(column.toLowerCase().replaceAll("-", "_")));
284
284
  }
285
+ /**
286
+ * Table names the supported auth libraries create.
287
+ *
288
+ * `hasSensitiveColumns` cannot catch these. Better Auth's `organization` table
289
+ * is `{id, name, slug, logo}` — no credential column anywhere, a real `name`,
290
+ * and "organizations" is in the company vocabulary above. It is, by every
291
+ * signal this module has, an excellent company candidate. On `vue-academy`
292
+ * `clivly init` duly chose it over `campuses`, the actual business table that
293
+ * every student row points at, and the first sync exported rows nothing could
294
+ * receive.
295
+ *
296
+ * Matched on name, deliberately, and this is the inverse of the rule above:
297
+ * withholding a table on a wrong guess is a real loss, so that is decided on
298
+ * columns; *ranking* one below another is cheap to get wrong, so a name match
299
+ * is enough. These are fixed names the plugins create, and an app whose own
300
+ * business table is called `member` still ranks — just after its rivals.
301
+ */
302
+ const FRAMEWORK_TABLE_NAMES = /* @__PURE__ */ new Set([
303
+ "account",
304
+ "session",
305
+ "user",
306
+ "verification",
307
+ "invitation",
308
+ "member",
309
+ "organization",
310
+ "team",
311
+ "team_member",
312
+ "apikey",
313
+ "api_key",
314
+ "jwks",
315
+ "passkey",
316
+ "rate_limit",
317
+ "ratelimit",
318
+ "two_factor",
319
+ "twofactor",
320
+ "__drizzle_migrations",
321
+ "drizzle_migrations"
322
+ ]);
323
+ /**
324
+ * Is this table one your auth library created, rather than one you wrote?
325
+ *
326
+ * Used to rank such tables below the developer's own when both could serve a
327
+ * concept. Never to exclude them: mapping `user` as the contact entity is
328
+ * legitimate for plenty of apps, and it stays selectable.
329
+ */
330
+ function isFrameworkTable(name) {
331
+ return FRAMEWORK_TABLE_NAMES.has(name.toLowerCase().replaceAll("-", "_"));
332
+ }
285
333
  function metaFor(table, column) {
286
334
  return table.columnsMeta?.find((c) => c.name === column);
287
335
  }
@@ -493,4 +541,4 @@ function toFieldMap(scored) {
493
541
  return map;
494
542
  }
495
543
  //#endregion
496
- export { TARGET_CONCEPTS, hasDefiningColumn, hasSensitiveColumns, matchesConcept, requiredFieldsFor, scoreConcepts, scoreFieldMap, scoreRelationships, suggestCursorField, suggestDiscriminatorColumns, toFieldMap, topConcept, validateMapping };
544
+ export { TARGET_CONCEPTS, hasDefiningColumn, hasSensitiveColumns, isFrameworkTable, matchesConcept, requiredFieldsFor, scoreConcepts, scoreFieldMap, scoreRelationships, suggestCursorField, suggestDiscriminatorColumns, toFieldMap, topConcept, validateMapping };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clivly/core",
3
- "version": "0.10.6",
3
+ "version": "0.10.7",
4
4
  "private": false,
5
5
  "description": "ORM/auth-agnostic CRM adapter contracts and shared domain types for Clivly.",
6
6
  "license": "MIT",