@dyrected/core 2.0.0 → 2.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/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
- import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './index-RylhgOwj.cjs';
2
- export { A as AccessFunction, a as AdminConfig, B as Block, b as DatabaseAdapter, F as Field, c as FieldHook, d as FieldType, e as FileData, H as HookFunction, I as ImageService, P as PaginatedResult, S as StorageAdapter, U as UploadConfig } from './index-RylhgOwj.cjs';
1
+ import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './app-KApbf4XL.cjs';
2
+ export { A as AccessFunction, a as AdminConfig, B as Block, b as DatabaseAdapter, c as DyrectedContext, F as Field, d as FieldHook, e as FieldType, f as FileData, H as HookFunction, I as ImageService, P as PaginatedResult, S as StorageAdapter, U as UploadConfig, g as createDyrectedApp } from './app-KApbf4XL.cjs';
3
+ import 'hono/types';
4
+ import 'hono';
3
5
 
4
6
  interface SetupPromptConfig {
5
7
  siteName?: string;
@@ -7,7 +9,9 @@ interface SetupPromptConfig {
7
9
  apiKey?: string;
8
10
  baseUrl?: string;
9
11
  isSelfHosted?: boolean;
12
+ existingSite?: boolean;
10
13
  }
14
+ declare function generateFreshSetupPrompt(activeTab: "next" | "nuxt" | "react" | "vue", config: SetupPromptConfig): string;
11
15
  declare function generateAIPrompt(activeTab: "next" | "nuxt" | "react" | "vue", config: SetupPromptConfig): string;
12
16
 
13
17
  /**
@@ -17,6 +21,69 @@ declare function generateAIPrompt(activeTab: "next" | "nuxt" | "react" | "vue",
17
21
  */
18
22
  declare function normalizeConfig(config: DyrectedConfig): DyrectedConfig;
19
23
 
24
+ /**
25
+ * Dyrected Where Clause DSL — shared query language across all database adapters.
26
+ *
27
+ * Adapters translate this DSL into their native format:
28
+ * - SQL adapters (SQLite, Postgres, MySQL): use parseSqlWhere()
29
+ * - MongoDB adapter: use parseMongoWhere()
30
+ * - Future adapters: implement their own translator against WhereClause
31
+ *
32
+ * Exhaustive operator handling is enforced at compile time via `assertNever`,
33
+ * so adding a new operator without handling it will produce a TypeScript error
34
+ * in every adapter translator.
35
+ */
36
+ type WhereOperatorName = 'equals' | 'not_equals' | 'in' | 'not_in' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'starts_with' | 'exists';
37
+ type WhereOperator = {
38
+ equals: any;
39
+ } | {
40
+ not_equals: any;
41
+ } | {
42
+ in: any[];
43
+ } | {
44
+ not_in: any[];
45
+ } | {
46
+ gt: any;
47
+ } | {
48
+ gte: any;
49
+ } | {
50
+ lt: any;
51
+ } | {
52
+ lte: any;
53
+ } | {
54
+ contains: string;
55
+ } | {
56
+ starts_with: string;
57
+ } | {
58
+ exists: boolean;
59
+ };
60
+ /** Top-level where clause. Fields map to operator objects or shorthand scalar values. */
61
+ type WhereClause = {
62
+ [field: string]: WhereOperator | any;
63
+ OR?: WhereClause[];
64
+ AND?: WhereClause[];
65
+ };
66
+ interface SqlWhereResult {
67
+ sql: string;
68
+ params: any[];
69
+ }
70
+ /**
71
+ * Translates a WhereClause into a parameterized SQL WHERE fragment.
72
+ *
73
+ * @param where The Dyrected where DSL object
74
+ * @param getJsonField Returns the SQL expression for a JSON-stored field (dialect-specific):
75
+ * SQLite: (f) => `json_extract(data, '$.${f}')`
76
+ * Postgres: (f) => `data->>'${f}'`
77
+ * MySQL: (f) => `JSON_UNQUOTE(JSON_EXTRACT(data, '$.${f}'))`
78
+ * @param placeholder '?' for SQLite/MySQL, 'pg' for auto-incrementing Postgres $1/$2/…
79
+ */
80
+ declare function parseSqlWhere(where: WhereClause, getJsonField: (field: string) => string, placeholder?: '?' | 'pg'): SqlWhereResult;
81
+ /**
82
+ * Translates a WhereClause into a MongoDB filter object.
83
+ * Handles nested OR/AND via $or/$and, and all operators via $eq/$in/$gt etc.
84
+ */
85
+ declare function parseMongoWhere(where: WhereClause): Record<string, any>;
86
+
20
87
  /**
21
88
  * Define a collection configuration with full type safety.
22
89
  */
@@ -30,4 +97,4 @@ declare function defineGlobal(config: GlobalConfig): GlobalConfig;
30
97
  */
31
98
  declare function defineConfig(config: DyrectedConfig): DyrectedConfig;
32
99
 
33
- export { CollectionConfig, DyrectedConfig, GlobalConfig, type SetupPromptConfig, defineCollection, defineConfig, defineGlobal, generateAIPrompt, normalizeConfig };
100
+ export { CollectionConfig, DyrectedConfig, GlobalConfig, type SetupPromptConfig, type SqlWhereResult, type WhereClause, type WhereOperator, type WhereOperatorName, defineCollection, defineConfig, defineGlobal, generateAIPrompt, generateFreshSetupPrompt, normalizeConfig, parseMongoWhere, parseSqlWhere };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './index-RylhgOwj.js';
2
- export { A as AccessFunction, a as AdminConfig, B as Block, b as DatabaseAdapter, F as Field, c as FieldHook, d as FieldType, e as FileData, H as HookFunction, I as ImageService, P as PaginatedResult, S as StorageAdapter, U as UploadConfig } from './index-RylhgOwj.js';
1
+ import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './app-KApbf4XL.js';
2
+ export { A as AccessFunction, a as AdminConfig, B as Block, b as DatabaseAdapter, c as DyrectedContext, F as Field, d as FieldHook, e as FieldType, f as FileData, H as HookFunction, I as ImageService, P as PaginatedResult, S as StorageAdapter, U as UploadConfig, g as createDyrectedApp } from './app-KApbf4XL.js';
3
+ import 'hono/types';
4
+ import 'hono';
3
5
 
4
6
  interface SetupPromptConfig {
5
7
  siteName?: string;
@@ -7,7 +9,9 @@ interface SetupPromptConfig {
7
9
  apiKey?: string;
8
10
  baseUrl?: string;
9
11
  isSelfHosted?: boolean;
12
+ existingSite?: boolean;
10
13
  }
14
+ declare function generateFreshSetupPrompt(activeTab: "next" | "nuxt" | "react" | "vue", config: SetupPromptConfig): string;
11
15
  declare function generateAIPrompt(activeTab: "next" | "nuxt" | "react" | "vue", config: SetupPromptConfig): string;
12
16
 
13
17
  /**
@@ -17,6 +21,69 @@ declare function generateAIPrompt(activeTab: "next" | "nuxt" | "react" | "vue",
17
21
  */
18
22
  declare function normalizeConfig(config: DyrectedConfig): DyrectedConfig;
19
23
 
24
+ /**
25
+ * Dyrected Where Clause DSL — shared query language across all database adapters.
26
+ *
27
+ * Adapters translate this DSL into their native format:
28
+ * - SQL adapters (SQLite, Postgres, MySQL): use parseSqlWhere()
29
+ * - MongoDB adapter: use parseMongoWhere()
30
+ * - Future adapters: implement their own translator against WhereClause
31
+ *
32
+ * Exhaustive operator handling is enforced at compile time via `assertNever`,
33
+ * so adding a new operator without handling it will produce a TypeScript error
34
+ * in every adapter translator.
35
+ */
36
+ type WhereOperatorName = 'equals' | 'not_equals' | 'in' | 'not_in' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'starts_with' | 'exists';
37
+ type WhereOperator = {
38
+ equals: any;
39
+ } | {
40
+ not_equals: any;
41
+ } | {
42
+ in: any[];
43
+ } | {
44
+ not_in: any[];
45
+ } | {
46
+ gt: any;
47
+ } | {
48
+ gte: any;
49
+ } | {
50
+ lt: any;
51
+ } | {
52
+ lte: any;
53
+ } | {
54
+ contains: string;
55
+ } | {
56
+ starts_with: string;
57
+ } | {
58
+ exists: boolean;
59
+ };
60
+ /** Top-level where clause. Fields map to operator objects or shorthand scalar values. */
61
+ type WhereClause = {
62
+ [field: string]: WhereOperator | any;
63
+ OR?: WhereClause[];
64
+ AND?: WhereClause[];
65
+ };
66
+ interface SqlWhereResult {
67
+ sql: string;
68
+ params: any[];
69
+ }
70
+ /**
71
+ * Translates a WhereClause into a parameterized SQL WHERE fragment.
72
+ *
73
+ * @param where The Dyrected where DSL object
74
+ * @param getJsonField Returns the SQL expression for a JSON-stored field (dialect-specific):
75
+ * SQLite: (f) => `json_extract(data, '$.${f}')`
76
+ * Postgres: (f) => `data->>'${f}'`
77
+ * MySQL: (f) => `JSON_UNQUOTE(JSON_EXTRACT(data, '$.${f}'))`
78
+ * @param placeholder '?' for SQLite/MySQL, 'pg' for auto-incrementing Postgres $1/$2/…
79
+ */
80
+ declare function parseSqlWhere(where: WhereClause, getJsonField: (field: string) => string, placeholder?: '?' | 'pg'): SqlWhereResult;
81
+ /**
82
+ * Translates a WhereClause into a MongoDB filter object.
83
+ * Handles nested OR/AND via $or/$and, and all operators via $eq/$in/$gt etc.
84
+ */
85
+ declare function parseMongoWhere(where: WhereClause): Record<string, any>;
86
+
20
87
  /**
21
88
  * Define a collection configuration with full type safety.
22
89
  */
@@ -30,4 +97,4 @@ declare function defineGlobal(config: GlobalConfig): GlobalConfig;
30
97
  */
31
98
  declare function defineConfig(config: DyrectedConfig): DyrectedConfig;
32
99
 
33
- export { CollectionConfig, DyrectedConfig, GlobalConfig, type SetupPromptConfig, defineCollection, defineConfig, defineGlobal, generateAIPrompt, normalizeConfig };
100
+ export { CollectionConfig, DyrectedConfig, GlobalConfig, type SetupPromptConfig, type SqlWhereResult, type WhereClause, type WhereOperator, type WhereOperatorName, defineCollection, defineConfig, defineGlobal, generateAIPrompt, generateFreshSetupPrompt, normalizeConfig, parseMongoWhere, parseSqlWhere };